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 #include "mmc-twl4030.h"
35 #define SMC91X_GPIO_IRQ 54
36 #define SMC91X_GPIO_RESET 164
37 #define SMC91X_GPIO_PWRDWN 86
39 #define RX51_TSC2005_RESET_GPIO 104
40 #define RX51_TSC2005_IRQ_GPIO 100
42 static struct resource rx51_smc91x_resources[] = {
44 .flags = IORESOURCE_MEM,
47 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
51 static struct platform_device rx51_smc91x_device = {
54 .num_resources = ARRAY_SIZE(rx51_smc91x_resources),
55 .resource = rx51_smc91x_resources,
58 static struct tsc2005_platform_data tsc2005_config = {
59 .reset_gpio = RX51_TSC2005_RESET_GPIO, /* not used */
61 .ts_x_plate_ohm = 280,
63 .ts_touch_pressure = 1500,
65 .ts_pressure_max = 2048,
66 .ts_pressure_fudge = 2,
73 static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
78 static struct spi_board_info rx51_peripherals_spi_board_info[] = {
80 .modalias = "tsc2005",
83 .irq = OMAP_GPIO_IRQ(RX51_TSC2005_IRQ_GPIO),
84 .max_speed_hz = 6000000,
85 .controller_data = &tsc2005_mcspi_config,
86 .platform_data = &tsc2005_config,
90 static int rx51_keymap[] = {
103 KEY(1, 4, KEY_DOWN ),
108 KEY(2, 4, KEY_RIGHT ),
109 KEY(3, 0, KEY_COMMA ),
111 KEY(3, 2, KEY_ENTER ),
113 KEY(4, 0, KEY_BACKSPACE ),
116 KEY(4, 4, KEY_LEFTCTRL),
119 KEY(5, 3, KEY_SPACE),
120 KEY(5, 4, KEY_LEFTSHIFT),
124 KEY(6, 3, KEY_SPACE),
130 KEY(0xff, 0, KEY_F6),
131 KEY(0xff, 1, KEY_F7),
132 KEY(0xff, 2, KEY_F8),
133 KEY(0xff, 4, KEY_F9),
134 KEY(0xff, 5, KEY_F10),
137 static struct twl4030_keypad_data rx51_kp_data = {
140 .keymap = rx51_keymap,
141 .keymapsize = ARRAY_SIZE(rx51_keymap),
145 static struct platform_device *rx51_peripherals_devices[] = {
150 * Timings are taken from smsc-lan91c96-ms.pdf
152 static int smc91x_init_gpmc(int cs)
154 struct gpmc_timings t;
155 const int t2_r = 45; /* t2 in Figure 12.10 */
156 const int t2_w = 30; /* t2 in Figure 12.11 */
157 const int t3 = 15; /* t3 in Figure 12.10 */
158 const int t5_r = 0; /* t5 in Figure 12.10 */
159 const int t6_r = 45; /* t6 in Figure 12.10 */
160 const int t6_w = 0; /* t6 in Figure 12.11 */
161 const int t7_w = 15; /* t7 in Figure 12.11 */
162 const int t15 = 12; /* t15 in Figure 12.2 */
163 const int t20 = 185; /* t20 in Figure 12.2 */
165 memset(&t, 0, sizeof(t));
168 t.cs_rd_off = t3 + t2_r + t5_r; /* Figure 12.10 */
169 t.cs_wr_off = t3 + t2_w + t6_w; /* Figure 12.11 */
170 t.adv_on = t3; /* Figure 12.10 */
171 t.adv_rd_off = t3 + t2_r; /* Figure 12.10 */
172 t.adv_wr_off = t3 + t2_w; /* Figure 12.11 */
173 t.oe_off = t3 + t2_r + t5_r; /* Figure 12.10 */
174 t.oe_on = t.oe_off - t6_r; /* Figure 12.10 */
175 t.we_off = t3 + t2_w + t6_w; /* Figure 12.11 */
176 t.we_on = t.we_off - t7_w; /* Figure 12.11 */
177 t.rd_cycle = t20; /* Figure 12.2 */
178 t.wr_cycle = t20; /* Figure 12.4 */
179 t.access = t3 + t2_r + t5_r; /* Figure 12.10 */
180 t.wr_access = t3 + t2_w + t6_w; /* Figure 12.11 */
182 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, GPMC_CONFIG1_DEVICESIZE_16);
184 return gpmc_cs_set_timings(cs, &t);
187 static void __init rx51_init_smc91x(void)
189 unsigned long cs_mem_base;
192 omap_cfg_reg(U8_34XX_GPIO54_DOWN);
193 omap_cfg_reg(G25_34XX_GPIO86_OUT);
194 omap_cfg_reg(H19_34XX_GPIO164_OUT);
196 if (gpmc_cs_request(SMC91X_CS, SZ_16M, &cs_mem_base) < 0) {
197 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
201 rx51_smc91x_resources[0].start = cs_mem_base + 0x300;
202 rx51_smc91x_resources[0].end = cs_mem_base + 0x30f;
204 smc91x_init_gpmc(SMC91X_CS);
206 if (gpio_request(SMC91X_GPIO_IRQ, "SMC91X irq") < 0)
209 gpio_direction_input(SMC91X_GPIO_IRQ);
210 rx51_smc91x_resources[1].start = gpio_to_irq(SMC91X_GPIO_IRQ);
212 ret = gpio_request(SMC91X_GPIO_PWRDWN, "SMC91X powerdown");
215 gpio_direction_output(SMC91X_GPIO_PWRDWN, 0);
217 ret = gpio_request(SMC91X_GPIO_RESET, "SMC91X reset");
220 gpio_direction_output(SMC91X_GPIO_RESET, 0);
221 gpio_set_value(SMC91X_GPIO_RESET, 1);
223 gpio_set_value(SMC91X_GPIO_RESET, 0);
228 gpio_free(SMC91X_GPIO_PWRDWN);
230 gpio_free(SMC91X_GPIO_IRQ);
232 gpmc_cs_free(SMC91X_CS);
234 printk(KERN_ERR "Could not initialize smc91x\n");
237 static void __init rx51_init_tsc2005(void)
241 r = gpio_request(RX51_TSC2005_IRQ_GPIO, "tsc2005 DAV IRQ");
243 gpio_direction_input(RX51_TSC2005_IRQ_GPIO);
245 printk(KERN_ERR "unable to get DAV GPIO");
249 static struct twl4030_madc_platform_data rx51_madc_data = {
253 static struct twl4030_hsmmc_info mmc[] = {
272 static struct regulator_consumer_supply rx51_vmmc1_supply = {
276 static struct regulator_consumer_supply rx51_vmmc2_supply = {
280 static struct regulator_consumer_supply rx51_vsim_supply = {
281 .supply = "vmmc_aux",
284 static struct regulator_init_data rx51_vaux1 = {
289 .valid_modes_mask = REGULATOR_MODE_NORMAL
290 | REGULATOR_MODE_STANDBY,
291 .valid_ops_mask = REGULATOR_CHANGE_MODE
292 | REGULATOR_CHANGE_STATUS,
296 static struct regulator_init_data rx51_vaux2 = {
301 .valid_modes_mask = REGULATOR_MODE_NORMAL
302 | REGULATOR_MODE_STANDBY,
303 .valid_ops_mask = REGULATOR_CHANGE_MODE
304 | REGULATOR_CHANGE_STATUS,
308 /* VAUX3 - adds more power to VIO_18 rail */
309 static struct regulator_init_data rx51_vaux3 = {
311 .name = "VCAM_DIG_18",
315 .valid_modes_mask = REGULATOR_MODE_NORMAL
316 | REGULATOR_MODE_STANDBY,
317 .valid_ops_mask = REGULATOR_CHANGE_MODE
318 | REGULATOR_CHANGE_STATUS,
322 static struct regulator_init_data rx51_vaux4 = {
324 .name = "VCAM_ANA_28",
328 .valid_modes_mask = REGULATOR_MODE_NORMAL
329 | REGULATOR_MODE_STANDBY,
330 .valid_ops_mask = REGULATOR_CHANGE_MODE
331 | REGULATOR_CHANGE_STATUS,
335 static struct regulator_init_data rx51_vmmc1 = {
339 .valid_modes_mask = REGULATOR_MODE_NORMAL
340 | REGULATOR_MODE_STANDBY,
341 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
342 | REGULATOR_CHANGE_MODE
343 | REGULATOR_CHANGE_STATUS,
345 .num_consumer_supplies = 1,
346 .consumer_supplies = &rx51_vmmc1_supply,
349 static struct regulator_init_data rx51_vmmc2 = {
355 .valid_modes_mask = REGULATOR_MODE_NORMAL
356 | REGULATOR_MODE_STANDBY,
357 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
358 | REGULATOR_CHANGE_MODE
359 | REGULATOR_CHANGE_STATUS,
361 .num_consumer_supplies = 1,
362 .consumer_supplies = &rx51_vmmc2_supply,
365 static struct regulator_init_data rx51_vsim = {
367 .name = "VMMC2_IO_18",
371 .valid_modes_mask = REGULATOR_MODE_NORMAL
372 | REGULATOR_MODE_STANDBY,
373 .valid_ops_mask = REGULATOR_CHANGE_MODE
374 | REGULATOR_CHANGE_STATUS,
376 .num_consumer_supplies = 1,
377 .consumer_supplies = &rx51_vsim_supply,
380 static struct regulator_init_data rx51_vdac = {
384 .valid_modes_mask = REGULATOR_MODE_NORMAL
385 | REGULATOR_MODE_STANDBY,
386 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
387 | REGULATOR_CHANGE_MODE
388 | REGULATOR_CHANGE_STATUS,
392 static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
394 /* FIXME this gpio setup is just a placeholder for now */
395 gpio_request(gpio + 6, "backlight_pwm");
396 gpio_direction_output(gpio + 6, 0);
397 gpio_request(gpio + 7, "speaker_en");
398 gpio_direction_output(gpio + 7, 1);
400 /* set up MMC adapters, linking their regulators to them */
401 twl4030_mmc_init(mmc);
402 rx51_vmmc1_supply.dev = mmc[0].dev;
403 rx51_vmmc2_supply.dev = mmc[1].dev;
404 rx51_vsim_supply.dev = mmc[1].dev;
409 static struct twl4030_gpio_platform_data rx51_gpio_data = {
410 .gpio_base = OMAP_MAX_GPIO_LINES,
411 .irq_base = TWL4030_GPIO_IRQ_BASE,
412 .irq_end = TWL4030_GPIO_IRQ_END,
413 .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3)
415 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
416 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
417 | BIT(16) | BIT(17) ,
418 .setup = rx51_twlgpio_setup,
421 static struct twl4030_platform_data rx51_twldata = {
422 .irq_base = TWL4030_IRQ_BASE,
423 .irq_end = TWL4030_IRQ_END,
425 /* platform_data for children goes here */
426 .gpio = &rx51_gpio_data,
427 .keypad = &rx51_kp_data,
428 .madc = &rx51_madc_data,
430 .vaux1 = &rx51_vaux1,
431 .vaux2 = &rx51_vaux2,
432 .vaux3 = &rx51_vaux3,
433 .vaux4 = &rx51_vaux4,
434 .vmmc1 = &rx51_vmmc1,
435 .vmmc2 = &rx51_vmmc2,
440 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
442 I2C_BOARD_INFO("twl5030", 0x48),
443 .flags = I2C_CLIENT_WAKE,
444 .irq = INT_34XX_SYS_NIRQ,
445 .platform_data = &rx51_twldata,
449 static int __init rx51_i2c_init(void)
451 omap_register_i2c_bus(1, 2600, rx51_peripherals_i2c_board_info_1,
452 ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
453 omap_register_i2c_bus(2, 100, NULL, 0);
454 omap_register_i2c_bus(3, 400, NULL, 0);
459 void __init rx51_peripherals_init(void)
461 platform_add_devices(rx51_peripherals_devices,
462 ARRAY_SIZE(rx51_peripherals_devices));
463 spi_register_board_info(rx51_peripherals_spi_board_info,
464 ARRAY_SIZE(rx51_peripherals_spi_board_info));