* [PATCH 1/3] iio: gyro: ADXRS450: Add missing scale attributes
@ 2011-12-14 12:12 michael.hennerich
2011-12-14 12:12 ` [PATCH 2/3] iio: gyro: ADXRS450: Add missing read support for calibbias attribute michael.hennerich
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: michael.hennerich @ 2011-12-14 12:12 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, device-drivers-devel, drivers, Michael Hennerich
From: Michael Hennerich <michael.hennerich@analog.com>
Add missing scale attributes.
Temperature data is presented as 10-bit, twos complement number.
Therefore use singed and shift accordingly.
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
---
drivers/staging/iio/gyro/adxrs450_core.c | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c
index e832aea..9d33628 100644
--- a/drivers/staging/iio/gyro/adxrs450_core.c
+++ b/drivers/staging/iio/gyro/adxrs450_core.c
@@ -263,7 +263,7 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev,
{
int ret;
s16 t;
- u16 ut;
+
switch (mask) {
case 0:
switch (chan->type) {
@@ -276,10 +276,10 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev,
break;
case IIO_TEMP:
ret = adxrs450_spi_read_reg_16(indio_dev,
- ADXRS450_TEMP1, &ut);
+ ADXRS450_TEMP1, &t);
if (ret)
break;
- *val = ut;
+ *val = (t >> 6) + 225;
ret = IIO_VAL_INT;
break;
default:
@@ -287,6 +287,20 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev,
break;
}
break;
+ case IIO_CHAN_INFO_SCALE:
+ switch (chan->type) {
+ case IIO_ANGL_VEL:
+ *val = 0;
+ *val2 = 218166;
+ return IIO_VAL_INT_PLUS_NANO;
+ case IIO_TEMP:
+ *val = 200;
+ *val2 = 0;
+ return IIO_VAL_INT;
+ default:
+ return -EINVAL;
+ }
+ break;
case IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW:
ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_QUAD1, &t);
if (ret)
@@ -308,11 +322,13 @@ static const struct iio_chan_spec adxrs450_channels[] = {
.modified = 1,
.channel2 = IIO_MOD_Z,
.info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT,
+ IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
}, {
.type = IIO_TEMP,
.indexed = 1,
.channel = 0,
+ .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
}
};
--
1.7.0.4
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 2/3] iio: gyro: ADXRS450: Add missing read support for calibbias attribute 2011-12-14 12:12 [PATCH 1/3] iio: gyro: ADXRS450: Add missing scale attributes michael.hennerich @ 2011-12-14 12:12 ` michael.hennerich 2011-12-14 14:17 ` J.I. Cameron 2011-12-14 12:12 ` [PATCH 3/3] iio: gyro: ADXRS450: Add support for ADXRS453 Digital Gyroscope michael.hennerich 2011-12-14 14:17 ` [PATCH 1/3] iio: gyro: ADXRS450: Add missing scale attributes J.I. Cameron 2 siblings, 1 reply; 8+ messages in thread From: michael.hennerich @ 2011-12-14 12:12 UTC (permalink / raw) To: jic23; +Cc: linux-iio, device-drivers-devel, drivers, Michael Hennerich From: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> --- drivers/staging/iio/gyro/adxrs450_core.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c index 9d33628..a146d55 100644 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ b/drivers/staging/iio/gyro/adxrs450_core.c @@ -308,6 +308,13 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev, *val = t; ret = IIO_VAL_INT; break; + case IIO_CHAN_INFO_CALIBBIAS: + ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_DNC1, &t); + if (ret) + break; + *val = t; + ret = IIO_VAL_INT; + break; default: ret = -EINVAL; break; -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] iio: gyro: ADXRS450: Add missing read support for calibbias attribute 2011-12-14 12:12 ` [PATCH 2/3] iio: gyro: ADXRS450: Add missing read support for calibbias attribute michael.hennerich @ 2011-12-14 14:17 ` J.I. Cameron 0 siblings, 0 replies; 8+ messages in thread From: J.I. Cameron @ 2011-12-14 14:17 UTC (permalink / raw) To: michael.hennerich; +Cc: jic23, linux-iio, device-drivers-devel, drivers On Dec 14 2011, michael.hennerich@analog.com wrote: >From: Michael Hennerich <michael.hennerich@analog.com> > > >Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Acked-by: Jonathan Cameron <jic23@kernel.org> >--- > drivers/staging/iio/gyro/adxrs450_core.c | 7 +++++++ > 1 files changed, 7 insertions(+), 0 deletions(-) > >diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/ii= o/gyro/adxrs450_core.c >index 9d33628..a146d55 100644 >--- a/drivers/staging/iio/gyro/adxrs450_core.c >+++ b/drivers/staging/iio/gyro/adxrs450_core.c >@@ -308,6 +308,13 @@ static int adxrs450_read_raw(struct iio_dev *indio_de= v, > =09=09*val =3D t; > =09=09ret =3D IIO_VAL_INT; > =09=09break; >+=09case IIO_CHAN_INFO_CALIBBIAS: >+=09=09ret =3D adxrs450_spi_read_reg_16(indio_dev, ADXRS450_DNC1, &t); >+=09=09if (ret) >+=09=09=09break; >+=09=09*val =3D t; >+=09=09ret =3D IIO_VAL_INT; >+=09=09break; > =09default: > =09=09ret =3D -EINVAL; > =09=09break; > ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3] iio: gyro: ADXRS450: Add support for ADXRS453 Digital Gyroscope 2011-12-14 12:12 [PATCH 1/3] iio: gyro: ADXRS450: Add missing scale attributes michael.hennerich 2011-12-14 12:12 ` [PATCH 2/3] iio: gyro: ADXRS450: Add missing read support for calibbias attribute michael.hennerich @ 2011-12-14 12:12 ` michael.hennerich 2011-12-14 14:14 ` J.I. Cameron 2011-12-14 14:17 ` [PATCH 1/3] iio: gyro: ADXRS450: Add missing scale attributes J.I. Cameron 2 siblings, 1 reply; 8+ messages in thread From: michael.hennerich @ 2011-12-14 12:12 UTC (permalink / raw) To: jic23; +Cc: linux-iio, device-drivers-devel, drivers, Michael Hennerich From: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> --- drivers/staging/iio/gyro/Kconfig | 6 +- drivers/staging/iio/gyro/adxrs450.h | 5 ++ drivers/staging/iio/gyro/adxrs450_core.c | 60 +++++++++++++++++++++--------- 3 files changed, 50 insertions(+), 21 deletions(-) diff --git a/drivers/staging/iio/gyro/Kconfig b/drivers/staging/iio/gyro/Kconfig index 22aea5b..ea295b2 100644 --- a/drivers/staging/iio/gyro/Kconfig +++ b/drivers/staging/iio/gyro/Kconfig @@ -37,11 +37,11 @@ config ADIS16260 will be called adis16260. config ADXRS450 - tristate "Analog Devices ADXRS450 Digital Output Gyroscope SPI driver" + tristate "Analog Devices ADXRS450/3 Digital Output Gyroscope SPI driver" depends on SPI help - Say yes here to build support for Analog Devices ADXRS450 programmable - digital output gyroscope. + Say yes here to build support for Analog Devices ADXRS450 and ADXRS453 + programmable digital output gyroscope. This driver can also be built as a module. If so, the module will be called adxrs450. diff --git a/drivers/staging/iio/gyro/adxrs450.h b/drivers/staging/iio/gyro/adxrs450.h index b6b6828..af0c870 100644 --- a/drivers/staging/iio/gyro/adxrs450.h +++ b/drivers/staging/iio/gyro/adxrs450.h @@ -39,6 +39,11 @@ #define ADXRS450_GET_ST(a) ((a >> 26) & 0x3) +enum { + ID_ADXRS450, + ID_ADXRS453, +}; + /** * struct adxrs450_state - device instance specific data * @us: actual spi_device diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c index a146d55..61690e2 100644 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ b/drivers/staging/iio/gyro/adxrs450_core.c @@ -1,5 +1,5 @@ /* - * ADXRS450 Digital Output Gyroscope Driver + * ADXRS450/ADXRS453 Digital Output Gyroscope Driver * * Copyright 2011 Analog Devices Inc. * @@ -323,20 +323,36 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev, return ret; } -static const struct iio_chan_spec adxrs450_channels[] = { - { - .type = IIO_ANGL_VEL, - .modified = 1, - .channel2 = IIO_MOD_Z, - .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | - IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT | - IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - }, { - .type = IIO_TEMP, - .indexed = 1, - .channel = 0, - .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - } +static const struct iio_chan_spec adxrs450_channels[2][2] = { + [ID_ADXRS450] = { + { + .type = IIO_ANGL_VEL, + .modified = 1, + .channel2 = IIO_MOD_Z, + .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | + IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT | + IIO_CHAN_INFO_SCALE_SEPARATE_BIT, + }, { + .type = IIO_TEMP, + .indexed = 1, + .channel = 0, + .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT, + } + }, + [ID_ADXRS453] = { + { + .type = IIO_ANGL_VEL, + .modified = 1, + .channel2 = IIO_MOD_Z, + .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT | + IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT, + }, { + .type = IIO_TEMP, + .indexed = 1, + .channel = 0, + .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT, + } + }, }; static const struct iio_info adxrs450_info = { @@ -366,7 +382,8 @@ static int __devinit adxrs450_probe(struct spi_device *spi) indio_dev->dev.parent = &spi->dev; indio_dev->info = &adxrs450_info; indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->channels = adxrs450_channels; + indio_dev->channels = + adxrs450_channels[spi_get_device_id(spi)->driver_data]; indio_dev->num_channels = ARRAY_SIZE(adxrs450_channels); indio_dev->name = spi->dev.driver->name; @@ -396,6 +413,13 @@ static int adxrs450_remove(struct spi_device *spi) return 0; } +static const struct spi_device_id adxrs450_id[] = { + {"adxrs450", ID_ADXRS450}, + {"adxrs453", ID_ADXRS453}, + {} +}; +MODULE_DEVICE_TABLE(spi, adxrs450_id); + static struct spi_driver adxrs450_driver = { .driver = { .name = "adxrs450", @@ -403,6 +427,7 @@ static struct spi_driver adxrs450_driver = { }, .probe = adxrs450_probe, .remove = __devexit_p(adxrs450_remove), + .id_table = adxrs450_id, }; static __init int adxrs450_init(void) @@ -418,6 +443,5 @@ static __exit void adxrs450_exit(void) module_exit(adxrs450_exit); MODULE_AUTHOR("Cliff Cai <cliff.cai@xxxxxxxxxx>"); -MODULE_DESCRIPTION("Analog Devices ADXRS450 Gyroscope SPI driver"); +MODULE_DESCRIPTION("Analog Devices ADXRS450/ADXRS453 Gyroscope SPI driver"); MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("spi:adxrs450"); -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] iio: gyro: ADXRS450: Add support for ADXRS453 Digital Gyroscope 2011-12-14 12:12 ` [PATCH 3/3] iio: gyro: ADXRS450: Add support for ADXRS453 Digital Gyroscope michael.hennerich @ 2011-12-14 14:14 ` J.I. Cameron 2011-12-14 15:06 ` Hennerich, Michael 0 siblings, 1 reply; 8+ messages in thread From: J.I. Cameron @ 2011-12-14 14:14 UTC (permalink / raw) To: michael.hennerich; +Cc: jic23, linux-iio, device-drivers-devel, drivers Mostly fine, but why does the adxrs453 not have a scale associated with the gyro readings and the adxrs450 does? Also, just out curiosity what is the difference between these two parts? I'm not finding it obvious from the website :) > >Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> >--- > drivers/staging/iio/gyro/Kconfig | 6 +- > drivers/staging/iio/gyro/adxrs450.h | 5 ++ > drivers/staging/iio/gyro/adxrs450_core.c | 60 +++++++++++++++++++++--------- > 3 files changed, 50 insertions(+), 21 deletions(-) > >diff --git a/drivers/staging/iio/gyro/Kconfig b/drivers/staging/iio/gyro/Kconfig >index 22aea5b..ea295b2 100644 >--- a/drivers/staging/iio/gyro/Kconfig >+++ b/drivers/staging/iio/gyro/Kconfig >@@ -37,11 +37,11 @@ config ADIS16260 > will be called adis16260. > > config ADXRS450 >- tristate "Analog Devices ADXRS450 Digital Output Gyroscope SPI driver" >+ tristate "Analog Devices ADXRS450/3 Digital Output Gyroscope SPI driver" > depends on SPI > help >- Say yes here to build support for Analog Devices ADXRS450 programmable >- digital output gyroscope. >+ Say yes here to build support for Analog Devices ADXRS450 and ADXRS453 >+ programmable digital output gyroscope. > > This driver can also be built as a module. If so, the module > will be called adxrs450. >diff --git a/drivers/staging/iio/gyro/adxrs450.h b/drivers/staging/iio/gyro/adxrs450.h >index b6b6828..af0c870 100644 >--- a/drivers/staging/iio/gyro/adxrs450.h >+++ b/drivers/staging/iio/gyro/adxrs450.h >@@ -39,6 +39,11 @@ > > #define ADXRS450_GET_ST(a) ((a >> 26) & 0x3) > >+enum { >+ ID_ADXRS450, >+ ID_ADXRS453, >+}; >+ > /** > * struct adxrs450_state - device instance specific data > * @us: actual spi_device >diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c >index a146d55..61690e2 100644 >--- a/drivers/staging/iio/gyro/adxrs450_core.c >+++ b/drivers/staging/iio/gyro/adxrs450_core.c >@@ -1,5 +1,5 @@ > /* >- * ADXRS450 Digital Output Gyroscope Driver >+ * ADXRS450/ADXRS453 Digital Output Gyroscope Driver > * > * Copyright 2011 Analog Devices Inc. > * >@@ -323,20 +323,36 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev, > return ret; > } > >-static const struct iio_chan_spec adxrs450_channels[] = { >- { >- .type = IIO_ANGL_VEL, >- .modified = 1, >- .channel2 = IIO_MOD_Z, >- .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | >- IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT | >- IIO_CHAN_INFO_SCALE_SEPARATE_BIT, >- }, { >- .type = IIO_TEMP, >- .indexed = 1, >- .channel = 0, >- .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT, >- } >+static const struct iio_chan_spec adxrs450_channels[2][2] = { >+ [ID_ADXRS450] = { >+ { >+ .type = IIO_ANGL_VEL, >+ .modified = 1, >+ .channel2 = IIO_MOD_Z, >+ .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | >+ IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT | >+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT, >+ }, { >+ .type = IIO_TEMP, >+ .indexed = 1, >+ .channel = 0, >+ .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT, >+ } >+ }, >+ [ID_ADXRS453] = { >+ { >+ .type = IIO_ANGL_VEL, >+ .modified = 1, >+ .channel2 = IIO_MOD_Z, >+ .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT | >+ IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT, >+ }, { >+ .type = IIO_TEMP, >+ .indexed = 1, >+ .channel = 0, >+ .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT, >+ } >+ }, > }; > > static const struct iio_info adxrs450_info = { >@@ -366,7 +382,8 @@ static int __devinit adxrs450_probe(struct spi_device *spi) > indio_dev->dev.parent = &spi->dev; > indio_dev->info = &adxrs450_info; > indio_dev->modes = INDIO_DIRECT_MODE; >- indio_dev->channels = adxrs450_channels; >+ indio_dev->channels = >+ adxrs450_channels[spi_get_device_id(spi)->driver_data]; > indio_dev->num_channels = ARRAY_SIZE(adxrs450_channels); > indio_dev->name = spi->dev.driver->name; > >@@ -396,6 +413,13 @@ static int adxrs450_remove(struct spi_device *spi) > return 0; > } > >+static const struct spi_device_id adxrs450_id[] = { >+ {"adxrs450", ID_ADXRS450}, >+ {"adxrs453", ID_ADXRS453}, >+ {} >+}; >+MODULE_DEVICE_TABLE(spi, adxrs450_id); >+ > static struct spi_driver adxrs450_driver = { > .driver = { > .name = "adxrs450", >@@ -403,6 +427,7 @@ static struct spi_driver adxrs450_driver = { > }, > .probe = adxrs450_probe, > .remove = __devexit_p(adxrs450_remove), >+ .id_table = adxrs450_id, > }; > > static __init int adxrs450_init(void) >@@ -418,6 +443,5 @@ static __exit void adxrs450_exit(void) > module_exit(adxrs450_exit); > > MODULE_AUTHOR("Cliff Cai <cliff.cai@xxxxxxxxxx>"); >-MODULE_DESCRIPTION("Analog Devices ADXRS450 Gyroscope SPI driver"); >+MODULE_DESCRIPTION("Analog Devices ADXRS450/ADXRS453 Gyroscope SPI driver"); > MODULE_LICENSE("GPL v2"); >-MODULE_ALIAS("spi:adxrs450"); > ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH 3/3] iio: gyro: ADXRS450: Add support for ADXRS453 Digital Gyroscope 2011-12-14 14:14 ` J.I. Cameron @ 2011-12-14 15:06 ` Hennerich, Michael 2011-12-14 17:07 ` Jonathan Cameron 0 siblings, 1 reply; 8+ messages in thread From: Hennerich, Michael @ 2011-12-14 15:06 UTC (permalink / raw) To: J.I. Cameron Cc: jic23@kernel.org, linux-iio@vger.kernel.org, device-drivers-devel@blackfin.uclinux.org, Drivers J.I. Cameron wrote on 2011-12-14: > Mostly fine, but why does the adxrs453 not have a scale associated with > the gyro readings and the adxrs450 does? Please see again - both have a scale associated with the gyro readings. The difference is that the ADXRS453 doesn't have the IIO_CHAN_INFO_CALIBBIA= S. > > Also, just out curiosity what is the difference between these two parts? > I'm not finding it obvious from the website :) Honestly - I was asking me the same thing. But from a functional point of view the only difference I found was the mis= sing dynamic null correction feature on the ADXRS453. (exposed as CALIBBIAS) In addition there are slightly different datasheet specifications. Regards, Michael >> >> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> --- >> drivers/staging/iio/gyro/Kconfig | 6 +- >> drivers/staging/iio/gyro/adxrs450.h | 5 ++ >> drivers/staging/iio/gyro/adxrs450_core.c | 60 >> +++++++++++++++++++++--------- 3 files changed, 50 insertions(+), 21 >> deletions(-) >> >> diff --git a/drivers/staging/iio/gyro/Kconfig >> b/drivers/staging/iio/gyro/Kconfig index 22aea5b..ea295b2 100644 --- >> a/drivers/staging/iio/gyro/Kconfig +++ >> b/drivers/staging/iio/gyro/Kconfig @@ -37,11 +37,11 @@ config ADIS16260 >> will be called adis16260. >> >> config ADXRS450 - tristate "Analog Devices ADXRS450 Digital Output >> Gyroscope SPI driver" + tristate "Analog Devices ADXRS450/3 Digital >> Output Gyroscope SPI driver" depends on SPI help - Say yes h= ere to >> build support for Analog Devices ADXRS450 programmable - digital >> output gyroscope. + Say yes here to build support for Analog Devices >> ADXRS450 and ADXRS453 + programmable digital output gyroscope. >> >> This driver can also be built as a module. If so, the module >> will be called adxrs450. diff --git >> a/drivers/staging/iio/gyro/adxrs450.h >> b/drivers/staging/iio/gyro/adxrs450.h index b6b6828..af0c870 100644 --- >> a/drivers/staging/iio/gyro/adxrs450.h +++ >> b/drivers/staging/iio/gyro/adxrs450.h @@ -39,6 +39,11 @@ >> >> #define ADXRS450_GET_ST(a) ((a >> 26) & 0x3) >> >> +enum { >> + ID_ADXRS450, >> + ID_ADXRS453, >> +}; >> + >> /** >> * struct adxrs450_state - device instance specific data >> * @us: actual spi_device >> diff --git a/drivers/staging/iio/gyro/adxrs450_core.c >> b/drivers/staging/iio/gyro/adxrs450_core.c index a146d55..61690e2 >> 100644 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ >> b/drivers/staging/iio/gyro/adxrs450_core.c @@ -1,5 +1,5 @@ /* - * >> ADXRS450 Digital Output Gyroscope Driver + * ADXRS450/ADXRS453 Digital >> Output Gyroscope Driver >> * >> * Copyright 2011 Analog Devices Inc. >> * >> @@ -323,20 +323,36 @@ static int adxrs450_read_raw(struct iio_dev >> *indio_dev, return ret; } >> >> -static const struct iio_chan_spec adxrs450_channels[] =3D { - { - = .type >> =3D IIO_ANGL_VEL, - .modified =3D 1, - .channe= l2 =3D IIO_MOD_Z, >> - .info_mask =3D IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | >> - IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT | >> - IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - }, { - .ty= pe =3D IIO_TEMP, >> - .indexed =3D 1, - .channel =3D 0, - .info_m= ask =3D >> IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - } +static const struct >> iio_chan_spec adxrs450_channels[2][2] =3D { + [ID_ADXRS450] =3D { + = { >> + .type =3D IIO_ANGL_VEL, + .modified= =3D 1, + .channel2 =3D IIO_MOD_Z, >> + .info_mask =3D IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT= | >> + IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BI= T | >> + IIO_CHAN_INFO_SCALE_SEPARATE_BIT, + }, = { + .type =3D IIO_TEMP, >> + .indexed =3D 1, + .channel =3D 0, += .info_mask =3D >> IIO_CHAN_INFO_SCALE_SEPARATE_BIT, + } + }, + [ID_ADXRS45= 3] =3D { + { >> + .type =3D IIO_ANGL_VEL, + .modified= =3D 1, + .channel2 =3D IIO_MOD_Z, >> + .info_mask =3D IIO_CHAN_INFO_SCALE_SEPARATE_BIT | >> + IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BI= T, + }, { >> + .type =3D IIO_TEMP, + .indexed = =3D 1, + .channel =3D 0, >> + .info_mask =3D IIO_CHAN_INFO_SCALE_SEPARATE_BIT, + = } + }, }; >> >> static const struct iio_info adxrs450_info =3D { @@ -366,7 +382,8 @@ >> static int __devinit adxrs450_probe(struct spi_device *spi) >> indio_dev->dev.parent =3D &spi->dev; indio_dev->info =3D &adxr= s450_info; >> indio_dev->modes =3D INDIO_DIRECT_MODE; - indio_dev->channels =3D >> adxrs450_channels; + indio_dev->channels =3D >> + adxrs450_channels[spi_get_device_id(spi)->driver_data]; >> indio_dev->num_channels =3D ARRAY_SIZE(adxrs450_channels); >> indio_dev->name =3D spi->dev.driver->name; >> >> @@ -396,6 +413,13 @@ static int adxrs450_remove(struct spi_device *spi) >> return 0; } >> >> +static const struct spi_device_id adxrs450_id[] =3D { >> + {"adxrs450", ID_ADXRS450}, >> + {"adxrs453", ID_ADXRS453}, >> + {} >> +}; >> +MODULE_DEVICE_TABLE(spi, adxrs450_id); >> + >> static struct spi_driver adxrs450_driver =3D { >> .driver =3D { >> .name =3D "adxrs450", >> @@ -403,6 +427,7 @@ static struct spi_driver adxrs450_driver =3D { >> }, >> .probe =3D adxrs450_probe, >> .remove =3D __devexit_p(adxrs450_remove), >> + .id_table =3D adxrs450_id, >> }; >> >> static __init int adxrs450_init(void) >> @@ -418,6 +443,5 @@ static __exit void adxrs450_exit(void) >> module_exit(adxrs450_exit); >> >> MODULE_AUTHOR("Cliff Cai <cliff.cai@xxxxxxxxxx>"); >> -MODULE_DESCRIPTION("Analog Devices ADXRS450 Gyroscope SPI driver"); >> +MODULE_DESCRIPTION("Analog Devices ADXRS450/ADXRS453 Gyroscope SPI >> driver"); MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("spi:adxrs450"); >> Greetings, Michael -- Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar= garet Seif ^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH 3/3] iio: gyro: ADXRS450: Add support for ADXRS453 Digital Gyroscope 2011-12-14 15:06 ` Hennerich, Michael @ 2011-12-14 17:07 ` Jonathan Cameron 0 siblings, 0 replies; 8+ messages in thread From: Jonathan Cameron @ 2011-12-14 17:07 UTC (permalink / raw) To: Hennerich, Michael Cc: jic23@kernel.org, linux-iio@vger.kernel.org, device-drivers-devel@blackfin.uclinux.org, Drivers "Hennerich, Michael" <Michael.Hennerich@analog.com> wrote: >J.I. Cameron wrote on 2011-12-14: >> Mostly fine, but why does the adxrs453 not have a scale associated >with >> the gyro readings and the adxrs450 does? > >Please see again - both have a scale associated with the gyro readings. >The difference is that the ADXRS453 doesn't have the >IIO_CHAN_INFO_CALIBBIAS. Ah my missread. Feel free to add my ack. > >> >> Also, just out curiosity what is the difference between these two >parts? >> I'm not finding it obvious from the website :) > >Honestly - I was asking me the same thing. > >But from a functional point of view the only difference I found was the >missing >dynamic null correction feature on the ADXRS453. (exposed as CALIBBIAS) >In addition there are slightly different datasheet specifications. > >Regards, >Michael > > >>> >>> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> --- >>> drivers/staging/iio/gyro/Kconfig | 6 +- >>> drivers/staging/iio/gyro/adxrs450.h | 5 ++ >>> drivers/staging/iio/gyro/adxrs450_core.c | 60 >>> +++++++++++++++++++++--------- 3 files changed, 50 insertions(+), 21 >>> deletions(-) >>> >>> diff --git a/drivers/staging/iio/gyro/Kconfig >>> b/drivers/staging/iio/gyro/Kconfig index 22aea5b..ea295b2 100644 --- >>> a/drivers/staging/iio/gyro/Kconfig +++ >>> b/drivers/staging/iio/gyro/Kconfig @@ -37,11 +37,11 @@ config >ADIS16260 >>> will be called adis16260. >>> >>> config ADXRS450 - tristate "Analog Devices ADXRS450 Digital >Output >>> Gyroscope SPI driver" + tristate "Analog Devices ADXRS450/3 >Digital >>> Output Gyroscope SPI driver" depends on SPI help - Say >yes here to >>> build support for Analog Devices ADXRS450 programmable - >digital >>> output gyroscope. + Say yes here to build support for Analog >Devices >>> ADXRS450 and ADXRS453 + programmable digital output >gyroscope. >>> >>> This driver can also be built as a module. If so, the module >>> will be called adxrs450. diff --git >>> a/drivers/staging/iio/gyro/adxrs450.h >>> b/drivers/staging/iio/gyro/adxrs450.h index b6b6828..af0c870 100644 >--- >>> a/drivers/staging/iio/gyro/adxrs450.h +++ >>> b/drivers/staging/iio/gyro/adxrs450.h @@ -39,6 +39,11 @@ >>> >>> #define ADXRS450_GET_ST(a) ((a >> 26) & 0x3) >>> >>> +enum { >>> + ID_ADXRS450, >>> + ID_ADXRS453, >>> +}; >>> + >>> /** >>> * struct adxrs450_state - device instance specific data >>> * @us: actual spi_device >>> diff --git a/drivers/staging/iio/gyro/adxrs450_core.c >>> b/drivers/staging/iio/gyro/adxrs450_core.c index a146d55..61690e2 >>> 100644 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ >>> b/drivers/staging/iio/gyro/adxrs450_core.c @@ -1,5 +1,5 @@ /* - * >>> ADXRS450 Digital Output Gyroscope Driver + * ADXRS450/ADXRS453 >Digital >>> Output Gyroscope Driver >>> * >>> * Copyright 2011 Analog Devices Inc. >>> * >>> @@ -323,20 +323,36 @@ static int adxrs450_read_raw(struct iio_dev >>> *indio_dev, return ret; } >>> >>> -static const struct iio_chan_spec adxrs450_channels[] = { - { - > .type >>> = IIO_ANGL_VEL, - .modified = 1, - >.channel2 = IIO_MOD_Z, >>> - .info_mask = IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | >>> - IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT | >>> - IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - }, { - >.type = IIO_TEMP, >>> - .indexed = 1, - .channel = 0, - >.info_mask = >>> IIO_CHAN_INFO_SCALE_SEPARATE_BIT, - } +static const struct >>> iio_chan_spec adxrs450_channels[2][2] = { + [ID_ADXRS450] = { + > { >>> + .type = IIO_ANGL_VEL, + >.modified = 1, + .channel2 = IIO_MOD_Z, >>> + .info_mask = >IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | >>> + >IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT | >>> + IIO_CHAN_INFO_SCALE_SEPARATE_BIT, + >}, { + .type = IIO_TEMP, >>> + .indexed = 1, + .channel = 0, + > .info_mask = >>> IIO_CHAN_INFO_SCALE_SEPARATE_BIT, + } + }, + >[ID_ADXRS453] = { + { >>> + .type = IIO_ANGL_VEL, + >.modified = 1, + .channel2 = IIO_MOD_Z, >>> + .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT | >>> + >IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT, + }, { >>> + .type = IIO_TEMP, + >.indexed = 1, + .channel = 0, >>> + .info_mask = IIO_CHAN_INFO_SCALE_SEPARATE_BIT, >+ } + }, }; >>> >>> static const struct iio_info adxrs450_info = { @@ -366,7 +382,8 @@ >>> static int __devinit adxrs450_probe(struct spi_device *spi) >>> indio_dev->dev.parent = &spi->dev; indio_dev->info = >&adxrs450_info; >>> indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->channels = >>> adxrs450_channels; + indio_dev->channels = >>> + adxrs450_channels[spi_get_device_id(spi)->driver_data]; >>> indio_dev->num_channels = ARRAY_SIZE(adxrs450_channels); >>> indio_dev->name = spi->dev.driver->name; >>> >>> @@ -396,6 +413,13 @@ static int adxrs450_remove(struct spi_device >*spi) >>> return 0; } >>> >>> +static const struct spi_device_id adxrs450_id[] = { >>> + {"adxrs450", ID_ADXRS450}, >>> + {"adxrs453", ID_ADXRS453}, >>> + {} >>> +}; >>> +MODULE_DEVICE_TABLE(spi, adxrs450_id); >>> + >>> static struct spi_driver adxrs450_driver = { >>> .driver = { >>> .name = "adxrs450", >>> @@ -403,6 +427,7 @@ static struct spi_driver adxrs450_driver = { >>> }, >>> .probe = adxrs450_probe, >>> .remove = __devexit_p(adxrs450_remove), >>> + .id_table = adxrs450_id, >>> }; >>> >>> static __init int adxrs450_init(void) >>> @@ -418,6 +443,5 @@ static __exit void adxrs450_exit(void) >>> module_exit(adxrs450_exit); >>> >>> MODULE_AUTHOR("Cliff Cai <cliff.cai@xxxxxxxxxx>"); >>> -MODULE_DESCRIPTION("Analog Devices ADXRS450 Gyroscope SPI driver"); >>> +MODULE_DESCRIPTION("Analog Devices ADXRS450/ADXRS453 Gyroscope SPI >>> driver"); MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("spi:adxrs450"); >>> > >Greetings, >Michael > >-- >Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen >Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; >Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, >Margaret Seif -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] iio: gyro: ADXRS450: Add missing scale attributes 2011-12-14 12:12 [PATCH 1/3] iio: gyro: ADXRS450: Add missing scale attributes michael.hennerich 2011-12-14 12:12 ` [PATCH 2/3] iio: gyro: ADXRS450: Add missing read support for calibbias attribute michael.hennerich 2011-12-14 12:12 ` [PATCH 3/3] iio: gyro: ADXRS450: Add support for ADXRS453 Digital Gyroscope michael.hennerich @ 2011-12-14 14:17 ` J.I. Cameron 2 siblings, 0 replies; 8+ messages in thread From: J.I. Cameron @ 2011-12-14 14:17 UTC (permalink / raw) To: michael.hennerich; +Cc: jic23, linux-iio, device-drivers-devel, drivers On Dec 14 2011, michael.hennerich@analog.com wrote: >From: Michael Hennerich <michael.hennerich@analog.com> > >Add missing scale attributes. >Temperature data is presented as 10-bit, twos complement number. >Therefore use singed and shift accordingly. > >Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Acked-by: Jonathan Cameron <jic23@kernel.org> >--- > drivers/staging/iio/gyro/adxrs450_core.c | 24 ++++++++++++++++++++---- > 1 files changed, 20 insertions(+), 4 deletions(-) > >diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/ii= o/gyro/adxrs450_core.c >index e832aea..9d33628 100644 >--- a/drivers/staging/iio/gyro/adxrs450_core.c >+++ b/drivers/staging/iio/gyro/adxrs450_core.c >@@ -263,7 +263,7 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev= , > { > =09int ret; > =09s16 t; >-=09u16 ut; >+ > =09switch (mask) { > =09case 0: > =09=09switch (chan->type) { >@@ -276,10 +276,10 @@ static int adxrs450_read_raw(struct iio_dev *indio_d= ev, > =09=09=09break; > =09=09case IIO_TEMP: > =09=09=09ret =3D adxrs450_spi_read_reg_16(indio_dev, >-=09=09=09=09=09=09 ADXRS450_TEMP1, &ut); >+=09=09=09=09=09=09 ADXRS450_TEMP1, &t); > =09=09=09if (ret) > =09=09=09=09break; >-=09=09=09*val =3D ut; >+=09=09=09*val =3D (t >> 6) + 225; > =09=09=09ret =3D IIO_VAL_INT; > =09=09=09break; > =09=09default: >@@ -287,6 +287,20 @@ static int adxrs450_read_raw(struct iio_dev *indio_de= v, > =09=09=09break; > =09=09} > =09=09break; >+=09case IIO_CHAN_INFO_SCALE: >+=09=09switch (chan->type) { >+=09=09case IIO_ANGL_VEL: >+=09=09=09*val =3D 0; >+=09=09=09*val2 =3D 218166; >+=09=09=09return IIO_VAL_INT_PLUS_NANO; >+=09=09case IIO_TEMP: >+=09=09=09*val =3D 200; >+=09=09=09*val2 =3D 0; >+=09=09=09return IIO_VAL_INT; >+=09=09default: >+=09=09=09return -EINVAL; >+=09=09} >+=09=09break; > =09case IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW: > =09=09ret =3D adxrs450_spi_read_reg_16(indio_dev, ADXRS450_QUAD1, &t); > =09=09if (ret) >@@ -308,11 +322,13 @@ static const struct iio_chan_spec adxrs450_channels[= ] =3D { > =09=09.modified =3D 1, > =09=09.channel2 =3D IIO_MOD_Z, > =09=09.info_mask =3D IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | >-=09=09IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT, >+=09=09IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE_BIT | >+=09=09IIO_CHAN_INFO_SCALE_SEPARATE_BIT, > =09}, { > =09=09.type =3D IIO_TEMP, > =09=09.indexed =3D 1, > =09=09.channel =3D 0, >+=09=09.info_mask =3D IIO_CHAN_INFO_SCALE_SEPARATE_BIT, > =09} > }; >=20 > ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-12-14 17:07 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-12-14 12:12 [PATCH 1/3] iio: gyro: ADXRS450: Add missing scale attributes michael.hennerich 2011-12-14 12:12 ` [PATCH 2/3] iio: gyro: ADXRS450: Add missing read support for calibbias attribute michael.hennerich 2011-12-14 14:17 ` J.I. Cameron 2011-12-14 12:12 ` [PATCH 3/3] iio: gyro: ADXRS450: Add support for ADXRS453 Digital Gyroscope michael.hennerich 2011-12-14 14:14 ` J.I. Cameron 2011-12-14 15:06 ` Hennerich, Michael 2011-12-14 17:07 ` Jonathan Cameron 2011-12-14 14:17 ` [PATCH 1/3] iio: gyro: ADXRS450: Add missing scale attributes J.I. 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).