/*-1* SPDX-License-Identifier: ISC2*3* Copyright (c) 2015 Landon Fuller <[email protected]>4* Copyright (c) 2010 Broadcom Corporation5*6* Portions of this file were derived from the aidmp.h header7* distributed with Broadcom's initial brcm80211 Linux driver release, as8* contributed to the Linux staging repository.9*10* Permission to use, copy, modify, and/or distribute this software for any11* purpose with or without fee is hereby granted, provided that the above12* copyright notice and this permission notice appear in all copies.13*14* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES15* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF16* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY17* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES18* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION19* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN20* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.21*22*/2324#ifndef _BCMA_BCMA_EROM_REG_H_25#define _BCMA_BCMA_EROM_REG_H_2627/* Enumeration ROM device registers */28#define BCMA_EROM_TABLE_START 0x000 /**< device enumeration table offset */29#define BCMA_EROM_REMAPCONTROL 0xe0030#define BCMA_EROM_REMAPSELECT 0xe0431#define BCMA_EROM_MASTERSELECT 0xe1032#define BCMA_EROM_ITCR 0xf0033#define BCMA_EROM_ITIP 0xf0434#define BCMA_EROM_TABLE_SIZE BCMA_EROM_REMAPCONTROL - BCMA_EROM_TABLE_START3536/**37* Extract an entry attribute by applying _MASK and _SHIFT defines.38*39* @param _entry The entry containing the desired attribute40* @param _attr The BCMA EROM attribute name (e.g. ENTRY_ISVALID), to be41* concatenated with the `BCMA_EROM_` prefix and `_MASK`/`_SHIFT` suffixes.42*/43#define BCMA_EROM_GET_ATTR(_entry, _attr) \44((_entry & BCMA_EROM_ ## _attr ## _MASK) \45>> BCMA_EROM_ ## _attr ## _SHIFT)4647/**48* Test an EROM entry's validity and type.49*50* @param _entry The entry to test.51* @param _type The required type52* @retval true if the entry type matches and the BCMA_EROM_ENTRY_ISVALID flag53* is set.54* @retval false if the entry is not valid, or if the type does not match.55*/56#define BCMA_EROM_ENTRY_IS(_entry, _type) \57(BCMA_EROM_GET_ATTR(_entry, ENTRY_ISVALID) && \58BCMA_EROM_GET_ATTR(_entry, ENTRY_TYPE) == BCMA_EROM_ENTRY_TYPE_ ## _type)5960/*61* Enumeration ROM Constants62*/63#define BCMA_EROM_TABLE_EOF 0xF /* end of EROM table */6465#define BCMA_EROM_ENTRY_ISVALID_MASK 0x1 /* is entry valid? */66#define BCMA_EROM_ENTRY_ISVALID_SHIFT 06768/* EROM Entry Types */69#define BCMA_EROM_ENTRY_TYPE_MASK 0x6 /* entry type mask */70#define BCMA_EROM_ENTRY_TYPE_SHIFT 071# define BCMA_EROM_ENTRY_TYPE_CORE 0x0 /* core descriptor */72# define BCMA_EROM_ENTRY_TYPE_MPORT 0x2 /* master port descriptor */73# define BCMA_EROM_ENTRY_TYPE_REGION 0x4 /* address region descriptor */7475/* EROM Core DescriptorA (31:0) */76#define BCMA_EROM_COREA_DESIGNER_MASK 0xFFF00000 /* core designer (JEP-106 mfg id) */77#define BCMA_EROM_COREA_DESIGNER_SHIFT 2078#define BCMA_EROM_COREA_ID_MASK 0x000FFF00 /* broadcom-assigned core id */79#define BCMA_EROM_COREA_ID_SHIFT 880#define BCMA_EROM_COREA_CLASS_MASK 0x000000F0 /* core class */81#define BCMA_EROM_COREA_CLASS_SHIFT 48283/* EROM Core DescriptorB (63:32) */84#define BCMA_EROM_COREB_NUM_MP_MASK 0x000001F0 /* master port count */85#define BCMA_EROM_COREB_NUM_MP_SHIFT 486#define BCMA_EROM_COREB_NUM_DP_MASK 0x00003E00 /* device/bridge port count */87#define BCMA_EROM_COREB_NUM_DP_SHIFT 988#define BCMA_EROM_COREB_NUM_WMP_MASK 0x0007C000 /* master wrapper port count */89#define BCMA_EROM_COREB_NUM_WMP_SHIFT 1490#define BCMA_EROM_COREB_NUM_WSP_MASK 0x00F80000 /* slave wrapper port count */91#define BCMA_EROM_COREB_NUM_WSP_SHIFT 1992#define BCMA_EROM_COREB_REV_MASK 0xFF000000 /* broadcom-assigned core revision */93#define BCMA_EROM_COREB_REV_SHIFT 249495/* EROM Master Port Descriptor96*97* The attribute descriptions are derived from background information98* on the AXI bus and PL301 interconnect, but are undocumented99* by Broadcom and may be incorrect.100*/101#define BCMA_EROM_MPORT_NUM_MASK 0x0000FF00 /* AXI master number (unique per interconnect) */102#define BCMA_EROM_MPORT_NUM_SHIFT 8103#define BCMA_EROM_MPORT_ID_MASK 0x000000F0 /* AXI master ID (unique per master). */104#define BCMA_EROM_MPORT_ID_SHIFT 4105106/* EROM Slave Port MMIO Region Descriptor */107#define BCMA_EROM_REGION_BASE_MASK 0xFFFFF000 /* region base address */108#define BCMA_EROM_REGION_BASE_SHIFT 0109#define BCMA_EROM_REGION_64BIT_MASK 0x00000008 /* base address spans two 32-bit entries */110#define BCMA_EROM_REGION_64BIT_SHIFT 0111#define BCMA_EROM_REGION_PORT_MASK 0x00000F00 /* region's associated port */112#define BCMA_EROM_REGION_PORT_SHIFT 8113#define BCMA_EROM_REGION_TYPE_MASK 0x000000C0 /* region type */114#define BCMA_EROM_REGION_TYPE_SHIFT 6115#define BCMA_EROM_REGION_TYPE_DEVICE 0 /* region maps to a device */116#define BCMA_EROM_REGION_TYPE_BRIDGE 1 /* region maps to a bridge (e.g. AXI2APB) */117#define BCMA_EROM_REGION_TYPE_SWRAP 2 /* region maps to a slave port's DMP agent/wrapper */118#define BCMA_EROM_REGION_TYPE_MWRAP 3 /* region maps to a master port's DMP agent/wrapper */119120#define BCMA_EROM_REGION_SIZE_MASK 0x00000030 /* region size encoding */121#define BCMA_EROM_REGION_SIZE_SHIFT 4122#define BCMA_EROM_REGION_SIZE_4K 0 /* 4K region */123#define BCMA_EROM_REGION_SIZE_8K 1 /* 8K region */124#define BCMA_EROM_REGION_SIZE_16K 2 /* 16K region */125#define BCMA_EROM_REGION_SIZE_OTHER 3 /* defined by an additional size descriptor entry. */126#define BCMA_EROM_REGION_SIZE_BASE 0x1000127128/* Region Size Descriptor */129#define BCMA_EROM_RSIZE_VAL_MASK 0xFFFFF000 /* region size */130#define BCMA_EROM_RSIZE_VAL_SHIFT 0131#define BCMA_EROM_RSIZE_64BIT_MASK 0x00000008 /* size spans two 32-bit entries */132#define BCMA_EROM_RSIZE_64BIT_SHIFT 0133134#endif /* _BCMA_BCMA_EROM_REG_H_ */135136137