adding PCI support to AXS10x
Subsystems (5)
PATCH 1/2 add new platform driver for PCI RC
In reply to Joao PintoThis patch adds a new driver that will be the reference platform driver for all PCIe RC IP Protoyping Kits based on ARC SDP. This patch is composed by:
-Changes to pcie-designware driver adds a function that enables the feature of starting the LTSSM (Link Train Status State) used by the new driver -MAINTAINERS file was updated to include the new driver -Documentation/devicetree/bindings/pci was updated to include the new driver documentation
--- .../devicetree/bindings/pci/pcie-snpsdev.txt | 28 ++ MAINTAINERS | 7 + drivers/pci/host/Kconfig | 5 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pcie-designware.c | 9 + drivers/pci/host/pcie-designware.h | 1 + drivers/pci/host/pcie-snpsdev.c | 342 +++++++++++++++++++++ 7 files changed, 393 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/pcie-snpsdev.txt create mode 100644 drivers/pci/host/pcie-snpsdev.c
Documentation/devicetree/bindings/pci/pcie-snpsdev.txt new file +28 -0
@@ -0,0 +1,28 @@ +Synopsys PCI RC IP Prototyping Kit +---------------------------------- + +This is the reference platform driver to be used in the Synopsys PCI RC IP +Prototyping Kits. + +Required properties: +- compatible: "snps,pcie-snpsdev"; +- reg: A list of physical regions to access the device. +- interrupts: interrupt for the device. +- #address-cells: must be 3. +- #size-cells: must be 2. + +Example configuration: + + pcie: pcie@0xdffff000 { + #interrupt-cells = <1>; + compatible = "snps,pcie-snpsdev"; + reg = <0xdffff000 0x1000>; + interrupts = <25>, <24>; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + ranges = <0x00000800 0 0xd0000000 0xd0000000 0 0x00002000 + 0x81000000 0 0x00000000 0xde000000 0 0x00010000 + 0x82000000 0 0xd0400000 0xd0400000 0 0x0d000000>; + num-lanes = <1>; + };
MAINTAINERS +7 -0
@@ -8230,6 +8230,13 @@ S: Maintained F: Documentation/devicetree/bindings/pci/hisilicon-pcie.txt F: drivers/pci/host/pcie-hisi.c +PCI DRIVER FOR SYNOPSYS PROTOTYPING DEVICE +M: Joao Pinto <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/pci/pcie-snpsdev.txt +F: drivers/pci/host/pcie-snpsdev.c + PCMCIA SUBSYSTEM P: Linux PCMCIA Team L: [email protected]
drivers/pci/host/Kconfig +5 -0
@@ -172,4 +172,9 @@ config PCI_HISI help Say Y here if you want PCIe controller support on HiSilicon HIP05 SoC +config PCIE_SNPSDEV + bool "Platform Driver for Synopsys Device" + select PCIEPORTBUS + select PCIE_DW + endmenu
drivers/pci/host/Makefile +1 -0
@@ -20,3 +20,4 @@ obj-$(CONFIG_PCIE_IPROC_BCMA) += pcie-iproc-bcma.o obj-$(CONFIG_PCIE_ALTERA) += pcie-altera.o obj-$(CONFIG_PCIE_ALTERA_MSI) += pcie-altera-msi.o obj-$(CONFIG_PCI_HISI) += pcie-hisi.o +obj-$(CONFIG_PCIE_SNPSDEV) += pcie-snpsdev.o
drivers/pci/host/pcie-designware.c +9 -0
@@ -706,6 +706,15 @@ static struct pci_ops dw_pcie_ops = { .write = dw_pcie_wr_conf, }; +void dw_pcie_link_retrain (struct pcie_port *pp) +{ +u32 val =0 ; + +dw_pcie_readl_rc (pp,LINK_CONTROL_LINK_STATUS_REG , &val); + val = val |PCIE_RETRAIN_LINK_MASK ; +dw_pcie_writel_rc (pp, val,LINK_CONTROL_LINK_STATUS_REG ); +} +void dw_pcie_setup_rc (struct pcie_port *pp) {u32 val;
drivers/pci/host/pcie-designware.h +1 -0
@@ -79,5 +79,6 @@ void dw_pcie_msi_init(struct pcie_port *pp);int dw_pcie_link_up (struct pcie_port *pp);void dw_pcie_setup_rc (struct pcie_port *pp);int dw_pcie_host_init (struct pcie_port *pp); +void dw_pcie_link_retrain (struct pcie_port *pp);#endif /* _PCIE_DESIGNWARE_H */
drivers/pci/host/pcie-snpsdev.c new file +342 -0
342 lines not on this page · raw message
Signature · 1 line
1.8.1.5
PATCH 2/2 PCI support added to ARC
In reply to Joao PintoThis patch adds PCI support to ARC and updates drivers/pci Makefile enabling the ARC arch to use the generic PCI setup functions.
--- arch/arc/Kconfig | 22 +++ arch/arc/include/asm/dma.h | 5 + arch/arc/include/asm/io.h | 2 + arch/arc/include/asm/mach/pci.h | 97 +++++++++++ arch/arc/include/asm/pci.h | 34 ++++ arch/arc/kernel/Makefile | 1 + arch/arc/kernel/pcibios.c | 360 ++++++++++++++++++++++++++++++++++++++++ arch/arc/mm/ioremap.c | 29 +++- arch/arc/plat-axs10x/Kconfig | 1 + drivers/pci/Makefile | 1 + 10 files changed, 551 insertions(+), 1 deletion(-) create mode 100644 arch/arc/include/asm/mach/pci.h create mode 100644 arch/arc/include/asm/pci.h create mode 100644 arch/arc/kernel/pcibios.c
arch/arc/Kconfig +22 -0
@@ -19,6 +19,7 @@ config ARC select GENERIC_FIND_FIRST_BIT # for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP select GENERIC_IRQ_SHOW + select GENERIC_PCI_IOMAP select GENERIC_PENDING_IRQ if SMP select GENERIC_SMP_IDLE_THREAD select HAVE_ARCH_KGDB
@@ -39,6 +40,9 @@ config ARC select PERF_USE_VMALLOC select HAVE_DEBUG_STACKOVERFLOW +config MIGHT_HAVE_PCI + bool + config TRACE_IRQFLAGS_SUPPORT def_bool y
@@ -110,6 +114,24 @@ config ISA_ARCV2 endchoice +menu "Bus Support" + +config PCI + bool "PCI support" if MIGHT_HAVE_PCI + help + PCI is the name of a bus system, i.e. the way the CPU talks to the other stuff inside + your box.Find out if your board/platform have PCI. + Note: PCIE support for Synopsys Device will be available only when + HAPS DX is configured with PCIE RC bitmap. If you have PCI, say Y, otherwise N. + +config PCI_SYSCALL + def_bool PCI + +source "drivers/pci/Kconfig" +source "drivers/pci/pcie/Kconfig" + +endmenu + menu "ARC CPU Configuration" choice
arch/arc/include/asm/dma.h +5 -0
@@ -10,5 +10,10 @@#define ASM_ARC_DMA_H #define MAX_DMA_ADDRESS 0xC0000000 +#ifdef CONFIG_PCI +extern int isa_dma_bridge_buggy; +#else +#define isa_dma_bridge_buggy (0) +#endif #endif
arch/arc/include/asm/io.h +2 -0
@@ -17,6 +17,8 @@ extern void __iomem *ioremap(unsigned long physaddr, unsigned long size);extern void __iomem *ioremap_prot (phys_addr_t offset,unsigned long size,unsigned long flags);extern void iounmap (const void __iomem *addr); +extern void __iomem *ioport_map (unsigned long port,unsigned int size); +extern int pci_ioremap_io (unsigned int offset,phys_addr_t phys_addr);#define ioremap_nocache (phy, sz) ioremap(phy, sz)#define ioremap_wc (phy, sz) ioremap(phy, sz)
arch/arc/include/asm/mach/pci.h new file +97 -0
97 lines not on this page · raw message
arch/arc/include/asm/pci.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef _ASM_ARC_PCI_H +#define _ASM_ARC_PCI_H + +#ifdef __KERNEL__ +#include <asm-generic/pci-dma-compat.h> +#include <asm-generic/pci-bridge.h> + +#include <asm/mach/pci.h> /* for pci_sys_data */ + +extern unsigned long pcibios_min_io; +#define PCIBIOS_MIN_IO pcibios_min_io +extern unsigned long pcibios_min_mem; +#define PCIBIOS_MIN_MEM pcibios_min_mem + +#define pcibios_assign_all_busses () 1 +/* +* The PCI address space does equal the physical memory address space. +* The networking and block device layers use this boolean for bounce +* buffer decisions. +*/ +#define PCI_DMA_BUS_IS_PHYS (1) + +#endif /* __KERNEL__ */ + +#endif /* _ASM_ARC_PCI_H */ +
arch/arc/kernel/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-y := arcksyms.o setup.o irq.o time.o reset.o ptrace.o process.o devtree.o obj-y += signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o clk.o obj-$(CONFIG_ISA_ARCOMPACT) += entry-compact.o intc-compact.o obj-$(CONFIG_ISA_ARCV2) += entry-arcv2.o intc-arcv2.o +obj-$(CONFIG_PCI) += pcibios.o obj-$(CONFIG_MODULES) += arcksyms.o module.o obj-$(CONFIG_SMP) += smp.o
arch/arc/kernel/pcibios.c new file +360 -0
360 lines not on this page · raw message
arch/arc/mm/ioremap.c +28 -1
@@ -13,6 +13,26 @@#include <linux/mm.h> #include <linux/slab.h> #include <linux/cache.h> +#include <linux/sizes.h> + +#ifdef CONFIG_PCI +unsigned long pcibios_min_io =0x100 ; +EXPORT_SYMBOL (pcibios_min_io); + +unsigned long pcibios_min_mem =0x100000 ; +EXPORT_SYMBOL (pcibios_min_mem); +#endif + +inline void __iomem *ioport_map (unsigned long port,unsigned int nr) +{ +return port; +} +EXPORT_SYMBOL (ioport_map); + +inline void ioport_unmap (void __iomem *addr) +{ +} +EXPORT_SYMBOL (ioport_unmap);void __iomem *ioremap (unsigned long paddr,unsigned long size) {
@@ -80,7 +100,6 @@ void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size, }EXPORT_SYMBOL (ioremap_prot); -void iounmap (const void __iomem *addr) {if (addr >= (void __force __iomem *)ARC_UNCACHED_ADDR_SPACE )
@@ -89,3 +108,11 @@ void iounmap(const void __iomem *addr)vfree ((void *)(PAGE_MASK & (unsigned long __force )addr)); }EXPORT_SYMBOL (iounmap); + +#ifdef CONFIG_PCI +int pci_ioremap_io (unsigned int offset,phys_addr_t phys_addr) +{ +return ioremap_nocache (phys_addr + offset,SZ_64K ); +} +EXPORT_SYMBOL_GPL (pci_ioremap_io); +#endif
arch/arc/plat-axs10x/Kconfig +1 -0
@@ -8,6 +8,7 @@ menuconfig ARC_PLAT_AXS10X bool "Synopsys ARC AXS10x Software Development Platforms" + select MIGHT_HAVE_PCI select DW_APB_ICTL select GPIO_DWAPB select OF_GPIO
drivers/pci/Makefile +1 -0
@@ -32,6 +32,7 @@ obj-$(CONFIG_PCI_IOV) += iov.o # Some architectures use the generic PCI setup functions # obj-$(CONFIG_ALPHA) += setup-irq.o +obj-$(CONFIG_ARC) += setup-irq.o obj-$(CONFIG_ARM) += setup-irq.o obj-$(CONFIG_ARM64) += setup-irq.o obj-$(CONFIG_UNICORE32) += setup-irq.o
Signature · 1 line
1.8.1.5
cover adding PCI support to AXS10x
This patch set has the goal to add suppport for DesignWare PCIe RC in ARC AXS10x. It includes the necessary tweaks to the ARC architecture, necessary tweaks to the PCI subsystem and a new driver (pcie-snpsdev). This new driver will be used extensively in the PCIe RC Prototyping Kit.
The patches were produced against the 'next' branch of Bjorn Helgaas' repository. It was properly tested in an IP Prototyping Kit.
Joao Pinto (2):
add new platform driver for PCI RC
PCI support added to ARC
.../devicetree/bindings/pci/pcie-snpsdev.txt | 28 ++ MAINTAINERS | 7 + arch/arc/Kconfig | 22 ++ arch/arc/include/asm/dma.h | 5 + arch/arc/include/asm/io.h | 2 + arch/arc/include/asm/mach/pci.h | 97 ++++++ arch/arc/include/asm/pci.h | 34 ++ arch/arc/kernel/Makefile | 1 + arch/arc/kernel/pcibios.c | 360 +++++++++++++++++++++ arch/arc/mm/ioremap.c | 29 +- arch/arc/plat-axs10x/Kconfig | 1 + drivers/pci/Makefile | 1 + drivers/pci/host/Kconfig | 5 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pcie-designware.c | 9 + drivers/pci/host/pcie-designware.h | 1 + drivers/pci/host/pcie-snpsdev.c | 342 ++++++++++++++++++++ 17 files changed, 944 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/pci/pcie-snpsdev.txt create mode 100644 arch/arc/include/asm/mach/pci.h create mode 100644 arch/arc/include/asm/pci.h create mode 100644 arch/arc/kernel/pcibios.c create mode 100644 drivers/pci/host/pcie-snpsdev.c
Signature · 1 line
1.8.1.5
kbuild test robot
build botRe: [PATCH 1/2] add new platform driver for PCI RC
In reply to Joao Pintoreproduce:
Hi Joao,
[auto build test ERROR on arc/for-next]
[also build test ERROR on v4.4-rc2 next-20151124]
url: https://github.com/0day-ci/linux/commits/Joao-Pinto/add-new-platform-driver-for-PCI-RC/20151124-194755 base: https://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc for-next config: i386-allmodconfig (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=i386
All errors (new ones prefixed by >>):
drivers/pci/host/pcie-designware.c: In function 'dw_pcie_host_init':
drivers/pci/host/pcie-designware.c:555:7: error: implicit declaration of function 'pci_has_flag' [-Werror=implicit-function-declaration]
if (!pci_has_flag(PCI_PROBE_ONLY)) {
^
drivers/pci/host/pcie-designware.c:555:20: error: 'PCI_PROBE_ONLY' undeclared (first use in this function)
if (!pci_has_flag(PCI_PROBE_ONLY)) {
^
drivers/pci/host/pcie-designware.c:555:20: note: each undeclared identifier is reported only once for each function it appears in
drivers/pci/host/pcie-designware.c: In function 'dw_pcie_link_retrain':
>> drivers/pci/host/pcie-designware.c:713:23: error: 'LINK_CONTROL_LINK_STATUS_REG' undeclared (first use in this function)
dw_pcie_readl_rc(pp, LINK_CONTROL_LINK_STATUS_REG, &val);
^
>> drivers/pci/host/pcie-designware.c:714:14: error: 'PCIE_RETRAIN_LINK_MASK' undeclared (first use in this function)
val = val | PCIE_RETRAIN_LINK_MASK;
^cc1: some warnings being treated as errors
vim +/LINK_CONTROL_LINK_STATUS_REG +713 drivers/pci/host/pcie-designware.c
549
550 #ifdef CONFIG_ARM
551 /* support old dtbs that incorrectly describe IRQs */
552 pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci);
553 #endif
554
> 555 if (!pci_has_flag(PCI_PROBE_ONLY)) {
556 pci_bus_size_bridges(bus);
557 pci_bus_assign_resources(bus);
558
559 list_for_each_entry(child, &bus->children, node)
560 pcie_bus_configure_settings(child);
561 }
562
563 pci_bus_add_devices(bus);
564 return 0;
565 }
566
567 static int dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus,
568 u32 devfn, int where, int size, u32 *val)
569 {
570 int ret, type;
571 u32 busdev, cfg_size;
572 u64 cpu_addr;
573 void __iomem *va_cfg_base;
574
575 busdev = PCIE_ATU_BUS(bus->number) | PCIE_ATU_DEV(PCI_SLOT(devfn)) |
576 PCIE_ATU_FUNC(PCI_FUNC(devfn));
577
578 if (bus->parent->number == pp->root_bus_nr) {
579 type = PCIE_ATU_TYPE_CFG0;
580 cpu_addr = pp->cfg0_base;
581 cfg_size = pp->cfg0_size;
582 va_cfg_base = pp->va_cfg0_base;
583 } else {
584 type = PCIE_ATU_TYPE_CFG1;
585 cpu_addr = pp->cfg1_base;
586 cfg_size = pp->cfg1_size;
587 va_cfg_base = pp->va_cfg1_base;
588 }
589
590 dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
591 type, cpu_addr,
592 busdev, cfg_size);
593 ret = dw_pcie_cfg_read(va_cfg_base + where, size, val);
594 dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
595 PCIE_ATU_TYPE_IO, pp->io_base,
596 pp->io_bus_addr, pp->io_size);
597
598 return ret;
599 }
600
601 static int dw_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus,
602 u32 devfn, int where, int size, u32 val)
603 {
604 int ret, type;
605 u32 busdev, cfg_size;
606 u64 cpu_addr;
607 void __iomem *va_cfg_base;
608
609 busdev = PCIE_ATU_BUS(bus->number) | PCIE_ATU_DEV(PCI_SLOT(devfn)) |
610 PCIE_ATU_FUNC(PCI_FUNC(devfn));
611
612 if (bus->parent->number == pp->root_bus_nr) {
613 type = PCIE_ATU_TYPE_CFG0;
614 cpu_addr = pp->cfg0_base;
615 cfg_size = pp->cfg0_size;
616 va_cfg_base = pp->va_cfg0_base;
617 } else {
618 type = PCIE_ATU_TYPE_CFG1;
619 cpu_addr = pp->cfg1_base;
620 cfg_size = pp->cfg1_size;
621 va_cfg_base = pp->va_cfg1_base;
622 }
623
624 dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
625 type, cpu_addr,
626 busdev, cfg_size);
627 ret = dw_pcie_cfg_write(va_cfg_base + where, size, val);
628 dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX0,
629 PCIE_ATU_TYPE_IO, pp->io_base,
630 pp->io_bus_addr, pp->io_size);
631
632 return ret;
633 }
634
635 static int dw_pcie_valid_config(struct pcie_port *pp,
636 struct pci_bus *bus, int dev)
637 {
638 /* If there is no link, then there is no device */
639 if (bus->number != pp->root_bus_nr) {
640 if (!dw_pcie_link_up(pp))
641 return 0;
642 }
643
644 /* access only one slot on each root port */
645 if (bus->number == pp->root_bus_nr && dev > 0)
646 return 0;
647
648 /*
649 * do not read more than one device on the bus directly attached
650 * to RC's (Virtual Bridge's) DS side.
651 */
652 if (bus->primary == pp->root_bus_nr && dev > 0)
653 return 0;
654
655 return 1;
656 }
657
658 static int dw_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
659 int size, u32 *val)
660 {
661 struct pcie_port *pp = bus->sysdata;
662 int ret;
663
664 if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0) {
665 *val = 0xffffffff;
666 return PCIBIOS_DEVICE_NOT_FOUND;
667 }
668
669 if (bus->number != pp->root_bus_nr)
670 if (pp->ops->rd_other_conf)
671 ret = pp->ops->rd_other_conf(pp, bus, devfn,
672 where, size, val);
673 else
674 ret = dw_pcie_rd_other_conf(pp, bus, devfn,
675 where, size, val);
676 else
677 ret = dw_pcie_rd_own_conf(pp, where, size, val);
678
679 return ret;
680 }
681
682 static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
683 int where, int size, u32 val)
684 {
685 struct pcie_port *pp = bus->sysdata;
686 int ret;
687
688 if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0)
689 return PCIBIOS_DEVICE_NOT_FOUND;
690
691 if (bus->number != pp->root_bus_nr)
692 if (pp->ops->wr_other_conf)
693 ret = pp->ops->wr_other_conf(pp, bus, devfn,
694 where, size, val);
695 else
696 ret = dw_pcie_wr_other_conf(pp, bus, devfn,
697 where, size, val);
698 else
699 ret = dw_pcie_wr_own_conf(pp, where, size, val);
700
701 return ret;
702 }
703
704 static struct pci_ops dw_pcie_ops = {
705 .read = dw_pcie_rd_conf,
706 .write = dw_pcie_wr_conf,
707 };
708
709 void dw_pcie_link_retrain(struct pcie_port *pp)
710 {
711 u32 val = 0;
712
> 713 dw_pcie_readl_rc(pp, LINK_CONTROL_LINK_STATUS_REG, &val);
> 714 val = val | PCIE_RETRAIN_LINK_MASK; 715 dw_pcie_writel_rc(pp, val, LINK_CONTROL_LINK_STATUS_REG);
716 }
717
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation