Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2444580ybc; Sun, 17 Nov 2019 22:02:51 -0800 (PST) X-Google-Smtp-Source: APXvYqzZ8erLVu2ryzDqMDgRkuj0fIvSM46taU1PAq5NJi1UJxlsKrIbEff0K7Eg6DyhkWT3V0Pa X-Received: by 2002:a17:906:7e08:: with SMTP id e8mr24283950ejr.199.1574056971827; Sun, 17 Nov 2019 22:02:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574056971; cv=none; d=google.com; s=arc-20160816; b=WqmfsN/6sUET5hMUt/Pyun5K2C1p6ovyPutvR1zH4J8LdJcP6AVEG+sjU2bQ88RCQc TAsj6XZ+u/7DXds3rY83HOYztE0sOb2MySojUqfFKgFX21Bq/AyoGKB+tGmH82fII48I h0t1aKwDznr+AZj2LdfigW5afta6tX0GymF4xmNEK7ct9jhh8bsAHlUe1qp4iYxxWMxc 2zNm9pchgA9GpD2SeCaqtzdSSxMXSKnlvqCxP6QlR3py6a2+24ECgGJFiIADMWxMXnD4 nMKEiwtWgmW+X7FDKH0u3XPUvCv4aB/w708t56zeadhMV5BilC+JZXDvW3JvPdKY3mLu FDuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:feedback-id:user-agent:message-id :references:in-reply-to:subject:cc:to:from:date :content-transfer-encoding:mime-version:dkim-signature :dkim-signature; bh=ByI46q1Cf//ovm7KFCSLF5yLoHtIIgrWExgOG8jqecI=; b=A34LgAZf8xtqE4WVFUu0KJuFDkqndIVH2rPXMRYVR/IuKlzc4B5AdQ2XF5UKxFfX9k GjOqAXHOYh/NqgtNmFW8UjXyN5++aBDS4fS2llQqONRb1kW/HBXL0T34I2zRxBRGUPdC chik9KDK8thWrsPcHMOvTPeDHTcKHfmI56PxGJ2FdaoMbngMOZ2ipGnGF3IBbyomfV7g x25AlQ8doLuAGTTthhFKi3gweCd7Hbl7Bj8+1AZawHqBj9uIUVjDTL7C+iinzBcY5ISD T2VBcWCYGr3AYNjUXp70+NP3tEMaeH9KiwEEmdZcVy/bta2P9qFdU9VZCA+T+Jvi6MWd TOkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=zsmsymrwgfyinv5wlfyidntwsjeeldzt header.b=hrlrNkJ3; dkim=pass header.i=@amazonses.com header.s=gdwg2y3kokkkj5a55z2ilkup5wp5hhxx header.b=HHCuCMCz; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f29si11386021ejj.110.2019.11.17.22.02.10; Sun, 17 Nov 2019 22:02:51 -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=@codeaurora.org header.s=zsmsymrwgfyinv5wlfyidntwsjeeldzt header.b=hrlrNkJ3; dkim=pass header.i=@amazonses.com header.s=gdwg2y3kokkkj5a55z2ilkup5wp5hhxx header.b=HHCuCMCz; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726513AbfKRGBz (ORCPT + 99 others); Mon, 18 Nov 2019 01:01:55 -0500 Received: from a27-188.smtp-out.us-west-2.amazonses.com ([54.240.27.188]:48848 "EHLO a27-188.smtp-out.us-west-2.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726140AbfKRGBy (ORCPT ); Mon, 18 Nov 2019 01:01:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=zsmsymrwgfyinv5wlfyidntwsjeeldzt; d=codeaurora.org; t=1574056913; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Date:From:To:Cc:Subject:In-Reply-To:References:Message-ID; bh=Yancb5dODX/2FNvCl/6xMdvPhXPIMMHBTGHGYXMnW+s=; b=hrlrNkJ3nDFj/ygJSWJeIXMjQ/5t2xnKTaEUuntC6p+tKYFsMSrukzp9TDkAcIGB N/l1a4k8r0u+/ZH3cAErH77XLuyMvwFSUzSRO48PIPFYTHebU9NX3o6fHyN/fG5mBY9 9wpiYGbiyBnCUUpjUj8AH1SPu1TEeTLvIAC8x4CA= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=gdwg2y3kokkkj5a55z2ilkup5wp5hhxx; d=amazonses.com; t=1574056913; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Date:From:To:Cc:Subject:In-Reply-To:References:Message-ID:Feedback-ID; bh=Yancb5dODX/2FNvCl/6xMdvPhXPIMMHBTGHGYXMnW+s=; b=HHCuCMCzyUv3MSyoMrOUBPvvDp2xT3K34LIoDVyz1kNv/q+tUmkC162NUFqXYqRJ ntUmUp1isQxpVDPsXKvHCgF4hW6j0AKGCbMtctJ6we/p3ml7rys3LUrokW8hr/ZHup0 VDhKxGa2rs6bzFNIb0e45VJN4ILBvPc82fA7vOfE= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 18 Nov 2019 06:01:53 +0000 From: bgodavar@codeaurora.org To: Marcel Holtmann Cc: Johan Hedberg , Matthias Kaehlcke , lkml , 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 In-Reply-To: <39626995-672E-4D6A-8BD5-9E5D9272553B@holtmann.org> References: <20191114081430.25427-1-bgodavar@codeaurora.org> <39626995-672E-4D6A-8BD5-9E5D9272553B@holtmann.org> Message-ID: <0101016e7d1a6a67-d4af94cf-407a-4215-bd48-82d33990d5bb-000000@us-west-2.amazonses.com> X-Sender: bgodavar@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 X-SES-Outgoing: 2019.11.18-54.240.27.188 Feedback-ID: 1.us-west-2.CZuq2qbDmUIuT3qdvXlRHZZCpfZqZ4GtG9v3VKgRyF0=:AmazonSES Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On 2019-11-14 14:25, Marcel Holtmann wrote: > Hi Balakrishna, > >> 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); > > I really dislike forward declaration. Only use them if they are really > really needed. That said, this driver might actually need cleanups > since I just realized it has tons of forward declarations. > [Bala]: agree, will work on this change. >> 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) { > > There comes a point when using a switch statement is a lot easier to > read. See if that has been reached and if there are other places that > would benefit from a cleanup patch. > [Bala] : will work on this. > Regards > > Marcel