aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-davinci/board-da850-evm.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-davinci/board-da850-evm.c')
-rw-r--r--arch/arm/mach-davinci/board-da850-evm.c339
1 files changed, 321 insertions, 18 deletions
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index c6e11c682e4c..b01fb2ab944a 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -17,8 +17,10 @@
17#include <linux/i2c.h> 17#include <linux/i2c.h>
18#include <linux/i2c/at24.h> 18#include <linux/i2c/at24.h>
19#include <linux/i2c/pca953x.h> 19#include <linux/i2c/pca953x.h>
20#include <linux/input.h>
20#include <linux/mfd/tps6507x.h> 21#include <linux/mfd/tps6507x.h>
21#include <linux/gpio.h> 22#include <linux/gpio.h>
23#include <linux/gpio_keys.h>
22#include <linux/platform_device.h> 24#include <linux/platform_device.h>
23#include <linux/mtd/mtd.h> 25#include <linux/mtd/mtd.h>
24#include <linux/mtd/nand.h> 26#include <linux/mtd/nand.h>
@@ -266,34 +268,115 @@ static inline void da850_evm_setup_emac_rmii(int rmii_sel)
266 struct davinci_soc_info *soc_info = &davinci_soc_info; 268 struct davinci_soc_info *soc_info = &davinci_soc_info;
267 269
268 soc_info->emac_pdata->rmii_en = 1; 270 soc_info->emac_pdata->rmii_en = 1;
269 gpio_set_value(rmii_sel, 0); 271 gpio_set_value_cansleep(rmii_sel, 0);
270} 272}
271#else 273#else
272static inline void da850_evm_setup_emac_rmii(int rmii_sel) { } 274static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
273#endif 275#endif
274 276
277
278#define DA850_KEYS_DEBOUNCE_MS 10
279/*
280 * At 200ms polling interval it is possible to miss an
281 * event by tapping very lightly on the push button but most
282 * pushes do result in an event; longer intervals require the
283 * user to hold the button whereas shorter intervals require
284 * more CPU time for polling.
285 */
286#define DA850_GPIO_KEYS_POLL_MS 200
287
288enum da850_evm_ui_exp_pins {
289 DA850_EVM_UI_EXP_SEL_C = 5,
290 DA850_EVM_UI_EXP_SEL_B,
291 DA850_EVM_UI_EXP_SEL_A,
292 DA850_EVM_UI_EXP_PB8,
293 DA850_EVM_UI_EXP_PB7,
294 DA850_EVM_UI_EXP_PB6,
295 DA850_EVM_UI_EXP_PB5,
296 DA850_EVM_UI_EXP_PB4,
297 DA850_EVM_UI_EXP_PB3,
298 DA850_EVM_UI_EXP_PB2,
299 DA850_EVM_UI_EXP_PB1,
300};
301
302static const char const *da850_evm_ui_exp[] = {
303 [DA850_EVM_UI_EXP_SEL_C] = "sel_c",
304 [DA850_EVM_UI_EXP_SEL_B] = "sel_b",
305 [DA850_EVM_UI_EXP_SEL_A] = "sel_a",
306 [DA850_EVM_UI_EXP_PB8] = "pb8",
307 [DA850_EVM_UI_EXP_PB7] = "pb7",
308 [DA850_EVM_UI_EXP_PB6] = "pb6",
309 [DA850_EVM_UI_EXP_PB5] = "pb5",
310 [DA850_EVM_UI_EXP_PB4] = "pb4",
311 [DA850_EVM_UI_EXP_PB3] = "pb3",
312 [DA850_EVM_UI_EXP_PB2] = "pb2",
313 [DA850_EVM_UI_EXP_PB1] = "pb1",
314};
315
316#define DA850_N_UI_PB 8
317
318static struct gpio_keys_button da850_evm_ui_keys[] = {
319 [0 ... DA850_N_UI_PB - 1] = {
320 .type = EV_KEY,
321 .active_low = 1,
322 .wakeup = 0,
323 .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
324 .code = -1, /* assigned at runtime */
325 .gpio = -1, /* assigned at runtime */
326 .desc = NULL, /* assigned at runtime */
327 },
328};
329
330static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {
331 .buttons = da850_evm_ui_keys,
332 .nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
333 .poll_interval = DA850_GPIO_KEYS_POLL_MS,
334};
335
336static struct platform_device da850_evm_ui_keys_device = {
337 .name = "gpio-keys-polled",
338 .id = 0,
339 .dev = {
340 .platform_data = &da850_evm_ui_keys_pdata
341 },
342};
343
344static void da850_evm_ui_keys_init(unsigned gpio)
345{
346 int i;
347 struct gpio_keys_button *button;
348
349 for (i = 0; i < DA850_N_UI_PB; i++) {
350 button = &da850_evm_ui_keys[i];
351 button->code = KEY_F8 - i;
352 button->desc = (char *)
353 da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
354 button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
355 }
356}
357
275static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio, 358static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
276 unsigned ngpio, void *c) 359 unsigned ngpio, void *c)
277{ 360{
278 int sel_a, sel_b, sel_c, ret; 361 int sel_a, sel_b, sel_c, ret;
279 362
280 sel_a = gpio + 7; 363 sel_a = gpio + DA850_EVM_UI_EXP_SEL_A;
281 sel_b = gpio + 6; 364 sel_b = gpio + DA850_EVM_UI_EXP_SEL_B;
282 sel_c = gpio + 5; 365 sel_c = gpio + DA850_EVM_UI_EXP_SEL_C;
283 366
284 ret = gpio_request(sel_a, "sel_a"); 367 ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);
285 if (ret) { 368 if (ret) {
286 pr_warning("Cannot open UI expander pin %d\n", sel_a); 369 pr_warning("Cannot open UI expander pin %d\n", sel_a);
287 goto exp_setup_sela_fail; 370 goto exp_setup_sela_fail;
288 } 371 }
289 372
290 ret = gpio_request(sel_b, "sel_b"); 373 ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);
291 if (ret) { 374 if (ret) {
292 pr_warning("Cannot open UI expander pin %d\n", sel_b); 375 pr_warning("Cannot open UI expander pin %d\n", sel_b);
293 goto exp_setup_selb_fail; 376 goto exp_setup_selb_fail;
294 } 377 }
295 378
296 ret = gpio_request(sel_c, "sel_c"); 379 ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);
297 if (ret) { 380 if (ret) {
298 pr_warning("Cannot open UI expander pin %d\n", sel_c); 381 pr_warning("Cannot open UI expander pin %d\n", sel_c);
299 goto exp_setup_selc_fail; 382 goto exp_setup_selc_fail;
@@ -304,6 +387,13 @@ static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
304 gpio_direction_output(sel_b, 1); 387 gpio_direction_output(sel_b, 1);
305 gpio_direction_output(sel_c, 1); 388 gpio_direction_output(sel_c, 1);
306 389
390 da850_evm_ui_keys_init(gpio);
391 ret = platform_device_register(&da850_evm_ui_keys_device);
392 if (ret) {
393 pr_warning("Could not register UI GPIO expander push-buttons");
394 goto exp_setup_keys_fail;
395 }
396
307 ui_card_detected = 1; 397 ui_card_detected = 1;
308 pr_info("DA850/OMAP-L138 EVM UI card detected\n"); 398 pr_info("DA850/OMAP-L138 EVM UI card detected\n");
309 399
@@ -313,6 +403,8 @@ static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
313 403
314 return 0; 404 return 0;
315 405
406exp_setup_keys_fail:
407 gpio_free(sel_c);
316exp_setup_selc_fail: 408exp_setup_selc_fail:
317 gpio_free(sel_b); 409 gpio_free(sel_b);
318exp_setup_selb_fail: 410exp_setup_selb_fail:
@@ -324,14 +416,192 @@ exp_setup_sela_fail:
324static int da850_evm_ui_expander_teardown(struct i2c_client *client, 416static int da850_evm_ui_expander_teardown(struct i2c_client *client,
325 unsigned gpio, unsigned ngpio, void *c) 417 unsigned gpio, unsigned ngpio, void *c)
326{ 418{
419 platform_device_unregister(&da850_evm_ui_keys_device);
420
327 /* deselect all functionalities */ 421 /* deselect all functionalities */
328 gpio_set_value(gpio + 5, 1); 422 gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1);
329 gpio_set_value(gpio + 6, 1); 423 gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1);
330 gpio_set_value(gpio + 7, 1); 424 gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1);
425
426 gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);
427 gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);
428 gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);
429
430 return 0;
431}
432
433/* assign the baseboard expander's GPIOs after the UI board's */
434#define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp)
435#define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS)
436
437enum da850_evm_bb_exp_pins {
438 DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0,
439 DA850_EVM_BB_EXP_SW_RST,
440 DA850_EVM_BB_EXP_TP_23,
441 DA850_EVM_BB_EXP_TP_22,
442 DA850_EVM_BB_EXP_TP_21,
443 DA850_EVM_BB_EXP_USER_PB1,
444 DA850_EVM_BB_EXP_USER_LED2,
445 DA850_EVM_BB_EXP_USER_LED1,
446 DA850_EVM_BB_EXP_USER_SW1,
447 DA850_EVM_BB_EXP_USER_SW2,
448 DA850_EVM_BB_EXP_USER_SW3,
449 DA850_EVM_BB_EXP_USER_SW4,
450 DA850_EVM_BB_EXP_USER_SW5,
451 DA850_EVM_BB_EXP_USER_SW6,
452 DA850_EVM_BB_EXP_USER_SW7,
453 DA850_EVM_BB_EXP_USER_SW8
454};
455
456static const char const *da850_evm_bb_exp[] = {
457 [DA850_EVM_BB_EXP_DEEP_SLEEP_EN] = "deep_sleep_en",
458 [DA850_EVM_BB_EXP_SW_RST] = "sw_rst",
459 [DA850_EVM_BB_EXP_TP_23] = "tp_23",
460 [DA850_EVM_BB_EXP_TP_22] = "tp_22",
461 [DA850_EVM_BB_EXP_TP_21] = "tp_21",
462 [DA850_EVM_BB_EXP_USER_PB1] = "user_pb1",
463 [DA850_EVM_BB_EXP_USER_LED2] = "user_led2",
464 [DA850_EVM_BB_EXP_USER_LED1] = "user_led1",
465 [DA850_EVM_BB_EXP_USER_SW1] = "user_sw1",
466 [DA850_EVM_BB_EXP_USER_SW2] = "user_sw2",
467 [DA850_EVM_BB_EXP_USER_SW3] = "user_sw3",
468 [DA850_EVM_BB_EXP_USER_SW4] = "user_sw4",
469 [DA850_EVM_BB_EXP_USER_SW5] = "user_sw5",
470 [DA850_EVM_BB_EXP_USER_SW6] = "user_sw6",
471 [DA850_EVM_BB_EXP_USER_SW7] = "user_sw7",
472 [DA850_EVM_BB_EXP_USER_SW8] = "user_sw8",
473};
474
475#define DA850_N_BB_USER_SW 8
476
477static struct gpio_keys_button da850_evm_bb_keys[] = {
478 [0] = {
479 .type = EV_KEY,
480 .active_low = 1,
481 .wakeup = 0,
482 .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
483 .code = KEY_PROG1,
484 .desc = NULL, /* assigned at runtime */
485 .gpio = -1, /* assigned at runtime */
486 },
487 [1 ... DA850_N_BB_USER_SW] = {
488 .type = EV_SW,
489 .active_low = 1,
490 .wakeup = 0,
491 .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
492 .code = -1, /* assigned at runtime */
493 .desc = NULL, /* assigned at runtime */
494 .gpio = -1, /* assigned at runtime */
495 },
496};
497
498static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = {
499 .buttons = da850_evm_bb_keys,
500 .nbuttons = ARRAY_SIZE(da850_evm_bb_keys),
501 .poll_interval = DA850_GPIO_KEYS_POLL_MS,
502};
503
504static struct platform_device da850_evm_bb_keys_device = {
505 .name = "gpio-keys-polled",
506 .id = 1,
507 .dev = {
508 .platform_data = &da850_evm_bb_keys_pdata
509 },
510};
511
512static void da850_evm_bb_keys_init(unsigned gpio)
513{
514 int i;
515 struct gpio_keys_button *button;
516
517 button = &da850_evm_bb_keys[0];
518 button->desc = (char *)
519 da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1];
520 button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1;
521
522 for (i = 0; i < DA850_N_BB_USER_SW; i++) {
523 button = &da850_evm_bb_keys[i + 1];
524 button->code = SW_LID + i;
525 button->desc = (char *)
526 da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i];
527 button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i;
528 }
529}
331 530
332 gpio_free(gpio + 5); 531#define DA850_N_BB_USER_LED 2
333 gpio_free(gpio + 6); 532
334 gpio_free(gpio + 7); 533static struct gpio_led da850_evm_bb_leds[] = {
534 [0 ... DA850_N_BB_USER_LED - 1] = {
535 .active_low = 1,
536 .gpio = -1, /* assigned at runtime */
537 .name = NULL, /* assigned at runtime */
538 },
539};
540
541static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
542 .leds = da850_evm_bb_leds,
543 .num_leds = ARRAY_SIZE(da850_evm_bb_leds),
544};
545
546static struct platform_device da850_evm_bb_leds_device = {
547 .name = "leds-gpio",
548 .id = -1,
549 .dev = {
550 .platform_data = &da850_evm_bb_leds_pdata
551 }
552};
553
554static void da850_evm_bb_leds_init(unsigned gpio)
555{
556 int i;
557 struct gpio_led *led;
558
559 for (i = 0; i < DA850_N_BB_USER_LED; i++) {
560 led = &da850_evm_bb_leds[i];
561
562 led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
563 led->name =
564 da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
565 }
566}
567
568static int da850_evm_bb_expander_setup(struct i2c_client *client,
569 unsigned gpio, unsigned ngpio,
570 void *c)
571{
572 int ret;
573
574 /*
575 * Register the switches and pushbutton on the baseboard as a gpio-keys
576 * device.
577 */
578 da850_evm_bb_keys_init(gpio);
579 ret = platform_device_register(&da850_evm_bb_keys_device);
580 if (ret) {
581 pr_warning("Could not register baseboard GPIO expander keys");
582 goto io_exp_setup_sw_fail;
583 }
584
585 da850_evm_bb_leds_init(gpio);
586 ret = platform_device_register(&da850_evm_bb_leds_device);
587 if (ret) {
588 pr_warning("Could not register baseboard GPIO expander LEDS");
589 goto io_exp_setup_leds_fail;
590 }
591
592 return 0;
593
594io_exp_setup_leds_fail:
595 platform_device_unregister(&da850_evm_bb_keys_device);
596io_exp_setup_sw_fail:
597 return ret;
598}
599
600static int da850_evm_bb_expander_teardown(struct i2c_client *client,
601 unsigned gpio, unsigned ngpio, void *c)
602{
603 platform_device_unregister(&da850_evm_bb_leds_device);
604 platform_device_unregister(&da850_evm_bb_keys_device);
335 605
336 return 0; 606 return 0;
337} 607}
@@ -340,6 +610,14 @@ static struct pca953x_platform_data da850_evm_ui_expander_info = {
340 .gpio_base = DAVINCI_N_GPIO, 610 .gpio_base = DAVINCI_N_GPIO,
341 .setup = da850_evm_ui_expander_setup, 611 .setup = da850_evm_ui_expander_setup,
342 .teardown = da850_evm_ui_expander_teardown, 612 .teardown = da850_evm_ui_expander_teardown,
613 .names = da850_evm_ui_exp,
614};
615
616static struct pca953x_platform_data da850_evm_bb_expander_info = {
617 .gpio_base = DA850_BB_EXPANDER_GPIO_BASE,
618 .setup = da850_evm_bb_expander_setup,
619 .teardown = da850_evm_bb_expander_teardown,
620 .names = da850_evm_bb_exp,
343}; 621};
344 622
345static struct i2c_board_info __initdata da850_evm_i2c_devices[] = { 623static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
@@ -350,6 +628,10 @@ static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
350 I2C_BOARD_INFO("tca6416", 0x20), 628 I2C_BOARD_INFO("tca6416", 0x20),
351 .platform_data = &da850_evm_ui_expander_info, 629 .platform_data = &da850_evm_ui_expander_info,
352 }, 630 },
631 {
632 I2C_BOARD_INFO("tca6416", 0x21),
633 .platform_data = &da850_evm_bb_expander_info,
634 },
353}; 635};
354 636
355static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = { 637static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
@@ -540,7 +822,7 @@ static struct regulator_init_data tps65070_regulator_data[] = {
540 { 822 {
541 .constraints = { 823 .constraints = {
542 .min_uV = 950000, 824 .min_uV = 950000,
543 .max_uV = 1320000, 825 .max_uV = 1350000,
544 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE | 826 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
545 REGULATOR_CHANGE_STATUS), 827 REGULATOR_CHANGE_STATUS),
546 .boot_on = 1, 828 .boot_on = 1,
@@ -591,7 +873,7 @@ static struct tps6507x_board tps_board = {
591 .tps6507x_ts_init_data = &tps6507x_touchscreen_data, 873 .tps6507x_ts_init_data = &tps6507x_touchscreen_data,
592}; 874};
593 875
594static struct i2c_board_info __initdata da850evm_tps65070_info[] = { 876static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
595 { 877 {
596 I2C_BOARD_INFO("tps6507x", 0x48), 878 I2C_BOARD_INFO("tps6507x", 0x48),
597 .platform_data = &tps_board, 879 .platform_data = &tps_board,
@@ -600,8 +882,8 @@ static struct i2c_board_info __initdata da850evm_tps65070_info[] = {
600 882
601static int __init pmic_tps65070_init(void) 883static int __init pmic_tps65070_init(void)
602{ 884{
603 return i2c_register_board_info(1, da850evm_tps65070_info, 885 return i2c_register_board_info(1, da850_evm_tps65070_info,
604 ARRAY_SIZE(da850evm_tps65070_info)); 886 ARRAY_SIZE(da850_evm_tps65070_info));
605} 887}
606 888
607static const short da850_evm_lcdc_pins[] = { 889static const short da850_evm_lcdc_pins[] = {
@@ -736,6 +1018,27 @@ static struct edma_rsv_info *da850_edma_rsv[2] = {
736 &da850_edma_cc1_rsv, 1018 &da850_edma_cc1_rsv,
737}; 1019};
738 1020
1021#ifdef CONFIG_CPU_FREQ
1022static __init int da850_evm_init_cpufreq(void)
1023{
1024 switch (system_rev & 0xF) {
1025 case 3:
1026 da850_max_speed = 456000;
1027 break;
1028 case 2:
1029 da850_max_speed = 408000;
1030 break;
1031 case 1:
1032 da850_max_speed = 372000;
1033 break;
1034 }
1035
1036 return da850_register_cpufreq("pll0_sysclk3");
1037}
1038#else
1039static __init int da850_evm_init_cpufreq(void) { return 0; }
1040#endif
1041
739static __init void da850_evm_init(void) 1042static __init void da850_evm_init(void)
740{ 1043{
741 int ret; 1044 int ret;
@@ -836,7 +1139,7 @@ static __init void da850_evm_init(void)
836 if (ret) 1139 if (ret)
837 pr_warning("da850_evm_init: rtc setup failed: %d\n", ret); 1140 pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
838 1141
839 ret = da850_register_cpufreq("pll0_sysclk3"); 1142 ret = da850_evm_init_cpufreq();
840 if (ret) 1143 if (ret)
841 pr_warning("da850_evm_init: cpufreq registration failed: %d\n", 1144 pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
842 ret); 1145 ret);