[{"id":1760683,"web_url":"http://patchwork.ozlabs.org/comment/1760683/","msgid":"<CAEUhbmU0rQnZ4yNVk+gxSO5B0J407qjbF=tiPHrY70ENg_MS6Q@mail.gmail.com>","list_archive_url":null,"date":"2017-08-31T06:51:51","subject":"Re: [U-Boot] [PATCH 1/2] PCI: Add driver for a\n\t'pci-host-ecam-generic' host controller","submitter":{"id":64981,"url":"http://patchwork.ozlabs.org/api/people/64981/","name":"Bin Meng","email":"bmeng.cn@gmail.com"},"content":"Hi Tuomas,\n\nOn Wed, Aug 30, 2017 at 4:31 PM, Tuomas Tynkkynen\n<tuomas.tynkkynen@iki.fi> wrote:\n> QEMU emulates such a device with '-machine virt,highmem=off' on ARM.\n> The 'highmem=off' part is required for things to work as the PCI code\n> in U-Boot doesn't seem to support 64-bit BARs.\n>\n> This driver is basically a copy-paste of the Xilinx PCIE driver with the\n> Xilinx-specific bits removed and compatible string changed... The\n> generic code should probably be extracted into some sort of library\n> functions instead of duplicating them before committing this driver.\n>\n> Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>\n> ---\n>  drivers/pci/Kconfig             |   8 ++\n>  drivers/pci/Makefile            |   1 +\n>  drivers/pci/pcie_ecam_generic.c | 193 ++++++++++++++++++++++++++++++++++++++++\n>  3 files changed, 202 insertions(+)\n>  create mode 100644 drivers/pci/pcie_ecam_generic.c\n>\n> diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig\n> index e2a1c0a409..745161fb9f 100644\n> --- a/drivers/pci/Kconfig\n> +++ b/drivers/pci/Kconfig\n> @@ -33,6 +33,14 @@ config PCI_PNP\n>         help\n>           Enable PCI memory and I/O space resource allocation and assignment.\n>\n> +config PCIE_ECAM_GENERIC\n> +       bool \"Generic PCI-E ECAM support\"\n> +       default n\n\nnits: default n is not needed as it is the default value\n\n> +       depends on DM_PCI\n> +       help\n> +         Say Y here if you want to enable support for generic ECAM-based\n> +         PCIe controllers, such as the one emulated by QEMU.\n> +\n>  config PCIE_DW_MVEBU\n>         bool \"Enable Armada-8K PCIe driver (DesignWare core)\"\n>         default n\n> diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile\n> index ad44e83996..5eb12efbf5 100644\n> --- a/drivers/pci/Makefile\n> +++ b/drivers/pci/Makefile\n> @@ -17,6 +17,7 @@ obj-$(CONFIG_PCI) += pci.o pci_auto_old.o\n>  endif\n>  obj-$(CONFIG_PCI) += pci_auto_common.o pci_common.o\n>\n> +obj-$(CONFIG_PCIE_ECAM_GENERIC) += pcie_ecam_generic.o\n>  obj-$(CONFIG_FSL_PCI_INIT) += fsl_pci_init.o\n>  obj-$(CONFIG_PCI_INDIRECT_BRIDGE) += pci_indirect.o\n>  obj-$(CONFIG_PCI_GT64120) += pci_gt64120.o\n> diff --git a/drivers/pci/pcie_ecam_generic.c b/drivers/pci/pcie_ecam_generic.c\n> new file mode 100644\n> index 0000000000..039e378cb0\n> --- /dev/null\n> +++ b/drivers/pci/pcie_ecam_generic.c\n> @@ -0,0 +1,193 @@\n> +/*\n> + * Generic PCIE host provided by e.g. QEMU\n> + *\n> + * Heavily based on drivers/pci/pcie_xilinx.c\n> + *\n> + * Copyright (C) 2016 Imagination Technologies\n> + *\n> + * SPDX-License-Identifier:    GPL-2.0\n> + */\n> +\n> +#include <common.h>\n> +#include <dm.h>\n> +#include <pci.h>\n> +\n> +#include <asm/io.h>\n> +\n> +/**\n> + * struct generic_ecam_pcie - generic_ecam PCIe controller state\n> + * @hose: The parent classes PCI controller state\n> + * @cfg_base: The base address of memory mapped configuration space\n> + */\n> +struct generic_ecam_pcie {\n> +       struct pci_controller hose;\n\nThis sounds like a non-DM PCI driver stuff. I don't see it is\nreferenced in this driver.\n\n> +       void *cfg_base;\n> +};\n> +\n> +/**\n> + * pcie_generic_ecam_config_address() - Calculate the address of a config access\n> + * @pcie: Pointer to the PCI controller state\n> + * @bdf: Identifies the PCIe device to access\n> + * @offset: The offset into the device's configuration space\n> + * @paddress: Pointer to the pointer to write the calculates address to\n> + *\n> + * Calculates the address that should be accessed to perform a PCIe\n> + * configuration space access for a given device identified by the PCIe\n> + * controller device @pcie and the bus, device & function numbers in @bdf. If\n> + * access to the device is not valid then the function will return an error\n> + * code. Otherwise the address to access will be written to the pointer pointed\n> + * to by @paddress.\n> + *\n> + * Return: 0 on success, else -ENODEV\n\nI see this driver always return 0.\n\n> + */\n> +static int pcie_generic_ecam_config_address(struct generic_ecam_pcie *pcie, pci_dev_t bdf,\n> +                                     uint offset, void **paddress)\n> +{\n> +       unsigned int bus = PCI_BUS(bdf);\n> +       unsigned int dev = PCI_DEV(bdf);\n> +       unsigned int func = PCI_FUNC(bdf);\n> +       void *addr;\n> +\n> +       addr = pcie->cfg_base;\n> +       addr += bus << 20;\n> +       addr += dev << 15;\n> +       addr += func << 12;\n> +       addr += offset;\n> +       *paddress = addr;\n> +\n> +       return 0;\n> +}\n> +\n> +/**\n> + * pcie_generic_ecam_read_config() - Read from configuration space\n> + * @pcie: Pointer to the PCI controller state\n\nThere is no pcie parameter, instead it's bus.\n\n> + * @bdf: Identifies the PCIe device to access\n> + * @offset: The offset into the device's configuration space\n> + * @valuep: A pointer at which to store the read value\n> + * @size: Indicates the size of access to perform\n> + *\n> + * Read a value of size @size from offset @offset within the configuration\n> + * space of the device identified by the bus, device & function numbers in @bdf\n> + * on the PCI bus @bus.\n> + *\n> + * Return: 0 on success, else -ENODEV or -EINVAL\n> + */\n> +static int pcie_generic_ecam_read_config(struct udevice *bus, pci_dev_t bdf,\n> +                                  uint offset, ulong *valuep,\n> +                                  enum pci_size_t size)\n> +{\n> +       struct generic_ecam_pcie *pcie = dev_get_priv(bus);\n> +       void *address;\n> +       int err;\n> +\n> +       err = pcie_generic_ecam_config_address(pcie, bdf, offset, &address);\n> +       if (err < 0) {\n> +               *valuep = pci_get_ff(size);\n> +               return 0;\n> +       }\n> +\n> +       switch (size) {\n> +       case PCI_SIZE_8:\n> +               *valuep = __raw_readb(address);\n> +               return 0;\n> +       case PCI_SIZE_16:\n> +               *valuep = __raw_readw(address);\n> +               return 0;\n> +       case PCI_SIZE_32:\n> +               *valuep = __raw_readl(address);\n> +               return 0;\n> +       default:\n> +               return -EINVAL;\n> +       }\n> +}\n> +\n> +/**\n> + * pcie_generic_ecam_write_config() - Write to configuration space\n> + * @pcie: Pointer to the PCI controller state\n\nThere is no pcie parameter, instead it's bus.\n\n> + * @bdf: Identifies the PCIe device to access\n> + * @offset: The offset into the device's configuration space\n> + * @value: The value to write\n> + * @size: Indicates the size of access to perform\n> + *\n> + * Write the value @value of size @size from offset @offset within the\n> + * configuration space of the device identified by the bus, device & function\n> + * numbers in @bdf on the PCI bus @bus.\n> + *\n> + * Return: 0 on success, else -ENODEV or -EINVAL\n> + */\n> +static int pcie_generic_ecam_write_config(struct udevice *bus, pci_dev_t bdf,\n> +                                   uint offset, ulong value,\n> +                                   enum pci_size_t size)\n> +{\n> +       struct generic_ecam_pcie *pcie = dev_get_priv(bus);\n> +       void *address;\n> +       int err;\n> +\n> +       err = pcie_generic_ecam_config_address(pcie, bdf, offset, &address);\n> +       if (err < 0)\n> +               return 0;\n> +\n> +       switch (size) {\n> +       case PCI_SIZE_8:\n> +               __raw_writeb(value, address);\n> +               return 0;\n> +       case PCI_SIZE_16:\n> +               __raw_writew(value, address);\n> +               return 0;\n> +       case PCI_SIZE_32:\n> +               __raw_writel(value, address);\n> +               return 0;\n> +       default:\n> +               return -EINVAL;\n> +       }\n> +}\n> +\n> +/**\n> + * pcie_generic_ecam_ofdata_to_platdata() - Translate from DT to device state\n> + * @dev: A pointer to the device being operated on\n> + *\n> + * Translate relevant data from the device tree pertaining to device @dev into\n> + * state that the driver will later make use of. This state is stored in the\n> + * device's private data structure.\n> + *\n> + * Return: 0 on success, else -EINVAL\n> + */\n> +static int pcie_generic_ecam_ofdata_to_platdata(struct udevice *dev)\n> +{\n> +       struct generic_ecam_pcie *pcie = dev_get_priv(dev);\n> +       struct fdt_resource reg_res;\n> +       DECLARE_GLOBAL_DATA_PTR;\n> +       int err;\n> +\n> +       err = fdt_get_resource(gd->fdt_blob, dev_of_offset(dev), \"reg\",\n> +                              0, &reg_res);\n> +       if (err < 0) {\n> +               error(\"\\\"reg\\\" resource not found\\n\");\n> +               return err;\n> +       }\n> +\n> +       pcie->cfg_base = map_physmem(reg_res.start,\n> +                                    fdt_resource_size(&reg_res),\n> +                                    MAP_NOCACHE);\n> +\n> +       return 0;\n> +}\n> +\n> +static const struct dm_pci_ops pcie_generic_ecam_ops = {\n> +       .read_config    = pcie_generic_ecam_read_config,\n> +       .write_config   = pcie_generic_ecam_write_config,\n> +};\n> +\n> +static const struct udevice_id pcie_generic_ecam_ids[] = {\n> +       { .compatible = \"pci-host-ecam-generic\" },\n> +       { }\n> +};\n> +\n> +U_BOOT_DRIVER(pcie_generic_ecam) = {\n> +       .name                   = \"pcie_generic_ecam\",\n> +       .id                     = UCLASS_PCI,\n> +       .of_match               = pcie_generic_ecam_ids,\n> +       .ops                    = &pcie_generic_ecam_ops,\n> +       .ofdata_to_platdata     = pcie_generic_ecam_ofdata_to_platdata,\n> +       .priv_auto_alloc_size   = sizeof(struct generic_ecam_pcie),\n> +};\n> --\n\nRegards,\nBin","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"bY57q8wb\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xjY2V3b0Nz9s7F\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 16:52:01 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid E374BC21D7D; Thu, 31 Aug 2017 06:51:57 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 18146C21C54;\n\tThu, 31 Aug 2017 06:51:54 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 44071C21C54; Thu, 31 Aug 2017 06:51:53 +0000 (UTC)","from mail-wr0-f194.google.com (mail-wr0-f194.google.com\n\t[209.85.128.194])\n\tby lists.denx.de (Postfix) with ESMTPS id D3B55C21C51\n\tfor <u-boot@lists.denx.de>; Thu, 31 Aug 2017 06:51:52 +0000 (UTC)","by mail-wr0-f194.google.com with SMTP id k94so5321919wrc.0\n\tfor <u-boot@lists.denx.de>; Wed, 30 Aug 2017 23:51:52 -0700 (PDT)","by 10.223.135.121 with HTTP; Wed, 30 Aug 2017 23:51:51 -0700 (PDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=0.0 required=5.0 tests=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,\n\tT_DKIM_INVALID autolearn=unavailable\n\tautolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=BafqsXPWrp3fM45GZJg8usp+GlvkCOGmZMoVuEgSsIo=;\n\tb=bY57q8wb6C9FyvWkm82JM7E7wnyXP1qHAcmWiP5NnAYCVeVurBwfO+B+XXHi95VeeD\n\tGSuZnchrfA5zOBbXLccR9SkZok/eeIXZiF2k/rJtE6MK/G7yjI7JnEk+p7GY+RW25QZx\n\tnHl0tS2cadl7QLblBo+XFmEi/1f1dvBwAzATAn7YVRFT37rRRkwrubUJagovsMP0jvHn\n\ts8eMJt99CiVNLAsii2FoPf7O1fMgPwKvDggFnzcdpSTzoYh1yl4oBrbaZloGp+G4nZ3j\n\t5GhZSAgfBG/Pm1b5l2IwNwKsjD++u2mACa0JVQhaomjVPaHUMkbbl/6SwvAnKGr2Mer5\n\tNKsQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=BafqsXPWrp3fM45GZJg8usp+GlvkCOGmZMoVuEgSsIo=;\n\tb=JLb8VlaCcGKYHUFKP0qwQIcF3KvwakyMz7Bp/+gMElQe65zaBX+r837tWPyRZPjae7\n\tdANykBWbJpfeSHwA4tEuGCnhg4T5XYFsn7zi8UDzF7vJ+ooKTzzrf/g9M0jss4lDaNEZ\n\tOslIyQiaFfZF8eTNxENlbFSTse1kiXFcZQStNdVyM8caADTW+WaeK0niRQHJFdiV+f2v\n\tAbw7Z1GdZMvQWtIztU2xFn1x04he101a88gfymJnVw/qVnKniNQ4Xhqs7PZq8SGKGoSp\n\tDhBLOmWCvt2T8y5hvh64sb0zt0kVHvyk7i7QWp9828PKt3X0XgsGSBTsi3VZxQx7YypW\n\tqSTg==","X-Gm-Message-State":"AHYfb5iOcVAIPkyUipkcoS/B2Rqg2tS3b9HwfZ9KW2vKJ/EzA43nQF+8\n\t4B4TyLBJMhWvL74c1yPVAvf+LaD8iw==","X-Received":"by 10.223.143.111 with SMTP id\n\tp102mr2951862wrb.207.1504162312322; \n\tWed, 30 Aug 2017 23:51:52 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<20170830083135.9183-2-tuomas.tynkkynen@iki.fi>","References":"<20170830083135.9183-1-tuomas.tynkkynen@iki.fi>\n\t<20170830083135.9183-2-tuomas.tynkkynen@iki.fi>","From":"Bin Meng <bmeng.cn@gmail.com>","Date":"Thu, 31 Aug 2017 14:51:51 +0800","Message-ID":"<CAEUhbmU0rQnZ4yNVk+gxSO5B0J407qjbF=tiPHrY70ENg_MS6Q@mail.gmail.com>","To":"Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>","Cc":"U-Boot Mailing List <u-boot@lists.denx.de>, Tom Rini <trini@konsulko.com>","Subject":"Re: [U-Boot] [PATCH 1/2] PCI: Add driver for a\n\t'pci-host-ecam-generic' host controller","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}},{"id":1761574,"web_url":"http://patchwork.ozlabs.org/comment/1761574/","msgid":"<85ee7750-08f2-4822-0ce4-20469693ada1@gmail.com>","list_archive_url":null,"date":"2017-09-01T09:10:52","subject":"Re: [U-Boot] [PATCH 1/2] PCI: Add driver for a\n\t'pci-host-ecam-generic' host controller","submitter":{"id":72276,"url":"http://patchwork.ozlabs.org/api/people/72276/","name":"Tuomas Tynkkynen","email":"dezgeg@gmail.com"},"content":"Hi,\n\nOn 08/31/2017 09:51 AM, Bin Meng wrote:\n> Hi Tuomas,\n> \n> On Wed, Aug 30, 2017 at 4:31 PM, Tuomas Tynkkynen\n> <tuomas.tynkkynen@iki.fi> wrote:\n>> QEMU emulates such a device with '-machine virt,highmem=off' on ARM.\n>> The 'highmem=off' part is required for things to work as the PCI code\n>> in U-Boot doesn't seem to support 64-bit BARs.\n>>\n>> This driver is basically a copy-paste of the Xilinx PCIE driver with the\n>> Xilinx-specific bits removed and compatible string changed... The\n>> generic code should probably be extracted into some sort of library\n>> functions instead of duplicating them before committing this driver.\n>>\n>> Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>\n>> ---\n>>   drivers/pci/Kconfig             |   8 ++\n>>   drivers/pci/Makefile            |   1 +\n>>   drivers/pci/pcie_ecam_generic.c | 193 ++++++++++++++++++++++++++++++++++++++++\n>>   3 files changed, 202 insertions(+)\n>>   create mode 100644 drivers/pci/pcie_ecam_generic.c\n>>\n>> diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig\n>> index e2a1c0a409..745161fb9f 100644\n>> --- a/drivers/pci/Kconfig\n>> +++ b/drivers/pci/Kconfig\n>> @@ -33,6 +33,14 @@ config PCI_PNP\n>>          help\n>>            Enable PCI memory and I/O space resource allocation and assignment.\n>>\n>> +config PCIE_ECAM_GENERIC\n>> +       bool \"Generic PCI-E ECAM support\"\n>> +       default n\n> \n> nits: default n is not needed as it is the default value\n> \n\nSeems I have copied from PCIE_DW_MVEBU below. Removed.\n\n>> +       depends on DM_PCI\n>> +       help\n>> +         Say Y here if you want to enable support for generic ECAM-based\n>> +         PCIe controllers, such as the one emulated by QEMU.\n>> +\n>>   config PCIE_DW_MVEBU\n>>          bool \"Enable Armada-8K PCIe driver (DesignWare core)\"\n>>          default n\n>> diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile\n>> index ad44e83996..5eb12efbf5 100644\n>> --- a/drivers/pci/Makefile\n>> +++ b/drivers/pci/Makefile\n>> @@ -17,6 +17,7 @@ obj-$(CONFIG_PCI) += pci.o pci_auto_old.o\n>>   endif\n>>   obj-$(CONFIG_PCI) += pci_auto_common.o pci_common.o\n>>\n>> +obj-$(CONFIG_PCIE_ECAM_GENERIC) += pcie_ecam_generic.o\n>>   obj-$(CONFIG_FSL_PCI_INIT) += fsl_pci_init.o\n>>   obj-$(CONFIG_PCI_INDIRECT_BRIDGE) += pci_indirect.o\n>>   obj-$(CONFIG_PCI_GT64120) += pci_gt64120.o\n>> diff --git a/drivers/pci/pcie_ecam_generic.c b/drivers/pci/pcie_ecam_generic.c\n>> new file mode 100644\n>> index 0000000000..039e378cb0\n>> --- /dev/null\n>> +++ b/drivers/pci/pcie_ecam_generic.c\n>> @@ -0,0 +1,193 @@\n>> +/*\n>> + * Generic PCIE host provided by e.g. QEMU\n>> + *\n>> + * Heavily based on drivers/pci/pcie_xilinx.c\n>> + *\n>> + * Copyright (C) 2016 Imagination Technologies\n>> + *\n>> + * SPDX-License-Identifier:    GPL-2.0\n>> + */\n>> +\n>> +#include <common.h>\n>> +#include <dm.h>\n>> +#include <pci.h>\n>> +\n>> +#include <asm/io.h>\n>> +\n>> +/**\n>> + * struct generic_ecam_pcie - generic_ecam PCIe controller state\n>> + * @hose: The parent classes PCI controller state\n>> + * @cfg_base: The base address of memory mapped configuration space\n>> + */\n>> +struct generic_ecam_pcie {\n>> +       struct pci_controller hose;\n> \n> This sounds like a non-DM PCI driver stuff. I don't see it is\n> referenced in this driver.\n> \n\nIndeed, it appears to be leftover code also in the pcie_xilinx that I\ncopied from. Also a bunch of other drivers that have had a DM conversion\nhave this as leftovers. I will clean them up also.\n\n>> +       void *cfg_base;\n>> +};\n>> +\n>> +/**\n>> + * pcie_generic_ecam_config_address() - Calculate the address of a config access\n>> + * @pcie: Pointer to the PCI controller state\n>> + * @bdf: Identifies the PCIe device to access\n>> + * @offset: The offset into the device's configuration space\n>> + * @paddress: Pointer to the pointer to write the calculates address to\n>> + *\n>> + * Calculates the address that should be accessed to perform a PCIe\n>> + * configuration space access for a given device identified by the PCIe\n>> + * controller device @pcie and the bus, device & function numbers in @bdf. If\n>> + * access to the device is not valid then the function will return an error\n>> + * code. Otherwise the address to access will be written to the pointer pointed\n>> + * to by @paddress.\n>> + *\n>> + * Return: 0 on success, else -ENODEV\n> \n> I see this driver always return 0.\n> \n\nWill fix the comment. I kept the same signature for config_address since \nI'm planning to have common parts of .write_config and .read_config \nabstracted (similar to pci_generic_config_{read,write} in Linux) instead \nof copy pasting the same code the 3rd time in U-Boot.\n\n>> + */\n>> +static int pcie_generic_ecam_config_address(struct generic_ecam_pcie *pcie, pci_dev_t bdf,\n>> +                                     uint offset, void **paddress)\n>> +{\n>> +       unsigned int bus = PCI_BUS(bdf);\n>> +       unsigned int dev = PCI_DEV(bdf);\n>> +       unsigned int func = PCI_FUNC(bdf);\n>> +       void *addr;\n>> +\n>> +       addr = pcie->cfg_base;\n>> +       addr += bus << 20;\n>> +       addr += dev << 15;\n>> +       addr += func << 12;\n>> +       addr += offset;\n>> +       *paddress = addr;\n>> +\n>> +       return 0;\n>> +}\n>> +\n>> +/**\n>> + * pcie_generic_ecam_read_config() - Read from configuration space\n>> + * @pcie: Pointer to the PCI controller state\n> \n> There is no pcie parameter, instead it's bus.\n> \n\nAgain a problem inherited from pcie_xilinx... will fix there as well.\n\n>> + * @bdf: Identifies the PCIe device to access\n>> + * @offset: The offset into the device's configuration space\n>> + * @valuep: A pointer at which to store the read value\n>> + * @size: Indicates the size of access to perform\n>> + *\n>> + * Read a value of size @size from offset @offset within the configuration\n>> + * space of the device identified by the bus, device & function numbers in @bdf\n>> + * on the PCI bus @bus.\n>> + *\n>> + * Return: 0 on success, else -ENODEV or -EINVAL\n>> + */\n>> +static int pcie_generic_ecam_read_config(struct udevice *bus, pci_dev_t bdf,\n>> +                                  uint offset, ulong *valuep,\n>> +                                  enum pci_size_t size)\n>> +{\n>> +       struct generic_ecam_pcie *pcie = dev_get_priv(bus);\n>> +       void *address;\n>> +       int err;\n>> +\n>> +       err = pcie_generic_ecam_config_address(pcie, bdf, offset, &address);\n>> +       if (err < 0) {\n>> +               *valuep = pci_get_ff(size);\n>> +               return 0;\n>> +       }\n>> +\n>> +       switch (size) {\n>> +       case PCI_SIZE_8:\n>> +               *valuep = __raw_readb(address);\n>> +               return 0;\n>> +       case PCI_SIZE_16:\n>> +               *valuep = __raw_readw(address);\n>> +               return 0;\n>> +       case PCI_SIZE_32:\n>> +               *valuep = __raw_readl(address);\n>> +               return 0;\n>> +       default:\n>> +               return -EINVAL;\n>> +       }\n>> +}\n>> +\n>> +/**\n>> + * pcie_generic_ecam_write_config() - Write to configuration space\n>> + * @pcie: Pointer to the PCI controller state\n> \n> There is no pcie parameter, instead it's bus.\n> \n\nDitto.","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"kMkCxayb\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xkG244C91z9t32\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 20:39:08 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 0EA45C21F05; Fri,  1 Sep 2017 10:36:45 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 0E72AC21EFD;\n\tFri,  1 Sep 2017 10:35:22 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 7785AC21EB1; Fri,  1 Sep 2017 09:10:57 +0000 (UTC)","from mail-lf0-f68.google.com (mail-lf0-f68.google.com\n\t[209.85.215.68])\n\tby lists.denx.de (Postfix) with ESMTPS id 0B849C21C51\n\tfor <u-boot@lists.denx.de>; Fri,  1 Sep 2017 09:10:57 +0000 (UTC)","by mail-lf0-f68.google.com with SMTP id y15so1132128lfd.0\n\tfor <u-boot@lists.denx.de>; Fri, 01 Sep 2017 02:10:57 -0700 (PDT)","from [192.168.75.194] ([194.100.106.190])\n\tby smtp.gmail.com with ESMTPSA id\n\to192sm377531lfe.95.2017.09.01.02.10.52\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 01 Sep 2017 02:10:53 -0700 (PDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.0 required=5.0 tests=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=subject:to:cc:references:from:message-id:date:user-agent\n\t:mime-version:in-reply-to:content-language:content-transfer-encoding; \n\tbh=X/AJQ0Ob4WVG3HjPDgad2569ICtYBCnseIWu/zzR+g8=;\n\tb=kMkCxaybk9VToMAATGMVfXGOTlzew4p0IHpH53w6weoI4iGa5PETlDWsyMQQh94LJ+\n\tzjNuczK7e2+NpY08ECEdjRpBVGQiEGGcRUO11e3gYcL2/s2bhzGUnJ5rN9IMDH3P8Pxx\n\tdJT/PQhTcHR/KIYyUxEuc5of6oekiIV4ss5gCwVDTZI0xq9kbF8kUoAf3T/4SN4AnCuU\n\tJhFZxSHot/swW9Emc07vIiwu7AElB0OoEc7pMQ868RRriFf6kqmMp2bcgbuKKNrTK94W\n\t64c5af9Hf3weVihV2PENtUSRPo0C5waVln+2+sLSDJOwnTckyiVMgbLZqdwoQClUuxLi\n\tAzwQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:subject:to:cc:references:from:message-id:date\n\t:user-agent:mime-version:in-reply-to:content-language\n\t:content-transfer-encoding;\n\tbh=X/AJQ0Ob4WVG3HjPDgad2569ICtYBCnseIWu/zzR+g8=;\n\tb=mCbE9UE6lZrXvrgtP3hJNB4JA7YX7ifd6SnfHIlh+tzPl6WStP+ov4vXMWpdpyGKXH\n\tv2aHsUTVKr+zAi/Tdxko1eWrhZlp6DiKK2KXP5c2EhUEcjC32etCV3zKJ23C4NeoMuEQ\n\tBQcFxyFYnhcqAYRTvngCEWhUjP0G9+W8mPRyRow+btEgjpXFmy4BSH74QD01AbgQSbdU\n\tUmdKBWGIk8yx3RURj1qdUrUlv9JNBK7LoptvONpXopjrSdiAyyQGoKs7o0NnsxVccR3/\n\tyeOcnY+OC7ZQsFw2M0Un6K0giKOfXG56rERVa0LQgNTSXSeu1+dx/+BAPtsGYC2YxoAv\n\t6dUA==","X-Gm-Message-State":"AHPjjUgYuWWB63x8TmszWKRQNjdRI5yLEBjUlw0QZql/b7sqZj2WrdkL\n\tAMLl40gUSuqdmw==","X-Google-Smtp-Source":"ADKCNb41MGnJvVs65vEZiUmzzB+BIQFov80SJWhIMnOFCQhwuHuN2O8XYVBqZXC6y7ECkE8yXx+IBg==","X-Received":"by 10.25.157.141 with SMTP id g135mr546996lfe.91.1504257056370; \n\tFri, 01 Sep 2017 02:10:56 -0700 (PDT)","To":"Bin Meng <bmeng.cn@gmail.com>, Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>","References":"<20170830083135.9183-1-tuomas.tynkkynen@iki.fi>\n\t<20170830083135.9183-2-tuomas.tynkkynen@iki.fi>\n\t<CAEUhbmU0rQnZ4yNVk+gxSO5B0J407qjbF=tiPHrY70ENg_MS6Q@mail.gmail.com>","From":"Tuomas Tynkkynen <dezgeg@gmail.com>","Message-ID":"<85ee7750-08f2-4822-0ce4-20469693ada1@gmail.com>","Date":"Fri, 1 Sep 2017 12:10:52 +0300","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.1.0","MIME-Version":"1.0","In-Reply-To":"<CAEUhbmU0rQnZ4yNVk+gxSO5B0J407qjbF=tiPHrY70ENg_MS6Q@mail.gmail.com>","Content-Language":"en-US","X-Mailman-Approved-At":"Fri, 01 Sep 2017 10:35:15 +0000","Cc":"U-Boot Mailing List <u-boot@lists.denx.de>, Tom Rini <trini@konsulko.com>","Subject":"Re: [U-Boot] [PATCH 1/2] PCI: Add driver for a\n\t'pci-host-ecam-generic' host controller","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Transfer-Encoding":"base64","Content-Type":"text/plain; charset=\"utf-8\"; Format=\"flowed\"","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}}]