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 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
61 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
63 #include <mach/mcspi.h>
64 #include <linux/spi/spi.h>
65 #include <linux/spi/ads7846.h>
67 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
69 .single_channel = 1, /* 0: slave, 1: master */
72 static int ads7846_get_pendown_state(void)
74 return !gpio_get_value(OVERO_GPIO_PENDOWN);
77 static struct ads7846_platform_data ads7846_config = {
85 .get_pendown_state = ads7846_get_pendown_state,
89 static struct spi_board_info overo_spi_board_info[] __initdata = {
91 .modalias = "ads7846",
94 .max_speed_hz = 1500000,
95 .controller_data = &ads7846_mcspi_config,
96 .irq = OMAP_GPIO_IRQ(OVERO_GPIO_PENDOWN),
97 .platform_data = &ads7846_config,
101 static void __init overo_ads7846_init(void)
103 if ((gpio_request(OVERO_GPIO_PENDOWN, "ADS7846_PENDOWN") == 0) &&
104 (gpio_direction_input(OVERO_GPIO_PENDOWN) == 0)) {
105 gpio_export(OVERO_GPIO_PENDOWN, 0);
107 printk(KERN_ERR "could not obtain gpio for ADS7846_PENDOWN\n");
111 spi_register_board_info(overo_spi_board_info,
112 ARRAY_SIZE(overo_spi_board_info));
116 static inline void __init overo_ads7846_init(void) { return; }
119 static struct mtd_partition overo_nand_partitions[] = {
122 .offset = 0, /* Offset = 0x00000 */
123 .size = 4 * NAND_BLOCK_SIZE,
124 .mask_flags = MTD_WRITEABLE
128 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
129 .size = 14 * NAND_BLOCK_SIZE,
132 .name = "uboot environment",
133 .offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */
134 .size = 2 * NAND_BLOCK_SIZE,
138 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
139 .size = 32 * NAND_BLOCK_SIZE,
143 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
144 .size = MTDPART_SIZ_FULL,
148 static struct omap_nand_platform_data overo_nand_data = {
149 .parts = overo_nand_partitions,
150 .nr_parts = ARRAY_SIZE(overo_nand_partitions),
151 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
154 static struct resource overo_nand_resource = {
155 .flags = IORESOURCE_MEM,
158 static struct platform_device overo_nand_device = {
159 .name = "omap2-nand",
162 .platform_data = &overo_nand_data,
165 .resource = &overo_nand_resource,
169 static void __init overo_flash_init(void)
172 u8 nandcs = GPMC_CS_NUM + 1;
174 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
176 /* find out the chip-select on which NAND exists */
177 while (cs < GPMC_CS_NUM) {
179 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
181 if ((ret & 0xC00) == 0x800) {
182 printk(KERN_INFO "Found NAND on CS%d\n", cs);
183 if (nandcs > GPMC_CS_NUM)
189 if (nandcs > GPMC_CS_NUM) {
190 printk(KERN_INFO "NAND: Unable to find configuration "
195 if (nandcs < GPMC_CS_NUM) {
196 overo_nand_data.cs = nandcs;
197 overo_nand_data.gpmc_cs_baseaddr = (void *)
198 (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
199 overo_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
201 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
202 if (platform_device_register(&overo_nand_device) < 0)
203 printk(KERN_ERR "Unable to register NAND device\n");
206 static struct omap_uart_config overo_uart_config __initdata = {
207 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
210 static struct twl4030_gpio_platform_data overo_gpio_data = {
211 .gpio_base = OMAP_MAX_GPIO_LINES,
212 .irq_base = TWL4030_GPIO_IRQ_BASE,
213 .irq_end = TWL4030_GPIO_IRQ_END,
216 static struct twl4030_platform_data overo_twldata = {
217 .irq_base = TWL4030_IRQ_BASE,
218 .irq_end = TWL4030_IRQ_END,
219 .gpio = &overo_gpio_data,
222 static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
224 I2C_BOARD_INFO("twl4030", 0x48),
225 .flags = I2C_CLIENT_WAKE,
226 .irq = INT_34XX_SYS_NIRQ,
227 .platform_data = &overo_twldata,
231 static int __init overo_i2c_init(void)
233 omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo,
234 ARRAY_SIZE(overo_i2c_boardinfo));
235 /* i2c2 pins are used for gpio */
236 omap_register_i2c_bus(3, 400, NULL, 0);
240 static void __init overo_init_irq(void)
242 omap2_init_common_hw(NULL);
247 static struct platform_device overo_lcd_device = {
252 static struct omap_lcd_config overo_lcd_config __initdata = {
253 .ctrl_name = "internal",
256 static struct omap_board_config_kernel overo_config[] __initdata = {
257 { OMAP_TAG_UART, &overo_uart_config },
258 { OMAP_TAG_LCD, &overo_lcd_config },
261 static struct platform_device *overo_devices[] __initdata = {
265 static struct twl4030_hsmmc_info mmc[] __initdata = {
282 static void __init overo_init(void)
285 platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices));
286 omap_board_config = overo_config;
287 omap_board_config_size = ARRAY_SIZE(overo_config);
289 twl4030_mmc_init(mmc);
292 overo_ads7846_init();
294 if ((gpio_request(OVERO_GPIO_W2W_NRESET,
295 "OVERO_GPIO_W2W_NRESET") == 0) &&
296 (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) {
297 gpio_export(OVERO_GPIO_W2W_NRESET, 0);
298 gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);
300 gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
302 printk(KERN_ERR "could not obtain gpio for "
303 "OVERO_GPIO_W2W_NRESET\n");
306 if ((gpio_request(OVERO_GPIO_BT_XGATE, "OVERO_GPIO_BT_XGATE") == 0) &&
307 (gpio_direction_output(OVERO_GPIO_BT_XGATE, 0) == 0))
308 gpio_export(OVERO_GPIO_BT_XGATE, 0);
310 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
312 if ((gpio_request(OVERO_GPIO_BT_NRESET, "OVERO_GPIO_BT_NRESET") == 0) &&
313 (gpio_direction_output(OVERO_GPIO_BT_NRESET, 1) == 0)) {
314 gpio_export(OVERO_GPIO_BT_NRESET, 0);
315 gpio_set_value(OVERO_GPIO_BT_NRESET, 0);
317 gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
319 printk(KERN_ERR "could not obtain gpio for "
320 "OVERO_GPIO_BT_NRESET\n");
323 if ((gpio_request(OVERO_GPIO_USBH_CPEN, "OVERO_GPIO_USBH_CPEN") == 0) &&
324 (gpio_direction_output(OVERO_GPIO_USBH_CPEN, 1) == 0))
325 gpio_export(OVERO_GPIO_USBH_CPEN, 0);
327 printk(KERN_ERR "could not obtain gpio for "
328 "OVERO_GPIO_USBH_CPEN\n");
330 if ((gpio_request(OVERO_GPIO_USBH_NRESET,
331 "OVERO_GPIO_USBH_NRESET") == 0) &&
332 (gpio_direction_output(OVERO_GPIO_USBH_NRESET, 1) == 0))
333 gpio_export(OVERO_GPIO_USBH_NRESET, 0);
335 printk(KERN_ERR "could not obtain gpio for "
336 "OVERO_GPIO_USBH_NRESET\n");
339 static void __init overo_map_io(void)
341 omap2_set_globals_343x();
342 omap2_map_common_io();
345 MACHINE_START(OVERO, "Gumstix Overo")
346 .phys_io = 0x48000000,
347 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
348 .boot_params = 0x80000100,
349 .map_io = overo_map_io,
350 .init_irq = overo_init_irq,
351 .init_machine = overo_init,
352 .timer = &omap_timer,