blob: 6bce23004aa4ba0f1051126663f27ccd43447b18 [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>
Jean Pihet9fb97412009-07-24 19:43:25 -060047#include <mach/mux.h>
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070048#include <mach/usb.h>
Steve Sakomaneba26452008-10-09 17:51:43 +030049
Paul Walmsley2e12bd72009-05-28 14:03:59 -070050#include "sdram-micron-mt46h32m32lf-6.h"
Tony Lindgren90c62bf2008-12-10 17:37:17 -080051#include "mmc-twl4030.h"
52
Tony Lindgren0d4d9ab2009-03-23 18:07:38 -070053#define OVERO_GPIO_BT_XGATE 15
54#define OVERO_GPIO_W2W_NRESET 16
Kevin Hilman6fd210a2009-07-20 09:09:23 -070055#define OVERO_GPIO_PENDOWN 114
Tony Lindgren0d4d9ab2009-03-23 18:07:38 -070056#define OVERO_GPIO_BT_NRESET 164
57#define OVERO_GPIO_USBH_CPEN 168
58#define OVERO_GPIO_USBH_NRESET 183
59
Steve Sakomaneba26452008-10-09 17:51:43 +030060#define NAND_BLOCK_SIZE SZ_128K
61#define GPMC_CS0_BASE 0x60
62#define GPMC_CS_SIZE 0x30
63
Steve Sakoman172ef272009-02-02 06:27:49 +000064#define OVERO_SMSC911X_CS 5
65#define OVERO_SMSC911X_GPIO 176
66
Steve Sakomanc6a81312009-03-23 18:38:16 -070067#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
68 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
69
70#include <mach/mcspi.h>
71#include <linux/spi/spi.h>
72#include <linux/spi/ads7846.h>
73
74static struct omap2_mcspi_device_config ads7846_mcspi_config = {
75 .turbo_mode = 0,
76 .single_channel = 1, /* 0: slave, 1: master */
77};
78
79static int ads7846_get_pendown_state(void)
80{
81 return !gpio_get_value(OVERO_GPIO_PENDOWN);
82}
83
84static 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,
94};
95
96static struct spi_board_info overo_spi_board_info[] __initdata = {
97 {
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,
105 }
106};
107
108static void __init overo_ads7846_init(void)
109{
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;
116 }
117
118 spi_register_board_info(overo_spi_board_info,
119 ARRAY_SIZE(overo_spi_board_info));
120}
121
122#else
123static inline void __init overo_ads7846_init(void) { return; }
124#endif
125
Steve Sakoman172ef272009-02-02 06:27:49 +0000126#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
127
128#include <linux/smsc911x.h>
129
130static struct resource overo_smsc911x_resources[] = {
131 {
132 .name = "smsc911x-memory",
133 .flags = IORESOURCE_MEM,
134 },
135 {
136 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
137 },
138};
139
140static 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,
145};
146
147static struct platform_device overo_smsc911x_device = {
148 .name = "smsc911x",
149 .id = -1,
150 .num_resources = ARRAY_SIZE(overo_smsc911x_resources),
Sergio Aguirre50329022009-08-10 14:49:50 +0300151 .resource = overo_smsc911x_resources,
Steve Sakoman172ef272009-02-02 06:27:49 +0000152 .dev = {
153 .platform_data = &overo_smsc911x_config,
154 },
155};
156
157static inline void __init overo_init_smsc911x(void)
158{
159 unsigned long cs_mem_base;
160
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;
164 }
165
166 overo_smsc911x_resources[0].start = cs_mem_base + 0x0;
167 overo_smsc911x_resources[0].end = cs_mem_base + 0xff;
168
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;
175 }
176
177 overo_smsc911x_resources[1].start = OMAP_GPIO_IRQ(OVERO_SMSC911X_GPIO);
178 overo_smsc911x_resources[1].end = 0;
179
180 platform_device_register(&overo_smsc911x_device);
181}
182
183#else
184static inline void __init overo_init_smsc911x(void) { return; }
185#endif
186
Steve Sakomaneba26452008-10-09 17:51:43 +0300187static struct mtd_partition overo_nand_partitions[] = {
188 {
189 .name = "xloader",
190 .offset = 0, /* Offset = 0x00000 */
191 .size = 4 * NAND_BLOCK_SIZE,
192 .mask_flags = MTD_WRITEABLE
193 },
194 {
195 .name = "uboot",
196 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
197 .size = 14 * NAND_BLOCK_SIZE,
198 },
199 {
200 .name = "uboot environment",
201 .offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */
202 .size = 2 * NAND_BLOCK_SIZE,
203 },
204 {
205 .name = "linux",
206 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
207 .size = 32 * NAND_BLOCK_SIZE,
208 },
209 {
210 .name = "rootfs",
211 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
212 .size = MTDPART_SIZ_FULL,
213 },
214};
215
216static 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 */
220};
221
222static struct resource overo_nand_resource = {
223 .flags = IORESOURCE_MEM,
224};
225
226static struct platform_device overo_nand_device = {
227 .name = "omap2-nand",
228 .id = -1,
229 .dev = {
230 .platform_data = &overo_nand_data,
231 },
232 .num_resources = 1,
233 .resource = &overo_nand_resource,
234};
235
236
237static void __init overo_flash_init(void)
238{
239 u8 cs = 0;
240 u8 nandcs = GPMC_CS_NUM + 1;
241
242 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
243
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);
248
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;
253 }
254 cs++;
255 }
256
257 if (nandcs > GPMC_CS_NUM) {
258 printk(KERN_INFO "NAND: Unable to find configuration "
259 "in GPMC\n ");
260 return;
261 }
262
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);
268
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");
272 }
273}
274static struct omap_uart_config overo_uart_config __initdata = {
275 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
276};
277
David Brownellbb3b9d82009-05-28 14:04:03 -0700278static struct twl4030_hsmmc_info mmc[] = {
279 {
280 .mmc = 1,
281 .wires = 4,
282 .gpio_cd = -EINVAL,
283 .gpio_wp = -EINVAL,
284 },
285 {
286 .mmc = 2,
287 .wires = 4,
288 .gpio_cd = -EINVAL,
289 .gpio_wp = -EINVAL,
290 .transceiver = true,
291 .ocr_mask = 0x00100000, /* 3.3V */
292 },
293 {} /* Terminator */
294};
295
296static struct regulator_consumer_supply overo_vmmc1_supply = {
297 .supply = "vmmc",
298};
299
300static int overo_twl_gpio_setup(struct device *dev,
301 unsigned gpio, unsigned ngpio)
302{
303 twl4030_mmc_init(mmc);
304
305 overo_vmmc1_supply.dev = mmc[0].dev;
306
307 return 0;
308}
309
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800310static struct twl4030_gpio_platform_data overo_gpio_data = {
311 .gpio_base = OMAP_MAX_GPIO_LINES,
312 .irq_base = TWL4030_GPIO_IRQ_BASE,
313 .irq_end = TWL4030_GPIO_IRQ_END,
David Brownellbb3b9d82009-05-28 14:04:03 -0700314 .setup = overo_twl_gpio_setup,
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800315};
316
David Brownellbb3b9d82009-05-28 14:04:03 -0700317static struct twl4030_usb_data overo_usb_data = {
318 .usb_mode = T2_USB_MODE_ULPI,
319};
320
321static struct regulator_init_data overo_vmmc1 = {
322 .constraints = {
323 .min_uV = 1850000,
324 .max_uV = 3150000,
325 .valid_modes_mask = REGULATOR_MODE_NORMAL
326 | REGULATOR_MODE_STANDBY,
327 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
328 | REGULATOR_CHANGE_MODE
329 | REGULATOR_CHANGE_STATUS,
330 },
331 .num_consumer_supplies = 1,
332 .consumer_supplies = &overo_vmmc1_supply,
333};
334
335/* mmc2 (WLAN) and Bluetooth don't use twl4030 regulators */
336
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800337static struct twl4030_platform_data overo_twldata = {
338 .irq_base = TWL4030_IRQ_BASE,
339 .irq_end = TWL4030_IRQ_END,
340 .gpio = &overo_gpio_data,
David Brownellbb3b9d82009-05-28 14:04:03 -0700341 .usb = &overo_usb_data,
342 .vmmc1 = &overo_vmmc1,
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800343};
344
345static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
346 {
David Brownellbb3b9d82009-05-28 14:04:03 -0700347 I2C_BOARD_INFO("tps65950", 0x48),
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800348 .flags = I2C_CLIENT_WAKE,
349 .irq = INT_34XX_SYS_NIRQ,
350 .platform_data = &overo_twldata,
351 },
352};
353
Steve Sakomaneba26452008-10-09 17:51:43 +0300354static int __init overo_i2c_init(void)
355{
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800356 omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo,
357 ARRAY_SIZE(overo_i2c_boardinfo));
Steve Sakomaneba26452008-10-09 17:51:43 +0300358 /* i2c2 pins are used for gpio */
359 omap_register_i2c_bus(3, 400, NULL, 0);
360 return 0;
361}
362
363static void __init overo_init_irq(void)
364{
Jean Pihet58cda882009-07-24 19:43:25 -0600365 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
366 mt46h32m32lf6_sdrc_params);
Steve Sakomaneba26452008-10-09 17:51:43 +0300367 omap_init_irq();
368 omap_gpio_init();
369}
370
371static struct platform_device overo_lcd_device = {
372 .name = "overo_lcd",
373 .id = -1,
374};
375
376static struct omap_lcd_config overo_lcd_config __initdata = {
377 .ctrl_name = "internal",
378};
379
380static struct omap_board_config_kernel overo_config[] __initdata = {
381 { OMAP_TAG_UART, &overo_uart_config },
382 { OMAP_TAG_LCD, &overo_lcd_config },
383};
384
385static struct platform_device *overo_devices[] __initdata = {
386 &overo_lcd_device,
387};
388
389static void __init overo_init(void)
390{
391 overo_i2c_init();
392 platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices));
393 omap_board_config = overo_config;
394 omap_board_config_size = ARRAY_SIZE(overo_config);
395 omap_serial_init();
Steve Sakomaneba26452008-10-09 17:51:43 +0300396 overo_flash_init();
Felipe Balbi18cb7ac2009-03-23 18:34:06 -0700397 usb_musb_init();
Steve Sakomanc6a81312009-03-23 18:38:16 -0700398 overo_ads7846_init();
Steve Sakoman172ef272009-02-02 06:27:49 +0000399 overo_init_smsc911x();
Steve Sakomaneba26452008-10-09 17:51:43 +0300400
Jean Pihet9fb97412009-07-24 19:43:25 -0600401 /* Ensure SDRC pins are mux'd for self-refresh */
402 omap_cfg_reg(H16_34XX_SDRC_CKE0);
403 omap_cfg_reg(H17_34XX_SDRC_CKE1);
404
Steve Sakomaneba26452008-10-09 17:51:43 +0300405 if ((gpio_request(OVERO_GPIO_W2W_NRESET,
406 "OVERO_GPIO_W2W_NRESET") == 0) &&
407 (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) {
408 gpio_export(OVERO_GPIO_W2W_NRESET, 0);
409 gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);
410 udelay(10);
411 gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
412 } else {
413 printk(KERN_ERR "could not obtain gpio for "
414 "OVERO_GPIO_W2W_NRESET\n");
415 }
416
417 if ((gpio_request(OVERO_GPIO_BT_XGATE, "OVERO_GPIO_BT_XGATE") == 0) &&
418 (gpio_direction_output(OVERO_GPIO_BT_XGATE, 0) == 0))
419 gpio_export(OVERO_GPIO_BT_XGATE, 0);
420 else
421 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
422
423 if ((gpio_request(OVERO_GPIO_BT_NRESET, "OVERO_GPIO_BT_NRESET") == 0) &&
424 (gpio_direction_output(OVERO_GPIO_BT_NRESET, 1) == 0)) {
425 gpio_export(OVERO_GPIO_BT_NRESET, 0);
426 gpio_set_value(OVERO_GPIO_BT_NRESET, 0);
427 mdelay(6);
428 gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
429 } else {
430 printk(KERN_ERR "could not obtain gpio for "
431 "OVERO_GPIO_BT_NRESET\n");
432 }
433
434 if ((gpio_request(OVERO_GPIO_USBH_CPEN, "OVERO_GPIO_USBH_CPEN") == 0) &&
435 (gpio_direction_output(OVERO_GPIO_USBH_CPEN, 1) == 0))
436 gpio_export(OVERO_GPIO_USBH_CPEN, 0);
437 else
438 printk(KERN_ERR "could not obtain gpio for "
439 "OVERO_GPIO_USBH_CPEN\n");
440
441 if ((gpio_request(OVERO_GPIO_USBH_NRESET,
442 "OVERO_GPIO_USBH_NRESET") == 0) &&
443 (gpio_direction_output(OVERO_GPIO_USBH_NRESET, 1) == 0))
444 gpio_export(OVERO_GPIO_USBH_NRESET, 0);
445 else
446 printk(KERN_ERR "could not obtain gpio for "
447 "OVERO_GPIO_USBH_NRESET\n");
448}
449
450static void __init overo_map_io(void)
451{
452 omap2_set_globals_343x();
453 omap2_map_common_io();
454}
455
456MACHINE_START(OVERO, "Gumstix Overo")
457 .phys_io = 0x48000000,
458 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
459 .boot_params = 0x80000100,
460 .map_io = overo_map_io,
461 .init_irq = overo_init_irq,
462 .init_machine = overo_init,
463 .timer = &omap_timer,
464MACHINE_END