diff options
| author | Jesse Gilles <jgilles@multitech.com> | 2014-05-16 16:43:44 -0500 |
|---|---|---|
| committer | Jesse Gilles <jgilles@multitech.com> | 2014-05-16 16:43:44 -0500 |
| commit | 9cf9a09c665ecfb6425a08e424b01c8cacbdb660 (patch) | |
| tree | 4ca4e88e9e53076086610846e863c505e0d48674 | |
| parent | fb0cddc68ee95d61cd2af4889b18bf3d6ddd01d2 (diff) | |
| download | cdp-io-controller-9cf9a09c665ecfb6425a08e424b01c8cacbdb660.tar.gz cdp-io-controller-9cf9a09c665ecfb6425a08e424b01c8cacbdb660.tar.bz2 cdp-io-controller-9cf9a09c665ecfb6425a08e424b01c8cacbdb660.zip | |
Major changes to split sources up
* moved common peripheral i/o functions to separate source files
* moved device-specific setup to separate source files
* removed LED blink functionality (unused)
* mtcdp, mt100eocg are not supported, but code is included for possible future use
| -rw-r--r-- | io-module/adc.c | 87 | ||||
| -rw-r--r-- | io-module/gpio.c | 83 | ||||
| -rw-r--r-- | io-module/mt100eocg.c | 221 | ||||
| -rw-r--r-- | io-module/mtcdp.c | 310 | ||||
| -rw-r--r-- | io-module/mtr.c | 468 | ||||
| -rw-r--r-- | io-module/mtr2.c | 515 | ||||
| -rw-r--r-- | io-module/mts_io.c | 3140 | ||||
| -rw-r--r-- | io-module/mts_io.h | 19 | ||||
| -rw-r--r-- | io-module/spi.c | 767 | ||||
| -rw-r--r-- | io-module/telit_radio.c | 219 |
10 files changed, 2773 insertions, 3056 deletions
diff --git a/io-module/adc.c b/io-module/adc.c new file mode 100644 index 0000000..bcb3598 --- /dev/null +++ b/io-module/adc.c @@ -0,0 +1,87 @@ + +#define ADC_SHTIME_DEFAULT 0x05 +#define ADC_STARTUP_DEFAULT 0x04 +#define ADC_PRESCALE_DEFAULT 0x3F +#define ADC_MODE_DEFAULT \ + ((ADC_SHTIME_DEFAULT & 0x0F) << 24) | \ + ((ADC_STARTUP_DEFAULT & 0x1F) << 16) | \ + ((ADC_PRESCALE_DEFAULT & 0x3F) << 8) + +#define ADC_CR_OFFSET 0x00 +#define ADC_MR_OFFSET 0x04 +#define ADC_CHER_OFFSET 0x10 +#define ADC_CHDR_OFFSET 0x14 +#define ADC_CHSR_OFFSET 0x18 +#define ADC_SR_OFFSET 0x1C +#define ADC_LDCR_OFFSET 0x20 +#define ADC_IER_OFFSET 0x14 +#define ADC_IDR_OFFSET 0x28 +#define ADC_IMR_OFFSET 0x2C +#define ADC_CDR0_OFFSET 0x30 +#define ADC_CDR1_OFFSET 0x34 +#define ADC_CDR2_OFFSET 0x38 +#define ADC_CDR3_OFFSET 0x3C + +void __iomem *adc_base; +struct clk *adc_clk; + +#define ADC_CONVERT_RESET(base) writel(0x01, (base) + ADC_CR_OFFSET) +#define ADC_CONVERT_START(base) writel(0x02, (base) + ADC_CR_OFFSET) + +static ssize_t mts_attr_show_adc(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int offset; + u32 value; + u32 chan_mask; + + if (!DEVICE_CAPA(id_eeprom.capa, CAPA_ADC)) { + log_debug("ADC not available"); + return -ENODEV; + } + + if (!strcmp(attr->attr.name, "adc0")) { + offset = ADC_CDR0_OFFSET; + chan_mask = 0x01; + } else if (!strcmp(attr->attr.name, "adc1")) { + offset = ADC_CDR1_OFFSET; + chan_mask = 0x02; + } else if (!strcmp(attr->attr.name, "adc2")) { + offset = ADC_CDR2_OFFSET; + chan_mask = 0x04; + } else if (!strcmp(attr->attr.name, "adc3")) { + offset = ADC_CDR3_OFFSET; + chan_mask = 0x08; + } else { + log_notice("adc attr does not exist"); + return -ENOENT; + } + + mutex_lock(&mts_io_mutex); + + // disable all channels and enable the one we want + writel(0x0F, adc_base + ADC_CHDR_OFFSET); + writel(chan_mask, adc_base + ADC_CHER_OFFSET); + + ADC_CONVERT_START(adc_base); + + // wait for conversion to complete (EOC bit set) + value = 0; + while (value != chan_mask) { + value = readl(adc_base + ADC_SR_OFFSET) & chan_mask; + log_debug("ADC_SR EOC [%X]", value); + } + + // read result + value = readl(adc_base + offset); + + mutex_unlock(&mts_io_mutex); + + return sprintf(buf, "%lu\n", (unsigned long) value); +} + +static DEVICE_ATTR_RO_MTS(dev_attr_adc0, "adc0", mts_attr_show_adc); +static DEVICE_ATTR_RO_MTS(dev_attr_adc1, "adc1", mts_attr_show_adc); +static DEVICE_ATTR_RO_MTS(dev_attr_adc2, "adc2", mts_attr_show_adc); +static DEVICE_ATTR_RO_MTS(dev_attr_adc3, "adc3", mts_attr_show_adc); diff --git a/io-module/gpio.c b/io-module/gpio.c new file mode 100644 index 0000000..72c55f6 --- /dev/null +++ b/io-module/gpio.c @@ -0,0 +1,83 @@ + +struct gpio_pin *gpio_pin_by_name(const char *name) { + struct gpio_pin *pin; + + for (pin = gpio_pins; *pin->name; pin++) { + if (!strcmp(pin->name, name)) { + return pin; + } + } + + log_error("pin named %s not found", name); + + return NULL; +} + +struct gpio_pin *gpio_pin_by_attr_name(const char *name) { + struct gpio_pin *pin; + + for (pin = gpio_pins; *pin->name; pin++) { + if (!strcmp(pin->pin.label, name)) { + return pin; + } + } + + log_error("pin with attr name %s not found", name); + + return NULL; +} + +static ssize_t mts_attr_show_gpio_pin(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int value; + struct gpio_pin *pin = gpio_pin_by_attr_name(attr->attr.name); + + if (!pin) { + return -ENODEV; + } + + mutex_lock(&mts_io_mutex); + + value = gpio_get_value(pin->pin.gpio); + + mutex_unlock(&mts_io_mutex); + + if (value < 0) { + return value; + } + + if (pin->active_low) { + value = !value; + } + + return sprintf(buf, "%d\n", value); +} + +static ssize_t mts_attr_store_gpio_pin(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + int value; + struct gpio_pin *pin = gpio_pin_by_attr_name(attr->attr.name); + + if (!pin) { + return -ENODEV; + } + + if (sscanf(buf, "%i", &value) != 1) { + return -EINVAL; + } + + if (pin->active_low) { + value = !value; + } + + mutex_lock(&mts_io_mutex); + + gpio_set_value(pin->pin.gpio, value); + + mutex_unlock(&mts_io_mutex); + + return count; +} diff --git a/io-module/mt100eocg.c b/io-module/mt100eocg.c new file mode 100644 index 0000000..8d2338d --- /dev/null +++ b/io-module/mt100eocg.c @@ -0,0 +1,221 @@ + +static struct gpio_pin gpio_pins_mt100eocg_0_0[] = { + { + .name = "ENIO", + .pin = AT91_PIN_PC15, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + }, + { + .name = "ETH0_ENABLED", + .attr_name = "eth0-enabled", + .pin = AT91_PIN_PB31, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + }, + { + .name = "RADIO_RESET", + .attr_name = "radio-reset", + .pin = AT91_PIN_PB30, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + }, + { + .name = "DEVICE_RESET", + .attr_name = "reset", + .pin = AT91_PIN_PA22, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + .active_low = 1, + }, + { + .name = "LED3", + .attr_name = "led3", + .pin = AT91_PIN_PC9, +#if LED_LS_CONTROLLABLE + .direction = GPIO_DIR_OUTPUT, +#else + .direction = GPIO_DIR_INPUT, +#endif + .output_value = 1, + .use_pullup = 0, + .active_low = 1, + }, + { + .name = "LED2", + .attr_name = "led2", + .pin = AT91_PIN_PA30, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + .active_low = 1, + }, + { + .name = "RSERSRC", + .attr_name = "rsersrc", + .pin = AT91_PIN_PC7, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + .active_low = 1, + }, + { + .name = "TXD1", + .pin = AT91_PIN_PB17, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + }, + { + .name = "DTR1", + .attr_name = "extserial-dtr", + .pin = AT91_PIN_PB18, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + .active_low = 1, + }, + { + .name = "DCD1", + .attr_name = "extserial-dcd", + .pin = AT91_PIN_PB3, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + .active_low = 1, + }, + { + .name = "GPIO11", + .attr_name = "gpio11", + .pin = AT91_PIN_PB19, + .direction = GPIO_DIR_OD, + .output_value = 1, + .use_pullup = 1, + }, + { + .name = "GPIO12", + .attr_name = "gpio12", + .pin = AT91_PIN_PB20, + .direction = GPIO_DIR_OD, + .output_value = 1, + .use_pullup = 1, + }, + { + .name = "ADC0", + .pin = AT91_PIN_PC0, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + }, + { + .name = "ADC1", + .pin = AT91_PIN_PC1, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + }, + { + .name = "ADC2", + .pin = AT91_PIN_PC2, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + }, + { + .name = "ADC3", + .pin = AT91_PIN_PC3, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + }, + { }, +}; + +/* mt100eocg specific attributes */ +static DEVICE_ATTR_MTS(dev_attr_gpo1, "gpo1", + mts_attr_show_dout, mts_attr_store_dout); +static DEVICE_ATTR_MTS(dev_attr_gpo2, "gpo2", + mts_attr_show_dout, mts_attr_store_dout); +static DEVICE_ATTR_MTS(dev_attr_gpo3, "gpo3", + mts_attr_show_dout, mts_attr_store_dout); +static DEVICE_ATTR_MTS(dev_attr_gpo4, "gpo4", + mts_attr_show_dout, mts_attr_store_dout); + + +static DEVICE_ATTR_MTS(dev_attr_led1, "led1", + mts_attr_show_dout, mts_attr_store_dout); +static DEVICE_ATTR_MTS(dev_attr_led2, "led2", + mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); + +#if LED_LS_CONTROLLABLE +static DEVICE_ATTR_MTS(dev_attr_led3, "led3", + mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); +#else +static DEVICE_ATTR_RO_MTS(dev_attr_led3, "led3", mts_attr_show_gpio_pin); +#endif + +static DEVICE_ATTR_MTS(dev_attr_led4, "led4", + mts_attr_show_dout, mts_attr_store_dout); +static DEVICE_ATTR_MTS(dev_attr_led5, "led5", + mts_attr_show_dout, mts_attr_store_dout); +static DEVICE_ATTR_MTS(dev_attr_led6, "led6", + mts_attr_show_dout, mts_attr_store_dout); + +static DEVICE_ATTR_MTS(dev_attr_gpio11, "gpio11", + mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); +static DEVICE_ATTR_MTS(dev_attr_gpio12, "gpio12", + mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); + +static DEVICE_ATTR_MTS(dev_attr_rsersrc, "rsersrc", + mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); + +static struct attribute *mt100eocg_platform_attributes[] = { + &dev_attr_vendor_id.attr, + &dev_attr_product_id.attr, + &dev_attr_device_id.attr, + &dev_attr_hw_version.attr, + &dev_attr_imei.attr, + &dev_attr_eth_mac.attr, + &dev_attr_extserial_dtr.attr, + &dev_attr_extserial_dcd_gpio.attr, + &dev_attr_rsersrc.attr, + &dev_attr_radio_reset.attr, + &dev_attr_eth0_enabled.attr, + &dev_attr_gpio11.attr, + &dev_attr_gpio12.attr, + + &dev_attr_gpo1.attr, + &dev_attr_gpo2.attr, + &dev_attr_gpo3.attr, + &dev_attr_gpo4.attr, + &dev_attr_led1.attr, + &dev_attr_led2.attr, + &dev_attr_led3.attr, + &dev_attr_led4.attr, + &dev_attr_led5.attr, + &dev_attr_led6.attr, + + &dev_attr_gpi5.attr, + &dev_attr_gpi6.attr, + &dev_attr_gpi7.attr, + &dev_attr_gpi8.attr, + &dev_attr_gpi9.attr, + &dev_attr_gpi10.attr, + + &dev_attr_board_temperature.attr, + + &dev_attr_adc0.attr, + &dev_attr_adc1.attr, + &dev_attr_adc2.attr, + &dev_attr_adc3.attr, + + NULL, +}; + +static struct attribute_group mt100eocg_platform_attribute_group = { + .attrs = mt100eocg_platform_attributes +}; diff --git a/io-module/mtcdp.c b/io-module/mtcdp.c new file mode 100644 index 0000000..31551b0 --- /dev/null +++ b/io-module/mtcdp.c @@ -0,0 +1,310 @@ + +#define USBH2_PS_CONTROLLABLE 0 + +static struct gpio_pin gpio_pins_mtcdp_0_0[] = { + { + .name = "ENIO", + .pin = AT91_PIN_PC15, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + }, + { + .name = "ETH0_ENABLED", + .attr_name = "eth0-enabled", + .pin = AT91_PIN_PB31, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + }, + { + .name = "RADIO_RESET", + .attr_name = "radio-reset", + .pin = AT91_PIN_PB30, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + }, + { + .name = "DEVICE_RESET", + .attr_name = "reset", + .pin = AT91_PIN_PA22, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + .active_low = 1, + }, + { + .name = "LS_LED", + .attr_name = "led-ls", + .pin = AT91_PIN_PC9, +#if LED_LS_CONTROLLABLE + .direction = GPIO_DIR_OUTPUT, +#else + .direction = GPIO_DIR_INPUT, +#endif + .output_value = 1, + .use_pullup = 0, + .active_low = 1, + }, + { + .name = "STATUS_LED", + .attr_name = "led-status", + .pin = AT91_PIN_PA30, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + }, + { + .name = "STATUS_LED", + .attr_name = "led-sdk-a", + .pin = AT91_PIN_PA30, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + }, +#endif + { + .name = "RSERSRC", + .attr_name = "rsersrc", + .pin = AT91_PIN_PC7, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + .active_low = 1, + }, + { + .name = "DTR1", + .attr_name = "extserial-dtr", + .pin = AT91_PIN_PC10, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + .active_low = 1, + }, + { }, +}; + +static struct gpio_pin gpio_pins_mtcdp_1_0[] = { + { + .name = "ENIO", + .pin = AT91_PIN_PC15, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + }, + { + .name = "ETH0_ENABLED", + .attr_name = "eth0-enabled", + .pin = AT91_PIN_PB31, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + }, + { + .name = "RADIO_RESET", + .attr_name = "radio-reset", + .pin = AT91_PIN_PB30, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + }, + { + .name = "DEVICE_RESET", + .attr_name = "reset", + .pin = AT91_PIN_PA22, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + .active_low = 1, + }, + { + .name = "LS_LED", + .attr_name = "led-ls", + .pin = AT91_PIN_PC9, +#if LED_LS_CONTROLLABLE + .direction = GPIO_DIR_OUTPUT, +#else + .direction = GPIO_DIR_INPUT, +#endif + .output_value = 1, + .use_pullup = 0, + .active_low = 1, + }, + { + .name = "STATUS_LED", + .attr_name = "led-status", + .pin = AT91_PIN_PA30, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + }, + { + .name = "STATUS_LED", + .attr_name = "led-sdk-a", + .pin = AT91_PIN_PA30, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + }, + { + .name = "RSERSRC", + .attr_name = "rsersrc", + .pin = AT91_PIN_PC7, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + .active_low = 1, + }, + { + .name = "TXD1", + .pin = AT91_PIN_PB17, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + }, + { + .name = "DTR1", + .attr_name = "extserial-dtr", + .pin = AT91_PIN_PB18, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + .active_low = 1, + }, + { + .name = "USBH2_PS_OC", + .attr_name = "usbh2-ps-oc", + .pin = AT91_PIN_PB19, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + .active_low = 1, + }, +#if USBH2_PS_CONTROLLABLE + { + .name = "USBH2_PS_ENABLED", + .attr_name = "usbh2-ps-enabled", + .pin = AT91_PIN_PB20, + .direction = GPIO_DIR_OUTPUT, + .output_value = 0, + .use_pullup = 0, + .active_low = 1, + }, +#endif + { + .name = "NDC_RESET", + .attr_name = "ndc-reset", + .pin = AT91_PIN_PB21, + .direction = GPIO_DIR_OUTPUT, + .output_value = 1, + .use_pullup = 0, + }, + { + .name = "ADC0", + .pin = AT91_PIN_PC0, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + }, + { + .name = "ADC1", + .pin = AT91_PIN_PC1, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + }, + { + .name = "ADC2", + .pin = AT91_PIN_PC2, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + }, + { + .name = "ADC3", + .pin = AT91_PIN_PC3, + .direction = GPIO_DIR_INPUT, + .output_value = 0, + .use_pullup = 0, + }, + { }, +}; + +/* mtcdp specific attributes */ +static DEVICE_ATTR_MTS(dev_attr_led_sdk_a, "led-sdk-a", + mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); +static DEVICE_ATTR_RO_MTS(dev_attr_usbh2_ps_oc, "usbh2-ps-oc", + mts_attr_show_gpio_pin); + +#if USBH2_PS_CONTROLLABLE +static DEVICE_ATTR_MTS(dev_attr_usbh2_ps_enabled, "usbh2-ps-enabled", + mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); +#endif + +static struct attribute *mtcdp_platform_attributes[] = { + &dev_attr_vendor_id.attr, + &dev_attr_product_id.attr, + &dev_attr_device_id.attr, + &dev_attr_hw_version.attr, + &dev_attr_imei.attr, + &dev_attr_eth_mac.attr, + &dev_attr_reset.attr, + &dev_attr_reset_monitor.attr, + &dev_attr_radio_reset.attr, + &dev_attr_ndc_reset.attr, + &dev_attr_eth0_enabled.attr, + &dev_attr_extserial_dtr.attr, + &dev_attr_led_ls.attr, + &dev_attr_led_status.attr, + &dev_attr_led_sdk_a.attr, + &dev_attr_usbh2_ps_oc.attr, +#if USBH2_PS_CONTROLLABLE + &dev_attr_usbh2_ps_enabled.attr, +#endif + + &dev_attr_extserial_dcd.attr, + &dev_attr_extserial_ri.attr, + &dev_attr_extserial_dsr.attr, + &dev_attr_led_cd.attr, + &dev_attr_led_sdk_b.attr, + &dev_attr_led_sig1.attr, + &dev_attr_led_sdk_c.attr, + &dev_attr_led_sig2.attr, + &dev_attr_led_sdk_d.attr, + &dev_attr_led_sig3.attr, + &dev_attr_led_sdk_e.attr, + &dev_attr_led_dtr.attr, + &dev_attr_led_sdk_f.attr, + + &dev_attr_dout0.attr, + &dev_attr_dout1.attr, + &dev_attr_dout2.attr, + &dev_attr_dout3.attr, + &dev_attr_dout4.attr, + &dev_attr_dout5.attr, + &dev_attr_dout6.attr, + &dev_attr_dout7.attr, + + &dev_attr_din0.attr, + &dev_attr_din1.attr, + &dev_attr_din2.attr, + &dev_attr_din3.attr, + &dev_attr_din4.attr, + &dev_attr_din5.attr, + &dev_attr_din6.attr, + &dev_attr_din7.attr, + + &dev_attr_board_temperature.attr, + + &dev_attr_adc0.attr, + &dev_attr_adc1.attr, + &dev_attr_adc2.attr, + &dev_attr_adc3.attr, + + NULL, +}; + +static struct attribute_group mtcdp_platform_attribute_group = { + .attrs = mtcdp_platform_attributes +}; diff --git a/io-module/mtr.c b/io-module/mtr.c new file mode 100644 index 0000000..cef1560 --- /dev/null +++ b/io-module/mtr.c @@ -0,0 +1,468 @@ + +static struct gpio_pin gpio_pins_mtr_0_0[] = { + { + .name = "NETH_RST", + .pin = { + .gpio = AT91_PIN_PC6, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "eth0-enabled", + }, + }, + { + .name = "PWRMON", + .pin = { + .gpio = AT91_PIN_PA23, + .flags = GPIOF_IN, + .label = "radio-power", + }, + }, + { + .name = "3G_RST", + .pin = { + .gpio = AT91_PIN_PA22, + .flags = GPIOF_OPEN_DRAIN | GPIOF_INIT_HIGH, + .label = "radio-reset", + }, + }, + { + .name = "3G_ONOFF", + .pin = { + .gpio = AT91_PIN_PA21, + .flags = GPIOF_OPEN_DRAIN | GPIOF_INIT_HIGH, + .label = "radio-enabled", + }, + }, + { + .name = "DEVICE_RESET", + .pin = { + .gpio = AT91_PIN_PC4, + .flags = GPIOF_IN, + .label = "reset", + }, + .active_low = 1, + }, + { + .name = "LS_LED", + .pin = { + .gpio = AT91_PIN_PC16, +#if LED_LS_CONTROLLABLE + .flags = GPIOF_OUT_INIT_HIGH, +#else + .flags = GPIOF_IN, +#endif + .label = "led-ls", + }, + .active_low = 1, + }, + { + .name = "STATUS_LED", + .pin = { + .gpio = AT91_PIN_PC21, + .flags = GPIOF_OUT_INIT_LOW, + .label = "led-status", + }, + .active_low = 1, + }, + { + .name = "STATUS_LED", + .pin = { + .gpio = AT91_PIN_PC21, + .flags = GPIOF_OUT_INIT_LOW, + .label = "led-a", + }, + .active_low = 1, + }, + { + .name = "LED3", + .pin = { + .gpio = AT91_PIN_PC15, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-wifi", + }, + .active_low = 1, + }, + { + .name = "LED3", + .pin = { + .gpio = AT91_PIN_PC15, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-b", + }, + .active_low = 1, + }, + { + .name = "LED4", + .pin = { + .gpio = AT91_PIN_PC20, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-cd", + }, + .active_low = 1, + }, + { + .name = "LED4", + .pin = { + .gpio = AT91_PIN_PC20, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-c", + }, + .active_low = 1, + }, + { + .name = "LED6", + .pin = { + .gpio = AT91_PIN_PC19, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-sig1", + }, + .active_low = 1, + }, + { + .name = "LED6", + .pin = { + .gpio = AT91_PIN_PC19, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-d", + }, + .active_low = 1, + }, + { + .name = "LED7", + .pin = { + .gpio = AT91_PIN_PC18, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-sig2", + }, + .active_low = 1, + }, + { + .name = "LED7", + .pin = { + .gpio = AT91_PIN_PC18, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-e", + }, + .active_low = 1, + }, + { + .name = "LED8", + .pin = { + .gpio = AT91_PIN_PC17, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-sig3", + }, + .active_low = 1, + }, + { + .name = "LED8", + .pin = { + .gpio = AT91_PIN_PC17, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-f", + }, + .active_low = 1, + }, + { + .name = "RI_B", + .pin = { + .gpio = AT91_PIN_PC25, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "extserial-ri", + }, + .active_low = 1, + }, + { + .name = "DTR_B", + .pin = { + .gpio = AT91_PIN_PC26, + .flags = GPIOF_IN, + .label = "extserial-dtr", + }, + .active_low = 1, + }, + { + .name = "DSR_B", + .pin = { + .gpio = AT91_PIN_PC27, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "extserial-dsr", + }, + .active_low = 1, + }, + { + .name = "DCD_B", + .pin = { + .gpio = AT91_PIN_PC28, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "extserial-dcd", + }, + .active_low = 1, + }, + { + .name = "BT_EN", + .pin = { + .gpio = AT91_PIN_PA28, + .flags = GPIOF_OUT_INIT_LOW, + .label = "bt-enabled", + }, + }, + { + .name = "WLAN_EN", + .pin = { + .gpio = AT91_PIN_PA27, + .flags = GPIOF_OUT_INIT_LOW, + .label = "wlan-enabled", + }, + }, + { }, +}; + +static struct gpio_pin gpio_pins_mtr_0_1[] = { + { + .name = "NETH_RST", + .pin = { + .gpio = AT91_PIN_PC6, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "eth0-enabled", + }, + }, + { + .name = "PWRMON", + .pin = { + .gpio = AT91_PIN_PA23, + .flags = GPIOF_IN, + .label = "radio-power", + }, + }, + { + .name = "3G_RST", + .pin = { + .gpio = AT91_PIN_PA22, + .flags = GPIOF_OUT_INIT_HIGH | GPIOF_PULLUP, + .label = "radio-reset", + }, + }, + { + .name = "3G_ONOFF", + .pin = { + .gpio = AT91_PIN_PA21, + .flags = GPIOF_OUT_INIT_HIGH | GPIOF_PULLUP, + .label = "radio-enabled", + }, + }, + { + .name = "DEVICE_RESET", + .pin = { + .gpio = AT91_PIN_PC4, + .flags = GPIOF_IN, + .label = "reset", + }, + .active_low = 1, + }, + { + .name = "LS_LED", + .pin = { + .gpio = AT91_PIN_PC16, +#if LED_LS_CONTROLLABLE + .flags = GPIOF_OUT_INIT_HIGH, +#else + .flags = GPIOF_IN, +#endif + .label = "led-ls", + }, + .active_low = 1, + }, + { + .name = "STATUS_LED", + .pin = { + .gpio = AT91_PIN_PC21, + .flags = GPIOF_OUT_INIT_LOW, + .label = "led-status", + }, + .active_low = 1, + }, + { + .name = "LED3", + .pin = { + .gpio = AT91_PIN_PC15, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-wifi", + }, + .active_low = 1, + }, + { + .name = "LED3", + .pin = { + .gpio = AT91_PIN_PC15, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-b", + }, + .active_low = 1, + }, + { + .name = "LED4", + .pin = { + .gpio = AT91_PIN_PC20, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-cd", + }, + .active_low = 1, + }, + { + .name = "LED4", + .pin = { + .gpio = AT91_PIN_PC20, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-c", + }, + .active_low = 1, + }, + { + .name = "LED6", + .pin = { + .gpio = AT91_PIN_PC19, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-sig1", + }, + .active_low = 1, + }, + { + .name = "LED6", + .pin = { + .gpio = AT91_PIN_PC19, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-d", + }, + .active_low = 1, + }, + { + .name = "LED7", + .pin = { + .gpio = AT91_PIN_PC18, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-sig2", + }, + .active_low = 1, + }, + { + .name = "LED7", + .pin = { + .gpio = AT91_PIN_PC18, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-e", + }, + .active_low = 1, + }, + { + .name = "LED8", + .pin = { + .gpio = AT91_PIN_PC17, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-sig3", + }, + .active_low = 1, + }, + { + .name = "LED8", + .pin = { + .gpio = AT91_PIN_PC17, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-f", + }, + .active_low = 1, + }, + { + .name = "RI_B", + .pin = { + .gpio = AT91_PIN_PC25, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "extserial-ri", + }, + .active_low = 1, + }, + { + .name = "DTR_B", + .pin = { + .gpio = AT91_PIN_PC26, + .flags = GPIOF_IN, + .label = "extserial-dtr", + }, + .active_low = 1, + }, + { + .name = "DSR_B", + .pin = { + .gpio = AT91_PIN_PC27, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "extserial-dsr", + }, + .active_low = 1, + }, + { + .name = "DCD_B", + .pin = { + .gpio = AT91_PIN_PC28, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "extserial-dcd", + }, + .active_low = 1, + }, + { + .name = "BT_EN", + .pin = { + .gpio = AT91_PIN_PA28, + .flags = GPIOF_OUT_INIT_LOW, + .label = "bt-enabled", + }, + }, + { + .name = "WLAN_EN", + .pin = { + .gpio = AT91_PIN_PA27, + .flags = GPIOF_OUT_INIT_LOW, + .label = "wlan-enabled", + }, + }, + { }, +}; + +static struct attribute *mtr_platform_attributes[] = { + &dev_attr_vendor_id.attr, + &dev_attr_product_id.attr, + &dev_attr_device_id.attr, + &dev_attr_hw_version.attr, + &dev_attr_imei.attr, + &dev_attr_eth_mac.attr, + &dev_attr_wifi_mac.attr, + &dev_attr_reset.attr, + &dev_attr_reset_monitor.attr, + &dev_attr_radio_power_telit.attr, + &dev_attr_radio_reset_telit.attr, + &dev_attr_extserial_ri_gpio.attr, + &dev_attr_extserial_dtr.attr, + &dev_attr_extserial_dsr_gpio.attr, + &dev_attr_extserial_dcd_gpio.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_gpio.attr, + + &dev_attr_led_a_gpio.attr, + &dev_attr_led_b_gpio.attr, + &dev_attr_led_c_gpio.attr, + &dev_attr_led_d_gpio.attr, + &dev_attr_led_e_gpio.attr, + &dev_attr_led_f_gpio.attr, + + NULL, +}; + +static struct attribute_group mtr_platform_attribute_group = { + .attrs = mtr_platform_attributes +}; diff --git a/io-module/mtr2.c b/io-module/mtr2.c new file mode 100644 index 0000000..2efc85d --- /dev/null +++ b/io-module/mtr2.c @@ -0,0 +1,515 @@ + +static struct gpio_pin gpio_pins_mtr2_0_0[] = { + { + .name = "NETH_RST", + .pin = { + .gpio = AT91_PIN_PC6, + .flags = GPIOF_OPEN_DRAIN | GPIOF_INIT_HIGH, + .label = "eth-switch-enabled", + }, + }, + { + .name = "RADIO_RESET", + .pin = { + .gpio = AT91_PIN_PC5, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "radio-reset", + }, + }, + { + .name = "RADIO_RESET", + .pin = { + .gpio = AT91_PIN_PC5, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "radio-power", + }, + }, + { + .name = "DEVICE_RESET", + .pin = { + .gpio = AT91_PIN_PC4, + .flags = GPIOF_IN, + .label = "reset", + }, + .active_low = 1, + }, + { + .name = "LS_LED", + .pin = { + .gpio = AT91_PIN_PA14, +#if LED_LS_CONTROLLABLE + .flags = GPIOF_OUT_INIT_HIGH, +#else + .flags = GPIOF_IN, +#endif + .label = "led-ls", + }, + .active_low = 1, + }, + { + .name = "STATUS_LED", + .pin = { + .gpio = AT91_PIN_PA24, + .flags = GPIOF_OUT_INIT_LOW, + .label = "led-status", + }, + .active_low = 1, + }, + { + .name = "STATUS_LED", + .pin = { + .gpio = AT91_PIN_PA24, + .flags = GPIOF_OUT_INIT_LOW, + .label = "led-a", + }, + .active_low = 1, + }, + { + .name = "LED7", + .pin = { + .gpio = AT91_PIN_PA25, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-cd", + }, + .active_low = 1, + }, |
