freebsd-skq/sys/dev/imcsmb/imcsmb_var.h
rpokala 03d8fd318a imcsmb(4): Intel integrated Memory Controller (iMC) SMBus controller driver
imcsmb(4) provides smbus(4) support for the SMBus controller functionality
in the integrated Memory Controllers (iMCs) embedded in Intel Sandybridge-
Xeon, Ivybridge-Xeon, Haswell-Xeon, and Broadwell-Xeon CPUs. Each CPU
implements one or more iMCs, depending on the number of cores; each iMC
implements two SMBus controllers (iMC-SMBs).

*** IMPORTANT NOTE ***
Because motherboard firmware or the BMC might try to use the iMC-SMBs for
monitoring DIMM temperatures and/or managing an NVDIMM, the driver might
need to temporarily disable those functions, or take a hardware interlock,
before using the iMC-SMBs. Details on how to do this may vary from board to
board, and the procedure may be proprietary. It is strongly suggested that
anyone wishing to use this driver contact their motherboard vendor, and
modify the driver as described in the manual page and in the driver itself.
(For what it's worth, the driver as-is has been tested on various SuperMicro
motherboards.)

Reviewed by:	avg, jhb
MFC after:	1 week
Relnotes:	yes
Sponsored by:	Panasas
Differential Revision:	https://reviews.freebsd.org/D14447
Discussed with:	avg, ian, jhb
Tested by:	allanjude (previous version), Panasas
2018-03-03 01:53:51 +00:00

108 lines
3.7 KiB
C

/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Authors: Joe Kloss; Ravi Pokala (rpokala@freebsd.org)
*
* Copyright (c) 2017-2018 Panasas
* 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.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, 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 DAMAGE.
*
* $FreeBSD$
*/
#ifndef _DEV__IMCSMB__IMCSMB_VAR_H_
#define _DEV__IMCSMB__IMCSMB_VAR_H_
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/endian.h>
#include <sys/errno.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/syslog.h>
#include <sys/bus.h>
#include <machine/bus.h>
#include <machine/atomic.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/smbus/smbconf.h>
#include "smbus_if.h"
/* A detailed description of this device is present in imcsmb_pci.c */
/**
* The softc for a particular instance of the PCI device associated with a pair
* of iMC-SMB controllers.
*
* Ordinarily, locking would be done with a mutex. However, we might have an
* NVDIMM connected to this SMBus, and we might need to issue the SAVE command
* to the NVDIMM from a panic context. Mutex operations are not allowed while
* the scheduler is stopped, so just use a simple semaphore.
*
* If, as described in the manpage, additional steps are needed to stop/restart
* firmware operations before/after using the controller, then additional fields
* can be added to this softc.
*/
struct imcsmb_pci_softc {
device_t dev;
volatile int semaphore;
};
void imcsmb_pci_release_bus(device_t dev);
int imcsmb_pci_request_bus(device_t dev);
/**
* PCI config registers for each individual SMBus controller within the iMC.
* Each iMC-SMB has a separate set of registers. There is an array of these
* structures for the PCI device, and one of them is passed to driver for the
* actual iMC-SMB as the IVAR.
*/
struct imcsmb_reg_set {
uint16_t smb_stat;
uint16_t smb_cmd;
uint16_t smb_cntl;
};
/**
* The softc for the device associated with a particular iMC-SMB controller.
* There are two such controllers for each of the PCI devices. The PCI driver
* tells the iMC-SMB driver which set of registers to use via the IVAR. This
* technique was suggested by John Baldwin (jhb@).
*/
struct imcsmb_softc {
device_t dev;
device_t imcsmb_pci; /* The SMBus controller's parent iMC */
device_t smbus; /* The child smbusX interface */
struct imcsmb_reg_set *regs; /* The registers this controller uses */
};
#endif /* _DEV__IMCSMB__IMCSMB_VAR_H_ */
/* vi: set ts=8 sw=4 sts=8 noet: */