Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2545799pxj; Mon, 10 May 2021 05:37:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEQo6WLATumxb61FnLifN9c7juYydeJdaJH8qkpBcWnJRCDactI9bwK2rRX5n/QDWw1k2X X-Received: by 2002:a17:906:251a:: with SMTP id i26mr25722922ejb.367.1620650272533; Mon, 10 May 2021 05:37:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620650272; cv=none; d=google.com; s=arc-20160816; b=hmigHqPV29CV9jqjpkPawl29FoMbyUMF6YiYrntsxOr3ARYHrjT+9BZcwHTUz53lzI W2TYKsCMFScggOYxV0/SbGUr6mMzZx3JIkn07joFrMPy2K0a2SYqOOYl04je5un/NN/q UMThaUiR1lTH6GlAJSmihAE8k6V9D8COgn3ko7Gs3lmCKyN5S8SFMDIFqIF5zMOjImwf pX+ZNEThiK66CLR3wnv0mXKmXDVdUuAd6FDybXLQ6Tvm21ZywZCn66krq/GvjrhkzCS7 jgXSYK0Jw0OBGeLnDC+8gfdFEE3cmp2t7YDz2cspKCNV/IGPzVIzNdj0+4FDTpm5ixDS U2XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IGHn+1lujDu434fEYp5cNmlX4JVuIinBYLzOEk/fU94=; b=fFb6hrL0kTG2O0VEPgjgefbRmbgD/3n9CTv2Ax/QpxJNsHofKsgsjK65WaU+tdYwht MlSx7ZnJsVzVuztNbjUICVMuLlHBZGRNdY1xd5+TEUSITPhNRZ5o+4pKc4V72W3K1lgt gIUJAt6zJfzU8hrB4bj2tx0lP0z1zyEbqR2xHDQ6lG6hYXnj9bhfomVXKqYa1wZIRQ0c 7miWHTIw75iX1r2VstW+Oo3Fm8vpeZfVI82vENXiCGyms9/OSM9qzXIbIK6C3WzQzgvC DAB9GHzf7y9kh/LSy2faQG1DwKxKi77rcVaGA0Iw/TQv6LVhqybFDyRZTYqO5HUfU14P GjSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1GpFmcuy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n15si13456467edt.63.2021.05.10.05.37.28; Mon, 10 May 2021 05:37:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1GpFmcuy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243598AbhEJMYU (ORCPT + 99 others); Mon, 10 May 2021 08:24:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:46148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236984AbhEJLLH (ORCPT ); Mon, 10 May 2021 07:11:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0913561481; Mon, 10 May 2021 11:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620644766; bh=e0S2A85wlodek6a8G+QkbEFovBexDzqXvWqjCdQgf9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1GpFmcuy8BQj4kjoJsDFiol4hOWOoY2/gvFleSI1FzJ+FGPO2vlgBeyKoIF2j848P 85UBxPT0NYxE8X1WMxhJ+B0J6kPOGrnhljcTaemRjW2Md7q3XKlQeztKAINOMvxyXF NRuVa3dXRkpEKMnEoB042opbluTI9vakkYe3NDxI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Carl Philipp Klemm , Tony Lindgren , Sebastian Reichel , Sasha Levin Subject: [PATCH 5.12 215/384] power: supply: cpcap-charger: Add usleep to cpcap charger to avoid usb plug bounce Date: Mon, 10 May 2021 12:20:04 +0200 Message-Id: <20210510102021.975679809@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102014.849075526@linuxfoundation.org> References: <20210510102014.849075526@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Carl Philipp Klemm [ Upstream commit 751faedf06e895a17e985a88ef5b6364ffd797ed ] 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 Tested-by: Tony Lindgren Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- 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 3f06eb826ac2..2a8915c3e73e 100644 --- a/drivers/power/supply/cpcap-charger.c +++ b/drivers/power/supply/cpcap-charger.c @@ -668,6 +668,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.30.2