Commit | Line | Data |
---|---|---|
eba2645a SS |
1 | /* |
2 | * board-overo.c (Gumstix Overo) | |
3 | * | |
4 | * Initial code: Steve Sakoman <steve@sakoman.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 | |
8 | * version 2 as published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software | |
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA | |
19 | * | |
20 | */ | |
21 | ||
22 | #include <linux/clk.h> | |
23 | #include <linux/delay.h> | |
24 | #include <linux/err.h> | |
25 | #include <linux/init.h> | |
26 | #include <linux/io.h> | |
27 | #include <linux/kernel.h> | |
28 | #include <linux/platform_device.h> | |
90c62bf0 | 29 | #include <linux/i2c/twl4030.h> |
bb3b9d8e | 30 | #include <linux/regulator/machine.h> |
eba2645a SS |
31 | |
32 | #include <linux/mtd/mtd.h> | |
33 | #include <linux/mtd/nand.h> | |
34 | #include <linux/mtd/partitions.h> | |
35 | ||
36 | #include <asm/mach-types.h> | |
37 | #include <asm/mach/arch.h> | |
38 | #include <asm/mach/flash.h> | |
39 | #include <asm/mach/map.h> | |
40 | ||
ce491cf8 TL |
41 | #include <plat/board.h> |
42 | #include <plat/common.h> | |
eba2645a | 43 | #include <mach/gpio.h> |
ce491cf8 | 44 | #include <plat/gpmc.h> |
eba2645a | 45 | #include <mach/hardware.h> |
ce491cf8 TL |
46 | #include <plat/nand.h> |
47 | #include <plat/mux.h> | |
48 | #include <plat/usb.h> | |
eba2645a | 49 | |
ca5742bd | 50 | #include "mux.h" |
2e12bd7e | 51 | #include "sdram-micron-mt46h32m32lf-6.h" |
90c62bf0 TL |
52 | #include "mmc-twl4030.h" |
53 | ||
0d4d9ab0 TL |
54 | #define OVERO_GPIO_BT_XGATE 15 |
55 | #define OVERO_GPIO_W2W_NRESET 16 | |
6fd210a9 | 56 | #define OVERO_GPIO_PENDOWN 114 |
0d4d9ab0 TL |
57 | #define OVERO_GPIO_BT_NRESET 164 |
58 | #define OVERO_GPIO_USBH_CPEN 168 | |
59 | #define OVERO_GPIO_USBH_NRESET 183 | |
60 | ||
eba2645a SS |
61 | #define NAND_BLOCK_SIZE SZ_128K |
62 | #define GPMC_CS0_BASE 0x60 | |
63 | #define GPMC_CS_SIZE 0x30 | |
64 | ||
172ef275 SS |
65 | #define OVERO_SMSC911X_CS 5 |
66 | #define OVERO_SMSC911X_GPIO 176 | |
67 | ||
c6a81316 SS |
68 | #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \ |
69 | defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) | |
70 | ||
ce491cf8 | 71 | #include <plat/mcspi.h> |
c6a81316 SS |
72 | #include <linux/spi/spi.h> |
73 | #include <linux/spi/ads7846.h> | |
74 | ||
75 | static struct omap2_mcspi_device_config ads7846_mcspi_config = { | |
76 | .turbo_mode = 0, | |
77 | .single_channel = 1, /* 0: slave, 1: master */ | |
78 | }; | |
79 | ||
80 | static int ads7846_get_pendown_state(void) | |
81 | { | |
82 | return !gpio_get_value(OVERO_GPIO_PENDOWN); | |
83 | } | |
84 | ||
85 | static struct ads7846_platform_data ads7846_config = { | |
86 | .x_max = 0x0fff, | |
87 | .y_max = 0x0fff, | |
88 | .x_plate_ohms = 180, | |
89 | .pressure_max = 255, | |
90 | .debounce_max = 10, | |
91 | .debounce_tol = 3, | |
92 | .debounce_rep = 1, | |
93 | .get_pendown_state = ads7846_get_pendown_state, | |
94 | .keep_vref_on = 1, | |
95 | }; | |
96 | ||
97 | static struct spi_board_info overo_spi_board_info[] __initdata = { | |
98 | { | |
99 | .modalias = "ads7846", | |
100 | .bus_num = 1, | |
101 | .chip_select = 0, | |
102 | .max_speed_hz = 1500000, | |
103 | .controller_data = &ads7846_mcspi_config, | |
104 | .irq = OMAP_GPIO_IRQ(OVERO_GPIO_PENDOWN), | |
105 | .platform_data = &ads7846_config, | |
106 | } | |
107 | }; | |
108 | ||
109 | static void __init overo_ads7846_init(void) | |
110 | { | |
111 | if ((gpio_request(OVERO_GPIO_PENDOWN, "ADS7846_PENDOWN") == 0) && | |
112 | (gpio_direction_input(OVERO_GPIO_PENDOWN) == 0)) { | |
113 | gpio_export(OVERO_GPIO_PENDOWN, 0); | |
114 | } else { | |
115 | printk(KERN_ERR "could not obtain gpio for ADS7846_PENDOWN\n"); | |
116 | return; | |
117 | } | |
118 | ||
119 | spi_register_board_info(overo_spi_board_info, | |
120 | ARRAY_SIZE(overo_spi_board_info)); | |
121 | } | |
122 | ||
123 | #else | |
124 | static inline void __init overo_ads7846_init(void) { return; } | |
125 | #endif | |
126 | ||
172ef275 SS |
127 | #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) |
128 | ||
129 | #include <linux/smsc911x.h> | |
130 | ||
131 | static struct resource overo_smsc911x_resources[] = { | |
132 | { | |
133 | .name = "smsc911x-memory", | |
134 | .flags = IORESOURCE_MEM, | |
135 | }, | |
136 | { | |
137 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, | |
138 | }, | |
139 | }; | |
140 | ||
141 | static struct smsc911x_platform_config overo_smsc911x_config = { | |
142 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, | |
143 | .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN, | |
144 | .flags = SMSC911X_USE_32BIT , | |
145 | .phy_interface = PHY_INTERFACE_MODE_MII, | |
146 | }; | |
147 | ||
148 | static struct platform_device overo_smsc911x_device = { | |
149 | .name = "smsc911x", | |
150 | .id = -1, | |
151 | .num_resources = ARRAY_SIZE(overo_smsc911x_resources), | |
5032902c | 152 | .resource = overo_smsc911x_resources, |
172ef275 SS |
153 | .dev = { |
154 | .platform_data = &overo_smsc911x_config, | |
155 | }, | |
156 | }; | |
157 | ||
158 | static inline void __init overo_init_smsc911x(void) | |
159 | { | |
160 | unsigned long cs_mem_base; | |
161 | ||
162 | if (gpmc_cs_request(OVERO_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) { | |
163 | printk(KERN_ERR "Failed request for GPMC mem for smsc911x\n"); | |
164 | return; | |
165 | } | |
166 | ||
167 | overo_smsc911x_resources[0].start = cs_mem_base + 0x0; | |
168 | overo_smsc911x_resources[0].end = cs_mem_base + 0xff; | |
169 | ||
170 | if ((gpio_request(OVERO_SMSC911X_GPIO, "SMSC911X IRQ") == 0) && | |
171 | (gpio_direction_input(OVERO_SMSC911X_GPIO) == 0)) { | |
172 | gpio_export(OVERO_SMSC911X_GPIO, 0); | |
173 | } else { | |
174 | printk(KERN_ERR "could not obtain gpio for SMSC911X IRQ\n"); | |
175 | return; | |
176 | } | |
177 | ||
178 | overo_smsc911x_resources[1].start = OMAP_GPIO_IRQ(OVERO_SMSC911X_GPIO); | |
179 | overo_smsc911x_resources[1].end = 0; | |
180 | ||
181 | platform_device_register(&overo_smsc911x_device); | |
182 | } | |
183 | ||
184 | #else | |
185 | static inline void __init overo_init_smsc911x(void) { return; } | |
186 | #endif | |
187 | ||
eba2645a SS |
188 | static struct mtd_partition overo_nand_partitions[] = { |
189 | { | |
190 | .name = "xloader", | |
191 | .offset = 0, /* Offset = 0x00000 */ | |
192 | .size = 4 * NAND_BLOCK_SIZE, | |
193 | .mask_flags = MTD_WRITEABLE | |
194 | }, | |
195 | { | |
196 | .name = "uboot", | |
197 | .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */ | |
198 | .size = 14 * NAND_BLOCK_SIZE, | |
199 | }, | |
200 | { | |
201 | .name = "uboot environment", | |
202 | .offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */ | |
203 | .size = 2 * NAND_BLOCK_SIZE, | |
204 | }, | |
205 | { | |
206 | .name = "linux", | |
207 | .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */ | |
208 | .size = 32 * NAND_BLOCK_SIZE, | |
209 | }, | |
210 | { | |
211 | .name = "rootfs", | |
212 | .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */ | |
213 | .size = MTDPART_SIZ_FULL, | |
214 | }, | |
215 | }; | |
216 | ||
217 | static struct omap_nand_platform_data overo_nand_data = { | |
218 | .parts = overo_nand_partitions, | |
219 | .nr_parts = ARRAY_SIZE(overo_nand_partitions), | |
220 | .dma_channel = -1, /* disable DMA in OMAP NAND driver */ | |
221 | }; | |
222 | ||
223 | static struct resource overo_nand_resource = { | |
224 | .flags = IORESOURCE_MEM, | |
225 | }; | |
226 | ||
227 | static struct platform_device overo_nand_device = { | |
228 | .name = "omap2-nand", | |
229 | .id = -1, | |
230 | .dev = { | |
231 | .platform_data = &overo_nand_data, | |
232 | }, | |
233 | .num_resources = 1, | |
234 | .resource = &overo_nand_resource, | |
235 | }; | |
236 | ||
237 | ||
238 | static void __init overo_flash_init(void) | |
239 | { | |
240 | u8 cs = 0; | |
241 | u8 nandcs = GPMC_CS_NUM + 1; | |
242 | ||
243 | u32 gpmc_base_add = OMAP34XX_GPMC_VIRT; | |
244 | ||
245 | /* find out the chip-select on which NAND exists */ | |
246 | while (cs < GPMC_CS_NUM) { | |
247 | u32 ret = 0; | |
248 | ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); | |
249 | ||
250 | if ((ret & 0xC00) == 0x800) { | |
251 | printk(KERN_INFO "Found NAND on CS%d\n", cs); | |
252 | if (nandcs > GPMC_CS_NUM) | |
253 | nandcs = cs; | |
254 | } | |
255 | cs++; | |
256 | } | |
257 | ||
258 | if (nandcs > GPMC_CS_NUM) { | |
259 | printk(KERN_INFO "NAND: Unable to find configuration " | |
260 | "in GPMC\n "); | |
261 | return; | |
262 | } | |
263 | ||
264 | if (nandcs < GPMC_CS_NUM) { | |
265 | overo_nand_data.cs = nandcs; | |
266 | overo_nand_data.gpmc_cs_baseaddr = (void *) | |
267 | (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE); | |
268 | overo_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add); | |
269 | ||
270 | printk(KERN_INFO "Registering NAND on CS%d\n", nandcs); | |
271 | if (platform_device_register(&overo_nand_device) < 0) | |
272 | printk(KERN_ERR "Unable to register NAND device\n"); | |
273 | } | |
274 | } | |
eba2645a | 275 | |
bb3b9d8e DB |
276 | static struct twl4030_hsmmc_info mmc[] = { |
277 | { | |
278 | .mmc = 1, | |
279 | .wires = 4, | |
280 | .gpio_cd = -EINVAL, | |
281 | .gpio_wp = -EINVAL, | |
282 | }, | |
283 | { | |
284 | .mmc = 2, | |
285 | .wires = 4, | |
286 | .gpio_cd = -EINVAL, | |
287 | .gpio_wp = -EINVAL, | |
288 | .transceiver = true, | |
289 | .ocr_mask = 0x00100000, /* 3.3V */ | |
290 | }, | |
291 | {} /* Terminator */ | |
292 | }; | |
293 | ||
294 | static struct regulator_consumer_supply overo_vmmc1_supply = { | |
295 | .supply = "vmmc", | |
296 | }; | |
297 | ||
298 | static int overo_twl_gpio_setup(struct device *dev, | |
299 | unsigned gpio, unsigned ngpio) | |
300 | { | |
301 | twl4030_mmc_init(mmc); | |
302 | ||
303 | overo_vmmc1_supply.dev = mmc[0].dev; | |
304 | ||
305 | return 0; | |
306 | } | |
307 | ||
90c62bf0 TL |
308 | static struct twl4030_gpio_platform_data overo_gpio_data = { |
309 | .gpio_base = OMAP_MAX_GPIO_LINES, | |
310 | .irq_base = TWL4030_GPIO_IRQ_BASE, | |
311 | .irq_end = TWL4030_GPIO_IRQ_END, | |
bb3b9d8e DB |
312 | .setup = overo_twl_gpio_setup, |
313 | }; | |
314 | ||
315 | static struct twl4030_usb_data overo_usb_data = { | |
316 | .usb_mode = T2_USB_MODE_ULPI, | |
317 | }; | |
318 | ||
319 | static struct regulator_init_data overo_vmmc1 = { | |
320 | .constraints = { | |
321 | .min_uV = 1850000, | |
322 | .max_uV = 3150000, | |
323 | .valid_modes_mask = REGULATOR_MODE_NORMAL | |
324 | | REGULATOR_MODE_STANDBY, | |
325 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | |
326 | | REGULATOR_CHANGE_MODE | |
327 | | REGULATOR_CHANGE_STATUS, | |
328 | }, | |
329 | .num_consumer_supplies = 1, | |
330 | .consumer_supplies = &overo_vmmc1_supply, | |
90c62bf0 TL |
331 | }; |
332 | ||
e86fa0b4 PU |
333 | static struct twl4030_codec_audio_data overo_audio_data = { |
334 | .audio_mclk = 26000000, | |
335 | }; | |
336 | ||
337 | static struct twl4030_codec_data overo_codec_data = { | |
6df74efb | 338 | .audio_mclk = 26000000, |
e86fa0b4 PU |
339 | .audio = &overo_audio_data, |
340 | }; | |
341 | ||
bb3b9d8e DB |
342 | /* mmc2 (WLAN) and Bluetooth don't use twl4030 regulators */ |
343 | ||
90c62bf0 TL |
344 | static struct twl4030_platform_data overo_twldata = { |
345 | .irq_base = TWL4030_IRQ_BASE, | |
346 | .irq_end = TWL4030_IRQ_END, | |
347 | .gpio = &overo_gpio_data, | |
bb3b9d8e | 348 | .usb = &overo_usb_data, |
e86fa0b4 | 349 | .codec = &overo_codec_data, |
bb3b9d8e | 350 | .vmmc1 = &overo_vmmc1, |
90c62bf0 TL |
351 | }; |
352 | ||
353 | static struct i2c_board_info __initdata overo_i2c_boardinfo[] = { | |
354 | { | |
bb3b9d8e | 355 | I2C_BOARD_INFO("tps65950", 0x48), |
90c62bf0 TL |
356 | .flags = I2C_CLIENT_WAKE, |
357 | .irq = INT_34XX_SYS_NIRQ, | |
358 | .platform_data = &overo_twldata, | |
359 | }, | |
360 | }; | |
361 | ||
eba2645a SS |
362 | static int __init overo_i2c_init(void) |
363 | { | |
90c62bf0 TL |
364 | omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo, |
365 | ARRAY_SIZE(overo_i2c_boardinfo)); | |
eba2645a SS |
366 | /* i2c2 pins are used for gpio */ |
367 | omap_register_i2c_bus(3, 400, NULL, 0); | |
368 | return 0; | |
369 | } | |
370 | ||
eba2645a SS |
371 | static struct platform_device overo_lcd_device = { |
372 | .name = "overo_lcd", | |
373 | .id = -1, | |
374 | }; | |
375 | ||
376 | static struct omap_lcd_config overo_lcd_config __initdata = { | |
377 | .ctrl_name = "internal", | |
378 | }; | |
379 | ||
380 | static struct omap_board_config_kernel overo_config[] __initdata = { | |
eba2645a SS |
381 | { OMAP_TAG_LCD, &overo_lcd_config }, |
382 | }; | |
383 | ||
b3c6df3a PW |
384 | static void __init overo_init_irq(void) |
385 | { | |
386 | omap_board_config = overo_config; | |
387 | omap_board_config_size = ARRAY_SIZE(overo_config); | |
388 | omap2_init_common_hw(mt46h32m32lf6_sdrc_params, | |
389 | mt46h32m32lf6_sdrc_params); | |
390 | omap_init_irq(); | |
391 | omap_gpio_init(); | |
392 | } | |
393 | ||
eba2645a SS |
394 | static struct platform_device *overo_devices[] __initdata = { |
395 | &overo_lcd_device, | |
396 | }; | |
397 | ||
58a5491c FB |
398 | static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = { |
399 | .port_mode[0] = EHCI_HCD_OMAP_MODE_UNKNOWN, | |
400 | .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY, | |
401 | .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN, | |
402 | ||
403 | .phy_reset = true, | |
404 | .reset_gpio_port[0] = -EINVAL, | |
405 | .reset_gpio_port[1] = OVERO_GPIO_USBH_NRESET, | |
406 | .reset_gpio_port[2] = -EINVAL | |
407 | }; | |
408 | ||
ca5742bd TL |
409 | #ifdef CONFIG_OMAP_MUX |
410 | static struct omap_board_mux board_mux[] __initdata = { | |
411 | { .reg_offset = OMAP_MUX_TERMINATOR }, | |
412 | }; | |
413 | #else | |
414 | #define board_mux NULL | |
415 | #endif | |
58a5491c | 416 | |
eba2645a SS |
417 | static void __init overo_init(void) |
418 | { | |
ca5742bd | 419 | omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); |
eba2645a SS |
420 | overo_i2c_init(); |
421 | platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices)); | |
eba2645a SS |
422 | omap_serial_init(); |
423 | overo_flash_init(); | |
18cb7aca | 424 | usb_musb_init(); |
58a5491c | 425 | usb_ehci_init(&ehci_pdata); |
c6a81316 | 426 | overo_ads7846_init(); |
172ef275 | 427 | overo_init_smsc911x(); |
eba2645a | 428 | |
9fb97412 JP |
429 | /* Ensure SDRC pins are mux'd for self-refresh */ |
430 | omap_cfg_reg(H16_34XX_SDRC_CKE0); | |
431 | omap_cfg_reg(H17_34XX_SDRC_CKE1); | |
432 | ||
eba2645a SS |
433 | if ((gpio_request(OVERO_GPIO_W2W_NRESET, |
434 | "OVERO_GPIO_W2W_NRESET") == 0) && | |
435 | (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) { | |
436 | gpio_export(OVERO_GPIO_W2W_NRESET, 0); | |
437 | gpio_set_value(OVERO_GPIO_W2W_NRESET, 0); | |
438 | udelay(10); | |
439 | gpio_set_value(OVERO_GPIO_W2W_NRESET, 1); | |
440 | } else { | |
441 | printk(KERN_ERR "could not obtain gpio for " | |
442 | "OVERO_GPIO_W2W_NRESET\n"); | |
443 | } | |
444 | ||
445 | if ((gpio_request(OVERO_GPIO_BT_XGATE, "OVERO_GPIO_BT_XGATE") == 0) && | |
446 | (gpio_direction_output(OVERO_GPIO_BT_XGATE, 0) == 0)) | |
447 | gpio_export(OVERO_GPIO_BT_XGATE, 0); | |
448 | else | |
449 | printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_XGATE\n"); | |
450 | ||
451 | if ((gpio_request(OVERO_GPIO_BT_NRESET, "OVERO_GPIO_BT_NRESET") == 0) && | |
452 | (gpio_direction_output(OVERO_GPIO_BT_NRESET, 1) == 0)) { | |
453 | gpio_export(OVERO_GPIO_BT_NRESET, 0); | |
454 | gpio_set_value(OVERO_GPIO_BT_NRESET, 0); | |
455 | mdelay(6); | |
456 | gpio_set_value(OVERO_GPIO_BT_NRESET, 1); | |
457 | } else { | |
458 | printk(KERN_ERR "could not obtain gpio for " | |
459 | "OVERO_GPIO_BT_NRESET\n"); | |
460 | } | |
461 | ||
462 | if ((gpio_request(OVERO_GPIO_USBH_CPEN, "OVERO_GPIO_USBH_CPEN") == 0) && | |
463 | (gpio_direction_output(OVERO_GPIO_USBH_CPEN, 1) == 0)) | |
464 | gpio_export(OVERO_GPIO_USBH_CPEN, 0); | |
465 | else | |
466 | printk(KERN_ERR "could not obtain gpio for " | |
467 | "OVERO_GPIO_USBH_CPEN\n"); | |
eba2645a SS |
468 | } |
469 | ||
470 | static void __init overo_map_io(void) | |
471 | { | |
472 | omap2_set_globals_343x(); | |
473 | omap2_map_common_io(); | |
474 | } | |
475 | ||
476 | MACHINE_START(OVERO, "Gumstix Overo") | |
477 | .phys_io = 0x48000000, | |
b4224b23 | 478 | .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc, |
eba2645a SS |
479 | .boot_params = 0x80000100, |
480 | .map_io = overo_map_io, | |
481 | .init_irq = overo_init_irq, | |
482 | .init_machine = overo_init, | |
483 | .timer = &omap_timer, | |
484 | MACHINE_END |