xref: /freebsd/sys/dev/superio/superio.h (revision e3722b788eaa629d536a524e5b3fb7dc1082dbf3)
1*e3722b78SAndriy Gapon /*
2*e3722b78SAndriy Gapon  * Copyright (c) 2016 Andriy Gapon
3*e3722b78SAndriy Gapon  *
4*e3722b78SAndriy Gapon  * Redistribution and use in source and binary forms, with or without
5*e3722b78SAndriy Gapon  * modification, are permitted provided that the following conditions
6*e3722b78SAndriy Gapon  * are met:
7*e3722b78SAndriy Gapon  * 1. Redistributions of source code must retain the above copyright
8*e3722b78SAndriy Gapon  *    notice, this list of conditions and the following disclaimer.
9*e3722b78SAndriy Gapon  * 2. Redistributions in binary form must reproduce the above copyright
10*e3722b78SAndriy Gapon  *    notice, this list of conditions and the following disclaimer in the
11*e3722b78SAndriy Gapon  *    documentation and/or other materials provided with the distribution.
12*e3722b78SAndriy Gapon  *
13*e3722b78SAndriy Gapon  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS AS IS'' AND
14*e3722b78SAndriy Gapon  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15*e3722b78SAndriy Gapon  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16*e3722b78SAndriy Gapon  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17*e3722b78SAndriy Gapon  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18*e3722b78SAndriy Gapon  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19*e3722b78SAndriy Gapon  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20*e3722b78SAndriy Gapon  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21*e3722b78SAndriy Gapon  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22*e3722b78SAndriy Gapon  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23*e3722b78SAndriy Gapon  * SUCH DAMAGE.
24*e3722b78SAndriy Gapon  *
25*e3722b78SAndriy Gapon  * $FreeBSD$
26*e3722b78SAndriy Gapon  */
27*e3722b78SAndriy Gapon 
28*e3722b78SAndriy Gapon #ifndef SUPERIO_H
29*e3722b78SAndriy Gapon #define SUPERIO_H
30*e3722b78SAndriy Gapon 
31*e3722b78SAndriy Gapon typedef enum superio_vendor {
32*e3722b78SAndriy Gapon 	SUPERIO_VENDOR_NONE,
33*e3722b78SAndriy Gapon 	SUPERIO_VENDOR_ITE,
34*e3722b78SAndriy Gapon 	SUPERIO_VENDOR_NUVOTON,
35*e3722b78SAndriy Gapon 	SUPERIO_VENDOR_MAX
36*e3722b78SAndriy Gapon } superio_vendor_t;
37*e3722b78SAndriy Gapon 
38*e3722b78SAndriy Gapon typedef enum superio_dev_type {
39*e3722b78SAndriy Gapon 	SUPERIO_DEV_NONE,
40*e3722b78SAndriy Gapon 	SUPERIO_DEV_HWM,
41*e3722b78SAndriy Gapon 	SUPERIO_DEV_WDT,
42*e3722b78SAndriy Gapon 	SUPERIO_DEV_GPIO,
43*e3722b78SAndriy Gapon 	SUPERIO_DEV_MAX
44*e3722b78SAndriy Gapon } superio_dev_type_t;
45*e3722b78SAndriy Gapon 
46*e3722b78SAndriy Gapon superio_vendor_t superio_vendor(device_t dev);
47*e3722b78SAndriy Gapon uint16_t superio_devid(device_t dev);
48*e3722b78SAndriy Gapon uint8_t superio_revid(device_t dev);
49*e3722b78SAndriy Gapon uint8_t superio_read(device_t dev, uint8_t reg);
50*e3722b78SAndriy Gapon void superio_write(device_t dev, uint8_t reg, uint8_t val);
51*e3722b78SAndriy Gapon bool superio_dev_enabled(device_t dev, uint8_t mask);
52*e3722b78SAndriy Gapon void superio_dev_enable(device_t dev, uint8_t mask);
53*e3722b78SAndriy Gapon void superio_dev_disable(device_t dev, uint8_t mask);
54*e3722b78SAndriy Gapon 
55*e3722b78SAndriy Gapon device_t superio_find_dev(device_t superio, superio_dev_type_t type,
56*e3722b78SAndriy Gapon     int ldn);
57*e3722b78SAndriy Gapon 
58*e3722b78SAndriy Gapon enum superio_ivars {
59*e3722b78SAndriy Gapon 	SUPERIO_IVAR_LDN = 	10600,
60*e3722b78SAndriy Gapon 	SUPERIO_IVAR_TYPE,
61*e3722b78SAndriy Gapon 	SUPERIO_IVAR_IOBASE,
62*e3722b78SAndriy Gapon 	SUPERIO_IVAR_IOBASE2,
63*e3722b78SAndriy Gapon 	SUPERIO_IVAR_IRQ,
64*e3722b78SAndriy Gapon 	SUPERIO_IVAR_DMA
65*e3722b78SAndriy Gapon };
66*e3722b78SAndriy Gapon 
67*e3722b78SAndriy Gapon #define	SUPERIO_ACCESSOR(var, ivar, type)				\
68*e3722b78SAndriy Gapon 	__BUS_ACCESSOR(superio, var, SUPERIO, ivar, type)
69*e3722b78SAndriy Gapon 
70*e3722b78SAndriy Gapon SUPERIO_ACCESSOR(ldn,		LDN,		uint8_t)
71*e3722b78SAndriy Gapon SUPERIO_ACCESSOR(type,		TYPE,		superio_dev_type_t)
72*e3722b78SAndriy Gapon SUPERIO_ACCESSOR(iobase,	IOBASE,		uint16_t)
73*e3722b78SAndriy Gapon SUPERIO_ACCESSOR(iobase2,	IOBASE2,	uint16_t)
74*e3722b78SAndriy Gapon SUPERIO_ACCESSOR(irq,		IRQ,		uint8_t)
75*e3722b78SAndriy Gapon SUPERIO_ACCESSOR(dma,		DMA,		uint8_t)
76*e3722b78SAndriy Gapon 
77*e3722b78SAndriy Gapon #undef SUPERIO_ACCESSOR
78*e3722b78SAndriy Gapon 
79*e3722b78SAndriy Gapon #endif /*SUPERIO_H*/
80