All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2 v4] dt-bindings: leds: Add DT binding for Richtek RT8515
@ 2020-11-12 11:56 Linus Walleij
  2020-11-12 11:56 ` [PATCH 2/2 v4] leds: rt8515: Add Richtek RT8515 LED driver Linus Walleij
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Linus Walleij @ 2020-11-12 11:56 UTC (permalink / raw)
  To: Jacek Anaszewski, Pavel Machek, Dan Murphy
  Cc: linux-leds, Linus Walleij, Sakari Ailus, newbytee,
	Stephan Gerhold, phone-devel, linux-media, devicetree

Add a YAML devicetree binding for the Richtek RT8515
dual channel flash/torch LED driver.

Cc: Sakari Ailus <sakari.ailus@iki.fi>
Cc: newbytee@protonmail.com
Cc: Stephan Gerhold <stephan@gerhold.net>
Cc: phone-devel@vger.kernel.org
Cc: linux-media@vger.kernel.org
Cc: devicetree@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v3->v4:
- Add DT attributes for the RFS and RTS resistors, so that
  the hardware-defined maximum current can be determined.
- Add torch-max-microamp to the common bindings so we can
  set an attribute for the max microamp in torch mode.
- Add flash-max-microamp and torch-max-microamp as optional
  to the LED node.
- Slot in some elabortative descriptions of the new
  properties and describe what the hardware is doing.
- Cc phone-devel@vger.kernel.org
ChangeLog v2->v3:
- Add Sakari to CC
- Resend
ChangeLog v1->v2:
- Explicitly inherit function, color and flash-max-timeout-us
  from common.yaml
- Add "led" node as required.
---
 .../devicetree/bindings/leds/common.yaml      |   6 +
 .../bindings/leds/richtek,rt8515.yaml         | 111 ++++++++++++++++++
 2 files changed, 117 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/richtek,rt8515.yaml

diff --git a/Documentation/devicetree/bindings/leds/common.yaml b/Documentation/devicetree/bindings/leds/common.yaml
index 08b6700ca61e..28bdf09b4af4 100644
--- a/Documentation/devicetree/bindings/leds/common.yaml
+++ b/Documentation/devicetree/bindings/leds/common.yaml
@@ -151,6 +151,12 @@ properties:
       Maximum flash LED supply current in microamperes. Required for flash LED
       nodes with configurable current.
 
+  torch-max-microamp:
+    description:
+      Maximum flash LED supply current in microamperes, when the flash LED is
+      used as a torch (flashlight). This is usually lower than the flash mode
+      maximum current, if the LED supports torch mode.
+
   flash-max-timeout-us:
     description:
       Maximum timeout in microseconds after which the flash LED is turned off.
diff --git a/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml b/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml
new file mode 100644
index 000000000000..5f65a20b997d
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml
@@ -0,0 +1,111 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/richtek,rt8515.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Richtek RT8515 1.5A dual channel LED driver
+
+maintainers:
+  - Linus Walleij <linus.walleij@linaro.org>
+
+description: |
+  The Richtek RT8515 is a dual channel (two mode) LED driver that
+  supports driving a white LED in flash or torch mode. The maximum
+  current for each mode is defined in hardware using two resistors
+  RFS and RTS.
+
+properties:
+  compatible:
+    const: richtek,rt8515
+
+  enf-gpios:
+    maxItems: 1
+    description: A connection to the 'ENF' (enable flash) pin.
+
+  ent-gpios:
+    maxItems: 1
+    description: A connection to the 'ENT' (enable torch) pin.
+
+  richtek,rfs:
+    maxItems: 1
+    minimum: 7680
+    maximum: 367000
+    description: The resistance value of the RFS resisitor. This
+      resistors limits the maximum flash current. This must be set
+      for the property flash-max-microamp to work, the RFS resistor
+      defines the range of the dimmer setting (brightness) of the
+      flash LED.
+
+  richtek,rts:
+    maxItems: 1
+    minimum: 7680
+    maximum: 367000
+    description: The resistance value of the RTS resisitor. This
+      resistors limits the maximum torch current. This must be set
+      for the property torch-max-microamp to work, the RTS resistor
+      defines the range of the dimmer setting (brightness) of the
+      torch LED.
+
+  led:
+    type: object
+    $ref: common.yaml#
+    properties:
+      function: true
+      color: true
+      flash-max-timeout-us: true
+
+      flash-max-microamp:
+        maximum: 700000
+        description: The maximum current for flash mode
+          is hardwired to the component using the RFS resistor to
+          ground. The maximum hardware current setting is calculated
+          according to the formula Imax = 5500 / RFS. The lowest
+          allowed resistance value is 7.86 kOhm giving an absolute
+          maximum current of 700mA. By setting this attribute in
+          the device tree, you can further restrict the maximum
+          current below the hardware limit. This requires the RFS
+          to be defined as it defines the maximum range.
+
+      torch-max-microamp:
+        maximum: 700000
+        description: The maximum current for torch mode
+          is hardwired to the component using the RTS resistor to
+          ground. The maximum hardware current setting is calculated
+          according to the formula Imax = 5500 / RTS. The lowest
+          allowed resistance value is 7.86 kOhm giving an absolute
+          maximum current of 700mA. By setting this attribute in
+          the device tree, you can further restrict the maximum
+          current below the hardware limit. This requires the RTS
+          to be defined as it defines the maximum range.
+
+required:
+  - compatible
+  - ent-gpios
+  - enf-gpios
+  - led
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/leds/common.h>
+
+    led-controller {
+        compatible = "richtek,rt8515";
+        enf-gpios = <&gpio4 12 GPIO_ACTIVE_HIGH>;
+        ent-gpios = <&gpio4 13 GPIO_ACTIVE_HIGH>;
+        richtek,rfs = <16000>;
+        richtek,rts = <100000>;
+
+        led {
+            function = LED_FUNCTION_FLASH;
+            color = <LED_COLOR_ID_WHITE>;
+            flash-max-timeout-us = <250000>;
+            flash-max-microamp = <150000>;
+            torch-max-microamp = <25000>;
+        };
+    };
+
+...
-- 
2.26.2


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

* [PATCH 2/2 v4] leds: rt8515: Add Richtek RT8515 LED driver
  2020-11-12 11:56 [PATCH 1/2 v4] dt-bindings: leds: Add DT binding for Richtek RT8515 Linus Walleij
@ 2020-11-12 11:56 ` Linus Walleij
  2020-11-13  4:09   ` kernel test robot
  2020-11-12 14:58 ` [PATCH 1/2 v4] dt-bindings: leds: Add DT binding for Richtek RT8515 Rob Herring
  2020-11-12 22:16 ` Rob Herring
  2 siblings, 1 reply; 9+ messages in thread
From: Linus Walleij @ 2020-11-12 11:56 UTC (permalink / raw)
  To: Jacek Anaszewski, Pavel Machek, Dan Murphy
  Cc: linux-leds, Linus Walleij, Sakari Ailus, newbytee,
	Stephan Gerhold, linux-media, phone-devel

This adds a driver for the Richtek RT8515 dual channel
torch/flash white LED driver.

This LED driver is found in some mobile phones from
Samsung such as the GT-S7710 and GT-I8190.

A V4L interface is added.

We do not have a proper datasheet for the RT8515 but
it turns out that RT9387A has a public datasheet and
is essentially the same chip. We designed the driver
in accordance with this datasheet. The day someone
needs to drive a RT9387A this driver can probably
easily be augmented to handle that chip too.

Cc: Sakari Ailus <sakari.ailus@iki.fi>
Cc: newbytee@protonmail.com
Cc: Stephan Gerhold <stephan@gerhold.net>
Cc: linux-media@vger.kernel.org
Cc: phone-devel@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v3->v4:
- Create a new subdirectory for flash LEDs under
  drivers/leds/flash as requested by Pavel, move the
  driver there and set up a kbuild structure for pure
  flash LEDs.
  (Others can follow the established pattern.)
- Handle the new richtek,rfs and richtek,rts resistor
  values that make it possible to determine the current
  range configured in the hardware.
- Handle the new flash-max-microamp and torch-max-microamp
  if present and optionally further restrict the current
  range using these. Otherwise fall back on the hardware
  defaults as specified by the RFS and RTS resistors.
- Cc phone-devel@vger.kernel.org
- License as GPL-2.0-or-later
- Renable ent and enf gpio descriptors to enable_torch
  and enable_flash
Changelog v2->v3:
- Expand commit message.
- Add Sakari to Cc.
- Resend.
ChangeLog v1->v2:
- Break out routine to bitbang the brightness on a
  GPIO pin.
- Do not hardcode the LED name so that the framework
  can name it from DT properties.
---
 drivers/leds/Kconfig             |   3 +
 drivers/leds/Makefile            |   3 +
 drivers/leds/flash/Kconfig       |  15 ++
 drivers/leds/flash/Makefile      |   3 +
 drivers/leds/flash/leds-rt8515.c | 373 +++++++++++++++++++++++++++++++
 5 files changed, 397 insertions(+)
 create mode 100644 drivers/leds/flash/Kconfig
 create mode 100644 drivers/leds/flash/Makefile
 create mode 100644 drivers/leds/flash/leds-rt8515.c

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 849d3c5f908e..6c1d8b69a465 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -928,6 +928,9 @@ config LEDS_ACER_A500
 	  This option enables support for the Power Button LED of
 	  Acer Iconia Tab A500.
 
+comment "Flash and Torch LED drivers"
+source "drivers/leds/flash/Kconfig"
+
 comment "LED Triggers"
 source "drivers/leds/trigger/Kconfig"
 
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 73e603e1727e..156c0b4e60d9 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -103,5 +103,8 @@ obj-$(CONFIG_LEDS_SPI_BYTE)		+= leds-spi-byte.o
 # LED Userspace Drivers
 obj-$(CONFIG_LEDS_USER)			+= uleds.o
 
+# Flash and Torch LED Drivers
+obj-$(CONFIG_LEDS_CLASS_FLASH)		+= flash/
+
 # LED Triggers
 obj-$(CONFIG_LEDS_TRIGGERS)		+= trigger/
diff --git a/drivers/leds/flash/Kconfig b/drivers/leds/flash/Kconfig
new file mode 100644
index 000000000000..d21d273ef3da
--- /dev/null
+++ b/drivers/leds/flash/Kconfig
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0
+
+if LEDS_CLASS_FLASH
+
+config LEDS_RT8515
+	tristate "LED support for Richtek RT8515 flash/torch LED"
+	depends on GPIOLIB
+	help
+	  This option enables support for the Richtek RT8515 flash
+	  and torch LEDs found on some mobile phones.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called leds-rt8515.
+
+endif # LEDS_CLASS_FLASH
diff --git a/drivers/leds/flash/Makefile b/drivers/leds/flash/Makefile
new file mode 100644
index 000000000000..e990e257f4d7
--- /dev/null
+++ b/drivers/leds/flash/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_LEDS_RT8515)	+= leds-rt8515.o
diff --git a/drivers/leds/flash/leds-rt8515.c b/drivers/leds/flash/leds-rt8515.c
new file mode 100644
index 000000000000..0add32b9255b
--- /dev/null
+++ b/drivers/leds/flash/leds-rt8515.c
@@ -0,0 +1,373 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * LED driver for Richtek RT8515 flash/torch white LEDs
+ * found on some Samsung mobile phones.
+ * This is a 1.5A Boost dual channel driver produced around 2011.
+ *
+ * Linus Walleij <linus.walleij@linaro.org>
+ */
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/gpio/consumer.h>
+#include <linux/led-class-flash.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
+
+#include <media/v4l2-flash-led-class.h>
+
+/* We can provide 15-700 mA out to the LED */
+#define RT8515_MIN_IOUT_MA	15
+#define RT8515_MAX_IOUT_MA	700
+/* The maximum intensity is 1-16 for flash and 1-100 for torch */
+#define RT8515_FLASH_MAX	16
+#define RT8515_TORCH_MAX	100
+
+#define RT8515_TIMEOUT_DEFAULT		250000U /* 250ms */
+#define RT8515_MAX_TIMEOUT_DEFAULT	300000U /* 300ms */
+
+struct rt8515 {
+	struct device *dev;
+	struct led_classdev_flash fled;
+	struct v4l2_flash *v4l2_flash;
+	struct mutex lock;
+	struct regulator *reg;
+	struct gpio_desc *enable_torch;
+	struct gpio_desc *enable_flash;
+	struct timer_list powerdown_timer;
+	u32 max_timeout; /* Flash max timeout */
+	int flash_max_intensity;
+	int torch_max_intensity;
+};
+
+static struct rt8515 *to_rt8515(struct led_classdev_flash *fled)
+{
+	return container_of(fled, struct rt8515, fled);
+}
+
+static void rt8515_gpio_brightness_commit(struct gpio_desc *gpiod,
+					  int brightness)
+{
+	int i;
+
+	/*
+	 * Toggling a GPIO line with a small delay increases the
+	 * brightness one step at a time.
+	 */
+	for (i = 0; i < brightness; i++) {
+		gpiod_set_value(gpiod, 0);
+		udelay(1);
+		gpiod_set_value(gpiod, 1);
+		udelay(1);
+	}
+}
+
+/* This is setting the torch light level */
+static int rt8515_led_brightness_set(struct led_classdev *led,
+				     enum led_brightness brightness)
+{
+	struct led_classdev_flash *fled = lcdev_to_flcdev(led);
+	struct rt8515 *rt = to_rt8515(fled);
+
+	mutex_lock(&rt->lock);
+
+	if (brightness == LED_OFF) {
+		/* Off */
+		gpiod_set_value(rt->enable_flash, 0);
+		gpiod_set_value(rt->enable_torch, 0);
+	} else if (brightness < RT8515_TORCH_MAX) {
+		/* Step it up to movie mode brightness using the flash pin */
+		rt8515_gpio_brightness_commit(rt->enable_torch, brightness);
+	} else {
+		/* Max torch brightness requested */
+		gpiod_set_value(rt->enable_torch, 1);
+	}
+
+	mutex_unlock(&rt->lock);
+
+	return 0;
+}
+
+static int rt8515_led_flash_strobe_set(struct led_classdev_flash *fled,
+				       bool state)
+{
+	struct rt8515 *rt = to_rt8515(fled);
+	struct led_flash_setting *timeout = &fled->timeout;
+	int brightness = 4; /* max 16 */
+
+	mutex_lock(&rt->lock);
+
+	if (state) {
+		/* Enable LED flash mode and set brightness */
+		rt8515_gpio_brightness_commit(rt->enable_flash, brightness);
+		/* Set timeout */
+		mod_timer(&rt->powerdown_timer,
+			  jiffies + usecs_to_jiffies(timeout->val));
+	} else {
+		del_timer_sync(&rt->powerdown_timer);
+		/* Turn the LED off */
+		gpiod_set_value(rt->enable_flash, 0);
+		gpiod_set_value(rt->enable_torch, 0);
+	}
+
+	fled->led_cdev.brightness = LED_OFF;
+	/* After this the torch LED will be disabled */
+
+	mutex_unlock(&rt->lock);
+
+	return 0;
+}
+
+static int rt8515_led_flash_strobe_get(struct led_classdev_flash *fled,
+				       bool *state)
+{
+	struct rt8515 *rt = to_rt8515(fled);
+
+	*state = timer_pending(&rt->powerdown_timer);
+
+	return 0;
+}
+
+static int rt8515_led_flash_timeout_set(struct led_classdev_flash *fled,
+					u32 timeout)
+{
+	/* The timeout is stored in the led-class-flash core */
+	return 0;
+}
+
+static const struct led_flash_ops rt8515_flash_ops = {
+	.strobe_set = rt8515_led_flash_strobe_set,
+	.strobe_get = rt8515_led_flash_strobe_get,
+	.timeout_set = rt8515_led_flash_timeout_set,
+};
+
+static void rt8515_powerdown_timer(struct timer_list *t)
+{
+	struct rt8515 *rt = from_timer(rt, t, powerdown_timer);
+
+	/* Turn the LED off */
+	gpiod_set_value(rt->enable_flash, 0);
+	gpiod_set_value(rt->enable_torch, 0);
+}
+
+static void rt8515_init_flash_timeout(struct rt8515 *rt)
+{
+	struct led_classdev_flash *fled = &rt->fled;
+	struct led_flash_setting *s;
+
+	/* Init flash timeout setting */
+	s = &fled->timeout;
+	s->min = 1;
+	s->max = rt->max_timeout;
+	s->step = 1;
+	/*
+	 * Set default timeout to RT8515_DEFAULT_TIMEOUT except if
+	 * max_timeout from DT is lower.
+	 */
+	s->val = min(rt->max_timeout, RT8515_TIMEOUT_DEFAULT);
+}
+
+#if IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS)
+/* Configure the V2L2 flash subdevice */
+static void rt8515_init_v4l2_flash_config(struct rt8515 *rt,
+					  struct v4l2_flash_config *v4l2_sd_cfg)
+{
+	struct led_classdev *led = &rt->fled.led_cdev;
+	struct led_flash_setting *s;
+
+	strscpy(v4l2_sd_cfg->dev_name, led->dev->kobj.name,
+		sizeof(v4l2_sd_cfg->dev_name));
+
+	/*
+	 * Init flash intensity setting: this is a linear scale
+	 * capped from the device tree max intensity setting
+	 * 1..flash_max_intensity
+	 */
+	s = &v4l2_sd_cfg->intensity;
+	s->min = 1;
+	s->max = rt->flash_max_intensity;
+	s->step = 1;
+	s->val = s->max;
+}
+
+#else
+static void rt8515_init_v4l2_flash_config(struct rt8515 *rt,
+					  struct v4l2_flash_config *v4l2_sd_cfg)
+{
+}
+#endif
+
+void rt8515_determine_max_intensity(struct rt8515 *rt,
+				    struct fwnode_handle *led,
+				    const char *resistance,
+				    const char *max_ua_prop, int hw_max,
+				    int *max_intensity_setting)
+{
+	u32 res;
+	u32 ua;
+	u32 max_ma;
+	int max_intensity;
+	int ret1, ret2;
+
+
+	ret1 = fwnode_property_read_u32(rt->dev->fwnode, resistance, &res);
+	ret2 = fwnode_property_read_u32(led, max_ua_prop, &ua);
+
+	/* No info in DT, OK go with hardware maxima */
+	if (ret1 && ret2) {
+		max_ma = RT8515_MAX_IOUT_MA;
+		max_intensity = hw_max;
+		goto out_assign_max;
+	}
+
+	if (ret1 || ret2) {
+		dev_err(rt->dev,
+			"either %s or %s missing from DT, using HW max\n",
+			resistance, max_ua_prop);
+		max_ma = RT8515_MAX_IOUT_MA;
+		max_intensity = hw_max;
+		goto out_assign_max;
+	}
+
+	/*
+	 * Formula from datasheet, this is the maximum current
+	 * defined by the hardware.
+	 */
+	max_ma = (5500 * 1000) / res;
+	/*
+	 * Calculate max intensity (linear scaling)
+	 * Formula is ((ua / 1000) / max_ma) * 100, then simplified
+	 */
+	max_intensity = (ua / 10) / max_ma;
+
+	dev_info(rt->dev,
+		 "current restricted from %u to %u mA, max intensity %d/100\n",
+		 max_ma, (ua / 1000), max_intensity);
+
+out_assign_max:
+	dev_info(rt->dev, "max intensity %d/%d = %d mA\n",
+		 max_intensity, hw_max, max_ma);
+	*max_intensity_setting = max_intensity;
+}
+
+static int rt8515_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct fwnode_handle *child;
+	struct rt8515 *rt;
+	struct led_classdev *led;
+	struct led_classdev_flash *fled;
+	struct led_init_data init_data = {};
+	struct v4l2_flash_config v4l2_sd_cfg = {};
+	int ret;
+
+	rt = devm_kzalloc(dev, sizeof(*rt), GFP_KERNEL);
+	if (!rt)
+		return -ENOMEM;
+
+	rt->dev = dev;
+	fled = &rt->fled;
+	led = &fled->led_cdev;
+
+	/* ENF - Enable Flash line */
+	rt->enable_flash = devm_gpiod_get(dev, "enf", GPIOD_OUT_LOW);
+	if (IS_ERR(rt->enable_flash)) {
+		dev_err(dev, "cannot get ENF (enable flash) GPIO\n");
+		return PTR_ERR(rt->enable_flash);
+	}
+
+	/* ENT - Enable Torch line */
+	rt->enable_torch = devm_gpiod_get(dev, "ent", GPIOD_OUT_LOW);
+	if (IS_ERR(rt->enable_torch)) {
+		dev_err(dev, "cannot get ENT (enable torch) GPIO\n");
+		return PTR_ERR(rt->enable_torch);
+	}
+
+	child = fwnode_get_next_available_child_node(dev->fwnode, NULL);
+	if (!child) {
+		dev_err(dev,
+			"No fwnode child node found for connected LED.\n");
+		return -EINVAL;
+	}
+	init_data.fwnode = child;
+
+	rt8515_determine_max_intensity(rt, child, "richtek,rfs", "flash-max-microamp",
+				       RT8515_FLASH_MAX, &rt->flash_max_intensity);
+	rt8515_determine_max_intensity(rt, child, "richtek,rts", "torch-max-microamp",
+				       RT8515_TORCH_MAX, &rt->torch_max_intensity);
+
+	ret = fwnode_property_read_u32(child, "flash-max-timeout-us",
+				       &rt->max_timeout);
+	if (ret) {
+		rt->max_timeout = RT8515_MAX_TIMEOUT_DEFAULT;
+		dev_warn(dev,
+			 "flash-max-timeout-us property missing\n");
+	}
+	timer_setup(&rt->powerdown_timer, rt8515_powerdown_timer, 0);
+	rt8515_init_flash_timeout(rt);
+
+	fled->ops = &rt8515_flash_ops;
+
+	led->max_brightness = rt->torch_max_intensity;
+	led->brightness_set_blocking = rt8515_led_brightness_set;
+	led->flags |= LED_CORE_SUSPENDRESUME | LED_DEV_CAP_FLASH;
+
+	mutex_init(&rt->lock);
+
+	platform_set_drvdata(pdev, rt);
+
+	ret = devm_led_classdev_flash_register_ext(dev, fled, &init_data);
+	if (ret) {
+		dev_err(dev, "can't register LED %s\n", led->name);
+		mutex_destroy(&rt->lock);
+		return ret;
+	}
+
+	rt8515_init_v4l2_flash_config(rt, &v4l2_sd_cfg);
+
+	/* Create a V4L2 Flash device if V4L2 flash is enabled */
+	rt->v4l2_flash = v4l2_flash_init(dev, child, fled, NULL, &v4l2_sd_cfg);
+	if (IS_ERR(rt->v4l2_flash)) {
+		ret = PTR_ERR(rt->v4l2_flash);
+		dev_err(dev, "failed to register V4L2 flash device (%d)\n",
+			ret);
+		/*
+		 * Continue without the V4L2 flash
+		 * (we still have the classdev)
+		 */
+	}
+
+	return 0;
+}
+
+static int rt8515_remove(struct platform_device *pdev)
+{
+	struct rt8515 *rt = platform_get_drvdata(pdev);
+
+	v4l2_flash_release(rt->v4l2_flash);
+	del_timer_sync(&rt->powerdown_timer);
+	mutex_destroy(&rt->lock);
+
+	return 0;
+}
+
+static const struct of_device_id rt8515_match[] = {
+	{ .compatible = "richtek,rt8515", },
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, rt8515_match);
+
+static struct platform_driver rt8515_driver = {
+	.driver = {
+		.name  = "rt8515",
+		.of_match_table = rt8515_match,
+	},
+	.probe  = rt8515_probe,
+	.remove = rt8515_remove,
+};
+module_platform_driver(rt8515_driver);
+
+MODULE_AUTHOR("Linus Walleij <linus.walleij@linaro.org>");
+MODULE_DESCRIPTION("Richtek RT8515 LED driver");
+MODULE_LICENSE("GPL v2");
-- 
2.26.2


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

* Re: [PATCH 1/2 v4] dt-bindings: leds: Add DT binding for Richtek RT8515
  2020-11-12 11:56 [PATCH 1/2 v4] dt-bindings: leds: Add DT binding for Richtek RT8515 Linus Walleij
  2020-11-12 11:56 ` [PATCH 2/2 v4] leds: rt8515: Add Richtek RT8515 LED driver Linus Walleij
@ 2020-11-12 14:58 ` Rob Herring
  2020-11-12 15:03   ` Linus Walleij
  2020-11-12 22:16 ` Rob Herring
  2 siblings, 1 reply; 9+ messages in thread
From: Rob Herring @ 2020-11-12 14:58 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Jacek Anaszewski, newbytee, linux-leds, Dan Murphy, Sakari Ailus,
	devicetree, phone-devel, linux-media, Stephan Gerhold,
	Pavel Machek

On Thu, 12 Nov 2020 12:56:45 +0100, Linus Walleij wrote:
> Add a YAML devicetree binding for the Richtek RT8515
> dual channel flash/torch LED driver.
> 
> Cc: Sakari Ailus <sakari.ailus@iki.fi>
> Cc: newbytee@protonmail.com
> Cc: Stephan Gerhold <stephan@gerhold.net>
> Cc: phone-devel@vger.kernel.org
> Cc: linux-media@vger.kernel.org
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v3->v4:
> - Add DT attributes for the RFS and RTS resistors, so that
>   the hardware-defined maximum current can be determined.
> - Add torch-max-microamp to the common bindings so we can
>   set an attribute for the max microamp in torch mode.
> - Add flash-max-microamp and torch-max-microamp as optional
>   to the LED node.
> - Slot in some elabortative descriptions of the new
>   properties and describe what the hardware is doing.
> - Cc phone-devel@vger.kernel.org
> ChangeLog v2->v3:
> - Add Sakari to CC
> - Resend
> ChangeLog v1->v2:
> - Explicitly inherit function, color and flash-max-timeout-us
>   from common.yaml
> - Add "led" node as required.
> ---
>  .../devicetree/bindings/leds/common.yaml      |   6 +
>  .../bindings/leds/richtek,rt8515.yaml         | 111 ++++++++++++++++++
>  2 files changed, 117 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/leds/richtek,rt8515.yaml
> 


My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rts:maximum: False schema does not allow 367000
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rts:minimum: False schema does not allow 7680
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rfs:maximum: False schema does not allow 367000
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rfs:minimum: False schema does not allow 7680
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rts: 'oneOf' conditional failed, one must be fixed:
	'type' is a required property
	Additional properties are not allowed ('maximum', 'minimum', 'maxItems' were unexpected)
	/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rts: 'oneOf' conditional failed, one must be fixed:
		'enum' is a required property
		'const' is a required property
	/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rts: 'oneOf' conditional failed, one must be fixed:
		'$ref' is a required property
		'allOf' is a required property
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rfs: 'oneOf' conditional failed, one must be fixed:
	'type' is a required property
	Additional properties are not allowed ('maximum', 'minimum', 'maxItems' were unexpected)
	/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rfs: 'oneOf' conditional failed, one must be fixed:
		'enum' is a required property
		'const' is a required property
	/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: properties:richtek,rfs: 'oneOf' conditional failed, one must be fixed:
		'$ref' is a required property
		'allOf' is a required property
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml: ignoring, error in schema: properties: richtek,rfs: maximum
warning: no schema found in file: ./Documentation/devicetree/bindings/leds/richtek,rt8515.yaml


See https://patchwork.ozlabs.org/patch/1398897

The base for the patch is generally the last rc1. Any dependencies
should be noted.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit.


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

* Re: [PATCH 1/2 v4] dt-bindings: leds: Add DT binding for Richtek RT8515
  2020-11-12 14:58 ` [PATCH 1/2 v4] dt-bindings: leds: Add DT binding for Richtek RT8515 Rob Herring
@ 2020-11-12 15:03   ` Linus Walleij
  2020-11-12 15:45     ` Rob Herring
  0 siblings, 1 reply; 9+ messages in thread
From: Linus Walleij @ 2020-11-12 15:03 UTC (permalink / raw)
  To: Rob Herring
  Cc: Jacek Anaszewski, newbytee, Linux LED Subsystem, Dan Murphy,
	Sakari Ailus,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	phone-devel, Linux Media Mailing List, Stephan Gerhold,
	Pavel Machek

On Thu, Nov 12, 2020 at 3:58 PM Rob Herring <robh@kernel.org> wrote:

> My bot found errors running 'make dt_binding_check' on your patch:

I have a real hard time even testing YAML bindings after updating to the lates
dtschema, I just get so many errors from all over the tree and then it stops:

make[3]: *** [../Documentation/devicetree/bindings/Makefile:59:
Documentation/devicetree/bindings/processed-schema-examples.json]
Error 123
make[3]: Target '__build' not remade because of errors.
make[2]: *** [/var/linus/linux-nomadik/Makefile:1364: dt_binding_check] Error 2
make[2]: Leaving directory '/var/linus/linux-nomadik/build-ux500'
make[1]: *** [Makefile:185: __sub-make] Error 2
make[1]: Target 'dt_binding_check' not remade because of errors.
make[1]: Leaving directory '/var/linus/linux-nomadik'
make: *** [ux500.mak:573: check-bindings] Error 2

Is it necessary to run on linux-next to test schema/DTS for the moment?

Yours,
Linus Walleij

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

* Re: [PATCH 1/2 v4] dt-bindings: leds: Add DT binding for Richtek RT8515
  2020-11-12 15:03   ` Linus Walleij
@ 2020-11-12 15:45     ` Rob Herring
  2020-11-12 22:20       ` Rob Herring
  0 siblings, 1 reply; 9+ messages in thread
From: Rob Herring @ 2020-11-12 15:45 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Jacek Anaszewski, newbytee, Linux LED Subsystem, Dan Murphy,
	Sakari Ailus,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	phone-devel, Linux Media Mailing List, Stephan Gerhold,
	Pavel Machek

On Thu, Nov 12, 2020 at 9:04 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> On Thu, Nov 12, 2020 at 3:58 PM Rob Herring <robh@kernel.org> wrote:
>
> > My bot found errors running 'make dt_binding_check' on your patch:
>
> I have a real hard time even testing YAML bindings after updating to the lates
> dtschema, I just get so many errors from all over the tree and then it stops:
>
> make[3]: *** [../Documentation/devicetree/bindings/Makefile:59:
> Documentation/devicetree/bindings/processed-schema-examples.json]

I assume there was some error message more useful before this.

> Error 123
> make[3]: Target '__build' not remade because of errors.
> make[2]: *** [/var/linus/linux-nomadik/Makefile:1364: dt_binding_check] Error 2
> make[2]: Leaving directory '/var/linus/linux-nomadik/build-ux500'
> make[1]: *** [Makefile:185: __sub-make] Error 2
> make[1]: Target 'dt_binding_check' not remade because of errors.
> make[1]: Leaving directory '/var/linus/linux-nomadik'
> make: *** [ux500.mak:573: check-bindings] Error 2
>
> Is it necessary to run on linux-next to test schema/DTS for the moment?

next and rc3 are broken thanks to flexcan changes that should be v5.11
material. next pretty much always has something warning. It's like
maintainers just apply bindings without checking or something. rc2 and
rc1 should be good.

You can see current master and next builds here:

https://gitlab.com/robherring/linux-dt-bindings/-/jobs

You can also use 'make -k' to get all the warnings/errors.

Rob

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

* Re: [PATCH 1/2 v4] dt-bindings: leds: Add DT binding for Richtek RT8515
  2020-11-12 11:56 [PATCH 1/2 v4] dt-bindings: leds: Add DT binding for Richtek RT8515 Linus Walleij
  2020-11-12 11:56 ` [PATCH 2/2 v4] leds: rt8515: Add Richtek RT8515 LED driver Linus Walleij
  2020-11-12 14:58 ` [PATCH 1/2 v4] dt-bindings: leds: Add DT binding for Richtek RT8515 Rob Herring
@ 2020-11-12 22:16 ` Rob Herring
  2 siblings, 0 replies; 9+ messages in thread
From: Rob Herring @ 2020-11-12 22:16 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Jacek Anaszewski, Pavel Machek, Dan Murphy, Linux LED Subsystem,
	Sakari Ailus, newbytee, Stephan Gerhold, phone-devel,
	Linux Media Mailing List, devicetree

On Thu, Nov 12, 2020 at 5:57 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> Add a YAML devicetree binding for the Richtek RT8515
> dual channel flash/torch LED driver.
>
> Cc: Sakari Ailus <sakari.ailus@iki.fi>
> Cc: newbytee@protonmail.com
> Cc: Stephan Gerhold <stephan@gerhold.net>
> Cc: phone-devel@vger.kernel.org
> Cc: linux-media@vger.kernel.org
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v3->v4:
> - Add DT attributes for the RFS and RTS resistors, so that
>   the hardware-defined maximum current can be determined.
> - Add torch-max-microamp to the common bindings so we can
>   set an attribute for the max microamp in torch mode.
> - Add flash-max-microamp and torch-max-microamp as optional
>   to the LED node.
> - Slot in some elabortative descriptions of the new
>   properties and describe what the hardware is doing.
> - Cc phone-devel@vger.kernel.org
> ChangeLog v2->v3:
> - Add Sakari to CC
> - Resend
> ChangeLog v1->v2:
> - Explicitly inherit function, color and flash-max-timeout-us
>   from common.yaml
> - Add "led" node as required.
> ---
>  .../devicetree/bindings/leds/common.yaml      |   6 +
>  .../bindings/leds/richtek,rt8515.yaml         | 111 ++++++++++++++++++
>  2 files changed, 117 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/leds/richtek,rt8515.yaml
>
> diff --git a/Documentation/devicetree/bindings/leds/common.yaml b/Documentation/devicetree/bindings/leds/common.yaml
> index 08b6700ca61e..28bdf09b4af4 100644
> --- a/Documentation/devicetree/bindings/leds/common.yaml
> +++ b/Documentation/devicetree/bindings/leds/common.yaml
> @@ -151,6 +151,12 @@ properties:
>        Maximum flash LED supply current in microamperes. Required for flash LED
>        nodes with configurable current.
>
> +  torch-max-microamp:
> +    description:
> +      Maximum flash LED supply current in microamperes, when the flash LED is
> +      used as a torch (flashlight). This is usually lower than the flash mode
> +      maximum current, if the LED supports torch mode.
> +
>    flash-max-timeout-us:
>      description:
>        Maximum timeout in microseconds after which the flash LED is turned off.
> diff --git a/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml b/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml
> new file mode 100644
> index 000000000000..5f65a20b997d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/leds/richtek,rt8515.yaml
> @@ -0,0 +1,111 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/leds/richtek,rt8515.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Richtek RT8515 1.5A dual channel LED driver
> +
> +maintainers:
> +  - Linus Walleij <linus.walleij@linaro.org>
> +
> +description: |
> +  The Richtek RT8515 is a dual channel (two mode) LED driver that
> +  supports driving a white LED in flash or torch mode. The maximum
> +  current for each mode is defined in hardware using two resistors
> +  RFS and RTS.
> +
> +properties:
> +  compatible:
> +    const: richtek,rt8515
> +
> +  enf-gpios:
> +    maxItems: 1
> +    description: A connection to the 'ENF' (enable flash) pin.
> +
> +  ent-gpios:
> +    maxItems: 1
> +    description: A connection to the 'ENT' (enable torch) pin.
> +
> +  richtek,rfs:
> +    maxItems: 1
> +    minimum: 7680
> +    maximum: 367000

You've mixed vocabulary for arrays (maxItems) and scalars.

You need a type reference.

> +    description: The resistance value of the RFS resisitor. This

typo

> +      resistors limits the maximum flash current. This must be set
> +      for the property flash-max-microamp to work, the RFS resistor
> +      defines the range of the dimmer setting (brightness) of the
> +      flash LED.
> +
> +  richtek,rts:
> +    maxItems: 1
> +    minimum: 7680
> +    maximum: 367000
> +    description: The resistance value of the RTS resisitor. This

Same issues here.

> +      resistors limits the maximum torch current. This must be set
> +      for the property torch-max-microamp to work, the RTS resistor
> +      defines the range of the dimmer setting (brightness) of the
> +      torch LED.
> +
> +  led:
> +    type: object
> +    $ref: common.yaml#
> +    properties:
> +      function: true
> +      color: true
> +      flash-max-timeout-us: true
> +
> +      flash-max-microamp:
> +        maximum: 700000
> +        description: The maximum current for flash mode
> +          is hardwired to the component using the RFS resistor to
> +          ground. The maximum hardware current setting is calculated
> +          according to the formula Imax = 5500 / RFS. The lowest
> +          allowed resistance value is 7.86 kOhm giving an absolute
> +          maximum current of 700mA. By setting this attribute in
> +          the device tree, you can further restrict the maximum
> +          current below the hardware limit. This requires the RFS
> +          to be defined as it defines the maximum range.
> +
> +      torch-max-microamp:
> +        maximum: 700000
> +        description: The maximum current for torch mode
> +          is hardwired to the component using the RTS resistor to
> +          ground. The maximum hardware current setting is calculated
> +          according to the formula Imax = 5500 / RTS. The lowest
> +          allowed resistance value is 7.86 kOhm giving an absolute
> +          maximum current of 700mA. By setting this attribute in
> +          the device tree, you can further restrict the maximum
> +          current below the hardware limit. This requires the RTS
> +          to be defined as it defines the maximum range.
> +
> +required:
> +  - compatible
> +  - ent-gpios
> +  - enf-gpios
> +  - led
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/gpio/gpio.h>
> +    #include <dt-bindings/leds/common.h>
> +
> +    led-controller {
> +        compatible = "richtek,rt8515";
> +        enf-gpios = <&gpio4 12 GPIO_ACTIVE_HIGH>;
> +        ent-gpios = <&gpio4 13 GPIO_ACTIVE_HIGH>;
> +        richtek,rfs = <16000>;
> +        richtek,rts = <100000>;
> +
> +        led {
> +            function = LED_FUNCTION_FLASH;
> +            color = <LED_COLOR_ID_WHITE>;
> +            flash-max-timeout-us = <250000>;
> +            flash-max-microamp = <150000>;
> +            torch-max-microamp = <25000>;
> +        };
> +    };
> +
> +...
> --
> 2.26.2
>

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

* Re: [PATCH 1/2 v4] dt-bindings: leds: Add DT binding for Richtek RT8515
  2020-11-12 15:45     ` Rob Herring
@ 2020-11-12 22:20       ` Rob Herring
  2020-11-13 12:23         ` Linus Walleij
  0 siblings, 1 reply; 9+ messages in thread
From: Rob Herring @ 2020-11-12 22:20 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Jacek Anaszewski, newbytee, Linux LED Subsystem, Dan Murphy,
	Sakari Ailus,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	phone-devel, Linux Media Mailing List, Stephan Gerhold,
	Pavel Machek

On Thu, Nov 12, 2020 at 9:45 AM Rob Herring <robh@kernel.org> wrote:
>
> On Thu, Nov 12, 2020 at 9:04 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> >
> > On Thu, Nov 12, 2020 at 3:58 PM Rob Herring <robh@kernel.org> wrote:
> >
> > > My bot found errors running 'make dt_binding_check' on your patch:
> >
> > I have a real hard time even testing YAML bindings after updating to the lates
> > dtschema, I just get so many errors from all over the tree and then it stops:
> >
> > make[3]: *** [../Documentation/devicetree/bindings/Makefile:59:
> > Documentation/devicetree/bindings/processed-schema-examples.json]
>
> I assume there was some error message more useful before this.
>
> > Error 123
> > make[3]: Target '__build' not remade because of errors.
> > make[2]: *** [/var/linus/linux-nomadik/Makefile:1364: dt_binding_check] Error 2
> > make[2]: Leaving directory '/var/linus/linux-nomadik/build-ux500'
> > make[1]: *** [Makefile:185: __sub-make] Error 2
> > make[1]: Target 'dt_binding_check' not remade because of errors.
> > make[1]: Leaving directory '/var/linus/linux-nomadik'
> > make: *** [ux500.mak:573: check-bindings] Error 2
> >
> > Is it necessary to run on linux-next to test schema/DTS for the moment?
>
> next and rc3 are broken thanks to flexcan changes that should be v5.11
> material. next pretty much always has something warning. It's like
> maintainers just apply bindings without checking or something. rc2 and
> rc1 should be good.

Actually, rc1 was not good. I didn't get all the fixes in since armsoc
changes came in so late.

Rob

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

* Re: [PATCH 2/2 v4] leds: rt8515: Add Richtek RT8515 LED driver
  2020-11-12 11:56 ` [PATCH 2/2 v4] leds: rt8515: Add Richtek RT8515 LED driver Linus Walleij
@ 2020-11-13  4:09   ` kernel test robot
  0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2020-11-13  4:09 UTC (permalink / raw)
  To: kbuild-all

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

Hi Linus,

I love your patch! Perhaps something to improve:

[auto build test WARNING on pavel-linux-leds/for-next]
[also build test WARNING on v5.10-rc3 next-20201112]
[cannot apply to j.anaszewski-leds/for-next]
[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/Linus-Walleij/dt-bindings-leds-Add-DT-binding-for-Richtek-RT8515/20201112-195826
base:   git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git for-next
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.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/0day-ci/linux/commit/846dcb5b5cb37582e4b8398d794c7f4352653c8a
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Linus-Walleij/dt-bindings-leds-Add-DT-binding-for-Richtek-RT8515/20201112-195826
        git checkout 846dcb5b5cb37582e4b8398d794c7f4352653c8a
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k 

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 >>):

   In file included from include/linux/kernel.h:11,
                    from include/linux/delay.h:22,
                    from drivers/leds/flash/leds-rt8515.c:9:
   include/linux/scatterlist.h: In function 'sg_set_buf':
   arch/m68k/include/asm/page_mm.h:169:49: warning: ordered comparison of pointer with null pointer [-Wextra]
     169 | #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory)
         |                                                 ^~
   include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
      78 | # define unlikely(x) __builtin_expect(!!(x), 0)
         |                                          ^
   include/linux/scatterlist.h:143:2: note: in expansion of macro 'BUG_ON'
     143 |  BUG_ON(!virt_addr_valid(buf));
         |  ^~~~~~
   include/linux/scatterlist.h:143:10: note: in expansion of macro 'virt_addr_valid'
     143 |  BUG_ON(!virt_addr_valid(buf));
         |          ^~~~~~~~~~~~~~~
   drivers/leds/flash/leds-rt8515.c: At top level:
>> drivers/leds/flash/leds-rt8515.c:201:6: warning: no previous prototype for 'rt8515_determine_max_intensity' [-Wmissing-prototypes]
     201 | void rt8515_determine_max_intensity(struct rt8515 *rt,
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/rt8515_determine_max_intensity +201 drivers/leds/flash/leds-rt8515.c

   200	
 > 201	void rt8515_determine_max_intensity(struct rt8515 *rt,
   202					    struct fwnode_handle *led,
   203					    const char *resistance,
   204					    const char *max_ua_prop, int hw_max,
   205					    int *max_intensity_setting)
   206	{
   207		u32 res;
   208		u32 ua;
   209		u32 max_ma;
   210		int max_intensity;
   211		int ret1, ret2;
   212	
   213	
   214		ret1 = fwnode_property_read_u32(rt->dev->fwnode, resistance, &res);
   215		ret2 = fwnode_property_read_u32(led, max_ua_prop, &ua);
   216	
   217		/* No info in DT, OK go with hardware maxima */
   218		if (ret1 && ret2) {
   219			max_ma = RT8515_MAX_IOUT_MA;
   220			max_intensity = hw_max;
   221			goto out_assign_max;
   222		}
   223	
   224		if (ret1 || ret2) {
   225			dev_err(rt->dev,
   226				"either %s or %s missing from DT, using HW max\n",
   227				resistance, max_ua_prop);
   228			max_ma = RT8515_MAX_IOUT_MA;
   229			max_intensity = hw_max;
   230			goto out_assign_max;
   231		}
   232	
   233		/*
   234		 * Formula from datasheet, this is the maximum current
   235		 * defined by the hardware.
   236		 */
   237		max_ma = (5500 * 1000) / res;
   238		/*
   239		 * Calculate max intensity (linear scaling)
   240		 * Formula is ((ua / 1000) / max_ma) * 100, then simplified
   241		 */
   242		max_intensity = (ua / 10) / max_ma;
   243	
   244		dev_info(rt->dev,
   245			 "current restricted from %u to %u mA, max intensity %d/100\n",
   246			 max_ma, (ua / 1000), max_intensity);
   247	
   248	out_assign_max:
   249		dev_info(rt->dev, "max intensity %d/%d = %d mA\n",
   250			 max_intensity, hw_max, max_ma);
   251		*max_intensity_setting = max_intensity;
   252	}
   253	

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 58877 bytes --]

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

* Re: [PATCH 1/2 v4] dt-bindings: leds: Add DT binding for Richtek RT8515
  2020-11-12 22:20       ` Rob Herring
@ 2020-11-13 12:23         ` Linus Walleij
  0 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2020-11-13 12:23 UTC (permalink / raw)
  To: Rob Herring
  Cc: Jacek Anaszewski, newbytee, Linux LED Subsystem, Dan Murphy,
	Sakari Ailus,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	phone-devel, Linux Media Mailing List, Stephan Gerhold,
	Pavel Machek

On Thu, Nov 12, 2020 at 11:20 PM Rob Herring <robh@kernel.org> wrote:
> On Thu, Nov 12, 2020 at 9:45 AM Rob Herring <robh@kernel.org> wrote:
> > On Thu, Nov 12, 2020 at 9:04 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> > > On Thu, Nov 12, 2020 at 3:58 PM Rob Herring <robh@kernel.org> wrote:
> > >
> > > > My bot found errors running 'make dt_binding_check' on your patch:
> > >
> > > I have a real hard time even testing YAML bindings after updating to the lates
> > > dtschema, I just get so many errors from all over the tree and then it stops:
> > >
> > > make[3]: *** [../Documentation/devicetree/bindings/Makefile:59:
> > > Documentation/devicetree/bindings/processed-schema-examples.json]
> >
> > I assume there was some error message more useful before this.
> >
> > > Error 123
> > > make[3]: Target '__build' not remade because of errors.
> > > make[2]: *** [/var/linus/linux-nomadik/Makefile:1364: dt_binding_check] Error 2
> > > make[2]: Leaving directory '/var/linus/linux-nomadik/build-ux500'
> > > make[1]: *** [Makefile:185: __sub-make] Error 2
> > > make[1]: Target 'dt_binding_check' not remade because of errors.
> > > make[1]: Leaving directory '/var/linus/linux-nomadik'
> > > make: *** [ux500.mak:573: check-bindings] Error 2
> > >
> > > Is it necessary to run on linux-next to test schema/DTS for the moment?
> >
> > next and rc3 are broken thanks to flexcan changes that should be v5.11
> > material. next pretty much always has something warning. It's like
> > maintainers just apply bindings without checking or something. rc2 and
> > rc1 should be good.
>
> Actually, rc1 was not good. I didn't get all the fixes in since armsoc
> changes came in so late.

OK I try to rebase onto -rc2 and see if that solves my problem.

Yours,
Linus Walleij

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

end of thread, other threads:[~2020-11-13 12:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-12 11:56 [PATCH 1/2 v4] dt-bindings: leds: Add DT binding for Richtek RT8515 Linus Walleij
2020-11-12 11:56 ` [PATCH 2/2 v4] leds: rt8515: Add Richtek RT8515 LED driver Linus Walleij
2020-11-13  4:09   ` kernel test robot
2020-11-12 14:58 ` [PATCH 1/2 v4] dt-bindings: leds: Add DT binding for Richtek RT8515 Rob Herring
2020-11-12 15:03   ` Linus Walleij
2020-11-12 15:45     ` Rob Herring
2020-11-12 22:20       ` Rob Herring
2020-11-13 12:23         ` Linus Walleij
2020-11-12 22:16 ` Rob Herring

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.