diff mbox

[v3] PCI: layerscape: Add PCIe support for LS1043a and LS2080a

Message ID 1444458217-31004-1-git-send-email-Minghuan.Lian@freescale.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Minghuan Lian Oct. 10, 2015, 6:23 a.m. UTC
The patch adds PCIe support for LS1043a and LS2080a.

Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>
---
This patch is based on v4.3-rc4 and [PATCH v10 3/6]
PCI: designware: Add ARM64 support.

change log
v3:
1. Use 8 or 16 bit access function to simplify code
2. Add ls_add_pcie_port in accordance with other DesignWare-based drivers

v2:
1. Rename ls2085a to ls2080a
2. Add ls_pcie_msi_host_init()

 drivers/pci/host/Kconfig          |   2 +-
 drivers/pci/host/pci-layerscape.c | 215 +++++++++++++++++++++++++++-----------
 2 files changed, 153 insertions(+), 64 deletions(-)

Comments

kernel test robot Oct. 10, 2015, 2:12 p.m. UTC | #1
Hi Minghuan,

[auto build test ERROR on v4.3-rc4 -- if it's inappropriate base, please ignore]

config: arm64-allmodconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm64 

All error/warnings (new ones prefixed by >>):

   In file included from drivers/net/fddi/skfp/h/smc.h:50:0,
   from drivers/net/fddi/skfp/drvfbi.c:23:
   drivers/net/fddi/skfp/h/targetos.h:63:0: warning: "FALSE" redefined
   #define FALSE 0
   ^
   In file included from include/acpi/acpi.h:58:0,
   from include/linux/acpi.h:33,
   from arch/arm64/include/asm/dma-mapping.h:21,
   from include/linux/dma-mapping.h:86,
   from include/linux/skbuff.h:34,
   from include/linux/if_ether.h:23,
   from include/uapi/linux/ethtool.h:17,
   from include/linux/ethtool.h:16,
   from include/linux/netdevice.h:42,
   from drivers/net/fddi/skfp/h/targetos.h:47,
   from drivers/net/fddi/skfp/h/smc.h:50,
   from drivers/net/fddi/skfp/drvfbi.c:23:
   include/acpi/actypes.h:433:0: note: this is the location of the previous definition
   #define FALSE (1 == 0)
   ^
   In file included from drivers/net/fddi/skfp/h/smc.h:50:0,
   from drivers/net/fddi/skfp/hwt.c:32:
   drivers/net/fddi/skfp/h/targetos.h:62:0: warning: "TRUE" redefined
   #define TRUE 1
   ^
   In file included from include/acpi/acpi.h:58:0,
   from include/linux/acpi.h:33,
   from arch/arm64/include/asm/dma-mapping.h:21,
   from include/linux/dma-mapping.h:86,
   from include/linux/skbuff.h:34,
   from include/linux/if_ether.h:23,
   from include/uapi/linux/ethtool.h:17,
   from include/linux/ethtool.h:16,
   from include/linux/netdevice.h:42,
   from drivers/net/fddi/skfp/h/targetos.h:47,
   from drivers/net/fddi/skfp/h/smc.h:50,
   from drivers/net/fddi/skfp/hwt.c:32:
   include/acpi/actypes.h:438:0: note: this is the location of the previous definition
   #define TRUE (1 == 1)
   ^
   In file included from drivers/net/fddi/skfp/h/smc.h:50:0,
   from drivers/net/fddi/skfp/hwt.c:32:
   drivers/net/fddi/skfp/h/targetos.h:63:0: warning: "FALSE" redefined
   #define FALSE 0
   ^
   In file included from include/acpi/acpi.h:58:0,
   from include/linux/acpi.h:33,
   from arch/arm64/include/asm/dma-mapping.h:21,
   from include/linux/dma-mapping.h:86,
   from include/linux/skbuff.h:34,
   from include/linux/if_ether.h:23,
   from include/uapi/linux/ethtool.h:17,
   from include/linux/ethtool.h:16,
   from include/linux/netdevice.h:42,
   from drivers/net/fddi/skfp/h/targetos.h:47,
   from drivers/net/fddi/skfp/h/smc.h:50,
   from drivers/net/fddi/skfp/hwt.c:32:
   include/acpi/actypes.h:433:0: note: this is the location of the previous definition
   #define FALSE (1 == 0)
   ^
   In file included from drivers/net/fddi/skfp/h/smc.h:50:0,
   from drivers/net/fddi/skfp/ess.c:38:
   drivers/net/fddi/skfp/h/targetos.h:62:0: warning: "TRUE" redefined
   #define TRUE 1
   ^
   In file included from include/acpi/acpi.h:58:0,
   from include/linux/acpi.h:33,
   from arch/arm64/include/asm/dma-mapping.h:21,
   from include/linux/dma-mapping.h:86,
   from include/linux/skbuff.h:34,
   from include/linux/if_ether.h:23,
   from include/uapi/linux/ethtool.h:17,
   from include/linux/ethtool.h:16,
   from include/linux/netdevice.h:42,
   from drivers/net/fddi/skfp/h/targetos.h:47,
   from drivers/net/fddi/skfp/h/smc.h:50,
   from drivers/net/fddi/skfp/ess.c:38:
   include/acpi/actypes.h:438:0: note: this is the location of the previous definition
   #define TRUE (1 == 1)
   ^
   In file included from drivers/net/fddi/skfp/h/smc.h:50:0,
   from drivers/net/fddi/skfp/ess.c:38:
   drivers/net/fddi/skfp/h/targetos.h:63:0: warning: "FALSE" redefined
   #define FALSE 0
   ^
   In file included from include/acpi/acpi.h:58:0,
   from include/linux/acpi.h:33,
   from arch/arm64/include/asm/dma-mapping.h:21,
   from include/linux/dma-mapping.h:86,
   from include/linux/skbuff.h:34,
   from include/linux/if_ether.h:23,
   from include/uapi/linux/ethtool.h:17,
   from include/linux/ethtool.h:16,
   from include/linux/netdevice.h:42,
   from drivers/net/fddi/skfp/h/targetos.h:47,
   from drivers/net/fddi/skfp/h/smc.h:50,
   from drivers/net/fddi/skfp/ess.c:38:
   include/acpi/actypes.h:433:0: note: this is the location of the previous definition
   #define FALSE (1 == 0)
   ^
>> drivers/pci/host/pcie-designware.c:76:52: warning: 'struct pci_sys_data' declared inside parameter list
   static inline struct pcie_port pci_sys_data
   ^
>> drivers/pci/host/pcie-designware.c:76:52: warning: its scope is only this definition or declaration, which is probably not what you want
   In file included from include/uapi/linux/stddef.h:1:0,
   from include/linux/stddef.h:4,
   from include/uapi/linux/posix_types.h:4,
   from include/uapi/linux/types.h:13,
   from include/linux/types.h:5,
   from include/linux/smp.h:10,
   from include/linux/irq.h:12,
   from drivers/pci/host/pcie-designware.c:14:
   drivers/pci/host/pcie-designware.c: In function 'sys_to_pcie':
>> drivers/pci/host/pcie-designware.c:78:13: error: dereferencing pointer to incomplete type
   BUG_ON(!sys->private_data);
   ^
   include/linux/compiler.h:166:42: note: in definition of macro 'unlikely'
   # define unlikely(x) 0)
   ^
>> drivers/pci/host/pcie-designware.c:78:2: note: in expansion of macro 'BUG_ON'
   BUG_ON(!sys->private_data);
   ^
   drivers/pci/host/pcie-designware.c:80:12: error: dereferencing pointer to incomplete type
   return sys->private_data;
   ^
   drivers/pci/host/pcie-designware.c: In function 'dw_pcie_host_init':
>> drivers/pci/host/pcie-designware.c:530:2: error: invalid use of undefined type 'struct hw_pci'
   dw_pci.nr_controllers = 1;
   ^
   drivers/pci/host/pcie-designware.c:531:2: error: invalid use of undefined type 'struct hw_pci'
   dw_pci.private_data = (void
   ^
>> drivers/pci/host/pcie-designware.c:533:2: error: implicit declaration of function 'pci_common_init_dev'
   pci_common_init_dev(pp->dev, &dw_pci);
   ^
   drivers/pci/host/pcie-designware.c: At top level:
   drivers/pci/host/pcie-designware.c:682:41: warning: 'struct pci_sys_data' declared inside parameter list
   static int dw_pcie_setup(int nr, struct pci_sys_data
   ^
   drivers/pci/host/pcie-designware.c: In function 'dw_pcie_setup':
>> drivers/pci/host/pcie-designware.c:686:7: warning: passing argument 1 of 'sys_to_pcie' from incompatible pointer type
   pp = sys_to_pcie(sys);
   ^
   drivers/pci/host/pcie-designware.c:76:33: note: expected 'struct pci_sys_data but argument is of type 'struct pci_sys_data
   static inline struct pcie_port pci_sys_data
   ^
   drivers/pci/host/pcie-designware.c:689:6: error: dereferencing pointer to incomplete type
   sys->io_offset = global_io_offset - pp->io_bus_addr;
   ^
>> drivers/pci/host/pcie-designware.c:690:3: error: implicit declaration of function 'pci_ioremap_io'
   pci_ioremap_io(global_io_offset, pp->io_base);
   ^
   drivers/pci/host/pcie-designware.c:692:31: error: dereferencing pointer to incomplete type
   pci_add_resource_offset(&sys->resources, &pp->io,
   ^
   drivers/pci/host/pcie-designware.c:693:9: error: dereferencing pointer to incomplete type
   sys->io_offset);
   ^
   drivers/pci/host/pcie-designware.c:696:5: error: dereferencing pointer to incomplete type
   sys->mem_offset = pp->mem.start - pp->mem_bus_addr;
   ^
   drivers/pci/host/pcie-designware.c:697:30: error: dereferencing pointer to incomplete type
   pci_add_resource_offset(&sys->resources, &pp->mem, sys->mem_offset);
   ^
   drivers/pci/host/pcie-designware.c:697:56: error: dereferencing pointer to incomplete type
   pci_add_resource_offset(&sys->resources, &pp->mem, sys->mem_offset);
   ^
   drivers/pci/host/pcie-designware.c:698:23: error: dereferencing pointer to incomplete type
   pci_add_resource(&sys->resources, &pp->busn);
   ^
   drivers/pci/host/pcie-designware.c: At top level:
   drivers/pci/host/pcie-designware.c:703:56: warning: 'struct pci_sys_data' declared inside parameter list
   static struct pci_bus nr, struct pci_sys_data
   ^
   drivers/pci/host/pcie-designware.c: In function 'dw_pcie_scan_bus':
   drivers/pci/host/pcie-designware.c:706:25: warning: passing argument 1 of 'sys_to_pcie' from incompatible pointer type
   struct pcie_port = sys_to_pcie(sys);
   ^
   drivers/pci/host/pcie-designware.c:76:33: note: expected 'struct pci_sys_data but argument is of type 'struct pci_sys_data
   static inline struct pcie_port pci_sys_data
   ^
   drivers/pci/host/pcie-designware.c:708:23: error: dereferencing pointer to incomplete type
   pp->root_bus_nr = sys->busnr;
   ^
   drivers/pci/host/pcie-designware.c:711:43: error: dereferencing pointer to incomplete type
   bus = pci_scan_root_bus_msi(pp->dev, sys->busnr, &dw_pcie_ops,
   ^
   drivers/pci/host/pcie-designware.c:712:19: error: dereferencing pointer to incomplete type
   sys, &sys->resources,
   ^
   drivers/pci/host/pcie-designware.c:715:39: error: dereferencing pointer to incomplete type
   bus = pci_scan_root_bus(pp->dev, sys->busnr, &dw_pcie_ops,
   ^
   drivers/pci/host/pcie-designware.c:716:15: error: dereferencing pointer to incomplete type
   sys, &sys->resources);
   ^
   drivers/pci/host/pcie-designware.c: At top level:
>> drivers/pci/host/pcie-designware.c:739:15: error: variable 'dw_pci' has initializer but incomplete type
   static struct hw_pci dw_pci = {
   ^
>> drivers/pci/host/pcie-designware.c:740:2: error: unknown field 'setup' specified in initializer
   .setup = dw_pcie_setup,
   ^
>> drivers/pci/host/pcie-designware.c:740:2: warning: excess elements in struct initializer
>> drivers/pci/host/pcie-designware.c:740:2: warning: (near initialization for 'dw_pci')
>> drivers/pci/host/pcie-designware.c:741:2: error: unknown field 'scan' specified in initializer
   .scan = dw_pcie_scan_bus,
   ^
   drivers/pci/host/pcie-designware.c:741:2: warning: excess elements in struct initializer
   drivers/pci/host/pcie-designware.c:741:2: warning: (near initialization for 'dw_pci')
>> drivers/pci/host/pcie-designware.c:742:2: error: unknown field 'map_irq' specified in initializer
   .map_irq = dw_pcie_map_irq,
   ^
   drivers/pci/host/pcie-designware.c:742:2: warning: excess elements in struct initializer
   drivers/pci/host/pcie-designware.c:742:2: warning: (near initialization for 'dw_pci')
   drivers/pci/host/pcie-designware.c: In function 'sys_to_pcie':
>> drivers/pci/host/pcie-designware.c:81:1: warning: control reaches end of non-void function
   }
   ^
   cc1: some warnings being treated as errors
   Documentation Makefile Module.symvers System.map arch block certs crypto drivers firmware fs include init ipc kernel lib mm modules.builtin modules.order net scripts security sound source usr virt vmlinux vmlinux.o Error 1
   Target '__build' not remade because of errors.
   Documentation Makefile Module.symvers System.map arch block certs crypto drivers firmware fs include init ipc kernel lib mm modules.builtin modules.order net scripts security sound source usr virt vmlinux vmlinux.o Error 2
   Target '__build' not remade because of errors.
   Documentation Makefile Module.symvers System.map arch block certs crypto drivers firmware fs include init ipc kernel lib mm modules.builtin modules.order net scripts security sound source usr virt vmlinux vmlinux.o Error 2
   drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c: In function 'pm8xxx_gpio_probe':
   drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c:675:17: warning: cast from pointer to integer of different size
   pctrl->npins = (unsigned)of_device_get_match_data(&pdev->dev);
   ^
   drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c: In function 'pm8xxx_mpp_probe':
   drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c:766:17: warning: cast from pointer to integer of different size
   pctrl->npins = (unsigned)of_device_get_match_data(&pdev->dev);
   ^
   drivers/net/ethernet/dec/tulip/winbond-840.c: In function 'init_registers':
   drivers/net/ethernet/dec/tulip/winbond-840.c:910:2: warning: #warning Processor architecture undefined
   #warning Processor architecture undefined
   ^
   drivers/net/ethernet/dec/tulip/tulip_core.c:101:2: warning: #warning Processor architecture undefined!
   #warning Processor architecture undefined!
   ^
   In file included from include/linux/kernel.h:10:0,
   from include/linux/list.h:8,
   from include/linux/kobject.h:20,
   from include/linux/device.h:17,
   from drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c:19:
   drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c: In function 'ipq806x_gmac_probe':
   include/linux/bitops.h:6:19: warning: large integer implicitly truncated to unsigned type
   #define BIT(nr) (1UL << (nr))
   ^
   drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c:80:29: note: in expansion of macro 'BIT'
   #define QSGMII_PHY_CDR_EN BIT(0)
   ^
   drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c:335:9: note: in expansion of macro 'QSGMII_PHY_CDR_EN'
   QSGMII_PHY_CDR_EN |
   ^
   In file included from drivers/staging/ft1000/ft1000-usb/ft1000_debug.c:42:0:
   drivers/staging/ft1000/ft1000-usb/ft1000_usb.h:31:0: warning: "FALSE" redefined
   #define FALSE 0
   ^
   In file included from include/acpi/acpi.h:58:0,
   from include/linux/acpi.h:33,
   from arch/arm64/include/asm/dma-mapping.h:21,
   from include/linux/dma-mapping.h:86,
   from include/linux/skbuff.h:34,
   from include/linux/if_ether.h:23,
   from include/uapi/linux/ethtool.h:17,
   from include/linux/ethtool.h:16,
   from include/linux/netdevice.h:42,
   from drivers/staging/ft1000/ft1000-usb/ft1000_debug.c:37:
   include/acpi/actypes.h:433:0: note: this is the location of the previous definition
   #define FALSE (1 == 0)
   ^
   In file included from drivers/staging/ft1000/ft1000-usb/ft1000_debug.c:42:0:
   drivers/staging/ft1000/ft1000-usb/ft1000_usb.h:32:0: warning: "TRUE" redefined
   #define TRUE 1
   ^
   In file included from include/acpi/acpi.h:58:0,
   from include/linux/acpi.h:33,
   from arch/arm64/include/asm/dma-mapping.h:21,
   from include/linux/dma-mapping.h:86,
   from include/linux/skbuff.h:34,
   from include/linux/if_ether.h:23,
   from include/uapi/linux/ethtool.h:17,
   from include/linux/ethtool.h:16,
   from include/linux/netdevice.h:42,
   from drivers/staging/ft1000/ft1000-usb/ft1000_debug.c:37:
   include/acpi/actypes.h:438:0: note: this is the location of the previous definition
   #define TRUE (1 == 1)
   ^
   In file included from drivers/staging/ft1000/ft1000-usb/ft1000_download.c:15:0:
   drivers/staging/ft1000/ft1000-usb/ft1000_usb.h:31:0: warning: "FALSE" redefined
   #define FALSE 0
   ^
   In file included from include/acpi/acpi.h:58:0,
   from include/linux/acpi.h:33,
   from arch/arm64/include/asm/dma-mapping.h:21,
   from include/linux/dma-mapping.h:86,
   from include/linux/skbuff.h:34,
   from include/linux/if_ether.h:23,
   from include/uapi/linux/ethtool.h:17,
   from include/linux/ethtool.h:16,
   from include/linux/netdevice.h:42,
   from drivers/staging/ft1000/ft1000-usb/ft1000_download.c:11:
   include/acpi/actypes.h:433:0: note: this is the location of the previous definition
   #define FALSE (1 == 0)
   ^
   In file included from drivers/staging/ft1000/ft1000-usb/ft1000_download.c:15:0:
   drivers/staging/ft1000/ft1000-usb/ft1000_usb.h:32:0: warning: "TRUE" redefined
   #define TRUE 1
   ^
   In file included from include/acpi/acpi.h:58:0,
   from include/linux/acpi.h:33,
   from arch/arm64/include/asm/dma-mapping.h:21,
   from include/linux/dma-mapping.h:86,
   from include/linux/skbuff.h:34,
   from include/linux/if_ether.h:23,
   from include/uapi/linux/ethtool.h:17,

vim +78 drivers/pci/host/pcie-designware.c

340cba60 Jingoo Han             2013-06-21   8   *
340cba60 Jingoo Han             2013-06-21   9   * This program is free software; you can redistribute it and/or modify
340cba60 Jingoo Han             2013-06-21  10   * it under the terms of the GNU General Public License version 2 as
340cba60 Jingoo Han             2013-06-21  11   * published by the Free Software Foundation.
340cba60 Jingoo Han             2013-06-21  12   */
340cba60 Jingoo Han             2013-06-21  13  
f342d940 Jingoo Han             2013-09-06 @14  #include <linux/irq.h>
f342d940 Jingoo Han             2013-09-06  15  #include <linux/irqdomain.h>
340cba60 Jingoo Han             2013-06-21  16  #include <linux/kernel.h>
340cba60 Jingoo Han             2013-06-21  17  #include <linux/module.h>
f342d940 Jingoo Han             2013-09-06  18  #include <linux/msi.h>
340cba60 Jingoo Han             2013-06-21  19  #include <linux/of_address.h>
804f57b1 Lucas Stach            2014-03-05  20  #include <linux/of_pci.h>
340cba60 Jingoo Han             2013-06-21  21  #include <linux/pci.h>
340cba60 Jingoo Han             2013-06-21  22  #include <linux/pci_regs.h>
4dd964df Kishon Vijay Abraham I 2014-07-17  23  #include <linux/platform_device.h>
340cba60 Jingoo Han             2013-06-21  24  #include <linux/types.h>
340cba60 Jingoo Han             2013-06-21  25  
4b1ced84 Jingoo Han             2013-07-31  26  #include "pcie-designware.h"
340cba60 Jingoo Han             2013-06-21  27  
340cba60 Jingoo Han             2013-06-21  28  /* Synopsis specific PCIE configuration registers */
340cba60 Jingoo Han             2013-06-21  29  #define PCIE_PORT_LINK_CONTROL		0x710
340cba60 Jingoo Han             2013-06-21  30  #define PORT_LINK_MODE_MASK		(0x3f << 16)
4b1ced84 Jingoo Han             2013-07-31  31  #define PORT_LINK_MODE_1_LANES		(0x1 << 16)
4b1ced84 Jingoo Han             2013-07-31  32  #define PORT_LINK_MODE_2_LANES		(0x3 << 16)
340cba60 Jingoo Han             2013-06-21  33  #define PORT_LINK_MODE_4_LANES		(0x7 << 16)
5b0f0738 Zhou Wang              2015-05-13  34  #define PORT_LINK_MODE_8_LANES		(0xf << 16)
340cba60 Jingoo Han             2013-06-21  35  
340cba60 Jingoo Han             2013-06-21  36  #define PCIE_LINK_WIDTH_SPEED_CONTROL	0x80C
340cba60 Jingoo Han             2013-06-21  37  #define PORT_LOGIC_SPEED_CHANGE		(0x1 << 17)
340cba60 Jingoo Han             2013-06-21  38  #define PORT_LOGIC_LINK_WIDTH_MASK	(0x1ff << 8)
4b1ced84 Jingoo Han             2013-07-31  39  #define PORT_LOGIC_LINK_WIDTH_1_LANES	(0x1 << 8)
4b1ced84 Jingoo Han             2013-07-31  40  #define PORT_LOGIC_LINK_WIDTH_2_LANES	(0x2 << 8)
4b1ced84 Jingoo Han             2013-07-31  41  #define PORT_LOGIC_LINK_WIDTH_4_LANES	(0x4 << 8)
5b0f0738 Zhou Wang              2015-05-13  42  #define PORT_LOGIC_LINK_WIDTH_8_LANES	(0x8 << 8)
340cba60 Jingoo Han             2013-06-21  43  
340cba60 Jingoo Han             2013-06-21  44  #define PCIE_MSI_ADDR_LO		0x820
340cba60 Jingoo Han             2013-06-21  45  #define PCIE_MSI_ADDR_HI		0x824
340cba60 Jingoo Han             2013-06-21  46  #define PCIE_MSI_INTR0_ENABLE		0x828
340cba60 Jingoo Han             2013-06-21  47  #define PCIE_MSI_INTR0_MASK		0x82C
340cba60 Jingoo Han             2013-06-21  48  #define PCIE_MSI_INTR0_STATUS		0x830
340cba60 Jingoo Han             2013-06-21  49  
340cba60 Jingoo Han             2013-06-21  50  #define PCIE_ATU_VIEWPORT		0x900
340cba60 Jingoo Han             2013-06-21  51  #define PCIE_ATU_REGION_INBOUND		(0x1 << 31)
340cba60 Jingoo Han             2013-06-21  52  #define PCIE_ATU_REGION_OUTBOUND	(0x0 << 31)
340cba60 Jingoo Han             2013-06-21  53  #define PCIE_ATU_REGION_INDEX1		(0x1 << 0)
340cba60 Jingoo Han             2013-06-21  54  #define PCIE_ATU_REGION_INDEX0		(0x0 << 0)
340cba60 Jingoo Han             2013-06-21  55  #define PCIE_ATU_CR1			0x904
340cba60 Jingoo Han             2013-06-21  56  #define PCIE_ATU_TYPE_MEM		(0x0 << 0)
340cba60 Jingoo Han             2013-06-21  57  #define PCIE_ATU_TYPE_IO		(0x2 << 0)
340cba60 Jingoo Han             2013-06-21  58  #define PCIE_ATU_TYPE_CFG0		(0x4 << 0)
340cba60 Jingoo Han             2013-06-21  59  #define PCIE_ATU_TYPE_CFG1		(0x5 << 0)
340cba60 Jingoo Han             2013-06-21  60  #define PCIE_ATU_CR2			0x908
340cba60 Jingoo Han             2013-06-21  61  #define PCIE_ATU_ENABLE			(0x1 << 31)
340cba60 Jingoo Han             2013-06-21  62  #define PCIE_ATU_BAR_MODE_ENABLE	(0x1 << 30)
340cba60 Jingoo Han             2013-06-21  63  #define PCIE_ATU_LOWER_BASE		0x90C
340cba60 Jingoo Han             2013-06-21  64  #define PCIE_ATU_UPPER_BASE		0x910
340cba60 Jingoo Han             2013-06-21  65  #define PCIE_ATU_LIMIT			0x914
340cba60 Jingoo Han             2013-06-21  66  #define PCIE_ATU_LOWER_TARGET		0x918
340cba60 Jingoo Han             2013-06-21  67  #define PCIE_ATU_BUS(x)			(((x) & 0xff) << 24)
340cba60 Jingoo Han             2013-06-21  68  #define PCIE_ATU_DEV(x)			(((x) & 0x1f) << 19)
340cba60 Jingoo Han             2013-06-21  69  #define PCIE_ATU_FUNC(x)		(((x) & 0x7) << 16)
340cba60 Jingoo Han             2013-06-21  70  #define PCIE_ATU_UPPER_TARGET		0x91C
340cba60 Jingoo Han             2013-06-21  71  
4b1ced84 Jingoo Han             2013-07-31  72  static struct hw_pci dw_pci;
4b1ced84 Jingoo Han             2013-07-31  73  
73e40850 Bjorn Helgaas          2013-10-09  74  static unsigned long global_io_offset;
340cba60 Jingoo Han             2013-06-21  75  
340cba60 Jingoo Han             2013-06-21 @76  static inline struct pcie_port *sys_to_pcie(struct pci_sys_data *sys)
340cba60 Jingoo Han             2013-06-21  77  {
84a263f3 Lucas Stach            2014-09-05 @78  	BUG_ON(!sys->private_data);
84a263f3 Lucas Stach            2014-09-05  79  
340cba60 Jingoo Han             2013-06-21  80  	return sys->private_data;
340cba60 Jingoo Han             2013-06-21 @81  }
340cba60 Jingoo Han             2013-06-21  82  
a01ef59e Pratyush Anand         2013-12-11  83  int dw_pcie_cfg_read(void __iomem *addr, int where, int size, u32 *val)
340cba60 Jingoo Han             2013-06-21  84  {

:::::: The code at line 78 was first introduced by commit
:::::: 84a263f39403ca3b399af77499876e02e634b00b PCI: designware: Check private_data validity in single place

:::::: TO: Lucas Stach <l.stach@pengutronix.de>
:::::: CC: Bjorn Helgaas <bhelgaas@google.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig
index d5e58ba..b5f1a3b 100644
--- a/drivers/pci/host/Kconfig
+++ b/drivers/pci/host/Kconfig
@@ -105,7 +105,7 @@  config PCI_XGENE_MSI
 
 config PCI_LAYERSCAPE
 	bool "Freescale Layerscape PCIe controller"
-	depends on OF && ARM
+	depends on OF && (ARM || ARM64)
 	select PCIE_DW
 	select MFD_SYSCON
 	help
diff --git a/drivers/pci/host/pci-layerscape.c b/drivers/pci/host/pci-layerscape.c
index b2328ea1..024727f 100644
--- a/drivers/pci/host/pci-layerscape.c
+++ b/drivers/pci/host/pci-layerscape.c
@@ -11,7 +11,6 @@ 
  */
 
 #include <linux/kernel.h>
-#include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/of_pci.h>
@@ -32,27 +31,60 @@ 
 #define LTSSM_STATE_MASK	0x3f
 #define LTSSM_PCIE_L0		0x11 /* L0 state */
 
-/* Symbol Timer Register and Filter Mask Register 1 */
-#define PCIE_STRFMR1 0x71c
+/* PEX Internal Configuration Registers */
+#define PCIE_STRFMR1		0x71c /* Symbol Timer & Filter Mask Register1 */
+#define PCIE_DBI_RO_WR_EN	0x8bc /* DBI Read-Only Write Enable Register */
+
+/* PEX LUT registers */
+#define PCIE_LUT_DBG		0x7FC /* PEX LUT Debug Register */
+
+struct ls_pcie_drvdata {
+	u32 lut_offset;
+	u32 ltssm_shift;
+	struct pcie_host_ops *ops;
+};
 
 struct ls_pcie {
-	struct list_head node;
-	struct device *dev;
-	struct pci_bus *bus;
-	void __iomem *dbi;
-	struct regmap *scfg;
 	struct pcie_port pp;
+	const struct ls_pcie_drvdata *drvdata;
+	void __iomem *regs;
+	void __iomem *lut;
+	struct regmap *scfg;
 	int index;
-	int msi_irq;
 };
 
 #define to_ls_pcie(x)	container_of(x, struct ls_pcie, pp)
 
-static int ls_pcie_link_up(struct pcie_port *pp)
+static bool ls_pcie_is_bridge(struct ls_pcie *pcie)
+{
+	u32 header_type;
+
+	header_type = ioread8(pcie->regs + PCI_HEADER_TYPE);
+	header_type &= 0x7f;
+
+	return header_type == PCI_HEADER_TYPE_BRIDGE;
+}
+
+/* Clear multi-function bit */
+static void ls_pcie_clear_multifunction(struct ls_pcie *pcie)
+{
+	iowrite8(PCI_HEADER_TYPE_BRIDGE, pcie->regs + PCI_HEADER_TYPE);
+}
+
+/* Fix class value */
+static void ls_pcie_fix_class(struct ls_pcie *pcie)
+{
+	iowrite16(PCI_CLASS_BRIDGE_PCI, pcie->regs + PCI_CLASS_DEVICE);
+}
+
+static int ls1021_pcie_link_up(struct pcie_port *pp)
 {
 	u32 state;
 	struct ls_pcie *pcie = to_ls_pcie(pp);
 
+	if (!pcie->scfg)
+		return 0;
+
 	regmap_read(pcie->scfg, SCFG_PEXMSCPORTSR(pcie->index), &state);
 	state = (state >> LTSSM_STATE_SHIFT) & LTSSM_STATE_MASK;
 
@@ -62,56 +94,124 @@  static int ls_pcie_link_up(struct pcie_port *pp)
 	return 1;
 }
 
-static int ls_pcie_establish_link(struct pcie_port *pp)
+static void ls1021_pcie_host_init(struct pcie_port *pp)
 {
-	unsigned int retries;
+	struct ls_pcie *pcie = to_ls_pcie(pp);
+	u32 val, index[2];
 
-	for (retries = 0; retries < 200; retries++) {
-		if (dw_pcie_link_up(pp))
-			return 0;
-		usleep_range(100, 1000);
+	pcie->scfg = syscon_regmap_lookup_by_phandle(pp->dev->of_node,
+						     "fsl,pcie-scfg");
+	if (IS_ERR(pcie->scfg)) {
+		dev_err(pp->dev, "No syscfg phandle specified\n");
+		pcie->scfg = NULL;
+		return;
 	}
 
-	dev_err(pp->dev, "phy link never came up\n");
-	return -EINVAL;
+	if (of_property_read_u32_array(pp->dev->of_node,
+				       "fsl,pcie-scfg", index, 2)) {
+		pcie->scfg = NULL;
+		return;
+	}
+	pcie->index = index[1];
+
+	/*
+	 * LS1021A Workaround for internal TKT228622
+	 * to fix the INTx hang issue
+	 */
+	val = ioread32(pcie->regs + PCIE_STRFMR1);
+	val &= 0xffff;
+	iowrite32(val, pcie->regs + PCIE_STRFMR1);
+}
+
+static int ls_pcie_link_up(struct pcie_port *pp)
+{
+	struct ls_pcie *pcie = to_ls_pcie(pp);
+	u32 state;
+
+	state = (ioread32(pcie->lut + PCIE_LUT_DBG) >>
+		 pcie->drvdata->ltssm_shift) &
+		 LTSSM_STATE_MASK;
+
+	if (state < LTSSM_PCIE_L0)
+		return 0;
+
+	return 1;
 }
 
 static void ls_pcie_host_init(struct pcie_port *pp)
 {
 	struct ls_pcie *pcie = to_ls_pcie(pp);
-	u32 val;
 
-	dw_pcie_setup_rc(pp);
-	ls_pcie_establish_link(pp);
+	iowrite32(1, pcie->regs + PCIE_DBI_RO_WR_EN);
+	ls_pcie_fix_class(pcie);
+	ls_pcie_clear_multifunction(pcie);
+	iowrite32(0, pcie->regs + PCIE_DBI_RO_WR_EN);
+}
 
-	/*
-	 * LS1021A Workaround for internal TKT228622
-	 * to fix the INTx hang issue
-	 */
-	val = ioread32(pcie->dbi + PCIE_STRFMR1);
-	val &= 0xffff;
-	iowrite32(val, pcie->dbi + PCIE_STRFMR1);
+static int ls_pcie_msi_host_init(struct pcie_port *pp,
+				 struct msi_controller *chip)
+{
+	struct device_node *msi_node;
+	struct device_node *np = pp->dev->of_node;
+
+	msi_node = of_parse_phandle(np, "msi-parent", 0);
+	if (!msi_node) {
+		dev_err(pp->dev, "failed to find msi-parent\n");
+		return -EINVAL;
+	}
+
+	return 0;
 }
 
+static struct pcie_host_ops ls1021_pcie_host_ops = {
+	.link_up = ls1021_pcie_link_up,
+	.host_init = ls1021_pcie_host_init,
+	.msi_host_init = ls_pcie_msi_host_init,
+};
+
 static struct pcie_host_ops ls_pcie_host_ops = {
 	.link_up = ls_pcie_link_up,
 	.host_init = ls_pcie_host_init,
+	.msi_host_init = ls_pcie_msi_host_init,
+};
+
+static struct ls_pcie_drvdata ls1021_drvdata = {
+	.ops = &ls1021_pcie_host_ops,
+};
+
+static struct ls_pcie_drvdata ls1043_drvdata = {
+	.lut_offset = 0x10000,
+	.ltssm_shift = 24,
+	.ops = &ls_pcie_host_ops,
+};
+
+static struct ls_pcie_drvdata ls2080_drvdata = {
+	.lut_offset = 0x80000,
+	.ltssm_shift = 0,
+	.ops = &ls_pcie_host_ops,
 };
 
-static int ls_add_pcie_port(struct ls_pcie *pcie)
+static const struct of_device_id ls_pcie_of_match[] = {
+	{ .compatible = "fsl,ls1021a-pcie", .data = &ls1021_drvdata },
+	{ .compatible = "fsl,ls1043a-pcie", .data = &ls1043_drvdata },
+	{ .compatible = "fsl,ls2080a-pcie", .data = &ls2080_drvdata },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, ls_pcie_of_match);
+
+static int __init ls_add_pcie_port(struct pcie_port *pp,
+				   struct platform_device *pdev)
 {
-	struct pcie_port *pp;
 	int ret;
+	struct ls_pcie *pcie = to_ls_pcie(pp);
 
-	pp = &pcie->pp;
-	pp->dev = pcie->dev;
-	pp->dbi_base = pcie->dbi;
-	pp->root_bus_nr = -1;
-	pp->ops = &ls_pcie_host_ops;
+	pp->dev = &pdev->dev;
+	pp->dbi_base = pcie->regs;
+	pp->ops = pcie->drvdata->ops;
 
 	ret = dw_pcie_host_init(pp);
 	if (ret) {
-		dev_err(pp->dev, "failed to initialize host\n");
+		dev_err(&pdev->dev, "failed to initialize host\n");
 		return ret;
 	}
 
@@ -120,39 +220,34 @@  static int ls_add_pcie_port(struct ls_pcie *pcie)
 
 static int __init ls_pcie_probe(struct platform_device *pdev)
 {
+	const struct of_device_id *match;
 	struct ls_pcie *pcie;
-	struct resource *dbi_base;
-	u32 index[2];
+	struct resource *res;
 	int ret;
 
+	match = of_match_device(ls_pcie_of_match, &pdev->dev);
+	if (!match)
+		return -ENODEV;
+
 	pcie = devm_kzalloc(&pdev->dev, sizeof(*pcie), GFP_KERNEL);
 	if (!pcie)
 		return -ENOMEM;
 
-	pcie->dev = &pdev->dev;
-
-	dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
-	pcie->dbi = devm_ioremap_resource(&pdev->dev, dbi_base);
-	if (IS_ERR(pcie->dbi)) {
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
+	pcie->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(pcie->regs)) {
 		dev_err(&pdev->dev, "missing *regs* space\n");
-		return PTR_ERR(pcie->dbi);
+		return PTR_ERR(pcie->regs);
 	}
 
-	pcie->scfg = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
-						     "fsl,pcie-scfg");
-	if (IS_ERR(pcie->scfg)) {
-		dev_err(&pdev->dev, "No syscfg phandle specified\n");
-		return PTR_ERR(pcie->scfg);
-	}
+	pcie->drvdata = match->data;
+	pcie->lut = pcie->regs + pcie->drvdata->lut_offset;
 
-	ret = of_property_read_u32_array(pdev->dev.of_node,
-					 "fsl,pcie-scfg", index, 2);
-	if (ret)
-		return ret;
-	pcie->index = index[1];
+	if (!ls_pcie_is_bridge(pcie))
+		return -ENODEV;
 
-	ret = ls_add_pcie_port(pcie);
-	if (ret < 0)
+	ret = ls_add_pcie_port(&pcie->pp, pdev);
+	if (ret)
 		return ret;
 
 	platform_set_drvdata(pdev, pcie);
@@ -160,12 +255,6 @@  static int __init ls_pcie_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct of_device_id ls_pcie_of_match[] = {
-	{ .compatible = "fsl,ls1021a-pcie" },
-	{ },
-};
-MODULE_DEVICE_TABLE(of, ls_pcie_of_match);
-
 static struct platform_driver ls_pcie_driver = {
 	.driver = {
 		.name = "layerscape-pcie",