Yue Ma | 8bead6d | 2018-02-01 12:25:47 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. |
Yue Ma | 0317e4a | 2018-01-10 11:48:32 -0800 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef _NET_CNSS2_H |
| 14 | #define _NET_CNSS2_H |
| 15 | |
| 16 | #include <linux/pci.h> |
| 17 | |
| 18 | #define CNSS_MAX_FILE_NAME 20 |
| 19 | #define CNSS_MAX_TIMESTAMP_LEN 32 |
| 20 | |
| 21 | /* |
| 22 | * Temporary change for compilation, will be removed |
| 23 | * after WLAN host driver switched to use new APIs |
| 24 | */ |
| 25 | #define CNSS_API_WITH_DEV |
| 26 | |
| 27 | enum cnss_bus_width_type { |
| 28 | CNSS_BUS_WIDTH_NONE, |
| 29 | CNSS_BUS_WIDTH_LOW, |
| 30 | CNSS_BUS_WIDTH_MEDIUM, |
| 31 | CNSS_BUS_WIDTH_HIGH |
| 32 | }; |
| 33 | |
| 34 | enum cnss_platform_cap_flag { |
| 35 | CNSS_HAS_EXTERNAL_SWREG = 0x01, |
| 36 | CNSS_HAS_UART_ACCESS = 0x02, |
| 37 | }; |
| 38 | |
| 39 | struct cnss_platform_cap { |
| 40 | u32 cap_flag; |
| 41 | }; |
| 42 | |
| 43 | struct cnss_fw_files { |
| 44 | char image_file[CNSS_MAX_FILE_NAME]; |
| 45 | char board_data[CNSS_MAX_FILE_NAME]; |
| 46 | char otp_data[CNSS_MAX_FILE_NAME]; |
| 47 | char utf_file[CNSS_MAX_FILE_NAME]; |
| 48 | char utf_board_data[CNSS_MAX_FILE_NAME]; |
| 49 | char epping_file[CNSS_MAX_FILE_NAME]; |
| 50 | char evicted_data[CNSS_MAX_FILE_NAME]; |
| 51 | }; |
| 52 | |
| 53 | struct cnss_soc_info { |
| 54 | void __iomem *va; |
| 55 | phys_addr_t pa; |
| 56 | uint32_t chip_id; |
| 57 | uint32_t chip_family; |
| 58 | uint32_t board_id; |
| 59 | uint32_t soc_id; |
| 60 | uint32_t fw_version; |
| 61 | char fw_build_timestamp[CNSS_MAX_TIMESTAMP_LEN + 1]; |
| 62 | }; |
| 63 | |
| 64 | struct cnss_wlan_runtime_ops { |
| 65 | int (*runtime_suspend)(struct pci_dev *pdev); |
| 66 | int (*runtime_resume)(struct pci_dev *pdev); |
| 67 | }; |
| 68 | |
| 69 | struct cnss_wlan_driver { |
| 70 | char *name; |
| 71 | int (*probe)(struct pci_dev *pdev, const struct pci_device_id *id); |
| 72 | void (*remove)(struct pci_dev *pdev); |
| 73 | int (*reinit)(struct pci_dev *pdev, const struct pci_device_id *id); |
| 74 | void (*shutdown)(struct pci_dev *pdev); |
| 75 | void (*crash_shutdown)(struct pci_dev *pdev); |
| 76 | int (*suspend)(struct pci_dev *pdev, pm_message_t state); |
| 77 | int (*resume)(struct pci_dev *pdev); |
| 78 | int (*suspend_noirq)(struct pci_dev *pdev); |
| 79 | int (*resume_noirq)(struct pci_dev *pdev); |
| 80 | void (*modem_status)(struct pci_dev *, int state); |
| 81 | void (*update_status)(struct pci_dev *pdev, uint32_t status); |
| 82 | struct cnss_wlan_runtime_ops *runtime_ops; |
| 83 | const struct pci_device_id *id_table; |
| 84 | }; |
| 85 | |
| 86 | enum cnss_driver_status { |
| 87 | CNSS_UNINITIALIZED, |
| 88 | CNSS_INITIALIZED, |
| 89 | CNSS_LOAD_UNLOAD, |
| 90 | CNSS_RECOVERY, |
Yue Ma | 8bead6d | 2018-02-01 12:25:47 -0800 | [diff] [blame] | 91 | CNSS_FW_DOWN, |
Yue Ma | 0317e4a | 2018-01-10 11:48:32 -0800 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | struct cnss_ce_tgt_pipe_cfg { |
| 95 | u32 pipe_num; |
| 96 | u32 pipe_dir; |
| 97 | u32 nentries; |
| 98 | u32 nbytes_max; |
| 99 | u32 flags; |
| 100 | u32 reserved; |
| 101 | }; |
| 102 | |
| 103 | struct cnss_ce_svc_pipe_cfg { |
| 104 | u32 service_id; |
| 105 | u32 pipe_dir; |
| 106 | u32 pipe_num; |
| 107 | }; |
| 108 | |
| 109 | struct cnss_shadow_reg_cfg { |
| 110 | u16 ce_id; |
| 111 | u16 reg_offset; |
| 112 | }; |
| 113 | |
| 114 | struct cnss_shadow_reg_v2_cfg { |
| 115 | u32 addr; |
| 116 | }; |
| 117 | |
| 118 | struct cnss_wlan_enable_cfg { |
| 119 | u32 num_ce_tgt_cfg; |
| 120 | struct cnss_ce_tgt_pipe_cfg *ce_tgt_cfg; |
| 121 | u32 num_ce_svc_pipe_cfg; |
| 122 | struct cnss_ce_svc_pipe_cfg *ce_svc_cfg; |
| 123 | u32 num_shadow_reg_cfg; |
| 124 | struct cnss_shadow_reg_cfg *shadow_reg_cfg; |
| 125 | u32 num_shadow_reg_v2_cfg; |
| 126 | struct cnss_shadow_reg_v2_cfg *shadow_reg_v2_cfg; |
| 127 | }; |
| 128 | |
| 129 | enum cnss_driver_mode { |
| 130 | CNSS_MISSION, |
| 131 | CNSS_FTM, |
| 132 | CNSS_EPPING, |
| 133 | CNSS_WALTEST, |
| 134 | CNSS_OFF, |
| 135 | CNSS_CCPM, |
| 136 | CNSS_QVIT, |
| 137 | CNSS_CALIBRATION, |
| 138 | }; |
| 139 | |
| 140 | enum cnss_recovery_reason { |
| 141 | CNSS_REASON_DEFAULT, |
| 142 | CNSS_REASON_LINK_DOWN, |
| 143 | CNSS_REASON_RDDM, |
| 144 | CNSS_REASON_TIMEOUT, |
| 145 | }; |
| 146 | |
| 147 | extern int cnss_wlan_register_driver(struct cnss_wlan_driver *driver); |
| 148 | extern void cnss_wlan_unregister_driver(struct cnss_wlan_driver *driver); |
| 149 | extern void cnss_device_crashed(struct device *dev); |
| 150 | extern int cnss_pci_link_down(struct device *dev); |
| 151 | extern void cnss_schedule_recovery(struct device *dev, |
| 152 | enum cnss_recovery_reason reason); |
| 153 | extern int cnss_self_recovery(struct device *dev, |
| 154 | enum cnss_recovery_reason reason); |
| 155 | extern int cnss_force_fw_assert(struct device *dev); |
| 156 | extern void *cnss_get_virt_ramdump_mem(struct device *dev, unsigned long *size); |
| 157 | extern int cnss_get_fw_files_for_target(struct device *dev, |
| 158 | struct cnss_fw_files *pfw_files, |
| 159 | u32 target_type, u32 target_version); |
| 160 | extern int cnss_get_platform_cap(struct device *dev, |
| 161 | struct cnss_platform_cap *cap); |
| 162 | extern int cnss_get_soc_info(struct device *dev, struct cnss_soc_info *info); |
| 163 | extern int cnss_request_bus_bandwidth(struct device *dev, int bandwidth); |
| 164 | extern int cnss_power_up(struct device *dev); |
| 165 | extern int cnss_power_down(struct device *dev); |
| 166 | extern void cnss_request_pm_qos(struct device *dev, u32 qos_val); |
| 167 | extern void cnss_remove_pm_qos(struct device *dev); |
| 168 | extern void cnss_lock_pm_sem(struct device *dev); |
| 169 | extern void cnss_release_pm_sem(struct device *dev); |
| 170 | extern int cnss_wlan_pm_control(struct device *dev, bool vote); |
| 171 | extern int cnss_auto_suspend(struct device *dev); |
| 172 | extern int cnss_auto_resume(struct device *dev); |
| 173 | extern int cnss_get_user_msi_assignment(struct device *dev, char *user_name, |
| 174 | int *num_vectors, |
| 175 | uint32_t *user_base_data, |
| 176 | uint32_t *base_vector); |
| 177 | extern int cnss_get_msi_irq(struct device *dev, unsigned int vector); |
| 178 | extern void cnss_get_msi_address(struct device *dev, uint32_t *msi_addr_low, |
| 179 | uint32_t *msi_addr_high); |
| 180 | extern int cnss_wlan_enable(struct device *dev, |
| 181 | struct cnss_wlan_enable_cfg *config, |
| 182 | enum cnss_driver_mode mode, |
| 183 | const char *host_version); |
| 184 | extern int cnss_wlan_disable(struct device *dev, enum cnss_driver_mode mode); |
| 185 | extern unsigned int cnss_get_qmi_timeout(void); |
| 186 | extern int cnss_athdiag_read(struct device *dev, uint32_t offset, |
| 187 | uint32_t mem_type, uint32_t data_len, |
| 188 | uint8_t *output); |
| 189 | extern int cnss_athdiag_write(struct device *dev, uint32_t offset, |
| 190 | uint32_t mem_type, uint32_t data_len, |
| 191 | uint8_t *input); |
| 192 | extern int cnss_set_fw_log_mode(struct device *dev, uint8_t fw_log_mode); |
| 193 | |
| 194 | #endif /* _NET_CNSS2_H */ |