mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: linux-leds@vger.kernel.org, linux-media@vger.kernel.org,
	linux-kernel@vger.kernel.org, kyungmin.park@samsung.com,
	b.zolnierkie@samsung.com, pavel@ucw.cz, cooloney@gmail.com,
	rpurdie@rpsys.net, s.nawrocki@samsung.com, robh+dt@kernel.org,
	pawel.moll@arm.com, mark.rutland@arm.com,
	ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
	Andrzej Hajda <a.hajda@samsung.com>,
	Lee Jones <lee.jones@linaro.org>,
	Chanwoo Choi <cw00.choi@samsung.com>
Subject: Re: [PATCH/RFC v9 05/19] leds: Add support for max77693 mfd flash cell
Date: Thu, 11 Dec 2014 17:48:03 +0200	[thread overview]
Message-ID: <20141211154803.GT15559@valkosipuli.retiisi.org.uk> (raw)
In-Reply-To: <5489A1E1.9040108@samsung.com>

Hi Jacek,

On Thu, Dec 11, 2014 at 02:53:37PM +0100, Jacek Anaszewski wrote:
> Hi Sakari,
> 
> On 12/09/2014 02:11 PM, Sakari Ailus wrote:
> >Hi Jacek,
> >
> >On Thu, Dec 04, 2014 at 12:06:59PM +0100, Jacek Anaszewski wrote:
> >>Hi Sakari,
> >>
> >>Thanks for the review.
> >
> >You're welcome! :-)
> >
> >>On 12/04/2014 10:39 AM, Sakari Ailus wrote:
> >>>Hi Jacek,
> >>>
> >>>On Wed, Dec 03, 2014 at 05:06:40PM +0100, Jacek Anaszewski wrote:
> >>>>This patch adds led-flash support to Maxim max77693 chipset.
> >>>>A device can be exposed to user space through LED subsystem
> >>>>sysfs interface. Device supports up to two leds which can
> >>>>work in flash and torch mode. The leds can be triggered
> >>>>externally or by software.
> >>>>
> >>>>Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
> >>>>Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> >>>>Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
> >>>>Cc: Bryan Wu <cooloney@gmail.com>
> >>>>Cc: Richard Purdie <rpurdie@rpsys.net>
> >>>>Cc: Lee Jones <lee.jones@linaro.org>
> >>>>Cc: Chanwoo Choi <cw00.choi@samsung.com>
> >>>>---
> >>>>  drivers/leds/Kconfig         |   10 +
> >>>>  drivers/leds/Makefile        |    1 +
> >>>>  drivers/leds/leds-max77693.c | 1023 ++++++++++++++++++++++++++++++++++++++++++
> >>>>  3 files changed, 1034 insertions(+)
> >>>>  create mode 100644 drivers/leds/leds-max77693.c
> >>>>
> >>>>diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> >>>>index fa8021e..2e66d55 100644
> >>>>--- a/drivers/leds/Kconfig
> >>>>+++ b/drivers/leds/Kconfig
> >>>>@@ -463,6 +463,16 @@ config LEDS_TCA6507
> >>>>  	  LED driver chips accessed via the I2C bus.
> >>>>  	  Driver support brightness control and hardware-assisted blinking.
> >>>>
> >>>>+config LEDS_MAX77693
> >>>>+	tristate "LED support for MAX77693 Flash"
> >>>>+	depends on LEDS_CLASS_FLASH
> >>>>+	depends on MFD_MAX77693
> >>>>+	depends on OF
> >>>>+	help
> >>>>+	  This option enables support for the flash part of the MAX77693
> >>>>+	  multifunction device. It has build in control for two leds in flash
> >>>>+	  and torch mode.
> >>>>+
> >>>>  config LEDS_MAX8997
> >>>>  	tristate "LED support for MAX8997 PMIC"
> >>>>  	depends on LEDS_CLASS && MFD_MAX8997
> >>>>diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
> >>>>index cbba921..57ca62b 100644
> >>>>--- a/drivers/leds/Makefile
> >>>>+++ b/drivers/leds/Makefile
> >>>>@@ -52,6 +52,7 @@ obj-$(CONFIG_LEDS_MC13783)		+= leds-mc13783.o
> >>>>  obj-$(CONFIG_LEDS_NS2)			+= leds-ns2.o
> >>>>  obj-$(CONFIG_LEDS_NETXBIG)		+= leds-netxbig.o
> >>>>  obj-$(CONFIG_LEDS_ASIC3)		+= leds-asic3.o
> >>>>+obj-$(CONFIG_LEDS_MAX77693)		+= leds-max77693.o
> >>>>  obj-$(CONFIG_LEDS_MAX8997)		+= leds-max8997.o
> >>>>  obj-$(CONFIG_LEDS_LM355x)		+= leds-lm355x.o
> >>>>  obj-$(CONFIG_LEDS_BLINKM)		+= leds-blinkm.o
> >>>>diff --git a/drivers/leds/leds-max77693.c b/drivers/leds/leds-max77693.c
> >>>>new file mode 100644
> >>>>index 0000000..67a2f8f
> >>>>--- /dev/null
> >>>>+++ b/drivers/leds/leds-max77693.c
> >>>>@@ -0,0 +1,1023 @@
> >>>>+/*
> >>>>+ * LED Flash class driver for the flash cell of max77693 mfd.
> >>>>+ *
> >>>>+ *	Copyright (C) 2014, Samsung Electronics Co., Ltd.
> >>>>+ *
> >>>>+ *	Authors: Jacek Anaszewski <j.anaszewski@samsung.com>
> >>>>+ *		 Andrzej Hajda <a.hajda@samsung.com>
> >>>>+ *
> >>>>+ * This program is free software; you can redistribute it and/or
> >>>>+ * modify it under the terms of the GNU General Public License
> >>>>+ * version 2 as published by the Free Software Foundation.
> >>>>+ */
> >>>>+
> >>>>+#include <asm/div64.h>
> >>>>+#include <linux/led-class-flash.h>
> >>>>+#include <linux/mfd/max77693.h>
> >>>>+#include <linux/mfd/max77693-private.h>
> >>>>+#include <linux/module.h>
> >>>>+#include <linux/mutex.h>
> >>>>+#include <linux/platform_device.h>
> >>>>+#include <linux/regmap.h>
> >>>>+#include <linux/slab.h>
> >>>>+#include <linux/workqueue.h>
> >>>>+
> >>>>+#define MODE_OFF		0
> >>>>+#define MODE_FLASH1		(1 << 0)
> >>>>+#define MODE_FLASH2		(1 << 1)
> >>>>+#define MODE_TORCH1		(1 << 2)
> >>>>+#define MODE_TORCH2		(1 << 3)
> >>>>+#define MODE_FLASH_EXTERNAL1	(1 << 4)
> >>>>+#define MODE_FLASH_EXTERNAL2	(1 << 5)
> >>>
> >>>You could do this based on an argument (led number). E.g.
> >>>
> >>>#define MODE_FLASH_EXTERNAL(a)	(1 << (4 + a))
> >>
> >>OK.
> >>
> >>>>+#define MODE_FLASH		(MODE_FLASH1 | MODE_FLASH2 | \
> >>>>+				 MODE_FLASH_EXTERNAL1 | MODE_FLASH_EXTERNAL2)
> >>>>+
> >>>>+#define FLED1_IOUT		(1 << 0)
> >>>>+#define FLED2_IOUT		(1 << 1)
> >>>>+
> >>>>+enum {
> >>>>+	FLED1,
> >>>>+	FLED2
> >>>>+};
> >>>>+
> >>>>+enum {
> >>>>+	FLASH,
> >>>>+	TORCH
> >>>>+};
> >>>>+
> >>>>+struct max77693_sub_led {
> >
> >This could then be renamed as "max77693_led"; up to you.
> 
> It will be better to rename the max77693_led structure to
> max77693_led_device instead of max77693_device like you proposed. This
> is because there is already max77693_dev structure in the mfd driver
> for max77693 and this is only a driver for the led part of a device.
> 
> Taking above into account I'd rather leave struct max77693_sub_led
> name unchanged.

Fine for me.

> >>>>+	struct led_classdev_flash ldev;
> >>>>+	struct work_struct work_brightness_set;
> >>>>+
> >>>>+	unsigned int torch_brightness;
> >>>>+	unsigned int flash_timeout;
> >>>>+};
> >>>>+
> >>>>+struct max77693_led {
> >>>
> >>>As this does not refer to a device, how about struct max77693_device, for
> >>>instance?
> >>
> >>OK.
> >>
> >>>>+	struct regmap *regmap;
> >>>>+	struct platform_device *pdev;
> >>>>+	struct max77693_led_platform_data *pdata;
> >>>>+	struct mutex lock;
> >>>>+
> >>>>+	struct max77693_sub_led sub_leds[2];
> >>>>+
> >>>>+	unsigned int current_flash_timeout;
> >>>>+	unsigned int mode_flags;
> >>>>+	u8 torch_iout_reg;
> >>>>+	bool iout_joint;
> >>>>+	int strobing_sub_led_id;
> >>>>+};
> >>>>+
> >>>>+struct max77693_led_settings {
> >>>>+	struct led_flash_setting torch_brightness;
> >>>>+	struct led_flash_setting flash_brightness;
> >>>>+	struct led_flash_setting flash_timeout;
> >>>>+};
> >>>>+
> >>>>+static u8 max77693_led_iout_to_reg(u32 ua)
> >>>>+{
> >>>>+	if (ua < FLASH_IOUT_MIN)
> >>>>+		ua = FLASH_IOUT_MIN;
> >>>>+	return (ua - FLASH_IOUT_MIN) / FLASH_IOUT_STEP;
> >>>>+}
> >>>>+
> >>>>+static u8 max77693_flash_timeout_to_reg(u32 us)
> >>>>+{
> >>>>+	return (us - FLASH_TIMEOUT_MIN) / FLASH_TIMEOUT_STEP;
> >>>>+}
> >>>>+
> >>>>+static inline struct max77693_led *ldev1_to_led(
> >>>>+					struct led_classdev_flash *ldev)
> >>>>+{
> >>>>+	struct max77693_sub_led *sub_led = container_of(ldev,
> >>>>+						struct max77693_sub_led,
> >>>>+						ldev);
> >>>>+	return container_of(sub_led, struct max77693_led, sub_leds[0]);
> >>>
> >>>You could have a common macro to find the flash controller struct if you add
> >>>the LED number to struct max77693_sub_led.
> >>>
> >>>>+}
> >>>>+
> >>>>+static inline struct max77693_led *ldev2_to_led(
> >>>>+					struct led_classdev_flash *ldev)
> >>>>+{
> >>>>+	struct max77693_sub_led *sub_led = container_of(ldev,
> >>>>+						struct max77693_sub_led,
> >>>>+						ldev);
> >>>>+	return container_of(sub_led, struct max77693_led, sub_leds[1]);
> >>>>+}
> >>>>+
> >>>>+static u8 max77693_led_vsys_to_reg(u32 mv)
> >>>>+{
> >>>>+	return ((mv - MAX_FLASH1_VSYS_MIN) / MAX_FLASH1_VSYS_STEP) << 2;
> >>>>+}
> >>>>+
> >>>>+static u8 max77693_led_vout_to_reg(u32 mv)
> >>>>+{
> >>>>+	return (mv - FLASH_VOUT_MIN) / FLASH_VOUT_STEP + FLASH_VOUT_RMIN;
> >>>>+}
> >>>>+
> >>>>+/* split composite current @i into two @iout according to @imax weights */
> >>>
> >>>What do you intend to do in the oint iout mode? A single LED connected to
> >>>iout pins which are soldered together?
> >>
> >>Exactly that what is written in the comment - split the current into
> >>both outputs.
> >
> >I think we discussed this on #v4l --- was it so that both outputs, if
> >they're connected, should have the same current if there's a single LED
> >connected to them?
> 
> Precisely: the current levels will differ between the outputs by
> no more than one level, as for odd levels it will be impossible
> to split the current to two even components.

True. If that's allowed from HW point of view, sure.

> >>>>+static int max77693_led_parse_dt(struct max77693_led *led,
> >>>>+				struct device_node *node)
> >>>>+{
> >>>>+	struct max77693_led_platform_data *p = led->pdata;
> >>>>+	struct device *dev = &led->pdev->dev;
> >>>>+	struct device_node *child_node;
> >>>>+	u32 fled_id;
> >>>>+	int ret;
> >>>>+
> >>>>+	of_property_read_u32_array(node, "maxim,fleds", p->fleds, 2);
> >>>>+	of_property_read_u32_array(node, "maxim,trigger", p->trigger, 2);
> >>>>+	of_property_read_u32_array(node, "maxim,trigger-type", p->trigger_type,
> >>>>+									2);
> >>>>+	of_property_read_u32(node, "maxim,boost-mode", &p->boost_mode);
> >>>>+	of_property_read_u32(node, "maxim,boost-vout", &p->boost_vout);
> >>>>+	of_property_read_u32(node, "maxim,vsys-min", &p->low_vsys);
> >>>>+
> >>>>+	for_each_available_child_of_node(node, child_node) {
> >>>>+		ret = of_property_read_u32(child_node, "maxim,fled_id",
> >>>>+						&fled_id);
> >>>>+		if (ret < 0) {
> >>>>+			dev_err(dev, "Error reading \"fled_id\" DT property\n");
> >>>>+			return ret;
> >>>>+		}
> >>>>+
> >>>>+		fled_id = clamp_val(fled_id, 1, 2);
> >>>
> >>>I think you should check fled_id is really correct, and not clamp it.
> >>
> >>Right.
> >>
> >>>>+		--fled_id;
> >>>>+
> >>>>+		p->sub_nodes[fled_id] = child_node;
> >>>
> >>>p->sub_nodes is not accessed anywhere else. Do you plan to use it for
> >>>something?
> >>
> >>It is passed to v4l2_flash_init. In this patch set I add the V4L2
> >>support in the separate patch. Probably this should be move there.
> >
> >Ok. I'm ok to keep it here as well, up to you.
> >
> 
> As I explained on #v4l it won't be needed because it turned out that
> the sub-node pointer can be stored in the dev member of
> the led_classdev structure.

Ack.

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

  reply	other threads:[~2014-12-11 15:48 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-03 16:06 [PATCH/RFC v9 00/19] LED / flash API integration Jacek Anaszewski
2014-12-03 16:06 ` [PATCH/RFC v9 01/19] leds: Add LED Flash class extension to the LED subsystem Jacek Anaszewski
2014-12-03 16:50   ` Sakari Ailus
2014-12-04  9:29     ` Jacek Anaszewski
2014-12-09 12:36       ` Sakari Ailus
2014-12-09 12:56         ` Jacek Anaszewski
2014-12-09 14:12           ` Sakari Ailus
2014-12-03 16:06 ` [PATCH/RFC v9 02/19] Documentation: leds: Add description of LED Flash class extension Jacek Anaszewski
2014-12-03 17:08   ` Sakari Ailus
2014-12-04  9:42     ` Jacek Anaszewski
2014-12-09 12:38       ` Sakari Ailus
2014-12-09 13:14         ` Jacek Anaszewski
2014-12-03 16:06 ` [PATCH/RFC v9 03/19] mfd: max77693: Modify flash cell name identifiers Jacek Anaszewski
2014-12-09  8:52   ` Lee Jones
2014-12-09  9:18     ` Jacek Anaszewski
2014-12-09 10:02       ` Lee Jones
2014-12-03 16:06 ` [PATCH/RFC v9 04/19] mfd: max77693: adjust max77693_led_platform_data Jacek Anaszewski
2014-12-09  8:50   ` Lee Jones
2014-12-09  9:09     ` Jacek Anaszewski
2014-12-09 10:04       ` Lee Jones
2014-12-09 10:25         ` Jacek Anaszewski
2014-12-09 13:50           ` Lee Jones
2014-12-09 14:02             ` Jacek Anaszewski
2014-12-09 14:41               ` Lee Jones
2014-12-09 15:08                 ` Sylwester Nawrocki
2014-12-10 12:38                 ` Jacek Anaszewski
2014-12-03 16:06 ` [PATCH/RFC v9 05/19] leds: Add support for max77693 mfd flash cell Jacek Anaszewski
2014-12-04  9:39   ` Sakari Ailus
2014-12-04 11:06     ` Jacek Anaszewski
2014-12-09 13:11       ` Sakari Ailus
2014-12-11 13:53         ` Jacek Anaszewski
2014-12-11 15:48           ` Sakari Ailus [this message]
2014-12-03 16:06 ` [PATCH/RFC v9 06/19] DT: Add documentation for the mfd Maxim max77693 Jacek Anaszewski
2014-12-04 10:07   ` Sakari Ailus
2014-12-04 11:40     ` Jacek Anaszewski
2014-12-04 16:12       ` Pavel Machek
2014-12-08 10:29         ` Jacek Anaszewski
2014-12-10 12:20         ` Sylwester Nawrocki
2014-12-10 12:41           ` Jacek Anaszewski
2014-12-09 14:09       ` Sakari Ailus
2014-12-09 14:13         ` Jacek Anaszewski
2014-12-10 10:02       ` Jacek Anaszewski
2014-12-10 10:50         ` Sakari Ailus
2014-12-10 10:59         ` Sylwester Nawrocki
2014-12-03 16:06 ` [PATCH/RFC v9 07/19] dt-binding: mfd: max77693: Add DT binding related macros Jacek Anaszewski
2014-12-30 22:15   ` Sakari Ailus
2014-12-03 16:06 ` [PATCH/RFC v9 08/19] leds: Add driver for AAT1290 current regulator Jacek Anaszewski
2014-12-11 14:16   ` Sakari Ailus
2014-12-11 15:34     ` Jacek Anaszewski
2014-12-11 15:52       ` Sakari Ailus
2014-12-03 16:06 ` [PATCH/RFC v9 09/19] of: Add Skyworks Solutions, Inc. vendor prefix Jacek Anaszewski
2014-12-03 16:06 ` [PATCH/RFC v9 10/19] DT: Add documentation for the Skyworks AAT1290 Jacek Anaszewski
2014-12-03 16:06 ` [PATCH/RFC v9 11/19] v4l2-async: change custom.match callback argument type Jacek Anaszewski
2014-12-03 16:06 ` [PATCH/RFC v9 12/19] v4l2-async: add V4L2_ASYNC_MATCH_CUSTOM_OF matching type Jacek Anaszewski
2014-12-03 16:06 ` [PATCH/RFC v9 13/19] v4l2-ctrls: Add V4L2_CID_FLASH_SYNC_STROBE control Jacek Anaszewski
2014-12-03 16:06 ` [PATCH/RFC v9 14/19] media: Add registration helpers for V4L2 flash sub-devices Jacek Anaszewski
2014-12-03 16:06 ` [PATCH/RFC v9 15/19] Documentation: leds: Add description of v4l2-flash sub-device Jacek Anaszewski
2014-12-03 16:06 ` [PATCH/RFC v9 16/19] exynos4-is: Add support for v4l2-flash subdevs Jacek Anaszewski
2014-12-03 16:06 ` [PATCH/RFC v9 17/19] DT: Add documentation for exynos4-is 'flashes' property Jacek Anaszewski
2014-12-03 16:06 ` [PATCH/RFC v9 18/19] leds: max77693: add support for V4L2 Flash sub-device Jacek Anaszewski
2014-12-03 16:06 ` [PATCH/RFC v9 19/19] leds: aat1290: " Jacek Anaszewski
2014-12-10 13:48   ` Sakari Ailus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141211154803.GT15559@valkosipuli.retiisi.org.uk \
    --to=sakari.ailus@iki.fi \
    --cc=a.hajda@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=cooloney@gmail.com \
    --cc=cw00.choi@samsung.com \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=j.anaszewski@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pavel@ucw.cz \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=rpurdie@rpsys.net \
    --cc=s.nawrocki@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®