xref: /illumos-gate/usr/src/uts/i86pc/sys/psm_common.h (revision 2d6eb4a5)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5843e1988Sjohnlev  * Common Development and Distribution License (the "License").
6843e1988Sjohnlev  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22843e1988Sjohnlev  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_PSM_COMMON_H
277c478bd9Sstevel@tonic-gate #define	_SYS_PSM_COMMON_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <sys/types.h>
307c478bd9Sstevel@tonic-gate #include <sys/param.h>
317c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
327c478bd9Sstevel@tonic-gate #include <sys/acpi/acpi.h>
337c478bd9Sstevel@tonic-gate #include <sys/acpica.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
367c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
377c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
387c478bd9Sstevel@tonic-gate #include <sys/pci.h>
397c478bd9Sstevel@tonic-gate #include <sys/debug.h>
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
427c478bd9Sstevel@tonic-gate extern "C" {
437c478bd9Sstevel@tonic-gate #endif
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /* private data used in psm_common */
477c478bd9Sstevel@tonic-gate typedef struct acpi_prs_private {
487c478bd9Sstevel@tonic-gate 	uchar_t		prs_irqflags;
497c478bd9Sstevel@tonic-gate 	uchar_t		prs_type;
507c478bd9Sstevel@tonic-gate } acpi_prs_private_t;
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate typedef struct acpi_psm_lnk {
547c478bd9Sstevel@tonic-gate 	ACPI_HANDLE	lnkobj;
557c478bd9Sstevel@tonic-gate 	acpi_prs_private_t acpi_prs_prv;
567c478bd9Sstevel@tonic-gate 	uchar_t		device_status;
577c478bd9Sstevel@tonic-gate } acpi_psm_lnk_t;
587c478bd9Sstevel@tonic-gate 
59843e1988Sjohnlev typedef void (*intr_exit_fn_t)(int prev_ipl, int irq);
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate /*
627c478bd9Sstevel@tonic-gate  * status definition for device_status (as returned by _STA)
637c478bd9Sstevel@tonic-gate  */
647c478bd9Sstevel@tonic-gate #define	STA_PRESENT	0x1
657c478bd9Sstevel@tonic-gate #define	STA_ENABLE	0x2
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate /*
697c478bd9Sstevel@tonic-gate  * irq_cache_t: Entry for irq cache to map pci bus/dev/ipin or ACPI object
707c478bd9Sstevel@tonic-gate  * referencing an interrupt link device the configured irq for the device.
717c478bd9Sstevel@tonic-gate  * It is assumed that the acpi object that references the link device is
727c478bd9Sstevel@tonic-gate  * the same for all devices that reference the same link device.
737c478bd9Sstevel@tonic-gate  */
747c478bd9Sstevel@tonic-gate typedef struct irq_cache {
757c478bd9Sstevel@tonic-gate 	uchar_t bus, dev;
767c478bd9Sstevel@tonic-gate 	uchar_t ipin;
777c478bd9Sstevel@tonic-gate 	uchar_t irq;
787c478bd9Sstevel@tonic-gate 	iflag_t flags;
797c478bd9Sstevel@tonic-gate 	ACPI_HANDLE	lnkobj;
807c478bd9Sstevel@tonic-gate } irq_cache_t;
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate typedef struct acpi_irqlist {
847c478bd9Sstevel@tonic-gate 	acpi_prs_private_t acpi_prs_prv;
857c478bd9Sstevel@tonic-gate 	iflag_t intr_flags;
867c478bd9Sstevel@tonic-gate 	uint32_t *irqs;
877c478bd9Sstevel@tonic-gate 	int num_irqs;
887c478bd9Sstevel@tonic-gate 	struct acpi_irqlist *next;
897c478bd9Sstevel@tonic-gate } acpi_irqlist_t;
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate #define	MAX_ISA_IRQ 15
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate #define	ELCR_PORT1	0x4D0
957c478bd9Sstevel@tonic-gate #define	ELCR_PORT2	0x4D1
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate #define	ELCR_LEVEL(elcrval, irq)	(elcrval & (0x1 << irq))
987c478bd9Sstevel@tonic-gate #define	ELCR_EDGE(elcrval, irq)		((elcrval & (0x1 << irq)) == 0)
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate #define	ACPI_PSM_SUCCESS	0
1027c478bd9Sstevel@tonic-gate #define	ACPI_PSM_FAILURE	-1
1037c478bd9Sstevel@tonic-gate #define	ACPI_PSM_PARTIAL 	-2
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate /* verbose flags definitions */
1067c478bd9Sstevel@tonic-gate #define	PSM_VERBOSE_IRQ_FLAG			0x00000001
1077c478bd9Sstevel@tonic-gate #define	PSM_VERBOSE_POWEROFF_FLAG		0x00000002
1087c478bd9Sstevel@tonic-gate #define	PSM_VERBOSE_POWEROFF_PAUSE_FLAG		0x00000004
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate extern int acpi_psm_init(char *module_name, int verbose_flags);
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate extern void build_reserved_irqlist(uchar_t *reserved_irqs_table);
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate extern int acpi_translate_pci_irq(dev_info_t *dip, int ipin, int *pci_irqp,
1157c478bd9Sstevel@tonic-gate     iflag_t *intr_flagp, acpi_psm_lnk_t *acpipsmlnkp);
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate extern int acpi_set_irq_resource(acpi_psm_lnk_t *acpipsmlnkp, int irq);
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate extern int acpi_get_current_irq_resource(acpi_psm_lnk_t *acpipsmlnkp,
1207c478bd9Sstevel@tonic-gate     int *pci_irqp, iflag_t *intr_flagp);
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate extern int acpi_irqlist_find_irq(acpi_irqlist_t *irqlistp, int irq,
1237c478bd9Sstevel@tonic-gate     iflag_t *intr_flagp);
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate extern void acpi_free_irqlist(acpi_irqlist_t *irqlistp);
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate extern int acpi_get_possible_irq_resources(acpi_psm_lnk_t *acpipsmlnkp,
1287c478bd9Sstevel@tonic-gate     acpi_irqlist_t **irqlistp);
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate extern void acpi_new_irq_cache_ent(int bus, int dev, int ipin, int pci_irq,
1317c478bd9Sstevel@tonic-gate     iflag_t *intr_flagp, acpi_psm_lnk_t *acpipsmlnkp);
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate extern int acpi_get_irq_cache_ent(uchar_t bus, uchar_t dev, int ipin,
1347c478bd9Sstevel@tonic-gate     int *pci_irqp, iflag_t *intr_flagp);
1357c478bd9Sstevel@tonic-gate 
136*2df1fe9cSrandyf extern void acpi_restore_link_devices(void);
137*2df1fe9cSrandyf 
1387c478bd9Sstevel@tonic-gate extern int acpi_poweroff(void);
1397c478bd9Sstevel@tonic-gate 
140450d6964Smyers extern void psm_set_elcr(int vecno, int val);
141450d6964Smyers extern int psm_get_elcr(int vecno);
142843e1988Sjohnlev extern intr_exit_fn_t psm_intr_exit_fn(void);
143450d6964Smyers 
1447c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1457c478bd9Sstevel@tonic-gate }
1467c478bd9Sstevel@tonic-gate #endif
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate #endif	/* _SYS_PSM_COMMON_H */
149