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 5dcd3dacaSszhou * Common Development and Distribution License (the "License"). 6dcd3dacaSszhou * 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 /* 22*78323854SJudy Chen * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* 277c478bd9Sstevel@tonic-gate * ISA bus nexus driver 287c478bd9Sstevel@tonic-gate */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include <sys/types.h> 317c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h> 327c478bd9Sstevel@tonic-gate #include <sys/conf.h> 337c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 347c478bd9Sstevel@tonic-gate #include <sys/autoconf.h> 357c478bd9Sstevel@tonic-gate #include <sys/errno.h> 367c478bd9Sstevel@tonic-gate #include <sys/debug.h> 377c478bd9Sstevel@tonic-gate #include <sys/kmem.h> 38dffe9ac5Sml40262 #include <sys/psm.h> 397c478bd9Sstevel@tonic-gate #include <sys/ddidmareq.h> 407c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h> 417c478bd9Sstevel@tonic-gate #include <sys/dma_engine.h> 427c478bd9Sstevel@tonic-gate #include <sys/ddi.h> 437c478bd9Sstevel@tonic-gate #include <sys/sunddi.h> 447c478bd9Sstevel@tonic-gate #include <sys/sunndi.h> 457c478bd9Sstevel@tonic-gate #include <sys/acpi/acpi_enum.h> 46*78323854SJudy Chen #include <sys/mach_intr.h> 47*78323854SJudy Chen #include <sys/pci.h> 48*78323854SJudy Chen #include <sys/note.h> 49843e1988Sjohnlev #if defined(__xpv) 50843e1988Sjohnlev #include <sys/hypervisor.h> 51843e1988Sjohnlev #include <sys/evtchn_impl.h> 52843e1988Sjohnlev #endif 53843e1988Sjohnlev 54*78323854SJudy Chen extern int pseudo_isa; 557c478bd9Sstevel@tonic-gate extern int isa_resource_setup(void); 56*78323854SJudy Chen extern int (*psm_intr_ops)(dev_info_t *, ddi_intr_handle_impl_t *, 57*78323854SJudy Chen psm_intr_op_t, int *); 58*78323854SJudy Chen extern void pci_remove_isa_resources(int, uint32_t, uint32_t); 597c478bd9Sstevel@tonic-gate static char USED_RESOURCES[] = "used-resources"; 607c478bd9Sstevel@tonic-gate static void isa_alloc_nodes(dev_info_t *); 61dffe9ac5Sml40262 static void enumerate_BIOS_serial(dev_info_t *); 62*78323854SJudy Chen static void isa_postattach(dev_info_t *); 63dffe9ac5Sml40262 64*78323854SJudy Chen /* 65*78323854SJudy Chen * The following typedef is used to represent an entry in the "ranges" 66*78323854SJudy Chen * property of a pci-isa bridge device node. 67*78323854SJudy Chen */ 68*78323854SJudy Chen typedef struct { 69*78323854SJudy Chen uint32_t child_high; 70*78323854SJudy Chen uint32_t child_low; 71*78323854SJudy Chen uint32_t parent_high; 72*78323854SJudy Chen uint32_t parent_mid; 73*78323854SJudy Chen uint32_t parent_low; 74*78323854SJudy Chen uint32_t size; 75*78323854SJudy Chen } pib_ranges_t; 76*78323854SJudy Chen 77*78323854SJudy Chen typedef struct { 78*78323854SJudy Chen uint32_t base; 79*78323854SJudy Chen uint32_t len; 80*78323854SJudy Chen } used_ranges_t; 81*78323854SJudy Chen 82*78323854SJudy Chen #define USED_CELL_SIZE 2 /* 1 byte addr, 1 byte size */ 83*78323854SJudy Chen #define ISA_ADDR_IO 1 /* IO address space */ 84*78323854SJudy Chen #define ISA_ADDR_MEM 0 /* memory adress space */ 85dffe9ac5Sml40262 #define BIOS_DATA_AREA 0x400 867c478bd9Sstevel@tonic-gate /* 877c478bd9Sstevel@tonic-gate * #define ISA_DEBUG 1 887c478bd9Sstevel@tonic-gate */ 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate /* 917c478bd9Sstevel@tonic-gate * Local data 927c478bd9Sstevel@tonic-gate */ 937c478bd9Sstevel@tonic-gate static ddi_dma_lim_t ISA_dma_limits = { 947c478bd9Sstevel@tonic-gate 0, /* address low */ 957c478bd9Sstevel@tonic-gate 0x00ffffff, /* address high */ 967c478bd9Sstevel@tonic-gate 0, /* counter max */ 977c478bd9Sstevel@tonic-gate 1, /* burstsize */ 987c478bd9Sstevel@tonic-gate DMA_UNIT_8, /* minimum xfer */ 997c478bd9Sstevel@tonic-gate 0, /* dma speed */ 1007c478bd9Sstevel@tonic-gate (uint_t)DMALIM_VER0, /* version */ 1017c478bd9Sstevel@tonic-gate 0x0000ffff, /* address register */ 1027c478bd9Sstevel@tonic-gate 0x0000ffff, /* counter register */ 1037c478bd9Sstevel@tonic-gate 1, /* sector size */ 1047c478bd9Sstevel@tonic-gate 0x00000001, /* scatter/gather list length */ 1057c478bd9Sstevel@tonic-gate (uint_t)0xffffffff /* request size */ 1067c478bd9Sstevel@tonic-gate }; 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate static ddi_dma_attr_t ISA_dma_attr = { 1097c478bd9Sstevel@tonic-gate DMA_ATTR_V0, 1107c478bd9Sstevel@tonic-gate (unsigned long long)0, 1117c478bd9Sstevel@tonic-gate (unsigned long long)0x00ffffff, 1127c478bd9Sstevel@tonic-gate 0x0000ffff, 1137c478bd9Sstevel@tonic-gate 1, 1147c478bd9Sstevel@tonic-gate 1, 1157c478bd9Sstevel@tonic-gate 1, 1167c478bd9Sstevel@tonic-gate (unsigned long long)0xffffffff, 1177c478bd9Sstevel@tonic-gate (unsigned long long)0x0000ffff, 1187c478bd9Sstevel@tonic-gate 1, 1197c478bd9Sstevel@tonic-gate 1, 1207c478bd9Sstevel@tonic-gate 0 1217c478bd9Sstevel@tonic-gate }; 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * Config information 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate static int 129*78323854SJudy Chen isa_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, 130*78323854SJudy Chen off_t offset, off_t len, caddr_t *vaddrp); 131*78323854SJudy Chen 132*78323854SJudy Chen static int 1337c478bd9Sstevel@tonic-gate isa_dma_allochdl(dev_info_t *, dev_info_t *, ddi_dma_attr_t *, 1347c478bd9Sstevel@tonic-gate int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *); 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate static int 1377c478bd9Sstevel@tonic-gate isa_dma_mctl(dev_info_t *, dev_info_t *, ddi_dma_handle_t, enum ddi_dma_ctlops, 1387c478bd9Sstevel@tonic-gate off_t *, size_t *, caddr_t *, uint_t); 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate static int 1417c478bd9Sstevel@tonic-gate isa_ctlops(dev_info_t *, dev_info_t *, ddi_ctl_enum_t, void *, void *); 1427c478bd9Sstevel@tonic-gate 143*78323854SJudy Chen static int 144*78323854SJudy Chen isa_intr_ops(dev_info_t *pdip, dev_info_t *rdip, ddi_intr_op_t intr_op, 145*78323854SJudy Chen ddi_intr_handle_impl_t *hdlp, void *result); 146*78323854SJudy Chen 1477c478bd9Sstevel@tonic-gate struct bus_ops isa_bus_ops = { 1487c478bd9Sstevel@tonic-gate BUSO_REV, 149*78323854SJudy Chen isa_bus_map, 1507c478bd9Sstevel@tonic-gate NULL, 1517c478bd9Sstevel@tonic-gate NULL, 1527c478bd9Sstevel@tonic-gate NULL, 1537c478bd9Sstevel@tonic-gate i_ddi_map_fault, 1547c478bd9Sstevel@tonic-gate ddi_dma_map, 1557c478bd9Sstevel@tonic-gate isa_dma_allochdl, 1567c478bd9Sstevel@tonic-gate ddi_dma_freehdl, 1577c478bd9Sstevel@tonic-gate ddi_dma_bindhdl, 1587c478bd9Sstevel@tonic-gate ddi_dma_unbindhdl, 1597c478bd9Sstevel@tonic-gate ddi_dma_flush, 1607c478bd9Sstevel@tonic-gate ddi_dma_win, 1617c478bd9Sstevel@tonic-gate isa_dma_mctl, 1627c478bd9Sstevel@tonic-gate isa_ctlops, 1637c478bd9Sstevel@tonic-gate ddi_bus_prop_op, 1647c478bd9Sstevel@tonic-gate NULL, /* (*bus_get_eventcookie)(); */ 1657c478bd9Sstevel@tonic-gate NULL, /* (*bus_add_eventcall)(); */ 1667c478bd9Sstevel@tonic-gate NULL, /* (*bus_remove_eventcall)(); */ 1677c478bd9Sstevel@tonic-gate NULL, /* (*bus_post_event)(); */ 1687c478bd9Sstevel@tonic-gate NULL, /* (*bus_intr_ctl)(); */ 1697c478bd9Sstevel@tonic-gate NULL, /* (*bus_config)(); */ 1707c478bd9Sstevel@tonic-gate NULL, /* (*bus_unconfig)(); */ 1717c478bd9Sstevel@tonic-gate NULL, /* (*bus_fm_init)(); */ 1727c478bd9Sstevel@tonic-gate NULL, /* (*bus_fm_fini)(); */ 1737c478bd9Sstevel@tonic-gate NULL, /* (*bus_fm_access_enter)(); */ 1747c478bd9Sstevel@tonic-gate NULL, /* (*bus_fm_access_exit)(); */ 1757c478bd9Sstevel@tonic-gate NULL, /* (*bus_power)(); */ 176*78323854SJudy Chen isa_intr_ops /* (*bus_intr_op)(); */ 1777c478bd9Sstevel@tonic-gate }; 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate 1807c478bd9Sstevel@tonic-gate static int isa_attach(dev_info_t *devi, ddi_attach_cmd_t cmd); 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate /* 1837c478bd9Sstevel@tonic-gate * Internal isa ctlops support routines 1847c478bd9Sstevel@tonic-gate */ 1857c478bd9Sstevel@tonic-gate static int isa_initchild(dev_info_t *child); 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate struct dev_ops isa_ops = { 1887c478bd9Sstevel@tonic-gate DEVO_REV, /* devo_rev, */ 1897c478bd9Sstevel@tonic-gate 0, /* refcnt */ 1907c478bd9Sstevel@tonic-gate ddi_no_info, /* info */ 1917c478bd9Sstevel@tonic-gate nulldev, /* identify */ 1927c478bd9Sstevel@tonic-gate nulldev, /* probe */ 1937c478bd9Sstevel@tonic-gate isa_attach, /* attach */ 194*78323854SJudy Chen nulldev, /* detach */ 1957c478bd9Sstevel@tonic-gate nodev, /* reset */ 1967c478bd9Sstevel@tonic-gate (struct cb_ops *)0, /* driver operations */ 19719397407SSherry Moore &isa_bus_ops, /* bus operations */ 19819397407SSherry Moore NULL, /* power */ 19919397407SSherry Moore ddi_quiesce_not_needed, /* quiesce */ 2007c478bd9Sstevel@tonic-gate }; 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate /* 2037c478bd9Sstevel@tonic-gate * Module linkage information for the kernel. 2047c478bd9Sstevel@tonic-gate */ 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate static struct modldrv modldrv = { 2077c478bd9Sstevel@tonic-gate &mod_driverops, /* Type of module. This is ISA bus driver */ 208613b2871SRichard Bean "isa nexus driver for 'ISA'", 2097c478bd9Sstevel@tonic-gate &isa_ops, /* driver ops */ 2107c478bd9Sstevel@tonic-gate }; 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = { 2137c478bd9Sstevel@tonic-gate MODREV_1, 2147c478bd9Sstevel@tonic-gate &modldrv, 2157c478bd9Sstevel@tonic-gate NULL 2167c478bd9Sstevel@tonic-gate }; 2177c478bd9Sstevel@tonic-gate 2187c478bd9Sstevel@tonic-gate int 2197c478bd9Sstevel@tonic-gate _init(void) 2207c478bd9Sstevel@tonic-gate { 2217c478bd9Sstevel@tonic-gate return (mod_install(&modlinkage)); 2227c478bd9Sstevel@tonic-gate } 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate int 2257c478bd9Sstevel@tonic-gate _fini(void) 2267c478bd9Sstevel@tonic-gate { 2277c478bd9Sstevel@tonic-gate return (mod_remove(&modlinkage)); 2287c478bd9Sstevel@tonic-gate } 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate int 2317c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop) 2327c478bd9Sstevel@tonic-gate { 2337c478bd9Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop)); 2347c478bd9Sstevel@tonic-gate } 2357c478bd9Sstevel@tonic-gate 2367c478bd9Sstevel@tonic-gate static int 2377c478bd9Sstevel@tonic-gate isa_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) 2387c478bd9Sstevel@tonic-gate { 2397c478bd9Sstevel@tonic-gate int rval; 2407c478bd9Sstevel@tonic-gate 241843e1988Sjohnlev #if defined(__xpv) 242843e1988Sjohnlev /* 243843e1988Sjohnlev * don't allow isa to attach in domU. this can happen if someone sets 244843e1988Sjohnlev * the console wrong, etc. ISA devices assume the H/W is there and 245843e1988Sjohnlev * will cause the domU to panic. 246843e1988Sjohnlev */ 247843e1988Sjohnlev if (!DOMAIN_IS_INITDOMAIN(xen_info)) { 248843e1988Sjohnlev return (DDI_FAILURE); 249843e1988Sjohnlev } 250843e1988Sjohnlev #endif 251843e1988Sjohnlev 252*78323854SJudy Chen switch (cmd) { 253*78323854SJudy Chen case DDI_ATTACH: 254*78323854SJudy Chen break; 255*78323854SJudy Chen case DDI_RESUME: 256*78323854SJudy Chen return (DDI_SUCCESS); 257*78323854SJudy Chen default: 2587c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 259*78323854SJudy Chen } 2607c478bd9Sstevel@tonic-gate 2617c478bd9Sstevel@tonic-gate if ((rval = i_dmae_init(devi)) == DDI_SUCCESS) { 2627c478bd9Sstevel@tonic-gate ddi_report_dev(devi); 2637c478bd9Sstevel@tonic-gate /* 2647c478bd9Sstevel@tonic-gate * Enumerate children -- invoking ACPICA 2657c478bd9Sstevel@tonic-gate * This is normally in bus_config(), but we need this 2667c478bd9Sstevel@tonic-gate * to happen earlier to boot. 2677c478bd9Sstevel@tonic-gate */ 2687c478bd9Sstevel@tonic-gate isa_alloc_nodes(devi); 2697c478bd9Sstevel@tonic-gate } 270*78323854SJudy Chen 271*78323854SJudy Chen if (!pseudo_isa) 272*78323854SJudy Chen isa_postattach(devi); 273*78323854SJudy Chen 2747c478bd9Sstevel@tonic-gate return (rval); 2757c478bd9Sstevel@tonic-gate } 2767c478bd9Sstevel@tonic-gate 277*78323854SJudy Chen #define SET_RNGS(rng_p, used_p, ctyp, ptyp) do { \ 278*78323854SJudy Chen (rng_p)->child_high = (ctyp); \ 279*78323854SJudy Chen (rng_p)->child_low = (rng_p)->parent_low = (used_p)->base; \ 280*78323854SJudy Chen (rng_p)->parent_high = (ptyp); \ 281*78323854SJudy Chen (rng_p)->parent_mid = 0; \ 282*78323854SJudy Chen (rng_p)->size = (used_p)->len; \ 283*78323854SJudy Chen _NOTE(CONSTCOND) } while (0) 284*78323854SJudy Chen static uint_t 285*78323854SJudy Chen isa_used_to_ranges(int ctype, int *array, uint_t size, pib_ranges_t *ranges) 286*78323854SJudy Chen { 287*78323854SJudy Chen used_ranges_t *used_p; 288*78323854SJudy Chen pib_ranges_t *rng_p = ranges; 289*78323854SJudy Chen uint_t i, ptype; 290*78323854SJudy Chen 291*78323854SJudy Chen ptype = (ctype == ISA_ADDR_IO) ? PCI_ADDR_IO : PCI_ADDR_MEM32; 292*78323854SJudy Chen ptype |= PCI_REG_REL_M; 293*78323854SJudy Chen size /= USED_CELL_SIZE; 294*78323854SJudy Chen used_p = (used_ranges_t *)array; 295*78323854SJudy Chen SET_RNGS(rng_p, used_p, ctype, ptype); 296*78323854SJudy Chen for (i = 1, used_p++; i < size; i++, used_p++) { 297*78323854SJudy Chen /* merge ranges record if applicable */ 298*78323854SJudy Chen if (rng_p->child_low + rng_p->size == used_p->base) 299*78323854SJudy Chen rng_p->size += used_p->len; 300*78323854SJudy Chen else { 301*78323854SJudy Chen rng_p++; 302*78323854SJudy Chen SET_RNGS(rng_p, used_p, ctype, ptype); 303*78323854SJudy Chen } 304*78323854SJudy Chen } 305*78323854SJudy Chen return (rng_p - ranges + 1); 306*78323854SJudy Chen } 307*78323854SJudy Chen 308*78323854SJudy Chen void 309*78323854SJudy Chen isa_remove_res_from_pci(int type, int *array, uint_t size) 310*78323854SJudy Chen { 311*78323854SJudy Chen int i; 312*78323854SJudy Chen used_ranges_t *used_p; 313*78323854SJudy Chen 314*78323854SJudy Chen size /= USED_CELL_SIZE; 315*78323854SJudy Chen used_p = (used_ranges_t *)array; 316*78323854SJudy Chen for (i = 0; i < size; i++, used_p++) 317*78323854SJudy Chen pci_remove_isa_resources(type, used_p->base, used_p->len); 318*78323854SJudy Chen } 319*78323854SJudy Chen 320*78323854SJudy Chen static void 321*78323854SJudy Chen isa_postattach(dev_info_t *dip) 322*78323854SJudy Chen { 323*78323854SJudy Chen dev_info_t *used; 324*78323854SJudy Chen int *ioarray, *memarray, status; 325*78323854SJudy Chen uint_t nio = 0, nmem = 0, nrng = 0, n; 326*78323854SJudy Chen pib_ranges_t *ranges; 327*78323854SJudy Chen 328*78323854SJudy Chen used = ddi_find_devinfo("used-resources", -1, 0); 329*78323854SJudy Chen if (used == NULL) { 330*78323854SJudy Chen cmn_err(CE_WARN, "Failed to find used-resources <%s>\n", 331*78323854SJudy Chen ddi_get_name(dip)); 332*78323854SJudy Chen return; 333*78323854SJudy Chen } 334*78323854SJudy Chen status = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, used, 335*78323854SJudy Chen DDI_PROP_DONTPASS, "io-space", &ioarray, &nio); 336*78323854SJudy Chen if (status != DDI_PROP_SUCCESS && status != DDI_PROP_NOT_FOUND) { 337*78323854SJudy Chen cmn_err(CE_WARN, "io-space property failure for %s (%x)\n", 338*78323854SJudy Chen ddi_get_name(used), status); 339*78323854SJudy Chen return; 340*78323854SJudy Chen } 341*78323854SJudy Chen status = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, used, 342*78323854SJudy Chen DDI_PROP_DONTPASS, "device-memory", &memarray, &nmem); 343*78323854SJudy Chen if (status != DDI_PROP_SUCCESS && status != DDI_PROP_NOT_FOUND) { 344*78323854SJudy Chen cmn_err(CE_WARN, "device-memory property failure for %s (%x)\n", 345*78323854SJudy Chen ddi_get_name(used), status); 346*78323854SJudy Chen return; 347*78323854SJudy Chen } 348*78323854SJudy Chen n = (nio + nmem) / USED_CELL_SIZE; 349*78323854SJudy Chen ranges = (pib_ranges_t *)kmem_zalloc(sizeof (pib_ranges_t) * n, 350*78323854SJudy Chen KM_SLEEP); 351*78323854SJudy Chen 352*78323854SJudy Chen if (nio != 0) { 353*78323854SJudy Chen nrng = isa_used_to_ranges(ISA_ADDR_IO, ioarray, nio, ranges); 354*78323854SJudy Chen isa_remove_res_from_pci(ISA_ADDR_IO, ioarray, nio); 355*78323854SJudy Chen ddi_prop_free(ioarray); 356*78323854SJudy Chen } 357*78323854SJudy Chen if (nmem != 0) { 358*78323854SJudy Chen nrng += isa_used_to_ranges(ISA_ADDR_MEM, memarray, nmem, 359*78323854SJudy Chen ranges + nrng); 360*78323854SJudy Chen isa_remove_res_from_pci(ISA_ADDR_MEM, memarray, nmem); 361*78323854SJudy Chen ddi_prop_free(memarray); 362*78323854SJudy Chen } 363*78323854SJudy Chen 364*78323854SJudy Chen (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, dip, "ranges", 365*78323854SJudy Chen (int *)ranges, nrng * sizeof (pib_ranges_t) / sizeof (int)); 366*78323854SJudy Chen kmem_free(ranges, sizeof (pib_ranges_t) * n); 367*78323854SJudy Chen } 368*78323854SJudy Chen 369*78323854SJudy Chen /*ARGSUSED*/ 370*78323854SJudy Chen static int 371*78323854SJudy Chen isa_apply_range(dev_info_t *dip, struct regspec *isa_reg_p, 372*78323854SJudy Chen pci_regspec_t *pci_reg_p) 373*78323854SJudy Chen { 374*78323854SJudy Chen pib_ranges_t *ranges, *rng_p; 375*78323854SJudy Chen int len, i, offset, nrange; 376*78323854SJudy Chen static char out_of_range[] = 377*78323854SJudy Chen "Out of range register specification from device node <%s>"; 378*78323854SJudy Chen 379*78323854SJudy Chen if (ddi_getlongprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, 380*78323854SJudy Chen "ranges", (caddr_t)&ranges, &len) != DDI_SUCCESS) { 381*78323854SJudy Chen cmn_err(CE_WARN, "Can't get %s ranges property", 382*78323854SJudy Chen ddi_get_name(dip)); 383*78323854SJudy Chen return (DDI_ME_REGSPEC_RANGE); 384*78323854SJudy Chen } 385*78323854SJudy Chen nrange = len / sizeof (pib_ranges_t); 386*78323854SJudy Chen rng_p = ranges; 387*78323854SJudy Chen for (i = 0; i < nrange; i++, rng_p++) { 388*78323854SJudy Chen /* Check for correct space */ 389*78323854SJudy Chen if (isa_reg_p->regspec_bustype != rng_p->child_high) 390*78323854SJudy Chen continue; 391*78323854SJudy Chen 392*78323854SJudy Chen /* Detect whether request entirely fits within a range */ 393*78323854SJudy Chen if (isa_reg_p->regspec_addr < rng_p->child_low) 394*78323854SJudy Chen continue; 395*78323854SJudy Chen if ((isa_reg_p->regspec_addr + isa_reg_p->regspec_size) > 396*78323854SJudy Chen (rng_p->child_low + rng_p->size)) 397*78323854SJudy Chen continue; 398*78323854SJudy Chen 399*78323854SJudy Chen offset = isa_reg_p->regspec_addr - rng_p->child_low; 400*78323854SJudy Chen 401*78323854SJudy Chen pci_reg_p->pci_phys_hi = rng_p->parent_high; 402*78323854SJudy Chen pci_reg_p->pci_phys_mid = 0; 403*78323854SJudy Chen pci_reg_p->pci_phys_low = rng_p->parent_low + offset; 404*78323854SJudy Chen pci_reg_p->pci_size_hi = 0; 405*78323854SJudy Chen pci_reg_p->pci_size_low = isa_reg_p->regspec_size; 406*78323854SJudy Chen 407*78323854SJudy Chen break; 408*78323854SJudy Chen } 409*78323854SJudy Chen kmem_free(ranges, len); 410*78323854SJudy Chen if (i == nrange) { 411*78323854SJudy Chen cmn_err(CE_WARN, out_of_range, ddi_get_name(dip)); 412*78323854SJudy Chen return (DDI_ME_REGSPEC_RANGE); 413*78323854SJudy Chen } 414*78323854SJudy Chen 415*78323854SJudy Chen return (DDI_SUCCESS); 416*78323854SJudy Chen } 417*78323854SJudy Chen 418*78323854SJudy Chen static int 419*78323854SJudy Chen isa_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp, 420*78323854SJudy Chen off_t offset, off_t len, caddr_t *vaddrp) 421*78323854SJudy Chen { 422*78323854SJudy Chen struct regspec tmp_reg, *rp; 423*78323854SJudy Chen pci_regspec_t vreg; 424*78323854SJudy Chen ddi_map_req_t mr = *mp; /* Get private copy of request */ 425*78323854SJudy Chen int error; 426*78323854SJudy Chen 427*78323854SJudy Chen if (pseudo_isa) 428*78323854SJudy Chen return (i_ddi_bus_map(dip, rdip, mp, offset, len, vaddrp)); 429*78323854SJudy Chen 430*78323854SJudy Chen mp = &mr; 431*78323854SJudy Chen 432*78323854SJudy Chen /* 433*78323854SJudy Chen * First, if given an rnumber, convert it to a regspec... 434*78323854SJudy Chen */ 435*78323854SJudy Chen if (mp->map_type == DDI_MT_RNUMBER) { 436*78323854SJudy Chen 437*78323854SJudy Chen int rnumber = mp->map_obj.rnumber; 438*78323854SJudy Chen 439*78323854SJudy Chen rp = i_ddi_rnumber_to_regspec(rdip, rnumber); 440*78323854SJudy Chen if (rp == (struct regspec *)0) 441*78323854SJudy Chen return (DDI_ME_RNUMBER_RANGE); 442*78323854SJudy Chen 443*78323854SJudy Chen /* 444*78323854SJudy Chen * Convert the given ddi_map_req_t from rnumber to regspec... 445*78323854SJudy Chen */ 446*78323854SJudy Chen mp->map_type = DDI_MT_REGSPEC; 447*78323854SJudy Chen mp->map_obj.rp = rp; 448*78323854SJudy Chen } 449*78323854SJudy Chen 450*78323854SJudy Chen /* 451*78323854SJudy Chen * Adjust offset and length correspnding to called values... 452*78323854SJudy Chen * XXX: A non-zero length means override the one in the regspec. 453*78323854SJudy Chen * XXX: (Regardless of what's in the parent's range) 454*78323854SJudy Chen */ 455*78323854SJudy Chen 456*78323854SJudy Chen tmp_reg = *(mp->map_obj.rp); /* Preserve underlying data */ 457*78323854SJudy Chen rp = mp->map_obj.rp = &tmp_reg; /* Use tmp_reg in request */ 458*78323854SJudy Chen 459*78323854SJudy Chen rp->regspec_addr += (uint_t)offset; 460*78323854SJudy Chen if (len != 0) 461*78323854SJudy Chen rp->regspec_size = (uint_t)len; 462*78323854SJudy Chen 463*78323854SJudy Chen if ((error = isa_apply_range(dip, rp, &vreg)) != 0) 464*78323854SJudy Chen return (error); 465*78323854SJudy Chen mp->map_obj.rp = (struct regspec *)&vreg; 466*78323854SJudy Chen 467*78323854SJudy Chen /* 468*78323854SJudy Chen * Call my parents bus_map function with modified values... 469*78323854SJudy Chen */ 470*78323854SJudy Chen 471*78323854SJudy Chen return (ddi_map(dip, mp, (off_t)0, (off_t)0, vaddrp)); 472*78323854SJudy Chen } 473*78323854SJudy Chen 4747c478bd9Sstevel@tonic-gate static int 4757c478bd9Sstevel@tonic-gate isa_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *dma_attr, 4767c478bd9Sstevel@tonic-gate int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep) 4777c478bd9Sstevel@tonic-gate { 4787c478bd9Sstevel@tonic-gate ddi_dma_attr_merge(dma_attr, &ISA_dma_attr); 4797c478bd9Sstevel@tonic-gate return (ddi_dma_allochdl(dip, rdip, dma_attr, waitfp, arg, handlep)); 4807c478bd9Sstevel@tonic-gate } 4817c478bd9Sstevel@tonic-gate 4827c478bd9Sstevel@tonic-gate static int 4837c478bd9Sstevel@tonic-gate isa_dma_mctl(dev_info_t *dip, dev_info_t *rdip, 4847c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle, enum ddi_dma_ctlops request, 4857c478bd9Sstevel@tonic-gate off_t *offp, size_t *lenp, caddr_t *objp, uint_t flags) 4867c478bd9Sstevel@tonic-gate { 4877c478bd9Sstevel@tonic-gate int rval; 4887c478bd9Sstevel@tonic-gate ddi_dma_lim_t defalt; 4897c478bd9Sstevel@tonic-gate int arg = (int)(uintptr_t)objp; 4907c478bd9Sstevel@tonic-gate 4917c478bd9Sstevel@tonic-gate switch (request) { 4927c478bd9Sstevel@tonic-gate 4937c478bd9Sstevel@tonic-gate case DDI_DMA_E_PROG: 4947c478bd9Sstevel@tonic-gate return (i_dmae_prog(rdip, (struct ddi_dmae_req *)offp, 4957c478bd9Sstevel@tonic-gate (ddi_dma_cookie_t *)lenp, arg)); 4967c478bd9Sstevel@tonic-gate 4977c478bd9Sstevel@tonic-gate case DDI_DMA_E_ACQUIRE: 4987c478bd9Sstevel@tonic-gate return (i_dmae_acquire(rdip, arg, (int(*)(caddr_t))offp, 4997c478bd9Sstevel@tonic-gate (caddr_t)lenp)); 5007c478bd9Sstevel@tonic-gate 5017c478bd9Sstevel@tonic-gate case DDI_DMA_E_FREE: 5027c478bd9Sstevel@tonic-gate return (i_dmae_free(rdip, arg)); 5037c478bd9Sstevel@tonic-gate 5047c478bd9Sstevel@tonic-gate case DDI_DMA_E_STOP: 5057c478bd9Sstevel@tonic-gate i_dmae_stop(rdip, arg); 5067c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 5077c478bd9Sstevel@tonic-gate 5087c478bd9Sstevel@tonic-gate case DDI_DMA_E_ENABLE: 5097c478bd9Sstevel@tonic-gate i_dmae_enable(rdip, arg); 5107c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 5117c478bd9Sstevel@tonic-gate 5127c478bd9Sstevel@tonic-gate case DDI_DMA_E_DISABLE: 5137c478bd9Sstevel@tonic-gate i_dmae_disable(rdip, arg); 5147c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 5157c478bd9Sstevel@tonic-gate 5167c478bd9Sstevel@tonic-gate case DDI_DMA_E_GETCNT: 5177c478bd9Sstevel@tonic-gate i_dmae_get_chan_stat(rdip, arg, NULL, (int *)lenp); 5187c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 5197c478bd9Sstevel@tonic-gate 5207c478bd9Sstevel@tonic-gate case DDI_DMA_E_SWSETUP: 5217c478bd9Sstevel@tonic-gate return (i_dmae_swsetup(rdip, (struct ddi_dmae_req *)offp, 5227c478bd9Sstevel@tonic-gate (ddi_dma_cookie_t *)lenp, arg)); 5237c478bd9Sstevel@tonic-gate 5247c478bd9Sstevel@tonic-gate case DDI_DMA_E_SWSTART: 5257c478bd9Sstevel@tonic-gate i_dmae_swstart(rdip, arg); 5267c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 5277c478bd9Sstevel@tonic-gate 5287c478bd9Sstevel@tonic-gate case DDI_DMA_E_GETLIM: 5297c478bd9Sstevel@tonic-gate bcopy(&ISA_dma_limits, objp, sizeof (ddi_dma_lim_t)); 5307c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 5317c478bd9Sstevel@tonic-gate 5327c478bd9Sstevel@tonic-gate case DDI_DMA_E_GETATTR: 5337c478bd9Sstevel@tonic-gate bcopy(&ISA_dma_attr, objp, sizeof (ddi_dma_attr_t)); 5347c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 5357c478bd9Sstevel@tonic-gate 5367c478bd9Sstevel@tonic-gate case DDI_DMA_E_1STPTY: 5377c478bd9Sstevel@tonic-gate { 5387c478bd9Sstevel@tonic-gate struct ddi_dmae_req req1stpty = 5397c478bd9Sstevel@tonic-gate { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 5407c478bd9Sstevel@tonic-gate if (arg == 0) { 5417c478bd9Sstevel@tonic-gate req1stpty.der_command = DMAE_CMD_TRAN; 5427c478bd9Sstevel@tonic-gate req1stpty.der_trans = DMAE_TRANS_DMND; 5437c478bd9Sstevel@tonic-gate } else { 5447c478bd9Sstevel@tonic-gate req1stpty.der_trans = DMAE_TRANS_CSCD; 5457c478bd9Sstevel@tonic-gate } 5467c478bd9Sstevel@tonic-gate return (i_dmae_prog(rdip, &req1stpty, NULL, arg)); 5477c478bd9Sstevel@tonic-gate } 5487c478bd9Sstevel@tonic-gate 5497c478bd9Sstevel@tonic-gate case DDI_DMA_IOPB_ALLOC: /* get contiguous DMA-able memory */ 5507c478bd9Sstevel@tonic-gate case DDI_DMA_SMEM_ALLOC: 5517c478bd9Sstevel@tonic-gate if (!offp) { 5527c478bd9Sstevel@tonic-gate defalt = ISA_dma_limits; 5537c478bd9Sstevel@tonic-gate offp = (off_t *)&defalt; 5547c478bd9Sstevel@tonic-gate } 5557c478bd9Sstevel@tonic-gate /*FALLTHROUGH*/ 5567c478bd9Sstevel@tonic-gate default: 5577c478bd9Sstevel@tonic-gate rval = ddi_dma_mctl(dip, rdip, handle, request, offp, 5587c478bd9Sstevel@tonic-gate lenp, objp, flags); 5597c478bd9Sstevel@tonic-gate } 5607c478bd9Sstevel@tonic-gate return (rval); 5617c478bd9Sstevel@tonic-gate } 5627c478bd9Sstevel@tonic-gate 5637c478bd9Sstevel@tonic-gate /* 5647c478bd9Sstevel@tonic-gate * Check if driver should be treated as an old pre 2.6 driver 5657c478bd9Sstevel@tonic-gate */ 5667c478bd9Sstevel@tonic-gate static int 5677c478bd9Sstevel@tonic-gate old_driver(dev_info_t *dip) 5687c478bd9Sstevel@tonic-gate { 5697c478bd9Sstevel@tonic-gate extern int ignore_hardware_nodes; /* force flag from ddi_impl.c */ 5707c478bd9Sstevel@tonic-gate 5717c478bd9Sstevel@tonic-gate if (ndi_dev_is_persistent_node(dip)) { 5727c478bd9Sstevel@tonic-gate if (ignore_hardware_nodes) 5737c478bd9Sstevel@tonic-gate return (1); 5747c478bd9Sstevel@tonic-gate if (ddi_getprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, 5757c478bd9Sstevel@tonic-gate "ignore-hardware-nodes", -1) != -1) 5767c478bd9Sstevel@tonic-gate return (1); 5777c478bd9Sstevel@tonic-gate } 5787c478bd9Sstevel@tonic-gate return (0); 5797c478bd9Sstevel@tonic-gate } 5807c478bd9Sstevel@tonic-gate 5817c478bd9Sstevel@tonic-gate typedef struct { 5827c478bd9Sstevel@tonic-gate uint32_t phys_hi; 5837c478bd9Sstevel@tonic-gate uint32_t phys_lo; 5847c478bd9Sstevel@tonic-gate uint32_t size; 5857c478bd9Sstevel@tonic-gate } isa_regs_t; 5867c478bd9Sstevel@tonic-gate 5877c478bd9Sstevel@tonic-gate /* 5887c478bd9Sstevel@tonic-gate * Return non-zero if device in tree is a PnP isa device 5897c478bd9Sstevel@tonic-gate */ 5907c478bd9Sstevel@tonic-gate static int 5917c478bd9Sstevel@tonic-gate is_pnpisa(dev_info_t *dip) 5927c478bd9Sstevel@tonic-gate { 5937c478bd9Sstevel@tonic-gate isa_regs_t *isa_regs; 5947c478bd9Sstevel@tonic-gate int proplen, pnpisa; 5957c478bd9Sstevel@tonic-gate 5967c478bd9Sstevel@tonic-gate if (ndi_dev_is_persistent_node(dip) == 0) 5977c478bd9Sstevel@tonic-gate return (0); 5987c478bd9Sstevel@tonic-gate if (ddi_getlongprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, "reg", 5997c478bd9Sstevel@tonic-gate (caddr_t)&isa_regs, &proplen) != DDI_PROP_SUCCESS) { 6007c478bd9Sstevel@tonic-gate return (0); 6017c478bd9Sstevel@tonic-gate } 6027c478bd9Sstevel@tonic-gate pnpisa = isa_regs[0].phys_hi & 0x80000000; 6037c478bd9Sstevel@tonic-gate /* 6047c478bd9Sstevel@tonic-gate * free the memory allocated by ddi_getlongprop(). 6057c478bd9Sstevel@tonic-gate */ 6067c478bd9Sstevel@tonic-gate kmem_free(isa_regs, proplen); 6077c478bd9Sstevel@tonic-gate if (pnpisa) 6087c478bd9Sstevel@tonic-gate return (1); 6097c478bd9Sstevel@tonic-gate else 6107c478bd9Sstevel@tonic-gate return (0); 6117c478bd9Sstevel@tonic-gate } 6127c478bd9Sstevel@tonic-gate 6137c478bd9Sstevel@tonic-gate /*ARGSUSED*/ 6147c478bd9Sstevel@tonic-gate static int 6157c478bd9Sstevel@tonic-gate isa_ctlops(dev_info_t *dip, dev_info_t *rdip, 6167c478bd9Sstevel@tonic-gate ddi_ctl_enum_t ctlop, void *arg, void *result) 6177c478bd9Sstevel@tonic-gate { 618*78323854SJudy Chen int rn; 619*78323854SJudy Chen struct ddi_parent_private_data *pdp; 620*78323854SJudy Chen 6217c478bd9Sstevel@tonic-gate switch (ctlop) { 6227c478bd9Sstevel@tonic-gate case DDI_CTLOPS_REPORTDEV: 6237c478bd9Sstevel@tonic-gate if (rdip == (dev_info_t *)0) 6247c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 6257c478bd9Sstevel@tonic-gate cmn_err(CE_CONT, "?ISA-device: %s%d\n", 6267c478bd9Sstevel@tonic-gate ddi_driver_name(rdip), ddi_get_instance(rdip)); 6277c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 6287c478bd9Sstevel@tonic-gate 6297c478bd9Sstevel@tonic-gate case DDI_CTLOPS_INITCHILD: 6307c478bd9Sstevel@tonic-gate /* 6317c478bd9Sstevel@tonic-gate * older drivers aren't expecting the "standard" device 6327c478bd9Sstevel@tonic-gate * node format used by the hardware nodes. these drivers 6337c478bd9Sstevel@tonic-gate * only expect their own properties set in their driver.conf 6347c478bd9Sstevel@tonic-gate * files. so they tell us not to call them with hardware 6357c478bd9Sstevel@tonic-gate * nodes by setting the property "ignore-hardware-nodes". 6367c478bd9Sstevel@tonic-gate */ 6377c478bd9Sstevel@tonic-gate if (old_driver((dev_info_t *)arg)) { 6387c478bd9Sstevel@tonic-gate return (DDI_NOT_WELL_FORMED); 6397c478bd9Sstevel@tonic-gate } 6407c478bd9Sstevel@tonic-gate 6417c478bd9Sstevel@tonic-gate return (isa_initchild((dev_info_t *)arg)); 6427c478bd9Sstevel@tonic-gate 6437c478bd9Sstevel@tonic-gate case DDI_CTLOPS_UNINITCHILD: 6447c478bd9Sstevel@tonic-gate impl_ddi_sunbus_removechild((dev_info_t *)arg); 6457c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 6467c478bd9Sstevel@tonic-gate 6477c478bd9Sstevel@tonic-gate case DDI_CTLOPS_SIDDEV: 6487c478bd9Sstevel@tonic-gate /* 6497c478bd9Sstevel@tonic-gate * All ISA devices need to do confirming probes 6507c478bd9Sstevel@tonic-gate * unless they are PnP ISA. 6517c478bd9Sstevel@tonic-gate */ 6527c478bd9Sstevel@tonic-gate if (is_pnpisa(dip)) 6537c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 6547c478bd9Sstevel@tonic-gate else 6557c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 6567c478bd9Sstevel@tonic-gate 657*78323854SJudy Chen case DDI_CTLOPS_REGSIZE: 658*78323854SJudy Chen case DDI_CTLOPS_NREGS: 659*78323854SJudy Chen if (rdip == (dev_info_t *)0) 660*78323854SJudy Chen return (DDI_FAILURE); 661*78323854SJudy Chen 662*78323854SJudy Chen if ((pdp = ddi_get_parent_data(rdip)) == NULL) 663*78323854SJudy Chen return (DDI_FAILURE); 664*78323854SJudy Chen 665*78323854SJudy Chen if (ctlop == DDI_CTLOPS_NREGS) { 666*78323854SJudy Chen *(int *)result = pdp->par_nreg; 667*78323854SJudy Chen } else { 668*78323854SJudy Chen rn = *(int *)arg; 669*78323854SJudy Chen if (rn >= pdp->par_nreg) 670*78323854SJudy Chen return (DDI_FAILURE); 671*78323854SJudy Chen *(off_t *)result = (off_t)pdp->par_reg[rn].regspec_size; 672*78323854SJudy Chen } 673*78323854SJudy Chen return (DDI_SUCCESS); 674*78323854SJudy Chen 675*78323854SJudy Chen case DDI_CTLOPS_ATTACH: 676*78323854SJudy Chen case DDI_CTLOPS_DETACH: 677*78323854SJudy Chen case DDI_CTLOPS_PEEK: 678*78323854SJudy Chen case DDI_CTLOPS_POKE: 679*78323854SJudy Chen return (DDI_FAILURE); 680*78323854SJudy Chen 6817c478bd9Sstevel@tonic-gate default: 6827c478bd9Sstevel@tonic-gate return (ddi_ctlops(dip, rdip, ctlop, arg, result)); 6837c478bd9Sstevel@tonic-gate } 6847c478bd9Sstevel@tonic-gate } 6857c478bd9Sstevel@tonic-gate 686*78323854SJudy Chen static struct intrspec * 687*78323854SJudy Chen isa_get_ispec(dev_info_t *rdip, int inum) 688*78323854SJudy Chen { 689*78323854SJudy Chen struct ddi_parent_private_data *pdp = ddi_get_parent_data(rdip); 690*78323854SJudy Chen 691*78323854SJudy Chen /* Validate the interrupt number */ 692*78323854SJudy Chen if (inum >= pdp->par_nintr) 693*78323854SJudy Chen return (NULL); 694*78323854SJudy Chen 695*78323854SJudy Chen /* Get the interrupt structure pointer and return that */ 696*78323854SJudy Chen return ((struct intrspec *)&pdp->par_intr[inum]); 697*78323854SJudy Chen } 698*78323854SJudy Chen 699*78323854SJudy Chen static int 700*78323854SJudy Chen isa_intr_ops(dev_info_t *pdip, dev_info_t *rdip, ddi_intr_op_t intr_op, 701*78323854SJudy Chen ddi_intr_handle_impl_t *hdlp, void *result) 702*78323854SJudy Chen { 703*78323854SJudy Chen struct intrspec *ispec; 704*78323854SJudy Chen 705*78323854SJudy Chen if (pseudo_isa) 706*78323854SJudy Chen return (i_ddi_intr_ops(pdip, rdip, intr_op, hdlp, result)); 707*78323854SJudy Chen 708*78323854SJudy Chen 709*78323854SJudy Chen /* Process the interrupt operation */ 710*78323854SJudy Chen switch (intr_op) { 711*78323854SJudy Chen case DDI_INTROP_GETCAP: 712*78323854SJudy Chen /* First check with pcplusmp */ 713*78323854SJudy Chen if (psm_intr_ops == NULL) 714*78323854SJudy Chen return (DDI_FAILURE); 715*78323854SJudy Chen 716*78323854SJudy Chen if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_GET_CAP, result)) { 717*78323854SJudy Chen *(int *)result = 0; 718*78323854SJudy Chen return (DDI_FAILURE); 719*78323854SJudy Chen } 720*78323854SJudy Chen break; 721*78323854SJudy Chen case DDI_INTROP_SETCAP: 722*78323854SJudy Chen if (psm_intr_ops == NULL) 723*78323854SJudy Chen return (DDI_FAILURE); 724*78323854SJudy Chen 725*78323854SJudy Chen if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_SET_CAP, result)) 726*78323854SJudy Chen return (DDI_FAILURE); 727*78323854SJudy Chen break; 728*78323854SJudy Chen case DDI_INTROP_ALLOC: 729*78323854SJudy Chen if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL) 730*78323854SJudy Chen return (DDI_FAILURE); 731*78323854SJudy Chen hdlp->ih_pri = ispec->intrspec_pri; 732*78323854SJudy Chen *(int *)result = hdlp->ih_scratch1; 733*78323854SJudy Chen break; 734*78323854SJudy Chen case DDI_INTROP_FREE: 735*78323854SJudy Chen break; 736*78323854SJudy Chen case DDI_INTROP_GETPRI: 737*78323854SJudy Chen if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL) 738*78323854SJudy Chen return (DDI_FAILURE); 739*78323854SJudy Chen *(int *)result = ispec->intrspec_pri; 740*78323854SJudy Chen break; 741*78323854SJudy Chen case DDI_INTROP_SETPRI: 742*78323854SJudy Chen /* Validate the interrupt priority passed to us */ 743*78323854SJudy Chen if (*(int *)result > LOCK_LEVEL) 744*78323854SJudy Chen return (DDI_FAILURE); 745*78323854SJudy Chen 746*78323854SJudy Chen /* Ensure that PSM is all initialized and ispec is ok */ 747*78323854SJudy Chen if ((psm_intr_ops == NULL) || 748*78323854SJudy Chen ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL)) 749*78323854SJudy Chen return (DDI_FAILURE); 750*78323854SJudy Chen 751*78323854SJudy Chen /* update the ispec with the new priority */ 752*78323854SJudy Chen ispec->intrspec_pri = *(int *)result; 753*78323854SJudy Chen break; 754*78323854SJudy Chen case DDI_INTROP_ADDISR: 755*78323854SJudy Chen if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL) 756*78323854SJudy Chen return (DDI_FAILURE); 757*78323854SJudy Chen ispec->intrspec_func = hdlp->ih_cb_func; 758*78323854SJudy Chen break; 759*78323854SJudy Chen case DDI_INTROP_REMISR: 760*78323854SJudy Chen if (hdlp->ih_type != DDI_INTR_TYPE_FIXED) 761*78323854SJudy Chen return (DDI_FAILURE); 762*78323854SJudy Chen if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL) 763*78323854SJudy Chen return (DDI_FAILURE); 764*78323854SJudy Chen ispec->intrspec_func = (uint_t (*)()) 0; 765*78323854SJudy Chen break; 766*78323854SJudy Chen case DDI_INTROP_ENABLE: 767*78323854SJudy Chen if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL) 768*78323854SJudy Chen return (DDI_FAILURE); 769*78323854SJudy Chen 770*78323854SJudy Chen /* Call psmi to translate irq with the dip */ 771*78323854SJudy Chen if (psm_intr_ops == NULL) 772*78323854SJudy Chen return (DDI_FAILURE); 773*78323854SJudy Chen 774*78323854SJudy Chen ((ihdl_plat_t *)hdlp->ih_private)->ip_ispecp = ispec; 775*78323854SJudy Chen (void) (*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_XLATE_VECTOR, 776*78323854SJudy Chen (int *)&hdlp->ih_vector); 777*78323854SJudy Chen 778*78323854SJudy Chen /* Add the interrupt handler */ 779*78323854SJudy Chen if (!add_avintr((void *)hdlp, ispec->intrspec_pri, 780*78323854SJudy Chen hdlp->ih_cb_func, DEVI(rdip)->devi_name, hdlp->ih_vector, 781*78323854SJudy Chen hdlp->ih_cb_arg1, hdlp->ih_cb_arg2, NULL, rdip)) 782*78323854SJudy Chen return (DDI_FAILURE); 783*78323854SJudy Chen break; 784*78323854SJudy Chen case DDI_INTROP_DISABLE: 785*78323854SJudy Chen if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL) 786*78323854SJudy Chen return (DDI_FAILURE); 787*78323854SJudy Chen 788*78323854SJudy Chen /* Call psm_ops() to translate irq with the dip */ 789*78323854SJudy Chen if (psm_intr_ops == NULL) 790*78323854SJudy Chen return (DDI_FAILURE); 791*78323854SJudy Chen 792*78323854SJudy Chen ((ihdl_plat_t *)hdlp->ih_private)->ip_ispecp = ispec; 793*78323854SJudy Chen (void) (*psm_intr_ops)(rdip, hdlp, 794*78323854SJudy Chen PSM_INTR_OP_XLATE_VECTOR, (int *)&hdlp->ih_vector); 795*78323854SJudy Chen 796*78323854SJudy Chen /* Remove the interrupt handler */ 797*78323854SJudy Chen rem_avintr((void *)hdlp, ispec->intrspec_pri, 798*78323854SJudy Chen hdlp->ih_cb_func, hdlp->ih_vector); 799*78323854SJudy Chen break; 800*78323854SJudy Chen case DDI_INTROP_SETMASK: 801*78323854SJudy Chen if (psm_intr_ops == NULL) 802*78323854SJudy Chen return (DDI_FAILURE); 803*78323854SJudy Chen 804*78323854SJudy Chen if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_SET_MASK, NULL)) 805*78323854SJudy Chen return (DDI_FAILURE); 806*78323854SJudy Chen break; 807*78323854SJudy Chen case DDI_INTROP_CLRMASK: 808*78323854SJudy Chen if (psm_intr_ops == NULL) 809*78323854SJudy Chen return (DDI_FAILURE); 810*78323854SJudy Chen 811*78323854SJudy Chen if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_CLEAR_MASK, NULL)) 812*78323854SJudy Chen return (DDI_FAILURE); 813*78323854SJudy Chen break; 814*78323854SJudy Chen case DDI_INTROP_GETPENDING: 815*78323854SJudy Chen if (psm_intr_ops == NULL) 816*78323854SJudy Chen return (DDI_FAILURE); 817*78323854SJudy Chen 818*78323854SJudy Chen if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_GET_PENDING, 819*78323854SJudy Chen result)) { 820*78323854SJudy Chen *(int *)result = 0; 821*78323854SJudy Chen return (DDI_FAILURE); 822*78323854SJudy Chen } 823*78323854SJudy Chen break; 824*78323854SJudy Chen case DDI_INTROP_NAVAIL: 825*78323854SJudy Chen case DDI_INTROP_NINTRS: 826*78323854SJudy Chen *(int *)result = i_ddi_get_intx_nintrs(rdip); 827*78323854SJudy Chen if (*(int *)result == 0) { 828*78323854SJudy Chen return (DDI_FAILURE); 829*78323854SJudy Chen } 830*78323854SJudy Chen break; 831*78323854SJudy Chen case DDI_INTROP_SUPPORTED_TYPES: 832*78323854SJudy Chen *(int *)result = DDI_INTR_TYPE_FIXED; /* Always ... */ 833*78323854SJudy Chen break; 834*78323854SJudy Chen default: 835*78323854SJudy Chen return (DDI_FAILURE); 836*78323854SJudy Chen } 837*78323854SJudy Chen 838*78323854SJudy Chen return (DDI_SUCCESS); 839*78323854SJudy Chen } 840*78323854SJudy Chen 8417c478bd9Sstevel@tonic-gate static void 8427c478bd9Sstevel@tonic-gate isa_vendor(uint32_t id, char *vendor) 8437c478bd9Sstevel@tonic-gate { 8447c478bd9Sstevel@tonic-gate vendor[0] = '@' + ((id >> 26) & 0x1f); 8457c478bd9Sstevel@tonic-gate vendor[1] = '@' + ((id >> 21) & 0x1f); 8467c478bd9Sstevel@tonic-gate vendor[2] = '@' + ((id >> 16) & 0x1f); 8477c478bd9Sstevel@tonic-gate vendor[3] = 0; 8487c478bd9Sstevel@tonic-gate } 8497c478bd9Sstevel@tonic-gate 8507c478bd9Sstevel@tonic-gate /* 8517c478bd9Sstevel@tonic-gate * Name a child 8527c478bd9Sstevel@tonic-gate */ 8537c478bd9Sstevel@tonic-gate static int 8547c478bd9Sstevel@tonic-gate isa_name_child(dev_info_t *child, char *name, int namelen) 8557c478bd9Sstevel@tonic-gate { 8567c478bd9Sstevel@tonic-gate char vendor[8]; 8577c478bd9Sstevel@tonic-gate int device; 8587c478bd9Sstevel@tonic-gate uint32_t serial; 8597c478bd9Sstevel@tonic-gate int func; 8607c478bd9Sstevel@tonic-gate int bustype; 8617c478bd9Sstevel@tonic-gate uint32_t base; 8627c478bd9Sstevel@tonic-gate int proplen; 8637c478bd9Sstevel@tonic-gate int pnpisa = 0; 8647c478bd9Sstevel@tonic-gate isa_regs_t *isa_regs; 8657c478bd9Sstevel@tonic-gate 8667c478bd9Sstevel@tonic-gate void make_ddi_ppd(dev_info_t *, struct ddi_parent_private_data **); 8677c478bd9Sstevel@tonic-gate 8687c478bd9Sstevel@tonic-gate /* 8697c478bd9Sstevel@tonic-gate * older drivers aren't expecting the "standard" device 8707c478bd9Sstevel@tonic-gate * node format used by the hardware nodes. these drivers 8717c478bd9Sstevel@tonic-gate * only expect their own properties set in their driver.conf 8727c478bd9Sstevel@tonic-gate * files. so they tell us not to call them with hardware 8737c478bd9Sstevel@tonic-gate * nodes by setting the property "ignore-hardware-nodes". 8747c478bd9Sstevel@tonic-gate */ 8757c478bd9Sstevel@tonic-gate if (old_driver(child)) 8767c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 8777c478bd9Sstevel@tonic-gate 8787c478bd9Sstevel@tonic-gate /* 8797c478bd9Sstevel@tonic-gate * Fill in parent-private data 8807c478bd9Sstevel@tonic-gate */ 8817c478bd9Sstevel@tonic-gate if (ddi_get_parent_data(child) == NULL) { 8827c478bd9Sstevel@tonic-gate struct ddi_parent_private_data *pdptr; 8837c478bd9Sstevel@tonic-gate make_ddi_ppd(child, &pdptr); 8847c478bd9Sstevel@tonic-gate ddi_set_parent_data(child, pdptr); 8857c478bd9Sstevel@tonic-gate } 8867c478bd9Sstevel@tonic-gate 8877c478bd9Sstevel@tonic-gate if (ndi_dev_is_persistent_node(child) == 0) { 8887c478bd9Sstevel@tonic-gate /* 8897c478bd9Sstevel@tonic-gate * For .conf nodes, generate name from parent private data 8907c478bd9Sstevel@tonic-gate */ 8917c478bd9Sstevel@tonic-gate name[0] = '\0'; 8927c478bd9Sstevel@tonic-gate if (sparc_pd_getnreg(child) > 0) { 8937c478bd9Sstevel@tonic-gate (void) snprintf(name, namelen, "%x,%x", 8947c478bd9Sstevel@tonic-gate (uint_t)sparc_pd_getreg(child, 0)->regspec_bustype, 8957c478bd9Sstevel@tonic-gate (uint_t)sparc_pd_getreg(child, 0)->regspec_addr); 8967c478bd9Sstevel@tonic-gate } 8977c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 8987c478bd9Sstevel@tonic-gate } 8997c478bd9Sstevel@tonic-gate 9007c478bd9Sstevel@tonic-gate /* 9017c478bd9Sstevel@tonic-gate * For hw nodes, look up "reg" property 9027c478bd9Sstevel@tonic-gate */ 9037c478bd9Sstevel@tonic-gate if (ddi_getlongprop(DDI_DEV_T_ANY, child, DDI_PROP_DONTPASS, "reg", 9047c478bd9Sstevel@tonic-gate (caddr_t)&isa_regs, &proplen) != DDI_PROP_SUCCESS) { 9057c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 9067c478bd9Sstevel@tonic-gate } 9077c478bd9Sstevel@tonic-gate 9087c478bd9Sstevel@tonic-gate /* 9097c478bd9Sstevel@tonic-gate * extract the device identifications 9107c478bd9Sstevel@tonic-gate */ 9117c478bd9Sstevel@tonic-gate pnpisa = isa_regs[0].phys_hi & 0x80000000; 9127c478bd9Sstevel@tonic-gate if (pnpisa) { 9137c478bd9Sstevel@tonic-gate isa_vendor(isa_regs[0].phys_hi, vendor); 9147c478bd9Sstevel@tonic-gate device = isa_regs[0].phys_hi & 0xffff; 9157c478bd9Sstevel@tonic-gate serial = isa_regs[0].phys_lo; 9167c478bd9Sstevel@tonic-gate func = (isa_regs[0].size >> 24) & 0xff; 9177c478bd9Sstevel@tonic-gate if (func != 0) 9187c478bd9Sstevel@tonic-gate (void) snprintf(name, namelen, "pnp%s,%04x,%x,%x", 9197c478bd9Sstevel@tonic-gate vendor, device, serial, func); 9207c478bd9Sstevel@tonic-gate else 9217c478bd9Sstevel@tonic-gate (void) snprintf(name, namelen, "pnp%s,%04x,%x", 9227c478bd9Sstevel@tonic-gate vendor, device, serial); 9237c478bd9Sstevel@tonic-gate } else { 9247c478bd9Sstevel@tonic-gate bustype = isa_regs[0].phys_hi; 9257c478bd9Sstevel@tonic-gate base = isa_regs[0].phys_lo; 9267c478bd9Sstevel@tonic-gate (void) sprintf(name, "%x,%x", bustype, base); 9277c478bd9Sstevel@tonic-gate } 9287c478bd9Sstevel@tonic-gate 9297c478bd9Sstevel@tonic-gate /* 9307c478bd9Sstevel@tonic-gate * free the memory allocated by ddi_getlongprop(). 9317c478bd9Sstevel@tonic-gate */ 9327c478bd9Sstevel@tonic-gate kmem_free(isa_regs, proplen); 9337c478bd9Sstevel@tonic-gate 9347c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 9357c478bd9Sstevel@tonic-gate } 9367c478bd9Sstevel@tonic-gate 9377c478bd9Sstevel@tonic-gate static int 9387c478bd9Sstevel@tonic-gate isa_initchild(dev_info_t *child) 9397c478bd9Sstevel@tonic-gate { 9407c478bd9Sstevel@tonic-gate char name[80]; 9417c478bd9Sstevel@tonic-gate 9427c478bd9Sstevel@tonic-gate if (isa_name_child(child, name, 80) != DDI_SUCCESS) 9437c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 9447c478bd9Sstevel@tonic-gate ddi_set_name_addr(child, name); 9457c478bd9Sstevel@tonic-gate 9467c478bd9Sstevel@tonic-gate if (ndi_dev_is_persistent_node(child) != 0) 9477c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 9487c478bd9Sstevel@tonic-gate 9497c478bd9Sstevel@tonic-gate /* 9507c478bd9Sstevel@tonic-gate * This is a .conf node, try merge properties onto a 9517c478bd9Sstevel@tonic-gate * hw node with the same name. 9527c478bd9Sstevel@tonic-gate */ 9537c478bd9Sstevel@tonic-gate if (ndi_merge_node(child, isa_name_child) == DDI_SUCCESS) { 9547c478bd9Sstevel@tonic-gate /* 9557c478bd9Sstevel@tonic-gate * Return failure to remove node 9567c478bd9Sstevel@tonic-gate */ 9577c478bd9Sstevel@tonic-gate impl_ddi_sunbus_removechild(child); 9587c478bd9Sstevel@tonic-gate return (DDI_FAILURE); 9597c478bd9Sstevel@tonic-gate } 9607c478bd9Sstevel@tonic-gate /* 9617c478bd9Sstevel@tonic-gate * Cannot merge node, permit pseudo children 9627c478bd9Sstevel@tonic-gate */ 9637c478bd9Sstevel@tonic-gate return (DDI_SUCCESS); 9647c478bd9Sstevel@tonic-gate } 9657c478bd9Sstevel@tonic-gate 9667c478bd9Sstevel@tonic-gate /* 9677c478bd9Sstevel@tonic-gate * called when ACPI enumeration is not used 9687c478bd9Sstevel@tonic-gate */ 9697c478bd9Sstevel@tonic-gate static void 9707c478bd9Sstevel@tonic-gate add_known_used_resources(void) 9717c478bd9Sstevel@tonic-gate { 9727c478bd9Sstevel@tonic-gate /* needs to be in increasing order */ 9737c478bd9Sstevel@tonic-gate int intr[] = {0x1, 0x3, 0x4, 0x6, 0x7, 0xc}; 9747c478bd9Sstevel@tonic-gate int dma[] = {0x2}; 9757c478bd9Sstevel@tonic-gate int io[] = {0x60, 0x1, 0x64, 0x1, 0x2f8, 0x8, 0x378, 0x8, 0x3f0, 0x10, 9767c478bd9Sstevel@tonic-gate 0x778, 0x4}; 9777c478bd9Sstevel@tonic-gate dev_info_t *usedrdip; 9787c478bd9Sstevel@tonic-gate 9797c478bd9Sstevel@tonic-gate usedrdip = ddi_find_devinfo(USED_RESOURCES, -1, 0); 9807c478bd9Sstevel@tonic-gate 9817c478bd9Sstevel@tonic-gate if (usedrdip == NULL) { 9827c478bd9Sstevel@tonic-gate (void) ndi_devi_alloc_sleep(ddi_root_node(), USED_RESOURCES, 983fa9e4066Sahrens (pnode_t)DEVI_SID_NODEID, &usedrdip); 9847c478bd9Sstevel@tonic-gate } 9857c478bd9Sstevel@tonic-gate 9867c478bd9Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, usedrdip, 9877c478bd9Sstevel@tonic-gate "interrupts", (int *)intr, (int)(sizeof (intr) / sizeof (int))); 9887c478bd9Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, usedrdip, 9897c478bd9Sstevel@tonic-gate "io-space", (int *)io, (int)(sizeof (io) / sizeof (int))); 9907c478bd9Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, usedrdip, 9917c478bd9Sstevel@tonic-gate "dma-channels", (int *)dma, (int)(sizeof (dma) / sizeof (int))); 9927c478bd9Sstevel@tonic-gate (void) ndi_devi_bind_driver(usedrdip, 0); 9937c478bd9Sstevel@tonic-gate 9947c478bd9Sstevel@tonic-gate } 9957c478bd9Sstevel@tonic-gate 9967c478bd9Sstevel@tonic-gate static void 9977c478bd9Sstevel@tonic-gate isa_alloc_nodes(dev_info_t *isa_dip) 9987c478bd9Sstevel@tonic-gate { 9997c478bd9Sstevel@tonic-gate static int alloced = 0; 10007c478bd9Sstevel@tonic-gate int circ, i; 10017c478bd9Sstevel@tonic-gate dev_info_t *xdip; 10027c478bd9Sstevel@tonic-gate 10037c478bd9Sstevel@tonic-gate /* hard coded isa stuff */ 10047c478bd9Sstevel@tonic-gate struct regspec asy_regs[] = { 10057c478bd9Sstevel@tonic-gate {1, 0x3f8, 0x8}, 10067c478bd9Sstevel@tonic-gate {1, 0x2f8, 0x8} 10077c478bd9Sstevel@tonic-gate }; 10087c478bd9Sstevel@tonic-gate int asy_intrs[] = {0x4, 0x3}; 10097c478bd9Sstevel@tonic-gate 10107c478bd9Sstevel@tonic-gate struct regspec i8042_regs[] = { 10117c478bd9Sstevel@tonic-gate {1, 0x60, 0x1}, 10127c478bd9Sstevel@tonic-gate {1, 0x64, 0x1} 10137c478bd9Sstevel@tonic-gate }; 10147c478bd9Sstevel@tonic-gate int i8042_intrs[] = {0x1, 0xc}; 10157c478bd9Sstevel@tonic-gate char *acpi_prop; 10167c478bd9Sstevel@tonic-gate int acpi_enum = 1; /* ACPI is default to be on */ 10177c478bd9Sstevel@tonic-gate 10187c478bd9Sstevel@tonic-gate if (alloced) 10197c478bd9Sstevel@tonic-gate return; 10207c478bd9Sstevel@tonic-gate 10217c478bd9Sstevel@tonic-gate ndi_devi_enter(isa_dip, &circ); 10227c478bd9Sstevel@tonic-gate if (alloced) { /* just in case we are multi-threaded */ 10237c478bd9Sstevel@tonic-gate ndi_devi_exit(isa_dip, circ); 10247c478bd9Sstevel@tonic-gate return; 10257c478bd9Sstevel@tonic-gate } 10267c478bd9Sstevel@tonic-gate alloced = 1; 10277c478bd9Sstevel@tonic-gate 10287c478bd9Sstevel@tonic-gate if (ddi_prop_lookup_string(DDI_DEV_T_ANY, ddi_root_node(), 10297c478bd9Sstevel@tonic-gate DDI_PROP_DONTPASS, "acpi-enum", &acpi_prop) == DDI_PROP_SUCCESS) { 10307c478bd9Sstevel@tonic-gate acpi_enum = strcmp("off", acpi_prop); 10317c478bd9Sstevel@tonic-gate ddi_prop_free(acpi_prop); 10327c478bd9Sstevel@tonic-gate } 10337c478bd9Sstevel@tonic-gate 10347c478bd9Sstevel@tonic-gate if (acpi_enum) { 10357c478bd9Sstevel@tonic-gate if (acpi_isa_device_enum(isa_dip)) { 10367c478bd9Sstevel@tonic-gate ndi_devi_exit(isa_dip, circ); 10377c478bd9Sstevel@tonic-gate if (isa_resource_setup() != NDI_SUCCESS) { 10387c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "isa nexus: isa " 10397c478bd9Sstevel@tonic-gate "resource setup failed"); 10407c478bd9Sstevel@tonic-gate } 1041dffe9ac5Sml40262 1042dffe9ac5Sml40262 /* serial ports? */ 1043dffe9ac5Sml40262 enumerate_BIOS_serial(isa_dip); 10447c478bd9Sstevel@tonic-gate return; 10457c478bd9Sstevel@tonic-gate } 10467c478bd9Sstevel@tonic-gate cmn_err(CE_NOTE, "!Solaris did not detect ACPI BIOS"); 10477c478bd9Sstevel@tonic-gate } 10487c478bd9Sstevel@tonic-gate cmn_err(CE_NOTE, "!ACPI is off"); 10497c478bd9Sstevel@tonic-gate 10507c478bd9Sstevel@tonic-gate /* serial ports */ 10517c478bd9Sstevel@tonic-gate for (i = 0; i < 2; i++) { 1052843e1988Sjohnlev #if defined(__xpv) 1053843e1988Sjohnlev /* 1054843e1988Sjohnlev * the hypervisor may be reserving the serial ports for console 1055843e1988Sjohnlev * and/or debug use. Probe the irqs to see if they are 1056843e1988Sjohnlev * available. 1057843e1988Sjohnlev */ 1058843e1988Sjohnlev if (ec_probe_pirq(asy_intrs[i]) == 0) 1059843e1988Sjohnlev continue; /* in use */ 1060843e1988Sjohnlev #endif 10617c478bd9Sstevel@tonic-gate ndi_devi_alloc_sleep(isa_dip, "asy", 1062fa9e4066Sahrens (pnode_t)DEVI_SID_NODEID, &xdip); 10637c478bd9Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, xdip, 10647c478bd9Sstevel@tonic-gate "reg", (int *)&asy_regs[i], 3); 10657c478bd9Sstevel@tonic-gate (void) ndi_prop_update_int(DDI_DEV_T_NONE, xdip, 10667c478bd9Sstevel@tonic-gate "interrupts", asy_intrs[i]); 10677c478bd9Sstevel@tonic-gate (void) ndi_devi_bind_driver(xdip, 0); 10687c478bd9Sstevel@tonic-gate } 10697c478bd9Sstevel@tonic-gate 10707c478bd9Sstevel@tonic-gate /* i8042 node */ 10717c478bd9Sstevel@tonic-gate ndi_devi_alloc_sleep(isa_dip, "i8042", 1072fa9e4066Sahrens (pnode_t)DEVI_SID_NODEID, &xdip); 10737c478bd9Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, xdip, 10747c478bd9Sstevel@tonic-gate "reg", (int *)i8042_regs, 6); 10757c478bd9Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, xdip, 10767c478bd9Sstevel@tonic-gate "interrupts", (int *)i8042_intrs, 2); 10777c478bd9Sstevel@tonic-gate (void) ndi_prop_update_string(DDI_DEV_T_NONE, xdip, 10787c478bd9Sstevel@tonic-gate "unit-address", "1,60"); 10797c478bd9Sstevel@tonic-gate (void) ndi_devi_bind_driver(xdip, 0); 10807c478bd9Sstevel@tonic-gate 10817c478bd9Sstevel@tonic-gate add_known_used_resources(); 10827c478bd9Sstevel@tonic-gate 10837c478bd9Sstevel@tonic-gate ndi_devi_exit(isa_dip, circ); 10847c478bd9Sstevel@tonic-gate 10857c478bd9Sstevel@tonic-gate } 1086dffe9ac5Sml40262 1087dffe9ac5Sml40262 /* 1088dffe9ac5Sml40262 * On some machines, serial port 2 isn't listed in the ACPI table. 1089dffe9ac5Sml40262 * This function goes through the BIOS data area and makes sure all 1090dffe9ac5Sml40262 * the serial ports there are in the dev_info tree. If any are missing, 1091dffe9ac5Sml40262 * this function will add them. 1092dffe9ac5Sml40262 */ 1093dffe9ac5Sml40262 1094dffe9ac5Sml40262 static int num_BIOS_serial = 2; /* number of BIOS serial ports to look at */ 1095dffe9ac5Sml40262 1096dffe9ac5Sml40262 static void 1097dffe9ac5Sml40262 enumerate_BIOS_serial(dev_info_t *isa_dip) 1098dffe9ac5Sml40262 { 1099dffe9ac5Sml40262 ushort_t *bios_data; 1100dffe9ac5Sml40262 int i; 1101dffe9ac5Sml40262 dev_info_t *xdip; 1102dffe9ac5Sml40262 int found; 1103dffe9ac5Sml40262 int ret; 1104dffe9ac5Sml40262 struct regspec *tmpregs; 1105dffe9ac5Sml40262 int tmpregs_len; 1106dffe9ac5Sml40262 static struct regspec tmp_asy_regs[] = { 1107dffe9ac5Sml40262 {1, 0x3f8, 0x8}, 1108dffe9ac5Sml40262 }; 1109dffe9ac5Sml40262 static int default_asy_intrs[] = { 4, 3, 4, 3 }; 1110dffe9ac5Sml40262 static size_t size = 4; 1111dffe9ac5Sml40262 1112dffe9ac5Sml40262 /* 1113dffe9ac5Sml40262 * The first four 2-byte quantities of the BIOS data area contain 1114dffe9ac5Sml40262 * the base I/O addresses of the first four serial ports. 1115dffe9ac5Sml40262 */ 1116dffe9ac5Sml40262 bios_data = (ushort_t *)psm_map_new((paddr_t)BIOS_DATA_AREA, size, 1117dffe9ac5Sml40262 PSM_PROT_READ); 1118dffe9ac5Sml40262 for (i = 0; i < num_BIOS_serial; i++) { 1119dffe9ac5Sml40262 if (bios_data[i] == 0) { 1120dffe9ac5Sml40262 /* no COM[i]: port */ 1121dffe9ac5Sml40262 continue; 1122dffe9ac5Sml40262 } 1123dffe9ac5Sml40262 1124dffe9ac5Sml40262 /* Look for it in the dev_info tree */ 1125dffe9ac5Sml40262 found = 0; 1126dffe9ac5Sml40262 for (xdip = ddi_get_child(isa_dip); xdip != NULL; 1127dffe9ac5Sml40262 xdip = ddi_get_next_sibling(xdip)) { 1128dffe9ac5Sml40262 if (strncmp(ddi_node_name(xdip), "asy", 3) != 0) { 1129dffe9ac5Sml40262 /* skip non asy */ 1130dffe9ac5Sml40262 continue; 1131dffe9ac5Sml40262 } 1132dffe9ac5Sml40262 1133dffe9ac5Sml40262 /* Match by addr */ 1134dffe9ac5Sml40262 ret = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, xdip, 1135dffe9ac5Sml40262 DDI_PROP_DONTPASS, "reg", (int **)&tmpregs, 1136dffe9ac5Sml40262 (uint_t *)&tmpregs_len); 1137dffe9ac5Sml40262 if (ret != DDI_PROP_SUCCESS) { 1138dffe9ac5Sml40262 /* error */ 1139dffe9ac5Sml40262 continue; 1140dffe9ac5Sml40262 } 1141dffe9ac5Sml40262 1142dffe9ac5Sml40262 if (tmpregs->regspec_addr == bios_data[i]) 1143dffe9ac5Sml40262 found = 1; 1144dffe9ac5Sml40262 /* 1145dffe9ac5Sml40262 * Free the memory allocated by 1146dffe9ac5Sml40262 * ddi_prop_lookup_int_array(). 1147dffe9ac5Sml40262 */ 1148dffe9ac5Sml40262 ddi_prop_free(tmpregs); 1149843e1988Sjohnlev 1150dffe9ac5Sml40262 } 1151dffe9ac5Sml40262 1152dffe9ac5Sml40262 /* If not found, then add it */ 1153dffe9ac5Sml40262 if (!found) { 1154dffe9ac5Sml40262 ndi_devi_alloc_sleep(isa_dip, "asy", 1155dffe9ac5Sml40262 (pnode_t)DEVI_SID_NODEID, &xdip); 1156dffe9ac5Sml40262 (void) ndi_prop_update_string(DDI_DEV_T_NONE, xdip, 1157dffe9ac5Sml40262 "compatible", "PNP0500"); 1158dffe9ac5Sml40262 /* This should be gotten from master file: */ 1159dffe9ac5Sml40262 (void) ndi_prop_update_string(DDI_DEV_T_NONE, xdip, 1160dffe9ac5Sml40262 "model", "Standard PC COM port"); 1161dffe9ac5Sml40262 tmp_asy_regs[0].regspec_addr = bios_data[i]; 1162dffe9ac5Sml40262 (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, xdip, 1163dffe9ac5Sml40262 "reg", (int *)&tmp_asy_regs[0], 3); 1164dffe9ac5Sml40262 (void) ndi_prop_update_int(DDI_DEV_T_NONE, xdip, 1165dffe9ac5Sml40262 "interrupts", default_asy_intrs[i]); 1166dffe9ac5Sml40262 (void) ndi_devi_bind_driver(xdip, 0); 1167dffe9ac5Sml40262 } 1168dffe9ac5Sml40262 } 1169843e1988Sjohnlev #if defined(__xpv) 1170843e1988Sjohnlev /* 1171843e1988Sjohnlev * Check each serial port to see if it is in use by the hypervisor. 1172843e1988Sjohnlev * If it is in use, then remove the node from the device tree. 1173843e1988Sjohnlev */ 1174843e1988Sjohnlev i = 0; 1175843e1988Sjohnlev for (xdip = ddi_get_child(isa_dip); xdip != NULL; ) { 1176843e1988Sjohnlev int asy_intr; 1177843e1988Sjohnlev dev_info_t *curdip; 1178843e1988Sjohnlev 1179843e1988Sjohnlev curdip = xdip; 1180843e1988Sjohnlev xdip = ddi_get_next_sibling(xdip); 1181843e1988Sjohnlev if (strncmp(ddi_node_name(curdip), "asy", 3) != 0) { 1182843e1988Sjohnlev /* skip non asy */ 1183843e1988Sjohnlev continue; 1184843e1988Sjohnlev } 1185843e1988Sjohnlev /* 1186843e1988Sjohnlev * Check if the hypervisor is using the serial port by probing 1187843e1988Sjohnlev * the irq and if it is using it remove the node 1188843e1988Sjohnlev * from the device tree 1189843e1988Sjohnlev */ 1190843e1988Sjohnlev asy_intr = ddi_prop_get_int(DDI_DEV_T_ANY, curdip, 1191843e1988Sjohnlev DDI_PROP_DONTPASS, "interrupts", -1); 1192843e1988Sjohnlev if (asy_intr == -1) { 1193843e1988Sjohnlev /* error */ 1194843e1988Sjohnlev continue; 1195843e1988Sjohnlev } 1196843e1988Sjohnlev 1197843e1988Sjohnlev if (ec_probe_pirq(asy_intr)) { 1198843e1988Sjohnlev continue; 1199843e1988Sjohnlev } 1200843e1988Sjohnlev ret = ndi_devi_free(curdip); 1201843e1988Sjohnlev if (ret != DDI_SUCCESS) 1202843e1988Sjohnlev cmn_err(CE_WARN, 1203843e1988Sjohnlev "could not remove asy%d node", i); 1204843e1988Sjohnlev else 1205843e1988Sjohnlev cmn_err(CE_NOTE, "!asy%d unavailable, reserved" 1206843e1988Sjohnlev " to hypervisor", i); 1207843e1988Sjohnlev i++; 1208843e1988Sjohnlev } 1209843e1988Sjohnlev #endif /* __xpv */ 1210dffe9ac5Sml40262 1211dffe9ac5Sml40262 psm_unmap((caddr_t)bios_data, size); 1212dffe9ac5Sml40262 } 1213