Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755980AbcCaIYz (ORCPT ); Thu, 31 Mar 2016 04:24:55 -0400 Received: from mail-yw0-f176.google.com ([209.85.161.176]:36708 "EHLO mail-yw0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755964AbcCaIYp (ORCPT ); Thu, 31 Mar 2016 04:24:45 -0400 MIME-Version: 1.0 In-Reply-To: <87egargj1y.fsf@intel.com> References: <20160325070937.GA22398@peterchendt> <87egargj1y.fsf@intel.com> Date: Thu, 31 Mar 2016 16:24:44 +0800 Message-ID: Subject: Re: [PATCH v8 0/4] Introduce usb charger framework to deal with the usb gadget power negotation From: Baolin Wang To: Felipe Balbi Cc: Jun Li , Peter Chen , Greg KH , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , Peter Chen , Alan Stern , "r.baldyga@samsung.com" , Yoshihiro Shimoda , Lee Jones , Mark Brown , Charles Keepax , "patches@opensource.wolfsonmicro.com" , Linux PM list , USB , "device-mainlining@lists.linuxfoundation.org" , LKML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1818 Lines: 48 On 31 March 2016 at 16:15, Felipe Balbi wrote: > > Hi Baolin, > > Baolin Wang writes: >>>> >> Make sense. In our company's solution, charger detection can be done >>>> >> by hardware from PMIC at first, then it will not affect the DP/DM >>>> >> line when gadget starts to enumeration. >>>> > >>>> > I see, charger type detection is done automatically by PMIC when VBUS >>>> > is detected in your case, you just assume the process is complete >>>> > before SW do gadget connect. To make the framework common, you may do >>>> one time charger type check when vbus is on, and save it to avoid repeat >>>> charger type check. >>>> >>>> OK. I'll add one judgement to check if the charger type is set in >>>> 'usb_charger_detect_type()' function. >>> >>> Just adding a judgement isn't enough here, your framework should make sure >>> usb_charger_detect_type() is called before gadget connect, with that, the >>> existing caller place just gets the charger type from the saved value. >>> The real charger type detection done by usb_charger_detect_type() can >>> be called only when vbus is on. >>> e.g. maybe in usb_udc_vbus_handler() before usb_udc_connect_control(). >> >> Yeah, Like Felipe suggested, I think we need to introduce one >> 'charger_detect()' method to do the SW charger type detection at the >> right gadget state. Thanks for your comments. > > Just to be clear, we add ->charger_detect() when we know of a platform > which needs to manually detect the charger type. Until then, we ignore > that situation. It might be a good idea, however, do document this in > comments on your structure definition stating that if we need to detect > charger type, a new method should be added ;-) Make sense. Thanks. > > cheers > > -- > balbi -- Baolin.wang Best Regards