Konstantin Porotchkin | 646b5cc | 2018-06-07 18:48:49 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 Marvell International Ltd. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * https://spdx.org/licenses |
| 6 | */ |
| 7 | |
| 8 | #include <a8k_common.h> |
| 9 | /* |
| 10 | * If bootrom is currently at BLE there's no need to include the memory |
| 11 | * maps structure at this point |
| 12 | */ |
| 13 | #include <mvebu_def.h> |
| 14 | #ifndef IMAGE_BLE |
| 15 | |
| 16 | /***************************************************************************** |
| 17 | * AMB Configuration |
| 18 | ***************************************************************************** |
| 19 | */ |
| 20 | struct addr_map_win amb_memory_map[] = { |
| 21 | /* CP1 SPI1 CS0 Direct Mode access */ |
| 22 | {0xf900, 0x1000000, AMB_SPI1_CS0_ID}, |
| 23 | }; |
| 24 | |
| 25 | int marvell_get_amb_memory_map(struct addr_map_win **win, uint32_t *size, |
| 26 | uintptr_t base) |
| 27 | { |
| 28 | *win = amb_memory_map; |
| 29 | if (*win == NULL) |
| 30 | *size = 0; |
| 31 | else |
| 32 | *size = ARRAY_SIZE(amb_memory_map); |
| 33 | |
| 34 | return 0; |
| 35 | } |
| 36 | #endif |
| 37 | |
| 38 | /***************************************************************************** |
| 39 | * IO WIN Configuration |
| 40 | ***************************************************************************** |
| 41 | */ |
| 42 | struct addr_map_win io_win_memory_map[] = { |
| 43 | /* CP1 (MCI0) internal regs */ |
| 44 | {0x00000000f4000000, 0x2000000, MCI_0_TID}, |
| 45 | #ifndef IMAGE_BLE |
| 46 | /* PCIe0 and SPI1_CS0 (RUNIT) on CP1*/ |
| 47 | {0x00000000f9000000, 0x2000000, MCI_0_TID}, |
| 48 | /* PCIe1 on CP1*/ |
| 49 | {0x00000000fb000000, 0x1000000, MCI_0_TID}, |
| 50 | /* PCIe2 on CP1*/ |
| 51 | {0x00000000fc000000, 0x1000000, MCI_0_TID}, |
| 52 | /* MCI 0 indirect window */ |
| 53 | {MVEBU_MCI_REG_BASE_REMAP(0), 0x100000, MCI_0_TID}, |
| 54 | /* MCI 1 indirect window */ |
| 55 | {MVEBU_MCI_REG_BASE_REMAP(1), 0x100000, MCI_1_TID}, |
| 56 | #endif |
| 57 | }; |
| 58 | |
| 59 | uint32_t marvell_get_io_win_gcr_target(int ap_index) |
| 60 | { |
| 61 | return PIDI_TID; |
| 62 | } |
| 63 | |
| 64 | int marvell_get_io_win_memory_map(int ap_index, struct addr_map_win **win, |
| 65 | uint32_t *size) |
| 66 | { |
| 67 | *win = io_win_memory_map; |
| 68 | if (*win == NULL) |
| 69 | *size = 0; |
| 70 | else |
| 71 | *size = ARRAY_SIZE(io_win_memory_map); |
| 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | #ifndef IMAGE_BLE |
| 77 | /***************************************************************************** |
| 78 | * IOB Configuration |
| 79 | ***************************************************************************** |
| 80 | */ |
| 81 | struct addr_map_win iob_memory_map_cp0[] = { |
| 82 | /* CP0 */ |
| 83 | /* PEX1_X1 window */ |
| 84 | {0x00000000f7000000, 0x1000000, PEX1_TID}, |
| 85 | /* PEX2_X1 window */ |
| 86 | {0x00000000f8000000, 0x1000000, PEX2_TID}, |
| 87 | /* PEX0_X4 window */ |
| 88 | {0x00000000f6000000, 0x1000000, PEX0_TID} |
| 89 | }; |
| 90 | |
| 91 | struct addr_map_win iob_memory_map_cp1[] = { |
| 92 | /* CP1 */ |
| 93 | /* SPI1_CS0 (RUNIT) window */ |
| 94 | {0x00000000f9000000, 0x1000000, RUNIT_TID}, |
| 95 | /* PEX1_X1 window */ |
| 96 | {0x00000000fb000000, 0x1000000, PEX1_TID}, |
| 97 | /* PEX2_X1 window */ |
| 98 | {0x00000000fc000000, 0x1000000, PEX2_TID}, |
| 99 | /* PEX0_X4 window */ |
| 100 | {0x00000000fa000000, 0x1000000, PEX0_TID} |
| 101 | }; |
| 102 | |
| 103 | int marvell_get_iob_memory_map(struct addr_map_win **win, uint32_t *size, |
| 104 | uintptr_t base) |
| 105 | { |
| 106 | switch (base) { |
| 107 | case MVEBU_CP_REGS_BASE(0): |
| 108 | *win = iob_memory_map_cp0; |
| 109 | *size = ARRAY_SIZE(iob_memory_map_cp0); |
| 110 | return 0; |
| 111 | case MVEBU_CP_REGS_BASE(1): |
| 112 | *win = iob_memory_map_cp1; |
| 113 | *size = ARRAY_SIZE(iob_memory_map_cp1); |
| 114 | return 0; |
| 115 | default: |
| 116 | *size = 0; |
| 117 | *win = 0; |
| 118 | return 1; |
| 119 | } |
| 120 | } |
| 121 | #endif |
| 122 | |
| 123 | /***************************************************************************** |
| 124 | * CCU Configuration |
| 125 | ***************************************************************************** |
| 126 | */ |
| 127 | struct addr_map_win ccu_memory_map[] = { |
| 128 | #ifdef IMAGE_BLE |
| 129 | {0x00000000f2000000, 0x4000000, IO_0_TID}, /* IO window */ |
| 130 | #else |
| 131 | {0x00000000f2000000, 0xe000000, IO_0_TID}, /* IO window */ |
| 132 | #endif |
| 133 | }; |
| 134 | |
| 135 | uint32_t marvell_get_ccu_gcr_target(int ap) |
| 136 | { |
| 137 | return DRAM_0_TID; |
| 138 | } |
| 139 | |
| 140 | int marvell_get_ccu_memory_map(int ap, struct addr_map_win **win, |
| 141 | uint32_t *size) |
| 142 | { |
| 143 | *win = ccu_memory_map; |
| 144 | *size = ARRAY_SIZE(ccu_memory_map); |
| 145 | |
| 146 | return 0; |
| 147 | } |
| 148 | |
| 149 | #ifndef IMAGE_BLE |
| 150 | /***************************************************************************** |
| 151 | * SoC PM configuration |
| 152 | ***************************************************************************** |
| 153 | */ |
| 154 | /* CP GPIO should be used and the GPIOs should be within same GPIO register */ |
| 155 | struct power_off_method pm_cfg = { |
| 156 | .type = PMIC_GPIO, |
| 157 | .cfg.gpio.pin_count = 1, |
| 158 | .cfg.gpio.info = {{0, 35} }, |
| 159 | .cfg.gpio.step_count = 7, |
| 160 | .cfg.gpio.seq = {1, 0, 1, 0, 1, 0, 1}, |
| 161 | .cfg.gpio.delay_ms = 10, |
| 162 | }; |
| 163 | |
| 164 | void *plat_marvell_get_pm_cfg(void) |
| 165 | { |
| 166 | /* Return the PM configurations */ |
| 167 | return &pm_cfg; |
| 168 | } |
| 169 | |
| 170 | /* In reference to #ifndef IMAGE_BLE, this part is used for BLE only. */ |
| 171 | #else |
| 172 | /***************************************************************************** |
| 173 | * SKIP IMAGE Configuration |
| 174 | ***************************************************************************** |
| 175 | */ |
| 176 | #if PLAT_RECOVERY_IMAGE_ENABLE |
| 177 | struct skip_image skip_im = { |
| 178 | .detection_method = GPIO, |
| 179 | .info.gpio.num = 33, |
| 180 | .info.gpio.button_state = HIGH, |
| 181 | .info.test.cp_ap = CP, |
| 182 | .info.test.cp_index = 0, |
| 183 | }; |
| 184 | |
| 185 | void *plat_marvell_get_skip_image_data(void) |
| 186 | { |
| 187 | /* Return the skip_image configurations */ |
| 188 | return &skip_im; |
| 189 | } |
| 190 | #endif |
| 191 | #endif |