public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Benson Leung <bleung@google.com>
To: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Cc: linux-pm@vger.kernel.org, sre@kernel.org,
	Sameer Nanda <snanda@chromium.org>,
	bleung@chromium.org, rjw@rjwysocki.net, gwendal@chromium.org,
	linux-kernel@vger.kernel.org, Len Brown <len.brown@intel.com>,
	groeck@chromium.org, Adam.Thomson.Opensource@diasemi.com,
	kernel@collabora.com, Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH v4 1/2] power: supply: add input power and voltage limit properties
Date: Thu, 23 May 2019 12:54:38 -0700	[thread overview]
Message-ID: <20190523195438.GA110498@google.com> (raw)
In-Reply-To: <20190507095248.17915-1-enric.balletbo@collabora.com>

[-- Attachment #1: Type: text/plain, Size: 7352 bytes --]

Hi Enric,

On Tue, May 07, 2019 at 11:52:47AM +0200, Enric Balletbo i Serra wrote:
> For thermal management strategy you might be interested on limit the
> input power for a power supply. We already have current limit but
> basically what we probably want is to limit power. So, introduce the
> input_power_limit property.
> 
> Although the common use case is limit the input power, in some
> specific cases it is the voltage that is problematic (i.e some regulators
> have different efficiencies at higher voltage resulting in more heat).
> So introduce also the input_voltage_limit property.
> 
> This happens in one Chromebook and is used on the Pixel C's thermal
> management strategy to effectively limit the input power to 5V 3A when
> the screen is on. When the screen is on, the display, the CPU, and the GPU
> all contribute more heat to the system than while the screen is off, and
> we made a tradeoff to throttle the charger in order to give more of the
> thermal budget to those other components.
> 
> So there's nothing fundamentally broken about the hardware that would
> cause the Pixel C to malfunction if we were charging at 9V or 12V instead
> of 5V when the screen is on, i.e. if userspace doesn't change this.
> 
> What would happen is that you wouldn't meet Google's skin temperature
> targets on the system if the charger was allowed to run at 9V or 12V with
> the screen on.
> 
> For folks hacking on Pixel Cs (which is now outside of Google's official
> support window for Android) and customizing their own kernel and userspace
> this would be acceptable, but we wanted to expose this feature in the
> power supply properties because the feature does exist in the Emedded
> Controller firmware of the Pixel C and all of Google's Chromebooks with
> USB-C made since 2015 in case someone running an up to date kernel wanted
> to limit the charging power for thermal or other reasons.
> 
> This patch exposes a new property, similar to input current limit, to
> re-configure the maximum voltage from the external supply at runtime
> based on system-level knowledge or user input.
> 
> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
> Reviewed-by: Guenter Roeck <groeck@chromium.org>
> Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>

Reviewed-by: Benson Leung <bleung@chromium.org>

> ---
> 
> Changes in v4:
> - Add also input_power_limit.
> 
> Changes in v3:
> - Improve commit log and documentation with Benson comments.
> 
> Changes in v2:
> - Document the new property in ABI/testing/sysfs-class-power.
> - Add the Reviewed-by Guenter Roeck tag.
> 
>  Documentation/ABI/testing/sysfs-class-power | 32 +++++++++++++++++++++
>  Documentation/power/power_supply_class.txt  |  4 +++
>  drivers/power/supply/power_supply_sysfs.c   |  2 ++
>  include/linux/power_supply.h                |  2 ++
>  4 files changed, 40 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power
> index 5e23e22dce1b..962a27a1daf8 100644
> --- a/Documentation/ABI/testing/sysfs-class-power
> +++ b/Documentation/ABI/testing/sysfs-class-power
> @@ -331,10 +331,42 @@ Description:
>  		supply. Normally this is configured based on the type of
>  		connection made (e.g. A configured SDP should output a maximum
>  		of 500mA so the input current limit is set to the same value).
> +		Use preferably input_power_limit, and for problems that can be
> +		solved using power limit use input_current_limit.
>  
>  		Access: Read, Write
>  		Valid values: Represented in microamps
>  
> +What:		/sys/class/power_supply/<supply_name>/input_voltage_limit
> +Date:		May 2019
> +Contact:	linux-pm@vger.kernel.org
> +Description:
> +		This entry configures the incoming VBUS voltage limit currently
> +		set in the supply. Normally this is configured based on
> +		system-level knowledge or user input (e.g. This is part of the
> +		Pixel C's thermal management strategy to effectively limit the
> +		input power to 5V when the screen is on to meet Google's skin
> +		temperature targets). Note that this feature should not be
> +		used for safety critical things.
> +		Use preferably input_power_limit, and for problems that can be
> +		solved using power limit use input_voltage_limit.
> +
> +		Access: Read, Write
> +		Valid values: Represented in microvolts
> +
> +What:		/sys/class/power_supply/<supply_name>/input_power_limit
> +Date:		May 2019
> +Contact:	linux-pm@vger.kernel.org
> +Description:
> +		This entry configures the incoming power limit currently set
> +		in the supply. Normally this is configured based on
> +		system-level knowledge or user input. Use preferably this
> +		feature to limit the incoming power and use current/voltage
> +		limit only for problems that can be solved using power limit.
> +
> +		Access: Read, Write
> +		Valid values: Represented in microwatts
> +
>  What:		/sys/class/power_supply/<supply_name>/online,
>  Date:		May 2007
>  Contact:	linux-pm@vger.kernel.org
> diff --git a/Documentation/power/power_supply_class.txt b/Documentation/power/power_supply_class.txt
> index 300d37896e51..1e3c705111db 100644
> --- a/Documentation/power/power_supply_class.txt
> +++ b/Documentation/power/power_supply_class.txt
> @@ -137,6 +137,10 @@ power supply object.
>  
>  INPUT_CURRENT_LIMIT - input current limit programmed by charger. Indicates
>  the current drawn from a charging source.
> +INPUT_VOLTAGE_LIMIT - input voltage limit programmed by charger. Indicates
> +the voltage limit from a charging source.
> +INPUT_POWER_LIMIT - input power limit programmed by charger. Indicates
> +the power limit from a charging source.
>  
>  CHARGE_CONTROL_LIMIT - current charge control limit setting
>  CHARGE_CONTROL_LIMIT_MAX - maximum charge control limit setting
> diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
> index 5358a80d854f..860db617d241 100644
> --- a/drivers/power/supply/power_supply_sysfs.c
> +++ b/drivers/power/supply/power_supply_sysfs.c
> @@ -275,6 +275,8 @@ static struct device_attribute power_supply_attrs[] = {
>  	POWER_SUPPLY_ATTR(charge_control_limit),
>  	POWER_SUPPLY_ATTR(charge_control_limit_max),
>  	POWER_SUPPLY_ATTR(input_current_limit),
> +	POWER_SUPPLY_ATTR(input_voltage_limit),
> +	POWER_SUPPLY_ATTR(input_power_limit),
>  	POWER_SUPPLY_ATTR(energy_full_design),
>  	POWER_SUPPLY_ATTR(energy_empty_design),
>  	POWER_SUPPLY_ATTR(energy_full),
> diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> index 2f9c201a54d1..ba135a5d8996 100644
> --- a/include/linux/power_supply.h
> +++ b/include/linux/power_supply.h
> @@ -122,6 +122,8 @@ enum power_supply_property {
>  	POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT,
>  	POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX,
>  	POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
> +	POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT,
> +	POWER_SUPPLY_PROP_INPUT_POWER_LIMIT,
>  	POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
>  	POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN,
>  	POWER_SUPPLY_PROP_ENERGY_FULL,
> -- 
> 2.20.1
> 

-- 
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
bleung@google.com
Chromium OS Project
bleung@chromium.org

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  parent reply	other threads:[~2019-05-23 19:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-07  9:52 [PATCH v4 1/2] power: supply: add input power and voltage limit properties Enric Balletbo i Serra
2019-05-07  9:52 ` [PATCH v4 2/2] power: supply: cros: allow to set input voltage and current limit Enric Balletbo i Serra
2019-05-23 19:54 ` Benson Leung [this message]
2019-06-25 10:04   ` [PATCH v4 1/2] power: supply: add input power and voltage limit properties Enric Balletbo Serra
2019-06-27 18:37     ` Sebastian Reichel

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=20190523195438.GA110498@google.com \
    --to=bleung@google.com \
    --cc=Adam.Thomson.Opensource@diasemi.com \
    --cc=bleung@chromium.org \
    --cc=enric.balletbo@collabora.com \
    --cc=groeck@chromium.org \
    --cc=gwendal@chromium.org \
    --cc=kernel@collabora.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --cc=snanda@chromium.org \
    --cc=sre@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