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 | * |
| 17 | * See file CREDITS for list of people who contributed to this |
| 18 | * project. |
| 19 | * |
| 20 | * This program is free software; you can redistribute it and/or |
| 21 | * modify it under the terms of the GNU General Public License as |
| 22 | * published by the Free Software Foundation; either version 2 of |
| 23 | * the License, or (at your option) any later version. |
| 24 | * |
| 25 | * This program is distributed in the hope that it will be useful, |
| 26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 28 | * GNU General Public License for more details. |
| 29 | * |
| 30 | * You should have received a copy of the GNU General Public License |
| 31 | * along with this program; if not, write to the Free Software |
| 32 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 33 | * MA 02111-1307 USA |
| 34 | */ |
| 35 | #include <common.h> |
| 36 | #include <asm/io.h> |
| 37 | #include <asm/arch/sys_proto.h> |
| 38 | #include <asm/arch/mem.h> |
Kim, Heung Jun | 3b5ac95 | 2009-06-20 11:02:17 +0200 | [diff] [blame] | 39 | #include <asm/cache.h> |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 40 | #include <asm/armv7.h> |
Aneesh V | 1843eca | 2011-07-31 20:30:53 +0000 | [diff] [blame] | 41 | #include <asm/arch/gpio.h> |
Tom Rini | 29d69dc | 2012-08-14 08:50:58 -0700 | [diff] [blame] | 42 | #include <asm/spl.h> |
Simon Schwarz | 992dcf7 | 2011-09-14 15:29:26 -0400 | [diff] [blame] | 43 | #include <asm/omap_common.h> |
Tom Rini | a0b9fa5 | 2012-08-14 10:25:15 -0700 | [diff] [blame^] | 44 | #include <asm/arch/mmc_host_def.h> |
Tom Rini | ead66c1 | 2011-11-23 05:13:06 +0000 | [diff] [blame] | 45 | #include <i2c.h> |
Tom Rini | 05df891 | 2012-04-13 12:20:03 +0000 | [diff] [blame] | 46 | #include <linux/compiler.h> |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 47 | |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 48 | /* Declarations */ |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 49 | extern omap3_sysinfo sysinfo; |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 50 | static void omap3_setup_aux_cr(void); |
| 51 | static void omap3_invalidate_l2_cache_secure(void); |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 52 | |
Aneesh V | 9a39088 | 2011-07-21 09:29:29 -0400 | [diff] [blame] | 53 | static const struct gpio_bank gpio_bank_34xx[6] = { |
| 54 | { (void *)OMAP34XX_GPIO1_BASE, METHOD_GPIO_24XX }, |
| 55 | { (void *)OMAP34XX_GPIO2_BASE, METHOD_GPIO_24XX }, |
| 56 | { (void *)OMAP34XX_GPIO3_BASE, METHOD_GPIO_24XX }, |
| 57 | { (void *)OMAP34XX_GPIO4_BASE, METHOD_GPIO_24XX }, |
| 58 | { (void *)OMAP34XX_GPIO5_BASE, METHOD_GPIO_24XX }, |
| 59 | { (void *)OMAP34XX_GPIO6_BASE, METHOD_GPIO_24XX }, |
| 60 | }; |
| 61 | |
| 62 | const struct gpio_bank *const omap_gpio_bank = gpio_bank_34xx; |
| 63 | |
Simon Schwarz | 992dcf7 | 2011-09-14 15:29:26 -0400 | [diff] [blame] | 64 | #ifdef CONFIG_SPL_BUILD |
| 65 | /* |
| 66 | * We use static variables because global data is not ready yet. |
| 67 | * Initialized data is available in SPL right from the beginning. |
| 68 | * We would not typically need to save these parameters in regular |
| 69 | * U-Boot. This is needed only in SPL at the moment. |
| 70 | */ |
| 71 | u32 omap3_boot_device = BOOT_DEVICE_NAND; |
| 72 | |
| 73 | /* auto boot mode detection is not possible for OMAP3 - hard code */ |
Tom Rini | a76ff95 | 2012-08-14 09:19:44 -0700 | [diff] [blame] | 74 | u32 spl_boot_mode(void) |
Simon Schwarz | 992dcf7 | 2011-09-14 15:29:26 -0400 | [diff] [blame] | 75 | { |
Tom Rini | 0be93ff | 2012-08-13 12:53:23 -0700 | [diff] [blame] | 76 | switch (spl_boot_device()) { |
Simon Schwarz | 992dcf7 | 2011-09-14 15:29:26 -0400 | [diff] [blame] | 77 | case BOOT_DEVICE_MMC2: |
| 78 | return MMCSD_MODE_RAW; |
| 79 | case BOOT_DEVICE_MMC1: |
| 80 | return MMCSD_MODE_FAT; |
| 81 | break; |
Simon Schwarz | 992dcf7 | 2011-09-14 15:29:26 -0400 | [diff] [blame] | 82 | default: |
| 83 | puts("spl: ERROR: unknown device - can't select boot mode\n"); |
| 84 | hang(); |
| 85 | } |
| 86 | } |
| 87 | |
Tom Rini | 0be93ff | 2012-08-13 12:53:23 -0700 | [diff] [blame] | 88 | u32 spl_boot_device(void) |
Simon Schwarz | 992dcf7 | 2011-09-14 15:29:26 -0400 | [diff] [blame] | 89 | { |
| 90 | return omap3_boot_device; |
| 91 | } |
| 92 | |
Tom Rini | a0b9fa5 | 2012-08-14 10:25:15 -0700 | [diff] [blame^] | 93 | int board_mmc_init(bd_t *bis) |
| 94 | { |
| 95 | switch (spl_boot_device()) { |
| 96 | case BOOT_DEVICE_MMC1: |
| 97 | omap_mmc_init(0, 0, 0); |
| 98 | break; |
| 99 | case BOOT_DEVICE_MMC2: |
| 100 | case BOOT_DEVICE_MMC2_2: |
| 101 | omap_mmc_init(1, 0, 0); |
| 102 | break; |
| 103 | } |
| 104 | return 0; |
| 105 | } |
| 106 | |
Tom Rini | ead66c1 | 2011-11-23 05:13:06 +0000 | [diff] [blame] | 107 | void spl_board_init(void) |
| 108 | { |
Stefano Babic | 44fa188 | 2012-03-15 04:01:42 +0000 | [diff] [blame] | 109 | #ifdef CONFIG_SPL_I2C_SUPPORT |
Tom Rini | ead66c1 | 2011-11-23 05:13:06 +0000 | [diff] [blame] | 110 | i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); |
Stefano Babic | 44fa188 | 2012-03-15 04:01:42 +0000 | [diff] [blame] | 111 | #endif |
Tom Rini | ead66c1 | 2011-11-23 05:13:06 +0000 | [diff] [blame] | 112 | } |
Simon Schwarz | 992dcf7 | 2011-09-14 15:29:26 -0400 | [diff] [blame] | 113 | #endif /* CONFIG_SPL_BUILD */ |
| 114 | |
| 115 | |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 116 | /****************************************************************************** |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 117 | * Routine: secure_unlock |
| 118 | * Description: Setup security registers for access |
| 119 | * (GP Device only) |
| 120 | *****************************************************************************/ |
| 121 | void secure_unlock_mem(void) |
| 122 | { |
Dirk Behme | dc7af20 | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 123 | struct pm *pm_rt_ape_base = (struct pm *)PM_RT_APE_BASE_ADDR_ARM; |
| 124 | struct pm *pm_gpmc_base = (struct pm *)PM_GPMC_BASE_ADDR_ARM; |
| 125 | struct pm *pm_ocm_ram_base = (struct pm *)PM_OCM_RAM_BASE_ADDR_ARM; |
| 126 | struct pm *pm_iva2_base = (struct pm *)PM_IVA2_BASE_ADDR_ARM; |
| 127 | struct sms *sms_base = (struct sms *)OMAP34XX_SMS_BASE; |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 128 | |
| 129 | /* Protection Module Register Target APE (PM_RT) */ |
| 130 | writel(UNLOCK_1, &pm_rt_ape_base->req_info_permission_1); |
| 131 | writel(UNLOCK_1, &pm_rt_ape_base->read_permission_0); |
| 132 | writel(UNLOCK_1, &pm_rt_ape_base->wirte_permission_0); |
| 133 | writel(UNLOCK_2, &pm_rt_ape_base->addr_match_1); |
| 134 | |
| 135 | writel(UNLOCK_3, &pm_gpmc_base->req_info_permission_0); |
| 136 | writel(UNLOCK_3, &pm_gpmc_base->read_permission_0); |
| 137 | writel(UNLOCK_3, &pm_gpmc_base->wirte_permission_0); |
| 138 | |
| 139 | writel(UNLOCK_3, &pm_ocm_ram_base->req_info_permission_0); |
| 140 | writel(UNLOCK_3, &pm_ocm_ram_base->read_permission_0); |
| 141 | writel(UNLOCK_3, &pm_ocm_ram_base->wirte_permission_0); |
| 142 | writel(UNLOCK_2, &pm_ocm_ram_base->addr_match_2); |
| 143 | |
| 144 | /* IVA Changes */ |
| 145 | writel(UNLOCK_3, &pm_iva2_base->req_info_permission_0); |
| 146 | writel(UNLOCK_3, &pm_iva2_base->read_permission_0); |
| 147 | writel(UNLOCK_3, &pm_iva2_base->wirte_permission_0); |
| 148 | |
| 149 | /* SDRC region 0 public */ |
| 150 | writel(UNLOCK_1, &sms_base->rg_att0); |
| 151 | } |
| 152 | |
| 153 | /****************************************************************************** |
| 154 | * Routine: secureworld_exit() |
| 155 | * Description: If chip is EMU and boot type is external |
| 156 | * configure secure registers and exit secure world |
| 157 | * general use. |
| 158 | *****************************************************************************/ |
| 159 | void secureworld_exit() |
| 160 | { |
| 161 | unsigned long i; |
| 162 | |
Peter Meerwald | 7ea4b7c | 2012-02-02 12:51:02 +0000 | [diff] [blame] | 163 | /* configure non-secure access control register */ |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 164 | __asm__ __volatile__("mrc p15, 0, %0, c1, c1, 2":"=r"(i)); |
| 165 | /* enabling co-processor CP10 and CP11 accesses in NS world */ |
| 166 | __asm__ __volatile__("orr %0, %0, #0xC00":"=r"(i)); |
| 167 | /* |
| 168 | * allow allocation of locked TLBs and L2 lines in NS world |
| 169 | * allow use of PLE registers in NS world also |
| 170 | */ |
| 171 | __asm__ __volatile__("orr %0, %0, #0x70000":"=r"(i)); |
| 172 | __asm__ __volatile__("mcr p15, 0, %0, c1, c1, 2":"=r"(i)); |
| 173 | |
| 174 | /* Enable ASA in ACR register */ |
| 175 | __asm__ __volatile__("mrc p15, 0, %0, c1, c0, 1":"=r"(i)); |
| 176 | __asm__ __volatile__("orr %0, %0, #0x10":"=r"(i)); |
| 177 | __asm__ __volatile__("mcr p15, 0, %0, c1, c0, 1":"=r"(i)); |
| 178 | |
| 179 | /* Exiting secure world */ |
| 180 | __asm__ __volatile__("mrc p15, 0, %0, c1, c1, 0":"=r"(i)); |
| 181 | __asm__ __volatile__("orr %0, %0, #0x31":"=r"(i)); |
| 182 | __asm__ __volatile__("mcr p15, 0, %0, c1, c1, 0":"=r"(i)); |
| 183 | } |
| 184 | |
| 185 | /****************************************************************************** |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 186 | * Routine: try_unlock_sram() |
| 187 | * Description: If chip is GP/EMU(special) type, unlock the SRAM for |
| 188 | * general use. |
| 189 | *****************************************************************************/ |
| 190 | void try_unlock_memory() |
| 191 | { |
| 192 | int mode; |
| 193 | int in_sdram = is_running_in_sdram(); |
| 194 | |
| 195 | /* |
| 196 | * if GP device unlock device SRAM for general use |
| 197 | * secure code breaks for Secure/Emulation device - HS/E/T |
| 198 | */ |
| 199 | mode = get_device_type(); |
| 200 | if (mode == GP_DEVICE) |
| 201 | secure_unlock_mem(); |
| 202 | |
| 203 | /* |
| 204 | * If device is EMU and boot is XIP external booting |
| 205 | * Unlock firewalls and disable L2 and put chip |
| 206 | * out of secure world |
| 207 | * |
| 208 | * Assuming memories are unlocked by the demon who put us in SDRAM |
| 209 | */ |
| 210 | if ((mode <= EMU_DEVICE) && (get_boot_type() == 0x1F) |
| 211 | && (!in_sdram)) { |
| 212 | secure_unlock_mem(); |
| 213 | secureworld_exit(); |
| 214 | } |
| 215 | |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | /****************************************************************************** |
| 220 | * Routine: s_init |
| 221 | * Description: Does early system init of muxing and clocks. |
| 222 | * - Called path is with SRAM stack. |
| 223 | *****************************************************************************/ |
| 224 | void s_init(void) |
| 225 | { |
| 226 | int in_sdram = is_running_in_sdram(); |
| 227 | |
| 228 | watchdog_init(); |
| 229 | |
| 230 | try_unlock_memory(); |
| 231 | |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 232 | /* Errata workarounds */ |
| 233 | omap3_setup_aux_cr(); |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 234 | |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 235 | #ifndef CONFIG_SYS_L2CACHE_OFF |
| 236 | /* Invalidate L2-cache from secure mode */ |
| 237 | omap3_invalidate_l2_cache_secure(); |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 238 | #endif |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 239 | |
| 240 | set_muxconf_regs(); |
Alexander Holler | 4e333f6 | 2010-12-18 13:24:20 +0100 | [diff] [blame] | 241 | sdelay(100); |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 242 | |
| 243 | prcm_init(); |
| 244 | |
| 245 | per_clocks_enable(); |
| 246 | |
Govindraj.R | 3968a6a | 2012-02-06 03:55:35 +0000 | [diff] [blame] | 247 | #ifdef CONFIG_USB_EHCI_OMAP |
| 248 | ehci_clocks_enable(); |
| 249 | #endif |
| 250 | |
Simon Schwarz | 992dcf7 | 2011-09-14 15:29:26 -0400 | [diff] [blame] | 251 | #ifdef CONFIG_SPL_BUILD |
| 252 | preloader_console_init(); |
Andreas Müller | de3ffeb | 2012-01-04 15:26:23 +0000 | [diff] [blame] | 253 | |
| 254 | timer_init(); |
Simon Schwarz | 992dcf7 | 2011-09-14 15:29:26 -0400 | [diff] [blame] | 255 | #endif |
| 256 | |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 257 | if (!in_sdram) |
Vaibhav Hiremath | 558d23d | 2010-06-07 15:20:34 -0400 | [diff] [blame] | 258 | mem_init(); |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 259 | } |
| 260 | |
Tom Rini | 05df891 | 2012-04-13 12:20:03 +0000 | [diff] [blame] | 261 | /* |
| 262 | * Routine: misc_init_r |
| 263 | * Description: A basic misc_init_r that just displays the die ID |
| 264 | */ |
| 265 | int __weak misc_init_r(void) |
| 266 | { |
| 267 | dieid_num_r(); |
| 268 | |
| 269 | return 0; |
| 270 | } |
| 271 | |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 272 | /****************************************************************************** |
| 273 | * Routine: wait_for_command_complete |
| 274 | * Description: Wait for posting to finish on watchdog |
| 275 | *****************************************************************************/ |
Dirk Behme | dc7af20 | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 276 | void wait_for_command_complete(struct watchdog *wd_base) |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 277 | { |
| 278 | int pending = 1; |
| 279 | do { |
| 280 | pending = readl(&wd_base->wwps); |
| 281 | } while (pending); |
| 282 | } |
| 283 | |
| 284 | /****************************************************************************** |
| 285 | * Routine: watchdog_init |
| 286 | * Description: Shut down watch dogs |
| 287 | *****************************************************************************/ |
| 288 | void watchdog_init(void) |
| 289 | { |
Dirk Behme | dc7af20 | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 290 | struct watchdog *wd2_base = (struct watchdog *)WD2_BASE; |
| 291 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 292 | |
| 293 | /* |
| 294 | * There are 3 watch dogs WD1=Secure, WD2=MPU, WD3=IVA. WD1 is |
| 295 | * either taken care of by ROM (HS/EMU) or not accessible (GP). |
| 296 | * We need to take care of WD2-MPU or take a PRCM reset. WD3 |
| 297 | * should not be running and does not generate a PRCM reset. |
| 298 | */ |
| 299 | |
| 300 | sr32(&prcm_base->fclken_wkup, 5, 1, 1); |
| 301 | sr32(&prcm_base->iclken_wkup, 5, 1, 1); |
| 302 | wait_on_value(ST_WDT2, 0x20, &prcm_base->idlest_wkup, 5); |
| 303 | |
| 304 | writel(WD_UNLOCK1, &wd2_base->wspr); |
| 305 | wait_for_command_complete(wd2_base); |
| 306 | writel(WD_UNLOCK2, &wd2_base->wspr); |
| 307 | } |
| 308 | |
| 309 | /****************************************************************************** |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 310 | * Dummy function to handle errors for EABI incompatibility |
| 311 | *****************************************************************************/ |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 312 | void abort(void) |
| 313 | { |
| 314 | } |
| 315 | |
Simon Schwarz | 992dcf7 | 2011-09-14 15:29:26 -0400 | [diff] [blame] | 316 | #if defined(CONFIG_NAND_OMAP_GPMC) & !defined(CONFIG_SPL_BUILD) |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 317 | /****************************************************************************** |
| 318 | * OMAP3 specific command to switch between NAND HW and SW ecc |
| 319 | *****************************************************************************/ |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 320 | 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] | 321 | { |
| 322 | if (argc != 2) |
| 323 | goto usage; |
| 324 | if (strncmp(argv[1], "hw", 2) == 0) |
| 325 | omap_nand_switch_ecc(1); |
| 326 | else if (strncmp(argv[1], "sw", 2) == 0) |
| 327 | omap_nand_switch_ecc(0); |
| 328 | else |
| 329 | goto usage; |
| 330 | |
| 331 | return 0; |
| 332 | |
| 333 | usage: |
Sanjeev Premi | 15af998 | 2009-04-03 14:00:07 +0530 | [diff] [blame] | 334 | printf ("Usage: nandecc %s\n", cmdtp->usage); |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 335 | return 1; |
| 336 | } |
| 337 | |
| 338 | U_BOOT_CMD( |
| 339 | nandecc, 2, 1, do_switch_ecc, |
Robert P. J. Day | 3ea16c3 | 2009-11-17 07:30:23 -0500 | [diff] [blame] | 340 | "switch OMAP3 NAND ECC calculation algorithm", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 341 | "[hw/sw] - Switch between NAND hardware (hw) or software (sw) ecc algorithm" |
| 342 | ); |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 343 | |
Simon Schwarz | 992dcf7 | 2011-09-14 15:29:26 -0400 | [diff] [blame] | 344 | #endif /* CONFIG_NAND_OMAP_GPMC & !CONFIG_SPL_BUILD */ |
Sanjeev Premi | e32ef2e | 2009-04-27 21:27:27 +0530 | [diff] [blame] | 345 | |
| 346 | #ifdef CONFIG_DISPLAY_BOARDINFO |
| 347 | /** |
| 348 | * Print board information |
| 349 | */ |
| 350 | int checkboard (void) |
| 351 | { |
| 352 | char *mem_s ; |
| 353 | |
| 354 | if (is_mem_sdr()) |
| 355 | mem_s = "mSDR"; |
| 356 | else |
| 357 | mem_s = "LPDDR"; |
| 358 | |
| 359 | printf("%s + %s/%s\n", sysinfo.board_string, mem_s, |
| 360 | sysinfo.nand_string); |
| 361 | |
| 362 | return 0; |
| 363 | } |
| 364 | #endif /* CONFIG_DISPLAY_BOARDINFO */ |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 365 | |
| 366 | static void omap3_emu_romcode_call(u32 service_id, u32 *parameters) |
| 367 | { |
| 368 | u32 i, num_params = *parameters; |
| 369 | u32 *sram_scratch_space = (u32 *)OMAP3_PUBLIC_SRAM_SCRATCH_AREA; |
| 370 | |
| 371 | /* |
| 372 | * copy the parameters to an un-cached area to avoid coherency |
| 373 | * issues |
| 374 | */ |
| 375 | for (i = 0; i < num_params; i++) { |
| 376 | __raw_writel(*parameters, sram_scratch_space); |
| 377 | parameters++; |
| 378 | sram_scratch_space++; |
| 379 | } |
| 380 | |
| 381 | /* Now make the PPA call */ |
| 382 | do_omap3_emu_romcode_call(service_id, OMAP3_PUBLIC_SRAM_SCRATCH_AREA); |
| 383 | } |
| 384 | |
| 385 | static void omap3_update_aux_cr_secure(u32 set_bits, u32 clear_bits) |
| 386 | { |
| 387 | u32 acr; |
| 388 | |
| 389 | /* Read ACR */ |
| 390 | asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr)); |
| 391 | acr &= ~clear_bits; |
| 392 | acr |= set_bits; |
| 393 | |
| 394 | if (get_device_type() == GP_DEVICE) { |
| 395 | omap3_gp_romcode_call(OMAP3_GP_ROMCODE_API_WRITE_ACR, |
| 396 | acr); |
| 397 | } else { |
| 398 | struct emu_hal_params emu_romcode_params; |
| 399 | emu_romcode_params.num_params = 1; |
| 400 | emu_romcode_params.param1 = acr; |
| 401 | omap3_emu_romcode_call(OMAP3_EMU_HAL_API_WRITE_ACR, |
| 402 | (u32 *)&emu_romcode_params); |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | static void omap3_update_aux_cr(u32 set_bits, u32 clear_bits) |
| 407 | { |
| 408 | u32 acr; |
| 409 | |
| 410 | /* Read ACR */ |
| 411 | asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr)); |
| 412 | acr &= ~clear_bits; |
| 413 | acr |= set_bits; |
| 414 | |
| 415 | /* Write ACR - affects non-secure banked bits */ |
| 416 | asm volatile ("mcr p15, 0, %0, c1, c0, 1" : : "r" (acr)); |
| 417 | } |
| 418 | |
| 419 | static void omap3_setup_aux_cr(void) |
| 420 | { |
| 421 | /* Workaround for Cortex-A8 errata: #454179 #430973 |
| 422 | * Set "IBE" bit |
Peter Meerwald | 7ea4b7c | 2012-02-02 12:51:02 +0000 | [diff] [blame] | 423 | * Set "Disable Branch Size Mispredicts" bit |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 424 | * Workaround for erratum #621766 |
| 425 | * Enable L1NEON bit |
| 426 | * ACR |= (IBE | DBSM | L1NEON) => ACR |= 0xE0 |
| 427 | */ |
| 428 | omap3_update_aux_cr_secure(0xE0, 0); |
| 429 | } |
| 430 | |
| 431 | #ifndef CONFIG_SYS_L2CACHE_OFF |
| 432 | /* Invalidate the entire L2 cache from secure mode */ |
| 433 | static void omap3_invalidate_l2_cache_secure(void) |
| 434 | { |
| 435 | if (get_device_type() == GP_DEVICE) { |
| 436 | omap3_gp_romcode_call(OMAP3_GP_ROMCODE_API_L2_INVAL, |
| 437 | 0); |
| 438 | } else { |
| 439 | struct emu_hal_params emu_romcode_params; |
| 440 | emu_romcode_params.num_params = 1; |
| 441 | emu_romcode_params.param1 = 0; |
| 442 | omap3_emu_romcode_call(OMAP3_EMU_HAL_API_L2_INVAL, |
| 443 | (u32 *)&emu_romcode_params); |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | void v7_outer_cache_enable(void) |
| 448 | { |
| 449 | /* Set L2EN */ |
| 450 | omap3_update_aux_cr_secure(0x2, 0); |
| 451 | |
| 452 | /* |
| 453 | * On some revisions L2EN bit is banked on some revisions it's not |
| 454 | * No harm in setting both banked bits(in fact this is required |
| 455 | * by an erratum) |
| 456 | */ |
| 457 | omap3_update_aux_cr(0x2, 0); |
| 458 | } |
| 459 | |
Aneesh V | e0db71d | 2012-02-16 03:40:15 +0000 | [diff] [blame] | 460 | void omap3_outer_cache_disable(void) |
Aneesh V | d16dd01 | 2011-06-16 23:30:53 +0000 | [diff] [blame] | 461 | { |
| 462 | /* Clear L2EN */ |
| 463 | omap3_update_aux_cr_secure(0, 0x2); |
| 464 | |
| 465 | /* |
| 466 | * On some revisions L2EN bit is banked on some revisions it's not |
| 467 | * No harm in clearing both banked bits(in fact this is required |
| 468 | * by an erratum) |
| 469 | */ |
| 470 | omap3_update_aux_cr(0, 0x2); |
| 471 | } |
| 472 | #endif |
Aneesh V | 572134b | 2011-08-11 04:35:43 +0000 | [diff] [blame] | 473 | |
| 474 | #ifndef CONFIG_SYS_DCACHE_OFF |
| 475 | void enable_caches(void) |
| 476 | { |
| 477 | /* Enable D-cache. I-cache is already enabled in start.S */ |
| 478 | dcache_enable(); |
| 479 | } |
| 480 | #endif |