diff options
-rw-r--r-- | arch/arm/mach-davinci/board-da850-evm.c | 127 |
1 files changed, 99 insertions, 28 deletions
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c index a34df64bea2a..05b2d87d96bd 100644 --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/console.h> | 17 | #include <linux/console.h> |
18 | #include <linux/i2c.h> | 18 | #include <linux/i2c.h> |
19 | #include <linux/i2c/at24.h> | 19 | #include <linux/i2c/at24.h> |
20 | #include <linux/i2c/pca953x.h> | ||
20 | #include <linux/gpio.h> | 21 | #include <linux/gpio.h> |
21 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
22 | #include <linux/mtd/mtd.h> | 23 | #include <linux/mtd/mtd.h> |
@@ -145,10 +146,85 @@ static struct platform_device da850_evm_nandflash_device = { | |||
145 | .resource = da850_evm_nandflash_resource, | 146 | .resource = da850_evm_nandflash_resource, |
146 | }; | 147 | }; |
147 | 148 | ||
149 | static u32 ui_card_detected; | ||
150 | static void da850_evm_setup_nor_nand(void); | ||
151 | |||
152 | static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio, | ||
153 | unsigned ngpio, void *c) | ||
154 | { | ||
155 | int sel_a, sel_b, sel_c, ret; | ||
156 | |||
157 | sel_a = gpio + 7; | ||
158 | sel_b = gpio + 6; | ||
159 | sel_c = gpio + 5; | ||
160 | |||
161 | ret = gpio_request(sel_a, "sel_a"); | ||
162 | if (ret) { | ||
163 | pr_warning("Cannot open UI expander pin %d\n", sel_a); | ||
164 | goto exp_setup_sela_fail; | ||
165 | } | ||
166 | |||
167 | ret = gpio_request(sel_b, "sel_b"); | ||
168 | if (ret) { | ||
169 | pr_warning("Cannot open UI expander pin %d\n", sel_b); | ||
170 | goto exp_setup_selb_fail; | ||
171 | } | ||
172 | |||
173 | ret = gpio_request(sel_c, "sel_c"); | ||
174 | if (ret) { | ||
175 | pr_warning("Cannot open UI expander pin %d\n", sel_c); | ||
176 | goto exp_setup_selc_fail; | ||
177 | } | ||
178 | |||
179 | /* deselect all functionalities */ | ||
180 | gpio_direction_output(sel_a, 1); | ||
181 | gpio_direction_output(sel_b, 1); | ||
182 | gpio_direction_output(sel_c, 1); | ||
183 | |||
184 | ui_card_detected = 1; | ||
185 | pr_info("DA850/OMAP-L138 EVM UI card detected\n"); | ||
186 | |||
187 | da850_evm_setup_nor_nand(); | ||
188 | |||
189 | return 0; | ||
190 | |||
191 | exp_setup_selc_fail: | ||
192 | gpio_free(sel_b); | ||
193 | exp_setup_selb_fail: | ||
194 | gpio_free(sel_a); | ||
195 | exp_setup_sela_fail: | ||
196 | return ret; | ||
197 | } | ||
198 | |||
199 | static int da850_evm_ui_expander_teardown(struct i2c_client *client, | ||
200 | unsigned gpio, unsigned ngpio, void *c) | ||
201 | { | ||
202 | /* deselect all functionalities */ | ||
203 | gpio_set_value(gpio + 5, 1); | ||
204 | gpio_set_value(gpio + 6, 1); | ||
205 | gpio_set_value(gpio + 7, 1); | ||
206 | |||
207 | gpio_free(gpio + 5); | ||
208 | gpio_free(gpio + 6); | ||
209 | gpio_free(gpio + 7); | ||
210 | |||
211 | return 0; | ||
212 | } | ||
213 | |||
214 | static struct pca953x_platform_data da850_evm_ui_expander_info = { | ||
215 | .gpio_base = DAVINCI_N_GPIO, | ||
216 | .setup = da850_evm_ui_expander_setup, | ||
217 | .teardown = da850_evm_ui_expander_teardown, | ||
218 | }; | ||
219 | |||
148 | static struct i2c_board_info __initdata da850_evm_i2c_devices[] = { | 220 | static struct i2c_board_info __initdata da850_evm_i2c_devices[] = { |
149 | { | 221 | { |
150 | I2C_BOARD_INFO("tlv320aic3x", 0x18), | 222 | I2C_BOARD_INFO("tlv320aic3x", 0x18), |
151 | } | 223 | }, |
224 | { | ||
225 | I2C_BOARD_INFO("tca6416", 0x20), | ||
226 | .platform_data = &da850_evm_ui_expander_info, | ||
227 | }, | ||
152 | }; | 228 | }; |
153 | 229 | ||
154 | static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = { | 230 | static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = { |
@@ -399,13 +475,6 @@ static int __init pmic_tps65070_init(void) | |||
399 | ARRAY_SIZE(da850evm_tps65070_info)); | 475 | ARRAY_SIZE(da850evm_tps65070_info)); |
400 | } | 476 | } |
401 | 477 | ||
402 | #if defined(CONFIG_MTD_PHYSMAP) || \ | ||
403 | defined(CONFIG_MTD_PHYSMAP_MODULE) | ||
404 | #define HAS_NOR 1 | ||
405 | #else | ||
406 | #define HAS_NOR 0 | ||
407 | #endif | ||
408 | |||
409 | #if defined(CONFIG_MMC_DAVINCI) || \ | 478 | #if defined(CONFIG_MMC_DAVINCI) || \ |
410 | defined(CONFIG_MMC_DAVINCI_MODULE) | 479 | defined(CONFIG_MMC_DAVINCI_MODULE) |
411 | #define HAS_MMC 1 | 480 | #define HAS_MMC 1 |
@@ -413,6 +482,28 @@ static int __init pmic_tps65070_init(void) | |||
413 | #define HAS_MMC 0 | 482 | #define HAS_MMC 0 |
414 | #endif | 483 | #endif |
415 | 484 | ||
485 | static void da850_evm_setup_nor_nand(void) | ||
486 | { | ||
487 | int ret = 0; | ||
488 | |||
489 | if (ui_card_detected & !HAS_MMC) { | ||
490 | ret = da8xx_pinmux_setup(da850_nand_pins); | ||
491 | if (ret) | ||
492 | pr_warning("da850_evm_init: nand mux setup failed: " | ||
493 | "%d\n", ret); | ||
494 | |||
495 | ret = da8xx_pinmux_setup(da850_nor_pins); | ||
496 | if (ret) | ||
497 | pr_warning("da850_evm_init: nor mux setup failed: %d\n", | ||
498 | ret); | ||
499 | |||
500 | da850_evm_init_nor(); | ||
501 | |||
502 | platform_add_devices(da850_evm_devices, | ||
503 | ARRAY_SIZE(da850_evm_devices)); | ||
504 | } | ||
505 | } | ||
506 | |||
416 | static const short da850_evm_lcdc_pins[] = { | 507 | static const short da850_evm_lcdc_pins[] = { |
417 | DA850_GPIO2_8, DA850_GPIO2_15, | 508 | DA850_GPIO2_8, DA850_GPIO2_15, |
418 | -1 | 509 | -1 |
@@ -428,21 +519,6 @@ static __init void da850_evm_init(void) | |||
428 | pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n", | 519 | pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n", |
429 | ret); | 520 | ret); |
430 | 521 | ||
431 | ret = da8xx_pinmux_setup(da850_nand_pins); | ||
432 | if (ret) | ||
433 | pr_warning("da850_evm_init: nand mux setup failed: %d\n", | ||
434 | ret); | ||
435 | |||
436 | ret = da8xx_pinmux_setup(da850_nor_pins); | ||
437 | if (ret) | ||
438 | pr_warning("da850_evm_init: nor mux setup failed: %d\n", | ||
439 | ret); | ||
440 | |||
441 | da850_evm_init_nor(); | ||
442 | |||
443 | platform_add_devices(da850_evm_devices, | ||
444 | ARRAY_SIZE(da850_evm_devices)); | ||
445 | |||
446 | ret = da8xx_register_edma(); | 522 | ret = da8xx_register_edma(); |
447 | if (ret) | 523 | if (ret) |
448 | pr_warning("da850_evm_init: edma registration failed: %d\n", | 524 | pr_warning("da850_evm_init: edma registration failed: %d\n", |
@@ -478,11 +554,6 @@ static __init void da850_evm_init(void) | |||
478 | ret); | 554 | ret); |
479 | 555 | ||
480 | if (HAS_MMC) { | 556 | if (HAS_MMC) { |
481 | if (HAS_NOR) | ||
482 | pr_warning("WARNING: both NOR Flash and MMC/SD are " | ||
483 | "enabled, but they share AEMIF pins.\n" | ||
484 | "\tDisable one of them.\n"); | ||
485 | |||
486 | ret = da8xx_pinmux_setup(da850_mmcsd0_pins); | 557 | ret = da8xx_pinmux_setup(da850_mmcsd0_pins); |
487 | if (ret) | 558 | if (ret) |
488 | pr_warning("da850_evm_init: mmcsd0 mux setup failed:" | 559 | pr_warning("da850_evm_init: mmcsd0 mux setup failed:" |