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) |
| 14 | #define EDL_NVM_ACCESS_SET_REQ_CMD (0x01) |
| 15 | #define MAX_SIZE_PER_TLV_SEGMENT (243) |
Harish Bandi | a278088 | 2019-07-12 10:39:40 +0530 | [diff] [blame] | 16 | #define QCA_PRE_SHUTDOWN_CMD (0xFC08) |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 17 | |
| 18 | #define EDL_CMD_REQ_RES_EVT (0x00) |
| 19 | #define EDL_PATCH_VER_RES_EVT (0x19) |
| 20 | #define EDL_APP_VER_RES_EVT (0x02) |
| 21 | #define EDL_TVL_DNLD_RES_EVT (0x04) |
| 22 | #define EDL_CMD_EXE_STATUS_EVT (0x00) |
| 23 | #define EDL_SET_BAUDRATE_RSP_EVT (0x92) |
| 24 | #define EDL_NVM_ACCESS_CODE_EVT (0x0B) |
| 25 | |
| 26 | #define EDL_TAG_ID_HCI (17) |
| 27 | #define EDL_TAG_ID_DEEP_SLEEP (27) |
| 28 | |
Balakrishna Godavarthi | fa9ad87 | 2018-08-03 17:46:32 +0530 | [diff] [blame] | 29 | #define QCA_WCN3990_POWERON_PULSE 0xFC |
| 30 | #define QCA_WCN3990_POWEROFF_PULSE 0xC0 |
| 31 | |
Balakrishna Godavarthi | 32646db | 2019-05-28 14:43:22 -0700 | [diff] [blame] | 32 | #define QCA_HCI_CC_OPCODE 0xFC00 |
| 33 | #define QCA_HCI_CC_SUCCESS 0x00 |
| 34 | |
Matthias Kaehlcke | 75c98a9 | 2019-03-12 16:02:57 -0700 | [diff] [blame] | 35 | enum qca_baudrate { |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 36 | QCA_BAUDRATE_115200 = 0, |
| 37 | QCA_BAUDRATE_57600, |
| 38 | QCA_BAUDRATE_38400, |
| 39 | QCA_BAUDRATE_19200, |
| 40 | QCA_BAUDRATE_9600, |
| 41 | QCA_BAUDRATE_230400, |
| 42 | QCA_BAUDRATE_250000, |
| 43 | QCA_BAUDRATE_460800, |
| 44 | QCA_BAUDRATE_500000, |
| 45 | QCA_BAUDRATE_720000, |
| 46 | QCA_BAUDRATE_921600, |
| 47 | QCA_BAUDRATE_1000000, |
| 48 | QCA_BAUDRATE_1250000, |
| 49 | QCA_BAUDRATE_2000000, |
| 50 | QCA_BAUDRATE_3000000, |
| 51 | QCA_BAUDRATE_4000000, |
| 52 | QCA_BAUDRATE_1600000, |
| 53 | QCA_BAUDRATE_3200000, |
| 54 | QCA_BAUDRATE_3500000, |
| 55 | QCA_BAUDRATE_AUTO = 0xFE, |
| 56 | QCA_BAUDRATE_RESERVED |
| 57 | }; |
| 58 | |
Balakrishna Godavarthi | e303d12 | 2019-11-06 15:18:31 +0530 | [diff] [blame] | 59 | enum qca_tlv_dnld_mode { |
| 60 | QCA_SKIP_EVT_NONE, |
| 61 | QCA_SKIP_EVT_VSE, |
| 62 | QCA_SKIP_EVT_CC, |
| 63 | QCA_SKIP_EVT_VSE_CC |
Loic Poulain | 6e03126 | 2018-04-26 13:13:27 +0200 | [diff] [blame] | 64 | }; |
| 65 | |
Balakrishna Godavarthi | e303d12 | 2019-11-06 15:18:31 +0530 | [diff] [blame] | 66 | enum qca_tlv_type { |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 67 | TLV_TYPE_PATCH = 1, |
| 68 | TLV_TYPE_NVM |
| 69 | }; |
| 70 | |
Balakrishna Godavarthi | e303d12 | 2019-11-06 15:18:31 +0530 | [diff] [blame] | 71 | struct qca_fw_config { |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 72 | u8 type; |
| 73 | char fwname[64]; |
| 74 | uint8_t user_baud_rate; |
Balakrishna Godavarthi | e303d12 | 2019-11-06 15:18:31 +0530 | [diff] [blame] | 75 | enum qca_tlv_dnld_mode dnld_mode; |
| 76 | enum qca_tlv_dnld_mode dnld_type; |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | struct edl_event_hdr { |
| 80 | __u8 cresp; |
| 81 | __u8 rtype; |
| 82 | __u8 data[0]; |
| 83 | } __packed; |
| 84 | |
Balakrishna Godavarthi | e303d12 | 2019-11-06 15:18:31 +0530 | [diff] [blame] | 85 | struct qca_btsoc_version { |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 86 | __le32 product_id; |
| 87 | __le16 patch_ver; |
Balakrishna Godavarthi | e303d12 | 2019-11-06 15:18:31 +0530 | [diff] [blame] | 88 | __le16 rom_ver; |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 89 | __le32 soc_id; |
| 90 | } __packed; |
| 91 | |
| 92 | struct tlv_seg_resp { |
| 93 | __u8 result; |
| 94 | } __packed; |
| 95 | |
| 96 | struct tlv_type_patch { |
| 97 | __le32 total_size; |
| 98 | __le32 data_length; |
| 99 | __u8 format_version; |
| 100 | __u8 signature; |
Loic Poulain | 6e03126 | 2018-04-26 13:13:27 +0200 | [diff] [blame] | 101 | __u8 download_mode; |
| 102 | __u8 reserved1; |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 103 | __le16 product_id; |
| 104 | __le16 rom_build; |
| 105 | __le16 patch_version; |
| 106 | __le16 reserved2; |
| 107 | __le32 entry; |
| 108 | } __packed; |
| 109 | |
| 110 | struct tlv_type_nvm { |
| 111 | __le16 tag_id; |
| 112 | __le16 tag_len; |
| 113 | __le32 reserve1; |
| 114 | __le32 reserve2; |
| 115 | __u8 data[0]; |
| 116 | } __packed; |
| 117 | |
| 118 | struct tlv_type_hdr { |
| 119 | __le32 type_len; |
| 120 | __u8 data[0]; |
| 121 | } __packed; |
| 122 | |
Balakrishna Godavarthi | aadebac | 2018-08-03 17:46:28 +0530 | [diff] [blame] | 123 | enum qca_btsoc_type { |
| 124 | QCA_INVALID = -1, |
| 125 | QCA_AR3002, |
| 126 | QCA_ROME, |
Harish Bandi | 523760b | 2019-04-26 19:26:01 +0530 | [diff] [blame] | 127 | QCA_WCN3990, |
Balakrishna Godavarthi | 7d250a0 | 2019-11-06 15:18:32 +0530 | [diff] [blame] | 128 | QCA_WCN3991, |
Harish Bandi | 523760b | 2019-04-26 19:26:01 +0530 | [diff] [blame] | 129 | QCA_WCN3998, |
Balakrishna Godavarthi | aadebac | 2018-08-03 17:46:28 +0530 | [diff] [blame] | 130 | }; |
| 131 | |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 132 | #if IS_ENABLED(CONFIG_BT_QCA) |
| 133 | |
| 134 | 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] | 135 | int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, |
Rocky Liao | 99c905c | 2019-06-06 17:40:30 +0800 | [diff] [blame] | 136 | enum qca_btsoc_type soc_type, u32 soc_ver, |
| 137 | const char *firmware_name); |
Balakrishna Godavarthi | 7d250a0 | 2019-11-06 15:18:32 +0530 | [diff] [blame] | 138 | int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, |
| 139 | enum qca_btsoc_type); |
Balakrishna Godavarthi | 5c0a1001 | 2019-01-16 18:01:15 +0530 | [diff] [blame] | 140 | int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr); |
Harish Bandi | a278088 | 2019-07-12 10:39:40 +0530 | [diff] [blame] | 141 | int qca_send_pre_shutdown_cmd(struct hci_dev *hdev); |
Harish Bandi | 523760b | 2019-04-26 19:26:01 +0530 | [diff] [blame] | 142 | static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type) |
| 143 | { |
Balakrishna Godavarthi | 7d250a0 | 2019-11-06 15:18:32 +0530 | [diff] [blame] | 144 | return soc_type == QCA_WCN3990 || soc_type == QCA_WCN3991 || |
| 145 | soc_type == QCA_WCN3998; |
Harish Bandi | 523760b | 2019-04-26 19:26:01 +0530 | [diff] [blame] | 146 | } |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 147 | #else |
| 148 | |
| 149 | static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr) |
| 150 | { |
| 151 | return -EOPNOTSUPP; |
| 152 | } |
| 153 | |
Balakrishna Godavarthi | aadebac | 2018-08-03 17:46:28 +0530 | [diff] [blame] | 154 | static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, |
Rocky Liao | 99c905c | 2019-06-06 17:40:30 +0800 | [diff] [blame] | 155 | enum qca_btsoc_type soc_type, u32 soc_ver, |
| 156 | const char *firmware_name) |
Balakrishna Godavarthi | ba493d4 | 2018-08-03 17:46:27 +0530 | [diff] [blame] | 157 | { |
| 158 | return -EOPNOTSUPP; |
| 159 | } |
| 160 | |
Balakrishna Godavarthi | 7d250a0 | 2019-11-06 15:18:32 +0530 | [diff] [blame] | 161 | static inline int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, |
| 162 | enum qca_btsoc_type) |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 163 | { |
| 164 | return -EOPNOTSUPP; |
| 165 | } |
| 166 | |
Balakrishna Godavarthi | 5c0a1001 | 2019-01-16 18:01:15 +0530 | [diff] [blame] | 167 | static inline int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr) |
| 168 | { |
| 169 | return -EOPNOTSUPP; |
| 170 | } |
| 171 | |
Harish Bandi | 523760b | 2019-04-26 19:26:01 +0530 | [diff] [blame] | 172 | static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type) |
| 173 | { |
| 174 | return false; |
| 175 | } |
Harish Bandi | a278088 | 2019-07-12 10:39:40 +0530 | [diff] [blame] | 176 | |
| 177 | static inline int qca_send_pre_shutdown_cmd(struct hci_dev *hdev) |
| 178 | { |
| 179 | return -EOPNOTSUPP; |
| 180 | } |
Ben Young Tae Kim | 83e8196 | 2015-08-10 14:24:12 -0700 | [diff] [blame] | 181 | #endif |