* [PATCH 1/3] dt-bindings: vendor-prefixes: Add Alps @ 2020-04-06 14:13 Nick Reitemeyer 2020-04-06 14:13 ` [PATCH 2/3] dt-bindings: magnetometer: ak8974: Add Alps hscdtd008a Nick Reitemeyer ` (3 more replies) 0 siblings, 4 replies; 12+ messages in thread From: Nick Reitemeyer @ 2020-04-06 14:13 UTC (permalink / raw) To: Jonathan Cameron Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio, Nick Reitemeyer, Stephan Gerhold, Linus Walleij, devicetree, Rob Herring, Mark Rutland Alps Electric Co., Ltd. is a japanese electronics company: https://www.alps.com/ Signed-off-by: Nick Reitemeyer <nick.reitemeyer@web.de> --- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml index 77fb3c453014..bbccd6cbbe73 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -59,6 +59,8 @@ patternProperties: description: Allwinner Technology Co., Ltd. "^alphascale,.*": description: AlphaScale Integrated Circuits Systems, Inc. + "^alps,.*": + description: Alps Electric Co., Ltd. "^altr,.*": description: Altera Corp. "^amarula,.*": -- 2.26.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/3] dt-bindings: magnetometer: ak8974: Add Alps hscdtd008a 2020-04-06 14:13 [PATCH 1/3] dt-bindings: vendor-prefixes: Add Alps Nick Reitemeyer @ 2020-04-06 14:13 ` Nick Reitemeyer 2020-04-13 22:23 ` Linus Walleij 2020-04-15 0:09 ` Rob Herring 2020-04-06 14:13 ` [PATCH 3/3] iio: magnetometer: ak8974: add " Nick Reitemeyer ` (2 subsequent siblings) 3 siblings, 2 replies; 12+ messages in thread From: Nick Reitemeyer @ 2020-04-06 14:13 UTC (permalink / raw) To: Jonathan Cameron Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio, Nick Reitemeyer, Stephan Gerhold, Linus Walleij, devicetree, Rob Herring, Mark Rutland Add binding documentation for the Alps HSCDTD008A, which is similar to the ak8974. Signed-off-by: Nick Reitemeyer <nick.reitemeyer@web.de> --- Documentation/devicetree/bindings/iio/magnetometer/ak8974.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/magnetometer/ak8974.txt b/Documentation/devicetree/bindings/iio/magnetometer/ak8974.txt index baecc4a85197..7f06eff3b504 100644 --- a/Documentation/devicetree/bindings/iio/magnetometer/ak8974.txt +++ b/Documentation/devicetree/bindings/iio/magnetometer/ak8974.txt @@ -2,7 +2,9 @@ Required properties: -- compatible : should be "asahi-kasei,ak8974" +- compatible: + * "asahi-kasei,ak8974" + * "alps,hscdtd008a" - reg : the I2C address of the magnetometer Optional properties: -- 2.26.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] dt-bindings: magnetometer: ak8974: Add Alps hscdtd008a 2020-04-06 14:13 ` [PATCH 2/3] dt-bindings: magnetometer: ak8974: Add Alps hscdtd008a Nick Reitemeyer @ 2020-04-13 22:23 ` Linus Walleij 2020-04-15 0:09 ` Rob Herring 1 sibling, 0 replies; 12+ messages in thread From: Linus Walleij @ 2020-04-13 22:23 UTC (permalink / raw) To: Nick Reitemeyer Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio, Stephan Gerhold, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, Rob Herring, Mark Rutland On Mon, Apr 6, 2020 at 4:23 PM Nick Reitemeyer <nick.reitemeyer@web.de> wrote: > Add binding documentation for the Alps HSCDTD008A, which is similar > to the ak8974. > > Signed-off-by: Nick Reitemeyer <nick.reitemeyer@web.de> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] dt-bindings: magnetometer: ak8974: Add Alps hscdtd008a 2020-04-06 14:13 ` [PATCH 2/3] dt-bindings: magnetometer: ak8974: Add Alps hscdtd008a Nick Reitemeyer 2020-04-13 22:23 ` Linus Walleij @ 2020-04-15 0:09 ` Rob Herring 2020-04-25 17:38 ` Jonathan Cameron 1 sibling, 1 reply; 12+ messages in thread From: Rob Herring @ 2020-04-15 0:09 UTC (permalink / raw) To: Nick Reitemeyer Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio, Nick Reitemeyer, Stephan Gerhold, Linus Walleij, devicetree, Mark Rutland On Mon, 6 Apr 2020 16:13:51 +0200, Nick Reitemeyer wrote: > > Add binding documentation for the Alps HSCDTD008A, which is similar > to the ak8974. > > Signed-off-by: Nick Reitemeyer <nick.reitemeyer@web.de> > --- > Documentation/devicetree/bindings/iio/magnetometer/ak8974.txt | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > Acked-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] dt-bindings: magnetometer: ak8974: Add Alps hscdtd008a 2020-04-15 0:09 ` Rob Herring @ 2020-04-25 17:38 ` Jonathan Cameron 0 siblings, 0 replies; 12+ messages in thread From: Jonathan Cameron @ 2020-04-25 17:38 UTC (permalink / raw) To: Rob Herring Cc: Nick Reitemeyer, Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio, Stephan Gerhold, Linus Walleij, devicetree, Mark Rutland On Tue, 14 Apr 2020 19:09:45 -0500 Rob Herring <robh@kernel.org> wrote: > On Mon, 6 Apr 2020 16:13:51 +0200, Nick Reitemeyer wrote: > > > > Add binding documentation for the Alps HSCDTD008A, which is similar > > to the ak8974. > > > > Signed-off-by: Nick Reitemeyer <nick.reitemeyer@web.de> > > --- > > Documentation/devicetree/bindings/iio/magnetometer/ak8974.txt | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > Acked-by: Rob Herring <robh@kernel.org> Applied to the togreg branch of iio.git. thanks, Jonathan ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] iio: magnetometer: ak8974: add Alps hscdtd008a 2020-04-06 14:13 [PATCH 1/3] dt-bindings: vendor-prefixes: Add Alps Nick Reitemeyer 2020-04-06 14:13 ` [PATCH 2/3] dt-bindings: magnetometer: ak8974: Add Alps hscdtd008a Nick Reitemeyer @ 2020-04-06 14:13 ` Nick Reitemeyer 2020-04-06 14:31 ` Stephan Gerhold 2020-04-13 22:25 ` Linus Walleij 2020-04-13 22:23 ` [PATCH 1/3] dt-bindings: vendor-prefixes: Add Alps Linus Walleij 2020-04-15 0:09 ` Rob Herring 3 siblings, 2 replies; 12+ messages in thread From: Nick Reitemeyer @ 2020-04-06 14:13 UTC (permalink / raw) To: Jonathan Cameron Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio, Nick Reitemeyer, Stephan Gerhold, Linus Walleij, devicetree, Rob Herring, Mark Rutland The hscdtd008a is similar to the AK8974: Only the whoami value and some registers are different. Signed-off-by: Nick Reitemeyer <nick.reitemeyer@web.de> --- drivers/iio/magnetometer/ak8974.c | 38 ++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c index d32996702110..ade4ed8f67d2 100644 --- a/drivers/iio/magnetometer/ak8974.c +++ b/drivers/iio/magnetometer/ak8974.c @@ -49,6 +49,7 @@ #define AK8974_WHOAMI_VALUE_AMI306 0x46 #define AK8974_WHOAMI_VALUE_AMI305 0x47 #define AK8974_WHOAMI_VALUE_AK8974 0x48 +#define AK8974_WHOAMI_VALUE_HSCDTD008A 0x49 #define AK8974_DATA_X 0x10 #define AK8974_DATA_Y 0x12 @@ -140,6 +141,12 @@ #define AK8974_INT_CTRL_PULSE BIT(1) /* 0 = latched; 1 = pulse (50 usec) */ #define AK8974_INT_CTRL_RESDEF (AK8974_INT_CTRL_XYZEN | AK8974_INT_CTRL_POL) +/* HSCDTD008A-specific control register */ +#define HSCDTD008A_CTRL4 0x1E +#define HSCDTD008A_CTRL4_MMD BIT(7) /* must be set to 1 */ +#define HSCDTD008A_CTRL4_RANGE BIT(4) /* 0 = 14-bit output; 1 = 15-bit output */ +#define HSCDTD008A_CTRL4_RESDEF (HSCDTD008A_CTRL4_MMD | HSCDTD008A_CTRL4_RANGE) + /* The AMI305 has elaborate FW version and serial number registers */ #define AMI305_VER 0xE8 #define AMI305_SN 0xEA @@ -241,10 +248,17 @@ static int ak8974_reset(struct ak8974 *ak8974) ret = regmap_write(ak8974->map, AK8974_CTRL3, AK8974_CTRL3_RESDEF); if (ret) return ret; - ret = regmap_write(ak8974->map, AK8974_INT_CTRL, - AK8974_INT_CTRL_RESDEF); - if (ret) - return ret; + if (ak8974->variant != AK8974_WHOAMI_VALUE_HSCDTD008A) { + ret = regmap_write(ak8974->map, AK8974_INT_CTRL, + AK8974_INT_CTRL_RESDEF); + if (ret) + return ret; + } else { + ret = regmap_write(ak8974->map, HSCDTD008A_CTRL4, + HSCDTD008A_CTRL4_RESDEF); + if (ret) + return ret; + } /* After reset, power off is default state */ return ak8974_set_power(ak8974, AK8974_PWR_OFF); @@ -267,6 +281,8 @@ static int ak8974_configure(struct ak8974 *ak8974) if (ret) return ret; } + if (ak8974->variant == AK8974_WHOAMI_VALUE_HSCDTD008A) + return 0; ret = regmap_write(ak8974->map, AK8974_INT_CTRL, AK8974_INT_CTRL_POL); if (ret) return ret; @@ -495,6 +511,10 @@ static int ak8974_detect(struct ak8974 *ak8974) name = "ak8974"; dev_info(&ak8974->i2c->dev, "detected AK8974\n"); break; + case AK8974_WHOAMI_VALUE_HSCDTD008A: + name = "hscdtd008a"; + dev_info(&ak8974->i2c->dev, "detected hscdtd008a\n"); + break; default: dev_err(&ak8974->i2c->dev, "unsupported device (%02x) ", whoami); @@ -674,18 +694,18 @@ static bool ak8974_writeable_reg(struct device *dev, unsigned int reg) case AK8974_INT_CTRL: case AK8974_INT_THRES: case AK8974_INT_THRES + 1: + return true; case AK8974_PRESET: case AK8974_PRESET + 1: - return true; + return ak8974->variant != AK8974_WHOAMI_VALUE_HSCDTD008A; case AK8974_OFFSET_X: case AK8974_OFFSET_X + 1: case AK8974_OFFSET_Y: case AK8974_OFFSET_Y + 1: case AK8974_OFFSET_Z: case AK8974_OFFSET_Z + 1: - if (ak8974->variant == AK8974_WHOAMI_VALUE_AK8974) - return true; - return false; + return ak8974->variant == AK8974_WHOAMI_VALUE_AK8974 || + ak8974->variant == AK8974_WHOAMI_VALUE_HSCDTD008A; case AMI305_OFFSET_X: case AMI305_OFFSET_X + 1: case AMI305_OFFSET_Y: @@ -926,12 +946,14 @@ static const struct i2c_device_id ak8974_id[] = { {"ami305", 0 }, {"ami306", 0 }, {"ak8974", 0 }, + {"hscdtd008a", 0 }, {} }; MODULE_DEVICE_TABLE(i2c, ak8974_id); static const struct of_device_id ak8974_of_match[] = { { .compatible = "asahi-kasei,ak8974", }, + { .compatible = "alps,hscdtd008a", }, {} }; MODULE_DEVICE_TABLE(of, ak8974_of_match); -- 2.26.0 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] iio: magnetometer: ak8974: add Alps hscdtd008a 2020-04-06 14:13 ` [PATCH 3/3] iio: magnetometer: ak8974: add " Nick Reitemeyer @ 2020-04-06 14:31 ` Stephan Gerhold 2020-04-12 13:35 ` Jonathan Cameron 2020-04-13 22:25 ` Linus Walleij 1 sibling, 1 reply; 12+ messages in thread From: Stephan Gerhold @ 2020-04-06 14:31 UTC (permalink / raw) To: Nick Reitemeyer Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio, Linus Walleij, devicetree, Rob Herring, Mark Rutland On Mon, Apr 06, 2020 at 04:13:53PM +0200, Nick Reitemeyer wrote: > The hscdtd008a is similar to the AK8974: > Only the whoami value and some registers are different. > > Signed-off-by: Nick Reitemeyer <nick.reitemeyer@web.de> Thanks a lot for sending this patch upstream! I checked this with the datasheet available here: https://tech.alpsalpine.com/prod/c/pdf/sensor/geomagnetic/hscd/hscdtd008a_data.pdf Reviewed-by: Stephan Gerhold <stephan@gerhold.net> ... and it seems to produce reasonable values on samsung-golden: Tested-by: Stephan Gerhold <stephan@gerhold.net> Linus Walleij might want to test this on his samsung-skomer :) Thanks, Stephan > --- > drivers/iio/magnetometer/ak8974.c | 38 ++++++++++++++++++++++++------- > 1 file changed, 30 insertions(+), 8 deletions(-) > > diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c > index d32996702110..ade4ed8f67d2 100644 > --- a/drivers/iio/magnetometer/ak8974.c > +++ b/drivers/iio/magnetometer/ak8974.c > @@ -49,6 +49,7 @@ > #define AK8974_WHOAMI_VALUE_AMI306 0x46 > #define AK8974_WHOAMI_VALUE_AMI305 0x47 > #define AK8974_WHOAMI_VALUE_AK8974 0x48 > +#define AK8974_WHOAMI_VALUE_HSCDTD008A 0x49 > > #define AK8974_DATA_X 0x10 > #define AK8974_DATA_Y 0x12 > @@ -140,6 +141,12 @@ > #define AK8974_INT_CTRL_PULSE BIT(1) /* 0 = latched; 1 = pulse (50 usec) */ > #define AK8974_INT_CTRL_RESDEF (AK8974_INT_CTRL_XYZEN | AK8974_INT_CTRL_POL) > > +/* HSCDTD008A-specific control register */ > +#define HSCDTD008A_CTRL4 0x1E > +#define HSCDTD008A_CTRL4_MMD BIT(7) /* must be set to 1 */ > +#define HSCDTD008A_CTRL4_RANGE BIT(4) /* 0 = 14-bit output; 1 = 15-bit output */ > +#define HSCDTD008A_CTRL4_RESDEF (HSCDTD008A_CTRL4_MMD | HSCDTD008A_CTRL4_RANGE) > + > /* The AMI305 has elaborate FW version and serial number registers */ > #define AMI305_VER 0xE8 > #define AMI305_SN 0xEA > @@ -241,10 +248,17 @@ static int ak8974_reset(struct ak8974 *ak8974) > ret = regmap_write(ak8974->map, AK8974_CTRL3, AK8974_CTRL3_RESDEF); > if (ret) > return ret; > - ret = regmap_write(ak8974->map, AK8974_INT_CTRL, > - AK8974_INT_CTRL_RESDEF); > - if (ret) > - return ret; > + if (ak8974->variant != AK8974_WHOAMI_VALUE_HSCDTD008A) { > + ret = regmap_write(ak8974->map, AK8974_INT_CTRL, > + AK8974_INT_CTRL_RESDEF); > + if (ret) > + return ret; > + } else { > + ret = regmap_write(ak8974->map, HSCDTD008A_CTRL4, > + HSCDTD008A_CTRL4_RESDEF); > + if (ret) > + return ret; > + } > > /* After reset, power off is default state */ > return ak8974_set_power(ak8974, AK8974_PWR_OFF); > @@ -267,6 +281,8 @@ static int ak8974_configure(struct ak8974 *ak8974) > if (ret) > return ret; > } > + if (ak8974->variant == AK8974_WHOAMI_VALUE_HSCDTD008A) > + return 0; > ret = regmap_write(ak8974->map, AK8974_INT_CTRL, AK8974_INT_CTRL_POL); > if (ret) > return ret; > @@ -495,6 +511,10 @@ static int ak8974_detect(struct ak8974 *ak8974) > name = "ak8974"; > dev_info(&ak8974->i2c->dev, "detected AK8974\n"); > break; > + case AK8974_WHOAMI_VALUE_HSCDTD008A: > + name = "hscdtd008a"; > + dev_info(&ak8974->i2c->dev, "detected hscdtd008a\n"); > + break; > default: > dev_err(&ak8974->i2c->dev, "unsupported device (%02x) ", > whoami); > @@ -674,18 +694,18 @@ static bool ak8974_writeable_reg(struct device *dev, unsigned int reg) > case AK8974_INT_CTRL: > case AK8974_INT_THRES: > case AK8974_INT_THRES + 1: > + return true; > case AK8974_PRESET: > case AK8974_PRESET + 1: > - return true; > + return ak8974->variant != AK8974_WHOAMI_VALUE_HSCDTD008A; > case AK8974_OFFSET_X: > case AK8974_OFFSET_X + 1: > case AK8974_OFFSET_Y: > case AK8974_OFFSET_Y + 1: > case AK8974_OFFSET_Z: > case AK8974_OFFSET_Z + 1: > - if (ak8974->variant == AK8974_WHOAMI_VALUE_AK8974) > - return true; > - return false; > + return ak8974->variant == AK8974_WHOAMI_VALUE_AK8974 || > + ak8974->variant == AK8974_WHOAMI_VALUE_HSCDTD008A; > case AMI305_OFFSET_X: > case AMI305_OFFSET_X + 1: > case AMI305_OFFSET_Y: > @@ -926,12 +946,14 @@ static const struct i2c_device_id ak8974_id[] = { > {"ami305", 0 }, > {"ami306", 0 }, > {"ak8974", 0 }, > + {"hscdtd008a", 0 }, > {} > }; > MODULE_DEVICE_TABLE(i2c, ak8974_id); > > static const struct of_device_id ak8974_of_match[] = { > { .compatible = "asahi-kasei,ak8974", }, > + { .compatible = "alps,hscdtd008a", }, > {} > }; > MODULE_DEVICE_TABLE(of, ak8974_of_match); > -- > 2.26.0 > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] iio: magnetometer: ak8974: add Alps hscdtd008a 2020-04-06 14:31 ` Stephan Gerhold @ 2020-04-12 13:35 ` Jonathan Cameron 2020-04-25 17:48 ` Jonathan Cameron 0 siblings, 1 reply; 12+ messages in thread From: Jonathan Cameron @ 2020-04-12 13:35 UTC (permalink / raw) To: Stephan Gerhold Cc: Nick Reitemeyer, Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio, Linus Walleij, devicetree, Rob Herring, Mark Rutland On Mon, 6 Apr 2020 16:31:13 +0200 Stephan Gerhold <stephan@gerhold.net> wrote: > On Mon, Apr 06, 2020 at 04:13:53PM +0200, Nick Reitemeyer wrote: > > The hscdtd008a is similar to the AK8974: > > Only the whoami value and some registers are different. > > > > Signed-off-by: Nick Reitemeyer <nick.reitemeyer@web.de> > > Thanks a lot for sending this patch upstream! > > I checked this with the datasheet available here: > https://tech.alpsalpine.com/prod/c/pdf/sensor/geomagnetic/hscd/hscdtd008a_data.pdf > > Reviewed-by: Stephan Gerhold <stephan@gerhold.net> > > ... and it seems to produce reasonable values on samsung-golden: > > Tested-by: Stephan Gerhold <stephan@gerhold.net> > > Linus Walleij might want to test this on his samsung-skomer :) Looks good to me, but I'll need a review on the binding (particularly the vendor prefix as it's in a generic file). Thanks, Jonathan > > Thanks, > Stephan > > > --- > > drivers/iio/magnetometer/ak8974.c | 38 ++++++++++++++++++++++++------- > > 1 file changed, 30 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c > > index d32996702110..ade4ed8f67d2 100644 > > --- a/drivers/iio/magnetometer/ak8974.c > > +++ b/drivers/iio/magnetometer/ak8974.c > > @@ -49,6 +49,7 @@ > > #define AK8974_WHOAMI_VALUE_AMI306 0x46 > > #define AK8974_WHOAMI_VALUE_AMI305 0x47 > > #define AK8974_WHOAMI_VALUE_AK8974 0x48 > > +#define AK8974_WHOAMI_VALUE_HSCDTD008A 0x49 > > > > #define AK8974_DATA_X 0x10 > > #define AK8974_DATA_Y 0x12 > > @@ -140,6 +141,12 @@ > > #define AK8974_INT_CTRL_PULSE BIT(1) /* 0 = latched; 1 = pulse (50 usec) */ > > #define AK8974_INT_CTRL_RESDEF (AK8974_INT_CTRL_XYZEN | AK8974_INT_CTRL_POL) > > > > +/* HSCDTD008A-specific control register */ > > +#define HSCDTD008A_CTRL4 0x1E > > +#define HSCDTD008A_CTRL4_MMD BIT(7) /* must be set to 1 */ > > +#define HSCDTD008A_CTRL4_RANGE BIT(4) /* 0 = 14-bit output; 1 = 15-bit output */ > > +#define HSCDTD008A_CTRL4_RESDEF (HSCDTD008A_CTRL4_MMD | HSCDTD008A_CTRL4_RANGE) > > + > > /* The AMI305 has elaborate FW version and serial number registers */ > > #define AMI305_VER 0xE8 > > #define AMI305_SN 0xEA > > @@ -241,10 +248,17 @@ static int ak8974_reset(struct ak8974 *ak8974) > > ret = regmap_write(ak8974->map, AK8974_CTRL3, AK8974_CTRL3_RESDEF); > > if (ret) > > return ret; > > - ret = regmap_write(ak8974->map, AK8974_INT_CTRL, > > - AK8974_INT_CTRL_RESDEF); > > - if (ret) > > - return ret; > > + if (ak8974->variant != AK8974_WHOAMI_VALUE_HSCDTD008A) { > > + ret = regmap_write(ak8974->map, AK8974_INT_CTRL, > > + AK8974_INT_CTRL_RESDEF); > > + if (ret) > > + return ret; > > + } else { > > + ret = regmap_write(ak8974->map, HSCDTD008A_CTRL4, > > + HSCDTD008A_CTRL4_RESDEF); > > + if (ret) > > + return ret; > > + } > > > > /* After reset, power off is default state */ > > return ak8974_set_power(ak8974, AK8974_PWR_OFF); > > @@ -267,6 +281,8 @@ static int ak8974_configure(struct ak8974 *ak8974) > > if (ret) > > return ret; > > } > > + if (ak8974->variant == AK8974_WHOAMI_VALUE_HSCDTD008A) > > + return 0; > > ret = regmap_write(ak8974->map, AK8974_INT_CTRL, AK8974_INT_CTRL_POL); > > if (ret) > > return ret; > > @@ -495,6 +511,10 @@ static int ak8974_detect(struct ak8974 *ak8974) > > name = "ak8974"; > > dev_info(&ak8974->i2c->dev, "detected AK8974\n"); > > break; > > + case AK8974_WHOAMI_VALUE_HSCDTD008A: > > + name = "hscdtd008a"; > > + dev_info(&ak8974->i2c->dev, "detected hscdtd008a\n"); > > + break; > > default: > > dev_err(&ak8974->i2c->dev, "unsupported device (%02x) ", > > whoami); > > @@ -674,18 +694,18 @@ static bool ak8974_writeable_reg(struct device *dev, unsigned int reg) > > case AK8974_INT_CTRL: > > case AK8974_INT_THRES: > > case AK8974_INT_THRES + 1: > > + return true; > > case AK8974_PRESET: > > case AK8974_PRESET + 1: > > - return true; > > + return ak8974->variant != AK8974_WHOAMI_VALUE_HSCDTD008A; > > case AK8974_OFFSET_X: > > case AK8974_OFFSET_X + 1: > > case AK8974_OFFSET_Y: > > case AK8974_OFFSET_Y + 1: > > case AK8974_OFFSET_Z: > > case AK8974_OFFSET_Z + 1: > > - if (ak8974->variant == AK8974_WHOAMI_VALUE_AK8974) > > - return true; > > - return false; > > + return ak8974->variant == AK8974_WHOAMI_VALUE_AK8974 || > > + ak8974->variant == AK8974_WHOAMI_VALUE_HSCDTD008A; > > case AMI305_OFFSET_X: > > case AMI305_OFFSET_X + 1: > > case AMI305_OFFSET_Y: > > @@ -926,12 +946,14 @@ static const struct i2c_device_id ak8974_id[] = { > > {"ami305", 0 }, > > {"ami306", 0 }, > > {"ak8974", 0 }, > > + {"hscdtd008a", 0 }, > > {} > > }; > > MODULE_DEVICE_TABLE(i2c, ak8974_id); > > > > static const struct of_device_id ak8974_of_match[] = { > > { .compatible = "asahi-kasei,ak8974", }, > > + { .compatible = "alps,hscdtd008a", }, > > {} > > }; > > MODULE_DEVICE_TABLE(of, ak8974_of_match); > > -- > > 2.26.0 > > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] iio: magnetometer: ak8974: add Alps hscdtd008a 2020-04-12 13:35 ` Jonathan Cameron @ 2020-04-25 17:48 ` Jonathan Cameron 0 siblings, 0 replies; 12+ messages in thread From: Jonathan Cameron @ 2020-04-25 17:48 UTC (permalink / raw) To: Stephan Gerhold Cc: Nick Reitemeyer, Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio, Linus Walleij, devicetree, Rob Herring, Mark Rutland On Sun, 12 Apr 2020 14:35:24 +0100 Jonathan Cameron <jic23@kernel.org> wrote: > On Mon, 6 Apr 2020 16:31:13 +0200 > Stephan Gerhold <stephan@gerhold.net> wrote: > > > On Mon, Apr 06, 2020 at 04:13:53PM +0200, Nick Reitemeyer wrote: > > > The hscdtd008a is similar to the AK8974: > > > Only the whoami value and some registers are different. > > > > > > Signed-off-by: Nick Reitemeyer <nick.reitemeyer@web.de> > > > > Thanks a lot for sending this patch upstream! > > > > I checked this with the datasheet available here: > > https://tech.alpsalpine.com/prod/c/pdf/sensor/geomagnetic/hscd/hscdtd008a_data.pdf > > > > Reviewed-by: Stephan Gerhold <stephan@gerhold.net> > > > > ... and it seems to produce reasonable values on samsung-golden: > > > > Tested-by: Stephan Gerhold <stephan@gerhold.net> > > > > Linus Walleij might want to test this on his samsung-skomer :) > > Looks good to me, but I'll need a review on the binding (particularly > the vendor prefix as it's in a generic file). Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > > Thanks, > > Jonathan > > > > > Thanks, > > Stephan > > > > > --- > > > drivers/iio/magnetometer/ak8974.c | 38 ++++++++++++++++++++++++------- > > > 1 file changed, 30 insertions(+), 8 deletions(-) > > > > > > diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c > > > index d32996702110..ade4ed8f67d2 100644 > > > --- a/drivers/iio/magnetometer/ak8974.c > > > +++ b/drivers/iio/magnetometer/ak8974.c > > > @@ -49,6 +49,7 @@ > > > #define AK8974_WHOAMI_VALUE_AMI306 0x46 > > > #define AK8974_WHOAMI_VALUE_AMI305 0x47 > > > #define AK8974_WHOAMI_VALUE_AK8974 0x48 > > > +#define AK8974_WHOAMI_VALUE_HSCDTD008A 0x49 > > > > > > #define AK8974_DATA_X 0x10 > > > #define AK8974_DATA_Y 0x12 > > > @@ -140,6 +141,12 @@ > > > #define AK8974_INT_CTRL_PULSE BIT(1) /* 0 = latched; 1 = pulse (50 usec) */ > > > #define AK8974_INT_CTRL_RESDEF (AK8974_INT_CTRL_XYZEN | AK8974_INT_CTRL_POL) > > > > > > +/* HSCDTD008A-specific control register */ > > > +#define HSCDTD008A_CTRL4 0x1E > > > +#define HSCDTD008A_CTRL4_MMD BIT(7) /* must be set to 1 */ > > > +#define HSCDTD008A_CTRL4_RANGE BIT(4) /* 0 = 14-bit output; 1 = 15-bit output */ > > > +#define HSCDTD008A_CTRL4_RESDEF (HSCDTD008A_CTRL4_MMD | HSCDTD008A_CTRL4_RANGE) > > > + > > > /* The AMI305 has elaborate FW version and serial number registers */ > > > #define AMI305_VER 0xE8 > > > #define AMI305_SN 0xEA > > > @@ -241,10 +248,17 @@ static int ak8974_reset(struct ak8974 *ak8974) > > > ret = regmap_write(ak8974->map, AK8974_CTRL3, AK8974_CTRL3_RESDEF); > > > if (ret) > > > return ret; > > > - ret = regmap_write(ak8974->map, AK8974_INT_CTRL, > > > - AK8974_INT_CTRL_RESDEF); > > > - if (ret) > > > - return ret; > > > + if (ak8974->variant != AK8974_WHOAMI_VALUE_HSCDTD008A) { > > > + ret = regmap_write(ak8974->map, AK8974_INT_CTRL, > > > + AK8974_INT_CTRL_RESDEF); > > > + if (ret) > > > + return ret; > > > + } else { > > > + ret = regmap_write(ak8974->map, HSCDTD008A_CTRL4, > > > + HSCDTD008A_CTRL4_RESDEF); > > > + if (ret) > > > + return ret; > > > + } > > > > > > /* After reset, power off is default state */ > > > return ak8974_set_power(ak8974, AK8974_PWR_OFF); > > > @@ -267,6 +281,8 @@ static int ak8974_configure(struct ak8974 *ak8974) > > > if (ret) > > > return ret; > > > } > > > + if (ak8974->variant == AK8974_WHOAMI_VALUE_HSCDTD008A) > > > + return 0; > > > ret = regmap_write(ak8974->map, AK8974_INT_CTRL, AK8974_INT_CTRL_POL); > > > if (ret) > > > return ret; > > > @@ -495,6 +511,10 @@ static int ak8974_detect(struct ak8974 *ak8974) > > > name = "ak8974"; > > > dev_info(&ak8974->i2c->dev, "detected AK8974\n"); > > > break; > > > + case AK8974_WHOAMI_VALUE_HSCDTD008A: > > > + name = "hscdtd008a"; > > > + dev_info(&ak8974->i2c->dev, "detected hscdtd008a\n"); > > > + break; > > > default: > > > dev_err(&ak8974->i2c->dev, "unsupported device (%02x) ", > > > whoami); > > > @@ -674,18 +694,18 @@ static bool ak8974_writeable_reg(struct device *dev, unsigned int reg) > > > case AK8974_INT_CTRL: > > > case AK8974_INT_THRES: > > > case AK8974_INT_THRES + 1: > > > + return true; > > > case AK8974_PRESET: > > > case AK8974_PRESET + 1: > > > - return true; > > > + return ak8974->variant != AK8974_WHOAMI_VALUE_HSCDTD008A; > > > case AK8974_OFFSET_X: > > > case AK8974_OFFSET_X + 1: > > > case AK8974_OFFSET_Y: > > > case AK8974_OFFSET_Y + 1: > > > case AK8974_OFFSET_Z: > > > case AK8974_OFFSET_Z + 1: > > > - if (ak8974->variant == AK8974_WHOAMI_VALUE_AK8974) > > > - return true; > > > - return false; > > > + return ak8974->variant == AK8974_WHOAMI_VALUE_AK8974 || > > > + ak8974->variant == AK8974_WHOAMI_VALUE_HSCDTD008A; > > > case AMI305_OFFSET_X: > > > case AMI305_OFFSET_X + 1: > > > case AMI305_OFFSET_Y: > > > @@ -926,12 +946,14 @@ static const struct i2c_device_id ak8974_id[] = { > > > {"ami305", 0 }, > > > {"ami306", 0 }, > > > {"ak8974", 0 }, > > > + {"hscdtd008a", 0 }, > > > {} > > > }; > > > MODULE_DEVICE_TABLE(i2c, ak8974_id); > > > > > > static const struct of_device_id ak8974_of_match[] = { > > > { .compatible = "asahi-kasei,ak8974", }, > > > + { .compatible = "alps,hscdtd008a", }, > > > {} > > > }; > > > MODULE_DEVICE_TABLE(of, ak8974_of_match); > > > -- > > > 2.26.0 > > > > ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] iio: magnetometer: ak8974: add Alps hscdtd008a 2020-04-06 14:13 ` [PATCH 3/3] iio: magnetometer: ak8974: add " Nick Reitemeyer 2020-04-06 14:31 ` Stephan Gerhold @ 2020-04-13 22:25 ` Linus Walleij 1 sibling, 0 replies; 12+ messages in thread From: Linus Walleij @ 2020-04-13 22:25 UTC (permalink / raw) To: Nick Reitemeyer Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio, Stephan Gerhold, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, Rob Herring, Mark Rutland On Mon, Apr 6, 2020 at 4:24 PM Nick Reitemeyer <nick.reitemeyer@web.de> wrote: > The hscdtd008a is similar to the AK8974: > Only the whoami value and some registers are different. > > Signed-off-by: Nick Reitemeyer <nick.reitemeyer@web.de> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Also Tested-by: Linus Walleij <linus.walleij@linaro.org> Works like a charm on the Skomer. I don't know about the mounting matrix though. Does anyone have a simple procedure for how to calibrate the mounting matrix for a compass so it makes sense? I suppose just run a sensor app on a know working device and compare side-by-side but something more formal? Yours, Linus Walleij ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] dt-bindings: vendor-prefixes: Add Alps 2020-04-06 14:13 [PATCH 1/3] dt-bindings: vendor-prefixes: Add Alps Nick Reitemeyer 2020-04-06 14:13 ` [PATCH 2/3] dt-bindings: magnetometer: ak8974: Add Alps hscdtd008a Nick Reitemeyer 2020-04-06 14:13 ` [PATCH 3/3] iio: magnetometer: ak8974: add " Nick Reitemeyer @ 2020-04-13 22:23 ` Linus Walleij 2020-04-15 0:09 ` Rob Herring 3 siblings, 0 replies; 12+ messages in thread From: Linus Walleij @ 2020-04-13 22:23 UTC (permalink / raw) To: Nick Reitemeyer Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio, Stephan Gerhold, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, Rob Herring, Mark Rutland On Mon, Apr 6, 2020 at 4:23 PM Nick Reitemeyer <nick.reitemeyer@web.de> wrote: > Alps Electric Co., Ltd. is a japanese electronics company: > https://www.alps.com/ > > Signed-off-by: Nick Reitemeyer <nick.reitemeyer@web.de> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] dt-bindings: vendor-prefixes: Add Alps 2020-04-06 14:13 [PATCH 1/3] dt-bindings: vendor-prefixes: Add Alps Nick Reitemeyer ` (2 preceding siblings ...) 2020-04-13 22:23 ` [PATCH 1/3] dt-bindings: vendor-prefixes: Add Alps Linus Walleij @ 2020-04-15 0:09 ` Rob Herring 3 siblings, 0 replies; 12+ messages in thread From: Rob Herring @ 2020-04-15 0:09 UTC (permalink / raw) To: Nick Reitemeyer Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio, Nick Reitemeyer, Stephan Gerhold, Linus Walleij, devicetree, Mark Rutland On Mon, 6 Apr 2020 16:13:49 +0200, Nick Reitemeyer wrote: > > Alps Electric Co., Ltd. is a japanese electronics company: > https://www.alps.com/ > > Signed-off-by: Nick Reitemeyer <nick.reitemeyer@web.de> > --- > Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ > 1 file changed, 2 insertions(+) > Applied, thanks. Rob ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2020-04-25 17:48 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-04-06 14:13 [PATCH 1/3] dt-bindings: vendor-prefixes: Add Alps Nick Reitemeyer 2020-04-06 14:13 ` [PATCH 2/3] dt-bindings: magnetometer: ak8974: Add Alps hscdtd008a Nick Reitemeyer 2020-04-13 22:23 ` Linus Walleij 2020-04-15 0:09 ` Rob Herring 2020-04-25 17:38 ` Jonathan Cameron 2020-04-06 14:13 ` [PATCH 3/3] iio: magnetometer: ak8974: add " Nick Reitemeyer 2020-04-06 14:31 ` Stephan Gerhold 2020-04-12 13:35 ` Jonathan Cameron 2020-04-25 17:48 ` Jonathan Cameron 2020-04-13 22:25 ` Linus Walleij 2020-04-13 22:23 ` [PATCH 1/3] dt-bindings: vendor-prefixes: Add Alps Linus Walleij 2020-04-15 0:09 ` Rob Herring
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).