aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-01-06 22:13:58 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-06 22:13:58 -0500
commit01539ba2a706ab7d35fc0667dff919ade7f87d63 (patch)
tree5a4bd0cf78007d06690fe4ac06bbd49a5a70bc47 /arch/arm/plat-omap
parent9e9bc9736756f25d6c47b4eba0ebf25b20a6f153 (diff)
parentdc69d1af9e8d9cbbabff88bb35a6782187a22229 (diff)
Merge branch 'omap-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6
* 'omap-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6: (243 commits) omap2: Make OMAP2PLUS select OMAP_DM_TIMER OMAP4: hwmod data: Fix alignment and end of line in structurefields OMAP4: hwmod data: Move the DMA structures OMAP4: hwmod data: Move the smartreflex structures OMAP4: hwmod data: Fix missing SIDLE_SMART_WKUP in smartreflexsysc arm: omap: tusb6010: add name for MUSB IRQ arm: omap: craneboard: Add USB EHCI support omap2+: Initialize serial port for dynamic remuxing for n8x0 omap2+: Add struct omap_board_data and use it for platform level serial init omap2+: Allow hwmod state changes to mux pads based on the state changes omap2+: Add support for hwmod specific muxing of devices omap2+: Add omap_mux_get_by_name OMAP2: PM: fix compile error when !CONFIG_SUSPEND MAINTAINERS: OMAP: hwmod: update hwmod code, data maintainership OMAP4: Smartreflex framework extensions OMAP4: hwmod: Add inital data for smartreflex modules. OMAP4: PM: Program correct init voltages for scalable VDDs OMAP4: Adding voltage driver support OMAP4: Register voltage PMIC parameters with the voltage layer OMAP3: PM: Program correct init voltages for VDD1 and VDD2 ... Fix up trivial conflict in arch/arm/plat-omap/Kconfig
Diffstat (limited to 'arch/arm/plat-omap')
-rw-r--r--arch/arm/plat-omap/Kconfig35
-rw-r--r--arch/arm/plat-omap/devices.c40
-rw-r--r--arch/arm/plat-omap/dma.c695
-rw-r--r--arch/arm/plat-omap/gpio.c670
-rw-r--r--arch/arm/plat-omap/i2c.c128
-rw-r--r--arch/arm/plat-omap/include/plat/clkdev_omap.h20
-rw-r--r--arch/arm/plat-omap/include/plat/clock.h16
-rw-r--r--arch/arm/plat-omap/include/plat/clockdomain.h141
-rw-r--r--arch/arm/plat-omap/include/plat/common.h2
-rw-r--r--arch/arm/plat-omap/include/plat/dma.h232
-rw-r--r--arch/arm/plat-omap/include/plat/fpga.h4
-rw-r--r--arch/arm/plat-omap/include/plat/gpio.h48
-rw-r--r--arch/arm/plat-omap/include/plat/gpmc.h9
-rw-r--r--arch/arm/plat-omap/include/plat/i2c.h13
-rw-r--r--arch/arm/plat-omap/include/plat/io.h5
-rw-r--r--arch/arm/plat-omap/include/plat/iommu.h5
-rw-r--r--arch/arm/plat-omap/include/plat/irqs.h2
-rw-r--r--arch/arm/plat-omap/include/plat/keypad.h35
-rw-r--r--arch/arm/plat-omap/include/plat/l4_3xxx.h24
-rw-r--r--arch/arm/plat-omap/include/plat/mailbox.h8
-rw-r--r--arch/arm/plat-omap/include/plat/omap-pm.h39
-rw-r--r--arch/arm/plat-omap/include/plat/omap-serial.h14
-rw-r--r--arch/arm/plat-omap/include/plat/omap_device.h1
-rw-r--r--arch/arm/plat-omap/include/plat/omap_hwmod.h73
-rw-r--r--arch/arm/plat-omap/include/plat/powerdomain.h167
-rw-r--r--arch/arm/plat-omap/include/plat/prcm.h20
-rw-r--r--arch/arm/plat-omap/include/plat/serial.h5
-rw-r--r--arch/arm/plat-omap/include/plat/smartreflex.h245
-rw-r--r--arch/arm/plat-omap/include/plat/sram.h11
-rw-r--r--arch/arm/plat-omap/include/plat/uncompress.h3
-rw-r--r--arch/arm/plat-omap/include/plat/voltage.h146
-rw-r--r--arch/arm/plat-omap/io.c58
-rw-r--r--arch/arm/plat-omap/iommu.c24
-rw-r--r--arch/arm/plat-omap/iovmm.c81
-rw-r--r--arch/arm/plat-omap/mailbox.c130
-rw-r--r--arch/arm/plat-omap/mcbsp.c26
-rw-r--r--arch/arm/plat-omap/omap-pm-noop.c78
-rw-r--r--arch/arm/plat-omap/omap_device.c28
-rw-r--r--arch/arm/plat-omap/sram.c14
39 files changed, 1567 insertions, 1728 deletions
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index c9408434a855..18fe3cb195dc 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -18,6 +18,7 @@ config ARCH_OMAP1
18config ARCH_OMAP2PLUS 18config ARCH_OMAP2PLUS
19 bool "TI OMAP2/3/4" 19 bool "TI OMAP2/3/4"
20 select CLKDEV_LOOKUP 20 select CLKDEV_LOOKUP
21 select OMAP_DM_TIMER
21 help 22 help
22 "Systems based on OMAP2, OMAP3 or OMAP4" 23 "Systems based on OMAP2, OMAP3 or OMAP4"
23 24
@@ -35,6 +36,37 @@ config OMAP_DEBUG_LEDS
35 depends on OMAP_DEBUG_DEVICES 36 depends on OMAP_DEBUG_DEVICES
36 default y if LEDS_CLASS 37 default y if LEDS_CLASS
37 38
39config OMAP_SMARTREFLEX
40 bool "SmartReflex support"
41 depends on (ARCH_OMAP3 || ARCH_OMAP4) && PM
42 help
43 Say Y if you want to enable SmartReflex.
44
45 SmartReflex can perform continuous dynamic voltage
46 scaling around the nominal operating point voltage
47 according to silicon characteristics and operating
48 conditions. Enabling SmartReflex reduces power
49 consumption.
50
51 Please note, that by default SmartReflex is only
52 initialized. To enable the automatic voltage
53 compensation for vdd mpu and vdd core from user space,
54 user must write 1 to
55 /debug/voltage/vdd_<X>/smartreflex/autocomp,
56 where X is mpu or core for OMAP3.
57 Optionallly autocompensation can be enabled in the kernel
58 by default during system init via the enable_on_init flag
59 which an be passed as platform data to the smartreflex driver.
60
61config OMAP_SMARTREFLEX_CLASS3
62 bool "Class 3 mode of Smartreflex Implementation"
63 depends on OMAP_SMARTREFLEX && TWL4030_CORE
64 help
65 Say Y to enable Class 3 implementation of Smartreflex
66
67 Class 3 implementation of Smartreflex employs continuous hardware
68 voltage calibration.
69
38config OMAP_RESET_CLOCKS 70config OMAP_RESET_CLOCKS
39 bool "Reset unused clocks during boot" 71 bool "Reset unused clocks during boot"
40 depends on ARCH_OMAP 72 depends on ARCH_OMAP
@@ -109,6 +141,9 @@ config OMAP_IOMMU_DEBUG
109 141
110 Say N unless you know you need this. 142 Say N unless you know you need this.
111 143
144config OMAP_IOMMU_IVA2
145 bool
146
112choice 147choice
113 prompt "System timer" 148 prompt "System timer"
114 default OMAP_32K_TIMER if !ARCH_OMAP15XX 149 default OMAP_32K_TIMER if !ARCH_OMAP15XX
diff --git a/arch/arm/plat-omap/devices.c b/arch/arm/plat-omap/devices.c
index fc819120978d..10245b837c10 100644
--- a/arch/arm/plat-omap/devices.c
+++ b/arch/arm/plat-omap/devices.c
@@ -232,46 +232,6 @@ static void omap_init_uwire(void)
232static inline void omap_init_uwire(void) {} 232static inline void omap_init_uwire(void) {}
233#endif 233#endif
234 234
235/*-------------------------------------------------------------------------*/
236
237#if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE)
238
239static struct resource wdt_resources[] = {
240 {
241 .flags = IORESOURCE_MEM,
242 },
243};
244
245static struct platform_device omap_wdt_device = {
246 .name = "omap_wdt",
247 .id = -1,
248 .num_resources = ARRAY_SIZE(wdt_resources),
249 .resource = wdt_resources,
250};
251
252static void omap_init_wdt(void)
253{
254 if (cpu_is_omap16xx())
255 wdt_resources[0].start = 0xfffeb000;
256 else if (cpu_is_omap2420())
257 wdt_resources[0].start = 0x48022000; /* WDT2 */
258 else if (cpu_is_omap2430())
259 wdt_resources[0].start = 0x49016000; /* WDT2 */
260 else if (cpu_is_omap343x())
261 wdt_resources[0].start = 0x48314000; /* WDT2 */
262 else if (cpu_is_omap44xx())
263 wdt_resources[0].start = 0x4a314000;
264 else
265 return;
266
267 wdt_resources[0].end = wdt_resources[0].start + 0x4f;
268
269 (void) platform_device_register(&omap_wdt_device);
270}
271#else
272static inline void omap_init_wdt(void) {}
273#endif
274
275#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE) 235#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
276 236
277static phys_addr_t omap_dsp_phys_mempool_base; 237static phys_addr_t omap_dsp_phys_mempool_base;
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index 2c2826571d45..c4b2b478b1a5 100644
--- a/arch/arm/plat-omap/dma.c
+++ b/arch/arm/plat-omap/dma.c
@@ -15,6 +15,10 @@
15 * 15 *
16 * Support functions for the OMAP internal DMA channels. 16 * Support functions for the OMAP internal DMA channels.
17 * 17 *
18 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
19 * Converted DMA library into DMA platform driver.
20 * - G, Manjunath Kondaiah <manjugk@ti.com>
21 *
18 * This program is free software; you can redistribute it and/or modify 22 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License version 2 as 23 * it under the terms of the GNU General Public License version 2 as
20 * published by the Free Software Foundation. 24 * published by the Free Software Foundation.
@@ -53,7 +57,11 @@ enum { DMA_CHAIN_STARTED, DMA_CHAIN_NOTSTARTED };
53 57
54#define OMAP_FUNC_MUX_ARM_BASE (0xfffe1000 + 0xec) 58#define OMAP_FUNC_MUX_ARM_BASE (0xfffe1000 + 0xec)
55 59
60static struct omap_system_dma_plat_info *p;
61static struct omap_dma_dev_attr *d;
62
56static int enable_1510_mode; 63static int enable_1510_mode;
64static u32 errata;
57 65
58static struct omap_dma_global_context_registers { 66static struct omap_dma_global_context_registers {
59 u32 dma_irqenable_l0; 67 u32 dma_irqenable_l0;
@@ -61,27 +69,6 @@ static struct omap_dma_global_context_registers {
61 u32 dma_gcr; 69 u32 dma_gcr;
62} omap_dma_global_context; 70} omap_dma_global_context;
63 71
64struct omap_dma_lch {
65 int next_lch;
66 int dev_id;
67 u16 saved_csr;
68 u16 enabled_irqs;
69 const char *dev_name;
70 void (*callback)(int lch, u16 ch_status, void *data);
71 void *data;
72
73#ifndef CONFIG_ARCH_OMAP1
74 /* required for Dynamic chaining */
75 int prev_linked_ch;
76 int next_linked_ch;
77 int state;
78 int chain_id;
79
80 int status;
81#endif
82 long flags;
83};
84
85struct dma_link_info { 72struct dma_link_info {
86 int *linked_dmach_q; 73 int *linked_dmach_q;
87 int no_of_lchs_linked; 74 int no_of_lchs_linked;
@@ -137,15 +124,6 @@ static int omap_dma_reserve_channels;
137 124
138static spinlock_t dma_chan_lock; 125static spinlock_t dma_chan_lock;
139static struct omap_dma_lch *dma_chan; 126static struct omap_dma_lch *dma_chan;
140static void __iomem *omap_dma_base;
141
142static const u8 omap1_dma_irq[OMAP1_LOGICAL_DMA_CH_COUNT] = {
143 INT_DMA_CH0_6, INT_DMA_CH1_7, INT_DMA_CH2_8, INT_DMA_CH3,
144 INT_DMA_CH4, INT_DMA_CH5, INT_1610_DMA_CH6, INT_1610_DMA_CH7,
145 INT_1610_DMA_CH8, INT_1610_DMA_CH9, INT_1610_DMA_CH10,
146 INT_1610_DMA_CH11, INT_1610_DMA_CH12, INT_1610_DMA_CH13,
147 INT_1610_DMA_CH14, INT_1610_DMA_CH15, INT_DMA_LCD
148};
149 127
150static inline void disable_lnk(int lch); 128static inline void disable_lnk(int lch);
151static void omap_disable_channel_irq(int lch); 129static void omap_disable_channel_irq(int lch);
@@ -154,24 +132,6 @@ static inline void omap_enable_channel_irq(int lch);
154#define REVISIT_24XX() printk(KERN_ERR "FIXME: no %s on 24xx\n", \ 132#define REVISIT_24XX() printk(KERN_ERR "FIXME: no %s on 24xx\n", \
155 __func__); 133 __func__);
156 134
157#define dma_read(reg) \
158({ \
159 u32 __val; \
160 if (cpu_class_is_omap1()) \
161 __val = __raw_readw(omap_dma_base + OMAP1_DMA_##reg); \
162 else \
163 __val = __raw_readl(omap_dma_base + OMAP_DMA4_##reg); \
164 __val; \
165})
166
167#define dma_write(val, reg) \
168({ \
169 if (cpu_class_is_omap1()) \
170 __raw_writew((u16)(val), omap_dma_base + OMAP1_DMA_##reg); \
171 else \
172 __raw_writel((val), omap_dma_base + OMAP_DMA4_##reg); \
173})
174
175#ifdef CONFIG_ARCH_OMAP15XX 135#ifdef CONFIG_ARCH_OMAP15XX
176/* Returns 1 if the DMA module is in OMAP1510-compatible mode, 0 otherwise */ 136/* Returns 1 if the DMA module is in OMAP1510-compatible mode, 0 otherwise */
177int omap_dma_in_1510_mode(void) 137int omap_dma_in_1510_mode(void)
@@ -206,16 +166,6 @@ static inline void set_gdma_dev(int req, int dev)
206#define set_gdma_dev(req, dev) do {} while (0) 166#define set_gdma_dev(req, dev) do {} while (0)
207#endif 167#endif
208 168
209/* Omap1 only */
210static void clear_lch_regs(int lch)
211{
212 int i;
213 void __iomem *lch_base = omap_dma_base + OMAP1_DMA_CH_BASE(lch);
214
215 for (i = 0; i < 0x2c; i += 2)
216 __raw_writew(0, lch_base + i);
217}
218
219void omap_set_dma_priority(int lch, int dst_port, int priority) 169void omap_set_dma_priority(int lch, int dst_port, int priority)
220{ 170{
221 unsigned long reg; 171 unsigned long reg;
@@ -248,12 +198,12 @@ void omap_set_dma_priority(int lch, int dst_port, int priority)
248 if (cpu_class_is_omap2()) { 198 if (cpu_class_is_omap2()) {
249 u32 ccr; 199 u32 ccr;
250 200
251 ccr = dma_read(CCR(lch)); 201 ccr = p->dma_read(CCR, lch);
252 if (priority) 202 if (priority)
253 ccr |= (1 << 6); 203 ccr |= (1 << 6);
254 else 204 else
255 ccr &= ~(1 << 6); 205 ccr &= ~(1 << 6);
256 dma_write(ccr, CCR(lch)); 206 p->dma_write(ccr, CCR, lch);
257 } 207 }
258} 208}
259EXPORT_SYMBOL(omap_set_dma_priority); 209EXPORT_SYMBOL(omap_set_dma_priority);
@@ -264,31 +214,31 @@ void omap_set_dma_transfer_params(int lch, int data_type, int elem_count,
264{ 214{
265 u32 l; 215 u32 l;
266 216
267 l = dma_read(CSDP(lch)); 217 l = p->dma_read(CSDP, lch);
268 l &= ~0x03; 218 l &= ~0x03;
269 l |= data_type; 219 l |= data_type;
270 dma_write(l, CSDP(lch)); 220 p->dma_write(l, CSDP, lch);
271 221
272 if (cpu_class_is_omap1()) { 222 if (cpu_class_is_omap1()) {
273 u16 ccr; 223 u16 ccr;
274 224
275 ccr = dma_read(CCR(lch)); 225 ccr = p->dma_read(CCR, lch);
276 ccr &= ~(1 << 5); 226 ccr &= ~(1 << 5);
277 if (sync_mode == OMAP_DMA_SYNC_FRAME) 227 if (sync_mode == OMAP_DMA_SYNC_FRAME)
278 ccr |= 1 << 5; 228 ccr |= 1 << 5;
279 dma_write(ccr, CCR(lch)); 229 p->dma_write(ccr, CCR, lch);
280 230
281 ccr = dma_read(CCR2(lch)); 231 ccr = p->dma_read(CCR2, lch);
282 ccr &= ~(1 << 2); 232 ccr &= ~(1 << 2);
283 if (sync_mode == OMAP_DMA_SYNC_BLOCK) 233 if (sync_mode == OMAP_DMA_SYNC_BLOCK)
284 ccr |= 1 << 2; 234 ccr |= 1 << 2;
285 dma_write(ccr, CCR2(lch)); 235 p->dma_write(ccr, CCR2, lch);
286 } 236 }
287 237
288 if (cpu_class_is_omap2() && dma_trigger) { 238 if (cpu_class_is_omap2() && dma_trigger) {
289 u32 val; 239 u32 val;
290 240
291 val = dma_read(CCR(lch)); 241 val = p->dma_read(CCR, lch);
292 242
293 /* DMA_SYNCHRO_CONTROL_UPPER depends on the channel number */ 243 /* DMA_SYNCHRO_CONTROL_UPPER depends on the channel number */
294 val &= ~((1 << 23) | (3 << 19) | 0x1f); 244 val &= ~((1 << 23) | (3 << 19) | 0x1f);
@@ -313,11 +263,11 @@ void omap_set_dma_transfer_params(int lch, int data_type, int elem_count,
313 } else { 263 } else {
314 val &= ~(1 << 24); /* dest synch */ 264 val &= ~(1 << 24); /* dest synch */
315 } 265 }
316 dma_write(val, CCR(lch)); 266 p->dma_write(val, CCR, lch);
317 } 267 }
318 268
319 dma_write(elem_count, CEN(lch)); 269 p->dma_write(elem_count, CEN, lch);
320 dma_write(frame_count, CFN(lch)); 270 p->dma_write(frame_count, CFN, lch);
321} 271}
322EXPORT_SYMBOL(omap_set_dma_transfer_params); 272EXPORT_SYMBOL(omap_set_dma_transfer_params);
323 273
@@ -328,7 +278,7 @@ void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color)
328 if (cpu_class_is_omap1()) { 278 if (cpu_class_is_omap1()) {
329 u16 w; 279 u16 w;
330 280
331 w = dma_read(CCR2(lch)); 281 w = p->dma_read(CCR2, lch);
332 w &= ~0x03; 282 w &= ~0x03;
333 283
334 switch (mode) { 284 switch (mode) {
@@ -343,23 +293,22 @@ void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color)
343 default: 293 default:
344 BUG(); 294 BUG();
345 } 295 }
346 dma_write(w, CCR2(lch)); 296 p->dma_write(w, CCR2, lch);
347 297
348 w = dma_read(LCH_CTRL(lch)); 298 w = p->dma_read(LCH_CTRL, lch);
349 w &= ~0x0f; 299 w &= ~0x0f;
350 /* Default is channel type 2D */ 300 /* Default is channel type 2D */
351 if (mode) { 301 if (mode) {
352 dma_write((u16)color, COLOR_L(lch)); 302 p->dma_write(color, COLOR, lch);
353 dma_write((u16)(color >> 16), COLOR_U(lch));
354 w |= 1; /* Channel type G */ 303 w |= 1; /* Channel type G */
355 } 304 }
356 dma_write(w, LCH_CTRL(lch)); 305 p->dma_write(w, LCH_CTRL, lch);
357 } 306 }
358 307
359 if (cpu_class_is_omap2()) { 308 if (cpu_class_is_omap2()) {
360 u32 val; 309 u32 val;
361 310
362 val = dma_read(CCR(lch)); 311 val = p->dma_read(CCR, lch);
363 val &= ~((1 << 17) | (1 << 16)); 312 val &= ~((1 << 17) | (1 << 16));
364 313
365 switch (mode) { 314 switch (mode) {
@@ -374,10 +323,10 @@ void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color)
374 default: 323 default:
375 BUG(); 324 BUG();
376 } 325 }
377 dma_write(val, CCR(lch)); 326 p->dma_write(val, CCR, lch);
378 327
379 color &= 0xffffff; 328 color &= 0xffffff;
380 dma_write(color, COLOR(lch)); 329 p->dma_write(color, COLOR, lch);
381 } 330 }
382} 331}
383EXPORT_SYMBOL(omap_set_dma_color_mode); 332EXPORT_SYMBOL(omap_set_dma_color_mode);
@@ -387,10 +336,10 @@ void omap_set_dma_write_mode(int lch, enum omap_dma_write_mode mode)
387 if (cpu_class_is_omap2()) { 336 if (cpu_class_is_omap2()) {
388 u32 csdp; 337 u32 csdp;
389 338
390 csdp = dma_read(CSDP(lch)); 339 csdp = p->dma_read(CSDP, lch);
391 csdp &= ~(0x3 << 16); 340 csdp &= ~(0x3 << 16);
392 csdp |= (mode << 16); 341 csdp |= (mode << 16);
393 dma_write(csdp, CSDP(lch)); 342 p->dma_write(csdp, CSDP, lch);
394 } 343 }
395} 344}
396EXPORT_SYMBOL(omap_set_dma_write_mode); 345EXPORT_SYMBOL(omap_set_dma_write_mode);
@@ -400,10 +349,10 @@ void omap_set_dma_channel_mode(int lch, enum omap_dma_channel_mode mode)
400 if (cpu_class_is_omap1() && !cpu_is_omap15xx()) { 349 if (cpu_class_is_omap1() && !cpu_is_omap15xx()) {
401 u32 l; 350 u32 l;
402 351
403 l = dma_read(LCH_CTRL(lch)); 352 l = p->dma_read(LCH_CTRL, lch);
404 l &= ~0x7; 353 l &= ~0x7;
405 l |= mode; 354 l |= mode;
406 dma_write(l, LCH_CTRL(lch)); 355 p->dma_write(l, LCH_CTRL, lch);
407 } 356 }
408} 357}
409EXPORT_SYMBOL(omap_set_dma_channel_mode); 358EXPORT_SYMBOL(omap_set_dma_channel_mode);
@@ -418,27 +367,21 @@ void omap_set_dma_src_params(int lch, int src_port, int src_amode,
418 if (cpu_class_is_omap1()) { 367 if (cpu_class_is_omap1()) {
419 u16 w; 368 u16 w;
420 369
421 w = dma_read(CSDP(lch)); 370 w = p->dma_read(CSDP, lch);
422 w &= ~(0x1f << 2); 371 w &= ~(0x1f << 2);
423 w |= src_port << 2; 372 w |= src_port << 2;
424 dma_write(w, CSDP(lch)); 373 p->dma_write(w, CSDP, lch);
425 } 374 }
426 375
427 l = dma_read(CCR(lch)); 376 l = p->dma_read(CCR, lch);
428 l &= ~(0x03 << 12); 377 l &= ~(0x03 << 12);
429 l |= src_amode << 12; 378 l |= src_amode << 12;
430 dma_write(l, CCR(lch)); 379 p->dma_write(l, CCR, lch);
431
432 if (cpu_class_is_omap1()) {
433 dma_write(src_start >> 16, CSSA_U(lch));
434 dma_write((u16)src_start, CSSA_L(lch));
435 }
436 380
437 if (cpu_class_is_omap2()) 381 p->dma_write(src_start, CSSA, lch);
438 dma_write(src_start, CSSA(lch));
439 382
440 dma_write(src_ei, CSEI(lch)); 383 p->dma_write(src_ei, CSEI, lch);
441 dma_write(src_fi, CSFI(lch)); 384 p->dma_write(src_fi, CSFI, lch);
442} 385}
443EXPORT_SYMBOL(omap_set_dma_src_params); 386EXPORT_SYMBOL(omap_set_dma_src_params);
444 387
@@ -466,8 +409,8 @@ void omap_set_dma_src_index(int lch, int eidx, int fidx)
466 if (cpu_class_is_omap2()) 409 if (cpu_class_is_omap2())
467 return; 410 return;
468 411
469 dma_write(eidx, CSEI(lch)); 412 p->dma_write(eidx, CSEI, lch);
470 dma_write(fidx, CSFI(lch)); 413 p->dma_write(fidx, CSFI, lch);
471} 414}
472EXPORT_SYMBOL(omap_set_dma_src_index); 415EXPORT_SYMBOL(omap_set_dma_src_index);
473 416
@@ -475,11 +418,11 @@ void omap_set_dma_src_data_pack(int lch, int enable)
475{ 418{
476 u32 l; 419 u32 l;
477 420
478 l = dma_read(CSDP(lch)); 421 l = p->dma_read(CSDP, lch);
479 l &= ~(1 << 6); 422 l &= ~(1 << 6);
480 if (enable) 423 if (enable)
481 l |= (1 << 6); 424 l |= (1 << 6);
482 dma_write(l, CSDP(lch)); 425 p->dma_write(l, CSDP, lch);
483} 426}
484EXPORT_SYMBOL(omap_set_dma_src_data_pack); 427EXPORT_SYMBOL(omap_set_dma_src_data_pack);
485 428
@@ -488,7 +431,7 @@ void omap_set_dma_src_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)
488 unsigned int burst = 0; 431 unsigned int burst = 0;
489 u32 l; 432 u32 l;
490 433
491 l = dma_read(CSDP(lch)); 434 l = p->dma_read(CSDP, lch);
492 l &= ~(0x03 << 7); 435 l &= ~(0x03 << 7);
493 436
494 switch (burst_mode) { 437 switch (burst_mode) {
@@ -524,7 +467,7 @@ void omap_set_dma_src_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)
524 } 467 }
525 468
526 l |= (burst << 7); 469 l |= (burst << 7);
527 dma_write(l, CSDP(lch)); 470 p->dma_write(l, CSDP, lch);
528} 471}
529EXPORT_SYMBOL(omap_set_dma_src_burst_mode); 472EXPORT_SYMBOL(omap_set_dma_src_burst_mode);
530 473
@@ -536,27 +479,21 @@ void omap_set_dma_dest_params(int lch, int dest_port, int dest_amode,
536 u32 l; 479 u32 l;
537 480
538 if (cpu_class_is_omap1()) { 481 if (cpu_class_is_omap1()) {
539 l = dma_read(CSDP(lch)); 482 l = p->dma_read(CSDP, lch);
540 l &= ~(0x1f << 9); 483 l &= ~(0x1f << 9);
541 l |= dest_port << 9; 484 l |= dest_port << 9;
542 dma_write(l, CSDP(lch)); 485 p->dma_write(l, CSDP, lch);
543 } 486 }
544 487
545 l = dma_read(CCR(lch)); 488 l = p->dma_read(CCR, lch);
546 l &= ~(0x03 << 14); 489 l &= ~(0x03 << 14);
547 l |= dest_amode << 14; 490 l |= dest_amode << 14;
548 dma_write(l, CCR(lch)); 491 p->dma_write(l, CCR, lch);
549
550 if (cpu_class_is_omap1()) {
551 dma_write(dest_start >> 16, CDSA_U(lch));
552 dma_write(dest_start, CDSA_L(lch));
553 }
554 492
555 if (cpu_class_is_omap2()) 493 p->dma_write(dest_start, CDSA, lch);
556 dma_write(dest_start, CDSA(lch));
557 494
558 dma_write(dst_ei, CDEI(lch)); 495 p->dma_write(dst_ei, CDEI, lch);
559 dma_write(dst_fi, CDFI(lch)); 496 p->dma_write(dst_fi, CDFI, lch);
560} 497}
561EXPORT_SYMBOL(omap_set_dma_dest_params); 498EXPORT_SYMBOL(omap_set_dma_dest_params);
562 499
@@ -565,8 +502,8 @@ void omap_set_dma_dest_index(int lch, int eidx, int fidx)
565 if (cpu_class_is_omap2()) 502 if (cpu_class_is_omap2())
566 return; 503 return;
567 504
568 dma_write(eidx, CDEI(lch)); 505 p->dma_write(eidx, CDEI, lch);
569 dma_write(fidx, CDFI(lch)); 506 p->dma_write(fidx, CDFI, lch);
570} 507}
571EXPORT_SYMBOL(omap_set_dma_dest_index); 508EXPORT_SYMBOL(omap_set_dma_dest_index);
572 509
@@ -574,11 +511,11 @@ void omap_set_dma_dest_data_pack(int lch, int enable)
574{ 511{
575 u32 l; 512 u32 l;
576 513
577 l = dma_read(CSDP(lch)); 514 l = p->dma_read(CSDP, lch);
578 l &= ~(1 << 13); 515 l &= ~(1 << 13);
579 if (enable) 516 if (enable)
580 l |= 1 << 13; 517 l |= 1 << 13;
581 dma_write(l, CSDP(lch)); 518 p->dma_write(l, CSDP, lch);
582} 519}
583EXPORT_SYMBOL(omap_set_dma_dest_data_pack); 520EXPORT_SYMBOL(omap_set_dma_dest_data_pack);
584 521
@@ -587,7 +524,7 @@ void omap_set_dma_dest_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)
587 unsigned int burst = 0; 524 unsigned int burst = 0;
588 u32 l; 525 u32 l;
589 526
590 l = dma_read(CSDP(lch)); 527 l = p->dma_read(CSDP, lch);
591 l &= ~(0x03 << 14); 528 l &= ~(0x03 << 14);
592 529
593 switch (burst_mode) { 530 switch (burst_mode) {
@@ -620,7 +557,7 @@ void omap_set_dma_dest_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)
620 return; 557 return;
621 } 558 }
622 l |= (burst << 14); 559 l |= (burst << 14);
623 dma_write(l, CSDP(lch)); 560 p->dma_write(l, CSDP, lch);
624} 561}
625EXPORT_SYMBOL(omap_set_dma_dest_burst_mode); 562EXPORT_SYMBOL(omap_set_dma_dest_burst_mode);
626 563
@@ -630,18 +567,18 @@ static inline void omap_enable_channel_irq(int lch)
630 567
631 /* Clear CSR */ 568 /* Clear CSR */
632 if (cpu_class_is_omap1()) 569 if (cpu_class_is_omap1())
633 status = dma_read(CSR(lch)); 570 status = p->dma_read(CSR, lch);
634 else if (cpu_class_is_omap2()) 571 else if (cpu_class_is_omap2())
635 dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(lch)); 572 p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, lch);
636 573
637 /* Enable some nice interrupts. */ 574 /* Enable some nice interrupts. */
638 dma_write(dma_chan[lch].enabled_irqs, CICR(lch)); 575 p->dma_write(dma_chan[lch].enabled_irqs, CICR, lch);
639} 576}
640 577
641static void omap_disable_channel_irq(int lch) 578static void omap_disable_channel_irq(int lch)
642{ 579{
643 if (cpu_class_is_omap2()) 580 if (cpu_class_is_omap2())
644 dma_write(0, CICR(lch)); 581 p->dma_write(0, CICR, lch);
645} 582}
646 583
647void omap_enable_dma_irq(int lch, u16 bits) 584void omap_enable_dma_irq(int lch, u16 bits)
@@ -660,7 +597,7 @@ static inline void enable_lnk(int lch)
660{ 597{
661 u32 l; 598 u32 l;
662 599
663 l = dma_read(CLNK_CTRL(lch)); 600 l = p->dma_read(CLNK_CTRL, lch);
664 601
665 if (cpu_class_is_omap1()) 602 if (cpu_class_is_omap1())
666 l &= ~(1 << 14); 603 l &= ~(1 << 14);
@@ -675,18 +612,18 @@ static inline void enable_lnk(int lch)
675 l = dma_chan[lch].next_linked_ch | (1 << 15); 612 l = dma_chan[lch].next_linked_ch | (1 << 15);
676#endif 613#endif
677 614
678 dma_write(l, CLNK_CTRL(lch)); 615 p->dma_write(l, CLNK_CTRL, lch);
679} 616}
680 617
681static inline void disable_lnk(int lch) 618static inline void disable_lnk(int lch)
682{ 619{
683 u32 l; 620 u32 l;
684 621
685 l = dma_read(CLNK_CTRL(lch)); 622 l = p->dma_read(CLNK_CTRL, lch);
686 623
687 /* Disable interrupts */ 624 /* Disable interrupts */
688 if (cpu_class_is_omap1()) { 625 if (cpu_class_is_omap1()) {
689 dma_write(0, CICR(lch)); 626 p->dma_write(0, CICR, lch);
690 /* Set the STOP_LNK bit */ 627 /* Set the STOP_LNK bit */
691 l |= 1 << 14; 628 l |= 1 << 14;
692 } 629 }
@@ -697,7 +634,7 @@ static inline void disable_lnk(int lch)
697 l &= ~(1 << 15); 634 l &= ~(1 << 15);
698 } 635 }
699 636
700 dma_write(l, CLNK_CTRL(lch)); 637 p->dma_write(l, CLNK_CTRL, lch);
701 dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE; 638 dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE;
702} 639}
703 640
@@ -710,9 +647,9 @@ static inline void omap2_enable_irq_lch(int lch)
710 return; 647 return;
711 648
712 spin_lock_irqsave(&dma_chan_lock, flags); 649 spin_lock_irqsave(&dma_chan_lock, flags);
713 val = dma_read(IRQENABLE_L0); 650 val = p->dma_read(IRQENABLE_L0, lch);
714 val |= 1 << lch; 651 val |= 1 << lch;
715 dma_write(val, IRQENABLE_L0); 652 p->dma_write(val, IRQENABLE_L0, lch);
716 spin_unlock_irqrestore(&dma_chan_lock, flags); 653 spin_unlock_irqrestore(&dma_chan_lock, flags);
717} 654}
718 655
@@ -725,9 +662,9 @@ static inline void omap2_disable_irq_lch(int lch)
725 return; 662 return;
726 663
727 spin_lock_irqsave(&dma_chan_lock, flags); 664 spin_lock_irqsave(&dma_chan_lock, flags);
728 val = dma_read(IRQENABLE_L0); 665 val = p->dma_read(IRQENABLE_L0, lch);
729 val &= ~(1 << lch); 666 val &= ~(1 << lch);
730 dma_write(val, IRQENABLE_L0); 667 p->dma_write(val, IRQENABLE_L0, lch);
731 spin_unlock_irqrestore(&dma_chan_lock, flags); 668 spin_unlock_irqrestore(&dma_chan_lock, flags);
732} 669}
733 670
@@ -754,8 +691,8 @@ int omap_request_dma(int dev_id, const char *dev_name,
754 chan = dma_chan + free_ch; 691 chan = dma_chan + free_ch;
755 chan->dev_id = dev_id; 692 chan->dev_id = dev_id;
756 693
757 if (cpu_class_is_omap1()) 694 if (p->clear_lch_regs)
758 clear_lch_regs(free_ch); 695 p->clear_lch_regs(free_ch);
759 696
760 if (cpu_class_is_omap2()) 697 if (cpu_class_is_omap2())
761 omap_clear_dma(free_ch); 698 omap_clear_dma(free_ch);
@@ -792,17 +729,17 @@ int omap_request_dma(int dev_id, const char *dev_name,
792 * Disable the 1510 compatibility mode and set the sync device 729 * Disable the 1510 compatibility mode and set the sync device
793 * id. 730 * id.
794 */ 731 */
795 dma_write(dev_id | (1 << 10), CCR(free_ch)); 732 p->dma_write(dev_id | (1 << 10), CCR, free_ch);
796 } else if (cpu_is_omap7xx() || cpu_is_omap15xx()) { 733 } else if (cpu_is_omap7xx() || cpu_is_omap15xx()) {
797 dma_write(dev_id, CCR(free_ch)); 734 p->dma_write(dev_id, CCR, free_ch);
798 } 735 }
799 736
800 if (cpu_class_is_omap2()) { 737 if (cpu_class_is_omap2()) {
801 omap2_enable_irq_lch(free_ch); 738 omap2_enable_irq_lch(free_ch);
802 omap_enable_channel_irq(free_ch); 739 omap_enable_channel_irq(free_ch);
803 /* Clear the CSR register and IRQ status register */ 740 /* Clear the CSR register and IRQ status register */
804 dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(free_ch)); 741 p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, free_ch);
805 dma_write(1 << free_ch, IRQSTATUS_L0); 742 p->dma_write(1 << free_ch, IRQSTATUS_L0, 0);
806 } 743 }
807 744
808 *dma_ch_out = free_ch; 745 *dma_ch_out = free_ch;
@@ -823,23 +760,23 @@ void omap_free_dma(int lch)
823 760
824 if (cpu_class_is_omap1()) { 761 if (cpu_class_is_omap1()) {
825 /* Disable all DMA interrupts for the channel. */ 762 /* Disable all DMA interrupts for the channel. */
826 dma_write(0, CICR(lch)); 763 p->dma_write(0, CICR, lch);
827 /* Make sure the DMA transfer is stopped. */ 764 /* Make sure the DMA transfer is stopped. */
828 dma_write(0, CCR(lch)); 765 p->dma_write(0, CCR, lch);
829 } 766 }
830 767
831 if (cpu_class_is_omap2()) { 768 if (cpu_class_is_omap2()) {
832 omap2_disable_irq_lch(lch); 769 omap2_disable_irq_lch(lch);
833 770
834 /* Clear the CSR register and IRQ status register */ 771 /* Clear the CSR register and IRQ status register */
835 dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(lch)); 772 p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, lch);
836 dma_write(1 << lch, IRQSTATUS_L0); 773 p->dma_write(1 << lch, IRQSTATUS_L0, lch);
837 774
838 /* Disable all DMA interrupts for the channel. */ 775 /* Disable all DMA interrupts for the channel. */
839 dma_write(0, CICR(lch)); 776 p->dma_write(0, CICR, lch);
840 777
841 /* Make sure the DMA transfer is stopped. */ 778 /* Make sure the DMA transfer is stopped. */
842 dma_write(0, CCR(lch)); 779 p->dma_write(0, CCR, lch);
843 omap_clear_dma(lch); 780 omap_clear_dma(lch);
844 } 781 }
845 782
@@ -880,7 +817,7 @@ omap_dma_set_global_params(int arb_rate, int max_fifo_depth, int tparams)
880 reg |= (0x3 & tparams) << 12; 817 reg |= (0x3 & tparams) << 12;
881 reg |= (arb_rate & 0xff) << 16; 818 reg |= (arb_rate & 0xff) << 16;
882 819
883 dma_write(reg, GCR); 820 p->dma_write(reg, GCR, 0);
884} 821}
885EXPORT_SYMBOL(omap_dma_set_global_params); 822EXPORT_SYMBOL(omap_dma_set_global_params);
886 823
@@ -903,14 +840,14 @@ omap_dma_set_prio_lch(int lch, unsigned char read_prio,
903 printk(KERN_ERR "Invalid channel id\n"); 840 printk(KERN_ERR "Invalid channel id\n");
904 return -EINVAL; 841 return -EINVAL;
905 } 842 }
906 l = dma_read(CCR(lch)); 843 l = p->dma_read(CCR, lch);
907 l &= ~((1 << 6) | (1 << 26)); 844 l &= ~((1 << 6) | (1 << 26));
908 if (cpu_is_omap2430() || cpu_is_omap34xx() || cpu_is_omap44xx()) 845 if (cpu_is_omap2430() || cpu_is_omap34xx() || cpu_is_omap44xx())
909 l |= ((read_prio & 0x1) << 6) | ((write_prio & 0x1) << 26); 846 l |= ((read_prio & 0x1) << 6) | ((write_prio & 0x1) << 26);
910 else 847 else
911 l |= ((read_prio & 0x1) << 6); 848 l |= ((read_prio & 0x1) << 6);
912 849
913 dma_write(l, CCR(lch)); 850 p->dma_write(l, CCR, lch);
914 851
915 return 0; 852 return 0;
916} 853}
@@ -925,25 +862,7 @@ void omap_clear_dma(int lch)
925 unsigned long flags; 862 unsigned long flags;
926 863
927 local_irq_save(flags); 864 local_irq_save(flags);
928 865 p->clear_dma(lch);
929 if (cpu_class_is_omap1()) {
930 u32 l;
931
932 l = dma_read(CCR(lch));
933 l &= ~OMAP_DMA_CCR_EN;
934 dma_write(l, CCR(lch));
935
936 /* Clear pending interrupts */
937 l = dma_read(CSR(lch));
938 }
939
940 if (cpu_class_is_omap2()) {
941 int i;
942 void __iomem *lch_base = omap_dma_base + OMAP_DMA4_CH_BASE(lch);
943 for (i = 0; i < 0x44; i += 4)
944 __raw_writel(0, lch_base + i);
945 }
946
947 local_irq_restore(flags); 866 local_irq_restore(flags);
948} 867}
949EXPORT_SYMBOL(omap_clear_dma); 868EXPORT_SYMBOL(omap_clear_dma);
@@ -957,13 +876,13 @@ void omap_start_dma(int lch)
957 * before starting dma transfer. 876 * before starting dma transfer.
958 */ 877 */
959 if (cpu_is_omap15xx()) 878 if (cpu_is_omap15xx())
960 dma_write(0, CPC(lch)); 879 p->dma_write(0, CPC, lch);
961 else 880 else
962 dma_write(0, CDAC(lch)); 881 p->dma_write(0, CDAC, lch);
963 882
964 if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) { 883 if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) {
965 int next_lch, cur_lch; 884 int next_lch, cur_lch;
966 char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT]; 885 char dma_chan_link_map[dma_lch_count];
967 886
968 dma_chan_link_map[lch] = 1; 887 dma_chan_link_map[lch] = 1;
969 /* Set the link register of the first channel */ 888 /* Set the link register of the first channel */
@@ -985,32 +904,18 @@ void omap_start_dma(int lch)
985 904
986 cur_lch = next_lch; 905 cur_lch = next_lch;
987 } while (next_lch != -1); 906 } while (next_lch != -1);
988 } else if (cpu_is_omap242x() || 907 } else if (IS_DMA_ERRATA(DMA_ERRATA_PARALLEL_CHANNELS))
989 (cpu_is_omap243x() && omap_type() <= OMAP2430_REV_ES1_0)) { 908 p->dma_write(lch, CLNK_CTRL, lch);
990
991 /* Errata: Need to write lch even if not using chaining */
992 dma_write(lch, CLNK_CTRL(lch));
993 }
994 909
995 omap_enable_channel_irq(lch); 910 omap_enable_channel_irq(lch);
996 911
997 l = dma_read(CCR(lch)); 912 l = p->dma_read(CCR, lch);
998
999 /*
1000 * Errata: Inter Frame DMA buffering issue (All OMAP2420 and
1001 * OMAP2430ES1.0): DMA will wrongly buffer elements if packing and
1002 * bursting is enabled. This might result in data gets stalled in
1003 * FIFO at the end of the block.
1004 * Workaround: DMA channels must have BUFFERING_DISABLED bit set to
1005 * guarantee no data will stay in the DMA FIFO in case inter frame
1006 * buffering occurs.
1007 */
1008 if (cpu_is_omap2420() ||
1009 (cpu_is_omap2430() && (omap_type() == OMAP2430_REV_ES1_0)))
1010 l |= OMAP_DMA_CCR_BUFFERING_DISABLE;
1011 913
914 if (IS_DMA_ERRATA(DMA_ERRATA_IFRAME_BUFFERING))
915 l |= OMAP_DMA_CCR_BUFFERING_DISABLE;
1012 l |= OMAP_DMA_CCR_EN; 916 l |= OMAP_DMA_CCR_EN;
1013 dma_write(l, CCR(lch)); 917
918 p->dma_write(l, CCR, lch);
1014 919
1015 dma_chan[lch].flags |= OMAP_DMA_ACTIVE; 920 dma_chan[lch].flags |= OMAP_DMA_ACTIVE;
1016} 921}
@@ -1022,46 +927,46 @@ void omap_stop_dma(int lch)
1022 927
1023 /* Disable all interrupts on the channel */ 928 /* Disable all interrupts on the channel */
1024 if (cpu_class_is_omap1()) 929 if (cpu_class_is_omap1())
1025 dma_write(0, CICR(lch)); 930 p->dma_write(0, CICR, lch);
1026 931
1027 l = dma_read(CCR(lch)); 932 l = p->dma_read(CCR, lch);
1028 /* OMAP3 Errata i541: sDMA FIFO draining does not finish */ 933 if (IS_DMA_ERRATA(DMA_ERRATA_i541) &&
1029 if (cpu_is_omap34xx() && (l & OMAP_DMA_CCR_SEL_SRC_DST_SYNC)) { 934 (l & OMAP_DMA_CCR_SEL_SRC_DST_SYNC)) {
1030 int i = 0; 935 int i = 0;
1031 u32 sys_cf; 936 u32 sys_cf;
1032 937
1033 /* Configure No-Standby */ 938 /* Configure No-Standby */
1034 l = dma_read(OCP_SYSCONFIG); 939 l = p->dma_read(OCP_SYSCONFIG, lch);
1035 sys_cf = l; 940 sys_cf = l;
1036 l &= ~DMA_SYSCONFIG_MIDLEMODE_MASK; 941 l &= ~DMA_SYSCONFIG_MIDLEMODE_MASK;
1037 l |= DMA_SYSCONFIG_MIDLEMODE(DMA_IDLEMODE_NO_IDLE); 942 l |= DMA_SYSCONFIG_MIDLEMODE(DMA_IDLEMODE_NO_IDLE);
1038 dma_write(l , OCP_SYSCONFIG); 943 p->dma_write(l , OCP_SYSCONFIG, 0);
1039 944
1040 l = dma_read(CCR(lch)); 945 l = p->dma_read(CCR, lch);
1041 l &= ~OMAP_DMA_CCR_EN; 946 l &= ~OMAP_DMA_CCR_EN;
1042 dma_write(l, CCR(lch)); 947 p->dma_write(l, CCR, lch);
1043 948
1044 /* Wait for sDMA FIFO drain */ 949 /* Wait for sDMA FIFO drain */
1045 l = dma_read(CCR(lch)); 950 l = p->dma_read(CCR, lch);
1046 while (i < 100 && (l & (OMAP_DMA_CCR_RD_ACTIVE | 951 while (i < 100 && (l & (OMAP_DMA_CCR_RD_ACTIVE |
1047 OMAP_DMA_CCR_WR_ACTIVE))) { 952 OMAP_DMA_CCR_WR_ACTIVE))) {
1048 udelay(5); 953 udelay(5);
1049 i++; 954 i++;
1050 l = dma_read(CCR(lch)); 955 l = p->dma_read(CCR, lch);
1051 } 956 }
1052 if (i >= 100) 957 if (i >= 100)
1053 printk(KERN_ERR "DMA drain did not complete on " 958 printk(KERN_ERR "DMA drain did not complete on "
1054 "lch %d\n", lch); 959 "lch %d\n", lch);
1055 /* Restore OCP_SYSCONFIG */ 960 /* Restore OCP_SYSCONFIG */
1056 dma_write(sys_cf, OCP_SYSCONFIG); 961 p->dma_write(sys_cf, OCP_SYSCONFIG, lch);
1057 } else { 962 } else {
1058 l &= ~OMAP_DMA_CCR_EN; 963 l &= ~OMAP_DMA_CCR_EN;
1059 dma_write(l, CCR(lch)); 964 p->dma_write(l, CCR, lch);
1060 } 965 }
1061 966
1062 if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) { 967 if (!omap_dma_in_1510_mode() && dma_chan[lch].next_lch != -1) {
1063 int next_lch, cur_lch = lch; 968 int next_lch, cur_lch = lch;
1064 char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT]; 969 char dma_chan_link_map[dma_lch_count];
1065 970
1066 memset(dma_chan_link_map, 0, sizeof(dma_chan_link_map)); 971 memset(dma_chan_link_map, 0, sizeof(dma_chan_link_map));
1067 do { 972 do {
@@ -1122,19 +1027,15 @@ dma_addr_t omap_get_dma_src_pos(int lch)
1122 dma_addr_t offset = 0; 1027 dma_addr_t offset = 0;
1123 1028
1124 if (cpu_is_omap15xx()) 1029 if (cpu_is_omap15xx())
1125 offset = dma_read(CPC(lch)); 1030 offset = p->dma_read(CPC, lch);
1126 else 1031 else
1127 offset = dma_read(CSAC(lch)); 1032 offset = p->dma_read(CSAC, lch);
1128 1033
1129 /* 1034 if (IS_DMA_ERRATA(DMA_ERRATA_3_3) && offset == 0)
1130 * omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is 1035 offset = p->dma_read(CSAC, lch);
1131 * read before the DMA controller finished disabling the channel.
1132 */
1133 if (!cpu_is_omap15xx() && offset == 0)
1134 offset = dma_read(CSAC(lch));
1135 1036
1136 if (cpu_class_is_omap1()) 1037 if (cpu_class_is_omap1())
1137 offset |= (dma_read(CSSA_U(lch)) << 16); 1038 offset |= (p->dma_read(CSSA, lch) & 0xFFFF0000);
1138 1039
1139 return offset; 1040 return offset;
1140} 1041}
@@ -1153,19 +1054,19 @@ dma_addr_t omap_get_dma_dst_pos(int lch)
1153 dma_addr_t offset = 0; 1054 dma_addr_t offset = 0;
1154 1055
1155 if (cpu_is_omap15xx()) 1056 if (cpu_is_omap15xx())
1156 offset = dma_read(CPC(lch)); 1057 offset = p->dma_read(CPC, lch);
1157 else 1058 else
1158 offset = dma_read(CDAC(lch)); 1059 offset = p->dma_read(CDAC, lch);
1159 1060
1160 /* 1061 /*
1161 * omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is 1062 * omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is
1162 * read before the DMA controller finished disabling the channel. 1063 * read before the DMA controller finished disabling the channel.
1163 */ 1064 */
1164 if (!cpu_is_omap15xx() && offset == 0) 1065 if (!cpu_is_omap15xx() && offset == 0)
1165 offset = dma_read(CDAC(lch)); 1066 offset = p->dma_read(CDAC, lch);
1166 1067
1167 if (cpu_class_is_omap1()) 1068 if (cpu_class_is_omap1())
1168 offset |= (dma_read(CDSA_U(lch)) << 16); 1069 offset |= (p->dma_read(CDSA, lch) & 0xFFFF0000);
1169 1070
1170 return offset; 1071 return offset;
1171} 1072}
@@ -1173,7 +1074,7 @@ EXPORT_SYMBOL(omap_get_dma_dst_pos);
1173 1074
1174int omap_get_dma_active_status(int lch) 1075int omap_get_dma_active_status(int lch)
1175{ 1076{
1176 return (dma_read(CCR(lch)) & OMAP_DMA_CCR_EN) != 0; 1077 return (p->dma_read(CCR, lch) & OMAP_DMA_CCR_EN) != 0;
1177} 1078}
1178EXPORT_SYMBOL(omap_get_dma_active_status); 1079EXPORT_SYMBOL(omap_get_dma_active_status);
1179 1080
@@ -1186,7 +1087,7 @@ int omap_dma_running(void)
1186 return 1; 1087 return 1;
1187 1088
1188 for (lch = 0; lch < dma_chan_count; lch++) 1089 for (lch = 0; lch < dma_chan_count; lch++)
1189 if (dma_read(CCR(lch)) & OMAP_DMA_CCR_EN) 1090 if (p->dma_read(CCR, lch) & OMAP_DMA_CCR_EN)
1190 return 1; 1091 return 1;
1191 1092
1192 return 0; 1093 return 0;
@@ -1201,8 +1102,8 @@ void omap_dma_link_lch(int lch_head, int lch_queue)
1201{ 1102{
1202 if (omap_dma_in_1510_mode()) { 1103 if (omap_dma_in_1510_mode()) {
1203 if (lch_head == lch_queue) { 1104 if (lch_head == lch_queue) {
1204 dma_write(dma_read(CCR(lch_head)) | (3 << 8), 1105 p->dma_write(p->dma_read(CCR, lch_head) | (3 << 8),
1205 CCR(lch_head)); 1106 CCR, lch_head);
1206 return; 1107 return;
1207 } 1108 }
1208 printk(KERN_ERR "DMA linking is not supported in 1510 mode\n"); 1109 printk(KERN_ERR "DMA linking is not supported in 1510 mode\n");
@@ -1228,8 +1129,8 @@ void omap_dma_unlink_lch(int lch_head, int lch_queue)
1228{ 1129{
1229 if (omap_dma_in_1510_mode()) { 1130 if (omap_dma_in_1510_mode()) {
1230 if (lch_head == lch_queue) { 1131 if (lch_head == lch_queue) {
1231 dma_write(dma_read(CCR(lch_head)) & ~(3 << 8), 1132 p->dma_write(p->dma_read(CCR, lch_head) & ~(3 << 8),
1232 CCR(lch_head)); 1133 CCR, lch_head);
1233 return; 1134 return;
1234 } 1135 }
1235 printk(KERN_ERR "DMA linking is not supported in 1510 mode\n"); 1136 printk(KERN_ERR "DMA linking is not supported in 1510 mode\n");
@@ -1255,8 +1156,6 @@ void omap_dma_unlink_lch(int lch_head, int lch_queue)
1255} 1156}
1256EXPORT_SYMBOL(omap_dma_unlink_lch); 1157EXPORT_SYMBOL(omap_dma_unlink_lch);
1257 1158
1258/*----------------------------------------------------------------------------*/
1259
1260#ifndef CONFIG_ARCH_OMAP1 1159#ifndef CONFIG_ARCH_OMAP1
1261/* Create chain of DMA channesls */ 1160/* Create chain of DMA channesls */
1262static void create_dma_lch_chain(int lch_head, int lch_queue) 1161static void create_dma_lch_chain(int lch_head, int lch_queue)
@@ -1281,15 +1180,15 @@ static void create_dma_lch_chain(int lch_head, int lch_queue)
1281 lch_queue; 1180 lch_queue;
1282 } 1181 }
1283 1182
1284 l = dma_read(CLNK_CTRL(lch_head)); 1183 l = p->dma_read(CLNK_CTRL, lch_head);
1285 l &= ~(0x1f); 1184 l &= ~(0x1f);
1286 l |= lch_queue; 1185 l |= lch_queue;
1287 dma_write(l, CLNK_CTRL(lch_head)); 1186 p->dma_write(l, CLNK_CTRL, lch_head);
1288 1187
1289 l = dma_read(CLNK_CTRL(lch_queue)); 1188 l = p->dma_read(CLNK_CTRL, lch_queue);
1290 l &= ~(0x1f); 1189 l &= ~(0x1f);
1291 l |= (dma_chan[lch_queue].next_linked_ch); 1190 l |= (dma_chan[lch_queue].next_linked_ch);
1292 dma_write(l, CLNK_CTRL(lch_queue)); 1191 p->dma_write(l, CLNK_CTRL, lch_queue);
1293} 1192}
1294 1193
1295/** 1194/**
@@ -1565,13 +1464,13 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,
1565 1464
1566 /* Set the params to the free channel */ 1465 /* Set the params to the free channel */
1567 if (src_start != 0) 1466 if (src_start != 0)
1568 dma_write(src_start, CSSA(lch)); 1467 p->dma_write(src_start, CSSA, lch);
1569 if (dest_start != 0) 1468 if (dest_start != 0)
1570 dma_write(dest_start, CDSA(lch)); 1469 p->dma_write(dest_start, CDSA, lch);
1571 1470
1572 /* Write the buffer size */ 1471 /* Write the buffer size */
1573 dma_write(elem_count, CEN(lch)); 1472 p->dma_write(elem_count, CEN, lch);
1574 dma_write(frame_count, CFN(lch)); 1473 p->dma_write(frame_count, CFN, lch);
1575 1474
1576 /* 1475 /*
1577 * If the chain is dynamically linked, 1476 * If the chain is dynamically linked,
@@ -1604,8 +1503,8 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,
1604 enable_lnk(dma_chan[lch].prev_linked_ch); 1503 enable_lnk(dma_chan[lch].prev_linked_ch);
1605 dma_chan[lch].state = DMA_CH_QUEUED; 1504 dma_chan[lch].state = DMA_CH_QUEUED;
1606 start_dma = 0; 1505 start_dma = 0;
1607 if (0 == ((1 << 7) & dma_read( 1506 if (0 == ((1 << 7) & p->dma_read(
1608 CCR(dma_chan[lch].prev_linked_ch)))) { 1507 CCR, dma_chan[lch].prev_linked_ch))) {
1609 disable_lnk(dma_chan[lch]. 1508 disable_lnk(dma_chan[lch].
1610 prev_linked_ch); 1509 prev_linked_ch);
1611 pr_debug("\n prev ch is stopped\n"); 1510 pr_debug("\n prev ch is stopped\n");
@@ -1621,7 +1520,7 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,
1621 } 1520 }
1622 omap_enable_channel_irq(lch); 1521 omap_enable_channel_irq(lch);
1623 1522
1624 l = dma_read(CCR(lch)); 1523 l = p->dma_read(CCR, lch);
1625 1524
1626 if ((0 == (l & (1 << 24)))) 1525 if ((0 == (l & (1 << 24))))
1627 l &= ~(1 << 25); 1526 l &= ~(1 << 25);
@@ -1632,12 +1531,12 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,
1632 l |= (1 << 7); 1531 l |= (1 << 7);
1633 dma_chan[lch].state = DMA_CH_STARTED; 1532 dma_chan[lch].state = DMA_CH_STARTED;
1634 pr_debug("starting %d\n", lch); 1533 pr_debug("starting %d\n", lch);
1635 dma_write(l, CCR(lch)); 1534 p->dma_write(l, CCR, lch);
1636 } else 1535 } else
1637 start_dma = 0; 1536 start_dma = 0;
1638 } else { 1537 } else {
1639 if (0 == (l & (1 << 7))) 1538 if (0 == (l & (1 << 7)))
1640 dma_write(l, CCR(lch)); 1539 p->dma_write(l, CCR, lch);
1641 } 1540 }
1642 dma_chan[lch].flags |= OMAP_DMA_ACTIVE; 1541 dma_chan[lch].flags |= OMAP_DMA_ACTIVE;
1643 } 1542 }
@@ -1682,7 +1581,7 @@ int omap_start_dma_chain_transfers(int chain_id)
1682 omap_enable_channel_irq(channels[0]); 1581 omap_enable_channel_irq(channels[0]);
1683 } 1582 }
1684 1583
1685 l = dma_read(CCR(channels[0])); 1584 l = p->dma_read(CCR, channels[0]);
1686 l |= (1 << 7); 1585 l |= (1 << 7);
1687 dma_linked_lch[chain_id].chain_state = DMA_CHAIN_STARTED; 1586 dma_linked_lch[chain_id].chain_state = DMA_CHAIN_STARTED;
1688 dma_chan[channels[0]].state = DMA_CH_STARTED; 1587 dma_chan[channels[0]].state = DMA_CH_STARTED;
@@ -1691,7 +1590,7 @@ int omap_start_dma_chain_transfers(int chain_id)
1691 l &= ~(1 << 25); 1590 l &= ~(1 << 25);
1692 else 1591 else
1693 l |= (1 << 25); 1592 l |= (1 << 25);
1694 dma_write(l, CCR(channels[0])); 1593 p->dma_write(l, CCR, channels[0]);
1695 1594
1696 dma_chan[channels[0]].flags |= OMAP_DMA_ACTIVE; 1595 dma_chan[channels[0]].flags |= OMAP_DMA_ACTIVE;
1697 1596
@@ -1711,7 +1610,7 @@ int omap_stop_dma_chain_transfers(int chain_id)
1711{ 1610{
1712 int *channels; 1611 int *channels;
1713 u32 l, i; 1612 u32 l, i;
1714 u32 sys_cf; 1613 u32 sys_cf = 0;
1715 1614
1716 /* Check for input params */ 1615 /* Check for input params */
1717 if (unlikely((chain_id < 0 || chain_id >= dma_lch_count))) { 1616 if (unlikely((chain_id < 0 || chain_id >= dma_lch_count))) {
@@ -1726,22 +1625,20 @@ int omap_stop_dma_chain_transfers(int chain_id)
1726 } 1625 }
1727 channels = dma_linked_lch[chain_id].linked_dmach_q; 1626 channels = dma_linked_lch[chain_id].linked_dmach_q;
1728 1627
1729 /* 1628 if (IS_DMA_ERRATA(DMA_ERRATA_i88)) {
1730 * DMA Errata: 1629 sys_cf = p->dma_read(OCP_SYSCONFIG, 0);
1731 * Special programming model needed to disable DMA before end of block 1630 l = sys_cf;
1732 */ 1631 /* Middle mode reg set no Standby */
1733 sys_cf = dma_read(OCP_SYSCONFIG); 1632 l &= ~((1 << 12)|(1 << 13));
1734 l = sys_cf; 1633 p->dma_write(l, OCP_SYSCONFIG, 0);
1735 /* Middle mode reg set no Standby */ 1634 }
1736 l &= ~((1 << 12)|(1 << 13));
1737 dma_write(l, OCP_SYSCONFIG);
1738 1635
1739 for (i = 0; i < dma_linked_lch[chain_id].no_of_lchs_linked; i++) { 1636 for (i = 0; i < dma_linked_lch[chain_id].no_of_lchs_linked; i++) {
1740 1637
1741 /* Stop the Channel transmission */ 1638 /* Stop the Channel transmission */
1742 l = dma_read(CCR(channels[i])); 1639 l = p->dma_read(CCR, channels[i]);
1743 l &= ~(1 << 7); 1640 l &= ~(1 << 7);
1744 dma_write(l, CCR(channels[i])); 1641 p->dma_write(l, CCR, channels[i]);
1745 1642
1746 /* Disable the link in all the channels */ 1643 /* Disable the link in all the channels */
1747 disable_lnk(channels[i]); 1644 disable_lnk(channels[i]);
@@ -1753,8 +1650,8 @@ int omap_stop_dma_chain_transfers(int chain_id)
1753 /* Reset the Queue pointers */ 1650 /* Reset the Queue pointers */
1754 OMAP_DMA_CHAIN_QINIT(chain_id); 1651 OMAP_DMA_CHAIN_QINIT(chain_id);
1755 1652
1756 /* Errata - put in the old value */ 1653 if (IS_DMA_ERRATA(DMA_ERRATA_i88))
1757 dma_write(sys_cf, OCP_SYSCONFIG); 1654 p->dma_write(sys_cf, OCP_SYSCONFIG, 0);
1758 1655
1759 return 0; 1656 return 0;
1760} 1657}
@@ -1796,8 +1693,8 @@ int omap_get_dma_chain_index(int chain_id, int *ei, int *fi)
1796 /* Get the current channel */ 1693 /* Get the current channel */
1797 lch = channels[dma_linked_lch[chain_id].q_head]; 1694 lch = channels[dma_linked_lch[chain_id].q_head];
1798 1695
1799 *ei = dma_read(CCEN(lch)); 1696 *ei = p->dma_read(CCEN, lch);
1800 *fi = dma_read(CCFN(lch)); 1697 *fi = p->dma_read(CCFN, lch);
1801 1698
1802 return 0; 1699 return 0;
1803} 1700}
@@ -1834,7 +1731,7 @@ int omap_get_dma_chain_dst_pos(int chain_id)
1834 /* Get the current channel */ 1731 /* Get the current channel */
1835 lch = channels[dma_linked_lch[chain_id].q_head]; 1732 lch = channels[dma_linked_lch[chain_id].q_head];
1836 1733
1837 return dma_read(CDAC(lch)); 1734 return p->dma_read(CDAC, lch);
1838} 1735}
1839EXPORT_SYMBOL(omap_get_dma_chain_dst_pos); 1736EXPORT_SYMBOL(omap_get_dma_chain_dst_pos);
1840 1737
@@ -1868,7 +1765,7 @@ int omap_get_dma_chain_src_pos(int chain_id)
1868 /* Get the current channel */ 1765 /* Get the current channel */
1869 lch = channels[dma_linked_lch[chain_id].q_head]; 1766 lch = channels[dma_linked_lch[chain_id].q_head];
1870 1767
1871 return dma_read(CSAC(lch)); 1768 return p->dma_read(CSAC, lch);
1872} 1769}
1873EXPORT_SYMBOL(omap_get_dma_chain_src_pos); 1770EXPORT_SYMBOL(omap_get_dma_chain_src_pos);
1874#endif /* ifndef CONFIG_ARCH_OMAP1 */ 1771#endif /* ifndef CONFIG_ARCH_OMAP1 */
@@ -1885,7 +1782,7 @@ static int omap1_dma_handle_ch(int ch)
1885 csr = dma_chan[ch].saved_csr; 1782 csr = dma_chan[ch].saved_csr;
1886 dma_chan[ch].saved_csr = 0; 1783 dma_chan[ch].saved_csr = 0;
1887 } else 1784 } else
1888 csr = dma_read(CSR(ch)); 1785 csr = p->dma_read(CSR, ch);
1889 if (enable_1510_mode && ch <= 2 && (csr >> 7) != 0) { 1786 if (enable_1510_mode && ch <= 2 && (csr >> 7) != 0) {
1890 dma_chan[ch + 6].saved_csr = csr >> 7; 1787 dma_chan[ch + 6].saved_csr = csr >> 7;
1891 csr &= 0x7f; 1788 csr &= 0x7f;
@@ -1938,13 +1835,13 @@ static irqreturn_t omap1_dma_irq_handler(int irq, void *dev_id)
1938 1835
1939static int omap2_dma_handle_ch(int ch) 1836static int omap2_dma_handle_ch(int ch)
1940{ 1837{
1941 u32 status = dma_read(CSR(ch)); 1838 u32 status = p->dma_read(CSR, ch);
1942 1839
1943 if (!status) { 1840 if (!status) {
1944 if (printk_ratelimit()) 1841 if (printk_ratelimit())
1945 printk(KERN_WARNING "Spurious DMA IRQ for lch %d\n", 1842 printk(KERN_WARNING "Spurious DMA IRQ for lch %d\n",
1946 ch); 1843 ch);
1947 dma_write(1 << ch, IRQSTATUS_L0); 1844 p->dma_write(1 << ch, IRQSTATUS_L0, ch);
1948 return 0; 1845 return 0;
1949 } 1846 }
1950 if (unlikely(dma_chan[ch].dev_id == -1)) { 1847 if (unlikely(dma_chan[ch].dev_id == -1)) {
@@ -1960,17 +1857,12 @@ static int omap2_dma_handle_ch(int ch)
1960 if (unlikely(status & OMAP2_DMA_TRANS_ERR_IRQ)) { 1857 if (unlikely(status & OMAP2_DMA_TRANS_ERR_IRQ)) {
1961 printk(KERN_INFO "DMA transaction error with device %d\n", 1858 printk(KERN_INFO "DMA transaction error with device %d\n",
1962 dma_chan[ch].dev_id); 1859 dma_chan[ch].dev_id);
1963 if (cpu_class_is_omap2()) { 1860 if (IS_DMA_ERRATA(DMA_ERRATA_i378)) {
1964 /*
1965 * Errata: sDMA Channel is not disabled
1966 * after a transaction error. So we explicitely
1967 * disable the channel
1968 */
1969 u32 ccr; 1861 u32 ccr;
1970 1862
1971 ccr = dma_read(CCR(ch)); 1863 ccr = p->dma_read(CCR, ch);
1972 ccr &= ~OMAP_DMA_CCR_EN; 1864 ccr &= ~OMAP_DMA_CCR_EN;
1973 dma_write(ccr, CCR(ch)); 1865 p->dma_write(ccr, CCR, ch);
1974 dma_chan[ch].flags &= ~OMAP_DMA_ACTIVE; 1866 dma_chan[ch].flags &= ~OMAP_DMA_ACTIVE;
1975 } 1867 }
1976 } 1868 }
@@ -1981,16 +1873,16 @@ static int omap2_dma_handle_ch(int ch)
1981 printk(KERN_INFO "DMA misaligned error with device %d\n", 1873 printk(KERN_INFO "DMA misaligned error with device %d\n",
1982 dma_chan[ch].dev_id); 1874 dma_chan[ch].dev_id);
1983 1875
1984 dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(ch)); 1876 p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, ch);
1985 dma_write(1 << ch, IRQSTATUS_L0); 1877 p->dma_write(1 << ch, IRQSTATUS_L0, ch);
1986 /* read back the register to flush the write */ 1878 /* read back the register to flush the write */
1987 dma_read(IRQSTATUS_L0); 1879 p->dma_read(IRQSTATUS_L0, ch);
1988 1880
1989 /* If the ch is not chained then chain_id will be -1 */ 1881 /* If the ch is not chained then chain_id will be -1 */
1990 if (dma_chan[ch].chain_id != -1) { 1882 if (dma_chan[ch].chain_id != -1) {
1991 int chain_id = dma_chan[ch].chain_id; 1883 int chain_id = dma_chan[ch].chain_id;
1992 dma_chan[ch].state = DMA_CH_NOTSTARTED; 1884 dma_chan[ch].state = DMA_CH_NOTSTARTED;
1993 if (dma_read(CLNK_CTRL(ch)) & (1 << 15)) 1885 if (p->dma_read(CLNK_CTRL, ch) & (1 << 15))
1994 dma_chan[dma_chan[ch].next_linked_ch].state = 1886 dma_chan[dma_chan[ch].next_linked_ch].state =
1995 DMA_CH_STARTED; 1887 DMA_CH_STARTED;
1996 if (dma_linked_lch[chain_id].chain_mode == 1888 if (dma_linked_lch[chain_id].chain_mode ==
@@ -2000,10 +1892,10 @@ static int omap2_dma_handle_ch(int ch)
2000 if (!OMAP_DMA_CHAIN_QEMPTY(chain_id)) 1892 if (!OMAP_DMA_CHAIN_QEMPTY(chain_id))
2001 OMAP_DMA_CHAIN_INCQHEAD(chain_id); 1893 OMAP_DMA_CHAIN_INCQHEAD(chain_id);
2002 1894
2003 status = dma_read(CSR(ch)); 1895 status = p->dma_read(CSR, ch);
2004 } 1896 }
2005 1897
2006 dma_write(status, CSR(ch)); 1898 p->dma_write(status, CSR, ch);
2007 1899
2008 if (likely(dma_chan[ch].callback != NULL)) 1900 if (likely(dma_chan[ch].callback != NULL))
2009 dma_chan[ch].callback(ch, status, dma_chan[ch].data); 1901 dma_chan[ch].callback(ch, status, dma_chan[ch].data);
@@ -2017,13 +1909,13 @@ static irqreturn_t omap2_dma_irq_handler(int irq, void *dev_id)
2017 u32 val, enable_reg; 1909 u32 val, enable_reg;
2018 int i; 1910 int i;
2019 1911
2020 val = dma_read(IRQSTATUS_L0); 1912 val = p->dma_read(IRQSTATUS_L0, 0);
2021 if (val == 0) { 1913 if (val == 0) {
2022 if (printk_ratelimit()) 1914 if (printk_ratelimit())
2023 printk(KERN_WARNING "Spurious DMA IRQ\n"); 1915 printk(KERN_WARNING "Spurious DMA IRQ\n");
2024 return IRQ_HANDLED; 1916 return IRQ_HANDLED;
2025 } 1917 }
2026 enable_reg = dma_read(IRQENABLE_L0); 1918 enable_reg = p->dma_read(IRQENABLE_L0, 0);
2027 val &= enable_reg; /* Dispatch only relevant interrupts */ 1919 val &= enable_reg; /* Dispatch only relevant interrupts */
2028 for (i = 0; i < dma_lch_count && val != 0; i++) { 1920 for (i = 0; i < dma_lch_count && val != 0; i++) {
2029 if (val & 1) 1921 if (val & 1)
@@ -2049,119 +1941,66 @@ static struct irqaction omap24xx_dma_irq;
2049void omap_dma_global_context_save(void) 1941void omap_dma_global_context_save(void)
2050{ 1942{
2051 omap_dma_global_context.dma_irqenable_l0 = 1943 omap_dma_global_context.dma_irqenable_l0 =
2052 dma_read(IRQENABLE_L0); 1944 p->dma_read(IRQENABLE_L0, 0);
2053 omap_dma_global_context.dma_ocp_sysconfig = 1945 omap_dma_global_context.dma_ocp_sysconfig =
2054 dma_read(OCP_SYSCONFIG); 1946 p->dma_read(OCP_SYSCONFIG, 0);
2055 omap_dma_global_context.dma_gcr = dma_read(GCR); 1947 omap_dma_global_context.dma_gcr = p->dma_read(GCR, 0);
2056} 1948}
2057 1949
2058void omap_dma_global_context_restore(void) 1950void omap_dma_global_context_restore(void)
2059{ 1951{
2060 int ch; 1952 int ch;
2061 1953
2062 dma_write(omap_dma_global_context.dma_gcr, GCR); 1954 p->dma_write(omap_dma_global_context.dma_gcr, GCR, 0);
2063 dma_write(omap_dma_global_context.dma_ocp_sysconfig, 1955 p->dma_write(omap_dma_global_context.dma_ocp_sysconfig,
2064 OCP_SYSCONFIG); 1956 OCP_SYSCONFIG, 0);
2065 dma_write(omap_dma_global_context.dma_irqenable_l0, 1957 p->dma_write(omap_dma_global_context.dma_irqenable_l0,
2066 IRQENABLE_L0); 1958 IRQENABLE_L0, 0);
2067 1959
2068 /* 1960 if (IS_DMA_ERRATA(DMA_ROMCODE_BUG))
2069 * A bug in ROM code leaves IRQ status for channels 0 and 1 uncleared 1961 p->dma_write(0x3 , IRQSTATUS_L0, 0);
2070 * after secure sram context save and restore. Hence we need to
2071 * manually clear those IRQs to avoid spurious interrupts. This
2072 * affects only secure devices.
2073 */
2074 if (cpu_is_omap34xx() && (omap_type() != OMAP2_DEVICE_TYPE_GP))
2075 dma_write(0x3 , IRQSTATUS_L0);
2076 1962
2077 for (ch = 0; ch < dma_chan_count; ch++) 1963 for (ch = 0; ch < dma_chan_count; ch++)
2078 if (dma_chan[ch].dev_id != -1) 1964 if (dma_chan[ch].dev_id != -1)
2079 omap_clear_dma(ch); 1965 omap_clear_dma(ch);
2080} 1966}
2081 1967
2082/*----------------------------------------------------------------------------*/ 1968static int __devinit omap_system_dma_probe(struct platform_device *pdev)
2083
2084static int __init omap_init_dma(void)
2085{ 1969{
2086 unsigned long base; 1970 int ch, ret = 0;
2087 int ch, r; 1971 int dma_irq;
2088 1972 char irq_name[4];
2089 if (cpu_class_is_omap1()) { 1973 int irq_rel;
2090 base = OMAP1_DMA_BASE; 1974
2091 dma_lch_count = OMAP1_LOGICAL_DMA_CH_COUNT; 1975 p = pdev->dev.platform_data;
2092 } else if (cpu_is_omap24xx()) { 1976 if (!p) {
2093 base = OMAP24XX_DMA4_BASE; 1977 dev_err(&pdev->dev, "%s: System DMA initialized without"
2094 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT; 1978 "platform data\n", __func__);
2095 } else if (cpu_is_omap34xx()) { 1979 return -EINVAL;
2096 base = OMAP34XX_DMA4_BASE;
2097 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT;
2098 } else if (cpu_is_omap44xx()) {
2099 base = OMAP44XX_DMA4_BASE;
2100 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT;
2101 } else {
2102 pr_err("DMA init failed for unsupported omap\n");
2103 return -ENODEV;
2104 } 1980 }
2105 1981
2106 omap_dma_base = ioremap(base, SZ_4K); 1982 d = p->dma_attr;
2107 BUG_ON(!omap_dma_base); 1983 errata = p->errata;
2108 1984
2109 if (cpu_class_is_omap2() && omap_dma_reserve_channels 1985 if ((d->dev_caps & RESERVE_CHANNEL) && omap_dma_reserve_channels
2110 && (omap_dma_reserve_channels <= dma_lch_count)) 1986 && (omap_dma_reserve_channels <= dma_lch_count))
2111 dma_lch_count = omap_dma_reserve_channels; 1987 d->lch_count = omap_dma_reserve_channels;
2112 1988
2113 dma_chan = kzalloc(sizeof(struct omap_dma_lch) * dma_lch_count, 1989 dma_lch_count = d->lch_count;
2114 GFP_KERNEL); 1990 dma_chan_count = dma_lch_count;
2115 if (!dma_chan) { 1991 dma_chan = d->chan;
2116 r = -ENOMEM; 1992 enable_1510_mode = d->dev_caps & ENABLE_1510_MODE;
2117 goto out_unmap;
2118 }
2119 1993
2120 if (cpu_class_is_omap2()) { 1994 if (cpu_class_is_omap2()) {
2121 dma_linked_lch = kzalloc(sizeof(struct dma_link_info) * 1995 dma_linked_lch = kzalloc(sizeof(struct dma_link_info) *
2122 dma_lch_count, GFP_KERNEL); 1996 dma_lch_count, GFP_KERNEL);
2123 if (!dma_linked_lch) { 1997 if (!dma_linked_lch) {
2124 r = -ENOMEM; 1998 ret = -ENOMEM;
2125 goto out_free; 1999 goto exit_dma_lch_fail;
2126 } 2000 }
2127 } 2001 }
2128 2002
2129 if (cpu_is_omap15xx()) {
2130 printk(KERN_INFO "DMA support for OMAP15xx initialized\n");
2131 dma_chan_count = 9;
2132 enable_1510_mode = 1;
2133 } else if (cpu_is_omap16xx() || cpu_is_omap7xx()) {
2134 printk(KERN_INFO "OMAP DMA hardware version %d\n",
2135 dma_read(HW_ID));
2136 printk(KERN_INFO "DMA capabilities: %08x:%08x:%04x:%04x:%04x\n",
2137 (dma_read(CAPS_0_U) << 16) |
2138 dma_read(CAPS_0_L),
2139 (dma_read(CAPS_1_U) << 16) |
2140 dma_read(CAPS_1_L),
2141 dma_read(CAPS_2), dma_read(CAPS_3),
2142 dma_read(CAPS_4));
2143 if (!enable_1510_mode) {
2144 u16 w;
2145
2146 /* Disable OMAP 3.0/3.1 compatibility mode. */
2147 w = dma_read(GSCR);
2148 w |= 1 << 3;
2149 dma_write(w, GSCR);
2150 dma_chan_count = 16;
2151 } else
2152 dma_chan_count = 9;
2153 } else if (cpu_class_is_omap2()) {
2154 u8 revision = dma_read(REVISION) & 0xff;
2155 printk(KERN_INFO "OMAP DMA hardware revision %d.%d\n",
2156 revision >> 4, revision & 0xf);
2157 dma_chan_count = dma_lch_count;
2158 } else {
2159 dma_chan_count = 0;
2160 return 0;
2161 }
2162
2163 spin_lock_init(&dma_chan_lock); 2003 spin_lock_init(&dma_chan_lock);
2164
2165 for (ch = 0; ch < dma_chan_count; ch++) { 2004 for (ch = 0; ch < dma_chan_count; ch++) {
2166 omap_clear_dma(ch); 2005 omap_clear_dma(ch);
2167 if (cpu_class_is_omap2()) 2006 if (cpu_class_is_omap2())
@@ -2178,20 +2017,23 @@ static int __init omap_init_dma(void)
2178 * request_irq() doesn't like dev_id (ie. ch) being 2017 * request_irq() doesn't like dev_id (ie. ch) being
2179 * zero, so we have to kludge around this. 2018 * zero, so we have to kludge around this.
2180 */ 2019 */
2181 r = request_irq(omap1_dma_irq[ch], 2020 sprintf(&irq_name[0], "%d", ch);
2021 dma_irq = platform_get_irq_byname(pdev, irq_name);
2022
2023 if (dma_irq < 0) {
2024 ret = dma_irq;
2025 goto exit_dma_irq_fail;
2026 }
2027
2028 /* INT_DMA_LCD is handled in lcd_dma.c */
2029 if (dma_irq == INT_DMA_LCD)
2030 continue;
2031
2032 ret = request_irq(dma_irq,
2182 omap1_dma_irq_handler, 0, "DMA", 2033 omap1_dma_irq_handler, 0, "DMA",
2183 (void *) (ch + 1)); 2034 (void *) (ch + 1));
2184 if (r != 0) { 2035 if (ret != 0)
2185 int i; 2036 goto exit_dma_irq_fail;
2186
2187 printk(KERN_ERR "unable to request IRQ %d "
2188 "for DMA (error %d)\n",
2189 omap1_dma_irq[ch], r);
2190 for (i = 0; i < ch; i++)
2191 free_irq(omap1_dma_irq[i],
2192 (void *) (i + 1));
2193 goto out_free;
2194 }
2195 } 2037 }
2196 } 2038 }
2197 2039
@@ -2200,46 +2042,91 @@ static int __init omap_init_dma(void)
2200 DMA_DEFAULT_FIFO_DEPTH, 0); 2042 DMA_DEFAULT_FIFO_DEPTH, 0);
2201 2043
2202 if (cpu_class_is_omap2()) { 2044 if (cpu_class_is_omap2()) {
2203 int irq; 2045 strcpy(irq_name, "0");
2204 if (cpu_is_omap44xx()) 2046 dma_irq = platform_get_irq_byname(pdev, irq_name);
2205 irq = OMAP44XX_IRQ_SDMA_0; 2047 if (dma_irq < 0) {
2206 else 2048 dev_err(&pdev->dev, "failed: request IRQ %d", dma_irq);
2207 irq = INT_24XX_SDMA_IRQ0; 2049 goto exit_dma_lch_fail;
2208 setup_irq(irq, &omap24xx_dma_irq); 2050 }
2209 } 2051 ret = setup_irq(dma_irq, &omap24xx_dma_irq);
2210 2052 if (ret) {
2211 if (cpu_is_omap34xx() || cpu_is_omap44xx()) { 2053 dev_err(&pdev->dev, "set_up failed for IRQ %d"
2212 /* Enable smartidle idlemodes and autoidle */ 2054 "for DMA (error %d)\n", dma_irq, ret);
2213 u32 v = dma_read(OCP_SYSCONFIG); 2055 goto exit_dma_lch_fail;
2214 v &= ~(DMA_SYSCONFIG_MIDLEMODE_MASK |
2215 DMA_SYSCONFIG_SIDLEMODE_MASK |
2216 DMA_SYSCONFIG_AUTOIDLE);
2217 v |= (DMA_SYSCONFIG_MIDLEMODE(DMA_IDLEMODE_SMARTIDLE) |
2218 DMA_SYSCONFIG_SIDLEMODE(DMA_IDLEMODE_SMARTIDLE) |
2219 DMA_SYSCONFIG_AUTOIDLE);
2220 dma_write(v , OCP_SYSCONFIG);
2221 /* reserve dma channels 0 and 1 in high security devices */
2222 if (cpu_is_omap34xx() &&
2223 (omap_type() != OMAP2_DEVICE_TYPE_GP)) {
2224 printk(KERN_INFO "Reserving DMA channels 0 and 1 for "
2225 "HS ROM code\n");
2226 dma_chan[0].dev_id = 0;
2227 dma_chan[1].dev_id = 1;
2228 } 2056 }
2229 } 2057 }
2230 2058
2059 /* reserve dma channels 0 and 1 in high security devices */
2060 if (cpu_is_omap34xx() &&
2061 (omap_type() != OMAP2_DEVICE_TYPE_GP)) {
2062 printk(KERN_INFO "Reserving DMA channels 0 and 1 for "
2063 "HS ROM code\n");
2064 dma_chan[0].dev_id = 0;
2065 dma_chan[1].dev_id = 1;
2066 }
2067 p->show_dma_caps();
2231 return 0; 2068 return 0;
2232 2069
2233out_free: 2070exit_dma_irq_fail:
2071 dev_err(&pdev->dev, "unable to request IRQ %d"
2072 "for DMA (error %d)\n", dma_irq, ret);
2073 for (irq_rel = 0; irq_rel < ch; irq_rel++) {
2074 dma_irq = platform_get_irq(pdev, irq_rel);
2075 free_irq(dma_irq, (void *)(irq_rel + 1));
2076 }
2077
2078exit_dma_lch_fail:
2079 kfree(p);
2080 kfree(d);
2234 kfree(dma_chan); 2081 kfree(dma_chan);
2082 return ret;
2083}
2235 2084
2236out_unmap: 2085static int __devexit omap_system_dma_remove(struct platform_device *pdev)
2237 iounmap(omap_dma_base); 2086{
2087 int dma_irq;
2238 2088
2239 return r; 2089 if (cpu_class_is_omap2()) {
2090 char irq_name[4];
2091 strcpy(irq_name, "0");
2092 dma_irq = platform_get_irq_byname(pdev, irq_name);
2093 remove_irq(dma_irq, &omap24xx_dma_irq);
2094 } else {
2095 int irq_rel = 0;
2096 for ( ; irq_rel < dma_chan_count; irq_rel++) {
2097 dma_irq = platform_get_irq(pdev, irq_rel);
2098 free_irq(dma_irq, (void *)(irq_rel + 1));
2099 }
2100 }
2101 kfree(p);
2102 kfree(d);
2103 kfree(dma_chan);
2104 return 0;
2105}
2106
2107static struct platform_driver omap_system_dma_driver = {
2108 .probe = omap_system_dma_probe,
2109 .remove = omap_system_dma_remove,
2110 .driver = {
2111 .name = "omap_dma_system"
2112 },
2113};
2114
2115static int __init omap_system_dma_init(void)
2116{
2117 return platform_driver_register(&omap_system_dma_driver);
2118}
2119arch_initcall(omap_system_dma_init);
2120
2121static void __exit omap_system_dma_exit(void)
2122{
2123 platform_driver_unregister(&omap_system_dma_driver);
2240} 2124}
2241 2125
2242arch_initcall(omap_init_dma); 2126MODULE_DESCRIPTION("OMAP SYSTEM DMA DRIVER");
2127MODULE_LICENSE("GPL");
2128MODULE_ALIAS("platform:" DRIVER_NAME);
2129MODULE_AUTHOR("Texas Instruments Inc");
2243 2130
2244/* 2131/*
2245 * Reserve the omap SDMA channels using cmdline bootarg 2132 * Reserve the omap SDMA channels using cmdline bootarg
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index c05c653d1674..1f98e0b94847 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -21,18 +21,18 @@
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/io.h> 23#include <linux/io.h>
24#include <linux/slab.h>
25#include <linux/pm_runtime.h>
24 26
25#include <mach/hardware.h> 27#include <mach/hardware.h>
26#include <asm/irq.h> 28#include <asm/irq.h>
27#include <mach/irqs.h> 29#include <mach/irqs.h>
28#include <mach/gpio.h> 30#include <mach/gpio.h>
29#include <asm/mach/irq.h> 31#include <asm/mach/irq.h>
30#include <plat/powerdomain.h>
31 32
32/* 33/*
33 * OMAP1510 GPIO registers 34 * OMAP1510 GPIO registers
34 */ 35 */
35#define OMAP1510_GPIO_BASE 0xfffce000
36#define OMAP1510_GPIO_DATA_INPUT 0x00 36#define OMAP1510_GPIO_DATA_INPUT 0x00
37#define OMAP1510_GPIO_DATA_OUTPUT 0x04 37#define OMAP1510_GPIO_DATA_OUTPUT 0x04
38#define OMAP1510_GPIO_DIR_CONTROL 0x08 38#define OMAP1510_GPIO_DIR_CONTROL 0x08
@@ -46,10 +46,6 @@
46/* 46/*
47 * OMAP1610 specific GPIO registers 47 * OMAP1610 specific GPIO registers
48 */ 48 */
49#define OMAP1610_GPIO1_BASE 0xfffbe400
50#define OMAP1610_GPIO2_BASE 0xfffbec00
51#define OMAP1610_GPIO3_BASE 0xfffbb400
52#define OMAP1610_GPIO4_BASE 0xfffbbc00
53#define OMAP1610_GPIO_REVISION 0x0000 49#define OMAP1610_GPIO_REVISION 0x0000
54#define OMAP1610_GPIO_SYSCONFIG 0x0010 50#define OMAP1610_GPIO_SYSCONFIG 0x0010
55#define OMAP1610_GPIO_SYSSTATUS 0x0014 51#define OMAP1610_GPIO_SYSSTATUS 0x0014
@@ -71,12 +67,6 @@
71/* 67/*
72 * OMAP7XX specific GPIO registers 68 * OMAP7XX specific GPIO registers
73 */ 69 */
74#define OMAP7XX_GPIO1_BASE 0xfffbc000
75#define OMAP7XX_GPIO2_BASE 0xfffbc800
76#define OMAP7XX_GPIO3_BASE 0xfffbd000
77#define OMAP7XX_GPIO4_BASE 0xfffbd800
78#define OMAP7XX_GPIO5_BASE 0xfffbe000
79#define OMAP7XX_GPIO6_BASE 0xfffbe800
80#define OMAP7XX_GPIO_DATA_INPUT 0x00 70#define OMAP7XX_GPIO_DATA_INPUT 0x00
81#define OMAP7XX_GPIO_DATA_OUTPUT 0x04 71#define OMAP7XX_GPIO_DATA_OUTPUT 0x04
82#define OMAP7XX_GPIO_DIR_CONTROL 0x08 72#define OMAP7XX_GPIO_DIR_CONTROL 0x08
@@ -84,25 +74,10 @@
84#define OMAP7XX_GPIO_INT_MASK 0x10 74#define OMAP7XX_GPIO_INT_MASK 0x10
85#define OMAP7XX_GPIO_INT_STATUS 0x14 75#define OMAP7XX_GPIO_INT_STATUS 0x14
86 76
87#define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
88
89/* 77/*
90 * omap24xx specific GPIO registers 78 * omap2+ specific GPIO registers
91 */ 79 */
92#define OMAP242X_GPIO1_BASE 0x48018000
93#define OMAP242X_GPIO2_BASE 0x4801a000
94#define OMAP242X_GPIO3_BASE 0x4801c000
95#define OMAP242X_GPIO4_BASE 0x4801e000
96
97#define OMAP243X_GPIO1_BASE 0x4900C000
98#define OMAP243X_GPIO2_BASE 0x4900E000
99#define OMAP243X_GPIO3_BASE 0x49010000
100#define OMAP243X_GPIO4_BASE 0x49012000
101#define OMAP243X_GPIO5_BASE 0x480B6000
102
103#define OMAP24XX_GPIO_REVISION 0x0000 80#define OMAP24XX_GPIO_REVISION 0x0000
104#define OMAP24XX_GPIO_SYSCONFIG 0x0010
105#define OMAP24XX_GPIO_SYSSTATUS 0x0014
106#define OMAP24XX_GPIO_IRQSTATUS1 0x0018 81#define OMAP24XX_GPIO_IRQSTATUS1 0x0018
107#define OMAP24XX_GPIO_IRQSTATUS2 0x0028 82#define OMAP24XX_GPIO_IRQSTATUS2 0x0028
108#define OMAP24XX_GPIO_IRQENABLE2 0x002c 83#define OMAP24XX_GPIO_IRQENABLE2 0x002c
@@ -126,7 +101,6 @@
126#define OMAP24XX_GPIO_SETDATAOUT 0x0094 101#define OMAP24XX_GPIO_SETDATAOUT 0x0094
127 102
128#define OMAP4_GPIO_REVISION 0x0000 103#define OMAP4_GPIO_REVISION 0x0000
129#define OMAP4_GPIO_SYSCONFIG 0x0010
130#define OMAP4_GPIO_EOI 0x0020 104#define OMAP4_GPIO_EOI 0x0020
131#define OMAP4_GPIO_IRQSTATUSRAW0 0x0024 105#define OMAP4_GPIO_IRQSTATUSRAW0 0x0024
132#define OMAP4_GPIO_IRQSTATUSRAW1 0x0028 106#define OMAP4_GPIO_IRQSTATUSRAW1 0x0028
@@ -138,7 +112,6 @@
138#define OMAP4_GPIO_IRQSTATUSCLR1 0x0040 112#define OMAP4_GPIO_IRQSTATUSCLR1 0x0040
139#define OMAP4_GPIO_IRQWAKEN0 0x0044 113#define OMAP4_GPIO_IRQWAKEN0 0x0044
140#define OMAP4_GPIO_IRQWAKEN1 0x0048 114#define OMAP4_GPIO_IRQWAKEN1 0x0048
141#define OMAP4_GPIO_SYSSTATUS 0x0114
142#define OMAP4_GPIO_IRQENABLE1 0x011c 115#define OMAP4_GPIO_IRQENABLE1 0x011c
143#define OMAP4_GPIO_WAKE_EN 0x0120 116#define OMAP4_GPIO_WAKE_EN 0x0120
144#define OMAP4_GPIO_IRQSTATUS2 0x0128 117#define OMAP4_GPIO_IRQSTATUS2 0x0128
@@ -159,26 +132,6 @@
159#define OMAP4_GPIO_SETWKUENA 0x0184 132#define OMAP4_GPIO_SETWKUENA 0x0184
160#define OMAP4_GPIO_CLEARDATAOUT 0x0190 133#define OMAP4_GPIO_CLEARDATAOUT 0x0190
161#define OMAP4_GPIO_SETDATAOUT 0x0194 134#define OMAP4_GPIO_SETDATAOUT 0x0194
162/*
163 * omap34xx specific GPIO registers
164 */
165
166#define OMAP34XX_GPIO1_BASE 0x48310000
167#define OMAP34XX_GPIO2_BASE 0x49050000
168#define OMAP34XX_GPIO3_BASE 0x49052000
169#define OMAP34XX_GPIO4_BASE 0x49054000
170#define OMAP34XX_GPIO5_BASE 0x49056000
171#define OMAP34XX_GPIO6_BASE 0x49058000
172
173/*
174 * OMAP44XX specific GPIO registers
175 */
176#define OMAP44XX_GPIO1_BASE 0x4a310000
177#define OMAP44XX_GPIO2_BASE 0x48055000
178#define OMAP44XX_GPIO3_BASE 0x48057000
179#define OMAP44XX_GPIO4_BASE 0x48059000
180#define OMAP44XX_GPIO5_BASE 0x4805B000
181#define OMAP44XX_GPIO6_BASE 0x4805D000
182 135
183struct gpio_bank { 136struct gpio_bank {
184 unsigned long pbase; 137 unsigned long pbase;
@@ -190,14 +143,12 @@ struct gpio_bank {
190 u32 suspend_wakeup; 143 u32 suspend_wakeup;
191 u32 saved_wakeup; 144 u32 saved_wakeup;
192#endif 145#endif
193#ifdef CONFIG_ARCH_OMAP2PLUS
194 u32 non_wakeup_gpios; 146 u32 non_wakeup_gpios;
195 u32 enabled_non_wakeup_gpios; 147 u32 enabled_non_wakeup_gpios;
196 148
197 u32 saved_datain; 149 u32 saved_datain;
198 u32 saved_fallingdetect; 150 u32 saved_fallingdetect;
199 u32 saved_risingdetect; 151 u32 saved_risingdetect;
200#endif
201 u32 level_mask; 152 u32 level_mask;
202 u32 toggle_mask; 153 u32 toggle_mask;
203 spinlock_t lock; 154 spinlock_t lock;
@@ -205,104 +156,13 @@ struct gpio_bank {
205 struct clk *dbck; 156 struct clk *dbck;
206 u32 mod_usage; 157 u32 mod_usage;
207 u32 dbck_enable_mask; 158 u32 dbck_enable_mask;
159 struct device *dev;
160 bool dbck_flag;
161 int stride;
208}; 162};
209 163
210#define METHOD_MPUIO 0
211#define METHOD_GPIO_1510 1
212#define METHOD_GPIO_1610 2
213#define METHOD_GPIO_7XX 3
214#define METHOD_GPIO_24XX 5
215#define METHOD_GPIO_44XX 6
216
217#ifdef CONFIG_ARCH_OMAP16XX
218static struct gpio_bank gpio_bank_1610[5] = {
219 { OMAP1_MPUIO_VBASE, NULL, INT_MPUIO, IH_MPUIO_BASE,
220 METHOD_MPUIO },
221 { OMAP1610_GPIO1_BASE, NULL, INT_GPIO_BANK1, IH_GPIO_BASE,
222 METHOD_GPIO_1610 },
223 { OMAP1610_GPIO2_BASE, NULL, INT_1610_GPIO_BANK2, IH_GPIO_BASE + 16,
224 METHOD_GPIO_1610 },
225 { OMAP1610_GPIO3_BASE, NULL, INT_1610_GPIO_BANK3, IH_GPIO_BASE + 32,
226 METHOD_GPIO_1610 },
227 { OMAP1610_GPIO4_BASE, NULL, INT_1610_GPIO_BANK4, IH_GPIO_BASE + 48,
228 METHOD_GPIO_1610 },
229};
230#endif
231
232#ifdef CONFIG_ARCH_OMAP15XX
233static struct gpio_bank gpio_bank_1510[2] = {
234 { OMAP1_MPUIO_VBASE, NULL, INT_MPUIO, IH_MPUIO_BASE,
235 METHOD_MPUIO },
236 { OMAP1510_GPIO_BASE, NULL, INT_GPIO_BANK1, IH_GPIO_BASE,
237 METHOD_GPIO_1510 }
238};
239#endif
240
241#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
242static struct gpio_bank gpio_bank_7xx[7] = {
243 { OMAP1_MPUIO_VBASE, NULL, INT_7XX_MPUIO, IH_MPUIO_BASE,
244 METHOD_MPUIO },
245 { OMAP7XX_GPIO1_BASE, NULL, INT_7XX_GPIO_BANK1, IH_GPIO_BASE,
246 METHOD_GPIO_7XX },
247 { OMAP7XX_GPIO2_BASE, NULL, INT_7XX_GPIO_BANK2, IH_GPIO_BASE + 32,
248 METHOD_GPIO_7XX },
249 { OMAP7XX_GPIO3_BASE, NULL, INT_7XX_GPIO_BANK3, IH_GPIO_BASE + 64,
250 METHOD_GPIO_7XX },
251 { OMAP7XX_GPIO4_BASE, NULL, INT_7XX_GPIO_BANK4, IH_GPIO_BASE + 96,
252 METHOD_GPIO_7XX },
253 { OMAP7XX_GPIO5_BASE, NULL, INT_7XX_GPIO_BANK5, IH_GPIO_BASE + 128,
254 METHOD_GPIO_7XX },
255 { OMAP7XX_GPIO6_BASE, NULL, INT_7XX_GPIO_BANK6, IH_GPIO_BASE + 160,
256 METHOD_GPIO_7XX },
257};
258#endif
259
260#ifdef CONFIG_ARCH_OMAP2
261
262static struct gpio_bank gpio_bank_242x[4] = {
263 { OMAP242X_GPIO1_BASE, NULL, INT_24XX_GPIO_BANK1, IH_GPIO_BASE,
264 METHOD_GPIO_24XX },
265 { OMAP242X_GPIO2_BASE, NULL, INT_24XX_GPIO_BANK2, IH_GPIO_BASE + 32,
266 METHOD_GPIO_24XX },
267 { OMAP242X_GPIO3_BASE, NULL, INT_24XX_GPIO_BANK3, IH_GPIO_BASE + 64,
268 METHOD_GPIO_24XX },
269 { OMAP242X_GPIO4_BASE, NULL, INT_24XX_GPIO_BANK4, IH_GPIO_BASE + 96,
270 METHOD_GPIO_24XX },
271};
272
273static struct gpio_bank gpio_bank_243x[5] = {
274 { OMAP243X_GPIO1_BASE, NULL, INT_24XX_GPIO_BANK1, IH_GPIO_BASE,
275 METHOD_GPIO_24XX },
276 { OMAP243X_GPIO2_BASE, NULL, INT_24XX_GPIO_BANK2, IH_GPIO_BASE + 32,
277 METHOD_GPIO_24XX },
278 { OMAP243X_GPIO3_BASE, NULL, INT_24XX_GPIO_BANK3, IH_GPIO_BASE + 64,
279 METHOD_GPIO_24XX },
280 { OMAP243X_GPIO4_BASE, NULL, INT_24XX_GPIO_BANK4, IH_GPIO_BASE + 96,
281 METHOD_GPIO_24XX },
282 { OMAP243X_GPIO5_BASE, NULL, INT_24XX_GPIO_BANK5, IH_GPIO_BASE + 128,
283 METHOD_GPIO_24XX },
284};
285
286#endif
287
288#ifdef CONFIG_ARCH_OMAP3 164#ifdef CONFIG_ARCH_OMAP3
289static struct gpio_bank gpio_bank_34xx[6] = {
290 { OMAP34XX_GPIO1_BASE, NULL, INT_34XX_GPIO_BANK1, IH_GPIO_BASE,
291 METHOD_GPIO_24XX },
292 { OMAP34XX_GPIO2_BASE, NULL, INT_34XX_GPIO_BANK2, IH_GPIO_BASE + 32,
293 METHOD_GPIO_24XX },
294 { OMAP34XX_GPIO3_BASE, NULL, INT_34XX_GPIO_BANK3, IH_GPIO_BASE + 64,
295 METHOD_GPIO_24XX },
296 { OMAP34XX_GPIO4_BASE, NULL, INT_34XX_GPIO_BANK4, IH_GPIO_BASE + 96,
297 METHOD_GPIO_24XX },
298 { OMAP34XX_GPIO5_BASE, NULL, INT_34XX_GPIO_BANK5, IH_GPIO_BASE + 128,
299 METHOD_GPIO_24XX },
300 { OMAP34XX_GPIO6_BASE, NULL, INT_34XX_GPIO_BANK6, IH_GPIO_BASE + 160,
301 METHOD_GPIO_24XX },
302};
303
304struct omap3_gpio_regs { 165struct omap3_gpio_regs {
305 u32 sysconfig;
306 u32 irqenable1; 166 u32 irqenable1;
307 u32 irqenable2; 167 u32 irqenable2;
308 u32 wake_en; 168 u32 wake_en;
@@ -318,26 +178,16 @@ struct omap3_gpio_regs {
318static struct omap3_gpio_regs gpio_context[OMAP34XX_NR_GPIOS]; 178static struct omap3_gpio_regs gpio_context[OMAP34XX_NR_GPIOS];
319#endif 179#endif
320 180
321#ifdef CONFIG_ARCH_OMAP4 181/*
322static struct gpio_bank gpio_bank_44xx[6] = { 182 * TODO: Cleanup gpio_bank usage as it is having information
323 { OMAP44XX_GPIO1_BASE, NULL, OMAP44XX_IRQ_GPIO1, IH_GPIO_BASE, 183 * related to all instances of the device
324 METHOD_GPIO_44XX }, 184 */
325 { OMAP44XX_GPIO2_BASE, NULL, OMAP44XX_IRQ_GPIO2, IH_GPIO_BASE + 32, 185static struct gpio_bank *gpio_bank;
326 METHOD_GPIO_44XX },
327 { OMAP44XX_GPIO3_BASE, NULL, OMAP44XX_IRQ_GPIO3, IH_GPIO_BASE + 64,
328 METHOD_GPIO_44XX },
329 { OMAP44XX_GPIO4_BASE, NULL, OMAP44XX_IRQ_GPIO4, IH_GPIO_BASE + 96,
330 METHOD_GPIO_44XX },
331 { OMAP44XX_GPIO5_BASE, NULL, OMAP44XX_IRQ_GPIO5, IH_GPIO_BASE + 128,
332 METHOD_GPIO_44XX },
333 { OMAP44XX_GPIO6_BASE, NULL, OMAP44XX_IRQ_GPIO6, IH_GPIO_BASE + 160,
334 METHOD_GPIO_44XX },
335};
336 186
337#endif 187static int bank_width;
338 188
339static struct gpio_bank *gpio_bank; 189/* TODO: Analyze removing gpio_bank_count usage from driver code */
340static int gpio_bank_count; 190int gpio_bank_count;
341 191
342static inline struct gpio_bank *get_gpio_bank(int gpio) 192static inline struct gpio_bank *get_gpio_bank(int gpio)
343{ 193{
@@ -417,7 +267,7 @@ static void _set_gpio_direction(struct gpio_bank *bank, int gpio, int is_input)
417 switch (bank->method) { 267 switch (bank->method) {
418#ifdef CONFIG_ARCH_OMAP1 268#ifdef CONFIG_ARCH_OMAP1
419 case METHOD_MPUIO: 269 case METHOD_MPUIO:
420 reg += OMAP_MPUIO_IO_CNTL; 270 reg += OMAP_MPUIO_IO_CNTL / bank->stride;
421 break; 271 break;
422#endif 272#endif
423#ifdef CONFIG_ARCH_OMAP15XX 273#ifdef CONFIG_ARCH_OMAP15XX
@@ -465,7 +315,7 @@ static void _set_gpio_dataout(struct gpio_bank *bank, int gpio, int enable)
465 switch (bank->method) { 315 switch (bank->method) {
466#ifdef CONFIG_ARCH_OMAP1 316#ifdef CONFIG_ARCH_OMAP1
467 case METHOD_MPUIO: 317 case METHOD_MPUIO:
468 reg += OMAP_MPUIO_OUTPUT; 318 reg += OMAP_MPUIO_OUTPUT / bank->stride;
469 l = __raw_readl(reg); 319 l = __raw_readl(reg);
470 if (enable) 320 if (enable)
471 l |= 1 << gpio; 321 l |= 1 << gpio;
@@ -537,7 +387,7 @@ static int _get_gpio_datain(struct gpio_bank *bank, int gpio)
537 switch (bank->method) { 387 switch (bank->method) {
538#ifdef CONFIG_ARCH_OMAP1 388#ifdef CONFIG_ARCH_OMAP1
539 case METHOD_MPUIO: 389 case METHOD_MPUIO:
540 reg += OMAP_MPUIO_INPUT_LATCH; 390 reg += OMAP_MPUIO_INPUT_LATCH / bank->stride;
541 break; 391 break;
542#endif 392#endif
543#ifdef CONFIG_ARCH_OMAP15XX 393#ifdef CONFIG_ARCH_OMAP15XX
@@ -583,7 +433,7 @@ static int _get_gpio_dataout(struct gpio_bank *bank, int gpio)
583 switch (bank->method) { 433 switch (bank->method) {
584#ifdef CONFIG_ARCH_OMAP1 434#ifdef CONFIG_ARCH_OMAP1
585 case METHOD_MPUIO: 435 case METHOD_MPUIO:
586 reg += OMAP_MPUIO_OUTPUT; 436 reg += OMAP_MPUIO_OUTPUT / bank->stride;
587 break; 437 break;
588#endif 438#endif
589#ifdef CONFIG_ARCH_OMAP15XX 439#ifdef CONFIG_ARCH_OMAP15XX
@@ -642,6 +492,9 @@ static void _set_gpio_debounce(struct gpio_bank *bank, unsigned gpio,
642 u32 val; 492 u32 val;
643 u32 l; 493 u32 l;
644 494
495 if (!bank->dbck_flag)
496 return;
497
645 if (debounce < 32) 498 if (debounce < 32)
646 debounce = 0x01; 499 debounce = 0x01;
647 else if (debounce > 7936) 500 else if (debounce > 7936)
@@ -651,7 +504,7 @@ static void _set_gpio_debounce(struct gpio_bank *bank, unsigned gpio,
651 504
652 l = 1 << get_gpio_index(gpio); 505 l = 1 << get_gpio_index(gpio);
653 506
654 if (cpu_is_omap44xx()) 507 if (bank->method == METHOD_GPIO_44XX)
655 reg += OMAP4_GPIO_DEBOUNCINGTIME; 508 reg += OMAP4_GPIO_DEBOUNCINGTIME;
656 else 509 else
657 reg += OMAP24XX_GPIO_DEBOUNCE_VAL; 510 reg += OMAP24XX_GPIO_DEBOUNCE_VAL;
@@ -659,7 +512,7 @@ static void _set_gpio_debounce(struct gpio_bank *bank, unsigned gpio,
659 __raw_writel(debounce, reg); 512 __raw_writel(debounce, reg);
660 513
661 reg = bank->base; 514 reg = bank->base;
662 if (cpu_is_omap44xx()) 515 if (bank->method == METHOD_GPIO_44XX)
663 reg += OMAP4_GPIO_DEBOUNCENABLE; 516 reg += OMAP4_GPIO_DEBOUNCENABLE;
664 else 517 else
665 reg += OMAP24XX_GPIO_DEBOUNCE_EN; 518 reg += OMAP24XX_GPIO_DEBOUNCE_EN;
@@ -668,12 +521,10 @@ static void _set_gpio_debounce(struct gpio_bank *bank, unsigned gpio,
668 521
669 if (debounce) { 522 if (debounce) {
670 val |= l; 523 val |= l;
671 if (cpu_is_omap34xx() || cpu_is_omap44xx()) 524 clk_enable(bank->dbck);
672 clk_enable(bank->dbck);
673 } else { 525 } else {
674 val &= ~l; 526 val &= ~l;
675 if (cpu_is_omap34xx() || cpu_is_omap44xx()) 527 clk_disable(bank->dbck);
676 clk_disable(bank->dbck);
677 } 528 }
678 bank->dbck_enable_mask = val; 529 bank->dbck_enable_mask = val;
679 530
@@ -769,7 +620,7 @@ static void _toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio)
769 620
770 switch (bank->method) { 621 switch (bank->method) {
771 case METHOD_MPUIO: 622 case METHOD_MPUIO:
772 reg += OMAP_MPUIO_GPIO_INT_EDGE; 623 reg += OMAP_MPUIO_GPIO_INT_EDGE / bank->stride;
773 break; 624 break;
774#ifdef CONFIG_ARCH_OMAP15XX 625#ifdef CONFIG_ARCH_OMAP15XX
775 case METHOD_GPIO_1510: 626 case METHOD_GPIO_1510:
@@ -803,7 +654,7 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
803 switch (bank->method) { 654 switch (bank->method) {
804#ifdef CONFIG_ARCH_OMAP1 655#ifdef CONFIG_ARCH_OMAP1
805 case METHOD_MPUIO: 656 case METHOD_MPUIO:
806 reg += OMAP_MPUIO_GPIO_INT_EDGE; 657 reg += OMAP_MPUIO_GPIO_INT_EDGE / bank->stride;
807 l = __raw_readl(reg); 658 l = __raw_readl(reg);
808 if ((trigger & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) 659 if ((trigger & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH)
809 bank->toggle_mask |= 1 << gpio; 660 bank->toggle_mask |= 1 << gpio;
@@ -989,7 +840,7 @@ static u32 _get_gpio_irqbank_mask(struct gpio_bank *bank)
989 switch (bank->method) { 840 switch (bank->method) {
990#ifdef CONFIG_ARCH_OMAP1 841#ifdef CONFIG_ARCH_OMAP1
991 case METHOD_MPUIO: 842 case METHOD_MPUIO:
992 reg += OMAP_MPUIO_GPIO_MASKIT; 843 reg += OMAP_MPUIO_GPIO_MASKIT / bank->stride;
993 mask = 0xffff; 844 mask = 0xffff;
994 inv = 1; 845 inv = 1;
995 break; 846 break;
@@ -1046,7 +897,7 @@ static void _enable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask, int enab
1046 switch (bank->method) { 897 switch (bank->method) {
1047#ifdef CONFIG_ARCH_OMAP1 898#ifdef CONFIG_ARCH_OMAP1
1048 case METHOD_MPUIO: 899 case METHOD_MPUIO:
1049 reg += OMAP_MPUIO_GPIO_MASKIT; 900 reg += OMAP_MPUIO_GPIO_MASKIT / bank->stride;
1050 l = __raw_readl(reg); 901 l = __raw_readl(reg);
1051 if (enable) 902 if (enable)
1052 l &= ~(gpio_mask); 903 l &= ~(gpio_mask);
@@ -1296,7 +1147,8 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
1296 bank = get_irq_data(irq); 1147 bank = get_irq_data(irq);
1297#ifdef CONFIG_ARCH_OMAP1 1148#ifdef CONFIG_ARCH_OMAP1
1298 if (bank->method == METHOD_MPUIO) 1149 if (bank->method == METHOD_MPUIO)
1299 isr_reg = bank->base + OMAP_MPUIO_GPIO_INT; 1150 isr_reg = bank->base +
1151 OMAP_MPUIO_GPIO_INT / bank->stride;
1300#endif 1152#endif
1301#ifdef CONFIG_ARCH_OMAP15XX 1153#ifdef CONFIG_ARCH_OMAP15XX
1302 if (bank->method == METHOD_GPIO_1510) 1154 if (bank->method == METHOD_GPIO_1510)
@@ -1318,6 +1170,10 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
1318 if (bank->method == METHOD_GPIO_44XX) 1170 if (bank->method == METHOD_GPIO_44XX)
1319 isr_reg = bank->base + OMAP4_GPIO_IRQSTATUS0; 1171 isr_reg = bank->base + OMAP4_GPIO_IRQSTATUS0;
1320#endif 1172#endif
1173
1174 if (WARN_ON(!isr_reg))
1175 goto exit;
1176
1321 while(1) { 1177 while(1) {
1322 u32 isr_saved, level_mask = 0; 1178 u32 isr_saved, level_mask = 0;
1323 u32 enabled; 1179 u32 enabled;
@@ -1377,6 +1233,7 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
1377 configured, we must unmask the bank interrupt only after 1233 configured, we must unmask the bank interrupt only after
1378 handler(s) are executed in order to avoid spurious bank 1234 handler(s) are executed in order to avoid spurious bank
1379 interrupt */ 1235 interrupt */
1236exit:
1380 if (!unmasked) 1237 if (!unmasked)
1381 desc->chip->unmask(irq); 1238 desc->chip->unmask(irq);
1382 1239
@@ -1489,7 +1346,8 @@ static int omap_mpuio_suspend_noirq(struct device *dev)
1489{ 1346{
1490 struct platform_device *pdev = to_platform_device(dev); 1347 struct platform_device *pdev = to_platform_device(dev);
1491 struct gpio_bank *bank = platform_get_drvdata(pdev); 1348 struct gpio_bank *bank = platform_get_drvdata(pdev);
1492 void __iomem *mask_reg = bank->base + OMAP_MPUIO_GPIO_MASKIT; 1349 void __iomem *mask_reg = bank->base +
1350 OMAP_MPUIO_GPIO_MASKIT / bank->stride;
1493 unsigned long flags; 1351 unsigned long flags;
1494 1352
1495 spin_lock_irqsave(&bank->lock, flags); 1353 spin_lock_irqsave(&bank->lock, flags);
@@ -1504,7 +1362,8 @@ static int omap_mpuio_resume_noirq(struct device *dev)
1504{ 1362{
1505 struct platform_device *pdev = to_platform_device(dev); 1363 struct platform_device *pdev = to_platform_device(dev);
1506 struct gpio_bank *bank = platform_get_drvdata(pdev); 1364 struct gpio_bank *bank = platform_get_drvdata(pdev);
1507 void __iomem *mask_reg = bank->base + OMAP_MPUIO_GPIO_MASKIT; 1365 void __iomem *mask_reg = bank->base +
1366 OMAP_MPUIO_GPIO_MASKIT / bank->stride;
1508 unsigned long flags; 1367 unsigned long flags;
1509 1368
1510 spin_lock_irqsave(&bank->lock, flags); 1369 spin_lock_irqsave(&bank->lock, flags);
@@ -1540,7 +1399,8 @@ static struct platform_device omap_mpuio_device = {
1540 1399
1541static inline void mpuio_init(void) 1400static inline void mpuio_init(void)
1542{ 1401{
1543 platform_set_drvdata(&omap_mpuio_device, &gpio_bank_1610[0]); 1402 struct gpio_bank *bank = get_gpio_bank(OMAP_MPUIO(0));
1403 platform_set_drvdata(&omap_mpuio_device, bank);
1544 1404
1545 if (platform_driver_register(&omap_mpuio_driver) == 0) 1405 if (platform_driver_register(&omap_mpuio_driver) == 0)
1546 (void) platform_device_register(&omap_mpuio_device); 1406 (void) platform_device_register(&omap_mpuio_device);
@@ -1583,7 +1443,7 @@ static int gpio_is_input(struct gpio_bank *bank, int mask)
1583 1443
1584 switch (bank->method) { 1444 switch (bank->method) {
1585 case METHOD_MPUIO: 1445 case METHOD_MPUIO:
1586 reg += OMAP_MPUIO_IO_CNTL; 1446 reg += OMAP_MPUIO_IO_CNTL / bank->stride;
1587 break; 1447 break;
1588 case METHOD_GPIO_1510: 1448 case METHOD_GPIO_1510:
1589 reg += OMAP1510_GPIO_DIR_CONTROL; 1449 reg += OMAP1510_GPIO_DIR_CONTROL;
@@ -1645,6 +1505,13 @@ static int gpio_debounce(struct gpio_chip *chip, unsigned offset,
1645 unsigned long flags; 1505 unsigned long flags;
1646 1506
1647 bank = container_of(chip, struct gpio_bank, chip); 1507 bank = container_of(chip, struct gpio_bank, chip);
1508
1509 if (!bank->dbck) {
1510 bank->dbck = clk_get(bank->dev, "dbclk");
1511 if (IS_ERR(bank->dbck))
1512 dev_err(bank->dev, "Could not get gpio dbck\n");
1513 }
1514
1648 spin_lock_irqsave(&bank->lock, flags); 1515 spin_lock_irqsave(&bank->lock, flags);
1649 _set_gpio_debounce(bank, offset, debounce); 1516 _set_gpio_debounce(bank, offset, debounce);
1650 spin_unlock_irqrestore(&bank->lock, flags); 1517 spin_unlock_irqrestore(&bank->lock, flags);
@@ -1673,34 +1540,16 @@ static int gpio_2irq(struct gpio_chip *chip, unsigned offset)
1673 1540
1674/*---------------------------------------------------------------------*/ 1541/*---------------------------------------------------------------------*/
1675 1542
1676static int initialized; 1543static void __init omap_gpio_show_rev(struct gpio_bank *bank)
1677#if defined(CONFIG_ARCH_OMAP1) || defined(CONFIG_ARCH_OMAP2)
1678static struct clk * gpio_ick;
1679#endif
1680
1681#if defined(CONFIG_ARCH_OMAP2)
1682static struct clk * gpio_fck;
1683#endif
1684
1685#if defined(CONFIG_ARCH_OMAP2430)
1686static struct clk * gpio5_ick;
1687static struct clk * gpio5_fck;
1688#endif
1689
1690#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
1691static struct clk *gpio_iclks[OMAP34XX_NR_GPIOS];
1692#endif
1693
1694static void __init omap_gpio_show_rev(void)
1695{ 1544{
1696 u32 rev; 1545 u32 rev;
1697 1546
1698 if (cpu_is_omap16xx()) 1547 if (cpu_is_omap16xx() && !(bank->method != METHOD_MPUIO))
1699 rev = __raw_readw(gpio_bank[1].base + OMAP1610_GPIO_REVISION); 1548 rev = __raw_readw(bank->base + OMAP1610_GPIO_REVISION);
1700 else if (cpu_is_omap24xx() || cpu_is_omap34xx()) 1549 else if (cpu_is_omap24xx() || cpu_is_omap34xx())
1701 rev = __raw_readl(gpio_bank[0].base + OMAP24XX_GPIO_REVISION); 1550 rev = __raw_readl(bank->base + OMAP24XX_GPIO_REVISION);
1702 else if (cpu_is_omap44xx()) 1551 else if (cpu_is_omap44xx())
1703 rev = __raw_readl(gpio_bank[0].base + OMAP4_GPIO_REVISION); 1552 rev = __raw_readl(bank->base + OMAP4_GPIO_REVISION);
1704 else 1553 else
1705 return; 1554 return;
1706 1555
@@ -1713,250 +1562,190 @@ static void __init omap_gpio_show_rev(void)
1713 */ 1562 */
1714static struct lock_class_key gpio_lock_class; 1563static struct lock_class_key gpio_lock_class;
1715 1564
1716static int __init _omap_gpio_init(void) 1565static inline int init_gpio_info(struct platform_device *pdev)
1717{ 1566{
1718 int i; 1567 /* TODO: Analyze removing gpio_bank_count usage from driver code */
1719 int gpio = 0; 1568 gpio_bank = kzalloc(gpio_bank_count * sizeof(struct gpio_bank),
1720 struct gpio_bank *bank; 1569 GFP_KERNEL);
1721 int bank_size = SZ_8K; /* Module 4KB + L4 4KB except on omap1 */ 1570 if (!gpio_bank) {
1722 char clk_name[11]; 1571 dev_err(&pdev->dev, "Memory alloc failed for gpio_bank\n");
1723 1572 return -ENOMEM;
1724 initialized = 1;
1725
1726#if defined(CONFIG_ARCH_OMAP1)
1727 if (cpu_is_omap15xx()) {
1728 gpio_ick = clk_get(NULL, "arm_gpio_ck");
1729 if (IS_ERR(gpio_ick))
1730 printk("Could not get arm_gpio_ck\n");
1731 else
1732 clk_enable(gpio_ick);
1733 } 1573 }
1734#endif 1574 return 0;
1735#if defined(CONFIG_ARCH_OMAP2) 1575}
1736 if (cpu_class_is_omap2()) {
1737 gpio_ick = clk_get(NULL, "gpios_ick");
1738 if (IS_ERR(gpio_ick))
1739 printk("Could not get gpios_ick\n");
1740 else
1741 clk_enable(gpio_ick);
1742 gpio_fck = clk_get(NULL, "gpios_fck");
1743 if (IS_ERR(gpio_fck))
1744 printk("Could not get gpios_fck\n");
1745 else
1746 clk_enable(gpio_fck);
1747 1576
1748 /* 1577/* TODO: Cleanup cpu_is_* checks */
1749 * On 2430 & 3430 GPIO 5 uses CORE L4 ICLK 1578static void omap_gpio_mod_init(struct gpio_bank *bank, int id)
1750 */ 1579{
1751#if defined(CONFIG_ARCH_OMAP2430) 1580 if (cpu_class_is_omap2()) {
1752 if (cpu_is_omap2430()) { 1581 if (cpu_is_omap44xx()) {
1753 gpio5_ick = clk_get(NULL, "gpio5_ick"); 1582 __raw_writel(0xffffffff, bank->base +
1754 if (IS_ERR(gpio5_ick)) 1583 OMAP4_GPIO_IRQSTATUSCLR0);
1755 printk("Could not get gpio5_ick\n"); 1584 __raw_writel(0x00000000, bank->base +
1756 else 1585 OMAP4_GPIO_DEBOUNCENABLE);
1757 clk_enable(gpio5_ick); 1586 /* Initialize interface clk ungated, module enabled */
1758 gpio5_fck = clk_get(NULL, "gpio5_fck"); 1587 __raw_writel(0, bank->base + OMAP4_GPIO_CTRL);
1759 if (IS_ERR(gpio5_fck)) 1588 } else if (cpu_is_omap34xx()) {
1760 printk("Could not get gpio5_fck\n"); 1589 __raw_writel(0x00000000, bank->base +
1761 else 1590 OMAP24XX_GPIO_IRQENABLE1);
1762 clk_enable(gpio5_fck); 1591 __raw_writel(0xffffffff, bank->base +
1592 OMAP24XX_GPIO_IRQSTATUS1);
1593 __raw_writel(0x00000000, bank->base +
1594 OMAP24XX_GPIO_DEBOUNCE_EN);
1595
1596 /* Initialize interface clk ungated, module enabled */
1597 __raw_writel(0, bank->base + OMAP24XX_GPIO_CTRL);
1598 } else if (cpu_is_omap24xx()) {
1599 static const u32 non_wakeup_gpios[] = {
1600 0xe203ffc0, 0x08700040
1601 };
1602 if (id < ARRAY_SIZE(non_wakeup_gpios))
1603 bank->non_wakeup_gpios = non_wakeup_gpios[id];
1763 } 1604 }
1764#endif 1605 } else if (cpu_class_is_omap1()) {
1765 } 1606 if (bank_is_mpuio(bank))
1766#endif 1607 __raw_writew(0xffff, bank->base +
1608 OMAP_MPUIO_GPIO_MASKIT / bank->stride);
1609 if (cpu_is_omap15xx() && bank->method == METHOD_GPIO_1510) {
1610 __raw_writew(0xffff, bank->base
1611 + OMAP1510_GPIO_INT_MASK);
1612 __raw_writew(0x0000, bank->base
1613 + OMAP1510_GPIO_INT_STATUS);
1614 }
1615 if (cpu_is_omap16xx() && bank->method == METHOD_GPIO_1610) {
1616 __raw_writew(0x0000, bank->base
1617 + OMAP1610_GPIO_IRQENABLE1);
1618 __raw_writew(0xffff, bank->base
1619 + OMAP1610_GPIO_IRQSTATUS1);
1620 __raw_writew(0x0014, bank->base
1621 + OMAP1610_GPIO_SYSCONFIG);
1767 1622
1768#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) 1623 /*
1769 if (cpu_is_omap34xx() || cpu_is_omap44xx()) { 1624 * Enable system clock for GPIO module.
1770 for (i = 0; i < OMAP34XX_NR_GPIOS; i++) { 1625 * The CAM_CLK_CTRL *is* really the right place.
1771 sprintf(clk_name, "gpio%d_ick", i + 1); 1626 */
1772 gpio_iclks[i] = clk_get(NULL, clk_name); 1627 omap_writel(omap_readl(ULPD_CAM_CLK_CTRL) | 0x04,
1773 if (IS_ERR(gpio_iclks[i])) 1628 ULPD_CAM_CLK_CTRL);
1774 printk(KERN_ERR "Could not get %s\n", clk_name); 1629 }
1775 else 1630 if (cpu_is_omap7xx() && bank->method == METHOD_GPIO_7XX) {
1776 clk_enable(gpio_iclks[i]); 1631 __raw_writel(0xffffffff, bank->base
1632 + OMAP7XX_GPIO_INT_MASK);
1633 __raw_writel(0x00000000, bank->base
1634 + OMAP7XX_GPIO_INT_STATUS);
1777 } 1635 }
1778 } 1636 }
1779#endif 1637}
1780 1638
1639static void __init omap_gpio_chip_init(struct gpio_bank *bank)
1640{
1641 int j;
1642 static int gpio;
1781 1643
1782#ifdef CONFIG_ARCH_OMAP15XX 1644 bank->mod_usage = 0;
1783 if (cpu_is_omap15xx()) { 1645 /*
1784 gpio_bank_count = 2; 1646 * REVISIT eventually switch from OMAP-specific gpio structs
1785 gpio_bank = gpio_bank_1510; 1647 * over to the generic ones
1786 bank_size = SZ_2K; 1648 */
1787 } 1649 bank->chip.request = omap_gpio_request;
1788#endif 1650 bank->chip.free = omap_gpio_free;
1789#if defined(CONFIG_ARCH_OMAP16XX) 1651 bank->chip.direction_input = gpio_input;
1790 if (cpu_is_omap16xx()) { 1652 bank->chip.get = gpio_get;
1791 gpio_bank_count = 5; 1653 bank->chip.direction_output = gpio_output;
1792 gpio_bank = gpio_bank_1610; 1654 bank->chip.set_debounce = gpio_debounce;
1793 bank_size = SZ_2K; 1655 bank->chip.set = gpio_set;
1794 } 1656 bank->chip.to_irq = gpio_2irq;
1795#endif 1657 if (bank_is_mpuio(bank)) {
1796#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850) 1658 bank->chip.label = "mpuio";
1797 if (cpu_is_omap7xx()) { 1659#ifdef CONFIG_ARCH_OMAP16XX
1798 gpio_bank_count = 7; 1660 bank->chip.dev = &omap_mpuio_device.dev;
1799 gpio_bank = gpio_bank_7xx;
1800 bank_size = SZ_2K;
1801 }
1802#endif
1803#ifdef CONFIG_ARCH_OMAP2
1804 if (cpu_is_omap242x()) {
1805 gpio_bank_count = 4;
1806 gpio_bank = gpio_bank_242x;
1807 }
1808 if (cpu_is_omap243x()) {
1809 gpio_bank_count = 5;
1810 gpio_bank = gpio_bank_243x;
1811 }
1812#endif 1661#endif
1813#ifdef CONFIG_ARCH_OMAP3 1662 bank->chip.base = OMAP_MPUIO(0);
1814 if (cpu_is_omap34xx()) { 1663 } else {
1815 gpio_bank_count = OMAP34XX_NR_GPIOS; 1664 bank->chip.label = "gpio";
1816 gpio_bank = gpio_bank_34xx; 1665 bank->chip.base = gpio;
1666 gpio += bank_width;
1817 } 1667 }
1818#endif 1668 bank->chip.ngpio = bank_width;
1819#ifdef CONFIG_ARCH_OMAP4 1669
1820 if (cpu_is_omap44xx()) { 1670 gpiochip_add(&bank->chip);
1821 gpio_bank_count = OMAP34XX_NR_GPIOS; 1671
1822 gpio_bank = gpio_bank_44xx; 1672 for (j = bank->virtual_irq_start;
1673 j < bank->virtual_irq_start + bank_width; j++) {
1674 lockdep_set_class(&irq_desc[j].lock, &gpio_lock_class);
1675 set_irq_chip_data(j, bank);
1676 if (bank_is_mpuio(bank))
1677 set_irq_chip(j, &mpuio_irq_chip);
1678 else
1679 set_irq_chip(j, &gpio_irq_chip);
1680 set_irq_handler(j, handle_simple_irq);
1681 set_irq_flags(j, IRQF_VALID);
1823 } 1682 }
1824#endif 1683 set_irq_chained_handler(bank->irq, gpio_irq_handler);
1825 for (i = 0; i < gpio_bank_count; i++) { 1684 set_irq_data(bank->irq, bank);
1826 int j, gpio_count = 16; 1685}
1686
1687static int __devinit omap_gpio_probe(struct platform_device *pdev)
1688{
1689 static int gpio_init_done;
1690 struct omap_gpio_platform_data *pdata;
1691 struct resource *res;
1692 int id;
1693 struct gpio_bank *bank;
1827 1694
1828 bank = &gpio_bank[i]; 1695 if (!pdev->dev.platform_data)
1829 spin_lock_init(&bank->lock); 1696 return -EINVAL;
1830 1697
1831 /* Static mapping, never released */ 1698 pdata = pdev->dev.platform_data;
1832 bank->base = ioremap(bank->pbase, bank_size);
1833 if (!bank->base) {
1834 printk(KERN_ERR "Could not ioremap gpio bank%i\n", i);
1835 continue;
1836 }
1837 1699
1838 if (bank_is_mpuio(bank)) 1700 if (!gpio_init_done) {
1839 __raw_writew(0xffff, bank->base + OMAP_MPUIO_GPIO_MASKIT); 1701 int ret;
1840 if (cpu_is_omap15xx() && bank->method == METHOD_GPIO_1510) {
1841 __raw_writew(0xffff, bank->base + OMAP1510_GPIO_INT_MASK);
1842 __raw_writew(0x0000, bank->base + OMAP1510_GPIO_INT_STATUS);
1843 }
1844 if (cpu_is_omap16xx() && bank->method == METHOD_GPIO_1610) {
1845 __raw_writew(0x0000, bank->base + OMAP1610_GPIO_IRQENABLE1);
1846 __raw_writew(0xffff, bank->base + OMAP1610_GPIO_IRQSTATUS1);
1847 __raw_writew(0x0014, bank->base + OMAP1610_GPIO_SYSCONFIG);
1848 }
1849 if (cpu_is_omap7xx() && bank->method == METHOD_GPIO_7XX) {
1850 __raw_writel(0xffffffff, bank->base + OMAP7XX_GPIO_INT_MASK);
1851 __raw_writel(0x00000000, bank->base + OMAP7XX_GPIO_INT_STATUS);
1852 1702
1853 gpio_count = 32; /* 7xx has 32-bit GPIOs */ 1703 ret = init_gpio_info(pdev);
1854 } 1704 if (ret)
1705 return ret;
1706 }
1855 1707
1856#ifdef CONFIG_ARCH_OMAP2PLUS 1708 id = pdev->id;
1857 if ((bank->method == METHOD_GPIO_24XX) || 1709 bank = &gpio_bank[id];
1858 (bank->method == METHOD_GPIO_44XX)) {
1859 static const u32 non_wakeup_gpios[] = {
1860 0xe203ffc0, 0x08700040
1861 };
1862 1710
1863 if (cpu_is_omap44xx()) { 1711 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1864 __raw_writel(0xffffffff, bank->base + 1712 if (unlikely(!res)) {
1865 OMAP4_GPIO_IRQSTATUSCLR0); 1713 dev_err(&pdev->dev, "GPIO Bank %i Invalid IRQ resource\n", id);
1866 __raw_writew(0x0015, bank->base + 1714 return -ENODEV;
1867 OMAP4_GPIO_SYSCONFIG); 1715 }
1868 __raw_writel(0x00000000, bank->base +
1869 OMAP4_GPIO_DEBOUNCENABLE);
1870 /*
1871 * Initialize interface clock ungated,
1872 * module enabled
1873 */
1874 __raw_writel(0, bank->base + OMAP4_GPIO_CTRL);
1875 } else {
1876 __raw_writel(0x00000000, bank->base +
1877 OMAP24XX_GPIO_IRQENABLE1);
1878 __raw_writel(0xffffffff, bank->base +
1879 OMAP24XX_GPIO_IRQSTATUS1);
1880 __raw_writew(0x0015, bank->base +
1881 OMAP24XX_GPIO_SYSCONFIG);
1882 __raw_writel(0x00000000, bank->base +
1883 OMAP24XX_GPIO_DEBOUNCE_EN);
1884
1885 /*
1886 * Initialize interface clock ungated,
1887 * module enabled
1888 */
1889 __raw_writel(0, bank->base +
1890 OMAP24XX_GPIO_CTRL);
1891 }
1892 if (cpu_is_omap24xx() &&
1893 i < ARRAY_SIZE(non_wakeup_gpios))
1894 bank->non_wakeup_gpios = non_wakeup_gpios[i];
1895 gpio_count = 32;
1896 }
1897#endif
1898 1716
1899 bank->mod_usage = 0; 1717 bank->irq = res->start;
1900 /* REVISIT eventually switch from OMAP-specific gpio structs 1718 bank->virtual_irq_start = pdata->virtual_irq_start;
1901 * over to the generic ones 1719 bank->method = pdata->bank_type;
1902 */ 1720 bank->dev = &pdev->dev;
1903 bank->chip.request = omap_gpio_request; 1721 bank->dbck_flag = pdata->dbck_flag;
1904 bank->chip.free = omap_gpio_free; 1722 bank->stride = pdata->bank_stride;
1905 bank->chip.direction_input = gpio_input; 1723 bank_width = pdata->bank_width;
1906 bank->chip.get = gpio_get;
1907 bank->chip.direction_output = gpio_output;
1908 bank->chip.set_debounce = gpio_debounce;
1909 bank->chip.set = gpio_set;
1910 bank->chip.to_irq = gpio_2irq;
1911 if (bank_is_mpuio(bank)) {
1912 bank->chip.label = "mpuio";
1913#ifdef CONFIG_ARCH_OMAP16XX
1914 bank->chip.dev = &omap_mpuio_device.dev;
1915#endif
1916 bank->chip.base = OMAP_MPUIO(0);
1917 } else {
1918 bank->chip.label = "gpio";
1919 bank->chip.base = gpio;
1920 gpio += gpio_count;
1921 }
1922 bank->chip.ngpio = gpio_count;
1923 1724
1924 gpiochip_add(&bank->chip); 1725 spin_lock_init(&bank->lock);
1925 1726
1926 for (j = bank->virtual_irq_start; 1727 /* Static mapping, never released */
1927 j < bank->virtual_irq_start + gpio_count; j++) { 1728 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1928 lockdep_set_class(&irq_desc[j].lock, &gpio_lock_class); 1729 if (unlikely(!res)) {
1929 set_irq_chip_data(j, bank); 1730 dev_err(&pdev->dev, "GPIO Bank %i Invalid mem resource\n", id);
1930 if (bank_is_mpuio(bank)) 1731 return -ENODEV;
1931 set_irq_chip(j, &mpuio_irq_chip);
1932 else
1933 set_irq_chip(j, &gpio_irq_chip);
1934 set_irq_handler(j, handle_simple_irq);
1935 set_irq_flags(j, IRQF_VALID);
1936 }
1937 set_irq_chained_handler(bank->irq, gpio_irq_handler);
1938 set_irq_data(bank->irq, bank);
1939
1940 if (cpu_is_omap34xx() || cpu_is_omap44xx()) {
1941 sprintf(clk_name, "gpio%d_dbck", i + 1);
1942 bank->dbck = clk_get(NULL, clk_name);
1943 if (IS_ERR(bank->dbck))
1944 printk(KERN_ERR "Could not get %s\n", clk_name);
1945 }
1946 } 1732 }
1947 1733
1948 /* Enable system clock for GPIO module. 1734 bank->base = ioremap(res->start, resource_size(res));
1949 * The CAM_CLK_CTRL *is* really the right place. */ 1735 if (!bank->base) {
1950 if (cpu_is_omap16xx()) 1736 dev_err(&pdev->dev, "Could not ioremap gpio bank%i\n", id);
1951 omap_writel(omap_readl(ULPD_CAM_CLK_CTRL) | 0x04, ULPD_CAM_CLK_CTRL); 1737 return -ENOMEM;
1738 }
1952 1739
1953 /* Enable autoidle for the OCP interface */ 1740 pm_runtime_enable(bank->dev);
1954 if (cpu_is_omap24xx()) 1741 pm_runtime_get_sync(bank->dev);
1955 omap_writel(1 << 0, 0x48019010); 1742
1956 if (cpu_is_omap34xx()) 1743 omap_gpio_mod_init(bank, id);
1957 omap_writel(1 << 0, 0x48306814); 1744 omap_gpio_chip_init(bank);
1745 omap_gpio_show_rev(bank);
1958 1746
1959 omap_gpio_show_rev(); 1747 if (!gpio_init_done)
1748 gpio_init_done = 1;
1960 1749
1961 return 0; 1750 return 0;
1962} 1751}
@@ -2074,7 +1863,7 @@ static struct sys_device omap_gpio_device = {
2074 1863
2075static int workaround_enabled; 1864static int workaround_enabled;
2076 1865
2077void omap2_gpio_prepare_for_idle(int power_state) 1866void omap2_gpio_prepare_for_idle(int off_mode)
2078{ 1867{
2079 int i, c = 0; 1868 int i, c = 0;
2080 int min = 0; 1869 int min = 0;
@@ -2090,7 +1879,7 @@ void omap2_gpio_prepare_for_idle(int power_state)
2090 for (j = 0; j < hweight_long(bank->dbck_enable_mask); j++) 1879 for (j = 0; j < hweight_long(bank->dbck_enable_mask); j++)
2091 clk_disable(bank->dbck); 1880 clk_disable(bank->dbck);
2092 1881
2093 if (power_state > PWRDM_POWER_OFF) 1882 if (!off_mode)
2094 continue; 1883 continue;
2095 1884
2096 /* If going to OFF, remove triggering for all 1885 /* If going to OFF, remove triggering for all
@@ -2251,8 +2040,6 @@ void omap_gpio_save_context(void)
2251 /* saving banks from 2-6 only since GPIO1 is in WKUP */ 2040 /* saving banks from 2-6 only since GPIO1 is in WKUP */
2252 for (i = 1; i < gpio_bank_count; i++) { 2041 for (i = 1; i < gpio_bank_count; i++) {
2253 struct gpio_bank *bank = &gpio_bank[i]; 2042 struct gpio_bank *bank = &gpio_bank[i];
2254 gpio_context[i].sysconfig =
2255 __raw_readl(bank->base + OMAP24XX_GPIO_SYSCONFIG);
2256 gpio_context[i].irqenable1 = 2043 gpio_context[i].irqenable1 =
2257 __raw_readl(bank->base + OMAP24XX_GPIO_IRQENABLE1); 2044 __raw_readl(bank->base + OMAP24XX_GPIO_IRQENABLE1);
2258 gpio_context[i].irqenable2 = 2045 gpio_context[i].irqenable2 =
@@ -2283,8 +2070,6 @@ void omap_gpio_restore_context(void)
2283 2070
2284 for (i = 1; i < gpio_bank_count; i++) { 2071 for (i = 1; i < gpio_bank_count; i++) {
2285 struct gpio_bank *bank = &gpio_bank[i]; 2072 struct gpio_bank *bank = &gpio_bank[i];
2286 __raw_writel(gpio_context[i].sysconfig,
2287 bank->base + OMAP24XX_GPIO_SYSCONFIG);
2288 __raw_writel(gpio_context[i].irqenable1, 2073 __raw_writel(gpio_context[i].irqenable1,
2289 bank->base + OMAP24XX_GPIO_IRQENABLE1); 2074 bank->base + OMAP24XX_GPIO_IRQENABLE1);
2290 __raw_writel(gpio_context[i].irqenable2, 2075 __raw_writel(gpio_context[i].irqenable2,
@@ -2309,25 +2094,28 @@ void omap_gpio_restore_context(void)
2309} 2094}
2310#endif 2095#endif
2311 2096
2097static struct platform_driver omap_gpio_driver = {
2098 .probe = omap_gpio_probe,
2099 .driver = {
2100 .name = "omap_gpio",
2101 },
2102};
2103
2312/* 2104/*
2313 * This may get called early from board specific init 2105 * gpio driver register needs to be done before
2314 * for boards that have interrupts routed via FPGA. 2106 * machine_init functions access gpio APIs.
2107 * Hence omap_gpio_drv_reg() is a postcore_initcall.
2315 */ 2108 */
2316int __init omap_gpio_init(void) 2109static int __init omap_gpio_drv_reg(void)
2317{ 2110{
2318 if (!initialized) 2111 return platform_driver_register(&omap_gpio_driver);
2319 return _omap_gpio_init();
2320 else
2321 return 0;
2322} 2112}
2113postcore_initcall(omap_gpio_drv_reg);
2323 2114
2324static int __init omap_gpio_sysinit(void) 2115static int __init omap_gpio_sysinit(void)
2325{ 2116{
2326 int ret = 0; 2117 int ret = 0;
2327 2118
2328 if (!initialized)
2329 ret = _omap_gpio_init();
2330
2331 mpuio_init(); 2119 mpuio_init();
2332 2120
2333#if defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP2PLUS) 2121#if defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP2PLUS)
diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index a5ce4f0aad35..a4f8003de664 100644
--- a/arch/arm/plat-omap/i2c.c
+++ b/arch/arm/plat-omap/i2c.c
@@ -27,20 +27,20 @@
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/i2c-omap.h> 29#include <linux/i2c-omap.h>
30#include <linux/slab.h>
31#include <linux/err.h>
32#include <linux/clk.h>
30 33
31#include <mach/irqs.h> 34#include <mach/irqs.h>
32#include <plat/mux.h> 35#include <plat/mux.h>
33#include <plat/i2c.h> 36#include <plat/i2c.h>
34#include <plat/omap-pm.h> 37#include <plat/omap-pm.h>
38#include <plat/omap_device.h>
35 39
36#define OMAP_I2C_SIZE 0x3f 40#define OMAP_I2C_SIZE 0x3f
37#define OMAP1_I2C_BASE 0xfffb3800 41#define OMAP1_I2C_BASE 0xfffb3800
38#define OMAP2_I2C_BASE1 0x48070000
39#define OMAP2_I2C_BASE2 0x48072000
40#define OMAP2_I2C_BASE3 0x48060000
41#define OMAP4_I2C_BASE4 0x48350000
42 42
43static const char name[] = "i2c_omap"; 43static const char name[] = "omap_i2c";
44 44
45#define I2C_RESOURCE_BUILDER(base, irq) \ 45#define I2C_RESOURCE_BUILDER(base, irq) \
46 { \ 46 { \
@@ -55,15 +55,6 @@ static const char name[] = "i2c_omap";
55 55
56static struct resource i2c_resources[][2] = { 56static struct resource i2c_resources[][2] = {
57 { I2C_RESOURCE_BUILDER(0, 0) }, 57 { I2C_RESOURCE_BUILDER(0, 0) },
58#if defined(CONFIG_ARCH_OMAP2PLUS)
59 { I2C_RESOURCE_BUILDER(OMAP2_I2C_BASE2, 0) },
60#endif
61#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
62 { I2C_RESOURCE_BUILDER(OMAP2_I2C_BASE3, 0) },
63#endif
64#if defined(CONFIG_ARCH_OMAP4)
65 { I2C_RESOURCE_BUILDER(OMAP4_I2C_BASE4, 0) },
66#endif
67}; 58};
68 59
69#define I2C_DEV_BUILDER(bus_id, res, data) \ 60#define I2C_DEV_BUILDER(bus_id, res, data) \
@@ -77,18 +68,11 @@ static struct resource i2c_resources[][2] = {
77 }, \ 68 }, \
78 } 69 }
79 70
80static struct omap_i2c_bus_platform_data i2c_pdata[ARRAY_SIZE(i2c_resources)]; 71#define MAX_OMAP_I2C_HWMOD_NAME_LEN 16
72#define OMAP_I2C_MAX_CONTROLLERS 4
73static struct omap_i2c_bus_platform_data i2c_pdata[OMAP_I2C_MAX_CONTROLLERS];
81static struct platform_device omap_i2c_devices[] = { 74static struct platform_device omap_i2c_devices[] = {
82 I2C_DEV_BUILDER(1, i2c_resources[0], &i2c_pdata[0]), 75 I2C_DEV_BUILDER(1, i2c_resources[0], &i2c_pdata[0]),
83#if defined(CONFIG_ARCH_OMAP2PLUS)
84 I2C_DEV_BUILDER(2, i2c_resources[1], &i2c_pdata[1]),
85#endif
86#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
87 I2C_DEV_BUILDER(3, i2c_resources[2], &i2c_pdata[2]),
88#endif
89#if defined(CONFIG_ARCH_OMAP4)
90 I2C_DEV_BUILDER(4, i2c_resources[3], &i2c_pdata[3]),
91#endif
92}; 76};
93 77
94#define OMAP_I2C_CMDLINE_SETUP (BIT(31)) 78#define OMAP_I2C_CMDLINE_SETUP (BIT(31))
@@ -109,35 +93,25 @@ static int __init omap_i2c_nr_ports(void)
109 return ports; 93 return ports;
110} 94}
111 95
112/* Shared between omap2 and 3 */ 96static inline int omap1_i2c_add_bus(int bus_id)
113static resource_size_t omap2_i2c_irq[3] __initdata = {
114 INT_24XX_I2C1_IRQ,
115 INT_24XX_I2C2_IRQ,
116 INT_34XX_I2C3_IRQ,
117};
118
119static resource_size_t omap4_i2c_irq[4] __initdata = {
120 OMAP44XX_IRQ_I2C1,
121 OMAP44XX_IRQ_I2C2,
122 OMAP44XX_IRQ_I2C3,
123 OMAP44XX_IRQ_I2C4,
124};
125
126static inline int omap1_i2c_add_bus(struct platform_device *pdev, int bus_id)
127{ 97{
128 struct omap_i2c_bus_platform_data *pd; 98 struct platform_device *pdev;
99 struct omap_i2c_bus_platform_data *pdata;
129 struct resource *res; 100 struct resource *res;
130 101
131 pd = pdev->dev.platform_data; 102 omap1_i2c_mux_pins(bus_id);
103
104 pdev = &omap_i2c_devices[bus_id - 1];
132 res = pdev->resource; 105 res = pdev->resource;
133 res[0].start = OMAP1_I2C_BASE; 106 res[0].start = OMAP1_I2C_BASE;
134 res[0].end = res[0].start + OMAP_I2C_SIZE; 107 res[0].end = res[0].start + OMAP_I2C_SIZE;
135 res[1].start = INT_I2C; 108 res[1].start = INT_I2C;
136 omap1_i2c_mux_pins(bus_id); 109 pdata = &i2c_pdata[bus_id - 1];
137 110
138 return platform_device_register(pdev); 111 return platform_device_register(pdev);
139} 112}
140 113
114
141/* 115/*
142 * XXX This function is a temporary compatibility wrapper - only 116 * XXX This function is a temporary compatibility wrapper - only
143 * needed until the I2C driver can be converted to call 117 * needed until the I2C driver can be converted to call
@@ -148,52 +122,64 @@ static void omap_pm_set_max_mpu_wakeup_lat_compat(struct device *dev, long t)
148 omap_pm_set_max_mpu_wakeup_lat(dev, t); 122 omap_pm_set_max_mpu_wakeup_lat(dev, t);
149} 123}
150 124
151static inline int omap2_i2c_add_bus(struct platform_device *pdev, int bus_id) 125static struct omap_device_pm_latency omap_i2c_latency[] = {
152{ 126 [0] = {
153 struct resource *res; 127 .deactivate_func = omap_device_idle_hwmods,
154 resource_size_t *irq; 128 .activate_func = omap_device_enable_hwmods,
129 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
130 },
131};
155 132
156 res = pdev->resource; 133#ifdef CONFIG_ARCH_OMAP2PLUS
134static inline int omap2_i2c_add_bus(int bus_id)
135{
136 int l;
137 struct omap_hwmod *oh;
138 struct omap_device *od;
139 char oh_name[MAX_OMAP_I2C_HWMOD_NAME_LEN];
140 struct omap_i2c_bus_platform_data *pdata;
157 141
158 if (!cpu_is_omap44xx()) 142 omap2_i2c_mux_pins(bus_id);
159 irq = omap2_i2c_irq;
160 else
161 irq = omap4_i2c_irq;
162 143
163 if (bus_id == 1) { 144 l = snprintf(oh_name, MAX_OMAP_I2C_HWMOD_NAME_LEN, "i2c%d", bus_id);
164 res[0].start = OMAP2_I2C_BASE1; 145 WARN(l >= MAX_OMAP_I2C_HWMOD_NAME_LEN,
165 res[0].end = res[0].start + OMAP_I2C_SIZE; 146 "String buffer overflow in I2C%d device setup\n", bus_id);
147 oh = omap_hwmod_lookup(oh_name);
148 if (!oh) {
149 pr_err("Could not look up %s\n", oh_name);
150 return -EEXIST;
166 } 151 }
167 152
168 res[1].start = irq[bus_id - 1]; 153 pdata = &i2c_pdata[bus_id - 1];
169 omap2_i2c_mux_pins(bus_id);
170
171 /* 154 /*
172 * When waiting for completion of a i2c transfer, we need to 155 * When waiting for completion of a i2c transfer, we need to
173 * set a wake up latency constraint for the MPU. This is to 156 * set a wake up latency constraint for the MPU. This is to
174 * ensure quick enough wakeup from idle, when transfer 157 * ensure quick enough wakeup from idle, when transfer
175 * completes. 158 * completes.
159 * Only omap3 has support for constraints
176 */ 160 */
177 if (cpu_is_omap34xx()) { 161 if (cpu_is_omap34xx())
178 struct omap_i2c_bus_platform_data *pd; 162 pdata->set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat;
179 163 od = omap_device_build(name, bus_id, oh, pdata,
180 pd = pdev->dev.platform_data; 164 sizeof(struct omap_i2c_bus_platform_data),
181 pd->set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat; 165 omap_i2c_latency, ARRAY_SIZE(omap_i2c_latency), 0);
182 } 166 WARN(IS_ERR(od), "Could not build omap_device for %s\n", name);
183 167
184 return platform_device_register(pdev); 168 return PTR_ERR(od);
185} 169}
170#else
171static inline int omap2_i2c_add_bus(int bus_id)
172{
173 return 0;
174}
175#endif
186 176
187static int __init omap_i2c_add_bus(int bus_id) 177static int __init omap_i2c_add_bus(int bus_id)
188{ 178{
189 struct platform_device *pdev;
190
191 pdev = &omap_i2c_devices[bus_id - 1];
192
193 if (cpu_class_is_omap1()) 179 if (cpu_class_is_omap1())
194 return omap1_i2c_add_bus(pdev, bus_id); 180 return omap1_i2c_add_bus(bus_id);
195 else 181 else
196 return omap2_i2c_add_bus(pdev, bus_id); 182 return omap2_i2c_add_bus(bus_id);
197} 183}
198 184
199/** 185/**
diff --git a/arch/arm/plat-omap/include/plat/clkdev_omap.h b/arch/arm/plat-omap/include/plat/clkdev_omap.h
index 4b2028ab4d2b..256ab3f1ec8f 100644
--- a/arch/arm/plat-omap/include/plat/clkdev_omap.h
+++ b/arch/arm/plat-omap/include/plat/clkdev_omap.h
@@ -31,18 +31,18 @@ struct omap_clk {
31#define CK_1510 (1 << 2) 31#define CK_1510 (1 << 2)
32#define CK_16XX (1 << 3) /* 16xx, 17xx, 5912 */ 32#define CK_16XX (1 << 3) /* 16xx, 17xx, 5912 */
33#define CK_242X (1 << 4) 33#define CK_242X (1 << 4)
34#define CK_243X (1 << 5) 34#define CK_243X (1 << 5) /* 243x, 253x */
35#define CK_3XXX (1 << 6) /* OMAP3 + AM3 common clocks*/ 35#define CK_3430ES1 (1 << 6) /* 34xxES1 only */
36#define CK_343X (1 << 7) /* OMAP34xx common clocks */ 36#define CK_3430ES2PLUS (1 << 7) /* 34xxES2, ES3, non-Sitara 35xx only */
37#define CK_3430ES1 (1 << 8) /* 34xxES1 only */ 37#define CK_3505 (1 << 8)
38#define CK_3430ES2 (1 << 9) /* 34xxES2, ES3, non-Sitara 35xx only */ 38#define CK_3517 (1 << 9)
39#define CK_3505 (1 << 10) 39#define CK_36XX (1 << 10) /* 36xx/37xx-specific clocks */
40#define CK_3517 (1 << 11) 40#define CK_443X (1 << 11)
41#define CK_36XX (1 << 12) /* OMAP36xx/37xx-specific clocks */
42#define CK_443X (1 << 13)
43 41
44#define CK_AM35XX (CK_3505 | CK_3517) /* all Sitara AM35xx */
45 42
43#define CK_34XX (CK_3430ES1 | CK_3430ES2PLUS)
44#define CK_AM35XX (CK_3505 | CK_3517) /* all Sitara AM35xx */
45#define CK_3XXX (CK_34XX | CK_AM35XX | CK_36XX)
46 46
47 47
48#endif 48#endif
diff --git a/arch/arm/plat-omap/include/plat/clock.h b/arch/arm/plat-omap/include/plat/clock.h
index fef4696dcf67..8eb0adab19ea 100644
--- a/arch/arm/plat-omap/include/plat/clock.h
+++ b/arch/arm/plat-omap/include/plat/clock.h
@@ -49,13 +49,18 @@ struct clkops {
49/* struct clksel_rate.flags possibilities */ 49/* struct clksel_rate.flags possibilities */
50#define RATE_IN_242X (1 << 0) 50#define RATE_IN_242X (1 << 0)
51#define RATE_IN_243X (1 << 1) 51#define RATE_IN_243X (1 << 1)
52#define RATE_IN_3XXX (1 << 2) /* rates common to all OMAP3 */ 52#define RATE_IN_3430ES1 (1 << 2) /* 3430ES1 rates only */
53#define RATE_IN_3430ES2 (1 << 3) /* 3430ES2 rates only */ 53#define RATE_IN_3430ES2PLUS (1 << 3) /* 3430 ES >= 2 rates only */
54#define RATE_IN_36XX (1 << 4) 54#define RATE_IN_36XX (1 << 4)
55#define RATE_IN_4430 (1 << 5) 55#define RATE_IN_4430 (1 << 5)
56 56
57#define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X) 57#define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X)
58#define RATE_IN_3430ES2PLUS (RATE_IN_3430ES2 | RATE_IN_36XX) 58#define RATE_IN_34XX (RATE_IN_3430ES1 | RATE_IN_3430ES2PLUS)
59#define RATE_IN_3XXX (RATE_IN_34XX | RATE_IN_36XX)
60
61/* RATE_IN_3430ES2PLUS_36XX includes 34xx/35xx with ES >=2, and all 36xx/37xx */
62#define RATE_IN_3430ES2PLUS_36XX (RATE_IN_3430ES2PLUS | RATE_IN_36XX)
63
59 64
60/** 65/**
61 * struct clksel_rate - register bitfield values corresponding to clk divisors 66 * struct clksel_rate - register bitfield values corresponding to clk divisors
@@ -119,8 +124,7 @@ struct clksel {
119 * 124 *
120 * Possible values for @flags: 125 * Possible values for @flags:
121 * DPLL_J_TYPE: "J-type DPLL" (only some 36xx, 4xxx DPLLs) 126 * DPLL_J_TYPE: "J-type DPLL" (only some 36xx, 4xxx DPLLs)
122 * NO_DCO_SEL: don't program DCO (only for some J-type DPLLs) 127 *
123
124 * @freqsel_mask is only used on the OMAP34xx family and AM35xx. 128 * @freqsel_mask is only used on the OMAP34xx family and AM35xx.
125 * 129 *
126 * XXX Some DPLLs have multiple bypass inputs, so it's not technically 130 * XXX Some DPLLs have multiple bypass inputs, so it's not technically
@@ -156,6 +160,8 @@ struct dpll_data {
156 u32 autoidle_mask; 160 u32 autoidle_mask;
157 u32 freqsel_mask; 161 u32 freqsel_mask;
158 u32 idlest_mask; 162 u32 idlest_mask;
163 u32 dco_mask;
164 u32 sddiv_mask;
159 u8 auto_recal_bit; 165 u8 auto_recal_bit;
160 u8 recal_en_bit; 166 u8 recal_en_bit;
161 u8 recal_st_bit; 167 u8 recal_st_bit;
diff --git a/arch/arm/plat-omap/include/plat/clockdomain.h b/arch/arm/plat-omap/include/plat/clockdomain.h
deleted file mode 100644
index ba0a6c07c0fe..000000000000
--- a/arch/arm/plat-omap/include/plat/clockdomain.h
+++ /dev/null
@@ -1,141 +0,0 @@
1/*
2 * arch/arm/plat-omap/include/mach/clockdomain.h
3 *
4 * OMAP2/3 clockdomain framework functions
5 *
6 * Copyright (C) 2008 Texas Instruments, Inc.
7 * Copyright (C) 2008-2009 Nokia Corporation
8 *
9 * Written by Paul Walmsley
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#ifndef __ASM_ARM_ARCH_OMAP_CLOCKDOMAIN_H
17#define __ASM_ARM_ARCH_OMAP_CLOCKDOMAIN_H
18
19#include <plat/powerdomain.h>
20#include <plat/clock.h>
21#include <plat/cpu.h>
22
23/* Clockdomain capability flags */
24#define CLKDM_CAN_FORCE_SLEEP (1 << 0)
25#define CLKDM_CAN_FORCE_WAKEUP (1 << 1)
26#define CLKDM_CAN_ENABLE_AUTO (1 << 2)
27#define CLKDM_CAN_DISABLE_AUTO (1 << 3)
28
29#define CLKDM_CAN_HWSUP (CLKDM_CAN_ENABLE_AUTO | CLKDM_CAN_DISABLE_AUTO)
30#define CLKDM_CAN_SWSUP (CLKDM_CAN_FORCE_SLEEP | CLKDM_CAN_FORCE_WAKEUP)
31#define CLKDM_CAN_HWSUP_SWSUP (CLKDM_CAN_SWSUP | CLKDM_CAN_HWSUP)
32
33/* OMAP24XX CM_CLKSTCTRL_*.AUTOSTATE_* register bit values */
34#define OMAP24XX_CLKSTCTRL_DISABLE_AUTO 0x0
35#define OMAP24XX_CLKSTCTRL_ENABLE_AUTO 0x1
36
37/* OMAP3XXX CM_CLKSTCTRL_*.CLKTRCTRL_* register bit values */
38#define OMAP34XX_CLKSTCTRL_DISABLE_AUTO 0x0
39#define OMAP34XX_CLKSTCTRL_FORCE_SLEEP 0x1
40#define OMAP34XX_CLKSTCTRL_FORCE_WAKEUP 0x2
41#define OMAP34XX_CLKSTCTRL_ENABLE_AUTO 0x3
42
43/**
44 * struct clkdm_autodep - clkdm deps to add when entering/exiting hwsup mode
45 * @clkdm: clockdomain to add wkdep+sleepdep on - set name member only
46 * @omap_chip: OMAP chip types that this autodep is valid on
47 *
48 * A clockdomain that should have wkdeps and sleepdeps added when a
49 * clockdomain should stay active in hwsup mode; and conversely,
50 * removed when the clockdomain should be allowed to go inactive in
51 * hwsup mode.
52 *
53 * Autodeps are deprecated and should be removed after
54 * omap_hwmod-based fine-grained module idle control is added.
55 */
56struct clkdm_autodep {
57 union {
58 const char *name;
59 struct clockdomain *ptr;
60 } clkdm;
61 const struct omap_chip_id omap_chip;
62};
63
64/**
65 * struct clkdm_dep - encode dependencies between clockdomains
66 * @clkdm_name: clockdomain name
67 * @clkdm: pointer to the struct clockdomain of @clkdm_name
68 * @omap_chip: OMAP chip types that this dependency is valid on
69 * @wkdep_usecount: Number of wakeup dependencies causing this clkdm to wake
70 * @sleepdep_usecount: Number of sleep deps that could prevent clkdm from idle
71 *
72 * Statically defined. @clkdm is resolved from @clkdm_name at runtime and
73 * should not be pre-initialized.
74 *
75 * XXX Should also include hardware (fixed) dependencies.
76 */
77struct clkdm_dep {
78 const char *clkdm_name;
79 struct clockdomain *clkdm;
80 atomic_t wkdep_usecount;
81 atomic_t sleepdep_usecount;
82 const struct omap_chip_id omap_chip;
83};
84
85/**
86 * struct clockdomain - OMAP clockdomain
87 * @name: clockdomain name
88 * @pwrdm: powerdomain containing this clockdomain
89 * @clktrctrl_reg: CLKSTCTRL reg for the given clock domain
90 * @clktrctrl_mask: CLKTRCTRL/AUTOSTATE field mask in CM_CLKSTCTRL reg
91 * @flags: Clockdomain capability flags
92 * @dep_bit: Bit shift of this clockdomain's PM_WKDEP/CM_SLEEPDEP bit
93 * @wkdep_srcs: Clockdomains that can be told to wake this powerdomain up
94 * @sleepdep_srcs: Clockdomains that can be told to keep this clkdm from inact
95 * @omap_chip: OMAP chip types that this clockdomain is valid on
96 * @usecount: Usecount tracking
97 * @node: list_head to link all clockdomains together
98 */
99struct clockdomain {
100 const char *name;
101 union {
102 const char *name;
103 struct powerdomain *ptr;
104 } pwrdm;
105 void __iomem *clkstctrl_reg;
106 const u16 clktrctrl_mask;
107 const u8 flags;
108 const u8 dep_bit;
109 struct clkdm_dep *wkdep_srcs;
110 struct clkdm_dep *sleepdep_srcs;
111 const struct omap_chip_id omap_chip;
112 atomic_t usecount;
113 struct list_head node;
114};
115
116void clkdm_init(struct clockdomain **clkdms, struct clkdm_autodep *autodeps);
117struct clockdomain *clkdm_lookup(const char *name);
118
119int clkdm_for_each(int (*fn)(struct clockdomain *clkdm, void *user),
120 void *user);
121struct powerdomain *clkdm_get_pwrdm(struct clockdomain *clkdm);
122
123int clkdm_add_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
124int clkdm_del_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
125int clkdm_read_wkdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
126int clkdm_clear_all_wkdeps(struct clockdomain *clkdm);
127int clkdm_add_sleepdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
128int clkdm_del_sleepdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
129int clkdm_read_sleepdep(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
130int clkdm_clear_all_sleepdeps(struct clockdomain *clkdm);
131
132void omap2_clkdm_allow_idle(struct clockdomain *clkdm);
133void omap2_clkdm_deny_idle(struct clockdomain *clkdm);
134
135int omap2_clkdm_wakeup(struct clockdomain *clkdm);
136int omap2_clkdm_sleep(struct clockdomain *clkdm);
137
138int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk);
139int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk);
140
141#endif
diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-omap/include/plat/common.h
index a9d69a09920d..6b8088ec74af 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -27,6 +27,8 @@
27#ifndef __ARCH_ARM_MACH_OMAP_COMMON_H 27#ifndef __ARCH_ARM_MACH_OMAP_COMMON_H
28#define __ARCH_ARM_MACH_OMAP_COMMON_H 28#define __ARCH_ARM_MACH_OMAP_COMMON_H
29 29
30#include <linux/delay.h>
31
30#include <plat/i2c.h> 32#include <plat/i2c.h>
31 33
32struct sys_timer; 34struct sys_timer;
diff --git a/arch/arm/plat-omap/include/plat/dma.h b/arch/arm/plat-omap/include/plat/dma.h
index 0cce4ca83aa0..d1c916fcf770 100644
--- a/arch/arm/plat-omap/include/plat/dma.h
+++ b/arch/arm/plat-omap/include/plat/dma.h
@@ -21,141 +21,15 @@
21#ifndef __ASM_ARCH_DMA_H 21#ifndef __ASM_ARCH_DMA_H
22#define __ASM_ARCH_DMA_H 22#define __ASM_ARCH_DMA_H
23 23
24/* Move omap4 specific defines to dma-44xx.h */ 24#include <linux/platform_device.h>
25#include "dma-44xx.h"
26 25
27/* Hardware registers for omap1 */ 26/*
28#define OMAP1_DMA_BASE (0xfffed800) 27 * TODO: These dma channel defines should go away once all
29 28 * the omap drivers hwmod adapted.
30#define OMAP1_DMA_GCR 0x400 29 */
31#define OMAP1_DMA_GSCR 0x404
32#define OMAP1_DMA_GRST 0x408
33#define OMAP1_DMA_HW_ID 0x442
34#define OMAP1_DMA_PCH2_ID 0x444
35#define OMAP1_DMA_PCH0_ID 0x446
36#define OMAP1_DMA_PCH1_ID 0x448
37#define OMAP1_DMA_PCHG_ID 0x44a
38#define OMAP1_DMA_PCHD_ID 0x44c
39#define OMAP1_DMA_CAPS_0_U 0x44e
40#define OMAP1_DMA_CAPS_0_L 0x450
41#define OMAP1_DMA_CAPS_1_U 0x452
42#define OMAP1_DMA_CAPS_1_L 0x454
43#define OMAP1_DMA_CAPS_2 0x456
44#define OMAP1_DMA_CAPS_3 0x458
45#define OMAP1_DMA_CAPS_4 0x45a
46#define OMAP1_DMA_PCH2_SR 0x460
47#define OMAP1_DMA_PCH0_SR 0x480
48#define OMAP1_DMA_PCH1_SR 0x482
49#define OMAP1_DMA_PCHD_SR 0x4c0
50
51/* Hardware registers for omap2 and omap3 */
52#define OMAP24XX_DMA4_BASE (L4_24XX_BASE + 0x56000)
53#define OMAP34XX_DMA4_BASE (L4_34XX_BASE + 0x56000)
54#define OMAP44XX_DMA4_BASE (L4_44XX_BASE + 0x56000)
55
56#define OMAP_DMA4_REVISION 0x00
57#define OMAP_DMA4_GCR 0x78
58#define OMAP_DMA4_IRQSTATUS_L0 0x08
59#define OMAP_DMA4_IRQSTATUS_L1 0x0c
60#define OMAP_DMA4_IRQSTATUS_L2 0x10
61#define OMAP_DMA4_IRQSTATUS_L3 0x14
62#define OMAP_DMA4_IRQENABLE_L0 0x18
63#define OMAP_DMA4_IRQENABLE_L1 0x1c
64#define OMAP_DMA4_IRQENABLE_L2 0x20
65#define OMAP_DMA4_IRQENABLE_L3 0x24
66#define OMAP_DMA4_SYSSTATUS 0x28
67#define OMAP_DMA4_OCP_SYSCONFIG 0x2c
68#define OMAP_DMA4_CAPS_0 0x64
69#define OMAP_DMA4_CAPS_2 0x6c
70#define OMAP_DMA4_CAPS_3 0x70
71#define OMAP_DMA4_CAPS_4 0x74
72
73#define OMAP1_LOGICAL_DMA_CH_COUNT 17
74#define OMAP_DMA4_LOGICAL_DMA_CH_COUNT 32 /* REVISIT: Is this 32 + 2? */
75
76/* Common channel specific registers for omap1 */
77#define OMAP1_DMA_CH_BASE(n) (0x40 * (n) + 0x00)
78#define OMAP1_DMA_CSDP(n) (0x40 * (n) + 0x00)
79#define OMAP1_DMA_CCR(n) (0x40 * (n) + 0x02)
80#define OMAP1_DMA_CICR(n) (0x40 * (n) + 0x04)
81#define OMAP1_DMA_CSR(n) (0x40 * (n) + 0x06)
82#define OMAP1_DMA_CEN(n) (0x40 * (n) + 0x10)
83#define OMAP1_DMA_CFN(n) (0x40 * (n) + 0x12)
84#define OMAP1_DMA_CSFI(n) (0x40 * (n) + 0x14)
85#define OMAP1_DMA_CSEI(n) (0x40 * (n) + 0x16)
86#define OMAP1_DMA_CPC(n) (0x40 * (n) + 0x18) /* 15xx only */
87#define OMAP1_DMA_CSAC(n) (0x40 * (n) + 0x18)
88#define OMAP1_DMA_CDAC(n) (0x40 * (n) + 0x1a)
89#define OMAP1_DMA_CDEI(n) (0x40 * (n) + 0x1c)
90#define OMAP1_DMA_CDFI(n) (0x40 * (n) + 0x1e)
91#define OMAP1_DMA_CLNK_CTRL(n) (0x40 * (n) + 0x28)
92
93/* Common channel specific registers for omap2 */
94#define OMAP_DMA4_CH_BASE(n) (0x60 * (n) + 0x80)
95#define OMAP_DMA4_CCR(n) (0x60 * (n) + 0x80)
96#define OMAP_DMA4_CLNK_CTRL(n) (0x60 * (n) + 0x84)
97#define OMAP_DMA4_CICR(n) (0x60 * (n) + 0x88)
98#define OMAP_DMA4_CSR(n) (0x60 * (n) + 0x8c)
99#define OMAP_DMA4_CSDP(n) (0x60 * (n) + 0x90)
100#define OMAP_DMA4_CEN(n) (0x60 * (n) + 0x94)
101#define OMAP_DMA4_CFN(n) (0x60 * (n) + 0x98)
102#define OMAP_DMA4_CSEI(n) (0x60 * (n) + 0xa4)
103#define OMAP_DMA4_CSFI(n) (0x60 * (n) + 0xa8)
104#define OMAP_DMA4_CDEI(n) (0x60 * (n) + 0xac)
105#define OMAP_DMA4_CDFI(n) (0x60 * (n) + 0xb0)
106#define OMAP_DMA4_CSAC(n) (0x60 * (n) + 0xb4)
107#define OMAP_DMA4_CDAC(n) (0x60 * (n) + 0xb8)
108
109/* Channel specific registers only on omap1 */
110#define OMAP1_DMA_CSSA_L(n) (0x40 * (n) + 0x08)
111#define OMAP1_DMA_CSSA_U(n) (0x40 * (n) + 0x0a)
112#define OMAP1_DMA_CDSA_L(n) (0x40 * (n) + 0x0c)
113#define OMAP1_DMA_CDSA_U(n) (0x40 * (n) + 0x0e)
114#define OMAP1_DMA_COLOR_L(n) (0x40 * (n) + 0x20)
115#define OMAP1_DMA_COLOR_U(n) (0x40 * (n) + 0x22)
116#define OMAP1_DMA_CCR2(n) (0x40 * (n) + 0x24)
117#define OMAP1_DMA_LCH_CTRL(n) (0x40 * (n) + 0x2a) /* not on 15xx */
118#define OMAP1_DMA_CCEN(n) 0
119#define OMAP1_DMA_CCFN(n) 0
120
121/* Channel specific registers only on omap2 */
122#define OMAP_DMA4_CSSA(n) (0x60 * (n) + 0x9c)
123#define OMAP_DMA4_CDSA(n) (0x60 * (n) + 0xa0)
124#define OMAP_DMA4_CCEN(n) (0x60 * (n) + 0xbc)
125#define OMAP_DMA4_CCFN(n) (0x60 * (n) + 0xc0)
126#define OMAP_DMA4_COLOR(n) (0x60 * (n) + 0xc4)
127
128/* Additional registers available on OMAP4 */
129#define OMAP_DMA4_CDP(n) (0x60 * (n) + 0xd0)
130#define OMAP_DMA4_CNDP(n) (0x60 * (n) + 0xd4)
131#define OMAP_DMA4_CCDN(n) (0x60 * (n) + 0xd8)
132
133/* Dummy defines to keep multi-omap compiles happy */
134#define OMAP1_DMA_REVISION 0
135#define OMAP1_DMA_IRQSTATUS_L0 0
136#define OMAP1_DMA_IRQENABLE_L0 0
137#define OMAP1_DMA_OCP_SYSCONFIG 0
138#define OMAP_DMA4_HW_ID 0
139#define OMAP_DMA4_CAPS_0_L 0
140#define OMAP_DMA4_CAPS_0_U 0
141#define OMAP_DMA4_CAPS_1_L 0
142#define OMAP_DMA4_CAPS_1_U 0
143#define OMAP_DMA4_GSCR 0
144#define OMAP_DMA4_CPC(n) 0
145
146#define OMAP_DMA4_LCH_CTRL(n) 0
147#define OMAP_DMA4_COLOR_L(n) 0
148#define OMAP_DMA4_COLOR_U(n) 0
149#define OMAP_DMA4_CCR2(n) 0
150#define OMAP1_DMA_CSSA(n) 0
151#define OMAP1_DMA_CDSA(n) 0
152#define OMAP_DMA4_CSSA_L(n) 0
153#define OMAP_DMA4_CSSA_U(n) 0
154#define OMAP_DMA4_CDSA_L(n) 0
155#define OMAP_DMA4_CDSA_U(n) 0
156#define OMAP1_DMA_COLOR(n) 0
157 30
158/*----------------------------------------------------------------------------*/ 31/* Move omap4 specific defines to dma-44xx.h */
32#include "dma-44xx.h"
159 33
160/* DMA channels for omap1 */ 34/* DMA channels for omap1 */
161#define OMAP_DMA_NO_DEVICE 0 35#define OMAP_DMA_NO_DEVICE 0
@@ -405,6 +279,63 @@
405#define DMA_CH_PRIO_HIGH 0x1 279#define DMA_CH_PRIO_HIGH 0x1
406#define DMA_CH_PRIO_LOW 0x0 /* Def */ 280#define DMA_CH_PRIO_LOW 0x0 /* Def */
407 281
282/* Errata handling */
283#define IS_DMA_ERRATA(id) (errata & (id))
284#define SET_DMA_ERRATA(id) (errata |= (id))
285
286#define DMA_ERRATA_IFRAME_BUFFERING BIT(0x0)
287#define DMA_ERRATA_PARALLEL_CHANNELS BIT(0x1)
288#define DMA_ERRATA_i378 BIT(0x2)
289#define DMA_ERRATA_i541 BIT(0x3)
290#define DMA_ERRATA_i88 BIT(0x4)
291#define DMA_ERRATA_3_3 BIT(0x5)
292#define DMA_ROMCODE_BUG BIT(0x6)
293
294/* Attributes for OMAP DMA Contrller */
295#define DMA_LINKED_LCH BIT(0x0)
296#define GLOBAL_PRIORITY BIT(0x1)
297#define RESERVE_CHANNEL BIT(0x2)
298#define IS_CSSA_32 BIT(0x3)
299#define IS_CDSA_32 BIT(0x4)
300#define IS_RW_PRIORITY BIT(0x5)
301#define ENABLE_1510_MODE BIT(0x6)
302#define SRC_PORT BIT(0x7)
303#define DST_PORT BIT(0x8)
304#define SRC_INDEX BIT(0x9)
305#define DST_INDEX BIT(0xA)
306#define IS_BURST_ONLY4 BIT(0xB)
307#define CLEAR_CSR_ON_READ BIT(0xC)
308#define IS_WORD_16 BIT(0xD)
309
310enum omap_reg_offsets {
311
312GCR, GSCR, GRST1, HW_ID,
313PCH2_ID, PCH0_ID, PCH1_ID, PCHG_ID,
314PCHD_ID, CAPS_0, CAPS_1, CAPS_2,
315CAPS_3, CAPS_4, PCH2_SR, PCH0_SR,
316PCH1_SR, PCHD_SR, REVISION, IRQSTATUS_L0,
317IRQSTATUS_L1, IRQSTATUS_L2, IRQSTATUS_L3, IRQENABLE_L0,
318IRQENABLE_L1, IRQENABLE_L2, IRQENABLE_L3, SYSSTATUS,
319OCP_SYSCONFIG,
320
321/* omap1+ specific */
322CPC, CCR2, LCH_CTRL,
323
324/* Common registers for all omap's */
325CSDP, CCR, CICR, CSR,
326CEN, CFN, CSFI, CSEI,
327CSAC, CDAC, CDEI,
328CDFI, CLNK_CTRL,
329
330/* Channel specific registers */
331CSSA, CDSA, COLOR,
332CCEN, CCFN,
333
334/* omap3630 and omap4 specific */
335CDP, CNDP, CCDN,
336
337};
338
408enum omap_dma_burst_mode { 339enum omap_dma_burst_mode {
409 OMAP_DMA_DATA_BURST_DIS = 0, 340 OMAP_DMA_DATA_BURST_DIS = 0,
410 OMAP_DMA_DATA_BURST_4, 341 OMAP_DMA_DATA_BURST_4,
@@ -470,6 +401,41 @@ struct omap_dma_channel_params {
470#endif 401#endif
471}; 402};
472 403
404struct omap_dma_lch {
405 int next_lch;
406 int dev_id;
407 u16 saved_csr;
408 u16 enabled_irqs;
409 const char *dev_name;
410 void (*callback)(int lch, u16 ch_status, void *data);
411 void *data;
412 long flags;
413 /* required for Dynamic chaining */
414 int prev_linked_ch;
415 int next_linked_ch;
416 int state;
417 int chain_id;
418 int status;
419};
420
421struct omap_dma_dev_attr {
422 u32 dev_caps;
423 u16 lch_count;
424 u16 chan_count;
425 struct omap_dma_lch *chan;
426};
427
428/* System DMA platform data structure */
429struct omap_system_dma_plat_info {
430 struct omap_dma_dev_attr *dma_attr;
431 u32 errata;
432 void (*disable_irq_lch)(int lch);
433 void (*show_dma_caps)(void);
434 void (*clear_lch_regs)(int lch);
435 void (*clear_dma)(int lch);
436 void (*dma_write)(u32 val, int reg, int lch);
437 u32 (*dma_read)(int reg, int lch);
438};
473 439
474extern void omap_set_dma_priority(int lch, int dst_port, int priority); 440extern void omap_set_dma_priority(int lch, int dst_port, int priority);
475extern int omap_request_dma(int dev_id, const char *dev_name, 441extern int omap_request_dma(int dev_id, const char *dev_name,
diff --git a/arch/arm/plat-omap/include/plat/fpga.h b/arch/arm/plat-omap/include/plat/fpga.h
index f1864a652f7a..ae39bcb3f5ba 100644
--- a/arch/arm/plat-omap/include/plat/fpga.h
+++ b/arch/arm/plat-omap/include/plat/fpga.h
@@ -19,11 +19,7 @@
19#ifndef __ASM_ARCH_OMAP_FPGA_H 19#ifndef __ASM_ARCH_OMAP_FPGA_H
20#define __ASM_ARCH_OMAP_FPGA_H 20#define __ASM_ARCH_OMAP_FPGA_H
21 21
22#if defined(CONFIG_MACH_OMAP_INNOVATOR) && defined(CONFIG_ARCH_OMAP15XX)
23extern void omap1510_fpga_init_irq(void); 22extern void omap1510_fpga_init_irq(void);
24#else
25#define omap1510_fpga_init_irq() (0)
26#endif
27 23
28#define fpga_read(reg) __raw_readb(reg) 24#define fpga_read(reg) __raw_readb(reg)
29#define fpga_write(val, reg) __raw_writeb(val, reg) 25#define fpga_write(val, reg) __raw_writeb(val, reg)
diff --git a/arch/arm/plat-omap/include/plat/gpio.h b/arch/arm/plat-omap/include/plat/gpio.h
index de1c604962eb..d6f9fa0f62af 100644
--- a/arch/arm/plat-omap/include/plat/gpio.h
+++ b/arch/arm/plat-omap/include/plat/gpio.h
@@ -27,26 +27,15 @@
27#define __ASM_ARCH_OMAP_GPIO_H 27#define __ASM_ARCH_OMAP_GPIO_H
28 28
29#include <linux/io.h> 29#include <linux/io.h>
30#include <linux/platform_device.h>
30#include <mach/irqs.h> 31#include <mach/irqs.h>
31 32
32#define OMAP1_MPUIO_BASE 0xfffb5000 33#define OMAP1_MPUIO_BASE 0xfffb5000
33 34
34#if (defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)) 35/*
35 36 * These are the omap15xx/16xx offsets. The omap7xx offset are
36#define OMAP_MPUIO_INPUT_LATCH 0x00 37 * OMAP_MPUIO_ / 2 offsets below.
37#define OMAP_MPUIO_OUTPUT 0x02 38 */
38#define OMAP_MPUIO_IO_CNTL 0x04
39#define OMAP_MPUIO_KBR_LATCH 0x08
40#define OMAP_MPUIO_KBC 0x0a
41#define OMAP_MPUIO_GPIO_EVENT_MODE 0x0c
42#define OMAP_MPUIO_GPIO_INT_EDGE 0x0e
43#define OMAP_MPUIO_KBD_INT 0x10
44#define OMAP_MPUIO_GPIO_INT 0x12
45#define OMAP_MPUIO_KBD_MASKIT 0x14
46#define OMAP_MPUIO_GPIO_MASKIT 0x16
47#define OMAP_MPUIO_GPIO_DEBOUNCING 0x18
48#define OMAP_MPUIO_LATCH 0x1a
49#else
50#define OMAP_MPUIO_INPUT_LATCH 0x00 39#define OMAP_MPUIO_INPUT_LATCH 0x00
51#define OMAP_MPUIO_OUTPUT 0x04 40#define OMAP_MPUIO_OUTPUT 0x04
52#define OMAP_MPUIO_IO_CNTL 0x08 41#define OMAP_MPUIO_IO_CNTL 0x08
@@ -60,7 +49,6 @@
60#define OMAP_MPUIO_GPIO_MASKIT 0x2c 49#define OMAP_MPUIO_GPIO_MASKIT 0x2c
61#define OMAP_MPUIO_GPIO_DEBOUNCING 0x30 50#define OMAP_MPUIO_GPIO_DEBOUNCING 0x30
62#define OMAP_MPUIO_LATCH 0x34 51#define OMAP_MPUIO_LATCH 0x34
63#endif
64 52
65#define OMAP34XX_NR_GPIOS 6 53#define OMAP34XX_NR_GPIOS 6
66 54
@@ -71,8 +59,30 @@
71 IH_MPUIO_BASE + ((nr) & 0x0f) : \ 59 IH_MPUIO_BASE + ((nr) & 0x0f) : \
72 IH_GPIO_BASE + (nr)) 60 IH_GPIO_BASE + (nr))
73 61
74extern int omap_gpio_init(void); /* Call from board init only */ 62#define METHOD_MPUIO 0
75extern void omap2_gpio_prepare_for_idle(int power_state); 63#define METHOD_GPIO_1510 1
64#define METHOD_GPIO_1610 2
65#define METHOD_GPIO_7XX 3
66#define METHOD_GPIO_24XX 5
67#define METHOD_GPIO_44XX 6
68
69struct omap_gpio_dev_attr {
70 int bank_width; /* GPIO bank width */
71 bool dbck_flag; /* dbck required or not - True for OMAP3&4 */
72};
73
74struct omap_gpio_platform_data {
75 u16 virtual_irq_start;
76 int bank_type;
77 int bank_width; /* GPIO bank width */
78 int bank_stride; /* Only needed for omap1 MPUIO */
79 bool dbck_flag; /* dbck required or not - True for OMAP3&4 */
80};
81
82/* TODO: Analyze removing gpio_bank_count usage from driver code */
83extern int gpio_bank_count;
84
85extern void omap2_gpio_prepare_for_idle(int off_mode);
76extern void omap2_gpio_resume_after_idle(void); 86extern void omap2_gpio_resume_after_idle(void);
77extern void omap_set_gpio_debounce(int gpio, int enable); 87extern void omap_set_gpio_debounce(int gpio, int enable);
78extern void omap_set_gpio_debounce_time(int gpio, int enable); 88extern void omap_set_gpio_debounce_time(int gpio, int enable);
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h b/arch/arm/plat-omap/include/plat/gpmc.h
index 9fd99b9e40ab..85ded598853e 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -80,12 +80,12 @@
80#define GPMC_PREFETCH_STATUS_COUNT(val) (val & 0x00003fff) 80#define GPMC_PREFETCH_STATUS_COUNT(val) (val & 0x00003fff)
81 81
82/* 82/*
83 * Note that all values in this struct are in nanoseconds, while 83 * Note that all values in this struct are in nanoseconds except sync_clk
84 * the register values are in gpmc_fck cycles. 84 * (which is in picoseconds), while the register values are in gpmc_fck cycles.
85 */ 85 */
86struct gpmc_timings { 86struct gpmc_timings {
87 /* Minimum clock period for synchronous mode */ 87 /* Minimum clock period for synchronous mode (in picoseconds) */
88 u16 sync_clk; 88 u32 sync_clk;
89 89
90 /* Chip-select signal timings corresponding to GPMC_CS_CONFIG2 */ 90 /* Chip-select signal timings corresponding to GPMC_CS_CONFIG2 */
91 u16 cs_on; /* Assertion time */ 91 u16 cs_on; /* Assertion time */
@@ -117,6 +117,7 @@ struct gpmc_timings {
117}; 117};
118 118
119extern unsigned int gpmc_ns_to_ticks(unsigned int time_ns); 119extern unsigned int gpmc_ns_to_ticks(unsigned int time_ns);
120extern unsigned int gpmc_ps_to_ticks(unsigned int time_ps);
120extern unsigned int gpmc_ticks_to_ns(unsigned int ticks); 121extern unsigned int gpmc_ticks_to_ns(unsigned int ticks);
121extern unsigned int gpmc_round_ns_to_ticks(unsigned int time_ns); 122extern unsigned int gpmc_round_ns_to_ticks(unsigned int time_ns);
122extern unsigned long gpmc_get_fclk_period(void); 123extern unsigned long gpmc_get_fclk_period(void);
diff --git a/arch/arm/plat-omap/include/plat/i2c.h b/arch/arm/plat-omap/include/plat/i2c.h
index 36a0befd6168..878d632c4092 100644
--- a/arch/arm/plat-omap/include/plat/i2c.h
+++ b/arch/arm/plat-omap/include/plat/i2c.h
@@ -36,6 +36,19 @@ static inline int omap_register_i2c_bus(int bus_id, u32 clkrate,
36} 36}
37#endif 37#endif
38 38
39/**
40 * i2c_dev_attr - OMAP I2C controller device attributes for omap_hwmod
41 * @fifo_depth: total controller FIFO size (in bytes)
42 * @flags: differences in hardware support capability
43 *
44 * @fifo_depth represents what exists on the hardware, not what is
45 * actually configured at runtime by the device driver.
46 */
47struct omap_i2c_dev_attr {
48 u8 fifo_depth;
49 u8 flags;
50};
51
39void __init omap1_i2c_mux_pins(int bus_id); 52void __init omap1_i2c_mux_pins(int bus_id);
40void __init omap2_i2c_mux_pins(int bus_id); 53void __init omap2_i2c_mux_pins(int bus_id);
41 54
diff --git a/arch/arm/plat-omap/include/plat/io.h b/arch/arm/plat-omap/include/plat/io.h
index 204865f91d93..ef4106c13183 100644
--- a/arch/arm/plat-omap/include/plat/io.h
+++ b/arch/arm/plat-omap/include/plat/io.h
@@ -291,8 +291,9 @@ static inline void omap44xx_map_common_io(void)
291} 291}
292#endif 292#endif
293 293
294extern void omap2_init_common_hw(struct omap_sdrc_params *sdrc_cs0, 294extern void omap2_init_common_infrastructure(void);
295 struct omap_sdrc_params *sdrc_cs1); 295extern void omap2_init_common_devices(struct omap_sdrc_params *sdrc_cs0,
296 struct omap_sdrc_params *sdrc_cs1);
296 297
297#define __arch_ioremap omap_ioremap 298#define __arch_ioremap omap_ioremap
298#define __arch_iounmap omap_iounmap 299#define __arch_iounmap omap_iounmap
diff --git a/arch/arm/plat-omap/include/plat/iommu.h b/arch/arm/plat-omap/include/plat/iommu.h
index 33c7d41cb6a5..69230d685538 100644
--- a/arch/arm/plat-omap/include/plat/iommu.h
+++ b/arch/arm/plat-omap/include/plat/iommu.h
@@ -50,6 +50,8 @@ struct iommu {
50 int (*isr)(struct iommu *obj); 50 int (*isr)(struct iommu *obj);
51 51
52 void *ctx; /* iommu context: registres saved area */ 52 void *ctx; /* iommu context: registres saved area */
53 u32 da_start;
54 u32 da_end;
53}; 55};
54 56
55struct cr_regs { 57struct cr_regs {
@@ -103,6 +105,8 @@ struct iommu_platform_data {
103 const char *name; 105 const char *name;
104 const char *clk_name; 106 const char *clk_name;
105 const int nr_tlb_entries; 107 const int nr_tlb_entries;
108 u32 da_start;
109 u32 da_end;
106}; 110};
107 111
108#if defined(CONFIG_ARCH_OMAP1) 112#if defined(CONFIG_ARCH_OMAP1)
@@ -152,6 +156,7 @@ extern void flush_iotlb_all(struct iommu *obj);
152extern int iopgtable_store_entry(struct iommu *obj, struct iotlb_entry *e); 156extern int iopgtable_store_entry(struct iommu *obj, struct iotlb_entry *e);
153extern size_t iopgtable_clear_entry(struct iommu *obj, u32 iova); 157extern size_t iopgtable_clear_entry(struct iommu *obj, u32 iova);
154 158
159extern int iommu_set_da_range(struct iommu *obj, u32 start, u32 end);
155extern struct iommu *iommu_get(const char *name); 160extern struct iommu *iommu_get(const char *name);
156extern void iommu_put(struct iommu *obj); 161extern void iommu_put(struct iommu *obj);
157 162
diff --git a/arch/arm/plat-omap/include/plat/irqs.h b/arch/arm/plat-omap/include/plat/irqs.h
index 65e20a686713..2910de921c52 100644
--- a/arch/arm/plat-omap/include/plat/irqs.h
+++ b/arch/arm/plat-omap/include/plat/irqs.h
@@ -77,7 +77,7 @@
77/* 77/*
78 * OMAP-1610 specific IRQ numbers for interrupt handler 1 78 * OMAP-1610 specific IRQ numbers for interrupt handler 1
79 */ 79 */
80#define INT_1610_IH2_IRQ 0 80#define INT_1610_IH2_IRQ INT_1510_IH2_IRQ
81#define INT_1610_IH2_FIQ 2 81#define INT_1610_IH2_FIQ 2
82#define INT_1610_McBSP2_TX 4 82#define INT_1610_McBSP2_TX 4
83#define INT_1610_McBSP2_RX 5 83#define INT_1610_McBSP2_RX 5
diff --git a/arch/arm/plat-omap/include/plat/keypad.h b/arch/arm/plat-omap/include/plat/keypad.h
index 3ae52ccc793c..793ce9d53294 100644
--- a/arch/arm/plat-omap/include/plat/keypad.h
+++ b/arch/arm/plat-omap/include/plat/keypad.h
@@ -10,16 +10,18 @@
10#ifndef ASMARM_ARCH_KEYPAD_H 10#ifndef ASMARM_ARCH_KEYPAD_H
11#define ASMARM_ARCH_KEYPAD_H 11#define ASMARM_ARCH_KEYPAD_H
12 12
13#warning: Please update the board to use matrix_keypad.h instead 13#ifndef CONFIG_ARCH_OMAP1
14#warning Please update the board to use matrix-keypad driver
15#endif
16#include <linux/input/matrix_keypad.h>
14 17
15struct omap_kp_platform_data { 18struct omap_kp_platform_data {
16 int rows; 19 int rows;
17 int cols; 20 int cols;
18 int *keymap; 21 const struct matrix_keymap_data *keymap_data;
19 unsigned int keymapsize; 22 bool rep;
20 unsigned int rep:1;
21 unsigned long delay; 23 unsigned long delay;
22 unsigned int dbounce:1; 24 bool dbounce;
23 /* specific to OMAP242x*/ 25 /* specific to OMAP242x*/
24 unsigned int *row_gpios; 26 unsigned int *row_gpios;
25 unsigned int *col_gpios; 27 unsigned int *col_gpios;
@@ -28,18 +30,21 @@ struct omap_kp_platform_data {
28/* Group (0..3) -- when multiple keys are pressed, only the 30/* Group (0..3) -- when multiple keys are pressed, only the
29 * keys pressed in the same group are considered as pressed. This is 31 * keys pressed in the same group are considered as pressed. This is
30 * in order to workaround certain crappy HW designs that produce ghost 32 * in order to workaround certain crappy HW designs that produce ghost
31 * keypresses. */ 33 * keypresses. Two free bits, not used by neither row/col nor keynum,
32#define GROUP_0 (0 << 16) 34 * must be available for use as group bits. The below GROUP_SHIFT
33#define GROUP_1 (1 << 16) 35 * macro definition is based on some prior knowledge of the
34#define GROUP_2 (2 << 16) 36 * matrix_keypad defined KEY() macro internals.
35#define GROUP_3 (3 << 16) 37 */
38#define GROUP_SHIFT 14
39#define GROUP_0 (0 << GROUP_SHIFT)
40#define GROUP_1 (1 << GROUP_SHIFT)
41#define GROUP_2 (2 << GROUP_SHIFT)
42#define GROUP_3 (3 << GROUP_SHIFT)
36#define GROUP_MASK GROUP_3 43#define GROUP_MASK GROUP_3
44#if KEY_MAX & GROUP_MASK
45#error Group bits in conflict with keynum bits
46#endif
37 47
38#define KEY_PERSISTENT 0x00800000
39#define KEYNUM_MASK 0x00EFFFFF
40#define KEY(col, row, val) (((col) << 28) | ((row) << 24) | (val))
41#define PERSISTENT_KEY(col, row) (((col) << 28) | ((row) << 24) | \
42 KEY_PERSISTENT)
43 48
44#endif 49#endif
45 50
diff --git a/arch/arm/plat-omap/include/plat/l4_3xxx.h b/arch/arm/plat-omap/include/plat/l4_3xxx.h
new file mode 100644
index 000000000000..5e1949375422
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/l4_3xxx.h
@@ -0,0 +1,24 @@
1/*
2 * arch/arm/plat-omap/include/mach/l4_3xxx.h - L4 firewall definitions
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 * Paul Walmsley
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 */
13#ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_L4_3XXX_H
14#define __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_L4_3XXX_H
15
16/* L4 CORE */
17#define OMAP3_L4_CORE_FW_I2C1_REGION 21
18#define OMAP3_L4_CORE_FW_I2C1_TA_REGION 22
19#define OMAP3_L4_CORE_FW_I2C2_REGION 23
20#define OMAP3_L4_CORE_FW_I2C2_TA_REGION 24
21#define OMAP3_L4_CORE_FW_I2C3_REGION 73
22#define OMAP3_L4_CORE_FW_I2C3_TA_REGION 74
23
24#endif
diff --git a/arch/arm/plat-omap/include/plat/mailbox.h b/arch/arm/plat-omap/include/plat/mailbox.h
index 997656552109..cc3921e9059c 100644
--- a/arch/arm/plat-omap/include/plat/mailbox.h
+++ b/arch/arm/plat-omap/include/plat/mailbox.h
@@ -46,8 +46,8 @@ struct omap_mbox_queue {
46 struct kfifo fifo; 46 struct kfifo fifo;
47 struct work_struct work; 47 struct work_struct work;
48 struct tasklet_struct tasklet; 48 struct tasklet_struct tasklet;
49 int (*callback)(void *);
50 struct omap_mbox *mbox; 49 struct omap_mbox *mbox;
50 bool full;
51}; 51};
52 52
53struct omap_mbox { 53struct omap_mbox {
@@ -57,13 +57,15 @@ struct omap_mbox {
57 struct omap_mbox_ops *ops; 57 struct omap_mbox_ops *ops;
58 struct device *dev; 58 struct device *dev;
59 void *priv; 59 void *priv;
60 int use_count;
61 struct blocking_notifier_head notifier;
60}; 62};
61 63
62int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg); 64int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg);
63void omap_mbox_init_seq(struct omap_mbox *); 65void omap_mbox_init_seq(struct omap_mbox *);
64 66
65struct omap_mbox *omap_mbox_get(const char *); 67struct omap_mbox *omap_mbox_get(const char *, struct notifier_block *nb);
66void omap_mbox_put(struct omap_mbox *); 68void omap_mbox_put(struct omap_mbox *mbox, struct notifier_block *nb);
67 69
68int omap_mbox_register(struct device *parent, struct omap_mbox **); 70int omap_mbox_register(struct device *parent, struct omap_mbox **);
69int omap_mbox_unregister(void); 71int omap_mbox_unregister(void);
diff --git a/arch/arm/plat-omap/include/plat/omap-pm.h b/arch/arm/plat-omap/include/plat/omap-pm.h
index 728fbb9dd549..c0a752053039 100644
--- a/arch/arm/plat-omap/include/plat/omap-pm.h
+++ b/arch/arm/plat-omap/include/plat/omap-pm.h
@@ -17,26 +17,7 @@
17#include <linux/device.h> 17#include <linux/device.h>
18#include <linux/cpufreq.h> 18#include <linux/cpufreq.h>
19#include <linux/clk.h> 19#include <linux/clk.h>
20 20#include <linux/opp.h>
21#include "powerdomain.h"
22
23/**
24 * struct omap_opp - clock frequency-to-OPP ID table for DSP, MPU
25 * @rate: target clock rate
26 * @opp_id: OPP ID
27 * @min_vdd: minimum VDD1 voltage (in millivolts) for this OPP
28 *
29 * Operating performance point data. Can vary by OMAP chip and board.
30 */
31struct omap_opp {
32 unsigned long rate;
33 u8 opp_id;
34 u16 min_vdd;
35};
36
37extern struct omap_opp *mpu_opps;
38extern struct omap_opp *dsp_opps;
39extern struct omap_opp *l3_opps;
40 21
41/* 22/*
42 * agent_id values for use with omap_pm_set_min_bus_tput(): 23 * agent_id values for use with omap_pm_set_min_bus_tput():
@@ -59,9 +40,11 @@ extern struct omap_opp *l3_opps;
59 * framework starts. The "_if_" is to avoid name collisions with the 40 * framework starts. The "_if_" is to avoid name collisions with the
60 * PM idle-loop code. 41 * PM idle-loop code.
61 */ 42 */
62int __init omap_pm_if_early_init(struct omap_opp *mpu_opp_table, 43#ifdef CONFIG_OMAP_PM_NONE
63 struct omap_opp *dsp_opp_table, 44#define omap_pm_if_early_init() 0
64 struct omap_opp *l3_opp_table); 45#else
46int __init omap_pm_if_early_init(void);
47#endif
65 48
66/** 49/**
67 * omap_pm_if_init - OMAP PM init code called after clock fw init 50 * omap_pm_if_init - OMAP PM init code called after clock fw init
@@ -69,7 +52,11 @@ int __init omap_pm_if_early_init(struct omap_opp *mpu_opp_table,
69 * The main initialization code. OPP tables are passed in here. The 52 * The main initialization code. OPP tables are passed in here. The
70 * "_if_" is to avoid name collisions with the PM idle-loop code. 53 * "_if_" is to avoid name collisions with the PM idle-loop code.
71 */ 54 */
55#ifdef CONFIG_OMAP_PM_NONE
56#define omap_pm_if_init() 0
57#else
72int __init omap_pm_if_init(void); 58int __init omap_pm_if_init(void);
59#endif
73 60
74/** 61/**
75 * omap_pm_if_exit - OMAP PM exit code 62 * omap_pm_if_exit - OMAP PM exit code
@@ -363,9 +350,11 @@ unsigned long omap_pm_cpu_get_freq(void);
363 * driver must restore device context. If the number of context losses 350 * driver must restore device context. If the number of context losses
364 * exceeds the maximum positive integer, the function will wrap to 0 and 351 * exceeds the maximum positive integer, the function will wrap to 0 and
365 * continue counting. Returns the number of context losses for this device, 352 * continue counting. Returns the number of context losses for this device,
366 * or -EINVAL upon error. 353 * or zero upon error.
367 */ 354 */
368int omap_pm_get_dev_context_loss_count(struct device *dev); 355u32 omap_pm_get_dev_context_loss_count(struct device *dev);
369 356
357void omap_pm_enable_off_mode(void);
358void omap_pm_disable_off_mode(void);
370 359
371#endif 360#endif
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h b/arch/arm/plat-omap/include/plat/omap-serial.h
index c8dae02f0704..2682043f5a5b 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -22,7 +22,7 @@
22 22
23#include <plat/mux.h> 23#include <plat/mux.h>
24 24
25#define DRIVER_NAME "omap-hsuart" 25#define DRIVER_NAME "omap_uart"
26 26
27/* 27/*
28 * Use tty device name as ttyO, [O -> OMAP] 28 * Use tty device name as ttyO, [O -> OMAP]
@@ -31,20 +31,8 @@
31 */ 31 */
32#define OMAP_SERIAL_NAME "ttyO" 32#define OMAP_SERIAL_NAME "ttyO"
33 33
34#define OMAP_MDR1_DISABLE 0x07
35#define OMAP_MDR1_MODE13X 0x03
36#define OMAP_MDR1_MODE16X 0x00
37#define OMAP_MODE13X_SPEED 230400 34#define OMAP_MODE13X_SPEED 230400
38 35
39/*
40 * LCR = 0XBF: Switch to Configuration Mode B.
41 * In configuration mode b allow access
42 * to EFR,DLL,DLH.
43 * Reference OMAP TRM Chapter 17
44 * Section: 1.4.3 Mode Selection
45 */
46#define OMAP_UART_LCR_CONF_MDB 0XBF
47
48/* WER = 0x7F 36/* WER = 0x7F
49 * Enable module level wakeup in WER reg 37 * Enable module level wakeup in WER reg
50 */ 38 */
diff --git a/arch/arm/plat-omap/include/plat/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h
index 28e2d1a78433..e4c349ff9fd8 100644
--- a/arch/arm/plat-omap/include/plat/omap_device.h
+++ b/arch/arm/plat-omap/include/plat/omap_device.h
@@ -107,6 +107,7 @@ void __iomem *omap_device_get_rt_va(struct omap_device *od);
107int omap_device_align_pm_lat(struct platform_device *pdev, 107int omap_device_align_pm_lat(struct platform_device *pdev,
108 u32 new_wakeup_lat_limit); 108 u32 new_wakeup_lat_limit);
109struct powerdomain *omap_device_get_pwrdm(struct omap_device *od); 109struct powerdomain *omap_device_get_pwrdm(struct omap_device *od);
110u32 omap_device_get_context_loss_count(struct platform_device *pdev);
110 111
111/* Other */ 112/* Other */
112 113
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 7eaa8edf3b14..6864a997f2ca 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -23,7 +23,7 @@
23 * - add pinmuxing 23 * - add pinmuxing
24 * - init_conn_id_bit (CONNID_BIT_VECTOR) 24 * - init_conn_id_bit (CONNID_BIT_VECTOR)
25 * - implement default hwmod SMS/SDRC flags? 25 * - implement default hwmod SMS/SDRC flags?
26 * - remove unused fields 26 * - move Linux-specific data ("non-ROM data") out
27 * 27 *
28 */ 28 */
29#ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_HWMOD_H 29#ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_HWMOD_H
@@ -32,8 +32,9 @@
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/list.h> 33#include <linux/list.h>
34#include <linux/ioport.h> 34#include <linux/ioport.h>
35#include <linux/mutex.h> 35#include <linux/spinlock.h>
36#include <plat/cpu.h> 36#include <plat/cpu.h>
37#include <plat/voltage.h>
37 38
38struct omap_device; 39struct omap_device;
39 40
@@ -76,6 +77,20 @@ extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type2;
76#define HWMOD_IDLEMODE_FORCE (1 << 0) 77#define HWMOD_IDLEMODE_FORCE (1 << 0)
77#define HWMOD_IDLEMODE_NO (1 << 1) 78#define HWMOD_IDLEMODE_NO (1 << 1)
78#define HWMOD_IDLEMODE_SMART (1 << 2) 79#define HWMOD_IDLEMODE_SMART (1 << 2)
80/* Slave idle mode flag only */
81#define HWMOD_IDLEMODE_SMART_WKUP (1 << 3)
82
83/**
84 * struct omap_hwmod_mux_info - hwmod specific mux configuration
85 * @pads: array of omap_device_pad entries
86 * @nr_pads: number of omap_device_pad entries
87 *
88 * Note that this is currently built during init as needed.
89 */
90struct omap_hwmod_mux_info {
91 int nr_pads;
92 struct omap_device_pad *pads;
93};
79 94
80/** 95/**
81 * struct omap_hwmod_irq_info - MPU IRQs used by the hwmod 96 * struct omap_hwmod_irq_info - MPU IRQs used by the hwmod
@@ -159,7 +174,7 @@ struct omap_hwmod_omap2_firewall {
159 * ADDR_MAP_ON_INIT: Map this address space during omap_hwmod init. 174 * ADDR_MAP_ON_INIT: Map this address space during omap_hwmod init.
160 * ADDR_TYPE_RT: Address space contains module register target data. 175 * ADDR_TYPE_RT: Address space contains module register target data.
161 */ 176 */
162#define ADDR_MAP_ON_INIT (1 << 0) 177#define ADDR_MAP_ON_INIT (1 << 0) /* XXX does not belong */
163#define ADDR_TYPE_RT (1 << 1) 178#define ADDR_TYPE_RT (1 << 1)
164 179
165/** 180/**
@@ -200,8 +215,6 @@ struct omap_hwmod_addr_space {
200 * @fw: interface firewall data 215 * @fw: interface firewall data
201 * @addr_cnt: ARRAY_SIZE(@addr) 216 * @addr_cnt: ARRAY_SIZE(@addr)
202 * @width: OCP data width 217 * @width: OCP data width
203 * @thread_cnt: number of threads
204 * @max_burst_len: maximum burst length in @width sized words (0 if unlimited)
205 * @user: initiators using this interface (see OCP_USER_* macros above) 218 * @user: initiators using this interface (see OCP_USER_* macros above)
206 * @flags: OCP interface flags (see OCPIF_* macros above) 219 * @flags: OCP interface flags (see OCPIF_* macros above)
207 * 220 *
@@ -221,8 +234,6 @@ struct omap_hwmod_ocp_if {
221 } fw; 234 } fw;
222 u8 addr_cnt; 235 u8 addr_cnt;
223 u8 width; 236 u8 width;
224 u8 thread_cnt;
225 u8 max_burst_len;
226 u8 user; 237 u8 user;
227 u8 flags; 238 u8 flags;
228}; 239};
@@ -231,11 +242,12 @@ struct omap_hwmod_ocp_if {
231/* Macros for use in struct omap_hwmod_sysconfig */ 242/* Macros for use in struct omap_hwmod_sysconfig */
232 243
233/* Flags for use in omap_hwmod_sysconfig.idlemodes */ 244/* Flags for use in omap_hwmod_sysconfig.idlemodes */
234#define MASTER_STANDBY_SHIFT 2 245#define MASTER_STANDBY_SHIFT 4
235#define SLAVE_IDLE_SHIFT 0 246#define SLAVE_IDLE_SHIFT 0
236#define SIDLE_FORCE (HWMOD_IDLEMODE_FORCE << SLAVE_IDLE_SHIFT) 247#define SIDLE_FORCE (HWMOD_IDLEMODE_FORCE << SLAVE_IDLE_SHIFT)
237#define SIDLE_NO (HWMOD_IDLEMODE_NO << SLAVE_IDLE_SHIFT) 248#define SIDLE_NO (HWMOD_IDLEMODE_NO << SLAVE_IDLE_SHIFT)
238#define SIDLE_SMART (HWMOD_IDLEMODE_SMART << SLAVE_IDLE_SHIFT) 249#define SIDLE_SMART (HWMOD_IDLEMODE_SMART << SLAVE_IDLE_SHIFT)
250#define SIDLE_SMART_WKUP (HWMOD_IDLEMODE_SMART_WKUP << SLAVE_IDLE_SHIFT)
239#define MSTANDBY_FORCE (HWMOD_IDLEMODE_FORCE << MASTER_STANDBY_SHIFT) 251#define MSTANDBY_FORCE (HWMOD_IDLEMODE_FORCE << MASTER_STANDBY_SHIFT)
240#define MSTANDBY_NO (HWMOD_IDLEMODE_NO << MASTER_STANDBY_SHIFT) 252#define MSTANDBY_NO (HWMOD_IDLEMODE_NO << MASTER_STANDBY_SHIFT)
241#define MSTANDBY_SMART (HWMOD_IDLEMODE_SMART << MASTER_STANDBY_SHIFT) 253#define MSTANDBY_SMART (HWMOD_IDLEMODE_SMART << MASTER_STANDBY_SHIFT)
@@ -357,14 +369,14 @@ struct omap_hwmod_omap4_prcm {
357 * HWMOD_SWSUP_MSTDBY: omap_hwmod code should manually bring module in and out 369 * HWMOD_SWSUP_MSTDBY: omap_hwmod code should manually bring module in and out
358 * of standby, rather than relying on module smart-standby 370 * of standby, rather than relying on module smart-standby
359 * HWMOD_INIT_NO_RESET: don't reset this module at boot - important for 371 * HWMOD_INIT_NO_RESET: don't reset this module at boot - important for
360 * SDRAM controller, etc. 372 * SDRAM controller, etc. XXX probably belongs outside the main hwmod file
361 * HWMOD_INIT_NO_IDLE: don't idle this module at boot - important for SDRAM 373 * HWMOD_INIT_NO_IDLE: don't idle this module at boot - important for SDRAM
362 * controller, etc. 374 * controller, etc. XXX probably belongs outside the main hwmod file
363 * HWMOD_NO_AUTOIDLE: disable module autoidle (OCP_SYSCONFIG.AUTOIDLE) 375 * HWMOD_NO_AUTOIDLE: disable module autoidle (OCP_SYSCONFIG.AUTOIDLE)
364 * when module is enabled, rather than the default, which is to 376 * when module is enabled, rather than the default, which is to
365 * enable autoidle 377 * enable autoidle
366 * HWMOD_SET_DEFAULT_CLOCKACT: program CLOCKACTIVITY bits at startup 378 * HWMOD_SET_DEFAULT_CLOCKACT: program CLOCKACTIVITY bits at startup
367 * HWMOD_NO_IDLEST : this module does not have idle status - this is the case 379 * HWMOD_NO_IDLEST: this module does not have idle status - this is the case
368 * only for few initiator modules on OMAP2 & 3. 380 * only for few initiator modules on OMAP2 & 3.
369 * HWMOD_CONTROL_OPT_CLKS_IN_RESET: Enable all optional clocks during reset. 381 * HWMOD_CONTROL_OPT_CLKS_IN_RESET: Enable all optional clocks during reset.
370 * This is needed for devices like DSS that require optional clocks enabled 382 * This is needed for devices like DSS that require optional clocks enabled
@@ -415,14 +427,31 @@ struct omap_hwmod_omap4_prcm {
415 * @name: name of the hwmod_class 427 * @name: name of the hwmod_class
416 * @sysc: device SYSCONFIG/SYSSTATUS register data 428 * @sysc: device SYSCONFIG/SYSSTATUS register data
417 * @rev: revision of the IP class 429 * @rev: revision of the IP class
430 * @pre_shutdown: ptr to fn to be executed immediately prior to device shutdown
431 * @reset: ptr to fn to be executed in place of the standard hwmod reset fn
418 * 432 *
419 * Represent the class of a OMAP hardware "modules" (e.g. timer, 433 * Represent the class of a OMAP hardware "modules" (e.g. timer,
420 * smartreflex, gpio, uart...) 434 * smartreflex, gpio, uart...)
435 *
436 * @pre_shutdown is a function that will be run immediately before
437 * hwmod clocks are disabled, etc. It is intended for use for hwmods
438 * like the MPU watchdog, which cannot be disabled with the standard
439 * omap_hwmod_shutdown(). The function should return 0 upon success,
440 * or some negative error upon failure. Returning an error will cause
441 * omap_hwmod_shutdown() to abort the device shutdown and return an
442 * error.
443 *
444 * If @reset is defined, then the function it points to will be
445 * executed in place of the standard hwmod _reset() code in
446 * mach-omap2/omap_hwmod.c. This is needed for IP blocks which have
447 * unusual reset sequences - usually processor IP blocks like the IVA.
421 */ 448 */
422struct omap_hwmod_class { 449struct omap_hwmod_class {
423 const char *name; 450 const char *name;
424 struct omap_hwmod_class_sysconfig *sysc; 451 struct omap_hwmod_class_sysconfig *sysc;
425 u32 rev; 452 u32 rev;
453 int (*pre_shutdown)(struct omap_hwmod *oh);
454 int (*reset)(struct omap_hwmod *oh);
426}; 455};
427 456
428/** 457/**
@@ -436,14 +465,14 @@ struct omap_hwmod_class {
436 * @main_clk: main clock: OMAP clock name 465 * @main_clk: main clock: OMAP clock name
437 * @_clk: pointer to the main struct clk (filled in at runtime) 466 * @_clk: pointer to the main struct clk (filled in at runtime)
438 * @opt_clks: other device clocks that drivers can request (0..*) 467 * @opt_clks: other device clocks that drivers can request (0..*)
468 * @vdd_name: voltage domain name
469 * @voltdm: pointer to voltage domain (filled in at runtime)
439 * @masters: ptr to array of OCP ifs that this hwmod can initiate on 470 * @masters: ptr to array of OCP ifs that this hwmod can initiate on
440 * @slaves: ptr to array of OCP ifs that this hwmod can respond on 471 * @slaves: ptr to array of OCP ifs that this hwmod can respond on
441 * @dev_attr: arbitrary device attributes that can be passed to the driver 472 * @dev_attr: arbitrary device attributes that can be passed to the driver
442 * @_sysc_cache: internal-use hwmod flags 473 * @_sysc_cache: internal-use hwmod flags
443 * @_mpu_rt_va: cached register target start address (internal use) 474 * @_mpu_rt_va: cached register target start address (internal use)
444 * @_mpu_port_index: cached MPU register target slave ID (internal use) 475 * @_mpu_port_index: cached MPU register target slave ID (internal use)
445 * @msuspendmux_reg_id: CONTROL_MSUSPENDMUX register ID (1-6)
446 * @msuspendmux_shift: CONTROL_MSUSPENDMUX register bit shift
447 * @mpu_irqs_cnt: number of @mpu_irqs 476 * @mpu_irqs_cnt: number of @mpu_irqs
448 * @sdma_reqs_cnt: number of @sdma_reqs 477 * @sdma_reqs_cnt: number of @sdma_reqs
449 * @opt_clks_cnt: number of @opt_clks 478 * @opt_clks_cnt: number of @opt_clks
@@ -452,9 +481,10 @@ struct omap_hwmod_class {
452 * @response_lat: device OCP response latency (in interface clock cycles) 481 * @response_lat: device OCP response latency (in interface clock cycles)
453 * @_int_flags: internal-use hwmod flags 482 * @_int_flags: internal-use hwmod flags
454 * @_state: internal-use hwmod state 483 * @_state: internal-use hwmod state
484 * @_postsetup_state: internal-use state to leave the hwmod in after _setup()
455 * @flags: hwmod flags (documented below) 485 * @flags: hwmod flags (documented below)
456 * @omap_chip: OMAP chips this hwmod is present on 486 * @omap_chip: OMAP chips this hwmod is present on
457 * @_mutex: mutex serializing operations on this hwmod 487 * @_lock: spinlock serializing operations on this hwmod
458 * @node: list node for hwmod list (internal use) 488 * @node: list node for hwmod list (internal use)
459 * 489 *
460 * @main_clk refers to this module's "main clock," which for our 490 * @main_clk refers to this module's "main clock," which for our
@@ -469,6 +499,7 @@ struct omap_hwmod {
469 const char *name; 499 const char *name;
470 struct omap_hwmod_class *class; 500 struct omap_hwmod_class *class;
471 struct omap_device *od; 501 struct omap_device *od;
502 struct omap_hwmod_mux_info *mux;
472 struct omap_hwmod_irq_info *mpu_irqs; 503 struct omap_hwmod_irq_info *mpu_irqs;
473 struct omap_hwmod_dma_info *sdma_reqs; 504 struct omap_hwmod_dma_info *sdma_reqs;
474 struct omap_hwmod_rst_info *rst_lines; 505 struct omap_hwmod_rst_info *rst_lines;
@@ -479,17 +510,17 @@ struct omap_hwmod {
479 const char *main_clk; 510 const char *main_clk;
480 struct clk *_clk; 511 struct clk *_clk;
481 struct omap_hwmod_opt_clk *opt_clks; 512 struct omap_hwmod_opt_clk *opt_clks;
513 char *vdd_name;
514 struct voltagedomain *voltdm;
482 struct omap_hwmod_ocp_if **masters; /* connect to *_IA */ 515 struct omap_hwmod_ocp_if **masters; /* connect to *_IA */
483 struct omap_hwmod_ocp_if **slaves; /* connect to *_TA */ 516 struct omap_hwmod_ocp_if **slaves; /* connect to *_TA */
484 void *dev_attr; 517 void *dev_attr;
485 u32 _sysc_cache; 518 u32 _sysc_cache;
486 void __iomem *_mpu_rt_va; 519 void __iomem *_mpu_rt_va;
487 struct mutex _mutex; 520 spinlock_t _lock;
488 struct list_head node; 521 struct list_head node;
489 u16 flags; 522 u16 flags;
490 u8 _mpu_port_index; 523 u8 _mpu_port_index;
491 u8 msuspendmux_reg_id;
492 u8 msuspendmux_shift;
493 u8 response_lat; 524 u8 response_lat;
494 u8 mpu_irqs_cnt; 525 u8 mpu_irqs_cnt;
495 u8 sdma_reqs_cnt; 526 u8 sdma_reqs_cnt;
@@ -500,16 +531,15 @@ struct omap_hwmod {
500 u8 hwmods_cnt; 531 u8 hwmods_cnt;
501 u8 _int_flags; 532 u8 _int_flags;
502 u8 _state; 533 u8 _state;
534 u8 _postsetup_state;
503 const struct omap_chip_id omap_chip; 535 const struct omap_chip_id omap_chip;
504}; 536};
505 537
506int omap_hwmod_init(struct omap_hwmod **ohs); 538int omap_hwmod_init(struct omap_hwmod **ohs);
507int omap_hwmod_register(struct omap_hwmod *oh);
508int omap_hwmod_unregister(struct omap_hwmod *oh);
509struct omap_hwmod *omap_hwmod_lookup(const char *name); 539struct omap_hwmod *omap_hwmod_lookup(const char *name);
510int omap_hwmod_for_each(int (*fn)(struct omap_hwmod *oh, void *data), 540int omap_hwmod_for_each(int (*fn)(struct omap_hwmod *oh, void *data),
511 void *data); 541 void *data);
512int omap_hwmod_late_init(u8 skip_setup_idle); 542int omap_hwmod_late_init(void);
513 543
514int omap_hwmod_enable(struct omap_hwmod *oh); 544int omap_hwmod_enable(struct omap_hwmod *oh);
515int _omap_hwmod_enable(struct omap_hwmod *oh); 545int _omap_hwmod_enable(struct omap_hwmod *oh);
@@ -556,6 +586,9 @@ int omap_hwmod_for_each_by_class(const char *classname,
556 void *user), 586 void *user),
557 void *user); 587 void *user);
558 588
589int omap_hwmod_set_postsetup_state(struct omap_hwmod *oh, u8 state);
590u32 omap_hwmod_get_context_loss_count(struct omap_hwmod *oh);
591
559/* 592/*
560 * Chip variant-specific hwmod init routines - XXX should be converted 593 * Chip variant-specific hwmod init routines - XXX should be converted
561 * to use initcalls once the initial boot ordering is straightened out 594 * to use initcalls once the initial boot ordering is straightened out
diff --git a/arch/arm/plat-omap/include/plat/powerdomain.h b/arch/arm/plat-omap/include/plat/powerdomain.h
deleted file mode 100644
index 9ca420dcd2f8..000000000000
--- a/arch/arm/plat-omap/include/plat/powerdomain.h
+++ /dev/null
@@ -1,167 +0,0 @@
1/*
2 * OMAP2/3 powerdomain control
3 *
4 * Copyright (C) 2007-2008 Texas Instruments, Inc.
5 * Copyright (C) 2007-2009 Nokia Corporation
6 *
7 * Written by Paul Walmsley
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#ifndef ASM_ARM_ARCH_OMAP_POWERDOMAIN
15#define ASM_ARM_ARCH_OMAP_POWERDOMAIN
16
17#include <linux/types.h>
18#include <linux/list.h>
19
20#include <asm/atomic.h>
21
22#include <plat/cpu.h>
23
24
25/* Powerdomain basic power states */
26#define PWRDM_POWER_OFF 0x0
27#define PWRDM_POWER_RET 0x1
28#define PWRDM_POWER_INACTIVE 0x2
29#define PWRDM_POWER_ON 0x3
30
31#define PWRDM_MAX_PWRSTS 4
32
33/* Powerdomain allowable state bitfields */
34#define PWRSTS_ON (1 << PWRDM_POWER_ON)
35#define PWRSTS_OFF (1 << PWRDM_POWER_OFF)
36#define PWRSTS_OFF_ON ((1 << PWRDM_POWER_OFF) | \
37 (1 << PWRDM_POWER_ON))
38
39#define PWRSTS_OFF_RET ((1 << PWRDM_POWER_OFF) | \
40 (1 << PWRDM_POWER_RET))
41
42#define PWRSTS_RET_ON ((1 << PWRDM_POWER_RET) | \
43 (1 << PWRDM_POWER_ON))
44
45#define PWRSTS_OFF_RET_ON (PWRSTS_OFF_RET | (1 << PWRDM_POWER_ON))
46
47
48/* Powerdomain flags */
49#define PWRDM_HAS_HDWR_SAR (1 << 0) /* hardware save-and-restore support */
50#define PWRDM_HAS_MPU_QUIRK (1 << 1) /* MPU pwr domain has MEM bank 0 bits
51 * in MEM bank 1 position. This is
52 * true for OMAP3430
53 */
54#define PWRDM_HAS_LOWPOWERSTATECHANGE (1 << 2) /*
55 * support to transition from a
56 * sleep state to a lower sleep
57 * state without waking up the
58 * powerdomain
59 */
60
61/*
62 * Number of memory banks that are power-controllable. On OMAP4430, the
63 * maximum is 5.
64 */
65#define PWRDM_MAX_MEM_BANKS 5
66
67/*
68 * Maximum number of clockdomains that can be associated with a powerdomain.
69 * CORE powerdomain on OMAP4 is the worst case
70 */
71#define PWRDM_MAX_CLKDMS 9
72
73/* XXX A completely arbitrary number. What is reasonable here? */
74#define PWRDM_TRANSITION_BAILOUT 100000
75
76struct clockdomain;
77struct powerdomain;
78
79/**
80 * struct powerdomain - OMAP powerdomain
81 * @name: Powerdomain name
82 * @omap_chip: represents the OMAP chip types containing this pwrdm
83 * @prcm_offs: the address offset from CM_BASE/PRM_BASE
84 * @pwrsts: Possible powerdomain power states
85 * @pwrsts_logic_ret: Possible logic power states when pwrdm in RETENTION
86 * @flags: Powerdomain flags
87 * @banks: Number of software-controllable memory banks in this powerdomain
88 * @pwrsts_mem_ret: Possible memory bank pwrstates when pwrdm in RETENTION
89 * @pwrsts_mem_on: Possible memory bank pwrstates when pwrdm in ON
90 * @pwrdm_clkdms: Clockdomains in this powerdomain
91 * @node: list_head linking all powerdomains
92 * @state:
93 * @state_counter:
94 * @timer:
95 * @state_timer:
96 */
97struct powerdomain {
98 const char *name;
99 const struct omap_chip_id omap_chip;
100 const s16 prcm_offs;
101 const u8 pwrsts;
102 const u8 pwrsts_logic_ret;
103 const u8 flags;
104 const u8 banks;
105 const u8 pwrsts_mem_ret[PWRDM_MAX_MEM_BANKS];
106 const u8 pwrsts_mem_on[PWRDM_MAX_MEM_BANKS];
107 struct clockdomain *pwrdm_clkdms[PWRDM_MAX_CLKDMS];
108 struct list_head node;
109 int state;
110 unsigned state_counter[PWRDM_MAX_PWRSTS];
111 unsigned ret_logic_off_counter;
112 unsigned ret_mem_off_counter[PWRDM_MAX_MEM_BANKS];
113
114#ifdef CONFIG_PM_DEBUG
115 s64 timer;
116 s64 state_timer[PWRDM_MAX_PWRSTS];
117#endif
118};
119
120
121void pwrdm_init(struct powerdomain **pwrdm_list);
122
123struct powerdomain *pwrdm_lookup(const char *name);
124
125int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm, void *user),
126 void *user);
127int pwrdm_for_each_nolock(int (*fn)(struct powerdomain *pwrdm, void *user),
128 void *user);
129
130int pwrdm_add_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm);
131int pwrdm_del_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm);
132int pwrdm_for_each_clkdm(struct powerdomain *pwrdm,
133 int (*fn)(struct powerdomain *pwrdm,
134 struct clockdomain *clkdm));
135
136int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm);
137
138int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst);
139int pwrdm_read_next_pwrst(struct powerdomain *pwrdm);
140int pwrdm_read_pwrst(struct powerdomain *pwrdm);
141int pwrdm_read_prev_pwrst(struct powerdomain *pwrdm);
142int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm);
143
144int pwrdm_set_logic_retst(struct powerdomain *pwrdm, u8 pwrst);
145int pwrdm_set_mem_onst(struct powerdomain *pwrdm, u8 bank, u8 pwrst);
146int pwrdm_set_mem_retst(struct powerdomain *pwrdm, u8 bank, u8 pwrst);
147
148int pwrdm_read_logic_pwrst(struct powerdomain *pwrdm);
149int pwrdm_read_prev_logic_pwrst(struct powerdomain *pwrdm);
150int pwrdm_read_logic_retst(struct powerdomain *pwrdm);
151int pwrdm_read_mem_pwrst(struct powerdomain *pwrdm, u8 bank);
152int pwrdm_read_prev_mem_pwrst(struct powerdomain *pwrdm, u8 bank);
153int pwrdm_read_mem_retst(struct powerdomain *pwrdm, u8 bank);
154
155int pwrdm_enable_hdwr_sar(struct powerdomain *pwrdm);
156int pwrdm_disable_hdwr_sar(struct powerdomain *pwrdm);
157bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm);
158
159int pwrdm_wait_transition(struct powerdomain *pwrdm);
160
161int pwrdm_state_switch(struct powerdomain *pwrdm);
162int pwrdm_clkdm_state_switch(struct clockdomain *clkdm);
163int pwrdm_pre_transition(void);
164int pwrdm_post_transition(void);
165int pwrdm_set_lowpwrstchange(struct powerdomain *pwrdm);
166
167#endif
diff --git a/arch/arm/plat-omap/include/plat/prcm.h b/arch/arm/plat-omap/include/plat/prcm.h
index ab77442e42ab..2fdf8c80d390 100644
--- a/arch/arm/plat-omap/include/plat/prcm.h
+++ b/arch/arm/plat-omap/include/plat/prcm.h
@@ -18,6 +18,10 @@
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * XXX This file is deprecated. The PRCM is an OMAP2+-only subsystem,
23 * so this file doesn't belong in plat-omap/include/plat. Please
24 * do not add anything new to this file.
21 */ 25 */
22 26
23#ifndef __ASM_ARM_ARCH_OMAP_PRCM_H 27#ifndef __ASM_ARM_ARCH_OMAP_PRCM_H
@@ -28,22 +32,6 @@ void omap_prcm_arch_reset(char mode, const char *cmd);
28int omap2_cm_wait_idlest(void __iomem *reg, u32 mask, u8 idlest, 32int omap2_cm_wait_idlest(void __iomem *reg, u32 mask, u8 idlest,
29 const char *name); 33 const char *name);
30 34
31#define START_PADCONF_SAVE 0x2
32#define PADCONF_SAVE_DONE 0x1
33
34void omap3_prcm_save_context(void);
35void omap3_prcm_restore_context(void);
36
37u32 prm_read_mod_reg(s16 module, u16 idx);
38void prm_write_mod_reg(u32 val, s16 module, u16 idx);
39u32 prm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx);
40u32 prm_read_mod_bits_shift(s16 domain, s16 idx, u32 mask);
41u32 omap4_prm_read_bits_shift(void __iomem *reg, u32 mask);
42u32 omap4_prm_rmw_reg_bits(u32 mask, u32 bits, void __iomem *reg);
43u32 cm_read_mod_reg(s16 module, u16 idx);
44void cm_write_mod_reg(u32 val, s16 module, u16 idx);
45u32 cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx);
46
47#endif 35#endif
48 36
49 37
diff --git a/arch/arm/plat-omap/include/plat/serial.h b/arch/arm/plat-omap/include/plat/serial.h
index 19145f5c32ba..cec5d56db2eb 100644
--- a/arch/arm/plat-omap/include/plat/serial.h
+++ b/arch/arm/plat-omap/include/plat/serial.h
@@ -93,9 +93,12 @@
93 }) 93 })
94 94
95#ifndef __ASSEMBLER__ 95#ifndef __ASSEMBLER__
96
97struct omap_board_data;
98
96extern void __init omap_serial_early_init(void); 99extern void __init omap_serial_early_init(void);
97extern void omap_serial_init(void); 100extern void omap_serial_init(void);
98extern void omap_serial_init_port(int port); 101extern void omap_serial_init_port(struct omap_board_data *bdata);
99extern int omap_uart_can_sleep(void); 102extern int omap_uart_can_sleep(void);
100extern void omap_uart_check_wakeup(void); 103extern void omap_uart_check_wakeup(void);
101extern void omap_uart_prepare_suspend(void); 104extern void omap_uart_prepare_suspend(void);
diff --git a/arch/arm/plat-omap/include/plat/smartreflex.h b/arch/arm/plat-omap/include/plat/smartreflex.h
new file mode 100644
index 000000000000..6568c885f37a
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/smartreflex.h
@@ -0,0 +1,245 @@
1/*
2 * OMAP Smartreflex Defines and Routines
3 *
4 * Author: Thara Gopinath <thara@ti.com>
5 *
6 * Copyright (C) 2010 Texas Instruments, Inc.
7 * Thara Gopinath <thara@ti.com>
8 *
9 * Copyright (C) 2008 Nokia Corporation
10 * Kalle Jokiniemi
11 *
12 * Copyright (C) 2007 Texas Instruments, Inc.
13 * Lesly A M <x0080970@ti.com>
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License version 2 as
17 * published by the Free Software Foundation.
18 */
19
20#ifndef __ASM_ARM_OMAP_SMARTREFLEX_H
21#define __ASM_ARM_OMAP_SMARTREFLEX_H
22
23#include <linux/platform_device.h>
24#include <plat/voltage.h>
25
26/*
27 * Different Smartreflex IPs version. The v1 is the 65nm version used in
28 * OMAP3430. The v2 is the update for the 45nm version of the IP
29 * used in OMAP3630 and OMAP4430
30 */
31#define SR_TYPE_V1 1
32#define SR_TYPE_V2 2
33
34/* SMART REFLEX REG ADDRESS OFFSET */
35#define SRCONFIG 0x00
36#define SRSTATUS 0x04
37#define SENVAL 0x08
38#define SENMIN 0x0C
39#define SENMAX 0x10
40#define SENAVG 0x14
41#define AVGWEIGHT 0x18
42#define NVALUERECIPROCAL 0x1c
43#define SENERROR_V1 0x20
44#define ERRCONFIG_V1 0x24
45#define IRQ_EOI 0x20
46#define IRQSTATUS_RAW 0x24
47#define IRQSTATUS 0x28
48#define IRQENABLE_SET 0x2C
49#define IRQENABLE_CLR 0x30
50#define SENERROR_V2 0x34
51#define ERRCONFIG_V2 0x38
52
53/* Bit/Shift Positions */
54
55/* SRCONFIG */
56#define SRCONFIG_ACCUMDATA_SHIFT 22
57#define SRCONFIG_SRCLKLENGTH_SHIFT 12
58#define SRCONFIG_SENNENABLE_V1_SHIFT 5
59#define SRCONFIG_SENPENABLE_V1_SHIFT 3
60#define SRCONFIG_SENNENABLE_V2_SHIFT 1
61#define SRCONFIG_SENPENABLE_V2_SHIFT 0
62#define SRCONFIG_CLKCTRL_SHIFT 0
63
64#define SRCONFIG_ACCUMDATA_MASK (0x3ff << 22)
65
66#define SRCONFIG_SRENABLE BIT(11)
67#define SRCONFIG_SENENABLE BIT(10)
68#define SRCONFIG_ERRGEN_EN BIT(9)
69#define SRCONFIG_MINMAXAVG_EN BIT(8)
70#define SRCONFIG_DELAYCTRL BIT(2)
71
72/* AVGWEIGHT */
73#define AVGWEIGHT_SENPAVGWEIGHT_SHIFT 2
74#define AVGWEIGHT_SENNAVGWEIGHT_SHIFT 0
75
76/* NVALUERECIPROCAL */
77#define NVALUERECIPROCAL_SENPGAIN_SHIFT 20
78#define NVALUERECIPROCAL_SENNGAIN_SHIFT 16
79#define NVALUERECIPROCAL_RNSENP_SHIFT 8
80#define NVALUERECIPROCAL_RNSENN_SHIFT 0
81
82/* ERRCONFIG */
83#define ERRCONFIG_ERRWEIGHT_SHIFT 16
84#define ERRCONFIG_ERRMAXLIMIT_SHIFT 8
85#define ERRCONFIG_ERRMINLIMIT_SHIFT 0
86
87#define SR_ERRWEIGHT_MASK (0x07 << 16)
88#define SR_ERRMAXLIMIT_MASK (0xff << 8)
89#define SR_ERRMINLIMIT_MASK (0xff << 0)
90
91#define ERRCONFIG_VPBOUNDINTEN_V1 BIT(31)
92#define ERRCONFIG_VPBOUNDINTST_V1 BIT(30)
93#define ERRCONFIG_MCUACCUMINTEN BIT(29)
94#define ERRCONFIG_MCUACCUMINTST BIT(28)
95#define ERRCONFIG_MCUVALIDINTEN BIT(27)
96#define ERRCONFIG_MCUVALIDINTST BIT(26)
97#define ERRCONFIG_MCUBOUNDINTEN BIT(25)
98#define ERRCONFIG_MCUBOUNDINTST BIT(24)
99#define ERRCONFIG_MCUDISACKINTEN BIT(23)
100#define ERRCONFIG_VPBOUNDINTST_V2 BIT(23)
101#define ERRCONFIG_MCUDISACKINTST BIT(22)
102#define ERRCONFIG_VPBOUNDINTEN_V2 BIT(22)
103
104#define ERRCONFIG_STATUS_V1_MASK (ERRCONFIG_VPBOUNDINTST_V1 | \
105 ERRCONFIG_MCUACCUMINTST | \
106 ERRCONFIG_MCUVALIDINTST | \
107 ERRCONFIG_MCUBOUNDINTST | \
108 ERRCONFIG_MCUDISACKINTST)
109/* IRQSTATUS */
110#define IRQSTATUS_MCUACCUMINT BIT(3)
111#define IRQSTATUS_MCVALIDINT BIT(2)
112#define IRQSTATUS_MCBOUNDSINT BIT(1)
113#define IRQSTATUS_MCUDISABLEACKINT BIT(0)
114
115/* IRQENABLE_SET and IRQENABLE_CLEAR */
116#define IRQENABLE_MCUACCUMINT BIT(3)
117#define IRQENABLE_MCUVALIDINT BIT(2)
118#define IRQENABLE_MCUBOUNDSINT BIT(1)
119#define IRQENABLE_MCUDISABLEACKINT BIT(0)
120
121/* Common Bit values */
122
123#define SRCLKLENGTH_12MHZ_SYSCLK 0x3c
124#define SRCLKLENGTH_13MHZ_SYSCLK 0x41
125#define SRCLKLENGTH_19MHZ_SYSCLK 0x60
126#define SRCLKLENGTH_26MHZ_SYSCLK 0x82
127#define SRCLKLENGTH_38MHZ_SYSCLK 0xC0
128
129/*
130 * 3430 specific values. Maybe these should be passed from board file or
131 * pmic structures.
132 */
133#define OMAP3430_SR_ACCUMDATA 0x1f4
134
135#define OMAP3430_SR1_SENPAVGWEIGHT 0x03
136#define OMAP3430_SR1_SENNAVGWEIGHT 0x03
137
138#define OMAP3430_SR2_SENPAVGWEIGHT 0x01
139#define OMAP3430_SR2_SENNAVGWEIGHT 0x01
140
141#define OMAP3430_SR_ERRWEIGHT 0x04
142#define OMAP3430_SR_ERRMAXLIMIT 0x02
143
144/**
145 * struct omap_sr_pmic_data - Strucutre to be populated by pmic code to pass
146 * pmic specific info to smartreflex driver
147 *
148 * @sr_pmic_init: API to initialize smartreflex on the PMIC side.
149 */
150struct omap_sr_pmic_data {
151 void (*sr_pmic_init) (void);
152};
153
154#ifdef CONFIG_OMAP_SMARTREFLEX
155/*
156 * The smart reflex driver supports CLASS1 CLASS2 and CLASS3 SR.
157 * The smartreflex class driver should pass the class type.
158 * Should be used to populate the class_type field of the
159 * omap_smartreflex_class_data structure.
160 */
161#define SR_CLASS1 0x1
162#define SR_CLASS2 0x2
163#define SR_CLASS3 0x3
164
165/**
166 * struct omap_sr_class_data - Smartreflex class driver info
167 *
168 * @enable: API to enable a particular class smaartreflex.
169 * @disable: API to disable a particular class smartreflex.
170 * @configure: API to configure a particular class smartreflex.
171 * @notify: API to notify the class driver about an event in SR.
172 * Not needed for class3.
173 * @notify_flags: specify the events to be notified to the class driver
174 * @class_type: specify which smartreflex class.
175 * Can be used by the SR driver to take any class
176 * based decisions.
177 */
178struct omap_sr_class_data {
179 int (*enable)(struct voltagedomain *voltdm);
180 int (*disable)(struct voltagedomain *voltdm, int is_volt_reset);
181 int (*configure)(struct voltagedomain *voltdm);
182 int (*notify)(struct voltagedomain *voltdm, u32 status);
183 u8 notify_flags;
184 u8 class_type;
185};
186
187/**
188 * struct omap_sr_nvalue_table - Smartreflex n-target value info
189 *
190 * @efuse_offs: The offset of the efuse where n-target values are stored.
191 * @nvalue: The n-target value.
192 */
193struct omap_sr_nvalue_table {
194 u32 efuse_offs;
195 u32 nvalue;
196};
197
198/**
199 * struct omap_sr_data - Smartreflex platform data.
200 *
201 * @ip_type: Smartreflex IP type.
202 * @senp_mod: SENPENABLE value for the sr
203 * @senn_mod: SENNENABLE value for sr
204 * @nvalue_count: Number of distinct nvalues in the nvalue table
205 * @enable_on_init: whether this sr module needs to enabled at
206 * boot up or not.
207 * @nvalue_table: table containing the efuse offsets and nvalues
208 * corresponding to them.
209 * @voltdm: Pointer to the voltage domain associated with the SR
210 */
211struct omap_sr_data {
212 int ip_type;
213 u32 senp_mod;
214 u32 senn_mod;
215 int nvalue_count;
216 bool enable_on_init;
217 struct omap_sr_nvalue_table *nvalue_table;
218 struct voltagedomain *voltdm;
219};
220
221/* Smartreflex module enable/disable interface */
222void omap_sr_enable(struct voltagedomain *voltdm);
223void omap_sr_disable(struct voltagedomain *voltdm);
224void omap_sr_disable_reset_volt(struct voltagedomain *voltdm);
225
226/* API to register the pmic specific data with the smartreflex driver. */
227void omap_sr_register_pmic(struct omap_sr_pmic_data *pmic_data);
228
229/* Smartreflex driver hooks to be called from Smartreflex class driver */
230int sr_enable(struct voltagedomain *voltdm, unsigned long volt);
231void sr_disable(struct voltagedomain *voltdm);
232int sr_configure_errgen(struct voltagedomain *voltdm);
233int sr_configure_minmax(struct voltagedomain *voltdm);
234
235/* API to register the smartreflex class driver with the smartreflex driver */
236int sr_register_class(struct omap_sr_class_data *class_data);
237#else
238static inline void omap_sr_enable(struct voltagedomain *voltdm) {}
239static inline void omap_sr_disable(struct voltagedomain *voltdm) {}
240static inline void omap_sr_disable_reset_volt(
241 struct voltagedomain *voltdm) {}
242static inline void omap_sr_register_pmic(
243 struct omap_sr_pmic_data *pmic_data) {}
244#endif
245#endif
diff --git a/arch/arm/plat-omap/include/plat/sram.h b/arch/arm/plat-omap/include/plat/sram.h
index 5905100b29a1..9967d5e855c7 100644
--- a/arch/arm/plat-omap/include/plat/sram.h
+++ b/arch/arm/plat-omap/include/plat/sram.h
@@ -11,6 +11,7 @@
11#ifndef __ARCH_ARM_OMAP_SRAM_H 11#ifndef __ARCH_ARM_OMAP_SRAM_H
12#define __ARCH_ARM_OMAP_SRAM_H 12#define __ARCH_ARM_OMAP_SRAM_H
13 13
14#ifndef __ASSEMBLY__
14extern void * omap_sram_push(void * start, unsigned long size); 15extern void * omap_sram_push(void * start, unsigned long size);
15extern void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl); 16extern void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl);
16 17
@@ -74,4 +75,14 @@ extern void omap_push_sram_idle(void);
74static inline void omap_push_sram_idle(void) {} 75static inline void omap_push_sram_idle(void) {}
75#endif /* CONFIG_PM */ 76#endif /* CONFIG_PM */
76 77
78#endif /* __ASSEMBLY__ */
79
80/*
81 * OMAP2+: define the SRAM PA addresses.
82 * Used by the SRAM management code and the idle sleep code.
83 */
84#define OMAP2_SRAM_PA 0x40200000
85#define OMAP3_SRAM_PA 0x40200000
86#define OMAP4_SRAM_PA 0x40300000
87
77#endif 88#endif
diff --git a/arch/arm/plat-omap/include/plat/uncompress.h b/arch/arm/plat-omap/include/plat/uncompress.h
index 9036e374e0ac..ad98b85cae21 100644
--- a/arch/arm/plat-omap/include/plat/uncompress.h
+++ b/arch/arm/plat-omap/include/plat/uncompress.h
@@ -145,8 +145,11 @@ static inline void __arch_decomp_setup(unsigned long arch_id)
145 /* omap3 based boards using UART3 */ 145 /* omap3 based boards using UART3 */
146 DEBUG_LL_OMAP3(3, cm_t35); 146 DEBUG_LL_OMAP3(3, cm_t35);
147 DEBUG_LL_OMAP3(3, cm_t3517); 147 DEBUG_LL_OMAP3(3, cm_t3517);
148 DEBUG_LL_OMAP3(3, craneboard);
149 DEBUG_LL_OMAP3(3, devkit8000);
148 DEBUG_LL_OMAP3(3, igep0020); 150 DEBUG_LL_OMAP3(3, igep0020);
149 DEBUG_LL_OMAP3(3, igep0030); 151 DEBUG_LL_OMAP3(3, igep0030);
152 DEBUG_LL_OMAP3(3, nokia_rm680);
150 DEBUG_LL_OMAP3(3, nokia_rx51); 153 DEBUG_LL_OMAP3(3, nokia_rx51);
151 DEBUG_LL_OMAP3(3, omap3517evm); 154 DEBUG_LL_OMAP3(3, omap3517evm);
152 DEBUG_LL_OMAP3(3, omap3_beagle); 155 DEBUG_LL_OMAP3(3, omap3_beagle);
diff --git a/arch/arm/plat-omap/include/plat/voltage.h b/arch/arm/plat-omap/include/plat/voltage.h
new file mode 100644
index 000000000000..0ff123399f3b
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/voltage.h
@@ -0,0 +1,146 @@
1/*
2 * OMAP Voltage Management Routines
3 *
4 * Author: Thara Gopinath <thara@ti.com>
5 *
6 * Copyright (C) 2009 Texas Instruments, Inc.
7 * Thara Gopinath <thara@ti.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#ifndef __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
15#define __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
16
17#define VOLTSCALE_VPFORCEUPDATE 1
18#define VOLTSCALE_VCBYPASS 2
19
20/*
21 * OMAP3 GENERIC setup times. Revisit to see if these needs to be
22 * passed from board or PMIC file
23 */
24#define OMAP3_CLKSETUP 0xff
25#define OMAP3_VOLTOFFSET 0xff
26#define OMAP3_VOLTSETUP2 0xff
27
28/* Voltage value defines */
29#define OMAP3430_VDD_MPU_OPP1_UV 975000
30#define OMAP3430_VDD_MPU_OPP2_UV 1075000
31#define OMAP3430_VDD_MPU_OPP3_UV 1200000
32#define OMAP3430_VDD_MPU_OPP4_UV 1270000
33#define OMAP3430_VDD_MPU_OPP5_UV 1350000
34
35#define OMAP3430_VDD_CORE_OPP1_UV 975000
36#define OMAP3430_VDD_CORE_OPP2_UV 1050000
37#define OMAP3430_VDD_CORE_OPP3_UV 1150000
38
39#define OMAP3630_VDD_MPU_OPP50_UV 1012500
40#define OMAP3630_VDD_MPU_OPP100_UV 1200000
41#define OMAP3630_VDD_MPU_OPP120_UV 1325000
42#define OMAP3630_VDD_MPU_OPP1G_UV 1375000
43
44#define OMAP3630_VDD_CORE_OPP50_UV 1000000
45#define OMAP3630_VDD_CORE_OPP100_UV 1200000
46
47#define OMAP4430_VDD_MPU_OPP50_UV 930000
48#define OMAP4430_VDD_MPU_OPP100_UV 1100000
49#define OMAP4430_VDD_MPU_OPPTURBO_UV 1260000
50#define OMAP4430_VDD_MPU_OPPNITRO_UV 1350000
51
52#define OMAP4430_VDD_IVA_OPP50_UV 930000
53#define OMAP4430_VDD_IVA_OPP100_UV 1100000
54#define OMAP4430_VDD_IVA_OPPTURBO_UV 1260000
55
56#define OMAP4430_VDD_CORE_OPP50_UV 930000
57#define OMAP4430_VDD_CORE_OPP100_UV 1100000
58
59/**
60 * struct voltagedomain - omap voltage domain global structure.
61 * @name: Name of the voltage domain which can be used as a unique
62 * identifier.
63 */
64struct voltagedomain {
65 char *name;
66};
67
68/* API to get the voltagedomain pointer */
69struct voltagedomain *omap_voltage_domain_lookup(char *name);
70
71/**
72 * struct omap_volt_data - Omap voltage specific data.
73 * @voltage_nominal: The possible voltage value in uV
74 * @sr_efuse_offs: The offset of the efuse register(from system
75 * control module base address) from where to read
76 * the n-target value for the smartreflex module.
77 * @sr_errminlimit: Error min limit value for smartreflex. This value
78 * differs at differnet opp and thus is linked
79 * with voltage.
80 * @vp_errorgain: Error gain value for the voltage processor. This
81 * field also differs according to the voltage/opp.
82 */
83struct omap_volt_data {
84 u32 volt_nominal;
85 u32 sr_efuse_offs;
86 u8 sr_errminlimit;
87 u8 vp_errgain;
88};
89
90/**
91 * struct omap_volt_pmic_info - PMIC specific data required by voltage driver.
92 * @slew_rate: PMIC slew rate (in uv/us)
93 * @step_size: PMIC voltage step size (in uv)
94 * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV.
95 * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value.
96 */
97struct omap_volt_pmic_info {
98 int slew_rate;
99 int step_size;
100 u32 on_volt;
101 u32 onlp_volt;
102 u32 ret_volt;
103 u32 off_volt;
104 u16 volt_setup_time;
105 u8 vp_erroroffset;
106 u8 vp_vstepmin;
107 u8 vp_vstepmax;
108 u8 vp_vddmin;
109 u8 vp_vddmax;
110 u8 vp_timeout_us;
111 u8 i2c_slave_addr;
112 u8 pmic_reg;
113 unsigned long (*vsel_to_uv) (const u8 vsel);
114 u8 (*uv_to_vsel) (unsigned long uV);
115};
116
117unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm);
118void omap_vp_enable(struct voltagedomain *voltdm);
119void omap_vp_disable(struct voltagedomain *voltdm);
120int omap_voltage_scale_vdd(struct voltagedomain *voltdm,
121 unsigned long target_volt);
122void omap_voltage_reset(struct voltagedomain *voltdm);
123void omap_voltage_get_volttable(struct voltagedomain *voltdm,
124 struct omap_volt_data **volt_data);
125struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
126 unsigned long volt);
127unsigned long omap_voltage_get_nom_volt(struct voltagedomain *voltdm);
128struct dentry *omap_voltage_get_dbgdir(struct voltagedomain *voltdm);
129#ifdef CONFIG_PM
130int omap_voltage_register_pmic(struct voltagedomain *voltdm,
131 struct omap_volt_pmic_info *pmic_info);
132void omap_change_voltscale_method(struct voltagedomain *voltdm,
133 int voltscale_method);
134int omap_voltage_late_init(void);
135#else
136static inline int omap_voltage_register_pmic(struct voltagedomain *voltdm,
137 struct omap_volt_pmic_info *pmic_info) {}
138static inline void omap_change_voltscale_method(struct voltagedomain *voltdm,
139 int voltscale_method) {}
140static inline int omap_voltage_late_init(void)
141{
142 return -EINVAL;
143}
144#endif
145
146#endif
diff --git a/arch/arm/plat-omap/io.c b/arch/arm/plat-omap/io.c
index b0078cf96281..f1295fafcd31 100644
--- a/arch/arm/plat-omap/io.c
+++ b/arch/arm/plat-omap/io.c
@@ -136,61 +136,3 @@ void omap_iounmap(volatile void __iomem *addr)
136 __iounmap(addr); 136 __iounmap(addr);
137} 137}
138EXPORT_SYMBOL(omap_iounmap); 138EXPORT_SYMBOL(omap_iounmap);
139
140/*
141 * NOTE: Please use ioremap + __raw_read/write where possible instead of these
142 */
143
144u8 omap_readb(u32 pa)
145{
146 if (cpu_class_is_omap1())
147 return __raw_readb(OMAP1_IO_ADDRESS(pa));
148 else
149 return __raw_readb(OMAP2_L4_IO_ADDRESS(pa));
150}
151EXPORT_SYMBOL(omap_readb);
152
153u16 omap_readw(u32 pa)
154{
155 if (cpu_class_is_omap1())
156 return __raw_readw(OMAP1_IO_ADDRESS(pa));
157 else
158 return __raw_readw(OMAP2_L4_IO_ADDRESS(pa));
159}
160EXPORT_SYMBOL(omap_readw);
161
162u32 omap_readl(u32 pa)
163{
164 if (cpu_class_is_omap1())
165 return __raw_readl(OMAP1_IO_ADDRESS(pa));
166 else
167 return __raw_readl(OMAP2_L4_IO_ADDRESS(pa));
168}
169EXPORT_SYMBOL(omap_readl);
170
171void omap_writeb(u8 v, u32 pa)
172{
173 if (cpu_class_is_omap1())
174 __raw_writeb(v, OMAP1_IO_ADDRESS(pa));
175 else
176 __raw_writeb(v, OMAP2_L4_IO_ADDRESS(pa));
177}
178EXPORT_SYMBOL(omap_writeb);
179
180void omap_writew(u16 v, u32 pa)
181{
182 if (cpu_class_is_omap1())
183 __raw_writew(v, OMAP1_IO_ADDRESS(pa));
184 else
185 __raw_writew(v, OMAP2_L4_IO_ADDRESS(pa));
186}
187EXPORT_SYMBOL(omap_writew);
188
189void omap_writel(u32 v, u32 pa)
190{
191 if (cpu_class_is_omap1())
192 __raw_writel(v, OMAP1_IO_ADDRESS(pa));
193 else
194 __raw_writel(v, OMAP2_L4_IO_ADDRESS(pa));
195}
196EXPORT_SYMBOL(omap_writel);
diff --git a/arch/arm/plat-omap/iommu.c b/arch/arm/plat-omap/iommu.c
index 6cd151b31bc5..b1107c08da56 100644
--- a/arch/arm/plat-omap/iommu.c
+++ b/arch/arm/plat-omap/iommu.c
@@ -830,6 +830,28 @@ static int device_match_by_alias(struct device *dev, void *data)
830} 830}
831 831
832/** 832/**
833 * iommu_set_da_range - Set a valid device address range
834 * @obj: target iommu
835 * @start Start of valid range
836 * @end End of valid range
837 **/
838int iommu_set_da_range(struct iommu *obj, u32 start, u32 end)
839{
840
841 if (!obj)
842 return -EFAULT;
843
844 if (end < start || !PAGE_ALIGN(start | end))
845 return -EINVAL;
846
847 obj->da_start = start;
848 obj->da_end = end;
849
850 return 0;
851}
852EXPORT_SYMBOL_GPL(iommu_set_da_range);
853
854/**
833 * iommu_get - Get iommu handler 855 * iommu_get - Get iommu handler
834 * @name: target iommu name 856 * @name: target iommu name
835 **/ 857 **/
@@ -922,6 +944,8 @@ static int __devinit omap_iommu_probe(struct platform_device *pdev)
922 obj->name = pdata->name; 944 obj->name = pdata->name;
923 obj->dev = &pdev->dev; 945 obj->dev = &pdev->dev;
924 obj->ctx = (void *)obj + sizeof(*obj); 946 obj->ctx = (void *)obj + sizeof(*obj);
947 obj->da_start = pdata->da_start;
948 obj->da_end = pdata->da_end;
925 949
926 mutex_init(&obj->iommu_lock); 950 mutex_init(&obj->iommu_lock);
927 mutex_init(&obj->mmap_lock); 951 mutex_init(&obj->mmap_lock);
diff --git a/arch/arm/plat-omap/iovmm.c b/arch/arm/plat-omap/iovmm.c
index 8ce0de247c71..6dc1296c8c77 100644
--- a/arch/arm/plat-omap/iovmm.c
+++ b/arch/arm/plat-omap/iovmm.c
@@ -87,35 +87,43 @@ static size_t sgtable_len(const struct sg_table *sgt)
87} 87}
88#define sgtable_ok(x) (!!sgtable_len(x)) 88#define sgtable_ok(x) (!!sgtable_len(x))
89 89
90static unsigned max_alignment(u32 addr)
91{
92 int i;
93 unsigned pagesize[] = { SZ_16M, SZ_1M, SZ_64K, SZ_4K, };
94 for (i = 0; i < ARRAY_SIZE(pagesize) && addr & (pagesize[i] - 1); i++)
95 ;
96 return (i < ARRAY_SIZE(pagesize)) ? pagesize[i] : 0;
97}
98
90/* 99/*
91 * calculate the optimal number sg elements from total bytes based on 100 * calculate the optimal number sg elements from total bytes based on
92 * iommu superpages 101 * iommu superpages
93 */ 102 */
94static unsigned int sgtable_nents(size_t bytes) 103static unsigned sgtable_nents(size_t bytes, u32 da, u32 pa)
95{ 104{
96 int i; 105 unsigned nr_entries = 0, ent_sz;
97 unsigned int nr_entries;
98 const unsigned long pagesize[] = { SZ_16M, SZ_1M, SZ_64K, SZ_4K, };
99 106
100 if (!IS_ALIGNED(bytes, PAGE_SIZE)) { 107 if (!IS_ALIGNED(bytes, PAGE_SIZE)) {
101 pr_err("%s: wrong size %08x\n", __func__, bytes); 108 pr_err("%s: wrong size %08x\n", __func__, bytes);
102 return 0; 109 return 0;
103 } 110 }
104 111
105 nr_entries = 0; 112 while (bytes) {
106 for (i = 0; i < ARRAY_SIZE(pagesize); i++) { 113 ent_sz = max_alignment(da | pa);
107 if (bytes >= pagesize[i]) { 114 ent_sz = min_t(unsigned, ent_sz, iopgsz_max(bytes));
108 nr_entries += (bytes / pagesize[i]); 115 nr_entries++;
109 bytes %= pagesize[i]; 116 da += ent_sz;
110 } 117 pa += ent_sz;
118 bytes -= ent_sz;
111 } 119 }
112 BUG_ON(bytes);
113 120
114 return nr_entries; 121 return nr_entries;
115} 122}
116 123
117/* allocate and initialize sg_table header(a kind of 'superblock') */ 124/* allocate and initialize sg_table header(a kind of 'superblock') */
118static struct sg_table *sgtable_alloc(const size_t bytes, u32 flags) 125static struct sg_table *sgtable_alloc(const size_t bytes, u32 flags,
126 u32 da, u32 pa)
119{ 127{
120 unsigned int nr_entries; 128 unsigned int nr_entries;
121 int err; 129 int err;
@@ -127,9 +135,8 @@ static struct sg_table *sgtable_alloc(const size_t bytes, u32 flags)
127 if (!IS_ALIGNED(bytes, PAGE_SIZE)) 135 if (!IS_ALIGNED(bytes, PAGE_SIZE))
128 return ERR_PTR(-EINVAL); 136 return ERR_PTR(-EINVAL);
129 137
130 /* FIXME: IOVMF_DA_FIXED should support 'superpages' */ 138 if (flags & IOVMF_LINEAR) {
131 if ((flags & IOVMF_LINEAR) && (flags & IOVMF_DA_ANON)) { 139 nr_entries = sgtable_nents(bytes, da, pa);
132 nr_entries = sgtable_nents(bytes);
133 if (!nr_entries) 140 if (!nr_entries)
134 return ERR_PTR(-EINVAL); 141 return ERR_PTR(-EINVAL);
135 } else 142 } else
@@ -273,13 +280,14 @@ static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da,
273 alignement = PAGE_SIZE; 280 alignement = PAGE_SIZE;
274 281
275 if (flags & IOVMF_DA_ANON) { 282 if (flags & IOVMF_DA_ANON) {
276 /* 283 start = obj->da_start;
277 * Reserve the first page for NULL 284
278 */
279 start = PAGE_SIZE;
280 if (flags & IOVMF_LINEAR) 285 if (flags & IOVMF_LINEAR)
281 alignement = iopgsz_max(bytes); 286 alignement = iopgsz_max(bytes);
282 start = roundup(start, alignement); 287 start = roundup(start, alignement);
288 } else if (start < obj->da_start || start > obj->da_end ||
289 obj->da_end - start < bytes) {
290 return ERR_PTR(-EINVAL);
283 } 291 }
284 292
285 tmp = NULL; 293 tmp = NULL;
@@ -289,19 +297,19 @@ static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da,
289 prev_end = 0; 297 prev_end = 0;
290 list_for_each_entry(tmp, &obj->mmap, list) { 298 list_for_each_entry(tmp, &obj->mmap, list) {
291 299
292 if (prev_end >= start) 300 if (prev_end > start)
293 break; 301 break;
294 302
295 if (start + bytes < tmp->da_start) 303 if (tmp->da_start > start && (tmp->da_start - start) >= bytes)
296 goto found; 304 goto found;
297 305
298 if (flags & IOVMF_DA_ANON) 306 if (tmp->da_end >= start && flags & IOVMF_DA_ANON)
299 start = roundup(tmp->da_end + 1, alignement); 307 start = roundup(tmp->da_end + 1, alignement);
300 308
301 prev_end = tmp->da_end; 309 prev_end = tmp->da_end;
302 } 310 }
303 311
304 if ((start > prev_end) && (ULONG_MAX - start >= bytes)) 312 if ((start >= prev_end) && (obj->da_end - start >= bytes))
305 goto found; 313 goto found;
306 314
307 dev_dbg(obj->dev, "%s: no space to fit %08x(%x) flags: %08x\n", 315 dev_dbg(obj->dev, "%s: no space to fit %08x(%x) flags: %08x\n",
@@ -409,7 +417,8 @@ static inline void sgtable_drain_vmalloc(struct sg_table *sgt)
409 BUG_ON(!sgt); 417 BUG_ON(!sgt);
410} 418}
411 419
412static void sgtable_fill_kmalloc(struct sg_table *sgt, u32 pa, size_t len) 420static void sgtable_fill_kmalloc(struct sg_table *sgt, u32 pa, u32 da,
421 size_t len)
413{ 422{
414 unsigned int i; 423 unsigned int i;
415 struct scatterlist *sg; 424 struct scatterlist *sg;
@@ -418,9 +427,10 @@ static void sgtable_fill_kmalloc(struct sg_table *sgt, u32 pa, size_t len)
418 va = phys_to_virt(pa); 427 va = phys_to_virt(pa);
419 428
420 for_each_sg(sgt->sgl, sg, sgt->nents, i) { 429 for_each_sg(sgt->sgl, sg, sgt->nents, i) {
421 size_t bytes; 430 unsigned bytes;
422 431
423 bytes = iopgsz_max(len); 432 bytes = max_alignment(da | pa);
433 bytes = min_t(unsigned, bytes, iopgsz_max(len));
424 434
425 BUG_ON(!iopgsz_ok(bytes)); 435 BUG_ON(!iopgsz_ok(bytes));
426 436
@@ -429,6 +439,7 @@ static void sgtable_fill_kmalloc(struct sg_table *sgt, u32 pa, size_t len)
429 * 'pa' is cotinuous(linear). 439 * 'pa' is cotinuous(linear).
430 */ 440 */
431 pa += bytes; 441 pa += bytes;
442 da += bytes;
432 len -= bytes; 443 len -= bytes;
433 } 444 }
434 BUG_ON(len); 445 BUG_ON(len);
@@ -695,18 +706,18 @@ u32 iommu_vmalloc(struct iommu *obj, u32 da, size_t bytes, u32 flags)
695 if (!va) 706 if (!va)
696 return -ENOMEM; 707 return -ENOMEM;
697 708
698 sgt = sgtable_alloc(bytes, flags); 709 flags &= IOVMF_HW_MASK;
710 flags |= IOVMF_DISCONT;
711 flags |= IOVMF_ALLOC;
712 flags |= (da ? IOVMF_DA_FIXED : IOVMF_DA_ANON);
713
714 sgt = sgtable_alloc(bytes, flags, da, 0);
699 if (IS_ERR(sgt)) { 715 if (IS_ERR(sgt)) {
700 da = PTR_ERR(sgt); 716 da = PTR_ERR(sgt);
701 goto err_sgt_alloc; 717 goto err_sgt_alloc;
702 } 718 }
703 sgtable_fill_vmalloc(sgt, va); 719 sgtable_fill_vmalloc(sgt, va);
704 720
705 flags &= IOVMF_HW_MASK;
706 flags |= IOVMF_DISCONT;
707 flags |= IOVMF_ALLOC;
708 flags |= (da ? IOVMF_DA_FIXED : IOVMF_DA_ANON);
709
710 da = __iommu_vmap(obj, da, sgt, va, bytes, flags); 721 da = __iommu_vmap(obj, da, sgt, va, bytes, flags);
711 if (IS_ERR_VALUE(da)) 722 if (IS_ERR_VALUE(da))
712 goto err_iommu_vmap; 723 goto err_iommu_vmap;
@@ -746,11 +757,11 @@ static u32 __iommu_kmap(struct iommu *obj, u32 da, u32 pa, void *va,
746{ 757{
747 struct sg_table *sgt; 758 struct sg_table *sgt;
748 759
749 sgt = sgtable_alloc(bytes, flags); 760 sgt = sgtable_alloc(bytes, flags, da, pa);
750 if (IS_ERR(sgt)) 761 if (IS_ERR(sgt))
751 return PTR_ERR(sgt); 762 return PTR_ERR(sgt);
752 763
753 sgtable_fill_kmalloc(sgt, pa, bytes); 764 sgtable_fill_kmalloc(sgt, pa, da, bytes);
754 765
755 da = map_iommu_region(obj, da, sgt, va, bytes, flags); 766 da = map_iommu_region(obj, da, sgt, va, bytes, flags);
756 if (IS_ERR_VALUE(da)) { 767 if (IS_ERR_VALUE(da)) {
@@ -811,7 +822,7 @@ void iommu_kunmap(struct iommu *obj, u32 da)
811 struct sg_table *sgt; 822 struct sg_table *sgt;
812 typedef void (*func_t)(const void *); 823 typedef void (*func_t)(const void *);
813 824
814 sgt = unmap_vm_area(obj, da, (func_t)__iounmap, 825 sgt = unmap_vm_area(obj, da, (func_t)iounmap,
815 IOVMF_LINEAR | IOVMF_MMIO); 826 IOVMF_LINEAR | IOVMF_MMIO);
816 if (!sgt) 827 if (!sgt)
817 dev_dbg(obj->dev, "%s: No sgt\n", __func__); 828 dev_dbg(obj->dev, "%s: No sgt\n", __func__);
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index d2fafb892f7f..459b319a9fad 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -28,12 +28,12 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/kfifo.h> 29#include <linux/kfifo.h>
30#include <linux/err.h> 30#include <linux/err.h>
31#include <linux/notifier.h>
31 32
32#include <plat/mailbox.h> 33#include <plat/mailbox.h>
33 34
34static struct workqueue_struct *mboxd; 35static struct workqueue_struct *mboxd;
35static struct omap_mbox **mboxes; 36static struct omap_mbox **mboxes;
36static bool rq_full;
37 37
38static int mbox_configured; 38static int mbox_configured;
39static DEFINE_MUTEX(mbox_configured_lock); 39static DEFINE_MUTEX(mbox_configured_lock);
@@ -93,20 +93,25 @@ int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
93 struct omap_mbox_queue *mq = mbox->txq; 93 struct omap_mbox_queue *mq = mbox->txq;
94 int ret = 0, len; 94 int ret = 0, len;
95 95
96 spin_lock(&mq->lock); 96 spin_lock_bh(&mq->lock);
97 97
98 if (kfifo_avail(&mq->fifo) < sizeof(msg)) { 98 if (kfifo_avail(&mq->fifo) < sizeof(msg)) {
99 ret = -ENOMEM; 99 ret = -ENOMEM;
100 goto out; 100 goto out;
101 } 101 }
102 102
103 if (kfifo_is_empty(&mq->fifo) && !__mbox_poll_for_space(mbox)) {
104 mbox_fifo_write(mbox, msg);
105 goto out;
106 }
107
103 len = kfifo_in(&mq->fifo, (unsigned char *)&msg, sizeof(msg)); 108 len = kfifo_in(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
104 WARN_ON(len != sizeof(msg)); 109 WARN_ON(len != sizeof(msg));
105 110
106 tasklet_schedule(&mbox->txq->tasklet); 111 tasklet_schedule(&mbox->txq->tasklet);
107 112
108out: 113out:
109 spin_unlock(&mq->lock); 114 spin_unlock_bh(&mq->lock);
110 return ret; 115 return ret;
111} 116}
112EXPORT_SYMBOL(omap_mbox_msg_send); 117EXPORT_SYMBOL(omap_mbox_msg_send);
@@ -146,8 +151,14 @@ static void mbox_rx_work(struct work_struct *work)
146 len = kfifo_out(&mq->fifo, (unsigned char *)&msg, sizeof(msg)); 151 len = kfifo_out(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
147 WARN_ON(len != sizeof(msg)); 152 WARN_ON(len != sizeof(msg));
148 153
149 if (mq->callback) 154 blocking_notifier_call_chain(&mq->mbox->notifier, len,
150 mq->callback((void *)msg); 155 (void *)msg);
156 spin_lock_irq(&mq->lock);
157 if (mq->full) {
158 mq->full = false;
159 omap_mbox_enable_irq(mq->mbox, IRQ_RX);
160 }
161 spin_unlock_irq(&mq->lock);
151 } 162 }
152} 163}
153 164
@@ -170,7 +181,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
170 while (!mbox_fifo_empty(mbox)) { 181 while (!mbox_fifo_empty(mbox)) {
171 if (unlikely(kfifo_avail(&mq->fifo) < sizeof(msg))) { 182 if (unlikely(kfifo_avail(&mq->fifo) < sizeof(msg))) {
172 omap_mbox_disable_irq(mbox, IRQ_RX); 183 omap_mbox_disable_irq(mbox, IRQ_RX);
173 rq_full = true; 184 mq->full = true;
174 goto nomem; 185 goto nomem;
175 } 186 }
176 187
@@ -239,73 +250,77 @@ static int omap_mbox_startup(struct omap_mbox *mbox)
239 int ret = 0; 250 int ret = 0;
240 struct omap_mbox_queue *mq; 251 struct omap_mbox_queue *mq;
241 252
242 if (mbox->ops->startup) { 253 mutex_lock(&mbox_configured_lock);
243 mutex_lock(&mbox_configured_lock); 254 if (!mbox_configured++) {
244 if (!mbox_configured) 255 if (likely(mbox->ops->startup)) {
245 ret = mbox->ops->startup(mbox); 256 ret = mbox->ops->startup(mbox);
246 257 if (unlikely(ret))
247 if (ret) { 258 goto fail_startup;
248 mutex_unlock(&mbox_configured_lock); 259 } else
249 return ret; 260 goto fail_startup;
250 }
251 mbox_configured++;
252 mutex_unlock(&mbox_configured_lock);
253 }
254
255 ret = request_irq(mbox->irq, mbox_interrupt, IRQF_SHARED,
256 mbox->name, mbox);
257 if (ret) {
258 printk(KERN_ERR
259 "failed to register mailbox interrupt:%d\n", ret);
260 goto fail_request_irq;
261 } 261 }
262 262
263 mq = mbox_queue_alloc(mbox, NULL, mbox_tx_tasklet); 263 if (!mbox->use_count++) {
264 if (!mq) { 264 ret = request_irq(mbox->irq, mbox_interrupt, IRQF_SHARED,
265 ret = -ENOMEM; 265 mbox->name, mbox);
266 goto fail_alloc_txq; 266 if (unlikely(ret)) {
267 } 267 pr_err("failed to register mailbox interrupt:%d\n",
268 mbox->txq = mq; 268 ret);
269 goto fail_request_irq;
270 }
271 mq = mbox_queue_alloc(mbox, NULL, mbox_tx_tasklet);
272 if (!mq) {
273 ret = -ENOMEM;
274 goto fail_alloc_txq;
275 }
276 mbox->txq = mq;
269 277
270 mq = mbox_queue_alloc(mbox, mbox_rx_work, NULL); 278 mq = mbox_queue_alloc(mbox, mbox_rx_work, NULL);
271 if (!mq) { 279 if (!mq) {
272 ret = -ENOMEM; 280 ret = -ENOMEM;
273 goto fail_alloc_rxq; 281 goto fail_alloc_rxq;
282 }
283 mbox->rxq = mq;
284 mq->mbox = mbox;
274 } 285 }
275 mbox->rxq = mq; 286 mutex_unlock(&mbox_configured_lock);
276
277 return 0; 287 return 0;
278 288
279 fail_alloc_rxq: 289fail_alloc_rxq:
280 mbox_queue_free(mbox->txq); 290 mbox_queue_free(mbox->txq);
281 fail_alloc_txq: 291fail_alloc_txq:
282 free_irq(mbox->irq, mbox); 292 free_irq(mbox->irq, mbox);
283 fail_request_irq: 293fail_request_irq:
284 if (mbox->ops->shutdown) 294 if (mbox->ops->shutdown)
285 mbox->ops->shutdown(mbox); 295 mbox->ops->shutdown(mbox);
286 296 mbox->use_count--;
297fail_startup:
298 mbox_configured--;
299 mutex_unlock(&mbox_configured_lock);
287 return ret; 300 return ret;
288} 301}
289 302
290static void omap_mbox_fini(struct omap_mbox *mbox) 303static void omap_mbox_fini(struct omap_mbox *mbox)
291{ 304{
292 free_irq(mbox->irq, mbox); 305 mutex_lock(&mbox_configured_lock);
293 tasklet_kill(&mbox->txq->tasklet); 306
294 flush_work(&mbox->rxq->work); 307 if (!--mbox->use_count) {
295 mbox_queue_free(mbox->txq); 308 free_irq(mbox->irq, mbox);
296 mbox_queue_free(mbox->rxq); 309 tasklet_kill(&mbox->txq->tasklet);
310 flush_work(&mbox->rxq->work);
311 mbox_queue_free(mbox->txq);
312 mbox_queue_free(mbox->rxq);
313 }
297 314
298 if (mbox->ops->shutdown) { 315 if (likely(mbox->ops->shutdown)) {
299 mutex_lock(&mbox_configured_lock); 316 if (!--mbox_configured)
300 if (mbox_configured > 0)
301 mbox_configured--;
302 if (!mbox_configured)
303 mbox->ops->shutdown(mbox); 317 mbox->ops->shutdown(mbox);
304 mutex_unlock(&mbox_configured_lock);
305 } 318 }
319
320 mutex_unlock(&mbox_configured_lock);
306} 321}
307 322
308struct omap_mbox *omap_mbox_get(const char *name) 323struct omap_mbox *omap_mbox_get(const char *name, struct notifier_block *nb)
309{ 324{
310 struct omap_mbox *mbox; 325 struct omap_mbox *mbox;
311 int ret; 326 int ret;
@@ -324,12 +339,16 @@ struct omap_mbox *omap_mbox_get(const char *name)
324 if (ret) 339 if (ret)
325 return ERR_PTR(-ENODEV); 340 return ERR_PTR(-ENODEV);
326 341
342 if (nb)
343 blocking_notifier_chain_register(&mbox->notifier, nb);
344
327 return mbox; 345 return mbox;
328} 346}
329EXPORT_SYMBOL(omap_mbox_get); 347EXPORT_SYMBOL(omap_mbox_get);
330 348
331void omap_mbox_put(struct omap_mbox *mbox) 349void omap_mbox_put(struct omap_mbox *mbox, struct notifier_block *nb)
332{ 350{
351 blocking_notifier_chain_unregister(&mbox->notifier, nb);
333 omap_mbox_fini(mbox); 352 omap_mbox_fini(mbox);
334} 353}
335EXPORT_SYMBOL(omap_mbox_put); 354EXPORT_SYMBOL(omap_mbox_put);
@@ -353,6 +372,8 @@ int omap_mbox_register(struct device *parent, struct omap_mbox **list)
353 ret = PTR_ERR(mbox->dev); 372 ret = PTR_ERR(mbox->dev);
354 goto err_out; 373 goto err_out;
355 } 374 }
375
376 BLOCKING_INIT_NOTIFIER_HEAD(&mbox->notifier);
356 } 377 }
357 return 0; 378 return 0;
358 379
@@ -391,7 +412,8 @@ static int __init omap_mbox_init(void)
391 412
392 /* kfifo size sanity check: alignment and minimal size */ 413 /* kfifo size sanity check: alignment and minimal size */
393 mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(mbox_msg_t)); 414 mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(mbox_msg_t));
394 mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size, sizeof(mbox_msg_t)); 415 mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size,
416 sizeof(mbox_msg_t));
395 417
396 return 0; 418 return 0;
397} 419}
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index eac4b978e9fd..b5a6e178a7f9 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -28,6 +28,8 @@
28#include <plat/dma.h> 28#include <plat/dma.h>
29#include <plat/mcbsp.h> 29#include <plat/mcbsp.h>
30 30
31/* XXX These "sideways" includes are a sign that something is wrong */
32#include "../mach-omap2/cm2xxx_3xxx.h"
31#include "../mach-omap2/cm-regbits-34xx.h" 33#include "../mach-omap2/cm-regbits-34xx.h"
32 34
33struct omap_mcbsp **mcbsp_ptr; 35struct omap_mcbsp **mcbsp_ptr;
@@ -234,9 +236,9 @@ static void omap_st_on(struct omap_mcbsp *mcbsp)
234 * Sidetone uses McBSP ICLK - which must not idle when sidetones 236 * Sidetone uses McBSP ICLK - which must not idle when sidetones
235 * are enabled or sidetones start sounding ugly. 237 * are enabled or sidetones start sounding ugly.
236 */ 238 */
237 w = cm_read_mod_reg(OMAP3430_PER_MOD, CM_AUTOIDLE); 239 w = omap2_cm_read_mod_reg(OMAP3430_PER_MOD, CM_AUTOIDLE);
238 w &= ~(1 << (mcbsp->id - 2)); 240 w &= ~(1 << (mcbsp->id - 2));
239 cm_write_mod_reg(w, OMAP3430_PER_MOD, CM_AUTOIDLE); 241 omap2_cm_write_mod_reg(w, OMAP3430_PER_MOD, CM_AUTOIDLE);
240 242
241 /* Enable McBSP Sidetone */ 243 /* Enable McBSP Sidetone */
242 w = MCBSP_READ(mcbsp, SSELCR); 244 w = MCBSP_READ(mcbsp, SSELCR);
@@ -263,9 +265,9 @@ static void omap_st_off(struct omap_mcbsp *mcbsp)
263 w = MCBSP_READ(mcbsp, SSELCR); 265 w = MCBSP_READ(mcbsp, SSELCR);
264 MCBSP_WRITE(mcbsp, SSELCR, w & ~(SIDETONEEN)); 266 MCBSP_WRITE(mcbsp, SSELCR, w & ~(SIDETONEEN));
265 267
266 w = cm_read_mod_reg(OMAP3430_PER_MOD, CM_AUTOIDLE); 268 w = omap2_cm_read_mod_reg(OMAP3430_PER_MOD, CM_AUTOIDLE);
267 w |= 1 << (mcbsp->id - 2); 269 w |= 1 << (mcbsp->id - 2);
268 cm_write_mod_reg(w, OMAP3430_PER_MOD, CM_AUTOIDLE); 270 omap2_cm_write_mod_reg(w, OMAP3430_PER_MOD, CM_AUTOIDLE);
269} 271}
270 272
271static void omap_st_fir_write(struct omap_mcbsp *mcbsp, s16 *fir) 273static void omap_st_fir_write(struct omap_mcbsp *mcbsp, s16 *fir)
@@ -755,7 +757,7 @@ int omap_mcbsp_request(unsigned int id)
755 goto err_kfree; 757 goto err_kfree;
756 } 758 }
757 759
758 mcbsp->free = 0; 760 mcbsp->free = false;
759 mcbsp->reg_cache = reg_cache; 761 mcbsp->reg_cache = reg_cache;
760 spin_unlock(&mcbsp->lock); 762 spin_unlock(&mcbsp->lock);
761 763
@@ -815,7 +817,7 @@ err_clk_disable:
815 clk_disable(mcbsp->iclk); 817 clk_disable(mcbsp->iclk);
816 818
817 spin_lock(&mcbsp->lock); 819 spin_lock(&mcbsp->lock);
818 mcbsp->free = 1; 820 mcbsp->free = true;
819 mcbsp->reg_cache = NULL; 821 mcbsp->reg_cache = NULL;
820err_kfree: 822err_kfree:
821 spin_unlock(&mcbsp->lock); 823 spin_unlock(&mcbsp->lock);
@@ -858,7 +860,7 @@ void omap_mcbsp_free(unsigned int id)
858 if (mcbsp->free) 860 if (mcbsp->free)
859 dev_err(mcbsp->dev, "McBSP%d was not reserved\n", mcbsp->id); 861 dev_err(mcbsp->dev, "McBSP%d was not reserved\n", mcbsp->id);
860 else 862 else
861 mcbsp->free = 1; 863 mcbsp->free = true;
862 mcbsp->reg_cache = NULL; 864 mcbsp->reg_cache = NULL;
863 spin_unlock(&mcbsp->lock); 865 spin_unlock(&mcbsp->lock);
864 866
@@ -1771,7 +1773,7 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
1771 1773
1772 spin_lock_init(&mcbsp->lock); 1774 spin_lock_init(&mcbsp->lock);
1773 mcbsp->id = id + 1; 1775 mcbsp->id = id + 1;
1774 mcbsp->free = 1; 1776 mcbsp->free = true;
1775 mcbsp->dma_tx_lch = -1; 1777 mcbsp->dma_tx_lch = -1;
1776 mcbsp->dma_rx_lch = -1; 1778 mcbsp->dma_rx_lch = -1;
1777 1779
@@ -1836,17 +1838,11 @@ static int __devexit omap_mcbsp_remove(struct platform_device *pdev)
1836 1838
1837 omap34xx_device_exit(mcbsp); 1839 omap34xx_device_exit(mcbsp);
1838 1840
1839 clk_disable(mcbsp->fclk);
1840 clk_disable(mcbsp->iclk);
1841 clk_put(mcbsp->fclk); 1841 clk_put(mcbsp->fclk);
1842 clk_put(mcbsp->iclk); 1842 clk_put(mcbsp->iclk);
1843 1843
1844 iounmap(mcbsp->io_base); 1844 iounmap(mcbsp->io_base);
1845 1845 kfree(mcbsp);
1846 mcbsp->fclk = NULL;
1847 mcbsp->iclk = NULL;
1848 mcbsp->free = 0;
1849 mcbsp->dev = NULL;
1850 } 1846 }
1851 1847
1852 return 0; 1848 return 0;
diff --git a/arch/arm/plat-omap/omap-pm-noop.c b/arch/arm/plat-omap/omap-pm-noop.c
index e129ce80c53b..b0471bb2d47d 100644
--- a/arch/arm/plat-omap/omap-pm-noop.c
+++ b/arch/arm/plat-omap/omap-pm-noop.c
@@ -20,15 +20,14 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/cpufreq.h> 21#include <linux/cpufreq.h>
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/platform_device.h>
23 24
24/* Interface documentation is in mach/omap-pm.h */ 25/* Interface documentation is in mach/omap-pm.h */
25#include <plat/omap-pm.h> 26#include <plat/omap-pm.h>
27#include <plat/omap_device.h>
26 28
27#include <plat/powerdomain.h> 29static bool off_mode_enabled;
28 30static u32 dummy_context_loss_counter;
29struct omap_opp *dsp_opps;
30struct omap_opp *mpu_opps;
31struct omap_opp *l3_opps;
32 31
33/* 32/*
34 * Device-driver-originated constraints (via board-*.c files) 33 * Device-driver-originated constraints (via board-*.c files)
@@ -284,37 +283,70 @@ unsigned long omap_pm_cpu_get_freq(void)
284 return 0; 283 return 0;
285} 284}
286 285
286/**
287 * omap_pm_enable_off_mode - notify OMAP PM that off-mode is enabled
288 *
289 * Intended for use only by OMAP PM core code to notify this layer
290 * that off mode has been enabled.
291 */
292void omap_pm_enable_off_mode(void)
293{
294 off_mode_enabled = true;
295}
296
297/**
298 * omap_pm_disable_off_mode - notify OMAP PM that off-mode is disabled
299 *
300 * Intended for use only by OMAP PM core code to notify this layer
301 * that off mode has been disabled.
302 */
303void omap_pm_disable_off_mode(void)
304{
305 off_mode_enabled = false;
306}
307
287/* 308/*
288 * Device context loss tracking 309 * Device context loss tracking
289 */ 310 */
290 311
291int omap_pm_get_dev_context_loss_count(struct device *dev) 312#ifdef CONFIG_ARCH_OMAP2PLUS
313
314u32 omap_pm_get_dev_context_loss_count(struct device *dev)
292{ 315{
293 if (!dev) { 316 struct platform_device *pdev = to_platform_device(dev);
294 WARN_ON(1); 317 u32 count;
295 return -EINVAL; 318
296 }; 319 if (WARN_ON(!dev))
320 return 0;
321
322 if (dev->parent == &omap_device_parent) {
323 count = omap_device_get_context_loss_count(pdev);
324 } else {
325 WARN_ONCE(off_mode_enabled, "omap_pm: using dummy context loss counter; device %s should be converted to omap_device",
326 dev_name(dev));
327 if (off_mode_enabled)
328 dummy_context_loss_counter++;
329 count = dummy_context_loss_counter;
330 }
297 331
298 pr_debug("OMAP PM: returning context loss count for dev %s\n", 332 pr_debug("OMAP PM: context loss count for dev %s = %d\n",
299 dev_name(dev)); 333 dev_name(dev), count);
300 334
301 /* 335 return count;
302 * Map the device to the powerdomain. Return the powerdomain 336}
303 * off counter.
304 */
305 337
306 return 0; 338#else
339
340u32 omap_pm_get_dev_context_loss_count(struct device *dev)
341{
342 return dummy_context_loss_counter;
307} 343}
308 344
345#endif
309 346
310/* Should be called before clk framework init */ 347/* Should be called before clk framework init */
311int __init omap_pm_if_early_init(struct omap_opp *mpu_opp_table, 348int __init omap_pm_if_early_init(void)
312 struct omap_opp *dsp_opp_table,
313 struct omap_opp *l3_opp_table)
314{ 349{
315 mpu_opps = mpu_opp_table;
316 dsp_opps = dsp_opp_table;
317 l3_opps = l3_opp_table;
318 return 0; 350 return 0;
319} 351}
320 352
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
index abe933cd8f09..57adb270767b 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -280,6 +280,34 @@ static void _add_optional_clock_alias(struct omap_device *od,
280/* Public functions for use by core code */ 280/* Public functions for use by core code */
281 281
282/** 282/**
283 * omap_device_get_context_loss_count - get lost context count
284 * @od: struct omap_device *
285 *
286 * Using the primary hwmod, query the context loss count for this
287 * device.
288 *
289 * Callers should consider context for this device lost any time this
290 * function returns a value different than the value the caller got
291 * the last time it called this function.
292 *
293 * If any hwmods exist for the omap_device assoiated with @pdev,
294 * return the context loss counter for that hwmod, otherwise return
295 * zero.
296 */
297u32 omap_device_get_context_loss_count(struct platform_device *pdev)
298{
299 struct omap_device *od;
300 u32 ret = 0;
301
302 od = _find_by_pdev(pdev);
303
304 if (od->hwmods_cnt)
305 ret = omap_hwmod_get_context_loss_count(od->hwmods[0]);
306
307 return ret;
308}
309
310/**
283 * omap_device_count_resources - count number of struct resource entries needed 311 * omap_device_count_resources - count number of struct resource entries needed
284 * @od: struct omap_device * 312 * @od: struct omap_device *
285 * 313 *
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
index 74dac419d328..e26e50487d60 100644
--- a/arch/arm/plat-omap/sram.c
+++ b/arch/arm/plat-omap/sram.c
@@ -33,23 +33,21 @@
33 33
34#include "sram.h" 34#include "sram.h"
35#include "fb.h" 35#include "fb.h"
36
37/* XXX These "sideways" includes are a sign that something is wrong */
36#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 38#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
37# include "../mach-omap2/prm.h" 39# include "../mach-omap2/prm2xxx_3xxx.h"
38# include "../mach-omap2/cm.h"
39# include "../mach-omap2/sdrc.h" 40# include "../mach-omap2/sdrc.h"
40#endif 41#endif
41 42
42#define OMAP1_SRAM_PA 0x20000000 43#define OMAP1_SRAM_PA 0x20000000
43#define OMAP1_SRAM_VA VMALLOC_END 44#define OMAP1_SRAM_VA VMALLOC_END
44#define OMAP2_SRAM_PA 0x40200000 45#define OMAP2_SRAM_PUB_PA (OMAP2_SRAM_PA + 0xf800)
45#define OMAP2_SRAM_PUB_PA 0x4020f800
46#define OMAP2_SRAM_VA 0xfe400000 46#define OMAP2_SRAM_VA 0xfe400000
47#define OMAP2_SRAM_PUB_VA (OMAP2_SRAM_VA + 0x800) 47#define OMAP2_SRAM_PUB_VA (OMAP2_SRAM_VA + 0x800)
48#define OMAP3_SRAM_PA 0x40200000
49#define OMAP3_SRAM_VA 0xfe400000 48#define OMAP3_SRAM_VA 0xfe400000
50#define OMAP3_SRAM_PUB_PA 0x40208000 49#define OMAP3_SRAM_PUB_PA (OMAP3_SRAM_PA + 0x8000)
51#define OMAP3_SRAM_PUB_VA (OMAP3_SRAM_VA + 0x8000) 50#define OMAP3_SRAM_PUB_VA (OMAP3_SRAM_VA + 0x8000)
52#define OMAP4_SRAM_PA 0x40300000
53#define OMAP4_SRAM_VA 0xfe400000 51#define OMAP4_SRAM_VA 0xfe400000
54#define OMAP4_SRAM_PUB_PA (OMAP4_SRAM_PA + 0x4000) 52#define OMAP4_SRAM_PUB_PA (OMAP4_SRAM_PA + 0x4000)
55#define OMAP4_SRAM_PUB_VA (OMAP4_SRAM_VA + 0x4000) 53#define OMAP4_SRAM_PUB_VA (OMAP4_SRAM_VA + 0x4000)
@@ -270,7 +268,7 @@ void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl)
270 _omap_sram_reprogram_clock(dpllctl, ckctl); 268 _omap_sram_reprogram_clock(dpllctl, ckctl);
271} 269}
272 270
273int __init omap1_sram_init(void) 271static int __init omap1_sram_init(void)
274{ 272{
275 _omap_sram_reprogram_clock = 273 _omap_sram_reprogram_clock =
276 omap_sram_push(omap1_sram_reprogram_clock, 274 omap_sram_push(omap1_sram_reprogram_clock,