2022-02-14 13:16:53

by Tzung-Bi Shih

[permalink] [raw]
Subject: [PATCH 0/5] platform/chrome: cros_kbd_led_backlight: add EC PWM backend

The series adds EC PWM as an backend option for ChromeOS keyboard LED
backlight.

The 1st patch reorder the headers alphabetically.

The 2nd patch separates the ACPI backend as an independent option.

The 3rd patch is the DT binding document for the proposed compatible string.

The 4th patch supports OF match.

The 5th patch adds EC PWM as another backend option.

Tzung-Bi Shih (5):
platform/chrome: cros_kbd_led_backlight: sort headers alphabetically
platform/chrome: cros_kbd_led_backlight: separate ACPI backend
dt-bindings: add google,cros-kbd-led-backlight
platform/chrome: cros_kbd_led_backlight: support OF match
platform/chrome: cros_kbd_led_backlight: support EC PWM backend

.../chrome/google,cros-kbd-led-backlight.yaml | 35 +++
.../bindings/mfd/google,cros-ec.yaml | 3 +
drivers/platform/chrome/Kconfig | 14 +-
.../platform/chrome/cros_kbd_led_backlight.c | 218 ++++++++++++++++--
4 files changed, 247 insertions(+), 23 deletions(-)
create mode 100644 Documentation/devicetree/bindings/chrome/google,cros-kbd-led-backlight.yaml

--
2.35.1.265.g69c8d7142f-goog


2022-02-14 20:10:50

by Tzung-Bi Shih

[permalink] [raw]
Subject: [PATCH 3/5] dt-bindings: add google,cros-kbd-led-backlight

Signed-off-by: Tzung-Bi Shih <[email protected]>
---
.../chrome/google,cros-kbd-led-backlight.yaml | 35 +++++++++++++++++++
.../bindings/mfd/google,cros-ec.yaml | 3 ++
2 files changed, 38 insertions(+)
create mode 100644 Documentation/devicetree/bindings/chrome/google,cros-kbd-led-backlight.yaml

diff --git a/Documentation/devicetree/bindings/chrome/google,cros-kbd-led-backlight.yaml b/Documentation/devicetree/bindings/chrome/google,cros-kbd-led-backlight.yaml
new file mode 100644
index 000000000000..104299e09cbb
--- /dev/null
+++ b/Documentation/devicetree/bindings/chrome/google,cros-kbd-led-backlight.yaml
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/chrome/google,cros-kbd-led-backlight.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ChromeOS keyboard backlight LED driver.
+
+maintainers:
+ - Tzung-Bi Shih <[email protected]>
+
+properties:
+ compatible:
+ const: google,cros-kbd-led-backlight
+
+required:
+ - compatible
+
+additionalProperties: false
+
+examples:
+ - |
+ spi0 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ cros_ec: ec@0 {
+ compatible = "google,cros-ec-spi";
+ reg = <0>;
+
+ kbd-led-backlight {
+ compatible = "google,cros-kbd-led-backlight";
+ };
+ };
+ };
diff --git a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
index d1f53bd449f7..1815ca0e8ebc 100644
--- a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
+++ b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
@@ -90,6 +90,9 @@ properties:
ec-pwm:
$ref: "/schemas/pwm/google,cros-ec-pwm.yaml#"

+ kbd-led-backlight:
+ $ref: "/schemas/chrome/google,cros-kbd-led-backlight.yaml#"
+
keyboard-controller:
$ref: "/schemas/input/google,cros-ec-keyb.yaml#"

--
2.35.1.265.g69c8d7142f-goog

2022-02-14 20:20:51

by Tzung-Bi Shih

[permalink] [raw]
Subject: [PATCH 4/5] platform/chrome: cros_kbd_led_backlight: support OF match

Signed-off-by: Tzung-Bi Shih <[email protected]>
---
.../platform/chrome/cros_kbd_led_backlight.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/chrome/cros_kbd_led_backlight.c b/drivers/platform/chrome/cros_kbd_led_backlight.c
index 814f2b74c602..ba853e55d29a 100644
--- a/drivers/platform/chrome/cros_kbd_led_backlight.c
+++ b/drivers/platform/chrome/cros_kbd_led_backlight.c
@@ -10,6 +10,7 @@
#include <linux/kernel.h>
#include <linux/leds.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/slab.h>

@@ -128,8 +129,11 @@ static int keyboard_led_probe(struct platform_device *pdev)
int error;

drvdata = acpi_device_get_match_data(&pdev->dev);
- if (!drvdata)
- return -EINVAL;
+ if (!drvdata) {
+ drvdata = of_device_get_match_data(&pdev->dev);
+ if (!drvdata)
+ return -EINVAL;
+ }

if (drvdata->init) {
error = drvdata->init(pdev);
@@ -161,10 +165,19 @@ static const struct acpi_device_id keyboard_led_acpi_match[] = {
};
MODULE_DEVICE_TABLE(acpi, keyboard_led_acpi_match);

+static const struct of_device_id keyboard_led_of_match[] = {
+ {
+ .compatible = "google,cros-kbd-led-backlight",
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(of, keyboard_led_of_match);
+
static struct platform_driver keyboard_led_driver = {
.driver = {
.name = "chromeos-keyboard-leds",
.acpi_match_table = ACPI_PTR(keyboard_led_acpi_match),
+ .of_match_table = of_match_ptr(keyboard_led_of_match),
},
.probe = keyboard_led_probe,
};
--
2.35.1.265.g69c8d7142f-goog

2022-02-16 06:22:54

by Tzung-Bi Shih

[permalink] [raw]
Subject: Re: [PATCH 4/5] platform/chrome: cros_kbd_led_backlight: support OF match

On Tue, Feb 15, 2022 at 05:10:04PM -0800, Prashant Malani wrote:
> On Sun, Feb 13, 2022 at 9:37 PM Tzung-Bi Shih <[email protected]> wrote:
> > diff --git a/drivers/platform/chrome/cros_kbd_led_backlight.c b/drivers/platform/chrome/cros_kbd_led_backlight.c
> > index 814f2b74c602..ba853e55d29a 100644
> > --- a/drivers/platform/chrome/cros_kbd_led_backlight.c
> > +++ b/drivers/platform/chrome/cros_kbd_led_backlight.c
> > @@ -10,6 +10,7 @@
> > #include <linux/kernel.h>
> > #include <linux/leds.h>
> > #include <linux/module.h>
> > +#include <linux/of_device.h>
> > #include <linux/platform_device.h>
> > #include <linux/slab.h>
> >
> > @@ -128,8 +129,11 @@ static int keyboard_led_probe(struct platform_device *pdev)
> > int error;
> >
> > drvdata = acpi_device_get_match_data(&pdev->dev);
> > - if (!drvdata)
> > - return -EINVAL;
> > + if (!drvdata) {
> > + drvdata = of_device_get_match_data(&pdev->dev);
> > + if (!drvdata)
> > + return -EINVAL;
> > + }
>
> I'm not familiar with this driver, so can't do a full review, but
> shouldn't device_get_match_data()
> from property.h [1] be able to handle both DT and ACPI cases?
>
> [1]: https://elixir.bootlin.com/linux/v5.17-rc4/source/include/linux/property.h

Yes, it does[2][3]. Thanks for the feedback, will fix it in next version.

[2]: https://elixir.bootlin.com/linux/v5.17-rc4/source/drivers/of/property.c#L1474
[3]: https://elixir.bootlin.com/linux/v5.17-rc4/source/drivers/acpi/property.c#L1386

2022-02-16 07:09:41

by Prashant Malani

[permalink] [raw]
Subject: Re: [PATCH 4/5] platform/chrome: cros_kbd_led_backlight: support OF match

On Sun, Feb 13, 2022 at 9:37 PM Tzung-Bi Shih <[email protected]> wrote:
>
> Signed-off-by: Tzung-Bi Shih <[email protected]>
> ---
> .../platform/chrome/cros_kbd_led_backlight.c | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/chrome/cros_kbd_led_backlight.c b/drivers/platform/chrome/cros_kbd_led_backlight.c
> index 814f2b74c602..ba853e55d29a 100644
> --- a/drivers/platform/chrome/cros_kbd_led_backlight.c
> +++ b/drivers/platform/chrome/cros_kbd_led_backlight.c
> @@ -10,6 +10,7 @@
> #include <linux/kernel.h>
> #include <linux/leds.h>
> #include <linux/module.h>
> +#include <linux/of_device.h>
> #include <linux/platform_device.h>
> #include <linux/slab.h>
>
> @@ -128,8 +129,11 @@ static int keyboard_led_probe(struct platform_device *pdev)
> int error;
>
> drvdata = acpi_device_get_match_data(&pdev->dev);
> - if (!drvdata)
> - return -EINVAL;
> + if (!drvdata) {
> + drvdata = of_device_get_match_data(&pdev->dev);
> + if (!drvdata)
> + return -EINVAL;
> + }

I'm not familiar with this driver, so can't do a full review, but
shouldn't device_get_match_data()
from property.h [1] be able to handle both DT and ACPI cases?

[1]: https://elixir.bootlin.com/linux/v5.17-rc4/source/include/linux/property.h

>
> if (drvdata->init) {
> error = drvdata->init(pdev);
> @@ -161,10 +165,19 @@ static const struct acpi_device_id keyboard_led_acpi_match[] = {
> };
> MODULE_DEVICE_TABLE(acpi, keyboard_led_acpi_match);
>
> +static const struct of_device_id keyboard_led_of_match[] = {
> + {
> + .compatible = "google,cros-kbd-led-backlight",
> + },
> + {}
> +};
> +MODULE_DEVICE_TABLE(of, keyboard_led_of_match);
> +
> static struct platform_driver keyboard_led_driver = {
> .driver = {
> .name = "chromeos-keyboard-leds",
> .acpi_match_table = ACPI_PTR(keyboard_led_acpi_match),
> + .of_match_table = of_match_ptr(keyboard_led_of_match),
> },
> .probe = keyboard_led_probe,
> };
> --
> 2.35.1.265.g69c8d7142f-goog
>
>

2022-03-02 23:44:55

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH 3/5] dt-bindings: add google,cros-kbd-led-backlight

On Mon, 14 Feb 2022 13:36:44 +0800, Tzung-Bi Shih wrote:
> Signed-off-by: Tzung-Bi Shih <[email protected]>
> ---
> .../chrome/google,cros-kbd-led-backlight.yaml | 35 +++++++++++++++++++
> .../bindings/mfd/google,cros-ec.yaml | 3 ++
> 2 files changed, 38 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/chrome/google,cros-kbd-led-backlight.yaml
>

Acked-by: Rob Herring <[email protected]>