devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Martin Kepplinger
	<martink-1KBjaw7Xf1+zQB+pC5nmwQ@public.gmane.org>,
	knaack.h-Mmb7MZpHnFY@public.gmane.org,
	lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org,
	pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org,
	mfuzzey-mB3Nsq4MPf1BDgjK7y7TUQ@public.gmane.org,
	roberta.dobrescu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	christoph.muellner-SN7IsUiht6C/RdPyistoZJqQE7yCjDx5@public.gmane.org
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Martin Kepplinger
	<martin.kepplinger-SN7IsUiht6C/RdPyistoZJqQE7yCjDx5@public.gmane.org>
Subject: Re: [PATCH 4/9] iio: mma8452: add support for MMA8652FC and MMA8653FC accelerometers
Date: Sun, 05 Jul 2015 12:47:26 +0100	[thread overview]
Message-ID: <5599194E.5020207@kernel.org> (raw)
In-Reply-To: <1436018110-3903-5-git-send-email-martink-1KBjaw7Xf1+zQB+pC5nmwQ@public.gmane.org>

On 04/07/15 14:55, Martin Kepplinger wrote:
> MMA8652FC and MMA8653FC don't provide the transient interrupt source, so
> the motion interrupt source is used by providing a new iio_chan_spec
> definition, so that other supported devices are not affected by this.
> 
> Datasheets for the newly supported devices are available at Freescale's
> website:
> 
> http://cache.freescale.com/files/sensors/doc/data_sheet/MMA8652FC.pdf
> http://cache.freescale.com/files/sensors/doc/data_sheet/MMA8653FC.pdf
> 
> Signed-off-by: Martin Kepplinger <martin.kepplinger-SN7IsUiht6C/RdPyistoZJqQE7yCjDx5@public.gmane.org>
> Signed-off-by: Christoph Muellner <christoph.muellner-SN7IsUiht6C/RdPyistoZJqQE7yCjDx5@public.gmane.org>
Only really one comment which is a follow through from an earlier suggestion.

Looking good.
> ---
>  drivers/iio/accel/Kconfig   |  2 +-
>  drivers/iio/accel/mma8452.c | 79 ++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 79 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
> index 91fab16..684c8b5 100644
> --- a/drivers/iio/accel/Kconfig
> +++ b/drivers/iio/accel/Kconfig
> @@ -93,7 +93,7 @@ config MMA8452
>  	select IIO_TRIGGERED_BUFFER
>  	help
>  	  Say yes here to build support for the following Freescale 3-axis
> -	  accelerometers: MMA8452Q, MMA8453Q.
> +	  accelerometers: 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 0498b6e..ccce925 100644
> --- a/drivers/iio/accel/mma8452.c
> +++ b/drivers/iio/accel/mma8452.c
> @@ -3,6 +3,8 @@
>   *
>   *	MMA8452Q
>   *	MMA8453Q
> + *	MMA8652FC
> + *	MMA8653FC
>   *
>   * Copyright 2014 Peter Meerwald <pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org>
>   *
> @@ -88,6 +90,8 @@
>  
>  #define MMA8452_DEVICE_ID 0x2a
>  #define MMA8453_DEVICE_ID 0x3a
> +#define MMA8652_DEVICE_ID 0x4a
> +#define MMA8653_DEVICE_ID 0x5a
>  
>  struct mma8452_data {
>  	struct i2c_client *client;
> @@ -740,6 +744,26 @@ static struct attribute_group mma8452_event_attribute_group = {
>  	.num_event_specs = ARRAY_SIZE(mma8452_transient_event), \
>  }
>  
> +#define MMA8652_CHANNEL(axis, idx, bits) { \
> +	.type = IIO_ACCEL, \
> +	.modified = 1, \
> +	.channel2 = IIO_MOD_##axis, \
> +	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
> +		BIT(IIO_CHAN_INFO_CALIBBIAS), \
> +	.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
> +		BIT(IIO_CHAN_INFO_SCALE), \
> +	.scan_index = idx, \
> +	.scan_type = { \
> +		.sign = 's', \
> +		.realbits = (bits), \
> +		.storagebits = 16, \
> +		.shift = 16 - (bits), \
> +		.endianness = IIO_BE, \
> +	}, \
> +	.event_spec = mma8452_motion_event, \
> +	.num_event_specs = ARRAY_SIZE(mma8452_motion_event), \
> +}
> +
>  static const struct iio_chan_spec mma8452_channels[] = {
>  	MMA8452_CHANNEL(X, 0, 12),
>  	MMA8452_CHANNEL(Y, 1, 12),
> @@ -754,9 +778,25 @@ static const struct iio_chan_spec mma8453_channels[] = {
>  	IIO_CHAN_SOFT_TIMESTAMP(3),
>  };
>  
> +static const struct iio_chan_spec mma8652_channels[] = {
> +	MMA8652_CHANNEL(X, 0, 12),
> +	MMA8652_CHANNEL(Y, 1, 12),
> +	MMA8652_CHANNEL(Z, 2, 12),
> +	IIO_CHAN_SOFT_TIMESTAMP(3),
> +};
> +
> +static const struct iio_chan_spec mma8653_channels[] = {
> +	MMA8652_CHANNEL(X, 0, 10),
> +	MMA8652_CHANNEL(Y, 1, 10),
> +	MMA8652_CHANNEL(Z, 2, 10),
> +	IIO_CHAN_SOFT_TIMESTAMP(3),
> +};
> +
>  enum {
>  	mma8452,
>  	mma8453,
> +	mma8652,
> +	mma8653,
>  };
>  
>  /*
> @@ -800,6 +840,38 @@ static const struct mma_chip_info mma_chip_info_table[] = {
>  		.ev_ths_mask = MMA8452_TRANSIENT_THS_MASK,
>  		.ev_count = MMA8452_TRANSIENT_COUNT,
>  	},
> +	[mma8652] = {
> +		.chip_id = MMA8652_DEVICE_ID,
> +		.channels = mma8652_channels,
> +		.num_channels = ARRAY_SIZE(mma8652_channels),
> +		.mma_scales = { {0, 9577}, {0, 19154}, {0, 38307} },
> +		.ev_cfg = MMA8452_FF_MT_CFG,
> +		.ev_cfg_ele = MMA8452_FF_MT_CFG_ELE,
> +		.ev_cfg_chan_shift = 3,
> +		.ev_src = MMA8452_FF_MT_SRC,
> +		.ev_src_xe = MMA8452_FF_MT_SRC_XHE,
> +		.ev_src_ye = MMA8452_FF_MT_SRC_YHE,
> +		.ev_src_ze = MMA8452_FF_MT_SRC_ZHE,
> +		.ev_ths = MMA8452_FF_MT_THS,
> +		.ev_ths_mask = MMA8452_FF_MT_THS_MASK,
> +		.ev_count = MMA8452_FF_MT_COUNT,
> +	},
> +	[mma8653] = {
> +		.chip_id = MMA8653_DEVICE_ID,
> +		.channels = mma8653_channels,
> +		.num_channels = ARRAY_SIZE(mma8653_channels),
> +		.mma_scales = { {0, 38307}, {0, 76614}, {0, 153228} },
> +		.ev_cfg = MMA8452_FF_MT_CFG,
> +		.ev_cfg_ele = MMA8452_FF_MT_CFG_ELE,
> +		.ev_cfg_chan_shift = 3,
> +		.ev_src = MMA8452_FF_MT_SRC,
> +		.ev_src_xe = MMA8452_FF_MT_SRC_XHE,
> +		.ev_src_ye = MMA8452_FF_MT_SRC_YHE,
> +		.ev_src_ze = MMA8452_FF_MT_SRC_ZHE,
> +		.ev_ths = MMA8452_FF_MT_THS,
> +		.ev_ths_mask = MMA8452_FF_MT_THS_MASK,
> +		.ev_count = MMA8452_FF_MT_COUNT,
> +	},
>  };
>  
>  static struct attribute *mma8452_attributes[] = {
> @@ -921,6 +993,8 @@ static int mma8452_reset(struct i2c_client *client)
>  static const struct of_device_id mma8452_dt_ids[] = {
>  	{ .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] },
> +	{ .compatible = "fsl,mma8653", .data = &mma_chip_info_table[mma8653] },
>  	{ }
>  };
>  
> @@ -936,7 +1010,8 @@ static int mma8452_probe(struct i2c_client *client,
>  	if (ret < 0)
>  		return ret;
>  
> -	if (ret != MMA8452_DEVICE_ID && ret != MMA8453_DEVICE_ID)
> +	if (ret != MMA8452_DEVICE_ID && ret != MMA8453_DEVICE_ID &&
> +	    ret != MMA8652_DEVICE_ID && ret != MMA8653_DEVICE_ID)
And now the advantages of a switch become apparent ;)
switch (ret) {
       case MMA8452_DEVICE_ID:
       case MMA8453_DEVICE_ID:
       ..
       break;
       default:
	  return -ENODEV;

Also, you should really be verifying that not only is it a supported
part, but that it is the one that our board configuration is telling us
is there.

>  		return -ENODEV;
>  
>  	match = of_match_device(mma8452_dt_ids, &client->dev);
> @@ -1086,6 +1161,8 @@ static SIMPLE_DEV_PM_OPS(mma8452_pm_ops, mma8452_suspend, mma8452_resume);
>  static const struct i2c_device_id mma8452_id[] = {
>  	{ "mma8452", mma8452 },
>  	{ "mma8453", mma8453 },
> +	{ "mma8652", mma8652 },
> +	{ "mma8653", mma8653 },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(i2c, mma8452_id);
> 

  parent reply	other threads:[~2015-07-05 11:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-04 13:55 [PATCH v3 0/9] iio: mma8452: improve driver and support more chips Martin Kepplinger
     [not found] ` <1436018110-3903-1-git-send-email-martink-1KBjaw7Xf1+zQB+pC5nmwQ@public.gmane.org>
2015-07-04 13:55   ` [PATCH 1/9] iio: mma8452: refactor for seperating chip specific data Martin Kepplinger
     [not found]     ` <1436018110-3903-2-git-send-email-martink-1KBjaw7Xf1+zQB+pC5nmwQ@public.gmane.org>
2015-07-05 11:37       ` Jonathan Cameron
2015-07-04 13:55   ` [PATCH 2/9] iio: mma8452: add support for MMA8453Q accelerometer chip Martin Kepplinger
     [not found]     ` <1436018110-3903-3-git-send-email-martink-1KBjaw7Xf1+zQB+pC5nmwQ@public.gmane.org>
2015-07-05 11:41       ` Jonathan Cameron
2015-07-04 13:55   ` [PATCH 3/9] iio: mma8452: add freefall / motion interrupt source Martin Kepplinger
     [not found]     ` <1436018110-3903-4-git-send-email-martink-1KBjaw7Xf1+zQB+pC5nmwQ@public.gmane.org>
2015-07-05 11:44       ` Jonathan Cameron
     [not found]         ` <55991885.9030204-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-07-05 11:44           ` Jonathan Cameron
2015-07-04 13:55   ` [PATCH 4/9] iio: mma8452: add support for MMA8652FC and MMA8653FC accelerometers Martin Kepplinger
     [not found]     ` <1436018110-3903-5-git-send-email-martink-1KBjaw7Xf1+zQB+pC5nmwQ@public.gmane.org>
2015-07-05 11:47       ` Jonathan Cameron [this message]
2015-07-04 13:55   ` [PATCH 5/9] iio: mma8452: add devicetree documentation Martin Kepplinger
     [not found]     ` <1436018110-3903-6-git-send-email-martink-1KBjaw7Xf1+zQB+pC5nmwQ@public.gmane.org>
2015-07-05 11:48       ` Jonathan Cameron
     [not found]         ` <5599199B.6030006-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-07-05 11:50           ` Martin Kepplinger
     [not found]             ` <55991A1E.30608-1KBjaw7Xf1+zQB+pC5nmwQ@public.gmane.org>
2015-07-05 12:12               ` Jonathan Cameron
2015-07-06  8:06         ` Martin Fuzzey
     [not found]           ` <559A3715.3040206-mB3Nsq4MPf1BDgjK7y7TUQ@public.gmane.org>
2015-07-06  8:13             ` Martin Kepplinger
2015-07-04 13:55   ` [PATCH 6/9] iio: mma8452: add copyright notice comment Martin Kepplinger
2015-07-04 13:55   ` [PATCH 7/9] iio: mma8452: change iio event type to IIO_EV_TYPE_MAG Martin Kepplinger
     [not found]     ` <1436018110-3903-8-git-send-email-martink-1KBjaw7Xf1+zQB+pC5nmwQ@public.gmane.org>
2015-07-05 11:50       ` Jonathan Cameron
2015-07-06  8:39         ` Martin Fuzzey
     [not found]           ` <559A3EB0.2060200-mB3Nsq4MPf1BDgjK7y7TUQ@public.gmane.org>
2015-07-07  7:05             ` Jonathan Cameron
     [not found]               ` <E94BB95F-0719-41A8-B7B7-E035BE1B9C43-tko9wxEg+fIOOJlXag/Snyp2UmYkHbXO@public.gmane.org>
2015-07-07  7:32                 ` Martin Kepplinger
2015-07-04 13:55   ` [PATCH 8/9] iio: mma8452: leave sysfs namings to the iio core Martin Kepplinger
2015-07-04 13:55   ` [PATCH 9/9] iio: mma8452: add devicetree property to allow all pin wirings Martin Kepplinger
     [not found]     ` <1436018110-3903-10-git-send-email-martink-1KBjaw7Xf1+zQB+pC5nmwQ@public.gmane.org>
2015-07-05 11:51       ` 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=5599194E.5020207@kernel.org \
    --to=jic23-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=christoph.muellner-SN7IsUiht6C/RdPyistoZJqQE7yCjDx5@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=knaack.h-Mmb7MZpHnFY@public.gmane.org \
    --cc=lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org \
    --cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=martin.kepplinger-SN7IsUiht6C/RdPyistoZJqQE7yCjDx5@public.gmane.org \
    --cc=martink-1KBjaw7Xf1+zQB+pC5nmwQ@public.gmane.org \
    --cc=mfuzzey-mB3Nsq4MPf1BDgjK7y7TUQ@public.gmane.org \
    --cc=pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org \
    --cc=roberta.dobrescu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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).