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