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)
34 struct intf_priv *intfpriv = intfhdl->pintfpriv;
37 requesttype = 0x01; /* read_in */
39 wvalue = (u16)(addr & 0x0000ffff);
41 status = r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index,
42 &data, len, requesttype);
45 return (u8)(le32_to_cpu(data) & 0x0ff);
48 static u16 usb_read16(struct intf_hdl *intfhdl, u32 addr)
57 struct intf_priv *intfpriv = intfhdl->pintfpriv;
60 requesttype = 0x01; /* read_in */
62 wvalue = (u16)(addr & 0x0000ffff);
64 status = r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index,
65 &data, len, requesttype);
68 return (u16)(le32_to_cpu(data) & 0xffff);
71 static u32 usb_read32(struct intf_hdl *intfhdl, u32 addr)
80 struct intf_priv *intfpriv = intfhdl->pintfpriv;
83 requesttype = 0x01; /* read_in */
85 wvalue = (u16)(addr & 0x0000ffff);
87 status = r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index,
88 &data, len, requesttype);
91 return le32_to_cpu(data);
94 static void usb_write8(struct intf_hdl *intfhdl, u32 addr, u8 val)
102 struct intf_priv *intfpriv = intfhdl->pintfpriv;
105 requesttype = 0x00; /* write_out */
107 wvalue = (u16)(addr & 0x0000ffff);
109 data = cpu_to_le32((u32)val & 0x000000ff);
110 r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, &data, len,
114 static void usb_write16(struct intf_hdl *intfhdl, u32 addr, u16 val)
122 struct intf_priv *intfpriv = intfhdl->pintfpriv;
125 requesttype = 0x00; /* write_out */
127 wvalue = (u16)(addr & 0x0000ffff);
129 data = cpu_to_le32((u32)val & 0x0000ffff);
130 r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, &data, len,
134 static void usb_write32(struct intf_hdl *intfhdl, u32 addr, u32 val)
142 struct intf_priv *intfpriv = intfhdl->pintfpriv;
145 requesttype = 0x00; /* write_out */
147 wvalue = (u16)(addr & 0x0000ffff);
149 data = cpu_to_le32(val);
150 r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, &data, len,
154 void r8712_usb_set_intf_option(u32 *option)
156 *option = ((*option) | _INTF_ASYNC_);
159 static void usb_intf_hdl_init(u8 *priv)
163 static void usb_intf_hdl_unload(u8 *priv)
167 static void usb_intf_hdl_open(u8 *priv)
171 static void usb_intf_hdl_close(u8 *priv)
175 void r8712_usb_set_intf_funs(struct intf_hdl *intfhdl)
177 intfhdl->intf_hdl_init = usb_intf_hdl_init;
178 intfhdl->intf_hdl_unload = usb_intf_hdl_unload;
179 intfhdl->intf_hdl_open = usb_intf_hdl_open;
180 intfhdl->intf_hdl_close = usb_intf_hdl_close;
183 void r8712_usb_set_intf_ops(struct _io_ops *ops)
185 memset((u8 *)ops, 0, sizeof(struct _io_ops));
186 ops->_read8 = usb_read8;
187 ops->_read16 = usb_read16;
188 ops->_read32 = usb_read32;
189 ops->_read_port = r8712_usb_read_port;
190 ops->_write8 = usb_write8;
191 ops->_write16 = usb_write16;
192 ops->_write32 = usb_write32;
193 ops->_write_mem = r8712_usb_write_mem;
194 ops->_write_port = r8712_usb_write_port;