diff options
author | dmitry pervushin <dpervushin@embeddedalley.com> | 2009-06-04 08:51:05 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-06-04 09:16:45 -0400 |
commit | c11c22177ae2929598051a39e4655be4a42cb805 (patch) | |
tree | e003e7c2ef7c78b1cc6281e30a3031af59782a5f /arch/arm/mach-stmp378x | |
parent | a50808b6c4e0e25a72314391d70479447e3ce092 (diff) |
[ARM] 5539/1: Freescale STMP: onboard devices declaration
Define onboard devices for Freescale STMP3xxx boards
Signed-off-by: dmitry pervushin <dpervushin@embeddedalley.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-stmp378x')
-rw-r--r-- | arch/arm/mach-stmp378x/stmp378x.c | 61 | ||||
-rw-r--r-- | arch/arm/mach-stmp378x/stmp378x.h | 1 | ||||
-rw-r--r-- | arch/arm/mach-stmp378x/stmp378x_devb.c | 254 |
3 files changed, 316 insertions, 0 deletions
diff --git a/arch/arm/mach-stmp378x/stmp378x.c b/arch/arm/mach-stmp378x/stmp378x.c index 9a363fb2acf3..ddd49a760fd4 100644 --- a/arch/arm/mach-stmp378x/stmp378x.c +++ b/arch/arm/mach-stmp378x/stmp378x.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/irq.h> | 21 | #include <linux/irq.h> |
22 | #include <linux/dma-mapping.h> | ||
22 | 23 | ||
23 | #include <asm/dma.h> | 24 | #include <asm/dma.h> |
24 | #include <asm/setup.h> | 25 | #include <asm/setup.h> |
@@ -39,6 +40,8 @@ | |||
39 | #include <mach/regs-icoll.h> | 40 | #include <mach/regs-icoll.h> |
40 | #include <mach/regs-apbh.h> | 41 | #include <mach/regs-apbh.h> |
41 | #include <mach/regs-apbx.h> | 42 | #include <mach/regs-apbx.h> |
43 | #include <mach/regs-pxp.h> | ||
44 | #include <mach/regs-i2c.h> | ||
42 | 45 | ||
43 | #include "stmp378x.h" | 46 | #include "stmp378x.h" |
44 | /* | 47 | /* |
@@ -232,6 +235,64 @@ static struct map_desc stmp378x_io_desc[] __initdata = { | |||
232 | }, | 235 | }, |
233 | }; | 236 | }; |
234 | 237 | ||
238 | |||
239 | static u64 common_dmamask = DMA_BIT_MASK(32); | ||
240 | |||
241 | /* | ||
242 | * devices that are present only on stmp378x, not on all 3xxx boards: | ||
243 | * PxP | ||
244 | * I2C | ||
245 | */ | ||
246 | static struct resource pxp_resource[] = { | ||
247 | { | ||
248 | .flags = IORESOURCE_MEM, | ||
249 | .start = REGS_PXP_PHYS, | ||
250 | .end = REGS_PXP_PHYS + REGS_PXP_SIZE, | ||
251 | }, { | ||
252 | .flags = IORESOURCE_IRQ, | ||
253 | .start = IRQ_PXP, | ||
254 | .end = IRQ_PXP, | ||
255 | }, | ||
256 | }; | ||
257 | |||
258 | struct platform_device stmp378x_pxp = { | ||
259 | .name = "stmp3xxx-pxp", | ||
260 | .id = -1, | ||
261 | .dev = { | ||
262 | .dma_mask = &common_dmamask, | ||
263 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
264 | }, | ||
265 | .num_resources = ARRAY_SIZE(pxp_resource), | ||
266 | .resource = pxp_resource, | ||
267 | }; | ||
268 | |||
269 | static struct resource i2c_resources[] = { | ||
270 | { | ||
271 | .flags = IORESOURCE_IRQ, | ||
272 | .start = IRQ_I2C_ERROR, | ||
273 | .end = IRQ_I2C_ERROR, | ||
274 | }, { | ||
275 | .flags = IORESOURCE_MEM, | ||
276 | .start = REGS_I2C_PHYS, | ||
277 | .end = REGS_I2C_PHYS + REGS_I2C_SIZE, | ||
278 | }, { | ||
279 | .flags = IORESOURCE_DMA, | ||
280 | .start = STMP3XXX_DMA(3, STMP3XXX_BUS_APBX), | ||
281 | .end = STMP3XXX_DMA(3, STMP3XXX_BUS_APBX), | ||
282 | }, | ||
283 | }; | ||
284 | |||
285 | struct platform_device stmp378x_i2c = { | ||
286 | .name = "i2c_stmp3xxx", | ||
287 | .id = 0, | ||
288 | .dev = { | ||
289 | .dma_mask = &common_dmamask, | ||
290 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
291 | }, | ||
292 | .resource = i2c_resources, | ||
293 | .num_resources = ARRAY_SIZE(i2c_resources), | ||
294 | }; | ||
295 | |||
235 | void __init stmp378x_map_io(void) | 296 | void __init stmp378x_map_io(void) |
236 | { | 297 | { |
237 | iotable_init(stmp378x_io_desc, ARRAY_SIZE(stmp378x_io_desc)); | 298 | iotable_init(stmp378x_io_desc, ARRAY_SIZE(stmp378x_io_desc)); |
diff --git a/arch/arm/mach-stmp378x/stmp378x.h b/arch/arm/mach-stmp378x/stmp378x.h index 473de64cf8f7..0dc15b3c891f 100644 --- a/arch/arm/mach-stmp378x/stmp378x.h +++ b/arch/arm/mach-stmp378x/stmp378x.h | |||
@@ -21,4 +21,5 @@ | |||
21 | void stmp378x_map_io(void); | 21 | void stmp378x_map_io(void); |
22 | void stmp378x_init_irq(void); | 22 | void stmp378x_init_irq(void); |
23 | 23 | ||
24 | extern struct platform_device stmp378x_pxp, stmp378x_i2c; | ||
24 | #endif /* __MACH_STMP378X_COMMON_H */ | 25 | #endif /* __MACH_STMP378X_COMMON_H */ |
diff --git a/arch/arm/mach-stmp378x/stmp378x_devb.c b/arch/arm/mach-stmp378x/stmp378x_devb.c index bc643f686b11..90d8fe6f10fe 100644 --- a/arch/arm/mach-stmp378x/stmp378x_devb.c +++ b/arch/arm/mach-stmp378x/stmp378x_devb.c | |||
@@ -17,7 +17,12 @@ | |||
17 | */ | 17 | */ |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/io.h> | ||
20 | #include <linux/platform_device.h> | 21 | #include <linux/platform_device.h> |
22 | #include <linux/delay.h> | ||
23 | #include <linux/clk.h> | ||
24 | #include <linux/err.h> | ||
25 | #include <linux/spi/spi.h> | ||
21 | 26 | ||
22 | #include <asm/setup.h> | 27 | #include <asm/setup.h> |
23 | #include <asm/mach-types.h> | 28 | #include <asm/mach-types.h> |
@@ -25,12 +30,39 @@ | |||
25 | 30 | ||
26 | #include <mach/pins.h> | 31 | #include <mach/pins.h> |
27 | #include <mach/pinmux.h> | 32 | #include <mach/pinmux.h> |
33 | #include <mach/platform.h> | ||
28 | #include <mach/stmp3xxx.h> | 34 | #include <mach/stmp3xxx.h> |
35 | #include <mach/mmc.h> | ||
36 | #include <mach/gpmi.h> | ||
29 | 37 | ||
30 | #include "stmp378x.h" | 38 | #include "stmp378x.h" |
31 | 39 | ||
32 | static struct platform_device *devices[] = { | 40 | static struct platform_device *devices[] = { |
33 | &stmp3xxx_dbguart, | 41 | &stmp3xxx_dbguart, |
42 | &stmp3xxx_appuart, | ||
43 | &stmp3xxx_watchdog, | ||
44 | &stmp3xxx_touchscreen, | ||
45 | &stmp3xxx_rtc, | ||
46 | &stmp3xxx_keyboard, | ||
47 | &stmp3xxx_framebuffer, | ||
48 | &stmp3xxx_backlight, | ||
49 | &stmp3xxx_rotdec, | ||
50 | &stmp3xxx_persistent, | ||
51 | &stmp3xxx_dcp_bootstream, | ||
52 | &stmp3xxx_dcp, | ||
53 | &stmp3xxx_battery, | ||
54 | &stmp378x_pxp, | ||
55 | &stmp378x_i2c, | ||
56 | }; | ||
57 | |||
58 | static struct pin_desc i2c_pins_desc[] = { | ||
59 | { PINID_I2C_SCL, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
60 | { PINID_I2C_SDA, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
61 | }; | ||
62 | |||
63 | static struct pin_group i2c_pins = { | ||
64 | .pins = i2c_pins_desc, | ||
65 | .nr_pins = ARRAY_SIZE(i2c_pins_desc), | ||
34 | }; | 66 | }; |
35 | 67 | ||
36 | static struct pin_desc dbguart_pins_0[] = { | 68 | static struct pin_desc dbguart_pins_0[] = { |
@@ -56,6 +88,215 @@ static int dbguart_pins_control(int id, int request) | |||
56 | return r; | 88 | return r; |
57 | } | 89 | } |
58 | 90 | ||
91 | static struct pin_desc appuart_pins_0[] = { | ||
92 | { PINID_AUART1_CTS, PIN_FUN1, PIN_4MA, PIN_1_8V, 0, }, | ||
93 | { PINID_AUART1_RTS, PIN_FUN1, PIN_4MA, PIN_1_8V, 0, }, | ||
94 | { PINID_AUART1_RX, PIN_FUN1, PIN_4MA, PIN_1_8V, 0, }, | ||
95 | { PINID_AUART1_TX, PIN_FUN1, PIN_4MA, PIN_1_8V, 0, }, | ||
96 | }; | ||
97 | |||
98 | static struct pin_desc appuart_pins_1[] = { | ||
99 | #if 0 /* enable these when second appuart will be connected */ | ||
100 | { PINID_AUART2_CTS, PIN_FUN1, PIN_4MA, PIN_1_8V, 0, }, | ||
101 | { PINID_AUART2_RTS, PIN_FUN1, PIN_4MA, PIN_1_8V, 0, }, | ||
102 | { PINID_AUART2_RX, PIN_FUN1, PIN_4MA, PIN_1_8V, 0, }, | ||
103 | { PINID_AUART2_TX, PIN_FUN1, PIN_4MA, PIN_1_8V, 0, }, | ||
104 | #endif | ||
105 | }; | ||
106 | |||
107 | static struct pin_desc mmc_pins_desc[] = { | ||
108 | { PINID_SSP1_DATA0, PIN_FUN1, PIN_8MA, PIN_3_3V, 1 }, | ||
109 | { PINID_SSP1_DATA1, PIN_FUN1, PIN_8MA, PIN_3_3V, 1 }, | ||
110 | { PINID_SSP1_DATA2, PIN_FUN1, PIN_8MA, PIN_3_3V, 1 }, | ||
111 | { PINID_SSP1_DATA3, PIN_FUN1, PIN_8MA, PIN_3_3V, 1 }, | ||
112 | { PINID_SSP1_CMD, PIN_FUN1, PIN_8MA, PIN_3_3V, 1 }, | ||
113 | { PINID_SSP1_SCK, PIN_FUN1, PIN_8MA, PIN_3_3V, 0 }, | ||
114 | { PINID_SSP1_DETECT, PIN_FUN1, PIN_8MA, PIN_3_3V, 0 }, | ||
115 | }; | ||
116 | |||
117 | static struct pin_group mmc_pins = { | ||
118 | .pins = mmc_pins_desc, | ||
119 | .nr_pins = ARRAY_SIZE(mmc_pins_desc), | ||
120 | }; | ||
121 | |||
122 | static int stmp3xxxmmc_get_wp(void) | ||
123 | { | ||
124 | return gpio_get_value(PINID_PWM4); | ||
125 | } | ||
126 | |||
127 | static int stmp3xxxmmc_hw_init_ssp1(void) | ||
128 | { | ||
129 | int ret; | ||
130 | |||
131 | ret = stmp3xxx_request_pin_group(&mmc_pins, "mmc"); | ||
132 | if (ret) | ||
133 | goto out; | ||
134 | |||
135 | /* Configure write protect GPIO pin */ | ||
136 | ret = gpio_request(PINID_PWM4, "mmc wp"); | ||
137 | if (ret) | ||
138 | goto out_wp; | ||
139 | |||
140 | gpio_direction_input(PINID_PWM4); | ||
141 | |||
142 | /* Configure POWER pin as gpio to drive power to MMC slot */ | ||
143 | ret = gpio_request(PINID_PWM3, "mmc power"); | ||
144 | if (ret) | ||
145 | goto out_power; | ||
146 | |||
147 | gpio_direction_output(PINID_PWM3, 0); | ||
148 | mdelay(100); | ||
149 | |||
150 | return 0; | ||
151 | |||
152 | out_power: | ||
153 | gpio_free(PINID_PWM4); | ||
154 | out_wp: | ||
155 | stmp3xxx_release_pin_group(&mmc_pins, "mmc"); | ||
156 | out: | ||
157 | return ret; | ||
158 | } | ||
159 | |||
160 | static void stmp3xxxmmc_hw_release_ssp1(void) | ||
161 | { | ||
162 | gpio_free(PINID_PWM3); | ||
163 | gpio_free(PINID_PWM4); | ||
164 | stmp3xxx_release_pin_group(&mmc_pins, "mmc"); | ||
165 | } | ||
166 | |||
167 | static void stmp3xxxmmc_cmd_pullup_ssp1(int enable) | ||
168 | { | ||
169 | stmp3xxx_pin_pullup(PINID_SSP1_CMD, enable, "mmc"); | ||
170 | } | ||
171 | |||
172 | static unsigned long | ||
173 | stmp3xxxmmc_setclock_ssp1(void __iomem *base, unsigned long hz) | ||
174 | { | ||
175 | struct clk *ssp, *parent; | ||
176 | char *p; | ||
177 | long r; | ||
178 | |||
179 | ssp = clk_get(NULL, "ssp"); | ||
180 | |||
181 | /* using SSP1, no timeout, clock rate 1 */ | ||
182 | writel(BF(2, SSP_TIMING_CLOCK_DIVIDE) | | ||
183 | BF(0xFFFF, SSP_TIMING_TIMEOUT), | ||
184 | base + HW_SSP_TIMING); | ||
185 | |||
186 | p = (hz > 1000000) ? "io" : "osc_24M"; | ||
187 | parent = clk_get(NULL, p); | ||
188 | clk_set_parent(ssp, parent); | ||
189 | r = clk_set_rate(ssp, 2 * hz / 1000); | ||
190 | clk_put(parent); | ||
191 | clk_put(ssp); | ||
192 | |||
193 | return hz; | ||
194 | } | ||
195 | |||
196 | static struct stmp3xxxmmc_platform_data mmc_data = { | ||
197 | .hw_init = stmp3xxxmmc_hw_init_ssp1, | ||
198 | .hw_release = stmp3xxxmmc_hw_release_ssp1, | ||
199 | .get_wp = stmp3xxxmmc_get_wp, | ||
200 | .cmd_pullup = stmp3xxxmmc_cmd_pullup_ssp1, | ||
201 | .setclock = stmp3xxxmmc_setclock_ssp1, | ||
202 | }; | ||
203 | |||
204 | |||
205 | static struct pin_group appuart_pins[] = { | ||
206 | [0] = { | ||
207 | .pins = appuart_pins_0, | ||
208 | .nr_pins = ARRAY_SIZE(appuart_pins_0), | ||
209 | }, | ||
210 | [1] = { | ||
211 | .pins = appuart_pins_1, | ||
212 | .nr_pins = ARRAY_SIZE(appuart_pins_1), | ||
213 | }, | ||
214 | }; | ||
215 | |||
216 | static struct pin_desc ssp1_pins_desc[] = { | ||
217 | { PINID_SSP1_SCK, PIN_FUN1, PIN_8MA, PIN_3_3V, 0, }, | ||
218 | { PINID_SSP1_CMD, PIN_FUN1, PIN_4MA, PIN_3_3V, 0, }, | ||
219 | { PINID_SSP1_DATA0, PIN_FUN1, PIN_4MA, PIN_3_3V, 0, }, | ||
220 | { PINID_SSP1_DATA3, PIN_FUN1, PIN_4MA, PIN_3_3V, 0, }, | ||
221 | }; | ||
222 | |||
223 | static struct pin_desc ssp2_pins_desc[] = { | ||
224 | { PINID_GPMI_WRN, PIN_FUN3, PIN_8MA, PIN_3_3V, 0, }, | ||
225 | { PINID_GPMI_RDY1, PIN_FUN3, PIN_4MA, PIN_3_3V, 0, }, | ||
226 | { PINID_GPMI_D00, PIN_FUN3, PIN_4MA, PIN_3_3V, 0, }, | ||
227 | { PINID_GPMI_D03, PIN_FUN3, PIN_4MA, PIN_3_3V, 0, }, | ||
228 | }; | ||
229 | |||
230 | static struct pin_group ssp1_pins = { | ||
231 | .pins = ssp1_pins_desc, | ||
232 | .nr_pins = ARRAY_SIZE(ssp1_pins_desc), | ||
233 | }; | ||
234 | |||
235 | static struct pin_group ssp2_pins = { | ||
236 | .pins = ssp1_pins_desc, | ||
237 | .nr_pins = ARRAY_SIZE(ssp2_pins_desc), | ||
238 | }; | ||
239 | |||
240 | static struct pin_desc gpmi_pins_desc[] = { | ||
241 | { PINID_GPMI_CE0N, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
242 | { PINID_GPMI_CE1N, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
243 | { PINID_GMPI_CE2N, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
244 | { PINID_GPMI_CLE, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
245 | { PINID_GPMI_ALE, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
246 | { PINID_GPMI_WPN, PIN_FUN1, PIN_12MA, PIN_3_3V, 0 }, | ||
247 | { PINID_GPMI_RDY1, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
248 | { PINID_GPMI_D00, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
249 | { PINID_GPMI_D01, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
250 | { PINID_GPMI_D02, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
251 | { PINID_GPMI_D03, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
252 | { PINID_GPMI_D04, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
253 | { PINID_GPMI_D05, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
254 | { PINID_GPMI_D06, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
255 | { PINID_GPMI_D07, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
256 | { PINID_GPMI_RDY0, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
257 | { PINID_GPMI_RDY2, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
258 | { PINID_GPMI_RDY3, PIN_FUN1, PIN_4MA, PIN_3_3V, 0 }, | ||
259 | { PINID_GPMI_WRN, PIN_FUN1, PIN_12MA, PIN_3_3V, 0 }, | ||
260 | { PINID_GPMI_RDN, PIN_FUN1, PIN_12MA, PIN_3_3V, 0 }, | ||
261 | }; | ||
262 | |||
263 | static struct pin_group gpmi_pins = { | ||
264 | .pins = gpmi_pins_desc, | ||
265 | .nr_pins = ARRAY_SIZE(gpmi_pins_desc), | ||
266 | }; | ||
267 | |||
268 | static struct mtd_partition gpmi_partitions[] = { | ||
269 | [0] = { | ||
270 | .name = "boot", | ||
271 | .size = 10 * SZ_1M, | ||
272 | .offset = 0, | ||
273 | }, | ||
274 | [1] = { | ||
275 | .name = "data", | ||
276 | .size = MTDPART_SIZ_FULL, | ||
277 | .offset = MTDPART_OFS_APPEND, | ||
278 | }, | ||
279 | }; | ||
280 | |||
281 | static struct gpmi_platform_data gpmi_data = { | ||
282 | .pins = &gpmi_pins, | ||
283 | .nr_parts = ARRAY_SIZE(gpmi_partitions), | ||
284 | .parts = gpmi_partitions, | ||
285 | .part_types = { "cmdline", NULL }, | ||
286 | }; | ||
287 | |||
288 | static struct spi_board_info spi_board_info[] __initdata = { | ||
289 | #if defined(CONFIG_ENC28J60) || defined(CONFIG_ENC28J60_MODULE) | ||
290 | { | ||
291 | .modalias = "enc28j60", | ||
292 | .max_speed_hz = 6 * 1000 * 1000, | ||
293 | .bus_num = 1, | ||
294 | .chip_select = 0, | ||
295 | .platform_data = NULL, | ||
296 | }, | ||
297 | #endif | ||
298 | }; | ||
299 | |||
59 | static void __init stmp378x_devb_init(void) | 300 | static void __init stmp378x_devb_init(void) |
60 | { | 301 | { |
61 | stmp3xxx_pinmux_init(NR_REAL_IRQS); | 302 | stmp3xxx_pinmux_init(NR_REAL_IRQS); |
@@ -64,9 +305,22 @@ static void __init stmp378x_devb_init(void) | |||
64 | stmp3xxx_init(); | 305 | stmp3xxx_init(); |
65 | 306 | ||
66 | stmp3xxx_dbguart.dev.platform_data = dbguart_pins_control; | 307 | stmp3xxx_dbguart.dev.platform_data = dbguart_pins_control; |
308 | stmp3xxx_appuart.dev.platform_data = appuart_pins; | ||
309 | stmp3xxx_mmc.dev.platform_data = &mmc_data; | ||
310 | stmp3xxx_gpmi.dev.platform_data = &gpmi_data; | ||
311 | stmp3xxx_spi1.dev.platform_data = &ssp1_pins; | ||
312 | stmp3xxx_spi2.dev.platform_data = &ssp2_pins; | ||
313 | stmp378x_i2c.dev.platform_data = &i2c_pins; | ||
314 | |||
315 | /* register spi devices */ | ||
316 | spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info)); | ||
67 | 317 | ||
68 | /* add board's devices */ | 318 | /* add board's devices */ |
69 | platform_add_devices(devices, ARRAY_SIZE(devices)); | 319 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
320 | |||
321 | /* add devices selected by command line ssp1= and ssp2= options */ | ||
322 | stmp3xxx_ssp1_device_register(); | ||
323 | stmp3xxx_ssp2_device_register(); | ||
70 | } | 324 | } |
71 | 325 | ||
72 | MACHINE_START(STMP378X, "STMP378X") | 326 | MACHINE_START(STMP378X, "STMP378X") |