From patchwork Mon Aug 15 00:55:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12942981 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 0CB91C282E7 for ; Mon, 15 Aug 2022 00:56:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230045AbiHOA4L (ORCPT ); Sun, 14 Aug 2022 20:56:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229675AbiHOA4J (ORCPT ); Sun, 14 Aug 2022 20:56:09 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2104.outbound.protection.outlook.com [40.107.94.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1555FA46F; Sun, 14 Aug 2022 17:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D3K9AdVt/5BUEv8LCH1k9vDNRE83u2rE8QXvAaS9NRnZf0QvKErcNBWNBdMU4bzBe/yV9h0T/DSwXKWh2z/I92b+jSbGdtnaXeECNXd7lT/Jr74FZb1eSkr60JXWKwTRCcEBDip7aB+cOIbkMAUspkxhOUtgKC4kYS1xAwjfn5mzMZHv3VRFD+LROrqx1w4aNHN47/xlHYmSY1ScBT43brrG/JwnwoIyovtbbZaLm4Dfc5Yz7+ynipZJVMN4scUy/BpcDKNfRICiXMOanbUq6LVak7yAEPcglfuY722f7AjJaLMcgPgw3MaysUhOQ9Z215IGkgUhvy41ZRLxkSEzpg== 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=Gb+PD0ps/NW6gcSs2B7caK5rMMUizct8apoO41vF6h0=; b=jdm0Z9yjWCErqZ4E6uwcEySJu3Wn5XhFD2FR5EhyGtWf4SNUxWHraIl0TQq76Blj8Q/C2L5lBDtCrX3P0LF4KOHRiX/EhD0Kr3UJp35009ZO+b1Du5ovViUGbB1H7e6aYLy3m4DfMndh2lGnZjqbPDnZDjgzEkCYG4jscpsFMw0BAeDui8RBbkAq/N9wg7xOA/mNjG/DcH1oouENDo+HLGZjrMKI4iCnGKNRfc6OrQTQYOuhcAaXpWYiAvcf6vVsf5fkRRLMWu2oPeD5FKc+m68PzYbyeAC+QKZhKx1zkFHYkxkAyFyrlf1wkF93k9oEmJym3qBsmwHCZrnQs8Z+EA== 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=Gb+PD0ps/NW6gcSs2B7caK5rMMUizct8apoO41vF6h0=; b=i5ICY5vKu4JDvQVJUMnBvOu7a68S0o5+jv8uKgGUBhKPKwxm5SKLzJSLxKF5L2IVPA4PLkjtb1ORDML//waA4XfCwy6a+XHDR+5HYtJqmpRnDLBIA/eJiNOdxH3q7dgT88GnToYZRVx8vkRvq0SEQs4gll7Q1rYUNZ2VRrPIseQ= 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 SN7PR10MB6286.namprd10.prod.outlook.com (2603:10b6:806:26e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.16; Mon, 15 Aug 2022 00:56:06 +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.5504.027; Mon, 15 Aug 2022 00:56:06 +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, Jonathan Cameron , Dan Williams Subject: [PATCH v16 mfd 1/8] mfd: ocelot: add helper to get regmap from a resource Date: Sun, 14 Aug 2022 17:55:46 -0700 Message-Id: <20220815005553.1450359-2-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220815005553.1450359-1-colin.foster@in-advantage.com> References: <20220815005553.1450359-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR08CA0034.namprd08.prod.outlook.com (2603:10b6:a03:100::47) 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: 71a607ad-ca60-439e-dbde-08da7e58ef56 X-MS-TrafficTypeDiagnostic: SN7PR10MB6286:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LQrdvag9mI0RL7EuZuwwYheRZRVe4DSsEquchs8AyCfwQv9sOxBGXLf9QB0dPT9TRlSrXsoBQWeMeQo+134eAajjtkVDYKeUGvB4bRE1gJvW2PLBG7rFfix9TXrfUK17UlgNjW3rpkJtOvLTV3eSNXmBb8Oo3cwuOAaGPp42adoACKGIn3DKwjheKNs/sNMnaAim/pASGJa9b/XOBE8PCDWSBa554mKVga/msz9yBEm0Os1qMjxIyr1Mp/W2bTmazkHMXzr1m7ViIRGN3/qKJiormmF3Y+Mdkx6AZzCjUzWz+1rTnQ/Z48xEMDLIPRc3HjH1NSssk7ADVgC3H3ekx3QZCeB3P7HCa7xMvikkQhd24+Mo4/LqnJlVtZ5mD58+PZEuaPdSbpqgIDvloFpAOm9zHAyL9v+GSis1R0gmmgYsrSa/cDa5hQZw+GkxVAPbAWO9NOMED2Ys9YM12qm7ujjBDA1ZYOQAD7XxzvQ78B448rdkRB+s4JxBR+XWOlv1/GPyR1KYPTBWEzLQzTDax0t4fgVmLWUZYo/e6AvFR+5z0oenrqLvBRQGKe6YLzD6AXfXyPd7CYJEAI4iP5mkg42oCjUHVtQgbqSc1JxClwylFk3RohkIxJcI1lzK7B2/KWIvpRT35bpNwQRZyOZO2w8Jk8whOgSu9XgDU9uFnBML43zX4NvPHp2P+IoewKpNOKx2jlGKETotRKwdvOpK8kXyZqeA5wWFTyni2rh8dgqwXeQy1+Da+bMx/O2b/R/PJNAVe/uRT77t9SNWluURmSJi6S0aNc2cZn+CUl1BB0u32dbjnQkMc2tLMJwM/aew 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)(39830400003)(366004)(136003)(396003)(346002)(376002)(38350700002)(5660300002)(7416002)(2906002)(44832011)(86362001)(38100700002)(52116002)(6666004)(41300700001)(6506007)(478600001)(2616005)(6486002)(186003)(316002)(1076003)(6512007)(26005)(83380400001)(8676002)(66556008)(66946007)(66476007)(4326008)(8936002)(54906003)(36756003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DHsFHiBQtHsLDsu0ftWeG3pzq9O1vPGTNC6jbHMBdXCEOrR+9bxldUhVGnI6dH3Cuoj0yOK41jk2mVwvYk3yrzvvxCY29I5es9g/AHt5f5cBvU+mpCZUhL1nq3Ql/k6GCPLPpo39GYzg/3aMYFtDkCI83jMIlHWLWpZyRJMwVrV06JFm+TOLs8ws5j4Jxr8aIPm8+QsjeRHgQ8qrjEP9Aaw+51o/ryD7R5LkQupU7/QAGql20486biWkp7B/vcrIH+csUGAUBCErmt0p94M7GJ9KgvMXsHoriKuybM6JRsQgdDuH8fnwCtalBdb8eUgWqTSjE31ciOUBvdXwzEdF8XSuB46uMHJhZL8TX71jTO5Nfqa/k/EXWjxwL1L2drVp2lQ/X0MpbEZct2YSKVf+y9jOIPn59VKyjY4PcDqbVDzTCQOqTqc2eGiWrnFGHNDVUUWrR8Ntl9AiSpyEBDwb4X4xWyEkwjkzm2m4KLkQRpjyUq8pFnmf/d5BWYlzxssMgTVjwyzy9uJXJqNTlwqumQdZKu8c1CFSNJ/PMiF1kmBMIKcq06UHzOZ9PmpS3loxmqpClhH2MRhiDiuIIvvngPl9NSdGM2x5KiRz7Dt4vzj7B2REGoHKvZQN+pv0jSHFiy+t5HCGXCWHF6l/xyxemxi1aacoZ9FUnEI6i2t3jN+cgOc9EK4YCI8h17thPFeRcC+jq0qhzG3yQjKIMh0NztkyzEWJ363tsXapy9c88b2/cIzQAF1gtb8YHw74pgNyiVPAqaL6t8NSY1Awo9AHELeXVsre7uR3dXvidCUq+y8bxUrZGKYwS+A7EZAQnnFv7hiCCHZpftAUoQvXJAJL3FoGotTlkPaxRxXzkX5xzTg5hG3AcuyZk8UT7jbMwhY2SHGHR4UpeOXM73ZZbhdtYh6LdubrkFrCKOiyQtMXmZ1dO9s1jCXDg9M7gTH0t39JmJURhoC9r46JQrfCF39AXat+gPAn3+ivZCYxTzmtkTLU4Oott578nmJnPH/ItnM0Q/fApQ/Calrsn1PTtBIPQa7TezBboZUjLv/U11R7tyf4F3dS7u38roEvomhAncFpaLT16oQgF6fvgT7v0mdOdGF1pOr7zSsSsq8t+Vh5dWcbsNlRcQzwg5nbu1UVS2y6OVvXu3WZuaYESaTk8O1rJG3ITmWxAeKxRJlfshsZvhR9RAn8wxX1TMYCShaKP886B4JLBoFgc2EUZD1gvMQ/suOaKUlTf7F9KKlVQQ4qn4YtHjDmzVDbkttVMseIYkE309n8PoJUzSr8a/L5M5H4nqtevD5g/iDtIT9Y6ThNgliBc8fqL9ci8SG3MrnvqjCP7RRNtkawgT1JcY3F8zI3dbOf/vA3t/6K9ABoFBkVjsbuxT5tFppGTvPAxrZ7pRweR9vh3RgzAC6/jLMZpK9FRcuF7yCFU/VjTx70pgjaEVraCeqJEkrnamhoM7YckdtqDJAaOThnxYLwcGrdBGudb7Qtgy6bJNZr7dHFIWS16PJa1Y2SaF57qBgttrm79iaN4Mxx1AxOJf4xHUObBjicNiKKGAbwi9B557abY3WLQ5se37TYtaM5YpgVmU9Yqu8NVvBWBQJNeZF+7NnC+i88MnCAfmY2eEyPdW8p1WU1Efw= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71a607ad-ca60-439e-dbde-08da7e58ef56 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2022 00:56:06.5733 (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: l7rHDy6P1Twbxh05XnBNFrtWFRaW3WYPSwkfOH4f/H86a+wvqJcOmE8aArhPHlpAT15KC3VYPS+pvUZjoFUlsyXLpSLIARg3zrCc1DhAvdc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6286 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 --- v16 * Add Andy Reviewed-by tag 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 8a5012ba6ff9..e0732e9f9090 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14741,6 +14741,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 Mon Aug 15 00:55:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12942983 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 57747C25B08 for ; Mon, 15 Aug 2022 00:56:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230134AbiHOA4P (ORCPT ); Sun, 14 Aug 2022 20:56:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbiHOA4K (ORCPT ); Sun, 14 Aug 2022 20:56:10 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2104.outbound.protection.outlook.com [40.107.94.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E42B8A46D; Sun, 14 Aug 2022 17:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OSY6txrkPbDtFzocmXzk6NVmV+I37F2djLmyr9XW4ejDeVq2bC1L60MdAIru66vsBOTgmB7mPEgN+nzPEfkRByWsLYliABou6d3tIt/30V2Nf08pwm26GTpu2RZukakCVVqCP9sVk17WJc9QZ9s+C6AFyOA14p6kDvKYtLTkTS7wdWXTaMyohAYyrAhbvyI4UdYE/8de5rnwjfT7g0iEWEocsJHxDue3dhJTtVoUmCbJEI3wyNcSKg9PfZ7FKrOM2uLPwKceS0uWG6dKnQXxLWx0ujSjX/8jfd7Oc0q92I9BpWmZShBxzz4EwVT99SOCLD8xyht3PKwmw5EGBJuu9g== 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=Z39i6OC/sPmsXF/Eki5x4NJ6S/zHYKHFcrA55K5fD8s=; b=j03hwXRRiI2633nOeuIBo4zRjbEH1cmFnG2XjnqFj+J3hHsPEBbo4OcWZzwdjfnsRSS8/FRleKRNZB2i+Ph/wf6ydsYjdck+Xoo4hQ1n92mToD0ukMv5SuG6sdFMAVx5Vhjg+Zp61QgcAPjaulfDZpx2RDymhYnECltMo7DS+GfLRjSANmQc2HDeNqn2/uSls2kxg5y/Ym8DKB3aeaZmK8kDmD1ykGm39Vf4/8zR5DuBnKu/iNkk9hk4Aec5TqV4U/F6RZoTVTrVH5pvJFQGKnnJiGdaOyrrH+nJc2+Eh2bu6Qef4pD9UT7BT5Ufz6kXwlua5UX3+hfPZX13/cdY+g== 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=Z39i6OC/sPmsXF/Eki5x4NJ6S/zHYKHFcrA55K5fD8s=; b=RinNivs5WSTJUX+snVhwLYvSaST75WdpfhL3NxvDQHhaN8NTkS+YFJyALRcUKamGWDmcdq/o0wo+mfxzkzJTNtGSfXlw7kyyDGFThzTzSHQ4k0nR79haZ31zBTAwaZ0dqYvDYbVtOTFtGe2O97NIzjN/G9Vm4hGuBEPA0wZSobQ= 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 SN7PR10MB6286.namprd10.prod.outlook.com (2603:10b6:806:26e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.16; Mon, 15 Aug 2022 00:56:08 +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.5504.027; Mon, 15 Aug 2022 00:56:08 +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, Jonathan Cameron , Dan Williams Subject: [PATCH v16 mfd 2/8] net: mdio: mscc-miim: add ability to be used in a non-mmio configuration Date: Sun, 14 Aug 2022 17:55:47 -0700 Message-Id: <20220815005553.1450359-3-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220815005553.1450359-1-colin.foster@in-advantage.com> References: <20220815005553.1450359-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR08CA0034.namprd08.prod.outlook.com (2603:10b6:a03:100::47) 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: d6bd55ab-f756-44a4-554d-08da7e58f058 X-MS-TrafficTypeDiagnostic: SN7PR10MB6286:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Fced/WnZ7B80X49AnITRVcGNNFfu5S/SVFsMTUtlZXG7sx1wdtkDxZYm3xhhZo48R3PhEPfuOSYjMVv0I7vJh72HiVge28pBbWY79nzAHfZcLRx++cPdqwHJhfPQEHkM5Xy66rGepxkgJSiuoxR77IaO4dH6EdXHEapLIVIbRxxXCbNJb5RG0dckoMaFyavWIYDZSG0ro+xGa9X25DY9sh/J/t6snxtsoD5wvRzd14eenlh+ZqM6Oat5k68t2c2fXJZfAACwwCC+UCxfsEvJrRauUZA3cPvGoTznyohByRATPiY7ZZ8/6tWk4D/I7li3aXc4z0JVJiOb52isDj3ashuvRM+u6XHzbt9eG9sI6WwyNe2K8Yc/nS2UZbkz4fCWbIAevehSBTYga59qFq3U1GN2PVe3GNcshgdTI8I4tu4I/SmO/1bdrRKGl2jXv+NfSfSQ0hJMfQQxvv6hwxC5VKz8PqEx3bU3Qc1/9GCSIUnrJX3m6abGu95K3Kia9Fu7l5hIVRDWVGwUn8vzs0t7i7Sc6mKVNCThsRQbOonQIMjq+7N8hE/hX19lnc7eS/NlDZKp7Nla9bqJi2QduKDVEn0wGE3crHY0KBT0kMmc+TYnOWuL6irzKTcHjHAZAneQax1ENR0/9nkKdsQyMPAqBpCISsU8heQo/yd8x1j8Ci9gzKSw7LElVNTRtmOsNyJakP7XJvjM12U6DpegbI8pWy2Ut8MO9rjNtsy8yr4OGHrkQbhjKQM3JP66cICEJbkoyXSb0epR/LarqZqKO1dr1VtrFn8fGPxT5QUlBYfNQUg= 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)(39830400003)(366004)(136003)(396003)(346002)(376002)(38350700002)(5660300002)(7416002)(2906002)(44832011)(86362001)(38100700002)(52116002)(6666004)(41300700001)(6506007)(478600001)(2616005)(6486002)(186003)(316002)(1076003)(6512007)(26005)(83380400001)(8676002)(66556008)(66946007)(66476007)(4326008)(8936002)(54906003)(36756003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tsa/xYQg2UV/otIrjozk5DUAoHA7/q2b0plhy4P8XDKj867m0YnWIOh8jrWMDzMOJQOhDWh1KVuF6xxS19yVnDW6fY6SaM66FtvoTv2pYwdQwibU61kZlf1LL9AlDMN95e7uD1KLw+hGRJG9OWT7xSHx2qejwDJEkazsi9+4lTB/8eKp9dY5nXfELhRjENbzm7rxzqlHt6SOwd4icNhgyvh97+Ej8Iqj9eN+W8JC3fUSYPg/LpIkUToHRBe6HiS0ekT7fqG95xVzFDVBdZ0RP8nnXvZFvCbuvynx0cc+1qEbAL96ulA6PzL02aUnQj5KE4mEO0lH72CS6JbdoSvBzUjIiCbvRB8ItXI/w+fyU71xaESk0Ecjz/jnLviDjFBrhWlkn/XXMR3WosiCYq/U9IgkZvhrRBjgRzGwczKYMALTZh52VK8i36S1v7cPn0pvozdv/YDIKLA/fL3viChb+OMFW0ijfFbHkd4uRQE0NnTHu0GOeweO3Upqwy3WgOc8NadD0JdnF2+g2UN6Q3lTLqbgQ9eRe8vX8oucZNeDxxCeS+Qm7vpfde3b0+KmZpzpviPxHxOisL6p2BMUH51oI2sFML35dgyzTuoJDWYwWCsTBIw6HnrWAmWnBDrH6EVrm/TPR9/hUROp3vBGlAoqZIP6M1aYUpdUTOzmogWAh5XBmx3ZSEAUxLz1JHMTRFnpYbv5Qqp1HgBMr1P+wFKggI8ui9cC7UoLysw+3hDg0Q6+nz21fFSzRYs001MtMJrlPvfldDlhjJG6PkNaBbxA6INMYHp378U3WLC98pQs7D/OrOQ5t5j8eRh0sMzZvNqAGjcf70w9ItS/dEbqZ9dpjcJOvg9g5DT7/108Q5sYMGxltel969Jv67un64foD5PsHygaG+YEt8xP9I6L25rJxPzzaDkr/bV2o7D6syuJWvjGqmwXBCcKVClFO89iUeKJmMYjFdksZ/DEoQGUlNgXQ2/ShYC/caxqoI6uX2eLvn3B4VqVgs2p2d0kLxWkIbS5hVqrkjNfSUacI0zF/YtIk7XM2iZ+w++BPxdXP0V41p73kb79R+DhgYxoQyWlPF/biY8MP8o5VlHEtL4Jd72EV1fIYLwlOp9oTKeTY077Kqr01k9J184ZGBaDsOqoiR6CLTNIOroGYG94mWeYTFWYrIgA98Mkm9JI0uiWJEsk24eQXrGUBuZdSmK4t77OPOg0H61hAX87oh7DXCQ8Mx9a9hWujF7EK9yaz1RieomYMm8Z8jjV5Glpam0SxCJX7mzS7nKU0vWiy/PgRcms3b08BmiPgPe5BzTrqlcvdxNPfc8Lp+TX85wD6WfE0Pqkw3ZaF5a+9Mpa+MLW1Nz1TA66xJugLK95xjp+uB53gnfMKuHXa1wdYuTexxhcNOL/ez16fNXOSfs6Xceq0UAMAbKeSL7fOB24G7dPnKsEyV2/KPpHvhl6MFh7XVx5GBRbK1aH7VTCwr2wu0phXzBfF3JXBEoHdPGsrQkX9SNWpr2izbFXJTkbltYABuH4jPHrPMInnrz69y2JyGFgg602xcufBXPFwX521IyX1EraFGUjYxgbbnYGha8bRAktq3Ci4T5Ob1NA6jtWUoStEg849rpQdA== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: d6bd55ab-f756-44a4-554d-08da7e58f058 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2022 00:56:08.2920 (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: v9uTwCym4L7FIpgx46WuNbzzTK515KlI7EiGCydfpeJ/oXDhDGWxpS93q+b1HY+1+rvf+no1LTyIITXBdVHJ15i6QlUivaXtl95er3Gk0KI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB6286 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 Reviewed-by: Andy Shevchenko Acked-by: Jakub Kicinski --- v16 * Add Andy Reviewed-by tag v15 * No changes 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 Mon Aug 15 00:55:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12942989 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 30923C25B06 for ; Mon, 15 Aug 2022 00:56:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231738AbiHOA4m (ORCPT ); Sun, 14 Aug 2022 20:56:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230200AbiHOA4g (ORCPT ); Sun, 14 Aug 2022 20:56:36 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2126.outbound.protection.outlook.com [40.107.100.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FF43B856; Sun, 14 Aug 2022 17:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AXz78wNYgTSok5mw1l5QdfNuqXkUspgd0c7Rxi2lLKnLHlFiglupLnsbW9jfsamoL7JaMwoRgvTzLQGZRBzRG9Y1fOmpTNrcVcUhxK1CsnvBt7SZ4qzMIkmcLbOjuyDGMXxfYGfPbfpafwsBHfL/6WTmUakl4wV43awkSgEZovixvAbfD0fGnI/Ql3y3i3jpNdrAb+8kqRNqGM0uAJWrw3ftwTDIod4wEtPHjvyo0P0BlKjuVD331zKS95lNhjXnXGH7kaBvlMoHNi3zljEAGjMcLLt+Rk4A6hjNijEnc3UMpd+fpQKhSde1F7S6xkTlnHGVSWrYQ+SZ4sd/bNZPPA== 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=X5YiTOizMEq699Jb164Rl8ZUbsPRl90dx3bmh4H/GhM=; b=eqSIVgQGEX+bFXG1xpIwGn/9qFuvMzDM0q9N/7iiCa++cFcVSlZrRrpRJH7ewVyfyvZn84mhtGLA1K9vrQrQXPsr6oXomf0/+skLlqsyguN6MHDvQAB/GBtyyvv1ocN+x8vg+BkH08NJouLNWQtjM/rOEip6yV8Iu287Lz43qa2RhdXsf1S4tSrmUoJXFy1f8jpV4W2/i12iWpKp3nNqH3NS61GhSIf5/EktebxMfKD6EohdGigPCc22IlNrpqG8LVN9Zt8ElqvVW+P91vDA06g26b8HgFQwM8cjy9j7hD8aIP9ox0w3HWNEV5rH9d8gIOJRjHMOdrdEfbqJZDUCkQ== 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=X5YiTOizMEq699Jb164Rl8ZUbsPRl90dx3bmh4H/GhM=; b=I/UelCScXdKPqZSQcNwCNJF6qh8j82ifg7rHzh6iIsP0SSefmHcOJ6eucOQKix2eeDhf5XAk37vYJGVsR+bqI5BJN0nSr70FL+oAMJZblk8rFveF+pCVHhkD0+dbFsjSk35de9jy+5pgeUwl0ZYVhxuJOiTDsIrN3yfDbeBt5so= 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 CH2PR10MB3862.namprd10.prod.outlook.com (2603:10b6:610:8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11; Mon, 15 Aug 2022 00:56:10 +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.5504.027; Mon, 15 Aug 2022 00:56:10 +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, Jonathan Cameron , Dan Williams Subject: [PATCH v16 mfd 3/8] pinctrl: ocelot: add ability to be used in a non-mmio configuration Date: Sun, 14 Aug 2022 17:55:48 -0700 Message-Id: <20220815005553.1450359-4-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220815005553.1450359-1-colin.foster@in-advantage.com> References: <20220815005553.1450359-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR08CA0034.namprd08.prod.outlook.com (2603:10b6:a03:100::47) 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: fae45f93-82d9-45f2-937c-08da7e58f15e X-MS-TrafficTypeDiagnostic: CH2PR10MB3862:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rLumUiK6yyCWeSsIgZL+8L4Zot+3M9B+sBbFgGJ5CQ/+CrkU+QKotfNXV43jQvDg+BlwDchcn+dW+zORJKyK+LNs7s/bYsT9tCCnqb45WIibFzvVfBjMzvSLJAa3K4hZlKt1ANwfeqVK3OG8ym7cXKGe9XEmpE5n4zkh7egm8IJ/aoWVsEqlZ7bwAkmBpvML440wfxnCJp2BAJU36QhzcRUvkqBi0C4xMRZUrVpRCJ8vZFyd9QsUjAW1EYfJxnjjD6tvr3vP5jRWV62259vWKRGE1yf9yMHLyqKp4PSP/9UPH7fFWfbgckeYZx+YUczkO4oJ7In6AgZRK7iSU4nM5eIqHhvJtr7F9/xoAxHCtpk6/bXSMfkXOkJG/t/s0boNwkbMTrRnrGbslaUkjehr25OUiM6nSWrtwq0zmXDmS2dPYSH6nkxTE3oFPxE6rpeYIedrZ3eP/wR7u5YJCCBGvGihL6Yj/7TisdgEuKTFzy3rehXTZoKSWu4t0CE87gaelnV3V94ibGOMafVhykpI2lw1TCkcIcn+m/Jf34mqc5BXR7Cr+8firgmsfNRfMTgjd7NgkWlMtBhrNPbEKyOMbOaARte0ziqXCBZ7nFSSV7so51OyUaKdfx3ifZRnj2rzEO3laxmTanvnJxDYL8lOhzuSF44sdSsqqFUMCHbyF+d21EMgf6eSqyRIkarp5/yniMllJGgUH3ryTETFWvyXp3Xdr8TccW2oRwuFcdg22Ggcn/5604nfAQ5ijmTfvZoSY1R7w/xzWclBteNsOJec7uZwFIS7VF++yRPgRPPztTU= 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)(366004)(39830400003)(396003)(136003)(346002)(376002)(1076003)(54906003)(41300700001)(52116002)(2616005)(6666004)(86362001)(186003)(6506007)(26005)(36756003)(6512007)(316002)(83380400001)(4326008)(66946007)(66556008)(66476007)(2906002)(478600001)(6486002)(5660300002)(44832011)(8676002)(7416002)(8936002)(38100700002)(38350700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NvFJ86bZyvzLEreErLjuyH/UsBN4BD+TR2Y+hAXXhz6LaFGyh1PdHVkTM/yVrq6dFlcaEqnf9J+1Lw+k1IW99y6nMnyLHrYnc8sAm8EJyzkiEWUsz+pQcdoF0AiTWYA2+fvMa0l+4Xz18C4MFS7R6u+I0ljpSfS1ODj5Woiw3QG5viZmsmBZm/6VXgsRmf/S6QlQqcHO3gp45hdN9JLllUWk22iVnL7wl2vUmlMsss65d50gY4SVJC9AOL9x0WbTSSrOSZt3k6PHlRSgLfJBrxpa8NEeJhdmtbOphCl+/BWUMTwMVEmRpwuOYy2fZ30aGKVqPumlbPEfjK9Jjp6mk3c7DNg1JSHgvEtCdBOe4n+KKA1poRMEF64ogEaHkqHEWev38kDvr/fQ3Mpdh0akuGUoq5GaxleW7mi9VhHEcN21FGP2Cqk7wzPI5lhK/VYhlpo62yp+V/jwmQOSv25I1WUqSbFU0KdraLnzAf03gQZZ1Qs02VScqpnhBctSWpVRkyvt+Gy1R6U57V/S5dedns0MsFqtho+mxNBaWOX6/EA9XbofPlGcLb5L1lQ0sgskeTPc4XAMr0TnAb3nJvkQEJR8jrcPgmN/lp2F7iYulVjmQ8weN/PgXEN71Ximze/As25fTl+ebV0WEiDWoIde/soOUqwW1ozJhlvfzrxdBGA6062Hv4xSsHHrK7PHZy4caH9HWE+v4o9gWg2QJMumw5rBjZecUUMO6G1SRgRgTjSi5TKNsKfGd6x5dlnwihsVfXtEn5sGloALDu95CpXeuIAeeHxA5Tm/0BLJJKN+0+C9tlVk0VnXmjh8wz4KpFEWMIu0voNZMAR5B/n13AvhaZ0CTg3wFtM+g+a2dMod7qab+J+n65rictyilYOAVUt6/gbKHqXIbX+TRiNBWfIG1priZha8b9jnpHnhcRgiw8PAfb6fr+RMFZQClZRJDsinne1OA4xfDVAGUBb3Wqzyo+uhD4/00rTAw1U2Td+l+EI9bGFxUiXlkF1ZObRgj45T6yaybe9Dr2a2hFdYCeZgjoHu+wZ9GqvWIos8POOI3kuiDSVDr4b/uaVNeScZZRuaqyeIsmxAw54nEm9WhtI3w8rewPfD9BSZXC+7wrlW5va9HCc1pRta0+fZZmi3KuvLIiNxTv/kBy6WaS45FR+0C3DhHDY+a1Ur8gyHmou+VHJGz78XkeJ6As6DjeRHZN8ZNrcjfY+/6eaQsYVMOO46CYh0TlEMFvxvcj27ImzoNQxReukL/QeNj0LWKmtNpR92zvOkhb/KrJH4PuHzFmoEHuGL6ObLonoqzoFsc/0jC3kc8YgvyWfD5K/qK4Ko711fJG7HWIf7hL7eypwn/iEJHJDzYvYUlj6pDOJt0CtCQ5ccuxg2nGoBN7Zp69Y8+Ms4GT/bd9HvvNSjE+Qln44aeekWKXNkVHayMx3ez/ug7ral2dBxyJrFzSDGJO45qK84braixcMSUPJ7pyS4r8vu5aaHSBUawtn7ytpVkY/Ch2J+PHjgNtBbZG5vhi6i4Tc4d3e/yZ2aI6/6glrR0PFTmIQlmOfojRurCqFSYuQRGXiP751BHknTmhNfMRPUDR6bUOVjgiliK2rlPRPzcpsHqA== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: fae45f93-82d9-45f2-937c-08da7e58f15e X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2022 00:56:10.0106 (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: W8E+Xakqg5aoXqTbeIXh+7mOJCuhnde8++MUKMMV7XeqaOKYFNCZcpDECwT/w+vZcIjUcnApqh/kwXG0N2hD2o+UHFooaW6cENuud/MSYjg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB3862 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 Reviewed-by: Andy Shevchenko Acked-by: Linus Walleij --- v16 * Add Andy Reviewed-by tag v15 * No changes 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 c5fd154990c8..340ca2373429 100644 --- a/drivers/pinctrl/pinctrl-ocelot.c +++ b/drivers/pinctrl/pinctrl-ocelot.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1975,7 +1976,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, @@ -2004,20 +2004,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 Mon Aug 15 00:55:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12942988 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 40A52C3F6B0 for ; Mon, 15 Aug 2022 00:56:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230082AbiHOA4k (ORCPT ); Sun, 14 Aug 2022 20:56:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230199AbiHOA4g (ORCPT ); Sun, 14 Aug 2022 20:56:36 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2126.outbound.protection.outlook.com [40.107.100.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A92FBCB1; Sun, 14 Aug 2022 17:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nMhNONdFpIBpXpaMlSuGT3+FTtT5cwoXounCGpiM7bl+DOoz9ZRbiC32Om5BqhXURmIml6V9T6o6QnmuFlO3KnrF9w9xB0pjeZKyUf2xhkGbrpQ4+/0GZI4y9Gq1YM99Sag8K5+BtEO+PCr2jTOKID0Fsd8WQoFVLB4SSgx9S/+Wu/mrvvaaEIjHgO53LBKkCy9PlAsEbTlxuWAMbjZcp2VdcDdToLGr3Z5BBqY3o/RIhn+CX+qvtP91nllH/sI+O7hDd3UJ3IhWZQ5nujd9ZgfkuIxnDvPI72JjjNxVlmLbFNPItVW0hudpJZwqbcIZAwX4WBPvzC9GT56nDcm33w== 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=T5opAq0Wal163efo4bIJB29QMAdu4+IcusfP/GfBH4w=; b=ZsP64Bvl42Q0eVCueaTbBk04+O6V6X3x925zPr0o9sKo4Y5TXA4lgyRSN1zGivXQfYDLEl6HLDx0Q736yyI7HqpuAqt3OZlYJrC4yHhmsxblrdv9eFVP04RggLWsfePM7OPrA4WNPZ3rLjKJi4lUkZxGL2ehhH37bgsU4DYSmtoLuqex8l2Rcf2zevvBzbbKG8uBwe2E8ZaYwhOOIQVC4UjDuLUVdZi1lQh2t0TSyOQE+fX2qtk5y1pk8eLaW3cIDEh76at1gu51oiWxOYh26gG+xv7/adhOyMOSTSkKLhxL9c68YkrgcNMX3kxWNp2frTzME0fILRR60sqUjludpw== 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=T5opAq0Wal163efo4bIJB29QMAdu4+IcusfP/GfBH4w=; b=OyiQwDQAY8UvOVrP0IkMd+kp/CQyyH8AoZt89w9DlPVnCmaheEZPxXud58huI/xCaGl5Jz4U/dA/aqv47awjRSgJcuyZn/RMCc3CDW/dqgS6mu2OAN8v9yTn3OFxjwLSOSTlxFaH/Xuqa3UiIy/THQMY5+ZsH22z/MW6g3ecZuM= 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 CH2PR10MB3862.namprd10.prod.outlook.com (2603:10b6:610:8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11; Mon, 15 Aug 2022 00:56:11 +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.5504.027; Mon, 15 Aug 2022 00:56:11 +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, Jonathan Cameron , Dan Williams , Florian Fainelli Subject: [PATCH v16 mfd 4/8] pinctrl: microchip-sgpio: allow sgpio driver to be used as a module Date: Sun, 14 Aug 2022 17:55:49 -0700 Message-Id: <20220815005553.1450359-5-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220815005553.1450359-1-colin.foster@in-advantage.com> References: <20220815005553.1450359-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR08CA0034.namprd08.prod.outlook.com (2603:10b6:a03:100::47) 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: a2c45aa0-4bec-4331-961d-08da7e58f269 X-MS-TrafficTypeDiagnostic: CH2PR10MB3862:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q9Jk+bRH12gldUt2H6YkvHNyPRxymK6d4xRw1YtDxuTP2j+qJHpzjrIqLbfHobsDgwM/f4sTfW+0GbdU1xYIAC4pYN6Lk/XaH+lcILNLj1coYwVVvT9N8PQDui1k1hI+Bm2HoN4eDKa8AeOEffV7tuctbpPJgJ19vUmvCvJVc1b+vkiFlVfRwmIeVoZOWjO0Bg8ErNNRqKcviTtFEY1upibe/Suv88YMX8om8t6VkmvChGVCklYo2i++LGBzU2ur8Y4VkHHMRzhSPSq7K8WkhbRle6+BOdcq7uRT2cMMmdFZW86lkkZVgrUvj6BNepihliRv3JL9lK+hIvmBw1yhjDpAa0lpSunqXNIejFYG+mQ7ZVc0UuQWnzE3UUZeyyS2GyF9MuNWo+yk+oxMGxjaYKX4jMiVaFscFF4GVjVyltl6FOmhSiKlBXXxlEN+9aMu67KtFIGxhQYPXTl84FNN5J5gpDSPhHU2DOwFenBUaUERBeEJRUnBfPiLNDICXZ4oCItUgPUhfJedQ0Cj0OJLZwedND04Tbl457wduCns6hvZINgyfPx0XkCQXrVclhjv+jwf3BWyFlTC6RNMc+yBrTZZlOnU/yyody/g3zutLFx6DBBJgNpchB1el6ozCA02iVC8dp9LSRNaYA/a12YzEzwh/bwO+H4Unwrhtb3JSXhUllI77qogE6sB8K41BMJxa/+8nVmpNRPKgTEz4qqRDTldJlNRmV9fddG2+IJwnuMTzCeAZcZfp/sU8qfUdaeLHMm8/5shKTEX51pYvYmCunO/sXp7U/hOrEFUUxHf4rk= 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)(366004)(39830400003)(396003)(136003)(346002)(376002)(1076003)(54906003)(41300700001)(52116002)(2616005)(6666004)(86362001)(186003)(6506007)(26005)(36756003)(6512007)(316002)(83380400001)(4326008)(66946007)(66556008)(66476007)(2906002)(478600001)(6486002)(5660300002)(44832011)(8676002)(7416002)(8936002)(38100700002)(38350700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sh1jH6ruosWZjCSiXyKUUMnN+CMkIwSmkePG026CRmdX7lBlyx3Ebj3mbVlzfQxLx9LKe5ZfeL68H5/i4HAxywPNC3+B8Od0nqMwRyjHyxN5KP0PIRJRsmG64/sGpBA4JH0nv8ptUHjgSP7G5GVKHOKAnjD8UuII3dGMO/trBiG1bW676QucIIJcOWjXPjyg4PRgTTr+T2BK5rXQUiDmur6J1t83bFAQK4Kqv/D7gZKicEXJyyWVjKuPoSTy9p4v6DhDnRpDno2oEYgZ9E7VdPBUsjmCumqj6nZaImgLLWytxmNqcVfb2N1/ZGa6gYh1Wbl/vT4Rq/uxJy3mCHDsW0J15HXZb/YPf+a1X7PwyucLVL9OgOj4UDRvytm+WzuyGK+MFBDNT9c65h47oiVATmps4mJGGfZAmF0WCMFeJYiUrAVK5WkXDX8UTQU41UddXxRCeV86zQI6YYnUrpJVKUGk/u//D3EWfdO+EgpsYmEIijkAt92VuzbXSTktipK8XKWnEOngZs2PotLk1tgNoc3TpE0g5dv0n2hltxm0msNIvGmEc1/dVrqyRZnSK4m8kZfvmO68FM8NA2leXZwGzabYNR8fGGUAWPeNa38gAg/wM6Fi6RBUfclXnZzpHY6qkRNzpHB3/9uGjaJPwJJ3knd8iffrsUjjLcgCeGcLt37/3K54yLjGctUEculP+sS/uClc3rKFHXSNO4FmMzMSbIS8dOMPmThqFe4PcjY9Y//iWJEkGtZdu+WQR0uJJF/hRP2uQDbyd3+OLplbDykqoLES+sFol9O+KyuDAjOQ4yiv5Fnzepbzzq34pLGHOTQb6Fw63O9pbFyksyD19R+9EgzyZ9K2BQvvlPKbXl31vmi5bMKhg3qvgcnjY60IBwNe+5c5EoX+tAPYYTHfNm8t4f5rtcgKrRjRKgZISYrSlWDZrDrTbWQZWCN2ZshZ2MEaW1qsaWGpCSBGSOMR8YODNwvwca2rcnj1xA8f67IHDJrHCQbeN/fTOpNdmUIYuEwDEEwhDbcx4ZPJ+mPjNFAvu2/tzmoP5vZpf/QRKJ/kCrrilQDbvtv7kY5B3aXbU3EDG+iR+e6bOAt5ei4YnTP/+MK9/iLuu77LvpQZTiJ6nBOevxFGzXI6s94fL0mCQDMxAxmr+l+wqcTHQyzZNWvKPYXu5S+dsdUZhMiL7GLAB2IhFxLW6EyoPnB3ajVu8PvvpCXyYz3CNSvb4phZ+CR2wdGPnN02+fzC/EWSZ/sn0mW/eyb2Cwb8909cniCxL9Dg0rY6dKZ88D5iyjudshEVCAKqkLnJlYRXnFZuTUbBZ4lgoP+W0tG6FwqEwi0mkBYx7G4osaNWic8F7BjIsYIbMfgykQqy1JVZOq6kLOBsu1nO4UswekrFOfC/fAOfE9/PSBWyK5Qll2fWqQ9tpk/ZxGeQ5cvpn4zhL725tSDf5xea/RauteHEG3+YUfV5SWRS+W0Edd/Il9R7vIyJPx1fWoZZzTjLWSTMkq/iJk6cE6tyvJEK33+85vuA57dBo+w3uCxiE4ekT8HDfeybgdJ2Tif6ghW36XHCotLYUh2FACqlyiy8xmDgMojzn6tef+Ww4LlWyC7O2HbUE7MY/5xKYQ== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: a2c45aa0-4bec-4331-961d-08da7e58f269 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2022 00:56:11.7136 (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: Sq8a5iUatvzX4MlKko4hpawID+w6aiuya8SiVzK8AhpG/6mgpYPkCUsgl1PWAbyT5OL+n6MDA6/B5bkh9Dqy4ggPjk1iRUprczsQUhWo0IE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB3862 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 --- v16 * Add Andy Reviewed-by tag v14,15 * 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 1cf74b0c42e5..d768dcf75cf1 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 Mon Aug 15 00:55:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12942990 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 79D1AC25B0F for ; Mon, 15 Aug 2022 00:57:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232319AbiHOA5E (ORCPT ); Sun, 14 Aug 2022 20:57:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231642AbiHOA4m (ORCPT ); Sun, 14 Aug 2022 20:56:42 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2126.outbound.protection.outlook.com [40.107.100.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C07BADEC3; Sun, 14 Aug 2022 17:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U1bAF4ZrVbFH8gSK2r4A+ZV7jkypW/J84BqLCyvwYEn8RI+flFA5jSak1mDofPsgVtTVOPuMD6w70J/NgreQYTlgQjVfRYqnn8z5gFDtj2XuU71eVnd3TCUW+y0Jwgs1vY/KhxMcvQU6I1gAJvROXHjPjO8IulgCfr/d/qHNgV19tLrSOl3MNtppYGa64+JYT7yYH5gev92A10wQkvC7XclRzfAPvcq+IsLML4Tnu6uT+70C0ssVgmxxSnIj7jMyXpqYDGdl4sz1Yq1bqGs8Hlx8P0tpWm2+gPGdIXowl3BiwmDyhUbExfPfRx8gsiYhkdSNFPuaU6n5ILZWYYr6nQ== 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=VeRckxEZO54EkM75hMOVmLtgg5AW5O+vUBQluRmm+bU=; b=QZpmvG7Gu5P7AfIGItaaLE0zXMNquvIO7DqNAZ0WP9o4pVRuilKpdhlrr9Uo7g7dy6Erw64ritCPrmDNMlUvX7yIKxCqGiyKEYFm0JIr/C1wj3s2aJd6bEszbystu6fsFtT3sELzwsSWyC20pWI/aoxFf4VfF8Mjh1W8M/IwPyQoMJVGKT61uIjfImbjTEAC/jhLCcaj8Q6+wIfZ/NWwt0w6EdjEcwo9ksPfydkw4cN7/XnRW9UV/fN9mePmW0jvZ1TQ3i+8jebe8XK7DiE3ZSI1e3jyYOz/Gy6qOdVoKPti2CTYhbvFw7S7o4K18B8kobM6w/p3HkI7j8QhX5bKww== 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=VeRckxEZO54EkM75hMOVmLtgg5AW5O+vUBQluRmm+bU=; b=aqpyGBmWPt8QXJxXZ4OMK40tFnF+GDC9DtcDzkl5PIMIocoM/a+dldB3yQ7ylauzotIfGH8WvMfA5ZeZVsGMDEtC14ZVsZyHocpCZw+SR79TWEtL1K+Af7/RDcHo7D84DH3gOnK099FkzzReqWC1OiEqZkGwL3tx0p6mWKYeg3A= 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 CH2PR10MB3862.namprd10.prod.outlook.com (2603:10b6:610:8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11; Mon, 15 Aug 2022 00:56:13 +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.5504.027; Mon, 15 Aug 2022 00:56:13 +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, Jonathan Cameron , Dan Williams Subject: [PATCH v16 mfd 5/8] pinctrl: microchip-sgpio: add ability to be used in a non-mmio configuration Date: Sun, 14 Aug 2022 17:55:50 -0700 Message-Id: <20220815005553.1450359-6-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220815005553.1450359-1-colin.foster@in-advantage.com> References: <20220815005553.1450359-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR08CA0034.namprd08.prod.outlook.com (2603:10b6:a03:100::47) 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: 3a4f1b3a-1b0d-4d7c-71c7-08da7e58f36d X-MS-TrafficTypeDiagnostic: CH2PR10MB3862:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S74AKBcejZBvK1InBKTCo3H1rB8tSoZne17ZbxabYV2mZoD1iO1Kzqn0OKUioOH5ruq4j6hgtrdL6XS+9uNVzGRRxmWE5bFAsrDlSp4lO1dFgKz1iWmkkCBS7nt3Vfe0t54jE9h26rg18MwhlhfDD1M3SwDG5n/ykpt5ECACb27P68Teip8hE04LAZBhjfJzahegYuM091yxuFaTw20OyxnjkOdLE6m5chg4WGpG2jiHsziUvgAqOEc8pHoaSe/xRAEN6o+vD1x6Zi8rtt2b3+EPl3Cb6o8Lm6gqqK0yydyIrlnROuYnfCX13vGCoUS4W8rPFKqpUhAp8lWbBGLDRT+2fJEsbYxjyU58T0FCJ4rYY6HCSC9M/w5fjotyByLMoLMkQbNo8QobD0SmSSiJ5eTwbGS866UxfW5IDk9CN7StigfL5RnhRet4qYobArSrDEod7ZXJiw73tB5sVmDwBI5Bd3FbzdoDyiVX/UUQjrDDd/qEiSi6oiPLuf/JdMOn9IVdN+cyhwJ1zPi6tHxcZ57f2p2fxiE5yJVGXs1GZOe2cXY/NhiBeN/fFH0H0E4fAm1E6OMpBOegZNzYDrpqmkNVUuOcUzO/TR+qYxUkB35aXDZmOxDk0CeTiMhH+XCWgzcqMG/g5vQOCBp2VLuom2C94D9Gg60nQAWpqnzlmlbYJ2pxBKWULL1Ck2NxROiRiuxbIbiMffP8PBmAYz/3A6XY3xtZT3X9koL/cK5JaV7BzBIb+pLsiuY1edhaIbaEfAFu3Az3Guo+MC86R4tKTcpehg7BZdRmWmnNnu+Yijc= 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)(366004)(39830400003)(396003)(136003)(346002)(376002)(1076003)(54906003)(41300700001)(52116002)(2616005)(6666004)(86362001)(186003)(6506007)(26005)(36756003)(6512007)(316002)(83380400001)(4326008)(66946007)(66556008)(66476007)(2906002)(478600001)(6486002)(5660300002)(44832011)(8676002)(7416002)(8936002)(38100700002)(38350700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DYQ7MBHF/+j8HqvCUfy+W+5sX0tHy5IwolNY8p6YwVL0y+aq6VkES0BDAZ3UUaILYMIV9K8LJsoLQPGzUzLkPlFW9OJ4R1qxAF7wM5wwfBWMVJ/cgnwQ2IRq8k/G/0KL5gXfllq2hmV+7P3uOYj67www8eoe2nnA4EqCj7y+4SA7GA3OMCF6oqCckLpMGsLGgDnahv45stUshaXrMnD9bRVgKetmojd8GBM3GNO5b/1In2SACiO85LC5SjVL/ROPiB5oeEIEPwx2B1qiSNW/37G5iXltDTp8KHxbxKoNxx5pVsJKmRQhyssMWRdpXB43xgc1DVZfGkq2GkGNTtF8sJqocUsyLmEYzZPY7OB9P38jgrF+CcQOmBoJtGHd4vC1823B5nUqW9fKf7K+5ZEkEmVNUyJ08JYEllt45BUNc6x3xfrpu2FvRmWo5qkIyxvVLaosD3bZfNekMWn8YkS8rCHr7Jo9QL6RYny8KZsc3H8p4lJ6UIe9SP6AV58OhEvzhFY5BSOLJdg2SY4bbbPpLKh6kvIgFiQQ2yOF7kqrRRqv0MuoD6GAsusaZR9Mlw3WIxv+4nVRsuVg7t0xv0NY2pSkfUNFcpDLG6hiYX1DsOM9zYQk/+Xo+XDWIjylURyP3Jx7DmUvi2maJ3D32XbGQF8iNNghAuhLiUMWFffPpX5hcPa2rRO6Od9Bjuv8TBIFxki/xNrXALyQoqYViboX5GfkV50jcyttH5qp5L9hOWhS5NJsAdwY3EjN5im6MjKl7EKfgvqzNWhNhEekwsmHcfIB9z2jYWsC5R8GNmMFfbR65unsCVYmMx8qfKkVY54KPy0fP6deVONP/s5VH9nNvavbSkLmTPTw+NvELcclcJn+6yJM6AVBMx6nbSxWYCAY+zVBZjH02tVo0Yx+auTKeUU1phALW0blW4xp8iEIFzrv2VsRLmz2/L4C5mcImMwX5OsQuizMY85X08MSUqyV6rvx/q1c/7vus22cYktvytRIRj2PiTR1L1f8Qik2SgAXFLkj2XpAqE871SMpdFsEyofjkXzlCE78X/MXK2DvVZiiLstXpNCI5CH59oVtwvQcwHbetySv+w2eXCMG859WCA3CkjqJt5Dx7kQoTivSRr1MbFoLpi5jm5h9FGcxHne2JU5kmPEnjEYkaU9XP8vVy3c2j1UEavHc+xdOFxbg084ez96zjC2z81+7oPIOSo3iKL4W/mot1NJ6wahBqbU6SF5luv2Cidz3HI1/6gwwdrXcSRU2RDj9F7dF4cfZCHVZvJSpUoWag3jWbugf9CHEKuIhqmbktsVwdgei1yVm460EY67ZthVjOangx6dKSHJhlEN/noPthn7b/foU9jzpuHKhOy/ebb3GGOs0sxfwd77QEGthyCwmYV6x82F8awxwxLUWLG1Bh+RZhL+nxXK4VoxbZHFByPd/3ShCKMl5G2EhgaL6u/tL2uCgGUXyfK+aX7pgAA6YUKjOgWOCf6oTZ1wXgfPr0azJK1PCfaw0z4YCJVv/TTb7WNH6ngqLa4um5tC4oXgLIw+YWuaO6ENYOd6xQIfGzZuHMJLcMQpYQhsIDeWqRJ367Y8ftxGFEgm876OdySThnKJH/OTvGDORRA== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a4f1b3a-1b0d-4d7c-71c7-08da7e58f36d X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2022 00:56:13.4947 (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: ikigP4setFmEi9fqscGQNGUc5LXk8+XRPX5NibrDMtWOUaFw8InAymNZx/uE10BFDcytlixDw6eZo05NFE29/16cjnOmwjqli/cn/AYUVLo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB3862 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 --- v16 * Add Andy Reviewed-by tag v15 * No changes 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 Mon Aug 15 00:55:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12942991 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 B5FE9C3F6B0 for ; Mon, 15 Aug 2022 00:57:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232470AbiHOA5S (ORCPT ); Sun, 14 Aug 2022 20:57:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230210AbiHOA5B (ORCPT ); Sun, 14 Aug 2022 20:57:01 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2126.outbound.protection.outlook.com [40.107.100.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A8C112625; Sun, 14 Aug 2022 17:56:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AhaKMSFu5FbvHisSp+CvmIbMWUy6FPWSunCEjJo1nIC6BIjalN4gkQsOfo1PoSLIbs+lp725CaskwzGEWjuulFm1ShenI0DcrbgXu5QsdaQOBeTNl3OHFK/gorQ8CwNIDio8iW49IESMlWPUyQ0JrqncMi+fhsma2FJllGxN34k40V8RO/Re4MZkdP1xAGCmqhT7AENifcB4M+35iUgiHLZgh8VsiHM6y4fG1M/Vok5dtv/0OarIBYCZWN/NO1O/zkBKZ3cZzT46AsVTCp9aO7E+wOrqo6JH5Fruai8Q18c0AM0i5Nt0a6MApRJhn1qhGCSAec1UjZz4UXzqbyWPsQ== 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=hkWt1g9y1Rj2yx6TLx+yEiwfaAPfZe2xipge1N5vais=; b=RCmvrCqjsSw2jSG/PHVAlKRkUf113h1CZR475uiaUB4kWe+MPhbzc+ZZhBn0sHqunTqkGTRZ73l1lXYbVCuEHSh5l8wOrf75V7+fW3IS0n+GVoq9BbsLgW+Smchm0D6Swh47XVQJD7ccMqWYtCR2jxvyeRjBIHjm8wIl/lV1hPNnL18OyNlRbRY9apcIHfwHGwn4azHWc/2z7cMNRNCP5intKuOnYwKZNmrzOssOYBh20eVTgd4B8U/0u3OOswDP3w2XXWezY897H9IwHwC3QaasfsSgVD+DvBmmg8wXWrVyP7UvusstnqjxBE2WaLQnm9TjcY6I1GqBmbzfzLAZhA== 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=hkWt1g9y1Rj2yx6TLx+yEiwfaAPfZe2xipge1N5vais=; b=kW1hNgzIaO6vEXpRsE7R8pzVrIYqKQpdA1q9/RXHk/KIjmVGQh/CVedAsZR60c5wyimiu/aebTkF/POQ11Eee549ZM8CtQ/DoHnvk48UnwgUyuINvIvpnhbqycZ1JseEplSdcxi0MfAr5h9i0BoHa4Cn3eLoNN7rQ2LLSxIU9Tc= 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 CH2PR10MB3862.namprd10.prod.outlook.com (2603:10b6:610:8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11; Mon, 15 Aug 2022 00:56:15 +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.5504.027; Mon, 15 Aug 2022 00:56:15 +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, Jonathan Cameron , Dan Williams Subject: [PATCH v16 mfd 6/8] resource: add define macro for register address resources Date: Sun, 14 Aug 2022 17:55:51 -0700 Message-Id: <20220815005553.1450359-7-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220815005553.1450359-1-colin.foster@in-advantage.com> References: <20220815005553.1450359-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR08CA0034.namprd08.prod.outlook.com (2603:10b6:a03:100::47) 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: 23bc5fbc-eae8-4da0-1237-08da7e58f476 X-MS-TrafficTypeDiagnostic: CH2PR10MB3862:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NVK+2cWj4GUukHm0BTd1hGFh/aRLXnic/1bNi8xI4xaL0PalOFT8UIBIsnVSAFNJpmDJ0gabK5uPycLqkEApA09CTEhaLQhUfoNTIw6K4txH9pC5pw6Umj97XFnat/ehAlyeUMj2C8ipRLzuF9P84ciKSEiBH+q9BH1fNI0RuDLKaAtp2PndKMkcMaOm25D3VHPX7iarp0xxaQI/bNWExheD+DfDyPJsWWtG3XFCX1nyczOR06o0X9ddDZ+FnYSk0v2XQbHgkISkfXxeF/+RSyEZeObS0Q24PuAY2DY3D0CIeZVf6uHPeBXBjUVk4qxizvxsgS3jHcUHNfQjVH9/UG+ObczgBOF8LaobZRxIPlQGWwZbx6IKrUylEWzheXz2N6DznYuW5Esz8+1Mbaif+c8km6sHg7xMSxxs446d+DqP3Hr2iYMzrjEunqQ+i17xxex5Nvy5qtvJa187iUTAMpTRHzEGy7hQM5uTH7zNACXfgjgkIQOZQvW+V5PkK2vYOXgwzwUwdV3UIrQmNoTR77o8QTZea31fI84CHTHUTDHJ/x0DzS7FUB9kOmkLd2T/UPXJRbI6afed/uArLzEJ+nb1vhFEOSwjN1prXmXZUc+4Ey6pYbI83ibJX3pXMYTiIdihXFjhlqW0OJDMivYyqNfI0+GFFTMwTrgFc+MmMjlS5odFgPGTOioq6ka4/4E5//e1FpXa5VK9VdsRFnC4u/in3Q6QDtf/mJ5DfTo4gZjrCzAvTjbjqPAV4xwR/94DI3/5u6EXqp6yma0qsvYfalD0soz21DKkNWmZ7rXdgMQ= 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)(366004)(39830400003)(396003)(136003)(346002)(376002)(1076003)(54906003)(41300700001)(52116002)(2616005)(6666004)(86362001)(186003)(6506007)(26005)(36756003)(6512007)(316002)(4326008)(66946007)(66556008)(66476007)(2906002)(478600001)(6486002)(5660300002)(44832011)(8676002)(7416002)(8936002)(38100700002)(38350700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vYsLeUZdoTGCJK9zgvaK94z8RZ3U3Iu1vtbIDimhy1o5f+WhnRlKXGwuy6t7Xf//nB4w53+zaTwyxV8oTOdl7bxAHGh6dKhPEaI7oQxB8EsNKEJZSBlVNOriPCsDKi9PWz0Xybdw+LxwRi59GM2yxctz57KeeOe5fMIZDjiU+AdjTDIsuCtaOBU2KBGBClm7IAPsdvduo7SXoloKZ4ywAG+X+x8/u4fOkpuagutRDyMtE1JPbYW4Z4y5G9c3m17uf+putLkpjPyGnG7Hk0pa0u/zHvrKK8peH1zY+qaIMZWerchF64N7Kn3xucmLmOY9FMorT0aGATdo+Ne2buKWudcx5Iaj3Nxy6LDyHk93Jd+emNYaa6kWJJYALIl3GzbOwd3udubfQtHtEqPYnGNK9snsi6qeHCMwnCSQYT5/Vpfk6ctp+XtjXN9lLsbPhxXrsnltG1+Z0YvGPNCC5m9NkgAsTBC1RawVMu844e8fjTMW9zDd+PMx/ildn4Fgxfh9awn4A0FT7Xv8YXspb0ALwsSUs/Jk8V8/+t/6g32Kt1te6mp7ecQOXlEjMtf8ebBD9SLx4LTBEmNPc+y/67mvO3+sozmAJL3E1EeP2hHvJtE0wko4On8wo9+fI6Kgy+cylxgAzbnj07Etlej92RR8N1qBlBLp/JFZP6+OF9Pfp/veXi/yHWvLO9qH6l0ZdSB+HV8o9gafeKtLw7e7tkcgiomjv2Xp5YOSI9u/yd0uf/KcAH5QzPniO3GsH4zHGf3N7D3zWqcgnMsGdhE24jOYxkoLaXXe/mY+61QnKTMq5yayAr9XJLwvZnWtHmX4v85Pw4z2HS9wwg/WuTagI5fHOdYl+faCiuhzpTRHsTTdF0HgmwPX72/3A9ZIWszvvmH2pvEHI4ohAgbukHZlIm87J4hegIm9xTsQGMrOySIJf4NK1wFpJzUSwqlJ9mrdJrqHG8okQ6fQpwSgdgBl2j39X/JYS+3jSt0ZKfSPQQGqRHx62OhUbpRsbgGpmdxpNI0ZYAPkX+jDomMF6iF7qeG7pEnGH5Qly/siX3lx4e4legvmJ4NpZhB3iqvMG5l17EFawEzrziBFPe+JvWHJLvuarh7lzVhm8WjPlMVdJhIuEXDOeJ6RoNueY+VmtTffq43U4HDLpKc54ZrUNJ7IybnbJcjZUlBaa4MUiypGDygqyky9rphcIRf8hhO8ml6VG4zzd7vZrD/c+zzEB9gIQ0+EPcUfI9evPaZw9Vmlvv3um/i7HC+4ge6jpbn/CjGkqfKbQQUmxeRmQ7uF87t5R1cBDlSWwza6cNrh8oi9krjR6CBzmPTra15MBPhoLaV+RiD0aXoV4pjymLPndUAkE5TNfBTr3Vc37fS9nVX1AHyi+mKTxVl5uorGX6vsgHAAblxXyxbwrPMwhVjdGx3rp+rbJ1UQOKXPsbEcM2sQBYpZ7/6REuHEI/RZft5skwo78Gl++rnqYe75+jpeTcy8+JjUqh8ebpJPFpTuNLz0GmoROSu5T068RhjuAE2o7uZ1fDp9lThwbAbP7tvrcgazGaCxZqzlH3Vy4cbsboCC4L1CPIvyroSSfxn8lzW1CsAELrb0NIWpBH0y/RLNR1AZf3J/yA== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 23bc5fbc-eae8-4da0-1237-08da7e58f476 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2022 00:56:15.1821 (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: cPG7q+yNg9TyPc0wfnmse3M1uG3YHP7KsY8AR3fjfRlPAeBPikg+OkbUipeUMJEwY0Qy6bS9o/epgJLFdY20iJLyHj4JxuMhB9Al5JM37V0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB3862 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 --- v16 * Add Andy Reviewed-by tag v15 * No changes 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 616b683563a9..8a76dca9deee 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -172,6 +172,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 Mon Aug 15 00:55:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12942992 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 186D8C25B08 for ; Mon, 15 Aug 2022 00:57:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232533AbiHOA5e (ORCPT ); Sun, 14 Aug 2022 20:57:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232353AbiHOA5E (ORCPT ); Sun, 14 Aug 2022 20:57:04 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2126.outbound.protection.outlook.com [40.107.100.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BD6EBF5A; Sun, 14 Aug 2022 17:56:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NA6L21VfGXC96uQSVhpOYO4T572TjiquNTJk3J9XNdMwavuayuVl9bwaFy+QXOKu067HP76enkoRnkzzIC1PhAPPgyGnm2SwXz5FpysVywQQUU7LllOAmrf94ZvkACgg4qOM9GKnM9zB5ItXDBZ4Kqlgb5/bCtexlV0q1ywtE0lW+0Lsworj9vp1SZvj7eTk6GlJn37wac5z7TqH8pjVnJkpEvDtEZ33s5+k/JcQbW2xlAcjnJnzaBJTHFE83347dX0xo9fvi5kA3IGdWMg2dyvO1iDAO7018K+pfEizEw0AZF3T/4yLrhZaZ+yHu4hXxDJP8jpYGHAGHm4+RCDwog== 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=7ugWM/t7mNaTvEKz3aMsWhD90NlTeDCnSdjabF2ck04=; b=Xlzfvl9py1nCdde+WrFLCVBdKCRIMw2XleKUYS4qQtECa80X3+YEUR/0fuHI11Tsxoj1Iv7mTxk/7cyiyxNTRAwpBJLjN5CrPo80qBBrbNT9aya1TQ+vYx3owlOCM2KTqj1xETw1B+RO+rEztjjHeGBRFtIziXx0QkZclrNqVWYMp9U26xjclzwAG4z/aIGp6MTwR2ZlCjkYTU1Lz3my6bzkZRfnAcdSbsb2xIsWmYyqXSHKa+ucAwArZO/VO5qgOFfDiL2GbNtwdLfILmjP58ClVtavqP4aPJPs17VeRXJ/z2kO7PlUyxSBCZAp8XRfOe/rBHRu0amvR6DL2DEJWw== 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=7ugWM/t7mNaTvEKz3aMsWhD90NlTeDCnSdjabF2ck04=; b=fQmPh2siA1v2U+5pthe0cPWMB9jDzm79AB2dy4jl5od0UqfdKYDathDAOK/5rcUa372ROAEQtHAVyCuSB2a4dN69SAK3BMvo4rBcOf58gWjHjtha7pJzjEWRtrQBmBe8tcSz5KlKEhqE+9a8JUy000Ib4eYtZWPvXIIod1nKu68= 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 CH2PR10MB3862.namprd10.prod.outlook.com (2603:10b6:610:8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11; Mon, 15 Aug 2022 00:56:17 +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.5504.027; Mon, 15 Aug 2022 00:56:17 +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, Jonathan Cameron , Dan Williams , Rob Herring Subject: [PATCH v16 mfd 7/8] dt-bindings: mfd: ocelot: add bindings for VSC7512 Date: Sun, 14 Aug 2022 17:55:52 -0700 Message-Id: <20220815005553.1450359-8-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220815005553.1450359-1-colin.foster@in-advantage.com> References: <20220815005553.1450359-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR08CA0034.namprd08.prod.outlook.com (2603:10b6:a03:100::47) 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: 8344b628-faa8-4814-b28b-08da7e58f57e X-MS-TrafficTypeDiagnostic: CH2PR10MB3862:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: osxo359Z7zalW8o6+q5V43v/wMMhNYUiQXizN+Oo74Vj/LnPL1YCXQ0Eczo9Np0gby29a9s/xwFisCfTKmU6vZ3CAXhl9lXoMpZ5Y5a4+316SD5c7B+7e3TnzYGZZivHZmp0Q7I9IZRR9doKBMFd4RWXA91W2vCOuGZCDoKicZ/Kcem8eHFHGsctnTxmU63TFaCwbURG1NBG4JYGuCxF4OiZ9+yzuhrRPYHeHuKWVVHgEse6cQCBpAPD4WYwVD93uNIXOx1JeaIEbhlvUsFHmTB1LrkoREemhfKc1EO5rwCTii80RTAqZLduXN3WAhaoig1qbvSjAW8VgDMdtvKKpWrF3RvKs1UOp3E08pFhkb+oBxi0yKWsQHPuW/MmXySrAEfWviX0Mstf+WsJUR9DuRgzAt7H57Xo4HZejTgJfWDcrYa+spYsnM59HvIehLRdMeGC+rhSXm077Y8rLyZVQamVeBrTX2J9KeNVRsB4nlPO4ipbonAp2VJWTrQ9E4DOarJ3yHosXnzP4B4otrAmegLS2/6ZjuOSmpKhxuW747Ulobugh8T5F5TOqCCRQwzd78WGcysNwase9hDwCZyLn2TTUrnqUaqOJkq4ekjU6x99Zv19rMAwjKI5u0D9hbOHekFKdiMIjg7uOq/HFGmXNqmDvD+nn5KGChG7WVbxbjYbKpMVsrh3GJ1J83ZOW7J7CGJzD529Ansug8PLDOg9IBaYqJ38s8KXT7QXW+cN2Rd1LqDEwlPoMNGtYdxAxytfo3kjNeH6m6YgW2bRzqbSYX4tvlz7eGnMySCqiiO06ax9htF0ZHa6gaEJPav2uTKS 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)(366004)(39830400003)(396003)(136003)(346002)(376002)(1076003)(54906003)(41300700001)(52116002)(2616005)(6666004)(86362001)(186003)(6506007)(26005)(36756003)(6512007)(316002)(83380400001)(4326008)(66946007)(66556008)(66476007)(2906002)(478600001)(6486002)(5660300002)(966005)(44832011)(8676002)(7416002)(8936002)(38100700002)(38350700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: p8LRwHXZinfG7VWe84zdTL4DYCW/wR1hJk9KJHXY12pw3UAIWkthcOdMuojUrcCnpEFfTN0M5fJd4e0VateqkI+NHSAAf8oXbWlYpy3PnHH3PeroQc0+38ORLp+kHSkMWqvijTLsCd0iyKUrs4rDVj5Jdb5Wq1fWDvNUWGAa8jH3GXRBfF/Kv6QOatGV4zwILgo5XDSJK725psYZ86pQ8kSRzekJ5O+zCes8KbuqxjWm+EENWGLgh5rjPE3Igbpbn5LexD4++9/nd0Ss8Mq4kCZA1jn9kPfnkXJPW3Pz4n3UNC/6WnMFq+MGipeGsxjZYHXJmilSCrHU/U2M4NeRiroq4qS7GxPWSIkfxumXo4V2GultH6DNNefjbVMOpo3V2TWoDM/LC2ClIO/LciR9XJYK3QQML9SPhb71Q5zhic2jJDqP9hjU1mfblywEopBJsuM2O2Ve5JxNO/4l708t9MQE0YWuQ3OZb99XaluFMi01inulzT9Y8FLF1OoVMlZvGKwLFY7p4UARnFmKwP8i7IXxnjVm8Ym3hzu4fUTxBJVuFnoHA22hFWpTTmDyDarQ8OrV+cBOEswcbu9dJ8FxL3fdzIhlW4G0TF6r74FoxzZOmmRXF1pbtfhth/xhAoFyP+HjbAqU2zk2q/JdgVaTsFpuzU2W95nNpKSvlJ8hggaGzSk1dj6G52y0PTOpb0nzof6mUdoJ1jiApsP6/v8W4k1OIFYHKbMihkOTmjEgaBO/yckWvrfLBu01oc/crNh83MBToDGHBj5qAy8NkIAcqRjcAH8cxYgkDeqbAu0taIgPR6+yNPd9bgpeeVVfDHDAkeiBqaXa5koU44LvaV/cCnJm03FIDLpv3z8p6YXpnETkC/1i+QIrC4KawuR2kImpAFMyfNibuLKrXByP2ZAw8cJ+E9g7M+PMxsU1GkrUAohYpZBr9ItZlKFYyOI/xxmZ/FA/yFoLA55yjxZMKURzrPB/EjJ5EDXecFWSVOT+4VvNgs/vDKwpXY5lP3OTVwR/Aeo+j3gepw7+jNWV7WCDtHtCaNUIYcvxJpKGQMhvzQVs9rMMvsnM85YqLVqMLJkV043rH/IsEYA+BEcM5VLrWlqBxlMeov/5ceiOgwmFFoNTf4r1WtxV/ijUTQ0vVfwBfIl7xO7FSJuTpalZRutU4pEQRhmCGv3Dj8vyrC+22MKhpWNtuNRIrUqtI9aiVq/NQ1kqyrPdW4p8bRqmnFo3Tj8QPNOHRRF35kT+XVXpXkntwq7/KQcc9S7AHyr5UoCxEHRA1PQ8t2bLKgoxGv3c4N6SxRGMU4RzAh9Tdvi59glJjKRPm4OYeDtro3EQC3FRYT2qBEOUkh5I9kvikZmEKc6/Gzpa2FQxXvYoc93wc5CMnwBCRypGecvRrZ+mbRXMwRpnhyeSREf23dSpOl4TMD6XdyzgWQc9hJtz7k2K1Gv3Jum1dM0QoLPHAkoKhj1g/kiRNWRI2MqlGQwWXKaCIiCfz+pByQWOM9FaiR+lSx2YiPMRiuLxUeFMfk+vBQvcl8gYuyCoORfjJxUJakTVSNmWCf7KUrz1+R9eK2zkuYwHlJeTJJuUHIf1loxFKdO+Gm9Vzc8xdpd9ar5/ZcA2+A== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8344b628-faa8-4814-b28b-08da7e58f57e X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2022 00:56:16.9164 (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: PWxUMt1jSBGHzMKzoztWPL+q0Qsg8771x9jSkNR6H+xoJ6UCVHMPCChwqHwdAqZdSt9agUJxLxFYwFZYq5NIv2FtAfPCF3CfWeraiZ1B1TM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB3862 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 e0732e9f9090..a5df3b0b9601 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14744,6 +14744,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 Mon Aug 15 00:55:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12942993 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 000A1C25B0F for ; Mon, 15 Aug 2022 00:57:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232615AbiHOA5q (ORCPT ); Sun, 14 Aug 2022 20:57:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbiHOA5S (ORCPT ); Sun, 14 Aug 2022 20:57:18 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2126.outbound.protection.outlook.com [40.107.100.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 342F212D1E; Sun, 14 Aug 2022 17:56:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UbKeVNDuc5DGZYfUvAzTptqI0rvjUtWSYz/UC2G0fT2u+UwrVJi0FxJjNIOvWYlmQtrRUlLTVyld87lFbqR4VRNW3fEK7BJ4fWyzB1JWaDq/Ee0ZQMaPTzqPWTxNObi7FViLQY5ZFOKZk3gnfzLwQecEnTZ7hjewLLO87UwvCi77U9daKV35B3O1knbsxxKKIx+yzFQnd0LI93txoedGLWVwvOOFX8uIefEqhjMBOv/7lFBouzewXDJxnelXB0u8BhnIkhc/jXiY/uSKQ8mQghh1/BtscpX48eLm04F5qkCxiIdcjOHBWA71qNRRLOpvgvK0aOqmbbBVC11dMThlyg== 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=CkSt1DE0vzKc6FUZaF6mG5wilqZzfirnN8MpyLbR5hc=; b=deKHfHoTygk3VcyMqzQU8OYIQfFg+04AZV2mBXu/yy8lOLm6fLjiG3wNxxl9e3ei4fXAV5vAawUhkxONRFNXdMRpOGYkAwo51HDqxARzAf0Er6snl9DiABFqC/KDc/YO2DkWTwxRaTOaHOtmc6Rd39GIOdHjcdOhNdD47QJbB03S3Xylvlcg2PJBqVq38bNXCTljTQAP28MIByDXvEpLMZgIhpSzZ05JcYd827kvSKZaory+xXgwVYQwCxB4fDgMq3N/uvDosz9CYmZPVpSSQMnfVnWRaLPD0+c1hCRehB+stCPbL9GyvIS57BeA6brfNdc9Gec8UeDYeNf+SC1PbQ== 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=CkSt1DE0vzKc6FUZaF6mG5wilqZzfirnN8MpyLbR5hc=; b=VaImrgk1uMGBdfScvg3e6HgOLbyay8N9tiSZQXIo0wrXXC/IFJtsvjFHnCjlsHu8lL03GFO3ptMeMBo/HfEI8GGay0/f13NKQwXpiWo1L2XSOIMKnF7CAQYbA1V06CwM+6CbZs9OlKR/dap0eLmTelsWuuER7IJNUg5yNOFQYq8= 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 CH2PR10MB3862.namprd10.prod.outlook.com (2603:10b6:610:8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11; Mon, 15 Aug 2022 00:56:18 +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.5504.027; Mon, 15 Aug 2022 00:56:18 +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, Jonathan Cameron , Dan Williams Subject: [PATCH v16 mfd 8/8] mfd: ocelot: add support for the vsc7512 chip via spi Date: Sun, 14 Aug 2022 17:55:53 -0700 Message-Id: <20220815005553.1450359-9-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220815005553.1450359-1-colin.foster@in-advantage.com> References: <20220815005553.1450359-1-colin.foster@in-advantage.com> X-ClientProxiedBy: BYAPR08CA0034.namprd08.prod.outlook.com (2603:10b6:a03:100::47) 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: 934fed2f-3224-497f-f098-08da7e58f684 X-MS-TrafficTypeDiagnostic: CH2PR10MB3862:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xus5iENXgj4qJfq+2g15O/++gKqK4D6qdIDblhn4pCMxQGHer7+uUAYSOeHDnag9cO7ISMREE5D4wNyr6Uh/v8bfLyjUs61uIvrVUk/c5jT6oUxYtc3k4BnBgGy8I8qY9rtGRIZPZtSLVbRV8IxCsguSje1ksAOHQy5Nt4ZfATfh3Txe94/+5m/2NMZfa9wy4PC11qul/JUFkXR2GrFJ0APg/+WTt94Tye3AwjuGtT6YrABUSArpQyQKZk+8AU6hf5sz4+YlXr4HiGHnbLYfkVK6VVooZmQoN26TGB1TSJ0OhD4guoPVf8DtP+Fs/J0M1h1hxYoaLB0KW2CRfm8UP31pNCfPTh2kCMClBNYQNGZsRA/xprckoIAzRqRBKWqRYnxVnEqPJfJZwePIzw79VN2MWU6M4oKTUIezz52kFA+wzqV/RQL28GPy3vdrjRsMG0YkWO8/lbw3N6/WjRnHifNRyEMQWBNX0ROb5yXSPQyWTKyJlL4b3TIaFcD6Jvhjpk6YWttSRGUPxXVf2liJgxJJ9XKzIibkW2hWyUP7k58GuxPZ9++iM7e2Cz8pn9N4aoL8ShIDqo+PKetrBrGkxFouI8I6PkiFBwfGeTd18IRu58iKE25F1+niEqqeWhtRpCGv83sAF4FdWE/DTVPk0fcLOptXEaluzgKgn7DwXm2Cu0qPsDLyQyeOcYbNaLiBmgrsJkwSfbYR+/0j9Ec+RIc0ua7MDAkJV4tc05wjWOUA3HA2WYpleLLLzO3RfDcWwCegMtTUWZvaTmWNQ78kgKp7lqY9biFmKp5Kmlrt26s= 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)(366004)(39830400003)(396003)(136003)(346002)(376002)(1076003)(54906003)(41300700001)(52116002)(2616005)(6666004)(86362001)(186003)(6506007)(26005)(36756003)(6512007)(316002)(83380400001)(4326008)(66946007)(66556008)(66476007)(2906002)(478600001)(6486002)(5660300002)(30864003)(44832011)(8676002)(7416002)(8936002)(38100700002)(38350700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XEFvt8EKa7vJ84LPgYThHO2XSp6kSWitwCPnsELQOY9kbDwf9fok0Pq22xwKtTl92HApyDS7aYLjIYqZo2PG1C3pcye97oxyg8dCzfhNAvnIsesV6ks7CTKNQpzlpAuN4BQmcB2R/QTsB/yYXTnK1mITXLSN9cguc3YUKD+MT3N+qpF0G/3tW5qOcE1NAG28D3fHvVTeIlIhRqwkm/XiR8v/EucVTJZ03rsgJAz4QP0DsIT7w8byopCrQ6oWIn3lpAG6K760esZAdUHXu5kBzZ9wwu5sfECMLLj1D7PlpZimi5hYB94dPPkoPaux9NKbFfD/rpvap2LB3sHprRKPIuWQDrks4DoU6DaEuGRsaCbwfWJ6b6N1XNr1fIvNXUs7ovUshn/DRuawGePzmjhtaoT+Msk2EjZdChcbPxDuXX58Dz+8xEvdyVB7eJeQCPyatw//U4fY5NER9jBz+KUr2LjHTop5vFD+qhEpor8TlRrJANC24qd5Fdujbq/YGkhIV1xZTqDVO06PW/injwrKhYqoHWu9jWr2ScHOpDXreffAtOEG1tlySUu/86ldFUiPCEmXS8SbrZSHvbGBF8vIPBVvV66wPsKzn9EcO5AVMkgV+KhXS/MudwtV/1WfEogAACaxSO5GRsavQmhMpXquQFUs50wZZRnEYdCq9yU7XdHD4p4+Jb0uW4XqNB34/a+hejHL/iT18Ig5smleXoR1/DXffsOkywhZ6XHDzz6VjehTeJqRi1tcaYGc1muXWFlqtuBvXoErLMllBahyXbHwpEFfusYaXmSTfkL/fKSngC+FnP+eaZn+lsZIFNvUv+MCGWBybumK4826OL27iIe35yDpYxuCgm+g66lvB7BI0Lh4HfzVEyMbMjw95EhjQ1SP0X8Z9UsM3xL0rmzs6zK6ZS1BuHiLU7Jz+aiM1qwRvjIR6AMl89Rnmnjs6qHJrXvHe14OkckBMUwjuxHHdWmm+sfzEFQve3KT3IJRjytNYUZIxF3nch2x04QytXjV3sTRmthPZ5SFGlNVI4Hjp4z8ZfiRMmhZ3LJEKywLxKF/pFuCBbwzEgQmP2CUgdeUCPmk7vySzFbPl2QE4BgU1kyLNpTqXu4+8tUyUagBN1tMPU2m5M16oDSFkHtjp8ET3TfGCuVTRYxWjkxFMgDZuZaGrMgM3HWqbSrOFumiL6852zWyUuzSMrRKNotYYbgFJdyVoQj/ijhwc0iW9mdSxmIsRi0GLHcFtJFS/ppeBAwEECb+/BH3bpxG3fHy61WwdJOMfAYQmmlUaEiZh1gna9jBC0r6GxxnrrVG4d2jOQaGWmizJ/b+Jh1JKyKT8DzZYAOnaHqsbUch4srvrtiOyV3pAadfIr5A23bVYP6fpTnBn32lOnwNTgj19xDFQEJ4BmODl6X9kdmYYn5lL82qi/uucB7AlaOhLHAgjsIr0p30gH8vM2GjT86s+qoCASXx1obeMAjWeLVK3RMoCMCM6y4CTrFL/QlKSStx2iu2RUXeRGdTea7EMmBe/mdcHWVjtsyuS/pYIAG+ZL6m2K/VzsuDaUj5JCyVQxiQuGkhEw5J+03TLbBWi5rQcTEiqrP75LuqT5H58kAJRBxLq9y6aelxdA== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 934fed2f-3224-497f-f098-08da7e58f684 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2022 00:56:18.6663 (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: Nk0FpTOmzekPgUkTiGVql9SVb0yK/HEuJ8dIsedIUbO05BMhFe27SLhqsEwhaOS6nIPURkJW8McUP3/jPr38E92ZD5+DoR7Lu6Sw+wp2N4E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB3862 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 --- v16 * Includes fixups: * ocelot-core.c add includes device.h, export.h, iopoll.h, ioport,h * ocelot-spi.c add includes device.h, err.h, errno.h, export.h, mod_devicetable.h, types.h * Move kconfig.h from ocelot-spi.c to ocelot.h * Remove unnecessary byteorder.h * Utilize resource_size() function 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 | 161 ++++++++++++++++++++ drivers/mfd/ocelot-spi.c | 299 ++++++++++++++++++++++++++++++++++++++ drivers/mfd/ocelot.h | 49 +++++++ 6 files changed, 534 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 a5df3b0b9601..90a873dd04b0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14745,6 +14745,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 abb58ab1a1a4..c3dd1fe8d8c9 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -963,6 +963,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..1816d52c65c5 --- /dev/null +++ b/drivers/mfd/ocelot-core.c @@ -0,0 +1,161 @@ +// 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 +#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..0f097f4829d1 --- /dev/null +++ b/drivers/mfd/ocelot-spi.c @@ -0,0 +1,299 @@ +// 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 +#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 = resource_size(res) - 1; + 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..b8bc2f1486e2 --- /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