2 * Copyright (C) 2008-2009 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>
16 #include <linux/i2c.h>
17 #include <linux/gpio.h>
18 #include <linux/amba/bus.h>
19 #include <linux/amba/pl022.h>
20 #include <linux/amba/serial.h>
21 #include <linux/spi/spi.h>
22 #include <linux/mfd/ab8500.h>
23 #include <linux/regulator/ab8500.h>
24 #include <linux/mfd/tc3589x.h>
25 #include <linux/mfd/tps6105x.h>
26 #include <linux/mfd/ab8500/gpio.h>
27 #include <linux/leds-lp5521.h>
28 #include <linux/input.h>
29 #include <linux/smsc911x.h>
30 #include <linux/gpio_keys.h>
31 #include <linux/delay.h>
33 #include <linux/leds.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
38 #include <plat/ste_dma40.h>
39 #include <plat/pincfg.h>
40 #include <plat/gpio-nomadik.h>
42 #include <mach/hardware.h>
43 #include <mach/setup.h>
44 #include <mach/devices.h>
45 #include <mach/irqs.h>
47 #include "pins-db8500.h"
48 #include "ste-dma40-db8500.h"
49 #include "devices-db8500.h"
50 #include "board-mop500.h"
51 #include "board-mop500-regulators.h"
53 static struct gpio_led snowball_led_array
[] = {
56 .default_trigger
= "none",
61 static struct gpio_led_platform_data snowball_led_data
= {
62 .leds
= snowball_led_array
,
63 .num_leds
= ARRAY_SIZE(snowball_led_array
),
66 static struct platform_device snowball_led_dev
= {
69 .platform_data
= &snowball_led_data
,
73 static struct ab8500_gpio_platform_data ab8500_gpio_pdata
= {
74 .gpio_base
= MOP500_AB8500_GPIO(0),
75 .irq_base
= MOP500_AB8500_VIR_GPIO_IRQ_BASE
,
76 /* config_reg is the initial configuration of ab8500 pins.
77 * The pins can be configured as GPIO or alt functions based
78 * on value present in GpioSel1 to GpioSel6 and AlternatFunction
79 * register. This is the array of 7 configuration settings.
80 * One has to compile time decide these settings. Below is the
81 * explanation of these setting
82 * GpioSel1 = 0x00 => Pins GPIO1 to GPIO8 are not used as GPIO
83 * GpioSel2 = 0x1E => Pins GPIO10 to GPIO13 are configured as GPIO
84 * GpioSel3 = 0x80 => Pin GPIO24 is configured as GPIO
85 * GpioSel4 = 0x01 => Pin GPIo25 is configured as GPIO
86 * GpioSel5 = 0x7A => Pins GPIO34, GPIO36 to GPIO39 are conf as GPIO
87 * GpioSel6 = 0x00 => Pins GPIO41 & GPIo42 are not configured as GPIO
88 * AlternaFunction = 0x00 => If Pins GPIO10 to 13 are not configured
89 * as GPIO then this register selectes the alternate fucntions
91 .config_reg
= {0x00, 0x1E, 0x80, 0x01,
95 static struct gpio_keys_button snowball_key_array
[] = {
102 .debounce_interval
= 50,
111 .debounce_interval
= 50,
120 .debounce_interval
= 50,
129 .debounce_interval
= 50,
138 .debounce_interval
= 50,
143 static struct gpio_keys_platform_data snowball_key_data
= {
144 .buttons
= snowball_key_array
,
145 .nbuttons
= ARRAY_SIZE(snowball_key_array
),
148 static struct platform_device snowball_key_dev
= {
152 .platform_data
= &snowball_key_data
,
156 static struct smsc911x_platform_config snowball_sbnet_cfg
= {
157 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_HIGH
,
158 .irq_type
= SMSC911X_IRQ_TYPE_PUSH_PULL
,
159 .flags
= SMSC911X_USE_16BIT
| SMSC911X_FORCE_INTERNAL_PHY
,
163 static struct resource sbnet_res
[] = {
165 .name
= "smsc911x-memory",
166 .start
= (0x5000 << 16),
167 .end
= (0x5000 << 16) + 0xffff,
168 .flags
= IORESOURCE_MEM
,
171 .start
= NOMADIK_GPIO_TO_IRQ(140),
172 .end
= NOMADIK_GPIO_TO_IRQ(140),
173 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
177 static struct platform_device snowball_sbnet_dev
= {
179 .num_resources
= ARRAY_SIZE(sbnet_res
),
180 .resource
= sbnet_res
,
182 .platform_data
= &snowball_sbnet_cfg
,
186 static struct ab8500_platform_data ab8500_platdata
= {
187 .irq_base
= MOP500_AB8500_IRQ_BASE
,
188 .regulator_reg_init
= ab8500_regulator_reg_init
,
189 .num_regulator_reg_init
= ARRAY_SIZE(ab8500_regulator_reg_init
),
190 .regulator
= ab8500_regulators
,
191 .num_regulator
= ARRAY_SIZE(ab8500_regulators
),
192 .gpio
= &ab8500_gpio_pdata
,
195 static struct resource ab8500_resources
[] = {
197 .start
= IRQ_DB8500_AB8500
,
198 .end
= IRQ_DB8500_AB8500
,
199 .flags
= IORESOURCE_IRQ
203 struct platform_device ab8500_device
= {
204 .name
= "ab8500-i2c",
207 .platform_data
= &ab8500_platdata
,
210 .resource
= ab8500_resources
,
217 static struct tps6105x_platform_data mop500_tps61052_data
= {
218 .mode
= TPS6105X_MODE_VOLTAGE
,
219 .regulator_data
= &tps61052_regulator
,
226 static void mop500_tc35892_init(struct tc3589x
*tc3589x
, unsigned int base
)
228 mop500_sdi_tc35892_init();
231 static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data
= {
232 .gpio_base
= MOP500_EGPIO(0),
233 .setup
= mop500_tc35892_init
,
236 static struct tc3589x_platform_data mop500_tc35892_data
= {
237 .block
= TC3589x_BLOCK_GPIO
,
238 .gpio
= &mop500_tc35892_gpio_data
,
239 .irq_base
= MOP500_EGPIO_IRQ_BASE
,
242 static struct lp5521_led_config lp5521_pri_led
[] = {
260 static struct lp5521_platform_data __initdata lp5521_pri_data
= {
261 .label
= "lp5521_pri",
262 .led_config
= &lp5521_pri_led
[0],
264 .clock_mode
= LP5521_CLOCK_EXT
,
267 static struct lp5521_led_config lp5521_sec_led
[] = {
285 static struct lp5521_platform_data __initdata lp5521_sec_data
= {
286 .label
= "lp5521_sec",
287 .led_config
= &lp5521_sec_led
[0],
289 .clock_mode
= LP5521_CLOCK_EXT
,
292 static struct i2c_board_info __initdata mop500_i2c0_devices
[] = {
294 I2C_BOARD_INFO("tc3589x", 0x42),
295 .irq
= NOMADIK_GPIO_TO_IRQ(217),
296 .platform_data
= &mop500_tc35892_data
,
298 /* I2C0 devices only available prior to HREFv60 */
300 I2C_BOARD_INFO("tps61052", 0x33),
301 .platform_data
= &mop500_tps61052_data
,
305 #define NUM_PRE_V60_I2C0_DEVICES 1
307 static struct i2c_board_info __initdata mop500_i2c2_devices
[] = {
309 /* lp5521 LED driver, 1st device */
310 I2C_BOARD_INFO("lp5521", 0x33),
311 .platform_data
= &lp5521_pri_data
,
314 /* lp5521 LED driver, 2st device */
315 I2C_BOARD_INFO("lp5521", 0x34),
316 .platform_data
= &lp5521_sec_data
,
319 /* Light sensor Rohm BH1780GLI */
320 I2C_BOARD_INFO("bh1780", 0x29),
324 #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, t_out, _sm) \
325 static struct nmk_i2c_controller u8500_i2c##id##_data = { \
327 * slave data setup time, which is \
328 * 250 ns,100ns,10ns which is 14,6,2 \
329 * respectively for a 48 Mhz \
333 /* Tx FIFO threshold */ \
335 /* Rx FIFO threshold */ \
337 /* std. mode operation */ \
339 /* Slave response timeout(ms) */\
345 * The board uses 4 i2c controllers, initialize all of
346 * them with slave data setup time of 250 ns,
347 * Tx & Rx FIFO threshold values as 8 and standard
350 U8500_I2C_CONTROLLER(0, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST
);
351 U8500_I2C_CONTROLLER(1, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST
);
352 U8500_I2C_CONTROLLER(2, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST
);
353 U8500_I2C_CONTROLLER(3, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST
);
355 static void __init
mop500_i2c_init(void)
357 db8500_add_i2c0(&u8500_i2c0_data
);
358 db8500_add_i2c1(&u8500_i2c1_data
);
359 db8500_add_i2c2(&u8500_i2c2_data
);
360 db8500_add_i2c3(&u8500_i2c3_data
);
363 static struct gpio_keys_button mop500_gpio_keys
[] = {
365 .desc
= "SFH7741 Proximity Sensor",
367 .code
= SW_FRONT_PROXIMITY
,
373 static struct regulator
*prox_regulator
;
374 static int mop500_prox_activate(struct device
*dev
);
375 static void mop500_prox_deactivate(struct device
*dev
);
377 static struct gpio_keys_platform_data mop500_gpio_keys_data
= {
378 .buttons
= mop500_gpio_keys
,
379 .nbuttons
= ARRAY_SIZE(mop500_gpio_keys
),
380 .enable
= mop500_prox_activate
,
381 .disable
= mop500_prox_deactivate
,
384 static struct platform_device mop500_gpio_keys_device
= {
388 .platform_data
= &mop500_gpio_keys_data
,
392 static int mop500_prox_activate(struct device
*dev
)
394 prox_regulator
= regulator_get(&mop500_gpio_keys_device
.dev
,
396 if (IS_ERR(prox_regulator
)) {
397 dev_err(&mop500_gpio_keys_device
.dev
,
399 return PTR_ERR(prox_regulator
);
401 regulator_enable(prox_regulator
);
405 static void mop500_prox_deactivate(struct device
*dev
)
407 regulator_disable(prox_regulator
);
408 regulator_put(prox_regulator
);
411 /* add any platform devices here - TODO */
412 static struct platform_device
*mop500_platform_devs
[] __initdata
= {
413 &mop500_gpio_keys_device
,
417 #ifdef CONFIG_STE_DMA40
418 static struct stedma40_chan_cfg ssp0_dma_cfg_rx
= {
419 .mode
= STEDMA40_MODE_LOGICAL
,
420 .dir
= STEDMA40_PERIPH_TO_MEM
,
421 .src_dev_type
= DB8500_DMA_DEV8_SSP0_RX
,
422 .dst_dev_type
= STEDMA40_DEV_DST_MEMORY
,
423 .src_info
.data_width
= STEDMA40_BYTE_WIDTH
,
424 .dst_info
.data_width
= STEDMA40_BYTE_WIDTH
,
427 static struct stedma40_chan_cfg ssp0_dma_cfg_tx
= {
428 .mode
= STEDMA40_MODE_LOGICAL
,
429 .dir
= STEDMA40_MEM_TO_PERIPH
,
430 .src_dev_type
= STEDMA40_DEV_SRC_MEMORY
,
431 .dst_dev_type
= DB8500_DMA_DEV8_SSP0_TX
,
432 .src_info
.data_width
= STEDMA40_BYTE_WIDTH
,
433 .dst_info
.data_width
= STEDMA40_BYTE_WIDTH
,
437 static struct pl022_ssp_controller ssp0_platform_data
= {
439 #ifdef CONFIG_STE_DMA40
441 .dma_filter
= stedma40_filter
,
442 .dma_rx_param
= &ssp0_dma_cfg_rx
,
443 .dma_tx_param
= &ssp0_dma_cfg_tx
,
447 /* on this platform, gpio 31,142,144,214 &
448 * 224 are connected as chip selects
453 static void __init
mop500_spi_init(void)
455 db8500_add_ssp0(&ssp0_platform_data
);
458 #ifdef CONFIG_STE_DMA40
459 static struct stedma40_chan_cfg uart0_dma_cfg_rx
= {
460 .mode
= STEDMA40_MODE_LOGICAL
,
461 .dir
= STEDMA40_PERIPH_TO_MEM
,
462 .src_dev_type
= DB8500_DMA_DEV13_UART0_RX
,
463 .dst_dev_type
= STEDMA40_DEV_DST_MEMORY
,
464 .src_info
.data_width
= STEDMA40_BYTE_WIDTH
,
465 .dst_info
.data_width
= STEDMA40_BYTE_WIDTH
,
468 static struct stedma40_chan_cfg uart0_dma_cfg_tx
= {
469 .mode
= STEDMA40_MODE_LOGICAL
,
470 .dir
= STEDMA40_MEM_TO_PERIPH
,
471 .src_dev_type
= STEDMA40_DEV_SRC_MEMORY
,
472 .dst_dev_type
= DB8500_DMA_DEV13_UART0_TX
,
473 .src_info
.data_width
= STEDMA40_BYTE_WIDTH
,
474 .dst_info
.data_width
= STEDMA40_BYTE_WIDTH
,
477 static struct stedma40_chan_cfg uart1_dma_cfg_rx
= {
478 .mode
= STEDMA40_MODE_LOGICAL
,
479 .dir
= STEDMA40_PERIPH_TO_MEM
,
480 .src_dev_type
= DB8500_DMA_DEV12_UART1_RX
,
481 .dst_dev_type
= STEDMA40_DEV_DST_MEMORY
,
482 .src_info
.data_width
= STEDMA40_BYTE_WIDTH
,
483 .dst_info
.data_width
= STEDMA40_BYTE_WIDTH
,
486 static struct stedma40_chan_cfg uart1_dma_cfg_tx
= {
487 .mode
= STEDMA40_MODE_LOGICAL
,
488 .dir
= STEDMA40_MEM_TO_PERIPH
,
489 .src_dev_type
= STEDMA40_DEV_SRC_MEMORY
,
490 .dst_dev_type
= DB8500_DMA_DEV12_UART1_TX
,
491 .src_info
.data_width
= STEDMA40_BYTE_WIDTH
,
492 .dst_info
.data_width
= STEDMA40_BYTE_WIDTH
,
495 static struct stedma40_chan_cfg uart2_dma_cfg_rx
= {
496 .mode
= STEDMA40_MODE_LOGICAL
,
497 .dir
= STEDMA40_PERIPH_TO_MEM
,
498 .src_dev_type
= DB8500_DMA_DEV11_UART2_RX
,
499 .dst_dev_type
= STEDMA40_DEV_DST_MEMORY
,
500 .src_info
.data_width
= STEDMA40_BYTE_WIDTH
,
501 .dst_info
.data_width
= STEDMA40_BYTE_WIDTH
,
504 static struct stedma40_chan_cfg uart2_dma_cfg_tx
= {
505 .mode
= STEDMA40_MODE_LOGICAL
,
506 .dir
= STEDMA40_MEM_TO_PERIPH
,
507 .src_dev_type
= STEDMA40_DEV_SRC_MEMORY
,
508 .dst_dev_type
= DB8500_DMA_DEV11_UART2_TX
,
509 .src_info
.data_width
= STEDMA40_BYTE_WIDTH
,
510 .dst_info
.data_width
= STEDMA40_BYTE_WIDTH
,
515 static pin_cfg_t mop500_pins_uart0
[] = {
516 GPIO0_U0_CTSn
| PIN_INPUT_PULLUP
,
517 GPIO1_U0_RTSn
| PIN_OUTPUT_HIGH
,
518 GPIO2_U0_RXD
| PIN_INPUT_PULLUP
,
519 GPIO3_U0_TXD
| PIN_OUTPUT_HIGH
,
522 #define PRCC_K_SOFTRST_SET 0x18
523 #define PRCC_K_SOFTRST_CLEAR 0x1C
524 static void ux500_uart0_reset(void)
526 void __iomem
*prcc_rst_set
, *prcc_rst_clr
;
528 prcc_rst_set
= (void __iomem
*)IO_ADDRESS(U8500_CLKRST1_BASE
+
530 prcc_rst_clr
= (void __iomem
*)IO_ADDRESS(U8500_CLKRST1_BASE
+
531 PRCC_K_SOFTRST_CLEAR
);
533 /* Activate soft reset PRCC_K_SOFTRST_CLEAR */
534 writel((readl(prcc_rst_clr
) | 0x1), prcc_rst_clr
);
537 /* Release soft reset PRCC_K_SOFTRST_SET */
538 writel((readl(prcc_rst_set
) | 0x1), prcc_rst_set
);
542 static void ux500_uart0_init(void)
546 ret
= nmk_config_pins(mop500_pins_uart0
,
547 ARRAY_SIZE(mop500_pins_uart0
));
549 pr_err("pl011: uart pins_enable failed\n");
552 static void ux500_uart0_exit(void)
556 ret
= nmk_config_pins_sleep(mop500_pins_uart0
,
557 ARRAY_SIZE(mop500_pins_uart0
));
559 pr_err("pl011: uart pins_disable failed\n");
562 static struct amba_pl011_data uart0_plat
= {
563 #ifdef CONFIG_STE_DMA40
564 .dma_filter
= stedma40_filter
,
565 .dma_rx_param
= &uart0_dma_cfg_rx
,
566 .dma_tx_param
= &uart0_dma_cfg_tx
,
568 .init
= ux500_uart0_init
,
569 .exit
= ux500_uart0_exit
,
570 .reset
= ux500_uart0_reset
,
573 static struct amba_pl011_data uart1_plat
= {
574 #ifdef CONFIG_STE_DMA40
575 .dma_filter
= stedma40_filter
,
576 .dma_rx_param
= &uart1_dma_cfg_rx
,
577 .dma_tx_param
= &uart1_dma_cfg_tx
,
581 static struct amba_pl011_data uart2_plat
= {
582 #ifdef CONFIG_STE_DMA40
583 .dma_filter
= stedma40_filter
,
584 .dma_rx_param
= &uart2_dma_cfg_rx
,
585 .dma_tx_param
= &uart2_dma_cfg_tx
,
589 static void __init
mop500_uart_init(void)
591 db8500_add_uart0(&uart0_plat
);
592 db8500_add_uart1(&uart1_plat
);
593 db8500_add_uart2(&uart2_plat
);
596 static struct platform_device
*snowball_platform_devs
[] __initdata
= {
603 static void __init
mop500_init_machine(void)
608 * The HREFv60 board removed a GPIO expander and routed
609 * all these GPIO pins to the internal GPIO controller
612 if (!machine_is_snowball()) {
613 if (machine_is_hrefv60())
614 mop500_gpio_keys
[0].gpio
= HREFV60_PROX_SENSE_GPIO
;
616 mop500_gpio_keys
[0].gpio
= GPIO_PROX_SENSOR
;
619 u8500_init_devices();
623 if (machine_is_snowball())
624 platform_add_devices(snowball_platform_devs
,
625 ARRAY_SIZE(snowball_platform_devs
));
627 platform_add_devices(mop500_platform_devs
,
628 ARRAY_SIZE(mop500_platform_devs
));
635 i2c0_devs
= ARRAY_SIZE(mop500_i2c0_devices
);
636 if (machine_is_hrefv60())
637 i2c0_devs
-= NUM_PRE_V60_I2C0_DEVICES
;
639 i2c_register_board_info(0, mop500_i2c0_devices
, i2c0_devs
);
640 i2c_register_board_info(2, mop500_i2c2_devices
,
641 ARRAY_SIZE(mop500_i2c2_devices
));
643 /* This board has full regulator constraints */
644 regulator_has_full_constraints();
647 MACHINE_START(U8500
, "ST-Ericsson MOP500 platform")
648 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
649 .boot_params
= 0x100,
650 .map_io
= u8500_map_io
,
651 .init_irq
= ux500_init_irq
,
652 /* we re-use nomadik timer here */
653 .timer
= &ux500_timer
,
654 .init_machine
= mop500_init_machine
,
657 MACHINE_START(HREFV60
, "ST-Ericsson U8500 Platform HREFv60+")
658 .boot_params
= 0x100,
659 .map_io
= u8500_map_io
,
660 .init_irq
= ux500_init_irq
,
661 .timer
= &ux500_timer
,
662 .init_machine
= mop500_init_machine
,
665 MACHINE_START(SNOWBALL
, "Calao Systems Snowball platform")
666 .boot_params
= 0x100,
667 .map_io
= u8500_map_io
,
668 .init_irq
= ux500_init_irq
,
669 /* we re-use nomadik timer here */
670 .timer
= &ux500_timer
,
671 .init_machine
= mop500_init_machine
,