From patchwork Tue Jan 25 16:12:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Horatiu Vultur X-Patchwork-Id: 12723998 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E209CC433F5 for ; Tue, 25 Jan 2022 16:19:15 +0000 (UTC) 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: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:In-Reply-To:References: List-Owner; bh=Eo8GvPk97npLyGPHWy8s6j8azlMRE+WjfKp1xx6Jrco=; b=xa28wrz9LmcdFD tzfzEFHwGFAzagYy3xtdA4JgRPtQeHcfOFfHfbTj7KQe1zvKGyvITP1FJv8mHUoJGtJxYBEHt622D itQukS4gd2b4WanSc0PYXRIImcC6SwX0M1DwXZdeZrsRr6mu/qZEVViZVrwLnMOWaxwbsm5CykzXr O2maMyN9kDMVRzGniY8YsfohP58qvSs5oTF/G6oNYKxBBzZo6tkMnBJ4XwochdgtfmvjOFkUkhYtu C+ekPRqckhujXxWw92lM87leK5HpmYj8gK3iOm9IbBDZBgeCNWev4l+P1Oe2562i6JXahmzkga3e7 3dz748S8VqrWo6CsNmHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCOVq-008crN-7q; Tue, 25 Jan 2022 16:17:43 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCOPT-008aRD-Hf for linux-arm-kernel@lists.infradead.org; Tue, 25 Jan 2022 16:11:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1643127067; x=1674663067; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=xRYkd7VewVRjl2nwBsabmztrBiW/NhQrxdxHXY44LgQ=; b=w/y5gUMajtplyCast5+TtUPzWQnVVb26IKP7F25ju7SkHy1PIMm8+Gvh F051ibNjUTd7WYcxu6NN92V/DvE91P1/c3eZ8w5W/W+zJR86ZnfaTM17m 4w9K8AEesJUUAsMk0a1KCOmFF2FWgg41YgK5rJP4lv5H6CbA4ZD8s/Xa3 YKhZEQAfWCcDmsEX56UTG0zYA+uf9umkrk8nn8iAkqcfDXrcidTqQywM/ zvXBCkgrVTpIgeFu0hxz9hKB1JKHvqle128p/vuLouUpYQtNrXJM+rBBN OT+hrHsR1nrkDzkbJvsSnbe8M9yCkhhx2d2kYs7YBJcI7DEIHR82VbCFV g==; IronPort-SDR: 2ZX6Jzv4KYS6XAdsDpNOkUNCRiajSPWu+JvId5T0r+V3uhUO8t/v4s34gwICPsjqRKfqhXolFb Dm+k7QZPq00RnqYdIqcUSj8mig5WzuaVz3bqmSYatVHzrX6Syd60hMLDfjls1zr1A6w4b0/ymf fXXX7+JGgIZTOJ28PF3AQBxmoO7zyXNwwsyNWI2AleCPf0gj8PwvR8Afrig/iaLeXveMPs9D19 Y+kQ9ob4/IgsN2Q9wcebexiTGvA1r12eLJYOyBO8BqiRbmzINXtZE9l1x7V8nqFu20jKANHUDv IWm0SWF/xpWdVJQL7sajvG7y X-IronPort-AV: E=Sophos;i="5.88,315,1635231600"; d="scan'208";a="143829729" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 Jan 2022 09:11:05 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Tue, 25 Jan 2022 09:11:05 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Tue, 25 Jan 2022 09:11:03 -0700 From: Horatiu Vultur To: , , CC: , , , , , Horatiu Vultur Subject: [PATCH] pinctrl: microchip-sgpio: Fix support for regmap Date: Tue, 25 Jan 2022 17:12:45 +0100 Message-ID: <20220125161245.418882-1-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220125_081107_740063_721471E8 X-CRM114-Status: GOOD ( 14.00 ) 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 Initially the driver accessed the registers using u32 __iomem but then in the blamed commit it changed it to use regmap. The problem is that now the offset of the registers is not calculated anymore at word offset but at byte offset. Therefore make sure to multiply the offset with word size. Fixes: 2afbbab45c261a ("pinctrl: microchip-sgpio: update to support regmap") Signed-off-by: Horatiu Vultur Reviewed-by: Colin Foster Acked-by: Steen Hegelund --- drivers/pinctrl/pinctrl-microchip-sgpio.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-microchip-sgpio.c b/drivers/pinctrl/pinctrl-microchip-sgpio.c index 8e081c90bdb2..2999c98bbdee 100644 --- a/drivers/pinctrl/pinctrl-microchip-sgpio.c +++ b/drivers/pinctrl/pinctrl-microchip-sgpio.c @@ -98,6 +98,12 @@ static const struct sgpio_properties properties_sparx5 = { .regoff = { 0x00, 0x06, 0x26, 0x04, 0x05, 0x2a, 0x32, 0x3a, 0x3e, 0x42 }, }; +static const struct regmap_config regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, +}; + static const char * const functions[] = { "gpio" }; struct sgpio_bank { @@ -137,7 +143,7 @@ static inline int sgpio_addr_to_pin(struct sgpio_priv *priv, int port, int bit) static inline u32 sgpio_get_addr(struct sgpio_priv *priv, u32 rno, u32 off) { - return priv->properties->regoff[rno] + off; + return (priv->properties->regoff[rno] + off) * regmap_config.reg_stride; } static u32 sgpio_readl(struct sgpio_priv *priv, u32 rno, u32 off) @@ -821,11 +827,6 @@ static int microchip_sgpio_probe(struct platform_device *pdev) struct clk *clk; u32 __iomem *regs; u32 val; - struct regmap_config regmap_config = { - .reg_bits = 32, - .val_bits = 32, - .reg_stride = 4, - }; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv)