From: Jun Li <jun.li@nxp.com>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: "balbi@kernel.org" <balbi@kernel.org>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"sre@kernel.org" <sre@kernel.org>,
"dbaryshkov@gmail.com" <dbaryshkov@gmail.com>,
"dwmw2@infradead.org" <dwmw2@infradead.org>,
"peter.chen@freescale.com" <peter.chen@freescale.com>,
"stern@rowland.harvard.edu" <stern@rowland.harvard.edu>,
"r.baldyga@samsung.com" <r.baldyga@samsung.com>,
"yoshihiro.shimoda.uh@renesas.com"
<yoshihiro.shimoda.uh@renesas.com>,
"lee.jones@linaro.org" <lee.jones@linaro.org>,
"broonie@kernel.org" <broonie@kernel.org>,
"ckeepax@opensource.wolfsonmicro.com"
<ckeepax@opensource.wolfsonmicro.com>,
"patches@opensource.wolfsonmicro.com"
<patches@opensource.wolfsonmicro.com>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"device-mainlining@lists.linuxfoundation.org"
<device-mainlining@lists.linuxfoundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v9 1/4] gadget: Introduce the usb charger framework
Date: Wed, 6 Apr 2016 11:55:13 +0000 [thread overview]
Message-ID: <AM4PR04MB2130849E31BD77AAA487064B899F0@AM4PR04MB2130.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <CAMz4kuJmQTEXSjL55+fEm0-RO6N3isS60kPmD1XaXxGNumTpXg@mail.gmail.com>
Hi
> -----Original Message-----
> From: Baolin Wang [mailto:baolin.wang@linaro.org]
> Sent: Wednesday, April 06, 2016 7:31 PM
> To: Jun Li <jun.li@nxp.com>
> Cc: balbi@kernel.org; gregkh@linuxfoundation.org; sre@kernel.org;
> dbaryshkov@gmail.com; dwmw2@infradead.org; peter.chen@freescale.com;
> stern@rowland.harvard.edu; r.baldyga@samsung.com;
> yoshihiro.shimoda.uh@renesas.com; lee.jones@linaro.org; broonie@kernel.org;
> ckeepax@opensource.wolfsonmicro.com; patches@opensource.wolfsonmicro.com;
> linux-pm@vger.kernel.org; linux-usb@vger.kernel.org; device-
> mainlining@lists.linuxfoundation.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH v9 1/4] gadget: Introduce the usb charger framework
>
> On 6 April 2016 at 16:26, Jun Li <jun.li@nxp.com> wrote:
> > Hi
> >
> >> + */
> >> +static enum usb_charger_type
> >> +usb_charger_get_type_by_others(struct usb_charger *uchger) {
> >> + if (uchger->type != UNKNOWN_TYPE)
> >> + return uchger->type;
> >> +
> >> + if (uchger->psy) {
> >> + union power_supply_propval val;
> >> +
> >> + power_supply_get_property(uchger->psy,
> >> + POWER_SUPPLY_PROP_CHARGE_TYPE,
> >> + &val);
> >> + switch (val.intval) {
> >> + case POWER_SUPPLY_TYPE_USB:
> >> + uchger->type = SDP_TYPE;
> >> + break;
> >> + case POWER_SUPPLY_TYPE_USB_DCP:
> >> + uchger->type = DCP_TYPE;
> >> + break;
> >> + case POWER_SUPPLY_TYPE_USB_CDP:
> >> + uchger->type = CDP_TYPE;
> >> + break;
> >> + case POWER_SUPPLY_TYPE_USB_ACA:
> >> + uchger->type = ACA_TYPE;
> >> + break;
> >> + default:
> >> + uchger->type = UNKNOWN_TYPE;
> >> + break;
> >> + }
> >> + } else if (uchger->get_charger_type) {
> >> + uchger->type = uchger->get_charger_type(uchger);
> >> + } else {
> >> + uchger->type = UNKNOWN_TYPE;
> >> + }
> >> +
> >> + return uchger->type;
> >> +}
> >> +
> >
> > I think we may don't need this usb_charger_get_type_by_others().
> > "uchger->type" is set in one place is enough, that is: by
> > uchger->charger_detect() in usb_charger_detect_type(), then
> > usb_charger_get_type_by_others() is replaced by usb_charger_get_type().
> >
> > uchger->charger_detect() can have diff implementations no matter
> > what kind of mechanism is used, for your PMIC case, you can just
> > directly get the type value by power_supply_get_property(); with that,
> > we can have one central place to set uchger->type.
> > After uchger->type is set, charger type detection is no need to be
> > involved until charger type changes.
> >
> > Then next question is where is to call usb_charger_detect_type(), We
> > need make sure it finished before usb gadget connect.
>
> Yeah, that's the point: where? It is hard for usb charger framework to
> control, which will make it more complicated. The
> 'usb_charger_detect_type()' is used for detecting the charger type
> manually on user's platform, and user should call it at the right time to
> avoid affecting gadget enumeration. Otherwise user can implement some
> callbacks showed in 'usb_charger_get_type_by_others()' function to get
> charger type. I think this is controllable and simple for the usb charger
> framework.
As my suggested, Can this detection be in usb_udc_vbus_handler(), and
before usb_udc_connect_control()? We should be able to find some central
place where it is between vbus detection and gadget connect.
>
> >
> > Ideal is with your framework, diff users only need implement
> > uchger->charger_detect(). :)
> >
>
> --
> Baolin.wang
> Best Regards
next prev parent reply other threads:[~2016-04-06 11:55 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-01 7:21 [PATCH v9 0/4] Introduce usb charger framework to deal with the usb gadget power negotation Baolin Wang
2016-04-01 7:21 ` [PATCH v9 1/4] gadget: Introduce the usb charger framework Baolin Wang
2016-04-05 7:56 ` Peter Chen
2016-04-05 9:41 ` Baolin Wang
2016-04-06 7:25 ` Peter Chen
2016-04-06 7:38 ` Felipe Balbi
2016-04-06 7:43 ` Peter Chen
2016-04-06 8:05 ` Felipe Balbi
2016-04-06 8:10 ` Peter Chen
2016-04-06 10:25 ` Felipe Balbi
2016-04-07 2:39 ` Peter Chen
2016-04-07 4:56 ` Felipe Balbi
2016-04-07 6:11 ` Baolin Wang
2016-04-06 8:11 ` Peter Chen
2016-04-06 10:25 ` Felipe Balbi
2016-04-06 8:26 ` Jun Li
2016-04-06 11:31 ` Baolin Wang
2016-04-06 11:55 ` Jun Li [this message]
2016-04-01 7:21 ` [PATCH v9 2/4] gadget: Support for " Baolin Wang
2016-04-06 7:19 ` Peter Chen
2016-04-06 10:46 ` Baolin Wang
2016-04-06 12:03 ` Jun Li
2016-04-06 12:21 ` Felipe Balbi
2016-04-06 12:51 ` Jun Li
2016-04-06 12:55 ` Felipe Balbi
2016-04-06 13:49 ` Jun Li
2016-04-06 13:58 ` Felipe Balbi
2016-04-07 3:03 ` Peter Chen
2016-04-07 4:58 ` Felipe Balbi
2016-04-01 7:21 ` [PATCH v9 3/4] gadget: Integrate with the usb gadget supporting for usb charger Baolin Wang
2016-04-01 7:21 ` [PATCH v9 4/4] power: wm831x_power: Support USB charger current limit management Baolin Wang
2016-04-05 6:46 ` [PATCH v9 0/4] Introduce usb charger framework to deal with the usb gadget power negotation Peter Chen
2016-04-05 7:54 ` Baolin Wang
2016-04-05 8:12 ` Peter Chen
2016-04-05 9:34 ` Baolin Wang
2016-04-05 9:43 ` Peter Chen
2016-04-05 11:06 ` Baolin Wang
2016-04-05 17:01 ` Mark Brown
2016-04-05 16:53 ` Mark Brown
2016-04-06 1:15 ` Peter Chen
2016-04-06 17:01 ` Mark Brown
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=AM4PR04MB2130849E31BD77AAA487064B899F0@AM4PR04MB2130.eurprd04.prod.outlook.com \
--to=jun.li@nxp.com \
--cc=balbi@kernel.org \
--cc=baolin.wang@linaro.org \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.wolfsonmicro.com \
--cc=dbaryshkov@gmail.com \
--cc=device-mainlining@lists.linuxfoundation.org \
--cc=dwmw2@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=patches@opensource.wolfsonmicro.com \
--cc=peter.chen@freescale.com \
--cc=r.baldyga@samsung.com \
--cc=sre@kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=yoshihiro.shimoda.uh@renesas.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).