diff mbox series

[2/9] net: dsa: mv88e6xxx: account for PHY base address offset in dual chip mode

Message ID 20221108082330.2086671-3-lukma@denx.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: Add support for mv88e6020 and mv88e6071 | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 24 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Lukasz Majewski Nov. 8, 2022, 8:23 a.m. UTC
From: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>

In dual chip mode (6250 family), not only global and port registers are
shifted by sw_addr, but also the PHY addresses. Account for this in the
IRQ mapping.

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---
 drivers/net/dsa/mv88e6xxx/chip.h    | 1 +
 drivers/net/dsa/mv88e6xxx/global2.c | 2 +-
 drivers/net/dsa/mv88e6xxx/smi.c     | 4 ++++
 3 files changed, 6 insertions(+), 1 deletion(-)

Comments

Andrew Lunn Nov. 8, 2022, 1:26 p.m. UTC | #1
On Tue, Nov 08, 2022 at 09:23:23AM +0100, Lukasz Majewski wrote:
> From: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
> 
> In dual chip mode (6250 family), not only global and port registers are
> shifted by sw_addr, but also the PHY addresses. Account for this in the
> IRQ mapping.

> +++ b/drivers/net/dsa/mv88e6xxx/smi.c
> @@ -186,5 +186,9 @@ int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
>  	if (chip->smi_ops->init)
>  		return chip->smi_ops->init(chip);
>  
> +	chip->phy_base_addr = chip->info->phy_base_addr;
> +	if (chip->info->dual_chip)
> +		chip->phy_base_addr += sw_addr;
> +
>  	return 0;


Again, reviewing first to last, i assume the will be a patch soon
implementing get_phy_address(), and it will have the same logic. Why
not call it here, a default implementation which returns
info->phy_base_addr, and a version for 6250 which returns sw_addr.

	Andrew
Lukasz Majewski Nov. 10, 2022, 5:02 p.m. UTC | #2
Hi Andrew,

> On Tue, Nov 08, 2022 at 09:23:23AM +0100, Lukasz Majewski wrote:
> > From: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
> > 
> > In dual chip mode (6250 family), not only global and port registers
> > are shifted by sw_addr, but also the PHY addresses. Account for
> > this in the IRQ mapping.  
> 
> > +++ b/drivers/net/dsa/mv88e6xxx/smi.c
> > @@ -186,5 +186,9 @@ int mv88e6xxx_smi_init(struct mv88e6xxx_chip
> > *chip, if (chip->smi_ops->init)
> >  		return chip->smi_ops->init(chip);
> >  
> > +	chip->phy_base_addr = chip->info->phy_base_addr;
> > +	if (chip->info->dual_chip)
> > +		chip->phy_base_addr += sw_addr;
> > +
> >  	return 0;  
> 
> 
> Again, reviewing first to last, i assume the will be a patch soon
> implementing get_phy_address(), and it will have the same logic. Why
> not call it here, a default implementation which returns
> info->phy_base_addr, and a version for 6250 which returns sw_addr.
> 

I will squash Matthias patches and prepare new set of them with proper
operation's ordering.

> 	Andrew


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
diff mbox series

Patch

diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h
index e693154cf803..b03f279a673d 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.h
+++ b/drivers/net/dsa/mv88e6xxx/chip.h
@@ -328,6 +328,7 @@  struct mv88e6xxx_chip {
 	const struct mv88e6xxx_bus_ops *smi_ops;
 	struct mii_bus *bus;
 	int sw_addr;
+	unsigned int phy_base_addr;
 
 	/* Handles automatic disabling and re-enabling of the PHY
 	 * polling unit.
diff --git a/drivers/net/dsa/mv88e6xxx/global2.c b/drivers/net/dsa/mv88e6xxx/global2.c
index fa65ecd9cb85..fd6ba1fc6bef 100644
--- a/drivers/net/dsa/mv88e6xxx/global2.c
+++ b/drivers/net/dsa/mv88e6xxx/global2.c
@@ -1172,7 +1172,7 @@  int mv88e6xxx_g2_irq_mdio_setup(struct mv88e6xxx_chip *chip,
 			err = irq;
 			goto out;
 		}
-		bus->irq[chip->info->phy_base_addr + phy] = irq;
+		bus->irq[chip->phy_base_addr + phy] = irq;
 	}
 	return 0;
 out:
diff --git a/drivers/net/dsa/mv88e6xxx/smi.c b/drivers/net/dsa/mv88e6xxx/smi.c
index a990271b7482..520e47b375b2 100644
--- a/drivers/net/dsa/mv88e6xxx/smi.c
+++ b/drivers/net/dsa/mv88e6xxx/smi.c
@@ -186,5 +186,9 @@  int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
 	if (chip->smi_ops->init)
 		return chip->smi_ops->init(chip);
 
+	chip->phy_base_addr = chip->info->phy_base_addr;
+	if (chip->info->dual_chip)
+		chip->phy_base_addr += sw_addr;
+
 	return 0;
 }