Merge branch 'linus' into core/futexes
[deliverable/linux.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/io.h>
25
26 #include <mach/hardware.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/flash.h>
31
32 #include <mach/gpio.h>
33 #include <mach/mux.h>
34 #include <mach/board.h>
35 #include <mach/common.h>
36 #include <mach/gpmc.h>
37
38
39 #define SDP2430_FLASH_CS 0
40 #define SDP2430_SMC91X_CS 5
41
42 static struct mtd_partition sdp2430_partitions[] = {
43 /* bootloader (U-Boot, etc) in first sector */
44 {
45 .name = "bootloader",
46 .offset = 0,
47 .size = SZ_256K,
48 .mask_flags = MTD_WRITEABLE, /* force read-only */
49 },
50 /* bootloader params in the next sector */
51 {
52 .name = "params",
53 .offset = MTDPART_OFS_APPEND,
54 .size = SZ_128K,
55 .mask_flags = 0,
56 },
57 /* kernel */
58 {
59 .name = "kernel",
60 .offset = MTDPART_OFS_APPEND,
61 .size = SZ_2M,
62 .mask_flags = 0
63 },
64 /* file system */
65 {
66 .name = "filesystem",
67 .offset = MTDPART_OFS_APPEND,
68 .size = MTDPART_SIZ_FULL,
69 .mask_flags = 0
70 }
71 };
72
73 static struct flash_platform_data sdp2430_flash_data = {
74 .map_name = "cfi_probe",
75 .width = 2,
76 .parts = sdp2430_partitions,
77 .nr_parts = ARRAY_SIZE(sdp2430_partitions),
78 };
79
80 static struct resource sdp2430_flash_resource = {
81 .start = SDP2430_CS0_BASE,
82 .end = SDP2430_CS0_BASE + SZ_64M - 1,
83 .flags = IORESOURCE_MEM,
84 };
85
86 static struct platform_device sdp2430_flash_device = {
87 .name = "omapflash",
88 .id = 0,
89 .dev = {
90 .platform_data = &sdp2430_flash_data,
91 },
92 .num_resources = 1,
93 .resource = &sdp2430_flash_resource,
94 };
95
96 static struct resource sdp2430_smc91x_resources[] = {
97 [0] = {
98 .start = SDP2430_CS0_BASE,
99 .end = SDP2430_CS0_BASE + SZ_64M - 1,
100 .flags = IORESOURCE_MEM,
101 },
102 [1] = {
103 .start = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
104 .end = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
105 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
106 },
107 };
108
109 static struct platform_device sdp2430_smc91x_device = {
110 .name = "smc91x",
111 .id = -1,
112 .num_resources = ARRAY_SIZE(sdp2430_smc91x_resources),
113 .resource = sdp2430_smc91x_resources,
114 };
115
116 static struct platform_device *sdp2430_devices[] __initdata = {
117 &sdp2430_smc91x_device,
118 &sdp2430_flash_device,
119 };
120
121 static inline void __init sdp2430_init_smc91x(void)
122 {
123 int eth_cs;
124 unsigned long cs_mem_base;
125 unsigned int rate;
126 struct clk *gpmc_fck;
127
128 eth_cs = SDP2430_SMC91X_CS;
129
130 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
131 if (IS_ERR(gpmc_fck)) {
132 WARN_ON(1);
133 return;
134 }
135
136 clk_enable(gpmc_fck);
137 rate = clk_get_rate(gpmc_fck);
138
139 /* Make sure CS1 timings are correct, for 2430 always muxed */
140 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
141
142 if (rate >= 160000000) {
143 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
144 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
145 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
146 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
147 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
148 } else if (rate >= 130000000) {
149 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
150 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
151 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
152 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
153 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
154 } else { /* rate = 100000000 */
155 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
156 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
157 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
158 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
159 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
160 }
161
162 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
163 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
164 goto out;
165 }
166
167 sdp2430_smc91x_resources[0].start = cs_mem_base + 0x300;
168 sdp2430_smc91x_resources[0].end = cs_mem_base + 0x30f;
169 udelay(100);
170
171 if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ) < 0) {
172 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
173 OMAP24XX_ETHR_GPIO_IRQ);
174 gpmc_cs_free(eth_cs);
175 goto out;
176 }
177 omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ, 1);
178
179 out:
180 clk_disable(gpmc_fck);
181 clk_put(gpmc_fck);
182 }
183
184 static void __init omap_2430sdp_init_irq(void)
185 {
186 omap2_init_common_hw();
187 omap_init_irq();
188 omap_gpio_init();
189 sdp2430_init_smc91x();
190 }
191
192 static struct omap_uart_config sdp2430_uart_config __initdata = {
193 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
194 };
195
196 static struct omap_board_config_kernel sdp2430_config[] = {
197 {OMAP_TAG_UART, &sdp2430_uart_config},
198 };
199
200 static void __init omap_2430sdp_init(void)
201 {
202 platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices));
203 omap_board_config = sdp2430_config;
204 omap_board_config_size = ARRAY_SIZE(sdp2430_config);
205 omap_serial_init();
206 }
207
208 static void __init omap_2430sdp_map_io(void)
209 {
210 omap2_set_globals_243x();
211 omap2_map_common_io();
212 }
213
214 MACHINE_START(OMAP_2430SDP, "OMAP2430 sdp2430 board")
215 /* Maintainer: Syed Khasim - Texas Instruments Inc */
216 .phys_io = 0x48000000,
217 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
218 .boot_params = 0x80000100,
219 .map_io = omap_2430sdp_map_io,
220 .init_irq = omap_2430sdp_init_irq,
221 .init_machine = omap_2430sdp_init,
222 .timer = &omap_timer,
223 MACHINE_END
This page took 0.038819 seconds and 6 git commands to generate.