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/i2c.h>
17 #include <linux/i2c/twl4030.h>
18 #include <linux/clk.h>
19 #include <linux/delay.h>
20 #include <linux/regulator/machine.h>
21 #include <linux/gpio.h>
23 #include <mach/mcspi.h>
25 #include <mach/board.h>
26 #include <mach/common.h>
28 #include <mach/gpmc.h>
29 #include <mach/keypad.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 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 int rx51_keymap[] = {
78 KEY(4, 0, KEY_BACKSPACE),
81 KEY(4, 4, KEY_LEFTCTRL),
85 KEY(5, 4, KEY_LEFTSHIFT),
99 KEY(0xff, 5, KEY_F10),
102 static struct twl4030_keypad_data rx51_kp_data = {
105 .keymap = rx51_keymap,
106 .keymapsize = ARRAY_SIZE(rx51_keymap),
110 static struct platform_device *rx51_peripherals_devices[] = {
115 * Timings are taken from smsc-lan91c96-ms.pdf
117 static int smc91x_init_gpmc(int cs)
119 struct gpmc_timings t;
120 const int t2_r = 45; /* t2 in Figure 12.10 */
121 const int t2_w = 30; /* t2 in Figure 12.11 */
122 const int t3 = 15; /* t3 in Figure 12.10 */
123 const int t5_r = 0; /* t5 in Figure 12.10 */
124 const int t6_r = 45; /* t6 in Figure 12.10 */
125 const int t6_w = 0; /* t6 in Figure 12.11 */
126 const int t7_w = 15; /* t7 in Figure 12.11 */
127 const int t15 = 12; /* t15 in Figure 12.2 */
128 const int t20 = 185; /* t20 in Figure 12.2 */
130 memset(&t, 0, sizeof(t));
133 t.cs_rd_off = t3 + t2_r + t5_r; /* Figure 12.10 */
134 t.cs_wr_off = t3 + t2_w + t6_w; /* Figure 12.11 */
135 t.adv_on = t3; /* Figure 12.10 */
136 t.adv_rd_off = t3 + t2_r; /* Figure 12.10 */
137 t.adv_wr_off = t3 + t2_w; /* Figure 12.11 */
138 t.oe_off = t3 + t2_r + t5_r; /* Figure 12.10 */
139 t.oe_on = t.oe_off - t6_r; /* Figure 12.10 */
140 t.we_off = t3 + t2_w + t6_w; /* Figure 12.11 */
141 t.we_on = t.we_off - t7_w; /* Figure 12.11 */
142 t.rd_cycle = t20; /* Figure 12.2 */
143 t.wr_cycle = t20; /* Figure 12.4 */
144 t.access = t3 + t2_r + t5_r; /* Figure 12.10 */
145 t.wr_access = t3 + t2_w + t6_w; /* Figure 12.11 */
147 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, GPMC_CONFIG1_DEVICESIZE_16);
149 return gpmc_cs_set_timings(cs, &t);
152 static void __init rx51_init_smc91x(void)
154 unsigned long cs_mem_base;
157 omap_cfg_reg(U8_34XX_GPIO54_DOWN);
158 omap_cfg_reg(G25_34XX_GPIO86_OUT);
159 omap_cfg_reg(H19_34XX_GPIO164_OUT);
161 if (gpmc_cs_request(SMC91X_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 + 0x300;
167 rx51_smc91x_resources[0].end = cs_mem_base + 0x30f;
169 smc91x_init_gpmc(SMC91X_CS);
171 if (gpio_request(SMC91X_GPIO_IRQ, "SMC91X irq") < 0)
174 gpio_direction_input(SMC91X_GPIO_IRQ);
175 rx51_smc91x_resources[1].start = gpio_to_irq(SMC91X_GPIO_IRQ);
177 ret = gpio_request(SMC91X_GPIO_PWRDWN, "SMC91X powerdown");
180 gpio_direction_output(SMC91X_GPIO_PWRDWN, 0);
182 ret = gpio_request(SMC91X_GPIO_RESET, "SMC91X reset");
185 gpio_direction_output(SMC91X_GPIO_RESET, 0);
186 gpio_set_value(SMC91X_GPIO_RESET, 1);
188 gpio_set_value(SMC91X_GPIO_RESET, 0);
193 gpio_free(SMC91X_GPIO_PWRDWN);
195 gpio_free(SMC91X_GPIO_IRQ);
197 gpmc_cs_free(SMC91X_CS);
199 printk(KERN_ERR "Could not initialize smc91x\n");
202 static struct twl4030_madc_platform_data rx51_madc_data = {
206 static struct twl4030_hsmmc_info mmc[] = {
225 static struct regulator_consumer_supply rx51_vmmc1_supply = {
229 static struct regulator_consumer_supply rx51_vmmc2_supply = {
233 static struct regulator_consumer_supply rx51_vsim_supply = {
234 .supply = "vmmc_aux",
237 static struct regulator_init_data rx51_vaux1 = {
242 .valid_modes_mask = REGULATOR_MODE_NORMAL
243 | REGULATOR_MODE_STANDBY,
244 .valid_ops_mask = REGULATOR_CHANGE_MODE
245 | REGULATOR_CHANGE_STATUS,
249 static struct regulator_init_data rx51_vaux2 = {
254 .valid_modes_mask = REGULATOR_MODE_NORMAL
255 | REGULATOR_MODE_STANDBY,
256 .valid_ops_mask = REGULATOR_CHANGE_MODE
257 | REGULATOR_CHANGE_STATUS,
261 /* VAUX3 - adds more power to VIO_18 rail */
262 static struct regulator_init_data rx51_vaux3 = {
264 .name = "VCAM_DIG_18",
268 .valid_modes_mask = REGULATOR_MODE_NORMAL
269 | REGULATOR_MODE_STANDBY,
270 .valid_ops_mask = REGULATOR_CHANGE_MODE
271 | REGULATOR_CHANGE_STATUS,
275 static struct regulator_init_data rx51_vaux4 = {
277 .name = "VCAM_ANA_28",
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_vmmc1 = {
292 .valid_modes_mask = REGULATOR_MODE_NORMAL
293 | REGULATOR_MODE_STANDBY,
294 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
295 | REGULATOR_CHANGE_MODE
296 | REGULATOR_CHANGE_STATUS,
298 .num_consumer_supplies = 1,
299 .consumer_supplies = &rx51_vmmc1_supply,
302 static struct regulator_init_data rx51_vmmc2 = {
308 .valid_modes_mask = REGULATOR_MODE_NORMAL
309 | REGULATOR_MODE_STANDBY,
310 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
311 | REGULATOR_CHANGE_MODE
312 | REGULATOR_CHANGE_STATUS,
314 .num_consumer_supplies = 1,
315 .consumer_supplies = &rx51_vmmc2_supply,
318 static struct regulator_init_data rx51_vsim = {
320 .name = "VMMC2_IO_18",
324 .valid_modes_mask = REGULATOR_MODE_NORMAL
325 | REGULATOR_MODE_STANDBY,
326 .valid_ops_mask = REGULATOR_CHANGE_MODE
327 | REGULATOR_CHANGE_STATUS,
329 .num_consumer_supplies = 1,
330 .consumer_supplies = &rx51_vsim_supply,
333 static struct regulator_init_data rx51_vdac = {
337 .valid_modes_mask = REGULATOR_MODE_NORMAL
338 | REGULATOR_MODE_STANDBY,
339 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
340 | REGULATOR_CHANGE_MODE
341 | REGULATOR_CHANGE_STATUS,
345 static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
347 /* FIXME this gpio setup is just a placeholder for now */
348 gpio_request(gpio + 6, "backlight_pwm");
349 gpio_direction_output(gpio + 6, 0);
350 gpio_request(gpio + 7, "speaker_en");
351 gpio_direction_output(gpio + 7, 1);
353 /* set up MMC adapters, linking their regulators to them */
354 twl4030_mmc_init(mmc);
355 rx51_vmmc1_supply.dev = mmc[0].dev;
356 rx51_vmmc2_supply.dev = mmc[1].dev;
357 rx51_vsim_supply.dev = mmc[1].dev;
362 static struct twl4030_gpio_platform_data rx51_gpio_data = {
363 .gpio_base = OMAP_MAX_GPIO_LINES,
364 .irq_base = TWL4030_GPIO_IRQ_BASE,
365 .irq_end = TWL4030_GPIO_IRQ_END,
366 .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3)
368 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
369 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
370 | BIT(16) | BIT(17) ,
371 .setup = rx51_twlgpio_setup,
374 static struct twl4030_platform_data rx51_twldata = {
375 .irq_base = TWL4030_IRQ_BASE,
376 .irq_end = TWL4030_IRQ_END,
378 /* platform_data for children goes here */
379 .gpio = &rx51_gpio_data,
380 .keypad = &rx51_kp_data,
381 .madc = &rx51_madc_data,
383 .vaux1 = &rx51_vaux1,
384 .vaux2 = &rx51_vaux2,
385 .vaux3 = &rx51_vaux3,
386 .vaux4 = &rx51_vaux4,
387 .vmmc1 = &rx51_vmmc1,
388 .vmmc2 = &rx51_vmmc2,
393 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
395 I2C_BOARD_INFO("twl5030", 0x48),
396 .flags = I2C_CLIENT_WAKE,
397 .irq = INT_34XX_SYS_NIRQ,
398 .platform_data = &rx51_twldata,
402 static int __init rx51_i2c_init(void)
404 omap_register_i2c_bus(1, 2600, rx51_peripherals_i2c_board_info_1,
405 ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
406 omap_register_i2c_bus(2, 100, NULL, 0);
407 omap_register_i2c_bus(3, 400, NULL, 0);
412 void __init rx51_peripherals_init(void)
414 platform_add_devices(rx51_peripherals_devices,
415 ARRAY_SIZE(rx51_peripherals_devices));