Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Common board functions for OMAP3 based boards. |
| 4 | * |
| 5 | * (C) Copyright 2004-2008 |
| 6 | * Texas Instruments, <www.ti.com> |
| 7 | * |
| 8 | * Author : |
| 9 | * Sunil Kumar <sunilsaini05@gmail.com> |
| 10 | * Shashi Ranjan <shashiranjanmca05@gmail.com> |
| 11 | * |
| 12 | * Derived from Beagle Board and 3430 SDP code by |
| 13 | * Richard Woodruff <r-woodruff2@ti.com> |
| 14 | * Syed Mohammed Khasim <khasim@ti.com> |
| 15 | * |
| 16 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 17 | * SPDX-License-Identifier: GPL-2.0+ |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 18 | */ |
| 19 | #include <common.h> |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 20 | #include <dm.h> |
Tom Rini | 28591df | 2012-08-13 12:03:19 -0700 | [diff] [blame] | 21 | #include <spl.h> |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 22 | #include <asm/io.h> |
| 23 | #include <asm/arch/sys_proto.h> |
| 24 | #include <asm/arch/mem.h> |
Kim, Heung Jun | 3b5ac95 | 2009-06-20 11:02:17 +0200 | [diff] [blame] | 25 | #include <asm/cache.h> |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 26 | #include <asm/armv7.h> |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 27 | #include <asm/gpio.h> |
Simon Schwarz | 992dcf7 | 2011-09-14 15:29:26 -0400 | [diff] [blame] | 28 | #include <asm/omap_common.h> |
Tom Rini | 05df891 | 2012-04-13 12:20:03 +0000 | [diff] [blame] | 29 | #include <linux/compiler.h> |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 30 | |
Tom Rini | 31dfba4 | 2012-08-22 15:31:05 -0700 | [diff] [blame] | 31 | DECLARE_GLOBAL_DATA_PTR; |
| 32 | |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 33 | /* Declarations */ |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 34 | extern omap3_sysinfo sysinfo; |
Tom Rini | b759db3 | 2012-10-30 22:23:28 -0700 | [diff] [blame] | 35 | #ifndef CONFIG_SYS_L2CACHE_OFF |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 36 | static void omap3_invalidate_l2_cache_secure(void); |
Tom Rini | b759db3 | 2012-10-30 22:23:28 -0700 | [diff] [blame] | 37 | #endif |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 38 | |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 39 | #ifdef CONFIG_DM_GPIO |
| 40 | static const struct omap_gpio_platdata omap34xx_gpio[] = { |
Tom Rini | 7bc2bca | 2015-07-31 19:55:09 -0400 | [diff] [blame] | 41 | { 0, OMAP34XX_GPIO1_BASE }, |
| 42 | { 1, OMAP34XX_GPIO2_BASE }, |
| 43 | { 2, OMAP34XX_GPIO3_BASE }, |
| 44 | { 3, OMAP34XX_GPIO4_BASE }, |
| 45 | { 4, OMAP34XX_GPIO5_BASE }, |
| 46 | { 5, OMAP34XX_GPIO6_BASE }, |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 47 | }; |
| 48 | |
Adam Ford | 8d70ffd | 2017-04-09 07:35:12 -0500 | [diff] [blame] | 49 | U_BOOT_DEVICES(omap34xx_gpios) = { |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 50 | { "gpio_omap", &omap34xx_gpio[0] }, |
| 51 | { "gpio_omap", &omap34xx_gpio[1] }, |
| 52 | { "gpio_omap", &omap34xx_gpio[2] }, |
| 53 | { "gpio_omap", &omap34xx_gpio[3] }, |
| 54 | { "gpio_omap", &omap34xx_gpio[4] }, |
| 55 | { "gpio_omap", &omap34xx_gpio[5] }, |
| 56 | }; |
| 57 | |
| 58 | #else |
| 59 | |
Aneesh V | 9a39088 | 2011-07-21 09:29:29 -0400 | [diff] [blame] | 60 | static const struct gpio_bank gpio_bank_34xx[6] = { |
Tom Rini | 7bc2bca | 2015-07-31 19:55:09 -0400 | [diff] [blame] | 61 | { (void *)OMAP34XX_GPIO1_BASE }, |
| 62 | { (void *)OMAP34XX_GPIO2_BASE }, |
| 63 | { (void *)OMAP34XX_GPIO3_BASE }, |
| 64 | { (void *)OMAP34XX_GPIO4_BASE }, |
| 65 | { (void *)OMAP34XX_GPIO5_BASE }, |
| 66 | { (void *)OMAP34XX_GPIO6_BASE }, |
Aneesh V | 9a39088 | 2011-07-21 09:29:29 -0400 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | const struct gpio_bank *const omap_gpio_bank = gpio_bank_34xx; |
| 70 | |
Simon Glass | bc0f4ea | 2014-10-22 21:37:15 -0600 | [diff] [blame] | 71 | #endif |
| 72 | |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 73 | /****************************************************************************** |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 74 | * Routine: secure_unlock |
| 75 | * Description: Setup security registers for access |
| 76 | * (GP Device only) |
| 77 | *****************************************************************************/ |
| 78 | void secure_unlock_mem(void) |
| 79 | { |
Dirk Behme | dc7af20 | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 80 | struct pm *pm_rt_ape_base = (struct pm *)PM_RT_APE_BASE_ADDR_ARM; |
| 81 | struct pm *pm_gpmc_base = (struct pm *)PM_GPMC_BASE_ADDR_ARM; |
| 82 | struct pm *pm_ocm_ram_base = (struct pm *)PM_OCM_RAM_BASE_ADDR_ARM; |
| 83 | struct pm *pm_iva2_base = (struct pm *)PM_IVA2_BASE_ADDR_ARM; |
| 84 | struct sms *sms_base = (struct sms *)OMAP34XX_SMS_BASE; |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 85 | |
| 86 | /* Protection Module Register Target APE (PM_RT) */ |
| 87 | writel(UNLOCK_1, &pm_rt_ape_base->req_info_permission_1); |
| 88 | writel(UNLOCK_1, &pm_rt_ape_base->read_permission_0); |
| 89 | writel(UNLOCK_1, &pm_rt_ape_base->wirte_permission_0); |
| 90 | writel(UNLOCK_2, &pm_rt_ape_base->addr_match_1); |
| 91 | |
| 92 | writel(UNLOCK_3, &pm_gpmc_base->req_info_permission_0); |
| 93 | writel(UNLOCK_3, &pm_gpmc_base->read_permission_0); |
| 94 | writel(UNLOCK_3, &pm_gpmc_base->wirte_permission_0); |
| 95 | |
| 96 | writel(UNLOCK_3, &pm_ocm_ram_base->req_info_permission_0); |
| 97 | writel(UNLOCK_3, &pm_ocm_ram_base->read_permission_0); |
| 98 | writel(UNLOCK_3, &pm_ocm_ram_base->wirte_permission_0); |
| 99 | writel(UNLOCK_2, &pm_ocm_ram_base->addr_match_2); |
| 100 | |
| 101 | /* IVA Changes */ |
| 102 | writel(UNLOCK_3, &pm_iva2_base->req_info_permission_0); |
| 103 | writel(UNLOCK_3, &pm_iva2_base->read_permission_0); |
| 104 | writel(UNLOCK_3, &pm_iva2_base->wirte_permission_0); |
| 105 | |
| 106 | /* SDRC region 0 public */ |
| 107 | writel(UNLOCK_1, &sms_base->rg_att0); |
| 108 | } |
| 109 | |
| 110 | /****************************************************************************** |
| 111 | * Routine: secureworld_exit() |
| 112 | * Description: If chip is EMU and boot type is external |
| 113 | * configure secure registers and exit secure world |
| 114 | * general use. |
| 115 | *****************************************************************************/ |
Jeroen Hofstee | 69ab383 | 2014-06-16 23:22:23 +0200 | [diff] [blame] | 116 | void secureworld_exit(void) |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 117 | { |
| 118 | unsigned long i; |
| 119 | |
Peter Meerwald | 7ea4b7c | 2012-02-02 12:51:02 +0000 | [diff] [blame] | 120 | /* configure non-secure access control register */ |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 121 | __asm__ __volatile__("mrc p15, 0, %0, c1, c1, 2":"=r"(i)); |
| 122 | /* enabling co-processor CP10 and CP11 accesses in NS world */ |
| 123 | __asm__ __volatile__("orr %0, %0, #0xC00":"=r"(i)); |
| 124 | /* |
| 125 | * allow allocation of locked TLBs and L2 lines in NS world |
| 126 | * allow use of PLE registers in NS world also |
| 127 | */ |
| 128 | __asm__ __volatile__("orr %0, %0, #0x70000":"=r"(i)); |
| 129 | __asm__ __volatile__("mcr p15, 0, %0, c1, c1, 2":"=r"(i)); |
| 130 | |
| 131 | /* Enable ASA in ACR register */ |
| 132 | __asm__ __volatile__("mrc p15, 0, %0, c1, c0, 1":"=r"(i)); |
| 133 | __asm__ __volatile__("orr %0, %0, #0x10":"=r"(i)); |
| 134 | __asm__ __volatile__("mcr p15, 0, %0, c1, c0, 1":"=r"(i)); |
| 135 | |
| 136 | /* Exiting secure world */ |
| 137 | __asm__ __volatile__("mrc p15, 0, %0, c1, c1, 0":"=r"(i)); |
| 138 | __asm__ __volatile__("orr %0, %0, #0x31":"=r"(i)); |
| 139 | __asm__ __volatile__("mcr p15, 0, %0, c1, c1, 0":"=r"(i)); |
| 140 | } |
| 141 | |
| 142 | /****************************************************************************** |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 143 | * Routine: try_unlock_sram() |
| 144 | * Description: If chip is GP/EMU(special) type, unlock the SRAM for |
| 145 | * general use. |
| 146 | *****************************************************************************/ |
Jeroen Hofstee | 69ab383 | 2014-06-16 23:22:23 +0200 | [diff] [blame] | 147 | void try_unlock_memory(void) |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 148 | { |
| 149 | int mode; |
| 150 | int in_sdram = is_running_in_sdram(); |
| 151 | |
| 152 | /* |
| 153 | * if GP device unlock device SRAM for general use |
| 154 | * secure code breaks for Secure/Emulation device - HS/E/T |
| 155 | */ |
| 156 | mode = get_device_type(); |
| 157 | if (mode == GP_DEVICE) |
| 158 | secure_unlock_mem(); |
| 159 | |
| 160 | /* |
| 161 | * If device is EMU and boot is XIP external booting |
| 162 | * Unlock firewalls and disable L2 and put chip |
| 163 | * out of secure world |
| 164 | * |
| 165 | * Assuming memories are unlocked by the demon who put us in SDRAM |
| 166 | */ |
| 167 | if ((mode <= EMU_DEVICE) && (get_boot_type() == 0x1F) |
| 168 | && (!in_sdram)) { |
| 169 | secure_unlock_mem(); |
| 170 | secureworld_exit(); |
| 171 | } |
| 172 | |
| 173 | return; |
| 174 | } |
| 175 | |
| 176 | /****************************************************************************** |
| 177 | * Routine: s_init |
| 178 | * Description: Does early system init of muxing and clocks. |
| 179 | * - Called path is with SRAM stack. |
| 180 | *****************************************************************************/ |
| 181 | void s_init(void) |
| 182 | { |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 183 | watchdog_init(); |
| 184 | |
| 185 | try_unlock_memory(); |
| 186 | |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 187 | #ifndef CONFIG_SYS_L2CACHE_OFF |
| 188 | /* Invalidate L2-cache from secure mode */ |
| 189 | omap3_invalidate_l2_cache_secure(); |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 190 | #endif |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 191 | |
| 192 | set_muxconf_regs(); |
Alexander Holler | 4e333f6 | 2010-12-18 13:24:20 +0100 | [diff] [blame] | 193 | sdelay(100); |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 194 | |
| 195 | prcm_init(); |
| 196 | |
| 197 | per_clocks_enable(); |
| 198 | |
Govindraj.R | 3968a6a | 2012-02-06 03:55:35 +0000 | [diff] [blame] | 199 | #ifdef CONFIG_USB_EHCI_OMAP |
| 200 | ehci_clocks_enable(); |
| 201 | #endif |
Simon Glass | 0c078ea | 2015-03-03 08:03:02 -0700 | [diff] [blame] | 202 | } |
Govindraj.R | 3968a6a | 2012-02-06 03:55:35 +0000 | [diff] [blame] | 203 | |
Simon Glass | 0c078ea | 2015-03-03 08:03:02 -0700 | [diff] [blame] | 204 | #ifdef CONFIG_SPL_BUILD |
| 205 | void board_init_f(ulong dummy) |
| 206 | { |
| 207 | mem_init(); |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 208 | } |
Simon Glass | 0c078ea | 2015-03-03 08:03:02 -0700 | [diff] [blame] | 209 | #endif |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 210 | |
Tom Rini | 05df891 | 2012-04-13 12:20:03 +0000 | [diff] [blame] | 211 | /* |
| 212 | * Routine: misc_init_r |
| 213 | * Description: A basic misc_init_r that just displays the die ID |
| 214 | */ |
| 215 | int __weak misc_init_r(void) |
| 216 | { |
Paul Kocialkowski | 6bc318e | 2015-08-27 19:37:13 +0200 | [diff] [blame] | 217 | omap_die_id_display(); |
Tom Rini | 05df891 | 2012-04-13 12:20:03 +0000 | [diff] [blame] | 218 | |
| 219 | return 0; |
| 220 | } |
| 221 | |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 222 | /****************************************************************************** |
| 223 | * Routine: wait_for_command_complete |
| 224 | * Description: Wait for posting to finish on watchdog |
| 225 | *****************************************************************************/ |
Jeroen Hofstee | cbc7562 | 2014-10-08 22:57:41 +0200 | [diff] [blame] | 226 | static void wait_for_command_complete(struct watchdog *wd_base) |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 227 | { |
| 228 | int pending = 1; |
| 229 | do { |
| 230 | pending = readl(&wd_base->wwps); |
| 231 | } while (pending); |
| 232 | } |
| 233 | |
| 234 | /****************************************************************************** |
| 235 | * Routine: watchdog_init |
| 236 | * Description: Shut down watch dogs |
| 237 | *****************************************************************************/ |
| 238 | void watchdog_init(void) |
| 239 | { |
Dirk Behme | dc7af20 | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 240 | struct watchdog *wd2_base = (struct watchdog *)WD2_BASE; |
| 241 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 242 | |
| 243 | /* |
| 244 | * There are 3 watch dogs WD1=Secure, WD2=MPU, WD3=IVA. WD1 is |
| 245 | * either taken care of by ROM (HS/EMU) or not accessible (GP). |
| 246 | * We need to take care of WD2-MPU or take a PRCM reset. WD3 |
| 247 | * should not be running and does not generate a PRCM reset. |
| 248 | */ |
| 249 | |
Wolfgang Denk | 42b97cb | 2014-03-25 14:49:48 +0100 | [diff] [blame] | 250 | setbits_le32(&prcm_base->fclken_wkup, 0x20); |
| 251 | setbits_le32(&prcm_base->iclken_wkup, 0x20); |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 252 | wait_on_value(ST_WDT2, 0x20, &prcm_base->idlest_wkup, 5); |
| 253 | |
| 254 | writel(WD_UNLOCK1, &wd2_base->wspr); |
| 255 | wait_for_command_complete(wd2_base); |
| 256 | writel(WD_UNLOCK2, &wd2_base->wspr); |
| 257 | } |
| 258 | |
| 259 | /****************************************************************************** |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 260 | * Dummy function to handle errors for EABI incompatibility |
| 261 | *****************************************************************************/ |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 262 | void abort(void) |
| 263 | { |
| 264 | } |
| 265 | |
Simon Schwarz | 992dcf7 | 2011-09-14 15:29:26 -0400 | [diff] [blame] | 266 | #if defined(CONFIG_NAND_OMAP_GPMC) & !defined(CONFIG_SPL_BUILD) |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 267 | /****************************************************************************** |
| 268 | * OMAP3 specific command to switch between NAND HW and SW ecc |
| 269 | *****************************************************************************/ |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 270 | static int do_switch_ecc(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 271 | { |
Ladislav Michl | d3bc985 | 2017-03-06 13:54:30 +0100 | [diff] [blame] | 272 | int hw, strength = 1; |
| 273 | |
Andreas Bießmann | 1e4eccf | 2013-04-04 23:52:50 +0000 | [diff] [blame] | 274 | if (argc < 2 || argc > 3) |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 275 | goto usage; |
Andreas Bießmann | 1e4eccf | 2013-04-04 23:52:50 +0000 | [diff] [blame] | 276 | |
| 277 | if (strncmp(argv[1], "hw", 2) == 0) { |
Ladislav Michl | d3bc985 | 2017-03-06 13:54:30 +0100 | [diff] [blame] | 278 | hw = 1; |
| 279 | if (argc == 3) { |
| 280 | if (strncmp(argv[2], "bch8", 4) == 0) |
| 281 | strength = 8; |
Heiko Schocher | 5bf904c | 2016-06-07 08:55:42 +0200 | [diff] [blame] | 282 | else if (strncmp(argv[2], "bch16", 5) == 0) |
Ladislav Michl | d3bc985 | 2017-03-06 13:54:30 +0100 | [diff] [blame] | 283 | strength = 16; |
| 284 | else if (strncmp(argv[2], "hamming", 7) != 0) |
Andreas Bießmann | 1e4eccf | 2013-04-04 23:52:50 +0000 | [diff] [blame] | 285 | goto usage; |
| 286 | } |
| 287 | } else if (strncmp(argv[1], "sw", 2) == 0) { |
Ladislav Michl | d3bc985 | 2017-03-06 13:54:30 +0100 | [diff] [blame] | 288 | hw = 0; |
| 289 | if (argc == 3) { |
| 290 | if (strncmp(argv[2], "bch8", 4) == 0) |
| 291 | strength = 8; |
| 292 | else if (strncmp(argv[2], "hamming", 7) != 0) |
Ash Charles | 4a5faa8 | 2015-02-18 11:25:11 -0800 | [diff] [blame] | 293 | goto usage; |
| 294 | } |
Andreas Bießmann | 1e4eccf | 2013-04-04 23:52:50 +0000 | [diff] [blame] | 295 | } else { |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 296 | goto usage; |
Andreas Bießmann | 1e4eccf | 2013-04-04 23:52:50 +0000 | [diff] [blame] | 297 | } |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 298 | |
Ladislav Michl | d3bc985 | 2017-03-06 13:54:30 +0100 | [diff] [blame] | 299 | return -omap_nand_switch_ecc(hw, strength); |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 300 | |
| 301 | usage: |
Sanjeev Premi | 15af998 | 2009-04-03 14:00:07 +0530 | [diff] [blame] | 302 | printf ("Usage: nandecc %s\n", cmdtp->usage); |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 303 | return 1; |
| 304 | } |
| 305 | |
| 306 | U_BOOT_CMD( |
Andreas Bießmann | 1e4eccf | 2013-04-04 23:52:50 +0000 | [diff] [blame] | 307 | nandecc, 3, 1, do_switch_ecc, |
Robert P. J. Day | 3ea16c3 | 2009-11-17 07:30:23 -0500 | [diff] [blame] | 308 | "switch OMAP3 NAND ECC calculation algorithm", |
Heiko Schocher | 5bf904c | 2016-06-07 08:55:42 +0200 | [diff] [blame] | 309 | "hw [hamming|bch8|bch16] - Switch between NAND hardware 1-bit hamming" |
| 310 | " and 8-bit/16-bit BCH\n" |
Andreas Bießmann | 1e4eccf | 2013-04-04 23:52:50 +0000 | [diff] [blame] | 311 | " ecc calculation (second parameter may" |
| 312 | " be omitted).\n" |
| 313 | "nandecc sw - Switch to NAND software ecc algorithm." |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 314 | ); |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 315 | |
Simon Schwarz | 992dcf7 | 2011-09-14 15:29:26 -0400 | [diff] [blame] | 316 | #endif /* CONFIG_NAND_OMAP_GPMC & !CONFIG_SPL_BUILD */ |
Sanjeev Premi | e32ef2e | 2009-04-27 21:27:27 +0530 | [diff] [blame] | 317 | |
| 318 | #ifdef CONFIG_DISPLAY_BOARDINFO |
| 319 | /** |
| 320 | * Print board information |
| 321 | */ |
| 322 | int checkboard (void) |
| 323 | { |
| 324 | char *mem_s ; |
| 325 | |
| 326 | if (is_mem_sdr()) |
| 327 | mem_s = "mSDR"; |
| 328 | else |
| 329 | mem_s = "LPDDR"; |
| 330 | |
| 331 | printf("%s + %s/%s\n", sysinfo.board_string, mem_s, |
| 332 | sysinfo.nand_string); |
| 333 | |
| 334 | return 0; |
| 335 | } |
| 336 | #endif /* CONFIG_DISPLAY_BOARDINFO */ |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 337 | |
| 338 | static void omap3_emu_romcode_call(u32 service_id, u32 *parameters) |
| 339 | { |
| 340 | u32 i, num_params = *parameters; |
| 341 | u32 *sram_scratch_space = (u32 *)OMAP3_PUBLIC_SRAM_SCRATCH_AREA; |
| 342 | |
| 343 | /* |
| 344 | * copy the parameters to an un-cached area to avoid coherency |
| 345 | * issues |
| 346 | */ |
| 347 | for (i = 0; i < num_params; i++) { |
| 348 | __raw_writel(*parameters, sram_scratch_space); |
| 349 | parameters++; |
| 350 | sram_scratch_space++; |
| 351 | } |
| 352 | |
| 353 | /* Now make the PPA call */ |
| 354 | do_omap3_emu_romcode_call(service_id, OMAP3_PUBLIC_SRAM_SCRATCH_AREA); |
| 355 | } |
| 356 | |
Nishanth Menon | 53fee1e | 2015-03-09 17:12:09 -0500 | [diff] [blame] | 357 | void __weak omap3_set_aux_cr_secure(u32 acr) |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 358 | { |
Nishanth Menon | 53fee1e | 2015-03-09 17:12:09 -0500 | [diff] [blame] | 359 | struct emu_hal_params emu_romcode_params; |
| 360 | |
| 361 | emu_romcode_params.num_params = 1; |
| 362 | emu_romcode_params.param1 = acr; |
| 363 | omap3_emu_romcode_call(OMAP3_EMU_HAL_API_WRITE_ACR, |
| 364 | (u32 *)&emu_romcode_params); |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 365 | } |
| 366 | |
Siarhei Siamashka | fe038a7 | 2017-03-06 03:16:53 +0200 | [diff] [blame] | 367 | void v7_arch_cp15_set_l2aux_ctrl(u32 l2auxctrl, u32 cpu_midr, |
| 368 | u32 cpu_rev_comb, u32 cpu_variant, |
| 369 | u32 cpu_rev) |
| 370 | { |
| 371 | if (get_device_type() == GP_DEVICE) |
| 372 | omap_smc1(OMAP3_GP_ROMCODE_API_WRITE_L2ACR, l2auxctrl); |
| 373 | |
| 374 | /* L2 Cache Auxiliary Control Register is not banked */ |
| 375 | } |
| 376 | |
Nishanth Menon | 53fee1e | 2015-03-09 17:12:09 -0500 | [diff] [blame] | 377 | void v7_arch_cp15_set_acr(u32 acr, u32 cpu_midr, u32 cpu_rev_comb, |
| 378 | u32 cpu_variant, u32 cpu_rev) |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 379 | { |
Nishanth Menon | 53fee1e | 2015-03-09 17:12:09 -0500 | [diff] [blame] | 380 | /* Write ACR - affects secure banked bits */ |
| 381 | if (get_device_type() == GP_DEVICE) |
| 382 | omap_smc1(OMAP3_GP_ROMCODE_API_WRITE_ACR, acr); |
| 383 | else |
| 384 | omap3_set_aux_cr_secure(acr); |
Nishanth Menon | 3e46e3e | 2015-03-09 17:12:08 -0500 | [diff] [blame] | 385 | |
Nishanth Menon | 53fee1e | 2015-03-09 17:12:09 -0500 | [diff] [blame] | 386 | /* Write ACR - affects non-secure banked bits - some erratas need it */ |
| 387 | asm volatile ("mcr p15, 0, %0, c1, c0, 1" : : "r" (acr)); |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 388 | } |
| 389 | |
Nishanth Menon | 53fee1e | 2015-03-09 17:12:09 -0500 | [diff] [blame] | 390 | |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 391 | #ifndef CONFIG_SYS_L2CACHE_OFF |
Tom Rini | b759db3 | 2012-10-30 22:23:28 -0700 | [diff] [blame] | 392 | static void omap3_update_aux_cr(u32 set_bits, u32 clear_bits) |
| 393 | { |
| 394 | u32 acr; |
| 395 | |
| 396 | /* Read ACR */ |
| 397 | asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr)); |
| 398 | acr &= ~clear_bits; |
| 399 | acr |= set_bits; |
Nishanth Menon | 53fee1e | 2015-03-09 17:12:09 -0500 | [diff] [blame] | 400 | v7_arch_cp15_set_acr(acr, 0, 0, 0, 0); |
Tom Rini | b759db3 | 2012-10-30 22:23:28 -0700 | [diff] [blame] | 401 | |
Tom Rini | b759db3 | 2012-10-30 22:23:28 -0700 | [diff] [blame] | 402 | } |
| 403 | |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 404 | /* Invalidate the entire L2 cache from secure mode */ |
| 405 | static void omap3_invalidate_l2_cache_secure(void) |
| 406 | { |
| 407 | if (get_device_type() == GP_DEVICE) { |
Nishanth Menon | a816cc3 | 2015-03-09 17:12:05 -0500 | [diff] [blame] | 408 | omap_smc1(OMAP3_GP_ROMCODE_API_L2_INVAL, 0); |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 409 | } else { |
| 410 | struct emu_hal_params emu_romcode_params; |
| 411 | emu_romcode_params.num_params = 1; |
| 412 | emu_romcode_params.param1 = 0; |
| 413 | omap3_emu_romcode_call(OMAP3_EMU_HAL_API_L2_INVAL, |
| 414 | (u32 *)&emu_romcode_params); |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | void v7_outer_cache_enable(void) |
| 419 | { |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 420 | |
| 421 | /* |
Nishanth Menon | 53fee1e | 2015-03-09 17:12:09 -0500 | [diff] [blame] | 422 | * Set L2EN |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 423 | * On some revisions L2EN bit is banked on some revisions it's not |
| 424 | * No harm in setting both banked bits(in fact this is required |
| 425 | * by an erratum) |
| 426 | */ |
| 427 | omap3_update_aux_cr(0x2, 0); |
| 428 | } |
| 429 | |
Aneesh V | e0db71d | 2012-02-16 03:40:15 +0000 | [diff] [blame] | 430 | void omap3_outer_cache_disable(void) |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 431 | { |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 432 | /* |
Nishanth Menon | 53fee1e | 2015-03-09 17:12:09 -0500 | [diff] [blame] | 433 | * Clear L2EN |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 434 | * On some revisions L2EN bit is banked on some revisions it's not |
| 435 | * No harm in clearing both banked bits(in fact this is required |
| 436 | * by an erratum) |
| 437 | */ |
| 438 | omap3_update_aux_cr(0, 0x2); |
| 439 | } |
Robert P. J. Day | 3bb3c29 | 2012-11-13 07:57:54 +0000 | [diff] [blame] | 440 | #endif /* !CONFIG_SYS_L2CACHE_OFF */ |