Skip to contentSkip to conversation

ibm_newemac: Add support for GPCS, SGMII and M88E1112 PHY

PATCH In review Victor Gallardo 3 participants 11 messages Oct 2, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ibm_newemac: Add support for GPCS, SGMII and M88E1112 PHY

---
v2:
- update to sync up with latest ibm_newemac driver

 arch/powerpc/include/asm/dcr-regs.h |    4 ++
 drivers/net/ibm_newemac/core.c      |   58 ++++++++++++++++++++----
 drivers/net/ibm_newemac/core.h      |    8 +++
 drivers/net/ibm_newemac/phy.c       |   84 +++++++++++++++++++++++++++++++++++
 drivers/net/ibm_newemac/phy.h       |    2 +
 5 files changed, 147 insertions(+), 9 deletions(-)
arch/powerpc/include/asm/dcr-regs.h +4 -0
index 29b0ece..f15296c 100644
@@ -68,6 +68,10 @@
 #define SDR0_UART3		0x0123
 #define SDR0_CUST0		0x4000
 
+/* SDRs (460EX/460GT) */
+#define SDR0_ETH_CFG		0x4103
+#define SDR0_ETH_CFG_ECS	0x00000100	/* EMAC int clk source */
+
 /*
  * All those DCR register addresses are offsets from the base address
  * for the SRAM0 controller (e.g. 0x20 on 440GX). The base address is
drivers/net/ibm_newemac/core.c +49 -9

140 lines not on this page · raw message

drivers/net/ibm_newemac/core.h +8 -0
index 6545e69..b402ea9 100644
@@ -190,6 +190,9 @@ struct emac_instance {
 	struct delayed_work		link_work;
 	int				link_polling;
 
+	/* GPCS PHY infos */
+	u32				gpcs_address;
+
 	/* Shared MDIO if any */
 	u32				mdio_ph;
 	struct of_device		*mdio_dev;
@@ -317,6 +320,10 @@ struct emac_instance {
  * The 405EX and 460EX contain the EMAC4SYNC core
  */
 #define EMAC_FTR_EMAC4SYNC		0x00000200
+/*
+ * Set if we need phy clock workaround for 460ex or 460gt
+ */
+#define EMAC_FTR_460EX_PHY_CLK_FIX	0x00000400
 
 
 /* Right now, we don't quite handle the always/possible masks on the
@@ -341,6 +348,7 @@ enum {
 #ifdef CONFIG_IBM_NEW_EMAC_RGMII
 	    EMAC_FTR_HAS_RGMII	|
 #endif
+	EMAC_FTR_460EX_PHY_CLK_FIX |
 	EMAC_FTR_440EP_PHY_CLK_FIX,
 };
 
drivers/net/ibm_newemac/phy.c +84 -0

113 lines not on this page · raw message

drivers/net/ibm_newemac/phy.h +2 -0
index 1b65c81..5d2bf4c 100644
@@ -57,6 +57,7 @@ struct mii_phy {
 				   or determined automaticaly */
 	int address;		/* PHY address */
 	int mode;		/* PHY mode */
+	int gpcs_address;	/* GPCS PHY address */
 
 	/* 1: autoneg enabled, 0: disabled */
 	int autoneg;
@@ -81,5 +82,6 @@ struct mii_phy {
  */
 int emac_mii_phy_probe(struct mii_phy *phy, int address);
 int emac_mii_reset_phy(struct mii_phy *phy);
+int emac_mii_reset_gpcs(struct mii_phy *phy);
 
 #endif /* __IBM_NEWEMAC_PHY_H */
Signature · 1 line
1.5.5
#2 lore raw

RE: [PATCH v2] ibm_newemac: Add support for GPCS, SGMII andM88E1112 PHY

Quoted 10 lines
Quoted 4 lines

---
v2:
- update to sync up with latest ibm_newemac driver

Ack.

Is this on top of Josh work ?

Ben.

Yes, this based on Josh's git repository. Should I sync up with your git repository or is Josh's OK.

Regards,

Victor Gallardo

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

#3 lore raw

RE: [PATCH v2] ibm_newemac: Add support for GPCS, SGMII andM88E1112 PHY

Quoted 4 lines · Victor Gallardo

Yes, this based on Josh's git repository. Should I sync up with your git repository or is Josh's OK.

Josh is fine.

Jeff, can we merge all those EMAC patches via the powerpc git ? need an ack from you I suppose ...

Thanks,
Ben.

#4 lore raw

Re: [PATCH v2] ibm_newemac: Add support for GPCS, SGMII andM88E1112 PHY

Quoted 10 lines · On Thu, 02 Oct 2008 17:32:39 +1000 Benjamin Herrenschmidt…
Quoted 4 lines · Victor Gallardo

Yes, this based on Josh's git repository. Should I sync up with your git repository or is Josh's OK.

Josh is fine.

Jeff, can we merge all those EMAC patches via the powerpc git ? need an ack from you I suppose ...

I already have this in my tree. Jeff already acked it (twice now I think).

http://git.kernel.org/?p=linux/kernel/git/jwboyer/powerpc-4xx.git;a=shortlog;h=next

josh

#5 lore raw

Re: [PATCH v2] ibm_newemac: Add support for GPCS, SGMII andM88E1112 PHY

Quoted 11 lines · Josh Boyer
Quoted 8 lines · On Thu, 02 Oct 2008 17:32:39 +1000 Benjamin Herrenschmidt…
Quoted 4 lines · Victor Gallardo

Yes, this based on Josh's git repository. Should I sync up with your git repository or is Josh's OK.

Josh is fine.

Quoted 7 lines
Quoted 2 lines

Jeff, can we merge all those EMAC patches via the powerpc git ? need an ack from you I suppose ...

I already have this in my tree. Jeff already acked it (twice now I think).

http://git.kernel.org/?p=linux/kernel/git/jwboyer/powerpc-4xx.git;a=shortlog;h=next

Ok so it will go in when I get your pull request then :-0

Cheers,
Ben.

#6 lore raw

Re: [PATCH v2] ibm_newemac: Add support for GPCS, SGMII andM88E1112 PHY

Quoted 15 lines · On Thu, 02 Oct 2008 20:34:28 +1000 Benjamin Herrenschmidt…
Quoted 14 lines · Josh Boyer
Quoted 10 lines · On Thu, 02 Oct 2008 17:32:39 +1000 Benjamin Herrenschmidt…
Quoted 4 lines · Victor Gallardo

Yes, this based on Josh's git repository. Should I sync up with your git repository or is Josh's OK.

Josh is fine.

Jeff, can we merge all those EMAC patches via the powerpc git ? need an ack from you I suppose ...

Quoted 6 lines
Quoted 4 lines

I already have this in my tree. Jeff already acked it (twice now I think).

http://git.kernel.org/?p=linux/kernel/git/jwboyer/powerpc-4xx.git;a=shortlog;h=next

Ok so it will go in when I get your pull request then :-0

Yep. You could pull now if you'd like. I have a few more patches I'd like to get in before the merge window, but if it helps things I can do those in a separate pull request.

josh

#7 lore raw

Re: [PATCH v2] ibm_newemac: Add support for GPCS, SGMII andM88E1112 PHY

Quoted 6 lines · Josh Boyer
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

Jeff, can we merge all those EMAC patches via the powerpc git ? need an ack from you I suppose ...

I already have this in my tree. Jeff already acked it (twice now I think).

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

http://git.kernel.org/?p=linux/kernel/git/jwboyer/powerpc-4xx.git;a=shortlog;h=next

Ok so it will go in when I get your pull request then :-0

Yep. You could pull now if you'd like. I have a few more patches I'd like to get in before the merge window, but if it helps things I can do those in a separate pull request.

Actually, it seems not. I pulled in an older version of the patch. I'll grab the new version today.

/me sighs.

josh

#8 lore raw

Re: [PATCH v2] ibm_newemac: Add support for GPCS, SGMII andM88E1112 PHY

Quoted 6 lines · Josh Boyer
Quoted 3 lines

Yep. You could pull now if you'd like. I have a few more patches I'd like to get in before the merge window, but if it helps things I can do those in a separate pull request.

Actually, it seems not. I pulled in an older version of the patch. I'll grab the new version today.

Victor, while at it, can you do a fixup patch on top of it that guards the new feature with a Kconfig option like some of the other ones so that the code for it doesn't get compiled in when building, for example. for 405GP only ?

The trick is to have the option not be part of the possible mask, so that the compiler optimises out the feature tests as if (0) (gcc nowadays is supposedly smart enough to rip off the code when it finds such constructs).

Thanks !

Cheers,
Ben.

#9 lore raw

RE: [PATCH v2] ibm_newemac: Add support for GPCS, SGMIIandM88E1112 PHY

Quoted 9 lines

Victor, while at it, can you do a fixup patch on top of it that guards the new feature with a Kconfig option like some of the other ones so that the code for it doesn't get compiled in when building, for example. for 405GP only ?

The trick is to have the option not be part of the possible mask, so that the compiler optimises out the feature tests as if (0) (gcc nowadays is supposedly smart enough to rip off the code when it finds such constructs).

Hi Ben,

Can you give an example of what you are asking for? I am not sure if I understand your request.

Thanks,

Victor Gallardo

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

#10 lore raw

RE: [PATCH v2] ibm_newemac: Add support for GPCS, SGMIIandM88E1112 PHY

Quoted 5 lines · Victor Gallardo
Quoted 5 lines

Victor, while at it, can you do a fixup patch on top of it that guards the new feature with a Kconfig option like some of the other ones so that the code for it doesn't get compiled in when building, for example. for 405GP only ?

Quoted 8 lines
Quoted 4 lines

The trick is to have the option not be part of the possible mask, so that the compiler optimises out the feature tests as if (0) (gcc nowadays is supposedly smart enough to rip off the code when it finds such constructs).

Hi Ben,

Can you give an example of what you are asking for? I am not sure if I understand your request.

Well, if you look at the way emac_has_feature is implemented:

static inline int emac_has_feature(struct emac_instance *dev,
unsigned long feature)

{
	return (EMAC_FTRS_ALWAYS & feature) ||
	       (EMAC_FTRS_POSSIBLE & dev->features & feature);
}

And now, if you look a few lines up, you see that various CONFIG_* options define what is in EMAC_FTRS_POSSIBLE.

The trick is, you can thus make your new option only be part of EMAC_FTRS_POSSIBLE if support for a 460EX based board has been enabled or even better, one that uses a GPCS PHY. You do that by creating a new Kconfig option such as CONFIG_EMAC_SUPPORTS_GPCS for example that gets select'ed by the boards that need it.

That way, when compiling a kernel for a board that does -not- need it, the feature bit will be absent from EMAC_FTRS_POSSIBLE. That will allow the compiler to figure out that when emac_has_feature() is called for that option, the result will always be 0. Thus the compiler gets to optimize out all the code relative to that option.

Cheers,
Ben.