drivers: gpio_ht16k33: update to use new GPIO API

Implement the new GPIO driver APIs for the HT16K33 and update the
driver to use the new GPIO flags.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
This commit is contained in:
Henrik Brix Andersen 2019-10-06 20:15:34 +02:00 committed by Carles Cufí
commit c7382c80a0
2 changed files with 77 additions and 4 deletions

View file

@ -43,8 +43,9 @@ static int gpio_ht16k33_cfg(struct device *dev, int access_op,
ARG_UNUSED(pin); ARG_UNUSED(pin);
/* Keyscan is input-only */ /* Keyscan is input-only */
if ((flags & GPIO_DIR_MASK) != GPIO_DIR_IN) { if (((flags & (GPIO_INPUT | GPIO_OUTPUT)) == GPIO_DISCONNECTED)
return -EINVAL; || ((flags & GPIO_OUTPUT) != 0)) {
return -ENOTSUP;
} }
return 0; return 0;
@ -74,6 +75,72 @@ static int gpio_ht16k33_read(struct device *dev, int access_op,
return -ENOTSUP; return -ENOTSUP;
} }
static int gpio_ht16k33_port_get_raw(struct device *port,
gpio_port_value_t *value)
{
ARG_UNUSED(port);
ARG_UNUSED(value);
/* Keyscan only supports interrupt mode */
return -ENOTSUP;
}
static int gpio_ht16k33_port_set_masked_raw(struct device *port,
gpio_port_pins_t mask,
gpio_port_value_t value)
{
ARG_UNUSED(port);
ARG_UNUSED(mask);
ARG_UNUSED(value);
/* Keyscan is input-only */
return -ENOTSUP;
}
static int gpio_ht16k33_port_set_bits_raw(struct device *port,
gpio_port_pins_t pins)
{
ARG_UNUSED(port);
ARG_UNUSED(pins);
/* Keyscan is input-only */
return -ENOTSUP;
}
static int gpio_ht16k33_port_clear_bits_raw(struct device *port,
gpio_port_pins_t pins)
{
ARG_UNUSED(port);
ARG_UNUSED(pins);
/* Keyscan is input-only */
return -ENOTSUP;
}
static int gpio_ht16k33_port_toggle_bits(struct device *port,
gpio_port_pins_t pins)
{
ARG_UNUSED(port);
ARG_UNUSED(pins);
/* Keyscan is input-only */
return -ENOTSUP;
}
static int gpio_ht16k33_pin_interrupt_configure(struct device *port,
unsigned int pin,
enum gpio_int_mode int_mode,
enum gpio_int_trig int_trig)
{
ARG_UNUSED(port);
ARG_UNUSED(pin);
ARG_UNUSED(int_mode);
ARG_UNUSED(int_trig);
/* Interrupts are always enabled */
return 0;
}
void ht16k33_process_keyscan_row_data(struct device *dev, void ht16k33_process_keyscan_row_data(struct device *dev,
u32_t keys) u32_t keys)
{ {
@ -141,6 +208,12 @@ static const struct gpio_driver_api gpio_ht16k33_api = {
.config = gpio_ht16k33_cfg, .config = gpio_ht16k33_cfg,
.write = gpio_ht16k33_write, .write = gpio_ht16k33_write,
.read = gpio_ht16k33_read, .read = gpio_ht16k33_read,
.port_get_raw = gpio_ht16k33_port_get_raw,
.port_set_masked_raw = gpio_ht16k33_port_set_masked_raw,
.port_set_bits_raw = gpio_ht16k33_port_set_bits_raw,
.port_clear_bits_raw = gpio_ht16k33_port_clear_bits_raw,
.port_toggle_bits = gpio_ht16k33_port_toggle_bits,
.pin_interrupt_configure = gpio_ht16k33_pin_interrupt_configure,
.manage_callback = gpio_ht16k33_manage_callback, .manage_callback = gpio_ht16k33_manage_callback,
.enable_callback = gpio_ht16k33_enable_callback, .enable_callback = gpio_ht16k33_enable_callback,
.disable_callback = gpio_ht16k33_disable_callback, .disable_callback = gpio_ht16k33_disable_callback,

View file

@ -12,7 +12,7 @@
reg = <0x70>; reg = <0x70>;
label = "HT16K33"; label = "HT16K33";
/* Uncomment to use IRQ instead of polling: */ /* Uncomment to use IRQ instead of polling: */
/* irq-gpios = <&gpio1 8 (GPIO_PUD_PULL_UP | GPIO_INT_ACTIVE_LOW)>; */ /* irq-gpios = <&gpio1 8 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; */
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;