From 9d66ada9f2e5e060f4d3cbaa8e33b67c81a95efc Mon Sep 17 00:00:00 2001 From: John Klug Date: Fri, 25 Feb 2022 16:43:15 -0600 Subject: Use gpio descriptors for MTAC-GPIOB --- AUTHORS | 4 +- README | 7 +++ mtac_gpiob.c | 184 ++++++++++++++++++++++++++++++++++++++++++----------------- 3 files changed, 139 insertions(+), 56 deletions(-) diff --git a/AUTHORS b/AUTHORS index 930c551..d338ebe 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1 @@ -James Maki -John Klug - +Multi-Tech diff --git a/README b/README index 292a6e8..0b7ada5 100644 --- a/README +++ b/README @@ -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 -#include #include #include #include @@ -13,54 +12,142 @@ #include #include #include -#include -#include -#ifdef TI43X -#include -#endif -#ifdef SAM9G25 -#include -#endif +#include 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" -- cgit v1.2.3