From patchwork Tue Nov 3 12:09:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 314362 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 582F1C4742C for ; Tue, 3 Nov 2020 12:09:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6B4522264 for ; Tue, 3 Nov 2020 12:09:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="lDUD5G3B" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728902AbgKCMJt (ORCPT ); Tue, 3 Nov 2020 07:09:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728644AbgKCMJt (ORCPT ); Tue, 3 Nov 2020 07:09:49 -0500 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 600FCC0613D1 for ; Tue, 3 Nov 2020 04:09:47 -0800 (PST) Received: by mail-lj1-x243.google.com with SMTP id i2so18794940ljg.4 for ; Tue, 03 Nov 2020 04:09:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wV6Ly4OTVMIHuO3QgeFv/pV+xSUgjDASQ2+fZhKE0+w=; b=lDUD5G3BKbsO7njFX973jlMkuFWjh80WIMfdBSol37Y6t1X0Bb+jVGR1APjJpfXtZD 1GWznh0ZEeQkSOPtWBHJM3b3zwqO+n6tUQaYWSWNUwLWm0+PAaI1ooow9FWkENUow2At HbBICEJVdFfszyoMKS6GHpkglzIfW8knjXi7c6L7pLuLwLsiOs+AdUkdu/Sugyb3DrnK 33EYZaq7FlquURV5ZKFYnZWmdN9Bcqf1qJ4oKLHxYhE2ecCFvGFzK5eRhylmnOLLXoNF 5lzvkU1T+qVcel5YtGr5A0td/tTFYgRoLuItbfGvjICxj0PBG0zmWOQyyfLaHtN13ghy PKvw== 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:mime-version :content-transfer-encoding; bh=wV6Ly4OTVMIHuO3QgeFv/pV+xSUgjDASQ2+fZhKE0+w=; b=H07a/3aT5eoP891zVCaD65/qNl3KNYosR8zCp4eddd7ugNzPwtNSYlswn7O4Uzdza+ RV+SEkavhoU0JMB/81Eg8ApYbK3jwBe8eGyiBcI0qYTz8NRbKRmU9zBsMSYGtq0H+HAp ItkTtGwYgf0aPTVniHZvMbV4PpZ0yW/mcLjI/yfWg+IuikgkKm7TCbRU/sn/dj/UaPsn MpSobFES5UHpPpERmnsnurWXaFPEDHDDPvBSv0VIeFjCTnF/eUEnsvATDcrvWwtKqaq6 wLDmhwhDT8fPuj/cWZ6idKlrK0wss68twcPbobHBNfNM3LroEDVjnwDpIdkrMlAH8aUZ z/aA== X-Gm-Message-State: AOAM5335x1ERLd9NeuWt6MON97MBqQ42txE+gK9jZ2pKUtKxX/YKPNyq 4egh+YQB7/cod3CN7ZyTteXimg0i4pct00t9 X-Google-Smtp-Source: ABdhPJzP8QkebpLumvWNek0wptLkNxKJKP5M8iwRa97pDBpiEMCZ6DJAVA0MWItt8ZuCfpPOuMyvcQ== X-Received: by 2002:a2e:8350:: with SMTP id l16mr698947ljh.128.1604405385766; Tue, 03 Nov 2020 04:09:45 -0800 (PST) Received: from localhost.bredbandsbolaget (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id p18sm4155723ljn.127.2020.11.03.04.09.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 04:09:45 -0800 (PST) From: Linus Walleij To: Marcel Holtmann , Johan Hedberg Cc: linux-bluetooth@vger.kernel.org, Linus Walleij , devicetree@vger.kernel.org Subject: [PATCH 1/2] Bluetooth: btbcm: Rewrite bindings i YAML and add reset Date: Tue, 3 Nov 2020 13:09:42 +0100 Message-Id: <20201103120943.1289277-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This rewrites the Broadcom bluetooth bindings in YAML and adds a GPIO handle for the BT_RST_N line as used on some platforms. Cc: devicetree@vger.kernel.org Signed-off-by: Linus Walleij --- .../bindings/net/broadcom-bluetooth.txt | 56 --------- .../bindings/net/broadcom-bluetooth.yaml | 117 ++++++++++++++++++ 2 files changed, 117 insertions(+), 56 deletions(-) delete mode 100644 Documentation/devicetree/bindings/net/broadcom-bluetooth.txt create mode 100644 Documentation/devicetree/bindings/net/broadcom-bluetooth.yaml diff --git a/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt b/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt deleted file mode 100644 index a7d57ba5f2ac..000000000000 --- a/Documentation/devicetree/bindings/net/broadcom-bluetooth.txt +++ /dev/null @@ -1,56 +0,0 @@ -Broadcom Bluetooth Chips ---------------------- - -This documents the binding structure and common properties for serial -attached Broadcom devices. - -Serial attached Broadcom devices shall be a child node of the host UART -device the slave device is attached to. - -Required properties: - - - compatible: should contain one of the following: - * "brcm,bcm20702a1" - * "brcm,bcm4329-bt" - * "brcm,bcm4330-bt" - * "brcm,bcm43438-bt" - * "brcm,bcm4345c5" - * "brcm,bcm43540-bt" - * "brcm,bcm4335a0" - -Optional properties: - - - max-speed: see Documentation/devicetree/bindings/serial/serial.yaml - - shutdown-gpios: GPIO specifier, used to enable the BT module - - device-wakeup-gpios: GPIO specifier, used to wakeup the controller - - host-wakeup-gpios: GPIO specifier, used to wakeup the host processor. - deprecated, replaced by interrupts and - "host-wakeup" interrupt-names - - clocks: 1 or 2 clocks as defined in clock-names below, in that order - - clock-names: names for clock inputs, matching the clocks given - - "extclk": deprecated, replaced by "txco" - - "txco": external reference clock (not a standalone crystal) - - "lpo": external low power 32.768 kHz clock - - vbat-supply: phandle to regulator supply for VBAT - - vddio-supply: phandle to regulator supply for VDDIO - - brcm,bt-pcm-int-params: configure PCM parameters via a 5-byte array - - sco-routing: 0 = PCM, 1 = Transport, 2 = Codec, 3 = I2S - - pcm-interface-rate: 128KBps, 256KBps, 512KBps, 1024KBps, 2048KBps - - pcm-frame-type: short, long - - pcm-sync-mode: slave, master - - pcm-clock-mode: slave, master - - interrupts: must be one, used to wakeup the host processor - - interrupt-names: must be "host-wakeup" - -Example: - -&uart2 { - pinctrl-names = "default"; - pinctrl-0 = <&uart2_pins>; - - bluetooth { - compatible = "brcm,bcm43438-bt"; - max-speed = <921600>; - brcm,bt-pcm-int-params = [01 02 00 01 01]; - }; -}; diff --git a/Documentation/devicetree/bindings/net/broadcom-bluetooth.yaml b/Documentation/devicetree/bindings/net/broadcom-bluetooth.yaml new file mode 100644 index 000000000000..bdd6ca617e23 --- /dev/null +++ b/Documentation/devicetree/bindings/net/broadcom-bluetooth.yaml @@ -0,0 +1,117 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/broadcom-bluetooth.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom Bluetooth Chips + +maintainers: + - Linus Walleij + +description: + This binding describes Broadcom UART-attached bluetooth chips. + +properties: + compatible: + enum: + - brcm,bcm20702a1 + - brcm,bcm4329-bt + - brcm,bcm4330-bt + - brcm,bcm43438-bt + - brcm,bcm4345c5 + - brcm,bcm43540-bt + - brcm,bcm4335a0 + + shutdown-gpios: + maxItems: 1 + description: GPIO specifier for the line BT_REG_ON used to + power on the BT module + + reset-gpios: + maxItems: 1 + description: GPIO specifier for the line BT_RST_N used to + reset the BT module. This should be marked as + GPIO_ACTIVE_LOW. + + device-wakeup-gpios: + maxItems: 1 + description: GPIO specifier for the line BT_WAKE used to + wakeup the controller. This is using the BT_GPIO_0 + pin on the chip when in use. + + host-wakeup-gpios: + maxItems: 1 + deprecated: true + description: GPIO specifier for the line HOST_WAKE used + to wakeup the host processor. This is using he BT_GPIO_1 + pin on the chip when in use. This is deprecated and replaced + by interrupts and "host-wakeup" interrupt-names + + clocks: + maxItems: 2 + description: 1 or 2 clocks as defined in clock-names below, + in that order + + clock-names: + description: Names of the 1 to 2 supplied clocks + items: + - const: txco + - const: lpo + - const: extclk + + vbat-supply: + description: phandle to regulator supply for VBAT + + vddio-supply: + description: phandle to regulator supply for VDDIO + + brcm,bt-pcm-int-params: + $ref: /schemas/types.yaml#/definitions/uint8-array + minItems: 5 + maxItems: 5 + description: |- + configure PCM parameters via a 5-byte array: + sco-routing: 0 = PCM, 1 = Transport, 2 = Codec, 3 = I2S + pcm-interface-rate: 128KBps, 256KBps, 512KBps, 1024KBps, 2048KBps + pcm-frame-type: short, long + pcm-sync-mode: slave, master + pcm-clock-mode: slave, master + + interrupts: + items: + - description: Handle to the line HOST_WAKE used to wake + up the host processor. This uses the BT_GPIO_1 pin on + the chip when in use. + + interrupt-names: + items: + - const: host-wakeup + + max-speed: true + current-speed: true + +required: + - compatible + +additionalProperties: false + +examples: + - | + #include + #include + + uart { + uart-has-rtscts; + + bluetooth { + compatible = "brcm,bcm4330-bt"; + max-speed = <921600>; + brcm,bt-pcm-int-params = [01 02 00 01 01]; + shutdown-gpios = <&gpio 30 GPIO_ACTIVE_HIGH>; + device-wakeup-gpios = <&gpio 7 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio 9 GPIO_ACTIVE_LOW>; + interrupt-parent = <&gpio>; + interrupts = <8 IRQ_TYPE_EDGE_FALLING>; + }; + }; From patchwork Tue Nov 3 12:09:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 320405 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp4528486ilc; Tue, 3 Nov 2020 04:09:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwe5n+te/NrMOdRak8EnGgH5jg+iMbrsggoGOZq999RAURYk6b/5OB/y1WZbT8cjYacc9ZW X-Received: by 2002:a17:906:eb57:: with SMTP id mc23mr19383871ejb.373.1604405391686; Tue, 03 Nov 2020 04:09:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604405391; cv=none; d=google.com; s=arc-20160816; b=XmkjUSXlF7riX7CE6KVcsN98xz3PBaLpw0FKGXRX2KMbzDVQ4L/KIQ0vRaAdLc+Eoc BBtEz3ckpq5wO9fdW6mBA/EUEUa3bb/yqQ4+d2LskYnLsK5O5cDiXsgdHVKeAzp2jl4+ 2jCREZ87h/uw6OuotNGpFjWwoyCEnHEpmfpbWqEH4KrNJXNzmqruZrGzim8mvJ53zY95 biFLdNGOQUEEGMPCfG7XcilaV2lTBNF1uvJEHI6npMsjmFeazkeJQyRVm1u1VAcVc3u5 mVytfJjsWpKMcDeTToNX0RsAz2FAwoI9ngEjXXHRaJXZJdButRzQTYeVNcuzBhi1UTvv +LoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pXw+4mvpHTL0090esXvbC0/ocXQHd2mKNDoOfKKak1Y=; b=vrxAtNvCaVAacaz/wr0ipkqZ6W1V/dQqkknHmDw3zY8scLVEbkN6PZnvHeUEPkUHbn KCEREIeJyyf+QyVtjAn10y6hszIt1krq8+YadV0swVrK723ulV7KaosjFMr9jbVxFN1g NzATMre9M//z04hzzs/CDInRMxRYutcTTWOlNNnwt54OX2rpZVCHezgztyU1EfF5trE9 jbEgWt/mu7c7+zjuzzFEGhT+Ce4z3TYAhqjxk15JIAWmXHin8h/EiY1ArQx4p+UjDDpU czUukFgHAguqS3cUKGdlAXm0Lhv4vpjjFjFscCQ2RYREFZGxus2ShJ74DU0/wZnaJFOj GwQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=syFMOrEJ; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f21si1201415ejk.90.2020.11.03.04.09.51; Tue, 03 Nov 2020 04:09:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=syFMOrEJ; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728948AbgKCMJv (ORCPT + 1 other); Tue, 3 Nov 2020 07:09:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728644AbgKCMJu (ORCPT ); Tue, 3 Nov 2020 07:09:50 -0500 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBE68C0613D1 for ; Tue, 3 Nov 2020 04:09:49 -0800 (PST) Received: by mail-lj1-x242.google.com with SMTP id o13so10461339ljj.11 for ; Tue, 03 Nov 2020 04:09:49 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=pXw+4mvpHTL0090esXvbC0/ocXQHd2mKNDoOfKKak1Y=; b=syFMOrEJOfYJj9/XmAs2cGnnCf6XnD3oP5+Jo8vfxhcbw58xPE7GAm/8BMNf1xVQ2h GWS8EnzFAT2H9F/BLkhfbmAtDZy+eovdrKCNTDxt18I4LPvq/kgELa5SxAmlK02Y6pR5 9H/CeGWslniyaWpUIlx61DW0IXXmOJtNFzOJLogl//KWMzHxBnAbCuyIrrEKhHaZr0bd AKfU2afnpJlYBrhH5gVTIHXysqwTjs5wH6uZF6ksJf1icyQ/6r4zbwSHtUR6bEd26r+m N1Z5AvrmqO0RA60F3wQS0vnynguDKXhYhHJt8EQl0goPK9Y9AoK5CQjrsPy52thXnlYq yemQ== 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:mime-version:content-transfer-encoding; bh=pXw+4mvpHTL0090esXvbC0/ocXQHd2mKNDoOfKKak1Y=; b=Sl4OErtOgkJupOLIIAL2mY8KAFJL6yhAguZEXOwBGkZx5pmAYpgu4oY0B1COhP2R5G 3grdMFP0KNtAHPgChlcCEUtpfE24uHHzWQweR14x4ieS6wmyPTgual0IOd6Is/x1EBzQ dBR/+DNJvnnIwFonnHytrMvhGoClbf2qhhV8G1nwgv9xDKwRC6dVWgRGodx4CCLZldiP GaO4uoUohxVjzpMt9gCKwB1R0y2d83y15qGjbYia0ypqnP+6jiARgkuh+j8I4josh7+I 7sCECz8evsOKIGA8AzUb+HsAhQzaNgi07JvOFb4JrRGGTTCtH4DshgJUJ23SvwHxwZdf PmRQ== X-Gm-Message-State: AOAM533CHg1yq7SABbNJ/5fpCqpCHynCJDMO8lwT5xjKsR5L7q1MvUvK iKB+kf1vydwQ1CEI6orZgUmm+A== X-Received: by 2002:a05:651c:1a6:: with SMTP id c6mr6768863ljn.244.1604405388189; Tue, 03 Nov 2020 04:09:48 -0800 (PST) Received: from localhost.bredbandsbolaget (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id p18sm4155723ljn.127.2020.11.03.04.09.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 04:09:47 -0800 (PST) From: Linus Walleij To: Marcel Holtmann , Johan Hedberg Cc: linux-bluetooth@vger.kernel.org, Linus Walleij Subject: [PATCH 2/2] Bluetooth: btbcm: Obtain and handle reset GPIO Date: Tue, 3 Nov 2020 13:09:43 +0100 Message-Id: <20201103120943.1289277-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201103120943.1289277-1-linus.walleij@linaro.org> References: <20201103120943.1289277-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Obtain and drive the optional reset GPIO line if this is not hardwired in the platform. This is needed on the Samsung GT-I9070 mobile phone. The invers of power is used, this should be OK to apply simultaneously as the power signal according to figures 47-51 on pages 159-161 in the BCM4330 datasheet. Signed-off-by: Linus Walleij --- drivers/bluetooth/hci_bcm.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) -- 2.26.2 diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c index 8ea5ca8d71d6..15a28b90c2d0 100644 --- a/drivers/bluetooth/hci_bcm.c +++ b/drivers/bluetooth/hci_bcm.c @@ -68,6 +68,8 @@ struct bcm_device_data { * deassert = Bluetooth device may sleep when sleep criteria are met * @shutdown: BT_REG_ON pin, * power up or power down Bluetooth device internal regulators + * @reset: BT_RST_N pin, + * active low resets the Bluetooth logic core * @set_device_wakeup: callback to toggle BT_WAKE pin * either by accessing @device_wakeup or by calling @btlp * @set_shutdown: callback to toggle BT_REG_ON pin @@ -101,6 +103,7 @@ struct bcm_device { const char *name; struct gpio_desc *device_wakeup; struct gpio_desc *shutdown; + struct gpio_desc *reset; int (*set_device_wakeup)(struct bcm_device *, bool); int (*set_shutdown)(struct bcm_device *, bool); #ifdef CONFIG_ACPI @@ -984,6 +987,15 @@ static int bcm_gpio_set_device_wakeup(struct bcm_device *dev, bool awake) static int bcm_gpio_set_shutdown(struct bcm_device *dev, bool powered) { gpiod_set_value_cansleep(dev->shutdown, powered); + if (dev->reset) + /* + * The reset line is asserted on powerdown and deasserted + * on poweron so the inverse of powered is used. Notice + * that the GPIO line BT_RST_N needs to be specified as + * active low in the device tree or similar system + * description. + */ + gpiod_set_value_cansleep(dev->reset, !powered); return 0; } @@ -1049,6 +1061,11 @@ static int bcm_get_resources(struct bcm_device *dev) if (IS_ERR(dev->shutdown)) return PTR_ERR(dev->shutdown); + dev->reset = devm_gpiod_get_optional(dev->dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(dev->reset)) + return PTR_ERR(dev->reset); + dev->set_device_wakeup = bcm_gpio_set_device_wakeup; dev->set_shutdown = bcm_gpio_set_shutdown;