From patchwork Wed Jun 7 09:08:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 9770987 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 156BD6034B for ; Wed, 7 Jun 2017 09:09:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 007C0212BE for ; Wed, 7 Jun 2017 09:09:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E920C28417; Wed, 7 Jun 2017 09:09:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 89913212BE for ; Wed, 7 Jun 2017 09:09:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=k+lHFkWWuWHUixKnnJZ8Lb5LtpmaYjTCj11kwB1ET9c=; b=R/7tci/aMfeqIOahtccuoNq/i0 ytX1OPMRN2/Ut4HQM537N6AEddC3y3kuVpxQUMcR1OaQU+f7duiEt383CHjOz6DkNH8o1ykYHqnJ+ VugCsnl0ApwI8MCOxrnjoMNynUxnSqBGwgyM1Givc9x/Zs/2IMHkobd0yOhO5Gz+J7UCIIMgY8gbB lQxoXOq1cVoDShdNWpnCcFXpLFCbCB+YvGMkD/tnL1kyC/9nGLhp61FxLnoIe0m80jdpiGmSlzt/T qmc7+8wh7e7KRQ6siES7FY618IVve+kOeZcfMTCOKCgm1ibPiMHZz8Zo6vVPPWERCtfnx04f/+jcO /O0KzINQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dIWxy-0003Dq-2D; Wed, 07 Jun 2017 09:09:26 +0000 Received: from mail-lf0-x236.google.com ([2a00:1450:4010:c07::236]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dIWxZ-0002ey-HC for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2017 09:09:03 +0000 Received: by mail-lf0-x236.google.com with SMTP id o83so3022583lff.3 for ; Wed, 07 Jun 2017 02:08:41 -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; bh=OxSLad4lm1TXC9SYRl5pPfrM5e1J/Qyh417cFN0Nsfg=; b=G4n5jeUnW2tYr3HJRhNqXE6vwDcJrn9a5avgNnqnA+coaQfUqcV0bdTABJn8y9np90 rF26K/cC0Sj15aUYjwq5zSYKbvPOA1Lnx03XiAJmRL1FlrKplgif/nLlqWthqOAaDHWD T5eZV0C4HrzVtpSLaph4JVRUcBzkIyV8nVe8w= 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; bh=OxSLad4lm1TXC9SYRl5pPfrM5e1J/Qyh417cFN0Nsfg=; b=I3DvIcXtRyU8TR9cSSyPf7z2bkiYUWYvNc9PoAIgSSj02IPiFYBoeqp4/aeLwlY7ek VB59whqEWOtB/i3z7/d5PtldC4Sb6UvcPAUwaw+lzo7N6dPEYH5WEQtknYfqCLXEjhLn iYkQxUKDXahvreg5HF7pzxvOhhkU5DbgmUpaM3ucJThix0eG3bGpttYuLoyOv/X+tLiI vg5kbvBPY4bEGUVQOTk5qHCkk8tJ4R1FG3JyOuxr8333QYCuLUubulKg9P4xpkbatbxl IAsMyKBGvUT6aFi3PLa9LGD8Uf4dzqxS6irQc9T3BPkiXTaBClkOq8sVTXO1GPPt5+V6 KSuQ== X-Gm-Message-State: AODbwcAlUS25OZ06r+z8O4zz8Rj1Y0GlhZDHMqCOg3HHxNhcWR657hdL yrOAYxxzbpY/PQx8 X-Received: by 10.46.83.83 with SMTP id t19mr9177754ljd.82.1496826519483; Wed, 07 Jun 2017 02:08:39 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-67.NA.cust.bahnhof.se. [158.174.22.67]) by smtp.gmail.com with ESMTPSA id e36sm226271lji.49.2017.06.07.02.08.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jun 2017 02:08:38 -0700 (PDT) From: Ulf Hansson To: Marcel Holtmann , Gustavo Padovan , Johan Hedberg , linux-bluetooth@vger.kernel.org Subject: [PATCH 2/3] Bluetooth: hci_ll: Add support for the external clock Date: Wed, 7 Jun 2017 11:08:21 +0200 Message-Id: <1496826502-1339-3-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496826502-1339-1-git-send-email-ulf.hansson@linaro.org> References: <1496826502-1339-1-git-send-email-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170607_020901_760856_CC1A4263 X-CRM114-Status: GOOD ( 15.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Herring , Ulf Hansson , Arnd Bergmann , Satish Patel , Daniel Lezcano , Wei Xu , John Stultz , Olof Johansson , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add support to manage the external clock provided to the WiLink combo chip as it's needed for any of the transport interfaces. To avoid breaking platforms not yet specifying the external clock, we make it optional. In case the clock is successfully fetched during ->probe(), let's manage it via the ->open|close() callbacks, to make sure the device get properly powered on/off. Fixes: ea452678734e ("arm64: dts: hikey: Fix WiFi support") Signed-off-by: Ulf Hansson --- drivers/bluetooth/hci_ll.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_ll.c b/drivers/bluetooth/hci_ll.c index adc444f..68f3d16 100644 --- a/drivers/bluetooth/hci_ll.c +++ b/drivers/bluetooth/hci_ll.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -84,6 +85,7 @@ struct ll_device { struct hci_uart hu; struct serdev_device *serdev; struct gpio_desc *enable_gpio; + struct clk *ext_clk; }; struct ll_struct { @@ -146,8 +148,12 @@ static int ll_open(struct hci_uart *hu) hu->priv = ll; - if (hu->serdev) + if (hu->serdev) { + struct ll_device *lldev = serdev_device_get_drvdata(hu->serdev); serdev_device_open(hu->serdev); + if (!IS_ERR(lldev->ext_clk)) + clk_prepare_enable(lldev->ext_clk); + } return 0; } @@ -181,6 +187,8 @@ static int ll_close(struct hci_uart *hu) struct ll_device *lldev = serdev_device_get_drvdata(hu->serdev); gpiod_set_value_cansleep(lldev->enable_gpio, 0); + clk_disable_unprepare(lldev->ext_clk); + serdev_device_close(hu->serdev); } @@ -720,6 +728,10 @@ static int hci_ti_probe(struct serdev_device *serdev) if (IS_ERR(lldev->enable_gpio)) return PTR_ERR(lldev->enable_gpio); + lldev->ext_clk = devm_clk_get(&serdev->dev, "ext_clock"); + if (IS_ERR(lldev->ext_clk) && PTR_ERR(lldev->ext_clk) != -ENOENT) + return PTR_ERR(lldev->ext_clk); + of_property_read_u32(serdev->dev.of_node, "max-speed", &max_speed); hci_uart_set_speeds(hu, 115200, max_speed);