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