Skip to content
Open
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
56 changes: 56 additions & 0 deletions drivers/bluetooth/btqca.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,53 @@ static int qca_download_firmware(struct hci_dev *hdev,
memcpy(data, fw->data, size);
release_firmware(fw);

/* For QCC2072, combine the NVM (type 2) with the calibration file
* into a single TLV of outer type 4.
*/
if (soc_type == QCA_QCC2072 && config->type == TLV_TYPE_NVM) {
const struct firmware *calib_fw = NULL;
char calib_name[32];
u8 *combined_data = NULL;
size_t inner_len, combined_size;
struct tlv_type_hdr *outer_hdr;
int err;

snprintf(calib_name, sizeof(calib_name),
"qca/ornbcscal%02x.bin", rom_ver);
err = request_firmware(&calib_fw, calib_name, &hdev->dev);
if (err) {
bt_dev_err(hdev, "QCA Failed to request file: %s (%d)",
calib_name, err);
goto skip_combination;
}

bt_dev_info(hdev, "QCA Downloading %s", calib_name);

inner_len = size + calib_fw->size;
combined_size = sizeof(*outer_hdr) + inner_len;
combined_data = vmalloc(combined_size);
if (!combined_data) {
bt_dev_warn(hdev,
"QCA Failed to allocate memory for file: %s",
calib_name);
release_firmware(calib_fw);
goto skip_combination;
}

outer_hdr = (struct tlv_type_hdr *)combined_data;
/* high 24 bits = payload length, low 8 bits = type */
outer_hdr->type_len = cpu_to_le32((inner_len << 8) | 4);
memcpy(combined_data + sizeof(*outer_hdr), data, size);
memcpy(combined_data + sizeof(*outer_hdr) + size,
calib_fw->data, calib_fw->size);
release_firmware(calib_fw);
vfree(data);
data = combined_data;
size = combined_size;
skip_combination:
;
}

ret = qca_tlv_check_data(hdev, config, data, size, soc_type);
if (ret)
goto out;
Expand Down Expand Up @@ -843,6 +890,10 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
snprintf(config.fwname, sizeof(config.fwname),
"qca/hmtbtfw%02x.tlv", rom_ver);
break;
case QCA_QCC2072:
snprintf(config.fwname, sizeof(config.fwname),
"qca/ornbtfw%02x.tlv", rom_ver);
break;
default:
snprintf(config.fwname, sizeof(config.fwname),
"qca/rampatch_%08x.bin", soc_ver);
Expand Down Expand Up @@ -937,6 +988,10 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
qca_get_nvm_name_by_board(config.fwname, sizeof(config.fwname),
"hmtnv", soc_type, ver, rom_ver, boardid);
break;
case QCA_QCC2072:
snprintf(config.fwname, sizeof(config.fwname),
"qca/ornnv%02x.bin", rom_ver);
break;
default:
snprintf(config.fwname, sizeof(config.fwname),
"qca/nvm_%08x.bin", soc_ver);
Expand Down Expand Up @@ -999,6 +1054,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
case QCA_WCN6750:
case QCA_WCN6855:
case QCA_WCN7850:
case QCA_QCC2072:
/* get fw build info */
err = qca_read_fw_build_info(hdev);
if (err < 0)
Expand Down
1 change: 1 addition & 0 deletions drivers/bluetooth/btqca.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ enum qca_btsoc_type {
QCA_WCN6750,
QCA_WCN6855,
QCA_WCN7850,
QCA_QCC2072,
};

#if IS_ENABLED(CONFIG_BT_QCA)
Expand Down
24 changes: 24 additions & 0 deletions drivers/bluetooth/hci_qca.c
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)

/* Give the controller time to process the request */
switch (qca_soc_type(hu)) {
case QCA_QCC2072:
case QCA_WCN3950:
case QCA_WCN3988:
case QCA_WCN3990:
Expand Down Expand Up @@ -1459,6 +1460,7 @@ static unsigned int qca_get_speed(struct hci_uart *hu,
static int qca_check_speeds(struct hci_uart *hu)
{
switch (qca_soc_type(hu)) {
case QCA_QCC2072:
case QCA_WCN3950:
case QCA_WCN3988:
case QCA_WCN3990:
Expand Down Expand Up @@ -1510,6 +1512,7 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)
case QCA_WCN6750:
case QCA_WCN6855:
case QCA_WCN7850:
case QCA_QCC2072:
hci_uart_set_flow_control(hu, true);
break;

Expand Down Expand Up @@ -1545,6 +1548,7 @@ static int qca_set_speed(struct hci_uart *hu, enum qca_speed_type speed_type)
case QCA_WCN6750:
case QCA_WCN6855:
case QCA_WCN7850:
case QCA_QCC2072:
hci_uart_set_flow_control(hu, false);
break;

Expand Down Expand Up @@ -1861,6 +1865,7 @@ static int qca_power_on(struct hci_dev *hdev)
case QCA_WCN6750:
case QCA_WCN6855:
case QCA_WCN7850:
case QCA_QCC2072:
ret = qca_regulator_init(hu);
break;

Expand Down Expand Up @@ -1957,6 +1962,10 @@ static int qca_setup(struct hci_uart *hu)
soc_name = "wcn7850";
break;

case QCA_QCC2072:
soc_name = "qcc2072";
break;

default:
soc_name = "ROME/QCA6390";
}
Expand All @@ -1980,6 +1989,7 @@ static int qca_setup(struct hci_uart *hu)
case QCA_WCN6750:
case QCA_WCN6855:
case QCA_WCN7850:
case QCA_QCC2072:
if (qcadev->bdaddr_property_broken)
hci_set_quirk(hdev, HCI_QUIRK_BDADDR_PROPERTY_BROKEN);

Expand Down Expand Up @@ -2013,6 +2023,7 @@ static int qca_setup(struct hci_uart *hu)
case QCA_WCN6750:
case QCA_WCN6855:
case QCA_WCN7850:
case QCA_QCC2072:
break;

default:
Expand Down Expand Up @@ -2110,6 +2121,12 @@ static const struct qca_device_data qca_soc_data_qca6390 __maybe_unused = {
.num_vregs = 0,
};

static const struct qca_device_data qca_soc_data_qcc2072 __maybe_unused = {
.soc_type = QCA_QCC2072,
.num_vregs = 0,
.capabilities = QCA_CAP_WIDEBAND_SPEECH | QCA_CAP_VALID_LE_STATES,
};

static const struct qca_device_data qca_soc_data_wcn3950 __maybe_unused = {
.soc_type = QCA_WCN3950,
.vregs = (struct qca_vreg []) {
Expand Down Expand Up @@ -2268,6 +2285,7 @@ static void qca_power_off(struct hci_uart *hu)

case QCA_WCN6750:
case QCA_WCN6855:
case QCA_QCC2072:
gpiod_set_value_cansleep(qcadev->bt_en, 0);
msleep(100);
qca_regulator_disable(qcadev);
Expand Down Expand Up @@ -2415,6 +2433,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)

switch (qcadev->btsoc_type) {
case QCA_QCA6390:
case QCA_QCC2072:
case QCA_WCN3950:
case QCA_WCN3988:
case QCA_WCN3990:
Expand Down Expand Up @@ -2442,6 +2461,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
case QCA_WCN6750:
case QCA_WCN6855:
case QCA_WCN7850:
case QCA_QCC2072:
if (!device_property_present(&serdev->dev, "enable-gpios")) {
/*
* Backward compatibility with old DT sources. If the
Expand Down Expand Up @@ -2483,6 +2503,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)

if (!qcadev->bt_en &&
(data->soc_type == QCA_WCN6750 ||
data->soc_type == QCA_QCC2072 ||
data->soc_type == QCA_WCN6855 ||
data->soc_type == QCA_WCN7850))
power_ctrl_enabled = false;
Expand All @@ -2492,6 +2513,7 @@ static int qca_serdev_probe(struct serdev_device *serdev)
if (IS_ERR(qcadev->sw_ctrl) &&
(data->soc_type == QCA_WCN6750 ||
data->soc_type == QCA_WCN6855 ||
data->soc_type == QCA_QCC2072 ||
data->soc_type == QCA_WCN7850)) {
dev_err(&serdev->dev, "failed to acquire SW_CTRL gpio\n");
return PTR_ERR(qcadev->sw_ctrl);
Expand Down Expand Up @@ -2574,6 +2596,7 @@ static void qca_serdev_remove(struct serdev_device *serdev)
case QCA_WCN3990:
case QCA_WCN3991:
case QCA_WCN3998:
case QCA_QCC2072:
case QCA_WCN6750:
case QCA_WCN6855:
case QCA_WCN7850:
Expand Down Expand Up @@ -2779,6 +2802,7 @@ static const struct of_device_id qca_bluetooth_of_match[] = {
{ .compatible = "qcom,wcn6750-bt", .data = &qca_soc_data_wcn6750},
{ .compatible = "qcom,wcn6855-bt", .data = &qca_soc_data_wcn6855},
{ .compatible = "qcom,wcn7850-bt", .data = &qca_soc_data_wcn7850},
{ .compatible = "qcom,qcc2072-bt", .data = &qca_soc_data_qcc2072},
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, qca_bluetooth_of_match);
Expand Down