diff mbox

Odroid XU3 DTS: Hook up PWM and use it for LEDs

Message ID 84vbfyk4w4.wl-peter.chubb@nicta.com.au (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Chubb May 12, 2015, 12:29 a.m. UTC
PWM output on the XU3 wasn't working because it wasn't hooked up to
its pincontrol.

This patch:
   -- hooks up PWM to its pincontrol, and documents what
      the outputs are on the XU3
   -- switches the LEDs that are on PWM outputs to use PWM
      rather than GPIO.

The main effect is that the brightness of the LEDs can be controlled, and
user-mode fan control is enabled via /sys/class/pwm

The patch is against the for-next branch of the linux-samsung tree.

Signed-off-by: Peter Chubb <peter.chubb@nicta.com.au>
---
 arch/arm/boot/dts/exynos5422-odroidxu3.dts | 55 +++++++++++++++++++++---------
 1 file changed, 39 insertions(+), 16 deletions(-)

--
2.1.4


--
Dr Peter Chubb                                  peter.chubb AT nicta.com.au
http://www.ssrg.nicta.com.au          Software Systems Research Group/NICTA

Comments

Krzysztof Kozlowski May 12, 2015, 1:15 a.m. UTC | #1
2015-05-12 9:29 GMT+09:00 Peter Chubb <peter.chubb@nicta.com.au>:
>
> PWM output on the XU3 wasn't working because it wasn't hooked up to
> its pincontrol.

Hi,

Use a common convention of patch title - prefix with "ARM: dts:" and
optionally name of the board. Just look at previous commits in
arch/arm/boot/dts/.

>
> This patch:
>    -- hooks up PWM to its pincontrol, and documents what
>       the outputs are on the XU3
>    -- switches the LEDs that are on PWM outputs to use PWM
>       rather than GPIO.
>
> The main effect is that the brightness of the LEDs can be controlled, and
> user-mode fan control is enabled via /sys/class/pwm
>
> The patch is against the for-next branch of the linux-samsung tree.
>
> Signed-off-by: Peter Chubb <peter.chubb@nicta.com.au>
> ---
>  arch/arm/boot/dts/exynos5422-odroidxu3.dts | 55 +++++++++++++++++++++---------
>  1 file changed, 39 insertions(+), 16 deletions(-)
>
> diff --git a/arch/arm/boot/dts/exynos5422-odroidxu3.dts b/arch/arm/boot/dts/exynos5422-odroidxu3.dts
> index 026f83e..84d71a1 100644
> --- a/arch/arm/boot/dts/exynos5422-odroidxu3.dts
> +++ b/arch/arm/boot/dts/exynos5422-odroidxu3.dts
> @@ -13,6 +13,7 @@
>  /dts-v1/;
>  #include <dt-bindings/gpio/gpio.h>
>  #include "exynos5800.dtsi"
> +#include <dt-bindings/gpio/gpio.h>
>
>  / {
>         model = "Hardkernel Odroid XU3";
> @@ -287,25 +288,47 @@
>                 status = "okay";
>         };
>
> -       leds {
> -               compatible = "gpio-leds";
> -               heartbeat {
> -                       label = "blue:heartbeart";
> -                       gpios = <&gpb2 2 0>;
> -                       default-state = "off";
> -                       linux,default-trigger = "heartbeat";
> -               };
> +       pwm: pwm@12dd0000 {

The label for node is already specified in exynos5420.dtsi. Don't
duplicate it. Actually when overriding nodes you should use
label-convention:
&pwm {
    ...
};

Best regards,
Krzysztof
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Peter Chubb May 12, 2015, 1:25 a.m. UTC | #2
>>>>> "Krzysztof" == Krzysztof Kozlowski <k.kozlowski@samsung.com> writes:

Krzysztof> 2015-05-12 9:29 GMT+09:00 Peter Chubb
Krzysztof> <peter.chubb@nicta.com.au>:
>>
>> PWM output on the XU3 wasn't working because it wasn't hooked up to
>> its pincontrol.

Krzysztof> Hi,

Krzysztof> Use a common convention of patch title - prefix with "ARM:
Krzysztof> dts:" and optionally name of the board. Just look at
Krzysztof> previous commits in arch/arm/boot/dts/.


Thanks I'll fix.

Krzysztof> The label for node is already specified in
Krzysztof> exynos5420.dtsi. Don't duplicate it. Actually when
Krzysztof> overriding nodes you should use label-convention: &pwm {
Krzysztof> ...  };

I wasn't sure whether I shouldn't have changed exynos5422.dtsi
rather than here, and just leave the "status = 'okay'" part for this file.

What do you think?  All exynos 54xx parts have the same PWM using the
same pincontrol -- if it's enabled maybe it should be common?

--
Dr Peter Chubb                                  peter.chubb AT nicta.com.au
http://www.ssrg.nicta.com.au          Software Systems Research Group/NICTA
Krzysztof Kozlowski May 12, 2015, 1:37 a.m. UTC | #3
2015-05-12 10:25 GMT+09:00 Peter Chubb <peter.chubb@nicta.com.au>:
>
> Krzysztof> The label for node is already specified in
> Krzysztof> exynos5420.dtsi. Don't duplicate it. Actually when
> Krzysztof> overriding nodes you should use label-convention: &pwm {
> Krzysztof> ...  };
>
> I wasn't sure whether I shouldn't have changed exynos5422.dtsi
> rather than here, and just leave the "status = 'okay'" part for this file.
>
> What do you think?  All exynos 54xx parts have the same PWM using the
> same pincontrol -- if it's enabled maybe it should be common?
>

You are actually overriding the node here, so I meant that instead of:

+       pwm: pwm@12dd0000 {
+               /*
+                * PWM 0 -- fan
+                * PWM 1 -- Green LED
+                * PWM 2 -- Blue LED
+                * PWM 3 -- on MIPI connector for backlight
+                */
+               pinctrl-0 = <&pwm0_out &pwm1_out &pwm2_out &pwm3_out>;
+               pinctrl-names = "default";
+               status = "okay";
+       };

do like:

+ &pwm {
+               /*
+                * PWM 0 -- fan
+                * PWM 1 -- Green LED
+                * PWM 2 -- Blue LED
+                * PWM 3 -- on MIPI connector for backlight
+                */
+               pinctrl-0 = <&pwm0_out &pwm1_out &pwm2_out &pwm3_out>;
+               pinctrl-names = "default";
+               status = "okay";
+       };

This does not require touching exynos5422.dtsi (there is no such file
:) ) or other DTSI.

As for generalizing this for other Exynos54xx boards - it depends if
the wires are the same. I don't know how it is connected on other
boards.
Additionally what is connected to the GPIOs of the SoC is not usually
a property of the SoC but the board. So in such case it could go to a
common-board-DTSI file for but rather not for the SoC DTSI. Also then
it would require testing on these common boards.

Best regards,
Krzysztof
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/arm/boot/dts/exynos5422-odroidxu3.dts b/arch/arm/boot/dts/exynos5422-odroidxu3.dts
index 026f83e..84d71a1 100644
--- a/arch/arm/boot/dts/exynos5422-odroidxu3.dts
+++ b/arch/arm/boot/dts/exynos5422-odroidxu3.dts
@@ -13,6 +13,7 @@ 
 /dts-v1/;
 #include <dt-bindings/gpio/gpio.h>
 #include "exynos5800.dtsi"
+#include <dt-bindings/gpio/gpio.h>

 / {
        model = "Hardkernel Odroid XU3";
@@ -287,25 +288,47 @@ 
                status = "okay";
        };

-       leds {
-               compatible = "gpio-leds";
-               heartbeat {
-                       label = "blue:heartbeart";
-                       gpios = <&gpb2 2 0>;
-                       default-state = "off";
-                       linux,default-trigger = "heartbeat";
-               };
+       pwm: pwm@12dd0000 {
+               /*
+                * PWM 0 -- fan
+                * PWM 1 -- Green LED
+                * PWM 2 -- Blue LED
+                * PWM 3 -- on MIPI connector for backlight
+                */
+               pinctrl-0 = <&pwm0_out &pwm1_out &pwm2_out &pwm3_out>;
+               pinctrl-names = "default";
+               status = "okay";
+       };

-               eMMC {
-                       label = "green:eMMC";
-                       gpios = <&gpb2 1 0>;
-                       default-state = "off";
-                       linux,default-trigger = "mmc0";
-               };
+       pwmleds {
+            compatible = "pwm-leds";
+
+            greenled {
+                    label = "green:mmc0";
+                    pwms = <&pwm 1 2000000 0>;
+                    pwm-names = "pwm1";
+                    /*
+                     * Green LED is much brighter than the others
+                     * so limit its max brightness
+                     */
+                    max_brightness = <127>;
+                    linux,default-trigger = "mmc0";
+            };
+
+            blueled {
+                    label = "blue:heartbeat";
+                    pwms = <&pwm 2 2000000 0>;
+                    pwm-names = "pwm2";
+                    max_brightness = <255>;
+                    linux,default-trigger = "heartbeat";
+            };
+       };

-               microSD {
+       gpioleds {
+               compatible = "gpio-leds";
+               redled {
                        label = "red:microSD";
-                       gpios = <&gpx2 3 0>;
+                       gpios = <&gpx2 3 GPIO_ACTIVE_HIGH>;
                        default-state = "off";
                        linux,default-trigger = "mmc1";
                };