|
发表于 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); |
|