Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions Documentation/devicetree/bindings/pci/google,gs201-pcie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
$id: http://devicetree.org/schemas/pci/google,gs201-pcie.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Google gs201 and zuma PCIe host controllers
title: Google gs101, gs201 and zuma PCIe host controllers

maintainers:
- Derek Ross <derekross@gmail.com>

description:
The PCIe controllers of the Google gs201 (Tensor G2) and zuma (Tensor G3)
The PCIe controllers of Google gs101 (Tensor G1), gs201 (Tensor G2) and zuma (Tensor G3)
SoCs are Synopsys DesignWare cores (IP versions 0x984500 and 0x986500) in
a Samsung wrapper. The wrapper
adds a sub-control block (ELBI) with link training control and interrupt
Expand All @@ -36,10 +36,24 @@ allOf:
reg-names:
maxItems: 3

- if:
properties:
compatible:
contains:
const: google,gs101-pcie
then:
properties:
dma-coherent: false
samsung,cmu: false
required:
- vpcie0v85-supply
- vpcie1v8-supply

properties:
compatible:
oneOf:
- enum:
- google,gs101-pcie
- google,gs201-pcie
- google,zuma-pcie
- items:
Expand Down Expand Up @@ -95,6 +109,12 @@ properties:
description:
Needed with dma-coherent, to make the controller's DMA shareable.

vpcie0v85-supply:
description: PCIe analog 0.85 V supply.

vpcie1v8-supply:
description: PCIe analog 1.8 V supply.

num-lanes:
maximum: 2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$id: http://devicetree.org/schemas/phy/google,gs201-pcie-phy.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Google gs201 PCIe PHY
title: Google gs101 / gs201 PCIe PHY

maintainers:
- Derek Ross <derekross@gmail.com>
Expand All @@ -18,7 +18,9 @@ description:

properties:
compatible:
const: google,gs201-pcie-phy
enum:
- google,gs101-pcie-phy
- google,gs201-pcie-phy

reg:
items:
Expand Down
71 changes: 69 additions & 2 deletions drivers/pci/controller/dwc/pcie-gs201.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>

#include "pcie-designware.h"

Expand Down Expand Up @@ -172,6 +173,11 @@ MODULE_PARM_DESC(cmu_acg_off,
* set before the PHY configuration, and not again after it. zuma's
* CAL does them in the middle of its PHY configuration; gs201's
* establish_link() does them after.
* @phy_supplies: acquire the controller's two analog supplies before clocks
* @skip_cmu: the CMU diagnostic window has inaccessible holes
* @noncoherent_only: coherent DMA is not qualified for this controller
* @skip_link_history: do not read unqualified history registers on failure
* @link_tries: maximum link attempts, zero for the existing default
* @pwr_reset_before_phy_off: the power-down turns the LTSSM off and pulses
* the soft power reset before the PHY powers down, as Google's
* exynos_pcie_rc_poweroff() does for the zuma family. Only zumapro so
Expand All @@ -180,6 +186,11 @@ MODULE_PARM_DESC(cmu_acg_off,
struct gs201_pcie_soc_data {
bool ctrl_reset_before_phy;
bool pwr_reset_before_phy_off;
bool phy_supplies;
bool skip_cmu;
bool noncoherent_only;
bool skip_link_history;
unsigned int link_tries;
};

struct gs201_pcie {
Expand All @@ -198,6 +209,8 @@ struct gs201_pcie {
int clks_on;
struct phy *phy;
struct gpio_desc *perst;
struct regulator_bulk_data supplies[2];
bool supplies_on;
bool coherent;
bool phy_inited;
bool phy_on;
Expand Down Expand Up @@ -510,6 +523,14 @@ static int gs201_pcie_stage_clocks(struct gs201_pcie *gp)
u32 opt;
int ret;

if (gp->data->phy_supplies && !gp->supplies_on) {
gs201_trace(gp, "enable PCIe1 LDO17/LDO19 supplies");
ret = regulator_bulk_enable(ARRAY_SIZE(gp->supplies), gp->supplies);
if (ret)
return ret;
gp->supplies_on = true;
}

if (gp->cmu) {
gs201_trace(gp, "about to read CMU_HSI2 CONTROLLER_OPTION (0x14400800)");
opt = readl(gp->cmu + GS201_CMU_OPTION);
Expand Down Expand Up @@ -767,17 +788,28 @@ static void gs201_pcie_bringdown(struct gs201_pcie *gp)
gp->phy_inited = false;
}
gs201_pcie_clocks_off(gp);
if (gp->supplies_on) {
int ret;

gs201_trace(gp, "release PCIe1 supply votes");
ret = regulator_bulk_disable(ARRAY_SIZE(gp->supplies), gp->supplies);
if (ret)
dev_err(gp->pci.dev, "supply release failed: %d\n", ret);
else
gp->supplies_on = false;
}
}

static int gs201_pcie_start_link(struct dw_pcie *pci)
{
struct gs201_pcie *gp = to_gs201_pcie(pci);
struct device *dev = pci->dev;
unsigned int tries = gp->data->link_tries ?: GS201_LINK_TRIES;
unsigned int try;
u32 val;
int ret;

for (try = 1; try <= GS201_LINK_TRIES; try++) {
for (try = 1; try <= tries; try++) {
gs201_trace(gp, "link try %u: about to write ELBI 0x054 = 1 and poll 0x2c8 for L0 (48 ms)",
try);
gs201_elbi_writel(gp, GS201_ELBI_LTSSM_EN, 1);
Expand All @@ -793,7 +825,9 @@ static int gs201_pcie_start_link(struct dw_pcie *pci)
dev_warn(dev, "link training failed (try %u), LTSSM %#lx\n",
try, FIELD_GET(GS201_ELBI_LTSSM_STATE_MASK, val));

if (try == GS201_LINK_TRIES) {
if (try == tries) {
if (gp->data->skip_link_history)
return ret;
gs201_pcie_dump_history(gp);
break;
}
Expand Down Expand Up @@ -1111,6 +1145,10 @@ static int gs201_pcie_get_cmu(struct gs201_pcie *gp)
struct resource res;
int ret;

/* gs101 has holes in the gs201 CMU gate range (including 0x20e0). */
if (gp->data->skip_cmu)
return 0;

cmu_np = of_parse_phandle(dev->of_node, "samsung,cmu", 0);
if (!cmu_np)
return 0;
Expand Down Expand Up @@ -1170,6 +1208,10 @@ static int gs201_pcie_probe(struct platform_device *pdev)

raw_spin_lock_init(&gp->lock);
gp->data = of_device_get_match_data(dev);
if (gp->data->noncoherent_only &&
(cmu_acg_off || of_dma_is_coherent(np)))
return dev_err_probe(dev, -EINVAL,
"gs101 needs noncoherent DMA and no CMU override\n");

pci = &gp->pci;
pci->dev = dev;
Expand Down Expand Up @@ -1222,6 +1264,18 @@ static int gs201_pcie_probe(struct platform_device *pdev)
return dev_err_probe(dev, PTR_ERR(gp->perst),
"failed to get PERST# GPIO\n");

if (gp->data->phy_supplies) {
if (!of_property_present(np, "vpcie0v85-supply") ||
!of_property_present(np, "vpcie1v8-supply"))
return dev_err_probe(dev, -EINVAL, "missing PCIe1 supplies\n");
gp->supplies[0].supply = "vpcie0v85";
gp->supplies[1].supply = "vpcie1v8";
ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(gp->supplies),
gp->supplies);
if (ret)
return dev_err_probe(dev, ret, "PCIe1 supplies unavailable\n");
}

/* The DWC core reads num-lanes in host_init; stages need it earlier */
if (of_property_read_u32(np, "num-lanes", &pci->num_lanes))
pci->num_lanes = 1;
Expand Down Expand Up @@ -1255,6 +1309,18 @@ static void gs201_pcie_remove(struct platform_device *pdev)
gs201_pcie_remove_irq(gp);
}

/*
* Initial GS101 bring-up qualifies one link attempt. Retry power cycles and
* failure-path link-history reads are not qualified on this controller.
*/
static const struct gs201_pcie_soc_data gs101_pcie_data = {
.phy_supplies = true,
.skip_cmu = true,
.noncoherent_only = true,
.skip_link_history = true,
.link_tries = 1,
};

static const struct gs201_pcie_soc_data gs201_pcie_data = {
};

Expand All @@ -1268,6 +1334,7 @@ static const struct gs201_pcie_soc_data zumapro_pcie_data = {
};

static const struct of_device_id gs201_pcie_of_match[] = {
{ .compatible = "google,gs101-pcie", .data = &gs101_pcie_data },
{ .compatible = "google,gs201-pcie", .data = &gs201_pcie_data },
{ .compatible = "google,zumapro-pcie", .data = &zumapro_pcie_data },
{ .compatible = "google,zuma-pcie", .data = &zuma_pcie_data },
Expand Down
Loading