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>
30 #include <mach/onenand.h>
32 #include "mmc-twl4030.h"
36 #define SMC91X_GPIO_IRQ 54
37 #define SMC91X_GPIO_RESET 164
38 #define SMC91X_GPIO_PWRDWN 86
40 static struct resource rx51_smc91x_resources
[] = {
42 .flags
= IORESOURCE_MEM
,
45 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
49 static struct platform_device rx51_smc91x_device
= {
52 .num_resources
= ARRAY_SIZE(rx51_smc91x_resources
),
53 .resource
= rx51_smc91x_resources
,
56 static int rx51_keymap
[] = {
79 KEY(4, 0, KEY_BACKSPACE
),
82 KEY(4, 4, KEY_LEFTCTRL
),
86 KEY(5, 4, KEY_LEFTSHIFT
),
100 KEY(0xff, 5, KEY_F10
),
103 static struct twl4030_keypad_data rx51_kp_data
= {
106 .keymap
= rx51_keymap
,
107 .keymapsize
= ARRAY_SIZE(rx51_keymap
),
111 static struct platform_device
*rx51_peripherals_devices
[] = {
116 * Timings are taken from smsc-lan91c96-ms.pdf
118 static int smc91x_init_gpmc(int cs
)
120 struct gpmc_timings t
;
121 const int t2_r
= 45; /* t2 in Figure 12.10 */
122 const int t2_w
= 30; /* t2 in Figure 12.11 */
123 const int t3
= 15; /* t3 in Figure 12.10 */
124 const int t5_r
= 0; /* t5 in Figure 12.10 */
125 const int t6_r
= 45; /* t6 in Figure 12.10 */
126 const int t6_w
= 0; /* t6 in Figure 12.11 */
127 const int t7_w
= 15; /* t7 in Figure 12.11 */
128 const int t15
= 12; /* t15 in Figure 12.2 */
129 const int t20
= 185; /* t20 in Figure 12.2 */
131 memset(&t
, 0, sizeof(t
));
134 t
.cs_rd_off
= t3
+ t2_r
+ t5_r
; /* Figure 12.10 */
135 t
.cs_wr_off
= t3
+ t2_w
+ t6_w
; /* Figure 12.11 */
136 t
.adv_on
= t3
; /* Figure 12.10 */
137 t
.adv_rd_off
= t3
+ t2_r
; /* Figure 12.10 */
138 t
.adv_wr_off
= t3
+ t2_w
; /* Figure 12.11 */
139 t
.oe_off
= t3
+ t2_r
+ t5_r
; /* Figure 12.10 */
140 t
.oe_on
= t
.oe_off
- t6_r
; /* Figure 12.10 */
141 t
.we_off
= t3
+ t2_w
+ t6_w
; /* Figure 12.11 */
142 t
.we_on
= t
.we_off
- t7_w
; /* Figure 12.11 */
143 t
.rd_cycle
= t20
; /* Figure 12.2 */
144 t
.wr_cycle
= t20
; /* Figure 12.4 */
145 t
.access
= t3
+ t2_r
+ t5_r
; /* Figure 12.10 */
146 t
.wr_access
= t3
+ t2_w
+ t6_w
; /* Figure 12.11 */
148 gpmc_cs_write_reg(cs
, GPMC_CS_CONFIG1
, GPMC_CONFIG1_DEVICESIZE_16
);
150 return gpmc_cs_set_timings(cs
, &t
);
153 static void __init
rx51_init_smc91x(void)
155 unsigned long cs_mem_base
;
158 omap_cfg_reg(U8_34XX_GPIO54_DOWN
);
159 omap_cfg_reg(G25_34XX_GPIO86_OUT
);
160 omap_cfg_reg(H19_34XX_GPIO164_OUT
);
162 if (gpmc_cs_request(SMC91X_CS
, SZ_16M
, &cs_mem_base
) < 0) {
163 printk(KERN_ERR
"Failed to request GPMC mem for smc91x\n");
167 rx51_smc91x_resources
[0].start
= cs_mem_base
+ 0x300;
168 rx51_smc91x_resources
[0].end
= cs_mem_base
+ 0x30f;
170 smc91x_init_gpmc(SMC91X_CS
);
172 if (gpio_request(SMC91X_GPIO_IRQ
, "SMC91X irq") < 0)
175 gpio_direction_input(SMC91X_GPIO_IRQ
);
176 rx51_smc91x_resources
[1].start
= gpio_to_irq(SMC91X_GPIO_IRQ
);
178 ret
= gpio_request(SMC91X_GPIO_PWRDWN
, "SMC91X powerdown");
181 gpio_direction_output(SMC91X_GPIO_PWRDWN
, 0);
183 ret
= gpio_request(SMC91X_GPIO_RESET
, "SMC91X reset");
186 gpio_direction_output(SMC91X_GPIO_RESET
, 0);
187 gpio_set_value(SMC91X_GPIO_RESET
, 1);
189 gpio_set_value(SMC91X_GPIO_RESET
, 0);
194 gpio_free(SMC91X_GPIO_PWRDWN
);
196 gpio_free(SMC91X_GPIO_IRQ
);
198 gpmc_cs_free(SMC91X_CS
);
200 printk(KERN_ERR
"Could not initialize smc91x\n");
203 static struct twl4030_madc_platform_data rx51_madc_data
= {
207 static struct twl4030_hsmmc_info mmc
[] = {
226 static struct regulator_consumer_supply rx51_vmmc1_supply
= {
230 static struct regulator_consumer_supply rx51_vmmc2_supply
= {
234 static struct regulator_consumer_supply rx51_vsim_supply
= {
235 .supply
= "vmmc_aux",
238 static struct regulator_init_data rx51_vaux1
= {
243 .valid_modes_mask
= REGULATOR_MODE_NORMAL
244 | REGULATOR_MODE_STANDBY
,
245 .valid_ops_mask
= REGULATOR_CHANGE_MODE
246 | REGULATOR_CHANGE_STATUS
,
250 static struct regulator_init_data rx51_vaux2
= {
255 .valid_modes_mask
= REGULATOR_MODE_NORMAL
256 | REGULATOR_MODE_STANDBY
,
257 .valid_ops_mask
= REGULATOR_CHANGE_MODE
258 | REGULATOR_CHANGE_STATUS
,
262 /* VAUX3 - adds more power to VIO_18 rail */
263 static struct regulator_init_data rx51_vaux3
= {
265 .name
= "VCAM_DIG_18",
269 .valid_modes_mask
= REGULATOR_MODE_NORMAL
270 | REGULATOR_MODE_STANDBY
,
271 .valid_ops_mask
= REGULATOR_CHANGE_MODE
272 | REGULATOR_CHANGE_STATUS
,
276 static struct regulator_init_data rx51_vaux4
= {
278 .name
= "VCAM_ANA_28",
282 .valid_modes_mask
= REGULATOR_MODE_NORMAL
283 | REGULATOR_MODE_STANDBY
,
284 .valid_ops_mask
= REGULATOR_CHANGE_MODE
285 | REGULATOR_CHANGE_STATUS
,
289 static struct regulator_init_data rx51_vmmc1
= {
293 .valid_modes_mask
= REGULATOR_MODE_NORMAL
294 | REGULATOR_MODE_STANDBY
,
295 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
296 | REGULATOR_CHANGE_MODE
297 | REGULATOR_CHANGE_STATUS
,
299 .num_consumer_supplies
= 1,
300 .consumer_supplies
= &rx51_vmmc1_supply
,
303 static struct regulator_init_data rx51_vmmc2
= {
309 .valid_modes_mask
= REGULATOR_MODE_NORMAL
310 | REGULATOR_MODE_STANDBY
,
311 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
312 | REGULATOR_CHANGE_MODE
313 | REGULATOR_CHANGE_STATUS
,
315 .num_consumer_supplies
= 1,
316 .consumer_supplies
= &rx51_vmmc2_supply
,
319 static struct regulator_init_data rx51_vsim
= {
321 .name
= "VMMC2_IO_18",
325 .valid_modes_mask
= REGULATOR_MODE_NORMAL
326 | REGULATOR_MODE_STANDBY
,
327 .valid_ops_mask
= REGULATOR_CHANGE_MODE
328 | REGULATOR_CHANGE_STATUS
,
330 .num_consumer_supplies
= 1,
331 .consumer_supplies
= &rx51_vsim_supply
,
334 static struct regulator_init_data rx51_vdac
= {
338 .valid_modes_mask
= REGULATOR_MODE_NORMAL
339 | REGULATOR_MODE_STANDBY
,
340 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
341 | REGULATOR_CHANGE_MODE
342 | REGULATOR_CHANGE_STATUS
,
346 static int rx51_twlgpio_setup(struct device
*dev
, unsigned gpio
, unsigned n
)
348 /* FIXME this gpio setup is just a placeholder for now */
349 gpio_request(gpio
+ 6, "backlight_pwm");
350 gpio_direction_output(gpio
+ 6, 0);
351 gpio_request(gpio
+ 7, "speaker_en");
352 gpio_direction_output(gpio
+ 7, 1);
354 /* set up MMC adapters, linking their regulators to them */
355 twl4030_mmc_init(mmc
);
356 rx51_vmmc1_supply
.dev
= mmc
[0].dev
;
357 rx51_vmmc2_supply
.dev
= mmc
[1].dev
;
358 rx51_vsim_supply
.dev
= mmc
[1].dev
;
363 static struct twl4030_gpio_platform_data rx51_gpio_data
= {
364 .gpio_base
= OMAP_MAX_GPIO_LINES
,
365 .irq_base
= TWL4030_GPIO_IRQ_BASE
,
366 .irq_end
= TWL4030_GPIO_IRQ_END
,
367 .pulldowns
= BIT(0) | BIT(1) | BIT(2) | BIT(3)
369 | BIT(8) | BIT(9) | BIT(10) | BIT(11)
370 | BIT(12) | BIT(13) | BIT(14) | BIT(15)
371 | BIT(16) | BIT(17) ,
372 .setup
= rx51_twlgpio_setup
,
375 static struct twl4030_platform_data rx51_twldata
= {
376 .irq_base
= TWL4030_IRQ_BASE
,
377 .irq_end
= TWL4030_IRQ_END
,
379 /* platform_data for children goes here */
380 .gpio
= &rx51_gpio_data
,
381 .keypad
= &rx51_kp_data
,
382 .madc
= &rx51_madc_data
,
384 .vaux1
= &rx51_vaux1
,
385 .vaux2
= &rx51_vaux2
,
386 .vaux3
= &rx51_vaux3
,
387 .vaux4
= &rx51_vaux4
,
388 .vmmc1
= &rx51_vmmc1
,
389 .vmmc2
= &rx51_vmmc2
,
394 static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1
[] = {
396 I2C_BOARD_INFO("twl5030", 0x48),
397 .flags
= I2C_CLIENT_WAKE
,
398 .irq
= INT_34XX_SYS_NIRQ
,
399 .platform_data
= &rx51_twldata
,
403 static int __init
rx51_i2c_init(void)
405 omap_register_i2c_bus(1, 2600, rx51_peripherals_i2c_board_info_1
,
406 ARRAY_SIZE(rx51_peripherals_i2c_board_info_1
));
407 omap_register_i2c_bus(2, 100, NULL
, 0);
408 omap_register_i2c_bus(3, 400, NULL
, 0);
412 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
413 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
415 static struct mtd_partition onenand_partitions
[] = {
417 .name
= "bootloader",
420 .mask_flags
= MTD_WRITEABLE
, /* Force read-only */
424 .offset
= MTDPART_OFS_APPEND
,
429 .offset
= MTDPART_OFS_APPEND
,
434 .offset
= MTDPART_OFS_APPEND
,
439 .offset
= MTDPART_OFS_APPEND
,
444 .offset
= MTDPART_OFS_APPEND
,
445 .size
= MTDPART_SIZ_FULL
,
449 static struct omap_onenand_platform_data board_onenand_data
= {
452 .parts
= onenand_partitions
,
453 .nr_parts
= ARRAY_SIZE(onenand_partitions
),
456 static void __init
board_onenand_init(void)
458 gpmc_onenand_init(&board_onenand_data
);
463 static inline void board_onenand_init(void)
469 void __init
rx51_peripherals_init(void)
471 platform_add_devices(rx51_peripherals_devices
,
472 ARRAY_SIZE(rx51_peripherals_devices
));
475 board_onenand_init();