All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>,
	Hans de Goede <hdegoede@redhat.com>
Cc: Guenter Roeck <linux@roeck-us.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sebastian Reichel <sre@kernel.org>,
	Yueyao Zhu <yueyao.zhu@gmail.com>,
	Rui Miguel Silva <rmfrfs@gmail.com>,
	linux-usb@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, support.opensource@diasemi.com
Subject: Re: [RFC PATCH v2 6/7] typec: tcpm: Represent source supply through power_supply class
Date: Fri, 24 Nov 2017 14:19:02 +0200	[thread overview]
Message-ID: <20171124121902.GA2403@kuha.fi.intel.com> (raw)
In-Reply-To: <81dd8843163c9ca193f32d54adb6fece99e5f159.1510657748.git.Adam.Thomson.Opensource@diasemi.com>

Hi,

On Tue, Nov 14, 2017 at 11:44:47AM +0000, Adam Thomson wrote:
> diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
> index 78983e1..7c26c3d 100644
> --- a/drivers/usb/typec/tcpm.c
> +++ b/drivers/usb/typec/tcpm.c
> @@ -12,6 +12,7 @@
>  #include <linux/kernel.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
> +#include <linux/power_supply.h>
>  #include <linux/proc_fs.h>
>  #include <linux/sched/clock.h>
>  #include <linux/seq_file.h>
> @@ -277,6 +278,10 @@ struct tcpm_port {
>  	u32 current_limit;
>  	u32 supply_voltage;
>  
> +	/* Used to export TA voltage and current */
> +	struct power_supply *psy;
> +	struct power_supply_desc psy_desc;
> +
>  	u32 bist_request;
>  
>  	/* PD state for Vendor Defined Messages */
> @@ -1756,6 +1761,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port)
>  	int ret = -EINVAL;
>  
>  	port->pps_data.supported = false;
> +	port->psy_desc.type = POWER_SUPPLY_TYPE_USB_PD;
>  
>  	/*
>  	 * Select the source PDO providing the most power while staying within
> @@ -1775,8 +1781,10 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port)
>  			mv = pdo_min_voltage(pdo);
>  			break;
>  		case PDO_TYPE_APDO:
> -			if (pdo_apdo_type(pdo) == APDO_TYPE_PPS)
> +			if (pdo_apdo_type(pdo) == APDO_TYPE_PPS) {
>  				port->pps_data.supported = true;
> +				port->psy_desc.type = POWER_SUPPLY_TYPE_USB_PD_PPS;
> +			}
>  			continue;
>  		default:
>  			tcpm_log(port, "Invalid PDO type, ignoring");
> @@ -2248,6 +2256,9 @@ static void tcpm_reset_port(struct tcpm_port *port)
>  	port->try_snk_count = 0;
>  	port->supply_voltage = 0;
>  	port->current_limit = 0;
> +	port->psy_desc.type = POWER_SUPPLY_TYPE_USB_TYPE_C;

Is it OK to everybody that the type of the psy is changed like that?
Hans?!

We do have drivers that already change the type, for example
drivers/power/supply/isp1704_charger.c, but what does the user space
expect? The ABI for the power supply class was never documented I
guess.

I'm not against changing the type, but I think that we should have an
attribute file listing all supported types a psy can have if we go
forward with this. Ideally the type file would just list them as space
separated values, and show the current one with asterisk in front of
it. The output would be similar we have with some of the other files
under /sys/power, at least /sys/power/state, but that would break the
ABI.


Thanks,

-- 
heikki

  reply	other threads:[~2017-11-24 12:19 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-14 11:44 [RFC PATCH v2 0/7] typec: tcpm: Add sink side support for PPS Adam Thomson
2017-11-14 11:44 ` Adam Thomson
2017-11-14 11:44 ` [RFC PATCH v2 1/7] typec: tcpm: Add PD Rev 3.0 definitions to PD header Adam Thomson
2017-11-14 11:44   ` Adam Thomson
2017-11-14 11:44 ` [RFC PATCH v2 2/7] typec: tcpm: Add ADO header for Alert message handling Adam Thomson
2017-11-14 11:44   ` Adam Thomson
2017-11-14 11:44 ` [RFC PATCH v2 3/7] typec: tcpm: Add SDB header for Status " Adam Thomson
2017-11-14 11:44   ` Adam Thomson
2017-11-14 11:44 ` [RFC PATCH v2 4/7] typec: tcpm: Add core support for sink side PPS Adam Thomson
2017-11-14 11:44   ` Adam Thomson
2017-11-14 11:44 ` [RFC PATCH v2 5/7] power: supply: Add type for USB PD PPS chargers Adam Thomson
2017-11-14 11:44   ` Adam Thomson
2017-11-14 11:44 ` [RFC PATCH v2 6/7] typec: tcpm: Represent source supply through power_supply class Adam Thomson
2017-11-14 11:44   ` Adam Thomson
2017-11-24 12:19   ` Heikki Krogerus [this message]
2017-11-24 14:05     ` Adam Thomson
2017-11-27 14:11       ` Heikki Krogerus
2017-11-27 16:54         ` Adam Thomson
2017-11-28 11:45           ` Heikki Krogerus
2017-11-25 14:03     ` Hans de Goede
2017-11-27 13:38       ` Heikki Krogerus
2017-11-27 13:43       ` Adam Thomson
2017-11-14 11:44 ` [RFC PATCH v2 7/7] typec: tcpm: Add support for sink PPS related messages Adam Thomson
2017-11-14 11:44   ` Adam Thomson
2017-11-21 13:35 ` [RFC PATCH v2 0/7] typec: tcpm: Add sink side support for PPS Heikki Krogerus
2017-11-21 13:51   ` Adam Thomson
2017-11-21 14:18     ` Heikki Krogerus
2017-11-21 14:21       ` Adam Thomson

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=20171124121902.GA2403@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=Adam.Thomson.Opensource@diasemi.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=rmfrfs@gmail.com \
    --cc=sre@kernel.org \
    --cc=support.opensource@diasemi.com \
    --cc=yueyao.zhu@gmail.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 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.