summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mtac_lora.c70
1 files changed, 69 insertions, 1 deletions
diff --git a/mtac_lora.c b/mtac_lora.c
index ce61874..e5a587e 100644
--- a/mtac_lora.c
+++ b/mtac_lora.c
@@ -92,6 +92,45 @@ static struct gpio_pin gpio_pins_mtcdt_mtac_lora_1_5[] = {
{ },
};
+static struct gpio_pin gpio_pins_mtcdt_mtac_lora_2g4_0_0[] = {
+ // gpio pins for Accessory Card 1
+ {
+ .name = "AP1_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PB12,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "ap1-reset",
+ }
+ },
+ {
+ .name = "AP1_BOOT",
+ .pin = {
+ .gpio = AT91_PIN_PC6,
+ .flags = GPIOF_OUT_INIT_LOW,
+ .label = "ap1-boot",
+ },
+ },
+
+ // gpio pins for Accessory Card 2
+ {
+ .name = "AP2_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PB13,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "ap2-reset",
+ }
+ },
+ {
+ .name = "AP2_BOOT",
+ .pin = {
+ .gpio = AT91_PIN_PC20,
+ .flags = GPIOF_OUT_INIT_LOW,
+ .label = "ap2-boot",
+ },
+ },
+ { },
+};
+
ssize_t lora_show_eui(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
{
int retval = -1;
@@ -132,6 +171,8 @@ static char* lora_gpio_pin_name_by_attr_name(const char* name, int port) {
return "ap1-cdone";
} else if (!strcmp(name,"creset")) {
return "ap1-creset";
+ } else if (!strcmp(name,"boot")) {
+ return "ap1-boot";
} else {
log_error("attribute name [%s] is invalid for LORA in port %d", name, port);
return "";
@@ -144,6 +185,8 @@ static char* lora_gpio_pin_name_by_attr_name(const char* name, int port) {
return "ap2-cdone";
} else if (!strcmp(name,"creset")) {
return "ap2-creset";
+ } else if (!strcmp(name,"boot")) {
+ return "ap2-boot";
} else {
log_error("attribute name [%s] is invalid for LORA in port %d", name, port);
return "";
@@ -153,7 +196,7 @@ static char* lora_gpio_pin_name_by_attr_name(const char* name, int port) {
return "";
}
-// 1 cdone (optional)
+// 1 cdone/boot (optional)
// 1 creset (optional)
// 1 eui
// 1 reset
@@ -164,6 +207,7 @@ static char* lora_gpio_pin_name_by_attr_name(const char* name, int port) {
// NULL
#define ATTRS_SIZE_1_5 9
+#define ATTRS_SIZE_2G4_0_0 8
#define ATTRS_SIZE_0_0 7
// Set the hardware version if the ROM string matches one of the valid
@@ -231,6 +275,7 @@ static bool lora_setup(enum ap port) {
if COMPARE_AND_ASSIGN(MTAC_LORA_0_0)
else if COMPARE_AND_ASSIGN(MTAC_LORA_1_0)
else if COMPARE_AND_ASSIGN(MTAC_LORA_1_5)
+ else if COMPARE_AND_ASSIGN(MTAC_LORA_2G4_0_0)
else {
log_error("Unknown hw-version in port %d", port);
return false;
@@ -239,6 +284,9 @@ static bool lora_setup(enum ap port) {
if ((lora_hw_version == MTAC_LORA_0_0) || (lora_hw_version == MTAC_LORA_1_0)) {
ap_lora_attrs_size = ATTRS_SIZE_0_0;
mtac_set_port_pins(port_index,gpio_pins_mtcdt_mtac_lora_0_0,subdir);
+ } else if ((lora_hw_version == MTAC_LORA_2G4_0_0) || (lora_hw_version == MTAC_LORA_2G4_0_0)) {
+ ap_lora_attrs_size = ATTRS_SIZE_2G4_0_0;
+ mtac_set_port_pins(port_index,gpio_pins_mtcdt_mtac_lora_2g4_0_0,subdir);
} else {
ap_lora_attrs_size = ATTRS_SIZE_1_5;
mtac_set_port_pins(port_index,gpio_pins_mtcdt_mtac_lora_1_5,subdir);
@@ -295,6 +343,26 @@ static bool lora_setup(enum ap port) {
}
}
+ if (lora_hw_version == MTAC_LORA_2G4_0_0) {
+ //GPIO1 - boot on MCU controls reset into bootloader mode
+ sprintf(buf, "boot");
+ attr = mtac_create_attribute(buf, MTS_ATTR_MODE_RW);
+ if (! attr) {
+ log_error("failed to create attribute [%s] for LORA in port %d", buf, port);
+ attrs[index] = NULL;
+ mtac_port_info[port_index]->attr_group.attrs = attrs;
+ return false;
+ }
+ attr->show = mtac_attr_show_ap_gpio_pin;
+ attr->store = mtac_attr_store_ap_gpio_pin;
+ attrs[index++] = &attr->attr;
+
+ if(index >= ap_lora_attrs_size) {
+ panic("Internal error, too many attributes on the LORA card index %d >= %d",
+ index,ap_lora_attrs_size);
+ }
+ }
+
sprintf(buf,"eui");
attr = mtac_create_attribute("eui", MTS_ATTR_MODE_RO);
if (! attr) {