blob: e58a522fc02886113179b0379f24b7a0409db38c [file] [log] [blame]
Yuanyuan Liu5cd732a2017-02-09 10:42:01 -08001/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
Yuanyuan Liu607051c2016-11-28 17:04:13 -08002 *
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 Liu68939762017-04-04 16:43:03 -070020enum icnss_uevent {
21 ICNSS_UEVENT_FW_READY,
22 ICNSS_UEVENT_FW_CRASHED,
23 ICNSS_UEVENT_FW_DOWN,
24};
25
26struct icnss_uevent_fw_down_data {
27 bool crashed;
28};
29
30struct icnss_uevent_data {
31 enum icnss_uevent uevent;
32 void *data;
33};
34
Yuanyuan Liu607051c2016-11-28 17:04:13 -080035struct 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 Liu68939762017-04-04 16:43:03 -070046 int (*uevent)(struct device *dev, struct icnss_uevent_data *uevent);
Yuanyuan Liu607051c2016-11-28 17:04:13 -080047};
48
49
50struct 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
59struct ce_svc_pipe_cfg {
60 u32 service_id;
61 u32 pipe_dir;
62 u32 pipe_num;
63};
64
65struct icnss_shadow_reg_cfg {
66 u16 ce_id;
67 u16 reg_offset;
68};
69
70/* CE configuration to target */
71struct 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 Liu607051c2016-11-28 17:04:13 -080080/* driver modes */
81enum 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
91struct 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
102extern int icnss_register_driver(struct icnss_driver_ops *driver);
103extern int icnss_unregister_driver(struct icnss_driver_ops *driver);
104extern int icnss_wlan_enable(struct icnss_wlan_enable_cfg *config,
105 enum icnss_driver_mode mode,
106 const char *host_version);
107extern int icnss_wlan_disable(enum icnss_driver_mode mode);
108extern void icnss_enable_irq(unsigned int ce_id);
109extern void icnss_disable_irq(unsigned int ce_id);
110extern int icnss_get_soc_info(struct icnss_soc_info *info);
111extern int icnss_ce_free_irq(unsigned int ce_id, void *ctx);
112extern int icnss_ce_request_irq(unsigned int ce_id,
113 irqreturn_t (*handler)(int, void *),
114 unsigned long flags, const char *name, void *ctx);
115extern int icnss_get_ce_id(int irq);
Yuanyuan Liu5cd732a2017-02-09 10:42:01 -0800116extern int icnss_set_fw_log_mode(uint8_t fw_log_mode);
Yuanyuan Liu607051c2016-11-28 17:04:13 -0800117extern int icnss_athdiag_read(struct device *dev, uint32_t offset,
118 uint32_t mem_type, uint32_t data_len,
119 uint8_t *output);
120extern int icnss_athdiag_write(struct device *dev, uint32_t offset,
121 uint32_t mem_type, uint32_t data_len,
122 uint8_t *input);
123extern int icnss_get_irq(int ce_id);
124extern int icnss_power_on(struct device *dev);
125extern int icnss_power_off(struct device *dev);
126extern struct dma_iommu_mapping *icnss_smmu_get_mapping(struct device *dev);
127extern int icnss_smmu_map(struct device *dev, phys_addr_t paddr,
128 uint32_t *iova_addr, size_t size);
129extern unsigned int icnss_socinfo_get_serial_number(struct device *dev);
Yuanyuan Liu607051c2016-11-28 17:04:13 -0800130extern bool icnss_is_qmi_disable(void);
Yuanyuan Liu5cd732a2017-02-09 10:42:01 -0800131extern bool icnss_is_fw_ready(void);
Yuanyuan Liu5cd732a2017-02-09 10:42:01 -0800132extern int icnss_trigger_recovery(struct device *dev);
Yuanyuan Liu607051c2016-11-28 17:04:13 -0800133#endif /* _ICNSS_WLAN_H_ */