From patchwork Mon Jun 21 22:31:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 464605 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp64268jao; Mon, 21 Jun 2021 15:31:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqLiHF6G0Lo5hUTs1lI+TwFjiECWYVcjsZT7h8lrRPySsoL2OtHfx0UAc89TzkbiQbTsyl X-Received: by 2002:a17:906:411a:: with SMTP id j26mr409120ejk.486.1624314716898; Mon, 21 Jun 2021 15:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624314716; cv=none; d=google.com; s=arc-20160816; b=BPX+kqYmKNoVDCBPetrx3w131aLYxgDL9jxd0OpDOZ2waOsWm7NKdlgjOyoBV+E11y 4oPRhPLsk47GBFofZDHxrd21eX37Kq+DC1wDt62U8Smldkgghr5L5LV9bsM5jUDrFpyB c3NOuriRkZ7v7cQY4438kXQDRoS0TKj6M2jI8TEatW/qLSuks7Be/PEYKo8Nv/Mzy8pw iAXjnCnkpdmvlk9AuuvPTIjNS8qHIFRJuuHgwXCGItvnA9xUcnJGAImCqq5Kdmrfc4cs xKhfprWYP3JJC8i3hRAirl99qtv3tf082UVBu7IiRurtoByyts2qgvew7cGFiy7kBcju +sNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wWkLC+6IHo1LkiZQZtpwJkfJ4H3Gk2cOkMI7a3h8YO8=; b=WacwEPQze7VxgvI+OR/Zdz0F2Fncq2yFIAmxAsf2BJK5avy47H1J6zieMN2boj3AHS ef6PQ5KPlfE4qRoxbHmGg+QwUdD7IitJ3VzMJzI1n/gVVYUDrmPwba+/vGHAqKQ6crEN eEGBVsazcQkGMJ3aqwxj8fCUoyH+WzoLohostW49RPAbrBWTS7P7CAXWTK0+j7CVA1Jo qur4lqIg6Z6lhWfNE7aj0sBwma8uORlwmctdE5oCSghjPSwO7iNVb1N3gpptF3688naY Fch2dL1+XfDkoIauJIQmvohPpGylcTvavXEsHU7zgPsafq9+OWWplIIV1/0ZYY8wrJM9 vJsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AHJoQMSy; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lv23si13558627ejb.467.2021.06.21.15.31.56; Mon, 21 Jun 2021 15:31:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AHJoQMSy; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232180AbhFUWeC (ORCPT + 1 other); Mon, 21 Jun 2021 18:34:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231446AbhFUWeB (ORCPT ); Mon, 21 Jun 2021 18:34:01 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD438C061756 for ; Mon, 21 Jun 2021 15:31:46 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id h15so14158316lfv.12 for ; Mon, 21 Jun 2021 15:31:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wWkLC+6IHo1LkiZQZtpwJkfJ4H3Gk2cOkMI7a3h8YO8=; b=AHJoQMSyw2F26sqRP070Z2DonSPoTif5Q8B2lrDRcKW5F1+eFXYk4G946n7T7XovwA HWzV6sHthnzp2WCvluiMwRQVU7N3PtyOt3lBX6SgjbPvYtoo4fiMlBcMnKum4WwDaI+p mFwAxgmEFRw9yZ6eP43t1a+EfWr/ttIxBCOrWwMbwVSh45YzlalARMd5D6Rxu58jij/y SMxp+75C/iJgqwx3HpSkseiqqbXWRWiQzCbfEN4KONNn0+tzR0NjTnUF1Y9KVSqiuQAz cO3+Voo+knC88V8IQQ97O+xQkgTEf+SGHeruwkZ1mD9CYv9CvNlWMWyCFLPpV5J+m2+L +cVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wWkLC+6IHo1LkiZQZtpwJkfJ4H3Gk2cOkMI7a3h8YO8=; b=YxPWadlVuQhuf42DruVwM63HVr0DLpxm3ZNpHpbmfxcGPbt+LuaMVeUJlk/Fw1iGx0 zeOqpq5jjaE4SHsXf367wDVv7enSrwUOEdSba+7omeHbfRxQuCYGt6dennyoXxDrkdPg 5xbev9QOqmosjDCM3qKr1lQKh95KU1HtYPOsYJ7Gn/bTPqkRZgUzorUQbiTlTGsNZiMk G+rHqS8DiSilLIegAlemtpONDT/ORJzKVasi7Fwno2zUj6uf6HyGLzZYc6QkE+qNa9q1 e8hM/bs6iYtyHpktQ8pq12R4UDbL6RAmKLvPFrl9iOLCR2Bu/aVzIeC8e3YjOTmgU99W ijIw== X-Gm-Message-State: AOAM533GzwarB3v2Z4SRGeaIF2luATX4abBGNEfIkO18BdutzlJ0snj/ +zKTvQ7FeGYn5gQ0dP3iKfDCZw== X-Received: by 2002:a19:ad44:: with SMTP id s4mr363796lfd.563.1624314705160; Mon, 21 Jun 2021 15:31:45 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id b10sm2516025ljf.72.2021.06.21.15.31.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 15:31:44 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Rob Herring , Liam Girdwood , Mark Brown , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: linux-arm-msm@vger.kernel.org, Manivannan Sadhasivam , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org Subject: [PATCH v3 1/7] dt-bindings: regulator: qcom, qca6390: add binding for QCA6390 device Date: Tue, 22 Jun 2021 01:31:35 +0300 Message-Id: <20210621223141.1638189-2-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210621223141.1638189-1-dmitry.baryshkov@linaro.org> References: <20210621223141.1638189-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Qualcomm QCA6390/1 is a family of WiFi + Bluetooth SoCs, with BT part being controlled through the UART and WiFi being present on PCIe bus. Both blocks share common power sources. Add binding to describe power sequencing required to power up this device. Signed-off-by: Dmitry Baryshkov --- .../bindings/regulator/qcom,qca6390.yaml | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/qcom,qca6390.yaml -- 2.30.2 diff --git a/Documentation/devicetree/bindings/regulator/qcom,qca6390.yaml b/Documentation/devicetree/bindings/regulator/qcom,qca6390.yaml new file mode 100644 index 000000000000..35315c521041 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/qcom,qca6390.yaml @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/regulator/qcom,qca6390.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Qualcomm QCA6390 WiFi + Bluetoot SoC bindings + +maintainers: + - Andy Gross + - Bjorn Andersson + +description: | + This binding describes thes Qualcomm QCA6390 or QCA6391 power supplies and + enablement pins. + +properties: + compatible: + const: qcom,qca6390 + + vddaon-supply: + description: + 0.95V always-on LDO power input + + vddpmu-supply: + description: + 0.95V LDO power input to PMU + + vddrfa1-supply: + description: + 0.95V LDO power input to RFA + + vddrfa2-supply: + description: + 1.25V LDO power input to RFA + + vddrfa3-supply: + description: + 2V LDO power input to RFA + + vddpcie1-supply: + description: + 1.25V LDO power input to PCIe part + + vddpcie2-supply: + description: + 2V LDO power input to PCIe part + + vddio-supply: + description: + 1.8V VIO input + +additionalProperties: false + +examples: + - | + #include + qca6390: qca6390 { + compatible = "qcom,qca6390"; + + vddaon-supply = <&vreg_s6a_0p95>; + vddpmu-supply = <&vreg_s2f_0p95>; + vddrfa1-supply = <&vreg_s2f_0p95>; + vddrfa2-supply = <&vreg_s8c_1p3>; + vddrfa3-supply = <&vreg_s5a_1p9>; + vddpcie1-supply = <&vreg_s8c_1p3>; + vddpcie2-supply = <&vreg_s5a_1p9>; + vddio-supply = <&vreg_s4a_1p8>; + }; +... From patchwork Mon Jun 21 22:31:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 464710 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB085C4743C for ; Mon, 21 Jun 2021 22:31:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A0E9061352 for ; Mon, 21 Jun 2021 22:31:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232332AbhFUWeJ (ORCPT ); Mon, 21 Jun 2021 18:34:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232208AbhFUWeE (ORCPT ); Mon, 21 Jun 2021 18:34:04 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFC03C061574 for ; Mon, 21 Jun 2021 15:31:47 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id j2so32748016lfg.9 for ; Mon, 21 Jun 2021 15:31:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QHx4lPVuLgrkbYf8vHia5iLzhseB4SWEXJbfsdqWkv8=; b=TU2PbbIf7czYnoGY2jhObwIuRV669cWODpa4obBiKhfbq+paEHe2fDx2tBXoZgmMuu isGcF8UFk50IbKCENjFiRFImY/cJ/sj2EqAgJbyjBD8JRs95N/KOn866SynmbnBWaYq6 Ssos/lcKbUBntpLuCFSyikx6gvGjjqq5xx/Bmr1eNPs8CQwpisQkgSagxODUeJGa8gDW 56Idk1jWqOmAgu93x/e/SDVGezVpMyUIROCJOn8jazqIDfmqs4um27iLdcPwoH59wcTi tRosi115cReiQ4P3j7Xg9i//rJxWVh+RRuwDztOud/SaG692S/pdrjXeEv6JTY9Pm/Ob p0fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QHx4lPVuLgrkbYf8vHia5iLzhseB4SWEXJbfsdqWkv8=; b=GLAOFVx3NcIjFcXZVPUOqJmBw/CHSYlHg32EljbBg076FAHzsmPdVqqrLnzyZGCfpc xvwxXnWQFEhD9bAmFyXqLQZQQN7I82Q018GkmxQqOMc6mCDcVIxjgHw48+9viQoxY8xV EPGhFYOlXaCVwZXmT9dbdrpchc/RYK3xjt4fS37fXX02yIUahJTXJNrFspalfxrVNIy6 noY104xxI4gsjCy2O1vm6B3+gPS9EEHa4C0tXq7g9F//SbnLk71XqBBMFH1vJBGjNje5 hFSSR/aOTOoWAe5wKfu7a9/d2DdIONSRM2b5sjzCCh7OOHYld3I5bB7YgeJpmRYRuTBM vGsA== X-Gm-Message-State: AOAM532xQyeePDVfnrIeY6Wj1AWpr7aYwa0T1ktcEsnsMruVZeNZs8U4 QsBrTKznx/ODVl+k96uQSiwzNg== X-Google-Smtp-Source: ABdhPJxnA3LhLY66TfvahxeoPfG2LD8ALEpGrQB5AxrwAtExTQuaM7dYLOWAT1jp624hkIeoUqMYmg== X-Received: by 2002:ac2:4d81:: with SMTP id g1mr381309lfe.319.1624314705927; Mon, 21 Jun 2021 15:31:45 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id b10sm2516025ljf.72.2021.06.21.15.31.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 15:31:45 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Rob Herring , Liam Girdwood , Mark Brown , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: linux-arm-msm@vger.kernel.org, Manivannan Sadhasivam , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org Subject: [PATCH v3 2/7] regulator: qca6390: add support for QCA639x powerup sequence Date: Tue, 22 Jun 2021 01:31:36 +0300 Message-Id: <20210621223141.1638189-3-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210621223141.1638189-1-dmitry.baryshkov@linaro.org> References: <20210621223141.1638189-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Qualcomm QCA6390/1 is a family of WiFi + Bluetooth SoCs, with BT part being controlled through the UART and WiFi being present on PCIe bus. Both blocks share common power sources. Add device driver handling power sequencing of QCA6390/1. Signed-off-by: Dmitry Baryshkov --- drivers/regulator/Kconfig | 13 +++ drivers/regulator/Makefile | 1 + drivers/regulator/qcom-qca639x.c | 157 +++++++++++++++++++++++++++++++ 3 files changed, 171 insertions(+) create mode 100644 drivers/regulator/qcom-qca639x.c diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 3e7a38525cb3..7a560cddea7a 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -909,6 +909,19 @@ config REGULATOR_PWM This driver supports PWM controlled voltage regulators. PWM duty cycle can increase or decrease the voltage. +config REGULATOR_QCOM_QCA639X + tristate "Qualcomm QCA639x WiFi/Bluetooth module support" + help + If you say yes to this option, support will be included for Qualcomm + QCA639x family of WiFi and Bluetooth SoCs. Note, this driver supports + only power control for this SoC, you still have to enable individual + Bluetooth and WiFi drivers. This driver is only necessary on ARM + platforms with this chip. PCIe cards handle power sequencing on their + own. + + Say M here if you want to include support for QCA639x chips as a + module. This will build a module called "qcom-qca639x". + config REGULATOR_QCOM_RPM tristate "Qualcomm RPM regulator driver" depends on MFD_QCOM_RPM diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 580b015296ea..129c2110b78d 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -99,6 +99,7 @@ obj-$(CONFIG_REGULATOR_MT6380) += mt6380-regulator.o obj-$(CONFIG_REGULATOR_MT6397) += mt6397-regulator.o obj-$(CONFIG_REGULATOR_MTK_DVFSRC) += mtk-dvfsrc-regulator.o obj-$(CONFIG_REGULATOR_QCOM_LABIBB) += qcom-labibb-regulator.o +obj-$(CONFIG_REGULATOR_QCOM_QCA639X) += qcom-qca639x.o obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o obj-$(CONFIG_REGULATOR_QCOM_RPMH) += qcom-rpmh-regulator.o obj-$(CONFIG_REGULATOR_QCOM_SMD_RPM) += qcom_smd-regulator.o diff --git a/drivers/regulator/qcom-qca639x.c b/drivers/regulator/qcom-qca639x.c new file mode 100644 index 000000000000..a2c78c0f8baa --- /dev/null +++ b/drivers/regulator/qcom-qca639x.c @@ -0,0 +1,157 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2021, Linaro Limited + */ +#include +#include +#include +#include +#include +#include +#include + +#define MAX_NUM_REGULATORS 8 + +static struct vreg { + const char *name; + unsigned int load_uA; +} vregs[MAX_NUM_REGULATORS] = { + /* 2.0 V */ + { "vddpcie2", 15000 }, + { "vddrfa3", 400000 }, + + /* 0.95 V */ + { "vddaon", 100000 }, + { "vddpmu", 1250000 }, + { "vddrfa1", 200000 }, + + /* 1.35 V */ + { "vddrfa2", 400000 }, + { "vddpcie1", 35000 }, + + /* 1.8 V */ + { "vddio", 20000 }, +}; + +struct qca6390_data { + struct device *dev; + struct regulator_bulk_data regulators[MAX_NUM_REGULATORS]; + size_t num_vregs; + + struct regulator_desc desc; + struct regulator_dev *regulator_dev; + unsigned int enable_counter; +}; + +#define domain_to_data(domain) container_of(domain, struct qca6390_data, pd) + +static int qca6390_enable(struct regulator_dev *rdev) +{ + struct qca6390_data *data = rdev_get_drvdata(rdev); + int ret; + + ret = regulator_bulk_enable(data->num_vregs, data->regulators); + if (ret) { + dev_err(data->dev, "Failed to enable regulators"); + return ret; + } + + /* Wait for 1ms before toggling enable pins. */ + usleep_range(1000, 2000); + + data->enable_counter++; + + return 0; +} + +static int qca6390_disable(struct regulator_dev *rdev) +{ + struct qca6390_data *data = rdev_get_drvdata(rdev); + + regulator_bulk_disable(data->num_vregs, data->regulators); + + data->enable_counter--; + + return 0; +} + +static int qca6390_is_enabled(struct regulator_dev *rdev) +{ + struct qca6390_data *data = rdev_get_drvdata(rdev); + + return data->enable_counter > 0; +} + +static const struct regulator_ops qca6390_ops = { + .enable = qca6390_enable, + .disable = qca6390_disable, + .is_enabled = qca6390_is_enabled, +}; + +static int qca6390_probe(struct platform_device *pdev) +{ + struct qca6390_data *data; + struct device *dev = &pdev->dev; + struct regulator_config cfg = { }; + int i, ret; + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->dev = dev; + data->num_vregs = ARRAY_SIZE(vregs); + + for (i = 0; i < data->num_vregs; i++) + data->regulators[i].supply = vregs[i].name; + + ret = devm_regulator_bulk_get(dev, data->num_vregs, data->regulators); + if (ret < 0) + return ret; + + for (i = 0; i < data->num_vregs; i++) { + ret = regulator_set_load(data->regulators[i].consumer, vregs[i].load_uA); + if (ret) + return ret; + } + + data->desc.name = devm_kstrdup(dev, dev_name(dev), GFP_KERNEL); + if (!data->desc.name) + return -ENOMEM; + + data->desc.type = REGULATOR_VOLTAGE; + data->desc.owner = THIS_MODULE; + data->desc.ops = &qca6390_ops; + + cfg.dev = dev; + cfg.of_node = dev->of_node; + cfg.driver_data = data; + cfg.init_data = of_get_regulator_init_data(dev, dev->of_node, &data->desc); + + data->regulator_dev = devm_regulator_register(dev, &data->desc, &cfg); + if (IS_ERR(data->regulator_dev)) { + ret = PTR_ERR(data->regulator_dev); + return ret; + } + + platform_set_drvdata(pdev, data); + + return 0; +} + +static const struct of_device_id qca6390_of_match[] = { + { .compatible = "qcom,qca6390" }, +}; + +static struct platform_driver qca6390_driver = { + .probe = qca6390_probe, + .driver = { + .name = "qca6390", + .of_match_table = qca6390_of_match, + }, +}; + +module_platform_driver(qca6390_driver); +MODULE_AUTHOR("Dmitry Baryshkov "); +MODULE_DESCRIPTION("Power control for Qualcomm QCA6390/1 BT/WiFi chip"); +MODULE_LICENSE("GPL v2"); From patchwork Mon Jun 21 22:31:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 464607 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp64364jao; Mon, 21 Jun 2021 15:32:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQazZ8GcFOctxmnRbp2xqtMVIB5U4aWjZm5AsCFrGfLtvVACCZfXfUwNDAOdqm/fhgahXg X-Received: by 2002:a17:907:96a0:: with SMTP id hd32mr409781ejc.198.1624314721189; Mon, 21 Jun 2021 15:32:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624314721; cv=none; d=google.com; s=arc-20160816; b=fgIgrQjqGSRt9u/NaQ/r75g8C9UBQtSPlpRE6njDTlfgi2MDI14oQdp5JaUCAPoOgT RxE+EHcPNP+dq6fUcF0VA9ZwQZXH0jmQwkWXfLYoIUViBtgFtAiedhnSG3Ba95RXkK2p JzgVZU/xmUZWvfTmTM8WXeIMOm8QSp4yfmSRC7zGOxN7i5bv9xvKYle43jlCnAgd+bXy zntZI6TbcBcFCq5eNHCOQRshuS/DFmsucYPlA4xZrsbN8ygDobPvOp9xG5RUhDHj1IsK xX8lkK6cjbVaWiVM34JsC0RRZVqdAXZQYnzVq4FhWSXGkgBQoGZXQNIgoOQIjeWwQE1M ksFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mMcsAXLjdzqmXTrqYecRXzkTaTpEAvP3tlWseu3ox9A=; b=xWRaB4rihIWYGF7hv1ZJh546D7WNU2ZJRhLP5s70evCr9mXUXZN5VwVRV3sC+KumfA VerPPQnR+keMvTGag/b1aXUnMYK+9wGLRfkmvj3TwKTUf3Dpjlw3Yq6T5VcQTfTjemjQ Yglt2BvdfjeX7ZZJ6C/nbj7eST/DNkRA37scvgWgO2cWT81FBpapPYuIFa1EkZ0B9eqg 5Mzj5eef5fYauKosgGlrSGnLh74up9Et1td9mX3Lmha/07b2g/90furA7XFkPnFtW4XB ckR+mK4HHfLXZwo3D+rHaZI0IeyDyd/L4Kft1cj+Ft88MEiuP1Xp4kIF5b6aNyHqooD/ KV2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QqQsgPb8; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lv23si13558627ejb.467.2021.06.21.15.32.01; Mon, 21 Jun 2021 15:32:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QqQsgPb8; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232256AbhFUWeG (ORCPT + 1 other); Mon, 21 Jun 2021 18:34:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232193AbhFUWeD (ORCPT ); Mon, 21 Jun 2021 18:34:03 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64B45C061767 for ; Mon, 21 Jun 2021 15:31:48 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id i13so32662910lfc.7 for ; Mon, 21 Jun 2021 15:31:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mMcsAXLjdzqmXTrqYecRXzkTaTpEAvP3tlWseu3ox9A=; b=QqQsgPb8dWBwxyeGmtUH5SsMbqq91ExfilXUZD49aAn/O8PypCkqXVt+EYWPqpHYv0 y91K7G2eh7AZH7potCOxSb/HsR2WU50nzQeDG5L07Jw603Fyv751Rvygq9XQlOx6Px13 8Ns6aYLSrYTLnL1Ucm6YFcoJuE1zfWkSd7Jj/ezs9Ac8Ko4miQYyq/VdzBW+gQSD/77C SNz182xmjUuhcLOC4jLoc+9sI5GrGqE/RMxdHG4lJCqRgOsuWpztbWuk2ye2XZSzhQGq Td/RKxqq6ljPwy/K+UuVX4eeKrU0PkEyK7KKfmq+Ef8tOqm4GnbS+C8lAHPSlvAYELGT /Imw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mMcsAXLjdzqmXTrqYecRXzkTaTpEAvP3tlWseu3ox9A=; b=EopYyNpKMGOaKGiqrejjXbkwNtHieIrdsiO6wgAD8vZa2YcRT6m6EFlXyAi9QuUgHp 5LTjrvtQBJhsIBBRFPWU67ky7Y40InKouO6hmKAHk2daRBqR15joRjVOtenVEGCMVhTh foDps+yH/zf6kmYKW6aCg5ZfxE15E6a5lllrNW0giGcy50FadVwWd0qhrVMQvg+dycVz 1iUVcHyvyHHjEbOjygZSx244fy/Xr0X9FadVw6oCZjkUnRjcnUQwyIWQ9g8C7uCbAEsf mBuizq2YKWuph2he7IUAvWQx8mAFi+CdnyNJLKJ2jEmbS0lELJz1nlmM+c/wlrt3VRW6 Rf7A== X-Gm-Message-State: AOAM5301HTU2KBWpaEtajOLCB8jiKk6gOSKpEppBIh0y/IMV4UmFX6Ev Y/rBqXNaiu/yAXfxcjsrUKAN6Q== X-Received: by 2002:a05:6512:4d0:: with SMTP id w16mr420221lfq.44.1624314706695; Mon, 21 Jun 2021 15:31:46 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id b10sm2516025ljf.72.2021.06.21.15.31.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 15:31:46 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Rob Herring , Liam Girdwood , Mark Brown , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: linux-arm-msm@vger.kernel.org, Manivannan Sadhasivam , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org Subject: [PATCH v3 3/7] Bluetooth: hci_qca: provide default device data Date: Tue, 22 Jun 2021 01:31:37 +0300 Message-Id: <20210621223141.1638189-4-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210621223141.1638189-1-dmitry.baryshkov@linaro.org> References: <20210621223141.1638189-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org In order to simplify probe function provide default device data. This removes the rest of if (data) checks. Signed-off-by: Dmitry Baryshkov --- drivers/bluetooth/hci_qca.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) -- 2.30.2 Reviewed-by: Bjorn Andersson diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 53deea2eb7b4..3704dbadba1d 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -1874,6 +1874,11 @@ static const struct qca_device_data qca_soc_data_wcn6750 = { .capabilities = QCA_CAP_WIDEBAND_SPEECH | QCA_CAP_VALID_LE_STATES, }; +static const struct qca_device_data qca_soc_data_default = { + .soc_type = QCA_ROME, + .num_vregs = 0, +}; + static void qca_power_shutdown(struct hci_uart *hu) { struct qca_serdev *qcadev; @@ -2019,12 +2024,15 @@ static int qca_serdev_probe(struct serdev_device *serdev) int err; bool power_ctrl_enabled = true; + data = device_get_match_data(&serdev->dev); + if (!data) + return -EINVAL; + qcadev = devm_kzalloc(&serdev->dev, sizeof(*qcadev), GFP_KERNEL); if (!qcadev) return -ENOMEM; qcadev->serdev_hu.serdev = serdev; - data = device_get_match_data(&serdev->dev); serdev_device_set_drvdata(serdev, qcadev); device_property_read_string(&serdev->dev, "firmware-name", &qcadev->firmware_name); @@ -2033,9 +2041,8 @@ static int qca_serdev_probe(struct serdev_device *serdev) if (!qcadev->oper_speed) BT_DBG("UART will pick default operating speed"); - if (data && - (qca_is_wcn399x(data->soc_type) || - qca_is_wcn6750(data->soc_type))) { + if ((qca_is_wcn399x(data->soc_type) || + qca_is_wcn6750(data->soc_type))) { qcadev->btsoc_type = data->soc_type; qcadev->bt_power = devm_kzalloc(&serdev->dev, sizeof(struct qca_power), @@ -2077,10 +2084,7 @@ static int qca_serdev_probe(struct serdev_device *serdev) return err; } } else { - if (data) - qcadev->btsoc_type = data->soc_type; - else - qcadev->btsoc_type = QCA_ROME; + qcadev->btsoc_type = data->soc_type; qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable", GPIOD_OUT_LOW); @@ -2309,9 +2313,9 @@ static SIMPLE_DEV_PM_OPS(qca_pm_ops, qca_suspend, qca_resume); #ifdef CONFIG_OF static const struct of_device_id qca_bluetooth_of_match[] = { - { .compatible = "qcom,qca6174-bt" }, + { .compatible = "qcom,qca6174-bt", .data = &qca_soc_data_default}, { .compatible = "qcom,qca6390-bt", .data = &qca_soc_data_qca6390}, - { .compatible = "qcom,qca9377-bt" }, + { .compatible = "qcom,qca9377-bt", .data = &qca_soc_data_default}, { .compatible = "qcom,wcn3990-bt", .data = &qca_soc_data_wcn3990}, { .compatible = "qcom,wcn3991-bt", .data = &qca_soc_data_wcn3991}, { .compatible = "qcom,wcn3998-bt", .data = &qca_soc_data_wcn3998}, From patchwork Mon Jun 21 22:31:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 464709 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E427C49EAB for ; Mon, 21 Jun 2021 22:31:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2783B6124B for ; Mon, 21 Jun 2021 22:31:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232374AbhFUWeL (ORCPT ); Mon, 21 Jun 2021 18:34:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232239AbhFUWeF (ORCPT ); Mon, 21 Jun 2021 18:34:05 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB827C061760 for ; Mon, 21 Jun 2021 15:31:49 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id f30so32786948lfj.1 for ; Mon, 21 Jun 2021 15:31:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UfaTXgDF4vMyaJzGI+Ia8CfRX0d1Tnl83CcZoFAKsfc=; b=MgVjuyU64KYro8Dh10oMm4sKvsTqIT5s0jM0f4y3Wmuu6SR/cB+YwflEcHwmetf1Pw a7eH8yz9Ae8VMGRr4mWxOodhMdFWo+FWdVGVK842LgNW6iTfE7qt+nfQwNCnkY75hRjW +bsjaiRBqfye9ZVaoPLA3mEwTreWf15Y6P00/3gsegidP0rBM/ENZBVcz5jhFPsaHU5D Kqi9UhHjEuwqEkf74BH2otnNTHaeq9ewmEa0nlZxITh4TxM9R5RxzhlH8wk5piU0+8lj ap3JrX6qE0c6IiGOWBdufYPcahPoj5XIiSJP2wu2LXa+NcnzLNm9Pc0pWQRZ/54vqbDs pf5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UfaTXgDF4vMyaJzGI+Ia8CfRX0d1Tnl83CcZoFAKsfc=; b=lfRjZ07eDkAX9Dm7ASDDCgs8OlDmvfcRFzJ6fnExyK8yawSDKjcfUqW364tipxDl94 +DCVAp3Zn4qyfsd7aeKUsIDDRHJH3vM8tEqUDcnONHnqtVh+Q7wQwQ8103t2hYPrx4t1 caNEftkO1NA/OXlt8h8dN5Lp/PLEpO85YrQgTwYLuL043upXV9NC7vpaGF6JL+VGqqtH TFyoJgI65x9WFee/inCVGIm/I0KuxGpT/gRhkrJMMbIeIvNGR8eMR2WxCEo99HLr0jPU kDV6W2I7yb2xmWAwzdggHENBWfF6lBp8m0Gfgcm/QQIFsVJwOn/v5voOk1BpdAvAYRXp 9s+A== X-Gm-Message-State: AOAM531jG93hYU7oJCyuFIvsFtomheOgqB534oeMmilbFEmR23ooNw0S zAgRSAMQSXG9hUJgFq9jqX+X+A== X-Google-Smtp-Source: ABdhPJwJkpZL7XXRKnMB+hiz9rs9619dCIDpP90WydOc8iLjYpF8G/z6pF0arDZ1vc9s2NfBWXctLw== X-Received: by 2002:a19:6907:: with SMTP id e7mr390137lfc.660.1624314708120; Mon, 21 Jun 2021 15:31:48 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id b10sm2516025ljf.72.2021.06.21.15.31.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 15:31:47 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Rob Herring , Liam Girdwood , Mark Brown , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: linux-arm-msm@vger.kernel.org, Manivannan Sadhasivam , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org Subject: [PATCH v3 5/7] Bluetooth: hci_qca: merge wcn & non-wcn code paths Date: Tue, 22 Jun 2021 01:31:39 +0300 Message-Id: <20210621223141.1638189-6-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210621223141.1638189-1-dmitry.baryshkov@linaro.org> References: <20210621223141.1638189-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org In preparation to add power sequencer support to qca6390, merge wcnxxxx and non-wcn codepaths. Signed-off-by: Dmitry Baryshkov --- drivers/bluetooth/hci_qca.c | 152 +++++++++++++++++------------------- 1 file changed, 71 insertions(+), 81 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 9cc8a9153d76..bb04da08468a 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -84,6 +84,7 @@ enum qca_flags { enum qca_capabilities { QCA_CAP_WIDEBAND_SPEECH = BIT(0), QCA_CAP_VALID_LE_STATES = BIT(1), + QCA_CAP_NEEDS_BT_ENABLE = BIT(2), }; /* HCI_IBS transmit side sleep protocol states */ @@ -203,6 +204,7 @@ struct qca_device_data { struct qca_vreg *vregs; size_t num_vregs; uint32_t capabilities; + const char *name; }; /* @@ -220,6 +222,7 @@ struct qca_serdev { u32 init_speed; u32 oper_speed; const char *firmware_name; + const char *name; }; static int qca_regulator_enable(struct qca_serdev *qcadev); @@ -254,6 +257,17 @@ static const char *qca_get_firmware_name(struct hci_uart *hu) } } +static const char *qca_soc_name(struct hci_uart *hu) +{ + if (hu->serdev) { + struct qca_serdev *qsd = serdev_device_get_drvdata(hu->serdev); + + return qsd->name; + } else { + return "ROME"; + } +} + static void __serial_clock_on(struct tty_struct *tty) { /* TODO: Some chipset requires to enable UART clock on client @@ -1623,14 +1637,16 @@ static int qca_regulator_init(struct hci_uart *hu) gpiod_set_value_cansleep(qcadev->bt_en, 0); msleep(50); gpiod_set_value_cansleep(qcadev->bt_en, 1); - msleep(50); + msleep(150); if (qcadev->sw_ctrl) { sw_ctrl_state = gpiod_get_value_cansleep(qcadev->sw_ctrl); bt_dev_dbg(hu->hdev, "SW_CTRL is %d", sw_ctrl_state); } } - qca_set_speed(hu, QCA_INIT_SPEED); + if (qca_is_wcn399x(soc_type) || + qca_is_wcn6750(soc_type)) + qca_set_speed(hu, QCA_INIT_SPEED); if (qca_is_wcn399x(soc_type)) { ret = qca_send_power_pulse(hu, true); @@ -1650,7 +1666,9 @@ static int qca_regulator_init(struct hci_uart *hu) return ret; } - hci_uart_set_flow_control(hu, false); + if (qca_is_wcn399x(soc_type) || + qca_is_wcn6750(soc_type)) + hci_uart_set_flow_control(hu, false); return 0; } @@ -1658,8 +1676,6 @@ static int qca_regulator_init(struct hci_uart *hu) static int qca_power_on(struct hci_dev *hdev) { struct hci_uart *hu = hci_get_drvdata(hdev); - enum qca_btsoc_type soc_type = qca_soc_type(hu); - struct qca_serdev *qcadev; struct qca_data *qca = hu->priv; int ret = 0; @@ -1669,17 +1685,7 @@ static int qca_power_on(struct hci_dev *hdev) if (!hu->serdev) return 0; - if (qca_is_wcn399x(soc_type) || - qca_is_wcn6750(soc_type)) { - ret = qca_regulator_init(hu); - } else { - qcadev = serdev_device_get_drvdata(hu->serdev); - if (qcadev->bt_en) { - gpiod_set_value_cansleep(qcadev->bt_en, 1); - /* Controller needs time to bootup. */ - msleep(150); - } - } + ret = qca_regulator_init(hu); clear_bit(QCA_BT_OFF, &qca->flags); return ret; @@ -1709,9 +1715,7 @@ static int qca_setup(struct hci_uart *hu) */ set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); - bt_dev_info(hdev, "setting up %s", - qca_is_wcn399x(soc_type) ? "wcn399x" : - (soc_type == QCA_WCN6750) ? "wcn6750" : "ROME/QCA6390"); + bt_dev_info(hdev, "setting up %s", qca_soc_name(hu)); qca->memdump_state = QCA_MEMDUMP_IDLE; @@ -1822,6 +1826,7 @@ static const struct qca_device_data qca_soc_data_wcn3990 = { { "vddch0", 450000 }, }, .num_vregs = 4, + .name = "wcn3990", }; static const struct qca_device_data qca_soc_data_wcn3991 = { @@ -1834,6 +1839,7 @@ static const struct qca_device_data qca_soc_data_wcn3991 = { }, .num_vregs = 4, .capabilities = QCA_CAP_WIDEBAND_SPEECH | QCA_CAP_VALID_LE_STATES, + .name = "wcn3991", }; static const struct qca_device_data qca_soc_data_wcn3998 = { @@ -1845,11 +1851,14 @@ static const struct qca_device_data qca_soc_data_wcn3998 = { { "vddch0", 450000 }, }, .num_vregs = 4, + .name = "wcn3998", }; static const struct qca_device_data qca_soc_data_qca6390 = { .soc_type = QCA_QCA6390, .num_vregs = 0, + .capabilities = QCA_CAP_NEEDS_BT_ENABLE, + .name = "qca6390", }; static const struct qca_device_data qca_soc_data_wcn6750 = { @@ -1866,12 +1875,15 @@ static const struct qca_device_data qca_soc_data_wcn6750 = { { "vddasd", 200 }, }, .num_vregs = 9, - .capabilities = QCA_CAP_WIDEBAND_SPEECH | QCA_CAP_VALID_LE_STATES, + .capabilities = QCA_CAP_WIDEBAND_SPEECH | QCA_CAP_VALID_LE_STATES | QCA_CAP_NEEDS_BT_ENABLE, + .name = "wcn6750", }; static const struct qca_device_data qca_soc_data_default = { .soc_type = QCA_ROME, .num_vregs = 0, + .capabilities = QCA_CAP_NEEDS_BT_ENABLE, + .name = "ROME", }; static void qca_power_shutdown(struct hci_uart *hu) @@ -1903,7 +1915,7 @@ static void qca_power_shutdown(struct hci_uart *hu) host_set_baudrate(hu, 2400); qca_send_power_pulse(hu, false); qca_regulator_disable(qcadev); - } else if (soc_type == QCA_WCN6750) { + } else if (qcadev->bt_en) { gpiod_set_value_cansleep(qcadev->bt_en, 0); msleep(100); qca_regulator_disable(qcadev); @@ -1911,8 +1923,6 @@ static void qca_power_shutdown(struct hci_uart *hu) sw_ctrl_state = gpiod_get_value_cansleep(qcadev->sw_ctrl); bt_dev_dbg(hu->hdev, "SW_CTRL is %d", sw_ctrl_state); } - } else if (qcadev->bt_en) { - gpiod_set_value_cansleep(qcadev->bt_en, 0); } set_bit(QCA_BT_OFF, &qca->flags); @@ -2034,71 +2044,51 @@ static int qca_serdev_probe(struct serdev_device *serdev) if (!qcadev->oper_speed) BT_DBG("UART will pick default operating speed"); - if ((qca_is_wcn399x(data->soc_type) || - qca_is_wcn6750(data->soc_type))) { - qcadev->btsoc_type = data->soc_type; - - err = qca_init_regulators(&serdev->dev, qcadev, data->vregs, - data->num_vregs); - if (err) { - BT_ERR("Failed to init regulators:%d", err); - return err; - } + qcadev->name = data->name; + qcadev->btsoc_type = data->soc_type; - qcadev->vregs_on = false; - - qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable", - GPIOD_OUT_LOW); - if (!qcadev->bt_en && data->soc_type == QCA_WCN6750) { - dev_err(&serdev->dev, "failed to acquire BT_EN gpio\n"); - power_ctrl_enabled = false; - } + err = qca_init_regulators(&serdev->dev, qcadev, data->vregs, + data->num_vregs); + if (err) { + BT_ERR("Failed to init regulators:%d", err); + return err; + } - qcadev->sw_ctrl = devm_gpiod_get_optional(&serdev->dev, "swctrl", - GPIOD_IN); - if (!qcadev->sw_ctrl && data->soc_type == QCA_WCN6750) - dev_warn(&serdev->dev, "failed to acquire SW_CTRL gpio\n"); + qcadev->vregs_on = false; - qcadev->susclk = devm_clk_get_optional(&serdev->dev, NULL); - if (IS_ERR(qcadev->susclk)) { - dev_err(&serdev->dev, "failed to acquire clk\n"); - return PTR_ERR(qcadev->susclk); - } + qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable", + GPIOD_OUT_LOW); + if (!qcadev->bt_en && (data->capabilities & QCA_CAP_NEEDS_BT_ENABLE)) { + dev_err(&serdev->dev, "failed to acquire BT_EN gpio\n"); + power_ctrl_enabled = false; + } - err = hci_uart_register_device(&qcadev->serdev_hu, &qca_proto); - if (err) { - BT_ERR("wcn3990 serdev registration failed"); - return err; - } - } else { - qcadev->btsoc_type = data->soc_type; + qcadev->sw_ctrl = devm_gpiod_get_optional(&serdev->dev, "swctrl", + GPIOD_IN); + if (!qcadev->sw_ctrl && data->soc_type == QCA_WCN6750) + dev_warn(&serdev->dev, "failed to acquire SW_CTRL gpio\n"); - qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable", - GPIOD_OUT_LOW); - if (!qcadev->bt_en) { - dev_warn(&serdev->dev, "failed to acquire enable gpio\n"); - power_ctrl_enabled = false; - } + qcadev->susclk = devm_clk_get_optional(&serdev->dev, NULL); + if (IS_ERR(qcadev->susclk)) { + dev_err(&serdev->dev, "failed to acquire clk\n"); + return PTR_ERR(qcadev->susclk); + } - qcadev->susclk = devm_clk_get_optional(&serdev->dev, NULL); - if (IS_ERR(qcadev->susclk)) { - dev_warn(&serdev->dev, "failed to acquire clk\n"); - return PTR_ERR(qcadev->susclk); - } - err = clk_set_rate(qcadev->susclk, SUSCLK_RATE_32KHZ); - if (err) - return err; + err = clk_set_rate(qcadev->susclk, SUSCLK_RATE_32KHZ); + if (err) + return err; + if (!qca_is_wcn399x(qcadev->btsoc_type) && + !qca_is_wcn6750(qcadev->btsoc_type)) { err = clk_prepare_enable(qcadev->susclk); if (err) return err; + } - err = hci_uart_register_device(&qcadev->serdev_hu, &qca_proto); - if (err) { - BT_ERR("Rome serdev registration failed"); - clk_disable_unprepare(qcadev->susclk); - return err; - } + err = hci_uart_register_device(&qcadev->serdev_hu, &qca_proto); + if (err) { + BT_ERR("%s serdev registration failed", qcadev->name); + return err; } hdev = qcadev->serdev_hu.hdev; @@ -2127,11 +2117,11 @@ static void qca_serdev_remove(struct serdev_device *serdev) { struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev); - if ((qca_is_wcn399x(qcadev->btsoc_type) || - qca_is_wcn6750(qcadev->btsoc_type)) && - qcadev->vregs_on) + if (qcadev->vregs_on) qca_power_shutdown(&qcadev->serdev_hu); - else if (qcadev->susclk) + + if (!qca_is_wcn399x(qcadev->btsoc_type) && + !qca_is_wcn6750(qcadev->btsoc_type)) clk_disable_unprepare(qcadev->susclk); hci_uart_unregister_device(&qcadev->serdev_hu); From patchwork Mon Jun 21 22:31:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 464708 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2CE3C4743C for ; Mon, 21 Jun 2021 22:32:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBB9860FEE for ; Mon, 21 Jun 2021 22:32:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232469AbhFUWeU (ORCPT ); Mon, 21 Jun 2021 18:34:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232375AbhFUWeL (ORCPT ); Mon, 21 Jun 2021 18:34:11 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DF12C0613A3 for ; Mon, 21 Jun 2021 15:31:50 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id u20so7662043ljl.13 for ; Mon, 21 Jun 2021 15:31:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Pl85yJPQ8UWWXJ4GoZSz05OqJVvyRpSXlOX5oJ9CbE0=; b=zIZNEtQC22piu1oOY/ASJ6inohtioGWMbhHGNwKmnkg+6S/zgVXtgw3YYIm6KRmP7D 2yQ+iV2uCIm7l2AsLFnTvfAptHFR7kZGrn47hI61YYqso7ykfC0HB6FlLPh7WTjbgJUu lA27VdWWiL5tFBNCvlEGIYuvH1FYQqSwllKOQtjzoRkIHRiuJkTNV9LEiJZuKLspFiv1 +XxMW6ymZVbLE+RC+aKxtEFjpUXZwG+6uvo6kfJECwE9jgE5A8gK3fdFrkzUypwirFYW u0CyisCXrQiw1gQpxDWdumJ3GCAWqi9X31v2gYEgXFNfRqqGOEuutu89S3R72hsZkt+G W96g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Pl85yJPQ8UWWXJ4GoZSz05OqJVvyRpSXlOX5oJ9CbE0=; b=pkAz+lyS8qECd3/JZb3iduaijvkg12AZg7VMxHZjs8VVg7lZ90EXx8xAq+P0y6C9Y5 rwWrYE6jYmzd6IGnJyafiwu9UrOSk8MBee7fu2u1U+DzCJbK4FpfmfhMEcgafeHlcTuv hznaLA79QqQHCSMsflEGgDSDDMLaK9kfPEp3uB0cN0JfY7P+CZAZvZqVHz6f97wJyd6Q iOakS7YSY38WQrgIKxyiLCs/RGA/27a4lvNkb0Kw0xlWj5GMcUcr+P9oAvPHw4wnR7dr DWdd5SNw7YWcLuHGGyaPVvMhlkG2bPB+TteHuzxG69rZUcRkYkKY6rLBjIkbRbjG8t3z OXiQ== X-Gm-Message-State: AOAM532Zwmju36T5Kz0Md6TN5iyjmCmfBFAcnYN/+lq/kZ9v/bYOFxqm Gp8I0OX6NYPZykmWeqzllMt1CA== X-Google-Smtp-Source: ABdhPJxjoVCplwPuJvjbPzknCoMLW1t50J1MCoASlafBc+Ph6ulmOtfGcOvFbeHinnh6DsqSmvnOig== X-Received: by 2002:a2e:2a41:: with SMTP id q62mr372448ljq.371.1624314708998; Mon, 21 Jun 2021 15:31:48 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id b10sm2516025ljf.72.2021.06.21.15.31.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 15:31:48 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Rob Herring , Liam Girdwood , Mark Brown , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: linux-arm-msm@vger.kernel.org, Manivannan Sadhasivam , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org Subject: [PATCH v3 6/7] Bluetooth: hci_qca: add power sequencer support to qca6390 Date: Tue, 22 Jun 2021 01:31:40 +0300 Message-Id: <20210621223141.1638189-7-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210621223141.1638189-1-dmitry.baryshkov@linaro.org> References: <20210621223141.1638189-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org QCA6390 uses on-chip power sequencer (and power management unit) to supply power to both WiFi and BT parts. Since this sequencer is supported by a separate driver, use it as a single "vin" regulator. Signed-off-by: Dmitry Baryshkov --- drivers/bluetooth/hci_qca.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index bb04da08468a..deea38033248 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -1856,7 +1856,10 @@ static const struct qca_device_data qca_soc_data_wcn3998 = { static const struct qca_device_data qca_soc_data_qca6390 = { .soc_type = QCA_QCA6390, - .num_vregs = 0, + .vregs = (struct qca_vreg []) { + { "vin", 1000 }, + }, + .num_vregs = 1, .capabilities = QCA_CAP_NEEDS_BT_ENABLE, .name = "qca6390", };