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 <pab@pabigot.com>
This commit is contained in:
Peter A. Bigot 2018-11-20 13:07:21 -06:00 committed by Anas Nashif
parent b7dc23984d
commit 5313d4fb51
3 changed files with 13 additions and 24 deletions

View File

@ -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

View File

@ -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!");

View File

@ -17,5 +17,10 @@ inherits:
properties:
compatible:
constraint: "sensirion,sht3xd"
alert-gpios:
type: compound
category: optional
description: ALERT pin
generation: define, use-prop-name
...