Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2004-2011 Atheros Communications Inc. |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
| 17 | #ifndef HIF_OPS_H |
| 18 | #define HIF_OPS_H |
| 19 | |
| 20 | #include "hif.h" |
Kalle Valo | 83973e0 | 2011-10-13 15:21:53 +0300 | [diff] [blame] | 21 | #include "debug.h" |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 22 | |
| 23 | static inline int hif_read_write_sync(struct ath6kl *ar, u32 addr, u8 *buf, |
| 24 | u32 len, u32 request) |
| 25 | { |
Kalle Valo | 83973e0 | 2011-10-13 15:21:53 +0300 | [diff] [blame] | 26 | ath6kl_dbg(ATH6KL_DBG_HIF, |
| 27 | "hif %s sync addr 0x%x buf 0x%p len %d request 0x%x\n", |
| 28 | (request & HIF_WRITE) ? "write" : "read", |
| 29 | addr, buf, len, request); |
| 30 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 31 | return ar->hif_ops->read_write_sync(ar, addr, buf, len, request); |
| 32 | } |
| 33 | |
| 34 | static inline int hif_write_async(struct ath6kl *ar, u32 address, u8 *buffer, |
| 35 | u32 length, u32 request, |
| 36 | struct htc_packet *packet) |
| 37 | { |
Kalle Valo | 83973e0 | 2011-10-13 15:21:53 +0300 | [diff] [blame] | 38 | ath6kl_dbg(ATH6KL_DBG_HIF, |
| 39 | "hif write async addr 0x%x buf 0x%p len %d request 0x%x\n", |
| 40 | address, buffer, length, request); |
| 41 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 42 | return ar->hif_ops->write_async(ar, address, buffer, length, |
| 43 | request, packet); |
| 44 | } |
| 45 | static inline void ath6kl_hif_irq_enable(struct ath6kl *ar) |
| 46 | { |
Kalle Valo | 83973e0 | 2011-10-13 15:21:53 +0300 | [diff] [blame] | 47 | ath6kl_dbg(ATH6KL_DBG_HIF, "hif irq enable\n"); |
| 48 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 49 | return ar->hif_ops->irq_enable(ar); |
| 50 | } |
| 51 | |
| 52 | static inline void ath6kl_hif_irq_disable(struct ath6kl *ar) |
| 53 | { |
Kalle Valo | 83973e0 | 2011-10-13 15:21:53 +0300 | [diff] [blame] | 54 | ath6kl_dbg(ATH6KL_DBG_HIF, "hif irq disable\n"); |
| 55 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 56 | return ar->hif_ops->irq_disable(ar); |
| 57 | } |
| 58 | |
| 59 | static inline struct hif_scatter_req *hif_scatter_req_get(struct ath6kl *ar) |
| 60 | { |
| 61 | return ar->hif_ops->scatter_req_get(ar); |
| 62 | } |
| 63 | |
| 64 | static inline void hif_scatter_req_add(struct ath6kl *ar, |
| 65 | struct hif_scatter_req *s_req) |
| 66 | { |
| 67 | return ar->hif_ops->scatter_req_add(ar, s_req); |
| 68 | } |
| 69 | |
Vasanthakumar Thiagarajan | 50745af | 2011-07-18 14:23:29 +0530 | [diff] [blame] | 70 | static inline int ath6kl_hif_enable_scatter(struct ath6kl *ar) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 71 | { |
Vasanthakumar Thiagarajan | 50745af | 2011-07-18 14:23:29 +0530 | [diff] [blame] | 72 | return ar->hif_ops->enable_scatter(ar); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 73 | } |
| 74 | |
Vasanthakumar Thiagarajan | f74a736 | 2011-07-16 20:29:05 +0530 | [diff] [blame] | 75 | static inline int ath6kl_hif_scat_req_rw(struct ath6kl *ar, |
| 76 | struct hif_scatter_req *scat_req) |
| 77 | { |
| 78 | return ar->hif_ops->scat_req_rw(ar, scat_req); |
| 79 | } |
| 80 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 81 | static inline void ath6kl_hif_cleanup_scatter(struct ath6kl *ar) |
| 82 | { |
| 83 | return ar->hif_ops->cleanup_scatter(ar); |
| 84 | } |
| 85 | |
Raja Mani | 0f60e9f | 2011-11-07 22:52:45 +0200 | [diff] [blame] | 86 | static inline int ath6kl_hif_suspend(struct ath6kl *ar, |
| 87 | struct cfg80211_wowlan *wow) |
Kalle Valo | abcb344 | 2011-07-22 08:26:20 +0300 | [diff] [blame] | 88 | { |
Kalle Valo | 83973e0 | 2011-10-13 15:21:53 +0300 | [diff] [blame] | 89 | ath6kl_dbg(ATH6KL_DBG_HIF, "hif suspend\n"); |
| 90 | |
Raja Mani | 0f60e9f | 2011-11-07 22:52:45 +0200 | [diff] [blame] | 91 | return ar->hif_ops->suspend(ar, wow); |
Kalle Valo | abcb344 | 2011-07-22 08:26:20 +0300 | [diff] [blame] | 92 | } |
| 93 | |
Kalle Valo | c711149 | 2011-11-11 12:17:51 +0200 | [diff] [blame^] | 94 | /* |
| 95 | * Read from the ATH6KL through its diagnostic window. No cooperation from |
| 96 | * the Target is required for this. |
| 97 | */ |
| 98 | static inline int ath6kl_hif_diag_read32(struct ath6kl *ar, u32 address, |
| 99 | u32 *value) |
| 100 | { |
| 101 | return ar->hif_ops->diag_read32(ar, address, value); |
| 102 | } |
| 103 | |
| 104 | /* |
| 105 | * Write to the ATH6KL through its diagnostic window. No cooperation from |
| 106 | * the Target is required for this. |
| 107 | */ |
| 108 | static inline int ath6kl_hif_diag_write32(struct ath6kl *ar, u32 address, |
| 109 | __le32 value) |
| 110 | { |
| 111 | return ar->hif_ops->diag_write32(ar, address, value); |
| 112 | } |
| 113 | |
Kalle Valo | 66b693c | 2011-11-11 12:17:33 +0200 | [diff] [blame] | 114 | static inline int ath6kl_hif_bmi_read(struct ath6kl *ar, u8 *buf, u32 len) |
| 115 | { |
| 116 | return ar->hif_ops->bmi_read(ar, buf, len); |
| 117 | } |
| 118 | |
| 119 | static inline int ath6kl_hif_bmi_write(struct ath6kl *ar, u8 *buf, u32 len) |
| 120 | { |
| 121 | return ar->hif_ops->bmi_write(ar, buf, len); |
| 122 | } |
| 123 | |
Chilam Ng | aa6cffc | 2011-10-05 10:12:52 +0300 | [diff] [blame] | 124 | static inline int ath6kl_hif_resume(struct ath6kl *ar) |
| 125 | { |
Kalle Valo | 83973e0 | 2011-10-13 15:21:53 +0300 | [diff] [blame] | 126 | ath6kl_dbg(ATH6KL_DBG_HIF, "hif resume\n"); |
| 127 | |
Chilam Ng | aa6cffc | 2011-10-05 10:12:52 +0300 | [diff] [blame] | 128 | return ar->hif_ops->resume(ar); |
| 129 | } |
Kalle Valo | b2e7569 | 2011-10-27 18:48:14 +0300 | [diff] [blame] | 130 | |
| 131 | static inline int ath6kl_hif_power_on(struct ath6kl *ar) |
| 132 | { |
| 133 | ath6kl_dbg(ATH6KL_DBG_HIF, "hif power on\n"); |
| 134 | |
| 135 | return ar->hif_ops->power_on(ar); |
| 136 | } |
| 137 | |
| 138 | static inline int ath6kl_hif_power_off(struct ath6kl *ar) |
| 139 | { |
| 140 | ath6kl_dbg(ATH6KL_DBG_HIF, "hif power off\n"); |
| 141 | |
| 142 | return ar->hif_ops->power_off(ar); |
| 143 | } |
| 144 | |
Kalle Valo | 32a07e4 | 2011-10-30 21:15:57 +0200 | [diff] [blame] | 145 | static inline void ath6kl_hif_stop(struct ath6kl *ar) |
| 146 | { |
| 147 | ath6kl_dbg(ATH6KL_DBG_HIF, "hif stop\n"); |
| 148 | |
| 149 | ar->hif_ops->stop(ar); |
| 150 | } |
| 151 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 152 | #endif |