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/regulator/gpio-regulator.h>
30 #include <linux/mfd/tc3589x.h>
31 #include <linux/mfd/tps6105x.h>
32 #include <linux/mfd/abx500/ab8500-gpio.h>
33 #include <linux/mfd/abx500/ab8500-codec.h>
34 #include <linux/platform_data/leds-lp55xx.h>
35 #include <linux/input.h>
36 #include <linux/gpio_keys.h>
37 #include <linux/delay.h>
38 #include <linux/leds.h>
39 #include <linux/pinctrl/consumer.h>
40 #include <linux/platform_data/pinctrl-nomadik.h>
41 #include <linux/platform_data/dma-ste-dma40.h>
43 #include <asm/mach-types.h>
48 #include <linux/platform_data/crypto-ux500.h>
50 #include "ste-dma40-db8500.h"
51 #include "db8500-regs.h"
52 #include "devices-db8500.h"
53 #include "board-mop500.h"
54 #include "board-mop500-regulators.h"
56 static struct fixed_voltage_config snowball_gpio_en_3v3_data = {
57 .supply_name = "EN-3V3",
58 .gpio = SNOWBALL_EN_3V3_ETH_GPIO,
59 .microvolts = 3300000,
61 .init_data = &gpio_en_3v3_regulator,
62 .startup_delay = 5000, /* 1200us */
65 static struct platform_device snowball_gpio_en_3v3_regulator_dev = {
66 .name = "reg-fixed-voltage",
69 .platform_data = &snowball_gpio_en_3v3_data,
73 /* Dynamically populated. */
74 static struct gpio sdi0_reg_gpios[] = {
75 { 0, GPIOF_OUT_INIT_LOW, "mmci_vsel" },
78 static struct gpio_regulator_state sdi0_reg_states[] = {
79 { .value = 2900000, .gpios = (0 << 0) },
80 { .value = 1800000, .gpios = (1 << 0) },
83 static struct gpio_regulator_config sdi0_reg_info = {
84 .supply_name = "ext-mmc-level-shifter",
85 .gpios = sdi0_reg_gpios,
86 .nr_gpios = ARRAY_SIZE(sdi0_reg_gpios),
87 .states = sdi0_reg_states,
88 .nr_states = ARRAY_SIZE(sdi0_reg_states),
89 .type = REGULATOR_VOLTAGE,
92 .init_data = &sdi0_reg_init_data,
96 static struct platform_device sdi0_regulator = {
97 .name = "gpio-regulator",
100 .platform_data = &sdi0_reg_info,
104 static struct abx500_gpio_platform_data ab8500_gpio_pdata = {
105 .gpio_base = MOP500_AB8500_PIN_GPIO(1),
109 static struct ab8500_codec_platform_data ab8500_codec_pdata = {
111 .mic1_type = AMIC_TYPE_DIFFERENTIAL,
112 .mic2_type = AMIC_TYPE_DIFFERENTIAL,
113 .mic1a_micbias = AMIC_MICBIAS_VAMIC1,
114 .mic1b_micbias = AMIC_MICBIAS_VAMIC1,
115 .mic2_micbias = AMIC_MICBIAS_VAMIC2
117 .ear_cmv = EAR_CMV_0_95V
120 struct ab8500_platform_data ab8500_platdata = {
121 .irq_base = MOP500_AB8500_IRQ_BASE,
122 .regulator = &ab8500_regulator_plat_data,
123 .gpio = &ab8500_gpio_pdata,
124 .codec = &ab8500_codec_pdata,
127 static struct platform_device u8500_cpufreq_cooling_device = {
128 .name = "db8500-cpufreq-cooling",
135 static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
137 struct device *parent = NULL;
139 /* FIXME: Is the sdi actually part of tc3589x? */
140 parent = tc3589x->dev;
142 mop500_sdi_tc35892_init(parent);
145 static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
146 .gpio_base = MOP500_EGPIO(0),
147 .setup = mop500_tc35892_init,
150 static struct tc3589x_platform_data mop500_tc35892_data = {
151 .block = TC3589x_BLOCK_GPIO,
152 .gpio = &mop500_tc35892_gpio_data,
153 .irq_base = MOP500_EGPIO_IRQ_BASE,
156 /* I2C0 devices only available on the first HREF/MOP500 */
157 static struct i2c_board_info __initdata mop500_i2c0_devices[] = {
159 I2C_BOARD_INFO("tc3589x", 0x42),
160 .irq = NOMADIK_GPIO_TO_IRQ(217),
161 .platform_data = &mop500_tc35892_data,
165 static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
167 /* Light sensor Rohm BH1780GLI */
168 I2C_BOARD_INFO("bh1780", 0x29),
172 static int __init mop500_i2c_board_init(void)
174 if (machine_is_u8500())
175 mop500_uib_i2c_add(0, mop500_i2c0_devices,
176 ARRAY_SIZE(mop500_i2c0_devices));
177 mop500_uib_i2c_add(2, mop500_i2c2_devices,
178 ARRAY_SIZE(mop500_i2c2_devices));
181 device_initcall(mop500_i2c_board_init);
183 static void __init mop500_i2c_init(struct device *parent)
185 db8500_add_i2c0(parent, NULL);
186 db8500_add_i2c1(parent, NULL);
187 db8500_add_i2c2(parent, NULL);
188 db8500_add_i2c3(parent, NULL);
191 static struct gpio_keys_button mop500_gpio_keys[] = {
193 .desc = "SFH7741 Proximity Sensor",
195 .code = SW_FRONT_PROXIMITY,
201 static struct regulator *prox_regulator;
202 static int mop500_prox_activate(struct device *dev);
203 static void mop500_prox_deactivate(struct device *dev);
205 static struct gpio_keys_platform_data mop500_gpio_keys_data = {
206 .buttons = mop500_gpio_keys,
207 .nbuttons = ARRAY_SIZE(mop500_gpio_keys),
208 .enable = mop500_prox_activate,
209 .disable = mop500_prox_deactivate,
212 static struct platform_device mop500_gpio_keys_device = {
216 .platform_data = &mop500_gpio_keys_data,
220 static int mop500_prox_activate(struct device *dev)
222 prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
224 if (IS_ERR(prox_regulator)) {
225 dev_err(&mop500_gpio_keys_device.dev,
227 return PTR_ERR(prox_regulator);
230 return regulator_enable(prox_regulator);
233 static void mop500_prox_deactivate(struct device *dev)
235 regulator_disable(prox_regulator);
236 regulator_put(prox_regulator);
239 static struct cryp_platform_data u8500_cryp1_platform_data = {
241 .dir = DMA_MEM_TO_DEV,
242 .dev_type = DB8500_DMA_DEV48_CAC1,
243 .mode = STEDMA40_MODE_LOGICAL,
246 .dir = DMA_DEV_TO_MEM,
247 .dev_type = DB8500_DMA_DEV48_CAC1,
248 .mode = STEDMA40_MODE_LOGICAL,
252 static struct stedma40_chan_cfg u8500_hash_dma_cfg_tx = {
253 .dir = DMA_MEM_TO_DEV,
254 .dev_type = DB8500_DMA_DEV50_HAC1_TX,
255 .mode = STEDMA40_MODE_LOGICAL,
258 static struct hash_platform_data u8500_hash1_platform_data = {
259 .mem_to_engine = &u8500_hash_dma_cfg_tx,
260 .dma_filter = stedma40_filter,
263 /* add any platform devices here - TODO */
264 static struct platform_device *mop500_platform_devs[] __initdata = {
265 &mop500_gpio_keys_device,
269 #ifdef CONFIG_STE_DMA40
270 static struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
271 .mode = STEDMA40_MODE_LOGICAL,
272 .dir = DMA_DEV_TO_MEM,
273 .dev_type = DB8500_DMA_DEV8_SSP0,
276 static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
277 .mode = STEDMA40_MODE_LOGICAL,
278 .dir = DMA_MEM_TO_DEV,
279 .dev_type = DB8500_DMA_DEV8_SSP0,
283 struct pl022_ssp_controller ssp0_plat = {
285 #ifdef CONFIG_STE_DMA40
287 .dma_filter = stedma40_filter,
288 .dma_rx_param = &ssp0_dma_cfg_rx,
289 .dma_tx_param = &ssp0_dma_cfg_tx,
293 /* on this platform, gpio 31,142,144,214 &
294 * 224 are connected as chip selects
299 static void __init mop500_spi_init(struct device *parent)
301 db8500_add_ssp0(parent, &ssp0_plat);
304 #ifdef CONFIG_STE_DMA40
305 static struct stedma40_chan_cfg uart0_dma_cfg_rx = {
306 .mode = STEDMA40_MODE_LOGICAL,
307 .dir = DMA_DEV_TO_MEM,
308 .dev_type = DB8500_DMA_DEV13_UART0,
311 static struct stedma40_chan_cfg uart0_dma_cfg_tx = {
312 .mode = STEDMA40_MODE_LOGICAL,
313 .dir = DMA_MEM_TO_DEV,
314 .dev_type = DB8500_DMA_DEV13_UART0,
317 static struct stedma40_chan_cfg uart1_dma_cfg_rx = {
318 .mode = STEDMA40_MODE_LOGICAL,
319 .dir = DMA_DEV_TO_MEM,
320 .dev_type = DB8500_DMA_DEV12_UART1,
323 static struct stedma40_chan_cfg uart1_dma_cfg_tx = {
324 .mode = STEDMA40_MODE_LOGICAL,
325 .dir = DMA_MEM_TO_DEV,
326 .dev_type = DB8500_DMA_DEV12_UART1,
329 static struct stedma40_chan_cfg uart2_dma_cfg_rx = {
330 .mode = STEDMA40_MODE_LOGICAL,
331 .dir = DMA_DEV_TO_MEM,
332 .dev_type = DB8500_DMA_DEV11_UART2,
335 static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
336 .mode = STEDMA40_MODE_LOGICAL,
337 .dir = DMA_MEM_TO_DEV,
338 .dev_type = DB8500_DMA_DEV11_UART2,
342 struct amba_pl011_data uart0_plat = {
343 #ifdef CONFIG_STE_DMA40
344 .dma_filter = stedma40_filter,
345 .dma_rx_param = &uart0_dma_cfg_rx,
346 .dma_tx_param = &uart0_dma_cfg_tx,
350 struct amba_pl011_data uart1_plat = {
351 #ifdef CONFIG_STE_DMA40
352 .dma_filter = stedma40_filter,
353 .dma_rx_param = &uart1_dma_cfg_rx,
354 .dma_tx_param = &uart1_dma_cfg_tx,
358 struct amba_pl011_data uart2_plat = {
359 #ifdef CONFIG_STE_DMA40
360 .dma_filter = stedma40_filter,
361 .dma_rx_param = &uart2_dma_cfg_rx,
362 .dma_tx_param = &uart2_dma_cfg_tx,
366 static void __init mop500_uart_init(struct device *parent)
368 db8500_add_uart0(parent, &uart0_plat);
369 db8500_add_uart1(parent, &uart1_plat);
370 db8500_add_uart2(parent, &uart2_plat);
373 static void __init u8500_cryp1_hash1_init(struct device *parent)
375 db8500_add_cryp1(parent, &u8500_cryp1_platform_data);
376 db8500_add_hash1(parent, &u8500_hash1_platform_data);
379 static struct platform_device *snowball_platform_devs[] __initdata = {
380 &snowball_gpio_en_3v3_regulator_dev,
381 &u8500_cpufreq_cooling_device,
385 static void __init mop500_init_machine(void)
387 struct device *parent = NULL;
390 platform_device_register(&db8500_prcmu_device);
391 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
393 sdi0_reg_info.enable_gpio = GPIO_SDMMC_EN;
394 sdi0_reg_info.gpios[0].gpio = GPIO_SDMMC_1V8_3V_SEL;
396 mop500_pinmaps_init();
397 parent = u8500_init_devices();
399 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
400 mop500_platform_devs[i]->dev.parent = parent;
402 platform_add_devices(mop500_platform_devs,
403 ARRAY_SIZE(mop500_platform_devs));
405 mop500_i2c_init(parent);
406 mop500_sdi_init(parent);
407 mop500_spi_init(parent);
408 mop500_uart_init(parent);
409 u8500_cryp1_hash1_init(parent);
411 /* This board has full regulator constraints */
412 regulator_has_full_constraints();
416 static void __init snowball_init_machine(void)
418 struct device *parent = NULL;
421 platform_device_register(&db8500_prcmu_device);
423 sdi0_reg_info.enable_gpio = SNOWBALL_SDMMC_EN_GPIO;
424 sdi0_reg_info.gpios[0].gpio = SNOWBALL_SDMMC_1V8_3V_GPIO;
426 snowball_pinmaps_init();
427 parent = u8500_init_devices();
429 for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
430 snowball_platform_devs[i]->dev.parent = parent;
432 platform_add_devices(snowball_platform_devs,
433 ARRAY_SIZE(snowball_platform_devs));
435 mop500_i2c_init(parent);
436 snowball_sdi_init(parent);
437 mop500_spi_init(parent);
438 mop500_uart_init(parent);
440 u8500_cryp1_hash1_init(parent);
442 /* This board has full regulator constraints */
443 regulator_has_full_constraints();
446 static void __init hrefv60_init_machine(void)
448 struct device *parent = NULL;
451 platform_device_register(&db8500_prcmu_device);
453 * The HREFv60 board removed a GPIO expander and routed
454 * all these GPIO pins to the internal GPIO controller
457 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
459 sdi0_reg_info.enable_gpio = HREFV60_SDMMC_EN_GPIO;
460 sdi0_reg_info.gpios[0].gpio = HREFV60_SDMMC_1V8_3V_GPIO;
462 hrefv60_pinmaps_init();
463 parent = u8500_init_devices();
465 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
466 mop500_platform_devs[i]->dev.parent = parent;
468 platform_add_devices(mop500_platform_devs,
469 ARRAY_SIZE(mop500_platform_devs));
471 mop500_i2c_init(parent);
472 hrefv60_sdi_init(parent);
473 mop500_spi_init(parent);
474 mop500_uart_init(parent);
476 /* This board has full regulator constraints */
477 regulator_has_full_constraints();
480 MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
481 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
482 .atag_offset = 0x100,
483 .smp = smp_ops(ux500_smp_ops),
484 .map_io = u8500_map_io,
485 .init_irq = ux500_init_irq,
486 /* we re-use nomadik timer here */
487 .init_time = ux500_timer_init,
488 .init_machine = mop500_init_machine,
489 .init_late = ux500_init_late,
490 .restart = ux500_restart,
493 MACHINE_START(U8520, "ST-Ericsson U8520 Platform HREFP520")
494 .atag_offset = 0x100,
495 .map_io = u8500_map_io,
496 .init_irq = ux500_init_irq,
497 .init_time = ux500_timer_init,
498 .init_machine = mop500_init_machine,
499 .init_late = ux500_init_late,
500 .restart = ux500_restart,
503 MACHINE_START(HREFV60, "ST-Ericsson U8500 Platform HREFv60+")
504 .atag_offset = 0x100,
505 .smp = smp_ops(ux500_smp_ops),
506 .map_io = u8500_map_io,
507 .init_irq = ux500_init_irq,
508 .init_time = ux500_timer_init,
509 .init_machine = hrefv60_init_machine,
510 .init_late = ux500_init_late,
511 .restart = ux500_restart,
514 MACHINE_START(SNOWBALL, "Calao Systems Snowball platform")
515 .atag_offset = 0x100,
516 .smp = smp_ops(ux500_smp_ops),
517 .map_io = u8500_map_io,
518 .init_irq = ux500_init_irq,
519 /* we re-use nomadik timer here */
520 .init_time = ux500_timer_init,
521 .init_machine = snowball_init_machine,
523 .restart = ux500_restart,