xref: /wlan-dirver/qca-wifi-host-cmn/hif/src/sdio/hif_sdio_dev.h (revision cf1f958b5f95998520dd6165a27010242a69721e)
1 /*
2  * Copyright (c) 2013-2016, 2018-2019 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef HIF_SDIO_DEV_H_
20 #define HIF_SDIO_DEV_H_
21 
22 #include "qdf_net_types.h"
23 #include "a_types.h"
24 #include "athdefs.h"
25 #include "a_osapi.h"
26 #include <hif.h>
27 #include "athstartpack.h"
28 #include "hif_internal.h"
29 #include "if_sdio.h"
30 
31 struct hif_sdio_device *hif_dev_from_hif(struct hif_sdio_dev *hif_device);
32 
33 struct hif_sdio_device *hif_dev_create(struct hif_sdio_dev *hif_device,
34 				struct hif_msg_callbacks *callbacks,
35 				void *target);
36 
37 void hif_dev_destroy(struct hif_sdio_device *htc_sdio_device);
38 
39 QDF_STATUS hif_dev_setup(struct hif_sdio_device *htc_sdio_device);
40 
41 QDF_STATUS hif_dev_enable_interrupts(struct hif_sdio_device *htc_sdio_device);
42 
43 QDF_STATUS hif_dev_disable_interrupts(struct hif_sdio_device *htc_sdio_device);
44 
45 QDF_STATUS hif_dev_send_buffer(struct hif_sdio_device *htc_sdio_device,
46 			     unsigned int transfer_id, uint8_t pipe,
47 			     unsigned int nbytes, qdf_nbuf_t buf);
48 
49 QDF_STATUS hif_dev_process_pending_irqs(struct hif_sdio_device *pdev,
50 					bool *done,
51 					bool *async_processing);
52 
53 void hif_dev_mask_interrupts(struct hif_sdio_device *pdev);
54 
55 QDF_STATUS hif_dev_map_service_to_pipe(struct hif_sdio_dev *pdev,
56 				       uint16_t service_id,
57 				       uint8_t *ul_pipe,
58 				       uint8_t *dl_pipe);
59 
60 void hif_dev_unmask_interrupts(struct hif_sdio_device *pdev);
61 
62 int hif_dev_setup_device(struct hif_sdio_device *pdev);
63 
64 int hif_dev_get_fifo_address(struct hif_sdio_dev *pdev,
65 			     void *config,
66 			     uint32_t config_len);
67 
68 void hif_dev_get_block_size(void *config);
69 
70 void hif_dev_set_mailbox_swap(struct hif_sdio_dev *pdev);
71 
72 bool hif_dev_get_mailbox_swap(struct hif_sdio_dev *pdev);
73 
74 QDF_STATUS hif_read_write(struct hif_sdio_dev *device, unsigned long address,
75 			  char *buffer,	uint32_t length, uint32_t request,
76 			  void *context);
77 
78 #ifdef CONFIG_SDIO_TRANSFER_MAILBOX
79 static inline struct hif_sdio_dev *get_hif_device(struct hif_softc *hif_ctx,
80 						  struct sdio_func *func)
81 {
82 	qdf_assert(func);
83 	return (struct hif_sdio_dev *)sdio_get_drvdata(func);
84 }
85 
86 /**
87  * hif_sdio_set_drvdata() - set wlan driver data into upper layer private
88  * @hif_ctx: HIF object
89  * @func: pointer to sdio function
90  * @hifdevice: pointer to hif device
91  *
92  * Return: zero for success.
93  */
94 static inline int hif_sdio_set_drvdata(struct hif_softc *hif_ctx,
95 				       struct sdio_func *func,
96 				       struct hif_sdio_dev *hifdevice)
97 {
98 	sdio_set_drvdata(func, hifdevice);
99 	return 0;
100 }
101 
102 static inline int hif_dev_configure_pipes(struct hif_sdio_dev *pdev,
103 					  struct sdio_func *func)
104 {
105 	return 0;
106 }
107 
108 static inline int hif_dev_register_channels(struct hif_sdio_dev *dev,
109 					    struct sdio_func *func)
110 {
111 	return 0;
112 }
113 
114 static inline void hif_dev_unregister_channels(struct hif_sdio_dev *dev,
115 					       struct sdio_func *func)
116 {
117 }
118 #else
119 static inline struct hif_sdio_dev *get_hif_device(struct hif_softc *hif_ctx,
120 						  struct sdio_func *func)
121 {
122 	struct hif_sdio_softc *scn = (struct hif_sdio_softc *)hif_ctx;
123 
124 	return (struct hif_sdio_dev *)scn->hif_handle;
125 }
126 
127 /**
128  * hif_sdio_set_drvdata() - set wlan driver data into upper layer private
129  * @hif_ctx: HIF object
130  * @func: pointer to sdio function
131  * @hifdevice: pointer to hif device
132  *
133  * Return: zero for success.
134  */
135 static inline int hif_sdio_set_drvdata(struct hif_softc *hif_ctx,
136 				       struct sdio_func *func,
137 				       struct hif_sdio_dev *hifdevice)
138 {
139 	struct hif_sdio_softc *sc = (struct hif_sdio_softc *)hif_ctx;
140 
141 	sc->hif_handle = hifdevice;
142 
143 	return 0;
144 }
145 
146 int hif_dev_configure_pipes(struct hif_sdio_dev *pdev,
147 			    struct sdio_func *func);
148 
149 int hif_dev_register_channels(struct hif_sdio_dev *dev,
150 			      struct sdio_func *func);
151 
152 void hif_dev_unregister_channels(struct hif_sdio_dev *dev,
153 				 struct sdio_func *func);
154 #endif /* SDIO_TRANSFER */
155 QDF_STATUS hif_enable_func(struct hif_softc *ol_sc, struct hif_sdio_dev *device,
156 			   struct sdio_func *func, bool resume);
157 QDF_STATUS hif_disable_func(struct hif_sdio_dev *device,
158 			    struct sdio_func *func,
159 			    bool reset);
160 A_STATUS hif_sdio_probe(struct hif_softc *ol_sc,
161 			struct sdio_func *func,
162 			struct hif_sdio_dev *device);
163 #endif /* HIF_SDIO_DEV_H_ */
164