blob: d3ceed398e0b03df926f14b78f24b7ecf7cc15d7 [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
Tony Lindgren90c62bf2008-12-10 17:37:17 -080048#include "mmc-twl4030.h"
49
Tony Lindgren0d4d9ab2009-03-23 18:07:38 -070050#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
55
Steve Sakomaneba26452008-10-09 17:51:43 +030056#define NAND_BLOCK_SIZE SZ_128K
57#define GPMC_CS0_BASE 0x60
58#define GPMC_CS_SIZE 0x30
59
60static struct mtd_partition overo_nand_partitions[] = {
61 {
62 .name = "xloader",
63 .offset = 0, /* Offset = 0x00000 */
64 .size = 4 * NAND_BLOCK_SIZE,
65 .mask_flags = MTD_WRITEABLE
66 },
67 {
68 .name = "uboot",
69 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
70 .size = 14 * NAND_BLOCK_SIZE,
71 },
72 {
73 .name = "uboot environment",
74 .offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */
75 .size = 2 * NAND_BLOCK_SIZE,
76 },
77 {
78 .name = "linux",
79 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
80 .size = 32 * NAND_BLOCK_SIZE,
81 },
82 {
83 .name = "rootfs",
84 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
85 .size = MTDPART_SIZ_FULL,
86 },
87};
88
89static struct omap_nand_platform_data overo_nand_data = {
90 .parts = overo_nand_partitions,
91 .nr_parts = ARRAY_SIZE(overo_nand_partitions),
92 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
93};
94
95static struct resource overo_nand_resource = {
96 .flags = IORESOURCE_MEM,
97};
98
99static struct platform_device overo_nand_device = {
100 .name = "omap2-nand",
101 .id = -1,
102 .dev = {
103 .platform_data = &overo_nand_data,
104 },
105 .num_resources = 1,
106 .resource = &overo_nand_resource,
107};
108
109
110static void __init overo_flash_init(void)
111{
112 u8 cs = 0;
113 u8 nandcs = GPMC_CS_NUM + 1;
114
115 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
116
117 /* find out the chip-select on which NAND exists */
118 while (cs < GPMC_CS_NUM) {
119 u32 ret = 0;
120 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
121
122 if ((ret & 0xC00) == 0x800) {
123 printk(KERN_INFO "Found NAND on CS%d\n", cs);
124 if (nandcs > GPMC_CS_NUM)
125 nandcs = cs;
126 }
127 cs++;
128 }
129
130 if (nandcs > GPMC_CS_NUM) {
131 printk(KERN_INFO "NAND: Unable to find configuration "
132 "in GPMC\n ");
133 return;
134 }
135
136 if (nandcs < GPMC_CS_NUM) {
137 overo_nand_data.cs = nandcs;
138 overo_nand_data.gpmc_cs_baseaddr = (void *)
139 (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
140 overo_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
141
142 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
143 if (platform_device_register(&overo_nand_device) < 0)
144 printk(KERN_ERR "Unable to register NAND device\n");
145 }
146}
147static struct omap_uart_config overo_uart_config __initdata = {
148 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
149};
150
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800151static struct twl4030_gpio_platform_data overo_gpio_data = {
152 .gpio_base = OMAP_MAX_GPIO_LINES,
153 .irq_base = TWL4030_GPIO_IRQ_BASE,
154 .irq_end = TWL4030_GPIO_IRQ_END,
155};
156
157static struct twl4030_platform_data overo_twldata = {
158 .irq_base = TWL4030_IRQ_BASE,
159 .irq_end = TWL4030_IRQ_END,
160 .gpio = &overo_gpio_data,
161};
162
163static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
164 {
165 I2C_BOARD_INFO("twl4030", 0x48),
166 .flags = I2C_CLIENT_WAKE,
167 .irq = INT_34XX_SYS_NIRQ,
168 .platform_data = &overo_twldata,
169 },
170};
171
Steve Sakomaneba26452008-10-09 17:51:43 +0300172static int __init overo_i2c_init(void)
173{
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800174 omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo,
175 ARRAY_SIZE(overo_i2c_boardinfo));
Steve Sakomaneba26452008-10-09 17:51:43 +0300176 /* i2c2 pins are used for gpio */
177 omap_register_i2c_bus(3, 400, NULL, 0);
178 return 0;
179}
180
181static void __init overo_init_irq(void)
182{
183 omap2_init_common_hw();
184 omap_init_irq();
185 omap_gpio_init();
186}
187
188static struct platform_device overo_lcd_device = {
189 .name = "overo_lcd",
190 .id = -1,
191};
192
193static struct omap_lcd_config overo_lcd_config __initdata = {
194 .ctrl_name = "internal",
195};
196
197static struct omap_board_config_kernel overo_config[] __initdata = {
198 { OMAP_TAG_UART, &overo_uart_config },
199 { OMAP_TAG_LCD, &overo_lcd_config },
200};
201
202static struct platform_device *overo_devices[] __initdata = {
203 &overo_lcd_device,
204};
205
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800206static struct twl4030_hsmmc_info mmc[] __initdata = {
207 {
208 .mmc = 1,
209 .wires = 4,
210 .gpio_cd = -EINVAL,
211 .gpio_wp = -EINVAL,
212 },
213 {
214 .mmc = 2,
215 .wires = 4,
216 .gpio_cd = -EINVAL,
217 .gpio_wp = -EINVAL,
David Brownell0329c372009-03-23 18:23:47 -0700218 .transceiver = true,
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800219 },
220 {} /* Terminator */
221};
222
Steve Sakomaneba26452008-10-09 17:51:43 +0300223static void __init overo_init(void)
224{
225 overo_i2c_init();
226 platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices));
227 omap_board_config = overo_config;
228 omap_board_config_size = ARRAY_SIZE(overo_config);
229 omap_serial_init();
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800230 twl4030_mmc_init(mmc);
Steve Sakomaneba26452008-10-09 17:51:43 +0300231 overo_flash_init();
Felipe Balbi18cb7ac2009-03-23 18:34:06 -0700232 usb_musb_init();
Steve Sakomaneba26452008-10-09 17:51:43 +0300233
234 if ((gpio_request(OVERO_GPIO_W2W_NRESET,
235 "OVERO_GPIO_W2W_NRESET") == 0) &&
236 (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) {
237 gpio_export(OVERO_GPIO_W2W_NRESET, 0);
238 gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);
239 udelay(10);
240 gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
241 } else {
242 printk(KERN_ERR "could not obtain gpio for "
243 "OVERO_GPIO_W2W_NRESET\n");
244 }
245
246 if ((gpio_request(OVERO_GPIO_BT_XGATE, "OVERO_GPIO_BT_XGATE") == 0) &&
247 (gpio_direction_output(OVERO_GPIO_BT_XGATE, 0) == 0))
248 gpio_export(OVERO_GPIO_BT_XGATE, 0);
249 else
250 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
251
252 if ((gpio_request(OVERO_GPIO_BT_NRESET, "OVERO_GPIO_BT_NRESET") == 0) &&
253 (gpio_direction_output(OVERO_GPIO_BT_NRESET, 1) == 0)) {
254 gpio_export(OVERO_GPIO_BT_NRESET, 0);
255 gpio_set_value(OVERO_GPIO_BT_NRESET, 0);
256 mdelay(6);
257 gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
258 } else {
259 printk(KERN_ERR "could not obtain gpio for "
260 "OVERO_GPIO_BT_NRESET\n");
261 }
262
263 if ((gpio_request(OVERO_GPIO_USBH_CPEN, "OVERO_GPIO_USBH_CPEN") == 0) &&
264 (gpio_direction_output(OVERO_GPIO_USBH_CPEN, 1) == 0))
265 gpio_export(OVERO_GPIO_USBH_CPEN, 0);
266 else
267 printk(KERN_ERR "could not obtain gpio for "
268 "OVERO_GPIO_USBH_CPEN\n");
269
270 if ((gpio_request(OVERO_GPIO_USBH_NRESET,
271 "OVERO_GPIO_USBH_NRESET") == 0) &&
272 (gpio_direction_output(OVERO_GPIO_USBH_NRESET, 1) == 0))
273 gpio_export(OVERO_GPIO_USBH_NRESET, 0);
274 else
275 printk(KERN_ERR "could not obtain gpio for "
276 "OVERO_GPIO_USBH_NRESET\n");
277}
278
279static void __init overo_map_io(void)
280{
281 omap2_set_globals_343x();
282 omap2_map_common_io();
283}
284
285MACHINE_START(OVERO, "Gumstix Overo")
286 .phys_io = 0x48000000,
287 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
288 .boot_params = 0x80000100,
289 .map_io = overo_map_io,
290 .init_irq = overo_init_irq,
291 .init_machine = overo_init,
292 .timer = &omap_timer,
293MACHINE_END