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>
30 #include <linux/regulator/machine.h>
32 #include <linux/mtd/mtd.h>
33 #include <linux/mtd/nand.h>
34 #include <linux/mtd/partitions.h>
36 #include <asm/mach-types.h>
37 #include <asm/mach/arch.h>
38 #include <asm/mach/flash.h>
39 #include <asm/mach/map.h>
41 #include <mach/board-overo.h>
42 #include <mach/board.h>
43 #include <mach/common.h>
44 #include <mach/gpio.h>
45 #include <mach/gpmc.h>
46 #include <mach/hardware.h>
47 #include <mach/nand.h>
48 #include <mach/usb-ehci.h>
49 #include <mach/usb-musb.h>
51 #include "sdram-micron-mt46h32m32lf-6.h"
52 #include "twl4030-generic-scripts.h"
53 #include "mmc-twl4030.h"
55 #define NAND_BLOCK_SIZE SZ_128K
56 #define GPMC_CS0_BASE 0x60
57 #define GPMC_CS_SIZE 0x30
59 static struct mtd_partition overo_nand_partitions[] = {
62 .offset = 0, /* Offset = 0x00000 */
63 .size = 4 * NAND_BLOCK_SIZE,
64 .mask_flags = MTD_WRITEABLE
68 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
69 .size = 14 * NAND_BLOCK_SIZE,
72 .name = "uboot environment",
73 .offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */
74 .size = 2 * NAND_BLOCK_SIZE,
78 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
79 .size = 32 * NAND_BLOCK_SIZE,
83 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
84 .size = MTDPART_SIZ_FULL,
88 static struct omap_nand_platform_data overo_nand_data = {
89 .parts = overo_nand_partitions,
90 .nr_parts = ARRAY_SIZE(overo_nand_partitions),
91 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
94 static struct resource overo_nand_resource = {
95 .flags = IORESOURCE_MEM,
98 static struct platform_device overo_nand_device = {
102 .platform_data = &overo_nand_data,
105 .resource = &overo_nand_resource,
109 static void __init overo_flash_init(void)
112 u8 nandcs = GPMC_CS_NUM + 1;
114 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
116 /* find out the chip-select on which NAND exists */
117 while (cs < GPMC_CS_NUM) {
119 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
121 if ((ret & 0xC00) == 0x800) {
122 printk(KERN_INFO "Found NAND on CS%d\n", cs);
123 if (nandcs > GPMC_CS_NUM)
129 if (nandcs > GPMC_CS_NUM) {
130 printk(KERN_INFO "NAND: Unable to find configuration "
135 if (nandcs < GPMC_CS_NUM) {
136 overo_nand_data.cs = nandcs;
137 overo_nand_data.gpmc_cs_baseaddr = (void *)
138 (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
139 overo_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
141 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
142 if (platform_device_register(&overo_nand_device) < 0)
143 printk(KERN_ERR "Unable to register NAND device\n");
146 static struct omap_uart_config overo_uart_config __initdata = {
147 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
150 static struct twl4030_gpio_platform_data overo_gpio_data = {
151 .gpio_base = OMAP_MAX_GPIO_LINES,
152 .irq_base = TWL4030_GPIO_IRQ_BASE,
153 .irq_end = TWL4030_GPIO_IRQ_END,
156 static struct twl4030_usb_data overo_usb_data = {
157 .usb_mode = T2_USB_MODE_ULPI,
160 static struct regulator_init_data overo_vmmc1 = {
162 .valid_modes_mask = REGULATOR_MODE_NORMAL
163 | REGULATOR_MODE_STANDBY,
164 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
165 | REGULATOR_CHANGE_MODE
166 | REGULATOR_CHANGE_STATUS,
170 /* mmc2 (WLAN) and Bluetooth don't use twl4030 regulators */
172 static struct twl4030_platform_data overo_twldata = {
173 .irq_base = TWL4030_IRQ_BASE,
174 .irq_end = TWL4030_IRQ_END,
175 .gpio = &overo_gpio_data,
176 .usb = &overo_usb_data,
177 .power = GENERIC3430_T2SCRIPTS_DATA,
178 .vmmc1 = &overo_vmmc1,
181 static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
183 I2C_BOARD_INFO("tps65950", 0x48),
184 .flags = I2C_CLIENT_WAKE,
185 .irq = INT_34XX_SYS_NIRQ,
186 .platform_data = &overo_twldata,
190 static int __init overo_i2c_init(void)
192 omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo,
193 ARRAY_SIZE(overo_i2c_boardinfo));
194 /* i2c2 pins are used for gpio */
195 omap_register_i2c_bus(3, 400, NULL, 0);
199 static void __init overo_init_irq(void)
201 omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
206 static struct platform_device overo_lcd_device = {
211 static struct omap_lcd_config overo_lcd_config __initdata = {
212 .ctrl_name = "internal",
215 static struct omap_board_config_kernel overo_config[] __initdata = {
216 { OMAP_TAG_UART, &overo_uart_config },
217 { OMAP_TAG_LCD, &overo_lcd_config },
220 static struct platform_device *overo_devices[] __initdata = {
224 static struct twl4030_hsmmc_info mmc[] __initdata = {
241 static void __init overo_init(void)
244 platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices));
245 omap_board_config = overo_config;
246 omap_board_config_size = ARRAY_SIZE(overo_config);
248 twl4030_mmc_init(mmc);
253 if ((gpio_request(OVERO_GPIO_W2W_NRESET,
254 "OVERO_GPIO_W2W_NRESET") == 0) &&
255 (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) {
256 gpio_export(OVERO_GPIO_W2W_NRESET, 0);
257 gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);
259 gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
261 printk(KERN_ERR "could not obtain gpio for "
262 "OVERO_GPIO_W2W_NRESET\n");
265 if ((gpio_request(OVERO_GPIO_BT_XGATE, "OVERO_GPIO_BT_XGATE") == 0) &&
266 (gpio_direction_output(OVERO_GPIO_BT_XGATE, 0) == 0))
267 gpio_export(OVERO_GPIO_BT_XGATE, 0);
269 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
271 if ((gpio_request(OVERO_GPIO_BT_NRESET, "OVERO_GPIO_BT_NRESET") == 0) &&
272 (gpio_direction_output(OVERO_GPIO_BT_NRESET, 1) == 0)) {
273 gpio_export(OVERO_GPIO_BT_NRESET, 0);
274 gpio_set_value(OVERO_GPIO_BT_NRESET, 0);
276 gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
278 printk(KERN_ERR "could not obtain gpio for "
279 "OVERO_GPIO_BT_NRESET\n");
282 if ((gpio_request(OVERO_GPIO_USBH_CPEN, "OVERO_GPIO_USBH_CPEN") == 0) &&
283 (gpio_direction_output(OVERO_GPIO_USBH_CPEN, 1) == 0))
284 gpio_export(OVERO_GPIO_USBH_CPEN, 0);
286 printk(KERN_ERR "could not obtain gpio for "
287 "OVERO_GPIO_USBH_CPEN\n");
289 if ((gpio_request(OVERO_GPIO_USBH_NRESET,
290 "OVERO_GPIO_USBH_NRESET") == 0) &&
291 (gpio_direction_output(OVERO_GPIO_USBH_NRESET, 1) == 0))
292 gpio_export(OVERO_GPIO_USBH_NRESET, 0);
294 printk(KERN_ERR "could not obtain gpio for "
295 "OVERO_GPIO_USBH_NRESET\n");
298 static void __init overo_map_io(void)
300 omap2_set_globals_343x();
301 omap2_map_common_io();
304 MACHINE_START(OVERO, "Gumstix Overo")
305 .phys_io = 0x48000000,
306 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
307 .boot_params = 0x80000100,
308 .map_io = overo_map_io,
309 .init_irq = overo_init_irq,
310 .init_machine = overo_init,
311 .timer = &omap_timer,