Path: blob/main/sys/contrib/dev/broadcom/brcm80211/brcmsmac/aiutils.h
178665 views
/*1* Copyright (c) 2011 Broadcom Corporation2*3* Permission to use, copy, modify, and/or distribute this software for any4* purpose with or without fee is hereby granted, provided that the above5* copyright notice and this permission notice appear in all copies.6*7* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES8* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF9* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY10* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES11* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION12* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN13* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.14*/1516#ifndef _BRCM_AIUTILS_H_17#define _BRCM_AIUTILS_H_1819#include <linux/bcma/bcma.h>2021#include "types.h"2223/*24* SOC Interconnect Address Map.25* All regions may not exist on all chips.26*/27/* each core gets 4Kbytes for registers */28#define SI_CORE_SIZE 0x100029/*30* Max cores (this is arbitrary, for software31* convenience and could be changed if we32* make any larger chips33*/34#define SI_MAXCORES 163536/* Client Mode sb2pcitranslation2 size in bytes */37#define SI_PCI_DMA_SZ 0x400000003839/* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */40#define SI_PCIE_DMA_H32 0x800000004142/* chipcommon being the first core: */43#define SI_CC_IDX 04445/* SOC Interconnect types (aka chip types) */46#define SOCI_AI 14748/* A register that is common to all cores to49* communicate w/PMU regarding clock control.50*/51#define SI_CLK_CTL_ST 0x1e0 /* clock control and status */5253/* clk_ctl_st register */54#define CCS_FORCEALP 0x00000001 /* force ALP request */55#define CCS_FORCEHT 0x00000002 /* force HT request */56#define CCS_FORCEILP 0x00000004 /* force ILP request */57#define CCS_ALPAREQ 0x00000008 /* ALP Avail Request */58#define CCS_HTAREQ 0x00000010 /* HT Avail Request */59#define CCS_FORCEHWREQOFF 0x00000020 /* Force HW Clock Request Off */60#define CCS_ERSRC_REQ_MASK 0x00000700 /* external resource requests */61#define CCS_ERSRC_REQ_SHIFT 862#define CCS_ALPAVAIL 0x00010000 /* ALP is available */63#define CCS_HTAVAIL 0x00020000 /* HT is available */64#define CCS_BP_ON_APL 0x00040000 /* RO: running on ALP clock */65#define CCS_BP_ON_HT 0x00080000 /* RO: running on HT clock */66#define CCS_ERSRC_STS_MASK 0x07000000 /* external resource status */67#define CCS_ERSRC_STS_SHIFT 246869/* HT avail in chipc and pcmcia on 4328a0 */70#define CCS0_HTAVAIL 0x0001000071/* ALP avail in chipc and pcmcia on 4328a0 */72#define CCS0_ALPAVAIL 0x000200007374/* Not really related to SOC Interconnect, but a couple of software75* conventions for the use the flash space:76*/7778/* Minimum amount of flash we support */79#define FLASH_MIN 0x00020000 /* Minimum flash size */8081#define CC_SROM_OTP 0x800 /* SROM/OTP address space */8283/* gpiotimerval */84#define GPIO_ONTIME_SHIFT 168586/* Fields in clkdiv */87#define CLKD_OTP 0x000f000088#define CLKD_OTP_SHIFT 168990/* dynamic clock control defines */91#define LPOMINFREQ 25000 /* low power oscillator min */92#define LPOMAXFREQ 43000 /* low power oscillator max */93#define XTALMINFREQ 19800000 /* 20 MHz - 1% */94#define XTALMAXFREQ 20200000 /* 20 MHz + 1% */95#define PCIMINFREQ 25000000 /* 25 MHz */96#define PCIMAXFREQ 34000000 /* 33 MHz + fudge */9798#define ILP_DIV_5MHZ 0 /* ILP = 5 MHz */99#define ILP_DIV_1MHZ 4 /* ILP = 1 MHz */100101/* clkctl xtal what flags */102#define XTAL 0x1 /* primary crystal oscillator (2050) */103#define PLL 0x2 /* main chip pll */104105/* GPIO usage priorities */106#define GPIO_DRV_PRIORITY 0 /* Driver */107#define GPIO_APP_PRIORITY 1 /* Application */108#define GPIO_HI_PRIORITY 2 /* Highest priority. Ignore GPIO109* reservation110*/111112/* GPIO pull up/down */113#define GPIO_PULLUP 0114#define GPIO_PULLDN 1115116/* GPIO event regtype */117#define GPIO_REGEVT 0 /* GPIO register event */118#define GPIO_REGEVT_INTMSK 1 /* GPIO register event int mask */119#define GPIO_REGEVT_INTPOL 2 /* GPIO register event int polarity */120121/* device path */122#define SI_DEVPATH_BUFSZ 16 /* min buffer size in bytes */123124/* SI routine enumeration: to be used by update function with multiple hooks */125#define SI_DOATTACH 1126#define SI_PCIDOWN 2127#define SI_PCIUP 3128129/*130* Data structure to export all chip specific common variables131* public (read-only) portion of aiutils handle returned by si_attach()132*/133struct si_pub {134int ccrev; /* chip common core rev */135u32 cccaps; /* chip common capabilities */136int pmurev; /* pmu core rev */137u32 pmucaps; /* pmu capabilities */138uint boardtype; /* board type */139uint boardvendor; /* board vendor */140uint chip; /* chip number */141uint chiprev; /* chip revision */142uint chippkg; /* chip package option */143};144145struct pci_dev;146147/* misc si info needed by some of the routines */148struct si_info {149struct si_pub pub; /* back plane public state (must be first) */150struct bcma_bus *icbus; /* handle to soc interconnect bus */151struct pci_dev *pcibus; /* handle to pci bus */152153u32 chipst; /* chip status */154};155156/*157* Many of the routines below take an 'sih' handle as their first arg.158* Allocate this by calling si_attach(). Free it by calling si_detach().159* At any one time, the sih is logically focused on one particular si core160* (the "current core").161* Use si_setcore() or si_setcoreidx() to change the association to another core162*/163164165/* AMBA Interconnect exported externs */166u32 ai_core_cflags(struct bcma_device *core, u32 mask, u32 val);167168/* === exported functions === */169struct si_pub *ai_attach(struct bcma_bus *pbus);170void ai_detach(struct si_pub *sih);171uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val);172void ai_clkctl_init(struct si_pub *sih);173u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih);174bool ai_clkctl_cc(struct si_pub *sih, enum bcma_clkmode mode);175bool ai_deviceremoved(struct si_pub *sih);176177/* Enable Ex-PA for 4313 */178void ai_epa_4313war(struct si_pub *sih);179180static inline u32 ai_get_cccaps(struct si_pub *sih)181{182return sih->cccaps;183}184185static inline int ai_get_pmurev(struct si_pub *sih)186{187return sih->pmurev;188}189190static inline u32 ai_get_pmucaps(struct si_pub *sih)191{192return sih->pmucaps;193}194195static inline uint ai_get_boardtype(struct si_pub *sih)196{197return sih->boardtype;198}199200static inline uint ai_get_boardvendor(struct si_pub *sih)201{202return sih->boardvendor;203}204205static inline uint ai_get_chip_id(struct si_pub *sih)206{207return sih->chip;208}209210static inline uint ai_get_chiprev(struct si_pub *sih)211{212return sih->chiprev;213}214215static inline uint ai_get_chippkg(struct si_pub *sih)216{217return sih->chippkg;218}219220#endif /* _BRCM_AIUTILS_H_ */221222223