1 // SPDX-License-Identifier: GPL-2.0
2 /******************************************************************************
5 * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
6 * Linux device driver for RTL8192SU
8 * Modifications for inclusion into the Linux staging tree are
9 * Copyright(c) 2010 Larry Finger. All rights reserved.
11 * Contact information:
15 ******************************************************************************/
19 #include "osdep_service.h"
20 #include "drv_types.h"
21 #include "osdep_intf.h"
23 #include "recv_osdep.h"
25 static u8 usb_read8(struct intf_hdl *intfhdl, u32 addr)
33 struct intf_priv *intfpriv = intfhdl->pintfpriv;
36 requesttype = 0x01; /* read_in */
38 wvalue = (u16)(addr & 0x0000ffff);
40 r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, &data, len,
42 return (u8)(le32_to_cpu(data) & 0x0ff);
45 static u16 usb_read16(struct intf_hdl *intfhdl, u32 addr)
53 struct intf_priv *intfpriv = intfhdl->pintfpriv;
56 requesttype = 0x01; /* read_in */
58 wvalue = (u16)(addr & 0x0000ffff);
60 r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, &data, len,
62 return (u16)(le32_to_cpu(data) & 0xffff);
65 static u32 usb_read32(struct intf_hdl *intfhdl, u32 addr)
73 struct intf_priv *intfpriv = intfhdl->pintfpriv;
76 requesttype = 0x01; /* read_in */
78 wvalue = (u16)(addr & 0x0000ffff);
80 r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, &data, len,
82 return le32_to_cpu(data);
85 static void usb_write8(struct intf_hdl *intfhdl, u32 addr, u8 val)
93 struct intf_priv *intfpriv = intfhdl->pintfpriv;
96 requesttype = 0x00; /* write_out */
98 wvalue = (u16)(addr & 0x0000ffff);
100 data = cpu_to_le32((u32)val & 0x000000ff);
101 r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, &data, len,
105 static void usb_write16(struct intf_hdl *intfhdl, u32 addr, u16 val)
113 struct intf_priv *intfpriv = intfhdl->pintfpriv;
116 requesttype = 0x00; /* write_out */
118 wvalue = (u16)(addr & 0x0000ffff);
120 data = cpu_to_le32((u32)val & 0x0000ffff);
121 r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, &data, len,
125 static void usb_write32(struct intf_hdl *intfhdl, u32 addr, u32 val)
133 struct intf_priv *intfpriv = intfhdl->pintfpriv;
136 requesttype = 0x00; /* write_out */
138 wvalue = (u16)(addr & 0x0000ffff);
140 data = cpu_to_le32(val);
141 r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, &data, len,
145 void r8712_usb_set_intf_option(u32 *option)
147 *option = ((*option) | _INTF_ASYNC_);
150 static void usb_intf_hdl_init(u8 *priv)
154 static void usb_intf_hdl_unload(u8 *priv)
158 static void usb_intf_hdl_open(u8 *priv)
162 static void usb_intf_hdl_close(u8 *priv)
166 void r8712_usb_set_intf_funs(struct intf_hdl *intfhdl)
168 intfhdl->intf_hdl_init = usb_intf_hdl_init;
169 intfhdl->intf_hdl_unload = usb_intf_hdl_unload;
170 intfhdl->intf_hdl_open = usb_intf_hdl_open;
171 intfhdl->intf_hdl_close = usb_intf_hdl_close;
174 void r8712_usb_set_intf_ops(struct _io_ops *ops)
176 memset((u8 *)ops, 0, sizeof(struct _io_ops));
177 ops->_read8 = usb_read8;
178 ops->_read16 = usb_read16;
179 ops->_read32 = usb_read32;
180 ops->_read_port = r8712_usb_read_port;
181 ops->_write8 = usb_write8;
182 ops->_write16 = usb_write16;
183 ops->_write32 = usb_write32;
184 ops->_write_mem = r8712_usb_write_mem;
185 ops->_write_port = r8712_usb_write_port;