diff options
author | John Klug <john.klug@multitech.com> | 2022-02-25 16:43:15 -0600 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2022-02-25 16:50:25 -0600 |
commit | 9d66ada9f2e5e060f4d3cbaa8e33b67c81a95efc (patch) | |
tree | d287aebcfb18c2c882b0cd257d725adf7dcc5137 | |
parent | 477e4e7de645806ef17ddc2ce917061fade6cd9b (diff) | |
download | mtac-gpiob-master.tar.gz mtac-gpiob-master.tar.bz2 mtac-gpiob-master.zip |
-rw-r--r-- | AUTHORS | 4 | ||||
-rw-r--r-- | README | 7 | ||||
-rw-r--r-- | mtac_gpiob.c | 184 |
3 files changed, 139 insertions, 56 deletions
@@ -1,3 +1 @@ -James Maki <jmaki@multitech.com> -John Klug <john.klug@multitech.com> - +Multi-Tech <info@multitech.com> @@ -14,3 +14,10 @@ An init script can look in: /lib/modules/$(uname -r)/extra/mtac_gpiob.ko to find the driver. + +The mtac-mfser v2.0.0 driver is based on v1.1.4, +with the legacy kernel gpio library replaced +with gpiod. + +v1.3.0 was a stopgap before gpiod could be implemented +in mts-io and mtac drivers. diff --git a/mtac_gpiob.c b/mtac_gpiob.c index da3fa61..91006d5 100644 --- a/mtac_gpiob.c +++ b/mtac_gpiob.c @@ -1,10 +1,9 @@ -#define DRIVER_VERSION "v1.3.0" +#define DRIVER_VERSION "v2.0.0" #define DRIVER_AUTHOR "Multi-Tech" #define DRIVER_DESC "MTS General Purpose I/O Accessory Card" #define DRIVER_NAME "mtac-gpiob" #include <linux/types.h> -#include <linux/gpio.h> #include <linux/platform_device.h> #include <linux/kmod.h> #include <linux/bitops.h> @@ -13,54 +12,142 @@ #include <linux/spi/spi.h> #include <linux/mtac.h> #include <linux/mts_io.h> -#include <linux/mts_io_module.h> -#include <linux/mtac_pin_defs.h> -#ifdef TI43X -#include <linux/ti43x_gpio.h> -#endif -#ifdef SAM9G25 -#include <linux/sam9g25_gpio.h> -#endif +#include <linux/gpio/consumer.h> static struct gpio_pin gpio_pins_mtcdt_mtac_gpiob[] = { // gpio pins for Accessory Card 1 - AP1_RESET, - AP1_GPIO1, - AP1_GPIO2, - AP1_GPIO3, - AP1_GPIO4, - AP1_INTERRUPT1, - AP1_INTERRUPT2, + { + .name = "AP1_NRESET", + .pin = { + .gpio = ~0, + .flags = GPIOD_OUT_HIGH, + .label = "ap1-reset", + }, + .do_gpio_desc = 1, + }, + { + .name = "AP1_GPIO1", + .pin = { + .gpio = ~0, + .flags = GPIOD_OUT_LOW, + .label = "ap1-gpio1", + }, + .active_low = 1, + .do_gpio_desc = 1, + }, + { + .name = "AP1_GPIO2", + .pin = { + .gpio = ~0, + .flags = GPIOD_OUT_LOW, + .label = "ap1-gpio2", + }, + .do_gpio_desc = 1, + }, + { + .name = "AP1_GPIO3", + .pin = { + .gpio = ~0, + .flags = GPIOD_OUT_LOW, + .label = "ap1-gpio3", + }, + .do_gpio_desc = 1, + }, + { + .name = "AP1_GPIO4", + .pin = { + .gpio = ~0, + .flags = GPIOD_OUT_LOW, + .label = "ap1-gpio4", + }, + .do_gpio_desc = 1, + }, + { + .name = "AP1_NINT1", + .pin = { + .gpio = ~0, + .flags = GPIOD_IN, + .label = "ap1-interrupt1", + }, + .do_gpio_desc = 1, + }, + { + .name = "AP1_NINT2", + .pin = { + .gpio = ~0, + .flags = GPIOD_IN, + .label = "ap1-interrupt2", + }, + .do_gpio_desc = 1, + }, + // The PPS is driven by the on-board GPS -- removed // gpio pins for Accessory Card 2 - AP2_RESET, - AP2_GPIO1, - AP2_GPIO2, - AP2_GPIO3, - AP2_GPIO4, - AP2_INTERRUPT1, - AP2_INTERRUPT2, - { }, -}; - -static struct gpio_pin gpio_pins_mtcdt_0_2_mtac_gpiob[] = { - // gpio pins for Accessory Card 1 - AP1_RESET, - AP1_GPIO1, - AP1_GPIO2, - AP1_GPIO3_MTCDT0_2, - AP1_GPIO4_MTCDT0_2, - AP1_INTERRUPT1, - AP1_INTERRUPT2, + { + .name = "AP2_NRESET", + .pin = { + .gpio = ~0, + .flags = GPIOD_OUT_HIGH, + .label = "ap2-reset", + }, + .do_gpio_desc = 1, + }, + { + .name = "AP2_GPIO1", + .pin = { + .gpio = ~0, + .flags = GPIOD_OUT_LOW, + .label = "ap2-gpio1", + }, + .active_low = 1, + .do_gpio_desc = 1, + }, + { + .name = "AP2_GPIO2", + .pin = { + .gpio = ~0, + .flags = GPIOD_OUT_LOW, + .label = "ap2-gpio2", + }, + .do_gpio_desc = 1, + }, + { + .name = "AP2_GPIO3", + .pin = { + .gpio = ~0, + .flags = GPIOD_OUT_LOW, + .label = "ap2-gpio3", + }, + .do_gpio_desc = 1, + }, + { + .name = "AP2_GPIO4", + .pin = { + .gpio = ~0, + .flags = GPIOD_OUT_LOW, + .label = "ap2-gpio4", + }, + .do_gpio_desc = 1, + }, + { + .name = "AP2_NINT1", + .pin = { + .gpio = ~0, + .flags = GPIOD_IN, + .label = "ap2-interrupt1", + }, + .do_gpio_desc = 1, + }, + { + .name = "AP2_NINT2", + .pin = { + .gpio = ~0, + .flags = GPIOD_IN, + .label = "ap2-interrupt2", + }, + .do_gpio_desc = 1, + }, - // gpio pins for Accessory Card 2 - AP2_RESET, - AP2_GPIO1, - AP2_GPIO2, - AP2_GPIO3_MTCDT0_2, - AP2_GPIO4_MTCDT0_2, - AP2_INTERRUPT1, - AP2_INTERRUPT2, { }, }; @@ -477,7 +564,6 @@ static bool gpiob_setup(enum ap port) { struct kobj_attribute* attr; struct attribute **attrs; struct kobject *subdir; - char *tmp, *hw_version; log_info("loading GPIOB accessory card in port %d", port); @@ -488,15 +574,7 @@ static bool gpiob_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_gpiob,subdir); - } - else { - log_info("%s detected, MTCDT pinout used", hw_version); mtac_set_port_pins(port_index,gpio_pins_mtcdt_mtac_gpiob,subdir); - }; // create the link to the apX directory this card is in // if we're in the first slot, we get plain "gpiob" |