Amit Blay | e5bb35e | 2012-05-08 20:38:20 +0300 | [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 | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 16 | |
| 17 | /** |
Amit Blay | e5bb35e | 2012-05-08 20:38:20 +0300 | [diff] [blame] | 18 | * 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 | */ |
| 25 | enum usb_bam_pipe_dir { |
| 26 | USB_TO_PEER_PERIPHERAL, |
| 27 | PEER_PERIPHERAL_TO_USB, |
| 28 | }; |
| 29 | |
| 30 | #ifdef CONFIG_USB_BAM |
| 31 | /** |
Ofir Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 32 | * 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 Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 47 | 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] | 48 | |
| 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 | */ |
| 59 | int usb_bam_register_wake_cb(u8 idx, |
| 60 | int (*callback)(void *), void* param); |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * Disconnect USB-to-Periperal SPS connection. |
| 64 | * |
| 65 | * @idx - Connection index. |
| 66 | * |
| 67 | * @return 0 on success, negative value on error |
| 68 | */ |
| 69 | int 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 | */ |
| 89 | void 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 Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 93 | #else |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 94 | 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] | 95 | { |
| 96 | return -ENODEV; |
| 97 | } |
| 98 | |
| 99 | static inline int usb_bam_register_wake_cb(u8 idx, |
| 100 | int (*callback)(void *), void* param) |
Ofir Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 101 | { |
| 102 | return -ENODEV; |
| 103 | } |
Shimrit Malichi | 255b534 | 2012-08-02 21:01:43 +0300 | [diff] [blame] | 104 | |
| 105 | static inline int usb_bam_disconnect_pipe(u8 idx) |
| 106 | { |
| 107 | return -ENODEV; |
| 108 | } |
| 109 | |
| 110 | static 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 Cohen | c7827e4 | 2011-12-13 20:10:01 +0200 | [diff] [blame] | 117 | #endif |
| 118 | #endif /* _USB_BAM_H_ */ |