2015-08-18 19:03:09 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2019-11-09 10:12:08 +00:00
|
|
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
|
|
|
*
|
2015-08-18 19:03:09 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
2019-11-09 10:12:08 +00:00
|
|
|
*****************************************************************************/
|
2015-08-18 19:03:09 +00:00
|
|
|
#define _HAL_USB_C_
|
|
|
|
|
|
|
|
#include <drv_types.h>
|
|
|
|
#include <hal_data.h>
|
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
int usb_init_recv_priv(_adapter *padapter, u16 ini_in_buf_sz)
|
|
|
|
{
|
|
|
|
struct recv_priv *precvpriv = &padapter->recvpriv;
|
|
|
|
int i, res = _SUCCESS;
|
|
|
|
struct recv_buf *precvbuf;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
#ifdef PLATFORM_LINUX
|
|
|
|
tasklet_init(&precvpriv->recv_tasklet,
|
2019-11-09 10:12:08 +00:00
|
|
|
(void(*)(unsigned long))usb_recv_tasklet,
|
|
|
|
(unsigned long)padapter);
|
2017-05-11 18:47:23 +00:00
|
|
|
#endif /* PLATFORM_LINUX */
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef PLATFORM_FREEBSD
|
|
|
|
#ifdef CONFIG_RX_INDICATE_QUEUE
|
2017-05-11 18:47:23 +00:00
|
|
|
TASK_INIT(&precvpriv->rx_indicate_tasklet, 0, rtw_rx_indicate_tasklet, padapter);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* CONFIG_RX_INDICATE_QUEUE */
|
2017-05-11 18:47:23 +00:00
|
|
|
#endif /* PLATFORM_FREEBSD */
|
|
|
|
|
|
|
|
#ifdef CONFIG_USB_INTERRUPT_IN_PIPE
|
|
|
|
#ifdef PLATFORM_LINUX
|
|
|
|
precvpriv->int_in_urb = usb_alloc_urb(0, GFP_KERNEL);
|
2019-11-09 10:12:08 +00:00
|
|
|
if (precvpriv->int_in_urb == NULL) {
|
2017-05-11 18:47:23 +00:00
|
|
|
res = _FAIL;
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("alloc_urb for interrupt in endpoint fail !!!!\n");
|
2017-05-11 18:47:23 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
#endif /* PLATFORM_LINUX */
|
|
|
|
precvpriv->int_in_buf = rtw_zmalloc(ini_in_buf_sz);
|
2019-11-09 10:12:08 +00:00
|
|
|
if (precvpriv->int_in_buf == NULL) {
|
2017-05-11 18:47:23 +00:00
|
|
|
res = _FAIL;
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("alloc_mem for interrupt in endpoint fail !!!!\n");
|
2017-05-11 18:47:23 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_USB_INTERRUPT_IN_PIPE */
|
|
|
|
|
|
|
|
/* init recv_buf */
|
|
|
|
_rtw_init_queue(&precvpriv->free_recv_buf_queue);
|
|
|
|
_rtw_init_queue(&precvpriv->recv_buf_pending_queue);
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifndef CONFIG_USE_USB_BUFFER_ALLOC_RX
|
2017-05-11 18:47:23 +00:00
|
|
|
/* this is used only when RX_IOBUF is sk_buff */
|
|
|
|
skb_queue_head_init(&precvpriv->free_recv_skb_queue);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
RTW_INFO("NR_RECVBUFF: %d\n", NR_RECVBUFF);
|
|
|
|
RTW_INFO("MAX_RECVBUF_SZ: %d\n", MAX_RECVBUF_SZ);
|
|
|
|
precvpriv->pallocated_recv_buf = rtw_zmalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4);
|
|
|
|
if (precvpriv->pallocated_recv_buf == NULL) {
|
|
|
|
res = _FAIL;
|
2017-05-11 18:47:23 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
precvpriv->precv_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_recv_buf), 4);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
precvbuf = (struct recv_buf *)precvpriv->precv_buf;
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
for (i = 0; i < NR_RECVBUFF ; i++) {
|
2017-05-11 18:47:23 +00:00
|
|
|
_rtw_init_listhead(&precvbuf->list);
|
|
|
|
|
|
|
|
_rtw_spinlock_init(&precvbuf->recvbuf_lock);
|
|
|
|
|
|
|
|
precvbuf->alloc_sz = MAX_RECVBUF_SZ;
|
|
|
|
|
|
|
|
res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf);
|
2019-11-09 10:12:08 +00:00
|
|
|
if (res == _FAIL)
|
2017-05-11 18:47:23 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
precvbuf->ref_cnt = 0;
|
2019-11-09 10:12:08 +00:00
|
|
|
precvbuf->adapter = padapter;
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* rtw_list_insert_tail(&precvbuf->list, &(precvpriv->free_recv_buf_queue.queue)); */
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
precvbuf++;
|
|
|
|
}
|
|
|
|
|
|
|
|
precvpriv->free_recv_buf_queue_cnt = NR_RECVBUFF;
|
|
|
|
|
|
|
|
#if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD)
|
|
|
|
|
|
|
|
skb_queue_head_init(&precvpriv->rx_skb_queue);
|
|
|
|
|
|
|
|
#ifdef CONFIG_RX_INDICATE_QUEUE
|
|
|
|
memset(&precvpriv->rx_indicate_queue, 0, sizeof(struct ifqueue));
|
|
|
|
mtx_init(&precvpriv->rx_indicate_queue.ifq_mtx, "rx_indicate_queue", NULL, MTX_DEF);
|
|
|
|
#endif /* CONFIG_RX_INDICATE_QUEUE */
|
|
|
|
|
|
|
|
#ifdef CONFIG_PREALLOC_RECV_SKB
|
|
|
|
{
|
|
|
|
int i;
|
2019-11-09 10:12:08 +00:00
|
|
|
SIZE_PTR tmpaddr = 0;
|
|
|
|
SIZE_PTR alignment = 0;
|
|
|
|
struct sk_buff *pskb = NULL;
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("NR_PREALLOC_RECV_SKB: %d\n", NR_PREALLOC_RECV_SKB);
|
2017-05-11 18:47:23 +00:00
|
|
|
#ifdef CONFIG_FIX_NR_BULKIN_BUFFER
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("Enable CONFIG_FIX_NR_BULKIN_BUFFER\n");
|
2017-05-11 18:47:23 +00:00
|
|
|
#endif
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
for (i = 0; i < NR_PREALLOC_RECV_SKB; i++) {
|
2017-05-11 18:47:23 +00:00
|
|
|
#ifdef CONFIG_PREALLOC_RX_SKB_BUFFER
|
|
|
|
pskb = rtw_alloc_skb_premem(MAX_RECVBUF_SZ);
|
|
|
|
#else
|
|
|
|
pskb = rtw_skb_alloc(MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* CONFIG_PREALLOC_RX_SKB_BUFFER */
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (pskb) {
|
|
|
|
#ifdef PLATFORM_FREEBSD
|
2017-05-11 18:47:23 +00:00
|
|
|
pskb->dev = padapter->pifp;
|
2019-11-09 10:12:08 +00:00
|
|
|
#else
|
2017-05-11 18:47:23 +00:00
|
|
|
pskb->dev = padapter->pnetdev;
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* PLATFORM_FREEBSD */
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
#ifndef CONFIG_PREALLOC_RX_SKB_BUFFER
|
|
|
|
tmpaddr = (SIZE_PTR)pskb->data;
|
2019-11-09 10:12:08 +00:00
|
|
|
alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1);
|
2017-05-11 18:47:23 +00:00
|
|
|
skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment));
|
|
|
|
#endif
|
|
|
|
skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PREALLOC_RECV_SKB */
|
|
|
|
|
|
|
|
#endif /* defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD) */
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
void usb_free_recv_priv(_adapter *padapter, u16 ini_in_buf_sz)
|
2017-05-11 18:47:23 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct recv_buf *precvbuf;
|
|
|
|
struct recv_priv *precvpriv = &padapter->recvpriv;
|
|
|
|
|
|
|
|
precvbuf = (struct recv_buf *)precvpriv->precv_buf;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
for (i = 0; i < NR_RECVBUFF ; i++) {
|
2017-05-11 18:47:23 +00:00
|
|
|
rtw_os_recvbuf_resource_free(padapter, precvbuf);
|
|
|
|
precvbuf++;
|
|
|
|
}
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (precvpriv->pallocated_recv_buf)
|
|
|
|
rtw_mfree(precvpriv->pallocated_recv_buf, NR_RECVBUFF * sizeof(struct recv_buf) + 4);
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_USB_INTERRUPT_IN_PIPE
|
|
|
|
#ifdef PLATFORM_LINUX
|
2019-11-09 10:12:08 +00:00
|
|
|
if (precvpriv->int_in_urb)
|
2017-05-11 18:47:23 +00:00
|
|
|
usb_free_urb(precvpriv->int_in_urb);
|
|
|
|
#endif
|
2019-11-09 10:12:08 +00:00
|
|
|
if (precvpriv->int_in_buf)
|
2017-05-11 18:47:23 +00:00
|
|
|
rtw_mfree(precvpriv->int_in_buf, ini_in_buf_sz);
|
|
|
|
#endif /* CONFIG_USB_INTERRUPT_IN_PIPE */
|
|
|
|
|
|
|
|
#ifdef PLATFORM_LINUX
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (skb_queue_len(&precvpriv->rx_skb_queue))
|
|
|
|
RTW_WARN("rx_skb_queue not empty\n");
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
rtw_skb_queue_purge(&precvpriv->rx_skb_queue);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (skb_queue_len(&precvpriv->free_recv_skb_queue))
|
|
|
|
RTW_WARN("free_recv_skb_queue not empty, %d\n", skb_queue_len(&precvpriv->free_recv_skb_queue));
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
#if !defined(CONFIG_USE_USB_BUFFER_ALLOC_RX)
|
2019-11-09 10:12:08 +00:00
|
|
|
#if defined(CONFIG_PREALLOC_RECV_SKB) && defined(CONFIG_PREALLOC_RX_SKB_BUFFER)
|
2017-05-11 18:47:23 +00:00
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
while ((skb = skb_dequeue(&precvpriv->free_recv_skb_queue)) != NULL) {
|
2017-05-11 18:47:23 +00:00
|
|
|
if (rtw_free_skb_premem(skb) != 0)
|
|
|
|
rtw_skb_free(skb);
|
|
|
|
}
|
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
#else
|
2017-05-11 18:47:23 +00:00
|
|
|
rtw_skb_queue_purge(&precvpriv->free_recv_skb_queue);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* defined(CONFIG_PREALLOC_RX_SKB_BUFFER) && defined(CONFIG_PREALLOC_RECV_SKB) */
|
2017-05-11 18:47:23 +00:00
|
|
|
#endif /* !defined(CONFIG_USE_USB_BUFFER_ALLOC_RX) */
|
|
|
|
|
|
|
|
#endif /* PLATFORM_LINUX */
|
|
|
|
|
|
|
|
#ifdef PLATFORM_FREEBSD
|
|
|
|
struct sk_buff *pskb;
|
|
|
|
while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue)))
|
|
|
|
rtw_skb_free(pskb);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#if !defined(CONFIG_USE_USB_BUFFER_ALLOC_RX)
|
2017-05-11 18:47:23 +00:00
|
|
|
rtw_skb_queue_purge(&precvpriv->free_recv_skb_queue);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_RX_INDICATE_QUEUE
|
|
|
|
struct mbuf *m;
|
|
|
|
for (;;) {
|
|
|
|
IF_DEQUEUE(&precvpriv->rx_indicate_queue, m);
|
|
|
|
if (m == NULL)
|
|
|
|
break;
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_os_pkt_free(m);
|
2017-05-11 18:47:23 +00:00
|
|
|
}
|
|
|
|
mtx_destroy(&precvpriv->rx_indicate_queue.ifq_mtx);
|
|
|
|
#endif /* CONFIG_RX_INDICATE_QUEUE */
|
|
|
|
|
|
|
|
#endif /* PLATFORM_FREEBSD */
|
|
|
|
}
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_FW_C2H_REG
|
|
|
|
void usb_c2h_hisr_hdl(_adapter *adapter, u8 *buf)
|
|
|
|
{
|
|
|
|
u8 *c2h_evt = buf;
|
|
|
|
u8 id, seq, plen;
|
|
|
|
u8 *payload;
|
|
|
|
|
|
|
|
if (rtw_hal_c2h_reg_hdr_parse(adapter, buf, &id, &seq, &plen, &payload) != _SUCCESS)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
RTW_PRINT("%s C2H == %d\n", __func__, id);
|
|
|
|
|
|
|
|
if (rtw_hal_c2h_id_handle_directly(adapter, id, seq, plen, payload)) {
|
|
|
|
/* Handle directly */
|
|
|
|
rtw_hal_c2h_handler(adapter, id, seq, plen, payload);
|
|
|
|
|
|
|
|
/* Replace with special pointer to trigger c2h_evt_clear only */
|
|
|
|
if (rtw_cbuf_push(adapter->evtpriv.c2h_queue, (void*)&adapter->evtpriv) != _SUCCESS)
|
|
|
|
RTW_ERR("%s rtw_cbuf_push fail\n", __func__);
|
|
|
|
} else {
|
|
|
|
c2h_evt = rtw_malloc(C2H_REG_LEN);
|
|
|
|
if (c2h_evt != NULL) {
|
2021-10-12 14:53:20 +00:00
|
|
|
memcpy(c2h_evt, buf, C2H_REG_LEN);
|
2019-11-09 10:12:08 +00:00
|
|
|
if (rtw_cbuf_push(adapter->evtpriv.c2h_queue, (void*)c2h_evt) != _SUCCESS)
|
|
|
|
RTW_ERR("%s rtw_cbuf_push fail\n", __func__);
|
|
|
|
} else {
|
|
|
|
/* Error handling for malloc fail */
|
|
|
|
if (rtw_cbuf_push(adapter->evtpriv.c2h_queue, (void*)NULL) != _SUCCESS)
|
|
|
|
RTW_ERR("%s rtw_cbuf_push fail\n", __func__);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_set_workitem(&adapter->evtpriv.c2h_wk);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
#ifdef CONFIG_USB_SUPPORT_ASYNC_VDN_REQ
|
|
|
|
int usb_write_async(struct usb_device *udev, u32 addr, void *pdata, u16 len)
|
|
|
|
{
|
|
|
|
u8 request;
|
|
|
|
u16 wvalue;
|
|
|
|
u16 index;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
request = REALTEK_USB_VENQT_CMD_REQ;
|
2019-11-09 10:12:08 +00:00
|
|
|
index = REALTEK_USB_VENQT_CMD_IDX;/* n/a */
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
wvalue = (u16)(addr & 0x0000ffff);
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2021-10-14 13:56:07 +00:00
|
|
|
ret = _usbctrl_vendorreq_async_write(udev, request, wvalue, index, pdata, len, REALTEK_USB_VENQT_WRITE);
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int usb_async_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val)
|
|
|
|
{
|
|
|
|
u8 data;
|
|
|
|
int ret;
|
2019-11-09 10:12:08 +00:00
|
|
|
struct dvobj_priv *pdvobjpriv = (struct dvobj_priv *)pintfhdl->pintf_dev;
|
|
|
|
struct usb_device *udev = pdvobjpriv->pusbdev;
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
data = val;
|
|
|
|
ret = usb_write_async(udev, addr, &data, 1);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int usb_async_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val)
|
|
|
|
{
|
|
|
|
u16 data;
|
|
|
|
int ret;
|
2019-11-09 10:12:08 +00:00
|
|
|
struct dvobj_priv *pdvobjpriv = (struct dvobj_priv *)pintfhdl->pintf_dev;
|
|
|
|
struct usb_device *udev = pdvobjpriv->pusbdev;
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
data = val;
|
|
|
|
ret = usb_write_async(udev, addr, &data, 2);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int usb_async_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val)
|
|
|
|
{
|
|
|
|
u32 data;
|
|
|
|
int ret;
|
2019-11-09 10:12:08 +00:00
|
|
|
struct dvobj_priv *pdvobjpriv = (struct dvobj_priv *)pintfhdl->pintf_dev;
|
|
|
|
struct usb_device *udev = pdvobjpriv->pusbdev;
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
data = val;
|
|
|
|
ret = usb_write_async(udev, addr, &data, 4);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_USB_SUPPORT_ASYNC_VDN_REQ */
|
|
|
|
|
|
|
|
u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr)
|
|
|
|
{
|
2021-08-21 16:48:55 +00:00
|
|
|
u16 wvalue = (u16)(addr & 0x0000ffff);
|
2019-11-09 10:12:08 +00:00
|
|
|
u8 data = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/* WLANON PAGE0_REG needs to add an offset 0x8000 */
|
|
|
|
#if defined(CONFIG_RTL8710B)
|
|
|
|
if(wvalue >= 0x0000 && wvalue < 0x0100)
|
|
|
|
wvalue |= 0x8000;
|
|
|
|
#endif
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2021-10-14 13:56:07 +00:00
|
|
|
usbctrl_vendorreq(pintfhdl, wvalue, 0, &data, 1, REALTEK_USB_VENQT_READ);
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
return data;
|
2017-05-11 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr)
|
2019-11-09 10:12:08 +00:00
|
|
|
{
|
2021-08-21 16:48:55 +00:00
|
|
|
u16 wvalue = (u16)(addr & 0x0000ffff);
|
|
|
|
u16 data;
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
/* WLANON PAGE0_REG needs to add an offset 0x8000 */
|
|
|
|
#if defined(CONFIG_RTL8710B)
|
|
|
|
if(wvalue >= 0x0000 && wvalue < 0x0100)
|
|
|
|
wvalue |= 0x8000;
|
|
|
|
#endif
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2021-10-14 13:56:07 +00:00
|
|
|
usbctrl_vendorreq(pintfhdl, wvalue, 0, &data, 2, REALTEK_USB_VENQT_READ);
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
return data;
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr)
|
|
|
|
{
|
2021-08-21 16:48:55 +00:00
|
|
|
u16 wvalue = (u16)(addr & 0x0000ffff);
|
|
|
|
u32 data;
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* WLANON PAGE0_REG needs to add an offset 0x8000 */
|
|
|
|
#if defined(CONFIG_RTL8710B)
|
|
|
|
if(wvalue >= 0x0000 && wvalue < 0x0100)
|
|
|
|
wvalue |= 0x8000;
|
|
|
|
#endif
|
|
|
|
|
2021-10-14 13:56:07 +00:00
|
|
|
usbctrl_vendorreq(pintfhdl, wvalue, 0, &data, 4, REALTEK_USB_VENQT_READ);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val)
|
|
|
|
{
|
2021-08-21 16:48:56 +00:00
|
|
|
u16 wvalue = (u16)(addr & 0x0000ffff);
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* WLANON PAGE0_REG needs to add an offset 0x8000 */
|
|
|
|
#if defined(CONFIG_RTL8710B)
|
|
|
|
if(wvalue >= 0x0000 && wvalue < 0x0100)
|
|
|
|
wvalue |= 0x8000;
|
|
|
|
#endif
|
|
|
|
|
2021-10-14 13:56:07 +00:00
|
|
|
return usbctrl_vendorreq(pintfhdl, wvalue, 0, &val, 1, REALTEK_USB_VENQT_WRITE);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val)
|
2019-11-09 10:12:08 +00:00
|
|
|
{
|
2021-08-21 16:48:56 +00:00
|
|
|
u16 wvalue = (u16)(addr & 0x0000ffff);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
/* WLANON PAGE0_REG needs to add an offset 0x8000 */
|
|
|
|
#if defined(CONFIG_RTL8710B)
|
|
|
|
if(wvalue >= 0x0000 && wvalue < 0x0100)
|
|
|
|
wvalue |= 0x8000;
|
|
|
|
#endif
|
|
|
|
|
2021-10-14 13:56:07 +00:00
|
|
|
return usbctrl_vendorreq(pintfhdl, wvalue, 0, &val, 2, REALTEK_USB_VENQT_WRITE);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val)
|
|
|
|
{
|
2021-08-21 16:48:56 +00:00
|
|
|
u16 wvalue = (u16)(addr & 0x0000ffff);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
/* WLANON PAGE0_REG needs to add an offset 0x8000 */
|
|
|
|
#if defined(CONFIG_RTL8710B)
|
|
|
|
if(wvalue >= 0x0000 && wvalue < 0x0100)
|
|
|
|
wvalue |= 0x8000;
|
|
|
|
#endif
|
|
|
|
|
2021-10-14 13:56:07 +00:00
|
|
|
return usbctrl_vendorreq(pintfhdl, wvalue, 0, &val, 4, REALTEK_USB_VENQT_WRITE);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata)
|
|
|
|
{
|
2021-08-21 16:48:57 +00:00
|
|
|
u16 wvalue = (u16)(addr & 0x0000ffff);
|
2019-11-09 10:12:08 +00:00
|
|
|
u8 buf[VENDOR_CMD_MAX_DATA_LEN] = {0};
|
|
|
|
|
2021-08-21 16:48:57 +00:00
|
|
|
if (length > VENDOR_CMD_MAX_DATA_LEN)
|
|
|
|
return -EINVAL;
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2021-08-21 16:48:57 +00:00
|
|
|
memcpy(buf, pdata, length);
|
2021-10-14 13:56:07 +00:00
|
|
|
return usbctrl_vendorreq(pintfhdl, wvalue, 0, buf, (length & 0xffff), REALTEK_USB_VENQT_WRITE);
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void usb_set_intf_ops(_adapter *padapter, struct _io_ops *pops)
|
|
|
|
{
|
2021-10-11 10:07:17 +00:00
|
|
|
memset((u8 *)pops, 0, sizeof(struct _io_ops));
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
pops->_read8 = &usb_read8;
|
|
|
|
pops->_read16 = &usb_read16;
|
|
|
|
pops->_read32 = &usb_read32;
|
|
|
|
pops->_read_mem = &usb_read_mem;
|
|
|
|
pops->_read_port = &usb_read_port;
|
|
|
|
|
|
|
|
pops->_write8 = &usb_write8;
|
|
|
|
pops->_write16 = &usb_write16;
|
|
|
|
pops->_write32 = &usb_write32;
|
|
|
|
pops->_writeN = &usb_writeN;
|
|
|
|
|
|
|
|
#ifdef CONFIG_USB_SUPPORT_ASYNC_VDN_REQ
|
|
|
|
pops->_write8_async = &usb_async_write8;
|
|
|
|
pops->_write16_async = &usb_async_write16;
|
|
|
|
pops->_write32_async = &usb_async_write32;
|
|
|
|
#endif
|
|
|
|
pops->_write_mem = &usb_write_mem;
|
|
|
|
pops->_write_port = &usb_write_port;
|
|
|
|
|
|
|
|
pops->_read_port_cancel = &usb_read_port_cancel;
|
|
|
|
pops->_write_port_cancel = &usb_write_port_cancel;
|
|
|
|
|
|
|
|
#ifdef CONFIG_USB_INTERRUPT_IN_PIPE
|
|
|
|
pops->_read_interrupt = &usb_read_interrupt;
|
|
|
|
#endif
|
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
}
|