linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 1/2] dt-bindings: leds: backlight: Add Kinetic KTZ8866 backlight
@ 2023-01-18 13:10 Jianhua Lu
  2023-01-18 13:10 ` [PATCH v6 2/2] backlight: ktz8866: Add support for " Jianhua Lu
  2023-01-18 13:40 ` [PATCH v6 1/2] dt-bindings: leds: backlight: Add " Krzysztof Kozlowski
  0 siblings, 2 replies; 7+ messages in thread
From: Jianhua Lu @ 2023-01-18 13:10 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Helge Deller
  Cc: linux-kernel, dri-devel, linux-leds, devicetree, linux-fbdev,
	Jianhua Lu

Add Kinetic KTZ8866 backlight binding documentation.

Signed-off-by: Jianhua Lu <lujianhua000@gmail.com>
---
Changes in v2:
  - Remove "items" between "compatible" and "const: kinetic,ktz8866"
  - Change "additionalProperties" to "unevaluatedProperties"

Changes in v3:
  - Add Krzysztof's R-b

Changes in v4:
  - Drop Krzysztof's R-b
  - Add some new properties

Changes in v5:
  - Add missing enum under property description.
  - Rename uncorrect properties.

Changes in v6:
  - Correct wrong property suffix and description.

 .../leds/backlight/kinetic,ktz8866.yaml       | 59 +++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml

diff --git a/Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml b/Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml
new file mode 100644
index 000000000000..ca0deba14523
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml
@@ -0,0 +1,59 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/backlight/kinetic,ktz8866.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Kinetic Technologies KTZ8866 backlight
+
+maintainers:
+  - Jianhua Lu <lujianhua000@gmail.com>
+
+description: |
+  The Kinetic Technologies KTZ8866 is a high efficiency 6-sinks led backlight
+  with dual lcd bias power.
+  https://www.kinet-ic.com/ktz8866/
+
+allOf:
+  - $ref: common.yaml#
+
+properties:
+  compatible:
+    const: kinetic,ktz8866
+
+  current-num-sinks:
+    description: Number of LED current sinks.
+    enum: [1, 2, 3, 4, 5, 6]
+
+  current-ramping-time-ms:
+    description: LED current ramping time in milliseconds.
+    enum: [2, 4, 8, 16, 32, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640]
+
+  led-ramping-time-ms:
+    description: |
+      LED on/off ramping time in milliseconds, note that the case 0 will be mapped
+      to 512μs because ktz8866 can't ramp faster than it.
+    enum: [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]
+
+  enable-lcd-bias:
+    description: Set if we want to output bias power supply for LCD.
+    type: boolean
+
+required:
+  - compatible
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    backlight {
+        compatible = "kinetic,ktz8866";
+
+        pinctrl-names = "default";
+        pinctrl-0 = <&bl_en_default>;
+
+        current-num-sinks = <5>;
+        current-ramping-time-ms = <128>;
+        led-ramping-time-ms = <1>;
+        enable-lcd-bias;
+    };
-- 
2.39.1


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

* [PATCH v6 2/2] backlight: ktz8866: Add support for Kinetic KTZ8866 backlight
  2023-01-18 13:10 [PATCH v6 1/2] dt-bindings: leds: backlight: Add Kinetic KTZ8866 backlight Jianhua Lu
@ 2023-01-18 13:10 ` Jianhua Lu
  2023-01-18 13:39   ` Krzysztof Kozlowski
  2023-01-19 18:35   ` kernel test robot
  2023-01-18 13:40 ` [PATCH v6 1/2] dt-bindings: leds: backlight: Add " Krzysztof Kozlowski
  1 sibling, 2 replies; 7+ messages in thread
From: Jianhua Lu @ 2023-01-18 13:10 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Helge Deller
  Cc: linux-kernel, dri-devel, linux-leds, devicetree, linux-fbdev,
	Jianhua Lu

Add support for Kinetic KTZ8866 backlight, which is used in
Xiaomi tablet, Mi Pad 5 series. This driver lightly based on
downstream implementation [1].
[1] https://github.com/MiCode/Xiaomi_Kernel_OpenSource/blob/elish-r-oss/drivers/video/backlight/ktz8866.c

Signed-off-by: Jianhua Lu <lujianhua000@gmail.com>
---
Changes in v2:
  - Add missing staitc modifier to ktz8866_write function.

Changes in v3:
  - Add 2022 to Copyright line.
  - Sort headers.
  - Remove meaningless comment.
  - Use definitions instead of hardcoding.
  - Add missing maintainer info.

Changes in v4:
  - Change 2022 to 2023.
  - Remove useless macro and enum.
  - Describe settings by devicetree.
  - Move header file to C file.

Changes in v5:
  - Change "2023" to "2022, 2023" in Copyright line.
  - Set scale property for backlight.

Changes in v6:
  - Correct devicetree property name.

 MAINTAINERS                       |   6 +
 drivers/video/backlight/Kconfig   |   8 ++
 drivers/video/backlight/Makefile  |   1 +
 drivers/video/backlight/ktz8866.c | 205 ++++++++++++++++++++++++++++++
 4 files changed, 220 insertions(+)
 create mode 100644 drivers/video/backlight/ktz8866.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 42fc47c6edfd..2084e74e1b58 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11674,6 +11674,12 @@ M:	John Hawley <warthog9@eaglescrag.net>
 S:	Maintained
 F:	tools/testing/ktest
 
+KTZ8866 BACKLIGHT DRIVER
+M:	Jianhua Lu <lujianhua000@gmail.com>
+S:	Maintained
+F:	Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml
+F:	drivers/video/backlight/ktz8866.c
+
 L3MDEV
 M:	David Ahern <dsahern@kernel.org>
 L:	netdev@vger.kernel.org
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 936ba1e4d35e..f7113ceb264a 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -190,6 +190,14 @@ config BACKLIGHT_KTD253
 	  which is a 1-wire GPIO-controlled backlight found in some mobile
 	  phones.
 
+config BACKLIGHT_KTZ8866
+	tristate "Backlight Driver for Kinetic KTZ8866"
+	depends on I2C
+	select REGMAP_I2C
+	help
+		Say Y to enable the backlight driver for the Kinetic KTZ8866
+		found in Xiaomi Mi Pad 5 series.
+
 config BACKLIGHT_LM3533
 	tristate "Backlight Driver for LM3533"
 	depends on MFD_LM3533
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index e815f3f1deff..f70a819c304c 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -36,6 +36,7 @@ obj-$(CONFIG_BACKLIGHT_HP680)		+= hp680_bl.o
 obj-$(CONFIG_BACKLIGHT_HP700)		+= jornada720_bl.o
 obj-$(CONFIG_BACKLIGHT_IPAQ_MICRO)	+= ipaq_micro_bl.o
 obj-$(CONFIG_BACKLIGHT_KTD253)		+= ktd253-backlight.o
+obj-$(CONFIG_BACKLIGHT_KTZ8866)		+= ktz8866.o
 obj-$(CONFIG_BACKLIGHT_LM3533)		+= lm3533_bl.o
 obj-$(CONFIG_BACKLIGHT_LM3630A)		+= lm3630a_bl.o
 obj-$(CONFIG_BACKLIGHT_LM3639)		+= lm3639_bl.o
diff --git a/drivers/video/backlight/ktz8866.c b/drivers/video/backlight/ktz8866.c
new file mode 100644
index 000000000000..ca3ac349cd10
--- /dev/null
+++ b/drivers/video/backlight/ktz8866.c
@@ -0,0 +1,205 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Backlight driver for the Kinetic KTZ8866
+ *
+ * Copyright (C) 2022, 2023 Jianhua Lu <lujianhua000@gmail.com>
+ */
+
+#include <linux/backlight.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/regmap.h>
+
+#define DEFAULT_BRIGHTNESS 1500
+#define MAX_BRIGHTNESS 2047
+#define REG_MAX 0x15
+
+/* reg */
+#define DEVICE_ID 0x01
+#define BL_CFG1 0x02
+#define BL_CFG2 0x03
+#define BL_BRT_LSB 0x04
+#define BL_BRT_MSB 0x05
+#define BL_EN 0x08
+#define LCD_BIAS_CFG1 0x09
+#define LCD_BIAS_CFG2 0x0A
+#define LCD_BIAS_CFG3 0x0B
+#define LCD_BOOST_CFG 0x0C
+#define OUTP_CFG 0x0D
+#define OUTN_CFG 0x0E
+#define FLAG 0x0F
+#define BL_OPTION1 0x10
+#define BL_OPTION2 0x11
+#define PWM2DIG_LSBs 0x12
+#define PWM2DIG_MSBs 0x13
+#define BL_DIMMING 0x14
+#define PWM_RAMP_TIME 0x15
+
+/* definition */
+#define BL_EN_BIT BIT(6)
+#define LCD_BIAS_EN 0x9F
+#define PWM_HYST 0x5
+
+struct ktz8866 {
+	struct i2c_client *client;
+	struct regmap *regmap;
+	bool led_on;
+};
+
+static const struct regmap_config ktz8866_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = REG_MAX,
+};
+
+static int ktz8866_write(struct ktz8866 *ktz, unsigned int reg,
+			 unsigned int val)
+{
+	return regmap_write(ktz->regmap, reg, val);
+}
+
+static int ktz8866_update_bits(struct ktz8866 *ktz, unsigned int reg,
+			       unsigned int mask, unsigned int val)
+{
+	return regmap_update_bits(ktz->regmap, reg, mask, val);
+}
+
+static int ktz8866_backlight_update_status(struct backlight_device *backlight_dev)
+{
+	struct ktz8866 *ktz = bl_get_data(backlight_dev);
+	unsigned int brightness = backlight_get_brightness(backlight_dev);
+
+	if (!ktz->led_on && brightness > 0) {
+		ktz8866_update_bits(ktz, BL_EN, BL_EN_BIT, BL_EN_BIT);
+		ktz->led_on = true;
+	} else if (brightness == 0) {
+		ktz8866_update_bits(ktz, BL_EN, BL_EN_BIT, 0);
+		ktz->led_on = false;
+		msleep(10);
+	}
+
+	/* Set brightness */
+	ktz8866_write(ktz, BL_BRT_LSB, brightness & 0x7);
+	ktz8866_write(ktz, BL_BRT_MSB, (brightness >> 3) & 0xFF);
+
+	return 0;
+}
+
+static const struct backlight_ops ktz8866_backlight_ops = {
+	.options = BL_CORE_SUSPENDRESUME,
+	.update_status = ktz8866_backlight_update_status,
+};
+
+static void ktz8866_init(struct ktz8866 *ktz)
+{
+	unsigned int val;
+
+	if(of_property_read_u32(ktz->client->dev.of_node, "current-num-sinks", &val))
+		ktz8866_write(ktz, BL_EN, BIT(val) - 1);
+	else
+		/* Enable all 6 current sinks if the number of current sinks isn't specifed. */
+		ktz8866_write(ktz, BL_EN, BIT(6) - 1);
+
+	if(of_property_read_u32(ktz->client->dev.of_node, "current-ramping-time-ms", &val)) {
+		if(val <= 128) {
+			ktz8866_write(ktz, BL_CFG2, BIT(7) | (ilog2(val) << 3) | PWM_HYST);
+		} else {
+			ktz8866_write(ktz, BL_CFG2, BIT(7) | ((5 + val / 64) << 3) | PWM_HYST);
+		}
+	}
+
+	if(of_property_read_u32(ktz->client->dev.of_node, "led-ramping-time-ms", &val)) {
+		if(val == 0) {
+			ktz8866_write(ktz, BL_DIMMING, 0);
+		} else {
+			unsigned int ramp_off_time = ilog2(val) + 1;
+			unsigned int ramp_on_time = ramp_off_time << 4;
+			ktz8866_write(ktz, BL_DIMMING, ramp_on_time | ramp_off_time);
+		}
+	}
+
+	if(of_property_read_bool(ktz->client->dev.of_node, "enable-lcd-bias"))
+		ktz8866_write(ktz, LCD_BIAS_CFG1, LCD_BIAS_EN);
+}
+
+static int ktz8866_probe(struct i2c_client *client,
+			 const struct i2c_device_id *id)
+{
+	struct backlight_device *backlight_dev;
+	struct backlight_properties props;
+	struct ktz8866 *ktz;
+
+	ktz = devm_kzalloc(&client->dev, sizeof(*ktz), GFP_KERNEL);
+	if (!ktz)
+		return -ENOMEM;
+
+	ktz->client = client;
+	ktz->regmap = devm_regmap_init_i2c(client, &ktz8866_regmap_config);
+
+	if (IS_ERR(ktz->regmap)) {
+		dev_err(&client->dev, "failed to init regmap\n");
+		return PTR_ERR(ktz->regmap);
+	}
+
+	memset(&props, 0, sizeof(props));
+	props.type = BACKLIGHT_RAW;
+	props.max_brightness = MAX_BRIGHTNESS;
+	props.brightness = DEFAULT_BRIGHTNESS;
+	props.scale = BACKLIGHT_SCALE_LINEAR;
+
+	backlight_dev = devm_backlight_device_register(
+		&client->dev, "ktz8866-backlight", &client->dev, ktz,
+		&ktz8866_backlight_ops, &props);
+
+	if (IS_ERR(backlight_dev)) {
+		dev_err(&client->dev, "failed to register backlight device\n");
+		return PTR_ERR(backlight_dev);
+	}
+
+	ktz8866_init(ktz);
+
+	i2c_set_clientdata(client, backlight_dev);
+	backlight_update_status(backlight_dev);
+
+	return 0;
+}
+
+static void ktz8866_remove(struct i2c_client *client)
+{
+	struct backlight_device *backlight_dev = i2c_get_clientdata(client);
+
+	backlight_dev->props.brightness = 0;
+	backlight_update_status(backlight_dev);
+}
+
+static const struct i2c_device_id ktz8866_ids[] = {
+	{ "ktz8866", 0 },
+	{},
+};
+MODULE_DEVICE_TABLE(i2c, ktz8866_ids);
+
+static const struct of_device_id ktz8866_match_table[] = {
+	{
+		.compatible = "kinetic,ktz8866",
+	},
+	{},
+};
+
+static struct i2c_driver ktz8866_driver = {
+	.driver = {
+		.name = "ktz8866",
+		.of_match_table = ktz8866_match_table,
+	},
+	.probe = ktz8866_probe,
+	.remove = ktz8866_remove,
+	.id_table = ktz8866_ids,
+};
+
+module_i2c_driver(ktz8866_driver);
+
+MODULE_DESCRIPTION("Kinetic KTZ8866 Backlight Driver");
+MODULE_AUTHOR("Jianhua Lu <lujianhua000@gmail.com>");
+MODULE_LICENSE("GPL");
-- 
2.39.1


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

* Re: [PATCH v6 2/2] backlight: ktz8866: Add support for Kinetic KTZ8866 backlight
  2023-01-18 13:10 ` [PATCH v6 2/2] backlight: ktz8866: Add support for " Jianhua Lu
@ 2023-01-18 13:39   ` Krzysztof Kozlowski
  2023-01-18 13:53     ` Jianhua Lu
  2023-01-19 18:35   ` kernel test robot
  1 sibling, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2023-01-18 13:39 UTC (permalink / raw)
  To: Jianhua Lu, Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek,
	Rob Herring, Krzysztof Kozlowski, Helge Deller
  Cc: linux-kernel, dri-devel, linux-leds, devicetree, linux-fbdev

On 18/01/2023 14:10, Jianhua Lu wrote:
> Add support for Kinetic KTZ8866 backlight, which is used in
> Xiaomi tablet, Mi Pad 5 series. This driver lightly based on
> downstream implementation [1].
> [1] https://github.com/MiCode/Xiaomi_Kernel_OpenSource/blob/elish-r-oss/drivers/video/backlight/ktz8866.c
> 
> Signed-off-by: Jianhua Lu <lujianhua000@gmail.com>
> ---
> Changes in v2:
>   - Add missing staitc modifier to ktz8866_write function.
> 
> Changes in v3:
>   - Add 2022 to Copyright line.
>   - Sort headers.
>   - Remove meaningless comment.
>   - Use definitions instead of hardcoding.
>   - Add missing maintainer info.
> 
> Changes in v4:
>   - Change 2022 to 2023.
>   - Remove useless macro and enum.
>   - Describe settings by devicetree.
>   - Move header file to C file.
> 
> Changes in v5:
>   - Change "2023" to "2022, 2023" in Copyright line.
>   - Set scale property for backlight.
> 
> Changes in v6:
>   - Correct devicetree property name.
> 
>  MAINTAINERS                       |   6 +
>  drivers/video/backlight/Kconfig   |   8 ++
>  drivers/video/backlight/Makefile  |   1 +
>  drivers/video/backlight/ktz8866.c | 205 ++++++++++++++++++++++++++++++
>  4 files changed, 220 insertions(+)
>  create mode 100644 drivers/video/backlight/ktz8866.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 42fc47c6edfd..2084e74e1b58 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -11674,6 +11674,12 @@ M:	John Hawley <warthog9@eaglescrag.net>
>  S:	Maintained
>  F:	tools/testing/ktest
>  
> +KTZ8866 BACKLIGHT DRIVER
> +M:	Jianhua Lu <lujianhua000@gmail.com>
> +S:	Maintained
> +F:	Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml
> +F:	drivers/video/backlight/ktz8866.c
> +
>  L3MDEV
>  M:	David Ahern <dsahern@kernel.org>
>  L:	netdev@vger.kernel.org
> diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
> index 936ba1e4d35e..f7113ceb264a 100644
> --- a/drivers/video/backlight/Kconfig
> +++ b/drivers/video/backlight/Kconfig
> @@ -190,6 +190,14 @@ config BACKLIGHT_KTD253
>  	  which is a 1-wire GPIO-controlled backlight found in some mobile
>  	  phones.
>  
> +config BACKLIGHT_KTZ8866
> +	tristate "Backlight Driver for Kinetic KTZ8866"
> +	depends on I2C
> +	select REGMAP_I2C
> +	help
> +		Say Y to enable the backlight driver for the Kinetic KTZ8866
> +		found in Xiaomi Mi Pad 5 series.
> +
>  config BACKLIGHT_LM3533
>  	tristate "Backlight Driver for LM3533"
>  	depends on MFD_LM3533
> diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
> index e815f3f1deff..f70a819c304c 100644
> --- a/drivers/video/backlight/Makefile
> +++ b/drivers/video/backlight/Makefile
> @@ -36,6 +36,7 @@ obj-$(CONFIG_BACKLIGHT_HP680)		+= hp680_bl.o
>  obj-$(CONFIG_BACKLIGHT_HP700)		+= jornada720_bl.o
>  obj-$(CONFIG_BACKLIGHT_IPAQ_MICRO)	+= ipaq_micro_bl.o
>  obj-$(CONFIG_BACKLIGHT_KTD253)		+= ktd253-backlight.o
> +obj-$(CONFIG_BACKLIGHT_KTZ8866)		+= ktz8866.o
>  obj-$(CONFIG_BACKLIGHT_LM3533)		+= lm3533_bl.o
>  obj-$(CONFIG_BACKLIGHT_LM3630A)		+= lm3630a_bl.o
>  obj-$(CONFIG_BACKLIGHT_LM3639)		+= lm3639_bl.o
> diff --git a/drivers/video/backlight/ktz8866.c b/drivers/video/backlight/ktz8866.c
> new file mode 100644
> index 000000000000..ca3ac349cd10
> --- /dev/null
> +++ b/drivers/video/backlight/ktz8866.c
> @@ -0,0 +1,205 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Backlight driver for the Kinetic KTZ8866
> + *
> + * Copyright (C) 2022, 2023 Jianhua Lu <lujianhua000@gmail.com>
> + */
> +
> +#include <linux/backlight.h>
> +#include <linux/delay.h>
> +#include <linux/err.h>
> +#include <linux/i2c.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/regmap.h>
> +
> +#define DEFAULT_BRIGHTNESS 1500
> +#define MAX_BRIGHTNESS 2047
> +#define REG_MAX 0x15
> +
> +/* reg */
> +#define DEVICE_ID 0x01
> +#define BL_CFG1 0x02
> +#define BL_CFG2 0x03
> +#define BL_BRT_LSB 0x04
> +#define BL_BRT_MSB 0x05
> +#define BL_EN 0x08
> +#define LCD_BIAS_CFG1 0x09
> +#define LCD_BIAS_CFG2 0x0A
> +#define LCD_BIAS_CFG3 0x0B
> +#define LCD_BOOST_CFG 0x0C
> +#define OUTP_CFG 0x0D
> +#define OUTN_CFG 0x0E
> +#define FLAG 0x0F
> +#define BL_OPTION1 0x10
> +#define BL_OPTION2 0x11
> +#define PWM2DIG_LSBs 0x12
> +#define PWM2DIG_MSBs 0x13
> +#define BL_DIMMING 0x14
> +#define PWM_RAMP_TIME 0x15
> +
> +/* definition */
> +#define BL_EN_BIT BIT(6)
> +#define LCD_BIAS_EN 0x9F
> +#define PWM_HYST 0x5
> +
> +struct ktz8866 {
> +	struct i2c_client *client;
> +	struct regmap *regmap;
> +	bool led_on;
> +};
> +
> +static const struct regmap_config ktz8866_regmap_config = {
> +	.reg_bits = 8,
> +	.val_bits = 8,
> +	.max_register = REG_MAX,
> +};
> +
> +static int ktz8866_write(struct ktz8866 *ktz, unsigned int reg,
> +			 unsigned int val)
> +{
> +	return regmap_write(ktz->regmap, reg, val);
> +}
> +
> +static int ktz8866_update_bits(struct ktz8866 *ktz, unsigned int reg,
> +			       unsigned int mask, unsigned int val)
> +{
> +	return regmap_update_bits(ktz->regmap, reg, mask, val);
> +}
> +
> +static int ktz8866_backlight_update_status(struct backlight_device *backlight_dev)
> +{
> +	struct ktz8866 *ktz = bl_get_data(backlight_dev);
> +	unsigned int brightness = backlight_get_brightness(backlight_dev);
> +
> +	if (!ktz->led_on && brightness > 0) {
> +		ktz8866_update_bits(ktz, BL_EN, BL_EN_BIT, BL_EN_BIT);
> +		ktz->led_on = true;
> +	} else if (brightness == 0) {
> +		ktz8866_update_bits(ktz, BL_EN, BL_EN_BIT, 0);
> +		ktz->led_on = false;
> +		msleep(10);

Why 10 ms? Document magic values. Their need, reason behind.

> +	}
> +
> +	/* Set brightness */
> +	ktz8866_write(ktz, BL_BRT_LSB, brightness & 0x7);
> +	ktz8866_write(ktz, BL_BRT_MSB, (brightness >> 3) & 0xFF);
> +
> +	return 0;
> +}
> +
> +static const struct backlight_ops ktz8866_backlight_ops = {
> +	.options = BL_CORE_SUSPENDRESUME,
> +	.update_status = ktz8866_backlight_update_status,
> +};
> +
> +static void ktz8866_init(struct ktz8866 *ktz)
> +{
> +	unsigned int val;
> +
> +	if(of_property_read_u32(ktz->client->dev.of_node, "current-num-sinks", &val))

Here and in other places - not conforming to coding style. Missing space
before (.

Be sure you run checkpatch --strict and fix all relevant errors.

> +		ktz8866_write(ktz, BL_EN, BIT(val) - 1);
> +	else
> +		/* Enable all 6 current sinks if the number of current sinks isn't specifed. */
> +		ktz8866_write(ktz, BL_EN, BIT(6) - 1);
> +
> +	if(of_property_read_u32(ktz->client->dev.of_node, "current-ramping-time-ms", &val)) {
> +		if(val <= 128) {
> +			ktz8866_write(ktz, BL_CFG2, BIT(7) | (ilog2(val) << 3) | PWM_HYST);
> +		} else {
> +			ktz8866_write(ktz, BL_CFG2, BIT(7) | ((5 + val / 64) << 3) | PWM_HYST);
> +		}
> +	}
> +
> +	if(of_property_read_u32(ktz->client->dev.of_node, "led-ramping-time-ms", &val)) {
> +		if(val == 0) {
> +			ktz8866_write(ktz, BL_DIMMING, 0);
> +		} else {
> +			unsigned int ramp_off_time = ilog2(val) + 1;
> +			unsigned int ramp_on_time = ramp_off_time << 4;
> +			ktz8866_write(ktz, BL_DIMMING, ramp_on_time | ramp_off_time);
> +		}
> +	}
> +
> +	if(of_property_read_bool(ktz->client->dev.of_node, "enable-lcd-bias"))
> +		ktz8866_write(ktz, LCD_BIAS_CFG1, LCD_BIAS_EN);
> +}
> +
> +static int ktz8866_probe(struct i2c_client *client,
> +			 const struct i2c_device_id *id)
> +{
> +	struct backlight_device *backlight_dev;
> +	struct backlight_properties props;
> +	struct ktz8866 *ktz;
> +
> +	ktz = devm_kzalloc(&client->dev, sizeof(*ktz), GFP_KERNEL);
> +	if (!ktz)
> +		return -ENOMEM;
> +
> +	ktz->client = client;
> +	ktz->regmap = devm_regmap_init_i2c(client, &ktz8866_regmap_config);
> +

Drop blank line

> +	if (IS_ERR(ktz->regmap)) {
> +		dev_err(&client->dev, "failed to init regmap\n");

dev_err_probe

> +		return PTR_ERR(ktz->regmap);
> +	}
> +
> +	memset(&props, 0, sizeof(props));
> +	props.type = BACKLIGHT_RAW;
> +	props.max_brightness = MAX_BRIGHTNESS;
> +	props.brightness = DEFAULT_BRIGHTNESS;
> +	props.scale = BACKLIGHT_SCALE_LINEAR;
> +
> +	backlight_dev = devm_backlight_device_register(
> +		&client->dev, "ktz8866-backlight", &client->dev, ktz,> +		&ktz8866_backlight_ops, &props);
> +

Drop blank line

> +	if (IS_ERR(backlight_dev)) {
> +		dev_err(&client->dev, "failed to register backlight device\n");

dev_err_probe

> +		return PTR_ERR(backlight_dev);
> +	}
> +
> +	ktz8866_init(ktz);
> +
> +	i2c_set_clientdata(client, backlight_dev);
> +	backlight_update_status(backlight_dev);
> +
> +	return 0;
> +}
> +
> +static void ktz8866_remove(struct i2c_client *client)
> +{
> +	struct backlight_device *backlight_dev = i2c_get_clientdata(client);
> +
> +	backlight_dev->props.brightness = 0;
> +	backlight_update_status(backlight_dev);
> +}
> +
> +static const struct i2c_device_id ktz8866_ids[] = {
> +	{ "ktz8866", 0 },
> +	{},
> +};
> +MODULE_DEVICE_TABLE(i2c, ktz8866_ids);
> +
> +static const struct of_device_id ktz8866_match_table[] = {
> +	{
> +		.compatible = "kinetic,ktz8866",
> +	},
> +	{},
> +};
> +
> +static struct i2c_driver ktz8866_driver = {
> +	.driver = {
> +		.name = "ktz8866",
> +		.of_match_table = ktz8866_match_table,
> +	},
> +	.probe = ktz8866_probe,
> +	.remove = ktz8866_remove,
> +	.id_table = ktz8866_ids,
> +};
> +
> +module_i2c_driver(ktz8866_driver);
> +
> +MODULE_DESCRIPTION("Kinetic KTZ8866 Backlight Driver");
> +MODULE_AUTHOR("Jianhua Lu <lujianhua000@gmail.com>");
> +MODULE_LICENSE("GPL");

Best regards,
Krzysztof


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

* Re: [PATCH v6 1/2] dt-bindings: leds: backlight: Add Kinetic KTZ8866 backlight
  2023-01-18 13:10 [PATCH v6 1/2] dt-bindings: leds: backlight: Add Kinetic KTZ8866 backlight Jianhua Lu
  2023-01-18 13:10 ` [PATCH v6 2/2] backlight: ktz8866: Add support for " Jianhua Lu
@ 2023-01-18 13:40 ` Krzysztof Kozlowski
  2023-01-18 14:00   ` Jianhua Lu
  1 sibling, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2023-01-18 13:40 UTC (permalink / raw)
  To: Jianhua Lu, Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek,
	Rob Herring, Krzysztof Kozlowski, Helge Deller
  Cc: linux-kernel, dri-devel, linux-leds, devicetree, linux-fbdev

On 18/01/2023 14:10, Jianhua Lu wrote:
> Add Kinetic KTZ8866 backlight binding documentation.
> 
> Signed-off-by: Jianhua Lu <lujianhua000@gmail.com>
> ---
> Changes in v2:
>   - Remove "items" between "compatible" and "const: kinetic,ktz8866"
>   - Change "additionalProperties" to "unevaluatedProperties"
> 
> Changes in v3:
>   - Add Krzysztof's R-b
> 
> Changes in v4:
>   - Drop Krzysztof's R-b
>   - Add some new properties
> 
> Changes in v5:
>   - Add missing enum under property description.
>   - Rename uncorrect properties.
> 
> Changes in v6:
>   - Correct wrong property suffix and description.
> 
>  .../leds/backlight/kinetic,ktz8866.yaml       | 59 +++++++++++++++++++
>  1 file changed, 59 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml
> 
> diff --git a/Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml b/Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml
> new file mode 100644
> index 000000000000..ca0deba14523
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml
> @@ -0,0 +1,59 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/leds/backlight/kinetic,ktz8866.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Kinetic Technologies KTZ8866 backlight
> +
> +maintainers:
> +  - Jianhua Lu <lujianhua000@gmail.com>
> +
> +description: |
> +  The Kinetic Technologies KTZ8866 is a high efficiency 6-sinks led backlight
> +  with dual lcd bias power.
> +  https://www.kinet-ic.com/ktz8866/
> +
> +allOf:
> +  - $ref: common.yaml#
> +
> +properties:
> +  compatible:
> +    const: kinetic,ktz8866
> +
> +  current-num-sinks:
> +    description: Number of LED current sinks.
> +    enum: [1, 2, 3, 4, 5, 6]
> +
> +  current-ramping-time-ms:
> +    description: LED current ramping time in milliseconds.
> +    enum: [2, 4, 8, 16, 32, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640]
> +
> +  led-ramping-time-ms:
> +    description: |
> +      LED on/off ramping time in milliseconds, note that the case 0 will be mapped
> +      to 512μs because ktz8866 can't ramp faster than it.

Aren't you just missing supplies here and their ramp up time?

> +    enum: [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]
> +
> +  enable-lcd-bias:
> +    description: Set if we want to output bias power supply for LCD.

Is it a generic property? I don't see any other users, so this looks
device specific thus needs vendor prefix.

This applies to all of the properties. They might be generic or might
not, I don't know the backlight hardware that much.

> +    type: boolean
> +
> +required:
> +  - compatible
> +
> +unevaluatedProperties: false
> +
> +examples:
> +  - |
> +    backlight {
> +        compatible = "kinetic,ktz8866";
> +
> +        pinctrl-names = "default";
> +        pinctrl-0 = <&bl_en_default>;
> +
> +        current-num-sinks = <5>;
> +        current-ramping-time-ms = <128>;
> +        led-ramping-time-ms = <1>;
> +        enable-lcd-bias;
> +    };

Best regards,
Krzysztof


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

* Re: [PATCH v6 2/2] backlight: ktz8866: Add support for Kinetic KTZ8866 backlight
  2023-01-18 13:39   ` Krzysztof Kozlowski
@ 2023-01-18 13:53     ` Jianhua Lu
  0 siblings, 0 replies; 7+ messages in thread
From: Jianhua Lu @ 2023-01-18 13:53 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Helge Deller, linux-kernel, dri-devel,
	linux-leds, devicetree, linux-fbdev

On Wed, Jan 18, 2023 at 02:39:15PM +0100, Krzysztof Kozlowski wrote:
> On 18/01/2023 14:10, Jianhua Lu wrote:
> > Add support for Kinetic KTZ8866 backlight, which is used in
> > Xiaomi tablet, Mi Pad 5 series. This driver lightly based on
> > downstream implementation [1].
> > [1] https://github.com/MiCode/Xiaomi_Kernel_OpenSource/blob/elish-r-oss/drivers/video/backlight/ktz8866.c
> > 
> > Signed-off-by: Jianhua Lu <lujianhua000@gmail.com>
> > ---
> > Changes in v2:
> >   - Add missing staitc modifier to ktz8866_write function.
> > 
> > Changes in v3:
> >   - Add 2022 to Copyright line.
> >   - Sort headers.
> >   - Remove meaningless comment.
> >   - Use definitions instead of hardcoding.
> >   - Add missing maintainer info.
> > 
> > Changes in v4:
> >   - Change 2022 to 2023.
> >   - Remove useless macro and enum.
> >   - Describe settings by devicetree.
> >   - Move header file to C file.
> > 
> > Changes in v5:
> >   - Change "2023" to "2022, 2023" in Copyright line.
> >   - Set scale property for backlight.
> > 
> > Changes in v6:
> >   - Correct devicetree property name.
> > 
> >  MAINTAINERS                       |   6 +
> >  drivers/video/backlight/Kconfig   |   8 ++
> >  drivers/video/backlight/Makefile  |   1 +
> >  drivers/video/backlight/ktz8866.c | 205 ++++++++++++++++++++++++++++++
> >  4 files changed, 220 insertions(+)
> >  create mode 100644 drivers/video/backlight/ktz8866.c
> > 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 42fc47c6edfd..2084e74e1b58 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -11674,6 +11674,12 @@ M:	John Hawley <warthog9@eaglescrag.net>
> >  S:	Maintained
> >  F:	tools/testing/ktest
> >  
> > +KTZ8866 BACKLIGHT DRIVER
> > +M:	Jianhua Lu <lujianhua000@gmail.com>
> > +S:	Maintained
> > +F:	Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml
> > +F:	drivers/video/backlight/ktz8866.c
> > +
> >  L3MDEV
> >  M:	David Ahern <dsahern@kernel.org>
> >  L:	netdev@vger.kernel.org
> > diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
> > index 936ba1e4d35e..f7113ceb264a 100644
> > --- a/drivers/video/backlight/Kconfig
> > +++ b/drivers/video/backlight/Kconfig
> > @@ -190,6 +190,14 @@ config BACKLIGHT_KTD253
> >  	  which is a 1-wire GPIO-controlled backlight found in some mobile
> >  	  phones.
> >  
> > +config BACKLIGHT_KTZ8866
> > +	tristate "Backlight Driver for Kinetic KTZ8866"
> > +	depends on I2C
> > +	select REGMAP_I2C
> > +	help
> > +		Say Y to enable the backlight driver for the Kinetic KTZ8866
> > +		found in Xiaomi Mi Pad 5 series.
> > +
> >  config BACKLIGHT_LM3533
> >  	tristate "Backlight Driver for LM3533"
> >  	depends on MFD_LM3533
> > diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
> > index e815f3f1deff..f70a819c304c 100644
> > --- a/drivers/video/backlight/Makefile
> > +++ b/drivers/video/backlight/Makefile
> > @@ -36,6 +36,7 @@ obj-$(CONFIG_BACKLIGHT_HP680)		+= hp680_bl.o
> >  obj-$(CONFIG_BACKLIGHT_HP700)		+= jornada720_bl.o
> >  obj-$(CONFIG_BACKLIGHT_IPAQ_MICRO)	+= ipaq_micro_bl.o
> >  obj-$(CONFIG_BACKLIGHT_KTD253)		+= ktd253-backlight.o
> > +obj-$(CONFIG_BACKLIGHT_KTZ8866)		+= ktz8866.o
> >  obj-$(CONFIG_BACKLIGHT_LM3533)		+= lm3533_bl.o
> >  obj-$(CONFIG_BACKLIGHT_LM3630A)		+= lm3630a_bl.o
> >  obj-$(CONFIG_BACKLIGHT_LM3639)		+= lm3639_bl.o
> > diff --git a/drivers/video/backlight/ktz8866.c b/drivers/video/backlight/ktz8866.c
> > new file mode 100644
> > index 000000000000..ca3ac349cd10
> > --- /dev/null
> > +++ b/drivers/video/backlight/ktz8866.c
> > @@ -0,0 +1,205 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * Backlight driver for the Kinetic KTZ8866
> > + *
> > + * Copyright (C) 2022, 2023 Jianhua Lu <lujianhua000@gmail.com>
> > + */
> > +
> > +#include <linux/backlight.h>
> > +#include <linux/delay.h>
> > +#include <linux/err.h>
> > +#include <linux/i2c.h>
> > +#include <linux/module.h>
> > +#include <linux/of.h>
> > +#include <linux/regmap.h>
> > +
> > +#define DEFAULT_BRIGHTNESS 1500
> > +#define MAX_BRIGHTNESS 2047
> > +#define REG_MAX 0x15
> > +
> > +/* reg */
> > +#define DEVICE_ID 0x01
> > +#define BL_CFG1 0x02
> > +#define BL_CFG2 0x03
> > +#define BL_BRT_LSB 0x04
> > +#define BL_BRT_MSB 0x05
> > +#define BL_EN 0x08
> > +#define LCD_BIAS_CFG1 0x09
> > +#define LCD_BIAS_CFG2 0x0A
> > +#define LCD_BIAS_CFG3 0x0B
> > +#define LCD_BOOST_CFG 0x0C
> > +#define OUTP_CFG 0x0D
> > +#define OUTN_CFG 0x0E
> > +#define FLAG 0x0F
> > +#define BL_OPTION1 0x10
> > +#define BL_OPTION2 0x11
> > +#define PWM2DIG_LSBs 0x12
> > +#define PWM2DIG_MSBs 0x13
> > +#define BL_DIMMING 0x14
> > +#define PWM_RAMP_TIME 0x15
> > +
> > +/* definition */
> > +#define BL_EN_BIT BIT(6)
> > +#define LCD_BIAS_EN 0x9F
> > +#define PWM_HYST 0x5
> > +
> > +struct ktz8866 {
> > +	struct i2c_client *client;
> > +	struct regmap *regmap;
> > +	bool led_on;
> > +};
> > +
> > +static const struct regmap_config ktz8866_regmap_config = {
> > +	.reg_bits = 8,
> > +	.val_bits = 8,
> > +	.max_register = REG_MAX,
> > +};
> > +
> > +static int ktz8866_write(struct ktz8866 *ktz, unsigned int reg,
> > +			 unsigned int val)
> > +{
> > +	return regmap_write(ktz->regmap, reg, val);
> > +}
> > +
> > +static int ktz8866_update_bits(struct ktz8866 *ktz, unsigned int reg,
> > +			       unsigned int mask, unsigned int val)
> > +{
> > +	return regmap_update_bits(ktz->regmap, reg, mask, val);
> > +}
> > +
> > +static int ktz8866_backlight_update_status(struct backlight_device *backlight_dev)
> > +{
> > +	struct ktz8866 *ktz = bl_get_data(backlight_dev);
> > +	unsigned int brightness = backlight_get_brightness(backlight_dev);
> > +
> > +	if (!ktz->led_on && brightness > 0) {
> > +		ktz8866_update_bits(ktz, BL_EN, BL_EN_BIT, BL_EN_BIT);
> > +		ktz->led_on = true;
> > +	} else if (brightness == 0) {
> > +		ktz8866_update_bits(ktz, BL_EN, BL_EN_BIT, 0);
> > +		ktz->led_on = false;
> > +		msleep(10);
> 
> Why 10 ms? Document magic values. Their need, reason behind.
> 
> > +	}
> > +
> > +	/* Set brightness */
> > +	ktz8866_write(ktz, BL_BRT_LSB, brightness & 0x7);
> > +	ktz8866_write(ktz, BL_BRT_MSB, (brightness >> 3) & 0xFF);
> > +
> > +	return 0;
> > +}
> > +
> > +static const struct backlight_ops ktz8866_backlight_ops = {
> > +	.options = BL_CORE_SUSPENDRESUME,
> > +	.update_status = ktz8866_backlight_update_status,
> > +};
> > +
> > +static void ktz8866_init(struct ktz8866 *ktz)
> > +{
> > +	unsigned int val;
> > +
> > +	if(of_property_read_u32(ktz->client->dev.of_node, "current-num-sinks", &val))
> 
> Here and in other places - not conforming to coding style. Missing space
> before (.
> 
> Be sure you run checkpatch --strict and fix all relevant errors.
> 
> > +		ktz8866_write(ktz, BL_EN, BIT(val) - 1);
> > +	else
> > +		/* Enable all 6 current sinks if the number of current sinks isn't specifed. */
> > +		ktz8866_write(ktz, BL_EN, BIT(6) - 1);
> > +
> > +	if(of_property_read_u32(ktz->client->dev.of_node, "current-ramping-time-ms", &val)) {
> > +		if(val <= 128) {
> > +			ktz8866_write(ktz, BL_CFG2, BIT(7) | (ilog2(val) << 3) | PWM_HYST);
> > +		} else {
> > +			ktz8866_write(ktz, BL_CFG2, BIT(7) | ((5 + val / 64) << 3) | PWM_HYST);
> > +		}
> > +	}
> > +
> > +	if(of_property_read_u32(ktz->client->dev.of_node, "led-ramping-time-ms", &val)) {
> > +		if(val == 0) {
> > +			ktz8866_write(ktz, BL_DIMMING, 0);
> > +		} else {
> > +			unsigned int ramp_off_time = ilog2(val) + 1;
> > +			unsigned int ramp_on_time = ramp_off_time << 4;
> > +			ktz8866_write(ktz, BL_DIMMING, ramp_on_time | ramp_off_time);
> > +		}
> > +	}
> > +
> > +	if(of_property_read_bool(ktz->client->dev.of_node, "enable-lcd-bias"))
> > +		ktz8866_write(ktz, LCD_BIAS_CFG1, LCD_BIAS_EN);
> > +}
> > +
> > +static int ktz8866_probe(struct i2c_client *client,
> > +			 const struct i2c_device_id *id)
> > +{
> > +	struct backlight_device *backlight_dev;
> > +	struct backlight_properties props;
> > +	struct ktz8866 *ktz;
> > +
> > +	ktz = devm_kzalloc(&client->dev, sizeof(*ktz), GFP_KERNEL);
> > +	if (!ktz)
> > +		return -ENOMEM;
> > +
> > +	ktz->client = client;
> > +	ktz->regmap = devm_regmap_init_i2c(client, &ktz8866_regmap_config);
> > +
> 
> Drop blank line
> 
> > +	if (IS_ERR(ktz->regmap)) {
> > +		dev_err(&client->dev, "failed to init regmap\n");
> 
> dev_err_probe
> 
> > +		return PTR_ERR(ktz->regmap);
> > +	}
> > +
> > +	memset(&props, 0, sizeof(props));
> > +	props.type = BACKLIGHT_RAW;
> > +	props.max_brightness = MAX_BRIGHTNESS;
> > +	props.brightness = DEFAULT_BRIGHTNESS;
> > +	props.scale = BACKLIGHT_SCALE_LINEAR;
> > +
> > +	backlight_dev = devm_backlight_device_register(
> > +		&client->dev, "ktz8866-backlight", &client->dev, ktz,> +		&ktz8866_backlight_ops, &props);
> > +
> 
> Drop blank line
> 
> > +	if (IS_ERR(backlight_dev)) {
> > +		dev_err(&client->dev, "failed to register backlight device\n");
> 
> dev_err_probe
> 
> > +		return PTR_ERR(backlight_dev);
> > +	}
> > +
> > +	ktz8866_init(ktz);
> > +
> > +	i2c_set_clientdata(client, backlight_dev);
> > +	backlight_update_status(backlight_dev);
> > +
> > +	return 0;
> > +}
> > +
> > +static void ktz8866_remove(struct i2c_client *client)
> > +{
> > +	struct backlight_device *backlight_dev = i2c_get_clientdata(client);
> > +
> > +	backlight_dev->props.brightness = 0;
> > +	backlight_update_status(backlight_dev);
> > +}
> > +
> > +static const struct i2c_device_id ktz8866_ids[] = {
> > +	{ "ktz8866", 0 },
> > +	{},
> > +};
> > +MODULE_DEVICE_TABLE(i2c, ktz8866_ids);
> > +
> > +static const struct of_device_id ktz8866_match_table[] = {
> > +	{
> > +		.compatible = "kinetic,ktz8866",
> > +	},
> > +	{},
> > +};
> > +
> > +static struct i2c_driver ktz8866_driver = {
> > +	.driver = {
> > +		.name = "ktz8866",
> > +		.of_match_table = ktz8866_match_table,
> > +	},
> > +	.probe = ktz8866_probe,
> > +	.remove = ktz8866_remove,
> > +	.id_table = ktz8866_ids,
> > +};
> > +
> > +module_i2c_driver(ktz8866_driver);
> > +
> > +MODULE_DESCRIPTION("Kinetic KTZ8866 Backlight Driver");
> > +MODULE_AUTHOR("Jianhua Lu <lujianhua000@gmail.com>");
> > +MODULE_LICENSE("GPL");
> 
> Best regards,
> Krzysztof
> 
I will send new version patches, thanks.

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

* Re: [PATCH v6 1/2] dt-bindings: leds: backlight: Add Kinetic KTZ8866 backlight
  2023-01-18 13:40 ` [PATCH v6 1/2] dt-bindings: leds: backlight: Add " Krzysztof Kozlowski
@ 2023-01-18 14:00   ` Jianhua Lu
  0 siblings, 0 replies; 7+ messages in thread
From: Jianhua Lu @ 2023-01-18 14:00 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek, Rob Herring,
	Krzysztof Kozlowski, Helge Deller, linux-kernel, dri-devel,
	linux-leds, devicetree, linux-fbdev

On Wed, Jan 18, 2023 at 02:40:00PM +0100, Krzysztof Kozlowski wrote:
> On 18/01/2023 14:10, Jianhua Lu wrote:
> > Add Kinetic KTZ8866 backlight binding documentation.
> > 
> > Signed-off-by: Jianhua Lu <lujianhua000@gmail.com>
> > ---
> > Changes in v2:
> >   - Remove "items" between "compatible" and "const: kinetic,ktz8866"
> >   - Change "additionalProperties" to "unevaluatedProperties"
> > 
> > Changes in v3:
> >   - Add Krzysztof's R-b
> > 
> > Changes in v4:
> >   - Drop Krzysztof's R-b
> >   - Add some new properties
> > 
> > Changes in v5:
> >   - Add missing enum under property description.
> >   - Rename uncorrect properties.
> > 
> > Changes in v6:
> >   - Correct wrong property suffix and description.
> > 
> >  .../leds/backlight/kinetic,ktz8866.yaml       | 59 +++++++++++++++++++
> >  1 file changed, 59 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml b/Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml
> > new file mode 100644
> > index 000000000000..ca0deba14523
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml
> > @@ -0,0 +1,59 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/leds/backlight/kinetic,ktz8866.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Kinetic Technologies KTZ8866 backlight
> > +
> > +maintainers:
> > +  - Jianhua Lu <lujianhua000@gmail.com>
> > +
> > +description: |
> > +  The Kinetic Technologies KTZ8866 is a high efficiency 6-sinks led backlight
> > +  with dual lcd bias power.
> > +  https://www.kinet-ic.com/ktz8866/
> > +
> > +allOf:
> > +  - $ref: common.yaml#
> > +
> > +properties:
> > +  compatible:
> > +    const: kinetic,ktz8866
> > +
> > +  current-num-sinks:
> > +    description: Number of LED current sinks.
> > +    enum: [1, 2, 3, 4, 5, 6]
> > +
> > +  current-ramping-time-ms:
> > +    description: LED current ramping time in milliseconds.
> > +    enum: [2, 4, 8, 16, 32, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640]
> > +
> > +  led-ramping-time-ms:
> > +    description: |
> > +      LED on/off ramping time in milliseconds, note that the case 0 will be mapped
> > +      to 512μs because ktz8866 can't ramp faster than it.
> 
> Aren't you just missing supplies here and their ramp up time?
>
backlight ic supply bias power to panel, but downsteam devicetree adds power supplies node to panel node, 
so I'm not sure if need to add power supplies to backlight node.
> > +    enum: [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]
> > +
> > +  enable-lcd-bias:
> > +    description: Set if we want to output bias power supply for LCD.
> 
> Is it a generic property? I don't see any other users, so this looks
> device specific thus needs vendor prefix.
> 
> This applies to all of the properties. They might be generic or might
> not, I don't know the backlight hardware that much.
It surely is device specific, thanks.
> 
> > +    type: boolean
> > +
> > +required:
> > +  - compatible
> > +
> > +unevaluatedProperties: false
> > +
> > +examples:
> > +  - |
> > +    backlight {
> > +        compatible = "kinetic,ktz8866";
> > +
> > +        pinctrl-names = "default";
> > +        pinctrl-0 = <&bl_en_default>;
> > +
> > +        current-num-sinks = <5>;
> > +        current-ramping-time-ms = <128>;
> > +        led-ramping-time-ms = <1>;
> > +        enable-lcd-bias;
> > +    };
> 
> Best regards,
> Krzysztof
> 

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

* Re: [PATCH v6 2/2] backlight: ktz8866: Add support for Kinetic KTZ8866 backlight
  2023-01-18 13:10 ` [PATCH v6 2/2] backlight: ktz8866: Add support for " Jianhua Lu
  2023-01-18 13:39   ` Krzysztof Kozlowski
@ 2023-01-19 18:35   ` kernel test robot
  1 sibling, 0 replies; 7+ messages in thread
From: kernel test robot @ 2023-01-19 18:35 UTC (permalink / raw)
  To: Jianhua Lu, Lee Jones, Daniel Thompson, Jingoo Han, Pavel Machek,
	Rob Herring, Krzysztof Kozlowski, Helge Deller
  Cc: oe-kbuild-all, linux-kernel, dri-devel, linux-leds, devicetree,
	linux-fbdev, Jianhua Lu

Hi Jianhua,

I love your patch! Perhaps something to improve:

[auto build test WARNING on lee-backlight/for-backlight-next]
[also build test WARNING on lee-backlight/for-backlight-fixes lee-leds/for-leds-next pavel-leds/for-next linus/master v6.2-rc4 next-20230119]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jianhua-Lu/backlight-ktz8866-Add-support-for-Kinetic-KTZ8866-backlight/20230118-214354
base:   https://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight.git for-backlight-next
patch link:    https://lore.kernel.org/r/20230118131002.15453-2-lujianhua000%40gmail.com
patch subject: [PATCH v6 2/2] backlight: ktz8866: Add support for Kinetic KTZ8866 backlight
config: parisc-randconfig-r031-20230119 (https://download.01.org/0day-ci/archive/20230120/202301200239.m4ZDprWz-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 12.1.0
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/intel-lab-lkp/linux/commit/b862510e8bf9eb34db9d71a372b9de05682cb8ad
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Jianhua-Lu/backlight-ktz8866-Add-support-for-Kinetic-KTZ8866-backlight/20230118-214354
        git checkout b862510e8bf9eb34db9d71a372b9de05682cb8ad
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=parisc olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=parisc SHELL=/bin/bash drivers/video/backlight/

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

All warnings (new ones prefixed by >>):

   In file included from include/linux/bits.h:6,
                    from include/linux/ratelimit_types.h:5,
                    from include/linux/ratelimit.h:5,
                    from include/linux/dev_printk.h:16,
                    from include/linux/device.h:15,
                    from include/linux/backlight.h:12,
                    from drivers/video/backlight/ktz8866.c:8:
   include/vdso/bits.h: In function 'ktz8866_init':
>> include/vdso/bits.h:7:40: warning: 'val' is used uninitialized [-Wuninitialized]
       7 | #define BIT(nr)                 (UL(1) << (nr))
         |                                        ^~
   drivers/video/backlight/ktz8866.c:98:22: note: 'val' was declared here
      98 |         unsigned int val;
         |                      ^~~


vim +/val +7 include/vdso/bits.h

3945ff37d2f48d Vincenzo Frascino 2020-03-20  6  
3945ff37d2f48d Vincenzo Frascino 2020-03-20 @7  #define BIT(nr)			(UL(1) << (nr))
3945ff37d2f48d Vincenzo Frascino 2020-03-20  8  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

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

end of thread, other threads:[~2023-01-19 18:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-18 13:10 [PATCH v6 1/2] dt-bindings: leds: backlight: Add Kinetic KTZ8866 backlight Jianhua Lu
2023-01-18 13:10 ` [PATCH v6 2/2] backlight: ktz8866: Add support for " Jianhua Lu
2023-01-18 13:39   ` Krzysztof Kozlowski
2023-01-18 13:53     ` Jianhua Lu
2023-01-19 18:35   ` kernel test robot
2023-01-18 13:40 ` [PATCH v6 1/2] dt-bindings: leds: backlight: Add " Krzysztof Kozlowski
2023-01-18 14:00   ` Jianhua Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).