1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
4 * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
6 * Modifications for inclusion into the Linux staging tree are
7 * Copyright(c) 2010 Larry Finger. All rights reserved.
13 ******************************************************************************/
14 #ifndef _RTL871X_IO_H_
15 #define _RTL871X_IO_H_
17 #include "osdep_service.h"
18 #include "osdep_intf.h"
22 #define MAX_PROT_SZ (64-16)
25 #define _IO_WAIT_COMPLETE 1
26 #define _IO_WAIT_RSP 2
29 #define _IOSZ_MASK_ (0x7F)
30 #define _IO_WRITE_ BIT(7)
31 #define _IO_FIXED_ BIT(8)
32 #define _IO_BURST_ BIT(9)
33 #define _IO_BYTE_ BIT(10)
34 #define _IO_HW_ BIT(11)
35 #define _IO_WORD_ BIT(12)
36 #define _IO_SYNC_ BIT(13)
37 #define _IO_CMDMASK_ (0x1F80)
40 * For prompt mode accessing, caller shall free io_req
41 * Otherwise, io_handler will free io_req
44 #define _IO_ERR_ BIT(2)
45 #define _IO_SUCCESS_ BIT(1)
46 #define _IO_DONE_ BIT(0)
47 #define IO_RD32 (_IO_SYNC_ | _IO_WORD_)
48 #define IO_RD16 (_IO_SYNC_ | _IO_HW_)
49 #define IO_RD8 (_IO_SYNC_ | _IO_BYTE_)
50 #define IO_RD32_ASYNC (_IO_WORD_)
51 #define IO_RD16_ASYNC (_IO_HW_)
52 #define IO_RD8_ASYNC (_IO_BYTE_)
53 #define IO_WR32 (_IO_WRITE_ | _IO_SYNC_ | _IO_WORD_)
54 #define IO_WR16 (_IO_WRITE_ | _IO_SYNC_ | _IO_HW_)
55 #define IO_WR8 (_IO_WRITE_ | _IO_SYNC_ | _IO_BYTE_)
56 #define IO_WR32_ASYNC (_IO_WRITE_ | _IO_WORD_)
57 #define IO_WR16_ASYNC (_IO_WRITE_ | _IO_HW_)
58 #define IO_WR8_ASYNC (_IO_WRITE_ | _IO_BYTE_)
60 * Only Sync. burst accessing is provided.
62 #define IO_WR_BURST(x) (IO_WRITE_ | _IO_SYNC_ | _IO_BURST_ | \
64 #define IO_RD_BURST(x) (_IO_SYNC_ | _IO_BURST_ | ((x) & _IOSZ_MASK_))
65 /*below is for the intf_option bit defition...*/
66 #define _INTF_ASYNC_ BIT(0) /*support async io*/
71 uint (*_sdbus_read_bytes_to_membuf)(struct intf_priv *pintfpriv,
72 u32 addr, u32 cnt, u8 *pbuf);
73 uint (*_sdbus_read_blocks_to_membuf)(struct intf_priv *pintfpriv,
74 u32 addr, u32 cnt, u8 *pbuf);
75 u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr);
76 u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr);
77 u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr);
78 uint (*_sdbus_write_blocks_from_membuf)(struct intf_priv *pintfpriv,
79 u32 addr, u32 cnt, u8 *pbuf,
81 uint (*_sdbus_write_bytes_from_membuf)(struct intf_priv *pintfpriv,
82 u32 addr, u32 cnt, u8 *pbuf);
83 u8 (*_cmd52r)(struct intf_priv *pintfpriv, u32 addr);
84 void (*_cmd52w)(struct intf_priv *pintfpriv, u32 addr, u8 val8);
85 u8 (*_cmdfunc152r)(struct intf_priv *pintfpriv, u32 addr);
86 void (*_cmdfunc152w)(struct intf_priv *pintfpriv, u32 addr, u8 val8);
87 void (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
88 void (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
89 void (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
90 void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
92 void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
94 void (*_sync_irp_protocol_rw)(struct io_queue *pio_q);
95 u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
97 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
102 struct list_head list;
104 /*volatile*/ u32 val;
108 void (*_async_io_callback)(struct _adapter *padapter,
109 struct io_req *pio_req, u8 *cnxt);
117 struct intf_priv *pintfpriv;
118 void (*intf_hdl_init)(u8 *priv);
119 void (*intf_hdl_unload)(u8 *priv);
120 void (*intf_hdl_open)(u8 *priv);
121 void (*intf_hdl_close)(u8 *priv);
122 struct _io_ops io_ops;
125 struct reg_protocol_rd {
126 #ifdef __LITTLE_ENDIAN
133 u32 WriteEnable:1; /*0:read, 1:write*/
134 u32 FixOrContinuous:1; /*0:continuous, 1: Fix*/
157 u32 FixOrContinuous:1;
165 struct reg_protocol_wt {
166 #ifdef __LITTLE_ENDIAN
173 u32 WriteEnable:1; /*0:read, 1:write*/
174 u32 FixOrContinuous:1; /*0:continuous, 1: Fix*/
198 u32 FixOrContinuous:1;
208 * Below is the data structure used by _io_handler
213 struct list_head free_ioreqs;
214 /*The io_req list that will be served in the single protocol r/w.*/
215 struct list_head pending;
216 struct list_head processing;
217 u8 *free_ioreqs_buf; /* 4-byte aligned */
218 u8 *pallocated_free_ioreqs_buf;
219 struct intf_hdl intf;
222 u8 r8712_read8(struct _adapter *adapter, u32 addr);
223 u16 r8712_read16(struct _adapter *adapter, u32 addr);
224 u32 r8712_read32(struct _adapter *adapter, u32 addr);
225 void r8712_read_mem(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
226 void r8712_read_port(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
227 void r8712_write8(struct _adapter *adapter, u32 addr, u8 val);
228 void r8712_write16(struct _adapter *adapter, u32 addr, u16 val);
229 void r8712_write32(struct _adapter *adapter, u32 addr, u32 val);
230 void r8712_write_mem(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
231 void r8712_write_port(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
233 uint r8712_alloc_io_queue(struct _adapter *adapter);
234 void r8712_free_io_queue(struct _adapter *adapter);
236 #endif /*_RTL871X_IO_H_*/