treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / net / wireless / ralink / rt2x00 / rt2x00mmio.h
blob9c7e31c4553fc0f6c3de89201c7b34439f16327b
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
4 <http://rt2x00.serialmonkey.com>
6 */
8 /*
9 Module: rt2x00mmio
10 Abstract: Data structures for the rt2x00mmio module.
13 #ifndef RT2X00MMIO_H
14 #define RT2X00MMIO_H
16 #include <linux/io.h>
19 * Register access.
21 static inline u32 rt2x00mmio_register_read(struct rt2x00_dev *rt2x00dev,
22 const unsigned int offset)
24 return readl(rt2x00dev->csr.base + offset);
27 static inline void rt2x00mmio_register_multiread(struct rt2x00_dev *rt2x00dev,
28 const unsigned int offset,
29 void *value, const u32 length)
31 memcpy_fromio(value, rt2x00dev->csr.base + offset, length);
34 static inline void rt2x00mmio_register_write(struct rt2x00_dev *rt2x00dev,
35 const unsigned int offset,
36 u32 value)
38 writel(value, rt2x00dev->csr.base + offset);
41 static inline void rt2x00mmio_register_multiwrite(struct rt2x00_dev *rt2x00dev,
42 const unsigned int offset,
43 const void *value,
44 const u32 length)
46 __iowrite32_copy(rt2x00dev->csr.base + offset, value, length >> 2);
49 /**
50 * rt2x00mmio_regbusy_read - Read from register with busy check
51 * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
52 * @offset: Register offset
53 * @field: Field to check if register is busy
54 * @reg: Pointer to where register contents should be stored
56 * This function will read the given register, and checks if the
57 * register is busy. If it is, it will sleep for a couple of
58 * microseconds before reading the register again. If the register
59 * is not read after a certain timeout, this function will return
60 * FALSE.
62 int rt2x00mmio_regbusy_read(struct rt2x00_dev *rt2x00dev,
63 const unsigned int offset,
64 const struct rt2x00_field32 field,
65 u32 *reg);
67 /**
68 * struct queue_entry_priv_mmio: Per entry PCI specific information
70 * @desc: Pointer to device descriptor
71 * @desc_dma: DMA pointer to &desc.
73 struct queue_entry_priv_mmio {
74 __le32 *desc;
75 dma_addr_t desc_dma;
78 /**
79 * rt2x00mmio_rxdone - Handle RX done events
80 * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
82 * Returns true if there are still rx frames pending and false if all
83 * pending rx frames were processed.
85 bool rt2x00mmio_rxdone(struct rt2x00_dev *rt2x00dev);
87 /**
88 * rt2x00mmio_flush_queue - Flush data queue
89 * @queue: Data queue to stop
90 * @drop: True to drop all pending frames.
92 * This will wait for a maximum of 100ms, waiting for the queues
93 * to become empty.
95 void rt2x00mmio_flush_queue(struct data_queue *queue, bool drop);
98 * Device initialization handlers.
100 int rt2x00mmio_initialize(struct rt2x00_dev *rt2x00dev);
101 void rt2x00mmio_uninitialize(struct rt2x00_dev *rt2x00dev);
103 #endif /* RT2X00MMIO_H */