summaryrefslogtreecommitdiff
path: root/io-module
diff options
context:
space:
mode:
authorJames Maki <jmaki@multitech.com>2010-09-09 16:07:44 -0500
committerJames Maki <jmaki@multitech.com>2010-09-09 16:07:44 -0500
commit45ab09eeae9128bbe3dd425b78b70887c597b984 (patch)
treef4c32ff5a169ba7a37094d43c2445cba331eab8e /io-module
parent427222a6fdf12e8220cffbb96646f0d166286da3 (diff)
downloadmts-io-45ab09eeae9128bbe3dd425b78b70887c597b984.tar.gz
mts-io-45ab09eeae9128bbe3dd425b78b70887c597b984.tar.bz2
mts-io-45ab09eeae9128bbe3dd425b78b70887c597b984.zip
cleanup eeprom related stuff.
- removed eeprom dir there is now a util mts-id-eeprom to create images. - added mac_addr and imei to the eeprom layout. If we decide not to use them I will remove it later.
Diffstat (limited to 'io-module')
-rw-r--r--io-module/eeprom/eeprom.binbin512 -> 0 bytes
-rw-r--r--io-module/mts_io.c79
-rw-r--r--io-module/mts_io.h47
3 files changed, 77 insertions, 49 deletions
diff --git a/io-module/eeprom/eeprom.bin b/io-module/eeprom/eeprom.bin
deleted file mode 100644
index 985f368..0000000
--- a/io-module/eeprom/eeprom.bin
+++ /dev/null
Binary files differ
diff --git a/io-module/mts_io.c b/io-module/mts_io.c
index d95eed5..199c723 100644
--- a/io-module/mts_io.c
+++ b/io-module/mts_io.c
@@ -267,45 +267,9 @@ struct gpio_pin *gpio_pin_by_name(const char *name) {
return NULL;
}
-static uint8_t __capa_mask[] = {
- 0x01,
- 0x02,
- 0x04,
- 0x08,
- 0x10,
- 0x20,
- 0x40,
- 0x80
-};
-
-#define DEVICE_CAPA_INDEX(c) ((c) >> 3)
-#define DEVICE_CAPA_MASK(c) __capa_mask[(c) & 0x07]
-
-#define DEVICE_CAPA(capa_buf, c) ((capa_buf)[DEVICE_CAPA_INDEX(c)] & DEVICE_CAPA_MASK(c))
-#define DEVICE_CAPA_SET(capa_buf, c) \
-do { \
- (capa_buf)[DEVICE_CAPA_INDEX(c)] |= DEVICE_CAPA_MASK(c); \
-}while (0)
-#define DEVICE_CAPA_CLEAR(capa_buf, c) \
-do { \
- (capa_buf)[DEVICE_CAPA_INDEX(c)] &= ~DEVICE_CAPA_MASK(c); \
-} while (0)
-
-struct mts_id_eeprom_overlay {
- char vendor_id[32];
- char product_id[32];
- char device_id[32];
- char hw_version[32];
- uint8_t capa[32];
- uint8_t reserved[352];
-};
-
extern uint8_t mts_id_eeprom[512];
-struct mts_id_eeprom_overlay *id_eeprom =
- (struct mts_id_eeprom_overlay *) mts_id_eeprom;
-
-#define HWV_MTCDP_0_0 "MTCDP-0.0"
-#define HWV_MTCDP_1_0 "MTCDP-1.0"
+static struct mts_id_eeprom_layout *id_eeprom =
+ (struct mts_id_eeprom_layout *) mts_id_eeprom;
static int mts_id_eeprom_load(void)
{
@@ -313,18 +277,35 @@ static int mts_id_eeprom_load(void)
log_error("uninitialized eeprom");
return -EIO;
} else if (id_eeprom->vendor_id[0] == 0x00) {
- log_debug("MTCDP-0.0 hardware found");
- strcpy(id_eeprom->hw_version, HWV_MTCDP_0_0);
+ strncpy(id_eeprom->vendor_id, VENDOR_ID_MULTITECH, sizeof(id_eeprom->vendor_id) - 1);
+ strncpy(id_eeprom->product_id, PRODUCT_ID_MTCDP_E1_DK, sizeof(id_eeprom->product_id) - 1);
+ strncpy(id_eeprom->device_id, "", sizeof(id_eeprom->device_id) - 1);
+ strncpy(id_eeprom->hw_version, HW_VERSION_MTCDP_0_0, sizeof(id_eeprom->hw_version) - 1);
+
+ DEVICE_CAPA_SET(id_eeprom->capa, CAPA_GPS);
+
gpio_pins = gpio_pins_mtcdp_0_0;
} else {
gpio_pins = gpio_pins_mtcdp_1_0;
}
- log_info("vendor_id: %.32s", id_eeprom->vendor_id);
- log_info("product_id: %.32s", id_eeprom->product_id);
- log_info("device_id: %.32s", id_eeprom->device_id);
- log_info("hw_version: %.32s", id_eeprom->hw_version);
- log_info("capa: %02X", id_eeprom->capa[0]);
+ log_info("sizeof: %lu", (unsigned long) sizeof(struct mts_id_eeprom_layout));
+ log_info("vendor-id: %.32s", id_eeprom->vendor_id);
+ log_info("product-id: %.32s", id_eeprom->product_id);
+ log_info("device-id: %.32s", id_eeprom->device_id);
+ log_info("hw-version: %.32s", id_eeprom->hw_version);
+ log_info("mac-addr: %02X:%02X:%02X:%02X:%02X:%02X",
+ id_eeprom->mac_addr[0],
+ id_eeprom->mac_addr[1],
+ id_eeprom->mac_addr[2],
+ id_eeprom->mac_addr[3],
+ id_eeprom->mac_addr[4],
+ id_eeprom->mac_addr[5]);
+ log_info("imei: %.32s", id_eeprom->imei);
+ log_info("capa-gps: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_GPS) ? "yes" : "no");
+ log_info("capa-din: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_DIN) ? "yes" : "no");
+ log_info("capa-dout: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_DOUT) ? "yes" : "no");
+ log_info("capa-adc: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_ADC) ? "yes" : "no");
return 0;
}
@@ -1367,7 +1348,7 @@ static ssize_t mts_attr_show_adc(struct device *dev,
int offset;
u32 value;
- if (!strcmp(id_eeprom->hw_version, HWV_MTCDP_0_0)) {
+ if (!strcmp(id_eeprom->hw_version, HW_VERSION_MTCDP_0_0)) {
log_debug("ADC not available on 0.0 hw");
return -ENODEV;
}
@@ -1532,7 +1513,7 @@ static int __devinit mts_spi_dout_probe(struct spi_device *spi)
{
int tmp;
- if (!strcmp(id_eeprom->hw_version, HWV_MTCDP_0_0)) {
+ if (!strcmp(id_eeprom->hw_version, HW_VERSION_MTCDP_0_0)) {
log_debug("digital outputs not available on 0.0 hw");
return -ENODEV;
}
@@ -1576,7 +1557,7 @@ static int __devinit mts_spi_din_probe(struct spi_device *spi)
{
int tmp;
- if (!strcmp(id_eeprom->hw_version, HWV_MTCDP_0_0)) {
+ if (!strcmp(id_eeprom->hw_version, HW_VERSION_MTCDP_0_0)) {
log_debug("digital inputs not available on 0.0 hw");
return -ENODEV;
}
@@ -1712,7 +1693,7 @@ static int __init mts_io_init(void)
ADC_CONVERT_RESET(adc_base);
writel(ADC_MODE_DEFAULT, adc_base + ADC_MR_OFFSET);
writel(0x000F0F0F, adc_base + ADC_IDR_OFFSET);
- if (!strcmp(id_eeprom->hw_version, HWV_MTCDP_0_0)) {
+ if (!strcmp(id_eeprom->hw_version, HW_VERSION_MTCDP_0_0)) {
writel(0x0F, adc_base + ADC_CHDR_OFFSET);
} else {
writel(0x0F, adc_base + ADC_CHER_OFFSET);
diff --git a/io-module/mts_io.h b/io-module/mts_io.h
index 6cd1189..e9282cc 100644
--- a/io-module/mts_io.h
+++ b/io-module/mts_io.h
@@ -2,6 +2,53 @@
#ifndef __MTS_IO_H
#define __MTS_IO_H
+#if !__KERNEL__
+#include <stdint.h>
+
+#ifndef BIT
+#define BIT(nr) (1UL << (nr))
+#endif
+#endif
+
+#define VENDOR_ID_MULTITECH "Multi-Tech Systems"
+#define PRODUCT_ID_MTCDP_E1_DK "MTCDP-E1-DK"
+
+#define HW_VERSION_MTCBA2_2_0 "MTCBA2-2.0"
+#define HW_VERSION_MTCDP_0_0 "MTCDP-0.0"
+#define HW_VERSION_MTCDP_1_0 "MTCDP-1.0"
+
+#define DEVICE_CAPA_INDEX(c) (((c) & 0xFF) >> 3)
+#define DEVICE_CAPA_MASK(c) BIT((c) & 0x07)
+
+#define DEVICE_CAPA(capa_buf, c) ((capa_buf)[DEVICE_CAPA_INDEX(c)] & DEVICE_CAPA_MASK(c))
+
+#define DEVICE_CAPA_SET(capa_buf, c) \
+do { \
+ (capa_buf)[DEVICE_CAPA_INDEX(c)] |= DEVICE_CAPA_MASK(c); \
+}while (0)
+
+#define DEVICE_CAPA_CLEAR(capa_buf, c) \
+do { \
+ (capa_buf)[DEVICE_CAPA_INDEX(c)] &= ~DEVICE_CAPA_MASK(c); \
+} while (0)
+
+#define DEVICE_CAPA_VALUE(index, bit) ((((index) & 0x1F) << 3) | ((bit) & 0x07))
+
+#define CAPA_GPS DEVICE_CAPA_VALUE(0, 7)
+#define CAPA_DIN DEVICE_CAPA_VALUE(0, 6)
+#define CAPA_DOUT DEVICE_CAPA_VALUE(0, 5)
+#define CAPA_ADC DEVICE_CAPA_VALUE(0, 4)
+
+struct mts_id_eeprom_layout {
+ char vendor_id[32];
+ char product_id[32];
+ char device_id[32];
+ char hw_version[32];
+ uint8_t mac_addr[6];
+ char imei[32];
+ uint8_t capa[32];
+ uint8_t reserved[314];
+};
#endif /* ~__MTS_IO_H */