2 * linux/arch/arm/mach-omap2/board-rx51-flash.c
4 * Copyright (C) 2008-2009 Nokia
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/platform_device.h>
14 #include <linux/input.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/tsc2005.h>
17 #include <linux/i2c.h>
18 #include <linux/i2c/twl4030.h>
19 #include <linux/clk.h>
20 #include <linux/delay.h>
21 #include <linux/regulator/machine.h>
23 #include <mach/mcspi.h>
24 #include <mach/gpio.h>
26 #include <mach/board.h>
27 #include <mach/common.h>
29 #include <mach/gpmc.h>
31 #define RX51_ETHR_GPIO_IRQ 54
33 #define RX51_TSC2005_RESET_GPIO 104
34 #define RX51_TSC2005_IRQ_GPIO 100
36 #define RX51_SMC91X_CS 1
38 static struct resource rx51_smc91x_resources[] = {
40 .flags = IORESOURCE_MEM,
43 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
47 static struct platform_device rx51_smc91x_device = {
50 .num_resources = ARRAY_SIZE(rx51_smc91x_resources),
51 .resource = rx51_smc91x_resources,
54 static struct tsc2005_platform_data tsc2005_config = {
55 .reset_gpio = RX51_TSC2005_RESET_GPIO, /* not used */
57 .ts_x_plate_ohm = 280,
59 .ts_touch_pressure = 1500,
61 .ts_pressure_max = 2048,
62 .ts_pressure_fudge = 2,
69 static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
75 static struct spi_board_info rx51_peripherals_spi_board_info[] = {
77 .modalias = "tsc2005",
80 .irq = OMAP_GPIO_IRQ(RX51_TSC2005_IRQ_GPIO),
81 .max_speed_hz = 6000000,
82 .controller_data = &tsc2005_mcspi_config,
83 .platform_data = &tsc2005_config,
87 static int rx51_keymap[] = {
100 KEY(1, 4, KEY_DOWN ),
105 KEY(2, 4, KEY_RIGHT ),
106 KEY(3, 0, KEY_COMMA ),
108 KEY(3, 2, KEY_ENTER ),
110 KEY(4, 0, KEY_BACKSPACE ),
113 KEY(4, 4, KEY_LEFTCTRL),
116 KEY(5, 3, KEY_SPACE),
117 KEY(5, 4, KEY_LEFTSHIFT),
121 KEY(6, 3, KEY_SPACE),
127 KEY(0xff, 0, KEY_F6),
128 KEY(0xff, 1, KEY_F7),
129 KEY(0xff, 2, KEY_F8),
130 KEY(0xff, 4, KEY_F9),
131 KEY(0xff, 5, KEY_F10),
134 static struct twl4030_keypad_data rx51_kp_data = {
137 .keymap = rx51_keymap,
138 .keymapsize = ARRAY_SIZE(rx51_keymap),
142 static struct platform_device *rx51_peripherals_devices[] = {
146 static void __init rx51_init_smc91x(void)
149 unsigned long cs_mem_base;
153 eth_cs = RX51_SMC91X_CS;
155 l3ck = clk_get(NULL, "core_l3_ck");
159 rate = clk_get_rate(l3ck);
161 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
162 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
166 rx51_smc91x_resources[0].start = cs_mem_base + 0x0;
167 rx51_smc91x_resources[0].end = cs_mem_base + 0xf;
170 if (gpio_request(RX51_ETHR_GPIO_IRQ, "SMC91X irq") < 0) {
171 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
175 gpio_direction_input(RX51_ETHR_GPIO_IRQ);
176 rx51_smc91x_resources[1].start = gpio_to_irq(RX51_ETHR_GPIO_IRQ);
179 static void __init rx51_init_tsc2005(void)
183 r = gpio_request(RX51_TSC2005_IRQ_GPIO, "tsc2005 DAV IRQ");
185 gpio_direction_input(RX51_TSC2005_IRQ_GPIO);
187 printk(KERN_ERR "unable to get DAV GPIO");
191 static struct twl4030_madc_platform_data rx51_madc_data = {
195 static struct regulator_init_data rx51_vaux1 = {
200 .valid_modes_mask = REGULATOR_MODE_NORMAL
201 | REGULATOR_MODE_STANDBY,
202 .valid_ops_mask = REGULATOR_CHANGE_MODE
203 | REGULATOR_CHANGE_STATUS,
207 static struct regulator_init_data rx51_vaux2 = {
212 .valid_modes_mask = REGULATOR_MODE_NORMAL
213 | REGULATOR_MODE_STANDBY,
214 .valid_ops_mask = REGULATOR_CHANGE_MODE
215 | REGULATOR_CHANGE_STATUS,
219 /* VAUX3 - adds more power to VIO_18 rail */
220 static struct regulator_init_data rx51_vaux3 = {
222 .name = "VCAM_DIG_18",
226 .valid_modes_mask = REGULATOR_MODE_NORMAL
227 | REGULATOR_MODE_STANDBY,
228 .valid_ops_mask = REGULATOR_CHANGE_MODE
229 | REGULATOR_CHANGE_STATUS,
233 static struct regulator_init_data rx51_vaux4 = {
235 .name = "VCAM_ANA_28",
239 .valid_modes_mask = REGULATOR_MODE_NORMAL
240 | REGULATOR_MODE_STANDBY,
241 .valid_ops_mask = REGULATOR_CHANGE_MODE
242 | REGULATOR_CHANGE_STATUS,
246 static struct regulator_init_data rx51_vmmc1 = {
250 .valid_modes_mask = REGULATOR_MODE_NORMAL
251 | REGULATOR_MODE_STANDBY,
252 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
253 | REGULATOR_CHANGE_MODE
254 | REGULATOR_CHANGE_STATUS,
258 static struct regulator_init_data rx51_vmmc2 = {
264 .valid_modes_mask = REGULATOR_MODE_NORMAL
265 | REGULATOR_MODE_STANDBY,
266 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
267 | REGULATOR_CHANGE_MODE
268 | REGULATOR_CHANGE_STATUS,
272 static struct regulator_init_data rx51_vsim = {
274 .name = "VMMC2_IO_18",
278 .valid_modes_mask = REGULATOR_MODE_NORMAL
279 | REGULATOR_MODE_STANDBY,
280 .valid_ops_mask = REGULATOR_CHANGE_MODE
281 | REGULATOR_CHANGE_STATUS,
285 static struct regulator_init_data rx51_vdac = {
289 .valid_modes_mask = REGULATOR_MODE_NORMAL
290 | REGULATOR_MODE_STANDBY,
291 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
292 | REGULATOR_CHANGE_MODE
293 | REGULATOR_CHANGE_STATUS,
297 static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
299 /* FIXME this gpio setup is just a placeholder for now */
300 gpio_request(gpio + 6, "backlight_pwm");
301 gpio_direction_output(gpio + 6, 0);
302 gpio_request(gpio + 7, "speaker_en");
303 gpio_direction_output(gpio + 7, 1);
305 /* FIXME connect power supplies to devices; register MMC */
310 static struct twl4030_gpio_platform_data rx51_gpio_data = {
311 .gpio_base = OMAP_MAX_GPIO_LINES,
312 .irq_base = TWL4030_GPIO_IRQ_BASE,
313 .irq_end = TWL4030_GPIO_IRQ_END,
314 .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3)
316 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
317 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
318 | BIT(16) | BIT(17) ,
319 .setup = rx51_twlgpio_setup,
322 static struct twl4030_platform_data rx51_twldata = {
323 .irq_base = TWL4030_IRQ_BASE,
324 .irq_end = TWL4030_IRQ_END,
326 /* platform_data for children goes here */
327 .gpio = &rx51_gpio_data,
328 .keypad = &rx51_kp_data,
329 .madc = &rx51_madc_data,
331 .vaux1 = &rx51_vaux1,
332 .vaux2 = &rx51_vaux2,
333 .vaux3 = &rx51_vaux3,
334 .vaux4 = &rx51_vaux4,
335 .vmmc1 = &rx51_vmmc1,
336 .vmmc2 = &rx51_vmmc2,
341 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
343 I2C_BOARD_INFO("twl5030", 0x48),
344 .flags = I2C_CLIENT_WAKE,
345 .irq = INT_34XX_SYS_NIRQ,
346 .platform_data = &rx51_twldata,
350 static int __init rx51_i2c_init(void)
352 omap_register_i2c_bus(1, 2600, rx51_peripherals_i2c_board_info_1,
353 ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
354 omap_register_i2c_bus(2, 100, NULL, 0);
355 omap_register_i2c_bus(3, 400, NULL, 0);
360 void __init rx51_peripherals_init(void)
362 platform_add_devices(rx51_peripherals_devices,
363 ARRAY_SIZE(rx51_peripherals_devices));
364 spi_register_board_info(rx51_peripherals_spi_board_info,
365 ARRAY_SIZE(rx51_peripherals_spi_board_info));