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 /*
....@@ -291,17 +350,13 @@
291350 */
292351 #ifdef CONFIG_ARM64
293352 #define SIP_UARTDBG_FN SIP_UARTDBG_CFG64
294
-#define SIP_FIQ_DBG_STACK_SIZE IRQ_STACK_SIZE
295353 #else
296354 #define SIP_UARTDBG_FN SIP_UARTDBG_CFG
297
-#define SIP_FIQ_DBG_STACK_SIZE SZ_8K
298
-
299355 static int firmware_64_32bit;
300356 #endif
301357
302358 static int fiq_sip_enabled;
303359 static int fiq_target_cpu;
304
-static unsigned long fiq_stack_top;
305360 static phys_addr_t ft_fiq_mem_phy;
306361 static void __iomem *ft_fiq_mem_base;
307362 static sip_fiq_debugger_uart_irq_tf_cb_t sip_fiq_debugger_uart_irq_tf;
....@@ -410,26 +465,13 @@
410465 {
411466 struct arm_smccc_res res;
412467
413
- /* Alloc a page for fiq_debugger's stack */
414
- if (fiq_stack_top == 0) {
415
- fiq_stack_top = __get_free_pages(GFP_KERNEL | __GFP_ZERO,
416
- get_order(SIP_FIQ_DBG_STACK_SIZE));
417
- if (fiq_stack_top) {
418
- fiq_stack_top += SIP_FIQ_DBG_STACK_SIZE;
419
- } else {
420
- pr_err("%s: alloc stack failed\n", __func__);
421
- return -ENOMEM;
422
- }
423
- }
468
+ fiq_target_cpu = 0;
424469
425470 /* init fiq debugger callback */
426471 sip_fiq_debugger_uart_irq_tf = callback_fn;
427
- arm_smccc_smc(SIP_UARTDBG_FN,
428
- irq_id,
429
- (unsigned long)sip_fiq_debugger_uart_irq_tf_cb,
430
- UARTDBG_CFG_INIT,
431
- fiq_stack_top, 0, 0, 0, &res);
432
-
472
+ res = __invoke_sip_fn_smc(SIP_UARTDBG_FN, irq_id,
473
+ (unsigned long)sip_fiq_debugger_uart_irq_tf_cb,
474
+ UARTDBG_CFG_INIT);
433475 if (IS_SIP_ERROR(res.a0)) {
434476 pr_err("%s error: %d\n", __func__, (int)res.a0);
435477 return res.a0;
....@@ -456,22 +498,33 @@
456498 {
457499 #ifdef MODULE
458500 /* Empirically, local "cpu_logical_map()" for rockchip platforms */
459
- ulong mpidr = 0x00;
501
+ ulong mpidr = read_cpuid_mpidr();
460502
461
- if (cpu < 4)
462
- /* 0x00, 0x01, 0x02, 0x03 */
463
- mpidr = cpu;
464
- else if (cpu < 8)
465
- /* 0x100, 0x101, 0x102, 0x103 */
466
- mpidr = 0x100 | (cpu - 4);
467
- else
468
- 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
+ }
469516
470517 return mpidr;
471518 #else
472519 return cpu_logical_map(cpu);
473520 #endif
474521 }
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);
475528
476529 int sip_fiq_debugger_switch_cpu(u32 cpu)
477530 {
....@@ -559,6 +612,58 @@
559612 }
560613 EXPORT_SYMBOL_GPL(sip_fiq_debugger_enable_fiq);
561614
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);
562667 /******************************************************************************/
563668 #ifdef CONFIG_ARM
564669 static __init int sip_firmware_init(void)