netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amy Fong <amy.fong@windriver.com>
To: linux-kernel@vger.kernel.org
Cc: netdev@vger.kernel.org, jeff@garzik.org
Subject: [PATCH] Add Broadcom PHY support
Date: Fri, 15 Sep 2006 16:15:38 -0400	[thread overview]
Message-ID: <20060915201538.GA28483@lucciola.windriver.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 185 bytes --]

[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 <amy.fong@windriver.com>

[-- Attachment #2: broadcom-phy.diff --]
[-- Type: text/plain, Size: 5274 bytes --]

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 <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/unistd.h>
+#include <linux/slab.h>
+#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/spinlock.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/mii.h>
+#include <linux/ethtool.h>
+#include <linux/phy.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/uaccess.h>
+
+/* BCM5421S control register */
+#define MII_BCM5421S_CONTROL           0x00
+#define MII_BCM5421S_CONTROL_RESET     0x00008000
+#define MII_BCM5421S_CONTROL_INIT      0x00001140
+#define MII_BCM5421S_ANEN              0x00001000
+#define MII_BCM5421S_CR                 0x00
+#define MII_BCM5421S_CR_RST            0x00008000
+#define MII_BCM5421S_CR_INIT           0x00001000
+#define MII_BCM5421S_STATUS            0x1
+#define MII_BCM5421S_STATUS_AN_DONE    0x00000020
+#define MII_BCM5421S_STATUS_LINK       0x0004
+#define MII_BCM5421S_PHYIR1            0x2
+#define MII_BCM5421S_PHYIR2            0x3
+#define MII_BCM5421S_ANLPBPA           0x5
+#define MII_BCM5421S_ANLPBPA_HALF      0x00000040
+#define MII_BCM5421S_ANLPBPA_FULL      0x00000020
+#define MII_BCM5421S_ANEX              0x6
+#define MII_BCM5421S_ANEX_NP           0x00000004
+#define MII_BCM5421S_ANEX_PRX          0x00000002
+
+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    = 0x00ffffff,
+	.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    = 0x00ffffff,
+	.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 for PHY emulation on fixed speed/link"
 	depends on PHYLIB
Index: linux-2.6.18-rc6/drivers/net/phy/Makefile
===================================================================
--- linux-2.6.18-rc6.orig/drivers/net/phy/Makefile
+++ linux-2.6.18-rc6/drivers/net/phy/Makefile
@@ -10,4 +10,5 @@
 obj-$(CONFIG_QSEMI_PHY)		+= qsemi.o
 obj-$(CONFIG_SMSC_PHY)		+= smsc.o
 obj-$(CONFIG_VITESSE_PHY)	+= vitesse.o
+obj-$(CONFIG_BROADCOM_PHY)	+= broadcom.o
 obj-$(CONFIG_FIXED_PHY)		+= fixed.o

             reply	other threads:[~2006-09-15 20:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-15 20:15 Amy Fong [this message]
2006-09-19  4:39 ` [PATCH] Add Broadcom PHY support Jeff Garzik
2006-09-19 13:35   ` Amy Fong
2006-09-19 13:43     ` Maciej W. Rozycki
2006-09-19 16:45       ` Jeff Garzik
2006-09-19 17:10         ` Maciej W. Rozycki
2006-12-04 21:16 ` Benjamin Herrenschmidt
2006-12-05  5:55   ` Amy Fong
2006-12-05  6:03     ` Benjamin Herrenschmidt
2006-12-05 19:50       ` Andy Fleming

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=20060915201538.GA28483@lucciola.windriver.com \
    --to=amy.fong@windriver.com \
    --cc=jeff@garzik.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).