summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Gilles <jgilles@multitech.com>2010-07-27 14:38:09 -0500
committerJesse Gilles <jgilles@multitech.com>2010-07-27 14:38:09 -0500
commitb3556e09b09136ac6b4435b2ccd1f57a13365535 (patch)
tree74a29854b11d1e0fa629250686e9adab221ac63f
parenteee8f03b6f9a49fe072533d5aa4795d4df4ae539 (diff)
downloadcdp-io-controller-0.3.0.tar.gz
cdp-io-controller-0.3.0.tar.bz2
cdp-io-controller-0.3.0.zip
add extserial-dtrv0.3.0
* Add ability to read DTR pin on external serial port
-rw-r--r--io-module/mts_io.c28
-rwxr-xr-xio-tool/mts-io-sysfs1
-rwxr-xr-xio-tool/sysfs-tests8
3 files changed, 37 insertions, 0 deletions
diff --git a/io-module/mts_io.c b/io-module/mts_io.c
index 3609d1a..bc5db24 100644
--- a/io-module/mts_io.c
+++ b/io-module/mts_io.c
@@ -481,6 +481,33 @@ static struct device_attribute dev_attr_extserial_dsr = {
.store = store_extserial_dsr,
};
+static ssize_t show_extserial_dtr(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ int value;
+
+ mutex_lock(&mts_io_mutex);
+
+ value = !at91_get_gpio_value(GPIO_DTR1);
+
+ mutex_unlock(&mts_io_mutex);
+
+ if (value < 0) {
+ return value;
+ }
+
+ return sprintf(buf, "%d\n", value);
+}
+
+static struct device_attribute dev_attr_extserial_dtr = {
+ .attr = {
+ .name = "extserial-dtr",
+ .mode = 0444,
+ },
+ .show = show_extserial_dtr,
+};
+
static ssize_t show_led_sig1(struct device *dev,
struct device_attribute *attr,
char *buf)
@@ -970,6 +997,7 @@ static struct attribute *platform_attributes[] = {
&dev_attr_extserial_dcd.attr,
&dev_attr_extserial_ri.attr,
&dev_attr_extserial_dsr.attr,
+ &dev_attr_extserial_dtr.attr,
&dev_attr_led_sig1.attr,
&dev_attr_led_sdk_c.attr,
&dev_attr_led_sig2.attr,
diff --git a/io-tool/mts-io-sysfs b/io-tool/mts-io-sysfs
index de06bb9..911dce1 100755
--- a/io-tool/mts-io-sysfs
+++ b/io-tool/mts-io-sysfs
@@ -76,6 +76,7 @@ usage() {
printf " extserial-dcd |\n" >&${out}
printf " extserial-ri |\n" >&${out}
printf " extserial-dsr |\n" >&${out}
+ printf " extserial-dtr |\n" >&${out}
printf " led-cd |\n" >&${out}
printf " led-sdk-b |\n" >&${out}
printf " led-sig1 |\n" >&${out}
diff --git a/io-tool/sysfs-tests b/io-tool/sysfs-tests
index 3c55a3d..fb465b4 100755
--- a/io-tool/sysfs-tests
+++ b/io-tool/sysfs-tests
@@ -133,10 +133,18 @@ show_assert extserial-dcd 0
store_assert extserial-dcd 1
store_assert extserial-dcd 0
+show_assert extserial-dsr 0
+store_assert extserial-dsr 1
+store_assert extserial-dsr 0
+
show_assert extserial-ri 0
store_assert extserial-ri 1
store_assert extserial-ri 0
+show_assert extserial-dtr 0
+store extserial-dtr 1
+show_assert extserial-dtr 0
+
show_assert led-sig1 0
store_assert led-sig1 1
store_assert led-sig1 0