]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-2430sdp.c
Merge omap-drivers
[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 #include <linux/spi/spi.h>
25 #include <linux/spi/tsc2046.h>
26
27 #include <asm/hardware.h>
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
31 #include <asm/mach/flash.h>
32
33 #include <asm/arch/gpio.h>
34 #include <asm/arch/mux.h>
35 #include <asm/arch/board.h>
36 #include <asm/arch/common.h>
37 #include <asm/arch/gpmc.h>
38 #include <asm/arch/mcspi.h>
39 #include "prcm-regs.h"
40
41 #include <asm/io.h>
42
43 #define SDP2430_FLASH_CS        0
44 #define SDP2430_SMC91X_CS       5
45
46 /* TSC2046 (touchscreen) */
47 #define TS_GPIO                 24
48
49 static struct mtd_partition sdp2430_partitions[] = {
50         /* bootloader (U-Boot, etc) in first sector */
51         {
52                 .name           = "bootloader",
53                 .offset         = 0,
54                 .size           = SZ_256K,
55                 .mask_flags     = MTD_WRITEABLE,        /* force read-only */
56          },
57         /* bootloader params in the next sector */
58         {
59                 .name           = "params",
60                 .offset         = MTDPART_OFS_APPEND,
61                 .size           = SZ_128K,
62                 .mask_flags     = 0,
63          },
64         /* kernel */
65         {
66                 .name           = "kernel",
67                 .offset         = MTDPART_OFS_APPEND,
68                 .size           = SZ_2M,
69                 .mask_flags     = 0
70         },
71         /* file system */
72         {
73                 .name           = "filesystem",
74                 .offset         = MTDPART_OFS_APPEND,
75                 .size           = MTDPART_SIZ_FULL,
76                 .mask_flags     = 0
77         }
78 };
79
80 static struct flash_platform_data sdp2430_flash_data = {
81         .map_name       = "cfi_probe",
82         .width          = 2,
83         .parts          = sdp2430_partitions,
84         .nr_parts       = ARRAY_SIZE(sdp2430_partitions),
85 };
86
87 static struct resource sdp2430_flash_resource = {
88         .start          = SDP2430_CS0_BASE,
89         .end            = SDP2430_CS0_BASE + SZ_64M - 1,
90         .flags          = IORESOURCE_MEM,
91 };
92
93 static struct platform_device sdp2430_flash_device = {
94         .name           = "omapflash",
95         .id             = 0,
96         .dev = {
97                 .platform_data  = &sdp2430_flash_data,
98         },
99         .num_resources  = 1,
100         .resource       = &sdp2430_flash_resource,
101 };
102
103 static struct resource sdp2430_smc91x_resources[] = {
104         [0] = {
105                 .start  = SDP2430_CS0_BASE,
106                 .end    = SDP2430_CS0_BASE + SZ_64M - 1,
107                 .flags  = IORESOURCE_MEM,
108         },
109         [1] = {
110                 .start  = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
111                 .end    = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
112                 .flags  = IORESOURCE_IRQ,
113         },
114 };
115
116 static struct platform_device sdp2430_smc91x_device = {
117         .name           = "smc91x",
118         .id             = -1,
119         .num_resources  = ARRAY_SIZE(sdp2430_smc91x_resources),
120         .resource       = sdp2430_smc91x_resources,
121 };
122
123 static struct platform_device *sdp2430_devices[] __initdata = {
124         &sdp2430_smc91x_device,
125         &sdp2430_flash_device,
126 };
127
128 static struct tsc2046_platform_data tsc2046_config = {
129         .dav_gpio       = TS_GPIO,
130         .gpio_debounce  = 0xa,
131 };
132
133 static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
134         .turbo_mode     = 0,
135         .single_channel = 0,  /* 0: slave, 1: master */
136 };
137
138 static struct spi_board_info sdp2430_spi_board_info[] __initdata = {
139         [0] = {
140                 /*
141                  * TSC2046 operates at a max freqency of 2MHz, so
142                  * operate slightly below at 1.5MHz
143                  */
144                 .modalias        = "tsc2046",
145                 .bus_num         = 1,
146                 .chip_select     = 0,
147                 .max_speed_hz    = 1500000,
148                 .controller_data = &tsc2046_mcspi_config,
149                 .platform_data   = &tsc2046_config,
150         },
151 };
152
153 static inline void __init sdp2430_init_smc91x(void)
154 {
155         int eth_cs;
156         unsigned long cs_mem_base;
157         unsigned int rate;
158         struct clk *l3ck;
159
160         eth_cs = SDP2430_SMC91X_CS;
161
162         l3ck = clk_get(NULL, "core_l3_ck");
163         if (IS_ERR(l3ck))
164                 rate = 100000000;
165         else
166                 rate = clk_get_rate(l3ck);
167
168         /* Make sure CS1 timings are correct, for 2430 always muxed */
169         gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
170
171         if (rate >= 160000000) {
172                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
173                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
174                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
175                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
176                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
177         } else if (rate >= 130000000) {
178                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
179                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
180                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
181                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
182                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
183         } else { /* rate = 100000000 */
184                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
185                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
186                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
187                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
188                 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
189         }
190
191         if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
192                 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
193                 return;
194         }
195
196         sdp2430_smc91x_resources[0].start = cs_mem_base + 0x300;
197         sdp2430_smc91x_resources[0].end = cs_mem_base + 0x30f;
198         udelay(100);
199
200         if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ) < 0) {
201                 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
202                         OMAP24XX_ETHR_GPIO_IRQ);
203                 gpmc_cs_free(eth_cs);
204                 return;
205         }
206         omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ, 1);
207
208 }
209
210 static void __init omap_2430sdp_init_irq(void)
211 {
212         omap2_init_common_hw();
213         omap_init_irq();
214         omap_gpio_init();
215         sdp2430_init_smc91x();
216 }
217
218 static struct omap_uart_config sdp2430_uart_config __initdata = {
219         .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
220 };
221
222 static struct omap_board_config_kernel sdp2430_config[] = {
223         {OMAP_TAG_UART, &sdp2430_uart_config},
224 };
225
226 #if     defined(CONFIG_I2C_OMAP) || defined(CONFIG_I2C_OMAP_MODULE)
227
228 #define OMAP2_I2C_BASE1         0x48070000
229 #define OMAP2_I2C_BASE2         0x48072000
230 #define OMAP2_I2C_INT1          56
231 #define OMAP2_I2C_INT2          57
232
233 static u32 omap2_i2c1_clkrate   = 400;
234 static u32 omap2_i2c2_clkrate   = 2600;
235
236 static struct resource i2c_resources1[] = {
237         {
238                 .start  = OMAP2_I2C_BASE1,
239                 .end    = OMAP2_I2C_BASE1 + 0x3f,
240                 .flags  = IORESOURCE_MEM,
241         },
242         {
243                 .start  = OMAP2_I2C_INT1,
244                 .flags  = IORESOURCE_IRQ,
245         },
246 };
247
248 static struct resource i2c_resources2[] = {
249         {
250                 .start  = OMAP2_I2C_BASE2,
251                 .end    = OMAP2_I2C_BASE2 + 0x3f,
252                 .flags  = IORESOURCE_MEM,
253         },
254         {
255                 .start  = OMAP2_I2C_INT2,
256                 .flags  = IORESOURCE_IRQ,
257         },
258 };
259
260 static struct platform_device omap_i2c_device1 = {
261         .name           = "i2c_omap",
262         .id             = 1,
263         .num_resources  = ARRAY_SIZE(i2c_resources1),
264         .resource       = i2c_resources1,
265         .dev            = {
266                 .platform_data  = &omap2_i2c1_clkrate,
267         },
268 };
269
270 static struct platform_device omap_i2c_device2 = {
271         .name           = "i2c_omap",
272         .id             = 2,
273         .num_resources  = ARRAY_SIZE(i2c_resources2),
274         .resource       = i2c_resources2,
275         .dev            = {
276                 .platform_data  = &omap2_i2c2_clkrate,
277         },
278 };
279
280 static void omap_init_i2c(void)
281 {
282         (void) platform_device_register(&omap_i2c_device2);
283         (void) platform_device_register(&omap_i2c_device1);
284 }
285
286 #else
287
288 static void omap_init_i2c(void) {}
289
290 #endif
291
292 static int __init omap2430_i2c_init(void)
293 {
294         omap_init_i2c();
295         return 0;
296 }
297
298 extern void __init sdp2430_flash_init(void);
299
300 static void __init omap_2430sdp_init(void)
301 {
302         platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices));
303         omap_board_config = sdp2430_config;
304         omap_board_config_size = ARRAY_SIZE(sdp2430_config);
305         omap_serial_init();
306
307         sdp2430_flash_init();
308
309         spi_register_board_info(sdp2430_spi_board_info,
310                                 ARRAY_SIZE(sdp2430_spi_board_info));
311 }
312
313 static void __init omap_2430sdp_map_io(void)
314 {
315         omap2_map_common_io();
316 }
317
318 arch_initcall(omap2430_i2c_init);
319
320 MACHINE_START(OMAP_2430SDP, "OMAP2430 sdp2430 board")
321         /* Maintainer: Syed Khasim - Texas Instruments Inc */
322         .phys_io        = 0x48000000,
323         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
324         .boot_params    = 0x80000100,
325         .map_io         = omap_2430sdp_map_io,
326         .init_irq       = omap_2430sdp_init_irq,
327         .init_machine   = omap_2430sdp_init,
328         .timer          = &omap_timer,
329 MACHINE_END