Commit 7ad8a89c authored by Eugene Surovegin's avatar Eugene Surovegin Committed by Jeff Garzik

[PATCH] PPC 44x EMAC driver: add 440SPe support

For some reason, the hardware designers made the polarity of one bit
in the 440SPe's PHY interface register the opposite of all other PPC
440 chips.  To handle this, abstract our access to this bit and do the
right thing based on the configured CPU type.
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
Signed-off-by: default avatarEugene Surovegin <ebs@ebshome.net>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent be15cd72
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
/* This is a simple check to prevent use of this driver on non-tested SoCs */ /* This is a simple check to prevent use of this driver on non-tested SoCs */
#if !defined(CONFIG_405GP) && !defined(CONFIG_405GPR) && !defined(CONFIG_405EP) && \ #if !defined(CONFIG_405GP) && !defined(CONFIG_405GPR) && !defined(CONFIG_405EP) && \
!defined(CONFIG_440GP) && !defined(CONFIG_440GX) && !defined(CONFIG_440SP) && \ !defined(CONFIG_440GP) && !defined(CONFIG_440GX) && !defined(CONFIG_440SP) && \
!defined(CONFIG_440EP) && !defined(CONFIG_NP405H) !defined(CONFIG_440EP) && !defined(CONFIG_NP405H) && !defined(CONFIG_440SPE)
#error "Unknown SoC. Please, check chip user manual and make sure EMAC defines are OK" #error "Unknown SoC. Please, check chip user manual and make sure EMAC defines are OK"
#endif #endif
...@@ -246,6 +246,25 @@ struct emac_regs { ...@@ -246,6 +246,25 @@ struct emac_regs {
#define EMAC_STACR_PCDA_SHIFT 5 #define EMAC_STACR_PCDA_SHIFT 5
#define EMAC_STACR_PRA_MASK 0x1f #define EMAC_STACR_PRA_MASK 0x1f
/*
* For the 440SPe, AMCC inexplicably changed the polarity of
* the "operation complete" bit in the MII control register.
*/
#if defined(CONFIG_440SPE)
static inline int emac_phy_done(u32 stacr)
{
return !(stacr & EMAC_STACR_OC);
};
#define EMAC_STACR_START EMAC_STACR_OC
#else /* CONFIG_440SPE */
static inline int emac_phy_done(u32 stacr)
{
return stacr & EMAC_STACR_OC;
};
#define EMAC_STACR_START 0
#endif /* !CONFIG_440SPE */
/* EMACx_TRTR */ /* EMACx_TRTR */
#if !defined(CONFIG_IBM_EMAC4) #if !defined(CONFIG_IBM_EMAC4)
#define EMAC_TRTR_SHIFT 27 #define EMAC_TRTR_SHIFT 27
......
...@@ -546,7 +546,7 @@ static int __emac_mdio_read(struct ocp_enet_private *dev, u8 id, u8 reg) ...@@ -546,7 +546,7 @@ static int __emac_mdio_read(struct ocp_enet_private *dev, u8 id, u8 reg)
/* Wait for management interface to become idle */ /* Wait for management interface to become idle */
n = 10; n = 10;
while (!(in_be32(&p->stacr) & EMAC_STACR_OC)) { while (!emac_phy_done(in_be32(&p->stacr))) {
udelay(1); udelay(1);
if (!--n) if (!--n)
goto to; goto to;
...@@ -556,11 +556,12 @@ static int __emac_mdio_read(struct ocp_enet_private *dev, u8 id, u8 reg) ...@@ -556,11 +556,12 @@ static int __emac_mdio_read(struct ocp_enet_private *dev, u8 id, u8 reg)
out_be32(&p->stacr, out_be32(&p->stacr,
EMAC_STACR_BASE(emac_opb_mhz()) | EMAC_STACR_STAC_READ | EMAC_STACR_BASE(emac_opb_mhz()) | EMAC_STACR_STAC_READ |
(reg & EMAC_STACR_PRA_MASK) (reg & EMAC_STACR_PRA_MASK)
| ((id & EMAC_STACR_PCDA_MASK) << EMAC_STACR_PCDA_SHIFT)); | ((id & EMAC_STACR_PCDA_MASK) << EMAC_STACR_PCDA_SHIFT)
| EMAC_STACR_START);
/* Wait for read to complete */ /* Wait for read to complete */
n = 100; n = 100;
while (!((r = in_be32(&p->stacr)) & EMAC_STACR_OC)) { while (!emac_phy_done(r = in_be32(&p->stacr))) {
udelay(1); udelay(1);
if (!--n) if (!--n)
goto to; goto to;
...@@ -594,7 +595,7 @@ static void __emac_mdio_write(struct ocp_enet_private *dev, u8 id, u8 reg, ...@@ -594,7 +595,7 @@ static void __emac_mdio_write(struct ocp_enet_private *dev, u8 id, u8 reg,
/* Wait for management interface to be idle */ /* Wait for management interface to be idle */
n = 10; n = 10;
while (!(in_be32(&p->stacr) & EMAC_STACR_OC)) { while (!emac_phy_done(in_be32(&p->stacr))) {
udelay(1); udelay(1);
if (!--n) if (!--n)
goto to; goto to;
...@@ -605,11 +606,11 @@ static void __emac_mdio_write(struct ocp_enet_private *dev, u8 id, u8 reg, ...@@ -605,11 +606,11 @@ static void __emac_mdio_write(struct ocp_enet_private *dev, u8 id, u8 reg,
EMAC_STACR_BASE(emac_opb_mhz()) | EMAC_STACR_STAC_WRITE | EMAC_STACR_BASE(emac_opb_mhz()) | EMAC_STACR_STAC_WRITE |
(reg & EMAC_STACR_PRA_MASK) | (reg & EMAC_STACR_PRA_MASK) |
((id & EMAC_STACR_PCDA_MASK) << EMAC_STACR_PCDA_SHIFT) | ((id & EMAC_STACR_PCDA_MASK) << EMAC_STACR_PCDA_SHIFT) |
(val << EMAC_STACR_PHYD_SHIFT)); (val << EMAC_STACR_PHYD_SHIFT) | EMAC_STACR_START);
/* Wait for write to complete */ /* Wait for write to complete */
n = 100; n = 100;
while (!(in_be32(&p->stacr) & EMAC_STACR_OC)) { while (!emac_phy_done(in_be32(&p->stacr))) {
udelay(1); udelay(1);
if (!--n) if (!--n)
goto to; goto to;
......
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
#if defined(CONFIG_405GP) || defined(CONFIG_405GPR) || defined(CONFIG_405EP) || \ #if defined(CONFIG_405GP) || defined(CONFIG_405GPR) || defined(CONFIG_405EP) || \
defined(CONFIG_440EP) || defined(CONFIG_NP405H) defined(CONFIG_440EP) || defined(CONFIG_NP405H)
#define MAL_VERSION 1 #define MAL_VERSION 1
#elif defined(CONFIG_440GP) || defined(CONFIG_440GX) || defined(CONFIG_440SP) #elif defined(CONFIG_440GP) || defined(CONFIG_440GX) || defined(CONFIG_440SP) || \
defined(CONFIG_440SPE)
#define MAL_VERSION 2 #define MAL_VERSION 2
#else #else
#error "Unknown SoC, please check chip manual and choose MAL 'version'" #error "Unknown SoC, please check chip manual and choose MAL 'version'"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment