18c2ecf20Sopenharmony_ci/**
28c2ecf20Sopenharmony_ci * @section LICENSE
38c2ecf20Sopenharmony_ci * Copyright (c) 2014 Redpine Signals Inc.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any
68c2ecf20Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above
78c2ecf20Sopenharmony_ci * copyright notice and this permission notice appear in all copies.
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
108c2ecf20Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
118c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
128c2ecf20Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
138c2ecf20Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
148c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
158c2ecf20Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
168c2ecf20Sopenharmony_ci */
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#ifndef __RSI_USB_INTF__
198c2ecf20Sopenharmony_ci#define __RSI_USB_INTF__
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#include <linux/usb.h>
228c2ecf20Sopenharmony_ci#include "rsi_main.h"
238c2ecf20Sopenharmony_ci#include "rsi_common.h"
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#define RSI_USB_VENDOR_ID	0x1618
268c2ecf20Sopenharmony_ci#define RSI_USB_PID_9113	0x9113
278c2ecf20Sopenharmony_ci#define RSI_USB_PID_9116	0x9116
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#define USB_INTERNAL_REG_1           0x25000
308c2ecf20Sopenharmony_ci#define RSI_USB_READY_MAGIC_NUM      0xab
318c2ecf20Sopenharmony_ci#define FW_STATUS_REG                0x41050012
328c2ecf20Sopenharmony_ci#define RSI_TA_HOLD_REG              0x22000844
338c2ecf20Sopenharmony_ci#define RSI_FW_WDT_DISABLE_REQ	     0x69
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define USB_VENDOR_REGISTER_READ     0x15
368c2ecf20Sopenharmony_ci#define USB_VENDOR_REGISTER_WRITE    0x16
378c2ecf20Sopenharmony_ci#define RSI_USB_TX_HEAD_ROOM         128
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define MAX_RX_URBS                  2
408c2ecf20Sopenharmony_ci#define MAX_BULK_EP                  8
418c2ecf20Sopenharmony_ci#define WLAN_EP                      1
428c2ecf20Sopenharmony_ci#define BT_EP                        2
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#define RSI_USB_BUF_SIZE	     4096
458c2ecf20Sopenharmony_ci#define RSI_USB_CTRL_BUF_SIZE	     0x04
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#define RSI_MAX_RX_USB_PKT_SIZE	3000
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_cistruct rx_usb_ctrl_block {
508c2ecf20Sopenharmony_ci	u8 *data;
518c2ecf20Sopenharmony_ci	struct urb *rx_urb;
528c2ecf20Sopenharmony_ci	struct sk_buff *rx_skb;
538c2ecf20Sopenharmony_ci	u8 ep_num;
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_cistruct rsi_91x_usbdev {
578c2ecf20Sopenharmony_ci	void *priv;
588c2ecf20Sopenharmony_ci	struct rsi_thread rx_thread;
598c2ecf20Sopenharmony_ci	u8 endpoint;
608c2ecf20Sopenharmony_ci	struct usb_device *usbdev;
618c2ecf20Sopenharmony_ci	struct usb_interface *pfunction;
628c2ecf20Sopenharmony_ci	struct rx_usb_ctrl_block rx_cb[MAX_RX_URBS];
638c2ecf20Sopenharmony_ci	u8 *tx_buffer;
648c2ecf20Sopenharmony_ci	__le16 bulkin_size[MAX_BULK_EP];
658c2ecf20Sopenharmony_ci	u8 bulkin_endpoint_addr[MAX_BULK_EP];
668c2ecf20Sopenharmony_ci	__le16 bulkout_size[MAX_BULK_EP];
678c2ecf20Sopenharmony_ci	u8 bulkout_endpoint_addr[MAX_BULK_EP];
688c2ecf20Sopenharmony_ci	u32 tx_blk_size;
698c2ecf20Sopenharmony_ci	u8 write_fail;
708c2ecf20Sopenharmony_ci	struct sk_buff_head rx_q;
718c2ecf20Sopenharmony_ci};
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_cistatic inline int rsi_usb_check_queue_status(struct rsi_hw *adapter, u8 q_num)
748c2ecf20Sopenharmony_ci{
758c2ecf20Sopenharmony_ci	/* In USB, there isn't any need to check the queue status */
768c2ecf20Sopenharmony_ci	return QUEUE_NOT_FULL;
778c2ecf20Sopenharmony_ci}
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_cistatic inline int rsi_usb_event_timeout(struct rsi_hw *adapter)
808c2ecf20Sopenharmony_ci{
818c2ecf20Sopenharmony_ci	return EVENT_WAIT_FOREVER;
828c2ecf20Sopenharmony_ci}
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_civoid rsi_usb_rx_thread(struct rsi_common *common);
858c2ecf20Sopenharmony_ci#endif
86