linux/drivers/staging/rtl8723bs/include/rtw_io.h

/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
 *
 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
 *
 ******************************************************************************/

#ifndef _RTW_IO_H_
#define _RTW_IO_H_

/*
	For prompt mode accessing, caller shall free io_req
	Otherwise, io_handler will free io_req
*/

/* below is for the intf_option bit defition... */

struct intf_priv;
struct intf_hdl;
struct io_queue;

struct _io_ops {};

struct io_req {};

struct	intf_hdl {};

#define SD_IO_TRY_CNT
#define MAX_CONTINUAL_IO_ERR

int rtw_inc_and_chk_continual_io_error(struct dvobj_priv *dvobj);
void rtw_reset_continual_io_error(struct dvobj_priv *dvobj);

/*
Below is the data structure used by _io_handler

*/

struct io_queue {};

struct io_priv {};

extern uint ioreq_flush(struct adapter *adapter, struct io_queue *ioqueue);
extern void sync_ioreq_enqueue(struct io_req *preq, struct io_queue *ioqueue);
extern uint sync_ioreq_flush(struct adapter *adapter, struct io_queue *ioqueue);


extern uint free_ioreq(struct io_req *preq, struct io_queue *pio_queue);
extern struct io_req *alloc_ioreq(struct io_queue *pio_q);

extern uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl);
extern void unregister_intf_hdl(struct intf_hdl *pintfhdl);

extern void _rtw_attrib_read(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
extern void _rtw_attrib_write(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);

extern u8 rtw_read8(struct adapter *adapter, u32 addr);
extern u16 rtw_read16(struct adapter *adapter, u32 addr);
extern u32 rtw_read32(struct adapter *adapter, u32 addr);

extern int rtw_write8(struct adapter *adapter, u32 addr, u8 val);
extern int rtw_write16(struct adapter *adapter, u32 addr, u16 val);
extern int rtw_write32(struct adapter *adapter, u32 addr, u32 val);

extern u32 rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);

extern void rtw_write_scsi(struct adapter *adapter, u32 cnt, u8 *pmem);

/* ioreq */
extern void ioreq_read8(struct adapter *adapter, u32 addr, u8 *pval);
extern void ioreq_read16(struct adapter *adapter, u32 addr, u16 *pval);
extern void ioreq_read32(struct adapter *adapter, u32 addr, u32 *pval);
extern void ioreq_write8(struct adapter *adapter, u32 addr, u8 val);
extern void ioreq_write16(struct adapter *adapter, u32 addr, u16 val);
extern void ioreq_write32(struct adapter *adapter, u32 addr, u32 val);


extern uint async_read8(struct adapter *adapter, u32 addr, u8 *pbuff,
	void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);
extern uint async_read16(struct adapter *adapter, u32 addr,  u8 *pbuff,
	void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);
extern uint async_read32(struct adapter *adapter, u32 addr,  u8 *pbuff,
	void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);

extern void async_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
extern void async_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);

extern void async_write8(struct adapter *adapter, u32 addr, u8 val,
	void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);
extern void async_write16(struct adapter *adapter, u32 addr, u16 val,
	void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);
extern void async_write32(struct adapter *adapter, u32 addr, u32 val,
	void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt), u8 *cnxt);

extern void async_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
extern void async_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem);


int rtw_init_io_priv(struct adapter *padapter, void (*set_intf_ops)(struct adapter *padapter, struct _io_ops *pops));


extern uint alloc_io_queue(struct adapter *adapter);
extern void free_io_queue(struct adapter *adapter);
extern void async_bus_io(struct io_queue *pio_q);
extern void bus_sync_io(struct io_queue *pio_q);
extern u32 _ioreq2rwmem(struct io_queue *pio_q);
extern void dev_power_down(struct adapter *Adapter, u8 bpwrup);

#endif	/* _RTL8711_IO_H_ */