12061Sjkh/* SPDX-License-Identifier: GPL-2.0 */
250479Speter/* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
32061Sjkh
438666Sjb#ifndef _GDM_USB_H_
532427Sjb#define _GDM_USB_H_
6111131Sru
7111131Sru#include <linux/types.h>
8217733Sbz#include <linux/usb.h>
9217733Sbz#include <linux/list.h>
1038666Sjb#include <linux/time.h>
1138666Sjb
1238666Sjb#include "gdm_endian.h"
13159363Strhodes#include "hci_packet.h"
1464049Salex
1564049Salex#define PM_NORMAL 0
16116679Ssimokawa#define PM_SUSPEND 1
1766071Smarkm#define AUTO_SUSPEND_TIMER 5000 /* ms */
18116679Ssimokawa
1973504Sobrien#define RX_BUF_SIZE		(1024 * 32)
20204661Simp#define TX_BUF_SIZE		(1024 * 32)
21158962Snetchild#define SDU_BUF_SIZE	2048
2238666Sjb#define MAX_SDU_SIZE	(1024 * 30)
23169597Sdes#define MAX_PACKET_IN_MULTI_SDU	256
24169597Sdes
25169597Sdes#define VID_GCT			0x1076
26169597Sdes#define PID_GDM7240		0x8000
27169597Sdes#define PID_GDM7243		0x9000
28169597Sdes
29169597Sdes#define NETWORK_INTERFACE 1
30169597Sdes#define USB_SC_SCSI 0x06
31217815Sbz#define USB_PR_BULK 0x50
32217815Sbz
33218524Sjhb#define MAX_NUM_SDU_BUF	64
3432427Sjb
3538666Sjbstruct usb_tx {
36108451Sschweikh	struct list_head list;
3738666Sjb	struct urb *urb;
3838666Sjb	u8 *buf;
3938666Sjb	u32 len;
4038666Sjb	void (*callback)(void *cb_data);
4117308Speter	void *cb_data;
42217273Simp	struct tx_cxt *tx;
43217294Simp	u8 is_sdu;
4419175Sbde};
4596205Sjwd
46217297Simpstruct usb_tx_sdu {
47217297Simp	struct list_head list;
4838042Sbde	u8 *buf;
4996205Sjwd	u32 len;
5096205Sjwd	void (*callback)(void *cb_data);
5138042Sbde	void *cb_data;
5296205Sjwd};
53159363Strhodes
54159363Strhodesstruct usb_rx {
5517308Speter	struct list_head to_host_list;
5696205Sjwd	struct list_head free_list;
5796205Sjwd	struct list_head rx_submit_list;
5817308Speter	struct rx_cxt	*rx;
59148330Snetchild	struct urb *urb;
60148330Snetchild	u8 *buf;
61148330Snetchild	int (*callback)(void *cb_data, void *data, int len, int context);
62148330Snetchild	void *cb_data;
63159831Sobrien	void *index;
64148330Snetchild};
65148330Snetchild
66148330Snetchildstruct tx_cxt {
67148330Snetchild	struct list_head sdu_list;
68178653Srwatson	struct list_head hci_list;
69148330Snetchild	struct list_head free_list;
70148330Snetchild	u32 avail_count;
7196205Sjwd	spinlock_t lock;
7296205Sjwd};
7396205Sjwd
74162147Srustruct rx_cxt {
75162147Sru	struct list_head to_host_list;
7698723Sdillon	struct list_head rx_submit_list;
7798723Sdillon	struct list_head free_list;
7898723Sdillon	u32	avail_count;
7938666Sjb	spinlock_t to_host_lock;
8038666Sjb	spinlock_t rx_lock;
8117308Speter	spinlock_t submit_lock;
82123311Speter};
83123311Speter
84123311Speterstruct lte_udev {
85123311Speter	struct usb_device *usbdev;
86175833Sjhb	struct tx_cxt tx;
87175833Sjhb	struct rx_cxt rx;
88169597Sdes	struct delayed_work work_tx;
89169597Sdes	struct delayed_work work_rx;
90169597Sdes	u8 gdm_ed;
91169597Sdes	u8 send_complete;
92159349Simp	u8 tx_stop;
93158962Snetchild	struct usb_interface *intf;
94158962Snetchild	int (*rx_cb)(void *cb_data, void *data, int len, int context);
95158962Snetchild	int usb_state;
96156840Sru	u8 request_mac_addr;
97123311Speter};
98137288Speter
99209128Sraj#endif /* _GDM_USB_H_ */
100209128Sraj