3 * Copyright (C) 2008-2009 ST-Ericsson
5 * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2, as
9 * published by the Free Software Foundation.
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/interrupt.h>
15 #include <linux/platform_device.h>
17 #include <linux/i2c.h>
18 #include <linux/platform_data/i2c-nomadik.h>
19 #include <linux/gpio.h>
20 #include <linux/amba/bus.h>
21 #include <linux/amba/pl022.h>
22 #include <linux/amba/serial.h>
23 #include <linux/spi/spi.h>
24 #include <linux/mfd/abx500/ab8500.h>
25 #include <linux/regulator/ab8500.h>
26 #include <linux/regulator/fixed.h>
27 #include <linux/mfd/tc3589x.h>
28 #include <linux/mfd/tps6105x.h>
29 #include <linux/mfd/abx500/ab8500-gpio.h>
30 #include <linux/mfd/abx500/ab8500-codec.h>
31 #include <linux/leds-lp5521.h>
32 #include <linux/input.h>
33 #include <linux/smsc911x.h>
34 #include <linux/gpio_keys.h>
35 #include <linux/delay.h>
36 #include <linux/leds.h>
37 #include <linux/pinctrl/consumer.h>
39 #include <asm/mach-types.h>
40 #include <asm/mach/arch.h>
41 #include <asm/hardware/gic.h>
43 #include <plat/ste_dma40.h>
44 #include <plat/gpio-nomadik.h>
46 #include <mach/hardware.h>
47 #include <mach/setup.h>
48 #include <mach/devices.h>
49 #include <mach/irqs.h>
50 #include <linux/platform_data/crypto-ux500.h>
52 #include "ste-dma40-db8500.h"
53 #include "devices-db8500.h"
54 #include "board-mop500.h"
55 #include "board-mop500-regulators.h"
57 static struct gpio_led snowball_led_array[] = {
60 .default_trigger = "heartbeat",
65 static struct gpio_led_platform_data snowball_led_data = {
66 .leds = snowball_led_array,
67 .num_leds = ARRAY_SIZE(snowball_led_array),
70 static struct platform_device snowball_led_dev = {
73 .platform_data = &snowball_led_data,
77 static struct fixed_voltage_config snowball_gpio_en_3v3_data = {
78 .supply_name = "EN-3V3",
79 .gpio = SNOWBALL_EN_3V3_ETH_GPIO,
80 .microvolts = 3300000,
82 .init_data = &gpio_en_3v3_regulator,
83 .startup_delay = 5000, /* 1200us */
86 static struct platform_device snowball_gpio_en_3v3_regulator_dev = {
87 .name = "reg-fixed-voltage",
90 .platform_data = &snowball_gpio_en_3v3_data,
94 static struct ab8500_gpio_platform_data ab8500_gpio_pdata = {
95 .gpio_base = MOP500_AB8500_PIN_GPIO(1),
96 .irq_base = MOP500_AB8500_VIR_GPIO_IRQ_BASE,
97 /* config_reg is the initial configuration of ab8500 pins.
98 * The pins can be configured as GPIO or alt functions based
99 * on value present in GpioSel1 to GpioSel6 and AlternatFunction
100 * register. This is the array of 7 configuration settings.
101 * One has to compile time decide these settings. Below is the
102 * explanation of these setting
103 * GpioSel1 = 0x00 => Pins GPIO1 to GPIO8 are not used as GPIO
104 * GpioSel2 = 0x1E => Pins GPIO10 to GPIO13 are configured as GPIO
105 * GpioSel3 = 0x80 => Pin GPIO24 is configured as GPIO
106 * GpioSel4 = 0x01 => Pin GPIo25 is configured as GPIO
107 * GpioSel5 = 0x7A => Pins GPIO34, GPIO36 to GPIO39 are conf as GPIO
108 * GpioSel6 = 0x00 => Pins GPIO41 & GPIo42 are not configured as GPIO
109 * AlternaFunction = 0x00 => If Pins GPIO10 to 13 are not configured
110 * as GPIO then this register selectes the alternate fucntions
112 .config_reg = {0x00, 0x1E, 0x80, 0x01,
117 static struct ab8500_codec_platform_data ab8500_codec_pdata = {
119 .mic1_type = AMIC_TYPE_DIFFERENTIAL,
120 .mic2_type = AMIC_TYPE_DIFFERENTIAL,
121 .mic1a_micbias = AMIC_MICBIAS_VAMIC1,
122 .mic1b_micbias = AMIC_MICBIAS_VAMIC1,
123 .mic2_micbias = AMIC_MICBIAS_VAMIC2
125 .ear_cmv = EAR_CMV_0_95V
128 static struct gpio_keys_button snowball_key_array[] = {
135 .debounce_interval = 50,
144 .debounce_interval = 50,
153 .debounce_interval = 50,
162 .debounce_interval = 50,
171 .debounce_interval = 50,
176 static struct gpio_keys_platform_data snowball_key_data = {
177 .buttons = snowball_key_array,
178 .nbuttons = ARRAY_SIZE(snowball_key_array),
181 static struct platform_device snowball_key_dev = {
185 .platform_data = &snowball_key_data,
189 static struct smsc911x_platform_config snowball_sbnet_cfg = {
190 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
191 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
192 .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY,
196 static struct resource sbnet_res[] = {
198 .name = "smsc911x-memory",
199 .start = (0x5000 << 16),
200 .end = (0x5000 << 16) + 0xffff,
201 .flags = IORESOURCE_MEM,
204 .start = NOMADIK_GPIO_TO_IRQ(140),
205 .end = NOMADIK_GPIO_TO_IRQ(140),
206 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
210 static struct platform_device snowball_sbnet_dev = {
212 .num_resources = ARRAY_SIZE(sbnet_res),
213 .resource = sbnet_res,
215 .platform_data = &snowball_sbnet_cfg,
219 static struct ab8500_platform_data ab8500_platdata = {
220 .irq_base = MOP500_AB8500_IRQ_BASE,
221 .regulator_reg_init = ab8500_regulator_reg_init,
222 .num_regulator_reg_init = ARRAY_SIZE(ab8500_regulator_reg_init),
223 .regulator = ab8500_regulators,
224 .num_regulator = ARRAY_SIZE(ab8500_regulators),
225 .gpio = &ab8500_gpio_pdata,
226 .codec = &ab8500_codec_pdata,
233 static struct tps6105x_platform_data mop500_tps61052_data = {
234 .mode = TPS6105X_MODE_VOLTAGE,
235 .regulator_data = &tps61052_regulator,
242 static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
244 struct device *parent = NULL;
246 /* FIXME: Is the sdi actually part of tc3589x? */
247 parent = tc3589x->dev;
249 mop500_sdi_tc35892_init(parent);
252 static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
253 .gpio_base = MOP500_EGPIO(0),
254 .setup = mop500_tc35892_init,
257 static struct tc3589x_platform_data mop500_tc35892_data = {
258 .block = TC3589x_BLOCK_GPIO,
259 .gpio = &mop500_tc35892_gpio_data,
260 .irq_base = MOP500_EGPIO_IRQ_BASE,
263 static struct lp5521_led_config lp5521_pri_led[] = {
281 static struct lp5521_platform_data __initdata lp5521_pri_data = {
282 .label = "lp5521_pri",
283 .led_config = &lp5521_pri_led[0],
285 .clock_mode = LP5521_CLOCK_EXT,
288 static struct lp5521_led_config lp5521_sec_led[] = {
306 static struct lp5521_platform_data __initdata lp5521_sec_data = {
307 .label = "lp5521_sec",
308 .led_config = &lp5521_sec_led[0],
310 .clock_mode = LP5521_CLOCK_EXT,
313 static struct i2c_board_info __initdata mop500_i2c0_devices[] = {
315 I2C_BOARD_INFO("tc3589x", 0x42),
316 .irq = NOMADIK_GPIO_TO_IRQ(217),
317 .platform_data = &mop500_tc35892_data,
319 /* I2C0 devices only available prior to HREFv60 */
321 I2C_BOARD_INFO("tps61052", 0x33),
322 .platform_data = &mop500_tps61052_data,
326 #define NUM_PRE_V60_I2C0_DEVICES 1
328 static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
330 /* lp5521 LED driver, 1st device */
331 I2C_BOARD_INFO("lp5521", 0x33),
332 .platform_data = &lp5521_pri_data,
335 /* lp5521 LED driver, 2st device */
336 I2C_BOARD_INFO("lp5521", 0x34),
337 .platform_data = &lp5521_sec_data,
340 /* Light sensor Rohm BH1780GLI */
341 I2C_BOARD_INFO("bh1780", 0x29),
345 static void __init mop500_i2c_init(struct device *parent)
347 db8500_add_i2c0(parent, NULL);
348 db8500_add_i2c1(parent, NULL);
349 db8500_add_i2c2(parent, NULL);
350 db8500_add_i2c3(parent, NULL);
353 static struct gpio_keys_button mop500_gpio_keys[] = {
355 .desc = "SFH7741 Proximity Sensor",
357 .code = SW_FRONT_PROXIMITY,
363 static struct regulator *prox_regulator;
364 static int mop500_prox_activate(struct device *dev);
365 static void mop500_prox_deactivate(struct device *dev);
367 static struct gpio_keys_platform_data mop500_gpio_keys_data = {
368 .buttons = mop500_gpio_keys,
369 .nbuttons = ARRAY_SIZE(mop500_gpio_keys),
370 .enable = mop500_prox_activate,
371 .disable = mop500_prox_deactivate,
374 static struct platform_device mop500_gpio_keys_device = {
378 .platform_data = &mop500_gpio_keys_data,
382 static int mop500_prox_activate(struct device *dev)
384 prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
386 if (IS_ERR(prox_regulator)) {
387 dev_err(&mop500_gpio_keys_device.dev,
389 return PTR_ERR(prox_regulator);
391 regulator_enable(prox_regulator);
395 static void mop500_prox_deactivate(struct device *dev)
397 regulator_disable(prox_regulator);
398 regulator_put(prox_regulator);
401 static struct cryp_platform_data u8500_cryp1_platform_data = {
403 .dir = STEDMA40_MEM_TO_PERIPH,
404 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
405 .dst_dev_type = DB8500_DMA_DEV48_CAC1_TX,
406 .src_info.data_width = STEDMA40_WORD_WIDTH,
407 .dst_info.data_width = STEDMA40_WORD_WIDTH,
408 .mode = STEDMA40_MODE_LOGICAL,
409 .src_info.psize = STEDMA40_PSIZE_LOG_4,
410 .dst_info.psize = STEDMA40_PSIZE_LOG_4,
413 .dir = STEDMA40_PERIPH_TO_MEM,
414 .src_dev_type = DB8500_DMA_DEV48_CAC1_RX,
415 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
416 .src_info.data_width = STEDMA40_WORD_WIDTH,
417 .dst_info.data_width = STEDMA40_WORD_WIDTH,
418 .mode = STEDMA40_MODE_LOGICAL,
419 .src_info.psize = STEDMA40_PSIZE_LOG_4,
420 .dst_info.psize = STEDMA40_PSIZE_LOG_4,
424 static struct stedma40_chan_cfg u8500_hash_dma_cfg_tx = {
425 .dir = STEDMA40_MEM_TO_PERIPH,
426 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
427 .dst_dev_type = DB8500_DMA_DEV50_HAC1_TX,
428 .src_info.data_width = STEDMA40_WORD_WIDTH,
429 .dst_info.data_width = STEDMA40_WORD_WIDTH,
430 .mode = STEDMA40_MODE_LOGICAL,
431 .src_info.psize = STEDMA40_PSIZE_LOG_16,
432 .dst_info.psize = STEDMA40_PSIZE_LOG_16,
435 static struct hash_platform_data u8500_hash1_platform_data = {
436 .mem_to_engine = &u8500_hash_dma_cfg_tx,
437 .dma_filter = stedma40_filter,
440 /* add any platform devices here - TODO */
441 static struct platform_device *mop500_platform_devs[] __initdata = {
442 &mop500_gpio_keys_device,
445 #ifdef CONFIG_STE_DMA40
446 static struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
447 .mode = STEDMA40_MODE_LOGICAL,
448 .dir = STEDMA40_PERIPH_TO_MEM,
449 .src_dev_type = DB8500_DMA_DEV8_SSP0_RX,
450 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
451 .src_info.data_width = STEDMA40_BYTE_WIDTH,
452 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
455 static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
456 .mode = STEDMA40_MODE_LOGICAL,
457 .dir = STEDMA40_MEM_TO_PERIPH,
458 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
459 .dst_dev_type = DB8500_DMA_DEV8_SSP0_TX,
460 .src_info.data_width = STEDMA40_BYTE_WIDTH,
461 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
465 struct pl022_ssp_controller ssp0_plat = {
467 #ifdef CONFIG_STE_DMA40
469 .dma_filter = stedma40_filter,
470 .dma_rx_param = &ssp0_dma_cfg_rx,
471 .dma_tx_param = &ssp0_dma_cfg_tx,
475 /* on this platform, gpio 31,142,144,214 &
476 * 224 are connected as chip selects
481 static void __init mop500_spi_init(struct device *parent)
483 db8500_add_ssp0(parent, &ssp0_plat);
486 #ifdef CONFIG_STE_DMA40
487 static struct stedma40_chan_cfg uart0_dma_cfg_rx = {
488 .mode = STEDMA40_MODE_LOGICAL,
489 .dir = STEDMA40_PERIPH_TO_MEM,
490 .src_dev_type = DB8500_DMA_DEV13_UART0_RX,
491 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
492 .src_info.data_width = STEDMA40_BYTE_WIDTH,
493 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
496 static struct stedma40_chan_cfg uart0_dma_cfg_tx = {
497 .mode = STEDMA40_MODE_LOGICAL,
498 .dir = STEDMA40_MEM_TO_PERIPH,
499 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
500 .dst_dev_type = DB8500_DMA_DEV13_UART0_TX,
501 .src_info.data_width = STEDMA40_BYTE_WIDTH,
502 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
505 static struct stedma40_chan_cfg uart1_dma_cfg_rx = {
506 .mode = STEDMA40_MODE_LOGICAL,
507 .dir = STEDMA40_PERIPH_TO_MEM,
508 .src_dev_type = DB8500_DMA_DEV12_UART1_RX,
509 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
510 .src_info.data_width = STEDMA40_BYTE_WIDTH,
511 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
514 static struct stedma40_chan_cfg uart1_dma_cfg_tx = {
515 .mode = STEDMA40_MODE_LOGICAL,
516 .dir = STEDMA40_MEM_TO_PERIPH,
517 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
518 .dst_dev_type = DB8500_DMA_DEV12_UART1_TX,
519 .src_info.data_width = STEDMA40_BYTE_WIDTH,
520 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
523 static struct stedma40_chan_cfg uart2_dma_cfg_rx = {
524 .mode = STEDMA40_MODE_LOGICAL,
525 .dir = STEDMA40_PERIPH_TO_MEM,
526 .src_dev_type = DB8500_DMA_DEV11_UART2_RX,
527 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
528 .src_info.data_width = STEDMA40_BYTE_WIDTH,
529 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
532 static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
533 .mode = STEDMA40_MODE_LOGICAL,
534 .dir = STEDMA40_MEM_TO_PERIPH,
535 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
536 .dst_dev_type = DB8500_DMA_DEV11_UART2_TX,
537 .src_info.data_width = STEDMA40_BYTE_WIDTH,
538 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
542 struct amba_pl011_data uart0_plat = {
543 #ifdef CONFIG_STE_DMA40
544 .dma_filter = stedma40_filter,
545 .dma_rx_param = &uart0_dma_cfg_rx,
546 .dma_tx_param = &uart0_dma_cfg_tx,
550 struct amba_pl011_data uart1_plat = {
551 #ifdef CONFIG_STE_DMA40
552 .dma_filter = stedma40_filter,
553 .dma_rx_param = &uart1_dma_cfg_rx,
554 .dma_tx_param = &uart1_dma_cfg_tx,
558 struct amba_pl011_data uart2_plat = {
559 #ifdef CONFIG_STE_DMA40
560 .dma_filter = stedma40_filter,
561 .dma_rx_param = &uart2_dma_cfg_rx,
562 .dma_tx_param = &uart2_dma_cfg_tx,
566 static void __init mop500_uart_init(struct device *parent)
568 db8500_add_uart0(parent, &uart0_plat);
569 db8500_add_uart1(parent, &uart1_plat);
570 db8500_add_uart2(parent, &uart2_plat);
573 static void __init u8500_cryp1_hash1_init(struct device *parent)
575 db8500_add_cryp1(parent, &u8500_cryp1_platform_data);
576 db8500_add_hash1(parent, &u8500_hash1_platform_data);
579 static struct platform_device *snowball_platform_devs[] __initdata = {
583 &snowball_gpio_en_3v3_regulator_dev,
586 static void __init mop500_init_machine(void)
588 struct device *parent = NULL;
592 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
594 mop500_pinmaps_init();
595 parent = u8500_init_devices(&ab8500_platdata);
597 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
598 mop500_platform_devs[i]->dev.parent = parent;
600 platform_add_devices(mop500_platform_devs,
601 ARRAY_SIZE(mop500_platform_devs));
603 mop500_i2c_init(parent);
604 mop500_sdi_init(parent);
605 mop500_spi_init(parent);
606 mop500_audio_init(parent);
607 mop500_uart_init(parent);
609 u8500_cryp1_hash1_init(parent);
611 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
613 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
614 i2c_register_board_info(2, mop500_i2c2_devices,
615 ARRAY_SIZE(mop500_i2c2_devices));
617 /* This board has full regulator constraints */
618 regulator_has_full_constraints();
621 static void __init snowball_init_machine(void)
623 struct device *parent = NULL;
626 snowball_pinmaps_init();
627 parent = u8500_init_devices(&ab8500_platdata);
629 for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
630 snowball_platform_devs[i]->dev.parent = parent;
632 platform_add_devices(snowball_platform_devs,
633 ARRAY_SIZE(snowball_platform_devs));
635 mop500_i2c_init(parent);
636 snowball_sdi_init(parent);
637 mop500_spi_init(parent);
638 mop500_audio_init(parent);
639 mop500_uart_init(parent);
641 /* This board has full regulator constraints */
642 regulator_has_full_constraints();
645 static void __init hrefv60_init_machine(void)
647 struct device *parent = NULL;
652 * The HREFv60 board removed a GPIO expander and routed
653 * all these GPIO pins to the internal GPIO controller
656 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
658 hrefv60_pinmaps_init();
659 parent = u8500_init_devices(&ab8500_platdata);
661 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
662 mop500_platform_devs[i]->dev.parent = parent;
664 platform_add_devices(mop500_platform_devs,
665 ARRAY_SIZE(mop500_platform_devs));
667 mop500_i2c_init(parent);
668 hrefv60_sdi_init(parent);
669 mop500_spi_init(parent);
670 mop500_audio_init(parent);
671 mop500_uart_init(parent);
673 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
675 i2c0_devs -= NUM_PRE_V60_I2C0_DEVICES;
677 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
678 i2c_register_board_info(2, mop500_i2c2_devices,
679 ARRAY_SIZE(mop500_i2c2_devices));
681 /* This board has full regulator constraints */
682 regulator_has_full_constraints();
685 MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
686 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
687 .atag_offset = 0x100,
688 .smp = smp_ops(ux500_smp_ops),
689 .map_io = u8500_map_io,
690 .init_irq = ux500_init_irq,
691 /* we re-use nomadik timer here */
692 .timer = &ux500_timer,
693 .handle_irq = gic_handle_irq,
694 .init_machine = mop500_init_machine,
695 .init_late = ux500_init_late,
698 MACHINE_START(HREFV60, "ST-Ericsson U8500 Platform HREFv60+")
699 .atag_offset = 0x100,
700 .smp = smp_ops(ux500_smp_ops),
701 .map_io = u8500_map_io,
702 .init_irq = ux500_init_irq,
703 .timer = &ux500_timer,
704 .handle_irq = gic_handle_irq,
705 .init_machine = hrefv60_init_machine,
706 .init_late = ux500_init_late,
709 MACHINE_START(SNOWBALL, "Calao Systems Snowball platform")
710 .atag_offset = 0x100,
711 .smp = smp_ops(ux500_smp_ops),
712 .map_io = u8500_map_io,
713 .init_irq = ux500_init_irq,
714 /* we re-use nomadik timer here */
715 .timer = &ux500_timer,
716 .handle_irq = gic_handle_irq,
717 .init_machine = snowball_init_machine,