Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
0003 
0004 #ifndef _GDM_MUX_H_
0005 #define _GDM_MUX_H_
0006 
0007 #include <linux/types.h>
0008 #include <linux/usb.h>
0009 #include <linux/list.h>
0010 
0011 #include "gdm_tty.h"
0012 
0013 #define PM_NORMAL 0
0014 #define PM_SUSPEND 1
0015 
0016 #define USB_RT_ACM          (USB_TYPE_CLASS | USB_RECIP_INTERFACE)
0017 
0018 #define START_FLAG 0xA512485A
0019 #define MUX_HEADER_SIZE 14
0020 #define MUX_TX_MAX_SIZE (1024 * 10)
0021 #define MUX_RX_MAX_SIZE (1024 * 30)
0022 #define AT_PKT_TYPE 0xF011
0023 #define DM_PKT_TYPE 0xF010
0024 
0025 #define RETRY_TIMER 30 /* msec */
0026 
0027 struct mux_pkt_header {
0028     __le32 start_flag;
0029     __le32 seq_num;
0030     __le32 payload_size;
0031     __le16 packet_type;
0032     unsigned char data[];
0033 };
0034 
0035 struct mux_tx {
0036     struct urb *urb;
0037     u8 *buf;
0038     int  len;
0039     void (*callback)(void *cb_data);
0040     void *cb_data;
0041 };
0042 
0043 struct mux_rx {
0044     struct list_head free_list;
0045     struct list_head rx_submit_list;
0046     struct list_head to_host_list;
0047     struct urb *urb;
0048     u8 *buf;
0049     void *mux_dev;
0050     u32 offset;
0051     u32 len;
0052     int (*callback)(void *data,
0053             int len,
0054             int tty_index,
0055             struct tty_dev *tty_dev,
0056             int complete);
0057 };
0058 
0059 struct rx_cxt {
0060     struct list_head to_host_list;
0061     struct list_head rx_submit_list;
0062     struct list_head rx_free_list;
0063     spinlock_t to_host_lock;
0064     spinlock_t submit_list_lock;
0065     spinlock_t free_list_lock;
0066 };
0067 
0068 struct mux_dev {
0069     struct usb_device *usbdev;
0070     struct usb_interface *control_intf;
0071     struct usb_interface *data_intf;
0072     struct rx_cxt   rx;
0073     struct delayed_work work_rx;
0074     struct usb_interface *intf;
0075     int usb_state;
0076     int (*rx_cb)(void *data,
0077              int len,
0078              int tty_index,
0079              struct tty_dev *tty_dev,
0080              int complete);
0081     spinlock_t write_lock;
0082     struct tty_dev *tty_dev;
0083 };
0084 
0085 #endif /* _GDM_MUX_H_ */