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>
30 #include <linux/mtd/mtd.h>
31 #include <linux/mtd/nand.h>
32 #include <linux/mtd/partitions.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/flash.h>
37 #include <asm/mach/map.h>
39 #include <mach/board-overo.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/hsmmc.h>
46 #include <mach/nand.h>
47 #include <mach/usb-ehci.h>
48 #include <mach/usb-musb.h>
50 #include "sdram-micron-mt46h32m32lf-6.h"
51 #include "twl4030-generic-scripts.h"
53 #define NAND_BLOCK_SIZE SZ_128K
54 #define GPMC_CS0_BASE 0x60
55 #define GPMC_CS_SIZE 0x30
57 static struct mtd_partition overo_nand_partitions
[] = {
60 .offset
= 0, /* Offset = 0x00000 */
61 .size
= 4 * NAND_BLOCK_SIZE
,
62 .mask_flags
= MTD_WRITEABLE
66 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x80000 */
67 .size
= 14 * NAND_BLOCK_SIZE
,
70 .name
= "uboot environment",
71 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x240000 */
72 .size
= 2 * NAND_BLOCK_SIZE
,
76 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x280000 */
77 .size
= 32 * NAND_BLOCK_SIZE
,
81 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x680000 */
82 .size
= MTDPART_SIZ_FULL
,
86 static struct omap_nand_platform_data overo_nand_data
= {
87 .parts
= overo_nand_partitions
,
88 .nr_parts
= ARRAY_SIZE(overo_nand_partitions
),
89 .dma_channel
= -1, /* disable DMA in OMAP NAND driver */
92 static struct resource overo_nand_resource
= {
93 .flags
= IORESOURCE_MEM
,
96 static struct platform_device overo_nand_device
= {
100 .platform_data
= &overo_nand_data
,
103 .resource
= &overo_nand_resource
,
107 static void __init
overo_flash_init(void)
110 u8 nandcs
= GPMC_CS_NUM
+ 1;
112 u32 gpmc_base_add
= OMAP34XX_GPMC_VIRT
;
114 /* find out the chip-select on which NAND exists */
115 while (cs
< GPMC_CS_NUM
) {
117 ret
= gpmc_cs_read_reg(cs
, GPMC_CS_CONFIG1
);
119 if ((ret
& 0xC00) == 0x800) {
120 printk(KERN_INFO
"Found NAND on CS%d\n", cs
);
121 if (nandcs
> GPMC_CS_NUM
)
127 if (nandcs
> GPMC_CS_NUM
) {
128 printk(KERN_INFO
"NAND: Unable to find configuration "
133 if (nandcs
< GPMC_CS_NUM
) {
134 overo_nand_data
.cs
= nandcs
;
135 overo_nand_data
.gpmc_cs_baseaddr
= (void *)
136 (gpmc_base_add
+ GPMC_CS0_BASE
+ nandcs
* GPMC_CS_SIZE
);
137 overo_nand_data
.gpmc_baseaddr
= (void *) (gpmc_base_add
);
139 printk(KERN_INFO
"Registering NAND on CS%d\n", nandcs
);
140 if (platform_device_register(&overo_nand_device
) < 0)
141 printk(KERN_ERR
"Unable to register NAND device\n");
144 static struct omap_uart_config overo_uart_config __initdata
= {
145 .enabled_uarts
= ((1 << 0) | (1 << 1) | (1 << 2)),
147 static struct twl4030_gpio_platform_data overo_gpio_data
= {
148 .gpio_base
= OMAP_MAX_GPIO_LINES
,
149 .irq_base
= TWL4030_GPIO_IRQ_BASE
,
150 .irq_end
= TWL4030_GPIO_IRQ_END
,
153 static struct twl4030_usb_data overo_usb_data
= {
154 .usb_mode
= T2_USB_MODE_ULPI
,
157 static struct twl4030_platform_data overo_twldata
= {
158 .irq_base
= TWL4030_IRQ_BASE
,
159 .irq_end
= TWL4030_IRQ_END
,
160 .gpio
= &overo_gpio_data
,
161 .usb
= &overo_usb_data
,
162 .power
= &generic3430_t2scripts_data
,
165 static struct i2c_board_info __initdata overo_i2c_boardinfo
[] = {
167 I2C_BOARD_INFO("twl4030", 0x48),
168 .flags
= I2C_CLIENT_WAKE
,
169 .irq
= INT_34XX_SYS_NIRQ
,
170 .platform_data
= &overo_twldata
,
174 static int __init
overo_i2c_init(void)
176 omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo
,
177 ARRAY_SIZE(overo_i2c_boardinfo
));
178 /* i2c2 pins are used for gpio */
179 omap_register_i2c_bus(3, 400, NULL
, 0);
183 static void __init
overo_init_irq(void)
185 omap2_init_common_hw(mt46h32m32lf6_sdrc_params
);
190 static struct platform_device overo_lcd_device
= {
195 static struct omap_lcd_config overo_lcd_config __initdata
= {
196 .ctrl_name
= "internal",
199 static struct omap_board_config_kernel overo_config
[] __initdata
= {
200 { OMAP_TAG_UART
, &overo_uart_config
},
201 { OMAP_TAG_LCD
, &overo_lcd_config
},
204 static struct platform_device
*overo_devices
[] __initdata
= {
208 static void __init
overo_init(void)
211 platform_add_devices(overo_devices
, ARRAY_SIZE(overo_devices
));
212 omap_board_config
= overo_config
;
213 omap_board_config_size
= ARRAY_SIZE(overo_config
);
220 if ((gpio_request(OVERO_GPIO_W2W_NRESET
,
221 "OVERO_GPIO_W2W_NRESET") == 0) &&
222 (gpio_direction_output(OVERO_GPIO_W2W_NRESET
, 1) == 0)) {
223 gpio_export(OVERO_GPIO_W2W_NRESET
, 0);
224 gpio_set_value(OVERO_GPIO_W2W_NRESET
, 0);
226 gpio_set_value(OVERO_GPIO_W2W_NRESET
, 1);
228 printk(KERN_ERR
"could not obtain gpio for "
229 "OVERO_GPIO_W2W_NRESET\n");
232 if ((gpio_request(OVERO_GPIO_BT_XGATE
, "OVERO_GPIO_BT_XGATE") == 0) &&
233 (gpio_direction_output(OVERO_GPIO_BT_XGATE
, 0) == 0))
234 gpio_export(OVERO_GPIO_BT_XGATE
, 0);
236 printk(KERN_ERR
"could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
238 if ((gpio_request(OVERO_GPIO_BT_NRESET
, "OVERO_GPIO_BT_NRESET") == 0) &&
239 (gpio_direction_output(OVERO_GPIO_BT_NRESET
, 1) == 0)) {
240 gpio_export(OVERO_GPIO_BT_NRESET
, 0);
241 gpio_set_value(OVERO_GPIO_BT_NRESET
, 0);
243 gpio_set_value(OVERO_GPIO_BT_NRESET
, 1);
245 printk(KERN_ERR
"could not obtain gpio for "
246 "OVERO_GPIO_BT_NRESET\n");
249 if ((gpio_request(OVERO_GPIO_USBH_CPEN
, "OVERO_GPIO_USBH_CPEN") == 0) &&
250 (gpio_direction_output(OVERO_GPIO_USBH_CPEN
, 1) == 0))
251 gpio_export(OVERO_GPIO_USBH_CPEN
, 0);
253 printk(KERN_ERR
"could not obtain gpio for "
254 "OVERO_GPIO_USBH_CPEN\n");
256 if ((gpio_request(OVERO_GPIO_USBH_NRESET
,
257 "OVERO_GPIO_USBH_NRESET") == 0) &&
258 (gpio_direction_output(OVERO_GPIO_USBH_NRESET
, 1) == 0))
259 gpio_export(OVERO_GPIO_USBH_NRESET
, 0);
261 printk(KERN_ERR
"could not obtain gpio for "
262 "OVERO_GPIO_USBH_NRESET\n");
265 static void __init
overo_map_io(void)
267 omap2_set_globals_343x();
268 omap2_map_common_io();
271 MACHINE_START(OVERO
, "Gumstix Overo")
272 .phys_io
= 0x48000000,
273 .io_pg_offst
= ((0xd8000000) >> 18) & 0xfffc,
274 .boot_params
= 0x80000100,
275 .map_io
= overo_map_io
,
276 .init_irq
= overo_init_irq
,
277 .init_machine
= overo_init
,
278 .timer
= &omap_timer
,