hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
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,65 @@
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
+struct arm_smccc_res sip_smc_get_pvtpll_info(u32 sub_func_id, u32 arg1)
287
+{
288
+ struct arm_smccc_res res;
289
+
290
+ /*
291
+ * res.a0: error code(0: success, !0: error).
292
+ * res.a1: low temp config flag(0: support, !0: don't support).
293
+ */
294
+ arm_smccc_smc(SIP_PVTPLL_CFG, sub_func_id, arg1, 0, 0, 0, 0, 0, &res);
295
+ return res;
296
+}
297
+EXPORT_SYMBOL_GPL(sip_smc_get_pvtpll_info);
298
+
299
+struct arm_smccc_res sip_smc_pvtpll_config(u32 sub_func_id, u32 arg1, u32 arg2,
300
+ u32 arg3, u32 arg4, u32 arg5, u32 arg6)
301
+{
302
+ struct arm_smccc_res res;
303
+
304
+ /*
305
+ * res.a0: error code(0: success, !0: error).
306
+ */
307
+ arm_smccc_smc(SIP_PVTPLL_CFG, sub_func_id, arg1, arg2, arg3, arg4, arg5,
308
+ arg6, &res);
309
+ return res;
310
+}
311
+EXPORT_SYMBOL_GPL(sip_smc_pvtpll_config);
312
+
313
+void __iomem *sip_hdcp_request_share_memory(int id)
314
+{
315
+ static void __iomem *base;
316
+ struct arm_smccc_res res;
317
+
318
+ if (id < 0 || id >= MAX_DEVICE) {
319
+ pr_err("%s: invalid device id\n", __func__);
320
+ return NULL;
321
+ }
322
+
323
+ if (!base) {
324
+ /* request page share memory */
325
+ res = sip_smc_request_share_mem(2, SHARE_PAGE_TYPE_HDCP);
326
+ if (IS_SIP_ERROR(res.a0))
327
+ return NULL;
328
+ base = (void __iomem *)res.a1;
329
+ }
330
+
331
+ return base + id * 1024;
332
+}
333
+EXPORT_SYMBOL_GPL(sip_hdcp_request_share_memory);
334
+
335
+struct arm_smccc_res sip_hdcp_config(u32 arg0, u32 arg1, u32 arg2)
336
+{
337
+ struct arm_smccc_res res;
338
+
339
+ res = __invoke_sip_fn_smc(SIP_HDCP_CONFIG, arg0, arg1, arg2);
340
+ return res;
341
+}
342
+EXPORT_SYMBOL_GPL(sip_hdcp_config);
284343
285344 /************************** fiq debugger **************************************/
286345 /*
....@@ -300,8 +359,7 @@
300359 static int fiq_target_cpu;
301360 static phys_addr_t ft_fiq_mem_phy;
302361 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);
362
+static sip_fiq_debugger_uart_irq_tf_cb_t sip_fiq_debugger_uart_irq_tf;
305363 static struct pt_regs fiq_pt_regs;
306364
307365 int sip_fiq_debugger_is_enabled(void)
....@@ -388,7 +446,7 @@
388446
389447 static void sip_fiq_debugger_uart_irq_tf_cb(unsigned long sp_el1,
390448 unsigned long offset,
391
- uint32_t cpu)
449
+ unsigned long cpu)
392450 {
393451 char *cpu_context;
394452
....@@ -403,9 +461,11 @@
403461 __invoke_sip_fn_smc(SIP_UARTDBG_FN, 0, 0, UARTDBG_CFG_OSHDL_TO_OS);
404462 }
405463
406
-int sip_fiq_debugger_uart_irq_tf_init(u32 irq_id, void *callback_fn)
464
+int sip_fiq_debugger_uart_irq_tf_init(u32 irq_id, sip_fiq_debugger_uart_irq_tf_cb_t callback_fn)
407465 {
408466 struct arm_smccc_res res;
467
+
468
+ fiq_target_cpu = 0;
409469
410470 /* init fiq debugger callback */
411471 sip_fiq_debugger_uart_irq_tf = callback_fn;
....@@ -438,22 +498,33 @@
438498 {
439499 #ifdef MODULE
440500 /* Empirically, local "cpu_logical_map()" for rockchip platforms */
441
- ulong mpidr = 0x00;
501
+ ulong mpidr = read_cpuid_mpidr();
442502
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);
503
+ if (mpidr & MPIDR_MT_BITMASK) {
504
+ /* 0x100, 0x200, 0x300, 0x400 ... */
505
+ mpidr = (cpu & 0xff) << 8;
506
+ } else {
507
+ if (cpu < 4)
508
+ /* 0x00, 0x01, 0x02, 0x03 */
509
+ mpidr = cpu;
510
+ else if (cpu < 8)
511
+ /* 0x100, 0x101, 0x102, 0x103 */
512
+ mpidr = 0x100 | (cpu - 4);
513
+ else
514
+ pr_err("Unsupported map cpu: %d\n", cpu);
515
+ }
451516
452517 return mpidr;
453518 #else
454519 return cpu_logical_map(cpu);
455520 #endif
456521 }
522
+
523
+ulong sip_cpu_logical_map_mpidr(u32 cpu)
524
+{
525
+ return cpu_logical_map_mpidr(cpu);
526
+}
527
+EXPORT_SYMBOL_GPL(sip_cpu_logical_map_mpidr);
457528
458529 int sip_fiq_debugger_switch_cpu(u32 cpu)
459530 {
....@@ -541,6 +612,58 @@
541612 }
542613 EXPORT_SYMBOL_GPL(sip_fiq_debugger_enable_fiq);
543614
615
+int sip_fiq_control(u32 sub_func, u32 irq, unsigned long data)
616
+{
617
+ struct arm_smccc_res res;
618
+
619
+ res = __invoke_sip_fn_smc(RK_SIP_FIQ_CTRL,
620
+ sub_func, irq, data);
621
+ return res.a0;
622
+}
623
+EXPORT_SYMBOL_GPL(sip_fiq_control);
624
+
625
+int sip_wdt_config(u32 sub_func, u32 arg1, u32 arg2, u32 arg3)
626
+{
627
+ struct arm_smccc_res res;
628
+
629
+ arm_smccc_smc(SIP_WDT_CFG, sub_func, arg1, arg2, arg3,
630
+ 0, 0, 0, &res);
631
+
632
+ return res.a0;
633
+}
634
+EXPORT_SYMBOL_GPL(sip_wdt_config);
635
+
636
+int sip_hdmirx_config(u32 sub_func, u32 arg1, u32 arg2, u32 arg3)
637
+{
638
+ struct arm_smccc_res res;
639
+
640
+ arm_smccc_smc(SIP_HDMIRX_CFG, sub_func, arg1, arg2, arg3,
641
+ 0, 0, 0, &res);
642
+
643
+ return res.a0;
644
+}
645
+EXPORT_SYMBOL_GPL(sip_hdmirx_config);
646
+
647
+int sip_hdcpkey_init(u32 hdcp_id)
648
+{
649
+ struct arm_smccc_res res;
650
+
651
+ res = __invoke_sip_fn_smc(TRUSTED_OS_HDCPKEY_INIT, hdcp_id, 0, 0);
652
+
653
+ return res.a0;
654
+}
655
+EXPORT_SYMBOL_GPL(sip_hdcpkey_init);
656
+
657
+int sip_smc_mcu_config(unsigned long mcu_id,
658
+ unsigned long func,
659
+ unsigned long arg2)
660
+{
661
+ struct arm_smccc_res res;
662
+
663
+ res = __invoke_sip_fn_smc(SIP_MCU_CFG, mcu_id, func, arg2);
664
+ return res.a0;
665
+}
666
+EXPORT_SYMBOL_GPL(sip_smc_mcu_config);
544667 /******************************************************************************/
545668 #ifdef CONFIG_ARM
546669 static __init int sip_firmware_init(void)