Skip to content

Commit 3ac7f14

Browse files
mranostaykwilczynski
authored andcommitted
PCI: j721e: Add per platform maximum lane settings
Various platforms have different maximum amount of lanes that can be selected. Add max_lanes to struct j721e_pcie to allow for detection of this which is needed to calculate the needed bitmask size for the possible lane count. Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Matt Ranostay <[email protected]> Signed-off-by: Achal Verma <[email protected]> Signed-off-by: Siddharth Vadapalli <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Ravi Gunasekaran <[email protected]>
1 parent adc14d4 commit 3ac7f14

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/pci/controller/cadence/pci-j721e.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ enum link_status {
4747

4848
#define GENERATION_SEL_MASK GENMASK(1, 0)
4949

50-
#define MAX_LANES 2
51-
5250
struct j721e_pcie {
5351
struct cdns_pcie *cdns_pcie;
5452
struct clk *refclk;
@@ -71,6 +69,7 @@ struct j721e_pcie_data {
7169
unsigned int quirk_disable_flr:1;
7270
u32 linkdown_irq_regfield;
7371
unsigned int byte_access_allowed:1;
72+
unsigned int max_lanes;
7473
};
7574

7675
static inline u32 j721e_pcie_user_readl(struct j721e_pcie *pcie, u32 offset)
@@ -290,35 +289,41 @@ static const struct j721e_pcie_data j721e_pcie_rc_data = {
290289
.quirk_retrain_flag = true,
291290
.byte_access_allowed = false,
292291
.linkdown_irq_regfield = LINK_DOWN,
292+
.max_lanes = 2,
293293
};
294294

295295
static const struct j721e_pcie_data j721e_pcie_ep_data = {
296296
.mode = PCI_MODE_EP,
297297
.linkdown_irq_regfield = LINK_DOWN,
298+
.max_lanes = 2,
298299
};
299300

300301
static const struct j721e_pcie_data j7200_pcie_rc_data = {
301302
.mode = PCI_MODE_RC,
302303
.quirk_detect_quiet_flag = true,
303304
.linkdown_irq_regfield = J7200_LINK_DOWN,
304305
.byte_access_allowed = true,
306+
.max_lanes = 2,
305307
};
306308

307309
static const struct j721e_pcie_data j7200_pcie_ep_data = {
308310
.mode = PCI_MODE_EP,
309311
.quirk_detect_quiet_flag = true,
310312
.quirk_disable_flr = true,
313+
.max_lanes = 2,
311314
};
312315

313316
static const struct j721e_pcie_data am64_pcie_rc_data = {
314317
.mode = PCI_MODE_RC,
315318
.linkdown_irq_regfield = J7200_LINK_DOWN,
316319
.byte_access_allowed = true,
320+
.max_lanes = 1,
317321
};
318322

319323
static const struct j721e_pcie_data am64_pcie_ep_data = {
320324
.mode = PCI_MODE_EP,
321325
.linkdown_irq_regfield = J7200_LINK_DOWN,
326+
.max_lanes = 1,
322327
};
323328

324329
static const struct of_device_id of_j721e_pcie_match[] = {
@@ -432,8 +437,10 @@ static int j721e_pcie_probe(struct platform_device *pdev)
432437
pcie->user_cfg_base = base;
433438

434439
ret = of_property_read_u32(node, "num-lanes", &num_lanes);
435-
if (ret || num_lanes > MAX_LANES)
440+
if (ret || num_lanes > data->max_lanes) {
441+
dev_warn(dev, "num-lanes property not provided or invalid, setting num-lanes to 1\n");
436442
num_lanes = 1;
443+
}
437444
pcie->num_lanes = num_lanes;
438445

439446
if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48)))

0 commit comments

Comments
 (0)