zephyr/drivers/sensor/fxas21002/Kconfig
Kumar Gala df81fef944 drivers: sensor: Convert Kconfig bus 'depends on' to 'select'
This change in pattern is meant to address a misconfiguration issue
that can occur for sensors that support being on multiple busses
like I2C & SPI.

For example, you can have a configuration in which such a sensor is
on the I2C bus in the devicetree and the sensor is enabled.  However
the application configuration enables CONFIG_SPI=y and CONFIG_I2C=n
and this will cause the sensor driver to be built by default, however
since we don't have the I2C bus enabled the driver will not compile
correctly.

Previously we had been adding to board Kconfig.defconfig something
like:

	config I2C
		default y if SENSOR

This pattern doesn't scale well and may differ from what an application
specific need/use is.

So instead move to a pattern in which we leave the default enablement
up to the devicetree "status" property for the sensor.  We then have
the Kconfig move from 'depends on <BUS>' to 'select <BUS>' and in
the case of drivers that support multiple busses we have the Kconfig
be: 'select <BUS> if $(dt_compat_on_bus,$(<DT_COMPAT>),<BUS>) for
each bus type the sensor supports.

This removes the need to add Kconfig logic to each board and enables
the bus subsystem and bus controller driver if the sensor requires
it by default in the build system.

Fixes: #48518

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-08-08 06:58:18 +01:00

92 lines
1.8 KiB
Plaintext

# FXAS21002 3-axis gyroscope
# Copyright (c) 2017, NXP
# SPDX-License-Identifier: Apache-2.0
menuconfig FXAS21002
bool "FXAS21002 gyroscope driver"
default y
depends on DT_HAS_NXP_FXAS21002_ENABLED
select I2C
help
Enable driver for the FXAS21002 gyroscope
if FXAS21002
config FXAS21002_WHOAMI
hex "WHOAMI value"
range 0x00 0xff
default 0xd7
help
The datasheet defines the value of the WHOAMI register, but some
pre-production devices can have a different value. It is unlikely you
should need to change this configuration option from the default.
config FXAS21002_RANGE
int "Full scale range"
range 0 3
default 0
help
Selects the full scale range
0: +/-2000 dps (62.5 mdps/LSB)
1: +/-1000 dps (31.25 mdps/LSB)
2: +/-500 dps (15.625 mdps/LSB)
3: +/-250 dps (7.8125 mdps/LSB)
config FXAS21002_DR
int "Output data rate"
range 0 7
default 3
help
Selects the output data rate
0: 800 Hz
1: 400 Hz
2: 200 Hz
3: 100 Hz
4: 50 Hz
5: 25 Hz
6: 12.5 Hz
7: 12.5 Hz
choice
prompt "Trigger mode"
default FXAS21002_TRIGGER_NONE
config FXAS21002_TRIGGER_NONE
bool "No trigger"
config FXAS21002_TRIGGER_GLOBAL_THREAD
bool "Use global thread"
select FXAS21002_TRIGGER
config FXAS21002_TRIGGER_OWN_THREAD
bool "Use own thread"
select FXAS21002_TRIGGER
endchoice
config FXAS21002_TRIGGER
bool
if FXAS21002_TRIGGER
config FXAS21002_DRDY_INT1
bool "Data ready interrupt to INT1 pin"
help
Say Y to route data ready interrupt to INT1 pin. Say N to route to
INT2 pin.
config FXAS21002_THREAD_PRIORITY
int "Own thread priority"
depends on FXAS21002_TRIGGER_OWN_THREAD
default 10
config FXAS21002_THREAD_STACK_SIZE
int "Own thread stack size"
depends on FXAS21002_TRIGGER_OWN_THREAD
default 1024
endif # FXAS21002_TRIGGER
endif # FXAS21002