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