linux-ti33x-psp 3.2: fix buttons on LCD capes
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / beaglebone / 0069-beaglebone-add-support-for-LCD3-rev-A1.patch
1 From b61b89f98ac85ccd8d503a902bad208343ed0aba Mon Sep 17 00:00:00 2001
2 From: Koen Kooi <koen@dominion.thruhere.net>
3 Date: Mon, 4 Jun 2012 14:38:02 +0200
4 Subject: [PATCH] beaglebone: add support for LCD3 rev A1
6 Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
7 ---
8  arch/arm/mach-omap2/board-am335xevm.c |   94 +++++++++++++++++++++++++++++----
9  1 files changed, 83 insertions(+), 11 deletions(-)
11 diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
12 index bb6049a..51bfa8b 100644
13 --- a/arch/arm/mach-omap2/board-am335xevm.c
14 +++ b/arch/arm/mach-omap2/board-am335xevm.c
15 @@ -1136,7 +1136,7 @@ static struct pinmux_config lcd3_keys_pin_mux[] = {
16         {NULL, 0},
17  };
18  
19 -/* Configure GPIOs for lcd3 keys */
20 +/* Configure GPIOs for lcd3 rev A or earlier keys */
21  static struct gpio_keys_button beaglebone_lcd3_gpio_keys[] = {
22         {
23                 .code                   = KEY_LEFT,
24 @@ -1193,14 +1193,72 @@ static struct platform_device beaglebone_lcd3_keys = {
25         },
26  };
27  
28 -static void beaglebone_lcd3_keys_init(int evm_id, int profile)
29 -{
30 -       int err;
31 -       setup_pin_mux(lcd3_keys_pin_mux);
32 -       err = platform_device_register(&beaglebone_lcd3_keys);
33 -       if (err)
34 -               pr_err("failed to register gpio keys for LCD3 cape\n");
35 -}
36 +/* pinmux for lcd3 A1 or newer keys */
37 +static struct pinmux_config lcd3a1_keys_pin_mux[] = {
38 +       {"gpmc_a0.gpio1_16",  OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, // Left
39 +       {"gpmc_a1.gpio1_17",    OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, //Right
40 +       {"gpmc_a3.gpio1_19", OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT}, // Up
41 +       {"mcasp0_axr0.gpio3_16",    OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, //Down
42 +       {"mcasp0_fsr.gpio3_19",  OMAP_MUX_MODE7 | AM33XX_PIN_INPUT}, // Enter
43 +       {NULL, 0},
44 +};
45 +
46 +/* Configure GPIOs for lcd3 rev A1 or newer keys */
47 +static struct gpio_keys_button lcd3a1_gpio_keys[] = {
48 +       {
49 +               .code                   = KEY_LEFT,
50 +               .gpio                   = GPIO_TO_PIN(1, 16),
51 +               .active_low             = true,
52 +               .desc                   = "left",
53 +               .type                   = EV_KEY,
54 +               .wakeup                 = 1,
55 +       },
56 +       {
57 +               .code                   = KEY_RIGHT,
58 +               .gpio                   = GPIO_TO_PIN(1, 17),
59 +               .active_low             = true,
60 +               .desc                   = "right",
61 +               .type                   = EV_KEY,
62 +               .wakeup                 = 1,
63 +       },
64 +       {
65 +               .code                   = KEY_UP,
66 +               .gpio                   = GPIO_TO_PIN(1, 19),
67 +               .active_low             = true,
68 +               .desc                   = "up",
69 +               .type                   = EV_KEY,
70 +               .wakeup                 = 1,
71 +       },
72 +       {
73 +               .code                   = KEY_DOWN,
74 +               .gpio                   = GPIO_TO_PIN(3, 16),
75 +               .active_low             = true,
76 +               .desc                   = "down",
77 +               .type                   = EV_KEY,
78 +               .wakeup                 = 1,
79 +       },
80 +       {
81 +               .code                   = KEY_ENTER,
82 +               .gpio                   = GPIO_TO_PIN(3, 19),
83 +               .active_low             = true,
84 +               .desc                   = "enter",
85 +               .type                   = EV_KEY,
86 +               .wakeup                 = 1,
87 +       },
88 +};
89 +
90 +static struct gpio_keys_platform_data lcd3a1_gpio_key_info = {
91 +       .buttons        = lcd3a1_gpio_keys,
92 +       .nbuttons       = ARRAY_SIZE(lcd3a1_gpio_keys),
93 +};
94 +
95 +static struct platform_device lcd3a1_keys = {
96 +       .name   = "gpio-keys",
97 +       .id     = -1,
98 +       .dev    = {
99 +               .platform_data  = &lcd3a1_gpio_key_info,
100 +       },
101 +};
102  
103  /*
104  * @evm_id - evm id which needs to be configured
105 @@ -2691,8 +2749,22 @@ static void beaglebone_cape_setup(struct memory_accessor *mem_acc, void *context
106                 pr_info("BeagleBone cape: initializing LCD cape touchscreen\n");
107                 tsc_init(0,0);
108                 beaglebone_tsadcpins_free = 0;
109 -               pr_info("BeagleBone cape: Registering gpio-keys for LCD cape\n");
110 -               beaglebone_lcd3_keys_init(0,0);
111 +               
112 +               if (!strncmp("00A0", cape_config.version, 4)) {
113 +                       pr_info("BeagleBone cape: Registering gpio-keys for LCD3 rev A or earlier cape\n");
114 +                       int err;
115 +                       setup_pin_mux(lcd3_keys_pin_mux);
116 +                       err = platform_device_register(&beaglebone_lcd3_keys);
117 +                       if (err)
118 +                               pr_err("failed to register gpio keys for LCD3 rev A or earlier cape\n");
119 +               } else {
120 +                       pr_info("BeagleBone cape: Registering gpio-keys for LCD rev A1 or later cape\n");
121 +                       int err;
122 +                       setup_pin_mux(lcd3a1_keys_pin_mux);
123 +                       err = platform_device_register(&lcd3a1_keys);
124 +                       if (err)
125 +                               pr_err("failed to register gpio keys for LCD3 rev A1 or later cape\n");
126 +               }
127                 beaglebone_leds_free = 0;
128                 lcd3leds_init(0,0);
129         }
130 -- 
131 1.7.7.6