2 * linux/arch/arm/plat-omap/common.c
4 * Code common to all OMAP machines.
5 * The file is created by Tony Lindgren <tony@atomide.com>
7 * Copyright (C) 2009 Texas Instruments
8 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/delay.h>
18 #include <linux/console.h>
19 #include <linux/serial.h>
20 #include <linux/tty.h>
21 #include <linux/serial_8250.h>
22 #include <linux/serial_reg.h>
23 #include <linux/clk.h>
26 #include <mach/hardware.h>
27 #include <asm/system.h>
28 #include <asm/pgtable.h>
29 #include <asm/mach/map.h>
30 #include <asm/setup.h>
32 #include <plat/common.h>
33 #include <plat/board.h>
34 #include <plat/control.h>
36 #include <plat/fpga.h>
38 #include <plat/clock.h>
40 #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
41 # include "../mach-omap2/sdrc.h"
44 #define NO_LENGTH_CHECK 0xffffffff
46 unsigned char omap_bootloader_tag
[512];
47 int omap_bootloader_tag_len
;
49 struct omap_board_config_kernel
*omap_board_config
;
50 int omap_board_config_size
;
52 /* used by omap-smp.c and board-4430sdp.c */
53 void __iomem
*gic_cpu_base_addr
;
55 #ifdef CONFIG_OMAP_PM_NONE
56 struct omap_opp
*mpu_opps
;
57 struct omap_opp
*dsp_opps
;
58 struct omap_opp
*l3_opps
;
61 static const void *get_config(u16 tag
, size_t len
, int skip
, size_t *len_out
)
63 struct omap_board_config_kernel
*kinfo
= NULL
;
66 /* Try to find the config from the board-specific structures
68 for (i
= 0; i
< omap_board_config_size
; i
++) {
69 if (omap_board_config
[i
].tag
== tag
) {
71 kinfo
= &omap_board_config
[i
];
83 const void *__omap_get_config(u16 tag
, size_t len
, int nr
)
85 return get_config(tag
, len
, nr
, NULL
);
87 EXPORT_SYMBOL(__omap_get_config
);
89 const void *omap_get_var_config(u16 tag
, size_t *len
)
91 return get_config(tag
, NO_LENGTH_CHECK
, 0, len
);
93 EXPORT_SYMBOL(omap_get_var_config
);
96 * 32KHz clocksource ... always available, on pretty most chips except
97 * OMAP 730 and 1510. Other timers could be used as clocksources, with
98 * higher resolution in free-running counter modes (e.g. 12 MHz xtal),
99 * but systems won't necessarily want to spend resources that way.
102 #define OMAP16XX_TIMER_32K_SYNCHRONIZED 0xfffbc410
104 #if !(defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP15XX))
106 #include <linux/clocksource.h>
108 #ifdef CONFIG_ARCH_OMAP16XX
109 static cycle_t
omap16xx_32k_read(struct clocksource
*cs
)
111 return omap_readl(OMAP16XX_TIMER_32K_SYNCHRONIZED
);
114 #define omap16xx_32k_read NULL
117 #ifdef CONFIG_ARCH_OMAP2420
118 static cycle_t
omap2420_32k_read(struct clocksource
*cs
)
120 return omap_readl(OMAP2420_32KSYNCT_BASE
+ 0x10);
123 #define omap2420_32k_read NULL
126 #ifdef CONFIG_ARCH_OMAP2430
127 static cycle_t
omap2430_32k_read(struct clocksource
*cs
)
129 return omap_readl(OMAP2430_32KSYNCT_BASE
+ 0x10);
132 #define omap2430_32k_read NULL
135 #ifdef CONFIG_ARCH_OMAP34XX
136 static cycle_t
omap34xx_32k_read(struct clocksource
*cs
)
138 return omap_readl(OMAP3430_32KSYNCT_BASE
+ 0x10);
141 #define omap34xx_32k_read NULL
144 #ifdef CONFIG_ARCH_OMAP4
145 static cycle_t
omap44xx_32k_read(struct clocksource
*cs
)
147 return omap_readl(OMAP4430_32KSYNCT_BASE
+ 0x10);
150 #define omap44xx_32k_read NULL
154 * Kernel assumes that sched_clock can be called early but may not have
157 static cycle_t
omap_32k_read_dummy(struct clocksource
*cs
)
162 static struct clocksource clocksource_32k
= {
163 .name
= "32k_counter",
165 .read
= omap_32k_read_dummy
,
166 .mask
= CLOCKSOURCE_MASK(32),
168 .flags
= CLOCK_SOURCE_IS_CONTINUOUS
,
172 * Returns current time from boot in nsecs. It's OK for this to wrap
173 * around for now, as it's just a relative time stamp.
175 unsigned long long sched_clock(void)
177 return clocksource_cyc2ns(clocksource_32k
.read(&clocksource_32k
),
178 clocksource_32k
.mult
, clocksource_32k
.shift
);
181 static int __init
omap_init_clocksource_32k(void)
183 static char err
[] __initdata
= KERN_ERR
184 "%s: can't register clocksource!\n";
186 if (cpu_is_omap16xx() || cpu_class_is_omap2()) {
187 struct clk
*sync_32k_ick
;
189 if (cpu_is_omap16xx())
190 clocksource_32k
.read
= omap16xx_32k_read
;
191 else if (cpu_is_omap2420())
192 clocksource_32k
.read
= omap2420_32k_read
;
193 else if (cpu_is_omap2430())
194 clocksource_32k
.read
= omap2430_32k_read
;
195 else if (cpu_is_omap34xx())
196 clocksource_32k
.read
= omap34xx_32k_read
;
197 else if (cpu_is_omap44xx())
198 clocksource_32k
.read
= omap44xx_32k_read
;
202 sync_32k_ick
= clk_get(NULL
, "omap_32ksync_ick");
204 clk_enable(sync_32k_ick
);
206 clocksource_32k
.mult
= clocksource_hz2mult(32768,
207 clocksource_32k
.shift
);
209 if (clocksource_register(&clocksource_32k
))
210 printk(err
, clocksource_32k
.name
);
214 arch_initcall(omap_init_clocksource_32k
);
216 #endif /* !(defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP15XX)) */
218 /* Global address base setup code */
220 #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
222 static void __init
__omap2_set_globals(struct omap_globals
*omap2_globals
)
224 omap2_set_globals_tap(omap2_globals
);
225 omap2_set_globals_sdrc(omap2_globals
);
226 omap2_set_globals_control(omap2_globals
);
227 omap2_set_globals_prcm(omap2_globals
);
232 #if defined(CONFIG_ARCH_OMAP2420)
234 static struct omap_globals omap242x_globals
= {
235 .class = OMAP242X_CLASS
,
236 .tap
= OMAP2_L4_IO_ADDRESS(0x48014000),
237 .sdrc
= OMAP2_L3_IO_ADDRESS(OMAP2420_SDRC_BASE
),
238 .sms
= OMAP2_L3_IO_ADDRESS(OMAP2420_SMS_BASE
),
239 .ctrl
= OMAP2_L4_IO_ADDRESS(OMAP2420_CTRL_BASE
),
240 .prm
= OMAP2_L4_IO_ADDRESS(OMAP2420_PRM_BASE
),
241 .cm
= OMAP2_L4_IO_ADDRESS(OMAP2420_CM_BASE
),
244 void __init
omap2_set_globals_242x(void)
246 __omap2_set_globals(&omap242x_globals
);
250 #if defined(CONFIG_ARCH_OMAP2430)
252 static struct omap_globals omap243x_globals
= {
253 .class = OMAP243X_CLASS
,
254 .tap
= OMAP2_L4_IO_ADDRESS(0x4900a000),
255 .sdrc
= OMAP2_L3_IO_ADDRESS(OMAP243X_SDRC_BASE
),
256 .sms
= OMAP2_L3_IO_ADDRESS(OMAP243X_SMS_BASE
),
257 .ctrl
= OMAP2_L4_IO_ADDRESS(OMAP243X_CTRL_BASE
),
258 .prm
= OMAP2_L4_IO_ADDRESS(OMAP2430_PRM_BASE
),
259 .cm
= OMAP2_L4_IO_ADDRESS(OMAP2430_CM_BASE
),
262 void __init
omap2_set_globals_243x(void)
264 __omap2_set_globals(&omap243x_globals
);
268 #if defined(CONFIG_ARCH_OMAP3430)
270 static struct omap_globals omap343x_globals
= {
271 .class = OMAP343X_CLASS
,
272 .tap
= OMAP2_L4_IO_ADDRESS(0x4830A000),
273 .sdrc
= OMAP2_L3_IO_ADDRESS(OMAP343X_SDRC_BASE
),
274 .sms
= OMAP2_L3_IO_ADDRESS(OMAP343X_SMS_BASE
),
275 .ctrl
= OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE
),
276 .prm
= OMAP2_L4_IO_ADDRESS(OMAP3430_PRM_BASE
),
277 .cm
= OMAP2_L4_IO_ADDRESS(OMAP3430_CM_BASE
),
280 void __init
omap2_set_globals_343x(void)
282 __omap2_set_globals(&omap343x_globals
);
286 #if defined(CONFIG_ARCH_OMAP4)
287 static struct omap_globals omap4_globals
= {
288 .class = OMAP443X_CLASS
,
289 .tap
= OMAP2_L4_IO_ADDRESS(0x4830a000),
290 .ctrl
= OMAP2_L4_IO_ADDRESS(OMAP443X_CTRL_BASE
),
291 .prm
= OMAP2_L4_IO_ADDRESS(OMAP4430_PRM_BASE
),
292 .cm
= OMAP2_L4_IO_ADDRESS(OMAP4430_CM_BASE
),
295 void __init
omap2_set_globals_443x(void)
297 omap2_set_globals_tap(&omap4_globals
);
298 omap2_set_globals_control(&omap4_globals
);