Skip to content

Deprecate hci cmd create #3044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/releases/migration-guide-4.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ Bluetooth HCI
have been deprecated, but are still usable, with the exception that they can only be
called once per buffer.

* The :c:func:`bt_hci_cmd_create` function has been depracated and the new :c:func:`bt_hci_cmd_alloc`
function should be used instead. The new function takes no parameters because the command
sending functions have been updated to do the command header encoding.

Bluetooth Host
==============

Expand Down
8 changes: 4 additions & 4 deletions drivers/bluetooth/hci/Kconfig.nxp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ config HCI_NXP_ENABLE_AUTO_SLEEP
message to the Controller as the Host will need to wake it up.

config HCI_NXP_SET_CAL_DATA
bool "BLE Controller calibration data"
bool "Bluetooth Controller calibration data"
help
If enabled, the Host will send calibration data to the BLE Controller during HCI init.
If enabled, the Host will send calibration data to the Bluetooth Controller during HCI init.

config HCI_NXP_SET_CAL_DATA_ANNEX100
bool "BLE Controller calibration data annex 100"
bool "Bluetooth Controller calibration data annex 100"
help
If enabled, the Host will send calibration data annex 100 to the BLE Controller during HCI
If enabled, the Host will send calibration data annex 100 to the Bluetooth Controller during HCI
init.

config HCI_NXP_RX_THREAD
Expand Down
3 changes: 1 addition & 2 deletions drivers/bluetooth/hci/apollox_blue.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,7 @@ static int bt_apollo_set_nvds(void)
#else
uint8_t *p;

buf = bt_hci_cmd_create(HCI_VSC_UPDATE_NVDS_CFG_CMD_OPCODE,
HCI_VSC_UPDATE_NVDS_CFG_CMD_LENGTH);
buf = bt_hci_cmd_alloc(K_FOREVER);
if (!buf) {
return -ENOBUFS;
}
Expand Down
5 changes: 2 additions & 3 deletions drivers/bluetooth/hci/h4_ifx_cyw43xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ static int bt_update_controller_baudrate(const struct device *bt_uart_dev, uint3
/* Allocate buffer for update uart baudrate command.
* It will be BT_HCI_OP_RESET with extra parameters.
*/
buf = bt_hci_cmd_create(BT_HCI_VND_OP_UPDATE_BAUDRATE,
HCI_VSC_UPDATE_BAUD_RATE_LENGTH);
buf = bt_hci_cmd_alloc(K_FOREVER);
if (buf == NULL) {
LOG_ERR("Unable to allocate command buffer");
return -ENOMEM;
Expand Down Expand Up @@ -172,7 +171,7 @@ static int bt_firmware_download(const uint8_t *firmware_image, uint32_t size)
uint16_t op_code = *(uint16_t *)data;

/* Allocate buffer for hci_write_ram/hci_launch_ram command. */
buf = bt_hci_cmd_create(op_code, data_length);
buf = bt_hci_cmd_alloc(K_FOREVER);
if (buf == NULL) {
LOG_ERR("Unable to allocate command buffer");
return err;
Expand Down
6 changes: 3 additions & 3 deletions drivers/bluetooth/hci/hci_ifx_cyw208xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static int cyw208xx_bt_firmware_download(const uint8_t *firmware_image, uint32_t
}

/* Allocate buffer for hci_write_ram/hci_launch_ram command. */
buf = bt_hci_cmd_create(op_code, data_length);
buf = bt_hci_cmd_alloc(K_FOREVER);
if (buf == NULL) {
LOG_ERR("Unable to allocate command buffer");
return -ENOBUFS;
Expand Down Expand Up @@ -211,7 +211,7 @@ static int cyw208xx_setup(const struct device *dev, const struct bt_hci_setup_pa
cybt_platform_hci_wait_for_boot_fully_up(false);

/* Set public address */
buf = bt_hci_cmd_create(BT_HCI_VND_OP_SET_LOCAL_DEV_ADDR, BTM_SET_LOCAL_DEV_ADDR_LENGTH);
buf = bt_hci_cmd_alloc(K_FOREVER);
if (buf == NULL) {
LOG_ERR("Unable to allocate command buffer");
cyhal_syspm_unlock_deepsleep();
Expand Down Expand Up @@ -375,7 +375,7 @@ wiced_bt_dev_vendor_specific_command(uint16_t opcode, uint8_t param_len, uint8_t
struct net_buf *buf = NULL;

/* Allocate a HCI command buffer */
buf = bt_hci_cmd_create(opcode, param_len);
buf = bt_hci_cmd_alloc(K_FOREVER);
if (!buf) {
LOG_ERR("Unable to allocate buffer");
return WICED_NO_MEMORY;
Expand Down
2 changes: 1 addition & 1 deletion drivers/bluetooth/hci/hci_ifx_psoc6_bless.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static int psoc6_bless_setup(const struct device *dev, const struct bt_hci_setup
addr[5], addr[4], addr[3], addr[2], addr[1], addr[0], BT_ADDR_LE_PUBLIC,
};

buf = bt_hci_cmd_create(PSOC6_BLESS_OP_SET_PUBLIC_ADDR, sizeof(hci_data));
buf = bt_hci_cmd_alloc(K_FOREVER);
if (buf == NULL) {
LOG_ERR("Unable to allocate command buffer");
return -ENOMEM;
Expand Down
2 changes: 1 addition & 1 deletion drivers/bluetooth/hci/hci_nxp.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static int nxp_bt_send_vs_command(uint16_t opcode, const uint8_t *params, uint8_
struct net_buf *buf;

/* Allocate buffer for the hci command */
buf = bt_hci_cmd_create(opcode, params_len);
buf = bt_hci_cmd_alloc(K_FOREVER);
if (buf == NULL) {
LOG_ERR("Unable to allocate command buffer");
return -ENOMEM;
Expand Down
219 changes: 214 additions & 5 deletions drivers/bluetooth/hci/hci_nxp_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,25 @@

#define DT_DRV_COMPAT nxp_bt_hci_uart

#define FW_UPLOAD_CHANGE_TIMEOUT_RETRY_COUNT 6
#define FW_UPLOAD_CHANGE_TIMEOUT_RETRY_COUNT 6
#define HCI_CMD_STORE_BT_CAL_DATA_ANNEX100_OCF 0xFF
#define HCI_CMD_STORE_BT_CAL_DATA_PARAM_ANNEX100_LENGTH 16
#define HCI_CMD_STORE_BT_CAL_DATA_OCF 0x61
#define HCI_CMD_STORE_BT_CAL_DATA_PARAM_LENGTH 32

extern const unsigned char *bt_fw_bin;
extern const unsigned int bt_fw_bin_len;

static const struct device *uart_dev = DEVICE_DT_GET(DT_INST_GPARENT(0));

#if !defined(CONFIG_HCI_NXP_SET_CAL_DATA)
#define bt_nxp_set_calibration_data_annex55() 0
#endif

#if !defined(CONFIG_HCI_NXP_SET_CAL_DATA_ANNEX100)
#define bt_nxp_set_calibration_data_annex100() 0
#endif

#if DT_NODE_HAS_PROP(DT_DRV_INST(0), sdio_reset_gpios)
struct gpio_dt_spec sdio_reset = GPIO_DT_SPEC_GET(DT_DRV_INST(0), sdio_reset_gpios);
#endif /* DT_NODE_HAS_PROP(DT_DRV_INST(0), sdio_reset_gpios) */
Expand Down Expand Up @@ -1171,6 +1183,189 @@
return 0;
}

#if defined(CONFIG_HCI_NXP_SET_CAL_DATA)

static int bt_nxp_set_calibration_data_annex55(void)
{
int ret = 0;
uint16_t opcode = BT_OP(BT_OGF_VS, HCI_CMD_STORE_BT_CAL_DATA_OCF);

const uint8_t hci_cal_data_annex55[HCI_CMD_STORE_BT_CAL_DATA_PARAM_LENGTH] = {
#if defined(CONFIG_BT_NXP_NW612)
0x00, /* Sequence Number : 0x00 */
0x01, /* Action : 0x01 */
0x01, /* Type : Not use CheckSum */
0x1C, /* File Length : 0x1C */
0x37, /* BT Annex Type : BT CFG */
0x33, /* Checksum : 0x71 */
0x1C, /* Annex Length LSB: 0x001C */
0x00, /* Annex Length MSB: 0x001C */
0x00, /* Pointer For Next Annex[0] : 0x00000000 */
0x00, /* Pointer For Next Annex[1] : 0x00000000 */
0x00, /* Pointer For Next Annex[2] : 0x00000000 */
0x00, /* Pointer For Next Annex[3] : 0x00000000 */
0x01, /* Annex Version : 0x01 */
0x81, /* External Xtal Calibration Value : 0x7d */
0x0D, /* Initial TX Power : 13 */
0x07, /* Front End Loss : 0x07 */
0x28, /* BT Options : */
/* BIT[0] Force Class 2 operation = 0 */
/* BIT[1] Disable Pwr-ctrl for class 2=0 */
/* BIT[2] MiscFlg(to indicate ext.XTAL)=0 */
/* BIT[3] Used Internal Sleep Clock = 1 */
/* BIT[4] BT AOA location support = 0 */
/* BIT[5] Force Class 1 mode = 1 */
/* BIT[7:6] Reserved */
0x00, /* AOANumberOfAntennas: 0x00 */
0x00, /* RSSI Golden Low : 0 */
0x00, /* RSSI Golden High : 0 */
0xC0, /* UART Baud Rate[0] : 0x002DC6C0(3000000) */
0xC6, /* UART Baud Rate[1] : 0x002DC6C0(3000000) */
0x2D, /* UART Baud Rate[2] : 0x002DC6C0(3000000) */
0x00, /* UART Baud Rate[3] : 0x002DC6C0(3000000) */
0x00, /* BdAddress[0] : 0x000000000000 */
0x00, /* BdAddress[1] : 0x000000000000 */
0x00, /* BdAddress[2] : 0x000000000000 */
0x00, /* BdAddress[3] : 0x000000000000 */
0x00, /* BdAddress[4] : 0x000000000000 */
0x00, /* BdAddress[5] : 0x000000000000 */
0xF0, /* Encr_Key_Len[3:0]: MinEncrKeyLen = 0x0 */
/* ExEncrKeyLen = 0xF */
0x00, /* RegionCode : 0x00 */
#elif defined(CONFIG_BT_NXP_IW416)
0x00, /* Sequence Number : 0x00 */
0x01, /* Action : 0x01 */
0x01, /* Type : Not use CheckSum */
0x1C, /* File Length : 0x1C */
0x37, /* BT Annex Type : BT CFG */
0x33, /* Checksum : 0x71 */
0x1C, /* Annex Length LSB: 0x001C */
0x00, /* Annex Length MSB: 0x001C */
0x00, /* Pointer For Next Annex[0] : 0x00000000 */
0x00, /* Pointer For Next Annex[1] : 0x00000000 */
0x00, /* Pointer For Next Annex[2] : 0x00000000 */
0x00, /* Pointer For Next Annex[3] : 0x00000000 */
0x01, /* Annex Version : 0x01 */
0x00, /* External Xtal Calibration Value */
0x03, /* Initial TX Power : 0x03 */
0x03, /* Front End Loss : 0x03 */
0x00, /* BT Options : */
/* BIT[0] Force Class 2 operation = 0 */
/* BIT[1] Disable Pwr Ctrl for class 2=0 */
/* BIT[2] MiscFlg(to indicate ext.XTAL)=0 */
/* BIT[3] Used Internal Sleep Clock = 0 */
/* BIT[4] BT AOA localtion support = 0 */
/* BIT[5] Force Class 1 mode = 0 */
/* BIT[7:6] Reserved */
0x00, /* AOANumberOfAntennas: 0x00 */
0xBA, /* RSSI Golden Low : 0 */
0xCE, /* RSSI Golden High : 0 */
0xC0, /* UART Baud Rate[0] : 0x002DC6C0(3000000) */
0xC6, /* UART Baud Rate[1] : 0x002DC6C0(3000000) */
0x2D, /* UART Baud Rate[2] : 0x002DC6C0(3000000) */
0x00, /* UART Baud Rate[3] : 0x002DC6C0(3000000) */
0x00, /* BdAddress[0] : 0x000000000000 */
0x00, /* BdAddress[1] : 0x000000000000 */
0x00, /* BdAddress[2] : 0x000000000000 */
0x00, /* BdAddress[3] : 0x000000000000 */
0x00, /* BdAddress[4] : 0x000000000000 */
0x00, /* BdAddress[5] : 0x000000000000 */
0xF0, /* Encr_Key_Len[3:0]: MinEncrKeyLen = 0x0 */
/* ExEncrKeyLen = 0xF */
0x00, /* RegionCode : 0x00 */
#else

Check notice on line 1276 in drivers/bluetooth/hci/hci_nxp_setup.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/bluetooth/hci/hci_nxp_setup.c:1276 - 0x00, /* Sequence Number : 0x00 */ - 0x01, /* Action : 0x01 */ - 0x01, /* Type : Not use CheckSum */ - 0x1C, /* File Length : 0x1C */ - 0x37, /* BT Annex Type : BT CFG */ - 0x33, /* Checksum : 0x71 */ - 0x1C, /* Annex Length LSB: 0x001C */ - 0x00, /* Annex Length MSB: 0x001C */ - 0x00, /* Pointer For Next Annex[0] : 0x00000000 */ - 0x00, /* Pointer For Next Annex[1] : 0x00000000 */ - 0x00, /* Pointer For Next Annex[2] : 0x00000000 */ - 0x00, /* Pointer For Next Annex[3] : 0x00000000 */ - 0x01, /* Annex Version : 0x01 */ - 0x81, /* External Xtal Calibration Value : 0x7d */ - 0x0D, /* Initial TX Power : 13 */ - 0x07, /* Front End Loss : 0x07 */ - 0x28, /* BT Options : */ - /* BIT[0] Force Class 2 operation = 0 */ - /* BIT[1] Disable Pwr-ctrl for class 2=0 */ - /* BIT[2] MiscFlg(to indicate ext.XTAL)=0 */ - /* BIT[3] Used Internal Sleep Clock = 1 */ - /* BIT[4] BT AOA location support = 0 */ - /* BIT[5] Force Class 1 mode = 1 */ - /* BIT[7:6] Reserved */ - 0x00, /* AOANumberOfAntennas: 0x00 */ - 0x00, /* RSSI Golden Low : 0 */ - 0x00, /* RSSI Golden High : 0 */ - 0xC0, /* UART Baud Rate[0] : 0x002DC6C0(3000000) */ - 0xC6, /* UART Baud Rate[1] : 0x002DC6C0(3000000) */ - 0x2D, /* UART Baud Rate[2] : 0x002DC6C0(3000000) */ - 0x00, /* UART Baud Rate[3] : 0x002DC6C0(3000000) */ - 0x00, /* BdAddress[0] : 0x000000000000 */ - 0x00, /* BdAddress[1] : 0x000000000000 */ - 0x00, /* BdAddress[2] : 0x000000000000 */ - 0x00, /* BdAddress[3] : 0x000000000000 */ - 0x00, /* BdAddress[4] : 0x000000000000 */ - 0x00, /* BdAddress[5] : 0x000000000000 */ - 0xF0, /* Encr_Key_Len[3:0]: MinEncrKeyLen = 0x0 */ - /* ExEncrKeyLen = 0xF */ - 0x00, /* RegionCode : 0x00 */ + 0x00, /* Sequence Number : 0x00 */ + 0x01, /* Action : 0x01 */ + 0x01, /* Type : Not use CheckSum */ + 0x1C, /* File Length : 0x1C */ + 0x37, /* BT Annex Type : BT CFG */ + 0x33, /* Checksum : 0x71 */ + 0x1C, /* Annex Length LSB: 0x001C */ + 0x00, /* Annex Length MSB: 0x001C */ + 0x00, /* Pointer For Next Annex[0] : 0x00000000 */ + 0x00, /* Pointer For Next Annex[1] : 0x00000000 */ + 0x00, /* Pointer For Next Annex[2] : 0x00000000 */ + 0x00, /* Pointer For Next Annex[3] : 0x00000000 */ + 0x01, /* Annex Version : 0x01 */ + 0x81, /* External Xtal Calibration Value : 0x7d */ + 0x0D, /* Initial TX Power : 13 */ + 0x07, /* Front End Loss : 0x07 */ + 0x28, /* BT Options : */ + /* BIT[0] Force Class 2 operation = 0 */ + /* BIT[1] Disable Pwr-ctrl for class 2=0 */ + /* BIT[2] MiscFlg(to indicate ext.XTAL)=0 */ + /* BIT[3] Used Internal Sleep Clock = 1 */ + /* BIT[4] BT AOA location support = 0 */ + /* BIT[5] Force Class 1 mode = 1 */ + /* BIT[7:6] Reserved */ + 0x00, /* AOANumberOfAntennas: 0x00 */ + 0x00, /* RSSI Golden Low : 0 */ + 0x00, /* RSSI Golden High : 0 */ + 0xC0, /* UART Baud Rate[0] : 0x002DC6C0(3000000) */ + 0xC6, /* UART Baud Rate[1] : 0x002DC6C0(3000000) */ + 0x2D, /* UART Baud Rate[2] : 0x002DC6C0(3000000) */ + 0x00, /* UART Baud Rate[3] : 0x002DC6C0(3000000) */ + 0x00, /* BdAddress[0] : 0x000000000000 */ + 0x00, /* BdAddress[1] : 0x000000000000 */ + 0x00, /* BdAddress[2] : 0x000000000000 */ + 0x00, /* BdAddress[3] : 0x000000000000 */ + 0x00, /* BdAddress[4] : 0x000000000000 */ + 0x00, /* BdAddress[5] : 0x000000000000 */ + 0xF0, /* Encr_Key_Len[3:0]: MinEncrKeyLen = 0x0 */ + /* ExEncrKeyLen = 0xF */ + 0x00, /* RegionCode : 0x00 */ #elif defined(CONFIG_BT_NXP_IW416) - 0x00, /* Sequence Number : 0x00 */ - 0x01, /* Action : 0x01 */ - 0x01, /* Type : Not use CheckSum */ - 0x1C, /* File Length : 0x1C */ - 0x37, /* BT Annex Type : BT CFG */ - 0x33, /* Checksum : 0x71

Check notice on line 1276 in drivers/bluetooth/hci/hci_nxp_setup.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/bluetooth/hci/hci_nxp_setup.c:1276 - 0x00, /* Sequence Number : 0x00 */ - 0x01, /* Action : 0x01 */ - 0x01, /* Type : Not use CheckSum */ - 0x1C, /* File Length : 0x1C */ - 0x37, /* BT Annex Type : BT CFG */ - 0x33, /* Checksum : 0x71 */ - 0x1C, /* Annex Length LSB: 0x001C */ - 0x00, /* Annex Length MSB: 0x001C */ - 0x00, /* Pointer For Next Annex[0] : 0x00000000 */ - 0x00, /* Pointer For Next Annex[1] : 0x00000000 */ - 0x00, /* Pointer For Next Annex[2] : 0x00000000 */ - 0x00, /* Pointer For Next Annex[3] : 0x00000000 */ - 0x01, /* Annex Version : 0x01 */ - 0x81, /* External Xtal Calibration Value : 0x7d */ - 0x0D, /* Initial TX Power : 13 */ - 0x07, /* Front End Loss : 0x07 */ - 0x28, /* BT Options : */ - /* BIT[0] Force Class 2 operation = 0 */ - /* BIT[1] Disable Pwr-ctrl for class 2=0 */ - /* BIT[2] MiscFlg(to indicate ext.XTAL)=0 */ - /* BIT[3] Used Internal Sleep Clock = 1 */ - /* BIT[4] BT AOA location support = 0 */ - /* BIT[5] Force Class 1 mode = 1 */ - /* BIT[7:6] Reserved */ - 0x00, /* AOANumberOfAntennas: 0x00 */ - 0x00, /* RSSI Golden Low : 0 */ - 0x00, /* RSSI Golden High : 0 */ - 0xC0, /* UART Baud Rate[0] : 0x002DC6C0(3000000) */ - 0xC6, /* UART Baud Rate[1] : 0x002DC6C0(3000000) */ - 0x2D, /* UART Baud Rate[2] : 0x002DC6C0(3000000) */ - 0x00, /* UART Baud Rate[3] : 0x002DC6C0(3000000) */ - 0x00, /* BdAddress[0] : 0x000000000000 */ - 0x00, /* BdAddress[1] : 0x000000000000 */ - 0x00, /* BdAddress[2] : 0x000000000000 */ - 0x00, /* BdAddress[3] : 0x000000000000 */ - 0x00, /* BdAddress[4] : 0x000000000000 */ - 0x00, /* BdAddress[5] : 0x000000000000 */ - 0xF0, /* Encr_Key_Len[3:0]: MinEncrKeyLen = 0x0 */ - /* ExEncrKeyLen = 0xF */ - 0x00, /* RegionCode : 0x00 */ + 0x00, /* Sequence Number : 0x00 */ + 0x01, /* Action : 0x01 */ + 0x01, /* Type : Not use CheckSum */ + 0x1C, /* File Length : 0x1C */ + 0x37, /* BT Annex Type : BT CFG */ + 0x33, /* Checksum : 0x71 */ + 0x1C, /* Annex Length LSB: 0x001C */ + 0x00, /* Annex Length MSB: 0x001C */ + 0x00, /* Pointer For Next Annex[0] : 0x00000000 */ + 0x00, /* Pointer For Next Annex[1] : 0x00000000 */ + 0x00, /* Pointer For Next Annex[2] : 0x00000000 */ + 0x00, /* Pointer For Next Annex[3] : 0x00000000 */ + 0x01, /* Annex Version : 0x01 */ + 0x81, /* External Xtal Calibration Value : 0x7d */ + 0x0D, /* Initial TX Power : 13 */ + 0x07, /* Front End Loss : 0x07 */ + 0x28, /* BT Options : */ + /* BIT[0] Force Class 2 operation = 0 */ + /* BIT[1] Disable Pwr-ctrl for class 2=0 */ + /* BIT[2] MiscFlg(to indicate ext.XTAL)=0 */ + /* BIT[3] Used Internal Sleep Clock = 1 */ + /* BIT[4] BT AOA location support = 0 */ + /* BIT[5] Force Class 1 mode = 1 */ + /* BIT[7:6] Reserved */ + 0x00, /* AOANumberOfAntennas: 0x00 */ + 0x00, /* RSSI Golden Low : 0 */ + 0x00, /* RSSI Golden High : 0 */ + 0xC0, /* UART Baud Rate[0] : 0x002DC6C0(3000000) */ + 0xC6, /* UART Baud Rate[1] : 0x002DC6C0(3000000) */ + 0x2D, /* UART Baud Rate[2] : 0x002DC6C0(3000000) */ + 0x00, /* UART Baud Rate[3] : 0x002DC6C0(3000000) */ + 0x00, /* BdAddress[0] : 0x000000000000 */ + 0x00, /* BdAddress[1] : 0x000000000000 */ + 0x00, /* BdAddress[2] : 0x000000000000 */ + 0x00, /* BdAddress[3] : 0x000000000000 */ + 0x00, /* BdAddress[4] : 0x000000000000 */ + 0x00, /* BdAddress[5] : 0x000000000000 */ + 0xF0, /* Encr_Key_Len[3:0]: MinEncrKeyLen = 0x0 */ + /* ExEncrKeyLen = 0xF */ + 0x00, /* RegionCode : 0x00 */ #elif defined(CONFIG_BT_NXP_IW416) - 0x00, /* Sequence Number : 0x00 */ - 0x01, /* Action : 0x01 */ - 0x01, /* Type : Not use CheckSum */ - 0x1C, /* File Length : 0x1C */ - 0x37, /* BT Annex Type : BT CFG */ - 0x33, /* Checksum : 0x71
#error "BT Calibration data (annex-55) is not given for selected chipset"
#endif
};

if (IS_ENABLED(CONFIG_BT_HCI_HOST)) {
struct net_buf *buf;

buf = bt_hci_cmd_alloc(K_FOREVER);
if (buf == NULL) {
LOG_ERR("Unable to allocate command buffer");
return -ENOMEM;
}

net_buf_add_mem(buf, hci_cal_data_annex55, HCI_CMD_STORE_BT_CAL_DATA_PARAM_LENGTH);

ret = bt_hci_cmd_send_sync(opcode, buf, NULL);
if (ret) {
LOG_ERR("Failed to send set-calibration cmd (err %d)", ret);
return ret;
}

(void)k_msleep(CONFIG_BT_H4_NXP_CTLR_WAIT_TIME_AFTER_BAUDRATE_UPDATE);
}

return ret;
}
#endif /*CONFIG_HCI_NXP_SET_CAL_DATA*/

#if defined(CONFIG_HCI_NXP_SET_CAL_DATA_ANNEX100)

static int bt_nxp_set_calibration_data_annex100(void)
{
int ret = 0;
const uint8_t hci_cal_data_annex100[HCI_CMD_STORE_BT_CAL_DATA_PARAM_ANNEX100_LENGTH] = {
#if defined(CONFIG_BT_NXP_NW612)
0x64, /* Annex Type : 0x64 */
0x83, /* Checksum */
0x10, 0x00, /* Length */
0x00, 0x00, 0x00, 0x00, /* Pointer for next Annex-Structure */
0x01, /* Ext PA Present (1 bit) + */
/* Ext. PA Gain (7 bits) */
0x00, /* Ext Antenna Gain(1 bit) + */
/* Ext. Antenna Gain Val(4 bits) */
0x04, 0x00, /* BT / LE Ext PA FEM CTRL Bitmask */
0x01, /* Ext LNA Present (1 bit) + */
/* Ext LNA Gain (7 bits) */
0x00, /* Reserved */

Check notice on line 1323 in drivers/bluetooth/hci/hci_nxp_setup.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/bluetooth/hci/hci_nxp_setup.c:1323 - /* Ext. PA Gain (7 bits) */ + /* Ext. PA Gain (7 bits) */ 0x00, /* Ext Antenna Gain(1 bit) + */ - /* Ext. Antenna Gain Val(4 bits) */ + /* Ext. Antenna Gain Val(4 bits) */ 0x04, 0x00, /* BT / LE Ext PA FEM CTRL Bitmask */ 0x01, /* Ext LNA Present (1 bit) + */ - /* Ext LNA Gain (7 bits) */ + /* Ext LNA Gain (7 bits) */

Check notice on line 1323 in drivers/bluetooth/hci/hci_nxp_setup.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/bluetooth/hci/hci_nxp_setup.c:1323 - /* Ext. PA Gain (7 bits) */ + /* Ext. PA Gain (7 bits) */ 0x00, /* Ext Antenna Gain(1 bit) + */ - /* Ext. Antenna Gain Val(4 bits) */ + /* Ext. Antenna Gain Val(4 bits) */ 0x04, 0x00, /* BT / LE Ext PA FEM CTRL Bitmask */ 0x01, /* Ext LNA Present (1 bit) + */ - /* Ext LNA Gain (7 bits) */ + /* Ext LNA Gain (7 bits) */
0x04, 0x00 /* BT / LE Ext LNA FEM CTRL Bitmask */
#elif defined(CONFIG_BT_NXP_IW416)
0x64, /* Annex Type : 0x64 */
0x83, /* Checksum */
0x10, 0x00, /* Length */
0x00, 0x00, 0x00, 0x00, /* Pointer for next Annex-Structure */
0x01, /* Ext PA Present (1 bit) + */
/* Ext. PA Gain (7 bits) */
0x00, /* Ext Antenna Gain(1 bit) + */
/* Ext. Antenna Gain Val (4 bits) */
0x0C, 0x00, /* BT / LE Ext PA FEM CTRL Bitmask */
0x01, /* Ext LNA Present (1 bit) + */
/* Ext LNA Gain (7 bits) */
0x00, /* Reserved */

Check notice on line 1337 in drivers/bluetooth/hci/hci_nxp_setup.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/bluetooth/hci/hci_nxp_setup.c:1337 - /* Ext. PA Gain (7 bits) */ + /* Ext. PA Gain (7 bits) */ 0x00, /* Ext Antenna Gain(1 bit) + */ - /* Ext. Antenna Gain Val (4 bits) */ + /* Ext. Antenna Gain Val (4 bits) */ 0x0C, 0x00, /* BT / LE Ext PA FEM CTRL Bitmask */ 0x01, /* Ext LNA Present (1 bit) + */ - /* Ext LNA Gain (7 bits) */ + /* Ext LNA Gain (7 bits) */

Check notice on line 1337 in drivers/bluetooth/hci/hci_nxp_setup.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/bluetooth/hci/hci_nxp_setup.c:1337 - /* Ext. PA Gain (7 bits) */ + /* Ext. PA Gain (7 bits) */ 0x00, /* Ext Antenna Gain(1 bit) + */ - /* Ext. Antenna Gain Val (4 bits) */ + /* Ext. Antenna Gain Val (4 bits) */ 0x0C, 0x00, /* BT / LE Ext PA FEM CTRL Bitmask */ 0x01, /* Ext LNA Present (1 bit) + */ - /* Ext LNA Gain (7 bits) */ + /* Ext LNA Gain (7 bits) */
0x0C, 0x00 /* BT/LE Ext LNA FEM CTRL Bitmask */
#else
#error "BT Calibration data (annex-100) is not given for selected chipset"
#endif
};

uint16_t opcode = BT_OP(BT_OGF_VS, HCI_CMD_STORE_BT_CAL_DATA_ANNEX100_OCF);

if (IS_ENABLED(CONFIG_BT_HCI_HOST)) {
struct net_buf *buf;

buf = bt_hci_cmd_alloc(K_FOREVER);
if (buf == NULL) {
LOG_ERR("Unable to allocate command buffer");
return -ENOMEM;
}

net_buf_add_mem(buf, hci_cal_data_annex100,
HCI_CMD_STORE_BT_CAL_DATA_PARAM_ANNEX100_LENGTH);

Check notice on line 1357 in drivers/bluetooth/hci/hci_nxp_setup.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/bluetooth/hci/hci_nxp_setup.c:1357 - HCI_CMD_STORE_BT_CAL_DATA_PARAM_ANNEX100_LENGTH); + HCI_CMD_STORE_BT_CAL_DATA_PARAM_ANNEX100_LENGTH);

Check notice on line 1357 in drivers/bluetooth/hci/hci_nxp_setup.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/bluetooth/hci/hci_nxp_setup.c:1357 - HCI_CMD_STORE_BT_CAL_DATA_PARAM_ANNEX100_LENGTH); + HCI_CMD_STORE_BT_CAL_DATA_PARAM_ANNEX100_LENGTH);
ret = bt_hci_cmd_send_sync(opcode, buf, NULL);
if (ret) {
LOG_ERR("Failed to send set-calibration cmd (err %d)", ret);
return ret;
}
}

return ret;
}
#endif /* defined(CONFIG_HCI_NXP_SET_CAL_DATA_ANNEX100) */

int bt_hci_transport_setup(const struct device *dev)
{
int ret = 0;
Expand All @@ -1192,8 +1387,7 @@
int err;
struct net_buf *buf;

buf = bt_hci_cmd_create(BT_HCI_VSC_BAUDRATE_UPDATE_OPCODE,
BT_HCI_VSC_BAUDRATE_UPDATE_LENGTH);
buf = bt_hci_cmd_alloc(K_FOREVER);
if (!buf) {
LOG_ERR("Fail to allocate buffer");
return -ENOBUFS;
Expand Down Expand Up @@ -1231,6 +1425,7 @@
flowcontrol_of_hci = (bool)DT_PROP_OR(DT_DRV_INST(0), hw_flow_control, false);

if (operation_speed == default_speed) {
fw_upload.is_setup_done = true;
return 0;
}

Expand All @@ -1240,8 +1435,8 @@
return err;
}

/* BT waiting time after controller bandrate updated */
/* BT waiting time after controller bandrate updated */
(void)k_msleep(CONFIG_BT_H4_NXP_CTLR_WAIT_TIME_AFTER_BAUDRATE_UPDATE);

Check notice on line 1439 in drivers/bluetooth/hci/hci_nxp_setup.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/bluetooth/hci/hci_nxp_setup.c:1439 - /* BT waiting time after controller bandrate updated */ + /* BT waiting time after controller bandrate updated */

Check notice on line 1439 in drivers/bluetooth/hci/hci_nxp_setup.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/bluetooth/hci/hci_nxp_setup.c:1439 - /* BT waiting time after controller bandrate updated */ + /* BT waiting time after controller bandrate updated */
}

err = fw_upload_uart_reconfig(operation_speed, flowcontrol_of_hci);
Expand All @@ -1250,7 +1445,21 @@
return err;
}

fw_upload.is_setup_done = true;
if (!fw_upload.is_setup_done) {
err = bt_nxp_set_calibration_data_annex55();
if (err) {
LOG_ERR("Fail to load annex-55 calibration data");
return err;
}

err = bt_nxp_set_calibration_data_annex100();
if (err) {
LOG_ERR("Fail to load annex-100 calibration data");
return err;
}

fw_upload.is_setup_done = true;
}

return 0;
}
2 changes: 1 addition & 1 deletion drivers/bluetooth/hci/hci_spi_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ static int bt_spi_send_aci_config(uint8_t offset, const uint8_t *value, size_t v
hdr.param_len = data_len;
buf = bt_buf_get_tx(BT_BUF_CMD, K_NO_WAIT, &hdr, sizeof(hdr));
#else
buf = bt_hci_cmd_create(BLUENRG_ACI_WRITE_CONFIG_DATA, data_len);
buf = bt_hci_cmd_alloc(K_FOREVER);
#endif /* CONFIG_BT_HCI_RAW */

if (!buf) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/bluetooth/hci/hci_stm32wba.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ static int bt_hci_stm32wba_setup(const struct device *dev,
return -ENOMSG;
}

buf = bt_hci_cmd_create(ACI_HAL_WRITE_CONFIG_DATA, sizeof(*param));
buf = bt_hci_cmd_alloc(K_FOREVER);
if (!buf) {
return -ENOBUFS;
}
Expand Down
Loading
Loading