162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*	Copyright (C) 2009 - 2010 Ivo van Doorn <IvDoorn@gmail.com>
362306a36Sopenharmony_ci *	Copyright (C) 2009 Alban Browaeys <prahal@yahoo.com>
462306a36Sopenharmony_ci *	Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
562306a36Sopenharmony_ci *	Copyright (C) 2009 Luis Correia <luis.f.correia@gmail.com>
662306a36Sopenharmony_ci *	Copyright (C) 2009 Mattias Nissler <mattias.nissler@gmx.de>
762306a36Sopenharmony_ci *	Copyright (C) 2009 Mark Asselstine <asselsm@gmail.com>
862306a36Sopenharmony_ci *	Copyright (C) 2009 Xose Vazquez Perez <xose.vazquez@gmail.com>
962306a36Sopenharmony_ci *	Copyright (C) 2009 Bart Zolnierkiewicz <bzolnier@gmail.com>
1062306a36Sopenharmony_ci *	<http://rt2x00.serialmonkey.com>
1162306a36Sopenharmony_ci */
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/*	Module: rt2800mmio
1462306a36Sopenharmony_ci *	Abstract: forward declarations for the rt2800mmio module.
1562306a36Sopenharmony_ci */
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci#ifndef RT2800MMIO_H
1862306a36Sopenharmony_ci#define RT2800MMIO_H
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci/*
2162306a36Sopenharmony_ci * Queue register offset macros
2262306a36Sopenharmony_ci */
2362306a36Sopenharmony_ci#define TX_QUEUE_REG_OFFSET	0x10
2462306a36Sopenharmony_ci#define TX_BASE_PTR(__x)	(TX_BASE_PTR0 + ((__x) * TX_QUEUE_REG_OFFSET))
2562306a36Sopenharmony_ci#define TX_MAX_CNT(__x)		(TX_MAX_CNT0 + ((__x) * TX_QUEUE_REG_OFFSET))
2662306a36Sopenharmony_ci#define TX_CTX_IDX(__x)		(TX_CTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET))
2762306a36Sopenharmony_ci#define TX_DTX_IDX(__x)		(TX_DTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET))
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci/*
3062306a36Sopenharmony_ci * DMA descriptor defines.
3162306a36Sopenharmony_ci */
3262306a36Sopenharmony_ci#define TXD_DESC_SIZE			(4 * sizeof(__le32))
3362306a36Sopenharmony_ci#define RXD_DESC_SIZE			(4 * sizeof(__le32))
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci/*
3662306a36Sopenharmony_ci * TX descriptor format for TX, PRIO and Beacon Ring.
3762306a36Sopenharmony_ci */
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci/*
4062306a36Sopenharmony_ci * Word0
4162306a36Sopenharmony_ci */
4262306a36Sopenharmony_ci#define TXD_W0_SD_PTR0			FIELD32(0xffffffff)
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci/*
4562306a36Sopenharmony_ci * Word1
4662306a36Sopenharmony_ci */
4762306a36Sopenharmony_ci#define TXD_W1_SD_LEN1			FIELD32(0x00003fff)
4862306a36Sopenharmony_ci#define TXD_W1_LAST_SEC1		FIELD32(0x00004000)
4962306a36Sopenharmony_ci#define TXD_W1_BURST			FIELD32(0x00008000)
5062306a36Sopenharmony_ci#define TXD_W1_SD_LEN0			FIELD32(0x3fff0000)
5162306a36Sopenharmony_ci#define TXD_W1_LAST_SEC0		FIELD32(0x40000000)
5262306a36Sopenharmony_ci#define TXD_W1_DMA_DONE			FIELD32(0x80000000)
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci/*
5562306a36Sopenharmony_ci * Word2
5662306a36Sopenharmony_ci */
5762306a36Sopenharmony_ci#define TXD_W2_SD_PTR1			FIELD32(0xffffffff)
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci/*
6062306a36Sopenharmony_ci * Word3
6162306a36Sopenharmony_ci * WIV: Wireless Info Valid. 1: Driver filled WI, 0: DMA needs to copy WI
6262306a36Sopenharmony_ci * QSEL: Select on-chip FIFO ID for 2nd-stage output scheduler.
6362306a36Sopenharmony_ci *       0:MGMT, 1:HCCA 2:EDCA
6462306a36Sopenharmony_ci */
6562306a36Sopenharmony_ci#define TXD_W3_WIV			FIELD32(0x01000000)
6662306a36Sopenharmony_ci#define TXD_W3_QSEL			FIELD32(0x06000000)
6762306a36Sopenharmony_ci#define TXD_W3_TCO			FIELD32(0x20000000)
6862306a36Sopenharmony_ci#define TXD_W3_UCO			FIELD32(0x40000000)
6962306a36Sopenharmony_ci#define TXD_W3_ICO			FIELD32(0x80000000)
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci/*
7262306a36Sopenharmony_ci * RX descriptor format for RX Ring.
7362306a36Sopenharmony_ci */
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci/*
7662306a36Sopenharmony_ci * Word0
7762306a36Sopenharmony_ci */
7862306a36Sopenharmony_ci#define RXD_W0_SDP0			FIELD32(0xffffffff)
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci/*
8162306a36Sopenharmony_ci * Word1
8262306a36Sopenharmony_ci */
8362306a36Sopenharmony_ci#define RXD_W1_SDL1			FIELD32(0x00003fff)
8462306a36Sopenharmony_ci#define RXD_W1_SDL0			FIELD32(0x3fff0000)
8562306a36Sopenharmony_ci#define RXD_W1_LS0			FIELD32(0x40000000)
8662306a36Sopenharmony_ci#define RXD_W1_DMA_DONE			FIELD32(0x80000000)
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci/*
8962306a36Sopenharmony_ci * Word2
9062306a36Sopenharmony_ci */
9162306a36Sopenharmony_ci#define RXD_W2_SDP1			FIELD32(0xffffffff)
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci/*
9462306a36Sopenharmony_ci * Word3
9562306a36Sopenharmony_ci * AMSDU: RX with 802.3 header, not 802.11 header.
9662306a36Sopenharmony_ci * DECRYPTED: This frame is being decrypted.
9762306a36Sopenharmony_ci */
9862306a36Sopenharmony_ci#define RXD_W3_BA			FIELD32(0x00000001)
9962306a36Sopenharmony_ci#define RXD_W3_DATA			FIELD32(0x00000002)
10062306a36Sopenharmony_ci#define RXD_W3_NULLDATA			FIELD32(0x00000004)
10162306a36Sopenharmony_ci#define RXD_W3_FRAG			FIELD32(0x00000008)
10262306a36Sopenharmony_ci#define RXD_W3_UNICAST_TO_ME		FIELD32(0x00000010)
10362306a36Sopenharmony_ci#define RXD_W3_MULTICAST		FIELD32(0x00000020)
10462306a36Sopenharmony_ci#define RXD_W3_BROADCAST		FIELD32(0x00000040)
10562306a36Sopenharmony_ci#define RXD_W3_MY_BSS			FIELD32(0x00000080)
10662306a36Sopenharmony_ci#define RXD_W3_CRC_ERROR		FIELD32(0x00000100)
10762306a36Sopenharmony_ci#define RXD_W3_CIPHER_ERROR		FIELD32(0x00000600)
10862306a36Sopenharmony_ci#define RXD_W3_AMSDU			FIELD32(0x00000800)
10962306a36Sopenharmony_ci#define RXD_W3_HTC			FIELD32(0x00001000)
11062306a36Sopenharmony_ci#define RXD_W3_RSSI			FIELD32(0x00002000)
11162306a36Sopenharmony_ci#define RXD_W3_L2PAD			FIELD32(0x00004000)
11262306a36Sopenharmony_ci#define RXD_W3_AMPDU			FIELD32(0x00008000)
11362306a36Sopenharmony_ci#define RXD_W3_DECRYPTED		FIELD32(0x00010000)
11462306a36Sopenharmony_ci#define RXD_W3_PLCP_SIGNAL		FIELD32(0x00020000)
11562306a36Sopenharmony_ci#define RXD_W3_PLCP_RSSI		FIELD32(0x00040000)
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ciunsigned int rt2800mmio_get_dma_done(struct data_queue *queue);
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci/* TX descriptor initialization */
12062306a36Sopenharmony_ci__le32 *rt2800mmio_get_txwi(struct queue_entry *entry);
12162306a36Sopenharmony_civoid rt2800mmio_write_tx_desc(struct queue_entry *entry,
12262306a36Sopenharmony_ci			      struct txentry_desc *txdesc);
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci/* RX control handlers */
12562306a36Sopenharmony_civoid rt2800mmio_fill_rxdone(struct queue_entry *entry,
12662306a36Sopenharmony_ci			    struct rxdone_entry_desc *rxdesc);
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci/* Interrupt functions */
12962306a36Sopenharmony_civoid rt2800mmio_txstatus_tasklet(struct tasklet_struct *t);
13062306a36Sopenharmony_civoid rt2800mmio_pretbtt_tasklet(struct tasklet_struct *t);
13162306a36Sopenharmony_civoid rt2800mmio_tbtt_tasklet(struct tasklet_struct *t);
13262306a36Sopenharmony_civoid rt2800mmio_rxdone_tasklet(struct tasklet_struct *t);
13362306a36Sopenharmony_civoid rt2800mmio_autowake_tasklet(struct tasklet_struct *t);
13462306a36Sopenharmony_ciirqreturn_t rt2800mmio_interrupt(int irq, void *dev_instance);
13562306a36Sopenharmony_civoid rt2800mmio_toggle_irq(struct rt2x00_dev *rt2x00dev,
13662306a36Sopenharmony_ci			   enum dev_state state);
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci/* Queue handlers */
13962306a36Sopenharmony_civoid rt2800mmio_start_queue(struct data_queue *queue);
14062306a36Sopenharmony_civoid rt2800mmio_kick_queue(struct data_queue *queue);
14162306a36Sopenharmony_civoid rt2800mmio_flush_queue(struct data_queue *queue, bool drop);
14262306a36Sopenharmony_civoid rt2800mmio_stop_queue(struct data_queue *queue);
14362306a36Sopenharmony_civoid rt2800mmio_queue_init(struct data_queue *queue);
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci/* Initialization functions */
14662306a36Sopenharmony_ciint rt2800mmio_probe_hw(struct rt2x00_dev *rt2x00dev);
14762306a36Sopenharmony_cibool rt2800mmio_get_entry_state(struct queue_entry *entry);
14862306a36Sopenharmony_civoid rt2800mmio_clear_entry(struct queue_entry *entry);
14962306a36Sopenharmony_ciint rt2800mmio_init_queues(struct rt2x00_dev *rt2x00dev);
15062306a36Sopenharmony_ciint rt2800mmio_init_registers(struct rt2x00_dev *rt2x00dev);
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ci/* Device state switch handlers. */
15362306a36Sopenharmony_ciint rt2800mmio_enable_radio(struct rt2x00_dev *rt2x00dev);
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ci#endif /* RT2800MMIO_H */
156