sensor: sx9500: Convert to DTS
Convert sx9500 sensor driver and sample app to utilize device tree. Introduce a dts board overlay on the frdm_k64f board to ensure we at least have a single platform in which the sample gets built. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
c7fae66952
commit
03c7cb4f46
|
@ -11,23 +11,6 @@ menuconfig SX9500
|
|||
|
||||
if SX9500
|
||||
|
||||
config SX9500_DEV_NAME
|
||||
string "SX9500 device name"
|
||||
default "SX9500"
|
||||
|
||||
config SX9500_I2C_ADDR
|
||||
hex "SX9500 I2C slave address"
|
||||
default 0x2B
|
||||
help
|
||||
Specify the I2C slave address for the SX9500.
|
||||
|
||||
config SX9500_I2C_DEV_NAME
|
||||
string "I2C master where SX9500 is connected"
|
||||
default "I2C_0"
|
||||
help
|
||||
Specify the device name of the I2C master device to which SX9500 is
|
||||
connected.
|
||||
|
||||
config SX9500_PROX_CHANNEL
|
||||
int "Proximity channel to use"
|
||||
default 3
|
||||
|
@ -57,19 +40,6 @@ endchoice
|
|||
config SX9500_TRIGGER
|
||||
bool
|
||||
|
||||
config SX9500_GPIO_CONTROLLER
|
||||
string "GPIO controller for SX9500 interrupt"
|
||||
depends on SX9500_TRIGGER
|
||||
default "GPIO_0"
|
||||
help
|
||||
Specify the device name of the GPIO controller the SX9500 interrupt
|
||||
is connected to.
|
||||
|
||||
config SX9500_GPIO_PIN
|
||||
int "GPIO pin for SX9500 interrupt"
|
||||
depends on SX9500_TRIGGER
|
||||
default 3
|
||||
|
||||
config SX9500_THREAD_STACK_SIZE
|
||||
int "Sensor delayed work thread stack size"
|
||||
depends on SX9500_TRIGGER_OWN_THREAD
|
||||
|
|
|
@ -110,14 +110,14 @@ int sx9500_init(struct device *dev)
|
|||
{
|
||||
struct sx9500_data *data = dev->driver_data;
|
||||
|
||||
data->i2c_master = device_get_binding(CONFIG_SX9500_I2C_DEV_NAME);
|
||||
data->i2c_master = device_get_binding(DT_INST_0_SEMTECH_SX9500_BUS_NAME);
|
||||
if (!data->i2c_master) {
|
||||
LOG_DBG("sx9500: i2c master not found: %s",
|
||||
CONFIG_SX9500_I2C_DEV_NAME);
|
||||
DT_INST_0_SEMTECH_SX9500_BUS_NAME);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
data->i2c_slave_addr = CONFIG_SX9500_I2C_ADDR;
|
||||
data->i2c_slave_addr = DT_INST_0_SEMTECH_SX9500_BASE_ADDRESS;
|
||||
|
||||
if (sx9500_init_chip(dev) < 0) {
|
||||
LOG_DBG("sx9500: failed to initialize chip");
|
||||
|
@ -134,6 +134,6 @@ int sx9500_init(struct device *dev)
|
|||
|
||||
struct sx9500_data sx9500_data;
|
||||
|
||||
DEVICE_AND_API_INIT(sx9500, CONFIG_SX9500_DEV_NAME, sx9500_init, &sx9500_data,
|
||||
DEVICE_AND_API_INIT(sx9500, DT_INST_0_SEMTECH_SX9500_LABEL, sx9500_init, &sx9500_data,
|
||||
NULL, POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY,
|
||||
&sx9500_api_funcs);
|
||||
|
|
|
@ -157,23 +157,23 @@ int sx9500_setup_interrupt(struct device *dev)
|
|||
data->dev = dev;
|
||||
#endif
|
||||
|
||||
gpio = device_get_binding(CONFIG_SX9500_GPIO_CONTROLLER);
|
||||
gpio = device_get_binding(DT_INST_0_SEMTECH_SX9500_INT_GPIOS_CONTROLLER);
|
||||
if (!gpio) {
|
||||
LOG_DBG("sx9500: gpio controller %s not found",
|
||||
CONFIG_SX9500_GPIO_CONTROLLER);
|
||||
DT_INST_0_SEMTECH_SX9500_INT_GPIOS_CONTROLLER);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
gpio_pin_configure(gpio, CONFIG_SX9500_GPIO_PIN,
|
||||
gpio_pin_configure(gpio, DT_INST_0_SEMTECH_SX9500_INT_GPIOS_PIN,
|
||||
GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
|
||||
GPIO_INT_ACTIVE_LOW | GPIO_INT_DEBOUNCE);
|
||||
|
||||
gpio_init_callback(&data->gpio_cb,
|
||||
sx9500_gpio_cb,
|
||||
BIT(CONFIG_SX9500_GPIO_PIN));
|
||||
BIT(DT_INST_0_SEMTECH_SX9500_INT_GPIOS_PIN));
|
||||
|
||||
gpio_add_callback(gpio, &data->gpio_cb);
|
||||
gpio_pin_enable_callback(gpio, CONFIG_SX9500_GPIO_PIN);
|
||||
gpio_pin_enable_callback(gpio, DT_INST_0_SEMTECH_SX9500_INT_GPIOS_PIN);
|
||||
|
||||
#ifdef CONFIG_SX9500_TRIGGER_OWN_THREAD
|
||||
k_thread_create(&sx9500_thread, sx9500_thread_stack,
|
||||
|
|
17
dts/bindings/sensor/semtech,sx9500.yaml
Normal file
17
dts/bindings/sensor/semtech,sx9500.yaml
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Copyright (c) 2019, Linaro Limited
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
title: Semtech SX9500 capacitive proximity/button
|
||||
|
||||
description: |
|
||||
Semtech SX9500 capacitive proximity/button. See more info at
|
||||
https://www.semtech.com/products/smart-sensing/touch-proximity-devices/sx9500
|
||||
|
||||
compatible: "semtech,sx9500"
|
||||
|
||||
include: i2c-device.yaml
|
||||
|
||||
properties:
|
||||
int-gpios:
|
||||
type: phandle-array
|
||||
required: false
|
14
samples/sensor/sx9500/boards/frdm_k64f.overlay
Normal file
14
samples/sensor/sx9500/boards/frdm_k64f.overlay
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Linaro Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
&i2c0 {
|
||||
sx9500@28 {
|
||||
compatible = "semtech,sx9500";
|
||||
reg = <0x28>;
|
||||
int-gpios = <&gpioc 6 0>;
|
||||
label = "SX9500";
|
||||
};
|
||||
};
|
|
@ -5,3 +5,4 @@ tests:
|
|||
harness: sensor
|
||||
tags: sensors
|
||||
depends_on: i2c gpio
|
||||
filter: dt_compat_enabled("semtech,sx9500")
|
||||
|
|
|
@ -333,6 +333,15 @@
|
|||
#define DT_INST_0_TI_TMP007_INT_GPIOS_PIN 0
|
||||
#endif
|
||||
|
||||
#ifndef DT_INST_0_SEMTECH_SX9500_LABEL
|
||||
#define DT_INST_0_SEMTECH_SX9500_LABEL ""
|
||||
#define DT_INST_0_SEMTECH_SX9500_BASE_ADDRESS 0
|
||||
#define DT_INST_0_SEMTECH_SX9500_BUS_NAME ""
|
||||
#define DT_INST_0_SEMTECH_SX9500_INT_GPIOS_CONTROLLER ""
|
||||
#define DT_INST_0_SEMTECH_SX9500_INT_GPIOS_FLAGS 0
|
||||
#define DT_INST_0_SEMTECH_SX9500_INT_GPIOS_PIN 0
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_HAS_DTS_I2C */
|
||||
|
||||
#ifndef DT_ADXL372_DEV_NAME
|
||||
|
|
Loading…
Reference in a new issue