Skip to content
Draft
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
16 changes: 16 additions & 0 deletions Documentation/devicetree/bindings/pci/google,gs201-pcie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ description:
the controller interrupt by a child interrupt controller.

allOf:
- if:
properties:
compatible:
contains:
const: google,gs201-lynx-pcie
then:
required:
- google,aoc
- $ref: /schemas/pci/pci-host-bridge.yaml#
- $ref: /schemas/pci/snps,dw-pcie-common.yaml#
- if:
Expand All @@ -45,6 +53,14 @@ properties:
- items:
- const: google,zumapro-pcie
- const: google,zuma-pcie
- items:
- const: google,gs201-lynx-pcie
- const: google,gs201-pcie

google,aoc:
$ref: /schemas/types.yaml#/definitions/phandle
description:
AoC whose firmware must be online before powering the WLAN endpoint.

reg:
minItems: 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ properties:
vdd-supply:
description: VDD supply regulator handle

google,aoc:
$ref: /schemas/types.yaml#/definitions/phandle
description:
AoC supplying the WLAN boot strap. Its firmware must be online before
acquiring the enable GPIO or enabling the WLAN target.

vddaon-supply:
description: VDD_AON supply regulator handle

Expand Down
42 changes: 41 additions & 1 deletion arch/arm64/boot/dts/exynos/google/gs201-lynx.dts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
regulator-always-on;
};

wcn6855-pmu {
lynx_wcn_pmu: wcn6855-pmu {
compatible = "qcom,wcn6855-pmu";
pinctrl-0 = <&bt_reg_on>;
pinctrl-names = "default";
Expand Down Expand Up @@ -269,6 +269,46 @@
/* gph2 (the buck's GPIO) is on HSI2, disabled in gs201.dtsi. */
&pinctrl_hsi2 {
status = "okay";

lynx_wlan_low: wlan-low-pins {
samsung,pins = "gph2-4";
samsung,pin-function = <GS101_PIN_FUNC_OUTPUT>;
samsung,pin-val = <0>;
samsung,pin-pud = <GS101_PIN_PULL_NONE>;
samsung,pin-drv = <GS101_PIN_DRV_2_5_MA>;
};
};

/* Bench only: disabled until an attended, watchdog-protected test. */
&pcie_1 {
status = "disabled";
compatible = "google,gs201-lynx-pcie", "google,gs201-pcie";
google,aoc = <&aoc>;

pcie@0,0 {
compatible = "pciclass,0604";
device_type = "pci";
reg = <0 0 0 0 0>;
bus-range = <0x01 0xff>;
#address-cells = <3>;
#size-cells = <2>;
ranges;

wifi@0,0 {
compatible = "pci17cb,1103";
reg = <0x10000 0 0 0 0>;
qcom,ath11k-calibration-variant = "google,gs201-lynx";
vddrfacmn-supply = <&vreg_pmu_rfa_cmn_0p8>;
vddaon-supply = <&vreg_pmu_aon_0p8>;
vddwlcx-supply = <&vreg_pmu_wlcx_0p8>;
vddwlmx-supply = <&vreg_pmu_wlmx_0p8>;
vddrfa0p8-supply = <&vreg_pmu_rfa_0p8>;
vddrfa1p2-supply = <&vreg_pmu_rfa_1p2>;
vddrfa1p8-supply = <&vreg_pmu_rfa_1p7>;
vddpcie0p9-supply = <&vreg_pmu_pcie_0p9>;
vddpcie1p8-supply = <&vreg_pmu_pcie_1p8>;
};
};
};

&pinctrl_peric0 {
Expand Down
1 change: 1 addition & 0 deletions drivers/pci/controller/dwc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ config PCIE_GS201
tristate "Google gs201 PCIe controller (host mode)"
depends on OF && (ARCH_EXYNOS || COMPILE_TEST)
depends on PCI_MSI
depends on GS201_AOC || !GS201_AOC
select PCIE_DW_HOST
select PCI_PWRCTRL_GENERIC
help
Expand Down
1 change: 1 addition & 0 deletions drivers/pci/controller/dwc/pcie-designware-host.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ void dw_handle_msi_irq(struct dw_pcie_rp *pp)
generic_handle_demux_domain_irq(pp->irq_domain, irq_off + pos);
}
}
EXPORT_SYMBOL_GPL(dw_handle_msi_irq);

/* Chained MSI interrupt service routine */
static void dw_chained_msi_isr(struct irq_desc *desc)
Expand Down
110 changes: 101 additions & 9 deletions drivers/pci/controller/dwc/pcie-gs201.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* controller/dwc-whi/pcie-exynos-rc.c (exynos_pcie_rc_resumed_phydown(),
* exynos_pcie_rc_poweron() and exynos_pcie_rc_establish_link()).
*
* Only legacy INTx interrupts are supported, which is what the Pixel 7 Wi-Fi
* uses on stock firmware too.
* Pixel 7 Wi-Fi uses legacy INTx. Pixel 7a uses the DWC iMSI-RX, demuxed
* from the shared ELBI interrupt after link reset has completed.
*
* Bring-up runs in numbered stages, each touching one more part of the
* hardware. The stop_after parameter ends probe after a given stage, and
Expand Down Expand Up @@ -40,6 +40,7 @@
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/soc/google/gs201-aoc.h>

#include "pcie-designware.h"

Expand All @@ -53,6 +54,7 @@
#define GS201_ELBI_IRQ1_LINK_DOWN BIT(10)
#define GS201_ELBI_IRQ2 0x008
#define GS201_ELBI_IRQ2_CPL_TIMEOUT BIT(24)
#define GS201_ELBI_IRQ2_MSI_RISING BIT(17)
#define GS201_ELBI_IRQ0_EN 0x010
#define GS201_ELBI_IRQ1_EN 0x014
#define GS201_ELBI_IRQ2_EN 0x018
Expand Down Expand Up @@ -176,10 +178,12 @@ MODULE_PARM_DESC(cmu_acg_off,
* the soft power reset before the PHY powers down, as Google's
* exynos_pcie_rc_poweroff() does for the zuma family. Only zumapro so
* far: it hasn't run on a zuma board here.
* @wcn_msi: lynx's WCN endpoint requires iMSI-RX and online AoC firmware
*/
struct gs201_pcie_soc_data {
bool ctrl_reset_before_phy;
bool pwr_reset_before_phy_off;
bool wcn_msi;
};

struct gs201_pcie {
Expand All @@ -203,6 +207,7 @@ struct gs201_pcie {
bool phy_on;
int irq;
struct irq_domain *intx_domain;
bool msi_ready;
raw_spinlock_t lock;
};

Expand Down Expand Up @@ -439,8 +444,10 @@ static bool gs201_pcie_link_up(struct dw_pcie *pci)
ltssm <= DW_PCIE_LTSSM_L1_IDLE;
}

static void gs201_pcie_enable_irqs(struct gs201_pcie *gp)
static int gs201_pcie_enable_irqs(struct gs201_pcie *gp)
{
u32 enabled;

gs201_trace(gp, "about to clear ELBI IRQ0-2 and enable link-down and completion-timeout interrupts");

/* Clear anything latched during training */
Expand All @@ -453,6 +460,21 @@ static void gs201_pcie_enable_irqs(struct gs201_pcie *gp)

gs201_elbi_rmw(gp, GS201_ELBI_IRQ1_EN, 0, GS201_ELBI_IRQ1_LINK_DOWN);
gs201_elbi_rmw(gp, GS201_ELBI_IRQ2_EN, 0, GS201_ELBI_IRQ2_CPL_TIMEOUT);
/* Link soft reset clears this bit too. Arm only after the link is up. */
if (gp->data->wcn_msi) {
if (upper_32_bits(gp->pci.pp.msi_data))
return dev_err_probe(gp->pci.dev, -ERANGE,
"MSI target exceeds 32 bits\n");
gs201_elbi_rmw(gp, GS201_ELBI_IRQ2_EN, 0,
GS201_ELBI_IRQ2_MSI_RISING);
enabled = gs201_elbi_readl(gp, GS201_ELBI_IRQ2_EN);
if (!(enabled & GS201_ELBI_IRQ2_MSI_RISING))
return dev_err_probe(gp->pci.dev, -EIO,
"MSI interrupt enable did not latch\n");
dev_info(gp->pci.dev, "MSI armed after link up, ELBI IRQ2_EN %#x\n",
enabled);
}
return 0;
}

static void gs201_pcie_disable_irqs(struct gs201_pcie *gp)
Expand Down Expand Up @@ -816,14 +838,22 @@ static int gs201_pcie_start_link(struct dw_pcie *pci)
return ret;
}

/*
* Leave the LTSSM running even on failure: dw_pcie_wait_for_link()
* reports the final state, and a card that shows up late can still
* train.
*/
/* MSI must be armed before the DWC core can enumerate an endpoint. */
if (ret && gp->data->wcn_msi)
return ret;

/* The existing INTx path permits a card to train during DWC's wait. */
if (!ret) {
dev_info(dev, "link up on try %u\n", try);
gs201_pcie_enable_irqs(gp);
/* Publish the initialized MSI domain before the handler uses it. */
smp_store_release(&gp->msi_ready, gp->data->wcn_msi);
ret = gs201_pcie_enable_irqs(gp);
if (ret) {
WRITE_ONCE(gp->msi_ready, false);
gs201_pcie_disable_irqs(gp);
synchronize_irq(gp->irq);
return ret;
}
gs201_pcie_check_iocc(gp, "after link up");
}

Expand All @@ -839,7 +869,10 @@ static void gs201_pcie_stop_link(struct dw_pcie *pci)
{
struct gs201_pcie *gp = to_gs201_pcie(pci);

WRITE_ONCE(gp->msi_ready, false);
gs201_pcie_disable_irqs(gp);
if (gp->data->wcn_msi)
synchronize_irq(gp->irq);
gs201_elbi_writel(gp, GS201_ELBI_LTSSM_EN, 0);
}

Expand All @@ -850,6 +883,33 @@ static const struct dw_pcie_ops gs201_pcie_dw_ops = {
.stop_link = gs201_pcie_stop_link,
};

static void gs201_pcie_handle_msi(struct gs201_pcie *gp)
{
struct dw_pcie_rp *pp = &gp->pci.pp;
unsigned long flags;
unsigned int ctrl, num_ctrls;
u32 offset;

dw_handle_msi_irq(pp);

/*
* The wrapper latches a rising edge, while iMSI-RX remains asserted
* until all unmasked status bits are cleared. A lower vector arriving
* while an upper vector is handled can miss the status snapshot and
* leave the line high without another edge. As Google's combined-MSI
* handler does, pulse the mask to re-pend it. Preserve Linux's masks
* under the same lock used by the DWC IRQ chip's mask/unmask paths.
*/
num_ctrls = pp->num_vectors / MAX_MSI_IRQS_PER_CTRL;
raw_spin_lock_irqsave(&pp->lock, flags);
for (ctrl = 0; ctrl < num_ctrls; ctrl++) {
offset = PCIE_MSI_INTR0_MASK + ctrl * MSI_REG_CTRL_BLOCK_SIZE;
dw_pcie_writel_dbi(&gp->pci, offset, U32_MAX);
dw_pcie_writel_dbi(&gp->pci, offset, pp->irq_mask[ctrl]);
}
raw_spin_unlock_irqrestore(&pp->lock, flags);
}

static void gs201_pcie_irq_handler(struct irq_desc *desc);

/*
Expand All @@ -865,6 +925,10 @@ static int gs201_pcie_host_init(struct dw_pcie_rp *pp)
struct device *dev = pci->dev;
int ret;

ret = gs201_aoc_require_online(dev);
if (ret)
return ret;

gpiod_set_value_cansleep(gp->perst, 1);

ret = gs201_pcie_bringup(gp, GS201_STAGE_WAKE, false);
Expand Down Expand Up @@ -951,6 +1015,11 @@ static const struct dw_pcie_host_ops gs201_pcie_host_ops = {
.msi_init = gs201_pcie_msi_init,
};

static const struct dw_pcie_host_ops gs201_pcie_host_ops_msi = {
.init = gs201_pcie_host_init,
.deinit = gs201_pcie_host_deinit,
};

static void gs201_pcie_intx_mask(struct irq_data *d)
{
struct gs201_pcie *gp = irq_data_get_irq_chip_data(d);
Expand Down Expand Up @@ -1026,6 +1095,11 @@ static void gs201_pcie_irq_handler(struct irq_desc *desc)
for_each_set_bit(bit, &intx, PCI_NUM_INTX)
generic_handle_domain_irq(gp->intx_domain, bit);

/* DWC owns the MSI domain; our handler owns the shared interrupt. */
/* Pairs with publication after link training, before IRQ enable. */
if (smp_load_acquire(&gp->msi_ready))
gs201_pcie_handle_msi(gp);

chained_irq_exit(chip, desc);
}

Expand Down Expand Up @@ -1164,6 +1238,10 @@ static int gs201_pcie_probe(struct platform_device *pdev)
struct resource *res;
int ret;

ret = gs201_aoc_require_online(dev);
if (ret)
return dev_err_probe(dev, ret, "AoC firmware is not online\n");

gp = devm_kzalloc(dev, sizeof(*gp), GFP_KERNEL);
if (!gp)
return -ENOMEM;
Expand All @@ -1175,6 +1253,15 @@ static int gs201_pcie_probe(struct platform_device *pdev)
pci->dev = dev;
pci->ops = &gs201_pcie_dw_ops;
pci->pp.ops = &gs201_pcie_host_ops;
if (gp->data->wcn_msi) {
if (!pci_msi_enabled())
return dev_err_probe(dev, -ENODEV, "lynx requires PCI MSI\n");
if (!of_find_property(np, "google,aoc", NULL))
return dev_err_probe(dev, -EINVAL, "missing AoC dependency\n");
pci->pp.ops = &gs201_pcie_host_ops_msi;
pci->pp.msi_irq[0] = -ENXIO;
pci->pp.num_vectors = MAX_MSI_IRQS_PER_CTRL;
}

dev_info(dev, "stage 0/%u: %s (stop_after=%u, trace=%d, use_ia=%d, cmu_acg_off=%d)\n",
GS201_STAGE_LINK, gs201_stage_names[GS201_STAGE_NONE],
Expand Down Expand Up @@ -1258,6 +1345,10 @@ static void gs201_pcie_remove(struct platform_device *pdev)
static const struct gs201_pcie_soc_data gs201_pcie_data = {
};

static const struct gs201_pcie_soc_data lynx_pcie_data = {
.wcn_msi = true,
};

static const struct gs201_pcie_soc_data zuma_pcie_data = {
.ctrl_reset_before_phy = true,
};
Expand All @@ -1268,6 +1359,7 @@ static const struct gs201_pcie_soc_data zumapro_pcie_data = {
};

static const struct of_device_id gs201_pcie_of_match[] = {
{ .compatible = "google,gs201-lynx-pcie", .data = &lynx_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
1 change: 1 addition & 0 deletions drivers/power/sequencing/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ config POWER_SEQUENCING_QCOM_WCN
tristate "Qualcomm WCN family PMU driver"
default m if ARCH_QCOM
depends on OF || COMPILE_TEST
depends on GS201_AOC || !GS201_AOC
help
Say Y here to enable the power sequencing driver for Qualcomm
WCN Bluetooth/WLAN chipsets.
Expand Down
Loading