All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mfd: rk808: RK818 uses DEV_OFF to power off supplies
@ 2016-10-17  9:03 Jianhong Chen
  2016-10-21  7:44 ` Wadim Egorov
  2016-10-26 13:53 ` Lee Jones
  0 siblings, 2 replies; 4+ messages in thread
From: Jianhong Chen @ 2016-10-17  9:03 UTC (permalink / raw)
  To: zhangqing, zyw, w.egorov
  Cc: lee.jones, linux-kernel, linux-rockchip, tony.xie, huangtao, xsf,
	Jianhong Chen

DEV_OFF and DEV_OFF_RST functions for RK808 are designed error that
only DEV_OFF_RST can power off supplies. RK818 has been fixed this
issue, so that DEV_OFF is used to power off supplies.

Signed-off-by: Jianhong Chen <chenjh@rock-chips.com>
---
 drivers/mfd/rk808.c       | 23 ++++++++++++++++++++++-
 include/linux/mfd/rk808.h |  1 +
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index 0f8acc5..2c9acdb 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -290,6 +290,24 @@ static void rk808_device_shutdown(void)
 		dev_err(&rk808_i2c_client->dev, "power off error!\n");
 }
 
+static void rk818_device_shutdown(void)
+{
+	int ret;
+	struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
+
+	if (!rk808) {
+		dev_warn(&rk808_i2c_client->dev,
+			 "have no rk818, so do nothing here\n");
+		return;
+	}
+
+	ret = regmap_update_bits(rk808->regmap,
+				 RK818_DEVCTRL_REG,
+				 DEV_OFF, DEV_OFF);
+	if (ret)
+		dev_err(&rk808_i2c_client->dev, "power off error!\n");
+}
+
 static const struct of_device_id rk808_of_match[] = {
 	{ .compatible = "rockchip,rk808" },
 	{ .compatible = "rockchip,rk818" },
@@ -304,6 +322,7 @@ static int rk808_probe(struct i2c_client *client,
 	struct rk808 *rk808;
 	const struct rk808_reg_data *pre_init_reg;
 	const struct mfd_cell *cells;
+	void (*pm_pwroff_fn)(void);
 	int nr_pre_init_regs;
 	int nr_cells;
 	int pm_off = 0;
@@ -331,6 +350,7 @@ static int rk808_probe(struct i2c_client *client,
 		nr_pre_init_regs = ARRAY_SIZE(rk808_pre_init_reg);
 		cells = rk808s;
 		nr_cells = ARRAY_SIZE(rk808s);
+		pm_pwroff_fn = rk808_device_shutdown;
 		break;
 	case RK818_ID:
 		rk808->regmap_cfg = &rk818_regmap_config;
@@ -339,6 +359,7 @@ static int rk808_probe(struct i2c_client *client,
 		nr_pre_init_regs = ARRAY_SIZE(rk818_pre_init_reg);
 		cells = rk818s;
 		nr_cells = ARRAY_SIZE(rk818s);
+		pm_pwroff_fn = rk818_device_shutdown;
 		break;
 	default:
 		dev_err(&client->dev, "Unsupported RK8XX ID %lu\n",
@@ -393,7 +414,7 @@ static int rk808_probe(struct i2c_client *client,
 				"rockchip,system-power-controller");
 	if (pm_off && !pm_power_off) {
 		rk808_i2c_client = client;
-		pm_power_off = rk808_device_shutdown;
+		pm_power_off = pm_pwroff_fn;
 	}
 
 	return 0;
diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 6d435a3..83701ef 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -290,6 +290,7 @@ enum rk818_reg {
 #define SWITCH2_EN	BIT(6)
 #define SWITCH1_EN	BIT(5)
 #define DEV_OFF_RST	BIT(3)
+#define DEV_OFF		BIT(0)
 
 #define VB_LO_ACT		BIT(4)
 #define VB_LO_SEL_3500MV	(7 << 0)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mfd: rk808: RK818 uses DEV_OFF to power off supplies
  2016-10-17  9:03 [PATCH] mfd: rk808: RK818 uses DEV_OFF to power off supplies Jianhong Chen
@ 2016-10-21  7:44 ` Wadim Egorov
  2016-10-21  9:15   ` chenjh
  2016-10-26 13:53 ` Lee Jones
  1 sibling, 1 reply; 4+ messages in thread
From: Wadim Egorov @ 2016-10-21  7:44 UTC (permalink / raw)
  To: Jianhong Chen, zhangqing, zyw
  Cc: lee.jones, linux-kernel, linux-rockchip, tony.xie, huangtao, xsf

Hi Jianhong,

with this patch a poweroff causes a restart on our board.
In our design a 5V USB voltage is supplied on the USB supply input pins.
After setting DEV_OFF bit, the RK818 restart automatically. The
ON_SOURCE_REG (Address AEH) is 0x40 after the automatic restart which
says that the RK818 was started by ON_PLUG_IN event.
Is there a possibility to configure the RK818 that it will not start
automatically in this case?

Regards,
Wadim

On 17.10.2016 11:03, Jianhong Chen wrote:
> DEV_OFF and DEV_OFF_RST functions for RK808 are designed error that
> only DEV_OFF_RST can power off supplies. RK818 has been fixed this
> issue, so that DEV_OFF is used to power off supplies.
>
> Signed-off-by: Jianhong Chen <chenjh@rock-chips.com>
> ---
>  drivers/mfd/rk808.c       | 23 ++++++++++++++++++++++-
>  include/linux/mfd/rk808.h |  1 +
>  2 files changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
> index 0f8acc5..2c9acdb 100644
> --- a/drivers/mfd/rk808.c
> +++ b/drivers/mfd/rk808.c
> @@ -290,6 +290,24 @@ static void rk808_device_shutdown(void)
>  		dev_err(&rk808_i2c_client->dev, "power off error!\n");
>  }
>  
> +static void rk818_device_shutdown(void)
> +{
> +	int ret;
> +	struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
> +
> +	if (!rk808) {
> +		dev_warn(&rk808_i2c_client->dev,
> +			 "have no rk818, so do nothing here\n");
> +		return;
> +	}
> +
> +	ret = regmap_update_bits(rk808->regmap,
> +				 RK818_DEVCTRL_REG,
> +				 DEV_OFF, DEV_OFF);
> +	if (ret)
> +		dev_err(&rk808_i2c_client->dev, "power off error!\n");
> +}
> +
>  static const struct of_device_id rk808_of_match[] = {
>  	{ .compatible = "rockchip,rk808" },
>  	{ .compatible = "rockchip,rk818" },
> @@ -304,6 +322,7 @@ static int rk808_probe(struct i2c_client *client,
>  	struct rk808 *rk808;
>  	const struct rk808_reg_data *pre_init_reg;
>  	const struct mfd_cell *cells;
> +	void (*pm_pwroff_fn)(void);
>  	int nr_pre_init_regs;
>  	int nr_cells;
>  	int pm_off = 0;
> @@ -331,6 +350,7 @@ static int rk808_probe(struct i2c_client *client,
>  		nr_pre_init_regs = ARRAY_SIZE(rk808_pre_init_reg);
>  		cells = rk808s;
>  		nr_cells = ARRAY_SIZE(rk808s);
> +		pm_pwroff_fn = rk808_device_shutdown;
>  		break;
>  	case RK818_ID:
>  		rk808->regmap_cfg = &rk818_regmap_config;
> @@ -339,6 +359,7 @@ static int rk808_probe(struct i2c_client *client,
>  		nr_pre_init_regs = ARRAY_SIZE(rk818_pre_init_reg);
>  		cells = rk818s;
>  		nr_cells = ARRAY_SIZE(rk818s);
> +		pm_pwroff_fn = rk818_device_shutdown;
>  		break;
>  	default:
>  		dev_err(&client->dev, "Unsupported RK8XX ID %lu\n",
> @@ -393,7 +414,7 @@ static int rk808_probe(struct i2c_client *client,
>  				"rockchip,system-power-controller");
>  	if (pm_off && !pm_power_off) {
>  		rk808_i2c_client = client;
> -		pm_power_off = rk808_device_shutdown;
> +		pm_power_off = pm_pwroff_fn;
>  	}
>  
>  	return 0;
> diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
> index 6d435a3..83701ef 100644
> --- a/include/linux/mfd/rk808.h
> +++ b/include/linux/mfd/rk808.h
> @@ -290,6 +290,7 @@ enum rk818_reg {
>  #define SWITCH2_EN	BIT(6)
>  #define SWITCH1_EN	BIT(5)
>  #define DEV_OFF_RST	BIT(3)
> +#define DEV_OFF		BIT(0)
>  
>  #define VB_LO_ACT		BIT(4)
>  #define VB_LO_SEL_3500MV	(7 << 0)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mfd: rk808: RK818 uses DEV_OFF to power off supplies
  2016-10-21  7:44 ` Wadim Egorov
@ 2016-10-21  9:15   ` chenjh
  0 siblings, 0 replies; 4+ messages in thread
From: chenjh @ 2016-10-21  9:15 UTC (permalink / raw)
  To: Wadim Egorov, zhangqing, zyw
  Cc: lee.jones, linux-kernel, linux-rockchip, tony.xie, huangtao, xsf

Hi Wadim:

     It's impossible not to restart automatically, this situation is 
normal for RK818.
     Because it is hardware designed that RK818 can't power off when a 
voltage is supplies on the USB supply input pins.



Best Regards

在 2016/10/21 15:44, Wadim Egorov 写道:
> Hi Jianhong,
>
> with this patch a poweroff causes a restart on our board.
> In our design a 5V USB voltage is supplied on the USB supply input pins.
> After setting DEV_OFF bit, the RK818 restart automatically. The
> ON_SOURCE_REG (Address AEH) is 0x40 after the automatic restart which
> says that the RK818 was started by ON_PLUG_IN event.
> Is there a possibility to configure the RK818 that it will not start
> automatically in this case?
>
> Regards,
> Wadim
>
> On 17.10.2016 11:03, Jianhong Chen wrote:
>> DEV_OFF and DEV_OFF_RST functions for RK808 are designed error that
>> only DEV_OFF_RST can power off supplies. RK818 has been fixed this
>> issue, so that DEV_OFF is used to power off supplies.
>>
>> Signed-off-by: Jianhong Chen <chenjh@rock-chips.com>
>> ---
>>   drivers/mfd/rk808.c       | 23 ++++++++++++++++++++++-
>>   include/linux/mfd/rk808.h |  1 +
>>   2 files changed, 23 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
>> index 0f8acc5..2c9acdb 100644
>> --- a/drivers/mfd/rk808.c
>> +++ b/drivers/mfd/rk808.c
>> @@ -290,6 +290,24 @@ static void rk808_device_shutdown(void)
>>   		dev_err(&rk808_i2c_client->dev, "power off error!\n");
>>   }
>>   
>> +static void rk818_device_shutdown(void)
>> +{
>> +	int ret;
>> +	struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
>> +
>> +	if (!rk808) {
>> +		dev_warn(&rk808_i2c_client->dev,
>> +			 "have no rk818, so do nothing here\n");
>> +		return;
>> +	}
>> +
>> +	ret = regmap_update_bits(rk808->regmap,
>> +				 RK818_DEVCTRL_REG,
>> +				 DEV_OFF, DEV_OFF);
>> +	if (ret)
>> +		dev_err(&rk808_i2c_client->dev, "power off error!\n");
>> +}
>> +
>>   static const struct of_device_id rk808_of_match[] = {
>>   	{ .compatible = "rockchip,rk808" },
>>   	{ .compatible = "rockchip,rk818" },
>> @@ -304,6 +322,7 @@ static int rk808_probe(struct i2c_client *client,
>>   	struct rk808 *rk808;
>>   	const struct rk808_reg_data *pre_init_reg;
>>   	const struct mfd_cell *cells;
>> +	void (*pm_pwroff_fn)(void);
>>   	int nr_pre_init_regs;
>>   	int nr_cells;
>>   	int pm_off = 0;
>> @@ -331,6 +350,7 @@ static int rk808_probe(struct i2c_client *client,
>>   		nr_pre_init_regs = ARRAY_SIZE(rk808_pre_init_reg);
>>   		cells = rk808s;
>>   		nr_cells = ARRAY_SIZE(rk808s);
>> +		pm_pwroff_fn = rk808_device_shutdown;
>>   		break;
>>   	case RK818_ID:
>>   		rk808->regmap_cfg = &rk818_regmap_config;
>> @@ -339,6 +359,7 @@ static int rk808_probe(struct i2c_client *client,
>>   		nr_pre_init_regs = ARRAY_SIZE(rk818_pre_init_reg);
>>   		cells = rk818s;
>>   		nr_cells = ARRAY_SIZE(rk818s);
>> +		pm_pwroff_fn = rk818_device_shutdown;
>>   		break;
>>   	default:
>>   		dev_err(&client->dev, "Unsupported RK8XX ID %lu\n",
>> @@ -393,7 +414,7 @@ static int rk808_probe(struct i2c_client *client,
>>   				"rockchip,system-power-controller");
>>   	if (pm_off && !pm_power_off) {
>>   		rk808_i2c_client = client;
>> -		pm_power_off = rk808_device_shutdown;
>> +		pm_power_off = pm_pwroff_fn;
>>   	}
>>   
>>   	return 0;
>> diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
>> index 6d435a3..83701ef 100644
>> --- a/include/linux/mfd/rk808.h
>> +++ b/include/linux/mfd/rk808.h
>> @@ -290,6 +290,7 @@ enum rk818_reg {
>>   #define SWITCH2_EN	BIT(6)
>>   #define SWITCH1_EN	BIT(5)
>>   #define DEV_OFF_RST	BIT(3)
>> +#define DEV_OFF		BIT(0)
>>   
>>   #define VB_LO_ACT		BIT(4)
>>   #define VB_LO_SEL_3500MV	(7 << 0)
>
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mfd: rk808: RK818 uses DEV_OFF to power off supplies
  2016-10-17  9:03 [PATCH] mfd: rk808: RK818 uses DEV_OFF to power off supplies Jianhong Chen
  2016-10-21  7:44 ` Wadim Egorov
@ 2016-10-26 13:53 ` Lee Jones
  1 sibling, 0 replies; 4+ messages in thread
From: Lee Jones @ 2016-10-26 13:53 UTC (permalink / raw)
  To: Jianhong Chen
  Cc: zhangqing, zyw, w.egorov, linux-kernel, linux-rockchip, tony.xie,
	huangtao, xsf

On Mon, 17 Oct 2016, Jianhong Chen wrote:

> DEV_OFF and DEV_OFF_RST functions for RK808 are designed error that
> only DEV_OFF_RST can power off supplies. RK818 has been fixed this
> issue, so that DEV_OFF is used to power off supplies.
> 
> Signed-off-by: Jianhong Chen <chenjh@rock-chips.com>
> ---
>  drivers/mfd/rk808.c       | 23 ++++++++++++++++++++++-
>  include/linux/mfd/rk808.h |  1 +
>  2 files changed, 23 insertions(+), 1 deletion(-)

Applied, thanks.

> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
> index 0f8acc5..2c9acdb 100644
> --- a/drivers/mfd/rk808.c
> +++ b/drivers/mfd/rk808.c
> @@ -290,6 +290,24 @@ static void rk808_device_shutdown(void)
>  		dev_err(&rk808_i2c_client->dev, "power off error!\n");
>  }
>  
> +static void rk818_device_shutdown(void)
> +{
> +	int ret;
> +	struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client);
> +
> +	if (!rk808) {
> +		dev_warn(&rk808_i2c_client->dev,
> +			 "have no rk818, so do nothing here\n");
> +		return;
> +	}
> +
> +	ret = regmap_update_bits(rk808->regmap,
> +				 RK818_DEVCTRL_REG,
> +				 DEV_OFF, DEV_OFF);
> +	if (ret)
> +		dev_err(&rk808_i2c_client->dev, "power off error!\n");
> +}
> +
>  static const struct of_device_id rk808_of_match[] = {
>  	{ .compatible = "rockchip,rk808" },
>  	{ .compatible = "rockchip,rk818" },
> @@ -304,6 +322,7 @@ static int rk808_probe(struct i2c_client *client,
>  	struct rk808 *rk808;
>  	const struct rk808_reg_data *pre_init_reg;
>  	const struct mfd_cell *cells;
> +	void (*pm_pwroff_fn)(void);
>  	int nr_pre_init_regs;
>  	int nr_cells;
>  	int pm_off = 0;
> @@ -331,6 +350,7 @@ static int rk808_probe(struct i2c_client *client,
>  		nr_pre_init_regs = ARRAY_SIZE(rk808_pre_init_reg);
>  		cells = rk808s;
>  		nr_cells = ARRAY_SIZE(rk808s);
> +		pm_pwroff_fn = rk808_device_shutdown;
>  		break;
>  	case RK818_ID:
>  		rk808->regmap_cfg = &rk818_regmap_config;
> @@ -339,6 +359,7 @@ static int rk808_probe(struct i2c_client *client,
>  		nr_pre_init_regs = ARRAY_SIZE(rk818_pre_init_reg);
>  		cells = rk818s;
>  		nr_cells = ARRAY_SIZE(rk818s);
> +		pm_pwroff_fn = rk818_device_shutdown;
>  		break;
>  	default:
>  		dev_err(&client->dev, "Unsupported RK8XX ID %lu\n",
> @@ -393,7 +414,7 @@ static int rk808_probe(struct i2c_client *client,
>  				"rockchip,system-power-controller");
>  	if (pm_off && !pm_power_off) {
>  		rk808_i2c_client = client;
> -		pm_power_off = rk808_device_shutdown;
> +		pm_power_off = pm_pwroff_fn;
>  	}
>  
>  	return 0;
> diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
> index 6d435a3..83701ef 100644
> --- a/include/linux/mfd/rk808.h
> +++ b/include/linux/mfd/rk808.h
> @@ -290,6 +290,7 @@ enum rk818_reg {
>  #define SWITCH2_EN	BIT(6)
>  #define SWITCH1_EN	BIT(5)
>  #define DEV_OFF_RST	BIT(3)
> +#define DEV_OFF		BIT(0)
>  
>  #define VB_LO_ACT		BIT(4)
>  #define VB_LO_SEL_3500MV	(7 << 0)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-26 13:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-17  9:03 [PATCH] mfd: rk808: RK818 uses DEV_OFF to power off supplies Jianhong Chen
2016-10-21  7:44 ` Wadim Egorov
2016-10-21  9:15   ` chenjh
2016-10-26 13:53 ` Lee Jones

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.