1257293Sneel/*-
2330449Seadler * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3330449Seadler *
4257293Sneel * Copyright (c) 2013 Neel Natu <neel@freebsd.org>
5257293Sneel * All rights reserved.
6257293Sneel *
7257293Sneel * Redistribution and use in source and binary forms, with or without
8257293Sneel * modification, are permitted provided that the following conditions
9257293Sneel * are met:
10257293Sneel * 1. Redistributions of source code must retain the above copyright
11257293Sneel *    notice, this list of conditions and the following disclaimer.
12257293Sneel * 2. Redistributions in binary form must reproduce the above copyright
13257293Sneel *    notice, this list of conditions and the following disclaimer in the
14257293Sneel *    documentation and/or other materials provided with the distribution.
15257293Sneel *
16257293Sneel * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
17257293Sneel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18257293Sneel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19257293Sneel * ARE DISCLAIMED.  IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
20257293Sneel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21257293Sneel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22257293Sneel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23257293Sneel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24257293Sneel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25257293Sneel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26257293Sneel * SUCH DAMAGE.
27257293Sneel *
28257293Sneel * $FreeBSD: stable/11/usr.sbin/bhyve/pci_lpc.h 330449 2018-03-05 07:26:05Z eadler $
29257293Sneel */
30257293Sneel
31257293Sneel#ifndef _LPC_H_
32257293Sneel#define	_LPC_H_
33257293Sneel
34260206Sjhb#include <sys/linker_set.h>
35260206Sjhb
36260206Sjhbtypedef void (*lpc_write_dsdt_t)(void);
37260206Sjhb
38260206Sjhbstruct lpc_dsdt {
39260206Sjhb	lpc_write_dsdt_t handler;
40260206Sjhb};
41260206Sjhb
42260206Sjhb#define	LPC_DSDT(handler)						\
43260206Sjhb	static struct lpc_dsdt __CONCAT(__lpc_dsdt, __LINE__) = {	\
44260206Sjhb		(handler),						\
45260206Sjhb	};								\
46260206Sjhb	DATA_SET(lpc_dsdt_set, __CONCAT(__lpc_dsdt, __LINE__))
47260206Sjhb
48260206Sjhbenum lpc_sysres_type {
49260206Sjhb	LPC_SYSRES_IO,
50260206Sjhb	LPC_SYSRES_MEM
51260206Sjhb};
52260206Sjhb
53260206Sjhbstruct lpc_sysres {
54260206Sjhb	enum lpc_sysres_type type;
55260206Sjhb	uint32_t base;
56260206Sjhb	uint32_t length;
57260206Sjhb};
58260206Sjhb
59260206Sjhb#define	LPC_SYSRES(type, base, length)					\
60260206Sjhb	static struct lpc_sysres __CONCAT(__lpc_sysres, __LINE__) = {	\
61260206Sjhb		(type),							\
62260206Sjhb		(base),							\
63260206Sjhb		(length)						\
64260206Sjhb	};								\
65260206Sjhb	DATA_SET(lpc_sysres_set, __CONCAT(__lpc_sysres, __LINE__))
66260206Sjhb
67260206Sjhb#define	SYSRES_IO(base, length)		LPC_SYSRES(LPC_SYSRES_IO, base, length)
68260206Sjhb#define	SYSRES_MEM(base, length)	LPC_SYSRES(LPC_SYSRES_MEM, base, length)
69260206Sjhb
70257293Sneelint	lpc_device_parse(const char *opt);
71266125Sjhbchar	*lpc_pirq_name(int pin);
72266125Sjhbvoid	lpc_pirq_routed(void);
73284539Sneelconst char *lpc_bootrom(void);
74257293Sneel
75257293Sneel#endif
76