Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3412576ybi; Tue, 2 Jul 2019 07:20:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqztCisYdKUl4E3nsTNzxaHIRDwgwBQ3SkJLtZI8sADpKM2WJa01QaN0Y2UeaL8Q5WjVt2Tt X-Received: by 2002:a63:b547:: with SMTP id u7mr31937167pgo.322.1562077248785; Tue, 02 Jul 2019 07:20:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562077248; cv=none; d=google.com; s=arc-20160816; b=hv4zSlhV3PJbtnVlo3YwrwQphBFtcNhdB/1SdlxSW89pXcjM9oUEPYYlLqGPO9RqwH adpw29E0+U8wk3eyVHP32h+uiy8yIB87Q9bFFk0/TFBsYoTLe4ooNwEM8mLwRonodPdH oA/jzd8eHLGD1FAXyfrDdMNOHbtXx10aROJg41zxODSlTyj+Irp51NpsAYKJ2Pp0cBst ChMsTXKrjeJnLPxGMSzbze1HShFgL0u/pMC6mX/X/nsaiJ6dvbu5DZ5t8aOKr3n15pv7 jsd+wxXtYEHN0ZnQPQzN4Gt1AyQ4j1svyFrTxLl35yAc3epPYO6LkBruA7WpspCohTeM Dw/w== 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 :message-id:date:subject:cc:to:from; bh=7uGxWzJPV0FYbjpy1GSKMd9jsIi2l7zOJnrXCC3R28Q=; b=XS5F+GuCJQQz3BdOpCQcloD9gGqGwwMT2d8oKLJ1p/3GwkYrSlCLUgdDokhe/TUJ4W 2L39FNjtPLkYH/gx46mVBdHhTsb01osQsa8wXjNJdcY+9hWjkuiJUE+Z6dUP0Z8AXsh4 CU/vbQT1RsSQ/NakOZk6AMnhPfnAuxs76ALzJKuyUlZ9ZlTTAZiVhFXJTqpLKgDpLlun FNTzRE+G5iSPnH6L5JnqNcZxm9okr/coTz26EMG/2IC+g4uF3tVT9rKIF7EhfcCglmQb RGZU9NlleLxoCON190Mls/O+DMJkL9QhgO14UEXHZUBMUFS8axZp1MJXEjyvYtYWj9Ju CkVA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d31si13166526pla.393.2019.07.02.07.20.34; Tue, 02 Jul 2019 07:20:48 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727237AbfGBOTS (ORCPT + 99 others); Tue, 2 Jul 2019 10:19:18 -0400 Received: from mx1.emlix.com ([188.40.240.192]:57588 "EHLO mx1.emlix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727109AbfGBOTM (ORCPT ); Tue, 2 Jul 2019 10:19:12 -0400 X-Greylist: delayed 320 seconds by postgrey-1.27 at vger.kernel.org; Tue, 02 Jul 2019 10:19:12 EDT Received: from mailer.emlix.com (unknown [81.20.119.6]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.emlix.com (Postfix) with ESMTPS id EC37F60AF8; Tue, 2 Jul 2019 16:13:50 +0200 (CEST) From: Philipp Puschmann To: marcel@holtmann.org Cc: johan.hedberg@gmail.com, linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Philipp Puschmann Subject: [PATCH] Bluetooth: serdev: hci_ll: set operational frequency earlier Date: Tue, 2 Jul 2019 16:13:37 +0200 Message-Id: <20190702141337.10528-1-philipp.puschmann@emlix.com> X-Mailer: git-send-email 2.20.1 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 Uploading the firmware needs quite a few seconds if done at 115200 kbps. So set the operational frequency, usually 3 MHz, before uploading the firmware. I have successfully tested this with a wl1837mod. Signed-off-by: Philipp Puschmann --- drivers/bluetooth/hci_ll.c | 39 ++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/drivers/bluetooth/hci_ll.c b/drivers/bluetooth/hci_ll.c index c04f5f9e1ed0..cbd7bc539d5e 100644 --- a/drivers/bluetooth/hci_ll.c +++ b/drivers/bluetooth/hci_ll.c @@ -601,6 +601,13 @@ static int ll_setup(struct hci_uart *hu) serdev_device_set_flow_control(serdev, true); + if (hu->oper_speed) + speed = hu->oper_speed; + else if (hu->proto->oper_speed) + speed = hu->proto->oper_speed; + else + speed = 0; + do { /* Reset the Bluetooth device */ gpiod_set_value_cansleep(lldev->enable_gpio, 0); @@ -612,6 +619,20 @@ static int ll_setup(struct hci_uart *hu) return err; } + if (speed) { + __le32 speed_le = cpu_to_le32(speed); + struct sk_buff *skb; + + skb = __hci_cmd_sync(hu->hdev, + HCI_VS_UPDATE_UART_HCI_BAUDRATE, + sizeof(speed_le), &speed_le, + HCI_INIT_TIMEOUT); + if (!IS_ERR(skb)) { + kfree_skb(skb); + serdev_device_set_baudrate(serdev, speed); + } + } + err = download_firmware(lldev); if (!err) break; @@ -636,25 +657,7 @@ static int ll_setup(struct hci_uart *hu) } /* Operational speed if any */ - if (hu->oper_speed) - speed = hu->oper_speed; - else if (hu->proto->oper_speed) - speed = hu->proto->oper_speed; - else - speed = 0; - - if (speed) { - __le32 speed_le = cpu_to_le32(speed); - struct sk_buff *skb; - skb = __hci_cmd_sync(hu->hdev, HCI_VS_UPDATE_UART_HCI_BAUDRATE, - sizeof(speed_le), &speed_le, - HCI_INIT_TIMEOUT); - if (!IS_ERR(skb)) { - kfree_skb(skb); - serdev_device_set_baudrate(serdev, speed); - } - } return 0; } -- 2.20.1