[U-Boot] [PATCH 2/4 v3] pci: pci_mvebu: Add DM_PCI support and move CONFIG_PCI_MVEBU to defconfig

Bin Meng bmeng.cn at gmail.com
Thu Jan 31 14:41:49 UTC 2019


Hi Stefan,

On Fri, Jan 25, 2019 at 6:53 PM Stefan Roese <sr at denx.de> wrote:
>
> This patch adds DM_PCI support to the MVEBU PCIe driver. This is
> necessary, since all PCI drivers have to be moved to DM (driver model)
> until the v2019.07 release.
>
> To not break git bisect'ablility, this patch also moves CONFIG_PCI_MVEBU
> from config headers to the defconfig files.
>
> Signed-off-by: Stefan Roese <sr at denx.de>
> Cc: Dirk Eibach <dirk.eibach at gdsys.cc>
> Cc: Mario Six <mario.six at gdsys.cc>
> Cc: Chris Packham <chris.packham at alliedtelesis.co.nz>
> Cc: Phil Sutter <phil at nwl.cc>
> Cc: Marek BehĂșn <marek.behun at nic.cz>
> Cc: VlaoMao <vlaomao at gmail.com>
> ---
> v3:
> - Add x530 defconfig / config/foo.h changes
> - Remove misleading function comment
> - Use PCI_DEV instead of PCI_SLOT
> - Introduce mvebu_pcie_ofdata_to_platdata() to remove most functions
>   from the loop in mvebu_pcie_bind(). This also enables to usage of
>   a udevice pointer for the newly introduced function pci_get_devfn()
>
>
> v2:
> - Completely configure the controller based on DT properties. Now
>   port and lane are read from the DT nodes and also the tgt and
>   attr values are generated using the DT similar to how this is
>   done in the Linux driver version. All A38x / XP specific defines
>   can now be removed from this driver because of this.
> - Please note that now the board specific dts file needs to enable
>   the used PCIe ports, as this is also done in Linux.
>
>  configs/clearfog_defconfig          |   1 +
>  configs/controlcenterdc_defconfig   |   3 +
>  configs/db-88f6820-amc_defconfig    |   1 +
>  configs/db-88f6820-gp_defconfig     |   1 +
>  configs/db-mv784mp-gp_defconfig     |   1 +
>  configs/ds414_defconfig             |   1 +
>  configs/theadorable_debug_defconfig |   2 +
>  configs/turris_omnia_defconfig      |   3 +-
>  configs/x530_defconfig              |   3 +-
>  drivers/pci/Kconfig                 |   9 +
>  drivers/pci/pci_mvebu.c             | 470 ++++++++++++++++------------
>  include/configs/clearfog.h          |   1 -
>  include/configs/controlcenterdc.h   |   3 -
>  include/configs/db-88f6820-amc.h    |   1 -
>  include/configs/db-88f6820-gp.h     |   1 -
>  include/configs/db-mv784mp-gp.h     |   1 -
>  include/configs/ds414.h             |   1 -
>  include/configs/theadorable.h       |   7 -
>  include/configs/turris_omnia.h      |   1 -
>  include/configs/x530.h              |   1 -
>  scripts/config_whitelist.txt        |   1 -
>  21 files changed, 296 insertions(+), 217 deletions(-)
>

[snip]

> +static int mvebu_get_tgt_attr(ofnode node, int devfn,
> +                             unsigned long type,
> +                             unsigned int *tgt,
> +                             unsigned int *attr)
> +{
> +       const int na = 3, ns = 2;
> +       const __be32 *range;
> +       int rlen, nranges, rangesz, pna, i;
> +
> +       *tgt = -1;
> +       *attr = -1;
> +
> +       range = ofnode_get_property(node, "ranges", &rlen);
> +       if (!range)
> +               return -EINVAL;
> +
> +       pna = 2; /* hardcoded for now because of lack of of_n_addr_cells() */

Why? U-Boot has of_n_addr_cells() API.

> +       rangesz = pna + na + ns;
> +       nranges = rlen / sizeof(__be32) / rangesz;
> +
> +       for (i = 0; i < nranges; i++, range += rangesz) {
> +               u32 flags = of_read_number(range, 1);
> +               u32 slot = of_read_number(range + 1, 1);
> +               u64 cpuaddr = of_read_number(range + na, pna);
> +               unsigned long rtype;
> +
> +               if (DT_FLAGS_TO_TYPE(flags) == DT_TYPE_IO)
> +                       rtype = IORESOURCE_IO;
> +               else if (DT_FLAGS_TO_TYPE(flags) == DT_TYPE_MEM32)
> +                       rtype = IORESOURCE_MEM;
> +               else
>                         continue;
> +
> +               /*
> +                * The Linux code used PCI_SLOT() here, which expects devfn
> +                * in bits 7..0. PCI_DEV() in U-Boot is similar to PCI_SLOT(),
> +                * only expects devfn in 15..8, where its saved in this driver.
> +                */
> +               if (slot == PCI_DEV(devfn) && type == rtype) {
> +                       *tgt = DT_CPUADDR_TO_TARGET(cpuaddr);
> +                       *attr = DT_CPUADDR_TO_ATTR(cpuaddr);
> +                       return 0;
>                 }
> +       }
> +
> +       return -ENOENT;
> +}
> +

[snip]

Regards,
Bin


More information about the U-Boot mailing list