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/mfd/tc3589x.h>
29 #include <linux/mfd/tps6105x.h>
30 #include <linux/mfd/abx500/ab8500-gpio.h>
31 #include <linux/mfd/abx500/ab8500-codec.h>
32 #include <linux/platform_data/leds-lp55xx.h>
33 #include <linux/input.h>
34 #include <linux/smsc911x.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>
43 #include <asm/mach/arch.h>
45 #include <mach/hardware.h>
46 #include <mach/setup.h>
47 #include <mach/devices.h>
48 #include <mach/irqs.h>
49 #include <linux/platform_data/crypto-ux500.h>
51 #include "ste-dma40-db8500.h"
52 #include "devices-db8500.h"
53 #include "board-mop500.h"
54 #include "board-mop500-regulators.h"
56 static struct gpio_led snowball_led_array[] = {
59 .default_trigger = "heartbeat",
64 static struct gpio_led_platform_data snowball_led_data = {
65 .leds = snowball_led_array,
66 .num_leds = ARRAY_SIZE(snowball_led_array),
69 static struct platform_device snowball_led_dev = {
72 .platform_data = &snowball_led_data,
76 static struct fixed_voltage_config snowball_gpio_en_3v3_data = {
77 .supply_name = "EN-3V3",
78 .gpio = SNOWBALL_EN_3V3_ETH_GPIO,
79 .microvolts = 3300000,
81 .init_data = &gpio_en_3v3_regulator,
82 .startup_delay = 5000, /* 1200us */
85 static struct platform_device snowball_gpio_en_3v3_regulator_dev = {
86 .name = "reg-fixed-voltage",
89 .platform_data = &snowball_gpio_en_3v3_data,
93 static struct abx500_gpio_platform_data ab8500_gpio_pdata = {
94 .gpio_base = MOP500_AB8500_PIN_GPIO(1),
98 static struct ab8500_codec_platform_data ab8500_codec_pdata = {
100 .mic1_type = AMIC_TYPE_DIFFERENTIAL,
101 .mic2_type = AMIC_TYPE_DIFFERENTIAL,
102 .mic1a_micbias = AMIC_MICBIAS_VAMIC1,
103 .mic1b_micbias = AMIC_MICBIAS_VAMIC1,
104 .mic2_micbias = AMIC_MICBIAS_VAMIC2
106 .ear_cmv = EAR_CMV_0_95V
109 static struct gpio_keys_button snowball_key_array[] = {
116 .debounce_interval = 50,
125 .debounce_interval = 50,
134 .debounce_interval = 50,
143 .debounce_interval = 50,
152 .debounce_interval = 50,
157 static struct gpio_keys_platform_data snowball_key_data = {
158 .buttons = snowball_key_array,
159 .nbuttons = ARRAY_SIZE(snowball_key_array),
162 static struct platform_device snowball_key_dev = {
166 .platform_data = &snowball_key_data,
170 static struct smsc911x_platform_config snowball_sbnet_cfg = {
171 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
172 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
173 .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY,
177 static struct resource sbnet_res[] = {
179 .name = "smsc911x-memory",
180 .start = (0x5000 << 16),
181 .end = (0x5000 << 16) + 0xffff,
182 .flags = IORESOURCE_MEM,
185 .start = NOMADIK_GPIO_TO_IRQ(140),
186 .end = NOMADIK_GPIO_TO_IRQ(140),
187 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
191 static struct platform_device snowball_sbnet_dev = {
193 .num_resources = ARRAY_SIZE(sbnet_res),
194 .resource = sbnet_res,
196 .platform_data = &snowball_sbnet_cfg,
200 struct ab8500_platform_data ab8500_platdata = {
201 .irq_base = MOP500_AB8500_IRQ_BASE,
202 .regulator_reg_init = ab8500_regulator_reg_init,
203 .num_regulator_reg_init = ARRAY_SIZE(ab8500_regulator_reg_init),
204 .regulator = ab8500_regulators,
205 .num_regulator = ARRAY_SIZE(ab8500_regulators),
206 .gpio = &ab8500_gpio_pdata,
207 .codec = &ab8500_codec_pdata,
214 static struct resource db8500_thsens_resources[] = {
216 .name = "IRQ_HOTMON_LOW",
217 .start = IRQ_PRCMU_HOTMON_LOW,
218 .end = IRQ_PRCMU_HOTMON_LOW,
219 .flags = IORESOURCE_IRQ,
222 .name = "IRQ_HOTMON_HIGH",
223 .start = IRQ_PRCMU_HOTMON_HIGH,
224 .end = IRQ_PRCMU_HOTMON_HIGH,
225 .flags = IORESOURCE_IRQ,
229 static struct db8500_thsens_platform_data db8500_thsens_data = {
232 .type = THERMAL_TRIP_ACTIVE,
234 [0] = "thermal-cpufreq-0",
239 .type = THERMAL_TRIP_ACTIVE,
241 [0] = "thermal-cpufreq-0",
246 .type = THERMAL_TRIP_ACTIVE,
248 [0] = "thermal-cpufreq-0",
253 .type = THERMAL_TRIP_CRITICAL,
258 static struct platform_device u8500_thsens_device = {
259 .name = "db8500-thermal",
260 .resource = db8500_thsens_resources,
261 .num_resources = ARRAY_SIZE(db8500_thsens_resources),
263 .platform_data = &db8500_thsens_data,
267 static struct platform_device u8500_cpufreq_cooling_device = {
268 .name = "db8500-cpufreq-cooling",
275 static struct tps6105x_platform_data mop500_tps61052_data = {
276 .mode = TPS6105X_MODE_VOLTAGE,
277 .regulator_data = &tps61052_regulator,
284 static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
286 struct device *parent = NULL;
288 /* FIXME: Is the sdi actually part of tc3589x? */
289 parent = tc3589x->dev;
291 mop500_sdi_tc35892_init(parent);
294 static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
295 .gpio_base = MOP500_EGPIO(0),
296 .setup = mop500_tc35892_init,
299 static struct tc3589x_platform_data mop500_tc35892_data = {
300 .block = TC3589x_BLOCK_GPIO,
301 .gpio = &mop500_tc35892_gpio_data,
302 .irq_base = MOP500_EGPIO_IRQ_BASE,
305 static struct lp55xx_led_config lp5521_pri_led[] = {
323 static struct lp55xx_platform_data __initdata lp5521_pri_data = {
324 .label = "lp5521_pri",
325 .led_config = &lp5521_pri_led[0],
327 .clock_mode = LP55XX_CLOCK_EXT,
330 static struct lp55xx_led_config lp5521_sec_led[] = {
348 static struct lp55xx_platform_data __initdata lp5521_sec_data = {
349 .label = "lp5521_sec",
350 .led_config = &lp5521_sec_led[0],
352 .clock_mode = LP55XX_CLOCK_EXT,
355 static struct i2c_board_info __initdata mop500_i2c0_devices[] = {
357 I2C_BOARD_INFO("tc3589x", 0x42),
358 .irq = NOMADIK_GPIO_TO_IRQ(217),
359 .platform_data = &mop500_tc35892_data,
361 /* I2C0 devices only available prior to HREFv60 */
363 I2C_BOARD_INFO("tps61052", 0x33),
364 .platform_data = &mop500_tps61052_data,
368 #define NUM_PRE_V60_I2C0_DEVICES 1
370 static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
372 /* lp5521 LED driver, 1st device */
373 I2C_BOARD_INFO("lp5521", 0x33),
374 .platform_data = &lp5521_pri_data,
377 /* lp5521 LED driver, 2st device */
378 I2C_BOARD_INFO("lp5521", 0x34),
379 .platform_data = &lp5521_sec_data,
382 /* Light sensor Rohm BH1780GLI */
383 I2C_BOARD_INFO("bh1780", 0x29),
387 static void __init mop500_i2c_init(struct device *parent)
389 db8500_add_i2c0(parent, NULL);
390 db8500_add_i2c1(parent, NULL);
391 db8500_add_i2c2(parent, NULL);
392 db8500_add_i2c3(parent, NULL);
395 static struct gpio_keys_button mop500_gpio_keys[] = {
397 .desc = "SFH7741 Proximity Sensor",
399 .code = SW_FRONT_PROXIMITY,
405 static struct regulator *prox_regulator;
406 static int mop500_prox_activate(struct device *dev);
407 static void mop500_prox_deactivate(struct device *dev);
409 static struct gpio_keys_platform_data mop500_gpio_keys_data = {
410 .buttons = mop500_gpio_keys,
411 .nbuttons = ARRAY_SIZE(mop500_gpio_keys),
412 .enable = mop500_prox_activate,
413 .disable = mop500_prox_deactivate,
416 static struct platform_device mop500_gpio_keys_device = {
420 .platform_data = &mop500_gpio_keys_data,
424 static int mop500_prox_activate(struct device *dev)
426 prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
428 if (IS_ERR(prox_regulator)) {
429 dev_err(&mop500_gpio_keys_device.dev,
431 return PTR_ERR(prox_regulator);
433 regulator_enable(prox_regulator);
437 static void mop500_prox_deactivate(struct device *dev)
439 regulator_disable(prox_regulator);
440 regulator_put(prox_regulator);
443 void mop500_snowball_ethernet_clock_enable(void)
447 clk = clk_get_sys("fsmc", NULL);
449 clk_prepare_enable(clk);
452 static struct cryp_platform_data u8500_cryp1_platform_data = {
454 .dir = STEDMA40_MEM_TO_PERIPH,
455 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
456 .dst_dev_type = DB8500_DMA_DEV48_CAC1_TX,
457 .src_info.data_width = STEDMA40_WORD_WIDTH,
458 .dst_info.data_width = STEDMA40_WORD_WIDTH,
459 .mode = STEDMA40_MODE_LOGICAL,
460 .src_info.psize = STEDMA40_PSIZE_LOG_4,
461 .dst_info.psize = STEDMA40_PSIZE_LOG_4,
464 .dir = STEDMA40_PERIPH_TO_MEM,
465 .src_dev_type = DB8500_DMA_DEV48_CAC1_RX,
466 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
467 .src_info.data_width = STEDMA40_WORD_WIDTH,
468 .dst_info.data_width = STEDMA40_WORD_WIDTH,
469 .mode = STEDMA40_MODE_LOGICAL,
470 .src_info.psize = STEDMA40_PSIZE_LOG_4,
471 .dst_info.psize = STEDMA40_PSIZE_LOG_4,
475 static struct stedma40_chan_cfg u8500_hash_dma_cfg_tx = {
476 .dir = STEDMA40_MEM_TO_PERIPH,
477 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
478 .dst_dev_type = DB8500_DMA_DEV50_HAC1_TX,
479 .src_info.data_width = STEDMA40_WORD_WIDTH,
480 .dst_info.data_width = STEDMA40_WORD_WIDTH,
481 .mode = STEDMA40_MODE_LOGICAL,
482 .src_info.psize = STEDMA40_PSIZE_LOG_16,
483 .dst_info.psize = STEDMA40_PSIZE_LOG_16,
486 static struct hash_platform_data u8500_hash1_platform_data = {
487 .mem_to_engine = &u8500_hash_dma_cfg_tx,
488 .dma_filter = stedma40_filter,
491 /* add any platform devices here - TODO */
492 static struct platform_device *mop500_platform_devs[] __initdata = {
493 &mop500_gpio_keys_device,
496 #ifdef CONFIG_STE_DMA40
497 static struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
498 .mode = STEDMA40_MODE_LOGICAL,
499 .dir = STEDMA40_PERIPH_TO_MEM,
500 .src_dev_type = DB8500_DMA_DEV8_SSP0_RX,
501 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
502 .src_info.data_width = STEDMA40_BYTE_WIDTH,
503 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
506 static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
507 .mode = STEDMA40_MODE_LOGICAL,
508 .dir = STEDMA40_MEM_TO_PERIPH,
509 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
510 .dst_dev_type = DB8500_DMA_DEV8_SSP0_TX,
511 .src_info.data_width = STEDMA40_BYTE_WIDTH,
512 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
516 struct pl022_ssp_controller ssp0_plat = {
518 #ifdef CONFIG_STE_DMA40
520 .dma_filter = stedma40_filter,
521 .dma_rx_param = &ssp0_dma_cfg_rx,
522 .dma_tx_param = &ssp0_dma_cfg_tx,
526 /* on this platform, gpio 31,142,144,214 &
527 * 224 are connected as chip selects
532 static void __init mop500_spi_init(struct device *parent)
534 db8500_add_ssp0(parent, &ssp0_plat);
537 #ifdef CONFIG_STE_DMA40
538 static struct stedma40_chan_cfg uart0_dma_cfg_rx = {
539 .mode = STEDMA40_MODE_LOGICAL,
540 .dir = STEDMA40_PERIPH_TO_MEM,
541 .src_dev_type = DB8500_DMA_DEV13_UART0_RX,
542 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
543 .src_info.data_width = STEDMA40_BYTE_WIDTH,
544 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
547 static struct stedma40_chan_cfg uart0_dma_cfg_tx = {
548 .mode = STEDMA40_MODE_LOGICAL,
549 .dir = STEDMA40_MEM_TO_PERIPH,
550 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
551 .dst_dev_type = DB8500_DMA_DEV13_UART0_TX,
552 .src_info.data_width = STEDMA40_BYTE_WIDTH,
553 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
556 static struct stedma40_chan_cfg uart1_dma_cfg_rx = {
557 .mode = STEDMA40_MODE_LOGICAL,
558 .dir = STEDMA40_PERIPH_TO_MEM,
559 .src_dev_type = DB8500_DMA_DEV12_UART1_RX,
560 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
561 .src_info.data_width = STEDMA40_BYTE_WIDTH,
562 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
565 static struct stedma40_chan_cfg uart1_dma_cfg_tx = {
566 .mode = STEDMA40_MODE_LOGICAL,
567 .dir = STEDMA40_MEM_TO_PERIPH,
568 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
569 .dst_dev_type = DB8500_DMA_DEV12_UART1_TX,
570 .src_info.data_width = STEDMA40_BYTE_WIDTH,
571 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
574 static struct stedma40_chan_cfg uart2_dma_cfg_rx = {
575 .mode = STEDMA40_MODE_LOGICAL,
576 .dir = STEDMA40_PERIPH_TO_MEM,
577 .src_dev_type = DB8500_DMA_DEV11_UART2_RX,
578 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
579 .src_info.data_width = STEDMA40_BYTE_WIDTH,
580 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
583 static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
584 .mode = STEDMA40_MODE_LOGICAL,
585 .dir = STEDMA40_MEM_TO_PERIPH,
586 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
587 .dst_dev_type = DB8500_DMA_DEV11_UART2_TX,
588 .src_info.data_width = STEDMA40_BYTE_WIDTH,
589 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
593 struct amba_pl011_data uart0_plat = {
594 #ifdef CONFIG_STE_DMA40
595 .dma_filter = stedma40_filter,
596 .dma_rx_param = &uart0_dma_cfg_rx,
597 .dma_tx_param = &uart0_dma_cfg_tx,
601 struct amba_pl011_data uart1_plat = {
602 #ifdef CONFIG_STE_DMA40
603 .dma_filter = stedma40_filter,
604 .dma_rx_param = &uart1_dma_cfg_rx,
605 .dma_tx_param = &uart1_dma_cfg_tx,
609 struct amba_pl011_data uart2_plat = {
610 #ifdef CONFIG_STE_DMA40
611 .dma_filter = stedma40_filter,
612 .dma_rx_param = &uart2_dma_cfg_rx,
613 .dma_tx_param = &uart2_dma_cfg_tx,
617 static void __init mop500_uart_init(struct device *parent)
619 db8500_add_uart0(parent, &uart0_plat);
620 db8500_add_uart1(parent, &uart1_plat);
621 db8500_add_uart2(parent, &uart2_plat);
624 static void __init u8500_cryp1_hash1_init(struct device *parent)
626 db8500_add_cryp1(parent, &u8500_cryp1_platform_data);
627 db8500_add_hash1(parent, &u8500_hash1_platform_data);
630 static struct platform_device *snowball_platform_devs[] __initdata = {
634 &snowball_gpio_en_3v3_regulator_dev,
635 &u8500_thsens_device,
636 &u8500_cpufreq_cooling_device,
639 static void __init mop500_init_machine(void)
641 struct device *parent = NULL;
645 platform_device_register(&db8500_prcmu_device);
646 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
648 mop500_pinmaps_init();
649 parent = u8500_init_devices(&ab8500_platdata);
651 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
652 mop500_platform_devs[i]->dev.parent = parent;
654 platform_add_devices(mop500_platform_devs,
655 ARRAY_SIZE(mop500_platform_devs));
657 mop500_i2c_init(parent);
658 mop500_sdi_init(parent);
659 mop500_spi_init(parent);
660 mop500_audio_init(parent);
661 mop500_uart_init(parent);
663 u8500_cryp1_hash1_init(parent);
665 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
667 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
668 i2c_register_board_info(2, mop500_i2c2_devices,
669 ARRAY_SIZE(mop500_i2c2_devices));
671 /* This board has full regulator constraints */
672 regulator_has_full_constraints();
675 static void __init snowball_init_machine(void)
677 struct device *parent = NULL;
680 platform_device_register(&db8500_prcmu_device);
681 snowball_pinmaps_init();
682 parent = u8500_init_devices(&ab8500_platdata);
684 for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
685 snowball_platform_devs[i]->dev.parent = parent;
687 platform_add_devices(snowball_platform_devs,
688 ARRAY_SIZE(snowball_platform_devs));
690 mop500_i2c_init(parent);
691 snowball_sdi_init(parent);
692 mop500_spi_init(parent);
693 mop500_audio_init(parent);
694 mop500_uart_init(parent);
696 mop500_snowball_ethernet_clock_enable();
698 /* This board has full regulator constraints */
699 regulator_has_full_constraints();
702 static void __init hrefv60_init_machine(void)
704 struct device *parent = NULL;
708 platform_device_register(&db8500_prcmu_device);
710 * The HREFv60 board removed a GPIO expander and routed
711 * all these GPIO pins to the internal GPIO controller
714 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
716 hrefv60_pinmaps_init();
717 parent = u8500_init_devices(&ab8500_platdata);
719 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
720 mop500_platform_devs[i]->dev.parent = parent;
722 platform_add_devices(mop500_platform_devs,
723 ARRAY_SIZE(mop500_platform_devs));
725 mop500_i2c_init(parent);
726 hrefv60_sdi_init(parent);
727 mop500_spi_init(parent);
728 mop500_audio_init(parent);
729 mop500_uart_init(parent);
731 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
733 i2c0_devs -= NUM_PRE_V60_I2C0_DEVICES;
735 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
736 i2c_register_board_info(2, mop500_i2c2_devices,
737 ARRAY_SIZE(mop500_i2c2_devices));
739 /* This board has full regulator constraints */
740 regulator_has_full_constraints();
743 MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
744 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
745 .atag_offset = 0x100,
746 .smp = smp_ops(ux500_smp_ops),
747 .map_io = u8500_map_io,
748 .init_irq = ux500_init_irq,
749 /* we re-use nomadik timer here */
750 .init_time = ux500_timer_init,
751 .init_machine = mop500_init_machine,
752 .init_late = ux500_init_late,
755 MACHINE_START(U8520, "ST-Ericsson U8520 Platform HREFP520")
756 .atag_offset = 0x100,
757 .map_io = u8500_map_io,
758 .init_irq = ux500_init_irq,
759 .init_time = ux500_timer_init,
760 .init_machine = mop500_init_machine,
761 .init_late = ux500_init_late,
764 MACHINE_START(HREFV60, "ST-Ericsson U8500 Platform HREFv60+")
765 .atag_offset = 0x100,
766 .smp = smp_ops(ux500_smp_ops),
767 .map_io = u8500_map_io,
768 .init_irq = ux500_init_irq,
769 .init_time = ux500_timer_init,
770 .init_machine = hrefv60_init_machine,
771 .init_late = ux500_init_late,
774 MACHINE_START(SNOWBALL, "Calao Systems Snowball platform")
775 .atag_offset = 0x100,
776 .smp = smp_ops(ux500_smp_ops),
777 .map_io = u8500_map_io,
778 .init_irq = ux500_init_irq,
779 /* we re-use nomadik timer here */
780 .init_time = ux500_timer_init,
781 .init_machine = snowball_init_machine,