1983e3700STom Rini /*
2983e3700STom Rini *
3983e3700STom Rini * Common board functions for OMAP3 based boards.
4983e3700STom Rini *
5983e3700STom Rini * (C) Copyright 2004-2008
6983e3700STom Rini * Texas Instruments, <www.ti.com>
7983e3700STom Rini *
8983e3700STom Rini * Author :
9983e3700STom Rini * Sunil Kumar <sunilsaini05@gmail.com>
10983e3700STom Rini * Shashi Ranjan <shashiranjanmca05@gmail.com>
11983e3700STom Rini *
12983e3700STom Rini * Derived from Beagle Board and 3430 SDP code by
13983e3700STom Rini * Richard Woodruff <r-woodruff2@ti.com>
14983e3700STom Rini * Syed Mohammed Khasim <khasim@ti.com>
15983e3700STom Rini *
16983e3700STom Rini *
17983e3700STom Rini * SPDX-License-Identifier: GPL-2.0+
18983e3700STom Rini */
19983e3700STom Rini #include <common.h>
20983e3700STom Rini #include <dm.h>
21983e3700STom Rini #include <spl.h>
22983e3700STom Rini #include <asm/io.h>
23983e3700STom Rini #include <asm/arch/sys_proto.h>
24983e3700STom Rini #include <asm/arch/mem.h>
25983e3700STom Rini #include <asm/cache.h>
26983e3700STom Rini #include <asm/armv7.h>
27983e3700STom Rini #include <asm/gpio.h>
28983e3700STom Rini #include <asm/omap_common.h>
29983e3700STom Rini #include <linux/compiler.h>
30983e3700STom Rini
31983e3700STom Rini DECLARE_GLOBAL_DATA_PTR;
32983e3700STom Rini
33983e3700STom Rini /* Declarations */
34983e3700STom Rini extern omap3_sysinfo sysinfo;
35983e3700STom Rini #ifndef CONFIG_SYS_L2CACHE_OFF
36983e3700STom Rini static void omap3_invalidate_l2_cache_secure(void);
37983e3700STom Rini #endif
38983e3700STom Rini
39983e3700STom Rini #ifdef CONFIG_DM_GPIO
40983e3700STom Rini static const struct omap_gpio_platdata omap34xx_gpio[] = {
41983e3700STom Rini { 0, OMAP34XX_GPIO1_BASE },
42983e3700STom Rini { 1, OMAP34XX_GPIO2_BASE },
43983e3700STom Rini { 2, OMAP34XX_GPIO3_BASE },
44983e3700STom Rini { 3, OMAP34XX_GPIO4_BASE },
45983e3700STom Rini { 4, OMAP34XX_GPIO5_BASE },
46983e3700STom Rini { 5, OMAP34XX_GPIO6_BASE },
47983e3700STom Rini };
48983e3700STom Rini
4944913aa5SAdam Ford U_BOOT_DEVICES(omap34xx_gpios) = {
50983e3700STom Rini { "gpio_omap", &omap34xx_gpio[0] },
51983e3700STom Rini { "gpio_omap", &omap34xx_gpio[1] },
52983e3700STom Rini { "gpio_omap", &omap34xx_gpio[2] },
53983e3700STom Rini { "gpio_omap", &omap34xx_gpio[3] },
54983e3700STom Rini { "gpio_omap", &omap34xx_gpio[4] },
55983e3700STom Rini { "gpio_omap", &omap34xx_gpio[5] },
56983e3700STom Rini };
57983e3700STom Rini
58983e3700STom Rini #else
59983e3700STom Rini
60983e3700STom Rini static const struct gpio_bank gpio_bank_34xx[6] = {
61983e3700STom Rini { (void *)OMAP34XX_GPIO1_BASE },
62983e3700STom Rini { (void *)OMAP34XX_GPIO2_BASE },
63983e3700STom Rini { (void *)OMAP34XX_GPIO3_BASE },
64983e3700STom Rini { (void *)OMAP34XX_GPIO4_BASE },
65983e3700STom Rini { (void *)OMAP34XX_GPIO5_BASE },
66983e3700STom Rini { (void *)OMAP34XX_GPIO6_BASE },
67983e3700STom Rini };
68983e3700STom Rini
69983e3700STom Rini const struct gpio_bank *const omap_gpio_bank = gpio_bank_34xx;
70983e3700STom Rini
71983e3700STom Rini #endif
72983e3700STom Rini
73983e3700STom Rini /******************************************************************************
74983e3700STom Rini * Routine: secure_unlock
75983e3700STom Rini * Description: Setup security registers for access
76983e3700STom Rini * (GP Device only)
77983e3700STom Rini *****************************************************************************/
secure_unlock_mem(void)78983e3700STom Rini void secure_unlock_mem(void)
79983e3700STom Rini {
80983e3700STom Rini struct pm *pm_rt_ape_base = (struct pm *)PM_RT_APE_BASE_ADDR_ARM;
81983e3700STom Rini struct pm *pm_gpmc_base = (struct pm *)PM_GPMC_BASE_ADDR_ARM;
82983e3700STom Rini struct pm *pm_ocm_ram_base = (struct pm *)PM_OCM_RAM_BASE_ADDR_ARM;
83983e3700STom Rini struct pm *pm_iva2_base = (struct pm *)PM_IVA2_BASE_ADDR_ARM;
84983e3700STom Rini struct sms *sms_base = (struct sms *)OMAP34XX_SMS_BASE;
85983e3700STom Rini
86983e3700STom Rini /* Protection Module Register Target APE (PM_RT) */
87983e3700STom Rini writel(UNLOCK_1, &pm_rt_ape_base->req_info_permission_1);
88983e3700STom Rini writel(UNLOCK_1, &pm_rt_ape_base->read_permission_0);
89983e3700STom Rini writel(UNLOCK_1, &pm_rt_ape_base->wirte_permission_0);
90983e3700STom Rini writel(UNLOCK_2, &pm_rt_ape_base->addr_match_1);
91983e3700STom Rini
92983e3700STom Rini writel(UNLOCK_3, &pm_gpmc_base->req_info_permission_0);
93983e3700STom Rini writel(UNLOCK_3, &pm_gpmc_base->read_permission_0);
94983e3700STom Rini writel(UNLOCK_3, &pm_gpmc_base->wirte_permission_0);
95983e3700STom Rini
96983e3700STom Rini writel(UNLOCK_3, &pm_ocm_ram_base->req_info_permission_0);
97983e3700STom Rini writel(UNLOCK_3, &pm_ocm_ram_base->read_permission_0);
98983e3700STom Rini writel(UNLOCK_3, &pm_ocm_ram_base->wirte_permission_0);
99983e3700STom Rini writel(UNLOCK_2, &pm_ocm_ram_base->addr_match_2);
100983e3700STom Rini
101983e3700STom Rini /* IVA Changes */
102983e3700STom Rini writel(UNLOCK_3, &pm_iva2_base->req_info_permission_0);
103983e3700STom Rini writel(UNLOCK_3, &pm_iva2_base->read_permission_0);
104983e3700STom Rini writel(UNLOCK_3, &pm_iva2_base->wirte_permission_0);
105983e3700STom Rini
106983e3700STom Rini /* SDRC region 0 public */
107983e3700STom Rini writel(UNLOCK_1, &sms_base->rg_att0);
108983e3700STom Rini }
109983e3700STom Rini
110983e3700STom Rini /******************************************************************************
111983e3700STom Rini * Routine: secureworld_exit()
112983e3700STom Rini * Description: If chip is EMU and boot type is external
113983e3700STom Rini * configure secure registers and exit secure world
114983e3700STom Rini * general use.
115983e3700STom Rini *****************************************************************************/
secureworld_exit(void)116983e3700STom Rini void secureworld_exit(void)
117983e3700STom Rini {
118983e3700STom Rini unsigned long i;
119983e3700STom Rini
120983e3700STom Rini /* configure non-secure access control register */
121983e3700STom Rini __asm__ __volatile__("mrc p15, 0, %0, c1, c1, 2":"=r"(i));
122983e3700STom Rini /* enabling co-processor CP10 and CP11 accesses in NS world */
123983e3700STom Rini __asm__ __volatile__("orr %0, %0, #0xC00":"=r"(i));
124983e3700STom Rini /*
125983e3700STom Rini * allow allocation of locked TLBs and L2 lines in NS world
126983e3700STom Rini * allow use of PLE registers in NS world also
127983e3700STom Rini */
128983e3700STom Rini __asm__ __volatile__("orr %0, %0, #0x70000":"=r"(i));
129983e3700STom Rini __asm__ __volatile__("mcr p15, 0, %0, c1, c1, 2":"=r"(i));
130983e3700STom Rini
131983e3700STom Rini /* Enable ASA in ACR register */
132983e3700STom Rini __asm__ __volatile__("mrc p15, 0, %0, c1, c0, 1":"=r"(i));
133983e3700STom Rini __asm__ __volatile__("orr %0, %0, #0x10":"=r"(i));
134983e3700STom Rini __asm__ __volatile__("mcr p15, 0, %0, c1, c0, 1":"=r"(i));
135983e3700STom Rini
136983e3700STom Rini /* Exiting secure world */
137983e3700STom Rini __asm__ __volatile__("mrc p15, 0, %0, c1, c1, 0":"=r"(i));
138983e3700STom Rini __asm__ __volatile__("orr %0, %0, #0x31":"=r"(i));
139983e3700STom Rini __asm__ __volatile__("mcr p15, 0, %0, c1, c1, 0":"=r"(i));
140983e3700STom Rini }
141983e3700STom Rini
142983e3700STom Rini /******************************************************************************
143983e3700STom Rini * Routine: try_unlock_sram()
144983e3700STom Rini * Description: If chip is GP/EMU(special) type, unlock the SRAM for
145983e3700STom Rini * general use.
146983e3700STom Rini *****************************************************************************/
try_unlock_memory(void)147983e3700STom Rini void try_unlock_memory(void)
148983e3700STom Rini {
149983e3700STom Rini int mode;
150983e3700STom Rini int in_sdram = is_running_in_sdram();
151983e3700STom Rini
152983e3700STom Rini /*
153983e3700STom Rini * if GP device unlock device SRAM for general use
154983e3700STom Rini * secure code breaks for Secure/Emulation device - HS/E/T
155983e3700STom Rini */
156983e3700STom Rini mode = get_device_type();
157983e3700STom Rini if (mode == GP_DEVICE)
158983e3700STom Rini secure_unlock_mem();
159983e3700STom Rini
160983e3700STom Rini /*
161983e3700STom Rini * If device is EMU and boot is XIP external booting
162983e3700STom Rini * Unlock firewalls and disable L2 and put chip
163983e3700STom Rini * out of secure world
164983e3700STom Rini *
165983e3700STom Rini * Assuming memories are unlocked by the demon who put us in SDRAM
166983e3700STom Rini */
167983e3700STom Rini if ((mode <= EMU_DEVICE) && (get_boot_type() == 0x1F)
168983e3700STom Rini && (!in_sdram)) {
169983e3700STom Rini secure_unlock_mem();
170983e3700STom Rini secureworld_exit();
171983e3700STom Rini }
172983e3700STom Rini
173983e3700STom Rini return;
174983e3700STom Rini }
175983e3700STom Rini
early_system_init(void)17600bbe96eSSemen Protsenko void early_system_init(void)
17700bbe96eSSemen Protsenko {
17800bbe96eSSemen Protsenko hw_data_init();
17900bbe96eSSemen Protsenko }
18000bbe96eSSemen Protsenko
181983e3700STom Rini /******************************************************************************
182983e3700STom Rini * Routine: s_init
183983e3700STom Rini * Description: Does early system init of muxing and clocks.
184983e3700STom Rini * - Called path is with SRAM stack.
185983e3700STom Rini *****************************************************************************/
s_init(void)186983e3700STom Rini void s_init(void)
187983e3700STom Rini {
188983e3700STom Rini watchdog_init();
18900bbe96eSSemen Protsenko early_system_init();
190983e3700STom Rini
191983e3700STom Rini try_unlock_memory();
192983e3700STom Rini
193983e3700STom Rini #ifndef CONFIG_SYS_L2CACHE_OFF
194983e3700STom Rini /* Invalidate L2-cache from secure mode */
195983e3700STom Rini omap3_invalidate_l2_cache_secure();
196983e3700STom Rini #endif
197983e3700STom Rini
198983e3700STom Rini set_muxconf_regs();
199983e3700STom Rini sdelay(100);
200983e3700STom Rini
201983e3700STom Rini prcm_init();
202983e3700STom Rini
203983e3700STom Rini per_clocks_enable();
204983e3700STom Rini
205983e3700STom Rini #ifdef CONFIG_USB_EHCI_OMAP
206983e3700STom Rini ehci_clocks_enable();
207983e3700STom Rini #endif
208983e3700STom Rini }
209983e3700STom Rini
210983e3700STom Rini #ifdef CONFIG_SPL_BUILD
board_init_f(ulong dummy)211983e3700STom Rini void board_init_f(ulong dummy)
212983e3700STom Rini {
21300bbe96eSSemen Protsenko early_system_init();
214983e3700STom Rini mem_init();
215*c3bec547SAdam Ford /*
216*c3bec547SAdam Ford * Save the boot parameters passed from romcode.
217*c3bec547SAdam Ford * We cannot delay the saving further than this,
218*c3bec547SAdam Ford * to prevent overwrites.
219*c3bec547SAdam Ford */
220*c3bec547SAdam Ford save_omap_boot_params();
221983e3700STom Rini }
222983e3700STom Rini #endif
223983e3700STom Rini
224983e3700STom Rini /*
225983e3700STom Rini * Routine: misc_init_r
226983e3700STom Rini * Description: A basic misc_init_r that just displays the die ID
227983e3700STom Rini */
misc_init_r(void)228983e3700STom Rini int __weak misc_init_r(void)
229983e3700STom Rini {
230983e3700STom Rini omap_die_id_display();
231983e3700STom Rini
232983e3700STom Rini return 0;
233983e3700STom Rini }
234983e3700STom Rini
235983e3700STom Rini /******************************************************************************
236983e3700STom Rini * Routine: wait_for_command_complete
237983e3700STom Rini * Description: Wait for posting to finish on watchdog
238983e3700STom Rini *****************************************************************************/
wait_for_command_complete(struct watchdog * wd_base)239983e3700STom Rini static void wait_for_command_complete(struct watchdog *wd_base)
240983e3700STom Rini {
241983e3700STom Rini int pending = 1;
242983e3700STom Rini do {
243983e3700STom Rini pending = readl(&wd_base->wwps);
244983e3700STom Rini } while (pending);
245983e3700STom Rini }
246983e3700STom Rini
247983e3700STom Rini /******************************************************************************
248983e3700STom Rini * Routine: watchdog_init
249983e3700STom Rini * Description: Shut down watch dogs
250983e3700STom Rini *****************************************************************************/
watchdog_init(void)251983e3700STom Rini void watchdog_init(void)
252983e3700STom Rini {
253983e3700STom Rini struct watchdog *wd2_base = (struct watchdog *)WD2_BASE;
254983e3700STom Rini struct prcm *prcm_base = (struct prcm *)PRCM_BASE;
255983e3700STom Rini
256983e3700STom Rini /*
257983e3700STom Rini * There are 3 watch dogs WD1=Secure, WD2=MPU, WD3=IVA. WD1 is
258983e3700STom Rini * either taken care of by ROM (HS/EMU) or not accessible (GP).
259983e3700STom Rini * We need to take care of WD2-MPU or take a PRCM reset. WD3
260983e3700STom Rini * should not be running and does not generate a PRCM reset.
261983e3700STom Rini */
262983e3700STom Rini
263983e3700STom Rini setbits_le32(&prcm_base->fclken_wkup, 0x20);
264983e3700STom Rini setbits_le32(&prcm_base->iclken_wkup, 0x20);
265983e3700STom Rini wait_on_value(ST_WDT2, 0x20, &prcm_base->idlest_wkup, 5);
266983e3700STom Rini
267983e3700STom Rini writel(WD_UNLOCK1, &wd2_base->wspr);
268983e3700STom Rini wait_for_command_complete(wd2_base);
269983e3700STom Rini writel(WD_UNLOCK2, &wd2_base->wspr);
270983e3700STom Rini }
271983e3700STom Rini
272983e3700STom Rini /******************************************************************************
273983e3700STom Rini * Dummy function to handle errors for EABI incompatibility
274983e3700STom Rini *****************************************************************************/
abort(void)275983e3700STom Rini void abort(void)
276983e3700STom Rini {
277983e3700STom Rini }
278983e3700STom Rini
279983e3700STom Rini #if defined(CONFIG_NAND_OMAP_GPMC) & !defined(CONFIG_SPL_BUILD)
280983e3700STom Rini /******************************************************************************
281983e3700STom Rini * OMAP3 specific command to switch between NAND HW and SW ecc
282983e3700STom Rini *****************************************************************************/
do_switch_ecc(cmd_tbl_t * cmdtp,int flag,int argc,char * const argv[])283983e3700STom Rini static int do_switch_ecc(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
284983e3700STom Rini {
28550075153SLadislav Michl int hw, strength = 1;
28650075153SLadislav Michl
287983e3700STom Rini if (argc < 2 || argc > 3)
288983e3700STom Rini goto usage;
289983e3700STom Rini
290983e3700STom Rini if (strncmp(argv[1], "hw", 2) == 0) {
29150075153SLadislav Michl hw = 1;
29250075153SLadislav Michl if (argc == 3) {
29350075153SLadislav Michl if (strncmp(argv[2], "bch8", 4) == 0)
29450075153SLadislav Michl strength = 8;
295983e3700STom Rini else if (strncmp(argv[2], "bch16", 5) == 0)
29650075153SLadislav Michl strength = 16;
29750075153SLadislav Michl else if (strncmp(argv[2], "hamming", 7) != 0)
298983e3700STom Rini goto usage;
299983e3700STom Rini }
300983e3700STom Rini } else if (strncmp(argv[1], "sw", 2) == 0) {
30150075153SLadislav Michl hw = 0;
30250075153SLadislav Michl if (argc == 3) {
30350075153SLadislav Michl if (strncmp(argv[2], "bch8", 4) == 0)
30450075153SLadislav Michl strength = 8;
30550075153SLadislav Michl else if (strncmp(argv[2], "hamming", 7) != 0)
306983e3700STom Rini goto usage;
307983e3700STom Rini }
308983e3700STom Rini } else {
309983e3700STom Rini goto usage;
310983e3700STom Rini }
311983e3700STom Rini
31250075153SLadislav Michl return -omap_nand_switch_ecc(hw, strength);
313983e3700STom Rini
314983e3700STom Rini usage:
315983e3700STom Rini printf ("Usage: nandecc %s\n", cmdtp->usage);
316983e3700STom Rini return 1;
317983e3700STom Rini }
318983e3700STom Rini
319983e3700STom Rini U_BOOT_CMD(
320983e3700STom Rini nandecc, 3, 1, do_switch_ecc,
321983e3700STom Rini "switch OMAP3 NAND ECC calculation algorithm",
322983e3700STom Rini "hw [hamming|bch8|bch16] - Switch between NAND hardware 1-bit hamming"
323983e3700STom Rini " and 8-bit/16-bit BCH\n"
324983e3700STom Rini " ecc calculation (second parameter may"
325983e3700STom Rini " be omitted).\n"
326983e3700STom Rini "nandecc sw - Switch to NAND software ecc algorithm."
327983e3700STom Rini );
328983e3700STom Rini
329983e3700STom Rini #endif /* CONFIG_NAND_OMAP_GPMC & !CONFIG_SPL_BUILD */
330983e3700STom Rini
331983e3700STom Rini #ifdef CONFIG_DISPLAY_BOARDINFO
332983e3700STom Rini /**
333983e3700STom Rini * Print board information
334983e3700STom Rini */
checkboard(void)335983e3700STom Rini int checkboard (void)
336983e3700STom Rini {
337983e3700STom Rini char *mem_s ;
338983e3700STom Rini
339983e3700STom Rini if (is_mem_sdr())
340983e3700STom Rini mem_s = "mSDR";
341983e3700STom Rini else
342983e3700STom Rini mem_s = "LPDDR";
343983e3700STom Rini
344983e3700STom Rini printf("%s + %s/%s\n", sysinfo.board_string, mem_s,
345983e3700STom Rini sysinfo.nand_string);
346983e3700STom Rini
347983e3700STom Rini return 0;
348983e3700STom Rini }
349983e3700STom Rini #endif /* CONFIG_DISPLAY_BOARDINFO */
350983e3700STom Rini
omap3_emu_romcode_call(u32 service_id,u32 * parameters)351983e3700STom Rini static void omap3_emu_romcode_call(u32 service_id, u32 *parameters)
352983e3700STom Rini {
353983e3700STom Rini u32 i, num_params = *parameters;
354983e3700STom Rini u32 *sram_scratch_space = (u32 *)OMAP3_PUBLIC_SRAM_SCRATCH_AREA;
355983e3700STom Rini
356983e3700STom Rini /*
357983e3700STom Rini * copy the parameters to an un-cached area to avoid coherency
358983e3700STom Rini * issues
359983e3700STom Rini */
360983e3700STom Rini for (i = 0; i < num_params; i++) {
361983e3700STom Rini __raw_writel(*parameters, sram_scratch_space);
362983e3700STom Rini parameters++;
363983e3700STom Rini sram_scratch_space++;
364983e3700STom Rini }
365983e3700STom Rini
366983e3700STom Rini /* Now make the PPA call */
367983e3700STom Rini do_omap3_emu_romcode_call(service_id, OMAP3_PUBLIC_SRAM_SCRATCH_AREA);
368983e3700STom Rini }
369983e3700STom Rini
omap3_set_aux_cr_secure(u32 acr)370983e3700STom Rini void __weak omap3_set_aux_cr_secure(u32 acr)
371983e3700STom Rini {
372983e3700STom Rini struct emu_hal_params emu_romcode_params;
373983e3700STom Rini
374983e3700STom Rini emu_romcode_params.num_params = 1;
375983e3700STom Rini emu_romcode_params.param1 = acr;
376983e3700STom Rini omap3_emu_romcode_call(OMAP3_EMU_HAL_API_WRITE_ACR,
377983e3700STom Rini (u32 *)&emu_romcode_params);
378983e3700STom Rini }
379983e3700STom Rini
v7_arch_cp15_set_l2aux_ctrl(u32 l2auxctrl,u32 cpu_midr,u32 cpu_rev_comb,u32 cpu_variant,u32 cpu_rev)38019a75b8cSSiarhei Siamashka void v7_arch_cp15_set_l2aux_ctrl(u32 l2auxctrl, u32 cpu_midr,
38119a75b8cSSiarhei Siamashka u32 cpu_rev_comb, u32 cpu_variant,
38219a75b8cSSiarhei Siamashka u32 cpu_rev)
38319a75b8cSSiarhei Siamashka {
38419a75b8cSSiarhei Siamashka if (get_device_type() == GP_DEVICE)
38519a75b8cSSiarhei Siamashka omap_smc1(OMAP3_GP_ROMCODE_API_WRITE_L2ACR, l2auxctrl);
38619a75b8cSSiarhei Siamashka
38719a75b8cSSiarhei Siamashka /* L2 Cache Auxiliary Control Register is not banked */
38819a75b8cSSiarhei Siamashka }
38919a75b8cSSiarhei Siamashka
v7_arch_cp15_set_acr(u32 acr,u32 cpu_midr,u32 cpu_rev_comb,u32 cpu_variant,u32 cpu_rev)390983e3700STom Rini void v7_arch_cp15_set_acr(u32 acr, u32 cpu_midr, u32 cpu_rev_comb,
391983e3700STom Rini u32 cpu_variant, u32 cpu_rev)
392983e3700STom Rini {
393983e3700STom Rini /* Write ACR - affects secure banked bits */
394983e3700STom Rini if (get_device_type() == GP_DEVICE)
395983e3700STom Rini omap_smc1(OMAP3_GP_ROMCODE_API_WRITE_ACR, acr);
396983e3700STom Rini else
397983e3700STom Rini omap3_set_aux_cr_secure(acr);
398983e3700STom Rini
399983e3700STom Rini /* Write ACR - affects non-secure banked bits - some erratas need it */
400983e3700STom Rini asm volatile ("mcr p15, 0, %0, c1, c0, 1" : : "r" (acr));
401983e3700STom Rini }
402983e3700STom Rini
403983e3700STom Rini
404983e3700STom Rini #ifndef CONFIG_SYS_L2CACHE_OFF
omap3_update_aux_cr(u32 set_bits,u32 clear_bits)405983e3700STom Rini static void omap3_update_aux_cr(u32 set_bits, u32 clear_bits)
406983e3700STom Rini {
407983e3700STom Rini u32 acr;
408983e3700STom Rini
409983e3700STom Rini /* Read ACR */
410983e3700STom Rini asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr));
411983e3700STom Rini acr &= ~clear_bits;
412983e3700STom Rini acr |= set_bits;
413983e3700STom Rini v7_arch_cp15_set_acr(acr, 0, 0, 0, 0);
414983e3700STom Rini
415983e3700STom Rini }
416983e3700STom Rini
417983e3700STom Rini /* Invalidate the entire L2 cache from secure mode */
omap3_invalidate_l2_cache_secure(void)418983e3700STom Rini static void omap3_invalidate_l2_cache_secure(void)
419983e3700STom Rini {
420983e3700STom Rini if (get_device_type() == GP_DEVICE) {
421983e3700STom Rini omap_smc1(OMAP3_GP_ROMCODE_API_L2_INVAL, 0);
422983e3700STom Rini } else {
423983e3700STom Rini struct emu_hal_params emu_romcode_params;
424983e3700STom Rini emu_romcode_params.num_params = 1;
425983e3700STom Rini emu_romcode_params.param1 = 0;
426983e3700STom Rini omap3_emu_romcode_call(OMAP3_EMU_HAL_API_L2_INVAL,
427983e3700STom Rini (u32 *)&emu_romcode_params);
428983e3700STom Rini }
429983e3700STom Rini }
430983e3700STom Rini
v7_outer_cache_enable(void)431983e3700STom Rini void v7_outer_cache_enable(void)
432983e3700STom Rini {
433983e3700STom Rini
434983e3700STom Rini /*
435983e3700STom Rini * Set L2EN
436983e3700STom Rini * On some revisions L2EN bit is banked on some revisions it's not
437983e3700STom Rini * No harm in setting both banked bits(in fact this is required
438983e3700STom Rini * by an erratum)
439983e3700STom Rini */
440983e3700STom Rini omap3_update_aux_cr(0x2, 0);
441983e3700STom Rini }
442983e3700STom Rini
omap3_outer_cache_disable(void)443983e3700STom Rini void omap3_outer_cache_disable(void)
444983e3700STom Rini {
445983e3700STom Rini /*
446983e3700STom Rini * Clear L2EN
447983e3700STom Rini * On some revisions L2EN bit is banked on some revisions it's not
448983e3700STom Rini * No harm in clearing both banked bits(in fact this is required
449983e3700STom Rini * by an erratum)
450983e3700STom Rini */
451983e3700STom Rini omap3_update_aux_cr(0, 0x2);
452983e3700STom Rini }
453983e3700STom Rini #endif /* !CONFIG_SYS_L2CACHE_OFF */
454