Gabor Juhos | 69a2bac | 2013-03-29 15:52:27 +0100 | [diff] [blame] | 1 | /* |
| 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 Juhos | 58959bd | 2013-04-05 08:27:00 +0200 | [diff] [blame] | 34 | static inline void rt2x00mmio_register_read(struct rt2x00_dev *rt2x00dev, |
| 35 | const unsigned int offset, |
| 36 | u32 *value) |
Gabor Juhos | 69a2bac | 2013-03-29 15:52:27 +0100 | [diff] [blame] | 37 | { |
| 38 | *value = readl(rt2x00dev->csr.base + offset); |
| 39 | } |
| 40 | |
Gabor Juhos | 58959bd | 2013-04-05 08:27:00 +0200 | [diff] [blame] | 41 | static inline void rt2x00mmio_register_multiread(struct rt2x00_dev *rt2x00dev, |
| 42 | const unsigned int offset, |
| 43 | void *value, const u32 length) |
Gabor Juhos | 69a2bac | 2013-03-29 15:52:27 +0100 | [diff] [blame] | 44 | { |
| 45 | memcpy_fromio(value, rt2x00dev->csr.base + offset, length); |
| 46 | } |
| 47 | |
Gabor Juhos | 58959bd | 2013-04-05 08:27:00 +0200 | [diff] [blame] | 48 | static inline void rt2x00mmio_register_write(struct rt2x00_dev *rt2x00dev, |
| 49 | const unsigned int offset, |
| 50 | u32 value) |
Gabor Juhos | 69a2bac | 2013-03-29 15:52:27 +0100 | [diff] [blame] | 51 | { |
| 52 | writel(value, rt2x00dev->csr.base + offset); |
| 53 | } |
| 54 | |
Gabor Juhos | 58959bd | 2013-04-05 08:27:00 +0200 | [diff] [blame] | 55 | static inline void rt2x00mmio_register_multiwrite(struct rt2x00_dev *rt2x00dev, |
| 56 | const unsigned int offset, |
| 57 | const void *value, |
| 58 | const u32 length) |
Gabor Juhos | 69a2bac | 2013-03-29 15:52:27 +0100 | [diff] [blame] | 59 | { |
| 60 | __iowrite32_copy(rt2x00dev->csr.base + offset, value, length >> 2); |
| 61 | } |
| 62 | |
| 63 | /** |
Gabor Juhos | 58959bd | 2013-04-05 08:27:00 +0200 | [diff] [blame] | 64 | * rt2x00mmio_regbusy_read - Read from register with busy check |
Gabor Juhos | 69a2bac | 2013-03-29 15:52:27 +0100 | [diff] [blame] | 65 | * @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 Juhos | 58959bd | 2013-04-05 08:27:00 +0200 | [diff] [blame] | 76 | int rt2x00mmio_regbusy_read(struct rt2x00_dev *rt2x00dev, |
| 77 | const unsigned int offset, |
| 78 | const struct rt2x00_field32 field, |
| 79 | u32 *reg); |
Gabor Juhos | 69a2bac | 2013-03-29 15:52:27 +0100 | [diff] [blame] | 80 | |
| 81 | /** |
Gabor Juhos | 58959bd | 2013-04-05 08:27:00 +0200 | [diff] [blame] | 82 | * struct queue_entry_priv_mmio: Per entry PCI specific information |
Gabor Juhos | 69a2bac | 2013-03-29 15:52:27 +0100 | [diff] [blame] | 83 | * |
| 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 Juhos | 58959bd | 2013-04-05 08:27:00 +0200 | [diff] [blame] | 89 | struct queue_entry_priv_mmio { |
Gabor Juhos | 69a2bac | 2013-03-29 15:52:27 +0100 | [diff] [blame] | 90 | __le32 *desc; |
| 91 | dma_addr_t desc_dma; |
| 92 | }; |
| 93 | |
| 94 | /** |
Gabor Juhos | 58959bd | 2013-04-05 08:27:00 +0200 | [diff] [blame] | 95 | * rt2x00mmio_rxdone - Handle RX done events |
Gabor Juhos | 69a2bac | 2013-03-29 15:52:27 +0100 | [diff] [blame] | 96 | * @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 Juhos | 58959bd | 2013-04-05 08:27:00 +0200 | [diff] [blame] | 101 | bool rt2x00mmio_rxdone(struct rt2x00_dev *rt2x00dev); |
Gabor Juhos | 69a2bac | 2013-03-29 15:52:27 +0100 | [diff] [blame] | 102 | |
| 103 | /** |
Gabor Juhos | 58959bd | 2013-04-05 08:27:00 +0200 | [diff] [blame] | 104 | * rt2x00mmio_flush_queue - Flush data queue |
Gabor Juhos | 69a2bac | 2013-03-29 15:52:27 +0100 | [diff] [blame] | 105 | * @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 Juhos | 58959bd | 2013-04-05 08:27:00 +0200 | [diff] [blame] | 111 | void rt2x00mmio_flush_queue(struct data_queue *queue, bool drop); |
Gabor Juhos | 69a2bac | 2013-03-29 15:52:27 +0100 | [diff] [blame] | 112 | |
| 113 | /* |
| 114 | * Device initialization handlers. |
| 115 | */ |
Gabor Juhos | 58959bd | 2013-04-05 08:27:00 +0200 | [diff] [blame] | 116 | int rt2x00mmio_initialize(struct rt2x00_dev *rt2x00dev); |
Gabor Juhos | 58959bd | 2013-04-05 08:27:00 +0200 | [diff] [blame] | 117 | void rt2x00mmio_uninitialize(struct rt2x00_dev *rt2x00dev); |
Gabor Juhos | 69a2bac | 2013-03-29 15:52:27 +0100 | [diff] [blame] | 118 | |
| 119 | #endif /* RT2X00MMIO_H */ |