From 4afeacb37962034c35249d18b56716c8ea04a7ad Mon Sep 17 00:00:00 2001 From: Thanh Tran Date: Mon, 22 Aug 2011 10:30:26 -0500 Subject: Added control of external DTR and external DCD signals for MT100ECDP. --- io-module/mts_io.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/io-module/mts_io.c b/io-module/mts_io.c index 4697209..8c1251b 100644 --- a/io-module/mts_io.c +++ b/io-module/mts_io.c @@ -328,6 +328,13 @@ static struct gpio_pin gpio_pins_mt100ecdp_0_0[] = { .output_value = 0, .use_pullup = 0, }, + { + .name = "DCD1", + .pin = AT91_PIN_PB3, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + }, { .name = "GPIO11", .pin = AT91_PIN_PB19, @@ -1840,6 +1847,109 @@ static ssize_t mts_attr_store_gpio12(struct device *dev, return count; } +static ssize_t mts_attr_show_rsersrc(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int value; + struct gpio_pin *pin = gpio_pin_by_name("RSERSRC"); + + if (!pin) { + return -ENODEV; + } + + mutex_lock(&mts_io_mutex); + + value = at91_get_gpio_value(pin->pin); + + mutex_unlock(&mts_io_mutex); + + if (value < 0) { + return value; + } + + return sprintf(buf, "%d\n", !value); +} + +static ssize_t mts_attr_store_rsersrc(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + int value; + int err; + struct gpio_pin *pin = gpio_pin_by_name("RSERSRC"); + + if (!pin) { + return -ENODEV; + } + + if (sscanf(buf, "%i", &value) != 1) { + return -EINVAL; + } + + mutex_lock(&mts_io_mutex); + + err = at91_set_gpio_value(pin->pin, !value); + + mutex_unlock(&mts_io_mutex); + + if (err) { + return err; + } + + return count; +} + +static ssize_t mts_attr_show_cd(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int value; + struct gpio_pin *pin = gpio_pin_by_name("DCD1"); + + if (!pin) { + return -ENODEV; + } + + mutex_lock(&mts_io_mutex); + + value = at91_get_gpio_value(pin->pin); + + mutex_unlock(&mts_io_mutex); + + if (value < 0) { + return value; + } + + return sprintf(buf, "%d\n", !value); +} + +static ssize_t mts_attr_store_cd(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + int value; + int err; + struct gpio_pin *pin = gpio_pin_by_name("DCD1"); + + if (!pin) { + return -ENODEV; + } + + if (sscanf(buf, "%i", &value) != 1) { + return -EINVAL; + } + + mutex_lock(&mts_io_mutex); + + err = at91_set_gpio_value(pin->pin, !value); + + mutex_unlock(&mts_io_mutex); + + if (err) { + return err; + } + + return count; +} + + static struct device_attribute dev_attr_gpo1 = { .attr = { .name = "gpo1", @@ -2000,8 +2110,29 @@ static struct device_attribute dev_attr_gpio12 = { .store = mts_attr_store_gpio12, }; +static struct device_attribute dev_attr_rsersrc = { + .attr = { + .name = "rsersrc", + .mode = MTS_ATTR_MODE_RW, + }, + .show = mts_attr_show_rsersrc, + .store = mts_attr_store_rsersrc, +}; + +static struct device_attribute dev_attr_extserial_cd = { + .attr = { + .name = "extserial-dcd", + .mode = MTS_ATTR_MODE_RW, + }, + .show = mts_attr_show_cd, + .store = mts_attr_store_cd, +}; + static struct attribute *mt100ecdp_platform_attributes[] = { + &dev_attr_extserial_dtr.attr, + &dev_attr_extserial_cd.attr, + &dev_attr_rsersrc.attr, &dev_attr_radio_reset.attr, &dev_attr_eth0_enabled.attr, &dev_attr_gpio11.attr, -- cgit v1.2.3