Brent Hronik | 4d62771 | 2013-08-27 14:34:22 -0600 | [diff] [blame] | 1 | /* Copyright (c) 2013, The Linux Foundation. All rights reserved. |
| 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 _BAM_DMUX_PRIVATE_H |
| 14 | #define _BAM_DMUX_PRIVATE_H |
| 15 | |
| 16 | #include <linux/types.h> |
| 17 | #include <linux/dma-mapping.h> |
| 18 | |
| 19 | #include <mach/sps.h> |
| 20 | |
| 21 | #define BAM_MUX_HDR_MAGIC_NO 0x33fc |
| 22 | #define BAM_MUX_HDR_CMD_DATA 0 |
| 23 | #define BAM_MUX_HDR_CMD_OPEN 1 |
| 24 | #define BAM_MUX_HDR_CMD_CLOSE 2 |
| 25 | #define BAM_MUX_HDR_CMD_STATUS 3 /* unused */ |
| 26 | #define BAM_MUX_HDR_CMD_OPEN_NO_A2_PC 4 |
| 27 | #define BUFFER_SIZE 2048 |
| 28 | |
| 29 | /** |
| 30 | * struct bam_ops_if - collection of function pointers to allow swappable |
| 31 | * runtime functionality |
| 32 | * @smsm_change_state_ptr: pointer to smsm_change_state function |
| 33 | * @smsm_get_state_ptr: pointer to smsm_get_state function |
| 34 | * @smsm_state_cb_register_ptr: pointer to smsm_state_cb_register function |
| 35 | * @smsm_state_cb_deregister_ptr: pointer to smsm_state_cb_deregister function |
| 36 | * @sps_connect_ptr: pointer to sps_connect function |
| 37 | * @sps_disconnect_ptr: pointer to sps_disconnect function |
| 38 | * @sps_register_bam_device_ptr: pointer to sps_register_bam_device |
| 39 | * @sps_deregister_bam_device_ptr: pointer to sps_deregister_bam_device |
| 40 | * function |
| 41 | * @sps_alloc_endpoint_ptr: pointer to sps_alloc_endpoint function |
| 42 | * @sps_free_endpoint_ptr: pointer to sps_free_endpoint function |
| 43 | * @sps_set_config_ptr: pointer to sps_set_config function |
| 44 | * @sps_get_config_ptr: pointer to sps_get_config function |
| 45 | * @sps_device_reset_ptr: pointer to sps_device_reset function |
| 46 | * @sps_register_event_ptr: pointer to sps_register_event function |
| 47 | * @sps_transfer_one_ptr: pointer to sps_transfer_one function |
| 48 | * @sps_get_iovec_ptr: pointer to sps_get_iovec function |
| 49 | * @sps_get_unused_desc_num_ptr: pointer to sps_get_unused_desc_num function |
| 50 | * @dma_to: enum for the direction of dma operations to device |
| 51 | * @dma_from: enum for the direction of dma operations from device |
| 52 | * |
| 53 | * This struct contains the interface from bam_dmux to smsm and sps. The |
| 54 | * pointers can be swapped out at run time to provide different functionality. |
| 55 | */ |
| 56 | struct bam_ops_if { |
| 57 | /* smsm */ |
| 58 | int (*smsm_change_state_ptr)(uint32_t smsm_entry, |
| 59 | uint32_t clear_mask, uint32_t set_mask); |
| 60 | |
| 61 | uint32_t (*smsm_get_state_ptr)(uint32_t smsm_entry); |
| 62 | |
| 63 | int (*smsm_state_cb_register_ptr)(uint32_t smsm_entry, uint32_t mask, |
| 64 | void (*notify)(void *, uint32_t old_state, uint32_t new_state), |
| 65 | void *data); |
| 66 | |
| 67 | int (*smsm_state_cb_deregister_ptr)(uint32_t smsm_entry, uint32_t mask, |
| 68 | void (*notify)(void *, uint32_t, uint32_t), void *data); |
| 69 | |
| 70 | /* sps */ |
| 71 | int (*sps_connect_ptr)(struct sps_pipe *h, struct sps_connect *connect); |
| 72 | |
| 73 | int (*sps_disconnect_ptr)(struct sps_pipe *h); |
| 74 | |
| 75 | int (*sps_register_bam_device_ptr)( |
| 76 | const struct sps_bam_props *bam_props, |
| 77 | u32 *dev_handle); |
| 78 | |
| 79 | int (*sps_deregister_bam_device_ptr)(u32 dev_handle); |
| 80 | |
| 81 | struct sps_pipe *(*sps_alloc_endpoint_ptr)(void); |
| 82 | |
| 83 | int (*sps_free_endpoint_ptr)(struct sps_pipe *h); |
| 84 | |
| 85 | int (*sps_set_config_ptr)(struct sps_pipe *h, |
| 86 | struct sps_connect *config); |
| 87 | |
| 88 | int (*sps_get_config_ptr)(struct sps_pipe *h, |
| 89 | struct sps_connect *config); |
| 90 | |
| 91 | int (*sps_device_reset_ptr)(u32 dev); |
| 92 | |
| 93 | int (*sps_register_event_ptr)(struct sps_pipe *h, |
| 94 | struct sps_register_event *reg); |
| 95 | |
| 96 | int (*sps_transfer_one_ptr)(struct sps_pipe *h, |
| 97 | u32 addr, u32 size, |
| 98 | void *user, u32 flags); |
| 99 | |
| 100 | int (*sps_get_iovec_ptr)(struct sps_pipe *h, |
| 101 | struct sps_iovec *iovec); |
| 102 | |
| 103 | int (*sps_get_unused_desc_num_ptr)(struct sps_pipe *h, |
| 104 | u32 *desc_num); |
| 105 | |
| 106 | enum dma_data_direction dma_to; |
| 107 | |
| 108 | enum dma_data_direction dma_from; |
| 109 | }; |
| 110 | |
| 111 | /** |
| 112 | * struct bam_mux_hdr - struct which contains bam dmux header info |
| 113 | * @magic_num: magic number placed at start to ensure that it is actually a |
| 114 | * valid bam dmux header |
| 115 | * @reserved: for later use |
| 116 | * @cmd: the command |
| 117 | * @pad_len: the length of padding |
| 118 | * @ch_id: the id of the bam dmux channel that this is sent on |
| 119 | * @pkt_len: the length of the packet that this is the header of |
| 120 | */ |
| 121 | struct bam_mux_hdr { |
| 122 | uint16_t magic_num; |
| 123 | uint8_t reserved; |
| 124 | uint8_t cmd; |
| 125 | uint8_t pad_len; |
| 126 | uint8_t ch_id; |
| 127 | uint16_t pkt_len; |
| 128 | }; |
| 129 | |
| 130 | /** |
| 131 | * struct rx_pkt_info - struct describing an rx packet |
| 132 | * @skb: socket buffer containing the packet |
| 133 | * @dma_address: dma mapped address of the packet |
| 134 | * @work: work_struct for processing the packet |
| 135 | * @list_node: list_head for placing this on a list |
| 136 | */ |
| 137 | struct rx_pkt_info { |
| 138 | struct sk_buff *skb; |
| 139 | dma_addr_t dma_address; |
| 140 | struct work_struct work; |
| 141 | struct list_head list_node; |
| 142 | }; |
| 143 | |
| 144 | /** |
| 145 | * struct tx_pkt_info - struct describing a tx packet |
| 146 | * @skb: socket buffer containing the packet |
| 147 | * @dma_address: dma mapped address of the packet |
| 148 | * @is_cmd: signifies whether this is a command or data packet |
| 149 | * @len: length og the packet |
| 150 | * @work: work_struct for processing this packet |
| 151 | * @list_node: list_head for placing this on a list |
| 152 | * @ts_sec: seconds portion of the timestamp |
| 153 | * @ts_nsec: nanoseconds portion of the timestamp |
| 154 | * |
| 155 | */ |
| 156 | struct tx_pkt_info { |
| 157 | struct sk_buff *skb; |
| 158 | dma_addr_t dma_address; |
| 159 | char is_cmd; |
| 160 | uint32_t len; |
| 161 | struct work_struct work; |
| 162 | struct list_head list_node; |
| 163 | unsigned ts_sec; |
| 164 | unsigned long ts_nsec; |
| 165 | }; |
| 166 | |
| 167 | void msm_bam_dmux_set_bam_ops(struct bam_ops_if *ops); |
| 168 | |
| 169 | void msm_bam_dmux_deinit(void); |
| 170 | |
| 171 | void msm_bam_dmux_reinit(void); |
| 172 | |
| 173 | #endif /* _BAM_DMUX_PRIVATE_H */ |