diff mbox

[U-Boot] phy: Add support PHY of SMSC

Message ID 1322119455-29628-1-git-send-email-nobuhiro.iwamatsu.yj@renesas.com
State Accepted
Delegated to: Wolfgang Denk
Headers show

Commit Message

Nobuhiro Iwamatsu Nov. 24, 2011, 7:24 a.m. UTC
This add support PHY of SMSC. 
Following phy can be used by set CONFIG_PHY_SMSC to config.
 - SMSC LAN8700
 - SMSC LAN8710/LAN8720
 - SMSC LAN8710/LAN8720

A setup of PHY was copied from linux kenrel. 

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
---
 drivers/net/phy/Makefile |    1 +
 drivers/net/phy/phy.c    |    3 +
 drivers/net/phy/smsc.c   |   92 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 96 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/phy/smsc.c

Comments

Wolfgang Denk Dec. 5, 2011, 10:10 p.m. UTC | #1
Dear Nobuhiro Iwamatsu,

In message <1322119455-29628-1-git-send-email-nobuhiro.iwamatsu.yj@renesas.com> you wrote:
> This add support PHY of SMSC. 
> Following phy can be used by set CONFIG_PHY_SMSC to config.
>  - SMSC LAN8700
>  - SMSC LAN8710/LAN8720
>  - SMSC LAN8710/LAN8720
> 
> A setup of PHY was copied from linux kenrel. 
> 
> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
> ---
>  drivers/net/phy/Makefile |    1 +
>  drivers/net/phy/phy.c    |    3 +
>  drivers/net/phy/smsc.c   |   92 ++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 96 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/net/phy/smsc.c

This patch was not white-space-clean. Checkpatch reported 2 x  ERROR:
trailing whitespace

Fixed when applying.   I also changed the subject and commit messahe a
tiny bit.

Best regards,

Wolfgang Denk
Nobuhiro Iwamatsu Dec. 6, 2011, 2:15 a.m. UTC | #2
Hi,

2011/12/6 Wolfgang Denk <wd@denx.de>:
> Dear Nobuhiro Iwamatsu,
>
> In message <1322119455-29628-1-git-send-email-nobuhiro.iwamatsu.yj@renesas.com> you wrote:
>> This add support PHY of SMSC.
>> Following phy can be used by set CONFIG_PHY_SMSC to config.
>>  - SMSC LAN8700
>>  - SMSC LAN8710/LAN8720
>>  - SMSC LAN8710/LAN8720
>>
>> A setup of PHY was copied from linux kenrel.
>>
>> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
>> ---
>>  drivers/net/phy/Makefile |    1 +
>>  drivers/net/phy/phy.c    |    3 +
>>  drivers/net/phy/smsc.c   |   92 ++++++++++++++++++++++++++++++++++++++++++++++
>>  3 files changed, 96 insertions(+), 0 deletions(-)
>>  create mode 100644 drivers/net/phy/smsc.c
>
> This patch was not white-space-clean. Checkpatch reported 2 x  ERROR:
> trailing whitespace
>
> Fixed when applying.   I also changed the subject and commit messahe a
> tiny bit.
>

Sorry, and thanks!

Nobuhiro
diff mbox

Patch

diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index a59834b..feced39 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -38,6 +38,7 @@  COBJS-$(CONFIG_PHY_MARVELL) += marvell.o
 COBJS-$(CONFIG_PHY_MICREL) += micrel.o
 COBJS-$(CONFIG_PHY_NATSEMI) += natsemi.o
 COBJS-$(CONFIG_PHY_REALTEK) += realtek.o
+COBJS-$(CONFIG_PHY_SMSC) += smsc.o
 COBJS-$(CONFIG_PHY_TERANETICS) += teranetics.o
 COBJS-$(CONFIG_PHY_VITESSE) += vitesse.o
 
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 8da7688..eb55180 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -444,6 +444,9 @@  int phy_init(void)
 #ifdef CONFIG_PHY_REALTEK
 	phy_realtek_init();
 #endif
+#ifdef CONFIG_PHY_SMSC
+	phy_smsc_init();
+#endif
 #ifdef CONFIG_PHY_TERANETICS
 	phy_teranetics_init();
 #endif
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
new file mode 100644
index 0000000..43ecd34
--- /dev/null
+++ b/drivers/net/phy/smsc.c
@@ -0,0 +1,92 @@ 
+/*
+ * SMSC PHY drivers
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ * 
+ * Base code from drivers/net/phy/davicom.c
+ *   Copyright 2010-2011 Freescale Semiconductor, Inc.
+ *   author Andy Fleming
+ * 
+ * Some code get from linux kenrel
+ * Copyright (c) 2006 Herbert Valerio Riedel <hvr@gnu.org>
+ *
+ */
+#include <miiphy.h>
+
+static int smsc_parse_status(struct phy_device *phydev)
+{
+	int mii_reg;
+
+	mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
+
+	if (mii_reg & (BMSR_100FULL | BMSR_100HALF))
+		phydev->speed = SPEED_100;
+	else
+		phydev->speed = SPEED_10;
+
+	if (mii_reg & (BMSR_10FULL | BMSR_100FULL))
+		phydev->duplex = DUPLEX_FULL;
+	else
+		phydev->duplex = DUPLEX_HALF;
+
+	return 0;
+}
+
+static int smsc_startup(struct phy_device *phydev)
+{
+	genphy_update_link(phydev);
+	smsc_parse_status(phydev);
+	return 0;
+}
+
+static struct phy_driver lan8700_driver = {
+	.name = "SMSC LAN8700",
+	.uid = 0x0007c0c0,
+	.mask = 0xffff0,
+	.features = PHY_BASIC_FEATURES,
+	.config = &genphy_config_aneg,
+	.startup = &smsc_startup,
+	.shutdown = &genphy_shutdown,
+};
+
+static struct phy_driver lan911x_driver = {
+	.name = "SMSC LAN911x Internal PHY",
+	.uid = 0x0007c0d0,
+	.mask = 0xffff0,
+	.features = PHY_BASIC_FEATURES,
+	.config = &genphy_config_aneg,
+	.startup = &smsc_startup,
+	.shutdown = &genphy_shutdown,
+};
+
+static struct phy_driver lan8710_driver = {
+	.name = "SMSC LAN8710/LAN8720",
+	.uid = 0x0007c0f0,
+	.mask = 0xffff0,
+	.features = PHY_GBIT_FEATURES,
+	.config = &genphy_config_aneg,
+	.startup = &smsc_startup,
+	.shutdown = &genphy_shutdown,
+};
+
+int phy_smsc_init(void)
+{
+	phy_register(&lan8710_driver);
+	phy_register(&lan911x_driver);
+	phy_register(&lan8700_driver);
+
+	return 0;
+}