18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com> 48c2ecf20Sopenharmony_ci <http://rt2x00.serialmonkey.com> 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci/* 98c2ecf20Sopenharmony_ci Module: rt2x00mmio 108c2ecf20Sopenharmony_ci Abstract: Data structures for the rt2x00mmio module. 118c2ecf20Sopenharmony_ci */ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#ifndef RT2X00MMIO_H 148c2ecf20Sopenharmony_ci#define RT2X00MMIO_H 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include <linux/io.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* 198c2ecf20Sopenharmony_ci * Register access. 208c2ecf20Sopenharmony_ci */ 218c2ecf20Sopenharmony_cistatic inline u32 rt2x00mmio_register_read(struct rt2x00_dev *rt2x00dev, 228c2ecf20Sopenharmony_ci const unsigned int offset) 238c2ecf20Sopenharmony_ci{ 248c2ecf20Sopenharmony_ci return readl(rt2x00dev->csr.base + offset); 258c2ecf20Sopenharmony_ci} 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistatic inline void rt2x00mmio_register_multiread(struct rt2x00_dev *rt2x00dev, 288c2ecf20Sopenharmony_ci const unsigned int offset, 298c2ecf20Sopenharmony_ci void *value, const u32 length) 308c2ecf20Sopenharmony_ci{ 318c2ecf20Sopenharmony_ci memcpy_fromio(value, rt2x00dev->csr.base + offset, length); 328c2ecf20Sopenharmony_ci} 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistatic inline void rt2x00mmio_register_write(struct rt2x00_dev *rt2x00dev, 358c2ecf20Sopenharmony_ci const unsigned int offset, 368c2ecf20Sopenharmony_ci u32 value) 378c2ecf20Sopenharmony_ci{ 388c2ecf20Sopenharmony_ci writel(value, rt2x00dev->csr.base + offset); 398c2ecf20Sopenharmony_ci} 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cistatic inline void rt2x00mmio_register_multiwrite(struct rt2x00_dev *rt2x00dev, 428c2ecf20Sopenharmony_ci const unsigned int offset, 438c2ecf20Sopenharmony_ci const void *value, 448c2ecf20Sopenharmony_ci const u32 length) 458c2ecf20Sopenharmony_ci{ 468c2ecf20Sopenharmony_ci __iowrite32_copy(rt2x00dev->csr.base + offset, value, length >> 2); 478c2ecf20Sopenharmony_ci} 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci/** 508c2ecf20Sopenharmony_ci * rt2x00mmio_regbusy_read - Read from register with busy check 518c2ecf20Sopenharmony_ci * @rt2x00dev: Device pointer, see &struct rt2x00_dev. 528c2ecf20Sopenharmony_ci * @offset: Register offset 538c2ecf20Sopenharmony_ci * @field: Field to check if register is busy 548c2ecf20Sopenharmony_ci * @reg: Pointer to where register contents should be stored 558c2ecf20Sopenharmony_ci * 568c2ecf20Sopenharmony_ci * This function will read the given register, and checks if the 578c2ecf20Sopenharmony_ci * register is busy. If it is, it will sleep for a couple of 588c2ecf20Sopenharmony_ci * microseconds before reading the register again. If the register 598c2ecf20Sopenharmony_ci * is not read after a certain timeout, this function will return 608c2ecf20Sopenharmony_ci * FALSE. 618c2ecf20Sopenharmony_ci */ 628c2ecf20Sopenharmony_ciint rt2x00mmio_regbusy_read(struct rt2x00_dev *rt2x00dev, 638c2ecf20Sopenharmony_ci const unsigned int offset, 648c2ecf20Sopenharmony_ci const struct rt2x00_field32 field, 658c2ecf20Sopenharmony_ci u32 *reg); 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci/** 688c2ecf20Sopenharmony_ci * struct queue_entry_priv_mmio: Per entry PCI specific information 698c2ecf20Sopenharmony_ci * 708c2ecf20Sopenharmony_ci * @desc: Pointer to device descriptor 718c2ecf20Sopenharmony_ci * @desc_dma: DMA pointer to &desc. 728c2ecf20Sopenharmony_ci */ 738c2ecf20Sopenharmony_cistruct queue_entry_priv_mmio { 748c2ecf20Sopenharmony_ci __le32 *desc; 758c2ecf20Sopenharmony_ci dma_addr_t desc_dma; 768c2ecf20Sopenharmony_ci}; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci/** 798c2ecf20Sopenharmony_ci * rt2x00mmio_rxdone - Handle RX done events 808c2ecf20Sopenharmony_ci * @rt2x00dev: Device pointer, see &struct rt2x00_dev. 818c2ecf20Sopenharmony_ci * 828c2ecf20Sopenharmony_ci * Returns true if there are still rx frames pending and false if all 838c2ecf20Sopenharmony_ci * pending rx frames were processed. 848c2ecf20Sopenharmony_ci */ 858c2ecf20Sopenharmony_cibool rt2x00mmio_rxdone(struct rt2x00_dev *rt2x00dev); 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/** 888c2ecf20Sopenharmony_ci * rt2x00mmio_flush_queue - Flush data queue 898c2ecf20Sopenharmony_ci * @queue: Data queue to stop 908c2ecf20Sopenharmony_ci * @drop: True to drop all pending frames. 918c2ecf20Sopenharmony_ci * 928c2ecf20Sopenharmony_ci * This will wait for a maximum of 100ms, waiting for the queues 938c2ecf20Sopenharmony_ci * to become empty. 948c2ecf20Sopenharmony_ci */ 958c2ecf20Sopenharmony_civoid rt2x00mmio_flush_queue(struct data_queue *queue, bool drop); 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci/* 988c2ecf20Sopenharmony_ci * Device initialization handlers. 998c2ecf20Sopenharmony_ci */ 1008c2ecf20Sopenharmony_ciint rt2x00mmio_initialize(struct rt2x00_dev *rt2x00dev); 1018c2ecf20Sopenharmony_civoid rt2x00mmio_uninitialize(struct rt2x00_dev *rt2x00dev); 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci#endif /* RT2X00MMIO_H */ 104