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/spi/spi.h>
21 #include <linux/mfd/ab8500.h>
22 #include <linux/mfd/tc3589x.h>
23 #include <linux/leds-lp5521.h>
24 #include <linux/input.h>
25 #include <linux/gpio_keys.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
30 #include <plat/pincfg.h>
33 #include <mach/hardware.h>
34 #include <mach/setup.h>
35 #include <mach/devices.h>
36 #include <mach/irqs.h>
38 #include "devices-db8500.h"
39 #include "pins-db8500.h"
40 #include "board-mop500.h"
41 #include "board-mop500-regulators.h"
43 static pin_cfg_t mop500_pins[] = {
82 GPIO218_GPIO | PIN_INPUT_PULLUP,
85 GPIO84_GPIO | PIN_INPUT_PULLUP,
88 static struct ab8500_platform_data ab8500_platdata = {
89 .irq_base = MOP500_AB8500_IRQ_BASE,
90 .regulator = ab8500_regulators,
91 .num_regulator = ARRAY_SIZE(ab8500_regulators),
94 static struct resource ab8500_resources[] = {
96 .start = IRQ_DB8500_AB8500,
97 .end = IRQ_DB8500_AB8500,
98 .flags = IORESOURCE_IRQ
102 struct platform_device ab8500_device = {
103 .name = "ab8500-i2c",
106 .platform_data = &ab8500_platdata,
109 .resource = ab8500_resources,
112 static struct pl022_ssp_controller ssp0_platform_data = {
114 /* pl022 not yet supports dma */
116 /* on this platform, gpio 31,142,144,214 &
117 * 224 are connected as chip selects
126 static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
128 mop500_sdi_tc35892_init();
131 static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
132 .gpio_base = MOP500_EGPIO(0),
133 .setup = mop500_tc35892_init,
136 static struct tc3589x_platform_data mop500_tc35892_data = {
137 .block = TC3589x_BLOCK_GPIO,
138 .gpio = &mop500_tc35892_gpio_data,
139 .irq_base = MOP500_EGPIO_IRQ_BASE,
142 static struct lp5521_led_config lp5521_pri_led[] = {
160 static struct lp5521_platform_data __initdata lp5521_pri_data = {
161 .label = "lp5521_pri",
162 .led_config = &lp5521_pri_led[0],
164 .clock_mode = LP5521_CLOCK_EXT,
167 static struct lp5521_led_config lp5521_sec_led[] = {
185 static struct lp5521_platform_data __initdata lp5521_sec_data = {
186 .label = "lp5521_sec",
187 .led_config = &lp5521_sec_led[0],
189 .clock_mode = LP5521_CLOCK_EXT,
192 static struct i2c_board_info mop500_i2c0_devices[] = {
194 I2C_BOARD_INFO("tc3589x", 0x42),
195 .irq = NOMADIK_GPIO_TO_IRQ(217),
196 .platform_data = &mop500_tc35892_data,
200 static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
202 /* lp5521 LED driver, 1st device */
203 I2C_BOARD_INFO("lp5521", 0x33),
204 .platform_data = &lp5521_pri_data,
207 /* lp5521 LED driver, 2st device */
208 I2C_BOARD_INFO("lp5521", 0x34),
209 .platform_data = &lp5521_sec_data,
212 /* Light sensor Rohm BH1780GLI */
213 I2C_BOARD_INFO("bh1780", 0x29),
217 #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
218 static struct nmk_i2c_controller u8500_i2c##id##_data = { \
220 * slave data setup time, which is \
221 * 250 ns,100ns,10ns which is 14,6,2 \
222 * respectively for a 48 Mhz \
226 /* Tx FIFO threshold */ \
228 /* Rx FIFO threshold */ \
230 /* std. mode operation */ \
236 * The board uses 4 i2c controllers, initialize all of
237 * them with slave data setup time of 250 ns,
238 * Tx & Rx FIFO threshold values as 1 and standard
241 U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
242 U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
243 U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
244 U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
246 static void __init mop500_i2c_init(void)
248 db8500_add_i2c0(&u8500_i2c0_data);
249 db8500_add_i2c1(&u8500_i2c1_data);
250 db8500_add_i2c2(&u8500_i2c2_data);
251 db8500_add_i2c3(&u8500_i2c3_data);
254 static struct gpio_keys_button mop500_gpio_keys[] = {
256 .desc = "SFH7741 Proximity Sensor",
258 .code = SW_FRONT_PROXIMITY,
259 .gpio = GPIO_PROX_SENSOR,
265 static struct regulator *prox_regulator;
266 static int mop500_prox_activate(struct device *dev);
267 static void mop500_prox_deactivate(struct device *dev);
269 static struct gpio_keys_platform_data mop500_gpio_keys_data = {
270 .buttons = mop500_gpio_keys,
271 .nbuttons = ARRAY_SIZE(mop500_gpio_keys),
272 .enable = mop500_prox_activate,
273 .disable = mop500_prox_deactivate,
276 static struct platform_device mop500_gpio_keys_device = {
280 .platform_data = &mop500_gpio_keys_data,
284 static int mop500_prox_activate(struct device *dev)
286 prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
288 if (IS_ERR(prox_regulator)) {
289 dev_err(&mop500_gpio_keys_device.dev,
291 return PTR_ERR(prox_regulator);
293 regulator_enable(prox_regulator);
297 static void mop500_prox_deactivate(struct device *dev)
299 regulator_disable(prox_regulator);
300 regulator_put(prox_regulator);
303 /* add any platform devices here - TODO */
304 static struct platform_device *platform_devs[] __initdata = {
305 &mop500_gpio_keys_device,
308 static void __init mop500_spi_init(void)
310 db8500_add_ssp0(&ssp0_platform_data);
313 static void __init mop500_uart_init(void)
320 static void __init u8500_init_machine(void)
322 u8500_init_devices();
324 nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins));
326 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
333 platform_device_register(&ab8500_device);
335 i2c_register_board_info(0, mop500_i2c0_devices,
336 ARRAY_SIZE(mop500_i2c0_devices));
337 i2c_register_board_info(2, mop500_i2c2_devices,
338 ARRAY_SIZE(mop500_i2c2_devices));
341 MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
342 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
343 .boot_params = 0x100,
344 .map_io = u8500_map_io,
345 .init_irq = ux500_init_irq,
346 /* we re-use nomadik timer here */
347 .timer = &ux500_timer,
348 .init_machine = u8500_init_machine,