2016-02-26 03:34:08 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2015 Landon Fuller <landon@landonf.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
|
|
|
* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
|
|
|
|
* redistribution must be conditioned upon including a substantially
|
|
|
|
* similar Disclaimer requirement for further binary redistribution.
|
|
|
|
*
|
|
|
|
* NO WARRANTY
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
|
|
|
|
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
|
|
|
|
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
|
|
|
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* THE POSSIBILITY OF SUCH DAMAGES.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BCMA_BCMAVAR_H_
|
|
|
|
#define _BCMA_BCMAVAR_H_
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/limits.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
|
|
|
|
#include "bcma.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Internal definitions shared by bcma(4) driver implementations.
|
|
|
|
*/
|
|
|
|
|
2016-09-04 00:58:19 +00:00
|
|
|
/** Base resource ID for per-core agent register allocations */
|
|
|
|
#define BCMA_AGENT_RID_BASE 100
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the device's core index.
|
|
|
|
*
|
|
|
|
* @param _dinfo The bcma_devinfo instance to query.
|
|
|
|
*/
|
|
|
|
#define BCMA_DINFO_COREIDX(_dinfo) \
|
|
|
|
((_dinfo)->corecfg->core_info.core_idx)
|
|
|
|
|
|
|
|
|
2016-02-26 03:34:08 +00:00
|
|
|
/** BCMA port identifier. */
|
|
|
|
typedef u_int bcma_pid_t;
|
|
|
|
#define BCMA_PID_MAX UINT_MAX /**< Maximum bcma_pid_t value */
|
|
|
|
|
|
|
|
/** BCMA per-port region map identifier. */
|
|
|
|
typedef u_int bcma_rmid_t;
|
|
|
|
#define BCMA_RMID_MAX UINT_MAX /**< Maximum bcma_rmid_t value */
|
|
|
|
|
|
|
|
struct bcma_devinfo;
|
|
|
|
struct bcma_corecfg;
|
|
|
|
struct bcma_map;
|
|
|
|
struct bcma_mport;
|
|
|
|
struct bcma_sport;
|
|
|
|
|
|
|
|
int bcma_probe(device_t dev);
|
|
|
|
int bcma_attach(device_t dev);
|
|
|
|
int bcma_detach(device_t dev);
|
2016-09-05 22:11:46 +00:00
|
|
|
int bcma_get_intr_count(device_t dev, device_t child);
|
|
|
|
int bcma_get_core_ivec(device_t dev, device_t child,
|
|
|
|
u_int intr, uint32_t *ivec);
|
2016-02-26 03:34:08 +00:00
|
|
|
|
Implement a generic bhnd(4) device enumeration table API.
This defines a new bhnd_erom_if API, providing a common interface to device
enumeration on siba(4) and bcma(4) devices, for use both in the bhndb bridge
and SoC early boot contexts, and migrates mips/broadcom over to the new API.
This also replaces the previous adhoc device enumeration support implemented
for mips/broadcom.
Migration of bhndb to the new API will be implemented in a follow-up commit.
- Defined new bhnd_erom_if interface for bhnd(4) device enumeration, along
with bcma(4) and siba(4)-specific implementations.
- Fixed a minor bug in bhndb that logged an error when we attempted to map the
full siba(4) bus space (18000000-17FFFFFF) in the siba EROM parser.
- Reverted use of the resource's start address as the ChipCommon enum_addr in
bhnd_read_chipid(). When called from bhndb, this address is found within the
host address space, resulting in an invalid bridged enum_addr.
- Added support for falling back on standard bus_activate_resource() in
bhnd_bus_generic_activate_resource(), enabling allocation of the bhnd_erom's
bhnd_resource directly from a nexus-attached bhnd(4) device.
- Removed BHND_BUS_GET_CORE_TABLE(); it has been replaced by the erom API.
- Added support for statically initializing bhnd_erom instances, for use prior
to malloc availability. The statically allocated buffer size is verified both
at runtime, and via a compile-time assertion (see BHND_EROM_STATIC_BYTES).
- bhnd_erom classes are registered within a module via a linker set, allowing
mips/broadcom to probe available EROM parser instances without creating a
strong reference to bcma/siba-specific symbols.
- Migrated mips/broadcom to bhnd_erom_if, replacing the previous MIPS-specific
device enumeration implementation.
Approved by: adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D7748
2016-09-03 23:57:17 +00:00
|
|
|
int bcma_add_children(device_t bus);
|
2016-02-26 03:34:08 +00:00
|
|
|
|
|
|
|
struct bcma_sport_list *bcma_corecfg_get_port_list(struct bcma_corecfg *cfg,
|
|
|
|
bhnd_port_type type);
|
|
|
|
|
2016-06-25 04:36:30 +00:00
|
|
|
struct bcma_devinfo *bcma_alloc_dinfo(device_t bus);
|
|
|
|
int bcma_init_dinfo(device_t bus,
|
|
|
|
struct bcma_devinfo *dinfo,
|
2016-02-26 03:34:08 +00:00
|
|
|
struct bcma_corecfg *corecfg);
|
2016-09-04 00:58:19 +00:00
|
|
|
int bcma_dinfo_alloc_agent(device_t bus, device_t child,
|
|
|
|
struct bcma_devinfo *dinfo);
|
2016-02-26 03:34:08 +00:00
|
|
|
void bcma_free_dinfo(device_t bus,
|
|
|
|
struct bcma_devinfo *dinfo);
|
|
|
|
|
|
|
|
struct bcma_corecfg *bcma_alloc_corecfg(u_int core_index, int core_unit,
|
|
|
|
uint16_t vendor, uint16_t device, uint8_t hwrev);
|
|
|
|
void bcma_free_corecfg(struct bcma_corecfg *corecfg);
|
|
|
|
|
|
|
|
struct bcma_sport *bcma_alloc_sport(bcma_pid_t port_num, bhnd_port_type port_type);
|
|
|
|
void bcma_free_sport(struct bcma_sport *sport);
|
|
|
|
|
2016-09-24 04:08:16 +00:00
|
|
|
int bcma_dmp_wait_reset(device_t child,
|
|
|
|
struct bcma_devinfo *dinfo);
|
|
|
|
int bcma_dmp_write_reset(device_t child,
|
|
|
|
struct bcma_devinfo *dinfo, uint32_t value);
|
|
|
|
|
2016-02-26 03:34:08 +00:00
|
|
|
/** BCMA master port descriptor */
|
|
|
|
struct bcma_mport {
|
|
|
|
bcma_pid_t mp_num; /**< AXI port identifier (bus-unique) */
|
|
|
|
bcma_pid_t mp_vid; /**< AXI master virtual ID (core-unique) */
|
|
|
|
STAILQ_ENTRY(bcma_mport) mp_link;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** BCMA memory region descriptor */
|
|
|
|
struct bcma_map {
|
|
|
|
bcma_rmid_t m_region_num; /**< region identifier (port-unique). */
|
|
|
|
bhnd_addr_t m_base; /**< base address */
|
|
|
|
bhnd_size_t m_size; /**< size */
|
|
|
|
int m_rid; /**< bus resource id, or -1. */
|
|
|
|
|
|
|
|
STAILQ_ENTRY(bcma_map) m_link;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** BCMA slave port descriptor */
|
|
|
|
struct bcma_sport {
|
|
|
|
bcma_pid_t sp_num; /**< slave port number (core-unique) */
|
|
|
|
bhnd_port_type sp_type; /**< port type */
|
|
|
|
|
|
|
|
u_long sp_num_maps; /**< number of regions mapped to this port */
|
|
|
|
STAILQ_HEAD(, bcma_map) sp_maps;
|
|
|
|
STAILQ_ENTRY(bcma_sport) sp_link;
|
|
|
|
};
|
|
|
|
|
|
|
|
STAILQ_HEAD(bcma_mport_list, bcma_mport);
|
|
|
|
STAILQ_HEAD(bcma_sport_list, bcma_sport);
|
|
|
|
|
|
|
|
/** BCMA IP core/block configuration */
|
|
|
|
struct bcma_corecfg {
|
|
|
|
struct bhnd_core_info core_info; /**< standard core info */
|
|
|
|
|
|
|
|
u_long num_master_ports; /**< number of master port descriptors. */
|
|
|
|
struct bcma_mport_list master_ports; /**< master port descriptors */
|
|
|
|
|
|
|
|
u_long num_dev_ports; /**< number of device slave port descriptors. */
|
|
|
|
struct bcma_sport_list dev_ports; /**< device port descriptors */
|
|
|
|
|
|
|
|
u_long num_bridge_ports; /**< number of bridge slave port descriptors. */
|
|
|
|
struct bcma_sport_list bridge_ports; /**< bridge port descriptors */
|
|
|
|
|
|
|
|
u_long num_wrapper_ports; /**< number of wrapper slave port descriptors. */
|
|
|
|
struct bcma_sport_list wrapper_ports; /**< wrapper port descriptors */
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* BCMA per-device info
|
|
|
|
*/
|
|
|
|
struct bcma_devinfo {
|
2016-09-24 04:08:16 +00:00
|
|
|
struct resource_list resources; /**< Slave port memory regions. */
|
|
|
|
struct bcma_corecfg *corecfg; /**< IP core/block config */
|
2016-06-25 04:36:30 +00:00
|
|
|
|
2016-09-24 04:08:16 +00:00
|
|
|
struct bhnd_resource *res_agent; /**< Agent (wrapper) resource, or NULL. Not
|
|
|
|
* all bcma(4) cores have or require an agent. */
|
|
|
|
int rid_agent; /**< Agent resource ID, or -1 */
|
2016-02-26 03:34:08 +00:00
|
|
|
|
2016-09-24 04:08:16 +00:00
|
|
|
struct bhnd_core_pmu_info *pmu_info; /**< Bus-managed PMU state, or NULL */
|
2016-02-26 03:34:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** BMCA per-instance state */
|
|
|
|
struct bcma_softc {
|
|
|
|
struct bhnd_softc bhnd_sc; /**< bhnd state */
|
|
|
|
};
|
|
|
|
|
2016-06-25 04:36:30 +00:00
|
|
|
#endif /* _BCMA_BCMAVAR_H_ */
|