public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 15/21] sunxi: emac: Add device model support
Date: Sat, 25 Apr 2015 10:39:28 +0200	[thread overview]
Message-ID: <553B52C0.8010205@redhat.com> (raw)
In-Reply-To: <CAPnjgZ1zFE8RK9iYEn3q35kmhAfBAPv5hZAJ=jO8pY+Yd-_k+g@mail.gmail.com>

Hi,

On 25-04-15 01:24, Simon Glass wrote:
> Hi Hans,
>
> On 24 April 2015 at 07:48, Hans de Goede <hdegoede@redhat.com> wrote:
>> Modify the sunxi-emac eth driver to support device model.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>   arch/arm/cpu/armv7/sunxi/board.c |  4 +-
>>   drivers/net/sunxi_emac.c         | 81 ++++++++++++++++++++++++++++++++++++++++
>>   2 files changed, 84 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c
>> index 7e9cf11..cde13ef 100644
>> --- a/arch/arm/cpu/armv7/sunxi/board.c
>> +++ b/arch/arm/cpu/armv7/sunxi/board.c
>> @@ -12,7 +12,9 @@
>>
>>   #include <common.h>
>>   #include <i2c.h>
>> +#ifndef CONFIG_DM_ETH
>>   #include <netdev.h>
>> +#endif
>>   #include <miiphy.h>
>>   #include <serial.h>
>>   #ifdef CONFIG_SPL_BUILD
>> @@ -224,7 +226,7 @@ int cpu_eth_init(bd_t *bis)
>>          mdelay(200);
>>   #endif
>>
>> -#ifdef CONFIG_SUNXI_EMAC
>> +#if defined CONFIG_SUNXI_EMAC && !defined CONFIG_DM_ETH
>>          rc = sunxi_emac_initialize(bis);
>>          if (rc < 0) {
>>                  printf("sunxi: failed to initialize emac\n");
>> diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c
>> index 038f474..a9efe11 100644
>> --- a/drivers/net/sunxi_emac.c
>> +++ b/drivers/net/sunxi_emac.c
>> @@ -7,6 +7,7 @@
>>    */
>>
>>   #include <common.h>
>> +#include <dm.h>
>>   #include <linux/err.h>
>>   #include <malloc.h>
>>   #include <miiphy.h>
>> @@ -160,6 +161,9 @@ struct emac_eth_dev {
>>          struct mii_dev *bus;
>>          struct phy_device *phydev;
>>          int link_printed;
>> +#ifdef CONFIG_DM_ETH
>> +       uchar rx_buf[DMA_CPU_TRRESHOLD];
>
> THRESHOLD

This define already exists and actually has the typo in it, I can
do another preparation patch fixing this I guess.

> Also does this need to be DMA-aligned? - e.g. DM_FLAG_ALLOC_PRIV_DMA

Nope, this driver only uses mmio, not dma, the name of the
variable not only has a typo it is also misleading. Guess I
better do a preparation patch to slot in before this one
to fixup the define's name.

Regards,

Hans


>
>> +#endif
>>   };
>>
>>   struct emac_rxhdr {
>> @@ -509,6 +513,7 @@ static void sunxi_emac_board_setup(struct emac_eth_dev *priv)
>>          clrsetbits_le32(&regs->mac_mcfg, 0xf << 2, 0xd << 2);
>>   }
>>
>> +#ifndef CONFIG_DM_ETH
>>   static int sunxi_emac_eth_init(struct eth_device *dev, bd_t *bis)
>>   {
>>          return _sunxi_emac_eth_init(dev->priv, dev->enetaddr);
>> @@ -573,3 +578,79 @@ int sunxi_emac_initialize(void)
>>
>>          return sunxi_emac_init_phy(priv, dev);
>>   }
>> +#endif
>> +
>> +#ifdef CONFIG_DM_ETH
>> +static int sunxi_emac_eth_start(struct udevice *dev)
>> +{
>> +       struct eth_pdata *pdata = dev_get_platdata(dev);
>> +
>> +       return _sunxi_emac_eth_init(dev->priv, pdata->enetaddr);
>> +}
>> +
>> +static int sunxi_emac_eth_send(struct udevice *dev, void *packet, int length)
>> +{
>> +       struct emac_eth_dev *priv = dev_get_priv(dev);
>> +
>> +       return _sunxi_emac_eth_send(priv, packet, length);
>> +}
>> +
>> +static int sunxi_emac_eth_recv(struct udevice *dev, uchar **packetp)
>> +{
>> +       struct emac_eth_dev *priv = dev_get_priv(dev);
>> +       int rx_len;
>> +
>> +       rx_len = _sunxi_emac_eth_recv(priv, priv->rx_buf);
>> +       *packetp = priv->rx_buf;
>> +
>> +       return rx_len;
>> +}
>> +
>> +static void sunxi_emac_eth_stop(struct udevice *dev)
>> +{
>> +       /* Nothing to do here */
>> +}
>> +
>> +static int sunxi_emac_eth_probe(struct udevice *dev)
>> +{
>> +       struct eth_pdata *pdata = dev_get_platdata(dev);
>> +       struct emac_eth_dev *priv = dev_get_priv(dev);
>> +
>> +       priv->regs = (struct emac_regs *)pdata->iobase;
>> +       sunxi_emac_board_setup(priv);
>> +
>> +       return sunxi_emac_init_phy(priv, dev);
>> +}
>> +
>> +static const struct eth_ops sunxi_emac_eth_ops = {
>> +       .start                  = sunxi_emac_eth_start,
>> +       .send                   = sunxi_emac_eth_send,
>> +       .recv                   = sunxi_emac_eth_recv,
>> +       .stop                   = sunxi_emac_eth_stop,
>> +};
>> +
>> +static int sunxi_emac_eth_ofdata_to_platdata(struct udevice *dev)
>> +{
>> +       struct eth_pdata *pdata = dev_get_platdata(dev);
>> +
>> +       pdata->iobase = dev_get_addr(dev);
>> +
>> +       return 0;
>> +}
>> +
>> +static const struct udevice_id sunxi_emac_eth_ids[] = {
>> +       { .compatible = "allwinner,sun4i-a10-emac" },
>> +       { }
>> +};
>> +
>> +U_BOOT_DRIVER(eth_sunxi_emac) = {
>> +       .name   = "eth_sunxi_emac",
>> +       .id     = UCLASS_ETH,
>> +       .of_match = sunxi_emac_eth_ids,
>> +       .ofdata_to_platdata = sunxi_emac_eth_ofdata_to_platdata,
>> +       .probe  = sunxi_emac_eth_probe,
>> +       .ops    = &sunxi_emac_eth_ops,
>> +       .priv_auto_alloc_size = sizeof(struct emac_eth_dev),
>> +       .platdata_auto_alloc_size = sizeof(struct eth_pdata),
>> +};
>> +#endif
>> --
>> 2.3.5
>>
>
> Regards,
> Simon
>

  reply	other threads:[~2015-04-25  8:39 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-24 13:48 [U-Boot] [PATCH 00/21] sunxi: Move ALL boards to the device-model Hans de Goede
2015-04-24 13:48 ` [U-Boot] [PATCH 01/21] sunxi: Do not build i2c support when we've no i2c controllers Hans de Goede
2015-04-24 23:22   ` Simon Glass
2015-04-25  8:29     ` Hans de Goede
2015-04-26  3:14   ` Ian Campbell
2015-04-24 13:48 ` [U-Boot] [PATCH 02/21] sunxi: mmc: Fix card-detect gpio handling to work with the device-model Hans de Goede
2015-04-24 23:23   ` Simon Glass
2015-04-26  3:15     ` Ian Campbell
2015-04-24 13:48 ` [U-Boot] [PATCH 03/21] sunxi: usbc: Fix vbus " Hans de Goede
2015-04-24 18:10   ` Fabio Estevam
2015-04-24 18:15     ` Hans de Goede
2015-04-24 23:23       ` Simon Glass
2015-04-26  3:16   ` Ian Campbell
2015-04-24 13:48 ` [U-Boot] [PATCH 04/21] sunxi: display: Fix " Hans de Goede
2015-04-24 23:24   ` Simon Glass
2015-04-26  3:17   ` Ian Campbell
2015-04-24 13:48 ` [U-Boot] [PATCH 05/21] sunxi: soft-i2c: " Hans de Goede
2015-04-24 23:24   ` Simon Glass
2015-04-26  3:18   ` Ian Campbell
2015-04-24 13:48 ` [U-Boot] [PATCH 06/21] sunxi: gpio: Rename GPIOs to include a 'P' prefix Hans de Goede
2015-04-24 13:48 ` [U-Boot] [PATCH 07/21] sunxi: gpio: Add temporary implementation of name_to_gpio() Hans de Goede
2015-04-24 13:48 ` [U-Boot] [PATCH 08/21] sunxi: gpio: Add compatible strings for all supported SoCs Hans de Goede
2015-04-24 23:24   ` Simon Glass
2015-04-26  3:19   ` Ian Campbell
2015-04-24 13:48 ` [U-Boot] [PATCH 09/21] sunxi: gpio: Build sunxi_name_to_gpio_bank for device-model code too Hans de Goede
2015-04-24 23:24   ` Simon Glass
2015-04-26  3:21   ` Ian Campbell
2015-04-24 13:48 ` [U-Boot] [PATCH 10/21] sunxi: gpio: Change axp_gpio_foo prototype to match gpio uclass ops Hans de Goede
2015-04-24 23:24   ` Simon Glass
2015-04-24 13:48 ` [U-Boot] [PATCH 11/21] sunxi: gpio: Add support for AXP gpios to the dm gpio code Hans de Goede
2015-04-24 13:54   ` Hans de Goede
2015-04-24 23:24   ` Simon Glass
2015-04-24 13:48 ` [U-Boot] [PATCH 12/21] sunxi: gmac: Move sunxi_gmac_initialize proto out of netdev.h Hans de Goede
2015-04-24 23:24   ` Simon Glass
2015-04-26  3:23   ` Ian Campbell
2015-04-26  9:55     ` Hans de Goede
2015-04-24 13:48 ` [U-Boot] [PATCH 13/21] sunxi: emac: port to phylib Hans de Goede
2015-04-26  3:24   ` Ian Campbell
2015-04-24 13:48 ` [U-Boot] [PATCH 14/21] sunxi: emac: Prepare for device-model support Hans de Goede
2015-04-24 13:48 ` [U-Boot] [PATCH 15/21] sunxi: emac: Add device model support Hans de Goede
2015-04-24 23:24   ` Simon Glass
2015-04-25  8:39     ` Hans de Goede [this message]
2015-04-24 13:48 ` [U-Boot] [PATCH 16/21] sunxi: dts: Sync all dts files with upstream kernel Hans de Goede
2015-04-24 23:24   ` Simon Glass
2015-04-26  3:27   ` Ian Campbell
2015-04-24 13:48 ` [U-Boot] [PATCH 17/21] sunxi: dts: Add dts files which have been submitted but not yet merged upstream Hans de Goede
2015-04-24 23:24   ` Simon Glass
2015-04-26  3:27   ` Ian Campbell
2015-04-24 13:48 ` [U-Boot] [PATCH 18/21] sunxi: dts: Add minimal dts files for board which lack a dts sofar Hans de Goede
2015-04-24 23:24   ` Simon Glass
2015-04-26  3:30   ` Ian Campbell
2015-04-26  9:57     ` Hans de Goede
2015-05-02 13:48       ` Ian Campbell
2015-05-04 14:12         ` Hans de Goede
2015-04-24 13:48 ` [U-Boot] [PATCH 19/21] sunxi: dts: Add a CONFIG_DEFAULT_DEVICE_TREE setting to all sunxi boards Hans de Goede
2015-04-24 23:24   ` Simon Glass
2015-04-26  3:31   ` Ian Campbell
2015-04-24 13:48 ` [U-Boot] [PATCH 20/21] sunxi: Move all boards to the device-model Hans de Goede
2015-04-24 23:24   ` Simon Glass
2015-04-26  3:33   ` Ian Campbell
2015-04-26 10:06     ` Hans de Goede
2015-05-02 13:49       ` Ian Campbell
2015-04-24 13:48 ` [U-Boot] [PATCH 21/21] sunxi: emac: Remove non device-model code Hans de Goede
2015-04-24 23:24   ` Simon Glass
2015-04-26  3:33   ` Ian Campbell
2015-04-24 23:23 ` [U-Boot] [PATCH 00/21] sunxi: Move ALL boards to the device-model Simon Glass
2015-04-25  8:27   ` Hans de Goede

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=553B52C0.8010205@redhat.com \
    --to=hdegoede@redhat.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