summaryrefslogtreecommitdiff
path: root/io-module
diff options
context:
space:
mode:
Diffstat (limited to 'io-module')
-rw-r--r--io-module/mts_io.c27
-rw-r--r--io-module/mts_io.h6
2 files changed, 23 insertions, 10 deletions
diff --git a/io-module/mts_io.c b/io-module/mts_io.c
index 427c464..c9a2c4b 100644
--- a/io-module/mts_io.c
+++ b/io-module/mts_io.c
@@ -103,6 +103,8 @@ struct gpio_pin {
int use_pullup;
};
+static uint8_t mts_product_id;
+
static struct gpio_pin *gpio_pins;
static struct gpio_pin gpio_pins_mtcdp_0_0[] = {
@@ -375,6 +377,8 @@ static int mts_id_eeprom_load(void)
{
memcpy(&id_eeprom, mts_id_eeprom, sizeof(mts_id_eeprom));
+ mts_product_id = MTCDP_E1_DK_1_0;
+
if (mts_id_eeprom[0] == 0xFF) {
log_error("uninitialized eeprom");
return -EIO;
@@ -387,10 +391,13 @@ static int mts_id_eeprom_load(void)
DEVICE_CAPA_SET(id_eeprom.capa, CAPA_GPS);
gpio_pins = gpio_pins_mtcdp_0_0;
+ mts_product_id = MTCDP_E1_DK_0_0;
} else if (strncmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG, strlen(PRODUCT_ID_MT100EOCG)) == 0) {
gpio_pins = gpio_pins_mt100eocg_0_0;
+ mts_product_id = MT100EOCG_0_0;
} else {
gpio_pins = gpio_pins_mtcdp_1_0;
+ mts_product_id = MTCDP_E1_DK_1_0;
}
log_info("sizeof: %lu", (unsigned long) sizeof(struct mts_id_eeprom_layout));
@@ -1354,7 +1361,7 @@ static ssize_t mts_attr_show_led_ls(struct device *dev,
int value;
struct gpio_pin *pin;
- if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) == 0) {
+ if ( mts_product_id == MT100EOCG_0_0 ) {
pin = gpio_pin_by_name("LED3");
}
else {
@@ -1385,7 +1392,7 @@ static ssize_t mts_attr_store_led_ls(struct device *dev,
int err;
struct gpio_pin *pin;
- if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) == 0) {
+ if ( mts_product_id == MT100EOCG_0_0 ) {
pin = gpio_pin_by_name("LED3");
}
else {
@@ -2428,7 +2435,7 @@ static int __init mts_io_init(void)
goto error2;
}
- if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) == 0) {
+ if ( mts_product_id == MT100EOCG_0_0 ) {
ret = sysfs_create_group(&mts_io_platform_device->dev.kobj,
&mt100eocg_platform_attribute_group);
if (ret) {
@@ -2444,7 +2451,7 @@ static int __init mts_io_init(void)
}
// No sout driver for MT100EOCG
- if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) != 0) {
+ if ( mts_product_id != MT100EOCG_0_0 ) {
ret = spi_register_driver(&mts_spi_sout_driver);
if (ret) {
goto error4;
@@ -2496,7 +2503,7 @@ static int __init mts_io_init(void)
}
}
- if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) == 0) {
+ if ( mts_product_id == MT100EOCG_0_0 ) {
//Set open drain for GPIO11 and GPIO12 using multi drive
pin = gpio_pin_by_name("GPIO11");
if (pin) {
@@ -2516,7 +2523,7 @@ static int __init mts_io_init(void)
}
// No blink_callback for MT100EOCG
- if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) != 0) {
+ if ( mts_product_id != MT100EOCG_0_0 ) {
blink_callback(NULL);
}
@@ -2531,11 +2538,11 @@ error7:
error6:
spi_unregister_driver(&mts_spi_dout_driver);
error5:
- if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) != 0) {
+ if ( mts_product_id != MT100EOCG_0_0 ) {
spi_unregister_driver(&mts_spi_sout_driver);
}
error4:
- if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) == 0) {
+ if ( mts_product_id == MT100EOCG_0_0 ) {
sysfs_remove_group(&mts_io_platform_device->dev.kobj,
&mt100eocg_platform_attribute_group);
}
@@ -2555,7 +2562,7 @@ error1:
static void __exit mts_io_exit(void)
{
- if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) != 0) {
+ if ( mts_product_id != MT100EOCG_0_0 ) {
cancel_delayed_work_sync(&blink_work);
}
@@ -2567,7 +2574,7 @@ static void __exit mts_io_exit(void)
spi_unregister_driver(&mts_spi_dout_driver);
spi_unregister_driver(&mts_spi_board_temp_driver);
- if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) == 0) {
+ if ( mts_product_id == MT100EOCG_0_0 ) {
sysfs_remove_group(&mts_io_platform_device->dev.kobj,
&mt100eocg_platform_attribute_group);
}
diff --git a/io-module/mts_io.h b/io-module/mts_io.h
index 38551ad..c15d5b0 100644
--- a/io-module/mts_io.h
+++ b/io-module/mts_io.h
@@ -19,6 +19,12 @@
#define HW_VERSION_MTCDP_1_0 "MTCDP-1.0"
#define HW_VERSION_MT100EOCG_0_0 "MT100EOCG-0.0"
+enum {
+ MTCDP_E1_DK_0_0,
+ MTCDP_E1_DK_1_0,
+ MT100EOCG_0_0
+};
+
#define DEVICE_CAPA_INDEX(c) (((c) & 0xFF) >> 3)
#define DEVICE_CAPA_MASK(c) BIT((c) & 0x07)