From 5313d4fb515ddff1c46d2653bee653fd15884ed8 Mon Sep 17 00:00:00 2001 From: "Peter A. Bigot" Date: Tue, 20 Nov 2018 13:07:21 -0600 Subject: [PATCH] drivers: sensor: sht3xd: migrate GPIO from Kconfig to device tree Replace Kconfig ALERT signal GPIO device and pin information with device tree bindings. Signed-off-by: Peter A. Bigot --- drivers/sensor/sht3xd/Kconfig | 16 ---------------- drivers/sensor/sht3xd/sht3xd_trigger.c | 16 ++++++++-------- dts/bindings/sensor/sensirion,sht3xd.yaml | 5 +++++ 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/drivers/sensor/sht3xd/Kconfig b/drivers/sensor/sht3xd/Kconfig index 4aff3bc21b7..c728ab97cc4 100644 --- a/drivers/sensor/sht3xd/Kconfig +++ b/drivers/sensor/sht3xd/Kconfig @@ -38,22 +38,6 @@ endchoice config SHT3XD_TRIGGER bool -config SHT3XD_GPIO_DEV_NAME - string "GPIO device" - default "GPIO_0" - depends on SHT3XD_TRIGGER - help - The device name of the GPIO device to which the SHT3xD interrupt - pins are connected. - -config SHT3XD_GPIO_PIN_NUM - int "Interrupt GPIO pin number" - default 0 - depends on SHT3XD_TRIGGER - help - The number of the GPIO on which the interrupt signal from the - SHT3xD chip will be received. - config SHT3XD_THREAD_PRIORITY int "Thread priority" depends on SHT3XD_TRIGGER_OWN_THREAD diff --git a/drivers/sensor/sht3xd/sht3xd_trigger.c b/drivers/sensor/sht3xd/sht3xd_trigger.c index ccb3e831563..a70169e5a32 100644 --- a/drivers/sensor/sht3xd/sht3xd_trigger.c +++ b/drivers/sensor/sht3xd/sht3xd_trigger.c @@ -90,7 +90,7 @@ static void sht3xd_gpio_callback(struct device *dev, ARG_UNUSED(pins); - gpio_pin_disable_callback(dev, CONFIG_SHT3XD_GPIO_PIN_NUM); + gpio_pin_disable_callback(dev, DT_SHT3XD_GPIO_ALERT_PIN); #if defined(CONFIG_SHT3XD_TRIGGER_OWN_THREAD) k_sem_give(&drv_data->gpio_sem); @@ -108,7 +108,7 @@ static void sht3xd_thread_cb(void *arg) drv_data->handler(dev, &drv_data->trigger); } - gpio_pin_enable_callback(drv_data->gpio, CONFIG_SHT3XD_GPIO_PIN_NUM); + gpio_pin_enable_callback(drv_data->gpio, DT_SHT3XD_GPIO_ALERT_PIN); } #ifdef CONFIG_SHT3XD_TRIGGER_OWN_THREAD @@ -146,10 +146,10 @@ int sht3xd_trigger_set(struct device *dev, return -ENOTSUP; } - gpio_pin_disable_callback(drv_data->gpio, CONFIG_SHT3XD_GPIO_PIN_NUM); + gpio_pin_disable_callback(drv_data->gpio, DT_SHT3XD_GPIO_ALERT_PIN); drv_data->handler = handler; drv_data->trigger = *trig; - gpio_pin_enable_callback(drv_data->gpio, CONFIG_SHT3XD_GPIO_PIN_NUM); + gpio_pin_enable_callback(drv_data->gpio, DT_SHT3XD_GPIO_ALERT_PIN); return 0; } @@ -187,20 +187,20 @@ int sht3xd_init_interrupt(struct device *dev) } /* setup gpio interrupt */ - drv_data->gpio = device_get_binding(CONFIG_SHT3XD_GPIO_DEV_NAME); + drv_data->gpio = device_get_binding(DT_SHT3XD_GPIO_ALERT_DEV_NAME); if (drv_data->gpio == NULL) { LOG_DBG("Failed to get pointer to %s device!", - CONFIG_SHT3XD_GPIO_DEV_NAME); + DT_SHT3XD_GPIO_ALERT_DEV_NAME); return -EINVAL; } - gpio_pin_configure(drv_data->gpio, CONFIG_SHT3XD_GPIO_PIN_NUM, + gpio_pin_configure(drv_data->gpio, DT_SHT3XD_GPIO_ALERT_PIN, GPIO_DIR_IN | GPIO_INT | GPIO_INT_LEVEL | GPIO_INT_ACTIVE_HIGH | GPIO_INT_DEBOUNCE); gpio_init_callback(&drv_data->gpio_cb, sht3xd_gpio_callback, - BIT(CONFIG_SHT3XD_GPIO_PIN_NUM)); + BIT(DT_SHT3XD_GPIO_ALERT_PIN)); if (gpio_add_callback(drv_data->gpio, &drv_data->gpio_cb) < 0) { LOG_DBG("Failed to set gpio callback!"); diff --git a/dts/bindings/sensor/sensirion,sht3xd.yaml b/dts/bindings/sensor/sensirion,sht3xd.yaml index 938b72422a1..0d825ee7ca6 100644 --- a/dts/bindings/sensor/sensirion,sht3xd.yaml +++ b/dts/bindings/sensor/sensirion,sht3xd.yaml @@ -17,5 +17,10 @@ inherits: properties: compatible: constraint: "sensirion,sht3xd" + alert-gpios: + type: compound + category: optional + description: ALERT pin + generation: define, use-prop-name ...