Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2507601ybi; Sat, 1 Jun 2019 18:08:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqylPmbhzKnZcVsP/ZAZzvX+bd6yXvvoHKsNDFm9gAFVa5gFIxA5TM8EKekaonb/KDdr1JYB X-Received: by 2002:a63:a41:: with SMTP id z1mr18802937pgk.389.1559437731649; Sat, 01 Jun 2019 18:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559437731; cv=none; d=google.com; s=arc-20160816; b=sedLKsNxd4VePRPAZT5i9hfFHA8qe+sPjuYzcNyU/2yKq4HIJ1hF+526IQ8HtNhgE+ p1myiSmgQHRgTk2WuIghWiNH6u920GlXuql3lJLxt0Uaf3rjdxIgllAGRBp/n36hAFep 42opb3Z8wesPV7mPuyl29uIga/bOxalnIesGJbVteUo8KSzcOqBv3HXRWJn3WpC40mOI fFRztdfrHgTtBZJEky7fnajnmBb9R39/sIJi8jtrdF2x3+AyLmrjnOfJRM3CxkSEMoSO BXuIKdCL2pqtZMdFIelkpeuaF6zF6clNR1PM9T9CpDo66O8QAtXQdDpmGvj8DY2CHa10 SdHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=TeuOYjG3FdarsDb0o+L+k5faoj/HRAoDad8FCNSD+Ws=; b=RcFdAjwnuwJPYny7rv98NIpswgY+jUUSokVXeNgHhArkiyK+F4UkumL/t/SwKGORd/ NflBv+6eHhGIw2vMQJBvuLp1SkOzOW2f9n3xJNs8fRqZd7dpFkZ2XssmRywR49eOf/Uu yh3azHwdLh1Vrn1lLym2wka6hSX7bRs1ayBarDyYBwrPC7eDix98sMIJRfp7Kywm1J9z VW/KMHCuYyaAIwDIRjhriak0lnLVMo3xB1sOZfPkBcCX+zSdPeom/VQKqzwJgZx+MQ9Q yFr8k5cZqh2k+0GzHGHBWe1kZcaU33+i7pT62wcxEWQxbVGxAt/Z8wJ8I13/kk3uI+bs X07g== ARC-Authentication-Results: i=1; mx.google.com; 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 i14si14686318pfe.187.2019.06.01.18.08.37; Sat, 01 Jun 2019 18:08:51 -0700 (PDT) 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; 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 S1726840AbfFBBE5 (ORCPT + 99 others); Sat, 1 Jun 2019 21:04:57 -0400 Received: from mailgw02.mediatek.com ([216.200.240.185]:57513 "EHLO mailgw02.mediatek.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726211AbfFBBE5 (ORCPT ); Sat, 1 Jun 2019 21:04:57 -0400 X-UUID: d94cac872b104b4c8cc425c4ebba2e79-20190601 X-UUID: d94cac872b104b4c8cc425c4ebba2e79-20190601 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 2052023471; Sat, 01 Jun 2019 17:04:27 -0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sat, 1 Jun 2019 18:04:25 -0700 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Sun, 2 Jun 2019 09:04:24 +0800 From: To: , , , CC: , , , , , Sean Wang Subject: [PATCH v1 4/4] Bluetooth: btmtkuart: add an implementation for clock osc property Date: Sun, 2 Jun 2019 09:04:17 +0800 Message-ID: <1559437457-26766-5-git-send-email-sean.wang@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1559437457-26766-1-git-send-email-sean.wang@mediatek.com> References: <1559437457-26766-1-git-send-email-sean.wang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Sean Wang Some board requires explicitily control external osscilator via GPIO. So, add an implementation of a clock property for an external oscillator to the device. Signed-off-by: Sean Wang --- drivers/bluetooth/btmtkuart.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/bluetooth/btmtkuart.c b/drivers/bluetooth/btmtkuart.c index 1257149cfdc4..e11169ad8247 100644 --- a/drivers/bluetooth/btmtkuart.c +++ b/drivers/bluetooth/btmtkuart.c @@ -115,8 +115,9 @@ struct btmtk_hci_wmt_params { struct btmtkuart_dev { struct hci_dev *hdev; struct serdev_device *serdev; - struct clk *clk; + struct clk *clk; + struct clk *osc; struct regulator *vcc; struct gpio_desc *reset; struct gpio_desc *boot; @@ -912,6 +913,12 @@ static int btmtkuart_parse_dt(struct serdev_device *serdev) return err; } + bdev->osc = devm_clk_get_optional(&serdev->dev, "osc"); + if (IS_ERR(bdev->osc)) { + err = PTR_ERR(bdev->osc); + return err; + } + bdev->boot = devm_gpiod_get_optional(&serdev->dev, "boot", GPIOD_OUT_LOW); if (IS_ERR(bdev->boot)) { @@ -1006,6 +1013,10 @@ static int btmtkuart_probe(struct serdev_device *serdev) set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks); if (btmtkuart_is_standalone(bdev)) { + err = clk_prepare_enable(bdev->osc); + if (err < 0) + return err; + if (bdev->boot) { gpiod_set_value_cansleep(bdev->boot, 1); } else { @@ -1017,8 +1028,10 @@ static int btmtkuart_probe(struct serdev_device *serdev) /* Power on */ err = regulator_enable(bdev->vcc); - if (err < 0) + if (err < 0) { + clk_disable_unprepare(bdev->osc); return err; + } /* Reset if the reset-gpios is available otherwise the board * -level design should be guaranteed. @@ -1068,8 +1081,10 @@ static void btmtkuart_remove(struct serdev_device *serdev) struct btmtkuart_dev *bdev = serdev_device_get_drvdata(serdev); struct hci_dev *hdev = bdev->hdev; - if (btmtkuart_is_standalone(bdev)) + if (btmtkuart_is_standalone(bdev)) { regulator_disable(bdev->vcc); + clk_disable_unprepare(bdev->osc); + } hci_unregister_dev(hdev); hci_free_dev(hdev); -- 2.17.1