Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 1 | /* |
Houston Hoffman | cceec34 | 2015-11-11 11:37:20 -0800 | [diff] [blame] | 2 | * Copyright (c) 2013-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 | /* |
| 29 | * NB: Inappropriate references to "HTC" are used in this (and other) |
| 30 | * HIF implementations. HTC is typically the calling layer, but it |
| 31 | * theoretically could be some alternative. |
| 32 | */ |
| 33 | |
| 34 | /* |
| 35 | * This holds all state needed to process a pending send/recv interrupt. |
| 36 | * The information is saved here as soon as the interrupt occurs (thus |
| 37 | * allowing the underlying CE to re-use the ring descriptor). The |
| 38 | * information here is eventually processed by a completion processing |
| 39 | * thread. |
| 40 | */ |
| 41 | |
| 42 | #ifndef __HIF_MAIN_H__ |
| 43 | #define __HIF_MAIN_H__ |
| 44 | |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 45 | #include <qdf_atomic.h> /* qdf_atomic_read */ |
| 46 | #include "qdf_lock.h" |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 47 | #include "cepci.h" |
| 48 | #include "hif.h" |
Houston Hoffman | 32bc8eb | 2016-03-14 21:11:34 -0700 | [diff] [blame] | 49 | #include "multibus.h" |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 50 | |
| 51 | #define HIF_MIN_SLEEP_INACTIVITY_TIME_MS 50 |
| 52 | #define HIF_SLEEP_INACTIVITY_TIMER_PERIOD_MS 60 |
| 53 | |
| 54 | /* |
| 55 | * This macro implementation is exposed for efficiency only. |
| 56 | * The implementation may change and callers should |
| 57 | * consider the targid to be a completely opaque handle. |
| 58 | */ |
| 59 | #define TARGID_TO_PCI_ADDR(targid) (*((A_target_id_t *)(targid))) |
| 60 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 61 | #ifdef QCA_WIFI_3_0 |
| 62 | #define DISABLE_L1SS_STATES 1 |
| 63 | #endif |
| 64 | #ifdef CONFIG_SLUB_DEBUG_ON |
| 65 | #define MAX_NUM_OF_RECEIVES 100 /* Maximum number of Rx buf to process before* |
| 66 | * break out in SLUB debug builds */ |
| 67 | #elif defined(FEATURE_NAPI) |
| 68 | #define MAX_NUM_OF_RECEIVES HIF_NAPI_MAX_RECEIVES |
| 69 | #else /* no SLUBS, no NAPI */ |
| 70 | /* Maximum number of Rx buf to process before break out */ |
| 71 | #define MAX_NUM_OF_RECEIVES 1000 |
| 72 | #endif /* SLUB_DEBUG_ON / FEATURE_NAPI */ |
| 73 | |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 74 | #ifdef QCA_WIFI_3_0_ADRASTEA |
| 75 | #define ADRASTEA_BU 1 |
| 76 | #else |
| 77 | #define ADRASTEA_BU 0 |
| 78 | #endif |
| 79 | |
| 80 | #ifdef QCA_WIFI_3_0 |
| 81 | #define HAS_FW_INDICATOR 0 |
| 82 | #else |
| 83 | #define HAS_FW_INDICATOR 1 |
| 84 | #endif |
| 85 | |
| 86 | |
| 87 | #define AR9888_DEVICE_ID (0x003c) |
| 88 | #define AR6320_DEVICE_ID (0x003e) |
| 89 | #define AR6320_FW_1_1 (0x11) |
| 90 | #define AR6320_FW_1_3 (0x13) |
| 91 | #define AR6320_FW_2_0 (0x20) |
| 92 | #define AR6320_FW_3_0 (0x30) |
| 93 | #define AR6320_FW_3_2 (0x32) |
| 94 | #define ADRASTEA_DEVICE_ID (0xabcd) |
| 95 | #define ADRASTEA_DEVICE_ID_P2_E12 (0x7021) |
Houston Hoffman | 06bc4f5 | 2015-12-16 18:43:34 -0800 | [diff] [blame] | 96 | #if (defined(QVIT)) |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 97 | #define QCA6180_DEVICE_ID (0xabcd) |
| 98 | #else |
| 99 | #define QCA6180_DEVICE_ID (0x041) |
| 100 | #endif |
| 101 | |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 102 | #define HIF_GET_PCI_SOFTC(scn) ((struct hif_pci_softc *)scn) |
| 103 | #define HIF_GET_CE_STATE(scn) ((struct HIF_CE_state *)scn) |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 104 | #define HIF_GET_SOFTC(scn) ((struct hif_softc *)scn) |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 105 | #define GET_HIF_OPAQUE_HDL(scn) ((struct hif_opaque_softc *)scn) |
Komal Seelam | 02cf2f8 | 2016-02-22 20:44:25 +0530 | [diff] [blame] | 106 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 107 | struct hif_ce_stats { |
| 108 | int hif_pipe_no_resrc_count; |
| 109 | int ce_ring_delta_fail_count; |
| 110 | }; |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 111 | |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 112 | struct hif_softc { |
Komal Seelam | 5584a7c | 2016-02-24 19:22:48 +0530 | [diff] [blame] | 113 | struct hif_opaque_softc osc; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 114 | struct hif_config_info hif_config; |
| 115 | struct hif_target_info target_info; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 116 | void __iomem *mem; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 117 | enum qdf_bus_type bus_type; |
Houston Hoffman | 32bc8eb | 2016-03-14 21:11:34 -0700 | [diff] [blame] | 118 | struct hif_bus_ops bus_ops; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 119 | void *ce_id_to_state[CE_COUNT_MAX]; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 120 | qdf_device_t qdf_dev; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 121 | bool hif_init_done; |
| 122 | bool request_irq_done; |
| 123 | /* Packet statistics */ |
| 124 | struct hif_ce_stats pkt_stats; |
| 125 | ol_target_status target_status; |
| 126 | |
| 127 | struct targetdef_s *targetdef; |
| 128 | struct ce_reg_def *target_ce_def; |
| 129 | struct hostdef_s *hostdef; |
| 130 | struct host_shadow_regs_s *host_shadow_regs; |
| 131 | |
| 132 | bool recovery; |
| 133 | bool notice_send; |
| 134 | uint32_t ce_irq_summary; |
| 135 | /* No of copy engines supported */ |
| 136 | unsigned int ce_count; |
| 137 | atomic_t active_tasklet_cnt; |
| 138 | atomic_t link_suspended; |
| 139 | uint32_t *vaddr_rri_on_ddr; |
| 140 | int linkstate_vote; |
| 141 | int fastpath_mode_on; |
| 142 | atomic_t tasklet_from_intr; |
| 143 | int htc_endpoint; |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 144 | qdf_dma_addr_t mem_pa; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 145 | bool athdiag_procfs_inited; |
| 146 | #ifdef FEATURE_NAPI |
| 147 | struct qca_napi_data napi_data; |
| 148 | #endif /* FEATURE_NAPI */ |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame^] | 149 | struct hif_driver_state_callbacks callbacks; |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 150 | uint32_t hif_con_param; |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 151 | }; |
| 152 | |
| 153 | A_target_id_t hif_get_target_id(struct hif_softc *scn); |
| 154 | void hif_dump_pipe_debug_count(struct hif_softc *scn); |
| 155 | |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 156 | bool hif_max_num_receives_reached(struct hif_softc *scn, unsigned int count); |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 157 | int hif_bus_configure(struct hif_softc *scn); |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 158 | int hif_config_ce(struct hif_softc *scn); |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 159 | void hif_unconfig_ce(struct hif_softc *scn); |
| 160 | void hif_ce_prepare_config(struct hif_softc *scn); |
Houston Hoffman | 108da40 | 2016-03-14 21:11:24 -0700 | [diff] [blame] | 161 | QDF_STATUS hif_ce_open(struct hif_softc *scn); |
| 162 | void hif_ce_close(struct hif_softc *scn); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 163 | int athdiag_procfs_init(void *scn); |
| 164 | void athdiag_procfs_remove(void); |
| 165 | /* routine to modify the initial buffer count to be allocated on an os |
| 166 | * platform basis. Platform owner will need to modify this as needed |
| 167 | */ |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 168 | qdf_size_t init_buffer_count(qdf_size_t maxSize); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 169 | |
| 170 | irqreturn_t hif_fw_interrupt_handler(int irq, void *arg); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 171 | int hif_get_device_type(uint32_t device_id, |
| 172 | uint32_t revision_id, |
| 173 | uint32_t *hif_type, uint32_t *target_type); |
| 174 | /*These functions are exposed to HDD*/ |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 175 | void hif_nointrs(struct hif_softc *scn); |
| 176 | void hif_bus_close(struct hif_softc *ol_sc); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 177 | QDF_STATUS hif_bus_open(struct hif_softc *ol_sc, |
| 178 | enum qdf_bus_type bus_type); |
| 179 | QDF_STATUS hif_enable_bus(struct hif_softc *ol_sc, struct device *dev, |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 180 | void *bdev, const hif_bus_id *bid, enum hif_enable_type type); |
Vishwajith Upendra | 3f78aa6 | 2016-02-09 17:53:02 +0530 | [diff] [blame] | 181 | void hif_disable_bus(struct hif_softc *scn); |
Komal Seelam | 644263d | 2016-02-22 20:45:49 +0530 | [diff] [blame] | 182 | void hif_bus_prevent_linkdown(struct hif_softc *scn, bool flag); |
Houston Hoffman | 162164c | 2016-03-14 21:12:10 -0700 | [diff] [blame] | 183 | int hif_bus_get_context_size(enum qdf_bus_type bus_type); |
Chouhan, Anurag | fc06aa9 | 2016-03-03 19:05:05 +0530 | [diff] [blame] | 184 | void hif_read_phy_mem_base(struct hif_softc *scn, qdf_dma_addr_t *bar_value); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 185 | uint32_t hif_get_conparam(struct hif_softc *scn); |
Komal Seelam | 7508012 | 2016-03-02 15:18:25 +0530 | [diff] [blame^] | 186 | struct hif_driver_state_callbacks *hif_get_callbacks_handle(struct hif_softc *scn); |
Komal Seelam | bd7c51d | 2016-02-24 10:27:30 +0530 | [diff] [blame] | 187 | bool hif_is_driver_unloading(struct hif_softc *scn); |
| 188 | bool hif_is_load_or_unload_in_progress(struct hif_softc *scn); |
| 189 | bool hif_is_recovery_in_progress(struct hif_softc *scn); |
Houston Hoffman | 4ca03b6 | 2016-03-14 21:11:51 -0700 | [diff] [blame] | 190 | int hif_target_sleep_state_adjust(struct hif_softc *scn, |
| 191 | bool sleep_ok, |
| 192 | bool wait_for_it); |
Prakash Dhavali | d5c9f1c | 2015-11-08 19:04:44 -0800 | [diff] [blame] | 193 | #endif /* __HIF_MAIN_H__ */ |