All of lore.kernel.org
 help / color / mirror / Atom feed
* invensense mpu9250 ak8963 and devicetree
@ 2021-03-03 15:31 Philippe De Muyter
  2021-03-04  9:12 ` Jean-Baptiste Maneyrol
       [not found] ` <BL0PR12MB501190F3812AA541BDBEF625C4979@BL0PR12MB5011.namprd12.prod.outlook.com>
  0 siblings, 2 replies; 8+ messages in thread
From: Philippe De Muyter @ 2021-03-03 15:31 UTC (permalink / raw)
  To: linux-iio

Hello,

I am trying to use a mpu9250 imu, but I have trouble with the ak8963 part.

Currently, ak8975_probe fails in this code :

        /* Fetch the regulators */
        data->vdd = devm_regulator_get(&client->dev, "vdd");
        if (IS_ERR(data->vdd))
                return PTR_ERR(data->vdd);
        data->vid = devm_regulator_get(&client->dev, "vid");
        if (IS_ERR(data->vid))
                return PTR_ERR(data->vid);

but Documentation/devicetree/bindings/iio/magnetometer/asahi-kasei,ak8975.yaml
says :

  vdd-supply:
    description: |
      an optional regulator that needs to be on to provide VDD power to
      the sensor.

I have no vdd or vdd-supply property in my ak8963 description.

Is that unrelated ?

What should I write in my dts file for this ak8963 embedded in a mpu9250 ?

Thanks in advance

Philippe

-- 
Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: invensense mpu9250 ak8963 and devicetree
  2021-03-03 15:31 invensense mpu9250 ak8963 and devicetree Philippe De Muyter
@ 2021-03-04  9:12 ` Jean-Baptiste Maneyrol
  2021-03-04  9:31   ` Philippe De Muyter
       [not found] ` <BL0PR12MB501190F3812AA541BDBEF625C4979@BL0PR12MB5011.namprd12.prod.outlook.com>
  1 sibling, 1 reply; 8+ messages in thread
From: Jean-Baptiste Maneyrol @ 2021-03-04  9:12 UTC (permalink / raw)
  To: Philippe De Muyter, linux-iio

Hello Philippe,

I would recommend letting mpu9250 chip drives the magnetometer instead of using the ak8963 driver.

This is simpler to use and guarantees a good synchronization between all sensors and no possible latency coming from kernel scheduling when polling the magnetometer. And it enables the use of spi bus for connecting the device.

You just need to define mpu9250 dts without an i2c-gate, and delete all definition of ak8963 chip.

Best regards,
JB


From: Philippe De Muyter <phdm@macq.eu>
Sent: Wednesday, March 3, 2021 16:31
To: linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>
Subject: invensense mpu9250 ak8963 and devicetree 
 
 CAUTION: This email originated from outside of the organization. Please make sure the sender is who they say they are and do not click links or open attachments unless you recognize the sender and know the content is safe.

Hello,

I am trying to use a mpu9250 imu, but I have trouble with the ak8963 part.

Currently, ak8975_probe fails in this code :

        /* Fetch the regulators */
        data->vdd = devm_regulator_get(&client->dev, "vdd");
        if (IS_ERR(data->vdd))
                return PTR_ERR(data->vdd);
        data->vid = devm_regulator_get(&client->dev, "vid");
        if (IS_ERR(data->vid))
                return PTR_ERR(data->vid);

but Documentation/devicetree/bindings/iio/magnetometer/asahi-kasei,ak8975.yaml
says :

  vdd-supply:
    description: |
      an optional regulator that needs to be on to provide VDD power to
      the sensor.

I have no vdd or vdd-supply property in my ak8963 description.

Is that unrelated ?

What should I write in my dts file for this ak8963 embedded in a mpu9250 ?

Thanks in advance

Philippe

-- 
Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: invensense mpu9250 ak8963 and devicetree
  2021-03-04  9:12 ` Jean-Baptiste Maneyrol
@ 2021-03-04  9:31   ` Philippe De Muyter
  0 siblings, 0 replies; 8+ messages in thread
From: Philippe De Muyter @ 2021-03-04  9:31 UTC (permalink / raw)
  To: Jean-Baptiste Maneyrol; +Cc: linux-iio

Hello Jean-Baptiste,

thank you for your answer

I work actually with a nvidia-provided 4.9 kernel that I cannot change.
Up to now I have incorporated the mpu9250 related patches up to v4.12.

Do you think I should simply replace the inv_mpu6050 driver files of v4.9
by their v5.11 (or newer) counterparts ?

Thanks

Philippe

On Thu, Mar 04, 2021 at 09:12:47AM +0000, Jean-Baptiste Maneyrol wrote:
> Hello Philippe,
> 
> I would recommend letting mpu9250 chip drives the magnetometer instead of using the ak8963 driver.
> 
> This is simpler to use and guarantees a good synchronization between all sensors and no possible latency coming from kernel scheduling when polling the magnetometer. And it enables the use of spi bus for connecting the device.
> 
> You just need to define mpu9250 dts without an i2c-gate, and delete all definition of ak8963 chip.
> 
> Best regards,
> JB
> 
> 
> From: Philippe De Muyter <phdm@macq.eu>
> Sent: Wednesday, March 3, 2021 16:31
> To: linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>
> Subject: invensense mpu9250 ak8963 and devicetree 
>  
> Hello,
> 
> I am trying to use a mpu9250 imu, but I have trouble with the ak8963 part.
> 
> Currently, ak8975_probe fails in this code :
> 
>         /* Fetch the regulators */
>         data->vdd = devm_regulator_get(&client->dev, "vdd");
>         if (IS_ERR(data->vdd))
>                 return PTR_ERR(data->vdd);
>         data->vid = devm_regulator_get(&client->dev, "vid");
>         if (IS_ERR(data->vid))
>                 return PTR_ERR(data->vid);
> 
> but Documentation/devicetree/bindings/iio/magnetometer/asahi-kasei,ak8975.yaml
> says :
> 
>   vdd-supply:
>     description: |
>       an optional regulator that needs to be on to provide VDD power to
>       the sensor.
> 
> I have no vdd or vdd-supply property in my ak8963 description.
> 
> Is that unrelated ?
> 
> What should I write in my dts file for this ak8963 embedded in a mpu9250 ?
> 
> Thanks in advance
> 
> Philippe
> 
> -- 
> Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: invensense mpu9250 ak8963 and devicetree
       [not found] ` <BL0PR12MB501190F3812AA541BDBEF625C4979@BL0PR12MB5011.namprd12.prod.outlook.com>
@ 2021-03-08 13:06   ` Philippe De Muyter
  2021-03-08 17:24     ` Jonathan Cameron
  0 siblings, 1 reply; 8+ messages in thread
From: Philippe De Muyter @ 2021-03-08 13:06 UTC (permalink / raw)
  To: Jean-Baptiste Maneyrol; +Cc: linux-iio

Hello Jean-Baptiste,

On Thu, Mar 04, 2021 at 10:08:10AM +0000, Jean-Baptiste Maneyrol wrote:
> You can try to cherry-pick the corresponding commits inside Linux 5.10.
> 
> Or just copy the driver files and made the change to have them working properly.
> 

I have integrated in my kernel the patches up to v5.11.

My DT entry now is :

                mpu9250@68 {
                        compatible = "invensense,mpu9250";
                        reg = <0x68>;
                        interrupt-parent = <&tegra_main_gpio>;
                        interrupts = <TEGRA_MAIN_GPIO(P, 3) GPIO_ACTIVE_HIGH>;
                };

But probing fails with :

[    6.989291] inv-mpu6050-i2c 0-0068: mounting matrix not found: using identity...
[    6.989312] inv-mpu6050-i2c 0-0068: Failed to get vdd regulator -19

The "Failed to get vdd regulator" seems to come from those lines in
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c

        st->vdd_supply = devm_regulator_get(dev, "vdd");
        if (IS_ERR(st->vdd_supply)) {
                if (PTR_ERR(st->vdd_supply) != -EPROBE_DEFER)
                        dev_err(dev, "Failed to get vdd regulator %d\n",
                                (int)PTR_ERR(st->vdd_supply));

                return PTR_ERR(st->vdd_supply);
        }

Should I turn off those lines ?

Philippe

> Best regards,
> JB
> ________________________________
> From: Philippe De Muyter <phdm@macq.eu>
> Sent: Thursday, March 4, 2021 10:31
> To: Jean-Baptiste Maneyrol <JManeyrol@invensense.com>
> Cc: linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>
> Subject: Re: invensense mpu9250 ak8963 and devicetree
> 
>  CAUTION: This email originated from outside of the organization. Please make sure the sender is who they say they are and do not click links or open attachments unless you recognize the sender and know the content is safe.
> 
> Hello Jean-Baptiste,
> 
> thank you for your answer
> 
> I work actually with a nvidia-provided 4.9 kernel that I cannot change.
> Up to now I have incorporated the mpu9250 related patches up to v4.12.
> 
> Do you think I should simply replace the inv_mpu6050 driver files of v4.9
> by their v5.11 (or newer) counterparts ?
> 
> Thanks
> 
> Philippe
> 
> On Thu, Mar 04, 2021 at 09:12:47AM +0000, Jean-Baptiste Maneyrol wrote:
> > Hello Philippe,
> >
> > I would recommend letting mpu9250 chip drives the magnetometer instead of using the ak8963 driver.
> >
> > This is simpler to use and guarantees a good synchronization between all sensors and no possible latency coming from kernel scheduling when polling the magnetometer. And it enables the use of spi bus for connecting the device.
> >
> > You just need to define mpu9250 dts without an i2c-gate, and delete all definition of ak8963 chip.
> >
> > Best regards,
> > JB
> >
> >
> > From: Philippe De Muyter <phdm@macq.eu>
> > Sent: Wednesday, March 3, 2021 16:31
> > To: linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>
> > Subject: invensense mpu9250 ak8963 and devicetree
> >
> > Hello,
> >
> > I am trying to use a mpu9250 imu, but I have trouble with the ak8963 part.
> >
> > Currently, ak8975_probe fails in this code :
> >
> >         /* Fetch the regulators */
> >         data->vdd = devm_regulator_get(&client->dev, "vdd");
> >         if (IS_ERR(data->vdd))
> >                 return PTR_ERR(data->vdd);
> >         data->vid = devm_regulator_get(&client->dev, "vid");
> >         if (IS_ERR(data->vid))
> >                 return PTR_ERR(data->vid);
> >
> > but Documentation/devicetree/bindings/iio/magnetometer/asahi-kasei,ak8975.yaml
> > says :
> >
> >   vdd-supply:
> >     description: |
> >       an optional regulator that needs to be on to provide VDD power to
> >       the sensor.
> >
> > I have no vdd or vdd-supply property in my ak8963 description.
> >
> > Is that unrelated ?
> >
> > What should I write in my dts file for this ak8963 embedded in a mpu9250 ?
> >
> > Thanks in advance
> >
> > Philippe

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: invensense mpu9250 ak8963 and devicetree
  2021-03-08 13:06   ` Philippe De Muyter
@ 2021-03-08 17:24     ` Jonathan Cameron
  2021-03-09 10:11       ` Philippe De Muyter
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Cameron @ 2021-03-08 17:24 UTC (permalink / raw)
  To: Philippe De Muyter; +Cc: Jean-Baptiste Maneyrol, linux-iio

On Mon, 8 Mar 2021 14:06:30 +0100
Philippe De Muyter <phdm@macq.eu> wrote:

> Hello Jean-Baptiste,
> 
> On Thu, Mar 04, 2021 at 10:08:10AM +0000, Jean-Baptiste Maneyrol wrote:
> > You can try to cherry-pick the corresponding commits inside Linux 5.10.
> > 
> > Or just copy the driver files and made the change to have them working properly.
> >   
> 
> I have integrated in my kernel the patches up to v5.11.
> 
> My DT entry now is :
> 
>                 mpu9250@68 {
>                         compatible = "invensense,mpu9250";
>                         reg = <0x68>;
>                         interrupt-parent = <&tegra_main_gpio>;
>                         interrupts = <TEGRA_MAIN_GPIO(P, 3) GPIO_ACTIVE_HIGH>;
>                 };
> 
> But probing fails with :
> 
> [    6.989291] inv-mpu6050-i2c 0-0068: mounting matrix not found: using identity...
> [    6.989312] inv-mpu6050-i2c 0-0068: Failed to get vdd regulator -19
> 
> The "Failed to get vdd regulator" seems to come from those lines in
> drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> 
>         st->vdd_supply = devm_regulator_get(dev, "vdd");
>         if (IS_ERR(st->vdd_supply)) {
>                 if (PTR_ERR(st->vdd_supply) != -EPROBE_DEFER)
>                         dev_err(dev, "Failed to get vdd regulator %d\n",
>                                 (int)PTR_ERR(st->vdd_supply));
> 
>                 return PTR_ERR(st->vdd_supply);
>         }

That's odd because you should get a stub regulator... For simple cases
where the regulator is always on, there is no need to specify a regulator,
you can just rely on the regulator framework giving you one that basically
does nothing.

Could you have a look at why you aren't getting a dummy_regulator from the code
just below here?

https://elixir.bootlin.com/linux/latest/source/drivers/regulator/core.c#L1948

Jonathan

> 
> Should I turn off those lines ?
> 
> Philippe
> 
> > Best regards,
> > JB
> > ________________________________
> > From: Philippe De Muyter <phdm@macq.eu>
> > Sent: Thursday, March 4, 2021 10:31
> > To: Jean-Baptiste Maneyrol <JManeyrol@invensense.com>
> > Cc: linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>
> > Subject: Re: invensense mpu9250 ak8963 and devicetree
> > 
> >  CAUTION: This email originated from outside of the organization. Please make sure the sender is who they say they are and do not click links or open attachments unless you recognize the sender and know the content is safe.
> > 
> > Hello Jean-Baptiste,
> > 
> > thank you for your answer
> > 
> > I work actually with a nvidia-provided 4.9 kernel that I cannot change.
> > Up to now I have incorporated the mpu9250 related patches up to v4.12.
> > 
> > Do you think I should simply replace the inv_mpu6050 driver files of v4.9
> > by their v5.11 (or newer) counterparts ?
> > 
> > Thanks
> > 
> > Philippe
> > 
> > On Thu, Mar 04, 2021 at 09:12:47AM +0000, Jean-Baptiste Maneyrol wrote:  
> > > Hello Philippe,
> > >
> > > I would recommend letting mpu9250 chip drives the magnetometer instead of using the ak8963 driver.
> > >
> > > This is simpler to use and guarantees a good synchronization between all sensors and no possible latency coming from kernel scheduling when polling the magnetometer. And it enables the use of spi bus for connecting the device.
> > >
> > > You just need to define mpu9250 dts without an i2c-gate, and delete all definition of ak8963 chip.
> > >
> > > Best regards,
> > > JB
> > >
> > >
> > > From: Philippe De Muyter <phdm@macq.eu>
> > > Sent: Wednesday, March 3, 2021 16:31
> > > To: linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>
> > > Subject: invensense mpu9250 ak8963 and devicetree
> > >
> > > Hello,
> > >
> > > I am trying to use a mpu9250 imu, but I have trouble with the ak8963 part.
> > >
> > > Currently, ak8975_probe fails in this code :
> > >
> > >         /* Fetch the regulators */
> > >         data->vdd = devm_regulator_get(&client->dev, "vdd");
> > >         if (IS_ERR(data->vdd))
> > >                 return PTR_ERR(data->vdd);
> > >         data->vid = devm_regulator_get(&client->dev, "vid");
> > >         if (IS_ERR(data->vid))
> > >                 return PTR_ERR(data->vid);
> > >
> > > but Documentation/devicetree/bindings/iio/magnetometer/asahi-kasei,ak8975.yaml
> > > says :
> > >
> > >   vdd-supply:
> > >     description: |
> > >       an optional regulator that needs to be on to provide VDD power to
> > >       the sensor.
> > >
> > > I have no vdd or vdd-supply property in my ak8963 description.
> > >
> > > Is that unrelated ?
> > >
> > > What should I write in my dts file for this ak8963 embedded in a mpu9250 ?
> > >
> > > Thanks in advance
> > >
> > > Philippe  


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: invensense mpu9250 ak8963 and devicetree
  2021-03-08 17:24     ` Jonathan Cameron
@ 2021-03-09 10:11       ` Philippe De Muyter
  2021-03-09 10:46         ` Lars-Peter Clausen
  0 siblings, 1 reply; 8+ messages in thread
From: Philippe De Muyter @ 2021-03-09 10:11 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: Jean-Baptiste Maneyrol, linux-iio

Hello Jonathan,

Thank you for your answer that led me to the explanation.

On Mon, Mar 08, 2021 at 05:24:27PM +0000, Jonathan Cameron wrote:
> 
> That's odd because you should get a stub regulator... For simple cases
> where the regulator is always on, there is no need to specify a regulator,
> you can just rely on the regulator framework giving you one that basically
> does nothing.
> 
> Could you have a look at why you aren't getting a dummy_regulator from the code
> just below here?
> 
> https://elixir.bootlin.com/linux/latest/source/drivers/regulator/core.c#L1948
> 

I use a kernel provided by nvidia that is called tegra-l4t-r32.3.1, but
is based on v4.9.

Although the patch that provides automatically stub regulators
 4ddfebd3b "regulator: core: Provide a dummy regulator with full constraints"
is older than v3.13, I have found in the commits of my kernel on top of
v4.9, this one

commit 7f25dfa01aafe3d3ac1983a0d0f895775a80c005
Author: Laxman Dewangan <ldewangan@nvidia.com>
Date:   Tue Aug 11 18:28:53 2015 +0530

    regulator: core: do not allow dummy regulator if config not selected

    Do not allow dummy regulator if DUMMY REGULATOR not selected from
    config.

    Bug 200223300

    Change-Id: I672fb4f9d70f05bf3044b63c904be54e19c8ab36
    Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
    Reviewed-on: http://git-master/r/781784
    (cherry picked from commit 4e11e2b997d315587956e8537064277c5687bf70)
    Reviewed-on: http://git-master/r/1195179
    Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
    Reviewed-on: https://git-master.nvidia.com/r/1550248
    Tested-by: Ujwal Patel <ujwalp@nvidia.com>
    Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
    Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
    Reviewed-by: Shardar Mohammed <smohammed@nvidia.com>
    Tested-by: Shardar Mohammed <smohammed@nvidia.com>
    GVS: Gerrit_Virtual_Submit

And CONFIG_REGULATOR_DUMMY is disabled in the default kernel configuration
provided by nvidia :(

Philippe

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: invensense mpu9250 ak8963 and devicetree
  2021-03-09 10:11       ` Philippe De Muyter
@ 2021-03-09 10:46         ` Lars-Peter Clausen
  2021-03-09 10:59           ` Philippe De Muyter
  0 siblings, 1 reply; 8+ messages in thread
From: Lars-Peter Clausen @ 2021-03-09 10:46 UTC (permalink / raw)
  To: Philippe De Muyter, Jonathan Cameron; +Cc: Jean-Baptiste Maneyrol, linux-iio

On 3/9/21 11:11 AM, Philippe De Muyter wrote:
> Hello Jonathan,
> 
> Thank you for your answer that led me to the explanation.
> 
> On Mon, Mar 08, 2021 at 05:24:27PM +0000, Jonathan Cameron wrote:
>>
>> That's odd because you should get a stub regulator... For simple cases
>> where the regulator is always on, there is no need to specify a regulator,
>> you can just rely on the regulator framework giving you one that basically
>> does nothing.
>>
>> Could you have a look at why you aren't getting a dummy_regulator from the code
>> just below here?
>>
>> https://elixir.bootlin.com/linux/latest/source/drivers/regulator/core.c#L1948
>>
> 
> I use a kernel provided by nvidia that is called tegra-l4t-r32.3.1, but
> is based on v4.9.
> 
> Although the patch that provides automatically stub regulators
>   4ddfebd3b "regulator: core: Provide a dummy regulator with full constraints"
> is older than v3.13, I have found in the commits of my kernel on top of
> v4.9, this one
[...]
> And CONFIG_REGULATOR_DUMMY is disabled in the default kernel configuration
> provided by nvidia :(

To work around this you can add a fixed-regulator to your devicetree and 
connect it to the IMU. 
Seehttps://www.kernel.org/doc/Documentation/devicetree/bindings/regulator/fixed-regulator.txt

- Lars


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: invensense mpu9250 ak8963 and devicetree
  2021-03-09 10:46         ` Lars-Peter Clausen
@ 2021-03-09 10:59           ` Philippe De Muyter
  0 siblings, 0 replies; 8+ messages in thread
From: Philippe De Muyter @ 2021-03-09 10:59 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Jonathan Cameron, Jean-Baptiste Maneyrol, linux-iio

Thank you Lars,

On Tue, Mar 09, 2021 at 11:46:54AM +0100, Lars-Peter Clausen wrote:
> On 3/9/21 11:11 AM, Philippe De Muyter wrote:
>> I use a kernel provided by nvidia that is called tegra-l4t-r32.3.1, but
>> is based on v4.9.
>> Although the patch that provides automatically stub regulators
>>   4ddfebd3b "regulator: core: Provide a dummy regulator with full 
>> constraints"
>> is older than v3.13, I have found in the commits of my kernel on top of
>> v4.9, this one
> [...]
>> And CONFIG_REGULATOR_DUMMY is disabled in the default kernel configuration
>> provided by nvidia :(
>
> To work around this you can add a fixed-regulator to your devicetree and 
> connect it to the IMU. 
> Seehttps://www.kernel.org/doc/Documentation/devicetree/bindings/regulator/fixed-regulator.txt

I have enabled REGULATOR_DUMMY and that solved the problem.

Philippe

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-03-09 11:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03 15:31 invensense mpu9250 ak8963 and devicetree Philippe De Muyter
2021-03-04  9:12 ` Jean-Baptiste Maneyrol
2021-03-04  9:31   ` Philippe De Muyter
     [not found] ` <BL0PR12MB501190F3812AA541BDBEF625C4979@BL0PR12MB5011.namprd12.prod.outlook.com>
2021-03-08 13:06   ` Philippe De Muyter
2021-03-08 17:24     ` Jonathan Cameron
2021-03-09 10:11       ` Philippe De Muyter
2021-03-09 10:46         ` Lars-Peter Clausen
2021-03-09 10:59           ` Philippe De Muyter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.