All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: linuxppc-dev@lists.ozlabs.org
Cc: Heiko Schocher <hs@denx.de>,
	linux-netdev@vger.kernel.org, Wolfgang Denk <wd@denx.de>
Subject: [PATCH 1/4] net, phy: am79c874 support
Date: Wed, 22 Jun 2011 09:55:08 +0200	[thread overview]
Message-ID: <1308729311-15375-2-git-send-email-hs@denx.de> (raw)
In-Reply-To: <1308729311-15375-1-git-send-email-hs@denx.de>

Signed-off-by: Heiko Schocher <hs@denx.de>
cc: linux-netdev@vger.kernel.org
cc: Wolfgang Denk <wd@denx.de>
---
 drivers/net/phy/Kconfig  |    5 ++
 drivers/net/phy/Makefile |    1 +
 drivers/net/phy/amd79.c  |  109 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 115 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/phy/amd79.c

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index a702443..ee70d04 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -15,6 +15,11 @@ if PHYLIB
 
 comment "MII PHY device drivers"
 
+config AMD_PHY
+	tristate "Drivers for the AMD79 PHYs"
+	---help---
+	  Currently supports the amd79c874
+
 config MARVELL_PHY
 	tristate "Drivers for Marvell PHYs"
 	---help---
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 2333215..79bc8b4 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -23,3 +23,4 @@ obj-$(CONFIG_DP83640_PHY)	+= dp83640.o
 obj-$(CONFIG_STE10XP)		+= ste10Xp.o
 obj-$(CONFIG_MICREL_PHY)	+= micrel.o
 obj-$(CONFIG_MDIO_OCTEON)	+= mdio-octeon.o
+obj-$(CONFIG_AMD_PHY)		+= amd79.o
diff --git a/drivers/net/phy/amd79.c b/drivers/net/phy/amd79.c
new file mode 100644
index 0000000..914d696
--- /dev/null
+++ b/drivers/net/phy/amd79.c
@@ -0,0 +1,109 @@
+/*
+ * Driver for AMD am79 PHYs
+ *
+ * Author: Heiko Schocher <hs@denx.de>
+ *
+ * Copyright (c) 2011 DENX Software Engineering GmbH
+ *
+ * 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/kernel.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/unistd.h>
+#include <linux/interrupt.h>
+#include <linux/init.h>
+#include <linux/io.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 <linux/uaccess.h>
+
+#include <asm/irq.h>
+
+#define MII_AMD79_IR		17  /* Interrupt Status/Control Register */
+#define MII_AMD79_IR_EN_LINK	0x0400	/* IR enable Linkstate */
+#define MII_AMD79_IR_ACK_LINK	0x0004	/* IR ack Linkstate */
+
+MODULE_DESCRIPTION("AMD PHY driver");
+MODULE_AUTHOR("Heiko Schocher <hs@denx.de>");
+MODULE_LICENSE("GPL");
+
+static int amd79_ack_interrupt(struct phy_device *phydev)
+{
+	int err;
+
+	err = phy_read(phydev, MII_BMSR);
+	if (err < 0)
+		return err;
+
+	err = phy_read(phydev, MII_AMD79_IR);
+	if (err < 0)
+		return err;
+
+	return 0;
+}
+
+static int amd79_config_init(struct phy_device *phydev)
+{
+	int err = 0;
+
+	return err;
+}
+
+static int amd79_config_intr(struct phy_device *phydev)
+{
+	int err;
+
+	if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
+		err = phy_write(phydev, MII_AMD79_IR_EN_LINK,
+			MII_AMD79_IR_EN_LINK);
+	else
+		err = phy_write(phydev, MII_AMD79_IR_EN_LINK, 0);
+
+	return err;
+}
+
+static struct phy_driver amd79_driver = {
+	.phy_id		= 0x0022561b,
+	.name		= "AMD79C874",
+	.phy_id_mask	= 0xfffffff0,
+	.features	= PHY_BASIC_FEATURES,
+	.flags		= PHY_HAS_INTERRUPT,
+	.config_init	= amd79_config_init,
+	.config_aneg	= genphy_config_aneg,
+	.read_status	= genphy_read_status,
+	.ack_interrupt	= amd79_ack_interrupt,
+	.config_intr	= amd79_config_intr,
+	.driver		= { .owner = THIS_MODULE,},
+};
+
+static int __init amd79_init(void)
+{
+	int ret;
+
+	ret = phy_driver_register(&amd79_driver);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+static void __exit amd79_exit(void)
+{
+	phy_driver_unregister(&amd79_driver);
+}
+
+module_init(amd79_init);
+module_exit(amd79_exit);
-- 
1.7.5.4

  reply	other threads:[~2011-06-22  7:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-22  7:55 [PATCH 0/4] powerpc, mpc5200: add support for a4m072 board Heiko Schocher
2011-06-22  7:55 ` Heiko Schocher [this message]
2011-07-26  4:55   ` [PATCH 1/4] net, phy: am79c874 support Heiko Schocher
2012-03-18 21:13     ` Anatolij Gustschin
2012-03-18 21:22   ` Anatolij Gustschin
     [not found] ` <1308729311-15375-1-git-send-email-hs-ynQEQJNshbs@public.gmane.org>
2011-06-22  7:55   ` [PATCH 2/4] powerpc, mpc52xx: add a4m072 board support Heiko Schocher
2011-06-22  7:55     ` Heiko Schocher
     [not found]     ` <1308729311-15375-3-git-send-email-hs-ynQEQJNshbs@public.gmane.org>
2011-06-22  8:09       ` Wolfram Sang
2011-06-22  8:09         ` Wolfram Sang
2011-06-22  8:13         ` Heiko Schocher
2011-06-22  8:25           ` Wolfram Sang
2011-06-22  8:25             ` Wolfram Sang
2011-06-22 10:39     ` [PATCH v2 " Heiko Schocher
2011-07-26  4:52       ` Heiko Schocher
2011-07-31  4:08       ` Grant Likely
2011-08-01  5:30         ` Heiko Schocher
2012-03-18 23:38       ` Anatolij Gustschin
2011-07-31  4:05     ` [PATCH " Grant Likely
2011-06-22  7:55 ` [PATCH 3/4] powerpc, mpc5200: update mpc5200_defconfig Heiko Schocher
2011-06-22  7:55 ` [PATCH 4/4] powerpc, mpc5200: add options to mpc5200_defconfig Heiko Schocher
2012-03-18 23:44   ` Anatolij Gustschin

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=1308729311-15375-2-git-send-email-hs@denx.de \
    --to=hs@denx.de \
    --cc=linux-netdev@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=wd@denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.