summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mtac_gpiob.c163
1 files changed, 46 insertions, 117 deletions
diff --git a/mtac_gpiob.c b/mtac_gpiob.c
index ee83416..2242ee6 100644
--- a/mtac_gpiob.c
+++ b/mtac_gpiob.c
@@ -1,4 +1,4 @@
-#define DRIVER_VERSION "v1.1.4"
+#define DRIVER_VERSION "v1.2.0"
#define DRIVER_AUTHOR "Multi-Tech"
#define DRIVER_DESC "MTS General Purpose I/O Accessory Card"
#define DRIVER_NAME "mtac-gpiob"
@@ -13,6 +13,8 @@
#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
@@ -22,125 +24,43 @@
static struct gpio_pin gpio_pins_mtcdt_mtac_gpiob[] = {
// gpio pins for Accessory Card 1
- {
- .name = "AP1_RESET",
- .pin = {
- .gpio = M_AP1_NRESET,
- .flags = GPIOF_OUT_INIT_HIGH,
- .label = "ap1-reset",
- }
- },
- {
- .name = "AP1_GPIO1",
- .pin = {
- .gpio = M_AP1_GPIO1,
- .flags = GPIOF_OUT_INIT_LOW,
- .label = "ap1-gpio1",
- },
- .active_low = 1,
- },
- {
- .name = "AP1_GPIO2",
- .pin = {
- .gpio = M_AP1_GPIO2,
- .flags = GPIOF_OUT_INIT_LOW,
- .label = "ap1-gpio2",
- }
- },
- {
- .name = "AP1_GPIO3",
- .pin = {
- .gpio = M_AP1_GPIO3,
- .flags = GPIOF_OUT_INIT_LOW,
- .label = "ap1-gpio3",
- }
- },
- {
- .name = "AP1_GPIO4",
- .pin = {
- .gpio = M_AP1_GPIO4,
- .flags = GPIOF_OUT_INIT_LOW,
- .label = "ap1-gpio4",
- }
- },
- {
- .name = "AP1_INTERRUPT1",
- .pin = {
- .gpio = M_AP1_NINT1,
- .flags = GPIOF_IN,
- .label = "ap1-interrupt1",
- }
- },
- {
- .name = "AP1_INTERRUPT2",
- .pin = {
- .gpio = M_AP1_NINT2,
- .flags = GPIOF_IN,
- .label = "ap1-interrupt2",
- }
- },
- // The PPS is driven by the on-board GPS -- removed
+ AP1_RESET,
+ AP1_GPIO1,
+ AP1_GPIO2,
+ AP1_GPIO3,
+ AP1_GPIO4,
+ AP1_INTERRUPT1,
+ AP1_INTERRUPT2,
// gpio pins for Accessory Card 2
- {
- .name = "AP2_RESET",
- .pin = {
- .gpio = M_AP2_NRESET,
- .flags = GPIOF_OUT_INIT_HIGH,
- .label = "ap2-reset",
- }
- },
- {
- .name = "AP2_GPIO1",
- .pin = {
- .gpio = M_AP2_GPIO1,
- .flags = GPIOF_OUT_INIT_LOW,
- .label = "ap2-gpio1",
- },
- .active_low = 1,
- },
- {
- .name = "AP2_GPIO2",
- .pin = {
- .gpio = M_AP2_GPIO2,
- .flags = GPIOF_OUT_INIT_LOW,
- .label = "ap2-gpio2",
- }
- },
- {
- .name = "AP2_GPIO3",
- .pin = {
- .gpio = M_AP2_GPIO3,
- .flags = GPIOF_OUT_INIT_LOW,
- .label = "ap2-gpio3",
- }
- },
- {
- .name = "AP2_GPIO4",
- .pin = {
- .gpio = M_AP2_GPIO4,
- .flags = GPIOF_OUT_INIT_LOW,
- .label = "ap2-gpio4",
- }
- },
- {
- .name = "AP2_INTERRUPT1",
- .pin = {
- .gpio = M_AP2_NINT1,
- .flags = GPIOF_IN,
- .label = "ap2-interrupt1",
- }
- },
- {
- .name = "AP2_INTERRUPT2",
- .pin = {
- .gpio = M_AP2_NINT2,
- .flags = GPIOF_IN,
- .label = "ap2-interrupt2",
- }
- },
- // The PPS is driven by the on-board GPS -- removed
+ 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,
+
+ // gpio pins for Accessory Card 2
+ AP2_RESET,
+ AP2_GPIO1,
+ AP2_GPIO2,
+ AP2_GPIO3_MTCDT0_2,
+ AP2_GPIO4_MTCDT0_2,
+ AP2_INTERRUPT1,
+ AP2_INTERRUPT2,
{ },
};
@@ -557,6 +477,7 @@ 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);
@@ -567,7 +488,15 @@ 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"