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] core: ofnode: Add ofnode_pci_get_devfn()
Date: Tue, 22 Jan 2019 07:15:29 +1300	[thread overview]
Message-ID: <CAPnjgZ0XObFDDNx5yDw3uQ1WR5+J0hqQOC_6h=jbZNHz6Uzc1A@mail.gmail.com> (raw)
In-Reply-To: <20190118114642.19412-1-sr@denx.de>

Hi Stefan,

On Sat, 19 Jan 2019 at 00:46, Stefan Roese <sr@denx.de> wrote:
>
> This function will be used by the Marvell Armada XP/38x PCIe driver,
> which is moved to DM right now. It's mostly copied from the Linux
> version.
>
> Signed-off-by: Stefan Roese <sr@denx.de>
> Cc: Simon Glass <sjg@chromium.org>
> ---
>  drivers/core/ofnode.c | 12 ++++++++++++
>  include/dm/ofnode.h   | 11 +++++++++++
>  2 files changed, 23 insertions(+)

The code to do this right now is in pci_uclass_child_post_bind(). Do
you think you could break that out into a pci_... function that you
can call from your new function?

Also I had a look at the code you wrote that calls this. Ideally we
would have the PCIe nodes have their own driver so that driver model
will automatically bind them, but I am not sure that is feasible.

Regards,
Simon


>
> diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
> index 0e584c12dc..b74b95ff61 100644
> --- a/drivers/core/ofnode.c
> +++ b/drivers/core/ofnode.c
> @@ -666,6 +666,18 @@ int ofnode_read_pci_vendev(ofnode node, u16 *vendor, u16 *device)
>         return -ENOENT;
>  }
>
> +int ofnode_pci_get_devfn(ofnode node)
> +{
> +       u32 reg[5];
> +       int error;
> +
> +       error = ofnode_read_u32_array(node, "reg", reg, ARRAY_SIZE(reg));
> +       if (error)
> +               return error;
> +
> +       return (reg[0] >> 8) & 0xff;
> +}
> +
>  int ofnode_read_addr_cells(ofnode node)
>  {
>         if (ofnode_is_np(node))
> diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
> index d206ee2caa..66d7f8d055 100644
> --- a/include/dm/ofnode.h
> +++ b/include/dm/ofnode.h
> @@ -608,6 +608,17 @@ int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type,
>   */
>  int ofnode_read_pci_vendev(ofnode node, u16 *vendor, u16 *device);
>
> +/**
> + * ofnode_pci_get_devfn() - Get device and function numbers for a device node
> + * @ofnode: node to examine
> + *
> + * Parses a standard 5-cell PCI resource and returns an 8-bit value that can
> + * be passed to the PCI_SLOT() and PCI_FUNC() macros to extract the device
> + * and function numbers respectively. On error a negative error code is
> + * returned.
> + */
> +int ofnode_pci_get_devfn(ofnode node);
> +
>  /**
>   * ofnode_read_addr_cells() - Get the number of address cells for a node
>   *
> --
> 2.20.1
>

  parent reply	other threads:[~2019-01-21 18:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-18 11:46 [U-Boot] [PATCH] core: ofnode: Add ofnode_pci_get_devfn() Stefan Roese
2019-01-18 11:46 ` [U-Boot] [PATCH] pci: Add PCI_SLOT macro to include/pci.h Stefan Roese
2019-01-22  0:32   ` Simon Glass
2019-01-22  2:11     ` Bin Meng
2019-01-22  9:54       ` Stefan Roese
2019-01-22  9:53     ` Stefan Roese
2019-01-18 11:46 ` [U-Boot] [PATCH 1/3 v2] pci: pci_mvebu: Add DM_PCI support and move CONFIG_PCI_MVEBU to defconfig Stefan Roese
2019-01-22  7:35   ` Chris Packham
2019-01-22 10:06     ` Stefan Roese
2019-01-18 11:46 ` [U-Boot] [PATCH 2/3 v2] arm: mvebu: armada-xp/37x.dtsi: Sync PCIe DT nodes with Linux v4.20 Stefan Roese
2019-01-18 11:46 ` [U-Boot] [PATCH 3/3 v2] arm: mvebu: armada-xp-theadorable.dts: Enable PCIe DT nodes Stefan Roese
2019-01-21 18:15 ` Simon Glass [this message]
2019-01-22  9:36   ` [U-Boot] [PATCH] core: ofnode: Add ofnode_pci_get_devfn() Stefan Roese
2019-01-31 10:04     ` Simon Glass
2019-01-31 10:45       ` Stefan Roese
2019-02-02  6:05         ` Simon Glass
2019-02-05  9:34           ` Stefan Roese

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='CAPnjgZ0XObFDDNx5yDw3uQ1WR5+J0hqQOC_6h=jbZNHz6Uzc1A@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.