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/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/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