162306a36Sopenharmony_ci/******************************************************************************
262306a36Sopenharmony_ci *
362306a36Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license.  When using or
462306a36Sopenharmony_ci * redistributing this file, you may do so under either license.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * GPL LICENSE SUMMARY
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved.
962306a36Sopenharmony_ci *
1062306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or modify
1162306a36Sopenharmony_ci * it under the terms of version 2 of the GNU General Public License as
1262306a36Sopenharmony_ci * published by the Free Software Foundation.
1362306a36Sopenharmony_ci *
1462306a36Sopenharmony_ci * This program is distributed in the hope that it will be useful, but
1562306a36Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of
1662306a36Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1762306a36Sopenharmony_ci * General Public License for more details.
1862306a36Sopenharmony_ci *
1962306a36Sopenharmony_ci * You should have received a copy of the GNU General Public License
2062306a36Sopenharmony_ci * along with this program; if not, write to the Free Software
2162306a36Sopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
2262306a36Sopenharmony_ci * USA
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci * The full GNU General Public License is included in this distribution
2562306a36Sopenharmony_ci * in the file called LICENSE.GPL.
2662306a36Sopenharmony_ci *
2762306a36Sopenharmony_ci * Contact Information:
2862306a36Sopenharmony_ci *  Intel Linux Wireless <ilw@linux.intel.com>
2962306a36Sopenharmony_ci * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
3062306a36Sopenharmony_ci *
3162306a36Sopenharmony_ci * BSD LICENSE
3262306a36Sopenharmony_ci *
3362306a36Sopenharmony_ci * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved.
3462306a36Sopenharmony_ci * All rights reserved.
3562306a36Sopenharmony_ci *
3662306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
3762306a36Sopenharmony_ci * modification, are permitted provided that the following conditions
3862306a36Sopenharmony_ci * are met:
3962306a36Sopenharmony_ci *
4062306a36Sopenharmony_ci *  * Redistributions of source code must retain the above copyright
4162306a36Sopenharmony_ci *    notice, this list of conditions and the following disclaimer.
4262306a36Sopenharmony_ci *  * Redistributions in binary form must reproduce the above copyright
4362306a36Sopenharmony_ci *    notice, this list of conditions and the following disclaimer in
4462306a36Sopenharmony_ci *    the documentation and/or other materials provided with the
4562306a36Sopenharmony_ci *    distribution.
4662306a36Sopenharmony_ci *  * Neither the name Intel Corporation nor the names of its
4762306a36Sopenharmony_ci *    contributors may be used to endorse or promote products derived
4862306a36Sopenharmony_ci *    from this software without specific prior written permission.
4962306a36Sopenharmony_ci *
5062306a36Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
5162306a36Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5262306a36Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
5362306a36Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
5462306a36Sopenharmony_ci * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
5562306a36Sopenharmony_ci * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
5662306a36Sopenharmony_ci * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
5762306a36Sopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
5862306a36Sopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5962306a36Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
6062306a36Sopenharmony_ci * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6162306a36Sopenharmony_ci *
6262306a36Sopenharmony_ci *****************************************************************************/
6362306a36Sopenharmony_ci#ifndef __il_csr_h__
6462306a36Sopenharmony_ci#define __il_csr_h__
6562306a36Sopenharmony_ci/*
6662306a36Sopenharmony_ci * CSR (control and status registers)
6762306a36Sopenharmony_ci *
6862306a36Sopenharmony_ci * CSR registers are mapped directly into PCI bus space, and are accessible
6962306a36Sopenharmony_ci * whenever platform supplies power to device, even when device is in
7062306a36Sopenharmony_ci * low power states due to driver-invoked device resets
7162306a36Sopenharmony_ci * (e.g. CSR_RESET_REG_FLAG_SW_RESET) or uCode-driven power-saving modes.
7262306a36Sopenharmony_ci *
7362306a36Sopenharmony_ci * Use _il_wr() and _il_rd() family to access these registers;
7462306a36Sopenharmony_ci * these provide simple PCI bus access, without waking up the MAC.
7562306a36Sopenharmony_ci * Do not use il_wr() family for these registers;
7662306a36Sopenharmony_ci * no need to "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ.
7762306a36Sopenharmony_ci * The MAC (uCode processor, etc.) does not need to be powered up for accessing
7862306a36Sopenharmony_ci * the CSR registers.
7962306a36Sopenharmony_ci *
8062306a36Sopenharmony_ci * NOTE:  Device does need to be awake in order to read this memory
8162306a36Sopenharmony_ci *        via CSR_EEPROM register
8262306a36Sopenharmony_ci */
8362306a36Sopenharmony_ci#define CSR_BASE    (0x000)
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG    (CSR_BASE+0x000)	/* hardware interface config */
8662306a36Sopenharmony_ci#define CSR_INT_COALESCING      (CSR_BASE+0x004)	/* accum ints, 32-usec units */
8762306a36Sopenharmony_ci#define CSR_INT                 (CSR_BASE+0x008)	/* host interrupt status/ack */
8862306a36Sopenharmony_ci#define CSR_INT_MASK            (CSR_BASE+0x00c)	/* host interrupt enable */
8962306a36Sopenharmony_ci#define CSR_FH_INT_STATUS       (CSR_BASE+0x010)	/* busmaster int status/ack */
9062306a36Sopenharmony_ci#define CSR_GPIO_IN             (CSR_BASE+0x018)	/* read external chip pins */
9162306a36Sopenharmony_ci#define CSR_RESET               (CSR_BASE+0x020)	/* busmaster enable, NMI, etc */
9262306a36Sopenharmony_ci#define CSR_GP_CNTRL            (CSR_BASE+0x024)
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci/* 2nd byte of CSR_INT_COALESCING, not accessible via _il_wr()! */
9562306a36Sopenharmony_ci#define CSR_INT_PERIODIC_REG	(CSR_BASE+0x005)
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci/*
9862306a36Sopenharmony_ci * Hardware revision info
9962306a36Sopenharmony_ci * Bit fields:
10062306a36Sopenharmony_ci * 31-8:  Reserved
10162306a36Sopenharmony_ci *  7-4:  Type of device:  see CSR_HW_REV_TYPE_xxx definitions
10262306a36Sopenharmony_ci *  3-2:  Revision step:  0 = A, 1 = B, 2 = C, 3 = D
10362306a36Sopenharmony_ci *  1-0:  "Dash" (-) value, as in A-1, etc.
10462306a36Sopenharmony_ci *
10562306a36Sopenharmony_ci * NOTE:  Revision step affects calculation of CCK txpower for 4965.
10662306a36Sopenharmony_ci * NOTE:  See also CSR_HW_REV_WA_REG (work-around for bug in 4965).
10762306a36Sopenharmony_ci */
10862306a36Sopenharmony_ci#define CSR_HW_REV              (CSR_BASE+0x028)
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci/*
11162306a36Sopenharmony_ci * EEPROM memory reads
11262306a36Sopenharmony_ci *
11362306a36Sopenharmony_ci * NOTE:  Device must be awake, initialized via apm_ops.init(),
11462306a36Sopenharmony_ci *        in order to read.
11562306a36Sopenharmony_ci */
11662306a36Sopenharmony_ci#define CSR_EEPROM_REG          (CSR_BASE+0x02c)
11762306a36Sopenharmony_ci#define CSR_EEPROM_GP           (CSR_BASE+0x030)
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci#define CSR_GIO_REG		(CSR_BASE+0x03C)
12062306a36Sopenharmony_ci#define CSR_GP_UCODE_REG	(CSR_BASE+0x048)
12162306a36Sopenharmony_ci#define CSR_GP_DRIVER_REG	(CSR_BASE+0x050)
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci/*
12462306a36Sopenharmony_ci * UCODE-DRIVER GP (general purpose) mailbox registers.
12562306a36Sopenharmony_ci * SET/CLR registers set/clear bit(s) if "1" is written.
12662306a36Sopenharmony_ci */
12762306a36Sopenharmony_ci#define CSR_UCODE_DRV_GP1       (CSR_BASE+0x054)
12862306a36Sopenharmony_ci#define CSR_UCODE_DRV_GP1_SET   (CSR_BASE+0x058)
12962306a36Sopenharmony_ci#define CSR_UCODE_DRV_GP1_CLR   (CSR_BASE+0x05c)
13062306a36Sopenharmony_ci#define CSR_UCODE_DRV_GP2       (CSR_BASE+0x060)
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci#define CSR_LED_REG             (CSR_BASE+0x094)
13362306a36Sopenharmony_ci#define CSR_DRAM_INT_TBL_REG	(CSR_BASE+0x0A0)
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ci/* GIO Chicken Bits (PCI Express bus link power management) */
13662306a36Sopenharmony_ci#define CSR_GIO_CHICKEN_BITS    (CSR_BASE+0x100)
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci/* Analog phase-lock-loop configuration  */
13962306a36Sopenharmony_ci#define CSR_ANA_PLL_CFG         (CSR_BASE+0x20c)
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci/*
14262306a36Sopenharmony_ci * CSR Hardware Revision Workaround Register.  Indicates hardware rev;
14362306a36Sopenharmony_ci * "step" determines CCK backoff for txpower calculation.  Used for 4965 only.
14462306a36Sopenharmony_ci * See also CSR_HW_REV register.
14562306a36Sopenharmony_ci * Bit fields:
14662306a36Sopenharmony_ci *  3-2:  0 = A, 1 = B, 2 = C, 3 = D step
14762306a36Sopenharmony_ci *  1-0:  "Dash" (-) value, as in C-1, etc.
14862306a36Sopenharmony_ci */
14962306a36Sopenharmony_ci#define CSR_HW_REV_WA_REG		(CSR_BASE+0x22C)
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci#define CSR_DBG_HPET_MEM_REG		(CSR_BASE+0x240)
15262306a36Sopenharmony_ci#define CSR_DBG_LINK_PWR_MGMT_REG	(CSR_BASE+0x250)
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_ci/* Bits for CSR_HW_IF_CONFIG_REG */
15562306a36Sopenharmony_ci#define CSR49_HW_IF_CONFIG_REG_BIT_4965_R	(0x00000010)
15662306a36Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG_MSK_BOARD_VER	(0x00000C00)
15762306a36Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG_BIT_MAC_SI 	(0x00000100)
15862306a36Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI	(0x00000200)
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_ci#define CSR39_HW_IF_CONFIG_REG_BIT_3945_MB         (0x00000100)
16162306a36Sopenharmony_ci#define CSR39_HW_IF_CONFIG_REG_BIT_3945_MM         (0x00000200)
16262306a36Sopenharmony_ci#define CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC            (0x00000400)
16362306a36Sopenharmony_ci#define CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE         (0x00000800)
16462306a36Sopenharmony_ci#define CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A    (0x00000000)
16562306a36Sopenharmony_ci#define CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B    (0x00001000)
16662306a36Sopenharmony_ci
16762306a36Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A	(0x00080000)
16862306a36Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM	(0x00200000)
16962306a36Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG_BIT_NIC_READY	(0x00400000)	/* PCI_OWN_SEM */
17062306a36Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE (0x02000000)	/* ME_OWN */
17162306a36Sopenharmony_ci#define CSR_HW_IF_CONFIG_REG_PREPARE		  (0x08000000)	/* WAKE_ME */
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci#define CSR_INT_PERIODIC_DIS			(0x00)	/* disable periodic int */
17462306a36Sopenharmony_ci#define CSR_INT_PERIODIC_ENA			(0xFF)	/* 255*32 usec ~ 8 msec */
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_ci/* interrupt flags in INTA, set by uCode or hardware (e.g. dma),
17762306a36Sopenharmony_ci * acknowledged (reset) by host writing "1" to flagged bits. */
17862306a36Sopenharmony_ci#define CSR_INT_BIT_FH_RX        (1 << 31)	/* Rx DMA, cmd responses, FH_INT[17:16] */
17962306a36Sopenharmony_ci#define CSR_INT_BIT_HW_ERR       (1 << 29)	/* DMA hardware error FH_INT[31] */
18062306a36Sopenharmony_ci#define CSR_INT_BIT_RX_PERIODIC	 (1 << 28)	/* Rx periodic */
18162306a36Sopenharmony_ci#define CSR_INT_BIT_FH_TX        (1 << 27)	/* Tx DMA FH_INT[1:0] */
18262306a36Sopenharmony_ci#define CSR_INT_BIT_SCD          (1 << 26)	/* TXQ pointer advanced */
18362306a36Sopenharmony_ci#define CSR_INT_BIT_SW_ERR       (1 << 25)	/* uCode error */
18462306a36Sopenharmony_ci#define CSR_INT_BIT_RF_KILL      (1 << 7)	/* HW RFKILL switch GP_CNTRL[27] toggled */
18562306a36Sopenharmony_ci#define CSR_INT_BIT_CT_KILL      (1 << 6)	/* Critical temp (chip too hot) rfkill */
18662306a36Sopenharmony_ci#define CSR_INT_BIT_SW_RX        (1 << 3)	/* Rx, command responses, 3945 */
18762306a36Sopenharmony_ci#define CSR_INT_BIT_WAKEUP       (1 << 1)	/* NIC controller waking up (pwr mgmt) */
18862306a36Sopenharmony_ci#define CSR_INT_BIT_ALIVE        (1 << 0)	/* uCode interrupts once it initializes */
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_ci#define CSR_INI_SET_MASK	(CSR_INT_BIT_FH_RX   | \
19162306a36Sopenharmony_ci				 CSR_INT_BIT_HW_ERR  | \
19262306a36Sopenharmony_ci				 CSR_INT_BIT_FH_TX   | \
19362306a36Sopenharmony_ci				 CSR_INT_BIT_SW_ERR  | \
19462306a36Sopenharmony_ci				 CSR_INT_BIT_RF_KILL | \
19562306a36Sopenharmony_ci				 CSR_INT_BIT_SW_RX   | \
19662306a36Sopenharmony_ci				 CSR_INT_BIT_WAKEUP  | \
19762306a36Sopenharmony_ci				 CSR_INT_BIT_ALIVE)
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_ci/* interrupt flags in FH (flow handler) (PCI busmaster DMA) */
20062306a36Sopenharmony_ci#define CSR_FH_INT_BIT_ERR       (1 << 31)	/* Error */
20162306a36Sopenharmony_ci#define CSR_FH_INT_BIT_HI_PRIOR  (1 << 30)	/* High priority Rx, bypass coalescing */
20262306a36Sopenharmony_ci#define CSR39_FH_INT_BIT_RX_CHNL2  (1 << 18)	/* Rx channel 2 (3945 only) */
20362306a36Sopenharmony_ci#define CSR_FH_INT_BIT_RX_CHNL1  (1 << 17)	/* Rx channel 1 */
20462306a36Sopenharmony_ci#define CSR_FH_INT_BIT_RX_CHNL0  (1 << 16)	/* Rx channel 0 */
20562306a36Sopenharmony_ci#define CSR39_FH_INT_BIT_TX_CHNL6  (1 << 6)	/* Tx channel 6 (3945 only) */
20662306a36Sopenharmony_ci#define CSR_FH_INT_BIT_TX_CHNL1  (1 << 1)	/* Tx channel 1 */
20762306a36Sopenharmony_ci#define CSR_FH_INT_BIT_TX_CHNL0  (1 << 0)	/* Tx channel 0 */
20862306a36Sopenharmony_ci
20962306a36Sopenharmony_ci#define CSR39_FH_INT_RX_MASK	(CSR_FH_INT_BIT_HI_PRIOR | \
21062306a36Sopenharmony_ci				 CSR39_FH_INT_BIT_RX_CHNL2 | \
21162306a36Sopenharmony_ci				 CSR_FH_INT_BIT_RX_CHNL1 | \
21262306a36Sopenharmony_ci				 CSR_FH_INT_BIT_RX_CHNL0)
21362306a36Sopenharmony_ci
21462306a36Sopenharmony_ci#define CSR39_FH_INT_TX_MASK	(CSR39_FH_INT_BIT_TX_CHNL6 | \
21562306a36Sopenharmony_ci				 CSR_FH_INT_BIT_TX_CHNL1 | \
21662306a36Sopenharmony_ci				 CSR_FH_INT_BIT_TX_CHNL0)
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_ci#define CSR49_FH_INT_RX_MASK	(CSR_FH_INT_BIT_HI_PRIOR | \
21962306a36Sopenharmony_ci				 CSR_FH_INT_BIT_RX_CHNL1 | \
22062306a36Sopenharmony_ci				 CSR_FH_INT_BIT_RX_CHNL0)
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ci#define CSR49_FH_INT_TX_MASK	(CSR_FH_INT_BIT_TX_CHNL1 | \
22362306a36Sopenharmony_ci				 CSR_FH_INT_BIT_TX_CHNL0)
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_ci/* GPIO */
22662306a36Sopenharmony_ci#define CSR_GPIO_IN_BIT_AUX_POWER                   (0x00000200)
22762306a36Sopenharmony_ci#define CSR_GPIO_IN_VAL_VAUX_PWR_SRC                (0x00000000)
22862306a36Sopenharmony_ci#define CSR_GPIO_IN_VAL_VMAIN_PWR_SRC               (0x00000200)
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_ci/* RESET */
23162306a36Sopenharmony_ci#define CSR_RESET_REG_FLAG_NEVO_RESET                (0x00000001)
23262306a36Sopenharmony_ci#define CSR_RESET_REG_FLAG_FORCE_NMI                 (0x00000002)
23362306a36Sopenharmony_ci#define CSR_RESET_REG_FLAG_SW_RESET                  (0x00000080)
23462306a36Sopenharmony_ci#define CSR_RESET_REG_FLAG_MASTER_DISABLED           (0x00000100)
23562306a36Sopenharmony_ci#define CSR_RESET_REG_FLAG_STOP_MASTER               (0x00000200)
23662306a36Sopenharmony_ci#define CSR_RESET_LINK_PWR_MGMT_DISABLED             (0x80000000)
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_ci/*
23962306a36Sopenharmony_ci * GP (general purpose) CONTROL REGISTER
24062306a36Sopenharmony_ci * Bit fields:
24162306a36Sopenharmony_ci *    27:  HW_RF_KILL_SW
24262306a36Sopenharmony_ci *         Indicates state of (platform's) hardware RF-Kill switch
24362306a36Sopenharmony_ci * 26-24:  POWER_SAVE_TYPE
24462306a36Sopenharmony_ci *         Indicates current power-saving mode:
24562306a36Sopenharmony_ci *         000 -- No power saving
24662306a36Sopenharmony_ci *         001 -- MAC power-down
24762306a36Sopenharmony_ci *         010 -- PHY (radio) power-down
24862306a36Sopenharmony_ci *         011 -- Error
24962306a36Sopenharmony_ci *   9-6:  SYS_CONFIG
25062306a36Sopenharmony_ci *         Indicates current system configuration, reflecting pins on chip
25162306a36Sopenharmony_ci *         as forced high/low by device circuit board.
25262306a36Sopenharmony_ci *     4:  GOING_TO_SLEEP
25362306a36Sopenharmony_ci *         Indicates MAC is entering a power-saving sleep power-down.
25462306a36Sopenharmony_ci *         Not a good time to access device-internal resources.
25562306a36Sopenharmony_ci *     3:  MAC_ACCESS_REQ
25662306a36Sopenharmony_ci *         Host sets this to request and maintain MAC wakeup, to allow host
25762306a36Sopenharmony_ci *         access to device-internal resources.  Host must wait for
25862306a36Sopenharmony_ci *         MAC_CLOCK_READY (and !GOING_TO_SLEEP) before accessing non-CSR
25962306a36Sopenharmony_ci *         device registers.
26062306a36Sopenharmony_ci *     2:  INIT_DONE
26162306a36Sopenharmony_ci *         Host sets this to put device into fully operational D0 power mode.
26262306a36Sopenharmony_ci *         Host resets this after SW_RESET to put device into low power mode.
26362306a36Sopenharmony_ci *     0:  MAC_CLOCK_READY
26462306a36Sopenharmony_ci *         Indicates MAC (ucode processor, etc.) is powered up and can run.
26562306a36Sopenharmony_ci *         Internal resources are accessible.
26662306a36Sopenharmony_ci *         NOTE:  This does not indicate that the processor is actually running.
26762306a36Sopenharmony_ci *         NOTE:  This does not indicate that 4965 or 3945 has completed
26862306a36Sopenharmony_ci *                init or post-power-down restore of internal SRAM memory.
26962306a36Sopenharmony_ci *                Use CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP as indication that
27062306a36Sopenharmony_ci *                SRAM is restored and uCode is in normal operation mode.
27162306a36Sopenharmony_ci *                Later devices (5xxx/6xxx/1xxx) use non-volatile SRAM, and
27262306a36Sopenharmony_ci *                do not need to save/restore it.
27362306a36Sopenharmony_ci *         NOTE:  After device reset, this bit remains "0" until host sets
27462306a36Sopenharmony_ci *                INIT_DONE
27562306a36Sopenharmony_ci */
27662306a36Sopenharmony_ci#define CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY        (0x00000001)
27762306a36Sopenharmony_ci#define CSR_GP_CNTRL_REG_FLAG_INIT_DONE              (0x00000004)
27862306a36Sopenharmony_ci#define CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ         (0x00000008)
27962306a36Sopenharmony_ci#define CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP         (0x00000010)
28062306a36Sopenharmony_ci
28162306a36Sopenharmony_ci#define CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN           (0x00000001)
28262306a36Sopenharmony_ci
28362306a36Sopenharmony_ci#define CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE         (0x07000000)
28462306a36Sopenharmony_ci#define CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE         (0x04000000)
28562306a36Sopenharmony_ci#define CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW          (0x08000000)
28662306a36Sopenharmony_ci
28762306a36Sopenharmony_ci/* EEPROM REG */
28862306a36Sopenharmony_ci#define CSR_EEPROM_REG_READ_VALID_MSK	(0x00000001)
28962306a36Sopenharmony_ci#define CSR_EEPROM_REG_BIT_CMD		(0x00000002)
29062306a36Sopenharmony_ci#define CSR_EEPROM_REG_MSK_ADDR		(0x0000FFFC)
29162306a36Sopenharmony_ci#define CSR_EEPROM_REG_MSK_DATA		(0xFFFF0000)
29262306a36Sopenharmony_ci
29362306a36Sopenharmony_ci/* EEPROM GP */
29462306a36Sopenharmony_ci#define CSR_EEPROM_GP_VALID_MSK		(0x00000007)	/* signature */
29562306a36Sopenharmony_ci#define CSR_EEPROM_GP_IF_OWNER_MSK	(0x00000180)
29662306a36Sopenharmony_ci#define CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K		(0x00000002)
29762306a36Sopenharmony_ci#define CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K		(0x00000004)
29862306a36Sopenharmony_ci
29962306a36Sopenharmony_ci/* GP REG */
30062306a36Sopenharmony_ci#define CSR_GP_REG_POWER_SAVE_STATUS_MSK            (0x03000000)	/* bit 24/25 */
30162306a36Sopenharmony_ci#define CSR_GP_REG_NO_POWER_SAVE            (0x00000000)
30262306a36Sopenharmony_ci#define CSR_GP_REG_MAC_POWER_SAVE           (0x01000000)
30362306a36Sopenharmony_ci#define CSR_GP_REG_PHY_POWER_SAVE           (0x02000000)
30462306a36Sopenharmony_ci#define CSR_GP_REG_POWER_SAVE_ERROR         (0x03000000)
30562306a36Sopenharmony_ci
30662306a36Sopenharmony_ci/* CSR GIO */
30762306a36Sopenharmony_ci#define CSR_GIO_REG_VAL_L0S_ENABLED	(0x00000002)
30862306a36Sopenharmony_ci
30962306a36Sopenharmony_ci/*
31062306a36Sopenharmony_ci * UCODE-DRIVER GP (general purpose) mailbox register 1
31162306a36Sopenharmony_ci * Host driver and uCode write and/or read this register to communicate with
31262306a36Sopenharmony_ci * each other.
31362306a36Sopenharmony_ci * Bit fields:
31462306a36Sopenharmony_ci *     4:  UCODE_DISABLE
31562306a36Sopenharmony_ci *         Host sets this to request permanent halt of uCode, same as
31662306a36Sopenharmony_ci *         sending CARD_STATE command with "halt" bit set.
31762306a36Sopenharmony_ci *     3:  CT_KILL_EXIT
31862306a36Sopenharmony_ci *         Host sets this to request exit from CT_KILL state, i.e. host thinks
31962306a36Sopenharmony_ci *         device temperature is low enough to continue normal operation.
32062306a36Sopenharmony_ci *     2:  CMD_BLOCKED
32162306a36Sopenharmony_ci *         Host sets this during RF KILL power-down sequence (HW, SW, CT KILL)
32262306a36Sopenharmony_ci *         to release uCode to clear all Tx and command queues, enter
32362306a36Sopenharmony_ci *         unassociated mode, and power down.
32462306a36Sopenharmony_ci *         NOTE:  Some devices also use HBUS_TARG_MBX_C register for this bit.
32562306a36Sopenharmony_ci *     1:  SW_BIT_RFKILL
32662306a36Sopenharmony_ci *         Host sets this when issuing CARD_STATE command to request
32762306a36Sopenharmony_ci *         device sleep.
32862306a36Sopenharmony_ci *     0:  MAC_SLEEP
32962306a36Sopenharmony_ci *         uCode sets this when preparing a power-saving power-down.
33062306a36Sopenharmony_ci *         uCode resets this when power-up is complete and SRAM is sane.
33162306a36Sopenharmony_ci *         NOTE:  3945/4965 saves internal SRAM data to host when powering down,
33262306a36Sopenharmony_ci *                and must restore this data after powering back up.
33362306a36Sopenharmony_ci *                MAC_SLEEP is the best indication that restore is complete.
33462306a36Sopenharmony_ci *                Later devices (5xxx/6xxx/1xxx) use non-volatile SRAM, and
33562306a36Sopenharmony_ci *                do not need to save/restore it.
33662306a36Sopenharmony_ci */
33762306a36Sopenharmony_ci#define CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP             (0x00000001)
33862306a36Sopenharmony_ci#define CSR_UCODE_SW_BIT_RFKILL                     (0x00000002)
33962306a36Sopenharmony_ci#define CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED           (0x00000004)
34062306a36Sopenharmony_ci#define CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT      (0x00000008)
34162306a36Sopenharmony_ci
34262306a36Sopenharmony_ci/* GIO Chicken Bits (PCI Express bus link power management) */
34362306a36Sopenharmony_ci#define CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX  (0x00800000)
34462306a36Sopenharmony_ci#define CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER  (0x20000000)
34562306a36Sopenharmony_ci
34662306a36Sopenharmony_ci/* LED */
34762306a36Sopenharmony_ci#define CSR_LED_BSM_CTRL_MSK (0xFFFFFFDF)
34862306a36Sopenharmony_ci#define CSR_LED_REG_TRUN_ON (0x78)
34962306a36Sopenharmony_ci#define CSR_LED_REG_TRUN_OFF (0x38)
35062306a36Sopenharmony_ci
35162306a36Sopenharmony_ci/* ANA_PLL */
35262306a36Sopenharmony_ci#define CSR39_ANA_PLL_CFG_VAL        (0x01000000)
35362306a36Sopenharmony_ci
35462306a36Sopenharmony_ci/* HPET MEM debug */
35562306a36Sopenharmony_ci#define CSR_DBG_HPET_MEM_REG_VAL	(0xFFFF0000)
35662306a36Sopenharmony_ci
35762306a36Sopenharmony_ci/* DRAM INT TBL */
35862306a36Sopenharmony_ci#define CSR_DRAM_INT_TBL_ENABLE		(1 << 31)
35962306a36Sopenharmony_ci#define CSR_DRAM_INIT_TBL_WRAP_CHECK	(1 << 27)
36062306a36Sopenharmony_ci
36162306a36Sopenharmony_ci/*
36262306a36Sopenharmony_ci * HBUS (Host-side Bus)
36362306a36Sopenharmony_ci *
36462306a36Sopenharmony_ci * HBUS registers are mapped directly into PCI bus space, but are used
36562306a36Sopenharmony_ci * to indirectly access device's internal memory or registers that
36662306a36Sopenharmony_ci * may be powered-down.
36762306a36Sopenharmony_ci *
36862306a36Sopenharmony_ci * Use il_wr()/il_rd() family
36962306a36Sopenharmony_ci * for these registers;
37062306a36Sopenharmony_ci * host must "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ
37162306a36Sopenharmony_ci * to make sure the MAC (uCode processor, etc.) is powered up for accessing
37262306a36Sopenharmony_ci * internal resources.
37362306a36Sopenharmony_ci *
37462306a36Sopenharmony_ci * Do not use _il_wr()/_il_rd() family to access these registers;
37562306a36Sopenharmony_ci * these provide only simple PCI bus access, without waking up the MAC.
37662306a36Sopenharmony_ci */
37762306a36Sopenharmony_ci#define HBUS_BASE	(0x400)
37862306a36Sopenharmony_ci
37962306a36Sopenharmony_ci/*
38062306a36Sopenharmony_ci * Registers for accessing device's internal SRAM memory (e.g. SCD SRAM
38162306a36Sopenharmony_ci * structures, error log, event log, verifying uCode load).
38262306a36Sopenharmony_ci * First write to address register, then read from or write to data register
38362306a36Sopenharmony_ci * to complete the job.  Once the address register is set up, accesses to
38462306a36Sopenharmony_ci * data registers auto-increment the address by one dword.
38562306a36Sopenharmony_ci * Bit usage for address registers (read or write):
38662306a36Sopenharmony_ci *  0-31:  memory address within device
38762306a36Sopenharmony_ci */
38862306a36Sopenharmony_ci#define HBUS_TARG_MEM_RADDR     (HBUS_BASE+0x00c)
38962306a36Sopenharmony_ci#define HBUS_TARG_MEM_WADDR     (HBUS_BASE+0x010)
39062306a36Sopenharmony_ci#define HBUS_TARG_MEM_WDAT      (HBUS_BASE+0x018)
39162306a36Sopenharmony_ci#define HBUS_TARG_MEM_RDAT      (HBUS_BASE+0x01c)
39262306a36Sopenharmony_ci
39362306a36Sopenharmony_ci/* Mailbox C, used as workaround alternative to CSR_UCODE_DRV_GP1 mailbox */
39462306a36Sopenharmony_ci#define HBUS_TARG_MBX_C         (HBUS_BASE+0x030)
39562306a36Sopenharmony_ci#define HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED         (0x00000004)
39662306a36Sopenharmony_ci
39762306a36Sopenharmony_ci/*
39862306a36Sopenharmony_ci * Registers for accessing device's internal peripheral registers
39962306a36Sopenharmony_ci * (e.g. SCD, BSM, etc.).  First write to address register,
40062306a36Sopenharmony_ci * then read from or write to data register to complete the job.
40162306a36Sopenharmony_ci * Bit usage for address registers (read or write):
40262306a36Sopenharmony_ci *  0-15:  register address (offset) within device
40362306a36Sopenharmony_ci * 24-25:  (# bytes - 1) to read or write (e.g. 3 for dword)
40462306a36Sopenharmony_ci */
40562306a36Sopenharmony_ci#define HBUS_TARG_PRPH_WADDR    (HBUS_BASE+0x044)
40662306a36Sopenharmony_ci#define HBUS_TARG_PRPH_RADDR    (HBUS_BASE+0x048)
40762306a36Sopenharmony_ci#define HBUS_TARG_PRPH_WDAT     (HBUS_BASE+0x04c)
40862306a36Sopenharmony_ci#define HBUS_TARG_PRPH_RDAT     (HBUS_BASE+0x050)
40962306a36Sopenharmony_ci
41062306a36Sopenharmony_ci/*
41162306a36Sopenharmony_ci * Per-Tx-queue write pointer (idx, really!)
41262306a36Sopenharmony_ci * Indicates idx to next TFD that driver will fill (1 past latest filled).
41362306a36Sopenharmony_ci * Bit usage:
41462306a36Sopenharmony_ci *  0-7:  queue write idx
41562306a36Sopenharmony_ci * 11-8:  queue selector
41662306a36Sopenharmony_ci */
41762306a36Sopenharmony_ci#define HBUS_TARG_WRPTR         (HBUS_BASE+0x060)
41862306a36Sopenharmony_ci
41962306a36Sopenharmony_ci#endif /* !__il_csr_h__ */
420