blob: b1f23bea863fec71ff972b5c9aec8952222f9fc4 [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>
Steve Sakomaneba26452008-10-09 17:51:43 +030030
31#include <linux/mtd/mtd.h>
32#include <linux/mtd/nand.h>
33#include <linux/mtd/partitions.h>
34
35#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
37#include <asm/mach/flash.h>
38#include <asm/mach/map.h>
39
Steve Sakomaneba26452008-10-09 17:51:43 +030040#include <mach/board.h>
41#include <mach/common.h>
42#include <mach/gpio.h>
43#include <mach/gpmc.h>
44#include <mach/hardware.h>
45#include <mach/nand.h>
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070046#include <mach/usb.h>
Steve Sakomaneba26452008-10-09 17:51:43 +030047
Tony Lindgren90c62bf2008-12-10 17:37:17 -080048#include "mmc-twl4030.h"
49
Tony Lindgren0d4d9ab2009-03-23 18:07:38 -070050#define OVERO_GPIO_BT_XGATE 15
51#define OVERO_GPIO_W2W_NRESET 16
52#define OVERO_GPIO_BT_NRESET 164
53#define OVERO_GPIO_USBH_CPEN 168
54#define OVERO_GPIO_USBH_NRESET 183
55
Steve Sakomaneba26452008-10-09 17:51:43 +030056#define NAND_BLOCK_SIZE SZ_128K
57#define GPMC_CS0_BASE 0x60
58#define GPMC_CS_SIZE 0x30
59
Steve Sakoman172ef272009-02-02 06:27:49 +000060#define OVERO_SMSC911X_CS 5
61#define OVERO_SMSC911X_GPIO 176
62
Steve Sakomanc6a81312009-03-23 18:38:16 -070063#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
64 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
65
66#include <mach/mcspi.h>
67#include <linux/spi/spi.h>
68#include <linux/spi/ads7846.h>
69
70static struct omap2_mcspi_device_config ads7846_mcspi_config = {
71 .turbo_mode = 0,
72 .single_channel = 1, /* 0: slave, 1: master */
73};
74
75static int ads7846_get_pendown_state(void)
76{
77 return !gpio_get_value(OVERO_GPIO_PENDOWN);
78}
79
80static struct ads7846_platform_data ads7846_config = {
81 .x_max = 0x0fff,
82 .y_max = 0x0fff,
83 .x_plate_ohms = 180,
84 .pressure_max = 255,
85 .debounce_max = 10,
86 .debounce_tol = 3,
87 .debounce_rep = 1,
88 .get_pendown_state = ads7846_get_pendown_state,
89 .keep_vref_on = 1,
90};
91
92static struct spi_board_info overo_spi_board_info[] __initdata = {
93 {
94 .modalias = "ads7846",
95 .bus_num = 1,
96 .chip_select = 0,
97 .max_speed_hz = 1500000,
98 .controller_data = &ads7846_mcspi_config,
99 .irq = OMAP_GPIO_IRQ(OVERO_GPIO_PENDOWN),
100 .platform_data = &ads7846_config,
101 }
102};
103
104static void __init overo_ads7846_init(void)
105{
106 if ((gpio_request(OVERO_GPIO_PENDOWN, "ADS7846_PENDOWN") == 0) &&
107 (gpio_direction_input(OVERO_GPIO_PENDOWN) == 0)) {
108 gpio_export(OVERO_GPIO_PENDOWN, 0);
109 } else {
110 printk(KERN_ERR "could not obtain gpio for ADS7846_PENDOWN\n");
111 return;
112 }
113
114 spi_register_board_info(overo_spi_board_info,
115 ARRAY_SIZE(overo_spi_board_info));
116}
117
118#else
119static inline void __init overo_ads7846_init(void) { return; }
120#endif
121
Steve Sakoman172ef272009-02-02 06:27:49 +0000122#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
123
124#include <linux/smsc911x.h>
125
126static struct resource overo_smsc911x_resources[] = {
127 {
128 .name = "smsc911x-memory",
129 .flags = IORESOURCE_MEM,
130 },
131 {
132 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
133 },
134};
135
136static struct smsc911x_platform_config overo_smsc911x_config = {
137 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
138 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
139 .flags = SMSC911X_USE_32BIT ,
140 .phy_interface = PHY_INTERFACE_MODE_MII,
141};
142
143static struct platform_device overo_smsc911x_device = {
144 .name = "smsc911x",
145 .id = -1,
146 .num_resources = ARRAY_SIZE(overo_smsc911x_resources),
147 .resource = &overo_smsc911x_resources,
148 .dev = {
149 .platform_data = &overo_smsc911x_config,
150 },
151};
152
153static inline void __init overo_init_smsc911x(void)
154{
155 unsigned long cs_mem_base;
156
157 if (gpmc_cs_request(OVERO_SMSC911X_CS, SZ_16M, &cs_mem_base) < 0) {
158 printk(KERN_ERR "Failed request for GPMC mem for smsc911x\n");
159 return;
160 }
161
162 overo_smsc911x_resources[0].start = cs_mem_base + 0x0;
163 overo_smsc911x_resources[0].end = cs_mem_base + 0xff;
164
165 if ((gpio_request(OVERO_SMSC911X_GPIO, "SMSC911X IRQ") == 0) &&
166 (gpio_direction_input(OVERO_SMSC911X_GPIO) == 0)) {
167 gpio_export(OVERO_SMSC911X_GPIO, 0);
168 } else {
169 printk(KERN_ERR "could not obtain gpio for SMSC911X IRQ\n");
170 return;
171 }
172
173 overo_smsc911x_resources[1].start = OMAP_GPIO_IRQ(OVERO_SMSC911X_GPIO);
174 overo_smsc911x_resources[1].end = 0;
175
176 platform_device_register(&overo_smsc911x_device);
177}
178
179#else
180static inline void __init overo_init_smsc911x(void) { return; }
181#endif
182
Steve Sakomaneba26452008-10-09 17:51:43 +0300183static struct mtd_partition overo_nand_partitions[] = {
184 {
185 .name = "xloader",
186 .offset = 0, /* Offset = 0x00000 */
187 .size = 4 * NAND_BLOCK_SIZE,
188 .mask_flags = MTD_WRITEABLE
189 },
190 {
191 .name = "uboot",
192 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
193 .size = 14 * NAND_BLOCK_SIZE,
194 },
195 {
196 .name = "uboot environment",
197 .offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */
198 .size = 2 * NAND_BLOCK_SIZE,
199 },
200 {
201 .name = "linux",
202 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
203 .size = 32 * NAND_BLOCK_SIZE,
204 },
205 {
206 .name = "rootfs",
207 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
208 .size = MTDPART_SIZ_FULL,
209 },
210};
211
212static struct omap_nand_platform_data overo_nand_data = {
213 .parts = overo_nand_partitions,
214 .nr_parts = ARRAY_SIZE(overo_nand_partitions),
215 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
216};
217
218static struct resource overo_nand_resource = {
219 .flags = IORESOURCE_MEM,
220};
221
222static struct platform_device overo_nand_device = {
223 .name = "omap2-nand",
224 .id = -1,
225 .dev = {
226 .platform_data = &overo_nand_data,
227 },
228 .num_resources = 1,
229 .resource = &overo_nand_resource,
230};
231
232
233static void __init overo_flash_init(void)
234{
235 u8 cs = 0;
236 u8 nandcs = GPMC_CS_NUM + 1;
237
238 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
239
240 /* find out the chip-select on which NAND exists */
241 while (cs < GPMC_CS_NUM) {
242 u32 ret = 0;
243 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
244
245 if ((ret & 0xC00) == 0x800) {
246 printk(KERN_INFO "Found NAND on CS%d\n", cs);
247 if (nandcs > GPMC_CS_NUM)
248 nandcs = cs;
249 }
250 cs++;
251 }
252
253 if (nandcs > GPMC_CS_NUM) {
254 printk(KERN_INFO "NAND: Unable to find configuration "
255 "in GPMC\n ");
256 return;
257 }
258
259 if (nandcs < GPMC_CS_NUM) {
260 overo_nand_data.cs = nandcs;
261 overo_nand_data.gpmc_cs_baseaddr = (void *)
262 (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
263 overo_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
264
265 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
266 if (platform_device_register(&overo_nand_device) < 0)
267 printk(KERN_ERR "Unable to register NAND device\n");
268 }
269}
270static struct omap_uart_config overo_uart_config __initdata = {
271 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
272};
273
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800274static struct twl4030_gpio_platform_data overo_gpio_data = {
275 .gpio_base = OMAP_MAX_GPIO_LINES,
276 .irq_base = TWL4030_GPIO_IRQ_BASE,
277 .irq_end = TWL4030_GPIO_IRQ_END,
278};
279
280static struct twl4030_platform_data overo_twldata = {
281 .irq_base = TWL4030_IRQ_BASE,
282 .irq_end = TWL4030_IRQ_END,
283 .gpio = &overo_gpio_data,
284};
285
286static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
287 {
288 I2C_BOARD_INFO("twl4030", 0x48),
289 .flags = I2C_CLIENT_WAKE,
290 .irq = INT_34XX_SYS_NIRQ,
291 .platform_data = &overo_twldata,
292 },
293};
294
Steve Sakomaneba26452008-10-09 17:51:43 +0300295static int __init overo_i2c_init(void)
296{
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800297 omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo,
298 ARRAY_SIZE(overo_i2c_boardinfo));
Steve Sakomaneba26452008-10-09 17:51:43 +0300299 /* i2c2 pins are used for gpio */
300 omap_register_i2c_bus(3, 400, NULL, 0);
301 return 0;
302}
303
304static void __init overo_init_irq(void)
305{
Tony Lindgren2f3ec502009-03-16 15:28:42 -0700306 omap2_init_common_hw(NULL);
Steve Sakomaneba26452008-10-09 17:51:43 +0300307 omap_init_irq();
308 omap_gpio_init();
309}
310
311static struct platform_device overo_lcd_device = {
312 .name = "overo_lcd",
313 .id = -1,
314};
315
316static struct omap_lcd_config overo_lcd_config __initdata = {
317 .ctrl_name = "internal",
318};
319
320static struct omap_board_config_kernel overo_config[] __initdata = {
321 { OMAP_TAG_UART, &overo_uart_config },
322 { OMAP_TAG_LCD, &overo_lcd_config },
323};
324
325static struct platform_device *overo_devices[] __initdata = {
326 &overo_lcd_device,
327};
328
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800329static struct twl4030_hsmmc_info mmc[] __initdata = {
330 {
331 .mmc = 1,
332 .wires = 4,
333 .gpio_cd = -EINVAL,
334 .gpio_wp = -EINVAL,
335 },
336 {
337 .mmc = 2,
338 .wires = 4,
339 .gpio_cd = -EINVAL,
340 .gpio_wp = -EINVAL,
David Brownell0329c372009-03-23 18:23:47 -0700341 .transceiver = true,
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800342 },
343 {} /* Terminator */
344};
345
Steve Sakomaneba26452008-10-09 17:51:43 +0300346static void __init overo_init(void)
347{
348 overo_i2c_init();
349 platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices));
350 omap_board_config = overo_config;
351 omap_board_config_size = ARRAY_SIZE(overo_config);
352 omap_serial_init();
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800353 twl4030_mmc_init(mmc);
Steve Sakomaneba26452008-10-09 17:51:43 +0300354 overo_flash_init();
Felipe Balbi18cb7ac2009-03-23 18:34:06 -0700355 usb_musb_init();
Steve Sakomanc6a81312009-03-23 18:38:16 -0700356 overo_ads7846_init();
Steve Sakoman172ef272009-02-02 06:27:49 +0000357 overo_init_smsc911x();
Steve Sakomaneba26452008-10-09 17:51:43 +0300358
359 if ((gpio_request(OVERO_GPIO_W2W_NRESET,
360 "OVERO_GPIO_W2W_NRESET") == 0) &&
361 (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) {
362 gpio_export(OVERO_GPIO_W2W_NRESET, 0);
363 gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);
364 udelay(10);
365 gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
366 } else {
367 printk(KERN_ERR "could not obtain gpio for "
368 "OVERO_GPIO_W2W_NRESET\n");
369 }
370
371 if ((gpio_request(OVERO_GPIO_BT_XGATE, "OVERO_GPIO_BT_XGATE") == 0) &&
372 (gpio_direction_output(OVERO_GPIO_BT_XGATE, 0) == 0))
373 gpio_export(OVERO_GPIO_BT_XGATE, 0);
374 else
375 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
376
377 if ((gpio_request(OVERO_GPIO_BT_NRESET, "OVERO_GPIO_BT_NRESET") == 0) &&
378 (gpio_direction_output(OVERO_GPIO_BT_NRESET, 1) == 0)) {
379 gpio_export(OVERO_GPIO_BT_NRESET, 0);
380 gpio_set_value(OVERO_GPIO_BT_NRESET, 0);
381 mdelay(6);
382 gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
383 } else {
384 printk(KERN_ERR "could not obtain gpio for "
385 "OVERO_GPIO_BT_NRESET\n");
386 }
387
388 if ((gpio_request(OVERO_GPIO_USBH_CPEN, "OVERO_GPIO_USBH_CPEN") == 0) &&
389 (gpio_direction_output(OVERO_GPIO_USBH_CPEN, 1) == 0))
390 gpio_export(OVERO_GPIO_USBH_CPEN, 0);
391 else
392 printk(KERN_ERR "could not obtain gpio for "
393 "OVERO_GPIO_USBH_CPEN\n");
394
395 if ((gpio_request(OVERO_GPIO_USBH_NRESET,
396 "OVERO_GPIO_USBH_NRESET") == 0) &&
397 (gpio_direction_output(OVERO_GPIO_USBH_NRESET, 1) == 0))
398 gpio_export(OVERO_GPIO_USBH_NRESET, 0);
399 else
400 printk(KERN_ERR "could not obtain gpio for "
401 "OVERO_GPIO_USBH_NRESET\n");
402}
403
404static void __init overo_map_io(void)
405{
406 omap2_set_globals_343x();
407 omap2_map_common_io();
408}
409
410MACHINE_START(OVERO, "Gumstix Overo")
411 .phys_io = 0x48000000,
412 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
413 .boot_params = 0x80000100,
414 .map_io = overo_map_io,
415 .init_irq = overo_init_irq,
416 .init_machine = overo_init,
417 .timer = &omap_timer,
418MACHINE_END