summaryrefslogtreecommitdiffstats
path: root/patches/barebox-2012.12.0/0011-ARM-omap-Add-device-register-convenience-functions.patch
blob: b3f256188caff6bb3a223d07e1afd333a4a261dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
From fd13df75c2f73dac4eb0bf2d77d6a5010d5754cb Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Fri, 14 Dec 2012 09:25:10 +0100
Subject: [PATCH] ARM omap: Add device register convenience functions

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-omap/Makefile                     |    2 +-
 arch/arm/mach-omap/include/mach/devices.h       |   13 +++++
 arch/arm/mach-omap/include/mach/omap3-devices.h |   54 ++++++++++++++++-
 arch/arm/mach-omap/include/mach/omap4-devices.h |   71 +++++++++++++++++++++++
 arch/arm/mach-omap/omap_devices.c               |   27 +++++++++
 5 files changed, 165 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-omap/include/mach/devices.h
 create mode 100644 arch/arm/mach-omap/include/mach/omap4-devices.h
 create mode 100644 arch/arm/mach-omap/omap_devices.c

diff --git a/arch/arm/mach-omap/Makefile b/arch/arm/mach-omap/Makefile
index 2ac7fb2..b7a5e4a 100644
--- a/arch/arm/mach-omap/Makefile
+++ b/arch/arm/mach-omap/Makefile
@@ -15,7 +15,7 @@
 # GNU General Public License for more details.
 #
 #
-obj-$(CONFIG_ARCH_OMAP) += syslib.o
+obj-$(CONFIG_ARCH_OMAP) += syslib.o omap_devices.o
 pbl-$(CONFIG_ARCH_OMAP) += syslib.o
 obj-$(CONFIG_OMAP_CLOCK_SOURCE_S32K) += s32k_clksource.o
 obj-$(CONFIG_ARCH_OMAP3) += omap3_core.o omap3_generic.o auxcr.o
diff --git a/arch/arm/mach-omap/include/mach/devices.h b/arch/arm/mach-omap/include/mach/devices.h
new file mode 100644
index 0000000..9881604
--- /dev/null
+++ b/arch/arm/mach-omap/include/mach/devices.h
@@ -0,0 +1,13 @@
+#ifndef __MACH_OMAP_DEVICES_H
+#define __MACH_OMAP_DEVICES_H
+
+#include <mach/omap_hsmmc.h>
+
+struct device_d *omap_add_uart(int id, unsigned long base);
+
+struct device_d *omap_add_mmc(int id, unsigned long base,
+		struct omap_hsmmc_platform_data *pdata);
+
+struct device_d *omap_add_i2c(int id, unsigned long base, void *pdata);
+
+#endif /* __MACH_OMAP_DEVICES_H */
diff --git a/arch/arm/mach-omap/include/mach/omap3-devices.h b/arch/arm/mach-omap/include/mach/omap3-devices.h
index 8a6b324..dd6826a 100644
--- a/arch/arm/mach-omap/include/mach/omap3-devices.h
+++ b/arch/arm/mach-omap/include/mach/omap3-devices.h
@@ -1,7 +1,12 @@
+#ifndef __MACH_OMAP3_DEVICES_H
+#define __MACH_OMAP3_DEVICES_H
+
 #include <driver.h>
 #include <sizes.h>
-
+#include <mach/omap3-silicon.h>
+#include <mach/devices.h>
 #include <mach/mcspi.h>
+#include <mach/omap_hsmmc.h>
 
 /* the device numbering is the same as in the device tree */
 
@@ -30,3 +35,50 @@ static inline struct device_d *omap3_add_spi4(void)
 {
 	return omap3_add_spi(4, OMAP3_MCSPI4_BASE);
 }
+
+static inline struct device_d *omap3_add_uart1(void)
+{
+	return omap_add_uart(0, OMAP_UART1_BASE);
+}
+
+static inline struct device_d *omap3_add_uart2(void)
+{
+	return omap_add_uart(1, OMAP_UART2_BASE);
+}
+
+static inline struct device_d *omap3_add_uart3(void)
+{
+	return omap_add_uart(2, OMAP_UART3_BASE);
+}
+
+static inline struct device_d *omap3_add_mmc1(struct omap_hsmmc_platform_data *pdata)
+{
+	return omap_add_mmc(0, OMAP_MMC1_BASE + 0x100, pdata);
+}
+
+static inline struct device_d *omap3_add_mmc2(struct omap_hsmmc_platform_data *pdata)
+{
+	return omap_add_mmc(1, OMAP_MMC2_BASE + 0x100, pdata);
+}
+
+static inline struct device_d *omap3_add_mmc3(struct omap_hsmmc_platform_data *pdata)
+{
+	return omap_add_mmc(2, OMAP_MMC3_BASE + 0x100, pdata);
+}
+
+static inline struct device_d *omap3_add_i2c1(void *pdata)
+{
+	return omap_add_i2c(0, OMAP_I2C1_BASE, pdata);
+}
+
+static inline struct device_d *omap3_add_i2c2(void *pdata)
+{
+	return omap_add_i2c(1, OMAP_I2C2_BASE, pdata);
+}
+
+static inline struct device_d *omap3_add_i2c3(void *pdata)
+{
+	return omap_add_i2c(2, OMAP_I2C3_BASE, pdata);
+}
+
+#endif /* __MACH_OMAP3_DEVICES_H */
diff --git a/arch/arm/mach-omap/include/mach/omap4-devices.h b/arch/arm/mach-omap/include/mach/omap4-devices.h
new file mode 100644
index 0000000..448de68
--- /dev/null
+++ b/arch/arm/mach-omap/include/mach/omap4-devices.h
@@ -0,0 +1,71 @@
+#ifndef __MACH_OMAP4_DEVICES_H
+#define __MACH_OMAP4_DEVICES_H
+
+#include <driver.h>
+#include <sizes.h>
+#include <mach/devices.h>
+#include <mach/omap4-silicon.h>
+#include <mach/mcspi.h>
+#include <mach/omap_hsmmc.h>
+
+static inline struct device_d *omap44xx_add_uart1(void)
+{
+	return omap_add_uart(0, OMAP44XX_UART1_BASE);
+}
+
+static inline struct device_d *omap44xx_add_uart2(void)
+{
+	return omap_add_uart(1, OMAP44XX_UART2_BASE);
+}
+
+static inline struct device_d *omap44xx_add_uart3(void)
+{
+	return omap_add_uart(2, OMAP44XX_UART3_BASE);
+}
+
+static inline struct device_d *omap44xx_add_mmc1(struct omap_hsmmc_platform_data *pdata)
+{
+	return omap_add_mmc(0, OMAP44XX_MMC1_BASE, pdata);
+}
+
+static inline struct device_d *omap44xx_add_mmc2(struct omap_hsmmc_platform_data *pdata)
+{
+	return omap_add_mmc(1, OMAP44XX_MMC2_BASE, pdata);
+}
+
+static inline struct device_d *omap44xx_add_mmc3(struct omap_hsmmc_platform_data *pdata)
+{
+	return omap_add_mmc(2, OMAP44XX_MMC3_BASE, pdata);
+}
+
+static inline struct device_d *omap44xx_add_mmc4(struct omap_hsmmc_platform_data *pdata)
+{
+	return omap_add_mmc(3, OMAP44XX_MMC4_BASE, pdata);
+}
+
+static inline struct device_d *omap44xx_add_mmc5(struct omap_hsmmc_platform_data *pdata)
+{
+	return omap_add_mmc(4, OMAP44XX_MMC5_BASE, pdata);
+}
+
+static inline struct device_d *omap44xx_add_i2c1(void *pdata)
+{
+	return omap_add_i2c(0, OMAP44XX_I2C1_BASE, pdata);
+}
+
+static inline struct device_d *omap44xx_add_i2c2(void *pdata)
+{
+	return omap_add_i2c(1, OMAP44XX_I2C2_BASE, pdata);
+}
+
+static inline struct device_d *omap44xx_add_i2c3(void *pdata)
+{
+	return omap_add_i2c(2, OMAP44XX_I2C3_BASE, pdata);
+}
+
+static inline struct device_d *omap44xx_add_i2c4(void *pdata)
+{
+	return omap_add_i2c(3, OMAP44XX_I2C4_BASE, pdata);
+}
+
+#endif /* __MACH_OMAP4_DEVICES_H */
diff --git a/arch/arm/mach-omap/omap_devices.c b/arch/arm/mach-omap/omap_devices.c
new file mode 100644
index 0000000..acf029d
--- /dev/null
+++ b/arch/arm/mach-omap/omap_devices.c
@@ -0,0 +1,27 @@
+#include <driver.h>
+#include <ns16550.h>
+#include <mach/omap3-devices.h>
+
+static struct NS16550_plat serial_plat = {
+	.clock = 48000000,      /* 48MHz (APLL96/2) */
+	.shift = 2,
+};
+
+struct device_d *omap_add_uart(int id, unsigned long base)
+{
+	return add_ns16550_device(id, base, 1024,
+			IORESOURCE_MEM_8BIT, &serial_plat);
+}
+
+struct device_d *omap_add_mmc(int id, unsigned long base,
+		struct omap_hsmmc_platform_data *pdata)
+{
+	return add_generic_device("omap-hsmmc", id, NULL,
+			base, SZ_4K, IORESOURCE_MEM, pdata);
+}
+
+struct device_d *omap_add_i2c(int id, unsigned long base, void *pdata)
+{
+	return add_generic_device("i2c-omap", id, NULL, base, SZ_4K,
+			   IORESOURCE_MEM, pdata);
+}