diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2016-09-01 09:44:38 (GMT) |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2016-09-18 10:26:53 (GMT) |
commit | bf96f6e80cef4b9a234e8ce81aa2e333ca7ce599 (patch) | |
tree | d3861d639b33ec4309fe9114ed1617c8f1ac439e /drivers/iio/accel/kxsd9.h | |
parent | 154021a317564a600fb5b8e6eba9a76ca6888310 (diff) | |
download | linux-bf96f6e80cef4b9a234e8ce81aa2e333ca7ce599.tar.xz |
iio: accel: kxsd9: Split out SPI transport
This moves the KXSD9 SPI transport out to its own file and Kconfig
entry, so that we will be able to add another transport method.
We export the common probe and add a local header file for the
functionality shared between the main driver and the transport
driver.
We make the SPI transport the default for the driver if SPI is
available and the KXSD9 driver was selected, so the oldconfig
upgrade path will be clear.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/accel/kxsd9.h')
-rw-r--r-- | drivers/iio/accel/kxsd9.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/iio/accel/kxsd9.h b/drivers/iio/accel/kxsd9.h new file mode 100644 index 0000000..28845c3 --- /dev/null +++ b/drivers/iio/accel/kxsd9.h @@ -0,0 +1,32 @@ +#include <linux/device.h> +#include <linux/kernel.h> + +#define KXSD9_STATE_RX_SIZE 2 +#define KXSD9_STATE_TX_SIZE 2 + +struct kxsd9_transport; + +/** + * struct kxsd9_transport - transport adapter for SPI or I2C + * @trdev: transport device such as SPI or I2C + * @readreg(): function to read a byte from an address in the device + * @writereg(): function to write a byte to an address in the device + * @write2(): function to write two consecutive bytes to the device + * @readval(): function to read a 16bit value from the device + * @rx: cache aligned read buffer + * @tx: cache aligned write buffer + */ +struct kxsd9_transport { + void *trdev; + int (*readreg) (struct kxsd9_transport *tr, u8 address); + int (*writereg) (struct kxsd9_transport *tr, u8 address, u8 val); + int (*write2) (struct kxsd9_transport *tr, u8 b1, u8 b2); + int (*readval) (struct kxsd9_transport *tr, u8 address); + u8 rx[KXSD9_STATE_RX_SIZE] ____cacheline_aligned; + u8 tx[KXSD9_STATE_TX_SIZE]; +}; + +int kxsd9_common_probe(struct device *parent, + struct kxsd9_transport *transport, + const char *name); +int kxsd9_common_remove(struct device *parent); |