Shimrit Malichi | 83df3ff | 2013-03-10 13:16:12 +0200 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. |
Ofir Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef _USB_BAM_H_ |
| 14 | #define _USB_BAM_H_ |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 15 | #include "sps.h" |
Ofir Cohen | ce5e3f2 | 2012-11-16 15:47:40 +0200 | [diff] [blame] | 16 | #include <mach/ipa.h> |
Ofir Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 17 | |
| 18 | /** |
Amit Blay | e5bb35e | 2012-05-08 20:38:20 +0300 | [diff] [blame] | 19 | * SPS Pipes direction. |
| 20 | * |
| 21 | * USB_TO_PEER_PERIPHERAL USB (as Producer) to other |
| 22 | * peer peripheral. |
| 23 | * PEER_PERIPHERAL_TO_USB Other Peripheral to |
| 24 | * USB (as consumer). |
| 25 | */ |
| 26 | enum usb_bam_pipe_dir { |
| 27 | USB_TO_PEER_PERIPHERAL, |
| 28 | PEER_PERIPHERAL_TO_USB, |
| 29 | }; |
| 30 | |
Ofir Cohen | ce5e3f2 | 2012-11-16 15:47:40 +0200 | [diff] [blame] | 31 | struct usb_bam_connect_ipa_params { |
| 32 | u8 idx; |
| 33 | u32 *src_pipe; |
| 34 | u32 *dst_pipe; |
| 35 | enum usb_bam_pipe_dir dir; |
| 36 | /* client handle assigned by IPA to client */ |
| 37 | u32 prod_clnt_hdl; |
| 38 | u32 cons_clnt_hdl; |
| 39 | /* params assigned by the CD */ |
| 40 | enum ipa_client_type client; |
| 41 | struct ipa_ep_cfg ipa_ep_cfg; |
| 42 | void *priv; |
| 43 | void (*notify)(void *priv, enum ipa_dp_evt_type evt, |
| 44 | unsigned long data); |
| 45 | }; |
| 46 | |
Amit Blay | e5bb35e | 2012-05-08 20:38:20 +0300 | [diff] [blame] | 47 | #ifdef CONFIG_USB_BAM |
| 48 | /** |
Ofir Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 49 | * Connect USB-to-Periperal SPS connection. |
| 50 | * |
| 51 | * This function returns the allocated pipes number. |
| 52 | * |
| 53 | * @idx - Connection index. |
| 54 | * |
| 55 | * @src_pipe_idx - allocated pipe index - USB as a |
| 56 | * source (output) |
| 57 | * |
| 58 | * @dst_pipe_idx - allocated pipe index - USB as a |
| 59 | * destination (output) |
| 60 | * |
| 61 | * @return 0 on success, negative value on error |
| 62 | * |
| 63 | */ |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 64 | int usb_bam_connect(u8 idx, u32 *src_pipe_idx, u32 *dst_pipe_idx); |
Amit Blay | e5bb35e | 2012-05-08 20:38:20 +0300 | [diff] [blame] | 65 | |
| 66 | /** |
Ofir Cohen | ce5e3f2 | 2012-11-16 15:47:40 +0200 | [diff] [blame] | 67 | * Connect USB-to-IPA SPS connection. |
| 68 | * |
| 69 | * This function returns the allocated pipes number adn clnt handles. |
| 70 | * |
| 71 | * @ipa_params - in/out parameters |
| 72 | * |
| 73 | * @return 0 on success, negative value on error |
| 74 | * |
| 75 | */ |
| 76 | int usb_bam_connect_ipa(struct usb_bam_connect_ipa_params *ipa_params); |
| 77 | |
| 78 | /** |
| 79 | * Disconnect USB-to-IPA SPS connection. |
| 80 | * |
| 81 | * @idx - Connection index. |
| 82 | * |
| 83 | * @ipa_params - in/out parameters |
| 84 | * |
| 85 | * @return 0 on success, negative value on error |
| 86 | * |
| 87 | */ |
| 88 | int usb_bam_disconnect_ipa(u8 idx, |
| 89 | struct usb_bam_connect_ipa_params *ipa_params); |
| 90 | |
| 91 | /** |
Amit Blay | e5bb35e | 2012-05-08 20:38:20 +0300 | [diff] [blame] | 92 | * Register a wakeup callback from peer BAM. |
| 93 | * |
| 94 | * @idx - Connection index. |
| 95 | * |
| 96 | * @callback - the callback function |
| 97 | * |
| 98 | * @return 0 on success, negative value on error |
| 99 | * |
| 100 | */ |
| 101 | int usb_bam_register_wake_cb(u8 idx, |
| 102 | int (*callback)(void *), void* param); |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 103 | |
| 104 | /** |
Amit Blay | 0c929f4 | 2012-12-26 12:02:29 +0200 | [diff] [blame] | 105 | * Register a callback for peer BAM reset. |
| 106 | * |
| 107 | * @idx - Connection index. |
| 108 | * |
| 109 | * @callback - the callback function that will be called in USB |
| 110 | * driver upon a peer bam reset |
| 111 | * |
| 112 | * @param - context that the caller can supply |
| 113 | * |
| 114 | * @return 0 on success, negative value on error |
| 115 | * |
| 116 | */ |
| 117 | int usb_bam_register_peer_reset_cb(u8 idx, |
| 118 | int (*callback)(void *), void *param); |
| 119 | |
| 120 | /** |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 121 | * Disconnect USB-to-Periperal SPS connection. |
| 122 | * |
| 123 | * @idx - Connection index. |
| 124 | * |
| 125 | * @return 0 on success, negative value on error |
| 126 | */ |
| 127 | int usb_bam_disconnect_pipe(u8 idx); |
| 128 | |
| 129 | /** |
| 130 | * Returns usb bam connection parameters. |
| 131 | * |
| 132 | * @conn_idx - Connection index. |
| 133 | * |
| 134 | * @usb_bam_pipe_dir - Usb pipe direction to/from peripheral. |
| 135 | * |
| 136 | * @usb_bam_handle - Usb bam handle. |
| 137 | * |
| 138 | * @usb_bam_pipe_idx - Usb bam pipe index. |
| 139 | * |
| 140 | * @peer_pipe_idx - Peer pipe index. |
| 141 | * |
| 142 | * @desc_fifo - Descriptor fifo parameters. |
| 143 | * |
| 144 | * @data_fifo - Data fifo parameters. |
| 145 | * |
| 146 | */ |
| 147 | void get_bam2bam_connection_info(u8 conn_idx, enum usb_bam_pipe_dir pipe_dir, |
| 148 | u32 *usb_bam_handle, u32 *usb_bam_pipe_idx, u32 *peer_pipe_idx, |
| 149 | struct sps_mem_buffer *desc_fifo, struct sps_mem_buffer *data_fifo); |
| 150 | |
Amit Blay | 0c929f4 | 2012-12-26 12:02:29 +0200 | [diff] [blame] | 151 | /** |
| 152 | * Resets the entire USB BAM. |
| 153 | * |
| 154 | */ |
| 155 | int usb_bam_reset(void); |
| 156 | |
| 157 | /** |
| 158 | * Indicates if the client of the USB BAM is ready to start |
| 159 | * sending/receiving transfers. |
| 160 | * |
| 161 | * @ready - TRUE to enable, FALSE to disable. |
| 162 | * |
| 163 | */ |
| 164 | int usb_bam_client_ready(bool ready); |
| 165 | |
Ofir Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 166 | #else |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 167 | static inline int usb_bam_connect(u8 idx, u32 *src_pipe_idx, u32 *dst_pipe_idx) |
Amit Blay | e5bb35e | 2012-05-08 20:38:20 +0300 | [diff] [blame] | 168 | { |
| 169 | return -ENODEV; |
| 170 | } |
| 171 | |
Ofir Cohen | ce5e3f2 | 2012-11-16 15:47:40 +0200 | [diff] [blame] | 172 | static inline int usb_bam_connect_ipa( |
| 173 | struct usb_bam_connect_ipa_params *ipa_params) |
| 174 | { |
| 175 | return -ENODEV; |
| 176 | } |
| 177 | |
| 178 | static inline int usb_bam_disconnect_ipa(u8 idx, |
| 179 | struct usb_bam_connect_ipa_params *ipa_params) |
| 180 | { |
| 181 | return -ENODEV; |
| 182 | } |
| 183 | |
Amit Blay | e5bb35e | 2012-05-08 20:38:20 +0300 | [diff] [blame] | 184 | static inline int usb_bam_register_wake_cb(u8 idx, |
| 185 | int (*callback)(void *), void* param) |
Ofir Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 186 | { |
| 187 | return -ENODEV; |
| 188 | } |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 189 | |
Amit Blay | 0c929f4 | 2012-12-26 12:02:29 +0200 | [diff] [blame] | 190 | static inline int usb_bam_register_peer_reset_cb(u8 idx, |
| 191 | int (*callback)(void *), void *param) |
| 192 | { |
| 193 | return -ENODEV; |
| 194 | } |
| 195 | |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 196 | static inline int usb_bam_disconnect_pipe(u8 idx) |
| 197 | { |
| 198 | return -ENODEV; |
| 199 | } |
| 200 | |
| 201 | static inline void get_bam2bam_connection_info(u8 conn_idx, |
| 202 | enum usb_bam_pipe_dir pipe_dir, u32 *usb_bam_handle, |
| 203 | u32 *usb_bam_pipe_idx, u32 *peer_pipe_idx, |
| 204 | struct sps_mem_buffer *desc_fifo, struct sps_mem_buffer *data_fifo) |
| 205 | { |
| 206 | return; |
| 207 | } |
Amit Blay | 0c929f4 | 2012-12-26 12:02:29 +0200 | [diff] [blame] | 208 | |
| 209 | static inline int usb_bam_reset(void) |
| 210 | { |
| 211 | return -ENODEV; |
| 212 | } |
| 213 | |
| 214 | static inline int usb_bam_client_ready(bool ready) |
| 215 | { |
| 216 | return -ENODEV; |
| 217 | } |
| 218 | |
Ofir Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 219 | #endif |
| 220 | #endif /* _USB_BAM_H_ */ |