10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
51756Sszhou * Common Development and Distribution License (the "License").
61756Sszhou * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
22*12825SJimmy.Vetayases@oracle.com * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate */
240Sstevel@tonic-gate
250Sstevel@tonic-gate /*
260Sstevel@tonic-gate * ISA bus nexus driver
270Sstevel@tonic-gate */
280Sstevel@tonic-gate
290Sstevel@tonic-gate #include <sys/types.h>
300Sstevel@tonic-gate #include <sys/cmn_err.h>
310Sstevel@tonic-gate #include <sys/conf.h>
320Sstevel@tonic-gate #include <sys/modctl.h>
330Sstevel@tonic-gate #include <sys/autoconf.h>
340Sstevel@tonic-gate #include <sys/errno.h>
350Sstevel@tonic-gate #include <sys/debug.h>
360Sstevel@tonic-gate #include <sys/kmem.h>
372007Sml40262 #include <sys/psm.h>
380Sstevel@tonic-gate #include <sys/ddidmareq.h>
390Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
4010127SLipeng.Sang@Sun.COM #include <sys/ddi_subrdefs.h>
410Sstevel@tonic-gate #include <sys/dma_engine.h>
420Sstevel@tonic-gate #include <sys/ddi.h>
430Sstevel@tonic-gate #include <sys/sunddi.h>
440Sstevel@tonic-gate #include <sys/sunndi.h>
450Sstevel@tonic-gate #include <sys/acpi/acpi_enum.h>
469149SJudy.Chen@Sun.COM #include <sys/mach_intr.h>
479149SJudy.Chen@Sun.COM #include <sys/pci.h>
489149SJudy.Chen@Sun.COM #include <sys/note.h>
4910175SStuart.Maybee@Sun.COM #include <sys/boot_console.h>
5012683SJimmy.Vetayases@oracle.com #include <sys/apic.h>
515084Sjohnlev #if defined(__xpv)
525084Sjohnlev #include <sys/hypervisor.h>
535084Sjohnlev #include <sys/evtchn_impl.h>
5410175SStuart.Maybee@Sun.COM
5510175SStuart.Maybee@Sun.COM extern int console_hypervisor_device;
565084Sjohnlev #endif
575084Sjohnlev
5812683SJimmy.Vetayases@oracle.com
599149SJudy.Chen@Sun.COM extern int pseudo_isa;
600Sstevel@tonic-gate extern int isa_resource_setup(void);
619149SJudy.Chen@Sun.COM extern int (*psm_intr_ops)(dev_info_t *, ddi_intr_handle_impl_t *,
629149SJudy.Chen@Sun.COM psm_intr_op_t, int *);
639226SJudy.Chen@Sun.COM extern void pci_register_isa_resources(int, uint32_t, uint32_t);
640Sstevel@tonic-gate static char USED_RESOURCES[] = "used-resources";
6510127SLipeng.Sang@Sun.COM static void isa_enumerate(int);
662007Sml40262 static void enumerate_BIOS_serial(dev_info_t *);
679226SJudy.Chen@Sun.COM static void adjust_prtsz(dev_info_t *isa_dip);
6810127SLipeng.Sang@Sun.COM static void isa_create_ranges_prop(dev_info_t *);
692007Sml40262
709149SJudy.Chen@Sun.COM /*
719149SJudy.Chen@Sun.COM * The following typedef is used to represent an entry in the "ranges"
729149SJudy.Chen@Sun.COM * property of a pci-isa bridge device node.
739149SJudy.Chen@Sun.COM */
749149SJudy.Chen@Sun.COM typedef struct {
759149SJudy.Chen@Sun.COM uint32_t child_high;
769149SJudy.Chen@Sun.COM uint32_t child_low;
779149SJudy.Chen@Sun.COM uint32_t parent_high;
789149SJudy.Chen@Sun.COM uint32_t parent_mid;
799149SJudy.Chen@Sun.COM uint32_t parent_low;
809149SJudy.Chen@Sun.COM uint32_t size;
819149SJudy.Chen@Sun.COM } pib_ranges_t;
829149SJudy.Chen@Sun.COM
839149SJudy.Chen@Sun.COM typedef struct {
849149SJudy.Chen@Sun.COM uint32_t base;
859149SJudy.Chen@Sun.COM uint32_t len;
869149SJudy.Chen@Sun.COM } used_ranges_t;
879149SJudy.Chen@Sun.COM
889149SJudy.Chen@Sun.COM #define USED_CELL_SIZE 2 /* 1 byte addr, 1 byte size */
899149SJudy.Chen@Sun.COM #define ISA_ADDR_IO 1 /* IO address space */
909149SJudy.Chen@Sun.COM #define ISA_ADDR_MEM 0 /* memory adress space */
912007Sml40262 #define BIOS_DATA_AREA 0x400
920Sstevel@tonic-gate /*
930Sstevel@tonic-gate * #define ISA_DEBUG 1
940Sstevel@tonic-gate */
950Sstevel@tonic-gate
960Sstevel@tonic-gate /*
979226SJudy.Chen@Sun.COM * For serial ports not enumerated by ACPI, and parallel ports with
989226SJudy.Chen@Sun.COM * illegal size. Typically, a system can have as many as 4 serial
999226SJudy.Chen@Sun.COM * ports and 3 parallel ports.
1009226SJudy.Chen@Sun.COM */
1019226SJudy.Chen@Sun.COM #define MAX_EXTRA_RESOURCE 7
1029226SJudy.Chen@Sun.COM static struct regspec isa_extra_resource[MAX_EXTRA_RESOURCE];
1039226SJudy.Chen@Sun.COM static int isa_extra_count = 0;
1049226SJudy.Chen@Sun.COM
1059226SJudy.Chen@Sun.COM /*
1060Sstevel@tonic-gate * Local data
1070Sstevel@tonic-gate */
1080Sstevel@tonic-gate static ddi_dma_lim_t ISA_dma_limits = {
1090Sstevel@tonic-gate 0, /* address low */
1100Sstevel@tonic-gate 0x00ffffff, /* address high */
1110Sstevel@tonic-gate 0, /* counter max */
1120Sstevel@tonic-gate 1, /* burstsize */
1130Sstevel@tonic-gate DMA_UNIT_8, /* minimum xfer */
1140Sstevel@tonic-gate 0, /* dma speed */
1150Sstevel@tonic-gate (uint_t)DMALIM_VER0, /* version */
1160Sstevel@tonic-gate 0x0000ffff, /* address register */
1170Sstevel@tonic-gate 0x0000ffff, /* counter register */
1180Sstevel@tonic-gate 1, /* sector size */
1190Sstevel@tonic-gate 0x00000001, /* scatter/gather list length */
1200Sstevel@tonic-gate (uint_t)0xffffffff /* request size */
1210Sstevel@tonic-gate };
1220Sstevel@tonic-gate
1230Sstevel@tonic-gate static ddi_dma_attr_t ISA_dma_attr = {
1240Sstevel@tonic-gate DMA_ATTR_V0,
1250Sstevel@tonic-gate (unsigned long long)0,
1260Sstevel@tonic-gate (unsigned long long)0x00ffffff,
1270Sstevel@tonic-gate 0x0000ffff,
1280Sstevel@tonic-gate 1,
1290Sstevel@tonic-gate 1,
1300Sstevel@tonic-gate 1,
1310Sstevel@tonic-gate (unsigned long long)0xffffffff,
1320Sstevel@tonic-gate (unsigned long long)0x0000ffff,
1330Sstevel@tonic-gate 1,
1340Sstevel@tonic-gate 1,
1350Sstevel@tonic-gate 0
1360Sstevel@tonic-gate };
1370Sstevel@tonic-gate
1380Sstevel@tonic-gate
1390Sstevel@tonic-gate /*
1400Sstevel@tonic-gate * Config information
1410Sstevel@tonic-gate */
1420Sstevel@tonic-gate
1430Sstevel@tonic-gate static int
1449149SJudy.Chen@Sun.COM isa_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp,
1459149SJudy.Chen@Sun.COM off_t offset, off_t len, caddr_t *vaddrp);
1469149SJudy.Chen@Sun.COM
1479149SJudy.Chen@Sun.COM static int
1480Sstevel@tonic-gate isa_dma_allochdl(dev_info_t *, dev_info_t *, ddi_dma_attr_t *,
1490Sstevel@tonic-gate int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *);
1500Sstevel@tonic-gate
1510Sstevel@tonic-gate static int
1520Sstevel@tonic-gate isa_dma_mctl(dev_info_t *, dev_info_t *, ddi_dma_handle_t, enum ddi_dma_ctlops,
1530Sstevel@tonic-gate off_t *, size_t *, caddr_t *, uint_t);
1540Sstevel@tonic-gate
1550Sstevel@tonic-gate static int
1560Sstevel@tonic-gate isa_ctlops(dev_info_t *, dev_info_t *, ddi_ctl_enum_t, void *, void *);
1570Sstevel@tonic-gate
1589149SJudy.Chen@Sun.COM static int
1599149SJudy.Chen@Sun.COM isa_intr_ops(dev_info_t *pdip, dev_info_t *rdip, ddi_intr_op_t intr_op,
1609149SJudy.Chen@Sun.COM ddi_intr_handle_impl_t *hdlp, void *result);
16112683SJimmy.Vetayases@oracle.com static int isa_alloc_intr_fixed(dev_info_t *, ddi_intr_handle_impl_t *, void *);
16212683SJimmy.Vetayases@oracle.com static int isa_free_intr_fixed(dev_info_t *, ddi_intr_handle_impl_t *);
1639149SJudy.Chen@Sun.COM
1640Sstevel@tonic-gate struct bus_ops isa_bus_ops = {
1650Sstevel@tonic-gate BUSO_REV,
1669149SJudy.Chen@Sun.COM isa_bus_map,
1670Sstevel@tonic-gate NULL,
1680Sstevel@tonic-gate NULL,
1690Sstevel@tonic-gate NULL,
1700Sstevel@tonic-gate i_ddi_map_fault,
1710Sstevel@tonic-gate ddi_dma_map,
1720Sstevel@tonic-gate isa_dma_allochdl,
1730Sstevel@tonic-gate ddi_dma_freehdl,
1740Sstevel@tonic-gate ddi_dma_bindhdl,
1750Sstevel@tonic-gate ddi_dma_unbindhdl,
1760Sstevel@tonic-gate ddi_dma_flush,
1770Sstevel@tonic-gate ddi_dma_win,
1780Sstevel@tonic-gate isa_dma_mctl,
1790Sstevel@tonic-gate isa_ctlops,
1800Sstevel@tonic-gate ddi_bus_prop_op,
1810Sstevel@tonic-gate NULL, /* (*bus_get_eventcookie)(); */
1820Sstevel@tonic-gate NULL, /* (*bus_add_eventcall)(); */
1830Sstevel@tonic-gate NULL, /* (*bus_remove_eventcall)(); */
1840Sstevel@tonic-gate NULL, /* (*bus_post_event)(); */
1850Sstevel@tonic-gate NULL, /* (*bus_intr_ctl)(); */
1860Sstevel@tonic-gate NULL, /* (*bus_config)(); */
1870Sstevel@tonic-gate NULL, /* (*bus_unconfig)(); */
1880Sstevel@tonic-gate NULL, /* (*bus_fm_init)(); */
1890Sstevel@tonic-gate NULL, /* (*bus_fm_fini)(); */
1900Sstevel@tonic-gate NULL, /* (*bus_fm_access_enter)(); */
1910Sstevel@tonic-gate NULL, /* (*bus_fm_access_exit)(); */
1920Sstevel@tonic-gate NULL, /* (*bus_power)(); */
1939149SJudy.Chen@Sun.COM isa_intr_ops /* (*bus_intr_op)(); */
1940Sstevel@tonic-gate };
1950Sstevel@tonic-gate
1960Sstevel@tonic-gate
1970Sstevel@tonic-gate static int isa_attach(dev_info_t *devi, ddi_attach_cmd_t cmd);
1980Sstevel@tonic-gate
1990Sstevel@tonic-gate /*
2000Sstevel@tonic-gate * Internal isa ctlops support routines
2010Sstevel@tonic-gate */
2020Sstevel@tonic-gate static int isa_initchild(dev_info_t *child);
2030Sstevel@tonic-gate
2040Sstevel@tonic-gate struct dev_ops isa_ops = {
2050Sstevel@tonic-gate DEVO_REV, /* devo_rev, */
2060Sstevel@tonic-gate 0, /* refcnt */
2070Sstevel@tonic-gate ddi_no_info, /* info */
2080Sstevel@tonic-gate nulldev, /* identify */
2090Sstevel@tonic-gate nulldev, /* probe */
2100Sstevel@tonic-gate isa_attach, /* attach */
2119149SJudy.Chen@Sun.COM nulldev, /* detach */
2120Sstevel@tonic-gate nodev, /* reset */
2130Sstevel@tonic-gate (struct cb_ops *)0, /* driver operations */
2147656SSherry.Moore@Sun.COM &isa_bus_ops, /* bus operations */
2157656SSherry.Moore@Sun.COM NULL, /* power */
2167656SSherry.Moore@Sun.COM ddi_quiesce_not_needed, /* quiesce */
2170Sstevel@tonic-gate };
2180Sstevel@tonic-gate
2190Sstevel@tonic-gate /*
2200Sstevel@tonic-gate * Module linkage information for the kernel.
2210Sstevel@tonic-gate */
2220Sstevel@tonic-gate
2230Sstevel@tonic-gate static struct modldrv modldrv = {
2240Sstevel@tonic-gate &mod_driverops, /* Type of module. This is ISA bus driver */
2257542SRichard.Bean@Sun.COM "isa nexus driver for 'ISA'",
2260Sstevel@tonic-gate &isa_ops, /* driver ops */
2270Sstevel@tonic-gate };
2280Sstevel@tonic-gate
2290Sstevel@tonic-gate static struct modlinkage modlinkage = {
2300Sstevel@tonic-gate MODREV_1,
2310Sstevel@tonic-gate &modldrv,
2320Sstevel@tonic-gate NULL
2330Sstevel@tonic-gate };
2340Sstevel@tonic-gate
2350Sstevel@tonic-gate int
_init(void)2360Sstevel@tonic-gate _init(void)
2370Sstevel@tonic-gate {
23810127SLipeng.Sang@Sun.COM int err;
23910127SLipeng.Sang@Sun.COM
24010127SLipeng.Sang@Sun.COM if ((err = mod_install(&modlinkage)) != 0)
24110127SLipeng.Sang@Sun.COM return (err);
24210127SLipeng.Sang@Sun.COM
24310127SLipeng.Sang@Sun.COM impl_bus_add_probe(isa_enumerate);
24410127SLipeng.Sang@Sun.COM return (0);
2450Sstevel@tonic-gate }
2460Sstevel@tonic-gate
2470Sstevel@tonic-gate int
_fini(void)2480Sstevel@tonic-gate _fini(void)
2490Sstevel@tonic-gate {
25010127SLipeng.Sang@Sun.COM int err;
25110127SLipeng.Sang@Sun.COM
25210127SLipeng.Sang@Sun.COM impl_bus_delete_probe(isa_enumerate);
25310127SLipeng.Sang@Sun.COM
25410127SLipeng.Sang@Sun.COM if ((err = mod_remove(&modlinkage)) != 0)
25510127SLipeng.Sang@Sun.COM return (err);
25610127SLipeng.Sang@Sun.COM
25710127SLipeng.Sang@Sun.COM return (0);
2580Sstevel@tonic-gate }
2590Sstevel@tonic-gate
2600Sstevel@tonic-gate int
_info(struct modinfo * modinfop)2610Sstevel@tonic-gate _info(struct modinfo *modinfop)
2620Sstevel@tonic-gate {
2630Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop));
2640Sstevel@tonic-gate }
2650Sstevel@tonic-gate
2660Sstevel@tonic-gate static int
isa_attach(dev_info_t * devi,ddi_attach_cmd_t cmd)2670Sstevel@tonic-gate isa_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
2680Sstevel@tonic-gate {
2690Sstevel@tonic-gate int rval;
2700Sstevel@tonic-gate
2715084Sjohnlev #if defined(__xpv)
2725084Sjohnlev /*
2735084Sjohnlev * don't allow isa to attach in domU. this can happen if someone sets
2745084Sjohnlev * the console wrong, etc. ISA devices assume the H/W is there and
2755084Sjohnlev * will cause the domU to panic.
2765084Sjohnlev */
2775084Sjohnlev if (!DOMAIN_IS_INITDOMAIN(xen_info)) {
2785084Sjohnlev return (DDI_FAILURE);
2795084Sjohnlev }
2805084Sjohnlev #endif
2815084Sjohnlev
2829149SJudy.Chen@Sun.COM switch (cmd) {
2839149SJudy.Chen@Sun.COM case DDI_ATTACH:
2849149SJudy.Chen@Sun.COM break;
2859149SJudy.Chen@Sun.COM case DDI_RESUME:
2869149SJudy.Chen@Sun.COM return (DDI_SUCCESS);
2879149SJudy.Chen@Sun.COM default:
2880Sstevel@tonic-gate return (DDI_FAILURE);
2899149SJudy.Chen@Sun.COM }
2900Sstevel@tonic-gate
29110127SLipeng.Sang@Sun.COM if ((rval = i_dmae_init(devi)) == DDI_SUCCESS)
2920Sstevel@tonic-gate ddi_report_dev(devi);
2939149SJudy.Chen@Sun.COM
2940Sstevel@tonic-gate return (rval);
2950Sstevel@tonic-gate }
2960Sstevel@tonic-gate
2979149SJudy.Chen@Sun.COM #define SET_RNGS(rng_p, used_p, ctyp, ptyp) do { \
2989149SJudy.Chen@Sun.COM (rng_p)->child_high = (ctyp); \
2999149SJudy.Chen@Sun.COM (rng_p)->child_low = (rng_p)->parent_low = (used_p)->base; \
3009149SJudy.Chen@Sun.COM (rng_p)->parent_high = (ptyp); \
3019149SJudy.Chen@Sun.COM (rng_p)->parent_mid = 0; \
3029149SJudy.Chen@Sun.COM (rng_p)->size = (used_p)->len; \
3039149SJudy.Chen@Sun.COM _NOTE(CONSTCOND) } while (0)
3049149SJudy.Chen@Sun.COM static uint_t
isa_used_to_ranges(int ctype,int * array,uint_t size,pib_ranges_t * ranges)3059149SJudy.Chen@Sun.COM isa_used_to_ranges(int ctype, int *array, uint_t size, pib_ranges_t *ranges)
3069149SJudy.Chen@Sun.COM {
3079149SJudy.Chen@Sun.COM used_ranges_t *used_p;
3089149SJudy.Chen@Sun.COM pib_ranges_t *rng_p = ranges;
3099149SJudy.Chen@Sun.COM uint_t i, ptype;
3109149SJudy.Chen@Sun.COM
3119149SJudy.Chen@Sun.COM ptype = (ctype == ISA_ADDR_IO) ? PCI_ADDR_IO : PCI_ADDR_MEM32;
3129149SJudy.Chen@Sun.COM ptype |= PCI_REG_REL_M;
3139149SJudy.Chen@Sun.COM size /= USED_CELL_SIZE;
3149149SJudy.Chen@Sun.COM used_p = (used_ranges_t *)array;
3159149SJudy.Chen@Sun.COM SET_RNGS(rng_p, used_p, ctype, ptype);
3169149SJudy.Chen@Sun.COM for (i = 1, used_p++; i < size; i++, used_p++) {
3179149SJudy.Chen@Sun.COM /* merge ranges record if applicable */
3189149SJudy.Chen@Sun.COM if (rng_p->child_low + rng_p->size == used_p->base)
3199149SJudy.Chen@Sun.COM rng_p->size += used_p->len;
3209149SJudy.Chen@Sun.COM else {
3219149SJudy.Chen@Sun.COM rng_p++;
3229149SJudy.Chen@Sun.COM SET_RNGS(rng_p, used_p, ctype, ptype);
3239149SJudy.Chen@Sun.COM }
3249149SJudy.Chen@Sun.COM }
3259149SJudy.Chen@Sun.COM return (rng_p - ranges + 1);
3269149SJudy.Chen@Sun.COM }
3279149SJudy.Chen@Sun.COM
3289149SJudy.Chen@Sun.COM void
isa_remove_res_from_pci(int type,int * array,uint_t size)3299149SJudy.Chen@Sun.COM isa_remove_res_from_pci(int type, int *array, uint_t size)
3309149SJudy.Chen@Sun.COM {
3319149SJudy.Chen@Sun.COM int i;
3329149SJudy.Chen@Sun.COM used_ranges_t *used_p;
3339149SJudy.Chen@Sun.COM
3349149SJudy.Chen@Sun.COM size /= USED_CELL_SIZE;
3359149SJudy.Chen@Sun.COM used_p = (used_ranges_t *)array;
3369149SJudy.Chen@Sun.COM for (i = 0; i < size; i++, used_p++)
3379226SJudy.Chen@Sun.COM pci_register_isa_resources(type, used_p->base, used_p->len);
3389149SJudy.Chen@Sun.COM }
3399149SJudy.Chen@Sun.COM
3409149SJudy.Chen@Sun.COM static void
isa_create_ranges_prop(dev_info_t * dip)34110127SLipeng.Sang@Sun.COM isa_create_ranges_prop(dev_info_t *dip)
3429149SJudy.Chen@Sun.COM {
3439149SJudy.Chen@Sun.COM dev_info_t *used;
3449149SJudy.Chen@Sun.COM int *ioarray, *memarray, status;
3459149SJudy.Chen@Sun.COM uint_t nio = 0, nmem = 0, nrng = 0, n;
3469149SJudy.Chen@Sun.COM pib_ranges_t *ranges;
3479149SJudy.Chen@Sun.COM
3489149SJudy.Chen@Sun.COM used = ddi_find_devinfo("used-resources", -1, 0);
3499149SJudy.Chen@Sun.COM if (used == NULL) {
3509149SJudy.Chen@Sun.COM cmn_err(CE_WARN, "Failed to find used-resources <%s>\n",
3519149SJudy.Chen@Sun.COM ddi_get_name(dip));
3529149SJudy.Chen@Sun.COM return;
3539149SJudy.Chen@Sun.COM }
3549149SJudy.Chen@Sun.COM status = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, used,
3559149SJudy.Chen@Sun.COM DDI_PROP_DONTPASS, "io-space", &ioarray, &nio);
3569149SJudy.Chen@Sun.COM if (status != DDI_PROP_SUCCESS && status != DDI_PROP_NOT_FOUND) {
3579149SJudy.Chen@Sun.COM cmn_err(CE_WARN, "io-space property failure for %s (%x)\n",
3589149SJudy.Chen@Sun.COM ddi_get_name(used), status);
3599149SJudy.Chen@Sun.COM return;
3609149SJudy.Chen@Sun.COM }
3619149SJudy.Chen@Sun.COM status = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, used,
3629149SJudy.Chen@Sun.COM DDI_PROP_DONTPASS, "device-memory", &memarray, &nmem);
3639149SJudy.Chen@Sun.COM if (status != DDI_PROP_SUCCESS && status != DDI_PROP_NOT_FOUND) {
3649149SJudy.Chen@Sun.COM cmn_err(CE_WARN, "device-memory property failure for %s (%x)\n",
3659149SJudy.Chen@Sun.COM ddi_get_name(used), status);
3669149SJudy.Chen@Sun.COM return;
3679149SJudy.Chen@Sun.COM }
3689149SJudy.Chen@Sun.COM n = (nio + nmem) / USED_CELL_SIZE;
3699149SJudy.Chen@Sun.COM ranges = (pib_ranges_t *)kmem_zalloc(sizeof (pib_ranges_t) * n,
3709149SJudy.Chen@Sun.COM KM_SLEEP);
3719149SJudy.Chen@Sun.COM
3729149SJudy.Chen@Sun.COM if (nio != 0) {
3739149SJudy.Chen@Sun.COM nrng = isa_used_to_ranges(ISA_ADDR_IO, ioarray, nio, ranges);
3749149SJudy.Chen@Sun.COM isa_remove_res_from_pci(ISA_ADDR_IO, ioarray, nio);
3759149SJudy.Chen@Sun.COM ddi_prop_free(ioarray);
3769149SJudy.Chen@Sun.COM }
3779149SJudy.Chen@Sun.COM if (nmem != 0) {
3789149SJudy.Chen@Sun.COM nrng += isa_used_to_ranges(ISA_ADDR_MEM, memarray, nmem,
3799149SJudy.Chen@Sun.COM ranges + nrng);
3809149SJudy.Chen@Sun.COM isa_remove_res_from_pci(ISA_ADDR_MEM, memarray, nmem);
3819149SJudy.Chen@Sun.COM ddi_prop_free(memarray);
3829149SJudy.Chen@Sun.COM }
3839149SJudy.Chen@Sun.COM
3849226SJudy.Chen@Sun.COM if (!pseudo_isa)
3859226SJudy.Chen@Sun.COM (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, dip, "ranges",
3869226SJudy.Chen@Sun.COM (int *)ranges, nrng * sizeof (pib_ranges_t) / sizeof (int));
3879149SJudy.Chen@Sun.COM kmem_free(ranges, sizeof (pib_ranges_t) * n);
3889149SJudy.Chen@Sun.COM }
3899149SJudy.Chen@Sun.COM
3909149SJudy.Chen@Sun.COM /*ARGSUSED*/
3919149SJudy.Chen@Sun.COM static int
isa_apply_range(dev_info_t * dip,struct regspec * isa_reg_p,pci_regspec_t * pci_reg_p)3929149SJudy.Chen@Sun.COM isa_apply_range(dev_info_t *dip, struct regspec *isa_reg_p,
3939149SJudy.Chen@Sun.COM pci_regspec_t *pci_reg_p)
3949149SJudy.Chen@Sun.COM {
3959149SJudy.Chen@Sun.COM pib_ranges_t *ranges, *rng_p;
3969149SJudy.Chen@Sun.COM int len, i, offset, nrange;
3979149SJudy.Chen@Sun.COM
3989149SJudy.Chen@Sun.COM if (ddi_getlongprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
3999149SJudy.Chen@Sun.COM "ranges", (caddr_t)&ranges, &len) != DDI_SUCCESS) {
4009149SJudy.Chen@Sun.COM cmn_err(CE_WARN, "Can't get %s ranges property",
4019149SJudy.Chen@Sun.COM ddi_get_name(dip));
4029149SJudy.Chen@Sun.COM return (DDI_ME_REGSPEC_RANGE);
4039149SJudy.Chen@Sun.COM }
4049149SJudy.Chen@Sun.COM nrange = len / sizeof (pib_ranges_t);
4059149SJudy.Chen@Sun.COM rng_p = ranges;
4069149SJudy.Chen@Sun.COM for (i = 0; i < nrange; i++, rng_p++) {
4079149SJudy.Chen@Sun.COM /* Check for correct space */
4089149SJudy.Chen@Sun.COM if (isa_reg_p->regspec_bustype != rng_p->child_high)
4099149SJudy.Chen@Sun.COM continue;
4109149SJudy.Chen@Sun.COM
4119149SJudy.Chen@Sun.COM /* Detect whether request entirely fits within a range */
4129149SJudy.Chen@Sun.COM if (isa_reg_p->regspec_addr < rng_p->child_low)
4139149SJudy.Chen@Sun.COM continue;
4149481SJudy.Chen@Sun.COM if ((isa_reg_p->regspec_addr + isa_reg_p->regspec_size - 1) >
4159481SJudy.Chen@Sun.COM (rng_p->child_low + rng_p->size - 1))
4169149SJudy.Chen@Sun.COM continue;
4179149SJudy.Chen@Sun.COM
4189149SJudy.Chen@Sun.COM offset = isa_reg_p->regspec_addr - rng_p->child_low;
4199149SJudy.Chen@Sun.COM
4209149SJudy.Chen@Sun.COM pci_reg_p->pci_phys_hi = rng_p->parent_high;
4219149SJudy.Chen@Sun.COM pci_reg_p->pci_phys_mid = 0;
4229149SJudy.Chen@Sun.COM pci_reg_p->pci_phys_low = rng_p->parent_low + offset;
4239149SJudy.Chen@Sun.COM pci_reg_p->pci_size_hi = 0;
4249149SJudy.Chen@Sun.COM pci_reg_p->pci_size_low = isa_reg_p->regspec_size;
4259149SJudy.Chen@Sun.COM
4269149SJudy.Chen@Sun.COM break;
4279149SJudy.Chen@Sun.COM }
4289149SJudy.Chen@Sun.COM kmem_free(ranges, len);
4299226SJudy.Chen@Sun.COM
4309226SJudy.Chen@Sun.COM if (i < nrange)
4319226SJudy.Chen@Sun.COM return (DDI_SUCCESS);
4329226SJudy.Chen@Sun.COM
4339226SJudy.Chen@Sun.COM /*
4349226SJudy.Chen@Sun.COM * Check extra resource range specially for serial and parallel
4359226SJudy.Chen@Sun.COM * devices, which are treated differently from all other ISA
4369226SJudy.Chen@Sun.COM * devices. On some machines, serial ports are not enumerated
4379226SJudy.Chen@Sun.COM * by ACPI but by BIOS, with io base addresses noted in legacy
4389226SJudy.Chen@Sun.COM * BIOS data area. Parallel port on some machines comes with
4399226SJudy.Chen@Sun.COM * illegal size.
4409226SJudy.Chen@Sun.COM */
4419226SJudy.Chen@Sun.COM if (isa_reg_p->regspec_bustype != ISA_ADDR_IO)
4429226SJudy.Chen@Sun.COM goto out_of_range;
4439226SJudy.Chen@Sun.COM
4449226SJudy.Chen@Sun.COM for (i = 0; i < isa_extra_count; i++) {
4459226SJudy.Chen@Sun.COM struct regspec *reg_p = &isa_extra_resource[i];
4469226SJudy.Chen@Sun.COM
4479226SJudy.Chen@Sun.COM if (isa_reg_p->regspec_addr < reg_p->regspec_addr)
4489226SJudy.Chen@Sun.COM continue;
4499226SJudy.Chen@Sun.COM if ((isa_reg_p->regspec_addr + isa_reg_p->regspec_size) >
4509226SJudy.Chen@Sun.COM (reg_p->regspec_addr + reg_p->regspec_size))
4519226SJudy.Chen@Sun.COM continue;
4529226SJudy.Chen@Sun.COM
4539226SJudy.Chen@Sun.COM pci_reg_p->pci_phys_hi = PCI_ADDR_IO | PCI_REG_REL_M;
4549226SJudy.Chen@Sun.COM pci_reg_p->pci_phys_mid = 0;
4559226SJudy.Chen@Sun.COM pci_reg_p->pci_phys_low = isa_reg_p->regspec_addr;
4569226SJudy.Chen@Sun.COM pci_reg_p->pci_size_hi = 0;
4579226SJudy.Chen@Sun.COM pci_reg_p->pci_size_low = isa_reg_p->regspec_size;
4589226SJudy.Chen@Sun.COM break;
4599149SJudy.Chen@Sun.COM }
4609226SJudy.Chen@Sun.COM if (i < isa_extra_count)
4619226SJudy.Chen@Sun.COM return (DDI_SUCCESS);
4629149SJudy.Chen@Sun.COM
4639226SJudy.Chen@Sun.COM out_of_range:
4649226SJudy.Chen@Sun.COM cmn_err(CE_WARN, "isa_apply_range: Out of range base <0x%x>, size <%d>",
4659226SJudy.Chen@Sun.COM isa_reg_p->regspec_addr, isa_reg_p->regspec_size);
4669226SJudy.Chen@Sun.COM return (DDI_ME_REGSPEC_RANGE);
4679149SJudy.Chen@Sun.COM }
4689149SJudy.Chen@Sun.COM
4699149SJudy.Chen@Sun.COM static int
isa_bus_map(dev_info_t * dip,dev_info_t * rdip,ddi_map_req_t * mp,off_t offset,off_t len,caddr_t * vaddrp)4709149SJudy.Chen@Sun.COM isa_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp,
4719149SJudy.Chen@Sun.COM off_t offset, off_t len, caddr_t *vaddrp)
4729149SJudy.Chen@Sun.COM {
4739149SJudy.Chen@Sun.COM struct regspec tmp_reg, *rp;
4749149SJudy.Chen@Sun.COM pci_regspec_t vreg;
4759149SJudy.Chen@Sun.COM ddi_map_req_t mr = *mp; /* Get private copy of request */
4769149SJudy.Chen@Sun.COM int error;
4779149SJudy.Chen@Sun.COM
4789149SJudy.Chen@Sun.COM if (pseudo_isa)
4799149SJudy.Chen@Sun.COM return (i_ddi_bus_map(dip, rdip, mp, offset, len, vaddrp));
4809149SJudy.Chen@Sun.COM
4819149SJudy.Chen@Sun.COM mp = &mr;
4829149SJudy.Chen@Sun.COM
4839149SJudy.Chen@Sun.COM /*
4849149SJudy.Chen@Sun.COM * First, if given an rnumber, convert it to a regspec...
4859149SJudy.Chen@Sun.COM */
4869149SJudy.Chen@Sun.COM if (mp->map_type == DDI_MT_RNUMBER) {
4879149SJudy.Chen@Sun.COM
4889149SJudy.Chen@Sun.COM int rnumber = mp->map_obj.rnumber;
4899149SJudy.Chen@Sun.COM
4909149SJudy.Chen@Sun.COM rp = i_ddi_rnumber_to_regspec(rdip, rnumber);
4919149SJudy.Chen@Sun.COM if (rp == (struct regspec *)0)
4929149SJudy.Chen@Sun.COM return (DDI_ME_RNUMBER_RANGE);
4939149SJudy.Chen@Sun.COM
4949149SJudy.Chen@Sun.COM /*
4959149SJudy.Chen@Sun.COM * Convert the given ddi_map_req_t from rnumber to regspec...
4969149SJudy.Chen@Sun.COM */
4979149SJudy.Chen@Sun.COM mp->map_type = DDI_MT_REGSPEC;
4989149SJudy.Chen@Sun.COM mp->map_obj.rp = rp;
4999149SJudy.Chen@Sun.COM }
5009149SJudy.Chen@Sun.COM
5019149SJudy.Chen@Sun.COM /*
5029149SJudy.Chen@Sun.COM * Adjust offset and length correspnding to called values...
5039149SJudy.Chen@Sun.COM * XXX: A non-zero length means override the one in the regspec.
5049149SJudy.Chen@Sun.COM * XXX: (Regardless of what's in the parent's range)
5059149SJudy.Chen@Sun.COM */
5069149SJudy.Chen@Sun.COM
5079149SJudy.Chen@Sun.COM tmp_reg = *(mp->map_obj.rp); /* Preserve underlying data */
5089149SJudy.Chen@Sun.COM rp = mp->map_obj.rp = &tmp_reg; /* Use tmp_reg in request */
5099149SJudy.Chen@Sun.COM
5109149SJudy.Chen@Sun.COM rp->regspec_addr += (uint_t)offset;
5119149SJudy.Chen@Sun.COM if (len != 0)
5129149SJudy.Chen@Sun.COM rp->regspec_size = (uint_t)len;
5139149SJudy.Chen@Sun.COM
5149149SJudy.Chen@Sun.COM if ((error = isa_apply_range(dip, rp, &vreg)) != 0)
5159149SJudy.Chen@Sun.COM return (error);
5169149SJudy.Chen@Sun.COM mp->map_obj.rp = (struct regspec *)&vreg;
5179149SJudy.Chen@Sun.COM
5189149SJudy.Chen@Sun.COM /*
5199149SJudy.Chen@Sun.COM * Call my parents bus_map function with modified values...
5209149SJudy.Chen@Sun.COM */
5219149SJudy.Chen@Sun.COM
5229149SJudy.Chen@Sun.COM return (ddi_map(dip, mp, (off_t)0, (off_t)0, vaddrp));
5239149SJudy.Chen@Sun.COM }
5249149SJudy.Chen@Sun.COM
5250Sstevel@tonic-gate static int
isa_dma_allochdl(dev_info_t * dip,dev_info_t * rdip,ddi_dma_attr_t * dma_attr,int (* waitfp)(caddr_t),caddr_t arg,ddi_dma_handle_t * handlep)5260Sstevel@tonic-gate isa_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *dma_attr,
5270Sstevel@tonic-gate int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep)
5280Sstevel@tonic-gate {
5290Sstevel@tonic-gate ddi_dma_attr_merge(dma_attr, &ISA_dma_attr);
5300Sstevel@tonic-gate return (ddi_dma_allochdl(dip, rdip, dma_attr, waitfp, arg, handlep));
5310Sstevel@tonic-gate }
5320Sstevel@tonic-gate
5330Sstevel@tonic-gate static int
isa_dma_mctl(dev_info_t * dip,dev_info_t * rdip,ddi_dma_handle_t handle,enum ddi_dma_ctlops request,off_t * offp,size_t * lenp,caddr_t * objp,uint_t flags)5340Sstevel@tonic-gate isa_dma_mctl(dev_info_t *dip, dev_info_t *rdip,
5350Sstevel@tonic-gate ddi_dma_handle_t handle, enum ddi_dma_ctlops request,
5360Sstevel@tonic-gate off_t *offp, size_t *lenp, caddr_t *objp, uint_t flags)
5370Sstevel@tonic-gate {
5380Sstevel@tonic-gate int rval;
5390Sstevel@tonic-gate ddi_dma_lim_t defalt;
5400Sstevel@tonic-gate int arg = (int)(uintptr_t)objp;
5410Sstevel@tonic-gate
5420Sstevel@tonic-gate switch (request) {
5430Sstevel@tonic-gate
5440Sstevel@tonic-gate case DDI_DMA_E_PROG:
5450Sstevel@tonic-gate return (i_dmae_prog(rdip, (struct ddi_dmae_req *)offp,
5460Sstevel@tonic-gate (ddi_dma_cookie_t *)lenp, arg));
5470Sstevel@tonic-gate
5480Sstevel@tonic-gate case DDI_DMA_E_ACQUIRE:
5490Sstevel@tonic-gate return (i_dmae_acquire(rdip, arg, (int(*)(caddr_t))offp,
5500Sstevel@tonic-gate (caddr_t)lenp));
5510Sstevel@tonic-gate
5520Sstevel@tonic-gate case DDI_DMA_E_FREE:
5530Sstevel@tonic-gate return (i_dmae_free(rdip, arg));
5540Sstevel@tonic-gate
5550Sstevel@tonic-gate case DDI_DMA_E_STOP:
5560Sstevel@tonic-gate i_dmae_stop(rdip, arg);
5570Sstevel@tonic-gate return (DDI_SUCCESS);
5580Sstevel@tonic-gate
5590Sstevel@tonic-gate case DDI_DMA_E_ENABLE:
5600Sstevel@tonic-gate i_dmae_enable(rdip, arg);
5610Sstevel@tonic-gate return (DDI_SUCCESS);
5620Sstevel@tonic-gate
5630Sstevel@tonic-gate case DDI_DMA_E_DISABLE:
5640Sstevel@tonic-gate i_dmae_disable(rdip, arg);
5650Sstevel@tonic-gate return (DDI_SUCCESS);
5660Sstevel@tonic-gate
5670Sstevel@tonic-gate case DDI_DMA_E_GETCNT:
5680Sstevel@tonic-gate i_dmae_get_chan_stat(rdip, arg, NULL, (int *)lenp);
5690Sstevel@tonic-gate return (DDI_SUCCESS);
5700Sstevel@tonic-gate
5710Sstevel@tonic-gate case DDI_DMA_E_SWSETUP:
5720Sstevel@tonic-gate return (i_dmae_swsetup(rdip, (struct ddi_dmae_req *)offp,
5730Sstevel@tonic-gate (ddi_dma_cookie_t *)lenp, arg));
5740Sstevel@tonic-gate
5750Sstevel@tonic-gate case DDI_DMA_E_SWSTART:
5760Sstevel@tonic-gate i_dmae_swstart(rdip, arg);
5770Sstevel@tonic-gate return (DDI_SUCCESS);
5780Sstevel@tonic-gate
5790Sstevel@tonic-gate case DDI_DMA_E_GETLIM:
5800Sstevel@tonic-gate bcopy(&ISA_dma_limits, objp, sizeof (ddi_dma_lim_t));
5810Sstevel@tonic-gate return (DDI_SUCCESS);
5820Sstevel@tonic-gate
5830Sstevel@tonic-gate case DDI_DMA_E_GETATTR:
5840Sstevel@tonic-gate bcopy(&ISA_dma_attr, objp, sizeof (ddi_dma_attr_t));
5850Sstevel@tonic-gate return (DDI_SUCCESS);
5860Sstevel@tonic-gate
5870Sstevel@tonic-gate case DDI_DMA_E_1STPTY:
5880Sstevel@tonic-gate {
5890Sstevel@tonic-gate struct ddi_dmae_req req1stpty =
5900Sstevel@tonic-gate { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
5910Sstevel@tonic-gate if (arg == 0) {
5920Sstevel@tonic-gate req1stpty.der_command = DMAE_CMD_TRAN;
5930Sstevel@tonic-gate req1stpty.der_trans = DMAE_TRANS_DMND;
5940Sstevel@tonic-gate } else {
5950Sstevel@tonic-gate req1stpty.der_trans = DMAE_TRANS_CSCD;
5960Sstevel@tonic-gate }
5970Sstevel@tonic-gate return (i_dmae_prog(rdip, &req1stpty, NULL, arg));
5980Sstevel@tonic-gate }
5990Sstevel@tonic-gate
6000Sstevel@tonic-gate case DDI_DMA_IOPB_ALLOC: /* get contiguous DMA-able memory */
6010Sstevel@tonic-gate case DDI_DMA_SMEM_ALLOC:
6020Sstevel@tonic-gate if (!offp) {
6030Sstevel@tonic-gate defalt = ISA_dma_limits;
6040Sstevel@tonic-gate offp = (off_t *)&defalt;
6050Sstevel@tonic-gate }
6060Sstevel@tonic-gate /*FALLTHROUGH*/
6070Sstevel@tonic-gate default:
6080Sstevel@tonic-gate rval = ddi_dma_mctl(dip, rdip, handle, request, offp,
6090Sstevel@tonic-gate lenp, objp, flags);
6100Sstevel@tonic-gate }
6110Sstevel@tonic-gate return (rval);
6120Sstevel@tonic-gate }
6130Sstevel@tonic-gate
6140Sstevel@tonic-gate /*
6150Sstevel@tonic-gate * Check if driver should be treated as an old pre 2.6 driver
6160Sstevel@tonic-gate */
6170Sstevel@tonic-gate static int
old_driver(dev_info_t * dip)6180Sstevel@tonic-gate old_driver(dev_info_t *dip)
6190Sstevel@tonic-gate {
6200Sstevel@tonic-gate extern int ignore_hardware_nodes; /* force flag from ddi_impl.c */
6210Sstevel@tonic-gate
6220Sstevel@tonic-gate if (ndi_dev_is_persistent_node(dip)) {
6230Sstevel@tonic-gate if (ignore_hardware_nodes)
6240Sstevel@tonic-gate return (1);
6250Sstevel@tonic-gate if (ddi_getprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
6260Sstevel@tonic-gate "ignore-hardware-nodes", -1) != -1)
6270Sstevel@tonic-gate return (1);
6280Sstevel@tonic-gate }
6290Sstevel@tonic-gate return (0);
6300Sstevel@tonic-gate }
6310Sstevel@tonic-gate
6320Sstevel@tonic-gate typedef struct {
6330Sstevel@tonic-gate uint32_t phys_hi;
6340Sstevel@tonic-gate uint32_t phys_lo;
6350Sstevel@tonic-gate uint32_t size;
6360Sstevel@tonic-gate } isa_regs_t;
6370Sstevel@tonic-gate
6380Sstevel@tonic-gate /*
6390Sstevel@tonic-gate * Return non-zero if device in tree is a PnP isa device
6400Sstevel@tonic-gate */
6410Sstevel@tonic-gate static int
is_pnpisa(dev_info_t * dip)6420Sstevel@tonic-gate is_pnpisa(dev_info_t *dip)
6430Sstevel@tonic-gate {
6440Sstevel@tonic-gate isa_regs_t *isa_regs;
6450Sstevel@tonic-gate int proplen, pnpisa;
6460Sstevel@tonic-gate
6470Sstevel@tonic-gate if (ddi_getlongprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, "reg",
6485084Sjohnlev (caddr_t)&isa_regs, &proplen) != DDI_PROP_SUCCESS) {
6490Sstevel@tonic-gate return (0);
6500Sstevel@tonic-gate }
6510Sstevel@tonic-gate pnpisa = isa_regs[0].phys_hi & 0x80000000;
6520Sstevel@tonic-gate /*
6530Sstevel@tonic-gate * free the memory allocated by ddi_getlongprop().
6540Sstevel@tonic-gate */
6550Sstevel@tonic-gate kmem_free(isa_regs, proplen);
6560Sstevel@tonic-gate if (pnpisa)
6570Sstevel@tonic-gate return (1);
6580Sstevel@tonic-gate else
6590Sstevel@tonic-gate return (0);
6600Sstevel@tonic-gate }
6610Sstevel@tonic-gate
6620Sstevel@tonic-gate /*ARGSUSED*/
6630Sstevel@tonic-gate static int
isa_ctlops(dev_info_t * dip,dev_info_t * rdip,ddi_ctl_enum_t ctlop,void * arg,void * result)6640Sstevel@tonic-gate isa_ctlops(dev_info_t *dip, dev_info_t *rdip,
6650Sstevel@tonic-gate ddi_ctl_enum_t ctlop, void *arg, void *result)
6660Sstevel@tonic-gate {
6679149SJudy.Chen@Sun.COM int rn;
6689149SJudy.Chen@Sun.COM struct ddi_parent_private_data *pdp;
6699149SJudy.Chen@Sun.COM
6700Sstevel@tonic-gate switch (ctlop) {
6710Sstevel@tonic-gate case DDI_CTLOPS_REPORTDEV:
6720Sstevel@tonic-gate if (rdip == (dev_info_t *)0)
6730Sstevel@tonic-gate return (DDI_FAILURE);
6740Sstevel@tonic-gate cmn_err(CE_CONT, "?ISA-device: %s%d\n",
6750Sstevel@tonic-gate ddi_driver_name(rdip), ddi_get_instance(rdip));
6760Sstevel@tonic-gate return (DDI_SUCCESS);
6770Sstevel@tonic-gate
6780Sstevel@tonic-gate case DDI_CTLOPS_INITCHILD:
6790Sstevel@tonic-gate /*
6800Sstevel@tonic-gate * older drivers aren't expecting the "standard" device
6810Sstevel@tonic-gate * node format used by the hardware nodes. these drivers
6820Sstevel@tonic-gate * only expect their own properties set in their driver.conf
6830Sstevel@tonic-gate * files. so they tell us not to call them with hardware
6840Sstevel@tonic-gate * nodes by setting the property "ignore-hardware-nodes".
6850Sstevel@tonic-gate */
6860Sstevel@tonic-gate if (old_driver((dev_info_t *)arg)) {
6870Sstevel@tonic-gate return (DDI_NOT_WELL_FORMED);
6880Sstevel@tonic-gate }
6890Sstevel@tonic-gate
6900Sstevel@tonic-gate return (isa_initchild((dev_info_t *)arg));
6910Sstevel@tonic-gate
6920Sstevel@tonic-gate case DDI_CTLOPS_UNINITCHILD:
6930Sstevel@tonic-gate impl_ddi_sunbus_removechild((dev_info_t *)arg);
6940Sstevel@tonic-gate return (DDI_SUCCESS);
6950Sstevel@tonic-gate
6960Sstevel@tonic-gate case DDI_CTLOPS_SIDDEV:
69711175SKerry.Shu@Sun.COM if (ndi_dev_is_persistent_node(rdip))
69811175SKerry.Shu@Sun.COM return (DDI_SUCCESS);
6990Sstevel@tonic-gate /*
7000Sstevel@tonic-gate * All ISA devices need to do confirming probes
7010Sstevel@tonic-gate * unless they are PnP ISA.
7020Sstevel@tonic-gate */
70311175SKerry.Shu@Sun.COM if (is_pnpisa(rdip))
7040Sstevel@tonic-gate return (DDI_SUCCESS);
7050Sstevel@tonic-gate else
7060Sstevel@tonic-gate return (DDI_FAILURE);
7070Sstevel@tonic-gate
7089149SJudy.Chen@Sun.COM case DDI_CTLOPS_REGSIZE:
7099149SJudy.Chen@Sun.COM case DDI_CTLOPS_NREGS:
7109149SJudy.Chen@Sun.COM if (rdip == (dev_info_t *)0)
7119149SJudy.Chen@Sun.COM return (DDI_FAILURE);
7129149SJudy.Chen@Sun.COM
7139149SJudy.Chen@Sun.COM if ((pdp = ddi_get_parent_data(rdip)) == NULL)
7149149SJudy.Chen@Sun.COM return (DDI_FAILURE);
7159149SJudy.Chen@Sun.COM
7169149SJudy.Chen@Sun.COM if (ctlop == DDI_CTLOPS_NREGS) {
7179149SJudy.Chen@Sun.COM *(int *)result = pdp->par_nreg;
7189149SJudy.Chen@Sun.COM } else {
7199149SJudy.Chen@Sun.COM rn = *(int *)arg;
7209149SJudy.Chen@Sun.COM if (rn >= pdp->par_nreg)
7219149SJudy.Chen@Sun.COM return (DDI_FAILURE);
7229149SJudy.Chen@Sun.COM *(off_t *)result = (off_t)pdp->par_reg[rn].regspec_size;
7239149SJudy.Chen@Sun.COM }
7249149SJudy.Chen@Sun.COM return (DDI_SUCCESS);
7259149SJudy.Chen@Sun.COM
7269149SJudy.Chen@Sun.COM case DDI_CTLOPS_ATTACH:
7279149SJudy.Chen@Sun.COM case DDI_CTLOPS_DETACH:
7289149SJudy.Chen@Sun.COM case DDI_CTLOPS_PEEK:
7299149SJudy.Chen@Sun.COM case DDI_CTLOPS_POKE:
7309149SJudy.Chen@Sun.COM return (DDI_FAILURE);
7319149SJudy.Chen@Sun.COM
7320Sstevel@tonic-gate default:
7330Sstevel@tonic-gate return (ddi_ctlops(dip, rdip, ctlop, arg, result));
7340Sstevel@tonic-gate }
7350Sstevel@tonic-gate }
7360Sstevel@tonic-gate
7379149SJudy.Chen@Sun.COM static struct intrspec *
isa_get_ispec(dev_info_t * rdip,int inum)7389149SJudy.Chen@Sun.COM isa_get_ispec(dev_info_t *rdip, int inum)
7399149SJudy.Chen@Sun.COM {
7409149SJudy.Chen@Sun.COM struct ddi_parent_private_data *pdp = ddi_get_parent_data(rdip);
7419149SJudy.Chen@Sun.COM
7429149SJudy.Chen@Sun.COM /* Validate the interrupt number */
7439149SJudy.Chen@Sun.COM if (inum >= pdp->par_nintr)
7449149SJudy.Chen@Sun.COM return (NULL);
7459149SJudy.Chen@Sun.COM
7469149SJudy.Chen@Sun.COM /* Get the interrupt structure pointer and return that */
7479149SJudy.Chen@Sun.COM return ((struct intrspec *)&pdp->par_intr[inum]);
7489149SJudy.Chen@Sun.COM }
7499149SJudy.Chen@Sun.COM
7509149SJudy.Chen@Sun.COM static int
isa_intr_ops(dev_info_t * pdip,dev_info_t * rdip,ddi_intr_op_t intr_op,ddi_intr_handle_impl_t * hdlp,void * result)7519149SJudy.Chen@Sun.COM isa_intr_ops(dev_info_t *pdip, dev_info_t *rdip, ddi_intr_op_t intr_op,
7529149SJudy.Chen@Sun.COM ddi_intr_handle_impl_t *hdlp, void *result)
7539149SJudy.Chen@Sun.COM {
7549149SJudy.Chen@Sun.COM struct intrspec *ispec;
7559149SJudy.Chen@Sun.COM
7569149SJudy.Chen@Sun.COM if (pseudo_isa)
7579149SJudy.Chen@Sun.COM return (i_ddi_intr_ops(pdip, rdip, intr_op, hdlp, result));
7589149SJudy.Chen@Sun.COM
7599149SJudy.Chen@Sun.COM
7609149SJudy.Chen@Sun.COM /* Process the interrupt operation */
7619149SJudy.Chen@Sun.COM switch (intr_op) {
7629149SJudy.Chen@Sun.COM case DDI_INTROP_GETCAP:
7639149SJudy.Chen@Sun.COM /* First check with pcplusmp */
7649149SJudy.Chen@Sun.COM if (psm_intr_ops == NULL)
7659149SJudy.Chen@Sun.COM return (DDI_FAILURE);
7669149SJudy.Chen@Sun.COM
7679149SJudy.Chen@Sun.COM if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_GET_CAP, result)) {
7689149SJudy.Chen@Sun.COM *(int *)result = 0;
7699149SJudy.Chen@Sun.COM return (DDI_FAILURE);
7709149SJudy.Chen@Sun.COM }
7719149SJudy.Chen@Sun.COM break;
7729149SJudy.Chen@Sun.COM case DDI_INTROP_SETCAP:
7739149SJudy.Chen@Sun.COM if (psm_intr_ops == NULL)
7749149SJudy.Chen@Sun.COM return (DDI_FAILURE);
7759149SJudy.Chen@Sun.COM
7769149SJudy.Chen@Sun.COM if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_SET_CAP, result))
7779149SJudy.Chen@Sun.COM return (DDI_FAILURE);
7789149SJudy.Chen@Sun.COM break;
7799149SJudy.Chen@Sun.COM case DDI_INTROP_ALLOC:
78012683SJimmy.Vetayases@oracle.com ASSERT(hdlp->ih_type == DDI_INTR_TYPE_FIXED);
78112683SJimmy.Vetayases@oracle.com return (isa_alloc_intr_fixed(rdip, hdlp, result));
7829149SJudy.Chen@Sun.COM case DDI_INTROP_FREE:
78312683SJimmy.Vetayases@oracle.com ASSERT(hdlp->ih_type == DDI_INTR_TYPE_FIXED);
78412683SJimmy.Vetayases@oracle.com return (isa_free_intr_fixed(rdip, hdlp));
7859149SJudy.Chen@Sun.COM case DDI_INTROP_GETPRI:
7869149SJudy.Chen@Sun.COM if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL)
7879149SJudy.Chen@Sun.COM return (DDI_FAILURE);
7889149SJudy.Chen@Sun.COM *(int *)result = ispec->intrspec_pri;
7899149SJudy.Chen@Sun.COM break;
7909149SJudy.Chen@Sun.COM case DDI_INTROP_SETPRI:
7919149SJudy.Chen@Sun.COM /* Validate the interrupt priority passed to us */
7929149SJudy.Chen@Sun.COM if (*(int *)result > LOCK_LEVEL)
7939149SJudy.Chen@Sun.COM return (DDI_FAILURE);
7949149SJudy.Chen@Sun.COM
7959149SJudy.Chen@Sun.COM /* Ensure that PSM is all initialized and ispec is ok */
7969149SJudy.Chen@Sun.COM if ((psm_intr_ops == NULL) ||
7979149SJudy.Chen@Sun.COM ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL))
7989149SJudy.Chen@Sun.COM return (DDI_FAILURE);
7999149SJudy.Chen@Sun.COM
8009149SJudy.Chen@Sun.COM /* update the ispec with the new priority */
8019149SJudy.Chen@Sun.COM ispec->intrspec_pri = *(int *)result;
8029149SJudy.Chen@Sun.COM break;
8039149SJudy.Chen@Sun.COM case DDI_INTROP_ADDISR:
8049149SJudy.Chen@Sun.COM if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL)
8059149SJudy.Chen@Sun.COM return (DDI_FAILURE);
8069149SJudy.Chen@Sun.COM ispec->intrspec_func = hdlp->ih_cb_func;
8079149SJudy.Chen@Sun.COM break;
8089149SJudy.Chen@Sun.COM case DDI_INTROP_REMISR:
8099149SJudy.Chen@Sun.COM if (hdlp->ih_type != DDI_INTR_TYPE_FIXED)
8109149SJudy.Chen@Sun.COM return (DDI_FAILURE);
8119149SJudy.Chen@Sun.COM if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL)
8129149SJudy.Chen@Sun.COM return (DDI_FAILURE);
8139149SJudy.Chen@Sun.COM ispec->intrspec_func = (uint_t (*)()) 0;
8149149SJudy.Chen@Sun.COM break;
8159149SJudy.Chen@Sun.COM case DDI_INTROP_ENABLE:
8169149SJudy.Chen@Sun.COM if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL)
8179149SJudy.Chen@Sun.COM return (DDI_FAILURE);
8189149SJudy.Chen@Sun.COM
8199149SJudy.Chen@Sun.COM /* Call psmi to translate irq with the dip */
8209149SJudy.Chen@Sun.COM if (psm_intr_ops == NULL)
8219149SJudy.Chen@Sun.COM return (DDI_FAILURE);
8229149SJudy.Chen@Sun.COM
82310175SStuart.Maybee@Sun.COM #if defined(__xpv)
82410175SStuart.Maybee@Sun.COM /*
82510175SStuart.Maybee@Sun.COM * if the hypervisor is using an isa serial port for the
82610175SStuart.Maybee@Sun.COM * console, make sure we don't try to use that interrupt as
82710175SStuart.Maybee@Sun.COM * it will cause us to panic when xen_bind_pirq() fails.
82810175SStuart.Maybee@Sun.COM */
82910175SStuart.Maybee@Sun.COM if (((ispec->intrspec_vec == 4) &&
83010175SStuart.Maybee@Sun.COM (console_hypervisor_device == CONS_TTYA)) ||
83110175SStuart.Maybee@Sun.COM ((ispec->intrspec_vec == 3) &&
83210175SStuart.Maybee@Sun.COM (console_hypervisor_device == CONS_TTYB))) {
83310175SStuart.Maybee@Sun.COM return (DDI_FAILURE);
83410175SStuart.Maybee@Sun.COM }
83510175SStuart.Maybee@Sun.COM #endif
8369149SJudy.Chen@Sun.COM ((ihdl_plat_t *)hdlp->ih_private)->ip_ispecp = ispec;
83711465SKerry.Shu@Sun.COM if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_XLATE_VECTOR,
83811465SKerry.Shu@Sun.COM (int *)&hdlp->ih_vector) == PSM_FAILURE)
83911465SKerry.Shu@Sun.COM return (DDI_FAILURE);
8409149SJudy.Chen@Sun.COM
8419149SJudy.Chen@Sun.COM /* Add the interrupt handler */
8429149SJudy.Chen@Sun.COM if (!add_avintr((void *)hdlp, ispec->intrspec_pri,
8439149SJudy.Chen@Sun.COM hdlp->ih_cb_func, DEVI(rdip)->devi_name, hdlp->ih_vector,
8449149SJudy.Chen@Sun.COM hdlp->ih_cb_arg1, hdlp->ih_cb_arg2, NULL, rdip))
8459149SJudy.Chen@Sun.COM return (DDI_FAILURE);
8469149SJudy.Chen@Sun.COM break;
8479149SJudy.Chen@Sun.COM case DDI_INTROP_DISABLE:
8489149SJudy.Chen@Sun.COM if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL)
8499149SJudy.Chen@Sun.COM return (DDI_FAILURE);
8509149SJudy.Chen@Sun.COM
8519149SJudy.Chen@Sun.COM /* Call psm_ops() to translate irq with the dip */
8529149SJudy.Chen@Sun.COM if (psm_intr_ops == NULL)
8539149SJudy.Chen@Sun.COM return (DDI_FAILURE);
8549149SJudy.Chen@Sun.COM
8559149SJudy.Chen@Sun.COM ((ihdl_plat_t *)hdlp->ih_private)->ip_ispecp = ispec;
8569149SJudy.Chen@Sun.COM (void) (*psm_intr_ops)(rdip, hdlp,
8579149SJudy.Chen@Sun.COM PSM_INTR_OP_XLATE_VECTOR, (int *)&hdlp->ih_vector);
8589149SJudy.Chen@Sun.COM
8599149SJudy.Chen@Sun.COM /* Remove the interrupt handler */
8609149SJudy.Chen@Sun.COM rem_avintr((void *)hdlp, ispec->intrspec_pri,
8619149SJudy.Chen@Sun.COM hdlp->ih_cb_func, hdlp->ih_vector);
8629149SJudy.Chen@Sun.COM break;
8639149SJudy.Chen@Sun.COM case DDI_INTROP_SETMASK:
8649149SJudy.Chen@Sun.COM if (psm_intr_ops == NULL)
8659149SJudy.Chen@Sun.COM return (DDI_FAILURE);
8669149SJudy.Chen@Sun.COM
8679149SJudy.Chen@Sun.COM if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_SET_MASK, NULL))
8689149SJudy.Chen@Sun.COM return (DDI_FAILURE);
8699149SJudy.Chen@Sun.COM break;
8709149SJudy.Chen@Sun.COM case DDI_INTROP_CLRMASK:
8719149SJudy.Chen@Sun.COM if (psm_intr_ops == NULL)
8729149SJudy.Chen@Sun.COM return (DDI_FAILURE);
8739149SJudy.Chen@Sun.COM
8749149SJudy.Chen@Sun.COM if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_CLEAR_MASK, NULL))
8759149SJudy.Chen@Sun.COM return (DDI_FAILURE);
8769149SJudy.Chen@Sun.COM break;
8779149SJudy.Chen@Sun.COM case DDI_INTROP_GETPENDING:
8789149SJudy.Chen@Sun.COM if (psm_intr_ops == NULL)
8799149SJudy.Chen@Sun.COM return (DDI_FAILURE);
8809149SJudy.Chen@Sun.COM
8819149SJudy.Chen@Sun.COM if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_GET_PENDING,
8829149SJudy.Chen@Sun.COM result)) {
8839149SJudy.Chen@Sun.COM *(int *)result = 0;
8849149SJudy.Chen@Sun.COM return (DDI_FAILURE);
8859149SJudy.Chen@Sun.COM }
8869149SJudy.Chen@Sun.COM break;
8879149SJudy.Chen@Sun.COM case DDI_INTROP_NAVAIL:
8889149SJudy.Chen@Sun.COM case DDI_INTROP_NINTRS:
8899149SJudy.Chen@Sun.COM *(int *)result = i_ddi_get_intx_nintrs(rdip);
8909149SJudy.Chen@Sun.COM if (*(int *)result == 0) {
8919149SJudy.Chen@Sun.COM return (DDI_FAILURE);
8929149SJudy.Chen@Sun.COM }
8939149SJudy.Chen@Sun.COM break;
8949149SJudy.Chen@Sun.COM case DDI_INTROP_SUPPORTED_TYPES:
8959149SJudy.Chen@Sun.COM *(int *)result = DDI_INTR_TYPE_FIXED; /* Always ... */
8969149SJudy.Chen@Sun.COM break;
8979149SJudy.Chen@Sun.COM default:
8989149SJudy.Chen@Sun.COM return (DDI_FAILURE);
8999149SJudy.Chen@Sun.COM }
9009149SJudy.Chen@Sun.COM
9019149SJudy.Chen@Sun.COM return (DDI_SUCCESS);
9029149SJudy.Chen@Sun.COM }
9039149SJudy.Chen@Sun.COM
90412683SJimmy.Vetayases@oracle.com /*
90512683SJimmy.Vetayases@oracle.com * Allocate interrupt vector for FIXED (legacy) type.
90612683SJimmy.Vetayases@oracle.com */
90712683SJimmy.Vetayases@oracle.com static int
isa_alloc_intr_fixed(dev_info_t * rdip,ddi_intr_handle_impl_t * hdlp,void * result)90812683SJimmy.Vetayases@oracle.com isa_alloc_intr_fixed(dev_info_t *rdip, ddi_intr_handle_impl_t *hdlp,
90912683SJimmy.Vetayases@oracle.com void *result)
91012683SJimmy.Vetayases@oracle.com {
91112683SJimmy.Vetayases@oracle.com struct intrspec *ispec;
91212683SJimmy.Vetayases@oracle.com ddi_intr_handle_impl_t info_hdl;
91312683SJimmy.Vetayases@oracle.com int ret;
91412683SJimmy.Vetayases@oracle.com int free_phdl = 0;
91512683SJimmy.Vetayases@oracle.com apic_get_type_t type_info;
91612683SJimmy.Vetayases@oracle.com
91712683SJimmy.Vetayases@oracle.com if (psm_intr_ops == NULL)
91812683SJimmy.Vetayases@oracle.com return (DDI_FAILURE);
91912683SJimmy.Vetayases@oracle.com
92012683SJimmy.Vetayases@oracle.com if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL)
92112683SJimmy.Vetayases@oracle.com return (DDI_FAILURE);
92212683SJimmy.Vetayases@oracle.com
92312683SJimmy.Vetayases@oracle.com /*
92412683SJimmy.Vetayases@oracle.com * If the PSM module is "APIX" then pass the request for it
92512683SJimmy.Vetayases@oracle.com * to allocate the vector now.
92612683SJimmy.Vetayases@oracle.com */
92712683SJimmy.Vetayases@oracle.com bzero(&info_hdl, sizeof (ddi_intr_handle_impl_t));
92812683SJimmy.Vetayases@oracle.com info_hdl.ih_private = &type_info;
92912683SJimmy.Vetayases@oracle.com if ((*psm_intr_ops)(NULL, &info_hdl, PSM_INTR_OP_APIC_TYPE, NULL) ==
93012683SJimmy.Vetayases@oracle.com PSM_SUCCESS && strcmp(type_info.avgi_type, APIC_APIX_NAME) == 0) {
93112683SJimmy.Vetayases@oracle.com if (hdlp->ih_private == NULL) { /* allocate phdl structure */
93212683SJimmy.Vetayases@oracle.com free_phdl = 1;
93312683SJimmy.Vetayases@oracle.com i_ddi_alloc_intr_phdl(hdlp);
93412683SJimmy.Vetayases@oracle.com }
93512683SJimmy.Vetayases@oracle.com ((ihdl_plat_t *)hdlp->ih_private)->ip_ispecp = ispec;
93612683SJimmy.Vetayases@oracle.com ret = (*psm_intr_ops)(rdip, hdlp,
93712683SJimmy.Vetayases@oracle.com PSM_INTR_OP_ALLOC_VECTORS, result);
93812683SJimmy.Vetayases@oracle.com if (free_phdl) { /* free up the phdl structure */
93912683SJimmy.Vetayases@oracle.com free_phdl = 0;
94012683SJimmy.Vetayases@oracle.com i_ddi_free_intr_phdl(hdlp);
94112683SJimmy.Vetayases@oracle.com hdlp->ih_private = NULL;
94212683SJimmy.Vetayases@oracle.com }
94312683SJimmy.Vetayases@oracle.com } else {
94412683SJimmy.Vetayases@oracle.com /*
94512683SJimmy.Vetayases@oracle.com * No APIX module; fall back to the old scheme where the
94612683SJimmy.Vetayases@oracle.com * interrupt vector is allocated during ddi_enable_intr() call.
94712683SJimmy.Vetayases@oracle.com */
94812683SJimmy.Vetayases@oracle.com hdlp->ih_pri = ispec->intrspec_pri;
94912683SJimmy.Vetayases@oracle.com *(int *)result = hdlp->ih_scratch1;
95012683SJimmy.Vetayases@oracle.com ret = DDI_SUCCESS;
95112683SJimmy.Vetayases@oracle.com }
95212683SJimmy.Vetayases@oracle.com
95312683SJimmy.Vetayases@oracle.com return (ret);
95412683SJimmy.Vetayases@oracle.com }
95512683SJimmy.Vetayases@oracle.com
95612683SJimmy.Vetayases@oracle.com /*
95712683SJimmy.Vetayases@oracle.com * Free up interrupt vector for FIXED (legacy) type.
95812683SJimmy.Vetayases@oracle.com */
95912683SJimmy.Vetayases@oracle.com static int
isa_free_intr_fixed(dev_info_t * rdip,ddi_intr_handle_impl_t * hdlp)96012683SJimmy.Vetayases@oracle.com isa_free_intr_fixed(dev_info_t *rdip, ddi_intr_handle_impl_t *hdlp)
96112683SJimmy.Vetayases@oracle.com {
96212683SJimmy.Vetayases@oracle.com struct intrspec *ispec;
96312683SJimmy.Vetayases@oracle.com ddi_intr_handle_impl_t info_hdl;
96412683SJimmy.Vetayases@oracle.com int ret;
96512683SJimmy.Vetayases@oracle.com apic_get_type_t type_info;
96612683SJimmy.Vetayases@oracle.com
96712683SJimmy.Vetayases@oracle.com if (psm_intr_ops == NULL)
96812683SJimmy.Vetayases@oracle.com return (DDI_FAILURE);
96912683SJimmy.Vetayases@oracle.com
97012683SJimmy.Vetayases@oracle.com /*
97112683SJimmy.Vetayases@oracle.com * If the PSM module is "APIX" then pass the request for it
97212683SJimmy.Vetayases@oracle.com * to free up the vector now.
97312683SJimmy.Vetayases@oracle.com */
97412683SJimmy.Vetayases@oracle.com bzero(&info_hdl, sizeof (ddi_intr_handle_impl_t));
97512683SJimmy.Vetayases@oracle.com info_hdl.ih_private = &type_info;
97612683SJimmy.Vetayases@oracle.com if ((*psm_intr_ops)(NULL, &info_hdl, PSM_INTR_OP_APIC_TYPE, NULL) ==
97712683SJimmy.Vetayases@oracle.com PSM_SUCCESS && strcmp(type_info.avgi_type, APIC_APIX_NAME) == 0) {
97812683SJimmy.Vetayases@oracle.com if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL)
97912683SJimmy.Vetayases@oracle.com return (DDI_FAILURE);
98012683SJimmy.Vetayases@oracle.com ((ihdl_plat_t *)hdlp->ih_private)->ip_ispecp = ispec;
98112683SJimmy.Vetayases@oracle.com ret = (*psm_intr_ops)(rdip, hdlp,
98212683SJimmy.Vetayases@oracle.com PSM_INTR_OP_FREE_VECTORS, NULL);
98312683SJimmy.Vetayases@oracle.com } else {
98412683SJimmy.Vetayases@oracle.com /*
98512683SJimmy.Vetayases@oracle.com * No APIX module; fall back to the old scheme where
98612683SJimmy.Vetayases@oracle.com * the interrupt vector was already freed during
98712683SJimmy.Vetayases@oracle.com * ddi_disable_intr() call.
98812683SJimmy.Vetayases@oracle.com */
98912683SJimmy.Vetayases@oracle.com ret = DDI_SUCCESS;
99012683SJimmy.Vetayases@oracle.com }
99112683SJimmy.Vetayases@oracle.com
99212683SJimmy.Vetayases@oracle.com return (ret);
99312683SJimmy.Vetayases@oracle.com }
99412683SJimmy.Vetayases@oracle.com
9950Sstevel@tonic-gate static void
isa_vendor(uint32_t id,char * vendor)9960Sstevel@tonic-gate isa_vendor(uint32_t id, char *vendor)
9970Sstevel@tonic-gate {
9980Sstevel@tonic-gate vendor[0] = '@' + ((id >> 26) & 0x1f);
9990Sstevel@tonic-gate vendor[1] = '@' + ((id >> 21) & 0x1f);
10000Sstevel@tonic-gate vendor[2] = '@' + ((id >> 16) & 0x1f);
10010Sstevel@tonic-gate vendor[3] = 0;
10020Sstevel@tonic-gate }
10030Sstevel@tonic-gate
10040Sstevel@tonic-gate /*
10050Sstevel@tonic-gate * Name a child
10060Sstevel@tonic-gate */
10070Sstevel@tonic-gate static int
isa_name_child(dev_info_t * child,char * name,int namelen)10080Sstevel@tonic-gate isa_name_child(dev_info_t *child, char *name, int namelen)
10090Sstevel@tonic-gate {
10100Sstevel@tonic-gate char vendor[8];
10110Sstevel@tonic-gate int device;
10120Sstevel@tonic-gate uint32_t serial;
10130Sstevel@tonic-gate int func;
10140Sstevel@tonic-gate int bustype;
10150Sstevel@tonic-gate uint32_t base;
10160Sstevel@tonic-gate int proplen;
10170Sstevel@tonic-gate int pnpisa = 0;
10180Sstevel@tonic-gate isa_regs_t *isa_regs;
10190Sstevel@tonic-gate
10200Sstevel@tonic-gate void make_ddi_ppd(dev_info_t *, struct ddi_parent_private_data **);
10210Sstevel@tonic-gate
10220Sstevel@tonic-gate /*
10230Sstevel@tonic-gate * older drivers aren't expecting the "standard" device
10240Sstevel@tonic-gate * node format used by the hardware nodes. these drivers
10250Sstevel@tonic-gate * only expect their own properties set in their driver.conf
10260Sstevel@tonic-gate * files. so they tell us not to call them with hardware
10270Sstevel@tonic-gate * nodes by setting the property "ignore-hardware-nodes".
10280Sstevel@tonic-gate */
10290Sstevel@tonic-gate if (old_driver(child))
10300Sstevel@tonic-gate return (DDI_FAILURE);
10310Sstevel@tonic-gate
10320Sstevel@tonic-gate /*
10330Sstevel@tonic-gate * Fill in parent-private data
10340Sstevel@tonic-gate */
10350Sstevel@tonic-gate if (ddi_get_parent_data(child) == NULL) {
10360Sstevel@tonic-gate struct ddi_parent_private_data *pdptr;
10370Sstevel@tonic-gate make_ddi_ppd(child, &pdptr);
10380Sstevel@tonic-gate ddi_set_parent_data(child, pdptr);
10390Sstevel@tonic-gate }
10400Sstevel@tonic-gate
10410Sstevel@tonic-gate if (ndi_dev_is_persistent_node(child) == 0) {
10420Sstevel@tonic-gate /*
10430Sstevel@tonic-gate * For .conf nodes, generate name from parent private data
10440Sstevel@tonic-gate */
10450Sstevel@tonic-gate name[0] = '\0';
10460Sstevel@tonic-gate if (sparc_pd_getnreg(child) > 0) {
10470Sstevel@tonic-gate (void) snprintf(name, namelen, "%x,%x",
10480Sstevel@tonic-gate (uint_t)sparc_pd_getreg(child, 0)->regspec_bustype,
10490Sstevel@tonic-gate (uint_t)sparc_pd_getreg(child, 0)->regspec_addr);
10500Sstevel@tonic-gate }
10510Sstevel@tonic-gate return (DDI_SUCCESS);
10520Sstevel@tonic-gate }
10530Sstevel@tonic-gate
10540Sstevel@tonic-gate /*
10550Sstevel@tonic-gate * For hw nodes, look up "reg" property
10560Sstevel@tonic-gate */
10570Sstevel@tonic-gate if (ddi_getlongprop(DDI_DEV_T_ANY, child, DDI_PROP_DONTPASS, "reg",
10580Sstevel@tonic-gate (caddr_t)&isa_regs, &proplen) != DDI_PROP_SUCCESS) {
10590Sstevel@tonic-gate return (DDI_FAILURE);
10600Sstevel@tonic-gate }
10610Sstevel@tonic-gate
10620Sstevel@tonic-gate /*
10630Sstevel@tonic-gate * extract the device identifications
10640Sstevel@tonic-gate */
10650Sstevel@tonic-gate pnpisa = isa_regs[0].phys_hi & 0x80000000;
10660Sstevel@tonic-gate if (pnpisa) {
10670Sstevel@tonic-gate isa_vendor(isa_regs[0].phys_hi, vendor);
10680Sstevel@tonic-gate device = isa_regs[0].phys_hi & 0xffff;
10690Sstevel@tonic-gate serial = isa_regs[0].phys_lo;
10700Sstevel@tonic-gate func = (isa_regs[0].size >> 24) & 0xff;
10710Sstevel@tonic-gate if (func != 0)
10720Sstevel@tonic-gate (void) snprintf(name, namelen, "pnp%s,%04x,%x,%x",
10730Sstevel@tonic-gate vendor, device, serial, func);
10740Sstevel@tonic-gate else
10750Sstevel@tonic-gate (void) snprintf(name, namelen, "pnp%s,%04x,%x",
10760Sstevel@tonic-gate vendor, device, serial);
10770Sstevel@tonic-gate } else {
10780Sstevel@tonic-gate bustype = isa_regs[0].phys_hi;
10790Sstevel@tonic-gate base = isa_regs[0].phys_lo;
10800Sstevel@tonic-gate (void) sprintf(name, "%x,%x", bustype, base);
10810Sstevel@tonic-gate }
10820Sstevel@tonic-gate
10830Sstevel@tonic-gate /*
10840Sstevel@tonic-gate * free the memory allocated by ddi_getlongprop().
10850Sstevel@tonic-gate */
10860Sstevel@tonic-gate kmem_free(isa_regs, proplen);
10870Sstevel@tonic-gate
10880Sstevel@tonic-gate return (DDI_SUCCESS);
10890Sstevel@tonic-gate }
10900Sstevel@tonic-gate
10910Sstevel@tonic-gate static int
isa_initchild(dev_info_t * child)10920Sstevel@tonic-gate isa_initchild(dev_info_t *child)
10930Sstevel@tonic-gate {
10940Sstevel@tonic-gate char name[80];
10950Sstevel@tonic-gate
10960Sstevel@tonic-gate if (isa_name_child(child, name, 80) != DDI_SUCCESS)
10970Sstevel@tonic-gate return (DDI_FAILURE);
10980Sstevel@tonic-gate ddi_set_name_addr(child, name);
10990Sstevel@tonic-gate
11000Sstevel@tonic-gate if (ndi_dev_is_persistent_node(child) != 0)
11010Sstevel@tonic-gate return (DDI_SUCCESS);
11020Sstevel@tonic-gate
11030Sstevel@tonic-gate /*
11040Sstevel@tonic-gate * This is a .conf node, try merge properties onto a
11050Sstevel@tonic-gate * hw node with the same name.
11060Sstevel@tonic-gate */
11070Sstevel@tonic-gate if (ndi_merge_node(child, isa_name_child) == DDI_SUCCESS) {
11080Sstevel@tonic-gate /*
11090Sstevel@tonic-gate * Return failure to remove node
11100Sstevel@tonic-gate */
11110Sstevel@tonic-gate impl_ddi_sunbus_removechild(child);
11120Sstevel@tonic-gate return (DDI_FAILURE);
11130Sstevel@tonic-gate }
11140Sstevel@tonic-gate /*
11150Sstevel@tonic-gate * Cannot merge node, permit pseudo children
11160Sstevel@tonic-gate */
11170Sstevel@tonic-gate return (DDI_SUCCESS);
11180Sstevel@tonic-gate }
11190Sstevel@tonic-gate
11200Sstevel@tonic-gate /*
11210Sstevel@tonic-gate * called when ACPI enumeration is not used
11220Sstevel@tonic-gate */
11230Sstevel@tonic-gate static void
add_known_used_resources(void)11240Sstevel@tonic-gate add_known_used_resources(void)
11250Sstevel@tonic-gate {
11260Sstevel@tonic-gate /* needs to be in increasing order */
11270Sstevel@tonic-gate int intr[] = {0x1, 0x3, 0x4, 0x6, 0x7, 0xc};
11280Sstevel@tonic-gate int dma[] = {0x2};
11290Sstevel@tonic-gate int io[] = {0x60, 0x1, 0x64, 0x1, 0x2f8, 0x8, 0x378, 0x8, 0x3f0, 0x10,
11300Sstevel@tonic-gate 0x778, 0x4};
11310Sstevel@tonic-gate dev_info_t *usedrdip;
11320Sstevel@tonic-gate
11330Sstevel@tonic-gate usedrdip = ddi_find_devinfo(USED_RESOURCES, -1, 0);
11340Sstevel@tonic-gate
11350Sstevel@tonic-gate if (usedrdip == NULL) {
11360Sstevel@tonic-gate (void) ndi_devi_alloc_sleep(ddi_root_node(), USED_RESOURCES,
1137789Sahrens (pnode_t)DEVI_SID_NODEID, &usedrdip);
11380Sstevel@tonic-gate }
11390Sstevel@tonic-gate
11400Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, usedrdip,
11410Sstevel@tonic-gate "interrupts", (int *)intr, (int)(sizeof (intr) / sizeof (int)));
11420Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, usedrdip,
11430Sstevel@tonic-gate "io-space", (int *)io, (int)(sizeof (io) / sizeof (int)));
11440Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, usedrdip,
11450Sstevel@tonic-gate "dma-channels", (int *)dma, (int)(sizeof (dma) / sizeof (int)));
11460Sstevel@tonic-gate (void) ndi_devi_bind_driver(usedrdip, 0);
11470Sstevel@tonic-gate
11480Sstevel@tonic-gate }
11490Sstevel@tonic-gate
11500Sstevel@tonic-gate static void
isa_enumerate(int reprogram)115110127SLipeng.Sang@Sun.COM isa_enumerate(int reprogram)
11520Sstevel@tonic-gate {
11530Sstevel@tonic-gate int circ, i;
11540Sstevel@tonic-gate dev_info_t *xdip;
115510127SLipeng.Sang@Sun.COM dev_info_t *isa_dip = ddi_find_devinfo("isa", -1, 0);
11560Sstevel@tonic-gate
11570Sstevel@tonic-gate /* hard coded isa stuff */
11580Sstevel@tonic-gate struct regspec asy_regs[] = {
11590Sstevel@tonic-gate {1, 0x3f8, 0x8},
11600Sstevel@tonic-gate {1, 0x2f8, 0x8}
11610Sstevel@tonic-gate };
11620Sstevel@tonic-gate int asy_intrs[] = {0x4, 0x3};
11630Sstevel@tonic-gate
11640Sstevel@tonic-gate struct regspec i8042_regs[] = {
11650Sstevel@tonic-gate {1, 0x60, 0x1},
11660Sstevel@tonic-gate {1, 0x64, 0x1}
11670Sstevel@tonic-gate };
11680Sstevel@tonic-gate int i8042_intrs[] = {0x1, 0xc};
11690Sstevel@tonic-gate char *acpi_prop;
11700Sstevel@tonic-gate int acpi_enum = 1; /* ACPI is default to be on */
11710Sstevel@tonic-gate
117210127SLipeng.Sang@Sun.COM if (reprogram || !isa_dip)
11730Sstevel@tonic-gate return;
11740Sstevel@tonic-gate
117510127SLipeng.Sang@Sun.COM bzero(isa_extra_resource, MAX_EXTRA_RESOURCE * sizeof (struct regspec));
117610127SLipeng.Sang@Sun.COM
11770Sstevel@tonic-gate ndi_devi_enter(isa_dip, &circ);
11780Sstevel@tonic-gate
11790Sstevel@tonic-gate if (ddi_prop_lookup_string(DDI_DEV_T_ANY, ddi_root_node(),
11800Sstevel@tonic-gate DDI_PROP_DONTPASS, "acpi-enum", &acpi_prop) == DDI_PROP_SUCCESS) {
11810Sstevel@tonic-gate acpi_enum = strcmp("off", acpi_prop);
11820Sstevel@tonic-gate ddi_prop_free(acpi_prop);
11830Sstevel@tonic-gate }
11840Sstevel@tonic-gate
11850Sstevel@tonic-gate if (acpi_enum) {
11860Sstevel@tonic-gate if (acpi_isa_device_enum(isa_dip)) {
11870Sstevel@tonic-gate ndi_devi_exit(isa_dip, circ);
11880Sstevel@tonic-gate if (isa_resource_setup() != NDI_SUCCESS) {
11890Sstevel@tonic-gate cmn_err(CE_WARN, "isa nexus: isa "
11900Sstevel@tonic-gate "resource setup failed");
11910Sstevel@tonic-gate }
11922007Sml40262
11932007Sml40262 /* serial ports? */
11942007Sml40262 enumerate_BIOS_serial(isa_dip);
11959226SJudy.Chen@Sun.COM
11969226SJudy.Chen@Sun.COM /* adjust parallel port size */
11979226SJudy.Chen@Sun.COM adjust_prtsz(isa_dip);
119810127SLipeng.Sang@Sun.COM
119910127SLipeng.Sang@Sun.COM isa_create_ranges_prop(isa_dip);
12000Sstevel@tonic-gate return;
12010Sstevel@tonic-gate }
12020Sstevel@tonic-gate cmn_err(CE_NOTE, "!Solaris did not detect ACPI BIOS");
12030Sstevel@tonic-gate }
12040Sstevel@tonic-gate cmn_err(CE_NOTE, "!ACPI is off");
12050Sstevel@tonic-gate
12060Sstevel@tonic-gate /* serial ports */
12070Sstevel@tonic-gate for (i = 0; i < 2; i++) {
12085084Sjohnlev #if defined(__xpv)
120910175SStuart.Maybee@Sun.COM if ((i == 0 && console_hypervisor_device == CONS_TTYA) ||
121010175SStuart.Maybee@Sun.COM (i == 1 && console_hypervisor_device == CONS_TTYB)) {
121110175SStuart.Maybee@Sun.COM continue;
121210175SStuart.Maybee@Sun.COM }
12135084Sjohnlev #endif
12140Sstevel@tonic-gate ndi_devi_alloc_sleep(isa_dip, "asy",
1215789Sahrens (pnode_t)DEVI_SID_NODEID, &xdip);
12160Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, xdip,
12170Sstevel@tonic-gate "reg", (int *)&asy_regs[i], 3);
12180Sstevel@tonic-gate (void) ndi_prop_update_int(DDI_DEV_T_NONE, xdip,
12190Sstevel@tonic-gate "interrupts", asy_intrs[i]);
12200Sstevel@tonic-gate (void) ndi_devi_bind_driver(xdip, 0);
12210Sstevel@tonic-gate }
12220Sstevel@tonic-gate
12230Sstevel@tonic-gate /* i8042 node */
12240Sstevel@tonic-gate ndi_devi_alloc_sleep(isa_dip, "i8042",
1225789Sahrens (pnode_t)DEVI_SID_NODEID, &xdip);
12260Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, xdip,
12270Sstevel@tonic-gate "reg", (int *)i8042_regs, 6);
12280Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, xdip,
12290Sstevel@tonic-gate "interrupts", (int *)i8042_intrs, 2);
12300Sstevel@tonic-gate (void) ndi_prop_update_string(DDI_DEV_T_NONE, xdip,
12310Sstevel@tonic-gate "unit-address", "1,60");
12320Sstevel@tonic-gate (void) ndi_devi_bind_driver(xdip, 0);
12330Sstevel@tonic-gate
12340Sstevel@tonic-gate add_known_used_resources();
12350Sstevel@tonic-gate
12360Sstevel@tonic-gate ndi_devi_exit(isa_dip, circ);
12370Sstevel@tonic-gate
123810127SLipeng.Sang@Sun.COM isa_create_ranges_prop(isa_dip);
12390Sstevel@tonic-gate }
12402007Sml40262
12412007Sml40262 /*
12422007Sml40262 * On some machines, serial port 2 isn't listed in the ACPI table.
12432007Sml40262 * This function goes through the BIOS data area and makes sure all
12442007Sml40262 * the serial ports there are in the dev_info tree. If any are missing,
12452007Sml40262 * this function will add them.
12462007Sml40262 */
12472007Sml40262
12482007Sml40262 static int num_BIOS_serial = 2; /* number of BIOS serial ports to look at */
12492007Sml40262
12502007Sml40262 static void
enumerate_BIOS_serial(dev_info_t * isa_dip)12512007Sml40262 enumerate_BIOS_serial(dev_info_t *isa_dip)
12522007Sml40262 {
12532007Sml40262 ushort_t *bios_data;
12542007Sml40262 int i;
12552007Sml40262 dev_info_t *xdip;
12562007Sml40262 int found;
12572007Sml40262 int ret;
12582007Sml40262 struct regspec *tmpregs;
12592007Sml40262 int tmpregs_len;
12602007Sml40262 static struct regspec tmp_asy_regs[] = {
12612007Sml40262 {1, 0x3f8, 0x8},
12622007Sml40262 };
12632007Sml40262 static int default_asy_intrs[] = { 4, 3, 4, 3 };
12642007Sml40262 static size_t size = 4;
12652007Sml40262
12662007Sml40262 /*
12672007Sml40262 * The first four 2-byte quantities of the BIOS data area contain
12682007Sml40262 * the base I/O addresses of the first four serial ports.
12692007Sml40262 */
12702007Sml40262 bios_data = (ushort_t *)psm_map_new((paddr_t)BIOS_DATA_AREA, size,
12715084Sjohnlev PSM_PROT_READ);
12722007Sml40262 for (i = 0; i < num_BIOS_serial; i++) {
12732007Sml40262 if (bios_data[i] == 0) {
12742007Sml40262 /* no COM[i]: port */
12752007Sml40262 continue;
12762007Sml40262 }
12772007Sml40262
12782007Sml40262 /* Look for it in the dev_info tree */
12792007Sml40262 found = 0;
12802007Sml40262 for (xdip = ddi_get_child(isa_dip); xdip != NULL;
12812007Sml40262 xdip = ddi_get_next_sibling(xdip)) {
12822007Sml40262 if (strncmp(ddi_node_name(xdip), "asy", 3) != 0) {
12832007Sml40262 /* skip non asy */
12842007Sml40262 continue;
12852007Sml40262 }
12862007Sml40262
12872007Sml40262 /* Match by addr */
12882007Sml40262 ret = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, xdip,
12895084Sjohnlev DDI_PROP_DONTPASS, "reg", (int **)&tmpregs,
12905084Sjohnlev (uint_t *)&tmpregs_len);
12912007Sml40262 if (ret != DDI_PROP_SUCCESS) {
12922007Sml40262 /* error */
12932007Sml40262 continue;
12942007Sml40262 }
12952007Sml40262
12962007Sml40262 if (tmpregs->regspec_addr == bios_data[i])
12972007Sml40262 found = 1;
12982007Sml40262 /*
12992007Sml40262 * Free the memory allocated by
13002007Sml40262 * ddi_prop_lookup_int_array().
13012007Sml40262 */
13022007Sml40262 ddi_prop_free(tmpregs);
13035084Sjohnlev
13042007Sml40262 }
13052007Sml40262
13062007Sml40262 /* If not found, then add it */
13072007Sml40262 if (!found) {
13082007Sml40262 ndi_devi_alloc_sleep(isa_dip, "asy",
13092007Sml40262 (pnode_t)DEVI_SID_NODEID, &xdip);
13102007Sml40262 (void) ndi_prop_update_string(DDI_DEV_T_NONE, xdip,
13112007Sml40262 "compatible", "PNP0500");
13122007Sml40262 /* This should be gotten from master file: */
13132007Sml40262 (void) ndi_prop_update_string(DDI_DEV_T_NONE, xdip,
13142007Sml40262 "model", "Standard PC COM port");
13152007Sml40262 tmp_asy_regs[0].regspec_addr = bios_data[i];
13162007Sml40262 (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, xdip,
13172007Sml40262 "reg", (int *)&tmp_asy_regs[0], 3);
13182007Sml40262 (void) ndi_prop_update_int(DDI_DEV_T_NONE, xdip,
13192007Sml40262 "interrupts", default_asy_intrs[i]);
13202007Sml40262 (void) ndi_devi_bind_driver(xdip, 0);
13219226SJudy.Chen@Sun.COM
13229226SJudy.Chen@Sun.COM ASSERT(isa_extra_count < MAX_EXTRA_RESOURCE);
13239226SJudy.Chen@Sun.COM bcopy(tmp_asy_regs,
13249226SJudy.Chen@Sun.COM isa_extra_resource + isa_extra_count,
13259226SJudy.Chen@Sun.COM sizeof (struct regspec));
13269226SJudy.Chen@Sun.COM isa_extra_count++;
13272007Sml40262 }
13282007Sml40262 }
132910175SStuart.Maybee@Sun.COM
13305084Sjohnlev /*
133110175SStuart.Maybee@Sun.COM * An asy node may have been attached via ACPI enumeration, or
133210175SStuart.Maybee@Sun.COM * directly from this file. Check each serial port to see if it
133310175SStuart.Maybee@Sun.COM * is in use by the hypervisor. If it is in use, then remove
133410175SStuart.Maybee@Sun.COM * the node from the device tree.
13355084Sjohnlev */
133610175SStuart.Maybee@Sun.COM #if defined(__xpv)
13375084Sjohnlev i = 0;
133810175SStuart.Maybee@Sun.COM
13395084Sjohnlev for (xdip = ddi_get_child(isa_dip); xdip != NULL; ) {
13405084Sjohnlev dev_info_t *curdip;
13415084Sjohnlev
13425084Sjohnlev curdip = xdip;
13435084Sjohnlev xdip = ddi_get_next_sibling(xdip);
134410175SStuart.Maybee@Sun.COM
134510175SStuart.Maybee@Sun.COM if (strncmp(ddi_node_name(curdip), "asy", 3) != 0)
13465084Sjohnlev continue;
134710175SStuart.Maybee@Sun.COM
134810175SStuart.Maybee@Sun.COM if ((i == 0 && console_hypervisor_device == CONS_TTYA) ||
134910175SStuart.Maybee@Sun.COM (i == 1 && console_hypervisor_device == CONS_TTYB)) {
135010175SStuart.Maybee@Sun.COM ret = ndi_devi_free(curdip);
135110175SStuart.Maybee@Sun.COM if (ret != DDI_SUCCESS) {
135210175SStuart.Maybee@Sun.COM cmn_err(CE_WARN,
135310175SStuart.Maybee@Sun.COM "could not remove asy%d node", i);
135410175SStuart.Maybee@Sun.COM }
135510175SStuart.Maybee@Sun.COM
135610175SStuart.Maybee@Sun.COM cmn_err(CE_NOTE, "!asy%d unavailable, reserved"
135710175SStuart.Maybee@Sun.COM " to hypervisor", i);
13585084Sjohnlev }
13595084Sjohnlev
13605084Sjohnlev i++;
13615084Sjohnlev }
136210175SStuart.Maybee@Sun.COM #endif
13632007Sml40262
13642007Sml40262 psm_unmap((caddr_t)bios_data, size);
13652007Sml40262 }
13669226SJudy.Chen@Sun.COM
13679226SJudy.Chen@Sun.COM /*
13689226SJudy.Chen@Sun.COM * Some machine comes with an illegal parallel port size of 3
13699226SJudy.Chen@Sun.COM * bytes in ACPI, even parallel port mode is ECP.
13709226SJudy.Chen@Sun.COM */
13719226SJudy.Chen@Sun.COM #define DEFAULT_PRT_SIZE 8
13729226SJudy.Chen@Sun.COM static void
adjust_prtsz(dev_info_t * isa_dip)13739226SJudy.Chen@Sun.COM adjust_prtsz(dev_info_t *isa_dip)
13749226SJudy.Chen@Sun.COM {
13759226SJudy.Chen@Sun.COM dev_info_t *cdip;
13769226SJudy.Chen@Sun.COM struct regspec *regs_p, *extreg_p;
13779226SJudy.Chen@Sun.COM int regs_len, nreg, i;
13789226SJudy.Chen@Sun.COM char *name;
13799226SJudy.Chen@Sun.COM
13809226SJudy.Chen@Sun.COM for (cdip = ddi_get_child(isa_dip); cdip != NULL;
13819226SJudy.Chen@Sun.COM cdip = ddi_get_next_sibling(cdip)) {
13829226SJudy.Chen@Sun.COM name = ddi_node_name(cdip);
13839226SJudy.Chen@Sun.COM if ((strncmp(name, "lp", 2) != 0) || (strnlen(name, 3) != 2))
13849226SJudy.Chen@Sun.COM continue; /* skip non parallel */
13859226SJudy.Chen@Sun.COM
13869226SJudy.Chen@Sun.COM if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, cdip,
13879226SJudy.Chen@Sun.COM DDI_PROP_DONTPASS, "reg", (int **)®s_p,
13889226SJudy.Chen@Sun.COM (uint_t *)®s_len) != DDI_PROP_SUCCESS)
13899226SJudy.Chen@Sun.COM continue;
13909226SJudy.Chen@Sun.COM
13919226SJudy.Chen@Sun.COM nreg = regs_len / (sizeof (struct regspec) / sizeof (int));
13929226SJudy.Chen@Sun.COM for (i = 0; i < nreg; i++) {
13939226SJudy.Chen@Sun.COM if (regs_p[i].regspec_size == DEFAULT_PRT_SIZE)
13949226SJudy.Chen@Sun.COM continue;
13959226SJudy.Chen@Sun.COM
13969226SJudy.Chen@Sun.COM ASSERT(isa_extra_count < MAX_EXTRA_RESOURCE);
13979226SJudy.Chen@Sun.COM extreg_p = &isa_extra_resource[isa_extra_count++];
13989226SJudy.Chen@Sun.COM extreg_p->regspec_bustype = ISA_ADDR_IO;
13999226SJudy.Chen@Sun.COM extreg_p->regspec_addr = regs_p[i].regspec_addr;
14009226SJudy.Chen@Sun.COM extreg_p->regspec_size = DEFAULT_PRT_SIZE;
14019226SJudy.Chen@Sun.COM }
14029226SJudy.Chen@Sun.COM
14039226SJudy.Chen@Sun.COM ddi_prop_free(regs_p);
14049226SJudy.Chen@Sun.COM }
14059226SJudy.Chen@Sun.COM }
1406