From patchwork Mon Mar 7 02:12:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12771079 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 4EAFCC433EF for ; Mon, 7 Mar 2022 02:15:51 +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: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=/G91a4J7T0Y/LIHfAMDVMAlqp7PdOLAkUlN7AgVgs4A=; b=V82v35dGOK/DL5 u9ePdg+XnZgoe2KZgfEKc0ULBHRylHLMro/GzaX2lP1cH+4Du5sFsth+pDgTJhLCEpT2bq5P6Mx/w d/oVxbJzQ5wnYmTy39jrhG/NDkkgPhcasDKXQajgvErkA1gH+0HvoHzqhmLYcEm+rkartsATPwsI1 5ir5BryOmYRjJQ8UmT8hsfPgCFc7Htt7oPWQwiu82p6DgLDdsTL5q5+/lBWnJh+5vmVMGdVwepl/R hDLHSr5h++EiLKkplUfyoBGbGSP/fNPtmMy3X0qKhS5xENF52knvZYMtgAobWXnWDguzXRKScyDGP Wlx0c8M7F/RQatPG61Dg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nR2sy-00FY7x-Gd; Mon, 07 Mar 2022 02:14:09 +0000 Received: from mail-dm6nam10on2072d.outbound.protection.outlook.com ([2a01:111:f400:7e88::72d] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nR2rU-00FXQl-J2; Mon, 07 Mar 2022 02:12:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gd0ylsI0ZUViY/RwXU0YnGr5rNKuaNJF0avVTrIc+f8V3G1vbUtW8TmoYOBJCee7AzbVuY6QQR94CHsAXLieyvSm1bXeyUzoKL1U+Vc6ISn1en7aF2BnIw1aN09OCddy1kl5Np2US3UKmJ44WImOu+cP+58Sss1sX414DoitGdr7w/Spl2VWbn5JViz8MBBleYQzQSEhcMHMStcaRN8dH7gmMAyRYJfOzF5diqpJbA9G/DnyW8TGc1Jnu732U0Mls8v+/OqL2Wsrll/C4bMoCFnImAxLmilMd0lrYKT9SRyK2aIr5I1IBdDDFCbS3CVJMto2BAhP5SKobXb5n8VZoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CbYwLr3ra++y9HNg8+DqdZvEcgqKSlEQD2pe4QGxE90=; b=dy3ut8ZKNU91Lx/JhLAC4+KDkcvw//U0ymwAYjCuxMPx5ZgkWY2/EUqeDT0Thd4ILmfWgDDhplJQ5DuY9KZWfjsEMpT6Bv8B8qBxUy/N27wm1Eqar0sFcZoOc7LmzzJSgaCdDXorVL9tLaFrn2aawCypjk+WEszT4th6/gs1xUAeozomaAwWFx9bDpVfoyvsbt3JIs4WBRbxBmCNdvXo40/QB25GxmO10DizZ+VbkSKcVNKEbIx+qDZmT19TvPqwff2BxB+7KBmzrf87LvrpzyVbQ0d6ISNr49+FCgxKrf5jmC3qTdnP7clIEBfHcNWdTWUd9uS88vSQ/adzmwJthA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CbYwLr3ra++y9HNg8+DqdZvEcgqKSlEQD2pe4QGxE90=; b=E0UXyzVgBECHk694JR3N4V8X2HT99tY1oUazKoJRI/Z4v1C8MjRcA0nEo30NYPGLns0zuYcyyWZ2zkmSavye91Qj6Dib88iFcuJCGcs3vIzf7ihXDV7WiZQzpVFeo9gvvcWmjiJz3/E1HB1N+ZRyCGfEZHfrj1Zu2mqJByklRvo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by SA2PR10MB4553.namprd10.prod.outlook.com (2603:10b6:806:11a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Mon, 7 Mar 2022 02:12:29 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7c:dc80:7f24:67c5]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7c:dc80:7f24:67c5%6]) with mapi id 15.20.5038.026; Mon, 7 Mar 2022 02:12:29 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-phy@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Rafael J. Wysocki" , Marc Zyngier , Hector Martin , Angela Czubak , Steen Hegelund , Lars Povlsen , Linus Walleij , Vinod Koul , Kishon Vijay Abraham I , Russell King , Heiner Kallweit , Jakub Kicinski , "David S. Miller" , Florian Fainelli , Vivien Didelot , Andrew Lunn , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Vladimir Oltean , Lee Jones , katie.morris@in-advantage.com Subject: [RFC v7 net-next 06/13] pinctrl: ocelot: add ability to be used in a non-mmio configuration Date: Sun, 6 Mar 2022 18:12:01 -0800 Message-Id: <20220307021208.2406741-7-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307021208.2406741-1-colin.foster@in-advantage.com> References: <20220307021208.2406741-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0174.namprd04.prod.outlook.com (2603:10b6:303:85::29) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b2d09bf8-db27-4810-6190-08d9ffdfee51 X-MS-TrafficTypeDiagnostic: SA2PR10MB4553:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KW4kEHuO3BnhBv5Fma6HdaiTqg0e3FudE3chwqPCAoZ/0k3slVYIa4jJtctxmJb71VK992oQeZfnsyRRthHuiDNpBpLqRbWXy+Th9twyb8sezJ06Vk/pFBfEt+ZcNqHoGMtMwB3PaLAGNA01/mvhJ54QKdCEPgxuKuvp1N5cEHDTYzbFYWyTW42J3a5SMojCgwNxKAWQb1HtGbycshU8Mly4TnrZiZrKqdIFpnAuzO7MoKz51O2ssBaSRswMDQ9qmWOFUM6FHzLq7cKSvr89B/w8VY7pxN+elJ9bNJNwVgOtqthxvMiesg/yd0dALvs9/+kWAaWXD5IfGbt7yt8NOX/Ld1UXQLeBNppegYDDGHThJSUGs66UDMttPTRSpMErwdlVjF9/mGu7P55y/1WAyKsZZ+xJuVEXJdhr2YWumQgZPTHjQy6gVkiP+5nmsSLqEVsdH607zOqHJkYvwfeYVh0b44E/VXL4/fGF5RfJggj8+q5E6/mFotwW5j2p7EsSCW7pCZ1LtFQxJHEZq9OTqr2637i4KlNE5IfYpax4Mq7VSTIv11HTs6/MeQGTktKgB0w8a4kzXulgfUieiYGmssIewE8fVo8K6Qxur6Mn/sFSRx02iRrt05Ev8XHLz/ofoRWOKqon5jmAQFHBflRU0Trgq0Qbdpu3kR8j3GlxMu7lswg1O6ygWlmFb5MpTxZeH91CTkYRdWCpR6iDxatT1w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2351.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(376002)(42606007)(396003)(136003)(39840400004)(346002)(38350700002)(86362001)(508600001)(107886003)(38100700002)(6486002)(54906003)(36756003)(44832011)(6666004)(6506007)(66556008)(66946007)(4326008)(316002)(66476007)(8676002)(6512007)(26005)(186003)(8936002)(83380400001)(52116002)(1076003)(5660300002)(7416002)(2616005)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ec7z8MfiweuD5EFbcNLahUuJ6ZWm/JOem76VqAm/BJ9IVyJ7C2K7wgY9kOgNDfktYnMyN/sVnCDl9z/JKuDz34JgEYJ4qtQbdIhowwQyJA/Kyeee2uIg7OJ38QOo8VoZjC2BLbL3xnnAi2oxbvp1mG7TG6OUY6sogHhN0vb7fSoIHKrjAaw2bUZhBslzgJfihBWRu3aMHTVsUCS7Jl5ZP3aVwqO3vJgULBQQvOEu2fococxKQ1C7xfsQ0bdbXOih/2/hfCyJ1F6k/asT6M/kgmi3ik22gjPLnusLGrTTuej40pLbg+YUB2MOEMUyu8wde4nXg1NpDhjNRvHBx3RQ+VOnRCJvs/Oqqd0YzoLBuxIyg2yT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4fHOk6UAsCDhWrgKMId7XcrCIbqwQdHaDHTbVqnRfV9PDf3qK/Q5LxshKrpoupXsFkXTuWuM8JztC/mX1JwMahMtr5MhKpg8ACSuFYgrVajk55oJq/VCBmE2GIVxyPeYGQrN0/lHAksINvyvj4gWJVNgRsuDE8hGFKd8hD8/MVnm7CJtbvCA/OwUJsIkMrnuFjMh5qq21QC9Gb+7QxyERU99qYS/2ZNK/ciEwQuXQBk1LSWK9AnIUezEfgvA== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: b2d09bf8-db27-4810-6190-08d9ffdfee51 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2022 02:12:29.3392 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OWcSdwh/0HMA7QfQlweKSHCKqgGXegqmdddMZ5COU2Q8UzuS9v5TgfsdtVVDwdtd0oAJo3g6SmMDnEa7ai87FUZouK/ES+nRsmDlj4911X0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4553 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220306_181236_696926_2978FECB X-CRM114-Status: GOOD ( 15.67 ) 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 There are a few Ocelot chips that contain pinctrl logic, but can be controlled externally. Specifically the VSC7511, 7512, 7513 and 7514. In the externally controlled configurations these registers are not memory-mapped. Add support for these non-memory-mapped configurations. Signed-off-by: Colin Foster --- drivers/pinctrl/pinctrl-ocelot.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c index b6ad3ffb4596..e327bf00d447 100644 --- a/drivers/pinctrl/pinctrl-ocelot.c +++ b/drivers/pinctrl/pinctrl-ocelot.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "core.h" #include "pinconf.h" @@ -1123,6 +1124,9 @@ static int lan966x_pinmux_set_mux(struct pinctrl_dev *pctldev, return 0; } +#if defined(REG) +#undef REG +#endif #define REG(r, info, p) ((r) * (info)->stride + (4 * ((p) / 32))) static int ocelot_gpio_set_direction(struct pinctrl_dev *pctldev, @@ -1805,6 +1809,7 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct ocelot_pinctrl *info; struct regmap *pincfg; + struct resource *res; void __iomem *base; int ret; struct regmap_config regmap_config = { @@ -1819,16 +1824,28 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev) info->desc = (struct pinctrl_desc *)device_get_match_data(dev); - base = devm_ioremap_resource(dev, - platform_get_resource(pdev, IORESOURCE_MEM, 0)); - if (IS_ERR(base)) - return PTR_ERR(base); + base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); + if (IS_ERR(base)) { + /* + * Fall back to using IORESOURCE_REG, which is possible in an + * MFD configuration + */ + res = platform_get_resource(pdev, IORESOURCE_REG, 0); + if (!res) { + dev_err(dev, "Failed to get resource\n"); + return -ENODEV; + } - info->stride = 1 + (info->desc->npins - 1) / 32; + info->map = ocelot_get_regmap_from_resource(dev, res); + } else { + regmap_config.max_register = + OCELOT_GPIO_SD_MAP * info->stride + 15 * 4; - regmap_config.max_register = OCELOT_GPIO_SD_MAP * info->stride + 15 * 4; + info->map = devm_regmap_init_mmio(dev, base, ®map_config); + } + + info->stride = 1 + (info->desc->npins - 1) / 32; - info->map = devm_regmap_init_mmio(dev, base, ®map_config); if (IS_ERR(info->map)) { dev_err(dev, "Failed to create regmap\n"); return PTR_ERR(info->map);