linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: Dan Murphy <dmurphy@ti.com>,
	pavel@ucw.cz, tony@atomide.com, sre@kernel.org,
	nekit1000@gmail.com, mpartap@gmx.net, merlijn@wizzup.org
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/5] leds: lm3532: Fix brightness control for i2c mode
Date: Sun, 25 Aug 2019 12:50:53 +0200	[thread overview]
Message-ID: <8497503d-6b6a-b557-2247-33b186218beb@gmail.com> (raw)
In-Reply-To: <20190820195307.27590-1-dmurphy@ti.com>

Hi Dan,

Thank you for the update.

On 8/20/19 9:53 PM, Dan Murphy wrote:
> Fix the brightness control for I2C mode.  Instead of
> changing the full scale current register update the ALS target
> register for the appropriate banks.
> 
> In addition clean up some code errors and random misspellings found
> during coding.
> 
> Tested on Droid4 as well as LM3532 EVM connected to a BeagleBoneBlack
> 
> Fixes: e37a7f8d77e1 ("leds: lm3532: Introduce the lm3532 LED driver")
> Reported-by: Pavel Machek <pavel@ucw.cz>
> Signed-off-by: Dan Murphy <dmurphy@ti.com>
> ---
> 
> v3 - Removed register define updates - https://lore.kernel.org/patchwork/patch/1114542/
> 
>  drivers/leds/leds-lm3532.c | 44 ++++++++++++++++++++++++++------------
>  1 file changed, 30 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c
> index 646100724971..8132d05f7add 100644
> --- a/drivers/leds/leds-lm3532.c
> +++ b/drivers/leds/leds-lm3532.c
> @@ -38,6 +38,9 @@
>  #define LM3532_REG_ZN_2_LO	0x65
>  #define LM3532_REG_ZN_3_HI	0x66
>  #define LM3532_REG_ZN_3_LO	0x67
> +#define LM3532_REG_ZONE_TRGT_A	0x70
> +#define LM3532_REG_ZONE_TRGT_B	0x75
> +#define LM3532_REG_ZONE_TRGT_C	0x7a
>  #define LM3532_REG_MAX		0x7e
>  
>  /* Contorl Enable */
> @@ -116,6 +119,7 @@ struct lm3532_als_data {
>   * @priv - Pointer the device data structure
>   * @control_bank - Control bank the LED is associated to
>   * @mode - Mode of the LED string
> + * @ctrl_brt_pointer - Zone target register that controls the sink
>   * @num_leds - Number of LED strings are supported in this array
>   * @led_strings - The LED strings supported in this array
>   * @label - LED label
> @@ -126,6 +130,7 @@ struct lm3532_led {
>  
>  	int control_bank;
>  	int mode;
> +	int ctrl_brt_pointer;
>  	int num_leds;
>  	u32 led_strings[LM3532_MAX_CONTROL_BANKS];
>  	char label[LED_MAX_NAME_SIZE];
> @@ -339,8 +344,8 @@ static int lm3532_brightness_set(struct led_classdev *led_cdev,
>  	if (ret)
>  		goto unlock;
>  
> -	brightness_reg = LM3532_REG_CTRL_A_BRT + led->control_bank * 2;
> -	brt_val = brt_val / LM3532_BRT_VAL_ADJUST;
> +	brightness_reg = LM3532_REG_ZONE_TRGT_A + led->control_bank * 5 +
> +			 (led->ctrl_brt_pointer >> 2);
>  
>  	ret = regmap_write(led->priv->regmap, brightness_reg, brt_val);
>  
> @@ -356,8 +361,30 @@ static int lm3532_init_registers(struct lm3532_led *led)
>  	unsigned int output_cfg_val = 0;
>  	unsigned int output_cfg_shift = 0;
>  	unsigned int output_cfg_mask = 0;
> +	unsigned int brightness_config_reg;
> +	unsigned int brightness_config_val;
>  	int ret, i;
>  
> +	if (drvdata->enable_gpio)
> +		gpiod_direction_output(drvdata->enable_gpio, 1);
> +
> +	brightness_config_reg = LM3532_REG_ZONE_CFG_A + led->control_bank * 2;
> +	/*
> +	 * This could be hard coded to the default value but the control
> +	 * brightness register may have changed during boot.
> +	 */
> +	ret = regmap_read(drvdata->regmap, brightness_config_reg,
> +			  &led->ctrl_brt_pointer);
> +	if (ret)
> +		return ret;
> +
> +	led->ctrl_brt_pointer &= LM3532_ZONE_MASK;
> +	brightness_config_val = led->ctrl_brt_pointer | led->mode;
> +	ret = regmap_write(drvdata->regmap, brightness_config_reg,
> +			   brightness_config_val);
> +	if (ret)
> +		return ret;
> +
>  	for (i = 0; i < led->num_leds; i++) {
>  		output_cfg_shift = led->led_strings[i] * 2;
>  		output_cfg_val |= (led->control_bank << output_cfg_shift);
> @@ -382,7 +409,6 @@ static int lm3532_als_configure(struct lm3532_data *priv,
>  	struct lm3532_als_data *als = priv->als_data;
>  	u32 als_vmin, als_vmax, als_vstep;
>  	int zone_reg = LM3532_REG_ZN_0_HI;
> -	int brightnes_config_reg;
>  	int ret;
>  	int i;
>  
> @@ -411,14 +437,7 @@ static int lm3532_als_configure(struct lm3532_data *priv,
>  	als->config = (als->als_avrg_time | (LM3532_ENABLE_ALS) |
>  		(als->als_input_mode << LM3532_ALS_SEL_SHIFT));
>  
> -	ret = regmap_write(priv->regmap, LM3532_ALS_CONFIG, als->config);
> -	if (ret)
> -		return ret;
> -
> -	brightnes_config_reg = LM3532_REG_ZONE_CFG_A + led->control_bank * 2;
> -
> -	return regmap_update_bits(priv->regmap, brightnes_config_reg,
> -				  LM3532_I2C_CTRL, LM3532_ALS_CTRL);
> +	return regmap_write(priv->regmap, LM3532_ALS_CONFIG, als->config);
>  }
>  
>  static int lm3532_parse_als(struct lm3532_data *priv)
> @@ -634,9 +653,6 @@ static int lm3532_probe(struct i2c_client *client,
>  		return ret;
>  	}
>  
> -	if (drvdata->enable_gpio)
> -		gpiod_direction_output(drvdata->enable_gpio, 1);
> -
>  	return ret;
>  }
>  
> 

Patch set applied.

-- 
Best regards,
Jacek Anaszewski

  parent reply	other threads:[~2019-08-25 10:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-20 19:53 [PATCH v3 1/5] leds: lm3532: Fix brightness control for i2c mode Dan Murphy
2019-08-20 19:53 ` [PATCH v3 2/5] leds: lm3532: Change the define for the fs current register Dan Murphy
2019-08-25  9:32   ` Pavel Machek
2019-08-27 21:33     ` Jacek Anaszewski
2019-08-27 21:37       ` Jacek Anaszewski
2019-08-20 19:53 ` [PATCH v3 3/5] leds: lm3532: Fixes for the driver for stability Dan Murphy
2019-08-20 19:53 ` [PATCH v3 4/5] dt: lm3532: Add property for full scale current Dan Murphy
2019-08-20 19:53 ` [PATCH v3 5/5] leds: lm3532: Add full scale current configuration Dan Murphy
2019-08-25 10:50 ` Jacek Anaszewski [this message]
2019-08-26 21:58 ` [PATCH v3 1/5] leds: lm3532: Fix brightness control for i2c mode Tony Lindgren
2019-08-26 22:14   ` Pavel Machek
2019-08-26 22:44     ` Tony Lindgren
2019-08-27 12:03       ` Dan Murphy
2019-08-27 12:18       ` Pavel Machek
2019-08-27 12:44         ` Dan Murphy
     [not found]           ` <9939e253-0c9e-5ef7-e160-c1e5fe99c453@ti.com>
2019-08-27 16:04             ` Tony Lindgren
2019-08-27 16:19               ` Dan Murphy
2019-08-27 16:45                 ` Tony Lindgren
2019-08-27 21:14           ` Jacek Anaszewski
2019-08-28 15:28             ` Dan Murphy
2019-08-28 20:37               ` Jacek Anaszewski

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=8497503d-6b6a-b557-2247-33b186218beb@gmail.com \
    --to=jacek.anaszewski@gmail.com \
    --cc=dmurphy@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=merlijn@wizzup.org \
    --cc=mpartap@gmx.net \
    --cc=nekit1000@gmail.com \
    --cc=pavel@ucw.cz \
    --cc=sre@kernel.org \
    --cc=tony@atomide.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;
as well as URLs for NNTP newsgroup(s).