Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3483780imu; Sun, 11 Nov 2018 16:08:20 -0800 (PST) X-Google-Smtp-Source: AJdET5eCUsZJxqgQwA6WqJ2KzWKoKPBIx4kp6GF/sEy6GtQtoAiYZgGAZCeuJNUZQ9WloTcJ2B1c X-Received: by 2002:a17:902:82ca:: with SMTP id u10-v6mr17198439plz.146.1541981300023; Sun, 11 Nov 2018 16:08:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981299; cv=none; d=google.com; s=arc-20160816; b=VOWPyCsBpjymmKueOkbfhFr+7lVkXqJXynrnZwqd7UZXMn5TBgiELgy05WQuW9iZfV 8Dy2eKn5CgrglqlDgOMlfoPTPcP3pA2wJKm/mlTLo0qS4SJRw33dFgFoYx4eCZoPdLXl fmcwOJ6HYAYFV1zeTWfsxJIYRl6QCsSXku0YHI4fGd07DTwPBALTjORJ+EI/ZiP03TFq nq1RtNSP5vvsmjzyWvZVIlDVhVhkedza6f1vuKlKi6sspBLdMrPw0/kfKFJO1ym1XApm 1Haa3tf5AHSLaauE2zF+vt8qHJcfG+gBUe854WOlCraZbbst7jdlRG1DMjaAA7XPMRL0 5fCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cWWbj5R/PszEbL+zV3S661iBZjoCZVb+1yI3H4wVWYs=; b=bb+g0OXhjmnMjkORH6XCdHaMI3IPigA4dAAm29WrGRdtC6Xf5uPG7400R50VrNu7Vi OCoTPSH6zmodq+tzsIK0Xv4+baylLZe4/nx5bzIXeymsW6jU9xs0DJWTe9hwIzqpceqa X4FDX1mXPwSjGEKjycOcshC61SXGMAKjtj//nqnTM1y476YEbm9zRxCmH72JAIjSWunc vRWXK6ZkR6MdrtDPtCyWCBhR8LeoOc91A8jWKMWSLP6aIWAeU9/4OA6Ho62rg5lVkBbl VpRveGYjFBoX4b6UXdXefn6fLJ5HPur7u9Rk7FQGzvhI/jPJf5EMvhIletBt/ZGpBsds ILOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NsLF2NwN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r28si12490188pgm.317.2018.11.11.16.08.04; Sun, 11 Nov 2018 16:08:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NsLF2NwN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731835AbeKLIRj (ORCPT + 99 others); Mon, 12 Nov 2018 03:17:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:60706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731800AbeKLIRi (ORCPT ); Mon, 12 Nov 2018 03:17:38 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C9B7921707; Sun, 11 Nov 2018 22:27:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975262; bh=Fm3KG6YbiNcpA/X3oEb4WPEJhZvWPUP+Qzv1ofDXmhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NsLF2NwNQIdVz2B2HqrT5sBxNKY/i0DqFRzfGd9i6/E2lkhamYi0UGeWhBG/25COe KwRUKrYaiAaeuavWYUbw2ZnXrriEcMkOGdA8KTcJ6rRZEuT/4aUp1xPX/akucfu4HI 4qyOoHWyNjwVWYDRznwabOn/ayDEC1NYvhTeMN5I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adam Thomson , Guenter Roeck , Sasha Levin Subject: [PATCH 4.19 150/361] usb: typec: tcpm: Report back negotiated PPS voltage and current Date: Sun, 11 Nov 2018 14:18:17 -0800 Message-Id: <20181111221641.420051557@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Adam Thomson [ Upstream commit 554fab6dbf20ee7298ed2d4e8398b85e6058abb7 ] Currently when requesting a specific voltage or current through the psy interface, for PPS, when reading back from that interface the values will always be the same as previously given, if the request was successful. However PPS only allows for 20mV voltage steps and 50mA current steps, and the psy class expects microvolt and micro amp requests, so inbetween values can be provided through this interface. Really when reading back the true values negotiated should be given, and not the ones originally asked for. To report the actual values negotiated with the Source, the values stored are now rounded down to the relevant step units prior to building the PPS request, so that those values are later correctly reported through the psy interface. In addition this improves the adjustments made to meet the operating power requirements of the platform, which previously could have been slightly out due to not using valid PPS units of voltage and current. Signed-off-by: Adam Thomson Reviewed-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -4116,6 +4116,9 @@ static int tcpm_pps_set_op_curr(struct t goto port_unlock; } + /* Round down operating current to align with PPS valid steps */ + op_curr = op_curr - (op_curr % RDO_PROG_CURR_MA_STEP); + reinit_completion(&port->pps_complete); port->pps_data.op_curr = op_curr; port->pps_status = 0; @@ -4169,6 +4172,9 @@ static int tcpm_pps_set_out_volt(struct goto port_unlock; } + /* Round down output voltage to align with PPS valid steps */ + out_volt = out_volt - (out_volt % RDO_PROG_VOLT_MV_STEP); + reinit_completion(&port->pps_complete); port->pps_data.out_volt = out_volt; port->pps_status = 0;