summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS3
-rw-r--r--README10
-rw-r--r--mtac_mfser.c134
3 files changed, 94 insertions, 53 deletions
diff --git a/AUTHORS b/AUTHORS
index f8e3fb5..d338ebe 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,2 +1 @@
-James Maki <jmaki@multitech.com>
-John Klug <john.klug@multitech.com>
+Multi-Tech <info@multitech.com>
diff --git a/README b/README
index 4a58590..08a6cb8 100644
--- a/README
+++ b/README
@@ -14,3 +14,13 @@ An init script can look in:
/lib/modules/$(uname -r)/extra/mtac_mfser.ko
to find the driver.
+
+
+The mtac-mfser v2.0.0 driver is based on v1.1.1,
+with the legacy kernel gpio library replaced
+with gpiod.
+
+The 1.2.0 driver was created for the new
+MTCDT-0.2, and the design was overly
+complex, also based on the legacy gpio
+library.
diff --git a/mtac_mfser.c b/mtac_mfser.c
index b8b163c..c38cb1e 100644
--- a/mtac_mfser.c
+++ b/mtac_mfser.c
@@ -1,10 +1,9 @@
-#define DRIVER_VERSION "v1.2.0"
+#define DRIVER_VERSION "v2.0.0"
#define DRIVER_AUTHOR "Multi-Tech"
#define DRIVER_DESC "MTS Multi-Fuction Serial Accessory Card"
#define DRIVER_NAME "mtac-mfser"
#include <linux/types.h>
-#include <linux/gpio.h>
#include <linux/platform_device.h>
#include <linux/kmod.h>
#include <linux/bitops.h>
@@ -12,45 +11,87 @@
#include <linux/slab.h>
#include <linux/mtac.h>
#include <linux/mts_io.h>
-#include <linux/mts_io_module.h>
+#include <linux/gpio/consumer.h>
-#include <linux/mtac.h>
-#include <linux/mtac_pin_defs.h>
-
-#ifdef TI43X
-#include <linux/ti43x_gpio.h>
-#endif
-#ifdef SAM9G25
-#include <linux/sam9g25_gpio.h>
-#endif
-
-static struct gpio_pin gpio_pins_mtcdt_mtac_mfser[] = {
- // gpio pins for Accessory Card 1
- AP1_GPIO1,
- AP1_GPIO2,
- AP1_GPIO3,
- AP1_GPIO4,
-
- // gpio pins for Accessory Card 2
- AP2_GPIO1,
- AP2_GPIO2,
- AP2_GPIO3,
- AP2_GPIO4,
- { },
-};
-
-static struct gpio_pin gpio_pins_mtcdt_0_2_mtac_mfser[] = {
+static struct gpio_pin gpio_pins_mtac_mfser[] = {
// gpio pins for Accessory Card 1
- AP1_GPIO1,
- AP1_GPIO2,
- AP1_GPIO3_MTCDT0_2,
- AP1_GPIO4_MTCDT0_2,
+ {
+ .name = "AP1_GPIO1",
+ .pin = {
+ .gpio = ~0U,
+ .flags = GPIOD_OUT_LOW,
+ .label = "ap1-gpio1",
+ },
+ .active_low = 1,
+ .do_gpio_desc = 1,
+ },
+ {
+ .name = "AP1_GPIO2",
+ .pin = {
+ .gpio = ~0U,
+ .flags = GPIOD_OUT_LOW,
+ .label = "ap1-gpio2",
+ },
+ .do_gpio_desc = 1,
+ },
+ {
+ .name = "AP1_GPIO3",
+ .pin = {
+ .gpio = ~0U,
+ .flags = GPIOD_OUT_LOW,
+ .label = "ap1-gpio3",
+ },
+ .do_gpio_desc = 1,
+ },
+ {
+ .name = "AP1_GPIO4",
+ .pin = {
+ .gpio = ~0U,
+ .flags = GPIOD_OUT_LOW,
+ .label = "ap1-gpio4",
+ },
+ .do_gpio_desc = 1,
+ },
+
// gpio pins for Accessory Card 2
- AP2_GPIO1,
- AP2_GPIO2,
- AP2_GPIO3_MTCDT0_2,
- AP2_GPIO4_MTCDT0_2,
+ {
+ .name = "AP2_GPIO1",
+ .pin = {
+ .gpio = ~0U,
+ .flags = GPIOD_OUT_LOW,
+ .label = "ap2-gpio1",
+ },
+ .active_low = 1,
+ .do_gpio_desc = 1,
+ },
+ {
+ .name = "AP2_GPIO2",
+ .pin = {
+ .gpio = ~0U,
+ .flags = GPIOD_OUT_LOW,
+ .label = "ap2-gpio2",
+ },
+ .do_gpio_desc = 1,
+ },
+ {
+ .name = "AP2_GPIO3",
+ .pin = {
+ .gpio = ~0U,
+ .flags = GPIOD_OUT_LOW,
+ .label = "ap2-gpio3",
+ },
+ .do_gpio_desc = 1,
+ },
+ {
+ .name = "AP2_GPIO4",
+ .pin = {
+ .gpio = ~0U,
+ .flags = GPIOD_OUT_LOW,
+ .label = "ap2-gpio4",
+ },
+ .do_gpio_desc = 1,
+ },
{ },
};
@@ -120,8 +161,8 @@ static ssize_t mts_attr_show_mfser_mode(struct kobject *kobj,
mutex_lock(&mtac_mutex);
- modesel0 = gpio_get_value(pin_modesel0->pin.gpio);
- modesel1 = gpio_get_value(pin_modesel1->pin.gpio);
+ modesel0 = gpiod_get_value(pin_modesel0->desc);
+ modesel1 = gpiod_get_value(pin_modesel1->desc);
if (modesel1 == 0 && modesel0 == 0)
ret = sprintf(buf, "loopback\n");
@@ -197,8 +238,8 @@ static ssize_t mts_attr_store_mfser_mode(struct kobject *kobj,
mutex_lock(&mtac_mutex);
- gpio_set_value(pin_modesel0->pin.gpio, modesel0);
- gpio_set_value(pin_modesel1->pin.gpio, modesel1);
+ gpiod_set_value(pin_modesel0->desc, modesel0);
+ gpiod_set_value(pin_modesel1->desc, modesel1);
mutex_unlock(&mtac_mutex);
@@ -225,7 +266,6 @@ static bool mfser_setup(enum ap port) {
struct kobj_attribute* attr;
struct attribute **attrs;
struct kobject *subdir;
- char *tmp, *hw_version;
log_info("loading MFSER accessory card in port %d", port);
@@ -236,15 +276,7 @@ static bool mfser_setup(enum ap port) {
return false;
}
- hw_version = mts_get_hw_version();
- if ((tmp=HW_VERSION_MTCDT_0_2),strncmp(hw_version, tmp, strlen(tmp)) == 0){
- log_info("MTCDT-0.2 detected");
- mtac_set_port_pins(port_index,gpio_pins_mtcdt_0_2_mtac_mfser,subdir);
- }
- else {
- log_info("%s detected, MTCDT pinout used", hw_version);
- mtac_set_port_pins(port_index,gpio_pins_mtcdt_mtac_mfser,subdir);
- };
+ mtac_set_port_pins(port_index,gpio_pins_mtac_mfser,subdir);
// create the link to the apX directory this card is in
// if we're in the first slot, we get plain "mfser"