summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Gilles <jgilles@multitech.com>2014-05-20 16:49:47 -0500
committerJesse Gilles <jgilles@multitech.com>2014-06-18 12:07:38 -0500
commitf8a371233d759309cd58672192294180c7f8842e (patch)
tree04a2089501c69e2b9b986828f41fc9a92b5d4398
parent7e07fe3959a903dd3fbcc1546058dc8a84241b28 (diff)
downloadcdp-io-controller-f8a371233d759309cd58672192294180c7f8842e.tar.gz
cdp-io-controller-f8a371233d759309cd58672192294180c7f8842e.tar.bz2
cdp-io-controller-f8a371233d759309cd58672192294180c7f8842e.zip
add reset_gpio_pin for generic pin reset
-rw-r--r--io-module/gpio.c15
-rw-r--r--io-module/mts_io.c56
2 files changed, 34 insertions, 37 deletions
diff --git a/io-module/gpio.c b/io-module/gpio.c
index 72c55f6..4a2d963 100644
--- a/io-module/gpio.c
+++ b/io-module/gpio.c
@@ -81,3 +81,18 @@ static ssize_t mts_attr_store_gpio_pin(struct device *dev,
return count;
}
+
+static int reset_gpio_pin(struct gpio_pin *pin, unsigned int delay_ms, unsigned int value)
+{
+ if (!pin) {
+ return -ENODEV;
+ }
+
+ gpio_set_value(pin->pin.gpio, value);
+
+ mdelay(delay_ms);
+
+ gpio_set_value(pin->pin.gpio, !value);
+
+ return 0;
+}
diff --git a/io-module/mts_io.c b/io-module/mts_io.c
index 1f641d9..e578941 100644
--- a/io-module/mts_io.c
+++ b/io-module/mts_io.c
@@ -212,29 +212,13 @@ static DEVICE_ATTR_MTS(dev_attr_reset_monitor, "reset-monitor",
mts_attr_show_reset_monitor, mts_attr_store_reset_monitor);
static DEVICE_ATTR_RO_MTS(dev_attr_reset, "reset", mts_attr_show_gpio_pin);
-/* generic peripheral reset functions */
-static int radio_reset(void)
-{
- struct gpio_pin *pin = gpio_pin_by_name("RADIO_RESET");
-
- if (!pin) {
- return -ENODEV;
- }
-
- gpio_set_value(pin->pin.gpio, 0);
-
- mdelay(250);
-
- gpio_set_value(pin->pin.gpio, 1);
-
- return 0;
-}
-
+/* active-low socket modem reset */
static ssize_t mts_attr_store_radio_reset(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
int value;
int err;
+ struct gpio_pin *pin;
if (sscanf(buf, "%i", &value) != 1) {
return -EINVAL;
@@ -243,9 +227,16 @@ static ssize_t mts_attr_store_radio_reset(struct device *dev,
return -EINVAL;
}
+ pin = gpio_pin_by_name("RADIO_RESET");
+
+ if (!pin) {
+ return -ENODEV;
+ }
+
mutex_lock(&mts_io_mutex);
- err = radio_reset();
+ // 250ms low reset
+ err = reset_gpio_pin(pin, 250, 0);
mutex_unlock(&mts_io_mutex);
@@ -256,28 +247,12 @@ static ssize_t mts_attr_store_radio_reset(struct device *dev,
return count;
}
-static int ndc_reset(void)
-{
- struct gpio_pin *pin = gpio_pin_by_name("NDC_RESET");
-
- if (!pin) {
- return -ENODEV;
- }
-
- gpio_set_value(pin->pin.gpio, 0);
-
- mdelay(1);
-
- gpio_set_value(pin->pin.gpio, 1);
-
- return 0;
-}
-
static ssize_t mts_attr_store_ndc_reset(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
int value;
int err;
+ struct gpio_pin *pin;
if (sscanf(buf, "%i", &value) != 1) {
return -EINVAL;
@@ -286,9 +261,16 @@ static ssize_t mts_attr_store_ndc_reset(struct device *dev,
return -EINVAL;
}
+ pin = gpio_pin_by_name("NDC_RESET");
+
+ if (!pin) {
+ return -ENODEV;
+ }
+
mutex_lock(&mts_io_mutex);
- err = ndc_reset();
+ // 1ms low reset
+ err = reset_gpio_pin(pin, 1, 0);
mutex_unlock(&mts_io_mutex);