blob: d4d6385cad7c7e3275370f8f67138c1a9398b1a5 [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>
22#include <linux/err.h>
23#include <linux/clk.h>
24
Russell Kinga09e64f2008-08-05 16:14:15 +010025#include <mach/hardware.h>
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -080026#include <asm/mach-types.h>
27#include <asm/mach/arch.h>
28#include <asm/mach/map.h>
29#include <asm/mach/flash.h>
30
Russell Kinga09e64f2008-08-05 16:14:15 +010031#include <mach/gpio.h>
32#include <mach/mux.h>
33#include <mach/board.h>
34#include <mach/common.h>
35#include <mach/gpmc.h>
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -080036
37#include <asm/io.h>
38
39
40#define SDP2430_FLASH_CS 0
41#define SDP2430_SMC91X_CS 5
42
43static 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
74static 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
81static struct resource sdp2430_flash_resource = {
82 .start = SDP2430_CS0_BASE,
83 .end = SDP2430_CS0_BASE + SZ_64M - 1,
84 .flags = IORESOURCE_MEM,
85};
86
87static 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
97static 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),
Russell Kinge7b3dc72008-01-14 22:30:10 +0000106 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800107 },
108};
109
110static 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
117static struct platform_device *sdp2430_devices[] __initdata = {
118 &sdp2430_smc91x_device,
119 &sdp2430_flash_device,
120};
121
122static inline void __init sdp2430_init_smc91x(void)
123{
124 int eth_cs;
125 unsigned long cs_mem_base;
126 unsigned int rate;
Paul Walmsley44595982008-03-18 10:04:51 +0200127 struct clk *gpmc_fck;
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800128
129 eth_cs = SDP2430_SMC91X_CS;
130
Paul Walmsley44595982008-03-18 10:04:51 +0200131 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
132 if (IS_ERR(gpmc_fck)) {
133 WARN_ON(1);
134 return;
135 }
136
137 clk_enable(gpmc_fck);
138 rate = clk_get_rate(gpmc_fck);
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800139
140 /* Make sure CS1 timings are correct, for 2430 always muxed */
141 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
142
143 if (rate >= 160000000) {
144 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
145 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
146 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
147 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
148 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
149 } else if (rate >= 130000000) {
150 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
151 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
152 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
153 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
154 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
155 } else { /* rate = 100000000 */
156 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
157 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
158 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
159 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
160 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
161 }
162
163 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
164 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
Paul Walmsley44595982008-03-18 10:04:51 +0200165 goto out;
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800166 }
167
168 sdp2430_smc91x_resources[0].start = cs_mem_base + 0x300;
169 sdp2430_smc91x_resources[0].end = cs_mem_base + 0x30f;
170 udelay(100);
171
172 if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ) < 0) {
173 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
174 OMAP24XX_ETHR_GPIO_IRQ);
175 gpmc_cs_free(eth_cs);
Paul Walmsley44595982008-03-18 10:04:51 +0200176 goto out;
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800177 }
178 omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ, 1);
179
Paul Walmsley44595982008-03-18 10:04:51 +0200180out:
181 clk_disable(gpmc_fck);
182 clk_put(gpmc_fck);
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800183}
184
185static void __init omap_2430sdp_init_irq(void)
186{
187 omap2_init_common_hw();
188 omap_init_irq();
189 omap_gpio_init();
190 sdp2430_init_smc91x();
191}
192
193static struct omap_uart_config sdp2430_uart_config __initdata = {
194 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
195};
196
197static struct omap_board_config_kernel sdp2430_config[] = {
198 {OMAP_TAG_UART, &sdp2430_uart_config},
199};
200
201static void __init omap_2430sdp_init(void)
202{
203 platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices));
204 omap_board_config = sdp2430_config;
205 omap_board_config_size = ARRAY_SIZE(sdp2430_config);
206 omap_serial_init();
207}
208
209static void __init omap_2430sdp_map_io(void)
210{
Paul Walmsleyc8d2eb82008-05-07 16:55:13 -0700211 omap2_set_globals_243x();
Syed Mohammed Khasim72d0f1c2006-12-06 17:14:05 -0800212 omap2_map_common_io();
213}
214
215MACHINE_START(OMAP_2430SDP, "OMAP2430 sdp2430 board")
216 /* Maintainer: Syed Khasim - Texas Instruments Inc */
217 .phys_io = 0x48000000,
218 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
219 .boot_params = 0x80000100,
220 .map_io = omap_2430sdp_map_io,
221 .init_irq = omap_2430sdp_init_irq,
222 .init_machine = omap_2430sdp_init,
223 .timer = &omap_timer,
224MACHINE_END