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);