summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--io-module/mts_io.c86
1 files changed, 73 insertions, 13 deletions
diff --git a/io-module/mts_io.c b/io-module/mts_io.c
index 0220817..434e179 100644
--- a/io-module/mts_io.c
+++ b/io-module/mts_io.c
@@ -977,6 +977,50 @@ static void blink_callback(struct work_struct *ignored)
schedule_delayed_work(&blink_work, BLINK_INTERVAL);
}
+static int radio_reset_telit(void)
+{
+ int ret;
+ struct gpio_pin *rst_pin = gpio_pin_by_name("3G_RST");
+ struct gpio_pin *onoff_pin = gpio_pin_by_name("3G_ONOFF");
+
+ if (!rst_pin || !onoff_pin) {
+ return -ENODEV;
+ }
+
+ // drive reset pin low for 500ms
+ ret = at91_set_gpio_output_with_pullup(rst_pin->pin, 0, rst_pin->use_pullup);
+ if (ret) {
+ return ret;
+ }
+
+ msleep(500);
+
+ // set pin as input (high Z)
+ ret = at91_set_gpio_input(rst_pin->pin, rst_pin->use_pullup);
+ if (ret) {
+ return ret;
+ }
+
+ // wait for 2 sec before toggling on/off pin
+ msleep(2000);
+
+ // drive on/off pin low for 6 sec
+ ret = at91_set_gpio_output_with_pullup(onoff_pin->pin, 0, onoff_pin->use_pullup);
+ if (ret) {
+ return ret;
+ }
+
+ msleep(6000);
+
+ // set on/off pin as input (high Z)
+ ret = at91_set_gpio_input(onoff_pin->pin, onoff_pin->use_pullup);
+ if (ret) {
+ return ret;
+ }
+
+ return ret;
+}
+
static int radio_reset(void)
{
int ret;
@@ -1164,6 +1208,32 @@ static ssize_t mts_attr_store_radio_reset(struct device *dev,
return count;
}
+static ssize_t mts_attr_store_radio_reset_telit(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ int value;
+ int err;
+
+ if (sscanf(buf, "%i", &value) != 1) {
+ return -EINVAL;
+ }
+ if (value != 0) {
+ return -EINVAL;
+ }
+
+ mutex_lock(&mts_io_mutex);
+
+ err = radio_reset_telit();
+
+ mutex_unlock(&mts_io_mutex);
+
+ if (err) {
+ return err;
+ }
+
+ return count;
+}
+
static struct device_attribute dev_attr_radio_reset = {
.attr = {
.name = "radio-reset",
@@ -2458,22 +2528,13 @@ static struct device_attribute dev_attr_eth_switch_enabled = {
.store = mts_attr_store_gpio_open_collector,
};
-static struct device_attribute dev_attr_radio_reset_oc = {
+static struct device_attribute dev_attr_radio_reset_telit = {
.attr = {
.name = "radio-reset",
.mode = MTS_ATTR_MODE_RW,
},
.show = mts_attr_show_gpio_pin,
- .store = mts_attr_store_gpio_open_collector,
-};
-
-static struct device_attribute dev_attr_radio_enabled_oc = {
- .attr = {
- .name = "radio-enabled",
- .mode = MTS_ATTR_MODE_RW,
- },
- .show = mts_attr_show_gpio_pin,
- .store = mts_attr_store_gpio_open_collector,
+ .store = mts_attr_store_radio_reset_telit,
};
static struct attribute *mt100eocg_platform_attributes[] = {
@@ -2615,8 +2676,7 @@ static struct attribute_group platform_attribute_group = {
static struct attribute *mtr_platform_attributes[] = {
&dev_attr_reset.attr,
&dev_attr_reset_monitor.attr,
- &dev_attr_radio_reset_oc.attr,
- &dev_attr_radio_enabled_oc.attr,
+ &dev_attr_radio_reset_telit.attr,
&dev_attr_extserial_dtr.attr,
&dev_attr_extserial_dsr_gpio.attr,
&dev_attr_extserial_cd.attr,