Yuanyuan Liu | 5cd732a | 2017-02-09 10:42:01 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. |
Yuanyuan Liu | 607051c | 2016-11-28 17:04:13 -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 | #ifndef _ICNSS_WLAN_H_ |
| 13 | #define _ICNSS_WLAN_H_ |
| 14 | |
| 15 | #include <linux/interrupt.h> |
| 16 | |
| 17 | #define ICNSS_MAX_IRQ_REGISTRATIONS 12 |
| 18 | #define ICNSS_MAX_TIMESTAMP_LEN 32 |
| 19 | |
Yuanyuan Liu | 6893976 | 2017-04-04 16:43:03 -0700 | [diff] [blame] | 20 | enum icnss_uevent { |
| 21 | ICNSS_UEVENT_FW_READY, |
| 22 | ICNSS_UEVENT_FW_CRASHED, |
| 23 | ICNSS_UEVENT_FW_DOWN, |
| 24 | }; |
| 25 | |
| 26 | struct icnss_uevent_fw_down_data { |
| 27 | bool crashed; |
| 28 | }; |
| 29 | |
| 30 | struct icnss_uevent_data { |
| 31 | enum icnss_uevent uevent; |
| 32 | void *data; |
| 33 | }; |
| 34 | |
Yuanyuan Liu | 607051c | 2016-11-28 17:04:13 -0800 | [diff] [blame] | 35 | struct icnss_driver_ops { |
| 36 | char *name; |
| 37 | int (*probe)(struct device *dev); |
| 38 | void (*remove)(struct device *dev); |
| 39 | void (*shutdown)(struct device *dev); |
| 40 | int (*reinit)(struct device *dev); |
| 41 | void (*crash_shutdown)(void *pdev); |
| 42 | int (*pm_suspend)(struct device *dev); |
| 43 | int (*pm_resume)(struct device *dev); |
| 44 | int (*suspend_noirq)(struct device *dev); |
| 45 | int (*resume_noirq)(struct device *dev); |
Yuanyuan Liu | 6893976 | 2017-04-04 16:43:03 -0700 | [diff] [blame] | 46 | int (*uevent)(struct device *dev, struct icnss_uevent_data *uevent); |
Yuanyuan Liu | 607051c | 2016-11-28 17:04:13 -0800 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | |
| 50 | struct ce_tgt_pipe_cfg { |
| 51 | u32 pipe_num; |
| 52 | u32 pipe_dir; |
| 53 | u32 nentries; |
| 54 | u32 nbytes_max; |
| 55 | u32 flags; |
| 56 | u32 reserved; |
| 57 | }; |
| 58 | |
| 59 | struct ce_svc_pipe_cfg { |
| 60 | u32 service_id; |
| 61 | u32 pipe_dir; |
| 62 | u32 pipe_num; |
| 63 | }; |
| 64 | |
| 65 | struct icnss_shadow_reg_cfg { |
| 66 | u16 ce_id; |
| 67 | u16 reg_offset; |
| 68 | }; |
| 69 | |
| 70 | /* CE configuration to target */ |
| 71 | struct icnss_wlan_enable_cfg { |
| 72 | u32 num_ce_tgt_cfg; |
| 73 | struct ce_tgt_pipe_cfg *ce_tgt_cfg; |
| 74 | u32 num_ce_svc_pipe_cfg; |
| 75 | struct ce_svc_pipe_cfg *ce_svc_cfg; |
| 76 | u32 num_shadow_reg_cfg; |
| 77 | struct icnss_shadow_reg_cfg *shadow_reg_cfg; |
| 78 | }; |
| 79 | |
Yuanyuan Liu | 607051c | 2016-11-28 17:04:13 -0800 | [diff] [blame] | 80 | /* driver modes */ |
| 81 | enum icnss_driver_mode { |
| 82 | ICNSS_MISSION, |
| 83 | ICNSS_FTM, |
| 84 | ICNSS_EPPING, |
| 85 | ICNSS_WALTEST, |
| 86 | ICNSS_OFF, |
| 87 | ICNSS_CCPM, |
| 88 | ICNSS_QVIT, |
| 89 | }; |
| 90 | |
| 91 | struct icnss_soc_info { |
| 92 | void __iomem *v_addr; |
| 93 | phys_addr_t p_addr; |
| 94 | uint32_t chip_id; |
| 95 | uint32_t chip_family; |
| 96 | uint32_t board_id; |
| 97 | uint32_t soc_id; |
| 98 | uint32_t fw_version; |
| 99 | char fw_build_timestamp[ICNSS_MAX_TIMESTAMP_LEN + 1]; |
| 100 | }; |
| 101 | |
| 102 | extern int icnss_register_driver(struct icnss_driver_ops *driver); |
| 103 | extern int icnss_unregister_driver(struct icnss_driver_ops *driver); |
| 104 | extern int icnss_wlan_enable(struct icnss_wlan_enable_cfg *config, |
| 105 | enum icnss_driver_mode mode, |
| 106 | const char *host_version); |
| 107 | extern int icnss_wlan_disable(enum icnss_driver_mode mode); |
| 108 | extern void icnss_enable_irq(unsigned int ce_id); |
| 109 | extern void icnss_disable_irq(unsigned int ce_id); |
| 110 | extern int icnss_get_soc_info(struct icnss_soc_info *info); |
| 111 | extern int icnss_ce_free_irq(unsigned int ce_id, void *ctx); |
| 112 | extern int icnss_ce_request_irq(unsigned int ce_id, |
| 113 | irqreturn_t (*handler)(int, void *), |
| 114 | unsigned long flags, const char *name, void *ctx); |
| 115 | extern int icnss_get_ce_id(int irq); |
Yuanyuan Liu | 5cd732a | 2017-02-09 10:42:01 -0800 | [diff] [blame] | 116 | extern int icnss_set_fw_log_mode(uint8_t fw_log_mode); |
Yuanyuan Liu | 607051c | 2016-11-28 17:04:13 -0800 | [diff] [blame] | 117 | extern int icnss_athdiag_read(struct device *dev, uint32_t offset, |
| 118 | uint32_t mem_type, uint32_t data_len, |
| 119 | uint8_t *output); |
| 120 | extern int icnss_athdiag_write(struct device *dev, uint32_t offset, |
| 121 | uint32_t mem_type, uint32_t data_len, |
| 122 | uint8_t *input); |
| 123 | extern int icnss_get_irq(int ce_id); |
| 124 | extern int icnss_power_on(struct device *dev); |
| 125 | extern int icnss_power_off(struct device *dev); |
| 126 | extern struct dma_iommu_mapping *icnss_smmu_get_mapping(struct device *dev); |
| 127 | extern int icnss_smmu_map(struct device *dev, phys_addr_t paddr, |
| 128 | uint32_t *iova_addr, size_t size); |
| 129 | extern unsigned int icnss_socinfo_get_serial_number(struct device *dev); |
Yuanyuan Liu | 607051c | 2016-11-28 17:04:13 -0800 | [diff] [blame] | 130 | extern bool icnss_is_qmi_disable(void); |
Yuanyuan Liu | 5cd732a | 2017-02-09 10:42:01 -0800 | [diff] [blame] | 131 | extern bool icnss_is_fw_ready(void); |
Yuanyuan Liu | 5cd732a | 2017-02-09 10:42:01 -0800 | [diff] [blame] | 132 | extern int icnss_trigger_recovery(struct device *dev); |
Yuanyuan Liu | 607051c | 2016-11-28 17:04:13 -0800 | [diff] [blame] | 133 | #endif /* _ICNSS_WLAN_H_ */ |