blob: e6996b50f6b91e3bc5561bb7e3b1cab7a57e252e [file] [log] [blame]
Dirk Behmee0e49fe2008-12-14 09:47:15 +01001/*
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 Denkd79de1d2013-07-08 09:37:19 +020017 * SPDX-License-Identifier: GPL-2.0+
Dirk Behmee0e49fe2008-12-14 09:47:15 +010018 */
19#include <common.h>
Simon Glassbc0f4ea2014-10-22 21:37:15 -060020#include <dm.h>
Tom Rini28591df2012-08-13 12:03:19 -070021#include <spl.h>
Dirk Behmee0e49fe2008-12-14 09:47:15 +010022#include <asm/io.h>
23#include <asm/arch/sys_proto.h>
24#include <asm/arch/mem.h>
Kim, Heung Jun3b5ac952009-06-20 11:02:17 +020025#include <asm/cache.h>
Aneesh Vd16dd012011-06-16 23:30:53 +000026#include <asm/armv7.h>
Simon Glassbc0f4ea2014-10-22 21:37:15 -060027#include <asm/gpio.h>
Simon Schwarz992dcf72011-09-14 15:29:26 -040028#include <asm/omap_common.h>
Tom Rinia0b9fa52012-08-14 10:25:15 -070029#include <asm/arch/mmc_host_def.h>
Tom Riniead66c12011-11-23 05:13:06 +000030#include <i2c.h>
Tom Rini05df8912012-04-13 12:20:03 +000031#include <linux/compiler.h>
Dirk Behmee0e49fe2008-12-14 09:47:15 +010032
Tom Rini31dfba42012-08-22 15:31:05 -070033DECLARE_GLOBAL_DATA_PTR;
34
Aneesh Vd16dd012011-06-16 23:30:53 +000035/* Declarations */
Dirk Behmee0e49fe2008-12-14 09:47:15 +010036extern omap3_sysinfo sysinfo;
Aneesh Vd16dd012011-06-16 23:30:53 +000037static void omap3_setup_aux_cr(void);
Tom Rinib759db32012-10-30 22:23:28 -070038#ifndef CONFIG_SYS_L2CACHE_OFF
Aneesh Vd16dd012011-06-16 23:30:53 +000039static void omap3_invalidate_l2_cache_secure(void);
Tom Rinib759db32012-10-30 22:23:28 -070040#endif
Dirk Behmee0e49fe2008-12-14 09:47:15 +010041
Simon Glassbc0f4ea2014-10-22 21:37:15 -060042#ifdef CONFIG_DM_GPIO
43static const struct omap_gpio_platdata omap34xx_gpio[] = {
44 { 0, OMAP34XX_GPIO1_BASE, METHOD_GPIO_24XX },
45 { 1, OMAP34XX_GPIO2_BASE, METHOD_GPIO_24XX },
46 { 2, OMAP34XX_GPIO3_BASE, METHOD_GPIO_24XX },
47 { 3, OMAP34XX_GPIO4_BASE, METHOD_GPIO_24XX },
48 { 4, OMAP34XX_GPIO5_BASE, METHOD_GPIO_24XX },
49 { 5, OMAP34XX_GPIO6_BASE, METHOD_GPIO_24XX },
50};
51
52U_BOOT_DEVICES(am33xx_gpios) = {
53 { "gpio_omap", &omap34xx_gpio[0] },
54 { "gpio_omap", &omap34xx_gpio[1] },
55 { "gpio_omap", &omap34xx_gpio[2] },
56 { "gpio_omap", &omap34xx_gpio[3] },
57 { "gpio_omap", &omap34xx_gpio[4] },
58 { "gpio_omap", &omap34xx_gpio[5] },
59};
60
61#else
62
Aneesh V9a390882011-07-21 09:29:29 -040063static const struct gpio_bank gpio_bank_34xx[6] = {
64 { (void *)OMAP34XX_GPIO1_BASE, METHOD_GPIO_24XX },
65 { (void *)OMAP34XX_GPIO2_BASE, METHOD_GPIO_24XX },
66 { (void *)OMAP34XX_GPIO3_BASE, METHOD_GPIO_24XX },
67 { (void *)OMAP34XX_GPIO4_BASE, METHOD_GPIO_24XX },
68 { (void *)OMAP34XX_GPIO5_BASE, METHOD_GPIO_24XX },
69 { (void *)OMAP34XX_GPIO6_BASE, METHOD_GPIO_24XX },
70};
71
72const struct gpio_bank *const omap_gpio_bank = gpio_bank_34xx;
73
Simon Glassbc0f4ea2014-10-22 21:37:15 -060074#endif
75
Simon Schwarz992dcf72011-09-14 15:29:26 -040076#ifdef CONFIG_SPL_BUILD
77/*
78* We use static variables because global data is not ready yet.
79* Initialized data is available in SPL right from the beginning.
80* We would not typically need to save these parameters in regular
81* U-Boot. This is needed only in SPL at the moment.
82*/
83u32 omap3_boot_device = BOOT_DEVICE_NAND;
84
85/* auto boot mode detection is not possible for OMAP3 - hard code */
Tom Rinia76ff952012-08-14 09:19:44 -070086u32 spl_boot_mode(void)
Simon Schwarz992dcf72011-09-14 15:29:26 -040087{
Tom Rini0be93ff2012-08-13 12:53:23 -070088 switch (spl_boot_device()) {
Simon Schwarz992dcf72011-09-14 15:29:26 -040089 case BOOT_DEVICE_MMC2:
90 return MMCSD_MODE_RAW;
91 case BOOT_DEVICE_MMC1:
92 return MMCSD_MODE_FAT;
93 break;
Simon Schwarz992dcf72011-09-14 15:29:26 -040094 default:
95 puts("spl: ERROR: unknown device - can't select boot mode\n");
96 hang();
97 }
98}
99
Tom Rini0be93ff2012-08-13 12:53:23 -0700100u32 spl_boot_device(void)
Simon Schwarz992dcf72011-09-14 15:29:26 -0400101{
102 return omap3_boot_device;
103}
104
Tom Rinia0b9fa52012-08-14 10:25:15 -0700105int board_mmc_init(bd_t *bis)
106{
107 switch (spl_boot_device()) {
108 case BOOT_DEVICE_MMC1:
Nikita Kiryanov4be9dbc2012-12-03 02:19:47 +0000109 omap_mmc_init(0, 0, 0, -1, -1);
Tom Rinia0b9fa52012-08-14 10:25:15 -0700110 break;
111 case BOOT_DEVICE_MMC2:
112 case BOOT_DEVICE_MMC2_2:
Nikita Kiryanov4be9dbc2012-12-03 02:19:47 +0000113 omap_mmc_init(1, 0, 0, -1, -1);
Tom Rinia0b9fa52012-08-14 10:25:15 -0700114 break;
115 }
116 return 0;
117}
118
Tom Riniead66c12011-11-23 05:13:06 +0000119void spl_board_init(void)
120{
Enric Balletbo i Serrab6d9efd2013-02-07 23:14:49 +0000121#if defined(CONFIG_SPL_NAND_SUPPORT) || defined(CONFIG_SPL_ONENAND_SUPPORT)
Tom Rini9e0c2602012-08-14 12:26:08 -0700122 gpmc_init();
123#endif
Stefano Babic44fa1882012-03-15 04:01:42 +0000124#ifdef CONFIG_SPL_I2C_SUPPORT
Heiko Schocherf53f2b82013-10-22 11:03:18 +0200125 i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
Stefano Babic44fa1882012-03-15 04:01:42 +0000126#endif
Tom Riniead66c12011-11-23 05:13:06 +0000127}
Simon Schwarz992dcf72011-09-14 15:29:26 -0400128#endif /* CONFIG_SPL_BUILD */
129
130
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100131/******************************************************************************
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100132 * Routine: secure_unlock
133 * Description: Setup security registers for access
134 * (GP Device only)
135 *****************************************************************************/
136void secure_unlock_mem(void)
137{
Dirk Behmedc7af202009-08-08 09:30:21 +0200138 struct pm *pm_rt_ape_base = (struct pm *)PM_RT_APE_BASE_ADDR_ARM;
139 struct pm *pm_gpmc_base = (struct pm *)PM_GPMC_BASE_ADDR_ARM;
140 struct pm *pm_ocm_ram_base = (struct pm *)PM_OCM_RAM_BASE_ADDR_ARM;
141 struct pm *pm_iva2_base = (struct pm *)PM_IVA2_BASE_ADDR_ARM;
142 struct sms *sms_base = (struct sms *)OMAP34XX_SMS_BASE;
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100143
144 /* Protection Module Register Target APE (PM_RT) */
145 writel(UNLOCK_1, &pm_rt_ape_base->req_info_permission_1);
146 writel(UNLOCK_1, &pm_rt_ape_base->read_permission_0);
147 writel(UNLOCK_1, &pm_rt_ape_base->wirte_permission_0);
148 writel(UNLOCK_2, &pm_rt_ape_base->addr_match_1);
149
150 writel(UNLOCK_3, &pm_gpmc_base->req_info_permission_0);
151 writel(UNLOCK_3, &pm_gpmc_base->read_permission_0);
152 writel(UNLOCK_3, &pm_gpmc_base->wirte_permission_0);
153
154 writel(UNLOCK_3, &pm_ocm_ram_base->req_info_permission_0);
155 writel(UNLOCK_3, &pm_ocm_ram_base->read_permission_0);
156 writel(UNLOCK_3, &pm_ocm_ram_base->wirte_permission_0);
157 writel(UNLOCK_2, &pm_ocm_ram_base->addr_match_2);
158
159 /* IVA Changes */
160 writel(UNLOCK_3, &pm_iva2_base->req_info_permission_0);
161 writel(UNLOCK_3, &pm_iva2_base->read_permission_0);
162 writel(UNLOCK_3, &pm_iva2_base->wirte_permission_0);
163
164 /* SDRC region 0 public */
165 writel(UNLOCK_1, &sms_base->rg_att0);
166}
167
168/******************************************************************************
169 * Routine: secureworld_exit()
170 * Description: If chip is EMU and boot type is external
171 * configure secure registers and exit secure world
172 * general use.
173 *****************************************************************************/
Jeroen Hofstee69ab3832014-06-16 23:22:23 +0200174void secureworld_exit(void)
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100175{
176 unsigned long i;
177
Peter Meerwald7ea4b7c2012-02-02 12:51:02 +0000178 /* configure non-secure access control register */
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100179 __asm__ __volatile__("mrc p15, 0, %0, c1, c1, 2":"=r"(i));
180 /* enabling co-processor CP10 and CP11 accesses in NS world */
181 __asm__ __volatile__("orr %0, %0, #0xC00":"=r"(i));
182 /*
183 * allow allocation of locked TLBs and L2 lines in NS world
184 * allow use of PLE registers in NS world also
185 */
186 __asm__ __volatile__("orr %0, %0, #0x70000":"=r"(i));
187 __asm__ __volatile__("mcr p15, 0, %0, c1, c1, 2":"=r"(i));
188
189 /* Enable ASA in ACR register */
190 __asm__ __volatile__("mrc p15, 0, %0, c1, c0, 1":"=r"(i));
191 __asm__ __volatile__("orr %0, %0, #0x10":"=r"(i));
192 __asm__ __volatile__("mcr p15, 0, %0, c1, c0, 1":"=r"(i));
193
194 /* Exiting secure world */
195 __asm__ __volatile__("mrc p15, 0, %0, c1, c1, 0":"=r"(i));
196 __asm__ __volatile__("orr %0, %0, #0x31":"=r"(i));
197 __asm__ __volatile__("mcr p15, 0, %0, c1, c1, 0":"=r"(i));
198}
199
200/******************************************************************************
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100201 * Routine: try_unlock_sram()
202 * Description: If chip is GP/EMU(special) type, unlock the SRAM for
203 * general use.
204 *****************************************************************************/
Jeroen Hofstee69ab3832014-06-16 23:22:23 +0200205void try_unlock_memory(void)
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100206{
207 int mode;
208 int in_sdram = is_running_in_sdram();
209
210 /*
211 * if GP device unlock device SRAM for general use
212 * secure code breaks for Secure/Emulation device - HS/E/T
213 */
214 mode = get_device_type();
215 if (mode == GP_DEVICE)
216 secure_unlock_mem();
217
218 /*
219 * If device is EMU and boot is XIP external booting
220 * Unlock firewalls and disable L2 and put chip
221 * out of secure world
222 *
223 * Assuming memories are unlocked by the demon who put us in SDRAM
224 */
225 if ((mode <= EMU_DEVICE) && (get_boot_type() == 0x1F)
226 && (!in_sdram)) {
227 secure_unlock_mem();
228 secureworld_exit();
229 }
230
231 return;
232}
233
234/******************************************************************************
235 * Routine: s_init
236 * Description: Does early system init of muxing and clocks.
237 * - Called path is with SRAM stack.
238 *****************************************************************************/
239void s_init(void)
240{
241 int in_sdram = is_running_in_sdram();
242
243 watchdog_init();
244
245 try_unlock_memory();
246
Aneesh Vd16dd012011-06-16 23:30:53 +0000247 /* Errata workarounds */
248 omap3_setup_aux_cr();
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100249
Aneesh Vd16dd012011-06-16 23:30:53 +0000250#ifndef CONFIG_SYS_L2CACHE_OFF
251 /* Invalidate L2-cache from secure mode */
252 omap3_invalidate_l2_cache_secure();
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100253#endif
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100254
255 set_muxconf_regs();
Alexander Holler4e333f62010-12-18 13:24:20 +0100256 sdelay(100);
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100257
258 prcm_init();
259
260 per_clocks_enable();
261
Govindraj.R3968a6a2012-02-06 03:55:35 +0000262#ifdef CONFIG_USB_EHCI_OMAP
263 ehci_clocks_enable();
264#endif
265
Simon Schwarz992dcf72011-09-14 15:29:26 -0400266#ifdef CONFIG_SPL_BUILD
Tom Rini31dfba42012-08-22 15:31:05 -0700267 gd = &gdata;
268
Simon Schwarz992dcf72011-09-14 15:29:26 -0400269 preloader_console_init();
Andreas Müllerde3ffeb2012-01-04 15:26:23 +0000270
271 timer_init();
Simon Schwarz992dcf72011-09-14 15:29:26 -0400272#endif
273
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100274 if (!in_sdram)
Vaibhav Hiremath558d23d2010-06-07 15:20:34 -0400275 mem_init();
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100276}
277
Tom Rini05df8912012-04-13 12:20:03 +0000278/*
279 * Routine: misc_init_r
280 * Description: A basic misc_init_r that just displays the die ID
281 */
282int __weak misc_init_r(void)
283{
284 dieid_num_r();
285
286 return 0;
287}
288
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100289/******************************************************************************
290 * Routine: wait_for_command_complete
291 * Description: Wait for posting to finish on watchdog
292 *****************************************************************************/
Dirk Behmedc7af202009-08-08 09:30:21 +0200293void wait_for_command_complete(struct watchdog *wd_base)
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100294{
295 int pending = 1;
296 do {
297 pending = readl(&wd_base->wwps);
298 } while (pending);
299}
300
301/******************************************************************************
302 * Routine: watchdog_init
303 * Description: Shut down watch dogs
304 *****************************************************************************/
305void watchdog_init(void)
306{
Dirk Behmedc7af202009-08-08 09:30:21 +0200307 struct watchdog *wd2_base = (struct watchdog *)WD2_BASE;
308 struct prcm *prcm_base = (struct prcm *)PRCM_BASE;
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100309
310 /*
311 * There are 3 watch dogs WD1=Secure, WD2=MPU, WD3=IVA. WD1 is
312 * either taken care of by ROM (HS/EMU) or not accessible (GP).
313 * We need to take care of WD2-MPU or take a PRCM reset. WD3
314 * should not be running and does not generate a PRCM reset.
315 */
316
Wolfgang Denk42b97cb2014-03-25 14:49:48 +0100317 setbits_le32(&prcm_base->fclken_wkup, 0x20);
318 setbits_le32(&prcm_base->iclken_wkup, 0x20);
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100319 wait_on_value(ST_WDT2, 0x20, &prcm_base->idlest_wkup, 5);
320
321 writel(WD_UNLOCK1, &wd2_base->wspr);
322 wait_for_command_complete(wd2_base);
323 writel(WD_UNLOCK2, &wd2_base->wspr);
324}
325
326/******************************************************************************
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100327 * Dummy function to handle errors for EABI incompatibility
328 *****************************************************************************/
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100329void abort(void)
330{
331}
332
Simon Schwarz992dcf72011-09-14 15:29:26 -0400333#if defined(CONFIG_NAND_OMAP_GPMC) & !defined(CONFIG_SPL_BUILD)
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100334/******************************************************************************
335 * OMAP3 specific command to switch between NAND HW and SW ecc
336 *****************************************************************************/
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200337static int do_switch_ecc(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100338{
Andreas Bießmann1e4eccf2013-04-04 23:52:50 +0000339 if (argc < 2 || argc > 3)
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100340 goto usage;
Andreas Bießmann1e4eccf2013-04-04 23:52:50 +0000341
342 if (strncmp(argv[1], "hw", 2) == 0) {
343 if (argc == 2) {
344 omap_nand_switch_ecc(1, 1);
345 } else {
346 if (strncmp(argv[2], "hamming", 7) == 0)
347 omap_nand_switch_ecc(1, 1);
348 else if (strncmp(argv[2], "bch8", 4) == 0)
349 omap_nand_switch_ecc(1, 8);
350 else
351 goto usage;
352 }
353 } else if (strncmp(argv[1], "sw", 2) == 0) {
354 omap_nand_switch_ecc(0, 0);
355 } else {
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100356 goto usage;
Andreas Bießmann1e4eccf2013-04-04 23:52:50 +0000357 }
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100358
359 return 0;
360
361usage:
Sanjeev Premi15af9982009-04-03 14:00:07 +0530362 printf ("Usage: nandecc %s\n", cmdtp->usage);
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100363 return 1;
364}
365
366U_BOOT_CMD(
Andreas Bießmann1e4eccf2013-04-04 23:52:50 +0000367 nandecc, 3, 1, do_switch_ecc,
Robert P. J. Day3ea16c32009-11-17 07:30:23 -0500368 "switch OMAP3 NAND ECC calculation algorithm",
Andreas Bießmann1e4eccf2013-04-04 23:52:50 +0000369 "hw [hamming|bch8] - Switch between NAND hardware 1-bit hamming and"
370 " 8-bit BCH\n"
371 " ecc calculation (second parameter may"
372 " be omitted).\n"
373 "nandecc sw - Switch to NAND software ecc algorithm."
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200374);
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100375
Simon Schwarz992dcf72011-09-14 15:29:26 -0400376#endif /* CONFIG_NAND_OMAP_GPMC & !CONFIG_SPL_BUILD */
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530377
378#ifdef CONFIG_DISPLAY_BOARDINFO
379/**
380 * Print board information
381 */
382int checkboard (void)
383{
384 char *mem_s ;
385
386 if (is_mem_sdr())
387 mem_s = "mSDR";
388 else
389 mem_s = "LPDDR";
390
391 printf("%s + %s/%s\n", sysinfo.board_string, mem_s,
392 sysinfo.nand_string);
393
394 return 0;
395}
396#endif /* CONFIG_DISPLAY_BOARDINFO */
Aneesh Vd16dd012011-06-16 23:30:53 +0000397
398static void omap3_emu_romcode_call(u32 service_id, u32 *parameters)
399{
400 u32 i, num_params = *parameters;
401 u32 *sram_scratch_space = (u32 *)OMAP3_PUBLIC_SRAM_SCRATCH_AREA;
402
403 /*
404 * copy the parameters to an un-cached area to avoid coherency
405 * issues
406 */
407 for (i = 0; i < num_params; i++) {
408 __raw_writel(*parameters, sram_scratch_space);
409 parameters++;
410 sram_scratch_space++;
411 }
412
413 /* Now make the PPA call */
414 do_omap3_emu_romcode_call(service_id, OMAP3_PUBLIC_SRAM_SCRATCH_AREA);
415}
416
417static void omap3_update_aux_cr_secure(u32 set_bits, u32 clear_bits)
418{
419 u32 acr;
420
421 /* Read ACR */
422 asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr));
423 acr &= ~clear_bits;
424 acr |= set_bits;
425
426 if (get_device_type() == GP_DEVICE) {
427 omap3_gp_romcode_call(OMAP3_GP_ROMCODE_API_WRITE_ACR,
428 acr);
429 } else {
430 struct emu_hal_params emu_romcode_params;
431 emu_romcode_params.num_params = 1;
432 emu_romcode_params.param1 = acr;
433 omap3_emu_romcode_call(OMAP3_EMU_HAL_API_WRITE_ACR,
434 (u32 *)&emu_romcode_params);
435 }
436}
437
Aneesh Vd16dd012011-06-16 23:30:53 +0000438static void omap3_setup_aux_cr(void)
439{
440 /* Workaround for Cortex-A8 errata: #454179 #430973
441 * Set "IBE" bit
Peter Meerwald7ea4b7c2012-02-02 12:51:02 +0000442 * Set "Disable Branch Size Mispredicts" bit
Aneesh Vd16dd012011-06-16 23:30:53 +0000443 * Workaround for erratum #621766
444 * Enable L1NEON bit
445 * ACR |= (IBE | DBSM | L1NEON) => ACR |= 0xE0
446 */
447 omap3_update_aux_cr_secure(0xE0, 0);
448}
449
450#ifndef CONFIG_SYS_L2CACHE_OFF
Tom Rinib759db32012-10-30 22:23:28 -0700451static void omap3_update_aux_cr(u32 set_bits, u32 clear_bits)
452{
453 u32 acr;
454
455 /* Read ACR */
456 asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr));
457 acr &= ~clear_bits;
458 acr |= set_bits;
459
460 /* Write ACR - affects non-secure banked bits */
461 asm volatile ("mcr p15, 0, %0, c1, c0, 1" : : "r" (acr));
462}
463
Aneesh Vd16dd012011-06-16 23:30:53 +0000464/* Invalidate the entire L2 cache from secure mode */
465static void omap3_invalidate_l2_cache_secure(void)
466{
467 if (get_device_type() == GP_DEVICE) {
468 omap3_gp_romcode_call(OMAP3_GP_ROMCODE_API_L2_INVAL,
469 0);
470 } else {
471 struct emu_hal_params emu_romcode_params;
472 emu_romcode_params.num_params = 1;
473 emu_romcode_params.param1 = 0;
474 omap3_emu_romcode_call(OMAP3_EMU_HAL_API_L2_INVAL,
475 (u32 *)&emu_romcode_params);
476 }
477}
478
479void v7_outer_cache_enable(void)
480{
481 /* Set L2EN */
482 omap3_update_aux_cr_secure(0x2, 0);
483
484 /*
485 * On some revisions L2EN bit is banked on some revisions it's not
486 * No harm in setting both banked bits(in fact this is required
487 * by an erratum)
488 */
489 omap3_update_aux_cr(0x2, 0);
490}
491
Aneesh Ve0db71d2012-02-16 03:40:15 +0000492void omap3_outer_cache_disable(void)
Aneesh Vd16dd012011-06-16 23:30:53 +0000493{
494 /* Clear L2EN */
495 omap3_update_aux_cr_secure(0, 0x2);
496
497 /*
498 * On some revisions L2EN bit is banked on some revisions it's not
499 * No harm in clearing both banked bits(in fact this is required
500 * by an erratum)
501 */
502 omap3_update_aux_cr(0, 0x2);
503}
Robert P. J. Day3bb3c292012-11-13 07:57:54 +0000504#endif /* !CONFIG_SYS_L2CACHE_OFF */