From: Nick Thompson <nick.thompson@ge.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] TI: DaVinci: Updating EMAC driver for DM365, DM646x and DA8XX
Date: Thu, 17 Dec 2009 11:38:45 +0000 [thread overview]
Message-ID: <4B2A1845.2010207@ge.com> (raw)
In-Reply-To: <20091216220037.2D4774C026@gemini.denx.de>
On 16/12/09 22:00, Wolfgang Denk wrote:
> Dear Nick Thompson,
>
> In message <4B2770F8.5090607@ge.com> you wrote:
>> The EMAC IP on DM365, DM646x and DA830 is slightly different
>> from that on DM644x. This change updates the DaVinci EMAC driver
>> so that EMAC becomes operational on SOCs with EMAC v2.
>>
>> Signed-off-by: Nick Thompson <nick.thompson@ge.com>
>> Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
>> ---
>> Applies to: u-boot-ti
>>
>> This is a combined patch with Sandeep's DM365 and DM646x changes
>> and additional changes for DA830. It replaces previous submissions
>> for EMAC support on these devices.
>>
>> drivers/net/davinci_emac.c | 131 ++++++++++++++++++++++++-----
>> include/asm-arm/arch-davinci/emac_defs.h | 60 +++++++++++++-
>> 2 files changed, 164 insertions(+), 27 deletions(-)
>>
>> diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
>> index fa8cee4..dbf94d2 100644
>> --- a/drivers/net/davinci_emac.c
>> +++ b/drivers/net/davinci_emac.c
>> @@ -42,6 +42,7 @@
>> #include <miiphy.h>
>> #include <malloc.h>
>> #include <asm/arch/emac_defs.h>
>> +#include <asm/io.h>
>>
>> unsigned int emac_dbg = 0;
>> #define debug_emac(fmt,args...) if (emac_dbg) printf(fmt,##args)
>> @@ -107,6 +108,35 @@ static void davinci_eth_mdio_enable(void)
>> while (adap_mdio->CONTROL & MDIO_CONTROL_IDLE) {;}
>
> Please fix this as well while we are here. Please make this:
>
> while (adap_mdio->CONTROL & MDIO_CONTROL_IDLE)
> ;
Yes, will do, here and elsewhere in the file. I will also change
all these cases to use readl().
>
>
>> + /* Wait for command to complete */
>> + while (readl(&adap_mdio->USERACCESS0) & MDIO_USERACCESS0_GO);
>
> Please make this:
>
> while (readl(&adap_mdio->USERACCESS0) & MDIO_USERACCESS0_GO)
> ;
Done.
>
>
>> +static void emac_gigabit_enable(void)
>> +{
>> +#ifdef DAVINCI_EMAC_GIG_ENABLE
>> + int temp
>> +
>> + if (mdio_read(EMAC_MDIO_PHY_NUM, 0) & (1 << 6)) {
>> + /*
>> + * Check if link detected is giga-bit
>> + * If Gigabit mode detected, enable gigbit in MAC and PHY
>> + */
>> + writel(EMAC_MACCONTROL_GIGFORCE |
>> + EMAC_MACCONTROL_GIGABIT_ENABLE,
>> + &adap_emac->MACCONTROL);
>> +
>> + /*
>> + * The SYS_CLK which feeds the SOC for giga-bit operation
>> + * does not seem to be enabled after reset as expected.
>> + * Force enabling SYS_CLK by writing to the PHY
>> + */
>> + temp = mdio_read(EMAC_MDIO_PHY_NUM, 22);
>> + temp |= (1 << 4);
>> + mdio_write(EMAC_MDIO_PHY_NUM, 22, temp);
>> + }
>> +#endif
>> +}
>
> Can we - instead of providing an empty function when
> DAVINCI_EMAC_GIG_ENABLE is not set - either omit this function
> completely, or use a weak implementation instead?
I don't want to use weak as it implies the function maybe replaced. This is
not the intention here. To avoid ifdefs all over the place I have added:
#ifdef DAVINCI_EMAC_GIG_ENABLE
#define mdio_gigabit_detect(phy) (mdio_read(phy, 0) & (1 << 6))
#else
#define mdio_gigabit_detect(phy) 0
#endif
and changed the if in the above function to:
if (mdio_gigabit_detect(EMAC_MDIO_PHY_NUM)) {
int temp;
...
The function is always present, but optimised away if there is a 0 method for
detecting gigabit in the phy. Is that acceptable?
>
>> if (!phy.get_link_speed(active_phy_addr))
>> return(0);
>> + else
>> + emac_gigabit_enable();
>
> No "else" is needed here. Remove it, and un-indent the
> emac_gigabit_enable() call.
Ahh yes - removed in all three cases.
I will submit a new patch tomorrow.
Thanks,
Nick.
next prev parent reply other threads:[~2009-12-17 11:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-15 11:20 [U-Boot] [PATCH] TI: DaVinci: Updating EMAC driver for DM365, DM646x and DA8XX Nick Thompson
2009-12-16 22:00 ` Wolfgang Denk
2009-12-17 11:38 ` Nick Thompson [this message]
2009-12-17 12:03 ` Sriramakrishnan
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=4B2A1845.2010207@ge.com \
--to=nick.thompson@ge.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 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.