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/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>
41 #include <asm/mach-types.h>
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"
53 static struct abx500_gpio_platform_data ab8500_gpio_pdata = {
54 .gpio_base = MOP500_AB8500_PIN_GPIO(1),
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,
67 static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
69 struct device *parent = NULL;
71 /* FIXME: Is the sdi actually part of tc3589x? */
72 parent = tc3589x->dev;
74 mop500_sdi_tc35892_init(parent);
77 static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
78 .gpio_base = MOP500_EGPIO(0),
79 .setup = mop500_tc35892_init,
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,
88 /* I2C0 devices only available on the first HREF/MOP500 */
89 static struct i2c_board_info __initdata mop500_i2c0_devices[] = {
91 I2C_BOARD_INFO("tc3589x", 0x42),
92 .irq = NOMADIK_GPIO_TO_IRQ(217),
93 .platform_data = &mop500_tc35892_data,
97 static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
99 /* Light sensor Rohm BH1780GLI */
100 I2C_BOARD_INFO("bh1780", 0x29),
104 static int __init mop500_i2c_board_init(void)
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));
113 device_initcall(mop500_i2c_board_init);
115 static void __init mop500_i2c_init(struct device *parent)
117 db8500_add_i2c0(parent, NULL);
118 db8500_add_i2c1(parent, NULL);
119 db8500_add_i2c2(parent, NULL);
120 db8500_add_i2c3(parent, NULL);
123 static struct gpio_keys_button mop500_gpio_keys[] = {
125 .desc = "SFH7741 Proximity Sensor",
127 .code = SW_FRONT_PROXIMITY,
133 static struct regulator *prox_regulator;
134 static int mop500_prox_activate(struct device *dev);
135 static void mop500_prox_deactivate(struct device *dev);
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,
144 static struct platform_device mop500_gpio_keys_device = {
148 .platform_data = &mop500_gpio_keys_data,
152 static int mop500_prox_activate(struct device *dev)
154 prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
156 if (IS_ERR(prox_regulator)) {
157 dev_err(&mop500_gpio_keys_device.dev,
159 return PTR_ERR(prox_regulator);
162 return regulator_enable(prox_regulator);
165 static void mop500_prox_deactivate(struct device *dev)
167 regulator_disable(prox_regulator);
168 regulator_put(prox_regulator);
171 /* add any platform devices here - TODO */
172 static struct platform_device *mop500_platform_devs[] __initdata = {
173 &mop500_gpio_keys_device,
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,
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,
190 struct pl022_ssp_controller ssp0_plat = {
192 #ifdef CONFIG_STE_DMA40
194 .dma_filter = stedma40_filter,
195 .dma_rx_param = &ssp0_dma_cfg_rx,
196 .dma_tx_param = &ssp0_dma_cfg_tx,
200 /* on this platform, gpio 31,142,144,214 &
201 * 224 are connected as chip selects
206 static void __init mop500_spi_init(struct device *parent)
208 db8500_add_ssp0(parent, &ssp0_plat);
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,
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,
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,
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,
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,
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,
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,
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,
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,
273 static void __init mop500_uart_init(struct device *parent)
275 db8500_add_uart0(parent, &uart0_plat);
276 db8500_add_uart1(parent, &uart1_plat);
277 db8500_add_uart2(parent, &uart2_plat);
280 static void __init mop500_init_machine(void)
282 struct device *parent = NULL;
285 platform_device_register(&db8500_prcmu_device);
286 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
288 mop500_pinmaps_init();
289 parent = u8500_init_devices();
291 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
292 mop500_platform_devs[i]->dev.parent = parent;
294 platform_add_devices(mop500_platform_devs,
295 ARRAY_SIZE(mop500_platform_devs));
297 mop500_i2c_init(parent);
298 mop500_sdi_init(parent);
299 mop500_spi_init(parent);
300 mop500_uart_init(parent);
302 /* This board has full regulator constraints */
303 regulator_has_full_constraints();
307 static void __init snowball_init_machine(void)
309 struct device *parent = NULL;
311 platform_device_register(&db8500_prcmu_device);
313 snowball_pinmaps_init();
314 parent = u8500_init_devices();
316 mop500_i2c_init(parent);
317 snowball_sdi_init(parent);
318 mop500_spi_init(parent);
319 mop500_uart_init(parent);
321 /* This board has full regulator constraints */
322 regulator_has_full_constraints();
325 static void __init hrefv60_init_machine(void)
327 struct device *parent = NULL;
330 platform_device_register(&db8500_prcmu_device);
332 * The HREFv60 board removed a GPIO expander and routed
333 * all these GPIO pins to the internal GPIO controller
336 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
338 hrefv60_pinmaps_init();
339 parent = u8500_init_devices();
341 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
342 mop500_platform_devs[i]->dev.parent = parent;
344 platform_add_devices(mop500_platform_devs,
345 ARRAY_SIZE(mop500_platform_devs));
347 mop500_i2c_init(parent);
348 hrefv60_sdi_init(parent);
349 mop500_spi_init(parent);
350 mop500_uart_init(parent);
352 /* This board has full regulator constraints */
353 regulator_has_full_constraints();
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,
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,
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,
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,
399 .restart = ux500_restart,