forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/drivers/firmware/rockchip_sip.c
....@@ -262,6 +262,7 @@
262262
263263 return res;
264264 }
265
+EXPORT_SYMBOL_GPL(sip_smc_lastlog_request);
265266
266267 int sip_smc_amp_config(u32 sub_func_id, u32 arg1, u32 arg2, u32 arg3)
267268 {
....@@ -271,6 +272,7 @@
271272 0, 0, 0, &res);
272273 return res.a0;
273274 }
275
+EXPORT_SYMBOL_GPL(sip_smc_amp_config);
274276
275277 struct arm_smccc_res sip_smc_get_amp_info(u32 sub_func_id, u32 arg1)
276278 {
....@@ -279,8 +281,38 @@
279281 arm_smccc_smc(RK_SIP_AMP_CFG, sub_func_id, arg1, 0, 0, 0, 0, 0, &res);
280282 return res;
281283 }
284
+EXPORT_SYMBOL_GPL(sip_smc_get_amp_info);
282285
283
-EXPORT_SYMBOL_GPL(sip_smc_lastlog_request);
286
+void __iomem *sip_hdcp_request_share_memory(int id)
287
+{
288
+ static void __iomem *base;
289
+ struct arm_smccc_res res;
290
+
291
+ if (id < 0 || id >= MAX_DEVICE) {
292
+ pr_err("%s: invalid device id\n", __func__);
293
+ return NULL;
294
+ }
295
+
296
+ if (!base) {
297
+ /* request page share memory */
298
+ res = sip_smc_request_share_mem(2, SHARE_PAGE_TYPE_HDCP);
299
+ if (IS_SIP_ERROR(res.a0))
300
+ return NULL;
301
+ base = (void __iomem *)res.a1;
302
+ }
303
+
304
+ return base + id * 1024;
305
+}
306
+EXPORT_SYMBOL_GPL(sip_hdcp_request_share_memory);
307
+
308
+struct arm_smccc_res sip_hdcp_config(u32 arg0, u32 arg1, u32 arg2)
309
+{
310
+ struct arm_smccc_res res;
311
+
312
+ res = __invoke_sip_fn_smc(SIP_HDCP_CONFIG, arg0, arg1, arg2);
313
+ return res;
314
+}
315
+EXPORT_SYMBOL_GPL(sip_hdcp_config);
284316
285317 /************************** fiq debugger **************************************/
286318 /*
....@@ -300,8 +332,7 @@
300332 static int fiq_target_cpu;
301333 static phys_addr_t ft_fiq_mem_phy;
302334 static void __iomem *ft_fiq_mem_base;
303
-static void (*sip_fiq_debugger_uart_irq_tf)(struct pt_regs *_pt_regs,
304
- uint32_t cpu);
335
+static sip_fiq_debugger_uart_irq_tf_cb_t sip_fiq_debugger_uart_irq_tf;
305336 static struct pt_regs fiq_pt_regs;
306337
307338 int sip_fiq_debugger_is_enabled(void)
....@@ -388,7 +419,7 @@
388419
389420 static void sip_fiq_debugger_uart_irq_tf_cb(unsigned long sp_el1,
390421 unsigned long offset,
391
- uint32_t cpu)
422
+ unsigned long cpu)
392423 {
393424 char *cpu_context;
394425
....@@ -403,9 +434,11 @@
403434 __invoke_sip_fn_smc(SIP_UARTDBG_FN, 0, 0, UARTDBG_CFG_OSHDL_TO_OS);
404435 }
405436
406
-int sip_fiq_debugger_uart_irq_tf_init(u32 irq_id, void *callback_fn)
437
+int sip_fiq_debugger_uart_irq_tf_init(u32 irq_id, sip_fiq_debugger_uart_irq_tf_cb_t callback_fn)
407438 {
408439 struct arm_smccc_res res;
440
+
441
+ fiq_target_cpu = 0;
409442
410443 /* init fiq debugger callback */
411444 sip_fiq_debugger_uart_irq_tf = callback_fn;
....@@ -438,22 +471,33 @@
438471 {
439472 #ifdef MODULE
440473 /* Empirically, local "cpu_logical_map()" for rockchip platforms */
441
- ulong mpidr = 0x00;
474
+ ulong mpidr = read_cpuid_mpidr();
442475
443
- if (cpu < 4)
444
- /* 0x00, 0x01, 0x02, 0x03 */
445
- mpidr = cpu;
446
- else if (cpu < 8)
447
- /* 0x100, 0x101, 0x102, 0x103 */
448
- mpidr = 0x100 | (cpu - 4);
449
- else
450
- pr_err("Unsupported map cpu: %d\n", cpu);
476
+ if (mpidr & MPIDR_MT_BITMASK) {
477
+ /* 0x100, 0x200, 0x300, 0x400 ... */
478
+ mpidr = (cpu & 0xff) << 8;
479
+ } else {
480
+ if (cpu < 4)
481
+ /* 0x00, 0x01, 0x02, 0x03 */
482
+ mpidr = cpu;
483
+ else if (cpu < 8)
484
+ /* 0x100, 0x101, 0x102, 0x103 */
485
+ mpidr = 0x100 | (cpu - 4);
486
+ else
487
+ pr_err("Unsupported map cpu: %d\n", cpu);
488
+ }
451489
452490 return mpidr;
453491 #else
454492 return cpu_logical_map(cpu);
455493 #endif
456494 }
495
+
496
+ulong sip_cpu_logical_map_mpidr(u32 cpu)
497
+{
498
+ return cpu_logical_map_mpidr(cpu);
499
+}
500
+EXPORT_SYMBOL_GPL(sip_cpu_logical_map_mpidr);
457501
458502 int sip_fiq_debugger_switch_cpu(u32 cpu)
459503 {
....@@ -541,6 +585,48 @@
541585 }
542586 EXPORT_SYMBOL_GPL(sip_fiq_debugger_enable_fiq);
543587
588
+int sip_fiq_control(u32 sub_func, u32 irq, unsigned long data)
589
+{
590
+ struct arm_smccc_res res;
591
+
592
+ res = __invoke_sip_fn_smc(RK_SIP_FIQ_CTRL,
593
+ sub_func, irq, data);
594
+ return res.a0;
595
+}
596
+EXPORT_SYMBOL_GPL(sip_fiq_control);
597
+
598
+int sip_wdt_config(u32 sub_func, u32 arg1, u32 arg2, u32 arg3)
599
+{
600
+ struct arm_smccc_res res;
601
+
602
+ arm_smccc_smc(SIP_WDT_CFG, sub_func, arg1, arg2, arg3,
603
+ 0, 0, 0, &res);
604
+
605
+ return res.a0;
606
+}
607
+EXPORT_SYMBOL_GPL(sip_wdt_config);
608
+
609
+int sip_hdmirx_config(u32 sub_func, u32 arg1, u32 arg2, u32 arg3)
610
+{
611
+ struct arm_smccc_res res;
612
+
613
+ arm_smccc_smc(SIP_HDMIRX_CFG, sub_func, arg1, arg2, arg3,
614
+ 0, 0, 0, &res);
615
+
616
+ return res.a0;
617
+}
618
+EXPORT_SYMBOL_GPL(sip_hdmirx_config);
619
+
620
+int sip_hdcpkey_init(u32 hdcp_id)
621
+{
622
+ struct arm_smccc_res res;
623
+
624
+ res = __invoke_sip_fn_smc(TRUSTED_OS_HDCPKEY_INIT, hdcp_id, 0, 0);
625
+
626
+ return res.a0;
627
+}
628
+EXPORT_SYMBOL_GPL(sip_hdcpkey_init);
629
+
544630 /******************************************************************************/
545631 #ifdef CONFIG_ARM
546632 static __init int sip_firmware_init(void)