summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README4
-rw-r--r--configure.ac2
-rw-r--r--debug/README1
-rw-r--r--debug/etc/modprobe.d/mts-io.conf2
-rw-r--r--io-module/gpio.c29
-rw-r--r--io-module/mts-io.c39
-rw-r--r--io-module/mts_io.h4
-rw-r--r--io-module/version.h2
8 files changed, 49 insertions, 34 deletions
diff --git a/README b/README
index c457baf..d4a3df6 100644
--- a/README
+++ b/README
@@ -11,3 +11,7 @@ does not instantiate any resets for the
LoRa 2.1 board. Instead this board is
reset via the mainboard I2C bus which includes
the on-board EE-PROM.
+
+dev_dbg can be turned on when loading the
+mts-io driver. See debug/README and
+debug/etc/modprobe.d/mts-io.conf
diff --git a/configure.ac b/configure.ac
index 0bde50a..470aeac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([mts-io], [4.8.4])
+AC_INIT([mts-io], [4.9.0])
AC_CONFIG_SRCDIR([util/mts_util_lora2_reset.c])
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER([config.h])
diff --git a/debug/README b/debug/README
new file mode 100644
index 0000000..8710a16
--- /dev/null
+++ b/debug/README
@@ -0,0 +1 @@
+Update for mts-io.conf to turn on debug
diff --git a/debug/etc/modprobe.d/mts-io.conf b/debug/etc/modprobe.d/mts-io.conf
new file mode 100644
index 0000000..e17ee57
--- /dev/null
+++ b/debug/etc/modprobe.d/mts-io.conf
@@ -0,0 +1,2 @@
+blacklist mts-io
+options mts-io dyndbg=+p
diff --git a/io-module/gpio.c b/io-module/gpio.c
index e754ed6..10f076b 100644
--- a/io-module/gpio.c
+++ b/io-module/gpio.c
@@ -65,7 +65,11 @@ ssize_t mts_attr_show_gpio_pin(struct device *dev,
mutex_lock(&mts_io_mutex);
- value = gpio_get_value_cansleep(pin->pin.gpio);
+ if (pin->do_gpio_desc == 1) {
+ value = gpiod_get_value_cansleep(pin->desc);
+ } else {
+ value = gpio_get_value_cansleep(pin->pin.gpio);
+ }
mutex_unlock(&mts_io_mutex);
@@ -99,9 +103,11 @@ static ssize_t mts_attr_store_gpio_pin(struct device *dev,
}
mutex_lock(&mts_io_mutex);
-
- gpio_set_value_cansleep(pin->pin.gpio, value);
-
+ if (pin->do_gpio_desc == 1) {
+ gpiod_set_value_cansleep(pin->desc, value);
+ } else {
+ gpio_set_value_cansleep(pin->pin.gpio, value);
+ }
mutex_unlock(&mts_io_mutex);
return count;
@@ -112,12 +118,17 @@ static int reset_gpio_pin(struct gpio_pin *pin, unsigned int delay_ms, unsigned
if (!pin) {
return -ENODEV;
}
-
- gpio_set_value_cansleep(pin->pin.gpio, value);
-
+ if (pin->do_gpio_desc == 1) {
+ gpiod_set_value_cansleep(pin->desc, value);
+ } else {
+ gpio_set_value_cansleep(pin->pin.gpio, value);
+ }
mdelay(delay_ms);
-
- gpio_set_value_cansleep(pin->pin.gpio, !value);
+ if (pin->do_gpio_desc == 1) {
+ gpiod_set_value_cansleep(pin->desc, !value);
+ } else {
+ gpio_set_value_cansleep(pin->pin.gpio, !value);
+ }
return 0;
}
diff --git a/io-module/mts-io.c b/io-module/mts-io.c
index 167e3f0..db736f9 100644
--- a/io-module/mts-io.c
+++ b/io-module/mts-io.c
@@ -90,8 +90,14 @@ EXPORT_SYMBOL(mts_get_hw_version);
#include "adc.c"
+struct platform_device *mts_io_platform_device;
+EXPORT_SYMBOL(mts_io_platform_device);
+
+
static int mts_io_probe(struct platform_device *pdev)
{
+ mts_io_platform_device = pdev;
+ dev_dbg(&pdev->dev,"%s: ENTER\n",__func__);
return 0;
}
@@ -114,8 +120,6 @@ static struct platform_driver mts_io_driver = {
static uint8_t mts_hw_version;
-struct platform_device *mts_io_platform_device;
-EXPORT_SYMBOL(mts_io_platform_device);
static struct attribute_group *attr_group;
static struct attribute_group *attr_group_lora; // on-board lora peripheral to be stored in the lora/ sub-directory
@@ -1313,10 +1317,13 @@ mts_id_eeprom_load(void)
static void cleanup(void)
{
log_info("cleaning up....");
- if (mts_io_platform_device) {
- platform_device_unregister(mts_io_platform_device);
+
+ if (mts_io_platform_device != NULL && attr_group != NULL) {
+ sysfs_remove_group(&mts_io_platform_device->dev.kobj, attr_group);
}
+ platform_driver_unregister(&mts_io_driver);
+
if(freelater) {
kfree(freelater);
freelater = NULL;
@@ -1328,7 +1335,7 @@ static void cleanup(void)
}
mts_capab_dir_delete();
- mts_cpu_dir_delete();
+ mts_cpu_dir_delete();
}
static int __init mts_io_init(void)
@@ -1346,27 +1353,15 @@ static int __init mts_io_init(void)
* probe function, we will do a 2nd probe in
* platform_device_add, which will result in a
* stack trace in the log. */
- ret = platform_driver_register(&mts_io_driver);
- if (ret)
- printk(KERN_ERR "mts-io: probe failed: %d\n", ret);
- platform_driver_unregister(&mts_io_driver);
-
- mts_io_platform_device = platform_device_alloc(PLATFORM_NAME, -1);
- if (!mts_io_platform_device)
- return -ENOMEM;
-
- /* request_firmware() requires a device, so call after device allocated */
- ret = mts_id_eeprom_load();
+ ret = platform_driver_register(&mts_io_driver);
if (ret) {
- kfree(mts_io_platform_device);
+ printk(KERN_ERR "mts-io: probe failed: %d\n", ret);
+ cleanup();
return ret;
}
- ret = platform_device_add(mts_io_platform_device);
- if (ret) {
- kfree(mts_io_platform_device);
- return ret;
- }
+ /* request_firmware() requires a device, so call after device allocated */
+ ret = mts_id_eeprom_load();
if (DEVICE_CAPA(id_eeprom.capa, CAPA_DOUT)) {
ret = spi_register_driver(&mts_spi_dout_driver);
diff --git a/io-module/mts_io.h b/io-module/mts_io.h
index 4f46804..e0b67b7 100644
--- a/io-module/mts_io.h
+++ b/io-module/mts_io.h
@@ -3,7 +3,7 @@
#include "mts_eeprom.h"
#include <linux/gpio.h>
-
+#include <linux/gpio/consumer.h>
/* Note that this header file is used by the MTAC driver. */
#define __log(level, name, format, args...) \
@@ -47,6 +47,8 @@ struct gpio_pin {
struct gpio pin;
int active_low;
uint8_t capability;
+ int do_gpio_desc;
+ struct gpio_desc *desc;
};
extern int mts_has_radio(const char *product_id, size_t len);
diff --git a/io-module/version.h b/io-module/version.h
index 3432796..a97e7df 100644
--- a/io-module/version.h
+++ b/io-module/version.h
@@ -1,7 +1,7 @@
#ifndef __VERSION_H
#define __VERSION_H
-#define DRIVER_VERSION "v4.8.4"
+#define DRIVER_VERSION "v4.9.0"
#define DRIVER_AUTHOR "Multitech Systems"
#define DRIVER_DESC "MTS-IO Controller"
#define DRIVER_NAME "mts-io"