blob: 8dc51e464a4e0f16536db3debe38023db0fd21d4 [file] [log] [blame]
Hartley Sweetena2bd40d2009-05-04 19:09:25 +01001/*
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>
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010029#include <linux/platform_device.h>
Hartley Sweeten6531a992009-10-08 00:45:00 +010030#include <linux/gpio.h>
31#include <linux/i2c.h>
32#include <linux/i2c-gpio.h>
Alexander Sverdlin31bb68a2011-03-03 10:53:52 +010033#include <linux/spi/spi.h>
34
35#include <sound/cs4271.h>
Hartley Sweeten583ddaf2009-07-06 17:39:50 +010036
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010037#include <mach/hardware.h>
Hartley Sweeten13055192011-01-27 17:50:53 +010038#include <mach/fb.h>
Alexander Sverdlin31bb68a2011-03-03 10:53:52 +010039#include <mach/ep93xx_spi.h>
Hartley Sweeten583ddaf2009-07-06 17:39:50 +010040
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010041#include <asm/mach-types.h>
42#include <asm/mach/arch.h>
43
Hartley Sweeten583ddaf2009-07-06 17:39:50 +010044
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010045static void __init edb93xx_register_flash(void)
46{
47 if (machine_is_edb9307() || machine_is_edb9312() ||
48 machine_is_edb9315()) {
Hartley Sweeten16bcf782010-06-10 16:19:08 +010049 ep93xx_register_flash(4, EP93XX_CS6_PHYS_BASE, SZ_32M);
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010050 } else {
Hartley Sweeten16bcf782010-06-10 16:19:08 +010051 ep93xx_register_flash(2, EP93XX_CS6_PHYS_BASE, SZ_16M);
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010052 }
53}
54
Hartley Sweetenb370e082010-03-18 18:04:06 +010055static struct ep93xx_eth_data __initdata edb93xx_eth_data = {
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010056 .phy_id = 1,
57};
58
Hartley Sweeten6531a992009-10-08 00:45:00 +010059
60/*************************************************************************
61 * EDB93xx i2c peripheral handling
62 *************************************************************************/
Hartley Sweetenb370e082010-03-18 18:04:06 +010063static struct i2c_gpio_platform_data __initdata edb93xx_i2c_gpio_data = {
Hartley Sweeten6531a992009-10-08 00:45:00 +010064 .sda_pin = EP93XX_GPIO_LINE_EEDAT,
65 .sda_is_open_drain = 0,
66 .scl_pin = EP93XX_GPIO_LINE_EECLK,
67 .scl_is_open_drain = 0,
68 .udelay = 0, /* default to 100 kHz */
69 .timeout = 0, /* default to 100 ms */
70};
71
72static struct i2c_board_info __initdata edb93xxa_i2c_board_info[] = {
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010073 {
74 I2C_BOARD_INFO("isl1208", 0x6f),
75 },
76};
77
Hartley Sweeten6531a992009-10-08 00:45:00 +010078static struct i2c_board_info __initdata edb93xx_i2c_board_info[] = {
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010079 {
80 I2C_BOARD_INFO("ds1337", 0x68),
81 },
82};
83
84static void __init edb93xx_register_i2c(void)
85{
86 if (machine_is_edb9302a() || machine_is_edb9307a() ||
87 machine_is_edb9315a()) {
Hartley Sweeten6531a992009-10-08 00:45:00 +010088 ep93xx_register_i2c(&edb93xx_i2c_gpio_data,
89 edb93xxa_i2c_board_info,
90 ARRAY_SIZE(edb93xxa_i2c_board_info));
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010091 } else if (machine_is_edb9307() || machine_is_edb9312() ||
92 machine_is_edb9315()) {
Hartley Sweeten3d977c02009-10-14 01:56:10 +010093 ep93xx_register_i2c(&edb93xx_i2c_gpio_data,
Hartley Sweeten6531a992009-10-08 00:45:00 +010094 edb93xx_i2c_board_info,
95 ARRAY_SIZE(edb93xx_i2c_board_info));
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010096 }
97}
98
Hartley Sweeten1fbd9722010-01-11 21:38:00 +010099
100/*************************************************************************
Alexander Sverdlin31bb68a2011-03-03 10:53:52 +0100101 * EDB93xx SPI peripheral handling
102 *************************************************************************/
103static struct cs4271_platform_data edb93xx_cs4271_data = {
104 .gpio_nreset = -EINVAL, /* filled in later */
105};
106
107static int edb93xx_cs4271_hw_setup(struct spi_device *spi)
108{
109 return gpio_request_one(EP93XX_GPIO_LINE_EGPIO6,
110 GPIOF_OUT_INIT_HIGH, spi->modalias);
111}
112
113static void edb93xx_cs4271_hw_cleanup(struct spi_device *spi)
114{
115 gpio_free(EP93XX_GPIO_LINE_EGPIO6);
116}
117
118static void edb93xx_cs4271_hw_cs_control(struct spi_device *spi, int value)
119{
120 gpio_set_value(EP93XX_GPIO_LINE_EGPIO6, value);
121}
122
123static struct ep93xx_spi_chip_ops edb93xx_cs4271_hw = {
124 .setup = edb93xx_cs4271_hw_setup,
125 .cleanup = edb93xx_cs4271_hw_cleanup,
126 .cs_control = edb93xx_cs4271_hw_cs_control,
127};
128
129static struct spi_board_info edb93xx_spi_board_info[] __initdata = {
130 {
131 .modalias = "cs4271",
132 .platform_data = &edb93xx_cs4271_data,
133 .controller_data = &edb93xx_cs4271_hw,
134 .max_speed_hz = 6000000,
135 .bus_num = 0,
136 .chip_select = 0,
137 .mode = SPI_MODE_3,
138 },
139};
140
141static struct ep93xx_spi_info edb93xx_spi_info __initdata = {
142 .num_chipselect = ARRAY_SIZE(edb93xx_spi_board_info),
143};
144
145static void __init edb93xx_register_spi(void)
146{
147 if (machine_is_edb9301() || machine_is_edb9302())
148 edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_EGPIO1;
149 else if (machine_is_edb9302a() || machine_is_edb9307a())
150 edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_H(2);
151 else if (machine_is_edb9315a())
152 edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_EGPIO14;
153
154 ep93xx_register_spi(&edb93xx_spi_info, edb93xx_spi_board_info,
155 ARRAY_SIZE(edb93xx_spi_board_info));
156}
157
158
159/*************************************************************************
160 * EDB93xx I2S
161 *************************************************************************/
Mika Westerberg075b20b2011-09-11 12:28:54 +0300162static struct platform_device edb93xx_audio_device = {
163 .name = "edb93xx-audio",
164 .id = -1,
165};
166
Alexander Sverdlin31bb68a2011-03-03 10:53:52 +0100167static int __init edb93xx_has_audio(void)
168{
169 return (machine_is_edb9301() || machine_is_edb9302() ||
170 machine_is_edb9302a() || machine_is_edb9307a() ||
171 machine_is_edb9315a());
172}
173
174static void __init edb93xx_register_i2s(void)
175{
176 if (edb93xx_has_audio()) {
177 ep93xx_register_i2s();
Mika Westerberg075b20b2011-09-11 12:28:54 +0300178 platform_device_register(&edb93xx_audio_device);
Alexander Sverdlin31bb68a2011-03-03 10:53:52 +0100179 }
180}
181
182
183/*************************************************************************
Hartley Sweeten1fbd9722010-01-11 21:38:00 +0100184 * EDB93xx pwm
185 *************************************************************************/
186static void __init edb93xx_register_pwm(void)
187{
188 if (machine_is_edb9301() ||
189 machine_is_edb9302() || machine_is_edb9302a()) {
190 /* EP9301 and EP9302 only have pwm.1 (EGPIO14) */
191 ep93xx_register_pwm(0, 1);
192 } else if (machine_is_edb9307() || machine_is_edb9307a()) {
193 /* EP9307 only has pwm.0 (PWMOUT) */
194 ep93xx_register_pwm(1, 0);
195 } else {
196 /* EP9312 and EP9315 have both */
197 ep93xx_register_pwm(1, 1);
198 }
199}
200
201
Hartley Sweeten13055192011-01-27 17:50:53 +0100202/*************************************************************************
203 * EDB93xx framebuffer
204 *************************************************************************/
205static struct ep93xxfb_mach_info __initdata edb93xxfb_info = {
206 .num_modes = EP93XXFB_USE_MODEDB,
207 .bpp = 16,
208 .flags = 0,
209};
210
211static int __init edb93xx_has_fb(void)
212{
213 /* These platforms have an ep93xx with video capability */
214 return machine_is_edb9307() || machine_is_edb9307a() ||
215 machine_is_edb9312() || machine_is_edb9315() ||
216 machine_is_edb9315a();
217}
218
219static void __init edb93xx_register_fb(void)
220{
221 if (!edb93xx_has_fb())
222 return;
223
224 if (machine_is_edb9307a() || machine_is_edb9315a())
225 edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN0;
226 else
227 edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN3;
228
229 ep93xx_register_fb(&edb93xxfb_info);
230}
231
232
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100233static void __init edb93xx_init_machine(void)
234{
235 ep93xx_init_devices();
236 edb93xx_register_flash();
237 ep93xx_register_eth(&edb93xx_eth_data, 1);
238 edb93xx_register_i2c();
Alexander Sverdlin31bb68a2011-03-03 10:53:52 +0100239 edb93xx_register_spi();
240 edb93xx_register_i2s();
Hartley Sweeten1fbd9722010-01-11 21:38:00 +0100241 edb93xx_register_pwm();
Hartley Sweeten13055192011-01-27 17:50:53 +0100242 edb93xx_register_fb();
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100243}
244
245
246#ifdef CONFIG_MACH_EDB9301
247MACHINE_START(EDB9301, "Cirrus Logic EDB9301 Evaluation Board")
248 /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100249 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
250 .map_io = ep93xx_map_io,
251 .init_irq = ep93xx_init_irq,
252 .timer = &ep93xx_timer,
253 .init_machine = edb93xx_init_machine,
254MACHINE_END
255#endif
256
257#ifdef CONFIG_MACH_EDB9302
258MACHINE_START(EDB9302, "Cirrus Logic EDB9302 Evaluation Board")
259 /* Maintainer: George Kashperko <george@chas.com.ua> */
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100260 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
261 .map_io = ep93xx_map_io,
262 .init_irq = ep93xx_init_irq,
263 .timer = &ep93xx_timer,
264 .init_machine = edb93xx_init_machine,
265MACHINE_END
266#endif
267
268#ifdef CONFIG_MACH_EDB9302A
269MACHINE_START(EDB9302A, "Cirrus Logic EDB9302A Evaluation Board")
270 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100271 .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100,
272 .map_io = ep93xx_map_io,
273 .init_irq = ep93xx_init_irq,
274 .timer = &ep93xx_timer,
275 .init_machine = edb93xx_init_machine,
276MACHINE_END
277#endif
278
279#ifdef CONFIG_MACH_EDB9307
280MACHINE_START(EDB9307, "Cirrus Logic EDB9307 Evaluation Board")
281 /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100282 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
283 .map_io = ep93xx_map_io,
284 .init_irq = ep93xx_init_irq,
285 .timer = &ep93xx_timer,
286 .init_machine = edb93xx_init_machine,
287MACHINE_END
288#endif
289
290#ifdef CONFIG_MACH_EDB9307A
291MACHINE_START(EDB9307A, "Cirrus Logic EDB9307A Evaluation Board")
292 /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100293 .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100,
294 .map_io = ep93xx_map_io,
295 .init_irq = ep93xx_init_irq,
296 .timer = &ep93xx_timer,
297 .init_machine = edb93xx_init_machine,
298MACHINE_END
299#endif
300
301#ifdef CONFIG_MACH_EDB9312
302MACHINE_START(EDB9312, "Cirrus Logic EDB9312 Evaluation Board")
303 /* Maintainer: Toufeeq Hussain <toufeeq_hussain@infosys.com> */
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100304 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
305 .map_io = ep93xx_map_io,
306 .init_irq = ep93xx_init_irq,
307 .timer = &ep93xx_timer,
308 .init_machine = edb93xx_init_machine,
309MACHINE_END
310#endif
311
312#ifdef CONFIG_MACH_EDB9315
313MACHINE_START(EDB9315, "Cirrus Logic EDB9315 Evaluation Board")
314 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100315 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
316 .map_io = ep93xx_map_io,
317 .init_irq = ep93xx_init_irq,
318 .timer = &ep93xx_timer,
319 .init_machine = edb93xx_init_machine,
320MACHINE_END
321#endif
322
323#ifdef CONFIG_MACH_EDB9315A
324MACHINE_START(EDB9315A, "Cirrus Logic EDB9315A Evaluation Board")
325 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100326 .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100,
327 .map_io = ep93xx_map_io,
328 .init_irq = ep93xx_init_irq,
329 .timer = &ep93xx_timer,
330 .init_machine = edb93xx_init_machine,
331MACHINE_END
332#endif