Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4459ee9 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm_11ad: support voltage GPIO connected to 11ad card"

parents e2831fb2 e882cffa
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ Required properties:
Optional properties:
- qcom,sleep-clk-en: GPIO for sleep clock used for low power modes by 11ad card
- qcom,wigig-en: Enable GPIO connected to 11ad card
- qcom,wigig-dc: Enable DC to DC GPIO connected to 11ad card
- qcom,use-ext-supply: Boolean flag to indicate if 11ad SIP uses external power supply
- vdd-supply: phandle to 11ad VDD regulator node
- vddio-supply: phandle to 11ad VDDIO regulator node
@@ -45,6 +46,7 @@ Example:
		qcom,smmu-mapping = <0x20000000 0xe0000000>;
		qcom,pcie-parent = <&pcie1>;
		qcom,wigig-en = <&tlmm 94 0>;
		qcom,wigig-dc = <&tlmm 81 0>;
		qcom,msm-bus,name = "wil6210";
		qcom,msm-bus,num-cases = <2>;
		qcom,msm-bus,num-paths = <1>;
+47 −4
Original line number Diff line number Diff line
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -57,6 +57,7 @@
struct device;

static const char * const gpio_en_name = "qcom,wigig-en";
static const char * const gpio_dc_name = "qcom,wigig-dc";
static const char * const sleep_clk_en_name = "qcom,sleep-clk-en";

struct wigig_pci {
@@ -90,6 +91,7 @@ struct msm11ad_ctx {
	struct list_head list;
	struct device *dev; /* for platform device */
	int gpio_en; /* card enable */
	int gpio_dc;
	int sleep_clk_en; /* sleep clock enable for low PM management */

	/* pci device */
@@ -539,6 +541,9 @@ static int msm_11ad_turn_device_power_off(struct msm11ad_ctx *ctx)
	if (ctx->gpio_en >= 0)
		gpio_direction_output(ctx->gpio_en, 0);

	if (ctx->gpio_dc >= 0)
		gpio_direction_output(ctx->gpio_dc, 0);

	if (ctx->sleep_clk_en >= 0)
		gpio_direction_output(ctx->sleep_clk_en, 0);

@@ -569,6 +574,11 @@ static int msm_11ad_turn_device_power_on(struct msm11ad_ctx *ctx)
	if (ctx->sleep_clk_en >= 0)
		gpio_direction_output(ctx->sleep_clk_en, 1);

	if (ctx->gpio_dc >= 0) {
		gpio_direction_output(ctx->gpio_dc, 1);
		msleep(WIGIG_ENABLE_DELAY);
	}

	if (ctx->gpio_en >= 0) {
		gpio_direction_output(ctx->gpio_en, 1);
		msleep(WIGIG_ENABLE_DELAY);
@@ -1060,6 +1070,7 @@ static int msm_11ad_probe(struct platform_device *pdev)
	 *	compatible = "qcom,wil6210";
	 *	qcom,pcie-parent = <&pcie1>;
	 *	qcom,wigig-en = <&tlmm 94 0>; (ctx->gpio_en)
	 *	qcom,wigig-dc = <&tlmm 81 0>; (ctx->gpio_dc)
	 *	qcom,sleep-clk-en = <&pm8994_gpios 18 0>; (ctx->sleep_clk_en)
	 *	qcom,msm-bus,name = "wil6210";
	 *	qcom,msm-bus,num-cases = <2>;
@@ -1075,7 +1086,11 @@ static int msm_11ad_probe(struct platform_device *pdev)
	 * qcom,smmu-exist;
	 */

	/* wigig-en is optional property */
	/* wigig-en and wigig-dc are optional properties */
	ctx->gpio_dc = of_get_named_gpio(of_node, gpio_dc_name, 0);
	if (ctx->gpio_dc < 0)
		dev_warn(ctx->dev, "GPIO <%s> not found, dc GPIO not used\n",
			 gpio_dc_name);
	ctx->gpio_en = of_get_named_gpio(of_node, gpio_en_name, 0);
	if (ctx->gpio_en < 0)
		dev_warn(ctx->dev, "GPIO <%s> not found, enable GPIO not used\n",
@@ -1150,6 +1165,22 @@ static int msm_11ad_probe(struct platform_device *pdev)
		goto out_vreg_clk;
	}

	if (ctx->gpio_dc >= 0) {
		rc = gpio_request(ctx->gpio_dc, gpio_dc_name);
		if (rc < 0) {
			dev_err(ctx->dev, "failed to request GPIO %d <%s>\n",
				ctx->gpio_dc, gpio_dc_name);
			goto out_req_dc;
		}
		rc = gpio_direction_output(ctx->gpio_dc, 1);
		if (rc < 0) {
			dev_err(ctx->dev, "failed to set GPIO %d <%s>\n",
				ctx->gpio_dc, gpio_dc_name);
			goto out_set_dc;
		}
		msleep(WIGIG_ENABLE_DELAY);
	}

	if (ctx->gpio_en >= 0) {
		rc = gpio_request(ctx->gpio_en, gpio_en_name);
		if (rc < 0) {
@@ -1260,12 +1291,13 @@ static int msm_11ad_probe(struct platform_device *pdev)
	/* report */
	dev_info(ctx->dev, "msm_11ad discovered. %p {\n"
		 "  gpio_en = %d\n"
		 "  gpio_dc = %d\n"
		 "  sleep_clk_en = %d\n"
		 "  rc_index = %d\n"
		 "  use_smmu = %d\n"
		 "  pcidev = %p\n"
		 "}\n", ctx, ctx->gpio_en, ctx->sleep_clk_en, ctx->rc_index,
		 ctx->use_smmu, ctx->pcidev);
		 "}\n", ctx, ctx->gpio_en, ctx->gpio_dc, ctx->sleep_clk_en,
		 ctx->rc_index, ctx->use_smmu, ctx->pcidev);

	platform_set_drvdata(pdev, ctx);
	device_disable_async_suspend(&pcidev->dev);
@@ -1285,6 +1317,13 @@ static int msm_11ad_probe(struct platform_device *pdev)
		gpio_free(ctx->gpio_en);
out_req:
	ctx->gpio_en = -EINVAL;
	if (ctx->gpio_dc >= 0)
		gpio_direction_output(ctx->gpio_dc, 0);
out_set_dc:
	if (ctx->gpio_dc >= 0)
		gpio_free(ctx->gpio_dc);
out_req_dc:
	ctx->gpio_dc = -EINVAL;
out_vreg_clk:
	msm_11ad_disable_clocks(ctx);
	msm_11ad_release_clocks(ctx);
@@ -1309,6 +1348,10 @@ static int msm_11ad_remove(struct platform_device *pdev)
		gpio_direction_output(ctx->gpio_en, 0);
		gpio_free(ctx->gpio_en);
	}
	if (ctx->gpio_dc >= 0) {
		gpio_direction_output(ctx->gpio_dc, 0);
		gpio_free(ctx->gpio_dc);
	}
	if (ctx->sleep_clk_en >= 0)
		gpio_free(ctx->sleep_clk_en);