blob: 83fa37211d77c1a1b04b1c68f0f913d5ea47d97c [file] [log] [blame]
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -08001/*
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>
Tony Lindgren90c62bf2008-12-10 17:37:17 -080022#include <linux/i2c/twl4030.h>
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -080023#include <linux/err.h>
24#include <linux/clk.h>
Russell Kingfced80c2008-09-06 12:10:45 +010025#include <linux/io.h>
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -080026
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/hardware.h>
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -080028#include <asm/mach-types.h>
29#include <asm/mach/arch.h>
30#include <asm/mach/map.h>
31#include <asm/mach/flash.h>
32
Russell Kinga09e64f2008-08-05 16:14:15 +010033#include <mach/gpio.h>
34#include <mach/mux.h>
35#include <mach/board.h>
36#include <mach/common.h>
37#include <mach/gpmc.h>
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -080038
Tony Lindgren90c62bf2008-12-10 17:37:17 -080039#include "mmc-twl4030.h"
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -080040
41#define SDP2430_FLASH_CS 0
42#define SDP2430_SMC91X_CS 5
43
44static struct mtd_partition sdp2430_partitions[] = {
45 /* bootloader (U-Boot, etc) in first sector */
46 {
47 .name = "bootloader",
48 .offset = 0,
49 .size = SZ_256K,
50 .mask_flags = MTD_WRITEABLE, /* force read-only */
51 },
52 /* bootloader params in the next sector */
53 {
54 .name = "params",
55 .offset = MTDPART_OFS_APPEND,
56 .size = SZ_128K,
57 .mask_flags = 0,
58 },
59 /* kernel */
60 {
61 .name = "kernel",
62 .offset = MTDPART_OFS_APPEND,
63 .size = SZ_2M,
64 .mask_flags = 0
65 },
66 /* file system */
67 {
68 .name = "filesystem",
69 .offset = MTDPART_OFS_APPEND,
70 .size = MTDPART_SIZ_FULL,
71 .mask_flags = 0
72 }
73};
74
75static struct flash_platform_data sdp2430_flash_data = {
76 .map_name = "cfi_probe",
77 .width = 2,
78 .parts = sdp2430_partitions,
79 .nr_parts = ARRAY_SIZE(sdp2430_partitions),
80};
81
82static struct resource sdp2430_flash_resource = {
83 .start = SDP2430_CS0_BASE,
84 .end = SDP2430_CS0_BASE + SZ_64M - 1,
85 .flags = IORESOURCE_MEM,
86};
87
88static struct platform_device sdp2430_flash_device = {
89 .name = "omapflash",
90 .id = 0,
91 .dev = {
92 .platform_data = &sdp2430_flash_data,
93 },
94 .num_resources = 1,
95 .resource = &sdp2430_flash_resource,
96};
97
98static struct resource sdp2430_smc91x_resources[] = {
99 [0] = {
100 .start = SDP2430_CS0_BASE,
101 .end = SDP2430_CS0_BASE + SZ_64M - 1,
102 .flags = IORESOURCE_MEM,
103 },
104 [1] = {
105 .start = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
106 .end = OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ),
Russell Kinga8149172008-08-27 14:29:40 +0100107 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800108 },
109};
110
111static struct platform_device sdp2430_smc91x_device = {
112 .name = "smc91x",
113 .id = -1,
114 .num_resources = ARRAY_SIZE(sdp2430_smc91x_resources),
115 .resource = sdp2430_smc91x_resources,
116};
117
118static struct platform_device *sdp2430_devices[] __initdata = {
119 &sdp2430_smc91x_device,
120 &sdp2430_flash_device,
121};
122
123static inline void __init sdp2430_init_smc91x(void)
124{
125 int eth_cs;
126 unsigned long cs_mem_base;
127 unsigned int rate;
Paul Walmsley44595982008-03-18 10:04:51 +0200128 struct clk *gpmc_fck;
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800129
130 eth_cs = SDP2430_SMC91X_CS;
131
Paul Walmsley44595982008-03-18 10:04:51 +0200132 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
133 if (IS_ERR(gpmc_fck)) {
134 WARN_ON(1);
135 return;
136 }
137
138 clk_enable(gpmc_fck);
139 rate = clk_get_rate(gpmc_fck);
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800140
141 /* Make sure CS1 timings are correct, for 2430 always muxed */
142 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
143
144 if (rate >= 160000000) {
145 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
146 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
147 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
148 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
149 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
150 } else if (rate >= 130000000) {
151 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
152 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
153 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
154 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
155 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
156 } else { /* rate = 100000000 */
157 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
158 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
159 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
160 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
161 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
162 }
163
164 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
165 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
Paul Walmsley44595982008-03-18 10:04:51 +0200166 goto out;
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800167 }
168
169 sdp2430_smc91x_resources[0].start = cs_mem_base + 0x300;
170 sdp2430_smc91x_resources[0].end = cs_mem_base + 0x30f;
171 udelay(100);
172
Jarkko Nikulaf2d18fe2008-12-10 17:35:30 -0800173 if (gpio_request(OMAP24XX_ETHR_GPIO_IRQ, "SMC91x irq") < 0) {
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800174 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
175 OMAP24XX_ETHR_GPIO_IRQ);
176 gpmc_cs_free(eth_cs);
Paul Walmsley44595982008-03-18 10:04:51 +0200177 goto out;
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800178 }
David Brownell40e39252008-12-10 17:35:26 -0800179 gpio_direction_input(OMAP24XX_ETHR_GPIO_IRQ);
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800180
Paul Walmsley44595982008-03-18 10:04:51 +0200181out:
182 clk_disable(gpmc_fck);
183 clk_put(gpmc_fck);
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800184}
185
186static void __init omap_2430sdp_init_irq(void)
187{
188 omap2_init_common_hw();
189 omap_init_irq();
190 omap_gpio_init();
191 sdp2430_init_smc91x();
192}
193
194static struct omap_uart_config sdp2430_uart_config __initdata = {
195 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
196};
197
198static struct omap_board_config_kernel sdp2430_config[] = {
199 {OMAP_TAG_UART, &sdp2430_uart_config},
200};
201
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800202
203static struct twl4030_gpio_platform_data sdp2430_gpio_data = {
204 .gpio_base = OMAP_MAX_GPIO_LINES,
205 .irq_base = TWL4030_GPIO_IRQ_BASE,
206 .irq_end = TWL4030_GPIO_IRQ_END,
207};
208
209static struct twl4030_platform_data sdp2430_twldata = {
210 .irq_base = TWL4030_IRQ_BASE,
211 .irq_end = TWL4030_IRQ_END,
212
213 /* platform_data for children goes here */
214 .gpio = &sdp2430_gpio_data,
215};
216
217static struct i2c_board_info __initdata sdp2430_i2c_boardinfo[] = {
218 {
219 I2C_BOARD_INFO("twl4030", 0x48),
220 .flags = I2C_CLIENT_WAKE,
221 .irq = INT_24XX_SYS_NIRQ,
222 .platform_data = &sdp2430_twldata,
223 },
224};
225
226static int __init omap2430_i2c_init(void)
227{
228 omap_register_i2c_bus(1, 400, NULL, 0);
229 omap_register_i2c_bus(2, 2600, sdp2430_i2c_boardinfo,
230 ARRAY_SIZE(sdp2430_i2c_boardinfo));
231 return 0;
232}
233
234static struct twl4030_hsmmc_info mmc[] __initdata = {
235 {
236 .mmc = 1,
237 .wires = 4,
238 .gpio_cd = -EINVAL,
239 .gpio_wp = -EINVAL,
240 .ext_clock = 1,
241 },
242 {} /* Terminator */
243};
244
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800245static void __init omap_2430sdp_init(void)
246{
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800247 omap2430_i2c_init();
248
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800249 platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices));
250 omap_board_config = sdp2430_config;
251 omap_board_config_size = ARRAY_SIZE(sdp2430_config);
252 omap_serial_init();
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800253 twl4030_mmc_init(mmc);
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800254}
255
256static void __init omap_2430sdp_map_io(void)
257{
Paul Walmsleyc8d2eb82008-05-07 16:55:13 -0700258 omap2_set_globals_243x();
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800259 omap2_map_common_io();
260}
261
262MACHINE_START(OMAP_2430SDP, "OMAP2430 sdp2430 board")
263 /* Maintainer: Syed Khasim - Texas Instruments Inc */
264 .phys_io = 0x48000000,
265 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
266 .boot_params = 0x80000100,
267 .map_io = omap_2430sdp_map_io,
268 .init_irq = omap_2430sdp_init_irq,
269 .init_machine = omap_2430sdp_init,
270 .timer = &omap_timer,
271MACHINE_END