blob: b3fb8af1629d7017e727e14945195d28e5036040 [file] [log] [blame]
Shimrit Malichi83df3ff2013-03-10 13:16:12 +02001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Ofir Cohenc7827e42011-12-13 20:10:01 +02002 *
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 Malichi255b5342012-08-02 21:01:43 +030015#include "sps.h"
Ofir Cohence5e3f22012-11-16 15:47:40 +020016#include <mach/ipa.h>
Ofir Cohenc7827e42011-12-13 20:10:01 +020017
18/**
Amit Blaye5bb35e2012-05-08 20:38:20 +030019 * 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 */
26enum usb_bam_pipe_dir {
27 USB_TO_PEER_PERIPHERAL,
28 PEER_PERIPHERAL_TO_USB,
29};
30
Ofir Cohence5e3f22012-11-16 15:47:40 +020031struct 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 Blaye5bb35e2012-05-08 20:38:20 +030047#ifdef CONFIG_USB_BAM
48/**
Ofir Cohenc7827e42011-12-13 20:10:01 +020049 * 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 Malichi255b5342012-08-02 21:01:43 +030064int usb_bam_connect(u8 idx, u32 *src_pipe_idx, u32 *dst_pipe_idx);
Amit Blaye5bb35e2012-05-08 20:38:20 +030065
66/**
Ofir Cohence5e3f22012-11-16 15:47:40 +020067 * 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 */
76int 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 */
88int usb_bam_disconnect_ipa(u8 idx,
89 struct usb_bam_connect_ipa_params *ipa_params);
90
91/**
Amit Blaye5bb35e2012-05-08 20:38:20 +030092 * 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 */
101int usb_bam_register_wake_cb(u8 idx,
102 int (*callback)(void *), void* param);
Shimrit Malichi255b5342012-08-02 21:01:43 +0300103
104/**
Amit Blay0c929f42012-12-26 12:02:29 +0200105 * 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 */
117int usb_bam_register_peer_reset_cb(u8 idx,
118 int (*callback)(void *), void *param);
119
120/**
Shimrit Malichi255b5342012-08-02 21:01:43 +0300121 * Disconnect USB-to-Periperal SPS connection.
122 *
123 * @idx - Connection index.
124 *
125 * @return 0 on success, negative value on error
126 */
127int 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 */
147void 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 Blay0c929f42012-12-26 12:02:29 +0200151/**
152 * Resets the entire USB BAM.
153 *
154 */
155int 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 */
164int usb_bam_client_ready(bool ready);
165
Ofir Cohenc7827e42011-12-13 20:10:01 +0200166#else
Shimrit Malichi255b5342012-08-02 21:01:43 +0300167static inline int usb_bam_connect(u8 idx, u32 *src_pipe_idx, u32 *dst_pipe_idx)
Amit Blaye5bb35e2012-05-08 20:38:20 +0300168{
169 return -ENODEV;
170}
171
Ofir Cohence5e3f22012-11-16 15:47:40 +0200172static inline int usb_bam_connect_ipa(
173 struct usb_bam_connect_ipa_params *ipa_params)
174{
175 return -ENODEV;
176}
177
178static inline int usb_bam_disconnect_ipa(u8 idx,
179 struct usb_bam_connect_ipa_params *ipa_params)
180{
181 return -ENODEV;
182}
183
Amit Blaye5bb35e2012-05-08 20:38:20 +0300184static inline int usb_bam_register_wake_cb(u8 idx,
185 int (*callback)(void *), void* param)
Ofir Cohenc7827e42011-12-13 20:10:01 +0200186{
187 return -ENODEV;
188}
Shimrit Malichi255b5342012-08-02 21:01:43 +0300189
Amit Blay0c929f42012-12-26 12:02:29 +0200190static inline int usb_bam_register_peer_reset_cb(u8 idx,
191 int (*callback)(void *), void *param)
192{
193 return -ENODEV;
194}
195
Shimrit Malichi255b5342012-08-02 21:01:43 +0300196static inline int usb_bam_disconnect_pipe(u8 idx)
197{
198 return -ENODEV;
199}
200
201static 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 Blay0c929f42012-12-26 12:02:29 +0200208
209static inline int usb_bam_reset(void)
210{
211 return -ENODEV;
212}
213
214static inline int usb_bam_client_ready(bool ready)
215{
216 return -ENODEV;
217}
218
Ofir Cohenc7827e42011-12-13 20:10:01 +0200219#endif
220#endif /* _USB_BAM_H_ */