iio: magnetometer: ak8975: Add gpio reset support
Subsystems (2)
v2 cover iio: magnetometer: ak8975: Add gpio reset support
Convert documentation from txt format to yaml. Add documentation about reset-gpio.
Deassert reset on ak8975_power_on, assert reset on ak8975_power_off.
Without reset's deassertion during ak8975_power_on, driver's probe fails on ak8975_who_i_am while checking for device identity for AK09911 chip
AK09911 has an active low reset gpio to handle register's reset. AK09911 datasheed says that, if not used, reset pin should be connected to VID. This patch emulates this situation
Jonathan Albrieux (3):
dt-bindings: iio: magnetometer: ak8975: convert txt format to yaml
dt-bindings: iio: magnetometer: ak8975: add gpio reset support
iio: magnetometer: ak8975: Add gpio reset support
.../bindings/iio/magnetometer/ak8975.txt | 30 -------- .../bindings/iio/magnetometer/ak8975.yaml | 70 +++++++++++++++++++ drivers/iio/magnetometer/ak8975.c | 22 +++++- 3 files changed, 90 insertions(+), 32 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/magnetometer/ak8975.txt create mode 100644 Documentation/devicetree/bindings/iio/magnetometer/ak8975.yaml
Signature · 1 line
2.17.1
PATCH v2 1/3 dt-bindings: iio: magnetometer: ak8975: convert txt format to yaml
Converts documentation from txt format to yaml
--- .../bindings/iio/magnetometer/ak8975.txt | 30 --------- .../bindings/iio/magnetometer/ak8975.yaml | 66 +++++++++++++++++++ 2 files changed, 66 insertions(+), 30 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/magnetometer/ak8975.txt create mode 100644 Documentation/devicetree/bindings/iio/magnetometer/ak8975.yaml
Documentation/devicetree/bindings/iio/magnetometer/ak8975.txt deleted +0 -30
@@ -1,30 +0,0 @@ -* AsahiKASEI AK8975 magnetometer sensor - -Required properties: - - - compatible : should be "asahi-kasei,ak8975" - - reg : the I2C address of the magnetometer - -Optional properties: - - - gpios : should be device tree identifier of the magnetometer DRDY pin - - vdd-supply: an optional regulator that needs to be on to provide VDD - - mount-matrix: an optional 3x3 mounting rotation matrix - -Example: - -ak8975@c { - compatible = "asahi-kasei,ak8975"; - reg = <0x0c>; - gpios = <&gpj0 7 0>; - vdd-supply = <&ldo_3v3_gnss>; - mount-matrix = "-0.984807753012208", /* x0 */ - "0", /* y0 */ - "-0.173648177666930", /* z0 */ - "0", /* x1 */ - "-1", /* y1 */ - "0", /* z1 */ - "-0.173648177666930", /* x2 */ - "0", /* y2 */ - "0.984807753012208"; /* z2 */ -};
Documentation/devicetree/bindings/iio/magnetometer/ak8975.yaml new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 2/3 dt-bindings: iio: magnetometer: ak8975: add gpio reset support
In reply to Jonathan AlbrieuxAdd reset-gpio support.
Without reset's deassertion during ak8975_power_on, driver's probe fails on ak8975_who_i_am while checking for device identity for AK09911 chip
AK09911 has an active low reset gpio to handle register's reset. AK09911 datasheed says that, if not used, reset pin should be connected to VID. This patch emulates this situation
--- .../devicetree/bindings/iio/magnetometer/ak8975.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/iio/magnetometer/ak8975.yaml +4 -0
@@ -37,6 +37,9 @@ properties: mount-matrix: description: an optional 3x3 mounting rotation matrix + reset-gpio: + description: an optional pin needed for AK09911 to set the reset state + required: - compatible - reg
@@ -53,6 +56,7 @@ examples: reg = <0x0c>; gpios = <&gpj0 7 0>; vdd-supply = <&ldo_3v3_gnss>; + reset-gpio = <&msmgpio 111 1>; mount-matrix = "-0.984807753012208", /* x0 */ "0", /* y0 */ "-0.173648177666930", /* z0 */
Signature · 1 line
2.17.1
PATCH v2 3/3 iio: magnetometer: ak8975: Add gpio reset support
In reply to Jonathan AlbrieuxAccording to AK09911 datasheet, if reset gpio is provided then deassert reset on ak8975_power_on and assert reset on ak8975_power_off.
Without reset's deassertion during ak8975_power_on, driver's probe fails on ak8975_who_i_am while checking for device identity for AK09911 chip
AK09911 has an active low reset gpio to handle register's reset. AK09911 datasheed says that, if not used, reset pin should be connected to VID. This patch emulates this situation
--- drivers/iio/magnetometer/ak8975.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/iio/magnetometer/ak8975.c +20 -2
@@ -358,6 +358,7 @@ struct ak8975_data {u8 asa[3 ];long raw_to_gauss[3 ];struct gpio_desc *eoc_gpiod; +struct gpio_desc *reset_gpiod;int eoc_irq;wait_queue_head_t data_ready_queue;unsigned long flags;
@@ -384,10 +385,13 @@ static int ak8975_power_on(const struct ak8975_data *data) "Failed to enable specified Vid supply\n");return ret; } + +gpiod_set_value_cansleep (data->reset_gpiod,0 ); +/* -* According to the datasheet the power supply rise time i 200us +* According to the datasheet the power supply rise time is 200us * and the minimum wait time before mode setting is 100us, in -* total 300 us. Add some margin and say minimum 500us here. +* total 300us. Add some margin and say minimum 500us here. */ usleep_range (500 ,1000 );return 0 ;
@@ -396,6 +400,8 @@ static int ak8975_power_on(const struct ak8975_data *data)/* Disable attached power regulator if any. */ static void ak8975_power_off (const struct ak8975_data *data) { +gpiod_set_value_cansleep (data->reset_gpiod,1 ); +regulator_disable (data->vid);regulator_disable (data->vdd); }
@@ -839,6 +845,7 @@ static int ak8975_probe(struct i2c_client *client,struct ak8975_data *data;struct iio_dev *indio_dev;struct gpio_desc *eoc_gpiod; +struct gpio_desc *reset_gpiod;const void *match;unsigned int i;int err;
@@ -856,6 +863,16 @@ static int ak8975_probe(struct i2c_client *client,if (eoc_gpiod)gpiod_set_consumer_name (eoc_gpiod,"ak_8975" ); +/* +* According to AK09911 datasheet, if reset gpio is provided then +* deassert reset on ak8975_power_on and assert reset on +* ak8975_power_off. +*/ + reset_gpiod =devm_gpiod_get_optional (&client->dev, +"reset" ,GPIOD_OUT_HIGH ); +if (IS_ERR (reset_gpiod)) +return PTR_ERR (reset_gpiod); +/* Register with IIO */ indio_dev =devm_iio_device_alloc (&client->dev,sizeof (*data));if (indio_dev ==NULL )
@@ -866,6 +883,7 @@ static int ak8975_probe(struct i2c_client *client, data->client = client; data->eoc_gpiod = eoc_gpiod; + data->reset_gpiod = reset_gpiod; data->eoc_irq =0 ; err =iio_read_mount_matrix (&client->dev,"mount-matrix" , &data->orientation);
Signature · 1 line
2.17.1
On Tue, May 19, 2020 at 08:57:43AM +0200, Jonathan Albrieux wrote:
Thanks for an update, my comments below.
Quoted 1 line
According to AK09911 datasheet, if reset gpio is provided then
Trailing whitespace.
Quoted 8 lines
deassert reset on
ak8975_power_onand assert reset onak8975_power_off.Without reset's deassertion during
ak8975_power_on, driver's probe fails onak8975_who_i_amwhile checking for device identity for AK09911 chipAK09911 has an active low reset gpio to handle register's reset. AK09911 datasheed says that, if not used, reset pin should be connected to VID. This patch emulates this situation
Please, put periods at the end of the phrases.
drivers/iio/magnetometer/ak8975.c static int ak8975_power_on(const struct ak8975_data *data) · line 395
Quoted 7 lines
drivers/iio/magnetometer/ak8975.c +2
-2/* -* According to the datasheet the power supply rise time i 200us +* According to the datasheet the power supply rise time is 200us * and the minimum wait time before mode setting is 100us, in -* total 300 us. Add some margin and say minimum 500us here. +* total 300us. Add some margin and say minimum 500us here. */
This is not related change (perhaps, you may do in separate patch), but I'm not against it. Up to maintainer.
drivers/iio/magnetometer/ak8975.c static int ak8975_probe(struct i2c_client *client, · line 869
Quoted 4 lines
drivers/iio/magnetometer/ak8975.c +4
-0+/* +* According to AK09911 datasheet, if reset gpio is provided then +* deassert reset on ak8975_power_on and assert reset on +* ak8975_power_off.
We try to refer to the code accordingly to the kernel doc recommendations (even for non-kdoc comments). So, here, 'function' as 'function()' (without quotes) and so on.
Quoted 20 lines
drivers/iio/magnetometer/ak8975.c +7
-0+*/ + reset_gpiod =devm_gpiod_get_optional (&client->dev, +"reset" ,GPIOD_OUT_HIGH ); +if (IS_ERR (reset_gpiod)) +return PTR_ERR (reset_gpiod); +/* Register with IIO */ indio_dev =devm_iio_device_alloc (&client->dev,sizeof (*data));if (indio_dev ==NULL )@@ -866,6 +883,7 @@ static int ak8975_probe(struct i2c_client *client, data->client = client; data->eoc_gpiod = eoc_gpiod; + data->reset_gpiod = reset_gpiod; data->eoc_irq =0 ; err =iio_read_mount_matrix (&client->dev,"mount-matrix" , &data->orientation);Signature · 1 line
2.17.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 4 lines · Andy Shevchenko
On Tue, May 19, 2020 at 08:57:43AM +0200, Jonathan Albrieux wrote:
Thanks for an update, my comments below.
Thanks to you for taking time to review the code!
Quoted 15 lines
Quoted 1 line
According to AK09911 datasheet, if reset gpio is provided then
Trailing whitespace.
Quoted 8 lines
deassert reset on
ak8975_power_onand assert reset onak8975_power_off.Without reset's deassertion during
ak8975_power_on, driver's probe fails onak8975_who_i_amwhile checking for device identity for AK09911 chipAK09911 has an active low reset gpio to handle register's reset. AK09911 datasheed says that, if not used, reset pin should be connected to VID. This patch emulates this situation
Please, put periods at the end of the phrases.
Quoted 11 lines
drivers/iio/magnetometer/ak8975.c static int ak8975_power_on(const struct ak8975_data *data) · line 395
Quoted 7 lines
drivers/iio/magnetometer/ak8975.c +2
-2/* -* According to the datasheet the power supply rise time i 200us +* According to the datasheet the power supply rise time is 200us * and the minimum wait time before mode setting is 100us, in -* total 300 us. Add some margin and say minimum 500us here. +* total 300us. Add some margin and say minimum 500us here. */ This is not related change (perhaps, you may do in separate patch), but I'm not against it. Up to maintainer.
Ok I will separate the patch
Quoted 9 lines
drivers/iio/magnetometer/ak8975.c static int ak8975_probe(struct i2c_client *client, · line 869
Quoted 4 lines
drivers/iio/magnetometer/ak8975.c +4
-0+/* +* According to AK09911 datasheet, if reset gpio is provided then +* deassert reset on ak8975_power_on and assert reset on +* ak8975_power_off. We try to refer to the code accordingly to the kernel doc recommendations (even for non-kdoc comments). So, here, 'function' as '
function()' (without quotes) and so on.
Will fix this as like as the other changes you pointed out about periods and trailing spaces as soon as possible
Quoted 16 lines
Quoted 16 lines
drivers/iio/magnetometer/ak8975.c +7
-0+*/ + reset_gpiod =devm_gpiod_get_optional (&client->dev, +"reset" ,GPIOD_OUT_HIGH ); +if (IS_ERR (reset_gpiod)) +return PTR_ERR (reset_gpiod); +/* Register with IIO */ indio_dev =devm_iio_device_alloc (&client->dev,sizeof (*data));if (indio_dev ==NULL )@@ -866,6 +883,7 @@ static int ak8975_probe(struct i2c_client *client, data->client = client; data->eoc_gpiod = eoc_gpiod; + data->reset_gpiod = reset_gpiod; data->eoc_irq =0 ;
Quoted 10 lines
Quoted 4 lines
drivers/iio/magnetometer/ak8975.c +0
-0err =iio_read_mount_matrix (&client->dev,"mount-matrix" , &data->orientation);Signature · 1 line
2.17.1Signature · 2 lines
With Best Regards, Andy Shevchenko
Again, thank you,
Best regards,
Jonathan Albrieux
Quoted 2 lines · Jonathan Albrieux
Convert documentation from txt format to yaml. Add documentation about reset-gpio.
Trailing white space (though it doesn't matter here, in cover letter).
Quoted 8 lines
Deassert reset on
ak8975_power_on, assert reset onak8975_power_off.Without reset's deassertion during
ak8975_power_on, driver's probe fails onak8975_who_i_amwhile checking for device identity for AK09911 chipAK09911 has an active low reset gpio to handle register's reset. AK09911 datasheed says that, if not used, reset pin should be connected to VID. This patch emulates this situation
I dunno if it's your first submission to Linux kernel project or other OSS, but here you missed a changelog. Rule of thumb is to provide a summary of the changes done in the history of the evolution of a patch series.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Jonathan Albrieux
Convert documentation from txt format to yaml. Add documentation about reset-gpio.
Trailing white space (though it doesn't matter here, in cover letter).
Ok will fix it!
Quoted 5 lines
Quoted 5 lines
Deassert reset on
ak8975_power_on, assert reset onak8975_power_off.Without reset's deassertion during
ak8975_power_on, driver's probe fails onak8975_who_i_amwhile checking for device identity for AK09911 chip
Quoted 8 lines
Quoted 3 lines
AK09911 has an active low reset gpio to handle register's reset. AK09911 datasheed says that, if not used, reset pin should be connected to VID. This patch emulates this situation
I dunno if it's your first submission to Linux kernel project or other OSS, but here you missed a changelog. Rule of thumb is to provide a summary of the changes done in the history of the evolution of a patch series.
Oh thank you and sorry for not having included it.
Does the changelog needs to be added to all patch files or just on the ones subject of the changes?
Quoted 5 lines
Signature · 2 lines
With Best Regards, Andy Shevchenko
Best regards,
Jonathan Albrieux
Quoted 2 lines · Jonathan Albrieux
Quoted 1 line · Andy Shevchenko
On Tue, May 19, 2020 at 08:57:40AM +0200, Jonathan Albrieux wrote:
...
Quoted 9 lines
Quoted 4 lines
I dunno if it's your first submission to Linux kernel project or other OSS, but here you missed a changelog. Rule of thumb is to provide a summary of the changes done in the history of the evolution of a patch series.
Oh thank you and sorry for not having included it.
Does the changelog needs to be added to all patch files or just on the ones subject of the changes?
Up to you and maintainer of the corresponding subsystem.
My common sense tells me that
1) if there is a cover letter, just put a joined changelog there
2) otherwise, put changelog in each patch.
I saw in practice all possible variants, i.e.
a) cover letter w/o changelog + changelog per patch;
b) cover letter w/ changelog + changelog per patch;
c) cover letter w/ changelog.
I think any of it is fine in general.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 22 lines · Andy Shevchenko
Quoted 2 lines · Jonathan Albrieux
Quoted 1 line · Andy Shevchenko
On Tue, May 19, 2020 at 08:57:40AM +0200, Jonathan Albrieux wrote:
...
Quoted 9 lines
Quoted 4 lines
I dunno if it's your first submission to Linux kernel project or other OSS, but here you missed a changelog. Rule of thumb is to provide a summary of the changes done in the history of the evolution of a patch series.
Oh thank you and sorry for not having included it.
Does the changelog needs to be added to all patch files or just on the ones subject of the changes?
Up to you and maintainer of the corresponding subsystem.
My common sense tells me that
1) if there is a cover letter, just put a joined changelog there
2) otherwise, put changelog in each patch.
Quoted 12 lines
I saw in practice all possible variants, i.e.
a) cover letter w/o changelog + changelog per patch;
b) cover letter w/ changelog + changelog per patch;
c) cover letter w/ changelog.I think any of it is fine in general.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Thank you for the tips, will work on it!
Best regards,
Jonathan Albrieux