Skip to content

Commit ba493d4

Browse files
bgodavarholtmann
authored andcommitted
Bluetooth: btqca: Rename ROME specific functions to generic functions
Some of the QCA BTSoC ROME functions, are used for different versions or different make of BTSoC's. Instead of duplicating the same functions for new chip, update names of the functions that are used for both chips to keep this generic and would help in future when we would have new BT SoC. To have generic text in logs updated from ROME to QCA where ever possible. This avoids confusion to user, when using the future Qualcomm Bluetooth SoC's. Updated BT_DBG, BT_ERR and BT_INFO with bt_dev_dbg, bt_dev_err and bt_dev_info where ever applicable. Signed-off-by: Balakrishna Godavarthi <[email protected]> Reviewed-by: Matthias Kaehlcke <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 5050135 commit ba493d4

File tree

3 files changed

+51
-46
lines changed

3 files changed

+51
-46
lines changed

drivers/bluetooth/btqca.c

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,44 +27,43 @@
2727

2828
#define VERSION "0.1"
2929

30-
static int rome_patch_ver_req(struct hci_dev *hdev, u32 *rome_version)
30+
int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version)
3131
{
3232
struct sk_buff *skb;
3333
struct edl_event_hdr *edl;
3434
struct rome_version *ver;
3535
char cmd;
3636
int err = 0;
3737

38-
BT_DBG("%s: ROME Patch Version Request", hdev->name);
38+
bt_dev_dbg(hdev, "QCA Version Request");
3939

4040
cmd = EDL_PATCH_VER_REQ_CMD;
4141
skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, EDL_PATCH_CMD_LEN,
4242
&cmd, HCI_VENDOR_PKT, HCI_INIT_TIMEOUT);
4343
if (IS_ERR(skb)) {
4444
err = PTR_ERR(skb);
45-
BT_ERR("%s: Failed to read version of ROME (%d)", hdev->name,
46-
err);
45+
bt_dev_err(hdev, "Reading QCA version information failed (%d)",
46+
err);
4747
return err;
4848
}
4949

5050
if (skb->len != sizeof(*edl) + sizeof(*ver)) {
51-
BT_ERR("%s: Version size mismatch len %d", hdev->name,
52-
skb->len);
51+
bt_dev_err(hdev, "QCA Version size mismatch len %d", skb->len);
5352
err = -EILSEQ;
5453
goto out;
5554
}
5655

5756
edl = (struct edl_event_hdr *)(skb->data);
5857
if (!edl) {
59-
BT_ERR("%s: TLV with no header", hdev->name);
58+
bt_dev_err(hdev, "QCA TLV with no header");
6059
err = -EILSEQ;
6160
goto out;
6261
}
6362

6463
if (edl->cresp != EDL_CMD_REQ_RES_EVT ||
6564
edl->rtype != EDL_APP_VER_RES_EVT) {
66-
BT_ERR("%s: Wrong packet received %d %d", hdev->name,
67-
edl->cresp, edl->rtype);
65+
bt_dev_err(hdev, "QCA Wrong packet received %d %d", edl->cresp,
66+
edl->rtype);
6867
err = -EIO;
6968
goto out;
7069
}
@@ -76,30 +75,31 @@ static int rome_patch_ver_req(struct hci_dev *hdev, u32 *rome_version)
7675
BT_DBG("%s: ROM :0x%08x", hdev->name, le16_to_cpu(ver->rome_ver));
7776
BT_DBG("%s: SOC :0x%08x", hdev->name, le32_to_cpu(ver->soc_id));
7877

79-
/* ROME chipset version can be decided by patch and SoC
78+
/* QCA chipset version can be decided by patch and SoC
8079
* version, combination with upper 2 bytes from SoC
8180
* and lower 2 bytes from patch will be used.
8281
*/
83-
*rome_version = (le32_to_cpu(ver->soc_id) << 16) |
82+
*soc_version = (le32_to_cpu(ver->soc_id) << 16) |
8483
(le16_to_cpu(ver->rome_ver) & 0x0000ffff);
8584

8685
out:
8786
kfree_skb(skb);
8887

8988
return err;
9089
}
90+
EXPORT_SYMBOL_GPL(qca_read_soc_version);
9191

92-
static int rome_reset(struct hci_dev *hdev)
92+
static int qca_send_reset(struct hci_dev *hdev)
9393
{
9494
struct sk_buff *skb;
9595
int err;
9696

97-
BT_DBG("%s: ROME HCI_RESET", hdev->name);
97+
bt_dev_dbg(hdev, "QCA HCI_RESET");
9898

9999
skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
100100
if (IS_ERR(skb)) {
101101
err = PTR_ERR(skb);
102-
BT_ERR("%s: Reset failed (%d)", hdev->name, err);
102+
bt_dev_err(hdev, "QCA Reset failed (%d)", err);
103103
return err;
104104
}
105105

@@ -108,7 +108,7 @@ static int rome_reset(struct hci_dev *hdev)
108108
return 0;
109109
}
110110

111-
static void rome_tlv_check_data(struct rome_config *config,
111+
static void qca_tlv_check_data(struct rome_config *config,
112112
const struct firmware *fw)
113113
{
114114
const u8 *data;
@@ -207,7 +207,7 @@ static void rome_tlv_check_data(struct rome_config *config,
207207
}
208208
}
209209

210-
static int rome_tlv_send_segment(struct hci_dev *hdev, int seg_size,
210+
static int qca_tlv_send_segment(struct hci_dev *hdev, int seg_size,
211211
const u8 *data, enum rome_tlv_dnld_mode mode)
212212
{
213213
struct sk_buff *skb;
@@ -228,19 +228,19 @@ static int rome_tlv_send_segment(struct hci_dev *hdev, int seg_size,
228228
HCI_VENDOR_PKT, HCI_INIT_TIMEOUT);
229229
if (IS_ERR(skb)) {
230230
err = PTR_ERR(skb);
231-
BT_ERR("%s: Failed to send TLV segment (%d)", hdev->name, err);
231+
bt_dev_err(hdev, "QCA Failed to send TLV segment (%d)", err);
232232
return err;
233233
}
234234

235235
if (skb->len != sizeof(*edl) + sizeof(*tlv_resp)) {
236-
BT_ERR("%s: TLV response size mismatch", hdev->name);
236+
bt_dev_err(hdev, "QCA TLV response size mismatch");
237237
err = -EILSEQ;
238238
goto out;
239239
}
240240

241241
edl = (struct edl_event_hdr *)(skb->data);
242242
if (!edl) {
243-
BT_ERR("%s: TLV with no header", hdev->name);
243+
bt_dev_err(hdev, "TLV with no header");
244244
err = -EILSEQ;
245245
goto out;
246246
}
@@ -249,8 +249,8 @@ static int rome_tlv_send_segment(struct hci_dev *hdev, int seg_size,
249249

250250
if (edl->cresp != EDL_CMD_REQ_RES_EVT ||
251251
edl->rtype != EDL_TVL_DNLD_RES_EVT || tlv_resp->result != 0x00) {
252-
BT_ERR("%s: TLV with error stat 0x%x rtype 0x%x (0x%x)",
253-
hdev->name, edl->cresp, edl->rtype, tlv_resp->result);
252+
bt_dev_err(hdev, "QCA TLV with error stat 0x%x rtype 0x%x (0x%x)",
253+
edl->cresp, edl->rtype, tlv_resp->result);
254254
err = -EIO;
255255
}
256256

@@ -260,23 +260,23 @@ static int rome_tlv_send_segment(struct hci_dev *hdev, int seg_size,
260260
return err;
261261
}
262262

263-
static int rome_download_firmware(struct hci_dev *hdev,
263+
static int qca_download_firmware(struct hci_dev *hdev,
264264
struct rome_config *config)
265265
{
266266
const struct firmware *fw;
267267
const u8 *segment;
268268
int ret, remain, i = 0;
269269

270-
bt_dev_info(hdev, "ROME Downloading %s", config->fwname);
270+
bt_dev_info(hdev, "QCA Downloading %s", config->fwname);
271271

272272
ret = request_firmware(&fw, config->fwname, &hdev->dev);
273273
if (ret) {
274-
BT_ERR("%s: Failed to request file: %s (%d)", hdev->name,
275-
config->fwname, ret);
274+
bt_dev_err(hdev, "QCA Failed to request file: %s (%d)",
275+
config->fwname, ret);
276276
return ret;
277277
}
278278

279-
rome_tlv_check_data(config, fw);
279+
qca_tlv_check_data(config, fw);
280280

281281
segment = fw->data;
282282
remain = fw->size;
@@ -290,7 +290,7 @@ static int rome_download_firmware(struct hci_dev *hdev,
290290
if (!remain || segsize < MAX_SIZE_PER_TLV_SEGMENT)
291291
config->dnld_mode = ROME_SKIP_EVT_NONE;
292292

293-
ret = rome_tlv_send_segment(hdev, segsize, segment,
293+
ret = qca_tlv_send_segment(hdev, segsize, segment,
294294
config->dnld_mode);
295295
if (ret)
296296
break;
@@ -317,8 +317,7 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
317317
HCI_VENDOR_PKT, HCI_INIT_TIMEOUT);
318318
if (IS_ERR(skb)) {
319319
err = PTR_ERR(skb);
320-
BT_ERR("%s: Change address command failed (%d)",
321-
hdev->name, err);
320+
bt_dev_err(hdev, "QCA Change address command failed (%d)", err);
322321
return err;
323322
}
324323

@@ -328,57 +327,57 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
328327
}
329328
EXPORT_SYMBOL_GPL(qca_set_bdaddr_rome);
330329

331-
int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate)
330+
int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate)
332331
{
333332
u32 rome_ver = 0;
334333
struct rome_config config;
335334
int err;
336335

337-
BT_DBG("%s: ROME setup on UART", hdev->name);
336+
bt_dev_dbg(hdev, "QCA setup on UART");
338337

339338
config.user_baud_rate = baudrate;
340339

341-
/* Get ROME version information */
342-
err = rome_patch_ver_req(hdev, &rome_ver);
340+
/* Get QCA version information */
341+
err = qca_read_soc_version(hdev, &rome_ver);
343342
if (err < 0 || rome_ver == 0) {
344-
BT_ERR("%s: Failed to get version 0x%x", hdev->name, err);
343+
bt_dev_err(hdev, "QCA Failed to get version %d", err);
345344
return err;
346345
}
347346

348-
bt_dev_info(hdev, "ROME controller version 0x%08x", rome_ver);
347+
bt_dev_info(hdev, "QCA controller version 0x%08x", rome_ver);
349348

350349
/* Download rampatch file */
351350
config.type = TLV_TYPE_PATCH;
352351
snprintf(config.fwname, sizeof(config.fwname), "qca/rampatch_%08x.bin",
353352
rome_ver);
354-
err = rome_download_firmware(hdev, &config);
353+
err = qca_download_firmware(hdev, &config);
355354
if (err < 0) {
356-
BT_ERR("%s: Failed to download patch (%d)", hdev->name, err);
355+
bt_dev_err(hdev, "QCA Failed to download patch (%d)", err);
357356
return err;
358357
}
359358

360359
/* Download NVM configuration */
361360
config.type = TLV_TYPE_NVM;
362361
snprintf(config.fwname, sizeof(config.fwname), "qca/nvm_%08x.bin",
363362
rome_ver);
364-
err = rome_download_firmware(hdev, &config);
363+
err = qca_download_firmware(hdev, &config);
365364
if (err < 0) {
366-
BT_ERR("%s: Failed to download NVM (%d)", hdev->name, err);
365+
bt_dev_err(hdev, "QCA Failed to download NVM (%d)", err);
367366
return err;
368367
}
369368

370369
/* Perform HCI reset */
371-
err = rome_reset(hdev);
370+
err = qca_send_reset(hdev);
372371
if (err < 0) {
373-
BT_ERR("%s: Failed to run HCI_RESET (%d)", hdev->name, err);
372+
bt_dev_err(hdev, "QCA Failed to run HCI_RESET (%d)", err);
374373
return err;
375374
}
376375

377-
bt_dev_info(hdev, "ROME setup on UART is completed");
376+
bt_dev_info(hdev, "QCA setup on UART is completed");
378377

379378
return 0;
380379
}
381-
EXPORT_SYMBOL_GPL(qca_uart_setup_rome);
380+
EXPORT_SYMBOL_GPL(qca_uart_setup);
382381

383382
MODULE_AUTHOR("Ben Young Tae Kim <[email protected]>");
384383
MODULE_DESCRIPTION("Bluetooth support for Qualcomm Atheros family ver " VERSION);

drivers/bluetooth/btqca.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ struct tlv_type_hdr {
127127
#if IS_ENABLED(CONFIG_BT_QCA)
128128

129129
int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr);
130-
int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate);
130+
int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate);
131+
int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version);
131132

132133
#else
133134

@@ -136,7 +137,12 @@ static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdad
136137
return -EOPNOTSUPP;
137138
}
138139

139-
static inline int qca_uart_setup_rome(struct hci_dev *hdev, int speed)
140+
static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate)
141+
{
142+
return -EOPNOTSUPP;
143+
}
144+
145+
static inline int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version)
140146
{
141147
return -EOPNOTSUPP;
142148
}

drivers/bluetooth/hci_qca.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ static int qca_setup(struct hci_uart *hu)
966966
}
967967

968968
/* Setup patch / NVM configurations */
969-
ret = qca_uart_setup_rome(hdev, qca_baudrate);
969+
ret = qca_uart_setup(hdev, qca_baudrate);
970970
if (!ret) {
971971
set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags);
972972
qca_debugfs_init(hdev);

0 commit comments

Comments
 (0)