搜索
bottom↓
回复: 6

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

[复制链接]

出0入0汤圆

发表于 2014-6-3 21:36:38 | 显示全部楼层 |阅读模式
目前在调试ar8035这个phy,这个phy初始化的时候的流程是什么样子的?

阿莫论坛20周年了!感谢大家的支持与爱护!!

曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……

出0入0汤圆

发表于 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 <[hidden email]>
Signed-off-by: Chunhe Lan <[hidden email]>
---
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 <[hidden email]>
+ *           Chunhe Lan <[hidden email]>
+ *
+ * Copyright (c) 2013 Freescale Semiconductor, Inc.
+ *
+ * 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.
+ *
+ */
+#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);

出0入0汤圆

 楼主| 发表于 2014-6-4 15:33:20 | 显示全部楼层
感谢了!现在我调试通了!

出0入0汤圆

 楼主| 发表于 2014-6-4 19:58:26 | 显示全部楼层
请问有没有参考原理图啊!我想参考下!

出0入0汤圆

发表于 2014-6-4 22:53:59 | 显示全部楼层
调通了还要原理图干什么,说明你本身的原理图是对的啊

出0入0汤圆

 楼主| 发表于 2014-6-5 12:49:00 | 显示全部楼层
是在别人的板子上面调试的!

出0入0汤圆

发表于 2014-6-5 15:44:00 | 显示全部楼层
microcreat 发表于 2014-6-5 12:49
是在别人的板子上面调试的!

这个我也没有啊,最好有原厂技术支持,找他们要比较好
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-8-25 22:14

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表