Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp712050pxb; Sat, 18 Sep 2021 16:02:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxszBzMunsmxh7aM1/3L2K7fpwir7fWHuhQt4Y7DWRL3N1sA/Az6kTaxnMpyVCyQVfN2+kW X-Received: by 2002:a17:906:e20e:: with SMTP id gf14mr20586083ejb.244.1632006173468; Sat, 18 Sep 2021 16:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632006173; cv=none; d=google.com; s=arc-20160816; b=bZ7MSi0pEDhGASh6fNYhcBtw2MXaGPhwMmTS0mxLzHZq7BJJpdmRaaCgrkcVfVqX48 aa7sCM+Cf2LDkt5Fn1+xm2WNZz1UztOTlwQQhl5XlzGzDBO3w9W0NQeYvtxcJAdmyS2e 202lha4UyNjPruGMgzIlExgGdXDUDiuali9n/BKkc60fFab9yjxI5yGebZn3DkoK/sAP UerwYo2kT1K9P3W8DOIb2pZd6X5j0iQ2mEvSx9zbxUPpBwJW2mwBBRhtZ5gL6X3G94QW QmtGi3NHh0IZA2jX2IH9QR6X5U3Gj9imzNj6wpM8rysl/S879kIomBUAYSebYe+wFkP0 Wo1w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=iRhxHP0o3O6O0kpyjR8ydrO7q+v1pFew5P5vbcKQk4E=; b=xr2QkRS5XmeHofJ8EEMaA1l9P6e9VUEDJYUogRpAOYLKK6iW/RJIRSNkduy9Mrt5kp mlHl4wl75iplPRYYi/jUilXaFTOyTr3urMvVbO+BxzSS+NcQsQNLhBD+wsnXuyLzqQsV QxWh0D6FNaqSi0meNn4K28TCK0NBt6iUNb9hRazQvIz812+rUDHq8SrQHvlPZ12WMq10 bgOOvFiXEQYTn4oNYFdzQtkOTh036fbytpptG8RnbQppVKf9uJwD3sK0z5ieDmcqIQGP gBs1UoqSBdFlD8BpC/u5TA2g9OQ5SV96cJ5g9kwy1QZLlnUhZ7avR0sonLJWDiTryPqm BaWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm2 header.b=tMs2+3hL; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=mnHGxbTA; 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=REJECT sp=REJECT dis=NONE) header.from=svenpeter.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m17si12558810edf.618.2021.09.18.16.01.58; Sat, 18 Sep 2021 16:02:53 -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=@svenpeter.dev header.s=fm2 header.b=tMs2+3hL; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=mnHGxbTA; 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=REJECT sp=REJECT dis=NONE) header.from=svenpeter.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232711AbhIRMLy (ORCPT + 99 others); Sat, 18 Sep 2021 08:11:54 -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=20G=C3=BCnther?= , "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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- 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[] = { -- 2.25.1