/*-1* Copyright (c) 2015 Landon Fuller <[email protected]>2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer,9* without modification.10* 2. Redistributions in binary form must reproduce at minimum a disclaimer11* similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any12* redistribution must be conditioned upon including a substantially13* similar Disclaimer requirement for further binary redistribution.14*15* NO WARRANTY16* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS17* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT18* LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY19* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL20* THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,21* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF22* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS23* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER24* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)25* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF26* THE POSSIBILITY OF SUCH DAMAGES.27*/2829#include <sys/param.h>3031#include <dev/bhnd/bhnd_ids.h>32#include <dev/bhnd/bhndreg.h>33#include <dev/bhnd/bhnd.h>3435#include "bhndb_hwdata.h"3637/*38* Resource priority specifications shared by all bhndb(4) bridge39* implementations.40*/4142/*43* Define a bhndb_port_priority table.44*/45#define BHNDB_PORTS(...) \46.ports = _BHNDB_PORT_ARRAY(__VA_ARGS__), \47.num_ports = nitems(_BHNDB_PORT_ARRAY(__VA_ARGS__))4849#define _BHNDB_PORT_ARRAY(...) (const struct bhndb_port_priority[]) { \50__VA_ARGS__ \51}5253/*54* Define a core priority record for all cores matching @p devclass55*/56#define BHNDB_CLASS_PRIO(_devclass, _priority, ...) { \57.match = { \58BHND_MATCH_CORE_CLASS(BHND_DEVCLASS_ ## _devclass), \59}, \60.priority = (BHNDB_PRIORITY_ ## _priority), \61BHNDB_PORTS(__VA_ARGS__) \62}6364/*65* Define a default core priority record66*/67#define BHNDB_DEFAULT_PRIO(...) { \68.match = { \69BHND_MATCH_ANY , \70}, \71.priority = (BHNDB_PRIORITY_DEFAULT), \72BHNDB_PORTS(__VA_ARGS__) \73}7475/* Define a port priority record for the type/port/region triplet, optionally76* specifying port allocation flags as the final argument */77#define BHNDB_PORT_PRIO(_type, _port, _region, _priority, ...) \78_BHNDB_PORT_PRIO(_type, _port, _region, _priority, ## __VA_ARGS__, 0)7980#define _BHNDB_PORT_PRIO(_type, _port, _region, _priority, _flags, ...) \81{ \82.type = (BHND_PORT_ ## _type), \83.port = _port, \84.region = _region, \85.priority = (BHNDB_PRIORITY_ ## _priority), \86.alloc_flags = (_flags) \87}8889/* Define a port priority record for the default (_type, 0, 0) type/port/region90* triplet. */91#define BHNDB_PORT0_PRIO(_type, _priority, ...) \92BHNDB_PORT_PRIO(_type, 0, 0, _priority, ## __VA_ARGS__, 0)9394/**95* Generic resource priority configuration usable with all currently supported96* bcma(4)-based PCI devices.97*/98const struct bhndb_hw_priority bhndb_bcma_priority_table[] = {99/*100* Ignorable device classes.101*102* Runtime access to these cores is not required, and no register103* windows should be reserved for these device types.104*/105BHNDB_CLASS_PRIO(SOC_ROUTER, NONE),106BHNDB_CLASS_PRIO(SOC_BRIDGE, NONE),107BHNDB_CLASS_PRIO(EROM, NONE),108BHNDB_CLASS_PRIO(OTHER, NONE),109110/*111* Low priority device classes.112*113* These devices do not sit in a performance-critical path and can be114* treated as a low allocation priority.115*/116BHNDB_CLASS_PRIO(CC, LOW,117/* Device Block */118BHNDB_PORT0_PRIO(DEVICE, LOW),119120/* CC agent registers are not accessed via the bridge. */121BHNDB_PORT0_PRIO(AGENT, NONE)122),123124BHNDB_CLASS_PRIO(PMU, LOW,125/* Device Block */126BHNDB_PORT0_PRIO(DEVICE, LOW),127128/* PMU agent registers are not accessed via the bridge. */129BHNDB_PORT0_PRIO(AGENT, NONE)130),131132/*133* Default Core Behavior134*135* All other cores are assumed to require efficient runtime access to136* the default device port, and if supported by the bus, an agent port.137*/138BHNDB_DEFAULT_PRIO(139/* Device Block */140BHNDB_PORT0_PRIO(DEVICE, HIGH),141142/* Agent Block */143BHNDB_PORT0_PRIO(AGENT, DEFAULT)144),145146BHNDB_HW_PRIORITY_TABLE_END147};148149/**150* Generic resource priority configuration usable with all currently supported151* siba(4)-based PCI devices.152*/153const struct bhndb_hw_priority bhndb_siba_priority_table[] = {154/*155* Ignorable device classes.156*157* Runtime access to these cores is not required, and no register158* windows should be reserved for these device types.159*/160BHNDB_CLASS_PRIO(SOC_ROUTER, NONE),161BHNDB_CLASS_PRIO(SOC_BRIDGE, NONE),162BHNDB_CLASS_PRIO(EROM, NONE),163BHNDB_CLASS_PRIO(OTHER, NONE),164165/*166* Low priority device classes.167*168* These devices do not sit in a performance-critical path and can be169* treated as a low allocation priority.170*171* Agent ports are marked as 'NONE' on siba(4) devices, as they172* will be fully mappable via register windows shared with the173* device0.0 port.174*175* To support early PCI_V0 devices, we enable FULFILL_ON_OVERCOMMIT for176* ChipCommon.177*/178BHNDB_CLASS_PRIO(CC, LOW,179/* Device Block */180BHNDB_PORT_PRIO(DEVICE, 0, 0, LOW,181BHNDB_ALLOC_FULFILL_ON_OVERCOMMIT)182),183184BHNDB_CLASS_PRIO(PMU, LOW,185/* Device Block */186BHNDB_PORT_PRIO(DEVICE, 0, 0, LOW)187),188189/*190* Default Core Behavior191*192* All other cores are assumed to require efficient runtime access to193* the device port.194*/195BHNDB_DEFAULT_PRIO(196/* Device Block */197BHNDB_PORT_PRIO(DEVICE, 0, 0, HIGH)198),199200BHNDB_HW_PRIORITY_TABLE_END201};202203204