blob: 3f320c6477bf6c74365b7d5566729cd83b8c968a [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>
Linus Walleijbd5f12a2011-09-22 08:07:00 +010040#include <mach/gpio-ep93xx.h>
Hartley Sweeten583ddaf2009-07-06 17:39:50 +010041
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010042#include <asm/mach-types.h>
43#include <asm/mach/arch.h>
44
Hartley Sweeten583ddaf2009-07-06 17:39:50 +010045
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010046static void __init edb93xx_register_flash(void)
47{
48 if (machine_is_edb9307() || machine_is_edb9312() ||
49 machine_is_edb9315()) {
Hartley Sweeten16bcf782010-06-10 16:19:08 +010050 ep93xx_register_flash(4, EP93XX_CS6_PHYS_BASE, SZ_32M);
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010051 } else {
Hartley Sweeten16bcf782010-06-10 16:19:08 +010052 ep93xx_register_flash(2, EP93XX_CS6_PHYS_BASE, SZ_16M);
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010053 }
54}
55
Hartley Sweetenb370e082010-03-18 18:04:06 +010056static struct ep93xx_eth_data __initdata edb93xx_eth_data = {
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010057 .phy_id = 1,
58};
59
Hartley Sweeten6531a992009-10-08 00:45:00 +010060
61/*************************************************************************
62 * EDB93xx i2c peripheral handling
63 *************************************************************************/
Hartley Sweetenb370e082010-03-18 18:04:06 +010064static struct i2c_gpio_platform_data __initdata edb93xx_i2c_gpio_data = {
Hartley Sweeten6531a992009-10-08 00:45:00 +010065 .sda_pin = EP93XX_GPIO_LINE_EEDAT,
66 .sda_is_open_drain = 0,
67 .scl_pin = EP93XX_GPIO_LINE_EECLK,
68 .scl_is_open_drain = 0,
69 .udelay = 0, /* default to 100 kHz */
70 .timeout = 0, /* default to 100 ms */
71};
72
73static struct i2c_board_info __initdata edb93xxa_i2c_board_info[] = {
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010074 {
75 I2C_BOARD_INFO("isl1208", 0x6f),
76 },
77};
78
Hartley Sweeten6531a992009-10-08 00:45:00 +010079static struct i2c_board_info __initdata edb93xx_i2c_board_info[] = {
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010080 {
81 I2C_BOARD_INFO("ds1337", 0x68),
82 },
83};
84
85static void __init edb93xx_register_i2c(void)
86{
87 if (machine_is_edb9302a() || machine_is_edb9307a() ||
88 machine_is_edb9315a()) {
Hartley Sweeten6531a992009-10-08 00:45:00 +010089 ep93xx_register_i2c(&edb93xx_i2c_gpio_data,
90 edb93xxa_i2c_board_info,
91 ARRAY_SIZE(edb93xxa_i2c_board_info));
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010092 } else if (machine_is_edb9307() || machine_is_edb9312() ||
93 machine_is_edb9315()) {
Hartley Sweeten3d977c02009-10-14 01:56:10 +010094 ep93xx_register_i2c(&edb93xx_i2c_gpio_data,
Hartley Sweeten6531a992009-10-08 00:45:00 +010095 edb93xx_i2c_board_info,
96 ARRAY_SIZE(edb93xx_i2c_board_info));
Hartley Sweetena2bd40d2009-05-04 19:09:25 +010097 }
98}
99
Hartley Sweeten1fbd9722010-01-11 21:38:00 +0100100
101/*************************************************************************
Alexander Sverdlin31bb68a2011-03-03 10:53:52 +0100102 * EDB93xx SPI peripheral handling
103 *************************************************************************/
104static struct cs4271_platform_data edb93xx_cs4271_data = {
105 .gpio_nreset = -EINVAL, /* filled in later */
106};
107
108static int edb93xx_cs4271_hw_setup(struct spi_device *spi)
109{
110 return gpio_request_one(EP93XX_GPIO_LINE_EGPIO6,
111 GPIOF_OUT_INIT_HIGH, spi->modalias);
112}
113
114static void edb93xx_cs4271_hw_cleanup(struct spi_device *spi)
115{
116 gpio_free(EP93XX_GPIO_LINE_EGPIO6);
117}
118
119static void edb93xx_cs4271_hw_cs_control(struct spi_device *spi, int value)
120{
121 gpio_set_value(EP93XX_GPIO_LINE_EGPIO6, value);
122}
123
124static struct ep93xx_spi_chip_ops edb93xx_cs4271_hw = {
125 .setup = edb93xx_cs4271_hw_setup,
126 .cleanup = edb93xx_cs4271_hw_cleanup,
127 .cs_control = edb93xx_cs4271_hw_cs_control,
128};
129
130static struct spi_board_info edb93xx_spi_board_info[] __initdata = {
131 {
132 .modalias = "cs4271",
133 .platform_data = &edb93xx_cs4271_data,
134 .controller_data = &edb93xx_cs4271_hw,
135 .max_speed_hz = 6000000,
136 .bus_num = 0,
137 .chip_select = 0,
138 .mode = SPI_MODE_3,
139 },
140};
141
142static struct ep93xx_spi_info edb93xx_spi_info __initdata = {
143 .num_chipselect = ARRAY_SIZE(edb93xx_spi_board_info),
144};
145
146static void __init edb93xx_register_spi(void)
147{
148 if (machine_is_edb9301() || machine_is_edb9302())
149 edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_EGPIO1;
150 else if (machine_is_edb9302a() || machine_is_edb9307a())
151 edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_H(2);
152 else if (machine_is_edb9315a())
153 edb93xx_cs4271_data.gpio_nreset = EP93XX_GPIO_LINE_EGPIO14;
154
155 ep93xx_register_spi(&edb93xx_spi_info, edb93xx_spi_board_info,
156 ARRAY_SIZE(edb93xx_spi_board_info));
157}
158
159
160/*************************************************************************
161 * EDB93xx I2S
162 *************************************************************************/
163static int __init edb93xx_has_audio(void)
164{
165 return (machine_is_edb9301() || machine_is_edb9302() ||
166 machine_is_edb9302a() || machine_is_edb9307a() ||
167 machine_is_edb9315a());
168}
169
170static void __init edb93xx_register_i2s(void)
171{
172 if (edb93xx_has_audio()) {
173 ep93xx_register_i2s();
174 }
175}
176
177
178/*************************************************************************
Hartley Sweeten1fbd9722010-01-11 21:38:00 +0100179 * EDB93xx pwm
180 *************************************************************************/
181static void __init edb93xx_register_pwm(void)
182{
183 if (machine_is_edb9301() ||
184 machine_is_edb9302() || machine_is_edb9302a()) {
185 /* EP9301 and EP9302 only have pwm.1 (EGPIO14) */
186 ep93xx_register_pwm(0, 1);
187 } else if (machine_is_edb9307() || machine_is_edb9307a()) {
188 /* EP9307 only has pwm.0 (PWMOUT) */
189 ep93xx_register_pwm(1, 0);
190 } else {
191 /* EP9312 and EP9315 have both */
192 ep93xx_register_pwm(1, 1);
193 }
194}
195
196
Hartley Sweeten13055192011-01-27 17:50:53 +0100197/*************************************************************************
198 * EDB93xx framebuffer
199 *************************************************************************/
200static struct ep93xxfb_mach_info __initdata edb93xxfb_info = {
201 .num_modes = EP93XXFB_USE_MODEDB,
202 .bpp = 16,
203 .flags = 0,
204};
205
206static int __init edb93xx_has_fb(void)
207{
208 /* These platforms have an ep93xx with video capability */
209 return machine_is_edb9307() || machine_is_edb9307a() ||
210 machine_is_edb9312() || machine_is_edb9315() ||
211 machine_is_edb9315a();
212}
213
214static void __init edb93xx_register_fb(void)
215{
216 if (!edb93xx_has_fb())
217 return;
218
219 if (machine_is_edb9307a() || machine_is_edb9315a())
220 edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN0;
221 else
222 edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN3;
223
224 ep93xx_register_fb(&edb93xxfb_info);
225}
226
227
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100228static void __init edb93xx_init_machine(void)
229{
230 ep93xx_init_devices();
231 edb93xx_register_flash();
232 ep93xx_register_eth(&edb93xx_eth_data, 1);
233 edb93xx_register_i2c();
Alexander Sverdlin31bb68a2011-03-03 10:53:52 +0100234 edb93xx_register_spi();
235 edb93xx_register_i2s();
Hartley Sweeten1fbd9722010-01-11 21:38:00 +0100236 edb93xx_register_pwm();
Hartley Sweeten13055192011-01-27 17:50:53 +0100237 edb93xx_register_fb();
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100238}
239
240
241#ifdef CONFIG_MACH_EDB9301
242MACHINE_START(EDB9301, "Cirrus Logic EDB9301 Evaluation Board")
243 /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100244 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
245 .map_io = ep93xx_map_io,
246 .init_irq = ep93xx_init_irq,
247 .timer = &ep93xx_timer,
248 .init_machine = edb93xx_init_machine,
249MACHINE_END
250#endif
251
252#ifdef CONFIG_MACH_EDB9302
253MACHINE_START(EDB9302, "Cirrus Logic EDB9302 Evaluation Board")
254 /* Maintainer: George Kashperko <george@chas.com.ua> */
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100255 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
256 .map_io = ep93xx_map_io,
257 .init_irq = ep93xx_init_irq,
258 .timer = &ep93xx_timer,
259 .init_machine = edb93xx_init_machine,
260MACHINE_END
261#endif
262
263#ifdef CONFIG_MACH_EDB9302A
264MACHINE_START(EDB9302A, "Cirrus Logic EDB9302A Evaluation Board")
265 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100266 .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100,
267 .map_io = ep93xx_map_io,
268 .init_irq = ep93xx_init_irq,
269 .timer = &ep93xx_timer,
270 .init_machine = edb93xx_init_machine,
271MACHINE_END
272#endif
273
274#ifdef CONFIG_MACH_EDB9307
275MACHINE_START(EDB9307, "Cirrus Logic EDB9307 Evaluation Board")
276 /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100277 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
278 .map_io = ep93xx_map_io,
279 .init_irq = ep93xx_init_irq,
280 .timer = &ep93xx_timer,
281 .init_machine = edb93xx_init_machine,
282MACHINE_END
283#endif
284
285#ifdef CONFIG_MACH_EDB9307A
286MACHINE_START(EDB9307A, "Cirrus Logic EDB9307A Evaluation Board")
287 /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100288 .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100,
289 .map_io = ep93xx_map_io,
290 .init_irq = ep93xx_init_irq,
291 .timer = &ep93xx_timer,
292 .init_machine = edb93xx_init_machine,
293MACHINE_END
294#endif
295
296#ifdef CONFIG_MACH_EDB9312
297MACHINE_START(EDB9312, "Cirrus Logic EDB9312 Evaluation Board")
298 /* Maintainer: Toufeeq Hussain <toufeeq_hussain@infosys.com> */
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100299 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
300 .map_io = ep93xx_map_io,
301 .init_irq = ep93xx_init_irq,
302 .timer = &ep93xx_timer,
303 .init_machine = edb93xx_init_machine,
304MACHINE_END
305#endif
306
307#ifdef CONFIG_MACH_EDB9315
308MACHINE_START(EDB9315, "Cirrus Logic EDB9315 Evaluation Board")
309 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100310 .boot_params = EP93XX_SDCE3_PHYS_BASE_SYNC + 0x100,
311 .map_io = ep93xx_map_io,
312 .init_irq = ep93xx_init_irq,
313 .timer = &ep93xx_timer,
314 .init_machine = edb93xx_init_machine,
315MACHINE_END
316#endif
317
318#ifdef CONFIG_MACH_EDB9315A
319MACHINE_START(EDB9315A, "Cirrus Logic EDB9315A Evaluation Board")
320 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
Hartley Sweetena2bd40d2009-05-04 19:09:25 +0100321 .boot_params = EP93XX_SDCE0_PHYS_BASE + 0x100,
322 .map_io = ep93xx_map_io,
323 .init_irq = ep93xx_init_irq,
324 .timer = &ep93xx_timer,
325 .init_machine = edb93xx_init_machine,
326MACHINE_END
327#endif