.. | .. |
---|
262 | 262 | |
---|
263 | 263 | return res; |
---|
264 | 264 | } |
---|
| 265 | +EXPORT_SYMBOL_GPL(sip_smc_lastlog_request); |
---|
265 | 266 | |
---|
266 | 267 | int sip_smc_amp_config(u32 sub_func_id, u32 arg1, u32 arg2, u32 arg3) |
---|
267 | 268 | { |
---|
.. | .. |
---|
271 | 272 | 0, 0, 0, &res); |
---|
272 | 273 | return res.a0; |
---|
273 | 274 | } |
---|
| 275 | +EXPORT_SYMBOL_GPL(sip_smc_amp_config); |
---|
274 | 276 | |
---|
275 | 277 | struct arm_smccc_res sip_smc_get_amp_info(u32 sub_func_id, u32 arg1) |
---|
276 | 278 | { |
---|
.. | .. |
---|
279 | 281 | arm_smccc_smc(RK_SIP_AMP_CFG, sub_func_id, arg1, 0, 0, 0, 0, 0, &res); |
---|
280 | 282 | return res; |
---|
281 | 283 | } |
---|
| 284 | +EXPORT_SYMBOL_GPL(sip_smc_get_amp_info); |
---|
282 | 285 | |
---|
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); |
---|
284 | 316 | |
---|
285 | 317 | /************************** fiq debugger **************************************/ |
---|
286 | 318 | /* |
---|
.. | .. |
---|
291 | 323 | */ |
---|
292 | 324 | #ifdef CONFIG_ARM64 |
---|
293 | 325 | #define SIP_UARTDBG_FN SIP_UARTDBG_CFG64 |
---|
294 | | -#define SIP_FIQ_DBG_STACK_SIZE IRQ_STACK_SIZE |
---|
295 | 326 | #else |
---|
296 | 327 | #define SIP_UARTDBG_FN SIP_UARTDBG_CFG |
---|
297 | | -#define SIP_FIQ_DBG_STACK_SIZE SZ_8K |
---|
298 | | - |
---|
299 | 328 | static int firmware_64_32bit; |
---|
300 | 329 | #endif |
---|
301 | 330 | |
---|
302 | 331 | static int fiq_sip_enabled; |
---|
303 | 332 | static int fiq_target_cpu; |
---|
304 | | -static unsigned long fiq_stack_top; |
---|
305 | 333 | static phys_addr_t ft_fiq_mem_phy; |
---|
306 | 334 | static void __iomem *ft_fiq_mem_base; |
---|
307 | 335 | static sip_fiq_debugger_uart_irq_tf_cb_t sip_fiq_debugger_uart_irq_tf; |
---|
.. | .. |
---|
410 | 438 | { |
---|
411 | 439 | struct arm_smccc_res res; |
---|
412 | 440 | |
---|
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 | | - } |
---|
| 441 | + fiq_target_cpu = 0; |
---|
424 | 442 | |
---|
425 | 443 | /* init fiq debugger callback */ |
---|
426 | 444 | 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 | | - |
---|
| 445 | + res = __invoke_sip_fn_smc(SIP_UARTDBG_FN, irq_id, |
---|
| 446 | + (unsigned long)sip_fiq_debugger_uart_irq_tf_cb, |
---|
| 447 | + UARTDBG_CFG_INIT); |
---|
433 | 448 | if (IS_SIP_ERROR(res.a0)) { |
---|
434 | 449 | pr_err("%s error: %d\n", __func__, (int)res.a0); |
---|
435 | 450 | return res.a0; |
---|
.. | .. |
---|
456 | 471 | { |
---|
457 | 472 | #ifdef MODULE |
---|
458 | 473 | /* Empirically, local "cpu_logical_map()" for rockchip platforms */ |
---|
459 | | - ulong mpidr = 0x00; |
---|
| 474 | + ulong mpidr = read_cpuid_mpidr(); |
---|
460 | 475 | |
---|
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); |
---|
| 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 | + } |
---|
469 | 489 | |
---|
470 | 490 | return mpidr; |
---|
471 | 491 | #else |
---|
472 | 492 | return cpu_logical_map(cpu); |
---|
473 | 493 | #endif |
---|
474 | 494 | } |
---|
| 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); |
---|
475 | 501 | |
---|
476 | 502 | int sip_fiq_debugger_switch_cpu(u32 cpu) |
---|
477 | 503 | { |
---|
.. | .. |
---|
559 | 585 | } |
---|
560 | 586 | EXPORT_SYMBOL_GPL(sip_fiq_debugger_enable_fiq); |
---|
561 | 587 | |
---|
| 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 | + |
---|
| 630 | +int sip_smc_mcu_config(unsigned long mcu_id, |
---|
| 631 | + unsigned long func, |
---|
| 632 | + unsigned long arg2) |
---|
| 633 | +{ |
---|
| 634 | + struct arm_smccc_res res; |
---|
| 635 | + |
---|
| 636 | + res = __invoke_sip_fn_smc(SIP_MCU_CFG, mcu_id, func, arg2); |
---|
| 637 | + return res.a0; |
---|
| 638 | +} |
---|
| 639 | +EXPORT_SYMBOL_GPL(sip_smc_mcu_config); |
---|
562 | 640 | /******************************************************************************/ |
---|
563 | 641 | #ifdef CONFIG_ARM |
---|
564 | 642 | static __init int sip_firmware_init(void) |
---|