Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2038028ybx; Thu, 7 Nov 2019 22:09:43 -0800 (PST) X-Google-Smtp-Source: APXvYqzrLVcXhewuEH1Y9tzG9ZMMhs2UNTVZDmPDEfNrftuozxkZqDul9tWzQZF5sNkOROsimBCp X-Received: by 2002:a17:906:5010:: with SMTP id s16mr6885962ejj.67.1573193383404; Thu, 07 Nov 2019 22:09:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573193383; cv=none; d=google.com; s=arc-20160816; b=cHVULO61MdWtEMhu9r4WrGhnqaY8FZkBxrIlCjANSyKzL6M3wk6MgmOC5rTyzqqyB2 DohtCT0htT8hCTwzHaeKwM8/c1vMkLiXE4EsdpVj8+TtsejjyqIWyMWHY380rH/pgci3 xoTgi0W1jwFBKW+wAQYBwyB+SXAtwoSMUrDz2bREyx8XwZZ49O06UAtP09lsada+i1lw 7PEFzeL8lHp8I0td+oCgLk5w2oSpp8UonL9hakz6LGMOEM/RQjqHtc5DcE9I3wIXXxE/ 8MwmWTy0YpkXXl2c/qJekNBmoUAiQSsN5voEYoTZsQ9dUeT/Fr+bn1pckZRO3m8nwY/W QWlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=y9Z82ExMq41dgkA9loNx1CTovw3cnG1xb7G+sr7PapI=; b=bOuLFEdctHiiwza7OHWPB+xMpp6NDlDY9kI6Qubblt7g8U/N4RfUxgPXOpbDLr/p5k /frp5eh+KlsVyGkPUAoQgCpDoaK29DgmJSkc2qWfnU5DLsxHMSBYBT96J8miRfdBtYPM U1o4v3Tz9pzbCL+vHs6mP2WVxaolbZTry+fDCAtOMqG+P9qtfeNQ6WItgvGvEJ0ryDm5 EtR6XkR2REj2BV0ceeCDe6dYRpMp5Dup0LKBdxtNUegFmDGsXxN9px58zWu44OYrgp2A jsxH3cqgi1MvbeG98i26ghnLZucaaloPIrqVOat6FQ0Fgd+Lo4/x70HMwjwvSbWHqT0G COsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b31si3602648edb.113.2019.11.07.22.08.59; Thu, 07 Nov 2019 22:09:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725877AbfKHGIz convert rfc822-to-8bit (ORCPT + 99 others); Fri, 8 Nov 2019 01:08:55 -0500 Received: from coyote.holtmann.net ([212.227.132.17]:39552 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725802AbfKHGIz (ORCPT ); Fri, 8 Nov 2019 01:08:55 -0500 Received: from marcel-macpro.fritz.box (p5B3D2BA4.dip0.t-ipconnect.de [91.61.43.164]) by mail.holtmann.org (Postfix) with ESMTPSA id DA6AECED12; Fri, 8 Nov 2019 07:17:57 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3601.0.10\)) Subject: Re: [PATCH v2 1/4] Bluetooth: hci_bcm: Disallow set_baudrate for BCM4354 From: Marcel Holtmann In-Reply-To: <20191107232713.48577-2-abhishekpandit@chromium.org> Date: Fri, 8 Nov 2019 07:08:53 +0100 Cc: Johan Hedberg , Rob Herring , linux-bluetooth@vger.kernel.org, dianders@chromium.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: References: <20191107232713.48577-1-abhishekpandit@chromium.org> <20191107232713.48577-2-abhishekpandit@chromium.org> To: Abhishek Pandit-Subedi X-Mailer: Apple Mail (2.3601.0.10) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Abhishek, > 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. > > Signed-off-by: Abhishek Pandit-Subedi > --- > > Changes in v2: None > > drivers/bluetooth/hci_bcm.c | 25 +++++++++++++++++++++++-- > 1 file changed, 23 insertions(+), 2 deletions(-) > > diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c > index 0f851c0dde7f..2114df607cb3 100644 > --- a/drivers/bluetooth/hci_bcm.c > +++ b/drivers/bluetooth/hci_bcm.c > @@ -1167,7 +1167,7 @@ static int bcm_remove(struct platform_device *pdev) > return 0; > } > > -static const struct hci_uart_proto bcm_proto = { > +static struct hci_uart_proto bcm_proto = { > .id = HCI_UART_BCM, > .name = "Broadcom", > .manufacturer = 15, > @@ -1371,6 +1371,24 @@ static struct platform_driver bcm_driver = { > }, > }; > > +#define BCM_QUIRK_DISALLOW_SET_BAUDRATE (1 << 0) > +const u32 disallow_set_baudrate = BCM_QUIRK_DISALLOW_SET_BAUDRATE; > + > +static int bcm_check_disallow_set_baudrate(struct serdev_device *serdev) > +{ > + const u32 *quirks = device_get_match_data(&serdev->dev); > + > + if (quirks) { > + /* BCM4354 can't run at full speed before patchram. Disallow > + * externally setting operating speed. > + */ > + if (*quirks & BCM_QUIRK_DISALLOW_SET_BAUDRATE) > + return 1; > + } > + > + return 0; > +} > + > static int bcm_serdev_probe(struct serdev_device *serdev) > { > struct bcm_device *bcmdev; > @@ -1408,6 +1426,9 @@ static int bcm_serdev_probe(struct serdev_device *serdev) > if (err) > dev_err(&serdev->dev, "Failed to power down\n"); > > + if (bcm_check_disallow_set_baudrate(serdev)) > + bcm_proto.set_baudrate = NULL; > + this change is not allowed since bcm_proto is on purpose const. > return hci_uart_register_device(&bcmdev->serdev_hu, &bcm_proto); > } > > @@ -1424,7 +1445,7 @@ static const struct of_device_id bcm_bluetooth_of_match[] = { > { .compatible = "brcm,bcm4345c5" }, > { .compatible = "brcm,bcm4330-bt" }, > { .compatible = "brcm,bcm43438-bt" }, > - { .compatible = "brcm,bcm43540-bt" }, > + { .compatible = "brcm,bcm43540-bt", .data = &disallow_set_baudrate }, > { }, > }; > MODULE_DEVICE_TABLE(of, bcm_bluetooth_of_match); So I would prefer if we do this in a more generic from that will make this easy to extend in the future. Similar to what hci_qca.c does actually with defining a separate struct for the module differences. struct bcm_device_data ( bool no_early_oper_speed; }; static const struct bcm_device_data bcm43540_device { .no_early_oper_speed = true, }; static const struct of_device_id bcm_bluetooth_of_match[] = { .. { .compatible = "brcm,bcm43540-bt", .data = &bcm43540_device }, ( }, }; And then load the struct in serdev probe as pointer and check its existence and add the struct bcm_device_data to struct bcm_device so it can be referenced when you change the baudrate. Regards Marcel