public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
To: Chanwoo Choi <cw00.choi@samsung.com>
Cc: sbkim73@samsung.com, sameo@linux.intel.com, lee.jones@linaro.org,
	broonie@kernel.org, lgirdwood@gmail.com,
	linux-kernel@vger.kernel.org, myungjoo.ham@samsung.com,
	kyungmin.park@samsung.com, jonghwa3.lee@samsung.com
Subject: Re: [PATCHv2 2/3] regulator: s2mps11: Add support S2MPU02 regulator device
Date: Fri, 30 May 2014 10:23:25 +0200	[thread overview]
Message-ID: <1401438205.9323.4.camel@AMDC1943> (raw)
In-Reply-To: <1401409510-28238-3-git-send-email-cw00.choi@samsung.com>

On pią, 2014-05-30 at 09:25 +0900, Chanwoo Choi wrote:
> This patch add S2MPU02 regulator device to existing S2MPS11 device driver
> because of little difference between S2MPS1x and S2MPU02. The S2MPU02
> regulator device includes LDO[1-28] and BUCK[1-7].
> 
> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
> [Add missing linear_min_sel of S2MPU02 LDO regulators by Jonghwa Lee]
> Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
> ---
>  drivers/mfd/sec-core.c              |  26 +++
>  drivers/regulator/s2mps11.c         | 319 +++++++++++++++++++++++++++++++++---
>  include/linux/mfd/samsung/s2mpu02.h | 200 ++++++++++++++++++++++
>  3 files changed, 525 insertions(+), 20 deletions(-)
>  create mode 100644 include/linux/mfd/samsung/s2mpu02.h
> 

(...)

> diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c
> index 02e2fb2..f7e5dab3d 100644
> --- a/drivers/regulator/s2mps11.c
> +++ b/drivers/regulator/s2mps11.c
> @@ -31,6 +31,7 @@
>  #include <linux/mfd/samsung/core.h>
>  #include <linux/mfd/samsung/s2mps11.h>
>  #include <linux/mfd/samsung/s2mps14.h>
> +#include <linux/mfd/samsung/s2mpu02.h>
>  
>  struct s2mps11_info {
>  	unsigned int rdev_num;
> @@ -40,11 +41,15 @@ struct s2mps11_info {
>  	int ramp_delay16;
>  	int ramp_delay7810;
>  	int ramp_delay9;
> +
> +	enum sec_device_type dev_type;
> +
>  	/*
> -	 * One bit for each S2MPS14 regulator whether the suspend mode
> +	 * One bit for each S2MPS14/S2MPU02 regulator whether the suspend mode
>  	 * was enabled.
>  	 */
> -	unsigned int s2mps14_suspend_state:30;
> +	unsigned long long s2mps14_suspend_state:35;
> +
>  	/* Array of size rdev_num with GPIO-s for external sleep control */
>  	int *ext_control_gpio;
>  };
> @@ -415,12 +420,24 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev)
>  	struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev);
>  	unsigned int val;
>  
> -	if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev)))
> -		val = S2MPS14_ENABLE_SUSPEND;
> -	else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)]))
> -		val = S2MPS14_ENABLE_EXT_CONTROL;
> -	else
> -		val = rdev->desc->enable_mask;
> +	switch (s2mps11->dev_type) {
> +	case S2MPS14X:
> +		if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev)))
> +			val = S2MPS14_ENABLE_SUSPEND;
> +		else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)]))
> +			val = S2MPS14_ENABLE_EXT_CONTROL;
> +		else
> +			val = rdev->desc->enable_mask;
> +		break;
> +	case S2MPU02:
> +		if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev)))
> +			val = S2MPU02_ENABLE_SUSPEND;
> +		else
> +			val = rdev->desc->enable_mask;
> +		break;
> +	default:
> +		return -EINVAL;
> +	};
>  
>  	return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
>  			rdev->desc->enable_mask, val);
> @@ -431,16 +448,42 @@ static int s2mps14_regulator_set_suspend_disable(struct regulator_dev *rdev)
>  	int ret;
>  	unsigned int val;
>  	struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev);
> +	int rdev_id = rdev_get_id(rdev);
>  
> -	/* LDO3 should be always on and does not support suspend mode */
> -	if (rdev_get_id(rdev) == S2MPS14_LDO3)
> -		return 0;
> +	/* Below LDO should be always on or does not support suspend mode. */
> +	switch (s2mps11->dev_type) {
> +	case S2MPS14X:
> +		switch (rdev_id) {
> +		case S2MPS14_LDO3:
> +			return 0;
> +		};
> +	case S2MPU02:
> +		switch (rdev_id) {
> +		case S2MPU02_LDO13:
> +		case S2MPU02_LDO14:
> +		case S2MPU02_LDO15:
> +		case S2MPU02_LDO16:
> +		case S2MPU02_LDO17:
> +		case S2MPU02_BUCK7:
> +			return 0;
> +		};
> +	default:
> +		return -EINVAL;
> +	};
>  
>  	ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val);
>  	if (ret < 0)
>  		return ret;
>  
> -	s2mps11->s2mps14_suspend_state |= (1 << rdev_get_id(rdev));
> +	switch (s2mps11->dev_type) {
> +	case S2MPS14X:
> +	case S2MPU02:
> +		s2mps11->s2mps14_suspend_state |= (1 << rdev_get_id(rdev));
> +		break;
> +	default:
> +		return -EINVAL;
> +	};
> +

I think this change is not needed. You are actually returning EINVAL on
wrong devices in switch above so:
	s2mps11->s2mps14_suspend_state |= (1 << rdev_get_id(rdev));
would be safe and sufficient.

Anyway:
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>

Best regards,
Krzysztof


  reply	other threads:[~2014-05-30  8:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-30  0:25 [PATCHv2 0/3] regulator: s2mps11: Add support S2MPU02 PMIC device Chanwoo Choi
2014-05-30  0:25 ` [PATCHv2 1/3] mfd: sec-core: Add support for S2MPU02 device Chanwoo Choi
2014-05-30  0:25 ` [PATCHv2 2/3] regulator: s2mps11: Add support S2MPU02 regulator device Chanwoo Choi
2014-05-30  8:23   ` Krzysztof Kozlowski [this message]
2014-05-30 10:33     ` Chanwoo Choi
2014-06-01 10:46   ` Mark Brown
2014-05-30  0:25 ` [PATCHv2 3/3] dt-bindings: mfd: s2mps11: Add support S2MPU02 PMIC Chanwoo Choi
2014-05-30 10:32 ` [PATCHv2 0/3] regulator: s2mps11: Add support S2MPU02 PMIC device Chanwoo Choi

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=1401438205.9323.4.camel@AMDC1943 \
    --to=k.kozlowski@samsung.com \
    --cc=broonie@kernel.org \
    --cc=cw00.choi@samsung.com \
    --cc=jonghwa3.lee@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=sameo@linux.intel.com \
    --cc=sbkim73@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