diff --git a/mtac_mfser.c b/mtac_mfser.c index d8548cb..fd7b0b6 100644 --- a/mtac_mfser.c +++ b/mtac_mfser.c @@ -1,4 +1,4 @@ -#define DRIVER_VERSION "v1.1.1" +#define DRIVER_VERSION "v1.2.0" #define DRIVER_AUTHOR "Multi-Tech" #define DRIVER_DESC "MTS Multi-Fuction Serial Accessory Card" #define DRIVER_NAME "mtac-mfser" @@ -12,6 +12,7 @@ #include #include #include +#include #ifdef TI43X #include #endif @@ -54,6 +55,86 @@ static struct gpio_pin gpio_pins_mtac_mfser[] = { .label = "ap1-gpio4", } }, + + // gpio pins for Accessory Card 2 + { + .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", + } + }, + { }, +}; +static struct gpio_pin gpio_pins_mtac_mfser_RI[] = { + // gpio pins for Accessory Card 1 + { + .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", + } + }, + { // MTCDT-0.4 only + .name = "AP1_ENABLE_TX_ENABLE", + .pin = { + .gpio = AT91_PIN_PC31, + .flags = GPIOF_OUT_INIT_LOW, + .label = "ap1-enable-tx-enable", + } + }, // gpio pins for Accessory Card 2 @@ -90,7 +171,15 @@ static struct gpio_pin gpio_pins_mtac_mfser[] = { .label = "ap2-gpio4", } }, - { }, + { // MTCDT-0.4 only + .name = "AP2_ENABLE_TX_ENABLE", + .pin = { + .gpio = AT91_PIN_PC30, + .flags = GPIOF_OUT_INIT_LOW, + .label = "ap2-enable-tx-enable", + } + }, + { }, }; static char* mfser_gpio_pin_name_by_attr_name(const char* name, int port) { @@ -251,8 +340,9 @@ static ssize_t mts_attr_store_mfser_mode(struct kobject *kobj, // 1 product-id // 1 device-id // 1 hw-version +// 1 enable_tx_enable // NULL -static size_t ap_mfser_attrs_size = 8; +static size_t ap_mfser_attrs_size = 9; static bool mfser_setup(enum ap port) { int i; @@ -264,6 +354,7 @@ static bool mfser_setup(enum ap port) { struct kobj_attribute* attr; struct attribute **attrs; struct kobject *subdir; + char *tmp; log_info("loading MFSER accessory card in port %d", port); @@ -273,8 +364,10 @@ static bool mfser_setup(enum ap port) { log_error("kobject_create_and_add for MFSER in port %d failed", port); return false; } - - mtac_set_port_pins(port_index,gpio_pins_mtac_mfser,subdir); + if ((tmp=HW_VERSION_MTCDT_0_2),strncmp(mts_get_hw_version(), tmp, strlen(tmp)) == 0) + mtac_set_port_pins(port_index,gpio_pins_mtac_mfser_RI,subdir); + else + 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" @@ -334,6 +427,18 @@ static bool mfser_setup(enum ap port) { attr->store = mtac_attr_store_ap_gpio_pin; attrs[index++] = &attr->attr; + if ((tmp=HW_VERSION_MTCDT_0_2),strncmp(mts_get_hw_version(), tmp, strlen(tmp)) == 0) { + sprintf(buf, "enable-tx-enable"); + attr = mtac_create_attribute(buf, MTS_ATTR_MODE_RW); + if (! attr) { + log_error("failed to create attribute [%s] for MFSER in port %d", buf, port); + return false; + } + attr->show = mtac_attr_show_ap_gpio_pin; + attr->store = mtac_attr_store_ap_gpio_pin; + attrs[index++] = &attr->attr; + } + // add attributes for eeprom contents if (! mtac_add_product_info_attributes(port, attrs, &index)) { log_error("failed to add product info attributes for MFSER in port %d", port);