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: 549904 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8E74C433F5 for ; Mon, 7 Mar 2022 02:12:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234762AbiCGCNs (ORCPT ); Sun, 6 Mar 2022 21:13:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234708AbiCGCNm (ORCPT ); Sun, 6 Mar 2022 21:13:42 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2099.outbound.protection.outlook.com [40.107.93.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E570A17A98; Sun, 6 Mar 2022 18:12:32 -0800 (PST) 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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7VNljfW/PX686iTMdV3u08XBJpkS0xwH3BXnfO52Q5xPJNmc7JwGEUF0PhzkhoydBIzg/qwqI+wsW42qUu+LoZY1xzXsH/fL6cEY8Se/Y/zkvdAa7DkHxnsn1xWjxO2QtBepWRcIYfhw7YcuNIp32P4bFUci2w+pwpoy/+RTwYjv5zI9MsLuh+TKJAI3cHjhRAcFP4/4u/BRLphk0mFDmfvFB8/KbmzTiXC7H57oha/Zb9AU7bB+FRxw/xXmD634SmKQqpgSnRPW6MdQzr5nzmelIi5SzE0/cWhnw3ld5c77JB9r6AdPaSzMsj/hKnEA7zUCKbRah7ksOdw9cTYXOvwFK2h7/9AJQCXEk8bUTotT9guHzyhW019fAYnAa52RF5ks8t4AyZdNX/ilPFS5sNWCAuEm/N/86CgK/BLo+Gxq8+Spxuu4fHOk6UAsCDhWrgKMId7XcrCIbqwQdHaDHTbVqnRfV9PDf3qK/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 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.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);