All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] platform/chrome: cros_kbd_led_backlight: add EC PWM backend
@ 2022-02-14  5:36 Tzung-Bi Shih
  2022-02-14  5:36 ` [PATCH 1/5] platform/chrome: cros_kbd_led_backlight: sort headers alphabetically Tzung-Bi Shih
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Tzung-Bi Shih @ 2022-02-14  5:36 UTC (permalink / raw)
  To: bleung, groeck, robh+dt
  Cc: chrome-platform, tzungbi, devicetree, linux-kernel

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


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

* [PATCH 1/5] platform/chrome: cros_kbd_led_backlight: sort headers alphabetically
  2022-02-14  5:36 [PATCH 0/5] platform/chrome: cros_kbd_led_backlight: add EC PWM backend Tzung-Bi Shih
@ 2022-02-14  5:36 ` Tzung-Bi Shih
  2022-02-14  5:36 ` [PATCH 2/5] platform/chrome: cros_kbd_led_backlight: separate ACPI backend Tzung-Bi Shih
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Tzung-Bi Shih @ 2022-02-14  5:36 UTC (permalink / raw)
  To: bleung, groeck, robh+dt
  Cc: chrome-platform, tzungbi, devicetree, linux-kernel

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 drivers/platform/chrome/cros_kbd_led_backlight.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/chrome/cros_kbd_led_backlight.c b/drivers/platform/chrome/cros_kbd_led_backlight.c
index aa409f0201fb..f9587a562bb7 100644
--- a/drivers/platform/chrome/cros_kbd_led_backlight.c
+++ b/drivers/platform/chrome/cros_kbd_led_backlight.c
@@ -4,12 +4,12 @@
 // Copyright (C) 2012 Google, Inc.
 
 #include <linux/acpi.h>
-#include <linux/leds.h>
 #include <linux/delay.h>
 #include <linux/err.h>
-#include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/leds.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 
-- 
2.35.1.265.g69c8d7142f-goog


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

* [PATCH 2/5] platform/chrome: cros_kbd_led_backlight: separate ACPI backend
  2022-02-14  5:36 [PATCH 0/5] platform/chrome: cros_kbd_led_backlight: add EC PWM backend Tzung-Bi Shih
  2022-02-14  5:36 ` [PATCH 1/5] platform/chrome: cros_kbd_led_backlight: sort headers alphabetically Tzung-Bi Shih
@ 2022-02-14  5:36 ` Tzung-Bi Shih
  2022-02-14 19:53     ` kernel test robot
  2022-02-14  5:36 ` [PATCH 3/5] dt-bindings: add google,cros-kbd-led-backlight Tzung-Bi Shih
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Tzung-Bi Shih @ 2022-02-14  5:36 UTC (permalink / raw)
  To: bleung, groeck, robh+dt
  Cc: chrome-platform, tzungbi, devicetree, linux-kernel

cros_kbd_led_backlight uses ACPI_KEYBOARD_BACKLIGHT_WRITE and
ACPI_KEYBOARD_BACKLIGHT_READ for setting and getting the brightness
respectively.

Separate ACPI operations as an independent option for preparing the
driver to support other backends.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 drivers/platform/chrome/Kconfig               |  8 +-
 .../platform/chrome/cros_kbd_led_backlight.c  | 91 ++++++++++++++++---
 2 files changed, 85 insertions(+), 14 deletions(-)

diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig
index ccc23d8686e8..3f74679a556c 100644
--- a/drivers/platform/chrome/Kconfig
+++ b/drivers/platform/chrome/Kconfig
@@ -128,7 +128,7 @@ config CROS_EC_PROTO
 
 config CROS_KBD_LED_BACKLIGHT
 	tristate "Backlight LED support for Chrome OS keyboards"
-	depends on LEDS_CLASS && ACPI
+	depends on LEDS_CLASS
 	help
 	  This option enables support for the keyboard backlight LEDs on
 	  select Chrome OS systems.
@@ -136,6 +136,12 @@ config CROS_KBD_LED_BACKLIGHT
 	  To compile this driver as a module, choose M here: the
 	  module will be called cros_kbd_led_backlight.
 
+config CROS_KBD_LED_BACKLIGHT_ACPI
+	bool "ChromeOS keyboard backlight ACPI backend"
+	depends on ACPI && CROS_KBD_LED_BACKLIGHT
+	help
+	  ChromeOS keyboard backlight ACPI backend.
+
 config CROS_EC_CHARDEV
 	tristate "ChromeOS EC miscdevice"
 	depends on MFD_CROS_EC_DEV
diff --git a/drivers/platform/chrome/cros_kbd_led_backlight.c b/drivers/platform/chrome/cros_kbd_led_backlight.c
index f9587a562bb7..814f2b74c602 100644
--- a/drivers/platform/chrome/cros_kbd_led_backlight.c
+++ b/drivers/platform/chrome/cros_kbd_led_backlight.c
@@ -13,6 +13,33 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 
+/**
+ * struct keyboard_led_drvdata - keyboard LED driver data.
+ * @init:			Init function.
+ * @brightness_get:		Get LED brightness level.
+ * @brightness_set:		Set LED brightness level.  Must not sleep.
+ * @brightness_set_blocking:	Set LED brightness level.  It can block the
+ *				caller for the time required for accessing a
+ *				LED device register
+ * @max_brightness:		Maximum brightness.
+ *
+ * See struct led_classdev in include/linux/leds.h for more details.
+ */
+struct keyboard_led_drvdata {
+	int (*init)(struct platform_device *pdev);
+
+	enum led_brightness (*brightness_get)(struct led_classdev *led_cdev);
+
+	void (*brightness_set)(struct led_classdev *led_cdev,
+			       enum led_brightness brightness);
+	int (*brightness_set_blocking)(struct led_classdev *led_cdev,
+				       enum led_brightness brightness);
+
+	enum led_brightness max_brightness;
+};
+
+#if IS_ENABLED(CONFIG_CROS_KBD_LED_BACKLIGHT_ACPI)
+
 /* Keyboard LED ACPI Device must be defined in firmware */
 #define ACPI_KEYBOARD_BACKLIGHT_DEVICE	"\\_SB.KBLT"
 #define ACPI_KEYBOARD_BACKLIGHT_READ	ACPI_KEYBOARD_BACKLIGHT_DEVICE ".KBQC"
@@ -20,8 +47,8 @@
 
 #define ACPI_KEYBOARD_BACKLIGHT_MAX		100
 
-static void keyboard_led_set_brightness(struct led_classdev *cdev,
-					enum led_brightness brightness)
+static void keyboard_led_set_brightness_acpi(struct led_classdev *cdev,
+					     enum led_brightness brightness)
 {
 	union acpi_object param;
 	struct acpi_object_list input;
@@ -40,7 +67,7 @@ static void keyboard_led_set_brightness(struct led_classdev *cdev,
 }
 
 static enum led_brightness
-keyboard_led_get_brightness(struct led_classdev *cdev)
+keyboard_led_get_brightness_acpi(struct led_classdev *cdev)
 {
 	unsigned long long brightness;
 	acpi_status status;
@@ -56,12 +83,10 @@ keyboard_led_get_brightness(struct led_classdev *cdev)
 	return brightness;
 }
 
-static int keyboard_led_probe(struct platform_device *pdev)
+static int keyboard_led_init_acpi(struct platform_device *pdev)
 {
-	struct led_classdev *cdev;
 	acpi_handle handle;
 	acpi_status status;
-	int error;
 
 	/* Look for the keyboard LED ACPI Device */
 	status = acpi_get_handle(ACPI_ROOT_OBJECT,
@@ -73,15 +98,55 @@ static int keyboard_led_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
+	return 0;
+}
+
+static const struct keyboard_led_drvdata keyboard_led_drvdata_acpi = {
+	.init = keyboard_led_init_acpi,
+	.brightness_set = keyboard_led_set_brightness_acpi,
+	.brightness_get = keyboard_led_get_brightness_acpi,
+	.max_brightness = ACPI_KEYBOARD_BACKLIGHT_MAX,
+};
+
+#else /* IS_ENABLED(CONFIG_CROS_KBD_LED_BACKLIGHT_ACPI) */
+
+static int keyboard_led_init_acpi_null(struct platform_device *pdev)
+{
+	return -EOPNOTSUPP;
+}
+
+static const struct keyboard_led_drvdata keyboard_led_drvdata_acpi = {
+	.init = keyboard_led_init_acpi_null,
+};
+
+#endif /* IS_ENABLED(CONFIG_CROS_KBD_LED_BACKLIGHT_ACPI) */
+
+static int keyboard_led_probe(struct platform_device *pdev)
+{
+	struct led_classdev *cdev;
+	const struct keyboard_led_drvdata *drvdata;
+	int error;
+
+	drvdata = acpi_device_get_match_data(&pdev->dev);
+	if (!drvdata)
+		return -EINVAL;
+
+	if (drvdata->init) {
+		error = drvdata->init(pdev);
+		if (error)
+			return error;
+	}
+
 	cdev = devm_kzalloc(&pdev->dev, sizeof(*cdev), GFP_KERNEL);
 	if (!cdev)
 		return -ENOMEM;
 
 	cdev->name = "chromeos::kbd_backlight";
-	cdev->max_brightness = ACPI_KEYBOARD_BACKLIGHT_MAX;
 	cdev->flags |= LED_CORE_SUSPENDRESUME;
-	cdev->brightness_set = keyboard_led_set_brightness;
-	cdev->brightness_get = keyboard_led_get_brightness;
+	cdev->max_brightness = drvdata->max_brightness;
+	cdev->brightness_set = drvdata->brightness_set;
+	cdev->brightness_set_blocking = drvdata->brightness_set_blocking;
+	cdev->brightness_get = drvdata->brightness_get;
 
 	error = devm_led_classdev_register(&pdev->dev, cdev);
 	if (error)
@@ -90,16 +155,16 @@ static int keyboard_led_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct acpi_device_id keyboard_led_id[] = {
-	{ "GOOG0002", 0 },
+static const struct acpi_device_id keyboard_led_acpi_match[] = {
+	{ "GOOG0002", (kernel_ulong_t)&keyboard_led_drvdata_acpi },
 	{ }
 };
-MODULE_DEVICE_TABLE(acpi, keyboard_led_id);
+MODULE_DEVICE_TABLE(acpi, keyboard_led_acpi_match);
 
 static struct platform_driver keyboard_led_driver = {
 	.driver		= {
 		.name	= "chromeos-keyboard-leds",
-		.acpi_match_table = ACPI_PTR(keyboard_led_id),
+		.acpi_match_table = ACPI_PTR(keyboard_led_acpi_match),
 	},
 	.probe		= keyboard_led_probe,
 };
-- 
2.35.1.265.g69c8d7142f-goog


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

* [PATCH 3/5] dt-bindings: add google,cros-kbd-led-backlight
  2022-02-14  5:36 [PATCH 0/5] platform/chrome: cros_kbd_led_backlight: add EC PWM backend Tzung-Bi Shih
  2022-02-14  5:36 ` [PATCH 1/5] platform/chrome: cros_kbd_led_backlight: sort headers alphabetically Tzung-Bi Shih
  2022-02-14  5:36 ` [PATCH 2/5] platform/chrome: cros_kbd_led_backlight: separate ACPI backend Tzung-Bi Shih
@ 2022-02-14  5:36 ` Tzung-Bi Shih
  2022-03-02 21:54   ` Rob Herring
  2022-02-14  5:36 ` [PATCH 4/5] platform/chrome: cros_kbd_led_backlight: support OF match Tzung-Bi Shih
  2022-02-14  5:36 ` [PATCH 5/5] platform/chrome: cros_kbd_led_backlight: support EC PWM backend Tzung-Bi Shih
  4 siblings, 1 reply; 14+ messages in thread
From: Tzung-Bi Shih @ 2022-02-14  5:36 UTC (permalink / raw)
  To: bleung, groeck, robh+dt
  Cc: chrome-platform, tzungbi, devicetree, linux-kernel

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 .../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 <tzungbi@google.com>
+
+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


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

* [PATCH 4/5] platform/chrome: cros_kbd_led_backlight: support OF match
  2022-02-14  5:36 [PATCH 0/5] platform/chrome: cros_kbd_led_backlight: add EC PWM backend Tzung-Bi Shih
                   ` (2 preceding siblings ...)
  2022-02-14  5:36 ` [PATCH 3/5] dt-bindings: add google,cros-kbd-led-backlight Tzung-Bi Shih
@ 2022-02-14  5:36 ` Tzung-Bi Shih
  2022-02-14 17:19   ` kernel test robot
  2022-02-16  1:10   ` Prashant Malani
  2022-02-14  5:36 ` [PATCH 5/5] platform/chrome: cros_kbd_led_backlight: support EC PWM backend Tzung-Bi Shih
  4 siblings, 2 replies; 14+ messages in thread
From: Tzung-Bi Shih @ 2022-02-14  5:36 UTC (permalink / raw)
  To: bleung, groeck, robh+dt
  Cc: chrome-platform, tzungbi, devicetree, linux-kernel

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 .../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


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

* [PATCH 5/5] platform/chrome: cros_kbd_led_backlight: support EC PWM backend
  2022-02-14  5:36 [PATCH 0/5] platform/chrome: cros_kbd_led_backlight: add EC PWM backend Tzung-Bi Shih
                   ` (3 preceding siblings ...)
  2022-02-14  5:36 ` [PATCH 4/5] platform/chrome: cros_kbd_led_backlight: support OF match Tzung-Bi Shih
@ 2022-02-14  5:36 ` Tzung-Bi Shih
  4 siblings, 0 replies; 14+ messages in thread
From: Tzung-Bi Shih @ 2022-02-14  5:36 UTC (permalink / raw)
  To: bleung, groeck, robh+dt
  Cc: chrome-platform, tzungbi, devicetree, linux-kernel

EC PWM backend uses EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT and
EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT for setting and getting the brightness
respectively.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 drivers/platform/chrome/Kconfig               |   6 +
 .../platform/chrome/cros_kbd_led_backlight.c  | 126 +++++++++++++++---
 2 files changed, 117 insertions(+), 15 deletions(-)

diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig
index 3f74679a556c..298a49550857 100644
--- a/drivers/platform/chrome/Kconfig
+++ b/drivers/platform/chrome/Kconfig
@@ -142,6 +142,12 @@ config CROS_KBD_LED_BACKLIGHT_ACPI
 	help
 	  ChromeOS keyboard backlight ACPI backend.
 
+config CROS_KBD_LED_BACKLIGHT_EC_PWM
+	tristate "ChromeOS keyboard backlight EC PWM backend"
+	depends on CROS_EC && CROS_KBD_LED_BACKLIGHT
+	help
+	  ChromeOS keyboard backlight EC PWM backend.
+
 config CROS_EC_CHARDEV
 	tristate "ChromeOS EC miscdevice"
 	depends on MFD_CROS_EC_DEV
diff --git a/drivers/platform/chrome/cros_kbd_led_backlight.c b/drivers/platform/chrome/cros_kbd_led_backlight.c
index ba853e55d29a..d655cf5bc960 100644
--- a/drivers/platform/chrome/cros_kbd_led_backlight.c
+++ b/drivers/platform/chrome/cros_kbd_led_backlight.c
@@ -11,9 +11,16 @@
 #include <linux/leds.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
+#include <linux/platform_data/cros_ec_commands.h>
+#include <linux/platform_data/cros_ec_proto.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 
+struct keyboard_led_private {
+	struct led_classdev cdev;
+	struct cros_ec_device *ec;
+};
+
 /**
  * struct keyboard_led_drvdata - keyboard LED driver data.
  * @init:			Init function.
@@ -39,6 +46,8 @@ struct keyboard_led_drvdata {
 	enum led_brightness max_brightness;
 };
 
+#define KEYBOARD_BACKLIGHT_MAX 100
+
 #if IS_ENABLED(CONFIG_CROS_KBD_LED_BACKLIGHT_ACPI)
 
 /* Keyboard LED ACPI Device must be defined in firmware */
@@ -46,8 +55,6 @@ struct keyboard_led_drvdata {
 #define ACPI_KEYBOARD_BACKLIGHT_READ	ACPI_KEYBOARD_BACKLIGHT_DEVICE ".KBQC"
 #define ACPI_KEYBOARD_BACKLIGHT_WRITE	ACPI_KEYBOARD_BACKLIGHT_DEVICE ".KBCM"
 
-#define ACPI_KEYBOARD_BACKLIGHT_MAX		100
-
 static void keyboard_led_set_brightness_acpi(struct led_classdev *cdev,
 					     enum led_brightness brightness)
 {
@@ -106,7 +113,7 @@ static const struct keyboard_led_drvdata keyboard_led_drvdata_acpi = {
 	.init = keyboard_led_init_acpi,
 	.brightness_set = keyboard_led_set_brightness_acpi,
 	.brightness_get = keyboard_led_get_brightness_acpi,
-	.max_brightness = ACPI_KEYBOARD_BACKLIGHT_MAX,
+	.max_brightness = KEYBOARD_BACKLIGHT_MAX,
 };
 
 #else /* IS_ENABLED(CONFIG_CROS_KBD_LED_BACKLIGHT_ACPI) */
@@ -122,10 +129,97 @@ static const struct keyboard_led_drvdata keyboard_led_drvdata_acpi = {
 
 #endif /* IS_ENABLED(CONFIG_CROS_KBD_LED_BACKLIGHT_ACPI) */
 
+#if IS_ENABLED(CONFIG_CROS_KBD_LED_BACKLIGHT_EC_PWM)
+
+static int
+keyboard_led_set_brightness_blocking_ec_pwm(struct led_classdev *cdev,
+					    enum led_brightness brightness)
+{
+	struct {
+		struct cros_ec_command msg;
+		struct ec_params_pwm_set_keyboard_backlight params;
+	} __packed buf;
+	struct ec_params_pwm_set_keyboard_backlight *params = &buf.params;
+	struct cros_ec_command *msg = &buf.msg;
+	struct keyboard_led_private *private =
+		container_of(cdev, struct keyboard_led_private, cdev);
+
+	memset(&buf, 0, sizeof(buf));
+
+	msg->version = 0;
+	msg->command = EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT;
+	msg->insize = 0;
+	msg->outsize = sizeof(*params);
+
+	params->percent = brightness;
+
+	return cros_ec_cmd_xfer_status(private->ec, msg);
+}
+
+static enum led_brightness
+keyboard_led_get_brightness_ec_pwm(struct led_classdev *cdev)
+{
+	struct {
+		struct cros_ec_command msg;
+		struct ec_response_pwm_get_keyboard_backlight resp;
+	} __packed buf;
+	struct ec_response_pwm_get_keyboard_backlight *resp = &buf.resp;
+	struct cros_ec_command *msg = &buf.msg;
+	struct keyboard_led_private *private =
+		container_of(cdev, struct keyboard_led_private, cdev);
+	int ret;
+
+	memset(&buf, 0, sizeof(buf));
+
+	msg->version = 0;
+	msg->command = EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT;
+	msg->insize = sizeof(*resp);
+	msg->outsize = 0;
+
+	ret = cros_ec_cmd_xfer_status(private->ec, msg);
+	if (ret < 0)
+		return ret;
+
+	return resp->percent;
+}
+
+static int keyboard_led_init_ec_pwm(struct platform_device *pdev)
+{
+	struct keyboard_led_private *private = platform_get_drvdata(pdev);
+
+	private->ec = dev_get_drvdata(pdev->dev.parent);
+	if (!private->ec) {
+		dev_err(&pdev->dev, "no parent EC device\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static const struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm = {
+	.init = keyboard_led_init_ec_pwm,
+	.brightness_set_blocking = keyboard_led_set_brightness_blocking_ec_pwm,
+	.brightness_get = keyboard_led_get_brightness_ec_pwm,
+	.max_brightness = KEYBOARD_BACKLIGHT_MAX,
+};
+
+#else /* IS_ENABLED(CONFIG_CROS_KBD_LED_BACKLIGHT_EC_PWM) */
+
+static int keyboard_led_init_ec_pwm_null(struct platform_device *pdev)
+{
+	return -EOPNOTSUPP;
+}
+
+static const struct keyboard_led_drvdata keyboard_led_drvdata_ec_pwm = {
+	.init = keyboard_led_init_ec_pwm_null,
+};
+
+#endif /* IS_ENABLED(CONFIG_CROS_KBD_LED_BACKLIGHT_EC_PWM) */
+
 static int keyboard_led_probe(struct platform_device *pdev)
 {
-	struct led_classdev *cdev;
 	const struct keyboard_led_drvdata *drvdata;
+	struct keyboard_led_private *private;
 	int error;
 
 	drvdata = acpi_device_get_match_data(&pdev->dev);
@@ -135,24 +229,25 @@ static int keyboard_led_probe(struct platform_device *pdev)
 			return -EINVAL;
 	}
 
+	private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL);
+	if (!private)
+		return -ENOMEM;
+	platform_set_drvdata(pdev, private);
+
 	if (drvdata->init) {
 		error = drvdata->init(pdev);
 		if (error)
 			return error;
 	}
 
-	cdev = devm_kzalloc(&pdev->dev, sizeof(*cdev), GFP_KERNEL);
-	if (!cdev)
-		return -ENOMEM;
-
-	cdev->name = "chromeos::kbd_backlight";
-	cdev->flags |= LED_CORE_SUSPENDRESUME;
-	cdev->max_brightness = drvdata->max_brightness;
-	cdev->brightness_set = drvdata->brightness_set;
-	cdev->brightness_set_blocking = drvdata->brightness_set_blocking;
-	cdev->brightness_get = drvdata->brightness_get;
+	private->cdev.name = "chromeos::kbd_backlight";
+	private->cdev.flags |= LED_CORE_SUSPENDRESUME;
+	private->cdev.max_brightness = drvdata->max_brightness;
+	private->cdev.brightness_set = drvdata->brightness_set;
+	private->cdev.brightness_set_blocking = drvdata->brightness_set_blocking;
+	private->cdev.brightness_get = drvdata->brightness_get;
 
-	error = devm_led_classdev_register(&pdev->dev, cdev);
+	error = devm_led_classdev_register(&pdev->dev, &private->cdev);
 	if (error)
 		return error;
 
@@ -168,6 +263,7 @@ MODULE_DEVICE_TABLE(acpi, keyboard_led_acpi_match);
 static const struct of_device_id keyboard_led_of_match[] = {
 	{
 		.compatible = "google,cros-kbd-led-backlight",
+		.data = &keyboard_led_drvdata_ec_pwm,
 	},
 	{}
 };
-- 
2.35.1.265.g69c8d7142f-goog


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

* Re: [PATCH 4/5] platform/chrome: cros_kbd_led_backlight: support OF match
  2022-02-14  5:36 ` [PATCH 4/5] platform/chrome: cros_kbd_led_backlight: support OF match Tzung-Bi Shih
@ 2022-02-14 17:19   ` kernel test robot
  2022-02-15  1:40     ` Tzung-Bi Shih
  2022-02-16  1:10   ` Prashant Malani
  1 sibling, 1 reply; 14+ messages in thread
From: kernel test robot @ 2022-02-14 17:19 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2286 bytes --]

Hi Tzung-Bi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on chrome-platform/for-next]
[also build test ERROR on robh/for-next lee-mfd/for-mfd-next v5.17-rc4 next-20220214]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Tzung-Bi-Shih/platform-chrome-cros_kbd_led_backlight-add-EC-PWM-backend/20220214-133805
base:   https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-next
config: i386-randconfig-a001 (https://download.01.org/0day-ci/archive/20220214/202202142320.uQhUtcwm-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/8f5fc05563b71136a2ab6f2cb5a068a152267965
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Tzung-Bi-Shih/platform-chrome-cros_kbd_led_backlight-add-EC-PWM-backend/20220214-133805
        git checkout 8f5fc05563b71136a2ab6f2cb5a068a152267965
        # save the config file to linux build tree
        mkdir build_dir
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/platform/chrome/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/platform/chrome/cros_kbd_led_backlight.c:168:34: error: 'keyboard_led_of_match' defined but not used [-Werror=unused-const-variable=]
     168 | static const struct of_device_id keyboard_led_of_match[] = {
         |                                  ^~~~~~~~~~~~~~~~~~~~~
   cc1: all warnings being treated as errors


vim +/keyboard_led_of_match +168 drivers/platform/chrome/cros_kbd_led_backlight.c

   167	
 > 168	static const struct of_device_id keyboard_led_of_match[] = {
   169		{
   170			.compatible = "google,cros-kbd-led-backlight",
   171		},
   172		{}
   173	};
   174	MODULE_DEVICE_TABLE(of, keyboard_led_of_match);
   175	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

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

* Re: [PATCH 2/5] platform/chrome: cros_kbd_led_backlight: separate ACPI backend
  2022-02-14  5:36 ` [PATCH 2/5] platform/chrome: cros_kbd_led_backlight: separate ACPI backend Tzung-Bi Shih
@ 2022-02-14 19:53     ` kernel test robot
  0 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2022-02-14 19:53 UTC (permalink / raw)
  To: Tzung-Bi Shih; +Cc: llvm, kbuild-all

Hi Tzung-Bi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on chrome-platform/for-next]
[also build test WARNING on robh/for-next lee-mfd/for-mfd-next v5.17-rc4 next-20220214]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Tzung-Bi-Shih/platform-chrome-cros_kbd_led_backlight-add-EC-PWM-backend/20220214-133805
base:   https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-next
config: hexagon-allyesconfig (https://download.01.org/0day-ci/archive/20220215/202202150337.USCNWPYx-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project ea071884b0cc7210b3cc5fe858f0e892a779a23b)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/aea3ce64e967f0980a22b475b6f4aa3154fff332
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Tzung-Bi-Shih/platform-chrome-cros_kbd_led_backlight-add-EC-PWM-backend/20220214-133805
        git checkout aea3ce64e967f0980a22b475b6f4aa3154fff332
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/platform/chrome/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/platform/chrome/cros_kbd_led_backlight.c:158:36: warning: unused variable 'keyboard_led_acpi_match' [-Wunused-const-variable]
   static const struct acpi_device_id keyboard_led_acpi_match[] = {
                                      ^
   1 warning generated.


vim +/keyboard_led_acpi_match +158 drivers/platform/chrome/cros_kbd_led_backlight.c

   157	
 > 158	static const struct acpi_device_id keyboard_led_acpi_match[] = {
   159		{ "GOOG0002", (kernel_ulong_t)&keyboard_led_drvdata_acpi },
   160		{ }
   161	};
   162	MODULE_DEVICE_TABLE(acpi, keyboard_led_acpi_match);
   163	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

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

* Re: [PATCH 2/5] platform/chrome: cros_kbd_led_backlight: separate ACPI backend
@ 2022-02-14 19:53     ` kernel test robot
  0 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2022-02-14 19:53 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2507 bytes --]

Hi Tzung-Bi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on chrome-platform/for-next]
[also build test WARNING on robh/for-next lee-mfd/for-mfd-next v5.17-rc4 next-20220214]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Tzung-Bi-Shih/platform-chrome-cros_kbd_led_backlight-add-EC-PWM-backend/20220214-133805
base:   https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-next
config: hexagon-allyesconfig (https://download.01.org/0day-ci/archive/20220215/202202150337.USCNWPYx-lkp(a)intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project ea071884b0cc7210b3cc5fe858f0e892a779a23b)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/aea3ce64e967f0980a22b475b6f4aa3154fff332
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Tzung-Bi-Shih/platform-chrome-cros_kbd_led_backlight-add-EC-PWM-backend/20220214-133805
        git checkout aea3ce64e967f0980a22b475b6f4aa3154fff332
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/platform/chrome/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/platform/chrome/cros_kbd_led_backlight.c:158:36: warning: unused variable 'keyboard_led_acpi_match' [-Wunused-const-variable]
   static const struct acpi_device_id keyboard_led_acpi_match[] = {
                                      ^
   1 warning generated.


vim +/keyboard_led_acpi_match +158 drivers/platform/chrome/cros_kbd_led_backlight.c

   157	
 > 158	static const struct acpi_device_id keyboard_led_acpi_match[] = {
   159		{ "GOOG0002", (kernel_ulong_t)&keyboard_led_drvdata_acpi },
   160		{ }
   161	};
   162	MODULE_DEVICE_TABLE(acpi, keyboard_led_acpi_match);
   163	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

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

* Re: [PATCH 4/5] platform/chrome: cros_kbd_led_backlight: support OF match
  2022-02-14 17:19   ` kernel test robot
@ 2022-02-15  1:40     ` Tzung-Bi Shih
  0 siblings, 0 replies; 14+ messages in thread
From: Tzung-Bi Shih @ 2022-02-15  1:40 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2572 bytes --]

Thanks, will fix it in the next version.

On Tue, Feb 15, 2022 at 1:20 AM kernel test robot <lkp@intel.com> wrote:

> Hi Tzung-Bi,
>
> Thank you for the patch! Yet something to improve:
>
> [auto build test ERROR on chrome-platform/for-next]
> [also build test ERROR on robh/for-next lee-mfd/for-mfd-next v5.17-rc4
> next-20220214]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
>
> url:
> https://github.com/0day-ci/linux/commits/Tzung-Bi-Shih/platform-chrome-cros_kbd_led_backlight-add-EC-PWM-backend/20220214-133805
> base:
> https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git
> for-next
> config: i386-randconfig-a001 (
> https://download.01.org/0day-ci/archive/20220214/202202142320.uQhUtcwm-lkp(a)intel.com/config
> )
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> reproduce (this is a W=1 build):
>         #
> https://github.com/0day-ci/linux/commit/8f5fc05563b71136a2ab6f2cb5a068a152267965
>         git remote add linux-review https://github.com/0day-ci/linux
>         git fetch --no-tags linux-review
> Tzung-Bi-Shih/platform-chrome-cros_kbd_led_backlight-add-EC-PWM-backend/20220214-133805
>         git checkout 8f5fc05563b71136a2ab6f2cb5a068a152267965
>         # save the config file to linux build tree
>         mkdir build_dir
>         make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash
> drivers/platform/chrome/
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All errors (new ones prefixed by >>):
>
> >> drivers/platform/chrome/cros_kbd_led_backlight.c:168:34: error:
> 'keyboard_led_of_match' defined but not used
> [-Werror=unused-const-variable=]
>      168 | static const struct of_device_id keyboard_led_of_match[] = {
>          |                                  ^~~~~~~~~~~~~~~~~~~~~
>    cc1: all warnings being treated as errors
>
>
> vim +/keyboard_led_of_match +168
> drivers/platform/chrome/cros_kbd_led_backlight.c
>
>    167
>  > 168  static const struct of_device_id keyboard_led_of_match[] = {
>    169          {
>    170                  .compatible = "google,cros-kbd-led-backlight",
>    171          },
>    172          {}
>    173  };
>    174  MODULE_DEVICE_TABLE(of, keyboard_led_of_match);
>    175
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
>

[-- Attachment #2: attachment.htm --]
[-- Type: text/html, Size: 3918 bytes --]

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

* Re: [PATCH 2/5] platform/chrome: cros_kbd_led_backlight: separate ACPI backend
  2022-02-14 19:53     ` kernel test robot
  (?)
@ 2022-02-15  1:40     ` Tzung-Bi Shih
  -1 siblings, 0 replies; 14+ messages in thread
From: Tzung-Bi Shih @ 2022-02-15  1:40 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2776 bytes --]

Thanks, will fix it in the next version.

On Tue, Feb 15, 2022 at 3:54 AM kernel test robot <lkp@intel.com> wrote:

> Hi Tzung-Bi,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on chrome-platform/for-next]
> [also build test WARNING on robh/for-next lee-mfd/for-mfd-next v5.17-rc4
> next-20220214]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
>
> url:
> https://github.com/0day-ci/linux/commits/Tzung-Bi-Shih/platform-chrome-cros_kbd_led_backlight-add-EC-PWM-backend/20220214-133805
> base:
> https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git
> for-next
> config: hexagon-allyesconfig (
> https://download.01.org/0day-ci/archive/20220215/202202150337.USCNWPYx-lkp(a)intel.com/config
> )
> compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project
> ea071884b0cc7210b3cc5fe858f0e892a779a23b)
> reproduce (this is a W=1 build):
>         wget
> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross
> -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         #
> https://github.com/0day-ci/linux/commit/aea3ce64e967f0980a22b475b6f4aa3154fff332
>         git remote add linux-review https://github.com/0day-ci/linux
>         git fetch --no-tags linux-review
> Tzung-Bi-Shih/platform-chrome-cros_kbd_led_backlight-add-EC-PWM-backend/20220214-133805
>         git checkout aea3ce64e967f0980a22b475b6f4aa3154fff332
>         # save the config file to linux build tree
>         mkdir build_dir
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1
> O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/platform/chrome/
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
> >> drivers/platform/chrome/cros_kbd_led_backlight.c:158:36: warning:
> unused variable 'keyboard_led_acpi_match' [-Wunused-const-variable]
>    static const struct acpi_device_id keyboard_led_acpi_match[] = {
>                                       ^
>    1 warning generated.
>
>
> vim +/keyboard_led_acpi_match +158
> drivers/platform/chrome/cros_kbd_led_backlight.c
>
>    157
>  > 158  static const struct acpi_device_id keyboard_led_acpi_match[] = {
>    159          { "GOOG0002", (kernel_ulong_t)&keyboard_led_drvdata_acpi },
>    160          { }
>    161  };
>    162  MODULE_DEVICE_TABLE(acpi, keyboard_led_acpi_match);
>    163
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
>

[-- Attachment #2: attachment.htm --]
[-- Type: text/html, Size: 4310 bytes --]

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

* Re: [PATCH 4/5] platform/chrome: cros_kbd_led_backlight: support OF match
  2022-02-14  5:36 ` [PATCH 4/5] platform/chrome: cros_kbd_led_backlight: support OF match Tzung-Bi Shih
  2022-02-14 17:19   ` kernel test robot
@ 2022-02-16  1:10   ` Prashant Malani
  2022-02-16  2:31     ` Tzung-Bi Shih
  1 sibling, 1 reply; 14+ messages in thread
From: Prashant Malani @ 2022-02-16  1:10 UTC (permalink / raw)
  To: Tzung-Bi Shih
  Cc: bleung, groeck, robh+dt, chrome-platform, devicetree, linux-kernel

On Sun, Feb 13, 2022 at 9:37 PM Tzung-Bi Shih <tzungbi@google.com> wrote:
>
> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
> ---
>  .../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
>
>

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

* Re: [PATCH 4/5] platform/chrome: cros_kbd_led_backlight: support OF match
  2022-02-16  1:10   ` Prashant Malani
@ 2022-02-16  2:31     ` Tzung-Bi Shih
  0 siblings, 0 replies; 14+ messages in thread
From: Tzung-Bi Shih @ 2022-02-16  2:31 UTC (permalink / raw)
  To: Prashant Malani
  Cc: bleung, groeck, robh+dt, chrome-platform, devicetree, linux-kernel

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 <tzungbi@google.com> 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

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

* Re: [PATCH 3/5] dt-bindings: add google,cros-kbd-led-backlight
  2022-02-14  5:36 ` [PATCH 3/5] dt-bindings: add google,cros-kbd-led-backlight Tzung-Bi Shih
@ 2022-03-02 21:54   ` Rob Herring
  0 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2022-03-02 21:54 UTC (permalink / raw)
  To: Tzung-Bi Shih
  Cc: devicetree, robh+dt, bleung, linux-kernel, chrome-platform, groeck

On Mon, 14 Feb 2022 13:36:44 +0800, Tzung-Bi Shih wrote:
> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
> ---
>  .../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 <robh@kernel.org>

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

end of thread, other threads:[~2022-03-02 21:54 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-14  5:36 [PATCH 0/5] platform/chrome: cros_kbd_led_backlight: add EC PWM backend Tzung-Bi Shih
2022-02-14  5:36 ` [PATCH 1/5] platform/chrome: cros_kbd_led_backlight: sort headers alphabetically Tzung-Bi Shih
2022-02-14  5:36 ` [PATCH 2/5] platform/chrome: cros_kbd_led_backlight: separate ACPI backend Tzung-Bi Shih
2022-02-14 19:53   ` kernel test robot
2022-02-14 19:53     ` kernel test robot
2022-02-15  1:40     ` Tzung-Bi Shih
2022-02-14  5:36 ` [PATCH 3/5] dt-bindings: add google,cros-kbd-led-backlight Tzung-Bi Shih
2022-03-02 21:54   ` Rob Herring
2022-02-14  5:36 ` [PATCH 4/5] platform/chrome: cros_kbd_led_backlight: support OF match Tzung-Bi Shih
2022-02-14 17:19   ` kernel test robot
2022-02-15  1:40     ` Tzung-Bi Shih
2022-02-16  1:10   ` Prashant Malani
2022-02-16  2:31     ` Tzung-Bi Shih
2022-02-14  5:36 ` [PATCH 5/5] platform/chrome: cros_kbd_led_backlight: support EC PWM backend Tzung-Bi Shih

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.