From: Randy Dunlap <rdunlap@infradead.org>
To: Dan Robertson <dan@dlrobertson.com>,
Jonathan Cameron <jic23@kernel.org>,
linux-iio@vger.kernel.org,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
devicetree@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/2] iio: (bma400) add driver for the BMA400
Date: Thu, 17 Oct 2019 21:25:37 -0700 [thread overview]
Message-ID: <487efd2c-b453-6c8b-eaac-7ba168bb4d77@infradead.org> (raw)
In-Reply-To: <20191018031848.18538-3-dan@dlrobertson.com>
On 10/17/19 8:18 PM, Dan Robertson wrote:
> Add a IIO driver for the Bosch BMA400 3-axes ultra-low power accelerometer.
> The driver supports reading from the acceleration and temperature
> registers. The driver also supports reading and configuring the output data
> rate, oversampling ratio, and scale.
>
> Signed-off-by: Dan Robertson <dan@dlrobertson.com>
Hi,
I'm repeating some comments from my V2 review.
> ---
> drivers/iio/accel/Kconfig | 18 +
> drivers/iio/accel/Makefile | 2 +
> drivers/iio/accel/bma400.h | 85 ++++
> drivers/iio/accel/bma400_core.c | 796 ++++++++++++++++++++++++++++++++
> drivers/iio/accel/bma400_i2c.c | 60 +++
> 5 files changed, 961 insertions(+)
> create mode 100644 drivers/iio/accel/bma400.h
> create mode 100644 drivers/iio/accel/bma400_core.c
> create mode 100644 drivers/iio/accel/bma400_i2c.c
>
> diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
> index 9b9656ce37e6..a1081b902d16 100644
> --- a/drivers/iio/accel/Kconfig
> +++ b/drivers/iio/accel/Kconfig
> @@ -112,6 +112,24 @@ config BMA220
> To compile this driver as a module, choose M here: the
> module will be called bma220_spi.
>
> +config BMA400
> + tristate "Bosch BMA400 3-Axis Accelerometer Driver"
> + depends on I2C
> + select REGMAP
> + select BMA400_I2C if (I2C)
Since BMA400 already depends on I2C, the "if (I2C)" above is
redundant so it's not needed.
> + help
> + Say Y here if you want to build a driver for the Bosch BMA400
> + triaxial acceleration sensor.
> +
> + To compile this driver as a module, choose M here: the
> + module will be called bma400_core and you will also get
> + bma400_i2c for I2C.
> +
> +config BMA400_I2C
> + tristate
> + depends on BMA400
> + select REGMAP_I2C
> +
> config BMC150_ACCEL
> tristate "Bosch BMC150 Accelerometer Driver"
> select IIO_BUFFER
> diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c
> new file mode 100644
> index 000000000000..80f1ee6713fa
> --- /dev/null
> +++ b/drivers/iio/accel/bma400_core.c
> @@ -0,0 +1,796 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * bma400_core.c - Core IIO driver for Bosch BMA400 triaxial acceleration
> + * sensor. Used by bma400-i2c.
> + *
> + * Copyright 2019 Dan Robertson <dan@dlrobertson.com>
> + *
> + * TODO:
> + * - Support for power management
> + * - Support events and interrupts
> + * - Create channel the step count
> + * - Create channel for sensor time
> + */
> +
> +#include <linux/device.h>
> +#include <linux/module.h>
> +#include <linux/regmap.h>
> +#include <linux/bitops.h>
> +#include <linux/iio/iio.h>
> +#include <linux/iio/sysfs.h>
> +
> +#include "bma400.h"
> +
> +/*
> + * The G-range selection may be one of 2g, 4g, 8, or 16g. The scale may
> + * be selected with the acc_range bits of the ACC_CONFIG1 register.
> + */
> +static const int bma400_scale_table[] = {
> + 0, 38344,
> + 0, 76590,
> + 0, 153277,
> + 0, 306457
> +};
> +
> +static const int bma400_osr_table[] = { 0, 1, 3 };
> +
> +/* See the ACC_CONFIG1 section of the datasheet */
> +static const int bma400_sample_freqs[] = {
> + 12, 500000,
> + 25, 0,
> + 50, 0,
> + 100, 0,
> + 200, 0,
> + 400, 0,
> + 800, 0,
> +};
> +
> +/* See the ACC_CONFIG0 section of the datasheet */
> +enum bma400_power_mode {
> + POWER_MODE_SLEEP = 0x00,
> + POWER_MODE_LOW = 0x01,
> + POWER_MODE_NORMAL = 0x02,
> + POWER_MODE_INVALID = 0x03,
> +};
> +
> +struct bma400_sample_freq {
> + int hz;
> + int uhz;
> +};
> +
> +struct bma400_data {
> + struct device *dev;
> + struct mutex mutex; /* data register lock */
needs #include <linux/mutex.h>
> + struct iio_mount_matrix orientation;
> + struct regmap *regmap;
> + enum bma400_power_mode power_mode;
> + struct bma400_sample_freq sample_freq;
> + int oversampling_ratio;
> + int scale;
> +};
> +
[snip]
> +static int bma400_get_accel_scale_idx(struct bma400_data *data, int val)
> +{
> + int i;
> +
> + for (i = 1; i < ARRAY_SIZE(bma400_scale_table); i += 2) {
needs #include <linux/kernel.h>
for ARRAY_SIZE()
> + if (bma400_scale_table[i] == val)
> + return i - 1;
> + }
> + return -EINVAL;
> +}
[snip]
Thanks.
--
~Randy
See Documentation/process/submit-checklist.rst, especially Rule #1.
next prev parent reply other threads:[~2019-10-18 4:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-18 3:18 [PATCH v3 0/2] iio: add driver for Bosch BMA400 accelerometer Dan Robertson
2019-10-18 3:18 ` [PATCH v4 1/2] dt-bindings: iio: accel: bma400: add bindings Dan Robertson
2019-10-25 16:35 ` Rob Herring
2019-10-18 3:18 ` [PATCH v4 2/2] iio: (bma400) add driver for the BMA400 Dan Robertson
2019-10-18 4:25 ` Randy Dunlap [this message]
2019-10-19 1:35 ` Dan Robertson
2019-10-18 7:23 ` Andy Shevchenko
2019-10-19 2:43 ` Dan Robertson
2019-10-21 15:20 ` Jonathan Cameron
2019-11-18 0:25 ` Dan Robertson
2019-11-23 12:51 ` Jonathan Cameron
2019-11-24 22:37 ` Dan Robertson
2019-10-19 4:25 ` Joe Perches
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=487efd2c-b453-6c8b-eaac-7ba168bb4d77@infradead.org \
--to=rdunlap@infradead.org \
--cc=andy.shevchenko@gmail.com \
--cc=dan@dlrobertson.com \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pmeerw@pmeerw.net \
--cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).