diff --git a/Documentation/devicetree/bindings/pci/google,gs201-pcie.yaml b/Documentation/devicetree/bindings/pci/google,gs201-pcie.yaml index 19181b1434..c9d9fcff32 100644 --- a/Documentation/devicetree/bindings/pci/google,gs201-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/google,gs201-pcie.yaml @@ -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: @@ -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 diff --git a/Documentation/devicetree/bindings/regulator/qcom,qca6390-pmu.yaml b/Documentation/devicetree/bindings/regulator/qcom,qca6390-pmu.yaml index 105174df7d..8c3f9cf060 100644 --- a/Documentation/devicetree/bindings/regulator/qcom,qca6390-pmu.yaml +++ b/Documentation/devicetree/bindings/regulator/qcom,qca6390-pmu.yaml @@ -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 diff --git a/arch/arm64/boot/dts/exynos/google/gs201-lynx.dts b/arch/arm64/boot/dts/exynos/google/gs201-lynx.dts index b43ff60bad..bfdfa02c40 100644 --- a/arch/arm64/boot/dts/exynos/google/gs201-lynx.dts +++ b/arch/arm64/boot/dts/exynos/google/gs201-lynx.dts @@ -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"; @@ -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 = ; + samsung,pin-val = <0>; + samsung,pin-pud = ; + samsung,pin-drv = ; + }; +}; + +/* 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 { diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig index f5226c8db0..0b50af4158 100644 --- a/drivers/pci/controller/dwc/Kconfig +++ b/drivers/pci/controller/dwc/Kconfig @@ -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 diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index f5a38e6fd8..31e1566647 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -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) diff --git a/drivers/pci/controller/dwc/pcie-gs201.c b/drivers/pci/controller/dwc/pcie-gs201.c index b114c6be96..89a2552bb3 100644 --- a/drivers/pci/controller/dwc/pcie-gs201.c +++ b/drivers/pci/controller/dwc/pcie-gs201.c @@ -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 @@ -40,6 +40,7 @@ #include #include #include +#include #include "pcie-designware.h" @@ -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 @@ -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 { @@ -203,6 +207,7 @@ struct gs201_pcie { bool phy_on; int irq; struct irq_domain *intx_domain; + bool msi_ready; raw_spinlock_t lock; }; @@ -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 */ @@ -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) @@ -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"); } @@ -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); } @@ -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); /* @@ -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); @@ -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); @@ -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); } @@ -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; @@ -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], @@ -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, }; @@ -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 }, diff --git a/drivers/power/sequencing/Kconfig b/drivers/power/sequencing/Kconfig index 226c62704d..fc87fc87c1 100644 --- a/drivers/power/sequencing/Kconfig +++ b/drivers/power/sequencing/Kconfig @@ -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. diff --git a/drivers/power/sequencing/pwrseq-qcom-wcn.c b/drivers/power/sequencing/pwrseq-qcom-wcn.c index d41793e1fc..27822b511d 100644 --- a/drivers/power/sequencing/pwrseq-qcom-wcn.c +++ b/drivers/power/sequencing/pwrseq-qcom-wcn.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,7 @@ struct pwrseq_qcom_wcn_pdata { }; struct pwrseq_qcom_wcn_ctx { + struct device *dev; struct pwrseq_device *pwrseq; struct device_node *of_node; const struct pwrseq_qcom_wcn_pdata *pdata; @@ -200,8 +202,15 @@ static const struct pwrseq_unit_data pwrseq_qcom_wcn6855_bt_unit_data = { static int pwrseq_qcom_wcn_wlan_enable(struct pwrseq_device *pwrseq) { struct pwrseq_qcom_wcn_ctx *ctx = pwrseq_device_get_drvdata(pwrseq); + int ret; pwrseq_qcom_wcn_ensure_gpio_delay(ctx); + ret = gs201_aoc_require_online(ctx->dev); + if (ret) + return ret; + if (of_find_property(ctx->of_node, "google,aoc", NULL)) + dev_info(ctx->dev, "AoC online; asserting WLAN_EN\n"); + gpiod_set_value_cansleep(ctx->wlan_gpio, 1); ctx->last_gpio_enable_jf = jiffies; @@ -461,11 +470,17 @@ static int pwrseq_qcom_wcn_probe(struct platform_device *pdev) struct pwrseq_config config; int i, ret; + /* The GPIO acquisition below preserves its level: defer before that too. */ + ret = gs201_aoc_require_online(dev); + if (ret) + return dev_err_probe(dev, ret, "AoC firmware is not online\n"); + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM; ctx->of_node = dev->of_node; + ctx->dev = dev; ctx->pdata = device_get_match_data(dev); if (!ctx->pdata) @@ -504,7 +519,8 @@ static int pwrseq_qcom_wcn_probe(struct platform_device *pdev) * the link down handling is implemented in the controller driver. */ ctx->wlan_gpio = devm_gpiod_get_optional(dev, "wlan-enable", - GPIOD_ASIS); + of_find_property(dev->of_node, "google,aoc", NULL) ? + GPIOD_OUT_LOW : GPIOD_ASIS); if (IS_ERR(ctx->wlan_gpio)) return dev_err_probe(dev, PTR_ERR(ctx->wlan_gpio), "Failed to get the WLAN enable GPIO\n"); diff --git a/drivers/soc/google/aoc/aoc.c b/drivers/soc/google/aoc/aoc.c index 366bdca832..9a9bc9ed16 100644 --- a/drivers/soc/google/aoc/aoc.c +++ b/drivers/soc/google/aoc/aoc.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -66,6 +67,16 @@ enum AOC_FW_STATE aoc_state; struct platform_device *aoc_platform_device; +bool gs201_aoc_firmware_online(const struct device_node *np) +{ + struct platform_device *pdev = READ_ONCE(aoc_platform_device); + + /* No MMIO or access to the protected firmware carve-out. */ + return pdev && pdev->dev.of_node == np && + READ_ONCE(aoc_state) == AOC_STATE_ONLINE; +} +EXPORT_SYMBOL_GPL(gs201_aoc_firmware_online); + /* TODO: Reduce the global variables (move into a driver structure) */ /* Resources found from the device tree */ struct resource *aoc_sram_resource; @@ -2751,8 +2762,7 @@ static int aoc_platform_probe(struct platform_device *pdev) rc = find_gsa_device(prvdata); if (rc) { - dev_err(dev, "Failed to initialize gsa device: %d\n", rc); - rc = -EINVAL; + dev_err_probe(dev, rc, "failed to initialize GSA device\n"); goto err_failed_prvdata_alloc; } @@ -2838,10 +2848,15 @@ static int aoc_platform_probe(struct platform_device *pdev) goto err_watchdog_iommu_irq; } } - prvdata->chipid_virt = - devm_platform_ioremap_resource_byname(pdev, "chipid"); - if (IS_ERR(prvdata->chipid_virt)) { - rc = PTR_ERR(prvdata->chipid_virt); + /* exynos-chipid owns this read-only range; do not claim it again. */ + rsrc = platform_get_resource_byname(pdev, IORESOURCE_MEM, "chipid"); + if (!rsrc) { + rc = -EINVAL; + goto err_watchdog_iommu_irq; + } + prvdata->chipid_virt = devm_ioremap(dev, rsrc->start, resource_size(rsrc)); + if (!prvdata->chipid_virt) { + rc = -ENOMEM; goto err_watchdog_iommu_irq; } aoc_chipid_virt = prvdata->chipid_virt; diff --git a/drivers/trusty/trusty-ipc.c b/drivers/trusty/trusty-ipc.c index 470089df6d..1010b64448 100644 --- a/drivers/trusty/trusty-ipc.c +++ b/drivers/trusty/trusty-ipc.c @@ -432,6 +432,15 @@ static struct tipc_msg_buf *vds_get_txbuf(struct tipc_virtio_dev *vds, return mb; } +/* Trusty descriptors contain shared-memory handles, not physical addresses. */ +static void tipc_msg_buf_sg(struct scatterlist *sg, struct tipc_msg_buf *mb, + size_t len) +{ + sg_init_one(sg, mb->buf_va, len); + sg_dma_address(sg) = mb->buf_id; + sg_dma_len(sg) = len; +} + static int vds_queue_txbuf(struct tipc_virtio_dev *vds, struct tipc_msg_buf *mb) { @@ -441,8 +450,8 @@ static int vds_queue_txbuf(struct tipc_virtio_dev *vds, mutex_lock(&vds->lock); if (vds->state == VDS_ONLINE) { - sg_init_one(&sg, mb, mb->wpos); - err = virtqueue_add_outbuf(vds->txvq, &sg, 1, mb, GFP_KERNEL); + tipc_msg_buf_sg(&sg, mb, mb->wpos); + err = virtqueue_add_outbuf_premapped(vds->txvq, &sg, 1, mb, GFP_KERNEL); need_notify = virtqueue_kick_prepare(vds->txvq); } else { err = -ENODEV; @@ -2089,8 +2098,8 @@ static int _handle_rxbuf(struct tipc_virtio_dev *vds, drop_it: /* add the buffer back to the virtqueue */ - sg_init_one(&sg, rxbuf, rxbuf->buf_sz); - err = virtqueue_add_inbuf(vds->rxvq, &sg, 1, rxbuf, GFP_KERNEL); + tipc_msg_buf_sg(&sg, rxbuf, rxbuf->buf_sz); + err = virtqueue_add_inbuf_premapped(vds->rxvq, &sg, 1, rxbuf, NULL, GFP_KERNEL); if (err < 0) { dev_err(dev, "failed to add a virtqueue buffer: %d\n", err); return err; @@ -2201,8 +2210,8 @@ static int tipc_virtio_probe(struct virtio_device *vdev) goto err_free_rx_buffers; } - sg_init_one(&sg, rxbuf, rxbuf->buf_sz); - err = virtqueue_add_inbuf(vds->rxvq, &sg, 1, rxbuf, GFP_KERNEL); + tipc_msg_buf_sg(&sg, rxbuf, rxbuf->buf_sz); + err = virtqueue_add_inbuf_premapped(vds->rxvq, &sg, 1, rxbuf, NULL, GFP_KERNEL); WARN_ON(err); /* sanity check; this can't really happen */ } diff --git a/drivers/trusty/trusty-virtio.c b/drivers/trusty/trusty-virtio.c index ae70fd4d74..bb50db5b94 100644 --- a/drivers/trusty/trusty-virtio.c +++ b/drivers/trusty/trusty-virtio.c @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -232,8 +231,8 @@ static int trusty_virtio_finalize_features(struct virtio_device *vdev) u64 features = vdev->features; /* - * We set VIRTIO_F_ACCESS_PLATFORM to enable the dma mapping hooks. - * The other side does not need to know. + * IPC buffers are already shared with Trusty and use the premapped + * virtqueue API. Keep the local mapping feature out of its feature word. */ features &= ~(1ULL << VIRTIO_F_ACCESS_PLATFORM); @@ -699,24 +698,6 @@ static int trusty_virtio_add_devices(struct trusty_ctx *tctx) return ret; } -/* - * The IPC driver maps its message buffers through this device; the "DMA - * address" handed to Trusty is the buffer's shared memory id. - */ -static dma_addr_t trusty_virtio_dma_map_phys(struct device *dev, - phys_addr_t phys, size_t size, - enum dma_data_direction dir, - unsigned long attrs) -{ - struct tipc_msg_buf *buf = phys_to_virt(phys); - - return buf->buf_id; -} - -static const struct dma_map_ops trusty_virtio_dma_map_ops = { - .map_phys = trusty_virtio_dma_map_phys, -}; - static int trusty_virtio_probe(struct platform_device *pdev) { int ret; @@ -734,8 +715,6 @@ static int trusty_virtio_probe(struct platform_device *pdev) INIT_WORK(&tctx->kick_vqs, kick_vqs); platform_set_drvdata(pdev, tctx); - set_dma_ops(&pdev->dev, &trusty_virtio_dma_map_ops); - tctx->check_wq = alloc_workqueue("trusty-check-wq", WQ_UNBOUND | WQ_HIGHPRI, 0); if (!tctx->check_wq) { diff --git a/include/linux/soc/google/gs201-aoc.h b/include/linux/soc/google/gs201-aoc.h new file mode 100644 index 0000000000..894c441d20 --- /dev/null +++ b/include/linux/soc/google/gs201-aoc.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _LINUX_SOC_GOOGLE_GS201_AOC_H +#define _LINUX_SOC_GOOGLE_GS201_AOC_H + +#include +#include +#include +#include + +#if IS_REACHABLE(CONFIG_GS201_AOC) +bool gs201_aoc_firmware_online(const struct device_node *np); +#else +static inline bool gs201_aoc_firmware_online(const struct device_node *np) +{ + return false; +} +#endif + +/* Optional for other boards; a malformed dependency must not permit power. */ +static inline int gs201_aoc_require_online(struct device *dev) +{ + struct device_node *np; + + if (!of_find_property(dev->of_node, "google,aoc", NULL)) + return 0; + + np = of_parse_phandle(dev->of_node, "google,aoc", 0); + if (!np) + return -EINVAL; + if (!gs201_aoc_firmware_online(np)) { + of_node_put(np); + return -EPROBE_DEFER; + } + of_node_put(np); + return 0; +} + +#endif