blob: dff5528fbfb567fbdd661d1546c5a8cc83e09cd7 [file] [log] [blame]
Steve Sakomaneba26452008-10-09 17:51:43 +03001/*
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>
Tony Lindgren90c62bf2008-12-10 17:37:17 -080029#include <linux/i2c/twl4030.h>
David Brownellbb3b9d82009-05-28 14:04:03 -070030#include <linux/regulator/machine.h>
Steve Sakomaneba26452008-10-09 17:51:43 +030031
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
Steve Sakomaneba26452008-10-09 17:51:43 +030041#include <mach/board.h>
42#include <mach/common.h>
43#include <mach/gpio.h>
44#include <mach/gpmc.h>
45#include <mach/hardware.h>
46#include <mach/nand.h>
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070047#include <mach/usb.h>
Steve Sakomaneba26452008-10-09 17:51:43 +030048
Paul Walmsley2e12bd72009-05-28 14:03:59 -070049#include "sdram-micron-mt46h32m32lf-6.h"
Tony Lindgren90c62bf2008-12-10 17:37:17 -080050#include "mmc-twl4030.h"
51
Tony Lindgren0d4d9ab2009-03-23 18:07:38 -070052#define OVERO_GPIO_BT_XGATE 15
53#define OVERO_GPIO_W2W_NRESET 16
54#define OVERO_GPIO_BT_NRESET 164
55#define OVERO_GPIO_USBH_CPEN 168
56#define OVERO_GPIO_USBH_NRESET 183
57
Steve Sakomaneba26452008-10-09 17:51:43 +030058#define NAND_BLOCK_SIZE SZ_128K
59#define GPMC_CS0_BASE 0x60
60#define GPMC_CS_SIZE 0x30
61
Steve Sakoman172ef272009-02-02 06:27:49 +000062#define OVERO_SMSC911X_CS 5
63#define OVERO_SMSC911X_GPIO 176
64
Steve Sakomanc6a81312009-03-23 18:38:16 -070065#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
66 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
67
68#include <mach/mcspi.h>
69#include <linux/spi/spi.h>
70#include <linux/spi/ads7846.h>
71
72static struct omap2_mcspi_device_config ads7846_mcspi_config = {
73 .turbo_mode = 0,
74 .single_channel = 1, /* 0: slave, 1: master */
75};
76
77static int ads7846_get_pendown_state(void)
78{
79 return !gpio_get_value(OVERO_GPIO_PENDOWN);
80}
81
82static struct ads7846_platform_data ads7846_config = {
83 .x_max = 0x0fff,
84 .y_max = 0x0fff,
85 .x_plate_ohms = 180,
86 .pressure_max = 255,
87 .debounce_max = 10,
88 .debounce_tol = 3,
89 .debounce_rep = 1,
90 .get_pendown_state = ads7846_get_pendown_state,
91 .keep_vref_on = 1,
92};
93
94static struct spi_board_info overo_spi_board_info[] __initdata = {
95 {
96 .modalias = "ads7846",
97 .bus_num = 1,
98 .chip_select = 0,
99 .max_speed_hz = 1500000,
100 .controller_data = &ads7846_mcspi_config,
101 .irq = OMAP_GPIO_IRQ(OVERO_GPIO_PENDOWN),
102 .platform_data = &ads7846_config,
103 }
104};
105
106static void __init overo_ads7846_init(void)
107{
108 if ((gpio_request(OVERO_GPIO_PENDOWN, "ADS7846_PENDOWN") == 0) &&
109 (gpio_direction_input(OVERO_GPIO_PENDOWN) == 0)) {
110 gpio_export(OVERO_GPIO_PENDOWN, 0);
111 } else {
112 printk(KERN_ERR "could not obtain gpio for ADS7846_PENDOWN\n");
113 return;
114 }
115
116 spi_register_board_info(overo_spi_board_info,
117 ARRAY_SIZE(overo_spi_board_info));
118}
119
120#else
121static inline void __init overo_ads7846_init(void) { return; }
122#endif
123
Steve Sakoman172ef272009-02-02 06:27:49 +0000124#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
125
126#include <linux/smsc911x.h>
127
128static struct resource overo_smsc911x_resources[] = {
129 {
130 .name = "smsc911x-memory",
131 .flags = IORESOURCE_MEM,
132 },
133 {
134 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
135 },
136};
137
138static struct smsc911x_platform_config overo_smsc911x_config = {
139 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
140 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
141 .flags = SMSC911X_USE_32BIT ,
142 .phy_interface = PHY_INTERFACE_MODE_MII,
143};
144
145static struct platform_device overo_smsc911x_device = {
146 .name = "smsc911x",
147 .id = -1,
148 .num_resources = ARRAY_SIZE(overo_smsc911x_resources),
149 .resource = &overo_smsc911x_resources,
150 .dev = {
151 .platform_data = &overo_smsc911x_config,
152 },
153};
154
155static inline void __init overo_init_smsc911x(void)
156{
157 unsigned long cs_mem_base;
158
159 if (gpmc_cs_request(OVERO_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) {
160 printk(KERN_ERR "Failed request for GPMC mem for smsc911x\n");
161 return;
162 }
163
164 overo_smsc911x_resources[0].start = cs_mem_base + 0x0;
165 overo_smsc911x_resources[0].end = cs_mem_base + 0xff;
166
167 if ((gpio_request(OVERO_SMSC911X_GPIO, "SMSC911X IRQ") == 0) &&
168 (gpio_direction_input(OVERO_SMSC911X_GPIO) == 0)) {
169 gpio_export(OVERO_SMSC911X_GPIO, 0);
170 } else {
171 printk(KERN_ERR "could not obtain gpio for SMSC911X IRQ\n");
172 return;
173 }
174
175 overo_smsc911x_resources[1].start = OMAP_GPIO_IRQ(OVERO_SMSC911X_GPIO);
176 overo_smsc911x_resources[1].end = 0;
177
178 platform_device_register(&overo_smsc911x_device);
179}
180
181#else
182static inline void __init overo_init_smsc911x(void) { return; }
183#endif
184
Steve Sakomaneba26452008-10-09 17:51:43 +0300185static struct mtd_partition overo_nand_partitions[] = {
186 {
187 .name = "xloader",
188 .offset = 0, /* Offset = 0x00000 */
189 .size = 4 * NAND_BLOCK_SIZE,
190 .mask_flags = MTD_WRITEABLE
191 },
192 {
193 .name = "uboot",
194 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
195 .size = 14 * NAND_BLOCK_SIZE,
196 },
197 {
198 .name = "uboot environment",
199 .offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */
200 .size = 2 * NAND_BLOCK_SIZE,
201 },
202 {
203 .name = "linux",
204 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
205 .size = 32 * NAND_BLOCK_SIZE,
206 },
207 {
208 .name = "rootfs",
209 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
210 .size = MTDPART_SIZ_FULL,
211 },
212};
213
214static struct omap_nand_platform_data overo_nand_data = {
215 .parts = overo_nand_partitions,
216 .nr_parts = ARRAY_SIZE(overo_nand_partitions),
217 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
218};
219
220static struct resource overo_nand_resource = {
221 .flags = IORESOURCE_MEM,
222};
223
224static struct platform_device overo_nand_device = {
225 .name = "omap2-nand",
226 .id = -1,
227 .dev = {
228 .platform_data = &overo_nand_data,
229 },
230 .num_resources = 1,
231 .resource = &overo_nand_resource,
232};
233
234
235static void __init overo_flash_init(void)
236{
237 u8 cs = 0;
238 u8 nandcs = GPMC_CS_NUM + 1;
239
240 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
241
242 /* find out the chip-select on which NAND exists */
243 while (cs < GPMC_CS_NUM) {
244 u32 ret = 0;
245 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
246
247 if ((ret & 0xC00) == 0x800) {
248 printk(KERN_INFO "Found NAND on CS%d\n", cs);
249 if (nandcs > GPMC_CS_NUM)
250 nandcs = cs;
251 }
252 cs++;
253 }
254
255 if (nandcs > GPMC_CS_NUM) {
256 printk(KERN_INFO "NAND: Unable to find configuration "
257 "in GPMC\n ");
258 return;
259 }
260
261 if (nandcs < GPMC_CS_NUM) {
262 overo_nand_data.cs = nandcs;
263 overo_nand_data.gpmc_cs_baseaddr = (void *)
264 (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
265 overo_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
266
267 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
268 if (platform_device_register(&overo_nand_device) < 0)
269 printk(KERN_ERR "Unable to register NAND device\n");
270 }
271}
272static struct omap_uart_config overo_uart_config __initdata = {
273 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
274};
275
David Brownellbb3b9d82009-05-28 14:04:03 -0700276static 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
294static struct regulator_consumer_supply overo_vmmc1_supply = {
295 .supply = "vmmc",
296};
297
298static 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
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800308static 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,
David Brownellbb3b9d82009-05-28 14:04:03 -0700312 .setup = overo_twl_gpio_setup,
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800313};
314
David Brownellbb3b9d82009-05-28 14:04:03 -0700315static struct twl4030_usb_data overo_usb_data = {
316 .usb_mode = T2_USB_MODE_ULPI,
317};
318
319static 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,
331};
332
333/* mmc2 (WLAN) and Bluetooth don't use twl4030 regulators */
334
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800335static struct twl4030_platform_data overo_twldata = {
336 .irq_base = TWL4030_IRQ_BASE,
337 .irq_end = TWL4030_IRQ_END,
338 .gpio = &overo_gpio_data,
David Brownellbb3b9d82009-05-28 14:04:03 -0700339 .usb = &overo_usb_data,
340 .vmmc1 = &overo_vmmc1,
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800341};
342
343static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
344 {
David Brownellbb3b9d82009-05-28 14:04:03 -0700345 I2C_BOARD_INFO("tps65950", 0x48),
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800346 .flags = I2C_CLIENT_WAKE,
347 .irq = INT_34XX_SYS_NIRQ,
348 .platform_data = &overo_twldata,
349 },
350};
351
Steve Sakomaneba26452008-10-09 17:51:43 +0300352static int __init overo_i2c_init(void)
353{
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800354 omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo,
355 ARRAY_SIZE(overo_i2c_boardinfo));
Steve Sakomaneba26452008-10-09 17:51:43 +0300356 /* i2c2 pins are used for gpio */
357 omap_register_i2c_bus(3, 400, NULL, 0);
358 return 0;
359}
360
361static void __init overo_init_irq(void)
362{
Paul Walmsley2e12bd72009-05-28 14:03:59 -0700363 omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
Steve Sakomaneba26452008-10-09 17:51:43 +0300364 omap_init_irq();
365 omap_gpio_init();
366}
367
368static struct platform_device overo_lcd_device = {
369 .name = "overo_lcd",
370 .id = -1,
371};
372
373static struct omap_lcd_config overo_lcd_config __initdata = {
374 .ctrl_name = "internal",
375};
376
377static struct omap_board_config_kernel overo_config[] __initdata = {
378 { OMAP_TAG_UART, &overo_uart_config },
379 { OMAP_TAG_LCD, &overo_lcd_config },
380};
381
382static struct platform_device *overo_devices[] __initdata = {
383 &overo_lcd_device,
384};
385
386static void __init overo_init(void)
387{
388 overo_i2c_init();
389 platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices));
390 omap_board_config = overo_config;
391 omap_board_config_size = ARRAY_SIZE(overo_config);
392 omap_serial_init();
Steve Sakomaneba26452008-10-09 17:51:43 +0300393 overo_flash_init();
Felipe Balbi18cb7ac2009-03-23 18:34:06 -0700394 usb_musb_init();
Steve Sakomanc6a81312009-03-23 18:38:16 -0700395 overo_ads7846_init();
Steve Sakoman172ef272009-02-02 06:27:49 +0000396 overo_init_smsc911x();
Steve Sakomaneba26452008-10-09 17:51:43 +0300397
398 if ((gpio_request(OVERO_GPIO_W2W_NRESET,
399 "OVERO_GPIO_W2W_NRESET") == 0) &&
400 (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) {
401 gpio_export(OVERO_GPIO_W2W_NRESET, 0);
402 gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);
403 udelay(10);
404 gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
405 } else {
406 printk(KERN_ERR "could not obtain gpio for "
407 "OVERO_GPIO_W2W_NRESET\n");
408 }
409
410 if ((gpio_request(OVERO_GPIO_BT_XGATE, "OVERO_GPIO_BT_XGATE") == 0) &&
411 (gpio_direction_output(OVERO_GPIO_BT_XGATE, 0) == 0))
412 gpio_export(OVERO_GPIO_BT_XGATE, 0);
413 else
414 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
415
416 if ((gpio_request(OVERO_GPIO_BT_NRESET, "OVERO_GPIO_BT_NRESET") == 0) &&
417 (gpio_direction_output(OVERO_GPIO_BT_NRESET, 1) == 0)) {
418 gpio_export(OVERO_GPIO_BT_NRESET, 0);
419 gpio_set_value(OVERO_GPIO_BT_NRESET, 0);
420 mdelay(6);
421 gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
422 } else {
423 printk(KERN_ERR "could not obtain gpio for "
424 "OVERO_GPIO_BT_NRESET\n");
425 }
426
427 if ((gpio_request(OVERO_GPIO_USBH_CPEN, "OVERO_GPIO_USBH_CPEN") == 0) &&
428 (gpio_direction_output(OVERO_GPIO_USBH_CPEN, 1) == 0))
429 gpio_export(OVERO_GPIO_USBH_CPEN, 0);
430 else
431 printk(KERN_ERR "could not obtain gpio for "
432 "OVERO_GPIO_USBH_CPEN\n");
433
434 if ((gpio_request(OVERO_GPIO_USBH_NRESET,
435 "OVERO_GPIO_USBH_NRESET") == 0) &&
436 (gpio_direction_output(OVERO_GPIO_USBH_NRESET, 1) == 0))
437 gpio_export(OVERO_GPIO_USBH_NRESET, 0);
438 else
439 printk(KERN_ERR "could not obtain gpio for "
440 "OVERO_GPIO_USBH_NRESET\n");
441}
442
443static void __init overo_map_io(void)
444{
445 omap2_set_globals_343x();
446 omap2_map_common_io();
447}
448
449MACHINE_START(OVERO, "Gumstix Overo")
450 .phys_io = 0x48000000,
451 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
452 .boot_params = 0x80000100,
453 .map_io = overo_map_io,
454 .init_irq = overo_init_irq,
455 .init_machine = overo_init,
456 .timer = &omap_timer,
457MACHINE_END