2023-01-06 14:19:57

by Sasha Finkelstein

[permalink] [raw]
Subject: [PATCH v6 0/5] PWM and keyboard backlight driver for ARM Macs

Hi,

This is the v6 of the patch series to add PWM and keyboard backlight
driver for ARM macs. This time the changes are a bit more substantial
and include the changes to the t600x (M1 Pro/Max) device trees.

Here is hoping that this time, the paint on this shed is up
to everyone's standards.

Changes in v1:
Addressing the review comments.

Changes in v2:
Added the reviewed-by and acked-by tags.
Addressing a review comment.

Changes in v3 and v4:
Addressing the review comments.

Changes in v5:
Added t600x device tree changes

v1: https://www.spinics.net/lists/linux-pwm/msg19500.html
v2: https://www.spinics.net/lists/linux-pwm/msg19562.html
v3: https://www.spinics.net/lists/linux-pwm/msg19901.html
v4: https://www.spinics.net/lists/linux-pwm/msg20093.html
v5: https://www.spinics.net/lists/linux-pwm/msg20150.html

Sasha Finkelstein (5):
dt-bindings: pwm: Add Apple PWM controller
pwm: Add Apple PWM controller
arm64: dts: apple: t8103: Add PWM controller
arm64: dts: apple: t600x: Add PWM controller
MAINTAINERS: Add entries for Apple PWM driver

.../bindings/pwm/apple,s5l-fpwm.yaml | 51 ++++++
MAINTAINERS | 2 +
arch/arm64/boot/dts/apple/t600x-die0.dtsi | 9 +
.../arm64/boot/dts/apple/t600x-j314-j316.dtsi | 18 ++
arch/arm64/boot/dts/apple/t8103-j293.dts | 17 ++
arch/arm64/boot/dts/apple/t8103-j313.dts | 17 ++
arch/arm64/boot/dts/apple/t8103.dtsi | 9 +
drivers/pwm/Kconfig | 12 ++
drivers/pwm/Makefile | 1 +
drivers/pwm/pwm-apple.c | 156 ++++++++++++++++++
10 files changed, 292 insertions(+)
create mode 100644 Documentation/devicetree/bindings/pwm/apple,s5l-fpwm.yaml
create mode 100644 drivers/pwm/pwm-apple.c

--
2.37.1 (Apple Git-137.1)


2023-01-06 14:20:25

by Sasha Finkelstein

[permalink] [raw]
Subject: [PATCH v6 5/5] MAINTAINERS: Add entries for Apple PWM driver

Add the MAINTAINERS entries for the driver

Signed-off-by: Sasha Finkelstein <[email protected]>
Acked-by: Sven Peter <[email protected]>
---
MAINTAINERS | 2 ++
1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7f86d02cb427..75bda5ab704d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1970,6 +1970,7 @@ F: Documentation/devicetree/bindings/nvmem/apple,efuses.yaml
F: Documentation/devicetree/bindings/pci/apple,pcie.yaml
F: Documentation/devicetree/bindings/pinctrl/apple,pinctrl.yaml
F: Documentation/devicetree/bindings/power/apple*
+F: Documentation/devicetree/bindings/pwm/pwm-apple.yaml
F: Documentation/devicetree/bindings/watchdog/apple,wdt.yaml
F: arch/arm64/boot/dts/apple/
F: drivers/bluetooth/hci_bcm4377.c
@@ -1985,6 +1986,7 @@ F: drivers/mailbox/apple-mailbox.c
F: drivers/nvme/host/apple.c
F: drivers/nvmem/apple-efuses.c
F: drivers/pinctrl/pinctrl-apple-gpio.c
+F: drivers/pwm/pwm-apple.c
F: drivers/soc/apple/*
F: drivers/watchdog/apple_wdt.c
F: include/dt-bindings/interrupt-controller/apple-aic.h
--
2.37.1 (Apple Git-137.1)

2023-01-06 14:26:11

by Sasha Finkelstein

[permalink] [raw]
Subject: [PATCH v6 3/5] arm64: dts: apple: t8103: Add PWM controller

Adds PWM controller and keyboard backlight bindings for M1 MacBooks

Signed-off-by: Sasha Finkelstein <[email protected]>
Acked-by: Sven Peter <[email protected]>
---
arch/arm64/boot/dts/apple/t8103-j293.dts | 17 +++++++++++++++++
arch/arm64/boot/dts/apple/t8103-j313.dts | 17 +++++++++++++++++
arch/arm64/boot/dts/apple/t8103.dtsi | 9 +++++++++
3 files changed, 43 insertions(+)

diff --git a/arch/arm64/boot/dts/apple/t8103-j293.dts b/arch/arm64/boot/dts/apple/t8103-j293.dts
index 151074109a11..7381dccc1613 100644
--- a/arch/arm64/boot/dts/apple/t8103-j293.dts
+++ b/arch/arm64/boot/dts/apple/t8103-j293.dts
@@ -11,10 +11,23 @@

#include "t8103.dtsi"
#include "t8103-jxxx.dtsi"
+#include <dt-bindings/leds/common.h>

/ {
compatible = "apple,j293", "apple,t8103", "apple,arm-platform";
model = "Apple MacBook Pro (13-inch, M1, 2020)";
+
+ led-controller {
+ compatible = "pwm-leds";
+ led-0 {
+ pwms = <&fpwm1 0 40000>;
+ label = "kbd_backlight";
+ function = LED_FUNCTION_KBD_BACKLIGHT;
+ color = <LED_COLOR_ID_WHITE>;
+ max-brightness = <255>;
+ default-state = "keep";
+ };
+ };
};

&bluetooth0 {
@@ -47,3 +60,7 @@ &i2c2 {
&i2c4 {
status = "okay";
};
+
+&fpwm1 {
+ status = "okay";
+};
\ No newline at end of file
diff --git a/arch/arm64/boot/dts/apple/t8103-j313.dts b/arch/arm64/boot/dts/apple/t8103-j313.dts
index bc1f865aa790..1e26aa1ef525 100644
--- a/arch/arm64/boot/dts/apple/t8103-j313.dts
+++ b/arch/arm64/boot/dts/apple/t8103-j313.dts
@@ -11,10 +11,23 @@

#include "t8103.dtsi"
#include "t8103-jxxx.dtsi"
+#include <dt-bindings/leds/common.h>

/ {
compatible = "apple,j313", "apple,t8103", "apple,arm-platform";
model = "Apple MacBook Air (M1, 2020)";
+
+ led-controller {
+ compatible = "pwm-leds";
+ led-0 {
+ pwms = <&fpwm1 0 40000>;
+ label = "kbd_backlight";
+ function = LED_FUNCTION_KBD_BACKLIGHT;
+ color = <LED_COLOR_ID_WHITE>;
+ max-brightness = <255>;
+ default-state = "keep";
+ };
+ };
};

&bluetooth0 {
@@ -39,3 +52,7 @@ &pcie0_dart_2 {

/delete-node/ &port01;
/delete-node/ &port02;
+
+&fpwm1 {
+ status = "okay";
+};
diff --git a/arch/arm64/boot/dts/apple/t8103.dtsi b/arch/arm64/boot/dts/apple/t8103.dtsi
index 9859219699f4..5300fd115561 100644
--- a/arch/arm64/boot/dts/apple/t8103.dtsi
+++ b/arch/arm64/boot/dts/apple/t8103.dtsi
@@ -432,6 +432,15 @@ i2c4: i2c@235020000 {
status = "disabled"; /* only used in J293 */
};

+ fpwm1: pwm@235044000 {
+ compatible = "apple,t8103-fpwm", "apple,s5l-fpwm";
+ reg = <0x2 0x35044000 0x0 0x4000>;
+ power-domains = <&ps_fpwm1>;
+ clocks = <&clkref>;
+ #pwm-cells = <2>;
+ status = "disabled";
+ };
+
serial0: serial@235200000 {
compatible = "apple,s5l-uart";
reg = <0x2 0x35200000 0x0 0x1000>;
--
2.37.1 (Apple Git-137.1)

2023-01-06 14:28:09

by Sasha Finkelstein

[permalink] [raw]
Subject: [PATCH v6 4/5] arm64: dts: apple: t600x: Add PWM controller

Adds PWM controller and keyboard backlight bindings for M1 Pro/Max MacBook Pros

Signed-off-by: Sasha Finkelstein <[email protected]>
---
arch/arm64/boot/dts/apple/t600x-die0.dtsi | 9 +++++++++
arch/arm64/boot/dts/apple/t600x-j314-j316.dtsi | 18 ++++++++++++++++++
2 files changed, 27 insertions(+)

diff --git a/arch/arm64/boot/dts/apple/t600x-die0.dtsi b/arch/arm64/boot/dts/apple/t600x-die0.dtsi
index 1c41954e3899..7065045dc43a 100644
--- a/arch/arm64/boot/dts/apple/t600x-die0.dtsi
+++ b/arch/arm64/boot/dts/apple/t600x-die0.dtsi
@@ -154,6 +154,15 @@ i2c5: i2c@39b054000 {
status = "disabled";
};

+ fpwm0: pwm@39b030000 {
+ compatible = "apple,t6000-fpwm", "apple,s5l-fpwm";
+ reg = <0x3 0x9b030000 0x0 0x4000>;
+ power-domains = <&ps_fpwm0>;
+ clocks = <&clkref>;
+ #pwm-cells = <2>;
+ status = "disabled";
+ };
+
serial0: serial@39b200000 {
compatible = "apple,s5l-uart";
reg = <0x3 0x9b200000 0x0 0x1000>;
diff --git a/arch/arm64/boot/dts/apple/t600x-j314-j316.dtsi b/arch/arm64/boot/dts/apple/t600x-j314-j316.dtsi
index 34906d522f0a..96de7165df6d 100644
--- a/arch/arm64/boot/dts/apple/t600x-j314-j316.dtsi
+++ b/arch/arm64/boot/dts/apple/t600x-j314-j316.dtsi
@@ -9,6 +9,8 @@
* Copyright The Asahi Linux Contributors
*/

+#include <dt-bindings/leds/common.h>
+
/ {
aliases {
serial0 = &serial0;
@@ -34,6 +36,18 @@ memory@10000000000 {
device_type = "memory";
reg = <0x100 0 0x2 0>; /* To be filled by loader */
};
+
+ led-controller {
+ compatible = "pwm-leds";
+ led-0 {
+ pwms = <&fpwm0 0 40000>;
+ label = "kbd_backlight";
+ function = LED_FUNCTION_KBD_BACKLIGHT;
+ color = <LED_COLOR_ID_WHITE>;
+ max-brightness = <255>;
+ default-state = "keep";
+ };
+ };
};

&serial0 {
@@ -110,5 +124,9 @@ &pcie0_dart_3 {
status = "disabled";
};

+&fpwm0 {
+ status = "okay";
+};
+
/delete-node/ &port02;
/delete-node/ &port03;
--
2.37.1 (Apple Git-137.1)

2023-01-06 17:16:31

by Hector Martin

[permalink] [raw]
Subject: Re: [PATCH v6 4/5] arm64: dts: apple: t600x: Add PWM controller

On 06/01/2023 22.58, Sasha Finkelstein wrote:
> Adds PWM controller and keyboard backlight bindings for M1 Pro/Max MacBook Pros
>
> Signed-off-by: Sasha Finkelstein <[email protected]>
> ---
> arch/arm64/boot/dts/apple/t600x-die0.dtsi | 9 +++++++++
> arch/arm64/boot/dts/apple/t600x-j314-j316.dtsi | 18 ++++++++++++++++++
> 2 files changed, 27 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/apple/t600x-die0.dtsi b/arch/arm64/boot/dts/apple/t600x-die0.dtsi
> index 1c41954e3899..7065045dc43a 100644
> --- a/arch/arm64/boot/dts/apple/t600x-die0.dtsi
> +++ b/arch/arm64/boot/dts/apple/t600x-die0.dtsi
> @@ -154,6 +154,15 @@ i2c5: i2c@39b054000 {
> status = "disabled";
> };
>
> + fpwm0: pwm@39b030000 {
> + compatible = "apple,t6000-fpwm", "apple,s5l-fpwm";
> + reg = <0x3 0x9b030000 0x0 0x4000>;
> + power-domains = <&ps_fpwm0>;
> + clocks = <&clkref>;
> + #pwm-cells = <2>;
> + status = "disabled";
> + };
> +

We usually keep device nodes sorted by address, so this is out of order
and should come before i2c (at least). No need to respin just for this
though, I can fix it when I apply it, so:

Acked-by: Hector Martin <[email protected]>

Maintainers: as we usually ask, please merge only the driver commit (#2)
via the PWM tree, we'll take care of DTs/MAINTAINERS/bindings via
asahi-soc so we can avoid serializing/blocking other DT changes.

- Hector