static int msp_gpio_in(struct gpio_chip *chip, unsigned offset) { switch (MSP_GPIO_REG(offset)) { case DM355EVM_MSP_SWITCH1: case DM355EVM_MSP_SWITCH2: case DM355EVM_MSP_SDMMC: return 0; default: return -EINVAL; } }
static int msp_gpio_get(struct gpio_chip *chip, unsigned offset) { int reg, status; reg = MSP_GPIO_REG(offset); status = dm355evm_msp_read(reg); if (status < 0) return status; if (reg == DM355EVM_MSP_LED) msp_led_cache = status; return status & MSP_GPIO_MASK(offset); }
static int msp_gpio_out(struct gpio_chip *chip, unsigned offset, int value) { int mask, bits; if (MSP_GPIO_REG(offset) != DM355EVM_MSP_LED) return -EINVAL; mask = MSP_GPIO_MASK(offset); bits = msp_led_cache; bits &= ~mask; if (value) bits |= mask; msp_led_cache = bits; return dm355evm_msp_write(bits, DM355EVM_MSP_LED); }
static int msp_gpio_out(struct gpio_chip *chip, unsigned offset, int value) { int mask, bits; /* NOTE: there are some other signals that could be * packaged as output GPIOs, but they aren't as useful * as the LEDs ... so for now we don't. */ if (MSP_GPIO_REG(offset) != DM355EVM_MSP_LED) return -EINVAL; mask = MSP_GPIO_MASK(offset); bits = msp_led_cache; bits &= ~mask; if (value) bits |= mask; msp_led_cache = bits; return dm355evm_msp_write(bits, DM355EVM_MSP_LED); }