Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1108290ybl; Thu, 12 Dec 2019 09:44:45 -0800 (PST) X-Google-Smtp-Source: APXvYqyrKyOLxgUtnUE7kh00UiSYD+k7MxTxxR+IGv+MYurEVnrCdniZ17QoLWjlEXHEUuJQ0rdf X-Received: by 2002:a9d:7590:: with SMTP id s16mr8949841otk.89.1576172685452; Thu, 12 Dec 2019 09:44:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576172685; cv=none; d=google.com; s=arc-20160816; b=xevtKO3jwdlmKDEQyy1b2Urwg4Q7zMF46EHKalXoYQ9swEIdYcQRrmmiBsSBF/NpWc MigjraaeZO0cemqtwnvIczPKCR0gmofOZlmQwNDPURA18INc2/uN+G5BqFEzQspZKtWT SvlY/g6fDK7PbheS/1H5sUl+M49PzlXdDxA0gmy+g15qBeUKuHt+jWzNZTGNuUPwi/eN 2WMs6l/7gLBwZCxxnc7waX0J64J5+TDnBk766IYKVklz9vx8otdspgR8fnb0UJmvYW6R rai6EJes2G5r0EB930GQe3MmqGyBvb29EHOkhbX30ixAPQdTPtUMx1iJigk1vFuLHvMG SOOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GuBEFzX5L/KmRFYdGw2tsnNnogFgZtYo6kJYMRL2d1I=; b=X3m9byqoUGxwRvudvwjJDCzeroQ2oSHxJxQgv46a/XhyAaJuhTcuTfROKUqkj5Awi5 uivqcjSwlgRpg5dWoPd1ojzkWJlaF50hTQ8pVNriHpwhhphtrZksdQweG6drvBx3btuN JHc8jW467mGIqcxiWj1+jdWFkZ2oHjwiyCeED384/PTiaIlPUIyz/DrvgKDOtyyB0A4I OL9uN8NnbwMks1qV+F7iBSmtlF20NWFVTQFLeXhvzxndw0zKbXz7keTzGIPCwjD+/W7V T9GocxcvMboDoXrUwapa9ogYf0DxXaZq71F6bq59H42JIlfBN9bdJjofdKnf8f0p0bP9 giYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AnD962j2; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 11si4905039otz.101.2019.12.12.09.44.25; Thu, 12 Dec 2019 09:44:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AnD962j2; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730240AbfLLRnv (ORCPT + 99 others); Thu, 12 Dec 2019 12:43:51 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:38004 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730236AbfLLRnv (ORCPT ); Thu, 12 Dec 2019 12:43:51 -0500 Received: by mail-pj1-f68.google.com with SMTP id l4so1323704pjt.5 for ; Thu, 12 Dec 2019 09:43:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=GuBEFzX5L/KmRFYdGw2tsnNnogFgZtYo6kJYMRL2d1I=; b=AnD962j2myid8WfZ47WNy9/d7nvicLmLtLcM+Pb2j1MmswRDY41Z8qerQylGnuKcr5 n9tvb681VzrQjbF+0arWfQn+N+O37W/1PXmwDDI8BYmYA9DkSDcRhlrswW3j777R0Efv cooEe887dVu+x52URwUGFbOfmceut8N4hhUiw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=GuBEFzX5L/KmRFYdGw2tsnNnogFgZtYo6kJYMRL2d1I=; b=oyhkPgmjkS8SnL4/i9a268sr8REGi0Y0VOXMqWRCl//Obyu6hz7KDgfBoFDk988/gk Cua2nDWA9S99AxbJjTZing2IiteokCCUSc9CCxs6R/ano7naSHxo5+V82MzcJVIMuxK2 utjMl+bfVDZGYROTN+JcFqP+zsACYbgoy5Lf9ZgeBgJHF2nn87DBZQyyYkPD5fTwRmMS AKc6uxHcs4NzRn9gfZtyXHhm7vA365yPFnpNUUrpSAB5PTmhAZxXEjFt2BfNM0JLyzLM OlaI2UimFxdlsyIEGuyLiyX9e4JRegu0USwTypQtgaAicXBQjdcE+nXgve3mEL4avuC8 SL9g== X-Gm-Message-State: APjAAAURdqL48EHhUBn8Yby1SX6hz8JA9M/cPkb/29nBEa0svWj19n3E asmfZWyHUlH0cuLnzv1sc4iyog== X-Received: by 2002:a17:90a:62ca:: with SMTP id k10mr11283072pjs.59.1576172630293; Thu, 12 Dec 2019 09:43:50 -0800 (PST) Received: from localhost ([2620:15c:202:1:4fff:7a6b:a335:8fde]) by smtp.gmail.com with ESMTPSA id g18sm7986007pfo.123.2019.12.12.09.43.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Dec 2019 09:43:49 -0800 (PST) Date: Thu, 12 Dec 2019 09:43:48 -0800 From: Matthias Kaehlcke To: Balakrishna Godavarthi Cc: marcel@holtmann.org, johan.hedberg@gmail.com, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, tientzu@chromium.org, seanpaul@chromium.org Subject: Re: [PATCH v1] Bluetooth: hci_qca: Enable clocks required for BT SOC Message-ID: <20191212174348.GS228856@google.com> References: <20191114081430.25427-1-bgodavar@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191114081430.25427-1-bgodavar@codeaurora.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On Thu, Nov 14, 2019 at 01:44:30PM +0530, Balakrishna Godavarthi wrote: > Instead of relying on other subsytem to turn ON clocks > required for BT SoC to operate, voting them from the driver. > > Signed-off-by: Balakrishna Godavarthi > --- > drivers/bluetooth/hci_qca.c | 31 +++++++++++++++++++++++++++++-- > 1 file changed, 29 insertions(+), 2 deletions(-) > > diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c > index f10bdf8e1fc5..dc95e378574b 100644 > --- a/drivers/bluetooth/hci_qca.c > +++ b/drivers/bluetooth/hci_qca.c > @@ -164,6 +164,7 @@ struct qca_serdev { > }; > > static int qca_regulator_enable(struct qca_serdev *qcadev); > +static int qca_power_on(struct qca_serdev *qcadev); > static void qca_regulator_disable(struct qca_serdev *qcadev); > static void qca_power_shutdown(struct hci_uart *hu); > static int qca_power_off(struct hci_dev *hdev); > @@ -528,7 +529,7 @@ static int qca_open(struct hci_uart *hu) > } else { > hu->init_speed = qcadev->init_speed; > hu->oper_speed = qcadev->oper_speed; > - ret = qca_regulator_enable(qcadev); > + ret = qca_power_on(qcadev); > if (ret) { > destroy_workqueue(qca->workqueue); > kfree_skb(qca->rx_skb); > @@ -1214,7 +1215,7 @@ static int qca_wcn3990_init(struct hci_uart *hu) > qcadev = serdev_device_get_drvdata(hu->serdev); > if (!qcadev->bt_power->vregs_on) { > serdev_device_close(hu->serdev); > - ret = qca_regulator_enable(qcadev); > + ret = qca_power_on(qcadev); > if (ret) > return ret; > > @@ -1408,6 +1409,9 @@ static void qca_power_shutdown(struct hci_uart *hu) > host_set_baudrate(hu, 2400); > qca_send_power_pulse(hu, false); > qca_regulator_disable(qcadev); > + > + if (qcadev->susclk) > + clk_disable_unprepare(qcadev->susclk); > } > > static int qca_power_off(struct hci_dev *hdev) > @@ -1423,6 +1427,20 @@ static int qca_power_off(struct hci_dev *hdev) > return 0; > } > > +static int qca_power_on(struct qca_serdev *qcadev) > +{ > + int err; > + > + if (qcadev->susclk) { > + err = clk_prepare_enable(qcadev->susclk); > + if (err) > + return err; > + } > + > + qca_regulator_enable(qcadev); > + return 0; > +} > + > static int qca_regulator_enable(struct qca_serdev *qcadev) > { > struct qca_power *power = qcadev->bt_power; > @@ -1523,6 +1541,15 @@ static int qca_serdev_probe(struct serdev_device *serdev) > > qcadev->bt_power->vregs_on = false; > > + if (qcadev->btsoc_type == QCA_WCN3990 || > + qcadev->btsoc_type == QCA_WCN3991) { > + qcadev->susclk = devm_clk_get(&serdev->dev, NULL); > + if (IS_ERR(qcadev->susclk)) { > + dev_err(&serdev->dev, "failed to acquire clk\n"); > + return PTR_ERR(qcadev->susclk); > + } This will break existing users. Use devm_clk_get_optional() and at most raise a warning if the clock doesn't exist. It would also be nice to add the clock to the affected devices in the tree if possible: arch/arm64/boot/dts/qcom/msm8998-clamshell.dtsi: compatible = "qcom,wcn3990-bt"; arch/arm64/boot/dts/qcom/msm8998-mtp.dtsi: compatible = "qcom,wcn3990-bt"; arch/arm64/boot/dts/qcom/qcs404-evb.dtsi: compatible = "qcom,wcn3990-bt"; arch/arm64/boot/dts/qcom/sdm845-cheza.dtsi: compatible = "qcom,wcn3990-bt"; arch/arm64/boot/dts/qcom/sdm845-db845c.dts: compatible = "qcom,wcn3990-bt"; arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts: compatible = "qcom,wcn3990-bt";