All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 09/11] net: designware: Add support to PCI designware devices
Date: Thu, 3 Sep 2015 18:43:03 -0600	[thread overview]
Message-ID: <CAPnjgZ2mSzBGu6jd0-yCnkk-DYWioagV=68ur6ShN0Ja9tP+CQ@mail.gmail.com> (raw)
In-Reply-To: <1441283853-30868-10-git-send-email-bmeng.cn@gmail.com>

Hi Joe,

On 3 September 2015 at 06:37, Bin Meng <bmeng.cn@gmail.com> wrote:
> The Designware ethernet controller is also seen on PCI bus, e.g.
> on Intel Quark SoC. Add this support in the DM version driver.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>
> ---
>
> Changes in v4: None
> Changes in v3:
> - Change to use dm_pci_read_config32()
>
> Changes in v2:
> - Change to use device_is_on_pci_bus()
>
>  drivers/net/designware.c | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

Does this patch look OK to you?

Bin, perhaps (later) we should add a dm_pci_mem_to_phys(struct udevice *...) ?

>
> diff --git a/drivers/net/designware.c b/drivers/net/designware.c
> index ae78d21..d45340c 100644
> --- a/drivers/net/designware.c
> +++ b/drivers/net/designware.c
> @@ -14,6 +14,7 @@
>  #include <errno.h>
>  #include <miiphy.h>
>  #include <malloc.h>
> +#include <pci.h>
>  #include <linux/compiler.h>
>  #include <linux/err.h>
>  #include <asm/io.h>
> @@ -558,6 +559,20 @@ static int designware_eth_write_hwaddr(struct udevice *dev)
>         return _dw_write_hwaddr(priv, pdata->enetaddr);
>  }
>
> +static int designware_eth_bind(struct udevice *dev)
> +{
> +       static int num_cards;
> +       char name[20];
> +
> +       /* Create a unique device name for PCI type devices */
> +       if (device_is_on_pci_bus(dev)) {
> +               sprintf(name, "eth_designware#%u", num_cards++);
> +               device_set_name(dev, name);
> +       }
> +
> +       return 0;
> +}
> +
>  static int designware_eth_probe(struct udevice *dev)
>  {
>         struct eth_pdata *pdata = dev_get_platdata(dev);
> @@ -565,6 +580,21 @@ static int designware_eth_probe(struct udevice *dev)
>         u32 iobase = pdata->iobase;
>         int ret;
>
> +       /*
> +        * If we are on PCI bus, either directly attached to a PCI root port,
> +        * or via a PCI bridge, fill in platdata before we probe the hardware.
> +        */
> +       if (device_is_on_pci_bus(dev)) {
> +               pci_dev_t bdf = pci_get_bdf(dev);
> +
> +               dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase);
> +               iobase &= PCI_BASE_ADDRESS_MEM_MASK;
> +               iobase = pci_mem_to_phys(bdf, iobase);
> +
> +               pdata->iobase = iobase;
> +               pdata->phy_interface = PHY_INTERFACE_MODE_RMII;
> +       }
> +
>         debug("%s, iobase=%x, priv=%p\n", __func__, iobase, priv);
>         priv->mac_regs_p = (struct eth_mac_regs *)iobase;
>         priv->dma_regs_p = (struct eth_dma_regs *)(iobase + DW_DMA_BASE_OFFSET);
> @@ -617,10 +647,18 @@ U_BOOT_DRIVER(eth_designware) = {
>         .id     = UCLASS_ETH,
>         .of_match = designware_eth_ids,
>         .ofdata_to_platdata = designware_eth_ofdata_to_platdata,
> +       .bind   = designware_eth_bind,
>         .probe  = designware_eth_probe,
>         .ops    = &designware_eth_ops,
>         .priv_auto_alloc_size = sizeof(struct dw_eth_dev),
>         .platdata_auto_alloc_size = sizeof(struct eth_pdata),
>         .flags = DM_FLAG_ALLOC_PRIV_DMA,
>  };
> +
> +static struct pci_device_id supported[] = {
> +       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_QRK_EMAC) },
> +       { }
> +};
> +
> +U_BOOT_PCI_DEVICE(eth_designware, supported);
>  #endif
> --
> 1.8.2.1
>

Regards,
Simon

  reply	other threads:[~2015-09-04  0:43 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-03 12:37 [U-Boot] [PATCH v4 00/11] x86: quark: Convert to driver model Bin Meng
2015-09-03 12:37 ` [U-Boot] [PATCH v4 01/11] x86: quark: Optimize MRC execution time Bin Meng
2015-09-04  0:45   ` Simon Glass
2015-09-03 12:37 ` [U-Boot] [PATCH v4 02/11] x86: quark: Avoid chicken and egg problem Bin Meng
2015-09-04  0:45   ` Simon Glass
2015-09-03 12:37 ` [U-Boot] [PATCH v4 03/11] x86: Enable PCIe controller on quark/galileo Bin Meng
2015-09-04  0:46   ` Simon Glass
2015-09-03 12:37 ` [U-Boot] [PATCH v4 04/11] x86: Convert to use driver model pci " Bin Meng
2015-09-04  0:46   ` Simon Glass
2015-09-03 12:37 ` [U-Boot] [PATCH v4 05/11] x86: quark: Add USB PHY initialization support Bin Meng
2015-09-04  0:46   ` Simon Glass
2015-09-03 12:37 ` [U-Boot] [PATCH v4 06/11] x86: galileo: Convert to use CONFIG_DM_USB Bin Meng
2015-09-04  0:46   ` Simon Glass
2015-09-03 12:37 ` [U-Boot] [PATCH v4 07/11] net: designware: Fix build warnings Bin Meng
2015-09-04  0:46   ` Simon Glass
2015-09-03 12:37 ` [U-Boot] [PATCH v4 08/11] dm: pci: Add an inline API to test if a device is on a PCI bus Bin Meng
2015-09-10  3:58   ` Simon Glass
2015-09-10 20:41     ` Simon Glass
2015-09-11 10:24       ` Bin Meng
2015-09-03 12:37 ` [U-Boot] [PATCH v4 09/11] net: designware: Add support to PCI designware devices Bin Meng
2015-09-04  0:43   ` Simon Glass [this message]
2015-09-04  0:49     ` Bin Meng
2015-09-03 12:37 ` [U-Boot] [PATCH v4 10/11] x86: Convert to use driver model eth on quark/galileo Bin Meng
2015-09-03 12:37 ` [U-Boot] [PATCH v4 11/11] x86: quark: Add PCIe/USB static register programming after memory init Bin Meng
2015-09-10  3:58   ` Simon Glass

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='CAPnjgZ2mSzBGu6jd0-yCnkk-DYWioagV=68ur6ShN0Ja9tP+CQ@mail.gmail.com' \
    --to=sjg@chromium.org \
    --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.