]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-3430sdp.c
Merge linux-2.6
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-3430sdp.c
1 /*
2  * linux/arch/arm/mach-omap2/board-3430sdp.c
3  *
4  * Copyright (C) 2007 Texas Instruments
5  *
6  * Modified from mach-omap2/board-generic.c
7  *
8  * Initial code: Syed Mohammed Khasim
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/partitions.h>
20 #include <linux/delay.h>
21 #include <linux/workqueue.h>
22 #include <linux/err.h>
23 #include <linux/clk.h>
24
25 #include <asm/hardware.h>
26 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29 #include <asm/mach/flash.h>
30
31 #include <asm/arch/gpio.h>
32 #include <asm/arch/mux.h>
33 #include <asm/arch/board.h>
34 #include <asm/arch/common.h>
35 #include <asm/arch/dma.h>
36 #include <asm/arch/gpmc.h>
37
38 #include <asm/io.h>
39 #include <asm/delay.h>
40
41 #define SDP3430_FLASH_CS        0
42 #define SDP3430_SMC91X_CS       3
43
44 static struct mtd_partition sdp3430_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
75 static struct flash_platform_data sdp3430_flash_data = {
76         .map_name       = "cfi_probe",
77         .width          = 2,
78         .parts          = sdp3430_partitions,
79         .nr_parts       = ARRAY_SIZE(sdp3430_partitions),
80 };
81
82 static struct resource sdp3430_flash_resource = {
83         .start          = FLASH_BASE,
84         .end            = FLASH_BASE + SZ_64M - 1,
85         .flags          = IORESOURCE_MEM,
86 };
87
88 static struct platform_device sdp3430_flash_device = {
89         .name           = "omapflash",
90         .id             = 0,
91         .dev            = {
92                 .platform_data  = &sdp3430_flash_data,
93         },
94         .num_resources  = 1,
95         .resource       = &sdp3430_flash_resource,
96 };
97
98 static struct resource sdp3430_smc91x_resources[] = {
99         [0] = {
100                 .start  = OMAP34XX_ETHR_START,
101                 .end    = OMAP34XX_ETHR_START + SZ_4K,
102                 .flags          = IORESOURCE_MEM,
103         },
104         [1] = {
105                 .start          = OMAP_GPIO_IRQ(OMAP34XX_ETHR_GPIO_IRQ),
106                 .end    = 0,
107                 .flags          = IORESOURCE_IRQ,
108         },
109 };
110
111 static struct platform_device sdp3430_smc91x_device = {
112         .name           = "smc91x",
113         .id             = -1,
114         .num_resources  = ARRAY_SIZE(sdp3430_smc91x_resources),
115         .resource       = sdp3430_smc91x_resources,
116 };
117
118 static struct platform_device *sdp3430_devices[] __initdata = {
119         &sdp3430_smc91x_device,
120         &sdp3430_flash_device,
121 };
122
123 static inline void __init sdp3430_init_smc91x(void)
124 {
125         int eth_cs;
126         unsigned long cs_mem_base;
127         unsigned int rate;
128         struct clk *l3ck;
129
130         eth_cs  = SDP3430_SMC91X_CS;
131
132         l3ck = clk_get(NULL, "core_l3_ck");
133         if (IS_ERR(l3ck))
134                 rate = 100000000;
135         else
136                 rate = clk_get_rate(l3ck);
137
138         if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
139                 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
140                 return;
141         }
142
143         sdp3430_smc91x_resources[0].start = cs_mem_base + 0x0;
144         sdp3430_smc91x_resources[0].end   = cs_mem_base + 0xf;
145         udelay(100);
146
147         if (omap_request_gpio(OMAP34XX_ETHR_GPIO_IRQ) < 0) {
148                 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
149                         OMAP34XX_ETHR_GPIO_IRQ);
150                 return;
151         }
152         omap_set_gpio_direction(OMAP34XX_ETHR_GPIO_IRQ, 1);
153 }
154
155 static void __init omap_3430sdp_init_irq(void)
156 {
157         omap2_init_common_hw();
158         omap_init_irq();
159         omap_gpio_init();
160         sdp3430_init_smc91x();
161 }
162
163 static struct omap_uart_config sdp3430_uart_config __initdata = {
164         .enabled_uarts  = ((1 << 0) | (1 << 1) | (1 << 2)),
165 };
166
167 static struct omap_board_config_kernel sdp3430_config[] = {
168         { OMAP_TAG_UART,        &sdp3430_uart_config },
169 };
170
171 static void __init omap_3430sdp_init(void)
172 {
173         platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
174         omap_board_config = sdp3430_config;
175         omap_board_config_size = ARRAY_SIZE(sdp3430_config);
176         omap_serial_init();
177 }
178
179 static void __init omap_3430sdp_map_io(void)
180 {
181         omap2_map_common_io();
182 }
183
184 MACHINE_START(OMAP_3430SDP, "OMAP3430 3430SDP board")
185         /* Maintainer: Syed Khasim - Texas Instruments Inc */
186         .phys_io        = 0x48000000,
187         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
188         .boot_params    = 0x80000100,
189         .map_io         = omap_3430sdp_map_io,
190         .init_irq       = omap_3430sdp_init_irq,
191         .init_machine   = omap_3430sdp_init,
192         .timer          = &omap_timer,
193 MACHINE_END