* [PATCH] iio: mma8452: add support for MMA8451Q
@ 2016-01-14 11:02 Martin Kepplinger
2016-01-14 11:15 ` kbuild test robot
2016-01-14 11:45 ` Peter Meerwald-Stadler
0 siblings, 2 replies; 6+ messages in thread
From: Martin Kepplinger @ 2016-01-14 11:02 UTC (permalink / raw)
To: jic23, knaack.h, lars, pmeerw, christoph.muellner, mfuzzey
Cc: linux-iio, linux-kernel, Martin Kepplinger, Martin Kepplinger
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>
---
This applies on top of
[PATCH v5] iio: mma8452: add freefall detection for Freescale's accelerometers
which should be in good shape (I think it already is) and accepted before this.
this is sent early for review, just for you to know what to expect for v4.6.
thanks
martin
.../devicetree/bindings/iio/accel/mma8452.txt | 4 +-
drivers/iio/accel/Kconfig | 2 +-
drivers/iio/accel/mma8452.c | 46 ++++++++++++++++++----
3 files changed, 42 insertions(+), 10 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..0e02c36 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: MMA8341Q, 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 820a8a3..b46694e 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,8 +86,9 @@
#define MMA8452_INT_FF_MT BIT(2)
#define MMA8452_INT_TRANS BIT(5)
-#define MMA8452_DEVICE_ID 0x2a
-#define MMA8453_DEVICE_ID 0x3a
+#define MMA8451_DEVICE_ID 0x1a
+#define MMA8452_DEVICE_ID 0x2a
+#define MMA8453_DEVICE_ID 0x3a
#define MMA8652_DEVICE_ID 0x4a
#define MMA8653_DEVICE_ID 0x5a
@@ -937,6 +939,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),
@@ -970,6 +980,7 @@ static const struct iio_chan_spec mma8653_channels[] = {
};
enum {
+ mma8451,
mma8452,
mma8453,
mma8652,
@@ -977,17 +988,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, 9576} },
+ .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,
@@ -1168,6 +1196,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] },
@@ -1204,6 +1233,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:
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: mma8452: add support for MMA8451Q
2016-01-14 11:02 [PATCH] iio: mma8452: add support for MMA8451Q Martin Kepplinger
@ 2016-01-14 11:15 ` kbuild test robot
2016-01-14 11:19 ` Martin Kepplinger
2016-01-14 11:45 ` Peter Meerwald-Stadler
1 sibling, 1 reply; 6+ messages in thread
From: kbuild test robot @ 2016-01-14 11:15 UTC (permalink / raw)
To: Martin Kepplinger
Cc: kbuild-all, jic23, knaack.h, lars, pmeerw, christoph.muellner,
mfuzzey, linux-iio, linux-kernel, Martin Kepplinger,
Martin Kepplinger
[-- Attachment #1: Type: text/plain, Size: 2072 bytes --]
Hi Martin,
[auto build test ERROR on next-20160114]
[also build test ERROR on v4.4]
[cannot apply to robh/for-next v4.4-rc8 v4.4-rc7 v4.4-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Martin-Kepplinger/iio-mma8452-add-support-for-MMA8451Q/20160114-190548
config: x86_64-randconfig-x015-01140842 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All error/warnings (new ones prefixed by >>):
>> drivers/iio/accel/mma8452.c:832:2: error: implicit declaration of function 'MMA8452_FREEFALL_CHANNEL' [-Werror=implicit-function-declaration]
MMA8452_FREEFALL_CHANNEL(IIO_MOD_X_AND_Y_AND_Z),
^
>> drivers/iio/accel/mma8452.c:832:2: error: initializer element is not constant
drivers/iio/accel/mma8452.c:832:2: note: (near initialization for 'mma8451_channels[4].type')
>> drivers/iio/accel/mma8452.c:827:56: warning: missing braces around initializer [-Wmissing-braces]
static const struct iio_chan_spec mma8451_channels[] = {
^
drivers/iio/accel/mma8452.c:827:56: note: (near initialization for 'mma8451_channels')
cc1: some warnings being treated as errors
vim +/MMA8452_FREEFALL_CHANNEL +832 drivers/iio/accel/mma8452.c
821 .endianness = IIO_BE, \
822 }, \
823 .event_spec = mma8452_motion_event, \
824 .num_event_specs = ARRAY_SIZE(mma8452_motion_event), \
825 }
826
> 827 static const struct iio_chan_spec mma8451_channels[] = {
828 MMA8452_CHANNEL(X, idx_x, 14),
829 MMA8452_CHANNEL(Y, idx_y, 14),
830 MMA8452_CHANNEL(Z, idx_z, 14),
831 IIO_CHAN_SOFT_TIMESTAMP(idx_ts),
> 832 MMA8452_FREEFALL_CHANNEL(IIO_MOD_X_AND_Y_AND_Z),
833 };
834
835 static const struct iio_chan_spec mma8452_channels[] = {
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 23811 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: mma8452: add support for MMA8451Q
2016-01-14 11:15 ` kbuild test robot
@ 2016-01-14 11:19 ` Martin Kepplinger
0 siblings, 0 replies; 6+ messages in thread
From: Martin Kepplinger @ 2016-01-14 11:19 UTC (permalink / raw)
To: kbuild test robot
Cc: kbuild-all, jic23, knaack.h, lars, pmeerw, christoph.muellner,
mfuzzey, linux-iio, linux-kernel, Martin Kepplinger
Am 2016-01-14 um 12:15 schrieb kbuild test robot:
> Hi Martin,
>
> [auto build test ERROR on next-20160114]
> [also build test ERROR on v4.4]
> [cannot apply to robh/for-next v4.4-rc8 v4.4-rc7 v4.4-rc6]
> [if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
I know. This was intentional. I'll keep this auto build in mind for the
future though.
thanks
martin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: mma8452: add support for MMA8451Q
2016-01-14 11:02 [PATCH] iio: mma8452: add support for MMA8451Q Martin Kepplinger
2016-01-14 11:15 ` kbuild test robot
@ 2016-01-14 11:45 ` Peter Meerwald-Stadler
2016-01-14 12:03 ` Martin Kepplinger
1 sibling, 1 reply; 6+ messages in thread
From: Peter Meerwald-Stadler @ 2016-01-14 11:45 UTC (permalink / raw)
To: Martin Kepplinger
Cc: jic23, knaack.h, lars, christoph.muellner, mfuzzey, linux-iio,
linux-kernel, Martin Kepplinger
> 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
comments below
> Signed-off-by: Martin Kepplinger <martin.kepplinger@theobroma-systems.com>
> Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
> ---
>
> This applies on top of
> [PATCH v5] iio: mma8452: add freefall detection for Freescale's accelerometers
> which should be in good shape (I think it already is) and accepted before this.
>
>
> this is sent early for review, just for you to know what to expect for v4.6.
>
> thanks
> martin
>
>
> .../devicetree/bindings/iio/accel/mma8452.txt | 4 +-
> drivers/iio/accel/Kconfig | 2 +-
> drivers/iio/accel/mma8452.c | 46 ++++++++++++++++++----
> 3 files changed, 42 insertions(+), 10 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..0e02c36 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: MMA8341Q, MMA8452Q, MMA8453Q, MMA8652FC, MMA8653FC.
should be MMA8451Q, not 8341
>
> 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 820a8a3..b46694e 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,8 +86,9 @@
> #define MMA8452_INT_FF_MT BIT(2)
> #define MMA8452_INT_TRANS BIT(5)
>
> -#define MMA8452_DEVICE_ID 0x2a
> -#define MMA8453_DEVICE_ID 0x3a
> +#define MMA8451_DEVICE_ID 0x1a
> +#define MMA8452_DEVICE_ID 0x2a
> +#define MMA8453_DEVICE_ID 0x3a
extra whitespace cleanup here
> #define MMA8652_DEVICE_ID 0x4a
> #define MMA8653_DEVICE_ID 0x5a
>
> @@ -937,6 +939,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),
> @@ -970,6 +980,7 @@ static const struct iio_chan_spec mma8653_channels[] = {
> };
>
> enum {
> + mma8451,
> mma8452,
> mma8453,
> mma8652,
> @@ -977,17 +988,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
this changes a tab to whitespace, probably not intended
> */
> + .mma_scales = { {0, 2394}, {0, 4788}, {0, 9576} },
> + .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} },
the first scale is 9577 here, the last scale for 8451 is 9576 -- probably
this should be the same value (rounding issue?)
> .ev_cfg = MMA8452_TRANSIENT_CFG,
> .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE,
> @@ -1168,6 +1196,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] },
> @@ -1204,6 +1233,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:
>
--
Peter Meerwald-Stadler
+43-664-2444418 (mobile)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: mma8452: add support for MMA8451Q
2016-01-14 11:45 ` Peter Meerwald-Stadler
@ 2016-01-14 12:03 ` Martin Kepplinger
2016-01-16 12:10 ` Jonathan Cameron
0 siblings, 1 reply; 6+ messages in thread
From: Martin Kepplinger @ 2016-01-14 12:03 UTC (permalink / raw)
To: Peter Meerwald-Stadler
Cc: jic23, knaack.h, lars, christoph.muellner, mfuzzey, linux-iio,
linux-kernel, Martin Kepplinger
Am 2016-01-14 um 12:45 schrieb Peter Meerwald-Stadler:
>
>> 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
>
> comments below
>
>> Signed-off-by: Martin Kepplinger <martin.kepplinger@theobroma-systems.com>
>> Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
>> ---
>>
>> This applies on top of
>> [PATCH v5] iio: mma8452: add freefall detection for Freescale's accelerometers
>> which should be in good shape (I think it already is) and accepted before this.
>>
>>
>> this is sent early for review, just for you to know what to expect for v4.6.
>>
>> thanks
>> martin
>>
>>
>> .../devicetree/bindings/iio/accel/mma8452.txt | 4 +-
>> drivers/iio/accel/Kconfig | 2 +-
>> drivers/iio/accel/mma8452.c | 46 ++++++++++++++++++----
>> 3 files changed, 42 insertions(+), 10 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..0e02c36 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: MMA8341Q, MMA8452Q, MMA8453Q, MMA8652FC, MMA8653FC.
>
> should be MMA8451Q, not 8341
>
thanks!
>>
>> 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 820a8a3..b46694e 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,8 +86,9 @@
>> #define MMA8452_INT_FF_MT BIT(2)
>> #define MMA8452_INT_TRANS BIT(5)
>>
>> -#define MMA8452_DEVICE_ID 0x2a
>> -#define MMA8453_DEVICE_ID 0x3a
>> +#define MMA8451_DEVICE_ID 0x1a
>> +#define MMA8452_DEVICE_ID 0x2a
>> +#define MMA8453_DEVICE_ID 0x3a
>
> extra whitespace cleanup here
>
Isn't it ok to stash it in here in this case?
>> #define MMA8652_DEVICE_ID 0x4a
>> #define MMA8653_DEVICE_ID 0x5a
>>
>> @@ -937,6 +939,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),
>> @@ -970,6 +980,7 @@ static const struct iio_chan_spec mma8653_channels[] = {
>> };
>>
>> enum {
>> + mma8451,
>> mma8452,
>> mma8453,
>> mma8652,
>> @@ -977,17 +988,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
>
> this changes a tab to whitespace, probably not intended
>
thanks!
>> */
>> + .mma_scales = { {0, 2394}, {0, 4788}, {0, 9576} },
>> + .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} },
>
> the first scale is 9577 here, the last scale for 8451 is 9576 -- probably
> this should be the same value (rounding issue?)
>
rounding issue, yes. I'll change it to 9577. The rest is ok.
Thanks Peter, for the good review!
>> .ev_cfg = MMA8452_TRANSIENT_CFG,
>> .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE,
>> @@ -1168,6 +1196,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] },
>> @@ -1204,6 +1233,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:
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iio: mma8452: add support for MMA8451Q
2016-01-14 12:03 ` Martin Kepplinger
@ 2016-01-16 12:10 ` Jonathan Cameron
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2016-01-16 12:10 UTC (permalink / raw)
To: Martin Kepplinger, Peter Meerwald-Stadler
Cc: knaack.h, lars, christoph.muellner, mfuzzey, linux-iio,
linux-kernel, Martin Kepplinger
On 14/01/16 12:03, Martin Kepplinger wrote:
> Am 2016-01-14 um 12:45 schrieb Peter Meerwald-Stadler:
>>
>>> 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
>>
>> comments below
>>
>>> Signed-off-by: Martin Kepplinger <martin.kepplinger@theobroma-systems.com>
>>> Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com>
>>> ---
>>>
>>> This applies on top of
>>> [PATCH v5] iio: mma8452: add freefall detection for Freescale's accelerometers
>>> which should be in good shape (I think it already is) and accepted before this.
>>>
>>>
>>> this is sent early for review, just for you to know what to expect for v4.6.
>>>
>>> thanks
>>> martin
>>>
>>>
>>> .../devicetree/bindings/iio/accel/mma8452.txt | 4 +-
>>> drivers/iio/accel/Kconfig | 2 +-
>>> drivers/iio/accel/mma8452.c | 46 ++++++++++++++++++----
>>> 3 files changed, 42 insertions(+), 10 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..0e02c36 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: MMA8341Q, MMA8452Q, MMA8453Q, MMA8652FC, MMA8653FC.
>>
>> should be MMA8451Q, not 8341
>>
>
> thanks!
>
>>>
>>> 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 820a8a3..b46694e 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,8 +86,9 @@
>>> #define MMA8452_INT_FF_MT BIT(2)
>>> #define MMA8452_INT_TRANS BIT(5)
>>>
>>> -#define MMA8452_DEVICE_ID 0x2a
>>> -#define MMA8453_DEVICE_ID 0x3a
>>> +#define MMA8451_DEVICE_ID 0x1a
>>> +#define MMA8452_DEVICE_ID 0x2a
>>> +#define MMA8453_DEVICE_ID 0x3a
>>
>> extra whitespace cleanup here
>>
>
> Isn't it ok to stash it in here in this case?
Definitely preferable to do it as a precursor patch.
Always best to keep the trivial fixes separate as if nothing else reviewers can read those
whilst half asleep ;)
>
>>> #define MMA8652_DEVICE_ID 0x4a
>>> #define MMA8653_DEVICE_ID 0x5a
>>>
>>> @@ -937,6 +939,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),
>>> @@ -970,6 +980,7 @@ static const struct iio_chan_spec mma8653_channels[] = {
>>> };
>>>
>>> enum {
>>> + mma8451,
>>> mma8452,
>>> mma8453,
>>> mma8652,
>>> @@ -977,17 +988,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
>>
>> this changes a tab to whitespace, probably not intended
>>
>
> thanks!
>
>>> */
>>> + .mma_scales = { {0, 2394}, {0, 4788}, {0, 9576} },
>>> + .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} },
>>
>> the first scale is 9577 here, the last scale for 8451 is 9576 -- probably
>> this should be the same value (rounding issue?)
>>
>
> rounding issue, yes. I'll change it to 9577. The rest is ok.
>
> Thanks Peter, for the good review!
>
>>> .ev_cfg = MMA8452_TRANSIENT_CFG,
>>> .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE,
>>> @@ -1168,6 +1196,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] },
>>> @@ -1204,6 +1233,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:
>>>
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-01-16 12:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-14 11:02 [PATCH] iio: mma8452: add support for MMA8451Q Martin Kepplinger
2016-01-14 11:15 ` kbuild test robot
2016-01-14 11:19 ` Martin Kepplinger
2016-01-14 11:45 ` Peter Meerwald-Stadler
2016-01-14 12:03 ` Martin Kepplinger
2016-01-16 12:10 ` Jonathan Cameron
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).