From patchwork Mon Nov 29 01:57:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12643291 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 2B1DBC433EF for ; Mon, 29 Nov 2021 02:00:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240621AbhK2CDl (ORCPT ); Sun, 28 Nov 2021 21:03:41 -0500 Received: from mail-bn8nam12on2099.outbound.protection.outlook.com ([40.107.237.99]:52576 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231578AbhK2CBk (ORCPT ); Sun, 28 Nov 2021 21:01:40 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SRGLc8mD2x0yiiV1mcX1eW3YLHtP0guY/4Nt11yr+8+03TAgag6UVZNuYf4XH9BooLeYjyZim5pLoOkkBHvUIfpaxi5ZJsaItDy530LQT2YGKhkueR4tcrXFxLsfNeweWWf52C9eyTo3R8Jya3EWe2CdX9dzffGTnY2Vi8g1GcyQXdSUtR+oKzbAR8z4/JpSrnfg/Edm4UcyYiAibyie8CKV5NhyXNxeBjGt6scAsiTqIBgvpUI95+2SfIJYEpg3KAkHRNj3o8MzkjSu+ri9GhmcapFh4QFZlUVpuF/8da1eL7E9Nj9CrfHWf31p/fjapoDNyJWoXpXjfLdGrG01Mg== 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=G3lKtXASmqFGMg7xuzV0I0WpD4SBZ2FZiF9Gqqe9yiI=; b=IRUJle273W46uvdbFPhitUiGlsu5tmXMynOMsTFMTFHiDi68Pdrfru6pd6NwkOzIA7/YjTiTQAJ7xVGWaIXhJk0C5zmWyYQGth9fDgn0Y0xtvRQHNsAciI3jfUSxo9n/BeLMrXHnLYfxJ0l+UbKiaNsaLBtVbwzSTsqq8s81vigX4arO0KCQPeFLEjHVojUshvKsj3qmpBWS+8KMbJVve4JxkUP+nOK+UGZLOsuk54DaIo8OaHeX3DwfeMT6kbVxmox59gSZDKs0syD7d+q2cwE9jW0JwBtMPmbuRtLKXOayqyHGzpqb+8HQ+3rmCi8Uh2S+C9TMUtZZc4nSKgi2yQ== 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=G3lKtXASmqFGMg7xuzV0I0WpD4SBZ2FZiF9Gqqe9yiI=; b=eFLJaq5xEB5D/GweSBrwrMzWpHJvSpigcNNFg0XCp5z7zsgyOrC5piZEP65aoZBJvtHECJsPWF9rIfhn6xh4MLyjCgUwBrMcSDaJDs75TqGAgt4zr0BeTKwc5ktvHJvX7xmHFHFj3FAKIHkCjnYidUvEgFzNCgPE/TYkI/2zdNw= 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 MWHPR10MB1341.namprd10.prod.outlook.com (2603:10b6:300:20::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.24; Mon, 29 Nov 2021 01:57:48 +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.023; Mon, 29 Nov 2021 01:57:48 +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 v3 net-next 1/3] net: mdio: mscc-miim: convert to a regmap implementation Date: Sun, 28 Nov 2021 17:57:35 -0800 Message-Id: <20211129015737.132054-2-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211129015737.132054-1-colin.foster@in-advantage.com> References: <20211129015737.132054-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0050.namprd04.prod.outlook.com (2603:10b6:303:6a::25) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 Received: from localhost.localdomain (67.185.175.147) by MW4PR04CA0050.namprd04.prod.outlook.com (2603:10b6:303:6a::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20 via Frontend Transport; Mon, 29 Nov 2021 01:57:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6bf049fd-f75a-4425-01a9-08d9b2dba4a1 X-MS-TrafficTypeDiagnostic: MWHPR10MB1341: 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: az8jSekGbqESnzYAUIBYu1rv+AstonqhT18W45em3dgih4Lxk3FZk8u6avMc2TblaxkvucAv9SXr30AgkmcrmWS+I8xu5T/AiNr1LPz7YPgT+50+gAKtLmqsaR0xF9GZk6qoukDOt6j5CQEIr0LA67Eyf38NRpvwRRiIgPMC7RmMbA3LpIZ0x3JY8J3wtm2OyO/1uIsduNOv9pJLfg7RC04F2BVLOzPXedLmEzedSknqoU1224/PXKv/gYb9WHoARbVqssvS9mUpaZB62gnmcfiPkWh109yD1Vn8ql/6UvrDSVnoF1Nr5RHUZfwJEJKj5SyydWvT44XwOiLrs0T5ORE1GAyB1E0W/CsrpSVk0bF+lp9veG089HYyst4qLsqdseKjrxum1rxS21nh+A63aUwyWg667/7wL4H9wlDtpAJdm90hGlbuLdgO0lBaEOpPMH+wERG+PE76bhIOe1HKkpG3xa0hmI7ieL52lYVgXJ3xuaI+jL7B2DecNZO8775lWV3vgrzcFRGtnzp3XdZ7rvEcoUjBtmreEnGuyET+bI6t/dQGq9yCuKITTH/Pb/b9zYZ1C2LNi27SwJSt8gYsEvGEtXWd73i8pV4HNsqqbd90ryp5P29pOfM3L/P0GfzljbR8lw5XfZhleNkV3BQkEa1B9jfQVlgO/ZQw91hlplRuRmMQ+j8l3RrzPuLDRnezbIzmu2YIdKp8Jnrkvo07bw== 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:(39830400003)(346002)(396003)(136003)(376002)(366004)(26005)(66556008)(66476007)(66946007)(38100700002)(38350700002)(186003)(8676002)(316002)(83380400001)(6506007)(8936002)(2906002)(508600001)(36756003)(6486002)(54906003)(4326008)(5660300002)(52116002)(6512007)(44832011)(7416002)(6666004)(956004)(2616005)(86362001)(1076003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Sk38gO0wlbg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V3sdx+LjuKhgaM9bWekVSTrBe0qwQM9MR3RWJQkLjWZfISoo5by+8C9VOs3nDIr+Y99KrWRAaB4qUnZscbB+rKhO2W0l980SAlkjDXojGZn1kvVDOsP5Qo4xw/Uoy2JBeOdS4HYc64S7T5kYiUOimWVCQfAFkph2cgUE9U3JItoyOPOZRQPazqfxFGg26pPJXCc3TxZrzb6eSutRVXX98gb+n6dYQr8+qm8jUPBWIMXigiQBXIbakLhesj4bEFhkd8ir1XBBS5epES1kqIqG2tYTyuD9UDBmGe2n48pdRF9XhvOJZbMMgNYgoUvmYzVmYmbLbNuJ6va3dSPVQkDDWQutfpCPe/qf9h7rd0FvXig3XuoH4oejFYg1Wg2H9JXMvIgYq6Rm8FoYz/xLl5CPLnRGJle0AurdpjJ9NMdYQIpAMWXFypImYj+qZBU4T/pQn0DuQIcbzpRO/ai1TnGwE4v3fYjD3CeS4OlgA+rKJFqg2wFN4YHbdDRDp69N/rja9NGZkXxv5HetkFwnWQE+pTrlCA+jB58PBtUdNHJLl86bQ0dqJdwhqTyH5kIEuozzVBXFw== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6bf049fd-f75a-4425-01a9-08d9b2dba4a1 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2021 01:57:48.1211 (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: pXLUpPk65hJY8kOc0qUBjwDJrW2tr2tT43zDKOjdShJHo+ojiPxUijuk0AthzmkxucI4TJICPdCNB2V9w8sZJcKueNSQqq9fX+W4ueifHoc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1341 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 | 163 ++++++++++++++++++++++-------- 1 file changed, 121 insertions(+), 42 deletions(-) diff --git a/drivers/net/mdio/mdio-mscc-miim.c b/drivers/net/mdio/mdio-mscc-miim.c index 17f98f609ec8..e016b32ad208 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 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,26 +190,62 @@ 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; + + 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 *miim; + 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(phy_regs)) { + dev_err(&pdev->dev, "Unable to map internal phy registers\n"); + return PTR_ERR(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(phy_regmap); + } + + ret = mscc_miim_setup(&pdev->dev, &bus, mii_regmap); + if (ret < 0) { + dev_err(&pdev->dev, "Unable to setup the MDIO bus\n"); + return ret; + } + + miim = bus->priv; + miim->phy_regs = phy_regmap; + ret = of_mdiobus_register(bus, pdev->dev.of_node); if (ret < 0) { dev_err(&pdev->dev, "Cannot register MDIO bus (%d)\n", ret); From patchwork Mon Nov 29 01:57:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12643287 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 C21BBC433F5 for ; Mon, 29 Nov 2021 01:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235473AbhK2CDM (ORCPT ); Sun, 28 Nov 2021 21:03:12 -0500 Received: from mail-dm6nam12on2124.outbound.protection.outlook.com ([40.107.243.124]:33505 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236845AbhK2CBI (ORCPT ); Sun, 28 Nov 2021 21:01:08 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F/by+zlerkSpdM8G6uIFMO/ZPuY1OLx7kwmPnnW3Sp5Ry4Fm3GTozFn8vM3jOdMsE4hmrAelNGEN2nFmjNjjUixq/pNq+sWEJ2xYCdxWqdY/HRIQoO+XaexPZute7WJsjUUZ/RkK41ExO2Pdu+xTRO8a3zh27rEf+9sVFiKowe5ZuZ0OXM8Y6OjqR3Brjz54nsiEgLyVEKl8bDhAGzlNIPYtJ4X81IOBP3wOhxlp5yyM/kJA8rqk7R61BkVy13nyv/PEBK27xWEN+T/GeCismKpUOLE6nhmMmqgFljwC48KC0y/O5S/ORem1n5DzSMm3S68Y8C2lYfBTgb0OS625fw== 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=Bh7cACjzxCrm27bR9NUkHajiXgmcNvqqUiTeVbN2pIo=; b=IdG42k5Tg9H3kaREZ9v6baUtlQbrv5r2wWfLj4jqcMjvTXFFfIZB7/uA6HctKER5/k7QAkXd45nQXKBzGSiPBBKYaIExkuj05BXAWHwgnQ3V7nOo/iEJEbr06laKfZsG3MpwBOlRWYD1mGjlud5ndFz2cpvfVlGbCVhQ1CBqNq1Zu15ku1IC89G/ukXVyHAzHbxeZs+ctKDIz5Xly1Us0mwREGQpHmBlxmTGTRB9I8hh71kX8gjxiGNVpNvqO5cAm53/94HH2sX/ximD4iLWgQsnypAeYA10QT2hLxstdYCs2UYMd/Elsf0l0bFKstueAptFMm7PlFzha3lK5CI+wA== 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=Bh7cACjzxCrm27bR9NUkHajiXgmcNvqqUiTeVbN2pIo=; b=MAp+1t5slAOI5T2loT++HfAMJHaOOcY8GkoYLM4U7zAyBWwJqbtdb1vNQivK4hyGO+iQJ83alka4UX5ykO1KoqlWwkEjuQLFGnGYAPsQaOn8p18zhDzvOF1GKPCVCovNhWUzMzGwfekAqpwmIzALZAeyLbqQ6F4qWJccYUb1Ahc= 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 MWHPR10MB1341.namprd10.prod.outlook.com (2603:10b6:300:20::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.24; Mon, 29 Nov 2021 01:57:48 +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.023; Mon, 29 Nov 2021 01:57:48 +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 v3 net-next 2/3] net: dsa: ocelot: seville: utilize of_mdiobus_register Date: Sun, 28 Nov 2021 17:57:36 -0800 Message-Id: <20211129015737.132054-3-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211129015737.132054-1-colin.foster@in-advantage.com> References: <20211129015737.132054-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0050.namprd04.prod.outlook.com (2603:10b6:303:6a::25) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 Received: from localhost.localdomain (67.185.175.147) by MW4PR04CA0050.namprd04.prod.outlook.com (2603:10b6:303:6a::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20 via Frontend Transport; Mon, 29 Nov 2021 01:57:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 97eb868d-7aae-40f1-f1be-08d9b2dba507 X-MS-TrafficTypeDiagnostic: MWHPR10MB1341: 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: ghOlvo7Ors/jwQzZkNl1kP6dudSTq2MGFJB8k4EuruCYrFDlDcAjrKxZE8nZbN2fisON+AQdixFVFTK4gchA2ElglawTTpglqgEoOGzyZudaRIcXeTu3IIA8aqukA17/ysEOWSZHTO9IIVlkvj14cAMJbxa+azoZCgNi2s/N3He1TmGTMzhxBAWgVhn44tOUD8ABG3CG0DEfq/7wZKaoAXWiR9RKHxFyAAPGe1SF/tOgLrZjxtLiINOvp8muRAq0CkRCEFY7m71aGAiCezCPP5/SvLXlP3MbGcWYA70AA5Ou+RGLz/7fIoeSvEBmNOyzXBdy6iK4HgELmoxxiYVGXm+HvxI3LtHdTcBd4AdOJ8zcevEpWMOC0kkdlcbo0gCHDBuY4qr1GVKgSmyqyDxOZt/LZkEnRcVzyRtrL81khmGXymWoOkSqghlqqy4HsjyNyndb2WvMz6nxARglT4ryigBFop5BAhXQc1UZJOHYyuyBaYYQnYw+tB0xqMBZO+FeYLfEKPAFdWiR+l+RnB/r3NieJ6LGTOWxDHYVorLh6wF4j4AoTjy2t2hF2KTnjxFwZgzlFRAl5loLLQVV0OLpu2gsnyiVycy3KYeBqssLp6aOhf6FPCkX6LiyFf2reStLFHdaaaBaf2BGoCROr2Yq8ez0UTOVuJZCrPm4D5xq/vRW0JGZu7hRF/Id8L8DwLubhzg1Hp0k44viCcvND2ILIg== 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:(39830400003)(346002)(396003)(136003)(376002)(366004)(26005)(66556008)(66476007)(66946007)(38100700002)(38350700002)(186003)(8676002)(316002)(83380400001)(6506007)(8936002)(2906002)(508600001)(36756003)(6486002)(54906003)(4326008)(5660300002)(52116002)(6512007)(44832011)(7416002)(6666004)(956004)(2616005)(86362001)(1076003);DIR:OUT;SFP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MDLWjlrkNSxoje7Bir2pShiaqS3CcmcUtKCWpk+uiR80wF7Lblmo/ROQvKhUqcNqLMNX5t9JMOUYD5LqqCnIQdHWZBMHMq9RqV/PHmVmI0AbQhwoPKLhvjwPfHvWWmqI8cXEYIvaBz4qTgBAH+wB61TAPl5aVhl1Zo3UPWnPc+Z4RqyboNpvqogVctdsPuZwSZKhVyrrUsDE/2nfvtYs2xAIPif0Tj3VVxiIXTV0+qIjDRczJ7fo+bNpnfqnFHllYKhUe9fnjcZqh7ueAZ2aPtL7y2t8CitaFq8tUOKzzk7LuoYyj5kt7/P4x9xyktuKaKQGvFUJ15cR2fUBtJmTMKjswsgJfV9KATXRlnXcGJwWjbLq8keU6eYQdwex7koBRyTKlTiF+LrSF1dc7SAiNpJHB36zNB39Wy6diVEMMxoHBwuWHXg3+IUiWKOUN8eq3xHUs8gQKFv9FbSEmPr2+gUlIZe9R90nPwVMS1ddJqUiAtwVTPNxRNWotZGYD/e6ERRiS4XmXKcRMKzEalTVUOOZO11pZbDIZdcfi3cIpiKqcx0OnCuB4zfKOaEO8dSrcQxJvpfZp1bsYu51cNq8WHDVIr3eGC9GqdBnVwrIPBWEiX0Qn2w7y24Od+ssY+SPI5Jl5dDLcmsp4L6//iHOz5J09Stw== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97eb868d-7aae-40f1-f1be-08d9b2dba507 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2021 01:57:48.7897 (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: BrqS6L33yn97Jp3n/K+ndswyjowkQLxkDnWvPuNZUbE/+cd4NMCq7/nE16u6m479kWNEzpI0ED0pv3RieImzRkKuzNBGpRJVUo29kyza6xM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1341 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 Mon Nov 29 01:57:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 12643289 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 EED76C433EF for ; Mon, 29 Nov 2021 01:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236262AbhK2CDM (ORCPT ); Sun, 28 Nov 2021 21:03:12 -0500 Received: from mail-dm6nam12on2100.outbound.protection.outlook.com ([40.107.243.100]:5222 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237230AbhK2CBK (ORCPT ); Sun, 28 Nov 2021 21:01:10 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kazeyUV25LYpksdH0iR0RMJX93fvbFEG7JFJhwd6X/8/HvNnmMyJqOLHfSTcDfkRKKazXQVVJlacw1I0o1w5OKXTC8A6b1purp3mgoKEMuFogirE07jG10d/gf1FwbqDgHvZAejtPQzNdGrjtzkNVmnRatFcHPh9KViGtt0zJGolLQxDXOAQc56eWCd96/5G9nR4tg8B5ClcB/SKeImwEQLxxlKK0WhvixXg8l5fXzQ43suFPjzTXF3GAxtO7xbAdhmrpIrX3VOi4KSjVVXfr+1RsgoN56yMvIkHNDz5+g1ugZO6hInDEiA9CPEpE/Vu3NcCVqxFBcYOVp8tHR2ktg== 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=CP9XDjMnA8A50o4nMnNI4GRkmkdUskkRw6IH8GWw3GE=; b=DN3i66HoHCOuX8lqhEi5mvHCV8/5sWpGyL/meUinIGJzYq36CntlqvVF+yKAyLR9ofk5droY3IkgHpW0Bsx46QDSaNAx8QLLsG//9/UtbW3RdjsNowL8nxV8nyqyjskjqEYmdtPHEo8FC+WeX8hlBkks1z59674TTnOYvG5OEdriG4r2DK7FnKVl22PNmlLjzVLHXV9fcXWvIXEPavYwAcL+7IwqP4Ji6ecEfDeZV5m7W3O1YV0+KkrnxGw88c/dKdfEhq+E3of5y5X0haXcTqUvdEXivNKtIdd/xvgPj6RwF2vtisOGa8DqdHzZ09leIY3ir5WHcRSK8a7ACnbZZQ== 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=CP9XDjMnA8A50o4nMnNI4GRkmkdUskkRw6IH8GWw3GE=; b=zNgNnDUOAm2vGEETI2F1KVjvFLwnH2FuVYbky1E+ywqVgIrkVXY4JpIasWagCpcitco4niFSG2sX7bKW7Ymu7RRn6LjMBmcfGa52XyywtGi5sjzRmSeyDvgqyDk1fR3C1+BDohyeKfmXtPF06dYeI6RuBd1ptrwWPm2z8WKvUD4= 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 MWHPR10MB1936.namprd10.prod.outlook.com (2603:10b6:300:10c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20; Mon, 29 Nov 2021 01:57:49 +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.023; Mon, 29 Nov 2021 01:57:49 +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 v3 net-next 3/3] net: dsa: ocelot: felix: utilize shared mscc-miim driver for indirect MDIO access Date: Sun, 28 Nov 2021 17:57:37 -0800 Message-Id: <20211129015737.132054-4-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211129015737.132054-1-colin.foster@in-advantage.com> References: <20211129015737.132054-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MW4PR04CA0050.namprd04.prod.outlook.com (2603:10b6:303:6a::25) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 Received: from localhost.localdomain (67.185.175.147) by MW4PR04CA0050.namprd04.prod.outlook.com (2603:10b6:303:6a::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.20 via Frontend Transport; Mon, 29 Nov 2021 01:57:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fd0e4b96-c736-451c-f3c2-08d9b2dba566 X-MS-TrafficTypeDiagnostic: MWHPR10MB1936: 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: CzBXFEnqxEtsJrLc1pyV+kbEctPDKo1asmvsqXTEc/JHo7uVraRxXlzkKBmphXcDWBzW7+CzFR9yjM6kKMtHt1Smv1pHXOenwrG4XjVzwuqYq9YQ3gy1SlEMT+7dIp2yMlcttQbFgjPChaPKULi4fhz4Ueh671GlW7HhLiM+FQWQETm9AnQSJ5BbJbsTXmoNLfcQ8TNs/F79jIAFO3si3//GYVmF8ZUGIgmbK1aUGRxfaKZmOKg2ZOatz4ZqB2Cf6oiKcZcFRypcdVBVx0egrW13yswbuYi8Qq5Y3r+KcdrJzQBSx8cqG2sqqR/ezG9uQj7CDAcYHHPd4xewiyNffXGncyTKllOFY8m05rQauFD2AMLHRbfMyzqgkiFpWA7500zhRo0kngv0uHPApr1fRPf+lXx2O6Gs5kwxNxGJnlqkIo61AZpSW4GydoElzwHwUH1b4rDHltj44QkdLlXskdSGDkx7D5LB5oaNhEsBWtuIXUu+Jl6sAWFnS6r1CU+V+tsel0oETOf6waxoUoGYjBMFRu9jqBNVnBOGt5gw4iJU9kVGNs9FtEUdwpsyoQJMUkV/uNpnxHV4tsBvYb2mTap8cmcG0Q3144YQPBk04EoE11nst0aftugeJC/qRteml1KaaQadPmlCG1TlaG8xJT0ouzjg0AVaeGXp4VJbCvArERdnDyaJXuh3OUarrLdSw9SP8sBwdVs4NNW45atU5A== 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:(346002)(376002)(136003)(39830400003)(366004)(396003)(83380400001)(52116002)(66946007)(6666004)(86362001)(316002)(44832011)(38350700002)(38100700002)(4326008)(26005)(508600001)(2616005)(8936002)(36756003)(2906002)(956004)(54906003)(8676002)(6506007)(186003)(66476007)(1076003)(6486002)(5660300002)(66556008)(7416002)(6512007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1Sg5bO5SyTGCFEXHCzqTQ8+jc/sNjBEn0ITsQbqspZARoE+eE2ELAvJ4lsKtpOIrv0x2L5kR9grkjr88u29OhGVjrHXu0BPQHhAdDQ87y6uh7z4yq/jmyi3KIpECYVCjB0KJNt0PZUR9PRLUnC9bqTxdIHApHCdVAFf5sUujFwxmWUdyf1QcWE//NdPZfxf9xHHewkOocP19Qccr/LSIHHdHgzZWvPhFq8ZtofySPPOBMfw53FQbjfPWKuwzSJf+djFqCN0YB5Zat/2XkOaJaoGEg89qF5Heu+3SkdP4AO00OC1S7s3mFvZMwwNr0TkgzHhf6HjRTNiAufj2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+9QZYZ6yjBZvIPzvX5nYIKGRRpTFH8NUnwJHWti7Erav3pufjG7L/7KqPDwoUxM34Aiu4pmrihvG3Zc3lhFRJajUN+56shBgknxlvxFz3Qo1KvnKoax71ZpOMh1YfucbNMqHb2IoYbLe021aCslIRPWisoYflMiX+FNHl7PI8ZmSpvaDR/d3VVEeLGCuqtXE9zel5IGbJ1GBxgATKlGI5zabTwe1FTzsz9O40C6dJf8G1ElzR+V80fe+GufD8y+xPw1MUoD5ONw== X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd0e4b96-c736-451c-f3c2-08d9b2dba566 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2021 01:57:49.3934 (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: tCVERA5zkY45vgmcT2LO+yVySGbtvorMvGpcHp25XZndsbLtpU43AyhwZeWb4KU2O5G3GcoPW80MOPp3n5uWK6SpAr+R4I3fUk0nzAUjEaY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1936 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 | 102 ++--------------------- drivers/net/mdio/mdio-mscc-miim.c | 38 ++++++--- include/linux/mdio/mdio-mscc-miim.h | 19 +++++ 4 files changed, 56 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..b9be889016ce 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,14 @@ 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]); - 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 e016b32ad208..2d420c9d7520 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,8 @@ 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) +int mscc_miim_setup(struct device *dev, struct mii_bus **pbus, const char *name, + struct regmap *mii_regmap, int status_offset) { struct mscc_miim_dev *miim; struct mii_bus *bus; @@ -186,7 +197,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,9 +209,13 @@ static int mscc_miim_setup(struct device *dev, struct mii_bus **pbus, *pbus = bus; miim->regs = mii_regmap; + miim->mii_status_offset = status_offset; + + *pbus = bus; return 0; } +EXPORT_SYMBOL(mscc_miim_setup); static int mscc_miim_probe(struct platform_device *pdev) { @@ -237,7 +252,7 @@ static int mscc_miim_probe(struct platform_device *pdev) return PTR_ERR(phy_regmap); } - ret = mscc_miim_setup(&pdev->dev, &bus, mii_regmap); + ret = mscc_miim_setup(&pdev->dev, &bus, "mscc_miim", mii_regmap, 0); if (ret < 0) { dev_err(&pdev->dev, "Unable to setup the MDIO bus\n"); return ret; @@ -245,6 +260,7 @@ static int mscc_miim_probe(struct platform_device *pdev) miim = bus->priv; miim->phy_regs = phy_regmap; + miim->phy_reset_offset = 0; ret = of_mdiobus_register(bus, pdev->dev.of_node); if (ret < 0) { diff --git a/include/linux/mdio/mdio-mscc-miim.h b/include/linux/mdio/mdio-mscc-miim.h new file mode 100644 index 000000000000..5b4ed2c3cbb9 --- /dev/null +++ b/include/linux/mdio/mdio-mscc-miim.h @@ -0,0 +1,19 @@ +/* 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); + +#endif