Index: io-module/mts_io.c =================================================================== --- io-module.orig/mts_io.c +++ io-module/mts_io.c @@ -317,17 +317,19 @@ static struct gpio_pin gpio_pins_mt100eo .output_value = 1, .use_pullup = 0, }, + // MTPCIE-H5: Wifi and BT enable pins + // (was TXD1 and DTR1) (PB17 and PB7 are tied together) { - .name = "TXD1", - .pin = AT91_PIN_PB17, - .direction = GPIO_DIR_INPUT, + .name = "WLAN_EN", + .pin = AT91_PIN_PB7, + .direction = GPIO_DIR_OUTPUT, .output_value = 0, .use_pullup = 0, }, { - .name = "DTR1", + .name = "BT_EN", .pin = AT91_PIN_PB18, - .direction = GPIO_DIR_INPUT, + .direction = GPIO_DIR_OUTPUT, .output_value = 0, .use_pullup = 0, }, @@ -338,6 +340,8 @@ static struct gpio_pin gpio_pins_mt100eo .output_value = 1, .use_pullup = 0, }, + // PCIE-H5 GPIO11 used for WLAN_IRQ +#if 0 { .name = "GPIO11", .pin = AT91_PIN_PB19, @@ -345,6 +349,7 @@ static struct gpio_pin gpio_pins_mt100eo .output_value = 1, .use_pullup = 1, }, +#endif { .name = "GPIO12", .pin = AT91_PIN_PB20, @@ -400,6 +405,13 @@ static int mts_id_eeprom_load(void) mts_product_id = MTCDP_E1_DK_1_0; } + // PCIE-H5 hard-coded to EOCG + gpio_pins = gpio_pins_mt100eocg_0_0; + mts_product_id = MT100EOCG_0_0; + DEVICE_CAPA_SET(id_eeprom.capa, CAPA_GPS); + DEVICE_CAPA_SET(id_eeprom.capa, CAPA_DIN); + DEVICE_CAPA_SET(id_eeprom.capa, CAPA_DOUT); + 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); @@ -1976,6 +1988,100 @@ static ssize_t mts_attr_store_cd(struct return count; } +static ssize_t mts_attr_show_bt_enabled(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int value; + struct gpio_pin *pin = gpio_pin_by_name("BT_EN"); + + if (!pin) { + return -ENODEV; + } + + mutex_lock(&mts_io_mutex); + + value = at91_get_gpio_value(pin->pin); + + mutex_unlock(&mts_io_mutex); + + if (value < 0) { + return value; + } + + return sprintf(buf, "%d\n", value); +} + +static ssize_t mts_attr_store_bt_enabled(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + int value; + int err; + struct gpio_pin *pin = gpio_pin_by_name("BT_EN"); + + if (!pin) { + return -ENODEV; + } + + if (sscanf(buf, "%i", &value) != 1) { + return -EINVAL; + } + + mutex_lock(&mts_io_mutex); + + err = at91_set_gpio_value(pin->pin, value); + + mutex_unlock(&mts_io_mutex); + + return count; +} + +static ssize_t mts_attr_show_wlan_enabled(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int value; + struct gpio_pin *pin = gpio_pin_by_name("WLAN_EN"); + + if (!pin) { + return -ENODEV; + } + + mutex_lock(&mts_io_mutex); + + value = at91_get_gpio_value(pin->pin); + + mutex_unlock(&mts_io_mutex); + + if (value < 0) { + return value; + } + + return sprintf(buf, "%d\n", value); +} + +static ssize_t mts_attr_store_wlan_enabled(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + int value; + int err; + struct gpio_pin *pin = gpio_pin_by_name("WLAN_EN"); + + if (!pin) { + return -ENODEV; + } + + if (sscanf(buf, "%i", &value) != 1) { + return -EINVAL; + } + + mutex_lock(&mts_io_mutex); + + err = at91_set_gpio_value(pin->pin, value); + + mutex_unlock(&mts_io_mutex); + + return count; +} + static struct device_attribute dev_attr_gpo1 = { .attr = { @@ -2137,6 +2243,24 @@ static struct device_attribute dev_attr_ .store = mts_attr_store_gpio12, }; +static struct device_attribute dev_attr_bt_enabled = { + .attr = { + .name = "bt-enabled", + .mode = MTS_ATTR_MODE_RW, + }, + .show = mts_attr_show_bt_enabled, + .store = mts_attr_store_bt_enabled, +}; + +static struct device_attribute dev_attr_wlan_enabled = { + .attr = { + .name = "wlan-enabled", + .mode = MTS_ATTR_MODE_RW, + }, + .show = mts_attr_show_wlan_enabled, + .store = mts_attr_store_wlan_enabled, +}; + static struct device_attribute dev_attr_rsersrc = { .attr = { .name = "rsersrc", @@ -2157,13 +2281,13 @@ static struct device_attribute dev_attr_ static struct attribute *mt100eocg_platform_attributes[] = { - &dev_attr_extserial_dtr.attr, &dev_attr_extserial_cd.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_bt_enabled.attr, + &dev_attr_wlan_enabled.attr, &dev_attr_gpo1.attr, &dev_attr_gpo2.attr, @@ -2323,7 +2447,7 @@ static int __devinit mts_spi_dout_probe( return tmp; } - spi_dout_value = 0x00; + spi_dout_value = 0xFF; // 0x00; spi_writen(spi, &spi_dout_value, 1); spi_dout_dev = spi; @@ -2521,11 +2645,14 @@ static int __init mts_io_init(void) if ( mts_product_id == MT100EOCG_0_0 ) { //Set open drain for GPIO11 and GPIO12 using multi drive + // PCIE-H5 GPIO11 used for WLAN_IRQ +#if 0 pin = gpio_pin_by_name("GPIO11"); if (pin) { log_info("Set open drain for GPIO11"); at91_set_multi_drive(pin->pin, true); } +#endif pin = gpio_pin_by_name("GPIO12"); if (pin) { log_info("Set open drain for GPIO12");