summaryrefslogtreecommitdiff
path: root/io-module
diff options
context:
space:
mode:
authorMykyta Dorokhin <mykyta.dorokhin@globallogic.com>2016-10-20 11:59:06 +0300
committerMykyta Dorokhin <mykyta.dorokhin@globallogic.com>2016-10-20 12:48:38 +0300
commit974fd95ac6bb3fddd75aa1103206e954be5cb055 (patch)
tree41c4b97a0b47b282b3eb6d59c454f5f7166961a8 /io-module
parent32666ddc7ce17ab0b9750b4481d0e44c10435abe (diff)
downloadmts-io-974fd95ac6bb3fddd75aa1103206e954be5cb055.tar.gz
mts-io-974fd95ac6bb3fddd75aa1103206e954be5cb055.tar.bz2
mts-io-974fd95ac6bb3fddd75aa1103206e954be5cb055.zip
mtp: add eth-reset sysfs node1.4.1
Diffstat (limited to 'io-module')
-rw-r--r--io-module/mtp.c82
-rw-r--r--io-module/mts_io.c2
2 files changed, 66 insertions, 18 deletions
diff --git a/io-module/mtp.c b/io-module/mtp.c
index e6da3d5..74867e3 100644
--- a/io-module/mtp.c
+++ b/io-module/mtp.c
@@ -1,10 +1,10 @@
static struct gpio_pin gpio_pins_mtp_0_0[] = {
{
- .name = "ETH_EN",
+ .name = "ETH_RESET",
.pin = {
.gpio = AT91_PIN_PC6, // NETH_RST
.flags = GPIOF_OUT_INIT_HIGH,
- .label = "eth-enabled",
+ .label = "eth-reset",
},
},
{
@@ -155,11 +155,11 @@ static int radio_off_mtp(void)
value = gpio_get_value(pwrmon_pin->pin.gpio);
if(value == 0) {
- log_warning("radio is already off");
+ log_warning("cell radio is already off");
return 0;
}
- log_info("turning off radio");
+ log_info("turning off cell radio");
// To turn OFF LE910 the pad ON/OFF# must be tied low for at least 2 seconds and then
// released. Same circuitry and timing for the power on must be used. When the hold
@@ -176,7 +176,7 @@ static int radio_off_mtp(void)
// check that power is low
value = gpio_get_value(pwrmon_pin->pin.gpio);
if (value != 0) {
- log_info("radio is still on. keep waiting...");
+ log_info("cell radio is still on. keep waiting...");
msleep(2000);
continue;
}
@@ -184,10 +184,10 @@ static int radio_off_mtp(void)
}
if (value == 0) {
- log_info("radio has been shut down");
+ log_info("cell radio has been shut down");
}
else {
- log_warning("radio is still on. performing unconditional shutdown...");
+ log_warning("cell radio is still on. performing unconditional shutdown...");
radio_unconditional_shutdown_mtp();
}
@@ -208,11 +208,11 @@ static int radio_on_mtp(void)
value = gpio_get_value(pwrmon_pin->pin.gpio);
if(value != 0) {
- log_warning("radio is already on");
+ log_warning("cell radio is already on");
return 0;
}
- log_info("turning on radio");
+ log_info("turning on cell radio");
// drive on/off pin high for at least 1 seconoff_pin
gpio_set_value(onoff_pin->pin.gpio, 1);
@@ -225,9 +225,9 @@ static int radio_on_mtp(void)
// check that power is high
value = gpio_get_value(pwrmon_pin->pin.gpio);
if(value == 0) {
- log_warning("radio is still off.");
+ log_warning("cell radio is still off.");
} else {
- log_info("radio has been turned on");
+ log_info("cell radio has been turned on");
}
return 0;
@@ -247,14 +247,14 @@ static int radio_reset_mtp(void)
// Unconditional shutdown
//
- log_info("performing unconditional radio shutdown");
+ log_info("performing unconditional cell radio shutdown");
radio_unconditional_shutdown_mtp();
//
// Turning on radio
//
- log_info("turning on radio");
+ log_info("turning on cell radio");
// drive on/off pin high for at least 1 sec
gpio_set_value(onoff_pin->pin.gpio, 1);
@@ -311,7 +311,7 @@ static ssize_t mts_attr_store_radio_reset_mtp(struct device *dev,
if (NULL != timings_data) {
/* check reset timer is started */
if (radio_reset_timer_is_start == 1) {
- log_info("radio reset timer is running. \n");
+ log_info("cell radio reset timer is running. \n");
return count;
}
@@ -406,6 +406,54 @@ static ssize_t mts_attr_store_lora_reset_mtp(struct device *dev,
return count;
}
+static int eth_reset_mtp(void)
+{
+ struct gpio_pin *rst_pin = gpio_pin_by_attr_name("eth-reset");
+
+ if (!rst_pin) {
+ return -ENODEV;
+ }
+
+ /*
+ * DS00002275A (09-15-16) KSZ8091MNX/RNB DATA SHEET:
+ * For warm reset, the reset (RST#) pin should be asserted low for a minimum of 500 μs.
+ */
+ gpio_set_value(rst_pin->pin.gpio, 0);
+
+ msleep(2);
+
+ gpio_set_value(rst_pin->pin.gpio, 1);
+
+ msleep(1);
+
+ return 0;
+}
+
+static ssize_t mts_attr_store_eth_reset_mtp(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;
+ }
+
+ log_info("performing eth reset");
+
+ mutex_lock(&mts_io_mutex);
+
+ err = eth_reset_mtp();
+
+ mutex_unlock(&mts_io_mutex);
+
+ if (err) {
+ return err;
+ }
+
+ return count;
+}
+
static DEVICE_ATTR_MTS(dev_attr_radio_reset_mtp, "radio-reset",
mts_attr_show_gpio_pin, mts_attr_store_radio_reset_mtp);
@@ -415,8 +463,8 @@ static DEVICE_ATTR_MTS(dev_attr_radio_power_mtp, "radio-power",
static DEVICE_ATTR_MTS(dev_attr_lora_reset_mtp, "lora-reset",
mts_attr_show_gpio_pin, mts_attr_store_lora_reset_mtp);
-static DEVICE_ATTR_MTS(dev_attr_eth_enabled_mtp, "eth-enabled",
- mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_eth_reset_mtp, "eth-reset",
+ mts_attr_show_gpio_pin, mts_attr_store_eth_reset_mtp);
static DEVICE_ATTR_MTS(dev_attr_led_lora_gpio_mtp, "led-lora",
mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
@@ -436,7 +484,7 @@ static struct attribute *mtp_0_0_platform_attributes[] = {
&dev_attr_reset_monitor.attr,
&dev_attr_reset_monitor_intervals.attr,
- &dev_attr_eth_enabled_mtp.attr,
+ &dev_attr_eth_reset_mtp.attr,
&dev_attr_lora_reset_mtp.attr,
diff --git a/io-module/mts_io.c b/io-module/mts_io.c
index 7dcdf54..7e3d1f0 100644
--- a/io-module/mts_io.c
+++ b/io-module/mts_io.c
@@ -47,7 +47,7 @@
#include "mts_io.h"
-#define DRIVER_VERSION "v1.4.0"
+#define DRIVER_VERSION "v1.4.1"
#define DRIVER_AUTHOR "James Maki <jmaki@multitech.com>"
#define DRIVER_DESC "MTS-IO Controller"
#define DRIVER_NAME "mts-io"