18c2ecf20Sopenharmony_ci/******************************************************************************
28c2ecf20Sopenharmony_ci *
38c2ecf20Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license.  When using or
48c2ecf20Sopenharmony_ci * redistributing this file, you may do so under either license.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * GPL LICENSE SUMMARY
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved.
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
118c2ecf20Sopenharmony_ci * it under the terms of version 2 of the GNU General Public License as
128c2ecf20Sopenharmony_ci * published by the Free Software Foundation.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful, but
158c2ecf20Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of
168c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
178c2ecf20Sopenharmony_ci * General Public License for more details.
188c2ecf20Sopenharmony_ci *
198c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License
208c2ecf20Sopenharmony_ci * along with this program; if not, write to the Free Software
218c2ecf20Sopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
228c2ecf20Sopenharmony_ci * USA
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci * The full GNU General Public License is included in this distribution
258c2ecf20Sopenharmony_ci * in the file called LICENSE.GPL.
268c2ecf20Sopenharmony_ci *
278c2ecf20Sopenharmony_ci * Contact Information:
288c2ecf20Sopenharmony_ci *  Intel Linux Wireless <ilw@linux.intel.com>
298c2ecf20Sopenharmony_ci * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
308c2ecf20Sopenharmony_ci *
318c2ecf20Sopenharmony_ci * BSD LICENSE
328c2ecf20Sopenharmony_ci *
338c2ecf20Sopenharmony_ci * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved.
348c2ecf20Sopenharmony_ci * All rights reserved.
358c2ecf20Sopenharmony_ci *
368c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
378c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions
388c2ecf20Sopenharmony_ci * are met:
398c2ecf20Sopenharmony_ci *
408c2ecf20Sopenharmony_ci *  * Redistributions of source code must retain the above copyright
418c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer.
428c2ecf20Sopenharmony_ci *  * Redistributions in binary form must reproduce the above copyright
438c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer in
448c2ecf20Sopenharmony_ci *    the documentation and/or other materials provided with the
458c2ecf20Sopenharmony_ci *    distribution.
468c2ecf20Sopenharmony_ci *  * Neither the name Intel Corporation nor the names of its
478c2ecf20Sopenharmony_ci *    contributors may be used to endorse or promote products derived
488c2ecf20Sopenharmony_ci *    from this software without specific prior written permission.
498c2ecf20Sopenharmony_ci *
508c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
518c2ecf20Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
528c2ecf20Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
538c2ecf20Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
548c2ecf20Sopenharmony_ci * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
558c2ecf20Sopenharmony_ci * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
568c2ecf20Sopenharmony_ci * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
578c2ecf20Sopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
588c2ecf20Sopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
598c2ecf20Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
608c2ecf20Sopenharmony_ci * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
618c2ecf20Sopenharmony_ci *
628c2ecf20Sopenharmony_ci *****************************************************************************/
638c2ecf20Sopenharmony_ci#ifndef __il_csr_h__
648c2ecf20Sopenharmony_ci#define __il_csr_h__
658c2ecf20Sopenharmony_ci/*
668c2ecf20Sopenharmony_ci * CSR (control and status registers)
678c2ecf20Sopenharmony_ci *
688c2ecf20Sopenharmony_ci * CSR registers are mapped directly into PCI bus space, and are accessible
698c2ecf20Sopenharmony_ci * whenever platform supplies power to device, even when device is in
708c2ecf20Sopenharmony_ci * low power states due to driver-invoked device resets
718c2ecf20Sopenharmony_ci * (e.g. CSR_RESET_REG_FLAG_SW_RESET) or uCode-driven power-saving modes.
728c2ecf20Sopenharmony_ci *
738c2ecf20Sopenharmony_ci * Use _il_wr() and _il_rd() family to access these registers;
748c2ecf20Sopenharmony_ci * these provide simple PCI bus access, without waking up the MAC.
758c2ecf20Sopenharmony_ci * Do not use il_wr() family for these registers;
768c2ecf20Sopenharmony_ci * no need to "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ.
778c2ecf20Sopenharmony_ci * The MAC (uCode processor, etc.) does not need to be powered up for accessing
788c2ecf20Sopenharmony_ci * the CSR registers.
798c2ecf20Sopenharmony_ci *
808c2ecf20Sopenharmony_ci * NOTE:  Device does need to be awake in order to read this memory
818c2ecf20Sopenharmony_ci *        via CSR_EEPROM register
828c2ecf20Sopenharmony_ci */
838c2ecf20Sopenharmony_ci#define CSR_BASE    (0x000)
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG    (CSR_BASE+0x000)	/* hardware interface config */
868c2ecf20Sopenharmony_ci#define CSR_INT_COALESCING      (CSR_BASE+0x004)	/* accum ints, 32-usec units */
878c2ecf20Sopenharmony_ci#define CSR_INT                 (CSR_BASE+0x008)	/* host interrupt status/ack */
888c2ecf20Sopenharmony_ci#define CSR_INT_MASK            (CSR_BASE+0x00c)	/* host interrupt enable */
898c2ecf20Sopenharmony_ci#define CSR_FH_INT_STATUS       (CSR_BASE+0x010)	/* busmaster int status/ack */
908c2ecf20Sopenharmony_ci#define CSR_GPIO_IN             (CSR_BASE+0x018)	/* read external chip pins */
918c2ecf20Sopenharmony_ci#define CSR_RESET               (CSR_BASE+0x020)	/* busmaster enable, NMI, etc */
928c2ecf20Sopenharmony_ci#define CSR_GP_CNTRL            (CSR_BASE+0x024)
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci/* 2nd byte of CSR_INT_COALESCING, not accessible via _il_wr()! */
958c2ecf20Sopenharmony_ci#define CSR_INT_PERIODIC_REG	(CSR_BASE+0x005)
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci/*
988c2ecf20Sopenharmony_ci * Hardware revision info
998c2ecf20Sopenharmony_ci * Bit fields:
1008c2ecf20Sopenharmony_ci * 31-8:  Reserved
1018c2ecf20Sopenharmony_ci *  7-4:  Type of device:  see CSR_HW_REV_TYPE_xxx definitions
1028c2ecf20Sopenharmony_ci *  3-2:  Revision step:  0 = A, 1 = B, 2 = C, 3 = D
1038c2ecf20Sopenharmony_ci *  1-0:  "Dash" (-) value, as in A-1, etc.
1048c2ecf20Sopenharmony_ci *
1058c2ecf20Sopenharmony_ci * NOTE:  Revision step affects calculation of CCK txpower for 4965.
1068c2ecf20Sopenharmony_ci * NOTE:  See also CSR_HW_REV_WA_REG (work-around for bug in 4965).
1078c2ecf20Sopenharmony_ci */
1088c2ecf20Sopenharmony_ci#define CSR_HW_REV              (CSR_BASE+0x028)
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci/*
1118c2ecf20Sopenharmony_ci * EEPROM memory reads
1128c2ecf20Sopenharmony_ci *
1138c2ecf20Sopenharmony_ci * NOTE:  Device must be awake, initialized via apm_ops.init(),
1148c2ecf20Sopenharmony_ci *        in order to read.
1158c2ecf20Sopenharmony_ci */
1168c2ecf20Sopenharmony_ci#define CSR_EEPROM_REG          (CSR_BASE+0x02c)
1178c2ecf20Sopenharmony_ci#define CSR_EEPROM_GP           (CSR_BASE+0x030)
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci#define CSR_GIO_REG		(CSR_BASE+0x03C)
1208c2ecf20Sopenharmony_ci#define CSR_GP_UCODE_REG	(CSR_BASE+0x048)
1218c2ecf20Sopenharmony_ci#define CSR_GP_DRIVER_REG	(CSR_BASE+0x050)
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci/*
1248c2ecf20Sopenharmony_ci * UCODE-DRIVER GP (general purpose) mailbox registers.
1258c2ecf20Sopenharmony_ci * SET/CLR registers set/clear bit(s) if "1" is written.
1268c2ecf20Sopenharmony_ci */
1278c2ecf20Sopenharmony_ci#define CSR_UCODE_DRV_GP1       (CSR_BASE+0x054)
1288c2ecf20Sopenharmony_ci#define CSR_UCODE_DRV_GP1_SET   (CSR_BASE+0x058)
1298c2ecf20Sopenharmony_ci#define CSR_UCODE_DRV_GP1_CLR   (CSR_BASE+0x05c)
1308c2ecf20Sopenharmony_ci#define CSR_UCODE_DRV_GP2       (CSR_BASE+0x060)
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci#define CSR_LED_REG             (CSR_BASE+0x094)
1338c2ecf20Sopenharmony_ci#define CSR_DRAM_INT_TBL_REG	(CSR_BASE+0x0A0)
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci/* GIO Chicken Bits (PCI Express bus link power management) */
1368c2ecf20Sopenharmony_ci#define CSR_GIO_CHICKEN_BITS    (CSR_BASE+0x100)
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci/* Analog phase-lock-loop configuration  */
1398c2ecf20Sopenharmony_ci#define CSR_ANA_PLL_CFG         (CSR_BASE+0x20c)
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci/*
1428c2ecf20Sopenharmony_ci * CSR Hardware Revision Workaround Register.  Indicates hardware rev;
1438c2ecf20Sopenharmony_ci * "step" determines CCK backoff for txpower calculation.  Used for 4965 only.
1448c2ecf20Sopenharmony_ci * See also CSR_HW_REV register.
1458c2ecf20Sopenharmony_ci * Bit fields:
1468c2ecf20Sopenharmony_ci *  3-2:  0 = A, 1 = B, 2 = C, 3 = D step
1478c2ecf20Sopenharmony_ci *  1-0:  "Dash" (-) value, as in C-1, etc.
1488c2ecf20Sopenharmony_ci */
1498c2ecf20Sopenharmony_ci#define CSR_HW_REV_WA_REG		(CSR_BASE+0x22C)
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci#define CSR_DBG_HPET_MEM_REG		(CSR_BASE+0x240)
1528c2ecf20Sopenharmony_ci#define CSR_DBG_LINK_PWR_MGMT_REG	(CSR_BASE+0x250)
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci/* Bits for CSR_HW_IF_CONFIG_REG */
1558c2ecf20Sopenharmony_ci#define CSR49_HW_IF_CONFIG_REG_BIT_4965_R	(0x00000010)
1568c2ecf20Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG_MSK_BOARD_VER	(0x00000C00)
1578c2ecf20Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG_BIT_MAC_SI 	(0x00000100)
1588c2ecf20Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI	(0x00000200)
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci#define CSR39_HW_IF_CONFIG_REG_BIT_3945_MB         (0x00000100)
1618c2ecf20Sopenharmony_ci#define CSR39_HW_IF_CONFIG_REG_BIT_3945_MM         (0x00000200)
1628c2ecf20Sopenharmony_ci#define CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC            (0x00000400)
1638c2ecf20Sopenharmony_ci#define CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE         (0x00000800)
1648c2ecf20Sopenharmony_ci#define CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A    (0x00000000)
1658c2ecf20Sopenharmony_ci#define CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B    (0x00001000)
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A	(0x00080000)
1688c2ecf20Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM	(0x00200000)
1698c2ecf20Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG_BIT_NIC_READY	(0x00400000)	/* PCI_OWN_SEM */
1708c2ecf20Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE (0x02000000)	/* ME_OWN */
1718c2ecf20Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG_PREPARE		  (0x08000000)	/* WAKE_ME */
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci#define CSR_INT_PERIODIC_DIS			(0x00)	/* disable periodic int */
1748c2ecf20Sopenharmony_ci#define CSR_INT_PERIODIC_ENA			(0xFF)	/* 255*32 usec ~ 8 msec */
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci/* interrupt flags in INTA, set by uCode or hardware (e.g. dma),
1778c2ecf20Sopenharmony_ci * acknowledged (reset) by host writing "1" to flagged bits. */
1788c2ecf20Sopenharmony_ci#define CSR_INT_BIT_FH_RX        (1 << 31)	/* Rx DMA, cmd responses, FH_INT[17:16] */
1798c2ecf20Sopenharmony_ci#define CSR_INT_BIT_HW_ERR       (1 << 29)	/* DMA hardware error FH_INT[31] */
1808c2ecf20Sopenharmony_ci#define CSR_INT_BIT_RX_PERIODIC	 (1 << 28)	/* Rx periodic */
1818c2ecf20Sopenharmony_ci#define CSR_INT_BIT_FH_TX        (1 << 27)	/* Tx DMA FH_INT[1:0] */
1828c2ecf20Sopenharmony_ci#define CSR_INT_BIT_SCD          (1 << 26)	/* TXQ pointer advanced */
1838c2ecf20Sopenharmony_ci#define CSR_INT_BIT_SW_ERR       (1 << 25)	/* uCode error */
1848c2ecf20Sopenharmony_ci#define CSR_INT_BIT_RF_KILL      (1 << 7)	/* HW RFKILL switch GP_CNTRL[27] toggled */
1858c2ecf20Sopenharmony_ci#define CSR_INT_BIT_CT_KILL      (1 << 6)	/* Critical temp (chip too hot) rfkill */
1868c2ecf20Sopenharmony_ci#define CSR_INT_BIT_SW_RX        (1 << 3)	/* Rx, command responses, 3945 */
1878c2ecf20Sopenharmony_ci#define CSR_INT_BIT_WAKEUP       (1 << 1)	/* NIC controller waking up (pwr mgmt) */
1888c2ecf20Sopenharmony_ci#define CSR_INT_BIT_ALIVE        (1 << 0)	/* uCode interrupts once it initializes */
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci#define CSR_INI_SET_MASK	(CSR_INT_BIT_FH_RX   | \
1918c2ecf20Sopenharmony_ci				 CSR_INT_BIT_HW_ERR  | \
1928c2ecf20Sopenharmony_ci				 CSR_INT_BIT_FH_TX   | \
1938c2ecf20Sopenharmony_ci				 CSR_INT_BIT_SW_ERR  | \
1948c2ecf20Sopenharmony_ci				 CSR_INT_BIT_RF_KILL | \
1958c2ecf20Sopenharmony_ci				 CSR_INT_BIT_SW_RX   | \
1968c2ecf20Sopenharmony_ci				 CSR_INT_BIT_WAKEUP  | \
1978c2ecf20Sopenharmony_ci				 CSR_INT_BIT_ALIVE)
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci/* interrupt flags in FH (flow handler) (PCI busmaster DMA) */
2008c2ecf20Sopenharmony_ci#define CSR_FH_INT_BIT_ERR       (1 << 31)	/* Error */
2018c2ecf20Sopenharmony_ci#define CSR_FH_INT_BIT_HI_PRIOR  (1 << 30)	/* High priority Rx, bypass coalescing */
2028c2ecf20Sopenharmony_ci#define CSR39_FH_INT_BIT_RX_CHNL2  (1 << 18)	/* Rx channel 2 (3945 only) */
2038c2ecf20Sopenharmony_ci#define CSR_FH_INT_BIT_RX_CHNL1  (1 << 17)	/* Rx channel 1 */
2048c2ecf20Sopenharmony_ci#define CSR_FH_INT_BIT_RX_CHNL0  (1 << 16)	/* Rx channel 0 */
2058c2ecf20Sopenharmony_ci#define CSR39_FH_INT_BIT_TX_CHNL6  (1 << 6)	/* Tx channel 6 (3945 only) */
2068c2ecf20Sopenharmony_ci#define CSR_FH_INT_BIT_TX_CHNL1  (1 << 1)	/* Tx channel 1 */
2078c2ecf20Sopenharmony_ci#define CSR_FH_INT_BIT_TX_CHNL0  (1 << 0)	/* Tx channel 0 */
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci#define CSR39_FH_INT_RX_MASK	(CSR_FH_INT_BIT_HI_PRIOR | \
2108c2ecf20Sopenharmony_ci				 CSR39_FH_INT_BIT_RX_CHNL2 | \
2118c2ecf20Sopenharmony_ci				 CSR_FH_INT_BIT_RX_CHNL1 | \
2128c2ecf20Sopenharmony_ci				 CSR_FH_INT_BIT_RX_CHNL0)
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci#define CSR39_FH_INT_TX_MASK	(CSR39_FH_INT_BIT_TX_CHNL6 | \
2158c2ecf20Sopenharmony_ci				 CSR_FH_INT_BIT_TX_CHNL1 | \
2168c2ecf20Sopenharmony_ci				 CSR_FH_INT_BIT_TX_CHNL0)
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci#define CSR49_FH_INT_RX_MASK	(CSR_FH_INT_BIT_HI_PRIOR | \
2198c2ecf20Sopenharmony_ci				 CSR_FH_INT_BIT_RX_CHNL1 | \
2208c2ecf20Sopenharmony_ci				 CSR_FH_INT_BIT_RX_CHNL0)
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci#define CSR49_FH_INT_TX_MASK	(CSR_FH_INT_BIT_TX_CHNL1 | \
2238c2ecf20Sopenharmony_ci				 CSR_FH_INT_BIT_TX_CHNL0)
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci/* GPIO */
2268c2ecf20Sopenharmony_ci#define CSR_GPIO_IN_BIT_AUX_POWER                   (0x00000200)
2278c2ecf20Sopenharmony_ci#define CSR_GPIO_IN_VAL_VAUX_PWR_SRC                (0x00000000)
2288c2ecf20Sopenharmony_ci#define CSR_GPIO_IN_VAL_VMAIN_PWR_SRC               (0x00000200)
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci/* RESET */
2318c2ecf20Sopenharmony_ci#define CSR_RESET_REG_FLAG_NEVO_RESET                (0x00000001)
2328c2ecf20Sopenharmony_ci#define CSR_RESET_REG_FLAG_FORCE_NMI                 (0x00000002)
2338c2ecf20Sopenharmony_ci#define CSR_RESET_REG_FLAG_SW_RESET                  (0x00000080)
2348c2ecf20Sopenharmony_ci#define CSR_RESET_REG_FLAG_MASTER_DISABLED           (0x00000100)
2358c2ecf20Sopenharmony_ci#define CSR_RESET_REG_FLAG_STOP_MASTER               (0x00000200)
2368c2ecf20Sopenharmony_ci#define CSR_RESET_LINK_PWR_MGMT_DISABLED             (0x80000000)
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci/*
2398c2ecf20Sopenharmony_ci * GP (general purpose) CONTROL REGISTER
2408c2ecf20Sopenharmony_ci * Bit fields:
2418c2ecf20Sopenharmony_ci *    27:  HW_RF_KILL_SW
2428c2ecf20Sopenharmony_ci *         Indicates state of (platform's) hardware RF-Kill switch
2438c2ecf20Sopenharmony_ci * 26-24:  POWER_SAVE_TYPE
2448c2ecf20Sopenharmony_ci *         Indicates current power-saving mode:
2458c2ecf20Sopenharmony_ci *         000 -- No power saving
2468c2ecf20Sopenharmony_ci *         001 -- MAC power-down
2478c2ecf20Sopenharmony_ci *         010 -- PHY (radio) power-down
2488c2ecf20Sopenharmony_ci *         011 -- Error
2498c2ecf20Sopenharmony_ci *   9-6:  SYS_CONFIG
2508c2ecf20Sopenharmony_ci *         Indicates current system configuration, reflecting pins on chip
2518c2ecf20Sopenharmony_ci *         as forced high/low by device circuit board.
2528c2ecf20Sopenharmony_ci *     4:  GOING_TO_SLEEP
2538c2ecf20Sopenharmony_ci *         Indicates MAC is entering a power-saving sleep power-down.
2548c2ecf20Sopenharmony_ci *         Not a good time to access device-internal resources.
2558c2ecf20Sopenharmony_ci *     3:  MAC_ACCESS_REQ
2568c2ecf20Sopenharmony_ci *         Host sets this to request and maintain MAC wakeup, to allow host
2578c2ecf20Sopenharmony_ci *         access to device-internal resources.  Host must wait for
2588c2ecf20Sopenharmony_ci *         MAC_CLOCK_READY (and !GOING_TO_SLEEP) before accessing non-CSR
2598c2ecf20Sopenharmony_ci *         device registers.
2608c2ecf20Sopenharmony_ci *     2:  INIT_DONE
2618c2ecf20Sopenharmony_ci *         Host sets this to put device into fully operational D0 power mode.
2628c2ecf20Sopenharmony_ci *         Host resets this after SW_RESET to put device into low power mode.
2638c2ecf20Sopenharmony_ci *     0:  MAC_CLOCK_READY
2648c2ecf20Sopenharmony_ci *         Indicates MAC (ucode processor, etc.) is powered up and can run.
2658c2ecf20Sopenharmony_ci *         Internal resources are accessible.
2668c2ecf20Sopenharmony_ci *         NOTE:  This does not indicate that the processor is actually running.
2678c2ecf20Sopenharmony_ci *         NOTE:  This does not indicate that 4965 or 3945 has completed
2688c2ecf20Sopenharmony_ci *                init or post-power-down restore of internal SRAM memory.
2698c2ecf20Sopenharmony_ci *                Use CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP as indication that
2708c2ecf20Sopenharmony_ci *                SRAM is restored and uCode is in normal operation mode.
2718c2ecf20Sopenharmony_ci *                Later devices (5xxx/6xxx/1xxx) use non-volatile SRAM, and
2728c2ecf20Sopenharmony_ci *                do not need to save/restore it.
2738c2ecf20Sopenharmony_ci *         NOTE:  After device reset, this bit remains "0" until host sets
2748c2ecf20Sopenharmony_ci *                INIT_DONE
2758c2ecf20Sopenharmony_ci */
2768c2ecf20Sopenharmony_ci#define CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY        (0x00000001)
2778c2ecf20Sopenharmony_ci#define CSR_GP_CNTRL_REG_FLAG_INIT_DONE              (0x00000004)
2788c2ecf20Sopenharmony_ci#define CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ         (0x00000008)
2798c2ecf20Sopenharmony_ci#define CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP         (0x00000010)
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci#define CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN           (0x00000001)
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci#define CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE         (0x07000000)
2848c2ecf20Sopenharmony_ci#define CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE         (0x04000000)
2858c2ecf20Sopenharmony_ci#define CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW          (0x08000000)
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci/* EEPROM REG */
2888c2ecf20Sopenharmony_ci#define CSR_EEPROM_REG_READ_VALID_MSK	(0x00000001)
2898c2ecf20Sopenharmony_ci#define CSR_EEPROM_REG_BIT_CMD		(0x00000002)
2908c2ecf20Sopenharmony_ci#define CSR_EEPROM_REG_MSK_ADDR		(0x0000FFFC)
2918c2ecf20Sopenharmony_ci#define CSR_EEPROM_REG_MSK_DATA		(0xFFFF0000)
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci/* EEPROM GP */
2948c2ecf20Sopenharmony_ci#define CSR_EEPROM_GP_VALID_MSK		(0x00000007)	/* signature */
2958c2ecf20Sopenharmony_ci#define CSR_EEPROM_GP_IF_OWNER_MSK	(0x00000180)
2968c2ecf20Sopenharmony_ci#define CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K		(0x00000002)
2978c2ecf20Sopenharmony_ci#define CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K		(0x00000004)
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci/* GP REG */
3008c2ecf20Sopenharmony_ci#define CSR_GP_REG_POWER_SAVE_STATUS_MSK            (0x03000000)	/* bit 24/25 */
3018c2ecf20Sopenharmony_ci#define CSR_GP_REG_NO_POWER_SAVE            (0x00000000)
3028c2ecf20Sopenharmony_ci#define CSR_GP_REG_MAC_POWER_SAVE           (0x01000000)
3038c2ecf20Sopenharmony_ci#define CSR_GP_REG_PHY_POWER_SAVE           (0x02000000)
3048c2ecf20Sopenharmony_ci#define CSR_GP_REG_POWER_SAVE_ERROR         (0x03000000)
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci/* CSR GIO */
3078c2ecf20Sopenharmony_ci#define CSR_GIO_REG_VAL_L0S_ENABLED	(0x00000002)
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci/*
3108c2ecf20Sopenharmony_ci * UCODE-DRIVER GP (general purpose) mailbox register 1
3118c2ecf20Sopenharmony_ci * Host driver and uCode write and/or read this register to communicate with
3128c2ecf20Sopenharmony_ci * each other.
3138c2ecf20Sopenharmony_ci * Bit fields:
3148c2ecf20Sopenharmony_ci *     4:  UCODE_DISABLE
3158c2ecf20Sopenharmony_ci *         Host sets this to request permanent halt of uCode, same as
3168c2ecf20Sopenharmony_ci *         sending CARD_STATE command with "halt" bit set.
3178c2ecf20Sopenharmony_ci *     3:  CT_KILL_EXIT
3188c2ecf20Sopenharmony_ci *         Host sets this to request exit from CT_KILL state, i.e. host thinks
3198c2ecf20Sopenharmony_ci *         device temperature is low enough to continue normal operation.
3208c2ecf20Sopenharmony_ci *     2:  CMD_BLOCKED
3218c2ecf20Sopenharmony_ci *         Host sets this during RF KILL power-down sequence (HW, SW, CT KILL)
3228c2ecf20Sopenharmony_ci *         to release uCode to clear all Tx and command queues, enter
3238c2ecf20Sopenharmony_ci *         unassociated mode, and power down.
3248c2ecf20Sopenharmony_ci *         NOTE:  Some devices also use HBUS_TARG_MBX_C register for this bit.
3258c2ecf20Sopenharmony_ci *     1:  SW_BIT_RFKILL
3268c2ecf20Sopenharmony_ci *         Host sets this when issuing CARD_STATE command to request
3278c2ecf20Sopenharmony_ci *         device sleep.
3288c2ecf20Sopenharmony_ci *     0:  MAC_SLEEP
3298c2ecf20Sopenharmony_ci *         uCode sets this when preparing a power-saving power-down.
3308c2ecf20Sopenharmony_ci *         uCode resets this when power-up is complete and SRAM is sane.
3318c2ecf20Sopenharmony_ci *         NOTE:  3945/4965 saves internal SRAM data to host when powering down,
3328c2ecf20Sopenharmony_ci *                and must restore this data after powering back up.
3338c2ecf20Sopenharmony_ci *                MAC_SLEEP is the best indication that restore is complete.
3348c2ecf20Sopenharmony_ci *                Later devices (5xxx/6xxx/1xxx) use non-volatile SRAM, and
3358c2ecf20Sopenharmony_ci *                do not need to save/restore it.
3368c2ecf20Sopenharmony_ci */
3378c2ecf20Sopenharmony_ci#define CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP             (0x00000001)
3388c2ecf20Sopenharmony_ci#define CSR_UCODE_SW_BIT_RFKILL                     (0x00000002)
3398c2ecf20Sopenharmony_ci#define CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED           (0x00000004)
3408c2ecf20Sopenharmony_ci#define CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT      (0x00000008)
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci/* GIO Chicken Bits (PCI Express bus link power management) */
3438c2ecf20Sopenharmony_ci#define CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX  (0x00800000)
3448c2ecf20Sopenharmony_ci#define CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER  (0x20000000)
3458c2ecf20Sopenharmony_ci
3468c2ecf20Sopenharmony_ci/* LED */
3478c2ecf20Sopenharmony_ci#define CSR_LED_BSM_CTRL_MSK (0xFFFFFFDF)
3488c2ecf20Sopenharmony_ci#define CSR_LED_REG_TRUN_ON (0x78)
3498c2ecf20Sopenharmony_ci#define CSR_LED_REG_TRUN_OFF (0x38)
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci/* ANA_PLL */
3528c2ecf20Sopenharmony_ci#define CSR39_ANA_PLL_CFG_VAL        (0x01000000)
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ci/* HPET MEM debug */
3558c2ecf20Sopenharmony_ci#define CSR_DBG_HPET_MEM_REG_VAL	(0xFFFF0000)
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_ci/* DRAM INT TBL */
3588c2ecf20Sopenharmony_ci#define CSR_DRAM_INT_TBL_ENABLE		(1 << 31)
3598c2ecf20Sopenharmony_ci#define CSR_DRAM_INIT_TBL_WRAP_CHECK	(1 << 27)
3608c2ecf20Sopenharmony_ci
3618c2ecf20Sopenharmony_ci/*
3628c2ecf20Sopenharmony_ci * HBUS (Host-side Bus)
3638c2ecf20Sopenharmony_ci *
3648c2ecf20Sopenharmony_ci * HBUS registers are mapped directly into PCI bus space, but are used
3658c2ecf20Sopenharmony_ci * to indirectly access device's internal memory or registers that
3668c2ecf20Sopenharmony_ci * may be powered-down.
3678c2ecf20Sopenharmony_ci *
3688c2ecf20Sopenharmony_ci * Use il_wr()/il_rd() family
3698c2ecf20Sopenharmony_ci * for these registers;
3708c2ecf20Sopenharmony_ci * host must "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ
3718c2ecf20Sopenharmony_ci * to make sure the MAC (uCode processor, etc.) is powered up for accessing
3728c2ecf20Sopenharmony_ci * internal resources.
3738c2ecf20Sopenharmony_ci *
3748c2ecf20Sopenharmony_ci * Do not use _il_wr()/_il_rd() family to access these registers;
3758c2ecf20Sopenharmony_ci * these provide only simple PCI bus access, without waking up the MAC.
3768c2ecf20Sopenharmony_ci */
3778c2ecf20Sopenharmony_ci#define HBUS_BASE	(0x400)
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci/*
3808c2ecf20Sopenharmony_ci * Registers for accessing device's internal SRAM memory (e.g. SCD SRAM
3818c2ecf20Sopenharmony_ci * structures, error log, event log, verifying uCode load).
3828c2ecf20Sopenharmony_ci * First write to address register, then read from or write to data register
3838c2ecf20Sopenharmony_ci * to complete the job.  Once the address register is set up, accesses to
3848c2ecf20Sopenharmony_ci * data registers auto-increment the address by one dword.
3858c2ecf20Sopenharmony_ci * Bit usage for address registers (read or write):
3868c2ecf20Sopenharmony_ci *  0-31:  memory address within device
3878c2ecf20Sopenharmony_ci */
3888c2ecf20Sopenharmony_ci#define HBUS_TARG_MEM_RADDR     (HBUS_BASE+0x00c)
3898c2ecf20Sopenharmony_ci#define HBUS_TARG_MEM_WADDR     (HBUS_BASE+0x010)
3908c2ecf20Sopenharmony_ci#define HBUS_TARG_MEM_WDAT      (HBUS_BASE+0x018)
3918c2ecf20Sopenharmony_ci#define HBUS_TARG_MEM_RDAT      (HBUS_BASE+0x01c)
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_ci/* Mailbox C, used as workaround alternative to CSR_UCODE_DRV_GP1 mailbox */
3948c2ecf20Sopenharmony_ci#define HBUS_TARG_MBX_C         (HBUS_BASE+0x030)
3958c2ecf20Sopenharmony_ci#define HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED         (0x00000004)
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci/*
3988c2ecf20Sopenharmony_ci * Registers for accessing device's internal peripheral registers
3998c2ecf20Sopenharmony_ci * (e.g. SCD, BSM, etc.).  First write to address register,
4008c2ecf20Sopenharmony_ci * then read from or write to data register to complete the job.
4018c2ecf20Sopenharmony_ci * Bit usage for address registers (read or write):
4028c2ecf20Sopenharmony_ci *  0-15:  register address (offset) within device
4038c2ecf20Sopenharmony_ci * 24-25:  (# bytes - 1) to read or write (e.g. 3 for dword)
4048c2ecf20Sopenharmony_ci */
4058c2ecf20Sopenharmony_ci#define HBUS_TARG_PRPH_WADDR    (HBUS_BASE+0x044)
4068c2ecf20Sopenharmony_ci#define HBUS_TARG_PRPH_RADDR    (HBUS_BASE+0x048)
4078c2ecf20Sopenharmony_ci#define HBUS_TARG_PRPH_WDAT     (HBUS_BASE+0x04c)
4088c2ecf20Sopenharmony_ci#define HBUS_TARG_PRPH_RDAT     (HBUS_BASE+0x050)
4098c2ecf20Sopenharmony_ci
4108c2ecf20Sopenharmony_ci/*
4118c2ecf20Sopenharmony_ci * Per-Tx-queue write pointer (idx, really!)
4128c2ecf20Sopenharmony_ci * Indicates idx to next TFD that driver will fill (1 past latest filled).
4138c2ecf20Sopenharmony_ci * Bit usage:
4148c2ecf20Sopenharmony_ci *  0-7:  queue write idx
4158c2ecf20Sopenharmony_ci * 11-8:  queue selector
4168c2ecf20Sopenharmony_ci */
4178c2ecf20Sopenharmony_ci#define HBUS_TARG_WRPTR         (HBUS_BASE+0x060)
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_ci#endif /* !__il_csr_h__ */
420