linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Hans de Goede <hdegoede@redhat.com>,
	Darren Hart <dvhart@infradead.org>,
	Andy Shevchenko <andy@infradead.org>,
	Wolfram Sang <wsa@the-dreams.de>,
	Sebastian Reichel <sre@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
	Liam Breck <liam@networkimprov.net>,
	Tony Lindgren <tony@atomide.com>,
	linux-pm@vger.kernel.org, devel@driverdev.osuosl.org
Subject: Re: [PATCH 08/18] staging: typec: fusb302: Add support for USB2 charger detection through extcon
Date: Sun, 6 Aug 2017 07:58:57 -0700	[thread overview]
Message-ID: <e5148d31-8de2-c4ee-d076-183a4f7aae54@roeck-us.net> (raw)
In-Reply-To: <60616f13-207e-f998-7151-ad670c876166@redhat.com>

On 08/06/2017 07:36 AM, Hans de Goede wrote:
> Hi,
> 
> On 06-08-17 16:22, Guenter Roeck wrote:
>> On 08/06/2017 05:35 AM, Hans de Goede wrote:
>>> The fusb302 port-controller relies on an external device doing USB2
>>> charger-type detection.
>>>
>>> The Intel Whiskey Cove PMIC with which the fusb302 is combined on some
>>> X86/ACPI platforms already has a charger-type detection driver which
>>> uses extcon to communicate the detected charger-type.
>>>
>>> This commit uses the tcpm_get_usb2_current_limit_extcon helper to enable
>>> USB2 charger detection on these systems. Note that the "fcs,extcon-name"
>>> property name is only for kernel internal use by X86/ACPI platform code
>>> and as such is NOT documented in the devicetree bindings.
>>>
>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>> ---
>>>   drivers/staging/typec/fusb302/fusb302.c | 16 ++++++++++++++++
>>>   1 file changed, 16 insertions(+)
>>>
>>> diff --git a/drivers/staging/typec/fusb302/fusb302.c b/drivers/staging/typec/fusb302/fusb302.c
>>> index be454b5ff6c7..1d8c9b66df2f 100644
>>> --- a/drivers/staging/typec/fusb302/fusb302.c
>>> +++ b/drivers/staging/typec/fusb302/fusb302.c
>>> @@ -1201,6 +1201,8 @@ static void init_tcpc_dev(struct tcpc_dev *fusb302_tcpc_dev)
>>>   {
>>>       fusb302_tcpc_dev->init = tcpm_init;
>>>       fusb302_tcpc_dev->get_vbus = tcpm_get_vbus;
>>> +    fusb302_tcpc_dev->get_usb2_current_limit =
>>> +        tcpm_get_usb2_current_limit_extcon;
>>>       fusb302_tcpc_dev->set_cc = tcpm_set_cc;
>>>       fusb302_tcpc_dev->get_cc = tcpm_get_cc;
>>>       fusb302_tcpc_dev->set_polarity = tcpm_set_polarity;
>>> @@ -1685,6 +1687,7 @@ static int fusb302_probe(struct i2c_client *client,
>>>       struct fusb302_chip *chip;
>>>       struct i2c_adapter *adapter;
>>>       struct device *dev = &client->dev;
>>> +    const char *name;
>>>       int ret = 0;
>>>       u32 val;
>>> @@ -1717,6 +1720,19 @@ static int fusb302_probe(struct i2c_client *client,
>>>       if (device_property_read_u32(dev, "fcs,operating-snk-mw", &val) == 0)
>>>           chip->tcpc_config.operating_snk_mw = val;
>>> +    /*
>>> +     * Devicetree platforms should get extcon via phandle (not yet
>>> +     * supported). On ACPI platforms, we get the name from a device prop.
>>> +     * This device prop is for kernel internal use only and is expected
>>> +     * to be set by the platform code which also registers the i2c client
>>> +     * for the fusb302.
>>> +     */
>>> +    if (device_property_read_string(dev, "fcs,extcon-name", &name) == 0) {
>>
>> Those new devicetree properties need to be documented and approved by dt maintainers.
> 
> As indicated by the comment, this property should not be used in the devicetree
> case, notice this is a device-property and not an of property and since it is
> not intended to be used with devicetree at all (in devicetree a phandle rather
> then a name would be used), it has no place under Documentation/devicetree at all.
> 

Ok. I thought device properties were supposed to unify dt and non-dt situations,
but apparently not. Oh well :-(.

> Also there is no current binding documentation for the "fcs,fusb302" compatible
> and the weird "fcs,int_n" gpio which really is an irq which it already uses.
> 

Yes, one of those TODO items for moving the code out of staging. "fcs," should
possibly be "fusb302,", and int_n _is_ weird.

> 
>>
>>> +        chip->tcpc_dev.usb2_extcon = extcon_get_extcon_dev(name);
>>> +        if (!chip->tcpc_dev.usb2_extcon)
>>
>> extcon_get_extcon_dev() can also return an ERR_PTR.
>>
>> As before, I am not really happy typing this into tcpm via tcpc_dev.
>> Until we have a better solution, I would prefer for that code to stay with the fusb302
>> code.
> 
> Ok, I tried to make this all re-usable since I think other port-controller drivers
> will need something similar, but I can kill the entire tcpm-helpers.c file in v2
> and then put everything in fusb302.c. I take it that that is what you want ?
> 
Yes, please.

Also, please copy Yueyao Zhu for the fusb302 changes in v2.

Thanks,
Guenter

  reply	other threads:[~2017-08-06 14:59 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-06 12:35 [PATCH 00/18] Hookup typec power-negotation to the PMIC and charger Hans de Goede
2017-08-06 12:35 ` [PATCH 01/18] staging: typec: tcpm: Add get_usb2_current_limit tcpc_dev callback Hans de Goede
2017-08-06 14:18   ` Guenter Roeck
2017-08-06 14:29     ` Hans de Goede
2017-08-06 14:52       ` Guenter Roeck
2017-08-06 12:35 ` [PATCH 02/18] staging: typec: tcpm: Add extcon helper functions for USB2 current limit detect Hans de Goede
2017-08-06 14:07   ` Guenter Roeck
2017-08-06 12:35 ` [PATCH 03/18] staging: typec: tcpm: Split tcpm code into tcpm-core.c and tcpm-helpers.c Hans de Goede
2017-08-06 12:35 ` [PATCH 04/18] staging: typec: tcpm: Add helpers for exporting current-limit through a psy Hans de Goede
2017-08-06 14:13   ` Guenter Roeck
2017-08-06 14:21     ` Hans de Goede
2017-08-06 14:41       ` Guenter Roeck
2017-08-06 12:35 ` [PATCH 05/18] staging: typec: fusb302: Set max supply voltage to 5V Hans de Goede
2017-08-06 12:35 ` [PATCH 06/18] staging: typec: fusb302: Get max snk mv/ma/mw from device-properties Hans de Goede
2017-08-06 14:03   ` Guenter Roeck
2017-08-06 12:35 ` [PATCH 07/18] staging: typec: fusb302: Use client->irq as irq if set Hans de Goede
2017-08-06 12:35 ` [PATCH 08/18] staging: typec: fusb302: Add support for USB2 charger detection through extcon Hans de Goede
2017-08-06 14:22   ` Guenter Roeck
2017-08-06 14:36     ` Hans de Goede
2017-08-06 14:58       ` Guenter Roeck [this message]
2017-08-06 12:35 ` [PATCH 09/18] staging: typec: fusb302: Use tcpm_set_current_limit_psy Hans de Goede
2017-08-06 14:24   ` Guenter Roeck
2017-08-06 12:35 ` [PATCH 10/18] staging: typec: fusb302: Add support for fcs,vbus-regulator-name device-property Hans de Goede
2017-08-06 14:30   ` Guenter Roeck
2017-08-06 14:52     ` Hans de Goede
2017-08-06 15:20       ` Guenter Roeck
2017-08-06 15:44     ` Hans de Goede
2017-08-07 11:10       ` Mark Brown
2017-08-07 14:41         ` Hans de Goede
2017-08-07 15:41           ` Mark Brown
2017-08-07 19:20             ` Hans de Goede
2017-08-08  9:39               ` Mark Brown
     [not found]                 ` <0b75c318-0f71-c536-7c7f-9ba16b215690@redhat.com>
     [not found]                   ` <20170808144217.c2fm25uge75p4lo2@sirena.org.uk>
2017-08-08 20:53                     ` Hans de Goede
2017-08-06 12:35 ` [PATCH 11/18] power: supply: Fix power_supply_am_i_supplied to return -ENODEV when apropriate Hans de Goede
2017-08-06 14:31   ` Guenter Roeck
2017-08-06 14:54     ` Hans de Goede
2017-08-06 12:35 ` [PATCH 12/18] power: supply: Add power_supply_set_input_current_limit_from_supplier helper Hans de Goede
2017-08-06 12:35 ` [PATCH 13/18] power: supply: bq24190_charger: Export 5V boost converter as regulator Hans de Goede
2017-08-08  4:15   ` Tony Lindgren
2017-08-08  8:39   ` Liam Breck
2017-08-08  9:00     ` Hans de Goede
2017-08-08 18:57       ` Liam Breck
2017-08-08 21:09         ` Hans de Goede
2017-08-06 12:35 ` [PATCH 14/18] power: supply: bq24190_charger: Add input_current_limit property Hans de Goede
2017-08-06 12:35 ` [PATCH 15/18] power: supply: bq24190_charger: Get input_current_limit from our supplier Hans de Goede
2017-08-08  8:24   ` Liam Breck
2017-08-08  9:11     ` Hans de Goede
2017-08-06 12:35 ` [PATCH 16/18] power: supply: bq24190_charger: Remove extcon handling Hans de Goede
2017-08-08  8:27   ` Liam Breck
2017-08-08  9:12     ` Hans de Goede
2017-08-06 12:35 ` [PATCH 17/18] platform/x86: intel_cht_int33fe Update fusb302 type string, add properties Hans de Goede
2017-08-06 12:35 ` [PATCH 18/18] i2c-cht-wc: Add device-properties for fusb302 integration Hans de Goede
2017-08-06 14:35   ` Guenter Roeck
2017-08-06 15:05     ` Hans de Goede
2017-08-06 16:29       ` Andy Shevchenko

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=e5148d31-8de2-c4ee-d076-183a4f7aae54@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=andy@infradead.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=dvhart@infradead.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=liam@networkimprov.net \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=sre@kernel.org \
    --cc=tony@atomide.com \
    --cc=wsa@the-dreams.de \
    /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).