blob: 349e48042982285af8eefc2ab4791e57ea6ed76d [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Tony Lindgren1dbae812005-11-10 14:26:51 +00002/*
3 * linux/arch/arm/mach-omap2/io.c
4 *
5 * OMAP2 I/O mapping code
6 *
7 * Copyright (C) 2005 Nokia Corporation
Santosh Shilimkar44169072009-05-28 14:16:04 -07008 * Copyright (C) 2007-2009 Texas Instruments
Tony Lindgren646e3ed2008-10-06 15:49:36 +03009 *
10 * Author:
11 * Juha Yrjola <juha.yrjola@nokia.com>
12 * Syed Khasim <x0khasim@ti.com>
Tony Lindgren1dbae812005-11-10 14:26:51 +000013 *
Santosh Shilimkar44169072009-05-28 14:16:04 -070014 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
Tony Lindgren1dbae812005-11-10 14:26:51 +000015 */
Tony Lindgren1dbae812005-11-10 14:26:51 +000016#include <linux/module.h>
17#include <linux/kernel.h>
18#include <linux/init.h>
Russell Kingfced80c2008-09-06 12:10:45 +010019#include <linux/io.h>
Paul Walmsley2f135ea2009-06-19 19:08:25 -060020#include <linux/clk.h>
Tony Lindgren1dbae812005-11-10 14:26:51 +000021
Tony Lindgren120db2c2006-04-02 17:46:27 +010022#include <asm/tlb.h>
Tony Lindgren120db2c2006-04-02 17:46:27 +010023#include <asm/mach/map.h>
24
Tony Lindgren45c3eb72012-11-30 08:41:50 -080025#include <linux/omap-dma.h>
Tony Lindgren646e3ed2008-10-06 15:49:36 +030026
Tony Lindgrendc843282012-10-03 11:23:43 -070027#include "omap_hwmod.h"
Tony Lindgrendbc04162012-08-31 10:59:07 -070028#include "soc.h"
Tony Lindgrenee0839c2012-02-24 10:34:35 -080029#include "iomap.h"
30#include "voltage.h"
31#include "powerdomain.h"
32#include "clockdomain.h"
33#include "common.h"
Vaibhav Hiremathe30384a2012-05-29 15:26:41 +053034#include "clock.h"
Paul Walmsleye80a9722010-01-26 20:13:12 -070035#include "clock2xxx.h"
Paul Walmsley657ebfa2010-02-22 22:09:20 -070036#include "clock3xxx.h"
Paul Walmsley3e6ece12012-10-17 00:46:45 +000037#include "sdrc.h"
Paul Walmsleyb6a42262012-10-29 20:50:21 -060038#include "control.h"
Tony Lindgren3d82cbb2012-10-15 12:50:46 -070039#include "serial.h"
Tony Lindgrenbf027ca2012-10-29 13:54:06 -070040#include "sram.h"
Paul Walmsleyc4ceedc2012-10-29 20:56:29 -060041#include "cm2xxx.h"
42#include "cm3xxx.h"
Tero Kristo7632a022014-10-27 08:39:23 -070043#include "cm33xx.h"
Tero Kristoab6c9bb2014-10-27 08:39:25 -070044#include "cm44xx.h"
Paul Walmsleyd9a16f92012-10-29 20:57:39 -060045#include "prm.h"
46#include "cm.h"
47#include "prcm_mpu44xx.h"
48#include "prminst44xx.h"
Paul Walmsley63a293e2012-11-21 16:15:16 -070049#include "prm2xxx.h"
50#include "prm3xxx.h"
Tero Kristod9bbe842014-10-27 08:39:24 -070051#include "prm33xx.h"
Paul Walmsley63a293e2012-11-21 16:15:16 -070052#include "prm44xx.h"
Tero Kristo69a1e7a2014-02-24 18:51:05 +020053#include "opp2xxx.h"
Tony Lindgren1dbae812005-11-10 14:26:51 +000054
Tony Lindgren1dbae812005-11-10 14:26:51 +000055/*
Tero Kristocfa96672013-10-22 11:53:02 +030056 * omap_clk_soc_init: points to a function that does the SoC-specific
Rajendra Nayakff931c82013-03-21 16:34:52 +053057 * clock initializations
58 */
Tero Kristocfa96672013-10-22 11:53:02 +030059static int (*omap_clk_soc_init)(void);
Rajendra Nayakff931c82013-03-21 16:34:52 +053060
61/*
Tony Lindgren1dbae812005-11-10 14:26:51 +000062 * The machine specific code may provide the extra mapping besides the
63 * default mapping provided here.
64 */
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +030065
Tony Lindgrene48f8142012-03-06 11:49:22 -080066#if defined(CONFIG_SOC_OMAP2420) || defined(CONFIG_SOC_OMAP2430)
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +030067static struct map_desc omap24xx_io_desc[] __initdata = {
Tony Lindgren1dbae812005-11-10 14:26:51 +000068 {
69 .virtual = L3_24XX_VIRT,
70 .pfn = __phys_to_pfn(L3_24XX_PHYS),
71 .length = L3_24XX_SIZE,
72 .type = MT_DEVICE
73 },
Kyungmin Park09f21ed2008-02-20 15:30:06 -080074 {
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +030075 .virtual = L4_24XX_VIRT,
76 .pfn = __phys_to_pfn(L4_24XX_PHYS),
77 .length = L4_24XX_SIZE,
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -080078 .type = MT_DEVICE
79 },
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +030080};
81
Tony Lindgren59b479e2011-01-27 16:39:40 -080082#ifdef CONFIG_SOC_OMAP2420
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +030083static struct map_desc omap242x_io_desc[] __initdata = {
Tony Lindgren1dbae812005-11-10 14:26:51 +000084 {
Paul Walmsley7adb9982010-01-08 15:23:05 -070085 .virtual = DSP_MEM_2420_VIRT,
86 .pfn = __phys_to_pfn(DSP_MEM_2420_PHYS),
87 .length = DSP_MEM_2420_SIZE,
Tony Lindgrenc40fae952006-12-07 13:58:10 -080088 .type = MT_DEVICE
89 },
90 {
Paul Walmsley7adb9982010-01-08 15:23:05 -070091 .virtual = DSP_IPI_2420_VIRT,
92 .pfn = __phys_to_pfn(DSP_IPI_2420_PHYS),
93 .length = DSP_IPI_2420_SIZE,
Tony Lindgrenc40fae952006-12-07 13:58:10 -080094 .type = MT_DEVICE
95 },
96 {
Paul Walmsley7adb9982010-01-08 15:23:05 -070097 .virtual = DSP_MMU_2420_VIRT,
98 .pfn = __phys_to_pfn(DSP_MMU_2420_PHYS),
99 .length = DSP_MMU_2420_SIZE,
Tony Lindgren1dbae812005-11-10 14:26:51 +0000100 .type = MT_DEVICE
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +0300101 },
Tony Lindgren1dbae812005-11-10 14:26:51 +0000102};
103
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +0300104#endif
105
Tony Lindgren59b479e2011-01-27 16:39:40 -0800106#ifdef CONFIG_SOC_OMAP2430
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +0300107static struct map_desc omap243x_io_desc[] __initdata = {
108 {
109 .virtual = L4_WK_243X_VIRT,
110 .pfn = __phys_to_pfn(L4_WK_243X_PHYS),
111 .length = L4_WK_243X_SIZE,
112 .type = MT_DEVICE
113 },
114 {
115 .virtual = OMAP243X_GPMC_VIRT,
116 .pfn = __phys_to_pfn(OMAP243X_GPMC_PHYS),
117 .length = OMAP243X_GPMC_SIZE,
118 .type = MT_DEVICE
119 },
120 {
121 .virtual = OMAP243X_SDRC_VIRT,
122 .pfn = __phys_to_pfn(OMAP243X_SDRC_PHYS),
123 .length = OMAP243X_SDRC_SIZE,
124 .type = MT_DEVICE
125 },
126 {
127 .virtual = OMAP243X_SMS_VIRT,
128 .pfn = __phys_to_pfn(OMAP243X_SMS_PHYS),
129 .length = OMAP243X_SMS_SIZE,
130 .type = MT_DEVICE
131 },
132};
133#endif
134#endif
135
Tony Lindgrena8eb7ca2010-02-12 12:26:48 -0800136#ifdef CONFIG_ARCH_OMAP3
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +0300137static struct map_desc omap34xx_io_desc[] __initdata = {
138 {
139 .virtual = L3_34XX_VIRT,
140 .pfn = __phys_to_pfn(L3_34XX_PHYS),
141 .length = L3_34XX_SIZE,
142 .type = MT_DEVICE
143 },
144 {
145 .virtual = L4_34XX_VIRT,
146 .pfn = __phys_to_pfn(L4_34XX_PHYS),
147 .length = L4_34XX_SIZE,
148 .type = MT_DEVICE
149 },
150 {
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +0300151 .virtual = OMAP34XX_GPMC_VIRT,
152 .pfn = __phys_to_pfn(OMAP34XX_GPMC_PHYS),
153 .length = OMAP34XX_GPMC_SIZE,
154 .type = MT_DEVICE
155 },
156 {
157 .virtual = OMAP343X_SMS_VIRT,
158 .pfn = __phys_to_pfn(OMAP343X_SMS_PHYS),
159 .length = OMAP343X_SMS_SIZE,
160 .type = MT_DEVICE
161 },
162 {
163 .virtual = OMAP343X_SDRC_VIRT,
164 .pfn = __phys_to_pfn(OMAP343X_SDRC_PHYS),
165 .length = OMAP343X_SDRC_SIZE,
166 .type = MT_DEVICE
167 },
168 {
169 .virtual = L4_PER_34XX_VIRT,
170 .pfn = __phys_to_pfn(L4_PER_34XX_PHYS),
171 .length = L4_PER_34XX_SIZE,
172 .type = MT_DEVICE
173 },
174 {
175 .virtual = L4_EMU_34XX_VIRT,
176 .pfn = __phys_to_pfn(L4_EMU_34XX_PHYS),
177 .length = L4_EMU_34XX_SIZE,
178 .type = MT_DEVICE
179 },
180};
181#endif
Hemant Pedanekar01001712011-02-16 08:31:39 -0800182
Kevin Hilman33959552012-05-10 11:10:07 -0700183#ifdef CONFIG_SOC_TI81XX
Hemant Pedanekara9203602011-12-13 10:46:44 -0800184static struct map_desc omapti81xx_io_desc[] __initdata = {
Hemant Pedanekar01001712011-02-16 08:31:39 -0800185 {
186 .virtual = L4_34XX_VIRT,
187 .pfn = __phys_to_pfn(L4_34XX_PHYS),
188 .length = L4_34XX_SIZE,
189 .type = MT_DEVICE
Afzal Mohammed1e6cb142011-12-13 10:46:43 -0800190 }
191};
192#endif
193
Afzal Mohammedaddb1542013-05-27 20:06:13 +0530194#if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
Afzal Mohammed1e6cb142011-12-13 10:46:43 -0800195static struct map_desc omapam33xx_io_desc[] __initdata = {
Hemant Pedanekar01001712011-02-16 08:31:39 -0800196 {
197 .virtual = L4_34XX_VIRT,
198 .pfn = __phys_to_pfn(L4_34XX_PHYS),
199 .length = L4_34XX_SIZE,
200 .type = MT_DEVICE
201 },
Afzal Mohammed1e6cb142011-12-13 10:46:43 -0800202 {
203 .virtual = L4_WK_AM33XX_VIRT,
204 .pfn = __phys_to_pfn(L4_WK_AM33XX_PHYS),
205 .length = L4_WK_AM33XX_SIZE,
206 .type = MT_DEVICE
207 }
Hemant Pedanekar01001712011-02-16 08:31:39 -0800208};
209#endif
210
Santosh Shilimkar44169072009-05-28 14:16:04 -0700211#ifdef CONFIG_ARCH_OMAP4
212static struct map_desc omap44xx_io_desc[] __initdata = {
213 {
214 .virtual = L3_44XX_VIRT,
215 .pfn = __phys_to_pfn(L3_44XX_PHYS),
216 .length = L3_44XX_SIZE,
217 .type = MT_DEVICE,
218 },
219 {
220 .virtual = L4_44XX_VIRT,
221 .pfn = __phys_to_pfn(L4_44XX_PHYS),
222 .length = L4_44XX_SIZE,
223 .type = MT_DEVICE,
224 },
225 {
Santosh Shilimkar44169072009-05-28 14:16:04 -0700226 .virtual = L4_PER_44XX_VIRT,
227 .pfn = __phys_to_pfn(L4_PER_44XX_PHYS),
228 .length = L4_PER_44XX_SIZE,
229 .type = MT_DEVICE,
230 },
Santosh Shilimkar44169072009-05-28 14:16:04 -0700231};
232#endif
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +0300233
Nishanth Menonea827ad2015-06-22 10:12:14 -0500234#ifdef CONFIG_SOC_OMAP5
R Sricharan05e152c2012-06-05 16:21:32 +0530235static struct map_desc omap54xx_io_desc[] __initdata = {
236 {
237 .virtual = L3_54XX_VIRT,
238 .pfn = __phys_to_pfn(L3_54XX_PHYS),
239 .length = L3_54XX_SIZE,
240 .type = MT_DEVICE,
241 },
242 {
243 .virtual = L4_54XX_VIRT,
244 .pfn = __phys_to_pfn(L4_54XX_PHYS),
245 .length = L4_54XX_SIZE,
246 .type = MT_DEVICE,
247 },
248 {
249 .virtual = L4_WK_54XX_VIRT,
250 .pfn = __phys_to_pfn(L4_WK_54XX_PHYS),
251 .length = L4_WK_54XX_SIZE,
252 .type = MT_DEVICE,
253 },
254 {
255 .virtual = L4_PER_54XX_VIRT,
256 .pfn = __phys_to_pfn(L4_PER_54XX_PHYS),
257 .length = L4_PER_54XX_SIZE,
258 .type = MT_DEVICE,
259 },
260};
261#endif
262
Nishanth Menonea827ad2015-06-22 10:12:14 -0500263#ifdef CONFIG_SOC_DRA7XX
264static struct map_desc dra7xx_io_desc[] __initdata = {
265 {
266 .virtual = L4_CFG_MPU_DRA7XX_VIRT,
267 .pfn = __phys_to_pfn(L4_CFG_MPU_DRA7XX_PHYS),
268 .length = L4_CFG_MPU_DRA7XX_SIZE,
269 .type = MT_DEVICE,
270 },
271 {
272 .virtual = L3_MAIN_SN_DRA7XX_VIRT,
273 .pfn = __phys_to_pfn(L3_MAIN_SN_DRA7XX_PHYS),
274 .length = L3_MAIN_SN_DRA7XX_SIZE,
275 .type = MT_DEVICE,
276 },
277 {
278 .virtual = L4_PER1_DRA7XX_VIRT,
279 .pfn = __phys_to_pfn(L4_PER1_DRA7XX_PHYS),
280 .length = L4_PER1_DRA7XX_SIZE,
281 .type = MT_DEVICE,
282 },
283 {
284 .virtual = L4_PER2_DRA7XX_VIRT,
285 .pfn = __phys_to_pfn(L4_PER2_DRA7XX_PHYS),
286 .length = L4_PER2_DRA7XX_SIZE,
287 .type = MT_DEVICE,
288 },
289 {
290 .virtual = L4_PER3_DRA7XX_VIRT,
291 .pfn = __phys_to_pfn(L4_PER3_DRA7XX_PHYS),
292 .length = L4_PER3_DRA7XX_SIZE,
293 .type = MT_DEVICE,
294 },
295 {
296 .virtual = L4_CFG_DRA7XX_VIRT,
297 .pfn = __phys_to_pfn(L4_CFG_DRA7XX_PHYS),
298 .length = L4_CFG_DRA7XX_SIZE,
299 .type = MT_DEVICE,
300 },
301 {
302 .virtual = L4_WKUP_DRA7XX_VIRT,
303 .pfn = __phys_to_pfn(L4_WKUP_DRA7XX_PHYS),
304 .length = L4_WKUP_DRA7XX_SIZE,
305 .type = MT_DEVICE,
306 },
307};
308#endif
309
Tony Lindgren59b479e2011-01-27 16:39:40 -0800310#ifdef CONFIG_SOC_OMAP2420
Paul Walmsleyb6a42262012-10-29 20:50:21 -0600311void __init omap242x_map_io(void)
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800312{
313 iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
314 iotable_init(omap242x_io_desc, ARRAY_SIZE(omap242x_io_desc));
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800315}
316#endif
317
Tony Lindgren59b479e2011-01-27 16:39:40 -0800318#ifdef CONFIG_SOC_OMAP2430
Paul Walmsleyb6a42262012-10-29 20:50:21 -0600319void __init omap243x_map_io(void)
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800320{
321 iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
322 iotable_init(omap243x_io_desc, ARRAY_SIZE(omap243x_io_desc));
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800323}
324#endif
325
Tony Lindgrena8eb7ca2010-02-12 12:26:48 -0800326#ifdef CONFIG_ARCH_OMAP3
Paul Walmsleyb6a42262012-10-29 20:50:21 -0600327void __init omap3_map_io(void)
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800328{
329 iotable_init(omap34xx_io_desc, ARRAY_SIZE(omap34xx_io_desc));
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800330}
331#endif
332
Kevin Hilman33959552012-05-10 11:10:07 -0700333#ifdef CONFIG_SOC_TI81XX
Paul Walmsleyb6a42262012-10-29 20:50:21 -0600334void __init ti81xx_map_io(void)
Hemant Pedanekar01001712011-02-16 08:31:39 -0800335{
Hemant Pedanekara9203602011-12-13 10:46:44 -0800336 iotable_init(omapti81xx_io_desc, ARRAY_SIZE(omapti81xx_io_desc));
Hemant Pedanekar01001712011-02-16 08:31:39 -0800337}
338#endif
339
Afzal Mohammedaddb1542013-05-27 20:06:13 +0530340#if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
Paul Walmsleyb6a42262012-10-29 20:50:21 -0600341void __init am33xx_map_io(void)
Afzal Mohammed1e6cb142011-12-13 10:46:43 -0800342{
343 iotable_init(omapam33xx_io_desc, ARRAY_SIZE(omapam33xx_io_desc));
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800344}
345#endif
346
347#ifdef CONFIG_ARCH_OMAP4
Paul Walmsleyb6a42262012-10-29 20:50:21 -0600348void __init omap4_map_io(void)
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800349{
350 iotable_init(omap44xx_io_desc, ARRAY_SIZE(omap44xx_io_desc));
Russell Kingf7469292015-06-06 00:13:40 +0100351 omap_barriers_init();
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800352}
353#endif
354
Nishanth Menonea827ad2015-06-22 10:12:14 -0500355#ifdef CONFIG_SOC_OMAP5
Paul Walmsleyb6a42262012-10-29 20:50:21 -0600356void __init omap5_map_io(void)
R Sricharan05e152c2012-06-05 16:21:32 +0530357{
358 iotable_init(omap54xx_io_desc, ARRAY_SIZE(omap54xx_io_desc));
Russell Kingf7469292015-06-06 00:13:40 +0100359 omap_barriers_init();
R Sricharan05e152c2012-06-05 16:21:32 +0530360}
361#endif
Nishanth Menonea827ad2015-06-22 10:12:14 -0500362
363#ifdef CONFIG_SOC_DRA7XX
364void __init dra7xx_map_io(void)
365{
366 iotable_init(dra7xx_io_desc, ARRAY_SIZE(dra7xx_io_desc));
Nishanth Menon456e8d52016-03-11 10:12:28 -0600367 omap_barriers_init();
Nishanth Menonea827ad2015-06-22 10:12:14 -0500368}
369#endif
Paul Walmsley2f135ea2009-06-19 19:08:25 -0600370/*
371 * omap2_init_reprogram_sdrc - reprogram SDRC timing parameters
372 *
373 * Sets the CORE DPLL3 M2 divider to the same value that it's at
374 * currently. This has the effect of setting the SDRC SDRAM AC timing
375 * registers to the values currently defined by the kernel. Currently
376 * only defined for OMAP3; will return 0 if called on OMAP2. Returns
377 * -EINVAL if the dpll3_m2_ck cannot be found, 0 if called on OMAP2,
378 * or passes along the return value of clk_set_rate().
379 */
380static int __init _omap2_init_reprogram_sdrc(void)
381{
382 struct clk *dpll3_m2_ck;
383 int v = -EINVAL;
384 long rate;
385
386 if (!cpu_is_omap34xx())
387 return 0;
388
389 dpll3_m2_ck = clk_get(NULL, "dpll3_m2_ck");
Aaro Koskinene281f7e2010-11-30 14:17:58 +0000390 if (IS_ERR(dpll3_m2_ck))
Paul Walmsley2f135ea2009-06-19 19:08:25 -0600391 return -EINVAL;
392
393 rate = clk_get_rate(dpll3_m2_ck);
394 pr_info("Reprogramming SDRC clock to %ld Hz\n", rate);
395 v = clk_set_rate(dpll3_m2_ck, rate);
396 if (v)
397 pr_err("dpll3_m2_clk rate change failed: %d\n", v);
398
399 clk_put(dpll3_m2_ck);
400
401 return v;
402}
403
Paul Walmsley2092e5c2010-12-14 12:42:35 -0700404static int _set_hwmod_postsetup_state(struct omap_hwmod *oh, void *data)
405{
406 return omap_hwmod_set_postsetup_state(oh, *(u8 *)data);
407}
408
Arnd Bergmann293ea3d2016-01-14 16:57:33 +0100409static void __init __maybe_unused omap_hwmod_init_postsetup(void)
Tony Lindgren120db2c2006-04-02 17:46:27 +0100410{
Tony Lindgren6d63b122019-03-21 11:00:21 -0700411 u8 postsetup_state = _HWMOD_STATE_DEFAULT;
Paul Walmsley2092e5c2010-12-14 12:42:35 -0700412
Paul Walmsley2092e5c2010-12-14 12:42:35 -0700413 /* Set the default postsetup state for all hwmods */
Paul Walmsley2092e5c2010-12-14 12:42:35 -0700414 omap_hwmod_for_each(_set_hwmod_postsetup_state, &postsetup_state);
Paul Walmsley48057342010-12-21 15:25:10 -0700415}
416
Paul Walmsley16110792012-01-25 12:57:46 -0700417#ifdef CONFIG_SOC_OMAP2420
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700418void __init omap2420_init_early(void)
419{
Paul Walmsleyb6a42262012-10-29 20:50:21 -0600420 omap2_set_globals_tap(OMAP242X_CLASS, OMAP2_L4_IO_ADDRESS(0x48014000));
421 omap2_set_globals_sdrc(OMAP2_L3_IO_ADDRESS(OMAP2420_SDRC_BASE),
422 OMAP2_L3_IO_ADDRESS(OMAP2420_SMS_BASE));
Tero Kristo2208bf12014-11-13 19:17:34 +0200423 omap2_control_base_init();
Vaibhav Hiremath4de34f32011-12-19 15:50:15 +0530424 omap2xxx_check_revision();
Tero Kristoab7b2ff2014-11-20 15:02:59 +0200425 omap2_prcm_base_init();
Tony Lindgren7b250af2011-10-04 18:26:28 -0700426 omap2xxx_voltagedomains_init();
427 omap242x_powerdomains_init();
428 omap242x_clockdomains_init();
429 omap2420_hwmod_init();
430 omap_hwmod_init_postsetup();
Tero Kristo6a194a62014-03-04 10:53:54 +0200431 omap_clk_soc_init = omap2420_dt_clk_init;
432 rate_table = omap2420_rate_table;
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700433}
Shawn Guobbd707a2012-04-26 16:06:50 +0800434
435void __init omap2420_init_late(void)
436{
Tony Lindgren02b83dc2018-04-16 10:23:46 -0700437 omap_pm_soc_init = omap2_pm_init;
Shawn Guobbd707a2012-04-26 16:06:50 +0800438}
Paul Walmsley16110792012-01-25 12:57:46 -0700439#endif
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700440
Paul Walmsley16110792012-01-25 12:57:46 -0700441#ifdef CONFIG_SOC_OMAP2430
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700442void __init omap2430_init_early(void)
443{
Paul Walmsleyb6a42262012-10-29 20:50:21 -0600444 omap2_set_globals_tap(OMAP243X_CLASS, OMAP2_L4_IO_ADDRESS(0x4900a000));
445 omap2_set_globals_sdrc(OMAP2_L3_IO_ADDRESS(OMAP243X_SDRC_BASE),
446 OMAP2_L3_IO_ADDRESS(OMAP243X_SMS_BASE));
Tero Kristo2208bf12014-11-13 19:17:34 +0200447 omap2_control_base_init();
Vaibhav Hiremath4de34f32011-12-19 15:50:15 +0530448 omap2xxx_check_revision();
Tero Kristoab7b2ff2014-11-20 15:02:59 +0200449 omap2_prcm_base_init();
Tony Lindgren7b250af2011-10-04 18:26:28 -0700450 omap2xxx_voltagedomains_init();
451 omap243x_powerdomains_init();
452 omap243x_clockdomains_init();
453 omap2430_hwmod_init();
454 omap_hwmod_init_postsetup();
Tero Kristo6a194a62014-03-04 10:53:54 +0200455 omap_clk_soc_init = omap2430_dt_clk_init;
456 rate_table = omap2430_rate_table;
Tony Lindgren7b250af2011-10-04 18:26:28 -0700457}
Shawn Guobbd707a2012-04-26 16:06:50 +0800458
459void __init omap2430_init_late(void)
460{
Tony Lindgren02b83dc2018-04-16 10:23:46 -0700461 omap_pm_soc_init = omap2_pm_init;
Shawn Guobbd707a2012-04-26 16:06:50 +0800462}
Sanjeev Premic4e2d242011-10-13 21:44:10 +0530463#endif
Tony Lindgren7b250af2011-10-04 18:26:28 -0700464
465/*
466 * Currently only board-omap3beagle.c should call this because of the
467 * same machine_id for 34xx and 36xx beagle.. Will get fixed with DT.
468 */
Sanjeev Premic4e2d242011-10-13 21:44:10 +0530469#ifdef CONFIG_ARCH_OMAP3
Tony Lindgren7b250af2011-10-04 18:26:28 -0700470void __init omap3_init_early(void)
471{
Paul Walmsleyb6a42262012-10-29 20:50:21 -0600472 omap2_set_globals_tap(OMAP343X_CLASS, OMAP2_L4_IO_ADDRESS(0x4830A000));
473 omap2_set_globals_sdrc(OMAP2_L3_IO_ADDRESS(OMAP343X_SDRC_BASE),
474 OMAP2_L3_IO_ADDRESS(OMAP343X_SMS_BASE));
Tero Kristo2208bf12014-11-13 19:17:34 +0200475 omap2_control_base_init();
Vaibhav Hiremath4de34f32011-12-19 15:50:15 +0530476 omap3xxx_check_revision();
477 omap3xxx_check_features();
Tero Kristoab7b2ff2014-11-20 15:02:59 +0200478 omap2_prcm_base_init();
Tony Lindgren7b250af2011-10-04 18:26:28 -0700479 omap3xxx_voltagedomains_init();
480 omap3xxx_powerdomains_init();
481 omap3xxx_clockdomains_init();
482 omap3xxx_hwmod_init();
483 omap_hwmod_init_postsetup();
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700484}
485
486void __init omap3430_init_early(void)
487{
Tony Lindgren7b250af2011-10-04 18:26:28 -0700488 omap3_init_early();
Tony Lindgren58a641c2017-05-31 15:51:34 -0700489 omap_clk_soc_init = omap3430_dt_clk_init;
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700490}
491
492void __init omap35xx_init_early(void)
493{
Tony Lindgren7b250af2011-10-04 18:26:28 -0700494 omap3_init_early();
Tony Lindgren58a641c2017-05-31 15:51:34 -0700495 omap_clk_soc_init = omap3430_dt_clk_init;
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700496}
497
498void __init omap3630_init_early(void)
499{
Tony Lindgren7b250af2011-10-04 18:26:28 -0700500 omap3_init_early();
Tony Lindgren58a641c2017-05-31 15:51:34 -0700501 omap_clk_soc_init = omap3630_dt_clk_init;
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700502}
503
504void __init am35xx_init_early(void)
505{
Tony Lindgren7b250af2011-10-04 18:26:28 -0700506 omap3_init_early();
Tony Lindgren58a641c2017-05-31 15:51:34 -0700507 omap_clk_soc_init = am35xx_dt_clk_init;
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700508}
509
Shawn Guobbd707a2012-04-26 16:06:50 +0800510void __init omap3_init_late(void)
511{
Tony Lindgren02b83dc2018-04-16 10:23:46 -0700512 omap_pm_soc_init = omap3_pm_init;
Shawn Guobbd707a2012-04-26 16:06:50 +0800513}
514
515void __init ti81xx_init_late(void)
516{
Tony Lindgren02b83dc2018-04-16 10:23:46 -0700517 omap_pm_soc_init = omap_pm_nop_init;
Shawn Guobbd707a2012-04-26 16:06:50 +0800518}
Sanjeev Premic4e2d242011-10-13 21:44:10 +0530519#endif
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700520
Aida Mynzhasovaa64459c2015-01-26 09:26:32 -0800521#ifdef CONFIG_SOC_TI81XX
522void __init ti814x_init_early(void)
523{
524 omap2_set_globals_tap(TI814X_CLASS,
525 OMAP2_L4_IO_ADDRESS(TI81XX_TAP_BASE));
Tero Kristo2208bf12014-11-13 19:17:34 +0200526 omap2_control_base_init();
Aida Mynzhasovaa64459c2015-01-26 09:26:32 -0800527 omap3xxx_check_revision();
528 ti81xx_check_features();
Tero Kristoab7b2ff2014-11-20 15:02:59 +0200529 omap2_prcm_base_init();
Aida Mynzhasovaa64459c2015-01-26 09:26:32 -0800530 omap3xxx_voltagedomains_init();
531 omap3xxx_powerdomains_init();
Tony Lindgren185fde62015-07-16 01:55:57 -0700532 ti814x_clockdomains_init();
Tony Lindgren0f3ccb22015-07-16 01:55:58 -0700533 dm814x_hwmod_init();
Aida Mynzhasovaa64459c2015-01-26 09:26:32 -0800534 omap_hwmod_init_postsetup();
Tony Lindgrend8936562015-12-03 12:02:32 -0800535 omap_clk_soc_init = dm814x_dt_clk_init;
Aida Mynzhasovaa64459c2015-01-26 09:26:32 -0800536}
537
538void __init ti816x_init_early(void)
539{
540 omap2_set_globals_tap(TI816X_CLASS,
541 OMAP2_L4_IO_ADDRESS(TI81XX_TAP_BASE));
Tero Kristo2208bf12014-11-13 19:17:34 +0200542 omap2_control_base_init();
Aida Mynzhasovaa64459c2015-01-26 09:26:32 -0800543 omap3xxx_check_revision();
544 ti81xx_check_features();
Tero Kristoab7b2ff2014-11-20 15:02:59 +0200545 omap2_prcm_base_init();
Aida Mynzhasovaa64459c2015-01-26 09:26:32 -0800546 omap3xxx_voltagedomains_init();
547 omap3xxx_powerdomains_init();
Tony Lindgren185fde62015-07-16 01:55:57 -0700548 ti816x_clockdomains_init();
Tony Lindgren0f3ccb22015-07-16 01:55:58 -0700549 dm816x_hwmod_init();
Aida Mynzhasovaa64459c2015-01-26 09:26:32 -0800550 omap_hwmod_init_postsetup();
Tony Lindgren58a641c2017-05-31 15:51:34 -0700551 omap_clk_soc_init = dm816x_dt_clk_init;
Aida Mynzhasovaa64459c2015-01-26 09:26:32 -0800552}
553#endif
554
Afzal Mohammed08f30982012-05-11 00:38:49 +0530555#ifdef CONFIG_SOC_AM33XX
556void __init am33xx_init_early(void)
557{
Paul Walmsleyb6a42262012-10-29 20:50:21 -0600558 omap2_set_globals_tap(AM335X_CLASS,
559 AM33XX_L4_WK_IO_ADDRESS(AM33XX_TAP_BASE));
Tero Kristo2208bf12014-11-13 19:17:34 +0200560 omap2_control_base_init();
Afzal Mohammed08f30982012-05-11 00:38:49 +0530561 omap3xxx_check_revision();
Vaibhav Hiremath7bcad172013-05-17 15:43:41 +0530562 am33xx_check_features();
Tero Kristoab7b2ff2014-11-20 15:02:59 +0200563 omap2_prcm_base_init();
Vaibhav Hiremath3f0ea762012-06-18 00:47:27 -0600564 am33xx_powerdomains_init();
Vaibhav Hiremath9c80f3a2012-06-18 00:47:27 -0600565 am33xx_clockdomains_init();
Vaibhav Hirematha2cfc502012-07-25 13:51:13 -0600566 am33xx_hwmod_init();
567 omap_hwmod_init_postsetup();
Tero Kristo149c09d2013-07-19 11:37:17 +0300568 omap_clk_soc_init = am33xx_dt_clk_init;
Afzal Mohammed08f30982012-05-11 00:38:49 +0530569}
Nishanth Menon765e7a02013-10-16 10:39:02 -0500570
571void __init am33xx_init_late(void)
572{
Tony Lindgren02b83dc2018-04-16 10:23:46 -0700573 omap_pm_soc_init = amx3_common_pm_init;
Nishanth Menon765e7a02013-10-16 10:39:02 -0500574}
Afzal Mohammed08f30982012-05-11 00:38:49 +0530575#endif
576
Afzal Mohammedc5107022013-05-27 20:06:23 +0530577#ifdef CONFIG_SOC_AM43XX
578void __init am43xx_init_early(void)
579{
580 omap2_set_globals_tap(AM335X_CLASS,
581 AM33XX_L4_WK_IO_ADDRESS(AM33XX_TAP_BASE));
Tero Kristo2208bf12014-11-13 19:17:34 +0200582 omap2_control_base_init();
Afzal Mohammedc5107022013-05-27 20:06:23 +0530583 omap3xxx_check_revision();
Afzal Mohammed7a2e0512014-02-07 15:51:25 +0530584 am33xx_check_features();
Tero Kristoab7b2ff2014-11-20 15:02:59 +0200585 omap2_prcm_base_init();
Ambresh K8835cf62013-10-12 15:46:37 +0530586 am43xx_powerdomains_init();
587 am43xx_clockdomains_init();
588 am43xx_hwmod_init();
589 omap_hwmod_init_postsetup();
Sekhar Norid941f862014-04-22 13:58:03 +0530590 omap_l2_cache_init();
Tero Kristod22031e2013-11-21 16:49:59 +0200591 omap_clk_soc_init = am43xx_dt_clk_init;
Afzal Mohammedc5107022013-05-27 20:06:23 +0530592}
Nishanth Menon765e7a02013-10-16 10:39:02 -0500593
594void __init am43xx_init_late(void)
595{
Tony Lindgren02b83dc2018-04-16 10:23:46 -0700596 omap_pm_soc_init = amx3_common_pm_init;
Nishanth Menon765e7a02013-10-16 10:39:02 -0500597}
Afzal Mohammedc5107022013-05-27 20:06:23 +0530598#endif
599
Sanjeev Premic4e2d242011-10-13 21:44:10 +0530600#ifdef CONFIG_ARCH_OMAP4
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700601void __init omap4430_init_early(void)
602{
Paul Walmsleyb6a42262012-10-29 20:50:21 -0600603 omap2_set_globals_tap(OMAP443X_CLASS,
604 OMAP2_L4_IO_ADDRESS(OMAP443X_SCM_BASE));
Paul Walmsleyd9a16f92012-10-29 20:57:39 -0600605 omap2_set_globals_prcm_mpu(OMAP2_L4_IO_ADDRESS(OMAP4430_PRCM_MPU_BASE));
Tero Kristoca125b52015-02-12 11:47:04 +0200606 omap2_control_base_init();
Vaibhav Hiremath4de34f32011-12-19 15:50:15 +0530607 omap4xxx_check_revision();
608 omap4xxx_check_features();
Tero Kristoab7b2ff2014-11-20 15:02:59 +0200609 omap2_prcm_base_init();
Tony Lindgrenf4b9f402016-06-22 01:59:39 -0700610 omap4_sar_ram_init();
Tony Lindgren0573b952016-06-22 01:59:39 -0700611 omap4_mpuss_early_init();
Nishanth Menonde70af42014-01-20 14:06:37 -0600612 omap4_pm_init_early();
Tony Lindgren7b250af2011-10-04 18:26:28 -0700613 omap44xx_voltagedomains_init();
614 omap44xx_powerdomains_init();
615 omap44xx_clockdomains_init();
616 omap44xx_hwmod_init();
617 omap_hwmod_init_postsetup();
Sekhar Norib39b14e2014-04-22 13:58:01 +0530618 omap_l2_cache_init();
Tero Kristoc8c88d82013-07-18 16:04:00 +0300619 omap_clk_soc_init = omap4xxx_dt_clk_init;
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700620}
Shawn Guobbd707a2012-04-26 16:06:50 +0800621
622void __init omap4430_init_late(void)
623{
Tony Lindgren02b83dc2018-04-16 10:23:46 -0700624 omap_pm_soc_init = omap4_pm_init;
Shawn Guobbd707a2012-04-26 16:06:50 +0800625}
Sanjeev Premic4e2d242011-10-13 21:44:10 +0530626#endif
Tony Lindgren8f5b5a42011-08-22 23:57:24 -0700627
R Sricharan05e152c2012-06-05 16:21:32 +0530628#ifdef CONFIG_SOC_OMAP5
629void __init omap5_init_early(void)
630{
Paul Walmsleyb6a42262012-10-29 20:50:21 -0600631 omap2_set_globals_tap(OMAP54XX_CLASS,
632 OMAP2_L4_IO_ADDRESS(OMAP54XX_SCM_BASE));
Paul Walmsleyd9a16f92012-10-29 20:57:39 -0600633 omap2_set_globals_prcm_mpu(OMAP2_L4_IO_ADDRESS(OMAP54XX_PRCM_MPU_BASE));
Tero Kristoca125b52015-02-12 11:47:04 +0200634 omap2_control_base_init();
Tero Kristoab7b2ff2014-11-20 15:02:59 +0200635 omap2_prcm_base_init();
R Sricharan05e152c2012-06-05 16:21:32 +0530636 omap5xxx_check_revision();
Tony Lindgrenf4b9f402016-06-22 01:59:39 -0700637 omap4_sar_ram_init();
Tony Lindgren8a8be462016-11-07 16:50:11 -0700638 omap4_mpuss_early_init();
639 omap4_pm_init_early();
Santosh Shilimkare4020aa2013-05-29 12:38:12 -0400640 omap54xx_voltagedomains_init();
641 omap54xx_powerdomains_init();
642 omap54xx_clockdomains_init();
643 omap54xx_hwmod_init();
644 omap_hwmod_init_postsetup();
Tero Kristocfa96672013-10-22 11:53:02 +0300645 omap_clk_soc_init = omap5xxx_dt_clk_init;
R Sricharan05e152c2012-06-05 16:21:32 +0530646}
Nishanth Menon765e7a02013-10-16 10:39:02 -0500647
648void __init omap5_init_late(void)
649{
Tony Lindgren02b83dc2018-04-16 10:23:46 -0700650 omap_pm_soc_init = omap4_pm_init;
Nishanth Menon765e7a02013-10-16 10:39:02 -0500651}
R Sricharan05e152c2012-06-05 16:21:32 +0530652#endif
653
R Sricharana3a93842013-07-03 11:52:04 +0530654#ifdef CONFIG_SOC_DRA7XX
655void __init dra7xx_init_early(void)
656{
Nishanth Menonec490f62016-04-01 17:53:06 -0500657 omap2_set_globals_tap(DRA7XX_CLASS,
658 OMAP2_L4_IO_ADDRESS(DRA7XX_TAP_BASE));
R Sricharana3a93842013-07-03 11:52:04 +0530659 omap2_set_globals_prcm_mpu(OMAP2_L4_IO_ADDRESS(OMAP54XX_PRCM_MPU_BASE));
Tero Kristoca125b52015-02-12 11:47:04 +0200660 omap2_control_base_init();
Rajendra Nayak6af16a12014-08-22 09:02:34 -0500661 omap4_pm_init_early();
Tero Kristoab7b2ff2014-11-20 15:02:59 +0200662 omap2_prcm_base_init();
Nishanth Menon733d20e2014-05-19 10:27:11 -0500663 dra7xxx_check_revision();
Ambresh K7de516a2013-08-23 04:05:08 -0600664 dra7xx_powerdomains_init();
665 dra7xx_clockdomains_init();
666 dra7xx_hwmod_init();
667 omap_hwmod_init_postsetup();
Tero Kristof1cf4982013-08-29 11:35:43 +0300668 omap_clk_soc_init = dra7xx_dt_clk_init;
R Sricharana3a93842013-07-03 11:52:04 +0530669}
Nishanth Menon765e7a02013-10-16 10:39:02 -0500670
671void __init dra7xx_init_late(void)
672{
Tony Lindgren02b83dc2018-04-16 10:23:46 -0700673 omap_pm_soc_init = omap4_pm_init;
Nishanth Menon765e7a02013-10-16 10:39:02 -0500674}
R Sricharana3a93842013-07-03 11:52:04 +0530675#endif
676
677
Tony Lindgrena4ca9db2011-08-22 23:57:23 -0700678void __init omap_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
Paul Walmsley48057342010-12-21 15:25:10 -0700679 struct omap_sdrc_params *sdrc_cs1)
680{
Tony Lindgrena66cb342011-10-04 13:52:57 -0700681 omap_sram_init();
682
Hemant Pedanekar01001712011-02-16 08:31:39 -0800683 if (cpu_is_omap24xx() || omap3_has_sdrc()) {
Kevin Hilmanaa4b1f62010-03-10 17:16:31 +0000684 omap2_sdrc_init(sdrc_cs0, sdrc_cs1);
685 _omap2_init_reprogram_sdrc();
686 }
Tony Lindgren1dbae812005-11-10 14:26:51 +0000687}
Tero Kristocfa96672013-10-22 11:53:02 +0300688
689int __init omap_clk_init(void)
690{
691 int ret = 0;
692
693 if (!omap_clk_soc_init)
694 return 0;
695
Tero Kristo8111e012014-07-02 11:47:39 +0300696 ti_clk_init_features();
697
Tero Kristoe9e63082015-04-27 21:55:42 +0300698 omap2_clk_setup_ll_ops();
699
Tony Lindgren58a641c2017-05-31 15:51:34 -0700700 ret = omap_control_init();
701 if (ret)
702 return ret;
Tero Kristofe874142014-03-12 18:33:45 +0200703
Tony Lindgren58a641c2017-05-31 15:51:34 -0700704 ret = omap_prcm_init();
705 if (ret)
706 return ret;
Tero Kristoc08ee142014-09-12 15:01:57 +0300707
Tony Lindgren58a641c2017-05-31 15:51:34 -0700708 of_clk_init(NULL);
Tero Kristoc08ee142014-09-12 15:01:57 +0300709
Tony Lindgren58a641c2017-05-31 15:51:34 -0700710 ti_dt_clk_init_retry_clks();
Tero Kristoc08ee142014-09-12 15:01:57 +0300711
Tony Lindgren58a641c2017-05-31 15:51:34 -0700712 ti_dt_clockdomains_setup();
Tero Kristoc08ee142014-09-12 15:01:57 +0300713
714 ret = omap_clk_soc_init();
Tero Kristocfa96672013-10-22 11:53:02 +0300715
716 return ret;
717}