From patchwork Sat Sep 18 12:09:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12503799 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 B3DFBC4332F for ; Sat, 18 Sep 2021 12:10:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 961FF61350 for ; Sat, 18 Sep 2021 12:10:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239671AbhIRMLs (ORCPT ); Sat, 18 Sep 2021 08:11:48 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:39437 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239578AbhIRMLR (ORCPT ); Sat, 18 Sep 2021 08:11:17 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 23539580A6A; Sat, 18 Sep 2021 08:09:54 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sat, 18 Sep 2021 08:09:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=cEal9g6XjUtTf /+blnFGD/0r9W4KfOLAKJXx/OVMfPQ=; b=O+X8MSeJQ7T73PWHX8toq+IPO4nFg WfwR41ARq4KH3Rr8fPnMMcOENkIWzd6H/EKNe1Ry1J3JROZwF0pOu78mLkOirKGs 6XtOfsOUrDyRTxHDuAKDm1vX0why6ghheIMHkbJnNLkWi/Z6ExAP3yf5VoPeIfHr Vs719+Ipe/T0PoGmncNB4SGIbTof9ONaVBtQDRCG8ZOAgV7Js2xOWLz0i1MO7RFD PRCW68avx+TXhItG/yZwFwb/Bo4yg2/Px7D7DEdugJ16ckmG7eZnDWaIXarZLGM1 FFyV2OnuOMvUjZYQXUrV3nN3BQpDFfr+rcbN/PPY3yiTyzm5R/GvcQciA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=cEal9g6XjUtTf/+blnFGD/0r9W4KfOLAKJXx/OVMfPQ=; b=JtRfETVR h4pm5y4JfhIv+BCoiBsNT3kDv9VPyw0YwKIufgMyYFiuvaxsW5gNI6TNDZfUeEdP 3uovH03RccqIPQb66yxIF1g/n7KD8zp9g92AE+KpRxdAtWsNv6fzXWmRqHx5RZn/ s9Lj7BGXyVa6jgDPSJb9FjxI2WUb7T4BqGgo2ovq4YwFTNIFA8V1dzyk5YZ37VMH cWw1Io+5sda0pTxcSsrPAl7dgR0KX5tt4zxecxavm1OVMTdX3w2kjMjs2r03e+WM RPv9wnxlrSBIuujNLfv5f/fSgCYzta1DwclDP6rwlN6w/VbW5/X8lOo3JHeYoqjg 7LhdjGqlC4kVNQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudehkedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 18 Sep 2021 08:09:52 -0400 (EDT) From: Sven Peter To: Heikki Krogerus , Greg Kroah-Hartman , "Bryan O'Donoghue" Cc: Sven Peter , =?utf-8?q?Guido_G=C3=BCnther?= , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alexander Graf , Alyssa Rosenzweig , Rob Herring , devicetree@vger.kernel.org Subject: [RFT PATCH 1/9] dt-bindings: usb: tps6598x: Add Apple CD321x compatible Date: Sat, 18 Sep 2021 14:09:26 +0200 Message-Id: <20210918120934.28252-2-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210918120934.28252-1-sven@svenpeter.dev> References: <20210918120934.28252-1-sven@svenpeter.dev> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org A variant of the TI TPS 6598x Type-C Port Switch and Power Delivery controller known as Apple CD321x is present on boards with Apple SoCs such as the M1. Add its compatible to the device tree binding. Signed-off-by: Sven Peter Reviewed-by: Alyssa Rosenzweig Acked-by: Rob Herring --- Documentation/devicetree/bindings/usb/ti,tps6598x.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml b/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml index f6819bf2a3b5..a4c53b1f1af3 100644 --- a/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml +++ b/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml @@ -12,10 +12,14 @@ maintainers: description: | Texas Instruments 6598x Type-C Port Switch and Power Delivery controller + A variant of this controller known as Apple CD321x or Apple ACE is also + present on hardware with Apple SoCs such as the M1. + properties: compatible: enum: - ti,tps6598x + - apple,cd321x reg: maxItems: 1 From patchwork Sat Sep 18 12:09:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12503801 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 6989CC433F5 for ; Sat, 18 Sep 2021 12:10:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E7B16127B for ; Sat, 18 Sep 2021 12:10:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233056AbhIRMLt (ORCPT ); Sat, 18 Sep 2021 08:11:49 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:48365 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239714AbhIRMLU (ORCPT ); Sat, 18 Sep 2021 08:11:20 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 45E89580A72; Sat, 18 Sep 2021 08:09:56 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sat, 18 Sep 2021 08:09:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=Zl0M3noJyP6W0 KWYI2clzOswdVoMc4ztCazBkMGp5No=; b=FqDnVrrOY94i3k7empvp2H8Zh+a7R eKm1SUBH3IHi5L9q7fg++nNC8r1lCfvJoSyJUUV0gVf8nLBERaBdIq7Ng8Zm7GrE ixzjevx14T/7m4EuqkzJoN8eRsHI4RSvemDcOz1psXGXR8vJSKKodPoZyOZdfAv4 3XLiPYok/d8YWx3t7PAPHhZ5K/YHS1YS+WZ8GtZErzLDF5WUaoFh6XX9VEp0bR9d LQzq3P6g4W/7MKQTLweKDz+iSolPm2QO0LsdpcvOPaCftgo+47DZMahyIUP98BeK 3YffI0Uv9X50fTG20d3OMgap5rp6AKVy61O2TgDRiF6FytS4+hasmjCnw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=Zl0M3noJyP6W0KWYI2clzOswdVoMc4ztCazBkMGp5No=; b=Cod01H4i XEezzDI0TfylfE+iJvRnxiGeOKSuNGhSbn7AudHQhhVwVEypGMGwlefNQgUXWPdc eFgNYNGcRHJ9qxTVee81JKtdjTyVRYNQSnW+A7igCskXvaJrLMVa3QkEB202CfF+ hKiM2l3miLiRjkQgDyBEVLayYlEoLITrK1g7HVEkrNB6CnPVx6TwoSRp/baUi1aA DjBeGscJuM3A2nGy6FNFUOC7SRmue4gkZJq+VYIHFa9ClwmCcxic5A5q3S1AB+3i lrDZd5f+ZPwAxvO6djq8ha8WavnSAj6LT0xfT65+A5AHuuWJ/isGk4dOG6JxXSiO 4gyP+le49fbniQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudehkedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 18 Sep 2021 08:09:54 -0400 (EDT) From: Sven Peter To: Heikki Krogerus Cc: Sven Peter , Greg Kroah-Hartman , =?utf-8?q?Guido_G=C3=BCnth?= =?utf-8?q?er?= , "Bryan O'Donoghue" , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alexander Graf , Alyssa Rosenzweig Subject: [RFT PATCH 2/9] usb: typec: tipd: Prepare supporting different variants Date: Sat, 18 Sep 2021 14:09:27 +0200 Message-Id: <20210918120934.28252-3-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210918120934.28252-1-sven@svenpeter.dev> References: <20210918120934.28252-1-sven@svenpeter.dev> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Apple M1 machines come with a variant of the TI TPS6598x and will need some changes to the current logic. Let's prepare for that by setting up the infrastructure required to support different variants of this chip identified by the DT compatible. Signed-off-by: Sven Peter Reviewed-by: Alyssa Rosenzweig --- drivers/usb/typec/tipd/core.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 21b3ae25c76d..656020e7f533 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -76,6 +77,10 @@ static const char *const modes[] = { /* Unrecognized commands will be replaced with "!CMD" */ #define INVALID_CMD(_cmd_) (_cmd_ == 0x444d4321) +struct tps6598x_hw { +}; +static const struct tps6598x_hw ti_tps6598x_data; + struct tps6598x { struct device *dev; struct regmap *regmap; @@ -91,6 +96,8 @@ struct tps6598x { struct power_supply *psy; struct power_supply_desc psy_desc; enum power_supply_usb_type usb_type; + + const struct tps6598x_hw *hw; }; static enum power_supply_property tps6598x_psy_props[] = { @@ -590,6 +597,13 @@ static int tps6598x_probe(struct i2c_client *client) if (!tps) return -ENOMEM; + if (client->dev.of_node) + tps->hw = of_device_get_match_data(&client->dev); + else + tps->hw = &ti_tps6598x_data; + if (!tps->hw) + return -EINVAL; + mutex_init(&tps->lock); tps->dev = &client->dev; @@ -729,8 +743,11 @@ static int tps6598x_remove(struct i2c_client *client) return 0; } +static const struct tps6598x_hw ti_tps6598x_data = { +}; + static const struct of_device_id tps6598x_of_match[] = { - { .compatible = "ti,tps6598x", }, + { .compatible = "ti,tps6598x", .data = &ti_tps6598x_data }, {} }; MODULE_DEVICE_TABLE(of, tps6598x_of_match); From patchwork Sat Sep 18 12:09:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12503803 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 A3B18C433EF for ; Sat, 18 Sep 2021 12:10:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 87AEE61283 for ; Sat, 18 Sep 2021 12:10:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239618AbhIRMLu (ORCPT ); Sat, 18 Sep 2021 08:11:50 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:53365 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239751AbhIRMLV (ORCPT ); Sat, 18 Sep 2021 08:11:21 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 383BD580A87; Sat, 18 Sep 2021 08:09:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sat, 18 Sep 2021 08:09:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=iRhxHP0o3O6O0 kpyjR8ydrO7q+v1pFew5P5vbcKQk4E=; b=tMs2+3hL8eoQadMa46O+VG1je91LI gHYkYY1NcrauMJ1hu5iVnF3aIecRUS1iYrJw2YYKqVWTqazDzM4TY92n6J3ck5u+ 3Qh2YDQ1hmyDmkmDsGooAGrWad1SnwvyPQIUsBDyZ5fHoJbPXsU2gUWrjUdELmHL CKQbPx1eI1wfPQQLOPhscClhc7adTqyvMRe0mGcjrZipfLHo2VU5sVW73Ui+WksF 5uRxRYp951RcGN0yrVN4Ptjt/mposgcT15VpCc757sfW8zClyDysJTzaXQUUdU+q OJYFslIsGpAg0mvzOxlu0Q9qmkyN1HbL+uX66a4p6+ayuIwncnRsGc6Dg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=iRhxHP0o3O6O0kpyjR8ydrO7q+v1pFew5P5vbcKQk4E=; b=mnHGxbTA U5Rg5877t7PfnUof/f5TV6Sp0b0IQZeko6onuPRnklZLWYwFtcMCdxiQLg1g1WR6 RiTRWKSvJwBzky8aA4umL1ICHIoQ17bsApDXXNkOzTekdEH/y7Yl+iRPBMecImpG 9xoVpr/5rKKrxm6iPQpnWEPHEAODbOSl2aozc7s0/gcq2ZyBhpoPGA5NJrb8PRXg EFLYAmNVTNoOu1mF7VbyzWv7fMjV6Dr4ddQNEJb7mwuGtep/iD4JVoRFpAPlySvY VH6fYzTBmCHv4LK0+/zwQkeKlJneTQCc0mL49OzFVWCD1/KE9fGYdEoVmn39zAJx ta93YyMKVIHFSw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudehkedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 18 Sep 2021 08:09:56 -0400 (EDT) From: Sven Peter To: Heikki Krogerus Cc: Sven Peter , Greg Kroah-Hartman , =?utf-8?q?Guido_G=C3=BCnth?= =?utf-8?q?er?= , "Bryan O'Donoghue" , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alexander Graf , Alyssa Rosenzweig Subject: [RFT PATCH 3/9] usb: typec: tipd: Allow irq controller selection Date: Sat, 18 Sep 2021 14:09:28 +0200 Message-Id: <20210918120934.28252-4-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210918120934.28252-1-sven@svenpeter.dev> References: <20210918120934.28252-1-sven@svenpeter.dev> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org TI TPS6598x chips come with two separate i2c buses which each have an independent interrupt controller. When only a single controller is connected both can just be used. On Apple M1 machines the secondary bus is however connected to the system management controller and we must not modify its configuration. Prepare for that by allowing to chose which interrupt controller(s) are used. Signed-off-by: Sven Peter Reviewed-by: Alyssa Rosenzweig --- drivers/usb/typec/tipd/core.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 656020e7f533..c2c399722c37 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -78,6 +78,8 @@ static const char *const modes[] = { #define INVALID_CMD(_cmd_) (_cmd_ == 0x444d4321) struct tps6598x_hw { + bool use_int1; + bool use_int2; }; static const struct tps6598x_hw ti_tps6598x_data; @@ -411,22 +413,28 @@ static const struct typec_operations tps6598x_ops = { static irqreturn_t tps6598x_interrupt(int irq, void *data) { struct tps6598x *tps = data; - u64 event1; - u64 event2; + u64 event1 = 0; + u64 event2 = 0; + u64 event = 0; u32 status, data_status; u16 pwr_status; int ret; mutex_lock(&tps->lock); - ret = tps6598x_read64(tps, TPS_REG_INT_EVENT1, &event1); - ret |= tps6598x_read64(tps, TPS_REG_INT_EVENT2, &event2); + ret = 0; + if (tps->hw->use_int1) + ret |= tps6598x_read64(tps, TPS_REG_INT_EVENT1, &event1); + if (tps->hw->use_int2) + ret |= tps6598x_read64(tps, TPS_REG_INT_EVENT2, &event2); if (ret) { dev_err(tps->dev, "%s: failed to read events\n", __func__); goto err_unlock; } trace_tps6598x_irq(event1, event2); + event = event1 | event2; + ret = tps6598x_read32(tps, TPS_REG_STATUS, &status); if (ret) { dev_err(tps->dev, "%s: failed to read status\n", __func__); @@ -434,7 +442,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data) } trace_tps6598x_status(status); - if ((event1 | event2) & TPS_REG_INT_POWER_STATUS_UPDATE) { + if (event & TPS_REG_INT_POWER_STATUS_UPDATE) { ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, &pwr_status); if (ret < 0) { dev_err(tps->dev, "failed to read power status: %d\n", ret); @@ -443,7 +451,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data) trace_tps6598x_power_status(pwr_status); } - if ((event1 | event2) & TPS_REG_INT_DATA_STATUS_UPDATE) { + if (event & TPS_REG_INT_DATA_STATUS_UPDATE) { ret = tps6598x_read32(tps, TPS_REG_DATA_STATUS, &data_status); if (ret < 0) { dev_err(tps->dev, "failed to read data status: %d\n", ret); @@ -453,7 +461,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data) } /* Handle plug insert or removal */ - if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT) { + if (event & TPS_REG_INT_PLUG_EVENT) { if (status & TPS_STATUS_PLUG_PRESENT) { ret = tps6598x_connect(tps, status); if (ret) @@ -465,8 +473,10 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data) } err_clear_ints: - tps6598x_write64(tps, TPS_REG_INT_CLEAR1, event1); - tps6598x_write64(tps, TPS_REG_INT_CLEAR2, event2); + if (tps->hw->use_int1) + tps6598x_write64(tps, TPS_REG_INT_CLEAR1, event1); + if (tps->hw->use_int2) + tps6598x_write64(tps, TPS_REG_INT_CLEAR2, event2); err_unlock: mutex_unlock(&tps->lock); @@ -744,6 +754,8 @@ static int tps6598x_remove(struct i2c_client *client) } static const struct tps6598x_hw ti_tps6598x_data = { + .use_int1 = true, + .use_int2 = true, }; static const struct of_device_id tps6598x_of_match[] = { From patchwork Sat Sep 18 12:09:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12503805 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 1F917C433F5 for ; Sat, 18 Sep 2021 12:10:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00A3E61354 for ; Sat, 18 Sep 2021 12:10:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239775AbhIRMLv (ORCPT ); Sat, 18 Sep 2021 08:11:51 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:51017 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235075AbhIRMLY (ORCPT ); Sat, 18 Sep 2021 08:11:24 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 88CD5580A89; Sat, 18 Sep 2021 08:10:00 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sat, 18 Sep 2021 08:10:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=43QUIQl/3S9/J FKbD85BT0gzw5E/ho94fIt2sDWG2Ig=; b=FSfomUJGxWDbhKXQmFClCILkUn/Wu bpxyEUuk6JwhLWYQALigYVPtyF2pjI3i8GgZwkxL9K4+TAFfJ0AyJ0mk+R5mDTek KCw+P9iAGPrusWb3Xfen5jcTG96EZ0Wk7WBEv2o49fHCVUk6QLpzhFKVGRTuPvLx qP1NBeuYmMJMwnxC4uGxLJxqknSwzJafPk5UTD5QwcNVX4S9L6j5+h5XZqnmhV5X 4eaM+yuZ6PRkQQofjWg1kK8BMGvUgSrn4gp9MGlnzjZr0hA66LA4JGSBqiTDgh20 pQyheZTJeAkAUu+X6hJH33z0kOcbX2NTwMddwgTPs0cpWdoLaTQ5ob86w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=43QUIQl/3S9/JFKbD85BT0gzw5E/ho94fIt2sDWG2Ig=; b=Tw1kVD/m LjOd5k+PE7Oi08ub93wDH5TRkY8BROaPk35/3bC90up82oGAGwQTZqMiFR9NCLwh o4bqQtweRODXnVS5GvZPEBhAwNNamY50cbHR2pj+BjWAdWgd4o6jIIjEaBVyq5HA YwqM7dDGGtcHKkt85zMlC69ktiDlTPormBkO99mlYDVkc+Swv6DsYoPmaU8nzFdM fVkSrxRn1jlYu3VIqmZF4FtttPkxea6cOZFFAmGLOhHX72TvC78gfCPdiph35jG4 uDFOH6dDmhNC5aR1kwfuMeOBhTpMuC+7YNL29G2YmtXXSMrzSljQI21QGTHtOkJB F4wnwl9z3KOjgA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudehkedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 18 Sep 2021 08:09:58 -0400 (EDT) From: Sven Peter To: Heikki Krogerus Cc: Sven Peter , Greg Kroah-Hartman , =?utf-8?q?Guido_G=C3=BCnth?= =?utf-8?q?er?= , "Bryan O'Donoghue" , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alexander Graf , Alyssa Rosenzweig Subject: [RFT PATCH 4/9] usb: typec: tipd: Add short-circuit for no irqs Date: Sat, 18 Sep 2021 14:09:29 +0200 Message-Id: <20210918120934.28252-5-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210918120934.28252-1-sven@svenpeter.dev> References: <20210918120934.28252-1-sven@svenpeter.dev> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org If no interrupts are set in IntEventX directly skip to the end of the interrupt handler and return IRQ_NONE instead of IRQ_HANDLED. This possibly allows to detect spurious interrupts if the i2c bus is fast enough. Signed-off-by: Sven Peter Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tipd/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index c2c399722c37..4a6d66250fef 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -434,6 +434,8 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data) trace_tps6598x_irq(event1, event2); event = event1 | event2; + if (!event) + goto err_unlock; ret = tps6598x_read32(tps, TPS_REG_STATUS, &status); if (ret) { @@ -481,7 +483,9 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data) err_unlock: mutex_unlock(&tps->lock); - return IRQ_HANDLED; + if (event) + return IRQ_HANDLED; + return IRQ_NONE; } static int tps6598x_check_mode(struct tps6598x *tps) From patchwork Sat Sep 18 12:09:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12503815 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 8349AC433F5 for ; Sat, 18 Sep 2021 12:10:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65E4260F51 for ; Sat, 18 Sep 2021 12:10:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244286AbhIRMMD (ORCPT ); Sat, 18 Sep 2021 08:12:03 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:34667 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236620AbhIRMLq (ORCPT ); Sat, 18 Sep 2021 08:11:46 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id BBCC8580A8B; Sat, 18 Sep 2021 08:10:02 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sat, 18 Sep 2021 08:10:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=aMQfqmJ3dKPGx spm3ASGg7int5qQFUsrLE46xAC0S2k=; b=L61ikF//r9bmQ0GNivc+4qcq+m6zA HJ7MtvS1ncS5FWMaSPSYHje7Qqy87fMn4uPuv4wgGsnTg9D3SVeFzpYcDva2z8/P xzg6gEBfyYyTOCIuJ2F/brtYAmKwugnQ5S1ihnCzUhieBBJclGfzZVCNfvMfJ3ZJ eJjVZ/219IC+v1oZ24I2OVIMp2OAzz7O87PkmAKe2nK20uP6FsqAeTUGsRTqGs2v OVVrtA9+v+ZM5DMwGcByFv5MgPvszkVWpPRKq/VSHBpInrvOkgHN/XHgZrU4zfXk xIt510mFNCy49inGrlPkcEeiyAe2IOWheoOpjXSwflfkWnTuk9ZX5SmIg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=aMQfqmJ3dKPGxspm3ASGg7int5qQFUsrLE46xAC0S2k=; b=lnYzo8od vQRfUpxvNiXFaR5s96VlzC6oHdQTlhAJWLeud0wMp4Ywih4i0l0fw2QEKON1TlVv drqFBRJQewi4BuzcZmS8mfUv91Xx6pza0NarW0KtLeduaGGIMmaU+LTFK2e9oaEd Z6HXmK/xs1DJON5eAVI+2XV1pti2f0mFkIzKWcVlGs2TgnApJF8eT4pyPCBcUSum U5LVBZCcXfPhb7eXX6/FmgfHCVowxL0a+mRNd5YoqRPGrGfkZ4EPqjAw09s9Slqk lq5+QkcHUnxgB0i1Ny8r9glhB+2FjPgXC0f1VQqOsjZZuhAegENyE19o1u7L2Fj3 coJv3SO5SwwQFw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudehkedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 18 Sep 2021 08:10:00 -0400 (EDT) From: Sven Peter To: Heikki Krogerus Cc: Sven Peter , Greg Kroah-Hartman , =?utf-8?q?Guido_G=C3=BCnth?= =?utf-8?q?er?= , "Bryan O'Donoghue" , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alexander Graf , Alyssa Rosenzweig Subject: [RFT PATCH 5/9] usb: typec: tipd: Allow to configure irq bits Date: Sat, 18 Sep 2021 14:09:30 +0200 Message-Id: <20210918120934.28252-6-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210918120934.28252-1-sven@svenpeter.dev> References: <20210918120934.28252-1-sven@svenpeter.dev> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The Apple variant of the TI TPS6598x chip uses different interrupt numbers. Prepare for that by allowing those to be configured depending on the compatible. Signed-off-by: Sven Peter --- drivers/usb/typec/tipd/core.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 4a6d66250fef..d191e7435018 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -80,6 +80,10 @@ static const char *const modes[] = { struct tps6598x_hw { bool use_int1; bool use_int2; + unsigned int irq_power_status_update; + unsigned int irq_data_status_update; + unsigned int irq_plug_event; + void (*irq_trace)(u64 event1, u64 event2); }; static const struct tps6598x_hw ti_tps6598x_data; @@ -431,7 +435,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data) dev_err(tps->dev, "%s: failed to read events\n", __func__); goto err_unlock; } - trace_tps6598x_irq(event1, event2); + tps->hw->irq_trace(event1, event2); event = event1 | event2; if (!event) @@ -444,7 +448,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data) } trace_tps6598x_status(status); - if (event & TPS_REG_INT_POWER_STATUS_UPDATE) { + if (event & tps->hw->irq_power_status_update) { ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, &pwr_status); if (ret < 0) { dev_err(tps->dev, "failed to read power status: %d\n", ret); @@ -453,7 +457,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data) trace_tps6598x_power_status(pwr_status); } - if (event & TPS_REG_INT_DATA_STATUS_UPDATE) { + if (event & tps->hw->irq_data_status_update) { ret = tps6598x_read32(tps, TPS_REG_DATA_STATUS, &data_status); if (ret < 0) { dev_err(tps->dev, "failed to read data status: %d\n", ret); @@ -463,7 +467,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data) } /* Handle plug insert or removal */ - if (event & TPS_REG_INT_PLUG_EVENT) { + if (event & tps->hw->irq_plug_event) { if (status & TPS_STATUS_PLUG_PRESENT) { ret = tps6598x_connect(tps, status); if (ret) @@ -760,6 +764,10 @@ static int tps6598x_remove(struct i2c_client *client) static const struct tps6598x_hw ti_tps6598x_data = { .use_int1 = true, .use_int2 = true, + .irq_power_status_update = TPS_REG_INT_POWER_STATUS_UPDATE, + .irq_data_status_update = TPS_REG_INT_DATA_STATUS_UPDATE, + .irq_plug_event = TPS_REG_INT_PLUG_EVENT, + .irq_trace = trace_tps6598x_irq, }; static const struct of_device_id tps6598x_of_match[] = { From patchwork Sat Sep 18 12:09:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12503809 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 172BFC433FE for ; Sat, 18 Sep 2021 12:10:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0204D60F51 for ; Sat, 18 Sep 2021 12:10:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239415AbhIRML4 (ORCPT ); Sat, 18 Sep 2021 08:11:56 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:58109 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236698AbhIRMLr (ORCPT ); Sat, 18 Sep 2021 08:11:47 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id D0DDD580AA0; Sat, 18 Sep 2021 08:10:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Sat, 18 Sep 2021 08:10:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=7EC26pNkFUOEe vhoWNPRSgdTWMwHLt1pj4bP1NJMakM=; b=hUUL3t3I/5uBIMQTuE6/4O+iR1Ohh YL5pc0Cd3FuYlOKtOw3lUH74YGsdbVjWGoT2P6fkRMaEktTTAkXPNmrhcj4ougWv +4WLL92wP2CQSWJa7u31TweCGu/oCvfP2xyCa+c+XZRUc/TQNs8m19lIkOyt3rAK 0vM+coIA3CWN7lZnNmH+A66tdpxsn5fCFvfX/qd7000aR5h9qitzw9WjeajXfhGC iy+gXXepgirtwN93XJnuxAMTaa+nyWMBspuBGk+GpOT4xMtMt/0b4k0bisItauHZ VAM+cxHza0dC89y4E2762auiUKkueLJqdcckwF9qJtengRfxykn+OCtNw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=7EC26pNkFUOEevhoWNPRSgdTWMwHLt1pj4bP1NJMakM=; b=t2mzvL8p HAutOtz5LQ9GqO7OEfbhS1XoUeJP0nShmDqTK90lx7nuhSlWCs725rSsRt/1ScZ4 pl9vB+Yok1Vn0BJ8WlDkcpI9UT0Y1HWN0dJGs0ucUnXUM0EGXIksX+sTlr42myn3 33YiUA8VkShucnBVSV4urieugLdJhNPOJfQI67pBuf9YNq5G+9+PpMdl+ngWtmZg 8De3mwo2wYdduHHkZ2Be9iySXnlYCezBHORJaEx0OQ6T1QlLrrLUTtK3ZU3X/Uyn 2Fnn9Z5A9q2kspv2aax5FUf1OqeeqG/pSt5Z37i4NaOr6rjJ114tnPLJ4TnqpsZS y1ZPRlT216ngsA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudehkedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 18 Sep 2021 08:10:02 -0400 (EDT) From: Sven Peter To: Heikki Krogerus Cc: Sven Peter , Greg Kroah-Hartman , =?utf-8?q?Guido_G=C3=BCnth?= =?utf-8?q?er?= , "Bryan O'Donoghue" , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alexander Graf , Alyssa Rosenzweig Subject: [RFT PATCH 6/9] usb: typec: tipd: Setup IntMask explicitly Date: Sat, 18 Sep 2021 14:09:31 +0200 Message-Id: <20210918120934.28252-7-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210918120934.28252-1-sven@svenpeter.dev> References: <20210918120934.28252-1-sven@svenpeter.dev> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Right now the code relies on the bootloader to set up the interrupt mask correctly. This usually works but let's make sure to do it explicitly to guarantee it will always work. Signed-off-by: Sven Peter --- drivers/usb/typec/tipd/core.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index d191e7435018..2058e8cca631 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -728,6 +728,24 @@ static int tps6598x_probe(struct i2c_client *client) dev_err(&client->dev, "failed to register partner\n"); } + if (tps->hw->use_int1) { + ret = tps6598x_write64(tps, TPS_REG_INT_MASK1, + tps->hw->irq_power_status_update | + tps->hw->irq_data_status_update | + tps->hw->irq_plug_event); + if (ret) + goto err_role_put; + } + + if (tps->hw->use_int2) { + ret = tps6598x_write64(tps, TPS_REG_INT_MASK2, + tps->hw->irq_power_status_update | + tps->hw->irq_data_status_update | + tps->hw->irq_plug_event); + if (ret) + goto err_role_put; + } + ret = devm_request_threaded_irq(&client->dev, client->irq, NULL, tps6598x_interrupt, IRQF_SHARED | IRQF_ONESHOT, From patchwork Sat Sep 18 12:09:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12503813 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 9A8F7C4332F for ; Sat, 18 Sep 2021 12:10:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 823B460F51 for ; Sat, 18 Sep 2021 12:10:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241208AbhIRMMC (ORCPT ); Sat, 18 Sep 2021 08:12:02 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:43569 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239663AbhIRMLr (ORCPT ); Sat, 18 Sep 2021 08:11:47 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id C5A3C580AA9; Sat, 18 Sep 2021 08:10:06 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sat, 18 Sep 2021 08:10:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=y9rOI/pQW3cZW IrfzVD6SZvXz7mjEgJOkBwidzpAln8=; b=dAXg6zkFdhDPJgsSJJlhedcnXOtTh rJLRxNRcsDczpgbKh9k0gtEMttPLut962ZE8I4wHOTo5BNtzBlQ1NG+djj/y/aLF PzisQXS42CptOSO2v7JP1kCT9Av3ptKZ1QjTl+VpItHCYKGuv3PAlcAabngYXCq4 4rLGKap5qyMOxwg3I7VDTgZs0d97JyAPz8+/kxOkMTiaNM8bJuWAF2p2VQ6CIGiQ jnZ5IrbtIe1MuOoJMLB8SKKhJc6DT8aDAPfncqVEIyLXk780mdB9pUiolTugQvc0 F4/GzOsHUGQxq+StUJquSOxtXRraPcr7F3TaN3I6j8evJ01hkCcb0H40g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=y9rOI/pQW3cZWIrfzVD6SZvXz7mjEgJOkBwidzpAln8=; b=wEhpyerK tf73vMvPMmBzW2AWjccTGInw5JZNjnjagYr6sMUdsKxsSUtEjksa9FwY0zh2yQoU CgV2DRD69KVrbrljuLAVxUOZd7hte6ge/0K3TCJz8/1bvVhZikESkJabMInh3Ivl qUfdApBYjYqKM2smq7nQA3ehXc+vFo3EIHUy2ci4cda7zGdci6lSdN/fp7mtpBcw 5ixw22vPD08gO3JaIHkzCupBw8CmZtQHbciNvHBE3v5YiQSL2uTBg4gL3APwwCPL as93/ERPiFX6xMJJCx9wU/1VRGtHCWb6fHC+YUS+YSAo9qkhllB2TJKkbcZefRIt YKm4PTHcnVTfGQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudehkedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 18 Sep 2021 08:10:04 -0400 (EDT) From: Sven Peter To: Heikki Krogerus Cc: Sven Peter , Greg Kroah-Hartman , =?utf-8?q?Guido_G=C3=BCnth?= =?utf-8?q?er?= , "Bryan O'Donoghue" , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alexander Graf , Alyssa Rosenzweig Subject: [RFT PATCH 7/9] usb: typec: tipd: Add support for apple,cd321x Date: Sat, 18 Sep 2021 14:09:32 +0200 Message-Id: <20210918120934.28252-8-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210918120934.28252-1-sven@svenpeter.dev> References: <20210918120934.28252-1-sven@svenpeter.dev> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org After all the preparations in the previous commits we can now finally add support for the Apple CD321x chip which is a variant of the TI TPS 6598x chip. The major differences are the changed interrupt numbers and the concurrent connection to the SMC which we must not disturb. Signed-off-by: Sven Peter Reviewed-by: Alyssa Rosenzweig --- drivers/usb/typec/tipd/core.c | 10 ++++++++++ drivers/usb/typec/tipd/tps6598x.h | 6 ++++++ drivers/usb/typec/tipd/trace.h | 27 +++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 2058e8cca631..e96b17fe6af6 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -788,8 +788,18 @@ static const struct tps6598x_hw ti_tps6598x_data = { .irq_trace = trace_tps6598x_irq, }; +static const struct tps6598x_hw apple_cd321x_data = { + .use_int1 = true, + .use_int2 = false, + .irq_power_status_update = APPLE_TPS_REG_INT_POWER_STATUS_UPDATE, + .irq_data_status_update = APPLE_TPS_REG_INT_DATA_STATUS_UPDATE, + .irq_plug_event = APPLE_TPS_REG_INT_PLUG_EVENT, + .irq_trace = trace_cd321x_irq, +}; + static const struct of_device_id tps6598x_of_match[] = { { .compatible = "ti,tps6598x", .data = &ti_tps6598x_data }, + { .compatible = "apple,cd321x", .data = &apple_cd321x_data }, {} }; MODULE_DEVICE_TABLE(of, tps6598x_of_match); diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index 003a577be216..36b482733297 100644 --- a/drivers/usb/typec/tipd/tps6598x.h +++ b/drivers/usb/typec/tipd/tps6598x.h @@ -129,6 +129,12 @@ #define TPS_REG_INT_HARD_RESET BIT(1) #define TPS_REG_INT_PD_SOFT_RESET BIT(0) +/* Apple-specific TPS_REG_INT_* bits */ +#define APPLE_TPS_REG_INT_DATA_STATUS_UPDATE BIT(10) +#define APPLE_TPS_REG_INT_POWER_STATUS_UPDATE BIT(9) +#define APPLE_TPS_REG_INT_STATUS_UPDATE BIT(8) +#define APPLE_TPS_REG_INT_PLUG_EVENT BIT(1) + /* TPS_REG_POWER_STATUS bits */ #define TPS_POWER_STATUS_CONNECTION(x) TPS_FIELD_GET(BIT(0), (x)) #define TPS_POWER_STATUS_SOURCESINK(x) TPS_FIELD_GET(BIT(1), (x)) diff --git a/drivers/usb/typec/tipd/trace.h b/drivers/usb/typec/tipd/trace.h index 5d09d6f78930..090633a1ae1d 100644 --- a/drivers/usb/typec/tipd/trace.h +++ b/drivers/usb/typec/tipd/trace.h @@ -67,6 +67,13 @@ { TPS_REG_INT_USER_VID_ALT_MODE_ATTN_VDM, "USER_VID_ALT_MODE_ATTN_VDM" }, \ { TPS_REG_INT_USER_VID_ALT_MODE_OTHER_VDM, "USER_VID_ALT_MODE_OTHER_VDM" }) +#define show_cd321x_irq_flags(flags) \ + __print_flags_u64(flags, "|", \ + { APPLE_TPS_REG_INT_PLUG_EVENT, "PLUG_EVENT" }, \ + { APPLE_TPS_REG_INT_POWER_STATUS_UPDATE, "POWER_STATUS_UPDATE" }, \ + { APPLE_TPS_REG_INT_STATUS_UPDATE, "DATA_STATUS_UPDATE" }, \ + { APPLE_TPS_REG_INT_PLUG_EVENT, "STATUS_UPDATE" }) + #define TPS6598X_STATUS_FLAGS_MASK (GENMASK(31, 0) ^ (TPS_STATUS_CONN_STATE_MASK | \ TPS_STATUS_PP_5V0_SWITCH_MASK | \ TPS_STATUS_PP_HV_SWITCH_MASK | \ @@ -207,6 +214,26 @@ TRACE_EVENT(tps6598x_irq, show_irq_flags(__entry->event2)) ); +TRACE_EVENT(cd321x_irq, + TP_PROTO(u64 event1, + u64 event2), + TP_ARGS(event1, event2), + + TP_STRUCT__entry( + __field(u64, event1) + __field(u64, event2) + ), + + TP_fast_assign( + __entry->event1 = event1; + __entry->event2 = event2; + ), + + TP_printk("event1=%s, event2=%s", + show_cd321x_irq_flags(__entry->event1), + show_cd321x_irq_flags(__entry->event2)) +); + TRACE_EVENT(tps6598x_status, TP_PROTO(u32 status), TP_ARGS(status), From patchwork Sat Sep 18 12:09:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12503807 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 9D7B8C433EF for ; Sat, 18 Sep 2021 12:10:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D6E561351 for ; Sat, 18 Sep 2021 12:10:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241386AbhIRMLy (ORCPT ); Sat, 18 Sep 2021 08:11:54 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:36001 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239654AbhIRMLr (ORCPT ); Sat, 18 Sep 2021 08:11:47 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id BB8F1580AA8; Sat, 18 Sep 2021 08:10:09 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sat, 18 Sep 2021 08:10:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=0itOJh54gQGaO D30thtQPa3Yp7a7smAvsgK9h2nk/EM=; b=GzeruHLvchfZHbMUP5wEbGmPKpdwR SWAuEPRNLc2IGZZ1XIFiTAFk9qPR74+UCXc9vj3K+sidJbUhrvKsYPznh8fWA937 FqLANQpDCFOOrwPJz42NvDBpafQZVNXOSacKSM8iPpBRaeXc08XoImYbZ//zSzM5 cIwesZhRW+PdZOER9rnX8DOuKlzbPRsnD6lrFU5RvXq1Z3GmBeN4qg6LMukRXKAQ Ti2aTa6JAB2ByNnWoRg/i05sDUvlVZ9s0KD89dbSZatehHc34RUHTk9p4iyplusu uZ30lDWdDmqY6pIMJ1f0PiRe4sV/ZCe91SlwOK5z+Ca190HsgATRPwCWw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=0itOJh54gQGaOD30thtQPa3Yp7a7smAvsgK9h2nk/EM=; b=L1iPXkgj JeSIbtBkn0Wtsf2G7SrzF02rLTQiiQAuvvowQXwwh8rcSLondHN6OAlzoriisRES CK7X6/uxU0ibCDt2EPL86HFDqEr27J1UMIj7ULXVnBTxSyXr67bdwlQGQcPw+yV/ df0U9latnknX2vGeVX352XbCgRpIqq7yUXyNzHaRFqkl14WPk42cGoL/msucquQk BSLZUGCCMPNTCAIAb+Mx08oO8DbHZa8dLK+GA1Rjso9TYVOJYyJJCR8RCdk1j2PN 34Ub7iBUYyAT/oUqtVxj+Jhf15VcIzt3IY+CG1dWJHGz+rep4egD+BivxGfo6jmq z1CHIOl7j+u+/w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudehkedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 18 Sep 2021 08:10:06 -0400 (EDT) From: Sven Peter To: Heikki Krogerus Cc: Sven Peter , Greg Kroah-Hartman , =?utf-8?q?Guido_G=C3=BCnth?= =?utf-8?q?er?= , "Bryan O'Donoghue" , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alexander Graf , Alyssa Rosenzweig Subject: [RFT PATCH 8/9] usb: typec: tipd: Switch power state to S0 for Apple variant Date: Sat, 18 Sep 2021 14:09:33 +0200 Message-Id: <20210918120934.28252-9-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210918120934.28252-1-sven@svenpeter.dev> References: <20210918120934.28252-1-sven@svenpeter.dev> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The Apple CD321x comes up in a low-power state after boot. Usually, the bootloader will already power it up to S0 but let's do it here as well in case that didn't happen. Suggested-by: Stan Skowronek Signed-off-by: Sven Peter Reviewed-by: Alyssa Rosenzweig --- drivers/usb/typec/tipd/core.c | 44 +++++++++++++++++++++++++++++++ drivers/usb/typec/tipd/tps6598x.h | 6 +++++ 2 files changed, 50 insertions(+) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index e96b17fe6af6..26807c050662 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -30,6 +30,7 @@ #define TPS_REG_INT_MASK2 0x17 #define TPS_REG_INT_CLEAR1 0x18 #define TPS_REG_INT_CLEAR2 0x19 +#define TPS_REG_SYSTEM_POWER_STATE 0x20 #define TPS_REG_STATUS 0x1a #define TPS_REG_SYSTEM_CONF 0x28 #define TPS_REG_CTRL_CONF 0x29 @@ -84,6 +85,8 @@ struct tps6598x_hw { unsigned int irq_data_status_update; unsigned int irq_plug_event; void (*irq_trace)(u64 event1, u64 event2); + + bool supports_spss; }; static const struct tps6598x_hw ti_tps6598x_data; @@ -161,6 +164,11 @@ static int tps6598x_block_write(struct tps6598x *tps, u8 reg, return regmap_raw_write(tps->regmap, reg, data, sizeof(data)); } +static inline int tps6598x_read8(struct tps6598x *tps, u8 reg, u8 *val) +{ + return tps6598x_block_read(tps, reg, val, sizeof(u8)); +} + static inline int tps6598x_read16(struct tps6598x *tps, u8 reg, u16 *val) { return tps6598x_block_read(tps, reg, val, sizeof(u16)); @@ -572,6 +580,35 @@ static int tps6598x_psy_get_prop(struct power_supply *psy, return ret; } +static int cd321x_switch_power_state(struct tps6598x *tps, u8 target_state) +{ + u8 state; + int ret; + + if (!tps->hw->supports_spss) + return 0; + + ret = tps6598x_read8(tps, TPS_REG_SYSTEM_POWER_STATE, &state); + if (ret) + return ret; + + if (state == target_state) + return 0; + + ret = tps6598x_exec_cmd(tps, "SPSS", sizeof(u8), &target_state, 0, NULL); + if (ret) + return ret; + + ret = tps6598x_read8(tps, TPS_REG_SYSTEM_POWER_STATE, &state); + if (ret) + return ret; + + if (state != target_state) + return -EINVAL; + + return 0; +} + static int devm_tps6598_psy_register(struct tps6598x *tps) { struct power_supply_config psy_cfg = {}; @@ -648,6 +685,11 @@ static int tps6598x_probe(struct i2c_client *client) if (ret) return ret; + /* Switch Apple chips to the correct system power state */ + ret = cd321x_switch_power_state(tps, TPS_SYSTEM_POWER_STATE_S0); + if (ret) + return ret; + ret = tps6598x_read32(tps, TPS_REG_STATUS, &status); if (ret < 0) return ret; @@ -786,6 +828,7 @@ static const struct tps6598x_hw ti_tps6598x_data = { .irq_data_status_update = TPS_REG_INT_DATA_STATUS_UPDATE, .irq_plug_event = TPS_REG_INT_PLUG_EVENT, .irq_trace = trace_tps6598x_irq, + .supports_spss = false, }; static const struct tps6598x_hw apple_cd321x_data = { @@ -795,6 +838,7 @@ static const struct tps6598x_hw apple_cd321x_data = { .irq_data_status_update = APPLE_TPS_REG_INT_DATA_STATUS_UPDATE, .irq_plug_event = APPLE_TPS_REG_INT_PLUG_EVENT, .irq_trace = trace_cd321x_irq, + .supports_spss = true, }; static const struct of_device_id tps6598x_of_match[] = { diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index 36b482733297..5e6ff51aa657 100644 --- a/drivers/usb/typec/tipd/tps6598x.h +++ b/drivers/usb/typec/tipd/tps6598x.h @@ -135,6 +135,12 @@ #define APPLE_TPS_REG_INT_STATUS_UPDATE BIT(8) #define APPLE_TPS_REG_INT_PLUG_EVENT BIT(1) +/* TPS_REG_SYSTEM_POWER_STATE states */ +#define TPS_SYSTEM_POWER_STATE_S0 0x00 +#define TPS_SYSTEM_POWER_STATE_S3 0x03 +#define TPS_SYSTEM_POWER_STATE_S4 0x04 +#define TPS_SYSTEM_POWER_STATE_S5 0x05 + /* TPS_REG_POWER_STATUS bits */ #define TPS_POWER_STATUS_CONNECTION(x) TPS_FIELD_GET(BIT(0), (x)) #define TPS_POWER_STATUS_SOURCESINK(x) TPS_FIELD_GET(BIT(1), (x)) From patchwork Sat Sep 18 12:09:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12503811 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 C798DC433EF for ; Sat, 18 Sep 2021 12:10:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B04E96128C for ; Sat, 18 Sep 2021 12:10:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239540AbhIRMMC (ORCPT ); Sat, 18 Sep 2021 08:12:02 -0400 Received: from new4-smtp.messagingengine.com ([66.111.4.230]:33867 "EHLO new4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239483AbhIRMLs (ORCPT ); Sat, 18 Sep 2021 08:11:48 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id B238D580AAF; Sat, 18 Sep 2021 08:10:11 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sat, 18 Sep 2021 08:10:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=2BUNai60PAsqa HL0XWy7FY7EGOOjnzZDxxMpH7rQ3Q4=; b=cVOv97tqGpyIKyv/WBxbBDWMhKaDS IbkB6ysOE+JWR2uz8bpqaINpYd4BoMZSXSmNprFA8wpMclhuDgxHeDRVGLQXrVQH 8XvfLhLDH0CooiZ+qOW4xSh64LAYe1U30Gi9kwQ0shgRaDP22EpueKs72Gf25+49 2+aNb12N79YhnNFuCtkFpUJ5WyShfRpLF9a+20KRVuIv1kQsG0OFMWpUBBtJPDUa w/zjyco0rWTZaLOoNyYXtHdQ6+0GZIgezabYqpJXyHbbJOECKfVSksM3BCypDRIw wrqdgwWdGeIJ3wEYAFLWIR9LAjmqPc08bgRBucyp1EbCnfMvjxonO238g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=2BUNai60PAsqaHL0XWy7FY7EGOOjnzZDxxMpH7rQ3Q4=; b=rAOhEJaM b+VawphzSWGyilbd5N/OZzKVXbohQubTWXVoLyH7HLZSmY/Tz1Lh94ffobzmJEr8 DGui+HCRH185pDcpQL84iYtZK5LIVypfKIZAqP0bFSnKS2B9BW7RLbO9Ua5Mmh8H gtS9YqoeBf4rMpge8Zu/BA9R5naxmGznVTsYu9jZM8jknHD1gX/2dDrS+X5JUC+c cCv+ziWP5CZYvkuqcgqfIBJmLD3c5Hmqd9RhKZOeoPu9Y6IMUABP5H/cInWCMfyg hWZHuwe8B/PZO9sKBkU9DXeSXqFFQ3jfdjnp8Aekg6DDwqbFsdsrE7zy7tFt2JqL /c/D7glsV6jEOQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudehkedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 18 Sep 2021 08:10:09 -0400 (EDT) From: Sven Peter To: Heikki Krogerus Cc: Sven Peter , Greg Kroah-Hartman , =?utf-8?q?Guido_G=C3=BCnth?= =?utf-8?q?er?= , "Bryan O'Donoghue" , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alexander Graf , Alyssa Rosenzweig Subject: [RFT PATCH 9/9] usb: typec: tipd: Remove FIXME about testing with I2C_FUNC_I2C Date: Sat, 18 Sep 2021 14:09:34 +0200 Message-Id: <20210918120934.28252-10-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210918120934.28252-1-sven@svenpeter.dev> References: <20210918120934.28252-1-sven@svenpeter.dev> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The Apple i2c bus uses I2C_FUNC_I2C and I've tested this quite extensivly in the past days. Remove the FIXME about that testing :-) Signed-off-by: Sven Peter Reviewed-by: Alyssa Rosenzweig Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tipd/core.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 26807c050662..3b6878e22ce9 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -673,9 +673,6 @@ static int tps6598x_probe(struct i2c_client *client) /* * Checking can the adapter handle SMBus protocol. If it can not, the * driver needs to take care of block reads separately. - * - * FIXME: Testing with I2C_FUNC_I2C. regmap-i2c uses I2C protocol - * unconditionally if the adapter has I2C_FUNC_I2C set. */ if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) tps->i2c_protocol = true;