• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  * rtl8712_io.c
3  *
4  * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
5  * Linux device driver for RTL8192SU
6  *
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.
10  *
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
14  * more details.
15  *
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
19  *
20  * Modifications for inclusion into the Linux staging tree are
21  * Copyright(c) 2010 Larry Finger. All rights reserved.
22  *
23  * Contact information:
24  * WLAN FAE <wlanfae@realtek.com>.
25  * Larry Finger <Larry.Finger@lwfinger.net>
26  *
27  ******************************************************************************/
28 
29 #define _RTL8712_IO_C_
30 
31 #include "osdep_service.h"
32 #include "drv_types.h"
33 #include "rtl871x_io.h"
34 #include "osdep_intf.h"
35 #include "usb_ops.h"
36 
r8712_read8(struct _adapter * adapter,u32 addr)37 u8 r8712_read8(struct _adapter *adapter, u32 addr)
38 {
39 	struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
40 	struct intf_hdl *pintfhdl = &(pio_queue->intf);
41 	u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr);
42 
43 	_read8 = pintfhdl->io_ops._read8;
44 	return  _read8(pintfhdl, addr);
45 }
46 
r8712_read16(struct _adapter * adapter,u32 addr)47 u16 r8712_read16(struct _adapter *adapter, u32 addr)
48 {
49 	struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
50 	struct intf_hdl *pintfhdl = &(pio_queue->intf);
51 	u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr);
52 
53 	_read16 = pintfhdl->io_ops._read16;
54 	return _read16(pintfhdl, addr);
55 }
56 
r8712_read32(struct _adapter * adapter,u32 addr)57 u32 r8712_read32(struct _adapter *adapter, u32 addr)
58 {
59 	struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
60 	struct intf_hdl *pintfhdl = &(pio_queue->intf);
61 	u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr);
62 
63 	_read32 = pintfhdl->io_ops._read32;
64 	return _read32(pintfhdl, addr);
65 }
66 
r8712_write8(struct _adapter * adapter,u32 addr,u8 val)67 void r8712_write8(struct _adapter *adapter, u32 addr, u8 val)
68 {
69 	struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
70 	struct intf_hdl *pintfhdl = &(pio_queue->intf);
71 	void (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
72 
73 	_write8 = pintfhdl->io_ops._write8;
74 	_write8(pintfhdl, addr, val);
75 }
76 
r8712_write16(struct _adapter * adapter,u32 addr,u16 val)77 void r8712_write16(struct _adapter *adapter, u32 addr, u16 val)
78 {
79 	struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
80 	struct intf_hdl *pintfhdl = &(pio_queue->intf);
81 	void (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
82 
83 	_write16 = pintfhdl->io_ops._write16;
84 	_write16(pintfhdl, addr, val);
85 }
86 
r8712_write32(struct _adapter * adapter,u32 addr,u32 val)87 void r8712_write32(struct _adapter *adapter, u32 addr, u32 val)
88 {
89 	struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
90 	struct intf_hdl *pintfhdl = (struct intf_hdl *)(&(pio_queue->intf));
91 
92 	void (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
93 
94 	_write32 = pintfhdl->io_ops._write32;
95 	_write32(pintfhdl, addr, val);
96 }
97 
r8712_read_mem(struct _adapter * adapter,u32 addr,u32 cnt,u8 * pmem)98 void r8712_read_mem(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
99 {
100 	struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
101 	struct intf_hdl *pintfhdl = &(pio_queue->intf);
102 
103 	void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
104 			  u8 *pmem);
105 	if ((adapter->bDriverStopped == true) ||
106 	    (adapter->bSurpriseRemoved == true))
107 		return;
108 	_read_mem = pintfhdl->io_ops._read_mem;
109 	_read_mem(pintfhdl, addr, cnt, pmem);
110 }
111 
r8712_write_mem(struct _adapter * adapter,u32 addr,u32 cnt,u8 * pmem)112 void r8712_write_mem(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
113 {
114 	struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
115 	struct intf_hdl *pintfhdl = &(pio_queue->intf);
116 	void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
117 			   u8 *pmem);
118 
119 	_write_mem = pintfhdl->io_ops._write_mem;
120 	_write_mem(pintfhdl, addr, cnt, pmem);
121 }
122 
r8712_read_port(struct _adapter * adapter,u32 addr,u32 cnt,u8 * pmem)123 void r8712_read_port(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
124 {
125 	struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
126 	struct intf_hdl	*pintfhdl = &(pio_queue->intf);
127 
128 	u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
129 			  u8 *pmem);
130 	if ((adapter->bDriverStopped == true) ||
131 	    (adapter->bSurpriseRemoved == true))
132 		return;
133 	_read_port = pintfhdl->io_ops._read_port;
134 	_read_port(pintfhdl, addr, cnt, pmem);
135 }
136 
r8712_write_port(struct _adapter * adapter,u32 addr,u32 cnt,u8 * pmem)137 void r8712_write_port(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
138 {
139 	struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
140 	struct intf_hdl *pintfhdl = &(pio_queue->intf);
141 
142 	u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
143 			   u8 *pmem);
144 	_write_port = pintfhdl->io_ops._write_port;
145 	_write_port(pintfhdl, addr, cnt, pmem);
146 }
147