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
22 #include <linux/clk.h>
23 #include <linux/delay.h>
24 #include <linux/err.h>
25 #include <linux/init.h>
27 #include <linux/kernel.h>
28 #include <linux/platform_device.h>
29 #include <linux/i2c/twl4030.h>
31 #include <linux/mtd/mtd.h>
32 #include <linux/mtd/nand.h>
33 #include <linux/mtd/partitions.h>
35 #include <asm/mach-types.h>
36 #include <asm/mach/arch.h>
37 #include <asm/mach/flash.h>
38 #include <asm/mach/map.h>
40 #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>
48 #include "mmc-twl4030.h"
50 #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
56 #define NAND_BLOCK_SIZE SZ_128K
57 #define GPMC_CS0_BASE 0x60
58 #define GPMC_CS_SIZE 0x30
60 #define OVERO_SMSC911X_CS 5
61 #define OVERO_SMSC911X_GPIO 176
63 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
64 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
66 #include <mach/mcspi.h>
67 #include <linux/spi/spi.h>
68 #include <linux/spi/ads7846.h>
70 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
72 .single_channel = 1, /* 0: slave, 1: master */
75 static int ads7846_get_pendown_state(void)
77 return !gpio_get_value(OVERO_GPIO_PENDOWN);
80 static struct ads7846_platform_data ads7846_config = {
88 .get_pendown_state = ads7846_get_pendown_state,
92 static struct spi_board_info overo_spi_board_info[] __initdata = {
94 .modalias = "ads7846",
97 .max_speed_hz = 1500000,
98 .controller_data = &ads7846_mcspi_config,
99 .irq = OMAP_GPIO_IRQ(OVERO_GPIO_PENDOWN),
100 .platform_data = &ads7846_config,
104 static void __init overo_ads7846_init(void)
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);
110 printk(KERN_ERR "could not obtain gpio for ADS7846_PENDOWN\n");
114 spi_register_board_info(overo_spi_board_info,
115 ARRAY_SIZE(overo_spi_board_info));
119 static inline void __init overo_ads7846_init(void) { return; }
122 #if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
124 #include <linux/smsc911x.h>
126 static struct resource overo_smsc911x_resources[] = {
128 .name = "smsc911x-memory",
129 .flags = IORESOURCE_MEM,
132 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
136 static 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,
143 static struct platform_device overo_smsc911x_device = {
146 .num_resources = ARRAY_SIZE(overo_smsc911x_resources),
147 .resource = &overo_smsc911x_resources,
149 .platform_data = &overo_smsc911x_config,
153 static inline void __init overo_init_smsc911x(void)
155 unsigned long cs_mem_base;
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");
162 overo_smsc911x_resources[0].start = cs_mem_base + 0x0;
163 overo_smsc911x_resources[0].end = cs_mem_base + 0xff;
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);
169 printk(KERN_ERR "could not obtain gpio for SMSC911X IRQ\n");
173 overo_smsc911x_resources[1].start = OMAP_GPIO_IRQ(OVERO_SMSC911X_GPIO);
174 overo_smsc911x_resources[1].end = 0;
176 platform_device_register(&overo_smsc911x_device);
180 static inline void __init overo_init_smsc911x(void) { return; }
183 static struct mtd_partition overo_nand_partitions[] = {
186 .offset = 0, /* Offset = 0x00000 */
187 .size = 4 * NAND_BLOCK_SIZE,
188 .mask_flags = MTD_WRITEABLE
192 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
193 .size = 14 * NAND_BLOCK_SIZE,
196 .name = "uboot environment",
197 .offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */
198 .size = 2 * NAND_BLOCK_SIZE,
202 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
203 .size = 32 * NAND_BLOCK_SIZE,
207 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
208 .size = MTDPART_SIZ_FULL,
212 static 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 */
218 static struct resource overo_nand_resource = {
219 .flags = IORESOURCE_MEM,
222 static struct platform_device overo_nand_device = {
223 .name = "omap2-nand",
226 .platform_data = &overo_nand_data,
229 .resource = &overo_nand_resource,
233 static void __init overo_flash_init(void)
236 u8 nandcs = GPMC_CS_NUM + 1;
238 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
240 /* find out the chip-select on which NAND exists */
241 while (cs < GPMC_CS_NUM) {
243 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
245 if ((ret & 0xC00) == 0x800) {
246 printk(KERN_INFO "Found NAND on CS%d\n", cs);
247 if (nandcs > GPMC_CS_NUM)
253 if (nandcs > GPMC_CS_NUM) {
254 printk(KERN_INFO "NAND: Unable to find configuration "
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);
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");
270 static struct omap_uart_config overo_uart_config __initdata = {
271 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
274 static 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,
280 static struct twl4030_platform_data overo_twldata = {
281 .irq_base = TWL4030_IRQ_BASE,
282 .irq_end = TWL4030_IRQ_END,
283 .gpio = &overo_gpio_data,
286 static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
288 I2C_BOARD_INFO("twl4030", 0x48),
289 .flags = I2C_CLIENT_WAKE,
290 .irq = INT_34XX_SYS_NIRQ,
291 .platform_data = &overo_twldata,
295 static int __init overo_i2c_init(void)
297 omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo,
298 ARRAY_SIZE(overo_i2c_boardinfo));
299 /* i2c2 pins are used for gpio */
300 omap_register_i2c_bus(3, 400, NULL, 0);
304 static void __init overo_init_irq(void)
306 omap2_init_common_hw(NULL);
311 static struct platform_device overo_lcd_device = {
316 static struct omap_lcd_config overo_lcd_config __initdata = {
317 .ctrl_name = "internal",
320 static struct omap_board_config_kernel overo_config[] __initdata = {
321 { OMAP_TAG_UART, &overo_uart_config },
322 { OMAP_TAG_LCD, &overo_lcd_config },
325 static struct platform_device *overo_devices[] __initdata = {
329 static struct twl4030_hsmmc_info mmc[] __initdata = {
346 static void __init overo_init(void)
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);
353 twl4030_mmc_init(mmc);
356 overo_ads7846_init();
357 overo_init_smsc911x();
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);
365 gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
367 printk(KERN_ERR "could not obtain gpio for "
368 "OVERO_GPIO_W2W_NRESET\n");
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);
375 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
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);
382 gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
384 printk(KERN_ERR "could not obtain gpio for "
385 "OVERO_GPIO_BT_NRESET\n");
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);
392 printk(KERN_ERR "could not obtain gpio for "
393 "OVERO_GPIO_USBH_CPEN\n");
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);
400 printk(KERN_ERR "could not obtain gpio for "
401 "OVERO_GPIO_USBH_NRESET\n");
404 static void __init overo_map_io(void)
406 omap2_set_globals_343x();
407 omap2_map_common_io();
410 MACHINE_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,