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