summaryrefslogtreecommitdiff
path: root/io-module
diff options
context:
space:
mode:
Diffstat (limited to 'io-module')
-rw-r--r--io-module/mts_io.c223
-rw-r--r--io-module/mts_io.h5
2 files changed, 221 insertions, 7 deletions
diff --git a/io-module/mts_io.c b/io-module/mts_io.c
index 528b754..e96360f 100644
--- a/io-module/mts_io.c
+++ b/io-module/mts_io.c
@@ -106,6 +106,7 @@ static uint8_t mts_product_id;
static uint8_t has_spi_sout;
static uint8_t has_spi_din;
static uint8_t has_spi_dout;
+static uint8_t has_spi_temp;
static struct gpio_pin *gpio_pins;
@@ -572,6 +573,142 @@ static struct gpio_pin gpio_pins_en4_0_0[] = {
{ },
};
+static struct gpio_pin gpio_pins_mtr_0_0[] = {
+ {
+ .name = "NETH_RST",
+ .attr_name = "eth0-enabled",
+ .pin = AT91_PIN_PC6,
+ .direction = GPIO_DIR_OUTPUT,
+ .output_value = 1,
+ .use_pullup = 0,
+ },
+ {
+ .name = "3G_RST",
+ .attr_name = "radio-reset",
+ .pin = AT91_PIN_PA22,
+ .direction = GPIO_DIR_OUTPUT,
+ .output_value = 1,
+ .use_pullup = 0,
+ },
+ {
+ .name = "3G_ONOFF",
+ .attr_name = "radio-enabled",
+ .pin = AT91_PIN_PA21,
+ .direction = GPIO_DIR_OUTPUT,
+ .output_value = 1,
+ .use_pullup = 0,
+ },
+ {
+ .name = "DEVICE_RESET",
+ .attr_name = "reset",
+ .pin = AT91_PIN_PC4,
+ .direction = GPIO_DIR_INPUT,
+ .output_value = 0,
+ .use_pullup = 0,
+ },
+ {
+ .name = "LS_LED",
+ .attr_name = "led-ls",
+ .pin = AT91_PIN_PC16,
+#if LED_LS_CONTROLLABLE
+ .direction = GPIO_DIR_OUTPUT,
+#else
+ .direction = GPIO_DIR_INPUT,
+#endif
+ .output_value = 1,
+ .use_pullup = 0,
+ },
+ {
+ .name = "STATUS_LED",
+ .attr_name = "led-status",
+ .pin = AT91_PIN_PC21,
+ .direction = GPIO_DIR_OUTPUT,
+ .output_value = 1,
+ .use_pullup = 0,
+ },
+ {
+ .name = "LED3",
+ .attr_name = "led-wifi",
+ .pin = AT91_PIN_PC15,
+ .direction = GPIO_DIR_OUTPUT,
+ .output_value = 1,
+ .use_pullup = 0,
+ },
+ {
+ .name = "LED4",
+ .attr_name = "led-cd",
+ .pin = AT91_PIN_PC20,
+ .direction = GPIO_DIR_OUTPUT,
+ .output_value = 1,
+ .use_pullup = 0,
+ },
+ {
+ .name = "LED6",
+ .attr_name = "led-sig1",
+ .pin = AT91_PIN_PC19,
+ .direction = GPIO_DIR_OUTPUT,
+ .output_value = 1,
+ .use_pullup = 0,
+ },
+ {
+ .name = "LED7",
+ .attr_name = "led-sig2",
+ .pin = AT91_PIN_PC18,
+ .direction = GPIO_DIR_OUTPUT,
+ .output_value = 1,
+ .use_pullup = 0,
+ },
+ {
+ .name = "LED8",
+ .attr_name = "led-sig3",
+ .pin = AT91_PIN_PC17,
+ .direction = GPIO_DIR_OUTPUT,
+ .output_value = 1,
+ .use_pullup = 0,
+ },
+ {
+ .name = "DTR3",
+ .attr_name = "extserial-dtr",
+ .pin = AT91_PIN_PC26,
+ .direction = GPIO_DIR_INPUT,
+ .output_value = 0,
+ .use_pullup = 0,
+ },
+ {
+ .name = "DSR3",
+ .attr_name = "extserial-dsr",
+ .pin = AT91_PIN_PC27,
+ .direction = GPIO_DIR_OUTPUT,
+ .output_value = 1,
+ .use_pullup = 0,
+ },
+ {
+ .name = "DCD3",
+ .attr_name = "extserial-dcd",
+ .pin = AT91_PIN_PC28,
+ .direction = GPIO_DIR_OUTPUT,
+ .output_value = 1,
+ .use_pullup = 0,
+ },
+ {
+ .name = "BT_EN",
+ .attr_name = "bt-enabled",
+ .pin = AT91_PIN_PA28,
+ .direction = GPIO_DIR_OUTPUT,
+ .output_value = 0,
+ .use_pullup = 0,
+ },
+ {
+ .name = "WLAN_EN",
+ .attr_name = "wlan-enabled",
+ .pin = AT91_PIN_PA27,
+ .direction = GPIO_DIR_OUTPUT,
+ .output_value = 0,
+ .use_pullup = 0,
+ },
+ { },
+};
+
struct gpio_pin *gpio_pin_by_name(const char *name) {
struct gpio_pin *pin;
@@ -612,6 +749,7 @@ static int mts_id_eeprom_load(void)
has_spi_sout = 1;
has_spi_din = 1;
has_spi_dout = 1;
+ has_spi_temp = 1;
if (mts_id_eeprom[0] == 0xFF) {
log_error("uninitialized eeprom");
@@ -632,18 +770,28 @@ static int mts_id_eeprom_load(void)
has_spi_sout = 0;
has_spi_din = 1;
has_spi_dout = 1;
+ has_spi_temp = 1;
} else if (strncmp(id_eeprom.product_id, PRODUCT_ID_EN4, strlen(PRODUCT_ID_EN4)) == 0) {
gpio_pins = gpio_pins_en4_0_0;
mts_product_id = EN4_0_0;
has_spi_sout = 0;
has_spi_din = 0;
has_spi_dout = 0;
+ has_spi_temp = 1;
+ } else if (strncmp(id_eeprom.product_id, PRODUCT_ID_MTR, strlen(PRODUCT_ID_MTR)) == 0) {
+ gpio_pins = gpio_pins_mtr_0_0;
+ mts_product_id = MTR_0_0;
+ has_spi_sout = 0;
+ has_spi_din = 0;
+ has_spi_dout = 0;
+ has_spi_temp = 0;
} else {
gpio_pins = gpio_pins_mtcdp_1_0;
mts_product_id = MTCDP_E1_DK_1_0;
has_spi_sout = 1;
has_spi_din = 1;
has_spi_dout = 1;
+ has_spi_temp = 1;
}
log_info("sizeof: %lu", (unsigned long) sizeof(struct mts_id_eeprom_layout));
@@ -1085,6 +1233,15 @@ static struct device_attribute dev_attr_wlan_enabled = {
.store = mts_attr_store_gpio_pin,
};
+static struct device_attribute dev_attr_radio_enabled = {
+ .attr = {
+ .name = "radio-enabled",
+ .mode = MTS_ATTR_MODE_RW,
+ },
+ .show = mts_attr_show_gpio_pin,
+ .store = mts_attr_store_gpio_pin,
+};
+
static ssize_t mts_attr_store_sout(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
@@ -1793,6 +1950,15 @@ static struct device_attribute dev_attr_led_cd_gpio = {
.store = mts_attr_store_gpio_pin_inverted,
};
+static struct device_attribute dev_attr_led_wifi = {
+ .attr = {
+ .name = "led-wifi",
+ .mode = MTS_ATTR_MODE_RW,
+ },
+ .show = mts_attr_show_gpio_pin_inverted,
+ .store = mts_attr_store_gpio_pin_inverted,
+};
+
static struct device_attribute dev_attr_reset = {
.attr = {
.name = "reset",
@@ -2435,6 +2601,32 @@ static struct attribute_group platform_attribute_group = {
.attrs = platform_attributes
};
+static struct attribute *mtr_platform_attributes[] = {
+ &dev_attr_reset.attr,
+ &dev_attr_reset_monitor.attr,
+ &dev_attr_radio_reset.attr,
+ &dev_attr_radio_enabled.attr,
+ &dev_attr_extserial_dtr.attr,
+ &dev_attr_extserial_dsr_gpio.attr,
+ &dev_attr_extserial_cd.attr,
+ &dev_attr_eth0_enabled.attr,
+ &dev_attr_bt_enabled.attr,
+ &dev_attr_wlan_enabled.attr,
+
+ &dev_attr_led_status.attr,
+ &dev_attr_led_sig1_gpio.attr,
+ &dev_attr_led_sig2_gpio.attr,
+ &dev_attr_led_sig3_gpio.attr,
+ &dev_attr_led_cd_gpio.attr,
+ &dev_attr_led_wifi.attr,
+
+ NULL,
+};
+
+static struct attribute_group mtr_platform_attribute_group = {
+ .attrs = mtr_platform_attributes
+};
+
static struct platform_device *mts_io_platform_device;
static int __devinit mts_spi_sout_probe(struct spi_device *spi)
@@ -2642,6 +2834,13 @@ static int __init mts_io_init(void)
goto error3;
}
}
+ else if ( mts_product_id == MTR_0_0 ) {
+ ret = sysfs_create_group(&mts_io_platform_device->dev.kobj,
+ &mtr_platform_attribute_group);
+ if (ret) {
+ goto error3;
+ }
+ }
else {
ret = sysfs_create_group(&mts_io_platform_device->dev.kobj,
&platform_attribute_group);
@@ -2657,10 +2856,11 @@ static int __init mts_io_init(void)
}
}
-
- ret = spi_register_driver(&mts_spi_board_temp_driver);
- if (ret) {
- goto error7;
+ if ( has_spi_temp ) {
+ ret = spi_register_driver(&mts_spi_board_temp_driver);
+ if (ret) {
+ goto error7;
+ }
}
if ( has_spi_dout ) {
@@ -2739,7 +2939,9 @@ static int __init mts_io_init(void)
error9:
iounmap(adc_base);
error8:
- spi_unregister_driver(&mts_spi_board_temp_driver);
+ if ( has_spi_temp ) {
+ spi_unregister_driver(&mts_spi_board_temp_driver);
+ }
error7:
if ( has_spi_din ) {
spi_unregister_driver(&mts_spi_din_driver);
@@ -2761,6 +2963,10 @@ error4:
sysfs_remove_group(&mts_io_platform_device->dev.kobj,
&en4_platform_attribute_group);
}
+ else if ( mts_product_id == MTR_0_0 ) {
+ sysfs_remove_group(&mts_io_platform_device->dev.kobj,
+ &mtr_platform_attribute_group);
+ }
else {
sysfs_remove_group(&mts_io_platform_device->dev.kobj,
&platform_attribute_group);
@@ -2785,7 +2991,8 @@ static void __exit mts_io_exit(void)
clk_disable(adc_clk);
clk_put(adc_clk);
- spi_unregister_driver(&mts_spi_board_temp_driver);
+ if (has_spi_temp)
+ spi_unregister_driver(&mts_spi_board_temp_driver);
if (has_spi_din)
spi_unregister_driver(&mts_spi_din_driver);
@@ -2804,6 +3011,10 @@ static void __exit mts_io_exit(void)
sysfs_remove_group(&mts_io_platform_device->dev.kobj,
&en4_platform_attribute_group);
}
+ else if ( mts_product_id == MTR_0_0 ) {
+ sysfs_remove_group(&mts_io_platform_device->dev.kobj,
+ &mtr_platform_attribute_group);
+ }
else {
sysfs_remove_group(&mts_io_platform_device->dev.kobj,
&platform_attribute_group);
diff --git a/io-module/mts_io.h b/io-module/mts_io.h
index 633a194..a9e6191 100644
--- a/io-module/mts_io.h
+++ b/io-module/mts_io.h
@@ -14,18 +14,21 @@
#define PRODUCT_ID_MTCDP_E1_DK "MTCDP-E1-DK"
#define PRODUCT_ID_MT100EOCG "MT100EOCG"
#define PRODUCT_ID_EN4 "EN4"
+#define PRODUCT_ID_MTR "MTR"
#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 HW_VERSION_MT100EOCG_0_0 "MT100EOCG-0.0"
#define HW_VERSION_EN4 "EN4-0.0"
+#define HW_VERSION_MTR "MTR-0.0"
enum {
MTCDP_E1_DK_0_0,
MTCDP_E1_DK_1_0,
MT100EOCG_0_0,
- EN4_0_0
+ EN4_0_0,
+ MTR_0_0,
};
#define DEVICE_CAPA_INDEX(c) (((c) & 0xFF) >> 3)