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>
32 #define SMC91X_GPIO_IRQ 54
33 #define SMC91X_GPIO_RESET 164
34 #define SMC91X_GPIO_PWRDWN 86
36 #define RX51_TSC2005_RESET_GPIO 104
37 #define RX51_TSC2005_IRQ_GPIO 100
39 static struct resource rx51_smc91x_resources[] = {
41 .flags = IORESOURCE_MEM,
44 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
48 static struct platform_device rx51_smc91x_device = {
51 .num_resources = ARRAY_SIZE(rx51_smc91x_resources),
52 .resource = rx51_smc91x_resources,
55 static struct tsc2005_platform_data tsc2005_config = {
56 .reset_gpio = RX51_TSC2005_RESET_GPIO, /* not used */
58 .ts_x_plate_ohm = 280,
60 .ts_touch_pressure = 1500,
62 .ts_pressure_max = 2048,
63 .ts_pressure_fudge = 2,
70 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[] = {
147 * Timings are taken from smsc-lan91c96-ms.pdf
149 static int smc91x_init_gpmc(int cs)
151 struct gpmc_timings t;
152 const int t2_r = 45; /* t2 in Figure 12.10 */
153 const int t2_w = 30; /* t2 in Figure 12.11 */
154 const int t3 = 15; /* t3 in Figure 12.10 */
155 const int t5_r = 0; /* t5 in Figure 12.10 */
156 const int t6_r = 45; /* t6 in Figure 12.10 */
157 const int t6_w = 0; /* t6 in Figure 12.11 */
158 const int t7_w = 15; /* t7 in Figure 12.11 */
159 const int t15 = 12; /* t15 in Figure 12.2 */
160 const int t20 = 185; /* t20 in Figure 12.2 */
162 memset(&t, 0, sizeof(t));
165 t.cs_rd_off = t3 + t2_r + t5_r; /* Figure 12.10 */
166 t.cs_wr_off = t3 + t2_w + t6_w; /* Figure 12.11 */
167 t.adv_on = t3; /* Figure 12.10 */
168 t.adv_rd_off = t3 + t2_r; /* Figure 12.10 */
169 t.adv_wr_off = t3 + t2_w; /* Figure 12.11 */
170 t.oe_off = t3 + t2_r + t5_r; /* Figure 12.10 */
171 t.oe_on = t.oe_off - t6_r; /* Figure 12.10 */
172 t.we_off = t3 + t2_w + t6_w; /* Figure 12.11 */
173 t.we_on = t.we_off - t7_w; /* Figure 12.11 */
174 t.rd_cycle = t20; /* Figure 12.2 */
175 t.wr_cycle = t20; /* Figure 12.4 */
176 t.access = t3 + t2_r + t5_r; /* Figure 12.10 */
177 t.wr_access = t3 + t2_w + t6_w; /* Figure 12.11 */
179 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, GPMC_CONFIG1_DEVICESIZE_16);
181 return gpmc_cs_set_timings(cs, &t);
184 static void __init rx51_init_smc91x(void)
186 unsigned long cs_mem_base;
189 omap_cfg_reg(U8_34XX_GPIO54_DOWN);
190 omap_cfg_reg(G25_34XX_GPIO86_OUT);
191 omap_cfg_reg(H19_34XX_GPIO164_OUT);
193 if (gpmc_cs_request(SMC91X_CS, SZ_16M, &cs_mem_base) < 0) {
194 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
198 rx51_smc91x_resources[0].start = cs_mem_base + 0x300;
199 rx51_smc91x_resources[0].end = cs_mem_base + 0x30f;
201 smc91x_init_gpmc(SMC91X_CS);
203 if (gpio_request(SMC91X_GPIO_IRQ, "SMC91X irq") < 0)
206 gpio_direction_input(SMC91X_GPIO_IRQ);
207 rx51_smc91x_resources[1].start = gpio_to_irq(SMC91X_GPIO_IRQ);
209 ret = gpio_request(SMC91X_GPIO_PWRDWN, "SMC91X powerdown");
212 gpio_direction_output(SMC91X_GPIO_PWRDWN, 0);
214 ret = gpio_request(SMC91X_GPIO_RESET, "SMC91X reset");
217 gpio_direction_output(SMC91X_GPIO_RESET, 0);
218 gpio_set_value(SMC91X_GPIO_RESET, 1);
220 gpio_set_value(SMC91X_GPIO_RESET, 0);
225 gpio_free(SMC91X_GPIO_PWRDWN);
227 gpio_free(SMC91X_GPIO_IRQ);
229 gpmc_cs_free(SMC91X_CS);
231 printk(KERN_ERR "Could not initialize smc91x\n");
234 static void __init rx51_init_tsc2005(void)
238 r = gpio_request(RX51_TSC2005_IRQ_GPIO, "tsc2005 DAV IRQ");
240 gpio_direction_input(RX51_TSC2005_IRQ_GPIO);
242 printk(KERN_ERR "unable to get DAV GPIO");
246 static struct twl4030_madc_platform_data rx51_madc_data = {
250 static struct regulator_init_data rx51_vaux1 = {
255 .valid_modes_mask = REGULATOR_MODE_NORMAL
256 | REGULATOR_MODE_STANDBY,
257 .valid_ops_mask = REGULATOR_CHANGE_MODE
258 | REGULATOR_CHANGE_STATUS,
262 static struct regulator_init_data rx51_vaux2 = {
267 .valid_modes_mask = REGULATOR_MODE_NORMAL
268 | REGULATOR_MODE_STANDBY,
269 .valid_ops_mask = REGULATOR_CHANGE_MODE
270 | REGULATOR_CHANGE_STATUS,
274 /* VAUX3 - adds more power to VIO_18 rail */
275 static struct regulator_init_data rx51_vaux3 = {
277 .name = "VCAM_DIG_18",
281 .valid_modes_mask = REGULATOR_MODE_NORMAL
282 | REGULATOR_MODE_STANDBY,
283 .valid_ops_mask = REGULATOR_CHANGE_MODE
284 | REGULATOR_CHANGE_STATUS,
288 static struct regulator_init_data rx51_vaux4 = {
290 .name = "VCAM_ANA_28",
294 .valid_modes_mask = REGULATOR_MODE_NORMAL
295 | REGULATOR_MODE_STANDBY,
296 .valid_ops_mask = REGULATOR_CHANGE_MODE
297 | REGULATOR_CHANGE_STATUS,
301 static struct regulator_init_data rx51_vmmc1 = {
305 .valid_modes_mask = REGULATOR_MODE_NORMAL
306 | REGULATOR_MODE_STANDBY,
307 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
308 | REGULATOR_CHANGE_MODE
309 | REGULATOR_CHANGE_STATUS,
313 static struct regulator_init_data rx51_vmmc2 = {
319 .valid_modes_mask = REGULATOR_MODE_NORMAL
320 | REGULATOR_MODE_STANDBY,
321 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
322 | REGULATOR_CHANGE_MODE
323 | REGULATOR_CHANGE_STATUS,
327 static struct regulator_init_data rx51_vsim = {
329 .name = "VMMC2_IO_18",
333 .valid_modes_mask = REGULATOR_MODE_NORMAL
334 | REGULATOR_MODE_STANDBY,
335 .valid_ops_mask = REGULATOR_CHANGE_MODE
336 | REGULATOR_CHANGE_STATUS,
340 static struct regulator_init_data rx51_vdac = {
344 .valid_modes_mask = REGULATOR_MODE_NORMAL
345 | REGULATOR_MODE_STANDBY,
346 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
347 | REGULATOR_CHANGE_MODE
348 | REGULATOR_CHANGE_STATUS,
352 static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
354 /* FIXME this gpio setup is just a placeholder for now */
355 gpio_request(gpio + 6, "backlight_pwm");
356 gpio_direction_output(gpio + 6, 0);
357 gpio_request(gpio + 7, "speaker_en");
358 gpio_direction_output(gpio + 7, 1);
360 /* FIXME connect power supplies to devices; register MMC */
365 static struct twl4030_gpio_platform_data rx51_gpio_data = {
366 .gpio_base = OMAP_MAX_GPIO_LINES,
367 .irq_base = TWL4030_GPIO_IRQ_BASE,
368 .irq_end = TWL4030_GPIO_IRQ_END,
369 .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3)
371 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
372 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
373 | BIT(16) | BIT(17) ,
374 .setup = rx51_twlgpio_setup,
377 static struct twl4030_platform_data rx51_twldata = {
378 .irq_base = TWL4030_IRQ_BASE,
379 .irq_end = TWL4030_IRQ_END,
381 /* platform_data for children goes here */
382 .gpio = &rx51_gpio_data,
383 .keypad = &rx51_kp_data,
384 .madc = &rx51_madc_data,
386 .vaux1 = &rx51_vaux1,
387 .vaux2 = &rx51_vaux2,
388 .vaux3 = &rx51_vaux3,
389 .vaux4 = &rx51_vaux4,
390 .vmmc1 = &rx51_vmmc1,
391 .vmmc2 = &rx51_vmmc2,
396 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
398 I2C_BOARD_INFO("twl5030", 0x48),
399 .flags = I2C_CLIENT_WAKE,
400 .irq = INT_34XX_SYS_NIRQ,
401 .platform_data = &rx51_twldata,
405 static int __init rx51_i2c_init(void)
407 omap_register_i2c_bus(1, 2600, rx51_peripherals_i2c_board_info_1,
408 ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
409 omap_register_i2c_bus(2, 100, NULL, 0);
410 omap_register_i2c_bus(3, 400, NULL, 0);
415 void __init rx51_peripherals_init(void)
417 platform_add_devices(rx51_peripherals_devices,
418 ARRAY_SIZE(rx51_peripherals_devices));
419 spi_register_board_info(rx51_peripherals_spi_board_info,
420 ARRAY_SIZE(rx51_peripherals_spi_board_info));