From ef8856a810429e44003294fd9585b16509a9d962 Mon Sep 17 00:00:00 2001 From: Jesse Gilles Date: Thu, 8 Nov 2012 13:53:58 -0600 Subject: add mtr2 rev A support * added wifi led * rsersrc is removed * new serial_mode pins, rs4xx_term_res pin * bt-enable pin changed --- io-module/mts_io.c | 85 +++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/io-module/mts_io.c b/io-module/mts_io.c index 9b089b6..547f730 100644 --- a/io-module/mts_io.c +++ b/io-module/mts_io.c @@ -427,7 +427,7 @@ static struct gpio_pin gpio_pins_mtr2_0_0[] = { { .name = "LS_LED", .attr_name = "led-ls", - .pin = AT91_PIN_PA29, + .pin = AT91_PIN_PA14, #if LED_LS_CONTROLLABLE .direction = GPIO_DIR_OUTPUT, #else @@ -477,15 +477,15 @@ static struct gpio_pin gpio_pins_mtr2_0_0[] = { .use_pullup = 0, }, { - .name = "RSERSRC", - .attr_name = "rsersrc", - .pin = AT91_PIN_PC14, + .name = "LED13", + .attr_name = "led-wifi", + .pin = AT91_PIN_PA29, .direction = GPIO_DIR_OUTPUT, .output_value = 1, .use_pullup = 0, }, { - .name = "DTR1", + .name = "UART3_DTR", .attr_name = "extserial-dtr", .pin = AT91_PIN_PC12, .direction = GPIO_DIR_INPUT, @@ -493,7 +493,7 @@ static struct gpio_pin gpio_pins_mtr2_0_0[] = { .use_pullup = 0, }, { - .name = "DSR1", + .name = "UART3_DSR", .attr_name = "extserial-dsr", .pin = AT91_PIN_PC11, .direction = GPIO_DIR_OUTPUT, @@ -501,7 +501,7 @@ static struct gpio_pin gpio_pins_mtr2_0_0[] = { .use_pullup = 0, }, { - .name = "DCD1", + .name = "UART3_DCD", .attr_name = "extserial-dcd", .pin = AT91_PIN_PC10, .direction = GPIO_DIR_OUTPUT, @@ -509,7 +509,7 @@ static struct gpio_pin gpio_pins_mtr2_0_0[] = { .use_pullup = 0, }, { - .name = "RI1", + .name = "UART3_RI", .attr_name = "extserial-ri", .pin = AT91_PIN_PC13, .direction = GPIO_DIR_OUTPUT, @@ -527,7 +527,7 @@ static struct gpio_pin gpio_pins_mtr2_0_0[] = { { .name = "BT_EN", .attr_name = "bt-enabled", - .pin = AT91_PIN_PC0, + .pin = AT91_PIN_PD21, .direction = GPIO_DIR_OUTPUT, .output_value = 0, .use_pullup = 0, @@ -542,31 +542,31 @@ static struct gpio_pin gpio_pins_mtr2_0_0[] = { }, { .name = "SERIAL_MODE0", - .attr_name = "", + .attr_name = "serial_mode", .pin = AT91_PIN_PC23, .direction = GPIO_DIR_OUTPUT, - .output_value = 0, + .output_value = 1, .use_pullup = 0, }, { - .name = "SERIAL_MODE2", - .attr_name = "", + .name = "SERIAL_MODE1", + .attr_name = "serial_mode", .pin = AT91_PIN_PC24, .direction = GPIO_DIR_OUTPUT, - .output_value = 1, + .output_value = 0, .use_pullup = 0, }, { - .name = "RS422_TERM_RES", - .attr_name = "rs422-term-res", + .name = "SERIAL_MODE2", + .attr_name = "serial_mode", .pin = AT91_PIN_PC25, .direction = GPIO_DIR_OUTPUT, .output_value = 0, .use_pullup = 0, }, { - .name = "RS485_TERM_RES", - .attr_name = "rs485-term-res", + .name = "RS4XX_TERM_RES", + .attr_name = "rs4xx-term-res", .pin = AT91_PIN_PC26, .direction = GPIO_DIR_OUTPUT, .output_value = 0, @@ -2054,18 +2054,9 @@ static struct device_attribute dev_attr_reset = { .show = mts_attr_show_gpio_pin_inverted, }; -static struct device_attribute dev_attr_rs485_term_res = { +static struct device_attribute dev_attr_rs4xx_term_res = { .attr = { - .name = "rs485-term-res", - .mode = MTS_ATTR_MODE_RW, - }, - .show = mts_attr_show_gpio_pin, - .store = mts_attr_store_gpio_pin, -}; - -static struct device_attribute dev_attr_rs422_term_res = { - .attr = { - .name = "rs422-term-res", + .name = "rs4xx-term-res", .mode = MTS_ATTR_MODE_RW, }, .show = mts_attr_show_gpio_pin, @@ -2438,25 +2429,30 @@ static ssize_t mts_attr_show_serial_mode(struct device *dev, { int ret; int smode0; + int smode1; int smode2; struct gpio_pin *pin_smode0 = gpio_pin_by_name("SERIAL_MODE0"); + struct gpio_pin *pin_smode1 = gpio_pin_by_name("SERIAL_MODE1"); struct gpio_pin *pin_smode2 = gpio_pin_by_name("SERIAL_MODE2"); - if (!pin_smode0 || !pin_smode2) + if (!pin_smode0 || !pin_smode1 || !pin_smode2) return -ENODEV; mutex_lock(&mts_io_mutex); smode0 = at91_get_gpio_value(pin_smode0->pin); + smode1 = at91_get_gpio_value(pin_smode1->pin); smode2 = at91_get_gpio_value(pin_smode2->pin); - if (smode2 == 0 && smode0 == 1) - ret = sprintf(buf, "rs485\n"); - else if (smode2 == 1 && smode0 == 0) + if (smode2 == 0 && smode1 == 0 && smode0 == 1) ret = sprintf(buf, "rs232\n"); - else if (smode2 == 1 && smode0 == 1) + else if (smode2 == 0 && smode1 == 1 && smode0 == 0) + ret = sprintf(buf, "rs485\n"); + else if (smode2 == 1 && smode1 == 0 && smode0 == 0) ret = sprintf(buf, "rs422\n"); + else + ret = sprintf(buf, "error\n"); mutex_unlock(&mts_io_mutex); @@ -2467,24 +2463,29 @@ static ssize_t mts_attr_store_serial_mode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int smode0; + int smode1; int smode2; struct gpio_pin *pin_smode0 = gpio_pin_by_name("SERIAL_MODE0"); + struct gpio_pin *pin_smode1 = gpio_pin_by_name("SERIAL_MODE1"); struct gpio_pin *pin_smode2 = gpio_pin_by_name("SERIAL_MODE2"); - if (!pin_smode0 || !pin_smode2) + if (!pin_smode0 || !pin_smode1 || !pin_smode2) return -ENODEV; - if (!strcasecmp(buf, "rs485")) { + if (!strcasecmp(buf, "rs232")) { smode2 = 0; + smode1 = 0; smode0 = 1; } - else if (!strcasecmp(buf, "rs232")) { - smode2 = 1; + else if (!strcasecmp(buf, "rs485")) { + smode2 = 0; + smode1 = 1; smode0 = 0; } else if (!strcasecmp(buf, "rs422")) { smode2 = 1; - smode0 = 1; + smode1 = 0; + smode0 = 0; } else { return -EINVAL; @@ -2493,6 +2494,7 @@ static ssize_t mts_attr_store_serial_mode(struct device *dev, mutex_lock(&mts_io_mutex); at91_set_gpio_value(pin_smode2->pin, smode2); + at91_set_gpio_value(pin_smode1->pin, smode1); at91_set_gpio_value(pin_smode0->pin, smode0); mutex_unlock(&mts_io_mutex); @@ -2610,20 +2612,19 @@ static struct attribute *mtr2_platform_attributes[] = { &dev_attr_extserial_dsr_gpio.attr, &dev_attr_extserial_ri_gpio.attr, &dev_attr_extserial_cd.attr, - &dev_attr_rsersrc.attr, &dev_attr_eth_switch_enabled.attr, &dev_attr_bt_enabled.attr, &dev_attr_wlan_enabled.attr, &dev_attr_serial_mode.attr, - &dev_attr_rs485_term_res.attr, - &dev_attr_rs422_term_res.attr, + &dev_attr_rs4xx_term_res.attr, &dev_attr_led_status.attr, &dev_attr_led_sig1_gpio.attr, &dev_attr_led_sig2_gpio.attr, &dev_attr_led_sig3_gpio.attr, &dev_attr_led_cd_gpio.attr, + &dev_attr_led_wifi.attr, &dev_attr_board_temperature.attr, -- cgit v1.2.3