Re: Micrel PHY KSZ8001 on MPC5200B FEC

3 messages, 3 authors, 2009-11-12 · open the first message on its own page

Re: Micrel PHY KSZ8001 on MPC5200B FEC

From: suvidh kankariya <hidden>
Date: 2009-10-28 14:20:30

Romen,
         I am sorry for the misguided statement.
         I indeed had patched it .
I am copying the patch here. Hope it helps you.
diff --exclude CVS -uNr linux-2.6.30/drivers/net/phy/Kconfig 
linux-2.6.30.modified/drivers/net/phy/Kconfig
--- linux-2.6.30/drivers/net/phy/Kconfig        2009-06-09 
23:05:27.000000000 -0400
+++ linux-2.6.30.modified/drivers/net/phy/Kconfig       2009-10-09 
15:43:09.000000000 -0400
@@ -82,6 +82,12 @@
         ---help---
           Supports the LSI ET1011C PHY.

+config MICREL_PHY
+       tristate "Drivers for MICREL  PHYs"
+        depends on PHYLIB
+       ---help---
+         Currently supports the KS8721BL, KSZ8041NL
+
  config FIXED_PHY
         bool "Driver for MDIO Bus/PHY emulation with fixed speed/link PHYs"
         depends on PHYLIB=y
diff --exclude CVS -uNr linux-2.6.30/drivers/net/phy/Makefile 
linux-2.6.30.modified/drivers/net/phy/Makefile
--- linux-2.6.30/drivers/net/phy/Makefile       2009-06-09 
23:05:27.000000000 -0400
+++ linux-2.6.30.modified/drivers/net/phy/Makefile      2009-10-09 
16:07:37.000000000 -0400
@@ -14,6 +14,7 @@
  obj-$(CONFIG_ICPLUS_PHY)       += icplus.o
  obj-$(CONFIG_REALTEK_PHY)      += realtek.o
  obj-$(CONFIG_LSI_ET1011C_PHY)  += et1011c.o
+obj-$(CONFIG_MICREL_PHY)       += micrel.o
  obj-$(CONFIG_FIXED_PHY)                += fixed.o
  obj-$(CONFIG_MDIO_BITBANG)     += mdio-bitbang.o
  obj-$(CONFIG_MDIO_GPIO)                += mdio-gpio.o
diff --exclude CVS -uNr linux-2.6.30/drivers/net/phy/micrel.c 
linux-2.6.30.modified/drivers/net/phy/micrel.c
--- linux-2.6.30/drivers/net/phy/micrel.c       1969-12-31 
19:00:00.000000000 -0500
+++ linux-2.6.30.modified/drivers/net/phy/micrel.c      2009-09-23 
16:04:53.000000000 -0400
@@ -0,0 +1,129 @@
+ /* drivers/net/phy/micrel.c
+ *
+ * Driver for Micrel  PHY
+ * based on drivers/net/phy/marvell.c  *
+ *
+ *
+ *
+ */
+
+#include <linux/kernel.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>
+#define MII_MICRELL_RXERCR     0x15
+#define MII_MICRELL_ICSR       0x1B
+#define MII_MICRELL_PHYCR      0x1F
+
+
+MODULE_DESCRIPTION("Micrel PHY driver");
+MODULE_AUTHOR("Suvidh Kankariya");
+MODULE_LICENSE("GPL");
+
+
+static int micrel_config_intr(struct phy_device *phydev)
+{
+  int err;
+
+       if(phydev->interrupts == PHY_INTERRUPT_ENABLED)
+       {
+         err = phy_write(phydev, MII_MICRELL_ICSR, 0xFF00);
+         err = phy_write(phydev, 0, 0x1200); /* control register */
+       }
+       else
+               err = phy_write(phydev, MII_MICRELL_ICSR, 0);
+
+       return err;
+}
+
+static int micrel_config_init(struct phy_device *phydev)
+{
+    printk("Phy config  done");
+
+       phy_write(phydev, MII_MICRELL_ICSR, 0);
+       return 0;
+}
+
+
+static int micrel_ack_interrupt(struct phy_device *phydev)
+{
+       int err = phy_read(phydev, MII_MICRELL_ICSR);
+       if (err < 0)
+               return err;
+
+       return 0;
+}
+
+static struct phy_driver ks8721bl_driver = {
+       .phy_id         = 0x000221619,
+       .name           = "KS8721BL",
+       .phy_id_mask    = 0xfffffff0,
+       .features       = PHY_BASIC_FEATURES,
+       .flags          = PHY_HAS_INTERRUPT,
+       .config_init    = micrel_config_init,
+       .config_aneg    = genphy_config_aneg,
+       .read_status    = genphy_read_status,
+       .ack_interrupt  = micrel_ack_interrupt,
+       .config_intr    = micrel_config_intr,
+       .driver         = { .owner = THIS_MODULE,},
+};
+
+
+
+static struct phy_driver ksz8041nl_driver = {
+       .phy_id         = 0x00022151,
+       .name           = "KSZ8041NL",
+       .phy_id_mask    = 0xfffffff0,
+       .features       = PHY_BASIC_FEATURES,
+       .flags          = PHY_HAS_INTERRUPT,
+       .config_init    = micrel_config_init,
+       .config_aneg    = genphy_config_aneg,
+       .read_status    = genphy_read_status,
+       .ack_interrupt  = micrel_ack_interrupt,
+       .config_intr    = micrel_config_intr,
+       .driver         = { .owner = THIS_MODULE,},
+};
+
+static int __init micrel_init(void)
+{
+       int ret;
+
+       ret = phy_driver_register(&ks8721bl_driver);
+       if (ret)
+               return ret;
+    ret = phy_driver_register(&ksz8041nl_driver);
+    printk("Phy Init  done");
+    if (ret)
+        goto err8041;
+
+       return 0;
+ err8041:
+    phy_driver_unregister(&ks8721bl_driver);
+       return ret;
+}
+
+static void __exit micrel_exit(void)
+{
+       phy_driver_unregister(&ks8721bl_driver);
+    phy_driver_unregister(&ksz8041nl_driver);
+}
+
+module_init(micrel_init);
+module_exit(micrel_exit);


Suvidh




------------------------------

Message: 6
Date: Tue, 27 Oct 2009 20:54:47 +0100
From: Roman Fietze <redacted>
To: linuxppc-dev@lists.ozlabs.org
Subject: Re: Micrel PHY KSZ8001 on MPC5200B FEC
Message-ID: [off-list ref]
Content-Type: Text/Plain;  charset="iso-8859-1"

Hello Suvidh,

On Tuesday 27 October 2009 17:47:51 suvidh kankariya wrote:
quoted
A driver for micrel phy exists in /drivers/net/phy/micrel.c. in
2.6.30.
Am I somewhat blind, or do you have access to other 2.6.30's than I
have?

I searched git.kernel.org, git.denx.de and git.secretlab.ca, but could
not find that file, neither in the current master, nor in older tags
somewhat related to "2.6.30", nor in any local clone in any version of
the 2.6 since "He" created the repos.

quoted
If you are using older kernel you may want to copy it.
2.6.30 and 2.6.31 from DENX or kernel.org.


Roman

--
Roman Fietze                Telemotive AG B?ro M?hlhausen
Breitwiesen                              73347 M?hlhausen
Tel.: +49(0)7335/18493-45        http://www.telemotive.de


------------------------------

Re: Micrel PHY KSZ8001 on MPC5200B FEC

From: Roman Fietze <hidden>
Date: 2009-11-12 06:34:04

Hello Suvidh,

On Wednesday 28 October 2009 16:19:04 suvidh kankariya wrote:
I am sorry for the misguided statement.
No problem, help is always welcome.
I indeed had patched it.
Allthough Grant's mail got stuck in our beloved Notes spam filter, we
found out how to use that KSZ8001 on our board.

As Grant mentioned as well, the key was and is a correct DTS. (At
least) one statement was missing:

  interrupt-parent =3D <&mpc5200_pic>;

This statement seemed to move all the way up from the devices to the
root of the tree, and somehow we missed that move.

Thanks again to all who answered.


Roman

=2D-=20
Roman Fietze                Telemotive AG B=FCro M=FChlhausen
Breitwiesen                              73347 M=FChlhausen
Tel.: +49(0)7335/18493-45        http://www.telemotive.de

Re: Micrel PHY KSZ8001 on MPC5200B FEC

From: Grant Likely <hidden>
Date: 2009-11-12 07:03:53

On Wed, Nov 11, 2009 at 11:33 PM, Roman Fietze
[off-list ref] wrote:
As Grant mentioned as well, the key was and is a correct DTS. (At
least) one statement was missing:

=A0interrupt-parent =3D <&mpc5200_pic>;

This statement seemed to move all the way up from the devices to the
root of the tree, and somehow we missed that move.
Yes, nodes inherit the interrupt-parent property from their parent.  I
took advantage of that to tidy up all the mpc5200 device trees.

g.

--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help