pci: Add PCIe driver for Samsung Exynos
Subsystems (4)
PATCH v6 1/3 pci: Add PCIe driver for Samsung Exynos
Exynos5440 has a PCIe controller which can be used as Root Complex. This driver supports a PCIe controller as Root Complex mode.
--- .../devicetree/bindings/pci/exynos-pcie.txt | 71 ++ drivers/pci/host/Kconfig | 5 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-exynos.c | 1057 ++++++++++++++++++++ 4 files changed, 1134 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/exynos-pcie.txt create mode 100644 drivers/pci/host/pci-exynos.c
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +71 -0
@@ -0,0 +1,71 @@ +* Samsung Exynos PCIe interface + +Required properties: +-compatible: should be "samsung,exynos5440-pcie" +-reg: base addresses and lengths of the pcie conteroller, + the phy controller, additional register for the phy controller. +- interrupts: interrupt values for level interrupt, + pulse interrupt, special interrupt. +- clocks: from common clock binding: handle to pci clock. +- clock-names: from common clock binding: Shall be "pcie", "pcie_bus". +- #address-cells: set to <3> +- #size-cells: set to <2> +- device_type: set to "pci" +- ranges: ranges for the PCI memory and I/O regions +- #interrupt-cells: set to <1> +- interrupt-map-mask and interrupt-map: standard PCI properties + to define the mapping of the PCIe interface to interrupt + numbers. +- reset-gpio: gpio pin number of power good signal + +Example: + +SoC specific DT Entry: + + pcie0 at 290000 { + compatible = "samsung,exynos5440-pcie"; + reg = <0x290000 0x1000 + 0x270000 0x1000 + 0x271000 0x40>; + interrupts = <0 20 0>, <0 21 0>, <0 22 0>; + clocks = <&clock 28>, <&clock 27>; + clock-names = "pcie", "pcie_bus"; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + ranges = <0x00000800 0 0x40000000 0x40000000 0 0x00001000 /* configuration space */ + 0x81000000 0 0 0x40001000 0 0x00010000 /* downstream I/O */ + 0x82000000 0 0x40011000 0x40011000 0 0x1ffef000>; /* non-prefetchable memory */ + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 0>; + interrupt-map = <0x0 0 &gic 53>; + }; + + pcie1 at 2a0000 { + compatible = "samsung,exynos5440-pcie"; + reg = <0x2a0000 0x1000 + 0x272000 0x1000 + 0x271040 0x40>; + interrupts = <0 23 0>, <0 24 0>, <0 25 0>; + clocks = <&clock 29>, <&clock 27>; + clock-names = "pcie", "pcie_bus"; + #address-cells = <3>; + #size-cells = <2>; + device_type = "pci"; + ranges = <0x00000800 0 0x60000000 0x60000000 0 0x00001000 /* configuration space */ + 0x81000000 0 0 0x60001000 0 0x00010000 /* downstream I/O */ + 0x82000000 0 0x60011000 0x60011000 0 0x1ffef000>; /* non-prefetchable memory */ + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 0>; + interrupt-map = <0x0 0 &gic 56>; + }; + +Board specific DT Entry: + + pcie0 at 290000 { + reset-gpio = <&pin_ctrl 5 0>; + }; + + pcie1 at 2a0000 { + reset-gpio = <&pin_ctrl 22 0>; + };
drivers/pci/host/Kconfig +5 -0
@@ -5,4 +5,9 @@ config PCI_MVEBU bool "Marvell EBU PCIe controller" depends on ARCH_MVEBU || ARCH_KIRKWOOD +config PCI_EXYNOS + bool "Samsung Exynos PCIe controller" + depends on SOC_EXYNOS5440 + select PCIEPORTBUS + endmenu
drivers/pci/host/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_PCI_MVEBU) += pci-mvebu.o +obj-$(CONFIG_PCI_EXYNOS) += pci-exynos.o
drivers/pci/host/pci-exynos.c new file +1057 -0
1,057 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Quoted 6 lines · Jingoo Han
Exynos5440 has a PCIe controller which can be used as Root Complex. This driver supports a PCIe controller as Root Complex mode.
Signed-off-by Surendranath Gurivireddy Balla <[email protected]>Signed-off-by Siva Reddy Kallam <[email protected]>Signed-off-by Jingoo Han <[email protected]>
The code looks good now.
Quoted 7 lines
.../devicetree/bindings/pci/exynos-pcie.txt | 71 ++ drivers/pci/host/Kconfig | 5 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-exynos.c | 1057 ++++++++++++++++++++ 4 files changed, 1134 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/exynos-pcie.txt create mode 100644 drivers/pci/host/pci-exynos.c
But please change the identifier to designware or synopsys as I asked you to.
Have a look at http://permalink.gmane.org/gmane.linux.kernel.pci/18400
This was an earlier submission for a PCIe host driver obviously based on the same IP block. I don't know why that driver never made it into the kernel, but if it gets submitted again, or another platform uses the same block, it should share most of your driver.
Whatever is exynos specific then can be moved out to a separate file.
Quoted 2 lines
+Required properties:
+-compatible: should be "samsung,exynos5440-pcie"
Please also add a generic string, e.g.
- compatible: should contain "snps,dwc-pcie" to identify the core, plus an identifier for the specific instance, such as "samsung,exynos5440-pcie".
Quoted 15 lines
drivers/pci/host/pci-exynos.c new file +15
-0+ +static unsigned long global_io_offset; + +static int exynos_pcie_setup (int nr,struct pci_sys_data *sys) +{ +struct pcie_port *pp; + + pp =sys_to_pcie (sys); + +if (!pp) +return 0 ; + +if (global_io_offset <SZ_1M && pp->config.io_size >0 ) { + sys->io_offset = global_io_offset - pp->config.io_bus_addr; +pci_ioremap_io (sys->io_offset, pp->io.start);
drivers/pci/host/pci-exynos.c line 418
Quoted 10 lines
drivers/pci/host/pci-exynos.c new file +10
-0+ global_io_offset +=SZ_64K ; + } + + sys->mem_offset = pp->mem.start - pp->config.mem_bus_addr; + +pci_add_resource_offset (&sys->resources, &pp->io, sys->io_offset); +pci_add_resource_offset (&sys->resources, &pp->mem, sys->mem_offset); + +return 1 ; +}
Just noticed one detail here: the 'pci_add_resource_offset' for the I/O window should be inside of the 'if' clause, we must not annouce the I/O port range to the PCI core layer unless we have actually mapped it.
Arnd