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
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
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
18 changes: 17 additions & 1 deletion drivers/power/sequencing/pwrseq-qcom-wcn.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/gpio/consumer.h>
#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/soc/google/gs201-aoc.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/property.h>
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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");
Expand Down
27 changes: 21 additions & 6 deletions drivers/soc/google/aoc/aoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <linux/mutex.h>
#include <linux/soc/google/gs201-aoc-sysmmu.h>
#include <linux/soc/google/gsa.h>
#include <linux/soc/google/gs201-aoc.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>

Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
38 changes: 38 additions & 0 deletions include/linux/soc/google/gs201-aoc.h
Original file line number Diff line number Diff line change
@@ -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 <linux/device.h>
#include <linux/errno.h>
#include <linux/kconfig.h>
#include <linux/of.h>

#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