From patchwork Wed Aug 3 05:47:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12935197 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 E1894C19F29 for ; Wed, 3 Aug 2022 05:47:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235622AbiHCFrt (ORCPT ); Wed, 3 Aug 2022 01:47:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233757AbiHCFrs (ORCPT ); Wed, 3 Aug 2022 01:47:48 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2121.outbound.protection.outlook.com [40.107.244.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC24F275F3; Tue, 2 Aug 2022 22:47:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MopFt6CFo/1jwPN8RJYbSIC7ZbMyM+HBJ3Sqx8ro/Fto+mgyUKmTaCxIiNyHfjLoNEcWZYbhfK8qlXFL1B8hUKBnnW5IuJLi5LhKEVxzRXQTtobIeHNNTdu6BDCZQ2FY0GiWPEt3art/QC1IEJzAgNmkXH1diq7RfZwWzIclbWr4V1yIGoJVGty80NzWqkqed7cNbIpWCJjj6wCtiENzhtbxk2u48tPIlywWiNK+GUy7rzpUvCelw1KvB4vJP7TyuRMUijl/qBdEc8WW6LW39OBj0BHP2tPwB0P76HcNZt6XE0y8wZttRkiOlXA4/y6xYIXjpaA9FZhwFwmEIGw+SA== 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=5/XcCw7ZF/2dEB8dgem0EIgpd5fGnQGzsj6FzPHDvzU=; b=P1xjTSwkzakoLZYUv5TKE+NjrTUk0rgj3l+ttyoizUlTYhianNXZcQ3uYpKRZbRsrIynGy4RtXVT6DYkI5hPM9qlz/G43pKNhjl9J0Ri9udwxDYN46aYSOdM+JPhDh1zviRswtyYW2r42G0rKvticccclJ7krJPOowBWiVg2FKEm7hFdGU0BELqQSUb95qquFM/weCbWW2BcaHGFU/etiE3Kzg8FxwjcBl91yqTeP8m0juhe/jpBMNWioEUnMUGval+ljBlVQdXZuvZNC/4QV7f3K2+eUYCR0bXLG9CqVueeJPQ0wDPpqEIBq5E5D9G86BqTBkPwS3T0AQPd6Zo97A== 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=5/XcCw7ZF/2dEB8dgem0EIgpd5fGnQGzsj6FzPHDvzU=; b=Kltx0wvMQAO8mO0KGoFXzEK61vXVsRolEUYOhjD99S2BvOe42ZGDUnV8uRpQAG+Gg/JDaIRV8wu4h3MQRN92MGhaqCjdUMf6dd6YXx+K/W/6GAfBXnsWLIheeGXHl+6SbAMs5ArmUEZhRQjM7+p3+UPikYvLq5u3rxaRH8TShuM= 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 MW4PR10MB6438.namprd10.prod.outlook.com (2603:10b6:303:218::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Wed, 3 Aug 2022 05:47:44 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee%4]) with mapi id 15.20.5482.014; Wed, 3 Aug 2022 05:47:44 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com Subject: [PATCH v15 mfd 1/9] mfd: ocelot: add helper to get regmap from a resource Date: Tue, 2 Aug 2022 22:47:20 -0700 Message-Id: <20220803054728.1541104-2-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220803054728.1541104-1-colin.foster@in-advantage.com> References: <20220803054728.1541104-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR01CA0026.prod.exchangelabs.com (2603:10b6:a02:80::39) 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: 00ab748f-59bc-49bc-633b-08da7513b00a X-MS-TrafficTypeDiagnostic: MW4PR10MB6438:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5dz8K3z0wr5aGwlQ8MN47Zf53V6b/phzNGtVMAWWm+xrT/uAXsDYSkT6g+19eRcFCwUsIidHfTBhkzCBTovo6S1vz9aw4Ia/LOs5AYqkwv9IZcwZzPGZxqyzEhkNkl8wrUnojMuTnXvsYXHW9brd2T8YNxlg7TQTHGlAwGdIbRGvEavqps1AcBFFuziou9S1RAlLAm+96Vov+ugF425UWOdZC3JvpqlgzRbTyxxcN2EcO+dn9dVbgH8rUc9IPrEyo4O1+GKxrCpim+6LIPZ6WEiWfDlPJjr0OD4gFv6w80rHUtHPL06TLYxMLz34JdtBBfjJ2rGeWNfMDG5fJm3dS/2CWqYNHWxl2zRS4LkH4cDfnq1STpouWbsqLNjSF2PuOgVN553+nu9x3+5AP/S/1AMJSYarU8+TzAamI40o8PyHrZL8cbFXvOarvyhfUL3ocLDehI4pK2M/E0WTMFm3jBAjrj6Egk1zMqGpHZE1pvqeu90QUNvqXWvyjqpVezYRS8XakJG7OMcDZ3ugByhfWEC+cKT+Ajt6OVt8/7KU8uMce+f+Murs2P/UAzKap2AquxwoEeInj/gqBw7uFX8z34N/Q8MfI3c65YQSnUTGtsf7YDSKOGTA8qW+YSs0T8XBVhXU977TJ9Ekt/MlIkrbUgY1UvGzW0uprj9DozsfRHIhLn+T/5qLoxC8Jn9mqOUdJck0ttm1H+ZepZyUgSZw4GsxLmc1mepM8oaeQhoXmj8WGU53NtZSudX6ZrQ42VlFDgxxexS2k01/FK4jK712SWF7eUnjJI3TMXV7//HABpc= 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:(13230016)(376002)(366004)(346002)(136003)(39830400003)(396003)(186003)(41300700001)(6666004)(2906002)(6512007)(26005)(52116002)(1076003)(6506007)(107886003)(2616005)(38350700002)(38100700002)(86362001)(83380400001)(5660300002)(36756003)(7416002)(6486002)(478600001)(8676002)(4326008)(66476007)(66556008)(66946007)(8936002)(44832011)(316002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uxlS4Zcy0ZFe48H4Bv/c13Pa55HTP7CQtXhM1FMOuikz2mx4eFEnhJU3OF2NQ6wmQfWo0JQx8UXZ+SnOgeGtHetkD3gsnhyhfvXn3Wf0r75nVuFqpT8+mDVrH9OWv4NemVuh6eZwrqDDCks3w+9VR0Eme5IF8Z7upQp13p0wFFAS2f65GLdUUmqzAJcABwR2a7DZ+WcAfnqvxNINc1KQtwPSDD6zE5mtmbRxZ6H3s+KqcivfvBWS4rKXJcFxBrbhsxmte48uJQ6FtfovJjkZukW/zygt6quWnW+MYzkOG7Yl+4UMNsBRmCCaRoUTiXOoh1pmTVAyGAOHEerdD8mUo9fYEfqnVOlIGc+vRSsCWv29Bb23NO6kzYhUj7kaaPzknwG0INO/SxZ4Rk6jXYSP8oQrOVOB2cqx5uNM3Q/+YW91UamiP1VzQNpAkE94JdyGP5NuzyWxgNiJTBqSzYjxW+Hh2eRcHntRPta/+d5TCR5Uw/qGHus2FqmYJq7Eoel8povlC6mNDKEcfOcwdaiyHPZVUPG36ZaG/WCcH/iFJWiD4XnVO5HDX2tg3OeFIByxAhvMYM7pscypt7Nl3eb6a2IF16J7v3fgaw8quNsH/Hvmjly50ZILuwBpJBgrrYpaCqxY7jMyQP5onYypwDrbn2twMx3vfb3bnD04tNsrve7PhlsbcA5qtcV/Bfs8LX6HjnT+7ZHGjBP5kvYbBg84ua96If7nqbkZ2eOHjw7D9xD8CTlmPFub3GbKRdaOOFAiHj7Bs++ff79sFD77nK8eV54oakadh85SyV2GTgAWnZ+19dfwY87no/DFzj6wN9HTl3rwQZ2JuFIY254UEYxz/XtC3qYig5lN2AlTmJnfKclidJSVWL6Vp6zbiTgrP+GPjPKYEgdmIM+PvNuqUqScZgvtCticb3daKm/zOJHRX8F768iFAJSli1pbsYTLDvSGPUYA4cr5MrZ+YaLSbq/yFjVgLcZPtISTCGonSEnx2chniPvyVemOMWwtYPmpdOwf+JuHjC2uxt8QApM7CdgAmjLgI/GJ1Idv2daqhUf97OHWy/sZGgro6B2jGtcxEooiVTvB/UF3vU4pYfMRep6WmiBNRmFeKrWb//InlhBrg/8yBI+9m1SDiyOgq4Ko3vaWgIzy1qv96OoZ9VLOUTOYmFFRs8R7ls/wuwxJmU6VdW+bZDG0P5szlDi7BJ3DF1Xcvx8uaei3YzTI+uEM4ceb0j1e5IZmII+tsnPynAdi4u89OikFKFsXhkVJtWQKiY+Bx2Kn12OfcDEa8L4uWof8EiHARWsFhQAJaOJocWQPHl3PvhhQ+UcJPZzSYeOtvZd6YP5CJ6AGjH/gbiPLabnvqNnCbBiIqDuYI6Tzxj/+Vgj0FgPcDVFzbFGqNTxphZ62JLfk6q5BMYsRMEBwfrMsEJUFUZmnWfvdMVuIxvu6nqrSJg2eZBqtfGCCzX7wx/29h0gHfiWXdg3GzLXjP3cqOnl824jrAEQ63k4M1s05cqK5RPYfMQLSgg42Mi2GsyxuaHpXidPDWVqBszHt4BW0L/q1vxrajkQOItfTXHL5m9iIjLbwCXadb871Hx1lBnrrq8VoG9gU3cXwaPLhDvrvnA== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00ab748f-59bc-49bc-633b-08da7513b00a X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2022 05:47:44.6989 (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: bm/ti1ZaFhphUdZBQ30Cdh+xL2Trp9NtLxgFRNcT6bE8nC9AHYuZXC0cYvyUlwB86YI2FByGhpW+s+MrLUOkyIiCLlLpCTgj7scbPZ0eFPA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6438 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Several ocelot-related modules are designed for MMIO / regmaps. As such, they often use a combination of devm_platform_get_and_ioremap_resource() and devm_regmap_init_mmio(). Operating in an MFD might be different, in that it could be memory mapped, or it could be SPI, I2C... In these cases a fallback to use IORESOURCE_REG instead of IORESOURCE_MEM becomes necessary. When this happens, there's redundant logic that needs to be implemented in every driver. In order to avoid this redundancy, utilize a single function that, if the MFD scenario is enabled, will perform this fallback logic. Signed-off-by: Colin Foster Reviewed-by: Vladimir Oltean Reviewed-by: Andy Shevchenko --- v15 * Add missed errno.h and ioport.h includes * Add () to function references in both the commit log and comments v14 * Add header guard * Change regs type from u32* to void* * Add Reviewed-by tag --- MAINTAINERS | 5 +++ include/linux/mfd/ocelot.h | 62 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 include/linux/mfd/ocelot.h diff --git a/MAINTAINERS b/MAINTAINERS index 28108e4fdb8f..f781caceeb38 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14467,6 +14467,11 @@ F: net/dsa/tag_ocelot.c F: net/dsa/tag_ocelot_8021q.c F: tools/testing/selftests/drivers/net/ocelot/* +OCELOT EXTERNAL SWITCH CONTROL +M: Colin Foster +S: Supported +F: include/linux/mfd/ocelot.h + OCXL (Open Coherent Accelerator Processor Interface OpenCAPI) DRIVER M: Frederic Barrat M: Andrew Donnellan diff --git a/include/linux/mfd/ocelot.h b/include/linux/mfd/ocelot.h new file mode 100644 index 000000000000..dd72073d2d4f --- /dev/null +++ b/include/linux/mfd/ocelot.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ +/* Copyright 2022 Innovative Advantage Inc. */ + +#ifndef _LINUX_MFD_OCELOT_H +#define _LINUX_MFD_OCELOT_H + +#include +#include +#include +#include +#include +#include + +struct resource; + +static inline struct regmap * +ocelot_regmap_from_resource_optional(struct platform_device *pdev, + unsigned int index, + const struct regmap_config *config) +{ + struct device *dev = &pdev->dev; + struct resource *res; + void __iomem *regs; + + /* + * Don't use _get_and_ioremap_resource() here, since that will invoke + * prints of "invalid resource" which will simply add confusion. + */ + res = platform_get_resource(pdev, IORESOURCE_MEM, index); + if (res) { + regs = devm_ioremap_resource(dev, res); + if (IS_ERR(regs)) + return ERR_CAST(regs); + return devm_regmap_init_mmio(dev, regs, config); + } + + /* + * Fall back to using REG and getting the resource from the parent + * device, which is possible in an MFD configuration + */ + if (dev->parent) { + res = platform_get_resource(pdev, IORESOURCE_REG, index); + if (!res) + return NULL; + + return dev_get_regmap(dev->parent, res->name); + } + + return NULL; +} + +static inline struct regmap * +ocelot_regmap_from_resource(struct platform_device *pdev, unsigned int index, + const struct regmap_config *config) +{ + struct regmap *map; + + map = ocelot_regmap_from_resource_optional(pdev, index, config); + return map ?: ERR_PTR(-ENOENT); +} + +#endif From patchwork Wed Aug 3 05:47:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12935199 X-Patchwork-Delegate: kuba@kernel.org 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 868F1C19F2A for ; Wed, 3 Aug 2022 05:47:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236174AbiHCFrv (ORCPT ); Wed, 3 Aug 2022 01:47:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235740AbiHCFrt (ORCPT ); Wed, 3 Aug 2022 01:47:49 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2121.outbound.protection.outlook.com [40.107.244.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D565275F3; Tue, 2 Aug 2022 22:47:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dJvDrkBhpjLBghSyb+1Nd4UJ2I5W2m2zf8VA2DN4G/0uJipoNHXlAsk+KKyZDaJ3wvSbLHv/+3mc2H5uzbSNMmNB93Sj/Mx5fnMaZRjEvqqKPiNSf3hNR4usbj20yTuBtQdrQpS1Bts2+EHSi6TuUD4oJ67XbI2idclhtvGud6+yl5SjDx6xfvdKarruDC7dCQrnBp2Rmiw8BEoqyvE7T+Pqqx1vmCwcUoF1tZy7koPcgH6X4zwNnaDJBCn+1NGKPgsbNQWcMK1Ijc79uQINWfhZnUd8xQXs12WlrmE6kO89y0WKE+XY5HzZS2e1G6JtQU1EZlTvIJKLFQJh96R6Kg== 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=9uVEXnd1+BBfpjQ6xPn099CA0d48ZgPj2KtjTmL7xr8=; b=antFEKtLGcoXk+++tGrDMDFZP6tI2WWpb23xpmG2BVz5gGGuSnEEF7y6b0IJUT2HXyITnBQDS69Mdp/zFtpBEpK3/MG335ao/VssqQX+SvZqVhjBWfdEfrhbM5O/thdK4xXw/YpiVflzgxyxG8kD8JVHkda3EBLIKcOqixfLw7wzjCTveL+dfMeyeU+XC355h3f/L0RTkDJjUGfxtgw2GBF3lDbT+vW3Uo1mq3WIDeoHb6pDjv49JBESMKVvMDAEpDXI4onjMizRSqTuq9ibnDaiqksq+mcYJ/tP6vpuetGq3LqsWC7KOAPhVAp9NSnX/hSJP0s6YxKxH15hYxnECg== 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=9uVEXnd1+BBfpjQ6xPn099CA0d48ZgPj2KtjTmL7xr8=; b=RJHAtXnJwNs0jSZL92iq9lLcdY7QJxrvpxgWKV8qFQYraRDSvUAir75QPhfJEPeZ86SKMPMBEtdmb5GFpfKWdGyrXWgagvtS02ltvW33FJzMf1pliSl9niOOD4urMVqv2Kbs17qczDBDaRNI7HRhm+4CRqLVZUQmrPYfqCQM/tU= 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 MW4PR10MB6438.namprd10.prod.outlook.com (2603:10b6:303:218::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Wed, 3 Aug 2022 05:47:46 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee%4]) with mapi id 15.20.5482.014; Wed, 3 Aug 2022 05:47:46 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com Subject: [PATCH v15 mfd 2/9] net: mdio: mscc-miim: add ability to be used in a non-mmio configuration Date: Tue, 2 Aug 2022 22:47:21 -0700 Message-Id: <20220803054728.1541104-3-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220803054728.1541104-1-colin.foster@in-advantage.com> References: <20220803054728.1541104-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR01CA0026.prod.exchangelabs.com (2603:10b6:a02:80::39) 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: 49ff1ac1-c566-4b02-5322-08da7513b102 X-MS-TrafficTypeDiagnostic: MW4PR10MB6438:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5Oiw9+0lTxwb8DCGcVCxxdHGBksxbQC4MnlTynwWrA/3ibTa8mK/ysYzyXnZfTum4fg6ffA418aS4izyt6CzfTm1uysPgqY7/tSPk0LGIrQJ7QfCj+/pxTHGJqsKrgRfLsNmxGLMWOM5zGFsUZwoCA0wvok00BAFyR7C4ENKDdNLbV/aVME9vL+cAeJ4soVy04P+itjazmrP5Kd3CcX5/MDMCSt8H4t32CxjAXH2SBZioD6Jl71uUY9jQ0d9iPJZ3851qV6hUiv47qyJq6NP1G0TfseIqPzmPHisG+I2SHhriIXxDFOEX9UEHEwfjD++KcDWsnR234zvOxDaFhcktZABCTuY8Rkn2xYBykrupENIEogFKAbzRwFDPdNLvd/gyP61Ol1hV4W+5ZpDKgtLhmkkc6OoKLPfYEXM5xg+Fpqq5seXV0mjV+fRUXQVZapFDJqKYhLuJFkwwbvOJR8/zIxauTUB9rZSu770ZzPFp6wwIDCQ8bKS3X12u1qbIXtaEKYLQ9wO4qIcpLOpix29RghqlcrqRIK4NlVuoSZcNnbtoAi2T7FHmW70Vy7ZTSYBLFitpoEwmClADgfpjfZ6IscYSCHZBMm4zqepUUvfu0aCeT9082KKpjAP4gHve3HPZe/MAutaxbsTLSj/rQeRy2XAKd6y9AuGRgFvZh4qL0J9ghNfuK9178WF+Vds6zMm2nWoNcCoMCE/7o9MRZiln8njcfCpapp4kqYcsOpkt/4gfDxL92RbHILndEhEC6gXFlXocXZDtPvCPh58ymyRJQRQuDC6kVJU1+4a4Vugckc= 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:(13230016)(376002)(366004)(346002)(136003)(39830400003)(396003)(186003)(41300700001)(6666004)(2906002)(6512007)(26005)(52116002)(1076003)(6506007)(107886003)(2616005)(38350700002)(38100700002)(86362001)(83380400001)(5660300002)(36756003)(7416002)(6486002)(478600001)(8676002)(4326008)(66476007)(66556008)(66946007)(8936002)(44832011)(316002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HOYnmv8C8r32kgaYa5tlEf/nCtMrlInwhe+qJVkrsVU9dFXEiRC4mCAAtcB/eBT+C/bj+v4X+rO+BKStqOHONX40mLlRy7VExV6fI/hUclMpvBa04W2BX1uz8VCne3ZjuUKHMF4WRZNfi9ie6OPv7b/7pQ9HDJ5STz/ofYztNHSejcbCzSFbWUwecDN+D6xcwuQ9wLupXEEX1W4LAgYm1+l3K8fL6MevLPI/wQnCGfv0X08/VBwmPUur4zbdQBNBu2Q6pFRro8ePyaZRbGz7YGHw11Rs26hZnrWOlgyG5RRw9QBdnRdOqrwzJttxJRqoaR6HxKlO7nI5NU3fft+VGGlyEp4CotdXw50iKxKzNWAahkvtf1WdObcQGvVkrpf5u6xLg5OZB/YZ/TahtcUR7PMYqdAI3Yb9t2LNXxtOIqXXZD+HkIGDNFmTW+EA9B9VFXVk2+meyVuWGQ+jWNzgFqvLgwdQN3r9ouhaTrk+XMdpecIJTvO9Ly+u5lkysAjXCzBxij1GWxptxykGAktPUXwV83fRw7BlLqmv3SteCwKvDxVnGBajN9rjFdXdOlxIAKeA9pq7JerBTGfoe7NG4RcO3i7H8BBewbnYL8Fau/44dIZF0GQQSQ0v1pF1wl3a9dEOxFw2KgTOOsgRjRDKSozUtPw8/109A4nDSeD/QbB6qup2Pu7nqgCvadDKR1EgCO6eUD30cPLfQjJY/QEqX63rv/fMYKe26fN6FoOJ9aIgPHbAcmPkubpwjLVP70Nn9QGMdI9w1ckTPn6mpEgVctm+cnqXyLCpAMW5/tGtpw2zR/PwgscHrFH/+eI+oABWq2syjj259w4Ll+6eU9BVgg+Ky8PcM6vDCgkzgOHCHiy2/sL02hQq4rkiHpFwe6HjqerxcJRAD+G3oY07xMKv5mqy18Z6OoDG92moGMBEey32l5GCnlvC9LuYdXWOCnjtpNrPnI8MSCD+K2QJA4xJtHC7wg88ijAVt09wKWTZnmWWK32dFl2nOiZaL8lQVC2SHYDbrzhajxfhVEIf6q/Ypi06upetp7MRlNAPm6jhmLvGEZZs853CbHEJYGbW9iTqY5R5867m4PItED1ZcGimWxR3UP6C7Fe6xcBhahN0fyjfQIZsvMfWflnd1W5qY86qrm+3YemXLIG/vBVHMn2DZPQZh0A/Kr4l1t8DDkiYEygw0k5qPry0YwnlfdPz6LrRHTVyyaNkZkmQDTs0Dz/bccLGO2DXpMJ/7sKUX38KrXQgsMRvvvlvG0Bj9OMULRfLbLAmUys/FyidtPPeQxpA1l9tyT73vyNVnXlE5aEl9pZYxN4B++EPmdyrWlB+5DP20dAmtJFm3oAI5SLm+FvmQJWFVxdnjwiZKMiXRRxBOHd2MtORE7q2iNRiL6/UpCE7snBrqPiqfFk/DFpjZCJ8KN3g2cyvGzsA3Bg1Qg7DzQeWGllYT+XlYkxyJ+ZMvufcg9xWvPvOp0V4SohVUcuXZXT6O1bxviwvp4QewvKKX+0LsTV057K4KWCrhRn8+cgGC5gyon8+KHpj0H/gOqIR6DT77mmjLhha5mz0D0l5p2wxnlhgtRnD7jLxfe0JZw8JSdRPBLfxgr2cDc2rJIrB7A== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49ff1ac1-c566-4b02-5322-08da7513b102 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2022 05:47:46.2300 (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: o1GyD8LqqDPXS6beGL1smBkQpzUXRGnFIlWc2463Sbm7ZX6cEDmlKAqPdPtqshBftnVkCMHJDngMtk63hC7jREK9uFaj7qoYwTQwlthoYoo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6438 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There are a few Ocelot chips that contain the logic for this bus, but are 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 Reviewed-by: Vladimir Oltean Acked-by: Jakub Kicinski Reviewed-by: Andy Shevchenko --- (No changes since v14) v14 * Add Reviewed and Acked tags --- drivers/net/mdio/mdio-mscc-miim.c | 42 +++++++++---------------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/drivers/net/mdio/mdio-mscc-miim.c b/drivers/net/mdio/mdio-mscc-miim.c index 08541007b18a..51f68daac152 100644 --- a/drivers/net/mdio/mdio-mscc-miim.c +++ b/drivers/net/mdio/mdio-mscc-miim.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -270,44 +271,25 @@ static int mscc_miim_clk_set(struct mii_bus *bus) static int mscc_miim_probe(struct platform_device *pdev) { - struct regmap *mii_regmap, *phy_regmap = NULL; struct device_node *np = pdev->dev.of_node; + struct regmap *mii_regmap, *phy_regmap; struct device *dev = &pdev->dev; - void __iomem *regs, *phy_regs; struct mscc_miim_dev *miim; - struct resource *res; struct mii_bus *bus; int ret; - regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); - if (IS_ERR(regs)) { - dev_err(dev, "Unable to map MIIM registers\n"); - return PTR_ERR(regs); - } - - mii_regmap = devm_regmap_init_mmio(dev, regs, &mscc_miim_regmap_config); - - if (IS_ERR(mii_regmap)) { - dev_err(dev, "Unable to create MIIM regmap\n"); - return PTR_ERR(mii_regmap); - } + mii_regmap = ocelot_regmap_from_resource(pdev, 0, + &mscc_miim_regmap_config); + if (IS_ERR(mii_regmap)) + return dev_err_probe(dev, PTR_ERR(mii_regmap), + "Unable to create MIIM regmap\n"); /* This resource is optional */ - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - if (res) { - phy_regs = devm_ioremap_resource(dev, res); - if (IS_ERR(phy_regs)) { - dev_err(dev, "Unable to map internal phy registers\n"); - return PTR_ERR(phy_regs); - } - - phy_regmap = devm_regmap_init_mmio(dev, phy_regs, - &mscc_miim_phy_regmap_config); - if (IS_ERR(phy_regmap)) { - dev_err(dev, "Unable to create phy register regmap\n"); - return PTR_ERR(phy_regmap); - } - } + phy_regmap = ocelot_regmap_from_resource_optional(pdev, 1, + &mscc_miim_phy_regmap_config); + if (IS_ERR(phy_regmap)) + return dev_err_probe(dev, PTR_ERR(phy_regmap), + "Unable to create phy register regmap\n"); ret = mscc_miim_setup(dev, &bus, "mscc_miim", mii_regmap, 0); if (ret < 0) { From patchwork Wed Aug 3 05:47:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12935200 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 9177DC19F29 for ; Wed, 3 Aug 2022 05:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235999AbiHCFrz (ORCPT ); Wed, 3 Aug 2022 01:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236006AbiHCFru (ORCPT ); Wed, 3 Aug 2022 01:47:50 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2121.outbound.protection.outlook.com [40.107.244.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADF8E422E3; Tue, 2 Aug 2022 22:47:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aPt1LAFvX653SYKycQU23JpSNzS7TRxDmgS+VXLMfHvFqIRerBYKofkirJfJzoq0tqJcxF8YaIs56DdfsgA1FTVnEwP3pJVgpPcF6nnFYLSlYk9+iwfMc4zKQApkaZOHypF5a+BYeiWjBMKvE2dGY13cc4+D6Y80gK8KOLQWRfYyV7Bm+1xX9ZyKQIHWV6SvHRozdxHOdPkq/GWL7Zvbfv/yND1QvPsHfIOvPgYkZbn8q0Qr9wcu6qFZbQKbYxHdThC978lUMetD7bzTgQ2OpGSt/apjL9s3tsIAVBSy3WpSw6ZlWxeikpVQ6rZOpl7z8A+WJSNKXhIp2ILsEjq3oQ== 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=ONhj7qLTGlhFD69mVtCxhS+oEMNKIdl/tpoi1u9Mmw0=; b=E+tyzhIJhvioB5iw/sHPb6mqCBMmnoNlUniG8f8UjQWe7h36CoDYWdDn8KAWmzJ/MDLuD7xmCo31sPpSEZ6Wv5eRl/8qzoUoH/d7K9vdu7P9Q+yrzZIzCAi6/pz8Ph0gUB4CqRj8Yn3UQvtbN7GJjaAphJf1BZG6UlCgrKVEbR60zAUm0aqvvw/AzUuPfJeeswKQTzOkJ2Yhqxb96rCA1Xyj+Zxae7Mr2YcOcc/MVp216MJHT/pCOjFdnpDC+coet0jyM5L5a5XghvCezhAGCO1txIqd+mIxz2N5hJgRIcdikCxV7HGdZgH2C9c8ALFWQJrNDfbHyA754G1C1YXLdw== 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=ONhj7qLTGlhFD69mVtCxhS+oEMNKIdl/tpoi1u9Mmw0=; b=rO82DUWgEirhixFav0ZNCKqs3SBQHcWfQ+pMYcDNeRUFycUZj1Vzy/JLMEqQimiVDG2i3RzYndC59u3IhzhcI/l5/3vFtcxnkm+dQYSjqxcCRMRDPnshevt11YMqgVeeJo+DjoR2LulVekGVggYPzS9I9HLinE0JLSDXUXREyCQ= 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 MW4PR10MB6438.namprd10.prod.outlook.com (2603:10b6:303:218::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Wed, 3 Aug 2022 05:47:48 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee%4]) with mapi id 15.20.5482.014; Wed, 3 Aug 2022 05:47:47 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com, Florian Fainelli Subject: [PATCH v15 mfd 3/9] pinctrl: ocelot: allow pinctrl-ocelot to be loaded as a module Date: Tue, 2 Aug 2022 22:47:22 -0700 Message-Id: <20220803054728.1541104-4-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220803054728.1541104-1-colin.foster@in-advantage.com> References: <20220803054728.1541104-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR01CA0026.prod.exchangelabs.com (2603:10b6:a02:80::39) 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: 859cbd7a-a4dc-4c09-7e74-08da7513b1f5 X-MS-TrafficTypeDiagnostic: MW4PR10MB6438:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9RjZYdOWhALZkfjonYjKJE/KDAIlFMVoxFrrfHhVhFW3dk0+OV4vZWJ7B20Y/n4n7X16n4C6M5RUkaVNTSepVQnZS1w3IxKLxD9X8VU2ngCdiiVlMPAgzCh30vc0AE1+OL8UIvLVQKOCg6VzBXkTuzFCeWDI+6GMuTxkZiVG+chj1WnFqb8JhIpDdh2HTp3FMfZReP7AqH9vMlx7mLaBD1WNTOFEkD0Y3Mjko6Ek8WP5SdekUmQHeX9eJsiHwHXRMapYu9fTJ2QsN36sfl89aS0gHgp2rHeUPNNouFUX7w1+G7U/zP8Z6y7nKuDBn7VpUuCivmAaEOh9K8Hrj5pQR+MCE+AGiqhMpYu3ER1NddH26LVu2+S8w+K6DYYs7YmQhjNpmMJO846vdPW33Ak5bQ8d73mj57iR0PF8CPoWvAD9IUwdPbncIa62xc3YzENL2MhJtGUC8WnjJ6r9IwVaFyfHiq19N0gRgwcc9lfn3V00cRY/nGDEgmpNT4dBFiUVv7dN5sGe0iBZvQF1/M5ry4fy3JTXl9dc+Kbpqp6BpjpXX29J+YyT1KwAa5O7kfCucN7MhZwG1FmjuPlrYnXDJtZ+UPkaDzEAUrjXp8TjQldYA1oqdL5ZZM6UwLz8Uf82elaophVeFl3FcctdxVzZjmfeYYDmeuSI2ZdZlEDyAreDJCF8ePgEv3E8pxKvrCQLLx/fU/PnGGSO01s4jcLIYayzUfLzgssZ0fnggxfccQSwqZPUDi5QoBnnCEyAbfc80H1AlqcUvP1oJlXXeb/ZxoTctKpuJ95ATsJ0mBo+//A= 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:(13230016)(376002)(366004)(346002)(136003)(39830400003)(396003)(186003)(41300700001)(6666004)(2906002)(6512007)(26005)(52116002)(1076003)(6506007)(2616005)(38350700002)(38100700002)(86362001)(83380400001)(5660300002)(36756003)(7416002)(6486002)(478600001)(8676002)(4326008)(66476007)(66556008)(66946007)(8936002)(44832011)(316002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: puo+tDmrB7iIJ7ifHNJ9BWcIdpAfx3Qc/MsrxlnRr4x9E6G5YpIuWQlv1wXLrptecDOi6uK5hEqOt/jdKvW0ZQJ/TTNHMJU8Mvdidpq8//UHAugMxYYHSw3/Pt7+VjFUmFJWDm9p2jIMWQze9Fxbrjt0JuM8AjOYAeOKAdhNEz1XCVQ+VNjZjSdl13cIsi0dIECgrTb7uSgWb5ruKe73usWYD/8jALbKYzdFTOZr1kyATAP8XW7jjNb9UsQT+W/VeXpZ1dy8KBAsbUAyGF2FGpp773HX1lCyfl4eS/iZxaQMSeVoBOyiBghU/FFP/RLfodyh8lVn8F1fbzkyIz9QCd0OyGNNedhsori16unhMQiYUZULZkyuAvZLZooDPHKNU4idzFFVw9hxc6eHZn0FQV2xZa+aLek1thdEu9t4Z6+Q5ykK9iv7WdC5U2jU82TsQ2cSNIOHC8P35wFD4fZ/O7VPgqx7rf0S6cn56r1KNNZmd0US+g05XBk+6AqWi3iDy2e64/yzorqNQr3EgsaNbUg1rSdvs9J6cQ7L6gzBW38iJ67808fOe/4WpLuGTMo8S0cWqohhJVoViZzBNByKfnq2qt/DdihqBP15rMBGR+VrA3JfvHwNlZClSwkqtOgFnumVTPgnx6/h4e80dl4EsbnCqpDHEWOrcFa8NkCzbCDhpc0aNmCd78ATjZ8fi4BBvd7We1ZTj8lWCKzoaO+Iv1ey/wPu9R2g8l2lgAwMhmxwJP0qqg/9PJp/z2S3NvFgetiwS+vVqTrkdd25rU14ZGhur9ENe+hbwHTcZJd2QL4mFXDjcCk/vrvHAQeIdkiMithD2b8Tg1/bNoHT2GGNyjbP7/xWaBLvKiWgc+twgETlT03BLbubsggERLXfWSYY8iDd2ywLvy0ditBC8wNIEZaUBPLw6tkcTe99Bsbo3NR+SsNLqFUKNONU2dD6C2mwormtU0LxWYxeGD58iolU9srBRj/u2RiRuT1X3QBfWBJkRviIkwpou8Dk8Rv73NUwcCu3kWzJwd9V0XGqFesSDco1eQdoAKxpyCKlkZATETNgpOJILCDLScEnJ4jKlOW34KcdbcMSckpXW3cAVD24cExi+k5cyWJ148bpbFW+0nFr6yP4eiCWeJlZwx0FBiqLiruCwWnipPVX3jhhCq2a4b3NSoxT+aAzOBue3NRvghGPPsxEa/66UcT+Rp4bXASzf4TuVzR/43BGCOkgwRQf2TtQmc+kfXlZZ7Ec5f3hg9mJYpjNRZUvpSnNXnvijJHWZjPhtLq5xH47y7vDa7iQUGvFFBU60mhygxOc1Rb6ReRSCfpYsIvT76zkGArF/N1MrQTrC74ZrlpKNsqezQNqJihEQOU9bsXvOn+aOFZULwjb3OnCEBs+QR/z+SFjgtMSv7x5VQeTIu1KyOXGSwRI7Kh0WVUolEror1y65l7bQM/kM0iR5YJnAlgpmqLkfzQ3i24561GEgMwFtEHpbup6o/YM+pS9XzOOKUGVZX+tvnl7204MJLKDpv9oHBTFus/yFN0wxfb8wMct1THF6JsMhMfhjldaxTdBR8B3Bw7zgtKKag8b78mPbzgWP5UhKJLLXpYVYEaybi32vpp0pCjvQg== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 859cbd7a-a4dc-4c09-7e74-08da7513b1f5 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2022 05:47:47.8393 (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: s6DePjYlR+AVsHzV13oBUKzy7DHaOSkWLKn3a/I1a+Ss956aLSU+f7g0qtD6prHyUqbZZG6oQ95m28R0I+2VyVu5i84on2L2eAc1FhlW05Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6438 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Work is being done to allow external control of Ocelot chips. When pinctrl drivers are used internally, it wouldn't make much sense to allow them to be loaded as modules. In the case where the Ocelot chip is controlled externally, this scenario becomes practical. Signed-off-by: Colin Foster Reviewed-by: Linus Walleij Reviewed-by: Florian Fainelli Reviewed-by: Vladimir Oltean Reviewed-by: Andy Shevchenko --- (No changes since before v14) v14 * No changes --- drivers/pinctrl/Kconfig | 7 ++++++- drivers/pinctrl/pinctrl-ocelot.c | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index f52960d2dfbe..ba48ff8be6e2 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig @@ -311,7 +311,7 @@ config PINCTRL_MICROCHIP_SGPIO LED controller. config PINCTRL_OCELOT - bool "Pinctrl driver for the Microsemi Ocelot and Jaguar2 SoCs" + tristate "Pinctrl driver for the Microsemi Ocelot and Jaguar2 SoCs" depends on OF depends on HAS_IOMEM select GPIOLIB @@ -321,6 +321,11 @@ config PINCTRL_OCELOT select GENERIC_PINMUX_FUNCTIONS select OF_GPIO select REGMAP_MMIO + help + Support for the internal GPIO interfaces on Microsemi Ocelot and + Jaguar2 SoCs. + + If conpiled as a module, the module name will be pinctrl-ocelot. config PINCTRL_OXNAS bool diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c index 5f4a8c5c6650..d18047d2306d 100644 --- a/drivers/pinctrl/pinctrl-ocelot.c +++ b/drivers/pinctrl/pinctrl-ocelot.c @@ -1889,6 +1889,7 @@ static const struct of_device_id ocelot_pinctrl_of_match[] = { { .compatible = "microchip,lan966x-pinctrl", .data = &lan966x_desc }, {}, }; +MODULE_DEVICE_TABLE(of, ocelot_pinctrl_of_match); static struct regmap *ocelot_pinctrl_create_pincfg(struct platform_device *pdev) { @@ -1984,4 +1985,7 @@ static struct platform_driver ocelot_pinctrl_driver = { }, .probe = ocelot_pinctrl_probe, }; -builtin_platform_driver(ocelot_pinctrl_driver); +module_platform_driver(ocelot_pinctrl_driver); + +MODULE_DESCRIPTION("Ocelot Chip Pinctrl Driver"); +MODULE_LICENSE("Dual MIT/GPL"); From patchwork Wed Aug 3 05:47:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12935201 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 3B2E9C19F28 for ; Wed, 3 Aug 2022 05:47:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235103AbiHCFr5 (ORCPT ); Wed, 3 Aug 2022 01:47:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233757AbiHCFrw (ORCPT ); Wed, 3 Aug 2022 01:47:52 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2121.outbound.protection.outlook.com [40.107.244.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE4053C8FB; Tue, 2 Aug 2022 22:47:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xz5glsx7Jz9CdvFcl+Rc9xu4kgDXcfhWQSVk5p0i2e+Y+faSgq717Gro2pnpjjbMQGBcPEVleEaBhxZW0wvBpCtKVNxhaWtRxDVP8zaU+8uGbgpG8OsAcwCidBcA7reMKUJpMXD87twWAJgk+i+8ZcJrEWPjzZ1Lew6BPF9z33IRhvrgbbK2F7JNy1q8D6DjAex95kJpiBAovn0H1etogW8RowBmtULvxgu7hsX5xbPZPyXBpC9JurRe4XQNajZg4PnoSsPROoW4kM3uFPM4Ii13cgUK++MFMQKCUoQSgmZtpkrpAUyDJ+HLvx7g89xqcqS7eaolr82/Xl6v0zLXZw== 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=xQJjcp8DKF6pLkVeT7POjvJZIlNckNnBJ3zmE7qNBYA=; b=g1AV3OB7pXh/ammpFu+lNOSDJjSSPMVQLeuxfDI0UG8caMlXxnQorGpp0LfgYwnwmMQbgSQHsO+cDNzf3B6fL+FKFL+3ZYrnOzJLKmREhA1wie/3OeYtrt7nEmla0qeYcp+Z7dYEsApzr+MqQxSns63T86GQM3vbEO66ayE/UPSaFin7NzEUlxvhYHYe8rbii0sCThHI0A1thWgFw0C/Cs5yaLv8FFO368B59EY+VOyia2Ow4lwNQqqUix5CFWQbvPID8utLzG6JsW/AGTEUB/8lf8qJhg5XaTxYQEiXy3BoKn1EJAMcQBJQPygoVLM/eubfr9oS2kJKLPjIpH47xA== 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=xQJjcp8DKF6pLkVeT7POjvJZIlNckNnBJ3zmE7qNBYA=; b=NLDWwSQSaBdNxV7wL2YCoLEtKbrxwch7G/l8kUzN20941gvfcuI1xBG0oCkL0tAd9y+wKkaJFpGh0RbgYlGAOAzS1PZfJ+3pYUuLOGNcogcv0APK7T8oQsEffqBWpzDWUUaHY1aC4gGWu2jDcqg7iBWpyHUH5p+sEPQLAddLQVM= 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 MW4PR10MB6438.namprd10.prod.outlook.com (2603:10b6:303:218::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Wed, 3 Aug 2022 05:47:49 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee%4]) with mapi id 15.20.5482.014; Wed, 3 Aug 2022 05:47:49 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com Subject: [PATCH v15 mfd 4/9] pinctrl: ocelot: add ability to be used in a non-mmio configuration Date: Tue, 2 Aug 2022 22:47:23 -0700 Message-Id: <20220803054728.1541104-5-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220803054728.1541104-1-colin.foster@in-advantage.com> References: <20220803054728.1541104-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR01CA0026.prod.exchangelabs.com (2603:10b6:a02:80::39) 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: a520dbad-15f4-428d-4772-08da7513b2e6 X-MS-TrafficTypeDiagnostic: MW4PR10MB6438:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ofMeyDomJHUWqxkhiSg5FxSdLJ/nsHF+2rQvHwKRGR+Ck3DLI2No6FCAkObK7gGeiwZ1hFQ1b8z+L+jTuZhWcg6MiwSHZX/bDMgVjzar5nXCSbl+7WLBqriRVPoOS9J2Bb5vvE58/v3hPDwFruqXrwO4R73GvWLW/YGJF3O/Wf/xuFvBvj0Q0zfLVQ4YhxQVvS/spIW6g4BtRqAW856sC8u1vrfwWNEhseibjBg1ihmmxVah+IghUiFO2OLbycPYL67V1P5dfXt5bIUIcioE9xsjGLdkXIkSe9V/atLOo5rUMnyvYh5QryHHahOdym+zqBaB3smbtBZqyMjn14aCIQtxH4u4UdpLBPvbvplwwN/oXmbypAeLhOOeKztQPpnUS/ZYcHjlpaz5dwQDMHaFInzJKBKV4KXkRpavwnlJoo+fdMm4eQqeNfTGBu+Bq6T+Tpw1RCC9BCRRL2l/c6KasJGgF73Yzxo5rXNvXC6XuZ2tXU7dRRBHtZwBxyZ1yy2bg/btcrFhYpkH1XRTsgNebrDeFSBfs5DXCkFoTm1BKz0gYqnBPiOmfBoDyr/RC7RrCHMoC0me8UrK1PFibsyUl0w0anegrxYQqjam6utl2b0LQZbgwy7fyC3BrS3/OW21yCzpLLi3RpBrmbGoe+RlyUQ+QXyQLOmpfm07PLdLxSiZL+NF8DaoENmz/C8QGENAk8HFVPW63jB0TMfRVGGZku20Po+ZOIvul+ULCZKvKBRsqbTexeK6wQbdut41dYpDQo3WEFZcVNdPOCV3CblxMrFf6ErwnF+cAriTth569IQ= 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:(13230016)(376002)(366004)(346002)(136003)(39830400003)(396003)(186003)(41300700001)(6666004)(2906002)(6512007)(26005)(52116002)(1076003)(6506007)(107886003)(2616005)(38350700002)(38100700002)(86362001)(83380400001)(5660300002)(36756003)(7416002)(6486002)(478600001)(8676002)(4326008)(66476007)(66556008)(66946007)(8936002)(44832011)(316002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: j4en16UqVG2wJOncM8uIMuy9blM9uSthyQwuJQA9m8vXIzo7U7xOU/pwWSv77JYG7JAP4Mlmr87pMBC6wcJmldwrEvUflJgJvE+pJJzDDYUed/IiQyKAvYHjJPn/QG7KTrV+PznLzHBMlshddkzfmujpgC5CTRxFXlU39RKqmhy2G0lSETK6Pq9AZ97OjdSiasHjGRvWs3hzNouQThHDxM1SHN/6RCVU0AP7693qI6yXFDxOy6foXongVc2qR79k22fUNc7q60W9rjXggRvL3YCItShHajLaMsplRmWqKRU6SGLSP7kSzduMw3FzBMKJ2q6yChb93v0W2MrOnI3S+rGAKgcGf+Uf4F4ubxSeUhTmLzbwPm9SYuu1mlShXuxgzi6eo9mLRg9thzzgWsv1LUR2UZgAD0F/OxhLZFAl4o/urwkbqjZlmi5rw5zIrMNECXlwviwU9Qr/oODPCBbInd5ttagYcBLcfxx9N5cZVLeTDrE9Gsbl3WNatW8K7Fwjpc22b12Az18k05mYDs+rVHyvtAh5+22MLd+UCrZSJw92zYNm6gtPk2qRIQkyOqa32pThnYjpTxdm9TArI7JPKWfazjnU0yMwI+BeSrVHpwfaIagVBbEU7/Fnvw0rdIJFBzMEoT7M6KdohztdqxwWQz54/rFXrDeTzNpeDs3Hi1YZXKrHK8aHKKy0VQ/FhgWoPac2ciJsT9YzWpHmfdTp1Ov7QCfd76D0TWPJuBSqrVOb6wqj86cLGMhcngS9fJbVH9tG2zurkP0sihkRVgCU2ltBSPxIPAmge+whD8YdHmSxj9fFBLyqt05Vw0k+CeTAKM7//oicmJFxtsh8YOPQkiIHOJbm9yREvzE9IR8006cysDcfp6csXYUXD12n1Y+TOgvdWtS6ueUoHCG+WYskHMpquMWTEjpvfGdMCElLQcU8ZRe+VEgTb86BhZE5Bfzh11t6TfOJdy/vsGP3Mqh8BKwMinxE7pcb+6euFfD6JXPrh6MdFZDULJnVSz4B0WkQ50rOu/93G8UFvPdrEw9ReXjeqPy8cW52UfMRPo4PsEyp5+jmXtRLdfVPVYLWmMKAsGXuW2pkUeAVyhoOh1bK6ak5FbUnbEz0lqq7bP1IkZTnhBAgvF7ocvykoLNk8TFnU1Mcupo5+oSU1dMp05TduwGh/pBLouEVf4H7CQSqoDZ+PLkrqcgcvntnzBpOliGtOmjkqArxdPriIbPXMpZf1yps5n9KMap2Plf5nKxRlUh2W3MuysH+KgLm0OBBjKOaXUiV9zrvmOgKur257kgQb50CH8iiLSmPPf7XYG/tmqVYD+TykxyYpNPnIYteGG6UKN8IsdD/rlhKUA6Kod7kZFAiYjqMguBcjs3+zrTxNavNY51Ce8rib7o8KJIMfr+/aTX1o8zg7X2W2/vCG4I3Atp8oqWhCGk52ZSLcR1q7BRCjEo5zeD15y/NZJQ3SH0dxHFvzf1QKYkP+2nBNqdxu05GGWUOZBt647Z5KVcuhw2IrlFDiYJTzJcyTmo3TQqSWP40B2+GVZw3WaaTBghpjkAJT9vTBhKwapx+UJccDZ7bwKqNSnBVF8etTMU+p+Ja593keBetrLG3R8Rom69mKQ== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: a520dbad-15f4-428d-4772-08da7513b2e6 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2022 05:47:49.4173 (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: +I41sEpjaPD7BKP8S0zgZV8ibqNuM5TMh+eKdBrJ7kNQTbPXs7KPJ+E2ghxQ9/OySXn1erMj8N0rhX20zp7Td3T3BljGlopYG+iaFDm43WE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6438 Precedence: bulk List-ID: X-Mailing-List: netdev@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 Reviewed-by: Vladimir Oltean Acked-by: Linus Walleij Reviewed-by: Andy Shevchenko --- (No changes since v14) v14 * Add Reviewed and Acked tags --- drivers/pinctrl/pinctrl-ocelot.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c index d18047d2306d..80a3bba520cb 100644 --- a/drivers/pinctrl/pinctrl-ocelot.c +++ b/drivers/pinctrl/pinctrl-ocelot.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1918,7 +1919,6 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev) struct ocelot_pinctrl *info; struct reset_control *reset; struct regmap *pincfg; - void __iomem *base; int ret; struct regmap_config regmap_config = { .reg_bits = 32, @@ -1938,20 +1938,14 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev) "Failed to get reset\n"); reset_control_reset(reset); - base = devm_ioremap_resource(dev, - platform_get_resource(pdev, IORESOURCE_MEM, 0)); - if (IS_ERR(base)) - return PTR_ERR(base); - info->stride = 1 + (info->desc->npins - 1) / 32; regmap_config.max_register = OCELOT_GPIO_SD_MAP * info->stride + 15 * 4; - 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); - } + info->map = ocelot_regmap_from_resource(pdev, 0, ®map_config); + if (IS_ERR(info->map)) + return dev_err_probe(dev, PTR_ERR(info->map), + "Failed to create regmap\n"); dev_set_drvdata(dev, info->map); info->dev = dev; From patchwork Wed Aug 3 05:47:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12935202 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 0E481C19F2D for ; Wed, 3 Aug 2022 05:48:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236006AbiHCFsK (ORCPT ); Wed, 3 Aug 2022 01:48:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236110AbiHCFr4 (ORCPT ); Wed, 3 Aug 2022 01:47:56 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2121.outbound.protection.outlook.com [40.107.244.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 673A85724B; Tue, 2 Aug 2022 22:47:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BWQskssOTaTB49pbXOTP2eq5ODVSX4xij9CGkkVoKuuxG5zM3zjKmg3nNwvnAqY/YWGR+T8UpNuI0OSPifCXmVxJ+0VFjJKccWdh1AcW3EAe/J7HpJLaOkoUjc2snyeKvuzq0jr8WMUurbGy57ZUmvIYZvdk27Hex05meR5OL8nhmiDIwMb3bZFN8FHqNKBYBcdqmXb3Ae8GVfJKxUfLJ3GMPDErZagu+MPeuK99+VvVCdfXrzvw5w3+m8pZu5pSnzxQY18GhB/Yu7xtAZ2Xgvljta9N+IBgMsHmmjQPczNMt8AbEafi2RJWQ2Vkett28m2Ud+RcJPt6WU+7OkEpsQ== 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=b4iqxIpL6SYkOcLWwCQPALRq2mAuAYQ0gxMxQkH7C+0=; b=HFPZE/z/16SQLYnhyoX9MfokhkOrfARRdUfnaPMwyrYuOEx8ubISBvvrNaomVmSpvinEiYzKHChLHKLUKIXOVPAHMc0vMwiF1Jphxm1HrJ4/NVJeGXCA6Btwe/t+gcaEsRnRDJeWpxif/0e4OXrQGIzTNw7YfODv96x2H2SISUsbNi7QlFc3PlNCn3lJNytUwyixd8OqA1lfbFksEuCYi6rQ4mEQgMBTLJ8/uQeul+bsyQbT76Op5e4cJiEVKgRsGa/oN6w1trbup6GC5j4UmOxkmIFc1G8irUX78bbUFmwWqALwZKYuSXortEMSCbY1vFxXtzbms0jlWMKP0SnlIg== 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=b4iqxIpL6SYkOcLWwCQPALRq2mAuAYQ0gxMxQkH7C+0=; b=RIgaBO4Fw0jr4nLKM7Oe18flppC97CmS19JvIPl5HNx1jomIhs1U6//nUe6/h0uQsSncPzrfL4H4bV57lqPjy/YoYG1ugao7Jfo7bRAUIwC53HopkgqtcKl8zpGUxGBoRbF/3bAnvBx6/n/HXdKa+CKKuckJcohf8RNFuftllG4= 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 MW4PR10MB6438.namprd10.prod.outlook.com (2603:10b6:303:218::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Wed, 3 Aug 2022 05:47:51 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee%4]) with mapi id 15.20.5482.014; Wed, 3 Aug 2022 05:47:51 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com, Florian Fainelli Subject: [PATCH v15 mfd 5/9] pinctrl: microchip-sgpio: allow sgpio driver to be used as a module Date: Tue, 2 Aug 2022 22:47:24 -0700 Message-Id: <20220803054728.1541104-6-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220803054728.1541104-1-colin.foster@in-advantage.com> References: <20220803054728.1541104-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR01CA0026.prod.exchangelabs.com (2603:10b6:a02:80::39) 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: 5e55b853-e4e9-4e5a-d502-08da7513b3db X-MS-TrafficTypeDiagnostic: MW4PR10MB6438:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: toGplqpGfOBdJ3lmz1Mid4icS6eIH7WIEinVxaQ9SU7mdo29UIWr2dO0pzh7jsAAqWdSrnA2jkRaWYUasf+6RxXHVY5oZt6yUilmPE3Pntaqo+sHOIFs0rggdz+vN6OSc5QUKLlirjElGdvGg67mKRJbz1OfYe0/t0RuUf426yjJwdZhRqrZh8AI+JjZbyi2INzL6CJG04gsGpfTLZ1EuV751UlDWKBhE+qMC/OSArgvQNnSdfJ7/ofecIpUP+SCIsy2aPl9+u+Uq9i5bqtfnn3Am5BSc0SaDKSqLd3mCboW76ZbTaru9DKyHghLIgGs89qlBETfv3ToHQSr18f7LWI14SClllDvt73ioa34Fw4IHWY800tHyuF1JdX3rSLl54AOm6kvgo41rghJenzYndJTAbWQ4OqEty8XdkYtKme5V/1UBqmdRDDaTY0tT5rNNJteNZaO7UEiP5w8GiEwbpdBPzuoO4vauSIOj4VjxKi+yX5P0YsQlaW0RLzRfnxReSDlrl22NOpz/6N5ZbCWPFos1OLpxyhu0NX6jS2XhTrdMPqIwTp1Qz2PTnURJkjAxmo3UWzr/HVAIF5Lw3rUU2M0VLeJ0ta6shmTtq2zGwtbIoXLJDziP28lmGhSefMis8mrUszsKbBxhsofFMi8prDEAvEPB3hgOJ1dgxlUmG71BRqTKqjePizy/buAoWoMd7HE5g2tRRZ1iJqSk+ozKU+NXLFp8p4LhhWPzt8usfSn2ffcaLFGWoOwrnfQqgOLoI9wiMkPnRCaIz4KtGaHgt7tOSGRmz8Tylfx4ahyLzQ= 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:(13230016)(376002)(366004)(346002)(136003)(39830400003)(396003)(186003)(41300700001)(6666004)(2906002)(6512007)(26005)(52116002)(1076003)(6506007)(2616005)(38350700002)(38100700002)(86362001)(83380400001)(5660300002)(36756003)(7416002)(6486002)(478600001)(8676002)(4326008)(66476007)(66556008)(66946007)(8936002)(44832011)(316002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MY3OkDnpyfyaO0I4fVzqwvWsM2Ki0SPIndn144Q58xKGInDofBwTS/Wq93A9d8ER6tLnEjcxn57+DvnYY3eTqWnbgnY2jtK79vZLUS3soUgpki99NMbE0p1yQOLooFxYPH8i9FWxO4oiJ2DbLZmDLPM64EhGySDqnv1G98eCsemUQbj7Z7eMVjYsKOlZcGsQy++pCp9VxBfh5yA1iyeTGceZvgTteQyqIV8WEwRgaEIz2LUv5GYwcHmG+vIgEkt16QxbZ6PAhheiILvhr/wLZZGw965qqSVhmtlUAulyLu2O53CMmwutXlfvwN2jnJ6UjYFy9Vqikege8zQt6mWgrgPbnyG6oXS3rKKeK6jM73dJwDXNI94ctFKtPjl2/46OOmt1AcNIkvW53OwDdeK6ilg1Ete4IiBK8h+vf9WnuFm0WmoumOt+bIayvoPC6opqRkWyeeeSWsc7s/7xgJcQTkyhdKn7iH9UwGWZBKWMzNvi11toNRokTMCXW3q58eYpN9szmZfTY/FQM4o7Th7e3ne70o5HwZDn/uWYvpkcxbqMSAh5U5cMmnoxgiQCkBVXtfEiU+G1RqUKV5WRDe4AIJMdi6Qeql4NEMVaqE1ZARWUUAo9SBkEZQHPhwGahN5oiw7Ts3j3Ve9fUctdleorWP4+XuKiEYXCVY7CJ3C7LrHGS7sUdKeGxUm8fJDPbQafPPG7fYsX4qfmqkLw6B3AqfNDNnHH0k4MdSOiJjB1eRQI14Ck71/5KsRFftpWw9cpX5/GdQQSfUAN/VFEtEZmsRTa+jFxN/B3vg4xhD7OfBmHr+NjyEby6tgyPgT9cEWf9JL4Zh3nsblGV0pSnD96CAoW1r/1GouGacT8ZdrH4s+kalK0CSldy2nxC7swvuahK+/gIX0ZvuswUj88TaUlnnXvunizCULUcpt2vIXCKj9csjKFQYEoo5m65M1RJbVm1C4x1Z3tcTgnTRoXwYQG9ErpO3QaiSwFqtN294AAyW6AAJpQojv1Zd9/4CBQpR7WiMJARDl3EY60RAzW9PqjNXA632+SzvQCMd25K7tZpsgje/RQHTBuyxhcUZSvBphnSwyZXJbpk7ifWK18VbwYBZzkCspIbIhdeXC7ZTlzmPHfaS4G+S8SIZwFiQgNGNSUtxkoNwb80MRmAxDGDwmKH1PI8SDj3jT86YiYWdbDKb1kA+BfxZcc13Vg+HQHOVayxtZr8fADYuKEeB2P02UzqvMfEJNJ37MQraKIbdiw61p5u+QrJDeUT2/LXDfOJqlo1a1CzldO1gQO8jkA8Mfcbz7qkyWTyXOIlNlrxNeAg7le9HRqAeZjlZ106tnQ9jnSvJZ4528cdKVVPAi+LthAP0Qb7naEFqilbP9VBR89he2KEAqH5l1N5isjKHcGJk2A1Ipv1zWsgL6+AjUmwxiB28gon8iKBh1rmLIm/TNQFyz15xJuZgFMAvFdbKj3J3JY336r5zHMosf2aS99qf0JHOjNER9XDhom43vg8UCH9Ol4A2IEyCLbywMfLuDNhL/S6e6myKR4ya+6FUxC+19M6rNxTwQLxiTZ3AxEduO9tGJhlZpmM6uhg+Fp01osHoejZCBItW7d1Frnj2IqOtE1QA== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e55b853-e4e9-4e5a-d502-08da7513b3db X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2022 05:47:51.0422 (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: eoY/vErf1ZwTIXtE3trUWpM3GWF1pmxND+cEuextDuE+rXa5DZ4+swxmGi4PhMoLvBWSprzhe2YofQzsqtaB7OkG5t1zxvXxyNY2kBpSi0s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6438 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org As the commit message suggests, this simply adds the ability to select SGPIO pinctrl as a module. This becomes more practical when the SGPIO hardware exists on an external chip, controlled indirectly by I2C or SPI. This commit enables that level of control. Signed-off-by: Colin Foster Reviewed-by: Linus Walleij Reviewed-by: Florian Fainelli Reviewed-by: Vladimir Oltean Reviewed-by: Andy Shevchenko --- (No changes since before v14) v14 * No changes --- drivers/pinctrl/Kconfig | 5 ++++- drivers/pinctrl/pinctrl-microchip-sgpio.c | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index ba48ff8be6e2..4e8d0ae6c81e 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig @@ -292,7 +292,7 @@ config PINCTRL_MCP23S08 corresponding interrupt-controller. config PINCTRL_MICROCHIP_SGPIO - bool "Pinctrl driver for Microsemi/Microchip Serial GPIO" + tristate "Pinctrl driver for Microsemi/Microchip Serial GPIO" depends on OF depends on HAS_IOMEM select GPIOLIB @@ -310,6 +310,9 @@ config PINCTRL_MICROCHIP_SGPIO connect control signals from SFP modules and to act as an LED controller. + If compiled as a module, the module name will be + pinctrl-microchip-sgpio. + config PINCTRL_OCELOT tristate "Pinctrl driver for the Microsemi Ocelot and Jaguar2 SoCs" depends on OF diff --git a/drivers/pinctrl/pinctrl-microchip-sgpio.c b/drivers/pinctrl/pinctrl-microchip-sgpio.c index 6f55bf7d5e05..e56074b7e659 100644 --- a/drivers/pinctrl/pinctrl-microchip-sgpio.c +++ b/drivers/pinctrl/pinctrl-microchip-sgpio.c @@ -999,6 +999,7 @@ static const struct of_device_id microchip_sgpio_gpio_of_match[] = { /* sentinel */ } }; +MODULE_DEVICE_TABLE(of, microchip_sgpio_gpio_of_match); static struct platform_driver microchip_sgpio_pinctrl_driver = { .driver = { @@ -1008,4 +1009,7 @@ static struct platform_driver microchip_sgpio_pinctrl_driver = { }, .probe = microchip_sgpio_probe, }; -builtin_platform_driver(microchip_sgpio_pinctrl_driver); +module_platform_driver(microchip_sgpio_pinctrl_driver); + +MODULE_DESCRIPTION("Microchip SGPIO Pinctrl Driver"); +MODULE_LICENSE("GPL"); From patchwork Wed Aug 3 05:47:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12935204 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 3E1F0C19F2A for ; Wed, 3 Aug 2022 05:49:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237046AbiHCFtD (ORCPT ); Wed, 3 Aug 2022 01:49:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236730AbiHCFsJ (ORCPT ); Wed, 3 Aug 2022 01:48:09 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2121.outbound.protection.outlook.com [40.107.244.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95B8257267; Tue, 2 Aug 2022 22:47:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NkVRBa1so/uU4lhXTuPnlKaXq65MQQovr4NSsmAiyFTrJzR2ClVlI2oWw//sMnfiN2zI5v3VwpirVEl19Iw+Fl1UVSc85CL9sFrrp4HjrDk7SdRLsZPDI88+1WYnh93us94XHa1jPLH6VI5RS8xiJRdir8YwG90ec82YZfjhdH3DiTXqYr/SmoiSG/CHhDWZBdcl6mluuk6vSc38nlpXvtTiuOAs50m5rnCVWJf2ZHtLK8lYstz5bXFQpdsxtPH1bJQYpJAnpdvwrtB8jbhFwSs4V9tU766oCG6Zh63RzXvi+5ewjG+adRTu7DQSlcc43Fk0XXlQvc4JfHEwqTe8aA== 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=RB2Ko3JvokEA1QTdWmgqle7W+LlLneKUy/WEwyOhBeg=; b=ehS2sTUG9WcqBhSJpKWV+oMyjF0r/UWVYMFhULTx+aVy3Fw7rnqQQaTGPudv5vdcw1ZKu1uXOLqq00Q5GJ10oPvQ6qmynTqfqtUY3hlg8vNvOp3h/C60ms1WJKlMV/JJ3M4ILRaOR5Ii9Vt8jVsWo7ZGMAYeqS2qHbttNK2MIJxlR7UInvRBu3p2lgvPmuBWoDVWDe7hq+utAmojL7y6DS2ivENhnI+ytO6ssGmCfwqaMkCp+NFEB7OZrnkaM8RPOu/b7FJ6my4tZiTR1h0fG4Q9WahCuohOHEFj+AASgt32WXYyoDhZ4w45BitjJTCN3yoQOLqCKhLgoS50AS4/Dg== 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=RB2Ko3JvokEA1QTdWmgqle7W+LlLneKUy/WEwyOhBeg=; b=jxMMisEYLm/jSzLAMj5Fd5zKl0MKS/eicwseyaExS5+u36/fE4XAz912r3zPCKrK0l4CvHQWsmzX2zkK8Qh/hNm/LYDyBFSBYyOAxQ9aH2L7swFV9AZal/mDYoc2wPD5ioVJliwyoyTbpqu6kNdZIfo1KOXtHhiZ2bauDzp+nHY= 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 MW4PR10MB6438.namprd10.prod.outlook.com (2603:10b6:303:218::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Wed, 3 Aug 2022 05:47:52 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee%4]) with mapi id 15.20.5482.014; Wed, 3 Aug 2022 05:47:52 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com Subject: [PATCH v15 mfd 6/9] pinctrl: microchip-sgpio: add ability to be used in a non-mmio configuration Date: Tue, 2 Aug 2022 22:47:25 -0700 Message-Id: <20220803054728.1541104-7-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220803054728.1541104-1-colin.foster@in-advantage.com> References: <20220803054728.1541104-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR01CA0026.prod.exchangelabs.com (2603:10b6:a02:80::39) 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: 580a5303-405f-46b5-d954-08da7513b4c7 X-MS-TrafficTypeDiagnostic: MW4PR10MB6438:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XzlRd7kVOxqw9uL+9jQWrwxAryqoeO7RlFhzEUMprSo4iGgaC8fv1tSCW9byUOAYEbP/KtRMSW72aqqxcKX4JzjeGurqwba3/zY5RUcq0CjTz9O2Bcd8XavMY7PC9jWGWJ7fh4FfSZbLwlbMagTsTCfsOoF7JBXQ5Uh2R0b86Sm+xDJs+BklW4+/lBNQFD8+Xe0Gx2p6XSUn7mMp1591PWPkzQNP3WW0wqq0n7SCRkncxQxypKRgjU6PyhIbzqYoihv4R8+wbaI4kBA48ecg8SRlkNGYnqiwdLeMSHfEdERBoweq8UyJIpEkNVhfDyRKtDNPw3IEu8VXaxKTSB+qyQLqSixBwbW7ojkedpneqouyU+rMPRYxbGGVqu76zOWrZGkItC+zJhWpyKsfhc4QeAMulGGHn+mdbIS6BLrHptjk8oTFM8EPRPNW17G1/N8EW0MXaUpiJ4awQ0JhjhehAGG+ZVwrbtX/t5YpFKf5j9YPcCWcoY/8E+JCaoIrZZjCL9giOmrmB4rkr5+xLCZuVI2W4pVu8Kk/rwMcpC1sQ+yj1okYkl+3GPEqheV2Y5hbrluu0MGcNJ9iTDY3mCj9RzpgBQqotzJ+Cad6bk1NzoRta5ZL/D2lr6fi+TgICMn8/KBgJKTE7TPie317TCpOhq7ADMDHj8/M8AfjIDN1lVhX0T7vJFXL5SdJ9p6+0wnpTNv/WPrdKjlOsfx8Gm8ArTiFd9rL/0keac6G/3Kqja9iKDxzB3X4ZOm41p+lk0swixtZOF0Bl5HhkB+IpJH8ntpQLQQPpwY5m5DJusTnrZs= 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:(13230016)(376002)(366004)(346002)(136003)(39830400003)(396003)(186003)(41300700001)(6666004)(2906002)(6512007)(26005)(52116002)(1076003)(6506007)(107886003)(2616005)(38350700002)(38100700002)(86362001)(83380400001)(5660300002)(36756003)(7416002)(6486002)(478600001)(8676002)(4326008)(66476007)(66556008)(66946007)(8936002)(44832011)(316002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Mcd1RkYp0D5DBhTt4qDzmJc4tUJ9pf1asYjdUJ2TJnotrUzNA06gw78ghN/tjvaCyfrrOBYhcRc1x91D6SYxXzj/4xw+OxE5jHlsU4j4zU0KGoPdh6BZdnzqIZE5dMh+5vM0K76ctOW8pVs4jieL5p6oqiPMTaJCDCx5xOm/Wbn0p7BO47nfBPcgJ3NL67GedOre0jpMkl/RZ3jCx//PWogLhBJ3jdONbPiC+gTO7jbzF4xeVq95posJElbT28TGt1HcnCpyxmWym7QN3bZuSGYTtdofUTDHcQT1yD1ojCRD5Yb+noRxbvW4OWOJels3IKYxE7lDt694d20LLVEyR0+sU8F3p0WzXvGIwiXbfeXgcl1M05J+tn/hxtY6Se3dt+tSzbFKMz8MzosYB/0fk5dmMXKIXALW27GFISYvTGUi/849sVQHzZUabNy3PjTNtI+HLoR0Lsw0qEktBuweUy/Eb0tYE3aT8yxry/cqJ36c210is3NoZHK6elG2UTxX0esBMqlgwnzztg7EYk4F3IYtQqXddlsBqTlnxiW1EXJvuBvf+iliWE97Y6DBuNOL2SzxTyJf82MN9D0ddC56041LPpkKfym0uy9hsDZEsxQ0VgztBhM8h20z0WHtILGV9VEI9c07XDfSjOQV7FTdIHgbKPcxt4d591qVhSrCkM0peKHGlSU1C8j9lwgPKsNxvno6AhMq0nWmbVgd8tdwfbm6INxzZiJmmHG0zXzNtEu59MDHOf8IJ8rIuFa/QrGRPvzDwrYGTVQpPGms1EeHbkYgCeMVj6gYmgedQl00bLAXSLsjCFR+NyWb5ucTsA0gAxZaR+viy9whJ505Xcn/9elQJ33M1TjupbDHul+Gb8B5YFK4pIWks+DH1IWF4lyO4F6x5KD+DcDA1mJO+WI5uAnmn/85qW5BW4ixKIsjCUKxR9Wg239wo7+pUrDLGSN3jXPgdEE41+oNA3zW0Tj6fYoX5ot45SjA97d7P/s7BoxyfhnxMoRUu6Z5qokmnRSEg6cCRQiDVk7/nHkVmUjgoF8KNI1l9dbTwcdL4I+NUHFL2+cc+5QZwyu4fOlcJzKmPOkrd6B/YGPE43nKjRjA6Co7kR7fkhliSD5oUE6eRhgany7OnGiRekHb9DeZfXZbtkFnyEFZuz04kbknLFNS52ZpFFuPDURPgjnjCxTOxvxHL+xG91tRM4YNxIYQ/Q7eKlEiN8+TsWm1ppy/lo0r9oyX3TyPHntQSmU/2Snp3e31CWb5xRlq5Jcp34+cFAEu18a0ibw8oFJFfxQlz4qhHdMcV6GhbjO/vW2OluwiNtSj6QlKv3HQRVqc1nt86neHU0KJOEQYwFQ+zhglSpQkeeMjYqAWmqmI96LA1rGlZr+RecGVZluJM/zL0x4y+YDMYA+QbpMdt5FVZHivpJyOhPERdPl/rftdCZZOgTQvCyCDTZJsnAGG50dyZ5dmzNCD7hajiV/L/rhuFNg5S6a/kg9/vODrlR7EcNH9k8rpx1zmjmeHJ8E5/06Ho7Bp8lwoXC808AfjacM7ixNzulvc9BpbQPYThcZu1FnyzAoI9ghuIHXlytUAhzYwe275Pk8+lQwiFXOzVA46LreIXv2zNQ== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 580a5303-405f-46b5-d954-08da7513b4c7 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2022 05:47:52.6202 (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: Jwy2PVJA+ADCUnnQv004FCojy4jD2uRM25yEcfpp+5gS81ifQtGusg/PLxRYwpBlRIZd4tmKPWwrEb7hy2wH7F1OK65sliqiFPnJHCGdN7k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6438 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There are a few Ocelot chips that can contain SGPIO 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 Reviewed-by: Vladimir Oltean Acked-by: Linus Walleij Reviewed-by: Andy Shevchenko --- (No changes since v14) v14 * Add Reviewed and Acked tags --- drivers/pinctrl/pinctrl-microchip-sgpio.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-microchip-sgpio.c b/drivers/pinctrl/pinctrl-microchip-sgpio.c index e56074b7e659..2b4167a09b3b 100644 --- a/drivers/pinctrl/pinctrl-microchip-sgpio.c +++ b/drivers/pinctrl/pinctrl-microchip-sgpio.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -904,7 +905,6 @@ static int microchip_sgpio_probe(struct platform_device *pdev) struct reset_control *reset; struct sgpio_priv *priv; struct clk *clk; - u32 __iomem *regs; u32 val; struct regmap_config regmap_config = { .reg_bits = 32, @@ -937,11 +937,7 @@ static int microchip_sgpio_probe(struct platform_device *pdev) return -EINVAL; } - regs = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(regs)) - return PTR_ERR(regs); - - priv->regs = devm_regmap_init_mmio(dev, regs, ®map_config); + priv->regs = ocelot_regmap_from_resource(pdev, 0, ®map_config); if (IS_ERR(priv->regs)) return PTR_ERR(priv->regs); From patchwork Wed Aug 3 05:47:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12935203 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 B548AC19F2A for ; Wed, 3 Aug 2022 05:49:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236933AbiHCFtB (ORCPT ); Wed, 3 Aug 2022 01:49:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236760AbiHCFsJ (ORCPT ); Wed, 3 Aug 2022 01:48:09 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2121.outbound.protection.outlook.com [40.107.244.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6C8D5724F; Tue, 2 Aug 2022 22:47:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n9O0c2yl95bqZvBmukK5mcLuoYfqwSwtKOlCWAd+S3/3YMFBZy1cv/i+zhEBiriycr8PoczOS2Q5ToE0iszgpNUc0SBOMJS+NV8mvZH/N5qLg1YLH1e9oDdhAMtYRZQVerGwOVqiS1D211t9UEA/hjlgT8JZIN7MAvLAhqWyNjNmK2AJ59WfH4XEyTKmOx9ZHfZ8ia9gFX3L/aidtylAt8GceWjN3ObQl8kOXquirD8zkOQCF111QvXvrGVJsekpP0hBY8PTKZlgdnltv9lohJDOjhTsTzTpp+n6LcLxMBX0b8dt0ighsuDm4nEQF21FweWIjlYn1hfjN/IaNA7plQ== 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=ohBdtxbTL6dXyAEpXkG3QBDJR8+3WUaB9PRVzHWrSE8=; b=JMHD8Ty3hDgbYfSLS97vCXT0x2vGUj39jIX1TD9AYVrTAQ4Lmfsb9FFs8aYQ2vYUHnunrKZfs62dUMExqxCRk2O215hmW8f7t/l98GBrp4Rx6dTPcPLj/x7kriVvGJhxyPKDZLx3TUoxEh3dlzKWsHk6tXHrQylRTQNrJVlGnvwY8dc37kjCWn7yP9l+BxgPbfaTuiQaKLeuGtoUHUY1XRAqRo53yLhUreIpOtkvUDJeZk4kV4kUYzRMNyeGA6i6w/arf1zhxcp7Pb6iZRf+PoWirnq/9/g0VAB4OCFkgQR2MchjE9HCeVrv6m4tMrpb8/j24PHAsze5pEuFRdo8KQ== 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=ohBdtxbTL6dXyAEpXkG3QBDJR8+3WUaB9PRVzHWrSE8=; b=Wau+diz0s8eo8yQE3PKMq/r+qmuhSgnjzzF1FbpJfDN2Y6mGc/3qe/yYbuwVuATRsEQfp8mZy7m3YH0EyzUbiwfhpVyK+KhxPUAqEChPqH4DUuwnzBa3sepZKg8B4WcpsWnkPlORCpFPZdttqlRswV71hs1DKFtbIsRmwbs2j3M= 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 MW4PR10MB6438.namprd10.prod.outlook.com (2603:10b6:303:218::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Wed, 3 Aug 2022 05:47:54 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee%4]) with mapi id 15.20.5482.014; Wed, 3 Aug 2022 05:47:54 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com Subject: [PATCH v15 mfd 7/9] resource: add define macro for register address resources Date: Tue, 2 Aug 2022 22:47:26 -0700 Message-Id: <20220803054728.1541104-8-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220803054728.1541104-1-colin.foster@in-advantage.com> References: <20220803054728.1541104-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR01CA0026.prod.exchangelabs.com (2603:10b6:a02:80::39) 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: 44d0e4b0-8c25-46dc-2b8c-08da7513b5c2 X-MS-TrafficTypeDiagnostic: MW4PR10MB6438:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QFC6G8B5/aci72ovxGLp5VKqO8OzGbgFWDRTuDMooLOwHssGIMrnLdIynhV2GPfqqLQmYa+4Bww9NtT1ui/ipKJq67Y8XqFUBp5XKsc7cBjNASowF++GrH41TXPQBP/FzRs5vyiD7TRNWj1p5NxpKOE6ezulXYoTZiDvOmUyvDcywALNETveZYwqjwAsu7yiRJnr3OXsYyZ6pXcQANvYV8CPp3/DvfuK01AOZ2Au5T7WPOnAUaQ+KCY17e8bCBqnuiIzyrSAJd4qNkL9NVXnL2TjqmiqU81fmxgE2HKyB7nYu+11IrJcjm0q8F7IrNO6PGWNycXS8hZSwcirEO3/ApFE6ENUWeuo3IiXSn+LI6vFw5S5lJKnnYlS3WtVqV9U+xTl95SE0YjoxyCQbOVcZBelkeyHswFLzkmDZxe47DXfFjJKOnJJNxIqIAuOwlWXxVJf/nb3YHdPU5TBpcHEdfwbpfWS0PMCBKXCEQgBAZ/RmHfumim7609yyYUJ7b5myrGtnitIOTaYxhaNcecBm/gvFh4941T4xt24Ytu7e+MIJ7w8DR7o/q6zTp/CVqKV+INEF+ybjX+j3n/i6YxJoWmQcugGg7rh8PXDQqhoJiksQr28qljyBG+z3MIEZSBobYl9dB1wYWogz8ddgSF+KXU7AIqHttr8pJ/YXKnWrIhoKFbuYTOzAA/B1fxoTw/6x4FURQdtkD0KQ79xwI8pdm+qjuOxX11Tt4hKIlnwDn8JhtIfaiqoLCesR7KPFZ+wd95MEDQ/ZkqC1n0gJd9/0ir1FmJnYZ1ot9jM1mqQ4YQ= 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:(13230016)(376002)(366004)(346002)(136003)(39830400003)(396003)(186003)(41300700001)(6666004)(2906002)(6512007)(26005)(52116002)(1076003)(6506007)(107886003)(2616005)(38350700002)(38100700002)(86362001)(5660300002)(36756003)(7416002)(6486002)(478600001)(8676002)(4326008)(66476007)(66556008)(66946007)(8936002)(44832011)(316002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N8pkLkCW/AFk1LMbDa20ZImN70XyGUWiK+CKWNC08Gy3uP/EAhDIlPm1GqXOsLrrIlgZDH154co94UQnH2LHdG3pkr3IQiR1KVVOU8t/H9Y6/VbbqZSPTTONOUO6vPB/78PtQRDy/57Q8TwCFUosBicJeVA0Fd6/7a7rYw3VA8Ep8wf+T00QwXdhKcq38pqQvHzTFPuhHoE6qX+PXssj38CrKmxsF5OJ+bKtc1VlozG4+7W8SQg8myQ/6hv1GY9dkHW8JF9PqAIywH4BnCunx77xpQc9hKZSfsgYXyNx2rwkkStwi3k9rF4UW2IqV/G503kWwY7m0UXfpx/vJBSvmNHA9HxJgJO+ngoHfX6FOed/Qj83hBfU5oon9boi0SblqUNJ37rw2S2k4g+3R/pwx53ZFqagvV9HPiPFmE9m5nK+k8bnuq4AeKI1PNFpCUheMWIFQM7eqoHdjS5Ujs4tZGP0fZc1++Lw5oP2/21juZzXVZO38urAnodb6fXlb0xW+4k3Rxsb+xUqLTVpaT+5qHyYkVwVvlC44ju6tiGVjFEVYM0Xii/5PUjX4ZbYQ0q5ZMQ6tm3aOw+GAUEl3EbWS7Zcw0fZj7xZXzzZNocyR9IOAdoBQpjnSW1iOhiIaFv+inXWLA9LADdWxN73bkEP1GGawlqVbZMy+gaYcfxiZ05BQI9RSQyh8DhEBtPL77r/ZfmSENmU80afISzo77u1iYoktPLxrpHVaTb+HDz8gddMpDRhApPzK5k47FZNIMnBwMlgr/2m/BFFRIsw0p3e09sRAztkL8YNLfYSacxIx0Ab7ajZWgov/EiE5DcHhg3pWwl6L0LMu0lxIh5JxNYZt1VWAENilLePYTQrpBy1TpoBi+caH2catrKnCF/FkeeZevL/XgrWDkBK3o00JVta14QdMJ87zG9TRunha4Wh2PBZtAWgPt2HLLeFr+SYKBT9FNEbIoo6liuVY1b+owPzjTap3tIqevOaC7gLR6swLJBbeXYIqglq73QOHzZHUDIMdWizak7taTY1Q14qFWYapLcy2peivyA4+IfRfg/6hqcEZT3/+5J/kvIzEhbTLLR20+DGJxJ3GBBaCI+dbr66g+ouPzdLZmIn/79uZcSaBOOzKQk2yfrMs+Gnb0mtFMJTuneToQ4ESl4s2LYd5UlAVc6qRuLNueT0wpMivifVyOwkJIwdwtfbxU4Tvzov/RA4Z8kPIuQlx/gOeWp8jmioPB064ngK9ZOXEy+zy4bwvBVGIskW9hZLgX9ME5aiW5Tv3tOhBvJU8957h/5IkfG8alkaJM7DQPoGS0pjXUMZ1J9Xj6FMEFf5cE5cfkQhzD4Rwbvwmth45XLWQq7nYo3aaeU4gSx3LGNWEAPgXkVBqanscKLQttMl3HXhPxlUyAFvoSy5hSkUfxu03oNVRCvmImROh8jZHMEKGJfSsK/xCHX8a6zzrSpfiKfVovSKdnQ2x8WpeK9Ef5/rTzwATYwvFR9RMu7PYPbyyU2N/4bBy1MZVRMGgQyPHmA9tYyNVMmscsfEv0yamk+8qxWxGIRGOd22Gc0NE5uKI5J7vobUmTZbAaueJLMPAor/55SLkmDxk/XVvkwQYIZ6j3rDxsK8Tw2TOcsWJF45E9Vh4pRsNMc= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44d0e4b0-8c25-46dc-2b8c-08da7513b5c2 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2022 05:47:54.2919 (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: cZ9aXnYLUcbID5w/2fSZDKV5bJShuw1Z0XyQYOKDeZNbTwB3CJLfqLCKID5iNeWoISGEAC3iDwigdGGQJcszAesePkhP9yUnmsoFA4pzAQc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6438 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org DEFINE_RES_ macros have been created for the commonly used resource types, but not IORESOURCE_REG. Add the macro so it can be used in a similar manner to all other resource types. Signed-off-by: Colin Foster Reviewed-by: Vladimir Oltean Reviewed-by: Andy Shevchenko --- (No changes since v14) v14 * Add Reviewed tag --- include/linux/ioport.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index ec5f71f7135b..b0d09b6f2ecf 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -171,6 +171,11 @@ enum { #define DEFINE_RES_MEM(_start, _size) \ DEFINE_RES_MEM_NAMED((_start), (_size), NULL) +#define DEFINE_RES_REG_NAMED(_start, _size, _name) \ + DEFINE_RES_NAMED((_start), (_size), (_name), IORESOURCE_REG) +#define DEFINE_RES_REG(_start, _size) \ + DEFINE_RES_REG_NAMED((_start), (_size), NULL) + #define DEFINE_RES_IRQ_NAMED(_irq, _name) \ DEFINE_RES_NAMED((_irq), 1, (_name), IORESOURCE_IRQ) #define DEFINE_RES_IRQ(_irq) \ From patchwork Wed Aug 3 05:47:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12935205 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 04997C19F2D for ; Wed, 3 Aug 2022 05:49:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237292AbiHCFtb (ORCPT ); Wed, 3 Aug 2022 01:49:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236991AbiHCFtB (ORCPT ); Wed, 3 Aug 2022 01:49:01 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2121.outbound.protection.outlook.com [40.107.244.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9356B58B56; Tue, 2 Aug 2022 22:48:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zb5TPqb+tqFyrp2E8MKdgAj6JOcaVL/uonRROyUcTkVlRt/u49WLqWRUCiuGBdvpVlgv/VoZ9YUg8bW8Dydf1LgAKXOCSqhZYU353Q8G1/lpLwOnsIODQ89wP2z8pLqOy/J+O8wn5L5kiNvoOw3xOiqckW3Sz6Y4H1VzpdPdw4TohjVTV89FajHLMWTktlbKZZrk73M0MTePFCjNRk799+BrFgmPnEvExqRSA6DGrNASGz3i7x3u4XaAaezPyvFLeaTsefDSn9inqiWcmpoTEChH6qXQJ44DWZClUOqHshT6m2KCuExsCFFH/sXMCID2bfwtTehfj8s12NwXJx44aA== 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=//7Nv24w/7I33yqXFqyK8T5I7UxWaF0l+WTbSq0/CQA=; b=Kb5Z4WlMwzZyOTEU24G7QBQAI0FclRP4beWLsJU9hJDAx3sfQC3V9mGfZsqCPO3d03bBRSsq50h990PW+uStyOcSj+4pp3yyZZoA7X0vgsX/TuQXmdvIowySLhfjo+wDxkLKtlx3FUS4Hd8h0+qjosI0665AJTWaBDDHKaS9XYxiy67e4CBTrJVApu7SAbRkUgHYFEymaNpFIlf8skNCthhLUbl6wnHevfWmmnZ5xwfawghDF9uLt0XtcSATGS6OSi8qT6NEwECoxmRpgDleUyW7kIGPvYi/Drufe2DxzE2+3Q8UygFTDTwfjgwTLr1vJ8Xr/lj93NuUIP5q5c8l3w== 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=//7Nv24w/7I33yqXFqyK8T5I7UxWaF0l+WTbSq0/CQA=; b=zGW/nRKuYezIA91ByD7d7oldcRDLqVb8lyIownNDJ3bdTB646aL6vkXj3Tcv82Q9cKLuTSwsQcNldL/7HVkVDn5aMdzhGtAPIlVPkeKRGXSOYdt/I10fSaH6YPhGA1B8yhmHfYI1NXBo2D5S7c2RlTJc+UgKn+Ljo4BrBzEZD3U= 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 MW4PR10MB6438.namprd10.prod.outlook.com (2603:10b6:303:218::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Wed, 3 Aug 2022 05:47:56 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee%4]) with mapi id 15.20.5482.014; Wed, 3 Aug 2022 05:47:56 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com, Rob Herring Subject: [PATCH v15 mfd 8/9] dt-bindings: mfd: ocelot: add bindings for VSC7512 Date: Tue, 2 Aug 2022 22:47:27 -0700 Message-Id: <20220803054728.1541104-9-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220803054728.1541104-1-colin.foster@in-advantage.com> References: <20220803054728.1541104-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR01CA0026.prod.exchangelabs.com (2603:10b6:a02:80::39) 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: 4c66b5a7-3f1d-4ea5-a4af-08da7513b6c3 X-MS-TrafficTypeDiagnostic: MW4PR10MB6438:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hhwMwKoZ9NM8/YY/Grq8p2qa9Fb/3UQ3m/tMlpaf19WIUPUkkEmZApdrXGOTT3ShIeHzjqUAqgjXQjJZbMVMU1ZmvFbJBMRJv83S9PqcUZ86TLMttkHmrKJlYbqd42r4VnH4kNkJ4nndjt1TmpuYcXaXRJpPW2gVXl42a1TR2oyNsrBvpld6XwMhhu2QFX0i/h2kyz9eu8BmcZcfQFGx1jid/b45sGBACRwLI5NXxTaaLB9becibg1HoE/XxTb96ZfKxxC0xYjr5nbjRmAQt6CkLtbWEvG0jBY5QKMGGdSftTkhQra5xvPI7ZnI5NwEYA6pHGHFWTG9n8E5La5VoRD3CSPsTFmTnh/t5ujl1ujAkYDLSePbIgwE4vC5QF/mWCi0CcI25p0Mk20lJ0ZyqoiOigjIhH6d4Wca4QXJlZcYOH7TcCbejF2cOcLP2F811Tg0kPw7+NOBZcB/xMgWzKzR3F9ptTlcMmSmR5QpFgBV+LjvGOceIqJuuy9TCGKWA6FQf0V2U8aCYjtlAH6bwWxEL4VojSK0IS51eqSdqBDYzxSAPn6bPEtUDLcFWY1JzSP8Vqw0X3hVToW9zBSzLuLFGwfdCEKV8sb30nVWGJK3rEPvl46d0uatEITY91/YDE7pQDRpCA0eVJ2DIYoYeGj0Mbzi3PjvhSOstTXh4YAErc+llYzYoDiKKlPpYH21ZbjUpZsUBKecM531swI40Dm9DmF+KdKTWtN7pnVl1wU4XB+gMUk07PbS2WnCHRLjbDt57V+KEbjOHPWldibBlMpY3ToE9katDgtNNdu6jlYUvKpvwUp5ddGpUbEo5L8G4 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:(13230016)(376002)(366004)(346002)(136003)(39830400003)(396003)(186003)(41300700001)(6666004)(2906002)(6512007)(26005)(52116002)(1076003)(6506007)(2616005)(38350700002)(38100700002)(86362001)(83380400001)(5660300002)(36756003)(7416002)(966005)(6486002)(478600001)(8676002)(4326008)(66476007)(66556008)(66946007)(8936002)(44832011)(316002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8HgznvTmR1SP5MEfx0Xqw+AD93kHIwc026AFbFK5xaVke1wxNrsTdFPOwhn7hNi40l00a2N73++46xRx3fUBfvzNAPf5BU6rEK3/c7ob79UusPrQ2Y1A3LQHs/s4zTiATKo8G+LQm7x9wUnY+/NZVPA7k9oQviiOssIQZo2A5vF0CQlZXKegj92rkBOd8ZKH7J/F2Z3IyCkY99DJCTWmR9B0EQNOYWub7POK2wjF5SVovv0fnY9vgSbo9pxBlqR1iyHNWL/ECSjjCkhsTrujLwKXxBdHA+E9p2pEHPi++9OSAwI2iLvqS0uTlNK1GaY//X8cUgg3f+BkaIPuRKoU8jrFRQv3P9hh8fvsSWxw7Zd+r7Lyp/DxxwiMG1iTOVzg7Hc3TnNtf1+NYwmGMcmHDyVkinHDlvQwyy7slsGREjcRQZTu0fqhfP4BkaFrynefoijv66rFBy8qfSXhijsnzHJc9BhR4lFPpLcXlJACGyAydo/rrxOxpUP0XKWwdtVJ8B7RZffVC1WKUX6fFO2cJejqiqZZrsghKLT/JfXyvI1uY/F8KHJ5mhcm2WNRDDLJTbGK1R3wITcfr03SJIKr9xBFk0kD8Sdzc+nZ8Y1E8Jk3oV6UKCFAeY+qE1XP6w8DoQkkV2ncmdyAxUYBXg4gaElnSXto5WTsFM+6FLCvHfMs88+JtLEc3DtX9MvUIr6KDjCnySv0/geA7SZav+Ny01YEaW2FXZIXdc++XjJiUR6YAYmk6PZ562Xeb45qYMQex9Ika262AYF/jlWe7KDw5W2/cUmls+59EMT2fJLpF/jIg7FR0A7rsS3SNQSwft6KeAPmWNl16xEQJ0s3oJ9mFGuWLcW8ke/EP6AeUeC/A9CSoZynedVwrOEmkOEJ9R6vPyYvIm4mRORm1o5bl1cyo4R/1Ji5u/ln5bieE/BiAqqO19s0v++2Lp6GjJScohMBgMLcqE7OAKXXPPiv0yHobIKAerSPNXVdMNRKU4N6IPmROw4SiyR0G+CCsoyXA12yYAxs381nb7Ys1hVBIynY6xsVZqe6TCotNZixQXLHOGAdPaTJfMHsioIJtxIA3yD6lIxfI1obVWGJR4gDiLogjYiqGAFE9b4HHSWuH+JYwrYPXDWSnXUa8Ar5cq+xKPvo8Z6vZTbReV/Vgs0zfcWFz1BtxIWFRuj8wkS8Gw34DXCOW1pHdA9Ppmip1vX/ZaXS4HL/uE3ZpN3jhVcf2lNd4TyKymAw93HNg6zogeLGsULwhf3HvlFWjw+4LN+LnlLbyv9Dpha6uCftlGsABNQg0LFvRd6/+beuCtswvdAwUdORLny3qGddA9sUQWUEztFUJPNge9HrnekejMvD90F5uSU4nEsZFkXQ22+V6MEqSMLBerv0/JYXFlWa5auB535AQ8O/aKKWmuo3YGf0XkvF8X5NUR1DCKkeVfDZcq7X5Am1imxVdPR3+9FHeWUMSRTSCK9f2/mfuq9MxOrhM0EtAmIjA4qWztf+Jw33fjmes979rj2+2apeS0SteacxsASFTzTy1Hx1pSLXdWOufc3zZRH2h8H9ZEjUyXF7CdlsJhUII/R6H23eMqnjbj+XJdl2jdS0t2FTkxHxGNOYT1FDnrt3wYvJfQ3YgINTn29K1Mo= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c66b5a7-3f1d-4ea5-a4af-08da7513b6c3 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2022 05:47:55.9012 (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: Su9IZyJ+ACoZV09kIxas6hN6J0FJHEuGzEjd3gHsoDvi7QvF9Km5Gk17rU8x9QxNxPX6UOvz6ZijjJQq8MvOMTAITDJkrco4GhH1zXPxWDY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6438 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add devicetree bindings for SPI-controlled Ocelot chips, specifically the VSC7512. Signed-off-by: Colin Foster Reviewed-by: Rob Herring Reviewed-by: Vladimir Oltean --- (No changes since v14) v14 * Add Vladimir Reviewed tag --- .../devicetree/bindings/mfd/mscc,ocelot.yaml | 160 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 161 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml diff --git a/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml b/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml new file mode 100644 index 000000000000..8bf45a5673a4 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml @@ -0,0 +1,160 @@ +# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */ +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/mscc,ocelot.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Ocelot Externally-Controlled Ethernet Switch + +maintainers: + - Colin Foster + +description: | + The Ocelot ethernet switch family contains chips that have an internal CPU + (VSC7513, VSC7514) and chips that don't (VSC7511, VSC7512). All switches have + the option to be controlled externally, which is the purpose of this driver. + + The switch family is a multi-port networking switch that supports many + interfaces. Additionally, the device can perform pin control, MDIO buses, and + external GPIO expanders. + +properties: + compatible: + enum: + - mscc,vsc7512 + + reg: + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 1 + + spi-max-frequency: + maxItems: 1 + +patternProperties: + "^pinctrl@[0-9a-f]+$": + type: object + $ref: /schemas/pinctrl/mscc,ocelot-pinctrl.yaml + + "^gpio@[0-9a-f]+$": + type: object + $ref: /schemas/pinctrl/microchip,sparx5-sgpio.yaml + properties: + compatible: + enum: + - mscc,ocelot-sgpio + + "^mdio@[0-9a-f]+$": + type: object + $ref: /schemas/net/mscc,miim.yaml + properties: + compatible: + enum: + - mscc,ocelot-miim + +required: + - compatible + - reg + - '#address-cells' + - '#size-cells' + - spi-max-frequency + +additionalProperties: false + +examples: + - | + ocelot_clock: ocelot-clock { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <125000000>; + }; + + spi { + #address-cells = <1>; + #size-cells = <0>; + + soc@0 { + compatible = "mscc,vsc7512"; + spi-max-frequency = <2500000>; + reg = <0>; + #address-cells = <1>; + #size-cells = <1>; + + mdio@7107009c { + compatible = "mscc,ocelot-miim"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x7107009c 0x24>; + + sw_phy0: ethernet-phy@0 { + reg = <0x0>; + }; + }; + + mdio@710700c0 { + compatible = "mscc,ocelot-miim"; + pinctrl-names = "default"; + pinctrl-0 = <&miim1_pins>; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x710700c0 0x24>; + + sw_phy4: ethernet-phy@4 { + reg = <0x4>; + }; + }; + + gpio: pinctrl@71070034 { + compatible = "mscc,ocelot-pinctrl"; + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&gpio 0 0 22>; + reg = <0x71070034 0x6c>; + + sgpio_pins: sgpio-pins { + pins = "GPIO_0", "GPIO_1", "GPIO_2", "GPIO_3"; + function = "sg0"; + }; + + miim1_pins: miim1-pins { + pins = "GPIO_14", "GPIO_15"; + function = "miim"; + }; + }; + + gpio@710700f8 { + compatible = "mscc,ocelot-sgpio"; + #address-cells = <1>; + #size-cells = <0>; + bus-frequency = <12500000>; + clocks = <&ocelot_clock>; + microchip,sgpio-port-ranges = <0 15>; + pinctrl-names = "default"; + pinctrl-0 = <&sgpio_pins>; + reg = <0x710700f8 0x100>; + + sgpio_in0: gpio@0 { + compatible = "microchip,sparx5-sgpio-bank"; + reg = <0>; + gpio-controller; + #gpio-cells = <3>; + ngpios = <64>; + }; + + sgpio_out1: gpio@1 { + compatible = "microchip,sparx5-sgpio-bank"; + reg = <1>; + gpio-controller; + #gpio-cells = <3>; + ngpios = <64>; + }; + }; + }; + }; + +... + diff --git a/MAINTAINERS b/MAINTAINERS index f781caceeb38..5e798c42fa08 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14470,6 +14470,7 @@ F: tools/testing/selftests/drivers/net/ocelot/* OCELOT EXTERNAL SWITCH CONTROL M: Colin Foster S: Supported +F: Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml F: include/linux/mfd/ocelot.h OCXL (Open Coherent Accelerator Processor Interface OpenCAPI) DRIVER From patchwork Wed Aug 3 05:47:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12935206 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 9B949C19F2D for ; Wed, 3 Aug 2022 05:50:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237116AbiHCFuA (ORCPT ); Wed, 3 Aug 2022 01:50:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236888AbiHCFta (ORCPT ); Wed, 3 Aug 2022 01:49:30 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2121.outbound.protection.outlook.com [40.107.244.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E61F57251; Tue, 2 Aug 2022 22:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mp2fyOOZrk3PNwa+JaLYjRgpgms5aSfv8khq/sJczhmTcbsjRrOfUYWmi144i6WNbRfzsYTql1aqMllVjTWgzdm1AI0+FpMYV1BauKlCiJG6EgA3Psqfw9PFgu/1/iSveU1DYNrW30MDUFe8n0FdGx3ufq8fJWi7FyjvJAQr2o8arNhXBjoaCrUKFZzQByS+/20o2/a+Fh8cukwjcWCWGDXQE8Qjjj6isitRMRWwy4rEHxrkcl/iVFjgTu0zSwYSJU0WnMWDSgP0chkLqHBHl0679emYiHDGokN/5O8IoO6yR+rpBnHdPsmUnk0rgE3WDgtJ8RQETxhm6VueqVvbnQ== 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=N9ApTt8+C/9FCDPCYB/3MlTRONAvgEq0ampuqyXSH0s=; b=OXRM2NepmwjvJcb+QEjiWGttPTDOO+kPkwKXYrENWCY+EcV6Fr7EMXTzHsGIn9j7CDh7YQa3IPlL3krhfgFgZ0ODdXOWbr4AyVMWzILDZ6qHYrB+CErCzdrWlUyHJZSYvl3p4TnlGLZx8xX5Fbac6l+fhvWwv1JTxQ12yyBsqB0P9+clI9chSV9/ElRD0LysUxs7xE5sZQVPktxsOBrHVfGAIkdHuwLLtU6JbWMzGq/UgVGrpM0kFRI0xph4BZVw1rF518jikvb2g2zZeCKbvcfvJvZ/P6rjhfelQdkH+aESqrVjTJMJ82kdn9nWFD4kPG9xGvexJELV9rqhNXFfxg== 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=N9ApTt8+C/9FCDPCYB/3MlTRONAvgEq0ampuqyXSH0s=; b=gi8AJtG4736MZmGqDWVZb/EebvV15Jcd4CV6tcHS5kxfpuEdQk7SXFcrFHSffyUjFs6ABSHufpNufYx/0v87EOO5GsShsXkzWSdkmKuDbWZxcsQJAKD//gB4bGoL2SR19LEPrEfXH3GCY4/yTpubKs0C0u66S6MB2bpFzlTvVfA= 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 MW4PR10MB6438.namprd10.prod.outlook.com (2603:10b6:303:218::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Wed, 3 Aug 2022 05:47:57 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b869:6c52:7a8d:ddee%4]) with mapi id 15.20.5482.014; Wed, 3 Aug 2022 05:47:57 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com Subject: [PATCH v15 mfd 9/9] mfd: ocelot: add support for the vsc7512 chip via spi Date: Tue, 2 Aug 2022 22:47:28 -0700 Message-Id: <20220803054728.1541104-10-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220803054728.1541104-1-colin.foster@in-advantage.com> References: <20220803054728.1541104-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR01CA0026.prod.exchangelabs.com (2603:10b6:a02:80::39) 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: e1213a96-6857-4652-0b5d-08da7513b7b2 X-MS-TrafficTypeDiagnostic: MW4PR10MB6438:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bvaQHCiqWZ2iEg9N8J14ULMwIswGA2MsW5/GSm6r/PZe1HDZWyeP2eQkfL/0/Vz60t98B30FKFk66ADq06US3oNMIU9SaT1d2JHrJxdeDV93vKczwLfjB0BybFaiTANetE7UoVVCmBYVYS/m+3CjjuSG8BszHVjmjXwG6/cHI3Ag3Fqe0hTFYKvMNsuzXM1Y4c0q0VWNW0EzNDEHyadcnI9Ztnwli3opEFGRXf9IA/ywOyOhefehTqWlBX20S/oQNX4bBYIi8JSDgzCaC1K6FxfFRlSxY1zAGJ02u1emV3JjaMR1betI/kdISrJiT3h+FUdMJP4PkZK+uyJ9Wh3QiMy/eeB/pluwIXIqa/erH46Q6vMgcV+/CaC4kjePVmQhIYlHFyu/zpQbCrVMZ9eSZly7kmCCegFmaNgZ1s3qxRE6Vy5+fGTeJ8nhU2CfrLUHlsYiovF4t6JdkzDv02dkmWnEGLuP1/P+ev3HTJ4hPtzzGuQBmBCeN+pELXOETFjqi2o5HMKrXPVlXQmFeqFLgq+fdNKOLwWPIJAimX0SayRknxy828UMeTMHMXH1P5Lt//5XnfYI/qpBHGx5RingvP2PRbqNbQyDuFDvdEQtJWdRyu0zd0/B6eKJrzlFjYfyyJG44g9D6gAaE5L4KVgSLyznrV752/Cl3lBo5QHPVSL0wM/zU6u7e2G29SQUp8JHCWaRUjNNtkMMLbjZm7ulVgULU0woh3P3nVirtC1m7L8LCbKKW4A7YmOgWj7UhvnsVUEJR+NSydha+1b6tbS32+wg09FnWKHnXQQJKEsKlK8= 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:(13230016)(376002)(366004)(346002)(136003)(39830400003)(396003)(186003)(41300700001)(6666004)(2906002)(6512007)(26005)(52116002)(1076003)(6506007)(107886003)(2616005)(38350700002)(38100700002)(86362001)(83380400001)(5660300002)(36756003)(7416002)(6486002)(478600001)(8676002)(4326008)(66476007)(66556008)(66946007)(8936002)(44832011)(316002)(30864003)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SG3e9u89yVYoNmYTfvNBv+aTjm1xI5FQaFT0LNc51nnPr++hqUpNpoX5Zt+m4JeCmMgUrGtqLdJwnroeKf7GZTgvmYjeFBIiXWHlsnEJyvxbZ3kRge626d8pL22ZS98RU4TSQer9lx0+6Ur+Qe0wSSloPf1dVRy3HIV0t8CPNS5VfzSPX5PL12ZmiKkFEAy/zxqMO15nbibhpZPf0iU4oPVX3nVK0GFntViiw49vhEj9AMKPt+Y925Sbimd6MT8uLMO0TGB4zNZnInIr+iPqYds73HXsv5ojvIZV21LDewUWpw7H+laFY1bae/4Exn0R1dfsEiwTMPRty3QinUGtPPnMuq7Qg/3dH4rkmQDYp5yKl1z+6NlF1DJJU7um8dNJxrMeeOmliNjQoPFN4bUlqQjhYqUO9Io3uRFv0GoRSnKdflH9JLjQxmJHf/t1PmmXrfaxWGwKvhX3h5bStlQ1H3rhRTYosFdNCuBwBlIwMyKlyUy7AdljHyvJKl8BfZ0PTDXvlnmKDcGCKupje3hpSFmTWQiKX4e9B0+eDVN/QtU66PLWr2Hhelg9QzqN8jx1fVDa1wlufNOI/h3CIIlHSU+q1sCT2X1vLliqRYE3PRiKWdacUeLLrYxksuOVbGgCVTP6uOA624g1E/f4VD3prDzpcAdhP7/CvzXFKwII1C0JxeDfacLrEqQa6GDLD5pyxbXO9SyPIGAiGPCC9Uxx0K2s1ORu4/NjWn92kAtMlBLBGhmU+ztTvR+7qoXJv8BQpbEomRiJ0S2xn+WbM/tS5UrdxtxWKasMiz4R9u/VC95f0TKGwj9cfcwqO3S5oK/e6CXCpz+UAXR0EM3QwNfQLO9p0UQaNkCL50+9ss4Sn2o9a2XNN9P92t4Orspe7xqubdTMRtGwFIWKIa2rkCxx0hATzLWS0moKG0PrpOZ1yeuJ1ndqZhT36A61DmSPWcdKY7vDwCHFeLakOKAimYB2pLi3IQtA1Lkux7yl6cdIeuQklXMB3mScgKQeBlRjzoYzIvjUMHxu5sr1uYPhhmsG/EW6NKzhhzZdqFB2XSekQG3iKbtUrLJzZeeWb9kGSSzaUy4qlxdk6sWexjYMycS2UVW7g1l/M6x+A4nFowP9J7FT5NWfgnrZJE0XJ7XTzdLbO6ID5+CNFghMrXtFceie3h1nDGPIGkJSpmNSUCaSuwJDGe+Yv8U40TBkxDh/ym9GRJSM2pJB/36GavfueusubNjmbHsMM6ZLYK46Kp6utaOYPw7JDa2pRObBJrAVpZdK36dL+eVizzitv1wmmrGw0FetWJrR5kSW2eLlRl0Ay5Xqy6e8ajbUPy0s5be+vkNJQ6+sxwakhET5CpHQyWokXlPdzR987vPMCLBMtDlZqYe/LsY0YAfu8EE83QX9u/OY5FhpmXPa5t4t6lLzHYD/mvFTfQ7xQ+9gYIgkJ/OZ5B1s6xElGKqOLIjTNvPpkJ5OnKS1fxnYcuJ2Xl3e7XkKHr9zNUHbWuWHFT9i/+AAtkt8/p691DMIzrW6j7R4jxVvB7HYsSvsppF2QXj7KqJCvi0Rh1Uu1iTVwISnPnMc5sBp7s1lDRlXrvN7pC5AZt52xS/lxWSzKwQN0Tj6UOh7TEBUEIRsyUQZcO2Pgcj5tDo= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: e1213a96-6857-4652-0b5d-08da7513b7b2 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2022 05:47:57.5261 (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: sg09OGw1hZChVQEoPD5XNnYFWFnFekQoWJQ8t1VkGPOqsR6Bfr+dN+6FlMTq+pynv7k1gnNz8cDtFcXgL/Q39aWEGHGqPYxP2yw/DBFvS2o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6438 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The VSC7512 is a networking chip that contains several peripherals. Many of these peripherals are currently supported by the VSC7513 and VSC7514 chips, but those run on an internal CPU. The VSC7512 lacks this CPU, and must be controlled externally. Utilize the existing drivers by referencing the chip as an MFD. Add support for the two MDIO buses, the internal phys, pinctrl, and serial GPIO. Signed-off-by: Colin Foster Reviewed-by: Vladimir Oltean --- v15 * Add missed include bits.h * Clean _SIZE macros to make them all the same width (e.g. 0x004) * Remove unnecessary ret = ...; return ret; calls * Utilize spi_message_init_with_transfers() instead of spi_message_add_tail() calls in the bus_read routine * Utilize HZ_PER_MHZ from units.h instead of a magic number * Remove unnecessary err < 0 checks * Fix typos in comments v14 * Add Reviewed tag * Copyright ranges are now "2021-2022" * 100-char width applied instead of 80 * Remove invalid dev_err_probe return * Remove "spi" and "dev" elements from ocelot_ddata struct. Since "dev" is available throughout, determine "ddata" and "spi" from there instead of keeping separate references. * Add header guard in drivers/mfd/ocelot.h * Document ocelot_ddata struct --- MAINTAINERS | 1 + drivers/mfd/Kconfig | 21 +++ drivers/mfd/Makefile | 3 + drivers/mfd/ocelot-core.c | 157 ++++++++++++++++++++ drivers/mfd/ocelot-spi.c | 296 ++++++++++++++++++++++++++++++++++++++ drivers/mfd/ocelot.h | 49 +++++++ 6 files changed, 527 insertions(+) create mode 100644 drivers/mfd/ocelot-core.c create mode 100644 drivers/mfd/ocelot-spi.c create mode 100644 drivers/mfd/ocelot.h diff --git a/MAINTAINERS b/MAINTAINERS index 5e798c42fa08..e3299677cd4a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14471,6 +14471,7 @@ OCELOT EXTERNAL SWITCH CONTROL M: Colin Foster S: Supported F: Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml +F: drivers/mfd/ocelot* F: include/linux/mfd/ocelot.h OCXL (Open Coherent Accelerator Processor Interface OpenCAPI) DRIVER diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 3b59456f5545..0ef433d170dc 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -962,6 +962,27 @@ config MFD_MENF21BMC This driver can also be built as a module. If so the module will be called menf21bmc. +config MFD_OCELOT + tristate "Microsemi Ocelot External Control Support" + depends on SPI_MASTER + select MFD_CORE + select REGMAP_SPI + help + Ocelot is a family of networking chips that support multiple ethernet + and fibre interfaces. In addition to networking, they contain several + other functions, including pinctrl, MDIO, and communication with + external chips. While some chips have an internal processor capable of + running an OS, others don't. All chips can be controlled externally + through different interfaces, including SPI, I2C, and PCIe. + + Say yes here to add support for Ocelot chips (VSC7511, VSC7512, + VSC7513, VSC7514) controlled externally. + + To compile this driver as a module, choose M here: the module will be + called ocelot-soc. + + If unsure, say N. + config EZX_PCAP bool "Motorola EZXPCAP Support" depends on SPI_MASTER diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 858cacf659d6..0004b7e86220 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -120,6 +120,9 @@ obj-$(CONFIG_MFD_MC13XXX_I2C) += mc13xxx-i2c.o obj-$(CONFIG_MFD_CORE) += mfd-core.o +ocelot-soc-objs := ocelot-core.o ocelot-spi.o +obj-$(CONFIG_MFD_OCELOT) += ocelot-soc.o + obj-$(CONFIG_EZX_PCAP) += ezx-pcap.o obj-$(CONFIG_MFD_CPCAP) += motorola-cpcap.o diff --git a/drivers/mfd/ocelot-core.c b/drivers/mfd/ocelot-core.c new file mode 100644 index 000000000000..fd97d878d6e8 --- /dev/null +++ b/drivers/mfd/ocelot-core.c @@ -0,0 +1,157 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Core driver for the Ocelot chip family. + * + * The VSC7511, 7512, 7513, and 7514 can be controlled internally via an + * on-chip MIPS processor, or externally via SPI, I2C, PCIe. This core driver is + * intended to be the bus-agnostic glue between, for example, the SPI bus and + * the child devices. + * + * Copyright 2021-2022 Innovative Advantage Inc. + * + * Author: Colin Foster + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "ocelot.h" + +#define REG_GCB_SOFT_RST 0x0008 + +#define BIT_SOFT_CHIP_RST BIT(0) + +#define VSC7512_MIIM0_RES_START 0x7107009c +#define VSC7512_MIIM1_RES_START 0x710700c0 +#define VSC7512_MIIM_RES_SIZE 0x024 + +#define VSC7512_PHY_RES_START 0x710700f0 +#define VSC7512_PHY_RES_SIZE 0x004 + +#define VSC7512_GPIO_RES_START 0x71070034 +#define VSC7512_GPIO_RES_SIZE 0x06c + +#define VSC7512_SIO_CTRL_RES_START 0x710700f8 +#define VSC7512_SIO_CTRL_RES_SIZE 0x100 + +#define VSC7512_GCB_RST_SLEEP_US 100 +#define VSC7512_GCB_RST_TIMEOUT_US 100000 + +static int ocelot_gcb_chip_rst_status(struct ocelot_ddata *ddata) +{ + int val, err; + + err = regmap_read(ddata->gcb_regmap, REG_GCB_SOFT_RST, &val); + if (err) + return err; + + return val; +} + +int ocelot_chip_reset(struct device *dev) +{ + struct ocelot_ddata *ddata = dev_get_drvdata(dev); + int ret, val; + + /* + * Reset the entire chip here to put it into a completely known state. + * Other drivers may want to reset their own subsystems. The register + * self-clears, so one write is all that is needed and wait for it to + * clear. + */ + ret = regmap_write(ddata->gcb_regmap, REG_GCB_SOFT_RST, BIT_SOFT_CHIP_RST); + if (ret) + return ret; + + return readx_poll_timeout(ocelot_gcb_chip_rst_status, ddata, val, !val, + VSC7512_GCB_RST_SLEEP_US, VSC7512_GCB_RST_TIMEOUT_US); +} +EXPORT_SYMBOL_NS(ocelot_chip_reset, MFD_OCELOT); + +static const struct resource vsc7512_miim0_resources[] = { + DEFINE_RES_REG_NAMED(VSC7512_MIIM0_RES_START, VSC7512_MIIM_RES_SIZE, "gcb_miim0"), + DEFINE_RES_REG_NAMED(VSC7512_PHY_RES_START, VSC7512_PHY_RES_SIZE, "gcb_phy"), +}; + +static const struct resource vsc7512_miim1_resources[] = { + DEFINE_RES_REG_NAMED(VSC7512_MIIM1_RES_START, VSC7512_MIIM_RES_SIZE, "gcb_miim1"), +}; + +static const struct resource vsc7512_pinctrl_resources[] = { + DEFINE_RES_REG_NAMED(VSC7512_GPIO_RES_START, VSC7512_GPIO_RES_SIZE, "gcb_gpio"), +}; + +static const struct resource vsc7512_sgpio_resources[] = { + DEFINE_RES_REG_NAMED(VSC7512_SIO_CTRL_RES_START, VSC7512_SIO_CTRL_RES_SIZE, "gcb_sio"), +}; + +static const struct mfd_cell vsc7512_devs[] = { + { + .name = "ocelot-pinctrl", + .of_compatible = "mscc,ocelot-pinctrl", + .num_resources = ARRAY_SIZE(vsc7512_pinctrl_resources), + .resources = vsc7512_pinctrl_resources, + }, { + .name = "ocelot-sgpio", + .of_compatible = "mscc,ocelot-sgpio", + .num_resources = ARRAY_SIZE(vsc7512_sgpio_resources), + .resources = vsc7512_sgpio_resources, + }, { + .name = "ocelot-miim0", + .of_compatible = "mscc,ocelot-miim", + .of_reg = VSC7512_MIIM0_RES_START, + .use_of_reg = true, + .num_resources = ARRAY_SIZE(vsc7512_miim0_resources), + .resources = vsc7512_miim0_resources, + }, { + .name = "ocelot-miim1", + .of_compatible = "mscc,ocelot-miim", + .of_reg = VSC7512_MIIM1_RES_START, + .use_of_reg = true, + .num_resources = ARRAY_SIZE(vsc7512_miim1_resources), + .resources = vsc7512_miim1_resources, + }, +}; + +static void ocelot_core_try_add_regmap(struct device *dev, + const struct resource *res) +{ + if (dev_get_regmap(dev, res->name)) + return; + + ocelot_spi_init_regmap(dev, res); +} + +static void ocelot_core_try_add_regmaps(struct device *dev, + const struct mfd_cell *cell) +{ + int i; + + for (i = 0; i < cell->num_resources; i++) + ocelot_core_try_add_regmap(dev, &cell->resources[i]); +} + +int ocelot_core_init(struct device *dev) +{ + int i, ndevs; + + ndevs = ARRAY_SIZE(vsc7512_devs); + + for (i = 0; i < ndevs; i++) + ocelot_core_try_add_regmaps(dev, &vsc7512_devs[i]); + + return devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, vsc7512_devs, ndevs, NULL, 0, NULL); +} +EXPORT_SYMBOL_NS(ocelot_core_init, MFD_OCELOT); + +MODULE_DESCRIPTION("Externally Controlled Ocelot Chip Driver"); +MODULE_AUTHOR("Colin Foster "); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(MFD_OCELOT_SPI); diff --git a/drivers/mfd/ocelot-spi.c b/drivers/mfd/ocelot-spi.c new file mode 100644 index 000000000000..5836788b7152 --- /dev/null +++ b/drivers/mfd/ocelot-spi.c @@ -0,0 +1,296 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * SPI core driver for the Ocelot chip family. + * + * This driver will handle everything necessary to allow for communication over + * SPI to the VSC7511, VSC7512, VSC7513 and VSC7514 chips. The main functions + * are to prepare the chip's SPI interface for a specific bus speed, and a host + * processor's endianness. This will create and distribute regmaps for any + * children. + * + * Copyright 2021-2022 Innovative Advantage Inc. + * + * Author: Colin Foster + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include "ocelot.h" + +#define REG_DEV_CPUORG_IF_CTRL 0x0000 +#define REG_DEV_CPUORG_IF_CFGSTAT 0x0004 + +#define CFGSTAT_IF_NUM_VCORE (0 << 24) +#define CFGSTAT_IF_NUM_VRAP (1 << 24) +#define CFGSTAT_IF_NUM_SI (2 << 24) +#define CFGSTAT_IF_NUM_MIIM (3 << 24) + +#define VSC7512_DEVCPU_ORG_RES_START 0x71000000 +#define VSC7512_DEVCPU_ORG_RES_SIZE 0x38 + +#define VSC7512_CHIP_REGS_RES_START 0x71070000 +#define VSC7512_CHIP_REGS_RES_SIZE 0x14 + +static const struct resource vsc7512_dev_cpuorg_resource = + DEFINE_RES_REG_NAMED(VSC7512_DEVCPU_ORG_RES_START, + VSC7512_DEVCPU_ORG_RES_SIZE, + "devcpu_org"); + +static const struct resource vsc7512_gcb_resource = + DEFINE_RES_REG_NAMED(VSC7512_CHIP_REGS_RES_START, + VSC7512_CHIP_REGS_RES_SIZE, + "devcpu_gcb_chip_regs"); + +static int ocelot_spi_initialize(struct device *dev) +{ + struct ocelot_ddata *ddata = dev_get_drvdata(dev); + u32 val, check; + int err; + + val = OCELOT_SPI_BYTE_ORDER; + + /* + * The SPI address must be big-endian, but we want the payload to match + * our CPU. These are two bits (0 and 1) but they're repeated such that + * the write from any configuration will be valid. The four + * configurations are: + * + * 0b00: little-endian, MSB first + * | 111111 | 22221111 | 33222222 | + * | 76543210 | 54321098 | 32109876 | 10987654 | + * + * 0b01: big-endian, MSB first + * | 33222222 | 22221111 | 111111 | | + * | 10987654 | 32109876 | 54321098 | 76543210 | + * + * 0b10: little-endian, LSB first + * | 111111 | 11112222 | 22222233 | + * | 01234567 | 89012345 | 67890123 | 45678901 | + * + * 0b11: big-endian, LSB first + * | 22222233 | 11112222 | 111111 | | + * | 45678901 | 67890123 | 89012345 | 01234567 | + */ + err = regmap_write(ddata->cpuorg_regmap, REG_DEV_CPUORG_IF_CTRL, val); + if (err) + return err; + + /* + * Apply the number of padding bytes between a read request and the data + * payload. Some registers have access times of up to 1us, so if the + * first payload bit is shifted out too quickly, the read will fail. + */ + val = ddata->spi_padding_bytes; + err = regmap_write(ddata->cpuorg_regmap, REG_DEV_CPUORG_IF_CFGSTAT, val); + if (err) + return err; + + /* + * After we write the interface configuration, read it back here. This + * will verify several different things. The first is that the number of + * padding bytes actually got written correctly. These are found in bits + * 0:3. + * + * The second is that bit 16 is cleared. Bit 16 is IF_CFGSTAT:IF_STAT, + * and will be set if the register access is too fast. This would be in + * the condition that the number of padding bytes is insufficient for + * the SPI bus frequency. + * + * The last check is for bits 31:24, which define the interface by which + * the registers are being accessed. Since we're accessing them via the + * serial interface, it must return IF_NUM_SI. + */ + check = val | CFGSTAT_IF_NUM_SI; + + err = regmap_read(ddata->cpuorg_regmap, REG_DEV_CPUORG_IF_CFGSTAT, &val); + if (err) + return err; + + if (check != val) + return -ENODEV; + + return 0; +} + +static const struct regmap_config ocelot_spi_regmap_config = { + .reg_bits = 24, + .reg_stride = 4, + .reg_downshift = 2, + .val_bits = 32, + + .write_flag_mask = 0x80, + + .use_single_write = true, + .can_multi_write = false, + + .reg_format_endian = REGMAP_ENDIAN_BIG, + .val_format_endian = REGMAP_ENDIAN_NATIVE, +}; + +static int ocelot_spi_regmap_bus_read(void *context, const void *reg, size_t reg_size, + void *val, size_t val_size) +{ + struct spi_transfer xfers[3] = {0}; + struct device *dev = context; + struct ocelot_ddata *ddata; + struct spi_device *spi; + struct spi_message msg; + unsigned int index = 0; + + ddata = dev_get_drvdata(dev); + spi = to_spi_device(dev); + + xfers[index].tx_buf = reg; + xfers[index].len = reg_size; + index++; + + if (ddata->spi_padding_bytes) { + xfers[index].len = ddata->spi_padding_bytes; + xfers[index].tx_buf = ddata->dummy_buf; + xfers[index].dummy_data = 1; + index++; + } + + xfers[index].rx_buf = val; + xfers[index].len = val_size; + index++; + + spi_message_init_with_transfers(&msg, xfers, index); + + return spi_sync(spi, &msg); +} + +static int ocelot_spi_regmap_bus_write(void *context, const void *data, size_t count) +{ + struct device *dev = context; + struct spi_device *spi = to_spi_device(dev); + + return spi_write(spi, data, count); +} + +static const struct regmap_bus ocelot_spi_regmap_bus = { + .write = ocelot_spi_regmap_bus_write, + .read = ocelot_spi_regmap_bus_read, +}; + +struct regmap *ocelot_spi_init_regmap(struct device *dev, const struct resource *res) +{ + struct regmap_config regmap_config; + + memcpy(®map_config, &ocelot_spi_regmap_config, sizeof(regmap_config)); + + regmap_config.name = res->name; + regmap_config.max_register = res->end - res->start; + regmap_config.reg_base = res->start; + + return devm_regmap_init(dev, &ocelot_spi_regmap_bus, dev, ®map_config); +} +EXPORT_SYMBOL_NS(ocelot_spi_init_regmap, MFD_OCELOT_SPI); + +static int ocelot_spi_probe(struct spi_device *spi) +{ + struct device *dev = &spi->dev; + struct ocelot_ddata *ddata; + struct regmap *r; + int err; + + ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); + if (!ddata) + return -ENOMEM; + + spi_set_drvdata(spi, ddata); + + if (spi->max_speed_hz <= 500000) { + ddata->spi_padding_bytes = 0; + } else { + /* + * Calculation taken from the manual for IF_CFGSTAT:IF_CFG. + * Register access time is 1us, so we need to configure and send + * out enough padding bytes between the read request and data + * transmission that lasts at least 1 microsecond. + */ + ddata->spi_padding_bytes = 1 + (spi->max_speed_hz / HZ_PER_MHZ + 2) / 8; + + ddata->dummy_buf = devm_kzalloc(dev, ddata->spi_padding_bytes, GFP_KERNEL); + if (!ddata->dummy_buf) + return -ENOMEM; + } + + spi->bits_per_word = 8; + + err = spi_setup(spi); + if (err) + return dev_err_probe(&spi->dev, err, "Error performing SPI setup\n"); + + r = ocelot_spi_init_regmap(dev, &vsc7512_dev_cpuorg_resource); + if (IS_ERR(r)) + return PTR_ERR(r); + + ddata->cpuorg_regmap = r; + + r = ocelot_spi_init_regmap(dev, &vsc7512_gcb_resource); + if (IS_ERR(r)) + return PTR_ERR(r); + + ddata->gcb_regmap = r; + + /* + * The chip must be set up for SPI before it gets initialized and reset. + * This must be done before calling init, and after a chip reset is + * performed. + */ + err = ocelot_spi_initialize(dev); + if (err) + return dev_err_probe(dev, err, "Error initializing SPI bus\n"); + + err = ocelot_chip_reset(dev); + if (err) + return dev_err_probe(dev, err, "Error resetting device\n"); + + /* + * A chip reset will clear the SPI configuration, so it needs to be done + * again before we can access any registers. + */ + err = ocelot_spi_initialize(dev); + if (err) + return dev_err_probe(dev, err, "Error initializing SPI bus after reset\n"); + + err = ocelot_core_init(dev); + if (err) + return dev_err_probe(dev, err, "Error initializing Ocelot core\n"); + + return 0; +} + +static const struct spi_device_id ocelot_spi_ids[] = { + { "vsc7512", 0 }, + { } +}; + +static const struct of_device_id ocelot_spi_of_match[] = { + { .compatible = "mscc,vsc7512" }, + { } +}; +MODULE_DEVICE_TABLE(of, ocelot_spi_of_match); + +static struct spi_driver ocelot_spi_driver = { + .driver = { + .name = "ocelot-soc", + .of_match_table = ocelot_spi_of_match, + }, + .id_table = ocelot_spi_ids, + .probe = ocelot_spi_probe, +}; +module_spi_driver(ocelot_spi_driver); + +MODULE_DESCRIPTION("SPI Controlled Ocelot Chip Driver"); +MODULE_AUTHOR("Colin Foster "); +MODULE_LICENSE("Dual MIT/GPL"); +MODULE_IMPORT_NS(MFD_OCELOT); diff --git a/drivers/mfd/ocelot.h b/drivers/mfd/ocelot.h new file mode 100644 index 000000000000..1c0e941f9baa --- /dev/null +++ b/drivers/mfd/ocelot.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ +/* Copyright 2021, 2022 Innovative Advantage Inc. */ + +#ifndef _MFD_OCELOT_H +#define _MFD_OCELOT_H + +#include + +struct device; +struct regmap; +struct resource; + +/** + * struct ocelot_ddata - Private data for an external Ocelot chip + * @gcb_regmap: General Configuration Block regmap. Used for + * operations like chip reset. + * @cpuorg_regmap: CPU Device Origin Block regmap. Used for operations + * like SPI bus configuration. + * @spi_padding_bytes: Number of padding bytes that must be thrown out before + * read data gets returned. This is calculated during + * initialization based on bus speed. + * @dummy_buf: Zero-filled buffer of spi_padding_bytes size. The dummy + * bytes that will be sent out between the address and + * data of a SPI read operation. + */ +struct ocelot_ddata { + struct regmap *gcb_regmap; + struct regmap *cpuorg_regmap; + int spi_padding_bytes; + void *dummy_buf; +}; + +int ocelot_chip_reset(struct device *dev); +int ocelot_core_init(struct device *dev); + +/* SPI-specific routines that won't be necessary for other interfaces */ +struct regmap *ocelot_spi_init_regmap(struct device *dev, + const struct resource *res); + +#define OCELOT_SPI_BYTE_ORDER_LE 0x00000000 +#define OCELOT_SPI_BYTE_ORDER_BE 0x81818181 + +#ifdef __LITTLE_ENDIAN +#define OCELOT_SPI_BYTE_ORDER OCELOT_SPI_BYTE_ORDER_LE +#else +#define OCELOT_SPI_BYTE_ORDER OCELOT_SPI_BYTE_ORDER_BE +#endif + +#endif