mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-07 13:43:51 +00:00
Merge branch 'pci/controller/brcmstb'
- Change DT binding maintainer to Jim Quinlan (Jim Quinlan) - Add DT binding maxItems for reset controllers (Jim Quinlan) - Refactor .probe() error handling (Jim Quinlan) - Use the 'bridge' reset method if described in the DT (Jim Quinlan) - Use the 'swinit' reset method if described in the DT (Jim Quinlan) - Add SoC-specific HARD_DEBUG, INTR2_CPU_BASE register offsets (Jim Quinlan) - Drop unused RGR1_SW_INIT_1_INIT_MASK, RGR1_SW_INIT_1_INIT_SHIFT offsets (Jim Quinlan) - Add 'has_phy' so the existence of a 'rescal' reset controller doesn't imply software control of it (Jim Quinlan) - Add support for many inbound DMA windows (Jim Quinlan) - Check return values of all reset_control_*() calls (Jim Quinlan) - Rename SoC 'type' to 'soc_base' express the fact that SoCs come in families of multiple similar devices (Jim Quinlan) - Add Broadcom 7712 DT description and driver support (Jim Quinlan) - Sort enums, pcie_offsets[], pcie_cfg_data, .compatible strings for maintainability (Bjorn Helgaas) * pci/controller/brcmstb: PCI: brcmstb: Sort enums, pcie_offsets[], pcie_cfg_data, .compatible strings PCI: brcmstb: Enable 7712 SoCs PCI: brcmstb: Change field name from 'type' to 'soc_base' PCI: brcmstb: Check return value of all reset_control_* calls PCI: brcmstb: Refactor for chips with many regular inbound windows PCI: brcmstb: Don't conflate the reset rescal with PHY ctrl PCI: brcmstb: Remove two unused constants from driver PCI: brcmstb: PCI: brcmstb: Make HARD_DEBUG, INTR2_CPU_BASE offsets SoC-specific PCI: brcmstb: Use swinit reset if available PCI: brcmstb: Use bridge reset if available PCI: brcmstb: Use common error handling code in brcm_pcie_probe() dt-bindings: PCI: brcm,stb-pcie: Add 7712 SoC description dt-bindings: PCI: brcm,stb-pcie: Use maxItems for reset controllers dt-bindings: PCI: brcm,stb-pcie: Change brcmstb maintainer and cleanup
This commit is contained in:
commit
b893f8ea38
@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
title: Brcmstb PCIe Host Controller
|
||||
|
||||
maintainers:
|
||||
- Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
|
||||
- Jim Quinlan <james.quinlan@broadcom.com>
|
||||
|
||||
properties:
|
||||
compatible:
|
||||
@ -16,11 +16,12 @@ properties:
|
||||
- brcm,bcm2711-pcie # The Raspberry Pi 4
|
||||
- brcm,bcm4908-pcie
|
||||
- brcm,bcm7211-pcie # Broadcom STB version of RPi4
|
||||
- brcm,bcm7278-pcie # Broadcom 7278 Arm
|
||||
- brcm,bcm7216-pcie # Broadcom 7216 Arm
|
||||
- brcm,bcm7445-pcie # Broadcom 7445 Arm
|
||||
- brcm,bcm7278-pcie # Broadcom 7278 Arm
|
||||
- brcm,bcm7425-pcie # Broadcom 7425 MIPs
|
||||
- brcm,bcm7435-pcie # Broadcom 7435 MIPs
|
||||
- brcm,bcm7445-pcie # Broadcom 7445 Arm
|
||||
- brcm,bcm7712-pcie # Broadcom STB sibling of Rpi 5
|
||||
|
||||
reg:
|
||||
maxItems: 1
|
||||
@ -95,6 +96,14 @@ properties:
|
||||
minItems: 1
|
||||
maxItems: 3
|
||||
|
||||
resets:
|
||||
minItems: 1
|
||||
maxItems: 3
|
||||
|
||||
reset-names:
|
||||
minItems: 1
|
||||
maxItems: 3
|
||||
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
||||
@ -118,8 +127,7 @@ allOf:
|
||||
then:
|
||||
properties:
|
||||
resets:
|
||||
items:
|
||||
- description: reset controller handling the PERST# signal
|
||||
maxItems: 1
|
||||
|
||||
reset-names:
|
||||
items:
|
||||
@ -136,8 +144,7 @@ allOf:
|
||||
then:
|
||||
properties:
|
||||
resets:
|
||||
items:
|
||||
- description: phandle pointing to the RESCAL reset controller
|
||||
maxItems: 1
|
||||
|
||||
reset-names:
|
||||
items:
|
||||
@ -147,6 +154,27 @@ allOf:
|
||||
- resets
|
||||
- reset-names
|
||||
|
||||
- if:
|
||||
properties:
|
||||
compatible:
|
||||
contains:
|
||||
const: brcm,bcm7712-pcie
|
||||
then:
|
||||
properties:
|
||||
resets:
|
||||
minItems: 3
|
||||
maxItems: 3
|
||||
|
||||
reset-names:
|
||||
items:
|
||||
- const: rescal
|
||||
- const: bridge
|
||||
- const: swinit
|
||||
|
||||
required:
|
||||
- resets
|
||||
- reset-names
|
||||
|
||||
unevaluatedProperties: false
|
||||
|
||||
examples:
|
||||
|
@ -75,15 +75,19 @@
|
||||
#define PCIE_MEM_WIN0_HI(win) \
|
||||
PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI + ((win) * 8)
|
||||
|
||||
/*
|
||||
* NOTE: You may see the term "BAR" in a number of register names used by
|
||||
* this driver. The term is an artifact of when the HW core was an
|
||||
* endpoint device (EP). Now it is a root complex (RC) and anywhere a
|
||||
* register has the term "BAR" it is related to an inbound window.
|
||||
*/
|
||||
|
||||
#define PCIE_BRCM_MAX_INBOUND_WINS 16
|
||||
#define PCIE_MISC_RC_BAR1_CONFIG_LO 0x402c
|
||||
#define PCIE_MISC_RC_BAR1_CONFIG_LO_SIZE_MASK 0x1f
|
||||
|
||||
#define PCIE_MISC_RC_BAR2_CONFIG_LO 0x4034
|
||||
#define PCIE_MISC_RC_BAR2_CONFIG_LO_SIZE_MASK 0x1f
|
||||
#define PCIE_MISC_RC_BAR2_CONFIG_HI 0x4038
|
||||
#define PCIE_MISC_RC_BAR4_CONFIG_LO 0x40d4
|
||||
|
||||
#define PCIE_MISC_RC_BAR3_CONFIG_LO 0x403c
|
||||
#define PCIE_MISC_RC_BAR3_CONFIG_LO_SIZE_MASK 0x1f
|
||||
|
||||
#define PCIE_MISC_MSI_BAR_CONFIG_LO 0x4044
|
||||
#define PCIE_MISC_MSI_BAR_CONFIG_HI 0x4048
|
||||
@ -122,7 +126,6 @@
|
||||
#define PCIE_MEM_WIN0_LIMIT_HI(win) \
|
||||
PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI + ((win) * 8)
|
||||
|
||||
#define PCIE_MISC_HARD_PCIE_HARD_DEBUG 0x4204
|
||||
#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_CLKREQ_DEBUG_ENABLE_MASK 0x2
|
||||
#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_L1SS_ENABLE_MASK 0x200000
|
||||
#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK 0x08000000
|
||||
@ -131,9 +134,13 @@
|
||||
(PCIE_MISC_HARD_PCIE_HARD_DEBUG_CLKREQ_DEBUG_ENABLE_MASK | \
|
||||
PCIE_MISC_HARD_PCIE_HARD_DEBUG_L1SS_ENABLE_MASK)
|
||||
|
||||
#define PCIE_INTR2_CPU_BASE 0x4300
|
||||
#define PCIE_MISC_UBUS_BAR1_CONFIG_REMAP 0x40ac
|
||||
#define PCIE_MISC_UBUS_BAR1_CONFIG_REMAP_ACCESS_EN_MASK BIT(0)
|
||||
#define PCIE_MISC_UBUS_BAR4_CONFIG_REMAP 0x410c
|
||||
|
||||
#define PCIE_MSI_INTR2_BASE 0x4500
|
||||
/* Offsets from PCIE_INTR2_CPU_BASE and PCIE_MSI_INTR2_BASE */
|
||||
|
||||
/* Offsets from INTR2_CPU and MSI_INTR2 BASE offsets */
|
||||
#define MSI_INT_STATUS 0x0
|
||||
#define MSI_INT_CLR 0x8
|
||||
#define MSI_INT_MASK_SET 0x10
|
||||
@ -184,9 +191,11 @@
|
||||
#define SSC_STATUS_PLL_LOCK_MASK 0x800
|
||||
#define PCIE_BRCM_MAX_MEMC 3
|
||||
|
||||
#define IDX_ADDR(pcie) (pcie->reg_offsets[EXT_CFG_INDEX])
|
||||
#define DATA_ADDR(pcie) (pcie->reg_offsets[EXT_CFG_DATA])
|
||||
#define PCIE_RGR1_SW_INIT_1(pcie) (pcie->reg_offsets[RGR1_SW_INIT_1])
|
||||
#define IDX_ADDR(pcie) ((pcie)->reg_offsets[EXT_CFG_INDEX])
|
||||
#define DATA_ADDR(pcie) ((pcie)->reg_offsets[EXT_CFG_DATA])
|
||||
#define PCIE_RGR1_SW_INIT_1(pcie) ((pcie)->reg_offsets[RGR1_SW_INIT_1])
|
||||
#define HARD_DEBUG(pcie) ((pcie)->reg_offsets[PCIE_HARD_DEBUG])
|
||||
#define INTR2_CPU_BASE(pcie) ((pcie)->reg_offsets[PCIE_INTR2_CPU_BASE])
|
||||
|
||||
/* Rescal registers */
|
||||
#define PCIE_DVT_PMU_PCIE_PHY_CTRL 0xc700
|
||||
@ -205,27 +214,33 @@ enum {
|
||||
RGR1_SW_INIT_1,
|
||||
EXT_CFG_INDEX,
|
||||
EXT_CFG_DATA,
|
||||
PCIE_HARD_DEBUG,
|
||||
PCIE_INTR2_CPU_BASE,
|
||||
};
|
||||
|
||||
enum {
|
||||
RGR1_SW_INIT_1_INIT_MASK,
|
||||
RGR1_SW_INIT_1_INIT_SHIFT,
|
||||
};
|
||||
|
||||
enum pcie_type {
|
||||
enum pcie_soc_base {
|
||||
GENERIC,
|
||||
BCM7425,
|
||||
BCM7435,
|
||||
BCM2711,
|
||||
BCM4908,
|
||||
BCM7278,
|
||||
BCM2711,
|
||||
BCM7425,
|
||||
BCM7435,
|
||||
BCM7712,
|
||||
};
|
||||
|
||||
struct inbound_win {
|
||||
u64 size;
|
||||
u64 pci_offset;
|
||||
u64 cpu_addr;
|
||||
};
|
||||
|
||||
struct pcie_cfg_data {
|
||||
const int *offsets;
|
||||
const enum pcie_type type;
|
||||
void (*perst_set)(struct brcm_pcie *pcie, u32 val);
|
||||
void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val);
|
||||
const enum pcie_soc_base soc_base;
|
||||
const bool has_phy;
|
||||
u8 num_inbound_wins;
|
||||
int (*perst_set)(struct brcm_pcie *pcie, u32 val);
|
||||
int (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val);
|
||||
};
|
||||
|
||||
struct subdev_regulators {
|
||||
@ -262,21 +277,25 @@ struct brcm_pcie {
|
||||
u64 msi_target_addr;
|
||||
struct brcm_msi *msi;
|
||||
const int *reg_offsets;
|
||||
enum pcie_type type;
|
||||
enum pcie_soc_base soc_base;
|
||||
struct reset_control *rescal;
|
||||
struct reset_control *perst_reset;
|
||||
struct reset_control *bridge_reset;
|
||||
struct reset_control *swinit_reset;
|
||||
int num_memc;
|
||||
u64 memc_size[PCIE_BRCM_MAX_MEMC];
|
||||
u32 hw_rev;
|
||||
void (*perst_set)(struct brcm_pcie *pcie, u32 val);
|
||||
void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val);
|
||||
int (*perst_set)(struct brcm_pcie *pcie, u32 val);
|
||||
int (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val);
|
||||
struct subdev_regulators *sr;
|
||||
bool ep_wakeup_capable;
|
||||
bool has_phy;
|
||||
u8 num_inbound_wins;
|
||||
};
|
||||
|
||||
static inline bool is_bmips(const struct brcm_pcie *pcie)
|
||||
{
|
||||
return pcie->type == BCM7435 || pcie->type == BCM7425;
|
||||
return pcie->soc_base == BCM7435 || pcie->soc_base == BCM7425;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -394,7 +413,7 @@ static void brcm_pcie_set_gen(struct brcm_pcie *pcie, int gen)
|
||||
}
|
||||
|
||||
static void brcm_pcie_set_outbound_win(struct brcm_pcie *pcie,
|
||||
unsigned int win, u64 cpu_addr,
|
||||
u8 win, u64 cpu_addr,
|
||||
u64 pcie_addr, u64 size)
|
||||
{
|
||||
u32 cpu_addr_mb_high, limit_addr_mb_high;
|
||||
@ -642,7 +661,7 @@ static int brcm_pcie_enable_msi(struct brcm_pcie *pcie)
|
||||
BUILD_BUG_ON(BRCM_INT_PCI_MSI_LEGACY_NR > BRCM_INT_PCI_MSI_NR);
|
||||
|
||||
if (msi->legacy) {
|
||||
msi->intr_base = msi->base + PCIE_INTR2_CPU_BASE;
|
||||
msi->intr_base = msi->base + INTR2_CPU_BASE(pcie);
|
||||
msi->nr = BRCM_INT_PCI_MSI_LEGACY_NR;
|
||||
msi->legacy_shift = 24;
|
||||
} else {
|
||||
@ -723,17 +742,33 @@ static void __iomem *brcm7425_pcie_map_bus(struct pci_bus *bus,
|
||||
return base + DATA_ADDR(pcie);
|
||||
}
|
||||
|
||||
static void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, u32 val)
|
||||
static int brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, u32 val)
|
||||
{
|
||||
u32 tmp, mask = RGR1_SW_INIT_1_INIT_GENERIC_MASK;
|
||||
u32 tmp, mask = RGR1_SW_INIT_1_INIT_GENERIC_MASK;
|
||||
u32 shift = RGR1_SW_INIT_1_INIT_GENERIC_SHIFT;
|
||||
int ret = 0;
|
||||
|
||||
if (pcie->bridge_reset) {
|
||||
if (val)
|
||||
ret = reset_control_assert(pcie->bridge_reset);
|
||||
else
|
||||
ret = reset_control_deassert(pcie->bridge_reset);
|
||||
|
||||
if (ret)
|
||||
dev_err(pcie->dev, "failed to %s 'bridge' reset, err=%d\n",
|
||||
val ? "assert" : "deassert", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
tmp = readl(pcie->base + PCIE_RGR1_SW_INIT_1(pcie));
|
||||
tmp = (tmp & ~mask) | ((val << shift) & mask);
|
||||
writel(tmp, pcie->base + PCIE_RGR1_SW_INIT_1(pcie));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void brcm_pcie_bridge_sw_init_set_7278(struct brcm_pcie *pcie, u32 val)
|
||||
static int brcm_pcie_bridge_sw_init_set_7278(struct brcm_pcie *pcie, u32 val)
|
||||
{
|
||||
u32 tmp, mask = RGR1_SW_INIT_1_INIT_7278_MASK;
|
||||
u32 shift = RGR1_SW_INIT_1_INIT_7278_SHIFT;
|
||||
@ -741,20 +776,29 @@ static void brcm_pcie_bridge_sw_init_set_7278(struct brcm_pcie *pcie, u32 val)
|
||||
tmp = readl(pcie->base + PCIE_RGR1_SW_INIT_1(pcie));
|
||||
tmp = (tmp & ~mask) | ((val << shift) & mask);
|
||||
writel(tmp, pcie->base + PCIE_RGR1_SW_INIT_1(pcie));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void brcm_pcie_perst_set_4908(struct brcm_pcie *pcie, u32 val)
|
||||
static int brcm_pcie_perst_set_4908(struct brcm_pcie *pcie, u32 val)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (WARN_ONCE(!pcie->perst_reset, "missing PERST# reset controller\n"))
|
||||
return;
|
||||
return -EINVAL;
|
||||
|
||||
if (val)
|
||||
reset_control_assert(pcie->perst_reset);
|
||||
ret = reset_control_assert(pcie->perst_reset);
|
||||
else
|
||||
reset_control_deassert(pcie->perst_reset);
|
||||
ret = reset_control_deassert(pcie->perst_reset);
|
||||
|
||||
if (ret)
|
||||
dev_err(pcie->dev, "failed to %s 'perst' reset, err=%d\n",
|
||||
val ? "assert" : "deassert", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void brcm_pcie_perst_set_7278(struct brcm_pcie *pcie, u32 val)
|
||||
static int brcm_pcie_perst_set_7278(struct brcm_pcie *pcie, u32 val)
|
||||
{
|
||||
u32 tmp;
|
||||
|
||||
@ -762,34 +806,77 @@ static void brcm_pcie_perst_set_7278(struct brcm_pcie *pcie, u32 val)
|
||||
tmp = readl(pcie->base + PCIE_MISC_PCIE_CTRL);
|
||||
u32p_replace_bits(&tmp, !val, PCIE_MISC_PCIE_CTRL_PCIE_PERSTB_MASK);
|
||||
writel(tmp, pcie->base + PCIE_MISC_PCIE_CTRL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void brcm_pcie_perst_set_generic(struct brcm_pcie *pcie, u32 val)
|
||||
static int brcm_pcie_perst_set_generic(struct brcm_pcie *pcie, u32 val)
|
||||
{
|
||||
u32 tmp;
|
||||
|
||||
tmp = readl(pcie->base + PCIE_RGR1_SW_INIT_1(pcie));
|
||||
u32p_replace_bits(&tmp, val, PCIE_RGR1_SW_INIT_1_PERST_MASK);
|
||||
writel(tmp, pcie->base + PCIE_RGR1_SW_INIT_1(pcie));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int brcm_pcie_get_rc_bar2_size_and_offset(struct brcm_pcie *pcie,
|
||||
u64 *rc_bar2_size,
|
||||
u64 *rc_bar2_offset)
|
||||
static void add_inbound_win(struct inbound_win *b, u8 *count, u64 size,
|
||||
u64 cpu_addr, u64 pci_offset)
|
||||
{
|
||||
b->size = size;
|
||||
b->cpu_addr = cpu_addr;
|
||||
b->pci_offset = pci_offset;
|
||||
(*count)++;
|
||||
}
|
||||
|
||||
static int brcm_pcie_get_inbound_wins(struct brcm_pcie *pcie,
|
||||
struct inbound_win inbound_wins[])
|
||||
{
|
||||
struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
|
||||
u64 pci_offset, cpu_addr, size = 0, tot_size = 0;
|
||||
struct resource_entry *entry;
|
||||
struct device *dev = pcie->dev;
|
||||
u64 lowest_pcie_addr = ~(u64)0;
|
||||
int ret, i = 0;
|
||||
u64 size = 0;
|
||||
u8 n = 0;
|
||||
|
||||
/*
|
||||
* The HW registers (and PCIe) use order-1 numbering for BARs. As such,
|
||||
* we have inbound_wins[0] unused and BAR1 starts at inbound_wins[1].
|
||||
*/
|
||||
struct inbound_win *b_begin = &inbound_wins[1];
|
||||
struct inbound_win *b = b_begin;
|
||||
|
||||
/*
|
||||
* STB chips beside 7712 disable the first inbound window default.
|
||||
* Rather being mapped to system memory it is mapped to the
|
||||
* internal registers of the SoC. This feature is deprecated, has
|
||||
* security considerations, and is not implemented in our modern
|
||||
* SoCs.
|
||||
*/
|
||||
if (pcie->soc_base != BCM7712)
|
||||
add_inbound_win(b++, &n, 0, 0, 0);
|
||||
|
||||
resource_list_for_each_entry(entry, &bridge->dma_ranges) {
|
||||
u64 pcie_beg = entry->res->start - entry->offset;
|
||||
u64 pcie_start = entry->res->start - entry->offset;
|
||||
u64 cpu_start = entry->res->start;
|
||||
|
||||
size += entry->res->end - entry->res->start + 1;
|
||||
if (pcie_beg < lowest_pcie_addr)
|
||||
lowest_pcie_addr = pcie_beg;
|
||||
size = resource_size(entry->res);
|
||||
tot_size += size;
|
||||
if (pcie_start < lowest_pcie_addr)
|
||||
lowest_pcie_addr = pcie_start;
|
||||
/*
|
||||
* 7712 and newer chips may have many BARs, with each
|
||||
* offering a non-overlapping viewport to system memory.
|
||||
* That being said, each BARs size must still be a power of
|
||||
* two.
|
||||
*/
|
||||
if (pcie->soc_base == BCM7712)
|
||||
add_inbound_win(b++, &n, size, cpu_start, pcie_start);
|
||||
|
||||
if (n > pcie->num_inbound_wins)
|
||||
break;
|
||||
}
|
||||
|
||||
if (lowest_pcie_addr == ~(u64)0) {
|
||||
@ -797,13 +884,20 @@ static int brcm_pcie_get_rc_bar2_size_and_offset(struct brcm_pcie *pcie,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* 7712 and newer chips do not have an internal memory mapping system
|
||||
* that enables multiple memory controllers. As such, it can return
|
||||
* now w/o doing special configuration.
|
||||
*/
|
||||
if (pcie->soc_base == BCM7712)
|
||||
return n;
|
||||
|
||||
ret = of_property_read_variable_u64_array(pcie->np, "brcm,scb-sizes", pcie->memc_size, 1,
|
||||
PCIE_BRCM_MAX_MEMC);
|
||||
|
||||
if (ret <= 0) {
|
||||
/* Make an educated guess */
|
||||
pcie->num_memc = 1;
|
||||
pcie->memc_size[0] = 1ULL << fls64(size - 1);
|
||||
pcie->memc_size[0] = 1ULL << fls64(tot_size - 1);
|
||||
} else {
|
||||
pcie->num_memc = ret;
|
||||
}
|
||||
@ -812,10 +906,15 @@ static int brcm_pcie_get_rc_bar2_size_and_offset(struct brcm_pcie *pcie,
|
||||
for (i = 0, size = 0; i < pcie->num_memc; i++)
|
||||
size += pcie->memc_size[i];
|
||||
|
||||
/* System memory starts at this address in PCIe-space */
|
||||
*rc_bar2_offset = lowest_pcie_addr;
|
||||
/* The sum of all memc views must also be a power of 2 */
|
||||
*rc_bar2_size = 1ULL << fls64(size - 1);
|
||||
/* Our HW mandates that the window size must be a power of 2 */
|
||||
size = 1ULL << fls64(size - 1);
|
||||
|
||||
/*
|
||||
* For STB chips, the BAR2 cpu_addr is hardwired to the start
|
||||
* of system memory, so we set it to 0.
|
||||
*/
|
||||
cpu_addr = 0;
|
||||
pci_offset = lowest_pcie_addr;
|
||||
|
||||
/*
|
||||
* We validate the inbound memory view even though we should trust
|
||||
@ -850,44 +949,119 @@ static int brcm_pcie_get_rc_bar2_size_and_offset(struct brcm_pcie *pcie,
|
||||
* outbound memory @ 3GB). So instead it will start at the 1x
|
||||
* multiple of its size
|
||||
*/
|
||||
if (!*rc_bar2_size || (*rc_bar2_offset & (*rc_bar2_size - 1)) ||
|
||||
(*rc_bar2_offset < SZ_4G && *rc_bar2_offset > SZ_2G)) {
|
||||
dev_err(dev, "Invalid rc_bar2_offset/size: size 0x%llx, off 0x%llx\n",
|
||||
*rc_bar2_size, *rc_bar2_offset);
|
||||
if (!size || (pci_offset & (size - 1)) ||
|
||||
(pci_offset < SZ_4G && pci_offset > SZ_2G)) {
|
||||
dev_err(dev, "Invalid inbound_win2_offset/size: size 0x%llx, off 0x%llx\n",
|
||||
size, pci_offset);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
/* Enable inbound window 2, the main inbound window for STB chips */
|
||||
add_inbound_win(b++, &n, size, cpu_addr, pci_offset);
|
||||
|
||||
/*
|
||||
* Disable inbound window 3. On some chips presents the same
|
||||
* window as #2 but the data appears in a settable endianness.
|
||||
*/
|
||||
add_inbound_win(b++, &n, 0, 0, 0);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static u32 brcm_bar_reg_offset(int bar)
|
||||
{
|
||||
if (bar <= 3)
|
||||
return PCIE_MISC_RC_BAR1_CONFIG_LO + 8 * (bar - 1);
|
||||
else
|
||||
return PCIE_MISC_RC_BAR4_CONFIG_LO + 8 * (bar - 4);
|
||||
}
|
||||
|
||||
static u32 brcm_ubus_reg_offset(int bar)
|
||||
{
|
||||
if (bar <= 3)
|
||||
return PCIE_MISC_UBUS_BAR1_CONFIG_REMAP + 8 * (bar - 1);
|
||||
else
|
||||
return PCIE_MISC_UBUS_BAR4_CONFIG_REMAP + 8 * (bar - 4);
|
||||
}
|
||||
|
||||
static void set_inbound_win_registers(struct brcm_pcie *pcie,
|
||||
const struct inbound_win *inbound_wins,
|
||||
u8 num_inbound_wins)
|
||||
{
|
||||
void __iomem *base = pcie->base;
|
||||
int i;
|
||||
|
||||
for (i = 1; i <= num_inbound_wins; i++) {
|
||||
u64 pci_offset = inbound_wins[i].pci_offset;
|
||||
u64 cpu_addr = inbound_wins[i].cpu_addr;
|
||||
u64 size = inbound_wins[i].size;
|
||||
u32 reg_offset = brcm_bar_reg_offset(i);
|
||||
u32 tmp = lower_32_bits(pci_offset);
|
||||
|
||||
u32p_replace_bits(&tmp, brcm_pcie_encode_ibar_size(size),
|
||||
PCIE_MISC_RC_BAR1_CONFIG_LO_SIZE_MASK);
|
||||
|
||||
/* Write low */
|
||||
writel_relaxed(tmp, base + reg_offset);
|
||||
/* Write high */
|
||||
writel_relaxed(upper_32_bits(pci_offset), base + reg_offset + 4);
|
||||
|
||||
/*
|
||||
* Most STB chips:
|
||||
* Do nothing.
|
||||
* 7712:
|
||||
* All of their BARs need to be set.
|
||||
*/
|
||||
if (pcie->soc_base == BCM7712) {
|
||||
/* BUS remap register settings */
|
||||
reg_offset = brcm_ubus_reg_offset(i);
|
||||
tmp = lower_32_bits(cpu_addr) & ~0xfff;
|
||||
tmp |= PCIE_MISC_UBUS_BAR1_CONFIG_REMAP_ACCESS_EN_MASK;
|
||||
writel_relaxed(tmp, base + reg_offset);
|
||||
tmp = upper_32_bits(cpu_addr);
|
||||
writel_relaxed(tmp, base + reg_offset + 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int brcm_pcie_setup(struct brcm_pcie *pcie)
|
||||
{
|
||||
u64 rc_bar2_offset, rc_bar2_size;
|
||||
struct inbound_win inbound_wins[PCIE_BRCM_MAX_INBOUND_WINS];
|
||||
void __iomem *base = pcie->base;
|
||||
struct pci_host_bridge *bridge;
|
||||
struct resource_entry *entry;
|
||||
u32 tmp, burst, aspm_support;
|
||||
int num_out_wins = 0;
|
||||
int ret, memc;
|
||||
u8 num_out_wins = 0;
|
||||
int num_inbound_wins = 0;
|
||||
int memc, ret;
|
||||
|
||||
/* Reset the bridge */
|
||||
pcie->bridge_sw_init_set(pcie, 1);
|
||||
ret = pcie->bridge_sw_init_set(pcie, 1);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Ensure that PERST# is asserted; some bootloaders may deassert it. */
|
||||
if (pcie->type == BCM2711)
|
||||
pcie->perst_set(pcie, 1);
|
||||
if (pcie->soc_base == BCM2711) {
|
||||
ret = pcie->perst_set(pcie, 1);
|
||||
if (ret) {
|
||||
pcie->bridge_sw_init_set(pcie, 0);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
usleep_range(100, 200);
|
||||
|
||||
/* Take the bridge out of reset */
|
||||
pcie->bridge_sw_init_set(pcie, 0);
|
||||
ret = pcie->bridge_sw_init_set(pcie, 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
tmp = readl(base + PCIE_MISC_HARD_PCIE_HARD_DEBUG);
|
||||
tmp = readl(base + HARD_DEBUG(pcie));
|
||||
if (is_bmips(pcie))
|
||||
tmp &= ~PCIE_BMIPS_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK;
|
||||
else
|
||||
tmp &= ~PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK;
|
||||
writel(tmp, base + PCIE_MISC_HARD_PCIE_HARD_DEBUG);
|
||||
writel(tmp, base + HARD_DEBUG(pcie));
|
||||
/* Wait for SerDes to be stable */
|
||||
usleep_range(100, 200);
|
||||
|
||||
@ -898,9 +1072,9 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
|
||||
*/
|
||||
if (is_bmips(pcie))
|
||||
burst = 0x1; /* 256 bytes */
|
||||
else if (pcie->type == BCM2711)
|
||||
else if (pcie->soc_base == BCM2711)
|
||||
burst = 0x0; /* 128 bytes */
|
||||
else if (pcie->type == BCM7278)
|
||||
else if (pcie->soc_base == BCM7278)
|
||||
burst = 0x3; /* 512 bytes */
|
||||
else
|
||||
burst = 0x2; /* 512 bytes */
|
||||
@ -917,17 +1091,16 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
|
||||
u32p_replace_bits(&tmp, 1, PCIE_MISC_MISC_CTRL_PCIE_RCB_64B_MODE_MASK);
|
||||
writel(tmp, base + PCIE_MISC_MISC_CTRL);
|
||||
|
||||
ret = brcm_pcie_get_rc_bar2_size_and_offset(pcie, &rc_bar2_size,
|
||||
&rc_bar2_offset);
|
||||
if (ret)
|
||||
return ret;
|
||||
num_inbound_wins = brcm_pcie_get_inbound_wins(pcie, inbound_wins);
|
||||
if (num_inbound_wins < 0)
|
||||
return num_inbound_wins;
|
||||
|
||||
tmp = lower_32_bits(rc_bar2_offset);
|
||||
u32p_replace_bits(&tmp, brcm_pcie_encode_ibar_size(rc_bar2_size),
|
||||
PCIE_MISC_RC_BAR2_CONFIG_LO_SIZE_MASK);
|
||||
writel(tmp, base + PCIE_MISC_RC_BAR2_CONFIG_LO);
|
||||
writel(upper_32_bits(rc_bar2_offset),
|
||||
base + PCIE_MISC_RC_BAR2_CONFIG_HI);
|
||||
set_inbound_win_registers(pcie, inbound_wins, num_inbound_wins);
|
||||
|
||||
if (!brcm_pcie_rc_mode(pcie)) {
|
||||
dev_err(pcie->dev, "PCIe RC controller misconfigured as Endpoint\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
tmp = readl(base + PCIE_MISC_MISC_CTRL);
|
||||
for (memc = 0; memc < pcie->num_memc; memc++) {
|
||||
@ -949,25 +1122,12 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
|
||||
* 4GB or when the inbound area is smaller than 4GB (taking into
|
||||
* account the rounding-up we're forced to perform).
|
||||
*/
|
||||
if (rc_bar2_offset >= SZ_4G || (rc_bar2_size + rc_bar2_offset) < SZ_4G)
|
||||
if (inbound_wins[2].pci_offset >= SZ_4G ||
|
||||
(inbound_wins[2].size + inbound_wins[2].pci_offset) < SZ_4G)
|
||||
pcie->msi_target_addr = BRCM_MSI_TARGET_ADDR_LT_4GB;
|
||||
else
|
||||
pcie->msi_target_addr = BRCM_MSI_TARGET_ADDR_GT_4GB;
|
||||
|
||||
if (!brcm_pcie_rc_mode(pcie)) {
|
||||
dev_err(pcie->dev, "PCIe RC controller misconfigured as Endpoint\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* disable the PCIe->GISB memory window (RC_BAR1) */
|
||||
tmp = readl(base + PCIE_MISC_RC_BAR1_CONFIG_LO);
|
||||
tmp &= ~PCIE_MISC_RC_BAR1_CONFIG_LO_SIZE_MASK;
|
||||
writel(tmp, base + PCIE_MISC_RC_BAR1_CONFIG_LO);
|
||||
|
||||
/* disable the PCIe->SCB memory window (RC_BAR3) */
|
||||
tmp = readl(base + PCIE_MISC_RC_BAR3_CONFIG_LO);
|
||||
tmp &= ~PCIE_MISC_RC_BAR3_CONFIG_LO_SIZE_MASK;
|
||||
writel(tmp, base + PCIE_MISC_RC_BAR3_CONFIG_LO);
|
||||
|
||||
/* Don't advertise L0s capability if 'aspm-no-l0s' */
|
||||
aspm_support = PCIE_LINK_STATE_L1;
|
||||
@ -1018,7 +1178,7 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
|
||||
num_out_wins++;
|
||||
}
|
||||
|
||||
/* PCIe->SCB endian mode for BAR */
|
||||
/* PCIe->SCB endian mode for inbound window */
|
||||
tmp = readl(base + PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1);
|
||||
u32p_replace_bits(&tmp, PCIE_RC_CFG_VENDOR_SPCIFIC_REG1_LITTLE_ENDIAN,
|
||||
PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1_ENDIAN_MODE_BAR2_MASK);
|
||||
@ -1038,6 +1198,10 @@ static void brcm_extend_rbus_timeout(struct brcm_pcie *pcie)
|
||||
const unsigned int REG_OFFSET = PCIE_RGR1_SW_INIT_1(pcie) - 8;
|
||||
u32 timeout_us = 4000000; /* 4 seconds, our setting for L1SS */
|
||||
|
||||
/* 7712 does not have this (RGR1) timer */
|
||||
if (pcie->soc_base == BCM7712)
|
||||
return;
|
||||
|
||||
/* Each unit in timeout register is 1/216,000,000 seconds */
|
||||
writel(216 * timeout_us, pcie->base + REG_OFFSET);
|
||||
}
|
||||
@ -1056,7 +1220,7 @@ static void brcm_config_clkreq(struct brcm_pcie *pcie)
|
||||
}
|
||||
|
||||
/* Start out assuming safe mode (both mode bits cleared) */
|
||||
clkreq_cntl = readl(pcie->base + PCIE_MISC_HARD_PCIE_HARD_DEBUG);
|
||||
clkreq_cntl = readl(pcie->base + HARD_DEBUG(pcie));
|
||||
clkreq_cntl &= ~PCIE_CLKREQ_MASK;
|
||||
|
||||
if (strcmp(mode, "no-l1ss") == 0) {
|
||||
@ -1099,7 +1263,7 @@ static void brcm_config_clkreq(struct brcm_pcie *pcie)
|
||||
dev_err(pcie->dev, err_msg);
|
||||
mode = "safe";
|
||||
}
|
||||
writel(clkreq_cntl, pcie->base + PCIE_MISC_HARD_PCIE_HARD_DEBUG);
|
||||
writel(clkreq_cntl, pcie->base + HARD_DEBUG(pcie));
|
||||
|
||||
dev_info(pcie->dev, "clkreq-mode set to %s\n", mode);
|
||||
}
|
||||
@ -1113,7 +1277,9 @@ static int brcm_pcie_start_link(struct brcm_pcie *pcie)
|
||||
int ret, i;
|
||||
|
||||
/* Unassert the fundamental reset */
|
||||
pcie->perst_set(pcie, 0);
|
||||
ret = pcie->perst_set(pcie, 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/*
|
||||
* Wait for 100ms after PERST# deassertion; see PCIe CEM specification
|
||||
@ -1297,23 +1463,25 @@ static int brcm_phy_cntl(struct brcm_pcie *pcie, const int start)
|
||||
|
||||
static inline int brcm_phy_start(struct brcm_pcie *pcie)
|
||||
{
|
||||
return pcie->rescal ? brcm_phy_cntl(pcie, 1) : 0;
|
||||
return pcie->has_phy ? brcm_phy_cntl(pcie, 1) : 0;
|
||||
}
|
||||
|
||||
static inline int brcm_phy_stop(struct brcm_pcie *pcie)
|
||||
{
|
||||
return pcie->rescal ? brcm_phy_cntl(pcie, 0) : 0;
|
||||
return pcie->has_phy ? brcm_phy_cntl(pcie, 0) : 0;
|
||||
}
|
||||
|
||||
static void brcm_pcie_turn_off(struct brcm_pcie *pcie)
|
||||
static int brcm_pcie_turn_off(struct brcm_pcie *pcie)
|
||||
{
|
||||
void __iomem *base = pcie->base;
|
||||
int tmp;
|
||||
int tmp, ret;
|
||||
|
||||
if (brcm_pcie_link_up(pcie))
|
||||
brcm_pcie_enter_l23(pcie);
|
||||
/* Assert fundamental reset */
|
||||
pcie->perst_set(pcie, 1);
|
||||
ret = pcie->perst_set(pcie, 1);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Deassert request for L23 in case it was asserted */
|
||||
tmp = readl(base + PCIE_MISC_PCIE_CTRL);
|
||||
@ -1321,12 +1489,14 @@ static void brcm_pcie_turn_off(struct brcm_pcie *pcie)
|
||||
writel(tmp, base + PCIE_MISC_PCIE_CTRL);
|
||||
|
||||
/* Turn off SerDes */
|
||||
tmp = readl(base + PCIE_MISC_HARD_PCIE_HARD_DEBUG);
|
||||
tmp = readl(base + HARD_DEBUG(pcie));
|
||||
u32p_replace_bits(&tmp, 1, PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK);
|
||||
writel(tmp, base + PCIE_MISC_HARD_PCIE_HARD_DEBUG);
|
||||
writel(tmp, base + HARD_DEBUG(pcie));
|
||||
|
||||
/* Shutdown PCIe bridge */
|
||||
pcie->bridge_sw_init_set(pcie, 1);
|
||||
ret = pcie->bridge_sw_init_set(pcie, 1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int pci_dev_may_wakeup(struct pci_dev *dev, void *data)
|
||||
@ -1344,9 +1514,12 @@ static int brcm_pcie_suspend_noirq(struct device *dev)
|
||||
{
|
||||
struct brcm_pcie *pcie = dev_get_drvdata(dev);
|
||||
struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
|
||||
int ret;
|
||||
int ret, rret;
|
||||
|
||||
ret = brcm_pcie_turn_off(pcie);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
brcm_pcie_turn_off(pcie);
|
||||
/*
|
||||
* If brcm_phy_stop() returns an error, just dev_err(). If we
|
||||
* return the error it will cause the suspend to fail and this is a
|
||||
@ -1375,7 +1548,10 @@ static int brcm_pcie_suspend_noirq(struct device *dev)
|
||||
pcie->sr->supplies);
|
||||
if (ret) {
|
||||
dev_err(dev, "Could not turn off regulators\n");
|
||||
reset_control_reset(pcie->rescal);
|
||||
rret = reset_control_reset(pcie->rescal);
|
||||
if (rret)
|
||||
dev_err(dev, "failed to reset 'rascal' controller ret=%d\n",
|
||||
rret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -1390,7 +1566,7 @@ static int brcm_pcie_resume_noirq(struct device *dev)
|
||||
struct brcm_pcie *pcie = dev_get_drvdata(dev);
|
||||
void __iomem *base;
|
||||
u32 tmp;
|
||||
int ret;
|
||||
int ret, rret;
|
||||
|
||||
base = pcie->base;
|
||||
ret = clk_prepare_enable(pcie->clk);
|
||||
@ -1409,9 +1585,9 @@ static int brcm_pcie_resume_noirq(struct device *dev)
|
||||
pcie->bridge_sw_init_set(pcie, 0);
|
||||
|
||||
/* SERDES_IDDQ = 0 */
|
||||
tmp = readl(base + PCIE_MISC_HARD_PCIE_HARD_DEBUG);
|
||||
tmp = readl(base + HARD_DEBUG(pcie));
|
||||
u32p_replace_bits(&tmp, 0, PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK);
|
||||
writel(tmp, base + PCIE_MISC_HARD_PCIE_HARD_DEBUG);
|
||||
writel(tmp, base + HARD_DEBUG(pcie));
|
||||
|
||||
/* wait for serdes to be stable */
|
||||
udelay(100);
|
||||
@ -1452,7 +1628,9 @@ static int brcm_pcie_resume_noirq(struct device *dev)
|
||||
if (pcie->sr)
|
||||
regulator_bulk_disable(pcie->sr->num_supplies, pcie->sr->supplies);
|
||||
err_reset:
|
||||
reset_control_rearm(pcie->rescal);
|
||||
rret = reset_control_rearm(pcie->rescal);
|
||||
if (rret)
|
||||
dev_err(pcie->dev, "failed to rearm 'rescal' reset, err=%d\n", rret);
|
||||
err_disable_clk:
|
||||
clk_disable_unprepare(pcie->clk);
|
||||
return ret;
|
||||
@ -1480,74 +1658,111 @@ static void brcm_pcie_remove(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
static const int pcie_offsets[] = {
|
||||
[RGR1_SW_INIT_1] = 0x9210,
|
||||
[EXT_CFG_INDEX] = 0x9000,
|
||||
[EXT_CFG_DATA] = 0x9004,
|
||||
[RGR1_SW_INIT_1] = 0x9210,
|
||||
[EXT_CFG_INDEX] = 0x9000,
|
||||
[EXT_CFG_DATA] = 0x9004,
|
||||
[PCIE_HARD_DEBUG] = 0x4204,
|
||||
[PCIE_INTR2_CPU_BASE] = 0x4300,
|
||||
};
|
||||
|
||||
static const int pcie_offsets_bmips_7425[] = {
|
||||
[RGR1_SW_INIT_1] = 0x8010,
|
||||
[EXT_CFG_INDEX] = 0x8300,
|
||||
[EXT_CFG_DATA] = 0x8304,
|
||||
static const int pcie_offsets_bcm7278[] = {
|
||||
[RGR1_SW_INIT_1] = 0xc010,
|
||||
[EXT_CFG_INDEX] = 0x9000,
|
||||
[EXT_CFG_DATA] = 0x9004,
|
||||
[PCIE_HARD_DEBUG] = 0x4204,
|
||||
[PCIE_INTR2_CPU_BASE] = 0x4300,
|
||||
};
|
||||
|
||||
static const int pcie_offsets_bcm7425[] = {
|
||||
[RGR1_SW_INIT_1] = 0x8010,
|
||||
[EXT_CFG_INDEX] = 0x8300,
|
||||
[EXT_CFG_DATA] = 0x8304,
|
||||
[PCIE_HARD_DEBUG] = 0x4204,
|
||||
[PCIE_INTR2_CPU_BASE] = 0x4300,
|
||||
};
|
||||
|
||||
static const int pcie_offsets_bcm7712[] = {
|
||||
[EXT_CFG_INDEX] = 0x9000,
|
||||
[EXT_CFG_DATA] = 0x9004,
|
||||
[PCIE_HARD_DEBUG] = 0x4304,
|
||||
[PCIE_INTR2_CPU_BASE] = 0x4400,
|
||||
};
|
||||
|
||||
static const struct pcie_cfg_data generic_cfg = {
|
||||
.offsets = pcie_offsets,
|
||||
.type = GENERIC,
|
||||
.soc_base = GENERIC,
|
||||
.perst_set = brcm_pcie_perst_set_generic,
|
||||
.bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic,
|
||||
};
|
||||
|
||||
static const struct pcie_cfg_data bcm7425_cfg = {
|
||||
.offsets = pcie_offsets_bmips_7425,
|
||||
.type = BCM7425,
|
||||
.perst_set = brcm_pcie_perst_set_generic,
|
||||
.bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic,
|
||||
};
|
||||
|
||||
static const struct pcie_cfg_data bcm7435_cfg = {
|
||||
.offsets = pcie_offsets,
|
||||
.type = BCM7435,
|
||||
.perst_set = brcm_pcie_perst_set_generic,
|
||||
.bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic,
|
||||
};
|
||||
|
||||
static const struct pcie_cfg_data bcm4908_cfg = {
|
||||
.offsets = pcie_offsets,
|
||||
.type = BCM4908,
|
||||
.perst_set = brcm_pcie_perst_set_4908,
|
||||
.bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic,
|
||||
};
|
||||
|
||||
static const int pcie_offset_bcm7278[] = {
|
||||
[RGR1_SW_INIT_1] = 0xc010,
|
||||
[EXT_CFG_INDEX] = 0x9000,
|
||||
[EXT_CFG_DATA] = 0x9004,
|
||||
};
|
||||
|
||||
static const struct pcie_cfg_data bcm7278_cfg = {
|
||||
.offsets = pcie_offset_bcm7278,
|
||||
.type = BCM7278,
|
||||
.perst_set = brcm_pcie_perst_set_7278,
|
||||
.bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_7278,
|
||||
.num_inbound_wins = 3,
|
||||
};
|
||||
|
||||
static const struct pcie_cfg_data bcm2711_cfg = {
|
||||
.offsets = pcie_offsets,
|
||||
.type = BCM2711,
|
||||
.soc_base = BCM2711,
|
||||
.perst_set = brcm_pcie_perst_set_generic,
|
||||
.bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic,
|
||||
.num_inbound_wins = 3,
|
||||
};
|
||||
|
||||
static const struct pcie_cfg_data bcm4908_cfg = {
|
||||
.offsets = pcie_offsets,
|
||||
.soc_base = BCM4908,
|
||||
.perst_set = brcm_pcie_perst_set_4908,
|
||||
.bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic,
|
||||
.num_inbound_wins = 3,
|
||||
};
|
||||
|
||||
static const struct pcie_cfg_data bcm7278_cfg = {
|
||||
.offsets = pcie_offsets_bcm7278,
|
||||
.soc_base = BCM7278,
|
||||
.perst_set = brcm_pcie_perst_set_7278,
|
||||
.bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_7278,
|
||||
.num_inbound_wins = 3,
|
||||
};
|
||||
|
||||
static const struct pcie_cfg_data bcm7425_cfg = {
|
||||
.offsets = pcie_offsets_bcm7425,
|
||||
.soc_base = BCM7425,
|
||||
.perst_set = brcm_pcie_perst_set_generic,
|
||||
.bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic,
|
||||
.num_inbound_wins = 3,
|
||||
};
|
||||
|
||||
static const struct pcie_cfg_data bcm7435_cfg = {
|
||||
.offsets = pcie_offsets,
|
||||
.soc_base = BCM7435,
|
||||
.perst_set = brcm_pcie_perst_set_generic,
|
||||
.bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic,
|
||||
.num_inbound_wins = 3,
|
||||
};
|
||||
|
||||
static const struct pcie_cfg_data bcm7216_cfg = {
|
||||
.offsets = pcie_offsets_bcm7278,
|
||||
.soc_base = BCM7278,
|
||||
.perst_set = brcm_pcie_perst_set_7278,
|
||||
.bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_7278,
|
||||
.has_phy = true,
|
||||
.num_inbound_wins = 3,
|
||||
};
|
||||
|
||||
static const struct pcie_cfg_data bcm7712_cfg = {
|
||||
.offsets = pcie_offsets_bcm7712,
|
||||
.perst_set = brcm_pcie_perst_set_7278,
|
||||
.bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic,
|
||||
.soc_base = BCM7712,
|
||||
.num_inbound_wins = 10,
|
||||
};
|
||||
|
||||
static const struct of_device_id brcm_pcie_match[] = {
|
||||
{ .compatible = "brcm,bcm2711-pcie", .data = &bcm2711_cfg },
|
||||
{ .compatible = "brcm,bcm4908-pcie", .data = &bcm4908_cfg },
|
||||
{ .compatible = "brcm,bcm7211-pcie", .data = &generic_cfg },
|
||||
{ .compatible = "brcm,bcm7216-pcie", .data = &bcm7216_cfg },
|
||||
{ .compatible = "brcm,bcm7278-pcie", .data = &bcm7278_cfg },
|
||||
{ .compatible = "brcm,bcm7216-pcie", .data = &bcm7278_cfg },
|
||||
{ .compatible = "brcm,bcm7445-pcie", .data = &generic_cfg },
|
||||
{ .compatible = "brcm,bcm7435-pcie", .data = &bcm7435_cfg },
|
||||
{ .compatible = "brcm,bcm7425-pcie", .data = &bcm7425_cfg },
|
||||
{ .compatible = "brcm,bcm7435-pcie", .data = &bcm7435_cfg },
|
||||
{ .compatible = "brcm,bcm7445-pcie", .data = &generic_cfg },
|
||||
{ .compatible = "brcm,bcm7712-pcie", .data = &bcm7712_cfg },
|
||||
{},
|
||||
};
|
||||
|
||||
@ -1589,9 +1804,11 @@ static int brcm_pcie_probe(struct platform_device *pdev)
|
||||
pcie->dev = &pdev->dev;
|
||||
pcie->np = np;
|
||||
pcie->reg_offsets = data->offsets;
|
||||
pcie->type = data->type;
|
||||
pcie->soc_base = data->soc_base;
|
||||
pcie->perst_set = data->perst_set;
|
||||
pcie->bridge_sw_init_set = data->bridge_sw_init_set;
|
||||
pcie->has_phy = data->has_phy;
|
||||
pcie->num_inbound_wins = data->num_inbound_wins;
|
||||
|
||||
pcie->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(pcie->base))
|
||||
@ -1606,25 +1823,52 @@ static int brcm_pcie_probe(struct platform_device *pdev)
|
||||
|
||||
pcie->ssc = of_property_read_bool(np, "brcm,enable-ssc");
|
||||
|
||||
ret = clk_prepare_enable(pcie->clk);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "could not enable clock\n");
|
||||
return ret;
|
||||
}
|
||||
pcie->rescal = devm_reset_control_get_optional_shared(&pdev->dev, "rescal");
|
||||
if (IS_ERR(pcie->rescal)) {
|
||||
clk_disable_unprepare(pcie->clk);
|
||||
if (IS_ERR(pcie->rescal))
|
||||
return PTR_ERR(pcie->rescal);
|
||||
}
|
||||
|
||||
pcie->perst_reset = devm_reset_control_get_optional_exclusive(&pdev->dev, "perst");
|
||||
if (IS_ERR(pcie->perst_reset)) {
|
||||
clk_disable_unprepare(pcie->clk);
|
||||
if (IS_ERR(pcie->perst_reset))
|
||||
return PTR_ERR(pcie->perst_reset);
|
||||
|
||||
pcie->bridge_reset = devm_reset_control_get_optional_exclusive(&pdev->dev, "bridge");
|
||||
if (IS_ERR(pcie->bridge_reset))
|
||||
return PTR_ERR(pcie->bridge_reset);
|
||||
|
||||
pcie->swinit_reset = devm_reset_control_get_optional_exclusive(&pdev->dev, "swinit");
|
||||
if (IS_ERR(pcie->swinit_reset))
|
||||
return PTR_ERR(pcie->swinit_reset);
|
||||
|
||||
ret = clk_prepare_enable(pcie->clk);
|
||||
if (ret)
|
||||
return dev_err_probe(&pdev->dev, ret, "could not enable clock\n");
|
||||
|
||||
pcie->bridge_sw_init_set(pcie, 0);
|
||||
|
||||
if (pcie->swinit_reset) {
|
||||
ret = reset_control_assert(pcie->swinit_reset);
|
||||
if (ret) {
|
||||
clk_disable_unprepare(pcie->clk);
|
||||
return dev_err_probe(&pdev->dev, ret,
|
||||
"could not assert reset 'swinit'\n");
|
||||
}
|
||||
|
||||
/* HW team recommends 1us for proper sync and propagation of reset */
|
||||
udelay(1);
|
||||
|
||||
ret = reset_control_deassert(pcie->swinit_reset);
|
||||
if (ret) {
|
||||
clk_disable_unprepare(pcie->clk);
|
||||
return dev_err_probe(&pdev->dev, ret,
|
||||
"could not de-assert reset 'swinit'\n");
|
||||
}
|
||||
}
|
||||
|
||||
ret = reset_control_reset(pcie->rescal);
|
||||
if (ret)
|
||||
dev_err(&pdev->dev, "failed to deassert 'rescal'\n");
|
||||
if (ret) {
|
||||
clk_disable_unprepare(pcie->clk);
|
||||
return dev_err_probe(&pdev->dev, ret, "failed to deassert 'rescal'\n");
|
||||
}
|
||||
|
||||
ret = brcm_phy_start(pcie);
|
||||
if (ret) {
|
||||
@ -1638,7 +1882,7 @@ static int brcm_pcie_probe(struct platform_device *pdev)
|
||||
goto fail;
|
||||
|
||||
pcie->hw_rev = readl(pcie->base + PCIE_MISC_REVISION);
|
||||
if (pcie->type == BCM4908 && pcie->hw_rev >= BRCM_PCIE_HW_REV_3_20) {
|
||||
if (pcie->soc_base == BCM4908 && pcie->hw_rev >= BRCM_PCIE_HW_REV_3_20) {
|
||||
dev_err(pcie->dev, "hardware revision with unsupported PERST# setup\n");
|
||||
ret = -ENODEV;
|
||||
goto fail;
|
||||
@ -1653,7 +1897,7 @@ static int brcm_pcie_probe(struct platform_device *pdev)
|
||||
}
|
||||
}
|
||||
|
||||
bridge->ops = pcie->type == BCM7425 ? &brcm7425_pcie_ops : &brcm_pcie_ops;
|
||||
bridge->ops = pcie->soc_base == BCM7425 ? &brcm7425_pcie_ops : &brcm_pcie_ops;
|
||||
bridge->sysdata = pcie;
|
||||
|
||||
platform_set_drvdata(pdev, pcie);
|
||||
@ -1671,6 +1915,7 @@ static int brcm_pcie_probe(struct platform_device *pdev)
|
||||
|
||||
fail:
|
||||
__brcm_pcie_remove(pcie);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user