Re: [U-Boot] [PATCH] smc911x MII made available

2011-06-30 Thread Luca Ceresoli
Hi Helmut,


helmut.rai...@hale.at wrote:
> From: Helmut Raiger
>
> The driver already had the MII functions, but they have not been
> registered using miiphy_register().
>
> Signed-off-by: Helmut Raiger
[...]

I implemented in the past, but never found the time to polish it for
submission. It looks very similar to yours, and the actual code is the
same.

Your version has more complete #ifdefs, mine has a more complete error
checking.

I'm sending my patch in reply to this e-mail. Feel free to have a look
and integrate my changes with yours.

Luca



--
Luca Ceresoli
Comelit R&D - Progettazione Software

Phone
Fax
Mail
Web
YouTube 

luca.ceres...@comelit.it
http://www.comelitgroup.com/
http://www.youtube.com/comelitgroup
--
Prima di stampare pensa all'ambiente / Think about environment before printing
AVVISO DI CONFIDENZIALITÀ
Questo messaggio ed i suoi eventuali allegati può contenere informazioni 
confidenziali, di proprietà, legalmente protette.È destinato all'utilizzo 
esclusivo del destinatario sopra indicato; privatezza e confidenzialità non 
sono modificati da eventuali errori di trasmissione. Se il messaggio non è a 
lei destinato, non deve utilizzarlo, diffonderlo, copiarlo con qualunque mezzo, 
o intraprendere azioni basandosi su di esso. Se ha ricevuto questo messaggio 
per errore, la preghiamo di volerlo distruggere (unitamente ad eventuali copie 
dello stesso) e di volerci cortesemente informare del fatto scrivendo al 
mittente.
CONFIDENTIALITY NOTICE
This message and its attachments (if any) may contain confidential, proprietary 
or legally privileged information and it is intended only for the use of the 
addressee named above. No confidentiality or privilege is waived or lost by any 
erroneous transmission. If you are not the intended recipient of this message 
you are hereby notified that you must not use, disseminate, copy it in any form 
or take any action in reliance on it. If you have received this message in 
error, please, delete it (and any copies of it) and kindly inform the sender.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] smc911x MII made available

2011-06-29 Thread helmut . raiger
From: Helmut Raiger 

The driver already had the MII functions, but they have not been
registered using miiphy_register().

Signed-off-by: Helmut Raiger 
---
 drivers/net/smc911x.c |   36 ++--
 1 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index aeafeba..6cc236c 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -50,7 +50,7 @@ static void smc911x_handle_mac_address(struct eth_device *dev)
printf(DRIVERNAME ": MAC %pM\n", m);
 }
 
-static int smc911x_miiphy_read(struct eth_device *dev,
+static int smc911x_eth_phy_read(struct eth_device *dev,
u8 phy, u8 reg, u16 *val)
 {
while (smc911x_get_mac_csr(dev, MII_ACC) & MII_ACC_MII_BUSY)
@@ -67,7 +67,7 @@ static int smc911x_miiphy_read(struct eth_device *dev,
return 0;
 }
 
-static int smc911x_miiphy_write(struct eth_device *dev,
+static int smc911x_eth_phy_write(struct eth_device *dev,
u8 phy, u8 reg, u16  val)
 {
while (smc911x_get_mac_csr(dev, MII_ACC) & MII_ACC_MII_BUSY)
@@ -103,10 +103,10 @@ static void smc911x_phy_configure(struct eth_device *dev)
 
smc911x_phy_reset(dev);
 
-   smc911x_miiphy_write(dev, 1, MII_BMCR, BMCR_RESET);
+   smc911x_eth_phy_write(dev, 1, MII_BMCR, BMCR_RESET);
mdelay(1);
-   smc911x_miiphy_write(dev, 1, MII_ADVERTISE, 0x01e1);
-   smc911x_miiphy_write(dev, 1, MII_BMCR, BMCR_ANENABLE |
+   smc911x_eth_phy_write(dev, 1, MII_ADVERTISE, 0x01e1);
+   smc911x_eth_phy_write(dev, 1, MII_BMCR, BMCR_ANENABLE |
BMCR_ANRESTART);
 
timeout = 5000;
@@ -115,7 +115,7 @@ static void smc911x_phy_configure(struct eth_device *dev)
if ((timeout--) == 0)
goto err_out;
 
-   if (smc911x_miiphy_read(dev, 1, MII_BMSR, &status) != 0)
+   if (smc911x_eth_phy_read(dev, 1, MII_BMSR, &status) != 0)
goto err_out;
} while (!(status & BMSR_LSTATUS));
 
@@ -235,6 +235,25 @@ static int smc911x_rx(struct eth_device *dev)
return 0;
 }
 
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+/* wrapper for smc911x_eth_phy_read */
+static int smc911x_miiphy_read(char *devname, u8 phy, u8 reg, u16 *val)
+{
+   struct eth_device *dev = eth_get_dev_by_name(devname);
+   if (dev)
+   return smc911x_eth_phy_read(dev, phy, reg, val);
+   return -1;
+}
+/* wrapper for smc911x_eth_phy_write */
+static int smc911x_miiphy_write(char *devname, u8 phy, u8 reg, u16 val)
+{
+   struct eth_device *dev = eth_get_dev_by_name(devname);
+   if (dev)
+   return smc911x_eth_phy_write(dev, phy, reg, val);
+   return -1;
+}
+#endif
+
 int smc911x_initialize(u8 dev_num, int base_addr)
 {
unsigned long addrl, addrh;
@@ -273,5 +292,10 @@ int smc911x_initialize(u8 dev_num, int base_addr)
sprintf(dev->name, "%s-%hu", DRIVERNAME, dev_num);
 
eth_register(dev);
+
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+   miiphy_register(dev->name, smc911x_miiphy_read, smc911x_miiphy_write);
+#endif
+
return 1;
 }
-- 
1.7.4.4



--
Scanned by MailScanner.

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] smc911x MII made available

2011-06-27 Thread Mike Frysinger
On Monday, June 27, 2011 03:22:03 helmut.rai...@hale.at wrote:
> From: Helmut Raiger 
> 
> The driver already had the MII functions, but they have not been
> registered using miiphy_register().

missing signed-off-by tag

> +static int mii_phy_read(char *devname, u8 phy, u8 reg, u16 *val)

this name is already in common name space in mii_phy.h.  all driver funcs 
really should be prefixed anyways.  so perhaps:
smc911x_mii_phy_read
-mike


signature.asc
Description: This is a digitally signed message part.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] smc911x MII made available

2011-06-27 Thread helmut . raiger
From: Helmut Raiger 

The driver already had the MII functions, but they have not been
registered using miiphy_register().
---
 drivers/net/smc911x.c |   24 
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index aeafeba..8753588 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -235,6 +235,25 @@ static int smc911x_rx(struct eth_device *dev)
return 0;
 }
 
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+/* wrapper for smc911x_miiphy_read */
+static int mii_phy_read(char *devname, u8 phy, u8 reg, u16 *val)
+{
+   struct eth_device *dev = eth_get_dev_by_name(devname);
+   if (dev)
+   return smc911x_miiphy_read(dev, phy, reg, val);
+   return -1;
+}
+/* wrapper for smc911x_miiphy_write */
+static int mii_phy_write(char *devname, u8 phy, u8 reg, u16 val)
+{
+   struct eth_device *dev = eth_get_dev_by_name(devname);
+   if (dev)
+   return smc911x_miiphy_write(dev, phy, reg, val);
+   return -1;
+}
+#endif
+
 int smc911x_initialize(u8 dev_num, int base_addr)
 {
unsigned long addrl, addrh;
@@ -273,5 +292,10 @@ int smc911x_initialize(u8 dev_num, int base_addr)
sprintf(dev->name, "%s-%hu", DRIVERNAME, dev_num);
 
eth_register(dev);
+
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
+   miiphy_register(dev->name, mii_phy_read, mii_phy_write);
+#endif
+
return 1;
 }
-- 
1.7.4.4



--
Scanned by MailScanner.

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot