Re: [PATCH] Add Broadcom PHY support

2006-12-05 Thread Andy Fleming


On Dec 5, 2006, at 00:03, Benjamin Herrenschmidt wrote:



I believe that this fiber enabling can be done by defining  
config_init in the phy_driver struct.


struct phy_driver {

/* Called to initialize the PHY,
 * including after a reset */
int (*config_init)(struct phy_device *phydev);

};


Well... I don't know for sure... thing is, enabling the fiber mode  
is a
rather platform specific thing. So it's the MAC driver that knows  
wether

it wants it on a PHY and should call into the driver.

It's difficult to abstract all possible PHY config options tho... some
MACs might want to enable low power, some don't because they have  
issues

with it, that sort of thing, though.

Not sure what the best solution is at this point... Maybe an ascii
string to pass the PHY driver is the most flexible, though a bit  
yucky,

or we try to have a list of all the possible configuration options in
phy.h and people just add new ones that they need as they add support
for them...

Sounds grossly like an in-kernel ioctl tho...



Each phy_device structure now has a dev_flags field that can be  
modified by the controller's code upon connecting.  The PHY driver  
can then check that field for PHY-specific, platform-specific  
interactions.  For instance, on the newer CDS, there's a Marvell PHY  
which requires configurable resistance changes to work in RGMII  
mode.  So there's a flag for that.  Basically, each PHY driver  
specifies its own flags, and the platform code is currently  
responsible for setting those flags appropriately.  A string might be  
more flexible, but I'm operating on the hope that there shouldn't be  
too many of these.


For Fiber mode, or other such changes, we might want to add another  
field, like the interface field, to describe standard external  
interfaces.  The call to phy_connect() is beginning to get a bit  
long, though.


Andy
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Add Broadcom PHY support

2006-12-04 Thread Benjamin Herrenschmidt

> I believe that this fiber enabling can be done by defining config_init in the 
> phy_driver struct.
> 
> struct phy_driver {
> 
> /* Called to initialize the PHY,
>* including after a reset */
>   int (*config_init)(struct phy_device *phydev);
> 
> };

Well... I don't know for sure... thing is, enabling the fiber mode is a
rather platform specific thing. So it's the MAC driver that knows wether
it wants it on a PHY and should call into the driver.

It's difficult to abstract all possible PHY config options tho... some
MACs might want to enable low power, some don't because they have issues
with it, that sort of thing, though.

Not sure what the best solution is at this point... Maybe an ascii
string to pass the PHY driver is the most flexible, though a bit yucky,
or we try to have a list of all the possible configuration options in
phy.h and people just add new ones that they need as they add support
for them...

Sounds grossly like an in-kernel ioctl tho...

Ben.


-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Add Broadcom PHY support

2006-12-04 Thread Amy Fong
> On Fri, 2006-09-15 at 16:15 -0400, Amy Fong wrote:
> > [PATCH] Add Broadcom PHY support
> > 
> > This patch adds a driver to support the bcm5421s and bcm5461s PHY
> > 
> > Kernel version:  linux-2.6.18-rc6
> > 
> > Signed-off-by: Amy Fong 
> 
> Some 5421's need special initialisation (see drivers/net/sungem_phy.c),
> might be worth having them there too. I was also wondering... for
> spidernet, we need to enable the fiber mode on the PHY. Does phylib has
> an API for that ?
> 
> I'd like to look into moving sungem and spidernet over to phylib.
> 
> Ben.


I believe that this fiber enabling can be done by defining config_init in the 
phy_driver struct.

struct phy_driver {

/* Called to initialize the PHY,
 * including after a reset */
int (*config_init)(struct phy_device *phydev);

};

ie.

static struct phy_driver bcm5421s_driver = {

.config_init = bcm5421s_phy_config,

};

int bcm5421s_phy_config(struct phy_device *phydev)
{
...
/* enable fiber mode here... */
...
}

Amy
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Add Broadcom PHY support

2006-12-04 Thread Benjamin Herrenschmidt
On Fri, 2006-09-15 at 16:15 -0400, Amy Fong wrote:
> [PATCH] Add Broadcom PHY support
> 
> This patch adds a driver to support the bcm5421s and bcm5461s PHY
> 
> Kernel version:  linux-2.6.18-rc6
> 
> Signed-off-by: Amy Fong 

Some 5421's need special initialisation (see drivers/net/sungem_phy.c),
might be worth having them there too. I was also wondering... for
spidernet, we need to enable the fiber mode on the PHY. Does phylib has
an API for that ?

I'd like to look into moving sungem and spidernet over to phylib.

Ben.


-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Add Broadcom PHY support

2006-09-19 Thread Maciej W. Rozycki
On Tue, 19 Sep 2006, Jeff Garzik wrote:

> >  And sb1250-mac.c would be happy to use it too.
> 
> "would be happy to" != "is using".   I don't want to add a phy driver until
> there are already active users in the kernel.

 Fair enough, but Amy may be looking forward to seeing yet another piece 
of code using the new driver. ;-)

  Maciej
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Add Broadcom PHY support

2006-09-19 Thread Jeff Garzik

Maciej W. Rozycki wrote:

On Tue, 19 Sep 2006, Amy Fong wrote:


And... where are the users of this phy driver?

[...]
This phy driver is used by the WRS's sbc8560 (bcm5421s) and sbc843x 
(bcm5461s) via the gianfar driver.


 And sb1250-mac.c would be happy to use it too.


"would be happy to" != "is using".   I don't want to add a phy driver 
until there are already active users in the kernel.


Jeff



-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Add Broadcom PHY support

2006-09-19 Thread Maciej W. Rozycki
On Tue, 19 Sep 2006, Amy Fong wrote:

> > And... where are the users of this phy driver?
[...]
> This phy driver is used by the WRS's sbc8560 (bcm5421s) and sbc843x 
> (bcm5461s) via the gianfar driver.

 And sb1250-mac.c would be happy to use it too.

  Maciej
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Add Broadcom PHY support

2006-09-19 Thread Amy Fong
[ Charset ISO-8859-1 unsupported, converting... ]
> Amy Fong wrote:
> > [PATCH] Add Broadcom PHY support
> > 
> > This patch adds a driver to support the bcm5421s and bcm5461s PHY
> > 
> > Kernel version:  linux-2.6.18-rc6
> > 
> > Signed-off-by: Amy Fong <[EMAIL PROTECTED]>
> 
> And... where are the users of this phy driver?
> 
>   Jeff
> 

This phy driver is used by the WRS's sbc8560 (bcm5421s) and sbc843x (bcm5461s) 
via the gianfar driver.

Amy
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Add Broadcom PHY support

2006-09-18 Thread Jeff Garzik

Amy Fong wrote:

[PATCH] Add Broadcom PHY support

This patch adds a driver to support the bcm5421s and bcm5461s PHY

Kernel version:  linux-2.6.18-rc6

Signed-off-by: Amy Fong <[EMAIL PROTECTED]>


And... where are the users of this phy driver?

Jeff



-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Add Broadcom PHY support

2006-09-15 Thread Amy Fong
[PATCH] Add Broadcom PHY support

This patch adds a driver to support the bcm5421s and bcm5461s PHY

Kernel version:  linux-2.6.18-rc6

Signed-off-by: Amy Fong <[EMAIL PROTECTED]>
Index: linux-2.6.18-rc6/drivers/net/phy/broadcom.c
===
--- /dev/null
+++ linux-2.6.18-rc6/drivers/net/phy/broadcom.c
@@ -0,0 +1,129 @@
+/*
+ * drivers/net/phy/broadcom.c, Driver for Broadcom PHYs
+ *
+ * Copyright (c) 2006 Wind River Systems, Inc.
+ * Written by Amy Fong
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+/* BCM5421S control register */
+#define MII_BCM5421S_CONTROL   0x00
+#define MII_BCM5421S_CONTROL_RESET 0x8000
+#define MII_BCM5421S_CONTROL_INIT  0x1140
+#define MII_BCM5421S_ANEN  0x1000
+#define MII_BCM5421S_CR 0x00
+#define MII_BCM5421S_CR_RST0x8000
+#define MII_BCM5421S_CR_INIT   0x1000
+#define MII_BCM5421S_STATUS0x1
+#define MII_BCM5421S_STATUS_AN_DONE0x0020
+#define MII_BCM5421S_STATUS_LINK   0x0004
+#define MII_BCM5421S_PHYIR10x2
+#define MII_BCM5421S_PHYIR20x3
+#define MII_BCM5421S_ANLPBPA   0x5
+#define MII_BCM5421S_ANLPBPA_HALF  0x0040
+#define MII_BCM5421S_ANLPBPA_FULL  0x0020
+#define MII_BCM5421S_ANEX  0x6
+#define MII_BCM5421S_ANEX_NP   0x0004
+#define MII_BCM5421S_ANEX_PRX  0x0002
+
+MODULE_DESCRIPTION("Broadcom PHY driver");
+MODULE_AUTHOR("Amy Fong");
+MODULE_LICENSE("GPL");
+
+static int bcm5421s_config_aneg(struct phy_device *phydev)
+{
+   int err;
+
+   /* Write the appropriate value to the PHY reg */
+   if (phydev->supported & SUPPORTED_1000baseT_Full)
+   err = phy_write(phydev, MII_BCM5421S_CONTROL, 
MII_BCM5421S_CONTROL_INIT);
+   else
+   err = phy_write(phydev, MII_BCM5421S_CONTROL, 
MII_BCM5421S_CR_INIT);
+
+   if (err < 0) return err;
+
+   /* doesn't have phy interrupt */
+   phydev->interrupts = PHY_INTERRUPT_DISABLED;
+
+   return 0;
+}
+
+static struct phy_driver bcm5421s_driver = {
+   .phy_id = 0x002060e1,
+   .phy_id_mask= 0x00ff,
+   .name   = "Broadcom BCM5421S",
+   .features   = PHY_GBIT_FEATURES,
+   .config_aneg= bcm5421s_config_aneg,
+   .read_status= genphy_read_status,
+   .driver = { .owner = THIS_MODULE,},
+};
+
+/* Glossy description on Broadcom's site seems to hint that the 5461
+   should be a drop-in for the 5421 */
+static struct phy_driver bcm5461s_driver = {
+   .phy_id = 0x002060c1,
+   .phy_id_mask= 0x00ff,
+   .name   = "Broadcom BCM5461S",
+   .features   = PHY_GBIT_FEATURES,
+   .config_aneg= bcm5421s_config_aneg,
+   .read_status= genphy_read_status,
+   .driver = { .owner = THIS_MODULE,},
+};
+
+static int __init broadcom_init(void)
+{
+   int ret;
+
+   ret = phy_driver_register(&bcm5421s_driver);
+   if (!ret) {
+   ret = phy_driver_register(&bcm5461s_driver);
+   if (ret) phy_driver_unregister(&bcm5421s_driver);
+   }
+   return ret;
+}
+
+static void __exit broadcom_exit(void)
+{
+   phy_driver_unregister(&bcm5421s_driver);
+   phy_driver_unregister(&bcm5461s_driver);
+}
+
+module_init(broadcom_init);
+module_exit(broadcom_exit);
Index: linux-2.6.18-rc6/drivers/net/phy/Kconfig
===
--- linux-2.6.18-rc6.orig/drivers/net/phy/Kconfig
+++ linux-2.6.18-rc6/drivers/net/phy/Kconfig
@@ -56,6 +56,12 @@
---help---
  Currently supports the LAN83C185 PHY
 
+config BROADCOM_PHY
+   tristate "Drivers for Broadcom PHYs"
+   depends on PHYLIB
+   ---help---
+ Currently supports bcm5421s and bcm5461s
+
 config FIXED_PHY
tristate "Drivers