]> Pileus Git - ~andy/linux/blob - arch/arm/mach-ux500/board-mop500.c
a8c22cd2f4b1ddf5a3de3e683243b5abfc89c281
[~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/tps6105x.h>
30 #include <linux/mfd/abx500/ab8500-gpio.h>
31 #include <linux/platform_data/leds-lp55xx.h>
32 #include <linux/input.h>
33 #include <linux/gpio_keys.h>
34 #include <linux/delay.h>
35 #include <linux/leds.h>
36 #include <linux/pinctrl/consumer.h>
37 #include <linux/platform_data/pinctrl-nomadik.h>
38 #include <linux/platform_data/dma-ste-dma40.h>
39
40 #include <asm/mach-types.h>
41
42 #include "setup.h"
43 #include "devices.h"
44 #include "irqs.h"
45
46 #include "ste-dma40-db8500.h"
47 #include "db8500-regs.h"
48 #include "devices-db8500.h"
49 #include "board-mop500.h"
50 #include "board-mop500-regulators.h"
51
52 struct ab8500_platform_data ab8500_platdata = {
53         .irq_base       = MOP500_AB8500_IRQ_BASE,
54         .regulator      = &ab8500_regulator_plat_data,
55 };
56
57 static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
58         {
59                 /* Light sensor Rohm BH1780GLI */
60                 I2C_BOARD_INFO("bh1780", 0x29),
61         },
62 };
63
64 static int __init mop500_i2c_board_init(void)
65 {
66         if (machine_is_u8500())
67                 mop500_uib_i2c_add(0, mop500_i2c0_devices,
68                                    ARRAY_SIZE(mop500_i2c0_devices));
69         mop500_uib_i2c_add(2, mop500_i2c2_devices,
70                            ARRAY_SIZE(mop500_i2c2_devices));
71         return 0;
72 }
73 device_initcall(mop500_i2c_board_init);
74
75 static void __init mop500_i2c_init(struct device *parent)
76 {
77         db8500_add_i2c0(parent, NULL);
78         db8500_add_i2c1(parent, NULL);
79         db8500_add_i2c2(parent, NULL);
80         db8500_add_i2c3(parent, NULL);
81 }
82
83 static struct gpio_keys_button mop500_gpio_keys[] = {
84         {
85                 .desc                   = "SFH7741 Proximity Sensor",
86                 .type                   = EV_SW,
87                 .code                   = SW_FRONT_PROXIMITY,
88                 .active_low             = 0,
89                 .can_disable            = 1,
90         }
91 };
92
93 static struct regulator *prox_regulator;
94 static int mop500_prox_activate(struct device *dev);
95 static void mop500_prox_deactivate(struct device *dev);
96
97 static struct gpio_keys_platform_data mop500_gpio_keys_data = {
98         .buttons        = mop500_gpio_keys,
99         .nbuttons       = ARRAY_SIZE(mop500_gpio_keys),
100         .enable         = mop500_prox_activate,
101         .disable        = mop500_prox_deactivate,
102 };
103
104 static struct platform_device mop500_gpio_keys_device = {
105         .name   = "gpio-keys",
106         .id     = 0,
107         .dev    = {
108                 .platform_data  = &mop500_gpio_keys_data,
109         },
110 };
111
112 static int mop500_prox_activate(struct device *dev)
113 {
114         prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
115                                                 "vcc");
116         if (IS_ERR(prox_regulator)) {
117                 dev_err(&mop500_gpio_keys_device.dev,
118                         "no regulator\n");
119                 return PTR_ERR(prox_regulator);
120         }
121
122         return regulator_enable(prox_regulator);
123 }
124
125 static void mop500_prox_deactivate(struct device *dev)
126 {
127         regulator_disable(prox_regulator);
128         regulator_put(prox_regulator);
129 }
130
131 /* add any platform devices here - TODO */
132 static struct platform_device *mop500_platform_devs[] __initdata = {
133         &mop500_gpio_keys_device,
134 };
135
136 #ifdef CONFIG_STE_DMA40
137 static struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
138         .mode = STEDMA40_MODE_LOGICAL,
139         .dir = DMA_DEV_TO_MEM,
140         .dev_type = DB8500_DMA_DEV8_SSP0,
141 };
142
143 static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
144         .mode = STEDMA40_MODE_LOGICAL,
145         .dir = DMA_MEM_TO_DEV,
146         .dev_type = DB8500_DMA_DEV8_SSP0,
147 };
148 #endif
149
150 struct pl022_ssp_controller ssp0_plat = {
151         .bus_id = 0,
152 #ifdef CONFIG_STE_DMA40
153         .enable_dma = 1,
154         .dma_filter = stedma40_filter,
155         .dma_rx_param = &ssp0_dma_cfg_rx,
156         .dma_tx_param = &ssp0_dma_cfg_tx,
157 #else
158         .enable_dma = 0,
159 #endif
160         /* on this platform, gpio 31,142,144,214 &
161          * 224 are connected as chip selects
162          */
163         .num_chipselect = 5,
164 };
165
166 static void __init mop500_spi_init(struct device *parent)
167 {
168         db8500_add_ssp0(parent, &ssp0_plat);
169 }
170
171 #ifdef CONFIG_STE_DMA40
172 static struct stedma40_chan_cfg uart0_dma_cfg_rx = {
173         .mode = STEDMA40_MODE_LOGICAL,
174         .dir = DMA_DEV_TO_MEM,
175         .dev_type = DB8500_DMA_DEV13_UART0,
176 };
177
178 static struct stedma40_chan_cfg uart0_dma_cfg_tx = {
179         .mode = STEDMA40_MODE_LOGICAL,
180         .dir = DMA_MEM_TO_DEV,
181         .dev_type = DB8500_DMA_DEV13_UART0,
182 };
183
184 static struct stedma40_chan_cfg uart1_dma_cfg_rx = {
185         .mode = STEDMA40_MODE_LOGICAL,
186         .dir = DMA_DEV_TO_MEM,
187         .dev_type = DB8500_DMA_DEV12_UART1,
188 };
189
190 static struct stedma40_chan_cfg uart1_dma_cfg_tx = {
191         .mode = STEDMA40_MODE_LOGICAL,
192         .dir = DMA_MEM_TO_DEV,
193         .dev_type = DB8500_DMA_DEV12_UART1,
194 };
195
196 static struct stedma40_chan_cfg uart2_dma_cfg_rx = {
197         .mode = STEDMA40_MODE_LOGICAL,
198         .dir = DMA_DEV_TO_MEM,
199         .dev_type = DB8500_DMA_DEV11_UART2,
200 };
201
202 static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
203         .mode = STEDMA40_MODE_LOGICAL,
204         .dir = DMA_MEM_TO_DEV,
205         .dev_type = DB8500_DMA_DEV11_UART2,
206 };
207 #endif
208
209 struct amba_pl011_data uart0_plat = {
210 #ifdef CONFIG_STE_DMA40
211         .dma_filter = stedma40_filter,
212         .dma_rx_param = &uart0_dma_cfg_rx,
213         .dma_tx_param = &uart0_dma_cfg_tx,
214 #endif
215 };
216
217 struct amba_pl011_data uart1_plat = {
218 #ifdef CONFIG_STE_DMA40
219         .dma_filter = stedma40_filter,
220         .dma_rx_param = &uart1_dma_cfg_rx,
221         .dma_tx_param = &uart1_dma_cfg_tx,
222 #endif
223 };
224
225 struct amba_pl011_data uart2_plat = {
226 #ifdef CONFIG_STE_DMA40
227         .dma_filter = stedma40_filter,
228         .dma_rx_param = &uart2_dma_cfg_rx,
229         .dma_tx_param = &uart2_dma_cfg_tx,
230 #endif
231 };
232
233 static void __init mop500_uart_init(struct device *parent)
234 {
235         db8500_add_uart0(parent, &uart0_plat);
236         db8500_add_uart1(parent, &uart1_plat);
237         db8500_add_uart2(parent, &uart2_plat);
238 }
239
240 static void __init mop500_init_machine(void)
241 {
242         struct device *parent = NULL;
243         int i;
244
245         platform_device_register(&db8500_prcmu_device);
246         mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
247
248         mop500_pinmaps_init();
249         parent = u8500_init_devices();
250
251         for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
252                 mop500_platform_devs[i]->dev.parent = parent;
253
254         platform_add_devices(mop500_platform_devs,
255                         ARRAY_SIZE(mop500_platform_devs));
256
257         mop500_i2c_init(parent);
258         mop500_sdi_init(parent);
259         mop500_spi_init(parent);
260         mop500_uart_init(parent);
261
262         /* This board has full regulator constraints */
263         regulator_has_full_constraints();
264 }
265
266
267 static void __init snowball_init_machine(void)
268 {
269         struct device *parent = NULL;
270
271         platform_device_register(&db8500_prcmu_device);
272
273         snowball_pinmaps_init();
274         parent = u8500_init_devices();
275
276         mop500_i2c_init(parent);
277         snowball_sdi_init(parent);
278         mop500_spi_init(parent);
279         mop500_uart_init(parent);
280
281         /* This board has full regulator constraints */
282         regulator_has_full_constraints();
283 }
284
285 static void __init hrefv60_init_machine(void)
286 {
287         struct device *parent = NULL;
288         int i;
289
290         platform_device_register(&db8500_prcmu_device);
291         /*
292          * The HREFv60 board removed a GPIO expander and routed
293          * all these GPIO pins to the internal GPIO controller
294          * instead.
295          */
296         mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
297
298         hrefv60_pinmaps_init();
299         parent = u8500_init_devices();
300
301         for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
302                 mop500_platform_devs[i]->dev.parent = parent;
303
304         platform_add_devices(mop500_platform_devs,
305                         ARRAY_SIZE(mop500_platform_devs));
306
307         mop500_i2c_init(parent);
308         hrefv60_sdi_init(parent);
309         mop500_spi_init(parent);
310         mop500_uart_init(parent);
311
312         /* This board has full regulator constraints */
313         regulator_has_full_constraints();
314 }
315
316 MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
317         /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
318         .atag_offset    = 0x100,
319         .smp            = smp_ops(ux500_smp_ops),
320         .map_io         = u8500_map_io,
321         .init_irq       = ux500_init_irq,
322         /* we re-use nomadik timer here */
323         .init_time      = ux500_timer_init,
324         .init_machine   = mop500_init_machine,
325         .init_late      = ux500_init_late,
326         .restart        = ux500_restart,
327 MACHINE_END
328
329 MACHINE_START(U8520, "ST-Ericsson U8520 Platform HREFP520")
330         .atag_offset    = 0x100,
331         .map_io         = u8500_map_io,
332         .init_irq       = ux500_init_irq,
333         .init_time      = ux500_timer_init,
334         .init_machine   = mop500_init_machine,
335         .init_late      = ux500_init_late,
336         .restart        = ux500_restart,
337 MACHINE_END
338
339 MACHINE_START(HREFV60, "ST-Ericsson U8500 Platform HREFv60+")
340         .atag_offset    = 0x100,
341         .smp            = smp_ops(ux500_smp_ops),
342         .map_io         = u8500_map_io,
343         .init_irq       = ux500_init_irq,
344         .init_time      = ux500_timer_init,
345         .init_machine   = hrefv60_init_machine,
346         .init_late      = ux500_init_late,
347         .restart        = ux500_restart,
348 MACHINE_END
349
350 MACHINE_START(SNOWBALL, "Calao Systems Snowball platform")
351         .atag_offset    = 0x100,
352         .smp            = smp_ops(ux500_smp_ops),
353         .map_io         = u8500_map_io,
354         .init_irq       = ux500_init_irq,
355         /* we re-use nomadik timer here */
356         .init_time      = ux500_timer_init,
357         .init_machine   = snowball_init_machine,
358         .init_late      = NULL,
359         .restart        = ux500_restart,
360 MACHINE_END