From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 6/9] fec_mxc: add support for MX51 processor
Date: Mon, 18 Jan 2010 10:35:10 +0100 [thread overview]
Message-ID: <4B542B4E.4000108@denx.de> (raw)
In-Reply-To: <20100117123400.9A006C88AE@gemini.denx.de>
Wolfgang Denk wrote:
> Dear Stefano Babic,
>
Hi Wolfgang,
>> -#include <asm/arch/clock.h>
>> #include <asm/arch/imx-regs.h>
>> +#ifndef CONFIG_MX51
>> +#include <asm/arch/clock.h>imx_get_ahbclk
>> +#endif
>
> Can we not implement the clock stuff for the iMX51 in such a way that
> we don't need #ifdef's here?
Good hint, I do it !
>
>> @@ -108,6 +110,23 @@ static int fec_miiphy_read(char *dev, uint8_t phyAddr, uint8_t regAddr,
>> return 0;
>> }
>>
>> +static void fec_mii_setspeed(struct fec_priv *fec)
>> +{
>> +#ifdef CONFIG_MX51
>> + writel((((mxc_get_clock(MXC_IPG_CLK) + 499999) / 5000000) << 1),
>> + &fec->eth->mii_speed);
>> +#else
>> + /*
>> + * Set MII_SPEED = (1/(mii_speed * 2)) * System Clock
>> + * and do not drop the Preamble.
>> + */
>> + writel((((imx_get_ahbclk() / 1000000) + 2) / 5) << 1,
>> + &fec->eth->mii_speed);
>
> What exactly, in addition to the (technically irrelevant) names and
> the different way how the rounding is implemented, requires the #ifdef
> here?
You are right, there is no technical reason. The only thing here is to
get the correct clock source. I will get as in serial_mxc and setting a
imx_get_fecclk() for both processors (i.MX27 and i.MX51), removing the
ifdef.
>> static int fec_get_hwaddr(struct eth_device *dev, unsigned char *mac)
>> {
>> +#ifndef CONFIG_MX51
>> struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
>> int i;
>>
>> @@ -306,6 +326,9 @@ static int fec_get_hwaddr(struct eth_device *dev, unsigned char *mac)
>> mac[6-1-i] = readl(&iim->iim_bank_area0[IIM0_MAC + i]);
>>
>> return is_valid_ether_addr(mac);
>> +#else
>> + return -1;
>> +#endif
>> }
>
> General remark: please use positive logic in cases like this, as it
> results in simpler code which is much easier to read.
Understood, thanks.
>> +#ifndef CONFIG_MX51
>> + struct pll_regs *pll = (struct pll_regs *)IMX_PLL_BASE;
>>
>> /* enable FEC clock */
>> writel(readl(&pll->pccr1) | PCCR1_HCLK_FEC, &pll->pccr1);
>> writel(readl(&pll->pccr0) | PCCR0_FEC_EN, &pll->pccr0);
>> +#endif
>
> Can we implement this clock enable in a way that goes without #ifdef ?
I think this should be dropped from the driver. The driver should be
responsible to set up the FEC controller and nothing else. Enabling the
clock should be done in another place (probably in the cpu related part
?), but not here. However, this is related to the i.MX27, I am not sure
where we have to move this code.
>> + tmp = getenv("ethaddr");
>> if ((NULL != tmp) && (12 <= strlen(tmp))) {
>> int i;
>> /* convert MAC from string to int */
>
> This is wrong and should be fixed. We don't convert to "int" but to
> "uchar[]"; While we touch this, please dump the code completely and
> use eth_getenv_enetaddr() instead.
Thanks, understood.
Regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
next prev parent reply other threads:[~2010-01-18 9:35 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-11 12:25 [U-Boot] MX51 Support in u-boot Stefano Babic
2010-01-11 12:25 ` [U-Boot] [PATCH 1/9] mkimage: Add Freescale imx Boot Image support (imximage) Stefano Babic
2010-01-11 12:25 ` [U-Boot] [PATCH 2/9] MX51: Add initial support for the Freescale MX51 Stefano Babic
2010-01-11 12:25 ` [U-Boot] [PATCH 3/9] MX51: Add register definitions Stefano Babic
2010-01-11 12:25 ` [U-Boot] [PATCH 4/9] MX51: Add pin and multiplexer definitions Stefano Babic
2010-01-11 12:25 ` [U-Boot] [PATCH 5/9] serial_mxc: add support for MX51 processor Stefano Babic
2010-01-11 12:25 ` [U-Boot] [PATCH 6/9] fec_mxc: " Stefano Babic
2010-01-11 12:25 ` [U-Boot] [PATCH 7/9] fsl_esdhc: add support for mx51 processor Stefano Babic
2010-01-11 12:25 ` [U-Boot] [PATCH 8/9] mmc: check correctness of the voltage mask in ocr Stefano Babic
2010-01-11 12:26 ` [U-Boot] [PATCH 9/9] Add initial support for Freescale mx51evk board Stefano Babic
2010-01-11 17:55 ` Fabio Estevam
2010-01-11 23:53 ` Fabio Estevam
2010-01-17 13:05 ` Wolfgang Denk
2010-01-18 7:34 ` Stefano Babic
2010-01-18 8:50 ` Wolfgang Denk
2010-01-18 10:25 ` Stefano Babic
2010-01-17 12:46 ` [U-Boot] [PATCH 7/9] fsl_esdhc: add support for mx51 processor Wolfgang Denk
2010-01-18 8:53 ` Stefano Babic
2010-01-18 9:16 ` Wolfgang Denk
2010-01-17 12:34 ` [U-Boot] [PATCH 6/9] fec_mxc: add support for MX51 processor Wolfgang Denk
2010-01-18 9:35 ` Stefano Babic [this message]
2010-01-18 11:24 ` Wolfgang Denk
2010-01-18 12:19 ` Stefano Babic
2010-01-18 17:02 ` John Rigby
2010-01-17 11:23 ` [U-Boot] [PATCH 5/9] serial_mxc: " Wolfgang Denk
2010-01-18 7:16 ` Stefano Babic
2010-01-18 8:45 ` Wolfgang Denk
2010-01-11 15:58 ` [U-Boot] [PATCH 4/9] MX51: Add pin and multiplexer definitions Detlev Zundel
2010-01-17 11:19 ` Wolfgang Denk
2010-01-11 15:56 ` [U-Boot] [PATCH 3/9] MX51: Add register definitions Detlev Zundel
2010-01-17 11:16 ` Wolfgang Denk
2010-01-18 6:40 ` Stefano Babic
2010-01-18 7:53 ` Wolfgang Denk
2010-01-11 15:48 ` [U-Boot] [PATCH 2/9] MX51: Add initial support for the Freescale MX51 Detlev Zundel
2010-01-11 15:58 ` Stefano Babic
2010-01-11 16:07 ` Detlev Zundel
2010-01-11 15:59 ` Detlev Zundel
2010-01-17 10:28 ` Wolfgang Denk
2010-01-18 7:05 ` Stefano Babic
2010-01-18 8:42 ` Wolfgang Denk
2010-01-11 15:43 ` [U-Boot] [PATCH 1/9] mkimage: Add Freescale imx Boot Image support (imximage) Detlev Zundel
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=4B542B4E.4000108@denx.de \
--to=sbabic@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox