Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph...
[pandora-kernel.git] / arch / arm / mach-ep93xx / edb93xx.c
1 /*
2  * arch/arm/mach-ep93xx/edb93xx.c
3  * Cirrus Logic EDB93xx Development Board support.
4  *
5  * EDB93XX, EDB9301, EDB9307A
6  * Copyright (C) 2008-2009 H Hartley Sweeten <hsweeten@visionengravers.com>
7  *
8  * EDB9302
9  * Copyright (C) 2006 George Kashperko <george@chas.com.ua>
10  *
11  * EDB9302A, EDB9315, EDB9315A
12  * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
13  *
14  * EDB9307
15  * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org>
16  *
17  * EDB9312
18  * Copyright (C) 2006 Infosys Technologies Limited
19  *                    Toufeeq Hussain <toufeeq_hussain@infosys.com>
20  *
21  * This program is free software; you can redistribute it and/or modify
22  * it under the terms of the GNU General Public License as published by
23  * the Free Software Foundation; either version 2 of the License, or (at
24  * your option) any later version.
25  */
26
27 #include <linux/kernel.h>
28 #include <linux/init.h>
29 #include <linux/platform_device.h>
30 #include <linux/mtd/physmap.h>
31 #include <linux/gpio.h>
32 #include <linux/i2c.h>
33 #include <linux/i2c-gpio.h>
34
35 #include <mach/hardware.h>
36
37 #include <asm/mach-types.h>
38 #include <asm/mach/arch.h>
39
40
41 static struct physmap_flash_data edb93xx_flash_data;
42
43 static struct resource edb93xx_flash_resource = {
44         .flags          = IORESOURCE_MEM,
45 };
46
47 static struct platform_device edb93xx_flash = {
48         .name           = "physmap-flash",
49         .id             = 0,
50         .dev            = {
51                 .platform_data  = &edb93xx_flash_data,
52         },
53         .num_resources  = 1,
54         .resource       = &edb93xx_flash_resource,
55 };
56
57 static void __init __edb93xx_register_flash(unsigned int width,
58                         resource_size_t start, resource_size_t size)
59 {
60         edb93xx_flash_data.width        = width;
61         edb93xx_flash_resource.start    = start;
62         edb93xx_flash_resource.end      = start + size - 1;
63
64         platform_device_register(&edb93xx_flash);
65 }
66
67 static void __init edb93xx_register_flash(void)
68 {
69         if (machine_is_edb9307() || machine_is_edb9312() ||
70             machine_is_edb9315()) {
71                 __edb93xx_register_flash(4, EP93XX_CS6_PHYS_BASE, SZ_32M);
72         } else {
73                 __edb93xx_register_flash(2, EP93XX_CS6_PHYS_BASE, SZ_16M);
74         }
75 }
76
77 static struct ep93xx_eth_data edb93xx_eth_data = {
78         .phy_id         = 1,
79 };
80
81
82 /*************************************************************************
83  * EDB93xx i2c peripheral handling
84  *************************************************************************/
85 static struct i2c_gpio_platform_data edb93xx_i2c_gpio_data = {
86         .sda_pin                = EP93XX_GPIO_LINE_EEDAT,
87         .sda_is_open_drain      = 0,
88         .scl_pin                = EP93XX_GPIO_LINE_EECLK,
89         .scl_is_open_drain      = 0,
90         .udelay                 = 0,    /* default to 100 kHz */
91         .timeout                = 0,    /* default to 100 ms */
92 };
93
94 static struct i2c_board_info __initdata edb93xxa_i2c_board_info[] = {
95         {
96                 I2C_BOARD_INFO("isl1208", 0x6f),
97         },
98 };
99
100 static struct i2c_board_info __initdata edb93xx_i2c_board_info[] = {
101         {
102                 I2C_BOARD_INFO("ds1337", 0x68),
103         },
104 };
105
106 static void __init edb93xx_register_i2c(void)
107 {
108         if (machine_is_edb9302a() || machine_is_edb9307a() ||
109             machine_is_edb9315a()) {
110                 ep93xx_register_i2c(&edb93xx_i2c_gpio_data,
111                                     edb93xxa_i2c_board_info,
112                                     ARRAY_SIZE(edb93xxa_i2c_board_info));
113         } else if (machine_is_edb9307() || machine_is_edb9312() ||
114                    machine_is_edb9315()) {
115                 ep93xx_register_i2c(&edb93xx_i2c_gpio_data,
116                                     edb93xx_i2c_board_info,
117                                     ARRAY_SIZE(edb93xx_i2c_board_info));
118         }
119 }
120
121
122 /*************************************************************************
123  * EDB93xx pwm
124  *************************************************************************/
125 static void __init edb93xx_register_pwm(void)
126 {
127         if (machine_is_edb9301() ||
128             machine_is_edb9302() || machine_is_edb9302a()) {
129                 /* EP9301 and EP9302 only have pwm.1 (EGPIO14) */
130                 ep93xx_register_pwm(0, 1);
131         } else if (machine_is_edb9307() || machine_is_edb9307a()) {
132                 /* EP9307 only has pwm.0 (PWMOUT) */
133                 ep93xx_register_pwm(1, 0);
134         } else {
135                 /* EP9312 and EP9315 have both */
136                 ep93xx_register_pwm(1, 1);
137         }
138 }
139
140
141 static void __init edb93xx_init_machine(void)
142 {
143         ep93xx_init_devices();
144         edb93xx_register_flash();
145         ep93xx_register_eth(&edb93xx_eth_data, 1);
146         edb93xx_register_i2c();
147         edb93xx_register_pwm();
148 }
149
150
151 #ifdef CONFIG_MACH_EDB9301
152 MACHINE_START(EDB9301, "Cirrus Logic EDB9301 Evaluation Board")
153         /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
154         .phys_io        = EP93XX_APB_PHYS_BASE,
155         .io_pg_offst    = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
156         .boot_params    = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
157         .map_io         = ep93xx_map_io,
158         .init_irq       = ep93xx_init_irq,
159         .timer          = &ep93xx_timer,
160         .init_machine   = edb93xx_init_machine,
161 MACHINE_END
162 #endif
163
164 #ifdef CONFIG_MACH_EDB9302
165 MACHINE_START(EDB9302, "Cirrus Logic EDB9302 Evaluation Board")
166         /* Maintainer: George Kashperko <george@chas.com.ua> */
167         .phys_io        = EP93XX_APB_PHYS_BASE,
168         .io_pg_offst    = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
169         .boot_params    = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
170         .map_io         = ep93xx_map_io,
171         .init_irq       = ep93xx_init_irq,
172         .timer          = &ep93xx_timer,
173         .init_machine   = edb93xx_init_machine,
174 MACHINE_END
175 #endif
176
177 #ifdef CONFIG_MACH_EDB9302A
178 MACHINE_START(EDB9302A, "Cirrus Logic EDB9302A Evaluation Board")
179         /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
180         .phys_io        = EP93XX_APB_PHYS_BASE,
181         .io_pg_offst    = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
182         .boot_params    = EP93XX_SDCE0_PHYS_BASE + 0x100,
183         .map_io         = ep93xx_map_io,
184         .init_irq       = ep93xx_init_irq,
185         .timer          = &ep93xx_timer,
186         .init_machine   = edb93xx_init_machine,
187 MACHINE_END
188 #endif
189
190 #ifdef CONFIG_MACH_EDB9307
191 MACHINE_START(EDB9307, "Cirrus Logic EDB9307 Evaluation Board")
192         /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
193         .phys_io        = EP93XX_APB_PHYS_BASE,
194         .io_pg_offst    = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
195         .boot_params    = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
196         .map_io         = ep93xx_map_io,
197         .init_irq       = ep93xx_init_irq,
198         .timer          = &ep93xx_timer,
199         .init_machine   = edb93xx_init_machine,
200 MACHINE_END
201 #endif
202
203 #ifdef CONFIG_MACH_EDB9307A
204 MACHINE_START(EDB9307A, "Cirrus Logic EDB9307A Evaluation Board")
205         /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
206         .phys_io        = EP93XX_APB_PHYS_BASE,
207         .io_pg_offst    = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
208         .boot_params    = EP93XX_SDCE0_PHYS_BASE + 0x100,
209         .map_io         = ep93xx_map_io,
210         .init_irq       = ep93xx_init_irq,
211         .timer          = &ep93xx_timer,
212         .init_machine   = edb93xx_init_machine,
213 MACHINE_END
214 #endif
215
216 #ifdef CONFIG_MACH_EDB9312
217 MACHINE_START(EDB9312, "Cirrus Logic EDB9312 Evaluation Board")
218         /* Maintainer: Toufeeq Hussain <toufeeq_hussain@infosys.com> */
219         .phys_io        = EP93XX_APB_PHYS_BASE,
220         .io_pg_offst    = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
221         .boot_params    = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
222         .map_io         = ep93xx_map_io,
223         .init_irq       = ep93xx_init_irq,
224         .timer          = &ep93xx_timer,
225         .init_machine   = edb93xx_init_machine,
226 MACHINE_END
227 #endif
228
229 #ifdef CONFIG_MACH_EDB9315
230 MACHINE_START(EDB9315, "Cirrus Logic EDB9315 Evaluation Board")
231         /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
232         .phys_io        = EP93XX_APB_PHYS_BASE,
233         .io_pg_offst    = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
234         .boot_params    = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
235         .map_io         = ep93xx_map_io,
236         .init_irq       = ep93xx_init_irq,
237         .timer          = &ep93xx_timer,
238         .init_machine   = edb93xx_init_machine,
239 MACHINE_END
240 #endif
241
242 #ifdef CONFIG_MACH_EDB9315A
243 MACHINE_START(EDB9315A, "Cirrus Logic EDB9315A Evaluation Board")
244         /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
245         .phys_io        = EP93XX_APB_PHYS_BASE,
246         .io_pg_offst    = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
247         .boot_params    = EP93XX_SDCE0_PHYS_BASE + 0x100,
248         .map_io         = ep93xx_map_io,
249         .init_irq       = ep93xx_init_irq,
250         .timer          = &ep93xx_timer,
251         .init_machine   = edb93xx_init_machine,
252 MACHINE_END
253 #endif