Thomas Gleixner | 4505153 | 2019-05-29 16:57:47 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Bluetooth supports for Qualcomm Atheros ROME chips |
| 4 | * |
| 5 | * Copyright (c) 2015 The Linux Foundation. All rights reserved. |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #define EDL_PATCH_CMD_OPCODE (0xFC00) |
| 9 | #define EDL_NVM_ACCESS_OPCODE (0xFC0B) |
Balakrishna Godavarthi | 5c0a1001 | 2019-01-16 18:01:15 +0530 | [diff] [blame] | 10 | #define EDL_WRITE_BD_ADDR_OPCODE (0xFC14) |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 11 | #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 Gubba | c0187b0 | 2020-12-08 17:25:29 +0530 | [diff] [blame] | 14 | #define EDL_GET_BUILD_INFO_CMD (0x20) |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 15 | #define EDL_NVM_ACCESS_SET_REQ_CMD (0x01) |
| 16 | #define MAX_SIZE_PER_TLV_SEGMENT (243) |
Harish Bandi | a278088 | 2019-07-12 10:39:40 +0530 | [diff] [blame] | 17 | #define QCA_PRE_SHUTDOWN_CMD (0xFC08) |
Balakrishna Godavarthi | 590decc | 2020-06-12 17:50:28 +0530 | [diff] [blame] | 18 | #define QCA_DISABLE_LOGGING (0xFC17) |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 19 | |
| 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 Godavarthi | 590decc | 2020-06-12 17:50:28 +0530 | [diff] [blame] | 27 | #define QCA_DISABLE_LOGGING_SUB_OP (0x14) |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 28 | |
| 29 | #define EDL_TAG_ID_HCI (17) |
| 30 | #define EDL_TAG_ID_DEEP_SLEEP (27) |
| 31 | |
Balakrishna Godavarthi | fa9ad87 | 2018-08-03 17:46:32 +0530 | [diff] [blame] | 32 | #define QCA_WCN3990_POWERON_PULSE 0xFC |
| 33 | #define QCA_WCN3990_POWEROFF_PULSE 0xC0 |
| 34 | |
Balakrishna Godavarthi | 32646db | 2019-05-28 14:43:22 -0700 | [diff] [blame] | 35 | #define QCA_HCI_CC_OPCODE 0xFC00 |
| 36 | #define QCA_HCI_CC_SUCCESS 0x00 |
| 37 | |
Venkata Lakshmi Narayana Gubba | 059924f | 2020-11-19 18:24:09 +0530 | [diff] [blame] | 38 | #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 Kaehlcke | 75c98a9 | 2019-03-12 16:02:57 -0700 | [diff] [blame] | 50 | enum qca_baudrate { |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 51 | 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 Godavarthi | e303d12 | 2019-11-06 15:18:31 +0530 | [diff] [blame] | 74 | enum 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 Poulain | 6e03126 | 2018-04-26 13:13:27 +0200 | [diff] [blame] | 79 | }; |
| 80 | |
Balakrishna Godavarthi | e303d12 | 2019-11-06 15:18:31 +0530 | [diff] [blame] | 81 | enum qca_tlv_type { |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 82 | TLV_TYPE_PATCH = 1, |
| 83 | TLV_TYPE_NVM |
| 84 | }; |
| 85 | |
Balakrishna Godavarthi | e303d12 | 2019-11-06 15:18:31 +0530 | [diff] [blame] | 86 | struct qca_fw_config { |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 87 | u8 type; |
| 88 | char fwname[64]; |
| 89 | uint8_t user_baud_rate; |
Balakrishna Godavarthi | e303d12 | 2019-11-06 15:18:31 +0530 | [diff] [blame] | 90 | enum qca_tlv_dnld_mode dnld_mode; |
| 91 | enum qca_tlv_dnld_mode dnld_type; |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | struct edl_event_hdr { |
| 95 | __u8 cresp; |
| 96 | __u8 rtype; |
Gustavo A. R. Silva | a7e4545 | 2020-02-26 17:02:27 -0600 | [diff] [blame] | 97 | __u8 data[]; |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 98 | } __packed; |
| 99 | |
Balakrishna Godavarthi | e303d12 | 2019-11-06 15:18:31 +0530 | [diff] [blame] | 100 | struct qca_btsoc_version { |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 101 | __le32 product_id; |
| 102 | __le16 patch_ver; |
Balakrishna Godavarthi | e303d12 | 2019-11-06 15:18:31 +0530 | [diff] [blame] | 103 | __le16 rom_ver; |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 104 | __le32 soc_id; |
| 105 | } __packed; |
| 106 | |
| 107 | struct tlv_seg_resp { |
| 108 | __u8 result; |
| 109 | } __packed; |
| 110 | |
| 111 | struct tlv_type_patch { |
| 112 | __le32 total_size; |
| 113 | __le32 data_length; |
| 114 | __u8 format_version; |
| 115 | __u8 signature; |
Loic Poulain | 6e03126 | 2018-04-26 13:13:27 +0200 | [diff] [blame] | 116 | __u8 download_mode; |
| 117 | __u8 reserved1; |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 118 | __le16 product_id; |
| 119 | __le16 rom_build; |
| 120 | __le16 patch_version; |
| 121 | __le16 reserved2; |
| 122 | __le32 entry; |
| 123 | } __packed; |
| 124 | |
| 125 | struct tlv_type_nvm { |
| 126 | __le16 tag_id; |
| 127 | __le16 tag_len; |
| 128 | __le32 reserve1; |
| 129 | __le32 reserve2; |
Gustavo A. R. Silva | a7e4545 | 2020-02-26 17:02:27 -0600 | [diff] [blame] | 130 | __u8 data[]; |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 131 | } __packed; |
| 132 | |
| 133 | struct tlv_type_hdr { |
| 134 | __le32 type_len; |
Gustavo A. R. Silva | a7e4545 | 2020-02-26 17:02:27 -0600 | [diff] [blame] | 135 | __u8 data[]; |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 136 | } __packed; |
| 137 | |
Balakrishna Godavarthi | aadebac | 2018-08-03 17:46:28 +0530 | [diff] [blame] | 138 | enum qca_btsoc_type { |
| 139 | QCA_INVALID = -1, |
| 140 | QCA_AR3002, |
| 141 | QCA_ROME, |
Harish Bandi | 523760b | 2019-04-26 19:26:01 +0530 | [diff] [blame] | 142 | QCA_WCN3990, |
| 143 | QCA_WCN3998, |
Rocky Liao | e5d6468 | 2020-03-25 10:26:37 +0800 | [diff] [blame] | 144 | QCA_WCN3991, |
| 145 | QCA_QCA6390, |
Venkata Lakshmi Narayana Gubba | d8f97da | 2021-05-18 22:04:42 +0530 | [diff] [blame^] | 146 | QCA_WCN6750, |
Balakrishna Godavarthi | aadebac | 2018-08-03 17:46:28 +0530 | [diff] [blame] | 147 | }; |
| 148 | |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 149 | #if IS_ENABLED(CONFIG_BT_QCA) |
| 150 | |
| 151 | int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr); |
Balakrishna Godavarthi | aadebac | 2018-08-03 17:46:28 +0530 | [diff] [blame] | 152 | int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, |
Venkata Lakshmi Narayana Gubba | 059924f | 2020-11-19 18:24:09 +0530 | [diff] [blame] | 153 | enum qca_btsoc_type soc_type, struct qca_btsoc_version ver, |
Rocky Liao | 99c905c | 2019-06-06 17:40:30 +0800 | [diff] [blame] | 154 | const char *firmware_name); |
Venkata Lakshmi Narayana Gubba | 059924f | 2020-11-19 18:24:09 +0530 | [diff] [blame] | 155 | int qca_read_soc_version(struct hci_dev *hdev, struct qca_btsoc_version *ver, |
Balakrishna Godavarthi | 7d250a0 | 2019-11-06 15:18:32 +0530 | [diff] [blame] | 156 | enum qca_btsoc_type); |
Balakrishna Godavarthi | 5c0a1001 | 2019-01-16 18:01:15 +0530 | [diff] [blame] | 157 | int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr); |
Harish Bandi | a278088 | 2019-07-12 10:39:40 +0530 | [diff] [blame] | 158 | int qca_send_pre_shutdown_cmd(struct hci_dev *hdev); |
Harish Bandi | 523760b | 2019-04-26 19:26:01 +0530 | [diff] [blame] | 159 | static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type) |
| 160 | { |
Balakrishna Godavarthi | 7d250a0 | 2019-11-06 15:18:32 +0530 | [diff] [blame] | 161 | return soc_type == QCA_WCN3990 || soc_type == QCA_WCN3991 || |
| 162 | soc_type == QCA_WCN3998; |
Harish Bandi | 523760b | 2019-04-26 19:26:01 +0530 | [diff] [blame] | 163 | } |
Venkata Lakshmi Narayana Gubba | d8f97da | 2021-05-18 22:04:42 +0530 | [diff] [blame^] | 164 | static inline bool qca_is_wcn6750(enum qca_btsoc_type soc_type) |
| 165 | { |
| 166 | return soc_type == QCA_WCN6750; |
| 167 | } |
| 168 | |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 169 | #else |
| 170 | |
| 171 | static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr) |
| 172 | { |
| 173 | return -EOPNOTSUPP; |
| 174 | } |
| 175 | |
Balakrishna Godavarthi | aadebac | 2018-08-03 17:46:28 +0530 | [diff] [blame] | 176 | static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, |
Venkata Lakshmi Narayana Gubba | 059924f | 2020-11-19 18:24:09 +0530 | [diff] [blame] | 177 | enum qca_btsoc_type soc_type, |
| 178 | struct qca_btsoc_version ver, |
Rocky Liao | 99c905c | 2019-06-06 17:40:30 +0800 | [diff] [blame] | 179 | const char *firmware_name) |
Balakrishna Godavarthi | ba493d4 | 2018-08-03 17:46:27 +0530 | [diff] [blame] | 180 | { |
| 181 | return -EOPNOTSUPP; |
| 182 | } |
| 183 | |
Venkata Lakshmi Narayana Gubba | 059924f | 2020-11-19 18:24:09 +0530 | [diff] [blame] | 184 | static inline int qca_read_soc_version(struct hci_dev *hdev, |
| 185 | struct qca_btsoc_version *ver, |
Balakrishna Godavarthi | 7d250a0 | 2019-11-06 15:18:32 +0530 | [diff] [blame] | 186 | enum qca_btsoc_type) |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 187 | { |
| 188 | return -EOPNOTSUPP; |
| 189 | } |
| 190 | |
Balakrishna Godavarthi | 5c0a1001 | 2019-01-16 18:01:15 +0530 | [diff] [blame] | 191 | static inline int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) |
| 192 | { |
| 193 | return -EOPNOTSUPP; |
| 194 | } |
| 195 | |
Harish Bandi | 523760b | 2019-04-26 19:26:01 +0530 | [diff] [blame] | 196 | static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type) |
| 197 | { |
| 198 | return false; |
| 199 | } |
Harish Bandi | a278088 | 2019-07-12 10:39:40 +0530 | [diff] [blame] | 200 | |
Venkata Lakshmi Narayana Gubba | d8f97da | 2021-05-18 22:04:42 +0530 | [diff] [blame^] | 201 | static inline bool qca_is_wcn6750(enum qca_btsoc_type soc_type) |
| 202 | { |
| 203 | return false; |
| 204 | } |
| 205 | |
Harish Bandi | a278088 | 2019-07-12 10:39:40 +0530 | [diff] [blame] | 206 | static inline int qca_send_pre_shutdown_cmd(struct hci_dev *hdev) |
| 207 | { |
| 208 | return -EOPNOTSUPP; |
| 209 | } |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 210 | #endif |