1 /******************************************************************************
4 * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
5 * Linux device driver for RTL8192SU
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20 * Modifications for inclusion into the Linux staging tree are
21 * Copyright(c) 2010 Larry Finger. All rights reserved.
23 * Contact information:
27 ******************************************************************************/
31 #include "osdep_service.h"
32 #include "drv_types.h"
33 #include "osdep_intf.h"
35 #include "recv_osdep.h"
37 static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr)
45 struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
48 requesttype = 0x01; /* read_in */
50 wvalue = (u16)(addr & 0x0000ffff);
52 r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len,
54 return (u8)(le32_to_cpu(data) & 0x0ff);
57 static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr)
65 struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
68 requesttype = 0x01; /* read_in */
70 wvalue = (u16)(addr & 0x0000ffff);
72 r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len,
74 return (u16)(le32_to_cpu(data) & 0xffff);
77 static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr)
85 struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
88 requesttype = 0x01; /* read_in */
90 wvalue = (u16)(addr & 0x0000ffff);
92 r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len,
94 return le32_to_cpu(data);
97 static void usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val)
105 struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
108 requesttype = 0x00; /* write_out */
110 wvalue = (u16)(addr & 0x0000ffff);
113 data = cpu_to_le32(data & 0x000000ff);
114 r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len,
118 static void usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val)
126 struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
129 requesttype = 0x00; /* write_out */
131 wvalue = (u16)(addr & 0x0000ffff);
134 data = cpu_to_le32(data & 0x0000ffff);
135 r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len,
139 static void usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val)
147 struct intf_priv *pintfpriv = pintfhdl->pintfpriv;
150 requesttype = 0x00; /* write_out */
152 wvalue = (u16)(addr & 0x0000ffff);
154 data = cpu_to_le32(val);
155 r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len,
159 void r8712_usb_set_intf_option(u32 *poption)
161 *poption = ((*poption) | _INTF_ASYNC_);
164 static void usb_intf_hdl_init(u8 *priv)
168 static void usb_intf_hdl_unload(u8 *priv)
172 static void usb_intf_hdl_open(u8 *priv)
176 static void usb_intf_hdl_close(u8 *priv)
180 void r8712_usb_set_intf_funs(struct intf_hdl *pintf_hdl)
182 pintf_hdl->intf_hdl_init = usb_intf_hdl_init;
183 pintf_hdl->intf_hdl_unload = usb_intf_hdl_unload;
184 pintf_hdl->intf_hdl_open = usb_intf_hdl_open;
185 pintf_hdl->intf_hdl_close = usb_intf_hdl_close;
188 void r8712_usb_set_intf_ops(struct _io_ops *pops)
190 memset((u8 *)pops, 0, sizeof(struct _io_ops));
191 pops->_read8 = usb_read8;
192 pops->_read16 = usb_read16;
193 pops->_read32 = usb_read32;
194 pops->_read_port = r8712_usb_read_port;
195 pops->_write8 = usb_write8;
196 pops->_write16 = usb_write16;
197 pops->_write32 = usb_write32;
198 pops->_write_mem = r8712_usb_write_mem;
199 pops->_write_port = r8712_usb_write_port;