First Support on Ginger and OMAP TI
[linux-ginger.git] / arch / arm / mach-omap2 / board-overo.c
blob75f5d098498aceca90e027b5deea6a7444318c37
1 /*
2 * board-overo.c (Gumstix Overo)
4 * Initial code: Steve Sakoman <steve@sakoman.com>
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.
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.
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
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>
29 #include <linux/i2c/twl4030.h>
30 #include <linux/regulator/machine.h>
32 #include <linux/mtd/mtd.h>
33 #include <linux/mtd/nand.h>
34 #include <linux/mtd/partitions.h>
36 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
38 #include <asm/mach/flash.h>
39 #include <asm/mach/map.h>
41 #include <plat/board.h>
42 #include <plat/common.h>
43 #include <mach/gpio.h>
44 #include <plat/gpmc.h>
45 #include <mach/hardware.h>
46 #include <plat/nand.h>
47 #include <plat/mux.h>
48 #include <plat/usb.h>
50 #include "sdram-micron-mt46h32m32lf-6.h"
51 #include "mmc-twl4030.h"
53 #define OVERO_GPIO_BT_XGATE 15
54 #define OVERO_GPIO_W2W_NRESET 16
55 #define OVERO_GPIO_PENDOWN 114
56 #define OVERO_GPIO_BT_NRESET 164
57 #define OVERO_GPIO_USBH_CPEN 168
58 #define OVERO_GPIO_USBH_NRESET 183
60 #define NAND_BLOCK_SIZE SZ_128K
61 #define GPMC_CS0_BASE 0x60
62 #define GPMC_CS_SIZE 0x30
64 #define OVERO_SMSC911X_CS 5
65 #define OVERO_SMSC911X_GPIO 176
67 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
68 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
70 #include <plat/mcspi.h>
71 #include <linux/spi/spi.h>
72 #include <linux/spi/ads7846.h>
74 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
75 .turbo_mode = 0,
76 .single_channel = 1, /* 0: slave, 1: master */
79 static int ads7846_get_pendown_state(void)
81 return !gpio_get_value(OVERO_GPIO_PENDOWN);
84 static struct ads7846_platform_data ads7846_config = {
85 .x_max = 0x0fff,
86 .y_max = 0x0fff,
87 .x_plate_ohms = 180,
88 .pressure_max = 255,
89 .debounce_max = 10,
90 .debounce_tol = 3,
91 .debounce_rep = 1,
92 .get_pendown_state = ads7846_get_pendown_state,
93 .keep_vref_on = 1,
96 static struct spi_board_info overo_spi_board_info[] __initdata = {
98 .modalias = "ads7846",
99 .bus_num = 1,
100 .chip_select = 0,
101 .max_speed_hz = 1500000,
102 .controller_data = &ads7846_mcspi_config,
103 .irq = OMAP_GPIO_IRQ(OVERO_GPIO_PENDOWN),
104 .platform_data = &ads7846_config,
108 static void __init overo_ads7846_init(void)
110 if ((gpio_request(OVERO_GPIO_PENDOWN, "ADS7846_PENDOWN") == 0) &&
111 (gpio_direction_input(OVERO_GPIO_PENDOWN) == 0)) {
112 gpio_export(OVERO_GPIO_PENDOWN, 0);
113 } else {
114 printk(KERN_ERR "could not obtain gpio for ADS7846_PENDOWN\n");
115 return;
118 spi_register_board_info(overo_spi_board_info,
119 ARRAY_SIZE(overo_spi_board_info));
122 #else
123 static inline void __init overo_ads7846_init(void) { return; }
124 #endif
126 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
128 #include <linux/smsc911x.h>
130 static struct resource overo_smsc911x_resources[] = {
132 .name = "smsc911x-memory",
133 .flags = IORESOURCE_MEM,
136 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
140 static struct smsc911x_platform_config overo_smsc911x_config = {
141 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
142 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
143 .flags = SMSC911X_USE_32BIT ,
144 .phy_interface = PHY_INTERFACE_MODE_MII,
147 static struct platform_device overo_smsc911x_device = {
148 .name = "smsc911x",
149 .id = -1,
150 .num_resources = ARRAY_SIZE(overo_smsc911x_resources),
151 .resource = overo_smsc911x_resources,
152 .dev = {
153 .platform_data = &overo_smsc911x_config,
157 static inline void __init overo_init_smsc911x(void)
159 unsigned long cs_mem_base;
161 if (gpmc_cs_request(OVERO_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) {
162 printk(KERN_ERR "Failed request for GPMC mem for smsc911x\n");
163 return;
166 overo_smsc911x_resources[0].start = cs_mem_base + 0x0;
167 overo_smsc911x_resources[0].end = cs_mem_base + 0xff;
169 if ((gpio_request(OVERO_SMSC911X_GPIO, "SMSC911X IRQ") == 0) &&
170 (gpio_direction_input(OVERO_SMSC911X_GPIO) == 0)) {
171 gpio_export(OVERO_SMSC911X_GPIO, 0);
172 } else {
173 printk(KERN_ERR "could not obtain gpio for SMSC911X IRQ\n");
174 return;
177 overo_smsc911x_resources[1].start = OMAP_GPIO_IRQ(OVERO_SMSC911X_GPIO);
178 overo_smsc911x_resources[1].end = 0;
180 platform_device_register(&overo_smsc911x_device);
183 #else
184 static inline void __init overo_init_smsc911x(void) { return; }
185 #endif
187 static struct mtd_partition overo_nand_partitions[] = {
189 .name = "xloader",
190 .offset = 0, /* Offset = 0x00000 */
191 .size = 4 * NAND_BLOCK_SIZE,
192 .mask_flags = MTD_WRITEABLE
195 .name = "uboot",
196 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
197 .size = 14 * NAND_BLOCK_SIZE,
200 .name = "uboot environment",
201 .offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */
202 .size = 2 * NAND_BLOCK_SIZE,
205 .name = "linux",
206 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
207 .size = 32 * NAND_BLOCK_SIZE,
210 .name = "rootfs",
211 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
212 .size = MTDPART_SIZ_FULL,
216 static struct omap_nand_platform_data overo_nand_data = {
217 .parts = overo_nand_partitions,
218 .nr_parts = ARRAY_SIZE(overo_nand_partitions),
219 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
222 static struct resource overo_nand_resource = {
223 .flags = IORESOURCE_MEM,
226 static struct platform_device overo_nand_device = {
227 .name = "omap2-nand",
228 .id = -1,
229 .dev = {
230 .platform_data = &overo_nand_data,
232 .num_resources = 1,
233 .resource = &overo_nand_resource,
237 static void __init overo_flash_init(void)
239 u8 cs = 0;
240 u8 nandcs = GPMC_CS_NUM + 1;
242 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
244 /* find out the chip-select on which NAND exists */
245 while (cs < GPMC_CS_NUM) {
246 u32 ret = 0;
247 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
249 if ((ret & 0xC00) == 0x800) {
250 printk(KERN_INFO "Found NAND on CS%d\n", cs);
251 if (nandcs > GPMC_CS_NUM)
252 nandcs = cs;
254 cs++;
257 if (nandcs > GPMC_CS_NUM) {
258 printk(KERN_INFO "NAND: Unable to find configuration "
259 "in GPMC\n ");
260 return;
263 if (nandcs < GPMC_CS_NUM) {
264 overo_nand_data.cs = nandcs;
265 overo_nand_data.gpmc_cs_baseaddr = (void *)
266 (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
267 overo_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
269 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
270 if (platform_device_register(&overo_nand_device) < 0)
271 printk(KERN_ERR "Unable to register NAND device\n");
275 static struct twl4030_hsmmc_info mmc[] = {
277 .mmc = 1,
278 .wires = 4,
279 .gpio_cd = -EINVAL,
280 .gpio_wp = -EINVAL,
283 .mmc = 2,
284 .wires = 4,
285 .gpio_cd = -EINVAL,
286 .gpio_wp = -EINVAL,
287 .transceiver = true,
288 .ocr_mask = 0x00100000, /* 3.3V */
290 {} /* Terminator */
293 static struct regulator_consumer_supply overo_vmmc1_supply = {
294 .supply = "vmmc",
297 static int overo_twl_gpio_setup(struct device *dev,
298 unsigned gpio, unsigned ngpio)
300 twl4030_mmc_init(mmc);
302 overo_vmmc1_supply.dev = mmc[0].dev;
304 return 0;
307 static struct twl4030_gpio_platform_data overo_gpio_data = {
308 .gpio_base = OMAP_MAX_GPIO_LINES,
309 .irq_base = TWL4030_GPIO_IRQ_BASE,
310 .irq_end = TWL4030_GPIO_IRQ_END,
311 .setup = overo_twl_gpio_setup,
314 static struct twl4030_usb_data overo_usb_data = {
315 .usb_mode = T2_USB_MODE_ULPI,
318 static struct regulator_init_data overo_vmmc1 = {
319 .constraints = {
320 .min_uV = 1850000,
321 .max_uV = 3150000,
322 .valid_modes_mask = REGULATOR_MODE_NORMAL
323 | REGULATOR_MODE_STANDBY,
324 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
325 | REGULATOR_CHANGE_MODE
326 | REGULATOR_CHANGE_STATUS,
328 .num_consumer_supplies = 1,
329 .consumer_supplies = &overo_vmmc1_supply,
332 /* mmc2 (WLAN) and Bluetooth don't use twl4030 regulators */
334 static struct twl4030_platform_data overo_twldata = {
335 .irq_base = TWL4030_IRQ_BASE,
336 .irq_end = TWL4030_IRQ_END,
337 .gpio = &overo_gpio_data,
338 .usb = &overo_usb_data,
339 .vmmc1 = &overo_vmmc1,
342 static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
344 I2C_BOARD_INFO("tps65950", 0x48),
345 .flags = I2C_CLIENT_WAKE,
346 .irq = INT_34XX_SYS_NIRQ,
347 .platform_data = &overo_twldata,
351 static int __init overo_i2c_init(void)
353 omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo,
354 ARRAY_SIZE(overo_i2c_boardinfo));
355 /* i2c2 pins are used for gpio */
356 omap_register_i2c_bus(3, 400, NULL, 0);
357 return 0;
360 static struct platform_device overo_lcd_device = {
361 .name = "overo_lcd",
362 .id = -1,
365 static struct omap_lcd_config overo_lcd_config __initdata = {
366 .ctrl_name = "internal",
369 static struct omap_board_config_kernel overo_config[] __initdata = {
370 { OMAP_TAG_LCD, &overo_lcd_config },
373 static void __init overo_init_irq(void)
375 omap_board_config = overo_config;
376 omap_board_config_size = ARRAY_SIZE(overo_config);
377 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
378 mt46h32m32lf6_sdrc_params, NULL, NULL, NULL);
379 omap_init_irq();
380 omap_gpio_init();
383 static struct platform_device *overo_devices[] __initdata = {
384 &overo_lcd_device,
387 static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
388 .port_mode[0] = EHCI_HCD_OMAP_MODE_UNKNOWN,
389 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
390 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
392 .phy_reset = true,
393 .reset_gpio_port[0] = -EINVAL,
394 .reset_gpio_port[1] = OVERO_GPIO_USBH_NRESET,
395 .reset_gpio_port[2] = -EINVAL
399 static void __init overo_init(void)
401 overo_i2c_init();
402 platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices));
403 omap_serial_init();
404 overo_flash_init();
405 usb_musb_init();
406 usb_ehci_init(&ehci_pdata);
407 overo_ads7846_init();
408 overo_init_smsc911x();
410 /* Ensure SDRC pins are mux'd for self-refresh */
411 omap_cfg_reg(H16_34XX_SDRC_CKE0);
412 omap_cfg_reg(H17_34XX_SDRC_CKE1);
414 if ((gpio_request(OVERO_GPIO_W2W_NRESET,
415 "OVERO_GPIO_W2W_NRESET") == 0) &&
416 (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) {
417 gpio_export(OVERO_GPIO_W2W_NRESET, 0);
418 gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);
419 udelay(10);
420 gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
421 } else {
422 printk(KERN_ERR "could not obtain gpio for "
423 "OVERO_GPIO_W2W_NRESET\n");
426 if ((gpio_request(OVERO_GPIO_BT_XGATE, "OVERO_GPIO_BT_XGATE") == 0) &&
427 (gpio_direction_output(OVERO_GPIO_BT_XGATE, 0) == 0))
428 gpio_export(OVERO_GPIO_BT_XGATE, 0);
429 else
430 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
432 if ((gpio_request(OVERO_GPIO_BT_NRESET, "OVERO_GPIO_BT_NRESET") == 0) &&
433 (gpio_direction_output(OVERO_GPIO_BT_NRESET, 1) == 0)) {
434 gpio_export(OVERO_GPIO_BT_NRESET, 0);
435 gpio_set_value(OVERO_GPIO_BT_NRESET, 0);
436 mdelay(6);
437 gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
438 } else {
439 printk(KERN_ERR "could not obtain gpio for "
440 "OVERO_GPIO_BT_NRESET\n");
443 if ((gpio_request(OVERO_GPIO_USBH_CPEN, "OVERO_GPIO_USBH_CPEN") == 0) &&
444 (gpio_direction_output(OVERO_GPIO_USBH_CPEN, 1) == 0))
445 gpio_export(OVERO_GPIO_USBH_CPEN, 0);
446 else
447 printk(KERN_ERR "could not obtain gpio for "
448 "OVERO_GPIO_USBH_CPEN\n");
451 static void __init overo_map_io(void)
453 omap2_set_globals_343x();
454 omap2_map_common_io();
457 MACHINE_START(OVERO, "Gumstix Overo")
458 .phys_io = 0x48000000,
459 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
460 .boot_params = 0x80000100,
461 .map_io = overo_map_io,
462 .init_irq = overo_init_irq,
463 .init_machine = overo_init,
464 .timer = &omap_timer,
465 MACHINE_END