From patchwork Sun May 8 18:53: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: 12842510 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 A6AA3C4332F for ; Sun, 8 May 2022 19:02:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238180AbiEHTF4 (ORCPT ); Sun, 8 May 2022 15:05:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346948AbiEHS53 (ORCPT ); Sun, 8 May 2022 14:57:29 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2101.outbound.protection.outlook.com [40.107.223.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB840BC08; Sun, 8 May 2022 11:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fsCrc7atXfXe3UZollBWUE9ZUsbNivGESZlrOYrtYke6jeEub8xR/Zum2HhjN6kLnh1z3/5+FIpDuaWsFjsQtldfVCVvGpLpnQmFgXKLhjr11G0PNOzmXp0kwH6zupxJeWQ2/o3xjQKX9brVVheu4KzZcm0v6TfYcuaAH2OK1TifxWMcsl0bL/tFHPoIpunAFQnORWnPXXBY+hCLRyFhISzWzcBAwZKw+igFbrCk9NW3cPKrcJnaf1kocO0fJmLuRFzbX/ten+bmrFdulcayBZ5AcZ11I+hByz4hU1NJBTufdMhnM6UAnFNCbKveggUwBET9KjyCwdPnbp6H2f+Jeg== 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=iCB4Vx2TDjKwAlu4m1e0KeGA5ZfMHTw0YwLUoW/ut2U=; b=WBrd46BW89+A5nK+af3Mi3o8nMVW8g4XmIzgYKfcF+t3oUm/S58vq3eiPRA84OXA6YNH7L2oDM3rX/69PwJf5JJrCjxiO3jC6PkIH29G37JrGcIvjbkqOVHL1GdPVBkJsNZO2Uo8iq7aQS2WnF1iXBRhCw7+1eLcPdoBN/Y1MjA+rSPSMbWHA2qdr2FDdtpq9kY8I78faOL4+zCjtgRQEOrPjo4P0S5TOMCJPXSQKecd+Z65i8/TmtTvmGTfwnoyCSEd2C4nFb1VyUyKg7sv3DIacLcr4c/qLexTPL21X0JUQcm3/BH/XSaQmbSARKbSpI+6B4p4iXXaaqBfEM4zgw== 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=iCB4Vx2TDjKwAlu4m1e0KeGA5ZfMHTw0YwLUoW/ut2U=; b=r7mAguzE/t4eNj/9BGFPy0qvIgSd8f+/9ApIWv/zTm+k+W2oadwFHEAhSQzn8ZarcPBrxx0JEQEWw6WsQo/o8ZKebxp8Dd2CdIdEX/ILtMecnQt5kKgjCKBULTEVal3ptZ0AnVMVkghxzQVvAC9xj6VIvgRZ/+KzunELiuo4kAw= 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 SJ0PR10MB5533.namprd10.prod.outlook.com (2603:10b6:a03:3f7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Sun, 8 May 2022 18:53:35 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::4581:787c:1a7a:873e]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::4581:787c:1a7a:873e%3]) with mapi id 15.20.5227.020; Sun, 8 May 2022 18:53:35 +0000 From: Colin Foster To: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org Cc: Terry Bowman , Wolfram Sang , Andy Shevchenko , Steen Hegelund , Lars Povlsen , Linus Walleij , Russell King , Heiner Kallweit , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Florian Fainelli , Vivien Didelot , Andrew Lunn , UNGLinuxDriver@microchip.com, Alexandre Belloni , Claudiu Manoil , Vladimir Oltean , Lee Jones Subject: [RFC v8 net-next 04/16] net: mdio: mscc-miim: add ability to be used in a non-mmio configuration Date: Sun, 8 May 2022 11:53:01 -0700 Message-Id: <20220508185313.2222956-5-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220508185313.2222956-1-colin.foster@in-advantage.com> References: <20220508185313.2222956-1-colin.foster@in-advantage.com> X-ClientProxiedBy: SJ0PR03CA0045.namprd03.prod.outlook.com (2603:10b6:a03:33e::20) 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: 75cd4e50-4190-4921-a52e-08da31240e0b X-MS-TrafficTypeDiagnostic: SJ0PR10MB5533: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: rWHQI43jWJ7ErQ8JymDd45aBlMLGf6xwCwS4/HpvHw59+1iTVSxBrSfO9V1f82s3jO9VuSANr29OBQvOVZK3FpIEJMn7q2eQyBCKCnksSmKtK4Ha+293XSosFvev+PeOTTrrzeH6gA6dWCfAS9uJPJURkxg/i/oFHlvlD0ENnj1Owbj807vDadDJc2FJ46aPj/BrMOwUVnkyMxQhlPBYJmOFpZpYMduW0lVR/10VEEmzwUsim2SRMC0KY+1bE4G3H2xqheC5VdXBHEPNXj080Ts/4T8Wv9fwp2Qins0mD2KnM3P8TNmpc5VSRMfJzrmSZIH8hZD/zo3q4NxYmPDV/61mvYQwl1dS3Hkdxer+2WRfT+JJcWFhrf//if5r28OEivYmuu69jfnnkSr09E+hplUnhAFtnxbEZAaZkRKp9mShg6xsq0IBY0iXJAMX/0/NMpFNNPFmxftDiG6X1hDsYJji+oIXigqm8RqpQRLM3b4/Y6xtoruVRgEZUu78KxPD80lfHL5WzxvWbCQWnFdpcNfbe4o7RU1sfYCL0gwlEsaaUgj6g5XpWbCTaB+tGQzbxowq6WXF+zPNF7KYts4GO/QV7rjLzEpFNy14URophMEn0vx7otwV+rNvPDu11Js2+KS1K+YF4CVcExATEpWzzztDEoV81CWqTCa9nd1c9Cl9Ev4lEIIvWAUzXNFUxfqr0NSKdQwgXw2XniQpHtf3Sg== 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)(39840400004)(136003)(376002)(366004)(396003)(346002)(316002)(66946007)(6666004)(26005)(66556008)(508600001)(44832011)(6512007)(6486002)(66476007)(52116002)(186003)(86362001)(2906002)(4326008)(54906003)(8676002)(38100700002)(2616005)(38350700002)(6506007)(83380400001)(8936002)(7416002)(1076003)(36756003)(5660300002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSp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xx/6wz2w9oWwwm0MHmZRsukmJiNjzwHt3oKd6ianyWTgYKMMgJ0SfILKvwHB+RWrxyrpnjIkC0IzvI0dyJFStTWG5Ccv/Nm3oOHF+5fUzEXsYLHENL5judS51u22TejI4FtV/Xi0HjUociQ7WDAsCqhTV28KxksA7O6N2exQIzmZZm35gLlGd5n5+Cwd+o0pB1vbUDRkVZ7a9MwB3ndaBnYPX4ZQHTNa28WKPQM3smGs+1iY1qax3z7aKHyCKdYXipO9fEpYBfhusZxcCM9r8mQRhDTAzwe4StNRZkzMztPVCsWjEqQCkElogLHOAiu4iXq4gVyL0Vex6sw1tkpPMBOvSNIfePZQCkb82437UU6jXmA9kpWy/3cv5Z8bJlZsNOcbb9eNmnIJ0U0q+EcoxVfzC81GhOG0bDUb4leBhMt9H/PnHh6o0oA7hPEFtVoyCjIdVur+XE6zTq/JWkP9eKCYUIDxiIv9mck/HrqDO+Ll3iA1HKff6qutNH5lflLgP9tP+C7h3xyxRj8/90ruayOF2qzotbKDgo8OksDOYXczLqa7Mw+smfQr4jzOP6Bwl+Kh5+z9feMrfPbUG6j9D7nktcX51XP95hCFAKEvJ90Ut126VXu0IWc64aAw5HaNwUXn3GBLWn+lTeVlt6gGBYplnonf926zHrN85WhRFQZMIb7+6uxkEwekcTtcv1KPI5KjI+Z6ws+LaDJeBf1Y3mT X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75cd4e50-4190-4921-a52e-08da31240e0b X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2022 18:53:35.3074 (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: 9P5RyhQC6ACxXwG6SDpFH48fJc+clrYkopjITy1arYx8i95lPeDU+ojEVu/0rPVwBDac2LushWu4uAVz9R71einb2YvGk+THtmvd5cHR1AA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5533 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/net/mdio/mdio-mscc-miim.c b/drivers/net/mdio/mdio-mscc-miim.c index 08541007b18a..728883f95edf 100644 --- a/drivers/net/mdio/mdio-mscc-miim.c +++ b/drivers/net/mdio/mdio-mscc-miim.c @@ -18,6 +18,7 @@ #include #include #include +#include #define MSCC_MIIM_REG_STATUS 0x0 #define MSCC_MIIM_STATUS_STAT_PENDING BIT(2) @@ -281,11 +282,20 @@ static int mscc_miim_probe(struct platform_device *pdev) 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); - } + /* Fall back to using IORESOURCE_REG, which is possible in an + * MFD configuration + */ + res = platform_get_resource(pdev, IORESOURCE_REG, 0); + if (!res) { + dev_err(dev, "Unable to get MIIM resource\n"); + return -ENODEV; + } - mii_regmap = devm_regmap_init_mmio(dev, regs, &mscc_miim_regmap_config); + mii_regmap = ocelot_init_regmap_from_resource(dev, res); + } else { + 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"); @@ -303,10 +313,15 @@ static int mscc_miim_probe(struct platform_device *pdev) 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 { + res = platform_get_resource(pdev, IORESOURCE_REG, 1); + if (res) + phy_regmap = ocelot_init_regmap_from_resource(dev, res); + } + + if (IS_ERR(phy_regmap)) { + dev_err(dev, "Unable to create phy register regmap\n"); + return PTR_ERR(phy_regmap); } ret = mscc_miim_setup(dev, &bus, "mscc_miim", mii_regmap, 0);