]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - arch/arm/mach-ep93xx/edb93xx.c
ARM: restart: ep93xx: use new restart hook
[mirror_ubuntu-jammy-kernel.git] / arch / arm / mach-ep93xx / edb93xx.c
CommitLineData
a2bd40d2
HS
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>
a2bd40d2 29#include <linux/platform_device.h>
6531a991
HS
30#include <linux/gpio.h>
31#include <linux/i2c.h>
32#include <linux/i2c-gpio.h>
31bb68a3
AS
33#include <linux/spi/spi.h>
34
35#include <sound/cs4271.h>
583ddafe 36
a2bd40d2 37#include <mach/hardware.h>
13055192 38#include <mach/fb.h>
31bb68a3 39#include <mach/ep93xx_spi.h>
bd5f12a2 40#include <mach/gpio-ep93xx.h>
583ddafe 41
a2bd40d2
HS
42#include <asm/mach-types.h>
43#include <asm/mach/arch.h>
44
583ddafe 45
a2bd40d2
HS
46static void __init edb93xx_register_flash(void)
47{
48 if (machine_is_edb9307() || machine_is_edb9312() ||
49 machine_is_edb9315()) {
16bcf78f 50 ep93xx_register_flash(4, EP93XX_CS6_PHYS_BASE, SZ_32M);
a2bd40d2 51 } else {
16bcf78f 52 ep93xx_register_flash(2, EP93XX_CS6_PHYS_BASE, SZ_16M);
a2bd40d2
HS
53 }
54}
55
b370e082 56static struct ep93xx_eth_data __initdata edb93xx_eth_data = {
a2bd40d2
HS
57 .phy_id = 1,
58};
59
6531a991
HS
60
61/*************************************************************************
62 * EDB93xx i2c peripheral handling
63 *************************************************************************/
b370e082 64static struct i2c_gpio_platform_data __initdata edb93xx_i2c_gpio_data = {
6531a991
HS
65 .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[] = {
a2bd40d2
HS
74 {
75 I2C_BOARD_INFO("isl1208", 0x6f),
76 },
77};
78
6531a991 79static struct i2c_board_info __initdata edb93xx_i2c_board_info[] = {
a2bd40d2
HS
80 {
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()) {
6531a991
HS
89 ep93xx_register_i2c(&edb93xx_i2c_gpio_data,
90 edb93xxa_i2c_board_info,
91 ARRAY_SIZE(edb93xxa_i2c_board_info));
a2bd40d2
HS
92 } else if (machine_is_edb9307() || machine_is_edb9312() ||
93 machine_is_edb9315()) {
3d977c01 94 ep93xx_register_i2c(&edb93xx_i2c_gpio_data,
6531a991
HS
95 edb93xx_i2c_board_info,
96 ARRAY_SIZE(edb93xx_i2c_board_info));
a2bd40d2
HS
97 }
98}
99
1fbd972a 100
31bb68a3
AS
101/*************************************************************************
102 * 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 *************************************************************************/
075b20b0
MW
163static struct platform_device edb93xx_audio_device = {
164 .name = "edb93xx-audio",
165 .id = -1,
166};
167
31bb68a3
AS
168static int __init edb93xx_has_audio(void)
169{
170 return (machine_is_edb9301() || machine_is_edb9302() ||
171 machine_is_edb9302a() || machine_is_edb9307a() ||
172 machine_is_edb9315a());
173}
174
175static void __init edb93xx_register_i2s(void)
176{
177 if (edb93xx_has_audio()) {
178 ep93xx_register_i2s();
075b20b0 179 platform_device_register(&edb93xx_audio_device);
31bb68a3
AS
180 }
181}
182
183
1fbd972a
HS
184/*************************************************************************
185 * EDB93xx pwm
186 *************************************************************************/
187static void __init edb93xx_register_pwm(void)
188{
189 if (machine_is_edb9301() ||
190 machine_is_edb9302() || machine_is_edb9302a()) {
191 /* EP9301 and EP9302 only have pwm.1 (EGPIO14) */
192 ep93xx_register_pwm(0, 1);
193 } else if (machine_is_edb9307() || machine_is_edb9307a()) {
194 /* EP9307 only has pwm.0 (PWMOUT) */
195 ep93xx_register_pwm(1, 0);
196 } else {
197 /* EP9312 and EP9315 have both */
198 ep93xx_register_pwm(1, 1);
199 }
200}
201
202
13055192
HS
203/*************************************************************************
204 * EDB93xx framebuffer
205 *************************************************************************/
206static struct ep93xxfb_mach_info __initdata edb93xxfb_info = {
207 .num_modes = EP93XXFB_USE_MODEDB,
208 .bpp = 16,
209 .flags = 0,
210};
211
212static int __init edb93xx_has_fb(void)
213{
214 /* These platforms have an ep93xx with video capability */
215 return machine_is_edb9307() || machine_is_edb9307a() ||
216 machine_is_edb9312() || machine_is_edb9315() ||
217 machine_is_edb9315a();
218}
219
220static void __init edb93xx_register_fb(void)
221{
222 if (!edb93xx_has_fb())
223 return;
224
225 if (machine_is_edb9307a() || machine_is_edb9315a())
226 edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN0;
227 else
228 edb93xxfb_info.flags |= EP93XXFB_USE_SDCSN3;
229
230 ep93xx_register_fb(&edb93xxfb_info);
231}
232
233
a2bd40d2
HS
234static void __init edb93xx_init_machine(void)
235{
236 ep93xx_init_devices();
237 edb93xx_register_flash();
238 ep93xx_register_eth(&edb93xx_eth_data, 1);
239 edb93xx_register_i2c();
31bb68a3
AS
240 edb93xx_register_spi();
241 edb93xx_register_i2s();
1fbd972a 242 edb93xx_register_pwm();
13055192 243 edb93xx_register_fb();
a2bd40d2
HS
244}
245
246
247#ifdef CONFIG_MACH_EDB9301
248MACHINE_START(EDB9301, "Cirrus Logic EDB9301 Evaluation Board")
249 /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
e562cf17 250 .atag_offset = 0x100,
a2bd40d2
HS
251 .map_io = ep93xx_map_io,
252 .init_irq = ep93xx_init_irq,
253 .timer = &ep93xx_timer,
254 .init_machine = edb93xx_init_machine,
3275166e 255 .restart = ep93xx_restart,
a2bd40d2
HS
256MACHINE_END
257#endif
258
259#ifdef CONFIG_MACH_EDB9302
260MACHINE_START(EDB9302, "Cirrus Logic EDB9302 Evaluation Board")
261 /* Maintainer: George Kashperko <george@chas.com.ua> */
e562cf17 262 .atag_offset = 0x100,
a2bd40d2
HS
263 .map_io = ep93xx_map_io,
264 .init_irq = ep93xx_init_irq,
265 .timer = &ep93xx_timer,
266 .init_machine = edb93xx_init_machine,
3275166e 267 .restart = ep93xx_restart,
a2bd40d2
HS
268MACHINE_END
269#endif
270
271#ifdef CONFIG_MACH_EDB9302A
272MACHINE_START(EDB9302A, "Cirrus Logic EDB9302A Evaluation Board")
273 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
e562cf17 274 .atag_offset = 0x100,
a2bd40d2
HS
275 .map_io = ep93xx_map_io,
276 .init_irq = ep93xx_init_irq,
277 .timer = &ep93xx_timer,
278 .init_machine = edb93xx_init_machine,
3275166e 279 .restart = ep93xx_restart,
a2bd40d2
HS
280MACHINE_END
281#endif
282
283#ifdef CONFIG_MACH_EDB9307
284MACHINE_START(EDB9307, "Cirrus Logic EDB9307 Evaluation Board")
285 /* Maintainer: Herbert Valerio Riedel <hvr@gnu.org> */
e562cf17 286 .atag_offset = 0x100,
a2bd40d2
HS
287 .map_io = ep93xx_map_io,
288 .init_irq = ep93xx_init_irq,
289 .timer = &ep93xx_timer,
290 .init_machine = edb93xx_init_machine,
3275166e 291 .restart = ep93xx_restart,
a2bd40d2
HS
292MACHINE_END
293#endif
294
295#ifdef CONFIG_MACH_EDB9307A
296MACHINE_START(EDB9307A, "Cirrus Logic EDB9307A Evaluation Board")
297 /* Maintainer: H Hartley Sweeten <hsweeten@visionengravers.com> */
e562cf17 298 .atag_offset = 0x100,
a2bd40d2
HS
299 .map_io = ep93xx_map_io,
300 .init_irq = ep93xx_init_irq,
301 .timer = &ep93xx_timer,
302 .init_machine = edb93xx_init_machine,
3275166e 303 .restart = ep93xx_restart,
a2bd40d2
HS
304MACHINE_END
305#endif
306
307#ifdef CONFIG_MACH_EDB9312
308MACHINE_START(EDB9312, "Cirrus Logic EDB9312 Evaluation Board")
309 /* Maintainer: Toufeeq Hussain <toufeeq_hussain@infosys.com> */
e562cf17 310 .atag_offset = 0x100,
a2bd40d2
HS
311 .map_io = ep93xx_map_io,
312 .init_irq = ep93xx_init_irq,
313 .timer = &ep93xx_timer,
314 .init_machine = edb93xx_init_machine,
3275166e 315 .restart = ep93xx_restart,
a2bd40d2
HS
316MACHINE_END
317#endif
318
319#ifdef CONFIG_MACH_EDB9315
320MACHINE_START(EDB9315, "Cirrus Logic EDB9315 Evaluation Board")
321 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
e562cf17 322 .atag_offset = 0x100,
a2bd40d2
HS
323 .map_io = ep93xx_map_io,
324 .init_irq = ep93xx_init_irq,
325 .timer = &ep93xx_timer,
326 .init_machine = edb93xx_init_machine,
3275166e 327 .restart = ep93xx_restart,
a2bd40d2
HS
328MACHINE_END
329#endif
330
331#ifdef CONFIG_MACH_EDB9315A
332MACHINE_START(EDB9315A, "Cirrus Logic EDB9315A Evaluation Board")
333 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
e562cf17 334 .atag_offset = 0x100,
a2bd40d2
HS
335 .map_io = ep93xx_map_io,
336 .init_irq = ep93xx_init_irq,
337 .timer = &ep93xx_timer,
338 .init_machine = edb93xx_init_machine,
3275166e 339 .restart = ep93xx_restart,
a2bd40d2
HS
340MACHINE_END
341#endif