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, see <http://www.gnu.org/licenses/>. 17 */ 18 19 /* 20 Module: rt2x00mmio 21 Abstract: Data structures for the rt2x00mmio module. 22 */ 23 24 #ifndef RT2X00MMIO_H 25 #define RT2X00MMIO_H 26 27 #include <linux/io.h> 28 29 /* 30 * Register access. 31 */ 32 static inline void rt2x00mmio_register_read(struct rt2x00_dev *rt2x00dev, 33 const unsigned int offset, 34 u32 *value) 35 { 36 *value = readl(rt2x00dev->csr.base + offset); 37 } 38 39 static inline void rt2x00mmio_register_multiread(struct rt2x00_dev *rt2x00dev, 40 const unsigned int offset, 41 void *value, const u32 length) 42 { 43 memcpy_fromio(value, rt2x00dev->csr.base + offset, length); 44 } 45 46 static inline void rt2x00mmio_register_write(struct rt2x00_dev *rt2x00dev, 47 const unsigned int offset, 48 u32 value) 49 { 50 writel(value, rt2x00dev->csr.base + offset); 51 } 52 53 static inline void rt2x00mmio_register_multiwrite(struct rt2x00_dev *rt2x00dev, 54 const unsigned int offset, 55 const void *value, 56 const u32 length) 57 { 58 __iowrite32_copy(rt2x00dev->csr.base + offset, value, length >> 2); 59 } 60 61 /** 62 * rt2x00mmio_regbusy_read - Read from register with busy check 63 * @rt2x00dev: Device pointer, see &struct rt2x00_dev. 64 * @offset: Register offset 65 * @field: Field to check if register is busy 66 * @reg: Pointer to where register contents should be stored 67 * 68 * This function will read the given register, and checks if the 69 * register is busy. If it is, it will sleep for a couple of 70 * microseconds before reading the register again. If the register 71 * is not read after a certain timeout, this function will return 72 * FALSE. 73 */ 74 int rt2x00mmio_regbusy_read(struct rt2x00_dev *rt2x00dev, 75 const unsigned int offset, 76 const struct rt2x00_field32 field, 77 u32 *reg); 78 79 /** 80 * struct queue_entry_priv_mmio: Per entry PCI specific information 81 * 82 * @desc: Pointer to device descriptor 83 * @desc_dma: DMA pointer to &desc. 84 * @data: Pointer to device's entry memory. 85 * @data_dma: DMA pointer to &data. 86 */ 87 struct queue_entry_priv_mmio { 88 __le32 *desc; 89 dma_addr_t desc_dma; 90 }; 91 92 /** 93 * rt2x00mmio_rxdone - Handle RX done events 94 * @rt2x00dev: Device pointer, see &struct rt2x00_dev. 95 * 96 * Returns true if there are still rx frames pending and false if all 97 * pending rx frames were processed. 98 */ 99 bool rt2x00mmio_rxdone(struct rt2x00_dev *rt2x00dev); 100 101 /** 102 * rt2x00mmio_flush_queue - Flush data queue 103 * @queue: Data queue to stop 104 * @drop: True to drop all pending frames. 105 * 106 * This will wait for a maximum of 100ms, waiting for the queues 107 * to become empty. 108 */ 109 void rt2x00mmio_flush_queue(struct data_queue *queue, bool drop); 110 111 /* 112 * Device initialization handlers. 113 */ 114 int rt2x00mmio_initialize(struct rt2x00_dev *rt2x00dev); 115 void rt2x00mmio_uninitialize(struct rt2x00_dev *rt2x00dev); 116 117 #endif /* RT2X00MMIO_H */ 118