From patchwork Thu Nov 25 20:12:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12639793 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 806A4C433EF for ; Thu, 25 Nov 2021 20:15:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357098AbhKYUS6 (ORCPT ); Thu, 25 Nov 2021 15:18:58 -0500 Received: from mail-dm6nam11on2116.outbound.protection.outlook.com ([40.107.223.116]:64547 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1356927AbhKYUQ6 (ORCPT ); Thu, 25 Nov 2021 15:16:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h0SggzUKZP8LNDhqPf/88AYVf79w1r0PpRcDSQrPA5GllGXE1g6xWmwiN0tnge+QXkyMI1w8NPb41V6vQ8ZJEyQy8bmiTDoKCYYA1AcI2Ro7DDkyWmVbRakOnFruptTYZiM/DArV+HV7Qcek9DXWoETZShkANgetxdVRaC5lX2l4vzGXZ3pgho90M12x3bSAjx985hm6wX17JSQWiNipRWIGeZbhra3AIGHXZF04xlfZs8zaeV83CfBYnX+XtDcqcGYZDxr3mliRcfwEngcuIx+mfDV2ZJ+dKCliS3Rjs1F9qKCfzkzbF8EueUe0hW68e5MMmm9xhgOLeznhshdNXA== 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=1L1M4G5nIPqHbUlMt9hZ1Wilw+g3XFxZTPwKZcgebI8=; b=ge0TMWmJ+JFrHTVFRNJPbpFovZ6qia4y6zXUlKy+NRIyBkegSrGio8RGLn0O1tSQZytcj7Cw7STVvO2j7BNwA1CM3pJhp/CDZdqLo7dHHJTtIxoiQY3urGNm5r/RbWv7nWY4GSluHpRWOceLERu1G+P0lBxlkt/JIq6rie+a1Ahcg50jfgFx0ebsygYLp9Ep30ERtCEwSWq2vkVUX5XZ8cs4dTwzGUid9qcyvv3aS66BvAdz3x/aAOmeSlKOQm1NlFNKAlZnGktoIWsI9oTO4cMCfGcLD4/EdrdNzx4VWP2ZGh05kpGbwEWVzwtLt1w8AqEUojeyANWbChOsX7h/4A== 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=1L1M4G5nIPqHbUlMt9hZ1Wilw+g3XFxZTPwKZcgebI8=; b=mIuXQ6VtnuYLtwach+wIGAx7or61N+ashMHAIAkS2g14aoSRap3yhIA+rFeJjrpmLOApcv/5Al8EcHkmYdrHVkygWoN85PZZ8FYmkPy259DLx8sX0mtYzCQo2x+RqSWEm56lZHWeeReXh7GRAnzb5r90eVdrJQE2QCcDS9MQ180= 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 CO1PR10MB5521.namprd10.prod.outlook.com (2603:10b6:303:160::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Thu, 25 Nov 2021 20:13:13 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::6430:b20:8805:cd9f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::6430:b20:8805:cd9f%5]) with mapi id 15.20.4734.022; Thu, 25 Nov 2021 20:13:13 +0000 From: Colin Foster To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , Heiner Kallweit , Russell King Subject: [PATCH v2 net-next 1/3] net: mdio: mscc-miim: convert to a regmap implementation Date: Thu, 25 Nov 2021 12:12:59 -0800 Message-Id: <20211125201301.3748513-2-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211125201301.3748513-1-colin.foster@in-advantage.com> References: <20211125201301.3748513-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR18CA0071.namprd18.prod.outlook.com (2603:10b6:300:39::33) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 Received: from localhost.localdomain (67.185.175.147) by MWHPR18CA0071.namprd18.prod.outlook.com (2603:10b6:300:39::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22 via Frontend Transport; Thu, 25 Nov 2021 20:13:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e048c854-454a-4037-893d-08d9b05001e4 X-MS-TrafficTypeDiagnostic: CO1PR10MB5521: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:923; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YYtYzRcgBspooTkAZxrcql/bxcZ518PC8OeiN+GbSMb39YdGM6Nk6G2CnUbjRRIsO1vXpd/7SpFBp/n12zDP/hNqeRHg0YpGVmtXPzeOHLbe3dmuyfe3bEF7DnRZ/b9g2Hsxd5YZ+N+gs7IFL2FztE9ZZOhOcUMyeL+zdj5X9pPFAOAYTSWzIpTgVD9QOJrmqrXOcRjYUIqJaQAwNMKC2rsylaPVSy8Qzy0cBOqGnTIDuXz0JE9qimYq9unPCBGZy6QVEDQp49T3ex55QUsVM3M8XbYkPSe8oXJq4fPSF7GdrmXEnHjxEdA9vxK1Q+dEXGABJBPcScdJQzNJWpPDQPaIJGIcBTG1lTrIhs0QKJXis7IOTkCly/i+eRLk8xyd/BmWOz8Xg+3oDg3kPflWjN1K1egQNv6ksGCAHK8dKjr4pxf/kw6s14++r4VJhoe5lxG1EXz9aKPDvUZl9xPvM8bt3CXl5hToSJNFfTnu9O6UW3IKybp3Q7BMHSbjNVdocarf9FtoHiXpGcab4+AeY6DUU5PSaTIASx20BDnD517O0dSBvEpvDkZWETel+RpWDsjqQyO6k4zjjtYHWJXYz3Z0yTkwWW/Gg1UeBnvRtUxC6A6ih+kcsctp3oJbx5aYXOJQ/rxZ5pGvLZd0hn8kv1q6JUTNdx6xKNhNR+Z2lYU5NzaLGX8hU/rNo2kXRva+bgSNzNHI768Ri72jPnfvdw== 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:(396003)(366004)(136003)(39830400003)(376002)(346002)(8936002)(44832011)(5660300002)(6512007)(38100700002)(8676002)(508600001)(86362001)(6666004)(6486002)(7416002)(186003)(26005)(38350700002)(2906002)(36756003)(316002)(66946007)(6506007)(54906003)(4326008)(2616005)(1076003)(956004)(52116002)(83380400001)(66476007)(66556008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: B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ZQtsN11udv8ew6I3b78J5lh0H4p24UmXvWwrT90iHahmCVCxx1Awka2A6PuftFHOFYQKYxL7JQ81jXjXo60CQ0EQ5tpaWYJFleqn0kWmBfys3LPuLPi/g3m3a0oPrFBVT6wxWWrL0ovXR0g5gS0xdklTrqe1w4GHdtqr9TTTTE0n7ZrsT+MPU45FjRfTIea1IAkfVT6vaRUBdfYj8FxJyLRdy0stWmexhjGjLhowPSAy5UoYdcviGDYnRj1CXwhJu4WV38HbA8qpwBQq8SS584mHdAz6YVUt0ITUDziBG7IQk63Xhwk6kdvCOwjHGuN8DQpBeWyfjUQHJQ93gdVFcSEGWJviV5UT/JZOLioSAmLMjKg/SVJVbPGYyMMCg7Nb+mb7ToIGWH4QAB6YUvKQ3e+QDrOUL4e7dR21EXVhoY7Zp4J01Sh9qhX/ApCbMj0araSz6pZd9gwYz1DOKsWynbpOOjhxwDxMbpELUu801VaZLyK6Q92YOZGDUIQtG2byocy3gGbRG7LXNM79sZGRPyLXn31W0RvfLib0vS5UyRchWcDDbb00V0D+IDzGTag2y/RMXPUGoqSwQbTFL+VdNxxMC8HyLRGQ== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: e048c854-454a-4037-893d-08d9b05001e4 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Nov 2021 20:13:13.0449 (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: zeUoUZ79LmqMLV3+JiE3ehM8OqMpxofr9zl+truFS7H2/UM8HlC0E1DuH6/YH6w1ynmaoo9MXv2aIduG0MFDRQZi2HrQZBLwDkzmuyJjXEg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB5521 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Utilize regmap instead of __iomem to perform indirect mdio access. This will allow for custom regmaps to be used by way of the mscc_miim_setup function. Signed-off-by: Colin Foster Tested-by: Vladimir Oltean --- drivers/net/mdio/mdio-mscc-miim.c | 161 ++++++++++++++++++++++-------- 1 file changed, 119 insertions(+), 42 deletions(-) diff --git a/drivers/net/mdio/mdio-mscc-miim.c b/drivers/net/mdio/mdio-mscc-miim.c index 17f98f609ec8..5a9c0b311bdb 100644 --- a/drivers/net/mdio/mdio-mscc-miim.c +++ b/drivers/net/mdio/mdio-mscc-miim.c @@ -14,6 +14,7 @@ #include #include #include +#include #define MSCC_MIIM_REG_STATUS 0x0 #define MSCC_MIIM_STATUS_STAT_PENDING BIT(2) @@ -35,37 +36,49 @@ #define MSCC_PHY_REG_PHY_STATUS 0x4 struct mscc_miim_dev { - void __iomem *regs; - void __iomem *phy_regs; + struct regmap *regs; + struct regmap *phy_regs; }; /* When high resolution timers aren't built-in: we can't use usleep_range() as * we would sleep way too long. Use udelay() instead. */ -#define mscc_readl_poll_timeout(addr, val, cond, delay_us, timeout_us) \ -({ \ - if (!IS_ENABLED(CONFIG_HIGH_RES_TIMERS)) \ - readl_poll_timeout_atomic(addr, val, cond, delay_us, \ - timeout_us); \ - readl_poll_timeout(addr, val, cond, delay_us, timeout_us); \ +#define mscc_readx_poll_timeout(op, addr, val, cond, delay_us, timeout_us)\ +({ \ + if (!IS_ENABLED(CONFIG_HIGH_RES_TIMERS)) \ + readx_poll_timeout_atomic(op, addr, val, cond, delay_us, \ + timeout_us); \ + readx_poll_timeout(op, addr, val, cond, delay_us, timeout_us); \ }) -static int mscc_miim_wait_ready(struct mii_bus *bus) +static int mscc_miim_status(struct mii_bus *bus) { struct mscc_miim_dev *miim = bus->priv; + int val, ret; + + ret = regmap_read(miim->regs, MSCC_MIIM_REG_STATUS, &val); + if (ret < 0) { + WARN_ONCE(1, "mscc miim status read error %d\n", ret); + return ret; + } + + return val; +} + +static int mscc_miim_wait_ready(struct mii_bus *bus) +{ u32 val; - return mscc_readl_poll_timeout(miim->regs + MSCC_MIIM_REG_STATUS, val, + return mscc_readx_poll_timeout(mscc_miim_status, bus, val, !(val & MSCC_MIIM_STATUS_STAT_BUSY), 50, 10000); } static int mscc_miim_wait_pending(struct mii_bus *bus) { - struct mscc_miim_dev *miim = bus->priv; u32 val; - return mscc_readl_poll_timeout(miim->regs + MSCC_MIIM_REG_STATUS, val, + return mscc_readx_poll_timeout(mscc_miim_status, bus, val, !(val & MSCC_MIIM_STATUS_STAT_PENDING), 50, 10000); } @@ -80,15 +93,27 @@ static int mscc_miim_read(struct mii_bus *bus, int mii_id, int regnum) if (ret) goto out; - writel(MSCC_MIIM_CMD_VLD | (mii_id << MSCC_MIIM_CMD_PHYAD_SHIFT) | - (regnum << MSCC_MIIM_CMD_REGAD_SHIFT) | MSCC_MIIM_CMD_OPR_READ, - miim->regs + MSCC_MIIM_REG_CMD); + ret = regmap_write(miim->regs, MSCC_MIIM_REG_CMD, MSCC_MIIM_CMD_VLD | + (mii_id << MSCC_MIIM_CMD_PHYAD_SHIFT) | + (regnum << MSCC_MIIM_CMD_REGAD_SHIFT) | + MSCC_MIIM_CMD_OPR_READ); + + if (ret < 0) { + WARN_ONCE(1, "mscc miim write cmd reg error %d\n", ret); + goto out; + } ret = mscc_miim_wait_ready(bus); if (ret) goto out; - val = readl(miim->regs + MSCC_MIIM_REG_DATA); + ret = regmap_read(miim->regs, MSCC_MIIM_REG_DATA, &val); + + if (ret < 0) { + WARN_ONCE(1, "mscc miim read data reg error %d\n", ret); + goto out; + } + if (val & MSCC_MIIM_DATA_ERROR) { ret = -EIO; goto out; @@ -109,12 +134,14 @@ static int mscc_miim_write(struct mii_bus *bus, int mii_id, if (ret < 0) goto out; - writel(MSCC_MIIM_CMD_VLD | (mii_id << MSCC_MIIM_CMD_PHYAD_SHIFT) | - (regnum << MSCC_MIIM_CMD_REGAD_SHIFT) | - (value << MSCC_MIIM_CMD_WRDATA_SHIFT) | - MSCC_MIIM_CMD_OPR_WRITE, - miim->regs + MSCC_MIIM_REG_CMD); + ret = regmap_write(miim->regs, MSCC_MIIM_REG_CMD, MSCC_MIIM_CMD_VLD | + (mii_id << MSCC_MIIM_CMD_PHYAD_SHIFT) | + (regnum << MSCC_MIIM_CMD_REGAD_SHIFT) | + (value << MSCC_MIIM_CMD_WRDATA_SHIFT) | + MSCC_MIIM_CMD_OPR_WRITE); + if (ret < 0) + WARN_ONCE(1, "mscc miim write error %d\n", ret); out: return ret; } @@ -122,24 +149,40 @@ static int mscc_miim_write(struct mii_bus *bus, int mii_id, static int mscc_miim_reset(struct mii_bus *bus) { struct mscc_miim_dev *miim = bus->priv; + int ret; if (miim->phy_regs) { - writel(0, miim->phy_regs + MSCC_PHY_REG_PHY_CFG); - writel(0x1ff, miim->phy_regs + MSCC_PHY_REG_PHY_CFG); + ret = regmap_write(miim->phy_regs, MSCC_PHY_REG_PHY_CFG, 0); + if (ret < 0) { + WARN_ONCE(1, "mscc reset set error %d\n", ret); + return ret; + } + + ret = regmap_write(miim->phy_regs, MSCC_PHY_REG_PHY_CFG, 0x1ff); + if (ret < 0) { + WARN_ONCE(1, "mscc reset clear error %d\n", ret); + return ret; + } + mdelay(500); } return 0; } -static int mscc_miim_probe(struct platform_device *pdev) +static const struct regmap_config mscc_miim_regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, +}; + +static int mscc_miim_setup(struct device *dev, struct mii_bus **pbus, + struct regmap *mii_regmap, struct regmap *phy_regmap) { - struct mscc_miim_dev *dev; - struct resource *res; + struct mscc_miim_dev *miim; struct mii_bus *bus; - int ret; - bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*dev)); + bus = devm_mdiobus_alloc_size(dev, sizeof(*miim)); if (!bus) return -ENOMEM; @@ -147,24 +190,58 @@ static int mscc_miim_probe(struct platform_device *pdev) bus->read = mscc_miim_read; bus->write = mscc_miim_write; bus->reset = mscc_miim_reset; - snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(&pdev->dev)); - bus->parent = &pdev->dev; + snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(dev)); + bus->parent = dev; + + miim = bus->priv; + + *pbus = bus; + + miim->regs = mii_regmap; + miim->phy_regs = phy_regmap; + + return 0; +} + +static int mscc_miim_probe(struct platform_device *pdev) +{ + struct regmap *mii_regmap, *phy_regmap; + void __iomem *regs, *phy_regs; + struct mscc_miim_dev *dev; + struct mii_bus *bus; + int ret; - dev = bus->priv; - dev->regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); - if (IS_ERR(dev->regs)) { + regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); + if (IS_ERR(regs)) { dev_err(&pdev->dev, "Unable to map MIIM registers\n"); - return PTR_ERR(dev->regs); + return PTR_ERR(regs); } - /* This resource is optional */ - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - if (res) { - dev->phy_regs = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(dev->phy_regs)) { - dev_err(&pdev->dev, "Unable to map internal phy registers\n"); - return PTR_ERR(dev->phy_regs); - } + mii_regmap = devm_regmap_init_mmio(&pdev->dev, regs, + &mscc_miim_regmap_config); + + if (IS_ERR(mii_regmap)) { + dev_err(&pdev->dev, "Unable to create MIIM regmap\n"); + return PTR_ERR(mii_regmap); + } + + phy_regs = devm_platform_ioremap_resource(pdev, 1); + if (IS_ERR(dev->phy_regs)) { + dev_err(&pdev->dev, "Unable to map internal phy registers\n"); + return PTR_ERR(dev->phy_regs); + } + + phy_regmap = devm_regmap_init_mmio(&pdev->dev, phy_regs, + &mscc_miim_regmap_config); + if (IS_ERR(phy_regmap)) { + dev_err(&pdev->dev, "Unable to create phy register regmap\n"); + return PTR_ERR(dev->phy_regs); + } + + ret = mscc_miim_setup(&pdev->dev, &bus, mii_regmap, phy_regmap); + if (ret < 0) { + dev_err(&pdev->dev, "Unable to setup the MDIO bus\n"); + return ret; } ret = of_mdiobus_register(bus, pdev->dev.of_node); From patchwork Thu Nov 25 20:13:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12639791 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 01925C433F5 for ; Thu, 25 Nov 2021 20:15:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357023AbhKYUS2 (ORCPT ); Thu, 25 Nov 2021 15:18:28 -0500 Received: from mail-dm6nam10on2131.outbound.protection.outlook.com ([40.107.93.131]:31905 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1356926AbhKYUQ2 (ORCPT ); Thu, 25 Nov 2021 15:16:28 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GQ3p9JuRmqQyaf39v09SJ+6uHBLdD5XHKjASlp4z92815qRW/XhqyUNtk6C4UpGN+InGobaTY11tOlVhV3SwxEsS34E3gZQ8dHh3VDUko2zDUESQ8hMIQBV3O+13esSPSiGzgSWIBDJZGIqP7nzVTp4Ad8qDlJyiVjEa6kYSalPCzYXR/yDX7HzFKnMbf5FCXfgi+W7WwcLYJCCgIsc7AZ0jWkAhas2YGge5IEM0HhBO5xdu3mYtTO4+X8KxbY0cYUZEQD625x2utfOOIBmIhH6gT/2DfhrFqQyONruHXkX1o3aDw4Hos0G2dn1QYmrpBJq71EvewaI9Tmq53xvLRg== 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=teWH3hIwMFBYnGApZq4W5Op1sj66sQ6tWyuyTDdfIM4=; b=U5XQwyGahCupw2GOdYX0IwgaaXr/COddGcSeCPxFDoCuv8ccM4oznWL+R+rd3FxNtWAosaZ/PY/ccdx3ZmLk91Td9RDD2drizskuw3Sa3waSg+bw63Zg8FR5fOFnbV+t1pwXGNmltM6JljdiPTxkqjtbPN3gumLHc086eOVotXMrDMBatNIa9xm+5eSN0fmmxQYIlv78u/j+PMRn1rBjTKyh9N4KbLQ2jxCd/hWWtSPTi89GeHU4JEUOKhjtX1wHpz62A3//rSNf23DTwBAtAZQEc1x0mDt85gKhR+FhWcVdOxLOgrOUSJyWCPP4g68tMBFCb/BAQoQa6wymTkJHYQ== 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=teWH3hIwMFBYnGApZq4W5Op1sj66sQ6tWyuyTDdfIM4=; b=lGMMOVriZJuQiMyK/vP8i9NbKOIR5CjNlKmTyh8K+iLd0j/fGgabwppST3MtDE1peRRpaPhExAupFUbVaQNVMa6MRP9LttGxKXFBnvIx92iWCZY74hVZvixHCrSeE3I33FV8PiIY79CzqEE9yxhUV0NEwaTN0HGyilqSFaQfCeE= 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 CO1PR10MB5521.namprd10.prod.outlook.com (2603:10b6:303:160::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Thu, 25 Nov 2021 20:13:13 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::6430:b20:8805:cd9f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::6430:b20:8805:cd9f%5]) with mapi id 15.20.4734.022; Thu, 25 Nov 2021 20:13:13 +0000 From: Colin Foster To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , Heiner Kallweit , Russell King Subject: [PATCH v2 net-next 2/3] net: dsa: ocelot: seville: utilize of_mdiobus_register Date: Thu, 25 Nov 2021 12:13:00 -0800 Message-Id: <20211125201301.3748513-3-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211125201301.3748513-1-colin.foster@in-advantage.com> References: <20211125201301.3748513-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR18CA0071.namprd18.prod.outlook.com (2603:10b6:300:39::33) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 Received: from localhost.localdomain (67.185.175.147) by MWHPR18CA0071.namprd18.prod.outlook.com (2603:10b6:300:39::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22 via Frontend Transport; Thu, 25 Nov 2021 20:13:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0f00c69a-c4ee-4a4b-f2fd-08d9b0500286 X-MS-TrafficTypeDiagnostic: CO1PR10MB5521: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LmgNO+uvEYmxBbFgw7TG6/70MbJgnP0f3139mzCtkvYbrv5VeisAOa/Ue+mpSRvSTbcc4SU5Tpz/tCaBX7hUIzsSsm+2+Q9l111B9+pkGM4/K4UjGZgTyjMBDDI8n39L6KU/zcMF59TkUH7USZMeW0Kqh+v9iclB4Vk9xRnQplb9+So/XE9oiCTwo+VaGaCPual+Q764l1vCrugQ0sd2pSDeh+ZFBz7s4xOWTtCZkJg5sEuwwigjiO/79oht/btuNWbdzYCcBIwQrJKJZoA7JaU/nT1+oNd85PAVGdB+k0RgCI1P2yXzUaFwdiU4ovD/Fmh+dXKFeVaaZMZBkuH9STbY1rJ5iuH+u4XiaMHUUu1gqNfeh6ZrjeIVBaIIXJAVvoEFM6KAzIYLPEs9X/+Qu8QHTi1FYRE5ZPHu88Lk4JZJ7H/pgdRDzsds2fqKt4DQBScum1mptPeOhuwnhU/4WIdMVXSXxQSwZ7EYl10UXE7zypYKMyDCJ0WocNpfQ4jC0UPK3d1wId2GPQ2qnO8fZm9kyRZ+PH50Mt7dHYs7sOyMezv+vOxm/W6nNbyC9IAHeQ4ydCP0s9DDG5bWxF0DLyiPzMK1edSCHP4tuc1kcqvs/4iPX8yMAY9HdMLVeGIA1Ij/A4+vPwx3l8ZyXpRbo6nb/64PBTqswgaoemAtDERdzBfUorbbVu77js45zzGcB4zJheFBjBONpWk0DcWqJg== 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:(396003)(366004)(136003)(39830400003)(376002)(346002)(8936002)(44832011)(5660300002)(6512007)(38100700002)(8676002)(508600001)(86362001)(6666004)(6486002)(7416002)(186003)(26005)(38350700002)(2906002)(36756003)(316002)(66946007)(6506007)(54906003)(4326008)(2616005)(1076003)(956004)(52116002)(83380400001)(66476007)(66556008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sWv2YxFinQJpxpUkQS768ZT7BMQtpTmkkmau0eLfP59AG6PbFygr+X/a1/IXPmPPf8NYMdLn0LOeVAdnu6IsrvQ81Uth94eHP4Vvx+emB0o5NmzPnMWZXpu7TP4pGbnGkZQkqXmBXNgiUVzVPnUARQeWUuvB7klJ2vKy69MlwIWbFyX1brI2J4FtzFK6K62cPwcsHfIEkr9me8QByDUEBcKr2Pe/Sk1I23rxtuoFur/D3CWsGrl3I+nElyBCgroWXF+yfrWJR35VJmJXGr+whkYDgWao8TIXa0iZv9oHPpPFaoINPll9TSYZ0fEWWPietvmSzyeT/flcrioJIpI6JH9PnuZ+ScG3ZMxkx2uky7bYCe0oBxSRZ6xcDcVRJYL7Dc3qJKk/u+ttV5DiaUoWdx5V73lpA0sxO8VPMO5jz4RJhGf4dRcvoEvcWIrrT9+juWP8dYdMh+h0oUJZbFyYnhEKI7ffDYw+kwOCk5PJvQ+8Wgu5ADbw9DO+HF4CV67Y8S9TtftkSl2lF1YDx13qKGIExpIkgeaNHan/VZgI4Sshkrzj3iBp2Eu80uUR8OPv3fIGDjwqBwOdp1x3icRHJukQdMVwLFTQ8UpT2CO2wRTOsTGMZOjNzQyIfAsbX3LbwQsw3+NOt6+FfkVpnyagGXEayjKWDbW4YJJWy6P1Mpzw== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f00c69a-c4ee-4a4b-f2fd-08d9b0500286 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Nov 2021 20:13:13.7715 (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: Badr9hgDMJAFO2kDzPlWIAo4NpqIXifl/ANGn9YrqXxR7JcxHk92AkwrQxQtqthQ+Ao04ybHMap1BYMMN30pkMcNPW93koDLpuh94Z+RsA4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB5521 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Switch seville to use of_mdiobus_register(bus, NULL) instead of just mdiobus_register. This code is about to be pulled into a separate module that can optionally define ports by the device_node. Signed-off-by: Colin Foster Reviewed-by: Florian Fainelli Reviewed-by: Vladimir Oltean Tested-by: Vladimir Oltean --- drivers/net/dsa/ocelot/seville_vsc9953.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c index 899b98193b4a..db124922c374 100644 --- a/drivers/net/dsa/ocelot/seville_vsc9953.c +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "felix.h" #define MSCC_MIIM_CMD_OPR_WRITE BIT(1) @@ -1112,7 +1113,7 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot) snprintf(bus->id, MII_BUS_ID_SIZE, "%s-imdio", dev_name(dev)); /* Needed in order to initialize the bus mutex lock */ - rc = mdiobus_register(bus); + rc = of_mdiobus_register(bus, NULL); if (rc < 0) { dev_err(dev, "failed to register MDIO bus\n"); return rc; From patchwork Thu Nov 25 20:13:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12639795 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 AA92DC433EF for ; Thu, 25 Nov 2021 20:16:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357118AbhKYUT2 (ORCPT ); Thu, 25 Nov 2021 15:19:28 -0500 Received: from mail-dm6nam10on2124.outbound.protection.outlook.com ([40.107.93.124]:37441 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S242697AbhKYUR2 (ORCPT ); Thu, 25 Nov 2021 15:17:28 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JDouimtZQwCuvytI02FFhG8+5MFFfAJxe+lpyfF63gip8m9NTD16Tc3gDpm9D2tmfHPA3WChz+Y8292wFtTx81o1p+C6M2GktR5Zi2ZUti8guVG2J3ZZV3uOpn26nInFPKqs89QgnXS8l7cus5qt+TSHyU7eLWrnlQdSwAD4akM3gfllLJUMFbeYkORiuIqwM14QsMGVKxgDyE7v4F7OdGWK2PxAaPInJR3L7F773HY5JQJCwvK+Gept8y2jHUTbuCLM9gGuvtS0hPgDsHDxAN3LgVkXAHpCR84hbdY7E3DYNYFuejDg67L6MAXUolL/gXdt7Y8VM1dTnPTa9bH27Q== 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=2HrD+yoM9CSpvXSUPjzyN40zllFE2ocs6R1NvCOzDZQ=; b=lzM+KpSR71ofMhgcCYd6c3rEiz0c/yceSCtdO9abfXyV3W2vqZvp6mBAz9WA01S+GLGKG+GZLFNbfFVyMn5Ylf0wAJ8pTeBaomRL7DGQaIgxJlha9ArYrEvXBShyHJeHvg3n0uZVni0Z28amJIaOAvgD87FrogfViXLORPuJtrE04ColZ18jWZGwGPmNZu7CBDY+huLcOZDfGitvVp4j6iClmzBYWp7vlyfMHtwDjiA4Bm//9pVyXc0NRkKtoeCGHAKPvzN1WYBV7sCUJpKg/SvPQkIqLpcwJFB7ElgA8iJUF4gcM35Dp39gRdCuz3VLhGup/hQXlFyZo4gkEz0dfg== 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=2HrD+yoM9CSpvXSUPjzyN40zllFE2ocs6R1NvCOzDZQ=; b=b87OmYjQITor9WTnUDmZux1OaEef7OKx26BsElLJSVdsoVfVwFTcJmn8RVR2aR62jAnuYnhFdJoPEy21SMCYMblNSOcNdpaGzQcX0fiJYgdEZFMjlA0Tw5six7QzITgUm/3bf2dM1DiwaU4xAOWxDx8Ff7tzzJ8GgKEhty3fuC0= 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 CO1PR10MB5521.namprd10.prod.outlook.com (2603:10b6:303:160::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Thu, 25 Nov 2021 20:13:14 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::6430:b20:8805:cd9f]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::6430:b20:8805:cd9f%5]) with mapi id 15.20.4734.022; Thu, 25 Nov 2021 20:13:14 +0000 From: Colin Foster To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Vladimir Oltean , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , Heiner Kallweit , Russell King Subject: [PATCH v2 net-next 3/3] net: dsa: ocelot: felix: utilize shared mscc-miim driver for indirect MDIO access Date: Thu, 25 Nov 2021 12:13:01 -0800 Message-Id: <20211125201301.3748513-4-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211125201301.3748513-1-colin.foster@in-advantage.com> References: <20211125201301.3748513-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR18CA0071.namprd18.prod.outlook.com (2603:10b6:300:39::33) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 Received: from localhost.localdomain (67.185.175.147) by MWHPR18CA0071.namprd18.prod.outlook.com (2603:10b6:300:39::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22 via Frontend Transport; Thu, 25 Nov 2021 20:13:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 85417c0a-2a21-4668-d6ef-08d9b05002e1 X-MS-TrafficTypeDiagnostic: CO1PR10MB5521: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XDYloJJ+FVbJDDbjPKwCMG5PmUWkoUyBd3Nwk++fV//QSCM9bZhd+siFLvuwzhS+LnA8gwOw21fE2Q29GAfIP5Yw0BZpr9aQJEBAQJGiytAFMHU1rWCTFNbaatbMQPj7+vb4Mc9aIrACiPiHbZGcwny1S/DFv/cVZxoCr344I0aWTf7zHRw8QdC6ghRijcimZ78eoeXdUrPHDs+p1K4RhUCJ3g/e3z74PD/13OTHBaPklNW1xgpmuRW/6/dFQ/mfmpHOiovI05Pt9kWHPoszz4T9qaRYbfXAu0Sb/ZCAYIk7wT3YitTcJ7iCuG/MymoA4DP7fU7VO/raYq1FBuzlrSCfxLKwRIER5qSWofumr6YsI33pX4IX2Zbnl7KJvdnJUAFT+ltNRNDcRZSOnvpoQtXplQkBuhCBSXUJl8dLeNSGUsIPEk3rydtAoUZpiAkOj+BKkkSKi2M/Q3OXBRXncs+rFWtetZh9uxAQhktOB0cK0+XjkV8heypyEZKU/46dNXAQpn3P2yMmEBsHbsf/pdb4OY0L2JtvF2pPSox65aB7lPegxIRm1QuW2ntSVGY1NxVlxGf9ioMSKWbhm/aiFPF3qyyShFnYC2P1BnRgHOZGjNqL092zEWUp0KCvdC53DAWQKb7DoO9l4msroRGlVK0P7PZ3KI2GgTs28LDEzsLkVJcbKeaOR2xqo8c5LVlqRDqdk5WXNOOn00eTJVq8tw== 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:(396003)(366004)(136003)(39830400003)(376002)(346002)(8936002)(44832011)(5660300002)(6512007)(38100700002)(8676002)(508600001)(86362001)(6666004)(6486002)(7416002)(186003)(26005)(38350700002)(2906002)(36756003)(316002)(30864003)(66946007)(6506007)(54906003)(4326008)(2616005)(1076003)(956004)(52116002)(83380400001)(66476007)(66556008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QTIxmWfxlrx2fNVoMcQBryHtoVKySoH22uuPbURqddWKJ8PVIZRwcCAwtOK9r6NUWzTsF0rprr5yk61qttFawm3ht4hjD3XaBBznAuUKWdtodRJJShnmbPerQKRQ1rolhU8M+lnVCkkeQclNUaXhU1MHiv0dtsYx8kJC4EWOOo/fgMRQT/Uy3riXWrUJEsdrF/rODmdar7X5ov8MNw7W/IxPAWZzcK7IJZxgwHGx2fu6YSDGLbk+pFhPTKgqFJqwECknryg5QY0cfJaAclUbjAMjeU90QgCJyh9BVej2pZVbC3blStf//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i72GxI/CFJp1X4j9pbirZWIzfVpqG/NnAenSEfwmnxqmobdX6jG6Zrh58tvrAMi9bf9xrpjHg6c6uDcCCC+kpU2N1spatUWkgo/+Mom23LzWAIjOw00IIYM+tFxnXbS7gdLw+i93cGRUOGPyUEMyZzBX6u7jGYIIlwxAduB2JNdJffeO3ovscKGPE6YMq4WMTq1z++RJGkXdVuVPwSPOLDR0D2D8WhtqULGyx4HxZ1a/7gTefR6gpluTMdTXEEEbrCQwuSsb5PC4cZUDwMZcknPPX+Z6AYlO+cszwTug4Nl7+FunJ1I6lw== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85417c0a-2a21-4668-d6ef-08d9b05002e1 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Nov 2021 20:13:14.7459 (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: WN7yqXgmIpAbx5kMsCUcpIL7kmiAAB2mmsTXa6sOg7LhjQvOSfvwWseQhdQ2/5rPnDIocEh0IeuK6z2+MO/uxm7mM86+mdXIVPwDRK1byZg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR10MB5521 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Switch to a shared MDIO access implementation by way of the mdio-mscc-miim driver. Signed-off-by: Colin Foster Tested-by: Vladimir Oltean --- drivers/net/dsa/ocelot/Kconfig | 1 + drivers/net/dsa/ocelot/seville_vsc9953.c | 103 +++-------------------- drivers/net/mdio/mdio-mscc-miim.c | 40 ++++++--- include/linux/mdio/mdio-mscc-miim.h | 20 +++++ include/soc/mscc/ocelot.h | 1 + 5 files changed, 61 insertions(+), 104 deletions(-) create mode 100644 include/linux/mdio/mdio-mscc-miim.h diff --git a/drivers/net/dsa/ocelot/Kconfig b/drivers/net/dsa/ocelot/Kconfig index 9948544ba1c4..220b0b027b55 100644 --- a/drivers/net/dsa/ocelot/Kconfig +++ b/drivers/net/dsa/ocelot/Kconfig @@ -21,6 +21,7 @@ config NET_DSA_MSCC_SEVILLE depends on NET_VENDOR_MICROSEMI depends on HAS_IOMEM depends on PTP_1588_CLOCK_OPTIONAL + select MDIO_MSCC_MIIM select MSCC_OCELOT_SWITCH_LIB select NET_DSA_TAG_OCELOT_8021Q select NET_DSA_TAG_OCELOT diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c index db124922c374..41ec60a1fc96 100644 --- a/drivers/net/dsa/ocelot/seville_vsc9953.c +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c @@ -6,19 +6,14 @@ #include #include #include +#include +#include #include #include #include #include -#include #include "felix.h" -#define MSCC_MIIM_CMD_OPR_WRITE BIT(1) -#define MSCC_MIIM_CMD_OPR_READ BIT(2) -#define MSCC_MIIM_CMD_WRDATA_SHIFT 4 -#define MSCC_MIIM_CMD_REGAD_SHIFT 20 -#define MSCC_MIIM_CMD_PHYAD_SHIFT 25 -#define MSCC_MIIM_CMD_VLD BIT(31) #define VSC9953_VCAP_POLICER_BASE 11 #define VSC9953_VCAP_POLICER_MAX 31 #define VSC9953_VCAP_POLICER_BASE2 120 @@ -862,7 +857,6 @@ static struct vcap_props vsc9953_vcap_props[] = { #define VSC9953_INIT_TIMEOUT 50000 #define VSC9953_GCB_RST_SLEEP 100 #define VSC9953_SYS_RAMINIT_SLEEP 80 -#define VCS9953_MII_TIMEOUT 10000 static int vsc9953_gcb_soft_rst_status(struct ocelot *ocelot) { @@ -882,82 +876,6 @@ static int vsc9953_sys_ram_init_status(struct ocelot *ocelot) return val; } -static int vsc9953_gcb_miim_pending_status(struct ocelot *ocelot) -{ - int val; - - ocelot_field_read(ocelot, GCB_MIIM_MII_STATUS_PENDING, &val); - - return val; -} - -static int vsc9953_gcb_miim_busy_status(struct ocelot *ocelot) -{ - int val; - - ocelot_field_read(ocelot, GCB_MIIM_MII_STATUS_BUSY, &val); - - return val; -} - -static int vsc9953_mdio_write(struct mii_bus *bus, int phy_id, int regnum, - u16 value) -{ - struct ocelot *ocelot = bus->priv; - int err, cmd, val; - - /* Wait while MIIM controller becomes idle */ - err = readx_poll_timeout(vsc9953_gcb_miim_pending_status, ocelot, - val, !val, 10, VCS9953_MII_TIMEOUT); - if (err) { - dev_err(ocelot->dev, "MDIO write: pending timeout\n"); - goto out; - } - - cmd = MSCC_MIIM_CMD_VLD | (phy_id << MSCC_MIIM_CMD_PHYAD_SHIFT) | - (regnum << MSCC_MIIM_CMD_REGAD_SHIFT) | - (value << MSCC_MIIM_CMD_WRDATA_SHIFT) | - MSCC_MIIM_CMD_OPR_WRITE; - - ocelot_write(ocelot, cmd, GCB_MIIM_MII_CMD); - -out: - return err; -} - -static int vsc9953_mdio_read(struct mii_bus *bus, int phy_id, int regnum) -{ - struct ocelot *ocelot = bus->priv; - int err, cmd, val; - - /* Wait until MIIM controller becomes idle */ - err = readx_poll_timeout(vsc9953_gcb_miim_pending_status, ocelot, - val, !val, 10, VCS9953_MII_TIMEOUT); - if (err) { - dev_err(ocelot->dev, "MDIO read: pending timeout\n"); - goto out; - } - - /* Write the MIIM COMMAND register */ - cmd = MSCC_MIIM_CMD_VLD | (phy_id << MSCC_MIIM_CMD_PHYAD_SHIFT) | - (regnum << MSCC_MIIM_CMD_REGAD_SHIFT) | MSCC_MIIM_CMD_OPR_READ; - - ocelot_write(ocelot, cmd, GCB_MIIM_MII_CMD); - - /* Wait while read operation via the MIIM controller is in progress */ - err = readx_poll_timeout(vsc9953_gcb_miim_busy_status, ocelot, - val, !val, 10, VCS9953_MII_TIMEOUT); - if (err) { - dev_err(ocelot->dev, "MDIO read: busy timeout\n"); - goto out; - } - - val = ocelot_read(ocelot, GCB_MIIM_MII_DATA); - - err = val & 0xFFFF; -out: - return err; -} /* CORE_ENA is in SYS:SYSTEM:RESET_CFG * MEM_INIT is in SYS:SYSTEM:RESET_CFG @@ -1101,16 +1019,15 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot) return -ENOMEM; } - bus = devm_mdiobus_alloc(dev); - if (!bus) - return -ENOMEM; + rc = mscc_miim_setup(dev, &bus, "VSC9953 internal MDIO bus", + ocelot->targets[GCB], + ocelot->map[GCB][GCB_MIIM_MII_STATUS & REG_MASK], + NULL, 0); - bus->name = "VSC9953 internal MDIO bus"; - bus->read = vsc9953_mdio_read; - bus->write = vsc9953_mdio_write; - bus->parent = dev; - bus->priv = ocelot; - snprintf(bus->id, MII_BUS_ID_SIZE, "%s-imdio", dev_name(dev)); + if (rc) { + dev_err(dev, "failed to setup MDIO bus\n"); + return rc; + } /* Needed in order to initialize the bus mutex lock */ rc = of_mdiobus_register(bus, NULL); diff --git a/drivers/net/mdio/mdio-mscc-miim.c b/drivers/net/mdio/mdio-mscc-miim.c index 5a9c0b311bdb..9eed6b597f21 100644 --- a/drivers/net/mdio/mdio-mscc-miim.c +++ b/drivers/net/mdio/mdio-mscc-miim.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -37,7 +38,9 @@ struct mscc_miim_dev { struct regmap *regs; + int mii_status_offset; struct regmap *phy_regs; + int phy_reset_offset; }; /* When high resolution timers aren't built-in: we can't use usleep_range() as @@ -56,7 +59,8 @@ static int mscc_miim_status(struct mii_bus *bus) struct mscc_miim_dev *miim = bus->priv; int val, ret; - ret = regmap_read(miim->regs, MSCC_MIIM_REG_STATUS, &val); + ret = regmap_read(miim->regs, + MSCC_MIIM_REG_STATUS + miim->mii_status_offset, &val); if (ret < 0) { WARN_ONCE(1, "mscc miim status read error %d\n", ret); return ret; @@ -93,7 +97,9 @@ static int mscc_miim_read(struct mii_bus *bus, int mii_id, int regnum) if (ret) goto out; - ret = regmap_write(miim->regs, MSCC_MIIM_REG_CMD, MSCC_MIIM_CMD_VLD | + ret = regmap_write(miim->regs, + MSCC_MIIM_REG_CMD + miim->mii_status_offset, + MSCC_MIIM_CMD_VLD | (mii_id << MSCC_MIIM_CMD_PHYAD_SHIFT) | (regnum << MSCC_MIIM_CMD_REGAD_SHIFT) | MSCC_MIIM_CMD_OPR_READ); @@ -107,8 +113,8 @@ static int mscc_miim_read(struct mii_bus *bus, int mii_id, int regnum) if (ret) goto out; - ret = regmap_read(miim->regs, MSCC_MIIM_REG_DATA, &val); - + ret = regmap_read(miim->regs, + MSCC_MIIM_REG_DATA + miim->mii_status_offset, &val); if (ret < 0) { WARN_ONCE(1, "mscc miim read data reg error %d\n", ret); goto out; @@ -134,7 +140,9 @@ static int mscc_miim_write(struct mii_bus *bus, int mii_id, if (ret < 0) goto out; - ret = regmap_write(miim->regs, MSCC_MIIM_REG_CMD, MSCC_MIIM_CMD_VLD | + ret = regmap_write(miim->regs, + MSCC_MIIM_REG_CMD + miim->mii_status_offset, + MSCC_MIIM_CMD_VLD | (mii_id << MSCC_MIIM_CMD_PHYAD_SHIFT) | (regnum << MSCC_MIIM_CMD_REGAD_SHIFT) | (value << MSCC_MIIM_CMD_WRDATA_SHIFT) | @@ -149,16 +157,19 @@ static int mscc_miim_write(struct mii_bus *bus, int mii_id, static int mscc_miim_reset(struct mii_bus *bus) { struct mscc_miim_dev *miim = bus->priv; + int offset = miim->phy_reset_offset; int ret; if (miim->phy_regs) { - ret = regmap_write(miim->phy_regs, MSCC_PHY_REG_PHY_CFG, 0); + ret = regmap_write(miim->phy_regs, + MSCC_PHY_REG_PHY_CFG + offset, 0); if (ret < 0) { WARN_ONCE(1, "mscc reset set error %d\n", ret); return ret; } - ret = regmap_write(miim->phy_regs, MSCC_PHY_REG_PHY_CFG, 0x1ff); + ret = regmap_write(miim->phy_regs, + MSCC_PHY_REG_PHY_CFG + offset, 0x1ff); if (ret < 0) { WARN_ONCE(1, "mscc reset clear error %d\n", ret); return ret; @@ -176,8 +187,9 @@ static const struct regmap_config mscc_miim_regmap_config = { .reg_stride = 4, }; -static int mscc_miim_setup(struct device *dev, struct mii_bus **pbus, - struct regmap *mii_regmap, struct regmap *phy_regmap) +int mscc_miim_setup(struct device *dev, struct mii_bus **pbus, const char *name, + struct regmap *mii_regmap, int status_offset, + struct regmap *phy_regmap, int reset_offset) { struct mscc_miim_dev *miim; struct mii_bus *bus; @@ -186,7 +198,7 @@ static int mscc_miim_setup(struct device *dev, struct mii_bus **pbus, if (!bus) return -ENOMEM; - bus->name = "mscc_miim"; + bus->name = name; bus->read = mscc_miim_read; bus->write = mscc_miim_write; bus->reset = mscc_miim_reset; @@ -198,10 +210,15 @@ static int mscc_miim_setup(struct device *dev, struct mii_bus **pbus, *pbus = bus; miim->regs = mii_regmap; + miim->mii_status_offset = status_offset; miim->phy_regs = phy_regmap; + miim->phy_reset_offset = reset_offset; + + *pbus = bus; return 0; } +EXPORT_SYMBOL(mscc_miim_setup); static int mscc_miim_probe(struct platform_device *pdev) { @@ -238,7 +255,8 @@ static int mscc_miim_probe(struct platform_device *pdev) return PTR_ERR(dev->phy_regs); } - ret = mscc_miim_setup(&pdev->dev, &bus, mii_regmap, phy_regmap); + ret = mscc_miim_setup(&pdev->dev, &bus, "mscc_miim", mii_regmap, 0, + phy_regmap, 0); if (ret < 0) { dev_err(&pdev->dev, "Unable to setup the MDIO bus\n"); return ret; diff --git a/include/linux/mdio/mdio-mscc-miim.h b/include/linux/mdio/mdio-mscc-miim.h new file mode 100644 index 000000000000..69a023cf8991 --- /dev/null +++ b/include/linux/mdio/mdio-mscc-miim.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */ +/* + * Driver for the MDIO interface of Microsemi network switches. + * + * Author: Colin Foster + * Copyright (C) 2021 Innovative Advantage + */ +#ifndef MDIO_MSCC_MIIM_H +#define MDIO_MSCC_MIIM_H + +#include +#include +#include + +int mscc_miim_setup(struct device *device, struct mii_bus **bus, + const char *name, struct regmap *mii_regmap, + int status_offset, struct regmap *phy_regmap, + int reset_offset); + +#endif diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 89d17629efe5..9d6fe8ce9dd1 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -398,6 +398,7 @@ enum ocelot_reg { GCB_MIIM_MII_STATUS, GCB_MIIM_MII_CMD, GCB_MIIM_MII_DATA, + GCB_PHY_PHY_CFG, DEV_CLOCK_CFG = DEV_GMII << TARGET_OFFSET, DEV_PORT_MISC, DEV_EVENTS,