2020-08-25 16:29:47

by Prabhakar Mahadev Lad

[permalink] [raw]
Subject: [PATCH 4/4] ARM: dts: r8a7742-iwg21d-q7: Enable SD2 LED indication

Add support for LED trigger on SD2 interface.

Signed-off-by: Lad Prabhakar <[email protected]>
Reviewed-by: Chris Paterson <[email protected]>
---
arch/arm/boot/dts/r8a7742-iwg21d-q7.dts | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/arch/arm/boot/dts/r8a7742-iwg21d-q7.dts b/arch/arm/boot/dts/r8a7742-iwg21d-q7.dts
index 070fc9729b39..6d31d2401481 100644
--- a/arch/arm/boot/dts/r8a7742-iwg21d-q7.dts
+++ b/arch/arm/boot/dts/r8a7742-iwg21d-q7.dts
@@ -63,6 +63,16 @@
enable-gpios = <&gpio3 11 GPIO_ACTIVE_HIGH>;
};

+ leds {
+ compatible = "gpio-leds";
+
+ sdhi2_led {
+ label = "sdio-led";
+ gpios = <&gpio5 22 GPIO_ACTIVE_LOW>;
+ linux,default-trigger = "mmc1";
+ };
+ };
+
lvds-receiver {
compatible = "ti,ds90cf384a", "lvds-decoder";
vcc-supply = <&vcc_3v3_tft1>;
--
2.17.1


2020-09-03 12:25:46

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 4/4] ARM: dts: r8a7742-iwg21d-q7: Enable SD2 LED indication

Hi Prabhakar,

On Tue, Aug 25, 2020 at 6:28 PM Lad Prabhakar
<[email protected]> wrote:
> Add support for LED trigger on SD2 interface.
>
> Signed-off-by: Lad Prabhakar <[email protected]>
> Reviewed-by: Chris Paterson <[email protected]>

> --- a/arch/arm/boot/dts/r8a7742-iwg21d-q7.dts
> +++ b/arch/arm/boot/dts/r8a7742-iwg21d-q7.dts
> @@ -63,6 +63,16 @@
> enable-gpios = <&gpio3 11 GPIO_ACTIVE_HIGH>;
> };
>
> + leds {
> + compatible = "gpio-leds";
> +
> + sdhi2_led {
> + label = "sdio-led";
> + gpios = <&gpio5 22 GPIO_ACTIVE_LOW>;

GPIO_ACTIVE_HIGH?

The LED is driven by an NPN transistor, with the LED between 3.3V and
the transistor's collector.

> + linux,default-trigger = "mmc1";
> + };
> + };
> +
> lvds-receiver {
> compatible = "ti,ds90cf384a", "lvds-decoder";
> vcc-supply = <&vcc_3v3_tft1>;

With the above fixed:
Reviewed-by: Geert Uytterhoeven <[email protected]>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2020-09-04 17:17:13

by Lad, Prabhakar

[permalink] [raw]
Subject: Re: [PATCH 4/4] ARM: dts: r8a7742-iwg21d-q7: Enable SD2 LED indication

Hi Geert,

Thank you for the review.

On Thu, Sep 3, 2020 at 1:20 PM Geert Uytterhoeven <[email protected]> wrote:
>
> Hi Prabhakar,
>
> On Tue, Aug 25, 2020 at 6:28 PM Lad Prabhakar
> <[email protected]> wrote:
> > Add support for LED trigger on SD2 interface.
> >
> > Signed-off-by: Lad Prabhakar <[email protected]>
> > Reviewed-by: Chris Paterson <[email protected]>
>
> > --- a/arch/arm/boot/dts/r8a7742-iwg21d-q7.dts
> > +++ b/arch/arm/boot/dts/r8a7742-iwg21d-q7.dts
> > @@ -63,6 +63,16 @@
> > enable-gpios = <&gpio3 11 GPIO_ACTIVE_HIGH>;
> > };
> >
> > + leds {
> > + compatible = "gpio-leds";
> > +
> > + sdhi2_led {
> > + label = "sdio-led";
> > + gpios = <&gpio5 22 GPIO_ACTIVE_LOW>;
>
> GPIO_ACTIVE_HIGH?
>
I did try with GPIO_ACTIVE_HIGH and it didn't work as expected. To
make sure I can control the LED through sysfs I deleted the node from
DTS and exported the pin GP5_22 (858) and writing the value "out"
direction and setting the values 0/1 to value did not toggle the SDIO
LED as expected and it stayed OFF all the time.

Looks like there is some information missing in the schematics.

I did some experiments. I completely removed the SDHI, LED and
regulator nodes and booted the system and exported GP1_27 (989) and
wrote values 0/1 and this toggled the SDIO_LED.

U-boot sets the below, so in u-boot the SDIO_LED is ON:
gpio_direction_output(GPIO_GP_1_27, 0); /* power on */
gpio_set_value(GPIO_GP_1_27, 0);
gpio_direction_output(GPIO_GP_5_22, 0); /* LED */
gpio_set_value(GPIO_GP_5_22, 1);
gpio_direction_output(GPIO_GP_1_8, 0); /* 1: 3.3V, 0: 1.8V*/
gpio_set_value(GPIO_GP_1_8, 1);

So in comparison we would need a hog node as below (and with this the
LED triggers correctly as expected),

&gpio5 {
sdio-led-gpio {
gpio-hog;
gpios = <22 GPIO_ACTIVE_HIGH>;
output-high;
line-name = "sdio-led-gpio";
};
};

Let me know if you are OK with the above.

Looks like the SDIO_PWR is tied up with an SDIO_LED pin and the
information is missing from schematics.

Cheers,
Prabhakar

> The LED is driven by an NPN transistor, with the LED between 3.3V and
> the transistor's collector.
>
> > + linux,default-trigger = "mmc1";
> > + };
> > + };
> > +
> > lvds-receiver {
> > compatible = "ti,ds90cf384a", "lvds-decoder";
> > vcc-supply = <&vcc_3v3_tft1>;
>
> With the above fixed:
> Reviewed-by: Geert Uytterhoeven <[email protected]>
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds

2020-09-07 07:58:56

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 4/4] ARM: dts: r8a7742-iwg21d-q7: Enable SD2 LED indication

Hi Prabhakar,

On Fri, Sep 4, 2020 at 7:15 PM Lad, Prabhakar
<[email protected]> wrote:
> On Thu, Sep 3, 2020 at 1:20 PM Geert Uytterhoeven <[email protected]> wrote:
> > On Tue, Aug 25, 2020 at 6:28 PM Lad Prabhakar
> > <[email protected]> wrote:
> > > Add support for LED trigger on SD2 interface.
> > >
> > > Signed-off-by: Lad Prabhakar <[email protected]>
> > > Reviewed-by: Chris Paterson <[email protected]>
> >
> > > --- a/arch/arm/boot/dts/r8a7742-iwg21d-q7.dts
> > > +++ b/arch/arm/boot/dts/r8a7742-iwg21d-q7.dts
> > > @@ -63,6 +63,16 @@
> > > enable-gpios = <&gpio3 11 GPIO_ACTIVE_HIGH>;
> > > };
> > >
> > > + leds {
> > > + compatible = "gpio-leds";
> > > +
> > > + sdhi2_led {
> > > + label = "sdio-led";
> > > + gpios = <&gpio5 22 GPIO_ACTIVE_LOW>;
> >
> > GPIO_ACTIVE_HIGH?
> >
> > The LED is driven by an NPN transistor, with the LED between 3.3V and
> > the transistor's collector.

Oops, 3.3V is not VCC_3V3, but SD_3V3, so it is not always-on, but
controlled by SDIO_PWR.

> I did try with GPIO_ACTIVE_HIGH and it didn't work as expected. To
> make sure I can control the LED through sysfs I deleted the node from
> DTS and exported the pin GP5_22 (858) and writing the value "out"
> direction and setting the values 0/1 to value did not toggle the SDIO
> LED as expected and it stayed OFF all the time.

Hence when SDIO_PWR is turned off, you cannot control the LED just by
toggling GP5_22.

> Looks like there is some information missing in the schematics.
>
> I did some experiments. I completely removed the SDHI, LED and
> regulator nodes and booted the system and exported GP1_27 (989) and
> wrote values 0/1 and this toggled the SDIO_LED.
>
> U-boot sets the below, so in u-boot the SDIO_LED is ON:
> gpio_direction_output(GPIO_GP_1_27, 0); /* power on */
> gpio_set_value(GPIO_GP_1_27, 0);
> gpio_direction_output(GPIO_GP_5_22, 0); /* LED */
> gpio_set_value(GPIO_GP_5_22, 1);
> gpio_direction_output(GPIO_GP_1_8, 0); /* 1: 3.3V, 0: 1.8V*/
> gpio_set_value(GPIO_GP_1_8, 1);
>
> So in comparison we would need a hog node as below (and with this the
> LED triggers correctly as expected),
>
> &gpio5 {
> sdio-led-gpio {
> gpio-hog;
> gpios = <22 GPIO_ACTIVE_HIGH>;
> output-high;
> line-name = "sdio-led-gpio";
> };
> };
>
> Let me know if you are OK with the above.

The above means the LED is always lit when SDIO_PWR is enabled.
While I agree that's some kind of SD activity indicator, probably it's less
fine-grained than using the mmc1 trigger?
I assume the mmc1 trigger is only activated when SDIO_PWR is enabled.
Are you sure this doesn't work?
Perhaps your kernel was missing SD trigger support, or "mmc1" is the
wrong SD instance?

> Looks like the SDIO_PWR is tied up with an SDIO_LED pin and the
> information is missing from schematics.

No, I think we just misread the schematics.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2020-09-07 15:28:22

by Lad, Prabhakar

[permalink] [raw]
Subject: Re: [PATCH 4/4] ARM: dts: r8a7742-iwg21d-q7: Enable SD2 LED indication

Hi Geert,

On Mon, Sep 7, 2020 at 8:55 AM Geert Uytterhoeven <[email protected]> wrote:
>
> Hi Prabhakar,
>
> On Fri, Sep 4, 2020 at 7:15 PM Lad, Prabhakar
> <[email protected]> wrote:
> > On Thu, Sep 3, 2020 at 1:20 PM Geert Uytterhoeven <[email protected]> wrote:
> > > On Tue, Aug 25, 2020 at 6:28 PM Lad Prabhakar
> > > <[email protected]> wrote:
> > > > Add support for LED trigger on SD2 interface.
> > > >
> > > > Signed-off-by: Lad Prabhakar <[email protected]>
> > > > Reviewed-by: Chris Paterson <[email protected]>
> > >
> > > > --- a/arch/arm/boot/dts/r8a7742-iwg21d-q7.dts
> > > > +++ b/arch/arm/boot/dts/r8a7742-iwg21d-q7.dts
> > > > @@ -63,6 +63,16 @@
> > > > enable-gpios = <&gpio3 11 GPIO_ACTIVE_HIGH>;
> > > > };
> > > >
> > > > + leds {
> > > > + compatible = "gpio-leds";
> > > > +
> > > > + sdhi2_led {
> > > > + label = "sdio-led";
> > > > + gpios = <&gpio5 22 GPIO_ACTIVE_LOW>;
> > >
> > > GPIO_ACTIVE_HIGH?
> > >
> > > The LED is driven by an NPN transistor, with the LED between 3.3V and
> > > the transistor's collector.
>
> Oops, 3.3V is not VCC_3V3, but SD_3V3, so it is not always-on, but
> controlled by SDIO_PWR.
>
> > I did try with GPIO_ACTIVE_HIGH and it didn't work as expected. To
> > make sure I can control the LED through sysfs I deleted the node from
> > DTS and exported the pin GP5_22 (858) and writing the value "out"
> > direction and setting the values 0/1 to value did not toggle the SDIO
> > LED as expected and it stayed OFF all the time.
>
> Hence when SDIO_PWR is turned off, you cannot control the LED just by
> toggling GP5_22.
>
> > Looks like there is some information missing in the schematics.
> >
> > I did some experiments. I completely removed the SDHI, LED and
> > regulator nodes and booted the system and exported GP1_27 (989) and
> > wrote values 0/1 and this toggled the SDIO_LED.
> >
> > U-boot sets the below, so in u-boot the SDIO_LED is ON:
> > gpio_direction_output(GPIO_GP_1_27, 0); /* power on */
> > gpio_set_value(GPIO_GP_1_27, 0);
> > gpio_direction_output(GPIO_GP_5_22, 0); /* LED */
> > gpio_set_value(GPIO_GP_5_22, 1);
> > gpio_direction_output(GPIO_GP_1_8, 0); /* 1: 3.3V, 0: 1.8V*/
> > gpio_set_value(GPIO_GP_1_8, 1);
> >
> > So in comparison we would need a hog node as below (and with this the
> > LED triggers correctly as expected),
> >
> > &gpio5 {
> > sdio-led-gpio {
> > gpio-hog;
> > gpios = <22 GPIO_ACTIVE_HIGH>;
> > output-high;
> > line-name = "sdio-led-gpio";
> > };
> > };
> >
> > Let me know if you are OK with the above.
>
> The above means the LED is always lit when SDIO_PWR is enabled.
> While I agree that's some kind of SD activity indicator, probably it's less
> fine-grained than using the mmc1 trigger?
> I assume the mmc1 trigger is only activated when SDIO_PWR is enabled.
> Are you sure this doesn't work?
> Perhaps your kernel was missing SD trigger support, or "mmc1" is the
> wrong SD instance?
>
> > Looks like the SDIO_PWR is tied up with an SDIO_LED pin and the
> > information is missing from schematics.
>
> No, I think we just misread the schematics.
>
My bad I misinterpreted the trigger, with GP5_22 being GPIO_ACTIVE_LOW
the LED remained ON when the card was inserted and turned OFF when the
card was pulled out.

When GP5_22 being GPIO_ACTIVE_HIGH the LED blinked and stayed OFF when
the card was inserted and remained OFF when the card was pulled out.
As a result I misinterpreted it.

I can confirm when GP5_22 is GPIO_ACTIVE_HIGH and there is any
activity on SD (read/write) the led turns ON.

Cheers,
Prabhakar

2020-10-09 07:27:41

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH 4/4] ARM: dts: r8a7742-iwg21d-q7: Enable SD2 LED indication

Hi!

> --- a/arch/arm/boot/dts/r8a7742-iwg21d-q7.dts
> +++ b/arch/arm/boot/dts/r8a7742-iwg21d-q7.dts
> @@ -63,6 +63,16 @@
> enable-gpios = <&gpio3 11 GPIO_ACTIVE_HIGH>;
> };
>
> + leds {
> + compatible = "gpio-leds";
> +
> + sdhi2_led {
> + label = "sdio-led";

I believe this should be something like "mmc1:green:activity"...

> + gpios = <&gpio5 22 GPIO_ACTIVE_LOW>;
> + linux,default-trigger = "mmc1";
> + };
> + };

Best regards,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (627.00 B)
signature.asc (188.00 B)
Digital signature
Download all attachments