From patchwork Fri Jul 22 04:06:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12925940 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 DAF2ACCA47F for ; Fri, 22 Jul 2022 04:06:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233655AbiGVEGg (ORCPT ); Fri, 22 Jul 2022 00:06:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233663AbiGVEGa (ORCPT ); Fri, 22 Jul 2022 00:06:30 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2097.outbound.protection.outlook.com [40.107.220.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3761D89A68; Thu, 21 Jul 2022 21:06:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cf9t2ELfDgLK4kPJbtynYOjsoKOt9+YV/R8QXg6WT/dUM02Q/TxcHRzUrB0vX0H078pJP0Ft4lDaQ5xgFVkN6R/xE7zdxOMhvA2MWzOchORxq2PTzuhCAqABK30Ro3ToAmsKLdZXa/gJ2gc2VtG/PitsBAoQVntZ9c/nF6sOjHI1nTQWxLmCz/9N6Sgb/IOjO9YexVeGK4YeYVv6T6zKjESMrpCCKqI5Wa7I7ZCuurAro9LFLFkRRLjdH7UBC8jHNBcJC1QvfX8zPekgme7uu8CcmCC4i6kgrbu4sGWeMxrk6CWGwECTRSjoWmwKWLRVvaDPG8BFlyo7u/7tYUUZ/Q== 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=PAchGmMFX/04T3UU1T0/gNCIsHcZw3dbC8/DL+At50U=; b=XOdx1sXPC0Orei/tIHVMH9yaHKpkcr9SHuv6lC2I/WMXt2NgwNmuI1b1B2/palqU2E5eFKYM7AiQldq0/aPhwvB0DJ8JVG5+CwA0ne8s6aTUCYUEULAs1s6C2q1jisO1oNMZD+IWKFTUcvWJkjupWLkoTxNyF8hE2ceg4te1CMwu6P9wHsdbLj2v4ZatBQApJoa8o8d5LOqk0YBY0uvtHOtbsYdtLlmVkjdohV3bWtZRpKHQThoQVn2S2MY7vTmaBSEpZY/BNZZp2HGLn4mRcIL3V58haaLzUyZdPvuWl/oKetJVBkJbroeamI4kI6tB+/ry++yrweL3UGVgfjtL5A== 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=PAchGmMFX/04T3UU1T0/gNCIsHcZw3dbC8/DL+At50U=; b=LsyHSQPUaw/kIXkjPBsmYbJItFUJtmFa4ZOLzn10w73Z+VO+Z2+I2XeSiVlk3oHTyunaOyBEd2P9FTb2Vyv/Uqwp8VTE4OPLGUJk8vK20fkD22VdMxR2H3xEycr1b/RooEqMDTivnWI8IfrBGxa5Nwv+QNhBpIgzrP2vsf7bS/k= 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 MN2PR10MB3919.namprd10.prod.outlook.com (2603:10b6:208:1be::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.20; Fri, 22 Jul 2022 04:06:27 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912%7]) with mapi id 15.20.5438.023; Fri, 22 Jul 2022 04:06:27 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com Subject: [PATCH v14 mfd 1/9] mfd: ocelot: add helper to get regmap from a resource Date: Thu, 21 Jul 2022 21:06:01 -0700 Message-Id: <20220722040609.91703-2-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722040609.91703-1-colin.foster@in-advantage.com> References: <20220722040609.91703-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR03CA0044.namprd03.prod.outlook.com (2603:10b6:303:8e::19) 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: ad0ad3a1-d9fd-4afc-e634-08da6b978bc6 X-MS-TrafficTypeDiagnostic: MN2PR10MB3919:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QlFVrgh4YyKTScuubrFoMllhDBmxaz+R1BENR/tJ1WVk8pHD8a75gYIiMZ6HLR0wTfZIe37/2U/o8MKNh74nGOo9EC58ymGGiwSzYF/giCmBVYpIa4NA2vhS6BemYXvs6DrRwc76rZLkmNG9vKy7+cbuoMe/nJh/vMqFpBl/1G39Wh3PEsa16SvAu/hnROE1g6R0nFGFB9ghddPn+bfY2LNBuQ60N1qVgVi3dMpt8wDjBoZCJ0rAzFfv4a4z8EwXn9v4zpghMWj89uXuZ5lHRK5yfOell0E/g8hEZc0Bv8i0vqf7XBXroPTWOmkQ44Mb2PIZiDP4113NRaqD/v39kpL3ENs56H5n6PDXBRVijIeTE2Qp2XtemzGXmXlD/Q7xFePbFwapJbYXYSqtqYHiVU/RxP0HXXAPu1gFFEIrrrm9TBjxi7nhNaf/XQXeC0Y8WVFXQ8ErHHJvmsTqfhsmC2g32ANRyltLk3C/V62pVbjjlecoU4WtU6pDNDFmJR4FcNKmLLvBxa/YiUTVlf7tCPt2byvkmIyplUjXMmPR9p5EEXA9tNTGNU2s15aiMOApt5g9jA3CdJX41sIT70tmxlGyM8OfAdRuwN+lc4I/6qHFxKZsUI7U+i2h+c5fcdt4bIyACnEO0CLDBeOxeN0YnEctIPKwEo8Zx5uExQJSTvGarRqgH/lPseY8/MNxYjUAW0QdzIZ4dM7+bGwzBj56vf9A+RsESiKefn3cbwKoh1S54n0RfaHn9qd8hIQvcWEdPxbS04sykfQFnw4jpIYE2VRbgUtf8BL99xl6PK53uOkty0dpWNsPOFudJ0kTaPni 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)(346002)(376002)(136003)(396003)(39840400004)(36756003)(6506007)(2906002)(44832011)(41300700001)(52116002)(5660300002)(1076003)(66556008)(8676002)(8936002)(4326008)(66476007)(186003)(6486002)(478600001)(6666004)(6512007)(7416002)(83380400001)(26005)(316002)(86362001)(38100700002)(107886003)(2616005)(38350700002)(54906003)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: r1RGFXmnVXjF4r8rekSI5i/aH3cF3JV+Hi3Is+WQDhZJbQ4HReWk/un+KkqWdz7emaIb+AD8E2KM8YiKLxm84hJN3aneBej+8HE9icM2F6W645Lq5QspRHC4tIqoxLHHwN2a32NwkGFmwvU/CYWYkK1oGRo3dBGX46AkNgcgUNG7zBXOwlAh3Op/eeSf6W0n+0D2KdDTkGX+UxlWYo1cMCP3U2jcpf1R0y1uxX1m9VlpjROGOiorpYzWhzxIfBMkh2hTzmpcsVkHCto/P6ipba57pfCEEp7qXx4ayuyYeQV8LGXOY7DX96mFotQ/UJI8J+1xiQfvRJ3dwBCcSXUss+PsH5De88gMDVVMiHsHDCFLk1p1X+3L7DrfdMNoXZTPkQAEWJpQ95JkX6L7IQL5p4BcZeLV/HATl5p+vHHzyMIyL/00v/w8MPKsXu2qWd/xou/HAGhzOR6QpMmhDorPPVfONb3NePL6eG/zrjpKwaEZsHKePP+j2ywt8DZbfCPTZWXUE+Z74lxwrpBcHitrdpY0cCmOq1bfmmrs606hzX7uhQ24XsTBklie4XUmDYKTeCL3e++BG/TSQhqrl8MfZB1O1IHFobC7sRZA8aw9XSOgVf30y5W7ZDDzoWNhuMilSab9c09gBdORqM1VgV586/5VrL+o+uLPMx/IHjYvWr7QzD9yrCPt77g+J6oj4gqWA8wgIGOMJKHbw9TxUMljKqXb8xWTEx9POevl4YY15fbnomHNh1Z6UsKChJs7QmPgLe6abugTFeOuwTWL1x3W6/Q9RNrcm6IWuTqEKjaC+ZfdCJCYF+3+UnXevjrGcQZ2ezZrg1HWJaGirXiGIb1ktwNG4EEHCg4MVhF4YiDWKNhlUW0wbQzAQ6nIWEl2i267Yn778lRDxo3SXd01HOFbWPj44dxJzxllL8e+opw3Rxj2YcDIIpvX3quC2CU1Ix45MAZ39cZwNrN+kV7FgXSE66l+309NMMHo7MfbNeh1hRfx9DfmVpqU6+4RvGiV7fLbfZOqDXVAfDVzjykt6Rw5Lyih7k3CBWMf2gjKfdjjkIkdm+mp0lYSOfwf4ETjgbOM2fiROXlc5KPiMO0jTIxWNq9LBYvWVdFg0pbw7/aMJ2GHEcR7IoGOBIZ/isOKoX1brYmcTsrlzek+FnR4lBPtT1Z7M2zm0adQigWH6tzO5LvDwureINaZCjDuWXYUx8ndzA6EFXnCV4kBka0jtZdEA4VqQJHkv6oqbJH/hJ1oyA5Uykhiw1GD43MaP5vDeM5ThDYppDwk54ersUD9MARkHbW+kOC6TNtCClgYovcOQQKWU7nm6L30pOxv3r4xxy18aAZYIarhHhJeEG5+MSMzagscYJvmY0dIgKVIZoNCG6iJHUl1uJKwT7F8NB24Ct7fOV411sGGSkoBhAsSfBg7gYBR1eBVgsqIE4BROrDqrQb8vR62aRRGKHvSQwkWmzN5nYsyrvMiNkEamWrexxjAZh0yvfNi/MNQAXmWuICPzdggMgZy3yfKyZfDEi1qdrf50m047+olCtx3nHvJxSqR4cVFZrDZCFxlgDwYxaiJtT+dfzD3HzJ5t8sWxM7BK2PZtaUzKSqgZEPnAxd+xZwnvikojdu/677UNr2+2GUfMDs= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad0ad3a1-d9fd-4afc-e634-08da6b978bc6 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2022 04:06:25.7679 (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: UymYj496281dIDUKMUCB3vz5pSb6OEDx95jSFKUKy7H9MWI4BQCgxwa5UikfypAXVV3mCrEEAcovQz2eDpBy451u0l9HuwYvCo12AGhhy3Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB3919 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 --- v14 * Add header guard * Change regs type from u32* to void* * Add Reviewed-by tag --- MAINTAINERS | 5 ++++ include/linux/mfd/ocelot.h | 60 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 include/linux/mfd/ocelot.h diff --git a/MAINTAINERS b/MAINTAINERS index 28108e4fdb8f..f781caceeb38 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14467,6 +14467,11 @@ F: net/dsa/tag_ocelot.c F: net/dsa/tag_ocelot_8021q.c F: tools/testing/selftests/drivers/net/ocelot/* +OCELOT EXTERNAL SWITCH CONTROL +M: Colin Foster +S: Supported +F: include/linux/mfd/ocelot.h + OCXL (Open Coherent Accelerator Processor Interface OpenCAPI) DRIVER M: Frederic Barrat M: Andrew Donnellan diff --git a/include/linux/mfd/ocelot.h b/include/linux/mfd/ocelot.h new file mode 100644 index 000000000000..7abca80ba7dc --- /dev/null +++ b/include/linux/mfd/ocelot.h @@ -0,0 +1,60 @@ +/* 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 + +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 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 Fri Jul 22 04:06:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12925944 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 0F472C433EF for ; Fri, 22 Jul 2022 04:06:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234088AbiGVEGp (ORCPT ); Fri, 22 Jul 2022 00:06:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229783AbiGVEGe (ORCPT ); Fri, 22 Jul 2022 00:06:34 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2097.outbound.protection.outlook.com [40.107.220.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83F6989AA1; Thu, 21 Jul 2022 21:06:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O5EfXFoKP9egAmzYB9f0Kt1u8CfnW6TgfMRHkQThBdcQgqZdDh8i1TOXiqEP7PFOmfIy91tlrtHDMHZomA+H8/X0gv/1nzs1IA1Ne5yOu4QZPm1fvsgX4X97d9E3QflCwo/AcgQd57KoCTnACV5LHlAcVlJiI6w+ZlPUHjCyu6w+VLkBppvjLgd1BltnjNkB0oyT61hsoOgPN0ElvS4Iv+kGSEKTFrV8ooBdIwJ6nmqYOYkGYfcwnEwg/VnEG8bPK21ZCLss5ZzFFfDflk8m8QiVNSwAzjOBx+6jGovVN7sfsiGslA8W92g1UP11ps5GBMDKg1ViGixI5yxKF3R/+w== 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=92iUzUXhYgf9AmwME9MmKxPd1Gl/mMhjGkiY2HAVkqA=; b=TrppVelV5+W0lXc5KCsvPnTXvQ7qP8rvOjviouqO/FGn0ZRkhij0xgR3tw3qXi8Gwk+zSuvuBaiA8ASoz43XkNOWbh8YCGlNRWYUQ9mPm2VWzPrndQCmx6kapV2h/9HTcUwBthqhbAkNe+OwldiQ/nOyepbzSCtRkJ3ytFpklce28GiYpDrXsww5P2/LiUXuf8+2iP7X4Ltp306k9Hnj6OHFrrgYZnCz+4YBV2AxcxdliHvl4Jtza+nQTesB21huptw5uiHtgdMxV7x3DcG0HjX9xRaEPYYro/8tBDwRU9LjIQX0WWxAMXmBRWYnUlcCl/AawY53m01EluenyM3YJg== 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=92iUzUXhYgf9AmwME9MmKxPd1Gl/mMhjGkiY2HAVkqA=; b=aDSxeX/AnnIR336ObIuWdDSuFd0luOmdZ57bHGdz98+p6AffJHd3cYHr7p1jWLGc312IDW7jY+XjHU/Wr677FJQUbysn/VWtnf+hkFKn06rcI9j88LE0fHEAMDMUFVnp02b2PdzDtZVHTK0lhEgOACjtKroibmhmOfBu3y013A0= 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 MN2PR10MB3919.namprd10.prod.outlook.com (2603:10b6:208:1be::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.20; Fri, 22 Jul 2022 04:06:27 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912%7]) with mapi id 15.20.5438.023; Fri, 22 Jul 2022 04:06:27 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com Subject: [PATCH v14 mfd 2/9] net: mdio: mscc-miim: add ability to be used in a non-mmio configuration Date: Thu, 21 Jul 2022 21:06:02 -0700 Message-Id: <20220722040609.91703-3-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722040609.91703-1-colin.foster@in-advantage.com> References: <20220722040609.91703-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR03CA0044.namprd03.prod.outlook.com (2603:10b6:303:8e::19) 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: eaf1dd82-b7d3-4eba-6981-08da6b978c2d X-MS-TrafficTypeDiagnostic: MN2PR10MB3919:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MtGiLm9sJA8NPyqSDg6K2XPqZLsUAkX5aGXGWBv/yfXzpVmuAqPs36RpjodVVd7PBBRJgpq1cgMo8xiVfKvPOlgC5zADpvAUoaanKwq1kWM7W2l+IIsN57b9wiyiRy4QRM9CLHpefDKWsgVI7HBLZ7ezDlc1+FWBFzPgbKPTpbNPlycDZsiqsKrVlvtO+VYEDEG+DSywu4Ao3OiL3wzwlMKnCuH+P22NFVwt4HgRXy6Ux9MQ0OG9bdUVWrH/vkSSBJYeG9/MhyVB6LY5U+ISuSniMZlwWsml4IEEkuG4LcSw0qw8vM0Q3GK36KiHszbWn0vO39MbJotmPTR6JgPxBfD/8jzg62+e+2TMph+lY4h+sjvB5vWrtxWerPyE3ls636/JtWe+/JPPif/mlg4mTsnsCzoo+GBaFt+01yeNn05KF7co8lXeqSGINsTUGcIVrz7qsSde/VP5GXC3lwI1cLVj3gRgnYMOLb0yZemkiSbv14ylo+OetRUKC19qk7shjYE0ZMlSqw8ODlOLPSpIpzGYZgxnqSUXnKxxAqEAXUG/h3H8DzKy1xemuQ2/QuNi7UmAxsjLxjTMzfwBKT55UXQPxEcNdf6IQXcA9tBRIrtHy01PRJgFhL7BqjoQ6723IceM9MHtPgOuDG23zZOdWplxLaoyaVsgI20ZssFPzuz55/dp1cM/9dEme8tI8hewUN3G4MlRzt/bPapthq2ktjVUdI4rhjvuUO12fOInxC+ToxHfM8lPExABQG9wY3k0BONRfuByFYvoIBXPp5lfNpshh6i+T+Hhoi5fwRe4hcM= 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)(346002)(376002)(136003)(396003)(39840400004)(36756003)(6506007)(2906002)(44832011)(41300700001)(52116002)(5660300002)(1076003)(66556008)(8676002)(8936002)(4326008)(66476007)(186003)(6486002)(478600001)(6666004)(6512007)(7416002)(83380400001)(26005)(316002)(86362001)(38100700002)(107886003)(2616005)(38350700002)(54906003)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BfC6KzkBC78WCELIWwAPkLwaCcvl0gFjt8dlInf56/URtsuvuUMB0XX8jIUQ8WoLGEOpR4aTwgqqsluvafha+wbkm61m3Mk4Pi2j8D45AKxLI/Ud+qkrc2tEwTxaJ9Ch/VMRJt2LGJ0FvVKQaWIAmonaKmN4lXJKyacrcPpucOmqUfheIIHEB2pvqE8H5XU/V4KdJ/GEUkvgA6s1XO5uDUP8OxWQ0V8jPigXjy+LNtezTie67lmeAJLKIISc1On7bsHxDP8m75LsEZddgh4J8+PHnggpG7WKu0AelA2V5xhhsIk4n1HYZYj8srp/67OXwXPf8jWQkgUCgv+n4dmVp/pUjqBsJE50q+MVQrtXUi6vcgwrpgrXedMgQlflWOQjAN0hrJp6X5wwBuS19jVndeQ+uCgz3z28HqQrtHHgL6hsXwjQuHN8OdnaODjphuOVw8axebrvfjQ7UQWNsfOPi+uVy+490dN4mjZiP3f6W5cd1oNBUi/Ai3iiyWPcsY5fJ44vQij9jKmzoo8sxL1fCQzkQD/Gs2ouGVJ0YCdfpQ1erWxgW1ZdiIj6Gh/BPoxkOsaOoliL8Cl+fjacnvNrVDhr4xkv3VE3ef7F6BDRr8Vn3zt621P7BSHjL8uMK8HsPR56pVyeSntFuenarN6bOD4idKr/AEpnVAmEi9k0aqoJpHupM1orSyAfKFJoX095JT+oiWuKy+YFaP8//JAna4P/td1KIHdSL12lsm96A4cmvSw1QFiOgsOB2ZRqqqB0Hg3Comq4XOP9NcEzjupqJOABcVdtrERTQyOYAIQhyaxJwSi6xDa59ltOxJ7CSFyxpfXM7eBGxcTXBK/k/UxgBjl5EEs9PM7pR03TPjQOClT2lLianfqZBDlEZgjnm9JfNvN8PtjprexVfhD3R3pqzr6srEScm6G+R0Md72QWZ4lk6GVPeDZfywCyiHoY5rxaFlrph0xHj67Q0FZyDIHR/R3l2OZZbjhyqGOVO0xsQ4Aju1S3yoxBdTTlugfzLPxLxRYmcjKy7ynjNGf7J0fAVBeGApeEMFeRl2peVgsUVSxb439z3YEvY6+2rJSPhDsF4PQd96gEaFyoQdyulObDnqT+UzUwnigN4EZ6GhstSzFzoI+4ExWv0Kcms6OpMEx+qJMH/dXNRqIIBYd9lr26RDitQL9jsvZb397Lv2o1RcreV8Wj78gG1z6THESRoUQQjWlYr4UZn+BTBGamZLA0CzM/xJSbA1pXyxRJ8EDlK0QbUUuBQS5bn3nTt1R9jXJ9Jkg+xrQ9i0TP5LTPWw7IuBkNxOGuY4d4x3DJvJU4yJJV1Geq+DXwIoPxlofXJtGZMYb9afYSSZAASlWjoAIJrwjK2if7m2r2P8WPLbH2INI4IJlwQN0IA6XCDUR9GOagiha+PwePdnnelJYJBUb3M04CDwjQJhd5ddRISy8tZPjueOSwus2/TnoJADbq+3JZ4IoTosN0NPjkwep2RTURBtahQzYt3MHddIMuSajBG3Q95Bwgtc0e4Jo0klo3GTgnfDzlDLZpnA/qv0AZrVp1iWaX9hIliSWLRl5HsPxWed5ZlfCHTJuPtLDoco2SX6n1ffiejOKcY7o+GyLvn+XfeA== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: eaf1dd82-b7d3-4eba-6981-08da6b978c2d X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2022 04:06:26.4085 (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: Fct9NIZs4KN1z6Fi/V2HXrKYc/3lYBTbkg0Myx5lVznUmY6w/caF+h+AImjAbssISHK34GCYPmgWn0tho4BDFG0whL8ii20kVvUiJ/nFF+g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB3919 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There are a few Ocelot chips that contain the logic for this bus, but are controlled externally. Specifically the VSC7511, 7512, 7513, and 7514. In the externally controlled configurations these registers are not memory-mapped. Add support for these non-memory-mapped configurations. Signed-off-by: Colin Foster Reviewed-by: Vladimir Oltean Acked-by: Jakub Kicinski --- 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 Fri Jul 22 04:06:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12925942 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 7EED0C43334 for ; Fri, 22 Jul 2022 04:06:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234003AbiGVEGl (ORCPT ); Fri, 22 Jul 2022 00:06:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233762AbiGVEGe (ORCPT ); Fri, 22 Jul 2022 00:06:34 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2097.outbound.protection.outlook.com [40.107.220.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 017E889A7F; Thu, 21 Jul 2022 21:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lhceq1diDPZWpwGIdKbJvrcMMVufATVvdVDhMjx/lIaJD0T7lUnOHCBcREU+PM01P3iljfu85qWt+D0/2ZfEb+75CJOBVtZ8zedqWkaLcN4tukyE6mCE8EEqiqoOms7j30HUx0AXEtnn+tm9y/mi8lMV9rGlTrTXwaiTbH6spDu+3sC25xhUYRQUBLCoJn0Dmb60bz5IecV6AkSeFH6vWJtrgDwXTsl7pW1QjDTVZTnRJFp3axiB1T0Lx6prjV0iCgFIK7dsIDj3xkjCb/gcHET6i7Qj/WqGsdT3VvnfEKuatfiOad/HISAu0poLojqonQZAjL9rechxxpH//3FlmQ== 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=oM7NXLchwVPorq6qyp5HaDRVFe11Us8AHLYVghdpYUU=; b=kFUWTLAohkX2z4/LsnnsBQviBqbfQYVbZrFmE081/exAi/FOzeBy2Ba2Cu3YlgT53McxYg/Awnh/OA9PpNuHw27gd8Vw22NwOHx1X2/Qd9+5k2y30MwgK1Oc5EtQHUXyMS+VC/UkiZg9Q/jUuV7MRrtkFSGujJuUoHjKjEsP9aqcMN0P0JDfUvuJ883pT/Dr6Cy6LQBo6O+pFD8y9mShfu5ItZBvsaEx1HuPv5p8dv45AlfrGU9rIgHSfErShYZemklGOnWdricQvBUyGHBJ67QPPlHJSBuNWJffRdYutJCLQjCbhMJ57b7awRNkkl+HeG+Wo5WvBglCqBUuRJLuFg== 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=oM7NXLchwVPorq6qyp5HaDRVFe11Us8AHLYVghdpYUU=; b=u8DWlItTvsBtq3WmKJfF9Nvbrnso7qTFCcsinSkfhsDybgUoMF16GTR2BPPgq3zzR381E3DOrjnRM5SxMrp70XWGc8MJXbQH+8iSs2kb0vBC1SyggbVhy1H0UA49D8J4WygB5Yf/hX/ZP7X7y7A6HtDyKqOUkmKPbt8RPwl495w= 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 MN2PR10MB3919.namprd10.prod.outlook.com (2603:10b6:208:1be::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.20; Fri, 22 Jul 2022 04:06:28 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912%7]) with mapi id 15.20.5438.023; Fri, 22 Jul 2022 04:06:28 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com, Florian Fainelli Subject: [PATCH v14 mfd 3/9] pinctrl: ocelot: allow pinctrl-ocelot to be loaded as a module Date: Thu, 21 Jul 2022 21:06:03 -0700 Message-Id: <20220722040609.91703-4-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722040609.91703-1-colin.foster@in-advantage.com> References: <20220722040609.91703-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR03CA0044.namprd03.prod.outlook.com (2603:10b6:303:8e::19) 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: f747090e-1546-4612-2835-08da6b978c8f X-MS-TrafficTypeDiagnostic: MN2PR10MB3919:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D7GZPKoLdCWzJ540TPEP2a+/TihdyZP1rJ2bleMBr3zK69GsehsjTurD2XlhXcVHlGl1Wv/fWcjbrBN3/odVRHULbnE3mONiV5xbKxLZchAYcCDD432fCjtax/vSkQZ2kyWKKwlxRaUF/BVhxblv08F6MIJgL1fQ5YfQZtQ+ZjZ6oeqcccDe/eg4hlSmnzgjuPPuUD3RXB12+7zyYH2jlQ+lt8n3l0LKeR+NG2yH/rb+Asavk+KeX04SD1InUPGDv57Bqrc2z2vh0YSjwidpjo2T0ldGK1Y5Mb8YVwtDHHolNpPidtKZ/pTBlAElP7v4J9ol/Wow9DwRz6Xd+aG3wsjRHSPdX7lbX4DB6gWJEon4gqmZuTtUq5qHG9L5lqtODt0BcYL/IuO1ASh7bFuX5tfhqo7FqQk53cAb7WmSBQ4cc3Zt/ZTHW2QE8scja2xpC0niu/2SWbksMvKzqELbH1DVmIZqCAspgTXjfLVeIaEEFVgGhmI0xHG37GumtJ9sYp7Z6yQKnt+a1AhdOP1aSA3hbzEULj9Ix6veqw/dNtaAAGxQEWi/PxuIalOAPTTle8A1p4gk9xg3qgfVqdt/zUoTMIsw75qvVOKeT57YeXAcLK/qB/OT+/eeGCccelgJkCtoR8D8cVhJTEBNFep2Mw/Fc2mufO4Ueer0rG2kaBgjT8rS22jWSUs53/RaUFfZ4bGBmaoU0O9ppvYH8K/lo6SQuI6jRqFrxGCoIM8WETavVlCGKQCTZ68w25idXNdqSk5pidqXp56PyW7aCFIM5t8dbBLPbUuck7xxLsxVHvKEezGBqvALn2LwUjiui96C 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)(346002)(376002)(136003)(396003)(39840400004)(36756003)(6506007)(2906002)(44832011)(41300700001)(52116002)(5660300002)(1076003)(66556008)(8676002)(8936002)(4326008)(66476007)(186003)(6486002)(478600001)(6666004)(6512007)(7416002)(83380400001)(26005)(316002)(86362001)(38100700002)(2616005)(38350700002)(54906003)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pXBiAU1fYboxrM/QeN7nUHOrrDwwAsU3yCowN9XSN7GzELpJkXtHjhdTq08Ymw78k2v4xoK92cjLqdV5hAkxUQcycidQEUGn+xv7tC2Kg4BYhINBT8sFZWKxY/mOwvo5lGigFrvkgHD2fRWVxJKjbPtvtJvXQupJO3p+ta+SX/MW55qNCilAaLAOEgztUyIw0PtMa8vc+dhRfaWZwyV+0afpzCB6Q8DdWhBlu7HYkfIYHWOK9tUTrGiBIL4ePjfqKnLqyALYjuJ4mLoGbwTx4w5jhiwJylFfdVWykVh2cIk/HhHfilRBpuHomccpFaMW3tyvr+sRuSFtNYjsGQvoTQv2i2o1t3lscqyD2awNc478zPo2StReqMe4Jo0bH1W7edj8xKEnpMoa3Gb+elO6cC/Kc2NBkMlv4XAEwkM2H7Wa+Zw9i8zMNrqVmK0+NhQypW4dyLqbhI/plpKDnZpavs39lMd22m0e2GRSgEjc4dXi5B8nza0XxxegueAxUA9BtzEEr6m21FgCY982Lba5dAo2MboiI9cgA3iuUlPj45b+wqkgvm5oplmTIutInQdGdcLiNLv8/9mAKJfTwjfJDT5OnB4aFpaypL34LvnBM6ZWLlSKNcZjAGiSD51KzN0E0ZBeMr+krVJBPt2AQjPcCD8zKDuoyrxDy5C8y7d/H1gYco56Aq2zOrsnIJN6MZE9HkJa7J9nL2YTJoeYsJiQjDf+MG6fGHuWGuKTikCrg2LFTaHomclGToh55abwJ99FHGWI1Dod9egX+hsp7e1SHB3A2fPPWMqK734F7iGR7vNfN+MhqD3I8e1H18XFZlNtdfaFyFuoe4r7BVposIAHYdyWTIIjNY/WxeD0ZZk/oTgX+fvjdaPU3rl5eFQiSj5tWSqC7AI5S6pB9D7prKhk4cv3LqaXLOYwG3bGRKX5JmK+SmeTqA5qRO1wvUy7YzQQSz7twEclDGynFdd7xwqVEQg3z3njTKQ++rppQ67WUxlb7NiTFMmSHe226t6bIpUsN3M58WRA825IS1Fz9H30R97A6YufB8/j7TEZSWAVfKIYy6I4pqi0alOYY2eVpkpssdaAzkiNTeXrcVLmUTXV6vwOS9mdTL721gC9GthrlTPm1Bw5DDyYVoBa2ERPc52DMYIjRhEpr0e4Juy3PMmCMlwyQnxCaZmil5RoGRTBhmKJhdHR10JIMN6eQqy1Y29w8Cr2fkkhTBhXlZfh+sKnfkONH3mKGP/aSpOgoBW7J1pF3A4ZhddP4QumWrOsjLwz5kLxGhrwiObAwbsGkBm+wggGbtEZvNOnx/e5gO5UYPECEpCvduFhNFyJz9IZviYVI5DLe/IMLs2x68Mxc+MBvTt/FDQnSolmyhNLwizagjcIci+n//C0hrCm8qRNf7i3WVVNoS1/J9vM181EzkazWLgo1Q+Hz4ZblWsdfCGKg4OfUXRkAXzKoxsC4HTTSXO2lZv30l9AsdV7raJ4eTj3ZUAPYQdzRWCF7iL442/xAjv3NRVAkHmvNl6MttSDtsjplF6NHrw0r7rFaVDfZz6lVU4YcFp0yac0zy7DCxc4WPr0KjxbPhefeuwQB74Mv/I9sTtOcFUavI/IoHj/3FV68O41/l89ao9AQMbpGNN/Bd0= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: f747090e-1546-4612-2835-08da6b978c8f X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2022 04:06:27.0491 (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: BbNW3BSr7AcFTuEfo1OUKRt/BQ7DzZcEKDz0Sx7nUydaDvVEfQ7rk1ZJ/2YtXV6pzjgHEy3AYGZKaMrs86vlbrKxdso0aAinNt3jfwtcOM4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB3919 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Work is being done to allow external control of Ocelot chips. When pinctrl drivers are used internally, it wouldn't make much sense to allow them to be loaded as modules. In the case where the Ocelot chip is controlled externally, this scenario becomes practical. Signed-off-by: Colin Foster Reviewed-by: Linus Walleij Reviewed-by: Florian Fainelli Reviewed-by: Vladimir Oltean --- v14 * No changes --- drivers/pinctrl/Kconfig | 7 ++++++- drivers/pinctrl/pinctrl-ocelot.c | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index f52960d2dfbe..ba48ff8be6e2 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig @@ -311,7 +311,7 @@ config PINCTRL_MICROCHIP_SGPIO LED controller. config PINCTRL_OCELOT - bool "Pinctrl driver for the Microsemi Ocelot and Jaguar2 SoCs" + tristate "Pinctrl driver for the Microsemi Ocelot and Jaguar2 SoCs" depends on OF depends on HAS_IOMEM select GPIOLIB @@ -321,6 +321,11 @@ config PINCTRL_OCELOT select GENERIC_PINMUX_FUNCTIONS select OF_GPIO select REGMAP_MMIO + help + Support for the internal GPIO interfaces on Microsemi Ocelot and + Jaguar2 SoCs. + + If conpiled as a module, the module name will be pinctrl-ocelot. config PINCTRL_OXNAS bool diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c index 5f4a8c5c6650..d18047d2306d 100644 --- a/drivers/pinctrl/pinctrl-ocelot.c +++ b/drivers/pinctrl/pinctrl-ocelot.c @@ -1889,6 +1889,7 @@ static const struct of_device_id ocelot_pinctrl_of_match[] = { { .compatible = "microchip,lan966x-pinctrl", .data = &lan966x_desc }, {}, }; +MODULE_DEVICE_TABLE(of, ocelot_pinctrl_of_match); static struct regmap *ocelot_pinctrl_create_pincfg(struct platform_device *pdev) { @@ -1984,4 +1985,7 @@ static struct platform_driver ocelot_pinctrl_driver = { }, .probe = ocelot_pinctrl_probe, }; -builtin_platform_driver(ocelot_pinctrl_driver); +module_platform_driver(ocelot_pinctrl_driver); + +MODULE_DESCRIPTION("Ocelot Chip Pinctrl Driver"); +MODULE_LICENSE("Dual MIT/GPL"); From patchwork Fri Jul 22 04:06:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12925943 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 DFC3BCCA48A for ; Fri, 22 Jul 2022 04:06:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234046AbiGVEGo (ORCPT ); Fri, 22 Jul 2022 00:06:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233766AbiGVEGe (ORCPT ); Fri, 22 Jul 2022 00:06:34 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2097.outbound.protection.outlook.com [40.107.220.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B919089A82; Thu, 21 Jul 2022 21:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=njb/JYboHI1t64/rDsbczUGqXhtMwPrCR3mj5b8pf7CVodXBb/vnEjb1o92urYMGw5OyDP1fF2PNa5aysklnSuZnUxjEDEr3AjBnGRdr5irVWVfsDUnk4nD0VyYDvJlsiEJerPqOLjfa8n21u1P2QW46aefJ0qElRDEeLO75WVO6bGkQ05CQW3THMp75UbtnvZD/+zmNoMOYGY21fsM+zajqWFvvjLDKdAdIC+6RayAdjZbsyE3Zar+xfk8/Jgd2wGOh1T0JQI1+5oHtL7MSNQ+JK3KQK/E3MSUQGyP5MF+sv9gJkJP4Cj2+UOLv8eP6LezWIBXWqcYEvfys/pWD1A== 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=w6yr94A9Iz2XvtHkLHQBCRjbbiW4Vk8lDV+gYVxAFAk=; b=fL31QMjXdKIZYTPtJHHqRtrc+2w68A1INn4WZAl0w9wbtB+9x3gDPYuF42J3+VTrtzC/TOc563mvgJErGvSeAePlYIDnU288W9YWAQsBHAOh+Q+uqDTWpOZ8R2INWai+mrUYqKU8m1d1NcSno8qV4T38x1y6WcmOdPOq28tWKSWF0T4sCPDTjKIG4q07BFIMUzmSBkGJCx3QZsGK0TyAkjO1HPsLZpQTHPGHzA2bxeLdYHSjqBPbBjslhaai+l+YAqZ8Aa/wStC5cY4bBg269gM/iaWivcyF7a7NTjY6ePLonzFmugOhKW3Iducy1KF2jQnkXtUK1CeZ75iXJdM8SQ== 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=w6yr94A9Iz2XvtHkLHQBCRjbbiW4Vk8lDV+gYVxAFAk=; b=myTeIu3wDViy/a0GLqMFdHG787yRq9LWtKLxhpCHEZYqDaTJ4N+cjJmvKswypIwpg8cKuF5T4r5RCsNZLJdcIrsTxVaiJIMpFXktMroFzHfExnE314jEV+mt0gWQ7ilsrphFE4RECE/22Fbjt+GG90UZEfyPAWC/0SBT+wSpz0Y= 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 MN2PR10MB3919.namprd10.prod.outlook.com (2603:10b6:208:1be::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.20; Fri, 22 Jul 2022 04:06:29 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912%7]) with mapi id 15.20.5438.023; Fri, 22 Jul 2022 04:06:29 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com Subject: [PATCH v14 mfd 4/9] pinctrl: ocelot: add ability to be used in a non-mmio configuration Date: Thu, 21 Jul 2022 21:06:04 -0700 Message-Id: <20220722040609.91703-5-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722040609.91703-1-colin.foster@in-advantage.com> References: <20220722040609.91703-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR03CA0044.namprd03.prod.outlook.com (2603:10b6:303:8e::19) 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: a0da7609-ab0e-4c5d-4932-08da6b978cf3 X-MS-TrafficTypeDiagnostic: MN2PR10MB3919:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: deOvO3FbizIbfwGrBpYjRwEYHprhe2x/hNE/1/VpcSiDiE8qW0zeLTnP/H7+Pq3J39cruyugvU9RfT76dVrXkyDv8YPKEf5DR5GSY5ugfceGfLCnkHQkVoFcLjm4ULWfetMTf7zD+zdurnj6XAAZ91xr1o55LywUL8oI3DLa39HvOiJjySbwWNXp6/9XxpHFUmKD6UCwKMsNb/fjg9YWpt7XSglQcWIJOex7o6fkzHKwATQ3sYl9Xf4uUywLcVicjnwov5xbxHXY89UZQB6zq2ti5IYnSGVwrTQj20npoNBbmI7+W+eQWRE5zRrQ7tOrFMy7gkRnTdTfG/Cm3YSTPQJHd1Wx5ExfZBE9CMfXnbrPjcqlewDCJaqxk8hCdCcrx7h2fxnFk1rN/uE/vQGrIwpCRzr5KDMg48i9XUw0dZFFC0xwz8NQlApxLnGmOEOt2bON0d41SPQCQCmAdldx9r0vG44ubbu6i59gx817v0Fe05PKLbY3G0bd4vU1SWE5kQ6tFNQ4++qpwMyP9EHErHazBlg18hT2NJjNplRJ8mRY6EaGm1xCz98wqUD3q6eoUSVxJyF72zCpXT2sGYk2A7JLWJwb6jlHU11jRjQQp4hdwAU7wv1YGPhVZC4f7jpB3yBxH9W3uh/6+zGUlzRFcOVMgp7WgD+MxUge7LQ0gw/p0RRctATuZ+LgHYelLYpDRysOlI3TXsFbKiByT1FrNVJLhDHijhGk+aYgszxWxrhWEn6Ak7b/6iF4ZKOGoOuruERpO08nJQUuy8OSKNWx3PKsMx0WzeoUQD3JmNGZCK5EU5t89F18WthnbwV1EwfD 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)(346002)(376002)(136003)(396003)(39840400004)(36756003)(6506007)(2906002)(44832011)(41300700001)(52116002)(5660300002)(1076003)(66556008)(8676002)(8936002)(4326008)(66476007)(186003)(6486002)(478600001)(6666004)(6512007)(7416002)(83380400001)(26005)(316002)(86362001)(38100700002)(107886003)(2616005)(38350700002)(54906003)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +dxyMUufvD4MI7robNnn7kHvSkw4SPkjTSGLpb3EAi9IkmJmaDFXZtoovwaHFvGmH0wGqPWOynsd7agq2RYHQrjXmZeQSoUF/vL6bES1nIQ4w3vdYPGXL1hvvh4r4/zuWAxzJZG6U/ofwKn4Rt67MDqOajSJ7xtKcXQHzRVpj627NEIPpSHXcXMSEmQNn20v/tIoDnJGXizsJ6FqdJWfPcTzIaehQdr9xz0dd7ZvizLPouXx4Po3nS3WRVWqnjpmfBgSn/4k+eL/36NbLf5gm8gOlDrcLmIHill0a1RwNNJ9h1Vet3mvY7/zpe2adjj9zD4wHDZpRXsL6EHMxIUxsRNqmWz08bM+zyJ2sI2GJnpvqDKL+z0sCGHvnn9nTG7gvBtXpFDB+QYOhhdYQL7CWxKXnh+yVsvtJnILBuvxLLlGMyKyWQIAjL/04CHFPqPyOi6+KmJLWrYtf+nOZXdWrQVuUwFlUwR6tlyE+i0ndbBM1bqP6Rw15O8pYKnpnIxZR9iWatzDA17D78lekz7c7d7q63O0P/LsFfxnuRwhBEwtrspHmnWUxxRtSS4z5L2dhXU6Y11lIGoCQAt1Hm+37bc/MwmMb0kBYZNFEgvXwVnyZPtEkORO5FL61olgc53QHxRz4XqU+Rg5KqNaz3mgalb/EUwSgdB3/B5OlqRzagJ8TT9k4WeBiY3NOgsdX0AUCvOG3KchdP2L9JEzNxcpskfFe+YDVLgSYE2nrR8zHsDZHVMU/QZ7UFKhy/Hn2huZPmsQedkHcRobHzsxskk5XoMPT6PDjHrX7i2ySjm5FI6PLdL2uUAmDzIqvy6P6vupCEZvn1P+zjEU3eNxCunedEy8SV3hrz/pjJKpzbCyCuR/GX7r+8viNeAHIh1/lG00ZaMnWyu6/XwrlZI50sH7lHYIcyfvUb5483/9/Sv2uIIMTVeL4ZkZKOnzIYb1BeFvymJxneN9oEzUSJbnn1kVL0x2D8SZLoMGqFNWacGqr/nBWT7u0O6vnthhJlsnuqyHurjNlBrycqIm/ag84LgzUrDMEf3rGrJDFbngqfO3fXcifXoYpSmulwr7g7HujIWFrD37NUKYjjSIfgpISiDkrAzpaPxkU9JyWWpQtfevS7YbItZTKMg3rNKmoIDEt4Pldw4dw3JCqe2ni1F1CtgmNnUXu6/+1ZLSpiXhFLo9xz2h+XkiL8K4LOdqw9Gqsi+NmF/8LR6p2woNFidC8UUoOErbSwFU7ZSN5tuUk0yj1XPiJZRxstrJagcBabraBLa6X6XPpU4YVOPgU9ai2EaFK0L3BZp1leX039ww+ZFYMIBsEBfzwyJB8+lEyS7da6ezmVpLHhXM6qq/e14q6YGc3abnH0mUNjBkPOGG3jTzSdomn9De0fkH0xAhmiGvPHWd5OTBUsRCjX4RrB10tTAoMqHHcGTaOLA+jfCuNK1MnG/lIb1uwDidO2LhLkX8ac5W8NbPYRyykGNObKMrINvyH5wzeAbdyzmaKlhom6QXyU6BhMVEeRzLS1im7i6Sl1bI2b/HvYT1W69/6EuCYuLLjEiEGQ8659gUr4bF9SMobeXBJzJMIDkLymbykRaBKwzDRuahSGeOtjaDKCeX01H1kLyfumoLiOrZ1/M/+Xp1RsA= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0da7609-ab0e-4c5d-4932-08da6b978cf3 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2022 04:06:27.7209 (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: QNj0MpQ+GXM5RBlN+Oe0Dr5jVOtBoREsPHybL3qyy9DNenN3ioElfn5qC+Nq5abzK6lH5++6iCdsmolU78YL0jVgTCkH5boI96EWBJYcKnc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB3919 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There are a few Ocelot chips that contain pinctrl logic, but can be controlled externally. Specifically the VSC7511, 7512, 7513 and 7514. In the externally controlled configurations these registers are not memory-mapped. Add support for these non-memory-mapped configurations. Signed-off-by: Colin Foster Reviewed-by: Vladimir Oltean Acked-by: Linus Walleij --- v14 * Add Reviewed and Acked tags --- drivers/pinctrl/pinctrl-ocelot.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c index d18047d2306d..80a3bba520cb 100644 --- a/drivers/pinctrl/pinctrl-ocelot.c +++ b/drivers/pinctrl/pinctrl-ocelot.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -1918,7 +1919,6 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev) struct ocelot_pinctrl *info; struct reset_control *reset; struct regmap *pincfg; - void __iomem *base; int ret; struct regmap_config regmap_config = { .reg_bits = 32, @@ -1938,20 +1938,14 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev) "Failed to get reset\n"); reset_control_reset(reset); - base = devm_ioremap_resource(dev, - platform_get_resource(pdev, IORESOURCE_MEM, 0)); - if (IS_ERR(base)) - return PTR_ERR(base); - info->stride = 1 + (info->desc->npins - 1) / 32; regmap_config.max_register = OCELOT_GPIO_SD_MAP * info->stride + 15 * 4; - info->map = devm_regmap_init_mmio(dev, base, ®map_config); - if (IS_ERR(info->map)) { - dev_err(dev, "Failed to create regmap\n"); - return PTR_ERR(info->map); - } + info->map = ocelot_regmap_from_resource(pdev, 0, ®map_config); + if (IS_ERR(info->map)) + return dev_err_probe(dev, PTR_ERR(info->map), + "Failed to create regmap\n"); dev_set_drvdata(dev, info->map); info->dev = dev; From patchwork Fri Jul 22 04:06:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12925946 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 F2810CCA47F for ; Fri, 22 Jul 2022 04:07:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234230AbiGVEHA (ORCPT ); Fri, 22 Jul 2022 00:07:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233803AbiGVEGf (ORCPT ); Fri, 22 Jul 2022 00:06:35 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2112.outbound.protection.outlook.com [40.107.237.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC9CA89AA0; Thu, 21 Jul 2022 21:06:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jJTXNFIUi0kJdetmSlJOarRXnRrVc65HA7pJf8X7e4Ec04fweK1STE0cW2MDz8c4jyBcsPzFq+fCkLqk1LIWJ2kcRD5iUhIHwvidNW01P99AriTWLuKv8e0DWfGHR/EHuW3NMhajoELUxj/sgXn2zvNbkX6UgKpkqrU8mYB2bYmucdgzN0lgIy5gIt6KKfE0POwQJJH/ERElc7bqtrwfN/pbDkCJlkW9qq6Vez8sqmnylUDAA6IcufPQDUcczeV2d5pvxP5WaNV5kPO8DUjWxkZOjTLwhjNT81+1gCoGeS7Se9qp8b3k3JqjrmFcFyXlQWPkOnubx6U/DU7ZPfz9KA== 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=lafS11npwB5UTfmFr3JA0o7GOe2aDgah3CQnMORekVQ=; b=jppbpzzUyp2YWFAD4xZSBsoLpb1ulPbadoruilL0i/PdRGrsKOMVHCXw3OekB0WIb8Ac/7ds89WkZUVJm3P0WQ2XwFIN9BypqlXGKhF/imYgnVpZp72URdZss0U2z0xISG5BR9/sFY+VTv747UOyTRBoWCQyc9DaQ7WpxJFITHucZzW2jbePQKMa814JYBcGvnpKyFaAQnBblq80WZxpaWuiTM25IGN/jdZfeQX4VGcqDeAnPFgFQDCcdjDEOKOcqwkOqvjt2+9Td8Iko/+MKx6YcG3rJe1sfUfKkMekoWd7CHy4EjOJWJxPQaCghBJGUFPkY6i7hwBRm30yJd3vdA== 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=lafS11npwB5UTfmFr3JA0o7GOe2aDgah3CQnMORekVQ=; b=b7a50q+32ZHIM/1bYsV0+DYy3nJig/Wx1PbEPI0+R9vuxjGqZc2t2D+Q//NDbvGE7mm6uudKw00GqA2txROdi13rV/Bt2V2+cl9JQzNmYkdRX5V1v/OpdgB2alD/fqRXkmdVc44CuPvTjQa4MVwrbgDy9lTYwCngLAuFzzKxMPY= 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 MN2PR10MB3919.namprd10.prod.outlook.com (2603:10b6:208:1be::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.20; Fri, 22 Jul 2022 04:06:30 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912%7]) with mapi id 15.20.5438.023; Fri, 22 Jul 2022 04:06:29 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com, Florian Fainelli Subject: [PATCH v14 mfd 5/9] pinctrl: microchip-sgpio: allow sgpio driver to be used as a module Date: Thu, 21 Jul 2022 21:06:05 -0700 Message-Id: <20220722040609.91703-6-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722040609.91703-1-colin.foster@in-advantage.com> References: <20220722040609.91703-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR03CA0044.namprd03.prod.outlook.com (2603:10b6:303:8e::19) 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: 4cd3ad85-b562-4cea-cc85-08da6b978d59 X-MS-TrafficTypeDiagnostic: MN2PR10MB3919:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /DMMyxZQpDw0DGyg52M4kNjMJvZuzCI57YVq5Y9dibWnz6QycXkxlVgrMVtvgCCGfwXocmOPTyMi1NZMyWi1R+aWYMCHfSihIIE7DL2yeDJWEmE4to70pVEgQtWf/ByBubtlxgpEEudJ6xe6PbSHqR31d/8cR0inYa28CHgDV3voaGPtITRBKr+iZFaT3unNiqroCshCJQb13RDKLe24HZtNBeu92snalyf4BuZC85NVoxlxANsh59pGTPzN5ADvZ/ZEXTkXzDVI6g65e+iC52XMBN4zEydT3SVpanWnUjdvCLm8IhhG5+xZu0ncCIG374owuvQZLCOwiOjplfdfKmk0twewowDmb+GJqOQTdR+OjkB3s+MsUOTOLazYklojqYWGZbxABrhsk4aCGqesNgbhBB+r+SS0oCEUOSStif7QRO6IqdwbmBfYjGcGjS9t+lratm3ojZF9yuEq2exwfldX5gABlUeNQTW1A1Ki6ytA+vi1r3p0kaYU0kyCLqSwSCALFpiNjMqiEFlzG56XHU76MHC2FcSpeThULuqLhIIhtin0Kan6V32Im237FU/DbrAmopmfRt0+8NTXXKRBLQgv9htj+Zs5EhPkojA8E9HCfHrVrhh507jC3h0ikgfN98xjofc5RX62A9NKcdymtcLIJHL1s37UOwJLIYvs7Zcqln1ai0eA/QRIE99ix99onWRto7fAEFZFFxzpmfKU7EUEXiJUR6PqW7kuR3v67WXPqTu5qF+uStoBb1JAx3Oh53y2kujBV3A3v9CzuFtIMJL7MkD9qAL384RZ0WXsS+M= 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)(346002)(376002)(136003)(396003)(39840400004)(36756003)(6506007)(2906002)(44832011)(41300700001)(52116002)(5660300002)(1076003)(66556008)(8676002)(8936002)(4326008)(66476007)(186003)(6486002)(478600001)(6666004)(6512007)(7416002)(83380400001)(26005)(316002)(86362001)(38100700002)(2616005)(38350700002)(54906003)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GOtDzABlpqXDh+4eG1oWK2sOZLcYx0f2rgSRK+1UZcdVzVLzCpzDfkGps9C+kj6U1e4jsLvwRxsikCJcImssQ/9vFp7x9TGeOwZCC5mzbrIIY0rz8ZzQsJJueG4GzlPKpbSd8lvz0prZDUn0gjFbVgP+KgCm1VoQssU1TONUroXN4gnq214pizA1R9hUmUGRwPLwdhW1hwHhiw8kdwaFYf60trbYRgnxYollBQI5+m1Hkr55+UnrvsaJabmNdYvTk6V786tztCUGdZHqlrCoJ1Z/Ij6Xv6ippilR4m1JXWmiBezI5/nZAtJPQqDkL5a/oVmiQBaRhQvOP34QamHlQYntCOiVn0/zYUNnBh5JnDiakYMAVO9cN8W3o6y4As6SRH+DD9IlOqRAo7ECVynAU5ICreW2zDvlQKG3ssz4M/dZDmyU5Xwk/fVpDu8DrewNs01xqhUQBPQ+TuE2+wEYKFLLW2VM5zxVB9YD4fyzXQUaAFFZoUxS6EojmC1O3U2SKCNvopy4KryC2vL0zi4X7Bl7/HPEZq6TeC+Nh1++qQMISvPG4N3V/mNCly3Egkx9jcyVJhMpSNRH8GVJxX9YXWK/jSn6GJ6cVu9dl4CYOCBdhvX33VUFOscZlf7xq3vcfASvqzENPubBhxaHewuTnrUeN3wt+Ixlfd6QL83rYtsEqdT6k7Cz3rsCikE/Zg+NTSc8Nt7kkaGO7BcXi926JvVqTuJZpV582BDND5dyH37Ya0h+aKmQfmWKhxl6FO8oUALiAtSfugY4zIF7P3VAlHlVNuQTgGGuAyL/4pAfh16JnKO2s9LoqLi+ImR/sjvuT/EUpymvdeQjRM1LJw8f0S5zyPwMfgsiIJ9/1jXXCUSKI+L18jtKjHUuNDhTMQwcxIEQHaOmVzvamUHTuy9JLH5ODaRwhMrBAl98FxeNJzh5lFvO6TBJWrvUSGaO3hGDcmVG4zpmBxqRD+afzt+LjocCZEEP87ZHUxdzaRjyiOq9L+Tsic2MxmbJfIKuoQo700J/0SjVuj5udWcrNlOfkNsUHZnHPtE86CY6ZVgv5xQOl2bRcOvlq2Pxqp6yPV9aubx4dOXo1YrFv6QTniyxvbO6fciMrgHfLYbRT8NWH1Xm3VqDQ1vF5kJvAd75ZG/w7xXhWyWBViJ1mDRV9gH2W5XzQ6FTOzonfnFMyheOfVLOS/g2yV1gou9rqfJG9ZR8wu97StHVmL+PQ4Lu5DaeP2XBbVPtnvk0nEpnn4QRphIw/NJbHCt6vpilz+4LiBkGlND1VK0+71Io5ih1I4gQK3UzB8+7RyXEtnmq91wPUvJwRDnzfn68Hg7t08A9WIufwIBAWad9qIXlerjuJ4LTd2c2sCt92I9AJ26TzCi//eEP4d5M4GdLY4VDHJ7hYU3f0X3S/HD1Get1vRmCdL4PsNzpVnz8XURoiNM5TXDeQ6NoXDQqxek++Dv7MVaF4wIZcpXXZaWIGMQ0KHW2QYIg4OcHitvdx0GG60PMiHkfXx2kdxrMwCWNUEUbTjdgzwyctdJLGzUxbi0+OtxgvUBB0FrVGpa1m2MnV1xEl+C69IKG2sh/Z/reWWjUVtS/zuCW66wYT9I0QWpnStwpX61QsmgVqDW/FEoltY8xFJq3tbw= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4cd3ad85-b562-4cea-cc85-08da6b978d59 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2022 04:06:28.3771 (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: ZrwiMYKLCsrx3MHBYjXifhS5qngChChrK2gpTkRgXbvIVxrbcYjPWJfxjGz4Rb9z3WMZQXNQY0sXtiK5uxBbrci/n9yieAdVy2710IcWt+k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB3919 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 --- v14 * No changes --- drivers/pinctrl/Kconfig | 5 ++++- drivers/pinctrl/pinctrl-microchip-sgpio.c | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index ba48ff8be6e2..4e8d0ae6c81e 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig @@ -292,7 +292,7 @@ config PINCTRL_MCP23S08 corresponding interrupt-controller. config PINCTRL_MICROCHIP_SGPIO - bool "Pinctrl driver for Microsemi/Microchip Serial GPIO" + tristate "Pinctrl driver for Microsemi/Microchip Serial GPIO" depends on OF depends on HAS_IOMEM select GPIOLIB @@ -310,6 +310,9 @@ config PINCTRL_MICROCHIP_SGPIO connect control signals from SFP modules and to act as an LED controller. + If compiled as a module, the module name will be + pinctrl-microchip-sgpio. + config PINCTRL_OCELOT tristate "Pinctrl driver for the Microsemi Ocelot and Jaguar2 SoCs" depends on OF diff --git a/drivers/pinctrl/pinctrl-microchip-sgpio.c b/drivers/pinctrl/pinctrl-microchip-sgpio.c index 6f55bf7d5e05..e56074b7e659 100644 --- a/drivers/pinctrl/pinctrl-microchip-sgpio.c +++ b/drivers/pinctrl/pinctrl-microchip-sgpio.c @@ -999,6 +999,7 @@ static const struct of_device_id microchip_sgpio_gpio_of_match[] = { /* sentinel */ } }; +MODULE_DEVICE_TABLE(of, microchip_sgpio_gpio_of_match); static struct platform_driver microchip_sgpio_pinctrl_driver = { .driver = { @@ -1008,4 +1009,7 @@ static struct platform_driver microchip_sgpio_pinctrl_driver = { }, .probe = microchip_sgpio_probe, }; -builtin_platform_driver(microchip_sgpio_pinctrl_driver); +module_platform_driver(microchip_sgpio_pinctrl_driver); + +MODULE_DESCRIPTION("Microchip SGPIO Pinctrl Driver"); +MODULE_LICENSE("GPL"); From patchwork Fri Jul 22 04:06:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12925945 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 7DC2ECCA47F for ; Fri, 22 Jul 2022 04:06:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234192AbiGVEGx (ORCPT ); Fri, 22 Jul 2022 00:06:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233263AbiGVEGf (ORCPT ); Fri, 22 Jul 2022 00:06:35 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2097.outbound.protection.outlook.com [40.107.220.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FBE889A87; Thu, 21 Jul 2022 21:06:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D0O+/DRDvEQi50M85QvzHYMgrJ11ItdhxUHQAywTMVW8Zw1s2uMswpxVOw+CnhzL3VgLoU9wEnJ061L4tPj8DX7Zqq6Q3IB5RggQysSHmxPiNlhRC7LOo/hVLKAjd/zTzP6/DxkqWHbNOVIT8UoSI2FTcwfNkERgLk6NN978kxlfWCEabioQno/JP6oLKMJotHRqDn/KgHqHEGDjI/W0wbBqdvYWWXHCbeGB/bk5Dr8HHHPUsmmWRBNe9K9bAKryiYT8qo70YMnhXr4Tny9CVfwJjIlPzvcQP4Qe5Z9Hqi2L/1BG1je8o8elFDumv2QUKaebWdFJv0zDBmxXTuBFfA== 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=kK8A1qhc8RxFrx0hyJytdFxYW1S6bsYH2mPTOT+0jtQ=; b=lZDYdaXFyZnk/tGmMO8zLpQMrKQMCZfR39sbK3XakM8oiYQTke0ug+Sfjbc1ld8Ymi8y4r5Q78pwCDmRXhthdHa0TwqHvvytTemO9e8+bGvGqtcE0MAwhGzrTZSZQqoQ57FGzpYZ9XKSEAitNPw4OFLhYgdSLcGtqiMKsUTN4+/uVOf58YMrCIWkwYXxaTyodn2AwWhOyqRT2LOuVuBR867HmJ0pdDCSae+r7sN2ocefuJKirdPZIeOzMFbc1Q1W2NxmU/0U1MCWmjd/3t61UmaBlfGxkoTj7spB7gku6Bi+7Rwsl2DLFMiMcsauXbhMbr/gMj7+E8lUHj4eJ5BUtg== 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=kK8A1qhc8RxFrx0hyJytdFxYW1S6bsYH2mPTOT+0jtQ=; b=ScbxJ1//sweJdXF/FQOw08rk15xG4WGalrG30CRJWlPQ7vSp6TLGDlKWm/ivWcJkGMqhSU9lyMvfRVGd5r8HN5CKO3fJYTdvSipxQ9YnZ0M/fUgAMls/8BdVd6etGesGESR14jXqNHW+V+rHSAPjFD7NzfMfjze0GTF1wbJVL2M= 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 MN2PR10MB3919.namprd10.prod.outlook.com (2603:10b6:208:1be::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.20; Fri, 22 Jul 2022 04:06:30 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912%7]) with mapi id 15.20.5438.023; Fri, 22 Jul 2022 04:06:30 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com Subject: [PATCH v14 mfd 6/9] pinctrl: microchip-sgpio: add ability to be used in a non-mmio configuration Date: Thu, 21 Jul 2022 21:06:06 -0700 Message-Id: <20220722040609.91703-7-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722040609.91703-1-colin.foster@in-advantage.com> References: <20220722040609.91703-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR03CA0044.namprd03.prod.outlook.com (2603:10b6:303:8e::19) 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: b228a45c-243f-4d10-72cb-08da6b978e05 X-MS-TrafficTypeDiagnostic: MN2PR10MB3919:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ddl6Yjogfxkg0C8wc/On9U/+/JgGY1rSR0hNsd4q5aZ3D9Kdk1odifKDuCgwDpl665tYQWLpr4Jhzg8MzKdZYKf+0BaSdjlzoZwprUnAcWEoq3ZZE51UDMY7RLrTeFHCEHmhb8DK3Z3WU97OgbcClpx/oitAq2bDl6/RpkeAtUhxeCQRROAqJV4Idw2E/5DS3Kh4Hmyfq4FolbKjg9ASFQvwDEJikNGOlJfHEa+8nBFz1lMl8kLdHGXRb9SlKvpqE3lmTJabTYdr44c36D3ZKkuugjhJk8QkAyBiC0JUQHut7qp01uvfSY4ZIHPmv7aq7EoBMGDcgV7LMRooiVIFMVZZSM8RLRW+ObTtoI2GclUp0/fOhpL7kkYk53FF/5S4csNEVIvDerhOSQMnX3yQXbRCS6aS4HRRidUjDe/+RnhnolOkDcr9URr/Dx5z4ADYTih8hHOJLHu5+t2aVNRadugNR0UPZObZ2FyoAXeFID+Gjp1gJnsVrKcscVYPG1scjl9nJmzrF2UuBdLjnI5tGGXTfZ5oNcYhTWlK4RVkIS8XTtTY038Nuj+E9BSiDezMbJ7XNWiFPn/2Yi7PnFd+6hgaRGz/PcE7V/yCImDXbV+IrBgeomGODArYURw8J8FMY/KGr7/rUexjPdXvOhacp/91trHXuqmnaXbZQIChYoHWGft7deN0z/PBUYfvNPQj09PzEdkcU8cECOz3c8jyItSDecieWo0IJIHxelAcMoPoiLWrUHa9qF3EpJk2St7Mvx6rpTdps4HRJd28aoa1Dt87BizfUkqBH9cQqWgZ/jY= 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)(346002)(376002)(136003)(396003)(39840400004)(36756003)(6506007)(2906002)(44832011)(41300700001)(52116002)(5660300002)(1076003)(66556008)(8676002)(8936002)(4326008)(66476007)(186003)(6486002)(478600001)(6666004)(6512007)(7416002)(83380400001)(26005)(316002)(86362001)(38100700002)(107886003)(2616005)(38350700002)(54906003)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 67j/+GtpdNYSdNjHdBrlnw2SjpQbQd4A/812voHoG3tsq3Seb+LM3fTe3yN+VIL62FFxLUAhPL6pvcHxBnajUj9OUQNnI55nsZD167++fh1AQU4tTbi4noKPW8BJl9HI28HWa3KqucqzBJEJV8KOVnrQ6kSN8y4djWwVq1zUpiPJ6H2AtfsNe40qiSW6iTw2eEXxwLc75jgX0pKmNFEm7ZFqdJxZngMPj6fB4TdYVSYjg1iRCHl6H0WgU3C3w8DJYqbhyXnfRenP8Lkc+cBMIc8p/hhTWoOyx4pBreypbeK/wH7PZDlp7mLQvbvMrhTRgKZDPrjfQBz6ynyf0u0a3bnpJxslfhXbGbrAur6KMm+XWa6/vKd8s0ChGt3stmnWtqo5zXm6i3fMTUUWkxkBLeqsfRE/DPiW1pt34zhtitZZ0MoGGkb0ubYy7sxTdQg5deCLVY6NqQ73TOyWdRt1uhsr09YhYW+8tA+4tiFyL7adCyqUJp43PGbz6jC64wGci6zWxFugwO/nMkvqxa7jW9McMgV62hcI9EbT93sVfxlMH3zGBzsjENMEsOJbKogMUoW1dhi7Ly2sMwopPEAD63f0u32bM6nuVyBDU3JmbJVMetFLWKRTveFCkvffE44dpXK4zMW0KvN6qAsC4/ByCfftOPh6N4tl0TLOvDeZ0zFY0XSD5HT0YFc4RHIXLU6RBEEfb8VCIygElS/ivey1+kAxsUfRl6R9+8ojplk93nMGv9e5Yxt9D2Kk7eB5M8wY7chCaWYawtU4kEorMVOu92Px3dBPR0/aj9s437zOMKg9/Pw1U4+o/sM3YlanUq+IhM+Mdtl2Y+hpMER9YauQ0zDuyZHCpRQESP1ovQoG9YQr6G9dsCQWAnTKlcOJuFFBq3JJApmhmyn73RGEVLwicarCtJTtxJppNfWCfET9dgH7vCjQPB/RJgXgttgzdes795FbCNTEANuto9U6Xq34/fX0ktCb27ubDOmLaS013CqOueP8PpWmHagKYMzoQmtZpLic9EHFgKQ2WLDbGAFvVD6Dz979WiHe+HLNuIncEFhofo2q0VKVUpS50qkbjYe31V7LFavFCNEylYXQwNfMPAon/wSnOx8Ep5MW58/7oFxXx623IoF08AVMRlJJjef6cozJaecM/RsSnFnFoyfH4O6SalqT5HXvXVBSVgbmlZCUr38QYQn/E1KcVj5Cghd6UerNaedFuatatVElMqQhz8SO8EJkFhErDfna1vEdYGLuwJANl1s50dNm1Mpit7KXz77iOeDkDaT1gGFfVqToVJDoDUa/beDWpwoTurouW3do247CfoYcOGiTWBcHx9vmmKXFNBCIelp43aRFHdeN7mtm++1voW5LZGPYecxDJIYLn7BpSy2dRFeahRbyrv0+Ao2ahZta+BLXZELhyPc8NHnXZZQNxl35yEZb/fUW/rPL/FoNZMf69ID5GCRE8NgA6F6WQjo3BhOg7ySO1HbPTiLySBdxdYdjlr9fCUVsVUb9zPJwCydn2FDMjjYI3k7arFsHi4WaZzeKLSCxpwP5xSyhiYs6HJr03cj0OzSgXjOIj2S0+ZNGda16cyVe/cbQUpf0UVslhhtZDqnJkreYcQBGDcZPSPISArDf3cwp6os= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: b228a45c-243f-4d10-72cb-08da6b978e05 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2022 04:06:29.5176 (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: 96eVxerX0Ts6ZqRzjKx8GiNUYZTWoJ1VFy6pnbLireqwX+rcDbLDCK1tNk99h/onK6B3ZaGw1cUaXNTSxnup5gT++f/cGgf0oG58DDCIqno= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB3919 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 --- 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 Fri Jul 22 04:06:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12925947 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 581A6C433EF for ; Fri, 22 Jul 2022 04:07:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234235AbiGVEHD (ORCPT ); Fri, 22 Jul 2022 00:07:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233810AbiGVEGg (ORCPT ); Fri, 22 Jul 2022 00:06:36 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2097.outbound.protection.outlook.com [40.107.220.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5994F89A68; Thu, 21 Jul 2022 21:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lUosOEPcaBVLqJVMpfUfdbyWuczRsWu5yve+yE3I+ddc2oC6lbMAKOQ2Th1Nimug3EjF5u79oYinbQ8vxvBwZFKhDjqc6pU5SYhna083wXgPoFFewdCkM/OHEtxhTwRsmVu9WbE7J2Gr25N6R4vk5sdYnij5kz+hRqLJlZzP/9kCzsYVjxcngOqO7CJo1JO0ioy7vaqcKIsdpagxEoruq5FMzldjucDfADthKJEycuXzDJGWRiL4yi4N5bBiOZQk8yXR2rpNFy6YnZiXzrtwwIkDOUKyhrz41sdP/EthCLmeHOH6S/k4Srfg1OkaAO0/z6/iMEphqV5vIAFWt6olbw== 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=lu6RMTzrV2iPUkUz7g79Z4MPGsziOJiTMk1VVuxsbAA=; b=Ynr8Kc206ggVQbVudSZVui1WXLL+Zsm3ZXKqjai+vcNQzMFRutM4i85kwQxzIt2tgoJYHn8G8qTRoWf1zG8UuHYMM2TVPsSRQ01oMdOKxYLhsOeSggyHuUuRnCOoFvmw48ELmSDFdU/YG3VFDhiHcTLZpZi33aAF+EDznPdz6xv4xkgNYL8Nh6o+mJ9gD3bHE0rT0j94qDIR0YUSmJ7ylgZlA9SBWEQZT6Wyhe0xsq68HsbvN1sF6yShJZaHtf4oVHF05H/6Xqb5COtuwGr/FbxgB5y8OKYtN2Vzfc7ij+Cjya7swbEogYcgMkTAJnDACXkEJIG1isHpt0PTOaKB9Q== 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=lu6RMTzrV2iPUkUz7g79Z4MPGsziOJiTMk1VVuxsbAA=; b=bamQIURUMMx+CB3g05L0pR52FWLGhmypz3uaBKsk6JGVXVMfRtPMjx4QLOU8lKsRxlqbUiUQ87tz/aBesHAe4yow5r5kg8eOV1rnvJANzCK4rFt0mEfOa/LilywhqOOuzjEQBOfC68cl+teZg6GdKd0POlHUVppawCj2a2jd31Q= 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 MN2PR10MB3919.namprd10.prod.outlook.com (2603:10b6:208:1be::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.20; Fri, 22 Jul 2022 04:06:31 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912%7]) with mapi id 15.20.5438.023; Fri, 22 Jul 2022 04:06:31 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com Subject: [PATCH v14 mfd 7/9] resource: add define macro for register address resources Date: Thu, 21 Jul 2022 21:06:07 -0700 Message-Id: <20220722040609.91703-8-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722040609.91703-1-colin.foster@in-advantage.com> References: <20220722040609.91703-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR03CA0044.namprd03.prod.outlook.com (2603:10b6:303:8e::19) 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: 65d5e645-a174-44f4-93c9-08da6b978e69 X-MS-TrafficTypeDiagnostic: MN2PR10MB3919:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Dpt5e+vdcN9uBzsuyurJgeYF5PrmZ6Pu9xY6uDuR4K5FNRih3QKJJZ0DYa+lMFCogZh8uAAT4GiL7reE0P0tTtm/TI7ZA0otVyDBSReU959R7T5tBBknXX8pMVyvZqWHci0L43LlBlI4QZ+sZmdSPLIr5Iz4O/5rMfwGr9Rz0ndj/4kCdZ9BSVlzwNnM6UT1fZyT81gx6HHa0iC6V8QOBJQMnR1lNdMsiA5PHFkHwISuF+V9SQoKQljRY44kcZVtj7cn7K9Vokzuw9/nYT+eqMflLJ5KbAAC0W6ZMEZ+u4mr24vCEPUKhqoLo38PHwaB73vCCiU5dI6ZVulp2vmblUz9R4UtAk4/PZnwIGJXrgomiF7fYxxFyZ8OSGZX7sDJJlpAWvssQ87yEnz2uCodQnsRY2HyCXjJYi2tmYpILp7F2neoqHhjtK8A5dPNuh9i+Fx7VZbNl3ZAMx7sQ79vzhnZNT/BXXUnrXty9P0nx+e0auFEtvScFXBrnwA1qAuZWF6cGe3QlP8JTvqLewavJdg8ACr+o1MyUCS0iIC/j1MmabxCh5sFqzh6J5zH55o+ikIv1eyb6QI1zuutrDRzBELFAZ7cNkvFsvG1+RprA3V+hmWFX1Q4c9dBmH+ZaDJHerdoLx+i5HTdtTcXhAvwvvPlIM1yzP/L40nCs8xE0L5R5FKNIXbOc/0C/5oz3YwyPsWyB1bSauAEoZcbrTXZV5L8MLXHTfPW4eukRi0l1meDhHjXD/SaIydqhzgfrwO4ZyCMpxt68m+monrJCrHaG997cdFim/8vmPIv02IeSQk= 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)(346002)(376002)(136003)(396003)(39840400004)(36756003)(6506007)(2906002)(44832011)(41300700001)(52116002)(5660300002)(1076003)(66556008)(8676002)(8936002)(4326008)(66476007)(186003)(6486002)(478600001)(6666004)(6512007)(7416002)(26005)(316002)(86362001)(38100700002)(107886003)(2616005)(38350700002)(54906003)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: t4XJQGW40zfnxluBECvjAGE6aOMG5uH7kSczk9doB5hL00KjLCwoxt9ljPzSdXWRtE/2Ba9bQBsinD9XItJ7b2xhjBJRuLZaohVRWGuZSfMv9sxe9SwTAmA0SnSEYu7H/wNcz5DdFqKwapGcr2LGQ+UC43OLQ+rCMTnGcINa7h5XW/O1ls2niYRCSozcboXdWHsFfRW08c2S/8WEUsX4+dzPCMAsVdSaQLJwFLKiuOFRcQR8f9mHgrfYXkTXw70Md1Too0oTBcoTlMA87WN3IQLixqSxtvjoPNHKin7lw3J7UWQH6LMI/bORDzJscvIpMaUH0EpKESIb5cFpZRrjZq4eRvbzNzSpUe67QGhT+YEUutr/HCWXwHDcayjsGKk+oogdgk1eZpHZUpJAo/9NiJNzt4+31ZGjAYuQNDAUE/HEU/eQoyEAeqkqRExxMmnF7H/PoWG53Kwuq1TUPCVRqf1PDiM+5bGT3z6pzsNeD9wFVdwT4Y8Z+bIgyHGhwLTCnR1Fy0e1NPyk70JRI6/D2S7ZmaISjj5hnqTOjbFGvvu4SkPflWDqaX7yRBWNi9WJTnCWjnI1riB45yuQWzashB9nRf5YkeyEZC8m9tO1XMNyPhz9Agcy8T+qNJMiUtRHQjjX4f8Isa2aTD7VBclip9mjXRA92xSYtCSo1O3d4x9IE3EJkNLf597dy/+7GxX4ix2HX3DedTLTDLQMUJwQs9dFuphv8AVMJeRi/+MPGPqfztD9bAvl+3jQA+/brWumptCzgE4fcfZ/eL54p9uwb9/FrDCwztJNdTF7NOZxNhZ00sQH2L8EoGTqju/yrhn1MVY7cu00R9WUVx2Ofn3Ml96xDexc6+Cyr/K08S00NRYZp3dw8D090ZM7P4yHVmHz7uqwuiWArxjcFygBXmwau7zJXaPgHXYrltDNL2RN11TZp+uMfdPl1eUgouOWjcnofiZ0+QwpxFfYq/7zQy4MsfIxv7G1Mn+viOS/tuU3mITyegTEFgsYEv4EZlhlCvG67dvSTZp6nfkGtRJ7cXgXx1GxIKuDSJXXIsfWGQTPCtdQJywXmalOoJ6DPaXxa6AkHoPvuo1be4r6GHoqfbmntZ8vH2dPzqgYyzaTLp5HTG3BKZ4HSjfQz9ywa0DeLuT+ogSBAFLhBmJqRKDUQ0kSqd09GIdZtGngC5sGwvqDwdQ8/mYxd7AdoI6nfjItJ3unTUdhiMdM2/+ckAAlHYJ3CWrU2gGNAD6g62Av3YCSoQtJBaIe8aCLi09RreHB5oG94kPh8MF+3OqAvRhp2ouOGjo2A6MTEw4aEpyt8ItfHysg1jKJPZTcPRm5t69KE/mOvTA9x3V2KHQ1C3SExFL5uGNrNigfDFfPGPV8ahzkNuP9ECKgSw2yMinHe/ue0xokYOYHoipN/7cy+Fe68y/orQjmeguEg1vyRcI04c85NGBuhTTzd+lPBsefdoGUyHS88fboL24GDQUYp4bHpg9oUD8xAiSPED9h/BT2IfYkbjLapWT1Kgm71TrCvSkfXhceQWnSiWu9rcZNexj+1NY7grus11z+eWLY+IdhUbuTcj8IhSIoRIUm4zs09f1LBVhGufbLkJpNLWBbVmzUUrHymrBvy2mbfI/TDHCOTxO5QmA= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65d5e645-a174-44f4-93c9-08da6b978e69 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2022 04:06:30.1738 (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: v3XmfuXg1YwB0v6ThdGZl7Kd2pqC8v9cDOU5AfNcDJEZsuTJaFlw55QpqSRPzrifWozG1qO11lt9Vt7MsuW1LUtwJAffpskSBGk5c7p54AQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB3919 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 --- v14 * Add Reviewed tag --- include/linux/ioport.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index ec5f71f7135b..b0d09b6f2ecf 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -171,6 +171,11 @@ enum { #define DEFINE_RES_MEM(_start, _size) \ DEFINE_RES_MEM_NAMED((_start), (_size), NULL) +#define DEFINE_RES_REG_NAMED(_start, _size, _name) \ + DEFINE_RES_NAMED((_start), (_size), (_name), IORESOURCE_REG) +#define DEFINE_RES_REG(_start, _size) \ + DEFINE_RES_REG_NAMED((_start), (_size), NULL) + #define DEFINE_RES_IRQ_NAMED(_irq, _name) \ DEFINE_RES_NAMED((_irq), 1, (_name), IORESOURCE_IRQ) #define DEFINE_RES_IRQ(_irq) \ From patchwork Fri Jul 22 04:06:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12925948 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 6653EC43334 for ; Fri, 22 Jul 2022 04:07:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234245AbiGVEHG (ORCPT ); Fri, 22 Jul 2022 00:07:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233818AbiGVEGg (ORCPT ); Fri, 22 Jul 2022 00:06:36 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2112.outbound.protection.outlook.com [40.107.237.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE64189AAE; Thu, 21 Jul 2022 21:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yuc8GK7omvCMzJunvK4+yCe6+OR8GhxVgC1hShvtGGLAsKHjLliYHGDnecLS/sh5xuWImIJgnm1E5s9EM9/4FpyR0v2wLbPkYpPev83dqCwV7uV949dRXYktEgEK2Yu5XkkL6gaeV+m+tayTNM8QcMt0PnChhyr5wNb66OHm/SSIqyKUW3rBNi2Z62By5q0j5BAtkE/xAzWjJPqdwr2UtrfUp5bJs629t+YR1Qm2+IumaZJ2HfV50cM8b/KO8BR3sMJgDe51RKmZujYTxBE5DZ8APc1ulpFUOkfmjn1LEkSnwF0FmdeuCvD8QMVGOglh7oXBXVrOIcYCRsashtm6MA== 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=beoq/GP8KB6nG6SPJLuj6c3ukjQD3qlQL3Gw7qKxLGk=; b=RYAF0dksjNAQOhBYO6+AQq/vRowcCmPgefI1ksf0aiCQx2rGCVZOl9QEPOrJYoNC9cXuF2foIG+TgngwY/S5gaE4bttkGFznzaFKaUvvFgwIel+VLSPGZpxhzJerMfgMHIPwS9TRUyrUEbwHKYfWnhC49AdZIBFCbouM4q+91g0aNjK8Nim++VKhtPdDlLugd4nJA7JumEVm6vDNCHfSjSdS3RSM4VXjAbm7KQh6qR67cU8pbrt9iyguQV0FF77dWU+sTDk3E+1AIjwZNayC003I/WJeznjunM8kuCxbvv8McbwEgDYXNx7PbGPM3/MmeOpTyFCV2kaLZKzND1wJKg== 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=beoq/GP8KB6nG6SPJLuj6c3ukjQD3qlQL3Gw7qKxLGk=; b=jS7pc4UUQYqWiszPOBGsSsXeGP+O2X6H4AnCCUmlEfiamIu49E8Z01yJDl1vsmKbqAQUoX8TUGupdxz/GH+WRdBIYRHjLbnCQiyvlEyOKusNs6KVXxA7xECGXjSwyZryIzqF+upQ8E3UQHTzPx3Gk8Jf61UHDx7YrGIcbl9s8zk= 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 MN2PR10MB3919.namprd10.prod.outlook.com (2603:10b6:208:1be::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.20; Fri, 22 Jul 2022 04:06:31 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912%7]) with mapi id 15.20.5438.023; Fri, 22 Jul 2022 04:06:31 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com, Rob Herring Subject: [PATCH v14 mfd 8/9] dt-bindings: mfd: ocelot: add bindings for VSC7512 Date: Thu, 21 Jul 2022 21:06:08 -0700 Message-Id: <20220722040609.91703-9-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722040609.91703-1-colin.foster@in-advantage.com> References: <20220722040609.91703-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR03CA0044.namprd03.prod.outlook.com (2603:10b6:303:8e::19) 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: 5e40fadb-17ac-478c-dbbc-08da6b978ed4 X-MS-TrafficTypeDiagnostic: MN2PR10MB3919:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AM/UiqnCEJjCN/y5F4iLUsvD5uykBnloCVBdrJ63vUrJQ/ZyHi6DOzmdj7T4wdxFfKZtxbGv5ekrGQhzUIZIx5YYJDnJ9KidbidGa5UGx14dH4p25sy6h6AU417G/hCamVvNkoyV5Z/xICzQCnA6OpJsWmH2URX1l7dHuUpA9/yaJ+hXhtuxO8IlyIGwUAKqGd1+2dsvC/VeebEmeXeq2Il/AnSHOrfHozMDaPzEeRjP/sic/lN+W91mDlu3bB/F6e3oI73mKPdxTgHZJx7wuK5pJ46JsKHc9m39boynAyuKgh9W658B/vVxjAuqRsYjgl1NYRZ2Eevu+dZjNDBj3lcdJceHEatS6XDa83b3y9w+wbEuJ6sVG6+SRw4QflE5+fJmrt1fzQCuj0CdunwtdLN3LuK8f1piefKFmkam8sOoLFkx1tUEmDm/E8rA66r2kwb10DXISGai19+bezuSwhY+pWBm28NLeYtM7g5mgKfpOloJDEs4bu+Jjtpx4lLp6ngymW6iy+dBUWQFu6XXdfGDLrutppdPOZPn8OLnj5v8o325M35IPq804rFOXhXOPDcL93qInWrnJ4AcAaL8h8aEqoAiRN7zL6Rg+zJkiAx251nwA/0qN5quKVMcof7pAuLz/6IplYsMNfVNxI2j3dv3qPQSfhuIxb9Yte8GkhpN2DczcZ0uStND9e2vIPNUlZska0+mamk6IiGg/LyL+RAPX07/AKjz/q2nCTE1fQRbbMphY9huXof1gEq2iyDQk1J6cABkdKOMYZBI2CQrR5o12HhS4Q8N9nXlcU6GnzGeQN334+fJEI1nzGj6OYpj 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)(346002)(376002)(136003)(396003)(39840400004)(36756003)(6506007)(2906002)(44832011)(41300700001)(52116002)(5660300002)(1076003)(66556008)(8676002)(8936002)(4326008)(66476007)(186003)(6486002)(478600001)(6666004)(6512007)(7416002)(83380400001)(26005)(316002)(966005)(86362001)(38100700002)(2616005)(38350700002)(54906003)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /0OoZmXQfMhTVhnikpm2tzJncqkiSiUv/sCX/2InJ7HvGV1Z6zMpALPaJn/xwob3bLKX+3eU0qIUlHmoEGGfTlNblTPwRLJCFhSokPl9lr94RkkFxVCZLo6OErr3N6dHLQcCtoRzv4NVxbJfByjLXhX0XlVnsdNjUO/mBU1KYIEoibAwhspLbz2mEUW+lPEwALWWqm1m0WuRswx4rKvsT1SiSj0nUP77qRT4+HeGHpujQBTMOmnoH0HVpEZ73nZfQtQwqgOrwvJW3/gfDuupj2W9XWvrcILQcrTGDxHsMMa8fN59eJxpTqWMDvAaGL6XRK6teTMcLjPNKwwv1d7UmsF3KMFsPLSlReNzazd3Pq6loU8/CNGwnFca+gFIWi4naUs4GXQlZw7iWBozwYcBNkDomLnmGQiTsfSG69B9UYkqu8RoW5ndhsb2od3/GsM5+4OncnbpQ9oXibqQCgfiHKVal6J/ptdDYtnOLuxdNRUAGwMCa34BcvjKIenDye3fpZJr7Jj0rPOzKiSKoaXhMtf9OAJiV2vkd2eZjgSRceP+Ti7BXbIHET1nhbyAZ6k4wanZ7zwzhGvFCixExIc2R4nDQtmkPMVk4ZqTnDz9rJb7Lzqrg6tnk5nMK/WtvZyqrGd4ARTbUtIAhTrHYnIHvajAEBKidURoh2M8pHXALh6ODR0YVTfxyIRr7rUpWGzq2JSl9ZT1KLxA92BJq+FxDtc0Q+Fmh8REKauZuJvsqnpfXbXVQXme1xBPybs5tENyje45EZyStR1mPU1+3ijy5YdF03pM6TeWdWAqHmBAMmYkPswsjWoPADa1w2ZZ7jG9yc7qqi6aszQuIOMUYTGM0KjbPUrhJ+k9GpTBfqIAsBMDy3LuJxdmxUS1OQ6xFBN+2vhKslmqyvY44JVZXtLMtUCqTAROID4eUc875yE3Okz3niGvErqON/0ZrNtEgZmhn8aL4NEahi0s88NhjXYKYdVZCK8u6f1qggFurp+OZW/irTwyNEWx8ehsxcVUKUih7COTx5rsCjPQcQj6/YQsX0dA5t7vPw3A83e5qhh09udyHRrhiezPP3OyM6t0kSpyIUgXWrxWdHbDpqW4Wh0VMNrZMt4HZ0id76BOF9FDzrs2wFl2jNCqGASfxsr5UC7hCEWJBMIqvdzOcNfFQCuAGZSaLl/2mgmYdlTu6gYTqTSHeSGAtDIR3j/f1lrAEGIKgXLVxZMD29zCzLqeAUPL2iABzid6uST57ScJRTA7UpRwlvxGPpYyRVnWfspRTvdmXM/XycHEmdKfdDj+rb27GifPfQjZUNCCs10PPQPA/4XV0ivfsg13u3nrKRbrU3+YO6buBj6rd5zJnhNzNsHa9NSBowjxfCv1eyNEMu5uVGivuvAYjCWdAVwircfg4iwAXsWiBE96U+E0XKIKA3oqbzQ19Y+YWrm2XMa0xIAPVXMVLgYJvaSx26cCa21qyO4Eov3FmG/98HX1J0sMnQV5uElBWIS45uXjSeoWz9RBBt8v4LhaEYQkqBlQIxmmIKQgx2FEzOE/CPYXbgcC+nZ8Hxnn8XDVz9WluHoaLSD0kJuQ5nw4AXi//926KbqNSMYy1reSAe7MFx73YlD/xOlVYNN8CUVpbS0/PH0PL+nz7NI= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e40fadb-17ac-478c-dbbc-08da6b978ed4 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2022 04:06:30.8769 (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: G9x6x9JrRUcnGBRX7VkbBK/no5T6yQMBkjz5wUI8BHsxDfGweiXgNZVKt+oFJsm/bPfKIRf5Pkatu8tdexYBBRqVCF1oLQCFlyi1nxsIqdo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB3919 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 --- v14 * Add Vladimir Reviewed tag --- .../devicetree/bindings/mfd/mscc,ocelot.yaml | 160 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 161 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml diff --git a/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml b/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml new file mode 100644 index 000000000000..8bf45a5673a4 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml @@ -0,0 +1,160 @@ +# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */ +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/mscc,ocelot.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Ocelot Externally-Controlled Ethernet Switch + +maintainers: + - Colin Foster + +description: | + The Ocelot ethernet switch family contains chips that have an internal CPU + (VSC7513, VSC7514) and chips that don't (VSC7511, VSC7512). All switches have + the option to be controlled externally, which is the purpose of this driver. + + The switch family is a multi-port networking switch that supports many + interfaces. Additionally, the device can perform pin control, MDIO buses, and + external GPIO expanders. + +properties: + compatible: + enum: + - mscc,vsc7512 + + reg: + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 1 + + spi-max-frequency: + maxItems: 1 + +patternProperties: + "^pinctrl@[0-9a-f]+$": + type: object + $ref: /schemas/pinctrl/mscc,ocelot-pinctrl.yaml + + "^gpio@[0-9a-f]+$": + type: object + $ref: /schemas/pinctrl/microchip,sparx5-sgpio.yaml + properties: + compatible: + enum: + - mscc,ocelot-sgpio + + "^mdio@[0-9a-f]+$": + type: object + $ref: /schemas/net/mscc,miim.yaml + properties: + compatible: + enum: + - mscc,ocelot-miim + +required: + - compatible + - reg + - '#address-cells' + - '#size-cells' + - spi-max-frequency + +additionalProperties: false + +examples: + - | + ocelot_clock: ocelot-clock { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <125000000>; + }; + + spi { + #address-cells = <1>; + #size-cells = <0>; + + soc@0 { + compatible = "mscc,vsc7512"; + spi-max-frequency = <2500000>; + reg = <0>; + #address-cells = <1>; + #size-cells = <1>; + + mdio@7107009c { + compatible = "mscc,ocelot-miim"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x7107009c 0x24>; + + sw_phy0: ethernet-phy@0 { + reg = <0x0>; + }; + }; + + mdio@710700c0 { + compatible = "mscc,ocelot-miim"; + pinctrl-names = "default"; + pinctrl-0 = <&miim1_pins>; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x710700c0 0x24>; + + sw_phy4: ethernet-phy@4 { + reg = <0x4>; + }; + }; + + gpio: pinctrl@71070034 { + compatible = "mscc,ocelot-pinctrl"; + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&gpio 0 0 22>; + reg = <0x71070034 0x6c>; + + sgpio_pins: sgpio-pins { + pins = "GPIO_0", "GPIO_1", "GPIO_2", "GPIO_3"; + function = "sg0"; + }; + + miim1_pins: miim1-pins { + pins = "GPIO_14", "GPIO_15"; + function = "miim"; + }; + }; + + gpio@710700f8 { + compatible = "mscc,ocelot-sgpio"; + #address-cells = <1>; + #size-cells = <0>; + bus-frequency = <12500000>; + clocks = <&ocelot_clock>; + microchip,sgpio-port-ranges = <0 15>; + pinctrl-names = "default"; + pinctrl-0 = <&sgpio_pins>; + reg = <0x710700f8 0x100>; + + sgpio_in0: gpio@0 { + compatible = "microchip,sparx5-sgpio-bank"; + reg = <0>; + gpio-controller; + #gpio-cells = <3>; + ngpios = <64>; + }; + + sgpio_out1: gpio@1 { + compatible = "microchip,sparx5-sgpio-bank"; + reg = <1>; + gpio-controller; + #gpio-cells = <3>; + ngpios = <64>; + }; + }; + }; + }; + +... + diff --git a/MAINTAINERS b/MAINTAINERS index f781caceeb38..5e798c42fa08 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14470,6 +14470,7 @@ F: tools/testing/selftests/drivers/net/ocelot/* OCELOT EXTERNAL SWITCH CONTROL M: Colin Foster S: Supported +F: Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml F: include/linux/mfd/ocelot.h OCXL (Open Coherent Accelerator Processor Interface OpenCAPI) DRIVER From patchwork Fri Jul 22 04:06:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12925949 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 70A14C433EF for ; Fri, 22 Jul 2022 04:07:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229611AbiGVEHI (ORCPT ); Fri, 22 Jul 2022 00:07:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233751AbiGVEGi (ORCPT ); Fri, 22 Jul 2022 00:06:38 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2097.outbound.protection.outlook.com [40.107.220.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1636089AB7; Thu, 21 Jul 2022 21:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z+3CR78DYz0pHFkEOX+/7DLo6nWg2ZO/YP2YTeBA7GPSCCVm0h/SI9H0c4KbWr6ZiK71XQGQboGtcfblwLVWLwOLsUanh/51IDLt/HnBA+wmYFnv8oPTGMZc4LVJg634pJ2E//trP20W13MJi285CuLKKtUpe3ItJ6BS60OquUMufV7IfXXTNPMCHee+gnEBbLyxSO69zWPVwv7xx4e67HOUWPt2ndzm9/9milB9ASU10bB41mHW6T+wNhyOapjtFKzIN/nYBMzdpUZV5yI2b+FxTHRPcYguspx8tmBWMteqVhcsxuImVZW4YT4mfgVBtUV1AFCi1ZqcJ5igoZOEUw== 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=vHFrdn/M+g08yWr8+/MCy+3wU6jJGI82IlpyxopJ+sM=; b=YlGgmJsLkper2DKW57UsrcQVb4lOKS40xsSb13bBWopXqYXWX85fAerG/7qjuUvu6CoRXEHkALEAZwiINtbcG6WyFeEgVN6lAlmxJsF5OOBTPHee6loYvEFGaVk+ysnFNOjFYGgodzxaVjyEAtmX2GXygALjffvC/UdGuaxJuGVjJtXwK7v2sTUXT0AfL6bo+/3hDdxD4Fmu7qZ+Q4x5Hbb337AgNt3y7gjoIYcvnO7LHRdIr3awRn2XbT/TAeAYgOnwKDUe7A0e8yvX6M+ekYJqCFZdtRHZoqBS6LDUfB9FznkeYKvxFT2cJT1lTUqWA8zXPtF6f1XAkDcxaeXVpg== 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=vHFrdn/M+g08yWr8+/MCy+3wU6jJGI82IlpyxopJ+sM=; b=pWLsjVzjUFSAFTgBTG2M2HVtB3Rp/S580kUswVftm0RogykQiICO7X5JcFiGmAsFTGihvfsBQObX5hRzHOksLNuYtPyqueGft+wCYTR1ANEhosiusj4hXhmwpp/PWyfXHrTlrhHNoZM7XIoIdCbNfHeZRqFWwF1DDQ5MFvhNi7M= 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 MN2PR10MB3919.namprd10.prod.outlook.com (2603:10b6:208:1be::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.20; Fri, 22 Jul 2022 04:06:32 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::7451:2903:45de:3912%7]) with mapi id 15.20.5438.023; Fri, 22 Jul 2022 04:06:32 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Terry Bowman , Vladimir Oltean , Wolfram Sang , Andy Shevchenko , UNGLinuxDriver@microchip.com, Steen Hegelund , Lars Povlsen , Linus Walleij , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Russell King , Heiner Kallweit , Andrew Lunn , Krzysztof Kozlowski , Rob Herring , Lee Jones , katie.morris@in-advantage.com Subject: [PATCH v14 mfd 9/9] mfd: ocelot: add support for the vsc7512 chip via spi Date: Thu, 21 Jul 2022 21:06:09 -0700 Message-Id: <20220722040609.91703-10-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722040609.91703-1-colin.foster@in-advantage.com> References: <20220722040609.91703-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR03CA0044.namprd03.prod.outlook.com (2603:10b6:303:8e::19) 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: 5e2c11b3-876f-466a-d5c3-08da6b978f31 X-MS-TrafficTypeDiagnostic: MN2PR10MB3919:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X5jrsmK5jK3SM2jPK6IduOZZe/3JkNoemOV3mbF5HvUVMcWp46G5aY4gxUjtKU5zzTLlxKMjIbagUEhi5C/RvF38PuWdBtk0i4nCL+a8gm5Kxl/Cn6T/dlNcSauMPiKgT5mQBEK/0t4Yvs6B2UJdVwfOluThA+VIoU0RFBc7lPv5TL7EClmHsfTPgg7u+0YbaVueWO1M+DaUW+lOJob2Qa7MnHa84LOOm1mJvUhCkfa6w6HrNFhgrs1G523WnVgTX8Y3hLocbL+i3zz3TTE/vRdgA0g9k+1DqQZNb3mbkHhvl97Rx/Yi8IBAEJWx6WBMVi9FxwsKh086UXYpUD7BJPDJhP3SKoVsmeSpCHHtIPr+/NERrSGOvJnzg6AmV3tECHE1CWyJcHjAFQlmk9WUz4c2ZIJU83AubAAm2VpngirqIfMDEz2x3YG07XiTsJvkV4cWhPQZcD2g7dsllHb+3gwV1uno/5zYEcBvFCg81+T4eoDuMYQhfNybqqR6ACLeiy5VJaJHTYlGg2x1+eUYcUkm+5hilsN6haWAZ2BjC2zEsmJOmuwglrmoTr/MglNspBd2ZhF3IJCeFzw+19RzRvm3lNP/Gj3TUJ0t5sGtUHeNYZl8H8gRdWRbrpHt9UOR38EojunB7zBaJR/GHlPedng8wH9TOD1hfIEhcOdmL9/DLNa/vnG4/m2ueO3gZyJdFi1J34mJUIarw9rBu1zFt8w6cALOASnKIVG8l3oWk4BwvOj2SQ4nIuEEzoucoivk/GPS/FNkXgKw6XldMkv9qLHTr3HBmqkiFBTZRvgi6H8= 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)(346002)(376002)(136003)(396003)(39840400004)(36756003)(6506007)(2906002)(44832011)(41300700001)(52116002)(5660300002)(1076003)(66556008)(8676002)(8936002)(4326008)(30864003)(66476007)(186003)(6486002)(478600001)(6666004)(6512007)(7416002)(83380400001)(26005)(316002)(86362001)(38100700002)(107886003)(2616005)(38350700002)(54906003)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: as7BbMdUYqKjIrFxWjK9W+qq0GoiRgtrgiG/3c81FElu/miDoiFFtf0tDY0UVhurT0cQX8vx5E+r4a6HsNvi7CcunZXvuaoJbJCZVoC7nGuhsyF1DZ/one+jP+iN8+HKlI0Zqyuokhu189CcSq7UONNfCiJNnxiNSoLvMpNOnBturZ18e40UhwXeOtcfAWesBBiV4m/hiQP10CsMEwy0mtPaImp71vhONbuuCEEII/gRDWNiA0uF6SnknLzAmvXlyIW3TGDivt9Z7bZFn28i6EAV7KJ9rCFkI8C4fbFCeA7k7npiRTarsRu3Dtu1fAHNlTc62qoOzWbuNdnafL3VmO4GZ2jJPg2SCLz0YjVe4D49Ze99g+Pw/qTeBbIPll3+uHxtldA9YD9Ejy8ybgZ8cwrh/UrMeoay2xU72ziQOz9OS5VViSmadxhB8jx7woj6NL1RzDp3a82flxFj6d3kHEl6PgGg3jnSs4fRaZWXZjZKDbxBgmX0p5TRQASTLsKdRT2gBtXkIVr+0VhkeMaFY5a4OTI92Z6UZvUH78gD9FJOBdX3Fo+3WwbEFzoRTr760TrQ+324svn9UVxdHtcfDeFHCSxj9/aCmTyyChPoro1TKTvemlqMGbyKuxHO7PEOZZJl+6A938aeKLTRwAg2wIdGEKLOxoafnj/UMXiX42R5zcKfxSYUoUhFu9tKrDY4ilKXFmfVR8L/5P7OHDl1ZpcuH8Z8l3QF3WAPXRIARtJGDwucjKEqN15XbXAoUu3icowl5ypkqs/QtD7H+lW0xXbllVVeurth8uWvtxGzSl+kUi/PXTe0qHkV3QHvMeaJGGlEL+gxoKgz2OyJOPY44zaeMdZbZCAMq4zZNv3acy7aHnGpF8KYgefzBA/zpcFaSoFYGijuDzqm2F2sOpzYfLjd0OJ4W0rEMmOgqn4zzh3MtUKRZ16YETXaDGgGYr8pj4Gzw27omxyThpu2N7+nrditukL96Ai6QtYaX5uuYjPoEdfcnJc3pG522to6W4GBYLOtAixouICsP9F2oazBnGXPKCqLgRN4n2f04s6uzayZ6Mqv0rgAWsCRF9dZX9LgyVb+GV6kYXnsavx5eFLVuEWMBbXsM7E41ukPWWHaGZBt0TZokr+5MqBo2YZc0hcLrXGFZOZeVjBIMak2c3DDmWi/Kqf6tIFWVytVTyLzGqsqcAKshSk23B631Q9hZL1es6FyfCRCbZz5BXSeCs/RX+cR/wHODf+FpTyD33OMge3WKquuTgGywF80APii/FjNxXBu8ciJ28AmFwR5fwdODPBc6vEoANN5RaCzCneRf279cLlL88WXWE4iu9jqRXLWJcFXgFXLon9q4etaxSl/gJiJV1eGxnXLvJFFirXYW00J0Lr1aWy+Ic0v5u8+vBHZjKJI628E89eUaISE8yNd5fHBXEzkA/dAii6MOkpajQ476seeBZ6h5NZKxQc1ZpNAmUC7m3GoC/eZU0ujq463J7dyGz+6izICE564TVCu4Wnt0ghVlANJMnCy9CvN9CLinG3csMl5DOT7uhqb3pMfiC62oUVZpdieELka8MxAu5zRLNmpcDb2nFlQ5WBKZk0/Rhi6XV/rulzFGdJsSpHMin5dLK/NoIsRCKvpm5q6UpU= X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e2c11b3-876f-466a-d5c3-08da6b978f31 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2022 04:06:31.5019 (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: qeQ+i4Grr9fNAu+b2VYq+OaCw8kVExRashd+3a0smeH3EDUzlvwgTKIb3g60D+I3GTP1oSBFOKs6lv/3bGp7KfCUfjetOW61E32u6z3RwpE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR10MB3919 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 --- v14 * Add Reviewed tag * Copyright ranges are now "2021-2022" * 100-char width applied instead of 80 * Remove invalid dev_err_probe return * Remove "spi" and "dev" elements from ocelot_ddata struct. Since "dev" is available throughout, determine "ddata" and "spi" from there instead of keeping separate references. * Add header guard in drivers/mfd/ocelot.h * Document ocelot_ddata struct --- MAINTAINERS | 1 + drivers/mfd/Kconfig | 21 +++ drivers/mfd/Makefile | 3 + drivers/mfd/ocelot-core.c | 157 ++++++++++++++++++++ drivers/mfd/ocelot-spi.c | 304 ++++++++++++++++++++++++++++++++++++++ drivers/mfd/ocelot.h | 53 +++++++ 6 files changed, 539 insertions(+) create mode 100644 drivers/mfd/ocelot-core.c create mode 100644 drivers/mfd/ocelot-spi.c create mode 100644 drivers/mfd/ocelot.h diff --git a/MAINTAINERS b/MAINTAINERS index 5e798c42fa08..e3299677cd4a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14471,6 +14471,7 @@ OCELOT EXTERNAL SWITCH CONTROL M: Colin Foster S: Supported F: Documentation/devicetree/bindings/mfd/mscc,ocelot.yaml +F: drivers/mfd/ocelot* F: include/linux/mfd/ocelot.h OCXL (Open Coherent Accelerator Processor Interface OpenCAPI) DRIVER diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 3b59456f5545..0ef433d170dc 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -962,6 +962,27 @@ config MFD_MENF21BMC This driver can also be built as a module. If so the module will be called menf21bmc. +config MFD_OCELOT + tristate "Microsemi Ocelot External Control Support" + depends on SPI_MASTER + select MFD_CORE + select REGMAP_SPI + help + Ocelot is a family of networking chips that support multiple ethernet + and fibre interfaces. In addition to networking, they contain several + other functions, including pinctrl, MDIO, and communication with + external chips. While some chips have an internal processor capable of + running an OS, others don't. All chips can be controlled externally + through different interfaces, including SPI, I2C, and PCIe. + + Say yes here to add support for Ocelot chips (VSC7511, VSC7512, + VSC7513, VSC7514) controlled externally. + + To compile this driver as a module, choose M here: the module will be + called ocelot-soc. + + If unsure, say N. + config EZX_PCAP bool "Motorola EZXPCAP Support" depends on SPI_MASTER diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 858cacf659d6..0004b7e86220 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -120,6 +120,9 @@ obj-$(CONFIG_MFD_MC13XXX_I2C) += mc13xxx-i2c.o obj-$(CONFIG_MFD_CORE) += mfd-core.o +ocelot-soc-objs := ocelot-core.o ocelot-spi.o +obj-$(CONFIG_MFD_OCELOT) += ocelot-soc.o + obj-$(CONFIG_EZX_PCAP) += ezx-pcap.o obj-$(CONFIG_MFD_CPCAP) += motorola-cpcap.o diff --git a/drivers/mfd/ocelot-core.c b/drivers/mfd/ocelot-core.c new file mode 100644 index 000000000000..579dcd590d9a --- /dev/null +++ b/drivers/mfd/ocelot-core.c @@ -0,0 +1,157 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Core driver for the Ocelot chip family. + * + * The VSC7511, 7512, 7513, and 7514 can be controlled internally via an + * on-chip MIPS processor, or externally via SPI, I2C, PCIe. This core driver is + * intended to be the bus-agnostic glue between, for example, the SPI bus and + * the child devices. + * + * Copyright 2021-2022 Innovative Advantage Inc. + * + * Author: Colin Foster + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include "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 0x24 + +#define VSC7512_PHY_RES_START 0x710700f0 +#define VSC7512_PHY_RES_SIZE 0x4 + +#define VSC7512_GPIO_RES_START 0x71070034 +#define VSC7512_GPIO_RES_SIZE 0x6c + +#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; + + ret = readx_poll_timeout(ocelot_gcb_chip_rst_status, ddata, val, !val, + VSC7512_GCB_RST_SLEEP_US, VSC7512_GCB_RST_TIMEOUT_US); + return ret; +} +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..a08e596d1fa9 --- /dev/null +++ b/drivers/mfd/ocelot-spi.c @@ -0,0 +1,304 @@ +// 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 "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 tx, padding, rx; + struct device *dev = context; + struct ocelot_ddata *ddata; + struct spi_device *spi; + struct spi_message msg; + + ddata = dev_get_drvdata(dev); + spi = to_spi_device(dev); + + spi_message_init(&msg); + + memset(&tx, 0, sizeof(tx)); + + tx.tx_buf = reg; + tx.len = reg_size; + + spi_message_add_tail(&tx, &msg); + + if (ddata->spi_padding_bytes) { + memset(&padding, 0, sizeof(padding)); + + padding.len = ddata->spi_padding_bytes; + padding.tx_buf = ddata->dummy_buf; + padding.dummy_data = 1; + + spi_message_add_tail(&padding, &msg); + } + + memset(&rx, 0, sizeof(rx)); + rx.rx_buf = val; + rx.len = val_size; + + spi_message_add_tail(&rx, &msg); + + 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; + + spi = to_spi_device(dev); + + return spi_write(spi, data, count); +} + +static const struct regmap_bus ocelot_spi_regmap_bus = { + .write = ocelot_spi_regmap_bus_write, + .read = ocelot_spi_regmap_bus_read, +}; + +struct regmap *ocelot_spi_init_regmap(struct device *dev, const struct resource *res) +{ + struct regmap_config regmap_config; + + memcpy(®map_config, &ocelot_spi_regmap_config, sizeof(regmap_config)); + + regmap_config.name = res->name; + regmap_config.max_register = res->end - res->start; + regmap_config.reg_base = res->start; + + return devm_regmap_init(dev, &ocelot_spi_regmap_bus, dev, ®map_config); +} +EXPORT_SYMBOL_NS(ocelot_spi_init_regmap, MFD_OCELOT_SPI); + +static int ocelot_spi_probe(struct spi_device *spi) +{ + struct device *dev = &spi->dev; + struct ocelot_ddata *ddata; + struct regmap *r; + int err; + + ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); + if (!ddata) + return -ENOMEM; + + spi_set_drvdata(spi, ddata); + + if (spi->max_speed_hz <= 500000) { + ddata->spi_padding_bytes = 0; + } else { + /* + * Calculation taken from the manual for IF_CFGSTAT:IF_CFG. + * Register access time is 1us, so we need to configure and send + * out enough padding bytes between the read request and data + * transmission that lasts at least 1 microsecond. + */ + ddata->spi_padding_bytes = 1 + (spi->max_speed_hz / 1000000 + 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 < 0) + 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 < 0) + 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..71eb61dd91e2 --- /dev/null +++ b/drivers/mfd/ocelot.h @@ -0,0 +1,53 @@ +/* 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