From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71C46C433ED for ; Sun, 4 Apr 2021 07:21:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29FC4610D1 for ; Sun, 4 Apr 2021 07:21:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229656AbhDDHVz (ORCPT ); Sun, 4 Apr 2021 03:21:55 -0400 Received: from muru.com ([72.249.23.125]:50606 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbhDDHVy (ORCPT ); Sun, 4 Apr 2021 03:21:54 -0400 Received: from atomide.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id 54A6B804D; Sun, 4 Apr 2021 07:22:56 +0000 (UTC) Date: Sun, 4 Apr 2021 10:21:46 +0300 From: Tony Lindgren To: Carl Philipp Klemm Cc: Sebastian Reichel , linux-pm@vger.kernel.org, linux-omap@vger.kernel.org, Arthur Demchenkov , Merlijn Wajer , Pavel Machek Subject: Re: [PATCH 5/5] power: supply: cpcap-charger: Add usleep to cpcap charger to avoid usb plug bounce Message-ID: References: <20210117224853.3602368391c9785e74748239@uvos.xyz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210117224853.3602368391c9785e74748239@uvos.xyz> Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org * Carl Philipp Klemm [210117 23:48]: > Adds 80000 us sleep when the usb cable is plugged in to hopefully avoid > bouncing contacts. > > Upon pluging in the usb cable vbus will bounce for some time, causing cpcap to > dissconnect charging due to detecting an undervoltage condition. This is a > scope of vbus on xt894 while quickly inserting the usb cable with firm force, > probed at the far side of the usb socket and vbus loaded with approx 1k: > http://uvos.xyz/maserati/usbplug.jpg. > > As can clearly be seen, vbus is all over the place for the first 15 ms or so > with a small blip at ~40 ms this causes the cpcap to trip up and disable > charging again. > > The delay helps cpcap_usb_detect avoid the worst of this. It is, however, still > not ideal as strong vibrations can cause the issue to reapear any time during > charging. I have however not been able to cause the device to stop charging due > to this in practice as it is hard to vibrate the device such that the vbus pins > start bouncing again but cpcap_usb_detect is not called again due to a detected > disconnect/reconnect event. > > Signed-off-by: Carl Philipp Klemm This patch fixes an issue where connecting a charger often fails for me: Tested-by: Tony Lindgren > --- > drivers/power/supply/cpcap-charger.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/power/supply/cpcap-charger.c b/drivers/power/supply/cpcap-charger.c > index be7d1da7a5a5..3e5fbdbdd645 100644 > --- a/drivers/power/supply/cpcap-charger.c > +++ b/drivers/power/supply/cpcap-charger.c > @@ -650,6 +650,9 @@ static void cpcap_usb_detect(struct work_struct *work) > return; > } > > + /* Delay for 80ms to avoid vbus bouncing when usb cable is plugged in */ > + usleep_range(80000, 120000); > + > /* Throttle chrgcurr2 interrupt for charger done and retry */ > switch (ddata->status) { > case POWER_SUPPLY_STATUS_CHARGING: > -- > 2.29.2 >