blob: 6ecd329bad410e86e483daac8b94071a5328b07e [file] [log] [blame]
Thomas Gleixner45051532019-05-29 16:57:47 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Ben Young Tae Kim83e81962015-08-10 14:24:12 -07002/*
3 * Bluetooth supports for Qualcomm Atheros ROME chips
4 *
5 * Copyright (c) 2015 The Linux Foundation. All rights reserved.
Ben Young Tae Kim83e81962015-08-10 14:24:12 -07006 */
7
8#define EDL_PATCH_CMD_OPCODE (0xFC00)
9#define EDL_NVM_ACCESS_OPCODE (0xFC0B)
Balakrishna Godavarthi5c0a10012019-01-16 18:01:15 +053010#define EDL_WRITE_BD_ADDR_OPCODE (0xFC14)
Ben Young Tae Kim83e81962015-08-10 14:24:12 -070011#define EDL_PATCH_CMD_LEN (1)
12#define EDL_PATCH_VER_REQ_CMD (0x19)
13#define EDL_PATCH_TLV_REQ_CMD (0x1E)
Venkata Lakshmi Narayana Gubbac0187b02020-12-08 17:25:29 +053014#define EDL_GET_BUILD_INFO_CMD (0x20)
Ben Young Tae Kim83e81962015-08-10 14:24:12 -070015#define EDL_NVM_ACCESS_SET_REQ_CMD (0x01)
16#define MAX_SIZE_PER_TLV_SEGMENT (243)
Harish Bandia2780882019-07-12 10:39:40 +053017#define QCA_PRE_SHUTDOWN_CMD (0xFC08)
Balakrishna Godavarthi590decc2020-06-12 17:50:28 +053018#define QCA_DISABLE_LOGGING (0xFC17)
Ben Young Tae Kim83e81962015-08-10 14:24:12 -070019
20#define EDL_CMD_REQ_RES_EVT (0x00)
21#define EDL_PATCH_VER_RES_EVT (0x19)
22#define EDL_APP_VER_RES_EVT (0x02)
23#define EDL_TVL_DNLD_RES_EVT (0x04)
24#define EDL_CMD_EXE_STATUS_EVT (0x00)
25#define EDL_SET_BAUDRATE_RSP_EVT (0x92)
26#define EDL_NVM_ACCESS_CODE_EVT (0x0B)
Balakrishna Godavarthi590decc2020-06-12 17:50:28 +053027#define QCA_DISABLE_LOGGING_SUB_OP (0x14)
Ben Young Tae Kim83e81962015-08-10 14:24:12 -070028
29#define EDL_TAG_ID_HCI (17)
30#define EDL_TAG_ID_DEEP_SLEEP (27)
31
Balakrishna Godavarthifa9ad872018-08-03 17:46:32 +053032#define QCA_WCN3990_POWERON_PULSE 0xFC
33#define QCA_WCN3990_POWEROFF_PULSE 0xC0
34
Balakrishna Godavarthi32646db2019-05-28 14:43:22 -070035#define QCA_HCI_CC_OPCODE 0xFC00
36#define QCA_HCI_CC_SUCCESS 0x00
37
Venkata Lakshmi Narayana Gubba059924f2020-11-19 18:24:09 +053038#define QCA_WCN3991_SOC_ID (0x40014320)
39
40/* QCA chipset version can be decided by patch and SoC
41 * version, combination with upper 2 bytes from SoC
42 * and lower 2 bytes from patch will be used.
43 */
44#define get_soc_ver(soc_id, rom_ver) \
45 ((le32_to_cpu(soc_id) << 16) | (le16_to_cpu(rom_ver)))
46
47#define QCA_FW_BUILD_VER_LEN 255
48
49
Matthias Kaehlcke75c98a92019-03-12 16:02:57 -070050enum qca_baudrate {
Ben Young Tae Kim83e81962015-08-10 14:24:12 -070051 QCA_BAUDRATE_115200 = 0,
52 QCA_BAUDRATE_57600,
53 QCA_BAUDRATE_38400,
54 QCA_BAUDRATE_19200,
55 QCA_BAUDRATE_9600,
56 QCA_BAUDRATE_230400,
57 QCA_BAUDRATE_250000,
58 QCA_BAUDRATE_460800,
59 QCA_BAUDRATE_500000,
60 QCA_BAUDRATE_720000,
61 QCA_BAUDRATE_921600,
62 QCA_BAUDRATE_1000000,
63 QCA_BAUDRATE_1250000,
64 QCA_BAUDRATE_2000000,
65 QCA_BAUDRATE_3000000,
66 QCA_BAUDRATE_4000000,
67 QCA_BAUDRATE_1600000,
68 QCA_BAUDRATE_3200000,
69 QCA_BAUDRATE_3500000,
70 QCA_BAUDRATE_AUTO = 0xFE,
71 QCA_BAUDRATE_RESERVED
72};
73
Balakrishna Godavarthie303d122019-11-06 15:18:31 +053074enum qca_tlv_dnld_mode {
75 QCA_SKIP_EVT_NONE,
76 QCA_SKIP_EVT_VSE,
77 QCA_SKIP_EVT_CC,
78 QCA_SKIP_EVT_VSE_CC
Loic Poulain6e031262018-04-26 13:13:27 +020079};
80
Balakrishna Godavarthie303d122019-11-06 15:18:31 +053081enum qca_tlv_type {
Ben Young Tae Kim83e81962015-08-10 14:24:12 -070082 TLV_TYPE_PATCH = 1,
83 TLV_TYPE_NVM
84};
85
Balakrishna Godavarthie303d122019-11-06 15:18:31 +053086struct qca_fw_config {
Ben Young Tae Kim83e81962015-08-10 14:24:12 -070087 u8 type;
88 char fwname[64];
89 uint8_t user_baud_rate;
Balakrishna Godavarthie303d122019-11-06 15:18:31 +053090 enum qca_tlv_dnld_mode dnld_mode;
91 enum qca_tlv_dnld_mode dnld_type;
Ben Young Tae Kim83e81962015-08-10 14:24:12 -070092};
93
94struct edl_event_hdr {
95 __u8 cresp;
96 __u8 rtype;
Gustavo A. R. Silvaa7e45452020-02-26 17:02:27 -060097 __u8 data[];
Ben Young Tae Kim83e81962015-08-10 14:24:12 -070098} __packed;
99
Balakrishna Godavarthie303d122019-11-06 15:18:31 +0530100struct qca_btsoc_version {
Ben Young Tae Kim83e81962015-08-10 14:24:12 -0700101 __le32 product_id;
102 __le16 patch_ver;
Balakrishna Godavarthie303d122019-11-06 15:18:31 +0530103 __le16 rom_ver;
Ben Young Tae Kim83e81962015-08-10 14:24:12 -0700104 __le32 soc_id;
105} __packed;
106
107struct tlv_seg_resp {
108 __u8 result;
109} __packed;
110
111struct tlv_type_patch {
112 __le32 total_size;
113 __le32 data_length;
114 __u8 format_version;
115 __u8 signature;
Loic Poulain6e031262018-04-26 13:13:27 +0200116 __u8 download_mode;
117 __u8 reserved1;
Ben Young Tae Kim83e81962015-08-10 14:24:12 -0700118 __le16 product_id;
119 __le16 rom_build;
120 __le16 patch_version;
121 __le16 reserved2;
122 __le32 entry;
123} __packed;
124
125struct tlv_type_nvm {
126 __le16 tag_id;
127 __le16 tag_len;
128 __le32 reserve1;
129 __le32 reserve2;
Gustavo A. R. Silvaa7e45452020-02-26 17:02:27 -0600130 __u8 data[];
Ben Young Tae Kim83e81962015-08-10 14:24:12 -0700131} __packed;
132
133struct tlv_type_hdr {
134 __le32 type_len;
Gustavo A. R. Silvaa7e45452020-02-26 17:02:27 -0600135 __u8 data[];
Ben Young Tae Kim83e81962015-08-10 14:24:12 -0700136} __packed;
137
Balakrishna Godavarthiaadebac2018-08-03 17:46:28 +0530138enum qca_btsoc_type {
139 QCA_INVALID = -1,
140 QCA_AR3002,
141 QCA_ROME,
Harish Bandi523760b2019-04-26 19:26:01 +0530142 QCA_WCN3990,
143 QCA_WCN3998,
Rocky Liaoe5d64682020-03-25 10:26:37 +0800144 QCA_WCN3991,
145 QCA_QCA6390,
Venkata Lakshmi Narayana Gubbad8f97da2021-05-18 22:04:42 +0530146 QCA_WCN6750,
Balakrishna Godavarthiaadebac2018-08-03 17:46:28 +0530147};
148
Ben Young Tae Kim83e81962015-08-10 14:24:12 -0700149#if IS_ENABLED(CONFIG_BT_QCA)
150
151int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr);
Balakrishna Godavarthiaadebac2018-08-03 17:46:28 +0530152int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
Venkata Lakshmi Narayana Gubba059924f2020-11-19 18:24:09 +0530153 enum qca_btsoc_type soc_type, struct qca_btsoc_version ver,
Rocky Liao99c905c2019-06-06 17:40:30 +0800154 const char *firmware_name);
Venkata Lakshmi Narayana Gubba059924f2020-11-19 18:24:09 +0530155int qca_read_soc_version(struct hci_dev *hdev, struct qca_btsoc_version *ver,
Balakrishna Godavarthi7d250a02019-11-06 15:18:32 +0530156 enum qca_btsoc_type);
Balakrishna Godavarthi5c0a10012019-01-16 18:01:15 +0530157int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr);
Harish Bandia2780882019-07-12 10:39:40 +0530158int qca_send_pre_shutdown_cmd(struct hci_dev *hdev);
Harish Bandi523760b2019-04-26 19:26:01 +0530159static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type)
160{
Balakrishna Godavarthi7d250a02019-11-06 15:18:32 +0530161 return soc_type == QCA_WCN3990 || soc_type == QCA_WCN3991 ||
162 soc_type == QCA_WCN3998;
Harish Bandi523760b2019-04-26 19:26:01 +0530163}
Venkata Lakshmi Narayana Gubbad8f97da2021-05-18 22:04:42 +0530164static inline bool qca_is_wcn6750(enum qca_btsoc_type soc_type)
165{
166 return soc_type == QCA_WCN6750;
167}
168
Ben Young Tae Kim83e81962015-08-10 14:24:12 -0700169#else
170
171static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
172{
173 return -EOPNOTSUPP;
174}
175
Balakrishna Godavarthiaadebac2018-08-03 17:46:28 +0530176static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate,
Venkata Lakshmi Narayana Gubba059924f2020-11-19 18:24:09 +0530177 enum qca_btsoc_type soc_type,
178 struct qca_btsoc_version ver,
Rocky Liao99c905c2019-06-06 17:40:30 +0800179 const char *firmware_name)
Balakrishna Godavarthiba493d42018-08-03 17:46:27 +0530180{
181 return -EOPNOTSUPP;
182}
183
Venkata Lakshmi Narayana Gubba059924f2020-11-19 18:24:09 +0530184static inline int qca_read_soc_version(struct hci_dev *hdev,
185 struct qca_btsoc_version *ver,
Balakrishna Godavarthi7d250a02019-11-06 15:18:32 +0530186 enum qca_btsoc_type)
Ben Young Tae Kim83e81962015-08-10 14:24:12 -0700187{
188 return -EOPNOTSUPP;
189}
190
Balakrishna Godavarthi5c0a10012019-01-16 18:01:15 +0530191static inline int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
192{
193 return -EOPNOTSUPP;
194}
195
Harish Bandi523760b2019-04-26 19:26:01 +0530196static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type)
197{
198 return false;
199}
Harish Bandia2780882019-07-12 10:39:40 +0530200
Venkata Lakshmi Narayana Gubbad8f97da2021-05-18 22:04:42 +0530201static inline bool qca_is_wcn6750(enum qca_btsoc_type soc_type)
202{
203 return false;
204}
205
Harish Bandia2780882019-07-12 10:39:40 +0530206static inline int qca_send_pre_shutdown_cmd(struct hci_dev *hdev)
207{
208 return -EOPNOTSUPP;
209}
Ben Young Tae Kim83e81962015-08-10 14:24:12 -0700210#endif