microcreat 发表于 2014-6-3 21:36:38

ar8035这个phy芯片初始化应该初始化那些寄存器?

目前在调试ar8035这个phy,这个phy初始化的时候的流程是什么样子的?

wangcjishu 发表于 2014-6-4 11:57:40

是在linux上做吗?是的话在网上搜了一个给你个参考

The AR8035 is a single port 10/100/1000 Mbps tri-speed Ethernet PHY.
It supports an RGMII interface to the MAC with wide RGMII I/O voltage
support from 1.5V to 3.3V.

Signed-off-by: Michael Johnston <>
Signed-off-by: Chunhe Lan <>
---
drivers/net/phy/Kconfig   |    5 ++
drivers/net/phy/Makefile|    1 +
drivers/net/phy/atheros.c |   95 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 101 insertions(+), 0 deletions(-)
create mode 100644 drivers/net/phy/atheros.c

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 4503452..c8d40d4 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -24,6 +24,11 @@ config AMD_PHY
        ---help---
          Currently supports the am79c874

+config ATHEROS_PHY
+        tristate "Drivers for Atheros PHYs"
+        ---help---
+          Currently supports the AR8035 PHY
+
config MARVELL_PHY
        tristate "Drivers for Marvell PHYs"
        ---help---
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 9645e38..762e77e 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -3,6 +3,7 @@
libphy-objs       := phy.o phy_device.o mdio_bus.o

obj-$(CONFIG_PHYLIB)       += libphy.o
+obj-$(CONFIG_ATHEROS_PHY)        += atheros.o
obj-$(CONFIG_MARVELL_PHY)        += marvell.o
obj-$(CONFIG_DAVICOM_PHY)        += davicom.o
obj-$(CONFIG_CICADA_PHY)        += cicada.o
diff --git a/drivers/net/phy/atheros.c b/drivers/net/phy/atheros.c
new file mode 100644
index 0000000..9a4aa29
--- /dev/null
+++ b/drivers/net/phy/atheros.c
@@ -0,0 +1,95 @@
+/*
+ * drivers/net/phy/atheros.c
+ *
+ * Driver for Atheros PHYs
+ *
+ * Author: Michael Johnston <>
+ *           Chunhe Lan <>
+ *
+ * Copyright (c) 2013 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistributeit and/or modify it
+ * underthe terms ofthe GNU GeneralPublic License as published by the
+ * Free Software Foundation;either version 2 of theLicense, or (at your
+ * option) any later version.
+ *
+ */
+#include <linux/phy.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+
+#define AR8035_PHYSR       0x0011
+#define AR8035_PHYSR_DUPLEX        0x2000
+#define AR8035_PHYSR_SPEED        0xc000
+#define AR8035_INER       0x0012
+#define AR8035_INER_INIT        0xec00
+#define AR8035_INSR       0x0013
+
+MODULE_DESCRIPTION("Atheros PHY driver");
+MODULE_AUTHOR("Michael Johnston");
+MODULE_LICENSE("GPL");
+
+static int ar8035_ack_interrupt(struct phy_device *phydev)
+{
+        int err;
+
+        err = phy_read(phydev, AR8035_INSR);
+
+        return (err < 0) ? err : 0;
+}
+
+static int ar8035_config_intr(struct phy_device *phydev)
+{
+        int err;
+
+        if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
+       err = phy_write(phydev, AR8035_INER, AR8035_INER_INIT);
+        else
+       err = phy_write(phydev, AR8035_INER, 0);
+
+        return err;
+}
+
+/* AR8035 */
+static struct phy_driver ar8035_driver = {
+        .phy_id       = 0x004dd072,
+        .name       = "AR8035 Gigabit Ethernet",
+        .phy_id_mask        = 0x007fffff,
+        .features        = PHY_GBIT_FEATURES,
+        .flags       = PHY_HAS_INTERRUPT,
+        .config_aneg        = &genphy_config_aneg,
+        .read_status        = &genphy_read_status,
+        .ack_interrupt        = &ar8035_ack_interrupt,
+        .config_intr        = &ar8035_config_intr,
+        .driver       = {
+       .owner = THIS_MODULE,
+        },
+};
+
+static int __init atheros_init(void)
+{
+        int ret;
+
+        ret = phy_driver_register(&ar8035_driver);
+        if (ret < 0)
+       pr_warn("AR8035: phy_driver_register is error\n");
+
+        return ret;
+}
+
+static void __exit atheros_exit(void)
+{
+        phy_driver_unregister(&ar8035_driver);
+}
+
+module_init(atheros_init);
+module_exit(atheros_exit);
+
+static struct mdio_device_id __maybe_unused atheros_tbl[] = {
+        { 0x004dd072, 0x007fffff },
+        { }
+};
+
+MODULE_DEVICE_TABLE(mdio, atheros_tbl);

microcreat 发表于 2014-6-4 15:33:20

感谢了!现在我调试通了!

microcreat 发表于 2014-6-4 19:58:26

请问有没有参考原理图啊!我想参考下!

wangcjishu 发表于 2014-6-4 22:53:59

调通了还要原理图干什么,说明你本身的原理图是对的啊

microcreat 发表于 2014-6-5 12:49:00

是在别人的板子上面调试的!

wangcjishu 发表于 2014-6-5 15:44:00

microcreat 发表于 2014-6-5 12:49
是在别人的板子上面调试的!

这个我也没有啊,最好有原厂技术支持,找他们要比较好
页: [1]
查看完整版本: ar8035这个phy芯片初始化应该初始化那些寄存器?