/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2015-2016 Landon Fuller <[email protected]>4* Copyright (c) 2017 The FreeBSD Foundation5* All rights reserved.6*7* Portions of this software were developed by Landon Fuller8* under sponsorship from the FreeBSD Foundation.9*10* Redistribution and use in source and binary forms, with or without11* modification, are permitted provided that the following conditions12* are met:13* 1. Redistributions of source code must retain the above copyright14* notice, this list of conditions and the following disclaimer,15* without modification.16* 2. Redistributions in binary form must reproduce at minimum a disclaimer17* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any18* redistribution must be conditioned upon including a substantially19* similar Disclaimer requirement for further binary redistribution.20*21* NO WARRANTY22* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS23* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT24* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY25* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL26* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,27* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF28* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS29* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER30* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)31* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF32* THE POSSIBILITY OF SUCH DAMAGES.33*34*/3536#ifndef _BCMA_BCMAVAR_H_37#define _BCMA_BCMAVAR_H_3839#include <sys/param.h>40#include <sys/bus.h>41#include <sys/limits.h>4243#include <machine/bus.h>44#include <sys/rman.h>4546#include "bcma.h"4748/*49* Internal definitions shared by bcma(4) driver implementations.50*/5152/** Base resource ID for per-core agent register allocations */53#define BCMA_AGENT_RID_BASE 1005455/**56* Return the device's core index.57*58* @param _dinfo The bcma_devinfo instance to query.59*/60#define BCMA_DINFO_COREIDX(_dinfo) \61((_dinfo)->corecfg->core_info.core_idx)6263/** BCMA port identifier. */64typedef u_int bcma_pid_t;65#define BCMA_PID_MAX UINT_MAX /**< Maximum bcma_pid_t value */6667/** BCMA per-port region map identifier. */68typedef u_int bcma_rmid_t;69#define BCMA_RMID_MAX UINT_MAX /**< Maximum bcma_rmid_t value */7071struct bcma_devinfo;72struct bcma_corecfg;73struct bcma_intr;74struct bcma_map;75struct bcma_mport;76struct bcma_sport;7778int bcma_probe(device_t dev);79int bcma_attach(device_t dev);80int bcma_detach(device_t dev);81u_int bcma_get_intr_count(device_t dev, device_t child);82int bcma_get_intr_ivec(device_t dev, device_t child,83u_int intr, uint32_t *ivec);8485int bcma_add_children(device_t bus);8687struct bcma_sport_list *bcma_corecfg_get_port_list(struct bcma_corecfg *cfg,88bhnd_port_type type);8990struct bcma_devinfo *bcma_alloc_dinfo(device_t bus);91int bcma_init_dinfo(device_t bus, device_t child,92struct bcma_devinfo *dinfo,93struct bcma_corecfg *corecfg);94void bcma_free_dinfo(device_t bus, device_t child,95struct bcma_devinfo *dinfo);9697struct bcma_corecfg *bcma_alloc_corecfg(u_int core_index, int core_unit,98uint16_t vendor, uint16_t device, uint8_t hwrev);99void bcma_free_corecfg(struct bcma_corecfg *corecfg);100101struct bcma_intr *bcma_alloc_intr(uint8_t bank, uint8_t sel,102uint8_t line);103void bcma_free_intr(struct bcma_intr *intr);104105struct bcma_sport *bcma_alloc_sport(bcma_pid_t port_num, bhnd_port_type port_type);106void bcma_free_sport(struct bcma_sport *sport);107108int bcma_dmp_wait_reset(device_t child,109struct bcma_devinfo *dinfo);110int bcma_dmp_write_reset(device_t child,111struct bcma_devinfo *dinfo, uint32_t value);112113/** BCMA master port descriptor */114struct bcma_mport {115bcma_pid_t mp_num; /**< AXI port identifier (bus-unique) */116bcma_pid_t mp_vid; /**< AXI master virtual ID (core-unique) */117STAILQ_ENTRY(bcma_mport) mp_link;118};119120/** BCMA memory region descriptor */121struct bcma_map {122bcma_rmid_t m_region_num; /**< region identifier (port-unique). */123bhnd_addr_t m_base; /**< base address */124bhnd_size_t m_size; /**< size */125int m_rid; /**< bus resource id, or -1. */126127STAILQ_ENTRY(bcma_map) m_link;128};129130/** BCMA interrupt descriptor */131struct bcma_intr {132uint8_t i_bank; /**< OOB bank (see BCMA_OOB_BANK[A-D]) */133uint8_t i_sel; /**< OOB selector (0-7) */134uint8_t i_busline; /**< OOB bus line assigned to this selector */135bool i_mapped; /**< if an irq has been mapped for this selector */136int i_rid; /**< bus resource id, or -1 */137rman_res_t i_irq; /**< the mapped bus irq, if any */138139STAILQ_ENTRY(bcma_intr) i_link;140};141142/** BCMA slave port descriptor */143struct bcma_sport {144bcma_pid_t sp_num; /**< slave port number (core-unique) */145bhnd_port_type sp_type; /**< port type */146147u_long sp_num_maps; /**< number of regions mapped to this port */148STAILQ_HEAD(, bcma_map) sp_maps;149STAILQ_ENTRY(bcma_sport) sp_link;150};151152STAILQ_HEAD(bcma_mport_list, bcma_mport);153STAILQ_HEAD(bcma_intr_list, bcma_intr);154STAILQ_HEAD(bcma_sport_list, bcma_sport);155156/** BCMA IP core/block configuration */157struct bcma_corecfg {158struct bhnd_core_info core_info; /**< standard core info */159160u_long num_master_ports; /**< number of master port descriptors. */161struct bcma_mport_list master_ports; /**< master port descriptors */162163u_long num_dev_ports; /**< number of device slave port descriptors. */164struct bcma_sport_list dev_ports; /**< device port descriptors */165166u_long num_bridge_ports; /**< number of bridge slave port descriptors. */167struct bcma_sport_list bridge_ports; /**< bridge port descriptors */168169u_long num_wrapper_ports; /**< number of wrapper slave port descriptors. */170struct bcma_sport_list wrapper_ports; /**< wrapper port descriptors */171};172173/**174* BCMA per-device info175*/176struct bcma_devinfo {177struct resource_list resources; /**< Slave port memory regions. */178struct bcma_corecfg *corecfg; /**< IP core/block config */179180struct bhnd_resource *res_agent; /**< Agent (wrapper) resource, or NULL. Not181* all bcma(4) cores have or require an agent. */182int rid_agent; /**< Agent resource ID, or -1 */183184u_int num_intrs; /**< number of interrupt descriptors. */185struct bcma_intr_list intrs; /**< interrupt descriptors */186187void *pmu_info; /**< Bus-managed PMU state, or NULL */188};189190/** BMCA per-instance state */191struct bcma_softc {192struct bhnd_softc bhnd_sc; /**< bhnd state */193};194195#endif /* _BCMA_BCMAVAR_H_ */196197198