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