Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003     Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
0004     <http://rt2x00.serialmonkey.com>
0005 
0006  */
0007 
0008 /*
0009     Module: rt2x00mmio
0010     Abstract: Data structures for the rt2x00mmio module.
0011  */
0012 
0013 #ifndef RT2X00MMIO_H
0014 #define RT2X00MMIO_H
0015 
0016 #include <linux/io.h>
0017 
0018 /*
0019  * Register access.
0020  */
0021 static inline u32 rt2x00mmio_register_read(struct rt2x00_dev *rt2x00dev,
0022                        const unsigned int offset)
0023 {
0024     return readl(rt2x00dev->csr.base + offset);
0025 }
0026 
0027 static inline void rt2x00mmio_register_multiread(struct rt2x00_dev *rt2x00dev,
0028                          const unsigned int offset,
0029                          void *value, const u32 length)
0030 {
0031     memcpy_fromio(value, rt2x00dev->csr.base + offset, length);
0032 }
0033 
0034 static inline void rt2x00mmio_register_write(struct rt2x00_dev *rt2x00dev,
0035                          const unsigned int offset,
0036                          u32 value)
0037 {
0038     writel(value, rt2x00dev->csr.base + offset);
0039 }
0040 
0041 static inline void rt2x00mmio_register_multiwrite(struct rt2x00_dev *rt2x00dev,
0042                           const unsigned int offset,
0043                           const void *value,
0044                           const u32 length)
0045 {
0046     __iowrite32_copy(rt2x00dev->csr.base + offset, value, length >> 2);
0047 }
0048 
0049 /**
0050  * rt2x00mmio_regbusy_read - Read from register with busy check
0051  * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
0052  * @offset: Register offset
0053  * @field: Field to check if register is busy
0054  * @reg: Pointer to where register contents should be stored
0055  *
0056  * This function will read the given register, and checks if the
0057  * register is busy. If it is, it will sleep for a couple of
0058  * microseconds before reading the register again. If the register
0059  * is not read after a certain timeout, this function will return
0060  * FALSE.
0061  */
0062 int rt2x00mmio_regbusy_read(struct rt2x00_dev *rt2x00dev,
0063                 const unsigned int offset,
0064                 const struct rt2x00_field32 field,
0065                 u32 *reg);
0066 
0067 /**
0068  * struct queue_entry_priv_mmio: Per entry PCI specific information
0069  *
0070  * @desc: Pointer to device descriptor
0071  * @desc_dma: DMA pointer to &desc.
0072  */
0073 struct queue_entry_priv_mmio {
0074     __le32 *desc;
0075     dma_addr_t desc_dma;
0076 };
0077 
0078 /**
0079  * rt2x00mmio_rxdone - Handle RX done events
0080  * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
0081  *
0082  * Returns true if there are still rx frames pending and false if all
0083  * pending rx frames were processed.
0084  */
0085 bool rt2x00mmio_rxdone(struct rt2x00_dev *rt2x00dev);
0086 
0087 /**
0088  * rt2x00mmio_flush_queue - Flush data queue
0089  * @queue: Data queue to stop
0090  * @drop: True to drop all pending frames.
0091  *
0092  * This will wait for a maximum of 100ms, waiting for the queues
0093  * to become empty.
0094  */
0095 void rt2x00mmio_flush_queue(struct data_queue *queue, bool drop);
0096 
0097 /*
0098  * Device initialization handlers.
0099  */
0100 int rt2x00mmio_initialize(struct rt2x00_dev *rt2x00dev);
0101 void rt2x00mmio_uninitialize(struct rt2x00_dev *rt2x00dev);
0102 
0103 #endif /* RT2X00MMIO_H */