]> Pileus Git - ~andy/linux/blob - arch/arm/mach-ux500/board-mop500.c
ARM: ux500: Prevent CODEC platform data from being passed when booting ATAGs
[~andy/linux] / arch / arm / mach-ux500 / board-mop500.c
1 /*
2  * Copyright (C) 2008-2012 ST-Ericsson
3  *
4  * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2, as
8  * published by the Free Software Foundation.
9  *
10  */
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/interrupt.h>
14 #include <linux/platform_device.h>
15 #include <linux/clk.h>
16 #include <linux/io.h>
17 #include <linux/i2c.h>
18 #include <linux/platform_data/i2c-nomadik.h>
19 #include <linux/platform_data/db8500_thermal.h>
20 #include <linux/gpio.h>
21 #include <linux/amba/bus.h>
22 #include <linux/amba/pl022.h>
23 #include <linux/amba/serial.h>
24 #include <linux/spi/spi.h>
25 #include <linux/mfd/abx500/ab8500.h>
26 #include <linux/regulator/ab8500.h>
27 #include <linux/regulator/fixed.h>
28 #include <linux/regulator/driver.h>
29 #include <linux/mfd/tc3589x.h>
30 #include <linux/mfd/tps6105x.h>
31 #include <linux/mfd/abx500/ab8500-gpio.h>
32 #include <linux/platform_data/leds-lp55xx.h>
33 #include <linux/input.h>
34 #include <linux/gpio_keys.h>
35 #include <linux/delay.h>
36 #include <linux/leds.h>
37 #include <linux/pinctrl/consumer.h>
38 #include <linux/platform_data/pinctrl-nomadik.h>
39 #include <linux/platform_data/dma-ste-dma40.h>
40
41 #include <asm/mach-types.h>
42
43 #include "setup.h"
44 #include "devices.h"
45 #include "irqs.h"
46
47 #include "ste-dma40-db8500.h"
48 #include "db8500-regs.h"
49 #include "devices-db8500.h"
50 #include "board-mop500.h"
51 #include "board-mop500-regulators.h"
52
53 static struct abx500_gpio_platform_data ab8500_gpio_pdata = {
54         .gpio_base              = MOP500_AB8500_PIN_GPIO(1),
55 };
56
57 struct ab8500_platform_data ab8500_platdata = {
58         .irq_base       = MOP500_AB8500_IRQ_BASE,
59         .regulator      = &ab8500_regulator_plat_data,
60         .gpio           = &ab8500_gpio_pdata,
61 };
62
63 /*
64  * TC35892
65  */
66
67 static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
68 {
69         struct device *parent = NULL;
70 #if 0
71         /* FIXME: Is the sdi actually part of tc3589x? */
72         parent = tc3589x->dev;
73 #endif
74         mop500_sdi_tc35892_init(parent);
75 }
76
77 static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
78         .gpio_base      = MOP500_EGPIO(0),
79         .setup          = mop500_tc35892_init,
80 };
81
82 static struct tc3589x_platform_data mop500_tc35892_data = {
83         .block          = TC3589x_BLOCK_GPIO,
84         .gpio           = &mop500_tc35892_gpio_data,
85         .irq_base       = MOP500_EGPIO_IRQ_BASE,
86 };
87
88 /* I2C0 devices only available on the first HREF/MOP500 */
89 static struct i2c_board_info __initdata mop500_i2c0_devices[] = {
90         {
91                 I2C_BOARD_INFO("tc3589x", 0x42),
92                 .irq            = NOMADIK_GPIO_TO_IRQ(217),
93                 .platform_data  = &mop500_tc35892_data,
94         },
95 };
96
97 static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
98         {
99                 /* Light sensor Rohm BH1780GLI */
100                 I2C_BOARD_INFO("bh1780", 0x29),
101         },
102 };
103
104 static int __init mop500_i2c_board_init(void)
105 {
106         if (machine_is_u8500())
107                 mop500_uib_i2c_add(0, mop500_i2c0_devices,
108                                    ARRAY_SIZE(mop500_i2c0_devices));
109         mop500_uib_i2c_add(2, mop500_i2c2_devices,
110                            ARRAY_SIZE(mop500_i2c2_devices));
111         return 0;
112 }
113 device_initcall(mop500_i2c_board_init);
114
115 static void __init mop500_i2c_init(struct device *parent)
116 {
117         db8500_add_i2c0(parent, NULL);
118         db8500_add_i2c1(parent, NULL);
119         db8500_add_i2c2(parent, NULL);
120         db8500_add_i2c3(parent, NULL);
121 }
122
123 static struct gpio_keys_button mop500_gpio_keys[] = {
124         {
125                 .desc                   = "SFH7741 Proximity Sensor",
126                 .type                   = EV_SW,
127                 .code                   = SW_FRONT_PROXIMITY,
128                 .active_low             = 0,
129                 .can_disable            = 1,
130         }
131 };
132
133 static struct regulator *prox_regulator;
134 static int mop500_prox_activate(struct device *dev);
135 static void mop500_prox_deactivate(struct device *dev);
136
137 static struct gpio_keys_platform_data mop500_gpio_keys_data = {
138         .buttons        = mop500_gpio_keys,
139         .nbuttons       = ARRAY_SIZE(mop500_gpio_keys),
140         .enable         = mop500_prox_activate,
141         .disable        = mop500_prox_deactivate,
142 };
143
144 static struct platform_device mop500_gpio_keys_device = {
145         .name   = "gpio-keys",
146         .id     = 0,
147         .dev    = {
148                 .platform_data  = &mop500_gpio_keys_data,
149         },
150 };
151
152 static int mop500_prox_activate(struct device *dev)
153 {
154         prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
155                                                 "vcc");
156         if (IS_ERR(prox_regulator)) {
157                 dev_err(&mop500_gpio_keys_device.dev,
158                         "no regulator\n");
159                 return PTR_ERR(prox_regulator);
160         }
161
162         return regulator_enable(prox_regulator);
163 }
164
165 static void mop500_prox_deactivate(struct device *dev)
166 {
167         regulator_disable(prox_regulator);
168         regulator_put(prox_regulator);
169 }
170
171 /* add any platform devices here - TODO */
172 static struct platform_device *mop500_platform_devs[] __initdata = {
173         &mop500_gpio_keys_device,
174 };
175
176 #ifdef CONFIG_STE_DMA40
177 static struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
178         .mode = STEDMA40_MODE_LOGICAL,
179         .dir = DMA_DEV_TO_MEM,
180         .dev_type = DB8500_DMA_DEV8_SSP0,
181 };
182
183 static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
184         .mode = STEDMA40_MODE_LOGICAL,
185         .dir = DMA_MEM_TO_DEV,
186         .dev_type = DB8500_DMA_DEV8_SSP0,
187 };
188 #endif
189
190 struct pl022_ssp_controller ssp0_plat = {
191         .bus_id = 0,
192 #ifdef CONFIG_STE_DMA40
193         .enable_dma = 1,
194         .dma_filter = stedma40_filter,
195         .dma_rx_param = &ssp0_dma_cfg_rx,
196         .dma_tx_param = &ssp0_dma_cfg_tx,
197 #else
198         .enable_dma = 0,
199 #endif
200         /* on this platform, gpio 31,142,144,214 &
201          * 224 are connected as chip selects
202          */
203         .num_chipselect = 5,
204 };
205
206 static void __init mop500_spi_init(struct device *parent)
207 {
208         db8500_add_ssp0(parent, &ssp0_plat);
209 }
210
211 #ifdef CONFIG_STE_DMA40
212 static struct stedma40_chan_cfg uart0_dma_cfg_rx = {
213         .mode = STEDMA40_MODE_LOGICAL,
214         .dir = DMA_DEV_TO_MEM,
215         .dev_type = DB8500_DMA_DEV13_UART0,
216 };
217
218 static struct stedma40_chan_cfg uart0_dma_cfg_tx = {
219         .mode = STEDMA40_MODE_LOGICAL,
220         .dir = DMA_MEM_TO_DEV,
221         .dev_type = DB8500_DMA_DEV13_UART0,
222 };
223
224 static struct stedma40_chan_cfg uart1_dma_cfg_rx = {
225         .mode = STEDMA40_MODE_LOGICAL,
226         .dir = DMA_DEV_TO_MEM,
227         .dev_type = DB8500_DMA_DEV12_UART1,
228 };
229
230 static struct stedma40_chan_cfg uart1_dma_cfg_tx = {
231         .mode = STEDMA40_MODE_LOGICAL,
232         .dir = DMA_MEM_TO_DEV,
233         .dev_type = DB8500_DMA_DEV12_UART1,
234 };
235
236 static struct stedma40_chan_cfg uart2_dma_cfg_rx = {
237         .mode = STEDMA40_MODE_LOGICAL,
238         .dir = DMA_DEV_TO_MEM,
239         .dev_type = DB8500_DMA_DEV11_UART2,
240 };
241
242 static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
243         .mode = STEDMA40_MODE_LOGICAL,
244         .dir = DMA_MEM_TO_DEV,
245         .dev_type = DB8500_DMA_DEV11_UART2,
246 };
247 #endif
248
249 struct amba_pl011_data uart0_plat = {
250 #ifdef CONFIG_STE_DMA40
251         .dma_filter = stedma40_filter,
252         .dma_rx_param = &uart0_dma_cfg_rx,
253         .dma_tx_param = &uart0_dma_cfg_tx,
254 #endif
255 };
256
257 struct amba_pl011_data uart1_plat = {
258 #ifdef CONFIG_STE_DMA40
259         .dma_filter = stedma40_filter,
260         .dma_rx_param = &uart1_dma_cfg_rx,
261         .dma_tx_param = &uart1_dma_cfg_tx,
262 #endif
263 };
264
265 struct amba_pl011_data uart2_plat = {
266 #ifdef CONFIG_STE_DMA40
267         .dma_filter = stedma40_filter,
268         .dma_rx_param = &uart2_dma_cfg_rx,
269         .dma_tx_param = &uart2_dma_cfg_tx,
270 #endif
271 };
272
273 static void __init mop500_uart_init(struct device *parent)
274 {
275         db8500_add_uart0(parent, &uart0_plat);
276         db8500_add_uart1(parent, &uart1_plat);
277         db8500_add_uart2(parent, &uart2_plat);
278 }
279
280 static void __init mop500_init_machine(void)
281 {
282         struct device *parent = NULL;
283         int i;
284
285         platform_device_register(&db8500_prcmu_device);
286         mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
287
288         mop500_pinmaps_init();
289         parent = u8500_init_devices();
290
291         for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
292                 mop500_platform_devs[i]->dev.parent = parent;
293
294         platform_add_devices(mop500_platform_devs,
295                         ARRAY_SIZE(mop500_platform_devs));
296
297         mop500_i2c_init(parent);
298         mop500_sdi_init(parent);
299         mop500_spi_init(parent);
300         mop500_uart_init(parent);
301
302         /* This board has full regulator constraints */
303         regulator_has_full_constraints();
304 }
305
306
307 static void __init snowball_init_machine(void)
308 {
309         struct device *parent = NULL;
310
311         platform_device_register(&db8500_prcmu_device);
312
313         snowball_pinmaps_init();
314         parent = u8500_init_devices();
315
316         mop500_i2c_init(parent);
317         snowball_sdi_init(parent);
318         mop500_spi_init(parent);
319         mop500_uart_init(parent);
320
321         /* This board has full regulator constraints */
322         regulator_has_full_constraints();
323 }
324
325 static void __init hrefv60_init_machine(void)
326 {
327         struct device *parent = NULL;
328         int i;
329
330         platform_device_register(&db8500_prcmu_device);
331         /*
332          * The HREFv60 board removed a GPIO expander and routed
333          * all these GPIO pins to the internal GPIO controller
334          * instead.
335          */
336         mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
337
338         hrefv60_pinmaps_init();
339         parent = u8500_init_devices();
340
341         for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
342                 mop500_platform_devs[i]->dev.parent = parent;
343
344         platform_add_devices(mop500_platform_devs,
345                         ARRAY_SIZE(mop500_platform_devs));
346
347         mop500_i2c_init(parent);
348         hrefv60_sdi_init(parent);
349         mop500_spi_init(parent);
350         mop500_uart_init(parent);
351
352         /* This board has full regulator constraints */
353         regulator_has_full_constraints();
354 }
355
356 MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
357         /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
358         .atag_offset    = 0x100,
359         .smp            = smp_ops(ux500_smp_ops),
360         .map_io         = u8500_map_io,
361         .init_irq       = ux500_init_irq,
362         /* we re-use nomadik timer here */
363         .init_time      = ux500_timer_init,
364         .init_machine   = mop500_init_machine,
365         .init_late      = ux500_init_late,
366         .restart        = ux500_restart,
367 MACHINE_END
368
369 MACHINE_START(U8520, "ST-Ericsson U8520 Platform HREFP520")
370         .atag_offset    = 0x100,
371         .map_io         = u8500_map_io,
372         .init_irq       = ux500_init_irq,
373         .init_time      = ux500_timer_init,
374         .init_machine   = mop500_init_machine,
375         .init_late      = ux500_init_late,
376         .restart        = ux500_restart,
377 MACHINE_END
378
379 MACHINE_START(HREFV60, "ST-Ericsson U8500 Platform HREFv60+")
380         .atag_offset    = 0x100,
381         .smp            = smp_ops(ux500_smp_ops),
382         .map_io         = u8500_map_io,
383         .init_irq       = ux500_init_irq,
384         .init_time      = ux500_timer_init,
385         .init_machine   = hrefv60_init_machine,
386         .init_late      = ux500_init_late,
387         .restart        = ux500_restart,
388 MACHINE_END
389
390 MACHINE_START(SNOWBALL, "Calao Systems Snowball platform")
391         .atag_offset    = 0x100,
392         .smp            = smp_ops(ux500_smp_ops),
393         .map_io         = u8500_map_io,
394         .init_irq       = ux500_init_irq,
395         /* we re-use nomadik timer here */
396         .init_time      = ux500_timer_init,
397         .init_machine   = snowball_init_machine,
398         .init_late      = NULL,
399         .restart        = ux500_restart,
400 MACHINE_END