|
63 | 63 | #ifdef CONFIG_MACH_DAVINCI_LEGOEV3 |
64 | 64 |
|
65 | 65 | #warning "Consolidate these one-time LED setup macros" |
66 | | -#define EV3_LED_0_PIN GPIO_TO_PIN(6, 12) |
67 | | -#define EV3_LED_1_PIN GPIO_TO_PIN(6, 14) |
68 | | -#define EV3_LED_2_PIN GPIO_TO_PIN(6, 13) |
69 | | -#define EV3_LED_3_PIN GPIO_TO_PIN(6, 7) |
70 | | - |
| 66 | +#define EV3_LED_0_PIN GPIO_TO_PIN(6, 12) |
| 67 | +#define EV3_LED_1_PIN GPIO_TO_PIN(6, 14) |
| 68 | +#define EV3_LED_2_PIN GPIO_TO_PIN(6, 13) |
| 69 | +#define EV3_LED_3_PIN GPIO_TO_PIN(6, 7) |
| 70 | + |
| 71 | +#define EV3_BUTTON_0_PIN GPIO_TO_PIN(7, 15) |
| 72 | +#define EV3_BUTTON_1_PIN GPIO_TO_PIN(1, 13) |
| 73 | +#define EV3_BUTTON_2_PIN GPIO_TO_PIN(7, 14) |
| 74 | +#define EV3_BUTTON_3_PIN GPIO_TO_PIN(7, 12) |
| 75 | +#define EV3_BUTTON_4_PIN GPIO_TO_PIN(6, 6 ) |
| 76 | +#define EV3_BUTTON_5_PIN GPIO_TO_PIN(6, 10) |
71 | 77 | #else |
72 | 78 | #warning "Delete this code and eliminate this warning after copying this file to board-legoev3.c" |
73 | 79 | #define DAVINCI_BACKLIGHT_MAX_BRIGHTNESS 250 |
@@ -2021,12 +2027,15 @@ static const short da850_lms2012_lcd_pins[] = { |
2021 | 2027 |
|
2022 | 2028 | static const short legoev3_ui_pins[] = { |
2023 | 2029 | #if !(defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)) |
2024 | | - #warning "The LEDs are owned by the ui driver, not the kernel - heartbeat LED will not work" |
| 2030 | + #warning "The LEDs are owned by the ui driver, not the kernel - LED triggers will not work" |
2025 | 2031 | EV3_LED_0, EV3_LED_1, EV3_LED_2, EV3_LED_3, |
2026 | 2032 | #endif |
| 2033 | + |
| 2034 | +#if !(defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)) |
| 2035 | + #warning "The buttons are owned by the ui driver, not the kernel - button events will not work" |
2027 | 2036 | EV3_BUTTON_0, EV3_BUTTON_1, EV3_BUTTON_2, |
2028 | 2037 | EV3_BUTTON_3, EV3_BUTTON_4, EV3_BUTTON_5, |
2029 | | - |
| 2038 | +#endif |
2030 | 2039 | -1 |
2031 | 2040 | }; |
2032 | 2041 | #endif |
@@ -2069,9 +2078,42 @@ static struct platform_device ev3_device_gpio_leds = { |
2069 | 2078 | .platform_data = &ev3_gpio_led_data, |
2070 | 2079 | }, |
2071 | 2080 | }; |
2072 | | - |
2073 | 2081 | #endif |
2074 | 2082 |
|
| 2083 | +#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) |
| 2084 | +#include <linux/gpio_keys.h> |
| 2085 | +#include<linux/input.h> |
| 2086 | + |
| 2087 | +static struct gpio_keys_button ev3_gpio_keys_table[] = { |
| 2088 | + {KEY_UP, EV3_BUTTON_0_PIN, 1, "ev3:UP", EV_KEY, 0, 50, 1}, |
| 2089 | + {KEY_ENTER, EV3_BUTTON_1_PIN, 1, "ev3:ENTER", EV_KEY, 0, 50, 1}, |
| 2090 | + {KEY_DOWN, EV3_BUTTON_2_PIN, 1, "ev3:DOWN", EV_KEY, 0, 50, 1}, |
| 2091 | + {KEY_RIGHT, EV3_BUTTON_3_PIN, 1, "ev3:RIGHT", EV_KEY, 0, 50, 1}, |
| 2092 | + {KEY_LEFT, EV3_BUTTON_4_PIN, 1, "ev3:LEFT", EV_KEY, 0, 50, 1}, |
| 2093 | + {KEY_ESC, EV3_BUTTON_5_PIN, 1, "ev3:ESC", EV_KEY, 0, 50, 1}, |
| 2094 | +}; |
| 2095 | + |
| 2096 | +static struct gpio_keys_platform_data ev3_gpio_keys_data = { |
| 2097 | + .buttons = ev3_gpio_keys_table, |
| 2098 | + .nbuttons = ARRAY_SIZE(ev3_gpio_keys_table), |
| 2099 | +}; |
| 2100 | + |
| 2101 | +static struct platform_device ev3_device_gpiokeys = { |
| 2102 | + .name = "gpio-keys", |
| 2103 | + .dev = { |
| 2104 | + .platform_data = &ev3_gpio_keys_data, |
| 2105 | + }, |
| 2106 | +}; |
| 2107 | + |
| 2108 | +static const int legoev3_button_gpio[] = { |
| 2109 | + EV3_BUTTON_0_PIN, |
| 2110 | + EV3_BUTTON_1_PIN, |
| 2111 | + EV3_BUTTON_2_PIN, |
| 2112 | + EV3_BUTTON_3_PIN, |
| 2113 | + EV3_BUTTON_4_PIN, |
| 2114 | + EV3_BUTTON_5_PIN |
| 2115 | +}; |
| 2116 | +#endif |
2075 | 2117 |
|
2076 | 2118 | static __init int da850_set_emif_clk_rate(void) |
2077 | 2119 | { |
@@ -2145,6 +2187,23 @@ static __init void da850_legoev3_init(void) |
2145 | 2187 | ret); |
2146 | 2188 | #endif |
2147 | 2189 |
|
| 2190 | +#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) |
| 2191 | + /* This is CRITICAL code to making the LEFT button work - it disables |
| 2192 | + * the internal pullup on pin group 25 which is where the GPIO6_6 lives. |
| 2193 | + */ |
| 2194 | + ret = __raw_readl(DA8XX_SYSCFG1_VIRT(DA8XX_PUPD_SEL_REG)); |
| 2195 | + ret &= 0xFDFFFFFF; |
| 2196 | + __raw_writel(ret, DA8XX_SYSCFG1_VIRT(DA8XX_PUPD_SEL_REG)); |
| 2197 | + |
| 2198 | + gpio_request_array(legoev3_button_gpio, ARRAY_SIZE(legoev3_button_gpio)); |
| 2199 | + gpio_free_array(legoev3_button_gpio, ARRAY_SIZE(legoev3_button_gpio)); |
| 2200 | + |
| 2201 | + ret = platform_device_register(&ev3_device_gpiokeys); |
| 2202 | + if (ret) |
| 2203 | + pr_warning("da850_evm_init: button registration failed: %d\n", |
| 2204 | + ret); |
| 2205 | +#endif |
| 2206 | + |
2148 | 2207 | #ifdef CONFIG_MACH_DAVINCI_LEGOEV3 |
2149 | 2208 | #warning "Eventually, we'll re-enable these pins!" |
2150 | 2209 | #else |
|
0 commit comments