18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2004-2011 Atheros Communications Inc.
38c2ecf20Sopenharmony_ci * Copyright (c) 2011 Qualcomm Atheros, Inc.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any
68c2ecf20Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above
78c2ecf20Sopenharmony_ci * copyright notice and this permission notice appear in all copies.
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
108c2ecf20Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
118c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
128c2ecf20Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
138c2ecf20Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
148c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
158c2ecf20Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
168c2ecf20Sopenharmony_ci */
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#ifndef HIF_OPS_H
198c2ecf20Sopenharmony_ci#define HIF_OPS_H
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#include "hif.h"
228c2ecf20Sopenharmony_ci#include "debug.h"
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistatic inline int hif_read_write_sync(struct ath6kl *ar, u32 addr, u8 *buf,
258c2ecf20Sopenharmony_ci				      u32 len, u32 request)
268c2ecf20Sopenharmony_ci{
278c2ecf20Sopenharmony_ci	ath6kl_dbg(ATH6KL_DBG_HIF,
288c2ecf20Sopenharmony_ci		   "hif %s sync addr 0x%x buf 0x%p len %d request 0x%x\n",
298c2ecf20Sopenharmony_ci		   (request & HIF_WRITE) ? "write" : "read",
308c2ecf20Sopenharmony_ci		   addr, buf, len, request);
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci	return ar->hif_ops->read_write_sync(ar, addr, buf, len, request);
338c2ecf20Sopenharmony_ci}
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistatic inline int hif_write_async(struct ath6kl *ar, u32 address, u8 *buffer,
368c2ecf20Sopenharmony_ci				  u32 length, u32 request,
378c2ecf20Sopenharmony_ci				  struct htc_packet *packet)
388c2ecf20Sopenharmony_ci{
398c2ecf20Sopenharmony_ci	ath6kl_dbg(ATH6KL_DBG_HIF,
408c2ecf20Sopenharmony_ci		   "hif write async addr 0x%x buf 0x%p len %d request 0x%x\n",
418c2ecf20Sopenharmony_ci		   address, buffer, length, request);
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci	return ar->hif_ops->write_async(ar, address, buffer, length,
448c2ecf20Sopenharmony_ci					request, packet);
458c2ecf20Sopenharmony_ci}
468c2ecf20Sopenharmony_cistatic inline void ath6kl_hif_irq_enable(struct ath6kl *ar)
478c2ecf20Sopenharmony_ci{
488c2ecf20Sopenharmony_ci	ath6kl_dbg(ATH6KL_DBG_HIF, "hif irq enable\n");
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci	return ar->hif_ops->irq_enable(ar);
518c2ecf20Sopenharmony_ci}
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_cistatic inline void ath6kl_hif_irq_disable(struct ath6kl *ar)
548c2ecf20Sopenharmony_ci{
558c2ecf20Sopenharmony_ci	ath6kl_dbg(ATH6KL_DBG_HIF, "hif irq disable\n");
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	return ar->hif_ops->irq_disable(ar);
588c2ecf20Sopenharmony_ci}
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_cistatic inline struct hif_scatter_req *hif_scatter_req_get(struct ath6kl *ar)
618c2ecf20Sopenharmony_ci{
628c2ecf20Sopenharmony_ci	return ar->hif_ops->scatter_req_get(ar);
638c2ecf20Sopenharmony_ci}
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_cistatic inline void hif_scatter_req_add(struct ath6kl *ar,
668c2ecf20Sopenharmony_ci				       struct hif_scatter_req *s_req)
678c2ecf20Sopenharmony_ci{
688c2ecf20Sopenharmony_ci	return ar->hif_ops->scatter_req_add(ar, s_req);
698c2ecf20Sopenharmony_ci}
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cistatic inline int ath6kl_hif_enable_scatter(struct ath6kl *ar)
728c2ecf20Sopenharmony_ci{
738c2ecf20Sopenharmony_ci	return ar->hif_ops->enable_scatter(ar);
748c2ecf20Sopenharmony_ci}
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_cistatic inline int ath6kl_hif_scat_req_rw(struct ath6kl *ar,
778c2ecf20Sopenharmony_ci					 struct hif_scatter_req *scat_req)
788c2ecf20Sopenharmony_ci{
798c2ecf20Sopenharmony_ci	return ar->hif_ops->scat_req_rw(ar, scat_req);
808c2ecf20Sopenharmony_ci}
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_cistatic inline void ath6kl_hif_cleanup_scatter(struct ath6kl *ar)
838c2ecf20Sopenharmony_ci{
848c2ecf20Sopenharmony_ci	return ar->hif_ops->cleanup_scatter(ar);
858c2ecf20Sopenharmony_ci}
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_cistatic inline int ath6kl_hif_suspend(struct ath6kl *ar,
888c2ecf20Sopenharmony_ci				     struct cfg80211_wowlan *wow)
898c2ecf20Sopenharmony_ci{
908c2ecf20Sopenharmony_ci	ath6kl_dbg(ATH6KL_DBG_HIF, "hif suspend\n");
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci	return ar->hif_ops->suspend(ar, wow);
938c2ecf20Sopenharmony_ci}
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci/*
968c2ecf20Sopenharmony_ci * Read from the ATH6KL through its diagnostic window. No cooperation from
978c2ecf20Sopenharmony_ci * the Target is required for this.
988c2ecf20Sopenharmony_ci */
998c2ecf20Sopenharmony_cistatic inline int ath6kl_hif_diag_read32(struct ath6kl *ar, u32 address,
1008c2ecf20Sopenharmony_ci					 u32 *value)
1018c2ecf20Sopenharmony_ci{
1028c2ecf20Sopenharmony_ci	return ar->hif_ops->diag_read32(ar, address, value);
1038c2ecf20Sopenharmony_ci}
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci/*
1068c2ecf20Sopenharmony_ci * Write to the ATH6KL through its diagnostic window. No cooperation from
1078c2ecf20Sopenharmony_ci * the Target is required for this.
1088c2ecf20Sopenharmony_ci */
1098c2ecf20Sopenharmony_cistatic inline int ath6kl_hif_diag_write32(struct ath6kl *ar, u32 address,
1108c2ecf20Sopenharmony_ci					  __le32 value)
1118c2ecf20Sopenharmony_ci{
1128c2ecf20Sopenharmony_ci	return ar->hif_ops->diag_write32(ar, address, value);
1138c2ecf20Sopenharmony_ci}
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_cistatic inline int ath6kl_hif_bmi_read(struct ath6kl *ar, u8 *buf, u32 len)
1168c2ecf20Sopenharmony_ci{
1178c2ecf20Sopenharmony_ci	return ar->hif_ops->bmi_read(ar, buf, len);
1188c2ecf20Sopenharmony_ci}
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_cistatic inline int ath6kl_hif_bmi_write(struct ath6kl *ar, u8 *buf, u32 len)
1218c2ecf20Sopenharmony_ci{
1228c2ecf20Sopenharmony_ci	return ar->hif_ops->bmi_write(ar, buf, len);
1238c2ecf20Sopenharmony_ci}
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_cistatic inline int ath6kl_hif_resume(struct ath6kl *ar)
1268c2ecf20Sopenharmony_ci{
1278c2ecf20Sopenharmony_ci	ath6kl_dbg(ATH6KL_DBG_HIF, "hif resume\n");
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci	return ar->hif_ops->resume(ar);
1308c2ecf20Sopenharmony_ci}
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_cistatic inline int ath6kl_hif_power_on(struct ath6kl *ar)
1338c2ecf20Sopenharmony_ci{
1348c2ecf20Sopenharmony_ci	ath6kl_dbg(ATH6KL_DBG_HIF, "hif power on\n");
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	return ar->hif_ops->power_on(ar);
1378c2ecf20Sopenharmony_ci}
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_cistatic inline int ath6kl_hif_power_off(struct ath6kl *ar)
1408c2ecf20Sopenharmony_ci{
1418c2ecf20Sopenharmony_ci	ath6kl_dbg(ATH6KL_DBG_HIF, "hif power off\n");
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci	return ar->hif_ops->power_off(ar);
1448c2ecf20Sopenharmony_ci}
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_cistatic inline void ath6kl_hif_stop(struct ath6kl *ar)
1478c2ecf20Sopenharmony_ci{
1488c2ecf20Sopenharmony_ci	ath6kl_dbg(ATH6KL_DBG_HIF, "hif stop\n");
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci	ar->hif_ops->stop(ar);
1518c2ecf20Sopenharmony_ci}
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_cistatic inline int ath6kl_hif_pipe_send(struct ath6kl *ar,
1548c2ecf20Sopenharmony_ci				       u8 pipe, struct sk_buff *hdr_buf,
1558c2ecf20Sopenharmony_ci				       struct sk_buff *buf)
1568c2ecf20Sopenharmony_ci{
1578c2ecf20Sopenharmony_ci	ath6kl_dbg(ATH6KL_DBG_HIF, "hif pipe send\n");
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci	return ar->hif_ops->pipe_send(ar, pipe, hdr_buf, buf);
1608c2ecf20Sopenharmony_ci}
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_cistatic inline void ath6kl_hif_pipe_get_default(struct ath6kl *ar,
1638c2ecf20Sopenharmony_ci					       u8 *ul_pipe, u8 *dl_pipe)
1648c2ecf20Sopenharmony_ci{
1658c2ecf20Sopenharmony_ci	ath6kl_dbg(ATH6KL_DBG_HIF, "hif pipe get default\n");
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci	ar->hif_ops->pipe_get_default(ar, ul_pipe, dl_pipe);
1688c2ecf20Sopenharmony_ci}
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_cistatic inline int ath6kl_hif_pipe_map_service(struct ath6kl *ar,
1718c2ecf20Sopenharmony_ci					      u16 service_id, u8 *ul_pipe,
1728c2ecf20Sopenharmony_ci					      u8 *dl_pipe)
1738c2ecf20Sopenharmony_ci{
1748c2ecf20Sopenharmony_ci	ath6kl_dbg(ATH6KL_DBG_HIF, "hif pipe get default\n");
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci	return ar->hif_ops->pipe_map_service(ar, service_id, ul_pipe, dl_pipe);
1778c2ecf20Sopenharmony_ci}
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_cistatic inline u16 ath6kl_hif_pipe_get_free_queue_number(struct ath6kl *ar,
1808c2ecf20Sopenharmony_ci							u8 pipe)
1818c2ecf20Sopenharmony_ci{
1828c2ecf20Sopenharmony_ci	ath6kl_dbg(ATH6KL_DBG_HIF, "hif pipe get free queue number\n");
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci	return ar->hif_ops->pipe_get_free_queue_number(ar, pipe);
1858c2ecf20Sopenharmony_ci}
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci#endif
188