]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-2430sdp.c
ARM: OMAP: 2430SDP support for omap2 OneNAND driver
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-2430sdp.c
1 /*
2  * linux/arch/arm/mach-omap2/board-2430sdp.c
3  *
4  * Copyright (C) 2006 Texas Instruments
5  *
6  * Modified from mach-omap2/board-generic.c
7  *
8  * Initial Code : Based on a patch from Komal Shah and Richard Woodruff
9  * Updated the Code for 2430 SDP : Syed Mohammed Khasim
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2 as
13  * published by the Free Software Foundation.
14  */
15
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/partitions.h>
21 #include <linux/delay.h>
22 #include <linux/err.h>
23 #include <linux/clk.h>
24
25 #include <asm/hardware.h>
26 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29 #include <asm/mach/flash.h>
30
31 #include <asm/arch/gpio.h>
32 #include <asm/arch/mux.h>
33 #include <asm/arch/board.h>
34 #include <asm/arch/common.h>
35 #include <asm/arch/gpmc.h>
36 #include "prcm-regs.h"
37
38 #include <asm/io.h>
39
40 #define SDP2430_FLASH_CS        0
41 #define SDP2430_SMC91X_CS       5
42
43 static struct mtd_partition sdp2430_partitions[] = {
44         /* bootloader (U-Boot, etc) in first sector */
45         {
46                 .name           = "bootloader",
47                 .offset         = 0,
48                 .size           = SZ_256K,
49                 .mask_flags     = MTD_WRITEABLE,        /* force read-only */
50          },
51         /* bootloader params in the next sector */
52         {
53                 .name           = "params",
54                 .offset         = MTDPART_OFS_APPEND,
55                 .size           = SZ_128K,
56                 .mask_flags     = 0,
57          },
58         /* kernel */
59         {
60                 .name           = "kernel",
61                 .offset         = MTDPART_OFS_APPEND,
62                 .size           = SZ_2M,
63                 .mask_flags     = 0
64         },
65         /* file system */
66         {
67                 .name           = "filesystem",
68                 .offset         = MTDPART_OFS_APPEND,
69                 .size           = MTDPART_SIZ_FULL,
70                 .mask_flags     = 0
71         }
72 };
73
74 static struct flash_platform_data sdp2430_flash_data = {
75         .map_name       = "cfi_probe",
76         .width          = 2,
77         .parts          = sdp2430_partitions,
78         .nr_parts       = ARRAY_SIZE(sdp2430_partitions),
79 };
80
81 static struct resource sdp2430_flash_resource = {
82         .start          = SDP2430_CS0_BASE,
83         .end            = SDP2430_CS0_BASE + SZ_64M - 1,
84         .flags          = IORESOURCE_MEM,
85 };
86
87 static struct platform_device sdp2430_flash_device = {
88         .name           = "omapflash",
89         .id             = 0,
90         .dev = {
91                 .platform_data  = &sdp2430_flash_data,
92         },
93         .num_resources  = 1,
94         .resource       = &sdp2430_flash_resource,
95 };
96
97 static struct resource sdp2430_smc91x_resources[] = {
98         [0] = {
99                 .start  = SDP2430_CS0_BASE,
100                 .end    = SDP2430_CS0_BASE + SZ_64M - 1,
101                 .flags  = IORESOURCE_MEM,
102         },
103         [1] = {
104                 .start  = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
105                 .end    = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
106                 .flags  = IORESOURCE_IRQ,
107         },
108 };
109
110 static struct platform_device sdp2430_smc91x_device = {
111         .name           = "smc91x",
112         .id             = -1,
113         .num_resources  = ARRAY_SIZE(sdp2430_smc91x_resources),
114         .resource       = sdp2430_smc91x_resources,
115 };
116
117 static struct platform_device *sdp2430_devices[] __initdata = {
118         &sdp2430_smc91x_device,
119         &sdp2430_flash_device,
120 };
121
122 static inline void __init sdp2430_init_smc91x(void)
123 {
124         int eth_cs;
125         unsigned long cs_mem_base;
126         unsigned int rate;
127         struct clk *l3ck;
128
129         eth_cs = SDP2430_SMC91X_CS;
130
131         l3ck = clk_get(NULL, "core_l3_ck");
132         if (IS_ERR(l3ck))
133                 rate = 100000000;
134         else
135                 rate = clk_get_rate(l3ck);
136
137         /* Make sure CS1 timings are correct, for 2430 always muxed */
138         gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
139
140         if (rate >= 160000000) {
141                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
142                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
143                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
144                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
145                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
146         } else if (rate >= 130000000) {
147                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
148                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
149                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
150                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
151                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
152         } else { /* rate = 100000000 */
153                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
154                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
155                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
156                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
157                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
158         }
159
160         if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
161                 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
162                 return;
163         }
164
165         sdp2430_smc91x_resources[0].start = cs_mem_base + 0x300;
166         sdp2430_smc91x_resources[0].end = cs_mem_base + 0x30f;
167         udelay(100);
168
169         if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ) < 0) {
170                 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
171                         OMAP24XX_ETHR_GPIO_IRQ);
172                 gpmc_cs_free(eth_cs);
173                 return;
174         }
175         omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ, 1);
176
177 }
178
179 static void __init omap_2430sdp_init_irq(void)
180 {
181         omap2_init_common_hw();
182         omap_init_irq();
183         omap_gpio_init();
184         sdp2430_init_smc91x();
185 }
186
187 static struct omap_uart_config sdp2430_uart_config __initdata = {
188         .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
189 };
190
191 static struct omap_board_config_kernel sdp2430_config[] = {
192         {OMAP_TAG_UART, &sdp2430_uart_config},
193 };
194
195 #if     defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
196
197 #define OMAP2_I2C_BASE1         0x48070000
198 #define OMAP2_I2C_BASE2         0x48072000
199 #define OMAP2_I2C_INT1          56
200 #define OMAP2_I2C_INT2          57
201
202 static u32 omap2_i2c1_clkrate   = 400;
203 static u32 omap2_i2c2_clkrate   = 2600;
204
205 static struct resource i2c_resources1[] = {
206         {
207                 .start  = OMAP2_I2C_BASE1,
208                 .end    = OMAP2_I2C_BASE1 + 0x3f,
209                 .flags  = IORESOURCE_MEM,
210         },
211         {
212                 .start  = OMAP2_I2C_INT1,
213                 .flags  = IORESOURCE_IRQ,
214         },
215 };
216
217 static struct resource i2c_resources2[] = {
218         {
219                 .start  = OMAP2_I2C_BASE2,
220                 .end    = OMAP2_I2C_BASE2 + 0x3f,
221                 .flags  = IORESOURCE_MEM,
222         },
223         {
224                 .start  = OMAP2_I2C_INT2,
225                 .flags  = IORESOURCE_IRQ,
226         },
227 };
228
229 static struct platform_device omap_i2c_device1 = {
230         .name           = "i2c_omap",
231         .id             = 1,
232         .num_resources  = ARRAY_SIZE(i2c_resources1),
233         .resource       = i2c_resources1,
234         .dev            = {
235                 .platform_data  = &omap2_i2c1_clkrate,
236         },
237 };
238
239 static struct platform_device omap_i2c_device2 = {
240         .name           = "i2c_omap",
241         .id             = 2,
242         .num_resources  = ARRAY_SIZE(i2c_resources2),
243         .resource       = i2c_resources2,
244         .dev            = {
245                 .platform_data  = &omap2_i2c2_clkrate,
246         },
247 };
248
249 static void omap_init_i2c(void)
250 {
251         (void) platform_device_register(&omap_i2c_device2);
252         (void) platform_device_register(&omap_i2c_device1);
253 }
254
255 #else
256
257 static void omap_init_i2c(void) {}
258
259 #endif
260
261 static int __init omap2430_i2c_init(void)
262 {
263         omap_init_i2c();
264         return 0;
265 }
266
267 extern void __init sdp2430_flash_init(void);
268
269 static void __init omap_2430sdp_init(void)
270 {
271         platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices));
272         omap_board_config = sdp2430_config;
273         omap_board_config_size = ARRAY_SIZE(sdp2430_config);
274         omap_serial_init();
275
276         sdp2430_flash_init();
277 }
278
279 static void __init omap_2430sdp_map_io(void)
280 {
281         omap2_map_common_io();
282 }
283
284 arch_initcall(omap2430_i2c_init);
285
286 MACHINE_START(OMAP_2430SDP, "OMAP2430 sdp2430 board")
287         /* Maintainer: Syed Khasim - Texas Instruments Inc */
288         .phys_io        = 0x48000000,
289         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
290         .boot_params    = 0x80000100,
291         .map_io         = omap_2430sdp_map_io,
292         .init_irq       = omap_2430sdp_init_irq,
293         .init_machine   = omap_2430sdp_init,
294         .timer          = &omap_timer,
295 MACHINE_END