From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] QE UEC: Add MII Commands
Date: Wed, 16 Jan 2008 12:31:12 +0300 [thread overview]
Message-ID: <20080116093112.GA4961@localhost.localdomain> (raw)
In-Reply-To: <B27D27F93BC429468DBC3B0DA043AA4401BE0860@ILPTEX02.ecitele.com>
Hi David,
On Wed, Jan 16, 2008 at 10:35:51AM +0200, David Saada wrote:
>
> Add MII commands to the UEC driver. Note that once a UEC device is
> selected, any device on its MDIO bus can be addressed.
Long ago I did something like that too (quite useful for playing
with MII registers ;-).
Though, I've done it in different way: I modified miiphyutil.c's
miiphy_register() to accept eth_device instead of device name, thus no
need of devlist hack in the UEC driver...
Unfortunately I didn't find time to convert every user of the
miiphy_register() and submit the patch. So.. while you're at it, maybe
something like this would be better approach?
diff --git a/common/miiphyutil.c b/common/miiphyutil.c
index 281f0b2..3750bb6 100644
--- a/common/miiphyutil.c
+++ b/common/miiphyutil.c
@@ -48,10 +48,11 @@
struct mii_dev {
struct list_head link;
+ struct eth_device *edev;
char *name;
- int (*read) (char *devname, unsigned char addr,
+ int (*read) (struct eth_device *edev, unsigned char addr,
unsigned char reg, unsigned short *value);
- int (*write) (char *devname, unsigned char addr,
+ int (*write) (struct eth_device *edev, unsigned char addr,
unsigned char reg, unsigned short value);
};
@@ -72,12 +73,13 @@ void miiphy_init ()
*
* Register read and write MII access routines for the device <name>.
*/
-void miiphy_register (char *name,
- int (*read) (char *devname, unsigned char addr,
+void miiphy_register (struct eth_device *edev,
+ int (*read) (struct eth_device *edev, unsigned char addr,
unsigned char reg, unsigned short *value),
- int (*write) (char *devname, unsigned char addr,
+ int (*write) (struct eth_device *edev, unsigned char addr,
unsigned char reg, unsigned short value))
{
+ char *name = edev->name;
struct list_head *entry;
struct mii_dev *new_dev;
struct mii_dev *miidev;
@@ -109,6 +111,7 @@ void miiphy_register (char *name,
INIT_LIST_HEAD (&new_dev->link);
new_dev->read = read;
new_dev->write = write;
+ new_dev->edev = edev;
new_dev->name = (char *)(new_dev + 1);
strncpy (new_dev->name, name, name_len);
new_dev->name[name_len] = '\0';
@@ -175,7 +178,7 @@ int miiphy_read (char *devname, unsigned char addr, unsigned char reg,
if (strcmp (devname, dev->name) == 0) {
found_dev = 1;
- read_ret = dev->read (devname, addr, reg, value);
+ read_ret = dev->read (dev->edev, addr, reg, value);
break;
}
}
@@ -212,7 +215,7 @@ int miiphy_write (char *devname, unsigned char addr, unsigned char reg,
if (strcmp (devname, dev->name) == 0) {
found_dev = 1;
- write_ret = dev->write (devname, addr, reg, value);
+ write_ret = dev->write (dev->edev, addr, reg, value);
break;
}
}
diff --git a/drivers/qe/uec.c b/drivers/qe/uec.c
index a27c12a..2d29403 100644
--- a/drivers/qe/uec.c
+++ b/drivers/qe/uec.c
@@ -1296,6 +1296,9 @@ int uec_initialize(int index)
phy_change(dev);
+ if (index == 1)
+ uec_mmiphy_register(dev);
+
return 1;
}
#endif /* CONFIG_QE */
diff --git a/drivers/qe/uec_phy.c b/drivers/qe/uec_phy.c
index 6882d03..ccd6645 100644
--- a/drivers/qe/uec_phy.c
+++ b/drivers/qe/uec_phy.c
@@ -681,4 +681,28 @@ void change_phy_interface_mode (struct eth_device *dev, enet_interface_e mode)
marvell_phy_interface_mode (dev, mode);
#endif
}
+
+
+#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) \
+ && !defined(BITBANGMII)
+static int uec_miiphy_read(struct eth_device *dev, unsigned char addr,
+ unsigned char reg, unsigned short *value)
+{
+ *value = uec_read_phy_reg(dev, addr, reg);
+ return 0;
+}
+
+static int uec_miiphy_write(struct eth_device *dev, unsigned char addr,
+ unsigned char reg, unsigned short value)
+{
+ uec_write_phy_reg(dev, addr, reg, value);
+ return 0;
+}
+
+void uec_mmiphy_register(struct eth_device *dev)
+{
+ miiphy_register(dev, uec_miiphy_read, uec_miiphy_write);
+}
+#endif
+
#endif /* CONFIG_QE */
diff --git a/drivers/qe/uec_phy.h b/drivers/qe/uec_phy.h
index 6f769fb..ef62f0b 100644
--- a/drivers/qe/uec_phy.h
+++ b/drivers/qe/uec_phy.h
@@ -261,4 +261,5 @@ int uec_read_phy_reg (struct eth_device *dev, int mii_id, int regnum);
void mii_clear_phy_interrupt (struct uec_mii_info *mii_info);
void mii_configure_phy_interrupt (struct uec_mii_info *mii_info,
u32 interrupts);
+void uec_mmiphy_register(struct eth_device *dev);
#endif /* __UEC_PHY_H__ */
diff --git a/include/miiphy.h b/include/miiphy.h
index 5518a0a..0ff4ae6 100644
--- a/include/miiphy.h
+++ b/include/miiphy.h
@@ -48,10 +48,10 @@ int miiphy_link (char *devname, unsigned char addr);
void miiphy_init (void);
-void miiphy_register (char *devname,
- int (*read) (char *devname, unsigned char addr,
+void miiphy_register (struct eth_device *edev,
+ int (*read) (struct eth_device *edev, unsigned char addr,
unsigned char reg, unsigned short *value),
- int (*write) (char *devname, unsigned char addr,
+ int (*write) (struct eth_device *edev, unsigned char addr,
unsigned char reg, unsigned short value));
int miiphy_set_current_dev (char *devname);
next prev parent reply other threads:[~2008-01-16 9:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-16 8:35 [U-Boot-Users] [PATCH] QE UEC: Add MII Commands David Saada
2008-01-16 9:31 ` Anton Vorontsov [this message]
2008-01-16 9:44 ` David Saada
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=20080116093112.GA4961@localhost.localdomain \
--to=avorontsov@ru.mvista.com \
--cc=u-boot@lists.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox