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