From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 03/20] FEC: Add support for iMX28 quirks
Date: Thu, 10 Nov 2011 14:09:18 +0100 [thread overview]
Message-ID: <4EBBCCFE.5050203@denx.de> (raw)
In-Reply-To: <1320830307-4762-4-git-send-email-marek.vasut@gmail.com>
On 11/09/2011 10:18 AM, Marek Vasut wrote:
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> Cc: Ben Warren <biggerbadderben@gmail.com>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Detlev Zundel <dzu@denx.de>
> ---
> drivers/net/fec_mxc.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
> 1 files changed, 42 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index 0c0c7cd..b05a4c0 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -42,6 +42,14 @@ DECLARE_GLOBAL_DATA_PTR;
> #define CONFIG_FEC_XCV_TYPE MII100
> #endif
>
> +/*
> + * The i.MX28 operates with packets in big endian. We need to swap them before
> + * sending and after receiving.
> + */
> +#ifdef CONFIG_MX28
> +#define CONFIG_FEC_MXC_SWAP_PACKET
> +#endif
> +
> #undef DEBUG
>
> struct nbuf {
> @@ -51,6 +59,32 @@ struct nbuf {
> uint8_t head[16]; /**< MAC header(6 + 6 + 2) + 2(aligned) */
> };
>
> +#ifdef CONFIG_FEC_MXC_SWAP_PACKET
> +static void swap_packet(uint32_t *packet, int length)
> +{
> + int i;
> +
> + for (i = 0; i < DIV_ROUND_UP(length, 4); i++)
> + packet[i] = __swab32(packet[i]);
> +}
> +#endif
> +
> +/*
> + * The i.MX28 has two ethernet interfaces, but they are not equal.
> + * Only the first one can access the MDIO bus.
> + */
> +#ifdef CONFIG_MX28
> +static inline struct ethernet_regs *fec_miiphy_fec_to_eth(struct fec_priv *fec)
> +{
> + return (struct ethernet_regs *)MXS_ENET0_BASE;
> +}
> +#else
> +static inline struct ethernet_regs *fec_miiphy_fec_to_eth(struct fec_priv *fec)
> +{
> + return fec->eth;
> +}
> +#endif
> +
> /*
> * MII-interface related functions
> */
> @@ -59,7 +93,7 @@ static int fec_miiphy_read(const char *dev, uint8_t phyAddr, uint8_t regAddr,
> {
> struct eth_device *edev = eth_get_dev_by_name(dev);
> struct fec_priv *fec = (struct fec_priv *)edev->priv;
> - struct ethernet_regs *eth = fec->eth;
> + struct ethernet_regs *eth = fec_miiphy_fec_to_eth(fec);
>
> uint32_t reg; /* convenient holder for the PHY register */
> uint32_t phy; /* convenient holder for the PHY */
> @@ -117,7 +151,7 @@ static int fec_miiphy_write(const char *dev, uint8_t phyAddr, uint8_t regAddr,
> {
> struct eth_device *edev = eth_get_dev_by_name(dev);
> struct fec_priv *fec = (struct fec_priv *)edev->priv;
> - struct ethernet_regs *eth = fec->eth;
> + struct ethernet_regs *eth = fec_miiphy_fec_to_eth(fec);
>
> uint32_t reg; /* convenient holder for the PHY register */
> uint32_t phy; /* convenient holder for the PHY */
> @@ -572,6 +606,9 @@ static int fec_send(struct eth_device *dev, volatile void* packet, int length)
> * Note: We are always using the first buffer for transmission,
> * the second will be empty and only used to stop the DMA engine
> */
> +#ifdef CONFIG_FEC_MXC_SWAP_PACKET
> + swap_packet((uint32_t *)packet, length);
> +#endif
> writew(length, &fec->tbd_base[fec->tbd_index].data_length);
> writel((uint32_t)packet, &fec->tbd_base[fec->tbd_index].data_pointer);
> /*
> @@ -668,6 +705,9 @@ static int fec_recv(struct eth_device *dev)
> /*
> * Fill the buffer and pass it to upper layers
> */
> +#ifdef CONFIG_FEC_MXC_SWAP_PACKET
> + swap_packet((uint32_t *)frame->data, frame_length);
> +#endif
> memcpy(buff, frame->data, frame_length);
> NetReceive(buff, frame_length);
> len = frame_length;
Applied to u-boot-imx, thanks.
Best 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:[~2011-11-10 13:09 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-09 9:18 [U-Boot] [PATCH 00/20 FINAL] Support for the DENX M28 SoM Marek Vasut
2011-11-09 9:18 ` [U-Boot] [PATCH 01/20] iMX28: Initial support for iMX28 CPU Marek Vasut
2011-11-09 9:18 ` [U-Boot] [PATCH 02/20] iMX28: Add SSP MMC driver Marek Vasut
2011-11-10 13:08 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 03/20] FEC: Add support for iMX28 quirks Marek Vasut
2011-11-10 13:09 ` Stefano Babic [this message]
2011-11-09 9:18 ` [U-Boot] [PATCH 04/20] iMX28: Add PINMUX control Marek Vasut
2011-11-10 13:09 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 05/20] iMX28: Add I2C bus driver Marek Vasut
2011-11-09 9:38 ` Heiko Schocher
2011-11-09 10:46 ` Marek Vasut
2011-11-10 13:10 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 06/20] iMX28: Add GPIO control Marek Vasut
2011-11-10 13:11 ` Stefano Babic
2011-11-10 16:23 ` Mike Frysinger
2011-11-10 16:58 ` Marek Vasut
2011-11-10 17:10 ` Mike Frysinger
2011-11-10 17:44 ` Marek Vasut
2011-11-09 9:18 ` [U-Boot] [PATCH 07/20] iMX28: Add SPI driver Marek Vasut
2011-11-10 13:11 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 08/20] iMX28: Add APBH DMA driver Marek Vasut
2011-11-10 13:12 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 09/20] iMX28: Add GPMI NAND driver Marek Vasut
2011-11-10 13:12 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 10/20] iMX28: Add driver for internal RTC Marek Vasut
2011-11-10 13:12 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 11/20] iMX28: Add image header generator tool Marek Vasut
2011-11-10 13:12 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 12/20] iMX28: Add u-boot.sb target to Makefile Marek Vasut
2011-11-10 13:13 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 13/20] iMX28: Add support for DENX M28EVK board Marek Vasut
2011-11-10 13:13 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 14/20] M28: Add MMC SPL Marek Vasut
2011-11-10 13:13 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 15/20] M28: Add doc/README.m28 documentation Marek Vasut
2011-11-10 13:14 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 16/20] iMX28: Fix ARM vector handling Marek Vasut
2011-11-10 13:14 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 17/20] M28: Add memory detection into SPL Marek Vasut
2011-11-10 13:14 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 18/20] iMX28: Add USB and USB PHY register definitions Marek Vasut
2011-11-10 13:15 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 19/20] iMX28: Add USB HOST driver Marek Vasut
2011-11-10 13:15 ` Stefano Babic
2011-11-09 9:18 ` [U-Boot] [PATCH 20/20] M28EVK: Enable USB HOST support Marek Vasut
2011-11-10 13:16 ` Stefano Babic
2011-11-11 14:07 ` Veli-Pekka Peltola
2011-11-11 17:49 ` Marek Vasut
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=4EBBCCFE.5050203@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