Won Kang | 61e1210 | 2013-07-25 03:36:17 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. |
| 3 | * |
| 4 | * This software is licensed under the terms of the GNU General Public |
| 5 | * License version 2, as published by the Free Software Foundation, and |
| 6 | * may be copied, distributed, and modified under those terms. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
| 14 | #ifndef _GDM_USB_H_ |
| 15 | #define _GDM_USB_H_ |
| 16 | |
Won Kang | 61e1210 | 2013-07-25 03:36:17 +0900 | [diff] [blame] | 17 | #include <linux/types.h> |
| 18 | #include <linux/usb.h> |
| 19 | #include <linux/list.h> |
| 20 | #include <linux/time.h> |
| 21 | |
| 22 | #include "gdm_endian.h" |
| 23 | #include "hci_packet.h" |
| 24 | |
| 25 | #define PM_NORMAL 0 |
| 26 | #define PM_SUSPEND 1 |
| 27 | #define AUTO_SUSPEND_TIMER 5000 /* ms */ |
| 28 | |
| 29 | #define RX_BUF_SIZE (1024*32) |
| 30 | #define TX_BUF_SIZE (1024*32) |
| 31 | #define SDU_BUF_SIZE 2048 |
| 32 | #define MAX_SDU_SIZE (1024*30) |
| 33 | #define MAX_PACKET_IN_MULTI_SDU 256 |
| 34 | |
| 35 | #define VID_GCT 0x1076 |
| 36 | #define PID_GDM7240 0x8000 |
| 37 | #define PID_GDM7243 0x9000 |
| 38 | |
| 39 | #define NETWORK_INTERFACE 1 |
| 40 | #define USB_SC_SCSI 0x06 |
| 41 | #define USB_PR_BULK 0x50 |
| 42 | |
| 43 | #define MAX_NUM_SDU_BUF 64 |
| 44 | |
| 45 | struct usb_tx { |
| 46 | struct list_head list; |
| 47 | struct urb *urb; |
| 48 | u8 *buf; |
| 49 | u32 len; |
| 50 | void (*callback)(void *cb_data); |
| 51 | void *cb_data; |
| 52 | struct tx_cxt *tx; |
| 53 | u8 is_sdu; |
| 54 | }; |
| 55 | |
| 56 | struct usb_tx_sdu { |
| 57 | struct list_head list; |
| 58 | u8 *buf; |
| 59 | u32 len; |
| 60 | void (*callback)(void *cb_data); |
| 61 | void *cb_data; |
| 62 | }; |
| 63 | |
| 64 | struct usb_rx { |
| 65 | struct list_head to_host_list; |
| 66 | struct list_head free_list; |
| 67 | struct list_head rx_submit_list; |
| 68 | struct rx_cxt *rx; |
| 69 | struct urb *urb; |
| 70 | u8 *buf; |
| 71 | int (*callback)(void *cb_data, void *data, int len, int context); |
| 72 | void *cb_data; |
| 73 | void *index; |
| 74 | }; |
| 75 | |
| 76 | struct tx_cxt { |
| 77 | struct list_head sdu_list; |
| 78 | struct list_head hci_list; |
| 79 | struct list_head free_list; |
| 80 | u32 avail_count; |
| 81 | spinlock_t lock; |
| 82 | }; |
| 83 | |
| 84 | struct rx_cxt { |
| 85 | struct list_head to_host_list; |
| 86 | struct list_head rx_submit_list; |
| 87 | struct list_head free_list; |
| 88 | u32 avail_count; |
| 89 | spinlock_t to_host_lock; |
| 90 | spinlock_t rx_lock; |
| 91 | spinlock_t submit_lock; |
| 92 | }; |
| 93 | |
| 94 | struct lte_udev { |
| 95 | struct usb_device *usbdev; |
| 96 | struct gdm_endian gdm_ed; |
| 97 | struct tx_cxt tx; |
| 98 | struct rx_cxt rx; |
| 99 | struct delayed_work work_tx; |
| 100 | struct delayed_work work_rx; |
| 101 | u8 send_complete; |
| 102 | u8 tx_stop; |
| 103 | struct usb_interface *intf; |
| 104 | int (*rx_cb)(void *cb_data, void *data, int len, int context); |
| 105 | int usb_state; |
| 106 | u8 request_mac_addr; |
| 107 | }; |
| 108 | |
| 109 | #endif /* _GDM_USB_H_ */ |