11772Sjl139090 /* 21772Sjl139090 * CDDL HEADER START 31772Sjl139090 * 41772Sjl139090 * The contents of this file are subject to the terms of the 51772Sjl139090 * Common Development and Distribution License (the "License"). 61772Sjl139090 * You may not use this file except in compliance with the License. 71772Sjl139090 * 81772Sjl139090 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 91772Sjl139090 * or http://www.opensolaris.org/os/licensing. 101772Sjl139090 * See the License for the specific language governing permissions 111772Sjl139090 * and limitations under the License. 121772Sjl139090 * 131772Sjl139090 * When distributing Covered Code, include this CDDL HEADER in each 141772Sjl139090 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 151772Sjl139090 * If applicable, add the following below this CDDL HEADER, with the 161772Sjl139090 * fields enclosed by brackets "[]" replaced with your own identifying 171772Sjl139090 * information: Portions Copyright [yyyy] [name of copyright owner] 181772Sjl139090 * 191772Sjl139090 * CDDL HEADER END 201772Sjl139090 */ 211772Sjl139090 /* 22*6587Sjfrank * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 231772Sjl139090 * Use is subject to license terms. 241772Sjl139090 */ 251772Sjl139090 261772Sjl139090 #ifndef _SYS_PCMU_IB_H 271772Sjl139090 #define _SYS_PCMU_IB_H 281772Sjl139090 291772Sjl139090 #pragma ident "%Z%%M% %I% %E% SMI" 301772Sjl139090 311772Sjl139090 #ifdef __cplusplus 321772Sjl139090 extern "C" { 331772Sjl139090 #endif 341772Sjl139090 351772Sjl139090 #include <sys/ddi_subrdefs.h> 361772Sjl139090 371772Sjl139090 typedef uint8_t pcmu_ib_ino_t; 381772Sjl139090 typedef uint16_t pcmu_ib_mondo_t; 391772Sjl139090 401772Sjl139090 /* 411772Sjl139090 * The following structure represents an interrupt entry for an INO. 421772Sjl139090 */ 431772Sjl139090 typedef struct ih { 441772Sjl139090 dev_info_t *ih_dip; /* devinfo structure */ 451772Sjl139090 uint32_t ih_inum; /* interrupt number for this device */ 461772Sjl139090 uint_t ih_intr_state; /* Only used for fixed interrupts */ 471772Sjl139090 uint_t (*ih_handler)(); /* interrupt handler */ 481772Sjl139090 caddr_t ih_handler_arg1; /* interrupt handler argument #1 */ 491772Sjl139090 caddr_t ih_handler_arg2; /* interrupt handler argument #2 */ 501772Sjl139090 ddi_acc_handle_t ih_config_handle; /* config space reg map handle */ 511772Sjl139090 struct ih *ih_next; /* next entry in list */ 521772Sjl139090 } ih_t; 531772Sjl139090 541772Sjl139090 /* 551772Sjl139090 * ino structure : one per CMU-CH ino with interrupt registered 561772Sjl139090 */ 571772Sjl139090 typedef struct pcmu_ib_ino_info { 581772Sjl139090 struct pcmu_ib_ino_info *pino_next; 591772Sjl139090 pcmu_ib_ino_t pino_ino; /* INO number - 8 bit */ 601772Sjl139090 uint8_t pino_slot_no; /* PCI slot number 0-8 */ 611772Sjl139090 uint16_t pino_ih_size; /* size of the pci intrspec list */ 621772Sjl139090 ih_t *pino_ih_head; /* intr spec (part of ppd) list head */ 631772Sjl139090 ih_t *pino_ih_tail; /* intr spec (part of ppd) list tail */ 641772Sjl139090 ih_t *pino_ih_start; /* starting point in intr spec list */ 651772Sjl139090 pcmu_ib_t *pino_ib_p; /* link back to interrupt block state */ 661772Sjl139090 volatile uint64_t *pino_clr_reg; /* ino interrupt clear register */ 671772Sjl139090 volatile uint64_t *pino_map_reg; /* ino interrupt mapping register */ 681772Sjl139090 uint64_t pino_map_reg_save; /* = *pino_map_reg if saved */ 691772Sjl139090 uint32_t pino_pil; /* PIL for this ino */ 701772Sjl139090 volatile uint_t pino_unclaimed; /* number of unclaimed interrupts */ 711772Sjl139090 clock_t pino_spurintr_begin; /* begin time of spurious intr series */ 721772Sjl139090 int pino_established; /* ino has been associated with a cpu */ 731772Sjl139090 uint32_t pino_cpuid; /* cpu that ino is targeting */ 741772Sjl139090 int32_t pino_intr_weight; /* intr weight of devices sharing ino */ 751772Sjl139090 } pcmu_ib_ino_info_t; 761772Sjl139090 771772Sjl139090 /* 781772Sjl139090 * interrupt block soft state structure: 791772Sjl139090 */ 801772Sjl139090 struct pcmu_ib { 811772Sjl139090 pcmu_t *pib_pcmu_p; /* link back to pci soft state */ 821772Sjl139090 pcmu_ign_t pib_ign; /* interrupt group # */ 831772Sjl139090 uintptr_t pib_obio_intr_map_regs; /* onboard intr map register */ 841772Sjl139090 uintptr_t pib_obio_clear_intr_regs; /* onboard intr clear reg */ 851772Sjl139090 volatile uint64_t *pib_upa_imr[2]; /* UPA expansion intr map register */ 861772Sjl139090 uint64_t pib_upa_imr_state[2]; /* UPA intr map state */ /* RAGS */ 871772Sjl139090 volatile uint64_t *pib_intr_retry_timer_reg; /* intr retry register */ 881772Sjl139090 volatile uint64_t *pib_obio_intr_state_diag_reg; /* onboard intr st. */ 891772Sjl139090 uint_t pib_max_ino; /* largest supported INO */ 901772Sjl139090 pcmu_ib_ino_info_t *pib_ino_lst; /* ino link list */ 911772Sjl139090 kmutex_t pib_ino_lst_mutex; /* mutex for ino link list */ 921772Sjl139090 kmutex_t pib_intr_lock; /* lock for internal intr */ 931772Sjl139090 }; 941772Sjl139090 951772Sjl139090 #define PCMU_MAX_INO 0x3f 961772Sjl139090 #define PCMU_INO_BITS 6 /* INO#s are 6 bits long */ 971772Sjl139090 981772Sjl139090 /* 991772Sjl139090 * Only used for fixed or legacy interrupts 1001772Sjl139090 */ 1011772Sjl139090 #define PCMU_INTR_STATE_DISABLE 0 /* disabled */ 1021772Sjl139090 #define PCMU_INTR_STATE_ENABLE 1 /* enabled */ 1031772Sjl139090 1041772Sjl139090 #define PCMU_IB_INTR_WAIT 1 /* wait for inter completion */ 1051772Sjl139090 #define PCMU_IB_INTR_NOWAIT 0 /* handling intr, no wait */ 1061772Sjl139090 1071772Sjl139090 #define PCMU_IB2CB(pib_p) ((pib_p)->pib_pcmu_p->pcmu_cb_p) 1081772Sjl139090 1091772Sjl139090 #define PCMU_IB_MONDO_TO_INO(mondo) ((pcmu_ib_ino_t)((mondo) & 0x3f)) 1101772Sjl139090 #define PCMU_IB_INO_INTR_ON(reg_p) *(reg_p) |= PCMU_INTR_MAP_REG_VALID 1111772Sjl139090 #define PCMU_IB_INO_INTR_OFF(reg_p) *(reg_p) &= ~PCMU_INTR_MAP_REG_VALID 1121772Sjl139090 #define PCMU_IB_INO_INTR_STATE_REG(pib_p, ino) \ 1131772Sjl139090 (pib_p->pib_obio_intr_state_diag_reg) 1141772Sjl139090 1151772Sjl139090 #define PCMU_IB_INO_INTR_PENDING(reg_p, ino) \ 1161772Sjl139090 (((*(reg_p) >> (((ino) & 0x1f) << 1)) & \ 1171772Sjl139090 PCMU_CLEAR_INTR_REG_MASK) == PCMU_CLEAR_INTR_REG_PENDING) 1181772Sjl139090 1191772Sjl139090 #define PCMU_IB_INO_INTR_CLEAR(reg_p) *(reg_p) = PCMU_CLEAR_INTR_REG_IDLE 1201772Sjl139090 #define PCMU_IB_INO_INTR_PEND(reg_p) *(reg_p) = PCMU_CLEAR_INTR_REG_PENDING 1211772Sjl139090 #define PCMU_IB_INO_INTR_ISON(imr) ((imr) >> 31) 1221772Sjl139090 1231772Sjl139090 #define PCMU_IB_IMR2MONDO(imr) ((imr) & \ 1241772Sjl139090 (PCMU_INTR_MAP_REG_IGN | PCMU_INTR_MAP_REG_INO)) 1251772Sjl139090 1261772Sjl139090 #define PCMU_IB_IS_OBIO_INO(ino) (ino & 0x20) 1271772Sjl139090 1281772Sjl139090 #define PCMU_IB_IGN_TO_MONDO(ign, ino) (((ign) << PCMU_INO_BITS) | (ino)) 1291772Sjl139090 #define PCMU_IB_INO_TO_MONDO(pib_p, ino) \ 1301772Sjl139090 PCMU_IB_IGN_TO_MONDO((pib_p)->pib_ign, ino) 1311772Sjl139090 1321772Sjl139090 1331772Sjl139090 extern int pcmu_pil[]; 1341772Sjl139090 1351772Sjl139090 /* 1361772Sjl139090 * Prototypes 1371772Sjl139090 */ 1381772Sjl139090 extern void pcmu_ib_create(pcmu_t *pcmu_p); 1391772Sjl139090 extern void pcmu_ib_destroy(pcmu_t *pcmu_p); 1401772Sjl139090 extern void pcmu_ib_configure(pcmu_ib_t *pib_p); 1411772Sjl139090 extern uint64_t ib_get_map_reg(pcmu_ib_mondo_t mondo, uint32_t cpu_id); 1421772Sjl139090 extern void pcmu_ib_intr_enable(pcmu_t *pcmu_p, pcmu_ib_ino_t ino); 1431772Sjl139090 extern void pcmu_ib_intr_disable(pcmu_ib_t *pib_p, pcmu_ib_ino_t ino, int wait); 1441772Sjl139090 extern void pcmu_ib_nintr_clear(pcmu_ib_t *pib_p, pcmu_ib_ino_t ino); 1451772Sjl139090 extern void pcmu_ib_suspend(pcmu_ib_t *pib_p); 1461772Sjl139090 extern void pcmu_ib_resume(pcmu_ib_t *pib_p); 1471772Sjl139090 extern pcmu_ib_ino_info_t *pcmu_ib_locate_ino(pcmu_ib_t *pib_p, 1481772Sjl139090 pcmu_ib_ino_t ino_num); 1491772Sjl139090 extern pcmu_ib_ino_info_t *pcmu_ib_new_ino(pcmu_ib_t *pib_p, 1501772Sjl139090 pcmu_ib_ino_t ino_num, ih_t *ih_p); 1511772Sjl139090 extern void pcmu_ib_delete_ino(pcmu_ib_t *pib_p, pcmu_ib_ino_info_t *ino_p); 1521772Sjl139090 extern void pcmu_ib_free_ino_all(pcmu_ib_t *pib_p); 1531772Sjl139090 extern int pcmu_ib_update_intr_state(pcmu_t *pcmu_p, dev_info_t *rdip, 1541772Sjl139090 ddi_intr_handle_impl_t *hdlp, uint_t new_intr_state); 1551772Sjl139090 extern void pcmu_ib_ino_add_intr(pcmu_t *pcmu_p, 1561772Sjl139090 pcmu_ib_ino_info_t *ino_p, ih_t *ih_p); 157*6587Sjfrank extern int pcmu_ib_ino_rem_intr(pcmu_t *pcmu_p, 1581772Sjl139090 pcmu_ib_ino_info_t *ino_p, ih_t *ih_p); 1591772Sjl139090 extern ih_t *pcmu_ib_ino_locate_intr(pcmu_ib_ino_info_t *ino_p, 1601772Sjl139090 dev_info_t *dip, uint32_t inum); 1611772Sjl139090 extern ih_t *pcmu_ib_alloc_ih(dev_info_t *dip, uint32_t inum, 1621772Sjl139090 uint_t (*int_handler)(caddr_t int_handler_arg1, caddr_t int_handler_arg2), 1631772Sjl139090 caddr_t int_handler_arg1, caddr_t int_handler_arg2); 1641772Sjl139090 extern void pcmu_ib_intr_dist_nintr(pcmu_ib_t *pib_p, pcmu_ib_ino_t ino, 1651772Sjl139090 volatile uint64_t *imr_p); 1661772Sjl139090 extern void pcmu_ib_intr_dist_all(void *arg, 1671772Sjl139090 int32_t max_weight, int32_t weight); 1681772Sjl139090 1691772Sjl139090 #ifdef __cplusplus 1701772Sjl139090 } 1711772Sjl139090 #endif 1721772Sjl139090 1731772Sjl139090 #endif /* _SYS_PCMU_IB_H */ 174