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