aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /arch/arm/plat-omap
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'arch/arm/plat-omap')
-rw-r--r--arch/arm/plat-omap/Kconfig49
-rw-r--r--arch/arm/plat-omap/Makefile6
-rw-r--r--arch/arm/plat-omap/clock.c104
-rw-r--r--arch/arm/plat-omap/common.c303
-rw-r--r--arch/arm/plat-omap/counter_32k.c207
-rw-r--r--arch/arm/plat-omap/cpu-omap.c6
-rw-r--r--arch/arm/plat-omap/devices.c66
-rw-r--r--arch/arm/plat-omap/dma.c716
-rw-r--r--arch/arm/plat-omap/dmtimer.c6
-rw-r--r--arch/arm/plat-omap/fb.c22
-rw-r--r--arch/arm/plat-omap/fb.h10
-rw-r--r--arch/arm/plat-omap/gpio.c2344
-rw-r--r--arch/arm/plat-omap/i2c.c128
-rw-r--r--arch/arm/plat-omap/include/plat/board.h4
-rw-r--r--arch/arm/plat-omap/include/plat/clkdev_omap.h23
-rw-r--r--arch/arm/plat-omap/include/plat/clock.h44
-rw-r--r--arch/arm/plat-omap/include/plat/clockdomain.h141
-rw-r--r--arch/arm/plat-omap/include/plat/common.h15
-rw-r--r--arch/arm/plat-omap/include/plat/control.h381
-rw-r--r--arch/arm/plat-omap/include/plat/cpu.h77
-rw-r--r--arch/arm/plat-omap/include/plat/display.h591
-rw-r--r--arch/arm/plat-omap/include/plat/dma.h238
-rw-r--r--arch/arm/plat-omap/include/plat/dmtimer.h13
-rw-r--r--arch/arm/plat-omap/include/plat/dsp.h31
-rw-r--r--arch/arm/plat-omap/include/plat/flash.h3
-rw-r--r--arch/arm/plat-omap/include/plat/fpga.h96
-rw-r--r--arch/arm/plat-omap/include/plat/gpio.h153
-rw-r--r--arch/arm/plat-omap/include/plat/gpmc-smsc911x.h35
-rw-r--r--arch/arm/plat-omap/include/plat/gpmc.h27
-rw-r--r--arch/arm/plat-omap/include/plat/hardware.h1
-rw-r--r--arch/arm/plat-omap/include/plat/i2c.h17
-rw-r--r--arch/arm/plat-omap/include/plat/io.h21
-rw-r--r--arch/arm/plat-omap/include/plat/iommu.h21
-rw-r--r--arch/arm/plat-omap/include/plat/iovmm.h5
-rw-r--r--arch/arm/plat-omap/include/plat/irqs.h15
-rw-r--r--arch/arm/plat-omap/include/plat/keypad.h35
-rw-r--r--arch/arm/plat-omap/include/plat/l3_2xxx.h20
-rw-r--r--arch/arm/plat-omap/include/plat/l3_3xxx.h20
-rw-r--r--arch/arm/plat-omap/include/plat/l4_2xxx.h24
-rw-r--r--arch/arm/plat-omap/include/plat/l4_3xxx.h34
-rw-r--r--arch/arm/plat-omap/include/plat/mailbox.h8
-rw-r--r--arch/arm/plat-omap/include/plat/mcbsp.h93
-rw-r--r--arch/arm/plat-omap/include/plat/mcspi.h11
-rw-r--r--arch/arm/plat-omap/include/plat/memory.h12
-rw-r--r--arch/arm/plat-omap/include/plat/mmc.h44
-rw-r--r--arch/arm/plat-omap/include/plat/multi.h4
-rw-r--r--arch/arm/plat-omap/include/plat/nand.h11
-rw-r--r--arch/arm/plat-omap/include/plat/nokia-dsi-panel.h31
-rw-r--r--arch/arm/plat-omap/include/plat/omap-pm.h39
-rw-r--r--arch/arm/plat-omap/include/plat/omap-serial.h116
-rw-r--r--arch/arm/plat-omap/include/plat/omap24xx.h2
-rw-r--r--arch/arm/plat-omap/include/plat/omap34xx.h16
-rw-r--r--arch/arm/plat-omap/include/plat/omap4-keypad.h14
-rw-r--r--arch/arm/plat-omap/include/plat/omap44xx.h5
-rw-r--r--arch/arm/plat-omap/include/plat/omap_device.h5
-rw-r--r--arch/arm/plat-omap/include/plat/omap_hwmod.h148
-rw-r--r--arch/arm/plat-omap/include/plat/onenand.h12
-rw-r--r--arch/arm/plat-omap/include/plat/powerdomain.h165
-rw-r--r--arch/arm/plat-omap/include/plat/prcm.h19
-rw-r--r--arch/arm/plat-omap/include/plat/sdrc.h9
-rw-r--r--arch/arm/plat-omap/include/plat/serial.h16
-rw-r--r--arch/arm/plat-omap/include/plat/smp.h47
-rw-r--r--arch/arm/plat-omap/include/plat/sram.h26
-rw-r--r--arch/arm/plat-omap/include/plat/system.h38
-rw-r--r--arch/arm/plat-omap/include/plat/ti816x.h27
-rw-r--r--arch/arm/plat-omap/include/plat/timer-gp.h17
-rw-r--r--arch/arm/plat-omap/include/plat/uncompress.h20
-rw-r--r--arch/arm/plat-omap/include/plat/usb.h88
-rw-r--r--arch/arm/plat-omap/include/plat/vrfb.h16
-rw-r--r--arch/arm/plat-omap/io.c63
-rw-r--r--arch/arm/plat-omap/iommu-debug.c2
-rw-r--r--arch/arm/plat-omap/iommu.c95
-rw-r--r--arch/arm/plat-omap/iovmm.c104
-rw-r--r--arch/arm/plat-omap/mailbox.c149
-rw-r--r--arch/arm/plat-omap/mcbsp.c257
-rw-r--r--arch/arm/plat-omap/omap-pm-noop.c78
-rw-r--r--arch/arm/plat-omap/omap_device.c192
-rw-r--r--arch/arm/plat-omap/sram.c95
-rw-r--r--arch/arm/plat-omap/sram.h6
79 files changed, 2660 insertions, 5492 deletions
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index a92cb499313f..49a4c75243fc 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -11,15 +11,18 @@ choice
11 11
12config ARCH_OMAP1 12config ARCH_OMAP1
13 bool "TI OMAP1" 13 bool "TI OMAP1"
14 select COMMON_CLKDEV 14 select CLKDEV_LOOKUP
15 select CLKSRC_MMIO
15 help 16 help
16 "Systems based on omap7xx, omap15xx or omap16xx" 17 "Systems based on omap7xx, omap15xx or omap16xx"
17 18
18config ARCH_OMAP2PLUS 19config ARCH_OMAP2PLUS
19 bool "TI OMAP2/3/4" 20 bool "TI OMAP2/3/4"
20 select COMMON_CLKDEV 21 select CLKDEV_LOOKUP
22 select GENERIC_IRQ_CHIP
23 select OMAP_DM_TIMER
21 help 24 help
22 "Systems based on omap24xx, omap34xx or omap44xx" 25 "Systems based on OMAP2, OMAP3 or OMAP4"
23 26
24endchoice 27endchoice
25 28
@@ -35,6 +38,37 @@ config OMAP_DEBUG_LEDS
35 depends on OMAP_DEBUG_DEVICES 38 depends on OMAP_DEBUG_DEVICES
36 default y if LEDS_CLASS 39 default y if LEDS_CLASS
37 40
41config OMAP_SMARTREFLEX
42 bool "SmartReflex support"
43 depends on (ARCH_OMAP3 || ARCH_OMAP4) && PM
44 help
45 Say Y if you want to enable SmartReflex.
46
47 SmartReflex can perform continuous dynamic voltage
48 scaling around the nominal operating point voltage
49 according to silicon characteristics and operating
50 conditions. Enabling SmartReflex reduces power
51 consumption.
52
53 Please note, that by default SmartReflex is only
54 initialized. To enable the automatic voltage
55 compensation for vdd mpu and vdd core from user space,
56 user must write 1 to
57 /debug/voltage/vdd_<X>/smartreflex/autocomp,
58 where X is mpu or core for OMAP3.
59 Optionally autocompensation can be enabled in the kernel
60 by default during system init via the enable_on_init flag
61 which an be passed as platform data to the smartreflex driver.
62
63config OMAP_SMARTREFLEX_CLASS3
64 bool "Class 3 mode of Smartreflex Implementation"
65 depends on OMAP_SMARTREFLEX && TWL4030_CORE
66 help
67 Say Y to enable Class 3 implementation of Smartreflex
68
69 Class 3 implementation of Smartreflex employs continuous hardware
70 voltage calibration.
71
38config OMAP_RESET_CLOCKS 72config OMAP_RESET_CLOCKS
39 bool "Reset unused clocks during boot" 73 bool "Reset unused clocks during boot"
40 depends on ARCH_OMAP 74 depends on ARCH_OMAP
@@ -109,12 +143,12 @@ config OMAP_IOMMU_DEBUG
109 143
110 Say N unless you know you need this. 144 Say N unless you know you need this.
111 145
112choice 146config OMAP_IOMMU_IVA2
113 prompt "System timer" 147 bool
114 default OMAP_32K_TIMER if !ARCH_OMAP15XX
115 148
116config OMAP_MPU_TIMER 149config OMAP_MPU_TIMER
117 bool "Use mpu timer" 150 bool "Use mpu timer"
151 depends on ARCH_OMAP1
118 help 152 help
119 Select this option if you want to use the OMAP mpu timer. This 153 Select this option if you want to use the OMAP mpu timer. This
120 timer provides more intra-tick resolution than the 32KHz timer, 154 timer provides more intra-tick resolution than the 32KHz timer,
@@ -123,6 +157,7 @@ config OMAP_MPU_TIMER
123config OMAP_32K_TIMER 157config OMAP_32K_TIMER
124 bool "Use 32KHz timer" 158 bool "Use 32KHz timer"
125 depends on ARCH_OMAP16XX || ARCH_OMAP2PLUS 159 depends on ARCH_OMAP16XX || ARCH_OMAP2PLUS
160 default y if (ARCH_OMAP16XX || ARCH_OMAP2PLUS)
126 help 161 help
127 Select this option if you want to enable the OMAP 32KHz timer. 162 Select this option if you want to enable the OMAP 32KHz timer.
128 This timer saves power compared to the OMAP_MPU_TIMER, and has 163 This timer saves power compared to the OMAP_MPU_TIMER, and has
@@ -130,8 +165,6 @@ config OMAP_32K_TIMER
130 intra-tick resolution than OMAP_MPU_TIMER. The 32KHz timer is 165 intra-tick resolution than OMAP_MPU_TIMER. The 32KHz timer is
131 currently only available for OMAP16XX, 24XX, 34XX and OMAP4. 166 currently only available for OMAP16XX, 24XX, 34XX and OMAP4.
132 167
133endchoice
134
135config OMAP3_L2_AUX_SECURE_SAVE_RESTORE 168config OMAP3_L2_AUX_SECURE_SAVE_RESTORE
136 bool "OMAP3 HS/EMU save and restore for L2 AUX control register" 169 bool "OMAP3 HS/EMU save and restore for L2 AUX control register"
137 depends on ARCH_OMAP3 && PM 170 depends on ARCH_OMAP3 && PM
diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
index 9405831b746a..f0233e6abcdf 100644
--- a/arch/arm/plat-omap/Makefile
+++ b/arch/arm/plat-omap/Makefile
@@ -3,8 +3,8 @@
3# 3#
4 4
5# Common support 5# Common support
6obj-y := common.o sram.o clock.o devices.o dma.o mux.o gpio.o \ 6obj-y := common.o sram.o clock.o devices.o dma.o mux.o \
7 usb.o fb.o io.o 7 usb.o fb.o io.o counter_32k.o
8obj-m := 8obj-m :=
9obj-n := 9obj-n :=
10obj- := 10obj- :=
@@ -31,4 +31,4 @@ obj-y += $(i2c-omap-m) $(i2c-omap-y)
31# OMAP mailbox framework 31# OMAP mailbox framework
32obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox.o 32obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox.o
33 33
34obj-$(CONFIG_OMAP_PM_NOOP) += omap-pm-noop.o \ No newline at end of file 34obj-$(CONFIG_OMAP_PM_NOOP) += omap-pm-noop.o
diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
index 7190cbd92620..c9122dd6ee8d 100644
--- a/arch/arm/plat-omap/clock.c
+++ b/arch/arm/plat-omap/clock.c
@@ -37,14 +37,16 @@ static struct clk_functions *arch_clock;
37int clk_enable(struct clk *clk) 37int clk_enable(struct clk *clk)
38{ 38{
39 unsigned long flags; 39 unsigned long flags;
40 int ret = 0; 40 int ret;
41 41
42 if (clk == NULL || IS_ERR(clk)) 42 if (clk == NULL || IS_ERR(clk))
43 return -EINVAL; 43 return -EINVAL;
44 44
45 if (!arch_clock || !arch_clock->clk_enable)
46 return -EINVAL;
47
45 spin_lock_irqsave(&clockfw_lock, flags); 48 spin_lock_irqsave(&clockfw_lock, flags);
46 if (arch_clock->clk_enable) 49 ret = arch_clock->clk_enable(clk);
47 ret = arch_clock->clk_enable(clk);
48 spin_unlock_irqrestore(&clockfw_lock, flags); 50 spin_unlock_irqrestore(&clockfw_lock, flags);
49 51
50 return ret; 52 return ret;
@@ -58,16 +60,18 @@ void clk_disable(struct clk *clk)
58 if (clk == NULL || IS_ERR(clk)) 60 if (clk == NULL || IS_ERR(clk))
59 return; 61 return;
60 62
63 if (!arch_clock || !arch_clock->clk_disable)
64 return;
65
61 spin_lock_irqsave(&clockfw_lock, flags); 66 spin_lock_irqsave(&clockfw_lock, flags);
62 if (clk->usecount == 0) { 67 if (clk->usecount == 0) {
63 printk(KERN_ERR "Trying disable clock %s with 0 usecount\n", 68 pr_err("Trying disable clock %s with 0 usecount\n",
64 clk->name); 69 clk->name);
65 WARN_ON(1); 70 WARN_ON(1);
66 goto out; 71 goto out;
67 } 72 }
68 73
69 if (arch_clock->clk_disable) 74 arch_clock->clk_disable(clk);
70 arch_clock->clk_disable(clk);
71 75
72out: 76out:
73 spin_unlock_irqrestore(&clockfw_lock, flags); 77 spin_unlock_irqrestore(&clockfw_lock, flags);
@@ -77,7 +81,7 @@ EXPORT_SYMBOL(clk_disable);
77unsigned long clk_get_rate(struct clk *clk) 81unsigned long clk_get_rate(struct clk *clk)
78{ 82{
79 unsigned long flags; 83 unsigned long flags;
80 unsigned long ret = 0; 84 unsigned long ret;
81 85
82 if (clk == NULL || IS_ERR(clk)) 86 if (clk == NULL || IS_ERR(clk))
83 return 0; 87 return 0;
@@ -97,14 +101,16 @@ EXPORT_SYMBOL(clk_get_rate);
97long clk_round_rate(struct clk *clk, unsigned long rate) 101long clk_round_rate(struct clk *clk, unsigned long rate)
98{ 102{
99 unsigned long flags; 103 unsigned long flags;
100 long ret = 0; 104 long ret;
101 105
102 if (clk == NULL || IS_ERR(clk)) 106 if (clk == NULL || IS_ERR(clk))
103 return ret; 107 return 0;
108
109 if (!arch_clock || !arch_clock->clk_round_rate)
110 return 0;
104 111
105 spin_lock_irqsave(&clockfw_lock, flags); 112 spin_lock_irqsave(&clockfw_lock, flags);
106 if (arch_clock->clk_round_rate) 113 ret = arch_clock->clk_round_rate(clk, rate);
107 ret = arch_clock->clk_round_rate(clk, rate);
108 spin_unlock_irqrestore(&clockfw_lock, flags); 114 spin_unlock_irqrestore(&clockfw_lock, flags);
109 115
110 return ret; 116 return ret;
@@ -119,14 +125,13 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
119 if (clk == NULL || IS_ERR(clk)) 125 if (clk == NULL || IS_ERR(clk))
120 return ret; 126 return ret;
121 127
128 if (!arch_clock || !arch_clock->clk_set_rate)
129 return ret;
130
122 spin_lock_irqsave(&clockfw_lock, flags); 131 spin_lock_irqsave(&clockfw_lock, flags);
123 if (arch_clock->clk_set_rate) 132 ret = arch_clock->clk_set_rate(clk, rate);
124 ret = arch_clock->clk_set_rate(clk, rate); 133 if (ret == 0)
125 if (ret == 0) {
126 if (clk->recalc)
127 clk->rate = clk->recalc(clk);
128 propagate_rate(clk); 134 propagate_rate(clk);
129 }
130 spin_unlock_irqrestore(&clockfw_lock, flags); 135 spin_unlock_irqrestore(&clockfw_lock, flags);
131 136
132 return ret; 137 return ret;
@@ -141,15 +146,14 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
141 if (clk == NULL || IS_ERR(clk) || parent == NULL || IS_ERR(parent)) 146 if (clk == NULL || IS_ERR(clk) || parent == NULL || IS_ERR(parent))
142 return ret; 147 return ret;
143 148
149 if (!arch_clock || !arch_clock->clk_set_parent)
150 return ret;
151
144 spin_lock_irqsave(&clockfw_lock, flags); 152 spin_lock_irqsave(&clockfw_lock, flags);
145 if (clk->usecount == 0) { 153 if (clk->usecount == 0) {
146 if (arch_clock->clk_set_parent) 154 ret = arch_clock->clk_set_parent(clk, parent);
147 ret = arch_clock->clk_set_parent(clk, parent); 155 if (ret == 0)
148 if (ret == 0) {
149 if (clk->recalc)
150 clk->rate = clk->recalc(clk);
151 propagate_rate(clk); 156 propagate_rate(clk);
152 }
153 } else 157 } else
154 ret = -EBUSY; 158 ret = -EBUSY;
155 spin_unlock_irqrestore(&clockfw_lock, flags); 159 spin_unlock_irqrestore(&clockfw_lock, flags);
@@ -335,6 +339,38 @@ struct clk *omap_clk_get_by_name(const char *name)
335 return ret; 339 return ret;
336} 340}
337 341
342int omap_clk_enable_autoidle_all(void)
343{
344 struct clk *c;
345 unsigned long flags;
346
347 spin_lock_irqsave(&clockfw_lock, flags);
348
349 list_for_each_entry(c, &clocks, node)
350 if (c->ops->allow_idle)
351 c->ops->allow_idle(c);
352
353 spin_unlock_irqrestore(&clockfw_lock, flags);
354
355 return 0;
356}
357
358int omap_clk_disable_autoidle_all(void)
359{
360 struct clk *c;
361 unsigned long flags;
362
363 spin_lock_irqsave(&clockfw_lock, flags);
364
365 list_for_each_entry(c, &clocks, node)
366 if (c->ops->deny_idle)
367 c->ops->deny_idle(c);
368
369 spin_unlock_irqrestore(&clockfw_lock, flags);
370
371 return 0;
372}
373
338/* 374/*
339 * Low level helpers 375 * Low level helpers
340 */ 376 */
@@ -367,9 +403,11 @@ void clk_init_cpufreq_table(struct cpufreq_frequency_table **table)
367{ 403{
368 unsigned long flags; 404 unsigned long flags;
369 405
406 if (!arch_clock || !arch_clock->clk_init_cpufreq_table)
407 return;
408
370 spin_lock_irqsave(&clockfw_lock, flags); 409 spin_lock_irqsave(&clockfw_lock, flags);
371 if (arch_clock->clk_init_cpufreq_table) 410 arch_clock->clk_init_cpufreq_table(table);
372 arch_clock->clk_init_cpufreq_table(table);
373 spin_unlock_irqrestore(&clockfw_lock, flags); 411 spin_unlock_irqrestore(&clockfw_lock, flags);
374} 412}
375 413
@@ -377,9 +415,11 @@ void clk_exit_cpufreq_table(struct cpufreq_frequency_table **table)
377{ 415{
378 unsigned long flags; 416 unsigned long flags;
379 417
418 if (!arch_clock || !arch_clock->clk_exit_cpufreq_table)
419 return;
420
380 spin_lock_irqsave(&clockfw_lock, flags); 421 spin_lock_irqsave(&clockfw_lock, flags);
381 if (arch_clock->clk_exit_cpufreq_table) 422 arch_clock->clk_exit_cpufreq_table(table);
382 arch_clock->clk_exit_cpufreq_table(table);
383 spin_unlock_irqrestore(&clockfw_lock, flags); 423 spin_unlock_irqrestore(&clockfw_lock, flags);
384} 424}
385#endif 425#endif
@@ -397,6 +437,10 @@ static int __init clk_disable_unused(void)
397 struct clk *ck; 437 struct clk *ck;
398 unsigned long flags; 438 unsigned long flags;
399 439
440 if (!arch_clock || !arch_clock->clk_disable_unused)
441 return 0;
442
443 pr_info("clock: disabling unused clocks to save power\n");
400 list_for_each_entry(ck, &clocks, node) { 444 list_for_each_entry(ck, &clocks, node) {
401 if (ck->ops == &clkops_null) 445 if (ck->ops == &clkops_null)
402 continue; 446 continue;
@@ -405,20 +449,20 @@ static int __init clk_disable_unused(void)
405 continue; 449 continue;
406 450
407 spin_lock_irqsave(&clockfw_lock, flags); 451 spin_lock_irqsave(&clockfw_lock, flags);
408 if (arch_clock->clk_disable_unused) 452 arch_clock->clk_disable_unused(ck);
409 arch_clock->clk_disable_unused(ck);
410 spin_unlock_irqrestore(&clockfw_lock, flags); 453 spin_unlock_irqrestore(&clockfw_lock, flags);
411 } 454 }
412 455
413 return 0; 456 return 0;
414} 457}
415late_initcall(clk_disable_unused); 458late_initcall(clk_disable_unused);
459late_initcall(omap_clk_enable_autoidle_all);
416#endif 460#endif
417 461
418int __init clk_init(struct clk_functions * custom_clocks) 462int __init clk_init(struct clk_functions * custom_clocks)
419{ 463{
420 if (!custom_clocks) { 464 if (!custom_clocks) {
421 printk(KERN_ERR "No custom clock functions registered\n"); 465 pr_err("No custom clock functions registered\n");
422 BUG(); 466 BUG();
423 } 467 }
424 468
diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index 3008e7104487..d9f10a31e604 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -11,45 +11,24 @@
11 * it under the terms of the GNU General Public License version 2 as 11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 */ 13 */
14#include <linux/module.h>
15#include <linux/kernel.h> 14#include <linux/kernel.h>
16#include <linux/init.h> 15#include <linux/init.h>
17#include <linux/delay.h>
18#include <linux/console.h>
19#include <linux/serial.h>
20#include <linux/tty.h>
21#include <linux/serial_8250.h>
22#include <linux/serial_reg.h>
23#include <linux/clk.h>
24#include <linux/io.h> 16#include <linux/io.h>
25#include <linux/omapfb.h> 17#include <linux/omapfb.h>
26 18
27#include <mach/hardware.h>
28#include <asm/system.h>
29#include <asm/pgtable.h>
30#include <asm/mach/map.h>
31#include <asm/setup.h>
32
33#include <plat/common.h> 19#include <plat/common.h>
34#include <plat/board.h> 20#include <plat/board.h>
35#include <plat/control.h>
36#include <plat/mux.h>
37#include <plat/fpga.h>
38#include <plat/serial.h>
39#include <plat/vram.h> 21#include <plat/vram.h>
22#include <plat/dsp.h>
40 23
41#include <plat/clock.h>
42
43#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
44# include "../mach-omap2/sdrc.h"
45#endif
46 24
47#define NO_LENGTH_CHECK 0xffffffff 25#define NO_LENGTH_CHECK 0xffffffff
48 26
49struct omap_board_config_kernel *omap_board_config; 27struct omap_board_config_kernel *omap_board_config __initdata;
50int omap_board_config_size; 28int omap_board_config_size;
51 29
52static const void *get_config(u16 tag, size_t len, int skip, size_t *len_out) 30static const void *__init get_config(u16 tag, size_t len,
31 int skip, size_t *len_out)
53{ 32{
54 struct omap_board_config_kernel *kinfo = NULL; 33 struct omap_board_config_kernel *kinfo = NULL;
55 int i; 34 int i;
@@ -71,287 +50,19 @@ static const void *get_config(u16 tag, size_t len, int skip, size_t *len_out)
71 return kinfo->data; 50 return kinfo->data;
72} 51}
73 52
74const void *__omap_get_config(u16 tag, size_t len, int nr) 53const void *__init __omap_get_config(u16 tag, size_t len, int nr)
75{ 54{
76 return get_config(tag, len, nr, NULL); 55 return get_config(tag, len, nr, NULL);
77} 56}
78EXPORT_SYMBOL(__omap_get_config);
79 57
80const void *omap_get_var_config(u16 tag, size_t *len) 58const void *__init omap_get_var_config(u16 tag, size_t *len)
81{ 59{
82 return get_config(tag, NO_LENGTH_CHECK, 0, len); 60 return get_config(tag, NO_LENGTH_CHECK, 0, len);
83} 61}
84EXPORT_SYMBOL(omap_get_var_config);
85 62
86void __init omap_reserve(void) 63void __init omap_reserve(void)
87{ 64{
88 omapfb_reserve_sdram_memblock(); 65 omapfb_reserve_sdram_memblock();
89 omap_vram_reserve_sdram_memblock(); 66 omap_vram_reserve_sdram_memblock();
67 omap_dsp_reserve_sdram_memblock();
90} 68}
91
92/*
93 * 32KHz clocksource ... always available, on pretty most chips except
94 * OMAP 730 and 1510. Other timers could be used as clocksources, with
95 * higher resolution in free-running counter modes (e.g. 12 MHz xtal),
96 * but systems won't necessarily want to spend resources that way.
97 */
98
99#define OMAP16XX_TIMER_32K_SYNCHRONIZED 0xfffbc410
100
101#if !(defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP15XX))
102
103#include <linux/clocksource.h>
104
105/*
106 * offset_32k holds the init time counter value. It is then subtracted
107 * from every counter read to achieve a counter that counts time from the
108 * kernel boot (needed for sched_clock()).
109 */
110static u32 offset_32k __read_mostly;
111
112#ifdef CONFIG_ARCH_OMAP16XX
113static cycle_t omap16xx_32k_read(struct clocksource *cs)
114{
115 return omap_readl(OMAP16XX_TIMER_32K_SYNCHRONIZED) - offset_32k;
116}
117#else
118#define omap16xx_32k_read NULL
119#endif
120
121#ifdef CONFIG_ARCH_OMAP2420
122static cycle_t omap2420_32k_read(struct clocksource *cs)
123{
124 return omap_readl(OMAP2420_32KSYNCT_BASE + 0x10) - offset_32k;
125}
126#else
127#define omap2420_32k_read NULL
128#endif
129
130#ifdef CONFIG_ARCH_OMAP2430
131static cycle_t omap2430_32k_read(struct clocksource *cs)
132{
133 return omap_readl(OMAP2430_32KSYNCT_BASE + 0x10) - offset_32k;
134}
135#else
136#define omap2430_32k_read NULL
137#endif
138
139#ifdef CONFIG_ARCH_OMAP3
140static cycle_t omap34xx_32k_read(struct clocksource *cs)
141{
142 return omap_readl(OMAP3430_32KSYNCT_BASE + 0x10) - offset_32k;
143}
144#else
145#define omap34xx_32k_read NULL
146#endif
147
148#ifdef CONFIG_ARCH_OMAP4
149static cycle_t omap44xx_32k_read(struct clocksource *cs)
150{
151 return omap_readl(OMAP4430_32KSYNCT_BASE + 0x10) - offset_32k;
152}
153#else
154#define omap44xx_32k_read NULL
155#endif
156
157/*
158 * Kernel assumes that sched_clock can be called early but may not have
159 * things ready yet.
160 */
161static cycle_t omap_32k_read_dummy(struct clocksource *cs)
162{
163 return 0;
164}
165
166static struct clocksource clocksource_32k = {
167 .name = "32k_counter",
168 .rating = 250,
169 .read = omap_32k_read_dummy,
170 .mask = CLOCKSOURCE_MASK(32),
171 .shift = 10,
172 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
173};
174
175/*
176 * Returns current time from boot in nsecs. It's OK for this to wrap
177 * around for now, as it's just a relative time stamp.
178 */
179unsigned long long sched_clock(void)
180{
181 return clocksource_cyc2ns(clocksource_32k.read(&clocksource_32k),
182 clocksource_32k.mult, clocksource_32k.shift);
183}
184
185/**
186 * read_persistent_clock - Return time from a persistent clock.
187 *
188 * Reads the time from a source which isn't disabled during PM, the
189 * 32k sync timer. Convert the cycles elapsed since last read into
190 * nsecs and adds to a monotonically increasing timespec.
191 */
192static struct timespec persistent_ts;
193static cycles_t cycles, last_cycles;
194void read_persistent_clock(struct timespec *ts)
195{
196 unsigned long long nsecs;
197 cycles_t delta;
198 struct timespec *tsp = &persistent_ts;
199
200 last_cycles = cycles;
201 cycles = clocksource_32k.read(&clocksource_32k);
202 delta = cycles - last_cycles;
203
204 nsecs = clocksource_cyc2ns(delta,
205 clocksource_32k.mult, clocksource_32k.shift);
206
207 timespec_add_ns(tsp, nsecs);
208 *ts = *tsp;
209}
210
211static int __init omap_init_clocksource_32k(void)
212{
213 static char err[] __initdata = KERN_ERR
214 "%s: can't register clocksource!\n";
215
216 if (cpu_is_omap16xx() || cpu_class_is_omap2()) {
217 struct clk *sync_32k_ick;
218
219 if (cpu_is_omap16xx())
220 clocksource_32k.read = omap16xx_32k_read;
221 else if (cpu_is_omap2420())
222 clocksource_32k.read = omap2420_32k_read;
223 else if (cpu_is_omap2430())
224 clocksource_32k.read = omap2430_32k_read;
225 else if (cpu_is_omap34xx())
226 clocksource_32k.read = omap34xx_32k_read;
227 else if (cpu_is_omap44xx())
228 clocksource_32k.read = omap44xx_32k_read;
229 else
230 return -ENODEV;
231
232 sync_32k_ick = clk_get(NULL, "omap_32ksync_ick");
233 if (sync_32k_ick)
234 clk_enable(sync_32k_ick);
235
236 clocksource_32k.mult = clocksource_hz2mult(32768,
237 clocksource_32k.shift);
238
239 offset_32k = clocksource_32k.read(&clocksource_32k);
240
241 if (clocksource_register(&clocksource_32k))
242 printk(err, clocksource_32k.name);
243 }
244 return 0;
245}
246arch_initcall(omap_init_clocksource_32k);
247
248#endif /* !(defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP15XX)) */
249
250/* Global address base setup code */
251
252#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
253
254static void __init __omap2_set_globals(struct omap_globals *omap2_globals)
255{
256 omap2_set_globals_tap(omap2_globals);
257 omap2_set_globals_sdrc(omap2_globals);
258 omap2_set_globals_control(omap2_globals);
259 omap2_set_globals_prcm(omap2_globals);
260 omap2_set_globals_uart(omap2_globals);
261}
262
263#endif
264
265#if defined(CONFIG_ARCH_OMAP2420)
266
267static struct omap_globals omap242x_globals = {
268 .class = OMAP242X_CLASS,
269 .tap = OMAP2_L4_IO_ADDRESS(0x48014000),
270 .sdrc = OMAP2420_SDRC_BASE,
271 .sms = OMAP2420_SMS_BASE,
272 .ctrl = OMAP2420_CTRL_BASE,
273 .prm = OMAP2420_PRM_BASE,
274 .cm = OMAP2420_CM_BASE,
275 .uart1_phys = OMAP2_UART1_BASE,
276 .uart2_phys = OMAP2_UART2_BASE,
277 .uart3_phys = OMAP2_UART3_BASE,
278};
279
280void __init omap2_set_globals_242x(void)
281{
282 __omap2_set_globals(&omap242x_globals);
283}
284#endif
285
286#if defined(CONFIG_ARCH_OMAP2430)
287
288static struct omap_globals omap243x_globals = {
289 .class = OMAP243X_CLASS,
290 .tap = OMAP2_L4_IO_ADDRESS(0x4900a000),
291 .sdrc = OMAP243X_SDRC_BASE,
292 .sms = OMAP243X_SMS_BASE,
293 .ctrl = OMAP243X_CTRL_BASE,
294 .prm = OMAP2430_PRM_BASE,
295 .cm = OMAP2430_CM_BASE,
296 .uart1_phys = OMAP2_UART1_BASE,
297 .uart2_phys = OMAP2_UART2_BASE,
298 .uart3_phys = OMAP2_UART3_BASE,
299};
300
301void __init omap2_set_globals_243x(void)
302{
303 __omap2_set_globals(&omap243x_globals);
304}
305#endif
306
307#if defined(CONFIG_ARCH_OMAP3)
308
309static struct omap_globals omap3_globals = {
310 .class = OMAP343X_CLASS,
311 .tap = OMAP2_L4_IO_ADDRESS(0x4830A000),
312 .sdrc = OMAP343X_SDRC_BASE,
313 .sms = OMAP343X_SMS_BASE,
314 .ctrl = OMAP343X_CTRL_BASE,
315 .prm = OMAP3430_PRM_BASE,
316 .cm = OMAP3430_CM_BASE,
317 .uart1_phys = OMAP3_UART1_BASE,
318 .uart2_phys = OMAP3_UART2_BASE,
319 .uart3_phys = OMAP3_UART3_BASE,
320 .uart4_phys = OMAP3_UART4_BASE, /* Only on 3630 */
321};
322
323void __init omap2_set_globals_3xxx(void)
324{
325 __omap2_set_globals(&omap3_globals);
326}
327
328void __init omap3_map_io(void)
329{
330 omap2_set_globals_3xxx();
331 omap34xx_map_common_io();
332}
333#endif
334
335#if defined(CONFIG_ARCH_OMAP4)
336static struct omap_globals omap4_globals = {
337 .class = OMAP443X_CLASS,
338 .tap = OMAP2_L4_IO_ADDRESS(OMAP443X_SCM_BASE),
339 .ctrl = OMAP443X_CTRL_BASE,
340 .prm = OMAP4430_PRM_BASE,
341 .cm = OMAP4430_CM_BASE,
342 .cm2 = OMAP4430_CM2_BASE,
343 .uart1_phys = OMAP4_UART1_BASE,
344 .uart2_phys = OMAP4_UART2_BASE,
345 .uart3_phys = OMAP4_UART3_BASE,
346 .uart4_phys = OMAP4_UART4_BASE,
347};
348
349void __init omap2_set_globals_443x(void)
350{
351 omap2_set_globals_tap(&omap4_globals);
352 omap2_set_globals_control(&omap4_globals);
353 omap2_set_globals_prcm(&omap4_globals);
354 omap2_set_globals_uart(&omap4_globals);
355}
356#endif
357
diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c
new file mode 100644
index 000000000000..f7fed6080190
--- /dev/null
+++ b/arch/arm/plat-omap/counter_32k.c
@@ -0,0 +1,207 @@
1/*
2 * OMAP 32ksynctimer/counter_32k-related code
3 *
4 * Copyright (C) 2009 Texas Instruments
5 * Copyright (C) 2010 Nokia Corporation
6 * Tony Lindgren <tony@atomide.com>
7 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@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 * NOTE: This timer is not the same timer as the old OMAP1 MPU timer.
14 */
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/clk.h>
18#include <linux/err.h>
19#include <linux/io.h>
20#include <linux/sched.h>
21
22#include <asm/sched_clock.h>
23
24#include <plat/common.h>
25#include <plat/board.h>
26
27#include <plat/clock.h>
28
29
30/*
31 * 32KHz clocksource ... always available, on pretty most chips except
32 * OMAP 730 and 1510. Other timers could be used as clocksources, with
33 * higher resolution in free-running counter modes (e.g. 12 MHz xtal),
34 * but systems won't necessarily want to spend resources that way.
35 */
36
37#define OMAP16XX_TIMER_32K_SYNCHRONIZED 0xfffbc410
38
39#include <linux/clocksource.h>
40
41/*
42 * offset_32k holds the init time counter value. It is then subtracted
43 * from every counter read to achieve a counter that counts time from the
44 * kernel boot (needed for sched_clock()).
45 */
46static u32 offset_32k __read_mostly;
47
48#ifdef CONFIG_ARCH_OMAP16XX
49static cycle_t notrace omap16xx_32k_read(struct clocksource *cs)
50{
51 return omap_readl(OMAP16XX_TIMER_32K_SYNCHRONIZED) - offset_32k;
52}
53#else
54#define omap16xx_32k_read NULL
55#endif
56
57#ifdef CONFIG_SOC_OMAP2420
58static cycle_t notrace omap2420_32k_read(struct clocksource *cs)
59{
60 return omap_readl(OMAP2420_32KSYNCT_BASE + 0x10) - offset_32k;
61}
62#else
63#define omap2420_32k_read NULL
64#endif
65
66#ifdef CONFIG_SOC_OMAP2430
67static cycle_t notrace omap2430_32k_read(struct clocksource *cs)
68{
69 return omap_readl(OMAP2430_32KSYNCT_BASE + 0x10) - offset_32k;
70}
71#else
72#define omap2430_32k_read NULL
73#endif
74
75#ifdef CONFIG_ARCH_OMAP3
76static cycle_t notrace omap34xx_32k_read(struct clocksource *cs)
77{
78 return omap_readl(OMAP3430_32KSYNCT_BASE + 0x10) - offset_32k;
79}
80#else
81#define omap34xx_32k_read NULL
82#endif
83
84#ifdef CONFIG_ARCH_OMAP4
85static cycle_t notrace omap44xx_32k_read(struct clocksource *cs)
86{
87 return omap_readl(OMAP4430_32KSYNCT_BASE + 0x10) - offset_32k;
88}
89#else
90#define omap44xx_32k_read NULL
91#endif
92
93/*
94 * Kernel assumes that sched_clock can be called early but may not have
95 * things ready yet.
96 */
97static cycle_t notrace omap_32k_read_dummy(struct clocksource *cs)
98{
99 return 0;
100}
101
102static struct clocksource clocksource_32k = {
103 .name = "32k_counter",
104 .rating = 250,
105 .read = omap_32k_read_dummy,
106 .mask = CLOCKSOURCE_MASK(32),
107 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
108};
109
110/*
111 * Returns current time from boot in nsecs. It's OK for this to wrap
112 * around for now, as it's just a relative time stamp.
113 */
114static DEFINE_CLOCK_DATA(cd);
115
116/*
117 * Constants generated by clocks_calc_mult_shift(m, s, 32768, NSEC_PER_SEC, 60).
118 * This gives a resolution of about 30us and a wrap period of about 36hrs.
119 */
120#define SC_MULT 4000000000u
121#define SC_SHIFT 17
122
123static inline unsigned long long notrace _omap_32k_sched_clock(void)
124{
125 u32 cyc = clocksource_32k.read(&clocksource_32k);
126 return cyc_to_fixed_sched_clock(&cd, cyc, (u32)~0, SC_MULT, SC_SHIFT);
127}
128
129#ifndef CONFIG_OMAP_MPU_TIMER
130unsigned long long notrace sched_clock(void)
131{
132 return _omap_32k_sched_clock();
133}
134#else
135unsigned long long notrace omap_32k_sched_clock(void)
136{
137 return _omap_32k_sched_clock();
138}
139#endif
140
141static void notrace omap_update_sched_clock(void)
142{
143 u32 cyc = clocksource_32k.read(&clocksource_32k);
144 update_sched_clock(&cd, cyc, (u32)~0);
145}
146
147/**
148 * read_persistent_clock - Return time from a persistent clock.
149 *
150 * Reads the time from a source which isn't disabled during PM, the
151 * 32k sync timer. Convert the cycles elapsed since last read into
152 * nsecs and adds to a monotonically increasing timespec.
153 */
154static struct timespec persistent_ts;
155static cycles_t cycles, last_cycles;
156void read_persistent_clock(struct timespec *ts)
157{
158 unsigned long long nsecs;
159 cycles_t delta;
160 struct timespec *tsp = &persistent_ts;
161
162 last_cycles = cycles;
163 cycles = clocksource_32k.read(&clocksource_32k);
164 delta = cycles - last_cycles;
165
166 nsecs = clocksource_cyc2ns(delta,
167 clocksource_32k.mult, clocksource_32k.shift);
168
169 timespec_add_ns(tsp, nsecs);
170 *ts = *tsp;
171}
172
173int __init omap_init_clocksource_32k(void)
174{
175 static char err[] __initdata = KERN_ERR
176 "%s: can't register clocksource!\n";
177
178 if (cpu_is_omap16xx() || cpu_class_is_omap2()) {
179 struct clk *sync_32k_ick;
180
181 if (cpu_is_omap16xx())
182 clocksource_32k.read = omap16xx_32k_read;
183 else if (cpu_is_omap2420())
184 clocksource_32k.read = omap2420_32k_read;
185 else if (cpu_is_omap2430())
186 clocksource_32k.read = omap2430_32k_read;
187 else if (cpu_is_omap34xx())
188 clocksource_32k.read = omap34xx_32k_read;
189 else if (cpu_is_omap44xx())
190 clocksource_32k.read = omap44xx_32k_read;
191 else
192 return -ENODEV;
193
194 sync_32k_ick = clk_get(NULL, "omap_32ksync_ick");
195 if (!IS_ERR(sync_32k_ick))
196 clk_enable(sync_32k_ick);
197
198 offset_32k = clocksource_32k.read(&clocksource_32k);
199
200 if (clocksource_register_hz(&clocksource_32k, 32768))
201 printk(err, clocksource_32k.name);
202
203 init_fixed_sched_clock(&cd, omap_update_sched_clock, 32,
204 32768, SC_MULT, SC_SHIFT);
205 }
206 return 0;
207}
diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/plat-omap/cpu-omap.c
index 6d3d33360056..da4f68dbba1d 100644
--- a/arch/arm/plat-omap/cpu-omap.c
+++ b/arch/arm/plat-omap/cpu-omap.c
@@ -40,7 +40,7 @@ static struct clk *mpu_clk;
40 40
41/* TODO: Add support for SDRAM timing changes */ 41/* TODO: Add support for SDRAM timing changes */
42 42
43int omap_verify_speed(struct cpufreq_policy *policy) 43static int omap_verify_speed(struct cpufreq_policy *policy)
44{ 44{
45 if (freq_table) 45 if (freq_table)
46 return cpufreq_frequency_table_verify(policy, freq_table); 46 return cpufreq_frequency_table_verify(policy, freq_table);
@@ -58,7 +58,7 @@ int omap_verify_speed(struct cpufreq_policy *policy)
58 return 0; 58 return 0;
59} 59}
60 60
61unsigned int omap_getspeed(unsigned int cpu) 61static unsigned int omap_getspeed(unsigned int cpu)
62{ 62{
63 unsigned long rate; 63 unsigned long rate;
64 64
@@ -101,7 +101,7 @@ static int omap_target(struct cpufreq_policy *policy,
101 return ret; 101 return ret;
102} 102}
103 103
104static int __init omap_cpu_init(struct cpufreq_policy *policy) 104static int __cpuinit omap_cpu_init(struct cpufreq_policy *policy)
105{ 105{
106 int result = 0; 106 int result = 0;
107 107
diff --git a/arch/arm/plat-omap/devices.c b/arch/arm/plat-omap/devices.c
index d1920be7833b..ea28f98d5d6a 100644
--- a/arch/arm/plat-omap/devices.c
+++ b/arch/arm/plat-omap/devices.c
@@ -15,13 +15,13 @@
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/memblock.h>
18 19
19#include <mach/hardware.h> 20#include <mach/hardware.h>
20#include <asm/mach-types.h> 21#include <asm/mach-types.h>
21#include <asm/mach/map.h> 22#include <asm/mach/map.h>
22 23
23#include <plat/tc.h> 24#include <plat/tc.h>
24#include <plat/control.h>
25#include <plat/board.h> 25#include <plat/board.h>
26#include <plat/mmc.h> 26#include <plat/mmc.h>
27#include <mach/gpio.h> 27#include <mach/gpio.h>
@@ -35,8 +35,8 @@
35 35
36static struct platform_device **omap_mcbsp_devices; 36static struct platform_device **omap_mcbsp_devices;
37 37
38void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config, 38void omap_mcbsp_register_board_cfg(struct resource *res, int res_count,
39 int size) 39 struct omap_mcbsp_platform_data *config, int size)
40{ 40{
41 int i; 41 int i;
42 42
@@ -54,6 +54,8 @@ void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
54 new_mcbsp = platform_device_alloc("omap-mcbsp", i + 1); 54 new_mcbsp = platform_device_alloc("omap-mcbsp", i + 1);
55 if (!new_mcbsp) 55 if (!new_mcbsp)
56 continue; 56 continue;
57 platform_device_add_resources(new_mcbsp, &res[i * res_count],
58 res_count);
57 new_mcbsp->dev.platform_data = &config[i]; 59 new_mcbsp->dev.platform_data = &config[i];
58 ret = platform_device_add(new_mcbsp); 60 ret = platform_device_add(new_mcbsp);
59 if (ret) { 61 if (ret) {
@@ -65,8 +67,8 @@ void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
65} 67}
66 68
67#else 69#else
68void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config, 70void omap_mcbsp_register_board_cfg(struct resource *res, int res_count,
69 int size) 71 struct omap_mcbsp_platform_data *config, int size)
70{ } 72{ }
71#endif 73#endif
72 74
@@ -232,44 +234,35 @@ static void omap_init_uwire(void)
232static inline void omap_init_uwire(void) {} 234static inline void omap_init_uwire(void) {}
233#endif 235#endif
234 236
235/*-------------------------------------------------------------------------*/ 237#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
236 238
237#if defined(CONFIG_OMAP_WATCHDOG) || defined(CONFIG_OMAP_WATCHDOG_MODULE) 239static phys_addr_t omap_dsp_phys_mempool_base;
238 240
239static struct resource wdt_resources[] = { 241void __init omap_dsp_reserve_sdram_memblock(void)
240 { 242{
241 .flags = IORESOURCE_MEM, 243 phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
242 }, 244 phys_addr_t paddr;
243};
244 245
245static struct platform_device omap_wdt_device = { 246 if (!size)
246 .name = "omap_wdt", 247 return;
247 .id = -1,
248 .num_resources = ARRAY_SIZE(wdt_resources),
249 .resource = wdt_resources,
250};
251 248
252static void omap_init_wdt(void) 249 paddr = memblock_alloc(size, SZ_1M);
253{ 250 if (!paddr) {
254 if (cpu_is_omap16xx()) 251 pr_err("%s: failed to reserve %x bytes\n",
255 wdt_resources[0].start = 0xfffeb000; 252 __func__, size);
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; 253 return;
254 }
255 memblock_free(paddr, size);
256 memblock_remove(paddr, size);
266 257
267 wdt_resources[0].end = wdt_resources[0].start + 0x4f; 258 omap_dsp_phys_mempool_base = paddr;
259}
268 260
269 (void) platform_device_register(&omap_wdt_device); 261phys_addr_t omap_dsp_get_mempool_base(void)
262{
263 return omap_dsp_phys_mempool_base;
270} 264}
271#else 265EXPORT_SYMBOL(omap_dsp_get_mempool_base);
272static inline void omap_init_wdt(void) {}
273#endif 266#endif
274 267
275/* 268/*
@@ -287,7 +280,7 @@ static inline void omap_init_wdt(void) {}
287 * Claiming GPIOs, and setting their direction and initial values, is the 280 * Claiming GPIOs, and setting their direction and initial values, is the
288 * responsibility of the device drivers. So is responding to probe(). 281 * responsibility of the device drivers. So is responding to probe().
289 * 282 *
290 * Board-specific knowlege like creating devices or pin setup is to be 283 * Board-specific knowledge like creating devices or pin setup is to be
291 * kept out of drivers as much as possible. In particular, pin setup 284 * kept out of drivers as much as possible. In particular, pin setup
292 * may be handled by the boot loader, and drivers should expect it will 285 * may be handled by the boot loader, and drivers should expect it will
293 * normally have been done by the time they're probed. 286 * normally have been done by the time they're probed.
@@ -300,7 +293,6 @@ static int __init omap_init_devices(void)
300 omap_init_rng(); 293 omap_init_rng();
301 omap_init_mcpdm(); 294 omap_init_mcpdm();
302 omap_init_uwire(); 295 omap_init_uwire();
303 omap_init_wdt();
304 return 0; 296 return 0;
305} 297}
306arch_initcall(omap_init_devices); 298arch_initcall(omap_init_devices);
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index ec7eddf9e525..c22217c2ee5f 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.
@@ -30,6 +34,7 @@
30#include <linux/irq.h> 34#include <linux/irq.h>
31#include <linux/io.h> 35#include <linux/io.h>
32#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/delay.h>
33 38
34#include <asm/system.h> 39#include <asm/system.h>
35#include <mach/hardware.h> 40#include <mach/hardware.h>
@@ -48,11 +53,15 @@ enum { DMA_CHAIN_STARTED, DMA_CHAIN_NOTSTARTED };
48#endif 53#endif
49 54
50#define OMAP_DMA_ACTIVE 0x01 55#define OMAP_DMA_ACTIVE 0x01
51#define OMAP2_DMA_CSR_CLEAR_MASK 0xffe 56#define OMAP2_DMA_CSR_CLEAR_MASK 0xffffffff
52 57
53#define OMAP_FUNC_MUX_ARM_BASE (0xfffe1000 + 0xec) 58#define OMAP_FUNC_MUX_ARM_BASE (0xfffe1000 + 0xec)
54 59
60static struct omap_system_dma_plat_info *p;
61static struct omap_dma_dev_attr *d;
62
55static int enable_1510_mode; 63static int enable_1510_mode;
64static u32 errata;
56 65
57static struct omap_dma_global_context_registers { 66static struct omap_dma_global_context_registers {
58 u32 dma_irqenable_l0; 67 u32 dma_irqenable_l0;
@@ -60,27 +69,6 @@ static struct omap_dma_global_context_registers {
60 u32 dma_gcr; 69 u32 dma_gcr;
61} omap_dma_global_context; 70} omap_dma_global_context;
62 71
63struct omap_dma_lch {
64 int next_lch;
65 int dev_id;
66 u16 saved_csr;
67 u16 enabled_irqs;
68 const char *dev_name;
69 void (*callback)(int lch, u16 ch_status, void *data);
70 void *data;
71
72#ifndef CONFIG_ARCH_OMAP1
73 /* required for Dynamic chaining */
74 int prev_linked_ch;
75 int next_linked_ch;
76 int state;
77 int chain_id;
78
79 int status;
80#endif
81 long flags;
82};
83
84struct dma_link_info { 72struct dma_link_info {
85 int *linked_dmach_q; 73 int *linked_dmach_q;
86 int no_of_lchs_linked; 74 int no_of_lchs_linked;
@@ -136,15 +124,6 @@ static int omap_dma_reserve_channels;
136 124
137static spinlock_t dma_chan_lock; 125static spinlock_t dma_chan_lock;
138static struct omap_dma_lch *dma_chan; 126static struct omap_dma_lch *dma_chan;
139static void __iomem *omap_dma_base;
140
141static const u8 omap1_dma_irq[OMAP1_LOGICAL_DMA_CH_COUNT] = {
142 INT_DMA_CH0_6, INT_DMA_CH1_7, INT_DMA_CH2_8, INT_DMA_CH3,
143 INT_DMA_CH4, INT_DMA_CH5, INT_1610_DMA_CH6, INT_1610_DMA_CH7,
144 INT_1610_DMA_CH8, INT_1610_DMA_CH9, INT_1610_DMA_CH10,
145 INT_1610_DMA_CH11, INT_1610_DMA_CH12, INT_1610_DMA_CH13,
146 INT_1610_DMA_CH14, INT_1610_DMA_CH15, INT_DMA_LCD
147};
148 127
149static inline void disable_lnk(int lch); 128static inline void disable_lnk(int lch);
150static void omap_disable_channel_irq(int lch); 129static void omap_disable_channel_irq(int lch);
@@ -153,27 +132,9 @@ static inline void omap_enable_channel_irq(int lch);
153#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", \
154 __func__); 133 __func__);
155 134
156#define dma_read(reg) \
157({ \
158 u32 __val; \
159 if (cpu_class_is_omap1()) \
160 __val = __raw_readw(omap_dma_base + OMAP1_DMA_##reg); \
161 else \
162 __val = __raw_readl(omap_dma_base + OMAP_DMA4_##reg); \
163 __val; \
164})
165
166#define dma_write(val, reg) \
167({ \
168 if (cpu_class_is_omap1()) \
169 __raw_writew((u16)(val), omap_dma_base + OMAP1_DMA_##reg); \
170 else \
171 __raw_writel((val), omap_dma_base + OMAP_DMA4_##reg); \
172})
173
174#ifdef CONFIG_ARCH_OMAP15XX 135#ifdef CONFIG_ARCH_OMAP15XX
175/* 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 */
176int omap_dma_in_1510_mode(void) 137static int omap_dma_in_1510_mode(void)
177{ 138{
178 return enable_1510_mode; 139 return enable_1510_mode;
179} 140}
@@ -205,16 +166,6 @@ static inline void set_gdma_dev(int req, int dev)
205#define set_gdma_dev(req, dev) do {} while (0) 166#define set_gdma_dev(req, dev) do {} while (0)
206#endif 167#endif
207 168
208/* Omap1 only */
209static void clear_lch_regs(int lch)
210{
211 int i;
212 void __iomem *lch_base = omap_dma_base + OMAP1_DMA_CH_BASE(lch);
213
214 for (i = 0; i < 0x2c; i += 2)
215 __raw_writew(0, lch_base + i);
216}
217
218void omap_set_dma_priority(int lch, int dst_port, int priority) 169void omap_set_dma_priority(int lch, int dst_port, int priority)
219{ 170{
220 unsigned long reg; 171 unsigned long reg;
@@ -247,12 +198,12 @@ void omap_set_dma_priority(int lch, int dst_port, int priority)
247 if (cpu_class_is_omap2()) { 198 if (cpu_class_is_omap2()) {
248 u32 ccr; 199 u32 ccr;
249 200
250 ccr = dma_read(CCR(lch)); 201 ccr = p->dma_read(CCR, lch);
251 if (priority) 202 if (priority)
252 ccr |= (1 << 6); 203 ccr |= (1 << 6);
253 else 204 else
254 ccr &= ~(1 << 6); 205 ccr &= ~(1 << 6);
255 dma_write(ccr, CCR(lch)); 206 p->dma_write(ccr, CCR, lch);
256 } 207 }
257} 208}
258EXPORT_SYMBOL(omap_set_dma_priority); 209EXPORT_SYMBOL(omap_set_dma_priority);
@@ -263,31 +214,31 @@ void omap_set_dma_transfer_params(int lch, int data_type, int elem_count,
263{ 214{
264 u32 l; 215 u32 l;
265 216
266 l = dma_read(CSDP(lch)); 217 l = p->dma_read(CSDP, lch);
267 l &= ~0x03; 218 l &= ~0x03;
268 l |= data_type; 219 l |= data_type;
269 dma_write(l, CSDP(lch)); 220 p->dma_write(l, CSDP, lch);
270 221
271 if (cpu_class_is_omap1()) { 222 if (cpu_class_is_omap1()) {
272 u16 ccr; 223 u16 ccr;
273 224
274 ccr = dma_read(CCR(lch)); 225 ccr = p->dma_read(CCR, lch);
275 ccr &= ~(1 << 5); 226 ccr &= ~(1 << 5);
276 if (sync_mode == OMAP_DMA_SYNC_FRAME) 227 if (sync_mode == OMAP_DMA_SYNC_FRAME)
277 ccr |= 1 << 5; 228 ccr |= 1 << 5;
278 dma_write(ccr, CCR(lch)); 229 p->dma_write(ccr, CCR, lch);
279 230
280 ccr = dma_read(CCR2(lch)); 231 ccr = p->dma_read(CCR2, lch);
281 ccr &= ~(1 << 2); 232 ccr &= ~(1 << 2);
282 if (sync_mode == OMAP_DMA_SYNC_BLOCK) 233 if (sync_mode == OMAP_DMA_SYNC_BLOCK)
283 ccr |= 1 << 2; 234 ccr |= 1 << 2;
284 dma_write(ccr, CCR2(lch)); 235 p->dma_write(ccr, CCR2, lch);
285 } 236 }
286 237
287 if (cpu_class_is_omap2() && dma_trigger) { 238 if (cpu_class_is_omap2() && dma_trigger) {
288 u32 val; 239 u32 val;
289 240
290 val = dma_read(CCR(lch)); 241 val = p->dma_read(CCR, lch);
291 242
292 /* DMA_SYNCHRO_CONTROL_UPPER depends on the channel number */ 243 /* DMA_SYNCHRO_CONTROL_UPPER depends on the channel number */
293 val &= ~((1 << 23) | (3 << 19) | 0x1f); 244 val &= ~((1 << 23) | (3 << 19) | 0x1f);
@@ -312,11 +263,11 @@ void omap_set_dma_transfer_params(int lch, int data_type, int elem_count,
312 } else { 263 } else {
313 val &= ~(1 << 24); /* dest synch */ 264 val &= ~(1 << 24); /* dest synch */
314 } 265 }
315 dma_write(val, CCR(lch)); 266 p->dma_write(val, CCR, lch);
316 } 267 }
317 268
318 dma_write(elem_count, CEN(lch)); 269 p->dma_write(elem_count, CEN, lch);
319 dma_write(frame_count, CFN(lch)); 270 p->dma_write(frame_count, CFN, lch);
320} 271}
321EXPORT_SYMBOL(omap_set_dma_transfer_params); 272EXPORT_SYMBOL(omap_set_dma_transfer_params);
322 273
@@ -327,7 +278,7 @@ void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color)
327 if (cpu_class_is_omap1()) { 278 if (cpu_class_is_omap1()) {
328 u16 w; 279 u16 w;
329 280
330 w = dma_read(CCR2(lch)); 281 w = p->dma_read(CCR2, lch);
331 w &= ~0x03; 282 w &= ~0x03;
332 283
333 switch (mode) { 284 switch (mode) {
@@ -342,23 +293,22 @@ void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color)
342 default: 293 default:
343 BUG(); 294 BUG();
344 } 295 }
345 dma_write(w, CCR2(lch)); 296 p->dma_write(w, CCR2, lch);
346 297
347 w = dma_read(LCH_CTRL(lch)); 298 w = p->dma_read(LCH_CTRL, lch);
348 w &= ~0x0f; 299 w &= ~0x0f;
349 /* Default is channel type 2D */ 300 /* Default is channel type 2D */
350 if (mode) { 301 if (mode) {
351 dma_write((u16)color, COLOR_L(lch)); 302 p->dma_write(color, COLOR, lch);
352 dma_write((u16)(color >> 16), COLOR_U(lch));
353 w |= 1; /* Channel type G */ 303 w |= 1; /* Channel type G */
354 } 304 }
355 dma_write(w, LCH_CTRL(lch)); 305 p->dma_write(w, LCH_CTRL, lch);
356 } 306 }
357 307
358 if (cpu_class_is_omap2()) { 308 if (cpu_class_is_omap2()) {
359 u32 val; 309 u32 val;
360 310
361 val = dma_read(CCR(lch)); 311 val = p->dma_read(CCR, lch);
362 val &= ~((1 << 17) | (1 << 16)); 312 val &= ~((1 << 17) | (1 << 16));
363 313
364 switch (mode) { 314 switch (mode) {
@@ -373,10 +323,10 @@ void omap_set_dma_color_mode(int lch, enum omap_dma_color_mode mode, u32 color)
373 default: 323 default:
374 BUG(); 324 BUG();
375 } 325 }
376 dma_write(val, CCR(lch)); 326 p->dma_write(val, CCR, lch);
377 327
378 color &= 0xffffff; 328 color &= 0xffffff;
379 dma_write(color, COLOR(lch)); 329 p->dma_write(color, COLOR, lch);
380 } 330 }
381} 331}
382EXPORT_SYMBOL(omap_set_dma_color_mode); 332EXPORT_SYMBOL(omap_set_dma_color_mode);
@@ -386,10 +336,10 @@ void omap_set_dma_write_mode(int lch, enum omap_dma_write_mode mode)
386 if (cpu_class_is_omap2()) { 336 if (cpu_class_is_omap2()) {
387 u32 csdp; 337 u32 csdp;
388 338
389 csdp = dma_read(CSDP(lch)); 339 csdp = p->dma_read(CSDP, lch);
390 csdp &= ~(0x3 << 16); 340 csdp &= ~(0x3 << 16);
391 csdp |= (mode << 16); 341 csdp |= (mode << 16);
392 dma_write(csdp, CSDP(lch)); 342 p->dma_write(csdp, CSDP, lch);
393 } 343 }
394} 344}
395EXPORT_SYMBOL(omap_set_dma_write_mode); 345EXPORT_SYMBOL(omap_set_dma_write_mode);
@@ -399,10 +349,10 @@ void omap_set_dma_channel_mode(int lch, enum omap_dma_channel_mode mode)
399 if (cpu_class_is_omap1() && !cpu_is_omap15xx()) { 349 if (cpu_class_is_omap1() && !cpu_is_omap15xx()) {
400 u32 l; 350 u32 l;
401 351
402 l = dma_read(LCH_CTRL(lch)); 352 l = p->dma_read(LCH_CTRL, lch);
403 l &= ~0x7; 353 l &= ~0x7;
404 l |= mode; 354 l |= mode;
405 dma_write(l, LCH_CTRL(lch)); 355 p->dma_write(l, LCH_CTRL, lch);
406 } 356 }
407} 357}
408EXPORT_SYMBOL(omap_set_dma_channel_mode); 358EXPORT_SYMBOL(omap_set_dma_channel_mode);
@@ -417,27 +367,21 @@ void omap_set_dma_src_params(int lch, int src_port, int src_amode,
417 if (cpu_class_is_omap1()) { 367 if (cpu_class_is_omap1()) {
418 u16 w; 368 u16 w;
419 369
420 w = dma_read(CSDP(lch)); 370 w = p->dma_read(CSDP, lch);
421 w &= ~(0x1f << 2); 371 w &= ~(0x1f << 2);
422 w |= src_port << 2; 372 w |= src_port << 2;
423 dma_write(w, CSDP(lch)); 373 p->dma_write(w, CSDP, lch);
424 } 374 }
425 375
426 l = dma_read(CCR(lch)); 376 l = p->dma_read(CCR, lch);
427 l &= ~(0x03 << 12); 377 l &= ~(0x03 << 12);
428 l |= src_amode << 12; 378 l |= src_amode << 12;
429 dma_write(l, CCR(lch)); 379 p->dma_write(l, CCR, lch);
430 380
431 if (cpu_class_is_omap1()) { 381 p->dma_write(src_start, CSSA, lch);
432 dma_write(src_start >> 16, CSSA_U(lch));
433 dma_write((u16)src_start, CSSA_L(lch));
434 }
435 382
436 if (cpu_class_is_omap2()) 383 p->dma_write(src_ei, CSEI, lch);
437 dma_write(src_start, CSSA(lch)); 384 p->dma_write(src_fi, CSFI, lch);
438
439 dma_write(src_ei, CSEI(lch));
440 dma_write(src_fi, CSFI(lch));
441} 385}
442EXPORT_SYMBOL(omap_set_dma_src_params); 386EXPORT_SYMBOL(omap_set_dma_src_params);
443 387
@@ -465,8 +409,8 @@ void omap_set_dma_src_index(int lch, int eidx, int fidx)
465 if (cpu_class_is_omap2()) 409 if (cpu_class_is_omap2())
466 return; 410 return;
467 411
468 dma_write(eidx, CSEI(lch)); 412 p->dma_write(eidx, CSEI, lch);
469 dma_write(fidx, CSFI(lch)); 413 p->dma_write(fidx, CSFI, lch);
470} 414}
471EXPORT_SYMBOL(omap_set_dma_src_index); 415EXPORT_SYMBOL(omap_set_dma_src_index);
472 416
@@ -474,11 +418,11 @@ void omap_set_dma_src_data_pack(int lch, int enable)
474{ 418{
475 u32 l; 419 u32 l;
476 420
477 l = dma_read(CSDP(lch)); 421 l = p->dma_read(CSDP, lch);
478 l &= ~(1 << 6); 422 l &= ~(1 << 6);
479 if (enable) 423 if (enable)
480 l |= (1 << 6); 424 l |= (1 << 6);
481 dma_write(l, CSDP(lch)); 425 p->dma_write(l, CSDP, lch);
482} 426}
483EXPORT_SYMBOL(omap_set_dma_src_data_pack); 427EXPORT_SYMBOL(omap_set_dma_src_data_pack);
484 428
@@ -487,7 +431,7 @@ void omap_set_dma_src_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)
487 unsigned int burst = 0; 431 unsigned int burst = 0;
488 u32 l; 432 u32 l;
489 433
490 l = dma_read(CSDP(lch)); 434 l = p->dma_read(CSDP, lch);
491 l &= ~(0x03 << 7); 435 l &= ~(0x03 << 7);
492 436
493 switch (burst_mode) { 437 switch (burst_mode) {
@@ -523,7 +467,7 @@ void omap_set_dma_src_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)
523 } 467 }
524 468
525 l |= (burst << 7); 469 l |= (burst << 7);
526 dma_write(l, CSDP(lch)); 470 p->dma_write(l, CSDP, lch);
527} 471}
528EXPORT_SYMBOL(omap_set_dma_src_burst_mode); 472EXPORT_SYMBOL(omap_set_dma_src_burst_mode);
529 473
@@ -535,27 +479,21 @@ void omap_set_dma_dest_params(int lch, int dest_port, int dest_amode,
535 u32 l; 479 u32 l;
536 480
537 if (cpu_class_is_omap1()) { 481 if (cpu_class_is_omap1()) {
538 l = dma_read(CSDP(lch)); 482 l = p->dma_read(CSDP, lch);
539 l &= ~(0x1f << 9); 483 l &= ~(0x1f << 9);
540 l |= dest_port << 9; 484 l |= dest_port << 9;
541 dma_write(l, CSDP(lch)); 485 p->dma_write(l, CSDP, lch);
542 } 486 }
543 487
544 l = dma_read(CCR(lch)); 488 l = p->dma_read(CCR, lch);
545 l &= ~(0x03 << 14); 489 l &= ~(0x03 << 14);
546 l |= dest_amode << 14; 490 l |= dest_amode << 14;
547 dma_write(l, CCR(lch)); 491 p->dma_write(l, CCR, lch);
548 492
549 if (cpu_class_is_omap1()) { 493 p->dma_write(dest_start, CDSA, lch);
550 dma_write(dest_start >> 16, CDSA_U(lch));
551 dma_write(dest_start, CDSA_L(lch));
552 }
553
554 if (cpu_class_is_omap2())
555 dma_write(dest_start, CDSA(lch));
556 494
557 dma_write(dst_ei, CDEI(lch)); 495 p->dma_write(dst_ei, CDEI, lch);
558 dma_write(dst_fi, CDFI(lch)); 496 p->dma_write(dst_fi, CDFI, lch);
559} 497}
560EXPORT_SYMBOL(omap_set_dma_dest_params); 498EXPORT_SYMBOL(omap_set_dma_dest_params);
561 499
@@ -564,8 +502,8 @@ void omap_set_dma_dest_index(int lch, int eidx, int fidx)
564 if (cpu_class_is_omap2()) 502 if (cpu_class_is_omap2())
565 return; 503 return;
566 504
567 dma_write(eidx, CDEI(lch)); 505 p->dma_write(eidx, CDEI, lch);
568 dma_write(fidx, CDFI(lch)); 506 p->dma_write(fidx, CDFI, lch);
569} 507}
570EXPORT_SYMBOL(omap_set_dma_dest_index); 508EXPORT_SYMBOL(omap_set_dma_dest_index);
571 509
@@ -573,11 +511,11 @@ void omap_set_dma_dest_data_pack(int lch, int enable)
573{ 511{
574 u32 l; 512 u32 l;
575 513
576 l = dma_read(CSDP(lch)); 514 l = p->dma_read(CSDP, lch);
577 l &= ~(1 << 13); 515 l &= ~(1 << 13);
578 if (enable) 516 if (enable)
579 l |= 1 << 13; 517 l |= 1 << 13;
580 dma_write(l, CSDP(lch)); 518 p->dma_write(l, CSDP, lch);
581} 519}
582EXPORT_SYMBOL(omap_set_dma_dest_data_pack); 520EXPORT_SYMBOL(omap_set_dma_dest_data_pack);
583 521
@@ -586,7 +524,7 @@ void omap_set_dma_dest_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)
586 unsigned int burst = 0; 524 unsigned int burst = 0;
587 u32 l; 525 u32 l;
588 526
589 l = dma_read(CSDP(lch)); 527 l = p->dma_read(CSDP, lch);
590 l &= ~(0x03 << 14); 528 l &= ~(0x03 << 14);
591 529
592 switch (burst_mode) { 530 switch (burst_mode) {
@@ -619,7 +557,7 @@ void omap_set_dma_dest_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)
619 return; 557 return;
620 } 558 }
621 l |= (burst << 14); 559 l |= (burst << 14);
622 dma_write(l, CSDP(lch)); 560 p->dma_write(l, CSDP, lch);
623} 561}
624EXPORT_SYMBOL(omap_set_dma_dest_burst_mode); 562EXPORT_SYMBOL(omap_set_dma_dest_burst_mode);
625 563
@@ -629,18 +567,18 @@ static inline void omap_enable_channel_irq(int lch)
629 567
630 /* Clear CSR */ 568 /* Clear CSR */
631 if (cpu_class_is_omap1()) 569 if (cpu_class_is_omap1())
632 status = dma_read(CSR(lch)); 570 status = p->dma_read(CSR, lch);
633 else if (cpu_class_is_omap2()) 571 else if (cpu_class_is_omap2())
634 dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(lch)); 572 p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, lch);
635 573
636 /* Enable some nice interrupts. */ 574 /* Enable some nice interrupts. */
637 dma_write(dma_chan[lch].enabled_irqs, CICR(lch)); 575 p->dma_write(dma_chan[lch].enabled_irqs, CICR, lch);
638} 576}
639 577
640static void omap_disable_channel_irq(int lch) 578static void omap_disable_channel_irq(int lch)
641{ 579{
642 if (cpu_class_is_omap2()) 580 if (cpu_class_is_omap2())
643 dma_write(0, CICR(lch)); 581 p->dma_write(0, CICR, lch);
644} 582}
645 583
646void omap_enable_dma_irq(int lch, u16 bits) 584void omap_enable_dma_irq(int lch, u16 bits)
@@ -659,7 +597,7 @@ static inline void enable_lnk(int lch)
659{ 597{
660 u32 l; 598 u32 l;
661 599
662 l = dma_read(CLNK_CTRL(lch)); 600 l = p->dma_read(CLNK_CTRL, lch);
663 601
664 if (cpu_class_is_omap1()) 602 if (cpu_class_is_omap1())
665 l &= ~(1 << 14); 603 l &= ~(1 << 14);
@@ -674,18 +612,18 @@ static inline void enable_lnk(int lch)
674 l = dma_chan[lch].next_linked_ch | (1 << 15); 612 l = dma_chan[lch].next_linked_ch | (1 << 15);
675#endif 613#endif
676 614
677 dma_write(l, CLNK_CTRL(lch)); 615 p->dma_write(l, CLNK_CTRL, lch);
678} 616}
679 617
680static inline void disable_lnk(int lch) 618static inline void disable_lnk(int lch)
681{ 619{
682 u32 l; 620 u32 l;
683 621
684 l = dma_read(CLNK_CTRL(lch)); 622 l = p->dma_read(CLNK_CTRL, lch);
685 623
686 /* Disable interrupts */ 624 /* Disable interrupts */
687 if (cpu_class_is_omap1()) { 625 if (cpu_class_is_omap1()) {
688 dma_write(0, CICR(lch)); 626 p->dma_write(0, CICR, lch);
689 /* Set the STOP_LNK bit */ 627 /* Set the STOP_LNK bit */
690 l |= 1 << 14; 628 l |= 1 << 14;
691 } 629 }
@@ -696,7 +634,7 @@ static inline void disable_lnk(int lch)
696 l &= ~(1 << 15); 634 l &= ~(1 << 15);
697 } 635 }
698 636
699 dma_write(l, CLNK_CTRL(lch)); 637 p->dma_write(l, CLNK_CTRL, lch);
700 dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE; 638 dma_chan[lch].flags &= ~OMAP_DMA_ACTIVE;
701} 639}
702 640
@@ -709,9 +647,9 @@ static inline void omap2_enable_irq_lch(int lch)
709 return; 647 return;
710 648
711 spin_lock_irqsave(&dma_chan_lock, flags); 649 spin_lock_irqsave(&dma_chan_lock, flags);
712 val = dma_read(IRQENABLE_L0); 650 val = p->dma_read(IRQENABLE_L0, lch);
713 val |= 1 << lch; 651 val |= 1 << lch;
714 dma_write(val, IRQENABLE_L0); 652 p->dma_write(val, IRQENABLE_L0, lch);
715 spin_unlock_irqrestore(&dma_chan_lock, flags); 653 spin_unlock_irqrestore(&dma_chan_lock, flags);
716} 654}
717 655
@@ -724,9 +662,9 @@ static inline void omap2_disable_irq_lch(int lch)
724 return; 662 return;
725 663
726 spin_lock_irqsave(&dma_chan_lock, flags); 664 spin_lock_irqsave(&dma_chan_lock, flags);
727 val = dma_read(IRQENABLE_L0); 665 val = p->dma_read(IRQENABLE_L0, lch);
728 val &= ~(1 << lch); 666 val &= ~(1 << lch);
729 dma_write(val, IRQENABLE_L0); 667 p->dma_write(val, IRQENABLE_L0, lch);
730 spin_unlock_irqrestore(&dma_chan_lock, flags); 668 spin_unlock_irqrestore(&dma_chan_lock, flags);
731} 669}
732 670
@@ -753,8 +691,8 @@ int omap_request_dma(int dev_id, const char *dev_name,
753 chan = dma_chan + free_ch; 691 chan = dma_chan + free_ch;
754 chan->dev_id = dev_id; 692 chan->dev_id = dev_id;
755 693
756 if (cpu_class_is_omap1()) 694 if (p->clear_lch_regs)
757 clear_lch_regs(free_ch); 695 p->clear_lch_regs(free_ch);
758 696
759 if (cpu_class_is_omap2()) 697 if (cpu_class_is_omap2())
760 omap_clear_dma(free_ch); 698 omap_clear_dma(free_ch);
@@ -791,17 +729,17 @@ int omap_request_dma(int dev_id, const char *dev_name,
791 * Disable the 1510 compatibility mode and set the sync device 729 * Disable the 1510 compatibility mode and set the sync device
792 * id. 730 * id.
793 */ 731 */
794 dma_write(dev_id | (1 << 10), CCR(free_ch)); 732 p->dma_write(dev_id | (1 << 10), CCR, free_ch);
795 } else if (cpu_is_omap7xx() || cpu_is_omap15xx()) { 733 } else if (cpu_is_omap7xx() || cpu_is_omap15xx()) {
796 dma_write(dev_id, CCR(free_ch)); 734 p->dma_write(dev_id, CCR, free_ch);
797 } 735 }
798 736
799 if (cpu_class_is_omap2()) { 737 if (cpu_class_is_omap2()) {
800 omap2_enable_irq_lch(free_ch); 738 omap2_enable_irq_lch(free_ch);
801 omap_enable_channel_irq(free_ch); 739 omap_enable_channel_irq(free_ch);
802 /* Clear the CSR register and IRQ status register */ 740 /* Clear the CSR register and IRQ status register */
803 dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(free_ch)); 741 p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, free_ch);
804 dma_write(1 << free_ch, IRQSTATUS_L0); 742 p->dma_write(1 << free_ch, IRQSTATUS_L0, 0);
805 } 743 }
806 744
807 *dma_ch_out = free_ch; 745 *dma_ch_out = free_ch;
@@ -822,23 +760,23 @@ void omap_free_dma(int lch)
822 760
823 if (cpu_class_is_omap1()) { 761 if (cpu_class_is_omap1()) {
824 /* Disable all DMA interrupts for the channel. */ 762 /* Disable all DMA interrupts for the channel. */
825 dma_write(0, CICR(lch)); 763 p->dma_write(0, CICR, lch);
826 /* Make sure the DMA transfer is stopped. */ 764 /* Make sure the DMA transfer is stopped. */
827 dma_write(0, CCR(lch)); 765 p->dma_write(0, CCR, lch);
828 } 766 }
829 767
830 if (cpu_class_is_omap2()) { 768 if (cpu_class_is_omap2()) {
831 omap2_disable_irq_lch(lch); 769 omap2_disable_irq_lch(lch);
832 770
833 /* Clear the CSR register and IRQ status register */ 771 /* Clear the CSR register and IRQ status register */
834 dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(lch)); 772 p->dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR, lch);
835 dma_write(1 << lch, IRQSTATUS_L0); 773 p->dma_write(1 << lch, IRQSTATUS_L0, lch);
836 774
837 /* Disable all DMA interrupts for the channel. */ 775 /* Disable all DMA interrupts for the channel. */
838 dma_write(0, CICR(lch)); 776 p->dma_write(0, CICR, lch);
839 777
840 /* Make sure the DMA transfer is stopped. */ 778 /* Make sure the DMA transfer is stopped. */
841 dma_write(0, CCR(lch)); 779 p->dma_write(0, CCR, lch);
842 omap_clear_dma(lch); 780 omap_clear_dma(lch);
843 } 781 }
844 782
@@ -879,7 +817,7 @@ omap_dma_set_global_params(int arb_rate, int max_fifo_depth, int tparams)
879 reg |= (0x3 & tparams) << 12; 817 reg |= (0x3 & tparams) << 12;
880 reg |= (arb_rate & 0xff) << 16; 818 reg |= (arb_rate & 0xff) << 16;
881 819
882 dma_write(reg, GCR); 820 p->dma_write(reg, GCR, 0);
883} 821}
884EXPORT_SYMBOL(omap_dma_set_global_params); 822EXPORT_SYMBOL(omap_dma_set_global_params);
885 823
@@ -902,14 +840,14 @@ omap_dma_set_prio_lch(int lch, unsigned char read_prio,
902 printk(KERN_ERR "Invalid channel id\n"); 840 printk(KERN_ERR "Invalid channel id\n");
903 return -EINVAL; 841 return -EINVAL;
904 } 842 }
905 l = dma_read(CCR(lch)); 843 l = p->dma_read(CCR, lch);
906 l &= ~((1 << 6) | (1 << 26)); 844 l &= ~((1 << 6) | (1 << 26));
907 if (cpu_is_omap2430() || cpu_is_omap34xx() || cpu_is_omap44xx()) 845 if (cpu_is_omap2430() || cpu_is_omap34xx() || cpu_is_omap44xx())
908 l |= ((read_prio & 0x1) << 6) | ((write_prio & 0x1) << 26); 846 l |= ((read_prio & 0x1) << 6) | ((write_prio & 0x1) << 26);
909 else 847 else
910 l |= ((read_prio & 0x1) << 6); 848 l |= ((read_prio & 0x1) << 6);
911 849
912 dma_write(l, CCR(lch)); 850 p->dma_write(l, CCR, lch);
913 851
914 return 0; 852 return 0;
915} 853}
@@ -924,25 +862,7 @@ void omap_clear_dma(int lch)
924 unsigned long flags; 862 unsigned long flags;
925 863
926 local_irq_save(flags); 864 local_irq_save(flags);
927 865 p->clear_dma(lch);
928 if (cpu_class_is_omap1()) {
929 u32 l;
930
931 l = dma_read(CCR(lch));
932 l &= ~OMAP_DMA_CCR_EN;
933 dma_write(l, CCR(lch));
934
935 /* Clear pending interrupts */
936 l = dma_read(CSR(lch));
937 }
938
939 if (cpu_class_is_omap2()) {
940 int i;
941 void __iomem *lch_base = omap_dma_base + OMAP_DMA4_CH_BASE(lch);
942 for (i = 0; i < 0x44; i += 4)
943 __raw_writel(0, lch_base + i);
944 }
945
946 local_irq_restore(flags); 866 local_irq_restore(flags);
947} 867}
948EXPORT_SYMBOL(omap_clear_dma); 868EXPORT_SYMBOL(omap_clear_dma);
@@ -956,13 +876,13 @@ void omap_start_dma(int lch)
956 * before starting dma transfer. 876 * before starting dma transfer.
957 */ 877 */
958 if (cpu_is_omap15xx()) 878 if (cpu_is_omap15xx())
959 dma_write(0, CPC(lch)); 879 p->dma_write(0, CPC, lch);
960 else 880 else
961 dma_write(0, CDAC(lch)); 881 p->dma_write(0, CDAC, lch);
962 882
963 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) {
964 int next_lch, cur_lch; 884 int next_lch, cur_lch;
965 char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT]; 885 char dma_chan_link_map[dma_lch_count];
966 886
967 dma_chan_link_map[lch] = 1; 887 dma_chan_link_map[lch] = 1;
968 /* Set the link register of the first channel */ 888 /* Set the link register of the first channel */
@@ -984,26 +904,18 @@ void omap_start_dma(int lch)
984 904
985 cur_lch = next_lch; 905 cur_lch = next_lch;
986 } while (next_lch != -1); 906 } while (next_lch != -1);
987 } else if (cpu_is_omap242x() || 907 } else if (IS_DMA_ERRATA(DMA_ERRATA_PARALLEL_CHANNELS))
988 (cpu_is_omap243x() && omap_type() <= OMAP2430_REV_ES1_0)) { 908 p->dma_write(lch, CLNK_CTRL, lch);
989
990 /* Errata: Need to write lch even if not using chaining */
991 dma_write(lch, CLNK_CTRL(lch));
992 }
993 909
994 omap_enable_channel_irq(lch); 910 omap_enable_channel_irq(lch);
995 911
996 l = dma_read(CCR(lch)); 912 l = p->dma_read(CCR, lch);
997
998 /*
999 * Errata: On ES2.0 BUFFERING disable must be set.
1000 * This will always fail on ES1.0
1001 */
1002 if (cpu_is_omap24xx())
1003 l |= OMAP_DMA_CCR_EN;
1004 913
914 if (IS_DMA_ERRATA(DMA_ERRATA_IFRAME_BUFFERING))
915 l |= OMAP_DMA_CCR_BUFFERING_DISABLE;
1005 l |= OMAP_DMA_CCR_EN; 916 l |= OMAP_DMA_CCR_EN;
1006 dma_write(l, CCR(lch)); 917
918 p->dma_write(l, CCR, lch);
1007 919
1008 dma_chan[lch].flags |= OMAP_DMA_ACTIVE; 920 dma_chan[lch].flags |= OMAP_DMA_ACTIVE;
1009} 921}
@@ -1015,15 +927,46 @@ void omap_stop_dma(int lch)
1015 927
1016 /* Disable all interrupts on the channel */ 928 /* Disable all interrupts on the channel */
1017 if (cpu_class_is_omap1()) 929 if (cpu_class_is_omap1())
1018 dma_write(0, CICR(lch)); 930 p->dma_write(0, CICR, lch);
1019 931
1020 l = dma_read(CCR(lch)); 932 l = p->dma_read(CCR, lch);
1021 l &= ~OMAP_DMA_CCR_EN; 933 if (IS_DMA_ERRATA(DMA_ERRATA_i541) &&
1022 dma_write(l, CCR(lch)); 934 (l & OMAP_DMA_CCR_SEL_SRC_DST_SYNC)) {
935 int i = 0;
936 u32 sys_cf;
937
938 /* Configure No-Standby */
939 l = p->dma_read(OCP_SYSCONFIG, lch);
940 sys_cf = l;
941 l &= ~DMA_SYSCONFIG_MIDLEMODE_MASK;
942 l |= DMA_SYSCONFIG_MIDLEMODE(DMA_IDLEMODE_NO_IDLE);
943 p->dma_write(l , OCP_SYSCONFIG, 0);
944
945 l = p->dma_read(CCR, lch);
946 l &= ~OMAP_DMA_CCR_EN;
947 p->dma_write(l, CCR, lch);
948
949 /* Wait for sDMA FIFO drain */
950 l = p->dma_read(CCR, lch);
951 while (i < 100 && (l & (OMAP_DMA_CCR_RD_ACTIVE |
952 OMAP_DMA_CCR_WR_ACTIVE))) {
953 udelay(5);
954 i++;
955 l = p->dma_read(CCR, lch);
956 }
957 if (i >= 100)
958 printk(KERN_ERR "DMA drain did not complete on "
959 "lch %d\n", lch);
960 /* Restore OCP_SYSCONFIG */
961 p->dma_write(sys_cf, OCP_SYSCONFIG, lch);
962 } else {
963 l &= ~OMAP_DMA_CCR_EN;
964 p->dma_write(l, CCR, lch);
965 }
1023 966
1024 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) {
1025 int next_lch, cur_lch = lch; 968 int next_lch, cur_lch = lch;
1026 char dma_chan_link_map[OMAP_DMA4_LOGICAL_DMA_CH_COUNT]; 969 char dma_chan_link_map[dma_lch_count];
1027 970
1028 memset(dma_chan_link_map, 0, sizeof(dma_chan_link_map)); 971 memset(dma_chan_link_map, 0, sizeof(dma_chan_link_map));
1029 do { 972 do {
@@ -1076,7 +1019,7 @@ EXPORT_SYMBOL(omap_set_dma_callback);
1076 * If the channel is running the caller must disable interrupts prior calling 1019 * If the channel is running the caller must disable interrupts prior calling
1077 * this function and process the returned value before re-enabling interrupt to 1020 * this function and process the returned value before re-enabling interrupt to
1078 * prevent races with the interrupt handler. Note that in continuous mode there 1021 * prevent races with the interrupt handler. Note that in continuous mode there
1079 * is a chance for CSSA_L register overflow inbetween the two reads resulting 1022 * is a chance for CSSA_L register overflow between the two reads resulting
1080 * in incorrect return value. 1023 * in incorrect return value.
1081 */ 1024 */
1082dma_addr_t omap_get_dma_src_pos(int lch) 1025dma_addr_t omap_get_dma_src_pos(int lch)
@@ -1084,19 +1027,15 @@ dma_addr_t omap_get_dma_src_pos(int lch)
1084 dma_addr_t offset = 0; 1027 dma_addr_t offset = 0;
1085 1028
1086 if (cpu_is_omap15xx()) 1029 if (cpu_is_omap15xx())
1087 offset = dma_read(CPC(lch)); 1030 offset = p->dma_read(CPC, lch);
1088 else 1031 else
1089 offset = dma_read(CSAC(lch)); 1032 offset = p->dma_read(CSAC, lch);
1090 1033
1091 /* 1034 if (IS_DMA_ERRATA(DMA_ERRATA_3_3) && offset == 0)
1092 * omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is 1035 offset = p->dma_read(CSAC, lch);
1093 * read before the DMA controller finished disabling the channel.
1094 */
1095 if (!cpu_is_omap15xx() && offset == 0)
1096 offset = dma_read(CSAC(lch));
1097 1036
1098 if (cpu_class_is_omap1()) 1037 if (cpu_class_is_omap1())
1099 offset |= (dma_read(CSSA_U(lch)) << 16); 1038 offset |= (p->dma_read(CSSA, lch) & 0xFFFF0000);
1100 1039
1101 return offset; 1040 return offset;
1102} 1041}
@@ -1107,7 +1046,7 @@ EXPORT_SYMBOL(omap_get_dma_src_pos);
1107 * If the channel is running the caller must disable interrupts prior calling 1046 * If the channel is running the caller must disable interrupts prior calling
1108 * this function and process the returned value before re-enabling interrupt to 1047 * this function and process the returned value before re-enabling interrupt to
1109 * prevent races with the interrupt handler. Note that in continuous mode there 1048 * prevent races with the interrupt handler. Note that in continuous mode there
1110 * is a chance for CDSA_L register overflow inbetween the two reads resulting 1049 * is a chance for CDSA_L register overflow between the two reads resulting
1111 * in incorrect return value. 1050 * in incorrect return value.
1112 */ 1051 */
1113dma_addr_t omap_get_dma_dst_pos(int lch) 1052dma_addr_t omap_get_dma_dst_pos(int lch)
@@ -1115,19 +1054,19 @@ dma_addr_t omap_get_dma_dst_pos(int lch)
1115 dma_addr_t offset = 0; 1054 dma_addr_t offset = 0;
1116 1055
1117 if (cpu_is_omap15xx()) 1056 if (cpu_is_omap15xx())
1118 offset = dma_read(CPC(lch)); 1057 offset = p->dma_read(CPC, lch);
1119 else 1058 else
1120 offset = dma_read(CDAC(lch)); 1059 offset = p->dma_read(CDAC, lch);
1121 1060
1122 /* 1061 /*
1123 * 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
1124 * read before the DMA controller finished disabling the channel. 1063 * read before the DMA controller finished disabling the channel.
1125 */ 1064 */
1126 if (!cpu_is_omap15xx() && offset == 0) 1065 if (!cpu_is_omap15xx() && offset == 0)
1127 offset = dma_read(CDAC(lch)); 1066 offset = p->dma_read(CDAC, lch);
1128 1067
1129 if (cpu_class_is_omap1()) 1068 if (cpu_class_is_omap1())
1130 offset |= (dma_read(CDSA_U(lch)) << 16); 1069 offset |= (p->dma_read(CDSA, lch) & 0xFFFF0000);
1131 1070
1132 return offset; 1071 return offset;
1133} 1072}
@@ -1135,7 +1074,7 @@ EXPORT_SYMBOL(omap_get_dma_dst_pos);
1135 1074
1136int omap_get_dma_active_status(int lch) 1075int omap_get_dma_active_status(int lch)
1137{ 1076{
1138 return (dma_read(CCR(lch)) & OMAP_DMA_CCR_EN) != 0; 1077 return (p->dma_read(CCR, lch) & OMAP_DMA_CCR_EN) != 0;
1139} 1078}
1140EXPORT_SYMBOL(omap_get_dma_active_status); 1079EXPORT_SYMBOL(omap_get_dma_active_status);
1141 1080
@@ -1148,7 +1087,7 @@ int omap_dma_running(void)
1148 return 1; 1087 return 1;
1149 1088
1150 for (lch = 0; lch < dma_chan_count; lch++) 1089 for (lch = 0; lch < dma_chan_count; lch++)
1151 if (dma_read(CCR(lch)) & OMAP_DMA_CCR_EN) 1090 if (p->dma_read(CCR, lch) & OMAP_DMA_CCR_EN)
1152 return 1; 1091 return 1;
1153 1092
1154 return 0; 1093 return 0;
@@ -1163,8 +1102,8 @@ void omap_dma_link_lch(int lch_head, int lch_queue)
1163{ 1102{
1164 if (omap_dma_in_1510_mode()) { 1103 if (omap_dma_in_1510_mode()) {
1165 if (lch_head == lch_queue) { 1104 if (lch_head == lch_queue) {
1166 dma_write(dma_read(CCR(lch_head)) | (3 << 8), 1105 p->dma_write(p->dma_read(CCR, lch_head) | (3 << 8),
1167 CCR(lch_head)); 1106 CCR, lch_head);
1168 return; 1107 return;
1169 } 1108 }
1170 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");
@@ -1190,8 +1129,8 @@ void omap_dma_unlink_lch(int lch_head, int lch_queue)
1190{ 1129{
1191 if (omap_dma_in_1510_mode()) { 1130 if (omap_dma_in_1510_mode()) {
1192 if (lch_head == lch_queue) { 1131 if (lch_head == lch_queue) {
1193 dma_write(dma_read(CCR(lch_head)) & ~(3 << 8), 1132 p->dma_write(p->dma_read(CCR, lch_head) & ~(3 << 8),
1194 CCR(lch_head)); 1133 CCR, lch_head);
1195 return; 1134 return;
1196 } 1135 }
1197 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");
@@ -1217,8 +1156,6 @@ void omap_dma_unlink_lch(int lch_head, int lch_queue)
1217} 1156}
1218EXPORT_SYMBOL(omap_dma_unlink_lch); 1157EXPORT_SYMBOL(omap_dma_unlink_lch);
1219 1158
1220/*----------------------------------------------------------------------------*/
1221
1222#ifndef CONFIG_ARCH_OMAP1 1159#ifndef CONFIG_ARCH_OMAP1
1223/* Create chain of DMA channesls */ 1160/* Create chain of DMA channesls */
1224static void create_dma_lch_chain(int lch_head, int lch_queue) 1161static void create_dma_lch_chain(int lch_head, int lch_queue)
@@ -1243,15 +1180,15 @@ static void create_dma_lch_chain(int lch_head, int lch_queue)
1243 lch_queue; 1180 lch_queue;
1244 } 1181 }
1245 1182
1246 l = dma_read(CLNK_CTRL(lch_head)); 1183 l = p->dma_read(CLNK_CTRL, lch_head);
1247 l &= ~(0x1f); 1184 l &= ~(0x1f);
1248 l |= lch_queue; 1185 l |= lch_queue;
1249 dma_write(l, CLNK_CTRL(lch_head)); 1186 p->dma_write(l, CLNK_CTRL, lch_head);
1250 1187
1251 l = dma_read(CLNK_CTRL(lch_queue)); 1188 l = p->dma_read(CLNK_CTRL, lch_queue);
1252 l &= ~(0x1f); 1189 l &= ~(0x1f);
1253 l |= (dma_chan[lch_queue].next_linked_ch); 1190 l |= (dma_chan[lch_queue].next_linked_ch);
1254 dma_write(l, CLNK_CTRL(lch_queue)); 1191 p->dma_write(l, CLNK_CTRL, lch_queue);
1255} 1192}
1256 1193
1257/** 1194/**
@@ -1527,13 +1464,13 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,
1527 1464
1528 /* Set the params to the free channel */ 1465 /* Set the params to the free channel */
1529 if (src_start != 0) 1466 if (src_start != 0)
1530 dma_write(src_start, CSSA(lch)); 1467 p->dma_write(src_start, CSSA, lch);
1531 if (dest_start != 0) 1468 if (dest_start != 0)
1532 dma_write(dest_start, CDSA(lch)); 1469 p->dma_write(dest_start, CDSA, lch);
1533 1470
1534 /* Write the buffer size */ 1471 /* Write the buffer size */
1535 dma_write(elem_count, CEN(lch)); 1472 p->dma_write(elem_count, CEN, lch);
1536 dma_write(frame_count, CFN(lch)); 1473 p->dma_write(frame_count, CFN, lch);
1537 1474
1538 /* 1475 /*
1539 * If the chain is dynamically linked, 1476 * If the chain is dynamically linked,
@@ -1566,8 +1503,8 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,
1566 enable_lnk(dma_chan[lch].prev_linked_ch); 1503 enable_lnk(dma_chan[lch].prev_linked_ch);
1567 dma_chan[lch].state = DMA_CH_QUEUED; 1504 dma_chan[lch].state = DMA_CH_QUEUED;
1568 start_dma = 0; 1505 start_dma = 0;
1569 if (0 == ((1 << 7) & dma_read( 1506 if (0 == ((1 << 7) & p->dma_read(
1570 CCR(dma_chan[lch].prev_linked_ch)))) { 1507 CCR, dma_chan[lch].prev_linked_ch))) {
1571 disable_lnk(dma_chan[lch]. 1508 disable_lnk(dma_chan[lch].
1572 prev_linked_ch); 1509 prev_linked_ch);
1573 pr_debug("\n prev ch is stopped\n"); 1510 pr_debug("\n prev ch is stopped\n");
@@ -1583,7 +1520,7 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,
1583 } 1520 }
1584 omap_enable_channel_irq(lch); 1521 omap_enable_channel_irq(lch);
1585 1522
1586 l = dma_read(CCR(lch)); 1523 l = p->dma_read(CCR, lch);
1587 1524
1588 if ((0 == (l & (1 << 24)))) 1525 if ((0 == (l & (1 << 24))))
1589 l &= ~(1 << 25); 1526 l &= ~(1 << 25);
@@ -1594,12 +1531,12 @@ int omap_dma_chain_a_transfer(int chain_id, int src_start, int dest_start,
1594 l |= (1 << 7); 1531 l |= (1 << 7);
1595 dma_chan[lch].state = DMA_CH_STARTED; 1532 dma_chan[lch].state = DMA_CH_STARTED;
1596 pr_debug("starting %d\n", lch); 1533 pr_debug("starting %d\n", lch);
1597 dma_write(l, CCR(lch)); 1534 p->dma_write(l, CCR, lch);
1598 } else 1535 } else
1599 start_dma = 0; 1536 start_dma = 0;
1600 } else { 1537 } else {
1601 if (0 == (l & (1 << 7))) 1538 if (0 == (l & (1 << 7)))
1602 dma_write(l, CCR(lch)); 1539 p->dma_write(l, CCR, lch);
1603 } 1540 }
1604 dma_chan[lch].flags |= OMAP_DMA_ACTIVE; 1541 dma_chan[lch].flags |= OMAP_DMA_ACTIVE;
1605 } 1542 }
@@ -1644,7 +1581,7 @@ int omap_start_dma_chain_transfers(int chain_id)
1644 omap_enable_channel_irq(channels[0]); 1581 omap_enable_channel_irq(channels[0]);
1645 } 1582 }
1646 1583
1647 l = dma_read(CCR(channels[0])); 1584 l = p->dma_read(CCR, channels[0]);
1648 l |= (1 << 7); 1585 l |= (1 << 7);
1649 dma_linked_lch[chain_id].chain_state = DMA_CHAIN_STARTED; 1586 dma_linked_lch[chain_id].chain_state = DMA_CHAIN_STARTED;
1650 dma_chan[channels[0]].state = DMA_CH_STARTED; 1587 dma_chan[channels[0]].state = DMA_CH_STARTED;
@@ -1653,7 +1590,7 @@ int omap_start_dma_chain_transfers(int chain_id)
1653 l &= ~(1 << 25); 1590 l &= ~(1 << 25);
1654 else 1591 else
1655 l |= (1 << 25); 1592 l |= (1 << 25);
1656 dma_write(l, CCR(channels[0])); 1593 p->dma_write(l, CCR, channels[0]);
1657 1594
1658 dma_chan[channels[0]].flags |= OMAP_DMA_ACTIVE; 1595 dma_chan[channels[0]].flags |= OMAP_DMA_ACTIVE;
1659 1596
@@ -1673,7 +1610,7 @@ int omap_stop_dma_chain_transfers(int chain_id)
1673{ 1610{
1674 int *channels; 1611 int *channels;
1675 u32 l, i; 1612 u32 l, i;
1676 u32 sys_cf; 1613 u32 sys_cf = 0;
1677 1614
1678 /* Check for input params */ 1615 /* Check for input params */
1679 if (unlikely((chain_id < 0 || chain_id >= dma_lch_count))) { 1616 if (unlikely((chain_id < 0 || chain_id >= dma_lch_count))) {
@@ -1688,22 +1625,20 @@ int omap_stop_dma_chain_transfers(int chain_id)
1688 } 1625 }
1689 channels = dma_linked_lch[chain_id].linked_dmach_q; 1626 channels = dma_linked_lch[chain_id].linked_dmach_q;
1690 1627
1691 /* 1628 if (IS_DMA_ERRATA(DMA_ERRATA_i88)) {
1692 * DMA Errata: 1629 sys_cf = p->dma_read(OCP_SYSCONFIG, 0);
1693 * Special programming model needed to disable DMA before end of block 1630 l = sys_cf;
1694 */ 1631 /* Middle mode reg set no Standby */
1695 sys_cf = dma_read(OCP_SYSCONFIG); 1632 l &= ~((1 << 12)|(1 << 13));
1696 l = sys_cf; 1633 p->dma_write(l, OCP_SYSCONFIG, 0);
1697 /* Middle mode reg set no Standby */ 1634 }
1698 l &= ~((1 << 12)|(1 << 13));
1699 dma_write(l, OCP_SYSCONFIG);
1700 1635
1701 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++) {
1702 1637
1703 /* Stop the Channel transmission */ 1638 /* Stop the Channel transmission */
1704 l = dma_read(CCR(channels[i])); 1639 l = p->dma_read(CCR, channels[i]);
1705 l &= ~(1 << 7); 1640 l &= ~(1 << 7);
1706 dma_write(l, CCR(channels[i])); 1641 p->dma_write(l, CCR, channels[i]);
1707 1642
1708 /* Disable the link in all the channels */ 1643 /* Disable the link in all the channels */
1709 disable_lnk(channels[i]); 1644 disable_lnk(channels[i]);
@@ -1715,8 +1650,8 @@ int omap_stop_dma_chain_transfers(int chain_id)
1715 /* Reset the Queue pointers */ 1650 /* Reset the Queue pointers */
1716 OMAP_DMA_CHAIN_QINIT(chain_id); 1651 OMAP_DMA_CHAIN_QINIT(chain_id);
1717 1652
1718 /* Errata - put in the old value */ 1653 if (IS_DMA_ERRATA(DMA_ERRATA_i88))
1719 dma_write(sys_cf, OCP_SYSCONFIG); 1654 p->dma_write(sys_cf, OCP_SYSCONFIG, 0);
1720 1655
1721 return 0; 1656 return 0;
1722} 1657}
@@ -1758,8 +1693,8 @@ int omap_get_dma_chain_index(int chain_id, int *ei, int *fi)
1758 /* Get the current channel */ 1693 /* Get the current channel */
1759 lch = channels[dma_linked_lch[chain_id].q_head]; 1694 lch = channels[dma_linked_lch[chain_id].q_head];
1760 1695
1761 *ei = dma_read(CCEN(lch)); 1696 *ei = p->dma_read(CCEN, lch);
1762 *fi = dma_read(CCFN(lch)); 1697 *fi = p->dma_read(CCFN, lch);
1763 1698
1764 return 0; 1699 return 0;
1765} 1700}
@@ -1796,7 +1731,7 @@ int omap_get_dma_chain_dst_pos(int chain_id)
1796 /* Get the current channel */ 1731 /* Get the current channel */
1797 lch = channels[dma_linked_lch[chain_id].q_head]; 1732 lch = channels[dma_linked_lch[chain_id].q_head];
1798 1733
1799 return dma_read(CDAC(lch)); 1734 return p->dma_read(CDAC, lch);
1800} 1735}
1801EXPORT_SYMBOL(omap_get_dma_chain_dst_pos); 1736EXPORT_SYMBOL(omap_get_dma_chain_dst_pos);
1802 1737
@@ -1830,7 +1765,7 @@ int omap_get_dma_chain_src_pos(int chain_id)
1830 /* Get the current channel */ 1765 /* Get the current channel */
1831 lch = channels[dma_linked_lch[chain_id].q_head]; 1766 lch = channels[dma_linked_lch[chain_id].q_head];
1832 1767
1833 return dma_read(CSAC(lch)); 1768 return p->dma_read(CSAC, lch);
1834} 1769}
1835EXPORT_SYMBOL(omap_get_dma_chain_src_pos); 1770EXPORT_SYMBOL(omap_get_dma_chain_src_pos);
1836#endif /* ifndef CONFIG_ARCH_OMAP1 */ 1771#endif /* ifndef CONFIG_ARCH_OMAP1 */
@@ -1847,7 +1782,7 @@ static int omap1_dma_handle_ch(int ch)
1847 csr = dma_chan[ch].saved_csr; 1782 csr = dma_chan[ch].saved_csr;
1848 dma_chan[ch].saved_csr = 0; 1783 dma_chan[ch].saved_csr = 0;
1849 } else 1784 } else
1850 csr = dma_read(CSR(ch)); 1785 csr = p->dma_read(CSR, ch);
1851 if (enable_1510_mode && ch <= 2 && (csr >> 7) != 0) { 1786 if (enable_1510_mode && ch <= 2 && (csr >> 7) != 0) {
1852 dma_chan[ch + 6].saved_csr = csr >> 7; 1787 dma_chan[ch + 6].saved_csr = csr >> 7;
1853 csr &= 0x7f; 1788 csr &= 0x7f;
@@ -1900,13 +1835,13 @@ static irqreturn_t omap1_dma_irq_handler(int irq, void *dev_id)
1900 1835
1901static int omap2_dma_handle_ch(int ch) 1836static int omap2_dma_handle_ch(int ch)
1902{ 1837{
1903 u32 status = dma_read(CSR(ch)); 1838 u32 status = p->dma_read(CSR, ch);
1904 1839
1905 if (!status) { 1840 if (!status) {
1906 if (printk_ratelimit()) 1841 if (printk_ratelimit())
1907 printk(KERN_WARNING "Spurious DMA IRQ for lch %d\n", 1842 printk(KERN_WARNING "Spurious DMA IRQ for lch %d\n",
1908 ch); 1843 ch);
1909 dma_write(1 << ch, IRQSTATUS_L0); 1844 p->dma_write(1 << ch, IRQSTATUS_L0, ch);
1910 return 0; 1845 return 0;
1911 } 1846 }
1912 if (unlikely(dma_chan[ch].dev_id == -1)) { 1847 if (unlikely(dma_chan[ch].dev_id == -1)) {
@@ -1922,17 +1857,12 @@ static int omap2_dma_handle_ch(int ch)
1922 if (unlikely(status & OMAP2_DMA_TRANS_ERR_IRQ)) { 1857 if (unlikely(status & OMAP2_DMA_TRANS_ERR_IRQ)) {
1923 printk(KERN_INFO "DMA transaction error with device %d\n", 1858 printk(KERN_INFO "DMA transaction error with device %d\n",
1924 dma_chan[ch].dev_id); 1859 dma_chan[ch].dev_id);
1925 if (cpu_class_is_omap2()) { 1860 if (IS_DMA_ERRATA(DMA_ERRATA_i378)) {
1926 /*
1927 * Errata: sDMA Channel is not disabled
1928 * after a transaction error. So we explicitely
1929 * disable the channel
1930 */
1931 u32 ccr; 1861 u32 ccr;
1932 1862
1933 ccr = dma_read(CCR(ch)); 1863 ccr = p->dma_read(CCR, ch);
1934 ccr &= ~OMAP_DMA_CCR_EN; 1864 ccr &= ~OMAP_DMA_CCR_EN;
1935 dma_write(ccr, CCR(ch)); 1865 p->dma_write(ccr, CCR, ch);
1936 dma_chan[ch].flags &= ~OMAP_DMA_ACTIVE; 1866 dma_chan[ch].flags &= ~OMAP_DMA_ACTIVE;
1937 } 1867 }
1938 } 1868 }
@@ -1943,14 +1873,16 @@ static int omap2_dma_handle_ch(int ch)
1943 printk(KERN_INFO "DMA misaligned error with device %d\n", 1873 printk(KERN_INFO "DMA misaligned error with device %d\n",
1944 dma_chan[ch].dev_id); 1874 dma_chan[ch].dev_id);
1945 1875
1946 dma_write(OMAP2_DMA_CSR_CLEAR_MASK, CSR(ch)); 1876 p->dma_write(status, CSR, ch);
1947 dma_write(1 << ch, IRQSTATUS_L0); 1877 p->dma_write(1 << ch, IRQSTATUS_L0, ch);
1878 /* read back the register to flush the write */
1879 p->dma_read(IRQSTATUS_L0, ch);
1948 1880
1949 /* 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 */
1950 if (dma_chan[ch].chain_id != -1) { 1882 if (dma_chan[ch].chain_id != -1) {
1951 int chain_id = dma_chan[ch].chain_id; 1883 int chain_id = dma_chan[ch].chain_id;
1952 dma_chan[ch].state = DMA_CH_NOTSTARTED; 1884 dma_chan[ch].state = DMA_CH_NOTSTARTED;
1953 if (dma_read(CLNK_CTRL(ch)) & (1 << 15)) 1885 if (p->dma_read(CLNK_CTRL, ch) & (1 << 15))
1954 dma_chan[dma_chan[ch].next_linked_ch].state = 1886 dma_chan[dma_chan[ch].next_linked_ch].state =
1955 DMA_CH_STARTED; 1887 DMA_CH_STARTED;
1956 if (dma_linked_lch[chain_id].chain_mode == 1888 if (dma_linked_lch[chain_id].chain_mode ==
@@ -1960,11 +1892,10 @@ static int omap2_dma_handle_ch(int ch)
1960 if (!OMAP_DMA_CHAIN_QEMPTY(chain_id)) 1892 if (!OMAP_DMA_CHAIN_QEMPTY(chain_id))
1961 OMAP_DMA_CHAIN_INCQHEAD(chain_id); 1893 OMAP_DMA_CHAIN_INCQHEAD(chain_id);
1962 1894
1963 status = dma_read(CSR(ch)); 1895 status = p->dma_read(CSR, ch);
1896 p->dma_write(status, CSR, ch);
1964 } 1897 }
1965 1898
1966 dma_write(status, CSR(ch));
1967
1968 if (likely(dma_chan[ch].callback != NULL)) 1899 if (likely(dma_chan[ch].callback != NULL))
1969 dma_chan[ch].callback(ch, status, dma_chan[ch].data); 1900 dma_chan[ch].callback(ch, status, dma_chan[ch].data);
1970 1901
@@ -1977,13 +1908,13 @@ static irqreturn_t omap2_dma_irq_handler(int irq, void *dev_id)
1977 u32 val, enable_reg; 1908 u32 val, enable_reg;
1978 int i; 1909 int i;
1979 1910
1980 val = dma_read(IRQSTATUS_L0); 1911 val = p->dma_read(IRQSTATUS_L0, 0);
1981 if (val == 0) { 1912 if (val == 0) {
1982 if (printk_ratelimit()) 1913 if (printk_ratelimit())
1983 printk(KERN_WARNING "Spurious DMA IRQ\n"); 1914 printk(KERN_WARNING "Spurious DMA IRQ\n");
1984 return IRQ_HANDLED; 1915 return IRQ_HANDLED;
1985 } 1916 }
1986 enable_reg = dma_read(IRQENABLE_L0); 1917 enable_reg = p->dma_read(IRQENABLE_L0, 0);
1987 val &= enable_reg; /* Dispatch only relevant interrupts */ 1918 val &= enable_reg; /* Dispatch only relevant interrupts */
1988 for (i = 0; i < dma_lch_count && val != 0; i++) { 1919 for (i = 0; i < dma_lch_count && val != 0; i++) {
1989 if (val & 1) 1920 if (val & 1)
@@ -2009,119 +1940,66 @@ static struct irqaction omap24xx_dma_irq;
2009void omap_dma_global_context_save(void) 1940void omap_dma_global_context_save(void)
2010{ 1941{
2011 omap_dma_global_context.dma_irqenable_l0 = 1942 omap_dma_global_context.dma_irqenable_l0 =
2012 dma_read(IRQENABLE_L0); 1943 p->dma_read(IRQENABLE_L0, 0);
2013 omap_dma_global_context.dma_ocp_sysconfig = 1944 omap_dma_global_context.dma_ocp_sysconfig =
2014 dma_read(OCP_SYSCONFIG); 1945 p->dma_read(OCP_SYSCONFIG, 0);
2015 omap_dma_global_context.dma_gcr = dma_read(GCR); 1946 omap_dma_global_context.dma_gcr = p->dma_read(GCR, 0);
2016} 1947}
2017 1948
2018void omap_dma_global_context_restore(void) 1949void omap_dma_global_context_restore(void)
2019{ 1950{
2020 int ch; 1951 int ch;
2021 1952
2022 dma_write(omap_dma_global_context.dma_gcr, GCR); 1953 p->dma_write(omap_dma_global_context.dma_gcr, GCR, 0);
2023 dma_write(omap_dma_global_context.dma_ocp_sysconfig, 1954 p->dma_write(omap_dma_global_context.dma_ocp_sysconfig,
2024 OCP_SYSCONFIG); 1955 OCP_SYSCONFIG, 0);
2025 dma_write(omap_dma_global_context.dma_irqenable_l0, 1956 p->dma_write(omap_dma_global_context.dma_irqenable_l0,
2026 IRQENABLE_L0); 1957 IRQENABLE_L0, 0);
2027 1958
2028 /* 1959 if (IS_DMA_ERRATA(DMA_ROMCODE_BUG))
2029 * A bug in ROM code leaves IRQ status for channels 0 and 1 uncleared 1960 p->dma_write(0x3 , IRQSTATUS_L0, 0);
2030 * after secure sram context save and restore. Hence we need to
2031 * manually clear those IRQs to avoid spurious interrupts. This
2032 * affects only secure devices.
2033 */
2034 if (cpu_is_omap34xx() && (omap_type() != OMAP2_DEVICE_TYPE_GP))
2035 dma_write(0x3 , IRQSTATUS_L0);
2036 1961
2037 for (ch = 0; ch < dma_chan_count; ch++) 1962 for (ch = 0; ch < dma_chan_count; ch++)
2038 if (dma_chan[ch].dev_id != -1) 1963 if (dma_chan[ch].dev_id != -1)
2039 omap_clear_dma(ch); 1964 omap_clear_dma(ch);
2040} 1965}
2041 1966
2042/*----------------------------------------------------------------------------*/ 1967static int __devinit omap_system_dma_probe(struct platform_device *pdev)
2043
2044static int __init omap_init_dma(void)
2045{ 1968{
2046 unsigned long base; 1969 int ch, ret = 0;
2047 int ch, r; 1970 int dma_irq;
2048 1971 char irq_name[4];
2049 if (cpu_class_is_omap1()) { 1972 int irq_rel;
2050 base = OMAP1_DMA_BASE; 1973
2051 dma_lch_count = OMAP1_LOGICAL_DMA_CH_COUNT; 1974 p = pdev->dev.platform_data;
2052 } else if (cpu_is_omap24xx()) { 1975 if (!p) {
2053 base = OMAP24XX_DMA4_BASE; 1976 dev_err(&pdev->dev, "%s: System DMA initialized without"
2054 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT; 1977 "platform data\n", __func__);
2055 } else if (cpu_is_omap34xx()) { 1978 return -EINVAL;
2056 base = OMAP34XX_DMA4_BASE;
2057 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT;
2058 } else if (cpu_is_omap44xx()) {
2059 base = OMAP44XX_DMA4_BASE;
2060 dma_lch_count = OMAP_DMA4_LOGICAL_DMA_CH_COUNT;
2061 } else {
2062 pr_err("DMA init failed for unsupported omap\n");
2063 return -ENODEV;
2064 } 1979 }
2065 1980
2066 omap_dma_base = ioremap(base, SZ_4K); 1981 d = p->dma_attr;
2067 BUG_ON(!omap_dma_base); 1982 errata = p->errata;
2068 1983
2069 if (cpu_class_is_omap2() && omap_dma_reserve_channels 1984 if ((d->dev_caps & RESERVE_CHANNEL) && omap_dma_reserve_channels
2070 && (omap_dma_reserve_channels <= dma_lch_count)) 1985 && (omap_dma_reserve_channels <= dma_lch_count))
2071 dma_lch_count = omap_dma_reserve_channels; 1986 d->lch_count = omap_dma_reserve_channels;
2072 1987
2073 dma_chan = kzalloc(sizeof(struct omap_dma_lch) * dma_lch_count, 1988 dma_lch_count = d->lch_count;
2074 GFP_KERNEL); 1989 dma_chan_count = dma_lch_count;
2075 if (!dma_chan) { 1990 dma_chan = d->chan;
2076 r = -ENOMEM; 1991 enable_1510_mode = d->dev_caps & ENABLE_1510_MODE;
2077 goto out_unmap;
2078 }
2079 1992
2080 if (cpu_class_is_omap2()) { 1993 if (cpu_class_is_omap2()) {
2081 dma_linked_lch = kzalloc(sizeof(struct dma_link_info) * 1994 dma_linked_lch = kzalloc(sizeof(struct dma_link_info) *
2082 dma_lch_count, GFP_KERNEL); 1995 dma_lch_count, GFP_KERNEL);
2083 if (!dma_linked_lch) { 1996 if (!dma_linked_lch) {
2084 r = -ENOMEM; 1997 ret = -ENOMEM;
2085 goto out_free; 1998 goto exit_dma_lch_fail;
2086 } 1999 }
2087 } 2000 }
2088 2001
2089 if (cpu_is_omap15xx()) {
2090 printk(KERN_INFO "DMA support for OMAP15xx initialized\n");
2091 dma_chan_count = 9;
2092 enable_1510_mode = 1;
2093 } else if (cpu_is_omap16xx() || cpu_is_omap7xx()) {
2094 printk(KERN_INFO "OMAP DMA hardware version %d\n",
2095 dma_read(HW_ID));
2096 printk(KERN_INFO "DMA capabilities: %08x:%08x:%04x:%04x:%04x\n",
2097 (dma_read(CAPS_0_U) << 16) |
2098 dma_read(CAPS_0_L),
2099 (dma_read(CAPS_1_U) << 16) |
2100 dma_read(CAPS_1_L),
2101 dma_read(CAPS_2), dma_read(CAPS_3),
2102 dma_read(CAPS_4));
2103 if (!enable_1510_mode) {
2104 u16 w;
2105
2106 /* Disable OMAP 3.0/3.1 compatibility mode. */
2107 w = dma_read(GSCR);
2108 w |= 1 << 3;
2109 dma_write(w, GSCR);
2110 dma_chan_count = 16;
2111 } else
2112 dma_chan_count = 9;
2113 } else if (cpu_class_is_omap2()) {
2114 u8 revision = dma_read(REVISION) & 0xff;
2115 printk(KERN_INFO "OMAP DMA hardware revision %d.%d\n",
2116 revision >> 4, revision & 0xf);
2117 dma_chan_count = dma_lch_count;
2118 } else {
2119 dma_chan_count = 0;
2120 return 0;
2121 }
2122
2123 spin_lock_init(&dma_chan_lock); 2002 spin_lock_init(&dma_chan_lock);
2124
2125 for (ch = 0; ch < dma_chan_count; ch++) { 2003 for (ch = 0; ch < dma_chan_count; ch++) {
2126 omap_clear_dma(ch); 2004 omap_clear_dma(ch);
2127 if (cpu_class_is_omap2()) 2005 if (cpu_class_is_omap2())
@@ -2138,20 +2016,23 @@ static int __init omap_init_dma(void)
2138 * request_irq() doesn't like dev_id (ie. ch) being 2016 * request_irq() doesn't like dev_id (ie. ch) being
2139 * zero, so we have to kludge around this. 2017 * zero, so we have to kludge around this.
2140 */ 2018 */
2141 r = request_irq(omap1_dma_irq[ch], 2019 sprintf(&irq_name[0], "%d", ch);
2020 dma_irq = platform_get_irq_byname(pdev, irq_name);
2021
2022 if (dma_irq < 0) {
2023 ret = dma_irq;
2024 goto exit_dma_irq_fail;
2025 }
2026
2027 /* INT_DMA_LCD is handled in lcd_dma.c */
2028 if (dma_irq == INT_DMA_LCD)
2029 continue;
2030
2031 ret = request_irq(dma_irq,
2142 omap1_dma_irq_handler, 0, "DMA", 2032 omap1_dma_irq_handler, 0, "DMA",
2143 (void *) (ch + 1)); 2033 (void *) (ch + 1));
2144 if (r != 0) { 2034 if (ret != 0)
2145 int i; 2035 goto exit_dma_irq_fail;
2146
2147 printk(KERN_ERR "unable to request IRQ %d "
2148 "for DMA (error %d)\n",
2149 omap1_dma_irq[ch], r);
2150 for (i = 0; i < ch; i++)
2151 free_irq(omap1_dma_irq[i],
2152 (void *) (i + 1));
2153 goto out_free;
2154 }
2155 } 2036 }
2156 } 2037 }
2157 2038
@@ -2160,46 +2041,91 @@ static int __init omap_init_dma(void)
2160 DMA_DEFAULT_FIFO_DEPTH, 0); 2041 DMA_DEFAULT_FIFO_DEPTH, 0);
2161 2042
2162 if (cpu_class_is_omap2()) { 2043 if (cpu_class_is_omap2()) {
2163 int irq; 2044 strcpy(irq_name, "0");
2164 if (cpu_is_omap44xx()) 2045 dma_irq = platform_get_irq_byname(pdev, irq_name);
2165 irq = OMAP44XX_IRQ_SDMA_0; 2046 if (dma_irq < 0) {
2166 else 2047 dev_err(&pdev->dev, "failed: request IRQ %d", dma_irq);
2167 irq = INT_24XX_SDMA_IRQ0; 2048 goto exit_dma_lch_fail;
2168 setup_irq(irq, &omap24xx_dma_irq); 2049 }
2169 } 2050 ret = setup_irq(dma_irq, &omap24xx_dma_irq);
2170 2051 if (ret) {
2171 if (cpu_is_omap34xx() || cpu_is_omap44xx()) { 2052 dev_err(&pdev->dev, "set_up failed for IRQ %d"
2172 /* Enable smartidle idlemodes and autoidle */ 2053 "for DMA (error %d)\n", dma_irq, ret);
2173 u32 v = dma_read(OCP_SYSCONFIG); 2054 goto exit_dma_lch_fail;
2174 v &= ~(DMA_SYSCONFIG_MIDLEMODE_MASK |
2175 DMA_SYSCONFIG_SIDLEMODE_MASK |
2176 DMA_SYSCONFIG_AUTOIDLE);
2177 v |= (DMA_SYSCONFIG_MIDLEMODE(DMA_IDLEMODE_SMARTIDLE) |
2178 DMA_SYSCONFIG_SIDLEMODE(DMA_IDLEMODE_SMARTIDLE) |
2179 DMA_SYSCONFIG_AUTOIDLE);
2180 dma_write(v , OCP_SYSCONFIG);
2181 /* reserve dma channels 0 and 1 in high security devices */
2182 if (cpu_is_omap34xx() &&
2183 (omap_type() != OMAP2_DEVICE_TYPE_GP)) {
2184 printk(KERN_INFO "Reserving DMA channels 0 and 1 for "
2185 "HS ROM code\n");
2186 dma_chan[0].dev_id = 0;
2187 dma_chan[1].dev_id = 1;
2188 } 2055 }
2189 } 2056 }
2190 2057
2058 /* reserve dma channels 0 and 1 in high security devices */
2059 if (cpu_is_omap34xx() &&
2060 (omap_type() != OMAP2_DEVICE_TYPE_GP)) {
2061 printk(KERN_INFO "Reserving DMA channels 0 and 1 for "
2062 "HS ROM code\n");
2063 dma_chan[0].dev_id = 0;
2064 dma_chan[1].dev_id = 1;
2065 }
2066 p->show_dma_caps();
2191 return 0; 2067 return 0;
2192 2068
2193out_free: 2069exit_dma_irq_fail:
2070 dev_err(&pdev->dev, "unable to request IRQ %d"
2071 "for DMA (error %d)\n", dma_irq, ret);
2072 for (irq_rel = 0; irq_rel < ch; irq_rel++) {
2073 dma_irq = platform_get_irq(pdev, irq_rel);
2074 free_irq(dma_irq, (void *)(irq_rel + 1));
2075 }
2076
2077exit_dma_lch_fail:
2078 kfree(p);
2079 kfree(d);
2194 kfree(dma_chan); 2080 kfree(dma_chan);
2081 return ret;
2082}
2195 2083
2196out_unmap: 2084static int __devexit omap_system_dma_remove(struct platform_device *pdev)
2197 iounmap(omap_dma_base); 2085{
2086 int dma_irq;
2198 2087
2199 return r; 2088 if (cpu_class_is_omap2()) {
2089 char irq_name[4];
2090 strcpy(irq_name, "0");
2091 dma_irq = platform_get_irq_byname(pdev, irq_name);
2092 remove_irq(dma_irq, &omap24xx_dma_irq);
2093 } else {
2094 int irq_rel = 0;
2095 for ( ; irq_rel < dma_chan_count; irq_rel++) {
2096 dma_irq = platform_get_irq(pdev, irq_rel);
2097 free_irq(dma_irq, (void *)(irq_rel + 1));
2098 }
2099 }
2100 kfree(p);
2101 kfree(d);
2102 kfree(dma_chan);
2103 return 0;
2104}
2105
2106static struct platform_driver omap_system_dma_driver = {
2107 .probe = omap_system_dma_probe,
2108 .remove = omap_system_dma_remove,
2109 .driver = {
2110 .name = "omap_dma_system"
2111 },
2112};
2113
2114static int __init omap_system_dma_init(void)
2115{
2116 return platform_driver_register(&omap_system_dma_driver);
2117}
2118arch_initcall(omap_system_dma_init);
2119
2120static void __exit omap_system_dma_exit(void)
2121{
2122 platform_driver_unregister(&omap_system_dma_driver);
2200} 2123}
2201 2124
2202arch_initcall(omap_init_dma); 2125MODULE_DESCRIPTION("OMAP SYSTEM DMA DRIVER");
2126MODULE_LICENSE("GPL");
2127MODULE_ALIAS("platform:" DRIVER_NAME);
2128MODULE_AUTHOR("Texas Instruments Inc");
2203 2129
2204/* 2130/*
2205 * Reserve the omap SDMA channels using cmdline bootarg 2131 * Reserve the omap SDMA channels using cmdline bootarg
diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index 44bafdab2dce..ee9f6ebba29b 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -342,6 +342,10 @@ static void omap_dm_timer_reset(struct omap_dm_timer *timer)
342 l |= 0x02 << 3; /* Set to smart-idle mode */ 342 l |= 0x02 << 3; /* Set to smart-idle mode */
343 l |= 0x2 << 8; /* Set clock activity to perserve f-clock on idle */ 343 l |= 0x2 << 8; /* Set clock activity to perserve f-clock on idle */
344 344
345 /* Enable autoidle on OMAP2 / OMAP3 */
346 if (cpu_is_omap24xx() || cpu_is_omap34xx())
347 l |= 0x1 << 0;
348
345 /* 349 /*
346 * Enable wake-up on OMAP2 CPUs. 350 * Enable wake-up on OMAP2 CPUs.
347 */ 351 */
@@ -581,7 +585,7 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
581 * When the functional clock disappears, too quick writes seem 585 * When the functional clock disappears, too quick writes seem
582 * to cause an abort. XXX Is this still necessary? 586 * to cause an abort. XXX Is this still necessary?
583 */ 587 */
584 __delay(150000); 588 __delay(300000);
585 589
586 return ret; 590 return ret;
587} 591}
diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c
index 0054b9501a53..c9e5d7298c40 100644
--- a/arch/arm/plat-omap/fb.c
+++ b/arch/arm/plat-omap/fb.c
@@ -36,6 +36,8 @@
36#include <plat/board.h> 36#include <plat/board.h>
37#include <plat/sram.h> 37#include <plat/sram.h>
38 38
39#include "fb.h"
40
39#if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE) 41#if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE)
40 42
41static struct omapfb_platform_data omapfb_config; 43static struct omapfb_platform_data omapfb_config;
@@ -94,7 +96,7 @@ static int fbmem_region_reserved(unsigned long start, size_t size)
94 * Get the region_idx`th region from board config/ATAG and convert it to 96 * Get the region_idx`th region from board config/ATAG and convert it to
95 * our internal format. 97 * our internal format.
96 */ 98 */
97static int get_fbmem_region(int region_idx, struct omapfb_mem_region *rg) 99static int __init get_fbmem_region(int region_idx, struct omapfb_mem_region *rg)
98{ 100{
99 const struct omap_fbmem_config *conf; 101 const struct omap_fbmem_config *conf;
100 u32 paddr; 102 u32 paddr;
@@ -126,7 +128,7 @@ static int set_fbmem_region_type(struct omapfb_mem_region *rg, int mem_type,
126 * type = 0 && paddr = 0, a default don't care case maps to 128 * type = 0 && paddr = 0, a default don't care case maps to
127 * the SDRAM type. 129 * the SDRAM type.
128 */ 130 */
129 if (rg->type || (!rg->type && !rg->paddr)) 131 if (rg->type || !rg->paddr)
130 return 0; 132 return 0;
131 if (ranges_overlap(rg->paddr, rg->size, mem_start, mem_size)) { 133 if (ranges_overlap(rg->paddr, rg->size, mem_start, mem_size)) {
132 rg->type = mem_type; 134 rg->type = mem_type;
@@ -173,11 +175,7 @@ static int check_fbmem_region(int region_idx, struct omapfb_mem_region *rg,
173 175
174static int valid_sdram(unsigned long addr, unsigned long size) 176static int valid_sdram(unsigned long addr, unsigned long size)
175{ 177{
176 struct memblock_property res; 178 return memblock_is_region_memory(addr, size);
177
178 res.base = addr;
179 res.size = size;
180 return !memblock_find(&res) && res.base == addr && res.size == size;
181} 179}
182 180
183static int reserve_sdram(unsigned long addr, unsigned long size) 181static int reserve_sdram(unsigned long addr, unsigned long size)
@@ -262,7 +260,7 @@ void __init omapfb_reserve_sdram_memblock(void)
262 * this point, since the driver built as a module would have problem with 260 * this point, since the driver built as a module would have problem with
263 * freeing / reallocating the regions. 261 * freeing / reallocating the regions.
264 */ 262 */
265unsigned long omapfb_reserve_sram(unsigned long sram_pstart, 263unsigned long __init omapfb_reserve_sram(unsigned long sram_pstart,
266 unsigned long sram_vstart, 264 unsigned long sram_vstart,
267 unsigned long sram_size, 265 unsigned long sram_size,
268 unsigned long pstart_avail, 266 unsigned long pstart_avail,
@@ -336,7 +334,7 @@ void omapfb_set_ctrl_platform_data(void *data)
336 omapfb_config.ctrl_platform_data = data; 334 omapfb_config.ctrl_platform_data = data;
337} 335}
338 336
339static inline int omap_init_fb(void) 337static int __init omap_init_fb(void)
340{ 338{
341 const struct omap_lcd_config *conf; 339 const struct omap_lcd_config *conf;
342 340
@@ -381,7 +379,7 @@ void omapfb_set_platform_data(struct omapfb_platform_data *data)
381 omapfb_config = *data; 379 omapfb_config = *data;
382} 380}
383 381
384static inline int omap_init_fb(void) 382static int __init omap_init_fb(void)
385{ 383{
386 return platform_device_register(&omap_fb_device); 384 return platform_device_register(&omap_fb_device);
387} 385}
@@ -392,7 +390,7 @@ void omapfb_reserve_sdram_memblock(void)
392{ 390{
393} 391}
394 392
395unsigned long omapfb_reserve_sram(unsigned long sram_pstart, 393unsigned long __init omapfb_reserve_sram(unsigned long sram_pstart,
396 unsigned long sram_vstart, 394 unsigned long sram_vstart,
397 unsigned long sram_size, 395 unsigned long sram_size,
398 unsigned long start_avail, 396 unsigned long start_avail,
@@ -411,7 +409,7 @@ void omapfb_reserve_sdram_memblock(void)
411{ 409{
412} 410}
413 411
414unsigned long omapfb_reserve_sram(unsigned long sram_pstart, 412unsigned long __init omapfb_reserve_sram(unsigned long sram_pstart,
415 unsigned long sram_vstart, 413 unsigned long sram_vstart,
416 unsigned long sram_size, 414 unsigned long sram_size,
417 unsigned long start_avail, 415 unsigned long start_avail,
diff --git a/arch/arm/plat-omap/fb.h b/arch/arm/plat-omap/fb.h
new file mode 100644
index 000000000000..d765d0bd8520
--- /dev/null
+++ b/arch/arm/plat-omap/fb.h
@@ -0,0 +1,10 @@
1#ifndef __PLAT_OMAP_FB_H__
2#define __PLAT_OMAP_FB_H__
3
4extern unsigned long omapfb_reserve_sram(unsigned long sram_pstart,
5 unsigned long sram_vstart,
6 unsigned long sram_size,
7 unsigned long pstart_avail,
8 unsigned long size_avail);
9
10#endif /* __PLAT_OMAP_FB_H__ */
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
deleted file mode 100644
index 7951eefe1a0e..000000000000
--- a/arch/arm/plat-omap/gpio.c
+++ /dev/null
@@ -1,2344 +0,0 @@
1/*
2 * linux/arch/arm/plat-omap/gpio.c
3 *
4 * Support functions for OMAP GPIO
5 *
6 * Copyright (C) 2003-2005 Nokia Corporation
7 * Written by Juha Yrjölä <juha.yrjola@nokia.com>
8 *
9 * Copyright (C) 2009 Texas Instruments
10 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16
17#include <linux/init.h>
18#include <linux/module.h>
19#include <linux/interrupt.h>
20#include <linux/sysdev.h>
21#include <linux/err.h>
22#include <linux/clk.h>
23#include <linux/io.h>
24
25#include <mach/hardware.h>
26#include <asm/irq.h>
27#include <mach/irqs.h>
28#include <mach/gpio.h>
29#include <asm/mach/irq.h>
30#include <plat/powerdomain.h>
31
32/*
33 * OMAP1510 GPIO registers
34 */
35#define OMAP1510_GPIO_BASE 0xfffce000
36#define OMAP1510_GPIO_DATA_INPUT 0x00
37#define OMAP1510_GPIO_DATA_OUTPUT 0x04
38#define OMAP1510_GPIO_DIR_CONTROL 0x08
39#define OMAP1510_GPIO_INT_CONTROL 0x0c
40#define OMAP1510_GPIO_INT_MASK 0x10
41#define OMAP1510_GPIO_INT_STATUS 0x14
42#define OMAP1510_GPIO_PIN_CONTROL 0x18
43
44#define OMAP1510_IH_GPIO_BASE 64
45
46/*
47 * OMAP1610 specific GPIO registers
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
54#define OMAP1610_GPIO_SYSCONFIG 0x0010
55#define OMAP1610_GPIO_SYSSTATUS 0x0014
56#define OMAP1610_GPIO_IRQSTATUS1 0x0018
57#define OMAP1610_GPIO_IRQENABLE1 0x001c
58#define OMAP1610_GPIO_WAKEUPENABLE 0x0028
59#define OMAP1610_GPIO_DATAIN 0x002c
60#define OMAP1610_GPIO_DATAOUT 0x0030
61#define OMAP1610_GPIO_DIRECTION 0x0034
62#define OMAP1610_GPIO_EDGE_CTRL1 0x0038
63#define OMAP1610_GPIO_EDGE_CTRL2 0x003c
64#define OMAP1610_GPIO_CLEAR_IRQENABLE1 0x009c
65#define OMAP1610_GPIO_CLEAR_WAKEUPENA 0x00a8
66#define OMAP1610_GPIO_CLEAR_DATAOUT 0x00b0
67#define OMAP1610_GPIO_SET_IRQENABLE1 0x00dc
68#define OMAP1610_GPIO_SET_WAKEUPENA 0x00e8
69#define OMAP1610_GPIO_SET_DATAOUT 0x00f0
70
71/*
72 * OMAP7XX specific GPIO registers
73 */
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
81#define OMAP7XX_GPIO_DATA_OUTPUT 0x04
82#define OMAP7XX_GPIO_DIR_CONTROL 0x08
83#define OMAP7XX_GPIO_INT_CONTROL 0x0c
84#define OMAP7XX_GPIO_INT_MASK 0x10
85#define OMAP7XX_GPIO_INT_STATUS 0x14
86
87#define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
88
89/*
90 * omap24xx specific GPIO registers
91 */
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
104#define OMAP24XX_GPIO_SYSCONFIG 0x0010
105#define OMAP24XX_GPIO_SYSSTATUS 0x0014
106#define OMAP24XX_GPIO_IRQSTATUS1 0x0018
107#define OMAP24XX_GPIO_IRQSTATUS2 0x0028
108#define OMAP24XX_GPIO_IRQENABLE2 0x002c
109#define OMAP24XX_GPIO_IRQENABLE1 0x001c
110#define OMAP24XX_GPIO_WAKE_EN 0x0020
111#define OMAP24XX_GPIO_CTRL 0x0030
112#define OMAP24XX_GPIO_OE 0x0034
113#define OMAP24XX_GPIO_DATAIN 0x0038
114#define OMAP24XX_GPIO_DATAOUT 0x003c
115#define OMAP24XX_GPIO_LEVELDETECT0 0x0040
116#define OMAP24XX_GPIO_LEVELDETECT1 0x0044
117#define OMAP24XX_GPIO_RISINGDETECT 0x0048
118#define OMAP24XX_GPIO_FALLINGDETECT 0x004c
119#define OMAP24XX_GPIO_DEBOUNCE_EN 0x0050
120#define OMAP24XX_GPIO_DEBOUNCE_VAL 0x0054
121#define OMAP24XX_GPIO_CLEARIRQENABLE1 0x0060
122#define OMAP24XX_GPIO_SETIRQENABLE1 0x0064
123#define OMAP24XX_GPIO_CLEARWKUENA 0x0080
124#define OMAP24XX_GPIO_SETWKUENA 0x0084
125#define OMAP24XX_GPIO_CLEARDATAOUT 0x0090
126#define OMAP24XX_GPIO_SETDATAOUT 0x0094
127
128#define OMAP4_GPIO_REVISION 0x0000
129#define OMAP4_GPIO_SYSCONFIG 0x0010
130#define OMAP4_GPIO_EOI 0x0020
131#define OMAP4_GPIO_IRQSTATUSRAW0 0x0024
132#define OMAP4_GPIO_IRQSTATUSRAW1 0x0028
133#define OMAP4_GPIO_IRQSTATUS0 0x002c
134#define OMAP4_GPIO_IRQSTATUS1 0x0030
135#define OMAP4_GPIO_IRQSTATUSSET0 0x0034
136#define OMAP4_GPIO_IRQSTATUSSET1 0x0038
137#define OMAP4_GPIO_IRQSTATUSCLR0 0x003c
138#define OMAP4_GPIO_IRQSTATUSCLR1 0x0040
139#define OMAP4_GPIO_IRQWAKEN0 0x0044
140#define OMAP4_GPIO_IRQWAKEN1 0x0048
141#define OMAP4_GPIO_SYSSTATUS 0x0114
142#define OMAP4_GPIO_IRQENABLE1 0x011c
143#define OMAP4_GPIO_WAKE_EN 0x0120
144#define OMAP4_GPIO_IRQSTATUS2 0x0128
145#define OMAP4_GPIO_IRQENABLE2 0x012c
146#define OMAP4_GPIO_CTRL 0x0130
147#define OMAP4_GPIO_OE 0x0134
148#define OMAP4_GPIO_DATAIN 0x0138
149#define OMAP4_GPIO_DATAOUT 0x013c
150#define OMAP4_GPIO_LEVELDETECT0 0x0140
151#define OMAP4_GPIO_LEVELDETECT1 0x0144
152#define OMAP4_GPIO_RISINGDETECT 0x0148
153#define OMAP4_GPIO_FALLINGDETECT 0x014c
154#define OMAP4_GPIO_DEBOUNCENABLE 0x0150
155#define OMAP4_GPIO_DEBOUNCINGTIME 0x0154
156#define OMAP4_GPIO_CLEARIRQENABLE1 0x0160
157#define OMAP4_GPIO_SETIRQENABLE1 0x0164
158#define OMAP4_GPIO_CLEARWKUENA 0x0180
159#define OMAP4_GPIO_SETWKUENA 0x0184
160#define OMAP4_GPIO_CLEARDATAOUT 0x0190
161#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
183struct gpio_bank {
184 unsigned long pbase;
185 void __iomem *base;
186 u16 irq;
187 u16 virtual_irq_start;
188 int method;
189#if defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP2PLUS)
190 u32 suspend_wakeup;
191 u32 saved_wakeup;
192#endif
193#ifdef CONFIG_ARCH_OMAP2PLUS
194 u32 non_wakeup_gpios;
195 u32 enabled_non_wakeup_gpios;
196
197 u32 saved_datain;
198 u32 saved_fallingdetect;
199 u32 saved_risingdetect;
200#endif
201 u32 level_mask;
202 u32 toggle_mask;
203 spinlock_t lock;
204 struct gpio_chip chip;
205 struct clk *dbck;
206 u32 mod_usage;
207 u32 dbck_enable_mask;
208};
209
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
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 {
305 u32 sysconfig;
306 u32 irqenable1;
307 u32 irqenable2;
308 u32 wake_en;
309 u32 ctrl;
310 u32 oe;
311 u32 leveldetect0;
312 u32 leveldetect1;
313 u32 risingdetect;
314 u32 fallingdetect;
315 u32 dataout;
316};
317
318static struct omap3_gpio_regs gpio_context[OMAP34XX_NR_GPIOS];
319#endif
320
321#ifdef CONFIG_ARCH_OMAP4
322static struct gpio_bank gpio_bank_44xx[6] = {
323 { OMAP44XX_GPIO1_BASE, NULL, OMAP44XX_IRQ_GPIO1, IH_GPIO_BASE,
324 METHOD_GPIO_44XX },
325 { OMAP44XX_GPIO2_BASE, NULL, OMAP44XX_IRQ_GPIO2, IH_GPIO_BASE + 32,
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
337#endif
338
339static struct gpio_bank *gpio_bank;
340static int gpio_bank_count;
341
342static inline struct gpio_bank *get_gpio_bank(int gpio)
343{
344 if (cpu_is_omap15xx()) {
345 if (OMAP_GPIO_IS_MPUIO(gpio))
346 return &gpio_bank[0];
347 return &gpio_bank[1];
348 }
349 if (cpu_is_omap16xx()) {
350 if (OMAP_GPIO_IS_MPUIO(gpio))
351 return &gpio_bank[0];
352 return &gpio_bank[1 + (gpio >> 4)];
353 }
354 if (cpu_is_omap7xx()) {
355 if (OMAP_GPIO_IS_MPUIO(gpio))
356 return &gpio_bank[0];
357 return &gpio_bank[1 + (gpio >> 5)];
358 }
359 if (cpu_is_omap24xx())
360 return &gpio_bank[gpio >> 5];
361 if (cpu_is_omap34xx() || cpu_is_omap44xx())
362 return &gpio_bank[gpio >> 5];
363 BUG();
364 return NULL;
365}
366
367static inline int get_gpio_index(int gpio)
368{
369 if (cpu_is_omap7xx())
370 return gpio & 0x1f;
371 if (cpu_is_omap24xx())
372 return gpio & 0x1f;
373 if (cpu_is_omap34xx() || cpu_is_omap44xx())
374 return gpio & 0x1f;
375 return gpio & 0x0f;
376}
377
378static inline int gpio_valid(int gpio)
379{
380 if (gpio < 0)
381 return -1;
382 if (cpu_class_is_omap1() && OMAP_GPIO_IS_MPUIO(gpio)) {
383 if (gpio >= OMAP_MAX_GPIO_LINES + 16)
384 return -1;
385 return 0;
386 }
387 if (cpu_is_omap15xx() && gpio < 16)
388 return 0;
389 if ((cpu_is_omap16xx()) && gpio < 64)
390 return 0;
391 if (cpu_is_omap7xx() && gpio < 192)
392 return 0;
393 if (cpu_is_omap2420() && gpio < 128)
394 return 0;
395 if (cpu_is_omap2430() && gpio < 160)
396 return 0;
397 if ((cpu_is_omap34xx() || cpu_is_omap44xx()) && gpio < 192)
398 return 0;
399 return -1;
400}
401
402static int check_gpio(int gpio)
403{
404 if (unlikely(gpio_valid(gpio) < 0)) {
405 printk(KERN_ERR "omap-gpio: invalid GPIO %d\n", gpio);
406 dump_stack();
407 return -1;
408 }
409 return 0;
410}
411
412static void _set_gpio_direction(struct gpio_bank *bank, int gpio, int is_input)
413{
414 void __iomem *reg = bank->base;
415 u32 l;
416
417 switch (bank->method) {
418#ifdef CONFIG_ARCH_OMAP1
419 case METHOD_MPUIO:
420 reg += OMAP_MPUIO_IO_CNTL;
421 break;
422#endif
423#ifdef CONFIG_ARCH_OMAP15XX
424 case METHOD_GPIO_1510:
425 reg += OMAP1510_GPIO_DIR_CONTROL;
426 break;
427#endif
428#ifdef CONFIG_ARCH_OMAP16XX
429 case METHOD_GPIO_1610:
430 reg += OMAP1610_GPIO_DIRECTION;
431 break;
432#endif
433#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
434 case METHOD_GPIO_7XX:
435 reg += OMAP7XX_GPIO_DIR_CONTROL;
436 break;
437#endif
438#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
439 case METHOD_GPIO_24XX:
440 reg += OMAP24XX_GPIO_OE;
441 break;
442#endif
443#if defined(CONFIG_ARCH_OMAP4)
444 case METHOD_GPIO_44XX:
445 reg += OMAP4_GPIO_OE;
446 break;
447#endif
448 default:
449 WARN_ON(1);
450 return;
451 }
452 l = __raw_readl(reg);
453 if (is_input)
454 l |= 1 << gpio;
455 else
456 l &= ~(1 << gpio);
457 __raw_writel(l, reg);
458}
459
460static void _set_gpio_dataout(struct gpio_bank *bank, int gpio, int enable)
461{
462 void __iomem *reg = bank->base;
463 u32 l = 0;
464
465 switch (bank->method) {
466#ifdef CONFIG_ARCH_OMAP1
467 case METHOD_MPUIO:
468 reg += OMAP_MPUIO_OUTPUT;
469 l = __raw_readl(reg);
470 if (enable)
471 l |= 1 << gpio;
472 else
473 l &= ~(1 << gpio);
474 break;
475#endif
476#ifdef CONFIG_ARCH_OMAP15XX
477 case METHOD_GPIO_1510:
478 reg += OMAP1510_GPIO_DATA_OUTPUT;
479 l = __raw_readl(reg);
480 if (enable)
481 l |= 1 << gpio;
482 else
483 l &= ~(1 << gpio);
484 break;
485#endif
486#ifdef CONFIG_ARCH_OMAP16XX
487 case METHOD_GPIO_1610:
488 if (enable)
489 reg += OMAP1610_GPIO_SET_DATAOUT;
490 else
491 reg += OMAP1610_GPIO_CLEAR_DATAOUT;
492 l = 1 << gpio;
493 break;
494#endif
495#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
496 case METHOD_GPIO_7XX:
497 reg += OMAP7XX_GPIO_DATA_OUTPUT;
498 l = __raw_readl(reg);
499 if (enable)
500 l |= 1 << gpio;
501 else
502 l &= ~(1 << gpio);
503 break;
504#endif
505#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
506 case METHOD_GPIO_24XX:
507 if (enable)
508 reg += OMAP24XX_GPIO_SETDATAOUT;
509 else
510 reg += OMAP24XX_GPIO_CLEARDATAOUT;
511 l = 1 << gpio;
512 break;
513#endif
514#ifdef CONFIG_ARCH_OMAP4
515 case METHOD_GPIO_44XX:
516 if (enable)
517 reg += OMAP4_GPIO_SETDATAOUT;
518 else
519 reg += OMAP4_GPIO_CLEARDATAOUT;
520 l = 1 << gpio;
521 break;
522#endif
523 default:
524 WARN_ON(1);
525 return;
526 }
527 __raw_writel(l, reg);
528}
529
530static int _get_gpio_datain(struct gpio_bank *bank, int gpio)
531{
532 void __iomem *reg;
533
534 if (check_gpio(gpio) < 0)
535 return -EINVAL;
536 reg = bank->base;
537 switch (bank->method) {
538#ifdef CONFIG_ARCH_OMAP1
539 case METHOD_MPUIO:
540 reg += OMAP_MPUIO_INPUT_LATCH;
541 break;
542#endif
543#ifdef CONFIG_ARCH_OMAP15XX
544 case METHOD_GPIO_1510:
545 reg += OMAP1510_GPIO_DATA_INPUT;
546 break;
547#endif
548#ifdef CONFIG_ARCH_OMAP16XX
549 case METHOD_GPIO_1610:
550 reg += OMAP1610_GPIO_DATAIN;
551 break;
552#endif
553#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
554 case METHOD_GPIO_7XX:
555 reg += OMAP7XX_GPIO_DATA_INPUT;
556 break;
557#endif
558#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
559 case METHOD_GPIO_24XX:
560 reg += OMAP24XX_GPIO_DATAIN;
561 break;
562#endif
563#ifdef CONFIG_ARCH_OMAP4
564 case METHOD_GPIO_44XX:
565 reg += OMAP4_GPIO_DATAIN;
566 break;
567#endif
568 default:
569 return -EINVAL;
570 }
571 return (__raw_readl(reg)
572 & (1 << get_gpio_index(gpio))) != 0;
573}
574
575static int _get_gpio_dataout(struct gpio_bank *bank, int gpio)
576{
577 void __iomem *reg;
578
579 if (check_gpio(gpio) < 0)
580 return -EINVAL;
581 reg = bank->base;
582
583 switch (bank->method) {
584#ifdef CONFIG_ARCH_OMAP1
585 case METHOD_MPUIO:
586 reg += OMAP_MPUIO_OUTPUT;
587 break;
588#endif
589#ifdef CONFIG_ARCH_OMAP15XX
590 case METHOD_GPIO_1510:
591 reg += OMAP1510_GPIO_DATA_OUTPUT;
592 break;
593#endif
594#ifdef CONFIG_ARCH_OMAP16XX
595 case METHOD_GPIO_1610:
596 reg += OMAP1610_GPIO_DATAOUT;
597 break;
598#endif
599#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
600 case METHOD_GPIO_7XX:
601 reg += OMAP7XX_GPIO_DATA_OUTPUT;
602 break;
603#endif
604#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
605 case METHOD_GPIO_24XX:
606 reg += OMAP24XX_GPIO_DATAOUT;
607 break;
608#endif
609#ifdef CONFIG_ARCH_OMAP4
610 case METHOD_GPIO_44XX:
611 reg += OMAP4_GPIO_DATAOUT;
612 break;
613#endif
614 default:
615 return -EINVAL;
616 }
617
618 return (__raw_readl(reg) & (1 << get_gpio_index(gpio))) != 0;
619}
620
621#define MOD_REG_BIT(reg, bit_mask, set) \
622do { \
623 int l = __raw_readl(base + reg); \
624 if (set) l |= bit_mask; \
625 else l &= ~bit_mask; \
626 __raw_writel(l, base + reg); \
627} while(0)
628
629/**
630 * _set_gpio_debounce - low level gpio debounce time
631 * @bank: the gpio bank we're acting upon
632 * @gpio: the gpio number on this @gpio
633 * @debounce: debounce time to use
634 *
635 * OMAP's debounce time is in 31us steps so we need
636 * to convert and round up to the closest unit.
637 */
638static void _set_gpio_debounce(struct gpio_bank *bank, unsigned gpio,
639 unsigned debounce)
640{
641 void __iomem *reg = bank->base;
642 u32 val;
643 u32 l;
644
645 if (debounce < 32)
646 debounce = 0x01;
647 else if (debounce > 7936)
648 debounce = 0xff;
649 else
650 debounce = (debounce / 0x1f) - 1;
651
652 l = 1 << get_gpio_index(gpio);
653
654 if (cpu_is_omap44xx())
655 reg += OMAP4_GPIO_DEBOUNCINGTIME;
656 else
657 reg += OMAP24XX_GPIO_DEBOUNCE_VAL;
658
659 __raw_writel(debounce, reg);
660
661 reg = bank->base;
662 if (cpu_is_omap44xx())
663 reg += OMAP4_GPIO_DEBOUNCENABLE;
664 else
665 reg += OMAP24XX_GPIO_DEBOUNCE_EN;
666
667 val = __raw_readl(reg);
668
669 if (debounce) {
670 val |= l;
671 if (cpu_is_omap34xx() || cpu_is_omap44xx())
672 clk_enable(bank->dbck);
673 } else {
674 val &= ~l;
675 if (cpu_is_omap34xx() || cpu_is_omap44xx())
676 clk_disable(bank->dbck);
677 }
678 bank->dbck_enable_mask = val;
679
680 __raw_writel(val, reg);
681}
682
683#ifdef CONFIG_ARCH_OMAP2PLUS
684static inline void set_24xx_gpio_triggering(struct gpio_bank *bank, int gpio,
685 int trigger)
686{
687 void __iomem *base = bank->base;
688 u32 gpio_bit = 1 << gpio;
689 u32 val;
690
691 if (cpu_is_omap44xx()) {
692 MOD_REG_BIT(OMAP4_GPIO_LEVELDETECT0, gpio_bit,
693 trigger & IRQ_TYPE_LEVEL_LOW);
694 MOD_REG_BIT(OMAP4_GPIO_LEVELDETECT1, gpio_bit,
695 trigger & IRQ_TYPE_LEVEL_HIGH);
696 MOD_REG_BIT(OMAP4_GPIO_RISINGDETECT, gpio_bit,
697 trigger & IRQ_TYPE_EDGE_RISING);
698 MOD_REG_BIT(OMAP4_GPIO_FALLINGDETECT, gpio_bit,
699 trigger & IRQ_TYPE_EDGE_FALLING);
700 } else {
701 MOD_REG_BIT(OMAP24XX_GPIO_LEVELDETECT0, gpio_bit,
702 trigger & IRQ_TYPE_LEVEL_LOW);
703 MOD_REG_BIT(OMAP24XX_GPIO_LEVELDETECT1, gpio_bit,
704 trigger & IRQ_TYPE_LEVEL_HIGH);
705 MOD_REG_BIT(OMAP24XX_GPIO_RISINGDETECT, gpio_bit,
706 trigger & IRQ_TYPE_EDGE_RISING);
707 MOD_REG_BIT(OMAP24XX_GPIO_FALLINGDETECT, gpio_bit,
708 trigger & IRQ_TYPE_EDGE_FALLING);
709 }
710 if (likely(!(bank->non_wakeup_gpios & gpio_bit))) {
711 if (cpu_is_omap44xx()) {
712 if (trigger != 0)
713 __raw_writel(1 << gpio, bank->base+
714 OMAP4_GPIO_IRQWAKEN0);
715 else {
716 val = __raw_readl(bank->base +
717 OMAP4_GPIO_IRQWAKEN0);
718 __raw_writel(val & (~(1 << gpio)), bank->base +
719 OMAP4_GPIO_IRQWAKEN0);
720 }
721 } else {
722 /*
723 * GPIO wakeup request can only be generated on edge
724 * transitions
725 */
726 if (trigger & IRQ_TYPE_EDGE_BOTH)
727 __raw_writel(1 << gpio, bank->base
728 + OMAP24XX_GPIO_SETWKUENA);
729 else
730 __raw_writel(1 << gpio, bank->base
731 + OMAP24XX_GPIO_CLEARWKUENA);
732 }
733 }
734 /* This part needs to be executed always for OMAP34xx */
735 if (cpu_is_omap34xx() || (bank->non_wakeup_gpios & gpio_bit)) {
736 /*
737 * Log the edge gpio and manually trigger the IRQ
738 * after resume if the input level changes
739 * to avoid irq lost during PER RET/OFF mode
740 * Applies for omap2 non-wakeup gpio and all omap3 gpios
741 */
742 if (trigger & IRQ_TYPE_EDGE_BOTH)
743 bank->enabled_non_wakeup_gpios |= gpio_bit;
744 else
745 bank->enabled_non_wakeup_gpios &= ~gpio_bit;
746 }
747
748 if (cpu_is_omap44xx()) {
749 bank->level_mask =
750 __raw_readl(bank->base + OMAP4_GPIO_LEVELDETECT0) |
751 __raw_readl(bank->base + OMAP4_GPIO_LEVELDETECT1);
752 } else {
753 bank->level_mask =
754 __raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT0) |
755 __raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT1);
756 }
757}
758#endif
759
760#ifdef CONFIG_ARCH_OMAP1
761/*
762 * This only applies to chips that can't do both rising and falling edge
763 * detection at once. For all other chips, this function is a noop.
764 */
765static void _toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio)
766{
767 void __iomem *reg = bank->base;
768 u32 l = 0;
769
770 switch (bank->method) {
771 case METHOD_MPUIO:
772 reg += OMAP_MPUIO_GPIO_INT_EDGE;
773 break;
774#ifdef CONFIG_ARCH_OMAP15XX
775 case METHOD_GPIO_1510:
776 reg += OMAP1510_GPIO_INT_CONTROL;
777 break;
778#endif
779#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
780 case METHOD_GPIO_7XX:
781 reg += OMAP7XX_GPIO_INT_CONTROL;
782 break;
783#endif
784 default:
785 return;
786 }
787
788 l = __raw_readl(reg);
789 if ((l >> gpio) & 1)
790 l &= ~(1 << gpio);
791 else
792 l |= 1 << gpio;
793
794 __raw_writel(l, reg);
795}
796#endif
797
798static int _set_gpio_triggering(struct gpio_bank *bank, int gpio, int trigger)
799{
800 void __iomem *reg = bank->base;
801 u32 l = 0;
802
803 switch (bank->method) {
804#ifdef CONFIG_ARCH_OMAP1
805 case METHOD_MPUIO:
806 reg += OMAP_MPUIO_GPIO_INT_EDGE;
807 l = __raw_readl(reg);
808 if ((trigger & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH)
809 bank->toggle_mask |= 1 << gpio;
810 if (trigger & IRQ_TYPE_EDGE_RISING)
811 l |= 1 << gpio;
812 else if (trigger & IRQ_TYPE_EDGE_FALLING)
813 l &= ~(1 << gpio);
814 else
815 goto bad;
816 break;
817#endif
818#ifdef CONFIG_ARCH_OMAP15XX
819 case METHOD_GPIO_1510:
820 reg += OMAP1510_GPIO_INT_CONTROL;
821 l = __raw_readl(reg);
822 if ((trigger & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH)
823 bank->toggle_mask |= 1 << gpio;
824 if (trigger & IRQ_TYPE_EDGE_RISING)
825 l |= 1 << gpio;
826 else if (trigger & IRQ_TYPE_EDGE_FALLING)
827 l &= ~(1 << gpio);
828 else
829 goto bad;
830 break;
831#endif
832#ifdef CONFIG_ARCH_OMAP16XX
833 case METHOD_GPIO_1610:
834 if (gpio & 0x08)
835 reg += OMAP1610_GPIO_EDGE_CTRL2;
836 else
837 reg += OMAP1610_GPIO_EDGE_CTRL1;
838 gpio &= 0x07;
839 l = __raw_readl(reg);
840 l &= ~(3 << (gpio << 1));
841 if (trigger & IRQ_TYPE_EDGE_RISING)
842 l |= 2 << (gpio << 1);
843 if (trigger & IRQ_TYPE_EDGE_FALLING)
844 l |= 1 << (gpio << 1);
845 if (trigger)
846 /* Enable wake-up during idle for dynamic tick */
847 __raw_writel(1 << gpio, bank->base + OMAP1610_GPIO_SET_WAKEUPENA);
848 else
849 __raw_writel(1 << gpio, bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA);
850 break;
851#endif
852#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
853 case METHOD_GPIO_7XX:
854 reg += OMAP7XX_GPIO_INT_CONTROL;
855 l = __raw_readl(reg);
856 if ((trigger & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH)
857 bank->toggle_mask |= 1 << gpio;
858 if (trigger & IRQ_TYPE_EDGE_RISING)
859 l |= 1 << gpio;
860 else if (trigger & IRQ_TYPE_EDGE_FALLING)
861 l &= ~(1 << gpio);
862 else
863 goto bad;
864 break;
865#endif
866#ifdef CONFIG_ARCH_OMAP2PLUS
867 case METHOD_GPIO_24XX:
868 case METHOD_GPIO_44XX:
869 set_24xx_gpio_triggering(bank, gpio, trigger);
870 break;
871#endif
872 default:
873 goto bad;
874 }
875 __raw_writel(l, reg);
876 return 0;
877bad:
878 return -EINVAL;
879}
880
881static int gpio_irq_type(unsigned irq, unsigned type)
882{
883 struct gpio_bank *bank;
884 unsigned gpio;
885 int retval;
886 unsigned long flags;
887
888 if (!cpu_class_is_omap2() && irq > IH_MPUIO_BASE)
889 gpio = OMAP_MPUIO(irq - IH_MPUIO_BASE);
890 else
891 gpio = irq - IH_GPIO_BASE;
892
893 if (check_gpio(gpio) < 0)
894 return -EINVAL;
895
896 if (type & ~IRQ_TYPE_SENSE_MASK)
897 return -EINVAL;
898
899 /* OMAP1 allows only only edge triggering */
900 if (!cpu_class_is_omap2()
901 && (type & (IRQ_TYPE_LEVEL_LOW|IRQ_TYPE_LEVEL_HIGH)))
902 return -EINVAL;
903
904 bank = get_irq_chip_data(irq);
905 spin_lock_irqsave(&bank->lock, flags);
906 retval = _set_gpio_triggering(bank, get_gpio_index(gpio), type);
907 if (retval == 0) {
908 irq_desc[irq].status &= ~IRQ_TYPE_SENSE_MASK;
909 irq_desc[irq].status |= type;
910 }
911 spin_unlock_irqrestore(&bank->lock, flags);
912
913 if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
914 __set_irq_handler_unlocked(irq, handle_level_irq);
915 else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING))
916 __set_irq_handler_unlocked(irq, handle_edge_irq);
917
918 return retval;
919}
920
921static void _clear_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
922{
923 void __iomem *reg = bank->base;
924
925 switch (bank->method) {
926#ifdef CONFIG_ARCH_OMAP1
927 case METHOD_MPUIO:
928 /* MPUIO irqstatus is reset by reading the status register,
929 * so do nothing here */
930 return;
931#endif
932#ifdef CONFIG_ARCH_OMAP15XX
933 case METHOD_GPIO_1510:
934 reg += OMAP1510_GPIO_INT_STATUS;
935 break;
936#endif
937#ifdef CONFIG_ARCH_OMAP16XX
938 case METHOD_GPIO_1610:
939 reg += OMAP1610_GPIO_IRQSTATUS1;
940 break;
941#endif
942#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
943 case METHOD_GPIO_7XX:
944 reg += OMAP7XX_GPIO_INT_STATUS;
945 break;
946#endif
947#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
948 case METHOD_GPIO_24XX:
949 reg += OMAP24XX_GPIO_IRQSTATUS1;
950 break;
951#endif
952#if defined(CONFIG_ARCH_OMAP4)
953 case METHOD_GPIO_44XX:
954 reg += OMAP4_GPIO_IRQSTATUS0;
955 break;
956#endif
957 default:
958 WARN_ON(1);
959 return;
960 }
961 __raw_writel(gpio_mask, reg);
962
963 /* Workaround for clearing DSP GPIO interrupts to allow retention */
964 if (cpu_is_omap24xx() || cpu_is_omap34xx())
965 reg = bank->base + OMAP24XX_GPIO_IRQSTATUS2;
966 else if (cpu_is_omap44xx())
967 reg = bank->base + OMAP4_GPIO_IRQSTATUS1;
968
969 if (cpu_is_omap24xx() || cpu_is_omap34xx() || cpu_is_omap44xx()) {
970 __raw_writel(gpio_mask, reg);
971
972 /* Flush posted write for the irq status to avoid spurious interrupts */
973 __raw_readl(reg);
974 }
975}
976
977static inline void _clear_gpio_irqstatus(struct gpio_bank *bank, int gpio)
978{
979 _clear_gpio_irqbank(bank, 1 << get_gpio_index(gpio));
980}
981
982static u32 _get_gpio_irqbank_mask(struct gpio_bank *bank)
983{
984 void __iomem *reg = bank->base;
985 int inv = 0;
986 u32 l;
987 u32 mask;
988
989 switch (bank->method) {
990#ifdef CONFIG_ARCH_OMAP1
991 case METHOD_MPUIO:
992 reg += OMAP_MPUIO_GPIO_MASKIT;
993 mask = 0xffff;
994 inv = 1;
995 break;
996#endif
997#ifdef CONFIG_ARCH_OMAP15XX
998 case METHOD_GPIO_1510:
999 reg += OMAP1510_GPIO_INT_MASK;
1000 mask = 0xffff;
1001 inv = 1;
1002 break;
1003#endif
1004#ifdef CONFIG_ARCH_OMAP16XX
1005 case METHOD_GPIO_1610:
1006 reg += OMAP1610_GPIO_IRQENABLE1;
1007 mask = 0xffff;
1008 break;
1009#endif
1010#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
1011 case METHOD_GPIO_7XX:
1012 reg += OMAP7XX_GPIO_INT_MASK;
1013 mask = 0xffffffff;
1014 inv = 1;
1015 break;
1016#endif
1017#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
1018 case METHOD_GPIO_24XX:
1019 reg += OMAP24XX_GPIO_IRQENABLE1;
1020 mask = 0xffffffff;
1021 break;
1022#endif
1023#if defined(CONFIG_ARCH_OMAP4)
1024 case METHOD_GPIO_44XX:
1025 reg += OMAP4_GPIO_IRQSTATUSSET0;
1026 mask = 0xffffffff;
1027 break;
1028#endif
1029 default:
1030 WARN_ON(1);
1031 return 0;
1032 }
1033
1034 l = __raw_readl(reg);
1035 if (inv)
1036 l = ~l;
1037 l &= mask;
1038 return l;
1039}
1040
1041static void _enable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask, int enable)
1042{
1043 void __iomem *reg = bank->base;
1044 u32 l;
1045
1046 switch (bank->method) {
1047#ifdef CONFIG_ARCH_OMAP1
1048 case METHOD_MPUIO:
1049 reg += OMAP_MPUIO_GPIO_MASKIT;
1050 l = __raw_readl(reg);
1051 if (enable)
1052 l &= ~(gpio_mask);
1053 else
1054 l |= gpio_mask;
1055 break;
1056#endif
1057#ifdef CONFIG_ARCH_OMAP15XX
1058 case METHOD_GPIO_1510:
1059 reg += OMAP1510_GPIO_INT_MASK;
1060 l = __raw_readl(reg);
1061 if (enable)
1062 l &= ~(gpio_mask);
1063 else
1064 l |= gpio_mask;
1065 break;
1066#endif
1067#ifdef CONFIG_ARCH_OMAP16XX
1068 case METHOD_GPIO_1610:
1069 if (enable)
1070 reg += OMAP1610_GPIO_SET_IRQENABLE1;
1071 else
1072 reg += OMAP1610_GPIO_CLEAR_IRQENABLE1;
1073 l = gpio_mask;
1074 break;
1075#endif
1076#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
1077 case METHOD_GPIO_7XX:
1078 reg += OMAP7XX_GPIO_INT_MASK;
1079 l = __raw_readl(reg);
1080 if (enable)
1081 l &= ~(gpio_mask);
1082 else
1083 l |= gpio_mask;
1084 break;
1085#endif
1086#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
1087 case METHOD_GPIO_24XX:
1088 if (enable)
1089 reg += OMAP24XX_GPIO_SETIRQENABLE1;
1090 else
1091 reg += OMAP24XX_GPIO_CLEARIRQENABLE1;
1092 l = gpio_mask;
1093 break;
1094#endif
1095#ifdef CONFIG_ARCH_OMAP4
1096 case METHOD_GPIO_44XX:
1097 if (enable)
1098 reg += OMAP4_GPIO_IRQSTATUSSET0;
1099 else
1100 reg += OMAP4_GPIO_IRQSTATUSCLR0;
1101 l = gpio_mask;
1102 break;
1103#endif
1104 default:
1105 WARN_ON(1);
1106 return;
1107 }
1108 __raw_writel(l, reg);
1109}
1110
1111static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int enable)
1112{
1113 _enable_gpio_irqbank(bank, 1 << get_gpio_index(gpio), enable);
1114}
1115
1116/*
1117 * Note that ENAWAKEUP needs to be enabled in GPIO_SYSCONFIG register.
1118 * 1510 does not seem to have a wake-up register. If JTAG is connected
1119 * to the target, system will wake up always on GPIO events. While
1120 * system is running all registered GPIO interrupts need to have wake-up
1121 * enabled. When system is suspended, only selected GPIO interrupts need
1122 * to have wake-up enabled.
1123 */
1124static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable)
1125{
1126 unsigned long uninitialized_var(flags);
1127
1128 switch (bank->method) {
1129#ifdef CONFIG_ARCH_OMAP16XX
1130 case METHOD_MPUIO:
1131 case METHOD_GPIO_1610:
1132 spin_lock_irqsave(&bank->lock, flags);
1133 if (enable)
1134 bank->suspend_wakeup |= (1 << gpio);
1135 else
1136 bank->suspend_wakeup &= ~(1 << gpio);
1137 spin_unlock_irqrestore(&bank->lock, flags);
1138 return 0;
1139#endif
1140#ifdef CONFIG_ARCH_OMAP2PLUS
1141 case METHOD_GPIO_24XX:
1142 case METHOD_GPIO_44XX:
1143 if (bank->non_wakeup_gpios & (1 << gpio)) {
1144 printk(KERN_ERR "Unable to modify wakeup on "
1145 "non-wakeup GPIO%d\n",
1146 (bank - gpio_bank) * 32 + gpio);
1147 return -EINVAL;
1148 }
1149 spin_lock_irqsave(&bank->lock, flags);
1150 if (enable)
1151 bank->suspend_wakeup |= (1 << gpio);
1152 else
1153 bank->suspend_wakeup &= ~(1 << gpio);
1154 spin_unlock_irqrestore(&bank->lock, flags);
1155 return 0;
1156#endif
1157 default:
1158 printk(KERN_ERR "Can't enable GPIO wakeup for method %i\n",
1159 bank->method);
1160 return -EINVAL;
1161 }
1162}
1163
1164static void _reset_gpio(struct gpio_bank *bank, int gpio)
1165{
1166 _set_gpio_direction(bank, get_gpio_index(gpio), 1);
1167 _set_gpio_irqenable(bank, gpio, 0);
1168 _clear_gpio_irqstatus(bank, gpio);
1169 _set_gpio_triggering(bank, get_gpio_index(gpio), IRQ_TYPE_NONE);
1170}
1171
1172/* Use disable_irq_wake() and enable_irq_wake() functions from drivers */
1173static int gpio_wake_enable(unsigned int irq, unsigned int enable)
1174{
1175 unsigned int gpio = irq - IH_GPIO_BASE;
1176 struct gpio_bank *bank;
1177 int retval;
1178
1179 if (check_gpio(gpio) < 0)
1180 return -ENODEV;
1181 bank = get_irq_chip_data(irq);
1182 retval = _set_gpio_wakeup(bank, get_gpio_index(gpio), enable);
1183
1184 return retval;
1185}
1186
1187static int omap_gpio_request(struct gpio_chip *chip, unsigned offset)
1188{
1189 struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip);
1190 unsigned long flags;
1191
1192 spin_lock_irqsave(&bank->lock, flags);
1193
1194 /* Set trigger to none. You need to enable the desired trigger with
1195 * request_irq() or set_irq_type().
1196 */
1197 _set_gpio_triggering(bank, offset, IRQ_TYPE_NONE);
1198
1199#ifdef CONFIG_ARCH_OMAP15XX
1200 if (bank->method == METHOD_GPIO_1510) {
1201 void __iomem *reg;
1202
1203 /* Claim the pin for MPU */
1204 reg = bank->base + OMAP1510_GPIO_PIN_CONTROL;
1205 __raw_writel(__raw_readl(reg) | (1 << offset), reg);
1206 }
1207#endif
1208 if (!cpu_class_is_omap1()) {
1209 if (!bank->mod_usage) {
1210 void __iomem *reg = bank->base;
1211 u32 ctrl;
1212
1213 if (cpu_is_omap24xx() || cpu_is_omap34xx())
1214 reg += OMAP24XX_GPIO_CTRL;
1215 else if (cpu_is_omap44xx())
1216 reg += OMAP4_GPIO_CTRL;
1217 ctrl = __raw_readl(reg);
1218 /* Module is enabled, clocks are not gated */
1219 ctrl &= 0xFFFFFFFE;
1220 __raw_writel(ctrl, reg);
1221 }
1222 bank->mod_usage |= 1 << offset;
1223 }
1224 spin_unlock_irqrestore(&bank->lock, flags);
1225
1226 return 0;
1227}
1228
1229static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
1230{
1231 struct gpio_bank *bank = container_of(chip, struct gpio_bank, chip);
1232 unsigned long flags;
1233
1234 spin_lock_irqsave(&bank->lock, flags);
1235#ifdef CONFIG_ARCH_OMAP16XX
1236 if (bank->method == METHOD_GPIO_1610) {
1237 /* Disable wake-up during idle for dynamic tick */
1238 void __iomem *reg = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA;
1239 __raw_writel(1 << offset, reg);
1240 }
1241#endif
1242#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
1243 if (bank->method == METHOD_GPIO_24XX) {
1244 /* Disable wake-up during idle for dynamic tick */
1245 void __iomem *reg = bank->base + OMAP24XX_GPIO_CLEARWKUENA;
1246 __raw_writel(1 << offset, reg);
1247 }
1248#endif
1249#ifdef CONFIG_ARCH_OMAP4
1250 if (bank->method == METHOD_GPIO_44XX) {
1251 /* Disable wake-up during idle for dynamic tick */
1252 void __iomem *reg = bank->base + OMAP4_GPIO_IRQWAKEN0;
1253 __raw_writel(1 << offset, reg);
1254 }
1255#endif
1256 if (!cpu_class_is_omap1()) {
1257 bank->mod_usage &= ~(1 << offset);
1258 if (!bank->mod_usage) {
1259 void __iomem *reg = bank->base;
1260 u32 ctrl;
1261
1262 if (cpu_is_omap24xx() || cpu_is_omap34xx())
1263 reg += OMAP24XX_GPIO_CTRL;
1264 else if (cpu_is_omap44xx())
1265 reg += OMAP4_GPIO_CTRL;
1266 ctrl = __raw_readl(reg);
1267 /* Module is disabled, clocks are gated */
1268 ctrl |= 1;
1269 __raw_writel(ctrl, reg);
1270 }
1271 }
1272 _reset_gpio(bank, bank->chip.base + offset);
1273 spin_unlock_irqrestore(&bank->lock, flags);
1274}
1275
1276/*
1277 * We need to unmask the GPIO bank interrupt as soon as possible to
1278 * avoid missing GPIO interrupts for other lines in the bank.
1279 * Then we need to mask-read-clear-unmask the triggered GPIO lines
1280 * in the bank to avoid missing nested interrupts for a GPIO line.
1281 * If we wait to unmask individual GPIO lines in the bank after the
1282 * line's interrupt handler has been run, we may miss some nested
1283 * interrupts.
1284 */
1285static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
1286{
1287 void __iomem *isr_reg = NULL;
1288 u32 isr;
1289 unsigned int gpio_irq, gpio_index;
1290 struct gpio_bank *bank;
1291 u32 retrigger = 0;
1292 int unmasked = 0;
1293
1294 desc->chip->ack(irq);
1295
1296 bank = get_irq_data(irq);
1297#ifdef CONFIG_ARCH_OMAP1
1298 if (bank->method == METHOD_MPUIO)
1299 isr_reg = bank->base + OMAP_MPUIO_GPIO_INT;
1300#endif
1301#ifdef CONFIG_ARCH_OMAP15XX
1302 if (bank->method == METHOD_GPIO_1510)
1303 isr_reg = bank->base + OMAP1510_GPIO_INT_STATUS;
1304#endif
1305#if defined(CONFIG_ARCH_OMAP16XX)
1306 if (bank->method == METHOD_GPIO_1610)
1307 isr_reg = bank->base + OMAP1610_GPIO_IRQSTATUS1;
1308#endif
1309#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
1310 if (bank->method == METHOD_GPIO_7XX)
1311 isr_reg = bank->base + OMAP7XX_GPIO_INT_STATUS;
1312#endif
1313#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
1314 if (bank->method == METHOD_GPIO_24XX)
1315 isr_reg = bank->base + OMAP24XX_GPIO_IRQSTATUS1;
1316#endif
1317#if defined(CONFIG_ARCH_OMAP4)
1318 if (bank->method == METHOD_GPIO_44XX)
1319 isr_reg = bank->base + OMAP4_GPIO_IRQSTATUS0;
1320#endif
1321 while(1) {
1322 u32 isr_saved, level_mask = 0;
1323 u32 enabled;
1324
1325 enabled = _get_gpio_irqbank_mask(bank);
1326 isr_saved = isr = __raw_readl(isr_reg) & enabled;
1327
1328 if (cpu_is_omap15xx() && (bank->method == METHOD_MPUIO))
1329 isr &= 0x0000ffff;
1330
1331 if (cpu_class_is_omap2()) {
1332 level_mask = bank->level_mask & enabled;
1333 }
1334
1335 /* clear edge sensitive interrupts before handler(s) are
1336 called so that we don't miss any interrupt occurred while
1337 executing them */
1338 _enable_gpio_irqbank(bank, isr_saved & ~level_mask, 0);
1339 _clear_gpio_irqbank(bank, isr_saved & ~level_mask);
1340 _enable_gpio_irqbank(bank, isr_saved & ~level_mask, 1);
1341
1342 /* if there is only edge sensitive GPIO pin interrupts
1343 configured, we could unmask GPIO bank interrupt immediately */
1344 if (!level_mask && !unmasked) {
1345 unmasked = 1;
1346 desc->chip->unmask(irq);
1347 }
1348
1349 isr |= retrigger;
1350 retrigger = 0;
1351 if (!isr)
1352 break;
1353
1354 gpio_irq = bank->virtual_irq_start;
1355 for (; isr != 0; isr >>= 1, gpio_irq++) {
1356 gpio_index = get_gpio_index(irq_to_gpio(gpio_irq));
1357
1358 if (!(isr & 1))
1359 continue;
1360
1361#ifdef CONFIG_ARCH_OMAP1
1362 /*
1363 * Some chips can't respond to both rising and falling
1364 * at the same time. If this irq was requested with
1365 * both flags, we need to flip the ICR data for the IRQ
1366 * to respond to the IRQ for the opposite direction.
1367 * This will be indicated in the bank toggle_mask.
1368 */
1369 if (bank->toggle_mask & (1 << gpio_index))
1370 _toggle_gpio_edge_triggering(bank, gpio_index);
1371#endif
1372
1373 generic_handle_irq(gpio_irq);
1374 }
1375 }
1376 /* if bank has any level sensitive GPIO pin interrupt
1377 configured, we must unmask the bank interrupt only after
1378 handler(s) are executed in order to avoid spurious bank
1379 interrupt */
1380 if (!unmasked)
1381 desc->chip->unmask(irq);
1382
1383}
1384
1385static void gpio_irq_shutdown(unsigned int irq)
1386{
1387 unsigned int gpio = irq - IH_GPIO_BASE;
1388 struct gpio_bank *bank = get_irq_chip_data(irq);
1389
1390 _reset_gpio(bank, gpio);
1391}
1392
1393static void gpio_ack_irq(unsigned int irq)
1394{
1395 unsigned int gpio = irq - IH_GPIO_BASE;
1396 struct gpio_bank *bank = get_irq_chip_data(irq);
1397
1398 _clear_gpio_irqstatus(bank, gpio);
1399}
1400
1401static void gpio_mask_irq(unsigned int irq)
1402{
1403 unsigned int gpio = irq - IH_GPIO_BASE;
1404 struct gpio_bank *bank = get_irq_chip_data(irq);
1405
1406 _set_gpio_irqenable(bank, gpio, 0);
1407 _set_gpio_triggering(bank, get_gpio_index(gpio), IRQ_TYPE_NONE);
1408}
1409
1410static void gpio_unmask_irq(unsigned int irq)
1411{
1412 unsigned int gpio = irq - IH_GPIO_BASE;
1413 struct gpio_bank *bank = get_irq_chip_data(irq);
1414 unsigned int irq_mask = 1 << get_gpio_index(gpio);
1415 struct irq_desc *desc = irq_to_desc(irq);
1416 u32 trigger = desc->status & IRQ_TYPE_SENSE_MASK;
1417
1418 if (trigger)
1419 _set_gpio_triggering(bank, get_gpio_index(gpio), trigger);
1420
1421 /* For level-triggered GPIOs, the clearing must be done after
1422 * the HW source is cleared, thus after the handler has run */
1423 if (bank->level_mask & irq_mask) {
1424 _set_gpio_irqenable(bank, gpio, 0);
1425 _clear_gpio_irqstatus(bank, gpio);
1426 }
1427
1428 _set_gpio_irqenable(bank, gpio, 1);
1429}
1430
1431static struct irq_chip gpio_irq_chip = {
1432 .name = "GPIO",
1433 .shutdown = gpio_irq_shutdown,
1434 .ack = gpio_ack_irq,
1435 .mask = gpio_mask_irq,
1436 .unmask = gpio_unmask_irq,
1437 .set_type = gpio_irq_type,
1438 .set_wake = gpio_wake_enable,
1439};
1440
1441/*---------------------------------------------------------------------*/
1442
1443#ifdef CONFIG_ARCH_OMAP1
1444
1445/* MPUIO uses the always-on 32k clock */
1446
1447static void mpuio_ack_irq(unsigned int irq)
1448{
1449 /* The ISR is reset automatically, so do nothing here. */
1450}
1451
1452static void mpuio_mask_irq(unsigned int irq)
1453{
1454 unsigned int gpio = OMAP_MPUIO(irq - IH_MPUIO_BASE);
1455 struct gpio_bank *bank = get_irq_chip_data(irq);
1456
1457 _set_gpio_irqenable(bank, gpio, 0);
1458}
1459
1460static void mpuio_unmask_irq(unsigned int irq)
1461{
1462 unsigned int gpio = OMAP_MPUIO(irq - IH_MPUIO_BASE);
1463 struct gpio_bank *bank = get_irq_chip_data(irq);
1464
1465 _set_gpio_irqenable(bank, gpio, 1);
1466}
1467
1468static struct irq_chip mpuio_irq_chip = {
1469 .name = "MPUIO",
1470 .ack = mpuio_ack_irq,
1471 .mask = mpuio_mask_irq,
1472 .unmask = mpuio_unmask_irq,
1473 .set_type = gpio_irq_type,
1474#ifdef CONFIG_ARCH_OMAP16XX
1475 /* REVISIT: assuming only 16xx supports MPUIO wake events */
1476 .set_wake = gpio_wake_enable,
1477#endif
1478};
1479
1480
1481#define bank_is_mpuio(bank) ((bank)->method == METHOD_MPUIO)
1482
1483
1484#ifdef CONFIG_ARCH_OMAP16XX
1485
1486#include <linux/platform_device.h>
1487
1488static int omap_mpuio_suspend_noirq(struct device *dev)
1489{
1490 struct platform_device *pdev = to_platform_device(dev);
1491 struct gpio_bank *bank = platform_get_drvdata(pdev);
1492 void __iomem *mask_reg = bank->base + OMAP_MPUIO_GPIO_MASKIT;
1493 unsigned long flags;
1494
1495 spin_lock_irqsave(&bank->lock, flags);
1496 bank->saved_wakeup = __raw_readl(mask_reg);
1497 __raw_writel(0xffff & ~bank->suspend_wakeup, mask_reg);
1498 spin_unlock_irqrestore(&bank->lock, flags);
1499
1500 return 0;
1501}
1502
1503static int omap_mpuio_resume_noirq(struct device *dev)
1504{
1505 struct platform_device *pdev = to_platform_device(dev);
1506 struct gpio_bank *bank = platform_get_drvdata(pdev);
1507 void __iomem *mask_reg = bank->base + OMAP_MPUIO_GPIO_MASKIT;
1508 unsigned long flags;
1509
1510 spin_lock_irqsave(&bank->lock, flags);
1511 __raw_writel(bank->saved_wakeup, mask_reg);
1512 spin_unlock_irqrestore(&bank->lock, flags);
1513
1514 return 0;
1515}
1516
1517static const struct dev_pm_ops omap_mpuio_dev_pm_ops = {
1518 .suspend_noirq = omap_mpuio_suspend_noirq,
1519 .resume_noirq = omap_mpuio_resume_noirq,
1520};
1521
1522/* use platform_driver for this, now that there's no longer any
1523 * point to sys_device (other than not disturbing old code).
1524 */
1525static struct platform_driver omap_mpuio_driver = {
1526 .driver = {
1527 .name = "mpuio",
1528 .pm = &omap_mpuio_dev_pm_ops,
1529 },
1530};
1531
1532static struct platform_device omap_mpuio_device = {
1533 .name = "mpuio",
1534 .id = -1,
1535 .dev = {
1536 .driver = &omap_mpuio_driver.driver,
1537 }
1538 /* could list the /proc/iomem resources */
1539};
1540
1541static inline void mpuio_init(void)
1542{
1543 platform_set_drvdata(&omap_mpuio_device, &gpio_bank_1610[0]);
1544
1545 if (platform_driver_register(&omap_mpuio_driver) == 0)
1546 (void) platform_device_register(&omap_mpuio_device);
1547}
1548
1549#else
1550static inline void mpuio_init(void) {}
1551#endif /* 16xx */
1552
1553#else
1554
1555extern struct irq_chip mpuio_irq_chip;
1556
1557#define bank_is_mpuio(bank) 0
1558static inline void mpuio_init(void) {}
1559
1560#endif
1561
1562/*---------------------------------------------------------------------*/
1563
1564/* REVISIT these are stupid implementations! replace by ones that
1565 * don't switch on METHOD_* and which mostly avoid spinlocks
1566 */
1567
1568static int gpio_input(struct gpio_chip *chip, unsigned offset)
1569{
1570 struct gpio_bank *bank;
1571 unsigned long flags;
1572
1573 bank = container_of(chip, struct gpio_bank, chip);
1574 spin_lock_irqsave(&bank->lock, flags);
1575 _set_gpio_direction(bank, offset, 1);
1576 spin_unlock_irqrestore(&bank->lock, flags);
1577 return 0;
1578}
1579
1580static int gpio_is_input(struct gpio_bank *bank, int mask)
1581{
1582 void __iomem *reg = bank->base;
1583
1584 switch (bank->method) {
1585 case METHOD_MPUIO:
1586 reg += OMAP_MPUIO_IO_CNTL;
1587 break;
1588 case METHOD_GPIO_1510:
1589 reg += OMAP1510_GPIO_DIR_CONTROL;
1590 break;
1591 case METHOD_GPIO_1610:
1592 reg += OMAP1610_GPIO_DIRECTION;
1593 break;
1594 case METHOD_GPIO_7XX:
1595 reg += OMAP7XX_GPIO_DIR_CONTROL;
1596 break;
1597 case METHOD_GPIO_24XX:
1598 reg += OMAP24XX_GPIO_OE;
1599 break;
1600 case METHOD_GPIO_44XX:
1601 reg += OMAP4_GPIO_OE;
1602 break;
1603 default:
1604 WARN_ONCE(1, "gpio_is_input: incorrect OMAP GPIO method");
1605 return -EINVAL;
1606 }
1607 return __raw_readl(reg) & mask;
1608}
1609
1610static int gpio_get(struct gpio_chip *chip, unsigned offset)
1611{
1612 struct gpio_bank *bank;
1613 void __iomem *reg;
1614 int gpio;
1615 u32 mask;
1616
1617 gpio = chip->base + offset;
1618 bank = get_gpio_bank(gpio);
1619 reg = bank->base;
1620 mask = 1 << get_gpio_index(gpio);
1621
1622 if (gpio_is_input(bank, mask))
1623 return _get_gpio_datain(bank, gpio);
1624 else
1625 return _get_gpio_dataout(bank, gpio);
1626}
1627
1628static int gpio_output(struct gpio_chip *chip, unsigned offset, int value)
1629{
1630 struct gpio_bank *bank;
1631 unsigned long flags;
1632
1633 bank = container_of(chip, struct gpio_bank, chip);
1634 spin_lock_irqsave(&bank->lock, flags);
1635 _set_gpio_dataout(bank, offset, value);
1636 _set_gpio_direction(bank, offset, 0);
1637 spin_unlock_irqrestore(&bank->lock, flags);
1638 return 0;
1639}
1640
1641static int gpio_debounce(struct gpio_chip *chip, unsigned offset,
1642 unsigned debounce)
1643{
1644 struct gpio_bank *bank;
1645 unsigned long flags;
1646
1647 bank = container_of(chip, struct gpio_bank, chip);
1648 spin_lock_irqsave(&bank->lock, flags);
1649 _set_gpio_debounce(bank, offset, debounce);
1650 spin_unlock_irqrestore(&bank->lock, flags);
1651
1652 return 0;
1653}
1654
1655static void gpio_set(struct gpio_chip *chip, unsigned offset, int value)
1656{
1657 struct gpio_bank *bank;
1658 unsigned long flags;
1659
1660 bank = container_of(chip, struct gpio_bank, chip);
1661 spin_lock_irqsave(&bank->lock, flags);
1662 _set_gpio_dataout(bank, offset, value);
1663 spin_unlock_irqrestore(&bank->lock, flags);
1664}
1665
1666static int gpio_2irq(struct gpio_chip *chip, unsigned offset)
1667{
1668 struct gpio_bank *bank;
1669
1670 bank = container_of(chip, struct gpio_bank, chip);
1671 return bank->virtual_irq_start + offset;
1672}
1673
1674/*---------------------------------------------------------------------*/
1675
1676static int initialized;
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{
1696 u32 rev;
1697
1698 if (cpu_is_omap16xx())
1699 rev = __raw_readw(gpio_bank[1].base + OMAP1610_GPIO_REVISION);
1700 else if (cpu_is_omap24xx() || cpu_is_omap34xx())
1701 rev = __raw_readl(gpio_bank[0].base + OMAP24XX_GPIO_REVISION);
1702 else if (cpu_is_omap44xx())
1703 rev = __raw_readl(gpio_bank[0].base + OMAP4_GPIO_REVISION);
1704 else
1705 return;
1706
1707 printk(KERN_INFO "OMAP GPIO hardware version %d.%d\n",
1708 (rev >> 4) & 0x0f, rev & 0x0f);
1709}
1710
1711/* This lock class tells lockdep that GPIO irqs are in a different
1712 * category than their parents, so it won't report false recursion.
1713 */
1714static struct lock_class_key gpio_lock_class;
1715
1716static int __init _omap_gpio_init(void)
1717{
1718 int i;
1719 int gpio = 0;
1720 struct gpio_bank *bank;
1721 int bank_size = SZ_8K; /* Module 4KB + L4 4KB except on omap1 */
1722 char clk_name[11];
1723
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 }
1734#endif
1735#if defined(CONFIG_ARCH_OMAP2)
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
1748 /*
1749 * On 2430 & 3430 GPIO 5 uses CORE L4 ICLK
1750 */
1751#if defined(CONFIG_ARCH_OMAP2430)
1752 if (cpu_is_omap2430()) {
1753 gpio5_ick = clk_get(NULL, "gpio5_ick");
1754 if (IS_ERR(gpio5_ick))
1755 printk("Could not get gpio5_ick\n");
1756 else
1757 clk_enable(gpio5_ick);
1758 gpio5_fck = clk_get(NULL, "gpio5_fck");
1759 if (IS_ERR(gpio5_fck))
1760 printk("Could not get gpio5_fck\n");
1761 else
1762 clk_enable(gpio5_fck);
1763 }
1764#endif
1765 }
1766#endif
1767
1768#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
1769 if (cpu_is_omap34xx() || cpu_is_omap44xx()) {
1770 for (i = 0; i < OMAP34XX_NR_GPIOS; i++) {
1771 sprintf(clk_name, "gpio%d_ick", i + 1);
1772 gpio_iclks[i] = clk_get(NULL, clk_name);
1773 if (IS_ERR(gpio_iclks[i]))
1774 printk(KERN_ERR "Could not get %s\n", clk_name);
1775 else
1776 clk_enable(gpio_iclks[i]);
1777 }
1778 }
1779#endif
1780
1781
1782#ifdef CONFIG_ARCH_OMAP15XX
1783 if (cpu_is_omap15xx()) {
1784 gpio_bank_count = 2;
1785 gpio_bank = gpio_bank_1510;
1786 bank_size = SZ_2K;
1787 }
1788#endif
1789#if defined(CONFIG_ARCH_OMAP16XX)
1790 if (cpu_is_omap16xx()) {
1791 gpio_bank_count = 5;
1792 gpio_bank = gpio_bank_1610;
1793 bank_size = SZ_2K;
1794 }
1795#endif
1796#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
1797 if (cpu_is_omap7xx()) {
1798 gpio_bank_count = 7;
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
1813#ifdef CONFIG_ARCH_OMAP3
1814 if (cpu_is_omap34xx()) {
1815 gpio_bank_count = OMAP34XX_NR_GPIOS;
1816 gpio_bank = gpio_bank_34xx;
1817 }
1818#endif
1819#ifdef CONFIG_ARCH_OMAP4
1820 if (cpu_is_omap44xx()) {
1821 gpio_bank_count = OMAP34XX_NR_GPIOS;
1822 gpio_bank = gpio_bank_44xx;
1823 }
1824#endif
1825 for (i = 0; i < gpio_bank_count; i++) {
1826 int j, gpio_count = 16;
1827
1828 bank = &gpio_bank[i];
1829 spin_lock_init(&bank->lock);
1830
1831 /* Static mapping, never released */
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
1838 if (bank_is_mpuio(bank))
1839 __raw_writew(0xffff, bank->base + OMAP_MPUIO_GPIO_MASKIT);
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
1853 gpio_count = 32; /* 7xx has 32-bit GPIOs */
1854 }
1855
1856#ifdef CONFIG_ARCH_OMAP2PLUS
1857 if ((bank->method == METHOD_GPIO_24XX) ||
1858 (bank->method == METHOD_GPIO_44XX)) {
1859 static const u32 non_wakeup_gpios[] = {
1860 0xe203ffc0, 0x08700040
1861 };
1862
1863 if (cpu_is_omap44xx()) {
1864 __raw_writel(0xffffffff, bank->base +
1865 OMAP4_GPIO_IRQSTATUSCLR0);
1866 __raw_writew(0x0015, bank->base +
1867 OMAP4_GPIO_SYSCONFIG);
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
1899 bank->mod_usage = 0;
1900 /* REVISIT eventually switch from OMAP-specific gpio structs
1901 * over to the generic ones
1902 */
1903 bank->chip.request = omap_gpio_request;
1904 bank->chip.free = omap_gpio_free;
1905 bank->chip.direction_input = gpio_input;
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
1924 gpiochip_add(&bank->chip);
1925
1926 for (j = bank->virtual_irq_start;
1927 j < bank->virtual_irq_start + gpio_count; j++) {
1928 lockdep_set_class(&irq_desc[j].lock, &gpio_lock_class);
1929 set_irq_chip_data(j, bank);
1930 if (bank_is_mpuio(bank))
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 }
1947
1948 /* Enable system clock for GPIO module.
1949 * The CAM_CLK_CTRL *is* really the right place. */
1950 if (cpu_is_omap16xx())
1951 omap_writel(omap_readl(ULPD_CAM_CLK_CTRL) | 0x04, ULPD_CAM_CLK_CTRL);
1952
1953 /* Enable autoidle for the OCP interface */
1954 if (cpu_is_omap24xx())
1955 omap_writel(1 << 0, 0x48019010);
1956 if (cpu_is_omap34xx())
1957 omap_writel(1 << 0, 0x48306814);
1958
1959 omap_gpio_show_rev();
1960
1961 return 0;
1962}
1963
1964#if defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP2PLUS)
1965static int omap_gpio_suspend(struct sys_device *dev, pm_message_t mesg)
1966{
1967 int i;
1968
1969 if (!cpu_class_is_omap2() && !cpu_is_omap16xx())
1970 return 0;
1971
1972 for (i = 0; i < gpio_bank_count; i++) {
1973 struct gpio_bank *bank = &gpio_bank[i];
1974 void __iomem *wake_status;
1975 void __iomem *wake_clear;
1976 void __iomem *wake_set;
1977 unsigned long flags;
1978
1979 switch (bank->method) {
1980#ifdef CONFIG_ARCH_OMAP16XX
1981 case METHOD_GPIO_1610:
1982 wake_status = bank->base + OMAP1610_GPIO_WAKEUPENABLE;
1983 wake_clear = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA;
1984 wake_set = bank->base + OMAP1610_GPIO_SET_WAKEUPENA;
1985 break;
1986#endif
1987#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
1988 case METHOD_GPIO_24XX:
1989 wake_status = bank->base + OMAP24XX_GPIO_WAKE_EN;
1990 wake_clear = bank->base + OMAP24XX_GPIO_CLEARWKUENA;
1991 wake_set = bank->base + OMAP24XX_GPIO_SETWKUENA;
1992 break;
1993#endif
1994#ifdef CONFIG_ARCH_OMAP4
1995 case METHOD_GPIO_44XX:
1996 wake_status = bank->base + OMAP4_GPIO_IRQWAKEN0;
1997 wake_clear = bank->base + OMAP4_GPIO_IRQWAKEN0;
1998 wake_set = bank->base + OMAP4_GPIO_IRQWAKEN0;
1999 break;
2000#endif
2001 default:
2002 continue;
2003 }
2004
2005 spin_lock_irqsave(&bank->lock, flags);
2006 bank->saved_wakeup = __raw_readl(wake_status);
2007 __raw_writel(0xffffffff, wake_clear);
2008 __raw_writel(bank->suspend_wakeup, wake_set);
2009 spin_unlock_irqrestore(&bank->lock, flags);
2010 }
2011
2012 return 0;
2013}
2014
2015static int omap_gpio_resume(struct sys_device *dev)
2016{
2017 int i;
2018
2019 if (!cpu_class_is_omap2() && !cpu_is_omap16xx())
2020 return 0;
2021
2022 for (i = 0; i < gpio_bank_count; i++) {
2023 struct gpio_bank *bank = &gpio_bank[i];
2024 void __iomem *wake_clear;
2025 void __iomem *wake_set;
2026 unsigned long flags;
2027
2028 switch (bank->method) {
2029#ifdef CONFIG_ARCH_OMAP16XX
2030 case METHOD_GPIO_1610:
2031 wake_clear = bank->base + OMAP1610_GPIO_CLEAR_WAKEUPENA;
2032 wake_set = bank->base + OMAP1610_GPIO_SET_WAKEUPENA;
2033 break;
2034#endif
2035#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
2036 case METHOD_GPIO_24XX:
2037 wake_clear = bank->base + OMAP24XX_GPIO_CLEARWKUENA;
2038 wake_set = bank->base + OMAP24XX_GPIO_SETWKUENA;
2039 break;
2040#endif
2041#ifdef CONFIG_ARCH_OMAP4
2042 case METHOD_GPIO_44XX:
2043 wake_clear = bank->base + OMAP4_GPIO_IRQWAKEN0;
2044 wake_set = bank->base + OMAP4_GPIO_IRQWAKEN0;
2045 break;
2046#endif
2047 default:
2048 continue;
2049 }
2050
2051 spin_lock_irqsave(&bank->lock, flags);
2052 __raw_writel(0xffffffff, wake_clear);
2053 __raw_writel(bank->saved_wakeup, wake_set);
2054 spin_unlock_irqrestore(&bank->lock, flags);
2055 }
2056
2057 return 0;
2058}
2059
2060static struct sysdev_class omap_gpio_sysclass = {
2061 .name = "gpio",
2062 .suspend = omap_gpio_suspend,
2063 .resume = omap_gpio_resume,
2064};
2065
2066static struct sys_device omap_gpio_device = {
2067 .id = 0,
2068 .cls = &omap_gpio_sysclass,
2069};
2070
2071#endif
2072
2073#ifdef CONFIG_ARCH_OMAP2PLUS
2074
2075static int workaround_enabled;
2076
2077void omap2_gpio_prepare_for_idle(int power_state)
2078{
2079 int i, c = 0;
2080 int min = 0;
2081
2082 if (cpu_is_omap34xx())
2083 min = 1;
2084
2085 for (i = min; i < gpio_bank_count; i++) {
2086 struct gpio_bank *bank = &gpio_bank[i];
2087 u32 l1, l2;
2088
2089 if (bank->dbck_enable_mask)
2090 clk_disable(bank->dbck);
2091
2092 if (power_state > PWRDM_POWER_OFF)
2093 continue;
2094
2095 /* If going to OFF, remove triggering for all
2096 * non-wakeup GPIOs. Otherwise spurious IRQs will be
2097 * generated. See OMAP2420 Errata item 1.101. */
2098 if (!(bank->enabled_non_wakeup_gpios))
2099 continue;
2100
2101 if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
2102 bank->saved_datain = __raw_readl(bank->base +
2103 OMAP24XX_GPIO_DATAIN);
2104 l1 = __raw_readl(bank->base +
2105 OMAP24XX_GPIO_FALLINGDETECT);
2106 l2 = __raw_readl(bank->base +
2107 OMAP24XX_GPIO_RISINGDETECT);
2108 }
2109
2110 if (cpu_is_omap44xx()) {
2111 bank->saved_datain = __raw_readl(bank->base +
2112 OMAP4_GPIO_DATAIN);
2113 l1 = __raw_readl(bank->base +
2114 OMAP4_GPIO_FALLINGDETECT);
2115 l2 = __raw_readl(bank->base +
2116 OMAP4_GPIO_RISINGDETECT);
2117 }
2118
2119 bank->saved_fallingdetect = l1;
2120 bank->saved_risingdetect = l2;
2121 l1 &= ~bank->enabled_non_wakeup_gpios;
2122 l2 &= ~bank->enabled_non_wakeup_gpios;
2123
2124 if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
2125 __raw_writel(l1, bank->base +
2126 OMAP24XX_GPIO_FALLINGDETECT);
2127 __raw_writel(l2, bank->base +
2128 OMAP24XX_GPIO_RISINGDETECT);
2129 }
2130
2131 if (cpu_is_omap44xx()) {
2132 __raw_writel(l1, bank->base + OMAP4_GPIO_FALLINGDETECT);
2133 __raw_writel(l2, bank->base + OMAP4_GPIO_RISINGDETECT);
2134 }
2135
2136 c++;
2137 }
2138 if (!c) {
2139 workaround_enabled = 0;
2140 return;
2141 }
2142 workaround_enabled = 1;
2143}
2144
2145void omap2_gpio_resume_after_idle(void)
2146{
2147 int i;
2148 int min = 0;
2149
2150 if (cpu_is_omap34xx())
2151 min = 1;
2152 for (i = min; i < gpio_bank_count; i++) {
2153 struct gpio_bank *bank = &gpio_bank[i];
2154 u32 l, gen, gen0, gen1;
2155
2156 if (bank->dbck_enable_mask)
2157 clk_enable(bank->dbck);
2158
2159 if (!workaround_enabled)
2160 continue;
2161
2162 if (!(bank->enabled_non_wakeup_gpios))
2163 continue;
2164
2165 if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
2166 __raw_writel(bank->saved_fallingdetect,
2167 bank->base + OMAP24XX_GPIO_FALLINGDETECT);
2168 __raw_writel(bank->saved_risingdetect,
2169 bank->base + OMAP24XX_GPIO_RISINGDETECT);
2170 l = __raw_readl(bank->base + OMAP24XX_GPIO_DATAIN);
2171 }
2172
2173 if (cpu_is_omap44xx()) {
2174 __raw_writel(bank->saved_fallingdetect,
2175 bank->base + OMAP4_GPIO_FALLINGDETECT);
2176 __raw_writel(bank->saved_risingdetect,
2177 bank->base + OMAP4_GPIO_RISINGDETECT);
2178 l = __raw_readl(bank->base + OMAP4_GPIO_DATAIN);
2179 }
2180
2181 /* Check if any of the non-wakeup interrupt GPIOs have changed
2182 * state. If so, generate an IRQ by software. This is
2183 * horribly racy, but it's the best we can do to work around
2184 * this silicon bug. */
2185 l ^= bank->saved_datain;
2186 l &= bank->enabled_non_wakeup_gpios;
2187
2188 /*
2189 * No need to generate IRQs for the rising edge for gpio IRQs
2190 * configured with falling edge only; and vice versa.
2191 */
2192 gen0 = l & bank->saved_fallingdetect;
2193 gen0 &= bank->saved_datain;
2194
2195 gen1 = l & bank->saved_risingdetect;
2196 gen1 &= ~(bank->saved_datain);
2197
2198 /* FIXME: Consider GPIO IRQs with level detections properly! */
2199 gen = l & (~(bank->saved_fallingdetect) &
2200 ~(bank->saved_risingdetect));
2201 /* Consider all GPIO IRQs needed to be updated */
2202 gen |= gen0 | gen1;
2203
2204 if (gen) {
2205 u32 old0, old1;
2206
2207 if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
2208 old0 = __raw_readl(bank->base +
2209 OMAP24XX_GPIO_LEVELDETECT0);
2210 old1 = __raw_readl(bank->base +
2211 OMAP24XX_GPIO_LEVELDETECT1);
2212 __raw_writel(old0 | gen, bank->base +
2213 OMAP24XX_GPIO_LEVELDETECT0);
2214 __raw_writel(old1 | gen, bank->base +
2215 OMAP24XX_GPIO_LEVELDETECT1);
2216 __raw_writel(old0, bank->base +
2217 OMAP24XX_GPIO_LEVELDETECT0);
2218 __raw_writel(old1, bank->base +
2219 OMAP24XX_GPIO_LEVELDETECT1);
2220 }
2221
2222 if (cpu_is_omap44xx()) {
2223 old0 = __raw_readl(bank->base +
2224 OMAP4_GPIO_LEVELDETECT0);
2225 old1 = __raw_readl(bank->base +
2226 OMAP4_GPIO_LEVELDETECT1);
2227 __raw_writel(old0 | l, bank->base +
2228 OMAP4_GPIO_LEVELDETECT0);
2229 __raw_writel(old1 | l, bank->base +
2230 OMAP4_GPIO_LEVELDETECT1);
2231 __raw_writel(old0, bank->base +
2232 OMAP4_GPIO_LEVELDETECT0);
2233 __raw_writel(old1, bank->base +
2234 OMAP4_GPIO_LEVELDETECT1);
2235 }
2236 }
2237 }
2238
2239}
2240
2241#endif
2242
2243#ifdef CONFIG_ARCH_OMAP3
2244/* save the registers of bank 2-6 */
2245void omap_gpio_save_context(void)
2246{
2247 int i;
2248
2249 /* saving banks from 2-6 only since GPIO1 is in WKUP */
2250 for (i = 1; i < gpio_bank_count; i++) {
2251 struct gpio_bank *bank = &gpio_bank[i];
2252 gpio_context[i].sysconfig =
2253 __raw_readl(bank->base + OMAP24XX_GPIO_SYSCONFIG);
2254 gpio_context[i].irqenable1 =
2255 __raw_readl(bank->base + OMAP24XX_GPIO_IRQENABLE1);
2256 gpio_context[i].irqenable2 =
2257 __raw_readl(bank->base + OMAP24XX_GPIO_IRQENABLE2);
2258 gpio_context[i].wake_en =
2259 __raw_readl(bank->base + OMAP24XX_GPIO_WAKE_EN);
2260 gpio_context[i].ctrl =
2261 __raw_readl(bank->base + OMAP24XX_GPIO_CTRL);
2262 gpio_context[i].oe =
2263 __raw_readl(bank->base + OMAP24XX_GPIO_OE);
2264 gpio_context[i].leveldetect0 =
2265 __raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT0);
2266 gpio_context[i].leveldetect1 =
2267 __raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT1);
2268 gpio_context[i].risingdetect =
2269 __raw_readl(bank->base + OMAP24XX_GPIO_RISINGDETECT);
2270 gpio_context[i].fallingdetect =
2271 __raw_readl(bank->base + OMAP24XX_GPIO_FALLINGDETECT);
2272 gpio_context[i].dataout =
2273 __raw_readl(bank->base + OMAP24XX_GPIO_DATAOUT);
2274 }
2275}
2276
2277/* restore the required registers of bank 2-6 */
2278void omap_gpio_restore_context(void)
2279{
2280 int i;
2281
2282 for (i = 1; i < gpio_bank_count; i++) {
2283 struct gpio_bank *bank = &gpio_bank[i];
2284 __raw_writel(gpio_context[i].sysconfig,
2285 bank->base + OMAP24XX_GPIO_SYSCONFIG);
2286 __raw_writel(gpio_context[i].irqenable1,
2287 bank->base + OMAP24XX_GPIO_IRQENABLE1);
2288 __raw_writel(gpio_context[i].irqenable2,
2289 bank->base + OMAP24XX_GPIO_IRQENABLE2);
2290 __raw_writel(gpio_context[i].wake_en,
2291 bank->base + OMAP24XX_GPIO_WAKE_EN);
2292 __raw_writel(gpio_context[i].ctrl,
2293 bank->base + OMAP24XX_GPIO_CTRL);
2294 __raw_writel(gpio_context[i].oe,
2295 bank->base + OMAP24XX_GPIO_OE);
2296 __raw_writel(gpio_context[i].leveldetect0,
2297 bank->base + OMAP24XX_GPIO_LEVELDETECT0);
2298 __raw_writel(gpio_context[i].leveldetect1,
2299 bank->base + OMAP24XX_GPIO_LEVELDETECT1);
2300 __raw_writel(gpio_context[i].risingdetect,
2301 bank->base + OMAP24XX_GPIO_RISINGDETECT);
2302 __raw_writel(gpio_context[i].fallingdetect,
2303 bank->base + OMAP24XX_GPIO_FALLINGDETECT);
2304 __raw_writel(gpio_context[i].dataout,
2305 bank->base + OMAP24XX_GPIO_DATAOUT);
2306 }
2307}
2308#endif
2309
2310/*
2311 * This may get called early from board specific init
2312 * for boards that have interrupts routed via FPGA.
2313 */
2314int __init omap_gpio_init(void)
2315{
2316 if (!initialized)
2317 return _omap_gpio_init();
2318 else
2319 return 0;
2320}
2321
2322static int __init omap_gpio_sysinit(void)
2323{
2324 int ret = 0;
2325
2326 if (!initialized)
2327 ret = _omap_gpio_init();
2328
2329 mpuio_init();
2330
2331#if defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP2PLUS)
2332 if (cpu_is_omap16xx() || cpu_class_is_omap2()) {
2333 if (ret == 0) {
2334 ret = sysdev_class_register(&omap_gpio_sysclass);
2335 if (ret == 0)
2336 ret = sysdev_register(&omap_gpio_device);
2337 }
2338 }
2339#endif
2340
2341 return ret;
2342}
2343
2344arch_initcall(omap_gpio_sysinit);
diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index a5ce4f0aad35..3341ca4703e9 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,26 @@ 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
115#ifdef CONFIG_ARCH_OMAP2PLUS
141/* 116/*
142 * XXX This function is a temporary compatibility wrapper - only 117 * XXX This function is a temporary compatibility wrapper - only
143 * needed until the I2C driver can be converted to call 118 * needed until the I2C driver can be converted to call
@@ -148,52 +123,63 @@ 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); 123 omap_pm_set_max_mpu_wakeup_lat(dev, t);
149} 124}
150 125
151static inline int omap2_i2c_add_bus(struct platform_device *pdev, int bus_id) 126static struct omap_device_pm_latency omap_i2c_latency[] = {
152{ 127 [0] = {
153 struct resource *res; 128 .deactivate_func = omap_device_idle_hwmods,
154 resource_size_t *irq; 129 .activate_func = omap_device_enable_hwmods,
130 .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
131 },
132};
155 133
156 res = pdev->resource; 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/board.h b/arch/arm/plat-omap/include/plat/board.h
index 3cf4fa25ab3d..97126dfd2888 100644
--- a/arch/arm/plat-omap/include/plat/board.h
+++ b/arch/arm/plat-omap/include/plat/board.h
@@ -151,14 +151,14 @@ struct omap_board_config_kernel {
151 const void *data; 151 const void *data;
152}; 152};
153 153
154extern const void *__omap_get_config(u16 tag, size_t len, int nr); 154extern const void *__init __omap_get_config(u16 tag, size_t len, int nr);
155 155
156#define omap_get_config(tag, type) \ 156#define omap_get_config(tag, type) \
157 ((const type *) __omap_get_config((tag), sizeof(type), 0)) 157 ((const type *) __omap_get_config((tag), sizeof(type), 0))
158#define omap_get_nr_config(tag, type, nr) \ 158#define omap_get_nr_config(tag, type, nr) \
159 ((const type *) __omap_get_config((tag), sizeof(type), (nr))) 159 ((const type *) __omap_get_config((tag), sizeof(type), (nr)))
160 160
161extern const void *omap_get_var_config(u16 tag, size_t *len); 161extern const void *__init omap_get_var_config(u16 tag, size_t *len);
162 162
163extern struct omap_board_config_kernel *omap_board_config; 163extern struct omap_board_config_kernel *omap_board_config;
164extern int omap_board_config_size; 164extern int omap_board_config_size;
diff --git a/arch/arm/plat-omap/include/plat/clkdev_omap.h b/arch/arm/plat-omap/include/plat/clkdev_omap.h
index bb937f3fabed..f1899a3e4174 100644
--- a/arch/arm/plat-omap/include/plat/clkdev_omap.h
+++ b/arch/arm/plat-omap/include/plat/clkdev_omap.h
@@ -8,7 +8,7 @@
8#ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H 8#ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H
9#define __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H 9#define __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H
10 10
11#include <asm/clkdev.h> 11#include <linux/clkdev.h>
12 12
13struct omap_clk { 13struct omap_clk {
14 u16 cpu; 14 u16 cpu;
@@ -31,18 +31,19 @@ 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 */ 41#define CK_TI816X (1 << 12)
42#define CK_443X (1 << 13)
43 42
44#define CK_AM35XX (CK_3505 | CK_3517) /* all Sitara AM35xx */
45 43
44#define CK_34XX (CK_3430ES1 | CK_3430ES2PLUS)
45#define CK_AM35XX (CK_3505 | CK_3517) /* all Sitara AM35xx */
46#define CK_3XXX (CK_34XX | CK_AM35XX | CK_36XX)
46 47
47 48
48#endif 49#endif
diff --git a/arch/arm/plat-omap/include/plat/clock.h b/arch/arm/plat-omap/include/plat/clock.h
index fef4696dcf67..006e599c6613 100644
--- a/arch/arm/plat-omap/include/plat/clock.h
+++ b/arch/arm/plat-omap/include/plat/clock.h
@@ -25,6 +25,8 @@ struct clockdomain;
25 * @disable: fn ptr that enables the current clock in hardware 25 * @disable: fn ptr that enables the current clock in hardware
26 * @find_idlest: function returning the IDLEST register for the clock's IP blk 26 * @find_idlest: function returning the IDLEST register for the clock's IP blk
27 * @find_companion: function returning the "companion" clk reg for the clock 27 * @find_companion: function returning the "companion" clk reg for the clock
28 * @allow_idle: fn ptr that enables autoidle for the current clock in hardware
29 * @deny_idle: fn ptr that disables autoidle for the current clock in hardware
28 * 30 *
29 * A "companion" clk is an accompanying clock to the one being queried 31 * A "companion" clk is an accompanying clock to the one being queried
30 * that must be enabled for the IP module connected to the clock to 32 * that must be enabled for the IP module connected to the clock to
@@ -42,6 +44,8 @@ struct clkops {
42 u8 *, u8 *); 44 u8 *, u8 *);
43 void (*find_companion)(struct clk *, void __iomem **, 45 void (*find_companion)(struct clk *, void __iomem **,
44 u8 *); 46 u8 *);
47 void (*allow_idle)(struct clk *);
48 void (*deny_idle)(struct clk *);
45}; 49};
46 50
47#ifdef CONFIG_ARCH_OMAP2PLUS 51#ifdef CONFIG_ARCH_OMAP2PLUS
@@ -49,13 +53,19 @@ struct clkops {
49/* struct clksel_rate.flags possibilities */ 53/* struct clksel_rate.flags possibilities */
50#define RATE_IN_242X (1 << 0) 54#define RATE_IN_242X (1 << 0)
51#define RATE_IN_243X (1 << 1) 55#define RATE_IN_243X (1 << 1)
52#define RATE_IN_3XXX (1 << 2) /* rates common to all OMAP3 */ 56#define RATE_IN_3430ES1 (1 << 2) /* 3430ES1 rates only */
53#define RATE_IN_3430ES2 (1 << 3) /* 3430ES2 rates only */ 57#define RATE_IN_3430ES2PLUS (1 << 3) /* 3430 ES >= 2 rates only */
54#define RATE_IN_36XX (1 << 4) 58#define RATE_IN_36XX (1 << 4)
55#define RATE_IN_4430 (1 << 5) 59#define RATE_IN_4430 (1 << 5)
60#define RATE_IN_TI816X (1 << 6)
56 61
57#define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X) 62#define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X)
58#define RATE_IN_3430ES2PLUS (RATE_IN_3430ES2 | RATE_IN_36XX) 63#define RATE_IN_34XX (RATE_IN_3430ES1 | RATE_IN_3430ES2PLUS)
64#define RATE_IN_3XXX (RATE_IN_34XX | RATE_IN_36XX)
65
66/* RATE_IN_3430ES2PLUS_36XX includes 34xx/35xx with ES >=2, and all 36xx/37xx */
67#define RATE_IN_3430ES2PLUS_36XX (RATE_IN_3430ES2PLUS | RATE_IN_36XX)
68
59 69
60/** 70/**
61 * struct clksel_rate - register bitfield values corresponding to clk divisors 71 * struct clksel_rate - register bitfield values corresponding to clk divisors
@@ -99,7 +109,6 @@ struct clksel {
99 * @clk_ref: struct clk pointer to the clock's reference clock input 109 * @clk_ref: struct clk pointer to the clock's reference clock input
100 * @control_reg: register containing the DPLL mode bitfield 110 * @control_reg: register containing the DPLL mode bitfield
101 * @enable_mask: mask of the DPLL mode bitfield in @control_reg 111 * @enable_mask: mask of the DPLL mode bitfield in @control_reg
102 * @rate_tolerance: maximum variance allowed from target rate (in Hz)
103 * @last_rounded_rate: cache of the last rate result of omap2_dpll_round_rate() 112 * @last_rounded_rate: cache of the last rate result of omap2_dpll_round_rate()
104 * @last_rounded_m: cache of the last M result of omap2_dpll_round_rate() 113 * @last_rounded_m: cache of the last M result of omap2_dpll_round_rate()
105 * @max_multiplier: maximum valid non-bypass multiplier value (actual) 114 * @max_multiplier: maximum valid non-bypass multiplier value (actual)
@@ -119,19 +128,15 @@ struct clksel {
119 * 128 *
120 * Possible values for @flags: 129 * Possible values for @flags:
121 * DPLL_J_TYPE: "J-type DPLL" (only some 36xx, 4xxx DPLLs) 130 * 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) 131 *
123
124 * @freqsel_mask is only used on the OMAP34xx family and AM35xx. 132 * @freqsel_mask is only used on the OMAP34xx family and AM35xx.
125 * 133 *
126 * XXX Some DPLLs have multiple bypass inputs, so it's not technically 134 * XXX Some DPLLs have multiple bypass inputs, so it's not technically
127 * correct to only have one @clk_bypass pointer. 135 * correct to only have one @clk_bypass pointer.
128 * 136 *
129 * XXX @rate_tolerance should probably be deprecated - currently there
130 * don't seem to be any usecases for DPLL rounding that is not exact.
131 *
132 * XXX The runtime-variable fields (@last_rounded_rate, @last_rounded_m, 137 * XXX The runtime-variable fields (@last_rounded_rate, @last_rounded_m,
133 * @last_rounded_n) should be separated from the runtime-fixed fields 138 * @last_rounded_n) should be separated from the runtime-fixed fields
134 * and placed into a differenct structure, so that the runtime-fixed data 139 * and placed into a different structure, so that the runtime-fixed data
135 * can be placed into read-only space. 140 * can be placed into read-only space.
136 */ 141 */
137struct dpll_data { 142struct dpll_data {
@@ -142,7 +147,6 @@ struct dpll_data {
142 struct clk *clk_ref; 147 struct clk *clk_ref;
143 void __iomem *control_reg; 148 void __iomem *control_reg;
144 u32 enable_mask; 149 u32 enable_mask;
145 unsigned int rate_tolerance;
146 unsigned long last_rounded_rate; 150 unsigned long last_rounded_rate;
147 u16 last_rounded_m; 151 u16 last_rounded_m;
148 u16 max_multiplier; 152 u16 max_multiplier;
@@ -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;
@@ -165,12 +171,24 @@ struct dpll_data {
165 171
166#endif 172#endif
167 173
168/* struct clk.flags possibilities */ 174/*
175 * struct clk.flags possibilities
176 *
177 * XXX document the rest of the clock flags here
178 *
179 * CLOCK_CLKOUTX2: (OMAP4 only) DPLL CLKOUT and CLKOUTX2 GATE_CTRL
180 * bits share the same register. This flag allows the
181 * omap4_dpllmx*() code to determine which GATE_CTRL bit field
182 * should be used. This is a temporary solution - a better approach
183 * would be to associate clock type-specific data with the clock,
184 * similar to the struct dpll_data approach.
185 */
169#define ENABLE_REG_32BIT (1 << 0) /* Use 32-bit access */ 186#define ENABLE_REG_32BIT (1 << 0) /* Use 32-bit access */
170#define CLOCK_IDLE_CONTROL (1 << 1) 187#define CLOCK_IDLE_CONTROL (1 << 1)
171#define CLOCK_NO_IDLE_PARENT (1 << 2) 188#define CLOCK_NO_IDLE_PARENT (1 << 2)
172#define ENABLE_ON_INIT (1 << 3) /* Enable upon framework init */ 189#define ENABLE_ON_INIT (1 << 3) /* Enable upon framework init */
173#define INVERT_ENABLE (1 << 4) /* 0 enables, 1 disables */ 190#define INVERT_ENABLE (1 << 4) /* 0 enables, 1 disables */
191#define CLOCK_CLKOUTX2 (1 << 5)
174 192
175/** 193/**
176 * struct clk - OMAP struct clk 194 * struct clk - OMAP struct clk
@@ -286,6 +304,8 @@ extern void clk_init_cpufreq_table(struct cpufreq_frequency_table **table);
286extern void clk_exit_cpufreq_table(struct cpufreq_frequency_table **table); 304extern void clk_exit_cpufreq_table(struct cpufreq_frequency_table **table);
287#endif 305#endif
288extern struct clk *omap_clk_get_by_name(const char *name); 306extern struct clk *omap_clk_get_by_name(const char *name);
307extern int omap_clk_enable_autoidle_all(void);
308extern int omap_clk_disable_autoidle_all(void);
289 309
290extern const struct clkops clkops_null; 310extern const struct clkops clkops_null;
291 311
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 9776b41ad76f..5288130be96e 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -27,12 +27,17 @@
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;
33 35
34extern void omap_map_common_io(void); 36extern void omap_map_common_io(void);
35extern struct sys_timer omap_timer; 37extern struct sys_timer omap_timer;
38extern bool omap_32k_timer_init(void);
39extern int __init omap_init_clocksource_32k(void);
40extern unsigned long long notrace omap_32k_sched_clock(void);
36 41
37extern void omap_reserve(void); 42extern void omap_reserve(void);
38 43
@@ -47,26 +52,23 @@ struct omap_globals {
47 unsigned long sdrc; /* SDRAM Controller */ 52 unsigned long sdrc; /* SDRAM Controller */
48 unsigned long sms; /* SDRAM Memory Scheduler */ 53 unsigned long sms; /* SDRAM Memory Scheduler */
49 unsigned long ctrl; /* System Control Module */ 54 unsigned long ctrl; /* System Control Module */
55 unsigned long ctrl_pad; /* PAD Control Module */
50 unsigned long prm; /* Power and Reset Management */ 56 unsigned long prm; /* Power and Reset Management */
51 unsigned long cm; /* Clock Management */ 57 unsigned long cm; /* Clock Management */
52 unsigned long cm2; 58 unsigned long cm2;
53 unsigned long uart1_phys;
54 unsigned long uart2_phys;
55 unsigned long uart3_phys;
56 unsigned long uart4_phys;
57}; 59};
58 60
59void omap2_set_globals_242x(void); 61void omap2_set_globals_242x(void);
60void omap2_set_globals_243x(void); 62void omap2_set_globals_243x(void);
61void omap2_set_globals_3xxx(void); 63void omap2_set_globals_3xxx(void);
62void omap2_set_globals_443x(void); 64void omap2_set_globals_443x(void);
65void omap2_set_globals_ti816x(void);
63 66
64/* These get called from omap2_set_globals_xxxx(), do not call these */ 67/* These get called from omap2_set_globals_xxxx(), do not call these */
65void omap2_set_globals_tap(struct omap_globals *); 68void omap2_set_globals_tap(struct omap_globals *);
66void omap2_set_globals_sdrc(struct omap_globals *); 69void omap2_set_globals_sdrc(struct omap_globals *);
67void omap2_set_globals_control(struct omap_globals *); 70void omap2_set_globals_control(struct omap_globals *);
68void omap2_set_globals_prcm(struct omap_globals *); 71void omap2_set_globals_prcm(struct omap_globals *);
69void omap2_set_globals_uart(struct omap_globals *);
70 72
71void omap3_map_io(void); 73void omap3_map_io(void);
72 74
@@ -91,7 +93,8 @@ void omap3_map_io(void);
91}) 93})
92 94
93extern struct device *omap2_get_mpuss_device(void); 95extern struct device *omap2_get_mpuss_device(void);
94extern struct device *omap2_get_dsp_device(void); 96extern struct device *omap2_get_iva_device(void);
95extern struct device *omap2_get_l3_device(void); 97extern struct device *omap2_get_l3_device(void);
98extern struct device *omap4_get_dsp_device(void);
96 99
97#endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */ 100#endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */
diff --git a/arch/arm/plat-omap/include/plat/control.h b/arch/arm/plat-omap/include/plat/control.h
deleted file mode 100644
index 131bf405c2f6..000000000000
--- a/arch/arm/plat-omap/include/plat/control.h
+++ /dev/null
@@ -1,381 +0,0 @@
1/*
2 * arch/arm/plat-omap/include/mach/control.h
3 *
4 * OMAP2/3/4 System Control Module definitions
5 *
6 * Copyright (C) 2007-2009 Texas Instruments, Inc.
7 * Copyright (C) 2007-2008 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 as published by
13 * the Free Software Foundation.
14 */
15
16#ifndef __ASM_ARCH_CONTROL_H
17#define __ASM_ARCH_CONTROL_H
18
19#include <mach/io.h>
20
21#ifndef __ASSEMBLY__
22#define OMAP242X_CTRL_REGADDR(reg) \
23 OMAP2_L4_IO_ADDRESS(OMAP242X_CTRL_BASE + (reg))
24#define OMAP243X_CTRL_REGADDR(reg) \
25 OMAP2_L4_IO_ADDRESS(OMAP243X_CTRL_BASE + (reg))
26#define OMAP343X_CTRL_REGADDR(reg) \
27 OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE + (reg))
28#else
29#define OMAP242X_CTRL_REGADDR(reg) \
30 OMAP2_L4_IO_ADDRESS(OMAP242X_CTRL_BASE + (reg))
31#define OMAP243X_CTRL_REGADDR(reg) \
32 OMAP2_L4_IO_ADDRESS(OMAP243X_CTRL_BASE + (reg))
33#define OMAP343X_CTRL_REGADDR(reg) \
34 OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE + (reg))
35#endif /* __ASSEMBLY__ */
36
37/*
38 * As elsewhere, the "OMAP2_" prefix indicates that the macro is valid for
39 * OMAP24XX and OMAP34XX.
40 */
41
42/* Control submodule offsets */
43
44#define OMAP2_CONTROL_INTERFACE 0x000
45#define OMAP2_CONTROL_PADCONFS 0x030
46#define OMAP2_CONTROL_GENERAL 0x270
47#define OMAP343X_CONTROL_MEM_WKUP 0x600
48#define OMAP343X_CONTROL_PADCONFS_WKUP 0xa00
49#define OMAP343X_CONTROL_GENERAL_WKUP 0xa60
50
51/* Control register offsets - read/write with omap_ctrl_{read,write}{bwl}() */
52
53#define OMAP2_CONTROL_SYSCONFIG (OMAP2_CONTROL_INTERFACE + 0x10)
54
55/* CONTROL_GENERAL register offsets common to OMAP2 & 3 */
56#define OMAP2_CONTROL_DEVCONF0 (OMAP2_CONTROL_GENERAL + 0x0004)
57#define OMAP2_CONTROL_MSUSPENDMUX_0 (OMAP2_CONTROL_GENERAL + 0x0020)
58#define OMAP2_CONTROL_MSUSPENDMUX_1 (OMAP2_CONTROL_GENERAL + 0x0024)
59#define OMAP2_CONTROL_MSUSPENDMUX_2 (OMAP2_CONTROL_GENERAL + 0x0028)
60#define OMAP2_CONTROL_MSUSPENDMUX_3 (OMAP2_CONTROL_GENERAL + 0x002c)
61#define OMAP2_CONTROL_MSUSPENDMUX_4 (OMAP2_CONTROL_GENERAL + 0x0030)
62#define OMAP2_CONTROL_MSUSPENDMUX_5 (OMAP2_CONTROL_GENERAL + 0x0034)
63#define OMAP2_CONTROL_SEC_CTRL (OMAP2_CONTROL_GENERAL + 0x0040)
64#define OMAP2_CONTROL_RPUB_KEY_H_0 (OMAP2_CONTROL_GENERAL + 0x0090)
65#define OMAP2_CONTROL_RPUB_KEY_H_1 (OMAP2_CONTROL_GENERAL + 0x0094)
66#define OMAP2_CONTROL_RPUB_KEY_H_2 (OMAP2_CONTROL_GENERAL + 0x0098)
67#define OMAP2_CONTROL_RPUB_KEY_H_3 (OMAP2_CONTROL_GENERAL + 0x009c)
68
69/* 242x-only CONTROL_GENERAL register offsets */
70#define OMAP242X_CONTROL_DEVCONF OMAP2_CONTROL_DEVCONF0 /* match TRM */
71#define OMAP242X_CONTROL_OCM_RAM_PERM (OMAP2_CONTROL_GENERAL + 0x0068)
72
73/* 243x-only CONTROL_GENERAL register offsets */
74/* CONTROL_IVA2_BOOT{ADDR,MOD} are at the same place on 343x - noted below */
75#define OMAP243X_CONTROL_DEVCONF1 (OMAP2_CONTROL_GENERAL + 0x0078)
76#define OMAP243X_CONTROL_CSIRXFE (OMAP2_CONTROL_GENERAL + 0x007c)
77#define OMAP243X_CONTROL_IVA2_BOOTADDR (OMAP2_CONTROL_GENERAL + 0x0190)
78#define OMAP243X_CONTROL_IVA2_BOOTMOD (OMAP2_CONTROL_GENERAL + 0x0194)
79#define OMAP243X_CONTROL_IVA2_GEMCFG (OMAP2_CONTROL_GENERAL + 0x0198)
80#define OMAP243X_CONTROL_PBIAS_LITE (OMAP2_CONTROL_GENERAL + 0x0230)
81
82/* 24xx-only CONTROL_GENERAL register offsets */
83#define OMAP24XX_CONTROL_DEBOBS (OMAP2_CONTROL_GENERAL + 0x0000)
84#define OMAP24XX_CONTROL_EMU_SUPPORT (OMAP2_CONTROL_GENERAL + 0x0008)
85#define OMAP24XX_CONTROL_SEC_TEST (OMAP2_CONTROL_GENERAL + 0x0044)
86#define OMAP24XX_CONTROL_PSA_CTRL (OMAP2_CONTROL_GENERAL + 0x0048)
87#define OMAP24XX_CONTROL_PSA_CMD (OMAP2_CONTROL_GENERAL + 0x004c)
88#define OMAP24XX_CONTROL_PSA_VALUE (OMAP2_CONTROL_GENERAL + 0x0050)
89#define OMAP24XX_CONTROL_SEC_EMU (OMAP2_CONTROL_GENERAL + 0x0060)
90#define OMAP24XX_CONTROL_SEC_TAP (OMAP2_CONTROL_GENERAL + 0x0064)
91#define OMAP24XX_CONTROL_OCM_PUB_RAM_ADD (OMAP2_CONTROL_GENERAL + 0x006c)
92#define OMAP24XX_CONTROL_EXT_SEC_RAM_START_ADD (OMAP2_CONTROL_GENERAL + 0x0070)
93#define OMAP24XX_CONTROL_EXT_SEC_RAM_STOP_ADD (OMAP2_CONTROL_GENERAL + 0x0074)
94#define OMAP24XX_CONTROL_SEC_STATUS (OMAP2_CONTROL_GENERAL + 0x0080)
95#define OMAP24XX_CONTROL_SEC_ERR_STATUS (OMAP2_CONTROL_GENERAL + 0x0084)
96#define OMAP24XX_CONTROL_STATUS (OMAP2_CONTROL_GENERAL + 0x0088)
97#define OMAP24XX_CONTROL_GENERAL_PURPOSE_STATUS (OMAP2_CONTROL_GENERAL + 0x008c)
98#define OMAP24XX_CONTROL_RAND_KEY_0 (OMAP2_CONTROL_GENERAL + 0x00a0)
99#define OMAP24XX_CONTROL_RAND_KEY_1 (OMAP2_CONTROL_GENERAL + 0x00a4)
100#define OMAP24XX_CONTROL_RAND_KEY_2 (OMAP2_CONTROL_GENERAL + 0x00a8)
101#define OMAP24XX_CONTROL_RAND_KEY_3 (OMAP2_CONTROL_GENERAL + 0x00ac)
102#define OMAP24XX_CONTROL_CUST_KEY_0 (OMAP2_CONTROL_GENERAL + 0x00b0)
103#define OMAP24XX_CONTROL_CUST_KEY_1 (OMAP2_CONTROL_GENERAL + 0x00b4)
104#define OMAP24XX_CONTROL_TEST_KEY_0 (OMAP2_CONTROL_GENERAL + 0x00c0)
105#define OMAP24XX_CONTROL_TEST_KEY_1 (OMAP2_CONTROL_GENERAL + 0x00c4)
106#define OMAP24XX_CONTROL_TEST_KEY_2 (OMAP2_CONTROL_GENERAL + 0x00c8)
107#define OMAP24XX_CONTROL_TEST_KEY_3 (OMAP2_CONTROL_GENERAL + 0x00cc)
108#define OMAP24XX_CONTROL_TEST_KEY_4 (OMAP2_CONTROL_GENERAL + 0x00d0)
109#define OMAP24XX_CONTROL_TEST_KEY_5 (OMAP2_CONTROL_GENERAL + 0x00d4)
110#define OMAP24XX_CONTROL_TEST_KEY_6 (OMAP2_CONTROL_GENERAL + 0x00d8)
111#define OMAP24XX_CONTROL_TEST_KEY_7 (OMAP2_CONTROL_GENERAL + 0x00dc)
112#define OMAP24XX_CONTROL_TEST_KEY_8 (OMAP2_CONTROL_GENERAL + 0x00e0)
113#define OMAP24XX_CONTROL_TEST_KEY_9 (OMAP2_CONTROL_GENERAL + 0x00e4)
114
115#define OMAP343X_CONTROL_PADCONF_SYSNIRQ (OMAP2_CONTROL_INTERFACE + 0x01b0)
116
117/* 34xx-only CONTROL_GENERAL register offsets */
118#define OMAP343X_CONTROL_PADCONF_OFF (OMAP2_CONTROL_GENERAL + 0x0000)
119#define OMAP343X_CONTROL_MEM_DFTRW0 (OMAP2_CONTROL_GENERAL + 0x0008)
120#define OMAP343X_CONTROL_MEM_DFTRW1 (OMAP2_CONTROL_GENERAL + 0x000c)
121#define OMAP343X_CONTROL_DEVCONF1 (OMAP2_CONTROL_GENERAL + 0x0068)
122#define OMAP343X_CONTROL_CSIRXFE (OMAP2_CONTROL_GENERAL + 0x006c)
123#define OMAP343X_CONTROL_SEC_STATUS (OMAP2_CONTROL_GENERAL + 0x0070)
124#define OMAP343X_CONTROL_SEC_ERR_STATUS (OMAP2_CONTROL_GENERAL + 0x0074)
125#define OMAP343X_CONTROL_SEC_ERR_STATUS_DEBUG (OMAP2_CONTROL_GENERAL + 0x0078)
126#define OMAP343X_CONTROL_STATUS (OMAP2_CONTROL_GENERAL + 0x0080)
127#define OMAP343X_CONTROL_GENERAL_PURPOSE_STATUS (OMAP2_CONTROL_GENERAL + 0x0084)
128#define OMAP343X_CONTROL_RPUB_KEY_H_4 (OMAP2_CONTROL_GENERAL + 0x00a0)
129#define OMAP343X_CONTROL_RAND_KEY_0 (OMAP2_CONTROL_GENERAL + 0x00a8)
130#define OMAP343X_CONTROL_RAND_KEY_1 (OMAP2_CONTROL_GENERAL + 0x00ac)
131#define OMAP343X_CONTROL_RAND_KEY_2 (OMAP2_CONTROL_GENERAL + 0x00b0)
132#define OMAP343X_CONTROL_RAND_KEY_3 (OMAP2_CONTROL_GENERAL + 0x00b4)
133#define OMAP343X_CONTROL_TEST_KEY_0 (OMAP2_CONTROL_GENERAL + 0x00c8)
134#define OMAP343X_CONTROL_TEST_KEY_1 (OMAP2_CONTROL_GENERAL + 0x00cc)
135#define OMAP343X_CONTROL_TEST_KEY_2 (OMAP2_CONTROL_GENERAL + 0x00d0)
136#define OMAP343X_CONTROL_TEST_KEY_3 (OMAP2_CONTROL_GENERAL + 0x00d4)
137#define OMAP343X_CONTROL_TEST_KEY_4 (OMAP2_CONTROL_GENERAL + 0x00d8)
138#define OMAP343X_CONTROL_TEST_KEY_5 (OMAP2_CONTROL_GENERAL + 0x00dc)
139#define OMAP343X_CONTROL_TEST_KEY_6 (OMAP2_CONTROL_GENERAL + 0x00e0)
140#define OMAP343X_CONTROL_TEST_KEY_7 (OMAP2_CONTROL_GENERAL + 0x00e4)
141#define OMAP343X_CONTROL_TEST_KEY_8 (OMAP2_CONTROL_GENERAL + 0x00e8)
142#define OMAP343X_CONTROL_TEST_KEY_9 (OMAP2_CONTROL_GENERAL + 0x00ec)
143#define OMAP343X_CONTROL_TEST_KEY_10 (OMAP2_CONTROL_GENERAL + 0x00f0)
144#define OMAP343X_CONTROL_TEST_KEY_11 (OMAP2_CONTROL_GENERAL + 0x00f4)
145#define OMAP343X_CONTROL_TEST_KEY_12 (OMAP2_CONTROL_GENERAL + 0x00f8)
146#define OMAP343X_CONTROL_TEST_KEY_13 (OMAP2_CONTROL_GENERAL + 0x00fc)
147#define OMAP343X_CONTROL_IVA2_BOOTADDR (OMAP2_CONTROL_GENERAL + 0x0190)
148#define OMAP343X_CONTROL_IVA2_BOOTMOD (OMAP2_CONTROL_GENERAL + 0x0194)
149#define OMAP343X_CONTROL_DEBOBS(i) (OMAP2_CONTROL_GENERAL + 0x01B0 \
150 + ((i) >> 1) * 4 + (!((i) & 1)) * 2)
151#define OMAP343X_CONTROL_PROG_IO0 (OMAP2_CONTROL_GENERAL + 0x01D4)
152#define OMAP343X_CONTROL_PROG_IO1 (OMAP2_CONTROL_GENERAL + 0x01D8)
153#define OMAP343X_CONTROL_DSS_DPLL_SPREADING (OMAP2_CONTROL_GENERAL + 0x01E0)
154#define OMAP343X_CONTROL_CORE_DPLL_SPREADING (OMAP2_CONTROL_GENERAL + 0x01E4)
155#define OMAP343X_CONTROL_PER_DPLL_SPREADING (OMAP2_CONTROL_GENERAL + 0x01E8)
156#define OMAP343X_CONTROL_USBHOST_DPLL_SPREADING (OMAP2_CONTROL_GENERAL + 0x01EC)
157#define OMAP343X_CONTROL_PBIAS_LITE (OMAP2_CONTROL_GENERAL + 0x02B0)
158#define OMAP343X_CONTROL_TEMP_SENSOR (OMAP2_CONTROL_GENERAL + 0x02B4)
159#define OMAP343X_CONTROL_SRAMLDO4 (OMAP2_CONTROL_GENERAL + 0x02B8)
160#define OMAP343X_CONTROL_SRAMLDO5 (OMAP2_CONTROL_GENERAL + 0x02C0)
161#define OMAP343X_CONTROL_CSI (OMAP2_CONTROL_GENERAL + 0x02C4)
162
163/* AM35XX only CONTROL_GENERAL register offsets */
164#define AM35XX_CONTROL_MSUSPENDMUX_6 (OMAP2_CONTROL_GENERAL + 0x0038)
165#define AM35XX_CONTROL_DEVCONF2 (OMAP2_CONTROL_GENERAL + 0x0310)
166#define AM35XX_CONTROL_DEVCONF3 (OMAP2_CONTROL_GENERAL + 0x0314)
167#define AM35XX_CONTROL_CBA_PRIORITY (OMAP2_CONTROL_GENERAL + 0x0320)
168#define AM35XX_CONTROL_LVL_INTR_CLEAR (OMAP2_CONTROL_GENERAL + 0x0324)
169#define AM35XX_CONTROL_IP_SW_RESET (OMAP2_CONTROL_GENERAL + 0x0328)
170#define AM35XX_CONTROL_IPSS_CLK_CTRL (OMAP2_CONTROL_GENERAL + 0x032C)
171
172/* 34xx PADCONF register offsets */
173#define OMAP343X_PADCONF_ETK(i) (OMAP2_CONTROL_PADCONFS + 0x5a8 + \
174 (i)*2)
175#define OMAP343X_PADCONF_ETK_CLK OMAP343X_PADCONF_ETK(0)
176#define OMAP343X_PADCONF_ETK_CTL OMAP343X_PADCONF_ETK(1)
177#define OMAP343X_PADCONF_ETK_D0 OMAP343X_PADCONF_ETK(2)
178#define OMAP343X_PADCONF_ETK_D1 OMAP343X_PADCONF_ETK(3)
179#define OMAP343X_PADCONF_ETK_D2 OMAP343X_PADCONF_ETK(4)
180#define OMAP343X_PADCONF_ETK_D3 OMAP343X_PADCONF_ETK(5)
181#define OMAP343X_PADCONF_ETK_D4 OMAP343X_PADCONF_ETK(6)
182#define OMAP343X_PADCONF_ETK_D5 OMAP343X_PADCONF_ETK(7)
183#define OMAP343X_PADCONF_ETK_D6 OMAP343X_PADCONF_ETK(8)
184#define OMAP343X_PADCONF_ETK_D7 OMAP343X_PADCONF_ETK(9)
185#define OMAP343X_PADCONF_ETK_D8 OMAP343X_PADCONF_ETK(10)
186#define OMAP343X_PADCONF_ETK_D9 OMAP343X_PADCONF_ETK(11)
187#define OMAP343X_PADCONF_ETK_D10 OMAP343X_PADCONF_ETK(12)
188#define OMAP343X_PADCONF_ETK_D11 OMAP343X_PADCONF_ETK(13)
189#define OMAP343X_PADCONF_ETK_D12 OMAP343X_PADCONF_ETK(14)
190#define OMAP343X_PADCONF_ETK_D13 OMAP343X_PADCONF_ETK(15)
191#define OMAP343X_PADCONF_ETK_D14 OMAP343X_PADCONF_ETK(16)
192#define OMAP343X_PADCONF_ETK_D15 OMAP343X_PADCONF_ETK(17)
193
194/* 34xx GENERAL_WKUP regist offsets */
195#define OMAP343X_CONTROL_WKUP_DEBOBSMUX(i) (OMAP343X_CONTROL_GENERAL_WKUP + \
196 0x008 + (i))
197#define OMAP343X_CONTROL_WKUP_DEBOBS0 (OMAP343X_CONTROL_GENERAL_WKUP + 0x008)
198#define OMAP343X_CONTROL_WKUP_DEBOBS1 (OMAP343X_CONTROL_GENERAL_WKUP + 0x00C)
199#define OMAP343X_CONTROL_WKUP_DEBOBS2 (OMAP343X_CONTROL_GENERAL_WKUP + 0x010)
200#define OMAP343X_CONTROL_WKUP_DEBOBS3 (OMAP343X_CONTROL_GENERAL_WKUP + 0x014)
201#define OMAP343X_CONTROL_WKUP_DEBOBS4 (OMAP343X_CONTROL_GENERAL_WKUP + 0x018)
202
203/* 34xx D2D idle-related pins, handled by PM core */
204#define OMAP3_PADCONF_SAD2D_MSTANDBY 0x250
205#define OMAP3_PADCONF_SAD2D_IDLEACK 0x254
206
207/* 44xx control status register offset */
208#define OMAP44XX_CONTROL_STATUS 0x2c4
209
210/* 44xx-only CONTROL_GENERAL register offsets */
211#define OMAP44XX_CONTROL_MMC1 0x628
212#define OMAP44XX_CONTROL_PBIAS_LITE 0x600
213/*
214 * REVISIT: This list of registers is not comprehensive - there are more
215 * that should be added.
216 */
217
218/*
219 * Control module register bit defines - these should eventually go into
220 * their own regbits file. Some of these will be complicated, depending
221 * on the device type (general-purpose, emulator, test, secure, bad, other)
222 * and the security mode (secure, non-secure, don't care)
223 */
224/* CONTROL_DEVCONF0 bits */
225#define OMAP2_MMCSDIO1ADPCLKISEL (1 << 24) /* MMC1 loop back clock */
226#define OMAP24XX_USBSTANDBYCTRL (1 << 15)
227#define OMAP2_MCBSP2_CLKS_MASK (1 << 6)
228#define OMAP2_MCBSP1_CLKS_MASK (1 << 2)
229
230/* CONTROL_DEVCONF1 bits */
231#define OMAP243X_MMC1_ACTIVE_OVERWRITE (1 << 31)
232#define OMAP2_MMCSDIO2ADPCLKISEL (1 << 6) /* MMC2 loop back clock */
233#define OMAP2_MCBSP5_CLKS_MASK (1 << 4) /* > 242x */
234#define OMAP2_MCBSP4_CLKS_MASK (1 << 2) /* > 242x */
235#define OMAP2_MCBSP3_CLKS_MASK (1 << 0) /* > 242x */
236
237/* CONTROL_STATUS bits */
238#define OMAP2_DEVICETYPE_MASK (0x7 << 8)
239#define OMAP2_SYSBOOT_5_MASK (1 << 5)
240#define OMAP2_SYSBOOT_4_MASK (1 << 4)
241#define OMAP2_SYSBOOT_3_MASK (1 << 3)
242#define OMAP2_SYSBOOT_2_MASK (1 << 2)
243#define OMAP2_SYSBOOT_1_MASK (1 << 1)
244#define OMAP2_SYSBOOT_0_MASK (1 << 0)
245
246/* CONTROL_PBIAS_LITE bits */
247#define OMAP343X_PBIASLITESUPPLY_HIGH1 (1 << 15)
248#define OMAP343X_PBIASLITEVMODEERROR1 (1 << 11)
249#define OMAP343X_PBIASSPEEDCTRL1 (1 << 10)
250#define OMAP343X_PBIASLITEPWRDNZ1 (1 << 9)
251#define OMAP343X_PBIASLITEVMODE1 (1 << 8)
252#define OMAP343X_PBIASLITESUPPLY_HIGH0 (1 << 7)
253#define OMAP343X_PBIASLITEVMODEERROR0 (1 << 3)
254#define OMAP2_PBIASSPEEDCTRL0 (1 << 2)
255#define OMAP2_PBIASLITEPWRDNZ0 (1 << 1)
256#define OMAP2_PBIASLITEVMODE0 (1 << 0)
257
258/* CONTROL_PBIAS_LITE bits for OMAP4 */
259#define OMAP4_MMC1_PWRDNZ (1 << 26)
260#define OMAP4_MMC1_PBIASLITE_HIZ_MODE (1 << 25)
261#define OMAP4_MMC1_PBIASLITE_SUPPLY_HI_OUT (1 << 24)
262#define OMAP4_MMC1_PBIASLITE_VMODE_ERROR (1 << 23)
263#define OMAP4_MMC1_PBIASLITE_PWRDNZ (1 << 22)
264#define OMAP4_MMC1_PBIASLITE_VMODE (1 << 21)
265#define OMAP4_USBC1_ICUSB_PWRDNZ (1 << 20)
266
267#define OMAP4_CONTROL_SDMMC1_PUSTRENGTHGRP0 (1 << 31)
268#define OMAP4_CONTROL_SDMMC1_PUSTRENGTHGRP1 (1 << 30)
269#define OMAP4_CONTROL_SDMMC1_PUSTRENGTHGRP2 (1 << 29)
270#define OMAP4_CONTROL_SDMMC1_PUSTRENGTHGRP3 (1 << 28)
271#define OMAP4_CONTROL_SDMMC1_DR0_SPEEDCTRL (1 << 27)
272#define OMAP4_CONTROL_SDMMC1_DR1_SPEEDCTRL (1 << 26)
273#define OMAP4_CONTROL_SDMMC1_DR2_SPEEDCTRL (1 << 25)
274
275/* CONTROL_PROG_IO1 bits */
276#define OMAP3630_PRG_SDMMC1_SPEEDCTRL (1 << 20)
277
278/* CONTROL_IVA2_BOOTMOD bits */
279#define OMAP3_IVA2_BOOTMOD_SHIFT 0
280#define OMAP3_IVA2_BOOTMOD_MASK (0xf << 0)
281#define OMAP3_IVA2_BOOTMOD_IDLE (0x1 << 0)
282
283/* CONTROL_PADCONF_X bits */
284#define OMAP3_PADCONF_WAKEUPEVENT0 (1 << 15)
285#define OMAP3_PADCONF_WAKEUPENABLE0 (1 << 14)
286
287#define OMAP343X_SCRATCHPAD_ROM (OMAP343X_CTRL_BASE + 0x860)
288#define OMAP343X_SCRATCHPAD (OMAP343X_CTRL_BASE + 0x910)
289#define OMAP343X_SCRATCHPAD_ROM_OFFSET 0x19C
290
291/* AM35XX_CONTROL_IPSS_CLK_CTRL bits */
292#define AM35XX_USBOTG_VBUSP_CLK_SHIFT 0
293#define AM35XX_CPGMAC_VBUSP_CLK_SHIFT 1
294#define AM35XX_VPFE_VBUSP_CLK_SHIFT 2
295#define AM35XX_HECC_VBUSP_CLK_SHIFT 3
296#define AM35XX_USBOTG_FCLK_SHIFT 8
297#define AM35XX_CPGMAC_FCLK_SHIFT 9
298#define AM35XX_VPFE_FCLK_SHIFT 10
299
300/*AM35XX CONTROL_LVL_INTR_CLEAR bits*/
301#define AM35XX_CPGMAC_C0_MISC_PULSE_CLR BIT(0)
302#define AM35XX_CPGMAC_C0_RX_PULSE_CLR BIT(1)
303#define AM35XX_CPGMAC_C0_RX_THRESH_CLR BIT(2)
304#define AM35XX_CPGMAC_C0_TX_PULSE_CLR BIT(3)
305#define AM35XX_USBOTGSS_INT_CLR BIT(4)
306#define AM35XX_VPFE_CCDC_VD0_INT_CLR BIT(5)
307#define AM35XX_VPFE_CCDC_VD1_INT_CLR BIT(6)
308#define AM35XX_VPFE_CCDC_VD2_INT_CLR BIT(7)
309
310/*AM35XX CONTROL_IP_SW_RESET bits*/
311#define AM35XX_USBOTGSS_SW_RST BIT(0)
312#define AM35XX_CPGMACSS_SW_RST BIT(1)
313#define AM35XX_VPFE_VBUSP_SW_RST BIT(2)
314#define AM35XX_HECC_SW_RST BIT(3)
315#define AM35XX_VPFE_PCLK_SW_RST BIT(4)
316
317/*
318 * CONTROL OMAP STATUS register to identify OMAP3 features
319 */
320#define OMAP3_CONTROL_OMAP_STATUS 0x044c
321
322#define OMAP3_SGX_SHIFT 13
323#define OMAP3_SGX_MASK (3 << OMAP3_SGX_SHIFT)
324#define FEAT_SGX_FULL 0
325#define FEAT_SGX_HALF 1
326#define FEAT_SGX_NONE 2
327
328#define OMAP3_IVA_SHIFT 12
329#define OMAP3_IVA_MASK (1 << OMAP3_SGX_SHIFT)
330#define FEAT_IVA 0
331#define FEAT_IVA_NONE 1
332
333#define OMAP3_L2CACHE_SHIFT 10
334#define OMAP3_L2CACHE_MASK (3 << OMAP3_L2CACHE_SHIFT)
335#define FEAT_L2CACHE_NONE 0
336#define FEAT_L2CACHE_64KB 1
337#define FEAT_L2CACHE_128KB 2
338#define FEAT_L2CACHE_256KB 3
339
340#define OMAP3_ISP_SHIFT 5
341#define OMAP3_ISP_MASK (1<< OMAP3_ISP_SHIFT)
342#define FEAT_ISP 0
343#define FEAT_ISP_NONE 1
344
345#define OMAP3_NEON_SHIFT 4
346#define OMAP3_NEON_MASK (1<< OMAP3_NEON_SHIFT)
347#define FEAT_NEON 0
348#define FEAT_NEON_NONE 1
349
350
351#ifndef __ASSEMBLY__
352#ifdef CONFIG_ARCH_OMAP2PLUS
353extern void __iomem *omap_ctrl_base_get(void);
354extern u8 omap_ctrl_readb(u16 offset);
355extern u16 omap_ctrl_readw(u16 offset);
356extern u32 omap_ctrl_readl(u16 offset);
357extern void omap_ctrl_writeb(u8 val, u16 offset);
358extern void omap_ctrl_writew(u16 val, u16 offset);
359extern void omap_ctrl_writel(u32 val, u16 offset);
360
361extern void omap3_save_scratchpad_contents(void);
362extern void omap3_clear_scratchpad_contents(void);
363extern u32 *get_restore_pointer(void);
364extern u32 *get_es3_restore_pointer(void);
365extern u32 omap3_arm_context[128];
366extern void omap3_control_save_context(void);
367extern void omap3_control_restore_context(void);
368
369#else
370#define omap_ctrl_base_get() 0
371#define omap_ctrl_readb(x) 0
372#define omap_ctrl_readw(x) 0
373#define omap_ctrl_readl(x) 0
374#define omap_ctrl_writeb(x, y) WARN_ON(1)
375#define omap_ctrl_writew(x, y) WARN_ON(1)
376#define omap_ctrl_writel(x, y) WARN_ON(1)
377#endif
378#endif /* __ASSEMBLY__ */
379
380#endif /* __ASM_ARCH_CONTROL_H */
381
diff --git a/arch/arm/plat-omap/include/plat/cpu.h b/arch/arm/plat-omap/include/plat/cpu.h
index 2e2ae530fced..8198bb6cdb5e 100644
--- a/arch/arm/plat-omap/include/plat/cpu.h
+++ b/arch/arm/plat-omap/include/plat/cpu.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * Copyright (C) 2004, 2008 Nokia Corporation 6 * Copyright (C) 2004, 2008 Nokia Corporation
7 * 7 *
8 * Copyright (C) 2009 Texas Instruments. 8 * Copyright (C) 2009-11 Texas Instruments.
9 * 9 *
10 * Written by Tony Lindgren <tony.lindgren@nokia.com> 10 * Written by Tony Lindgren <tony.lindgren@nokia.com>
11 * 11 *
@@ -68,10 +68,9 @@ unsigned int omap_rev(void);
68#define OMAP_REVBITS_00 0x00 68#define OMAP_REVBITS_00 0x00
69#define OMAP_REVBITS_01 0x01 69#define OMAP_REVBITS_01 0x01
70#define OMAP_REVBITS_02 0x02 70#define OMAP_REVBITS_02 0x02
71#define OMAP_REVBITS_10 0x10 71#define OMAP_REVBITS_03 0x03
72#define OMAP_REVBITS_20 0x20 72#define OMAP_REVBITS_04 0x04
73#define OMAP_REVBITS_30 0x30 73#define OMAP_REVBITS_05 0x05
74#define OMAP_REVBITS_40 0x40
75 74
76/* 75/*
77 * Get the CPU revision for OMAP devices 76 * Get the CPU revision for OMAP devices
@@ -106,6 +105,12 @@ static inline int is_omap ##subclass (void) \
106 return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \ 105 return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
107} 106}
108 107
108#define IS_TI_SUBCLASS(subclass, id) \
109static inline int is_ti ##subclass (void) \
110{ \
111 return (GET_OMAP_SUBCLASS == (id)) ? 1 : 0; \
112}
113
109IS_OMAP_CLASS(7xx, 0x07) 114IS_OMAP_CLASS(7xx, 0x07)
110IS_OMAP_CLASS(15xx, 0x15) 115IS_OMAP_CLASS(15xx, 0x15)
111IS_OMAP_CLASS(16xx, 0x16) 116IS_OMAP_CLASS(16xx, 0x16)
@@ -119,6 +124,8 @@ IS_OMAP_SUBCLASS(343x, 0x343)
119IS_OMAP_SUBCLASS(363x, 0x363) 124IS_OMAP_SUBCLASS(363x, 0x363)
120IS_OMAP_SUBCLASS(443x, 0x443) 125IS_OMAP_SUBCLASS(443x, 0x443)
121 126
127IS_TI_SUBCLASS(816x, 0x816)
128
122#define cpu_is_omap7xx() 0 129#define cpu_is_omap7xx() 0
123#define cpu_is_omap15xx() 0 130#define cpu_is_omap15xx() 0
124#define cpu_is_omap16xx() 0 131#define cpu_is_omap16xx() 0
@@ -127,6 +134,7 @@ IS_OMAP_SUBCLASS(443x, 0x443)
127#define cpu_is_omap243x() 0 134#define cpu_is_omap243x() 0
128#define cpu_is_omap34xx() 0 135#define cpu_is_omap34xx() 0
129#define cpu_is_omap343x() 0 136#define cpu_is_omap343x() 0
137#define cpu_is_ti816x() 0
130#define cpu_is_omap44xx() 0 138#define cpu_is_omap44xx() 0
131#define cpu_is_omap443x() 0 139#define cpu_is_omap443x() 0
132 140
@@ -171,11 +179,11 @@ IS_OMAP_SUBCLASS(443x, 0x443)
171# undef cpu_is_omap24xx 179# undef cpu_is_omap24xx
172# define cpu_is_omap24xx() is_omap24xx() 180# define cpu_is_omap24xx() is_omap24xx()
173# endif 181# endif
174# if defined (CONFIG_ARCH_OMAP2420) 182# if defined (CONFIG_SOC_OMAP2420)
175# undef cpu_is_omap242x 183# undef cpu_is_omap242x
176# define cpu_is_omap242x() is_omap242x() 184# define cpu_is_omap242x() is_omap242x()
177# endif 185# endif
178# if defined (CONFIG_ARCH_OMAP2430) 186# if defined (CONFIG_SOC_OMAP2430)
179# undef cpu_is_omap243x 187# undef cpu_is_omap243x
180# define cpu_is_omap243x() is_omap243x() 188# define cpu_is_omap243x() is_omap243x()
181# endif 189# endif
@@ -190,11 +198,11 @@ IS_OMAP_SUBCLASS(443x, 0x443)
190# undef cpu_is_omap24xx 198# undef cpu_is_omap24xx
191# define cpu_is_omap24xx() 1 199# define cpu_is_omap24xx() 1
192# endif 200# endif
193# if defined(CONFIG_ARCH_OMAP2420) 201# if defined(CONFIG_SOC_OMAP2420)
194# undef cpu_is_omap242x 202# undef cpu_is_omap242x
195# define cpu_is_omap242x() 1 203# define cpu_is_omap242x() 1
196# endif 204# endif
197# if defined(CONFIG_ARCH_OMAP2430) 205# if defined(CONFIG_SOC_OMAP2430)
198# undef cpu_is_omap243x 206# undef cpu_is_omap243x
199# define cpu_is_omap243x() 1 207# define cpu_is_omap243x() 1
200# endif 208# endif
@@ -202,7 +210,7 @@ IS_OMAP_SUBCLASS(443x, 0x443)
202# undef cpu_is_omap34xx 210# undef cpu_is_omap34xx
203# define cpu_is_omap34xx() 1 211# define cpu_is_omap34xx() 1
204# endif 212# endif
205# if defined(CONFIG_ARCH_OMAP3430) 213# if defined(CONFIG_SOC_OMAP3430)
206# undef cpu_is_omap343x 214# undef cpu_is_omap343x
207# define cpu_is_omap343x() 1 215# define cpu_is_omap343x() 1
208# endif 216# endif
@@ -331,6 +339,7 @@ IS_OMAP_TYPE(3517, 0x3517)
331# undef cpu_is_omap3530 339# undef cpu_is_omap3530
332# undef cpu_is_omap3505 340# undef cpu_is_omap3505
333# undef cpu_is_omap3517 341# undef cpu_is_omap3517
342# undef cpu_is_ti816x
334# define cpu_is_omap3430() is_omap3430() 343# define cpu_is_omap3430() is_omap3430()
335# define cpu_is_omap3503() (cpu_is_omap3430() && \ 344# define cpu_is_omap3503() (cpu_is_omap3430() && \
336 (!omap3_has_iva()) && \ 345 (!omap3_has_iva()) && \
@@ -346,6 +355,7 @@ IS_OMAP_TYPE(3517, 0x3517)
346# define cpu_is_omap3517() is_omap3517() 355# define cpu_is_omap3517() is_omap3517()
347# undef cpu_is_omap3630 356# undef cpu_is_omap3630
348# define cpu_is_omap3630() is_omap363x() 357# define cpu_is_omap3630() is_omap363x()
358# define cpu_is_ti816x() is_ti816x()
349#endif 359#endif
350 360
351# if defined(CONFIG_ARCH_OMAP4) 361# if defined(CONFIG_ARCH_OMAP4)
@@ -363,23 +373,24 @@ IS_OMAP_TYPE(3517, 0x3517)
363 373
364/* Various silicon revisions for omap2 */ 374/* Various silicon revisions for omap2 */
365#define OMAP242X_CLASS 0x24200024 375#define OMAP242X_CLASS 0x24200024
366#define OMAP2420_REV_ES1_0 0x24200024 376#define OMAP2420_REV_ES1_0 OMAP242X_CLASS
367#define OMAP2420_REV_ES2_0 0x24201024 377#define OMAP2420_REV_ES2_0 (OMAP242X_CLASS | (OMAP_REVBITS_01 << 8))
368 378
369#define OMAP243X_CLASS 0x24300024 379#define OMAP243X_CLASS 0x24300024
370#define OMAP2430_REV_ES1_0 0x24300024 380#define OMAP2430_REV_ES1_0 OMAP243X_CLASS
371 381
372#define OMAP343X_CLASS 0x34300034 382#define OMAP343X_CLASS 0x34300034
373#define OMAP3430_REV_ES1_0 0x34300034 383#define OMAP3430_REV_ES1_0 OMAP343X_CLASS
374#define OMAP3430_REV_ES2_0 0x34301034 384#define OMAP3430_REV_ES2_0 (OMAP343X_CLASS | (OMAP_REVBITS_01 << 8))
375#define OMAP3430_REV_ES2_1 0x34302034 385#define OMAP3430_REV_ES2_1 (OMAP343X_CLASS | (OMAP_REVBITS_02 << 8))
376#define OMAP3430_REV_ES3_0 0x34303034 386#define OMAP3430_REV_ES3_0 (OMAP343X_CLASS | (OMAP_REVBITS_03 << 8))
377#define OMAP3430_REV_ES3_1 0x34304034 387#define OMAP3430_REV_ES3_1 (OMAP343X_CLASS | (OMAP_REVBITS_04 << 8))
378#define OMAP3430_REV_ES3_1_2 0x34305034 388#define OMAP3430_REV_ES3_1_2 (OMAP343X_CLASS | (OMAP_REVBITS_05 << 8))
379 389
380#define OMAP3630_REV_ES1_0 0x36300034 390#define OMAP363X_CLASS 0x36300034
381#define OMAP3630_REV_ES1_1 0x36300134 391#define OMAP3630_REV_ES1_0 OMAP363X_CLASS
382#define OMAP3630_REV_ES1_2 0x36300234 392#define OMAP3630_REV_ES1_1 (OMAP363X_CLASS | (OMAP_REVBITS_01 << 8))
393#define OMAP3630_REV_ES1_2 (OMAP363X_CLASS | (OMAP_REVBITS_02 << 8))
383 394
384#define OMAP35XX_CLASS 0x35000034 395#define OMAP35XX_CLASS 0x35000034
385#define OMAP3503_REV(v) (OMAP35XX_CLASS | (0x3503 << 16) | (v << 8)) 396#define OMAP3503_REV(v) (OMAP35XX_CLASS | (0x3503 << 16) | (v << 8))
@@ -389,8 +400,15 @@ IS_OMAP_TYPE(3517, 0x3517)
389#define OMAP3505_REV(v) (OMAP35XX_CLASS | (0x3505 << 16) | (v << 8)) 400#define OMAP3505_REV(v) (OMAP35XX_CLASS | (0x3505 << 16) | (v << 8))
390#define OMAP3517_REV(v) (OMAP35XX_CLASS | (0x3517 << 16) | (v << 8)) 401#define OMAP3517_REV(v) (OMAP35XX_CLASS | (0x3517 << 16) | (v << 8))
391 402
403#define TI816X_CLASS 0x81600034
404#define TI8168_REV_ES1_0 TI816X_CLASS
405#define TI8168_REV_ES1_1 (TI816X_CLASS | (OMAP_REVBITS_01 << 8))
406
392#define OMAP443X_CLASS 0x44300044 407#define OMAP443X_CLASS 0x44300044
393#define OMAP4430_REV_ES1_0 0x44300044 408#define OMAP4430_REV_ES1_0 (OMAP443X_CLASS | (0x10 << 8))
409#define OMAP4430_REV_ES2_0 (OMAP443X_CLASS | (0x20 << 8))
410#define OMAP4430_REV_ES2_1 (OMAP443X_CLASS | (0x21 << 8))
411#define OMAP4430_REV_ES2_2 (OMAP443X_CLASS | (0x22 << 8))
394 412
395/* 413/*
396 * omap_chip bits 414 * omap_chip bits
@@ -417,10 +435,17 @@ IS_OMAP_TYPE(3517, 0x3517)
417#define CHIP_IS_OMAP4430ES1 (1 << 8) 435#define CHIP_IS_OMAP4430ES1 (1 << 8)
418#define CHIP_IS_OMAP3630ES1_1 (1 << 9) 436#define CHIP_IS_OMAP3630ES1_1 (1 << 9)
419#define CHIP_IS_OMAP3630ES1_2 (1 << 10) 437#define CHIP_IS_OMAP3630ES1_2 (1 << 10)
438#define CHIP_IS_OMAP4430ES2 (1 << 11)
439#define CHIP_IS_OMAP4430ES2_1 (1 << 12)
440#define CHIP_IS_OMAP4430ES2_2 (1 << 13)
441#define CHIP_IS_TI816X (1 << 14)
420 442
421#define CHIP_IS_OMAP24XX (CHIP_IS_OMAP2420 | CHIP_IS_OMAP2430) 443#define CHIP_IS_OMAP24XX (CHIP_IS_OMAP2420 | CHIP_IS_OMAP2430)
422 444
423#define CHIP_IS_OMAP4430 (CHIP_IS_OMAP4430ES1) 445#define CHIP_IS_OMAP4430 (CHIP_IS_OMAP4430ES1 | \
446 CHIP_IS_OMAP4430ES2 | \
447 CHIP_IS_OMAP4430ES2_1 | \
448 CHIP_IS_OMAP4430ES2_2)
424 449
425/* 450/*
426 * "GE" here represents "greater than or equal to" in terms of ES 451 * "GE" here represents "greater than or equal to" in terms of ES
@@ -452,6 +477,7 @@ extern u32 omap3_features;
452#define OMAP3_HAS_ISP BIT(4) 477#define OMAP3_HAS_ISP BIT(4)
453#define OMAP3_HAS_192MHZ_CLK BIT(5) 478#define OMAP3_HAS_192MHZ_CLK BIT(5)
454#define OMAP3_HAS_IO_WAKEUP BIT(6) 479#define OMAP3_HAS_IO_WAKEUP BIT(6)
480#define OMAP3_HAS_SDRC BIT(7)
455 481
456#define OMAP3_HAS_FEATURE(feat,flag) \ 482#define OMAP3_HAS_FEATURE(feat,flag) \
457static inline unsigned int omap3_has_ ##feat(void) \ 483static inline unsigned int omap3_has_ ##feat(void) \
@@ -466,5 +492,6 @@ OMAP3_HAS_FEATURE(neon, NEON)
466OMAP3_HAS_FEATURE(isp, ISP) 492OMAP3_HAS_FEATURE(isp, ISP)
467OMAP3_HAS_FEATURE(192mhz_clk, 192MHZ_CLK) 493OMAP3_HAS_FEATURE(192mhz_clk, 192MHZ_CLK)
468OMAP3_HAS_FEATURE(io_wakeup, IO_WAKEUP) 494OMAP3_HAS_FEATURE(io_wakeup, IO_WAKEUP)
495OMAP3_HAS_FEATURE(sdrc, SDRC)
469 496
470#endif 497#endif
diff --git a/arch/arm/plat-omap/include/plat/display.h b/arch/arm/plat-omap/include/plat/display.h
deleted file mode 100644
index 8bd15bdb4132..000000000000
--- a/arch/arm/plat-omap/include/plat/display.h
+++ /dev/null
@@ -1,591 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-omap/display.h
3 *
4 * Copyright (C) 2008 Nokia Corporation
5 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef __ASM_ARCH_OMAP_DISPLAY_H
21#define __ASM_ARCH_OMAP_DISPLAY_H
22
23#include <linux/list.h>
24#include <linux/kobject.h>
25#include <linux/device.h>
26#include <asm/atomic.h>
27
28#define DISPC_IRQ_FRAMEDONE (1 << 0)
29#define DISPC_IRQ_VSYNC (1 << 1)
30#define DISPC_IRQ_EVSYNC_EVEN (1 << 2)
31#define DISPC_IRQ_EVSYNC_ODD (1 << 3)
32#define DISPC_IRQ_ACBIAS_COUNT_STAT (1 << 4)
33#define DISPC_IRQ_PROG_LINE_NUM (1 << 5)
34#define DISPC_IRQ_GFX_FIFO_UNDERFLOW (1 << 6)
35#define DISPC_IRQ_GFX_END_WIN (1 << 7)
36#define DISPC_IRQ_PAL_GAMMA_MASK (1 << 8)
37#define DISPC_IRQ_OCP_ERR (1 << 9)
38#define DISPC_IRQ_VID1_FIFO_UNDERFLOW (1 << 10)
39#define DISPC_IRQ_VID1_END_WIN (1 << 11)
40#define DISPC_IRQ_VID2_FIFO_UNDERFLOW (1 << 12)
41#define DISPC_IRQ_VID2_END_WIN (1 << 13)
42#define DISPC_IRQ_SYNC_LOST (1 << 14)
43#define DISPC_IRQ_SYNC_LOST_DIGIT (1 << 15)
44#define DISPC_IRQ_WAKEUP (1 << 16)
45
46struct omap_dss_device;
47struct omap_overlay_manager;
48
49enum omap_display_type {
50 OMAP_DISPLAY_TYPE_NONE = 0,
51 OMAP_DISPLAY_TYPE_DPI = 1 << 0,
52 OMAP_DISPLAY_TYPE_DBI = 1 << 1,
53 OMAP_DISPLAY_TYPE_SDI = 1 << 2,
54 OMAP_DISPLAY_TYPE_DSI = 1 << 3,
55 OMAP_DISPLAY_TYPE_VENC = 1 << 4,
56};
57
58enum omap_plane {
59 OMAP_DSS_GFX = 0,
60 OMAP_DSS_VIDEO1 = 1,
61 OMAP_DSS_VIDEO2 = 2
62};
63
64enum omap_channel {
65 OMAP_DSS_CHANNEL_LCD = 0,
66 OMAP_DSS_CHANNEL_DIGIT = 1,
67};
68
69enum omap_color_mode {
70 OMAP_DSS_COLOR_CLUT1 = 1 << 0, /* BITMAP 1 */
71 OMAP_DSS_COLOR_CLUT2 = 1 << 1, /* BITMAP 2 */
72 OMAP_DSS_COLOR_CLUT4 = 1 << 2, /* BITMAP 4 */
73 OMAP_DSS_COLOR_CLUT8 = 1 << 3, /* BITMAP 8 */
74 OMAP_DSS_COLOR_RGB12U = 1 << 4, /* RGB12, 16-bit container */
75 OMAP_DSS_COLOR_ARGB16 = 1 << 5, /* ARGB16 */
76 OMAP_DSS_COLOR_RGB16 = 1 << 6, /* RGB16 */
77 OMAP_DSS_COLOR_RGB24U = 1 << 7, /* RGB24, 32-bit container */
78 OMAP_DSS_COLOR_RGB24P = 1 << 8, /* RGB24, 24-bit container */
79 OMAP_DSS_COLOR_YUV2 = 1 << 9, /* YUV2 4:2:2 co-sited */
80 OMAP_DSS_COLOR_UYVY = 1 << 10, /* UYVY 4:2:2 co-sited */
81 OMAP_DSS_COLOR_ARGB32 = 1 << 11, /* ARGB32 */
82 OMAP_DSS_COLOR_RGBA32 = 1 << 12, /* RGBA32 */
83 OMAP_DSS_COLOR_RGBX32 = 1 << 13, /* RGBx32 */
84
85 OMAP_DSS_COLOR_GFX_OMAP2 =
86 OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
87 OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
88 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
89 OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P,
90
91 OMAP_DSS_COLOR_VID_OMAP2 =
92 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
93 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
94 OMAP_DSS_COLOR_UYVY,
95
96 OMAP_DSS_COLOR_GFX_OMAP3 =
97 OMAP_DSS_COLOR_CLUT1 | OMAP_DSS_COLOR_CLUT2 |
98 OMAP_DSS_COLOR_CLUT4 | OMAP_DSS_COLOR_CLUT8 |
99 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
100 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
101 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 |
102 OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
103
104 OMAP_DSS_COLOR_VID1_OMAP3 =
105 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
106 OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P |
107 OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_UYVY,
108
109 OMAP_DSS_COLOR_VID2_OMAP3 =
110 OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
111 OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
112 OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
113 OMAP_DSS_COLOR_UYVY | OMAP_DSS_COLOR_ARGB32 |
114 OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
115};
116
117enum omap_lcd_display_type {
118 OMAP_DSS_LCD_DISPLAY_STN,
119 OMAP_DSS_LCD_DISPLAY_TFT,
120};
121
122enum omap_dss_load_mode {
123 OMAP_DSS_LOAD_CLUT_AND_FRAME = 0,
124 OMAP_DSS_LOAD_CLUT_ONLY = 1,
125 OMAP_DSS_LOAD_FRAME_ONLY = 2,
126 OMAP_DSS_LOAD_CLUT_ONCE_FRAME = 3,
127};
128
129enum omap_dss_trans_key_type {
130 OMAP_DSS_COLOR_KEY_GFX_DST = 0,
131 OMAP_DSS_COLOR_KEY_VID_SRC = 1,
132};
133
134enum omap_rfbi_te_mode {
135 OMAP_DSS_RFBI_TE_MODE_1 = 1,
136 OMAP_DSS_RFBI_TE_MODE_2 = 2,
137};
138
139enum omap_panel_config {
140 OMAP_DSS_LCD_IVS = 1<<0,
141 OMAP_DSS_LCD_IHS = 1<<1,
142 OMAP_DSS_LCD_IPC = 1<<2,
143 OMAP_DSS_LCD_IEO = 1<<3,
144 OMAP_DSS_LCD_RF = 1<<4,
145 OMAP_DSS_LCD_ONOFF = 1<<5,
146
147 OMAP_DSS_LCD_TFT = 1<<20,
148};
149
150enum omap_dss_venc_type {
151 OMAP_DSS_VENC_TYPE_COMPOSITE,
152 OMAP_DSS_VENC_TYPE_SVIDEO,
153};
154
155enum omap_display_caps {
156 OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE = 1 << 0,
157 OMAP_DSS_DISPLAY_CAP_TEAR_ELIM = 1 << 1,
158};
159
160enum omap_dss_update_mode {
161 OMAP_DSS_UPDATE_DISABLED = 0,
162 OMAP_DSS_UPDATE_AUTO,
163 OMAP_DSS_UPDATE_MANUAL,
164};
165
166enum omap_dss_display_state {
167 OMAP_DSS_DISPLAY_DISABLED = 0,
168 OMAP_DSS_DISPLAY_ACTIVE,
169 OMAP_DSS_DISPLAY_SUSPENDED,
170};
171
172/* XXX perhaps this should be removed */
173enum omap_dss_overlay_managers {
174 OMAP_DSS_OVL_MGR_LCD,
175 OMAP_DSS_OVL_MGR_TV,
176};
177
178enum omap_dss_rotation_type {
179 OMAP_DSS_ROT_DMA = 0,
180 OMAP_DSS_ROT_VRFB = 1,
181};
182
183/* clockwise rotation angle */
184enum omap_dss_rotation_angle {
185 OMAP_DSS_ROT_0 = 0,
186 OMAP_DSS_ROT_90 = 1,
187 OMAP_DSS_ROT_180 = 2,
188 OMAP_DSS_ROT_270 = 3,
189};
190
191enum omap_overlay_caps {
192 OMAP_DSS_OVL_CAP_SCALE = 1 << 0,
193 OMAP_DSS_OVL_CAP_DISPC = 1 << 1,
194};
195
196enum omap_overlay_manager_caps {
197 OMAP_DSS_OVL_MGR_CAP_DISPC = 1 << 0,
198};
199
200/* RFBI */
201
202struct rfbi_timings {
203 int cs_on_time;
204 int cs_off_time;
205 int we_on_time;
206 int we_off_time;
207 int re_on_time;
208 int re_off_time;
209 int we_cycle_time;
210 int re_cycle_time;
211 int cs_pulse_width;
212 int access_time;
213
214 int clk_div;
215
216 u32 tim[5]; /* set by rfbi_convert_timings() */
217
218 int converted;
219};
220
221void omap_rfbi_write_command(const void *buf, u32 len);
222void omap_rfbi_read_data(void *buf, u32 len);
223void omap_rfbi_write_data(const void *buf, u32 len);
224void omap_rfbi_write_pixels(const void __iomem *buf, int scr_width,
225 u16 x, u16 y,
226 u16 w, u16 h);
227int omap_rfbi_enable_te(bool enable, unsigned line);
228int omap_rfbi_setup_te(enum omap_rfbi_te_mode mode,
229 unsigned hs_pulse_time, unsigned vs_pulse_time,
230 int hs_pol_inv, int vs_pol_inv, int extif_div);
231
232/* DSI */
233void dsi_bus_lock(void);
234void dsi_bus_unlock(void);
235int dsi_vc_dcs_write(int channel, u8 *data, int len);
236int dsi_vc_dcs_write_0(int channel, u8 dcs_cmd);
237int dsi_vc_dcs_write_1(int channel, u8 dcs_cmd, u8 param);
238int dsi_vc_dcs_write_nosync(int channel, u8 *data, int len);
239int dsi_vc_dcs_read(int channel, u8 dcs_cmd, u8 *buf, int buflen);
240int dsi_vc_dcs_read_1(int channel, u8 dcs_cmd, u8 *data);
241int dsi_vc_dcs_read_2(int channel, u8 dcs_cmd, u8 *data1, u8 *data2);
242int dsi_vc_set_max_rx_packet_size(int channel, u16 len);
243int dsi_vc_send_null(int channel);
244int dsi_vc_send_bta_sync(int channel);
245
246/* Board specific data */
247struct omap_dss_board_info {
248 int (*get_last_off_on_transaction_id)(struct device *dev);
249 int num_devices;
250 struct omap_dss_device **devices;
251 struct omap_dss_device *default_device;
252};
253
254struct omap_video_timings {
255 /* Unit: pixels */
256 u16 x_res;
257 /* Unit: pixels */
258 u16 y_res;
259 /* Unit: KHz */
260 u32 pixel_clock;
261 /* Unit: pixel clocks */
262 u16 hsw; /* Horizontal synchronization pulse width */
263 /* Unit: pixel clocks */
264 u16 hfp; /* Horizontal front porch */
265 /* Unit: pixel clocks */
266 u16 hbp; /* Horizontal back porch */
267 /* Unit: line clocks */
268 u16 vsw; /* Vertical synchronization pulse width */
269 /* Unit: line clocks */
270 u16 vfp; /* Vertical front porch */
271 /* Unit: line clocks */
272 u16 vbp; /* Vertical back porch */
273};
274
275#ifdef CONFIG_OMAP2_DSS_VENC
276/* Hardcoded timings for tv modes. Venc only uses these to
277 * identify the mode, and does not actually use the configs
278 * itself. However, the configs should be something that
279 * a normal monitor can also show */
280extern const struct omap_video_timings omap_dss_pal_timings;
281extern const struct omap_video_timings omap_dss_ntsc_timings;
282#endif
283
284struct omap_overlay_info {
285 bool enabled;
286
287 u32 paddr;
288 void __iomem *vaddr;
289 u16 screen_width;
290 u16 width;
291 u16 height;
292 enum omap_color_mode color_mode;
293 u8 rotation;
294 enum omap_dss_rotation_type rotation_type;
295 bool mirror;
296
297 u16 pos_x;
298 u16 pos_y;
299 u16 out_width; /* if 0, out_width == width */
300 u16 out_height; /* if 0, out_height == height */
301 u8 global_alpha;
302};
303
304struct omap_overlay {
305 struct kobject kobj;
306 struct list_head list;
307
308 /* static fields */
309 const char *name;
310 int id;
311 enum omap_color_mode supported_modes;
312 enum omap_overlay_caps caps;
313
314 /* dynamic fields */
315 struct omap_overlay_manager *manager;
316 struct omap_overlay_info info;
317
318 /* if true, info has been changed, but not applied() yet */
319 bool info_dirty;
320
321 int (*set_manager)(struct omap_overlay *ovl,
322 struct omap_overlay_manager *mgr);
323 int (*unset_manager)(struct omap_overlay *ovl);
324
325 int (*set_overlay_info)(struct omap_overlay *ovl,
326 struct omap_overlay_info *info);
327 void (*get_overlay_info)(struct omap_overlay *ovl,
328 struct omap_overlay_info *info);
329
330 int (*wait_for_go)(struct omap_overlay *ovl);
331};
332
333struct omap_overlay_manager_info {
334 u32 default_color;
335
336 enum omap_dss_trans_key_type trans_key_type;
337 u32 trans_key;
338 bool trans_enabled;
339
340 bool alpha_enabled;
341};
342
343struct omap_overlay_manager {
344 struct kobject kobj;
345 struct list_head list;
346
347 /* static fields */
348 const char *name;
349 int id;
350 enum omap_overlay_manager_caps caps;
351 int num_overlays;
352 struct omap_overlay **overlays;
353 enum omap_display_type supported_displays;
354
355 /* dynamic fields */
356 struct omap_dss_device *device;
357 struct omap_overlay_manager_info info;
358
359 bool device_changed;
360 /* if true, info has been changed but not applied() yet */
361 bool info_dirty;
362
363 int (*set_device)(struct omap_overlay_manager *mgr,
364 struct omap_dss_device *dssdev);
365 int (*unset_device)(struct omap_overlay_manager *mgr);
366
367 int (*set_manager_info)(struct omap_overlay_manager *mgr,
368 struct omap_overlay_manager_info *info);
369 void (*get_manager_info)(struct omap_overlay_manager *mgr,
370 struct omap_overlay_manager_info *info);
371
372 int (*apply)(struct omap_overlay_manager *mgr);
373 int (*wait_for_go)(struct omap_overlay_manager *mgr);
374 int (*wait_for_vsync)(struct omap_overlay_manager *mgr);
375
376 int (*enable)(struct omap_overlay_manager *mgr);
377 int (*disable)(struct omap_overlay_manager *mgr);
378};
379
380struct omap_dss_device {
381 struct device dev;
382
383 enum omap_display_type type;
384
385 union {
386 struct {
387 u8 data_lines;
388 } dpi;
389
390 struct {
391 u8 channel;
392 u8 data_lines;
393 } rfbi;
394
395 struct {
396 u8 datapairs;
397 } sdi;
398
399 struct {
400 u8 clk_lane;
401 u8 clk_pol;
402 u8 data1_lane;
403 u8 data1_pol;
404 u8 data2_lane;
405 u8 data2_pol;
406
407 struct {
408 u16 regn;
409 u16 regm;
410 u16 regm3;
411 u16 regm4;
412
413 u16 lp_clk_div;
414
415 u16 lck_div;
416 u16 pck_div;
417 } div;
418
419 bool ext_te;
420 u8 ext_te_gpio;
421 } dsi;
422
423 struct {
424 enum omap_dss_venc_type type;
425 bool invert_polarity;
426 } venc;
427 } phy;
428
429 struct {
430 struct omap_video_timings timings;
431
432 int acbi; /* ac-bias pin transitions per interrupt */
433 /* Unit: line clocks */
434 int acb; /* ac-bias pin frequency */
435
436 enum omap_panel_config config;
437 } panel;
438
439 struct {
440 u8 pixel_size;
441 struct rfbi_timings rfbi_timings;
442 } ctrl;
443
444 int reset_gpio;
445
446 int max_backlight_level;
447
448 const char *name;
449
450 /* used to match device to driver */
451 const char *driver_name;
452
453 void *data;
454
455 struct omap_dss_driver *driver;
456
457 /* helper variable for driver suspend/resume */
458 bool activate_after_resume;
459
460 enum omap_display_caps caps;
461
462 struct omap_overlay_manager *manager;
463
464 enum omap_dss_display_state state;
465
466 /* platform specific */
467 int (*platform_enable)(struct omap_dss_device *dssdev);
468 void (*platform_disable)(struct omap_dss_device *dssdev);
469 int (*set_backlight)(struct omap_dss_device *dssdev, int level);
470 int (*get_backlight)(struct omap_dss_device *dssdev);
471};
472
473struct omap_dss_driver {
474 struct device_driver driver;
475
476 int (*probe)(struct omap_dss_device *);
477 void (*remove)(struct omap_dss_device *);
478
479 int (*enable)(struct omap_dss_device *display);
480 void (*disable)(struct omap_dss_device *display);
481 int (*suspend)(struct omap_dss_device *display);
482 int (*resume)(struct omap_dss_device *display);
483 int (*run_test)(struct omap_dss_device *display, int test);
484
485 int (*set_update_mode)(struct omap_dss_device *dssdev,
486 enum omap_dss_update_mode);
487 enum omap_dss_update_mode (*get_update_mode)(
488 struct omap_dss_device *dssdev);
489
490 int (*update)(struct omap_dss_device *dssdev,
491 u16 x, u16 y, u16 w, u16 h);
492 int (*sync)(struct omap_dss_device *dssdev);
493
494 int (*enable_te)(struct omap_dss_device *dssdev, bool enable);
495 int (*get_te)(struct omap_dss_device *dssdev);
496
497 u8 (*get_rotate)(struct omap_dss_device *dssdev);
498 int (*set_rotate)(struct omap_dss_device *dssdev, u8 rotate);
499
500 bool (*get_mirror)(struct omap_dss_device *dssdev);
501 int (*set_mirror)(struct omap_dss_device *dssdev, bool enable);
502
503 int (*memory_read)(struct omap_dss_device *dssdev,
504 void *buf, size_t size,
505 u16 x, u16 y, u16 w, u16 h);
506
507 void (*get_resolution)(struct omap_dss_device *dssdev,
508 u16 *xres, u16 *yres);
509 int (*get_recommended_bpp)(struct omap_dss_device *dssdev);
510
511 int (*check_timings)(struct omap_dss_device *dssdev,
512 struct omap_video_timings *timings);
513 void (*set_timings)(struct omap_dss_device *dssdev,
514 struct omap_video_timings *timings);
515 void (*get_timings)(struct omap_dss_device *dssdev,
516 struct omap_video_timings *timings);
517
518 int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
519 u32 (*get_wss)(struct omap_dss_device *dssdev);
520};
521
522int omap_dss_register_driver(struct omap_dss_driver *);
523void omap_dss_unregister_driver(struct omap_dss_driver *);
524
525int omap_dss_register_device(struct omap_dss_device *);
526void omap_dss_unregister_device(struct omap_dss_device *);
527
528void omap_dss_get_device(struct omap_dss_device *dssdev);
529void omap_dss_put_device(struct omap_dss_device *dssdev);
530#define for_each_dss_dev(d) while ((d = omap_dss_get_next_device(d)) != NULL)
531struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from);
532struct omap_dss_device *omap_dss_find_device(void *data,
533 int (*match)(struct omap_dss_device *dssdev, void *data));
534
535int omap_dss_start_device(struct omap_dss_device *dssdev);
536void omap_dss_stop_device(struct omap_dss_device *dssdev);
537
538int omap_dss_get_num_overlay_managers(void);
539struct omap_overlay_manager *omap_dss_get_overlay_manager(int num);
540
541int omap_dss_get_num_overlays(void);
542struct omap_overlay *omap_dss_get_overlay(int num);
543
544void omapdss_default_get_resolution(struct omap_dss_device *dssdev,
545 u16 *xres, u16 *yres);
546int omapdss_default_get_recommended_bpp(struct omap_dss_device *dssdev);
547
548typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
549int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
550int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
551
552int omap_dispc_wait_for_irq_timeout(u32 irqmask, unsigned long timeout);
553int omap_dispc_wait_for_irq_interruptible_timeout(u32 irqmask,
554 unsigned long timeout);
555
556#define to_dss_driver(x) container_of((x), struct omap_dss_driver, driver)
557#define to_dss_device(x) container_of((x), struct omap_dss_device, dev)
558
559void omapdss_dsi_vc_enable_hs(int channel, bool enable);
560int omapdss_dsi_enable_te(struct omap_dss_device *dssdev, bool enable);
561
562int omap_dsi_prepare_update(struct omap_dss_device *dssdev,
563 u16 *x, u16 *y, u16 *w, u16 *h,
564 bool enlarge_update_area);
565int omap_dsi_update(struct omap_dss_device *dssdev,
566 int channel,
567 u16 x, u16 y, u16 w, u16 h,
568 void (*callback)(int, void *), void *data);
569
570int omapdss_dsi_display_enable(struct omap_dss_device *dssdev);
571void omapdss_dsi_display_disable(struct omap_dss_device *dssdev);
572
573int omapdss_dpi_display_enable(struct omap_dss_device *dssdev);
574void omapdss_dpi_display_disable(struct omap_dss_device *dssdev);
575void dpi_set_timings(struct omap_dss_device *dssdev,
576 struct omap_video_timings *timings);
577int dpi_check_timings(struct omap_dss_device *dssdev,
578 struct omap_video_timings *timings);
579
580int omapdss_sdi_display_enable(struct omap_dss_device *dssdev);
581void omapdss_sdi_display_disable(struct omap_dss_device *dssdev);
582
583int omapdss_rfbi_display_enable(struct omap_dss_device *dssdev);
584void omapdss_rfbi_display_disable(struct omap_dss_device *dssdev);
585int omap_rfbi_prepare_update(struct omap_dss_device *dssdev,
586 u16 *x, u16 *y, u16 *w, u16 *h);
587int omap_rfbi_update(struct omap_dss_device *dssdev,
588 u16 x, u16 y, u16 w, u16 h,
589 void (*callback)(void *), void *data);
590
591#endif
diff --git a/arch/arm/plat-omap/include/plat/dma.h b/arch/arm/plat-omap/include/plat/dma.h
index af3a03941add..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
@@ -319,6 +193,8 @@
319#define OMAP34XX_DMA_USIM_TX 79 /* S_DMA_78 */ 193#define OMAP34XX_DMA_USIM_TX 79 /* S_DMA_78 */
320#define OMAP34XX_DMA_USIM_RX 80 /* S_DMA_79 */ 194#define OMAP34XX_DMA_USIM_RX 80 /* S_DMA_79 */
321 195
196#define OMAP36XX_DMA_UART4_TX 81 /* S_DMA_80 */
197#define OMAP36XX_DMA_UART4_RX 82 /* S_DMA_81 */
322/*----------------------------------------------------------------------------*/ 198/*----------------------------------------------------------------------------*/
323 199
324#define OMAP1_DMA_TOUT_IRQ (1 << 0) 200#define OMAP1_DMA_TOUT_IRQ (1 << 0)
@@ -335,6 +211,10 @@
335#define OMAP2_DMA_MISALIGNED_ERR_IRQ (1 << 11) 211#define OMAP2_DMA_MISALIGNED_ERR_IRQ (1 << 11)
336 212
337#define OMAP_DMA_CCR_EN (1 << 7) 213#define OMAP_DMA_CCR_EN (1 << 7)
214#define OMAP_DMA_CCR_RD_ACTIVE (1 << 9)
215#define OMAP_DMA_CCR_WR_ACTIVE (1 << 10)
216#define OMAP_DMA_CCR_SEL_SRC_DST_SYNC (1 << 24)
217#define OMAP_DMA_CCR_BUFFERING_DISABLE (1 << 25)
338 218
339#define OMAP_DMA_DATA_TYPE_S8 0x00 219#define OMAP_DMA_DATA_TYPE_S8 0x00
340#define OMAP_DMA_DATA_TYPE_S16 0x01 220#define OMAP_DMA_DATA_TYPE_S16 0x01
@@ -399,6 +279,63 @@
399#define DMA_CH_PRIO_HIGH 0x1 279#define DMA_CH_PRIO_HIGH 0x1
400#define DMA_CH_PRIO_LOW 0x0 /* Def */ 280#define DMA_CH_PRIO_LOW 0x0 /* Def */
401 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
402enum omap_dma_burst_mode { 339enum omap_dma_burst_mode {
403 OMAP_DMA_DATA_BURST_DIS = 0, 340 OMAP_DMA_DATA_BURST_DIS = 0,
404 OMAP_DMA_DATA_BURST_4, 341 OMAP_DMA_DATA_BURST_4,
@@ -464,6 +401,41 @@ struct omap_dma_channel_params {
464#endif 401#endif
465}; 402};
466 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};
467 439
468extern 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);
469extern 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/dmtimer.h b/arch/arm/plat-omap/include/plat/dmtimer.h
index 20f1054c0a80..d6c70d2f4030 100644
--- a/arch/arm/plat-omap/include/plat/dmtimer.h
+++ b/arch/arm/plat-omap/include/plat/dmtimer.h
@@ -3,6 +3,12 @@
3 * 3 *
4 * OMAP Dual-Mode Timers 4 * OMAP Dual-Mode Timers
5 * 5 *
6 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
7 * Tarun Kanti DebBarma <tarun.kanti@ti.com>
8 * Thara Gopinath <thara@ti.com>
9 *
10 * Platform device conversion and hwmod support.
11 *
6 * Copyright (C) 2005 Nokia Corporation 12 * Copyright (C) 2005 Nokia Corporation
7 * Author: Lauri Leukkunen <lauri.leukkunen@nokia.com> 13 * Author: Lauri Leukkunen <lauri.leukkunen@nokia.com>
8 * PWM and clock framwork support by Timo Teras. 14 * PWM and clock framwork support by Timo Teras.
@@ -44,7 +50,14 @@
44#define OMAP_TIMER_TRIGGER_OVERFLOW 0x01 50#define OMAP_TIMER_TRIGGER_OVERFLOW 0x01
45#define OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE 0x02 51#define OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE 0x02
46 52
53/*
54 * IP revision identifier so that Highlander IP
55 * in OMAP4 can be distinguished.
56 */
57#define OMAP_TIMER_IP_VERSION_1 0x1
47struct omap_dm_timer; 58struct omap_dm_timer;
59extern struct omap_dm_timer *gptimer_wakeup;
60extern struct sys_timer omap_timer;
48struct clk; 61struct clk;
49 62
50int omap_dm_timer_init(void); 63int omap_dm_timer_init(void);
diff --git a/arch/arm/plat-omap/include/plat/dsp.h b/arch/arm/plat-omap/include/plat/dsp.h
new file mode 100644
index 000000000000..9c604b390f9f
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/dsp.h
@@ -0,0 +1,31 @@
1#ifndef __OMAP_DSP_H__
2#define __OMAP_DSP_H__
3
4#include <linux/types.h>
5
6struct omap_dsp_platform_data {
7 void (*dsp_set_min_opp) (u8 opp_id);
8 u8 (*dsp_get_opp) (void);
9 void (*cpu_set_freq) (unsigned long f);
10 unsigned long (*cpu_get_freq) (void);
11 unsigned long mpu_speed[6];
12
13 /* functions to write and read PRCM registers */
14 void (*dsp_prm_write)(u32, s16 , u16);
15 u32 (*dsp_prm_read)(s16 , u16);
16 u32 (*dsp_prm_rmw_bits)(u32, u32, s16, s16);
17 void (*dsp_cm_write)(u32, s16 , u16);
18 u32 (*dsp_cm_read)(s16 , u16);
19 u32 (*dsp_cm_rmw_bits)(u32, u32, s16, s16);
20
21 phys_addr_t phys_mempool_base;
22 phys_addr_t phys_mempool_size;
23};
24
25#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
26extern void omap_dsp_reserve_sdram_memblock(void);
27#else
28static inline void omap_dsp_reserve_sdram_memblock(void) { }
29#endif
30
31#endif
diff --git a/arch/arm/plat-omap/include/plat/flash.h b/arch/arm/plat-omap/include/plat/flash.h
index 3e6327016b40..0d88499b79e9 100644
--- a/arch/arm/plat-omap/include/plat/flash.h
+++ b/arch/arm/plat-omap/include/plat/flash.h
@@ -11,6 +11,7 @@
11 11
12#include <linux/mtd/map.h> 12#include <linux/mtd/map.h>
13 13
14extern void omap1_set_vpp(struct map_info *map, int enable); 14struct platform_device;
15extern void omap1_set_vpp(struct platform_device *pdev, int enable);
15 16
16#endif 17#endif
diff --git a/arch/arm/plat-omap/include/plat/fpga.h b/arch/arm/plat-omap/include/plat/fpga.h
index f1864a652f7a..bd3c6324ae1f 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)
@@ -34,18 +30,18 @@ extern void omap1510_fpga_init_irq(void);
34 * --------------------------------------------------------------------------- 30 * ---------------------------------------------------------------------------
35 */ 31 */
36/* maps in the FPGA registers and the ETHR registers */ 32/* maps in the FPGA registers and the ETHR registers */
37#define H2P2_DBG_FPGA_BASE IOMEM(0xE8000000) /* VA */ 33#define H2P2_DBG_FPGA_BASE 0xE8000000 /* VA */
38#define H2P2_DBG_FPGA_SIZE SZ_4K /* SIZE */ 34#define H2P2_DBG_FPGA_SIZE SZ_4K /* SIZE */
39#define H2P2_DBG_FPGA_START 0x04000000 /* PA */ 35#define H2P2_DBG_FPGA_START 0x04000000 /* PA */
40 36
41#define H2P2_DBG_FPGA_ETHR_START (H2P2_DBG_FPGA_START + 0x300) 37#define H2P2_DBG_FPGA_ETHR_START (H2P2_DBG_FPGA_START + 0x300)
42#define H2P2_DBG_FPGA_FPGA_REV (H2P2_DBG_FPGA_BASE + 0x10) /* FPGA Revision */ 38#define H2P2_DBG_FPGA_FPGA_REV IOMEM(H2P2_DBG_FPGA_BASE + 0x10) /* FPGA Revision */
43#define H2P2_DBG_FPGA_BOARD_REV (H2P2_DBG_FPGA_BASE + 0x12) /* Board Revision */ 39#define H2P2_DBG_FPGA_BOARD_REV IOMEM(H2P2_DBG_FPGA_BASE + 0x12) /* Board Revision */
44#define H2P2_DBG_FPGA_GPIO (H2P2_DBG_FPGA_BASE + 0x14) /* GPIO outputs */ 40#define H2P2_DBG_FPGA_GPIO IOMEM(H2P2_DBG_FPGA_BASE + 0x14) /* GPIO outputs */
45#define H2P2_DBG_FPGA_LEDS (H2P2_DBG_FPGA_BASE + 0x16) /* LEDs outputs */ 41#define H2P2_DBG_FPGA_LEDS IOMEM(H2P2_DBG_FPGA_BASE + 0x16) /* LEDs outputs */
46#define H2P2_DBG_FPGA_MISC_INPUTS (H2P2_DBG_FPGA_BASE + 0x18) /* Misc inputs */ 42#define H2P2_DBG_FPGA_MISC_INPUTS IOMEM(H2P2_DBG_FPGA_BASE + 0x18) /* Misc inputs */
47#define H2P2_DBG_FPGA_LAN_STATUS (H2P2_DBG_FPGA_BASE + 0x1A) /* LAN Status line */ 43#define H2P2_DBG_FPGA_LAN_STATUS IOMEM(H2P2_DBG_FPGA_BASE + 0x1A) /* LAN Status line */
48#define H2P2_DBG_FPGA_LAN_RESET (H2P2_DBG_FPGA_BASE + 0x1C) /* LAN Reset line */ 44#define H2P2_DBG_FPGA_LAN_RESET IOMEM(H2P2_DBG_FPGA_BASE + 0x1C) /* LAN Reset line */
49 45
50/* NOTE: most boards don't have a static mapping for the FPGA ... */ 46/* NOTE: most boards don't have a static mapping for the FPGA ... */
51struct h2p2_dbg_fpga { 47struct h2p2_dbg_fpga {
@@ -85,55 +81,55 @@ struct h2p2_dbg_fpga {
85 * OMAP-1510 FPGA 81 * OMAP-1510 FPGA
86 * --------------------------------------------------------------------------- 82 * ---------------------------------------------------------------------------
87 */ 83 */
88#define OMAP1510_FPGA_BASE IOMEM(0xE8000000) /* VA */ 84#define OMAP1510_FPGA_BASE 0xE8000000 /* VA */
89#define OMAP1510_FPGA_SIZE SZ_4K 85#define OMAP1510_FPGA_SIZE SZ_4K
90#define OMAP1510_FPGA_START 0x08000000 /* PA */ 86#define OMAP1510_FPGA_START 0x08000000 /* PA */
91 87
92/* Revision */ 88/* Revision */
93#define OMAP1510_FPGA_REV_LOW (OMAP1510_FPGA_BASE + 0x0) 89#define OMAP1510_FPGA_REV_LOW IOMEM(OMAP1510_FPGA_BASE + 0x0)
94#define OMAP1510_FPGA_REV_HIGH (OMAP1510_FPGA_BASE + 0x1) 90#define OMAP1510_FPGA_REV_HIGH IOMEM(OMAP1510_FPGA_BASE + 0x1)
95 91
96#define OMAP1510_FPGA_LCD_PANEL_CONTROL (OMAP1510_FPGA_BASE + 0x2) 92#define OMAP1510_FPGA_LCD_PANEL_CONTROL IOMEM(OMAP1510_FPGA_BASE + 0x2)
97#define OMAP1510_FPGA_LED_DIGIT (OMAP1510_FPGA_BASE + 0x3) 93#define OMAP1510_FPGA_LED_DIGIT IOMEM(OMAP1510_FPGA_BASE + 0x3)
98#define INNOVATOR_FPGA_HID_SPI (OMAP1510_FPGA_BASE + 0x4) 94#define INNOVATOR_FPGA_HID_SPI IOMEM(OMAP1510_FPGA_BASE + 0x4)
99#define OMAP1510_FPGA_POWER (OMAP1510_FPGA_BASE + 0x5) 95#define OMAP1510_FPGA_POWER IOMEM(OMAP1510_FPGA_BASE + 0x5)
100 96
101/* Interrupt status */ 97/* Interrupt status */
102#define OMAP1510_FPGA_ISR_LO (OMAP1510_FPGA_BASE + 0x6) 98#define OMAP1510_FPGA_ISR_LO IOMEM(OMAP1510_FPGA_BASE + 0x6)
103#define OMAP1510_FPGA_ISR_HI (OMAP1510_FPGA_BASE + 0x7) 99#define OMAP1510_FPGA_ISR_HI IOMEM(OMAP1510_FPGA_BASE + 0x7)
104 100
105/* Interrupt mask */ 101/* Interrupt mask */
106#define OMAP1510_FPGA_IMR_LO (OMAP1510_FPGA_BASE + 0x8) 102#define OMAP1510_FPGA_IMR_LO IOMEM(OMAP1510_FPGA_BASE + 0x8)
107#define OMAP1510_FPGA_IMR_HI (OMAP1510_FPGA_BASE + 0x9) 103#define OMAP1510_FPGA_IMR_HI IOMEM(OMAP1510_FPGA_BASE + 0x9)
108 104
109/* Reset registers */ 105/* Reset registers */
110#define OMAP1510_FPGA_HOST_RESET (OMAP1510_FPGA_BASE + 0xa) 106#define OMAP1510_FPGA_HOST_RESET IOMEM(OMAP1510_FPGA_BASE + 0xa)
111#define OMAP1510_FPGA_RST (OMAP1510_FPGA_BASE + 0xb) 107#define OMAP1510_FPGA_RST IOMEM(OMAP1510_FPGA_BASE + 0xb)
112 108
113#define OMAP1510_FPGA_AUDIO (OMAP1510_FPGA_BASE + 0xc) 109#define OMAP1510_FPGA_AUDIO IOMEM(OMAP1510_FPGA_BASE + 0xc)
114#define OMAP1510_FPGA_DIP (OMAP1510_FPGA_BASE + 0xe) 110#define OMAP1510_FPGA_DIP IOMEM(OMAP1510_FPGA_BASE + 0xe)
115#define OMAP1510_FPGA_FPGA_IO (OMAP1510_FPGA_BASE + 0xf) 111#define OMAP1510_FPGA_FPGA_IO IOMEM(OMAP1510_FPGA_BASE + 0xf)
116#define OMAP1510_FPGA_UART1 (OMAP1510_FPGA_BASE + 0x14) 112#define OMAP1510_FPGA_UART1 IOMEM(OMAP1510_FPGA_BASE + 0x14)
117#define OMAP1510_FPGA_UART2 (OMAP1510_FPGA_BASE + 0x15) 113#define OMAP1510_FPGA_UART2 IOMEM(OMAP1510_FPGA_BASE + 0x15)
118#define OMAP1510_FPGA_OMAP1510_STATUS (OMAP1510_FPGA_BASE + 0x16) 114#define OMAP1510_FPGA_OMAP1510_STATUS IOMEM(OMAP1510_FPGA_BASE + 0x16)
119#define OMAP1510_FPGA_BOARD_REV (OMAP1510_FPGA_BASE + 0x18) 115#define OMAP1510_FPGA_BOARD_REV IOMEM(OMAP1510_FPGA_BASE + 0x18)
120#define OMAP1510P1_PPT_DATA (OMAP1510_FPGA_BASE + 0x100) 116#define OMAP1510P1_PPT_DATA IOMEM(OMAP1510_FPGA_BASE + 0x100)
121#define OMAP1510P1_PPT_STATUS (OMAP1510_FPGA_BASE + 0x101) 117#define OMAP1510P1_PPT_STATUS IOMEM(OMAP1510_FPGA_BASE + 0x101)
122#define OMAP1510P1_PPT_CONTROL (OMAP1510_FPGA_BASE + 0x102) 118#define OMAP1510P1_PPT_CONTROL IOMEM(OMAP1510_FPGA_BASE + 0x102)
123 119
124#define OMAP1510_FPGA_TOUCHSCREEN (OMAP1510_FPGA_BASE + 0x204) 120#define OMAP1510_FPGA_TOUCHSCREEN IOMEM(OMAP1510_FPGA_BASE + 0x204)
125 121
126#define INNOVATOR_FPGA_INFO (OMAP1510_FPGA_BASE + 0x205) 122#define INNOVATOR_FPGA_INFO IOMEM(OMAP1510_FPGA_BASE + 0x205)
127#define INNOVATOR_FPGA_LCD_BRIGHT_LO (OMAP1510_FPGA_BASE + 0x206) 123#define INNOVATOR_FPGA_LCD_BRIGHT_LO IOMEM(OMAP1510_FPGA_BASE + 0x206)
128#define INNOVATOR_FPGA_LCD_BRIGHT_HI (OMAP1510_FPGA_BASE + 0x207) 124#define INNOVATOR_FPGA_LCD_BRIGHT_HI IOMEM(OMAP1510_FPGA_BASE + 0x207)
129#define INNOVATOR_FPGA_LED_GRN_LO (OMAP1510_FPGA_BASE + 0x208) 125#define INNOVATOR_FPGA_LED_GRN_LO IOMEM(OMAP1510_FPGA_BASE + 0x208)
130#define INNOVATOR_FPGA_LED_GRN_HI (OMAP1510_FPGA_BASE + 0x209) 126#define INNOVATOR_FPGA_LED_GRN_HI IOMEM(OMAP1510_FPGA_BASE + 0x209)
131#define INNOVATOR_FPGA_LED_RED_LO (OMAP1510_FPGA_BASE + 0x20a) 127#define INNOVATOR_FPGA_LED_RED_LO IOMEM(OMAP1510_FPGA_BASE + 0x20a)
132#define INNOVATOR_FPGA_LED_RED_HI (OMAP1510_FPGA_BASE + 0x20b) 128#define INNOVATOR_FPGA_LED_RED_HI IOMEM(OMAP1510_FPGA_BASE + 0x20b)
133#define INNOVATOR_FPGA_CAM_USB_CONTROL (OMAP1510_FPGA_BASE + 0x20c) 129#define INNOVATOR_FPGA_CAM_USB_CONTROL IOMEM(OMAP1510_FPGA_BASE + 0x20c)
134#define INNOVATOR_FPGA_EXP_CONTROL (OMAP1510_FPGA_BASE + 0x20d) 130#define INNOVATOR_FPGA_EXP_CONTROL IOMEM(OMAP1510_FPGA_BASE + 0x20d)
135#define INNOVATOR_FPGA_ISR2 (OMAP1510_FPGA_BASE + 0x20e) 131#define INNOVATOR_FPGA_ISR2 IOMEM(OMAP1510_FPGA_BASE + 0x20e)
136#define INNOVATOR_FPGA_IMR2 (OMAP1510_FPGA_BASE + 0x210) 132#define INNOVATOR_FPGA_IMR2 IOMEM(OMAP1510_FPGA_BASE + 0x210)
137 133
138#define OMAP1510_FPGA_ETHR_START (OMAP1510_FPGA_START + 0x300) 134#define OMAP1510_FPGA_ETHR_START (OMAP1510_FPGA_START + 0x300)
139 135
diff --git a/arch/arm/plat-omap/include/plat/gpio.h b/arch/arm/plat-omap/include/plat/gpio.h
index de1c604962eb..ec97e00cb581 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,10 +49,112 @@
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
55/*
56 * OMAP1510 GPIO registers
57 */
58#define OMAP1510_GPIO_DATA_INPUT 0x00
59#define OMAP1510_GPIO_DATA_OUTPUT 0x04
60#define OMAP1510_GPIO_DIR_CONTROL 0x08
61#define OMAP1510_GPIO_INT_CONTROL 0x0c
62#define OMAP1510_GPIO_INT_MASK 0x10
63#define OMAP1510_GPIO_INT_STATUS 0x14
64#define OMAP1510_GPIO_PIN_CONTROL 0x18
65
66#define OMAP1510_IH_GPIO_BASE 64
67
68/*
69 * OMAP1610 specific GPIO registers
70 */
71#define OMAP1610_GPIO_REVISION 0x0000
72#define OMAP1610_GPIO_SYSCONFIG 0x0010
73#define OMAP1610_GPIO_SYSSTATUS 0x0014
74#define OMAP1610_GPIO_IRQSTATUS1 0x0018
75#define OMAP1610_GPIO_IRQENABLE1 0x001c
76#define OMAP1610_GPIO_WAKEUPENABLE 0x0028
77#define OMAP1610_GPIO_DATAIN 0x002c
78#define OMAP1610_GPIO_DATAOUT 0x0030
79#define OMAP1610_GPIO_DIRECTION 0x0034
80#define OMAP1610_GPIO_EDGE_CTRL1 0x0038
81#define OMAP1610_GPIO_EDGE_CTRL2 0x003c
82#define OMAP1610_GPIO_CLEAR_IRQENABLE1 0x009c
83#define OMAP1610_GPIO_CLEAR_WAKEUPENA 0x00a8
84#define OMAP1610_GPIO_CLEAR_DATAOUT 0x00b0
85#define OMAP1610_GPIO_SET_IRQENABLE1 0x00dc
86#define OMAP1610_GPIO_SET_WAKEUPENA 0x00e8
87#define OMAP1610_GPIO_SET_DATAOUT 0x00f0
88
89/*
90 * OMAP7XX specific GPIO registers
91 */
92#define OMAP7XX_GPIO_DATA_INPUT 0x00
93#define OMAP7XX_GPIO_DATA_OUTPUT 0x04
94#define OMAP7XX_GPIO_DIR_CONTROL 0x08
95#define OMAP7XX_GPIO_INT_CONTROL 0x0c
96#define OMAP7XX_GPIO_INT_MASK 0x10
97#define OMAP7XX_GPIO_INT_STATUS 0x14
98
99/*
100 * omap2+ specific GPIO registers
101 */
102#define OMAP24XX_GPIO_REVISION 0x0000
103#define OMAP24XX_GPIO_IRQSTATUS1 0x0018
104#define OMAP24XX_GPIO_IRQSTATUS2 0x0028
105#define OMAP24XX_GPIO_IRQENABLE2 0x002c
106#define OMAP24XX_GPIO_IRQENABLE1 0x001c
107#define OMAP24XX_GPIO_WAKE_EN 0x0020
108#define OMAP24XX_GPIO_CTRL 0x0030
109#define OMAP24XX_GPIO_OE 0x0034
110#define OMAP24XX_GPIO_DATAIN 0x0038
111#define OMAP24XX_GPIO_DATAOUT 0x003c
112#define OMAP24XX_GPIO_LEVELDETECT0 0x0040
113#define OMAP24XX_GPIO_LEVELDETECT1 0x0044
114#define OMAP24XX_GPIO_RISINGDETECT 0x0048
115#define OMAP24XX_GPIO_FALLINGDETECT 0x004c
116#define OMAP24XX_GPIO_DEBOUNCE_EN 0x0050
117#define OMAP24XX_GPIO_DEBOUNCE_VAL 0x0054
118#define OMAP24XX_GPIO_CLEARIRQENABLE1 0x0060
119#define OMAP24XX_GPIO_SETIRQENABLE1 0x0064
120#define OMAP24XX_GPIO_CLEARWKUENA 0x0080
121#define OMAP24XX_GPIO_SETWKUENA 0x0084
122#define OMAP24XX_GPIO_CLEARDATAOUT 0x0090
123#define OMAP24XX_GPIO_SETDATAOUT 0x0094
124
125#define OMAP4_GPIO_REVISION 0x0000
126#define OMAP4_GPIO_EOI 0x0020
127#define OMAP4_GPIO_IRQSTATUSRAW0 0x0024
128#define OMAP4_GPIO_IRQSTATUSRAW1 0x0028
129#define OMAP4_GPIO_IRQSTATUS0 0x002c
130#define OMAP4_GPIO_IRQSTATUS1 0x0030
131#define OMAP4_GPIO_IRQSTATUSSET0 0x0034
132#define OMAP4_GPIO_IRQSTATUSSET1 0x0038
133#define OMAP4_GPIO_IRQSTATUSCLR0 0x003c
134#define OMAP4_GPIO_IRQSTATUSCLR1 0x0040
135#define OMAP4_GPIO_IRQWAKEN0 0x0044
136#define OMAP4_GPIO_IRQWAKEN1 0x0048
137#define OMAP4_GPIO_IRQENABLE1 0x011c
138#define OMAP4_GPIO_WAKE_EN 0x0120
139#define OMAP4_GPIO_IRQSTATUS2 0x0128
140#define OMAP4_GPIO_IRQENABLE2 0x012c
141#define OMAP4_GPIO_CTRL 0x0130
142#define OMAP4_GPIO_OE 0x0134
143#define OMAP4_GPIO_DATAIN 0x0138
144#define OMAP4_GPIO_DATAOUT 0x013c
145#define OMAP4_GPIO_LEVELDETECT0 0x0140
146#define OMAP4_GPIO_LEVELDETECT1 0x0144
147#define OMAP4_GPIO_RISINGDETECT 0x0148
148#define OMAP4_GPIO_FALLINGDETECT 0x014c
149#define OMAP4_GPIO_DEBOUNCENABLE 0x0150
150#define OMAP4_GPIO_DEBOUNCINGTIME 0x0154
151#define OMAP4_GPIO_CLEARIRQENABLE1 0x0160
152#define OMAP4_GPIO_SETIRQENABLE1 0x0164
153#define OMAP4_GPIO_CLEARWKUENA 0x0180
154#define OMAP4_GPIO_SETWKUENA 0x0184
155#define OMAP4_GPIO_CLEARDATAOUT 0x0190
156#define OMAP4_GPIO_SETDATAOUT 0x0194
157
67#define OMAP_MPUIO(nr) (OMAP_MAX_GPIO_LINES + (nr)) 158#define OMAP_MPUIO(nr) (OMAP_MAX_GPIO_LINES + (nr))
68#define OMAP_GPIO_IS_MPUIO(nr) ((nr) >= OMAP_MAX_GPIO_LINES) 159#define OMAP_GPIO_IS_MPUIO(nr) ((nr) >= OMAP_MAX_GPIO_LINES)
69 160
@@ -71,8 +162,30 @@
71 IH_MPUIO_BASE + ((nr) & 0x0f) : \ 162 IH_MPUIO_BASE + ((nr) & 0x0f) : \
72 IH_GPIO_BASE + (nr)) 163 IH_GPIO_BASE + (nr))
73 164
74extern int omap_gpio_init(void); /* Call from board init only */ 165#define METHOD_MPUIO 0
75extern void omap2_gpio_prepare_for_idle(int power_state); 166#define METHOD_GPIO_1510 1
167#define METHOD_GPIO_1610 2
168#define METHOD_GPIO_7XX 3
169#define METHOD_GPIO_24XX 5
170#define METHOD_GPIO_44XX 6
171
172struct omap_gpio_dev_attr {
173 int bank_width; /* GPIO bank width */
174 bool dbck_flag; /* dbck required or not - True for OMAP3&4 */
175};
176
177struct omap_gpio_platform_data {
178 u16 virtual_irq_start;
179 int bank_type;
180 int bank_width; /* GPIO bank width */
181 int bank_stride; /* Only needed for omap1 MPUIO */
182 bool dbck_flag; /* dbck required or not - True for OMAP3&4 */
183};
184
185/* TODO: Analyze removing gpio_bank_count usage from driver code */
186extern int gpio_bank_count;
187
188extern void omap2_gpio_prepare_for_idle(int off_mode);
76extern void omap2_gpio_resume_after_idle(void); 189extern void omap2_gpio_resume_after_idle(void);
77extern void omap_set_gpio_debounce(int gpio, int enable); 190extern void omap_set_gpio_debounce(int gpio, int enable);
78extern void omap_set_gpio_debounce_time(int gpio, int enable); 191extern void omap_set_gpio_debounce_time(int gpio, int enable);
@@ -83,7 +196,7 @@ extern void omap_gpio_restore_context(void);
83/* Wrappers for "new style" GPIO calls, using the new infrastructure 196/* Wrappers for "new style" GPIO calls, using the new infrastructure
84 * which lets us plug in FPGA, I2C, and other implementations. 197 * which lets us plug in FPGA, I2C, and other implementations.
85 * * 198 * *
86 * The original OMAP-specfic calls should eventually be removed. 199 * The original OMAP-specific calls should eventually be removed.
87 */ 200 */
88 201
89#include <linux/errno.h> 202#include <linux/errno.h>
diff --git a/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h b/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h
new file mode 100644
index 000000000000..ea6c9c88c725
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h
@@ -0,0 +1,35 @@
1/*
2 * arch/arm/plat-omap/include/plat/gpmc-smsc911x.h
3 *
4 * Copyright (C) 2009 Li-Pro.Net
5 * Stephan Linz <linz@li-pro.net>
6 *
7 * Modified from arch/arm/plat-omap/include/plat/gpmc-smc91x.h
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_ARCH_OMAP_GPMC_SMSC911X_H__
15
16struct omap_smsc911x_platform_data {
17 int id;
18 int cs;
19 int gpio_irq;
20 int gpio_reset;
21 u32 flags;
22};
23
24#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
25
26extern void gpmc_smsc911x_init(struct omap_smsc911x_platform_data *d);
27
28#else
29
30static inline void gpmc_smsc911x_init(struct omap_smsc911x_platform_data *d)
31{
32}
33
34#endif
35#endif
diff --git a/arch/arm/plat-omap/include/plat/gpmc.h b/arch/arm/plat-omap/include/plat/gpmc.h
index 9fd99b9e40ab..1527929b445a 100644
--- a/arch/arm/plat-omap/include/plat/gpmc.h
+++ b/arch/arm/plat-omap/include/plat/gpmc.h
@@ -41,6 +41,8 @@
41#define GPMC_NAND_ADDRESS 0x0000000b 41#define GPMC_NAND_ADDRESS 0x0000000b
42#define GPMC_NAND_DATA 0x0000000c 42#define GPMC_NAND_DATA 0x0000000c
43 43
44#define GPMC_ENABLE_IRQ 0x0000000d
45
44/* ECC commands */ 46/* ECC commands */
45#define GPMC_ECC_READ 0 /* Reset Hardware ECC for read */ 47#define GPMC_ECC_READ 0 /* Reset Hardware ECC for read */
46#define GPMC_ECC_WRITE 1 /* Reset Hardware ECC for write */ 48#define GPMC_ECC_WRITE 1 /* Reset Hardware ECC for write */
@@ -78,14 +80,27 @@
78#define WR_RD_PIN_MONITORING 0x00600000 80#define WR_RD_PIN_MONITORING 0x00600000
79#define GPMC_PREFETCH_STATUS_FIFO_CNT(val) ((val >> 24) & 0x7F) 81#define GPMC_PREFETCH_STATUS_FIFO_CNT(val) ((val >> 24) & 0x7F)
80#define GPMC_PREFETCH_STATUS_COUNT(val) (val & 0x00003fff) 82#define GPMC_PREFETCH_STATUS_COUNT(val) (val & 0x00003fff)
83#define GPMC_IRQ_FIFOEVENTENABLE 0x01
84#define GPMC_IRQ_COUNT_EVENT 0x02
85
86#define PREFETCH_FIFOTHRESHOLD_MAX 0x40
87#define PREFETCH_FIFOTHRESHOLD(val) ((val) << 8)
88
89enum omap_ecc {
90 /* 1-bit ecc: stored at end of spare area */
91 OMAP_ECC_HAMMING_CODE_DEFAULT = 0, /* Default, s/w method */
92 OMAP_ECC_HAMMING_CODE_HW, /* gpmc to detect the error */
93 /* 1-bit ecc: stored at beginning of spare area as romcode */
94 OMAP_ECC_HAMMING_CODE_HW_ROMCODE, /* gpmc method & romcode layout */
95};
81 96
82/* 97/*
83 * Note that all values in this struct are in nanoseconds, while 98 * Note that all values in this struct are in nanoseconds except sync_clk
84 * the register values are in gpmc_fck cycles. 99 * (which is in picoseconds), while the register values are in gpmc_fck cycles.
85 */ 100 */
86struct gpmc_timings { 101struct gpmc_timings {
87 /* Minimum clock period for synchronous mode */ 102 /* Minimum clock period for synchronous mode (in picoseconds) */
88 u16 sync_clk; 103 u32 sync_clk;
89 104
90 /* Chip-select signal timings corresponding to GPMC_CS_CONFIG2 */ 105 /* Chip-select signal timings corresponding to GPMC_CS_CONFIG2 */
91 u16 cs_on; /* Assertion time */ 106 u16 cs_on; /* Assertion time */
@@ -117,6 +132,7 @@ struct gpmc_timings {
117}; 132};
118 133
119extern unsigned int gpmc_ns_to_ticks(unsigned int time_ns); 134extern unsigned int gpmc_ns_to_ticks(unsigned int time_ns);
135extern unsigned int gpmc_ps_to_ticks(unsigned int time_ps);
120extern unsigned int gpmc_ticks_to_ns(unsigned int ticks); 136extern unsigned int gpmc_ticks_to_ns(unsigned int ticks);
121extern unsigned int gpmc_round_ns_to_ticks(unsigned int time_ns); 137extern unsigned int gpmc_round_ns_to_ticks(unsigned int time_ns);
122extern unsigned long gpmc_get_fclk_period(void); 138extern unsigned long gpmc_get_fclk_period(void);
@@ -129,12 +145,11 @@ extern int gpmc_cs_request(int cs, unsigned long size, unsigned long *base);
129extern void gpmc_cs_free(int cs); 145extern void gpmc_cs_free(int cs);
130extern int gpmc_cs_set_reserved(int cs, int reserved); 146extern int gpmc_cs_set_reserved(int cs, int reserved);
131extern int gpmc_cs_reserved(int cs); 147extern int gpmc_cs_reserved(int cs);
132extern int gpmc_prefetch_enable(int cs, int dma_mode, 148extern int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
133 unsigned int u32_count, int is_write); 149 unsigned int u32_count, int is_write);
134extern int gpmc_prefetch_reset(int cs); 150extern int gpmc_prefetch_reset(int cs);
135extern void omap3_gpmc_save_context(void); 151extern void omap3_gpmc_save_context(void);
136extern void omap3_gpmc_restore_context(void); 152extern void omap3_gpmc_restore_context(void);
137extern void gpmc_init(void);
138extern int gpmc_read_status(int cmd); 153extern int gpmc_read_status(int cmd);
139extern int gpmc_cs_configure(int cs, int cmd, int wval); 154extern int gpmc_cs_configure(int cs, int cmd, int wval);
140extern int gpmc_nand_read(int cs, int cmd); 155extern int gpmc_nand_read(int cs, int cmd);
diff --git a/arch/arm/plat-omap/include/plat/hardware.h b/arch/arm/plat-omap/include/plat/hardware.h
index d5b26adfb890..e87efe1499b8 100644
--- a/arch/arm/plat-omap/include/plat/hardware.h
+++ b/arch/arm/plat-omap/include/plat/hardware.h
@@ -286,5 +286,6 @@
286#include <plat/omap24xx.h> 286#include <plat/omap24xx.h>
287#include <plat/omap34xx.h> 287#include <plat/omap34xx.h>
288#include <plat/omap44xx.h> 288#include <plat/omap44xx.h>
289#include <plat/ti816x.h>
289 290
290#endif /* __ASM_ARCH_OMAP_HARDWARE_H */ 291#endif /* __ASM_ARCH_OMAP_HARDWARE_H */
diff --git a/arch/arm/plat-omap/include/plat/i2c.h b/arch/arm/plat-omap/include/plat/i2c.h
index 87f6bf2ea4fa..878d632c4092 100644
--- a/arch/arm/plat-omap/include/plat/i2c.h
+++ b/arch/arm/plat-omap/include/plat/i2c.h
@@ -18,6 +18,8 @@
18 * 02110-1301 USA 18 * 02110-1301 USA
19 * 19 *
20 */ 20 */
21#ifndef __ASM__ARCH_OMAP_I2C_H
22#define __ASM__ARCH_OMAP_I2C_H
21 23
22#include <linux/i2c.h> 24#include <linux/i2c.h>
23 25
@@ -34,5 +36,20 @@ static inline int omap_register_i2c_bus(int bus_id, u32 clkrate,
34} 36}
35#endif 37#endif
36 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
37void __init omap1_i2c_mux_pins(int bus_id); 52void __init omap1_i2c_mux_pins(int bus_id);
38void __init omap2_i2c_mux_pins(int bus_id); 53void __init omap2_i2c_mux_pins(int bus_id);
54
55#endif /* __ASM__ARCH_OMAP_I2C_H */
diff --git a/arch/arm/plat-omap/include/plat/io.h b/arch/arm/plat-omap/include/plat/io.h
index 128b549c2796..d72ec85c97e6 100644
--- a/arch/arm/plat-omap/include/plat/io.h
+++ b/arch/arm/plat-omap/include/plat/io.h
@@ -259,7 +259,7 @@ struct omap_sdrc_params;
259extern void omap1_map_common_io(void); 259extern void omap1_map_common_io(void);
260extern void omap1_init_common_hw(void); 260extern void omap1_init_common_hw(void);
261 261
262#ifdef CONFIG_ARCH_OMAP2420 262#ifdef CONFIG_SOC_OMAP2420
263extern void omap242x_map_common_io(void); 263extern void omap242x_map_common_io(void);
264#else 264#else
265static inline void omap242x_map_common_io(void) 265static inline void omap242x_map_common_io(void)
@@ -267,7 +267,7 @@ static inline void omap242x_map_common_io(void)
267} 267}
268#endif 268#endif
269 269
270#ifdef CONFIG_ARCH_OMAP2430 270#ifdef CONFIG_SOC_OMAP2430
271extern void omap243x_map_common_io(void); 271extern void omap243x_map_common_io(void);
272#else 272#else
273static inline void omap243x_map_common_io(void) 273static inline void omap243x_map_common_io(void)
@@ -283,6 +283,14 @@ static inline void omap34xx_map_common_io(void)
283} 283}
284#endif 284#endif
285 285
286#ifdef CONFIG_SOC_OMAPTI816X
287extern void omapti816x_map_common_io(void);
288#else
289static inline void omapti816x_map_common_io(void)
290{
291}
292#endif
293
286#ifdef CONFIG_ARCH_OMAP4 294#ifdef CONFIG_ARCH_OMAP4
287extern void omap44xx_map_common_io(void); 295extern void omap44xx_map_common_io(void);
288#else 296#else
@@ -291,11 +299,12 @@ static inline void omap44xx_map_common_io(void)
291} 299}
292#endif 300#endif
293 301
294extern void omap2_init_common_hw(struct omap_sdrc_params *sdrc_cs0, 302extern void omap2_init_common_infrastructure(void);
295 struct omap_sdrc_params *sdrc_cs1); 303extern void omap2_init_common_devices(struct omap_sdrc_params *sdrc_cs0,
304 struct omap_sdrc_params *sdrc_cs1);
296 305
297#define __arch_ioremap(p,s,t) omap_ioremap(p,s,t) 306#define __arch_ioremap omap_ioremap
298#define __arch_iounmap(v) omap_iounmap(v) 307#define __arch_iounmap omap_iounmap
299 308
300void __iomem *omap_ioremap(unsigned long phys, size_t size, unsigned int type); 309void __iomem *omap_ioremap(unsigned long phys, size_t size, unsigned int type);
301void omap_iounmap(volatile void __iomem *addr); 310void omap_iounmap(volatile void __iomem *addr);
diff --git a/arch/arm/plat-omap/include/plat/iommu.h b/arch/arm/plat-omap/include/plat/iommu.h
index 33c7d41cb6a5..174f1b9c8c03 100644
--- a/arch/arm/plat-omap/include/plat/iommu.h
+++ b/arch/arm/plat-omap/include/plat/iommu.h
@@ -31,6 +31,7 @@ struct iommu {
31 struct clk *clk; 31 struct clk *clk;
32 void __iomem *regbase; 32 void __iomem *regbase;
33 struct device *dev; 33 struct device *dev;
34 void *isr_priv;
34 35
35 unsigned int refcount; 36 unsigned int refcount;
36 struct mutex iommu_lock; /* global for this whole object */ 37 struct mutex iommu_lock; /* global for this whole object */
@@ -47,9 +48,11 @@ struct iommu {
47 struct list_head mmap; 48 struct list_head mmap;
48 struct mutex mmap_lock; /* protect mmap */ 49 struct mutex mmap_lock; /* protect mmap */
49 50
50 int (*isr)(struct iommu *obj); 51 int (*isr)(struct iommu *obj, u32 da, u32 iommu_errs, void *priv);
51 52
52 void *ctx; /* iommu context: registres saved area */ 53 void *ctx; /* iommu context: registres saved area */
54 u32 da_start;
55 u32 da_end;
53}; 56};
54 57
55struct cr_regs { 58struct cr_regs {
@@ -103,8 +106,17 @@ struct iommu_platform_data {
103 const char *name; 106 const char *name;
104 const char *clk_name; 107 const char *clk_name;
105 const int nr_tlb_entries; 108 const int nr_tlb_entries;
109 u32 da_start;
110 u32 da_end;
106}; 111};
107 112
113/* IOMMU errors */
114#define OMAP_IOMMU_ERR_TLB_MISS (1 << 0)
115#define OMAP_IOMMU_ERR_TRANS_FAULT (1 << 1)
116#define OMAP_IOMMU_ERR_EMU_MISS (1 << 2)
117#define OMAP_IOMMU_ERR_TBLWALK_FAULT (1 << 3)
118#define OMAP_IOMMU_ERR_MULTIHIT_FAULT (1 << 4)
119
108#if defined(CONFIG_ARCH_OMAP1) 120#if defined(CONFIG_ARCH_OMAP1)
109#error "iommu for this processor not implemented yet" 121#error "iommu for this processor not implemented yet"
110#else 122#else
@@ -150,10 +162,17 @@ extern void flush_iotlb_range(struct iommu *obj, u32 start, u32 end);
150extern void flush_iotlb_all(struct iommu *obj); 162extern void flush_iotlb_all(struct iommu *obj);
151 163
152extern int iopgtable_store_entry(struct iommu *obj, struct iotlb_entry *e); 164extern int iopgtable_store_entry(struct iommu *obj, struct iotlb_entry *e);
165extern void iopgtable_lookup_entry(struct iommu *obj, u32 da, u32 **ppgd,
166 u32 **ppte);
153extern size_t iopgtable_clear_entry(struct iommu *obj, u32 iova); 167extern size_t iopgtable_clear_entry(struct iommu *obj, u32 iova);
154 168
169extern int iommu_set_da_range(struct iommu *obj, u32 start, u32 end);
155extern struct iommu *iommu_get(const char *name); 170extern struct iommu *iommu_get(const char *name);
156extern void iommu_put(struct iommu *obj); 171extern void iommu_put(struct iommu *obj);
172extern int iommu_set_isr(const char *name,
173 int (*isr)(struct iommu *obj, u32 da, u32 iommu_errs,
174 void *priv),
175 void *isr_priv);
157 176
158extern void iommu_save_ctx(struct iommu *obj); 177extern void iommu_save_ctx(struct iommu *obj);
159extern void iommu_restore_ctx(struct iommu *obj); 178extern void iommu_restore_ctx(struct iommu *obj);
diff --git a/arch/arm/plat-omap/include/plat/iovmm.h b/arch/arm/plat-omap/include/plat/iovmm.h
index bdc7ce5d7a4a..e992b9655fbc 100644
--- a/arch/arm/plat-omap/include/plat/iovmm.h
+++ b/arch/arm/plat-omap/include/plat/iovmm.h
@@ -29,9 +29,6 @@ struct iovm_struct {
29 * lower 16 bit is used for h/w and upper 16 bit is for s/w. 29 * lower 16 bit is used for h/w and upper 16 bit is for s/w.
30 */ 30 */
31#define IOVMF_SW_SHIFT 16 31#define IOVMF_SW_SHIFT 16
32#define IOVMF_HW_SIZE (1 << IOVMF_SW_SHIFT)
33#define IOVMF_HW_MASK (IOVMF_HW_SIZE - 1)
34#define IOVMF_SW_MASK (~IOVMF_HW_MASK)UL
35 32
36/* 33/*
37 * iovma: h/w flags derived from cam and ram attribute 34 * iovma: h/w flags derived from cam and ram attribute
@@ -71,8 +68,6 @@ struct iovm_struct {
71#define IOVMF_LINEAR_MASK (3 << (2 + IOVMF_SW_SHIFT)) 68#define IOVMF_LINEAR_MASK (3 << (2 + IOVMF_SW_SHIFT))
72 69
73#define IOVMF_DA_FIXED (1 << (4 + IOVMF_SW_SHIFT)) 70#define IOVMF_DA_FIXED (1 << (4 + IOVMF_SW_SHIFT))
74#define IOVMF_DA_ANON (2 << (4 + IOVMF_SW_SHIFT))
75#define IOVMF_DA_MASK (3 << (4 + IOVMF_SW_SHIFT))
76 71
77 72
78extern struct iovm_struct *find_iovm_area(struct iommu *obj, u32 da); 73extern struct iovm_struct *find_iovm_area(struct iommu *obj, u32 da);
diff --git a/arch/arm/plat-omap/include/plat/irqs.h b/arch/arm/plat-omap/include/plat/irqs.h
index c01d9f08a198..5a25098ea7ea 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
@@ -315,9 +315,12 @@
315#define INT_34XX_SSM_ABORT_IRQ 6 315#define INT_34XX_SSM_ABORT_IRQ 6
316#define INT_34XX_SYS_NIRQ 7 316#define INT_34XX_SYS_NIRQ 7
317#define INT_34XX_D2D_FW_IRQ 8 317#define INT_34XX_D2D_FW_IRQ 8
318#define INT_34XX_L3_DBG_IRQ 9
319#define INT_34XX_L3_APP_IRQ 10
318#define INT_34XX_PRCM_MPU_IRQ 11 320#define INT_34XX_PRCM_MPU_IRQ 11
319#define INT_34XX_MCBSP1_IRQ 16 321#define INT_34XX_MCBSP1_IRQ 16
320#define INT_34XX_MCBSP2_IRQ 17 322#define INT_34XX_MCBSP2_IRQ 17
323#define INT_34XX_GPMC_IRQ 20
321#define INT_34XX_MCBSP3_IRQ 22 324#define INT_34XX_MCBSP3_IRQ 22
322#define INT_34XX_MCBSP4_IRQ 23 325#define INT_34XX_MCBSP4_IRQ 23
323#define INT_34XX_CAM_IRQ 24 326#define INT_34XX_CAM_IRQ 24
@@ -345,6 +348,8 @@
345#define INT_34XX_MMC3_IRQ 94 348#define INT_34XX_MMC3_IRQ 94
346#define INT_34XX_GPT12_IRQ 95 349#define INT_34XX_GPT12_IRQ 95
347 350
351#define INT_36XX_UART4_IRQ 80
352
348#define INT_35XX_HECC0_IRQ 24 353#define INT_35XX_HECC0_IRQ 24
349#define INT_35XX_HECC1_IRQ 28 354#define INT_35XX_HECC1_IRQ 28
350#define INT_35XX_EMAC_C0_RXTHRESH_IRQ 67 355#define INT_35XX_EMAC_C0_RXTHRESH_IRQ 67
@@ -409,7 +414,13 @@
409#define TWL_IRQ_END TWL6030_IRQ_END 414#define TWL_IRQ_END TWL6030_IRQ_END
410#endif 415#endif
411 416
412#define NR_IRQS TWL_IRQ_END 417/* GPMC related */
418#define OMAP_GPMC_IRQ_BASE (TWL_IRQ_END)
419#define OMAP_GPMC_NR_IRQS 8
420#define OMAP_GPMC_IRQ_END (OMAP_GPMC_IRQ_BASE + OMAP_GPMC_NR_IRQS)
421
422
423#define NR_IRQS OMAP_GPMC_IRQ_END
413 424
414#define OMAP_IRQ_BIT(irq) (1 << ((irq) % 32)) 425#define OMAP_IRQ_BIT(irq) (1 << ((irq) % 32))
415 426
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/l3_2xxx.h b/arch/arm/plat-omap/include/plat/l3_2xxx.h
new file mode 100644
index 000000000000..b8b5641379b0
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/l3_2xxx.h
@@ -0,0 +1,20 @@
1/*
2 * arch/arm/plat-omap/include/plat/l3_2xxx.h - L3 firewall definitions
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
5 * Sumit Semwal
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_PLAT_L3_2XXX_H
14#define __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_L3_2XXX_H
15
16/* L3 CONNIDs */
17/* Display Sub system (DSS) */
18#define OMAP2_L3_CORE_FW_CONNID_DSS 8
19
20#endif
diff --git a/arch/arm/plat-omap/include/plat/l3_3xxx.h b/arch/arm/plat-omap/include/plat/l3_3xxx.h
new file mode 100644
index 000000000000..cde1938c5f82
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/l3_3xxx.h
@@ -0,0 +1,20 @@
1/*
2 * arch/arm/plat-omap/include/plat/l3_3xxx.h - L3 firewall definitions
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
5 * Sumit Semwal
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_PLAT_L3_3XXX_H
14#define __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_L3_3XXX_H
15
16/* L3 Initiator IDs */
17/* Display Sub system (DSS) */
18#define OMAP3_L3_CORE_FW_INIT_ID_DSS 29
19
20#endif
diff --git a/arch/arm/plat-omap/include/plat/l4_2xxx.h b/arch/arm/plat-omap/include/plat/l4_2xxx.h
new file mode 100644
index 000000000000..3f39cf8a35c6
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/l4_2xxx.h
@@ -0,0 +1,24 @@
1/*
2 * arch/arm/plat-omap/include/plat/l4_2xxx.h - L4 firewall definitions
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
5 * Sumit Semwal
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_PLAT_L4_2XXX_H
14#define __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_L4_2XXX_H
15
16/* L4 CORE */
17/* Display Sub system (DSS) */
18#define OMAP2420_L4_CORE_FW_DSS_CORE_REGION 28
19#define OMAP2420_L4_CORE_FW_DSS_DISPC_REGION 29
20#define OMAP2420_L4_CORE_FW_DSS_RFBI_REGION 30
21#define OMAP2420_L4_CORE_FW_DSS_VENC_REGION 31
22#define OMAP2420_L4_CORE_FW_DSS_TA_REGION 32
23
24#endif
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..881a858b1ffc
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/l4_3xxx.h
@@ -0,0 +1,34 @@
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/* Display Sub system (DSS) */
25#define OMAP3_L4_CORE_FW_DSS_PROT_GROUP 2
26
27#define OMAP3_L4_CORE_FW_DSS_DSI_REGION 104
28#define OMAP3ES1_L4_CORE_FW_DSS_CORE_REGION 3
29#define OMAP3_L4_CORE_FW_DSS_CORE_REGION 4
30#define OMAP3_L4_CORE_FW_DSS_DISPC_REGION 4
31#define OMAP3_L4_CORE_FW_DSS_RFBI_REGION 5
32#define OMAP3_L4_CORE_FW_DSS_VENC_REGION 6
33#define OMAP3_L4_CORE_FW_DSS_TA_REGION 7
34#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/mcbsp.h b/arch/arm/plat-omap/include/plat/mcbsp.h
index b4ff6a11a8f2..f8f690ab2997 100644
--- a/arch/arm/plat-omap/include/plat/mcbsp.h
+++ b/arch/arm/plat-omap/include/plat/mcbsp.h
@@ -30,6 +30,17 @@
30#include <mach/hardware.h> 30#include <mach/hardware.h>
31#include <plat/clock.h> 31#include <plat/clock.h>
32 32
33/* macro for building platform_device for McBSP ports */
34#define OMAP_MCBSP_PLATFORM_DEVICE(port_nr) \
35static struct platform_device omap_mcbsp##port_nr = { \
36 .name = "omap-mcbsp-dai", \
37 .id = OMAP_MCBSP##port_nr, \
38}
39
40#define MCBSP_CONFIG_TYPE2 0x2
41#define MCBSP_CONFIG_TYPE3 0x3
42#define MCBSP_CONFIG_TYPE4 0x4
43
33#define OMAP7XX_MCBSP1_BASE 0xfffb1000 44#define OMAP7XX_MCBSP1_BASE 0xfffb1000
34#define OMAP7XX_MCBSP2_BASE 0xfffb1800 45#define OMAP7XX_MCBSP2_BASE 0xfffb1800
35 46
@@ -41,32 +52,14 @@
41#define OMAP1610_MCBSP2_BASE 0xfffb1000 52#define OMAP1610_MCBSP2_BASE 0xfffb1000
42#define OMAP1610_MCBSP3_BASE 0xe1017000 53#define OMAP1610_MCBSP3_BASE 0xe1017000
43 54
44#define OMAP24XX_MCBSP1_BASE 0x48074000 55#ifdef CONFIG_ARCH_OMAP1
45#define OMAP24XX_MCBSP2_BASE 0x48076000
46#define OMAP2430_MCBSP3_BASE 0x4808c000
47#define OMAP2430_MCBSP4_BASE 0x4808e000
48#define OMAP2430_MCBSP5_BASE 0x48096000
49
50#define OMAP34XX_MCBSP1_BASE 0x48074000
51#define OMAP34XX_MCBSP2_BASE 0x49022000
52#define OMAP34XX_MCBSP2_ST_BASE 0x49028000
53#define OMAP34XX_MCBSP3_BASE 0x49024000
54#define OMAP34XX_MCBSP3_ST_BASE 0x4902A000
55#define OMAP34XX_MCBSP3_BASE 0x49024000
56#define OMAP34XX_MCBSP4_BASE 0x49026000
57#define OMAP34XX_MCBSP5_BASE 0x48096000
58
59#define OMAP44XX_MCBSP1_BASE 0x49022000
60#define OMAP44XX_MCBSP2_BASE 0x49024000
61#define OMAP44XX_MCBSP3_BASE 0x49026000
62#define OMAP44XX_MCBSP4_BASE 0x48096000
63
64#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
65 56
66#define OMAP_MCBSP_REG_DRR2 0x00 57#define OMAP_MCBSP_REG_DRR2 0x00
67#define OMAP_MCBSP_REG_DRR1 0x02 58#define OMAP_MCBSP_REG_DRR1 0x02
68#define OMAP_MCBSP_REG_DXR2 0x04 59#define OMAP_MCBSP_REG_DXR2 0x04
69#define OMAP_MCBSP_REG_DXR1 0x06 60#define OMAP_MCBSP_REG_DXR1 0x06
61#define OMAP_MCBSP_REG_DRR 0x02
62#define OMAP_MCBSP_REG_DXR 0x06
70#define OMAP_MCBSP_REG_SPCR2 0x08 63#define OMAP_MCBSP_REG_SPCR2 0x08
71#define OMAP_MCBSP_REG_SPCR1 0x0a 64#define OMAP_MCBSP_REG_SPCR1 0x0a
72#define OMAP_MCBSP_REG_RCR2 0x0c 65#define OMAP_MCBSP_REG_RCR2 0x0c
@@ -99,13 +92,6 @@
99#define OMAP_MCBSP_REG_XCCR 0x00 92#define OMAP_MCBSP_REG_XCCR 0x00
100#define OMAP_MCBSP_REG_RCCR 0x00 93#define OMAP_MCBSP_REG_RCCR 0x00
101 94
102#define AUDIO_MCBSP_DATAWRITE (OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DXR1)
103#define AUDIO_MCBSP_DATAREAD (OMAP1510_MCBSP1_BASE + OMAP_MCBSP_REG_DRR1)
104
105#define AUDIO_MCBSP OMAP_MCBSP1
106#define AUDIO_DMA_TX OMAP_DMA_MCBSP1_TX
107#define AUDIO_DMA_RX OMAP_DMA_MCBSP1_RX
108
109#else 95#else
110 96
111#define OMAP_MCBSP_REG_DRR2 0x00 97#define OMAP_MCBSP_REG_DRR2 0x00
@@ -161,13 +147,6 @@
161#define OMAP_ST_REG_SFIRCR 0x28 147#define OMAP_ST_REG_SFIRCR 0x28
162#define OMAP_ST_REG_SSELCR 0x2C 148#define OMAP_ST_REG_SSELCR 0x2C
163 149
164#define AUDIO_MCBSP_DATAWRITE (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DXR1)
165#define AUDIO_MCBSP_DATAREAD (OMAP24XX_MCBSP2_BASE + OMAP_MCBSP_REG_DRR1)
166
167#define AUDIO_MCBSP OMAP_MCBSP2
168#define AUDIO_DMA_TX OMAP24XX_DMA_MCBSP2_TX
169#define AUDIO_DMA_RX OMAP24XX_DMA_MCBSP2_RX
170
171#endif 150#endif
172 151
173/************************** McBSP SPCR1 bit definitions ***********************/ 152/************************** McBSP SPCR1 bit definitions ***********************/
@@ -312,6 +291,18 @@
312#define RFSREN 0x0002 291#define RFSREN 0x0002
313#define RSYNCERREN 0x0001 292#define RSYNCERREN 0x0001
314 293
294/* CLKR signal muxing options */
295#define CLKR_SRC_CLKR 0
296#define CLKR_SRC_CLKX 1
297
298/* FSR signal muxing options */
299#define FSR_SRC_FSR 0
300#define FSR_SRC_FSX 1
301
302/* McBSP functional clock sources */
303#define MCBSP_CLKS_PRCM_SRC 0
304#define MCBSP_CLKS_PAD_SRC 1
305
315/* we don't do multichannel for now */ 306/* we don't do multichannel for now */
316struct omap_mcbsp_reg_cfg { 307struct omap_mcbsp_reg_cfg {
317 u16 spcr2; 308 u16 spcr2;
@@ -398,6 +389,7 @@ struct omap_mcbsp_spi_cfg {
398struct omap_mcbsp_ops { 389struct omap_mcbsp_ops {
399 void (*request)(unsigned int); 390 void (*request)(unsigned int);
400 void (*free)(unsigned int); 391 void (*free)(unsigned int);
392 int (*set_clks_src)(u8, u8);
401}; 393};
402 394
403struct omap_mcbsp_platform_data { 395struct omap_mcbsp_platform_data {
@@ -408,8 +400,9 @@ struct omap_mcbsp_platform_data {
408#ifdef CONFIG_ARCH_OMAP3 400#ifdef CONFIG_ARCH_OMAP3
409 /* Sidetone block for McBSP 2 and 3 */ 401 /* Sidetone block for McBSP 2 and 3 */
410 unsigned long phys_base_st; 402 unsigned long phys_base_st;
411 u16 buffer_size;
412#endif 403#endif
404 u16 buffer_size;
405 unsigned int mcbsp_config_type;
413}; 406};
414 407
415struct omap_mcbsp_st_data { 408struct omap_mcbsp_st_data {
@@ -425,6 +418,7 @@ struct omap_mcbsp_st_data {
425struct omap_mcbsp { 418struct omap_mcbsp {
426 struct device *dev; 419 struct device *dev;
427 unsigned long phys_base; 420 unsigned long phys_base;
421 unsigned long phys_dma_base;
428 void __iomem *io_base; 422 void __iomem *io_base;
429 u8 id; 423 u8 id;
430 u8 free; 424 u8 free;
@@ -451,7 +445,6 @@ struct omap_mcbsp {
451 /* Protect the field .free, while checking if the mcbsp is in use */ 445 /* Protect the field .free, while checking if the mcbsp is in use */
452 spinlock_t lock; 446 spinlock_t lock;
453 struct omap_mcbsp_platform_data *pdata; 447 struct omap_mcbsp_platform_data *pdata;
454 struct clk *iclk;
455 struct clk *fclk; 448 struct clk *fclk;
456#ifdef CONFIG_ARCH_OMAP3 449#ifdef CONFIG_ARCH_OMAP3
457 struct omap_mcbsp_st_data *st_data; 450 struct omap_mcbsp_st_data *st_data;
@@ -460,13 +453,26 @@ struct omap_mcbsp {
460 u16 max_rx_thres; 453 u16 max_rx_thres;
461#endif 454#endif
462 void *reg_cache; 455 void *reg_cache;
456 unsigned int mcbsp_config_type;
457};
458
459/**
460 * omap_mcbsp_dev_attr - OMAP McBSP device attributes for omap_hwmod
461 * @sidetone: name of the sidetone device
462 */
463struct omap_mcbsp_dev_attr {
464 const char *sidetone;
463}; 465};
466
464extern struct omap_mcbsp **mcbsp_ptr; 467extern struct omap_mcbsp **mcbsp_ptr;
465extern int omap_mcbsp_count, omap_mcbsp_cache_size; 468extern int omap_mcbsp_count, omap_mcbsp_cache_size;
466 469
470#define omap_mcbsp_check_valid_id(id) (id < omap_mcbsp_count)
471#define id_to_mcbsp_ptr(id) mcbsp_ptr[id];
472
467int omap_mcbsp_init(void); 473int omap_mcbsp_init(void);
468void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config, 474void omap_mcbsp_register_board_cfg(struct resource *res, int res_count,
469 int size); 475 struct omap_mcbsp_platform_data *config, int size);
470void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config); 476void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config);
471#ifdef CONFIG_ARCH_OMAP3 477#ifdef CONFIG_ARCH_OMAP3
472void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold); 478void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold);
@@ -502,6 +508,8 @@ int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word);
502int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word); 508int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word);
503 509
504 510
511/* McBSP functional clock source changing function */
512extern int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id);
505/* SPI specific API */ 513/* SPI specific API */
506void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg * spi_cfg); 514void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg * spi_cfg);
507 515
@@ -510,6 +518,13 @@ int omap_mcbsp_pollread(unsigned int id, u16 * buf);
510int omap_mcbsp_pollwrite(unsigned int id, u16 buf); 518int omap_mcbsp_pollwrite(unsigned int id, u16 buf);
511int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type); 519int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type);
512 520
521/* McBSP signal muxing API */
522void omap2_mcbsp1_mux_clkr_src(u8 mux);
523void omap2_mcbsp1_mux_fsr_src(u8 mux);
524
525int omap_mcbsp_dma_ch_params(unsigned int id, unsigned int stream);
526int omap_mcbsp_dma_reg_params(unsigned int id, unsigned int stream);
527
513#ifdef CONFIG_ARCH_OMAP3 528#ifdef CONFIG_ARCH_OMAP3
514/* Sidetone specific API */ 529/* Sidetone specific API */
515int omap_st_set_chgain(unsigned int id, int channel, s16 chgain); 530int omap_st_set_chgain(unsigned int id, int channel, s16 chgain);
diff --git a/arch/arm/plat-omap/include/plat/mcspi.h b/arch/arm/plat-omap/include/plat/mcspi.h
index 1254e4945b6f..3d51b18131cc 100644
--- a/arch/arm/plat-omap/include/plat/mcspi.h
+++ b/arch/arm/plat-omap/include/plat/mcspi.h
@@ -1,8 +1,19 @@
1#ifndef _OMAP2_MCSPI_H 1#ifndef _OMAP2_MCSPI_H
2#define _OMAP2_MCSPI_H 2#define _OMAP2_MCSPI_H
3 3
4#define OMAP2_MCSPI_REV 0
5#define OMAP3_MCSPI_REV 1
6#define OMAP4_MCSPI_REV 2
7
8#define OMAP4_MCSPI_REG_OFFSET 0x100
9
4struct omap2_mcspi_platform_config { 10struct omap2_mcspi_platform_config {
5 unsigned short num_cs; 11 unsigned short num_cs;
12 unsigned int regs_offset;
13};
14
15struct omap2_mcspi_dev_attr {
16 unsigned short num_chipselect;
6}; 17};
7 18
8struct omap2_mcspi_device_config { 19struct omap2_mcspi_device_config {
diff --git a/arch/arm/plat-omap/include/plat/memory.h b/arch/arm/plat-omap/include/plat/memory.h
index d5306bee44b2..e6720aa2d553 100644
--- a/arch/arm/plat-omap/include/plat/memory.h
+++ b/arch/arm/plat-omap/include/plat/memory.h
@@ -37,9 +37,9 @@
37 * Physical DRAM offset. 37 * Physical DRAM offset.
38 */ 38 */
39#if defined(CONFIG_ARCH_OMAP1) 39#if defined(CONFIG_ARCH_OMAP1)
40#define PHYS_OFFSET UL(0x10000000) 40#define PLAT_PHYS_OFFSET UL(0x10000000)
41#else 41#else
42#define PHYS_OFFSET UL(0x80000000) 42#define PLAT_PHYS_OFFSET UL(0x80000000)
43#endif 43#endif
44 44
45/* 45/*
@@ -61,17 +61,17 @@
61#define lbus_to_virt(x) ((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET) 61#define lbus_to_virt(x) ((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET)
62#define is_lbus_device(dev) (cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0)) 62#define is_lbus_device(dev) (cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0))
63 63
64#define __arch_page_to_dma(dev, page) \ 64#define __arch_pfn_to_dma(dev, pfn) \
65 ({ dma_addr_t __dma = page_to_phys(page); \ 65 ({ dma_addr_t __dma = __pfn_to_phys(pfn); \
66 if (is_lbus_device(dev)) \ 66 if (is_lbus_device(dev)) \
67 __dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \ 67 __dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \
68 __dma; }) 68 __dma; })
69 69
70#define __arch_dma_to_page(dev, addr) \ 70#define __arch_dma_to_pfn(dev, addr) \
71 ({ dma_addr_t __dma = addr; \ 71 ({ dma_addr_t __dma = addr; \
72 if (is_lbus_device(dev)) \ 72 if (is_lbus_device(dev)) \
73 __dma += PHYS_OFFSET - OMAP1510_LB_OFFSET; \ 73 __dma += PHYS_OFFSET - OMAP1510_LB_OFFSET; \
74 phys_to_page(__dma); \ 74 __phys_to_pfn(__dma); \
75 }) 75 })
76 76
77#define __arch_dma_to_virt(dev, addr) ({ (void *) (is_lbus_device(dev) ? \ 77#define __arch_dma_to_virt(dev, addr) ({ (void *) (is_lbus_device(dev) ? \
diff --git a/arch/arm/plat-omap/include/plat/mmc.h b/arch/arm/plat-omap/include/plat/mmc.h
index 9b89ec601ee2..c7b874186c27 100644
--- a/arch/arm/plat-omap/include/plat/mmc.h
+++ b/arch/arm/plat-omap/include/plat/mmc.h
@@ -24,25 +24,19 @@
24#define OMAP1_MMC2_BASE 0xfffb7c00 /* omap16xx only */ 24#define OMAP1_MMC2_BASE 0xfffb7c00 /* omap16xx only */
25 25
26#define OMAP24XX_NR_MMC 2 26#define OMAP24XX_NR_MMC 2
27#define OMAP34XX_NR_MMC 3
28#define OMAP44XX_NR_MMC 5
29#define OMAP2420_MMC_SIZE OMAP1_MMC_SIZE 27#define OMAP2420_MMC_SIZE OMAP1_MMC_SIZE
30#define OMAP3_HSMMC_SIZE 0x200
31#define OMAP4_HSMMC_SIZE 0x1000
32#define OMAP2_MMC1_BASE 0x4809c000 28#define OMAP2_MMC1_BASE 0x4809c000
33#define OMAP2_MMC2_BASE 0x480b4000 29
34#define OMAP3_MMC3_BASE 0x480ad000
35#define OMAP4_MMC4_BASE 0x480d1000
36#define OMAP4_MMC5_BASE 0x480d5000
37#define OMAP4_MMC_REG_OFFSET 0x100 30#define OMAP4_MMC_REG_OFFSET 0x100
38#define HSMMC5 (1 << 4)
39#define HSMMC4 (1 << 3)
40#define HSMMC3 (1 << 2)
41#define HSMMC2 (1 << 1)
42#define HSMMC1 (1 << 0)
43 31
44#define OMAP_MMC_MAX_SLOTS 2 32#define OMAP_MMC_MAX_SLOTS 2
45 33
34#define OMAP_HSMMC_SUPPORTS_DUAL_VOLT BIT(1)
35
36struct omap_mmc_dev_attr {
37 u8 flags;
38};
39
46struct omap_mmc_platform_data { 40struct omap_mmc_platform_data {
47 /* back-link to device */ 41 /* back-link to device */
48 struct device *dev; 42 struct device *dev;
@@ -71,12 +65,20 @@ struct omap_mmc_platform_data {
71 65
72 u64 dma_mask; 66 u64 dma_mask;
73 67
68 /* Integrating attributes from the omap_hwmod layer */
69 u8 controller_flags;
70
71 /* Register offset deviation */
72 u16 reg_offset;
73
74 struct omap_mmc_slot_data { 74 struct omap_mmc_slot_data {
75 75
76 /* 4 wire signaling is optional, and is used for SD/SDIO/HSMMC; 76 /*
77 * 8 wire signaling is also optional, and is used with HSMMC 77 * 4/8 wires and any additional host capabilities
78 * need to OR'd all capabilities (ref. linux/mmc/host.h)
78 */ 79 */
79 u8 wires; 80 u8 wires; /* Used for the MMC driver on omap1 and 2420 */
81 u32 caps; /* Used for the MMC driver on 2430 and later */
80 82
81 /* 83 /*
82 * nomux means "standard" muxing is wrong on this board, and 84 * nomux means "standard" muxing is wrong on this board, and
@@ -99,11 +101,15 @@ struct omap_mmc_platform_data {
99 /* If using power_saving and the MMC power is not to go off */ 101 /* If using power_saving and the MMC power is not to go off */
100 unsigned no_off:1; 102 unsigned no_off:1;
101 103
104 /* eMMC does not handle power off when not in sleep state */
105 unsigned no_regulator_off_init:1;
106
102 /* Regulator off remapped to sleep */ 107 /* Regulator off remapped to sleep */
103 unsigned vcc_aux_disable_is_sleep:1; 108 unsigned vcc_aux_disable_is_sleep:1;
104 109
105 /* we can put the features above into this variable */ 110 /* we can put the features above into this variable */
106#define HSMMC_HAS_PBIAS (1 << 0) 111#define HSMMC_HAS_PBIAS (1 << 0)
112#define HSMMC_HAS_UPDATED_RESET (1 << 1)
107 unsigned features; 113 unsigned features;
108 114
109 int switch_pin; /* gpio (card detect) */ 115 int switch_pin; /* gpio (card detect) */
@@ -153,8 +159,7 @@ extern void omap_mmc_notify_cover_event(struct device *dev, int slot,
153 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE) 159 defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
154void omap1_init_mmc(struct omap_mmc_platform_data **mmc_data, 160void omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
155 int nr_controllers); 161 int nr_controllers);
156void omap2_init_mmc(struct omap_mmc_platform_data **mmc_data, 162void omap242x_init_mmc(struct omap_mmc_platform_data **mmc_data);
157 int nr_controllers);
158int omap_mmc_add(const char *name, int id, unsigned long base, 163int omap_mmc_add(const char *name, int id, unsigned long base,
159 unsigned long size, unsigned int irq, 164 unsigned long size, unsigned int irq,
160 struct omap_mmc_platform_data *data); 165 struct omap_mmc_platform_data *data);
@@ -163,8 +168,7 @@ static inline void omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
163 int nr_controllers) 168 int nr_controllers)
164{ 169{
165} 170}
166static inline void omap2_init_mmc(struct omap_mmc_platform_data **mmc_data, 171static inline void omap242x_init_mmc(struct omap_mmc_platform_data **mmc_data)
167 int nr_controllers)
168{ 172{
169} 173}
170static inline int omap_mmc_add(const char *name, int id, unsigned long base, 174static inline int omap_mmc_add(const char *name, int id, unsigned long base,
diff --git a/arch/arm/plat-omap/include/plat/multi.h b/arch/arm/plat-omap/include/plat/multi.h
index ffd909fa5287..999ffba2690c 100644
--- a/arch/arm/plat-omap/include/plat/multi.h
+++ b/arch/arm/plat-omap/include/plat/multi.h
@@ -66,7 +66,7 @@
66# error "OMAP1 and OMAP2PLUS can't be selected at the same time" 66# error "OMAP1 and OMAP2PLUS can't be selected at the same time"
67# endif 67# endif
68#endif 68#endif
69#ifdef CONFIG_ARCH_OMAP2420 69#ifdef CONFIG_SOC_OMAP2420
70# ifdef OMAP_NAME 70# ifdef OMAP_NAME
71# undef MULTI_OMAP2 71# undef MULTI_OMAP2
72# define MULTI_OMAP2 72# define MULTI_OMAP2
@@ -74,7 +74,7 @@
74# define OMAP_NAME omap2420 74# define OMAP_NAME omap2420
75# endif 75# endif
76#endif 76#endif
77#ifdef CONFIG_ARCH_OMAP2430 77#ifdef CONFIG_SOC_OMAP2430
78# ifdef OMAP_NAME 78# ifdef OMAP_NAME
79# undef MULTI_OMAP2 79# undef MULTI_OMAP2
80# define MULTI_OMAP2 80# define MULTI_OMAP2
diff --git a/arch/arm/plat-omap/include/plat/nand.h b/arch/arm/plat-omap/include/plat/nand.h
index 6562cd082bb1..d86d1ecf0068 100644
--- a/arch/arm/plat-omap/include/plat/nand.h
+++ b/arch/arm/plat-omap/include/plat/nand.h
@@ -8,8 +8,16 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10 10
11#include <plat/gpmc.h>
11#include <linux/mtd/partitions.h> 12#include <linux/mtd/partitions.h>
12 13
14enum nand_io {
15 NAND_OMAP_PREFETCH_POLLED = 0, /* prefetch polled mode, default */
16 NAND_OMAP_POLLED, /* polled mode, without prefetch */
17 NAND_OMAP_PREFETCH_DMA, /* prefetch enabled sDMA mode */
18 NAND_OMAP_PREFETCH_IRQ /* prefetch enabled irq mode */
19};
20
13struct omap_nand_platform_data { 21struct omap_nand_platform_data {
14 unsigned int options; 22 unsigned int options;
15 int cs; 23 int cs;
@@ -20,8 +28,11 @@ struct omap_nand_platform_data {
20 int (*nand_setup)(void); 28 int (*nand_setup)(void);
21 int (*dev_ready)(struct omap_nand_platform_data *); 29 int (*dev_ready)(struct omap_nand_platform_data *);
22 int dma_channel; 30 int dma_channel;
31 int gpmc_irq;
32 enum nand_io xfer_type;
23 unsigned long phys_base; 33 unsigned long phys_base;
24 int devsize; 34 int devsize;
35 enum omap_ecc ecc_opt;
25}; 36};
26 37
27/* minimum size for IO mapping */ 38/* minimum size for IO mapping */
diff --git a/arch/arm/plat-omap/include/plat/nokia-dsi-panel.h b/arch/arm/plat-omap/include/plat/nokia-dsi-panel.h
deleted file mode 100644
index 01ab6572ccbb..000000000000
--- a/arch/arm/plat-omap/include/plat/nokia-dsi-panel.h
+++ /dev/null
@@ -1,31 +0,0 @@
1#ifndef __ARCH_ARM_PLAT_OMAP_NOKIA_DSI_PANEL_H
2#define __ARCH_ARM_PLAT_OMAP_NOKIA_DSI_PANEL_H
3
4#include "display.h"
5
6/**
7 * struct nokia_dsi_panel_data - Nokia DSI panel driver configuration
8 * @name: panel name
9 * @use_ext_te: use external TE
10 * @ext_te_gpio: external TE GPIO
11 * @use_esd_check: perform ESD checks
12 * @max_backlight_level: maximum backlight level
13 * @set_backlight: pointer to backlight set function
14 * @get_backlight: pointer to backlight get function
15 */
16struct nokia_dsi_panel_data {
17 const char *name;
18
19 int reset_gpio;
20
21 bool use_ext_te;
22 int ext_te_gpio;
23
24 bool use_esd_check;
25
26 int max_backlight_level;
27 int (*set_backlight)(struct omap_dss_device *dssdev, int level);
28 int (*get_backlight)(struct omap_dss_device *dssdev);
29};
30
31#endif /* __ARCH_ARM_PLAT_OMAP_NOKIA_DSI_PANEL_H */
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
new file mode 100644
index 000000000000..2682043f5a5b
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -0,0 +1,116 @@
1/*
2 * Driver for OMAP-UART controller.
3 * Based on drivers/serial/8250.c
4 *
5 * Copyright (C) 2010 Texas Instruments.
6 *
7 * Authors:
8 * Govindraj R <govindraj.raja@ti.com>
9 * Thara Gopinath <thara@ti.com>
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 as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */
16
17#ifndef __OMAP_SERIAL_H__
18#define __OMAP_SERIAL_H__
19
20#include <linux/serial_core.h>
21#include <linux/platform_device.h>
22
23#include <plat/mux.h>
24
25#define DRIVER_NAME "omap_uart"
26
27/*
28 * Use tty device name as ttyO, [O -> OMAP]
29 * in bootargs we specify as console=ttyO0 if uart1
30 * is used as console uart.
31 */
32#define OMAP_SERIAL_NAME "ttyO"
33
34#define OMAP_MODE13X_SPEED 230400
35
36/* WER = 0x7F
37 * Enable module level wakeup in WER reg
38 */
39#define OMAP_UART_WER_MOD_WKUP 0X7F
40
41/* Enable XON/XOFF flow control on output */
42#define OMAP_UART_SW_TX 0x04
43
44/* Enable XON/XOFF flow control on input */
45#define OMAP_UART_SW_RX 0x04
46
47#define OMAP_UART_SYSC_RESET 0X07
48#define OMAP_UART_TCR_TRIG 0X0F
49#define OMAP_UART_SW_CLR 0XF0
50#define OMAP_UART_FIFO_CLR 0X06
51
52#define OMAP_UART_DMA_CH_FREE -1
53
54#define RX_TIMEOUT (3 * HZ)
55#define OMAP_MAX_HSUART_PORTS 4
56
57#define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
58
59struct omap_uart_port_info {
60 bool dma_enabled; /* To specify DMA Mode */
61 unsigned int uartclk; /* UART clock rate */
62 void __iomem *membase; /* ioremap cookie or NULL */
63 resource_size_t mapbase; /* resource base */
64 unsigned long irqflags; /* request_irq flags */
65 upf_t flags; /* UPF_* flags */
66};
67
68struct uart_omap_dma {
69 u8 uart_dma_tx;
70 u8 uart_dma_rx;
71 int rx_dma_channel;
72 int tx_dma_channel;
73 dma_addr_t rx_buf_dma_phys;
74 dma_addr_t tx_buf_dma_phys;
75 unsigned int uart_base;
76 /*
77 * Buffer for rx dma.It is not required for tx because the buffer
78 * comes from port structure.
79 */
80 unsigned char *rx_buf;
81 unsigned int prev_rx_dma_pos;
82 int tx_buf_size;
83 int tx_dma_used;
84 int rx_dma_used;
85 spinlock_t tx_lock;
86 spinlock_t rx_lock;
87 /* timer to poll activity on rx dma */
88 struct timer_list rx_timer;
89 int rx_buf_size;
90 int rx_timeout;
91};
92
93struct uart_omap_port {
94 struct uart_port port;
95 struct uart_omap_dma uart_dma;
96 struct platform_device *pdev;
97
98 unsigned char ier;
99 unsigned char lcr;
100 unsigned char mcr;
101 unsigned char fcr;
102 unsigned char efr;
103
104 int use_dma;
105 /*
106 * Some bits in registers are cleared on a read, so they must
107 * be saved whenever the register is read but the bits will not
108 * be immediately processed.
109 */
110 unsigned int lsr_break_flag;
111 unsigned char msr_saved_flags;
112 char name[20];
113 unsigned long port_activity;
114};
115
116#endif /* __OMAP_SERIAL_H__ */
diff --git a/arch/arm/plat-omap/include/plat/omap24xx.h b/arch/arm/plat-omap/include/plat/omap24xx.h
index 7055672a8c68..92df9e27cc5c 100644
--- a/arch/arm/plat-omap/include/plat/omap24xx.h
+++ b/arch/arm/plat-omap/include/plat/omap24xx.h
@@ -40,7 +40,7 @@
40#define OMAP24XX_IC_BASE (L4_24XX_BASE + 0xfe000) 40#define OMAP24XX_IC_BASE (L4_24XX_BASE + 0xfe000)
41#define OMAP24XX_IVA_INTC_BASE 0x40000000 41#define OMAP24XX_IVA_INTC_BASE 0x40000000
42 42
43#define OMAP2420_CTRL_BASE L4_24XX_BASE 43#define OMAP242X_CTRL_BASE L4_24XX_BASE
44#define OMAP2420_32KSYNCT_BASE (L4_24XX_BASE + 0x4000) 44#define OMAP2420_32KSYNCT_BASE (L4_24XX_BASE + 0x4000)
45#define OMAP2420_PRCM_BASE (L4_24XX_BASE + 0x8000) 45#define OMAP2420_PRCM_BASE (L4_24XX_BASE + 0x8000)
46#define OMAP2420_CM_BASE (L4_24XX_BASE + 0x8000) 46#define OMAP2420_CM_BASE (L4_24XX_BASE + 0x8000)
diff --git a/arch/arm/plat-omap/include/plat/omap34xx.h b/arch/arm/plat-omap/include/plat/omap34xx.h
index 98fc8b4a4cc4..b9e85886b9d6 100644
--- a/arch/arm/plat-omap/include/plat/omap34xx.h
+++ b/arch/arm/plat-omap/include/plat/omap34xx.h
@@ -56,8 +56,12 @@
56#define OMAP3430_ISP_RESZ_BASE (OMAP3430_ISP_BASE + 0x1000) 56#define OMAP3430_ISP_RESZ_BASE (OMAP3430_ISP_BASE + 0x1000)
57#define OMAP3430_ISP_SBL_BASE (OMAP3430_ISP_BASE + 0x1200) 57#define OMAP3430_ISP_SBL_BASE (OMAP3430_ISP_BASE + 0x1200)
58#define OMAP3430_ISP_MMU_BASE (OMAP3430_ISP_BASE + 0x1400) 58#define OMAP3430_ISP_MMU_BASE (OMAP3430_ISP_BASE + 0x1400)
59#define OMAP3430_ISP_CSI2A_BASE (OMAP3430_ISP_BASE + 0x1800) 59#define OMAP3430_ISP_CSI2A_REGS1_BASE (OMAP3430_ISP_BASE + 0x1800)
60#define OMAP3430_ISP_CSI2PHY_BASE (OMAP3430_ISP_BASE + 0x1970) 60#define OMAP3430_ISP_CSIPHY2_BASE (OMAP3430_ISP_BASE + 0x1970)
61#define OMAP3630_ISP_CSI2A_REGS2_BASE (OMAP3430_ISP_BASE + 0x19C0)
62#define OMAP3630_ISP_CSI2C_REGS1_BASE (OMAP3430_ISP_BASE + 0x1C00)
63#define OMAP3630_ISP_CSIPHY1_BASE (OMAP3430_ISP_BASE + 0x1D70)
64#define OMAP3630_ISP_CSI2C_REGS2_BASE (OMAP3430_ISP_BASE + 0x1DC0)
61 65
62#define OMAP3430_ISP_END (OMAP3430_ISP_BASE + 0x06F) 66#define OMAP3430_ISP_END (OMAP3430_ISP_BASE + 0x06F)
63#define OMAP3430_ISP_CBUFF_END (OMAP3430_ISP_CBUFF_BASE + 0x077) 67#define OMAP3430_ISP_CBUFF_END (OMAP3430_ISP_CBUFF_BASE + 0x077)
@@ -69,8 +73,12 @@
69#define OMAP3430_ISP_RESZ_END (OMAP3430_ISP_RESZ_BASE + 0x0AB) 73#define OMAP3430_ISP_RESZ_END (OMAP3430_ISP_RESZ_BASE + 0x0AB)
70#define OMAP3430_ISP_SBL_END (OMAP3430_ISP_SBL_BASE + 0x0FB) 74#define OMAP3430_ISP_SBL_END (OMAP3430_ISP_SBL_BASE + 0x0FB)
71#define OMAP3430_ISP_MMU_END (OMAP3430_ISP_MMU_BASE + 0x06F) 75#define OMAP3430_ISP_MMU_END (OMAP3430_ISP_MMU_BASE + 0x06F)
72#define OMAP3430_ISP_CSI2A_END (OMAP3430_ISP_CSI2A_BASE + 0x16F) 76#define OMAP3430_ISP_CSI2A_REGS1_END (OMAP3430_ISP_CSI2A_REGS1_BASE + 0x16F)
73#define OMAP3430_ISP_CSI2PHY_END (OMAP3430_ISP_CSI2PHY_BASE + 0x007) 77#define OMAP3430_ISP_CSIPHY2_END (OMAP3430_ISP_CSIPHY2_BASE + 0x00B)
78#define OMAP3630_ISP_CSI2A_REGS2_END (OMAP3630_ISP_CSI2A_REGS2_BASE + 0x3F)
79#define OMAP3630_ISP_CSI2C_REGS1_END (OMAP3630_ISP_CSI2C_REGS1_BASE + 0x16F)
80#define OMAP3630_ISP_CSIPHY1_END (OMAP3630_ISP_CSIPHY1_BASE + 0x00B)
81#define OMAP3630_ISP_CSI2C_REGS2_END (OMAP3630_ISP_CSI2C_REGS2_BASE + 0x3F)
74 82
75#define OMAP34XX_HSUSB_OTG_BASE (L4_34XX_BASE + 0xAB000) 83#define OMAP34XX_HSUSB_OTG_BASE (L4_34XX_BASE + 0xAB000)
76#define OMAP34XX_USBTLL_BASE (L4_34XX_BASE + 0x62000) 84#define OMAP34XX_USBTLL_BASE (L4_34XX_BASE + 0x62000)
diff --git a/arch/arm/plat-omap/include/plat/omap4-keypad.h b/arch/arm/plat-omap/include/plat/omap4-keypad.h
new file mode 100644
index 000000000000..2b1d9bc1eebb
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/omap4-keypad.h
@@ -0,0 +1,14 @@
1#ifndef ARCH_ARM_PLAT_OMAP4_KEYPAD_H
2#define ARCH_ARM_PLAT_OMAP4_KEYPAD_H
3
4#include <linux/input/matrix_keypad.h>
5
6struct omap4_keypad_platform_data {
7 const struct matrix_keymap_data *keymap_data;
8
9 u8 rows;
10 u8 cols;
11};
12
13extern int omap4_keyboard_init(struct omap4_keypad_platform_data *);
14#endif
diff --git a/arch/arm/plat-omap/include/plat/omap44xx.h b/arch/arm/plat-omap/include/plat/omap44xx.h
index 8b3f12ff5cbc..ea2b8a6306e7 100644
--- a/arch/arm/plat-omap/include/plat/omap44xx.h
+++ b/arch/arm/plat-omap/include/plat/omap44xx.h
@@ -52,5 +52,10 @@
52#define OMAP4_MMU1_BASE 0x55082000 52#define OMAP4_MMU1_BASE 0x55082000
53#define OMAP4_MMU2_BASE 0x4A066000 53#define OMAP4_MMU2_BASE 0x4A066000
54 54
55#define OMAP44XX_USBTLL_BASE (L4_44XX_BASE + 0x62000)
56#define OMAP44XX_UHH_CONFIG_BASE (L4_44XX_BASE + 0x64000)
57#define OMAP44XX_HSUSB_OHCI_BASE (L4_44XX_BASE + 0x64800)
58#define OMAP44XX_HSUSB_EHCI_BASE (L4_44XX_BASE + 0x64C00)
59
55#endif /* __ASM_ARCH_OMAP44XX_H */ 60#endif /* __ASM_ARCH_OMAP44XX_H */
56 61
diff --git a/arch/arm/plat-omap/include/plat/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h
index 25cd9ac3b095..e4c349ff9fd8 100644
--- a/arch/arm/plat-omap/include/plat/omap_device.h
+++ b/arch/arm/plat-omap/include/plat/omap_device.h
@@ -36,6 +36,8 @@
36 36
37#include <plat/omap_hwmod.h> 37#include <plat/omap_hwmod.h>
38 38
39extern struct device omap_device_parent;
40
39/* omap_device._state values */ 41/* omap_device._state values */
40#define OMAP_DEVICE_STATE_UNKNOWN 0 42#define OMAP_DEVICE_STATE_UNKNOWN 0
41#define OMAP_DEVICE_STATE_ENABLED 1 43#define OMAP_DEVICE_STATE_ENABLED 1
@@ -62,7 +64,6 @@
62 * 64 *
63 */ 65 */
64struct omap_device { 66struct omap_device {
65 u32 magic;
66 struct platform_device pdev; 67 struct platform_device pdev;
67 struct omap_hwmod **hwmods; 68 struct omap_hwmod **hwmods;
68 struct omap_device_pm_latency *pm_lats; 69 struct omap_device_pm_latency *pm_lats;
@@ -82,7 +83,6 @@ int omap_device_shutdown(struct platform_device *pdev);
82 83
83/* Core code interface */ 84/* Core code interface */
84 85
85bool omap_device_is_valid(struct omap_device *od);
86int omap_device_count_resources(struct omap_device *od); 86int omap_device_count_resources(struct omap_device *od);
87int omap_device_fill_resources(struct omap_device *od, struct resource *res); 87int omap_device_fill_resources(struct omap_device *od, struct resource *res);
88 88
@@ -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 a4e508dfaba2..1adea9c62984 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * omap_hwmod macros, structures 2 * omap_hwmod macros, structures
3 * 3 *
4 * Copyright (C) 2009-2010 Nokia Corporation 4 * Copyright (C) 2009-2011 Nokia Corporation
5 * Paul Walmsley 5 * Paul Walmsley
6 * 6 *
7 * Created in collaboration with (alphabetical order): Benoît Cousson, 7 * Created in collaboration with (alphabetical order): Benoît Cousson,
@@ -14,27 +14,26 @@
14 * 14 *
15 * These headers and macros are used to define OMAP on-chip module 15 * These headers and macros are used to define OMAP on-chip module
16 * data and their integration with other OMAP modules and Linux. 16 * data and their integration with other OMAP modules and Linux.
17 * 17 * Copious documentation and references can also be found in the
18 * References: 18 * omap_hwmod code, in arch/arm/mach-omap2/omap_hwmod.c (as of this
19 * - OMAP2420 Multimedia Processor Silicon Revision 2.1.1, 2.2 (SWPU064) 19 * writing).
20 * - OMAP2430 Multimedia Device POP Silicon Revision 2.1 (SWPU090)
21 * - OMAP34xx Multimedia Device Silicon Revision 3.1 (SWPU108)
22 * - OMAP4430 Multimedia Device Silicon Revision 1.0 (SWPU140)
23 * - Open Core Protocol Specification 2.2
24 * 20 *
25 * To do: 21 * To do:
26 * - add interconnect error log structures 22 * - add interconnect error log structures
27 * - add pinmuxing 23 * - add pinmuxing
28 * - init_conn_id_bit (CONNID_BIT_VECTOR) 24 * - init_conn_id_bit (CONNID_BIT_VECTOR)
29 * - implement default hwmod SMS/SDRC flags? 25 * - implement default hwmod SMS/SDRC flags?
26 * - move Linux-specific data ("non-ROM data") out
30 * 27 *
31 */ 28 */
32#ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_HWMOD_H 29#ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_HWMOD_H
33#define __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_HWMOD_H 30#define __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_HWMOD_H
34 31
35#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/init.h>
36#include <linux/list.h> 34#include <linux/list.h>
37#include <linux/ioport.h> 35#include <linux/ioport.h>
36#include <linux/spinlock.h>
38#include <plat/cpu.h> 37#include <plat/cpu.h>
39 38
40struct omap_device; 39struct omap_device;
@@ -78,6 +77,23 @@ extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type2;
78#define HWMOD_IDLEMODE_FORCE (1 << 0) 77#define HWMOD_IDLEMODE_FORCE (1 << 0)
79#define HWMOD_IDLEMODE_NO (1 << 1) 78#define HWMOD_IDLEMODE_NO (1 << 1)
80#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 int nr_pads_dynamic;
94 struct omap_device_pad **pads_dynamic;
95 bool enabled;
96};
81 97
82/** 98/**
83 * struct omap_hwmod_irq_info - MPU IRQs used by the hwmod 99 * struct omap_hwmod_irq_info - MPU IRQs used by the hwmod
@@ -96,7 +112,7 @@ struct omap_hwmod_irq_info {
96/** 112/**
97 * struct omap_hwmod_dma_info - DMA channels used by the hwmod 113 * struct omap_hwmod_dma_info - DMA channels used by the hwmod
98 * @name: name of the DMA channel (module local name) 114 * @name: name of the DMA channel (module local name)
99 * @dma_ch: DMA channel ID 115 * @dma_req: DMA request ID
100 * 116 *
101 * @name should be something short, e.g., "tx" or "rx". It is for use 117 * @name should be something short, e.g., "tx" or "rx". It is for use
102 * by platform_get_resource_byname(). It is defined locally to the 118 * by platform_get_resource_byname(). It is defined locally to the
@@ -104,7 +120,22 @@ struct omap_hwmod_irq_info {
104 */ 120 */
105struct omap_hwmod_dma_info { 121struct omap_hwmod_dma_info {
106 const char *name; 122 const char *name;
107 u16 dma_ch; 123 u16 dma_req;
124};
125
126/**
127 * struct omap_hwmod_rst_info - IPs reset lines use by hwmod
128 * @name: name of the reset line (module local name)
129 * @rst_shift: Offset of the reset bit
130 * @st_shift: Offset of the reset status bit (OMAP2/3 only)
131 *
132 * @name should be something short, e.g., "cpu0" or "rst". It is defined
133 * locally to the hwmod.
134 */
135struct omap_hwmod_rst_info {
136 const char *name;
137 u8 rst_shift;
138 u8 st_shift;
108}; 139};
109 140
110/** 141/**
@@ -148,11 +179,12 @@ struct omap_hwmod_omap2_firewall {
148 * ADDR_MAP_ON_INIT: Map this address space during omap_hwmod init. 179 * ADDR_MAP_ON_INIT: Map this address space during omap_hwmod init.
149 * ADDR_TYPE_RT: Address space contains module register target data. 180 * ADDR_TYPE_RT: Address space contains module register target data.
150 */ 181 */
151#define ADDR_MAP_ON_INIT (1 << 0) 182#define ADDR_MAP_ON_INIT (1 << 0) /* XXX does not belong */
152#define ADDR_TYPE_RT (1 << 1) 183#define ADDR_TYPE_RT (1 << 1)
153 184
154/** 185/**
155 * struct omap_hwmod_addr_space - MPU address space handled by the hwmod 186 * struct omap_hwmod_addr_space - address space handled by the hwmod
187 * @name: name of the address space
156 * @pa_start: starting physical address 188 * @pa_start: starting physical address
157 * @pa_end: ending physical address 189 * @pa_end: ending physical address
158 * @flags: (see omap_hwmod_addr_space.flags macros above) 190 * @flags: (see omap_hwmod_addr_space.flags macros above)
@@ -161,6 +193,7 @@ struct omap_hwmod_omap2_firewall {
161 * structure. GPMC is one example. 193 * structure. GPMC is one example.
162 */ 194 */
163struct omap_hwmod_addr_space { 195struct omap_hwmod_addr_space {
196 const char *name;
164 u32 pa_start; 197 u32 pa_start;
165 u32 pa_end; 198 u32 pa_end;
166 u8 flags; 199 u8 flags;
@@ -189,8 +222,6 @@ struct omap_hwmod_addr_space {
189 * @fw: interface firewall data 222 * @fw: interface firewall data
190 * @addr_cnt: ARRAY_SIZE(@addr) 223 * @addr_cnt: ARRAY_SIZE(@addr)
191 * @width: OCP data width 224 * @width: OCP data width
192 * @thread_cnt: number of threads
193 * @max_burst_len: maximum burst length in @width sized words (0 if unlimited)
194 * @user: initiators using this interface (see OCP_USER_* macros above) 225 * @user: initiators using this interface (see OCP_USER_* macros above)
195 * @flags: OCP interface flags (see OCPIF_* macros above) 226 * @flags: OCP interface flags (see OCPIF_* macros above)
196 * 227 *
@@ -210,8 +241,6 @@ struct omap_hwmod_ocp_if {
210 } fw; 241 } fw;
211 u8 addr_cnt; 242 u8 addr_cnt;
212 u8 width; 243 u8 width;
213 u8 thread_cnt;
214 u8 max_burst_len;
215 u8 user; 244 u8 user;
216 u8 flags; 245 u8 flags;
217}; 246};
@@ -220,11 +249,12 @@ struct omap_hwmod_ocp_if {
220/* Macros for use in struct omap_hwmod_sysconfig */ 249/* Macros for use in struct omap_hwmod_sysconfig */
221 250
222/* Flags for use in omap_hwmod_sysconfig.idlemodes */ 251/* Flags for use in omap_hwmod_sysconfig.idlemodes */
223#define MASTER_STANDBY_SHIFT 2 252#define MASTER_STANDBY_SHIFT 4
224#define SLAVE_IDLE_SHIFT 0 253#define SLAVE_IDLE_SHIFT 0
225#define SIDLE_FORCE (HWMOD_IDLEMODE_FORCE << SLAVE_IDLE_SHIFT) 254#define SIDLE_FORCE (HWMOD_IDLEMODE_FORCE << SLAVE_IDLE_SHIFT)
226#define SIDLE_NO (HWMOD_IDLEMODE_NO << SLAVE_IDLE_SHIFT) 255#define SIDLE_NO (HWMOD_IDLEMODE_NO << SLAVE_IDLE_SHIFT)
227#define SIDLE_SMART (HWMOD_IDLEMODE_SMART << SLAVE_IDLE_SHIFT) 256#define SIDLE_SMART (HWMOD_IDLEMODE_SMART << SLAVE_IDLE_SHIFT)
257#define SIDLE_SMART_WKUP (HWMOD_IDLEMODE_SMART_WKUP << SLAVE_IDLE_SHIFT)
228#define MSTANDBY_FORCE (HWMOD_IDLEMODE_FORCE << MASTER_STANDBY_SHIFT) 258#define MSTANDBY_FORCE (HWMOD_IDLEMODE_FORCE << MASTER_STANDBY_SHIFT)
229#define MSTANDBY_NO (HWMOD_IDLEMODE_NO << MASTER_STANDBY_SHIFT) 259#define MSTANDBY_NO (HWMOD_IDLEMODE_NO << MASTER_STANDBY_SHIFT)
230#define MSTANDBY_SMART (HWMOD_IDLEMODE_SMART << MASTER_STANDBY_SHIFT) 260#define MSTANDBY_SMART (HWMOD_IDLEMODE_SMART << MASTER_STANDBY_SHIFT)
@@ -237,8 +267,9 @@ struct omap_hwmod_ocp_if {
237#define SYSC_HAS_CLOCKACTIVITY (1 << 4) 267#define SYSC_HAS_CLOCKACTIVITY (1 << 4)
238#define SYSC_HAS_SIDLEMODE (1 << 5) 268#define SYSC_HAS_SIDLEMODE (1 << 5)
239#define SYSC_HAS_MIDLEMODE (1 << 6) 269#define SYSC_HAS_MIDLEMODE (1 << 6)
240#define SYSS_MISSING (1 << 7) 270#define SYSS_HAS_RESET_STATUS (1 << 7)
241#define SYSC_NO_CACHE (1 << 8) /* XXX SW flag, belongs elsewhere */ 271#define SYSC_NO_CACHE (1 << 8) /* XXX SW flag, belongs elsewhere */
272#define SYSC_HAS_RESET_STATUS (1 << 9)
242 273
243/* omap_hwmod_sysconfig.clockact flags */ 274/* omap_hwmod_sysconfig.clockact flags */
244#define CLOCKACT_TEST_BOTH 0x0 275#define CLOCKACT_TEST_BOTH 0x0
@@ -327,10 +358,12 @@ struct omap_hwmod_omap2_prcm {
327/** 358/**
328 * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data 359 * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data
329 * @clkctrl_reg: PRCM address of the clock control register 360 * @clkctrl_reg: PRCM address of the clock control register
361 * @rstctrl_reg: address of the XXX_RSTCTRL register located in the PRM
330 * @submodule_wkdep_bit: bit shift of the WKDEP range 362 * @submodule_wkdep_bit: bit shift of the WKDEP range
331 */ 363 */
332struct omap_hwmod_omap4_prcm { 364struct omap_hwmod_omap4_prcm {
333 void __iomem *clkctrl_reg; 365 void __iomem *clkctrl_reg;
366 void __iomem *rstctrl_reg;
334 u8 submodule_wkdep_bit; 367 u8 submodule_wkdep_bit;
335}; 368};
336 369
@@ -343,15 +376,22 @@ struct omap_hwmod_omap4_prcm {
343 * HWMOD_SWSUP_MSTDBY: omap_hwmod code should manually bring module in and out 376 * HWMOD_SWSUP_MSTDBY: omap_hwmod code should manually bring module in and out
344 * of standby, rather than relying on module smart-standby 377 * of standby, rather than relying on module smart-standby
345 * HWMOD_INIT_NO_RESET: don't reset this module at boot - important for 378 * HWMOD_INIT_NO_RESET: don't reset this module at boot - important for
346 * SDRAM controller, etc. 379 * SDRAM controller, etc. XXX probably belongs outside the main hwmod file
380 * XXX Should be HWMOD_SETUP_NO_RESET
347 * HWMOD_INIT_NO_IDLE: don't idle this module at boot - important for SDRAM 381 * HWMOD_INIT_NO_IDLE: don't idle this module at boot - important for SDRAM
348 * controller, etc. 382 * controller, etc. XXX probably belongs outside the main hwmod file
349 * HWMOD_NO_AUTOIDLE: disable module autoidle (OCP_SYSCONFIG.AUTOIDLE) 383 * XXX Should be HWMOD_SETUP_NO_IDLE
384 * HWMOD_NO_OCP_AUTOIDLE: disable module autoidle (OCP_SYSCONFIG.AUTOIDLE)
350 * when module is enabled, rather than the default, which is to 385 * when module is enabled, rather than the default, which is to
351 * enable autoidle 386 * enable autoidle
352 * HWMOD_SET_DEFAULT_CLOCKACT: program CLOCKACTIVITY bits at startup 387 * HWMOD_SET_DEFAULT_CLOCKACT: program CLOCKACTIVITY bits at startup
353 * HWMOD_NO_IDLEST : this module does not have idle status - this is the case 388 * HWMOD_NO_IDLEST: this module does not have idle status - this is the case
354 * only for few initiator modules on OMAP2 & 3. 389 * only for few initiator modules on OMAP2 & 3.
390 * HWMOD_CONTROL_OPT_CLKS_IN_RESET: Enable all optional clocks during reset.
391 * This is needed for devices like DSS that require optional clocks enabled
392 * in order to complete the reset. Optional clocks will be disabled
393 * again after the reset.
394 * HWMOD_16BIT_REG: Module has 16bit registers
355 */ 395 */
356#define HWMOD_SWSUP_SIDLE (1 << 0) 396#define HWMOD_SWSUP_SIDLE (1 << 0)
357#define HWMOD_SWSUP_MSTANDBY (1 << 1) 397#define HWMOD_SWSUP_MSTANDBY (1 << 1)
@@ -360,6 +400,8 @@ struct omap_hwmod_omap4_prcm {
360#define HWMOD_NO_OCP_AUTOIDLE (1 << 4) 400#define HWMOD_NO_OCP_AUTOIDLE (1 << 4)
361#define HWMOD_SET_DEFAULT_CLOCKACT (1 << 5) 401#define HWMOD_SET_DEFAULT_CLOCKACT (1 << 5)
362#define HWMOD_NO_IDLEST (1 << 6) 402#define HWMOD_NO_IDLEST (1 << 6)
403#define HWMOD_CONTROL_OPT_CLKS_IN_RESET (1 << 7)
404#define HWMOD_16BIT_REG (1 << 8)
363 405
364/* 406/*
365 * omap_hwmod._int_flags definitions 407 * omap_hwmod._int_flags definitions
@@ -394,14 +436,31 @@ struct omap_hwmod_omap4_prcm {
394 * @name: name of the hwmod_class 436 * @name: name of the hwmod_class
395 * @sysc: device SYSCONFIG/SYSSTATUS register data 437 * @sysc: device SYSCONFIG/SYSSTATUS register data
396 * @rev: revision of the IP class 438 * @rev: revision of the IP class
439 * @pre_shutdown: ptr to fn to be executed immediately prior to device shutdown
440 * @reset: ptr to fn to be executed in place of the standard hwmod reset fn
397 * 441 *
398 * Represent the class of a OMAP hardware "modules" (e.g. timer, 442 * Represent the class of a OMAP hardware "modules" (e.g. timer,
399 * smartreflex, gpio, uart...) 443 * smartreflex, gpio, uart...)
444 *
445 * @pre_shutdown is a function that will be run immediately before
446 * hwmod clocks are disabled, etc. It is intended for use for hwmods
447 * like the MPU watchdog, which cannot be disabled with the standard
448 * omap_hwmod_shutdown(). The function should return 0 upon success,
449 * or some negative error upon failure. Returning an error will cause
450 * omap_hwmod_shutdown() to abort the device shutdown and return an
451 * error.
452 *
453 * If @reset is defined, then the function it points to will be
454 * executed in place of the standard hwmod _reset() code in
455 * mach-omap2/omap_hwmod.c. This is needed for IP blocks which have
456 * unusual reset sequences - usually processor IP blocks like the IVA.
400 */ 457 */
401struct omap_hwmod_class { 458struct omap_hwmod_class {
402 const char *name; 459 const char *name;
403 struct omap_hwmod_class_sysconfig *sysc; 460 struct omap_hwmod_class_sysconfig *sysc;
404 u32 rev; 461 u32 rev;
462 int (*pre_shutdown)(struct omap_hwmod *oh);
463 int (*reset)(struct omap_hwmod *oh);
405}; 464};
406 465
407/** 466/**
@@ -410,29 +469,31 @@ struct omap_hwmod_class {
410 * @class: struct omap_hwmod_class * to the class of this hwmod 469 * @class: struct omap_hwmod_class * to the class of this hwmod
411 * @od: struct omap_device currently associated with this hwmod (internal use) 470 * @od: struct omap_device currently associated with this hwmod (internal use)
412 * @mpu_irqs: ptr to an array of MPU IRQs (see also mpu_irqs_cnt) 471 * @mpu_irqs: ptr to an array of MPU IRQs (see also mpu_irqs_cnt)
413 * @sdma_chs: ptr to an array of SDMA channel IDs (see also sdma_chs_cnt) 472 * @sdma_reqs: ptr to an array of System DMA request IDs (see sdma_reqs_cnt)
414 * @prcm: PRCM data pertaining to this hwmod 473 * @prcm: PRCM data pertaining to this hwmod
415 * @main_clk: main clock: OMAP clock name 474 * @main_clk: main clock: OMAP clock name
416 * @_clk: pointer to the main struct clk (filled in at runtime) 475 * @_clk: pointer to the main struct clk (filled in at runtime)
417 * @opt_clks: other device clocks that drivers can request (0..*) 476 * @opt_clks: other device clocks that drivers can request (0..*)
477 * @vdd_name: voltage domain name
478 * @voltdm: pointer to voltage domain (filled in at runtime)
418 * @masters: ptr to array of OCP ifs that this hwmod can initiate on 479 * @masters: ptr to array of OCP ifs that this hwmod can initiate on
419 * @slaves: ptr to array of OCP ifs that this hwmod can respond on 480 * @slaves: ptr to array of OCP ifs that this hwmod can respond on
420 * @dev_attr: arbitrary device attributes that can be passed to the driver 481 * @dev_attr: arbitrary device attributes that can be passed to the driver
421 * @_sysc_cache: internal-use hwmod flags 482 * @_sysc_cache: internal-use hwmod flags
422 * @_mpu_rt_va: cached register target start address (internal use) 483 * @_mpu_rt_va: cached register target start address (internal use)
423 * @_mpu_port_index: cached MPU register target slave ID (internal use) 484 * @_mpu_port_index: cached MPU register target slave ID (internal use)
424 * @msuspendmux_reg_id: CONTROL_MSUSPENDMUX register ID (1-6)
425 * @msuspendmux_shift: CONTROL_MSUSPENDMUX register bit shift
426 * @mpu_irqs_cnt: number of @mpu_irqs 485 * @mpu_irqs_cnt: number of @mpu_irqs
427 * @sdma_chs_cnt: number of @sdma_chs 486 * @sdma_reqs_cnt: number of @sdma_reqs
428 * @opt_clks_cnt: number of @opt_clks 487 * @opt_clks_cnt: number of @opt_clks
429 * @master_cnt: number of @master entries 488 * @master_cnt: number of @master entries
430 * @slaves_cnt: number of @slave entries 489 * @slaves_cnt: number of @slave entries
431 * @response_lat: device OCP response latency (in interface clock cycles) 490 * @response_lat: device OCP response latency (in interface clock cycles)
432 * @_int_flags: internal-use hwmod flags 491 * @_int_flags: internal-use hwmod flags
433 * @_state: internal-use hwmod state 492 * @_state: internal-use hwmod state
493 * @_postsetup_state: internal-use state to leave the hwmod in after _setup()
434 * @flags: hwmod flags (documented below) 494 * @flags: hwmod flags (documented below)
435 * @omap_chip: OMAP chips this hwmod is present on 495 * @omap_chip: OMAP chips this hwmod is present on
496 * @_lock: spinlock serializing operations on this hwmod
436 * @node: list node for hwmod list (internal use) 497 * @node: list node for hwmod list (internal use)
437 * 498 *
438 * @main_clk refers to this module's "main clock," which for our 499 * @main_clk refers to this module's "main clock," which for our
@@ -447,8 +508,10 @@ struct omap_hwmod {
447 const char *name; 508 const char *name;
448 struct omap_hwmod_class *class; 509 struct omap_hwmod_class *class;
449 struct omap_device *od; 510 struct omap_device *od;
511 struct omap_hwmod_mux_info *mux;
450 struct omap_hwmod_irq_info *mpu_irqs; 512 struct omap_hwmod_irq_info *mpu_irqs;
451 struct omap_hwmod_dma_info *sdma_chs; 513 struct omap_hwmod_dma_info *sdma_reqs;
514 struct omap_hwmod_rst_info *rst_lines;
452 union { 515 union {
453 struct omap_hwmod_omap2_prcm omap2; 516 struct omap_hwmod_omap2_prcm omap2;
454 struct omap_hwmod_omap4_prcm omap4; 517 struct omap_hwmod_omap4_prcm omap4;
@@ -456,35 +519,37 @@ struct omap_hwmod {
456 const char *main_clk; 519 const char *main_clk;
457 struct clk *_clk; 520 struct clk *_clk;
458 struct omap_hwmod_opt_clk *opt_clks; 521 struct omap_hwmod_opt_clk *opt_clks;
522 char *vdd_name;
523 struct voltagedomain *voltdm;
459 struct omap_hwmod_ocp_if **masters; /* connect to *_IA */ 524 struct omap_hwmod_ocp_if **masters; /* connect to *_IA */
460 struct omap_hwmod_ocp_if **slaves; /* connect to *_TA */ 525 struct omap_hwmod_ocp_if **slaves; /* connect to *_TA */
461 void *dev_attr; 526 void *dev_attr;
462 u32 _sysc_cache; 527 u32 _sysc_cache;
463 void __iomem *_mpu_rt_va; 528 void __iomem *_mpu_rt_va;
529 spinlock_t _lock;
464 struct list_head node; 530 struct list_head node;
465 u16 flags; 531 u16 flags;
466 u8 _mpu_port_index; 532 u8 _mpu_port_index;
467 u8 msuspendmux_reg_id;
468 u8 msuspendmux_shift;
469 u8 response_lat; 533 u8 response_lat;
470 u8 mpu_irqs_cnt; 534 u8 mpu_irqs_cnt;
471 u8 sdma_chs_cnt; 535 u8 sdma_reqs_cnt;
536 u8 rst_lines_cnt;
472 u8 opt_clks_cnt; 537 u8 opt_clks_cnt;
473 u8 masters_cnt; 538 u8 masters_cnt;
474 u8 slaves_cnt; 539 u8 slaves_cnt;
475 u8 hwmods_cnt; 540 u8 hwmods_cnt;
476 u8 _int_flags; 541 u8 _int_flags;
477 u8 _state; 542 u8 _state;
543 u8 _postsetup_state;
478 const struct omap_chip_id omap_chip; 544 const struct omap_chip_id omap_chip;
479}; 545};
480 546
481int omap_hwmod_init(struct omap_hwmod **ohs); 547int omap_hwmod_register(struct omap_hwmod **ohs);
482int omap_hwmod_register(struct omap_hwmod *oh);
483int omap_hwmod_unregister(struct omap_hwmod *oh);
484struct omap_hwmod *omap_hwmod_lookup(const char *name); 548struct omap_hwmod *omap_hwmod_lookup(const char *name);
485int omap_hwmod_for_each(int (*fn)(struct omap_hwmod *oh, void *data), 549int omap_hwmod_for_each(int (*fn)(struct omap_hwmod *oh, void *data),
486 void *data); 550 void *data);
487int omap_hwmod_late_init(u8 skip_setup_idle); 551
552int __init omap_hwmod_setup_one(const char *name);
488 553
489int omap_hwmod_enable(struct omap_hwmod *oh); 554int omap_hwmod_enable(struct omap_hwmod *oh);
490int _omap_hwmod_enable(struct omap_hwmod *oh); 555int _omap_hwmod_enable(struct omap_hwmod *oh);
@@ -492,16 +557,21 @@ int omap_hwmod_idle(struct omap_hwmod *oh);
492int _omap_hwmod_idle(struct omap_hwmod *oh); 557int _omap_hwmod_idle(struct omap_hwmod *oh);
493int omap_hwmod_shutdown(struct omap_hwmod *oh); 558int omap_hwmod_shutdown(struct omap_hwmod *oh);
494 559
560int omap_hwmod_assert_hardreset(struct omap_hwmod *oh, const char *name);
561int omap_hwmod_deassert_hardreset(struct omap_hwmod *oh, const char *name);
562int omap_hwmod_read_hardreset(struct omap_hwmod *oh, const char *name);
563
495int omap_hwmod_enable_clocks(struct omap_hwmod *oh); 564int omap_hwmod_enable_clocks(struct omap_hwmod *oh);
496int omap_hwmod_disable_clocks(struct omap_hwmod *oh); 565int omap_hwmod_disable_clocks(struct omap_hwmod *oh);
497 566
498int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode); 567int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode);
568int omap_hwmod_set_ocp_autoidle(struct omap_hwmod *oh, u8 autoidle);
499 569
500int omap_hwmod_reset(struct omap_hwmod *oh); 570int omap_hwmod_reset(struct omap_hwmod *oh);
501void omap_hwmod_ocp_barrier(struct omap_hwmod *oh); 571void omap_hwmod_ocp_barrier(struct omap_hwmod *oh);
502 572
503void omap_hwmod_writel(u32 v, struct omap_hwmod *oh, u16 reg_offs); 573void omap_hwmod_write(u32 v, struct omap_hwmod *oh, u16 reg_offs);
504u32 omap_hwmod_readl(struct omap_hwmod *oh, u16 reg_offs); 574u32 omap_hwmod_read(struct omap_hwmod *oh, u16 reg_offs);
505 575
506int omap_hwmod_count_resources(struct omap_hwmod *oh); 576int omap_hwmod_count_resources(struct omap_hwmod *oh);
507int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res); 577int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res);
@@ -527,6 +597,11 @@ int omap_hwmod_for_each_by_class(const char *classname,
527 void *user), 597 void *user),
528 void *user); 598 void *user);
529 599
600int omap_hwmod_set_postsetup_state(struct omap_hwmod *oh, u8 state);
601u32 omap_hwmod_get_context_loss_count(struct omap_hwmod *oh);
602
603int omap_hwmod_no_setup_reset(struct omap_hwmod *oh);
604
530/* 605/*
531 * Chip variant-specific hwmod init routines - XXX should be converted 606 * Chip variant-specific hwmod init routines - XXX should be converted
532 * to use initcalls once the initial boot ordering is straightened out 607 * to use initcalls once the initial boot ordering is straightened out
@@ -534,5 +609,6 @@ int omap_hwmod_for_each_by_class(const char *classname,
534extern int omap2420_hwmod_init(void); 609extern int omap2420_hwmod_init(void);
535extern int omap2430_hwmod_init(void); 610extern int omap2430_hwmod_init(void);
536extern int omap3xxx_hwmod_init(void); 611extern int omap3xxx_hwmod_init(void);
612extern int omap44xx_hwmod_init(void);
537 613
538#endif 614#endif
diff --git a/arch/arm/plat-omap/include/plat/onenand.h b/arch/arm/plat-omap/include/plat/onenand.h
index 72f433d7d827..2858667d2e4f 100644
--- a/arch/arm/plat-omap/include/plat/onenand.h
+++ b/arch/arm/plat-omap/include/plat/onenand.h
@@ -15,14 +15,24 @@
15#define ONENAND_SYNC_READ (1 << 0) 15#define ONENAND_SYNC_READ (1 << 0)
16#define ONENAND_SYNC_READWRITE (1 << 1) 16#define ONENAND_SYNC_READWRITE (1 << 1)
17 17
18struct onenand_freq_info {
19 u16 maf_id;
20 u16 dev_id;
21 u16 ver_id;
22};
23
18struct omap_onenand_platform_data { 24struct omap_onenand_platform_data {
19 int cs; 25 int cs;
20 int gpio_irq; 26 int gpio_irq;
21 struct mtd_partition *parts; 27 struct mtd_partition *parts;
22 int nr_parts; 28 int nr_parts;
23 int (*onenand_setup)(void __iomem *, int freq); 29 int (*onenand_setup)(void __iomem *, int *freq_ptr);
30 int (*get_freq)(const struct onenand_freq_info *freq_info,
31 bool *clk_dep);
24 int dma_channel; 32 int dma_channel;
25 u8 flags; 33 u8 flags;
34 u8 regulator_can_sleep;
35 u8 skip_initial_unlocking;
26}; 36};
27 37
28#define ONENAND_MAX_PARTITIONS 8 38#define ONENAND_MAX_PARTITIONS 8
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 fb6ec74fe39e..000000000000
--- a/arch/arm/plat-omap/include/plat/powerdomain.h
+++ /dev/null
@@ -1,165 +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_ON ((1 << PWRDM_POWER_OFF) | \
36 (1 << PWRDM_POWER_ON))
37
38#define PWRSTS_OFF_RET ((1 << PWRDM_POWER_OFF) | \
39 (1 << PWRDM_POWER_RET))
40
41#define PWRSTS_RET_ON ((1 << PWRDM_POWER_RET) | \
42 (1 << PWRDM_POWER_ON))
43
44#define PWRSTS_OFF_RET_ON (PWRSTS_OFF_RET | (1 << PWRDM_POWER_ON))
45
46
47/* Powerdomain flags */
48#define PWRDM_HAS_HDWR_SAR (1 << 0) /* hardware save-and-restore support */
49#define PWRDM_HAS_MPU_QUIRK (1 << 1) /* MPU pwr domain has MEM bank 0 bits
50 * in MEM bank 1 position. This is
51 * true for OMAP3430
52 */
53#define PWRDM_HAS_LOWPOWERSTATECHANGE (1 << 2) /*
54 * support to transition from a
55 * sleep state to a lower sleep
56 * state without waking up the
57 * powerdomain
58 */
59
60/*
61 * Number of memory banks that are power-controllable. On OMAP4430, the
62 * maximum is 5.
63 */
64#define PWRDM_MAX_MEM_BANKS 5
65
66/*
67 * Maximum number of clockdomains that can be associated with a powerdomain.
68 * CORE powerdomain on OMAP4 is the worst case
69 */
70#define PWRDM_MAX_CLKDMS 9
71
72/* XXX A completely arbitrary number. What is reasonable here? */
73#define PWRDM_TRANSITION_BAILOUT 100000
74
75struct clockdomain;
76struct powerdomain;
77
78/**
79 * struct powerdomain - OMAP powerdomain
80 * @name: Powerdomain name
81 * @omap_chip: represents the OMAP chip types containing this pwrdm
82 * @prcm_offs: the address offset from CM_BASE/PRM_BASE
83 * @pwrsts: Possible powerdomain power states
84 * @pwrsts_logic_ret: Possible logic power states when pwrdm in RETENTION
85 * @flags: Powerdomain flags
86 * @banks: Number of software-controllable memory banks in this powerdomain
87 * @pwrsts_mem_ret: Possible memory bank pwrstates when pwrdm in RETENTION
88 * @pwrsts_mem_on: Possible memory bank pwrstates when pwrdm in ON
89 * @pwrdm_clkdms: Clockdomains in this powerdomain
90 * @node: list_head linking all powerdomains
91 * @state:
92 * @state_counter:
93 * @timer:
94 * @state_timer:
95 */
96struct powerdomain {
97 const char *name;
98 const struct omap_chip_id omap_chip;
99 const s16 prcm_offs;
100 const u8 pwrsts;
101 const u8 pwrsts_logic_ret;
102 const u8 flags;
103 const u8 banks;
104 const u8 pwrsts_mem_ret[PWRDM_MAX_MEM_BANKS];
105 const u8 pwrsts_mem_on[PWRDM_MAX_MEM_BANKS];
106 struct clockdomain *pwrdm_clkdms[PWRDM_MAX_CLKDMS];
107 struct list_head node;
108 int state;
109 unsigned state_counter[PWRDM_MAX_PWRSTS];
110 unsigned ret_logic_off_counter;
111 unsigned ret_mem_off_counter[PWRDM_MAX_MEM_BANKS];
112
113#ifdef CONFIG_PM_DEBUG
114 s64 timer;
115 s64 state_timer[PWRDM_MAX_PWRSTS];
116#endif
117};
118
119
120void pwrdm_init(struct powerdomain **pwrdm_list);
121
122struct powerdomain *pwrdm_lookup(const char *name);
123
124int pwrdm_for_each(int (*fn)(struct powerdomain *pwrdm, void *user),
125 void *user);
126int pwrdm_for_each_nolock(int (*fn)(struct powerdomain *pwrdm, void *user),
127 void *user);
128
129int pwrdm_add_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm);
130int pwrdm_del_clkdm(struct powerdomain *pwrdm, struct clockdomain *clkdm);
131int pwrdm_for_each_clkdm(struct powerdomain *pwrdm,
132 int (*fn)(struct powerdomain *pwrdm,
133 struct clockdomain *clkdm));
134
135int pwrdm_get_mem_bank_count(struct powerdomain *pwrdm);
136
137int pwrdm_set_next_pwrst(struct powerdomain *pwrdm, u8 pwrst);
138int pwrdm_read_next_pwrst(struct powerdomain *pwrdm);
139int pwrdm_read_pwrst(struct powerdomain *pwrdm);
140int pwrdm_read_prev_pwrst(struct powerdomain *pwrdm);
141int pwrdm_clear_all_prev_pwrst(struct powerdomain *pwrdm);
142
143int pwrdm_set_logic_retst(struct powerdomain *pwrdm, u8 pwrst);
144int pwrdm_set_mem_onst(struct powerdomain *pwrdm, u8 bank, u8 pwrst);
145int pwrdm_set_mem_retst(struct powerdomain *pwrdm, u8 bank, u8 pwrst);
146
147int pwrdm_read_logic_pwrst(struct powerdomain *pwrdm);
148int pwrdm_read_prev_logic_pwrst(struct powerdomain *pwrdm);
149int pwrdm_read_logic_retst(struct powerdomain *pwrdm);
150int pwrdm_read_mem_pwrst(struct powerdomain *pwrdm, u8 bank);
151int pwrdm_read_prev_mem_pwrst(struct powerdomain *pwrdm, u8 bank);
152int pwrdm_read_mem_retst(struct powerdomain *pwrdm, u8 bank);
153
154int pwrdm_enable_hdwr_sar(struct powerdomain *pwrdm);
155int pwrdm_disable_hdwr_sar(struct powerdomain *pwrdm);
156bool pwrdm_has_hdwr_sar(struct powerdomain *pwrdm);
157
158int pwrdm_wait_transition(struct powerdomain *pwrdm);
159
160int pwrdm_state_switch(struct powerdomain *pwrdm);
161int pwrdm_clkdm_state_switch(struct clockdomain *clkdm);
162int pwrdm_pre_transition(void);
163int pwrdm_post_transition(void);
164
165#endif
diff --git a/arch/arm/plat-omap/include/plat/prcm.h b/arch/arm/plat-omap/include/plat/prcm.h
index 9fbd91419cd1..267f43bb2a4e 100644
--- a/arch/arm/plat-omap/include/plat/prcm.h
+++ b/arch/arm/plat-omap/include/plat/prcm.h
@@ -18,30 +18,19 @@
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
24#define __ASM_ARM_ARCH_OMAP_PRCM_H 28#define __ASM_ARM_ARCH_OMAP_PRCM_H
25 29
26u32 omap_prcm_get_reset_sources(void); 30u32 omap_prcm_get_reset_sources(void);
27void omap_prcm_arch_reset(char mode, const char *cmd);
28int omap2_cm_wait_idlest(void __iomem *reg, u32 mask, u8 idlest, 31int omap2_cm_wait_idlest(void __iomem *reg, u32 mask, u8 idlest,
29 const char *name); 32 const char *name);
30 33
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 cm_read_mod_reg(s16 module, u16 idx);
42void cm_write_mod_reg(u32 val, s16 module, u16 idx);
43u32 cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx);
44
45#endif 34#endif
46 35
47 36
diff --git a/arch/arm/plat-omap/include/plat/sdrc.h b/arch/arm/plat-omap/include/plat/sdrc.h
index 7b76f50564ba..925b12b500dc 100644
--- a/arch/arm/plat-omap/include/plat/sdrc.h
+++ b/arch/arm/plat-omap/include/plat/sdrc.h
@@ -124,8 +124,14 @@ struct omap_sdrc_params {
124 u32 mr; 124 u32 mr;
125}; 125};
126 126
127void __init omap2_sdrc_init(struct omap_sdrc_params *sdrc_cs0, 127#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
128void omap2_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
128 struct omap_sdrc_params *sdrc_cs1); 129 struct omap_sdrc_params *sdrc_cs1);
130#else
131static inline void __init omap2_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
132 struct omap_sdrc_params *sdrc_cs1) {};
133#endif
134
129int omap2_sdrc_get_params(unsigned long r, 135int omap2_sdrc_get_params(unsigned long r,
130 struct omap_sdrc_params **sdrc_cs0, 136 struct omap_sdrc_params **sdrc_cs0,
131 struct omap_sdrc_params **sdrc_cs1); 137 struct omap_sdrc_params **sdrc_cs1);
@@ -147,6 +153,7 @@ struct memory_timings {
147}; 153};
148 154
149extern void omap2xxx_sdrc_init_params(u32 force_lock_to_unlock_mode); 155extern void omap2xxx_sdrc_init_params(u32 force_lock_to_unlock_mode);
156struct omap_sdrc_params *rx51_get_sdram_timings(void);
150 157
151u32 omap2xxx_sdrc_dll_is_unlocked(void); 158u32 omap2xxx_sdrc_dll_is_unlocked(void);
152u32 omap2xxx_sdrc_reprogram(u32 level, u32 force); 159u32 omap2xxx_sdrc_reprogram(u32 level, u32 force);
diff --git a/arch/arm/plat-omap/include/plat/serial.h b/arch/arm/plat-omap/include/plat/serial.h
index 19145f5c32ba..2723f9166ea2 100644
--- a/arch/arm/plat-omap/include/plat/serial.h
+++ b/arch/arm/plat-omap/include/plat/serial.h
@@ -27,7 +27,7 @@
27 * 2. We assume printascii is called at least once before paging_init, 27 * 2. We assume printascii is called at least once before paging_init,
28 * and addruart has a chance to read OMAP_UART_INFO 28 * and addruart has a chance to read OMAP_UART_INFO
29 */ 29 */
30#define OMAP_UART_INFO (PHYS_OFFSET + 0x3ffc) 30#define OMAP_UART_INFO (PLAT_PHYS_OFFSET + 0x3ffc)
31 31
32/* OMAP1 serial ports */ 32/* OMAP1 serial ports */
33#define OMAP1_UART1_BASE 0xfffb0000 33#define OMAP1_UART1_BASE 0xfffb0000
@@ -51,6 +51,11 @@
51#define OMAP4_UART3_BASE 0x48020000 51#define OMAP4_UART3_BASE 0x48020000
52#define OMAP4_UART4_BASE 0x4806e000 52#define OMAP4_UART4_BASE 0x4806e000
53 53
54/* TI816X serial ports */
55#define TI816X_UART1_BASE 0x48020000
56#define TI816X_UART2_BASE 0x48022000
57#define TI816X_UART3_BASE 0x48024000
58
54/* External port on Zoom2/3 */ 59/* External port on Zoom2/3 */
55#define ZOOM_UART_BASE 0x10000000 60#define ZOOM_UART_BASE 0x10000000
56#define ZOOM_UART_VIRT 0xfa400000 61#define ZOOM_UART_VIRT 0xfa400000
@@ -81,6 +86,9 @@
81#define OMAP4UART2 OMAP2UART2 86#define OMAP4UART2 OMAP2UART2
82#define OMAP4UART3 43 87#define OMAP4UART3 43
83#define OMAP4UART4 44 88#define OMAP4UART4 44
89#define TI816XUART1 81
90#define TI816XUART2 82
91#define TI816XUART3 83
84#define ZOOM_UART 95 /* Only on zoom2/3 */ 92#define ZOOM_UART 95 /* Only on zoom2/3 */
85 93
86/* This is only used by 8250.c for omap1510 */ 94/* This is only used by 8250.c for omap1510 */
@@ -93,9 +101,11 @@
93 }) 101 })
94 102
95#ifndef __ASSEMBLER__ 103#ifndef __ASSEMBLER__
96extern void __init omap_serial_early_init(void); 104
105struct omap_board_data;
106
97extern void omap_serial_init(void); 107extern void omap_serial_init(void);
98extern void omap_serial_init_port(int port); 108extern void omap_serial_init_port(struct omap_board_data *bdata);
99extern int omap_uart_can_sleep(void); 109extern int omap_uart_can_sleep(void);
100extern void omap_uart_check_wakeup(void); 110extern void omap_uart_check_wakeup(void);
101extern void omap_uart_prepare_suspend(void); 111extern void omap_uart_prepare_suspend(void);
diff --git a/arch/arm/plat-omap/include/plat/smp.h b/arch/arm/plat-omap/include/plat/smp.h
deleted file mode 100644
index 5177a9c5a25a..000000000000
--- a/arch/arm/plat-omap/include/plat/smp.h
+++ /dev/null
@@ -1,47 +0,0 @@
1/*
2 * OMAP4 machine specific smp.h
3 *
4 * Copyright (C) 2009 Texas Instruments, Inc.
5 *
6 * Author:
7 * Santosh Shilimkar <santosh.shilimkar@ti.com>
8 *
9 * Interface functions needed for the SMP. This file is based on arm
10 * realview smp platform.
11 * Copyright (c) 2003 ARM Limited.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
16 */
17#ifndef OMAP_ARCH_SMP_H
18#define OMAP_ARCH_SMP_H
19
20#include <asm/hardware/gic.h>
21
22/* Needed for secondary core boot */
23extern void omap_secondary_startup(void);
24extern u32 omap_modify_auxcoreboot0(u32 set_mask, u32 clear_mask);
25extern void omap_auxcoreboot_addr(u32 cpu_addr);
26extern u32 omap_read_auxcoreboot0(void);
27
28/*
29 * We use Soft IRQ1 as the IPI
30 */
31static inline void smp_cross_call(const struct cpumask *mask)
32{
33 gic_raise_softirq(mask, 1);
34}
35
36/*
37 * Read MPIDR: Multiprocessor affinity register
38 */
39#define hard_smp_processor_id() \
40 ({ \
41 unsigned int cpunum; \
42 __asm__("mrc p15, 0, %0, c0, c0, 5" \
43 : "=r" (cpunum)); \
44 cpunum &= 0x0F; \
45 })
46
47#endif
diff --git a/arch/arm/plat-omap/include/plat/sram.h b/arch/arm/plat-omap/include/plat/sram.h
index 16a1b458d53c..f500fc34d065 100644
--- a/arch/arm/plat-omap/include/plat/sram.h
+++ b/arch/arm/plat-omap/include/plat/sram.h
@@ -11,8 +11,20 @@
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
14extern int __init omap_sram_init(void); 14#ifndef __ASSEMBLY__
15extern void * omap_sram_push(void * start, unsigned long size); 15#include <asm/fncpy.h>
16
17extern void *omap_sram_push_address(unsigned long size);
18
19/* Macro to push a function to the internal SRAM, using the fncpy API */
20#define omap_sram_push(funcp, size) ({ \
21 typeof(&(funcp)) _res = NULL; \
22 void *_sram_address = omap_sram_push_address(size); \
23 if (_sram_address) \
24 _res = fncpy(_sram_address, &(funcp), size); \
25 _res; \
26})
27
16extern void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl); 28extern void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl);
17 29
18extern void omap2_sram_ddr_init(u32 *slow_dll_ctrl, u32 fast_dll_ctrl, 30extern void omap2_sram_ddr_init(u32 *slow_dll_ctrl, u32 fast_dll_ctrl,
@@ -75,4 +87,14 @@ extern void omap_push_sram_idle(void);
75static inline void omap_push_sram_idle(void) {} 87static inline void omap_push_sram_idle(void) {}
76#endif /* CONFIG_PM */ 88#endif /* CONFIG_PM */
77 89
90#endif /* __ASSEMBLY__ */
91
92/*
93 * OMAP2+: define the SRAM PA addresses.
94 * Used by the SRAM management code and the idle sleep code.
95 */
96#define OMAP2_SRAM_PA 0x40200000
97#define OMAP3_SRAM_PA 0x40200000
98#define OMAP4_SRAM_PA 0x40300000
99
78#endif 100#endif
diff --git a/arch/arm/plat-omap/include/plat/system.h b/arch/arm/plat-omap/include/plat/system.h
index d0a119f735b4..c5fa9e929009 100644
--- a/arch/arm/plat-omap/include/plat/system.h
+++ b/arch/arm/plat-omap/include/plat/system.h
@@ -4,48 +4,14 @@
4 */ 4 */
5#ifndef __ASM_ARCH_SYSTEM_H 5#ifndef __ASM_ARCH_SYSTEM_H
6#define __ASM_ARCH_SYSTEM_H 6#define __ASM_ARCH_SYSTEM_H
7#include <linux/clk.h>
8 7
9#include <asm/mach-types.h> 8#include <asm/proc-fns.h>
10#include <mach/hardware.h>
11
12#include <plat/prcm.h>
13
14#ifndef CONFIG_MACH_VOICEBLUE
15#define voiceblue_reset() do {} while (0)
16#else
17extern void voiceblue_reset(void);
18#endif
19 9
20static inline void arch_idle(void) 10static inline void arch_idle(void)
21{ 11{
22 cpu_do_idle(); 12 cpu_do_idle();
23} 13}
24 14
25static inline void omap1_arch_reset(char mode, const char *cmd) 15extern void (*arch_reset)(char, const char *);
26{
27 /*
28 * Workaround for 5912/1611b bug mentioned in sprz209d.pdf p. 28
29 * "Global Software Reset Affects Traffic Controller Frequency".
30 */
31 if (cpu_is_omap5912()) {
32 omap_writew(omap_readw(DPLL_CTL) & ~(1 << 4),
33 DPLL_CTL);
34 omap_writew(0x8, ARM_RSTCT1);
35 }
36
37 if (machine_is_voiceblue())
38 voiceblue_reset();
39 else
40 omap_writew(1, ARM_RSTCT1);
41}
42
43static inline void arch_reset(char mode, const char *cmd)
44{
45 if (!cpu_class_is_omap2())
46 omap1_arch_reset(mode, cmd);
47 else
48 omap_prcm_arch_reset(mode, cmd);
49}
50 16
51#endif 17#endif
diff --git a/arch/arm/plat-omap/include/plat/ti816x.h b/arch/arm/plat-omap/include/plat/ti816x.h
new file mode 100644
index 000000000000..50510f5dda1e
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/ti816x.h
@@ -0,0 +1,27 @@
1/*
2 * This file contains the address data for various TI816X modules.
3 *
4 * Copyright (C) 2010 Texas Instruments, Inc. - http://www.ti.com/
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation version 2.
9 *
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#ifndef __ASM_ARCH_TI816X_H
17#define __ASM_ARCH_TI816X_H
18
19#define L4_SLOW_TI816X_BASE 0x48000000
20
21#define TI816X_SCM_BASE 0x48140000
22#define TI816X_CTRL_BASE TI816X_SCM_BASE
23#define TI816X_PRCM_BASE 0x48180000
24
25#define TI816X_ARM_INTC_BASE 0x48200000
26
27#endif /* __ASM_ARCH_TI816X_H */
diff --git a/arch/arm/plat-omap/include/plat/timer-gp.h b/arch/arm/plat-omap/include/plat/timer-gp.h
deleted file mode 100644
index c88d346b59d9..000000000000
--- a/arch/arm/plat-omap/include/plat/timer-gp.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/*
2 * OMAP2/3 GPTIMER support.headers
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_TIMER_GP_H
12#define __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_TIMER_GP_H
13
14int __init omap2_gp_clockevent_set_gptimer(u8 id);
15
16#endif
17
diff --git a/arch/arm/plat-omap/include/plat/uncompress.h b/arch/arm/plat-omap/include/plat/uncompress.h
index ddf723be48dc..ac4b60d9aa29 100644
--- a/arch/arm/plat-omap/include/plat/uncompress.h
+++ b/arch/arm/plat-omap/include/plat/uncompress.h
@@ -27,8 +27,8 @@
27 27
28#define MDR1_MODE_MASK 0x07 28#define MDR1_MODE_MASK 0x07
29 29
30static volatile u8 *uart_base; 30volatile u8 *uart_base;
31static int uart_shift; 31int uart_shift;
32 32
33/* 33/*
34 * Store the DEBUG_LL uart number into memory. 34 * Store the DEBUG_LL uart number into memory.
@@ -93,6 +93,10 @@ static inline void flush(void)
93#define DEBUG_LL_ZOOM(mach) \ 93#define DEBUG_LL_ZOOM(mach) \
94 _DEBUG_LL_ENTRY(mach, ZOOM_UART_BASE, ZOOM_PORT_SHIFT, ZOOM_UART) 94 _DEBUG_LL_ENTRY(mach, ZOOM_UART_BASE, ZOOM_PORT_SHIFT, ZOOM_UART)
95 95
96#define DEBUG_LL_TI816X(p, mach) \
97 _DEBUG_LL_ENTRY(mach, TI816X_UART##p##_BASE, OMAP_PORT_SHIFT, \
98 TI816XUART##p)
99
96static inline void __arch_decomp_setup(unsigned long arch_id) 100static inline void __arch_decomp_setup(unsigned long arch_id)
97{ 101{
98 int port = 0; 102 int port = 0;
@@ -125,7 +129,6 @@ static inline void __arch_decomp_setup(unsigned long arch_id)
125 DEBUG_LL_OMAP1(3, sx1); 129 DEBUG_LL_OMAP1(3, sx1);
126 130
127 /* omap2 based boards using UART1 */ 131 /* omap2 based boards using UART1 */
128 DEBUG_LL_OMAP2(1, omap2evm);
129 DEBUG_LL_OMAP2(1, omap_2430sdp); 132 DEBUG_LL_OMAP2(1, omap_2430sdp);
130 DEBUG_LL_OMAP2(1, omap_apollon); 133 DEBUG_LL_OMAP2(1, omap_apollon);
131 DEBUG_LL_OMAP2(1, omap_h4); 134 DEBUG_LL_OMAP2(1, omap_h4);
@@ -139,10 +142,17 @@ static inline void __arch_decomp_setup(unsigned long arch_id)
139 DEBUG_LL_OMAP2(1, omap3evm); 142 DEBUG_LL_OMAP2(1, omap3evm);
140 DEBUG_LL_OMAP3(1, omap_3430sdp); 143 DEBUG_LL_OMAP3(1, omap_3430sdp);
141 DEBUG_LL_OMAP3(1, omap_3630sdp); 144 DEBUG_LL_OMAP3(1, omap_3630sdp);
145 DEBUG_LL_OMAP3(1, omap3530_lv_som);
146 DEBUG_LL_OMAP3(1, omap3_torpedo);
142 147
143 /* omap3 based boards using UART3 */ 148 /* omap3 based boards using UART3 */
144 DEBUG_LL_OMAP3(3, cm_t35); 149 DEBUG_LL_OMAP3(3, cm_t35);
150 DEBUG_LL_OMAP3(3, cm_t3517);
151 DEBUG_LL_OMAP3(3, craneboard);
152 DEBUG_LL_OMAP3(3, devkit8000);
145 DEBUG_LL_OMAP3(3, igep0020); 153 DEBUG_LL_OMAP3(3, igep0020);
154 DEBUG_LL_OMAP3(3, igep0030);
155 DEBUG_LL_OMAP3(3, nokia_rm680);
146 DEBUG_LL_OMAP3(3, nokia_rx51); 156 DEBUG_LL_OMAP3(3, nokia_rx51);
147 DEBUG_LL_OMAP3(3, omap3517evm); 157 DEBUG_LL_OMAP3(3, omap3517evm);
148 DEBUG_LL_OMAP3(3, omap3_beagle); 158 DEBUG_LL_OMAP3(3, omap3_beagle);
@@ -153,11 +163,15 @@ static inline void __arch_decomp_setup(unsigned long arch_id)
153 163
154 /* omap4 based boards using UART3 */ 164 /* omap4 based boards using UART3 */
155 DEBUG_LL_OMAP4(3, omap_4430sdp); 165 DEBUG_LL_OMAP4(3, omap_4430sdp);
166 DEBUG_LL_OMAP4(3, omap4_panda);
156 167
157 /* zoom2/3 external uart */ 168 /* zoom2/3 external uart */
158 DEBUG_LL_ZOOM(omap_zoom2); 169 DEBUG_LL_ZOOM(omap_zoom2);
159 DEBUG_LL_ZOOM(omap_zoom3); 170 DEBUG_LL_ZOOM(omap_zoom3);
160 171
172 /* TI8168 base boards using UART3 */
173 DEBUG_LL_TI816X(3, ti8168evm);
174
161 } while (0); 175 } while (0);
162} 176}
163 177
diff --git a/arch/arm/plat-omap/include/plat/usb.h b/arch/arm/plat-omap/include/plat/usb.h
index 2a9427c8cc48..17d3c939775c 100644
--- a/arch/arm/plat-omap/include/plat/usb.h
+++ b/arch/arm/plat-omap/include/plat/usb.h
@@ -7,14 +7,12 @@
7#include <plat/board.h> 7#include <plat/board.h>
8 8
9#define OMAP3_HS_USB_PORTS 3 9#define OMAP3_HS_USB_PORTS 3
10enum ehci_hcd_omap_mode {
11 EHCI_HCD_OMAP_MODE_UNKNOWN,
12 EHCI_HCD_OMAP_MODE_PHY,
13 EHCI_HCD_OMAP_MODE_TLL,
14};
15 10
16enum ohci_omap3_port_mode { 11enum usbhs_omap_port_mode {
17 OMAP_OHCI_PORT_MODE_UNUSED, 12 OMAP_USBHS_PORT_MODE_UNUSED,
13 OMAP_EHCI_PORT_MODE_PHY,
14 OMAP_EHCI_PORT_MODE_TLL,
15 OMAP_EHCI_PORT_MODE_HSIC,
18 OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0, 16 OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0,
19 OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM, 17 OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM,
20 OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0, 18 OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0,
@@ -24,24 +22,45 @@ enum ohci_omap3_port_mode {
24 OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0, 22 OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0,
25 OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM, 23 OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM,
26 OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0, 24 OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0,
27 OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM, 25 OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM
28}; 26};
29 27
30struct ehci_hcd_omap_platform_data { 28struct usbhs_omap_board_data {
31 enum ehci_hcd_omap_mode port_mode[OMAP3_HS_USB_PORTS]; 29 enum usbhs_omap_port_mode port_mode[OMAP3_HS_USB_PORTS];
32 unsigned phy_reset:1;
33 30
34 /* have to be valid if phy_reset is true and portx is in phy mode */ 31 /* have to be valid if phy_reset is true and portx is in phy mode */
35 int reset_gpio_port[OMAP3_HS_USB_PORTS]; 32 int reset_gpio_port[OMAP3_HS_USB_PORTS];
33
34 /* Set this to true for ES2.x silicon */
35 unsigned es2_compatibility:1;
36
37 unsigned phy_reset:1;
38
39 /*
40 * Regulators for USB PHYs.
41 * Each PHY can have a separate regulator.
42 */
43 struct regulator *regulator[OMAP3_HS_USB_PORTS];
36}; 44};
37 45
38struct ohci_hcd_omap_platform_data { 46struct ehci_hcd_omap_platform_data {
39 enum ohci_omap3_port_mode port_mode[OMAP3_HS_USB_PORTS]; 47 enum usbhs_omap_port_mode port_mode[OMAP3_HS_USB_PORTS];
48 int reset_gpio_port[OMAP3_HS_USB_PORTS];
49 struct regulator *regulator[OMAP3_HS_USB_PORTS];
50 unsigned phy_reset:1;
51};
40 52
41 /* Set this to true for ES2.x silicon */ 53struct ohci_hcd_omap_platform_data {
54 enum usbhs_omap_port_mode port_mode[OMAP3_HS_USB_PORTS];
42 unsigned es2_compatibility:1; 55 unsigned es2_compatibility:1;
43}; 56};
44 57
58struct usbhs_omap_platform_data {
59 enum usbhs_omap_port_mode port_mode[OMAP3_HS_USB_PORTS];
60
61 struct ehci_hcd_omap_platform_data *ehci_data;
62 struct ohci_hcd_omap_platform_data *ohci_data;
63};
45/*-------------------------------------------------------------------------*/ 64/*-------------------------------------------------------------------------*/
46 65
47#define OMAP1_OTG_BASE 0xfffb0400 66#define OMAP1_OTG_BASE 0xfffb0400
@@ -69,18 +88,32 @@ struct omap_musb_board_data {
69 u8 mode; 88 u8 mode;
70 u16 power; 89 u16 power;
71 unsigned extvbus:1; 90 unsigned extvbus:1;
91 void (*set_phy_power)(u8 on);
92 void (*clear_irq)(void);
93 void (*set_mode)(u8 mode);
94 void (*reset)(void);
72}; 95};
73 96
74enum musb_interface {MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI}; 97enum musb_interface {MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI};
75 98
76extern void usb_musb_init(struct omap_musb_board_data *board_data); 99extern void usb_musb_init(struct omap_musb_board_data *board_data);
77 100
78extern void usb_ehci_init(const struct ehci_hcd_omap_platform_data *pdata); 101extern void usbhs_init(const struct usbhs_omap_board_data *pdata);
79 102
80extern void usb_ohci_init(const struct ohci_hcd_omap_platform_data *pdata); 103extern int omap_usbhs_enable(struct device *dev);
104extern void omap_usbhs_disable(struct device *dev);
81 105
106extern int omap4430_phy_power(struct device *dev, int ID, int on);
107extern int omap4430_phy_set_clk(struct device *dev, int on);
108extern int omap4430_phy_init(struct device *dev);
109extern int omap4430_phy_exit(struct device *dev);
110extern int omap4430_phy_suspend(struct device *dev, int suspend);
82#endif 111#endif
83 112
113extern void am35x_musb_reset(void);
114extern void am35x_musb_phy_power(u8 on);
115extern void am35x_musb_clear_irq(void);
116extern void am35x_set_mode(u8 musb_mode);
84 117
85/* 118/*
86 * FIXME correct answer depends on hmc_mode, 119 * FIXME correct answer depends on hmc_mode,
@@ -105,7 +138,7 @@ static inline void omap1_usb_init(struct omap_usb_config *pdata)
105#if defined(CONFIG_ARCH_OMAP_OTG) || defined(CONFIG_ARCH_OMAP_OTG_MODULE) 138#if defined(CONFIG_ARCH_OMAP_OTG) || defined(CONFIG_ARCH_OMAP_OTG_MODULE)
106void omap2_usbfs_init(struct omap_usb_config *pdata); 139void omap2_usbfs_init(struct omap_usb_config *pdata);
107#else 140#else
108static inline omap2_usbfs_init(struct omap_usb_config *pdata) 141static inline void omap2_usbfs_init(struct omap_usb_config *pdata)
109{ 142{
110} 143}
111#endif 144#endif
@@ -218,6 +251,27 @@ static inline omap2_usbfs_init(struct omap_usb_config *pdata)
218# define USBT2TLL5PI (1 << 17) 251# define USBT2TLL5PI (1 << 17)
219# define USB0PUENACTLOI (1 << 16) 252# define USB0PUENACTLOI (1 << 16)
220# define USBSTANDBYCTRL (1 << 15) 253# define USBSTANDBYCTRL (1 << 15)
254/* AM35x */
255/* USB 2.0 PHY Control */
256#define CONF2_PHY_GPIOMODE (1 << 23)
257#define CONF2_OTGMODE (3 << 14)
258#define CONF2_NO_OVERRIDE (0 << 14)
259#define CONF2_FORCE_HOST (1 << 14)
260#define CONF2_FORCE_DEVICE (2 << 14)
261#define CONF2_FORCE_HOST_VBUS_LOW (3 << 14)
262#define CONF2_SESENDEN (1 << 13)
263#define CONF2_VBDTCTEN (1 << 12)
264#define CONF2_REFFREQ_24MHZ (2 << 8)
265#define CONF2_REFFREQ_26MHZ (7 << 8)
266#define CONF2_REFFREQ_13MHZ (6 << 8)
267#define CONF2_REFFREQ (0xf << 8)
268#define CONF2_PHYCLKGD (1 << 7)
269#define CONF2_VBUSSENSE (1 << 6)
270#define CONF2_PHY_PLLON (1 << 5)
271#define CONF2_RESET (1 << 4)
272#define CONF2_PHYPWRDN (1 << 3)
273#define CONF2_OTGPWRDN (1 << 2)
274#define CONF2_DATPOL (1 << 1)
221 275
222#if defined(CONFIG_ARCH_OMAP1) && defined(CONFIG_USB) 276#if defined(CONFIG_ARCH_OMAP1) && defined(CONFIG_USB)
223u32 omap1_usb0_init(unsigned nwires, unsigned is_device); 277u32 omap1_usb0_init(unsigned nwires, unsigned is_device);
diff --git a/arch/arm/plat-omap/include/plat/vrfb.h b/arch/arm/plat-omap/include/plat/vrfb.h
index d8a03ced3b10..3792bdea2f6d 100644
--- a/arch/arm/plat-omap/include/plat/vrfb.h
+++ b/arch/arm/plat-omap/include/plat/vrfb.h
@@ -35,6 +35,7 @@ struct vrfb {
35 bool yuv_mode; 35 bool yuv_mode;
36}; 36};
37 37
38#ifdef CONFIG_OMAP2_VRFB
38extern int omap_vrfb_request_ctx(struct vrfb *vrfb); 39extern int omap_vrfb_request_ctx(struct vrfb *vrfb);
39extern void omap_vrfb_release_ctx(struct vrfb *vrfb); 40extern void omap_vrfb_release_ctx(struct vrfb *vrfb);
40extern void omap_vrfb_adjust_size(u16 *width, u16 *height, 41extern void omap_vrfb_adjust_size(u16 *width, u16 *height,
@@ -47,4 +48,19 @@ extern void omap_vrfb_setup(struct vrfb *vrfb, unsigned long paddr,
47extern int omap_vrfb_map_angle(struct vrfb *vrfb, u16 height, u8 rot); 48extern int omap_vrfb_map_angle(struct vrfb *vrfb, u16 height, u8 rot);
48extern void omap_vrfb_restore_context(void); 49extern void omap_vrfb_restore_context(void);
49 50
51#else
52static inline int omap_vrfb_request_ctx(struct vrfb *vrfb) { return 0; }
53static inline void omap_vrfb_release_ctx(struct vrfb *vrfb) {}
54static inline void omap_vrfb_adjust_size(u16 *width, u16 *height,
55 u8 bytespp) {}
56static inline u32 omap_vrfb_min_phys_size(u16 width, u16 height, u8 bytespp)
57 { return 0; }
58static inline u16 omap_vrfb_max_height(u32 phys_size, u16 width, u8 bytespp)
59 { return 0; }
60static inline void omap_vrfb_setup(struct vrfb *vrfb, unsigned long paddr,
61 u16 width, u16 height, unsigned bytespp, bool yuv_mode) {}
62static inline int omap_vrfb_map_angle(struct vrfb *vrfb, u16 height, u8 rot)
63 { return 0; }
64static inline void omap_vrfb_restore_context(void) {}
65#endif
50#endif /* __VRFB_H */ 66#endif /* __VRFB_H */
diff --git a/arch/arm/plat-omap/io.c b/arch/arm/plat-omap/io.c
index b0078cf96281..f1ecfa9fc61d 100644
--- a/arch/arm/plat-omap/io.c
+++ b/arch/arm/plat-omap/io.c
@@ -85,7 +85,10 @@ void __iomem *omap_ioremap(unsigned long p, size_t size, unsigned int type)
85 } 85 }
86#endif 86#endif
87#ifdef CONFIG_ARCH_OMAP3 87#ifdef CONFIG_ARCH_OMAP3
88 if (cpu_is_omap34xx()) { 88 if (cpu_is_ti816x()) {
89 if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
90 return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT);
91 } else if (cpu_is_omap34xx()) {
89 if (BETWEEN(p, L3_34XX_PHYS, L3_34XX_SIZE)) 92 if (BETWEEN(p, L3_34XX_PHYS, L3_34XX_SIZE))
90 return XLATE(p, L3_34XX_PHYS, L3_34XX_VIRT); 93 return XLATE(p, L3_34XX_PHYS, L3_34XX_VIRT);
91 if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE)) 94 if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
@@ -136,61 +139,3 @@ void omap_iounmap(volatile void __iomem *addr)
136 __iounmap(addr); 139 __iounmap(addr);
137} 140}
138EXPORT_SYMBOL(omap_iounmap); 141EXPORT_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-debug.c b/arch/arm/plat-omap/iommu-debug.c
index e6c0d536899c..f07cf2f08e09 100644
--- a/arch/arm/plat-omap/iommu-debug.c
+++ b/arch/arm/plat-omap/iommu-debug.c
@@ -328,12 +328,14 @@ static int debug_open_generic(struct inode *inode, struct file *file)
328 .open = debug_open_generic, \ 328 .open = debug_open_generic, \
329 .read = debug_read_##name, \ 329 .read = debug_read_##name, \
330 .write = debug_write_##name, \ 330 .write = debug_write_##name, \
331 .llseek = generic_file_llseek, \
331 }; 332 };
332 333
333#define DEBUG_FOPS_RO(name) \ 334#define DEBUG_FOPS_RO(name) \
334 static const struct file_operations debug_##name##_fops = { \ 335 static const struct file_operations debug_##name##_fops = { \
335 .open = debug_open_generic, \ 336 .open = debug_open_generic, \
336 .read = debug_read_##name, \ 337 .read = debug_read_##name, \
338 .llseek = generic_file_llseek, \
337 }; 339 };
338 340
339DEBUG_FOPS_RO(ver); 341DEBUG_FOPS_RO(ver);
diff --git a/arch/arm/plat-omap/iommu.c b/arch/arm/plat-omap/iommu.c
index 6cd151b31bc5..34fc31ee9081 100644
--- a/arch/arm/plat-omap/iommu.c
+++ b/arch/arm/plat-omap/iommu.c
@@ -104,6 +104,9 @@ static int iommu_enable(struct iommu *obj)
104 if (!obj) 104 if (!obj)
105 return -EINVAL; 105 return -EINVAL;
106 106
107 if (!arch_iommu)
108 return -ENODEV;
109
107 clk_enable(obj->clk); 110 clk_enable(obj->clk);
108 111
109 err = arch_iommu->enable(obj); 112 err = arch_iommu->enable(obj);
@@ -780,25 +783,21 @@ static void iopgtable_clear_entry_all(struct iommu *obj)
780 */ 783 */
781static irqreturn_t iommu_fault_handler(int irq, void *data) 784static irqreturn_t iommu_fault_handler(int irq, void *data)
782{ 785{
783 u32 stat, da; 786 u32 da, errs;
784 u32 *iopgd, *iopte; 787 u32 *iopgd, *iopte;
785 int err = -EIO;
786 struct iommu *obj = data; 788 struct iommu *obj = data;
787 789
788 if (!obj->refcount) 790 if (!obj->refcount)
789 return IRQ_NONE; 791 return IRQ_NONE;
790 792
791 /* Dynamic loading TLB or PTE */
792 if (obj->isr)
793 err = obj->isr(obj);
794
795 if (!err)
796 return IRQ_HANDLED;
797
798 clk_enable(obj->clk); 793 clk_enable(obj->clk);
799 stat = iommu_report_fault(obj, &da); 794 errs = iommu_report_fault(obj, &da);
800 clk_disable(obj->clk); 795 clk_disable(obj->clk);
801 if (!stat) 796 if (errs == 0)
797 return IRQ_HANDLED;
798
799 /* Fault callback or TLB/PTE Dynamic loading */
800 if (obj->isr && !obj->isr(obj, da, errs, obj->isr_priv))
802 return IRQ_HANDLED; 801 return IRQ_HANDLED;
803 802
804 iommu_disable(obj); 803 iommu_disable(obj);
@@ -806,15 +805,16 @@ static irqreturn_t iommu_fault_handler(int irq, void *data)
806 iopgd = iopgd_offset(obj, da); 805 iopgd = iopgd_offset(obj, da);
807 806
808 if (!iopgd_is_table(*iopgd)) { 807 if (!iopgd_is_table(*iopgd)) {
809 dev_err(obj->dev, "%s: da:%08x pgd:%p *pgd:%08x\n", __func__, 808 dev_err(obj->dev, "%s: errs:0x%08x da:0x%08x pgd:0x%p "
810 da, iopgd, *iopgd); 809 "*pgd:px%08x\n", obj->name, errs, da, iopgd, *iopgd);
811 return IRQ_NONE; 810 return IRQ_NONE;
812 } 811 }
813 812
814 iopte = iopte_offset(iopgd, da); 813 iopte = iopte_offset(iopgd, da);
815 814
816 dev_err(obj->dev, "%s: da:%08x pgd:%p *pgd:%08x pte:%p *pte:%08x\n", 815 dev_err(obj->dev, "%s: errs:0x%08x da:0x%08x pgd:0x%p *pgd:0x%08x "
817 __func__, da, iopgd, *iopgd, iopte, *iopte); 816 "pte:0x%p *pte:0x%08x\n", obj->name, errs, da, iopgd, *iopgd,
817 iopte, *iopte);
818 818
819 return IRQ_NONE; 819 return IRQ_NONE;
820} 820}
@@ -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 **/
@@ -895,6 +917,33 @@ void iommu_put(struct iommu *obj)
895} 917}
896EXPORT_SYMBOL_GPL(iommu_put); 918EXPORT_SYMBOL_GPL(iommu_put);
897 919
920int iommu_set_isr(const char *name,
921 int (*isr)(struct iommu *obj, u32 da, u32 iommu_errs,
922 void *priv),
923 void *isr_priv)
924{
925 struct device *dev;
926 struct iommu *obj;
927
928 dev = driver_find_device(&omap_iommu_driver.driver, NULL, (void *)name,
929 device_match_by_alias);
930 if (!dev)
931 return -ENODEV;
932
933 obj = to_iommu(dev);
934 mutex_lock(&obj->iommu_lock);
935 if (obj->refcount != 0) {
936 mutex_unlock(&obj->iommu_lock);
937 return -EBUSY;
938 }
939 obj->isr = isr;
940 obj->isr_priv = isr_priv;
941 mutex_unlock(&obj->iommu_lock);
942
943 return 0;
944}
945EXPORT_SYMBOL_GPL(iommu_set_isr);
946
898/* 947/*
899 * OMAP Device MMU(IOMMU) detection 948 * OMAP Device MMU(IOMMU) detection
900 */ 949 */
@@ -922,6 +971,8 @@ static int __devinit omap_iommu_probe(struct platform_device *pdev)
922 obj->name = pdata->name; 971 obj->name = pdata->name;
923 obj->dev = &pdev->dev; 972 obj->dev = &pdev->dev;
924 obj->ctx = (void *)obj + sizeof(*obj); 973 obj->ctx = (void *)obj + sizeof(*obj);
974 obj->da_start = pdata->da_start;
975 obj->da_end = pdata->da_end;
925 976
926 mutex_init(&obj->iommu_lock); 977 mutex_init(&obj->iommu_lock);
927 mutex_init(&obj->mmap_lock); 978 mutex_init(&obj->mmap_lock);
@@ -933,11 +984,6 @@ static int __devinit omap_iommu_probe(struct platform_device *pdev)
933 err = -ENODEV; 984 err = -ENODEV;
934 goto err_mem; 985 goto err_mem;
935 } 986 }
936 obj->regbase = ioremap(res->start, resource_size(res));
937 if (!obj->regbase) {
938 err = -ENOMEM;
939 goto err_mem;
940 }
941 987
942 res = request_mem_region(res->start, resource_size(res), 988 res = request_mem_region(res->start, resource_size(res),
943 dev_name(&pdev->dev)); 989 dev_name(&pdev->dev));
@@ -946,6 +992,12 @@ static int __devinit omap_iommu_probe(struct platform_device *pdev)
946 goto err_mem; 992 goto err_mem;
947 } 993 }
948 994
995 obj->regbase = ioremap(res->start, resource_size(res));
996 if (!obj->regbase) {
997 err = -ENOMEM;
998 goto err_ioremap;
999 }
1000
949 irq = platform_get_irq(pdev, 0); 1001 irq = platform_get_irq(pdev, 0);
950 if (irq < 0) { 1002 if (irq < 0) {
951 err = -ENODEV; 1003 err = -ENODEV;
@@ -974,8 +1026,9 @@ static int __devinit omap_iommu_probe(struct platform_device *pdev)
974err_pgd: 1026err_pgd:
975 free_irq(irq, obj); 1027 free_irq(irq, obj);
976err_irq: 1028err_irq:
977 release_mem_region(res->start, resource_size(res));
978 iounmap(obj->regbase); 1029 iounmap(obj->regbase);
1030err_ioremap:
1031 release_mem_region(res->start, resource_size(res));
979err_mem: 1032err_mem:
980 clk_put(obj->clk); 1033 clk_put(obj->clk);
981err_clk: 1034err_clk:
diff --git a/arch/arm/plat-omap/iovmm.c b/arch/arm/plat-omap/iovmm.c
index 8ce0de247c71..83a37c54342f 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
@@ -264,22 +271,24 @@ static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da,
264 size_t bytes, u32 flags) 271 size_t bytes, u32 flags)
265{ 272{
266 struct iovm_struct *new, *tmp; 273 struct iovm_struct *new, *tmp;
267 u32 start, prev_end, alignement; 274 u32 start, prev_end, alignment;
268 275
269 if (!obj || !bytes) 276 if (!obj || !bytes)
270 return ERR_PTR(-EINVAL); 277 return ERR_PTR(-EINVAL);
271 278
272 start = da; 279 start = da;
273 alignement = PAGE_SIZE; 280 alignment = PAGE_SIZE;
281
282 if (~flags & IOVMF_DA_FIXED) {
283 /* Don't map address 0 */
284 start = obj->da_start ? obj->da_start : alignment;
274 285
275 if (flags & IOVMF_DA_ANON) {
276 /*
277 * Reserve the first page for NULL
278 */
279 start = PAGE_SIZE;
280 if (flags & IOVMF_LINEAR) 286 if (flags & IOVMF_LINEAR)
281 alignement = iopgsz_max(bytes); 287 alignment = iopgsz_max(bytes);
282 start = roundup(start, alignement); 288 start = roundup(start, alignment);
289 } else if (start < obj->da_start || start > obj->da_end ||
290 obj->da_end - start < bytes) {
291 return ERR_PTR(-EINVAL);
283 } 292 }
284 293
285 tmp = NULL; 294 tmp = NULL;
@@ -289,19 +298,19 @@ static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da,
289 prev_end = 0; 298 prev_end = 0;
290 list_for_each_entry(tmp, &obj->mmap, list) { 299 list_for_each_entry(tmp, &obj->mmap, list) {
291 300
292 if (prev_end >= start) 301 if (prev_end > start)
293 break; 302 break;
294 303
295 if (start + bytes < tmp->da_start) 304 if (tmp->da_start > start && (tmp->da_start - start) >= bytes)
296 goto found; 305 goto found;
297 306
298 if (flags & IOVMF_DA_ANON) 307 if (tmp->da_end >= start && ~flags & IOVMF_DA_FIXED)
299 start = roundup(tmp->da_end + 1, alignement); 308 start = roundup(tmp->da_end + 1, alignment);
300 309
301 prev_end = tmp->da_end; 310 prev_end = tmp->da_end;
302 } 311 }
303 312
304 if ((start > prev_end) && (ULONG_MAX - start >= bytes)) 313 if ((start >= prev_end) && (obj->da_end - start >= bytes))
305 goto found; 314 goto found;
306 315
307 dev_dbg(obj->dev, "%s: no space to fit %08x(%x) flags: %08x\n", 316 dev_dbg(obj->dev, "%s: no space to fit %08x(%x) flags: %08x\n",
@@ -409,7 +418,8 @@ static inline void sgtable_drain_vmalloc(struct sg_table *sgt)
409 BUG_ON(!sgt); 418 BUG_ON(!sgt);
410} 419}
411 420
412static void sgtable_fill_kmalloc(struct sg_table *sgt, u32 pa, size_t len) 421static void sgtable_fill_kmalloc(struct sg_table *sgt, u32 pa, u32 da,
422 size_t len)
413{ 423{
414 unsigned int i; 424 unsigned int i;
415 struct scatterlist *sg; 425 struct scatterlist *sg;
@@ -418,9 +428,10 @@ static void sgtable_fill_kmalloc(struct sg_table *sgt, u32 pa, size_t len)
418 va = phys_to_virt(pa); 428 va = phys_to_virt(pa);
419 429
420 for_each_sg(sgt->sgl, sg, sgt->nents, i) { 430 for_each_sg(sgt->sgl, sg, sgt->nents, i) {
421 size_t bytes; 431 unsigned bytes;
422 432
423 bytes = iopgsz_max(len); 433 bytes = max_alignment(da | pa);
434 bytes = min_t(unsigned, bytes, iopgsz_max(len));
424 435
425 BUG_ON(!iopgsz_ok(bytes)); 436 BUG_ON(!iopgsz_ok(bytes));
426 437
@@ -429,6 +440,7 @@ static void sgtable_fill_kmalloc(struct sg_table *sgt, u32 pa, size_t len)
429 * 'pa' is cotinuous(linear). 440 * 'pa' is cotinuous(linear).
430 */ 441 */
431 pa += bytes; 442 pa += bytes;
443 da += bytes;
432 len -= bytes; 444 len -= bytes;
433 } 445 }
434 BUG_ON(len); 446 BUG_ON(len);
@@ -636,10 +648,8 @@ u32 iommu_vmap(struct iommu *obj, u32 da, const struct sg_table *sgt,
636 return PTR_ERR(va); 648 return PTR_ERR(va);
637 } 649 }
638 650
639 flags &= IOVMF_HW_MASK;
640 flags |= IOVMF_DISCONT; 651 flags |= IOVMF_DISCONT;
641 flags |= IOVMF_MMIO; 652 flags |= IOVMF_MMIO;
642 flags |= (da ? IOVMF_DA_FIXED : IOVMF_DA_ANON);
643 653
644 da = __iommu_vmap(obj, da, sgt, va, bytes, flags); 654 da = __iommu_vmap(obj, da, sgt, va, bytes, flags);
645 if (IS_ERR_VALUE(da)) 655 if (IS_ERR_VALUE(da))
@@ -679,7 +689,7 @@ EXPORT_SYMBOL_GPL(iommu_vunmap);
679 * @flags: iovma and page property 689 * @flags: iovma and page property
680 * 690 *
681 * Allocate @bytes linearly and creates 1-n-1 mapping and returns 691 * Allocate @bytes linearly and creates 1-n-1 mapping and returns
682 * @da again, which might be adjusted if 'IOVMF_DA_ANON' is set. 692 * @da again, which might be adjusted if 'IOVMF_DA_FIXED' is not set.
683 */ 693 */
684u32 iommu_vmalloc(struct iommu *obj, u32 da, size_t bytes, u32 flags) 694u32 iommu_vmalloc(struct iommu *obj, u32 da, size_t bytes, u32 flags)
685{ 695{
@@ -695,18 +705,16 @@ u32 iommu_vmalloc(struct iommu *obj, u32 da, size_t bytes, u32 flags)
695 if (!va) 705 if (!va)
696 return -ENOMEM; 706 return -ENOMEM;
697 707
698 sgt = sgtable_alloc(bytes, flags); 708 flags |= IOVMF_DISCONT;
709 flags |= IOVMF_ALLOC;
710
711 sgt = sgtable_alloc(bytes, flags, da, 0);
699 if (IS_ERR(sgt)) { 712 if (IS_ERR(sgt)) {
700 da = PTR_ERR(sgt); 713 da = PTR_ERR(sgt);
701 goto err_sgt_alloc; 714 goto err_sgt_alloc;
702 } 715 }
703 sgtable_fill_vmalloc(sgt, va); 716 sgtable_fill_vmalloc(sgt, va);
704 717
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); 718 da = __iommu_vmap(obj, da, sgt, va, bytes, flags);
711 if (IS_ERR_VALUE(da)) 719 if (IS_ERR_VALUE(da))
712 goto err_iommu_vmap; 720 goto err_iommu_vmap;
@@ -746,11 +754,11 @@ static u32 __iommu_kmap(struct iommu *obj, u32 da, u32 pa, void *va,
746{ 754{
747 struct sg_table *sgt; 755 struct sg_table *sgt;
748 756
749 sgt = sgtable_alloc(bytes, flags); 757 sgt = sgtable_alloc(bytes, flags, da, pa);
750 if (IS_ERR(sgt)) 758 if (IS_ERR(sgt))
751 return PTR_ERR(sgt); 759 return PTR_ERR(sgt);
752 760
753 sgtable_fill_kmalloc(sgt, pa, bytes); 761 sgtable_fill_kmalloc(sgt, pa, da, bytes);
754 762
755 da = map_iommu_region(obj, da, sgt, va, bytes, flags); 763 da = map_iommu_region(obj, da, sgt, va, bytes, flags);
756 if (IS_ERR_VALUE(da)) { 764 if (IS_ERR_VALUE(da)) {
@@ -769,7 +777,7 @@ static u32 __iommu_kmap(struct iommu *obj, u32 da, u32 pa, void *va,
769 * @flags: iovma and page property 777 * @flags: iovma and page property
770 * 778 *
771 * Creates 1-1-1 mapping and returns @da again, which can be 779 * Creates 1-1-1 mapping and returns @da again, which can be
772 * adjusted if 'IOVMF_DA_ANON' is set. 780 * adjusted if 'IOVMF_DA_FIXED' is not set.
773 */ 781 */
774u32 iommu_kmap(struct iommu *obj, u32 da, u32 pa, size_t bytes, 782u32 iommu_kmap(struct iommu *obj, u32 da, u32 pa, size_t bytes,
775 u32 flags) 783 u32 flags)
@@ -785,10 +793,8 @@ u32 iommu_kmap(struct iommu *obj, u32 da, u32 pa, size_t bytes,
785 if (!va) 793 if (!va)
786 return -ENOMEM; 794 return -ENOMEM;
787 795
788 flags &= IOVMF_HW_MASK;
789 flags |= IOVMF_LINEAR; 796 flags |= IOVMF_LINEAR;
790 flags |= IOVMF_MMIO; 797 flags |= IOVMF_MMIO;
791 flags |= (da ? IOVMF_DA_FIXED : IOVMF_DA_ANON);
792 798
793 da = __iommu_kmap(obj, da, pa, va, bytes, flags); 799 da = __iommu_kmap(obj, da, pa, va, bytes, flags);
794 if (IS_ERR_VALUE(da)) 800 if (IS_ERR_VALUE(da))
@@ -811,7 +817,7 @@ void iommu_kunmap(struct iommu *obj, u32 da)
811 struct sg_table *sgt; 817 struct sg_table *sgt;
812 typedef void (*func_t)(const void *); 818 typedef void (*func_t)(const void *);
813 819
814 sgt = unmap_vm_area(obj, da, (func_t)__iounmap, 820 sgt = unmap_vm_area(obj, da, (func_t)iounmap,
815 IOVMF_LINEAR | IOVMF_MMIO); 821 IOVMF_LINEAR | IOVMF_MMIO);
816 if (!sgt) 822 if (!sgt)
817 dev_dbg(obj->dev, "%s: No sgt\n", __func__); 823 dev_dbg(obj->dev, "%s: No sgt\n", __func__);
@@ -827,7 +833,7 @@ EXPORT_SYMBOL_GPL(iommu_kunmap);
827 * @flags: iovma and page property 833 * @flags: iovma and page property
828 * 834 *
829 * Allocate @bytes linearly and creates 1-1-1 mapping and returns 835 * Allocate @bytes linearly and creates 1-1-1 mapping and returns
830 * @da again, which might be adjusted if 'IOVMF_DA_ANON' is set. 836 * @da again, which might be adjusted if 'IOVMF_DA_FIXED' is not set.
831 */ 837 */
832u32 iommu_kmalloc(struct iommu *obj, u32 da, size_t bytes, u32 flags) 838u32 iommu_kmalloc(struct iommu *obj, u32 da, size_t bytes, u32 flags)
833{ 839{
@@ -844,10 +850,8 @@ u32 iommu_kmalloc(struct iommu *obj, u32 da, size_t bytes, u32 flags)
844 return -ENOMEM; 850 return -ENOMEM;
845 pa = virt_to_phys(va); 851 pa = virt_to_phys(va);
846 852
847 flags &= IOVMF_HW_MASK;
848 flags |= IOVMF_LINEAR; 853 flags |= IOVMF_LINEAR;
849 flags |= IOVMF_ALLOC; 854 flags |= IOVMF_ALLOC;
850 flags |= (da ? IOVMF_DA_FIXED : IOVMF_DA_ANON);
851 855
852 da = __iommu_kmap(obj, da, pa, va, bytes, flags); 856 da = __iommu_kmap(obj, da, pa, va, bytes, flags);
853 if (IS_ERR_VALUE(da)) 857 if (IS_ERR_VALUE(da))
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index d2fafb892f7f..69ddc9f76c13 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -28,12 +28,11 @@
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 omap_mbox **mboxes; 35static struct omap_mbox **mboxes;
36static bool rq_full;
37 36
38static int mbox_configured; 37static int mbox_configured;
39static DEFINE_MUTEX(mbox_configured_lock); 38static DEFINE_MUTEX(mbox_configured_lock);
@@ -93,20 +92,25 @@ int omap_mbox_msg_send(struct omap_mbox *mbox, mbox_msg_t msg)
93 struct omap_mbox_queue *mq = mbox->txq; 92 struct omap_mbox_queue *mq = mbox->txq;
94 int ret = 0, len; 93 int ret = 0, len;
95 94
96 spin_lock(&mq->lock); 95 spin_lock_bh(&mq->lock);
97 96
98 if (kfifo_avail(&mq->fifo) < sizeof(msg)) { 97 if (kfifo_avail(&mq->fifo) < sizeof(msg)) {
99 ret = -ENOMEM; 98 ret = -ENOMEM;
100 goto out; 99 goto out;
101 } 100 }
102 101
102 if (kfifo_is_empty(&mq->fifo) && !__mbox_poll_for_space(mbox)) {
103 mbox_fifo_write(mbox, msg);
104 goto out;
105 }
106
103 len = kfifo_in(&mq->fifo, (unsigned char *)&msg, sizeof(msg)); 107 len = kfifo_in(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
104 WARN_ON(len != sizeof(msg)); 108 WARN_ON(len != sizeof(msg));
105 109
106 tasklet_schedule(&mbox->txq->tasklet); 110 tasklet_schedule(&mbox->txq->tasklet);
107 111
108out: 112out:
109 spin_unlock(&mq->lock); 113 spin_unlock_bh(&mq->lock);
110 return ret; 114 return ret;
111} 115}
112EXPORT_SYMBOL(omap_mbox_msg_send); 116EXPORT_SYMBOL(omap_mbox_msg_send);
@@ -146,8 +150,14 @@ static void mbox_rx_work(struct work_struct *work)
146 len = kfifo_out(&mq->fifo, (unsigned char *)&msg, sizeof(msg)); 150 len = kfifo_out(&mq->fifo, (unsigned char *)&msg, sizeof(msg));
147 WARN_ON(len != sizeof(msg)); 151 WARN_ON(len != sizeof(msg));
148 152
149 if (mq->callback) 153 blocking_notifier_call_chain(&mq->mbox->notifier, len,
150 mq->callback((void *)msg); 154 (void *)msg);
155 spin_lock_irq(&mq->lock);
156 if (mq->full) {
157 mq->full = false;
158 omap_mbox_enable_irq(mq->mbox, IRQ_RX);
159 }
160 spin_unlock_irq(&mq->lock);
151 } 161 }
152} 162}
153 163
@@ -170,7 +180,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
170 while (!mbox_fifo_empty(mbox)) { 180 while (!mbox_fifo_empty(mbox)) {
171 if (unlikely(kfifo_avail(&mq->fifo) < sizeof(msg))) { 181 if (unlikely(kfifo_avail(&mq->fifo) < sizeof(msg))) {
172 omap_mbox_disable_irq(mbox, IRQ_RX); 182 omap_mbox_disable_irq(mbox, IRQ_RX);
173 rq_full = true; 183 mq->full = true;
174 goto nomem; 184 goto nomem;
175 } 185 }
176 186
@@ -186,7 +196,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
186 /* no more messages in the fifo. clear IRQ source. */ 196 /* no more messages in the fifo. clear IRQ source. */
187 ack_mbox_irq(mbox, IRQ_RX); 197 ack_mbox_irq(mbox, IRQ_RX);
188nomem: 198nomem:
189 queue_work(mboxd, &mbox->rxq->work); 199 schedule_work(&mbox->rxq->work);
190} 200}
191 201
192static irqreturn_t mbox_interrupt(int irq, void *p) 202static irqreturn_t mbox_interrupt(int irq, void *p)
@@ -239,83 +249,90 @@ static int omap_mbox_startup(struct omap_mbox *mbox)
239 int ret = 0; 249 int ret = 0;
240 struct omap_mbox_queue *mq; 250 struct omap_mbox_queue *mq;
241 251
242 if (mbox->ops->startup) { 252 mutex_lock(&mbox_configured_lock);
243 mutex_lock(&mbox_configured_lock); 253 if (!mbox_configured++) {
244 if (!mbox_configured) 254 if (likely(mbox->ops->startup)) {
245 ret = mbox->ops->startup(mbox); 255 ret = mbox->ops->startup(mbox);
246 256 if (unlikely(ret))
247 if (ret) { 257 goto fail_startup;
248 mutex_unlock(&mbox_configured_lock); 258 } else
249 return ret; 259 goto fail_startup;
250 }
251 mbox_configured++;
252 mutex_unlock(&mbox_configured_lock);
253 } 260 }
254 261
255 ret = request_irq(mbox->irq, mbox_interrupt, IRQF_SHARED, 262 if (!mbox->use_count++) {
256 mbox->name, mbox); 263 ret = request_irq(mbox->irq, mbox_interrupt, IRQF_SHARED,
257 if (ret) { 264 mbox->name, mbox);
258 printk(KERN_ERR 265 if (unlikely(ret)) {
259 "failed to register mailbox interrupt:%d\n", ret); 266 pr_err("failed to register mailbox interrupt:%d\n",
260 goto fail_request_irq; 267 ret);
261 } 268 goto fail_request_irq;
262 269 }
263 mq = mbox_queue_alloc(mbox, NULL, mbox_tx_tasklet); 270 mq = mbox_queue_alloc(mbox, NULL, mbox_tx_tasklet);
264 if (!mq) { 271 if (!mq) {
265 ret = -ENOMEM; 272 ret = -ENOMEM;
266 goto fail_alloc_txq; 273 goto fail_alloc_txq;
267 } 274 }
268 mbox->txq = mq; 275 mbox->txq = mq;
269 276
270 mq = mbox_queue_alloc(mbox, mbox_rx_work, NULL); 277 mq = mbox_queue_alloc(mbox, mbox_rx_work, NULL);
271 if (!mq) { 278 if (!mq) {
272 ret = -ENOMEM; 279 ret = -ENOMEM;
273 goto fail_alloc_rxq; 280 goto fail_alloc_rxq;
281 }
282 mbox->rxq = mq;
283 mq->mbox = mbox;
274 } 284 }
275 mbox->rxq = mq; 285 mutex_unlock(&mbox_configured_lock);
276
277 return 0; 286 return 0;
278 287
279 fail_alloc_rxq: 288fail_alloc_rxq:
280 mbox_queue_free(mbox->txq); 289 mbox_queue_free(mbox->txq);
281 fail_alloc_txq: 290fail_alloc_txq:
282 free_irq(mbox->irq, mbox); 291 free_irq(mbox->irq, mbox);
283 fail_request_irq: 292fail_request_irq:
284 if (mbox->ops->shutdown) 293 if (mbox->ops->shutdown)
285 mbox->ops->shutdown(mbox); 294 mbox->ops->shutdown(mbox);
286 295 mbox->use_count--;
296fail_startup:
297 mbox_configured--;
298 mutex_unlock(&mbox_configured_lock);
287 return ret; 299 return ret;
288} 300}
289 301
290static void omap_mbox_fini(struct omap_mbox *mbox) 302static void omap_mbox_fini(struct omap_mbox *mbox)
291{ 303{
292 free_irq(mbox->irq, mbox); 304 mutex_lock(&mbox_configured_lock);
293 tasklet_kill(&mbox->txq->tasklet); 305
294 flush_work(&mbox->rxq->work); 306 if (!--mbox->use_count) {
295 mbox_queue_free(mbox->txq); 307 free_irq(mbox->irq, mbox);
296 mbox_queue_free(mbox->rxq); 308 tasklet_kill(&mbox->txq->tasklet);
309 flush_work_sync(&mbox->rxq->work);
310 mbox_queue_free(mbox->txq);
311 mbox_queue_free(mbox->rxq);
312 }
297 313
298 if (mbox->ops->shutdown) { 314 if (likely(mbox->ops->shutdown)) {
299 mutex_lock(&mbox_configured_lock); 315 if (!--mbox_configured)
300 if (mbox_configured > 0)
301 mbox_configured--;
302 if (!mbox_configured)
303 mbox->ops->shutdown(mbox); 316 mbox->ops->shutdown(mbox);
304 mutex_unlock(&mbox_configured_lock);
305 } 317 }
318
319 mutex_unlock(&mbox_configured_lock);
306} 320}
307 321
308struct omap_mbox *omap_mbox_get(const char *name) 322struct omap_mbox *omap_mbox_get(const char *name, struct notifier_block *nb)
309{ 323{
310 struct omap_mbox *mbox; 324 struct omap_mbox *_mbox, *mbox = NULL;
311 int ret; 325 int i, ret;
312 326
313 if (!mboxes) 327 if (!mboxes)
314 return ERR_PTR(-EINVAL); 328 return ERR_PTR(-EINVAL);
315 329
316 for (mbox = *mboxes; mbox; mbox++) 330 for (i = 0; (_mbox = mboxes[i]); i++) {
317 if (!strcmp(mbox->name, name)) 331 if (!strcmp(_mbox->name, name)) {
332 mbox = _mbox;
318 break; 333 break;
334 }
335 }
319 336
320 if (!mbox) 337 if (!mbox)
321 return ERR_PTR(-ENOENT); 338 return ERR_PTR(-ENOENT);
@@ -324,12 +341,16 @@ struct omap_mbox *omap_mbox_get(const char *name)
324 if (ret) 341 if (ret)
325 return ERR_PTR(-ENODEV); 342 return ERR_PTR(-ENODEV);
326 343
344 if (nb)
345 blocking_notifier_chain_register(&mbox->notifier, nb);
346
327 return mbox; 347 return mbox;
328} 348}
329EXPORT_SYMBOL(omap_mbox_get); 349EXPORT_SYMBOL(omap_mbox_get);
330 350
331void omap_mbox_put(struct omap_mbox *mbox) 351void omap_mbox_put(struct omap_mbox *mbox, struct notifier_block *nb)
332{ 352{
353 blocking_notifier_chain_unregister(&mbox->notifier, nb);
333 omap_mbox_fini(mbox); 354 omap_mbox_fini(mbox);
334} 355}
335EXPORT_SYMBOL(omap_mbox_put); 356EXPORT_SYMBOL(omap_mbox_put);
@@ -353,6 +374,8 @@ int omap_mbox_register(struct device *parent, struct omap_mbox **list)
353 ret = PTR_ERR(mbox->dev); 374 ret = PTR_ERR(mbox->dev);
354 goto err_out; 375 goto err_out;
355 } 376 }
377
378 BLOCKING_INIT_NOTIFIER_HEAD(&mbox->notifier);
356 } 379 }
357 return 0; 380 return 0;
358 381
@@ -385,13 +408,10 @@ static int __init omap_mbox_init(void)
385 if (err) 408 if (err)
386 return err; 409 return err;
387 410
388 mboxd = create_workqueue("mboxd");
389 if (!mboxd)
390 return -ENOMEM;
391
392 /* kfifo size sanity check: alignment and minimal size */ 411 /* kfifo size sanity check: alignment and minimal size */
393 mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(mbox_msg_t)); 412 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)); 413 mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size,
414 sizeof(mbox_msg_t));
395 415
396 return 0; 416 return 0;
397} 417}
@@ -399,7 +419,6 @@ subsys_initcall(omap_mbox_init);
399 419
400static void __exit omap_mbox_exit(void) 420static void __exit omap_mbox_exit(void)
401{ 421{
402 destroy_workqueue(mboxd);
403 class_unregister(&omap_mbox_class); 422 class_unregister(&omap_mbox_class);
404} 423}
405module_exit(omap_mbox_exit); 424module_exit(omap_mbox_exit);
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index 0c8612fd8312..5587acf0eb2c 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -27,13 +27,17 @@
27 27
28#include <plat/dma.h> 28#include <plat/dma.h>
29#include <plat/mcbsp.h> 29#include <plat/mcbsp.h>
30#include <plat/omap_device.h>
31#include <linux/pm_runtime.h>
30 32
33/* XXX These "sideways" includes are a sign that something is wrong */
34#include "../mach-omap2/cm2xxx_3xxx.h"
31#include "../mach-omap2/cm-regbits-34xx.h" 35#include "../mach-omap2/cm-regbits-34xx.h"
32 36
33struct omap_mcbsp **mcbsp_ptr; 37struct omap_mcbsp **mcbsp_ptr;
34int omap_mcbsp_count, omap_mcbsp_cache_size; 38int omap_mcbsp_count, omap_mcbsp_cache_size;
35 39
36void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val) 40static void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val)
37{ 41{
38 if (cpu_class_is_omap1()) { 42 if (cpu_class_is_omap1()) {
39 ((u16 *)mcbsp->reg_cache)[reg / sizeof(u16)] = (u16)val; 43 ((u16 *)mcbsp->reg_cache)[reg / sizeof(u16)] = (u16)val;
@@ -47,7 +51,7 @@ void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val)
47 } 51 }
48} 52}
49 53
50int omap_mcbsp_read(struct omap_mcbsp *mcbsp, u16 reg, bool from_cache) 54static int omap_mcbsp_read(struct omap_mcbsp *mcbsp, u16 reg, bool from_cache)
51{ 55{
52 if (cpu_class_is_omap1()) { 56 if (cpu_class_is_omap1()) {
53 return !from_cache ? __raw_readw(mcbsp->io_base + reg) : 57 return !from_cache ? __raw_readw(mcbsp->io_base + reg) :
@@ -62,12 +66,12 @@ int omap_mcbsp_read(struct omap_mcbsp *mcbsp, u16 reg, bool from_cache)
62} 66}
63 67
64#ifdef CONFIG_ARCH_OMAP3 68#ifdef CONFIG_ARCH_OMAP3
65void omap_mcbsp_st_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val) 69static void omap_mcbsp_st_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val)
66{ 70{
67 __raw_writel(val, mcbsp->st_data->io_base_st + reg); 71 __raw_writel(val, mcbsp->st_data->io_base_st + reg);
68} 72}
69 73
70int omap_mcbsp_st_read(struct omap_mcbsp *mcbsp, u16 reg) 74static int omap_mcbsp_st_read(struct omap_mcbsp *mcbsp, u16 reg)
71{ 75{
72 return __raw_readl(mcbsp->st_data->io_base_st + reg); 76 return __raw_readl(mcbsp->st_data->io_base_st + reg);
73} 77}
@@ -80,9 +84,6 @@ int omap_mcbsp_st_read(struct omap_mcbsp *mcbsp, u16 reg)
80#define MCBSP_READ_CACHE(mcbsp, reg) \ 84#define MCBSP_READ_CACHE(mcbsp, reg) \
81 omap_mcbsp_read(mcbsp, OMAP_MCBSP_REG_##reg, 1) 85 omap_mcbsp_read(mcbsp, OMAP_MCBSP_REG_##reg, 1)
82 86
83#define omap_mcbsp_check_valid_id(id) (id < omap_mcbsp_count)
84#define id_to_mcbsp_ptr(id) mcbsp_ptr[id];
85
86#define MCBSP_ST_READ(mcbsp, reg) \ 87#define MCBSP_ST_READ(mcbsp, reg) \
87 omap_mcbsp_st_read(mcbsp, OMAP_ST_REG_##reg) 88 omap_mcbsp_st_read(mcbsp, OMAP_ST_REG_##reg)
88#define MCBSP_ST_WRITE(mcbsp, reg, val) \ 89#define MCBSP_ST_WRITE(mcbsp, reg, val) \
@@ -228,26 +229,96 @@ void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg *config)
228} 229}
229EXPORT_SYMBOL(omap_mcbsp_config); 230EXPORT_SYMBOL(omap_mcbsp_config);
230 231
232/**
233 * omap_mcbsp_dma_params - returns the dma channel number
234 * @id - mcbsp id
235 * @stream - indicates the direction of data flow (rx or tx)
236 *
237 * Returns the dma channel number for the rx channel or tx channel
238 * based on the value of @stream for the requested mcbsp given by @id
239 */
240int omap_mcbsp_dma_ch_params(unsigned int id, unsigned int stream)
241{
242 struct omap_mcbsp *mcbsp;
243
244 if (!omap_mcbsp_check_valid_id(id)) {
245 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
246 return -ENODEV;
247 }
248 mcbsp = id_to_mcbsp_ptr(id);
249
250 if (stream)
251 return mcbsp->dma_rx_sync;
252 else
253 return mcbsp->dma_tx_sync;
254}
255EXPORT_SYMBOL(omap_mcbsp_dma_ch_params);
256
257/**
258 * omap_mcbsp_dma_reg_params - returns the address of mcbsp data register
259 * @id - mcbsp id
260 * @stream - indicates the direction of data flow (rx or tx)
261 *
262 * Returns the address of mcbsp data transmit register or data receive register
263 * to be used by DMA for transferring/receiving data based on the value of
264 * @stream for the requested mcbsp given by @id
265 */
266int omap_mcbsp_dma_reg_params(unsigned int id, unsigned int stream)
267{
268 struct omap_mcbsp *mcbsp;
269 int data_reg;
270
271 if (!omap_mcbsp_check_valid_id(id)) {
272 printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1);
273 return -ENODEV;
274 }
275 mcbsp = id_to_mcbsp_ptr(id);
276
277 data_reg = mcbsp->phys_dma_base;
278
279 if (mcbsp->mcbsp_config_type < MCBSP_CONFIG_TYPE2) {
280 if (stream)
281 data_reg += OMAP_MCBSP_REG_DRR1;
282 else
283 data_reg += OMAP_MCBSP_REG_DXR1;
284 } else {
285 if (stream)
286 data_reg += OMAP_MCBSP_REG_DRR;
287 else
288 data_reg += OMAP_MCBSP_REG_DXR;
289 }
290
291 return data_reg;
292}
293EXPORT_SYMBOL(omap_mcbsp_dma_reg_params);
294
231#ifdef CONFIG_ARCH_OMAP3 295#ifdef CONFIG_ARCH_OMAP3
296static struct omap_device *find_omap_device_by_dev(struct device *dev)
297{
298 struct platform_device *pdev = container_of(dev,
299 struct platform_device, dev);
300 return container_of(pdev, struct omap_device, pdev);
301}
302
232static void omap_st_on(struct omap_mcbsp *mcbsp) 303static void omap_st_on(struct omap_mcbsp *mcbsp)
233{ 304{
234 unsigned int w; 305 unsigned int w;
306 struct omap_device *od;
307
308 od = find_omap_device_by_dev(mcbsp->dev);
235 309
236 /* 310 /*
237 * Sidetone uses McBSP ICLK - which must not idle when sidetones 311 * Sidetone uses McBSP ICLK - which must not idle when sidetones
238 * are enabled or sidetones start sounding ugly. 312 * are enabled or sidetones start sounding ugly.
239 */ 313 */
240 w = cm_read_mod_reg(OMAP3430_PER_MOD, CM_AUTOIDLE); 314 w = omap2_cm_read_mod_reg(OMAP3430_PER_MOD, CM_AUTOIDLE);
241 w &= ~(1 << (mcbsp->id - 2)); 315 w &= ~(1 << (mcbsp->id - 2));
242 cm_write_mod_reg(w, OMAP3430_PER_MOD, CM_AUTOIDLE); 316 omap2_cm_write_mod_reg(w, OMAP3430_PER_MOD, CM_AUTOIDLE);
243 317
244 /* Enable McBSP Sidetone */ 318 /* Enable McBSP Sidetone */
245 w = MCBSP_READ(mcbsp, SSELCR); 319 w = MCBSP_READ(mcbsp, SSELCR);
246 MCBSP_WRITE(mcbsp, SSELCR, w | SIDETONEEN); 320 MCBSP_WRITE(mcbsp, SSELCR, w | SIDETONEEN);
247 321
248 w = MCBSP_ST_READ(mcbsp, SYSCONFIG);
249 MCBSP_ST_WRITE(mcbsp, SYSCONFIG, w & ~(ST_AUTOIDLE));
250
251 /* Enable Sidetone from Sidetone Core */ 322 /* Enable Sidetone from Sidetone Core */
252 w = MCBSP_ST_READ(mcbsp, SSELCR); 323 w = MCBSP_ST_READ(mcbsp, SSELCR);
253 MCBSP_ST_WRITE(mcbsp, SSELCR, w | ST_SIDETONEEN); 324 MCBSP_ST_WRITE(mcbsp, SSELCR, w | ST_SIDETONEEN);
@@ -256,27 +327,27 @@ static void omap_st_on(struct omap_mcbsp *mcbsp)
256static void omap_st_off(struct omap_mcbsp *mcbsp) 327static void omap_st_off(struct omap_mcbsp *mcbsp)
257{ 328{
258 unsigned int w; 329 unsigned int w;
330 struct omap_device *od;
331
332 od = find_omap_device_by_dev(mcbsp->dev);
259 333
260 w = MCBSP_ST_READ(mcbsp, SSELCR); 334 w = MCBSP_ST_READ(mcbsp, SSELCR);
261 MCBSP_ST_WRITE(mcbsp, SSELCR, w & ~(ST_SIDETONEEN)); 335 MCBSP_ST_WRITE(mcbsp, SSELCR, w & ~(ST_SIDETONEEN));
262 336
263 w = MCBSP_ST_READ(mcbsp, SYSCONFIG);
264 MCBSP_ST_WRITE(mcbsp, SYSCONFIG, w | ST_AUTOIDLE);
265
266 w = MCBSP_READ(mcbsp, SSELCR); 337 w = MCBSP_READ(mcbsp, SSELCR);
267 MCBSP_WRITE(mcbsp, SSELCR, w & ~(SIDETONEEN)); 338 MCBSP_WRITE(mcbsp, SSELCR, w & ~(SIDETONEEN));
268 339
269 w = cm_read_mod_reg(OMAP3430_PER_MOD, CM_AUTOIDLE); 340 w = omap2_cm_read_mod_reg(OMAP3430_PER_MOD, CM_AUTOIDLE);
270 w |= 1 << (mcbsp->id - 2); 341 w |= 1 << (mcbsp->id - 2);
271 cm_write_mod_reg(w, OMAP3430_PER_MOD, CM_AUTOIDLE); 342 omap2_cm_write_mod_reg(w, OMAP3430_PER_MOD, CM_AUTOIDLE);
272} 343}
273 344
274static void omap_st_fir_write(struct omap_mcbsp *mcbsp, s16 *fir) 345static void omap_st_fir_write(struct omap_mcbsp *mcbsp, s16 *fir)
275{ 346{
276 u16 val, i; 347 u16 val, i;
348 struct omap_device *od;
277 349
278 val = MCBSP_ST_READ(mcbsp, SYSCONFIG); 350 od = find_omap_device_by_dev(mcbsp->dev);
279 MCBSP_ST_WRITE(mcbsp, SYSCONFIG, val & ~(ST_AUTOIDLE));
280 351
281 val = MCBSP_ST_READ(mcbsp, SSELCR); 352 val = MCBSP_ST_READ(mcbsp, SSELCR);
282 353
@@ -304,9 +375,9 @@ static void omap_st_chgain(struct omap_mcbsp *mcbsp)
304{ 375{
305 u16 w; 376 u16 w;
306 struct omap_mcbsp_st_data *st_data = mcbsp->st_data; 377 struct omap_mcbsp_st_data *st_data = mcbsp->st_data;
378 struct omap_device *od;
307 379
308 w = MCBSP_ST_READ(mcbsp, SYSCONFIG); 380 od = find_omap_device_by_dev(mcbsp->dev);
309 MCBSP_ST_WRITE(mcbsp, SYSCONFIG, w & ~(ST_AUTOIDLE));
310 381
311 w = MCBSP_ST_READ(mcbsp, SSELCR); 382 w = MCBSP_ST_READ(mcbsp, SSELCR);
312 383
@@ -649,48 +720,33 @@ EXPORT_SYMBOL(omap_mcbsp_get_dma_op_mode);
649 720
650static inline void omap34xx_mcbsp_request(struct omap_mcbsp *mcbsp) 721static inline void omap34xx_mcbsp_request(struct omap_mcbsp *mcbsp)
651{ 722{
723 struct omap_device *od;
724
725 od = find_omap_device_by_dev(mcbsp->dev);
652 /* 726 /*
653 * Enable wakup behavior, smart idle and all wakeups 727 * Enable wakup behavior, smart idle and all wakeups
654 * REVISIT: some wakeups may be unnecessary 728 * REVISIT: some wakeups may be unnecessary
655 */ 729 */
656 if (cpu_is_omap34xx() || cpu_is_omap44xx()) { 730 if (cpu_is_omap34xx() || cpu_is_omap44xx()) {
657 u16 syscon; 731 MCBSP_WRITE(mcbsp, WAKEUPEN, XRDYEN | RRDYEN);
658
659 syscon = MCBSP_READ(mcbsp, SYSCON);
660 syscon &= ~(ENAWAKEUP | SIDLEMODE(0x03) | CLOCKACTIVITY(0x03));
661
662 if (mcbsp->dma_op_mode == MCBSP_DMA_MODE_THRESHOLD) {
663 syscon |= (ENAWAKEUP | SIDLEMODE(0x02) |
664 CLOCKACTIVITY(0x02));
665 MCBSP_WRITE(mcbsp, WAKEUPEN, XRDYEN | RRDYEN);
666 } else {
667 syscon |= SIDLEMODE(0x01);
668 }
669
670 MCBSP_WRITE(mcbsp, SYSCON, syscon);
671 } 732 }
672} 733}
673 734
674static inline void omap34xx_mcbsp_free(struct omap_mcbsp *mcbsp) 735static inline void omap34xx_mcbsp_free(struct omap_mcbsp *mcbsp)
675{ 736{
737 struct omap_device *od;
738
739 od = find_omap_device_by_dev(mcbsp->dev);
740
676 /* 741 /*
677 * Disable wakup behavior, smart idle and all wakeups 742 * Disable wakup behavior, smart idle and all wakeups
678 */ 743 */
679 if (cpu_is_omap34xx() || cpu_is_omap44xx()) { 744 if (cpu_is_omap34xx() || cpu_is_omap44xx()) {
680 u16 syscon;
681
682 syscon = MCBSP_READ(mcbsp, SYSCON);
683 syscon &= ~(ENAWAKEUP | SIDLEMODE(0x03) | CLOCKACTIVITY(0x03));
684 /* 745 /*
685 * HW bug workaround - If no_idle mode is taken, we need to 746 * HW bug workaround - If no_idle mode is taken, we need to
686 * go to smart_idle before going to always_idle, or the 747 * go to smart_idle before going to always_idle, or the
687 * device will not hit retention anymore. 748 * device will not hit retention anymore.
688 */ 749 */
689 syscon |= SIDLEMODE(0x02);
690 MCBSP_WRITE(mcbsp, SYSCON, syscon);
691
692 syscon &= ~(SIDLEMODE(0x03));
693 MCBSP_WRITE(mcbsp, SYSCON, syscon);
694 750
695 MCBSP_WRITE(mcbsp, WAKEUPEN, 0); 751 MCBSP_WRITE(mcbsp, WAKEUPEN, 0);
696 } 752 }
@@ -758,15 +814,14 @@ int omap_mcbsp_request(unsigned int id)
758 goto err_kfree; 814 goto err_kfree;
759 } 815 }
760 816
761 mcbsp->free = 0; 817 mcbsp->free = false;
762 mcbsp->reg_cache = reg_cache; 818 mcbsp->reg_cache = reg_cache;
763 spin_unlock(&mcbsp->lock); 819 spin_unlock(&mcbsp->lock);
764 820
765 if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request) 821 if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request)
766 mcbsp->pdata->ops->request(id); 822 mcbsp->pdata->ops->request(id);
767 823
768 clk_enable(mcbsp->iclk); 824 pm_runtime_get_sync(mcbsp->dev);
769 clk_enable(mcbsp->fclk);
770 825
771 /* Do procedure specific to omap34xx arch, if applicable */ 826 /* Do procedure specific to omap34xx arch, if applicable */
772 omap34xx_mcbsp_request(mcbsp); 827 omap34xx_mcbsp_request(mcbsp);
@@ -814,11 +869,10 @@ err_clk_disable:
814 /* Do procedure specific to omap34xx arch, if applicable */ 869 /* Do procedure specific to omap34xx arch, if applicable */
815 omap34xx_mcbsp_free(mcbsp); 870 omap34xx_mcbsp_free(mcbsp);
816 871
817 clk_disable(mcbsp->fclk); 872 pm_runtime_put_sync(mcbsp->dev);
818 clk_disable(mcbsp->iclk);
819 873
820 spin_lock(&mcbsp->lock); 874 spin_lock(&mcbsp->lock);
821 mcbsp->free = 1; 875 mcbsp->free = true;
822 mcbsp->reg_cache = NULL; 876 mcbsp->reg_cache = NULL;
823err_kfree: 877err_kfree:
824 spin_unlock(&mcbsp->lock); 878 spin_unlock(&mcbsp->lock);
@@ -845,8 +899,7 @@ void omap_mcbsp_free(unsigned int id)
845 /* Do procedure specific to omap34xx arch, if applicable */ 899 /* Do procedure specific to omap34xx arch, if applicable */
846 omap34xx_mcbsp_free(mcbsp); 900 omap34xx_mcbsp_free(mcbsp);
847 901
848 clk_disable(mcbsp->fclk); 902 pm_runtime_put_sync(mcbsp->dev);
849 clk_disable(mcbsp->iclk);
850 903
851 if (mcbsp->io_type == OMAP_MCBSP_IRQ_IO) { 904 if (mcbsp->io_type == OMAP_MCBSP_IRQ_IO) {
852 /* Free IRQs */ 905 /* Free IRQs */
@@ -861,7 +914,7 @@ void omap_mcbsp_free(unsigned int id)
861 if (mcbsp->free) 914 if (mcbsp->free)
862 dev_err(mcbsp->dev, "McBSP%d was not reserved\n", mcbsp->id); 915 dev_err(mcbsp->dev, "McBSP%d was not reserved\n", mcbsp->id);
863 else 916 else
864 mcbsp->free = 1; 917 mcbsp->free = true;
865 mcbsp->reg_cache = NULL; 918 mcbsp->reg_cache = NULL;
866 spin_unlock(&mcbsp->lock); 919 spin_unlock(&mcbsp->lock);
867 920
@@ -878,7 +931,7 @@ EXPORT_SYMBOL(omap_mcbsp_free);
878void omap_mcbsp_start(unsigned int id, int tx, int rx) 931void omap_mcbsp_start(unsigned int id, int tx, int rx)
879{ 932{
880 struct omap_mcbsp *mcbsp; 933 struct omap_mcbsp *mcbsp;
881 int idle; 934 int enable_srg = 0;
882 u16 w; 935 u16 w;
883 936
884 if (!omap_mcbsp_check_valid_id(id)) { 937 if (!omap_mcbsp_check_valid_id(id)) {
@@ -893,10 +946,13 @@ void omap_mcbsp_start(unsigned int id, int tx, int rx)
893 mcbsp->rx_word_length = (MCBSP_READ_CACHE(mcbsp, RCR1) >> 5) & 0x7; 946 mcbsp->rx_word_length = (MCBSP_READ_CACHE(mcbsp, RCR1) >> 5) & 0x7;
894 mcbsp->tx_word_length = (MCBSP_READ_CACHE(mcbsp, XCR1) >> 5) & 0x7; 947 mcbsp->tx_word_length = (MCBSP_READ_CACHE(mcbsp, XCR1) >> 5) & 0x7;
895 948
896 idle = !((MCBSP_READ_CACHE(mcbsp, SPCR2) | 949 /* Only enable SRG, if McBSP is master */
897 MCBSP_READ_CACHE(mcbsp, SPCR1)) & 1); 950 w = MCBSP_READ_CACHE(mcbsp, PCR0);
951 if (w & (FSXM | FSRM | CLKXM | CLKRM))
952 enable_srg = !((MCBSP_READ_CACHE(mcbsp, SPCR2) |
953 MCBSP_READ_CACHE(mcbsp, SPCR1)) & 1);
898 954
899 if (idle) { 955 if (enable_srg) {
900 /* Start the sample generator */ 956 /* Start the sample generator */
901 w = MCBSP_READ_CACHE(mcbsp, SPCR2); 957 w = MCBSP_READ_CACHE(mcbsp, SPCR2);
902 MCBSP_WRITE(mcbsp, SPCR2, w | (1 << 6)); 958 MCBSP_WRITE(mcbsp, SPCR2, w | (1 << 6));
@@ -919,7 +975,7 @@ void omap_mcbsp_start(unsigned int id, int tx, int rx)
919 */ 975 */
920 udelay(500); 976 udelay(500);
921 977
922 if (idle) { 978 if (enable_srg) {
923 /* Start frame sync */ 979 /* Start frame sync */
924 w = MCBSP_READ_CACHE(mcbsp, SPCR2); 980 w = MCBSP_READ_CACHE(mcbsp, SPCR2);
925 MCBSP_WRITE(mcbsp, SPCR2, w | (1 << 7)); 981 MCBSP_WRITE(mcbsp, SPCR2, w | (1 << 7));
@@ -1047,7 +1103,7 @@ int omap_mcbsp_pollread(unsigned int id, u16 *buf)
1047 /* resend */ 1103 /* resend */
1048 return -1; 1104 return -1;
1049 } else { 1105 } else {
1050 /* wait for recieve confirmation */ 1106 /* wait for receive confirmation */
1051 int attemps = 0; 1107 int attemps = 0;
1052 while (!(MCBSP_READ(mcbsp, SPCR1) & RRDY)) { 1108 while (!(MCBSP_READ(mcbsp, SPCR1) & RRDY)) {
1053 if (attemps++ > 1000) { 1109 if (attemps++ > 1000) {
@@ -1645,9 +1701,10 @@ static const struct attribute_group sidetone_attr_group = {
1645 .attrs = (struct attribute **)sidetone_attrs, 1701 .attrs = (struct attribute **)sidetone_attrs,
1646}; 1702};
1647 1703
1648int __devinit omap_st_add(struct omap_mcbsp *mcbsp) 1704static int __devinit omap_st_add(struct omap_mcbsp *mcbsp)
1649{ 1705{
1650 struct omap_mcbsp_platform_data *pdata = mcbsp->pdata; 1706 struct platform_device *pdev;
1707 struct resource *res;
1651 struct omap_mcbsp_st_data *st_data; 1708 struct omap_mcbsp_st_data *st_data;
1652 int err; 1709 int err;
1653 1710
@@ -1657,7 +1714,10 @@ int __devinit omap_st_add(struct omap_mcbsp *mcbsp)
1657 goto err1; 1714 goto err1;
1658 } 1715 }
1659 1716
1660 st_data->io_base_st = ioremap(pdata->phys_base_st, SZ_4K); 1717 pdev = container_of(mcbsp->dev, struct platform_device, dev);
1718
1719 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sidetone");
1720 st_data->io_base_st = ioremap(res->start, resource_size(res));
1661 if (!st_data->io_base_st) { 1721 if (!st_data->io_base_st) {
1662 err = -ENOMEM; 1722 err = -ENOMEM;
1663 goto err2; 1723 goto err2;
@@ -1746,6 +1806,7 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
1746 struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data; 1806 struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data;
1747 struct omap_mcbsp *mcbsp; 1807 struct omap_mcbsp *mcbsp;
1748 int id = pdev->id - 1; 1808 int id = pdev->id - 1;
1809 struct resource *res;
1749 int ret = 0; 1810 int ret = 0;
1750 1811
1751 if (!pdata) { 1812 if (!pdata) {
@@ -1771,51 +1832,82 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
1771 1832
1772 spin_lock_init(&mcbsp->lock); 1833 spin_lock_init(&mcbsp->lock);
1773 mcbsp->id = id + 1; 1834 mcbsp->id = id + 1;
1774 mcbsp->free = 1; 1835 mcbsp->free = true;
1775 mcbsp->dma_tx_lch = -1; 1836 mcbsp->dma_tx_lch = -1;
1776 mcbsp->dma_rx_lch = -1; 1837 mcbsp->dma_rx_lch = -1;
1777 1838
1778 mcbsp->phys_base = pdata->phys_base; 1839 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
1779 mcbsp->io_base = ioremap(pdata->phys_base, SZ_4K); 1840 if (!res) {
1841 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1842 if (!res) {
1843 dev_err(&pdev->dev, "%s:mcbsp%d has invalid memory"
1844 "resource\n", __func__, pdev->id);
1845 ret = -ENOMEM;
1846 goto exit;
1847 }
1848 }
1849 mcbsp->phys_base = res->start;
1850 omap_mcbsp_cache_size = resource_size(res);
1851 mcbsp->io_base = ioremap(res->start, resource_size(res));
1780 if (!mcbsp->io_base) { 1852 if (!mcbsp->io_base) {
1781 ret = -ENOMEM; 1853 ret = -ENOMEM;
1782 goto err_ioremap; 1854 goto err_ioremap;
1783 } 1855 }
1784 1856
1857 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma");
1858 if (!res)
1859 mcbsp->phys_dma_base = mcbsp->phys_base;
1860 else
1861 mcbsp->phys_dma_base = res->start;
1862
1785 /* Default I/O is IRQ based */ 1863 /* Default I/O is IRQ based */
1786 mcbsp->io_type = OMAP_MCBSP_IRQ_IO; 1864 mcbsp->io_type = OMAP_MCBSP_IRQ_IO;
1787 mcbsp->tx_irq = pdata->tx_irq;
1788 mcbsp->rx_irq = pdata->rx_irq;
1789 mcbsp->dma_rx_sync = pdata->dma_rx_sync;
1790 mcbsp->dma_tx_sync = pdata->dma_tx_sync;
1791 1865
1792 mcbsp->iclk = clk_get(&pdev->dev, "ick"); 1866 mcbsp->tx_irq = platform_get_irq_byname(pdev, "tx");
1793 if (IS_ERR(mcbsp->iclk)) { 1867 mcbsp->rx_irq = platform_get_irq_byname(pdev, "rx");
1794 ret = PTR_ERR(mcbsp->iclk); 1868
1795 dev_err(&pdev->dev, "unable to get ick: %d\n", ret); 1869 /* From OMAP4 there will be a single irq line */
1796 goto err_iclk; 1870 if (mcbsp->tx_irq == -ENXIO)
1871 mcbsp->tx_irq = platform_get_irq(pdev, 0);
1872
1873 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
1874 if (!res) {
1875 dev_err(&pdev->dev, "%s:mcbsp%d has invalid rx DMA channel\n",
1876 __func__, pdev->id);
1877 ret = -ENODEV;
1878 goto err_res;
1879 }
1880 mcbsp->dma_rx_sync = res->start;
1881
1882 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx");
1883 if (!res) {
1884 dev_err(&pdev->dev, "%s:mcbsp%d has invalid tx DMA channel\n",
1885 __func__, pdev->id);
1886 ret = -ENODEV;
1887 goto err_res;
1797 } 1888 }
1889 mcbsp->dma_tx_sync = res->start;
1798 1890
1799 mcbsp->fclk = clk_get(&pdev->dev, "fck"); 1891 mcbsp->fclk = clk_get(&pdev->dev, "fck");
1800 if (IS_ERR(mcbsp->fclk)) { 1892 if (IS_ERR(mcbsp->fclk)) {
1801 ret = PTR_ERR(mcbsp->fclk); 1893 ret = PTR_ERR(mcbsp->fclk);
1802 dev_err(&pdev->dev, "unable to get fck: %d\n", ret); 1894 dev_err(&pdev->dev, "unable to get fck: %d\n", ret);
1803 goto err_fclk; 1895 goto err_res;
1804 } 1896 }
1805 1897
1806 mcbsp->pdata = pdata; 1898 mcbsp->pdata = pdata;
1807 mcbsp->dev = &pdev->dev; 1899 mcbsp->dev = &pdev->dev;
1808 mcbsp_ptr[id] = mcbsp; 1900 mcbsp_ptr[id] = mcbsp;
1901 mcbsp->mcbsp_config_type = pdata->mcbsp_config_type;
1809 platform_set_drvdata(pdev, mcbsp); 1902 platform_set_drvdata(pdev, mcbsp);
1903 pm_runtime_enable(mcbsp->dev);
1810 1904
1811 /* Initialize mcbsp properties for OMAP34XX if needed / applicable */ 1905 /* Initialize mcbsp properties for OMAP34XX if needed / applicable */
1812 omap34xx_device_init(mcbsp); 1906 omap34xx_device_init(mcbsp);
1813 1907
1814 return 0; 1908 return 0;
1815 1909
1816err_fclk: 1910err_res:
1817 clk_put(mcbsp->iclk);
1818err_iclk:
1819 iounmap(mcbsp->io_base); 1911 iounmap(mcbsp->io_base);
1820err_ioremap: 1912err_ioremap:
1821 kfree(mcbsp); 1913 kfree(mcbsp);
@@ -1836,17 +1928,10 @@ static int __devexit omap_mcbsp_remove(struct platform_device *pdev)
1836 1928
1837 omap34xx_device_exit(mcbsp); 1929 omap34xx_device_exit(mcbsp);
1838 1930
1839 clk_disable(mcbsp->fclk);
1840 clk_disable(mcbsp->iclk);
1841 clk_put(mcbsp->fclk); 1931 clk_put(mcbsp->fclk);
1842 clk_put(mcbsp->iclk);
1843 1932
1844 iounmap(mcbsp->io_base); 1933 iounmap(mcbsp->io_base);
1845 1934 kfree(mcbsp);
1846 mcbsp->fclk = NULL;
1847 mcbsp->iclk = NULL;
1848 mcbsp->free = 0;
1849 mcbsp->dev = NULL;
1850 } 1935 }
1851 1936
1852 return 0; 1937 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 d2b160942ccc..49fc0df0c21f 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -82,20 +82,18 @@
82#include <linux/slab.h> 82#include <linux/slab.h>
83#include <linux/err.h> 83#include <linux/err.h>
84#include <linux/io.h> 84#include <linux/io.h>
85#include <linux/clk.h>
86#include <linux/clkdev.h>
87#include <linux/pm_runtime.h>
85 88
86#include <plat/omap_device.h> 89#include <plat/omap_device.h>
87#include <plat/omap_hwmod.h> 90#include <plat/omap_hwmod.h>
91#include <plat/clock.h>
88 92
89/* These parameters are passed to _omap_device_{de,}activate() */ 93/* These parameters are passed to _omap_device_{de,}activate() */
90#define USE_WAKEUP_LAT 0 94#define USE_WAKEUP_LAT 0
91#define IGNORE_WAKEUP_LAT 1 95#define IGNORE_WAKEUP_LAT 1
92 96
93/*
94 * OMAP_DEVICE_MAGIC: used to determine whether a struct omap_device
95 * obtained via container_of() is in fact a struct omap_device
96 */
97#define OMAP_DEVICE_MAGIC 0xf00dcafe
98
99/* Private functions */ 97/* Private functions */
100 98
101/** 99/**
@@ -243,10 +241,90 @@ static inline struct omap_device *_find_by_pdev(struct platform_device *pdev)
243 return container_of(pdev, struct omap_device, pdev); 241 return container_of(pdev, struct omap_device, pdev);
244} 242}
245 243
244/**
245 * _add_optional_clock_clkdev - Add clkdev entry for hwmod optional clocks
246 * @od: struct omap_device *od
247 *
248 * For every optional clock present per hwmod per omap_device, this function
249 * adds an entry in the clkdev table of the form <dev-id=dev_name, con-id=role>
250 * if it does not exist already.
251 *
252 * The function is called from inside omap_device_build_ss(), after
253 * omap_device_register.
254 *
255 * This allows drivers to get a pointer to its optional clocks based on its role
256 * by calling clk_get(<dev*>, <role>).
257 *
258 * No return value.
259 */
260static void _add_optional_clock_clkdev(struct omap_device *od,
261 struct omap_hwmod *oh)
262{
263 int i;
264
265 for (i = 0; i < oh->opt_clks_cnt; i++) {
266 struct omap_hwmod_opt_clk *oc;
267 struct clk *r;
268 struct clk_lookup *l;
269
270 oc = &oh->opt_clks[i];
271
272 if (!oc->_clk)
273 continue;
274
275 r = clk_get_sys(dev_name(&od->pdev.dev), oc->role);
276 if (!IS_ERR(r))
277 continue; /* clkdev entry exists */
278
279 r = omap_clk_get_by_name((char *)oc->clk);
280 if (IS_ERR(r)) {
281 pr_err("omap_device: %s: omap_clk_get_by_name for %s failed\n",
282 dev_name(&od->pdev.dev), oc->clk);
283 continue;
284 }
285
286 l = clkdev_alloc(r, oc->role, dev_name(&od->pdev.dev));
287 if (!l) {
288 pr_err("omap_device: %s: clkdev_alloc for %s failed\n",
289 dev_name(&od->pdev.dev), oc->role);
290 return;
291 }
292 clkdev_add(l);
293 }
294}
295
246 296
247/* Public functions for use by core code */ 297/* Public functions for use by core code */
248 298
249/** 299/**
300 * omap_device_get_context_loss_count - get lost context count
301 * @od: struct omap_device *
302 *
303 * Using the primary hwmod, query the context loss count for this
304 * device.
305 *
306 * Callers should consider context for this device lost any time this
307 * function returns a value different than the value the caller got
308 * the last time it called this function.
309 *
310 * If any hwmods exist for the omap_device assoiated with @pdev,
311 * return the context loss counter for that hwmod, otherwise return
312 * zero.
313 */
314u32 omap_device_get_context_loss_count(struct platform_device *pdev)
315{
316 struct omap_device *od;
317 u32 ret = 0;
318
319 od = _find_by_pdev(pdev);
320
321 if (od->hwmods_cnt)
322 ret = omap_hwmod_get_context_loss_count(od->hwmods[0]);
323
324 return ret;
325}
326
327/**
250 * omap_device_count_resources - count number of struct resource entries needed 328 * omap_device_count_resources - count number of struct resource entries needed
251 * @od: struct omap_device * 329 * @od: struct omap_device *
252 * 330 *
@@ -257,12 +335,11 @@ static inline struct omap_device *_find_by_pdev(struct platform_device *pdev)
257 */ 335 */
258int omap_device_count_resources(struct omap_device *od) 336int omap_device_count_resources(struct omap_device *od)
259{ 337{
260 struct omap_hwmod *oh;
261 int c = 0; 338 int c = 0;
262 int i; 339 int i;
263 340
264 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++) 341 for (i = 0; i < od->hwmods_cnt; i++)
265 c += omap_hwmod_count_resources(oh); 342 c += omap_hwmod_count_resources(od->hwmods[i]);
266 343
267 pr_debug("omap_device: %s: counted %d total resources across %d " 344 pr_debug("omap_device: %s: counted %d total resources across %d "
268 "hwmods\n", od->pdev.name, c, od->hwmods_cnt); 345 "hwmods\n", od->pdev.name, c, od->hwmods_cnt);
@@ -289,12 +366,11 @@ int omap_device_count_resources(struct omap_device *od)
289 */ 366 */
290int omap_device_fill_resources(struct omap_device *od, struct resource *res) 367int omap_device_fill_resources(struct omap_device *od, struct resource *res)
291{ 368{
292 struct omap_hwmod *oh;
293 int c = 0; 369 int c = 0;
294 int i, r; 370 int i, r;
295 371
296 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++) { 372 for (i = 0; i < od->hwmods_cnt; i++) {
297 r = omap_hwmod_fill_resources(oh, res); 373 r = omap_hwmod_fill_resources(od->hwmods[i], res);
298 res += r; 374 res += r;
299 c += r; 375 c += r;
300 } 376 }
@@ -414,15 +490,15 @@ struct omap_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
414 od->pm_lats = pm_lats; 490 od->pm_lats = pm_lats;
415 od->pm_lats_cnt = pm_lats_cnt; 491 od->pm_lats_cnt = pm_lats_cnt;
416 492
417 od->magic = OMAP_DEVICE_MAGIC;
418
419 if (is_early_device) 493 if (is_early_device)
420 ret = omap_early_device_register(od); 494 ret = omap_early_device_register(od);
421 else 495 else
422 ret = omap_device_register(od); 496 ret = omap_device_register(od);
423 497
424 for (i = 0; i < oh_cnt; i++) 498 for (i = 0; i < oh_cnt; i++) {
425 hwmods[i]->od = od; 499 hwmods[i]->od = od;
500 _add_optional_clock_clkdev(od, hwmods[i]);
501 }
426 502
427 if (ret) 503 if (ret)
428 goto odbs_exit4; 504 goto odbs_exit4;
@@ -461,6 +537,42 @@ int omap_early_device_register(struct omap_device *od)
461 return 0; 537 return 0;
462} 538}
463 539
540static int _od_runtime_suspend(struct device *dev)
541{
542 struct platform_device *pdev = to_platform_device(dev);
543 int ret;
544
545 ret = pm_generic_runtime_suspend(dev);
546
547 if (!ret)
548 omap_device_idle(pdev);
549
550 return ret;
551}
552
553static int _od_runtime_idle(struct device *dev)
554{
555 return pm_generic_runtime_idle(dev);
556}
557
558static int _od_runtime_resume(struct device *dev)
559{
560 struct platform_device *pdev = to_platform_device(dev);
561
562 omap_device_enable(pdev);
563
564 return pm_generic_runtime_resume(dev);
565}
566
567static struct dev_power_domain omap_device_power_domain = {
568 .ops = {
569 .runtime_suspend = _od_runtime_suspend,
570 .runtime_idle = _od_runtime_idle,
571 .runtime_resume = _od_runtime_resume,
572 USE_PLATFORM_PM_SLEEP_OPS
573 }
574};
575
464/** 576/**
465 * omap_device_register - register an omap_device with one omap_hwmod 577 * omap_device_register - register an omap_device with one omap_hwmod
466 * @od: struct omap_device * to register 578 * @od: struct omap_device * to register
@@ -473,6 +585,8 @@ int omap_device_register(struct omap_device *od)
473{ 585{
474 pr_debug("omap_device: %s: registering\n", od->pdev.name); 586 pr_debug("omap_device: %s: registering\n", od->pdev.name);
475 587
588 od->pdev.dev.parent = &omap_device_parent;
589 od->pdev.dev.pwr_domain = &omap_device_power_domain;
476 return platform_device_register(&od->pdev); 590 return platform_device_register(&od->pdev);
477} 591}
478 592
@@ -566,7 +680,6 @@ int omap_device_shutdown(struct platform_device *pdev)
566{ 680{
567 int ret, i; 681 int ret, i;
568 struct omap_device *od; 682 struct omap_device *od;
569 struct omap_hwmod *oh;
570 683
571 od = _find_by_pdev(pdev); 684 od = _find_by_pdev(pdev);
572 685
@@ -579,8 +692,8 @@ int omap_device_shutdown(struct platform_device *pdev)
579 692
580 ret = _omap_device_deactivate(od, IGNORE_WAKEUP_LAT); 693 ret = _omap_device_deactivate(od, IGNORE_WAKEUP_LAT);
581 694
582 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++) 695 for (i = 0; i < od->hwmods_cnt; i++)
583 omap_hwmod_shutdown(oh); 696 omap_hwmod_shutdown(od->hwmods[i]);
584 697
585 od->_state = OMAP_DEVICE_STATE_SHUTDOWN; 698 od->_state = OMAP_DEVICE_STATE_SHUTDOWN;
586 699
@@ -627,18 +740,6 @@ int omap_device_align_pm_lat(struct platform_device *pdev,
627} 740}
628 741
629/** 742/**
630 * omap_device_is_valid - Check if pointer is a valid omap_device
631 * @od: struct omap_device *
632 *
633 * Return whether struct omap_device pointer @od points to a valid
634 * omap_device.
635 */
636bool omap_device_is_valid(struct omap_device *od)
637{
638 return (od && od->magic == OMAP_DEVICE_MAGIC);
639}
640
641/**
642 * omap_device_get_pwrdm - return the powerdomain * associated with @od 743 * omap_device_get_pwrdm - return the powerdomain * associated with @od
643 * @od: struct omap_device * 744 * @od: struct omap_device *
644 * 745 *
@@ -692,11 +793,10 @@ void __iomem *omap_device_get_rt_va(struct omap_device *od)
692 */ 793 */
693int omap_device_enable_hwmods(struct omap_device *od) 794int omap_device_enable_hwmods(struct omap_device *od)
694{ 795{
695 struct omap_hwmod *oh;
696 int i; 796 int i;
697 797
698 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++) 798 for (i = 0; i < od->hwmods_cnt; i++)
699 omap_hwmod_enable(oh); 799 omap_hwmod_enable(od->hwmods[i]);
700 800
701 /* XXX pass along return value here? */ 801 /* XXX pass along return value here? */
702 return 0; 802 return 0;
@@ -710,11 +810,10 @@ int omap_device_enable_hwmods(struct omap_device *od)
710 */ 810 */
711int omap_device_idle_hwmods(struct omap_device *od) 811int omap_device_idle_hwmods(struct omap_device *od)
712{ 812{
713 struct omap_hwmod *oh;
714 int i; 813 int i;
715 814
716 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++) 815 for (i = 0; i < od->hwmods_cnt; i++)
717 omap_hwmod_idle(oh); 816 omap_hwmod_idle(od->hwmods[i]);
718 817
719 /* XXX pass along return value here? */ 818 /* XXX pass along return value here? */
720 return 0; 819 return 0;
@@ -729,11 +828,10 @@ int omap_device_idle_hwmods(struct omap_device *od)
729 */ 828 */
730int omap_device_disable_clocks(struct omap_device *od) 829int omap_device_disable_clocks(struct omap_device *od)
731{ 830{
732 struct omap_hwmod *oh;
733 int i; 831 int i;
734 832
735 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++) 833 for (i = 0; i < od->hwmods_cnt; i++)
736 omap_hwmod_disable_clocks(oh); 834 omap_hwmod_disable_clocks(od->hwmods[i]);
737 835
738 /* XXX pass along return value here? */ 836 /* XXX pass along return value here? */
739 return 0; 837 return 0;
@@ -748,12 +846,22 @@ int omap_device_disable_clocks(struct omap_device *od)
748 */ 846 */
749int omap_device_enable_clocks(struct omap_device *od) 847int omap_device_enable_clocks(struct omap_device *od)
750{ 848{
751 struct omap_hwmod *oh;
752 int i; 849 int i;
753 850
754 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++) 851 for (i = 0; i < od->hwmods_cnt; i++)
755 omap_hwmod_enable_clocks(oh); 852 omap_hwmod_enable_clocks(od->hwmods[i]);
756 853
757 /* XXX pass along return value here? */ 854 /* XXX pass along return value here? */
758 return 0; 855 return 0;
759} 856}
857
858struct device omap_device_parent = {
859 .init_name = "omap",
860 .parent = &platform_bus,
861};
862
863static int __init omap_device_init(void)
864{
865 return device_register(&omap_device_parent);
866}
867core_initcall(omap_device_init);
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
index 10b3b4c63372..6af3d0b1f8d0 100644
--- a/arch/arm/plat-omap/sram.c
+++ b/arch/arm/plat-omap/sram.c
@@ -19,6 +19,7 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/omapfb.h>
22 23
23#include <asm/tlb.h> 24#include <asm/tlb.h>
24#include <asm/cacheflush.h> 25#include <asm/cacheflush.h>
@@ -30,30 +31,28 @@
30#include <plat/cpu.h> 31#include <plat/cpu.h>
31#include <plat/vram.h> 32#include <plat/vram.h>
32 33
33#include <plat/control.h> 34#include "sram.h"
35#include "fb.h"
34 36
37/* XXX These "sideways" includes are a sign that something is wrong */
35#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 38#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
36# include "../mach-omap2/prm.h" 39# include "../mach-omap2/prm2xxx_3xxx.h"
37# include "../mach-omap2/cm.h"
38# include "../mach-omap2/sdrc.h" 40# include "../mach-omap2/sdrc.h"
39#endif 41#endif
40 42
41#define OMAP1_SRAM_PA 0x20000000 43#define OMAP1_SRAM_PA 0x20000000
42#define OMAP1_SRAM_VA VMALLOC_END 44#define OMAP1_SRAM_VA VMALLOC_END
43#define OMAP2_SRAM_PA 0x40200000 45#define OMAP2_SRAM_PUB_PA (OMAP2_SRAM_PA + 0xf800)
44#define OMAP2_SRAM_PUB_PA 0x4020f800
45#define OMAP2_SRAM_VA 0xfe400000 46#define OMAP2_SRAM_VA 0xfe400000
46#define OMAP2_SRAM_PUB_VA (OMAP2_SRAM_VA + 0x800) 47#define OMAP2_SRAM_PUB_VA (OMAP2_SRAM_VA + 0x800)
47#define OMAP3_SRAM_PA 0x40200000
48#define OMAP3_SRAM_VA 0xfe400000 48#define OMAP3_SRAM_VA 0xfe400000
49#define OMAP3_SRAM_PUB_PA 0x40208000 49#define OMAP3_SRAM_PUB_PA (OMAP3_SRAM_PA + 0x8000)
50#define OMAP3_SRAM_PUB_VA (OMAP3_SRAM_VA + 0x8000) 50#define OMAP3_SRAM_PUB_VA (OMAP3_SRAM_VA + 0x8000)
51#define OMAP4_SRAM_PA 0x40300000
52#define OMAP4_SRAM_VA 0xfe400000 51#define OMAP4_SRAM_VA 0xfe400000
53#define OMAP4_SRAM_PUB_PA (OMAP4_SRAM_PA + 0x4000) 52#define OMAP4_SRAM_PUB_PA (OMAP4_SRAM_PA + 0x4000)
54#define OMAP4_SRAM_PUB_VA (OMAP4_SRAM_VA + 0x4000) 53#define OMAP4_SRAM_PUB_VA (OMAP4_SRAM_VA + 0x4000)
55 54
56#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 55#if defined(CONFIG_ARCH_OMAP2PLUS)
57#define SRAM_BOOTLOADER_SZ 0x00 56#define SRAM_BOOTLOADER_SZ 0x00
58#else 57#else
59#define SRAM_BOOTLOADER_SZ 0x80 58#define SRAM_BOOTLOADER_SZ 0x80
@@ -68,7 +67,6 @@
68#define OMAP34XX_VA_WRITEPERM0 OMAP2_L3_IO_ADDRESS(0x68012858) 67#define OMAP34XX_VA_WRITEPERM0 OMAP2_L3_IO_ADDRESS(0x68012858)
69#define OMAP34XX_VA_ADDR_MATCH2 OMAP2_L3_IO_ADDRESS(0x68012880) 68#define OMAP34XX_VA_ADDR_MATCH2 OMAP2_L3_IO_ADDRESS(0x68012880)
70#define OMAP34XX_VA_SMS_RG_ATT0 OMAP2_L3_IO_ADDRESS(0x6C000048) 69#define OMAP34XX_VA_SMS_RG_ATT0 OMAP2_L3_IO_ADDRESS(0x6C000048)
71#define OMAP34XX_VA_CONTROL_STAT OMAP2_L4_IO_ADDRESS(0x480022F0)
72 70
73#define GP_DEVICE 0x300 71#define GP_DEVICE 0x300
74 72
@@ -79,12 +77,6 @@ static unsigned long omap_sram_base;
79static unsigned long omap_sram_size; 77static unsigned long omap_sram_size;
80static unsigned long omap_sram_ceil; 78static unsigned long omap_sram_ceil;
81 79
82extern unsigned long omapfb_reserve_sram(unsigned long sram_pstart,
83 unsigned long sram_vstart,
84 unsigned long sram_size,
85 unsigned long pstart_avail,
86 unsigned long size_avail);
87
88/* 80/*
89 * Depending on the target RAMFS firewall setup, the public usable amount of 81 * Depending on the target RAMFS firewall setup, the public usable amount of
90 * SRAM varies. The default accessible size for all device types is 2k. A GP 82 * SRAM varies. The default accessible size for all device types is 2k. A GP
@@ -93,16 +85,7 @@ extern unsigned long omapfb_reserve_sram(unsigned long sram_pstart,
93 */ 85 */
94static int is_sram_locked(void) 86static int is_sram_locked(void)
95{ 87{
96 int type = 0; 88 if (OMAP2_DEVICE_TYPE_GP == omap_type()) {
97
98 if (cpu_is_omap44xx())
99 /* Not yet supported */
100 return 0;
101
102 if (cpu_is_omap242x())
103 type = omap_rev() & OMAP2_DEVICETYPE_MASK;
104
105 if (type == GP_DEVICE) {
106 /* RAMFW: R/W access to all initiators for all qualifier sets */ 89 /* RAMFW: R/W access to all initiators for all qualifier sets */
107 if (cpu_is_omap242x()) { 90 if (cpu_is_omap242x()) {
108 __raw_writel(0xFF, OMAP24XX_VA_REQINFOPERM0); /* all q-vects */ 91 __raw_writel(0xFF, OMAP24XX_VA_REQINFOPERM0); /* all q-vects */
@@ -127,7 +110,7 @@ static int is_sram_locked(void)
127 * to secure SRAM will hang the system. Also the SRAM is not 110 * to secure SRAM will hang the system. Also the SRAM is not
128 * yet mapped at this point. 111 * yet mapped at this point.
129 */ 112 */
130void __init omap_detect_sram(void) 113static void __init omap_detect_sram(void)
131{ 114{
132 unsigned long reserved; 115 unsigned long reserved;
133 116
@@ -181,9 +164,9 @@ void __init omap_detect_sram(void)
181 cpu_is_omap1710()) 164 cpu_is_omap1710())
182 omap_sram_size = 0x4000; /* 16K */ 165 omap_sram_size = 0x4000; /* 16K */
183 else if (cpu_is_omap1611()) 166 else if (cpu_is_omap1611())
184 omap_sram_size = 0x3e800; /* 250K */ 167 omap_sram_size = SZ_256K;
185 else { 168 else {
186 printk(KERN_ERR "Could not detect SRAM size\n"); 169 pr_err("Could not detect SRAM size\n");
187 omap_sram_size = 0x4000; 170 omap_sram_size = 0x4000;
188 } 171 }
189 } 172 }
@@ -213,7 +196,7 @@ static struct map_desc omap_sram_io_desc[] __initdata = {
213/* 196/*
214 * Note that we cannot use ioremap for SRAM, as clock init needs SRAM early. 197 * Note that we cannot use ioremap for SRAM, as clock init needs SRAM early.
215 */ 198 */
216void __init omap_map_sram(void) 199static void __init omap_map_sram(void)
217{ 200{
218 unsigned long base; 201 unsigned long base;
219 202
@@ -238,10 +221,10 @@ void __init omap_map_sram(void)
238 omap_sram_io_desc[0].length = ROUND_DOWN(omap_sram_size, PAGE_SIZE); 221 omap_sram_io_desc[0].length = ROUND_DOWN(omap_sram_size, PAGE_SIZE);
239 iotable_init(omap_sram_io_desc, ARRAY_SIZE(omap_sram_io_desc)); 222 iotable_init(omap_sram_io_desc, ARRAY_SIZE(omap_sram_io_desc));
240 223
241 printk(KERN_INFO "SRAM: Mapped pa 0x%08lx to va 0x%08lx size: 0x%lx\n", 224 pr_info("SRAM: Mapped pa 0x%08llx to va 0x%08lx size: 0x%lx\n",
242 __pfn_to_phys(omap_sram_io_desc[0].pfn), 225 (long long) __pfn_to_phys(omap_sram_io_desc[0].pfn),
243 omap_sram_io_desc[0].virtual, 226 omap_sram_io_desc[0].virtual,
244 omap_sram_io_desc[0].length); 227 omap_sram_io_desc[0].length);
245 228
246 /* 229 /*
247 * Normally devicemaps_init() would flush caches and tlb after 230 * Normally devicemaps_init() would flush caches and tlb after
@@ -259,18 +242,22 @@ void __init omap_map_sram(void)
259 omap_sram_size - SRAM_BOOTLOADER_SZ); 242 omap_sram_size - SRAM_BOOTLOADER_SZ);
260} 243}
261 244
262void * omap_sram_push(void * start, unsigned long size) 245/*
246 * Memory allocator for SRAM: calculates the new ceiling address
247 * for pushing a function using the fncpy API.
248 *
249 * Note that fncpy requires the returned address to be aligned
250 * to an 8-byte boundary.
251 */
252void *omap_sram_push_address(unsigned long size)
263{ 253{
264 if (size > (omap_sram_ceil - (omap_sram_base + SRAM_BOOTLOADER_SZ))) { 254 if (size > (omap_sram_ceil - (omap_sram_base + SRAM_BOOTLOADER_SZ))) {
265 printk(KERN_ERR "Not enough space in SRAM\n"); 255 pr_err("Not enough space in SRAM\n");
266 return NULL; 256 return NULL;
267 } 257 }
268 258
269 omap_sram_ceil -= size; 259 omap_sram_ceil -= size;
270 omap_sram_ceil = ROUND_DOWN(omap_sram_ceil, sizeof(void *)); 260 omap_sram_ceil = ROUND_DOWN(omap_sram_ceil, FNCPY_ALIGN);
271 memcpy((void *)omap_sram_ceil, start, size);
272 flush_icache_range((unsigned long)omap_sram_ceil,
273 (unsigned long)(omap_sram_ceil + size));
274 261
275 return (void *)omap_sram_ceil; 262 return (void *)omap_sram_ceil;
276} 263}
@@ -285,7 +272,7 @@ void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl)
285 _omap_sram_reprogram_clock(dpllctl, ckctl); 272 _omap_sram_reprogram_clock(dpllctl, ckctl);
286} 273}
287 274
288int __init omap1_sram_init(void) 275static int __init omap1_sram_init(void)
289{ 276{
290 _omap_sram_reprogram_clock = 277 _omap_sram_reprogram_clock =
291 omap_sram_push(omap1_sram_reprogram_clock, 278 omap_sram_push(omap1_sram_reprogram_clock,
@@ -329,8 +316,8 @@ u32 omap2_set_prcm(u32 dpll_ctrl_val, u32 sdrc_rfr_val, int bypass)
329} 316}
330#endif 317#endif
331 318
332#ifdef CONFIG_ARCH_OMAP2420 319#ifdef CONFIG_SOC_OMAP2420
333int __init omap242x_sram_init(void) 320static int __init omap242x_sram_init(void)
334{ 321{
335 _omap2_sram_ddr_init = omap_sram_push(omap242x_sram_ddr_init, 322 _omap2_sram_ddr_init = omap_sram_push(omap242x_sram_ddr_init,
336 omap242x_sram_ddr_init_sz); 323 omap242x_sram_ddr_init_sz);
@@ -350,8 +337,8 @@ static inline int omap242x_sram_init(void)
350} 337}
351#endif 338#endif
352 339
353#ifdef CONFIG_ARCH_OMAP2430 340#ifdef CONFIG_SOC_OMAP2430
354int __init omap243x_sram_init(void) 341static int __init omap243x_sram_init(void)
355{ 342{
356 _omap2_sram_ddr_init = omap_sram_push(omap243x_sram_ddr_init, 343 _omap2_sram_ddr_init = omap_sram_push(omap243x_sram_ddr_init,
357 omap243x_sram_ddr_init_sz); 344 omap243x_sram_ddr_init_sz);
@@ -407,7 +394,7 @@ void omap3_sram_restore_context(void)
407} 394}
408#endif /* CONFIG_PM */ 395#endif /* CONFIG_PM */
409 396
410int __init omap34xx_sram_init(void) 397static int __init omap34xx_sram_init(void)
411{ 398{
412 _omap3_sram_configure_core_dpll = 399 _omap3_sram_configure_core_dpll =
413 omap_sram_push(omap3_sram_configure_core_dpll, 400 omap_sram_push(omap3_sram_configure_core_dpll,
@@ -422,20 +409,6 @@ static inline int omap34xx_sram_init(void)
422} 409}
423#endif 410#endif
424 411
425#ifdef CONFIG_ARCH_OMAP4
426int __init omap44xx_sram_init(void)
427{
428 printk(KERN_ERR "FIXME: %s not implemented\n", __func__);
429
430 return -ENODEV;
431}
432#else
433static inline int omap44xx_sram_init(void)
434{
435 return 0;
436}
437#endif
438
439int __init omap_sram_init(void) 412int __init omap_sram_init(void)
440{ 413{
441 omap_detect_sram(); 414 omap_detect_sram();
@@ -449,8 +422,6 @@ int __init omap_sram_init(void)
449 omap243x_sram_init(); 422 omap243x_sram_init();
450 else if (cpu_is_omap34xx()) 423 else if (cpu_is_omap34xx())
451 omap34xx_sram_init(); 424 omap34xx_sram_init();
452 else if (cpu_is_omap44xx())
453 omap44xx_sram_init();
454 425
455 return 0; 426 return 0;
456} 427}
diff --git a/arch/arm/plat-omap/sram.h b/arch/arm/plat-omap/sram.h
new file mode 100644
index 000000000000..29b43ef97f20
--- /dev/null
+++ b/arch/arm/plat-omap/sram.h
@@ -0,0 +1,6 @@
1#ifndef __PLAT_OMAP_SRAM_H__
2#define __PLAT_OMAP_SRAM_H__
3
4extern int __init omap_sram_init(void);
5
6#endif /* __PLAT_OMAP_SRAM_H__ */