2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Authors: Joe Kloss; Ravi Pokala (rpokala@freebsd.org)
6 * Copyright (c) 2017-2018 Panasas
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #ifndef _DEV__IMCSMB__IMCSMB_VAR_H_
34 #define _DEV__IMCSMB__IMCSMB_VAR_H_
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/kernel.h>
39 #include <sys/module.h>
40 #include <sys/endian.h>
41 #include <sys/errno.h>
43 #include <sys/mutex.h>
44 #include <sys/syslog.h>
47 #include <machine/bus.h>
48 #include <machine/atomic.h>
50 #include <dev/pci/pcivar.h>
51 #include <dev/pci/pcireg.h>
53 #include <dev/smbus/smbconf.h>
57 /* A detailed description of this device is present in imcsmb_pci.c */
60 * The softc for a particular instance of the PCI device associated with a pair
61 * of iMC-SMB controllers.
63 * Ordinarily, locking would be done with a mutex. However, we might have an
64 * NVDIMM connected to this SMBus, and we might need to issue the SAVE command
65 * to the NVDIMM from a panic context. Mutex operations are not allowed while
66 * the scheduler is stopped, so just use a simple semaphore.
68 * If, as described in the manpage, additional steps are needed to stop/restart
69 * firmware operations before/after using the controller, then additional fields
70 * can be added to this softc.
72 struct imcsmb_pci_softc {
74 volatile int semaphore;
77 void imcsmb_pci_release_bus(device_t dev);
78 int imcsmb_pci_request_bus(device_t dev);
81 * PCI config registers for each individual SMBus controller within the iMC.
82 * Each iMC-SMB has a separate set of registers. There is an array of these
83 * structures for the PCI device, and one of them is passed to driver for the
84 * actual iMC-SMB as the IVAR.
86 struct imcsmb_reg_set {
93 * The softc for the device associated with a particular iMC-SMB controller.
94 * There are two such controllers for each of the PCI devices. The PCI driver
95 * tells the iMC-SMB driver which set of registers to use via the IVAR. This
96 * technique was suggested by John Baldwin (jhb@).
100 device_t imcsmb_pci; /* The SMBus controller's parent iMC */
101 device_t smbus; /* The child smbusX interface */
102 struct imcsmb_reg_set *regs; /* The registers this controller uses */
105 #endif /* _DEV__IMCSMB__IMCSMB_VAR_H_ */
107 /* vi: set ts=8 sw=4 sts=8 noet: */