From patchwork Fri Oct 8 16:35:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12545835 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 EF5A7C433EF for ; Fri, 8 Oct 2021 16:50:24 +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 9F56560F6D for ; Fri, 8 Oct 2021 16:50:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9F56560F6D 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=EPwly3kDWd+eA7ODukw7EbevZpdv8A4D+oXuLVPlqyI=; b=nnC1FXERkHku6m QCV8rssVPjh9aVu+6MGAJr0AxB3ndr1yxNuWrPUk9d2lf85sSzQKveT+kFyN4cDvW8HhimNv9BpzH 28i1VjKhqpgYRV6FyMDkPQhnYXIoKIVoHHTTIukx5BJCy+B9fh/o43c0Pu7SrcOYsp8QxrpkBQHMJ pRKIkTw27yq3wi0y5F0gcU28xovH3SS4NFhPpvfVj/eDzB08Fgkz+o76K5H5A0xqMVxHi5rwAIpFb dwiEPIfTPiIzA5IasFsOxJn/T7Z4edrXCXiHvOR1u6fxAp7tYp1iRzZi9FLTIiftl0shes5nqCK9m Vh6Vg1ebZ2zDEEiswryw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mYt2e-003aRJ-8z; Fri, 08 Oct 2021 16:48:17 +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 1mYsrO-003XRI-MF for linux-arm-kernel@lists.infradead.org; Fri, 08 Oct 2021 16:36:40 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id BF049581017; Fri, 8 Oct 2021 12:36:37 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 08 Oct 2021 12:36:37 -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=wjaNOvoPfH5mR fPiYoh4MKVRamUagf3VG7kW7qVwEyI=; b=PVRXKF1MDnHNQ8uwHshftgIhfsaJI aPYojnjSAysotdtPE4uG4rVqDSwkfNWxMo0/MPrfOE2OkDcMyf7a87Nv8CRaFAuj brQ0MvI/CpTX1eS1ZBMf6e0Eu9DDj8Vm0pxG+mqf/PRiqidH0CASutdviTeHV1Dd D5egebv34yjpOFFxcdQZknWCh/mtJz2ZdaFqVyXKlPT34DXoax4eJKDwKpP0JUNQ TdtXu2Q1xv2aMaPCQYQESdr+kilumrM4wdThImE8b9LXPFV7dO5DGDcr+TXdrv/T 9O5eHymO84HmljQx81CkFy/dy8Um3EuXGOvD8Pdds+g7RvjfDaUd64zsg== 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= fm1; bh=wjaNOvoPfH5mRfPiYoh4MKVRamUagf3VG7kW7qVwEyI=; b=GWgCb98T q6hh5DECoOk+pLf5s6cxti9ythS78R2SrH4KZpfzpp5jpYeglh8sCj157as5lqrN yDBy9+jnipIB7gruh5Mbdhw2jss+vPpEvzGu/aK1z07EH2mZaKI28ezjTuz/ccfU ox9ALfGBfIons666iCFICd7metvKeHiY4yxl04QITuXwKUo+hyLbrzDLwMk4oAtR INDuuB6qhMhADBEKHQVCcpWVVpEsaGJGkG/W6812C5PhIH76YfKyDEfwtyKJVwCC 2I+3G6Sv780CHuKqhGyW0DsesBMOlL/4KhvgaWTGSrHf30hy0PZ+2HK3u1aTyTNG se1zZ0jUd4pXEA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddttddguddttdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufhvvghn ucfrvghtvghruceoshhvvghnsehsvhgvnhhpvghtvghrrdguvghvqeenucggtffrrghtth gvrhhnpeetvdekteeluefffffhkeetteffgefggfevheeileeufedvtdeuffevveelhfef jeenucevlhhushhtvghrufhiiigvpeefnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsvh gvnhesshhvvghnphgvthgvrhdruggvvh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 8 Oct 2021 12:36:35 -0400 (EDT) From: Sven Peter To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Olof Johansson , Christian Zigotzky , Wolfram Sang 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 v2 08/11] i2c: pasemi: Allow to configure bus frequency Date: Fri, 8 Oct 2021 18:35:29 +0200 Message-Id: <20211008163532.75569-9-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20211008163532.75569-1-sven@svenpeter.dev> References: <20211008163532.75569-1-sven@svenpeter.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211008_093638_847332_43103D9D X-CRM114-Status: GOOD ( 13.24 ) 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. Reviewed-by: Arnd Bergmann Signed-off-by: Sven Peter --- v1 -> v2: no changes 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 232587c70a38..9fb8fac53f2b 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 644656e28012..96585bbf8c24 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)) {