summaryrefslogtreecommitdiff
path: root/io-module/mts_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io-module/mts_io.c')
-rw-r--r--io-module/mts_io.c57
1 files changed, 43 insertions, 14 deletions
diff --git a/io-module/mts_io.c b/io-module/mts_io.c
index 547f099..f1f8cb6 100644
--- a/io-module/mts_io.c
+++ b/io-module/mts_io.c
@@ -47,7 +47,7 @@
#include "mts_io.h"
-#define DRIVER_VERSION "v1.5.0"
+#define DRIVER_VERSION "v1.5.1"
#define DRIVER_AUTHOR "James Maki <jmaki@multitech.com>"
#define DRIVER_DESC "MTS-IO Controller"
#define DRIVER_NAME "mts-io"
@@ -77,6 +77,7 @@ static struct mts_id_eeprom_layout id_eeprom;
static uint8_t mts_hw_version;
static struct platform_device *mts_io_platform_device;
static struct attribute_group *attr_group;
+static struct attribute_group *attr_group_lora; // on-board lora peripheral to be stored in the lora/ sub-directory
static struct gpio_pin *gpio_pins;
static DEFINE_MUTEX(mts_io_mutex);
@@ -633,10 +634,14 @@ static DEVICE_ATTR_RO_MTS(dev_attr_imei, "imei",
static DEVICE_ATTR_RO_MTS(dev_attr_eth_mac, "mac-eth",
mts_attr_show_product_info);
+/* include on-board lora peripheral */
+#include "mts_lora.c"
+
/* include per-device pins and attributes */
#include "mtcdt.c"
#include "mtcap.c"
+
#if NUM_AP > 0
/* accessory card EEPROMs */
@@ -765,6 +770,25 @@ static void init_accessory_ports(void) {}
static void teardown_accessory_ports(void) {}
#endif
+static void init_ports(void)
+{
+ if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA) && attr_group_lora) {
+ mts_load_lora_port();
+ }
+
+ init_accessory_ports();
+}
+
+static void teardown_ports(void)
+{
+ if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA) && attr_group_lora) {
+ mts_teardown_lora_port();
+ }
+
+ teardown_accessory_ports();
+}
+
+
struct attribute *freelater = NULL; // Storage to free when driver is unloaded.
static int mts_id_eeprom_load()
@@ -789,6 +813,9 @@ static int mts_id_eeprom_load()
} else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTCAP_0_0, strlen(HW_VERSION_MTCAP_0_0)) == 0) {
attr_group = &mtcap_0_0_platform_attribute_group;
gpio_pins = gpio_pins_mtcap_0_0;
+ if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA)) {
+ attr_group_lora = &mtcap_0_0_lora_attribute_group;
+ }
mts_hw_version = MTCAP_0_0;
log_info("detected board %s", HW_VERSION_MTCAP_0_0);
}
@@ -851,6 +878,7 @@ static int mts_id_eeprom_load()
log_info("capa-bluetooth: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_BLUETOOTH) ? "yes" : "no");
log_info("capa-wifi-bluetooth: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_WIFI_BT) ? "yes" : "no");
log_info("capa-gnss: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_GNSS) ? "yes" : "no");
+ log_info("capa-lora: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_LORA) ? "yes" : "no");
if (DEVICE_CAPA(id_eeprom.capa, CAPA_BLUETOOTH)) {
log_info("mac-bluetooth: %02X:%02X:%02X:%02X:%02X:%02X",
@@ -877,17 +905,18 @@ static int mts_id_eeprom_load()
}
log_info("uuid: %s", (char*)buf);
- if (mts_hw_version == MTCAP_0_0) {
- log_info("lora-eui: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
- id_eeprom.lora_eui[0],
- id_eeprom.lora_eui[1],
- id_eeprom.lora_eui[2],
- id_eeprom.lora_eui[3],
- id_eeprom.lora_eui[4],
- id_eeprom.lora_eui[5],
- id_eeprom.lora_eui[6],
- id_eeprom.lora_eui[7]);
- }
+ log_info("lora-eui: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
+ id_eeprom.lora_eui[0],
+ id_eeprom.lora_eui[1],
+ id_eeprom.lora_eui[2],
+ id_eeprom.lora_eui[3],
+ id_eeprom.lora_eui[4],
+ id_eeprom.lora_eui[5],
+ id_eeprom.lora_eui[6],
+ id_eeprom.lora_eui[7]);
+
+ log_info("lora-product-id: %.32s", id_eeprom.lora_product_id);
+ log_info("lora-hw-version: %.32s", id_eeprom.lora_hw_version);
return 0;
}
@@ -899,7 +928,7 @@ static void cleanup(void)
platform_device_unregister(mts_io_platform_device);
}
- teardown_accessory_ports();
+ teardown_ports();
if(freelater) {
kfree(freelater);
freelater = NULL;
@@ -933,7 +962,7 @@ static int __init mts_io_init(void)
return ret;
}
- init_accessory_ports();
+ init_ports();
ret = sysfs_create_group(&mts_io_platform_device->dev.kobj, attr_group);
if (ret) {