]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap1/board-h3.c
Merge with /home/tmlind/src/kernel/linux-2.6
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap1 / board-h3.c
1 /*
2  * linux/arch/arm/mach-omap1/board-h3.c
3  *
4  * This file contains OMAP1710 H3 specific code.
5  *
6  * Copyright (C) 2004 Texas Instruments, Inc.
7  * Copyright (C) 2002 MontaVista Software, Inc.
8  * Copyright (C) 2001 RidgeRun, Inc.
9  * Author: RidgeRun, Inc.
10  *         Greg Lonnon (glonnon@ridgerun.com) or info@ridgerun.com
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License version 2 as
14  * published by the Free Software Foundation.
15  */
16
17 #include <linux/config.h>
18 #include <linux/types.h>
19 #include <linux/init.h>
20 #include <linux/major.h>
21 #include <linux/kernel.h>
22 #include <linux/platform_device.h>
23 #include <linux/errno.h>
24 #include <linux/workqueue.h>
25 #include <linux/mtd/mtd.h>
26 #include <linux/mtd/nand.h>
27 #include <linux/mtd/partitions.h>
28
29 #include <asm/setup.h>
30 #include <asm/page.h>
31 #include <asm/hardware.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/flash.h>
35 #include <asm/mach/map.h>
36
37 #include <asm/arch/gpio.h>
38 #include <asm/arch/gpioexpander.h>
39 #include <asm/arch/irqs.h>
40 #include <asm/arch/mux.h>
41 #include <asm/arch/tc.h>
42 #include <asm/arch/irda.h>
43 #include <asm/arch/usb.h>
44 #include <asm/arch/common.h>
45
46 extern int omap_gpio_init(void);
47
48 static struct mtd_partition nor_partitions[] = {
49         /* bootloader (U-Boot, etc) in first sector */
50         {
51               .name             = "bootloader",
52               .offset           = 0,
53               .size             = SZ_128K,
54               .mask_flags       = MTD_WRITEABLE, /* force read-only */
55         },
56         /* bootloader params in the next sector */
57         {
58               .name             = "params",
59               .offset           = MTDPART_OFS_APPEND,
60               .size             = SZ_128K,
61               .mask_flags       = 0,
62         },
63         /* kernel */
64         {
65               .name             = "kernel",
66               .offset           = MTDPART_OFS_APPEND,
67               .size             = SZ_2M,
68               .mask_flags       = 0
69         },
70         /* file system */
71         {
72               .name             = "filesystem",
73               .offset           = MTDPART_OFS_APPEND,
74               .size             = MTDPART_SIZ_FULL,
75               .mask_flags       = 0
76         }
77 };
78
79 static struct flash_platform_data nor_data = {
80         .map_name       = "cfi_probe",
81         .width          = 2,
82         .parts          = nor_partitions,
83         .nr_parts       = ARRAY_SIZE(nor_partitions),
84 };
85
86 static struct resource nor_resource = {
87         /* This is on CS3, wherever it's mapped */
88         .flags          = IORESOURCE_MEM,
89 };
90
91 static struct platform_device nor_device = {
92         .name           = "omapflash",
93         .id             = 0,
94         .dev            = {
95                 .platform_data  = &nor_data,
96         },
97         .num_resources  = 1,
98         .resource       = &nor_resource,
99 };
100
101 static struct mtd_partition nand_partitions[] = {
102 #if 0
103         /* REVISIT: enable these partitions if you make NAND BOOT work */
104         {
105                 .name           = "xloader",
106                 .offset         = 0,
107                 .size           = 64 * 1024,
108                 .mask_flags     = MTD_WRITEABLE,        /* force read-only */
109         },
110         {
111                 .name           = "bootloader",
112                 .offset         = MTDPART_OFS_APPEND,
113                 .size           = 256 * 1024,
114                 .mask_flags     = MTD_WRITEABLE,        /* force read-only */
115         },
116         {
117                 .name           = "params",
118                 .offset         = MTDPART_OFS_APPEND,
119                 .size           = 192 * 1024,
120         },
121         {
122                 .name           = "kernel",
123                 .offset         = MTDPART_OFS_APPEND,
124                 .size           = 2 * SZ_1M,
125         },
126 #endif
127         {
128                 .name           = "filesystem",
129                 .size           = MTDPART_SIZ_FULL,
130                 .offset         = MTDPART_OFS_APPEND,
131         },
132 };
133
134 /* dip switches control NAND chip access:  8 bit, 16 bit, or neither */
135 static struct nand_platform_data nand_data = {
136         .options        = NAND_SAMSUNG_LP_OPTIONS,
137         .parts          = nand_partitions,
138         .nr_parts       = ARRAY_SIZE(nand_partitions),
139 };
140
141 static struct resource nand_resource = {
142         .flags          = IORESOURCE_MEM,
143 };
144
145 static struct platform_device nand_device = {
146         .name           = "omapnand",
147         .id             = 0,
148         .dev            = {
149                 .platform_data  = &nand_data,
150         },
151         .num_resources  = 1,
152         .resource       = &nand_resource,
153 };
154
155 static struct resource smc91x_resources[] = {
156         [0] = {
157                 .start  = OMAP1710_ETHR_START,          /* Physical */
158                 .end    = OMAP1710_ETHR_START + 0xf,
159                 .flags  = IORESOURCE_MEM,
160         },
161         [1] = {
162                 .start  = OMAP_GPIO_IRQ(40),
163                 .end    = OMAP_GPIO_IRQ(40),
164                 .flags  = IORESOURCE_IRQ,
165         },
166 };
167
168 static struct platform_device smc91x_device = {
169         .name           = "smc91x",
170         .id             = 0,
171         .num_resources  = ARRAY_SIZE(smc91x_resources),
172         .resource       = smc91x_resources,
173 };
174
175 #define GPTIMER_BASE            0xFFFB1400
176 #define GPTIMER_REGS(x) (0xFFFB1400 + (x * 0x800))
177 #define GPTIMER_REGS_SIZE       0x46
178
179 static struct resource intlat_resources[] = {
180         [0] = {
181                 .start  = GPTIMER_REGS(0),            /* Physical */
182                 .end    = GPTIMER_REGS(0) + GPTIMER_REGS_SIZE,
183                 .flags  = IORESOURCE_MEM,
184         },
185         [1] = {
186                 .start  = INT_1610_GPTIMER1,
187                 .end    = INT_1610_GPTIMER1,
188                 .flags  = IORESOURCE_IRQ,
189         },
190 };
191
192 static struct platform_device intlat_device = {
193         .name      = "omap_intlat",
194         .id          = 0,
195         .num_resources  = ARRAY_SIZE(intlat_resources),
196         .resource       = intlat_resources,
197 };
198
199 /* Select between the IrDA and aGPS module
200  */
201 static int h3_select_irda(struct device *dev, int state)
202 {
203         unsigned char expa;
204         int err = 0;
205
206         if ((err = read_gpio_expa(&expa, 0x26))) {
207                 printk(KERN_ERR "Error reading from I/O EXPANDER \n");
208                 return err;
209         }
210
211         /* 'P6' enable/disable IRDA_TX and IRDA_RX */
212         if (state & IR_SEL) { /* IrDA */
213                 if ((err = write_gpio_expa(expa | 0x40, 0x26))) {
214                         printk(KERN_ERR "Error writing to I/O EXPANDER \n");
215                         return err;
216                 }
217         } else {
218                 if ((err = write_gpio_expa(expa & ~0x40, 0x26))) {
219                         printk(KERN_ERR "Error writing to I/O EXPANDER \n");
220                         return err;
221                 }
222         }
223         return err;
224 }
225
226 static void set_trans_mode(void *data)
227 {
228         int *mode = data;
229         unsigned char expa;
230         int err = 0;
231
232         if ((err = read_gpio_expa(&expa, 0x27)) != 0) {
233                 printk(KERN_ERR "Error reading from I/O expander\n");
234         }
235
236         expa &= ~0x03;
237
238         if (*mode & IR_SIRMODE) {
239                 expa |= 0x01;
240         } else { /* MIR/FIR */
241                 expa |= 0x03;
242         }
243
244         if ((err = write_gpio_expa(expa, 0x27)) != 0) {
245                 printk(KERN_ERR "Error writing to I/O expander\n");
246         }
247 }
248
249 static int h3_transceiver_mode(struct device *dev, int mode)
250 {
251         struct omap_irda_config *irda_config = dev->platform_data;
252
253         cancel_delayed_work(&irda_config->gpio_expa);
254         PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode);
255         schedule_work(&irda_config->gpio_expa);
256
257         return 0;
258 }
259
260 static struct omap_irda_config h3_irda_data = {
261         .transceiver_cap        = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
262         .transceiver_mode       = h3_transceiver_mode,
263         .select_irda            = h3_select_irda,
264 };
265
266 static struct resource h3_irda_resources[] = {
267         [0] = {
268                 .start  = INT_UART3,
269                 .end    = INT_UART3,
270                 .flags  = IORESOURCE_IRQ,
271         },
272 };
273 static struct platform_device h3_irda_device = {
274         .name           = "omapirda",
275         .id             = 0,
276         .dev            = {
277                 .platform_data  = &h3_irda_data,
278         },
279         .num_resources  = ARRAY_SIZE(h3_irda_resources),
280         .resource       = h3_irda_resources,
281 };
282
283 static struct platform_device *devices[] __initdata = {
284         &nor_device,
285         &nand_device,
286         &smc91x_device,
287         &intlat_device,
288         &h3_irda_device,
289 };
290
291 static struct omap_usb_config h3_usb_config __initdata = {
292         /* usb1 has a Mini-AB port and external isp1301 transceiver */
293         .otg        = 2,
294
295 #ifdef CONFIG_USB_GADGET_OMAP
296         .hmc_mode       = 19,   /* 0:host(off) 1:dev|otg 2:disabled */
297 #elif  defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
298         /* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
299         .hmc_mode       = 20,   /* 1:dev|otg(off) 1:host 2:disabled */
300 #endif
301
302         .pins[1]        = 3,
303 };
304
305 static struct omap_mmc_config h3_mmc_config __initdata = {
306         .mmc[0] = {
307                 .enabled        = 1,
308                 .power_pin      = -1,   /* tps65010 GPIO4 */
309                 .switch_pin     = OMAP_MPUIO(1),
310         },
311 };
312
313 static struct omap_uart_config h3_uart_config __initdata = {
314         .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
315 };
316
317 static struct omap_lcd_config h3_lcd_config __initdata = {
318         .panel_name     = "h3",
319         .ctrl_name      = "internal",
320 };
321
322 static struct omap_board_config_kernel h3_config[] = {
323         { OMAP_TAG_USB,         &h3_usb_config },
324         { OMAP_TAG_MMC,         &h3_mmc_config },
325         { OMAP_TAG_UART,        &h3_uart_config },
326         { OMAP_TAG_LCD,         &h3_lcd_config },
327 };
328
329 #define H3_NAND_RB_GPIO_PIN     10
330
331 static int nand_dev_ready(struct nand_platform_data *data)
332 {
333         return omap_get_gpio_datain(H3_NAND_RB_GPIO_PIN);
334 }
335
336 static void __init h3_init(void)
337 {
338         /* Here we assume the NOR boot config:  NOR on CS3 (possibly swapped
339          * to address 0 by a dip switch), NAND on CS2B.  The NAND driver will
340          * notice whether a NAND chip is enabled at probe time.
341          *
342          * H3 support NAND-boot, with a dip switch to put NOR on CS2B and NAND
343          * (which on H2 may be 16bit) on CS3.  Try detecting that in code here,
344          * to avoid probing every possible flash configuration...
345          */
346         nor_resource.end = nor_resource.start = omap_cs3_phys();
347         nor_resource.end += SZ_32M - 1;
348
349         nand_resource.end = nand_resource.start = OMAP_CS2B_PHYS;
350         nand_resource.end += SZ_4K - 1;
351         if (!(omap_request_gpio(H3_NAND_RB_GPIO_PIN)))
352                 nand_data.dev_ready = nand_dev_ready;
353
354         /* GPIO10 Func_MUX_CTRL reg bit 29:27, Configure V2 to mode1 as GPIO */
355         /* GPIO10 pullup/down register, Enable pullup on GPIO10 */
356         omap_cfg_reg(V2_1710_GPIO10);
357
358         platform_add_devices(devices, ARRAY_SIZE(devices));
359         omap_board_config = h3_config;
360         omap_board_config_size = ARRAY_SIZE(h3_config);
361         omap_serial_init();
362 }
363
364 static void __init h3_init_smc91x(void)
365 {
366         omap_cfg_reg(W15_1710_GPIO40);
367         if (omap_request_gpio(40) < 0) {
368                 printk("Error requesting gpio 40 for smc91x irq\n");
369                 return;
370         }
371 }
372
373 void h3_init_irq(void)
374 {
375         omap1_init_common_hw();
376         omap_init_irq();
377         omap_gpio_init();
378         h3_init_smc91x();
379 }
380
381 static void __init h3_map_io(void)
382 {
383         omap1_map_common_io();
384 }
385
386 MACHINE_START(OMAP_H3, "TI OMAP1710 H3 board")
387         /* Maintainer: Texas Instruments, Inc. */
388         .phys_io        = 0xfff00000,
389         .io_pg_offst    = ((0xfef00000) >> 18) & 0xfffc,
390         .boot_params    = 0x10000100,
391         .map_io         = h3_map_io,
392         .init_irq       = h3_init_irq,
393         .init_machine   = h3_init,
394         .timer          = &omap_timer,
395 MACHINE_END