public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Stefan Roese <sr@denx.de>
Cc: "Robert Marko" <robert.marko@sartura.hr>,
	"Pali Rohár" <pali@kernel.org>,
	U-Boot-Denx <u-boot@lists.denx.de>,
	"Ramon Fried" <rfried.dev@gmail.com>,
	"Joe Hershberger" <joe.hershberger@ni.com>,
	"Marek Behún" <marek.behun@nic.cz>
Subject: [PATCH u-boot-marvell 04/19] net: mvneta: Remember fixed link instead of PHY address in priv data
Date: Wed, 27 Apr 2022 12:41:47 +0200	[thread overview]
Message-ID: <20220427104202.1205-5-kabel@kernel.org> (raw)
In-Reply-To: <20220427104202.1205-1-kabel@kernel.org>

From: Marek Behún <marek.behun@nic.cz>

We don't need to remember PHY address anymore, because since using DM
MDIO for connecting PHY, the address is parsed by mdio-uclass from
the ofnode.

But the driver uses a special value of the address to signal fixed link
usage.

Drop phyaddr add fixed_link in driver private structure. This simplifies
code a little.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/net/mvneta.c | 23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 24a491dcde..83e9629138 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -277,12 +277,12 @@ struct mvneta_port {
 	u16 rx_ring_size;
 
 	phy_interface_t phy_interface;
+	bool fixed_link;
 	unsigned int link;
 	unsigned int duplex;
 	unsigned int speed;
 
 	int init;
-	int phyaddr;
 	struct phy_device *phydev;
 #if CONFIG_IS_ENABLED(DM_GPIO)
 	struct gpio_desc phy_reset_gpio;
@@ -576,13 +576,6 @@ static void mvneta_rxq_buf_size_set(struct mvneta_port *pp,
 	mvreg_write(pp, MVNETA_RXQ_SIZE_REG(rxq->id), val);
 }
 
-static int mvneta_port_is_fixed_link(struct mvneta_port *pp)
-{
-	/* phy_addr is set to invalid value for fixed link */
-	return pp->phyaddr > PHY_MAX_ADDR;
-}
-
-
 /* Start the Ethernet port RX and TX activity */
 static void mvneta_port_up(struct mvneta_port *pp)
 {
@@ -834,7 +827,7 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
 	mvreg_write(pp, MVNETA_SDMA_CONFIG, val);
 
 	/* Enable PHY polling in hardware if not in fixed-link mode */
-	if (!mvneta_port_is_fixed_link(pp)) {
+	if (!pp->fixed_link) {
 		val = mvreg_read(pp, MVNETA_UNIT_CONTROL);
 		val |= MVNETA_PHY_POLLING_ENABLE;
 		mvreg_write(pp, MVNETA_UNIT_CONTROL, val);
@@ -1173,7 +1166,7 @@ static void mvneta_adjust_link(struct udevice *dev)
 	struct phy_device *phydev = pp->phydev;
 	int status_change = 0;
 
-	if (mvneta_port_is_fixed_link(pp)) {
+	if (pp->fixed_link) {
 		debug("Using fixed link, skip link adjust\n");
 		return;
 	}
@@ -1548,7 +1541,7 @@ static int mvneta_start(struct udevice *dev)
 	mvneta_port_power_up(pp, pp->phy_interface);
 
 	if (!pp->init || pp->link == 0) {
-		if (mvneta_port_is_fixed_link(pp)) {
+		if (pp->fixed_link) {
 			u32 val;
 
 			pp->init = 1;
@@ -1698,7 +1691,6 @@ static int mvneta_probe(struct udevice *dev)
 	void *blob = (void *)gd->fdt_blob;
 	int node = dev_of_offset(dev);
 	struct mii_dev *bus;
-	unsigned long addr;
 	void *bd_space;
 	int ret;
 	int fl_node;
@@ -1742,14 +1734,9 @@ static int mvneta_probe(struct udevice *dev)
 	fl_node = fdt_subnode_offset(blob, node, "fixed-link");
 	if (fl_node != -FDT_ERR_NOTFOUND) {
 		/* set phy_addr to invalid value for fixed link */
-		pp->phyaddr = PHY_MAX_ADDR + 1;
 		pp->duplex = fdtdec_get_bool(blob, fl_node, "full-duplex");
 		pp->speed = fdtdec_get_int(blob, fl_node, "speed", 0);
-	} else {
-		/* Now read phyaddr from DT */
-		addr = fdtdec_get_int(blob, node, "phy", 0);
-		addr = fdt_node_offset_by_phandle(blob, addr);
-		pp->phyaddr = fdtdec_get_int(blob, addr, "reg", 0);
+		pp->fixed_link = true;
 	}
 
 	bus = mdio_alloc();
-- 
2.35.1


  parent reply	other threads:[~2022-04-27 10:43 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-27 10:41 [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Marek Behún
2022-04-27 10:41 ` [PATCH u-boot-marvell 01/19] net: mvneta: Get rid of platdata Marek Behún
2022-04-30 23:28   ` Ramon Fried
2022-05-02  6:48   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 02/19] net: mvneta: Fix 10Mbps speed Marek Behún
2022-04-30 23:28   ` Ramon Fried
2022-05-02  6:48   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 03/19] net: mvneta: Use DM MDIO API for connecting PHY Marek Behún
2022-04-30 23:28   ` Ramon Fried
2022-05-02  6:48   ` Stefan Roese
2022-04-27 10:41 ` Marek Behún [this message]
2022-04-30 23:28   ` [PATCH u-boot-marvell 04/19] net: mvneta: Remember fixed link instead of PHY address in priv data Ramon Fried
2022-05-02  6:48   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 05/19] arm: mvebu: Espressobin: Use DM registered MDIO to configure switch Marek Behún
2022-05-02  6:48   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 06/19] net: mdio-uclass: add dm_phy_find_by_ofnode() helper Marek Behún
2022-04-30 23:28   ` Ramon Fried
2022-05-02  7:00   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 07/19] arm: mvebu: turris_mox: Use DM registered MDIO Marek Behún
2022-05-02  7:00   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 08/19] net: mvneta: Don't register MDIO bus Marek Behún
2022-04-30 23:29   ` Ramon Fried
2022-05-02  7:01   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 09/19] net: mvneta: Fix unused variable warning if DM_GPIO is disabled Marek Behún
2022-04-30 23:29   ` Ramon Fried
2022-05-02  7:01   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 10/19] net: mvneta: Drop one indentation level in mvneta_adjust_link() Marek Behún
2022-04-30 23:29   ` Ramon Fried
2022-05-02  7:01   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 11/19] net: mvneta: Use bool instead of int for boolean variable Marek Behún
2022-04-30 23:29   ` Ramon Fried
2022-05-02  7:01   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 12/19] net: mvneta: Drop unnecessary space Marek Behún
2022-04-30 23:30   ` Ramon Fried
2022-05-02  7:01   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 13/19] net: mvneta: Don't check for CONFIG_PHYLIB Marek Behún
2022-04-30 23:30   ` Ramon Fried
2022-05-02  7:02   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 14/19] net: mvneta: Rename CONFIG_NR_CPUS to MVNETA_NR_CPUS Marek Behún
2022-04-30 23:30   ` Ramon Fried
2022-05-02  7:02   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 15/19] net: mvneta: Convert to use PHY_FIXED for fixed-link Marek Behún
2022-04-30 23:31   ` Ramon Fried
2022-05-02  7:02   ` Stefan Roese
2022-04-27 10:41 ` [PATCH u-boot-marvell 16/19] net: mvneta: Write PHY address just before enabling HW polling Marek Behún
2022-04-30 23:31   ` Ramon Fried
2022-05-02  7:03   ` Stefan Roese
2022-04-27 10:42 ` [PATCH u-boot-marvell 17/19] net: mvneta: Drop fixed_link member from private struct Marek Behún
2022-04-30 23:31   ` Ramon Fried
2022-05-02  7:03   ` Stefan Roese
2022-04-27 10:42 ` [PATCH u-boot-marvell 18/19] net: mvneta: Disable fixed PHY code if PHY_FIXED is not compiled in Marek Behún
2022-04-30 23:32   ` Ramon Fried
2022-05-02  7:03   ` Stefan Roese
2022-04-27 10:42 ` [PATCH u-boot-marvell 19/19] net: mvneta: Drop unneeded macro Marek Behún
2022-04-30 23:32   ` Ramon Fried
2022-05-02  7:03   ` Stefan Roese
2022-05-02  5:39 ` [PATCH u-boot-marvell 00/19] some mvneta changes, cleanups, fixes Stefan Roese
2022-05-04  9:25 ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220427104202.1205-5-kabel@kernel.org \
    --to=kabel@kernel.org \
    --cc=joe.hershberger@ni.com \
    --cc=marek.behun@nic.cz \
    --cc=pali@kernel.org \
    --cc=rfried.dev@gmail.com \
    --cc=robert.marko@sartura.hr \
    --cc=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox