[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AM4PR04MB2130849E31BD77AAA487064B899F0@AM4PR04MB2130.eurprd04.prod.outlook.com>
Date: Wed, 6 Apr 2016 11:55:13 +0000
From: Jun Li <jun.li@....com>
To: Baolin Wang <baolin.wang@...aro.org>
CC: "balbi@...nel.org" <balbi@...nel.org>,
"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
"sre@...nel.org" <sre@...nel.org>,
"dbaryshkov@...il.com" <dbaryshkov@...il.com>,
"dwmw2@...radead.org" <dwmw2@...radead.org>,
"peter.chen@...escale.com" <peter.chen@...escale.com>,
"stern@...land.harvard.edu" <stern@...land.harvard.edu>,
"r.baldyga@...sung.com" <r.baldyga@...sung.com>,
"yoshihiro.shimoda.uh@...esas.com" <yoshihiro.shimoda.uh@...esas.com>,
"lee.jones@...aro.org" <lee.jones@...aro.org>,
"broonie@...nel.org" <broonie@...nel.org>,
"ckeepax@...nsource.wolfsonmicro.com"
<ckeepax@...nsource.wolfsonmicro.com>,
"patches@...nsource.wolfsonmicro.com"
<patches@...nsource.wolfsonmicro.com>,
"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
"device-mainlining@...ts.linuxfoundation.org"
<device-mainlining@...ts.linuxfoundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v9 1/4] gadget: Introduce the usb charger framework
Hi
> -----Original Message-----
> From: Baolin Wang [mailto:baolin.wang@...aro.org]
> Sent: Wednesday, April 06, 2016 7:31 PM
> To: Jun Li <jun.li@....com>
> Cc: balbi@...nel.org; gregkh@...uxfoundation.org; sre@...nel.org;
> dbaryshkov@...il.com; dwmw2@...radead.org; peter.chen@...escale.com;
> stern@...land.harvard.edu; r.baldyga@...sung.com;
> yoshihiro.shimoda.uh@...esas.com; lee.jones@...aro.org; broonie@...nel.org;
> ckeepax@...nsource.wolfsonmicro.com; patches@...nsource.wolfsonmicro.com;
> linux-pm@...r.kernel.org; linux-usb@...r.kernel.org; device-
> mainlining@...ts.linuxfoundation.org; linux-kernel@...r.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@....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
Powered by blists - more mailing lists