Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2483816pxj; Mon, 10 May 2021 04:11:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJws0FQP+lhhUn9eeF8qFiHnmWLyje0hfLxGC43MnlhXf8P6LnlWCAVjQBNsFsZDXurqcWPk X-Received: by 2002:a02:3505:: with SMTP id k5mr642620jaa.123.1620645116911; Mon, 10 May 2021 04:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620645116; cv=none; d=google.com; s=arc-20160816; b=JgsLWOiz/eNk3i0WJTq+zf4Q10MctkVqP4XXMw3aeBwm6po6nulV+bVgHUpvLI00H9 GicoTahJa5ru1V4K9dE3C1vI60JpHzZvfaMxQZ13JzoyWytVL9hBkXOMECX5pFFonS31 LPPlzqT7MVwlieX3luKlakPY/dKTySw2tUisDcE5DVw4AdGSkbYmmFuSMbAIOYjIsVNb ycHYFHz+0yiw0axqMSTTv2f9SugxeIBNOlXmp0C2k1njFDbqWXfvch3511psujDW01Cm EqhllYjA3k+gGnWUp78kFAIHjju7cjJFMkhJiV4+Cfm4FnbreVj9JbKswZTnn+fAbwIB JbTQ== 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=f+4hL39AmskwWMq9XEnK8uIcsLaYC9uLIvwj+z2NNxs=; b=r64lEj2N+1JZ8G7p1LO8RPfaj74pj5rt27uGISPIj9tC1F36RfP4a+/wNtplEaAbe9 eQm75lsjNq1+HaYg1xQ2y1LVVJj9cAgt88+o1Ua13blETtINCKArwtV9DGGJSiq0MBGc QMrYLi95QOnDzlrjvx1Kup2zUtzHN42Jex9cLqfEb4Fmcu/ywY9dzuTMff6mdbhkbR1j WHW1IfQGJzmqbIAIYlKR0wKCmZYJhh7X3tsHspp12ZG4T5gLw3KoF6cXHWOYTLQuLOPF zO23ICwluNxlts6fXKBFarouNkYkNgZo9vXlE6pB6Ao6oUzA4irVAwxrw9xPYe2foN5j fMrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cz8eroWL; 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 m13si14869114ilq.150.2021.05.10.04.11.44; Mon, 10 May 2021 04:11:56 -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=cz8eroWL; 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 S236994AbhEJLLH (ORCPT + 99 others); Mon, 10 May 2021 07:11:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:41652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233525AbhEJKuL (ORCPT ); Mon, 10 May 2021 06:50:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3C834619FE; Mon, 10 May 2021 10:39:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643156; bh=OwcsqU4PLySawmBUJfohkZ3H3aAEwZ96ZNnc4P1EYA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cz8eroWLhy1HzgVJfeRDRLcNbFOf8uef1ZkdOrglCzSooHHMJxrSgZXG7AtC9vkdl OzWA34XhBRnNShXA91Tg2Zodjcd6zzCLXAo4LOFPApy4shy0ZCnbhfNBHvQ8JKBUxX u6FqL9Qu+P815HYm5q2ZCFkCooZHntiF+COD524Q= 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.10 165/299] power: supply: cpcap-charger: Add usleep to cpcap charger to avoid usb plug bounce Date: Mon, 10 May 2021 12:19:22 +0200 Message-Id: <20210510102010.401939099@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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 22fff01425d6..891e1eb8e39d 100644 --- a/drivers/power/supply/cpcap-charger.c +++ b/drivers/power/supply/cpcap-charger.c @@ -633,6 +633,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->state) { case CPCAP_CHARGER_CHARGING: -- 2.30.2