Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Chandni Cherukuri | c8ef045 | 2018-10-04 16:32:03 +0530 | [diff] [blame] | 7 | #include <assert.h> |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 8 | #include <bl_common.h> |
| 9 | #include <debug.h> |
Chandni Cherukuri | c8ef045 | 2018-10-04 16:32:03 +0530 | [diff] [blame] | 10 | #include <libfdt.h> |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 11 | #include <plat_arm.h> |
Sughosh Ganu | 18f513d | 2018-05-16 17:22:35 +0530 | [diff] [blame] | 12 | #include <sgi_ras.h> |
Chandni Cherukuri | c8ef045 | 2018-10-04 16:32:03 +0530 | [diff] [blame] | 13 | #include <sgi_variant.h> |
Chandni Cherukuri | 61f3a7c | 2018-10-11 14:08:08 +0530 | [diff] [blame] | 14 | #include "../../css/drivers/scmi/scmi.h" |
| 15 | #include "../../css/drivers/mhu/css_mhu_doorbell.h" |
| 16 | |
Chandni Cherukuri | c8ef045 | 2018-10-04 16:32:03 +0530 | [diff] [blame] | 17 | sgi_platform_info_t sgi_plat_info; |
| 18 | |
Chandni Cherukuri | 61f3a7c | 2018-10-11 14:08:08 +0530 | [diff] [blame] | 19 | static scmi_channel_plat_info_t sgi575_scmi_plat_info = { |
| 20 | .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE, |
| 21 | .db_reg_addr = PLAT_CSS_MHU_BASE + CSS_SCMI_MHU_DB_REG_OFF, |
| 22 | .db_preserve_mask = 0xfffffffe, |
| 23 | .db_modify_mask = 0x1, |
| 24 | .ring_doorbell = &mhu_ring_doorbell, |
| 25 | }; |
| 26 | |
Chandni Cherukuri | c8ef045 | 2018-10-04 16:32:03 +0530 | [diff] [blame] | 27 | static scmi_channel_plat_info_t sgi_clark_scmi_plat_info = { |
| 28 | .scmi_mbx_mem = CSS_SCMI_PAYLOAD_BASE, |
| 29 | .db_reg_addr = PLAT_CSS_MHU_BASE + SENDER_REG_SET(0), |
| 30 | .db_preserve_mask = 0xfffffffe, |
| 31 | .db_modify_mask = 0x1, |
| 32 | .ring_doorbell = &mhuv2_ring_doorbell, |
| 33 | }; |
| 34 | |
Chandni Cherukuri | 61f3a7c | 2018-10-11 14:08:08 +0530 | [diff] [blame] | 35 | scmi_channel_plat_info_t *plat_css_get_scmi_info() |
| 36 | { |
Chandni Cherukuri | c8ef045 | 2018-10-04 16:32:03 +0530 | [diff] [blame] | 37 | if (sgi_plat_info.platform_id == SGI_CLARK_SID_VER_PART_NUM) |
| 38 | return &sgi_clark_scmi_plat_info; |
| 39 | else if (sgi_plat_info.platform_id == SGI575_SSC_VER_PART_NUM) |
| 40 | return &sgi575_scmi_plat_info; |
| 41 | else |
| 42 | panic(); |
| 43 | }; |
| 44 | |
| 45 | /******************************************************************************* |
| 46 | * This function sets the sgi_platform_id and sgi_config_id |
| 47 | ******************************************************************************/ |
| 48 | int sgi_identify_platform(unsigned long hw_config) |
| 49 | { |
| 50 | void *fdt; |
| 51 | int nodeoffset; |
| 52 | const unsigned int *property; |
| 53 | |
| 54 | fdt = (void *)hw_config; |
| 55 | |
| 56 | /* Check the validity of the fdt */ |
| 57 | assert(fdt_check_header(fdt) == 0); |
| 58 | |
| 59 | nodeoffset = fdt_subnode_offset(fdt, 0, "system-id"); |
| 60 | if (nodeoffset < 0) { |
| 61 | ERROR("Failed to get system-id node offset\n"); |
| 62 | return -1; |
| 63 | } |
| 64 | |
| 65 | property = fdt_getprop(fdt, nodeoffset, "platform-id", NULL); |
| 66 | if (property == NULL) { |
| 67 | ERROR("Failed to get platform-id property\n"); |
| 68 | return -1; |
| 69 | } |
| 70 | |
| 71 | sgi_plat_info.platform_id = fdt32_to_cpu(*property); |
| 72 | |
| 73 | property = fdt_getprop(fdt, nodeoffset, "config-id", NULL); |
| 74 | if (property == NULL) { |
| 75 | ERROR("Failed to get config-id property\n"); |
| 76 | return -1; |
| 77 | } |
| 78 | |
| 79 | sgi_plat_info.config_id = fdt32_to_cpu(*property); |
| 80 | |
| 81 | return 0; |
Chandni Cherukuri | 61f3a7c | 2018-10-11 14:08:08 +0530 | [diff] [blame] | 82 | } |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 83 | |
| 84 | void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1, |
| 85 | u_register_t arg2, u_register_t arg3) |
| 86 | { |
Chandni Cherukuri | c8ef045 | 2018-10-04 16:32:03 +0530 | [diff] [blame] | 87 | int ret; |
| 88 | |
| 89 | ret = sgi_identify_platform(arg2); |
| 90 | if (ret == -1) |
| 91 | panic(); |
| 92 | |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 93 | arm_bl31_early_platform_setup((void *)arg0, arg1, arg2, (void *)arg3); |
| 94 | } |
Sughosh Ganu | 18f513d | 2018-05-16 17:22:35 +0530 | [diff] [blame] | 95 | |
| 96 | void bl31_platform_setup(void) |
| 97 | { |
| 98 | arm_bl31_platform_setup(); |
| 99 | |
| 100 | #if RAS_EXTENSION |
| 101 | sgi_ras_intr_handler_setup(); |
| 102 | #endif |
| 103 | } |
Chandni Cherukuri | e4bf6a0 | 2018-11-14 13:43:59 +0530 | [diff] [blame] | 104 | |
| 105 | const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops) |
| 106 | { |
| 107 | return css_scmi_override_pm_ops(ops); |
| 108 | } |