linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Pengyu Luo <mitltlatltl@gmail.com>,
	Jianhua Lu <lujianhua000@gmail.com>, Lee Jones <lee@kernel.org>,
	Daniel Thompson <danielt@kernel.org>,
	Jingoo Han <jingoohan1@gmail.com>,
	Pavel Machek <pavel@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>, Helge Deller <deller@gmx.de>
Cc: dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-fbdev@vger.kernel.org
Subject: Re: [PATCH 2/4] backlight: ktz8866: add slave handler
Date: Mon, 7 Apr 2025 12:00:26 +0200	[thread overview]
Message-ID: <eb23737f-5b6c-47fd-8b39-637e059bd5f1@kernel.org> (raw)
In-Reply-To: <20250407095119.588920-3-mitltlatltl@gmail.com>

On 07/04/2025 11:51, Pengyu Luo wrote:
> Kinetic ktz8866, found in many android devices, nowadays, some oem use
> dual ktz8866 to support a larger panel and  higher brightness, original
> driver would only handle half backlight region on these devices,
> registering it twice is unreasonable, so adding the slave handler to
> support it.
> 
> Note that, none of the devices supported by upstream require this, the
> devices using this is porting.
> 
> Signed-off-by: Pengyu Luo <mitltlatltl@gmail.com>
> ---
>  drivers/video/backlight/ktz8866.c | 68 +++++++++++++++++++++++++++----
>  1 file changed, 59 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/video/backlight/ktz8866.c b/drivers/video/backlight/ktz8866.c
> index 351c2b4d6..017ad80dd 100644
> --- a/drivers/video/backlight/ktz8866.c
> +++ b/drivers/video/backlight/ktz8866.c
> @@ -3,6 +3,9 @@
>   * Backlight driver for the Kinetic KTZ8866
>   *
>   * Copyright (C) 2022, 2023 Jianhua Lu <lujianhua000@gmail.com>
> + *
> + * Apr 2025 - Pengyu Luo <mitltlatltl@gmail.com>
> + *	Added handling for dual KTZ8866(master and slave)
>   */
>  
>  #include <linux/backlight.h>
> @@ -43,11 +46,17 @@
>  #define LCD_BIAS_EN 0x9F
>  #define PWM_HYST 0x5
>  
> +struct ktz8866_slave {
> +	struct i2c_client *client;
> +	struct regmap *regmap;
> +};
> +
>  struct ktz8866 {
>  	struct i2c_client *client;
>  	struct regmap *regmap;
> -	bool led_on;
>  	struct gpio_desc *enable_gpio;
> +	struct ktz8866_slave *slave;
> +	bool led_on;
>  };
>  
>  static const struct regmap_config ktz8866_regmap_config = {
> @@ -56,16 +65,22 @@ static const struct regmap_config ktz8866_regmap_config = {
>  	.max_register = REG_MAX,
>  };
>  
> -static int ktz8866_write(struct ktz8866 *ktz, unsigned int reg,
> -			 unsigned int val)
> +static void ktz8866_write(struct ktz8866 *ktz, unsigned int reg,
> +			  unsigned int val)
>  {
> -	return regmap_write(ktz->regmap, reg, val);
> +	regmap_write(ktz->regmap, reg, val);
> +
> +	if (ktz->slave)
> +		regmap_write(ktz->slave->regmap, reg, val);
>  }
>  
> -static int ktz8866_update_bits(struct ktz8866 *ktz, unsigned int reg,
> -			       unsigned int mask, unsigned int val)
> +static void ktz8866_update_bits(struct ktz8866 *ktz, unsigned int reg,
> +				unsigned int mask, unsigned int val)
>  {
> -	return regmap_update_bits(ktz->regmap, reg, mask, val);
> +	regmap_update_bits(ktz->regmap, reg, mask, val);
> +
> +	if (ktz->slave)
> +		regmap_update_bits(ktz->slave->regmap, reg, mask, val);
>  }
>  
>  static int ktz8866_backlight_update_status(struct backlight_device *backlight_dev)
> @@ -124,10 +139,41 @@ static void ktz8866_init(struct ktz8866 *ktz)
>  		ktz8866_write(ktz, LCD_BIAS_CFG1, LCD_BIAS_EN);
>  }
>  
> +static int ktz8866_slave_register(struct ktz8866 *ktz)
> +{
> +	struct device *dev = &ktz->client->dev;
> +	struct ktz8866_slave *slave;
> +	struct i2c_client *client;
> +	struct device_node *np;
> +
> +	np = of_find_compatible_node(NULL, NULL, "kinetic,ktz8866-slave");
> +	if (!np)
> +		return 0;
> +
> +	client = of_find_i2c_device_by_node(np);


I wrote on IRC - phandle to express the relationship between hardware -
and I do not see it implemented.

If you have devices depending on each other, you need to express it -
for links, for resource dependencies etc. phandle is for that usually.
Or OF graph. Or parent-child relationship.

You did not provide any description of the hardware in the binding, so I
really do not have any idea what is this setup thus how to represent it.
Use hardware terms, diagrams etc to explain the hardware in the bindings
commit. What are the addresses? Are there any shared resources? What
buses are devices sitting on, etc.

Best regards,
Krzysztof

  reply	other threads:[~2025-04-07 10:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-07  9:51 [PATCH 0/4] backlight: ktz8866: improve it and support slave Pengyu Luo
2025-04-07  9:51 ` [PATCH 1/4] dt-bindings: backlight: kinetic,ktz8866: add ktz8866 slave compatible Pengyu Luo
2025-04-07  9:57   ` Krzysztof Kozlowski
2025-04-07  9:51 ` [PATCH 2/4] backlight: ktz8866: add slave handler Pengyu Luo
2025-04-07 10:00   ` Krzysztof Kozlowski [this message]
2025-04-18 18:14     ` Pengyu Luo
2025-04-18 18:17     ` Pengyu Luo
2025-04-07 16:27   ` Daniel Thompson
2025-04-18 18:19     ` Pengyu Luo
2025-04-07  9:51 ` [PATCH 3/4] backlight: ktz8866: improve current sinks setting Pengyu Luo
2025-04-07 16:13   ` Daniel Thompson
2025-04-08  3:45   ` kernel test robot
2025-04-08  3:55   ` kernel test robot
2025-04-07  9:51 ` [PATCH 4/4] backlight: ktz8866: add definitions to make it more readable Pengyu Luo
2025-04-07 16:18   ` Daniel Thompson
2025-04-08  5:19   ` kernel test robot

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=eb23737f-5b6c-47fd-8b39-637e059bd5f1@kernel.org \
    --to=krzk@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=danielt@kernel.org \
    --cc=deller@gmx.de \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jingoohan1@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=lujianhua000@gmail.com \
    --cc=mitltlatltl@gmail.com \
    --cc=pavel@kernel.org \
    --cc=robh@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).