summaryrefslogtreecommitdiff
path: root/io-module/mts_io.c
diff options
context:
space:
mode:
authorThanh Tran <ttran@multitech.com>2011-09-30 09:19:58 -0500
committerThanh Tran <ttran@multitech.com>2011-09-30 09:19:58 -0500
commit7db83cc15dde71ec288c7b7424b2dbad12b18ecd (patch)
tree53df93db0b639fe034958fef234b597ec86d8fa3 /io-module/mts_io.c
parentded21d0aefd250f3ec6d2ca4c59edf7d9e3e7b8c (diff)
downloadcdp-io-controller-7db83cc15dde71ec288c7b7424b2dbad12b18ecd.tar.gz
cdp-io-controller-7db83cc15dde71ec288c7b7424b2dbad12b18ecd.tar.bz2
cdp-io-controller-7db83cc15dde71ec288c7b7424b2dbad12b18ecd.zip
1. Used strncmp() to compare only the product name portion of product_ID.
2. GPOx logic levels were wrong, corrections were made to match the stand-alone CDP box. 3. Configured GPIO11 and GPIO12 to be open-drain. 4. Set driver version to v0.5.1
Diffstat (limited to 'io-module/mts_io.c')
-rw-r--r--io-module/mts_io.c70
1 files changed, 36 insertions, 34 deletions
diff --git a/io-module/mts_io.c b/io-module/mts_io.c
index a6add6c..427c464 100644
--- a/io-module/mts_io.c
+++ b/io-module/mts_io.c
@@ -41,7 +41,7 @@
#include "mts_io.h"
-#define DRIVER_VERSION "v0.4.2"
+#define DRIVER_VERSION "v0.5.1"
#define DRIVER_AUTHOR "James Maki <jmaki@multitech.com>"
#define DRIVER_DESC "MTCDP IO Controller"
#define DRIVER_NAME "mts-io"
@@ -210,6 +210,7 @@ static struct gpio_pin gpio_pins_mtcdp_1_0[] = {
#endif
.output_value = 1,
.use_pullup = 0,
+
},
#if LED_STATUS_CONTROLLABLE
{
@@ -340,14 +341,14 @@ static struct gpio_pin gpio_pins_mt100eocg_0_0[] = {
.pin = AT91_PIN_PB19,
.direction = GPIO_DIR_OUTPUT,
.output_value = 1,
- .use_pullup = 0,
+ .use_pullup = 1,
},
{
.name = "GPIO12",
.pin = AT91_PIN_PB20,
.direction = GPIO_DIR_OUTPUT,
.output_value = 1,
- .use_pullup = 0,
+ .use_pullup = 1,
},
{ },
};
@@ -386,7 +387,7 @@ static int mts_id_eeprom_load(void)
DEVICE_CAPA_SET(id_eeprom.capa, CAPA_GPS);
gpio_pins = gpio_pins_mtcdp_0_0;
- } else if (!strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG)) {
+ } else if (strncmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG, strlen(PRODUCT_ID_MT100EOCG)) == 0) {
gpio_pins = gpio_pins_mt100eocg_0_0;
} else {
gpio_pins = gpio_pins_mtcdp_1_0;
@@ -1005,20 +1006,12 @@ static ssize_t mts_attr_store_dout(struct device *dev,
mutex_lock(&spi_dout_mutex);
- if (!strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG)) {
- if (!value) {
- spi_dout_value &= ~bit;
- } else {
- spi_dout_value |= bit;
- }
- }
- else {
- if (value) {
- spi_dout_value &= ~bit;
- } else {
- spi_dout_value |= bit;
- }
+ if (value) {
+ spi_dout_value &= ~bit;
+ } else {
+ spi_dout_value |= bit;
}
+
spi_writen(spi_dout_dev, &spi_dout_value, 1);
mutex_unlock(&spi_dout_mutex);
@@ -1061,12 +1054,7 @@ static ssize_t mts_attr_show_dout(struct device *dev,
mutex_lock(&spi_dout_mutex);
- if (!strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG)) {
- value = spi_dout_value & bit ? 1 : 0;
- }
- else {
- value = spi_dout_value & bit ? 0 : 1;
- }
+ value = spi_dout_value & bit ? 0 : 1;
mutex_unlock(&spi_dout_mutex);
@@ -1366,7 +1354,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)) {
+ if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) == 0) {
pin = gpio_pin_by_name("LED3");
}
else {
@@ -1397,7 +1385,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)) {
+ if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) == 0) {
pin = gpio_pin_by_name("LED3");
}
else {
@@ -2440,7 +2428,7 @@ static int __init mts_io_init(void)
goto error2;
}
- if (!strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG)) {
+ if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) == 0) {
ret = sysfs_create_group(&mts_io_platform_device->dev.kobj,
&mt100eocg_platform_attribute_group);
if (ret) {
@@ -2456,7 +2444,7 @@ static int __init mts_io_init(void)
}
// No sout driver for MT100EOCG
- if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG)) {
+ if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) != 0) {
ret = spi_register_driver(&mts_spi_sout_driver);
if (ret) {
goto error4;
@@ -2502,19 +2490,33 @@ static int __init mts_io_init(void)
gpio_request(pin->pin, pin->name);
if (pin->direction == GPIO_DIR_OUTPUT) {
- at91_set_gpio_output(pin->pin, pin->output_value);
+ at91_set_gpio_output_with_pullup(pin->pin, pin->output_value, pin->use_pullup);
} else {
at91_set_gpio_input(pin->pin, pin->use_pullup);
}
}
+ if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) == 0) {
+ //Set open drain for GPIO11 and GPIO12 using multi drive
+ pin = gpio_pin_by_name("GPIO11");
+ if (pin) {
+ log_info("Set open drain for GPIO11");
+ at91_set_multi_drive(pin->pin, true);
+ }
+ pin = gpio_pin_by_name("GPIO12");
+ if (pin) {
+ log_info("Set open drain for GPIO12");
+ at91_set_multi_drive(pin->pin, true);
+ }
+ }
+
pin = gpio_pin_by_name("ENIO");
if (pin) {
at91_set_gpio_value(pin->pin, 0);
}
- // No blinking for MT100EOCG
- if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG)) {
+ // No blink_callback for MT100EOCG
+ if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) != 0) {
blink_callback(NULL);
}
@@ -2529,11 +2531,11 @@ error7:
error6:
spi_unregister_driver(&mts_spi_dout_driver);
error5:
- if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG)) {
+ if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) != 0) {
spi_unregister_driver(&mts_spi_sout_driver);
}
error4:
- if (!strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG)) {
+ if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) == 0) {
sysfs_remove_group(&mts_io_platform_device->dev.kobj,
&mt100eocg_platform_attribute_group);
}
@@ -2553,7 +2555,7 @@ error1:
static void __exit mts_io_exit(void)
{
- if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG)) {
+ if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) != 0) {
cancel_delayed_work_sync(&blink_work);
}
@@ -2565,7 +2567,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)) {
+ if (strcmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG) == 0) {
sysfs_remove_group(&mts_io_platform_device->dev.kobj,
&mt100eocg_platform_attribute_group);
}