Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751765AbdHPPLZ (ORCPT ); Wed, 16 Aug 2017 11:11:25 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:55534 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751517AbdHPPLW (ORCPT ); Wed, 16 Aug 2017 11:11:22 -0400 Subject: Re: [PATCH v2 02/14] staging: typec: tcpm: Add get_current_limit tcpc_dev callback To: Hans de Goede , Wolfram Sang , Heikki Krogerus , Sebastian Reichel , Darren Hart , Andy Shevchenko , Greg Kroah-Hartman Cc: Liam Breck , Tony Lindgren , linux-i2c@vger.kernel.org, linux-pm@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org References: <20170815200502.17339-1-hdegoede@redhat.com> <20170815200502.17339-3-hdegoede@redhat.com> From: Guenter Roeck Message-ID: <655b5cd9-76df-c99d-39d9-efe31ad5849d@roeck-us.net> Date: Wed, 16 Aug 2017 08:11:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170815200502.17339-3-hdegoede@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: linux@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: linux@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2144 Lines: 57 On 08/15/2017 01:04 PM, Hans de Goede wrote: > A Rp signalling the default current limit indicates that we're possibly > connected to an USB2 power-source. In some cases the type-c port-controller > may provide the capability to detect the current-limit in this case, > through e.g. BC1.2 detection. > > This commit adds an optional get_current_limit tcpc_dev callback which > allows the port-controller to provide current-limit detection for when > the CC pin is pulled up with Rp. > > Signed-off-by: Hans de Goede Reviewed-by: Guenter Roeck > --- > Changes in v2: > -s/get_usb2_current_limit/get_current_limit/ > --- > drivers/staging/typec/tcpm.c | 5 ++++- > drivers/staging/typec/tcpm.h | 7 +++++++ > 2 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c > index 20eb4eb..8e823af 100644 > --- a/drivers/staging/typec/tcpm.c > +++ b/drivers/staging/typec/tcpm.c > @@ -660,7 +660,10 @@ static u32 tcpm_get_current_limit(struct tcpm_port *port) > break; > case TYPEC_CC_RP_DEF: > default: > - limit = 0; > + if (port->tcpc->get_current_limit) > + limit = port->tcpc->get_current_limit(port->tcpc); > + else > + limit = 0; > break; > } > > diff --git a/drivers/staging/typec/tcpm.h b/drivers/staging/typec/tcpm.h > index 19c307d..1465668 100644 > --- a/drivers/staging/typec/tcpm.h > +++ b/drivers/staging/typec/tcpm.h > @@ -108,6 +108,13 @@ struct tcpc_dev { > > int (*init)(struct tcpc_dev *dev); > int (*get_vbus)(struct tcpc_dev *dev); > + /* > + * This optional callback gets called by the tcpm core when configured > + * as a snk and cc=Rp-def. This allows the tcpm to provide a fallback > + * current-limit detection method for the cc=Rp-def case. E.g. some > + * tcpcs may include BC1.2 charger detection and use that in this case. > + */ > + int (*get_current_limit)(struct tcpc_dev *dev); > int (*set_cc)(struct tcpc_dev *dev, enum typec_cc_status cc); > int (*get_cc)(struct tcpc_dev *dev, enum typec_cc_status *cc1, > enum typec_cc_status *cc2); >