Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp171200imd; Wed, 31 Oct 2018 16:45:22 -0700 (PDT) X-Google-Smtp-Source: AJdET5fIPQlVHDhoC95djizDeISwKbi4aiDUSmANRfpzqce4rWpn5UhLWJzU2EU+zl/SmNiGywqZ X-Received: by 2002:a17:902:bcc4:: with SMTP id o4-v6mr775528pls.13.1541029522225; Wed, 31 Oct 2018 16:45:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029522; cv=none; d=google.com; s=arc-20160816; b=hQ4FbUDGDA5QBJFZh0CSmNpDBsLfYpQXl5SXuLxn0unYLLXow551CHhczHydxAvdGA AEEzzhEsG++pXDnNsz2kY5i7RJO4cwkh8ABke03WiCZqh3AlGhqVH8I6O5u4wyU2PuNa mVccvgffXnmCVIR8V+AWOLs/MgOFyT+U6UTP3m16vOgssehXzBIEILzyhiNFMUQukCSA FsUumhpekAdTy4BhXn7K2s6mY4GrK8upvqPQZ/PjX/Xh6k0xJjGTUo2TBFlayLPxa2Ei rmXeyElNydQRaU40GZL61Xs9+Kwyc7kFFoRDmqurlgZU8rQiAFui9VhZJ5orZYJ9oTSQ W+Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Zbz0S9qfKmJ2Appy2QsWzPjf+O9M5NJoncYQH4pR0IA=; b=oqlUBu/kUkJKwOHmAR0qY09d6sH4pm2FcK1EL5XblEi4PUrtMV4lw343CT87j2U+de uInnEKB4wLq9GtRpdZx8zlc91qGxazAUlwr0f4HPMxSBP4c/RGDCvMo8Te+pzaN7ubcH cOQ2Xa8Q3kviQCsL7FLmWStNsJMSMi4bW/1JgklNY8nQSAFvZu4HMOnfV+QdAAQJkmHl m9+odPHYfuEzrpdmfQ5E9f3PVjX79fhVyIKaYMqDLaEoYj7PurS5zgF2n3sC1/RMODd3 WE2cpjwNlMVO7l4ooIEQnAd7FJw71BYtOvUV2dMtzeWibtQPmY8oxQQLf+U4aNxnLgoy PHhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SkouXhyA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 11-v6si11696935pfx.102.2018.10.31.16.45.07; Wed, 31 Oct 2018 16:45:22 -0700 (PDT) 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=SkouXhyA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728941AbeKAIHa (ORCPT + 99 others); Thu, 1 Nov 2018 04:07:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:55248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728910AbeKAIH1 (ORCPT ); Thu, 1 Nov 2018 04:07:27 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A098F20664; Wed, 31 Oct 2018 23:07:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027237; bh=5DtZcSmZG9IztKds472XsUbAvp/GumdUjArnKMyDNnw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SkouXhyAL1Z4vfwKseVMCjPIqPKc5DSGcqTUcRLmVQSG35+VBW8lMRWKzpfekloOG OBxJ7XwCZvP9EbeYyz7xBYD7SOVsoJABlmoT1ytA3TINIT1nFj5mY5JpYYBykxwqDN qMOTt5AkI4CDjixzxLnstapuAEpS488gBlxejUSY= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Adam Thomson , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 4.19 105/146] usb: typec: tcpm: Report back negotiated PPS voltage and current Date: Wed, 31 Oct 2018 19:05:00 -0400 Message-Id: <20181031230541.28822-105-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/usb/typec/tcpm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index 4f1f4215f3d6..18fb0433f59a 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -4116,6 +4116,9 @@ static int tcpm_pps_set_op_curr(struct tcpm_port *port, u16 op_curr) 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 tcpm_port *port, u16 out_volt) 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; -- 2.17.1