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/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>
42 #include <asm/mach-types.h>
47 #include <linux/platform_data/crypto-ux500.h>
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"
55 static struct abx500_gpio_platform_data ab8500_gpio_pdata = {
56 .gpio_base = MOP500_AB8500_PIN_GPIO(1),
60 static struct ab8500_codec_platform_data ab8500_codec_pdata = {
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
68 .ear_cmv = EAR_CMV_0_95V
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,
82 static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
84 struct device *parent = NULL;
86 /* FIXME: Is the sdi actually part of tc3589x? */
87 parent = tc3589x->dev;
89 mop500_sdi_tc35892_init(parent);
92 static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
93 .gpio_base = MOP500_EGPIO(0),
94 .setup = mop500_tc35892_init,
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,
103 /* I2C0 devices only available on the first HREF/MOP500 */
104 static struct i2c_board_info __initdata mop500_i2c0_devices[] = {
106 I2C_BOARD_INFO("tc3589x", 0x42),
107 .irq = NOMADIK_GPIO_TO_IRQ(217),
108 .platform_data = &mop500_tc35892_data,
112 static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
114 /* Light sensor Rohm BH1780GLI */
115 I2C_BOARD_INFO("bh1780", 0x29),
119 static int __init mop500_i2c_board_init(void)
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));
128 device_initcall(mop500_i2c_board_init);
130 static void __init mop500_i2c_init(struct device *parent)
132 db8500_add_i2c0(parent, NULL);
133 db8500_add_i2c1(parent, NULL);
134 db8500_add_i2c2(parent, NULL);
135 db8500_add_i2c3(parent, NULL);
138 static struct gpio_keys_button mop500_gpio_keys[] = {
140 .desc = "SFH7741 Proximity Sensor",
142 .code = SW_FRONT_PROXIMITY,
148 static struct regulator *prox_regulator;
149 static int mop500_prox_activate(struct device *dev);
150 static void mop500_prox_deactivate(struct device *dev);
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,
159 static struct platform_device mop500_gpio_keys_device = {
163 .platform_data = &mop500_gpio_keys_data,
167 static int mop500_prox_activate(struct device *dev)
169 prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
171 if (IS_ERR(prox_regulator)) {
172 dev_err(&mop500_gpio_keys_device.dev,
174 return PTR_ERR(prox_regulator);
177 return regulator_enable(prox_regulator);
180 static void mop500_prox_deactivate(struct device *dev)
182 regulator_disable(prox_regulator);
183 regulator_put(prox_regulator);
186 static struct cryp_platform_data u8500_cryp1_platform_data = {
188 .dir = DMA_MEM_TO_DEV,
189 .dev_type = DB8500_DMA_DEV48_CAC1,
190 .mode = STEDMA40_MODE_LOGICAL,
193 .dir = DMA_DEV_TO_MEM,
194 .dev_type = DB8500_DMA_DEV48_CAC1,
195 .mode = STEDMA40_MODE_LOGICAL,
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,
205 static struct hash_platform_data u8500_hash1_platform_data = {
206 .mem_to_engine = &u8500_hash_dma_cfg_tx,
207 .dma_filter = stedma40_filter,
210 /* add any platform devices here - TODO */
211 static struct platform_device *mop500_platform_devs[] __initdata = {
212 &mop500_gpio_keys_device,
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,
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,
229 struct pl022_ssp_controller ssp0_plat = {
231 #ifdef CONFIG_STE_DMA40
233 .dma_filter = stedma40_filter,
234 .dma_rx_param = &ssp0_dma_cfg_rx,
235 .dma_tx_param = &ssp0_dma_cfg_tx,
239 /* on this platform, gpio 31,142,144,214 &
240 * 224 are connected as chip selects
245 static void __init mop500_spi_init(struct device *parent)
247 db8500_add_ssp0(parent, &ssp0_plat);
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,
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,
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,
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,
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,
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,
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,
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,
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,
312 static void __init mop500_uart_init(struct device *parent)
314 db8500_add_uart0(parent, &uart0_plat);
315 db8500_add_uart1(parent, &uart1_plat);
316 db8500_add_uart2(parent, &uart2_plat);
319 static void __init u8500_cryp1_hash1_init(struct device *parent)
321 db8500_add_cryp1(parent, &u8500_cryp1_platform_data);
322 db8500_add_hash1(parent, &u8500_hash1_platform_data);
325 static void __init mop500_init_machine(void)
327 struct device *parent = NULL;
330 platform_device_register(&db8500_prcmu_device);
331 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
333 mop500_pinmaps_init();
334 parent = u8500_init_devices();
336 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
337 mop500_platform_devs[i]->dev.parent = parent;
339 platform_add_devices(mop500_platform_devs,
340 ARRAY_SIZE(mop500_platform_devs));
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);
348 /* This board has full regulator constraints */
349 regulator_has_full_constraints();
353 static void __init snowball_init_machine(void)
355 struct device *parent = NULL;
357 platform_device_register(&db8500_prcmu_device);
359 snowball_pinmaps_init();
360 parent = u8500_init_devices();
362 mop500_i2c_init(parent);
363 snowball_sdi_init(parent);
364 mop500_spi_init(parent);
365 mop500_uart_init(parent);
367 u8500_cryp1_hash1_init(parent);
369 /* This board has full regulator constraints */
370 regulator_has_full_constraints();
373 static void __init hrefv60_init_machine(void)
375 struct device *parent = NULL;
378 platform_device_register(&db8500_prcmu_device);
380 * The HREFv60 board removed a GPIO expander and routed
381 * all these GPIO pins to the internal GPIO controller
384 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
386 hrefv60_pinmaps_init();
387 parent = u8500_init_devices();
389 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
390 mop500_platform_devs[i]->dev.parent = parent;
392 platform_add_devices(mop500_platform_devs,
393 ARRAY_SIZE(mop500_platform_devs));
395 mop500_i2c_init(parent);
396 hrefv60_sdi_init(parent);
397 mop500_spi_init(parent);
398 mop500_uart_init(parent);
400 /* This board has full regulator constraints */
401 regulator_has_full_constraints();
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,
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,
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,
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,
447 .restart = ux500_restart,