Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1055900imw; Wed, 13 Jul 2022 12:55:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1srNr5KldUEKpoz74zN4iT7Yvc2k2oV9iConbh0y4IUhnZdBy39mValnGoy//zobTlgU6rz X-Received: by 2002:a05:6402:11c9:b0:43a:b054:52ba with SMTP id j9-20020a05640211c900b0043ab05452bamr7359473edw.344.1657742153961; Wed, 13 Jul 2022 12:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657742153; cv=none; d=google.com; s=arc-20160816; b=kRuIU5CEctIS4yVTWkBQksGO4ZSIZPmh1RfsdiEfmZszIaCOnsujLphST0OQ3usu1/ nu9WTQtEn80IuLjrvMK5DIPFA3t8EvX+i2WwQDmoiHRVm2/kAGPM3pYkA6PHMtKGsM8f mb/c1CIK3t3ArOpPwJsF5kPaWcQx8BsjBjA3gHdKKSSjDRgIck6372pa2XFZJ5pdjjBi sLx8xPyUIheZiigMBuurh9z8QaoU5lkh12RN0T9VViyutXVLSRBHC9cgy18FXEJGtVEV 7QmZku0VM8zc5st6NixuIKmcAynnBmIIn1KnS8ZrN4L6C9hAlgooXBRQodV5b4VnIw5a A/RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=W65IE/z7sxI8v60nh+84nQACBUCbfQMfbL4SVj9KPJc=; b=P18Yi5HoK1k0CqOluBkV1AxaFQHpHd0vlhCuf68eDZ8eMLTtYB4CtfvG7l1Yf9vvLG tjedZ5xrsqVmRIxcD4xKQd7SezYugHNLPkOkM8kv1OhZlCrh5otgJWub8EGxwqu91WJp h5ke4dC/JmcX3PqeljF9u4SrCYiXc2TECMGDnH0KqLm6hKPYWAq+EtdvLdVBtzU8GvQm pQDMbPPog7GciU4a/NL94aawjmDGYeRtWX+Ob6Bpkcx2R4f9SAlpmErYZ5VYJGGAgpjg 9uJHXk/csjsxJz1AEzOOZJfUYhAQsOEZXu7ky72oOjaQcx93dg+JQKkBFdIHM+afZlz2 KjFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=0LBkAXkL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s4-20020a170906354400b0072a6e7a054dsi17986168eja.975.2022.07.13.12.55.28; Wed, 13 Jul 2022 12:55:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=0LBkAXkL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236964AbiGMTeJ (ORCPT + 99 others); Wed, 13 Jul 2022 15:34:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236391AbiGMTeC (ORCPT ); Wed, 13 Jul 2022 15:34:02 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A471F220FD; Wed, 13 Jul 2022 12:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1657740841; x=1689276841; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=H7RWMMYujXqvojJ9xxxElCDGxgPhF72C+WxWSjwMkAw=; b=0LBkAXkLBPBI54ALLsg8pi+5hwAMPWaUcYg5mtv5lBIypX0HGLRb54j7 CETONYSLrJO4Y7zRUU/YT+ncoJniGMaWudD5WAB7NN1so7oY5i9ZT2PpZ Wetyry9ZGsdcPjCMwCCLIaAYUyhssT4E2SBcNVaCn2snocb4pBsDBvSpk dJbtwLg6yvuiJrEW+BmLGsQWR6/+Ef9Q+J3bYY1HqzdWpxAg3/bbbVbDK f1djSsY1ocvf5w/BDx83vmzsdzWTOZnAV50wxTQ2dGJi2hu1TdPNJ0+IJ yo3wNavF9/mWm3UWHFla4oXGK/+zSgrK3smQggOCLbPedXCKHgZuP6k6C A==; X-IronPort-AV: E=Sophos;i="5.92,267,1650956400"; d="scan'208";a="167716423" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 13 Jul 2022 12:33:58 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Wed, 13 Jul 2022 12:33:57 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Wed, 13 Jul 2022 12:33:55 -0700 From: Horatiu Vultur To: , CC: , , , , , , , , Horatiu Vultur Subject: [PATCH v5 2/2] pinctrl: ocelot: Fix pincfg Date: Wed, 13 Jul 2022 21:37:50 +0200 Message-ID: <20220713193750.4079621-3-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220713193750.4079621-1-horatiu.vultur@microchip.com> References: <20220713193750.4079621-1-horatiu.vultur@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The blamed commit changed to use regmaps instead of __iomem. But it didn't update the register offsets to be at word offset, so it uses byte offset. Another issue with the same commit is that it has a limit of 32 registers which is incorrect. The sparx5 has 64 while lan966x has 77. Fixes: 076d9e71bcf8 ("pinctrl: ocelot: convert pinctrl to regmap") Acked-by: Colin Foster Reviewed-by: Andy Shevchenko Signed-off-by: Horatiu Vultur --- drivers/pinctrl/pinctrl-ocelot.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c index c6e0232770b7..dfc8ea9f3843 100644 --- a/drivers/pinctrl/pinctrl-ocelot.c +++ b/drivers/pinctrl/pinctrl-ocelot.c @@ -1334,7 +1334,9 @@ static int ocelot_hw_get_value(struct ocelot_pinctrl *info, const struct ocelot_pincfg_data *opd = info->pincfg_data; u32 regcfg; - ret = regmap_read(info->pincfg, pin, ®cfg); + ret = regmap_read(info->pincfg, + pin * regmap_get_reg_stride(info->pincfg), + ®cfg); if (ret) return ret; @@ -1366,14 +1368,18 @@ static int ocelot_pincfg_clrsetbits(struct ocelot_pinctrl *info, u32 regaddr, u32 val; int ret; - ret = regmap_read(info->pincfg, regaddr, &val); + ret = regmap_read(info->pincfg, + regaddr * regmap_get_reg_stride(info->pincfg), + &val); if (ret) return ret; val &= ~clrbits; val |= setbits; - ret = regmap_write(info->pincfg, regaddr, val); + ret = regmap_write(info->pincfg, + regaddr * regmap_get_reg_stride(info->pincfg), + val); return ret; } @@ -1933,7 +1939,8 @@ static const struct of_device_id ocelot_pinctrl_of_match[] = { {}, }; -static struct regmap *ocelot_pinctrl_create_pincfg(struct platform_device *pdev) +static struct regmap *ocelot_pinctrl_create_pincfg(struct platform_device *pdev, + const struct ocelot_pinctrl *info) { void __iomem *base; @@ -1941,7 +1948,7 @@ static struct regmap *ocelot_pinctrl_create_pincfg(struct platform_device *pdev) .reg_bits = 32, .val_bits = 32, .reg_stride = 4, - .max_register = 32, + .max_register = info->desc->npins * 4, .name = "pincfg", }; @@ -2009,7 +2016,7 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev) /* Pinconf registers */ if (info->desc->confops) { - pincfg = ocelot_pinctrl_create_pincfg(pdev); + pincfg = ocelot_pinctrl_create_pincfg(pdev, info); if (IS_ERR(pincfg)) dev_dbg(dev, "Failed to create pincfg regmap\n"); else -- 2.33.0