/* $NetBSD: rtwreg.h,v 1.29 2016/09/15 21:45:37 jdolecek Exp $ */
/*-
* Copyright (c) 2004, 2005 David Young. All rights reserved.
*
* Programmed for NetBSD by David Young.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY David Young ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David
* Young BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*/
#include <lib/libkern/libkern.h>
/* RTL8180L Host Control and Status Registers */
#define RTW_IDR0 0x00 /* ID Register: MAC addr, 6 bytes.
* Auto-loaded from EEPROM. Read by byte,
* by word, or by double word, but write
* only by double word.
*/
#define RTW_IDR1 0x04
#define RTW_TCR_CRC __BIT(16) /* 0: RTL8180 appends CRC32
* 1: host appends CRC32
*
* (I *think* this is right.
* The docs have a mysterious
* description in the
* passive voice.)
*/
#define RTW_TCR_SRL_MASK __BITS(15,8) /* Short Retry Limit */
#define RTW_TCR_LRL_MASK __BITS(7,0) /* Long Retry Limit */
#define RTW_RCR 0x44 /* Receive Configuration Register, 32b */
/* only do Early Rx on packets longer than 1536 bytes */
#define RTW_RCR_ONLYERLPKT __BIT(31)
/* enable carrier sense method 2 */
#define RTW_RCR_ENCS2 __BIT(30)
/* enable carrier sense method 1 */
#define RTW_RCR_ENCS1 __BIT(29)
#define RTW_RCR_ENMARP __BIT(28) /* enable MAC auto-reset PHY */
/* Check BSSID/ToDS/FromDS: set "Link On" when received BSSID
* matches RTW_BSSID and received ToDS/FromDS are appropriate
* according to RTW_MSR_NETYPE.
*/
#define RTW_RCR_CBSSID __BIT(23)
/* accept packets w/ PWRMGMT bit set */
#define RTW_RCR_APWRMGT __BIT(22)
/* when RTW_MSR_NETYPE == RTW_MSR_NETYPE_INFRA_OK, accept
* broadcast/multicast packets whose 3rd address matches RTL8180's MAC.
*/
#define RTW_RCR_ADD3 __BIT(21)
#define RTW_RCR_AMF __BIT(20) /* accept management frames */
#define RTW_RCR_ACF __BIT(19) /* accept control frames */
#define RTW_RCR_ADF __BIT(18) /* accept data frames */
/* Rx FIFO Threshold: RTL8180 begins PCI transfer when this many data
* bytes are received
*/
#define RTW_RCR_RXFTH_MASK __BITS(15,13)
#define RTW_RCR_RXFTH_64 __SHIFTIN(2, RTW_RCR_RXFTH_MASK)
#define RTW_RCR_RXFTH_128 __SHIFTIN(3, RTW_RCR_RXFTH_MASK)
#define RTW_RCR_RXFTH_256 __SHIFTIN(4, RTW_RCR_RXFTH_MASK)
#define RTW_RCR_RXFTH_512 __SHIFTIN(5, RTW_RCR_RXFTH_MASK)
#define RTW_RCR_RXFTH_1024 __SHIFTIN(6, RTW_RCR_RXFTH_MASK)
#define RTW_RCR_RXFTH_WHOLE __SHIFTIN(7, RTW_RCR_RXFTH_MASK)
/* LWAKE Output Signal. Only applicable to Cardbus. Pulse width is 150ms.
*
* RTW_CONFIG1_LWACT
* 0 1
* RTW_CONFIG4_LWPTN 0 active high active low
* 1 positive pulse negative pulse
*/
#define RTW_CONFIG1_LWACT __BIT(4)
#define RTW_CONFIG1_MEMMAP __BIT(3)/* using PCI memory space, read-only */
#define RTW_CONFIG1_IOMAP __BIT(2)/* using PCI I/O space, read-only */
#define RTW_CONFIG1_VPD __BIT(1)/* if set, VPD from offsets
* 0x40-0x7f in EEPROM are at
* registers 0x60-0x67 of PCI
* Configuration Space (XXX huh?)
*/
#define RTW_CONFIG1_PMEN __BIT(0)/* Power Management Enable: TBD */
#define RTW_CONFIG2 0x53 /* Configuration Register 2, 8b */
#define RTW_CONFIG2_LCK __BIT(7)/* clocks are locked, read-only:
* Tx frequency & symbol clocks
* are derived from the same OSC
*/
#define RTW_CONFIG2_ANT __BIT(6) /* diversity enabled, read-only */
#define RTW_CONFIG2_DPS __BIT(3) /* Descriptor Polling State: enable
* test mode.
*/
#define RTW_CONFIG2_PAPESIGN __BIT(2) /* TBD, from EEPROM */
#define RTW_CONFIG2_PAPETIME_MASK __BITS(1,0) /* TBD, from EEPROM */
#define RTW_ANAPARM 0x54 /* Analog parameter, 32b */
#define RTW_ANAPARM_RFPOW0_MASK __BITS(30,28) /* undocumented bits
* which appear to
* control the power
* state of the RF
* components
*/
#define RTW_ANAPARM_RFPOW_MASK \
(RTW_ANAPARM_RFPOW0_MASK|RTW_ANAPARM_RFPOW1_MASK)
#define RTW_ANAPARM_TXDACOFF __BIT(27) /* 1: disable Tx DAC,
* 0: enable
*/
#define RTW_ANAPARM_RFPOW1_MASK __BITS(26,20) /* undocumented bits
* which appear to
* control the power
* state of the RF
* components
*/
/*
* Maxim On/Sleep/Off control
*/
#define RTW_ANAPARM_RFPOW_MAXIM_ON __SHIFTIN(0x8, RTW_ANAPARM_RFPOW1_MASK)
#define RTW_ANAPARM_CARDSP_MASK __BITS(19,0) /* undocumented
* card-specific
* bits from the
* EEPROM.
*/
#define RTW_MSR 0x58 /* Media Status Register, 8b */
/* Network Type and Link Status */
#define RTW_MSR_NETYPE_MASK __BITS(3,2)
/* AP, XXX RTL8181 only? */
#define RTW_MSR_NETYPE_AP_OK __SHIFTIN(3, RTW_MSR_NETYPE_MASK)
/* infrastructure link ok */
#define RTW_MSR_NETYPE_INFRA_OK __SHIFTIN(2, RTW_MSR_NETYPE_MASK)
/* ad-hoc link ok */
#define RTW_MSR_NETYPE_ADHOC_OK __SHIFTIN(1, RTW_MSR_NETYPE_MASK)
/* no link */
#define RTW_MSR_NETYPE_NOLINK __SHIFTIN(0, RTW_MSR_NETYPE_MASK)
#define RTW_CONFIG3 0x59 /* Configuration Register 3, 8b */
#define RTW_CONFIG3_GNTSEL __BIT(7) /* Grant Select, read-only */
#define RTW_CONFIG3_PARMEN __BIT(6) /* Set RTW_CONFIG3_PARMEN and
* RTW_9346CR_EEM_CONFIG to
* allow RTW_ANAPARM writes.
*/
#define RTW_CONFIG3_MAGIC __BIT(5)/* Valid when RTW_CONFIG1_PMEN is
* set. If set, RTL8180 wakes up
* OS when Magic Packet is Rx'd.
*/
#define RTW_CONFIG3_CARDBEN __BIT(3)/* Cardbus-related registers
* and functions are enabled,
* read-only. XXX RTL8180 only.
*/
#define RTW_CONFIG3_CLKRUNEN __BIT(2)/* CLKRUN enabled, read-only.
* XXX RTL8180 only.
*/
#define RTW_CONFIG3_FUNCREGEN __BIT(1)/* Function Registers Enabled,
* read-only. XXX RTL8180 only.
*/
#define RTW_CONFIG3_FBTBEN __BIT(0)/* Fast back-to-back enabled,
* read-only.
*/
#define RTW_CONFIG4 0x5A /* Configuration Register 4, 8b */
#define RTW_CONFIG4_VCOPDN __BIT(7)/* VCO Power Down
* 0: normal operation
* (power-on default)
* 1: power-down VCO, RF front-end,
* and most RTL8180 components.
*/
#define RTW_CONFIG4_PWROFF __BIT(6)/* Power Off
* 0: normal operation
* (power-on default)
* 1: power-down RF front-end,
* and most RTL8180 components,
* but leave VCO on.
*
* XXX RFMD front-end only?
*/
#define RTW_CONFIG4_PWRMGT __BIT(5)/* Power Management
* 0: normal operation
* (power-on default)
* 1: set Tx packet's PWRMGMT bit.
*/
#define RTW_CONFIG4_LWPME __BIT(4)/* LANWAKE vs. PMEB: Cardbus-only
* 0: LWAKE & PMEB asserted
* simultaneously
* 1: LWAKE asserted only if
* both PMEB is asserted and
* ISOLATEB is low.
* XXX RTL8180 only.
*/
#define RTW_CONFIG4_LWPTN __BIT(2)/* see RTW_CONFIG1_LWACT
* XXX RTL8180 only.
*/
/* Radio Front-End Programming Method */
#define RTW_CONFIG4_RFTYPE_MASK __BITS(1,0)
#define RTW_CONFIG4_RFTYPE_INTERSIL __SHIFTIN(1, RTW_CONFIG4_RFTYPE_MASK)
#define RTW_CONFIG4_RFTYPE_RFMD __SHIFTIN(2, RTW_CONFIG4_RFTYPE_MASK)
#define RTW_CONFIG4_RFTYPE_PHILIPS __SHIFTIN(3, RTW_CONFIG4_RFTYPE_MASK)
#define RTW_TESTR 0x5B /* TEST mode register, 8b */
#define RTW_PSR 0x5e /* Page Select Register, 8b */
#define RTW_PSR_GPO __BIT(7)/* Control/status of pin 52. */
#define RTW_PSR_GPI __BIT(6)/* Status of pin 64. */
#define RTW_PSR_LEDGPO1 __BIT(5)/* Status/control of LED1 pin if
* RTW_CONFIG0_LEDGPOEN is set.
*/
#define RTW_PSR_LEDGPO0 __BIT(4)/* Status/control of LED0 pin if
* RTW_CONFIG0_LEDGPOEN is set.
*/
#define RTW_PSR_UWF __BIT(1)/* Enable Unicast Wakeup Frame */
#define RTW_PSR_PSEN __BIT(0)/* 1: page 1, 0: page 0 */
#define RTW_SCR 0x5f /* Security Configuration Register, 8b */
#define RTW_SCR_KM_MASK __BITS(5,4) /* Key Mode */
#define RTW_SCR_KM_WEP104 __SHIFTIN(1, RTW_SCR_KM_MASK)
#define RTW_SCR_KM_WEP40 __SHIFTIN(0, RTW_SCR_KM_MASK)
#define RTW_SCR_TXSECON __BIT(1)/* Enable Tx WEP. Invalid if
* neither RTW_CONFIG0_WEP40 nor
* RTW_CONFIG0_WEP104 is set.
*/
#define RTW_SCR_RXSECON __BIT(0)/* Enable Rx WEP. Invalid if
* neither RTW_CONFIG0_WEP40 nor
* RTW_CONFIG0_WEP104 is set.
*/
#define RTW_BCNITV 0x70 /* Beacon Interval Register, 16b */
#define RTW_BCNITV_BCNITV_MASK __BITS(9,0) /* TU between TBTT, written
* by host.
*/
#define RTW_ATIMWND 0x72 /* ATIM Window Register, 16b */
#define RTW_ATIMWND_ATIMWND __BITS(9,0) /* ATIM Window length in TU,
* written by host.
*/
#define RTW_BINTRITV 0x74 /* Beacon Interrupt Interval Register, 16b */
#define RTW_BINTRITV_BINTRITV __BITS(9,0) /* RTL8180 wakes host with
* RTW_INTR_BCNINT at BINTRITV
* microseconds before TBTT
*/
#define RTW_ATIMTRITV 0x76 /* ATIM Interrupt Interval Register, 16b */
#define RTW_ATIMTRITV_ATIMTRITV __BITS(9,0) /* RTL8180 wakes host with
* RTW_INTR_ATIMINT at ATIMTRITV
* microseconds before end of
* ATIM Window
*/
#define RTW_PHYDELAY 0x78 /* PHY Delay Register, 8b */
#define RTW_PHYDELAY_REVC_MAGIC __BIT(3) /* Rev. C magic from reference
* driver
*/
#define RTW_PHYDELAY_PHYDELAY __BITS(2,0) /* microsecond Tx delay between
* MAC and RF front-end
*/
#define RTW_CRCOUNT 0x79 /* Carrier Sense Counter, 8b */
#define RTW_CRCOUNT_MAGIC 0x4c
#define RTW_TPPOLL 0xd9 /* Transmit Priority Polling Register, 8b,
* write-only.
*/
#define RTW_TPPOLL_BQ __BIT(7)/* RTL8180 clears to notify host of a beacon
* Tx. Host writes have no effect.
*/
#define RTW_TPPOLL_HPQ __BIT(6)/* Host writes 1 to notify RTL8180 of
* high-priority Tx packets, RTL8180 clears
* to after high-priority Tx is complete.
*/
#define RTW_TPPOLL_NPQ __BIT(5)/* If RTW_CONFIG2_DPS is set,
* host writes 1 to notify RTL8180 of
* normal-priority Tx packets, RTL8180 clears
* after normal-priority Tx is complete.
*
* If RTW_CONFIG2_DPS is clear, host writes
* have no effect. RTL8180 clears after
* normal-priority Tx is complete.
*/
#define RTW_TPPOLL_LPQ __BIT(4)/* Host writes 1 to notify RTL8180 of
* low-priority Tx packets, RTL8180 clears
* after low-priority Tx is complete.
*/
#define RTW_TPPOLL_SBQ __BIT(3)/* Host writes 1 to tell RTL8180 to
* stop beacon DMA. This bit is invalid
* when RTW_CONFIG2_DPS is set.
*/
#define RTW_TPPOLL_SHPQ __BIT(2)/* Host writes 1 to tell RTL8180 to
* stop high-priority DMA.
*/
#define RTW_TPPOLL_SNPQ __BIT(1)/* Host writes 1 to tell RTL8180 to
* stop normal-priority DMA. This bit is invalid
* when RTW_CONFIG2_DPS is set.
*/
#define RTW_TPPOLL_SLPQ __BIT(0)/* Host writes 1 to tell RTL8180 to
* stop low-priority DMA.
*/
#define RTW_CWR 0xdc /* Contention Window Register, 16b, read-only */
/* Contention Window: indicates number of contention windows before Tx
*/
#define RTW_CWR_CW __BITS(9,0)
/* Retry Count Register, 16b, read-only */
#define RTW_RETRYCTR 0xde
/* Retry Count: indicates number of retries after Tx */
#define RTW_RETRYCTR_RETRYCT __BITS(7,0)
#define RTW_RDSAR 0xe4 /* Receive descriptor Start Address Register,
* 32b, 256-byte alignment.
*/
/* Function Event Register, 32b, Cardbus only. Only valid when
* both RTW_CONFIG3_CARDBEN and RTW_CONFIG3_FUNCREGEN are set.
*/
#define RTW_FER 0xf0
#define RTW_FER_INTR __BIT(15) /* set when RTW_FFER_INTR is set */
#define RTW_FER_GWAKE __BIT(4) /* General Wakeup */
/* Function Event Mask Register, 32b, Cardbus only. Only valid when
* both RTW_CONFIG3_CARDBEN and RTW_CONFIG3_FUNCREGEN are set.
*/
#define RTW_FEMR 0xf4
#define RTW_FEMR_INTR __BIT(15) /* set when RTW_FFER_INTR is set */
#define RTW_FEMR_WKUP __BIT(14) /* Wakeup Mask */
#define RTW_FEMR_GWAKE __BIT(4) /* General Wakeup */
/* Function Present State Register, 32b, read-only, Cardbus only.
* Only valid when both RTW_CONFIG3_CARDBEN and RTW_CONFIG3_FUNCREGEN
* are set.
*/
#define RTW_FPSR 0xf8
#define RTW_FPSR_INTR __BIT(15) /* TBD */
#define RTW_FPSR_GWAKE __BIT(4) /* General Wakeup: TBD */
/* Function Force Event Register, 32b, write-only, Cardbus only.
* Only valid when both RTW_CONFIG3_CARDBEN and RTW_CONFIG3_FUNCREGEN
* are set.
*/
#define RTW_FFER 0xfc
#define RTW_FFER_INTR __BIT(15) /* TBD */
#define RTW_FFER_GWAKE __BIT(4) /* General Wakeup: TBD */
#define rd_stat rd_ctl
#define rd_rssi rd_rsvd0
#define rd_tsftl rd_buf /* valid only when RTW_RXSTAT_LS is set */
#define rd_tsfth rd_rsvd1 /* valid only when RTW_RXSTAT_LS is set */
#define RTW_RXCTL_OWN __BIT(31) /* 1: owned by NIC */
#define RTW_RXCTL_EOR __BIT(30) /* end of ring */
#define RTW_RXCTL_FS __BIT(29) /* first segment */
#define RTW_RXCTL_LS __BIT(28) /* last segment */
#define RTW_RXCTL_RSVD0_MASK __BITS(29,12) /* reserved */
#define RTW_RXCTL_LENGTH_MASK __BITS(11,0) /* Rx buffer length */
#define RTW_RXSTAT_OWN RTW_RXCTL_OWN
#define RTW_RXSTAT_EOR RTW_RXCTL_EOR
#define RTW_RXSTAT_FS RTW_RXCTL_FS /* first segment */
#define RTW_RXSTAT_LS RTW_RXCTL_LS /* last segment */
#define RTW_RXSTAT_DMAFAIL __BIT(27) /* DMA failure on this pkt */
#define RTW_RXSTAT_BOVF __BIT(26) /* buffer overflow XXX means
* FIFO exhausted?
*/
#define RTW_RXSTAT_SPLCP __BIT(25) /* Rx'd with short preamble
* and PLCP header
*/
#define RTW_RXSTAT_RSVD1 __BIT(24) /* reserved */
#define RTW_RXSTAT_RATE_MASK __BITS(23,20) /* Rx rate */
#define RTW_RXSTAT_RATE_1MBPS __SHIFTIN(0, RTW_RXSTAT_RATE_MASK)
#define RTW_RXSTAT_RATE_2MBPS __SHIFTIN(1, RTW_RXSTAT_RATE_MASK)
#define RTW_RXSTAT_RATE_5MBPS __SHIFTIN(2, RTW_RXSTAT_RATE_MASK)
#define RTW_RXSTAT_RATE_11MBPS __SHIFTIN(3, RTW_RXSTAT_RATE_MASK)
#define RTW_RXSTAT_MIC __BIT(19) /* XXX from reference driver */
#define RTW_RXSTAT_MAR __BIT(18) /* is multicast */
#define RTW_RXSTAT_PAR __BIT(17) /* matches RTL8180's MAC */
#define RTW_RXSTAT_BAR __BIT(16) /* is broadcast */
#define RTW_RXSTAT_RES __BIT(15) /* error summary. valid when
* RTW_RXSTAT_LS set. indicates
* that either RTW_RXSTAT_CRC32
* or RTW_RXSTAT_ICV is set.
*/
#define RTW_RXSTAT_PWRMGT __BIT(14) /* 802.11 PWRMGMT bit is set */
#define RTW_RXSTAT_CRC16 __BIT(14) /* XXX CRC16 error, from
* reference driver
*/
#define RTW_RXSTAT_CRC32 __BIT(13) /* CRC32 error */
#define RTW_RXSTAT_ICV __BIT(12) /* ICV error */
#define RTW_RXSTAT_LENGTH_MASK __BITS(11,0) /* frame length, including
* CRC32
*/