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/smsc911x.h>
37 #include <linux/gpio_keys.h>
38 #include <linux/delay.h>
39 #include <linux/leds.h>
40 #include <linux/pinctrl/consumer.h>
41 #include <linux/platform_data/pinctrl-nomadik.h>
42 #include <linux/platform_data/dma-ste-dma40.h>
44 #include <asm/mach-types.h>
45 #include <asm/mach/arch.h>
50 #include <linux/platform_data/crypto-ux500.h>
52 #include "ste-dma40-db8500.h"
53 #include "db8500-regs.h"
54 #include "devices-db8500.h"
55 #include "board-mop500.h"
56 #include "board-mop500-regulators.h"
58 static struct gpio_led snowball_led_array[] = {
61 .default_trigger = "heartbeat",
66 static struct gpio_led_platform_data snowball_led_data = {
67 .leds = snowball_led_array,
68 .num_leds = ARRAY_SIZE(snowball_led_array),
71 static struct platform_device snowball_led_dev = {
74 .platform_data = &snowball_led_data,
78 static struct fixed_voltage_config snowball_gpio_en_3v3_data = {
79 .supply_name = "EN-3V3",
80 .gpio = SNOWBALL_EN_3V3_ETH_GPIO,
81 .microvolts = 3300000,
83 .init_data = &gpio_en_3v3_regulator,
84 .startup_delay = 5000, /* 1200us */
87 static struct platform_device snowball_gpio_en_3v3_regulator_dev = {
88 .name = "reg-fixed-voltage",
91 .platform_data = &snowball_gpio_en_3v3_data,
95 /* Dynamically populated. */
96 static struct gpio sdi0_reg_gpios[] = {
97 { 0, GPIOF_OUT_INIT_LOW, "mmci_vsel" },
100 static struct gpio_regulator_state sdi0_reg_states[] = {
101 { .value = 2900000, .gpios = (0 << 0) },
102 { .value = 1800000, .gpios = (1 << 0) },
105 static struct gpio_regulator_config sdi0_reg_info = {
106 .supply_name = "ext-mmc-level-shifter",
107 .gpios = sdi0_reg_gpios,
108 .nr_gpios = ARRAY_SIZE(sdi0_reg_gpios),
109 .states = sdi0_reg_states,
110 .nr_states = ARRAY_SIZE(sdi0_reg_states),
111 .type = REGULATOR_VOLTAGE,
113 .enabled_at_boot = 0,
114 .init_data = &sdi0_reg_init_data,
115 .startup_delay = 100,
118 static struct platform_device sdi0_regulator = {
119 .name = "gpio-regulator",
122 .platform_data = &sdi0_reg_info,
126 static struct abx500_gpio_platform_data ab8500_gpio_pdata = {
127 .gpio_base = MOP500_AB8500_PIN_GPIO(1),
131 static struct ab8500_codec_platform_data ab8500_codec_pdata = {
133 .mic1_type = AMIC_TYPE_DIFFERENTIAL,
134 .mic2_type = AMIC_TYPE_DIFFERENTIAL,
135 .mic1a_micbias = AMIC_MICBIAS_VAMIC1,
136 .mic1b_micbias = AMIC_MICBIAS_VAMIC1,
137 .mic2_micbias = AMIC_MICBIAS_VAMIC2
139 .ear_cmv = EAR_CMV_0_95V
142 static struct gpio_keys_button snowball_key_array[] = {
149 .debounce_interval = 50,
158 .debounce_interval = 50,
167 .debounce_interval = 50,
176 .debounce_interval = 50,
185 .debounce_interval = 50,
190 static struct gpio_keys_platform_data snowball_key_data = {
191 .buttons = snowball_key_array,
192 .nbuttons = ARRAY_SIZE(snowball_key_array),
195 static struct platform_device snowball_key_dev = {
199 .platform_data = &snowball_key_data,
203 static struct smsc911x_platform_config snowball_sbnet_cfg = {
204 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
205 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
206 .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY,
210 static struct resource sbnet_res[] = {
212 .name = "smsc911x-memory",
213 .start = (0x5000 << 16),
214 .end = (0x5000 << 16) + 0xffff,
215 .flags = IORESOURCE_MEM,
218 .start = NOMADIK_GPIO_TO_IRQ(140),
219 .end = NOMADIK_GPIO_TO_IRQ(140),
220 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
224 static struct platform_device snowball_sbnet_dev = {
226 .num_resources = ARRAY_SIZE(sbnet_res),
227 .resource = sbnet_res,
229 .platform_data = &snowball_sbnet_cfg,
233 struct ab8500_platform_data ab8500_platdata = {
234 .irq_base = MOP500_AB8500_IRQ_BASE,
235 .regulator = &ab8500_regulator_plat_data,
236 .gpio = &ab8500_gpio_pdata,
237 .codec = &ab8500_codec_pdata,
240 static struct platform_device u8500_cpufreq_cooling_device = {
241 .name = "db8500-cpufreq-cooling",
248 static struct tps6105x_platform_data mop500_tps61052_data = {
249 .mode = TPS6105X_MODE_VOLTAGE,
250 .regulator_data = &tps61052_regulator,
257 static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
259 struct device *parent = NULL;
261 /* FIXME: Is the sdi actually part of tc3589x? */
262 parent = tc3589x->dev;
264 mop500_sdi_tc35892_init(parent);
267 static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
268 .gpio_base = MOP500_EGPIO(0),
269 .setup = mop500_tc35892_init,
272 static struct tc3589x_platform_data mop500_tc35892_data = {
273 .block = TC3589x_BLOCK_GPIO,
274 .gpio = &mop500_tc35892_gpio_data,
275 .irq_base = MOP500_EGPIO_IRQ_BASE,
278 static struct lp55xx_led_config lp5521_pri_led[] = {
296 static struct lp55xx_platform_data __initdata lp5521_pri_data = {
297 .label = "lp5521_pri",
298 .led_config = &lp5521_pri_led[0],
300 .clock_mode = LP55XX_CLOCK_EXT,
303 static struct lp55xx_led_config lp5521_sec_led[] = {
321 static struct lp55xx_platform_data __initdata lp5521_sec_data = {
322 .label = "lp5521_sec",
323 .led_config = &lp5521_sec_led[0],
325 .clock_mode = LP55XX_CLOCK_EXT,
328 static struct i2c_board_info __initdata mop500_i2c0_devices[] = {
330 I2C_BOARD_INFO("tc3589x", 0x42),
331 .irq = NOMADIK_GPIO_TO_IRQ(217),
332 .platform_data = &mop500_tc35892_data,
334 /* I2C0 devices only available prior to HREFv60 */
336 I2C_BOARD_INFO("tps61052", 0x33),
337 .platform_data = &mop500_tps61052_data,
341 #define NUM_PRE_V60_I2C0_DEVICES 1
343 static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
345 /* lp5521 LED driver, 1st device */
346 I2C_BOARD_INFO("lp5521", 0x33),
347 .platform_data = &lp5521_pri_data,
350 /* lp5521 LED driver, 2st device */
351 I2C_BOARD_INFO("lp5521", 0x34),
352 .platform_data = &lp5521_sec_data,
355 /* Light sensor Rohm BH1780GLI */
356 I2C_BOARD_INFO("bh1780", 0x29),
360 static void __init mop500_i2c_init(struct device *parent)
362 db8500_add_i2c0(parent, NULL);
363 db8500_add_i2c1(parent, NULL);
364 db8500_add_i2c2(parent, NULL);
365 db8500_add_i2c3(parent, NULL);
368 static struct gpio_keys_button mop500_gpio_keys[] = {
370 .desc = "SFH7741 Proximity Sensor",
372 .code = SW_FRONT_PROXIMITY,
378 static struct regulator *prox_regulator;
379 static int mop500_prox_activate(struct device *dev);
380 static void mop500_prox_deactivate(struct device *dev);
382 static struct gpio_keys_platform_data mop500_gpio_keys_data = {
383 .buttons = mop500_gpio_keys,
384 .nbuttons = ARRAY_SIZE(mop500_gpio_keys),
385 .enable = mop500_prox_activate,
386 .disable = mop500_prox_deactivate,
389 static struct platform_device mop500_gpio_keys_device = {
393 .platform_data = &mop500_gpio_keys_data,
397 static int mop500_prox_activate(struct device *dev)
399 prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
401 if (IS_ERR(prox_regulator)) {
402 dev_err(&mop500_gpio_keys_device.dev,
404 return PTR_ERR(prox_regulator);
407 return regulator_enable(prox_regulator);
410 static void mop500_prox_deactivate(struct device *dev)
412 regulator_disable(prox_regulator);
413 regulator_put(prox_regulator);
416 static struct cryp_platform_data u8500_cryp1_platform_data = {
418 .dir = STEDMA40_MEM_TO_PERIPH,
419 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
420 .dst_dev_type = DB8500_DMA_DEV48_CAC1_TX,
421 .src_info.data_width = STEDMA40_WORD_WIDTH,
422 .dst_info.data_width = STEDMA40_WORD_WIDTH,
423 .mode = STEDMA40_MODE_LOGICAL,
424 .src_info.psize = STEDMA40_PSIZE_LOG_4,
425 .dst_info.psize = STEDMA40_PSIZE_LOG_4,
428 .dir = STEDMA40_PERIPH_TO_MEM,
429 .src_dev_type = DB8500_DMA_DEV48_CAC1_RX,
430 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
431 .src_info.data_width = STEDMA40_WORD_WIDTH,
432 .dst_info.data_width = STEDMA40_WORD_WIDTH,
433 .mode = STEDMA40_MODE_LOGICAL,
434 .src_info.psize = STEDMA40_PSIZE_LOG_4,
435 .dst_info.psize = STEDMA40_PSIZE_LOG_4,
439 static struct stedma40_chan_cfg u8500_hash_dma_cfg_tx = {
440 .dir = STEDMA40_MEM_TO_PERIPH,
441 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
442 .dst_dev_type = DB8500_DMA_DEV50_HAC1_TX,
443 .src_info.data_width = STEDMA40_WORD_WIDTH,
444 .dst_info.data_width = STEDMA40_WORD_WIDTH,
445 .mode = STEDMA40_MODE_LOGICAL,
446 .src_info.psize = STEDMA40_PSIZE_LOG_16,
447 .dst_info.psize = STEDMA40_PSIZE_LOG_16,
450 static struct hash_platform_data u8500_hash1_platform_data = {
451 .mem_to_engine = &u8500_hash_dma_cfg_tx,
452 .dma_filter = stedma40_filter,
455 /* add any platform devices here - TODO */
456 static struct platform_device *mop500_platform_devs[] __initdata = {
457 &mop500_gpio_keys_device,
461 #ifdef CONFIG_STE_DMA40
462 static struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
463 .mode = STEDMA40_MODE_LOGICAL,
464 .dir = STEDMA40_PERIPH_TO_MEM,
465 .src_dev_type = DB8500_DMA_DEV8_SSP0_RX,
466 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
467 .src_info.data_width = STEDMA40_BYTE_WIDTH,
468 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
471 static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
472 .mode = STEDMA40_MODE_LOGICAL,
473 .dir = STEDMA40_MEM_TO_PERIPH,
474 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
475 .dst_dev_type = DB8500_DMA_DEV8_SSP0_TX,
476 .src_info.data_width = STEDMA40_BYTE_WIDTH,
477 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
481 struct pl022_ssp_controller ssp0_plat = {
483 #ifdef CONFIG_STE_DMA40
485 .dma_filter = stedma40_filter,
486 .dma_rx_param = &ssp0_dma_cfg_rx,
487 .dma_tx_param = &ssp0_dma_cfg_tx,
491 /* on this platform, gpio 31,142,144,214 &
492 * 224 are connected as chip selects
497 static void __init mop500_spi_init(struct device *parent)
499 db8500_add_ssp0(parent, &ssp0_plat);
502 #ifdef CONFIG_STE_DMA40
503 static struct stedma40_chan_cfg uart0_dma_cfg_rx = {
504 .mode = STEDMA40_MODE_LOGICAL,
505 .dir = STEDMA40_PERIPH_TO_MEM,
506 .src_dev_type = DB8500_DMA_DEV13_UART0_RX,
507 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
508 .src_info.data_width = STEDMA40_BYTE_WIDTH,
509 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
512 static struct stedma40_chan_cfg uart0_dma_cfg_tx = {
513 .mode = STEDMA40_MODE_LOGICAL,
514 .dir = STEDMA40_MEM_TO_PERIPH,
515 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
516 .dst_dev_type = DB8500_DMA_DEV13_UART0_TX,
517 .src_info.data_width = STEDMA40_BYTE_WIDTH,
518 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
521 static struct stedma40_chan_cfg uart1_dma_cfg_rx = {
522 .mode = STEDMA40_MODE_LOGICAL,
523 .dir = STEDMA40_PERIPH_TO_MEM,
524 .src_dev_type = DB8500_DMA_DEV12_UART1_RX,
525 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
526 .src_info.data_width = STEDMA40_BYTE_WIDTH,
527 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
530 static struct stedma40_chan_cfg uart1_dma_cfg_tx = {
531 .mode = STEDMA40_MODE_LOGICAL,
532 .dir = STEDMA40_MEM_TO_PERIPH,
533 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
534 .dst_dev_type = DB8500_DMA_DEV12_UART1_TX,
535 .src_info.data_width = STEDMA40_BYTE_WIDTH,
536 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
539 static struct stedma40_chan_cfg uart2_dma_cfg_rx = {
540 .mode = STEDMA40_MODE_LOGICAL,
541 .dir = STEDMA40_PERIPH_TO_MEM,
542 .src_dev_type = DB8500_DMA_DEV11_UART2_RX,
543 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
544 .src_info.data_width = STEDMA40_BYTE_WIDTH,
545 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
548 static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
549 .mode = STEDMA40_MODE_LOGICAL,
550 .dir = STEDMA40_MEM_TO_PERIPH,
551 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
552 .dst_dev_type = DB8500_DMA_DEV11_UART2_TX,
553 .src_info.data_width = STEDMA40_BYTE_WIDTH,
554 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
558 struct amba_pl011_data uart0_plat = {
559 #ifdef CONFIG_STE_DMA40
560 .dma_filter = stedma40_filter,
561 .dma_rx_param = &uart0_dma_cfg_rx,
562 .dma_tx_param = &uart0_dma_cfg_tx,
566 struct amba_pl011_data uart1_plat = {
567 #ifdef CONFIG_STE_DMA40
568 .dma_filter = stedma40_filter,
569 .dma_rx_param = &uart1_dma_cfg_rx,
570 .dma_tx_param = &uart1_dma_cfg_tx,
574 struct amba_pl011_data uart2_plat = {
575 #ifdef CONFIG_STE_DMA40
576 .dma_filter = stedma40_filter,
577 .dma_rx_param = &uart2_dma_cfg_rx,
578 .dma_tx_param = &uart2_dma_cfg_tx,
582 static void __init mop500_uart_init(struct device *parent)
584 db8500_add_uart0(parent, &uart0_plat);
585 db8500_add_uart1(parent, &uart1_plat);
586 db8500_add_uart2(parent, &uart2_plat);
589 static void __init u8500_cryp1_hash1_init(struct device *parent)
591 db8500_add_cryp1(parent, &u8500_cryp1_platform_data);
592 db8500_add_hash1(parent, &u8500_hash1_platform_data);
595 static struct platform_device *snowball_platform_devs[] __initdata = {
599 &snowball_gpio_en_3v3_regulator_dev,
600 &u8500_cpufreq_cooling_device,
604 static void __init mop500_init_machine(void)
606 struct device *parent = NULL;
610 platform_device_register(&db8500_prcmu_device);
611 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
613 sdi0_reg_info.enable_gpio = GPIO_SDMMC_EN;
614 sdi0_reg_info.gpios[0].gpio = GPIO_SDMMC_1V8_3V_SEL;
616 mop500_pinmaps_init();
617 parent = u8500_init_devices();
619 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
620 mop500_platform_devs[i]->dev.parent = parent;
622 platform_add_devices(mop500_platform_devs,
623 ARRAY_SIZE(mop500_platform_devs));
625 mop500_i2c_init(parent);
626 mop500_sdi_init(parent);
627 mop500_spi_init(parent);
628 mop500_audio_init(parent);
629 mop500_uart_init(parent);
631 u8500_cryp1_hash1_init(parent);
633 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
635 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
636 i2c_register_board_info(2, mop500_i2c2_devices,
637 ARRAY_SIZE(mop500_i2c2_devices));
639 /* This board has full regulator constraints */
640 regulator_has_full_constraints();
643 static void __init snowball_init_machine(void)
645 struct device *parent = NULL;
648 platform_device_register(&db8500_prcmu_device);
650 sdi0_reg_info.enable_gpio = SNOWBALL_SDMMC_EN_GPIO;
651 sdi0_reg_info.gpios[0].gpio = SNOWBALL_SDMMC_1V8_3V_GPIO;
653 snowball_pinmaps_init();
654 parent = u8500_init_devices();
656 for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
657 snowball_platform_devs[i]->dev.parent = parent;
659 platform_add_devices(snowball_platform_devs,
660 ARRAY_SIZE(snowball_platform_devs));
662 mop500_i2c_init(parent);
663 snowball_sdi_init(parent);
664 mop500_spi_init(parent);
665 mop500_audio_init(parent);
666 mop500_uart_init(parent);
668 /* This board has full regulator constraints */
669 regulator_has_full_constraints();
672 static void __init hrefv60_init_machine(void)
674 struct device *parent = NULL;
678 platform_device_register(&db8500_prcmu_device);
680 * The HREFv60 board removed a GPIO expander and routed
681 * all these GPIO pins to the internal GPIO controller
684 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
686 sdi0_reg_info.enable_gpio = HREFV60_SDMMC_EN_GPIO;
687 sdi0_reg_info.gpios[0].gpio = HREFV60_SDMMC_1V8_3V_GPIO;
689 hrefv60_pinmaps_init();
690 parent = u8500_init_devices();
692 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
693 mop500_platform_devs[i]->dev.parent = parent;
695 platform_add_devices(mop500_platform_devs,
696 ARRAY_SIZE(mop500_platform_devs));
698 mop500_i2c_init(parent);
699 hrefv60_sdi_init(parent);
700 mop500_spi_init(parent);
701 mop500_audio_init(parent);
702 mop500_uart_init(parent);
704 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
706 i2c0_devs -= NUM_PRE_V60_I2C0_DEVICES;
708 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
709 i2c_register_board_info(2, mop500_i2c2_devices,
710 ARRAY_SIZE(mop500_i2c2_devices));
712 /* This board has full regulator constraints */
713 regulator_has_full_constraints();
716 MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
717 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
718 .atag_offset = 0x100,
719 .smp = smp_ops(ux500_smp_ops),
720 .map_io = u8500_map_io,
721 .init_irq = ux500_init_irq,
722 /* we re-use nomadik timer here */
723 .init_time = ux500_timer_init,
724 .init_machine = mop500_init_machine,
725 .init_late = ux500_init_late,
728 MACHINE_START(U8520, "ST-Ericsson U8520 Platform HREFP520")
729 .atag_offset = 0x100,
730 .map_io = u8500_map_io,
731 .init_irq = ux500_init_irq,
732 .init_time = ux500_timer_init,
733 .init_machine = mop500_init_machine,
734 .init_late = ux500_init_late,
737 MACHINE_START(HREFV60, "ST-Ericsson U8500 Platform HREFv60+")
738 .atag_offset = 0x100,
739 .smp = smp_ops(ux500_smp_ops),
740 .map_io = u8500_map_io,
741 .init_irq = ux500_init_irq,
742 .init_time = ux500_timer_init,
743 .init_machine = hrefv60_init_machine,
744 .init_late = ux500_init_late,
747 MACHINE_START(SNOWBALL, "Calao Systems Snowball platform")
748 .atag_offset = 0x100,
749 .smp = smp_ops(ux500_smp_ops),
750 .map_io = u8500_map_io,
751 .init_irq = ux500_init_irq,
752 /* we re-use nomadik timer here */
753 .init_time = ux500_timer_init,
754 .init_machine = snowball_init_machine,