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 #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include <sys/types.h> 327c478bd9Sstevel@tonic-gate #include <sys/param.h> 337c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h> 347c478bd9Sstevel@tonic-gate #include <sys/acpi/acpi.h> 357c478bd9Sstevel@tonic-gate #include <sys/acpica.h> 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 387c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 397c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h> 407c478bd9Sstevel@tonic-gate #include <sys/pci.h> 417c478bd9Sstevel@tonic-gate #include <sys/debug.h> 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #ifdef __cplusplus 447c478bd9Sstevel@tonic-gate extern "C" { 457c478bd9Sstevel@tonic-gate #endif 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate /* private data used in psm_common */ 497c478bd9Sstevel@tonic-gate typedef struct acpi_prs_private { 507c478bd9Sstevel@tonic-gate uchar_t prs_irqflags; 517c478bd9Sstevel@tonic-gate uchar_t prs_type; 527c478bd9Sstevel@tonic-gate } acpi_prs_private_t; 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate typedef struct acpi_psm_lnk { 567c478bd9Sstevel@tonic-gate ACPI_HANDLE lnkobj; 577c478bd9Sstevel@tonic-gate acpi_prs_private_t acpi_prs_prv; 587c478bd9Sstevel@tonic-gate uchar_t device_status; 597c478bd9Sstevel@tonic-gate } acpi_psm_lnk_t; 607c478bd9Sstevel@tonic-gate 61843e1988Sjohnlev typedef void (*intr_exit_fn_t)(int prev_ipl, int irq); 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate /* 647c478bd9Sstevel@tonic-gate * status definition for device_status (as returned by _STA) 657c478bd9Sstevel@tonic-gate */ 667c478bd9Sstevel@tonic-gate #define STA_PRESENT 0x1 677c478bd9Sstevel@tonic-gate #define STA_ENABLE 0x2 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate /* 717c478bd9Sstevel@tonic-gate * irq_cache_t: Entry for irq cache to map pci bus/dev/ipin or ACPI object 727c478bd9Sstevel@tonic-gate * referencing an interrupt link device the configured irq for the device. 737c478bd9Sstevel@tonic-gate * It is assumed that the acpi object that references the link device is 747c478bd9Sstevel@tonic-gate * the same for all devices that reference the same link device. 757c478bd9Sstevel@tonic-gate */ 767c478bd9Sstevel@tonic-gate typedef struct irq_cache { 777c478bd9Sstevel@tonic-gate uchar_t bus, dev; 787c478bd9Sstevel@tonic-gate uchar_t ipin; 797c478bd9Sstevel@tonic-gate uchar_t irq; 807c478bd9Sstevel@tonic-gate iflag_t flags; 817c478bd9Sstevel@tonic-gate ACPI_HANDLE lnkobj; 827c478bd9Sstevel@tonic-gate } irq_cache_t; 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate typedef struct acpi_irqlist { 867c478bd9Sstevel@tonic-gate acpi_prs_private_t acpi_prs_prv; 877c478bd9Sstevel@tonic-gate iflag_t intr_flags; 887c478bd9Sstevel@tonic-gate uint32_t *irqs; 897c478bd9Sstevel@tonic-gate int num_irqs; 907c478bd9Sstevel@tonic-gate struct acpi_irqlist *next; 917c478bd9Sstevel@tonic-gate } acpi_irqlist_t; 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate #define MAX_ISA_IRQ 15 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #define ELCR_PORT1 0x4D0 977c478bd9Sstevel@tonic-gate #define ELCR_PORT2 0x4D1 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate #define ELCR_LEVEL(elcrval, irq) (elcrval & (0x1 << irq)) 1007c478bd9Sstevel@tonic-gate #define ELCR_EDGE(elcrval, irq) ((elcrval & (0x1 << irq)) == 0) 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate #define ACPI_PSM_SUCCESS 0 1047c478bd9Sstevel@tonic-gate #define ACPI_PSM_FAILURE -1 1057c478bd9Sstevel@tonic-gate #define ACPI_PSM_PARTIAL -2 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* verbose flags definitions */ 1087c478bd9Sstevel@tonic-gate #define PSM_VERBOSE_IRQ_FLAG 0x00000001 1097c478bd9Sstevel@tonic-gate #define PSM_VERBOSE_POWEROFF_FLAG 0x00000002 1107c478bd9Sstevel@tonic-gate #define PSM_VERBOSE_POWEROFF_PAUSE_FLAG 0x00000004 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate extern int acpi_psm_init(char *module_name, int verbose_flags); 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate extern void build_reserved_irqlist(uchar_t *reserved_irqs_table); 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate extern int acpi_translate_pci_irq(dev_info_t *dip, int ipin, int *pci_irqp, 1177c478bd9Sstevel@tonic-gate iflag_t *intr_flagp, acpi_psm_lnk_t *acpipsmlnkp); 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate extern int acpi_set_irq_resource(acpi_psm_lnk_t *acpipsmlnkp, int irq); 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate extern int acpi_get_current_irq_resource(acpi_psm_lnk_t *acpipsmlnkp, 1227c478bd9Sstevel@tonic-gate int *pci_irqp, iflag_t *intr_flagp); 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate extern int acpi_irqlist_find_irq(acpi_irqlist_t *irqlistp, int irq, 1257c478bd9Sstevel@tonic-gate iflag_t *intr_flagp); 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate extern void acpi_free_irqlist(acpi_irqlist_t *irqlistp); 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate extern int acpi_get_possible_irq_resources(acpi_psm_lnk_t *acpipsmlnkp, 1307c478bd9Sstevel@tonic-gate acpi_irqlist_t **irqlistp); 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate extern void acpi_new_irq_cache_ent(int bus, int dev, int ipin, int pci_irq, 1337c478bd9Sstevel@tonic-gate iflag_t *intr_flagp, acpi_psm_lnk_t *acpipsmlnkp); 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate extern int acpi_get_irq_cache_ent(uchar_t bus, uchar_t dev, int ipin, 1367c478bd9Sstevel@tonic-gate int *pci_irqp, iflag_t *intr_flagp); 1377c478bd9Sstevel@tonic-gate 138*2df1fe9cSrandyf extern void acpi_restore_link_devices(void); 139*2df1fe9cSrandyf 1407c478bd9Sstevel@tonic-gate extern int acpi_poweroff(void); 1417c478bd9Sstevel@tonic-gate 142450d6964Smyers extern void psm_set_elcr(int vecno, int val); 143450d6964Smyers extern int psm_get_elcr(int vecno); 144843e1988Sjohnlev extern intr_exit_fn_t psm_intr_exit_fn(void); 145450d6964Smyers 1467c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1477c478bd9Sstevel@tonic-gate } 1487c478bd9Sstevel@tonic-gate #endif 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate #endif /* _SYS_PSM_COMMON_H */ 151