ar71xx: fix Arduino Yun enabling of level shifters outputs
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-arduino-yun.c
index fbe1f99c7940f98112faac22ee07c9119e97ad93..e92f68f490a14b38a0aef9afb6008a1d5fab6275 100644 (file)
@@ -19,9 +19,8 @@
 #include "machtypes.h"
 #include <asm/mach-ath79/ar71xx_regs.h>
 #include <asm/mach-ath79/ath79.h>
+#include <linux/gpio.h>
 #include "common.h"
-#include "gpio.h"
-#include "linux/gpio.h"
 
 // Uncomment to have reset on gpio18 instead of gipo7
 #define DS2_B
@@ -61,6 +60,17 @@ static struct gpio_led ds_leds_gpio[] __initdata = {
        },
 };
 
+static struct gpio_keys_button ds_gpio_keys[] __initdata = {
+       {
+               .desc           = "configuration button",
+               .type           = EV_KEY,
+               .code           = KEY_WPS_BUTTON,
+               .debounce_interval = DS_KEYS_DEBOUNCE_INTERVAL,
+               .gpio           = DS_GPIO_CONF_BTN,
+               .active_low     = 1,
+       },
+};
+
 static void __init ds_common_setup(void)
 {
        static u8 mac[6];
@@ -98,8 +108,18 @@ static void __init ds_setup(void)
 
        ath79_register_leds_gpio(-1, ARRAY_SIZE(ds_leds_gpio),
                                 ds_leds_gpio);
+       ath79_register_gpio_keys_polled(-1, DS_KEYS_POLL_INTERVAL,
+                                       ARRAY_SIZE(ds_gpio_keys),
+                                       ds_gpio_keys);
        ath79_register_usb();
 
+       /* use the swtich_led directly form sysfs */
+       ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
+                                                               AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
+                                                               AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
+                                                               AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
+                                                               AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
+
        //Disable the Function for some pins to have GPIO functionality active
        // GPIO6-7-8 and GPIO11
        ath79_gpio_function_setup(AR933X_GPIO_FUNC_JTAG_DISABLE | AR933X_GPIO_FUNC_I2S_MCK_EN, 0);
@@ -121,7 +141,7 @@ static void __init ds_setup(void)
 
        // enable OE of level shifter
        if (gpio_request_one(DS_GPIO_OE,
-           GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED, "OE-1") != 0)
+           GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED, "OE-1") != 0)
                printk("Error setting GPIO OE\n");
 
        if (gpio_request_one(DS_GPIO_UART_ENA,
@@ -130,7 +150,7 @@ static void __init ds_setup(void)
 
        // enable OE of level shifter
        if (gpio_request_one(DS_GPIO_OE2,
-           GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED, "OE-2") != 0)
+           GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED, "OE-2") != 0)
                printk("Error setting GPIO OE2\n");
 }