linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Thompson <daniel.thompson@linaro.org>
To: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Sebastian Reichel <sre@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH 2/2] power: supply: Add Lenovo Yoga C630 EC driver
Date: Mon, 12 Sep 2022 17:00:17 +0000	[thread overview]
Message-ID: <20220912165802.dvlf3eeqx5g3bzdm@maple.lan> (raw)
In-Reply-To: <20220810030500.2793882-3-bjorn.andersson@linaro.org>

On Tue, Aug 09, 2022 at 10:05:00PM -0500, Bjorn Andersson wrote:
> The Qualcomm Snapdragon-based Lenovo Yoga C630 has some sort of EC
> providing AC-adapter and battery status, as well as USB Type-C altmode
> notifications for Displayport operation.

There's a couple of minor review comments but before we get to that:
woo hoo!


> The Yoga C630 ships with Windows, where these operations primarily are
> implemented in ACPI, but due to various issues with the hardware
> representation therein it's not possible to run Linux on this
> information. As such this is a best-effort re-implementation of these
> operations, based on the register map expressed in ACPI and a fair
> amount of trial and error.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> Reported-by: kernel test robot <lkp@intel.com>
> ---
>  drivers/power/supply/Kconfig        |  11 +
>  drivers/power/supply/Makefile       |   1 +
>  drivers/power/supply/yoga-c630-ec.c | 547 ++++++++++++++++++++++++++++
>  3 files changed, 559 insertions(+)
>  create mode 100644 drivers/power/supply/yoga-c630-ec.c
>
> diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
> index 1aa8323ad9f6..6e706e948ad2 100644
> --- a/drivers/power/supply/Kconfig
> +++ b/drivers/power/supply/Kconfig
> @@ -897,4 +897,15 @@ config BATTERY_UG3105
>  	  device is off or suspended, the functionality of this driver is
>  	  limited to reporting capacity only.
>
> +config LENOVO_YOGA_C630_EC
> +	tristate "Lenovo Yoga C630 EC battery driver"
> +	depends on DRM
> +	depends on I2C

This needs a "depends on TYPEC" in order to avoid linker errors.


> +	help
> +	  Driver for the Embedded Controller in the Qualcomm Snapdragon-based
> +	  Lenovo Yoga C630, which provides battery information and USB Type-C
> +	  altmode notifications.
> +
> +	  Say M or Y here to include this support.
> +
>  endif # POWER_SUPPLY
> diff --git a/drivers/power/supply/yoga-c630-ec.c b/drivers/power/supply/yoga-c630-ec.c
> new file mode 100644
> index 000000000000..1fa0b5844e01
> --- /dev/null
> +++ b/drivers/power/supply/yoga-c630-ec.c
> @@ -0,0 +1,547 @@
> <snip>
> +static int yoga_c630_ec_bat_get_property(struct power_supply *psy,
> +					 enum power_supply_property psp,
> +					 union power_supply_propval *val)
> +{
> +	struct yoga_c630_ec *ec = power_supply_get_drvdata(psy);
> +	int rc = 0;
> +
> +	if (ec->bat_present)
> +		yoga_c630_ec_maybe_update_bat_status(ec);
> +	else if (psp != POWER_SUPPLY_PROP_PRESENT)
> +		return -ENODEV;
> +
> +	switch (psp) {
>       <snip>
> +	case POWER_SUPPLY_PROP_TECHNOLOGY:
> +		val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
> +		break;
> +	case POWER_SUPPLY_PROP_MODEL_NAME:
> +		val->strval = "PABAS0241231";
> +		break;
> +	case POWER_SUPPLY_PROP_MANUFACTURER:
> +		val->strval = "Compal";
> +		break;
> +	case POWER_SUPPLY_PROP_SERIAL_NUMBER:
> +		val->strval = "05072018";
> +		break;

I'm a little sceptical that hardcoding a serial number into the
driver provides anybody any benefit (regardless of whether the
AML code does this). AFAICT this is not a commonly implemented property
in other power supplies so I'm not clear why this is needed.


Daniel.

  reply	other threads:[~2022-09-12 17:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-10  3:04 [PATCH 0/2] power: supply: Lenovo Yoga C630 EC Bjorn Andersson
2022-08-10  3:04 ` [PATCH 1/2] dt-bindings: power: supply: Add " Bjorn Andersson
2022-08-10 13:35   ` Krzysztof Kozlowski
2022-08-10 19:33     ` Bjorn Andersson
2022-08-10 15:11   ` Rob Herring
2022-08-10  3:05 ` [PATCH 2/2] power: supply: Add Lenovo Yoga C630 EC driver Bjorn Andersson
2022-09-12 17:00   ` Daniel Thompson [this message]
2022-09-13  8:17     ` Daniel Thompson
2022-09-13 10:45   ` Sebastian Reichel
2022-09-15 21:25     ` Bjorn Andersson
2022-09-15 21:53       ` Dmitry Baryshkov
2022-09-21 22:10         ` Bjorn Andersson
2022-08-10  4:04 ` [PATCH 0/2] power: supply: Lenovo Yoga C630 EC Steev Klimaszewski
2022-08-10 19:15   ` Bjorn Andersson

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=20220912165802.dvlf3eeqx5g3bzdm@maple.lan \
    --to=daniel.thompson@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=robh+dt@kernel.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;
as well as URLs for NNTP newsgroup(s).