From patchwork Fri Jun 10 17:56:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 581204 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 B24D8C43334 for ; Fri, 10 Jun 2022 17:57:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349850AbiFJR5R (ORCPT ); Fri, 10 Jun 2022 13:57:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349601AbiFJR5P (ORCPT ); Fri, 10 Jun 2022 13:57:15 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2121.outbound.protection.outlook.com [40.107.223.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0C8A7890F; Fri, 10 Jun 2022 10:57:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mvI3dZT8pGq9dzifhxpoKeTvZw3Jkl2NcqCHqaKksgs/MCc/dDD83/aMWRDNNK7iCL03iWHfNQ6tvXg4/yVCWWoaS9hAnGlox5wvyQmCkA+rNMYb2Hi5SP2r4YCt78+C0Zz2+ECkze1kGynTTZ4w5G2Xfnt7J+C5x5TrK6U5m029yD66DqZtenNFOGoUWf9dh/wtm6yYdGWmqH6cDuM3kTdccWrMt7kmE7M7iebOp8w51oNkLu2op9kUo0wmdyOMyQYKcKZKALxtD29JyUmThtpI7bTFVKWkFvBKTGJeCHOYyJUs07WuieaV83HRW1w54BQcpKRMlZyNHrA+6h88QQ== 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=e34s1zcWVZ7Jns/59LxiobrgeUjv+/YLeiuNdoxRi/o=; b=iXp5wy739kRbtmSo2WSGU+Oz7chLU+8H9ig7UJ9uBnMJR74UX/VV6G+2ochIY32NpsrG/UvSsTSUDv2rqZi945CaFlrvplhXQHz6kb27o0U0Bc1+wivlqkbVBQC5sRcDd4KUEFysVGC+fYj5+CGD5jihKHkAd8gN6FiYCrCk8qKeBFbn5BoetAm7QMt4L7JmceVG0QhAiZMv5bmcs8V6Ey6oYtf37+5Hka8EoTuxg2PHROjXd934hayxHyBSuboCZlb4DKMslc9Cz/tf0QcVgvBGFgTEqPXhUD1Ut4o/zvhoan+9xlxEHHgEs8Mg2kjHgfx0AGFL8UoDo9p7qc/AYA== 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=e34s1zcWVZ7Jns/59LxiobrgeUjv+/YLeiuNdoxRi/o=; b=kukaOP6BeZV/rIGOVcQHW25g/v4rGSONA+sZR3yCFtK5O0kbdoRNJX9zrZVhJK9Go0+oz6obKmsWdSHE4v97ghp6aXwms+ALx9Scp/tPrzaF20AF9lo+CkqzSzHVquGV4ruYBoPkmQk51gh2SWMpgZH6mSSDBYCGep5wuxktGZA= 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 DM6PR10MB3356.namprd10.prod.outlook.com (2603:10b6:5:1a9::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.15; Fri, 10 Jun 2022 17:57:07 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b8c0:76a2:4c89:d10f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::b8c0:76a2:4c89:d10f%7]) with mapi id 15.20.5332.014; Fri, 10 Jun 2022 17:57:07 +0000 From: Colin Foster To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Cc: Vladimir Oltean , Lee Jones , Rob Herring , Krzysztof Kozlowski , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lars Povlsen , Steen Hegelund , UNGLinuxDriver@microchip.com, Linus Walleij , Wolfram Sang , Terry Bowman , Andy Shevchenko Subject: [PATCH v9 net-next 2/7] net: mdio: mscc-miim: add ability to be used in a non-mmio configuration Date: Fri, 10 Jun 2022 10:56:50 -0700 Message-Id: <20220610175655.776153-3-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610175655.776153-1-colin.foster@in-advantage.com> References: <20220610175655.776153-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR19CA0070.namprd19.prod.outlook.com (2603:10b6:300:94::32) 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: 2470f541-d1a1-4cd9-25c4-08da4b0aa222 X-MS-TrafficTypeDiagnostic: DM6PR10MB3356:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IaoFepCuhMwSoX8AWIJAFzAlttPcByPHyraEbFxMr3uNt1D7WHxMBANN9qoGXcldc3/CoyA8oef+gGwuigdjLIa5bhTq6u3PbfmbsJTCBDd/NZJ8pR1bGq5BYaVhG7e6bWc8VwJhiNybekgp4TjKuXSCpaBJBnLElLl1ip/eP2NSGDPmpJ9GO/r09Ne0MEg20r4e+ZfWU+tlZnPlFx+fyqUgacjwQNTcoouHUdFi6T+FYUYB5gwU1LMky47fucLih0KyIuhbOmr1MPaCeQc17DSGklOM45ZKB/OZz3IeNcpUnnzFjKbcC+NyMXpB4KxgD3eaxJshbuWgQJcBc8LX4wgkoKv3zou+cqqLoRfyeF8qAsBCDgXjuxaqtx+TcoCTyKDozVS+UWnZEU0150V1wLt7a4dKn+lRMpYx8AmZzu8vUW4yImMwLqJXFEx2klyswA6vQx6mepWXcZhnpOevrNj7mtodxJZHPb5ZNxNjlftwHO7uNG0s3daKyCsE/uakHQO6ND7RXRP5lNe9MdyjDCMFjpiV9/DSfMMdBp0GpdsJO/AQUYM5S1VA3p6iV63YpZ4f3Ae859vVGz7CT0cJx6E0eZJTdqVuZZkkHtkqn/OftKsS9z1Vod1InuXALNwBWhYoTyPLxCxeKBvt4e6htIWogblqVNa1w5xn43VV3P5wz4+tkD0cRTaD5meYREq0PUItvsNXaEgiyVOsgGS15g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2351.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(346002)(366004)(396003)(136003)(39830400003)(1076003)(54906003)(316002)(4326008)(52116002)(8676002)(2616005)(86362001)(508600001)(6512007)(26005)(6506007)(6666004)(41300700001)(6486002)(186003)(83380400001)(2906002)(38350700002)(44832011)(8936002)(36756003)(38100700002)(66556008)(66946007)(66476007)(7416002)(5660300002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-M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kQ0y1oU/dvzBA8H0QaXzTZGkgqENkmKGmpvmNRTrvzN+shL1SeGeg0AbKMxq3sb7I6mfy6Kt5UZvPY8aFSTHr5m54k6UqrW+1vYajkxK86D+JdUBM08ktonLcSxTloDkVNyORViqsrXFYCC5H+WYVcjyWmwQ6dWz+Fh/E3h6czfQ/IxbstpDHq9qEZOH8GLl9WpYV29OLBZ8U8kwO+1Pw9LS+3EffgT0MM/kDdex9ZYS2qHNvzFLfsK2ZbQvN6ucNMntB1Sffu7avGI1begY2UlKCuHc2iP7ZUPVHLLeXg/yXmjBM1TZBhscQz6nNweCLK48CVjsVFqdjdq73dPNXNmnM71OBbm97PQsUxVlJWygAgIVMbhSEP1DYCpyr8+HgYENL4JMTioUeYngdL2q5pVMvBvGB+GpodnxqE1rWj7vROLLKSGu0l8a4ZpQuyI+rRNFWNsb2cOaFu37u29US2qXIilmK+WhdCk169YnwixuHheaTpJtlZKkkZFhsTcRWqym2chqLJU1yHcNqRZ1cdR/qQXPxM5bUmvZGKDUFiGs4Fnqw+8UnsVNi4Imn1ZtsIt8Rh9n/N0UlRQNA/OY1yTcQ3wgpuZ+RlKShggDtOZfRbb4GFm5/XBzlErN9++x8yXO7LovWu/uQ4pxWyZfWVZDbnDnsqh4lHtzNFCx6/F6F9ES8Y7A5vvn0Z3gXu8XvKF1oT2 X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2470f541-d1a1-4cd9-25c4-08da4b0aa222 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2022 17:57:07.1218 (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: W4927oz8y/doqkA1Qv9Ls85hhw/jWi0cBii387Fe6sp7o2tof1smNILAIXXTjOv8ps3+LMLSCr13K/he8iw5SNt9sGG2ePnrisksnpRAlfE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR10MB3356 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.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 --- drivers/net/mdio/mdio-mscc-miim.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/net/mdio/mdio-mscc-miim.c b/drivers/net/mdio/mdio-mscc-miim.c index 08541007b18a..cd89a313cf82 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,43 +271,31 @@ 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); - + ocelot_platform_init_regmap_from_resource(pdev, 0, &mii_regmap, NULL, + &mscc_miim_regmap_config); if (IS_ERR(mii_regmap)) { dev_err(dev, "Unable to create MIIM regmap\n"); return PTR_ERR(mii_regmap); } /* This resource is optional */ - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + ocelot_platform_init_regmap_from_resource(pdev, 1, &phy_regmap, &res, + &mscc_miim_phy_regmap_config); 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); } + } else { + phy_regmap = NULL; } ret = mscc_miim_setup(dev, &bus, "mscc_miim", mii_regmap, 0);