Add PCIe driver for Samsung Exynos
Subsystems (4)
PATCH v3 1/3 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 | 56 + drivers/pci/host/Kconfig | 5 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-exynos.c | 1124 ++++++++++++++++++++ 4 files changed, 1186 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 +56 -0
@@ -0,0 +1,56 @@ +* Samsung Exynos PCIe interface + +Required properties: +-compatible: should be "samsung,exynos5440-pcie" +-reg: base addresses and lengths of the pcie conteroller, + additional register for the pcie controller, + the phy controller, + additional register for the phy controller. +- interrupts: interrupt values for level interrupt, + pulse interrupt, special interrupt. +- device_type, set to "pci" +- bus-range: PCI bus numbers covered +- ranges: ranges for the PCI memory and I/O regions +- reset-gpio: gpio pin number of power good signal + +Example: + +SoC specific DT Entry: + + pcie0 at 40000000 { + compatible = "samsung,exynos5440-pcie"; + reg = <0x40000000 0x4000 + 0x290000 0x1000 + 0x270000 0x1000 + 0x271000 0x40>; + interrupts = <0 20 0>, <0 21 0>, <0 22 0>; + device_type = "pci"; + bus-range = <0x0 0xf>; + ranges = <0x00000800 0 0x40000000 0x40000000 0 0x00200000 /* configuration space */ + 0x81000000 0 0 0x40200000 0 0x00004000 /* downstream I/O */ + 0x82000000 0 0 0x40204000 0 0x10000000>; /* non-prefetchable memory */ + }; + + pcie1 at 60000000 { + compatible = "samsung,exynos5440-pcie"; + reg = <0x60000000 0x4000 + 0x2a0000 0x1000 + 0x272000 0x1000 + 0x271040 0x40>; + interrupts = <0 23 0>, <0 24 0>, <0 25 0>; + device_type = "pci"; + bus-range = <0x0 0xf>; + ranges = <0x00000800 0 0x60000000 0x60000000 0 0x00200000 /* configuration space */ + 0x81000000 0 0 0x60200000 0 0x00004000 /* downstream I/O */ + 0x82000000 0 0 0x60204000 0 0x10000000>; /* non-prefetchable memory */ + }; + +Board specific DT Entry: + + pcie0 at 40000000 { + reset-gpio = <5>; + }; + + pcie1 at 60000000 { + reset-gpio = <22>; + };
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 +1124 -0
1,124 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Quoted 7 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]>
Quoted 9 lines
--- .../devicetree/bindings/pci/exynos-pcie.txt | 56 + drivers/pci/host/Kconfig | 5 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-exynos.c | 1124 ++++++++++++++++++++ 4 files changed, 1186 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/exynos-pcie.txt create mode 100644 drivers/pci/host/pci-exynos.c
Hi all,
Here is the lspci -vv output.
I tested Exynos PCIe with two e1000e LAN cards.
00:00.0 PCI bridge: Samsung Electronics Co Ltd Device a549 (rev 01) (prog-if 00 [Normal decode])
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr+ Stepping- SERR+ FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
I/O behind bridge: 00000000-00000fff
Memory behind bridge: 40300000-403fffff
Prefetchable memory behind bridge: 40400000-404fffff
Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
BridgeCtl: Parity+ SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI- D1+ D2- AuxCurrent=375mA PME(D0+,D1+,D2-,D3hot+,D3cold-)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
Address: 0000000000000000 Data: 0000
Capabilities: [70] Express (v2) Root Port (Slot-), MSI 00
DevCap: MaxPayload 512 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag+ RBE+ FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd+ ExtTag+ PhantFunc- AuxPwr- NoSnoop-
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #0, Speed 5GT/s, Width x4, ASPM L0s L1, Latency L0 <64ns, L1 <2us
ClockPM- Surprise- LLActRep+ BwNot+
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk- DLActive+ BWMgmt+ ABWMgmt-
RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal- PMEIntEna- CRSVisible-
RootCap: CRSVisible-
RootSta: PME ReqID 0000, PMEStatus- PMEPending-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+ ARIFwd-
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- ARIFwd-
LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS- Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete-, EqualizationPhase1-
EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
Capabilities: [100 v2] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
AERCap: First Error Pointer: 00, GenCap+ CGenEn- ChkCap+ ChkEn-
Capabilities: [148 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed- WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed- WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=ff
Status: NegoPending- InProgress-
Kernel driver in use: pcieport
01:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
Subsystem: Intel Corporation Gigabit CT Desktop Adapter
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr+ Stepping- SERR+ FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 53
Region 0: Memory at 40380000 (32-bit, non-prefetchable) [size=128K]
Region 1: Memory at 40300000 (32-bit, non-prefetchable) [size=512K]
Region 2: I/O ports at 40200000 [size=32]
Region 3: Memory at 403a0000 (32-bit, non-prefetchable) [size=16K]
[virtual] Expansion ROM@40400000 [disabled] [size=256K]
Capabilities: [c8] Power Management version 2
Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=1 PME-
Capabilities: [d0] MSI: Enable- Count=1/1 Maskable- 64bit+
Address: 0000000000000000 Data: 0000
Capabilities: [e0] Express (v1) Endpoint, MSI 00
DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <512ns, L1 <64us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset-
DevCtl: Report errors: Correctable+ Non-Fatal+ Fatal+ Unsupported+
RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
LnkCap: Port #4, Speed 2.5GT/s, Width x1, ASPM L0s L1, Latency L0 <128ns, L1 <64us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
Capabilities: [a0] MSI-X: Enable- Count=5 Masked-
Vector table: BAR=3 offset=00000000
PBA: BAR=3 offset=00002000
Capabilities: [100 v1] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES- TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr+ BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
AERCap: First Error Pointer: 00, GenCap- CGenEn- ChkCap- ChkEn-
Capabilities: [140 v1] Device Serial Number 68-05-ca-ff-ff-11-5e-75
Kernel driver in use: e1000e
10:00.0 PCI bridge: Samsung Electronics Co Ltd Device a549 (rev 01) (prog-if 00 [Normal decode])
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr+ Stepping- SERR+ FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Bus: primary=10, secondary=11, subordinate=11, sec-latency=0
I/O behind bridge: 00000000-00000fff
Memory behind bridge: 60300000-603fffff
Prefetchable memory behind bridge: 60400000-604fffff
Secondary status: 66MHz- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- <SERR- <PERR-
BridgeCtl: Parity+ SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
PriDiscTmr- SecDiscTmr- DiscTmrStat- DiscTmrSERREn-
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI- D1+ D2- AuxCurrent=375mA PME(D0+,D1+,D2-,D3hot+,D3cold-)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
Address: 0000000000000000 Data: 0000
Capabilities: [70] Express (v2) Root Port (Slot-), MSI 00
DevCap: MaxPayload 512 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
ExtTag+ RBE+ FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
RlxdOrd+ ExtTag+ PhantFunc- AuxPwr- NoSnoop-
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
LnkCap: Port #0, Speed 5GT/s, Width x4, ASPM L0s L1, Latency L0 <64ns, L1 <2us
ClockPM- Surprise- LLActRep+ BwNot+
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk- DLActive+ BWMgmt+ ABWMgmt-
RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal- PMEIntEna- CRSVisible-
RootCap: CRSVisible-
RootSta: PME ReqID 0000, PMEStatus- PMEPending-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+ ARIFwd-
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- ARIFwd-
LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-, Selectable De-emphasis: -6dB
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS- Compliance De-emphasis: -6dB
LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete-, EqualizationPhase1-
EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
Capabilities: [100 v2] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
AERCap: First Error Pointer: 00, GenCap+ CGenEn- ChkCap+ ChkEn-
Capabilities: [148 v1] Virtual Channel
Caps: LPEVC=0 RefClk=100ns PATEntryBits=1
Arb: Fixed- WRR32- WRR64- WRR128-
Ctrl: ArbSelect=Fixed
Status: InProgress-
VC0: Caps: PATOffset=00 MaxTimeSlots=1 RejSnoopTrans-
Arb: Fixed- WRR32- WRR64- WRR128- TWRR128- WRR256-
Ctrl: Enable+ ID=0 ArbSelect=Fixed TC/VC=ff
Status: NegoPending- InProgress-
Kernel driver in use: pcieport
11:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection
Subsystem: Intel Corporation Gigabit CT Desktop Adapter
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr+ Stepping- SERR+ FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 56
Region 0: Memory at 60380000 (32-bit, non-prefetchable) [size=128K]
Region 1: Memory at 60300000 (32-bit, non-prefetchable) [size=512K]
Region 2: I/O ports at 60200000 [size=32]
Region 3: Memory at 603a0000 (32-bit, non-prefetchable) [size=16K]
[virtual] Expansion ROM@60400000 [disabled] [size=256K]
Capabilities: [c8] Power Management version 2
Flags: PMEClk- DSI+ D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=1 PME-
Capabilities: [d0] MSI: Enable- Count=1/1 Maskable- 64bit+
Address: 0000000000000000 Data: 0000
Capabilities: [e0] Express (v1) Endpoint, MSI 00
DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <512ns, L1 <64us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset-
DevCtl: Report errors: Correctable+ Non-Fatal+ Fatal+ Unsupported+
RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr+ TransPend-
LnkCap: Port #4, Speed 2.5GT/s, Width x1, ASPM L0s L1, Latency L0 <128ns, L1 <64us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
Capabilities: [a0] MSI-X: Enable- Count=5 Masked-
Vector table: BAR=3 offset=00000000
PBA: BAR=3 offset=00002000
Capabilities: [100 v1] Advanced Error Reporting
UESta: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UEMsk: DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
UESvrt: DLP+ SDES- TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
CESta: RxErr+ BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
CEMsk: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
AERCap: First Error Pointer: 00, GenCap- CGenEn- ChkCap- ChkEn-
Capabilities: [140 v1] Device Serial Number 68-05-ca-ff-ff-18-44-c5
Kernel driver in use: e1000e
Quoted 8 lines · On Friday 07 June 2013 18:22:50 Jingoo Han wrote:
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +2
-0@@ -0,0 +1,56 @@ +* Samsung Exynos PCIe interface +
Documentation/devicetree/bindings/pci/exynos-pcie.txt line 12
Quoted 10 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +10
-0+Required properties: +-compatible: should be "samsung,exynos5440-pcie" +-reg: base addresses and lengths of the pcie conteroller, + additional register for the pcie controller, + the phy controller, + additional register for the phy controller. +- interrupts: interrupt values for level interrupt, + pulse interrupt, special interrupt. +- device_type, set to "pci" +- bus-range: PCI bus numbers covered
Why is it that only a subset of bus numbers are used? Can't you address the entire range?
Documentation/devicetree/bindings/pci/exynos-pcie.txt line 14
Quoted 2 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +2
-0+- ranges: ranges for the PCI memory and I/O regions +- reset-gpio: gpio pin number of power good signal
The 'reset-gpio' property seems incorrect. I think this should either use the gpio binding or the reset-controller binding. Specifying bare numbers to use as gpio pins does not work, since the number space for Linux internal gpio numbers is not necessarily the same as used by the hardware.
I think you also need an interrupt-map property as mandated by the PCI binding, in order to use legacy interrupts, as well as #address-cells and #size-cells.
Quoted 17 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +17
-0+ pcie0 at 40000000 { + compatible = "samsung,exynos5440-pcie"; + reg = <0x40000000 0x4000 + 0x290000 0x1000 + 0x270000 0x1000 + 0x271000 0x40>; + interrupts = <0 20 0>, <0 21 0>, <0 22 0>; + device_type = "pci"; + bus-range = <0x0 0xf>; + ranges = <0x00000800 0 0x40000000 0x40000000 0 0x00200000 /* configuration space */ + 0x81000000 0 0 0x40200000 0 0x00004000 /* downstream I/O */ + 0x82000000 0 0 0x40204000 0 0x10000000>; /* non-prefetchable memory */ + }; + + pcie1 at 60000000 { + compatible = "samsung,exynos5440-pcie"; + reg = <0x60000000 0x4000
Documentation/devicetree/bindings/pci/exynos-pcie.txt line 46
Quoted 10 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +10
-0+ 0x2a0000 0x1000 + 0x272000 0x1000 + 0x271040 0x40>; + interrupts = <0 23 0>, <0 24 0>, <0 25 0>; + device_type = "pci"; + bus-range = <0x0 0xf>; + ranges = <0x00000800 0 0x60000000 0x60000000 0 0x00200000 /* configuration space */ + 0x81000000 0 0 0x60200000 0 0x00004000 /* downstream I/O */ + 0x82000000 0 0 0x60204000 0 0x10000000>; /* non-prefetchable memory */ + };
Is it intentional that in this example you set up both buses to have both memory and I/O space start at address 0 in bus space?
I think it would be more logical to have non-overlapping addresses. You can also choose to have an identity mapping for memory space where a PCI bus address maps directly to the physical address used to access it, although that will prevent you from using legacy VGA cards that require the use of the low 16 MB.
Using a 16kb I/O space rather than a 64KB I/O space per port will lead to pci_ioremap_io() map the start of your memory space into PCI_IO_VIRT_BASE, which you probably didn't intend.
If your hardware cannot handle a full 64KB window, I would recommend to at least leave a hole before the start of the memory window.
Quoted 13 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +13
-0+struct pcie_port { + struct device *dev; + u8 controller; + u8 root_bus_nr; + void __iomem *dbi_base; + void __iomem *va_dbi_base; + void __iomem *elbi_base; + void __iomem *va_elbi_base; + void __iomem *base; + void __iomem *phy_base; + void __iomem *va_phy_base; + void __iomem *purple_base; + void __iomem *va_purple_base;
Documentation/devicetree/bindings/pci/exynos-pcie.txt
Quoted 10 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +10
-0+ void __iomem *cfg0_base; + void __iomem *va_cfg0_base; + void __iomem *cfg1_base; + void __iomem *va_cfg1_base; + void __iomem *io_base; + void __iomem *mem_base; + spinlock_t conf_lock; + struct resource io; + struct resource mem; + struct resource busn;
A lot of the fields above appear to be duplicated. If you pass a physical address, that needs to be a phys_addr_t, not void __iomem*. I think most of the physical addresses can be removed there, and you just keep the virtual addresses but drop the va_ prefix.
Quoted 9 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +9
-0+static int add_pcie_port(struct pcie_port *pp, struct platform_device *pdev) +{ + struct resource *dbi_base; + struct resource *elbi_base; + struct resource *phy_base; + struct resource *purple_base; + int ret; + + dbi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Documentation/devicetree/bindings/pci/exynos-pcie.txt
Quoted 10 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +10
-0+ if (!dbi_base) { + dev_err(&pdev->dev, "couldn't get dbi base resource\n"); + return -EINVAL; + } + if (!devm_request_mem_region(&pdev->dev, dbi_base->start, + resource_size(dbi_base), pdev->name)) { + dev_err(&pdev->dev, "dbi base resource is busy\n"); + return -EBUSY; + } + pp->dbi_base = (void __iomem *) (unsigned long)dbi_base->start;
That will also let you get rid of the casts here.
Documentation/devicetree/bindings/pci/exynos-pcie.txt
Quoted 5 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +5
-0+static int __exit exynos_pcie_remove(struct platform_device *pdev) +{ + return 0; +} +
an empty 'remove' function seems incorrect. I don't know what a removable PCI should be doing here, but at least you need to undo everything you set up in the probe function.
Arnd
Quoted 16 lines · Arnd Bergmann
Review
Quoted 1 line · On Friday 07 June 2013 18:22:50 Jingoo Han wrote:
(quoted diff) +0
-0
b/Documentation/devicetree/bindings/pci/exynos-pcie.txtQuoted 12 lines
new file mode 100644
index 0000000..3eb4a2dDocumentation/devicetree/bindings/pci/exynos-pcie.txt new file +7
-0@@ -0,0 +1,56 @@ +* Samsung Exynos PCIe interface + +Required properties: +-compatible: should be "samsung,exynos5440-pcie" +-reg: base addresses and lengths of the pcie conteroller, + additional register for the pcie controller, + the phy controller,
Quoted 8 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt line 12
Quoted 5 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +5
-0+ additional register for the phy controller. +- interrupts: interrupt values for level interrupt, + pulse interrupt, special interrupt. +- device_type, set to "pci" +- bus-range: PCI bus numbers coveredWhy is it that only a subset of bus numbers are used? Can't you address the entire range?
I will remove 'bus-range' property from DT.
Quoted 9 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt line 14
Quoted 3 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +2
-0+- ranges: ranges for the PCI memory and I/O regions +- reset-gpio: gpio pin number of power good signalThe 'reset-gpio' property seems incorrect. I think this should either use the gpio binding or the reset-controller binding. Specifying bare numbers to use as gpio pins does not work, since the number space for Linux internal gpio numbers is not necessarily the same as used by the hardware.
As you mentioned, other Exynos SoCs such as Exynos5250 set GPIO properties in DT, as below:
(./arch/arm/boot/dts/exynos5250-smdk5250.dts)
hdmi {
hpd-gpio = <&gpx3 7 0>;
};
usb at 12110000 {
samsung,vbus-gpio = <&gpx2 6 0>;
};However, the situation of Exynos5440 GPIO is different. The following bare numbers of GPIO work properly on Exynos5440. (./arch/arm/boot/dts/exynos5440-ssdk5440.dts)
pcie0 at 40000000 {
reset-gpio = <5>;
}
pcie0 at 40000000 {
reset-gpio = <22>;
}Thomas Abraham is the author of pinctrl driver for EXYNOS5440. (./drivers/pinctrl/pinctrl-exynos5440.c)
Thomas Abraham or Kukjin Kim, can you confirm this? If I am wrong, please let me know kindly. :)
Quoted 33 lines
I think you also need an interrupt-map property as mandated by the PCI binding, in order to use legacy interrupts, as well as #address-cells and #size-cells.
Quoted 17 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +17
-0+ pcie0 at 40000000 { + compatible = "samsung,exynos5440-pcie"; + reg = <0x40000000 0x4000 + 0x290000 0x1000 + 0x270000 0x1000 + 0x271000 0x40>; + interrupts = <0 20 0>, <0 21 0>, <0 22 0>; + device_type = "pci"; + bus-range = <0x0 0xf>; + ranges = <0x00000800 0 0x40000000 0x40000000 0 0x00200000 /* configuration space */ + 0x81000000 0 0 0x40200000 0 0x00004000 /* downstream I/O */ + 0x82000000 0 0 0x40204000 0 0x10000000>; /* non-prefetchable memory */ + }; + + pcie1 at 60000000 { + compatible = "samsung,exynos5440-pcie"; + reg = <0x60000000 0x4000Documentation/devicetree/bindings/pci/exynos-pcie.txt line 46
Quoted 10 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +10
-0+ 0x2a0000 0x1000 + 0x272000 0x1000 + 0x271040 0x40>; + interrupts = <0 23 0>, <0 24 0>, <0 25 0>; + device_type = "pci"; + bus-range = <0x0 0xf>; + ranges = <0x00000800 0 0x60000000 0x60000000 0 0x00200000 /* configuration space */ + 0x81000000 0 0 0x60200000 0 0x00004000 /* downstream I/O */ + 0x82000000 0 0 0x60204000 0 0x10000000>; /* non-prefetchable memory */ + };
Quoted 2 lines
Is it intentional that in this example you set up both buses to have both memory and I/O space start at address 0 in bus space?
No, it is not intentional.
I will fix it.
Quoted 7 lines
I think it would be more logical to have non-overlapping addresses. You can also choose to have an identity mapping for memory space where a PCI bus address maps directly to the physical address used to access it, although that will prevent you from using legacy VGA cards that require the use of the low 16 MB.
Quoted 6 lines
Using a 16kb I/O space rather than a 64KB I/O space per port will lead to
pci_ioremap_io()map the start of your memory space intoPCI_IO_VIRT_BASE, which you probably didn't intend.If your hardware cannot handle a full 64KB window, I would recommend to at least leave a hole before the start of the memory window.
OK, I see.
I will fix both MEM space and I/O space.
Quoted 22 lines
Quoted 22 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +21
-0+struct pcie_port { + struct device *dev; + u8 controller; + u8 root_bus_nr; + void __iomem *dbi_base; + void __iomem *va_dbi_base; + void __iomem *elbi_base; + void __iomem *va_elbi_base; + void __iomem *base; + void __iomem *phy_base; + void __iomem *va_phy_base; + void __iomem *purple_base; + void __iomem *va_purple_base; + void __iomem *cfg0_base; + void __iomem *va_cfg0_base; + void __iomem *cfg1_base; + void __iomem *va_cfg1_base; + void __iomem *io_base; + void __iomem *mem_base; + spinlock_t conf_lock; + struct resource io;
Quoted 8 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt
Quoted 2 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +2
-0+ struct resource mem; + struct resource busn;A lot of the fields above appear to be duplicated. If you pass a physical address, that needs to be a
phys_addr_t, not void __iomem*. I think most of the physical addresses can be removed there, and you just keep the virtual addresses but drop theva_prefix.
OK, I see.
I will use the 'phys_addr_t' and remove redundant physical addresses.
Quoted 14 lines
Quoted 14 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +13
-0+static int add_pcie_port(struct pcie_port *pp, struct platform_device *pdev) +{ + struct resource *dbi_base; + struct resource *elbi_base; + struct resource *phy_base; + struct resource *purple_base; + int ret; + + dbi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!dbi_base) { + dev_err(&pdev->dev, "couldn't get dbi base resource\n"); + return -EINVAL; + }
Quoted 8 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt
Quoted 6 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +6
-0+ if (!devm_request_mem_region(&pdev->dev, dbi_base->start, + resource_size(dbi_base), pdev->name)) { + dev_err(&pdev->dev, "dbi base resource is busy\n"); + return -EBUSY; + } + pp->dbi_base = (void __iomem *) (unsigned long)dbi_base->start;That will also let you get rid of the casts here.
Yes, I will remove unnecessary casts.
Quoted 11 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt
Quoted 7 lines
Documentation/devicetree/bindings/pci/exynos-pcie.txt new file +5
-0+static int __exit exynos_pcie_remove(struct platform_device *pdev) +{ + return 0; +} +an empty 'remove' function seems incorrect. I don't know what a removable PCI should be doing here, but at least you need to undo everything you set up in the probe function.
I will remove the empty 'remove' function.
Thank you for your comments. :)
I will fix it and send v4 patch, soon.
Best regards,
Jingoo Han
Quoted 3 lines
Arnd
Quoted 32 lines · Jingoo Han
Quoted 10 lines · Arnd Bergmann
Quoted 2 lines · On Friday 07 June 2013 18:22:50 Jingoo Han wrote:
+- ranges: ranges for the PCI memory and I/O regions +- reset-gpio: gpio pin number of power good signalThe 'reset-gpio' property seems incorrect. I think this should either use the gpio binding or the reset-controller binding. Specifying bare numbers to use as gpio pins does not work, since the number space for Linux internal gpio numbers is not necessarily the same as used by the hardware.
As you mentioned, other Exynos SoCs such as Exynos5250 set GPIO properties in DT, as below:
(./arch/arm/boot/dts/exynos5250-smdk5250.dts)hdmi { hpd-gpio = <&gpx3 7 0>; }; usb at 12110000 { samsung,vbus-gpio = <&gpx2 6 0>; };However, the situation of Exynos5440 GPIO is different. The following bare numbers of GPIO work properly on Exynos5440. (
./arch/arm/boot/dts/exynos5440-ssdk5440.dts)pcie0 at 40000000 { reset-gpio = <5>; } pcie0 at 40000000 { reset-gpio = <22>; }
Quoted 5 lines
Thomas Abraham is the author of pinctrl driver for EXYNOS5440. (
./drivers/pinctrl/pinctrl-exynos5440.c)Thomas Abraham or Kukjin Kim, can you confirm this? If I am wrong, please let me know kindly. :)
This is not about the code working at the moment, it is about it being correct. The current method you are using would stop working if something changes in the pinctrl code, and would not be portable to other SoCs.
Arnd