From patchwork Sun Sep 26 09:58:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12518199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 914EDC433F5 for ; Sun, 26 Sep 2021 10:02:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 56E0460295 for ; Sun, 26 Sep 2021 10:02:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 56E0460295 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=svenpeter.dev Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WQN8VaAKQyrUqpv53sIoGO9/I6+wSapqHAuXfNpO3p8=; b=k3Gg42pvNFZSpg hu2Np55CHrddYiu3W7iCoiwmY8RMr6Ir1nkIXd+1vsIlz5fVLNm+mHVTWDStWrumgsICLu0/OZ0Hz x4HZ4G/EIv1CqdH3luxIJB08E9vfSGx172ph3ALJ4OYMP4+kbSYtm7SSNLXh/APIex+1KDmAhB80d D4jtT9zmfC+dtlZuBBhC5VXaGyA7u1kEZZ4z+JGxm+3lVqZkcskFKVyllYYbf5L96wGn1Q5Yrq13n pJgJwLxrZEMB2vK+1ZEp2QC4s7jXQitmVkPwKwvmV+pgiPA6SxjcbjArADGH6nRpANv9zI/AUefce M0i3HwX9otn3kL7+MaCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQwt-000KGm-IH; Sun, 26 Sep 2021 09:59:55 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQwf-000KDb-M0 for linux-arm-kernel@lists.infradead.org; Sun, 26 Sep 2021 09:59:43 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id 17140580FBB; Sun, 26 Sep 2021 05:59:41 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sun, 26 Sep 2021 05:59:41 -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=cWp5zIpWjNlKX lE1CaQrGZSrcDn1/ZujYfNah3kcVMs=; b=RiGy3SiNA6RI3cbllOyPHwKSVL1Bl vezDYajenNaEDI08pHR8v97sUkcOYK4TzaJzcCbIhTLTFHtW+tsRxguE1os8CFd3 FM2FvXyNnl25iMqW83XMseXo8guYPHyteRq98SK0KJUPUHPEP5U152RWrxEHzARh HdJZzH3c3XsDNXXv+lswLm7LD9/+mTn7X6TtA5so13z+wX6ECSOZA6QeVkyIjYh8 HHci8jNtr1TPQ6WBBn7dwJMcyLX/2+jFBK2lYK7qruoVWPxmZC0hE8MSX3iaK0Xk 8InE98JvrS2OMt3YWOX/wUKZUlGoBv4sMMe0Y82swXwMAOAEEe/hHhHSg== 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=cWp5zIpWjNlKXlE1CaQrGZSrcDn1/ZujYfNah3kcVMs=; b=dOAooaKv d1UCQiYYrQE2ROmpc0o7NXYmtaKnjpHKuFJEpXv+AZz3NSXbUADepGkrrBeOn58m MXUBBe2Nsa94A2pQ8IwPHqxW9Y2tWZpULcRUzCwIVNtcLUR55jIh6WLi//QPiXcY C0/CMcyMMXzGx0Q1tyCnGOugE8WFNYsecROLNa1THvNTChC9fZAJ+z5tTLHXXW+h hkGnoWL1sjjEyv9LaOXRFhlYQf3k4zGnvxIxYRQKTofneon7T4TlH+1+3tNYkDuB RH2bmQHL93iZLv1ryG2HbNlHCA17Zsj3AGjfNIwTLx9iTI54WpIReEV1faDIflO7 6fa8f5ptKVX4nQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudejiedgvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnhepiedvudfftedvieevieffvdejveeiveduhfeifeegheehhedtgfehffeuheefhfel necuffhomhgrihhnpeguvghvihgtvghtrhgvvgdrohhrghdpghhithhhuhgsrdgtohhmpd hofhhttgdrnhgvthenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhl fhhrohhmpehsvhgvnhesshhvvghnphgvthgvrhdruggvvh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 26 Sep 2021 05:59:38 -0400 (EDT) From: Sven Peter To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Olof Johansson , Rob Herring Cc: Sven Peter , Arnd Bergmann , Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alyssa Rosenzweig , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 01/10] dt-bindings: i2c: Add Apple I2C controller bindings Date: Sun, 26 Sep 2021 11:58:38 +0200 Message-Id: <20210926095847.38261-2-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210926095847.38261-1-sven@svenpeter.dev> References: <20210926095847.38261-1-sven@svenpeter.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210926_025941_807649_05502209 X-CRM114-Status: GOOD ( 15.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The Apple I2C controller is based on the PASemi I2C controller. It is present on Apple SoCs such as the M1. Signed-off-by: Sven Peter Reviewed-by: Rob Herring --- .../devicetree/bindings/i2c/apple,i2c.yaml | 61 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 62 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/apple,i2c.yaml diff --git a/Documentation/devicetree/bindings/i2c/apple,i2c.yaml b/Documentation/devicetree/bindings/i2c/apple,i2c.yaml new file mode 100644 index 000000000000..22fc8483256f --- /dev/null +++ b/Documentation/devicetree/bindings/i2c/apple,i2c.yaml @@ -0,0 +1,61 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/i2c/apple,i2c.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Apple/PASemi I2C controller + +maintainers: + - Sven Peter + +description: | + Apple SoCs such as the M1 come with a I2C controller based on the one found + in machines with P. A. Semi's PWRficient processors. + The bus is used to communicate with e.g. USB PD chips or the speaker + amp. + +allOf: + - $ref: /schemas/i2c/i2c-controller.yaml# + +properties: + compatible: + enum: + - apple,t8103-i2c + - apple,i2c + + reg: + maxItems: 1 + + clocks: + items: + - description: I2C bus reference clock + + interrupts: + maxItems: 1 + + clock-frequency: + description: | + Desired I2C bus clock frequency in Hz. If not specified, 100 kHz will be + used. This frequency is generated by dividing the reference clock. + Allowed values are between ref_clk/(16*4) and ref_clk/(16*255). + +required: + - compatible + - reg + - clocks + - interrupts + +unevaluatedProperties: false + +examples: + - | + i2c@35010000 { + compatible = "apple,t8103-i2c"; + reg = <0x35010000 0x4000>; + interrupt-parent = <&aic>; + interrupts = <0 627 4>; + clocks = <&ref_clk>; + #address-cells = <1>; + #size-cells = <0>; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 329d3a0a9fdb..380a680db92f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1734,6 +1734,7 @@ B: https://github.com/AsahiLinux/linux/issues C: irc://irc.oftc.net/asahi-dev T: git https://github.com/AsahiLinux/linux.git F: Documentation/devicetree/bindings/arm/apple.yaml +F: Documentation/devicetree/bindings/i2c/apple,i2c.yaml F: Documentation/devicetree/bindings/interrupt-controller/apple,aic.yaml F: Documentation/devicetree/bindings/pinctrl/apple,pinctrl.yaml F: arch/arm64/boot/dts/apple/ From patchwork Sun Sep 26 09:58:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12518203 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2F32C433EF for ; Sun, 26 Sep 2021 10:02:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 797AE61019 for ; Sun, 26 Sep 2021 10:02:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 797AE61019 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=svenpeter.dev Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=w+0qJ/4zJAATANcv7j8k8YZELTB1Yx6bnbojPk+aCLw=; b=Mq5OaRbnp89Ohj YzJ+fI2t5MkUdNS3wloZW29JQ6DOeXLItdNtCdLxqyD6dNnDh29JLz6G2S610E3Lm07nwx9fuijkI eOxiZD/4f21lDL2JGtW9J8/2hjy18CM5otBD7lanVa7jMCjkjdfxau07Z9CxyE+eub5xo07WGwfjz P3nQuq6eKPw2Rt4YLWSrzF2O9NLMD9gK29HDVmZDn7E+5KPlJV91Bnn9LU1Cn0MQsJITnBnv8fvB2 lZrkLrzVNjKLzroiDEif8ccI/5j5gF7Ite//tkl7z5eEC7eqac82HX8w+16zR4XMnKMfyqkKSg5Y5 607g++BLqe0xeSAkhfTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQx4-000KKJ-LW; Sun, 26 Sep 2021 10:00:06 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQwi-000KEE-3T for linux-arm-kernel@lists.infradead.org; Sun, 26 Sep 2021 09:59:45 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 80880580FBE; Sun, 26 Sep 2021 05:59:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sun, 26 Sep 2021 05:59:43 -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=eDm2w0r9qdgIL osKDjxLOSNSl2XVh+4nrRVQCj+3Zbg=; b=loKi3BylPqTFC87PBvT1beyL5AI3a 9oJICsw/yvFiFn7dZ+kDGmryQJ9VBPB34mw7OVDyvgBAWl+wFqA6ZGvrprsWhj/q tCxS4J9zxxlTbm29lYKOPcVqGpuW1ikQqDUWkrg/7rQ3srGoZMMEV5y1Z027ADEJ JmA6hdEgIt4kPLJYYJ6xd+nEVmxIIUowxvEjXVIJoIJL7nwzjhCJYQRzWwP1Elre 5nbvr1IZTXHycYf1daUNpoD5xJ5ExOOTRorbPcMroI7sGtZVHycm/HBRxm9gQcWq 8C5+IvmGC06grdkFb8TW+320n9VQyirzr5igOTLCTZdMxhBovjBS/S1xQ== 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=eDm2w0r9qdgILosKDjxLOSNSl2XVh+4nrRVQCj+3Zbg=; b=Dzc1jhNB fWkJWAQ+pgASl5fF5XLxl4RqcO4B1G8A6ILOjmF4zORhzR+aOtUUvIqbmffoXH+V 5dXsu2pDvl4AZk8LHP7DAIbcOSyf/gLe//4HkOXoAVtPwzsw0YG+wuTwbcIapMQl tJu/7G4oRZxkIuPr1EXhn6VzqE4yWQzuRnMXmhNvZwDOvpBEX7BsJdd1hOlRpSRr FEreJOzRLo+bOYxLLFT9HNiw89z9PGbsp88qI++9O14sl2Gza4P1O6eL0Wly/PLX fC6gtsbxjEZUcDz/w3anl/E5ACRublM4b1NmtrDkulOCF40/cHHyD+u1mQZk4I4G 6P7WizXTlOup0w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudejiedgvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 26 Sep 2021 05:59:41 -0400 (EDT) From: Sven Peter To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Olof Johansson Cc: Sven Peter , Arnd Bergmann , Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alyssa Rosenzweig , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/10] i2c: pasemi: Use io{read,write}32 Date: Sun, 26 Sep 2021 11:58:39 +0200 Message-Id: <20210926095847.38261-3-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210926095847.38261-1-sven@svenpeter.dev> References: <20210926095847.38261-1-sven@svenpeter.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210926_025944_232866_0A6CFB7E X-CRM114-Status: GOOD ( 12.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In preparation for splitting this driver up into a platform_driver and a pci_driver, replace outl/inl usage with ioport_map and ioread32/iowrite32. Signed-off-by: Sven Peter --- drivers/i2c/busses/i2c-pasemi.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c index 20f2772c0e79..dd31d902a621 100644 --- a/drivers/i2c/busses/i2c-pasemi.c +++ b/drivers/i2c/busses/i2c-pasemi.c @@ -20,6 +20,7 @@ static struct pci_driver pasemi_smb_driver; struct pasemi_smbus { struct pci_dev *dev; struct i2c_adapter adapter; + void __iomem *ioaddr; unsigned long base; int size; }; @@ -53,13 +54,13 @@ static inline void reg_write(struct pasemi_smbus *smbus, int reg, int val) { dev_dbg(&smbus->dev->dev, "smbus write reg %lx val %08x\n", smbus->base + reg, val); - outl(val, smbus->base + reg); + iowrite32(val, smbus->ioaddr + reg); } static inline int reg_read(struct pasemi_smbus *smbus, int reg) { int ret; - ret = inl(smbus->base + reg); + ret = ioread32(smbus->ioaddr + reg); dev_dbg(&smbus->dev->dev, "smbus read reg %lx val %08x\n", smbus->base + reg, ret); return ret; @@ -351,6 +352,12 @@ static int pasemi_smb_probe(struct pci_dev *dev, goto out_kfree; } + smbus->ioaddr = ioport_map(smbus->base, smbus->size); + if (!smbus->ioaddr) { + error = -EBUSY; + goto out_release_region; + } + smbus->adapter.owner = THIS_MODULE; snprintf(smbus->adapter.name, sizeof(smbus->adapter.name), "PA Semi SMBus adapter at 0x%lx", smbus->base); @@ -366,12 +373,14 @@ static int pasemi_smb_probe(struct pci_dev *dev, error = i2c_add_adapter(&smbus->adapter); if (error) - goto out_release_region; + goto out_ioport_unmap; pci_set_drvdata(dev, smbus); return 0; + out_ioport_unmap: + ioport_unmap(smbus->ioaddr); out_release_region: release_region(smbus->base, smbus->size); out_kfree: @@ -384,6 +393,7 @@ static void pasemi_smb_remove(struct pci_dev *dev) struct pasemi_smbus *smbus = pci_get_drvdata(dev); i2c_del_adapter(&smbus->adapter); + ioport_unmap(smbus->ioaddr); release_region(smbus->base, smbus->size); kfree(smbus); } From patchwork Sun Sep 26 09:58:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12518205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6497C433F5 for ; Sun, 26 Sep 2021 10:02:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B63960295 for ; Sun, 26 Sep 2021 10:02:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9B63960295 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=svenpeter.dev Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ESyfY9qQzUASio+xi752ErNskboJfmJCWbOoZHiO+D8=; b=w5RzeiK5fXIm8I 1B9ptKiukxvefYlTj9ZENZlr+1igp+GWL9JMOubXXxiCBhk2qTi6wfMt/rISUSmBMGfTYces/NpF5 DTFf3hV9t0RKymwRuUvJJVxkQfjqj+DY1SHdwJcVJsnH2kZxJ1r3XmO5fjahPsg5M34Pbe//N+veW 1K6vzk5qasVSqwToruHtMskiDJb6nZ2qLXBrKqx3L4xlbHEzHMA7+VuU8IRQZfaTPeJCif/tjJ+zy VoXapisz9xyPCWywjoqJES1sCmAmFAYcvx0C0kx75ighrPsSzvdvLGV1iupbpkmfmlRUSy6u+jLT2 24AeJyARV5nwS3ouR+KQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQxF-000KMm-N7; Sun, 26 Sep 2021 10:00:18 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQwk-000KEh-JP for linux-arm-kernel@lists.infradead.org; Sun, 26 Sep 2021 09:59:48 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 0325E580FC0; Sun, 26 Sep 2021 05:59:46 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 26 Sep 2021 05:59:46 -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=lp+XUp7mIfXq3 15prP8VbwTOoD7Xg/G3KhTR4HgHB0I=; b=n/bwUgzw0kmotuC8bjksXKblzHPTY 5Z+L3BQ/jcwneG/mmwJoN+8F6M9gy6oHdqaz9QfN3RoTy4mk6WP4Drxan7UepCF+ fM0juN6F67kV+eYkrR3yv4kYZVdO1QSRUnXGR7L+tVL47a7GeEWxWmWB4DjCrMOV dvami0204CRFW5KY0BYo7SIdEHTkpLK9kJ0n2Lv1JwBgycqtxD1hNpzNMxvDgJVq AxI86GIp85zbWPC2ohNofJx50w0ivWXF1ssqD2bZcfaRQnbH4ycZsRxpHBQk4D04 1GQ3yjvR6SaP1JJm9KkDht2ZKYIhqZhVMPU9DQpFPVa4EneL7QiQtCEyQ== 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=lp+XUp7mIfXq315prP8VbwTOoD7Xg/G3KhTR4HgHB0I=; b=p+g75wOz QmwLuZ4yyIEva+90iJlSIj2jdKz/OkpP70yUTuXP8u9NsiBS8C9BdDBNwWdAA8Oi Mt2rPlrnq0I60VNhpHQRQ1wEC/H0PLSlphxOpz89oiaHM1z6pMHNn+5E5BEOB8ip 7X18rYwIGDW/4quvHj0EBeQ6t3tI4L2cIDzGMlxK+25IyphCip54CxCVMYgoMVjS buTOcs/w0jkpKAqps50HoxbOUwNTdzQoeffP4cmitLW80CYKuRzoXKOo0LEXkoDt iIChz+cgTJGHFRcmfkR7PUC5/Iq5e+t36q0SftL+4ycY+fHhHPQlgbjew/tzBM47 VBAY6n4kY9DZSQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudejiedgvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 26 Sep 2021 05:59:43 -0400 (EDT) From: Sven Peter To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Olof Johansson Cc: Sven Peter , Arnd Bergmann , Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alyssa Rosenzweig , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/10] i2c: pasemi: Remove usage of pci_dev Date: Sun, 26 Sep 2021 11:58:40 +0200 Message-Id: <20210926095847.38261-4-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210926095847.38261-1-sven@svenpeter.dev> References: <20210926095847.38261-1-sven@svenpeter.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210926_025946_733212_5B9B95E3 X-CRM114-Status: GOOD ( 12.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Prepare to create a platform driver by removing all usages of pci_dev we can. Signed-off-by: Sven Peter --- drivers/i2c/busses/i2c-pasemi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c index dd31d902a621..5a25c2e54b9e 100644 --- a/drivers/i2c/busses/i2c-pasemi.c +++ b/drivers/i2c/busses/i2c-pasemi.c @@ -18,7 +18,7 @@ static struct pci_driver pasemi_smb_driver; struct pasemi_smbus { - struct pci_dev *dev; + struct device *dev; struct i2c_adapter adapter; void __iomem *ioaddr; unsigned long base; @@ -52,7 +52,7 @@ struct pasemi_smbus { static inline void reg_write(struct pasemi_smbus *smbus, int reg, int val) { - dev_dbg(&smbus->dev->dev, "smbus write reg %lx val %08x\n", + dev_dbg(smbus->dev, "smbus write reg %lx val %08x\n", smbus->base + reg, val); iowrite32(val, smbus->ioaddr + reg); } @@ -61,7 +61,7 @@ static inline int reg_read(struct pasemi_smbus *smbus, int reg) { int ret; ret = ioread32(smbus->ioaddr + reg); - dev_dbg(&smbus->dev->dev, "smbus read reg %lx val %08x\n", + dev_dbg(smbus->dev, "smbus read reg %lx val %08x\n", smbus->base + reg, ret); return ret; } @@ -94,7 +94,7 @@ static int pasemi_smb_waitready(struct pasemi_smbus *smbus) return -ENXIO; if (timeout < 0) { - dev_warn(&smbus->dev->dev, "Timeout, status 0x%08x\n", status); + dev_warn(smbus->dev, "Timeout, status 0x%08x\n", status); reg_write(smbus, REG_SMSTA, status); return -ETIME; } @@ -342,7 +342,7 @@ static int pasemi_smb_probe(struct pci_dev *dev, if (!smbus) return -ENOMEM; - smbus->dev = dev; + smbus->dev = &dev->dev; smbus->base = pci_resource_start(dev, 0); smbus->size = pci_resource_len(dev, 0); @@ -366,7 +366,7 @@ static int pasemi_smb_probe(struct pci_dev *dev, smbus->adapter.algo_data = smbus; /* set up the sysfs linkage to our parent device */ - smbus->adapter.dev.parent = &dev->dev; + smbus->adapter.dev.parent = smbus->dev; reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR | (CLK_100K_DIV & CTL_CLK_M))); From patchwork Sun Sep 26 09:58:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12518207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 710E6C433F5 for ; Sun, 26 Sep 2021 10:02:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3BC6F60FDC for ; Sun, 26 Sep 2021 10:02:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3BC6F60FDC Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=svenpeter.dev Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uALOq7ZknQ3MEBL7yC6SdbPtY2R/BP3WSjf979Qv2vw=; b=E4woxhkhoOku66 LRXyP8+USoeWq53ROyY1vt32QWIjY/SLl2KlBpR1hhdFgxsVMb99QYC7tW+WWSq7YABhloQfaLA2T rrtSLFZlCRGTAguJEGk6PMwJx7NbBjjRm4+RjIO2JNN+YqoTRY4+dmrjGZkR2rGl1gfoIo3PCwAoD 89BoXg7A+hP+LdgMseAqcG+speOJTtWNMFoaMsyngzFNf5Pvwrv6vtMXKplru/L1gA9Wiv/4LHr7Q +CEgpnD6NamgZ2o3ZeJ+K3OfWwVa06SJXPk9RaqstRi3ddlIfxtFKU91nSNbH8dQXVGQowyOO6Nd9 ai3oaKbMros+BExowfvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQxR-000KOs-KI; Sun, 26 Sep 2021 10:00:29 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQwm-000KFa-Q8 for linux-arm-kernel@lists.infradead.org; Sun, 26 Sep 2021 09:59:50 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 32A1F580FC6; Sun, 26 Sep 2021 05:59:48 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 26 Sep 2021 05:59:48 -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=NSjoTG7uIR9X1 ggtIrb/y5LTCesEdfoXqS6PV7z9nz8=; b=oPm/T1qe+gvtr4k7fdYRk/qk+rSeH PKBrYlnGJUpEypAz/deYDIYNDp5/57KWK0ky9VKatAu2DGxj+vfmfffpoGxEp3bm x6Prazck1vZTf2L03BMxruqnT0QKm6PSumoIluiLMBgWBuSk4HAsUQ+Db0ODQLE8 OkNkf1PWvI6HJlCsxUpIytB+WsWS5KFzS+UK5PU2x+U0VA/Su3BxdIdn0jmyFrw4 b1ik0IukCbkiKGbXCWaY4qKAl5DKCHRGYWvzB3eyqp0B7lS0OynXPIRAiybjDFcB vGPZE3So3/lTWtd9Fgdn8WhzRwyt5FBmzEa5oUeBkh4xtv4csy95Xya3Q== 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=NSjoTG7uIR9X1ggtIrb/y5LTCesEdfoXqS6PV7z9nz8=; b=j4SnXb6r mFXGB/0Lk4s2BkgGeQa696+18pEJDTdgr8j/i9N18Dtv1ApVT0nnq7ElishSaewr vV0yTQq1bfAaT58TSjSPgep1X2TlfxqOqRnjE3NvGMx4mpfl7SzCO2mJg7/Q1+is fprJ6FhfNjsf3oE8oAg1LWy0oP9/g6CeLa0HTih9gHaNYbuapUuJgbXmoy4RbX65 PUurgalZ/xd/vHCMXE3p3IUt4ulNEsIhFA1YfD4pi/VS96Gtj1WP/oce+nrq/lMq 7IIsgUe9HV2Mnbo+JqtA94r5BXTq0j3h7DBSCU1fj1DPSq26oUEDISZyQAR4LrkW DA/p+jJVgu9Byw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudejiedgvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 26 Sep 2021 05:59:46 -0400 (EDT) From: Sven Peter To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Olof Johansson Cc: Sven Peter , Arnd Bergmann , Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alyssa Rosenzweig , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/10] i2c: pasemi: Split off common probing code Date: Sun, 26 Sep 2021 11:58:41 +0200 Message-Id: <20210926095847.38261-5-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210926095847.38261-1-sven@svenpeter.dev> References: <20210926095847.38261-1-sven@svenpeter.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210926_025948_947063_20D637C1 X-CRM114-Status: GOOD ( 12.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Split off common probing code that will be used by both the PCI and the platform device. Signed-off-by: Sven Peter --- drivers/i2c/busses/i2c-pasemi.c | 39 +++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c index 5a25c2e54b9e..9d69ff63f674 100644 --- a/drivers/i2c/busses/i2c-pasemi.c +++ b/drivers/i2c/busses/i2c-pasemi.c @@ -329,6 +329,30 @@ static const struct i2c_algorithm smbus_algorithm = { .functionality = pasemi_smb_func, }; +static int pasemi_i2c_common_probe(struct pasemi_smbus *smbus) +{ + int error; + + smbus->adapter.owner = THIS_MODULE; + snprintf(smbus->adapter.name, sizeof(smbus->adapter.name), + "PA Semi SMBus adapter at 0x%lx", smbus->base); + smbus->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; + smbus->adapter.algo = &smbus_algorithm; + smbus->adapter.algo_data = smbus; + + /* set up the sysfs linkage to our parent device */ + smbus->adapter.dev.parent = smbus->dev; + + reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR | + (CLK_100K_DIV & CTL_CLK_M))); + + error = i2c_add_adapter(&smbus->adapter); + if (error) + return error; + + return 0; +} + static int pasemi_smb_probe(struct pci_dev *dev, const struct pci_device_id *id) { @@ -358,20 +382,7 @@ static int pasemi_smb_probe(struct pci_dev *dev, goto out_release_region; } - smbus->adapter.owner = THIS_MODULE; - snprintf(smbus->adapter.name, sizeof(smbus->adapter.name), - "PA Semi SMBus adapter at 0x%lx", smbus->base); - smbus->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; - smbus->adapter.algo = &smbus_algorithm; - smbus->adapter.algo_data = smbus; - - /* set up the sysfs linkage to our parent device */ - smbus->adapter.dev.parent = smbus->dev; - - reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR | - (CLK_100K_DIV & CTL_CLK_M))); - - error = i2c_add_adapter(&smbus->adapter); + int error = pasemi_i2c_common_probe(smbus); if (error) goto out_ioport_unmap; From patchwork Sun Sep 26 09:58:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12518211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 962D9C433F5 for ; Sun, 26 Sep 2021 10:03:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 628E060295 for ; Sun, 26 Sep 2021 10:03:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 628E060295 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=svenpeter.dev Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=n2PYxppg9UcIZojQqGgrCzrp+0nKUJyTczTTYTRitF4=; b=q5Jcx79AqPZ76x oOgmTmfJK8OwHtFm1yRkAB75txXWtnqAPDf1ymgXM+3CW9+E2HqgePDDOJx7grQXYUqMgrvK1JEDf C4rSHHLJGrmALfayqarB+DxobfQb2Nz1rAoNsdU8gDr1irh+dF8VLT5zmUjPBledWFs4hnxu6tKYV 5uvP+YvWWgrMYuaNSKccLoA7FSpT3oPQ+maqxyPgVCAfHIevq9FXb8iG88fQsA8ZceGwmHjXjeVuA QqNx3WFHNZT32+TIs2yOS7jeTywUzQhIOSSZjB4SNgcYYwAEgamPqXCnh0RF2gKxW3Q8h+FE92MgB vx/riCSlQTVgWCtM1eJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQxf-000KSA-R5; Sun, 26 Sep 2021 10:00:44 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQwp-000KG3-06 for linux-arm-kernel@lists.infradead.org; Sun, 26 Sep 2021 09:59:53 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 65B07580FC9; Sun, 26 Sep 2021 05:59:50 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sun, 26 Sep 2021 05:59:50 -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=c7KwfXz039aW1 wfmY7eI8n7gO1ZrMIuHg4HVlfkwtsE=; b=J+sJvzwElGAyYmuAvc+rvWp0ItHSg UkKXp+NTBtufjuhICbmcyyS2Y7XpX4ciCDBOSZ6cCr5HoMREX/78fOC8VPba+4Y3 ajmwYa2UkJh+c9eBEKkpyXvoxaMibp9C13GKrV/KdRR8l3N4EXQo0NYiz9BKDDz+ GC11uKyOW3445Pvm4hyG8nCT4vadtC0G3BeFO3fVPQAFNUTe1LUqhjMjHoLLw+P0 jqQHJkSzviLCaIBK/t16bFQltKEQat2mlb/MA+drT4p33AcdGtZe8rBqc5MlWi58 t7HLLniy9mKvTij2eYbNlOF/gME4ZJYfC+XJ0EBx6k0rYvlWuUZqfnkiA== 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=c7KwfXz039aW1wfmY7eI8n7gO1ZrMIuHg4HVlfkwtsE=; b=CQdA+M9m 8yYPyUKfAxMHgcy0vuzT9QRKKTgSfIcgujXFDNuOJufIWXQxvyEWEgURSKR4Ncen 7QrcI8X2zCfQmCAxVpUyVj7+VeWPftpGuZOk9edB7s8AkkTyOgCFHCTmIF/8guUD 93fOlr/KLdkUwBM7SqdKGt2GdlowekQZOnluj6+LD+L5xOKSrSrgrYksUNFpAIxl BBNx38PGwEDGG5BG2eWE9ps9u2X8AceBorRhF+95MnAiaU/lx9nRFEKMTRTUYwYD r9e0ai6Hf+MxzYozenUa0EEaf0gJQAi9RwjyGxbtH87T4aJejU7mD4L68MyzO7NJ tYV8jj+rsphUig== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudejiedgvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 26 Sep 2021 05:59:48 -0400 (EDT) From: Sven Peter To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Olof Johansson Cc: Sven Peter , Arnd Bergmann , Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alyssa Rosenzweig , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/10] i2c: pasemi: Split pci driver to its own file Date: Sun, 26 Sep 2021 11:58:42 +0200 Message-Id: <20210926095847.38261-6-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210926095847.38261-1-sven@svenpeter.dev> References: <20210926095847.38261-1-sven@svenpeter.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210926_025951_149565_3D9842F5 X-CRM114-Status: GOOD ( 20.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Split off the PCI driver so that we can reuse common code for the platform driver. Signed-off-by: Sven Peter --- drivers/i2c/busses/Makefile | 1 + .../{i2c-pasemi.c => i2c-pasemi-core.c} | 88 +---------------- drivers/i2c/busses/i2c-pasemi-core.h | 19 ++++ drivers/i2c/busses/i2c-pasemi-pci.c | 96 +++++++++++++++++++ 4 files changed, 118 insertions(+), 86 deletions(-) rename drivers/i2c/busses/{i2c-pasemi.c => i2c-pasemi-core.c} (81%) create mode 100644 drivers/i2c/busses/i2c-pasemi-core.h create mode 100644 drivers/i2c/busses/i2c-pasemi-pci.c diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index 1336b04f40e2..0ab1b4cb2228 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile @@ -84,6 +84,7 @@ obj-$(CONFIG_I2C_NPCM7XX) += i2c-npcm7xx.o obj-$(CONFIG_I2C_OCORES) += i2c-ocores.o obj-$(CONFIG_I2C_OMAP) += i2c-omap.o obj-$(CONFIG_I2C_OWL) += i2c-owl.o +i2c-pasemi-objs := i2c-pasemi-core.o i2c-pasemi-pci.o obj-$(CONFIG_I2C_PASEMI) += i2c-pasemi.o obj-$(CONFIG_I2C_PCA_PLATFORM) += i2c-pca-platform.o obj-$(CONFIG_I2C_PNX) += i2c-pnx.o diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi-core.c similarity index 81% rename from drivers/i2c/busses/i2c-pasemi.c rename to drivers/i2c/busses/i2c-pasemi-core.c index 9d69ff63f674..3eda5e375fa2 100644 --- a/drivers/i2c/busses/i2c-pasemi.c +++ b/drivers/i2c/busses/i2c-pasemi-core.c @@ -15,15 +15,7 @@ #include #include -static struct pci_driver pasemi_smb_driver; - -struct pasemi_smbus { - struct device *dev; - struct i2c_adapter adapter; - void __iomem *ioaddr; - unsigned long base; - int size; -}; +#include "i2c-pasemi-core.h" /* Register offsets */ #define REG_MTXFIFO 0x00 @@ -329,7 +321,7 @@ static const struct i2c_algorithm smbus_algorithm = { .functionality = pasemi_smb_func, }; -static int pasemi_i2c_common_probe(struct pasemi_smbus *smbus) +int pasemi_i2c_common_probe(struct pasemi_smbus *smbus) { int error; @@ -352,79 +344,3 @@ static int pasemi_i2c_common_probe(struct pasemi_smbus *smbus) return 0; } - -static int pasemi_smb_probe(struct pci_dev *dev, - const struct pci_device_id *id) -{ - struct pasemi_smbus *smbus; - int error; - - if (!(pci_resource_flags(dev, 0) & IORESOURCE_IO)) - return -ENODEV; - - smbus = kzalloc(sizeof(struct pasemi_smbus), GFP_KERNEL); - if (!smbus) - return -ENOMEM; - - smbus->dev = &dev->dev; - smbus->base = pci_resource_start(dev, 0); - smbus->size = pci_resource_len(dev, 0); - - if (!request_region(smbus->base, smbus->size, - pasemi_smb_driver.name)) { - error = -EBUSY; - goto out_kfree; - } - - smbus->ioaddr = ioport_map(smbus->base, smbus->size); - if (!smbus->ioaddr) { - error = -EBUSY; - goto out_release_region; - } - - int error = pasemi_i2c_common_probe(smbus); - if (error) - goto out_ioport_unmap; - - pci_set_drvdata(dev, smbus); - - return 0; - - out_ioport_unmap: - ioport_unmap(smbus->ioaddr); - out_release_region: - release_region(smbus->base, smbus->size); - out_kfree: - kfree(smbus); - return error; -} - -static void pasemi_smb_remove(struct pci_dev *dev) -{ - struct pasemi_smbus *smbus = pci_get_drvdata(dev); - - i2c_del_adapter(&smbus->adapter); - ioport_unmap(smbus->ioaddr); - release_region(smbus->base, smbus->size); - kfree(smbus); -} - -static const struct pci_device_id pasemi_smb_ids[] = { - { PCI_DEVICE(0x1959, 0xa003) }, - { 0, } -}; - -MODULE_DEVICE_TABLE(pci, pasemi_smb_ids); - -static struct pci_driver pasemi_smb_driver = { - .name = "i2c-pasemi", - .id_table = pasemi_smb_ids, - .probe = pasemi_smb_probe, - .remove = pasemi_smb_remove, -}; - -module_pci_driver(pasemi_smb_driver); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR ("Olof Johansson "); -MODULE_DESCRIPTION("PA Semi PWRficient SMBus driver"); diff --git a/drivers/i2c/busses/i2c-pasemi-core.h b/drivers/i2c/busses/i2c-pasemi-core.h new file mode 100644 index 000000000000..7acc33de6ce1 --- /dev/null +++ b/drivers/i2c/busses/i2c-pasemi-core.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include +#include +#include +#include +#include +#include +#include +#include + +struct pasemi_smbus { + struct device *dev; + struct i2c_adapter adapter; + void __iomem *ioaddr; + unsigned long base; + int size; +}; + +int pasemi_i2c_common_probe(struct pasemi_smbus *smbus); diff --git a/drivers/i2c/busses/i2c-pasemi-pci.c b/drivers/i2c/busses/i2c-pasemi-pci.c new file mode 100644 index 000000000000..9a19df31866b --- /dev/null +++ b/drivers/i2c/busses/i2c-pasemi-pci.c @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2006-2007 PA Semi, Inc + * + * SMBus host driver for PA Semi PWRficient + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "i2c-pasemi-core.h" + +static struct pci_driver pasemi_smb_pci_driver; + +static int pasemi_smb_pci_probe(struct pci_dev *dev, + const struct pci_device_id *id) +{ + struct pasemi_smbus *smbus; + int error; + + if (!(pci_resource_flags(dev, 0) & IORESOURCE_IO)) + return -ENODEV; + + smbus = kzalloc(sizeof(struct pasemi_smbus), GFP_KERNEL); + if (!smbus) + return -ENOMEM; + + smbus->dev = &dev->dev; + smbus->base = pci_resource_start(dev, 0); + smbus->size = pci_resource_len(dev, 0); + + if (!request_region(smbus->base, smbus->size, + pasemi_smb_pci_driver.name)) { + error = -EBUSY; + goto out_kfree; + } + + smbus->ioaddr = ioport_map(smbus->base, smbus->size); + if (!smbus->ioaddr) { + error = -EBUSY; + goto out_release_region; + } + + error = pasemi_i2c_common_probe(smbus); + if (error) + goto out_ioport_unmap; + + pci_set_drvdata(dev, smbus); + + return 0; + + out_ioport_unmap: + ioport_unmap(smbus->ioaddr); + out_release_region: + release_region(smbus->base, smbus->size); + out_kfree: + kfree(smbus); + return error; +} + +static void pasemi_smb_pci_remove(struct pci_dev *dev) +{ + struct pasemi_smbus *smbus = pci_get_drvdata(dev); + + i2c_del_adapter(&smbus->adapter); + ioport_unmap(smbus->ioaddr); + release_region(smbus->base, smbus->size); + kfree(smbus); +} + +static const struct pci_device_id pasemi_smb_pci_ids[] = { + { PCI_DEVICE(0x1959, 0xa003) }, + { 0, } +}; + +MODULE_DEVICE_TABLE(pci, pasemi_smb_pci_ids); + +static struct pci_driver pasemi_smb_pci_driver = { + .name = "i2c-pasemi", + .id_table = pasemi_smb_pci_ids, + .probe = pasemi_smb_pci_probe, + .remove = pasemi_smb_pci_remove, +}; + +module_pci_driver(pasemi_smb_pci_driver); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Olof Johansson "); +MODULE_DESCRIPTION("PA Semi PWRficient SMBus driver"); From patchwork Sun Sep 26 09:58:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12518209 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C928BC433EF for ; Sun, 26 Sep 2021 10:03:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A038F60FDC for ; Sun, 26 Sep 2021 10:03:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A038F60FDC Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=svenpeter.dev Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1V6lthYqXVXZJMTapqj8z6EGD8xz6tToTYGCeimj2qo=; b=pbTkhMCo0EhlZG xIcHsJeHXqSEgukcGZHfUd1roHhHEnbG+InpswfdTKo4O/bRsPwkpO1zNXQ+IbKPJJQ8T7CCzCj6r /d+faLc++OeaQGLcGnDP8uhwNbq77YJXwxgA335Ud0+Rx8xylRfXeHaKy+ZDKOTyXIptoQG9JcYYE zEytodQfT9O/kBLnzIiAZlxzQz/qUcyb718uVwMAdy8bg5+8ZQ/qU4CUJNxoAK2qZXEWEYVvpfmjl ARTcV/3vzfAVWfgSkdl4F21jFLjB8QvDl1xA/jCfL0N7cj7tFGrMfpr8rvJ6qXQBCcYFmJ+Om76Us dmfihpU7Ld/iI8m7EfGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQxt-000KWG-8d; Sun, 26 Sep 2021 10:00:57 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQwr-000KGQ-7A for linux-arm-kernel@lists.infradead.org; Sun, 26 Sep 2021 09:59:54 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 962BB580FCE; Sun, 26 Sep 2021 05:59:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 26 Sep 2021 05:59:52 -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=eD+NxnkyU+/hP i/UKgsnf10rLOiXfMOCvTD3jf1t0H0=; b=BbJWmL9rIELiwqAwkx6ZdyYYfQ/yc gbZPgM6U8kt3QtDCO9OTwmAUoIwiPAk96YQ8fQ+ZIOi8uVmFs3W/D71ZZriQNx1r cXocC+U5BX4YoQUTLL/ctglzTQQmr5hQgKqPVdjq6lxYMBDhULMZ3x5hyCzZxJFm FGlE5Jovf2dqAaFpm+y6PwN7vcxIZ0MtVTVWrT3vmngvY2aYXafr7vmhD75iQ2uQ dg0CEpX5XWwneyPMralb7AhVnwERjkLW3JNhCfeU1WM4PFPTynYE6xdldhvp8Kuv CRnCNuL78vrbvUi+ESBD+FFUmjccbdF0ToCUcPiVh9pxvz9wFJ4PDa7fQ== 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=eD+NxnkyU+/hPi/UKgsnf10rLOiXfMOCvTD3jf1t0H0=; b=tlJ4Jm/6 XztkdtKC5bTdpdVe+6urPNE09FbmC+da3/py9U7aW7aYIT5v+zwc8izm6wYIk2aJ YuX78NBhoTc3cKCFU6s1D13/y5O+ssgUO+fLz6UAbQDMOfXvNwULRbhTSJHME4lE aXzmWfsqXFJVi9721iWz2a35yQZZap53anvFUhfuA+5o2p0vEvkZMtBZ2Ge7yqu3 OgHLjldgUiyL6qFLeAdpkTIeRD7zZEp5N5B+WQ0MJFCyzAIddf9rpqPERHQ/iIXv Bu7tb5Ecf3+blBfhoYy8y6cDJRq33Xk9SofZbOlSo4FyNI7CeB8lmOxRU3NhFOnQ QMQkCiMKIY1Tog== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudejiedgvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 26 Sep 2021 05:59:50 -0400 (EDT) From: Sven Peter To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Olof Johansson Cc: Sven Peter , Arnd Bergmann , Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alyssa Rosenzweig , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/10] i2c: pasemi: Move common reset code to own function Date: Sun, 26 Sep 2021 11:58:43 +0200 Message-Id: <20210926095847.38261-7-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210926095847.38261-1-sven@svenpeter.dev> References: <20210926095847.38261-1-sven@svenpeter.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210926_025953_351647_9C2C8BAF X-CRM114-Status: GOOD ( 10.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Split out common reset call to its own function so that we can later add support for selecting the clock frequency and an additional enable bit found in newer revisions. Signed-off-by: Sven Peter --- drivers/i2c/busses/i2c-pasemi-core.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-pasemi-core.c b/drivers/i2c/busses/i2c-pasemi-core.c index 3eda5e375fa2..7c6715f5dbb8 100644 --- a/drivers/i2c/busses/i2c-pasemi-core.c +++ b/drivers/i2c/busses/i2c-pasemi-core.c @@ -61,6 +61,12 @@ static inline int reg_read(struct pasemi_smbus *smbus, int reg) #define TXFIFO_WR(smbus, reg) reg_write((smbus), REG_MTXFIFO, (reg)) #define RXFIFO_RD(smbus) reg_read((smbus), REG_MRXFIFO) +static void pasemi_reset(struct pasemi_smbus *smbus) +{ + reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR | + (CLK_100K_DIV & CTL_CLK_M))); +} + static void pasemi_smb_clear(struct pasemi_smbus *smbus) { unsigned int status; @@ -135,8 +141,7 @@ static int pasemi_i2c_xfer_msg(struct i2c_adapter *adapter, return 0; reset_out: - reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR | - (CLK_100K_DIV & CTL_CLK_M))); + pasemi_reset(smbus); return err; } @@ -302,8 +307,7 @@ static int pasemi_smb_xfer(struct i2c_adapter *adapter, return 0; reset_out: - reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR | - (CLK_100K_DIV & CTL_CLK_M))); + pasemi_reset(smbus); return err; } @@ -335,8 +339,7 @@ int pasemi_i2c_common_probe(struct pasemi_smbus *smbus) /* set up the sysfs linkage to our parent device */ smbus->adapter.dev.parent = smbus->dev; - reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR | - (CLK_100K_DIV & CTL_CLK_M))); + pasemi_reset(smbus); error = i2c_add_adapter(&smbus->adapter); if (error) From patchwork Sun Sep 26 09:58:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12518213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12F8BC433EF for ; Sun, 26 Sep 2021 10:03:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BE6D960FDC for ; Sun, 26 Sep 2021 10:03:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BE6D960FDC Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=svenpeter.dev Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ocotcBqjOTq4eDMyL+LY/cq0OaGrgZCyCWQGjnA20Po=; b=o1c7A3Ig8adUa8 j8kcTKuPnKnHHgskwfsezwBpnQzDerYwC+eILCU9JURP6GynwmCJP2TdNi4U+FrLHUwML+3EnXfRq pn27z0/VHwAib2LwCVhTzNxwcSMSNV1ttFrYopaldAXmWJpxEabHqciRVBn/GujTvaCo/W1cqLgYI 9AYmO7lVCJt39aDo/9ftxQW1qOL2aHC5UtcRxdmGvzTxR5tYRRxCQ12W2vitM+rrSxxs3U6SJlRbe qmG6hcKMUcsWTFC9WoL023ppxXtYjQ4X218nsTIhCW4GfgGiewX/f+uil4aTqTNX2y9ovRTL6k0dw vgO4L9DRSjKPXktabZEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQyL-000KhJ-IC; Sun, 26 Sep 2021 10:01:27 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQwt-000KGw-Cd for linux-arm-kernel@lists.infradead.org; Sun, 26 Sep 2021 09:59:56 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id C4B8A580FD1; Sun, 26 Sep 2021 05:59:54 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 26 Sep 2021 05:59: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=KbpD7QDsVxr0s hguUMq4LBuqqbF0i6Fnb7YHPNOz3ek=; b=qUZpi53zHUD80M8nqu661ADs8im9g H6m6Mzdi6cRJ8NlT1f0sYVYv/7lnNa2vam1C9M7qUXc8Ze1S2wScKJYYiXIBtbM+ QX9LBZ0yXEU0nvI+Q7rC5udRfhf3J5gP1P/0lPDZ7xxosHFLeMy/EWkdXxIVqBsk ngsa4Mn/NZxRACP15t3rrjxZAA0GEAWqa/EYorxkfXUAtrcf1tNumgUwDbOOFlvm 0WEHWpi0Fi4WZSJGz4PVhkxdG415DFVMyqjNM9RFzHQgqtAU9+hl7QI+aamn2gJY BSr2rOUriYt/cj+aYQC/EfTuDwOSyeWmuyx7kmk+StJQCFDEI5jXbJHRQ== 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=KbpD7QDsVxr0shguUMq4LBuqqbF0i6Fnb7YHPNOz3ek=; b=nyyiw9q+ Cp+FfyGYWwkGuV6q61ImTxR7ybE9CossQWXltL7CYV5fGrBJ8NFESWwQFhv0sQKn yuHHHMX6NBQ7sk6gG+nw6ASpr7tp0GbvsaWoWgUaesN2hQB38Yo1TRS+T9H6bGbo Y4MKz8rpd065L+5YcYsOxm1LsUQ5WOkEEcsa22z23nzGPH40fZZu7/ltJ8c6/BC2 BG7akP526ty4d6wHShl2bFyQBxMLUr7JXIen9yhOW/w1vP/RM3YHLcycZ5XpRLsn JLDV+Pqc0/C2pe/RHrNueacCEoMgbfy+HfJLDFBRaa/Ngbz7bW7XmW1tz266n168 y5bbkaYgxCtr8Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudejiedgvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 26 Sep 2021 05:59:52 -0400 (EDT) From: Sven Peter To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Olof Johansson Cc: Sven Peter , Arnd Bergmann , Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alyssa Rosenzweig , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/10] i2c: pasemi: Allow to configure bus frequency Date: Sun, 26 Sep 2021 11:58:44 +0200 Message-Id: <20210926095847.38261-8-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210926095847.38261-1-sven@svenpeter.dev> References: <20210926095847.38261-1-sven@svenpeter.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210926_025955_518262_CD1CA6B0 X-CRM114-Status: GOOD ( 12.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Right now the bus frequency has always been hardcoded as 100 KHz with the specific reference clock used in the PASemi PCI controllers. Make this configurable to prepare for the platform driver. Signed-off-by: Sven Peter --- drivers/i2c/busses/i2c-pasemi-core.c | 8 +++----- drivers/i2c/busses/i2c-pasemi-core.h | 1 + drivers/i2c/busses/i2c-pasemi-pci.c | 4 ++++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-pasemi-core.c b/drivers/i2c/busses/i2c-pasemi-core.c index 7c6715f5dbb8..a39e3258b162 100644 --- a/drivers/i2c/busses/i2c-pasemi-core.c +++ b/drivers/i2c/busses/i2c-pasemi-core.c @@ -39,9 +39,6 @@ #define CTL_MTR 0x00000200 #define CTL_CLK_M 0x000000ff -#define CLK_100K_DIV 84 -#define CLK_400K_DIV 21 - static inline void reg_write(struct pasemi_smbus *smbus, int reg, int val) { dev_dbg(smbus->dev, "smbus write reg %lx val %08x\n", @@ -63,8 +60,9 @@ static inline int reg_read(struct pasemi_smbus *smbus, int reg) static void pasemi_reset(struct pasemi_smbus *smbus) { - reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR | - (CLK_100K_DIV & CTL_CLK_M))); + u32 val = (CTL_MTR | CTL_MRR | (smbus->clk_div & CTL_CLK_M)); + + reg_write(smbus, REG_CTL, val); } static void pasemi_smb_clear(struct pasemi_smbus *smbus) diff --git a/drivers/i2c/busses/i2c-pasemi-core.h b/drivers/i2c/busses/i2c-pasemi-core.h index 7acc33de6ce1..30a7990825ef 100644 --- a/drivers/i2c/busses/i2c-pasemi-core.h +++ b/drivers/i2c/busses/i2c-pasemi-core.h @@ -14,6 +14,7 @@ struct pasemi_smbus { void __iomem *ioaddr; unsigned long base; int size; + unsigned int clk_div; }; int pasemi_i2c_common_probe(struct pasemi_smbus *smbus); diff --git a/drivers/i2c/busses/i2c-pasemi-pci.c b/drivers/i2c/busses/i2c-pasemi-pci.c index 9a19df31866b..7405e0b48514 100644 --- a/drivers/i2c/busses/i2c-pasemi-pci.c +++ b/drivers/i2c/busses/i2c-pasemi-pci.c @@ -17,6 +17,9 @@ #include "i2c-pasemi-core.h" +#define CLK_100K_DIV 84 +#define CLK_400K_DIV 21 + static struct pci_driver pasemi_smb_pci_driver; static int pasemi_smb_pci_probe(struct pci_dev *dev, @@ -35,6 +38,7 @@ static int pasemi_smb_pci_probe(struct pci_dev *dev, smbus->dev = &dev->dev; smbus->base = pci_resource_start(dev, 0); smbus->size = pci_resource_len(dev, 0); + smbus->clk_div = CLK_100K_DIV; if (!request_region(smbus->base, smbus->size, pasemi_smb_pci_driver.name)) { From patchwork Sun Sep 26 09:58:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12518221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B178C433F5 for ; Sun, 26 Sep 2021 10:04:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DCF7860FDC for ; Sun, 26 Sep 2021 10:04:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DCF7860FDC Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=svenpeter.dev Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/oPhPjRbe91wr14JBNvymT2sz0vZxBKAyi+VOXxqg/M=; b=NxA0LZr/e8ISWS Sf1YloeRnWwrTMFY/ncNOzNfpDjcBmlIg3na0sX06Tt6GN821Wes7be8+a9Dq1X15qOB6vBLswyX6 bPyj16tyNAauFGzqQtPrq+PxmsaBhxVP5xTD1guGWR8YU4cEmDbS2jBREfaAKQvw0Nqrwqvj7W5QT iyRHc0CTDXyY8yYV+FUDRHh905xfTg1wzuQEArHujgDHoXOrPmwwQ+AuNbfwtG0xCoHZ7hFV1FJcN jbGS+s1DqQefBOj+CBSXk77Kaf6+Q19NTL/d5F/ZmTv4tE4Jbu6G2AQvMVHbXBjzYvwEF7RNpw5G8 fIHr+qarMovPWHsV4XnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQzG-000L7z-5a; Sun, 26 Sep 2021 10:02:25 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQwv-000KHN-Ko for linux-arm-kernel@lists.infradead.org; Sun, 26 Sep 2021 09:59:59 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id 06103580FD7; Sun, 26 Sep 2021 05:59:57 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sun, 26 Sep 2021 05:59:57 -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=MiY3vPnmv1t1u 25vIPIu3crGvGJdIxD82pjD4t4lZP8=; b=Ud8bDaAItoP39qCj2/S6Td0uWjCJU 8PEDSC65vYQtfb8MAlreERPbuTs26RSzT3Yu8kkj9XnkqAmCNNX1PlJm2cHULW0y zwZOT/jSB/P3YHrC4t1QznbWkalDS+GJJtq3U0didE5hMHGObO8XsZuYFfeIoFYg v42eVfmGyUNeIDGMKseKLUYTFNIDIunWkfNl3IIfltkMJdSwKcTQ/l9HvKPjzqBM FS40dvwCPnvnVH/YxQywVi0gSrOoVlCw+f3cWjUnEcPIYhUEl+1PXYm6A0TYIhFc 17/1j+hS4HzUdXwTLoMf+la98GvaaJq2us0/NlljrOoKqFcrhpNIwaS3Q== 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=MiY3vPnmv1t1u25vIPIu3crGvGJdIxD82pjD4t4lZP8=; b=vKfT/rej EUAGjcr3Cnhu5x9rxt23tMGY5KAzUQqongzZI8H302dTNuMrP6jQr9Fmo+dWpOUe PvPiAmH8TSWMG5QyEdUVhru6EeaXHQI/MV4uhhmgtqdIwaehzgtD3wu6Wr1samd2 1MVdHJ9rR1nphfamY/eiUEnBl2jwEbMV6FgKyer9bNAtpgtA5fVZECFd9a/hDw79 /J8CP7Q7fxoJdMyEE8iJVxfTcIAATOAdQKOdnAVYiEfeC3jnqETgi2Pyw7U1NEeW RVjyqzSE0fJ4iuxYm/SbZtwr6WtHhbd5N5SjwDqFnIBHV1TBEHaR5pzkp/NwZ2h+ qLLo3/RdnE2lPQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudejiedgvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 26 Sep 2021 05:59:54 -0400 (EDT) From: Sven Peter To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Olof Johansson Cc: Sven Peter , Arnd Bergmann , Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alyssa Rosenzweig , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/10] i2c: pasemi: Refactor _probe to use devm_* Date: Sun, 26 Sep 2021 11:58:45 +0200 Message-Id: <20210926095847.38261-9-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210926095847.38261-1-sven@svenpeter.dev> References: <20210926095847.38261-1-sven@svenpeter.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210926_025957_777509_99BF6157 X-CRM114-Status: GOOD ( 14.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Using managed device resources means there's nothing left to be done in pasemi_smb_pci_remove and also allows to remove base and size from struct pasemi_smbus. Signed-off-by: Sven Peter --- drivers/i2c/busses/i2c-pasemi-core.c | 10 +++---- drivers/i2c/busses/i2c-pasemi-core.h | 2 -- drivers/i2c/busses/i2c-pasemi-pci.c | 45 ++++++++-------------------- 3 files changed, 16 insertions(+), 41 deletions(-) diff --git a/drivers/i2c/busses/i2c-pasemi-core.c b/drivers/i2c/busses/i2c-pasemi-core.c index a39e3258b162..0ec65263fd08 100644 --- a/drivers/i2c/busses/i2c-pasemi-core.c +++ b/drivers/i2c/busses/i2c-pasemi-core.c @@ -41,8 +41,7 @@ static inline void reg_write(struct pasemi_smbus *smbus, int reg, int val) { - dev_dbg(smbus->dev, "smbus write reg %lx val %08x\n", - smbus->base + reg, val); + dev_dbg(smbus->dev, "smbus write reg %x val %08x\n", reg, val); iowrite32(val, smbus->ioaddr + reg); } @@ -50,8 +49,7 @@ static inline int reg_read(struct pasemi_smbus *smbus, int reg) { int ret; ret = ioread32(smbus->ioaddr + reg); - dev_dbg(smbus->dev, "smbus read reg %lx val %08x\n", - smbus->base + reg, ret); + dev_dbg(smbus->dev, "smbus read reg %x val %08x\n", reg, ret); return ret; } @@ -329,7 +327,7 @@ int pasemi_i2c_common_probe(struct pasemi_smbus *smbus) smbus->adapter.owner = THIS_MODULE; snprintf(smbus->adapter.name, sizeof(smbus->adapter.name), - "PA Semi SMBus adapter at 0x%lx", smbus->base); + "PA Semi SMBus adapter at 0x%p", smbus->ioaddr); smbus->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; smbus->adapter.algo = &smbus_algorithm; smbus->adapter.algo_data = smbus; @@ -339,7 +337,7 @@ int pasemi_i2c_common_probe(struct pasemi_smbus *smbus) pasemi_reset(smbus); - error = i2c_add_adapter(&smbus->adapter); + error = devm_i2c_add_adapter(smbus->dev, &smbus->adapter); if (error) return error; diff --git a/drivers/i2c/busses/i2c-pasemi-core.h b/drivers/i2c/busses/i2c-pasemi-core.h index 30a7990825ef..aca4e2da9089 100644 --- a/drivers/i2c/busses/i2c-pasemi-core.h +++ b/drivers/i2c/busses/i2c-pasemi-core.h @@ -12,8 +12,6 @@ struct pasemi_smbus { struct device *dev; struct i2c_adapter adapter; void __iomem *ioaddr; - unsigned long base; - int size; unsigned int clk_div; }; diff --git a/drivers/i2c/busses/i2c-pasemi-pci.c b/drivers/i2c/busses/i2c-pasemi-pci.c index 7405e0b48514..c1b8901110c0 100644 --- a/drivers/i2c/busses/i2c-pasemi-pci.c +++ b/drivers/i2c/busses/i2c-pasemi-pci.c @@ -26,57 +26,37 @@ static int pasemi_smb_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) { struct pasemi_smbus *smbus; + unsigned long base; + int size; int error; if (!(pci_resource_flags(dev, 0) & IORESOURCE_IO)) return -ENODEV; - smbus = kzalloc(sizeof(struct pasemi_smbus), GFP_KERNEL); + smbus = devm_kzalloc(&dev->dev, sizeof(*smbus), GFP_KERNEL); if (!smbus) return -ENOMEM; smbus->dev = &dev->dev; - smbus->base = pci_resource_start(dev, 0); - smbus->size = pci_resource_len(dev, 0); + base = pci_resource_start(dev, 0); + size = pci_resource_len(dev, 0); smbus->clk_div = CLK_100K_DIV; - if (!request_region(smbus->base, smbus->size, - pasemi_smb_pci_driver.name)) { - error = -EBUSY; - goto out_kfree; - } + if (!devm_request_region(&dev->dev, base, size, + pasemi_smb_pci_driver.name)) + return -EBUSY; - smbus->ioaddr = ioport_map(smbus->base, smbus->size); - if (!smbus->ioaddr) { - error = -EBUSY; - goto out_release_region; - } + smbus->ioaddr = devm_ioport_map(&dev->dev, base, size); + if (!smbus->ioaddr) + return -EBUSY; error = pasemi_i2c_common_probe(smbus); if (error) - goto out_ioport_unmap; + return error; pci_set_drvdata(dev, smbus); return 0; - - out_ioport_unmap: - ioport_unmap(smbus->ioaddr); - out_release_region: - release_region(smbus->base, smbus->size); - out_kfree: - kfree(smbus); - return error; -} - -static void pasemi_smb_pci_remove(struct pci_dev *dev) -{ - struct pasemi_smbus *smbus = pci_get_drvdata(dev); - - i2c_del_adapter(&smbus->adapter); - ioport_unmap(smbus->ioaddr); - release_region(smbus->base, smbus->size); - kfree(smbus); } static const struct pci_device_id pasemi_smb_pci_ids[] = { @@ -90,7 +70,6 @@ static struct pci_driver pasemi_smb_pci_driver = { .name = "i2c-pasemi", .id_table = pasemi_smb_pci_ids, .probe = pasemi_smb_pci_probe, - .remove = pasemi_smb_pci_remove, }; module_pci_driver(pasemi_smb_pci_driver); From patchwork Sun Sep 26 09:58:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12518223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE91CC433EF for ; Sun, 26 Sep 2021 10:05:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 745F960295 for ; Sun, 26 Sep 2021 10:05:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 745F960295 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=svenpeter.dev Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gfErsr0WjBGyBDh9BwTN5CgTMXIJuuLwbL0koBDrUoQ=; b=n8rlLwMRih2p8t dXgcYWAUA1PEHmPu0qQrZucVXRFSLAr0VVRYPM5G5/Nvntq2lSCJkHbhE1e/pNNoIverK3VD6WAKl DSb12V96F5DNUgdJw0NfIkMP424nm88+WxYOZ5JRO6b+CqR/CVWPCUOzioOGt6xnHzriydSxxMB/c /bIRnf7ubIdqyXXadOF8SFIWcQsAjr0qUpMB3oB2DYfrwXzEZcYwkFQLjjCIxikUeqxEiIK09XhRh r/Sq+6Heems+cS8nv+Y9DLwWOdXFynciu9+Kow84i4hmn00lBZE+zvQ5L7fhEqmRll4eBA/xlciLx 3rI/AzIynlvLtVDNF8kg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUR0F-000Lef-8k; Sun, 26 Sep 2021 10:03:23 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQwx-000KIK-Nq for linux-arm-kernel@lists.infradead.org; Sun, 26 Sep 2021 10:00:01 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.nyi.internal (Postfix) with ESMTP id 23A02580FDB; Sun, 26 Sep 2021 05:59:59 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 26 Sep 2021 05:59:59 -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=E5gQC5MWzZAJm rjvaWXcsPDVP/qqg20G3GfbqZGgj6w=; b=izSg/ggC41ZlBQxh1kHDQ7J1n/FqE yeeTSYfIkMETUeGmKcI72FWepcJoIQBDGFlxuEuZCbGqcN1ygRP92RQnZMPcy7st fNNrBR81U++f8xmuX4FJyWcj26E/quYHrOoWnpwqGeNZzudkjezdQu///S8LSj1O 6o5niBtCGyyAjhA10Ixsq79TGvZXkc+NTQoJ50fVEj+E9Cpo0eyeppYWIWdfHsi2 h/mFHp2LRWlo8uey3hAgtQ/z2InNecVLHvXT5oC8UXhyV36BGWyR66iwIO2H4li3 xEk7XT6daTppygBomkT67fqcdo2ByZ8+e2ppsOPNEwo2Dsi8IoUWq7ibg== 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=E5gQC5MWzZAJmrjvaWXcsPDVP/qqg20G3GfbqZGgj6w=; b=U0qHg7C9 OWcalaoWxC3w+/sKc2ZsJdQWY3p41988bkagHbZfEsQ8vwc3hzKIfmXZy/hry0aD 795dZlLYUICzeKTKyH2bUcCdUkOzXWXlolrUVSf6uV38JBavdO0diWTjJwAp2lgN p/BZjToaLw0WU+DhkGDssLqpQKuVShB22pj6KzLAdjrG2tv1sEHrgtlmbvH/DFvD itJuUdoErEF6SrpaSc7ViSA6t7S9h7afdX2nIQkXmHaKvA8FqXMNfpXppZRJDQTd XlY9u/1id8Daev+3eEoGA6uL/h8Kqx1Ry81lnts2H8RQKQu1Ajpu+AaKMOIuMgOO AYn/omc5g2ilWQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudejiedgvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 26 Sep 2021 05:59:57 -0400 (EDT) From: Sven Peter To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Olof Johansson Cc: Sven Peter , Arnd Bergmann , Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alyssa Rosenzweig , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/10] i2c: pasemi: Add Apple platform driver Date: Sun, 26 Sep 2021 11:58:46 +0200 Message-Id: <20210926095847.38261-10-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210926095847.38261-1-sven@svenpeter.dev> References: <20210926095847.38261-1-sven@svenpeter.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210926_025959_876313_FF2A148E X-CRM114-Status: GOOD ( 24.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org With all the previous preparations we can now finally add the platform driver to support the PASemi-based controllers in Apple SoCs. This does not work on the M1 yet but should work on the early iPhones already. Signed-off-by: Sven Peter --- MAINTAINERS | 1 + drivers/i2c/busses/Kconfig | 11 +++ drivers/i2c/busses/Makefile | 2 + drivers/i2c/busses/i2c-pasemi-apple.c | 122 ++++++++++++++++++++++++++ 4 files changed, 136 insertions(+) create mode 100644 drivers/i2c/busses/i2c-pasemi-apple.c diff --git a/MAINTAINERS b/MAINTAINERS index 380a680db92f..6e952158b6e1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1738,6 +1738,7 @@ F: Documentation/devicetree/bindings/i2c/apple,i2c.yaml F: Documentation/devicetree/bindings/interrupt-controller/apple,aic.yaml F: Documentation/devicetree/bindings/pinctrl/apple,pinctrl.yaml F: arch/arm64/boot/dts/apple/ +F: drivers/i2c/busses/i2c-pasemi-apple.c F: drivers/irqchip/irq-apple-aic.c F: include/dt-bindings/interrupt-controller/apple-aic.h F: include/dt-bindings/pinctrl/apple.h diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index e17790fe35a7..cf4dae07e319 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -856,6 +856,17 @@ config I2C_PASEMI help Supports the PA Semi PWRficient on-chip SMBus interfaces. +config I2C_APPLE + tristate "Apple SMBus platform driver" + depends on ARCH_APPLE || COMPILE_TEST + default ARCH_APPLE + help + Say Y here if you want to use the I2C controller present on Apple + Silicon chips such as the M1. + + This driver can also be built as a module. If so, the module + will be called i2c-apple. + config I2C_PCA_PLATFORM tristate "PCA9564/PCA9665 as platform device" select I2C_ALGOPCA diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index 0ab1b4cb2228..474fe2c520d0 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile @@ -86,6 +86,8 @@ obj-$(CONFIG_I2C_OMAP) += i2c-omap.o obj-$(CONFIG_I2C_OWL) += i2c-owl.o i2c-pasemi-objs := i2c-pasemi-core.o i2c-pasemi-pci.o obj-$(CONFIG_I2C_PASEMI) += i2c-pasemi.o +i2c-apple-objs := i2c-pasemi-core.o i2c-pasemi-apple.o +obj-$(CONFIG_I2C_APPLE) += i2c-apple.o obj-$(CONFIG_I2C_PCA_PLATFORM) += i2c-pca-platform.o obj-$(CONFIG_I2C_PNX) += i2c-pnx.o obj-$(CONFIG_I2C_PXA) += i2c-pxa.o diff --git a/drivers/i2c/busses/i2c-pasemi-apple.c b/drivers/i2c/busses/i2c-pasemi-apple.c new file mode 100644 index 000000000000..c87f8e516eff --- /dev/null +++ b/drivers/i2c/busses/i2c-pasemi-apple.c @@ -0,0 +1,122 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2021 The Asahi Linux Contributors + * + * PA Semi PWRficient SMBus host driver for Apple SoCs + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "i2c-pasemi-core.h" + +struct pasemi_apple_i2c_data { + struct pasemi_smbus smbus; + struct clk *clk_ref; + struct pinctrl *pctrl; +}; + +static int pasemi_apple_i2c_calc_clk_div(struct pasemi_apple_i2c_data *data, + u32 frequency) +{ + unsigned long clk_rate = clk_get_rate(data->clk_ref); + + if (!clk_rate) + return -EINVAL; + + data->smbus.clk_div = DIV_ROUND_UP(clk_rate, 16 * frequency); + if (data->smbus.clk_div < 4) + return dev_err_probe(data->smbus.dev, -EINVAL, + "Bus frequency %d is too fast.\n", + frequency); + if (data->smbus.clk_div > 0xff) + return dev_err_probe(data->smbus.dev, -EINVAL, + "Bus frequency %d is too slow.\n", + frequency); + + return 0; +} + +static int pasemi_apple_i2c_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct pasemi_apple_i2c_data *data; + struct pasemi_smbus *smbus; + u32 frequency; + int error; + + data = devm_kzalloc(dev, sizeof(struct pasemi_apple_i2c_data), + GFP_KERNEL); + if (!data) + return -ENOMEM; + + smbus = &data->smbus; + smbus->dev = dev; + + smbus->ioaddr = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(smbus->ioaddr)) + return PTR_ERR(smbus->ioaddr); + + if (of_property_read_u32(dev->of_node, "clock-frequency", &frequency)) + frequency = I2C_MAX_STANDARD_MODE_FREQ; + + data->clk_ref = devm_clk_get(dev, NULL); + if (IS_ERR(data->clk_ref)) + return PTR_ERR(data->clk_ref); + + error = clk_prepare_enable(data->clk_ref); + if (error) + return error; + + error = pasemi_apple_i2c_calc_clk_div(data, frequency); + if (error) + goto out_clk_disable; + + smbus->adapter.dev.of_node = pdev->dev.of_node; + error = pasemi_i2c_common_probe(smbus); + if (error) + goto out_clk_disable; + + platform_set_drvdata(pdev, data); + + return 0; + +out_clk_disable: + clk_disable_unprepare(data->clk_ref); + + return error; +} + +static int pasemi_apple_i2c_remove(struct platform_device *pdev) +{ + struct pasemi_apple_i2c_data *data = platform_get_drvdata(pdev); + + clk_disable_unprepare(data->clk_ref); + return 0; +} + +static const struct of_device_id pasemi_apple_i2c_of_match[] = { + { .compatible = "apple,t8103-i2c" }, + { .compatible = "apple,i2c" }, + {}, +}; +MODULE_DEVICE_TABLE(of, pasemi_apple_i2c_of_match); + +static struct platform_driver pasemi_apple_i2c_driver = { + .driver = { + .name = "i2c-apple", + .of_match_table = pasemi_apple_i2c_of_match, + }, + .probe = pasemi_apple_i2c_probe, + .remove = pasemi_apple_i2c_remove, +}; +module_platform_driver(pasemi_apple_i2c_driver); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Sven Peter "); +MODULE_DESCRIPTION("Apple/PASemi SMBus platform driver"); From patchwork Sun Sep 26 09:58:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12518225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C2E6C433F5 for ; Sun, 26 Sep 2021 10:05:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5B21B61019 for ; Sun, 26 Sep 2021 10:05:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5B21B61019 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=svenpeter.dev Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KblgH8cX19KHwbqwLyK3R66M4qKolRMrSju9Rv0Utmo=; b=ZeM0mktcA+Gaae M7/jpkmTWBV6t/DyfGsHe+bdpVhcGjpJ2+rkpXxtV0o+5CvvcOrfJV3npMxM+IgpBN7Ue3xpnV5Cq ZMDSJpPWyS2cmMZEwPTAKGrniCxZCw2dwBX72oZfj1DoeRTqPwdRRmMi452dvqF4PdTR5lPjNghTy LnpWy1FwUEBLOcJVK/PugrzrEQiX5hW6JcXlITs12d/AgLwOzxXRxfd1KLvg/6eK98spib7y724/G edlHmsVfRs2SePcJbpAZlcZuM/gMSEpDedrH09ZwlToKfcfeCcAU9IYnVbXB1dkk1lD0IV24IqfTh XWtB44DcfH9PCEYjL9FQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUR0v-000M01-Bb; Sun, 26 Sep 2021 10:04:05 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mUQwz-000KJG-Uw for linux-arm-kernel@lists.infradead.org; Sun, 26 Sep 2021 10:00:03 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id 547A3580FDE; Sun, 26 Sep 2021 06:00:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 26 Sep 2021 06:00:01 -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=LP/8lz47saqkf hCVmeWif4VdrSPwoBp2uj9OD6MO2sI=; b=TboQyJyt4MGPZJh/xJ6qiczrTbGWj r5ApKe/VulYN+FhoEFA2Qa93FiZAbXkU1ZtaUwNCSiCTkM7hl0FX9DLDf+jafm3f ML33GGGZnp8Er/R2btTDv2FpAhfpz1+x/vLcShzcqnDh5KMv3csTx1pKg2qt2Hm0 /UFXYA5NG4/gVSYBx6fUSeS8sBt2nV/Zy+VCZk/ZO/7i3diRgpap5XTrSuCsTbnH 74QM1QWjmIdItbseJZ8MYjXn7Ex9BL3qaTpC+6dmHWTAA8ULeCMj5bZU1vXr4oPz ZtXKW6NHxB50qxOiEEKfzobdWl9ffVpkMaDSh5P9e1riYsA8inkxZo8TQ== 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=LP/8lz47saqkfhCVmeWif4VdrSPwoBp2uj9OD6MO2sI=; b=NxAyPacu lGio5pH75/BsAtFRtcWvrptpUnUxDJJjbRfdGf6+/V3X61T4rm7z+D4m3S/dKNN/ UugMrelKaJ8AdH0p7lN0QCwSvJrLWpKPgwAlAYm17h5Uo5t0ZIZTGiHo09ud4K63 N6U+7iP8DbcxjQnJ7oz1rC39WRsuofgUdAzRWJTExpc1N62l+C2Sb445bhMsmugi dO1hhWz6UaaRf6TZqEKim+KP9vk+8RcQ4u/RW6jlbdOBNsCDlX65pW74QeXdyrj0 gYYZAfRWYnOPpqgaQnbcr6CAhyuMDhvcEmVLyLTIMPyee6M3eUKaXI54eriFTDtY Xnk91yd1fBBC5w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudejiedgvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 26 Sep 2021 05:59:59 -0400 (EDT) From: Sven Peter To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Olof Johansson Cc: Sven Peter , Arnd Bergmann , Hector Martin , Mohamed Mediouni , Stan Skowronek , Mark Kettenis , Alyssa Rosenzweig , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/10] i2c: pasemi: Set enable bit for Apple variant Date: Sun, 26 Sep 2021 11:58:47 +0200 Message-Id: <20210926095847.38261-11-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210926095847.38261-1-sven@svenpeter.dev> References: <20210926095847.38261-1-sven@svenpeter.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210926_030002_100529_7F1055E4 X-CRM114-Status: GOOD ( 13.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some later revisions after the original PASemi I2C controller introduce what likely is an enable bit to the CTL register. Without setting it the actual i2c transmission is never started. Signed-off-by: Sven Peter --- drivers/i2c/busses/i2c-pasemi-core.c | 8 ++++++++ drivers/i2c/busses/i2c-pasemi-core.h | 3 +++ drivers/i2c/busses/i2c-pasemi-pci.c | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/drivers/i2c/busses/i2c-pasemi-core.c b/drivers/i2c/busses/i2c-pasemi-core.c index 0ec65263fd08..b52a65beda99 100644 --- a/drivers/i2c/busses/i2c-pasemi-core.c +++ b/drivers/i2c/busses/i2c-pasemi-core.c @@ -22,6 +22,7 @@ #define REG_MRXFIFO 0x04 #define REG_SMSTA 0x14 #define REG_CTL 0x1c +#define REG_REV 0x28 /* Register defs */ #define MTXFIFO_READ 0x00000400 @@ -37,6 +38,7 @@ #define CTL_MRR 0x00000400 #define CTL_MTR 0x00000200 +#define CTL_EN 0x00000800 #define CTL_CLK_M 0x000000ff static inline void reg_write(struct pasemi_smbus *smbus, int reg, int val) @@ -60,6 +62,9 @@ static void pasemi_reset(struct pasemi_smbus *smbus) { u32 val = (CTL_MTR | CTL_MRR | (smbus->clk_div & CTL_CLK_M)); + if (smbus->hw_rev >= 6) + val |= CTL_EN; + reg_write(smbus, REG_CTL, val); } @@ -335,6 +340,9 @@ int pasemi_i2c_common_probe(struct pasemi_smbus *smbus) /* set up the sysfs linkage to our parent device */ smbus->adapter.dev.parent = smbus->dev; + if (smbus->hw_rev != PASEMI_HW_REV_PCI) + smbus->hw_rev = reg_read(smbus, REG_REV); + pasemi_reset(smbus); error = devm_i2c_add_adapter(smbus->dev, &smbus->adapter); diff --git a/drivers/i2c/busses/i2c-pasemi-core.h b/drivers/i2c/busses/i2c-pasemi-core.h index aca4e2da9089..4655124a37f3 100644 --- a/drivers/i2c/busses/i2c-pasemi-core.h +++ b/drivers/i2c/busses/i2c-pasemi-core.h @@ -8,11 +8,14 @@ #include #include +#define PASEMI_HW_REV_PCI -1 + struct pasemi_smbus { struct device *dev; struct i2c_adapter adapter; void __iomem *ioaddr; unsigned int clk_div; + int hw_rev; }; int pasemi_i2c_common_probe(struct pasemi_smbus *smbus); diff --git a/drivers/i2c/busses/i2c-pasemi-pci.c b/drivers/i2c/busses/i2c-pasemi-pci.c index c1b8901110c0..2b7be35421bc 100644 --- a/drivers/i2c/busses/i2c-pasemi-pci.c +++ b/drivers/i2c/busses/i2c-pasemi-pci.c @@ -42,6 +42,12 @@ static int pasemi_smb_pci_probe(struct pci_dev *dev, size = pci_resource_len(dev, 0); smbus->clk_div = CLK_100K_DIV; + /* + * The original PASemi PCI controllers don't have a register for + * their HW revision. + */ + smbus->hw_rev = PASEMI_HW_REV_PCI; + if (!devm_request_region(&dev->dev, base, size, pasemi_smb_pci_driver.name)) return -EBUSY;