Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6863540ybx; Mon, 11 Nov 2019 16:21:11 -0800 (PST) X-Google-Smtp-Source: APXvYqyvPgd9YjgkDduDjq/ZU4oB8qlYBpoywwTgkYLYXejOyufm9cdpnHqmiQKb7Kdf0L6gK1k7 X-Received: by 2002:a50:d713:: with SMTP id t19mr29929158edi.185.1573518071756; Mon, 11 Nov 2019 16:21:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573518071; cv=none; d=google.com; s=arc-20160816; b=kO4O8cLqnv/KTRjoBQXbHMppPLyKEGF69xjvC6A1Dcn9PUDtxgDau0QPZphbcre7B2 ZSFRIYoCM/puXS3wPwwDbdIV1tEQLuqixZORl1LtLFbeWT3JZ5ermEZO++P1TLBfMryR V+u0oJig9VzjgmTMavwSdr28V2PDuDBifj9wSeaE2PoyY+Do1tH9V5W1UWHW1WSvjnv7 iqD8yZ7JPWua81YlUJneTlznuJj8MF2sq4P/egm6oqNcuq+VWhEGx5+CD0Y8qtaVQGYH 5bq8eCxKQxDIfCcg46a9IaBPs5ECyN3pyz9oGrjYiy8g+fXSRG8tFux3fTDoH4rvV8A7 4aHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qcCI16g4dO/Qrfro0uo1Fa9EI3/y1R2NeWHuFFGKbTs=; b=rnuFKmanASemPgLXvwDLAicC4uM6tPsdO3+xM/ZATKxqfjbpi4ptQetRN1xM1feQVc KWL/ojYe9gftvJt6uI9itzQN1qrVVMxWyhEdVCLNOhBIntHREPbl3LU2gn2arpZdYggl fvVzU0+zqqJ593TLT49IZC7o8BWbHNi2lEf758A5oXZfDoWSjB86SPbh6rkVbkHKzVC3 jSgLKXxTn1Cy8sbjOhtEzYuz4aEFczOvtN4kI81ouvhYdE9OJHR70O3oR+pcC9hzhmF+ y01XaazwRq5g6DN9MT02YCx/SQl/RHWCNxLZk6Qtha2a49mv7SZ7iORYY18+iGYWJPa8 TPSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="PVm/Dskz"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l13si5488822eja.13.2019.11.11.16.20.48; Mon, 11 Nov 2019 16:21:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="PVm/Dskz"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727254AbfKLAUE (ORCPT + 99 others); Mon, 11 Nov 2019 19:20:04 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45104 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726958AbfKLAUD (ORCPT ); Mon, 11 Nov 2019 19:20:03 -0500 Received: by mail-pf1-f196.google.com with SMTP id z4so11930742pfn.12 for ; Mon, 11 Nov 2019 16:20:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qcCI16g4dO/Qrfro0uo1Fa9EI3/y1R2NeWHuFFGKbTs=; b=PVm/DskzvIOtIK+GQa0comOTWHhuqkF4T7Kxr4lb1uzHf/pjNtvYKE6GmhvZf+uAdp ZU6z0A7hraMCVUE5jHz1MjQXbYEeD8xrFFPTeUIBlIR0WXe6xVIz8UbMkHD4+K0i7aD+ Fygs01VY/bqT9SoHvfFvxEoG7UF7UMrao0xmQ= 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=qcCI16g4dO/Qrfro0uo1Fa9EI3/y1R2NeWHuFFGKbTs=; b=SZJAJQXgmfh92e5+IU8BUNc7ospLxlk/GyaqgzTctgN17B81tUjBWGaQEbtydgYfs6 rxFnIKuI/LqyWiOopWdquBgSl4+x38R5kj7kFurUEmyii+HDYjOepkCcya4jt0nDsvn9 JQ0V2HK/Jka3tYd4dSKX3IAKiH81nSNrHQE7jnIqDWtPRGjLBddVgE7zeBEcrX2av5Xm Vwqc889Nul5qIdEKHZMt7oWHFmysD/0aIGS8PK/50Je4g5GT4aHuwq+Mc1uue0aYFMVf TbxJ4zaYBIFTYrV57K3k6BXXj4CYECJuNslPW2jriJ1JSDgfyxGq4vfzWMEi1UTt1BDQ MbZw== X-Gm-Message-State: APjAAAUhMlSohUbJSUWh3AI8SIB06JrExEClZ3JRLF1pXMegfwZMuBKv XyFUrZvxPMM44OWSwBoxgmKKuizJxHM= X-Received: by 2002:a63:1a51:: with SMTP id a17mr30972921pgm.449.1573518001020; Mon, 11 Nov 2019 16:20:01 -0800 (PST) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:e09a:8d06:a338:aafb]) by smtp.gmail.com with ESMTPSA id h23sm8430898pgg.58.2019.11.11.16.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 16:20:00 -0800 (PST) From: Abhishek Pandit-Subedi To: Marcel Holtmann , Johan Hedberg , Rob Herring Cc: linux-bluetooth@vger.kernel.org, dianders@chromium.org, Abhishek Pandit-Subedi , linux-kernel@vger.kernel.org Subject: [PATCH v3 1/4] Bluetooth: hci_bcm: Disallow set_baudrate for BCM4354 Date: Mon, 11 Nov 2019 16:19:46 -0800 Message-Id: <20191112001949.136377-2-abhishekpandit@chromium.org> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191112001949.136377-1-abhishekpandit@chromium.org> References: <20191112001949.136377-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Without updating the patchram, the BCM4354 does not support a higher operating speed. The normal bcm_setup follows the correct order (init_speed, patchram and then oper_speed) but the serdev driver will set the operating speed before calling the hu->setup function. Thus, for the BCM4354, disallow setting the operating speed before patchram. If set_baudrate is called before setup, it will return -EBUSY. Signed-off-by: Abhishek Pandit-Subedi --- Changes in v3: None Changes in v2: None drivers/bluetooth/hci_bcm.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c index 0f851c0dde7f..6134bff58748 100644 --- a/drivers/bluetooth/hci_bcm.c +++ b/drivers/bluetooth/hci_bcm.c @@ -47,6 +47,14 @@ #define BCM_NUM_SUPPLIES 2 +/** + * struct bcm_device_data - device specific data + * @no_early_set_baudrate: Disallow set baudrate before driver setup() + */ +struct bcm_device_data { + bool no_early_set_baudrate; +}; + /** * struct bcm_device - device driver resources * @serdev_hu: HCI UART controller struct @@ -79,6 +87,7 @@ * @hu: pointer to HCI UART controller struct, * used to disable flow control during runtime suspend and system sleep * @is_suspended: whether flow control is currently disabled + * @disallow_set_baudrate: don't allow set_baudrate */ struct bcm_device { /* Must be the first member, hci_serdev.c expects this. */ @@ -112,6 +121,7 @@ struct bcm_device { struct hci_uart *hu; bool is_suspended; #endif + bool disallow_set_baudrate; }; /* generic bcm uart resources */ @@ -141,9 +151,13 @@ 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 (bcm && bcm->dev && bcm->dev->disallow_set_baudrate) + return -EBUSY; + if (speed > 3000000) { struct bcm_write_uart_clock_setting clock; @@ -551,6 +565,12 @@ static int bcm_setup(struct hci_uart *hu) goto finalize; } + /* If we disallow early set baudrate, we can re-enable it now that + * patchram is done + */ + if (bcm->dev && bcm->dev->disallow_set_baudrate) + bcm->dev->disallow_set_baudrate = false; + /* Init speed if any */ if (hu->init_speed) speed = hu->init_speed; @@ -1371,6 +1391,15 @@ static struct platform_driver bcm_driver = { }, }; +static void bcm_configure_device_data(struct bcm_device *bdev) +{ + const struct bcm_device_data *data = device_get_match_data(bdev->dev); + + if (data) { + bdev->disallow_set_baudrate = data->no_early_set_baudrate; + } +} + static int bcm_serdev_probe(struct serdev_device *serdev) { struct bcm_device *bcmdev; @@ -1408,6 +1437,8 @@ static int bcm_serdev_probe(struct serdev_device *serdev) if (err) dev_err(&serdev->dev, "Failed to power down\n"); + bcm_configure_device_data(bcmdev); + return hci_uart_register_device(&bcmdev->serdev_hu, &bcm_proto); } @@ -1419,12 +1450,16 @@ static void bcm_serdev_remove(struct serdev_device *serdev) } #ifdef CONFIG_OF +struct bcm_device_data bcm4354_device_data = { + .no_early_set_baudrate = true, +}; + static const struct of_device_id bcm_bluetooth_of_match[] = { { .compatible = "brcm,bcm20702a1" }, { .compatible = "brcm,bcm4345c5" }, { .compatible = "brcm,bcm4330-bt" }, { .compatible = "brcm,bcm43438-bt" }, - { .compatible = "brcm,bcm43540-bt" }, + { .compatible = "brcm,bcm43540-bt", .data = &bcm4354_device_data }, { }, }; MODULE_DEVICE_TABLE(of, bcm_bluetooth_of_match); -- 2.24.0.rc1.363.gb1bccd3e3d-goog