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"
33 #define SYSTEM_REV_B_USES_VAUX3 0x1699
34 #define SYSTEM_REV_S_USES_VAUX3 0x8
37 #define SMC91X_GPIO_IRQ 54
38 #define SMC91X_GPIO_RESET 164
39 #define SMC91X_GPIO_PWRDWN 86
41 #define RX51_TSC2005_RESET_GPIO 104
42 #define RX51_TSC2005_IRQ_GPIO 100
44 static struct resource rx51_smc91x_resources[] = {
46 .flags = IORESOURCE_MEM,
49 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
53 static struct platform_device rx51_smc91x_device = {
56 .num_resources = ARRAY_SIZE(rx51_smc91x_resources),
57 .resource = rx51_smc91x_resources,
60 static struct tsc2005_platform_data tsc2005_config = {
61 .reset_gpio = RX51_TSC2005_RESET_GPIO, /* not used */
63 .ts_x_plate_ohm = 280,
65 .ts_touch_pressure = 1500,
67 .ts_pressure_max = 2048,
68 .ts_pressure_fudge = 2,
75 static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
80 static struct spi_board_info rx51_peripherals_spi_board_info[] = {
82 .modalias = "tsc2005",
85 .irq = OMAP_GPIO_IRQ(RX51_TSC2005_IRQ_GPIO),
86 .max_speed_hz = 6000000,
87 .controller_data = &tsc2005_mcspi_config,
88 .platform_data = &tsc2005_config,
92 static int rx51_keymap[] = {
110 KEY(2, 4, KEY_RIGHT),
111 KEY(3, 0, KEY_COMMA),
113 KEY(3, 2, KEY_ENTER),
115 KEY(4, 0, KEY_BACKSPACE),
118 KEY(4, 4, KEY_LEFTCTRL),
121 KEY(5, 3, KEY_SPACE),
122 KEY(5, 4, KEY_LEFTSHIFT),
126 KEY(6, 3, KEY_SPACE),
132 KEY(0xff, 0, KEY_F6),
133 KEY(0xff, 1, KEY_F7),
134 KEY(0xff, 2, KEY_F8),
135 KEY(0xff, 4, KEY_F9),
136 KEY(0xff, 5, KEY_F10),
139 static struct twl4030_keypad_data rx51_kp_data = {
142 .keymap = rx51_keymap,
143 .keymapsize = ARRAY_SIZE(rx51_keymap),
147 static struct platform_device *rx51_peripherals_devices[] = {
152 * Timings are taken from smsc-lan91c96-ms.pdf
154 static int smc91x_init_gpmc(int cs)
156 struct gpmc_timings t;
157 const int t2_r = 45; /* t2 in Figure 12.10 */
158 const int t2_w = 30; /* t2 in Figure 12.11 */
159 const int t3 = 15; /* t3 in Figure 12.10 */
160 const int t5_r = 0; /* t5 in Figure 12.10 */
161 const int t6_r = 45; /* t6 in Figure 12.10 */
162 const int t6_w = 0; /* t6 in Figure 12.11 */
163 const int t7_w = 15; /* t7 in Figure 12.11 */
164 const int t15 = 12; /* t15 in Figure 12.2 */
165 const int t20 = 185; /* t20 in Figure 12.2 */
167 memset(&t, 0, sizeof(t));
170 t.cs_rd_off = t3 + t2_r + t5_r; /* Figure 12.10 */
171 t.cs_wr_off = t3 + t2_w + t6_w; /* Figure 12.11 */
172 t.adv_on = t3; /* Figure 12.10 */
173 t.adv_rd_off = t3 + t2_r; /* Figure 12.10 */
174 t.adv_wr_off = t3 + t2_w; /* Figure 12.11 */
175 t.oe_off = t3 + t2_r + t5_r; /* Figure 12.10 */
176 t.oe_on = t.oe_off - t6_r; /* Figure 12.10 */
177 t.we_off = t3 + t2_w + t6_w; /* Figure 12.11 */
178 t.we_on = t.we_off - t7_w; /* Figure 12.11 */
179 t.rd_cycle = t20; /* Figure 12.2 */
180 t.wr_cycle = t20; /* Figure 12.4 */
181 t.access = t3 + t2_r + t5_r; /* Figure 12.10 */
182 t.wr_access = t3 + t2_w + t6_w; /* Figure 12.11 */
184 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, GPMC_CONFIG1_DEVICESIZE_16);
186 return gpmc_cs_set_timings(cs, &t);
189 static void __init rx51_init_smc91x(void)
191 unsigned long cs_mem_base;
194 omap_cfg_reg(U8_34XX_GPIO54_DOWN);
195 omap_cfg_reg(G25_34XX_GPIO86_OUT);
196 omap_cfg_reg(H19_34XX_GPIO164_OUT);
198 if (gpmc_cs_request(SMC91X_CS, SZ_16M, &cs_mem_base) < 0) {
199 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
203 rx51_smc91x_resources[0].start = cs_mem_base + 0x300;
204 rx51_smc91x_resources[0].end = cs_mem_base + 0x30f;
206 smc91x_init_gpmc(SMC91X_CS);
208 if (gpio_request(SMC91X_GPIO_IRQ, "SMC91X irq") < 0)
211 gpio_direction_input(SMC91X_GPIO_IRQ);
212 rx51_smc91x_resources[1].start = gpio_to_irq(SMC91X_GPIO_IRQ);
214 ret = gpio_request(SMC91X_GPIO_PWRDWN, "SMC91X powerdown");
217 gpio_direction_output(SMC91X_GPIO_PWRDWN, 0);
219 ret = gpio_request(SMC91X_GPIO_RESET, "SMC91X reset");
222 gpio_direction_output(SMC91X_GPIO_RESET, 0);
223 gpio_set_value(SMC91X_GPIO_RESET, 1);
225 gpio_set_value(SMC91X_GPIO_RESET, 0);
230 gpio_free(SMC91X_GPIO_PWRDWN);
232 gpio_free(SMC91X_GPIO_IRQ);
234 gpmc_cs_free(SMC91X_CS);
236 printk(KERN_ERR "Could not initialize smc91x\n");
239 static void __init rx51_init_tsc2005(void)
243 r = gpio_request(RX51_TSC2005_IRQ_GPIO, "tsc2005 DAV IRQ");
245 gpio_direction_input(RX51_TSC2005_IRQ_GPIO);
247 printk(KERN_ERR "unable to get DAV GPIO");
251 static struct twl4030_madc_platform_data rx51_madc_data = {
255 static struct twl4030_hsmmc_info mmc[] = {
274 static struct regulator_consumer_supply rx51_vmmc1_supply = {
278 static struct regulator_consumer_supply rx51_vmmc2_supply = {
282 static struct regulator_consumer_supply rx51_vsim_supply = {
283 .supply = "vmmc_aux",
286 static struct regulator_init_data rx51_vaux1 = {
291 .valid_modes_mask = REGULATOR_MODE_NORMAL
292 | REGULATOR_MODE_STANDBY,
293 .valid_ops_mask = REGULATOR_CHANGE_MODE
294 | REGULATOR_CHANGE_STATUS,
298 static struct regulator_init_data rx51_vaux2 = {
303 .valid_modes_mask = REGULATOR_MODE_NORMAL
304 | REGULATOR_MODE_STANDBY,
305 .valid_ops_mask = REGULATOR_CHANGE_MODE
306 | REGULATOR_CHANGE_STATUS,
310 /* VAUX3 - adds more power to VIO_18 rail */
311 static struct regulator_init_data rx51_vaux3_cam = {
313 .name = "VCAM_DIG_18",
317 .valid_modes_mask = REGULATOR_MODE_NORMAL
318 | REGULATOR_MODE_STANDBY,
319 .valid_ops_mask = REGULATOR_CHANGE_MODE
320 | REGULATOR_CHANGE_STATUS,
324 static struct regulator_init_data rx51_vaux3_mmc = {
330 .valid_modes_mask = REGULATOR_MODE_NORMAL
331 | REGULATOR_MODE_STANDBY,
332 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
333 | REGULATOR_CHANGE_MODE
334 | REGULATOR_CHANGE_STATUS,
336 .num_consumer_supplies = 1,
337 .consumer_supplies = &rx51_vmmc2_supply,
340 static struct regulator_init_data rx51_vaux4 = {
342 .name = "VCAM_ANA_28",
346 .valid_modes_mask = REGULATOR_MODE_NORMAL
347 | REGULATOR_MODE_STANDBY,
348 .valid_ops_mask = REGULATOR_CHANGE_MODE
349 | REGULATOR_CHANGE_STATUS,
353 static struct regulator_init_data rx51_vmmc1 = {
357 .valid_modes_mask = REGULATOR_MODE_NORMAL
358 | REGULATOR_MODE_STANDBY,
359 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
360 | REGULATOR_CHANGE_MODE
361 | REGULATOR_CHANGE_STATUS,
363 .num_consumer_supplies = 1,
364 .consumer_supplies = &rx51_vmmc1_supply,
367 static struct regulator_init_data rx51_vmmc2 = {
373 .valid_modes_mask = REGULATOR_MODE_NORMAL
374 | REGULATOR_MODE_STANDBY,
375 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
376 | REGULATOR_CHANGE_MODE
377 | REGULATOR_CHANGE_STATUS,
379 .num_consumer_supplies = 1,
380 .consumer_supplies = &rx51_vmmc2_supply,
383 static struct regulator_init_data rx51_vsim = {
385 .name = "VMMC2_IO_18",
389 .valid_modes_mask = REGULATOR_MODE_NORMAL
390 | REGULATOR_MODE_STANDBY,
391 .valid_ops_mask = REGULATOR_CHANGE_MODE
392 | REGULATOR_CHANGE_STATUS,
394 .num_consumer_supplies = 1,
395 .consumer_supplies = &rx51_vsim_supply,
398 static struct regulator_init_data rx51_vdac = {
402 .valid_modes_mask = REGULATOR_MODE_NORMAL
403 | REGULATOR_MODE_STANDBY,
404 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
405 | REGULATOR_CHANGE_MODE
406 | REGULATOR_CHANGE_STATUS,
410 static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
412 /* FIXME this gpio setup is just a placeholder for now */
413 gpio_request(gpio + 6, "backlight_pwm");
414 gpio_direction_output(gpio + 6, 0);
415 gpio_request(gpio + 7, "speaker_en");
416 gpio_direction_output(gpio + 7, 1);
418 /* set up MMC adapters, linking their regulators to them */
419 twl4030_mmc_init(mmc);
420 rx51_vmmc1_supply.dev = mmc[0].dev;
421 rx51_vmmc2_supply.dev = mmc[1].dev;
422 rx51_vsim_supply.dev = mmc[1].dev;
427 static struct twl4030_gpio_platform_data rx51_gpio_data = {
428 .gpio_base = OMAP_MAX_GPIO_LINES,
429 .irq_base = TWL4030_GPIO_IRQ_BASE,
430 .irq_end = TWL4030_GPIO_IRQ_END,
431 .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3)
433 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
434 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
435 | BIT(16) | BIT(17) ,
436 .setup = rx51_twlgpio_setup,
439 static struct twl4030_platform_data rx51_twldata = {
440 .irq_base = TWL4030_IRQ_BASE,
441 .irq_end = TWL4030_IRQ_END,
443 /* platform_data for children goes here */
444 .gpio = &rx51_gpio_data,
445 .keypad = &rx51_kp_data,
446 .madc = &rx51_madc_data,
448 .vaux1 = &rx51_vaux1,
449 .vaux2 = &rx51_vaux2,
450 .vaux4 = &rx51_vaux4,
451 .vmmc1 = &rx51_vmmc1,
456 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
458 I2C_BOARD_INFO("twl5030", 0x48),
459 .flags = I2C_CLIENT_WAKE,
460 .irq = INT_34XX_SYS_NIRQ,
461 .platform_data = &rx51_twldata,
465 static int __init rx51_i2c_init(void)
467 if ((system_rev >= SYSTEM_REV_S_USES_VAUX3 && system_rev < 0x100) ||
468 system_rev >= SYSTEM_REV_B_USES_VAUX3)
469 rx51_twldata.vaux3 = &rx51_vaux3_mmc;
471 rx51_twldata.vaux3 = &rx51_vaux3_cam;
472 rx51_twldata.vmmc2 = &rx51_vmmc2;
474 omap_register_i2c_bus(1, 2600, rx51_peripherals_i2c_board_info_1,
475 ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
476 omap_register_i2c_bus(2, 100, NULL, 0);
477 omap_register_i2c_bus(3, 400, NULL, 0);
482 void __init rx51_peripherals_init(void)
484 platform_add_devices(rx51_peripherals_devices,
485 ARRAY_SIZE(rx51_peripherals_devices));
486 spi_register_board_info(rx51_peripherals_spi_board_info,
487 ARRAY_SIZE(rx51_peripherals_spi_board_info));