From patchwork Mon Dec 18 09:18:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 10118559 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2A79160390 for ; Mon, 18 Dec 2017 09:20:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 222EC28D31 for ; Mon, 18 Dec 2017 09:20:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1672B28D9A; Mon, 18 Dec 2017 09:20:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 863E128D31 for ; Mon, 18 Dec 2017 09:20:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=VrCSIBok9MqPy55eGkEl506wGtD95liGAsAg3tzReSg=; b=lX6YP0GtFwmV4GjHm8vK068WrK DARopxsjHh06dnIufCb/6KpiUw8Sr4rxZl83PBgxo0u0o7KKaTeec7J2rGLsoTrPvWqLoq5r1ToQJ MEaUyj95LEHVWpLp5jxzhFfApdWbtCrQ6oeutfD1CEvyd3a77ZhpxwN1aT6ExCvqFBNVFML1d1rUx uLH4YqelZyQRlQXm8pAE0yZSgvUDc+23FAfMfFHmwUmZCzNv50CfNE/bxhS1lA/WoG235TRmJeR65 7sowR4d2XO4GfIXjbWRB6zfIcAHxe7jr8Bxmn8N+GUjdD7zaqE5ijF7HIl0Lg4NqdQMSfPktqbnIB zQ0fU8VA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eQrbO-0008SC-Oa; Mon, 18 Dec 2017 09:20:50 +0000 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eQrZI-0005M3-Jg for linux-arm-kernel@lists.infradead.org; Mon, 18 Dec 2017 09:18:52 +0000 Received: by mail-lf0-x244.google.com with SMTP id a12so16946251lfe.4 for ; Mon, 18 Dec 2017 01:18:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yFKH4iPXd/4r5YtctdJLRHkSGyeJeMMi1Ybj5jbDS+g=; b=JUPDIbXlni0Dw/OMZG+R96hQ34syUnY/gIdLkTboRQCLPzbir8BCduuvvXy2+Dxx25 0L/TblUUygRB4sXKxS1lN4pJXXU5PNHw8zH507hnpWRc8Pu/b0YoIdRzL+YGYQw9hSGP X2Na0+4i57S+ujL0vAMjzUMPExtud5FiwlIYxjCyg9cPcdZJH8gP+sxOD/iaBiD9m668 k/RFEIN51ClCi6H9rBBsLdmkriFOmnFHWO9I1+quytwqsCMwX5ZrX6/s18HQzGa9gulX EjfPb6L+QA/29rcVF/OhHzZtXvtJbblyEPtmDlPTcHvu3MmzLS+XMW5RgkaqODJBCee+ TN/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yFKH4iPXd/4r5YtctdJLRHkSGyeJeMMi1Ybj5jbDS+g=; b=C2igHxnk3gE3SH2109px6ROpvoGJ/0b2r6jDadFyaYY4WlYunv0OaejcZVRKWD+Uub OlBXmR1Qf0vKArrIFc0cNqMXp2MmOKXC6atNrbuYp0S+I+UNgtFWq5gLMia8bV9PkqE/ ZRfkGpyWqvMKy7MRltlVpT9NZbnNsrqViMrNard8RgA4QfZkxiSiyDryEjWB6HuDnBEq OpWsI/5FwcKZU79pF0CXMHV+KxOFx4DxWRSlHbl+ncuTLqWUl2E8vPFuPp3P2sjYDGDl bqpt0Pkz/Q2cShcHiNC7hC0JVQFw7z1leXGJpgu9Jg1OEIImyVZJLIMWRv1ODZ/ZYQO+ dq3g== X-Gm-Message-State: AKGB3mLmZt35hwWigifW8RYl+zaQ4olROojVqRfvludREwrsU+9JsxZj ocxRqdXgyeE26lZCnlAVL9UC4w== X-Google-Smtp-Source: ACJfBov9JYL1Vmvwvg2Z3RvapYhNemVaMw+cnPzfvXcUpKCuLFAVfMOQ7seUhF5LvrIbXjNUmFbL+w== X-Received: by 10.25.21.11 with SMTP id l11mr9296634lfi.142.1513588703151; Mon, 18 Dec 2017 01:18:23 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id r16sm2407186ljd.18.2017.12.18.01.18.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Dec 2017 01:18:22 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Subject: [net-next: PATCH 7/8] net: mvpp2: handle PHY with its fwnode Date: Mon, 18 Dec 2017 10:18:03 +0100 Message-Id: <1513588684-15647-8-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513588684-15647-1-git-send-email-mw@semihalf.com> References: <1513588684-15647-1-git-send-email-mw@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171218_011841_755046_A91201D8 X-CRM114-Status: GOOD ( 15.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.petazzoni@free-electrons.com, andrew@lunn.ch, f.fainelli@gmail.com, linux@arm.linux.org.uk, ard.biesheuvel@linaro.org, jaz@semihalf.com, antoine.tenart@free-electrons.com, rafael.j.wysocki@intel.com, nadavh@marvell.com, neta@marvell.com, ezequiel.garcia@free-electrons.com, tn@semihalf.com, gregory.clement@free-electrons.com, mw@semihalf.com, davem@davemloft.net MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Newly introduced mvmdio driver ACPI support and also fwnode MDIO helpers allow for switching to PHY handling with its fwnode. This patch replaces of_* related PHY handling function with the fwnode_* equivalent and updates mvpp2_port structure accordingly. Signed-off-by: Marcin Wojtas --- drivers/net/ethernet/marvell/mvpp2.c | 41 ++++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c index 537474f..4e61ce7 100644 --- a/drivers/net/ethernet/marvell/mvpp2.c +++ b/drivers/net/ethernet/marvell/mvpp2.c @@ -963,7 +963,7 @@ struct mvpp2_port { struct delayed_work stats_work; phy_interface_t phy_interface; - struct device_node *phy_node; + struct fwnode_handle *phy_fwnode; struct phy *comphy; unsigned int link; unsigned int duplex; @@ -6890,14 +6890,22 @@ static void mvpp21_get_mac_address(struct mvpp2_port *port, unsigned char *addr) static int mvpp2_phy_connect(struct mvpp2_port *port) { struct phy_device *phy_dev; + int ret; /* No PHY is attached */ - if (!port->phy_node) + if (!port->phy_fwnode) return 0; - phy_dev = of_phy_connect(port->dev, port->phy_node, mvpp2_link_event, 0, + phy_dev = fwnode_phy_find_device(port->phy_fwnode); + phy_dev->dev_flags = 0; + + ret = phy_connect_direct(port->dev, phy_dev, mvpp2_link_event, port->phy_interface); - if (!phy_dev) { + + /* Refcount is held by phy_connect_direct() on success */ + put_device(&phy_dev->mdio.dev); + + if (ret) { netdev_err(port->dev, "cannot connect to phy\n"); return -ENODEV; } @@ -7047,7 +7055,7 @@ static int mvpp2_open(struct net_device *dev) goto err_cleanup_txqs; } - if (priv->hw_version == MVPP22 && !port->phy_node && port->link_irq) { + if (priv->hw_version == MVPP22 && !port->phy_fwnode && port->link_irq) { err = request_irq(port->link_irq, mvpp2_link_status_isr, 0, dev->name, port); if (err) { @@ -7082,7 +7090,7 @@ static int mvpp2_open(struct net_device *dev) return 0; err_free_link_irq: - if (priv->hw_version == MVPP22 && !port->phy_node && port->link_irq) + if (priv->hw_version == MVPP22 && !port->phy_fwnode && port->link_irq) free_irq(port->link_irq, port); err_free_irq: mvpp2_irqs_deinit(port); @@ -7107,7 +7115,7 @@ static int mvpp2_stop(struct net_device *dev) on_each_cpu(mvpp2_interrupts_mask, port, 1); mvpp2_shared_interrupt_mask_unmask(port, true); - if (priv->hw_version == MVPP22 && !port->phy_node && port->link_irq) + if (priv->hw_version == MVPP22 && !port->phy_fwnode && port->link_irq) free_irq(port->link_irq, port); mvpp2_irqs_deinit(port); @@ -7745,11 +7753,11 @@ static int mvpp2_port_probe(struct platform_device *pdev, struct fwnode_handle *port_fwnode, struct mvpp2 *priv) { - struct device_node *phy_node; struct phy *comphy; struct mvpp2_port *port; struct mvpp2_port_pcpu *port_pcpu; struct device_node *port_node = to_of_node(port_fwnode); + struct fwnode_reference_args args; struct net_device *dev; struct resource *res; char *mac_from = ""; @@ -7779,7 +7787,6 @@ static int mvpp2_port_probe(struct platform_device *pdev, if (!dev) return -ENOMEM; - phy_node = of_parse_phandle(port_node, "phy", 0); phy_mode = fwnode_get_phy_mode(port_fwnode); if (phy_mode < 0) { dev_err(&pdev->dev, "incorrect phy mode\n"); @@ -7814,6 +7821,17 @@ static int mvpp2_port_probe(struct platform_device *pdev, port->priv = priv; port->has_tx_irqs = has_tx_irqs; + err = fwnode_property_get_reference_args(port_fwnode, "phy", NULL, + 0, 0, &args); + if (!err) { + port->phy_fwnode = args.fwnode; + } else if (err == -ENOENT) { + port->phy_fwnode = NULL; + } else { + dev_err(&pdev->dev, "unable to parse \"phy\" node\n"); + goto err_free_netdev; + } + err = mvpp2_queue_vectors_init(port, port_node); if (err) goto err_free_netdev; @@ -7836,7 +7854,6 @@ static int mvpp2_port_probe(struct platform_device *pdev, else port->first_rxq = port->id * priv->max_port_rxqs; - port->phy_node = phy_node; port->phy_interface = phy_mode; port->comphy = comphy; @@ -7958,7 +7975,7 @@ static int mvpp2_port_probe(struct platform_device *pdev, err_deinit_qvecs: mvpp2_queue_vectors_deinit(port); err_free_netdev: - of_node_put(phy_node); + fwnode_handle_put(args.fwnode); free_netdev(dev); return err; } @@ -7969,7 +7986,7 @@ static void mvpp2_port_remove(struct mvpp2_port *port) int i; unregister_netdev(port->dev); - of_node_put(port->phy_node); + fwnode_handle_put(port->phy_fwnode); free_percpu(port->pcpu); free_percpu(port->stats); for (i = 0; i < port->ntxqs; i++)