1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright (c) 2004-2011 Atheros Communications Inc.
3*4882a593Smuzhiyun * Copyright (c) 2011 Qualcomm Atheros, Inc.
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Permission to use, copy, modify, and/or distribute this software for any
6*4882a593Smuzhiyun * purpose with or without fee is hereby granted, provided that the above
7*4882a593Smuzhiyun * copyright notice and this permission notice appear in all copies.
8*4882a593Smuzhiyun *
9*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*4882a593Smuzhiyun * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*4882a593Smuzhiyun * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*4882a593Smuzhiyun * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*4882a593Smuzhiyun * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*4882a593Smuzhiyun * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*4882a593Smuzhiyun * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*4882a593Smuzhiyun */
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun #ifndef HIF_OPS_H
19*4882a593Smuzhiyun #define HIF_OPS_H
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun #include "hif.h"
22*4882a593Smuzhiyun #include "debug.h"
23*4882a593Smuzhiyun
hif_read_write_sync(struct ath6kl * ar,u32 addr,u8 * buf,u32 len,u32 request)24*4882a593Smuzhiyun static inline int hif_read_write_sync(struct ath6kl *ar, u32 addr, u8 *buf,
25*4882a593Smuzhiyun u32 len, u32 request)
26*4882a593Smuzhiyun {
27*4882a593Smuzhiyun ath6kl_dbg(ATH6KL_DBG_HIF,
28*4882a593Smuzhiyun "hif %s sync addr 0x%x buf 0x%p len %d request 0x%x\n",
29*4882a593Smuzhiyun (request & HIF_WRITE) ? "write" : "read",
30*4882a593Smuzhiyun addr, buf, len, request);
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun return ar->hif_ops->read_write_sync(ar, addr, buf, len, request);
33*4882a593Smuzhiyun }
34*4882a593Smuzhiyun
hif_write_async(struct ath6kl * ar,u32 address,u8 * buffer,u32 length,u32 request,struct htc_packet * packet)35*4882a593Smuzhiyun static inline int hif_write_async(struct ath6kl *ar, u32 address, u8 *buffer,
36*4882a593Smuzhiyun u32 length, u32 request,
37*4882a593Smuzhiyun struct htc_packet *packet)
38*4882a593Smuzhiyun {
39*4882a593Smuzhiyun ath6kl_dbg(ATH6KL_DBG_HIF,
40*4882a593Smuzhiyun "hif write async addr 0x%x buf 0x%p len %d request 0x%x\n",
41*4882a593Smuzhiyun address, buffer, length, request);
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun return ar->hif_ops->write_async(ar, address, buffer, length,
44*4882a593Smuzhiyun request, packet);
45*4882a593Smuzhiyun }
ath6kl_hif_irq_enable(struct ath6kl * ar)46*4882a593Smuzhiyun static inline void ath6kl_hif_irq_enable(struct ath6kl *ar)
47*4882a593Smuzhiyun {
48*4882a593Smuzhiyun ath6kl_dbg(ATH6KL_DBG_HIF, "hif irq enable\n");
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun return ar->hif_ops->irq_enable(ar);
51*4882a593Smuzhiyun }
52*4882a593Smuzhiyun
ath6kl_hif_irq_disable(struct ath6kl * ar)53*4882a593Smuzhiyun static inline void ath6kl_hif_irq_disable(struct ath6kl *ar)
54*4882a593Smuzhiyun {
55*4882a593Smuzhiyun ath6kl_dbg(ATH6KL_DBG_HIF, "hif irq disable\n");
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun return ar->hif_ops->irq_disable(ar);
58*4882a593Smuzhiyun }
59*4882a593Smuzhiyun
hif_scatter_req_get(struct ath6kl * ar)60*4882a593Smuzhiyun static inline struct hif_scatter_req *hif_scatter_req_get(struct ath6kl *ar)
61*4882a593Smuzhiyun {
62*4882a593Smuzhiyun return ar->hif_ops->scatter_req_get(ar);
63*4882a593Smuzhiyun }
64*4882a593Smuzhiyun
hif_scatter_req_add(struct ath6kl * ar,struct hif_scatter_req * s_req)65*4882a593Smuzhiyun static inline void hif_scatter_req_add(struct ath6kl *ar,
66*4882a593Smuzhiyun struct hif_scatter_req *s_req)
67*4882a593Smuzhiyun {
68*4882a593Smuzhiyun return ar->hif_ops->scatter_req_add(ar, s_req);
69*4882a593Smuzhiyun }
70*4882a593Smuzhiyun
ath6kl_hif_enable_scatter(struct ath6kl * ar)71*4882a593Smuzhiyun static inline int ath6kl_hif_enable_scatter(struct ath6kl *ar)
72*4882a593Smuzhiyun {
73*4882a593Smuzhiyun return ar->hif_ops->enable_scatter(ar);
74*4882a593Smuzhiyun }
75*4882a593Smuzhiyun
ath6kl_hif_scat_req_rw(struct ath6kl * ar,struct hif_scatter_req * scat_req)76*4882a593Smuzhiyun static inline int ath6kl_hif_scat_req_rw(struct ath6kl *ar,
77*4882a593Smuzhiyun struct hif_scatter_req *scat_req)
78*4882a593Smuzhiyun {
79*4882a593Smuzhiyun return ar->hif_ops->scat_req_rw(ar, scat_req);
80*4882a593Smuzhiyun }
81*4882a593Smuzhiyun
ath6kl_hif_cleanup_scatter(struct ath6kl * ar)82*4882a593Smuzhiyun static inline void ath6kl_hif_cleanup_scatter(struct ath6kl *ar)
83*4882a593Smuzhiyun {
84*4882a593Smuzhiyun return ar->hif_ops->cleanup_scatter(ar);
85*4882a593Smuzhiyun }
86*4882a593Smuzhiyun
ath6kl_hif_suspend(struct ath6kl * ar,struct cfg80211_wowlan * wow)87*4882a593Smuzhiyun static inline int ath6kl_hif_suspend(struct ath6kl *ar,
88*4882a593Smuzhiyun struct cfg80211_wowlan *wow)
89*4882a593Smuzhiyun {
90*4882a593Smuzhiyun ath6kl_dbg(ATH6KL_DBG_HIF, "hif suspend\n");
91*4882a593Smuzhiyun
92*4882a593Smuzhiyun return ar->hif_ops->suspend(ar, wow);
93*4882a593Smuzhiyun }
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun /*
96*4882a593Smuzhiyun * Read from the ATH6KL through its diagnostic window. No cooperation from
97*4882a593Smuzhiyun * the Target is required for this.
98*4882a593Smuzhiyun */
ath6kl_hif_diag_read32(struct ath6kl * ar,u32 address,u32 * value)99*4882a593Smuzhiyun static inline int ath6kl_hif_diag_read32(struct ath6kl *ar, u32 address,
100*4882a593Smuzhiyun u32 *value)
101*4882a593Smuzhiyun {
102*4882a593Smuzhiyun return ar->hif_ops->diag_read32(ar, address, value);
103*4882a593Smuzhiyun }
104*4882a593Smuzhiyun
105*4882a593Smuzhiyun /*
106*4882a593Smuzhiyun * Write to the ATH6KL through its diagnostic window. No cooperation from
107*4882a593Smuzhiyun * the Target is required for this.
108*4882a593Smuzhiyun */
ath6kl_hif_diag_write32(struct ath6kl * ar,u32 address,__le32 value)109*4882a593Smuzhiyun static inline int ath6kl_hif_diag_write32(struct ath6kl *ar, u32 address,
110*4882a593Smuzhiyun __le32 value)
111*4882a593Smuzhiyun {
112*4882a593Smuzhiyun return ar->hif_ops->diag_write32(ar, address, value);
113*4882a593Smuzhiyun }
114*4882a593Smuzhiyun
ath6kl_hif_bmi_read(struct ath6kl * ar,u8 * buf,u32 len)115*4882a593Smuzhiyun static inline int ath6kl_hif_bmi_read(struct ath6kl *ar, u8 *buf, u32 len)
116*4882a593Smuzhiyun {
117*4882a593Smuzhiyun return ar->hif_ops->bmi_read(ar, buf, len);
118*4882a593Smuzhiyun }
119*4882a593Smuzhiyun
ath6kl_hif_bmi_write(struct ath6kl * ar,u8 * buf,u32 len)120*4882a593Smuzhiyun static inline int ath6kl_hif_bmi_write(struct ath6kl *ar, u8 *buf, u32 len)
121*4882a593Smuzhiyun {
122*4882a593Smuzhiyun return ar->hif_ops->bmi_write(ar, buf, len);
123*4882a593Smuzhiyun }
124*4882a593Smuzhiyun
ath6kl_hif_resume(struct ath6kl * ar)125*4882a593Smuzhiyun static inline int ath6kl_hif_resume(struct ath6kl *ar)
126*4882a593Smuzhiyun {
127*4882a593Smuzhiyun ath6kl_dbg(ATH6KL_DBG_HIF, "hif resume\n");
128*4882a593Smuzhiyun
129*4882a593Smuzhiyun return ar->hif_ops->resume(ar);
130*4882a593Smuzhiyun }
131*4882a593Smuzhiyun
ath6kl_hif_power_on(struct ath6kl * ar)132*4882a593Smuzhiyun static inline int ath6kl_hif_power_on(struct ath6kl *ar)
133*4882a593Smuzhiyun {
134*4882a593Smuzhiyun ath6kl_dbg(ATH6KL_DBG_HIF, "hif power on\n");
135*4882a593Smuzhiyun
136*4882a593Smuzhiyun return ar->hif_ops->power_on(ar);
137*4882a593Smuzhiyun }
138*4882a593Smuzhiyun
ath6kl_hif_power_off(struct ath6kl * ar)139*4882a593Smuzhiyun static inline int ath6kl_hif_power_off(struct ath6kl *ar)
140*4882a593Smuzhiyun {
141*4882a593Smuzhiyun ath6kl_dbg(ATH6KL_DBG_HIF, "hif power off\n");
142*4882a593Smuzhiyun
143*4882a593Smuzhiyun return ar->hif_ops->power_off(ar);
144*4882a593Smuzhiyun }
145*4882a593Smuzhiyun
ath6kl_hif_stop(struct ath6kl * ar)146*4882a593Smuzhiyun static inline void ath6kl_hif_stop(struct ath6kl *ar)
147*4882a593Smuzhiyun {
148*4882a593Smuzhiyun ath6kl_dbg(ATH6KL_DBG_HIF, "hif stop\n");
149*4882a593Smuzhiyun
150*4882a593Smuzhiyun ar->hif_ops->stop(ar);
151*4882a593Smuzhiyun }
152*4882a593Smuzhiyun
ath6kl_hif_pipe_send(struct ath6kl * ar,u8 pipe,struct sk_buff * hdr_buf,struct sk_buff * buf)153*4882a593Smuzhiyun static inline int ath6kl_hif_pipe_send(struct ath6kl *ar,
154*4882a593Smuzhiyun u8 pipe, struct sk_buff *hdr_buf,
155*4882a593Smuzhiyun struct sk_buff *buf)
156*4882a593Smuzhiyun {
157*4882a593Smuzhiyun ath6kl_dbg(ATH6KL_DBG_HIF, "hif pipe send\n");
158*4882a593Smuzhiyun
159*4882a593Smuzhiyun return ar->hif_ops->pipe_send(ar, pipe, hdr_buf, buf);
160*4882a593Smuzhiyun }
161*4882a593Smuzhiyun
ath6kl_hif_pipe_get_default(struct ath6kl * ar,u8 * ul_pipe,u8 * dl_pipe)162*4882a593Smuzhiyun static inline void ath6kl_hif_pipe_get_default(struct ath6kl *ar,
163*4882a593Smuzhiyun u8 *ul_pipe, u8 *dl_pipe)
164*4882a593Smuzhiyun {
165*4882a593Smuzhiyun ath6kl_dbg(ATH6KL_DBG_HIF, "hif pipe get default\n");
166*4882a593Smuzhiyun
167*4882a593Smuzhiyun ar->hif_ops->pipe_get_default(ar, ul_pipe, dl_pipe);
168*4882a593Smuzhiyun }
169*4882a593Smuzhiyun
ath6kl_hif_pipe_map_service(struct ath6kl * ar,u16 service_id,u8 * ul_pipe,u8 * dl_pipe)170*4882a593Smuzhiyun static inline int ath6kl_hif_pipe_map_service(struct ath6kl *ar,
171*4882a593Smuzhiyun u16 service_id, u8 *ul_pipe,
172*4882a593Smuzhiyun u8 *dl_pipe)
173*4882a593Smuzhiyun {
174*4882a593Smuzhiyun ath6kl_dbg(ATH6KL_DBG_HIF, "hif pipe get default\n");
175*4882a593Smuzhiyun
176*4882a593Smuzhiyun return ar->hif_ops->pipe_map_service(ar, service_id, ul_pipe, dl_pipe);
177*4882a593Smuzhiyun }
178*4882a593Smuzhiyun
ath6kl_hif_pipe_get_free_queue_number(struct ath6kl * ar,u8 pipe)179*4882a593Smuzhiyun static inline u16 ath6kl_hif_pipe_get_free_queue_number(struct ath6kl *ar,
180*4882a593Smuzhiyun u8 pipe)
181*4882a593Smuzhiyun {
182*4882a593Smuzhiyun ath6kl_dbg(ATH6KL_DBG_HIF, "hif pipe get free queue number\n");
183*4882a593Smuzhiyun
184*4882a593Smuzhiyun return ar->hif_ops->pipe_get_free_queue_number(ar, pipe);
185*4882a593Smuzhiyun }
186*4882a593Smuzhiyun
187*4882a593Smuzhiyun #endif
188