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.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/io-module/mts-io.c b/io-module/mts-io.c
index ed0cb49..8b1fbec 100644
--- a/io-module/mts-io.c
+++ b/io-module/mts-io.c
@@ -46,6 +46,7 @@
#include "at91gpio.h"
#include "mts_io_module.h"
+#include "version.h"
#include "mts_io.h"
#include "buttons.h"
#include "mts_supercap.h"
@@ -80,6 +81,13 @@ MODULE_DEVICE_TABLE(of, mts_io_dt_ids);
/* on-board EEPROM */
static struct mts_id_eeprom_layout id_eeprom;
+// Allow other modules to query the hardware version
+const char *mts_get_hw_version(void)
+{
+ return id_eeprom.hw_version;
+}
+EXPORT_SYMBOL(mts_get_hw_version);
+
#include "adc.c"
static int mts_io_probe(struct platform_device *pdev)
@@ -544,6 +552,9 @@ static DEVICE_ATTR_MTS(dev_attr_led_d_gpio, "led-d",
static DEVICE_ATTR_MTS(dev_attr_led_e_gpio, "led-e",
mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+
+
+
/* eeprom info */
static ssize_t mts_attr_show_product_info(struct device *dev,
struct device_attribute *attr,
@@ -962,6 +973,61 @@ mts_id_eeprom_load(void)
gpio_pins = gpio_pins_mtcdt_0_1;
set_buttons(default_buttons);
log_info("detected board %s", tmp);
+ } else if ((tmp=HW_VERSION_MTCDT_0_2),(mts_hw_version=MTCDT_0_2),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0) {
+ need_append = 0;
+ current_blength = attr_blength = sizeof mtcdt_0_2_platform_attributes;
+ current_blength -= sizeof(struct attribute *); /* Length without terminating NULL */
+
+ /* See if we have no radio, and if so, prune out the stuff that follows */
+ if(noradio) {
+ struct attribute **ap = mtcdt_0_2_platform_attribute_group.attrs;
+ while(1) {
+ if(ap[j] == NULL) {
+ log_info("Did not find radio power attribute. Possible driver fault.");
+ break;
+ }
+ j++;
+ if (is_radio_power_attr_mtcdt(ap[j])) {
+ log_info("Pruning radio feature from mts-io",j);
+ ap[j] = NULL;
+ current_blength = j * sizeof (ap[j]); /* Size without NULL */
+ attr_blength += sizeof (ap[j]); /* Size of attr array with NULL */
+ break;
+ }
+ }
+ }
+
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_WIFI)) {
+ attr_blength += sizeof mtcdt_0_2_wifi_bt_attributes;
+ need_append = 1;
+ }
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_GPS)) {
+ attr_blength += sizeof mtcdt_0_2_gnss_attributes;
+ need_append = 1;
+ }
+ if (need_append) {
+ freelater = all_attrs = kmalloc(attr_blength,GFP_KERNEL);
+ current_count = current_blength/(sizeof (struct attribute *));
+ memcpy(all_attrs,mtcdt_0_2_platform_attributes,current_blength);
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_WIFI)) {
+ log_info("Adding WiFi/BT to mts-io driver");
+ memcpy(all_attrs + current_count,mtcdt_0_2_wifi_bt_attributes,sizeof mtcdt_0_2_wifi_bt_attributes);
+ current_count += sizeof mtcdt_0_2_wifi_bt_attributes / (sizeof (struct attribute *));
+ }
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_GPS)) {
+ log_info("Adding GPS to mts-io driver");
+ attr_blength += sizeof mtcdt_0_2_gnss_attributes;
+ memcpy(all_attrs + current_count,mtcdt_0_2_gnss_attributes,sizeof mtcdt_0_2_gnss_attributes);
+ current_count += sizeof mtcdt_0_2_gnss_attributes / (sizeof (struct attribute *));
+ }
+ all_attrs[current_count] = (struct attribute *)NULL;
+ mtcdt_0_2_platform_attribute_group.attrs = all_attrs;
+ }
+
+ attr_group = &mtcdt_0_2_platform_attribute_group;
+ gpio_pins = gpio_pins_mtcdt_0_2;
+ set_buttons(default_buttons);
+ log_info("detected board %s", tmp);
} else if ((tmp=HW_VERSION_MTCDTIPHP_0_0),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0) {
need_append = 0;
current_blength = attr_blength = sizeof mtcdt_0_1_platform_attributes;