Path: blob/main/sys/dev/bhnd/bhndb/bhndb_pci_sprom.c
39536 views
/*-1* Copyright (c) 2015-2016 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/cdefs.h>30/*31* BHNDB PCI SPROM driver.32*33* Provides support for early PCI bridge cores that vend SPROM CSRs34* via PCI configuration space.35*/3637#include <sys/param.h>38#include <sys/kernel.h>39#include <sys/bus.h>40#include <sys/limits.h>41#include <sys/malloc.h>42#include <sys/module.h>43#include <sys/systm.h>4445#include <dev/pci/pcireg.h>46#include <dev/pci/pcivar.h>4748#include <dev/bhnd/bhnd.h>49#include <dev/bhnd/cores/pci/bhnd_pci_hostbvar.h>50#include <dev/bhnd/nvram/bhnd_spromvar.h>5152#include "bhnd_nvram_if.h"5354#include "bhndb_pcireg.h"55#include "bhndb_pcivar.h"5657static int58bhndb_pci_sprom_probe(device_t dev)59{60device_t bridge;61int error;6263/* Our parent must be a PCI-BHND bridge */64bridge = device_get_parent(dev);65if (device_get_driver(bridge) != &bhndb_pci_driver)66return (ENXIO);6768/* Defer to default driver implementation */69if ((error = bhnd_sprom_probe(dev)) > 0)70return (error);7172return (BUS_PROBE_NOWILDCARD);73}7475static device_method_t bhndb_pci_sprom_methods[] = {76/* Device interface */77DEVMETHOD(device_probe, bhndb_pci_sprom_probe),78DEVMETHOD_END79};8081DEFINE_CLASS_1(bhnd_nvram, bhndb_pci_sprom_driver, bhndb_pci_sprom_methods, sizeof(struct bhnd_sprom_softc), bhnd_sprom_driver);8283DRIVER_MODULE(bhndb_pci_sprom, bhndb, bhndb_pci_sprom_driver, NULL, NULL);84MODULE_DEPEND(bhndb_pci_sprom, bhnd, 1, 1, 1);85MODULE_DEPEND(bhndb_pci_sprom, bhnd_sprom, 1, 1, 1);86MODULE_VERSION(bhndb_pci_sprom, 1);878889