SPEAr13xx PCIe patches
Subsystems (6)
cover SPEAr13xx PCIe patches
-- First two patches are common for all platforms on ARM architecture. -- Remaining patches belongs to SPEAr13xx architecture.
-- SPEAr13xx supports both RC and EP mode of PCIe interface. This patchset
supports only RC mode.
Pratyush Anand (15):
arm: source drivers/pci/pcie/kconfig
arm: Call pcie_bus_configure_settings for pcie devices
SPEAr13xx: Add mach/io.h
SPEAr13xx: Add PCIe Root Complex driver support
clk: SPEAr1340: Fix pcie0 clock name
clk: SPEAr1310: Fix pcie clock name
SPEAr1340: Add PCIe auxdata for miphy clock initialization
SPEAr1310: Add PCIe auxdata for miphy clock initialization
SPEAr13xx: dts: Fix PCIe core address ranges
SPEAr13xx: DTS: Add auxiliary data for PCIe host
SPEAr1340-evb: dts: Enable PCIe0
SPEAr1310-EVB: DTS: Fix PCIe1 enable
SPEAr13xx: update kconfig for PCIe selection
SPEAR13xx: Update makefile for PCIe inclusion
SPEAR13xx: update defconfig for PCIe compilation
arch/arm/Kconfig | 1 + arch/arm/boot/dts/spear1310-evb.dts | 4 - arch/arm/boot/dts/spear1340-evb.dts | 4 + arch/arm/boot/dts/spear13xx.dtsi | 33 +- arch/arm/configs/spear13xx_defconfig | 1 + arch/arm/kernel/bios32.c | 12 + arch/arm/mach-spear13xx/Kconfig | 12 + arch/arm/mach-spear13xx/Makefile | 1 + arch/arm/mach-spear13xx/include/mach/io.h | 35 + arch/arm/mach-spear13xx/include/mach/pcie.h | 233 ++++++ arch/arm/mach-spear13xx/pcie.c | 1145 +++++++++++++++++++++++++++ arch/arm/mach-spear13xx/spear1310.c | 148 ++++ arch/arm/mach-spear13xx/spear1340.c | 26 + drivers/clk/spear/spear1310_clock.c | 6 +- drivers/clk/spear/spear1340_clock.c | 2 +- 15 files changed, 1651 insertions(+), 12 deletions(-) create mode 100644 arch/arm/mach-spear13xx/include/mach/io.h create mode 100644 arch/arm/mach-spear13xx/include/mach/pcie.h create mode 100644 arch/arm/mach-spear13xx/pcie.c
Signature · 1 line
1.7.5.4
PATCH 1/15 arm: source drivers/pci/pcie/kconfig
--- arch/arm/Kconfig | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/Kconfig +1 -0
@@ -1434,6 +1434,7 @@ config PCI_HOST_ITE8152 select DMABOUNCE source "drivers/pci/Kconfig" +source "drivers/pci/pcie/Kconfig" source "drivers/pcmcia/Kconfig"
Signature · 1 line
1.7.5.4
PATCH 2/15 arm: Call pcie_bus_configure_settings for pcie devices
In reply to Pratyush AnandThere could be some device which will work only after adjusting their "Max Packet Size" and/or "Max Read Request Size".
This modification will only be effective if proper 'pci=' bootargs is passed.
--- arch/arm/kernel/bios32.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
arch/arm/kernel/bios32.c +12 -0
@@ -490,6 +490,18 @@ void __init pci_common_init(struct hw_pci *hw)struct pci_bus *bus = sys->bus;if (!pci_has_flag (PCI_PROBE_ONLY )) { +struct pci_bus *child; + +/* +* Set MPS and readrq size +*/ +list_for_each_entry (child, &bus->children, node) { +struct pci_dev *self = child->self; +if (!self) +continue ; +pcie_bus_configure_settings (child, + self->pcie_mpss); + }/* * Size the bridge windows. */
Signature · 1 line
1.7.5.4
PATCH 3/15 SPEAr13xx: Add mach/io.h
In reply to Pratyush AnandIn case of PCIe we need to have a different __io macro, which can write into PCIe address space.
--- arch/arm/mach-spear13xx/include/mach/io.h | 35 +++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-spear13xx/include/mach/io.h
arch/arm/mach-spear13xx/include/mach/io.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* arch/arm/mach-spear13xx/include/mach/io.h +* +* spear13xx machine family generic header file +* +* Copyright (C) 2012 ST Microelectronics +* Pratyush Anand <[email protected]> +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#ifndef __MACH_IO_H +#define __MACH_IO_H + +#define IO_SPACE_LIMIT 0xFFFF + +#ifdef CONFIG_SPEAR13XX_PCI +extern void __iomem *spear13xx_pcie_io_base (unsigned long addr); + +static inline void __iomem *__io (unsigned long addr) +{ +return spear13xx_pcie_io_base (addr) + (addr &IO_SPACE_LIMIT ); +} +#else +static inline void __iomem *__io (unsigned long addr) +{ +return (void __iomem *)addr; +} +#endif + +#define __io (a) __io(a) + +#endif /* __MACH_IO_H */
Signature · 1 line
1.7.5.4
Re: [PATCH 03/15] SPEAr13xx: Add mach/io.h
Quoted 2 lines · Pratyush Anand
In case of PCIe we need to have a different
__iomacro, which can write into PCIe address space.
You may find this interesting:
Do, git log --stat -p dd9bf78040fa0da4cecc228e1682b9682b8cb180
There is a series of commits like:
commit dd9bf78040fa0da4cecc228e1682b9682b8cb180
Author: Rob Herring <[email protected]> Date: Wed Jul 4 11:18:40 2012 -0500
ARM: iop3xx: use fixed PCI i/o mapping
Move iop33x and iop32x PCI to fixed i/o mapping and remove io.h. This changes the PCI bus addresses from the cpu address to 0 based. It appears that there is translation h/w for this, but its untested.
Not sure what to do with io_offset. I think it should always be 0. AFAICT, PCI setup is skipped if the ATU is already setup.
All mach/io.h are removed and you are adding one of those. :)
Quoted 13 lines
Signed-off-by Pratyush Anand <[email protected]>--- arch/arm/mach-spear13xx/include/mach/io.h | 35 +++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-spear13xx/include/mach/io.harch/arm/mach-spear13xx/include/mach/io.h new file +0
-0
arch/arm/mach-spear13xx/include/mach/io.h line 4
Quoted 4 lines
arch/arm/mach-spear13xx/include/mach/io.h new file +4
-0@@ -0,0 +1,35 @@ +/* +* arch/arm/mach-spear13xx/include/mach/io.h +* +* spear13xx machine family generic header file
SPEAr
Quoted 34 lines
arch/arm/mach-spear13xx/include/mach/io.h new file +31
-1+* +* Copyright (C) 2012 ST Microelectronics +* Pratyush Anand <[email protected]> +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#ifndef __MACH_IO_H +#define __MACH_IO_H + +#define IO_SPACE_LIMIT 0xFFFF + +#ifdef CONFIG_SPEAR13XX_PCI +extern void __iomem *spear13xx_pcie_io_base (unsigned long addr); + +static inline void __iomem *__io (unsigned long addr) +{ +return spear13xx_pcie_io_base (addr) + (addr &IO_SPACE_LIMIT ); +} +#else +static inline void __iomem *__io (unsigned long addr) +{ +return (void __iomem *)addr; +} +#endif + +#define __io (a) __io(a) + +#endif /* __MACH_IO_H */ --1.7.5.4
Re: [PATCH 03/15] SPEAr13xx: Add mach/io.h
Quoted 11 lines · viresh kumar
Quoted 2 lines · Pratyush Anand
In case of PCIe we need to have a different
__iomacro, which can write into PCIe address space.You may find this interesting:
Do, git log --stat -p
dd9bf78040fa0da4cecc228e1682b9682b8cb180There is a series of commits like:
commit
dd9bf78040fa0da4cecc228e1682b9682b8cb180
Quoted 8 lines
Author: Rob Herring <[email protected]> Date: Wed Jul 4 11:18:40 2012 -0500ARM: iop3xx: use fixed PCI i/o mapping
Move iop33x and iop32x PCI to fixed i/o mapping and remove
io.h. This changes the PCI bus addresses from the cpu address to 0 based. It appears that there is translation h/w for this, but its untested.
In case of SPEAr we can not translate a CPU address 0 to PCIe space. To explain it better, lets say we allocate 0x0000 - 0xFFFF for PCIe IO transaction. Now if CPU writes on these addressed, there is no way we can route those transactions to PCIe bus.
Any transaction between 0x80000000 to 0x8FFFFFFF can only be used for any type(IO/MEM/CFG0/CFG1) of PCIe transaction. Therefore , we need to have this mapping in io.h.
Regards
Pratyush
Quoted 65 lines
Not sure what to do with
io_offset. I think it should always be 0. AFAICT, PCI setup is skipped if the ATU is already setup.Signed-off-by Rob Herring <[email protected]>Reviewed-by Arnd Bergmann <[email protected]>All
mach/io.hare removed and you are adding one of those. :)Quoted 13 lines
Signed-off-by Pratyush Anand <[email protected]>--- arch/arm/mach-spear13xx/include/mach/io.h | 35 +++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-)create mode 100644
arch/arm/mach-spear13xx/include/mach/io.harch/arm/mach-spear13xx/include/mach/io.h new file +0
-0arch/arm/mach-spear13xx/include/mach/io.h line 4
Quoted 4 lines
arch/arm/mach-spear13xx/include/mach/io.h new file +4
-0@@ -0,0 +1,35 @@ +/* +* arch/arm/mach-spear13xx/include/mach/io.h +* +* spear13xx machine family generic header file SPEAr
Quoted 32 lines
arch/arm/mach-spear13xx/include/mach/io.h new file +31
-1+* +* Copyright (C) 2012 ST Microelectronics +* Pratyush Anand <[email protected]> +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ + +#ifndef __MACH_IO_H +#define __MACH_IO_H + +#define IO_SPACE_LIMIT 0xFFFF + +#ifdef CONFIG_SPEAR13XX_PCI +extern void __iomem *spear13xx_pcie_io_base (unsigned long addr); + +static inline void __iomem *__io (unsigned long addr) +{ +return spear13xx_pcie_io_base (addr) + (addr &IO_SPACE_LIMIT ); +} +#else +static inline void __iomem *__io (unsigned long addr) +{ +return (void __iomem *)addr; +} +#endif + +#define __io (a) __io(a) + +#endif /* __MACH_IO_H */ --Quoted 2 lines
1.7.5.4
.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 03/15] SPEAr13xx: Add mach/io.h
Quoted 3 lines · Pratyush Anand
Any transaction between
0x80000000to0x8FFFFFFFcan only be used for any type(IO/MEM/CFG0/CFG1) of PCIe transaction. Therefore , we need to have this mapping inio.h.
No you don't.
The I/O space window will only be in one place on a given system, so you should register that window using pci_ioremap_io() as all the other modern platforms. There is no excuse for having a per-platform mach/io.h any more and that would prevent you from enabling spear in a multiplatform configuration.
Arnd
Re: [PATCH 03/15] SPEAr13xx: Add mach/io.h
Quoted 9 lines · Arnd Bergmann
Quoted 3 lines · Pratyush Anand
Any transaction between
0x80000000to0x8FFFFFFFcan only be used for any type(IO/MEM/CFG0/CFG1) of PCIe transaction. Therefore , we need to have this mapping inio.h.No you don't.
The I/O space window will only be in one place on a given system, so you should register that window using
pci_ioremap_io()as all the other
Sorry, I could not find pci_ioremap_io function. May be you wanted to refer something else.
In case of SPEAr too , we can reserve first 32Kb per controller as PCIe IO space. So, lets say I fixed address 0x80000000--0x80007FFF for IO transaction. I need to register address range of this window somehow.
But, issue which faced was that I was not able to successfully request_resource(&ioport_resource, &res]) with res.start = 0x80000000 and res.end = 0x80007fff.
So, I though first to change IO_SPACE_LIMIT. But I found it not a correct way.
May be I am missing something and not able to get how can I use pci_ioremap_io or something else to register 0x80000000--0x80007FFF window. A reference will help.
Regards
Pratyush
Quoted 7 lines
modern platforms. There is no excuse for having a per-platform
mach/io.hany more and that would prevent you from enabling spear in a multiplatform configuration.Arnd
.
Re: [PATCH 03/15] SPEAr13xx: Add mach/io.h
Quoted 2 lines · Pratyush Anand
Sorry, I could not find
pci_ioremap_iofunction. May be you wanted to refer something else.
$ git grep pci_ioremap_io arch/arm/include/asm/io.h:extern int pci_ioremap_io(unsigned int offset, phys_addr_t phys_addr); arch/arm/mach-dove/pcie.c: pci_ioremap_io(sys->busnr * SZ_64K, DOVE_PCIE0_IO_PHYS_BASE); ... arch/arm/mach-versatile/pci.c: ret = pci_ioremap_io(0, VERSATILE_PCI_MEM_BASE0); arch/arm/mm/ioremap.c:int pci_ioremap_io(unsigned int offset, phys_addr_t phys_addr) arch/arm/mm/ioremap.c:EXPORT_SYMBOL_GPL(pci_ioremap_io);
Quoted 7 lines
In case of SPEAr too , we can reserve first 32Kb per controller as PCIe IO space. So, lets say I fixed address 0x80000000--0x80007FFF for IO transaction. I need to register address range of this window somehow.
But, issue which faced was that I was not able to successfully
request_resource(&ioport_resource, &res])with res.start =0x80000000and res.end =0x80007fff.
That cannot work properly, because the ioport_resource lists ports between 0 and 0x10000 normally, or possibly a little bit higher. You certainly don't want to waste 2 GB of virtual address space for having a PCI I/O window that you don't use.
Quoted 6 lines
So, I though first to change
IO_SPACE_LIMIT. But I found it not a correct way.May be I am missing something and not able to get how can I use
pci_ioremap_ioor something else to register 0x80000000--0x80007FFF window. A reference will help.
Calling pci_ioremap_io will do the right thing, you just have to decide how you partition the I/O space between the root complexes you have.
Arnd
PATCH 4/15 SPEAr13xx: Add PCIe Root Complex driver support
In reply to Pratyush AnandSPEAr13xx has dual mode PCIe controller which can be used as Root Complex as well as Endpoint. This driver supports RC mode of the controller.
If CONFIG_PCI_MSI is defined then support of MSI interrupt for downstream PCIe devices will be enabled.
If CONFIG_PM is defined then it supports suspend/resume functionality.
--- arch/arm/mach-spear13xx/include/mach/pcie.h | 233 ++++++ arch/arm/mach-spear13xx/pcie.c | 1145 +++++++++++++++++++++++++++ 2 files changed, 1378 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-spear13xx/include/mach/pcie.h create mode 100644 arch/arm/mach-spear13xx/pcie.c
arch/arm/mach-spear13xx/include/mach/pcie.h new file +233 -0
@@ -0,0 +1,233 @@ +/* +* arch/arm/mach-spear13xx/include/mach/pcie.h +* +* Copyright (C) 2010-2012 ST Microelectronics +* Pratyush Anand <[email protected]> +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ +#ifndef __MACH_PCIE_H +#define __MACH_PCIE_H + +#include <linux/pci.h> +#include <linux/platform_device.h> +#include <linux/types.h> +#include <linux/clk.h> + +#define MAX_LINK_UP_WAIT_MS 2 +/* Max port defined can be changed if required */ +#define MAX_PCIE_PORT_SUPPORTED 3 +struct pcie_port ; + +struct pcie_port_info { +u32 is_host; +u32 is_gen1; +u32 cfg0_size; +u32 cfg1_size; +u32 mem_size; +u32 msg_size; +u32 in_mem_size; +u32 io_size; +int (*clk_init)(struct pcie_port *pp); +int (*clk_exit)(struct pcie_port *pp); +}; + +struct pcie_port { +u8 controller; +u8 root_bus_nr; +void __iomem *dbi_base; +void __iomem *va_dbi_base; +void __iomem *app_base; +void __iomem *va_app_base; +void __iomem *base; +void __iomem *phy_base; +void __iomem *va_phy_base; +void __iomem *cfg0_base; +void __iomem *va_cfg0_base; +void __iomem *cfg1_base; +void __iomem *va_cfg1_base; +void __iomem *mem_base; +void __iomem *io_base; +spinlock_t conf_lock; +char mem_space_name[16 ]; +char io_space_name[16 ]; +struct resource res[2 ]; +struct pcie_port_info config; +struct list_head next; +struct clk *clk; +int irq; +int virt_irq_base; +int susp_state; +}; + +/* synopsis specific PCIE configuration registers*/ +#define PCIE_PORT_LOGIC 0x80C +#define PORT_LOGIC_SPD_CHANGE_ID 17 + +#define PCIE_MSI_ADDR_LO 0x820 +#define PCIE_MSI_ADDR_HI 0x824 +#define PCIE_MSI_INTR0_ENABLE 0x828 +#define PCIE_MSI_INTR0_MASK 0x82C +#define PCIE_MSI_INTR0_STATUS 0x830 + +#define PCIE_ATU_VIEWPORT 0x900 +#define PCIE_ATU_REGION_INBOUND (1 << 31) +#define PCIE_ATU_REGION_OUTBOUND (0 << 31) +#define PCIE_ATU_CR1 0x904 +#define PCIE_ATU_TYPE_MEM 0 +#define PCIE_ATU_TYPE_IO 2 +#define PCIE_ATU_TYPE_CFG0 4 +#define PCIE_ATU_TYPE_CFG1 5 +#define PCIE_ATU_CR2 0x908 +#define PCIE_ATU_ENABLE (1 << 31) +#define PCIE_ATU_BAR_MODE_ENABLE (1 << 30) +#define PCIE_ATU_LOWER_BASE 0x90C +#define PCIE_ATU_UPPER_BASE 0x910 +#define PCIE_ATU_LIMIT 0x914 +#define PCIE_ATU_LOWER_TARGET 0x918 +#define PCIE_ATU_UPPER_TARGET 0x91C + +/*BAR MASK registers*/ +#define PCIE_BAR0_MASK_REG 0x1010 + +struct pcie_app_reg { +u32 app_ctrl_0;/*cr0*/ +u32 app_ctrl_1;/*cr1*/ +u32 app_status_0;/*cr2*/ +u32 app_status_1;/*cr3*/ +u32 msg_status;/*cr4*/ +u32 msg_payload;/*cr5*/ +u32 int_sts;/*cr6*/ +u32 int_clr;/*cr7*/ +u32 int_mask;/*cr8*/ +u32 mst_bmisc;/*cr9*/ +u32 phy_ctrl;/*cr10*/ +u32 phy_status;/*cr11*/ +u32 cxpl_debug_info_0;/*cr12*/ +u32 cxpl_debug_info_1;/*cr13*/ +u32 ven_msg_ctrl_0;/*cr14*/ +u32 ven_msg_ctrl_1;/*cr15*/ +u32 ven_msg_data_0;/*cr16*/ +u32 ven_msg_data_1;/*cr17*/ +u32 ven_msi_0;/*cr18*/ +u32 ven_msi_1;/*cr19*/ +u32 mst_rmisc;/*cr 20*/ +u32 slv_awmisc;/*cr 21*/ +u32 slv_armisc;/*cr 22*/ +u32 pom0_mem_addr_start;/*cr23*/ +u32 pom1_mem_addr_start;/*cr24*/ +u32 pom_io_addr_start;/*cr25*/ +u32 pom_cfg0_addr_start;/*cr26*/ +u32 pom_cfg1_addr_start;/*cr27*/ +u32 in0_mem_addr_start;/*cr28*/ +u32 in1_mem_addr_start;/*cr29*/ +u32 in_io_addr_start;/*cr30*/ +u32 in_cfg0_addr_start;/*cr31*/ +u32 in_cfg1_addr_start;/*cr32*/ +u32 in_msg_addr_start;/*cr33*/ +u32 in0_mem_addr_limit;/*cr34*/ +u32 in1_mem_addr_limit;/*cr35*/ +u32 in_io_addr_limit;/*cr36*/ +u32 in_cfg0_addr_limit;/*cr37*/ +u32 in_cfg1_addr_limit;/*cr38*/ +u32 in_msg_addr_limit;/*cr39*/ +u32 mem0_addr_offset_limit;/*cr40*/ +u32 pim0_mem_addr_start;/*cr41*/ +u32 pim1_mem_addr_start;/*cr42*/ +u32 pim_io_addr_start;/*cr43*/ +u32 pim_rom_addr_start;/*cr44*/ +}; + +/*CR0 ID*/ +#define RX_LANE_FLIP_EN_ID 0 +#define TX_LANE_FLIP_EN_ID 1 +#define SYS_AUX_PWR_DET_ID 2 +#define APP_LTSSM_ENABLE_ID 3 +#define SYS_ATTEN_BUTTON_PRESSED_ID 4 +#define SYS_MRL_SENSOR_STATE_ID 5 +#define SYS_PWR_FAULT_DET_ID 6 +#define SYS_MRL_SENSOR_CHGED_ID 7 +#define SYS_PRE_DET_CHGED_ID 8 +#define SYS_CMD_CPLED_INT_ID 9 +#define APP_INIT_RST_0_ID 11 +#define APP_REQ_ENTR_L1_ID 12 +#define APP_READY_ENTR_L23_ID 13 +#define APP_REQ_EXIT_L1_ID 14 +#define DEVICE_TYPE_EP (0 << 25) +#define DEVICE_TYPE_LEP (1 << 25) +#define DEVICE_TYPE_RC (4 << 25) +#define SYS_INT_ID 29 +#define MISCTRL_EN_ID 30 +#define REG_TRANSLATION_ENABLE 31 + +/*CR1 ID*/ +#define APPS_PM_XMT_TURNOFF_ID 2 +#define APPS_PM_XMT_PME_ID 5 + +/*CR3 ID*/ +#define XMLH_LTSSM_STATE_ID 0 +#define XMLH_LTSSM_STATE_L0 ((u32)0x11 << XMLH_LTSSM_STATE_ID) +#define XMLH_LTSSM_STATE_MASK ((u32)0x3F << XMLH_LTSSM_STATE_ID) +#define XMLH_LINK_UP_ID 6 + +/*CR4 ID*/ +#define CFG_MSI_EN_ID 18 + +/*CR6*/ +#define INTA_CTRL_INT (1 << 7) +#define INTB_CTRL_INT (1 << 8) +#define INTC_CTRL_INT (1 << 9) +#define INTD_CTRL_INT (1 << 10) +#define MSI_CTRL_INT (1 << 26) + +/*CR19 ID*/ +#define VEN_MSI_REQ_ID 11 +#define VEN_MSI_FUN_NUM_ID 8 +#define VEN_MSI_TC_ID 5 +#define VEN_MSI_VECTOR_ID 0 +#define VEN_MSI_REQ_EN ((u32)0x1 << VEN_MSI_REQ_ID) +#define VEN_MSI_FUN_NUM_MASK ((u32)0x7 << VEN_MSI_FUN_NUM_ID) +#define VEN_MSI_TC_MASK ((u32)0x7 << VEN_MSI_TC_ID) +#define VEN_MSI_VECTOR_MASK ((u32)0x1F << VEN_MSI_VECTOR_ID) + +/*CE21-22 ID*/ +/*ID definition of ARMISC*/ +#define AXI_OP_TYPE_ID 0 +#define AXI_OP_BCM_ID 5 +#define AXI_OP_EP_ID 6 +#define AXI_OP_TD_ID 7 +#define AXI_OP_ATTRIBUTE_ID 8 +#define AXI_OP_TC_ID 10 +#define AXI_OP_MSG_CODE_ID 13 +#define AXI_OP_DBI_ACCESS_ID 21 +#define AXI_OP_TYPE_MASK 0x1F +#define AXI_OP_TYPE_MEM_RDRW 0 +#define AXI_OP_TYPE_MEM_RDRW_LOCKED 1 +#define AXI_OP_TYPE_IO_RDRW 2 +#define AXI_OP_TYPE_CONFIG_RDRW_TYPE0 4 +#define AXI_OP_TYPE_CONFIG_RDRW_TYPE1 5 +#define AXI_OP_TYPE_MSG_REQ 16 +#define AXI_OP_TYPE_COMPLETION 10 +#define AXI_OP_TYPE_COMPLETION_LOCKED 11 +#define AXI_OP_TYPE_DBI_ELBI_ENABLE 1 + +#define PCI_CAP_ID_EXP_OFFSET 0x70 + +#define PCIE_IS_HOST 1 +#define PCIE_IS_DEVICE 0 + +#define PCIE_IS_GEN1 1 +#define PCIE_IS_GEN2 0 + +#define NUM_INTX_IRQS 4 +/* +* Maximum number of MSI IRQs can be 256 per controller. But keep it 64 +* as of now. Probably we will never need more than 64. If needed, then +* Increment it in multiple of 32. +*/ +#define NUM_MSI_IRQS 64 + +#define IO_SIZE_PER_PORT SZ_16K +#endif
arch/arm/mach-spear13xx/pcie.c new file +1145 -0
1,145 lines not on this page · raw message
Signature · 1 line
1.7.5.4
Re: [PATCH 04/15] SPEAr13xx: Add PCIe Root Complex driver support
Quoted 8 lines · Pratyush Anand
SPEAr13xx has dual mode PCIe controller which can be used as Root Complex as well as Endpoint. This driver supports RC mode of the controller.
If
CONFIG_PCI_MSIis defined then support of MSI interrupt for downstream PCIe devices will be enabled.If
CONFIG_PMis defined then it supports suspend/resume functionality.
I think I've seen the same hardware before used with another driver. IMHO we should really make sure this does not get duplicated again and move this stuff to a new subdirectory drivers/pci/host. We don't yet have a completely architecture independent way of defining a PCIe root complex, but we're getting there and given of how many ARM implementations we have, we can just as well start with this one and adapt it to another arch if necesary.
Quoted 17 lines
arch/arm/mach-spear13xx/include/mach/pcie.h new file +17
-0+struct pcie_port { +u8 controller; +u8 root_bus_nr; +void __iomem *dbi_base; +void __iomem *va_dbi_base; +void __iomem *app_base; +void __iomem *va_app_base; +void __iomem *base; +void __iomem *phy_base; +void __iomem *va_phy_base; +void __iomem *cfg0_base; +void __iomem *va_cfg0_base; +void __iomem *cfg1_base; +void __iomem *va_cfg1_base; +void __iomem *mem_base; +void __iomem *io_base; +spinlock_t conf_lock;
arch/arm/mach-spear13xx/include/mach/pcie.h line 63
Quoted 10 lines
arch/arm/mach-spear13xx/include/mach/pcie.h new file +10
-0+char mem_space_name[16 ]; +char io_space_name[16 ]; +struct resource res[2 ]; +struct pcie_port_info config; +struct list_head next; +struct clk *clk; +int irq; +int virt_irq_base; +int susp_state; +};
Can you explain why you need a total of 13 virtual memory areas?
arch/arm/mach-spear13xx/pcie.c line 31
Quoted 2 lines
arch/arm/mach-spear13xx/pcie.c new file +2
-0+ +static struct list_head pcie_port_list;
I'm pretty sure you don't need your own list of ports, since we already enumerate the ports in the PCI code.
Quoted 1 line
+static struct
hw_pcipci;
Why is this not statically initialized?
arch/arm/mach-spear13xx/pcie.c line 417
Quoted 10 lines
arch/arm/mach-spear13xx/pcie.c new file +10
-0+snprintf (pp->io_space_name,sizeof (pp->io_space_name), +"PCIe %d I/O" , nr); + pp->io_space_name[sizeof (pp->io_space_name) -1 ] =0 ; + pp->res[1 ].name = pp->io_space_name; + pp->res[1 ].start =PCIBIOS_MIN_IO + nr * pp->config.io_size; + pp->res[1 ].end = pp->res[1 ].start + (pp->config.io_size -1 ); + pp->res[1 ].flags =IORESOURCE_IO ; +if (request_resource (&ioport_resource, &pp->res[1 ])) +panic ("can't allocate PCIe IO space" ); +pci_add_resource_offset (&sys->resources, &pp->res[1 ], sys->io_offset);
Is the io_offset ever nonzero?
arch/arm/mach-spear13xx/pcie.c line 734
Quoted 9 lines
arch/arm/mach-spear13xx/pcie.c new file +9
-0+void __iomem *spear13xx_pcie_io_base (unsigned long addr) +{ +int controller = (addr -PCIBIOS_MIN_IO ) /IO_SIZE_PER_PORT ; +struct pcie_port *pp; + + pp =controller_to_port (controller); + +return pp->io_base; +}
This function looks completely bogus. Subtracting PCIBIOS_MIN_IO means that everything is shifted by 0x1000 ports, since secondary bridges don't have this offset. The I/O spaces are just mapped linearly into the virtual address space anyway, so looking up the I/O base like this is pointless.
arch/arm/mach-spear13xx/pcie.c line 748
Quoted 13 lines
arch/arm/mach-spear13xx/pcie.c new file +13
-0+static void pcie_host_init (struct pcie_port *pp) +{ +struct pcie_port_info *config = &pp->config; +void __iomem *dbi_base = pp->va_dbi_base; +struct pcie_app_reg *app_reg = pp->va_app_base; +u32 exp_cap_off =PCI_CAP_ID_EXP_OFFSET ; +u32 val; + +/* Keep first 64K for IO */ + pp->io_base = pp->base; + pp->mem_base = pp->io_base + config->io_size; + pp->cfg0_base = pp->mem_base + config->mem_size; + pp->cfg1_base = pp->cfg0_base + config->cfg0_size;
Why is the memory space part of the virtual bus address range here?
Quoted 12 lines
arch/arm/mach-spear13xx/pcie.c new file +12
-0+static int add_pcie_port (struct pcie_port *pp,struct platform_device *pdev) +{ +struct resource *base; +struct resource *dbi_base; +struct resource *phy_base; +int virt_irq_base; +struct device_node *np = pdev->dev.of_node; +struct irq_domain *irq_domain; +int num_virt_irqs =NUM_INTX_IRQS ; + + dbi_base =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!dbi_base) {
arch/arm/mach-spear13xx/pcie.c line 880
Quoted 10 lines
arch/arm/mach-spear13xx/pcie.c new file +10
-0+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 *)dbi_base->start;
dbi_base is a resource here, which refers to a physical address. You cannot cast that to an __iomem token.
arch/arm/mach-spear13xx/pcie.c line 882
Quoted 2 lines
arch/arm/mach-spear13xx/pcie.c new file +2
-0+ pp->va_dbi_base =devm_ioremap (&pdev->dev, dbi_base->start, +resource_size (dbi_base));
Here you even pass that address into ioremap, so it certainly isn't a virtual address
arch/arm/mach-spear13xx/pcie.c line 903
Quoted 1 line
arch/arm/mach-spear13xx/pcie.c new file +1
-0+ pp->phy_base = (void __iomem *)phy_base->start;
same here.
Quoted 4 lines
arch/arm/mach-spear13xx/pcie.c new file +4
-0+ pp->va_phy_base =devm_ioremap (&pdev->dev, phy_base->start, +resource_size (phy_base)); +if (!pp->va_phy_base) { +dev_err (&pdev->dev,"error with ioremap\n" );
arch/arm/mach-spear13xx/pcie.c line 917
Quoted 10 lines
arch/arm/mach-spear13xx/pcie.c new file +10
-0+return -ENOMEM ; + } + + base =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); +if (!base) { +dev_err (&pdev->dev,"couldn't get base resource\n" ); +return -EINVAL ; + } + + pp->base = (void __iomem *)base->start;
and here.
arch/arm/mach-spear13xx/pcie.c line 932
Quoted 8 lines
arch/arm/mach-spear13xx/pcie.c new file +8
-0+ virt_irq_base =irq_alloc_descs (-1 ,0 , num_virt_irqs,0 ); +if (IS_ERR_VALUE (virt_irq_base)) { +dev_err (&pdev->dev,"irq desc alloc failed\n" ); +return -ENXIO ; + } + + irq_domain =irq_domain_add_legacy (np, num_virt_irqs, virt_irq_base, +0 , &irq_domain_simple_ops,NULL );
Why not use a linear domain?
arch/arm/mach-spear13xx/pcie.c line 939
Quoted 1 line
arch/arm/mach-spear13xx/pcie.c new file +1
-0+ pp->virt_irq_base =irq_find_mapping (irq_domain,0 );
Then you can get rid of virt_irq_base and use CONFIG_SPARSE_IRQ.
arch/arm/mach-spear13xx/pcie.c line 948
Quoted 8 lines
arch/arm/mach-spear13xx/pcie.c new file +8
-0+spin_lock_init (&pp->conf_lock); +if (pcie_link_up (pp->va_app_base)) { +dev_info (&pdev->dev,"link up\n" ); + }else { +dev_info (&pdev->dev,"link down\n" ); +pcie_host_init (pp); + pp->va_cfg0_base = devm_ioremap(&pdev->dev, + (resource_size_t)pp->cfg0_base,
cfg0_base is an __iomem token, you cannot pass that into ioremap, which expects a physical address.
arch/arm/mach-spear13xx/pcie.c line 986
Quoted 3 lines
arch/arm/mach-spear13xx/pcie.c new file +3
-0+ pp->config.io_size =IO_SIZE_PER_PORT ; +of_property_read_u32 (np,"pcie-host,is_host" , &pp->config.is_host); +of_property_read_u32 (np,"pcie-host,is_gen1" , &pp->config.is_gen1);
These should probably be derived from the "compatible" value.
arch/arm/mach-spear13xx/pcie.c line 992
Quoted 6 lines
arch/arm/mach-spear13xx/pcie.c new file +6
-0+of_property_read_u32 (np,"pcie-host,cfg0_size" , &pp->config.cfg0_size); +of_property_read_u32 (np,"pcie-host,cfg1_size" , &pp->config.cfg1_size); +of_property_read_u32 (np,"pcie-host,mem_size" , &pp->config.mem_size); +of_property_read_u32 (np,"pcie-host,msg_size" , &pp->config.msg_size); +of_property_read_u32 (np,"pcie-host,in_mem_size" , + &pp->config.in_mem_size);
And these should come from the "ranges" property I suppose.
Arnd
Re: [PATCH 04/15] SPEAr13xx: Add PCIe Root Complex driver support
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · Pratyush Anand
SPEAr13xx has dual mode PCIe controller which can be used as Root Complex as well as Endpoint. This driver supports RC mode of the controller.
If
CONFIG_PCI_MSIis defined then support of MSI interrupt for downstream PCIe devices will be enabled.If
CONFIG_PMis defined then it supports suspend/resume functionality.
Quoted 8 lines
I think I've seen the same hardware before used with another driver. IMHO we should really make sure this does not get duplicated again and move this stuff to a new subdirectory
drivers/pci/host. We don't yet have a completely architecture independent way of defining a PCIe root complex, but we're getting there and given of how many ARM implementations we have, we can just as well start with this one and adapt it to another arch if necesary.
Yes, I too wanted to put it into drivers/pci/host. But, still it would be ARCH (arm) dependent, until we have a common solution for all architecture. Let me know, if I can put it into drivers/pci/host even if it works initially for ARM only.
Quoted 21 lines
Quoted 21 lines
(quoted diff) +21
-0+struct pcie_port { + u8 controller; + u8 root_bus_nr; + void __iomem *dbi_base; + void __iomem *va_dbi_base; + void __iomem *app_base; + void __iomem *va_app_base; + void __iomem *base; + void __iomem *phy_base; + void __iomem *va_phy_base; + void __iomem *cfg0_base; + void __iomem *va_cfg0_base; + void __iomem *cfg1_base; + void __iomem *va_cfg1_base; + void __iomem *mem_base; + void __iomem *io_base; + spinlock_t conf_lock; + char mem_space_name[16]; + char io_space_name[16]; + struct resource res[2]; + struct pcie_port_info config;
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ struct list_head next; + struct clk *clk; + int irq; + int virt_irq_base; + int susp_state; +};Can you explain why you need a total of 13 virtual memory areas?
Ah, its not 13, Its just 5 all va_xxxx.
Probably, I have wrongly put __iomem annotation with physical addresses too. I will correct. Will keep physical address as normal void *.
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +static struct list_head pcie_port_list;I'm pretty sure you don't need your own list of ports, since we already enumerate the ports in the PCI code.
This pcie_port_list is list of private data (struct pcie_port). Callbacks defined in struct hw_pci such as setup, scan etc are called with first argument as controller number. Now other option could have been to use a simple array of struct pcie_port[MAX_PORT_NUM], as other platforms has used. But I thought to keep list as better option, so that we are not dependent on MAX_PORT_NUM.
Quoted 3 lines
Quoted 1 line
+static struct
hw_pcipci;Why is this not statically initialized?
Ok, ll take care in next version.
Quoted 14 lines
Review
Quoted 11 lines
(quoted diff) +10
-0+ snprintf(pp->io_space_name, sizeof(pp->io_space_name), + "PCIe %d I/O", nr); + pp->io_space_name[sizeof(pp->io_space_name) - 1] = 0; + pp->res[1].name = pp->io_space_name; + pp->res[1].start = PCIBIOS_MIN_IO + nr * pp->config.io_size; + pp->res[1].end = pp->res[1].start + (pp->config.io_size - 1); + pp->res[1].flags = IORESOURCE_IO; + if (request_resource(&ioport_resource, &pp->res[1])) + panic("can't allocate PCIe IO space"); + pci_add_resource_offset(&sys->resources, &pp->res[1], sys->io_offset);Is the
io_offsetever nonzero?
Quoted 15 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+void __iomem *spear13xx_pcie_io_base(unsigned long addr) +{ + int controller = (addr - PCIBIOS_MIN_IO) / IO_SIZE_PER_PORT; + struct pcie_port *pp; + + pp = controller_to_port(controller); + + return pp->io_base; +}This function looks completely bogus. Subtracting
PCIBIOS_MIN_IOmeans that everything is shifted by0x1000ports, since secondary bridges don't have this offset. The I/O spaces are just mapped linearly into the virtual address space anyway, so looking up the I/O base like this is pointless.
Frankly speaking, I do not have clear understanding of PCIe IO transaction. I did not test any PCIe device with my host which might need IO resource. Since , my host controller does support IO transaction, I want to support it in driver. Let me explain my requirement, please correct my understanding where I am wrong.
-- I can program one my viewport to generate IO transaction on PCIe bus, if CPU writes between AHB address 0x80000000-0x80007FFF.
-- Now, lets say a PCIe device needs 100 io ports, then address range 0x80000000-0x80000064 will be allocated to this device by pci stack. It will also write 0x80000000 to IO_BAR register of its configuration address space. Now, if my CPU writes at ahb address 0x80000010 then 16th IO port of this device will be written.
-- Probably, I need something like following and it will remove mach/io.h , hence spear13xx_pcie_io_base too.
arch/arm/mach-spear13xx/pcie.c +1 -1
@@ -414,7 +414,7 @@ static int __init pcie_setup(int nr, struct pci_sys_data *sys) pp->res[1 ].flags =IORESOURCE_IO ;if (request_resource (&ioport_resource, &pp->res[1 ]))panic ("can't allocate PCIe IO space" ); -pci_add_resource_offset (&sys->resources, &pp->res[1 ], sys->io_offset); +pci_add_resource_offset (&sys->resources, &pp->res[1 ],0x80000000 );
Quoted 7 lines
Quoted 7 lines
(quoted diff) +7
-0+static void pcie_host_init(struct pcie_port *pp) +{ + struct pcie_port_info *config = &pp->config; + void __iomem *dbi_base = pp->va_dbi_base; + struct pcie_app_reg *app_reg = pp->va_app_base; + u32 exp_cap_off = PCI_CAP_ID_EXP_OFFSET; + u32 val;
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ + /* Keep first 64K for IO */ + pp->io_base = pp->base; + pp->mem_base = pp->io_base + config->io_size; + pp->cfg0_base = pp->mem_base + config->mem_size; + pp->cfg1_base = pp->cfg0_base + config->cfg0_size;Why is the memory space part of the virtual bus address range here?
Sorry, its not virtual address. I will remove __iomem from all physical address pointer.
Quoted 19 lines
Quoted 19 lines
(quoted diff) +17
-0+static int add_pcie_port(struct pcie_port *pp, struct platform_device *pdev) +{ + struct resource *base; + struct resource *dbi_base; + struct resource *phy_base; + int virt_irq_base; + struct device_node *np = pdev->dev.of_node; + struct irq_domain *irq_domain; + int num_virt_irqs = NUM_INTX_IRQS; + + 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; + } + if (!devm_request_mem_region(&pdev->dev, dbi_base->start, + resource_size(dbi_base), pdev->name)) {
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ dev_err(&pdev->dev, "dbi base resource is busy\n"); + return -EBUSY; + } + + pp->dbi_base = (void __iomem *)dbi_base->start;
dbi_baseis a resource here, which refers to a physical address. You cannot cast that to an__iomemtoken.
ok.
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ pp->va_dbi_base = devm_ioremap(&pdev->dev, dbi_base->start, + resource_size(dbi_base));Here you even pass that address into ioremap, so it certainly isn't a virtual address
Yes, I understand it :(
Quoted 33 lines
Review
Quoted 2 lines
(quoted diff) +1
-0+ pp->phy_base = (void __iomem *)phy_base->start;same here.
Quoted 4 lines
(quoted diff) +4
-0+ pp->va_phy_base = devm_ioremap(&pdev->dev, phy_base->start, + resource_size(phy_base)); + if (!pp->va_phy_base) { + dev_err(&pdev->dev, "error with ioremap\n");Review
Quoted 10 lines
(quoted diff) +10
-0+ return -ENOMEM; + } + + base = platform_get_resource(pdev, IORESOURCE_MEM, 1); + if (!base) { + dev_err(&pdev->dev, "couldn't get base resource\n"); + return -EINVAL; + } + + pp->base = (void __iomem *)base->start;and here.
Review
Quoted 8 lines
(quoted diff) +8
-0+ virt_irq_base = irq_alloc_descs(-1, 0, num_virt_irqs, 0); + if (IS_ERR_VALUE(virt_irq_base)) { + dev_err(&pdev->dev, "irq desc alloc failed\n"); + return -ENXIO; + } + + irq_domain = irq_domain_add_legacy(np, num_virt_irqs, virt_irq_base, + 0, &irq_domain_simple_ops, NULL);Why not use a linear domain?
Quoted 3 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ pp->virt_irq_base = irq_find_mapping(irq_domain, 0);Then you can get rid of
virt_irq_baseand useCONFIG_SPARSE_IRQ.
I do not know about. Will explore and implement.
Quoted 12 lines
Review
Quoted 9 lines
(quoted diff) +8
-0+ spin_lock_init(&pp->conf_lock); + if (pcie_link_up(pp->va_app_base)) { + dev_info(&pdev->dev, "link up\n"); + } else { + dev_info(&pdev->dev, "link down\n"); + pcie_host_init(pp); + pp->va_cfg0_base = devm_ioremap(&pdev->dev, + (resource_size_t)pp->cfg0_base,
cfg0_baseis an__iomemtoken, you cannot pass that into ioremap, which expects a physical address.
Again cfg0_base is physical and va_cfg0_base is virtual.
Quoted 6 lines
Review
Quoted 4 lines
(quoted diff) +3
-0+ pp->config.io_size = IO_SIZE_PER_PORT; + of_property_read_u32(np, "pcie-host,is_host", &pp->config.is_host); + of_property_read_u32(np, "pcie-host,is_gen1", &pp->config.is_gen1);These should probably be derived from the "compatible" value.
Yes, about is_host I think, I will go with "compatible".
Let me explain why I have provided is_gen1: There are few buggy PCIe cards which links up only if host is gen1. My host is by default gen2. It does work with gen1 as well as gen2 devices except some buggy gen1 devices. I provided this flag, to force controller to linkup at gen1 only so that it can work with those buggy cards too.
Quoted 9 lines
Review
Quoted 7 lines
(quoted diff) +6
-0+ of_property_read_u32(np, "pcie-host,cfg0_size", &pp->config.cfg0_size); + of_property_read_u32(np, "pcie-host,cfg1_size", &pp->config.cfg1_size); + of_property_read_u32(np, "pcie-host,mem_size", &pp->config.mem_size); + of_property_read_u32(np, "pcie-host,msg_size", &pp->config.msg_size); + of_property_read_u32(np, "pcie-host,in_mem_size", + &pp->config.in_mem_size);And these should come from the "ranges" property I suppose.
Ok..
Regards
Pratyush
PS: Thanks for your valuable inputs :)
Quoted 4 lines
Arnd
.
Re: [PATCH 04/15] SPEAr13xx: Add PCIe Root Complex driver support
Quoted 20 lines · Pratyush Anand
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · Pratyush Anand
SPEAr13xx has dual mode PCIe controller which can be used as Root Complex as well as Endpoint. This driver supports RC mode of the controller.
If
CONFIG_PCI_MSIis defined then support of MSI interrupt for downstream PCIe devices will be enabled.If
CONFIG_PMis defined then it supports suspend/resume functionality.Quoted 8 lines
I think I've seen the same hardware before used with another driver. IMHO we should really make sure this does not get duplicated again and move this stuff to a new subdirectory
drivers/pci/host. We don't yet have a completely architecture independent way of defining a PCIe root complex, but we're getting there and given of how many ARM implementations we have, we can just as well start with this one and adapt it to another arch if necesary.
Quoted 4 lines
Yes, I too wanted to put it into
drivers/pci/host. But, still it would be ARCH (arm) dependent, until we have a common solution for all architecture. Let me know, if I can put it intodrivers/pci/hosteven if it works initially for ARM only.
This is ultimately up to Bjorn Helgaas as the PCI maintainer. I think everybody would prefer to have an architecture independent interface between PCI hosts and platform specific code, and we are progressing towards that goal. I think it would be worthwhile to have this code already in drivers/pci while it's still ARM specific, and then remove the ARM bits over time by replacing them with generic interfaces as we get there.
Quoted 32 lines
Quoted 22 lines
Quoted 22 lines
(quoted diff) +21
-0+struct pcie_port { + u8 controller; + u8 root_bus_nr; + void __iomem *dbi_base; + void __iomem *va_dbi_base; + void __iomem *app_base; + void __iomem *va_app_base; + void __iomem *base; + void __iomem *phy_base; + void __iomem *va_phy_base; + void __iomem *cfg0_base; + void __iomem *va_cfg0_base; + void __iomem *cfg1_base; + void __iomem *va_cfg1_base; + void __iomem *mem_base; + void __iomem *io_base; + spinlock_t conf_lock; + char mem_space_name[16]; + char io_space_name[16]; + struct resource res[2]; + struct pcie_port_info config;Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ struct list_head next; + struct clk *clk; + int irq; + int virt_irq_base; + int susp_state; +};Can you explain why you need a total of 13 virtual memory areas?
Quoted 3 lines
Ah, its not 13, Its just 5 all
va_xxxx.
Probably, I have wrongly put__iomemannotation with physical addresses too. I will correct. Will keep physical address as normal void *.
Physical addresses should not be pointers at all, but they should be phys_addr_t. If you have a system with LPAE enabled, the physical address space may be 64 bit long, so pointers don't work on that.
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
+static struct
list_headpcie_port_list;I'm pretty sure you don't need your own list of ports, since we already enumerate the ports in the PCI code.
Quoted 6 lines
This
pcie_port_listis list of private data (structpcie_port). Callbacks defined in structhw_pcisuch as setup, scan etc are called with first argument as controller number. Now other option could have been to use a simple array of struct pcie_port[MAX_PORT_NUM], as other platforms has used. But I thought to keep list as better option, so that we are not dependent onMAX_PORT_NUM.
A list is indeed better than a static array. However, the preferred way to do kernel code is to not have any such global lists in a device driver at all, but keep it inside of the subsystems. I don't remember how this is done for PCIe ports, but I would assume that you can iterate over them already. If not, it would be nice to add this feature to the PCI subsystem so that nobody has to keep arrays or lists like this.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
+static struct
hw_pcipci;Why is this not statically initialized?
Ok, ll take care in next version.
I noticed later that it does get statically initialized below, so my comment wasn't actually correct. However, you should try to order the symbols so that you don't need forward declarations.
Quoted 12 lines
Quoted 5 lines
This function looks completely bogus. Subtracting
PCIBIOS_MIN_IOmeans that everything is shifted by0x1000ports, since secondary bridges don't have this offset. The I/O spaces are just mapped linearly into the virtual address space anyway, so looking up the I/O base like this is pointless.Frankly speaking, I do not have clear understanding of PCIe IO transaction. I did not test any PCIe device with my host which might need IO resource. Since , my host controller does support IO transaction, I want to support it in driver. Let me explain my requirement, please correct my understanding where I am wrong.
Quoted 8 lines
-- I can program one my viewport to generate IO transaction on PCIe bus, if CPU writes between AHB address 0x80000000-0x80007FFF.
-- Now, lets say a PCIe device needs 100 io ports, then address range 0x80000000-0x80000064 will be allocated to this device by pci stack. It will also write
0x80000000toIO_BARregister of its configuration address space. Now, if my CPU writes at ahb address0x80000010then 16th IO port of this device will be written.
The number space for I/O ports is usually 16 bits, which is a hardware limitation on x86. Practically all PCI implementations on non-x86 architecture have the I/O access directly mapped into the physical address space, like you have at phys address 0x80000000. However, the port number for the first port in there is still "0", not "0x80000000", and the I/O window in you PCI host registers should be set up so that an access to address 0x80000000 gets translated into a I/O transfer at address 0 on the PCI bus. This is different from the memory window, which is typically set up so that the physical addresses are the same as the bus address in PCI memory space accesses.
arch/arm/mach-spear13xx/pcie.c static int __init pcie_setup(int nr, struct · line 419
Quoted 13 lines
-- Probably, I need something like following and it will remove
mach/io.h, hencespear13xx_pcie_io_basetoo.arch/arm/mach-spear13xx/pcie.c +1
-1@@ -414,7 +414,7 @@ static int __init pcie_setup(int nr, struct pci_sys_data *sys) pp->res[1].flags = IORESOURCE_IO;if (request_resource (&ioport_resource, &pp->res[1 ]))panic ("can't allocate PCIe IO space" ); -pci_add_resource_offset (&sys->resources, &pp->res[1 ], sys->io_offset); +pci_add_resource_offset (&sys->resources, &pp->res[1 ],0x80000000 );
The io_offset should be zero on all modern implementations, we just have a few legacy cases that we carry around mostly because of interactions with older PCMCIA drivers that can get fixed over time.
If you have multiple root buses, you can choose to make the offset for the second bus 0x10000.
Quoted 16 lines
arch/arm/mach-spear13xx/pcie.c +0
-0>> +static void pcie_host_init(struct pcie_port *pp)Quoted 6 lines
Quoted 6 lines
(quoted diff) +6
-0+{ + struct pcie_port_info *config = &pp->config; + void __iomem *dbi_base = pp->va_dbi_base; + struct pcie_app_reg *app_reg = pp->va_app_base; + u32 exp_cap_off = PCI_CAP_ID_EXP_OFFSET; + u32 val;Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ + /* Keep first 64K for IO */ + pp->io_base = pp->base; + pp->mem_base = pp->io_base + config->io_size; + pp->cfg0_base = pp->mem_base + config->mem_size; + pp->cfg1_base = pp->cfg0_base + config->cfg0_size;Why is the memory space part of the virtual bus address range here?
Quoted 2 lines
Sorry, its not virtual address. I will remove
__iomemfrom all physical address pointer.
Ok. I suspect that you don't actually need to store the physicall address then, because it's not needed after setting up the devices, and you can easily retrieve it from the resources.
Quoted 6 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ pp->config.io_size = IO_SIZE_PER_PORT; + of_property_read_u32(np, "pcie-host,is_host", &pp->config.is_host); + of_property_read_u32(np, "pcie-host,is_gen1", &pp->config.is_gen1);These should probably be derived from the "compatible" value.
Quoted 7 lines
Yes, about
is_hostI think, I will go with "compatible".Let me explain why I have provided
is_gen1: There are few buggy PCIe cards which links up only if host is gen1. My host is by default gen2. It does work with gen1 as well as gen2 devices except some buggy gen1 devices. I provided this flag, to force controller to linkup at gen1 only so that it can work with those buggy cards too.
Ok, makes sense.
Thanks for the quick replies. I hope I managed to explain the I/O space accesses now.
Arnd
Re: [PATCH 04/15] SPEAr13xx: Add PCIe Root Complex driver support
Quoted 2 lines · Arnd Bergmann
Thanks for the quick replies. I hope I managed to explain the I/O space accesses now.
Yes, I understood now :)
Also looked into pci_ioremap_io. Things are clear now.
Will send V2 after incorporating all comments.
Regards
Pratyush
PATCH 5/15 clk: SPEAr1340: Fix pcie0 clock name
In reply to Pratyush Anand--- drivers/clk/spear/spear1340_clock.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/clk/spear/spear1340_clock.c +1 -1
@@ -844,7 +844,7 @@ void __init spear1340_clk_init(void) clk =clk_register_gate (NULL ,"pcie_sata_clk" ,"ahb_clk" ,0 ,SPEAR1340_PERIP1_CLK_ENB ,SPEAR1340_PCIE_SATA_CLK_ENB ,0 , &_lock); -clk_register_clkdev (clk,NULL ,"dw_pcie" ); +clk_register_clkdev (clk,NULL ,"b1000000.pcie0" );clk_register_clkdev (clk,NULL ,"b1000000.ahci" ); clk = clk_register_gate(NULL, "sysram0_clk", "ahb_clk", 0,
Signature · 1 line
1.7.5.4
PATCH 6/15 clk: SPEAr1310: Fix pcie clock name
In reply to Pratyush Anand--- drivers/clk/spear/spear1310_clock.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/clk/spear/spear1310_clock.c +3 -3
@@ -733,19 +733,19 @@ void __init spear1310_clk_init(void) clk =clk_register_gate (NULL ,"pcie_sata_0_clk" ,"ahb_clk" ,0 ,SPEAR1310_PERIP1_CLK_ENB ,SPEAR1310_PCIE_SATA_0_CLK_ENB ,0 , &_lock); -clk_register_clkdev (clk,NULL ,"dw_pcie.0" ); +clk_register_clkdev (clk,NULL ,"b1000000.pcie0" );clk_register_clkdev (clk,NULL ,"b1000000.ahci" ); clk =clk_register_gate (NULL ,"pcie_sata_1_clk" ,"ahb_clk" ,0 ,SPEAR1310_PERIP1_CLK_ENB ,SPEAR1310_PCIE_SATA_1_CLK_ENB ,0 , &_lock); -clk_register_clkdev (clk,NULL ,"dw_pcie.1" ); +clk_register_clkdev (clk,NULL ,"b1800000.pcie1" );clk_register_clkdev (clk,NULL ,"b1800000.ahci" ); clk =clk_register_gate (NULL ,"pcie_sata_2_clk" ,"ahb_clk" ,0 ,SPEAR1310_PERIP1_CLK_ENB ,SPEAR1310_PCIE_SATA_2_CLK_ENB ,0 , &_lock); -clk_register_clkdev (clk,NULL ,"dw_pcie.2" ); +clk_register_clkdev (clk,NULL ,"b4000000.pcie2" );clk_register_clkdev (clk,NULL ,"b4000000.ahci" ); clk = clk_register_gate(NULL, "sysram0_clk", "ahb_clk", 0,
Signature · 1 line
1.7.5.4
Re: [PATCH 06/15] clk: SPEAr1310: Fix pcie clock name
Quoted 4 lines · Pratyush Anand
Signed-off-by Pratyush Anand <[email protected]>--- drivers/clk/spear/spear1310_clock.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
It is not required, that you send one patch per file. If two changes to two files are having the same purpose, then merge them.
Merge this with 5/15.
PATCH 7/15 SPEAr1340: Add PCIe auxdata for miphy clock initialization
In reply to Pratyush AnandMiphy Clock initialization is very specific to controller and its instances. Pass this custom function using auxdata.
--- arch/arm/mach-spear13xx/spear1340.c | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-)
arch/arm/mach-spear13xx/spear1340.c +26 -0
@@ -29,6 +29,7 @@#include <asm/mach/arch.h> #include <mach/dma.h> #include <mach/generic.h> +#include <mach/pcie.h> #include <mach/spdif.h> #include <mach/spear.h> #include <sound/designware_i2s.h>
@@ -42,6 +43,7 @@#define SPEAR1340_CAM2_BASE UL(0xD0400000)#define SPEAR1340_CAM3_BASE UL(0xD0500000)#define SPEAR1340_SATA_BASE UL(0xB1000000) +#define SPEAR1340_PCIE_BASE UL(0xB1000000)#define SPEAR1340_UART1_BASE UL(0xB4100000)#define SPEAR1340_I2S_PLAY_BASE UL(0xB2400000)#define SPEAR1340_I2S_REC_BASE UL(0xB2000000)
@@ -358,6 +360,28 @@ static struct ahci_platform_data sata_pdata = { .resume = sata_resume, }; +static int spear1340_pcie_clk_init (struct pcie_port *pp) +{ +writel (SPEAR1340_PCIE_SATA_MIPHY_CFG_PCIE , +SPEAR1340_PCIE_MIPHY_CFG ); +writel (SPEAR1340_PCIE_CFG_VAL ,SPEAR1340_PCIE_SATA_CFG ); + +return 0 ; +} + +static int spear1340_pcie_clk_exit (struct pcie_port *pp) +{ +writel (0 ,SPEAR1340_PCIE_SATA_CFG ); +writel (0 ,SPEAR1340_PCIE_MIPHY_CFG ); + +return 0 ; +} + +static struct pcie_port_info pcie_pdata = { + .clk_init = spear1340_pcie_clk_init, + .clk_exit = spear1340_pcie_clk_exit, +}; +/* camera sensor registeration */ static struct i2c_board_info vs6725_camera_sensor_info = {I2C_BOARD_INFO ("vs6725" ,0x10 ),
@@ -609,6 +633,8 @@ static struct of_dev_auxdata spear1340_auxdata_lookup[] __initdata = {OF_DEV_AUXDATA ("snps,spear-ahci" ,SPEAR1340_SATA_BASE ,NULL , &sata_pdata), +OF_DEV_AUXDATA ("st,pcie-host" ,SPEAR1340_PCIE_BASE ,NULL , + &pcie_pdata),OF_DEV_AUXDATA ("arm,pl011" ,SPEAR1340_UART1_BASE ,NULL , &uart1_data),OF_DEV_AUXDATA ("st,spear600-gmac" ,SPEAR13XX_GETH_BASE ,NULL , ð_data),
Signature · 1 line
1.7.5.4
PATCH 8/15 SPEAr1310: Add PCIe auxdata for miphy clock initialization
In reply to Pratyush AnandMiphy Clock initialization is very specific to controller and its instances. Pass this custom function using auxdata.
--- arch/arm/mach-spear13xx/spear1310.c | 148 +++++++++++++++++++++++++++++++++++ 1 files changed, 148 insertions(+), 0 deletions(-)
arch/arm/mach-spear13xx/spear1310.c +148 -0
@@ -24,6 +24,7 @@#include <asm/mach/arch.h> #include <asm/mach/map.h> #include <mach/generic.h> +#include <mach/pcie.h> #include <mach/spear.h> /* Base addresses */
@@ -35,6 +36,9 @@#define SPEAR1310_SATA0_BASE UL(0xB1000000)#define SPEAR1310_SATA1_BASE UL(0xB1800000)#define SPEAR1310_SATA2_BASE UL(0xB4000000) +#define SPEAR1310_PCIE0_BASE UL(0xB1000000) +#define SPEAR1310_PCIE1_BASE UL(0xB1800000) +#define SPEAR1310_PCIE2_BASE UL(0xB4000000)/* RAS Area Control Register */ #define VA_SPEAR1310_RAS_CTRL_REG1 (VA_SPEAR1310_RAS_BASE + 0x4)
@@ -57,6 +61,81 @@#define SPEAR1310_PERIP1_SW_RST (VA_MISC_BASE + 0x308)#define SPEAR1310_UOC_RST_ENB 11 +#define VA_SPEAR1310_PCIE_SATA_CFG (VA_MISC_BASE + 0x3A4) +/* PCIE CFG MASks */ +#define SPEAR1310_PCIE_SATA2_SEL_PCIE (0 << 31) +#define SPEAR1310_PCIE_SATA1_SEL_PCIE (0 << 30) +#define SPEAR1310_PCIE_SATA0_SEL_PCIE (0 << 29) +#define SPEAR1310_PCIE_SATA2_SEL_SATA (1 << 31) +#define SPEAR1310_PCIE_SATA1_SEL_SATA (1 << 30) +#define SPEAR1310_PCIE_SATA0_SEL_SATA (1 << 29) +#define SPEAR1310_SATA2_CFG_TX_CLK_EN (1 << 27) +#define SPEAR1310_SATA2_CFG_RX_CLK_EN (1 << 26) +#define SPEAR1310_SATA2_CFG_POWERUP_RESET (1 << 25) +#define SPEAR1310_SATA2_CFG_PM_CLK_EN (1 << 24) +#define SPEAR1310_SATA1_CFG_TX_CLK_EN (1 << 23) +#define SPEAR1310_SATA1_CFG_RX_CLK_EN (1 << 22) +#define SPEAR1310_SATA1_CFG_POWERUP_RESET (1 << 21) +#define SPEAR1310_SATA1_CFG_PM_CLK_EN (1 << 20) +#define SPEAR1310_SATA0_CFG_TX_CLK_EN (1 << 19) +#define SPEAR1310_SATA0_CFG_RX_CLK_EN (1 << 18) +#define SPEAR1310_SATA0_CFG_POWERUP_RESET (1 << 17) +#define SPEAR1310_SATA0_CFG_PM_CLK_EN (1 << 16) +#define SPEAR1310_PCIE2_CFG_DEVICE_PRESENT (1 << 11) +#define SPEAR1310_PCIE2_CFG_POWERUP_RESET (1 << 10) +#define SPEAR1310_PCIE2_CFG_CORE_CLK_EN (1 << 9) +#define SPEAR1310_PCIE2_CFG_AUX_CLK_EN (1 << 8) +#define SPEAR1310_PCIE1_CFG_DEVICE_PRESENT (1 << 7) +#define SPEAR1310_PCIE1_CFG_POWERUP_RESET (1 << 6) +#define SPEAR1310_PCIE1_CFG_CORE_CLK_EN (1 << 5) +#define SPEAR1310_PCIE1_CFG_AUX_CLK_EN (1 << 4) +#define SPEAR1310_PCIE0_CFG_DEVICE_PRESENT (1 << 3) +#define SPEAR1310_PCIE0_CFG_POWERUP_RESET (1 << 2) +#define SPEAR1310_PCIE0_CFG_CORE_CLK_EN (1 << 1) +#define SPEAR1310_PCIE0_CFG_AUX_CLK_EN (1 << 0) + +#define SPEAR1310_PCIE_CFG_MASK (x) ((0xF << (x * 4)) | (1 << (x + 29))) +#define SPEAR1310_SATA_CFG_MASK (x) ((0xF << (x * 4 + 16)) | \ + (1 << (x + 29))) +#define SPEAR1310_PCIE_CFG_VAL (x) \ + (SPEAR1310_PCIE_SATA##x##_SEL_PCIE | \ + SPEAR1310_PCIE##x##_CFG_AUX_CLK_EN | \ + SPEAR1310_PCIE##x##_CFG_CORE_CLK_EN | \ + SPEAR1310_PCIE##x##_CFG_POWERUP_RESET | \ + SPEAR1310_PCIE##x##_CFG_DEVICE_PRESENT) +#define SPEAR1310_SATA_CFG_VAL (x) \ + (SPEAR1310_PCIE_SATA##x##_SEL_SATA | \ + SPEAR1310_SATA##x##_CFG_PM_CLK_EN | \ + SPEAR1310_SATA##x##_CFG_POWERUP_RESET | \ + SPEAR1310_SATA##x##_CFG_RX_CLK_EN | \ + SPEAR1310_SATA##x##_CFG_TX_CLK_EN) + +#define VA_SPEAR1310_PCIE_MIPHY_CFG_1 (VA_MISC_BASE + 0x3A8) +#define SPEAR1310_MIPHY_DUAL_OSC_BYPASS_EXT (1 << 31) +#define SPEAR1310_MIPHY_DUAL_CLK_REF_DIV2 (1 << 28) +#define SPEAR1310_MIPHY_DUAL_PLL_RATIO_TOP (x) (x << 16) +#define SPEAR1310_MIPHY_SINGLE_OSC_BYPASS_EXT (1 << 15) +#define SPEAR1310_MIPHY_SINGLE_CLK_REF_DIV2 (1 << 12) +#define SPEAR1310_MIPHY_SINGLE_PLL_RATIO_TOP (x) (x << 0) +#define SPEAR1310_PCIE_SATA_MIPHY_CFG_SATA_MASK (0xFFFF) +#define SPEAR1310_PCIE_SATA_MIPHY_CFG_PCIE_MASK (0xFFFF << 16) +#define SPEAR1310_PCIE_SATA_MIPHY_CFG_SATA \ + (SPEAR1310_MIPHY_DUAL_OSC_BYPASS_EXT | \ + SPEAR1310_MIPHY_DUAL_CLK_REF_DIV2 | \ + SPEAR1310_MIPHY_DUAL_PLL_RATIO_TOP(60) | \ + SPEAR1310_MIPHY_SINGLE_OSC_BYPASS_EXT | \ + SPEAR1310_MIPHY_SINGLE_CLK_REF_DIV2 | \ + SPEAR1310_MIPHY_SINGLE_PLL_RATIO_TOP(60)) +#define SPEAR1310_PCIE_SATA_MIPHY_CFG_SATA_25M_CRYSTAL_CLK \ + (SPEAR1310_MIPHY_SINGLE_PLL_RATIO_TOP(120)) +#define SPEAR1310_PCIE_SATA_MIPHY_CFG_PCIE \ + (SPEAR1310_MIPHY_DUAL_OSC_BYPASS_EXT | \ + SPEAR1310_MIPHY_DUAL_PLL_RATIO_TOP(25) | \ + SPEAR1310_MIPHY_SINGLE_OSC_BYPASS_EXT | \ + SPEAR1310_MIPHY_SINGLE_PLL_RATIO_TOP(25)) + +#define VA_SPEAR1310_PCIE_MIPHY_CFG_2 (VA_MISC_BASE + 0x3AC) +static int spear1310_eth_phy_clk_cfg (struct platform_device *pdev) {struct plat_stmmacenet_data *pdata =dev_get_platdata (&pdev->dev);
@@ -342,6 +421,69 @@ static struct dwc_otg_plat_data spear1310_otg_plat_data = { .phy_init = spear1310_otg_phy_init, }; +static int spear1310_pcie_clk_init (struct pcie_port *pp) +{ +u32 temp; + + temp =readl (VA_SPEAR1310_PCIE_MIPHY_CFG_1 ); + temp &= ~SPEAR1310_PCIE_SATA_MIPHY_CFG_PCIE_MASK ; + temp |=SPEAR1310_PCIE_SATA_MIPHY_CFG_PCIE ; + +writel (temp,VA_SPEAR1310_PCIE_MIPHY_CFG_1 ); + + temp =readl (VA_SPEAR1310_PCIE_SATA_CFG ); + +switch (pp->controller) { +case 0 : + temp &= ~SPEAR1310_PCIE_CFG_MASK (0 ); + temp |=SPEAR1310_PCIE_CFG_VAL (0 ); +break ; +case 1 : + temp &= ~SPEAR1310_PCIE_CFG_MASK (1 ); + temp |=SPEAR1310_PCIE_CFG_VAL (1 ); +break ; +case 2 : + temp &= ~SPEAR1310_PCIE_CFG_MASK (2 ); + temp |=SPEAR1310_PCIE_CFG_VAL (2 ); +break ; +default : +return -EINVAL ; + } +writel (temp,VA_SPEAR1310_PCIE_SATA_CFG ); + +return 0 ; +} + +static int spear1310_pcie_clk_exit (struct pcie_port *pp) +{ +u32 temp; + + temp =readl (VA_SPEAR1310_PCIE_SATA_CFG ); + +switch (pp->controller) { +case 0 : + temp &= ~SPEAR1310_PCIE_CFG_MASK (0 ); +break ; +case 1 : + temp &= ~SPEAR1310_PCIE_CFG_MASK (1 ); +break ; +case 2 : + temp &= ~SPEAR1310_PCIE_CFG_MASK (2 ); +break ; + } + +writel (temp,VA_SPEAR1310_PCIE_SATA_CFG ); +writel (~SPEAR1310_PCIE_SATA_MIPHY_CFG_PCIE_MASK , +VA_SPEAR1310_PCIE_MIPHY_CFG_1 ); + +return 0 ; +} + +static struct pcie_port_info pcie_pdata = { + .clk_init = spear1310_pcie_clk_init, + .clk_exit = spear1310_pcie_clk_exit, +}; +/* Add SPEAr1310 auxdata to pass platform data */ static struct of_dev_auxdata spear1310_auxdata_lookup[]__initdata = {OF_DEV_AUXDATA ("st,spear-adc" ,SPEAR13XX_ADC_BASE ,NULL , &adc_pdata),
@@ -363,6 +505,12 @@ static struct of_dev_auxdata spear1310_auxdata_lookup[] __initdata = { ð4_data),OF_DEV_AUXDATA ("snps,usb-otg" ,SPEAR_UOC_BASE ,NULL , &spear1310_otg_plat_data), +OF_DEV_AUXDATA ("st,pcie-host" ,SPEAR1310_PCIE0_BASE ,NULL , + &pcie_pdata), +OF_DEV_AUXDATA ("st,pcie-host" ,SPEAR1310_PCIE1_BASE ,NULL , + &pcie_pdata), +OF_DEV_AUXDATA ("st,pcie-host" ,SPEAR1310_PCIE2_BASE ,NULL , + &pcie_pdata),OF_DEV_AUXDATA ("st,db9000-clcd" ,SPEAR13XX_CLCD_BASE ,NULL , &clcd_plat_info), {}
Signature · 1 line
1.7.5.4
Re: [PATCH 08/15] SPEAr1310: Add PCIe auxdata for miphy clock initialization
Quoted 7 lines · Pratyush Anand
Miphy Clock initialization is very specific to controller and its instances. Pass this custom function using auxdata.
Signed-off-by Pratyush Anand <[email protected]>--- arch/arm/mach-spear13xx/spear1310.c | 148 +++++++++++++++++++++++++++++++++++ 1 files changed, 148 insertions(+), 0 deletions(-)
I think you shouldn't have this in platform code. I don't have the full picture here but it looks like it could be a separate clock driver so you can use the regular clock functions. Platform data with callbacks is not acceptable here.
Arnd
PATCH 9/15 SPEAr13xx: dts: Fix PCIe core address ranges
In reply to Pratyush AnandEach PCIe controller has 256 MB of address space whcih is accessible by AHB and used to communicate with PCIe devices connected with the host controller.
--- arch/arm/boot/dts/spear13xx.dtsi | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
arch/arm/boot/dts/spear13xx.dtsi +5 -4
@@ -76,7 +76,8 @@ #size-cells = <1>; compatible = "simple-bus"; ranges = <0x50000000 0x50000000 0x10000000 - 0xb0000000 0xb0000000 0x10000000 + 0x80000000 0x80000000 0x20000000 + 0xb0000000 0xb0000000 0x20000000 0xd0000000 0xd0000000 0x02000000 0xd8000000 0xd8000000 0x01000000 0xe0000000 0xe0000000 0x10000000>;
@@ -194,7 +195,7 @@ pcie0@b1000000 { compatible = "st,pcie-gadget", "st,pcie-host" ; reg = < 0xb1000000 0x4000 - 0x80000000 0x2000 + 0x80000000 0x10000000 0xeb800000 0x1000 >; interrupts = <0 68 0x4>; status = "disabled";
@@ -203,7 +204,7 @@ pcie1@b1800000 { compatible = "st,pcie-gadget", "st,pcie-host" ; reg = < 0xb1800000 0x4000 - 0x90000000 0x2000 + 0x90000000 0x10000000 0xeb804000 0x1000 >; interrupts = <0 69 0x4>; status = "disabled";
@@ -212,7 +213,7 @@ pcie2@b4000000 { compatible = "st,pcie-gadget", "st,pcie-host" ; reg = < 0xb4000000 0x4000 - 0xc0000000 0x2000 + 0xc0000000 0x10000000 0xeb808000 0x1000 >; interrupts = <0 70 0x4>; status = "disabled";
Signature · 1 line
1.7.5.4
Re: [PATCH 09/15] SPEAr13xx: dts: Fix PCIe core address ranges
Quoted 3 lines · Pratyush Anand
Each PCIe controller has 256 MB of address space whcih is accessible by AHB and used to communicate with PCIe devices connected with the host controller.
you haven't said what you have done here in this patch. i.e. extend AHB range to include pcie space.
Quoted 20 lines
Signed-off-by Pratyush Anand <[email protected]>--- arch/arm/boot/dts/spear13xx.dtsi | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)arch/arm/boot/dts/spear13xx.dtsi +2
-1@@ -76,7 +76,8 @@ #size-cells = <1>; compatible = "simple-bus"; ranges = <0x50000000 0x50000000 0x10000000 - 0xb0000000 0xb0000000 0x10000000 + 0x80000000 0x80000000 0x20000000 + 0xb0000000 0xb0000000 0x20000000 0xd0000000 0xd0000000 0x02000000 0xd8000000 0xd8000000 0x01000000 0xe0000000 0xe0000000 0x10000000>;
arch/arm/boot/dts/spear13xx.dtsi line 201
Quoted 8 lines
arch/arm/boot/dts/spear13xx.dtsi +1
-1@@ -194,7 +195,7 @@ pcie0@b1000000 { compatible = "st,pcie-gadget", "st,pcie-host" ; reg = < 0xb1000000 0x4000 - 0x80000000 0x2000 + 0x80000000 0x10000000 0xeb800000 0x1000 >; interrupts = <0 68 0x4>; status = "disabled";
That's a blunder. I am damn sure, you haven't rebased it on any rc. And you have rebased it on your local next.
There is no pci support in upstream kernel.
--
viresh
Re: [PATCH 09/15] SPEAr13xx: dts: Fix PCIe core address ranges
Quoted 31 lines · viresh kumar
Quoted 3 lines · Pratyush Anand
Each PCIe controller has 256 MB of address space whcih is accessible by AHB and used to communicate with PCIe devices connected with the host controller.
you haven't said what you have done here in this patch. i.e. extend AHB range to include pcie space.
Quoted 23 lines
Signed-off-by Pratyush Anand <[email protected]>--- arch/arm/boot/dts/spear13xx.dtsi | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)arch/arm/boot/dts/spear13xx.dtsi +2
-1@@ -76,7 +76,8 @@ #size-cells = <1>; compatible = "simple-bus"; ranges = <0x50000000 0x50000000 0x10000000 - 0xb0000000 0xb0000000 0x10000000 + 0x80000000 0x80000000 0x20000000 + 0xb0000000 0xb0000000 0x20000000 0xd0000000 0xd0000000 0x02000000 0xd8000000 0xd8000000 0x01000000 0xe0000000 0xe0000000 0x10000000>;@@ -194,7 +195,7 @@ pcie0@b1000000 { compatible = "st,pcie-gadget", "st,pcie-host" ; reg = < 0xb1000000 0x4000
Quoted 9 lines
arch/arm/boot/dts/spear13xx.dtsi line 201
Quoted 5 lines
arch/arm/boot/dts/spear13xx.dtsi +1
-1- 0x80000000 0x2000 + 0x80000000 0x10000000 0xeb800000 0x1000 >; interrupts = <0 68 0x4>; status = "disabled";That's a blunder. I am damn sure, you haven't rebased it on any rc. And you have rebased it on your local next.
Yes, I re-based it with next of ST's repo. :(
Quoted 1 line
There is no pci support in upstream kernel.
I will send a v2 after rebasing with mainline content.
Quoted 5 lines
--
viresh
.
Re: [PATCH 09/15] SPEAr13xx: dts: Fix PCIe core address ranges
In reply to Pratyush AnandQuoted 24 lines · Pratyush Anand
sible by
AHB and used to communicate with PCIe devices connected with the host controller.Signed-off-by Pratyush Anand <[email protected]>--- arch/arm/boot/dts/spear13xx.dtsi | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)arch/arm/boot/dts/spear13xx.dtsi +2
-1@@ -76,7 +76,8 @@ #size-cells = <1>; compatible = "simple-bus"; ranges = <0x50000000 0x50000000 0x10000000 - 0xb0000000 0xb0000000 0x10000000 + 0x80000000 0x80000000 0x20000000 + 0xb0000000 0xb0000000 0x20000000 0xd0000000 0xd0000000 0x02000000 0xd8000000 0xd8000000 0x01000000 0xe0000000 0xe0000000 0x10000000>;
arch/arm/boot/dts/spear13xx.dtsi line 201
Quoted 8 lines
arch/arm/boot/dts/spear13xx.dtsi +1
-1@@ -194,7 +195,7 @@ pcie0@b1000000 { compatible = "st,pcie-gadget", "st,pcie-host" ; reg = < 0xb1000000 0x4000 - 0x80000000 0x2000 + 0x80000000 0x10000000 0xeb800000 0x1000 >; interrupts = <0 68 0x4>; status = "disabled";
The code that I'm looking at in the upstream kernel looks very different, so I don't see how this patch would apply. Also, the version that you are patching as well as the changes you do don't actually follow the generic PCI bindings at all and should be done quite differently.
Please have a look at how to configure the PCI ranges in the IEEE1275 PCI bindings and in examples you find in arch/powerpc/.
Most importantly, the compatible string used here can't really refer to both the host and the endpoint mode, you really need separate bindings for those and have only one of the two used in a particular system. What you can do is to put both into the dtsi file and mark them as "disabled" and then enable just one of the two on a given board file.
Arnd
Re: [PATCH 09/15] SPEAr13xx: dts: Fix PCIe core address ranges
Quoted 30 lines · Arnd Bergmann
Quoted 29 lines · Pratyush Anand
sible by
AHB and used to communicate with PCIe devices connected with the host controller.Signed-off-by Pratyush Anand <[email protected]>--- arch/arm/boot/dts/spear13xx.dtsi | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)arch/arm/boot/dts/spear13xx.dtsi +3
-2@@ -76,7 +76,8 @@ #size-cells = <1>; compatible = "simple-bus"; ranges = <0x50000000 0x50000000 0x10000000 - 0xb0000000 0xb0000000 0x10000000 + 0x80000000 0x80000000 0x20000000 + 0xb0000000 0xb0000000 0x20000000 0xd0000000 0xd0000000 0x02000000 0xd8000000 0xd8000000 0x01000000 0xe0000000 0xe0000000 0x10000000>;@@ -194,7 +195,7 @@ pcie0@b1000000 { compatible = "st,pcie-gadget", "st,pcie-host" ; reg = < 0xb1000000 0x4000 - 0x80000000 0x2000 + 0x80000000 0x10000000
Quoted 9 lines
arch/arm/boot/dts/spear13xx.dtsi line 201
Quoted 3 lines
arch/arm/boot/dts/spear13xx.dtsi +0
-00xeb800000 0x1000 >; interrupts = <0 68 0x4>; status = "disabled";The code that I'm looking at in the upstream kernel looks very different, so I don't see how this patch would apply. Also, the version that you are patching as well as the changes you do don't actually follow the generic PCI bindings at all and should be done quite differently.
Yes, this was my mistake. I rebased with ST repo. Will send V2 with correct rebase.
Quoted 3 lines
Please have a look at how to configure the PCI ranges in the IEEE1275 PCI bindings and in examples you find in
arch/powerpc/.
Will look into.
Quoted 5 lines
Most importantly, the compatible string used here can't really refer to both the host and the endpoint mode, you really need separate bindings for those and have only one of the two used in a particular system. What you can do is to put both into the dtsi file and mark them as "disabled" and then enable just one of the two on a given board file.
Yes, we had though of this limitation and had decided to do exactly the same way you have suggested.
thanks for your review comments.
Regards
Pratyush
Quoted 4 lines
Arnd
.
PATCH 10/15 SPEAr13xx: DTS: Add auxiliary data for PCIe host
In reply to Pratyush Anand--- arch/arm/boot/dts/spear13xx.dtsi | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-)
arch/arm/boot/dts/spear13xx.dtsi +24 -0
@@ -199,6 +199,14 @@ 0xeb800000 0x1000 >; interrupts = <0 68 0x4>; status = "disabled"; + pcie-host,is_host = <1>; + pcie-host,is_gen1 = <0>; + pcie-host,cfg0_size = <0x100000>; + pcie-host,cfg1_size = <0x100000>; + pcie-host,mem_size = <0xFC00000>; + pcie-host,msg_size = <0x100000>; + /* Entire DDR Area */ + pcie-host,in_mem_size = <0x80000000>; }; pcie1@b1800000 {
@@ -208,6 +216,14 @@ 0xeb804000 0x1000 >; interrupts = <0 69 0x4>; status = "disabled"; + pcie-host,is_host = <1>; + pcie-host,is_gen1 = <0>; + pcie-host,cfg0_size = <0x100000>; + pcie-host,cfg1_size = <0x100000>; + pcie-host,mem_size = <0xFC00000>; + pcie-host,msg_size = <0x100000>; + /* Entire DDR Area */ + pcie-host,in_mem_size = <0x80000000>; }; pcie2@b4000000 {
@@ -217,6 +233,14 @@ 0xeb808000 0x1000 >; interrupts = <0 70 0x4>; status = "disabled"; + pcie-host,is_host = <1>; + pcie-host,is_gen1 = <0>; + pcie-host,cfg0_size = <0x100000>; + pcie-host,cfg1_size = <0x100000>; + pcie-host,mem_size = <0xFC00000>; + pcie-host,msg_size = <0x100000>; + /* Entire DDR Area */ + pcie-host,in_mem_size = <0x80000000>; }; c3@e1800000 {
Signature · 1 line
1.7.5.4
Re: [PATCH 10/15] SPEAr13xx: DTS: Add auxiliary data for PCIe host
Quoted 2 lines · Pratyush Anand
Signed-off-by Pratyush Anand <[email protected]>---
Please add commit log in each and every message.
What do you mean by auxiliary data in subject?
Re: [PATCH 10/15] SPEAr13xx: DTS: Add auxiliary data for PCIe host
Quoted 7 lines · viresh kumar
Quoted 2 lines · Pratyush Anand
Signed-off-by Pratyush Anand <[email protected]>---
Please add commit log in each and every message.
What do you mean by auxiliary data in subject?
It used to be plat data earlier, which is being passed from DT now.
Quoted 2 lines
.
Re: [PATCH 10/15] SPEAr13xx: DTS: Add auxiliary data for PCIe host
Quoted 3 lines · Pratyush Anand
Quoted 1 line
What do you mean by auxiliary data in subject?
It used to be plat data earlier, which is being passed from DT now.
Yes. But how did you conclude that it should be called auxiliary data?
I would change subject of this patch to:
ARM: SPEAr13xx: Pass configuration information of PCIe via DT
But i believe you wouldn't need any of above messages and the new message will also add basic DT support for PCIe.
--
viresh
PATCH 11/15 SPEAr1340-evb: dts: Enable PCIe0
In reply to Pratyush Anand--- arch/arm/boot/dts/spear1340-evb.dts | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
arch/arm/boot/dts/spear1340-evb.dts +4 -0
@@ -228,6 +228,10 @@ }; }; + pcie0@b1000000 { + status = "okay"; + }; + ehci@e4800000 { status = "okay"; };
Signature · 1 line
1.7.5.4
PATCH 12/15 SPEAr1310-EVB: DTS: Fix PCIe1 enable
In reply to Pratyush AnandOn SPEAr1310 EVB only PCIe2 can be used as PCIe host. Currently we do not have driver for PCIe EP. So keep PCIe1 disabled.
--- arch/arm/boot/dts/spear1310-evb.dts | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
arch/arm/boot/dts/spear1310-evb.dts +0 -4
@@ -237,10 +237,6 @@ ignore_cpufreq_notification = <0>; }; - pcie1@b1800000 { - status = "okay"; - }; - pcie2@b4000000 { status = "okay"; };
Signature · 1 line
1.7.5.4
PATCH 13/15 SPEAr13xx: update kconfig for PCIe selection
In reply to Pratyush Anand--- arch/arm/mach-spear13xx/Kconfig | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
arch/arm/mach-spear13xx/Kconfig +12 -0
@@ -16,5 +16,17 @@ config MACH_SPEAR1340 select PINCTRL_SPEAR1340 help Supports ST SPEAr1340 machine configured via the device-tree + endmenu + +config SPEAR13XX_PCI + bool "PCI Express support" + select PCI + select PCIEPORTBUS + select ARCH_SUPPORTS_MSI + select PCI_MSI + select NEED_MACH_IO_H + help + Support SPEAr13xx PCIe Dual controler as a host + endif #ARCH_SPEAR13XX
Signature · 1 line
1.7.5.4
Re: [PATCH 13/15] SPEAr13xx: update kconfig for PCIe selection
Quoted 10 lines · Pratyush Anand
Signed-off-by Pratyush Anand <[email protected]>--- arch/arm/mach-spear13xx/Kconfig | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)arch/arm/mach-spear13xx/Kconfig +0
-0
arch/arm/mach-spear13xx/Kconfig config MACH_SPEAR1340 · line 19
Quoted 4 lines
arch/arm/mach-spear13xx/Kconfig +1
-0@@ -16,5 +16,17 @@ config MACH_SPEAR1340 select PINCTRL_SPEAR1340 help Supports ST SPEAr1340 machine configured via the device-tree +
change irrelevant to your patch
arch/arm/mach-spear13xx/Kconfig config MACH_SPEAR1340 · line 23
Quoted 4 lines
arch/arm/mach-spear13xx/Kconfig +3
-0endmenu + +config SPEAR13XX_PCI + bool "PCI Express support"
cant this be module
arch/arm/mach-spear13xx/Kconfig config MACH_SPEAR1340 · line 30
Quoted 7 lines
arch/arm/mach-spear13xx/Kconfig +7
-0+ select PCI + select PCIEPORTBUS + select ARCH_SUPPORTS_MSI + select PCI_MSI + select NEED_MACH_IO_H + help + Support SPEAr13xx PCIe Dual controler as a host
s/controler/controller
Quoted 5 lines
arch/arm/mach-spear13xx/Kconfig +1
-1+ endif #ARCH_SPEAR13XX --1.7.5.4
Re: [PATCH 13/15] SPEAr13xx: update kconfig for PCIe selection
Quoted 6 lines · viresh kumar
Quoted 4 lines
arch/arm/mach-spear13xx/Kconfig config MACH_SPEAR1340 · line 23
Quoted 4 lines
endmenu
arch/arm/mach-spear13xx/Kconfig +3
-0+ +config SPEAR13XX_PCI + bool "PCI Express support"cant this be module
No.
PATCH 14/15 SPEAR13xx: Update makefile for PCIe inclusion
In reply to Pratyush Anand--- arch/arm/mach-spear13xx/Makefile | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/mach-spear13xx/Makefile +1 -0
@@ -9,3 +9,4 @@ obj-$(CONFIG_ARCH_SPEAR13XX) += spear13xx.o obj-$(CONFIG_SUSPEND) += pm.o wakeup.o sleep_1340.o sleep_1310.o obj-$(CONFIG_MACH_SPEAR1310) += spear1310.o obj-$(CONFIG_MACH_SPEAR1340) += spear1340.o +obj-$(CONFIG_SPEAR13XX_PCI) += pcie.o
Signature · 1 line
1.7.5.4
Re: [PATCH 14/15] SPEAR13xx: Update makefile for PCIe inclusion
Quoted 10 lines · Pratyush Anand
Signed-off-by Pratyush Anand <[email protected]>--- arch/arm/mach-spear13xx/Makefile | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)arch/arm/mach-spear13xx/Makefile +0
-0
arch/arm/mach-spear13xx/Makefile obj-$(CONFIG_ARCH_SPEAR13XX) += spear13xx.o · line 12
Quoted 4 lines
arch/arm/mach-spear13xx/Makefile +1
-0@@ -9,3 +9,4 @@ obj-$(CONFIG_ARCH_SPEAR13XX) += spear13xx.o obj-$(CONFIG_SUSPEND) += pm.o wakeup.o sleep_1340.o sleep_1310.o obj-$(CONFIG_MACH_SPEAR1310) += spear1310.o obj-$(CONFIG_MACH_SPEAR1340) += spear1340.o +obj-$(CONFIG_SPEAR13XX_PCI) += pcie.o
Add this before Machines. Also, you can add Kconfig and Makefile changes with drivers patch only.
PATCH 15/15 SPEAR13xx: update defconfig for PCIe compilation
In reply to Pratyush Anand--- arch/arm/configs/spear13xx_defconfig | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/configs/spear13xx_defconfig +1 -0
@@ -14,6 +14,7 @@ CONFIG_PLAT_SPEAR=y CONFIG_ARCH_SPEAR13XX=y CONFIG_MACH_SPEAR1310=y CONFIG_MACH_SPEAR1340=y +CONFIG_SPEAR13XX_PCI=y # CONFIG_SWP_EMULATE is not set CONFIG_SMP=y # CONFIG_ARM_CPU_TOPOLOGY is not set
Signature · 1 line
1.7.5.4
Quoted 4 lines · Pratyush Anand
-- First two patches are common for all platforms on ARM architecture. -- Remaining patches belongs to SPEAr13xx architecture.
-- SPEAr13xx supports both RC and EP mode of PCIe interface. This patchset
supports only RC mode.
Hi Pratyush,
For ARM SoC specific patches, that you want Arnd or Olof to apply, please send them to [email protected]. Arnd and Olof push ARM SoC trees in turns and they pick them from [email protected].
--
viresh
Hi Viresh,
Quoted 11 lines · viresh kumar
Quoted 4 lines · Pratyush Anand
-- First two patches are common for all platforms on ARM architecture. -- Remaining patches belongs to SPEAr13xx architecture.
-- SPEAr13xx supports both RC and EP mode of PCIe interface. This patchset
supports only RC mode.Hi Pratyush,
For ARM SoC specific patches, that you want Arnd or Olof to apply, please send them to [email protected]. Arnd and Olof push ARM SoC trees in turns and they pick them from [email protected].
Ok, I will wait for few days if any more comment is received, and V2 is needed then will take care during v2, else I will resend V1 to this id after few days.
Quoted 5 lines
--
viresh
.