2 * Copyright (C) 2008-2012 ST-Ericsson
4 * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
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.
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>
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>
40 #include <asm/mach-types.h>
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"
52 struct ab8500_platform_data ab8500_platdata = {
53 .irq_base = MOP500_AB8500_IRQ_BASE,
54 .regulator = &ab8500_regulator_plat_data,
57 static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
59 /* Light sensor Rohm BH1780GLI */
60 I2C_BOARD_INFO("bh1780", 0x29),
64 static int __init mop500_i2c_board_init(void)
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));
73 device_initcall(mop500_i2c_board_init);
75 static void __init mop500_i2c_init(struct device *parent)
77 db8500_add_i2c0(parent, NULL);
78 db8500_add_i2c1(parent, NULL);
79 db8500_add_i2c2(parent, NULL);
80 db8500_add_i2c3(parent, NULL);
83 static struct gpio_keys_button mop500_gpio_keys[] = {
85 .desc = "SFH7741 Proximity Sensor",
87 .code = SW_FRONT_PROXIMITY,
93 static struct regulator *prox_regulator;
94 static int mop500_prox_activate(struct device *dev);
95 static void mop500_prox_deactivate(struct device *dev);
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,
104 static struct platform_device mop500_gpio_keys_device = {
108 .platform_data = &mop500_gpio_keys_data,
112 static int mop500_prox_activate(struct device *dev)
114 prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
116 if (IS_ERR(prox_regulator)) {
117 dev_err(&mop500_gpio_keys_device.dev,
119 return PTR_ERR(prox_regulator);
122 return regulator_enable(prox_regulator);
125 static void mop500_prox_deactivate(struct device *dev)
127 regulator_disable(prox_regulator);
128 regulator_put(prox_regulator);
131 /* add any platform devices here - TODO */
132 static struct platform_device *mop500_platform_devs[] __initdata = {
133 &mop500_gpio_keys_device,
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,
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,
150 struct pl022_ssp_controller ssp0_plat = {
152 #ifdef CONFIG_STE_DMA40
154 .dma_filter = stedma40_filter,
155 .dma_rx_param = &ssp0_dma_cfg_rx,
156 .dma_tx_param = &ssp0_dma_cfg_tx,
160 /* on this platform, gpio 31,142,144,214 &
161 * 224 are connected as chip selects
166 static void __init mop500_spi_init(struct device *parent)
168 db8500_add_ssp0(parent, &ssp0_plat);
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,
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,
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,
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,
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,
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,
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,
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,
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,
233 static void __init mop500_uart_init(struct device *parent)
235 db8500_add_uart0(parent, &uart0_plat);
236 db8500_add_uart1(parent, &uart1_plat);
237 db8500_add_uart2(parent, &uart2_plat);
240 static void __init mop500_init_machine(void)
242 struct device *parent = NULL;
245 platform_device_register(&db8500_prcmu_device);
246 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
248 mop500_pinmaps_init();
249 parent = u8500_init_devices();
251 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
252 mop500_platform_devs[i]->dev.parent = parent;
254 platform_add_devices(mop500_platform_devs,
255 ARRAY_SIZE(mop500_platform_devs));
257 mop500_i2c_init(parent);
258 mop500_sdi_init(parent);
259 mop500_spi_init(parent);
260 mop500_uart_init(parent);
262 /* This board has full regulator constraints */
263 regulator_has_full_constraints();
267 static void __init snowball_init_machine(void)
269 struct device *parent = NULL;
271 platform_device_register(&db8500_prcmu_device);
273 snowball_pinmaps_init();
274 parent = u8500_init_devices();
276 mop500_i2c_init(parent);
277 snowball_sdi_init(parent);
278 mop500_spi_init(parent);
279 mop500_uart_init(parent);
281 /* This board has full regulator constraints */
282 regulator_has_full_constraints();
285 static void __init hrefv60_init_machine(void)
287 struct device *parent = NULL;
290 platform_device_register(&db8500_prcmu_device);
292 * The HREFv60 board removed a GPIO expander and routed
293 * all these GPIO pins to the internal GPIO controller
296 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
298 hrefv60_pinmaps_init();
299 parent = u8500_init_devices();
301 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
302 mop500_platform_devs[i]->dev.parent = parent;
304 platform_add_devices(mop500_platform_devs,
305 ARRAY_SIZE(mop500_platform_devs));
307 mop500_i2c_init(parent);
308 hrefv60_sdi_init(parent);
309 mop500_spi_init(parent);
310 mop500_uart_init(parent);
312 /* This board has full regulator constraints */
313 regulator_has_full_constraints();
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,
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,
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,
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,
359 .restart = ux500_restart,