From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] 83xx, uec: adjust enet_interface settings on the fly.
Date: Fri, 08 Jan 2010 08:37:53 +0100 [thread overview]
Message-ID: <4B46E0D1.2090706@denx.de> (raw)
In-Reply-To: <D7CCA83BB0796C49BC0BB53B6AB120898BE28F@zch01exm21.fsl.freescale.net>
Hello Liu,
Liu Dave-R63238 wrote:
>> did you make any effort to refactor this into the existing
>> eth_type == GIGA_ETH code? I'm not sure why that code became
>> conditional in commit
>> 24c3aca3f1358b113d3215adb5433b156e99f72b "mpc83xx: Add
>> support for the MPC832XEMDS board" in the first place - Dave?
>
> I don't remember why I added the eth_type==GIGA_ETH condition.
> If it is possible, please refactor it as Kim.
Hmm.. while looking at this code, a question comes in mind:
Did this code (eth_type==GIGA_ETH) work correctly?
I see there is a switching possible from 1000 to 100 or 10, but
never back to 1000, because the 1000 case did nothing ...?
Is this intentionally?
Also uec->uec_info->enet_interface is never updated, which should
be done ... or?
If the above mentioned is no problem, following patch comes
in my mind:
If using UCC as Ethernet Controller and type = FAST_ETH, it was
not possible to switch between 10 and 100 MBit interfaces. This
patch adds this for following interfaces:
10_MII
10_RMII
10_RGMII
100_MII
100_RMII
100_RGMII
Signed-off-by: Heiko Schocher <hs@denx.de>
---
drivers/qe/uec.c | 104 ++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 78 insertions(+), 26 deletions(-)
diff --git a/drivers/qe/uec.c b/drivers/qe/uec.c
index db95ada..263df9c 100644
--- a/drivers/qe/uec.c
+++ b/drivers/qe/uec.c
@@ -65,6 +65,22 @@ static uec_info_t uec_info[] = {
#define MAXCONTROLLERS (8)
+static char *enet_interface_name[] = {
+ "10_MII",
+ "10_RMII",
+ "10_RGMII",
+ "100_MII",
+ "100_RMII",
+ "100_RGMII",
+ "1000_GMII",
+ "1000_RGMII",
+ "1000_RGMII_ID",
+ "1000_RGMII_RXID",
+ "1000_TBI",
+ "1000_RTBI",
+ "1000_SGMII"
+};
+
static struct eth_device *devlist[MAXCONTROLLERS];
u16 phy_read (struct uec_mii_info *mii_info, u16 regnum);
@@ -497,6 +513,66 @@ bus_fail:
return err;
}
+static void adjust_enet_interface_speed(int speed, struct eth_device *dev)
+{
+ uec_private_t *uec = (uec_private_t *)dev->priv;
+ uec_t *uec_regs;
+ int change = 0;
+
+ extern void change_phy_interface_mode(struct eth_device *dev,
+ enet_interface_e mode);
+ uec_regs = uec->uec_regs;
+
+ switch (speed) {
+ case 1000:
+ break;
+ case 100:
+ switch (uec->uec_info->enet_interface) {
+ case ENET_10_MII:
+ case ENET_10_RMII:
+ case ENET_10_RGMII:
+ uec->uec_info->enet_interface += 3;
+ change = 1;
+ break;
+ default:
+ uec->uec_info->enet_interface = ENET_100_RGMII;
+ change = 1;
+ break;
+ }
+ break;
+ case 10:
+ switch (uec->uec_info->enet_interface) {
+ case ENET_100_MII:
+ case ENET_100_RMII:
+ case ENET_100_RGMII:
+ uec->uec_info->enet_interface -= 3;
+ change = 1;
+ break;
+ default:
+ uec->uec_info->enet_interface = ENET_10_RGMII;
+ change = 1;
+ break;
+ }
+ break;
+ default:
+ /* do nothing, not supported yet */
+ printf("%s: speed: %d and mode: %d not supported yet.\n",
+ __func__, speed, uec->uec_info->enet_interface);
+ break;
+ }
+ if (change) {
+ printf ("switching to %s\n",
+ enet_interface_name[uec->uec_info->enet_interface]);
+ /* change phy */
+ change_phy_interface_mode(dev,
+ uec->uec_info->enet_interface);
+ /* change the MAC interface mode */
+ uec_set_mac_if_mode(uec,
+ uec->uec_info->enet_interface);
+
+ }
+}
+
static void adjust_link(struct eth_device *dev)
{
uec_private_t *uec = (uec_private_t *)dev->priv;
@@ -522,32 +598,7 @@ static void adjust_link(struct eth_device *dev)
}
if (mii_info->speed != uec->oldspeed) {
- if (uec->uec_info->uf_info.eth_type == GIGA_ETH) {
- switch (mii_info->speed) {
- case 1000:
- break;
- case 100:
- printf ("switching to rgmii 100\n");
- /* change phy to rgmii 100 */
- change_phy_interface_mode(dev,
- ENET_100_RGMII);
- /* change the MAC interface mode */
- uec_set_mac_if_mode(uec,ENET_100_RGMII);
- break;
- case 10:
- printf ("switching to rgmii 10\n");
- /* change phy to rgmii 10 */
- change_phy_interface_mode(dev,
- ENET_10_RGMII);
- /* change the MAC interface mode */
- uec_set_mac_if_mode(uec,ENET_10_RGMII);
- break;
- default:
- printf("%s: Ack,Speed(%d)is illegal\n",
- dev->name, mii_info->speed);
- break;
- }
- }
+ adjust_enet_interface_speed(mii_info->speed, dev);
printf("%s: Speed %dBT\n", dev->name, mii_info->speed);
uec->oldspeed = mii_info->speed;
@@ -1215,6 +1266,7 @@ static int uec_init(struct eth_device* dev, bd_t *bd)
if (err || i <= 0)
printf("warning: %s: timeout on PHY link\n", dev->name);
+ adjust_link(dev);
uec->the_first_run = 1;
}
--
1.6.2.5
bye
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
next prev parent reply other threads:[~2010-01-08 7:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-07 8:01 [U-Boot] 83xx, uec: adjust enet_interface settings on the fly Heiko Schocher
2010-01-08 0:59 ` Kim Phillips
2010-01-08 3:11 ` Liu Dave-R63238
2010-01-08 7:37 ` Heiko Schocher [this message]
2010-01-08 7:52 ` Liu Dave-R63238
2010-01-08 8:12 ` Heiko Schocher
2010-01-08 8:14 ` Liu Dave-R63238
2010-01-19 6:49 ` Andy Fleming
2010-01-19 8:42 ` Heiko Schocher
2010-01-20 8:04 ` [U-Boot] 83xx, uec: split enet_interface in two variables, was: " Heiko Schocher
2010-02-01 5:25 ` Ben Warren
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=4B46E0D1.2090706@denx.de \
--to=hs@denx.de \
--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 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.