Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
[sfrench/cifs-2.6.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/i2c.h>
31 #include <linux/spi/spi.h>
32 #include <linux/gpio/machine.h>
33
34 #include <sound/cs4271.h>
35
36 #include <mach/hardware.h>
37 #include <linux/platform_data/video-ep93xx.h>
38 #include <linux/platform_data/spi-ep93xx.h>
39 #include <mach/gpio-ep93xx.h>
40
41 #include <asm/mach-types.h>
42 #include <asm/mach/arch.h>
43
44 #include "soc.h"
45
46 static void __init edb93xx_register_flash(void)
47 {
48         if (machine_is_edb9307() || machine_is_edb9312() ||
49             machine_is_edb9315()) {
50                 ep93xx_register_flash(4, EP93XX_CS6_PHYS_BASE, SZ_32M);
51         } else {
52                 ep93xx_register_flash(2, EP93XX_CS6_PHYS_BASE, SZ_16M);
53         }
54 }
55
56 static struct ep93xx_eth_data __initdata edb93xx_eth_data = {
57         .phy_id         = 1,
58 };
59
60
61 /*************************************************************************
62  * EDB93xx i2c peripheral handling
63  *************************************************************************/
64
65 static struct i2c_board_info __initdata edb93xxa_i2c_board_info[] = {
66         {
67                 I2C_BOARD_INFO("isl1208", 0x6f),
68         },
69 };
70
71 static struct i2c_board_info __initdata edb93xx_i2c_board_info[] = {
72         {
73                 I2C_BOARD_INFO("ds1337", 0x68),
74         },
75 };
76
77 static void __init edb93xx_register_i2c(void)
78 {
79         if (machine_is_edb9302a() || machine_is_edb9307a() ||
80             machine_is_edb9315a()) {
81                 ep93xx_register_i2c(edb93xxa_i2c_board_info,
82                                     ARRAY_SIZE(edb93xxa_i2c_board_info));
83         } else if (machine_is_edb9302() || machine_is_edb9307()
84                 || machine_is_edb9312() || machine_is_edb9315()) {
85                 ep93xx_register_i2c(edb93xx_i2c_board_info,
86                                     ARRAY_SIZE(edb93xx_i2c_board_info));
87         }
88 }
89
90
91 /*************************************************************************
92  * EDB93xx SPI peripheral handling
93  *************************************************************************/
94 static struct cs4271_platform_data edb93xx_cs4271_data = {
95         .gpio_nreset    = -EINVAL,      /* filled in later */
96 };
97
98 static struct spi_board_info edb93xx_spi_board_info[] __initdata = {
99         {
100                 .modalias               = "cs4271",
101                 .platform_data          = &edb93xx_cs4271_data,
102                 .max_speed_hz           = 6000000,
103                 .bus_num                = 0,
104                 .chip_select            = 0,
105                 .mode                   = SPI_MODE_3,
106         },
107 };
108
109 static struct gpiod_lookup_table edb93xx_spi_cs_gpio_table = {
110         .dev_id = "ep93xx-spi.0",
111         .table = {
112                 GPIO_LOOKUP("A", 6, "cs", GPIO_ACTIVE_LOW),
113                 { },
114         },
115 };
116
117 static struct ep93xx_spi_info edb93xx_spi_info __initdata = {
118         /* Intentionally left blank */
119 };
120
121 static void __init edb93xx_register_spi(void)
122 {
123         if (machine_is_edb9301() || machine_is_edb9302())
124                 edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_EGPIO1;
125         else if (machine_is_edb9302a() || machine_is_edb9307a())
126                 edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_H(2);
127         else if (machine_is_edb9315a())
128                 edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_EGPIO14;
129
130         gpiod_add_lookup_table(&edb93xx_spi_cs_gpio_table);
131         ep93xx_register_spi(&edb93xx_spi_info, edb93xx_spi_board_info,
132                             ARRAY_SIZE(edb93xx_spi_board_info));
133 }
134
135
136 /*************************************************************************
137  * EDB93xx I2S
138  *************************************************************************/
139 static struct platform_device edb93xx_audio_device = {
140         .name           = "edb93xx-audio",
141         .id             = -1,
142 };
143
144 static int __init edb93xx_has_audio(void)
145 {
146         return (machine_is_edb9301() || machine_is_edb9302() ||
147                 machine_is_edb9302a() || machine_is_edb9307a() ||
148                 machine_is_edb9315a());
149 }
150
151 static void __init edb93xx_register_i2s(void)
152 {
153         if (edb93xx_has_audio()) {
154                 ep93xx_register_i2s();
155                 platform_device_register(&edb93xx_audio_device);
156         }
157 }
158
159
160 /*************************************************************************
161  * EDB93xx pwm
162  *************************************************************************/
163 static void __init edb93xx_register_pwm(void)
164 {
165         if (machine_is_edb9301() ||
166             machine_is_edb9302() || machine_is_edb9302a()) {
167                 /* EP9301 and EP9302 only have pwm.1 (EGPIO14) */
168                 ep93xx_register_pwm(0, 1);
169         } else if (machine_is_edb9307() || machine_is_edb9307a()) {
170                 /* EP9307 only has pwm.0 (PWMOUT) */
171                 ep93xx_register_pwm(1, 0);
172         } else {
173                 /* EP9312 and EP9315 have both */
174                 ep93xx_register_pwm(1, 1);
175         }
176 }
177
178
179 /*************************************************************************
180  * EDB93xx framebuffer
181  *************************************************************************/
182 static struct ep93xxfb_mach_info __initdata edb93xxfb_info = {
183         .flags          = 0,
184 };
185
186 static int __init edb93xx_has_fb(void)
187 {
188         /* These platforms have an ep93xx with video capability */
189         return machine_is_edb9307() || machine_is_edb9307a() ||
190                machine_is_edb9312() || machine_is_edb9315() ||
191                machine_is_edb9315a();
192 }
193
194 static void __init edb93xx_register_fb(void)
195 {
196         if (!edb93xx_has_fb())
197                 return;
198
199         if (machine_is_edb9307a() || machine_is_edb9315a())
200                 edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN0;
201         else
202                 edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN3;
203
204         ep93xx_register_fb(&edb93xxfb_info);
205 }
206
207
208 /*************************************************************************
209  * EDB93xx IDE
210  *************************************************************************/
211 static int __init edb93xx_has_ide(void)
212 {
213         /*
214          * Although EDB9312 and EDB9315 do have IDE capability, they have
215          * INTRQ line wired as pull-up, which makes using IDE interface
216          * problematic.
217          */
218         return machine_is_edb9312() || machine_is_edb9315() ||
219                machine_is_edb9315a();
220 }
221
222 static void __init edb93xx_register_ide(void)
223 {
224         if (!edb93xx_has_ide())
225                 return;
226
227         ep93xx_register_ide();
228 }
229
230
231 static void __init edb93xx_init_machine(void)
232 {
233         ep93xx_init_devices();
234         edb93xx_register_flash();
235         ep93xx_register_eth(&edb93xx_eth_data, 1);
236         edb93xx_register_i2c();
237         edb93xx_register_spi();
238         edb93xx_register_i2s();
239         edb93xx_register_pwm();
240         edb93xx_register_fb();
241         edb93xx_register_ide();
242         ep93xx_register_adc();
243 }
244
245
246 #ifdef CONFIG_MACH_EDB9301
247 MACHINE_START(EDB9301, "Cirrus Logic EDB9301 Evaluation Board")
248         /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
249         .atag_offset    = 0x100,
250         .map_io         = ep93xx_map_io,
251         .init_irq       = ep93xx_init_irq,
252         .init_time      = ep93xx_timer_init,
253         .init_machine   = edb93xx_init_machine,
254         .init_late      = ep93xx_init_late,
255         .restart        = ep93xx_restart,
256 MACHINE_END
257 #endif
258
259 #ifdef CONFIG_MACH_EDB9302
260 MACHINE_START(EDB9302, "Cirrus Logic EDB9302 Evaluation Board")
261         /* Maintainer: George Kashperko <george@chas.com.ua> */
262         .atag_offset    = 0x100,
263         .map_io         = ep93xx_map_io,
264         .init_irq       = ep93xx_init_irq,
265         .init_time      = ep93xx_timer_init,
266         .init_machine   = edb93xx_init_machine,
267         .init_late      = ep93xx_init_late,
268         .restart        = ep93xx_restart,
269 MACHINE_END
270 #endif
271
272 #ifdef CONFIG_MACH_EDB9302A
273 MACHINE_START(EDB9302A, "Cirrus Logic EDB9302A Evaluation Board")
274         /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
275         .atag_offset    = 0x100,
276         .map_io         = ep93xx_map_io,
277         .init_irq       = ep93xx_init_irq,
278         .init_time      = ep93xx_timer_init,
279         .init_machine   = edb93xx_init_machine,
280         .init_late      = ep93xx_init_late,
281         .restart        = ep93xx_restart,
282 MACHINE_END
283 #endif
284
285 #ifdef CONFIG_MACH_EDB9307
286 MACHINE_START(EDB9307, "Cirrus Logic EDB9307 Evaluation Board")
287         /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
288         .atag_offset    = 0x100,
289         .map_io         = ep93xx_map_io,
290         .init_irq       = ep93xx_init_irq,
291         .init_time      = ep93xx_timer_init,
292         .init_machine   = edb93xx_init_machine,
293         .init_late      = ep93xx_init_late,
294         .restart        = ep93xx_restart,
295 MACHINE_END
296 #endif
297
298 #ifdef CONFIG_MACH_EDB9307A
299 MACHINE_START(EDB9307A, "Cirrus Logic EDB9307A Evaluation Board")
300         /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
301         .atag_offset    = 0x100,
302         .map_io         = ep93xx_map_io,
303         .init_irq       = ep93xx_init_irq,
304         .init_time      = ep93xx_timer_init,
305         .init_machine   = edb93xx_init_machine,
306         .init_late      = ep93xx_init_late,
307         .restart        = ep93xx_restart,
308 MACHINE_END
309 #endif
310
311 #ifdef CONFIG_MACH_EDB9312
312 MACHINE_START(EDB9312, "Cirrus Logic EDB9312 Evaluation Board")
313         /* Maintainer: Toufeeq Hussain <toufeeq_hussain@infosys.com> */
314         .atag_offset    = 0x100,
315         .map_io         = ep93xx_map_io,
316         .init_irq       = ep93xx_init_irq,
317         .init_time      = ep93xx_timer_init,
318         .init_machine   = edb93xx_init_machine,
319         .init_late      = ep93xx_init_late,
320         .restart        = ep93xx_restart,
321 MACHINE_END
322 #endif
323
324 #ifdef CONFIG_MACH_EDB9315
325 MACHINE_START(EDB9315, "Cirrus Logic EDB9315 Evaluation Board")
326         /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
327         .atag_offset    = 0x100,
328         .map_io         = ep93xx_map_io,
329         .init_irq       = ep93xx_init_irq,
330         .init_time      = ep93xx_timer_init,
331         .init_machine   = edb93xx_init_machine,
332         .init_late      = ep93xx_init_late,
333         .restart        = ep93xx_restart,
334 MACHINE_END
335 #endif
336
337 #ifdef CONFIG_MACH_EDB9315A
338 MACHINE_START(EDB9315A, "Cirrus Logic EDB9315A Evaluation Board")
339         /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
340         .atag_offset    = 0x100,
341         .map_io         = ep93xx_map_io,
342         .init_irq       = ep93xx_init_irq,
343         .init_time      = ep93xx_timer_init,
344         .init_machine   = edb93xx_init_machine,
345         .init_late      = ep93xx_init_late,
346         .restart        = ep93xx_restart,
347 MACHINE_END
348 #endif