blob: 47313a7b550a20246f8ee10ea2655d294260ba7d [file] [log] [blame]
Amit Blaye5bb35e2012-05-08 20:38:20 +03001/* 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 Cohenc7827e42011-12-13 20:10:01 +020016
17/**
Amit Blaye5bb35e2012-05-08 20:38:20 +030018 * SPS Pipes direction.
19 *
20 * USB_TO_PEER_PERIPHERAL USB (as Producer) to other
21 * peer peripheral.
22 * PEER_PERIPHERAL_TO_USB Other Peripheral to
23 * USB (as consumer).
24 */
25enum usb_bam_pipe_dir {
26 USB_TO_PEER_PERIPHERAL,
27 PEER_PERIPHERAL_TO_USB,
28};
29
30#ifdef CONFIG_USB_BAM
31/**
Ofir Cohenc7827e42011-12-13 20:10:01 +020032 * Connect USB-to-Periperal SPS connection.
33 *
34 * This function returns the allocated pipes number.
35 *
36 * @idx - Connection index.
37 *
38 * @src_pipe_idx - allocated pipe index - USB as a
39 * source (output)
40 *
41 * @dst_pipe_idx - allocated pipe index - USB as a
42 * destination (output)
43 *
44 * @return 0 on success, negative value on error
45 *
46 */
Shimrit Malichi255b5342012-08-02 21:01:43 +030047int usb_bam_connect(u8 idx, u32 *src_pipe_idx, u32 *dst_pipe_idx);
Amit Blaye5bb35e2012-05-08 20:38:20 +030048
49/**
50 * Register a wakeup callback from peer BAM.
51 *
52 * @idx - Connection index.
53 *
54 * @callback - the callback function
55 *
56 * @return 0 on success, negative value on error
57 *
58 */
59int usb_bam_register_wake_cb(u8 idx,
60 int (*callback)(void *), void* param);
Shimrit Malichi255b5342012-08-02 21:01:43 +030061
62/**
63 * Disconnect USB-to-Periperal SPS connection.
64 *
65 * @idx - Connection index.
66 *
67 * @return 0 on success, negative value on error
68 */
69int usb_bam_disconnect_pipe(u8 idx);
70
71/**
72 * Returns usb bam connection parameters.
73 *
74 * @conn_idx - Connection index.
75 *
76 * @usb_bam_pipe_dir - Usb pipe direction to/from peripheral.
77 *
78 * @usb_bam_handle - Usb bam handle.
79 *
80 * @usb_bam_pipe_idx - Usb bam pipe index.
81 *
82 * @peer_pipe_idx - Peer pipe index.
83 *
84 * @desc_fifo - Descriptor fifo parameters.
85 *
86 * @data_fifo - Data fifo parameters.
87 *
88 */
89void get_bam2bam_connection_info(u8 conn_idx, enum usb_bam_pipe_dir pipe_dir,
90 u32 *usb_bam_handle, u32 *usb_bam_pipe_idx, u32 *peer_pipe_idx,
91 struct sps_mem_buffer *desc_fifo, struct sps_mem_buffer *data_fifo);
92
Ofir Cohenc7827e42011-12-13 20:10:01 +020093#else
Shimrit Malichi255b5342012-08-02 21:01:43 +030094static inline int usb_bam_connect(u8 idx, u32 *src_pipe_idx, u32 *dst_pipe_idx)
Amit Blaye5bb35e2012-05-08 20:38:20 +030095{
96 return -ENODEV;
97}
98
99static inline int usb_bam_register_wake_cb(u8 idx,
100 int (*callback)(void *), void* param)
Ofir Cohenc7827e42011-12-13 20:10:01 +0200101{
102 return -ENODEV;
103}
Shimrit Malichi255b5342012-08-02 21:01:43 +0300104
105static inline int usb_bam_disconnect_pipe(u8 idx)
106{
107 return -ENODEV;
108}
109
110static inline void get_bam2bam_connection_info(u8 conn_idx,
111 enum usb_bam_pipe_dir pipe_dir, u32 *usb_bam_handle,
112 u32 *usb_bam_pipe_idx, u32 *peer_pipe_idx,
113 struct sps_mem_buffer *desc_fifo, struct sps_mem_buffer *data_fifo)
114{
115 return;
116}
Ofir Cohenc7827e42011-12-13 20:10:01 +0200117#endif
118#endif /* _USB_BAM_H_ */