From 95099d4622f8cb224d94e314c7a8e0df60b13f87 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Sat, 09 Dec 2023 08:38:01 +0000
Subject: [PATCH] enable docker ppp
---
kernel/drivers/firmware/rockchip_sip.c | 130 +++++++++++++++++++++++++++++++++----------
1 files changed, 99 insertions(+), 31 deletions(-)
diff --git a/kernel/drivers/firmware/rockchip_sip.c b/kernel/drivers/firmware/rockchip_sip.c
index 7f2073c..186011f 100644
--- a/kernel/drivers/firmware/rockchip_sip.c
+++ b/kernel/drivers/firmware/rockchip_sip.c
@@ -262,6 +262,7 @@
return res;
}
+EXPORT_SYMBOL_GPL(sip_smc_lastlog_request);
int sip_smc_amp_config(u32 sub_func_id, u32 arg1, u32 arg2, u32 arg3)
{
@@ -271,6 +272,7 @@
0, 0, 0, &res);
return res.a0;
}
+EXPORT_SYMBOL_GPL(sip_smc_amp_config);
struct arm_smccc_res sip_smc_get_amp_info(u32 sub_func_id, u32 arg1)
{
@@ -279,8 +281,38 @@
arm_smccc_smc(RK_SIP_AMP_CFG, sub_func_id, arg1, 0, 0, 0, 0, 0, &res);
return res;
}
+EXPORT_SYMBOL_GPL(sip_smc_get_amp_info);
-EXPORT_SYMBOL_GPL(sip_smc_lastlog_request);
+void __iomem *sip_hdcp_request_share_memory(int id)
+{
+ static void __iomem *base;
+ struct arm_smccc_res res;
+
+ if (id < 0 || id >= MAX_DEVICE) {
+ pr_err("%s: invalid device id\n", __func__);
+ return NULL;
+ }
+
+ if (!base) {
+ /* request page share memory */
+ res = sip_smc_request_share_mem(2, SHARE_PAGE_TYPE_HDCP);
+ if (IS_SIP_ERROR(res.a0))
+ return NULL;
+ base = (void __iomem *)res.a1;
+ }
+
+ return base + id * 1024;
+}
+EXPORT_SYMBOL_GPL(sip_hdcp_request_share_memory);
+
+struct arm_smccc_res sip_hdcp_config(u32 arg0, u32 arg1, u32 arg2)
+{
+ struct arm_smccc_res res;
+
+ res = __invoke_sip_fn_smc(SIP_HDCP_CONFIG, arg0, arg1, arg2);
+ return res;
+}
+EXPORT_SYMBOL_GPL(sip_hdcp_config);
/************************** fiq debugger **************************************/
/*
@@ -291,17 +323,13 @@
*/
#ifdef CONFIG_ARM64
#define SIP_UARTDBG_FN SIP_UARTDBG_CFG64
-#define SIP_FIQ_DBG_STACK_SIZE IRQ_STACK_SIZE
#else
#define SIP_UARTDBG_FN SIP_UARTDBG_CFG
-#define SIP_FIQ_DBG_STACK_SIZE SZ_8K
-
static int firmware_64_32bit;
#endif
static int fiq_sip_enabled;
static int fiq_target_cpu;
-static unsigned long fiq_stack_top;
static phys_addr_t ft_fiq_mem_phy;
static void __iomem *ft_fiq_mem_base;
static sip_fiq_debugger_uart_irq_tf_cb_t sip_fiq_debugger_uart_irq_tf;
@@ -410,26 +438,13 @@
{
struct arm_smccc_res res;
- /* Alloc a page for fiq_debugger's stack */
- if (fiq_stack_top == 0) {
- fiq_stack_top = __get_free_pages(GFP_KERNEL | __GFP_ZERO,
- get_order(SIP_FIQ_DBG_STACK_SIZE));
- if (fiq_stack_top) {
- fiq_stack_top += SIP_FIQ_DBG_STACK_SIZE;
- } else {
- pr_err("%s: alloc stack failed\n", __func__);
- return -ENOMEM;
- }
- }
+ fiq_target_cpu = 0;
/* init fiq debugger callback */
sip_fiq_debugger_uart_irq_tf = callback_fn;
- arm_smccc_smc(SIP_UARTDBG_FN,
- irq_id,
- (unsigned long)sip_fiq_debugger_uart_irq_tf_cb,
- UARTDBG_CFG_INIT,
- fiq_stack_top, 0, 0, 0, &res);
-
+ res = __invoke_sip_fn_smc(SIP_UARTDBG_FN, irq_id,
+ (unsigned long)sip_fiq_debugger_uart_irq_tf_cb,
+ UARTDBG_CFG_INIT);
if (IS_SIP_ERROR(res.a0)) {
pr_err("%s error: %d\n", __func__, (int)res.a0);
return res.a0;
@@ -456,22 +471,33 @@
{
#ifdef MODULE
/* Empirically, local "cpu_logical_map()" for rockchip platforms */
- ulong mpidr = 0x00;
+ ulong mpidr = read_cpuid_mpidr();
- if (cpu < 4)
- /* 0x00, 0x01, 0x02, 0x03 */
- mpidr = cpu;
- else if (cpu < 8)
- /* 0x100, 0x101, 0x102, 0x103 */
- mpidr = 0x100 | (cpu - 4);
- else
- pr_err("Unsupported map cpu: %d\n", cpu);
+ if (mpidr & MPIDR_MT_BITMASK) {
+ /* 0x100, 0x200, 0x300, 0x400 ... */
+ mpidr = (cpu & 0xff) << 8;
+ } else {
+ if (cpu < 4)
+ /* 0x00, 0x01, 0x02, 0x03 */
+ mpidr = cpu;
+ else if (cpu < 8)
+ /* 0x100, 0x101, 0x102, 0x103 */
+ mpidr = 0x100 | (cpu - 4);
+ else
+ pr_err("Unsupported map cpu: %d\n", cpu);
+ }
return mpidr;
#else
return cpu_logical_map(cpu);
#endif
}
+
+ulong sip_cpu_logical_map_mpidr(u32 cpu)
+{
+ return cpu_logical_map_mpidr(cpu);
+}
+EXPORT_SYMBOL_GPL(sip_cpu_logical_map_mpidr);
int sip_fiq_debugger_switch_cpu(u32 cpu)
{
@@ -559,6 +585,48 @@
}
EXPORT_SYMBOL_GPL(sip_fiq_debugger_enable_fiq);
+int sip_fiq_control(u32 sub_func, u32 irq, unsigned long data)
+{
+ struct arm_smccc_res res;
+
+ res = __invoke_sip_fn_smc(RK_SIP_FIQ_CTRL,
+ sub_func, irq, data);
+ return res.a0;
+}
+EXPORT_SYMBOL_GPL(sip_fiq_control);
+
+int sip_wdt_config(u32 sub_func, u32 arg1, u32 arg2, u32 arg3)
+{
+ struct arm_smccc_res res;
+
+ arm_smccc_smc(SIP_WDT_CFG, sub_func, arg1, arg2, arg3,
+ 0, 0, 0, &res);
+
+ return res.a0;
+}
+EXPORT_SYMBOL_GPL(sip_wdt_config);
+
+int sip_hdmirx_config(u32 sub_func, u32 arg1, u32 arg2, u32 arg3)
+{
+ struct arm_smccc_res res;
+
+ arm_smccc_smc(SIP_HDMIRX_CFG, sub_func, arg1, arg2, arg3,
+ 0, 0, 0, &res);
+
+ return res.a0;
+}
+EXPORT_SYMBOL_GPL(sip_hdmirx_config);
+
+int sip_hdcpkey_init(u32 hdcp_id)
+{
+ struct arm_smccc_res res;
+
+ res = __invoke_sip_fn_smc(TRUSTED_OS_HDCPKEY_INIT, hdcp_id, 0, 0);
+
+ return res.a0;
+}
+EXPORT_SYMBOL_GPL(sip_hdcpkey_init);
+
/******************************************************************************/
#ifdef CONFIG_ARM
static __init int sip_firmware_init(void)
--
Gitblit v1.6.2