From patchwork Fri Oct 8 16:35:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12545833 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 233D0C433F5 for ; Fri, 8 Oct 2021 16:49:07 +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 E16B760FDC for ; Fri, 8 Oct 2021 16:49:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E16B760FDC 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=HfnbxiVJw6zEl5y2CeMKzvbXSAMHT8/1whPfU/hP7N0=; b=AYFa326q/k69z7 rxBdlVlwohaTYL2UXRcCWK5TAjzj5Z2hevhPiEUTjPC064QIFNqv9Vj5u/K8YV9OVeVqrydfDmaf4 OgzN21hkUuj1SoSkTG5m3eTnfqwqTFW3pjcag96nAWvw4PM3wx3Bao4OjLRFKgepQAAeedhtJmaDv G1G6WVShkS0jg6+FXHXmN5CfgAuqhmvEl6Cx4PihEku+kM66vO5FY6xFCva/oZkY1tYxWJub3kryz gRbLQv/oexoPgexEAZWxJTyysY6kP1gvPdPSdOSEJtTCMM5ny6OFzhPmoDJQMDYLYDXJDot3bsgV1 nE1UR5U3YJUsxZTJ9VQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mYt1H-003a5Y-Qb; Fri, 08 Oct 2021 16:46:52 +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 1mYsrM-003XQN-16 for linux-arm-kernel@lists.infradead.org; Fri, 08 Oct 2021 16:36:38 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 4CF92581015; Fri, 8 Oct 2021 12:36:35 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 08 Oct 2021 12:36:35 -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=EqH0ZsHiaEtwh Gi9zyJrCeQh7KgGC2k47TQ9WU71+SM=; b=qHzfzmqzTb5HjdBSQQUrPULx3wCyo vkDYdYvnmjYNIRJpNS6cgV3O1A5Wd96nHW1bzrhFRSZDNS2ZN5oPebwyQzSpWthn e21+jAVFN/zSZ6aYqA+18Cr5XHLu4xR9lnS9za8X9quhQUjbT0BdjdzEHNuVb5pl 77iWZx8O+x0ZuqdplbIxIFUg1GZU7GnnJ5Hf7RHwuiIVdDUkWxoVVKt3WNFhMv8C iTYiVUllWaTeYMg0eg40XGjNY9k+d6ARTn5p9GfUd89Y+8gR+qDIGJV7NUSdaSCl 2c/lRnZexw6HrcKewX1AtPkLdUpPCsAErWceJuUAkXQcKHOM+75YHBk1g== 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=EqH0ZsHiaEtwhGi9zyJrCeQh7KgGC2k47TQ9WU71+SM=; b=NvieJBEY AqZCkkdT9cfTcHNcfv3MrAOB8DwlF13r3rjCasDMtlNTGNy1sLqplD6iFqTR+f2B 6CdP4+zNaycV9ENcsLtr/wNvB8b49MJzrr4gMgAcwL0Ls3HLGBLO//8duqEwRhmg 0oalKDfWcIp6jOWoXAGcNTi62ro+OWxwFkiZdBkSUbg9dlKTIKRmYXLE3s/AreqK ADWSGjjA2QFpD0vgOesbE6YLG0Zgi2SPB6y/gN7tzOP0FtM0jdUrDgGbFG14Fs9c mD9Q5NaKufYF8fRDS1RW/PS+86yVzdDOD7EajMgbbe/EI/Q0PewOZx0PK3ZfYVSW 9P5e4FgYqfyJeQ== 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:33 -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 07/11] i2c: pasemi: Move common reset code to own function Date: Fri, 8 Oct 2021 18:35:28 +0200 Message-Id: <20211008163532.75569-8-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_093636_295278_5AA154E5 X-CRM114-Status: GOOD ( 11.28 ) 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. Reviewed-by: Arnd Bergmann Signed-off-by: Sven Peter --- v1 -> v2: no changes 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 d1cab11a4d50..232587c70a38 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)