]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-h4.c
[PATCH] ARM: OMAP: omap24xx Flash support
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-h4.c
1 /*
2  * linux/arch/arm/mach-omap/omap2/board-h4.c
3  *
4  * Copyright (C) 2005 Nokia Corporation
5  * Author: Paul Mundt <paul.mundt@nokia.com>
6  *
7  * Modified from mach-omap/omap1/board-generic.c
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  */
13
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/device.h>
17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/partitions.h>
19
20 #include <asm/hardware.h>
21 #include <asm/mach-types.h>
22 #include <asm/mach/arch.h>
23 #include <asm/mach/map.h>
24 #include <asm/mach/flash.h>
25
26 #include <asm/arch/gpio.h>
27 #include <asm/arch/mux.h>
28 #include <asm/arch/usb.h>
29 #include <asm/arch/board.h>
30 #include <asm/arch/common.h>
31
32 #include <asm/io.h>
33 #include <asm/delay.h>
34
35 static struct mtd_partition h4_partitions[] = {
36         /* bootloader (U-Boot, etc) in first sector */
37         {
38               .name             = "bootloader",
39               .offset           = 0,
40               .size             = SZ_128K,
41               .mask_flags       = MTD_WRITEABLE, /* force read-only */
42         },
43         /* bootloader params in the next sector */
44         {
45               .name             = "params",
46               .offset           = MTDPART_OFS_APPEND,
47               .size             = SZ_128K,
48               .mask_flags       = 0,
49         },
50         /* kernel */
51         {
52               .name             = "kernel",
53               .offset           = MTDPART_OFS_APPEND,
54               .size             = SZ_2M,
55               .mask_flags       = 0
56         },
57         /* file system */
58         {
59               .name             = "filesystem",
60               .offset           = MTDPART_OFS_APPEND,
61               .size             = MTDPART_SIZ_FULL,
62               .mask_flags       = 0
63         }
64 };
65
66 static struct flash_platform_data h4_flash_data = {
67         .map_name       = "cfi_probe",
68         .width          = 2,
69         .parts          = h4_partitions,
70         .nr_parts       = ARRAY_SIZE(h4_partitions),
71 };
72
73 static struct resource h4_flash_resource = {
74         .start          = H4_CS0_BASE,
75         .end            = H4_CS0_BASE + SZ_64M - 1,
76         .flags          = IORESOURCE_MEM,
77 };
78
79 static struct platform_device h4_flash_device = {
80         .name           = "omapflash",
81         .id             = 0,
82         .dev            = {
83                 .platform_data  = &h4_flash_data,
84         },
85         .num_resources  = 1,
86         .resource       = &h4_flash_resource,
87 };
88
89 static struct resource h4_smc91x_resources[] = {
90         [0] = {
91                 .start  = OMAP24XX_ETHR_START,          /* Physical */
92                 .end    = OMAP24XX_ETHR_START + 0xf,
93                 .flags  = IORESOURCE_MEM,
94         },
95         [1] = {
96                 .start  = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
97                 .end    = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
98                 .flags  = IORESOURCE_IRQ,
99         },
100 };
101
102 static struct platform_device h4_smc91x_device = {
103         .name           = "smc91x",
104         .id             = -1,
105         .num_resources  = ARRAY_SIZE(h4_smc91x_resources),
106         .resource       = h4_smc91x_resources,
107 };
108
109 static struct platform_device *h4_devices[] __initdata = {
110         &h4_smc91x_device,
111         &h4_flash_device,
112 };
113
114 static inline void __init h4_init_smc91x(void)
115 {
116         u32 l;
117
118         if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ) < 0) {
119                 printk(KERN_ERR "Failed to request GPIO#%d for smc91x IRQ\n",
120                         OMAP24XX_ETHR_GPIO_IRQ);
121                 return;
122         }
123         set_irq_type(OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
124                                  IRQT_FALLING);
125         /* Set pin M15 to mux mode 3 -> GPIO#92, disable PU/PD */
126         /* FIXME: change this using omap2 mux api when it's ready */
127         l = __raw_readl(0xd8000000 + 0x108);
128         l &= ~(((1 << 5) - 1) << 16);
129         l |= 3 << 16;
130         __raw_writel(l, 0xd8000000 + 0x108);
131 }
132
133 static void __init omap_h4_init_irq(void)
134 {
135         omap_init_irq();
136         omap_gpio_init();
137         h4_init_smc91x();
138 }
139
140 static struct omap_uart_config h4_uart_config __initdata = {
141         .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
142 };
143
144 static struct omap_mmc_config h4_mmc_config __initdata = {
145         .mmc [0] = {
146                 .enabled        = 1,
147                 .wire4          = 1,
148                 .wp_pin         = -1,
149                 .power_pin      = -1,
150                 .switch_pin     = -1,
151         },
152 };
153
154 static struct omap_board_config_kernel h4_config[] = {
155         { OMAP_TAG_UART,        &h4_uart_config },
156         { OMAP_TAG_MMC,         &h4_mmc_config },
157 };
158
159 static void __init omap_h4_init(void)
160 {
161         /*
162          * Make sure the serial ports are muxed on at this point.
163          * You have to mux them off in device drivers later on
164          * if not needed.
165          */
166         platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
167         omap_board_config = h4_config;
168         omap_board_config_size = ARRAY_SIZE(h4_config);
169         omap_serial_init();
170 }
171
172 static void __init omap_h4_map_io(void)
173 {
174         omap_map_common_io();
175 }
176
177 MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
178         /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
179         .phys_ram       = 0x80000000,
180         .phys_io        = 0x48000000,
181         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
182         .boot_params    = 0x80000100,
183         .map_io         = omap_h4_map_io,
184         .init_irq       = omap_h4_init_irq,
185         .init_machine   = omap_h4_init,
186         .timer          = &omap_timer,
187 MACHINE_END