lkml.org 
[lkml]   [2016]   [Apr]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v10 1/4] gadget: Introduce the usb charger framework
From
On 8 April 2016 at 19:27, Jun Li <jun.li@nxp.com> wrote:
>
>
>> -----Original Message-----
>> From: Baolin Wang [mailto:baolin.wang@linaro.org]
>> Sent: Friday, April 08, 2016 7:00 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 v10 1/4] gadget: Introduce the usb charger framework
>>
>> Hi Jun,
>>
>> >> >> +/*
>> >> >> + * usb_charger_detect_type() - detect the charger type manually.
>> >> >> + * @uchger - usb charger device
>> >> >> + *
>> >> >> + * Note: You should ensure you need to detect the charger type
>> >> >> +manually on your
>> >> >> + * platform.
>> >> >> + * You should call it at the right gadget state to avoid
>> >> >> +affecting gadget
>> >> >> + * enumeration.
>> >> >> + */
>> >> >> +int usb_charger_detect_type(struct usb_charger *uchger) {
>> >> >> + enum usb_charger_type type;
>> >> >> +
>> >> >> + if (WARN(!uchger->charger_detect,
>> >> >> + "charger detection method should not be NULL"))
>> >> >> + return -EINVAL;
>> >> >> +
>> >> >> + type = uchger->charger_detect(uchger);
>> >> >> +
>> >> >> + mutex_lock(&uchger->lock);
>> >> >> + uchger->type = type;
>> >> >> + mutex_unlock(&uchger->lock);
>> >> >> +
>> >> >> + return 0;
>> >> >> +}
>> >> >> +EXPORT_SYMBOL_GPL(usb_charger_detect_type);
>> >> >
>> >> > I still recommend have a central place to call
>> >> > usb_charger_detect_type() to cover real charger detection instead
>> >> > of leaving this question open to diff users. This can be done after
>> >> > vbus-on is detected and before do gadget connect. I don't think
>> >> > this
>> >> will make your framework complicated.
>> >>
>> >> This API is used for detecting the charger type manually (software
>> >> charger detection), so if user's udc driver is needed to do this,
>> >> then they can issue it at their right place to make it more flexible.
>> >> But let us see other people's suggestion. Thanks.
>> >
>> > Ok, actually this API can be used for what ever charger detection
>> > type, user can implement any method(manual detection, directly read
>> > result from some HW...what ever) in uchger->charger_detect(), target
>> > is
>>
>> But reading result from some HW dose not means *detect*, actually is *get*.
>> We can not mix them together with the different semantics.
>
> It doesn’t matter here, you already define the _get_ API for just read
> the charger type from the saved value(uchger->type), so we can think
> the API to make uchger->type from UNKNOW to ONE KNOWN type is *detect*,
> because we don't need 2 separate API one for *get* type from HW and another
> one for *detect* from HW, only one API involve HW access is enough.

But another issue is some users may need to get the charger type from
power supply by "power_supply_get_property()" function, we need to
integrate with the power supply things in the usb charger framework,
not user to implement that.

>
> - Detect: (write to and) read from HW to get the charger type,
> save to uchger->type;
> - Get: read the charger type from uchger->type.
>
>>
>> > to have the charger type and set uchger->type, then you no need to add
>> > the comments/description to limit it usage. Also I do see there is
>> possible central place to do this.
>> >
>>
>> --
>> Baolin.wang
>> Best Regards



--
Baolin.wang
Best Regards

\
 
 \ /
  Last update: 2016-04-08 14:21    [W:0.248 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site