diff options
Diffstat (limited to 'io-module/mtac_mfser.c')
-rw-r--r-- | io-module/mtac_mfser.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/io-module/mtac_mfser.c b/io-module/mtac_mfser.c index 26fd339..d8b0029 100644 --- a/io-module/mtac_mfser.c +++ b/io-module/mtac_mfser.c @@ -5,7 +5,9 @@ static char* mfser_gpio_pin_name_by_attr_name(const char* name, int port) { return "ap1-gpio3"; } else if (! strcmp(name, "rts-override")) { return "ap1-gpio4"; - } else { + } else if (! strcmp(name, "reset")) { + return "ap1-reset"; + } else { log_error("attirbute name [%s] is invalid for MFSER in port %d", name, port); return ""; } @@ -15,8 +17,10 @@ static char* mfser_gpio_pin_name_by_attr_name(const char* name, int port) { return "ap2-gpio3"; } else if (! strcmp(name, "rts-override")) { return "ap2-gpio4"; + } else if (! strcmp(name, "reset")) { + return "ap2-reset"; } else { - log_error("attirbute name [%s] is invalid for MFSER in port %d", name, port); + log_error("attribute name [%s] is invalid for MFSER in port %d", name, port); return ""; } } @@ -145,6 +149,7 @@ static ssize_t mts_attr_store_mfser_mode(struct kobject *kobj, return count; } +// 1 reset # Unused in MFSER, but similar MTAC-XDOT needs reset // 1 serial mode // 1 rs4xx term resistor // 1 rts override @@ -153,7 +158,7 @@ static ssize_t mts_attr_store_mfser_mode(struct kobject *kobj, // 1 device-id // 1 hw-version // 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; @@ -164,7 +169,8 @@ static bool mfser_setup(enum ap port) { char buf[32]; struct kobj_attribute* attr; struct attribute **attrs; - + int ipin = 0; + log_info("loading MFSER accessory card in port %d", port); sprintf(buf, "ap%d", port); @@ -201,6 +207,30 @@ static bool mfser_setup(enum ap port) { log_error("failed to allocate attribute space for port %d", port); return false; } + + // Change GPIO ports 3 and 4 to match older versions of this driver. + // Substitute pins for this port + log_info("Substitute pins"); + while(*(mfser[port_index][ipin].name)) { + struct gpio_pin *p; + p = gpio_pin_by_num(mfser[port_index][ipin].pin.gpio); + if(p) { + log_info("MFSER: Replace name %s with name %s",p->name,mfser[port_index][ipin].name); + log_info("MFSER: Replace pin number %u with number %u",p->pin.gpio,mfser[port_index][ipin].pin.gpio); + *p = mfser[port_index][ipin]; + } + ipin++; + } + + sprintf(buf, "reset"); + attr = 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 = mts_attr_show_ap_gpio_pin; + attr->store = mts_attr_store_ap_gpio_pin; + attrs[index++] = &attr->attr; sprintf(buf, "serial-mode"); attr = create_attribute(buf, MTS_ATTR_MODE_RW); |