Lines Matching +full:speed +full:- +full:bin
1 // SPDX-License-Identifier: GPL-2.0-or-later
65 return -EOPNOTSUPP; in mrvl_open()
69 return -ENOMEM; in mrvl_open()
71 skb_queue_head_init(&mrvl->txq); in mrvl_open()
72 skb_queue_head_init(&mrvl->rawq); in mrvl_open()
74 set_bit(STATE_CHIP_VER_PENDING, &mrvl->flags); in mrvl_open()
76 hu->priv = mrvl; in mrvl_open()
78 if (hu->serdev) { in mrvl_open()
79 ret = serdev_device_open(hu->serdev); in mrvl_open()
93 struct mrvl_data *mrvl = hu->priv; in mrvl_close()
97 if (hu->serdev) in mrvl_close()
98 serdev_device_close(hu->serdev); in mrvl_close()
100 skb_queue_purge(&mrvl->txq); in mrvl_close()
101 skb_queue_purge(&mrvl->rawq); in mrvl_close()
102 kfree_skb(mrvl->rx_skb); in mrvl_close()
105 hu->priv = NULL; in mrvl_close()
111 struct mrvl_data *mrvl = hu->priv; in mrvl_flush()
115 skb_queue_purge(&mrvl->txq); in mrvl_flush()
116 skb_queue_purge(&mrvl->rawq); in mrvl_flush()
123 struct mrvl_data *mrvl = hu->priv; in mrvl_dequeue()
126 skb = skb_dequeue(&mrvl->txq); in mrvl_dequeue()
129 skb = skb_dequeue(&mrvl->rawq); in mrvl_dequeue()
132 memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1); in mrvl_dequeue()
140 struct mrvl_data *mrvl = hu->priv; in mrvl_enqueue()
142 skb_queue_tail(&mrvl->txq, skb); in mrvl_enqueue()
148 struct mrvl_data *mrvl = hu->priv; in mrvl_send_ack()
154 bt_dev_err(hu->hdev, "Unable to alloc ack/nak packet"); in mrvl_send_ack()
159 skb_queue_tail(&mrvl->txq, skb); in mrvl_send_ack()
165 struct hci_mrvl_pkt *pkt = (void *)skb->data; in mrvl_recv_fw_req()
167 struct mrvl_data *mrvl = hu->priv; in mrvl_recv_fw_req()
170 if ((pkt->lhs ^ pkt->rhs) != 0xffff) { in mrvl_recv_fw_req()
173 ret = -EINVAL; in mrvl_recv_fw_req()
178 if (!test_bit(STATE_FW_REQ_PENDING, &mrvl->flags)) { in mrvl_recv_fw_req()
180 ret = -EINVAL; in mrvl_recv_fw_req()
184 mrvl->tx_len = le16_to_cpu(pkt->lhs); in mrvl_recv_fw_req()
186 clear_bit(STATE_FW_REQ_PENDING, &mrvl->flags); in mrvl_recv_fw_req()
188 wake_up_bit(&mrvl->flags, STATE_FW_REQ_PENDING); in mrvl_recv_fw_req()
197 struct hci_mrvl_pkt *pkt = (void *)skb->data; in mrvl_recv_chip_ver()
199 struct mrvl_data *mrvl = hu->priv; in mrvl_recv_chip_ver()
200 u16 version = le16_to_cpu(pkt->lhs); in mrvl_recv_chip_ver()
203 if ((pkt->lhs ^ pkt->rhs) != 0xffff) { in mrvl_recv_chip_ver()
206 ret = -EINVAL; in mrvl_recv_chip_ver()
211 if (!test_bit(STATE_CHIP_VER_PENDING, &mrvl->flags)) { in mrvl_recv_chip_ver()
216 mrvl->id = version; in mrvl_recv_chip_ver()
217 mrvl->rev = version >> 8; in mrvl_recv_chip_ver()
219 bt_dev_info(hdev, "Controller id = %x, rev = %x", mrvl->id, mrvl->rev); in mrvl_recv_chip_ver()
221 clear_bit(STATE_CHIP_VER_PENDING, &mrvl->flags); in mrvl_recv_chip_ver()
223 wake_up_bit(&mrvl->flags, STATE_CHIP_VER_PENDING); in mrvl_recv_chip_ver()
254 struct mrvl_data *mrvl = hu->priv; in mrvl_recv()
256 if (!test_bit(HCI_UART_REGISTERED, &hu->flags)) in mrvl_recv()
257 return -EUNATCH; in mrvl_recv()
263 if (!test_bit(STATE_FW_REQ_PENDING, &mrvl->flags) && in mrvl_recv()
264 !test_bit(STATE_FW_LOADED, &mrvl->flags)) in mrvl_recv()
267 mrvl->rx_skb = h4_recv_buf(hu->hdev, mrvl->rx_skb, data, count, in mrvl_recv()
270 if (IS_ERR(mrvl->rx_skb)) { in mrvl_recv()
271 int err = PTR_ERR(mrvl->rx_skb); in mrvl_recv()
272 bt_dev_err(hu->hdev, "Frame reassembly failed (%d)", err); in mrvl_recv()
273 mrvl->rx_skb = NULL; in mrvl_recv()
283 struct mrvl_data *mrvl = hu->priv; in mrvl_load_firmware()
288 err = request_firmware(&fw, name, &hdev->dev); in mrvl_load_firmware()
294 fw_ptr = fw->data; in mrvl_load_firmware()
295 fw_max = fw->data + fw->size; in mrvl_load_firmware()
299 set_bit(STATE_FW_REQ_PENDING, &mrvl->flags); in mrvl_load_firmware()
307 err = wait_on_bit_timeout(&mrvl->flags, STATE_FW_REQ_PENDING, in mrvl_load_firmware()
312 err = -EINTR; in mrvl_load_firmware()
316 err = -ETIMEDOUT; in mrvl_load_firmware()
321 mrvl->tx_len); in mrvl_load_firmware()
328 if (!mrvl->tx_len) { in mrvl_load_firmware()
332 err = -EINVAL; in mrvl_load_firmware()
337 if (fw_ptr + mrvl->tx_len > fw_max) { in mrvl_load_firmware()
338 mrvl->tx_len = fw_max - fw_ptr; in mrvl_load_firmware()
340 mrvl->tx_len); in mrvl_load_firmware()
343 skb = bt_skb_alloc(mrvl->tx_len, GFP_KERNEL); in mrvl_load_firmware()
346 err = -ENOMEM; in mrvl_load_firmware()
349 bt_cb(skb)->pkt_type = MRVL_RAW_DATA; in mrvl_load_firmware()
351 skb_put_data(skb, fw_ptr, mrvl->tx_len); in mrvl_load_firmware()
352 fw_ptr += mrvl->tx_len; in mrvl_load_firmware()
354 set_bit(STATE_FW_REQ_PENDING, &mrvl->flags); in mrvl_load_firmware()
356 skb_queue_tail(&mrvl->rawq, skb); in mrvl_load_firmware()
367 struct mrvl_data *mrvl = hu->priv; in mrvl_setup()
371 err = mrvl_load_firmware(hu->hdev, "mrvl/helper_uart_3000000.bin"); in mrvl_setup()
373 bt_dev_err(hu->hdev, "Unable to download firmware helper"); in mrvl_setup()
374 return -EINVAL; in mrvl_setup()
380 if (hu->serdev) in mrvl_setup()
381 serdev_device_set_baudrate(hu->serdev, hu->oper_speed); in mrvl_setup()
383 hci_uart_set_baudrate(hu, hu->oper_speed); in mrvl_setup()
387 err = mrvl_load_firmware(hu->hdev, "mrvl/uart8897_bt.bin"); in mrvl_setup()
391 set_bit(STATE_FW_LOADED, &mrvl->flags); in mrvl_setup()
396 static int mrvl_set_baudrate(struct hci_uart *hu, unsigned int speed) in mrvl_set_baudrate() argument
399 struct mrvl_data *mrvl = hu->priv; in mrvl_set_baudrate()
400 __le32 speed_le = cpu_to_le32(speed); in mrvl_set_baudrate()
406 err = serdev_device_wait_for_cts(hu->serdev, true, 10000); in mrvl_set_baudrate()
408 bt_dev_err(hu->hdev, "Wait for CTS failed with %d\n", err); in mrvl_set_baudrate()
412 set_bit(STATE_FW_LOADED, &mrvl->flags); in mrvl_set_baudrate()
414 err = __hci_cmd_sync_status(hu->hdev, MRVL_SET_BAUDRATE, in mrvl_set_baudrate()
418 bt_dev_err(hu->hdev, "send command failed: %d", err); in mrvl_set_baudrate()
422 serdev_device_set_baudrate(hu->serdev, speed); in mrvl_set_baudrate()
429 set_bit(HCI_UART_VND_DETECT, &hu->hdev_flags); in mrvl_set_baudrate()
465 const struct hci_uart_proto *mrvl_proto = device_get_match_data(&serdev->dev); in mrvl_serdev_probe()
467 mrvldev = devm_kzalloc(&serdev->dev, sizeof(*mrvldev), GFP_KERNEL); in mrvl_serdev_probe()
469 return -ENOMEM; in mrvl_serdev_probe()
471 mrvldev->hu.oper_speed = mrvl_proto->oper_speed; in mrvl_serdev_probe()
472 if (mrvl_proto->set_baudrate) in mrvl_serdev_probe()
473 of_property_read_u32(serdev->dev.of_node, "max-speed", &mrvldev->hu.oper_speed); in mrvl_serdev_probe()
475 mrvldev->hu.serdev = serdev; in mrvl_serdev_probe()
478 return hci_uart_register_device(&mrvldev->hu, mrvl_proto); in mrvl_serdev_probe()
485 hci_uart_unregister_device(&mrvldev->hu); in mrvl_serdev_remove()