blob: cda3dbcf7eadf2f395e2ea6833615a0484c801f3 [file] [log] [blame]
Gabor Juhos69a2bac2013-03-29 15:52:27 +01001/*
2 Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
3 <http://rt2x00.serialmonkey.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the
17 Free Software Foundation, Inc.,
18 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21/*
22 Module: rt2x00mmio
23 Abstract: Data structures for the rt2x00mmio module.
24 */
25
26#ifndef RT2X00MMIO_H
27#define RT2X00MMIO_H
28
29#include <linux/io.h>
30
31/*
32 * Register access.
33 */
Gabor Juhos58959bd2013-04-05 08:27:00 +020034static inline void rt2x00mmio_register_read(struct rt2x00_dev *rt2x00dev,
35 const unsigned int offset,
36 u32 *value)
Gabor Juhos69a2bac2013-03-29 15:52:27 +010037{
38 *value = readl(rt2x00dev->csr.base + offset);
39}
40
Gabor Juhos58959bd2013-04-05 08:27:00 +020041static inline void rt2x00mmio_register_multiread(struct rt2x00_dev *rt2x00dev,
42 const unsigned int offset,
43 void *value, const u32 length)
Gabor Juhos69a2bac2013-03-29 15:52:27 +010044{
45 memcpy_fromio(value, rt2x00dev->csr.base + offset, length);
46}
47
Gabor Juhos58959bd2013-04-05 08:27:00 +020048static inline void rt2x00mmio_register_write(struct rt2x00_dev *rt2x00dev,
49 const unsigned int offset,
50 u32 value)
Gabor Juhos69a2bac2013-03-29 15:52:27 +010051{
52 writel(value, rt2x00dev->csr.base + offset);
53}
54
Gabor Juhos58959bd2013-04-05 08:27:00 +020055static inline void rt2x00mmio_register_multiwrite(struct rt2x00_dev *rt2x00dev,
56 const unsigned int offset,
57 const void *value,
58 const u32 length)
Gabor Juhos69a2bac2013-03-29 15:52:27 +010059{
60 __iowrite32_copy(rt2x00dev->csr.base + offset, value, length >> 2);
61}
62
63/**
Gabor Juhos58959bd2013-04-05 08:27:00 +020064 * rt2x00mmio_regbusy_read - Read from register with busy check
Gabor Juhos69a2bac2013-03-29 15:52:27 +010065 * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
66 * @offset: Register offset
67 * @field: Field to check if register is busy
68 * @reg: Pointer to where register contents should be stored
69 *
70 * This function will read the given register, and checks if the
71 * register is busy. If it is, it will sleep for a couple of
72 * microseconds before reading the register again. If the register
73 * is not read after a certain timeout, this function will return
74 * FALSE.
75 */
Gabor Juhos58959bd2013-04-05 08:27:00 +020076int rt2x00mmio_regbusy_read(struct rt2x00_dev *rt2x00dev,
77 const unsigned int offset,
78 const struct rt2x00_field32 field,
79 u32 *reg);
Gabor Juhos69a2bac2013-03-29 15:52:27 +010080
81/**
Gabor Juhos58959bd2013-04-05 08:27:00 +020082 * struct queue_entry_priv_mmio: Per entry PCI specific information
Gabor Juhos69a2bac2013-03-29 15:52:27 +010083 *
84 * @desc: Pointer to device descriptor
85 * @desc_dma: DMA pointer to &desc.
86 * @data: Pointer to device's entry memory.
87 * @data_dma: DMA pointer to &data.
88 */
Gabor Juhos58959bd2013-04-05 08:27:00 +020089struct queue_entry_priv_mmio {
Gabor Juhos69a2bac2013-03-29 15:52:27 +010090 __le32 *desc;
91 dma_addr_t desc_dma;
92};
93
94/**
Gabor Juhos58959bd2013-04-05 08:27:00 +020095 * rt2x00mmio_rxdone - Handle RX done events
Gabor Juhos69a2bac2013-03-29 15:52:27 +010096 * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
97 *
98 * Returns true if there are still rx frames pending and false if all
99 * pending rx frames were processed.
100 */
Gabor Juhos58959bd2013-04-05 08:27:00 +0200101bool rt2x00mmio_rxdone(struct rt2x00_dev *rt2x00dev);
Gabor Juhos69a2bac2013-03-29 15:52:27 +0100102
103/**
Gabor Juhos58959bd2013-04-05 08:27:00 +0200104 * rt2x00mmio_flush_queue - Flush data queue
Gabor Juhos69a2bac2013-03-29 15:52:27 +0100105 * @queue: Data queue to stop
106 * @drop: True to drop all pending frames.
107 *
108 * This will wait for a maximum of 100ms, waiting for the queues
109 * to become empty.
110 */
Gabor Juhos58959bd2013-04-05 08:27:00 +0200111void rt2x00mmio_flush_queue(struct data_queue *queue, bool drop);
Gabor Juhos69a2bac2013-03-29 15:52:27 +0100112
113/*
114 * Device initialization handlers.
115 */
Gabor Juhos58959bd2013-04-05 08:27:00 +0200116int rt2x00mmio_initialize(struct rt2x00_dev *rt2x00dev);
Gabor Juhos58959bd2013-04-05 08:27:00 +0200117void rt2x00mmio_uninitialize(struct rt2x00_dev *rt2x00dev);
Gabor Juhos69a2bac2013-03-29 15:52:27 +0100118
119#endif /* RT2X00MMIO_H */