Message ID | 20200406141350.162036-1-nick.reitemeyer@web.de |
---|---|
State | Accepted, archived |
Headers | show |
Series | [1/3] dt-bindings: vendor-prefixes: Add Alps | expand |
Context | Check | Description |
---|---|---|
robh/checkpatch | success | |
robh/dt-meta-schema | success |
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 >
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 > >
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
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
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
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 > > > >
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,.*":
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(+) -- 2.26.0