|
40 | 40 | #define CORE_RC_STAT_READY BIT(0) |
41 | 41 | #define CORE_FABRIC_STAT 0x04000 |
42 | 42 | #define CORE_FABRIC_STAT_MASK 0x001F001F |
43 | | -#define CORE_LANE_CFG(port) (0x84000 + 0x4000 * (port)) |
44 | | -#define CORE_LANE_CFG_REFCLK0REQ BIT(0) |
45 | | -#define CORE_LANE_CFG_REFCLK1REQ BIT(1) |
46 | | -#define CORE_LANE_CFG_REFCLK0ACK BIT(2) |
47 | | -#define CORE_LANE_CFG_REFCLK1ACK BIT(3) |
48 | | -#define CORE_LANE_CFG_REFCLKEN (BIT(9) | BIT(10)) |
49 | | -#define CORE_LANE_CTL(port) (0x84004 + 0x4000 * (port)) |
50 | | -#define CORE_LANE_CTL_CFGACC BIT(15) |
| 43 | + |
| 44 | +#define CORE_PHY_DEFAULT_BASE(port) (0x84000 + 0x4000 * (port)) |
| 45 | + |
| 46 | +#define PHY_LANE_CFG 0x00000 |
| 47 | +#define PHY_LANE_CFG_REFCLK0REQ BIT(0) |
| 48 | +#define PHY_LANE_CFG_REFCLK1REQ BIT(1) |
| 49 | +#define PHY_LANE_CFG_REFCLK0ACK BIT(2) |
| 50 | +#define PHY_LANE_CFG_REFCLK1ACK BIT(3) |
| 51 | +#define PHY_LANE_CFG_REFCLKEN (BIT(9) | BIT(10)) |
| 52 | +#define PHY_LANE_CFG_REFCLKCGEN (BIT(30) | BIT(31)) |
| 53 | +#define PHY_LANE_CTL 0x00004 |
| 54 | +#define PHY_LANE_CTL_CFGACC BIT(15) |
51 | 55 |
|
52 | 56 | #define PORT_LTSSMCTL 0x00080 |
53 | 57 | #define PORT_LTSSMCTL_START BIT(0) |
@@ -146,6 +150,7 @@ struct apple_pcie_port { |
146 | 150 | struct apple_pcie *pcie; |
147 | 151 | struct device_node *np; |
148 | 152 | void __iomem *base; |
| 153 | + void __iomem *phy; |
149 | 154 | struct irq_domain *domain; |
150 | 155 | struct list_head entry; |
151 | 156 | DECLARE_BITMAP(sid_map, MAX_RID2SID); |
@@ -474,26 +479,26 @@ static int apple_pcie_setup_refclk(struct apple_pcie *pcie, |
474 | 479 | if (res < 0) |
475 | 480 | return res; |
476 | 481 |
|
477 | | - rmw_set(CORE_LANE_CTL_CFGACC, pcie->base + CORE_LANE_CTL(port->idx)); |
478 | | - rmw_set(CORE_LANE_CFG_REFCLK0REQ, pcie->base + CORE_LANE_CFG(port->idx)); |
| 482 | + rmw_set(PHY_LANE_CTL_CFGACC, port->phy + PHY_LANE_CTL); |
| 483 | + rmw_set(PHY_LANE_CFG_REFCLK0REQ, port->phy + PHY_LANE_CFG); |
479 | 484 |
|
480 | | - res = readl_relaxed_poll_timeout(pcie->base + CORE_LANE_CFG(port->idx), |
481 | | - stat, stat & CORE_LANE_CFG_REFCLK0ACK, |
| 485 | + res = readl_relaxed_poll_timeout(port->phy + PHY_LANE_CFG, |
| 486 | + stat, stat & PHY_LANE_CFG_REFCLK0ACK, |
482 | 487 | 100, 50000); |
483 | 488 | if (res < 0) |
484 | 489 | return res; |
485 | 490 |
|
486 | | - rmw_set(CORE_LANE_CFG_REFCLK1REQ, pcie->base + CORE_LANE_CFG(port->idx)); |
487 | | - res = readl_relaxed_poll_timeout(pcie->base + CORE_LANE_CFG(port->idx), |
488 | | - stat, stat & CORE_LANE_CFG_REFCLK1ACK, |
| 491 | + rmw_set(PHY_LANE_CFG_REFCLK1REQ, port->phy + PHY_LANE_CFG); |
| 492 | + res = readl_relaxed_poll_timeout(port->phy + PHY_LANE_CFG, |
| 493 | + stat, stat & PHY_LANE_CFG_REFCLK1ACK, |
489 | 494 | 100, 50000); |
490 | 495 |
|
491 | 496 | if (res < 0) |
492 | 497 | return res; |
493 | 498 |
|
494 | | - rmw_clear(CORE_LANE_CTL_CFGACC, pcie->base + CORE_LANE_CTL(port->idx)); |
| 499 | + rmw_clear(PHY_LANE_CTL_CFGACC, port->phy + PHY_LANE_CTL); |
495 | 500 |
|
496 | | - rmw_set(CORE_LANE_CFG_REFCLKEN, pcie->base + CORE_LANE_CFG(port->idx)); |
| 501 | + rmw_set(PHY_LANE_CFG_REFCLKEN, port->phy + PHY_LANE_CFG); |
497 | 502 | rmw_set(PORT_REFCLK_EN, port->base + PORT_REFCLK); |
498 | 503 |
|
499 | 504 | return 0; |
@@ -539,6 +544,7 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie, |
539 | 544 | struct gpio_desc *reset, *pwren = NULL; |
540 | 545 | u32 stat, idx; |
541 | 546 | int ret, i; |
| 547 | + char name[16]; |
542 | 548 |
|
543 | 549 | reset = devm_fwnode_gpiod_get(pcie->dev, of_fwnode_handle(np), "reset", |
544 | 550 | GPIOD_OUT_LOW, "PERST#"); |
@@ -567,9 +573,18 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie, |
567 | 573 | port->pcie = pcie; |
568 | 574 | port->np = np; |
569 | 575 |
|
570 | | - port->base = devm_platform_ioremap_resource(platform, port->idx + 2); |
| 576 | + snprintf(name, sizeof(name), "port%d", port->idx); |
| 577 | + port->base = devm_platform_ioremap_resource_byname(platform, name); |
571 | 578 | if (IS_ERR(port->base)) |
| 579 | + port->base = devm_platform_ioremap_resource(platform, port->idx + 2); |
| 580 | + if (IS_ERR(port->base)) { |
572 | 581 | return PTR_ERR(port->base); |
| 582 | + } |
| 583 | + |
| 584 | + snprintf(name, sizeof(name), "phy%d", port->idx); |
| 585 | + port->phy = devm_platform_ioremap_resource_byname(platform, name); |
| 586 | + if (IS_ERR(port->phy)) |
| 587 | + port->phy = pcie->base + CORE_PHY_DEFAULT_BASE(port->idx); |
573 | 588 |
|
574 | 589 | rmw_set(PORT_APPCLK_EN, port->base + PORT_APPCLK); |
575 | 590 |
|
|
0 commit comments