All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: "André Apitzsch" <git@apitzsch.eu>
Cc: Pavel Machek <pavel@ucw.cz>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Trilok Soni <quic_tsoni@quicinc.com>, Kees Cook <kees@kernel.org>,
	linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
	linux-arm-msm@vger.kernel.org,
	~postmarketos/upstreaming@lists.sr.ht,
	phone-devel@vger.kernel.org
Subject: Re: [PATCH v4 2/3] leds: sy7802: Add support for Silergy SY7802 flash LED controller
Date: Mon, 24 Jun 2024 12:14:46 +0100	[thread overview]
Message-ID: <20240624111446.GT1318296@google.com> (raw)
In-Reply-To: <86f8110e8edc24d0df035b77a1aa68422e48bde1.camel@apitzsch.eu>

On Sat, 22 Jun 2024, André Apitzsch wrote:

> Hello Lee,
> 
> Am Freitag, dem 21.06.2024 um 11:26 +0100 schrieb Lee Jones:
> > On Sun, 16 Jun 2024, André Apitzsch via B4 Relay wrote:
> > 
> > > From: André Apitzsch <git@apitzsch.eu>
> > > 
> > > The SY7802 is a current-regulated charge pump which can regulate
> > > two
> > > current levels for Flash and Torch modes.
> > > 
> > > It is a high-current synchronous boost converter with 2-channel
> > > high
> > > side current sources. Each channel is able to deliver 900mA
> > > current.
> > > 
> > > Signed-off-by: André Apitzsch <git@apitzsch.eu>
> > > ---
> > >  drivers/leds/flash/Kconfig       |  11 +
> > >  drivers/leds/flash/Makefile      |   1 +
> > >  drivers/leds/flash/leds-sy7802.c | 542
> > > +++++++++++++++++++++++++++++++++++++++
> > >  3 files changed, 554 insertions(+)
> > 
> > Generally very nice.
> > 
> > Just a couple of teensy nits to fix then add my and resubmit please.
> > 
> > Acked-by: Lee Jones <lee@kernel.org>
> > 
> > > [...]
> > > diff --git a/drivers/leds/flash/leds-sy7802.c
> > > b/drivers/leds/flash/leds-sy7802.c
> > > new file mode 100644
> > > index 000000000000..c4bea55a62d0
> > > --- /dev/null
> > > +++ b/drivers/leds/flash/leds-sy7802.c
> > > @@ -0,0 +1,542 @@
> > > +// SPDX-License-Identifier: GPL-2.0-or-later
> > > +/*
> > > + * Silergy SY7802 flash LED driver with I2C interface
> > 
> > "an I2C interface"
> > 
> > Or
> > 
> > "I2C interfaces"
> > 
> > > + * Copyright 2024 André Apitzsch <git@apitzsch.eu>
> > > + */
> > > +
> > > +#include <linux/gpio/consumer.h>
> > > +#include <linux/i2c.h>
> > > +#include <linux/kernel.h>
> > > +#include <linux/led-class-flash.h>
> > > +#include <linux/module.h>
> > > +#include <linux/mutex.h>
> > > +#include <linux/regmap.h>
> > > +#include <linux/regulator/consumer.h>
> > > +
> > > +#define SY7802_MAX_LEDS 2
> > > +#define SY7802_LED_JOINT 2
> > > +
> > > +#define SY7802_REG_ENABLE		0x10
> > > +#define SY7802_REG_TORCH_BRIGHTNESS	0xa0
> > > +#define SY7802_REG_FLASH_BRIGHTNESS	0xb0
> > > +#define SY7802_REG_FLASH_DURATION	0xc0
> > > +#define SY7802_REG_FLAGS		0xd0
> > > +#define SY7802_REG_CONFIG_1		0xe0
> > > +#define SY7802_REG_CONFIG_2		0xf0
> > > +#define SY7802_REG_VIN_MONITOR		0x80
> > > +#define SY7802_REG_LAST_FLASH		0x81
> > > +#define SY7802_REG_VLED_MONITOR		0x30
> > > +#define SY7802_REG_ADC_DELAY		0x31
> > > +#define SY7802_REG_DEV_ID		0xff
> > > +
> > > +#define SY7802_MODE_OFF		0
> > > +#define SY7802_MODE_TORCH	2
> > > +#define SY7802_MODE_FLASH	3
> > > +#define SY7802_MODE_MASK	GENMASK(1, 0)
> > > +
> > > +#define SY7802_LEDS_SHIFT	3
> > > +#define SY7802_LEDS_MASK(_id)	(BIT(_id) << SY7802_LEDS_SHIFT)
> > > +#define SY7802_LEDS_MASK_ALL	(SY7802_LEDS_MASK(0) |
> > > SY7802_LEDS_MASK(1))
> > > +
> > > +#define SY7802_TORCH_CURRENT_SHIFT	3
> > > +#define SY7802_TORCH_CURRENT_MASK(_id) \
> > > +	(GENMASK(2, 0) << (SY7802_TORCH_CURRENT_SHIFT * (_id)))
> > > +#define SY7802_TORCH_CURRENT_MASK_ALL \
> > > +	(SY7802_TORCH_CURRENT_MASK(0) |
> > > SY7802_TORCH_CURRENT_MASK(1))
> > > +
> > > +#define SY7802_FLASH_CURRENT_SHIFT	4
> > > +#define SY7802_FLASH_CURRENT_MASK(_id) \
> > > +	(GENMASK(3, 0) << (SY7802_FLASH_CURRENT_SHIFT * (_id)))
> > > +#define SY7802_FLASH_CURRENT_MASK_ALL \
> > > +	(SY7802_FLASH_CURRENT_MASK(0) |
> > > SY7802_FLASH_CURRENT_MASK(1))
> > > +
> > > +#define SY7802_TIMEOUT_DEFAULT_US	512000U
> > > +#define SY7802_TIMEOUT_MIN_US		32000U
> > > +#define SY7802_TIMEOUT_MAX_US		1024000U
> > > +#define SY7802_TIMEOUT_STEPSIZE_US	32000U
> > > +
> > > +#define SY7802_TORCH_BRIGHTNESS_MAX 8
> > > +
> > > +#define SY7802_FLASH_BRIGHTNESS_DEFAULT	14
> > > +#define SY7802_FLASH_BRIGHTNESS_MIN	0
> > > +#define SY7802_FLASH_BRIGHTNESS_MAX	15
> > > +#define SY7802_FLASH_BRIGHTNESS_STEP	1
> > > +
> > > +#define SY7802_FLAG_TIMEOUT			BIT(0)
> > > +#define SY7802_FLAG_THERMAL_SHUTDOWN		BIT(1)
> > > +#define SY7802_FLAG_LED_FAULT			BIT(2)
> > > +#define SY7802_FLAG_TX1_INTERRUPT		BIT(3)
> > > +#define SY7802_FLAG_TX2_INTERRUPT		BIT(4)
> > > +#define SY7802_FLAG_LED_THERMAL_FAULT		BIT(5)
> > > +#define SY7802_FLAG_FLASH_INPUT_VOLTAGE_LOW	BIT(6)
> > > +#define SY7802_FLAG_INPUT_VOLTAGE_LOW		BIT(7)
> > > +
> > > +#define SY7802_CHIP_ID	0x51
> > > +
> > > +static const struct reg_default sy7802_regmap_defs[] = {
> > > +	{ SY7802_REG_ENABLE, SY7802_LEDS_MASK_ALL },
> > > +	{ SY7802_REG_TORCH_BRIGHTNESS, 0x92 },
> > > +	{ SY7802_REG_FLASH_BRIGHTNESS,
> > > SY7802_FLASH_BRIGHTNESS_DEFAULT |
> > > +		SY7802_FLASH_BRIGHTNESS_DEFAULT <<
> > > SY7802_FLASH_CURRENT_SHIFT },
> > > +	{ SY7802_REG_FLASH_DURATION, 0x6f },
> > > +	{ SY7802_REG_FLAGS, 0x0 },
> > > +	{ SY7802_REG_CONFIG_1, 0x68 },
> > > +	{ SY7802_REG_CONFIG_2, 0xf0 },
> > 
> > Not your fault, but this interface is frustrating since we have no
> > idea
> > what these register values mean.  IMHO, they should be defined and
> > ORed
> > together in some human readable way.
> > 
> > I say that it's not your fault because I see that this is the most
> > common usage.
> > 
> 
> I don't know how to interpret some bits of the default values. I don't
> have the documentation and changing the bits and observing the behavior
> of the device also didn't help.

And this is the problem.

> Should I remove the entries from sy7802_regmap_defs, which have values
> that we don't fully understand?

No, as I say, it's not your fault.  Sadly this appears to be the norm.

-- 
Lee Jones [李琼斯]

  reply	other threads:[~2024-06-24 11:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-16 18:22 [PATCH v4 0/3] Add sy7802 flash led driver André Apitzsch
2024-06-16 18:22 ` André Apitzsch via B4 Relay
2024-06-16 18:22 ` [PATCH v4 1/3] dt-bindings: leds: Add Silergy SY7802 flash LED André Apitzsch
2024-06-16 18:22   ` André Apitzsch via B4 Relay
2024-06-16 18:22 ` [PATCH v4 2/3] leds: sy7802: Add support for Silergy SY7802 flash LED controller André Apitzsch
2024-06-16 18:22   ` André Apitzsch via B4 Relay
2024-06-16 18:55   ` Markus Elfring
2024-06-17  9:53     ` Pavel Machek
2024-06-17 10:18       ` [v4 " Markus Elfring
2024-06-17 10:59         ` Dmitry Baryshkov
2024-06-17 11:34           ` Markus Elfring
2024-06-21 10:26   ` [PATCH v4 " Lee Jones
2024-06-22 11:55     ` André Apitzsch
2024-06-24 11:14       ` Lee Jones [this message]
2024-06-16 18:22 ` [PATCH v4 3/3] arm64: dts: qcom: msm8939-longcheer-l9100: Add rear flash André Apitzsch
2024-06-16 18:22   ` André Apitzsch via B4 Relay

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=20240624111446.GT1318296@google.com \
    --to=lee@kernel.org \
    --cc=andersson@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=git@apitzsch.eu \
    --cc=gustavoars@kernel.org \
    --cc=kees@kernel.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=phone-devel@vger.kernel.org \
    --cc=quic_tsoni@quicinc.com \
    --cc=robh@kernel.org \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    /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 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.