All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Martin Kepplinger <martink@posteo.de>,
	knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net,
	christoph.muellner@theobroma-systems.com, mfuzzey@parkeon.com
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Martin Kepplinger <martin.kepplinger@theobroma-systems.com>
Subject: Re: [PATCH 3/3] iio: mma8452: add support for MMA8451Q
Date: Sat, 23 Jan 2016 16:29:50 +0000	[thread overview]
Message-ID: <56A3AA7E.4010201@kernel.org> (raw)
In-Reply-To: <1452954922-2266-4-git-send-email-martink@posteo.de>

On 16/01/16 14:35, Martin Kepplinger wrote:
> This adds support for this series' 14 bit accelerometer chip, MMA8451Q.
> It's datasheet is available at the vendor's website:
> 
> https://cache.freescale.com/files/sensors/doc/data_sheet/MMA8451Q.pdf
> 
> Signed-off-by: Martin Kepplinger <martin.kepplinger@theobroma-systems.com>
> Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
Applied to the togreg branch of iio.git - initially pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  .../devicetree/bindings/iio/accel/mma8452.txt      |  4 ++-
>  drivers/iio/accel/Kconfig                          |  2 +-
>  drivers/iio/accel/mma8452.c                        | 42 ++++++++++++++++++----
>  3 files changed, 40 insertions(+), 8 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/iio/accel/mma8452.txt b/Documentation/devicetree/bindings/iio/accel/mma8452.txt
> index 3c10e85..165937e 100644
> --- a/Documentation/devicetree/bindings/iio/accel/mma8452.txt
> +++ b/Documentation/devicetree/bindings/iio/accel/mma8452.txt
> @@ -1,8 +1,10 @@
> -Freescale MMA8452Q, MMA8453Q, MMA8652FC or MMA8653FC triaxial accelerometer
> +Freescale MMA8451Q, MMA8452Q, MMA8453Q, MMA8652FC or MMA8653FC
> +triaxial accelerometer
>  
>  Required properties:
>  
>    - compatible: should contain one of
> +    * "fsl,mma8451"
>      * "fsl,mma8452"
>      * "fsl,mma8453"
>      * "fsl,mma8652"
> diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
> index edc29b1..d9feaa3 100644
> --- a/drivers/iio/accel/Kconfig
> +++ b/drivers/iio/accel/Kconfig
> @@ -143,7 +143,7 @@ config MMA8452
>  	select IIO_TRIGGERED_BUFFER
>  	help
>  	  Say yes here to build support for the following Freescale 3-axis
> -	  accelerometers: MMA8452Q, MMA8453Q, MMA8652FC, MMA8653FC.
> +	  accelerometers: MMA8451Q, MMA8452Q, MMA8453Q, MMA8652FC, MMA8653FC.
>  
>  	  To compile this driver as a module, choose M here: the module
>  	  will be called mma8452.
> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
> index 843169e..7f4994f 100644
> --- a/drivers/iio/accel/mma8452.c
> +++ b/drivers/iio/accel/mma8452.c
> @@ -1,6 +1,7 @@
>  /*
>   * mma8452.c - Support for following Freescale 3-axis accelerometers:
>   *
> + * MMA8451Q (14 bit)
>   * MMA8452Q (12 bit)
>   * MMA8453Q (10 bit)
>   * MMA8652FC (12 bit)
> @@ -85,6 +86,7 @@
>  #define  MMA8452_INT_FF_MT			BIT(2)
>  #define  MMA8452_INT_TRANS			BIT(5)
>  
> +#define MMA8451_DEVICE_ID			0x1a
>  #define MMA8452_DEVICE_ID			0x2a
>  #define MMA8453_DEVICE_ID			0x3a
>  #define MMA8652_DEVICE_ID			0x4a
> @@ -942,6 +944,14 @@ static struct attribute_group mma8452_event_attribute_group = {
>  	.num_event_specs = ARRAY_SIZE(mma8452_motion_event), \
>  }
>  
> +static const struct iio_chan_spec mma8451_channels[] = {
> +	MMA8452_CHANNEL(X, idx_x, 14),
> +	MMA8452_CHANNEL(Y, idx_y, 14),
> +	MMA8452_CHANNEL(Z, idx_z, 14),
> +	IIO_CHAN_SOFT_TIMESTAMP(idx_ts),
> +	MMA8452_FREEFALL_CHANNEL(IIO_MOD_X_AND_Y_AND_Z),
> +};
> +
>  static const struct iio_chan_spec mma8452_channels[] = {
>  	MMA8452_CHANNEL(X, idx_x, 12),
>  	MMA8452_CHANNEL(Y, idx_y, 12),
> @@ -975,6 +985,7 @@ static const struct iio_chan_spec mma8653_channels[] = {
>  };
>  
>  enum {
> +	mma8451,
>  	mma8452,
>  	mma8453,
>  	mma8652,
> @@ -982,17 +993,34 @@ enum {
>  };
>  
>  static const struct mma_chip_info mma_chip_info_table[] = {
> -	[mma8452] = {
> -		.chip_id = MMA8452_DEVICE_ID,
> -		.channels = mma8452_channels,
> -		.num_channels = ARRAY_SIZE(mma8452_channels),
> +	[mma8451] = {
> +		.chip_id = MMA8451_DEVICE_ID,
> +		.channels = mma8451_channels,
> +		.num_channels = ARRAY_SIZE(mma8451_channels),
>  		/*
>  		 * Hardware has fullscale of -2G, -4G, -8G corresponding to
> -		 * raw value -2048 for 12 bit or -512 for 10 bit.
> +		 * raw value -8192 for 14 bit, -2048 for 12 bit or -512 for 10
> +		 * bit.
>  		 * The userspace interface uses m/s^2 and we declare micro units
>  		 * So scale factor for 12 bit here is given by:
> -		 *	g * N * 1000000 / 2048 for N = 2, 4, 8 and g=9.80665
> +		 * 	g * N * 1000000 / 2048 for N = 2, 4, 8 and g=9.80665
>  		 */
> +		.mma_scales = { {0, 2394}, {0, 4788}, {0, 9577} },
> +		.ev_cfg = MMA8452_TRANSIENT_CFG,
> +		.ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE,
> +		.ev_cfg_chan_shift = 1,
> +		.ev_src = MMA8452_TRANSIENT_SRC,
> +		.ev_src_xe = MMA8452_TRANSIENT_SRC_XTRANSE,
> +		.ev_src_ye = MMA8452_TRANSIENT_SRC_YTRANSE,
> +		.ev_src_ze = MMA8452_TRANSIENT_SRC_ZTRANSE,
> +		.ev_ths = MMA8452_TRANSIENT_THS,
> +		.ev_ths_mask = MMA8452_TRANSIENT_THS_MASK,
> +		.ev_count = MMA8452_TRANSIENT_COUNT,
> +	},
> +	[mma8452] = {
> +		.chip_id = MMA8452_DEVICE_ID,
> +		.channels = mma8452_channels,
> +		.num_channels = ARRAY_SIZE(mma8452_channels),
>  		.mma_scales = { {0, 9577}, {0, 19154}, {0, 38307} },
>  		.ev_cfg = MMA8452_TRANSIENT_CFG,
>  		.ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE,
> @@ -1173,6 +1201,7 @@ static int mma8452_reset(struct i2c_client *client)
>  }
>  
>  static const struct of_device_id mma8452_dt_ids[] = {
> +	{ .compatible = "fsl,mma8451", .data = &mma_chip_info_table[mma8451] },
>  	{ .compatible = "fsl,mma8452", .data = &mma_chip_info_table[mma8452] },
>  	{ .compatible = "fsl,mma8453", .data = &mma_chip_info_table[mma8453] },
>  	{ .compatible = "fsl,mma8652", .data = &mma_chip_info_table[mma8652] },
> @@ -1209,6 +1238,7 @@ static int mma8452_probe(struct i2c_client *client,
>  		return ret;
>  
>  	switch (ret) {
> +	case MMA8451_DEVICE_ID:
>  	case MMA8452_DEVICE_ID:
>  	case MMA8453_DEVICE_ID:
>  	case MMA8652_DEVICE_ID:
> 


      reply	other threads:[~2016-01-23 16:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-16 14:35 iio: mma8452: driver improvements for v4.6 Martin Kepplinger
2016-01-16 14:35 ` [PATCH v6 1/3] iio: mma8452: add freefall detection for Freescale's accelerometers Martin Kepplinger
2016-01-22 17:13   ` Martin Kepplinger
2016-01-23 16:28   ` Jonathan Cameron
2016-01-16 14:35 ` [PATCH 2/3] iio: mma8452: whitespace cleanup Martin Kepplinger
2016-01-23 16:28   ` Jonathan Cameron
2016-01-16 14:35 ` [PATCH 3/3] iio: mma8452: add support for MMA8451Q Martin Kepplinger
2016-01-23 16:29   ` Jonathan Cameron [this message]

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=56A3AA7E.4010201@kernel.org \
    --to=jic23@kernel.org \
    --cc=christoph.muellner@theobroma-systems.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.kepplinger@theobroma-systems.com \
    --cc=martink@posteo.de \
    --cc=mfuzzey@parkeon.com \
    --cc=pmeerw@pmeerw.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.