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: 103219 Delivered-To: patches@linaro.org Received: by 10.140.91.77 with SMTP id y71csp1831885qgd; Wed, 7 Jun 2017 02:08:39 -0700 (PDT) X-Received: by 10.46.32.158 with SMTP id g30mr5661709lji.39.1496826519863; Wed, 07 Jun 2017 02:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496826519; cv=none; d=google.com; s=arc-20160816; b=YloNDCeSo5cW+2tkcj21H8cuG6KztLhoGJiyWPi3G2VNdSS/ux6nmKAPf8VtHr2Amp gLfujeNJ7MPC3lwe3B0Jsp4XfyHykRQ5ts6GPshva5OoSqR/GQFjAvkwOExxvu1NwI6G CaCx0YxS0Ybn7l2UlNk8x4lAWhurXBETepaBlu7E0d7y/ZtzK1te+DaVVtU1ACQhtoeM D5kiTwgZKdsNF9kOqxvIvZ/YJqbVDul9nqYdororTTtu48hO1EZeRVoDLAofiPyh3cVh xRCQjTMHyDo/zuMMhlUDcM6ePI9+2J0lZwrUGPvaXyc/Ik0/eYAHa5rlJTGs/wmnuMH7 FBMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=OxSLad4lm1TXC9SYRl5pPfrM5e1J/Qyh417cFN0Nsfg=; b=gWCIrPKeZHg+eckkDNLNo8Y/6rh4giGeAe2C/Pb99RzsirUvUp+a0uZ6epqwiR7CO9 M+uUGNOtYKy/oepkyQTpEpMtPhi0Kkp4yfUmFhtBfRzKNm79dtIPbMxUw/+0M17e4giU C9mh4kwtCuphm0xYH6lVxnSqD6S1JxnNe6Lhjuaxbb6i2IXsTuiqo7Yxe+faTY9kzBzl Lv5iC2ksQ/xCrqy8oUfiA3sDvgkDVJyQkC2YROPg9PGqM+unFdvky7h+D97I6FFW+mxF A3+N77ph8bmrLmUZ3AFzTeHGs0HTWXoR93lzWvtQKWkgdsyP1savjcbQ0Cz/SyC/demv EKiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22f as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x22f.google.com (mail-lf0-x22f.google.com. [2a00:1450:4010:c07::22f]) by mx.google.com with ESMTPS id t2si670127ljd.109.2017.06.07.02.08.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jun 2017 02:08:39 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22f as permitted sender) client-ip=2a00:1450:4010:c07::22f; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22f as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x22f.google.com with SMTP id o83so3022584lff.3 for ; Wed, 07 Jun 2017 02:08:39 -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=OneNEJ++Tr1qGOcS1+9LSL1JYgvOpcMA84vIR0+w5qgFKNA9rA6SbKNUAUjfL9e69P TY/hjKPgIVjx/yrmBeWnlG1ViqL55DjqLlHQ24bEmqMbpxEmkgH2ySXS/JESU5Y3ZnGH BWrVIe54nrfI7Lq2pn49I8JvdrXbO8AD+Zg4ujU6akffkkOf9scPcKycsF6/MYid0/jP vNRSk3RDjtdNVPlC42knJeL8risAn7TnNvSfEd04bNc/LKUxtrMwrgN+wDS9GRpBzwZv e43XXmmkUgkpB5qUUWRak+XZegcAHpRbu2E1b227dNvMx2P2h+gLlpNUNVLAhI5Z7KEW 3YXg== X-Gm-Message-State: AODbwcDvgMrpd34n31nszLbc3nZ3/I/Wu+fccVJE1A3O6eL+iglYQnkZ 9v3Rt5gvY7/K+gpx28A= X-Received: by 10.46.83.83 with SMTP id t19mr9177754ljd.82.1496826519483; Wed, 07 Jun 2017 02:08:39 -0700 (PDT) Return-Path: 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 Cc: linux-arm-kernel@lists.infradead.org, Daniel Lezcano , Wei Xu , Rob Herring , John Stultz , Satish Patel , Arnd Bergmann , Olof Johansson , Ulf Hansson 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> 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(-) -- 2.7.4 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);