/*-1* Copyright (c) 2015 Landon Fuller <[email protected]>2* Copyright (c) 2010 Broadcom Corporation3*4* Portions of this file were derived from the bcmdevs.h header contributed by5* Broadcom to Android's bcmdhd driver module, and the pcicfg.h header6* distributed with Broadcom's initial brcm80211 Linux driver release.7*8* Permission to use, copy, modify, and/or distribute this software for any9* purpose with or without fee is hereby granted, provided that the above10* copyright notice and this permission notice appear in all copies.11*12* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES13* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF14* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY15* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES16* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION17* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN18* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.19*20*/2122#ifndef _BHND_BHNDB_PCIREG_H_23#define _BHND_BHNDB_PCIREG_H_2425/*26* Common PCI/PCIE Bridge Configuration Registers.27*28* = MAJOR CORE REVISIONS =29*30* There have been four revisions to the BAR0 memory mappings used31* in BHND PCI/PCIE bridge cores:32*33* == PCI_V0 ==34* Applies to:35* - PCI (cid=0x804, revision <= 12)36* BAR0 size: 8KB37* Address Map:38* [offset+ size] type description39* [0x0000+0x1000] dynamic mapped backplane address space (window 0).40* [0x1000+0x0800] fixed SPROM shadow41* [0x1800+0x0E00] fixed pci core device registers42* [0x1E00+0x0200] fixed pci core siba config registers43*44* == PCI_V1 ==45* Applies to:46* - PCI (cid=0x804, revision >= 13)47* - PCIE (cid=0x820) with ChipCommon (revision <= 31)48* BAR0 size: 16KB49* Address Map:50* [offset+ size] type description51* [0x0000+0x1000] dynamic mapped backplane address space (window 0).52* [0x1000+0x1000] fixed SPROM shadow53* [0x2000+0x1000] fixed pci/pcie core registers54* [0x3000+0x1000] fixed chipcommon core registers55*56* == PCI_V2 ==57* Applies to:58* - PCIE (cid=0x820) with ChipCommon (revision >= 32)59* BAR0 size: 16KB60* Address Map:61* [offset+ size] type description62* [0x0000+0x1000] dynamic mapped backplane address space (window 0).63* [0x1000+0x1000] dynamic mapped backplane address space (window 1).64* [0x2000+0x1000] fixed pci/pcie core registers65* [0x3000+0x1000] fixed chipcommon core registers66*67* == PCI_V3 ==68* Applies to:69* - PCIE Gen 2 (cid=0x83c)70* BAR0 size: 32KB71* Address Map:72* [offset+ size] type description73* [0x0000+0x1000] dynamic mapped backplane address space (window 0).74* [0x1000+0x1000] dynamic mapped backplane address space (window 1).75* [0x2000+0x1000] fixed pci/pcie core registers76* [0x3000+0x1000] fixed chipcommon core registers77* [???]78* BAR1 size: varies79* Address Map:80* [offset+ size] type description81* [0x0000+0x????] fixed ARM tightly-coupled memory (TCM).82* While fullmac chipsets provided a fixed83* 4KB mapping, newer devices will vary.84*85* = MINOR CORE REVISIONS =86*87* == PCI Cores Revision >= 3 ==88* - Mapped GPIO CSRs into the PCI config space. Refer to89* BHND_PCI_GPIO_*.90*91* == PCI/PCIE Cores Revision >= 14 ==92* - Mapped the clock CSR into the PCI config space. Refer to93* BHND_PCI_CLK_CTL_ST94*/9596/* Common PCI/PCIE Config Registers */97#define BHNDB_PCI_SPROM_CONTROL 0x88 /* sprom property control */98#define BHNDB_PCI_BAR1_CONTROL 0x8c /* BAR1 region prefetch/burst control */99#define BHNDB_PCI_INT_STATUS 0x90 /* PCI and other cores interrupts */100#define BHNDB_PCI_INT_MASK 0x94 /* mask of PCI and other cores interrupts */101#define BHNDB_PCI_TO_SB_MB 0x98 /* signal backplane interrupts */102#define BHNDB_PCI_BACKPLANE_ADDR 0xa0 /* address an arbitrary location on the system backplane */103#define BHNDB_PCI_BACKPLANE_DATA 0xa4 /* data at the location specified by above address */104105/* PCI (non-PCIe) GPIO/Clock Config Registers */106#define BHNDB_PCI_CLK_CTL 0xa8 /* clock control/status (pci >=rev14) */107#define BHNDB_PCI_GPIO_IN 0xb0 /* gpio input (pci >=rev3) */108#define BHNDB_PCI_GPIO_OUT 0xb4 /* gpio output (pci >=rev3) */109#define BHNDB_PCI_GPIO_OUTEN 0xb8 /* gpio output enable (pci >=rev3) */110111/* Hardware revisions used to determine PCI revision */112#define BHNDB_PCI_V0_MAX_PCI_HWREV 12113#define BHNDB_PCI_V1_MIN_PCI_HWREV 13114#define BHNDB_PCI_V1_MAX_CHIPC_HWREV 31115#define BHNDB_PCI_V2_MIN_CHIPC_HWREV 32116117/**118* Number of times to retry writing to a PCI window address register.119*120* On siba(4) devices, it's possible that writing a PCI window register may121* not succeed; it's necessary to immediately read the configuration register122* and retry if not set to the desired value.123*/124#define BHNDB_PCI_BARCTRL_WRITE_RETRY 50125126/* PCI_V0 */127#define BHNDB_PCI_V0_BAR0_WIN0_CONTROL 0x80 /* backplane address space accessed by BAR0/WIN0 */128#define BHNDB_PCI_V0_BAR1_WIN0_CONTROL 0x84 /* backplane address space accessed by BAR1/WIN0. */129130#define BHNDB_PCI_V0_BAR0_SIZE 0x2000 /* 8KB BAR0 */131#define BHNDB_PCI_V0_BAR0_WIN0_OFFSET 0x0 /* bar0 + 0x0 accesses configurable 4K region of backplane address space */132#define BHNDB_PCI_V0_BAR0_WIN0_SIZE 0x1000133#define BHNDB_PCI_V0_BAR0_SPROM_OFFSET 0x1000 /* bar0 + 4K accesses sprom shadow (in pci core) */134#define BHNDB_PCI_V0_BAR0_SPROM_SIZE 0x0800135#define BHNDB_PCI_V0_BAR0_PCIREG_OFFSET 0x1800 /* bar0 + 6K accesses pci core registers (not including SSB CFG registers) */136#define BHNDB_PCI_V0_BAR0_PCIREG_SIZE 0x0E00137#define BHNDB_PCI_V0_BAR0_PCISB_OFFSET 0x1E00 /* bar0 + 7.5K accesses pci core's SSB CFG register blocks */138#define BHNDB_PCI_V0_BAR0_PCISB_SIZE 0x0200139#define BHNDB_PCI_V0_BAR0_PCISB_COREOFF 0xE00 /* mapped offset relative to the core base address */140141/* PCI_V1 */142#define BHNDB_PCI_V1_BAR0_WIN0_CONTROL 0x80 /* backplane address space accessed by BAR0/WIN0 */143#define BHNDB_PCI_V1_BAR1_WIN0_CONTROL 0x84 /* backplane address space accessed by BAR1/WIN0. */144145#define BHNDB_PCI_V1_BAR0_SIZE 0x4000 /* 16KB BAR0 */146#define BHNDB_PCI_V1_BAR0_WIN0_OFFSET 0x0 /* bar0 + 0x0 accesses configurable 4K region of backplane address space */147#define BHNDB_PCI_V1_BAR0_WIN0_SIZE 0x1000148#define BHNDB_PCI_V1_BAR0_SPROM_OFFSET 0x1000 /* bar0 + 4K accesses sprom shadow (in pci core) */149#define BHNDB_PCI_V1_BAR0_SPROM_SIZE 0x1000150#define BHNDB_PCI_V1_BAR0_PCIREG_OFFSET 0x2000 /* bar0 + 8K accesses pci/pcie core registers */151#define BHNDB_PCI_V1_BAR0_PCIREG_SIZE 0x1000152#define BHNDB_PCI_V1_BAR0_CCREGS_OFFSET 0x3000 /* bar0 + 12K accesses chipc core registers */153#define BHNDB_PCI_V1_BAR0_CCREGS_SIZE 0x1000154155/* PCI_V2 */156#define BHNDB_PCI_V2_BAR0_WIN0_CONTROL 0x80 /* backplane address space accessed by BAR0/WIN0 */157#define BHNDB_PCI_V2_BAR1_WIN0_CONTROL 0x84 /* backplane address space accessed by BAR1/WIN0. */158#define BHNDB_PCI_V2_BAR0_WIN1_CONTROL 0xAC /* backplane address space accessed by BAR0/WIN1 */159160#define BHNDB_PCI_V2_BAR0_SIZE 0x4000 /* 16KB BAR0 */161#define BHNDB_PCI_V2_BAR0_WIN0_OFFSET 0x0 /* bar0 + 0x0 accesses configurable 4K region of backplane address space */162#define BHNDB_PCI_V2_BAR0_WIN0_SIZE 0x1000163#define BHNDB_PCI_V2_BAR0_WIN1_OFFSET 0x1000 /* bar0 + 4K accesses second 4K window */164#define BHNDB_PCI_V2_BAR0_WIN1_SIZE 0x1000165#define BHNDB_PCI_V2_BAR0_PCIREG_OFFSET 0x2000 /* bar0 + 8K accesses pci/pcie core registers */166#define BHNDB_PCI_V2_BAR0_PCIREG_SIZE 0x1000167#define BHNDB_PCI_V2_BAR0_CCREGS_OFFSET 0x3000 /* bar0 + 12K accesses chipc core registers */168#define BHNDB_PCI_V2_BAR0_CCREGS_SIZE 0x1000169170/* PCI_V3 (PCIe-G2) */171#define BHNDB_PCI_V3_BAR0_WIN0_CONTROL 0x80 /* backplane address space accessed by BAR0/WIN0 */172#define BHNDB_PCI_V3_BAR0_WIN1_CONTROL 0x70 /* backplane address space accessed by BAR0/WIN1 */173174#define BHNDB_PCI_V3_BAR0_SIZE 0x8000 /* 32KB BAR0 */175#define BHNDB_PCI_V3_BAR0_WIN0_OFFSET 0x0 /* bar0 + 0x0 accesses configurable 4K region of backplane address space */176#define BHNDB_PCI_V3_BAR0_WIN0_SIZE 0x1000177#define BHNDB_PCI_V3_BAR0_WIN1_OFFSET 0x1000 /* bar0 + 4K accesses second 4K window */178#define BHNDB_PCI_V3_BAR0_WIN1_SIZE 0x1000179#define BHNDB_PCI_V3_BAR0_PCIREG_OFFSET 0x2000 /* bar0 + 8K accesses pci/pcie core registers */180#define BHNDB_PCI_V3_BAR0_PCIREG_SIZE 0x1000181#define BHNDB_PCI_V3_BAR0_CCREGS_OFFSET 0x3000 /* bar0 + 12K accesses chipc core registers */182#define BHNDB_PCI_V3_BAR0_CCREGS_SIZE 0x1000183184/* BHNDB_PCI_INT_STATUS */185#define BHNDB_PCI_SBIM_STATUS_SERR 0x4 /* backplane SBErr interrupt status */186187/* BHNDB_PCI_INT_MASK */188#define BHNDB_PCI_SBIM_SHIFT 8 /* backplane core interrupt mask bits offset */189#define BHNDB_PCI_SBIM_COREIDX_MAX 15 /**< maximum representible core index (in 16 bit field) */190#define BHNDB_PCI_SBIM_MASK 0xff00 /* backplane core interrupt mask */191#define BHNDB_PCI_SBIM_MASK_SERR 0x4 /* backplane SBErr interrupt mask */192193/* BHNDB_PCI_SPROM_CONTROL */194#define BHNDB_PCI_SPROM_SZ_MASK 0x03 /**< sprom size mask */195#define BHNDB_PCI_SPROM_SZ_1KB 0x00 /**< 1KB sprom size */196#define BHNDB_PCI_SPROM_SZ_4KB 0x01 /**< 4KB sprom size */197#define BHNDB_PCI_SPROM_SZ_16KB 0x02 /**< 16KB sprom size */198#define BHNDB_PCI_SPROM_SZ_RESERVED 0x03 /**< unsupported sprom size */199#define BHNDB_PCI_SPROM_LOCKED 0x08 /**< sprom locked */200#define BHNDB_PCI_SPROM_BLANK 0x04 /**< sprom blank */201#define BHNDB_PCI_SPROM_WRITEEN 0x10 /**< sprom write enable */202#define BHNDB_PCI_SPROM_BOOTROM_WE 0x20 /**< external bootrom write enable */203#define BHNDB_PCI_SPROM_BACKPLANE_EN 0x40 /**< enable indirect backplane access (BHNDB_PCI_BACKPLANE_*) */204#define BHNDB_PCI_SPROM_OTPIN_USE 0x80 /**< device OTP in use */205206/* PCI (non-PCIe) BHNDB_PCI_GPIO_OUTEN */207#define BHNDB_PCI_GPIO_SCS 0x10 /* PCI config space bit 4 for 4306c0 slow clock source */208#define BHNDB_PCI_GPIO_HWRAD_OFF 0x20 /* PCI config space GPIO 13 for hw radio disable */209#define BHNDB_PCI_GPIO_XTAL_ON 0x40 /* PCI config space GPIO 14 for Xtal power-up */210#define BHNDB_PCI_GPIO_PLL_OFF 0x80 /* PCI config space GPIO 15 for PLL power-down */211212#endif /* _BHND_BHNDB_PCIREG_H_ */213214215