From: David Lechner <dlechner@baylibre.com>
To: "Petre Rodan" <petre.rodan@subdimension.ro>,
"Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 09/14] iio: accel: bma220: add i2c module
Date: Thu, 11 Sep 2025 14:23:35 -0500 [thread overview]
Message-ID: <a69192a1-68cb-4c24-abe6-09534df0ba98@baylibre.com> (raw)
In-Reply-To: <20250910-bma220_improvements-v2-9-e23f4f2b9745@subdimension.ro>
On 9/10/25 2:57 AM, Petre Rodan wrote:
> Add the bma220_i2c module.
>
> Note that this kernel module transparently shifts all register addresses
> 1 bit to the left, so all functions will operate based on the SPI memory
> map.
>
> Signed-off-by: Petre Rodan <petre.rodan@subdimension.ro>
> ---
> no change
> ---
> drivers/iio/accel/Kconfig | 9 +++++-
> drivers/iio/accel/Makefile | 1 +
> drivers/iio/accel/bma220.h | 1 +
> drivers/iio/accel/bma220_core.c | 18 ++++++++++++
> drivers/iio/accel/bma220_i2c.c | 61 +++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 89 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
> index 9b6c35b759481df5ff3c91856f8783357d25de80..b3c5b0b7a406ec0cec531a122af424cb8ec57703 100644
> --- a/drivers/iio/accel/Kconfig
> +++ b/drivers/iio/accel/Kconfig
> @@ -221,6 +221,7 @@ config BMA220
depends I2C || SPI
> select REGMAP
> select IIO_BUFFER
> select IIO_TRIGGERED_BUFFER
> + select BMA220_I2C if I2C
> select BMA220_SPI if SPI
> help
> Say yes here to add support for the Bosch BMA220 triaxial
> @@ -228,7 +229,13 @@ config BMA220
>
> To compile this driver as a module, choose M here: the
> module will be called bma220_core and you will also get
> - bma220_spi if SPI is enabled.
> + bma220_i2c if I2C is enabled and bma220_spi if SPI is
> + enabled.
> +
> +config BMA220_I2C
> + tristate
> + select REGMAP_I2C
> + depends on BMA220
>
> config BMA220_SPI
> tristate
> diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile
> index 56a9f848f7f913633bc2a628c1ac5c9190774b9d..fa440a85928398fee927081f605595ba9fbc4ad9 100644
> --- a/drivers/iio/accel/Makefile
> +++ b/drivers/iio/accel/Makefile
> @@ -26,6 +26,7 @@ obj-$(CONFIG_ADXL380_I2C) += adxl380_i2c.o
> obj-$(CONFIG_ADXL380_SPI) += adxl380_spi.o
> obj-$(CONFIG_BMA180) += bma180.o
> obj-$(CONFIG_BMA220) += bma220_core.o
> +obj-$(CONFIG_BMA220_I2C) += bma220_i2c.o
> obj-$(CONFIG_BMA220_SPI) += bma220_spi.o
> obj-$(CONFIG_BMA400) += bma400_core.o
> obj-$(CONFIG_BMA400_I2C) += bma400_i2c.o
> diff --git a/drivers/iio/accel/bma220.h b/drivers/iio/accel/bma220.h
> index f9f4fa3daf33665f07f8bf073468dff070b46d74..384557d10d5613b7d829c6666f3da06de219277a 100644
> --- a/drivers/iio/accel/bma220.h
> +++ b/drivers/iio/accel/bma220.h
> @@ -12,6 +12,7 @@
> #include <linux/regmap.h>
>
> extern const struct regmap_config bma220_spi_regmap_config;
> +extern const struct regmap_config bma220_i2c_regmap_config;
Up to now, i2c is before spi. So would be consistent to keep
doing that.
> extern const struct dev_pm_ops bma220_pm_ops;
>
> int bma220_common_probe(struct device *dev, struct regmap *regmap, int irq);
> diff --git a/drivers/iio/accel/bma220_core.c b/drivers/iio/accel/bma220_core.c
> index 4d8b65ea737a2d5fe74f98da13a582a80874a5af..191074d8618ea2638f69283781b8677921876681 100644
> --- a/drivers/iio/accel/bma220_core.c
> +++ b/drivers/iio/accel/bma220_core.c
> @@ -175,6 +175,24 @@ const struct regmap_config bma220_spi_regmap_config = {
> };
> EXPORT_SYMBOL_NS_GPL(bma220_spi_regmap_config, "IIO_BOSCH_BMA220");
>
> +/*
> + * Based on the datasheet the memory map differs between the SPI and the I2C
> + * implementations. I2C register addresses are simply shifted to the left
> + * by 1 bit yet the register size remains unchanged.
> + * This driver employs the SPI memory map to correlate register names to
> + * addresses regardless of the bus type.
> + */
> +
> +const struct regmap_config bma220_i2c_regmap_config = {
> + .reg_bits = 8,
> + .val_bits = 8,
> + .reg_shift = -1,
> + .max_register = BMA220_REG_SOFTRESET,
> + .cache_type = REGCACHE_NONE,
> + .writeable_reg = bma220_is_writable_reg,
> +};
> +EXPORT_SYMBOL_NS_GPL(bma220_i2c_regmap_config, "IIO_BOSCH_BMA220");
> +
> static irqreturn_t bma220_trigger_handler(int irq, void *p)
> {
> int ret;
> diff --git a/drivers/iio/accel/bma220_i2c.c b/drivers/iio/accel/bma220_i2c.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..2b63949ea64ee11421e76a2e7c868a922d1f9a12
> --- /dev/null
> +++ b/drivers/iio/accel/bma220_i2c.c
> @@ -0,0 +1,61 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Bosch triaxial acceleration sensor
> + *
> + * Copyright (c) 2025 Petre Rodan <petre.rodan@subdimension.ro>
> + *
> + * Datasheet: https://media.digikey.com/pdf/Data%20Sheets/Bosch/BMA220.pdf
> + * I2C address is either 0x0b or 0x0a depending on CSB (pin 10)
> + */
> +
> +#include <linux/device.h>
> +#include <linux/errno.h>
> +#include <linux/i2c.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/module.h>
> +#include <linux/regmap.h>
> +#include <linux/types.h>
> +
> +#include <linux/iio/iio.h>
It doesn't look like the iio header is used. Maybe not device.h either.
> +
> +#include "bma220.h"
> +
next prev parent reply other threads:[~2025-09-11 19:23 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-10 7:57 [PATCH v2 00/14] iio: accel: bma220 improvements Petre Rodan
2025-09-10 7:57 ` [PATCH v2 01/14] dt-bindings: iio: accel: bosch,bma220 cleanup typo Petre Rodan
2025-09-11 7:31 ` Krzysztof Kozlowski
2025-09-10 7:57 ` [PATCH v2 02/14] dt-bindings: iio: accel: bosch,bma220 setup SPI clock mode Petre Rodan
2025-09-10 17:48 ` Jonathan Cameron
2025-09-11 7:31 ` Krzysztof Kozlowski
2025-09-10 7:57 ` [PATCH v2 03/14] dt-bindings: iio: accel: bosch,bma220 change irq type Petre Rodan
2025-09-11 7:33 ` Krzysztof Kozlowski
2025-09-11 9:53 ` Petre Rodan
2025-09-10 7:57 ` [PATCH v2 04/14] iio: accel: bma220: split original driver Petre Rodan
2025-09-10 17:56 ` Jonathan Cameron
2025-09-11 19:01 ` David Lechner
2025-09-10 7:57 ` [PATCH v2 05/14] iio: accel: bma220: add open firmware table Petre Rodan
2025-09-10 7:57 ` [PATCH v2 06/14] iio: accel: bma220: add get regulator check Petre Rodan
2025-09-10 17:58 ` Jonathan Cameron
2025-09-10 18:51 ` Petre Rodan
2025-09-10 20:28 ` Andy Shevchenko
2025-09-10 7:57 ` [PATCH v2 07/14] iio: accel: bma220: reset registers during init stage Petre Rodan
2025-09-10 18:01 ` Jonathan Cameron
2025-09-11 7:35 ` Krzysztof Kozlowski
2025-09-11 12:36 ` Petre Rodan
2025-09-11 13:07 ` Krzysztof Kozlowski
2025-09-11 13:52 ` Petre Rodan
2025-09-11 13:59 ` Andy Shevchenko
2025-09-11 13:44 ` David Lechner
2025-09-12 14:24 ` Jonathan Cameron
2025-09-11 19:14 ` David Lechner
2025-09-10 7:57 ` [PATCH v2 08/14] iio: accel: bma220: migrate to regmap API Petre Rodan
2025-09-10 18:12 ` Jonathan Cameron
2025-09-12 14:54 ` Petre Rodan
2025-09-13 12:22 ` Jonathan Cameron
2025-09-10 7:57 ` [PATCH v2 09/14] iio: accel: bma220: add i2c module Petre Rodan
2025-09-11 19:23 ` David Lechner [this message]
2025-09-10 7:57 ` [PATCH v2 10/14] iio: accel: bma220: add i2c watchdog feature Petre Rodan
2025-09-10 7:57 ` [PATCH v2 11/14] iio: accel: bma220: add interrupt trigger Petre Rodan
2025-09-10 18:15 ` Jonathan Cameron
2025-09-10 7:57 ` [PATCH v2 12/14] iio: accel: bma220: add LPF cut-off frequency mapping Petre Rodan
2025-09-10 18:16 ` Jonathan Cameron
2025-09-10 7:57 ` [PATCH v2 13/14] iio: accel: bma220: add debugfs reg access Petre Rodan
2025-09-10 7:57 ` [PATCH v2 14/14] iio: accel: bma220: add maintainer Petre Rodan
2025-09-10 18:18 ` [PATCH v2 00/14] iio: accel: bma220 improvements Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a69192a1-68cb-4c24-abe6-09534df0ba98@baylibre.com \
--to=dlechner@baylibre.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=petre.rodan@subdimension.ro \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®