summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/ath/ath10k/snoc.h
blob: a02cb2ad928e87124db6489b816685615f29db7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef _SNOC_H_
#define _SNOC_H_

#include "hw.h"
#include "ce.h"
#include "pci.h"
#include "qmi.h"
#include <linux/kernel.h>
#include <soc/qcom/service-locator.h>
#define ATH10K_SNOC_RX_POST_RETRY_MS 50
#define CE_POLL_PIPE 4
#define ATH10K_SERVICE_LOCATION_CLIENT_NAME			"ATH10K-WLAN"
#define ATH10K_WLAN_SERVICE_NAME					"wlan/fw"

/* struct snoc_state: SNOC target state
 * @pipe_cfg_addr: pipe configuration address
 * @svc_to_pipe_map: pipe services
 */
struct snoc_state {
	u32 pipe_cfg_addr;
	u32 svc_to_pipe_map;
};

/* struct ath10k_snoc_pipe: SNOC pipe configuration
 * @ath10k_ce_pipe: pipe handle
 * @pipe_num: pipe number
 * @hif_ce_state: pointer to ce state
 * @buf_sz: buffer size
 * @pipe_lock: pipe lock
 * @ar_snoc: snoc private structure
 */

struct ath10k_snoc_pipe {
	struct ath10k_ce_pipe *ce_hdl;
	u8 pipe_num;
	struct ath10k *hif_ce_state;
	size_t buf_sz;
	/* protect ce info */
	spinlock_t pipe_lock;
	struct ath10k_snoc *ar_snoc;
};

/* struct ath10k_snoc_supp_chip: supported chip set
 * @dev_id: device id
 * @rev_id: revison id
 */
struct ath10k_snoc_supp_chip {
	u32 dev_id;
	u32 rev_id;
};

/* struct ath10k_snoc_info: SNOC info struct
 * @v_addr: base virtual address
 * @p_addr: base physical address
 * @chip_id: chip id
 * @chip_family: chip family
 * @board_id: board id
 * @soc_id: soc id
 * @fw_version: fw version
 */
struct ath10k_snoc_info {
	void __iomem *v_addr;
	phys_addr_t p_addr;
	u32 chip_id;
	u32 chip_family;
	u32 board_id;
	u32 soc_id;
	u32 fw_version;
};

/* struct ath10k_target_info: SNOC target info
 * @target_version: target version
 * @target_type: target type
 * @target_revision: target revision
 * @soc_version: target soc version
 */
struct ath10k_target_info {
	u32 target_version;
	u32 target_type;
	u32 target_revision;
	u32 soc_version;
};

/* struct ath10k_service_notifier_context: service notification context
 * @handle: notifier handle
 * @instance_id: domain instance id
 * @name: domain name
 */
struct ath10k_service_notifier_context {
	void *handle;
	u32 instance_id;
	char name[QMI_SERVREG_LOC_NAME_LENGTH_V01 + 1];
};

/* struct ath10k_snoc_ce_irq: copy engine irq struct
 * @irq_req_stat: irq request status
 * @irq_line: irq line
 */
struct ath10k_snoc_ce_irq {
	atomic_t irq_req_stat;
	u32 irq_line;
};

struct ath10k_wcn3990_vreg_info {
	struct regulator *reg;
	const char *name;
	u32 min_v;
	u32 max_v;
	u32 load_ua;
	unsigned long settle_delay;
	bool required;
};

struct ath10k_wcn3990_clk_info {
	struct clk *handle;
	const char *name;
	u32 freq;
	bool required;
};

static struct ath10k_wcn3990_vreg_info vreg_cfg[] = {
	{NULL, "vdd-0.8-cx-mx", 800000, 800000, 0, 0, false},
	{NULL, "vdd-1.8-xo", 1800000, 1800000, 0, 0, false},
	{NULL, "vdd-1.3-rfa", 1304000, 1304000, 0, 0, false},
	{NULL, "vdd-3.3-ch0", 3312000, 3312000, 0, 0, false},
};

#define ATH10K_WCN3990_VREG_INFO_SIZE		ARRAY_SIZE(vreg_cfg)

static struct ath10k_wcn3990_clk_info clk_cfg[] = {
	{NULL, "cxo_ref_clk_pin", 0, false},
};

#define ATH10K_WCN3990_CLK_INFO_SIZE		ARRAY_SIZE(clk_cfg)

/* struct ath10k_snoc: SNOC info struct
 * @dev: device structure
 * @ar:ath10k base structure
 * @mem: mem base virtual address
 * @mem_pa: mem base physical address
 * @target_info: snoc target info
 * @mem_len: mempry map length
 * @pipe_info: pipe info struct
 * @ce_irqs: copy engine irq list
 * @ce_lock: protect ce structures
 * @ce_states: maps ce id to ce state
 * @rx_post_retry: rx buffer post processing timer
 * @vaddr_rri_on_ddr: virtual address for RRI
 * @is_driver_probed: flag to indicate driver state
 * @modem_ssr_nb: notifier callback for modem notification
 * @modem_notify_handler: modem notification handler
 * @service_notifier: notifier context for service notification
 * @service_notifier_nb: notifier callback for service notification
 * @total_domains: no of service domains
 * @get_service_nb: notifier callback for service discovery
 * @fw_crashed: fw state flag
 */
struct ath10k_snoc {
	struct bus_opaque opaque_ctx;
	struct platform_device *dev;
	struct ath10k *ar;
	void __iomem *mem;
	dma_addr_t mem_pa;
	struct ath10k_target_info target_info;
	size_t mem_len;
	struct ath10k_snoc_pipe pipe_info[CE_COUNT_MAX];
	struct timer_list rx_post_retry;
	struct ath10k_snoc_ce_irq ce_irqs[CE_COUNT_MAX];
	u32 *vaddr_rri_on_ddr;
	bool is_driver_probed;
	struct notifier_block modem_ssr_nb;
	struct notifier_block pm_notifier;
	void *modem_notify_handler;
	struct ath10k_service_notifier_context *service_notifier;
	struct notifier_block service_notifier_nb;
	int total_domains;
	struct notifier_block get_service_nb;
	atomic_t fw_crashed;
	atomic_t pm_ops_inprogress;
	struct ath10k_snoc_qmi_config qmi_cfg;
	struct ath10k_wcn3990_vreg_info vreg[ATH10K_WCN3990_VREG_INFO_SIZE];
	struct ath10k_wcn3990_clk_info clk[ATH10K_WCN3990_CLK_INFO_SIZE];
};

struct ath10k_event_pd_down_data {
	bool crashed;
	bool fw_rejuvenate;
};

static inline struct ath10k_snoc *ath10k_snoc_priv(struct ath10k *ar)
{
	return (struct ath10k_snoc *)ar->drv_priv;
}

void ath10k_snoc_write32(struct ath10k *ar, u32 offset, u32 value);
void ath10k_snoc_soc_write32(struct ath10k *ar, u32 addr, u32 val);
void ath10k_snoc_reg_write32(struct ath10k *ar, u32 addr, u32 val);
u32 ath10k_snoc_read32(struct ath10k *ar, u32 offset);
u32 ath10k_snoc_soc_read32(struct ath10k *ar, u32 addr);
u32 ath10k_snoc_reg_read32(struct ath10k *ar, u32 addr);

#endif /* _SNOC_H_ */