linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Li Jun <jun.li@nxp.com>
Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org,
	hdegoede@redhat.com, linux@roeck-us.net, rmfrfs@gmail.com,
	yueyao.zhu@gmail.com, linux-usb@vger.kernel.org,
	linux-imx@nxp.com
Subject: [v5,2/5] usb: typec: fusb302: remove max_snk_* for sink config
Date: Fri, 20 Apr 2018 18:14:17 +0300	[thread overview]
Message-ID: <20180420151417.GC25303@kuha.fi.intel.com> (raw)

On Mon, Apr 16, 2018 at 02:54:34PM +0800, Li Jun wrote:
> Since max_snk_* is to be deprecated, so remove max_snk_* by adding a
> variable PDO for sink config.
> 
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Li Jun <jun.li@nxp.com>

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/fusb302/fusb302.c | 42 ++++++++++++++++++++++++-------------
>  1 file changed, 28 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c
> index 7036171..664463d 100644
> --- a/drivers/usb/typec/fusb302/fusb302.c
> +++ b/drivers/usb/typec/fusb302/fusb302.c
> @@ -120,6 +120,7 @@ struct fusb302_chip {
>  	enum typec_cc_polarity cc_polarity;
>  	enum typec_cc_status cc1;
>  	enum typec_cc_status cc2;
> +	u32 snk_pdo[PDO_MAX_OBJECTS];
>  
>  #ifdef CONFIG_DEBUG_FS
>  	struct dentry *dentry;
> @@ -1212,11 +1213,6 @@ static const u32 snk_pdo[] = {
>  static const struct tcpc_config fusb302_tcpc_config = {
>  	.src_pdo = src_pdo,
>  	.nr_src_pdo = ARRAY_SIZE(src_pdo),
> -	.snk_pdo = snk_pdo,
> -	.nr_snk_pdo = ARRAY_SIZE(snk_pdo),
> -	.max_snk_mv = 5000,
> -	.max_snk_ma = 3000,
> -	.max_snk_mw = 15000,
>  	.operating_snk_mw = 2500,
>  	.type = TYPEC_PORT_DRP,
>  	.data = TYPEC_PORT_DRD,
> @@ -1756,6 +1752,29 @@ static int init_gpio(struct fusb302_chip *chip)
>  	return 0;
>  }
>  
> +static int fusb302_composite_snk_pdo_array(struct fusb302_chip *chip)
> +{
> +	struct device *dev = chip->dev;
> +	u32 max_uv, max_ua;
> +
> +	chip->snk_pdo[0] = PDO_FIXED(5000, 400, PDO_FIXED_FLAGS);
> +
> +	/*
> +	 * As max_snk_ma/mv/mw is not needed for tcpc_config,
> +	 * those settings should be passed in via sink PDO, so
> +	 * "fcs, max-sink-*" properties will be deprecated, to
> +	 * perserve compatibility with existing users of them,
> +	 * we read those properties to convert them to be a var
> +	 * PDO.
> +	 */
> +	if (device_property_read_u32(dev, "fcs,max-sink-microvolt", &max_uv) ||
> +		device_property_read_u32(dev, "fcs,max-sink-microamp", &max_ua))
> +		return 1;
> +
> +	chip->snk_pdo[1] = PDO_VAR(5000, max_uv / 1000, max_ua / 1000);
> +	return 2;
> +}
> +
>  static int fusb302_probe(struct i2c_client *client,
>  			 const struct i2c_device_id *id)
>  {
> @@ -1784,18 +1803,13 @@ static int fusb302_probe(struct i2c_client *client,
>  	chip->tcpc_dev.config = &chip->tcpc_config;
>  	mutex_init(&chip->lock);
>  
> -	if (!device_property_read_u32(dev, "fcs,max-sink-microvolt", &v))
> -		chip->tcpc_config.max_snk_mv = v / 1000;
> -
> -	if (!device_property_read_u32(dev, "fcs,max-sink-microamp", &v))
> -		chip->tcpc_config.max_snk_ma = v / 1000;
> -
> -	if (!device_property_read_u32(dev, "fcs,max-sink-microwatt", &v))
> -		chip->tcpc_config.max_snk_mw = v / 1000;
> -
>  	if (!device_property_read_u32(dev, "fcs,operating-sink-microwatt", &v))
>  		chip->tcpc_config.operating_snk_mw = v / 1000;
>  
> +	/* Composite sink PDO */
> +	chip->tcpc_config.nr_snk_pdo = fusb302_composite_snk_pdo_array(chip);
> +	chip->tcpc_config.snk_pdo = chip->snk_pdo;
> +
>  	/*
>  	 * Devicetree platforms should get extcon via phandle (not yet
>  	 * supported). On ACPI platforms, we get the name from a device prop.
> -- 
> 2.7.4

             reply	other threads:[~2018-04-20 15:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-20 15:14 Heikki Krogerus [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-04-16  6:54 [v5,2/5] usb: typec: fusb302: remove max_snk_* for sink config Jun Li

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=20180420151417.GC25303@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=jun.li@nxp.com \
    --cc=linux-imx@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=rmfrfs@gmail.com \
    --cc=robh+dt@kernel.org \
    --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 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).