Skip to content

Commit ed22aaa

Browse files
Dilip KotaLorenzo Pieralisi
authored andcommitted
PCI: dwc: intel: PCIe RC controller driver
Add support to PCIe RC controller on Intel Gateway SoCs. PCIe controller is based of Synopsys DesignWare PCIe core. Intel PCIe driver requires Upconfigure support, Fast Training Sequence and link speed configurations. So adding the respective helper functions in the PCIe DesignWare framework. It also programs hardware autonomous speed during speed configuration so defining it in pci_regs.h. Also, mark Intel PCIe driver depends on MSI IRQ Domain as Synopsys DesignWare framework depends on the PCI_MSI_IRQ_DOMAIN. Signed-off-by: Dilip Kota <eswara.kota@linux.intel.com> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Reviewed-by: Andrew Murray <andrew.murray@arm.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
1 parent e54ea45 commit ed22aaa

6 files changed

Lines changed: 626 additions & 0 deletions

File tree

‎drivers/pci/controller/dwc/Kconfig‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,17 @@ config PCIE_ARTPEC6_EP
209209
Enables support for the PCIe controller in the ARTPEC-6 SoC to work in
210210
endpoint mode. This uses the DesignWare core.
211211

212+
config PCIE_INTEL_GW
213+
bool "Intel Gateway PCIe host controller support"
214+
depends on OF && (X86 || COMPILE_TEST)
215+
depends on PCI_MSI_IRQ_DOMAIN
216+
select PCIE_DW_HOST
217+
help
218+
Say 'Y' here to enable PCIe Host controller support on Intel
219+
Gateway SoCs.
220+
The PCIe controller uses the DesignWare core plus Intel-specific
221+
hardware wrappers.
222+
212223
config PCIE_KIRIN
213224
depends on OF && (ARM64 || COMPILE_TEST)
214225
bool "HiSilicon Kirin series SoCs PCIe controllers"

‎drivers/pci/controller/dwc/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ obj-$(CONFIG_PCI_LAYERSCAPE_EP) += pci-layerscape-ep.o
1313
obj-$(CONFIG_PCIE_QCOM) += pcie-qcom.o
1414
obj-$(CONFIG_PCIE_ARMADA_8K) += pcie-armada8k.o
1515
obj-$(CONFIG_PCIE_ARTPEC6) += pcie-artpec6.o
16+
obj-$(CONFIG_PCIE_INTEL_GW) += pcie-intel-gw.o
1617
obj-$(CONFIG_PCIE_KIRIN) += pcie-kirin.o
1718
obj-$(CONFIG_PCIE_HISI_STB) += pcie-histb.o
1819
obj-$(CONFIG_PCI_MESON) += pci-meson.o

‎drivers/pci/controller/dwc/pcie-designware.c‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/of.h>
1313
#include <linux/types.h>
1414

15+
#include "../../pci.h"
1516
#include "pcie-designware.h"
1617

1718
/*
@@ -474,6 +475,61 @@ int dw_pcie_link_up(struct dw_pcie *pci)
474475
(!(val & PCIE_PORT_DEBUG1_LINK_IN_TRAINING)));
475476
}
476477

478+
void dw_pcie_upconfig_setup(struct dw_pcie *pci)
479+
{
480+
u32 val;
481+
482+
val = dw_pcie_readl_dbi(pci, PCIE_PORT_MULTI_LANE_CTRL);
483+
val |= PORT_MLTI_UPCFG_SUPPORT;
484+
dw_pcie_writel_dbi(pci, PCIE_PORT_MULTI_LANE_CTRL, val);
485+
}
486+
EXPORT_SYMBOL_GPL(dw_pcie_upconfig_setup);
487+
488+
void dw_pcie_link_set_max_speed(struct dw_pcie *pci, u32 link_gen)
489+
{
490+
u32 reg, val;
491+
u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
492+
493+
reg = dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCTL2);
494+
reg &= ~PCI_EXP_LNKCTL2_TLS;
495+
496+
switch (pcie_link_speed[link_gen]) {
497+
case PCIE_SPEED_2_5GT:
498+
reg |= PCI_EXP_LNKCTL2_TLS_2_5GT;
499+
break;
500+
case PCIE_SPEED_5_0GT:
501+
reg |= PCI_EXP_LNKCTL2_TLS_5_0GT;
502+
break;
503+
case PCIE_SPEED_8_0GT:
504+
reg |= PCI_EXP_LNKCTL2_TLS_8_0GT;
505+
break;
506+
case PCIE_SPEED_16_0GT:
507+
reg |= PCI_EXP_LNKCTL2_TLS_16_0GT;
508+
break;
509+
default:
510+
/* Use hardware capability */
511+
val = dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCAP);
512+
val = FIELD_GET(PCI_EXP_LNKCAP_SLS, val);
513+
reg &= ~PCI_EXP_LNKCTL2_HASD;
514+
reg |= FIELD_PREP(PCI_EXP_LNKCTL2_TLS, val);
515+
break;
516+
}
517+
518+
dw_pcie_writel_dbi(pci, offset + PCI_EXP_LNKCTL2, reg);
519+
}
520+
EXPORT_SYMBOL_GPL(dw_pcie_link_set_max_speed);
521+
522+
void dw_pcie_link_set_n_fts(struct dw_pcie *pci, u32 n_fts)
523+
{
524+
u32 val;
525+
526+
val = dw_pcie_readl_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL);
527+
val &= ~PORT_LOGIC_N_FTS_MASK;
528+
val |= n_fts & PORT_LOGIC_N_FTS_MASK;
529+
dw_pcie_writel_dbi(pci, PCIE_LINK_WIDTH_SPEED_CONTROL, val);
530+
}
531+
EXPORT_SYMBOL_GPL(dw_pcie_link_set_n_fts);
532+
477533
static u8 dw_pcie_iatu_unroll_enabled(struct dw_pcie *pci)
478534
{
479535
u32 val;

‎drivers/pci/controller/dwc/pcie-designware.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@
3030
#define LINK_WAIT_IATU 9
3131

3232
/* Synopsys-specific PCIe configuration registers */
33+
#define PCIE_PORT_AFR 0x70C
34+
#define PORT_AFR_N_FTS_MASK GENMASK(15, 8)
35+
#define PORT_AFR_CC_N_FTS_MASK GENMASK(23, 16)
36+
3337
#define PCIE_PORT_LINK_CONTROL 0x710
38+
#define PORT_LINK_DLL_LINK_EN BIT(5)
3439
#define PORT_LINK_MODE_MASK GENMASK(21, 16)
3540
#define PORT_LINK_MODE(n) FIELD_PREP(PORT_LINK_MODE_MASK, n)
3641
#define PORT_LINK_MODE_1_LANES PORT_LINK_MODE(0x1)
@@ -46,6 +51,7 @@
4651
#define PCIE_PORT_DEBUG1_LINK_IN_TRAINING BIT(29)
4752

4853
#define PCIE_LINK_WIDTH_SPEED_CONTROL 0x80C
54+
#define PORT_LOGIC_N_FTS_MASK GENMASK(7, 0)
4955
#define PORT_LOGIC_SPEED_CHANGE BIT(17)
5056
#define PORT_LOGIC_LINK_WIDTH_MASK GENMASK(12, 8)
5157
#define PORT_LOGIC_LINK_WIDTH(n) FIELD_PREP(PORT_LOGIC_LINK_WIDTH_MASK, n)
@@ -60,6 +66,9 @@
6066
#define PCIE_MSI_INTR0_MASK 0x82C
6167
#define PCIE_MSI_INTR0_STATUS 0x830
6268

69+
#define PCIE_PORT_MULTI_LANE_CTRL 0x8C0
70+
#define PORT_MLTI_UPCFG_SUPPORT BIT(7)
71+
6372
#define PCIE_ATU_VIEWPORT 0x900
6473
#define PCIE_ATU_REGION_INBOUND BIT(31)
6574
#define PCIE_ATU_REGION_OUTBOUND 0
@@ -273,6 +282,9 @@ void dw_pcie_write_dbi2(struct dw_pcie *pci, u32 reg, size_t size, u32 val);
273282
u32 dw_pcie_read_atu(struct dw_pcie *pci, u32 reg, size_t size);
274283
void dw_pcie_write_atu(struct dw_pcie *pci, u32 reg, size_t size, u32 val);
275284
int dw_pcie_link_up(struct dw_pcie *pci);
285+
void dw_pcie_upconfig_setup(struct dw_pcie *pci);
286+
void dw_pcie_link_set_max_speed(struct dw_pcie *pci, u32 link_gen);
287+
void dw_pcie_link_set_n_fts(struct dw_pcie *pci, u32 n_fts);
276288
int dw_pcie_wait_for_link(struct dw_pcie *pci);
277289
void dw_pcie_prog_outbound_atu(struct dw_pcie *pci, int index,
278290
int type, u64 cpu_addr, u64 pci_addr,

0 commit comments

Comments
 (0)