Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1 | /* |
Houston Hoffman | ebc6814 | 2016-01-18 15:38:27 -0800 | [diff] [blame] | 2 | * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved. |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | #ifndef __CE_H__ |
| 29 | #define __CE_H__ |
| 30 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 31 | #include "qdf_atomic.h" |
| 32 | #include "qdf_lock.h" |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 33 | #include "hif_main.h" |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 34 | |
| 35 | #define CE_HTT_T2H_MSG 1 |
| 36 | #define CE_HTT_H2T_MSG 4 |
| 37 | |
Govind Singh | 2443fb3 | 2016-01-13 17:44:48 +0530 | [diff] [blame] | 38 | #define CE_OFFSET 0x00000400 |
| 39 | #define CE_USEFUL_SIZE 0x00000058 |
| 40 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 41 | /** |
| 42 | * enum ce_id_type |
| 43 | * |
| 44 | * @ce_id_type: Copy engine ID |
| 45 | */ |
| 46 | enum ce_id_type { |
| 47 | CE_ID_0, |
| 48 | CE_ID_1, |
| 49 | CE_ID_2, |
| 50 | CE_ID_3, |
| 51 | CE_ID_4, |
| 52 | CE_ID_5, |
| 53 | CE_ID_6, |
| 54 | CE_ID_7, |
| 55 | CE_ID_8, |
| 56 | CE_ID_9, |
| 57 | CE_ID_10, |
| 58 | CE_ID_11, |
| 59 | CE_ID_MAX |
| 60 | }; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 61 | |
| 62 | enum ol_ath_hif_pkt_ecodes { |
| 63 | HIF_PIPE_NO_RESOURCE = 0 |
| 64 | }; |
| 65 | |
| 66 | struct HIF_CE_state; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 67 | |
| 68 | /* Per-pipe state. */ |
| 69 | struct HIF_CE_pipe_info { |
| 70 | /* Handle of underlying Copy Engine */ |
| 71 | struct CE_handle *ce_hdl; |
| 72 | |
| 73 | /* Our pipe number; facilitiates use of pipe_info ptrs. */ |
| 74 | uint8_t pipe_num; |
| 75 | |
| 76 | /* Convenience back pointer to HIF_CE_state. */ |
| 77 | struct HIF_CE_state *HIF_CE_state; |
| 78 | |
| 79 | /* Instantaneous number of receive buffers that should be posted */ |
| 80 | atomic_t recv_bufs_needed; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 81 | qdf_size_t buf_sz; |
| 82 | qdf_spinlock_t recv_bufs_needed_lock; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 83 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 84 | qdf_spinlock_t completion_freeq_lock; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 85 | /* Limit the number of outstanding send requests. */ |
| 86 | int num_sends_allowed; |
Houston Hoffman | 9c12f7f | 2015-09-28 16:52:14 -0700 | [diff] [blame] | 87 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 88 | /* adding three counts for debugging ring buffer errors */ |
| 89 | uint32_t nbuf_alloc_err_count; |
| 90 | uint32_t nbuf_dma_err_count; |
| 91 | uint32_t nbuf_ce_enqueue_err_count; |
| 92 | }; |
| 93 | |
| 94 | /** |
| 95 | * struct ce_tasklet_entry |
| 96 | * |
| 97 | * @intr_tq: intr_tq |
| 98 | * @ce_id: ce_id |
| 99 | * @inited: inited |
| 100 | * @hif_ce_state: hif_ce_state |
| 101 | * @from_irq: from_irq |
| 102 | */ |
| 103 | struct ce_tasklet_entry { |
| 104 | struct tasklet_struct intr_tq; |
| 105 | enum ce_id_type ce_id; |
| 106 | bool inited; |
| 107 | void *hif_ce_state; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | struct HIF_CE_state { |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 111 | struct hif_softc ol_sc; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 112 | bool started; |
| 113 | struct ce_tasklet_entry tasklets[CE_COUNT_MAX]; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 114 | qdf_spinlock_t keep_awake_lock; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 115 | unsigned int keep_awake_count; |
| 116 | bool verified_awake; |
| 117 | bool fake_sleep; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 118 | qdf_timer_t sleep_timer; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 119 | bool sleep_timer_init; |
| 120 | unsigned long sleep_ticks; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 121 | |
| 122 | /* Per-pipe state. */ |
| 123 | struct HIF_CE_pipe_info pipe_info[CE_COUNT_MAX]; |
| 124 | /* to be activated after BMI_DONE */ |
| 125 | struct hif_msg_callbacks msg_callbacks_pending; |
| 126 | /* current msg callbacks in use */ |
| 127 | struct hif_msg_callbacks msg_callbacks_current; |
| 128 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 129 | /* Target address used to signal a pending firmware event */ |
| 130 | uint32_t fw_indicator_address; |
| 131 | |
| 132 | /* Copy Engine used for Diagnostic Accesses */ |
| 133 | struct CE_handle *ce_diag; |
| 134 | }; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 135 | int hif_dump_ce_registers(struct hif_softc *scn); |
Houston Hoffman | 854e67f | 2016-03-14 21:11:39 -0700 | [diff] [blame^] | 136 | |
| 137 | int hif_wlan_enable(struct hif_softc *scn); |
| 138 | void hif_wlan_disable(struct hif_softc *scn); |
| 139 | void hif_get_target_ce_config(struct CE_pipe_config **target_ce_config_ret, |
| 140 | int *target_ce_config_sz_ret, |
| 141 | struct service_to_pipe **target_service_to_ce_map_ret, |
| 142 | int *target_service_to_ce_map_sz_ret, |
| 143 | struct shadow_reg_cfg **target_shadow_reg_cfg_ret, |
| 144 | int *shadow_cfg_sz_ret); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 145 | #endif /* __CE_H__ */ |