Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp108995rwi; Wed, 2 Nov 2022 09:50:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5I0ccYP7UHqPF8Nq2VMANbsA8ZuQalD5ZQGdVBq3xp5oIcUW/fVa/FwhBvjlhuh6Fju2Lq X-Received: by 2002:a05:6402:3213:b0:461:dec8:336d with SMTP id g19-20020a056402321300b00461dec8336dmr26888243eda.221.1667407850496; Wed, 02 Nov 2022 09:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667407850; cv=none; d=google.com; s=arc-20160816; b=WkP75qM2fuOtEt2pcZbKrz4IHM2UWo6mfvRIn+MJ7qA78GZwYwJKwQdZkZywNrbZMO NpMZh6J2/eAXLS9d92Fl26DhSw9P88N6fn0TPkGofdPC4sDCn+oHAEmXadtSpniXhVtb 36gqBm2/zPHYYsUjOUi6hr0Dwe29S+55YBCgoQaGSKWSSL6eRx0Aed9qJphnAiLfw2+z KhlN83yr8/JS6q4Aza8gOAEdZ99jxcvD0sWFLbykNOBwB7dkl8C28wKia1cNIAWLdOz6 lia053rqbJisD4pzdOxEiSJhSIyRMxD2+l1w+8Vklc/xidhzwW0+Yp574aQbGp1whB/z 21Ew== 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=4XK5Cyp7p6i8f2+fuR0IJHEB+iVox8xnrnDJEkhFRW8=; b=dmedbPS1EeQw9j0YnbPIhWSJcTCs1EHAyZTTbY+jG0htfS0q3WmPUpAF1R3sZ/bCA9 szZg/lRLJaZOM7K9Ed5xjnN28tvUd9E99bZ1XBQfm7IZjVCraZJIW3LYZVp3UijWB3Tv r6wkXEkOSllAHVoiClsaIchiZsoVoDLBp5zjqlEouxMoTxz5BTPtOsntfBd1xDRiOCJS r+gnOJtYou2Mciesvj4qJhY0Lxqlnoo/5NvmvtBdBFkztykR1439LldCo+ehSNVD3hQ4 MekAgqx//8Lr/rOm1shmsUYJP4/4pszwaFs5ABheU2JfciXLjE01zlrjY/4yv5TfHUfV Bxzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=d2eHUH0j; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm20-20020a170907949400b0078d8bd255d4si18921601ejc.949.2022.11.02.09.50.05; Wed, 02 Nov 2022 09:50:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=d2eHUH0j; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232093AbiKBQt3 (ORCPT + 99 others); Wed, 2 Nov 2022 12:49:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231963AbiKBQtL (ORCPT ); Wed, 2 Nov 2022 12:49:11 -0400 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51C3A1EEC8; Wed, 2 Nov 2022 09:47:25 -0700 (PDT) Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 4144685072; Wed, 2 Nov 2022 17:47:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1667407643; bh=4XK5Cyp7p6i8f2+fuR0IJHEB+iVox8xnrnDJEkhFRW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d2eHUH0jg9ia1ISjacMN/W263RYlkdx38O8uQcdG4nGv1pBhw7II8FUNN0Zo1vcoP 0RbheIh4FolSfPPm6CgnsdRhPSf0S2HMKSzgnh9gbF5JeDvUMwBcEdShMz7yPjAA+q tvQzWwHiWd+thtGh3UonEgso717pjKxD+G07Lboakk/7fN6r6QCi1yDuXer9IC3ZeB 7MlMNPLWXE+DniWDnGuMMJaPKESJ+bmc3ecKmJ+mDLJrBsHiQI3+0NbRusKGE2Gc0U p6pTOd43oN2kOEqx9ps3gQumFQIxo2ZWo/ZE2jsZv3H9DgEfy85Ih/19z8FgrHy0dg RPcdEXHrowjGw== From: Marek Vasut To: linux-bluetooth@vger.kernel.org Cc: pbrobinson@gmail.com, Marek Vasut , Linus Walleij , Hakan Jansson , Krzysztof Kozlowski , Luiz Augusto von Dentz , Marcel Holtmann , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH v2 2/2] Bluetooth: hci_bcm: Add CYW4373A0 support Date: Wed, 2 Nov 2022 17:47:05 +0100 Message-Id: <20221102164705.14538-2-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221102164705.14538-1-marex@denx.de> References: <20221102164705.14538-1-marex@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org CYW4373A0 is a Wi-Fi + Bluetooth combo device from Cypress. This chip is present e.g. on muRata 2AE module. This chip has additional quirk where the HCI command 0xfc45, used on older chips to switch UART clock from 24 MHz to 48 MHz, to support baudrates over 3 Mbdps, is no longer recognized by this newer chip. This newer chip can configure the 4 Mbdps baudrate without the need to issue HCI command 0xfc45, so add flag to indicate this and do not issue the command on this chip to avoid failure to set 4 Mbdps baud rate. It is not clear whether there is a way to determine which chip does and which chip does not support the HCI command 0xfc45, other than trial and error. Reviewed-by: Linus Walleij Signed-off-by: Marek Vasut --- Cc: Hakan Jansson Cc: Krzysztof Kozlowski Cc: Linus Walleij Cc: Luiz Augusto von Dentz Cc: Marcel Holtmann Cc: Rob Herring Cc: devicetree@vger.kernel.org To: linux-bluetooth@vger.kernel.org --- V2: - Rename bcm4373a0_device_data to cyw4373a0_device_data to be consistent with the rest of the device naming - Add RB from Linus --- drivers/bluetooth/hci_bcm.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c index d7e0b75db8a60..2b6c0e1922cb3 100644 --- a/drivers/bluetooth/hci_bcm.c +++ b/drivers/bluetooth/hci_bcm.c @@ -53,11 +53,13 @@ * struct bcm_device_data - device specific data * @no_early_set_baudrate: Disallow set baudrate before driver setup() * @drive_rts_on_open: drive RTS signal on ->open() when platform requires it + * @no_uart_clock_set: UART clock set command for >3Mbps mode is unavailable * @max_autobaud_speed: max baudrate supported by device in autobaud mode */ struct bcm_device_data { bool no_early_set_baudrate; bool drive_rts_on_open; + bool no_uart_clock_set; u32 max_autobaud_speed; }; @@ -100,6 +102,7 @@ struct bcm_device_data { * @is_suspended: whether flow control is currently disabled * @no_early_set_baudrate: don't set_baudrate before setup() * @drive_rts_on_open: drive RTS signal on ->open() when platform requires it + * @no_uart_clock_set: UART clock set command for >3Mbps mode is unavailable * @pcm_int_params: keep the initial PCM configuration * @use_autobaud_mode: start Bluetooth device in autobaud mode * @max_autobaud_speed: max baudrate supported by device in autobaud mode @@ -140,6 +143,7 @@ struct bcm_device { #endif bool no_early_set_baudrate; bool drive_rts_on_open; + bool no_uart_clock_set; bool use_autobaud_mode; u8 pcm_int_params[5]; u32 max_autobaud_speed; @@ -172,10 +176,11 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed) static int bcm_set_baudrate(struct hci_uart *hu, unsigned int speed) { struct hci_dev *hdev = hu->hdev; + struct bcm_data *bcm = hu->priv; struct sk_buff *skb; struct bcm_update_uart_baud_rate param; - if (speed > 3000000) { + if (speed > 3000000 && !bcm->dev->no_uart_clock_set) { struct bcm_write_uart_clock_setting clock; clock.type = BCM_UART_CLOCK_48MHZ; @@ -1529,6 +1534,7 @@ static int bcm_serdev_probe(struct serdev_device *serdev) bcmdev->max_autobaud_speed = data->max_autobaud_speed; bcmdev->no_early_set_baudrate = data->no_early_set_baudrate; bcmdev->drive_rts_on_open = data->drive_rts_on_open; + bcmdev->no_uart_clock_set = data->no_uart_clock_set; } return hci_uart_register_device(&bcmdev->serdev_hu, &bcm_proto); @@ -1550,6 +1556,10 @@ static struct bcm_device_data bcm43438_device_data = { .drive_rts_on_open = true, }; +static struct bcm_device_data cyw4373a0_device_data = { + .no_uart_clock_set = true, +}; + static struct bcm_device_data cyw55572_device_data = { .max_autobaud_speed = 921600, }; @@ -1566,6 +1576,7 @@ static const struct of_device_id bcm_bluetooth_of_match[] = { { .compatible = "brcm,bcm4349-bt", .data = &bcm43438_device_data }, { .compatible = "brcm,bcm43540-bt", .data = &bcm4354_device_data }, { .compatible = "brcm,bcm4335a0" }, + { .compatible = "cypress,cyw4373a0-bt", .data = &cyw4373a0_device_data }, { .compatible = "infineon,cyw55572-bt", .data = &cyw55572_device_data }, { }, }; -- 2.35.1