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*bd5222b6SGarrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org>
230d928757SGary Mills * Copyright (c) 2012 Gary Mills
245cd376e8SJimmy Vetayases * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate /*
287c478bd9Sstevel@tonic-gate * ISA bus nexus driver
297c478bd9Sstevel@tonic-gate */
307c478bd9Sstevel@tonic-gate
317c478bd9Sstevel@tonic-gate #include <sys/types.h>
327c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
337c478bd9Sstevel@tonic-gate #include <sys/conf.h>
347c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
357c478bd9Sstevel@tonic-gate #include <sys/autoconf.h>
367c478bd9Sstevel@tonic-gate #include <sys/errno.h>
377c478bd9Sstevel@tonic-gate #include <sys/debug.h>
387c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
39dffe9ac5Sml40262 #include <sys/psm.h>
407c478bd9Sstevel@tonic-gate #include <sys/ddidmareq.h>
417c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
4237d6e245Slipeng sang - Sun Microsystems - Beijing China #include <sys/ddi_subrdefs.h>
437c478bd9Sstevel@tonic-gate #include <sys/dma_engine.h>
447c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
457c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
467c478bd9Sstevel@tonic-gate #include <sys/sunndi.h>
477c478bd9Sstevel@tonic-gate #include <sys/acpi/acpi_enum.h>
4878323854SJudy Chen #include <sys/mach_intr.h>
4978323854SJudy Chen #include <sys/pci.h>
5078323854SJudy Chen #include <sys/note.h>
51349b53ddSStuart Maybee #include <sys/boot_console.h>
527ff178cdSJimmy Vetayases #include <sys/apic.h>
53843e1988Sjohnlev #if defined(__xpv)
54843e1988Sjohnlev #include <sys/hypervisor.h>
55843e1988Sjohnlev #include <sys/evtchn_impl.h>
56349b53ddSStuart Maybee
570d928757SGary Mills extern int console_hypervisor_dev_type(int *);
58843e1988Sjohnlev #endif
59843e1988Sjohnlev
607ff178cdSJimmy Vetayases
6178323854SJudy Chen extern int pseudo_isa;
627c478bd9Sstevel@tonic-gate extern int isa_resource_setup(void);
6378323854SJudy Chen extern int (*psm_intr_ops)(dev_info_t *, ddi_intr_handle_impl_t *,
6478323854SJudy Chen psm_intr_op_t, int *);
651d6b7b34SJudy Chen extern void pci_register_isa_resources(int, uint32_t, uint32_t);
6637d6e245Slipeng sang - Sun Microsystems - Beijing China static void isa_enumerate(int);
67dffe9ac5Sml40262 static void enumerate_BIOS_serial(dev_info_t *);
681d6b7b34SJudy Chen static void adjust_prtsz(dev_info_t *isa_dip);
6937d6e245Slipeng sang - Sun Microsystems - Beijing China static void isa_create_ranges_prop(dev_info_t *);
70dffe9ac5Sml40262
710d928757SGary Mills #define USED_RESOURCES "used-resources"
720d928757SGary Mills
7378323854SJudy Chen /*
7478323854SJudy Chen * The following typedef is used to represent an entry in the "ranges"
7578323854SJudy Chen * property of a pci-isa bridge device node.
7678323854SJudy Chen */
7778323854SJudy Chen typedef struct {
7878323854SJudy Chen uint32_t child_high;
7978323854SJudy Chen uint32_t child_low;
8078323854SJudy Chen uint32_t parent_high;
8178323854SJudy Chen uint32_t parent_mid;
8278323854SJudy Chen uint32_t parent_low;
8378323854SJudy Chen uint32_t size;
8478323854SJudy Chen } pib_ranges_t;
8578323854SJudy Chen
8678323854SJudy Chen typedef struct {
8778323854SJudy Chen uint32_t base;
8878323854SJudy Chen uint32_t len;
8978323854SJudy Chen } used_ranges_t;
9078323854SJudy Chen
9178323854SJudy Chen #define USED_CELL_SIZE 2 /* 1 byte addr, 1 byte size */
9278323854SJudy Chen #define ISA_ADDR_IO 1 /* IO address space */
9378323854SJudy Chen #define ISA_ADDR_MEM 0 /* memory adress space */
940d928757SGary Mills
957c478bd9Sstevel@tonic-gate /*
967c478bd9Sstevel@tonic-gate * #define ISA_DEBUG 1
977c478bd9Sstevel@tonic-gate */
987c478bd9Sstevel@tonic-gate
990d928757SGary Mills #define num_BIOS_serial 4 /* number of BIOS serial ports to look at */
1000d928757SGary Mills #define min_BIOS_serial 2 /* minimum number of BIOS serial ports */
1010d928757SGary Mills #define COM_ISR 2 /* 16550 intr status register */
1020d928757SGary Mills #define COM_SCR 7 /* 16550 scratch register */
1030d928757SGary Mills
1047c478bd9Sstevel@tonic-gate /*
1051d6b7b34SJudy Chen * For serial ports not enumerated by ACPI, and parallel ports with
1061d6b7b34SJudy Chen * illegal size. Typically, a system can have as many as 4 serial
1071d6b7b34SJudy Chen * ports and 3 parallel ports.
1081d6b7b34SJudy Chen */
1091d6b7b34SJudy Chen #define MAX_EXTRA_RESOURCE 7
1101d6b7b34SJudy Chen static struct regspec isa_extra_resource[MAX_EXTRA_RESOURCE];
1111d6b7b34SJudy Chen static int isa_extra_count = 0;
1121d6b7b34SJudy Chen
1130d928757SGary Mills /* Register definitions for COM1 to COM4. */
1140d928757SGary Mills static struct regspec asy_regs[] = {
1150d928757SGary Mills {1, 0x3f8, 0x8},
1160d928757SGary Mills {1, 0x2f8, 0x8},
1170d928757SGary Mills {1, 0x3e8, 0x8},
1180d928757SGary Mills {1, 0x2e8, 0x8}
1190d928757SGary Mills };
1200d928757SGary Mills
1210d928757SGary Mills /* Serial port interrupt vectors for COM1 to COM4. */
1220d928757SGary Mills static int asy_intrs[] = {0x4, 0x3, 0x4, 0x3};
123563191b4SPaul B. Henson /* Bitfield indicating which interrupts are overridden by eeprom config */
124563191b4SPaul B. Henson static uchar_t asy_intr_override = 0;
1250d928757SGary Mills
1261d6b7b34SJudy Chen /*
1277c478bd9Sstevel@tonic-gate * Local data
1287c478bd9Sstevel@tonic-gate */
1297c478bd9Sstevel@tonic-gate
1307c478bd9Sstevel@tonic-gate static ddi_dma_attr_t ISA_dma_attr = {
1317c478bd9Sstevel@tonic-gate DMA_ATTR_V0,
1327c478bd9Sstevel@tonic-gate (unsigned long long)0,
1337c478bd9Sstevel@tonic-gate (unsigned long long)0x00ffffff,
1347c478bd9Sstevel@tonic-gate 0x0000ffff,
1357c478bd9Sstevel@tonic-gate 1,
1367c478bd9Sstevel@tonic-gate 1,
1377c478bd9Sstevel@tonic-gate 1,
1387c478bd9Sstevel@tonic-gate (unsigned long long)0xffffffff,
1397c478bd9Sstevel@tonic-gate (unsigned long long)0x0000ffff,
1407c478bd9Sstevel@tonic-gate 1,
1417c478bd9Sstevel@tonic-gate 1,
1427c478bd9Sstevel@tonic-gate 0
1437c478bd9Sstevel@tonic-gate };
1447c478bd9Sstevel@tonic-gate
1457c478bd9Sstevel@tonic-gate
1467c478bd9Sstevel@tonic-gate /*
1477c478bd9Sstevel@tonic-gate * Config information
1487c478bd9Sstevel@tonic-gate */
1497c478bd9Sstevel@tonic-gate
1507c478bd9Sstevel@tonic-gate static int
15178323854SJudy Chen isa_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp,
15278323854SJudy Chen off_t offset, off_t len, caddr_t *vaddrp);
15378323854SJudy Chen
15478323854SJudy Chen static int
1557c478bd9Sstevel@tonic-gate isa_dma_allochdl(dev_info_t *, dev_info_t *, ddi_dma_attr_t *,
1567c478bd9Sstevel@tonic-gate int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *);
1577c478bd9Sstevel@tonic-gate
1587c478bd9Sstevel@tonic-gate static int
1597c478bd9Sstevel@tonic-gate isa_dma_mctl(dev_info_t *, dev_info_t *, ddi_dma_handle_t, enum ddi_dma_ctlops,
1607c478bd9Sstevel@tonic-gate off_t *, size_t *, caddr_t *, uint_t);
1617c478bd9Sstevel@tonic-gate
1627c478bd9Sstevel@tonic-gate static int
1637c478bd9Sstevel@tonic-gate isa_ctlops(dev_info_t *, dev_info_t *, ddi_ctl_enum_t, void *, void *);
1647c478bd9Sstevel@tonic-gate
16578323854SJudy Chen static int
16678323854SJudy Chen isa_intr_ops(dev_info_t *pdip, dev_info_t *rdip, ddi_intr_op_t intr_op,
16778323854SJudy Chen ddi_intr_handle_impl_t *hdlp, void *result);
1687ff178cdSJimmy Vetayases static int isa_alloc_intr_fixed(dev_info_t *, ddi_intr_handle_impl_t *, void *);
1697ff178cdSJimmy Vetayases static int isa_free_intr_fixed(dev_info_t *, ddi_intr_handle_impl_t *);
17078323854SJudy Chen
1717c478bd9Sstevel@tonic-gate struct bus_ops isa_bus_ops = {
1727c478bd9Sstevel@tonic-gate BUSO_REV,
17378323854SJudy Chen isa_bus_map,
1747c478bd9Sstevel@tonic-gate NULL,
1757c478bd9Sstevel@tonic-gate NULL,
1767c478bd9Sstevel@tonic-gate NULL,
1777c478bd9Sstevel@tonic-gate i_ddi_map_fault,
178cd21e7c5SGarrett D'Amore NULL,
1797c478bd9Sstevel@tonic-gate isa_dma_allochdl,
1807c478bd9Sstevel@tonic-gate ddi_dma_freehdl,
1817c478bd9Sstevel@tonic-gate ddi_dma_bindhdl,
1827c478bd9Sstevel@tonic-gate ddi_dma_unbindhdl,
1837c478bd9Sstevel@tonic-gate ddi_dma_flush,
1847c478bd9Sstevel@tonic-gate ddi_dma_win,
1857c478bd9Sstevel@tonic-gate isa_dma_mctl,
1867c478bd9Sstevel@tonic-gate isa_ctlops,
1877c478bd9Sstevel@tonic-gate ddi_bus_prop_op,
1887c478bd9Sstevel@tonic-gate NULL, /* (*bus_get_eventcookie)(); */
1897c478bd9Sstevel@tonic-gate NULL, /* (*bus_add_eventcall)(); */
1907c478bd9Sstevel@tonic-gate NULL, /* (*bus_remove_eventcall)(); */
1917c478bd9Sstevel@tonic-gate NULL, /* (*bus_post_event)(); */
1927c478bd9Sstevel@tonic-gate NULL, /* (*bus_intr_ctl)(); */
1937c478bd9Sstevel@tonic-gate NULL, /* (*bus_config)(); */
1947c478bd9Sstevel@tonic-gate NULL, /* (*bus_unconfig)(); */
1957c478bd9Sstevel@tonic-gate NULL, /* (*bus_fm_init)(); */
1967c478bd9Sstevel@tonic-gate NULL, /* (*bus_fm_fini)(); */
1977c478bd9Sstevel@tonic-gate NULL, /* (*bus_fm_access_enter)(); */
1987c478bd9Sstevel@tonic-gate NULL, /* (*bus_fm_access_exit)(); */
1997c478bd9Sstevel@tonic-gate NULL, /* (*bus_power)(); */
20078323854SJudy Chen isa_intr_ops /* (*bus_intr_op)(); */
2017c478bd9Sstevel@tonic-gate };
2027c478bd9Sstevel@tonic-gate
2037c478bd9Sstevel@tonic-gate
2047c478bd9Sstevel@tonic-gate static int isa_attach(dev_info_t *devi, ddi_attach_cmd_t cmd);
2057c478bd9Sstevel@tonic-gate
2067c478bd9Sstevel@tonic-gate /*
2077c478bd9Sstevel@tonic-gate * Internal isa ctlops support routines
2087c478bd9Sstevel@tonic-gate */
2097c478bd9Sstevel@tonic-gate static int isa_initchild(dev_info_t *child);
2107c478bd9Sstevel@tonic-gate
2117c478bd9Sstevel@tonic-gate struct dev_ops isa_ops = {
2127c478bd9Sstevel@tonic-gate DEVO_REV, /* devo_rev, */
2137c478bd9Sstevel@tonic-gate 0, /* refcnt */
2147c478bd9Sstevel@tonic-gate ddi_no_info, /* info */
2157c478bd9Sstevel@tonic-gate nulldev, /* identify */
2167c478bd9Sstevel@tonic-gate nulldev, /* probe */
2177c478bd9Sstevel@tonic-gate isa_attach, /* attach */
21878323854SJudy Chen nulldev, /* detach */
2197c478bd9Sstevel@tonic-gate nodev, /* reset */
2207c478bd9Sstevel@tonic-gate (struct cb_ops *)0, /* driver operations */
22119397407SSherry Moore &isa_bus_ops, /* bus operations */
22219397407SSherry Moore NULL, /* power */
22319397407SSherry Moore ddi_quiesce_not_needed, /* quiesce */
2247c478bd9Sstevel@tonic-gate };
2257c478bd9Sstevel@tonic-gate
2267c478bd9Sstevel@tonic-gate /*
2277c478bd9Sstevel@tonic-gate * Module linkage information for the kernel.
2287c478bd9Sstevel@tonic-gate */
2297c478bd9Sstevel@tonic-gate
2307c478bd9Sstevel@tonic-gate static struct modldrv modldrv = {
2317c478bd9Sstevel@tonic-gate &mod_driverops, /* Type of module. This is ISA bus driver */
232613b2871SRichard Bean "isa nexus driver for 'ISA'",
2337c478bd9Sstevel@tonic-gate &isa_ops, /* driver ops */
2347c478bd9Sstevel@tonic-gate };
2357c478bd9Sstevel@tonic-gate
2367c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = {
2377c478bd9Sstevel@tonic-gate MODREV_1,
2387c478bd9Sstevel@tonic-gate &modldrv,
2397c478bd9Sstevel@tonic-gate NULL
2407c478bd9Sstevel@tonic-gate };
2417c478bd9Sstevel@tonic-gate
2427c478bd9Sstevel@tonic-gate int
_init(void)2437c478bd9Sstevel@tonic-gate _init(void)
2447c478bd9Sstevel@tonic-gate {
24537d6e245Slipeng sang - Sun Microsystems - Beijing China int err;
246563191b4SPaul B. Henson char tty_irq_param[9] = "ttyX-irq";
247563191b4SPaul B. Henson char *tty_irq;
248563191b4SPaul B. Henson int i;
24937d6e245Slipeng sang - Sun Microsystems - Beijing China
25037d6e245Slipeng sang - Sun Microsystems - Beijing China if ((err = mod_install(&modlinkage)) != 0)
25137d6e245Slipeng sang - Sun Microsystems - Beijing China return (err);
25237d6e245Slipeng sang - Sun Microsystems - Beijing China
253563191b4SPaul B. Henson /* Check if any tty irqs are overridden by eeprom config */
254563191b4SPaul B. Henson for (i = 0; i < num_BIOS_serial; i++) {
255563191b4SPaul B. Henson tty_irq_param[3] = 'a' + i;
256563191b4SPaul B. Henson if (ddi_prop_lookup_string(DDI_DEV_T_ANY, ddi_root_node(),
257563191b4SPaul B. Henson DDI_PROP_DONTPASS, tty_irq_param, &tty_irq)
258563191b4SPaul B. Henson == DDI_PROP_SUCCESS) {
259563191b4SPaul B. Henson long data;
260563191b4SPaul B. Henson
261563191b4SPaul B. Henson if (ddi_strtol(tty_irq, NULL, 0, &data) == 0) {
262563191b4SPaul B. Henson asy_intrs[i] = (int)data;
263563191b4SPaul B. Henson asy_intr_override |= 1<<i;
264563191b4SPaul B. Henson }
265563191b4SPaul B. Henson
266563191b4SPaul B. Henson ddi_prop_free(tty_irq);
267563191b4SPaul B. Henson }
268563191b4SPaul B. Henson }
269563191b4SPaul B. Henson
27037d6e245Slipeng sang - Sun Microsystems - Beijing China impl_bus_add_probe(isa_enumerate);
27137d6e245Slipeng sang - Sun Microsystems - Beijing China return (0);
2727c478bd9Sstevel@tonic-gate }
2737c478bd9Sstevel@tonic-gate
2747c478bd9Sstevel@tonic-gate int
_fini(void)2757c478bd9Sstevel@tonic-gate _fini(void)
2767c478bd9Sstevel@tonic-gate {
27737d6e245Slipeng sang - Sun Microsystems - Beijing China int err;
27837d6e245Slipeng sang - Sun Microsystems - Beijing China
27937d6e245Slipeng sang - Sun Microsystems - Beijing China impl_bus_delete_probe(isa_enumerate);
28037d6e245Slipeng sang - Sun Microsystems - Beijing China
28137d6e245Slipeng sang - Sun Microsystems - Beijing China if ((err = mod_remove(&modlinkage)) != 0)
28237d6e245Slipeng sang - Sun Microsystems - Beijing China return (err);
28337d6e245Slipeng sang - Sun Microsystems - Beijing China
28437d6e245Slipeng sang - Sun Microsystems - Beijing China return (0);
2857c478bd9Sstevel@tonic-gate }
2867c478bd9Sstevel@tonic-gate
2877c478bd9Sstevel@tonic-gate int
_info(struct modinfo * modinfop)2887c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop)
2897c478bd9Sstevel@tonic-gate {
2907c478bd9Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop));
2917c478bd9Sstevel@tonic-gate }
2927c478bd9Sstevel@tonic-gate
2937c478bd9Sstevel@tonic-gate static int
isa_attach(dev_info_t * devi,ddi_attach_cmd_t cmd)2947c478bd9Sstevel@tonic-gate isa_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
2957c478bd9Sstevel@tonic-gate {
2967c478bd9Sstevel@tonic-gate int rval;
2977c478bd9Sstevel@tonic-gate
298843e1988Sjohnlev #if defined(__xpv)
299843e1988Sjohnlev /*
300843e1988Sjohnlev * don't allow isa to attach in domU. this can happen if someone sets
301843e1988Sjohnlev * the console wrong, etc. ISA devices assume the H/W is there and
302843e1988Sjohnlev * will cause the domU to panic.
303843e1988Sjohnlev */
304843e1988Sjohnlev if (!DOMAIN_IS_INITDOMAIN(xen_info)) {
305843e1988Sjohnlev return (DDI_FAILURE);
306843e1988Sjohnlev }
307843e1988Sjohnlev #endif
308843e1988Sjohnlev
30978323854SJudy Chen switch (cmd) {
31078323854SJudy Chen case DDI_ATTACH:
31178323854SJudy Chen break;
31278323854SJudy Chen case DDI_RESUME:
31378323854SJudy Chen return (DDI_SUCCESS);
31478323854SJudy Chen default:
3157c478bd9Sstevel@tonic-gate return (DDI_FAILURE);
31678323854SJudy Chen }
3177c478bd9Sstevel@tonic-gate
31837d6e245Slipeng sang - Sun Microsystems - Beijing China if ((rval = i_dmae_init(devi)) == DDI_SUCCESS)
3197c478bd9Sstevel@tonic-gate ddi_report_dev(devi);
32078323854SJudy Chen
3217c478bd9Sstevel@tonic-gate return (rval);
3227c478bd9Sstevel@tonic-gate }
3237c478bd9Sstevel@tonic-gate
32478323854SJudy Chen #define SET_RNGS(rng_p, used_p, ctyp, ptyp) do { \
32578323854SJudy Chen (rng_p)->child_high = (ctyp); \
32678323854SJudy Chen (rng_p)->child_low = (rng_p)->parent_low = (used_p)->base; \
32778323854SJudy Chen (rng_p)->parent_high = (ptyp); \
32878323854SJudy Chen (rng_p)->parent_mid = 0; \
32978323854SJudy Chen (rng_p)->size = (used_p)->len; \
33078323854SJudy Chen _NOTE(CONSTCOND) } while (0)
33178323854SJudy Chen static uint_t
isa_used_to_ranges(int ctype,int * array,uint_t size,pib_ranges_t * ranges)33278323854SJudy Chen isa_used_to_ranges(int ctype, int *array, uint_t size, pib_ranges_t *ranges)
33378323854SJudy Chen {
33478323854SJudy Chen used_ranges_t *used_p;
33578323854SJudy Chen pib_ranges_t *rng_p = ranges;
33678323854SJudy Chen uint_t i, ptype;
33778323854SJudy Chen
33878323854SJudy Chen ptype = (ctype == ISA_ADDR_IO) ? PCI_ADDR_IO : PCI_ADDR_MEM32;
33978323854SJudy Chen ptype |= PCI_REG_REL_M;
34078323854SJudy Chen size /= USED_CELL_SIZE;
34178323854SJudy Chen used_p = (used_ranges_t *)array;
34278323854SJudy Chen SET_RNGS(rng_p, used_p, ctype, ptype);
34378323854SJudy Chen for (i = 1, used_p++; i < size; i++, used_p++) {
34478323854SJudy Chen /* merge ranges record if applicable */
34578323854SJudy Chen if (rng_p->child_low + rng_p->size == used_p->base)
34678323854SJudy Chen rng_p->size += used_p->len;
34778323854SJudy Chen else {
34878323854SJudy Chen rng_p++;
34978323854SJudy Chen SET_RNGS(rng_p, used_p, ctype, ptype);
35078323854SJudy Chen }
35178323854SJudy Chen }
35278323854SJudy Chen return (rng_p - ranges + 1);
35378323854SJudy Chen }
35478323854SJudy Chen
35578323854SJudy Chen void
isa_remove_res_from_pci(int type,int * array,uint_t size)35678323854SJudy Chen isa_remove_res_from_pci(int type, int *array, uint_t size)
35778323854SJudy Chen {
35878323854SJudy Chen int i;
35978323854SJudy Chen used_ranges_t *used_p;
36078323854SJudy Chen
36178323854SJudy Chen size /= USED_CELL_SIZE;
36278323854SJudy Chen used_p = (used_ranges_t *)array;
36378323854SJudy Chen for (i = 0; i < size; i++, used_p++)
3641d6b7b34SJudy Chen pci_register_isa_resources(type, used_p->base, used_p->len);
36578323854SJudy Chen }
36678323854SJudy Chen
36778323854SJudy Chen static void
isa_create_ranges_prop(dev_info_t * dip)36837d6e245Slipeng sang - Sun Microsystems - Beijing China isa_create_ranges_prop(dev_info_t *dip)
36978323854SJudy Chen {
37078323854SJudy Chen dev_info_t *used;
37178323854SJudy Chen int *ioarray, *memarray, status;
37278323854SJudy Chen uint_t nio = 0, nmem = 0, nrng = 0, n;
37378323854SJudy Chen pib_ranges_t *ranges;
37478323854SJudy Chen
3750d928757SGary Mills used = ddi_find_devinfo(USED_RESOURCES, -1, 0);
37678323854SJudy Chen if (used == NULL) {
37778323854SJudy Chen cmn_err(CE_WARN, "Failed to find used-resources <%s>\n",
37878323854SJudy Chen ddi_get_name(dip));
37978323854SJudy Chen return;
38078323854SJudy Chen }
38178323854SJudy Chen status = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, used,
38278323854SJudy Chen DDI_PROP_DONTPASS, "io-space", &ioarray, &nio);
38378323854SJudy Chen if (status != DDI_PROP_SUCCESS && status != DDI_PROP_NOT_FOUND) {
38478323854SJudy Chen cmn_err(CE_WARN, "io-space property failure for %s (%x)\n",
38578323854SJudy Chen ddi_get_name(used), status);
38678323854SJudy Chen return;
38778323854SJudy Chen }
38878323854SJudy Chen status = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, used,
38978323854SJudy Chen DDI_PROP_DONTPASS, "device-memory", &memarray, &nmem);
39078323854SJudy Chen if (status != DDI_PROP_SUCCESS && status != DDI_PROP_NOT_FOUND) {
39178323854SJudy Chen cmn_err(CE_WARN, "device-memory property failure for %s (%x)\n",
39278323854SJudy Chen ddi_get_name(used), status);
39378323854SJudy Chen return;
39478323854SJudy Chen }
39578323854SJudy Chen n = (nio + nmem) / USED_CELL_SIZE;
39678323854SJudy Chen ranges = (pib_ranges_t *)kmem_zalloc(sizeof (pib_ranges_t) * n,
39778323854SJudy Chen KM_SLEEP);
39878323854SJudy Chen
39978323854SJudy Chen if (nio != 0) {
40078323854SJudy Chen nrng = isa_used_to_ranges(ISA_ADDR_IO, ioarray, nio, ranges);
40178323854SJudy Chen isa_remove_res_from_pci(ISA_ADDR_IO, ioarray, nio);
40278323854SJudy Chen ddi_prop_free(ioarray);
40378323854SJudy Chen }
40478323854SJudy Chen if (nmem != 0) {
40578323854SJudy Chen nrng += isa_used_to_ranges(ISA_ADDR_MEM, memarray, nmem,
40678323854SJudy Chen ranges + nrng);
40778323854SJudy Chen isa_remove_res_from_pci(ISA_ADDR_MEM, memarray, nmem);
40878323854SJudy Chen ddi_prop_free(memarray);
40978323854SJudy Chen }
41078323854SJudy Chen
4111d6b7b34SJudy Chen if (!pseudo_isa)
41278323854SJudy Chen (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, dip, "ranges",
41378323854SJudy Chen (int *)ranges, nrng * sizeof (pib_ranges_t) / sizeof (int));
41478323854SJudy Chen kmem_free(ranges, sizeof (pib_ranges_t) * n);
41578323854SJudy Chen }
41678323854SJudy Chen
41778323854SJudy Chen /*ARGSUSED*/
41878323854SJudy Chen static int
isa_apply_range(dev_info_t * dip,struct regspec * isa_reg_p,pci_regspec_t * pci_reg_p)41978323854SJudy Chen isa_apply_range(dev_info_t *dip, struct regspec *isa_reg_p,
42078323854SJudy Chen pci_regspec_t *pci_reg_p)
42178323854SJudy Chen {
42278323854SJudy Chen pib_ranges_t *ranges, *rng_p;
42378323854SJudy Chen int len, i, offset, nrange;
42478323854SJudy Chen
42578323854SJudy Chen if (ddi_getlongprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
42678323854SJudy Chen "ranges", (caddr_t)&ranges, &len) != DDI_SUCCESS) {
42778323854SJudy Chen cmn_err(CE_WARN, "Can't get %s ranges property",
42878323854SJudy Chen ddi_get_name(dip));
42978323854SJudy Chen return (DDI_ME_REGSPEC_RANGE);
43078323854SJudy Chen }
43178323854SJudy Chen nrange = len / sizeof (pib_ranges_t);
43278323854SJudy Chen rng_p = ranges;
43378323854SJudy Chen for (i = 0; i < nrange; i++, rng_p++) {
43478323854SJudy Chen /* Check for correct space */
43578323854SJudy Chen if (isa_reg_p->regspec_bustype != rng_p->child_high)
43678323854SJudy Chen continue;
43778323854SJudy Chen
43878323854SJudy Chen /* Detect whether request entirely fits within a range */
43978323854SJudy Chen if (isa_reg_p->regspec_addr < rng_p->child_low)
44078323854SJudy Chen continue;
4412273e7c7SJudy Chen if ((isa_reg_p->regspec_addr + isa_reg_p->regspec_size - 1) >
4422273e7c7SJudy Chen (rng_p->child_low + rng_p->size - 1))
44378323854SJudy Chen continue;
44478323854SJudy Chen
44578323854SJudy Chen offset = isa_reg_p->regspec_addr - rng_p->child_low;
44678323854SJudy Chen
44778323854SJudy Chen pci_reg_p->pci_phys_hi = rng_p->parent_high;
44878323854SJudy Chen pci_reg_p->pci_phys_mid = 0;
44978323854SJudy Chen pci_reg_p->pci_phys_low = rng_p->parent_low + offset;
45078323854SJudy Chen pci_reg_p->pci_size_hi = 0;
45178323854SJudy Chen pci_reg_p->pci_size_low = isa_reg_p->regspec_size;
45278323854SJudy Chen
45378323854SJudy Chen break;
45478323854SJudy Chen }
45578323854SJudy Chen kmem_free(ranges, len);
45678323854SJudy Chen
4571d6b7b34SJudy Chen if (i < nrange)
45878323854SJudy Chen return (DDI_SUCCESS);
4591d6b7b34SJudy Chen
4601d6b7b34SJudy Chen /*
4611d6b7b34SJudy Chen * Check extra resource range specially for serial and parallel
4621d6b7b34SJudy Chen * devices, which are treated differently from all other ISA
4631d6b7b34SJudy Chen * devices. On some machines, serial ports are not enumerated
4641d6b7b34SJudy Chen * by ACPI but by BIOS, with io base addresses noted in legacy
4651d6b7b34SJudy Chen * BIOS data area. Parallel port on some machines comes with
4661d6b7b34SJudy Chen * illegal size.
4671d6b7b34SJudy Chen */
4680d928757SGary Mills if (isa_reg_p->regspec_bustype != ISA_ADDR_IO) {
4690d928757SGary Mills cmn_err(CE_WARN, "Bus type not ISA I/O\n");
4700d928757SGary Mills return (DDI_ME_REGSPEC_RANGE);
4710d928757SGary Mills }
4721d6b7b34SJudy Chen
4731d6b7b34SJudy Chen for (i = 0; i < isa_extra_count; i++) {
4741d6b7b34SJudy Chen struct regspec *reg_p = &isa_extra_resource[i];
4751d6b7b34SJudy Chen
4761d6b7b34SJudy Chen if (isa_reg_p->regspec_addr < reg_p->regspec_addr)
4771d6b7b34SJudy Chen continue;
4781d6b7b34SJudy Chen if ((isa_reg_p->regspec_addr + isa_reg_p->regspec_size) >
4791d6b7b34SJudy Chen (reg_p->regspec_addr + reg_p->regspec_size))
4801d6b7b34SJudy Chen continue;
4811d6b7b34SJudy Chen
4821d6b7b34SJudy Chen pci_reg_p->pci_phys_hi = PCI_ADDR_IO | PCI_REG_REL_M;
4831d6b7b34SJudy Chen pci_reg_p->pci_phys_mid = 0;
4841d6b7b34SJudy Chen pci_reg_p->pci_phys_low = isa_reg_p->regspec_addr;
4851d6b7b34SJudy Chen pci_reg_p->pci_size_hi = 0;
4861d6b7b34SJudy Chen pci_reg_p->pci_size_low = isa_reg_p->regspec_size;
4871d6b7b34SJudy Chen break;
4881d6b7b34SJudy Chen }
4891d6b7b34SJudy Chen if (i < isa_extra_count)
4901d6b7b34SJudy Chen return (DDI_SUCCESS);
4911d6b7b34SJudy Chen
4921d6b7b34SJudy Chen cmn_err(CE_WARN, "isa_apply_range: Out of range base <0x%x>, size <%d>",
4931d6b7b34SJudy Chen isa_reg_p->regspec_addr, isa_reg_p->regspec_size);
4941d6b7b34SJudy Chen return (DDI_ME_REGSPEC_RANGE);
49578323854SJudy Chen }
49678323854SJudy Chen
49778323854SJudy Chen 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)49878323854SJudy Chen isa_bus_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp,
49978323854SJudy Chen off_t offset, off_t len, caddr_t *vaddrp)
50078323854SJudy Chen {
50178323854SJudy Chen struct regspec tmp_reg, *rp;
50278323854SJudy Chen pci_regspec_t vreg;
50378323854SJudy Chen ddi_map_req_t mr = *mp; /* Get private copy of request */
50478323854SJudy Chen int error;
50578323854SJudy Chen
50678323854SJudy Chen if (pseudo_isa)
50778323854SJudy Chen return (i_ddi_bus_map(dip, rdip, mp, offset, len, vaddrp));
50878323854SJudy Chen
50978323854SJudy Chen mp = &mr;
51078323854SJudy Chen
51178323854SJudy Chen /*
51278323854SJudy Chen * First, if given an rnumber, convert it to a regspec...
51378323854SJudy Chen */
51478323854SJudy Chen if (mp->map_type == DDI_MT_RNUMBER) {
51578323854SJudy Chen
51678323854SJudy Chen int rnumber = mp->map_obj.rnumber;
51778323854SJudy Chen
51878323854SJudy Chen rp = i_ddi_rnumber_to_regspec(rdip, rnumber);
51978323854SJudy Chen if (rp == (struct regspec *)0)
52078323854SJudy Chen return (DDI_ME_RNUMBER_RANGE);
52178323854SJudy Chen
52278323854SJudy Chen /*
52378323854SJudy Chen * Convert the given ddi_map_req_t from rnumber to regspec...
52478323854SJudy Chen */
52578323854SJudy Chen mp->map_type = DDI_MT_REGSPEC;
52678323854SJudy Chen mp->map_obj.rp = rp;
52778323854SJudy Chen }
52878323854SJudy Chen
52978323854SJudy Chen /*
53078323854SJudy Chen * Adjust offset and length correspnding to called values...
53178323854SJudy Chen * XXX: A non-zero length means override the one in the regspec.
53278323854SJudy Chen * XXX: (Regardless of what's in the parent's range)
53378323854SJudy Chen */
53478323854SJudy Chen
53578323854SJudy Chen tmp_reg = *(mp->map_obj.rp); /* Preserve underlying data */
53678323854SJudy Chen rp = mp->map_obj.rp = &tmp_reg; /* Use tmp_reg in request */
53778323854SJudy Chen
53878323854SJudy Chen rp->regspec_addr += (uint_t)offset;
53978323854SJudy Chen if (len != 0)
54078323854SJudy Chen rp->regspec_size = (uint_t)len;
54178323854SJudy Chen
54278323854SJudy Chen if ((error = isa_apply_range(dip, rp, &vreg)) != 0)
54378323854SJudy Chen return (error);
54478323854SJudy Chen mp->map_obj.rp = (struct regspec *)&vreg;
54578323854SJudy Chen
54678323854SJudy Chen /*
54778323854SJudy Chen * Call my parents bus_map function with modified values...
54878323854SJudy Chen */
54978323854SJudy Chen
55078323854SJudy Chen return (ddi_map(dip, mp, (off_t)0, (off_t)0, vaddrp));
55178323854SJudy Chen }
55278323854SJudy Chen
5537c478bd9Sstevel@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)5547c478bd9Sstevel@tonic-gate isa_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *dma_attr,
5557c478bd9Sstevel@tonic-gate int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep)
5567c478bd9Sstevel@tonic-gate {
5577c478bd9Sstevel@tonic-gate ddi_dma_attr_merge(dma_attr, &ISA_dma_attr);
5587c478bd9Sstevel@tonic-gate return (ddi_dma_allochdl(dip, rdip, dma_attr, waitfp, arg, handlep));
5597c478bd9Sstevel@tonic-gate }
5607c478bd9Sstevel@tonic-gate
5617c478bd9Sstevel@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)5627c478bd9Sstevel@tonic-gate isa_dma_mctl(dev_info_t *dip, dev_info_t *rdip,
5637c478bd9Sstevel@tonic-gate ddi_dma_handle_t handle, enum ddi_dma_ctlops request,
5647c478bd9Sstevel@tonic-gate off_t *offp, size_t *lenp, caddr_t *objp, uint_t flags)
5657c478bd9Sstevel@tonic-gate {
5667c478bd9Sstevel@tonic-gate int rval;
5677c478bd9Sstevel@tonic-gate int arg = (int)(uintptr_t)objp;
5687c478bd9Sstevel@tonic-gate
5697c478bd9Sstevel@tonic-gate switch (request) {
5707c478bd9Sstevel@tonic-gate
5717c478bd9Sstevel@tonic-gate case DDI_DMA_E_PROG:
5727c478bd9Sstevel@tonic-gate return (i_dmae_prog(rdip, (struct ddi_dmae_req *)offp,
5737c478bd9Sstevel@tonic-gate (ddi_dma_cookie_t *)lenp, arg));
5747c478bd9Sstevel@tonic-gate
5757c478bd9Sstevel@tonic-gate case DDI_DMA_E_ACQUIRE:
5767c478bd9Sstevel@tonic-gate return (i_dmae_acquire(rdip, arg, (int(*)(caddr_t))offp,
5777c478bd9Sstevel@tonic-gate (caddr_t)lenp));
5787c478bd9Sstevel@tonic-gate
5797c478bd9Sstevel@tonic-gate case DDI_DMA_E_FREE:
5807c478bd9Sstevel@tonic-gate return (i_dmae_free(rdip, arg));
5817c478bd9Sstevel@tonic-gate
5827c478bd9Sstevel@tonic-gate case DDI_DMA_E_STOP:
5837c478bd9Sstevel@tonic-gate i_dmae_stop(rdip, arg);
5847c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
5857c478bd9Sstevel@tonic-gate
5867c478bd9Sstevel@tonic-gate case DDI_DMA_E_ENABLE:
5877c478bd9Sstevel@tonic-gate i_dmae_enable(rdip, arg);
5887c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
5897c478bd9Sstevel@tonic-gate
5907c478bd9Sstevel@tonic-gate case DDI_DMA_E_DISABLE:
5917c478bd9Sstevel@tonic-gate i_dmae_disable(rdip, arg);
5927c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
5937c478bd9Sstevel@tonic-gate
5947c478bd9Sstevel@tonic-gate case DDI_DMA_E_GETCNT:
5957c478bd9Sstevel@tonic-gate i_dmae_get_chan_stat(rdip, arg, NULL, (int *)lenp);
5967c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
5977c478bd9Sstevel@tonic-gate
5987c478bd9Sstevel@tonic-gate case DDI_DMA_E_SWSETUP:
5997c478bd9Sstevel@tonic-gate return (i_dmae_swsetup(rdip, (struct ddi_dmae_req *)offp,
6007c478bd9Sstevel@tonic-gate (ddi_dma_cookie_t *)lenp, arg));
6017c478bd9Sstevel@tonic-gate
6027c478bd9Sstevel@tonic-gate case DDI_DMA_E_SWSTART:
6037c478bd9Sstevel@tonic-gate i_dmae_swstart(rdip, arg);
6047c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
6057c478bd9Sstevel@tonic-gate
6067c478bd9Sstevel@tonic-gate case DDI_DMA_E_GETATTR:
6077c478bd9Sstevel@tonic-gate bcopy(&ISA_dma_attr, objp, sizeof (ddi_dma_attr_t));
6087c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
6097c478bd9Sstevel@tonic-gate
6107c478bd9Sstevel@tonic-gate case DDI_DMA_E_1STPTY:
6117c478bd9Sstevel@tonic-gate {
6127c478bd9Sstevel@tonic-gate struct ddi_dmae_req req1stpty =
6137c478bd9Sstevel@tonic-gate { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
6147c478bd9Sstevel@tonic-gate if (arg == 0) {
6157c478bd9Sstevel@tonic-gate req1stpty.der_command = DMAE_CMD_TRAN;
6167c478bd9Sstevel@tonic-gate req1stpty.der_trans = DMAE_TRANS_DMND;
6177c478bd9Sstevel@tonic-gate } else {
6187c478bd9Sstevel@tonic-gate req1stpty.der_trans = DMAE_TRANS_CSCD;
6197c478bd9Sstevel@tonic-gate }
6207c478bd9Sstevel@tonic-gate return (i_dmae_prog(rdip, &req1stpty, NULL, arg));
6217c478bd9Sstevel@tonic-gate }
6227c478bd9Sstevel@tonic-gate
6237c478bd9Sstevel@tonic-gate default:
624*bd5222b6SGarrett D'Amore /*
625*bd5222b6SGarrett D'Amore * We pass to rootnex, but it turns out that rootnex will just
626*bd5222b6SGarrett D'Amore * return failure, as we don't use ddi_dma_mctl() except
627*bd5222b6SGarrett D'Amore * for DMA engine (ISA) and DVMA (SPARC). Arguably we could
628*bd5222b6SGarrett D'Amore * just return an error direclty here, instead.
629*bd5222b6SGarrett D'Amore */
6307c478bd9Sstevel@tonic-gate rval = ddi_dma_mctl(dip, rdip, handle, request, offp,
6317c478bd9Sstevel@tonic-gate lenp, objp, flags);
6327c478bd9Sstevel@tonic-gate }
6337c478bd9Sstevel@tonic-gate return (rval);
6347c478bd9Sstevel@tonic-gate }
6357c478bd9Sstevel@tonic-gate
6367c478bd9Sstevel@tonic-gate /*
6377c478bd9Sstevel@tonic-gate * Check if driver should be treated as an old pre 2.6 driver
6387c478bd9Sstevel@tonic-gate */
6397c478bd9Sstevel@tonic-gate static int
old_driver(dev_info_t * dip)6407c478bd9Sstevel@tonic-gate old_driver(dev_info_t *dip)
6417c478bd9Sstevel@tonic-gate {
6427c478bd9Sstevel@tonic-gate extern int ignore_hardware_nodes; /* force flag from ddi_impl.c */
6437c478bd9Sstevel@tonic-gate
6447c478bd9Sstevel@tonic-gate if (ndi_dev_is_persistent_node(dip)) {
6457c478bd9Sstevel@tonic-gate if (ignore_hardware_nodes)
6467c478bd9Sstevel@tonic-gate return (1);
6477c478bd9Sstevel@tonic-gate if (ddi_getprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS,
6487c478bd9Sstevel@tonic-gate "ignore-hardware-nodes", -1) != -1)
6497c478bd9Sstevel@tonic-gate return (1);
6507c478bd9Sstevel@tonic-gate }
6517c478bd9Sstevel@tonic-gate return (0);
6527c478bd9Sstevel@tonic-gate }
6537c478bd9Sstevel@tonic-gate
6547c478bd9Sstevel@tonic-gate typedef struct {
6557c478bd9Sstevel@tonic-gate uint32_t phys_hi;
6567c478bd9Sstevel@tonic-gate uint32_t phys_lo;
6577c478bd9Sstevel@tonic-gate uint32_t size;
6587c478bd9Sstevel@tonic-gate } isa_regs_t;
6597c478bd9Sstevel@tonic-gate
6607c478bd9Sstevel@tonic-gate /*
6617c478bd9Sstevel@tonic-gate * Return non-zero if device in tree is a PnP isa device
6627c478bd9Sstevel@tonic-gate */
6637c478bd9Sstevel@tonic-gate static int
is_pnpisa(dev_info_t * dip)6647c478bd9Sstevel@tonic-gate is_pnpisa(dev_info_t *dip)
6657c478bd9Sstevel@tonic-gate {
6667c478bd9Sstevel@tonic-gate isa_regs_t *isa_regs;
6677c478bd9Sstevel@tonic-gate int proplen, pnpisa;
6687c478bd9Sstevel@tonic-gate
6697c478bd9Sstevel@tonic-gate if (ddi_getlongprop(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, "reg",
6707c478bd9Sstevel@tonic-gate (caddr_t)&isa_regs, &proplen) != DDI_PROP_SUCCESS) {
6717c478bd9Sstevel@tonic-gate return (0);
6727c478bd9Sstevel@tonic-gate }
6737c478bd9Sstevel@tonic-gate pnpisa = isa_regs[0].phys_hi & 0x80000000;
6747c478bd9Sstevel@tonic-gate /*
6757c478bd9Sstevel@tonic-gate * free the memory allocated by ddi_getlongprop().
6767c478bd9Sstevel@tonic-gate */
6777c478bd9Sstevel@tonic-gate kmem_free(isa_regs, proplen);
6787c478bd9Sstevel@tonic-gate if (pnpisa)
6797c478bd9Sstevel@tonic-gate return (1);
6807c478bd9Sstevel@tonic-gate else
6817c478bd9Sstevel@tonic-gate return (0);
6827c478bd9Sstevel@tonic-gate }
6837c478bd9Sstevel@tonic-gate
6847c478bd9Sstevel@tonic-gate /*ARGSUSED*/
6857c478bd9Sstevel@tonic-gate static int
isa_ctlops(dev_info_t * dip,dev_info_t * rdip,ddi_ctl_enum_t ctlop,void * arg,void * result)6867c478bd9Sstevel@tonic-gate isa_ctlops(dev_info_t *dip, dev_info_t *rdip,
6877c478bd9Sstevel@tonic-gate ddi_ctl_enum_t ctlop, void *arg, void *result)
6887c478bd9Sstevel@tonic-gate {
68978323854SJudy Chen int rn;
69078323854SJudy Chen struct ddi_parent_private_data *pdp;
69178323854SJudy Chen
6927c478bd9Sstevel@tonic-gate switch (ctlop) {
6937c478bd9Sstevel@tonic-gate case DDI_CTLOPS_REPORTDEV:
6947c478bd9Sstevel@tonic-gate if (rdip == (dev_info_t *)0)
6957c478bd9Sstevel@tonic-gate return (DDI_FAILURE);
6967c478bd9Sstevel@tonic-gate cmn_err(CE_CONT, "?ISA-device: %s%d\n",
6977c478bd9Sstevel@tonic-gate ddi_driver_name(rdip), ddi_get_instance(rdip));
6987c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
6997c478bd9Sstevel@tonic-gate
7007c478bd9Sstevel@tonic-gate case DDI_CTLOPS_INITCHILD:
7017c478bd9Sstevel@tonic-gate /*
7027c478bd9Sstevel@tonic-gate * older drivers aren't expecting the "standard" device
7037c478bd9Sstevel@tonic-gate * node format used by the hardware nodes. these drivers
7047c478bd9Sstevel@tonic-gate * only expect their own properties set in their driver.conf
7057c478bd9Sstevel@tonic-gate * files. so they tell us not to call them with hardware
7067c478bd9Sstevel@tonic-gate * nodes by setting the property "ignore-hardware-nodes".
7077c478bd9Sstevel@tonic-gate */
7087c478bd9Sstevel@tonic-gate if (old_driver((dev_info_t *)arg)) {
7097c478bd9Sstevel@tonic-gate return (DDI_NOT_WELL_FORMED);
7107c478bd9Sstevel@tonic-gate }
7117c478bd9Sstevel@tonic-gate
7127c478bd9Sstevel@tonic-gate return (isa_initchild((dev_info_t *)arg));
7137c478bd9Sstevel@tonic-gate
7147c478bd9Sstevel@tonic-gate case DDI_CTLOPS_UNINITCHILD:
7157c478bd9Sstevel@tonic-gate impl_ddi_sunbus_removechild((dev_info_t *)arg);
7167c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
7177c478bd9Sstevel@tonic-gate
7187c478bd9Sstevel@tonic-gate case DDI_CTLOPS_SIDDEV:
71997caaa36SGuoli Shu if (ndi_dev_is_persistent_node(rdip))
72097caaa36SGuoli Shu return (DDI_SUCCESS);
7217c478bd9Sstevel@tonic-gate /*
7227c478bd9Sstevel@tonic-gate * All ISA devices need to do confirming probes
7237c478bd9Sstevel@tonic-gate * unless they are PnP ISA.
7247c478bd9Sstevel@tonic-gate */
72597caaa36SGuoli Shu if (is_pnpisa(rdip))
7267c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
7277c478bd9Sstevel@tonic-gate else
7287c478bd9Sstevel@tonic-gate return (DDI_FAILURE);
7297c478bd9Sstevel@tonic-gate
73078323854SJudy Chen case DDI_CTLOPS_REGSIZE:
73178323854SJudy Chen case DDI_CTLOPS_NREGS:
73278323854SJudy Chen if (rdip == (dev_info_t *)0)
73378323854SJudy Chen return (DDI_FAILURE);
73478323854SJudy Chen
73578323854SJudy Chen if ((pdp = ddi_get_parent_data(rdip)) == NULL)
73678323854SJudy Chen return (DDI_FAILURE);
73778323854SJudy Chen
73878323854SJudy Chen if (ctlop == DDI_CTLOPS_NREGS) {
73978323854SJudy Chen *(int *)result = pdp->par_nreg;
74078323854SJudy Chen } else {
74178323854SJudy Chen rn = *(int *)arg;
74278323854SJudy Chen if (rn >= pdp->par_nreg)
74378323854SJudy Chen return (DDI_FAILURE);
74478323854SJudy Chen *(off_t *)result = (off_t)pdp->par_reg[rn].regspec_size;
74578323854SJudy Chen }
74678323854SJudy Chen return (DDI_SUCCESS);
74778323854SJudy Chen
74878323854SJudy Chen case DDI_CTLOPS_ATTACH:
74978323854SJudy Chen case DDI_CTLOPS_DETACH:
75078323854SJudy Chen case DDI_CTLOPS_PEEK:
75178323854SJudy Chen case DDI_CTLOPS_POKE:
75278323854SJudy Chen return (DDI_FAILURE);
75378323854SJudy Chen
7547c478bd9Sstevel@tonic-gate default:
7557c478bd9Sstevel@tonic-gate return (ddi_ctlops(dip, rdip, ctlop, arg, result));
7567c478bd9Sstevel@tonic-gate }
7577c478bd9Sstevel@tonic-gate }
7587c478bd9Sstevel@tonic-gate
75978323854SJudy Chen static struct intrspec *
isa_get_ispec(dev_info_t * rdip,int inum)76078323854SJudy Chen isa_get_ispec(dev_info_t *rdip, int inum)
76178323854SJudy Chen {
76278323854SJudy Chen struct ddi_parent_private_data *pdp = ddi_get_parent_data(rdip);
76378323854SJudy Chen
76478323854SJudy Chen /* Validate the interrupt number */
76578323854SJudy Chen if (inum >= pdp->par_nintr)
76678323854SJudy Chen return (NULL);
76778323854SJudy Chen
76878323854SJudy Chen /* Get the interrupt structure pointer and return that */
76978323854SJudy Chen return ((struct intrspec *)&pdp->par_intr[inum]);
77078323854SJudy Chen }
77178323854SJudy Chen
77278323854SJudy Chen 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)77378323854SJudy Chen isa_intr_ops(dev_info_t *pdip, dev_info_t *rdip, ddi_intr_op_t intr_op,
77478323854SJudy Chen ddi_intr_handle_impl_t *hdlp, void *result)
77578323854SJudy Chen {
77678323854SJudy Chen struct intrspec *ispec;
7770d928757SGary Mills #if defined(__xpv)
7780d928757SGary Mills int cons, ttyn;
77978323854SJudy Chen
7800d928757SGary Mills cons = console_hypervisor_dev_type(&ttyn);
7810d928757SGary Mills #endif
78278323854SJudy Chen if (pseudo_isa)
78378323854SJudy Chen return (i_ddi_intr_ops(pdip, rdip, intr_op, hdlp, result));
78478323854SJudy Chen
78578323854SJudy Chen
78678323854SJudy Chen /* Process the interrupt operation */
78778323854SJudy Chen switch (intr_op) {
78878323854SJudy Chen case DDI_INTROP_GETCAP:
78978323854SJudy Chen /* First check with pcplusmp */
79078323854SJudy Chen if (psm_intr_ops == NULL)
79178323854SJudy Chen return (DDI_FAILURE);
79278323854SJudy Chen
79378323854SJudy Chen if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_GET_CAP, result)) {
79478323854SJudy Chen *(int *)result = 0;
79578323854SJudy Chen return (DDI_FAILURE);
79678323854SJudy Chen }
79778323854SJudy Chen break;
79878323854SJudy Chen case DDI_INTROP_SETCAP:
79978323854SJudy Chen if (psm_intr_ops == NULL)
80078323854SJudy Chen return (DDI_FAILURE);
80178323854SJudy Chen
80278323854SJudy Chen if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_SET_CAP, result))
80378323854SJudy Chen return (DDI_FAILURE);
80478323854SJudy Chen break;
80578323854SJudy Chen case DDI_INTROP_ALLOC:
8067ff178cdSJimmy Vetayases ASSERT(hdlp->ih_type == DDI_INTR_TYPE_FIXED);
8077ff178cdSJimmy Vetayases return (isa_alloc_intr_fixed(rdip, hdlp, result));
80878323854SJudy Chen case DDI_INTROP_FREE:
8097ff178cdSJimmy Vetayases ASSERT(hdlp->ih_type == DDI_INTR_TYPE_FIXED);
8107ff178cdSJimmy Vetayases return (isa_free_intr_fixed(rdip, hdlp));
81178323854SJudy Chen case DDI_INTROP_GETPRI:
81278323854SJudy Chen if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL)
81378323854SJudy Chen return (DDI_FAILURE);
81478323854SJudy Chen *(int *)result = ispec->intrspec_pri;
81578323854SJudy Chen break;
81678323854SJudy Chen case DDI_INTROP_SETPRI:
81778323854SJudy Chen /* Validate the interrupt priority passed to us */
81878323854SJudy Chen if (*(int *)result > LOCK_LEVEL)
81978323854SJudy Chen return (DDI_FAILURE);
82078323854SJudy Chen
82178323854SJudy Chen /* Ensure that PSM is all initialized and ispec is ok */
82278323854SJudy Chen if ((psm_intr_ops == NULL) ||
82378323854SJudy Chen ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL))
82478323854SJudy Chen return (DDI_FAILURE);
82578323854SJudy Chen
82678323854SJudy Chen /* update the ispec with the new priority */
82778323854SJudy Chen ispec->intrspec_pri = *(int *)result;
82878323854SJudy Chen break;
82978323854SJudy Chen case DDI_INTROP_ADDISR:
83078323854SJudy Chen if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL)
83178323854SJudy Chen return (DDI_FAILURE);
83278323854SJudy Chen ispec->intrspec_func = hdlp->ih_cb_func;
83378323854SJudy Chen break;
83478323854SJudy Chen case DDI_INTROP_REMISR:
83578323854SJudy Chen if (hdlp->ih_type != DDI_INTR_TYPE_FIXED)
83678323854SJudy Chen return (DDI_FAILURE);
83778323854SJudy Chen if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL)
83878323854SJudy Chen return (DDI_FAILURE);
83978323854SJudy Chen ispec->intrspec_func = (uint_t (*)()) 0;
84078323854SJudy Chen break;
84178323854SJudy Chen case DDI_INTROP_ENABLE:
84278323854SJudy Chen if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL)
84378323854SJudy Chen return (DDI_FAILURE);
84478323854SJudy Chen
84578323854SJudy Chen /* Call psmi to translate irq with the dip */
84678323854SJudy Chen if (psm_intr_ops == NULL)
84778323854SJudy Chen return (DDI_FAILURE);
84878323854SJudy Chen
849349b53ddSStuart Maybee #if defined(__xpv)
850349b53ddSStuart Maybee /*
851349b53ddSStuart Maybee * if the hypervisor is using an isa serial port for the
852349b53ddSStuart Maybee * console, make sure we don't try to use that interrupt as
853349b53ddSStuart Maybee * it will cause us to panic when xen_bind_pirq() fails.
854349b53ddSStuart Maybee */
8550d928757SGary Mills if (cons == CONS_TTY && ispec->intrspec_vec == asy_intrs[ttyn])
856349b53ddSStuart Maybee return (DDI_FAILURE);
857349b53ddSStuart Maybee #endif
85878323854SJudy Chen ((ihdl_plat_t *)hdlp->ih_private)->ip_ispecp = ispec;
85986a9c507SGuoli Shu if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_XLATE_VECTOR,
86086a9c507SGuoli Shu (int *)&hdlp->ih_vector) == PSM_FAILURE)
86186a9c507SGuoli Shu return (DDI_FAILURE);
86278323854SJudy Chen
86378323854SJudy Chen /* Add the interrupt handler */
86478323854SJudy Chen if (!add_avintr((void *)hdlp, ispec->intrspec_pri,
86578323854SJudy Chen hdlp->ih_cb_func, DEVI(rdip)->devi_name, hdlp->ih_vector,
86678323854SJudy Chen hdlp->ih_cb_arg1, hdlp->ih_cb_arg2, NULL, rdip))
86778323854SJudy Chen return (DDI_FAILURE);
86878323854SJudy Chen break;
86978323854SJudy Chen case DDI_INTROP_DISABLE:
87078323854SJudy Chen if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL)
87178323854SJudy Chen return (DDI_FAILURE);
87278323854SJudy Chen
87378323854SJudy Chen /* Call psm_ops() to translate irq with the dip */
87478323854SJudy Chen if (psm_intr_ops == NULL)
87578323854SJudy Chen return (DDI_FAILURE);
87678323854SJudy Chen
87778323854SJudy Chen ((ihdl_plat_t *)hdlp->ih_private)->ip_ispecp = ispec;
87878323854SJudy Chen (void) (*psm_intr_ops)(rdip, hdlp,
87978323854SJudy Chen PSM_INTR_OP_XLATE_VECTOR, (int *)&hdlp->ih_vector);
88078323854SJudy Chen
88178323854SJudy Chen /* Remove the interrupt handler */
88278323854SJudy Chen rem_avintr((void *)hdlp, ispec->intrspec_pri,
88378323854SJudy Chen hdlp->ih_cb_func, hdlp->ih_vector);
88478323854SJudy Chen break;
88578323854SJudy Chen case DDI_INTROP_SETMASK:
88678323854SJudy Chen if (psm_intr_ops == NULL)
88778323854SJudy Chen return (DDI_FAILURE);
88878323854SJudy Chen
88978323854SJudy Chen if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_SET_MASK, NULL))
89078323854SJudy Chen return (DDI_FAILURE);
89178323854SJudy Chen break;
89278323854SJudy Chen case DDI_INTROP_CLRMASK:
89378323854SJudy Chen if (psm_intr_ops == NULL)
89478323854SJudy Chen return (DDI_FAILURE);
89578323854SJudy Chen
89678323854SJudy Chen if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_CLEAR_MASK, NULL))
89778323854SJudy Chen return (DDI_FAILURE);
89878323854SJudy Chen break;
89978323854SJudy Chen case DDI_INTROP_GETPENDING:
90078323854SJudy Chen if (psm_intr_ops == NULL)
90178323854SJudy Chen return (DDI_FAILURE);
90278323854SJudy Chen
90378323854SJudy Chen if ((*psm_intr_ops)(rdip, hdlp, PSM_INTR_OP_GET_PENDING,
90478323854SJudy Chen result)) {
90578323854SJudy Chen *(int *)result = 0;
90678323854SJudy Chen return (DDI_FAILURE);
90778323854SJudy Chen }
90878323854SJudy Chen break;
90978323854SJudy Chen case DDI_INTROP_NAVAIL:
91078323854SJudy Chen case DDI_INTROP_NINTRS:
91178323854SJudy Chen *(int *)result = i_ddi_get_intx_nintrs(rdip);
91278323854SJudy Chen if (*(int *)result == 0) {
91378323854SJudy Chen return (DDI_FAILURE);
91478323854SJudy Chen }
91578323854SJudy Chen break;
91678323854SJudy Chen case DDI_INTROP_SUPPORTED_TYPES:
91778323854SJudy Chen *(int *)result = DDI_INTR_TYPE_FIXED; /* Always ... */
91878323854SJudy Chen break;
91978323854SJudy Chen default:
92078323854SJudy Chen return (DDI_FAILURE);
92178323854SJudy Chen }
92278323854SJudy Chen
92378323854SJudy Chen return (DDI_SUCCESS);
92478323854SJudy Chen }
92578323854SJudy Chen
9267ff178cdSJimmy Vetayases /*
9277ff178cdSJimmy Vetayases * Allocate interrupt vector for FIXED (legacy) type.
9287ff178cdSJimmy Vetayases */
9297ff178cdSJimmy Vetayases static int
isa_alloc_intr_fixed(dev_info_t * rdip,ddi_intr_handle_impl_t * hdlp,void * result)9307ff178cdSJimmy Vetayases isa_alloc_intr_fixed(dev_info_t *rdip, ddi_intr_handle_impl_t *hdlp,
9317ff178cdSJimmy Vetayases void *result)
9327ff178cdSJimmy Vetayases {
9337ff178cdSJimmy Vetayases struct intrspec *ispec;
9347ff178cdSJimmy Vetayases ddi_intr_handle_impl_t info_hdl;
9357ff178cdSJimmy Vetayases int ret;
9367ff178cdSJimmy Vetayases int free_phdl = 0;
9377ff178cdSJimmy Vetayases apic_get_type_t type_info;
9387ff178cdSJimmy Vetayases
9397ff178cdSJimmy Vetayases if (psm_intr_ops == NULL)
9407ff178cdSJimmy Vetayases return (DDI_FAILURE);
9417ff178cdSJimmy Vetayases
9427ff178cdSJimmy Vetayases if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL)
9437ff178cdSJimmy Vetayases return (DDI_FAILURE);
9447ff178cdSJimmy Vetayases
9457ff178cdSJimmy Vetayases /*
9467ff178cdSJimmy Vetayases * If the PSM module is "APIX" then pass the request for it
9477ff178cdSJimmy Vetayases * to allocate the vector now.
9487ff178cdSJimmy Vetayases */
9497ff178cdSJimmy Vetayases bzero(&info_hdl, sizeof (ddi_intr_handle_impl_t));
9507ff178cdSJimmy Vetayases info_hdl.ih_private = &type_info;
9517ff178cdSJimmy Vetayases if ((*psm_intr_ops)(NULL, &info_hdl, PSM_INTR_OP_APIC_TYPE, NULL) ==
9527ff178cdSJimmy Vetayases PSM_SUCCESS && strcmp(type_info.avgi_type, APIC_APIX_NAME) == 0) {
9537ff178cdSJimmy Vetayases if (hdlp->ih_private == NULL) { /* allocate phdl structure */
9547ff178cdSJimmy Vetayases free_phdl = 1;
9557ff178cdSJimmy Vetayases i_ddi_alloc_intr_phdl(hdlp);
9567ff178cdSJimmy Vetayases }
9577ff178cdSJimmy Vetayases ((ihdl_plat_t *)hdlp->ih_private)->ip_ispecp = ispec;
9587ff178cdSJimmy Vetayases ret = (*psm_intr_ops)(rdip, hdlp,
9597ff178cdSJimmy Vetayases PSM_INTR_OP_ALLOC_VECTORS, result);
9607ff178cdSJimmy Vetayases if (free_phdl) { /* free up the phdl structure */
9617ff178cdSJimmy Vetayases free_phdl = 0;
9627ff178cdSJimmy Vetayases i_ddi_free_intr_phdl(hdlp);
9637ff178cdSJimmy Vetayases hdlp->ih_private = NULL;
9647ff178cdSJimmy Vetayases }
9657ff178cdSJimmy Vetayases } else {
9667ff178cdSJimmy Vetayases /*
9677ff178cdSJimmy Vetayases * No APIX module; fall back to the old scheme where the
9687ff178cdSJimmy Vetayases * interrupt vector is allocated during ddi_enable_intr() call.
9697ff178cdSJimmy Vetayases */
9707ff178cdSJimmy Vetayases hdlp->ih_pri = ispec->intrspec_pri;
9717ff178cdSJimmy Vetayases *(int *)result = hdlp->ih_scratch1;
9727ff178cdSJimmy Vetayases ret = DDI_SUCCESS;
9737ff178cdSJimmy Vetayases }
9747ff178cdSJimmy Vetayases
9757ff178cdSJimmy Vetayases return (ret);
9767ff178cdSJimmy Vetayases }
9777ff178cdSJimmy Vetayases
9787ff178cdSJimmy Vetayases /*
9797ff178cdSJimmy Vetayases * Free up interrupt vector for FIXED (legacy) type.
9807ff178cdSJimmy Vetayases */
9817ff178cdSJimmy Vetayases static int
isa_free_intr_fixed(dev_info_t * rdip,ddi_intr_handle_impl_t * hdlp)9827ff178cdSJimmy Vetayases isa_free_intr_fixed(dev_info_t *rdip, ddi_intr_handle_impl_t *hdlp)
9837ff178cdSJimmy Vetayases {
9847ff178cdSJimmy Vetayases struct intrspec *ispec;
9857ff178cdSJimmy Vetayases ddi_intr_handle_impl_t info_hdl;
9867ff178cdSJimmy Vetayases int ret;
9877ff178cdSJimmy Vetayases apic_get_type_t type_info;
9887ff178cdSJimmy Vetayases
9897ff178cdSJimmy Vetayases if (psm_intr_ops == NULL)
9907ff178cdSJimmy Vetayases return (DDI_FAILURE);
9917ff178cdSJimmy Vetayases
9927ff178cdSJimmy Vetayases /*
9937ff178cdSJimmy Vetayases * If the PSM module is "APIX" then pass the request for it
9947ff178cdSJimmy Vetayases * to free up the vector now.
9957ff178cdSJimmy Vetayases */
9967ff178cdSJimmy Vetayases bzero(&info_hdl, sizeof (ddi_intr_handle_impl_t));
9977ff178cdSJimmy Vetayases info_hdl.ih_private = &type_info;
9987ff178cdSJimmy Vetayases if ((*psm_intr_ops)(NULL, &info_hdl, PSM_INTR_OP_APIC_TYPE, NULL) ==
9997ff178cdSJimmy Vetayases PSM_SUCCESS && strcmp(type_info.avgi_type, APIC_APIX_NAME) == 0) {
10007ff178cdSJimmy Vetayases if ((ispec = isa_get_ispec(rdip, hdlp->ih_inum)) == NULL)
10017ff178cdSJimmy Vetayases return (DDI_FAILURE);
10027ff178cdSJimmy Vetayases ((ihdl_plat_t *)hdlp->ih_private)->ip_ispecp = ispec;
10037ff178cdSJimmy Vetayases ret = (*psm_intr_ops)(rdip, hdlp,
10047ff178cdSJimmy Vetayases PSM_INTR_OP_FREE_VECTORS, NULL);
10057ff178cdSJimmy Vetayases } else {
10067ff178cdSJimmy Vetayases /*
10077ff178cdSJimmy Vetayases * No APIX module; fall back to the old scheme where
10087ff178cdSJimmy Vetayases * the interrupt vector was already freed during
10097ff178cdSJimmy Vetayases * ddi_disable_intr() call.
10107ff178cdSJimmy Vetayases */
10117ff178cdSJimmy Vetayases ret = DDI_SUCCESS;
10127ff178cdSJimmy Vetayases }
10137ff178cdSJimmy Vetayases
10147ff178cdSJimmy Vetayases return (ret);
10157ff178cdSJimmy Vetayases }
10167ff178cdSJimmy Vetayases
10177c478bd9Sstevel@tonic-gate static void
isa_vendor(uint32_t id,char * vendor)10187c478bd9Sstevel@tonic-gate isa_vendor(uint32_t id, char *vendor)
10197c478bd9Sstevel@tonic-gate {
10207c478bd9Sstevel@tonic-gate vendor[0] = '@' + ((id >> 26) & 0x1f);
10217c478bd9Sstevel@tonic-gate vendor[1] = '@' + ((id >> 21) & 0x1f);
10227c478bd9Sstevel@tonic-gate vendor[2] = '@' + ((id >> 16) & 0x1f);
10237c478bd9Sstevel@tonic-gate vendor[3] = 0;
10247c478bd9Sstevel@tonic-gate }
10257c478bd9Sstevel@tonic-gate
10267c478bd9Sstevel@tonic-gate /*
10277c478bd9Sstevel@tonic-gate * Name a child
10287c478bd9Sstevel@tonic-gate */
10297c478bd9Sstevel@tonic-gate static int
isa_name_child(dev_info_t * child,char * name,int namelen)10307c478bd9Sstevel@tonic-gate isa_name_child(dev_info_t *child, char *name, int namelen)
10317c478bd9Sstevel@tonic-gate {
10327c478bd9Sstevel@tonic-gate char vendor[8];
10337c478bd9Sstevel@tonic-gate int device;
10347c478bd9Sstevel@tonic-gate uint32_t serial;
10357c478bd9Sstevel@tonic-gate int func;
10367c478bd9Sstevel@tonic-gate int bustype;
10377c478bd9Sstevel@tonic-gate uint32_t base;
10387c478bd9Sstevel@tonic-gate int proplen;
10397c478bd9Sstevel@tonic-gate int pnpisa = 0;
10407c478bd9Sstevel@tonic-gate isa_regs_t *isa_regs;
10417c478bd9Sstevel@tonic-gate
10427c478bd9Sstevel@tonic-gate void make_ddi_ppd(dev_info_t *, struct ddi_parent_private_data **);
10437c478bd9Sstevel@tonic-gate
10447c478bd9Sstevel@tonic-gate /*
10457c478bd9Sstevel@tonic-gate * older drivers aren't expecting the "standard" device
10467c478bd9Sstevel@tonic-gate * node format used by the hardware nodes. these drivers
10477c478bd9Sstevel@tonic-gate * only expect their own properties set in their driver.conf
10487c478bd9Sstevel@tonic-gate * files. so they tell us not to call them with hardware
10497c478bd9Sstevel@tonic-gate * nodes by setting the property "ignore-hardware-nodes".
10507c478bd9Sstevel@tonic-gate */
10517c478bd9Sstevel@tonic-gate if (old_driver(child))
10527c478bd9Sstevel@tonic-gate return (DDI_FAILURE);
10537c478bd9Sstevel@tonic-gate
10547c478bd9Sstevel@tonic-gate /*
10557c478bd9Sstevel@tonic-gate * Fill in parent-private data
10567c478bd9Sstevel@tonic-gate */
10577c478bd9Sstevel@tonic-gate if (ddi_get_parent_data(child) == NULL) {
10587c478bd9Sstevel@tonic-gate struct ddi_parent_private_data *pdptr;
10597c478bd9Sstevel@tonic-gate make_ddi_ppd(child, &pdptr);
10607c478bd9Sstevel@tonic-gate ddi_set_parent_data(child, pdptr);
10617c478bd9Sstevel@tonic-gate }
10627c478bd9Sstevel@tonic-gate
10637c478bd9Sstevel@tonic-gate if (ndi_dev_is_persistent_node(child) == 0) {
10647c478bd9Sstevel@tonic-gate /*
10657c478bd9Sstevel@tonic-gate * For .conf nodes, generate name from parent private data
10667c478bd9Sstevel@tonic-gate */
10677c478bd9Sstevel@tonic-gate name[0] = '\0';
10687c478bd9Sstevel@tonic-gate if (sparc_pd_getnreg(child) > 0) {
10697c478bd9Sstevel@tonic-gate (void) snprintf(name, namelen, "%x,%x",
10707c478bd9Sstevel@tonic-gate (uint_t)sparc_pd_getreg(child, 0)->regspec_bustype,
10717c478bd9Sstevel@tonic-gate (uint_t)sparc_pd_getreg(child, 0)->regspec_addr);
10727c478bd9Sstevel@tonic-gate }
10737c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
10747c478bd9Sstevel@tonic-gate }
10757c478bd9Sstevel@tonic-gate
10767c478bd9Sstevel@tonic-gate /*
10777c478bd9Sstevel@tonic-gate * For hw nodes, look up "reg" property
10787c478bd9Sstevel@tonic-gate */
10797c478bd9Sstevel@tonic-gate if (ddi_getlongprop(DDI_DEV_T_ANY, child, DDI_PROP_DONTPASS, "reg",
10807c478bd9Sstevel@tonic-gate (caddr_t)&isa_regs, &proplen) != DDI_PROP_SUCCESS) {
10817c478bd9Sstevel@tonic-gate return (DDI_FAILURE);
10827c478bd9Sstevel@tonic-gate }
10837c478bd9Sstevel@tonic-gate
10847c478bd9Sstevel@tonic-gate /*
10857c478bd9Sstevel@tonic-gate * extract the device identifications
10867c478bd9Sstevel@tonic-gate */
10877c478bd9Sstevel@tonic-gate pnpisa = isa_regs[0].phys_hi & 0x80000000;
10887c478bd9Sstevel@tonic-gate if (pnpisa) {
10897c478bd9Sstevel@tonic-gate isa_vendor(isa_regs[0].phys_hi, vendor);
10907c478bd9Sstevel@tonic-gate device = isa_regs[0].phys_hi & 0xffff;
10917c478bd9Sstevel@tonic-gate serial = isa_regs[0].phys_lo;
10927c478bd9Sstevel@tonic-gate func = (isa_regs[0].size >> 24) & 0xff;
10937c478bd9Sstevel@tonic-gate if (func != 0)
10947c478bd9Sstevel@tonic-gate (void) snprintf(name, namelen, "pnp%s,%04x,%x,%x",
10957c478bd9Sstevel@tonic-gate vendor, device, serial, func);
10967c478bd9Sstevel@tonic-gate else
10977c478bd9Sstevel@tonic-gate (void) snprintf(name, namelen, "pnp%s,%04x,%x",
10987c478bd9Sstevel@tonic-gate vendor, device, serial);
10997c478bd9Sstevel@tonic-gate } else {
11007c478bd9Sstevel@tonic-gate bustype = isa_regs[0].phys_hi;
11017c478bd9Sstevel@tonic-gate base = isa_regs[0].phys_lo;
11027c478bd9Sstevel@tonic-gate (void) sprintf(name, "%x,%x", bustype, base);
11037c478bd9Sstevel@tonic-gate }
11047c478bd9Sstevel@tonic-gate
11057c478bd9Sstevel@tonic-gate /*
11067c478bd9Sstevel@tonic-gate * free the memory allocated by ddi_getlongprop().
11077c478bd9Sstevel@tonic-gate */
11087c478bd9Sstevel@tonic-gate kmem_free(isa_regs, proplen);
11097c478bd9Sstevel@tonic-gate
11107c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
11117c478bd9Sstevel@tonic-gate }
11127c478bd9Sstevel@tonic-gate
11137c478bd9Sstevel@tonic-gate static int
isa_initchild(dev_info_t * child)11147c478bd9Sstevel@tonic-gate isa_initchild(dev_info_t *child)
11157c478bd9Sstevel@tonic-gate {
11167c478bd9Sstevel@tonic-gate char name[80];
11177c478bd9Sstevel@tonic-gate
11187c478bd9Sstevel@tonic-gate if (isa_name_child(child, name, 80) != DDI_SUCCESS)
11197c478bd9Sstevel@tonic-gate return (DDI_FAILURE);
11207c478bd9Sstevel@tonic-gate ddi_set_name_addr(child, name);
11217c478bd9Sstevel@tonic-gate
11227c478bd9Sstevel@tonic-gate if (ndi_dev_is_persistent_node(child) != 0)
11237c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
11247c478bd9Sstevel@tonic-gate
11257c478bd9Sstevel@tonic-gate /*
11267c478bd9Sstevel@tonic-gate * This is a .conf node, try merge properties onto a
11277c478bd9Sstevel@tonic-gate * hw node with the same name.
11287c478bd9Sstevel@tonic-gate */
11297c478bd9Sstevel@tonic-gate if (ndi_merge_node(child, isa_name_child) == DDI_SUCCESS) {
11307c478bd9Sstevel@tonic-gate /*
11317c478bd9Sstevel@tonic-gate * Return failure to remove node
11327c478bd9Sstevel@tonic-gate */
11337c478bd9Sstevel@tonic-gate impl_ddi_sunbus_removechild(child);
11347c478bd9Sstevel@tonic-gate return (DDI_FAILURE);
11357c478bd9Sstevel@tonic-gate }
11367c478bd9Sstevel@tonic-gate /*
11377c478bd9Sstevel@tonic-gate * Cannot merge node, permit pseudo children
11387c478bd9Sstevel@tonic-gate */
11397c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
11407c478bd9Sstevel@tonic-gate }
11417c478bd9Sstevel@tonic-gate
11427c478bd9Sstevel@tonic-gate /*
11437c478bd9Sstevel@tonic-gate * called when ACPI enumeration is not used
11447c478bd9Sstevel@tonic-gate */
11457c478bd9Sstevel@tonic-gate static void
add_known_used_resources(void)11467c478bd9Sstevel@tonic-gate add_known_used_resources(void)
11477c478bd9Sstevel@tonic-gate {
11487c478bd9Sstevel@tonic-gate /* needs to be in increasing order */
11497c478bd9Sstevel@tonic-gate int intr[] = {0x1, 0x3, 0x4, 0x6, 0x7, 0xc};
11507c478bd9Sstevel@tonic-gate int dma[] = {0x2};
11517c478bd9Sstevel@tonic-gate int io[] = {0x60, 0x1, 0x64, 0x1, 0x2f8, 0x8, 0x378, 0x8, 0x3f0, 0x10,
11527c478bd9Sstevel@tonic-gate 0x778, 0x4};
11537c478bd9Sstevel@tonic-gate dev_info_t *usedrdip;
11547c478bd9Sstevel@tonic-gate
11557c478bd9Sstevel@tonic-gate usedrdip = ddi_find_devinfo(USED_RESOURCES, -1, 0);
11567c478bd9Sstevel@tonic-gate
11577c478bd9Sstevel@tonic-gate if (usedrdip == NULL) {
11587c478bd9Sstevel@tonic-gate (void) ndi_devi_alloc_sleep(ddi_root_node(), USED_RESOURCES,
1159fa9e4066Sahrens (pnode_t)DEVI_SID_NODEID, &usedrdip);
11607c478bd9Sstevel@tonic-gate }
11617c478bd9Sstevel@tonic-gate
11627c478bd9Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, usedrdip,
11637c478bd9Sstevel@tonic-gate "interrupts", (int *)intr, (int)(sizeof (intr) / sizeof (int)));
11647c478bd9Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, usedrdip,
11657c478bd9Sstevel@tonic-gate "io-space", (int *)io, (int)(sizeof (io) / sizeof (int)));
11667c478bd9Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, usedrdip,
11677c478bd9Sstevel@tonic-gate "dma-channels", (int *)dma, (int)(sizeof (dma) / sizeof (int)));
11687c478bd9Sstevel@tonic-gate (void) ndi_devi_bind_driver(usedrdip, 0);
11697c478bd9Sstevel@tonic-gate
11707c478bd9Sstevel@tonic-gate }
11717c478bd9Sstevel@tonic-gate
11720d928757SGary Mills /*
11730d928757SGary Mills * Return non-zero if UART device exists.
11740d928757SGary Mills */
11750d928757SGary Mills static int
uart_exists(ushort_t port)11760d928757SGary Mills uart_exists(ushort_t port)
11770d928757SGary Mills {
11780d928757SGary Mills outb(port + COM_SCR, (char)0x5a);
11790d928757SGary Mills outb(port + COM_ISR, (char)0x00);
11800d928757SGary Mills return (inb(port + COM_SCR) == (char)0x5a);
11810d928757SGary Mills }
11820d928757SGary Mills
11837c478bd9Sstevel@tonic-gate static void
isa_enumerate(int reprogram)118437d6e245Slipeng sang - Sun Microsystems - Beijing China isa_enumerate(int reprogram)
11857c478bd9Sstevel@tonic-gate {
11867c478bd9Sstevel@tonic-gate int circ, i;
11877c478bd9Sstevel@tonic-gate dev_info_t *xdip;
118837d6e245Slipeng sang - Sun Microsystems - Beijing China dev_info_t *isa_dip = ddi_find_devinfo("isa", -1, 0);
11897c478bd9Sstevel@tonic-gate
11907c478bd9Sstevel@tonic-gate struct regspec i8042_regs[] = {
11917c478bd9Sstevel@tonic-gate {1, 0x60, 0x1},
11927c478bd9Sstevel@tonic-gate {1, 0x64, 0x1}
11937c478bd9Sstevel@tonic-gate };
11947c478bd9Sstevel@tonic-gate int i8042_intrs[] = {0x1, 0xc};
11957c478bd9Sstevel@tonic-gate char *acpi_prop;
11967c478bd9Sstevel@tonic-gate int acpi_enum = 1; /* ACPI is default to be on */
11970d928757SGary Mills #if defined(__xpv)
11980d928757SGary Mills int cons, ttyn;
11997c478bd9Sstevel@tonic-gate
12000d928757SGary Mills cons = console_hypervisor_dev_type(&ttyn);
12010d928757SGary Mills #endif
120237d6e245Slipeng sang - Sun Microsystems - Beijing China if (reprogram || !isa_dip)
12037c478bd9Sstevel@tonic-gate return;
12047c478bd9Sstevel@tonic-gate
120537d6e245Slipeng sang - Sun Microsystems - Beijing China bzero(isa_extra_resource, MAX_EXTRA_RESOURCE * sizeof (struct regspec));
120637d6e245Slipeng sang - Sun Microsystems - Beijing China
12077c478bd9Sstevel@tonic-gate ndi_devi_enter(isa_dip, &circ);
12087c478bd9Sstevel@tonic-gate
12097c478bd9Sstevel@tonic-gate if (ddi_prop_lookup_string(DDI_DEV_T_ANY, ddi_root_node(),
12107c478bd9Sstevel@tonic-gate DDI_PROP_DONTPASS, "acpi-enum", &acpi_prop) == DDI_PROP_SUCCESS) {
12117c478bd9Sstevel@tonic-gate acpi_enum = strcmp("off", acpi_prop);
12127c478bd9Sstevel@tonic-gate ddi_prop_free(acpi_prop);
12137c478bd9Sstevel@tonic-gate }
12147c478bd9Sstevel@tonic-gate
12157c478bd9Sstevel@tonic-gate if (acpi_enum) {
12167c478bd9Sstevel@tonic-gate if (acpi_isa_device_enum(isa_dip)) {
12177c478bd9Sstevel@tonic-gate ndi_devi_exit(isa_dip, circ);
12187c478bd9Sstevel@tonic-gate if (isa_resource_setup() != NDI_SUCCESS) {
12197c478bd9Sstevel@tonic-gate cmn_err(CE_WARN, "isa nexus: isa "
12207c478bd9Sstevel@tonic-gate "resource setup failed");
12217c478bd9Sstevel@tonic-gate }
1222dffe9ac5Sml40262
1223dffe9ac5Sml40262 /* serial ports? */
1224dffe9ac5Sml40262 enumerate_BIOS_serial(isa_dip);
12251d6b7b34SJudy Chen
12261d6b7b34SJudy Chen /* adjust parallel port size */
12271d6b7b34SJudy Chen adjust_prtsz(isa_dip);
122837d6e245Slipeng sang - Sun Microsystems - Beijing China
122937d6e245Slipeng sang - Sun Microsystems - Beijing China isa_create_ranges_prop(isa_dip);
12307c478bd9Sstevel@tonic-gate return;
12317c478bd9Sstevel@tonic-gate }
12327c478bd9Sstevel@tonic-gate cmn_err(CE_NOTE, "!Solaris did not detect ACPI BIOS");
12337c478bd9Sstevel@tonic-gate }
12347c478bd9Sstevel@tonic-gate cmn_err(CE_NOTE, "!ACPI is off");
12357c478bd9Sstevel@tonic-gate
12367c478bd9Sstevel@tonic-gate /* serial ports */
12370d928757SGary Mills for (i = 0; i < min_BIOS_serial; i++) {
12380d928757SGary Mills ushort_t addr = asy_regs[i].regspec_addr;
12390d928757SGary Mills if (!uart_exists(addr))
1240349b53ddSStuart Maybee continue;
12410d928757SGary Mills #if defined(__xpv)
12420d928757SGary Mills if (cons == CONS_TTY && ttyn == i)
12430d928757SGary Mills continue;
1244843e1988Sjohnlev #endif
12457c478bd9Sstevel@tonic-gate ndi_devi_alloc_sleep(isa_dip, "asy",
1246fa9e4066Sahrens (pnode_t)DEVI_SID_NODEID, &xdip);
12470d928757SGary Mills (void) ndi_prop_update_string(DDI_DEV_T_NONE, xdip,
12480d928757SGary Mills "compatible", "PNP0500");
12490d928757SGary Mills /* This should be gotten from master file: */
12500d928757SGary Mills (void) ndi_prop_update_string(DDI_DEV_T_NONE, xdip,
12510d928757SGary Mills "model", "Standard PC COM port");
12527c478bd9Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, xdip,
12537c478bd9Sstevel@tonic-gate "reg", (int *)&asy_regs[i], 3);
12547c478bd9Sstevel@tonic-gate (void) ndi_prop_update_int(DDI_DEV_T_NONE, xdip,
12557c478bd9Sstevel@tonic-gate "interrupts", asy_intrs[i]);
12567c478bd9Sstevel@tonic-gate (void) ndi_devi_bind_driver(xdip, 0);
12570d928757SGary Mills /* Adjusting isa_extra here causes a kernel dump later. */
12587c478bd9Sstevel@tonic-gate }
12597c478bd9Sstevel@tonic-gate
12607c478bd9Sstevel@tonic-gate /* i8042 node */
12617c478bd9Sstevel@tonic-gate ndi_devi_alloc_sleep(isa_dip, "i8042",
1262fa9e4066Sahrens (pnode_t)DEVI_SID_NODEID, &xdip);
12637c478bd9Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, xdip,
12647c478bd9Sstevel@tonic-gate "reg", (int *)i8042_regs, 6);
12657c478bd9Sstevel@tonic-gate (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, xdip,
12667c478bd9Sstevel@tonic-gate "interrupts", (int *)i8042_intrs, 2);
12677c478bd9Sstevel@tonic-gate (void) ndi_prop_update_string(DDI_DEV_T_NONE, xdip,
12687c478bd9Sstevel@tonic-gate "unit-address", "1,60");
12697c478bd9Sstevel@tonic-gate (void) ndi_devi_bind_driver(xdip, 0);
12707c478bd9Sstevel@tonic-gate
12717c478bd9Sstevel@tonic-gate add_known_used_resources();
12727c478bd9Sstevel@tonic-gate
12737c478bd9Sstevel@tonic-gate ndi_devi_exit(isa_dip, circ);
12747c478bd9Sstevel@tonic-gate
127537d6e245Slipeng sang - Sun Microsystems - Beijing China isa_create_ranges_prop(isa_dip);
12767c478bd9Sstevel@tonic-gate }
1277dffe9ac5Sml40262
1278dffe9ac5Sml40262 /*
1279dffe9ac5Sml40262 * On some machines, serial port 2 isn't listed in the ACPI table.
12800d928757SGary Mills * This function goes through the base I/O addresses and makes sure all
1281dffe9ac5Sml40262 * the serial ports there are in the dev_info tree. If any are missing,
1282dffe9ac5Sml40262 * this function will add them.
1283dffe9ac5Sml40262 */
1284dffe9ac5Sml40262
1285dffe9ac5Sml40262 static void
enumerate_BIOS_serial(dev_info_t * isa_dip)1286dffe9ac5Sml40262 enumerate_BIOS_serial(dev_info_t *isa_dip)
1287dffe9ac5Sml40262 {
1288dffe9ac5Sml40262 int i;
1289dffe9ac5Sml40262 dev_info_t *xdip;
1290dffe9ac5Sml40262 int found;
1291dffe9ac5Sml40262 int ret;
1292dffe9ac5Sml40262 struct regspec *tmpregs;
1293dffe9ac5Sml40262 int tmpregs_len;
12940d928757SGary Mills #if defined(__xpv)
12950d928757SGary Mills int cons, ttyn;
12960d928757SGary Mills
12970d928757SGary Mills cons = console_hypervisor_dev_type(&ttyn);
12980d928757SGary Mills #endif
1299dffe9ac5Sml40262
1300dffe9ac5Sml40262 /*
13010d928757SGary Mills * Scan the base I/O addresses of the first four serial ports.
1302dffe9ac5Sml40262 */
1303dffe9ac5Sml40262 for (i = 0; i < num_BIOS_serial; i++) {
13040d928757SGary Mills ushort_t addr = asy_regs[i].regspec_addr;
1305dffe9ac5Sml40262
1306dffe9ac5Sml40262 /* Look for it in the dev_info tree */
1307dffe9ac5Sml40262 found = 0;
1308dffe9ac5Sml40262 for (xdip = ddi_get_child(isa_dip); xdip != NULL;
1309dffe9ac5Sml40262 xdip = ddi_get_next_sibling(xdip)) {
1310dffe9ac5Sml40262 if (strncmp(ddi_node_name(xdip), "asy", 3) != 0) {
1311dffe9ac5Sml40262 /* skip non asy */
1312dffe9ac5Sml40262 continue;
1313dffe9ac5Sml40262 }
1314dffe9ac5Sml40262
1315dffe9ac5Sml40262 /* Match by addr */
1316dffe9ac5Sml40262 ret = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, xdip,
1317dffe9ac5Sml40262 DDI_PROP_DONTPASS, "reg", (int **)&tmpregs,
1318dffe9ac5Sml40262 (uint_t *)&tmpregs_len);
1319dffe9ac5Sml40262 if (ret != DDI_PROP_SUCCESS) {
1320dffe9ac5Sml40262 /* error */
1321dffe9ac5Sml40262 continue;
1322dffe9ac5Sml40262 }
1323dffe9ac5Sml40262
13240d928757SGary Mills if (tmpregs->regspec_addr == addr)
1325dffe9ac5Sml40262 found = 1;
13260d928757SGary Mills
1327dffe9ac5Sml40262 /*
1328dffe9ac5Sml40262 * Free the memory allocated by
1329dffe9ac5Sml40262 * ddi_prop_lookup_int_array().
1330dffe9ac5Sml40262 */
1331dffe9ac5Sml40262 ddi_prop_free(tmpregs);
1332843e1988Sjohnlev
1333563191b4SPaul B. Henson if (found) {
1334563191b4SPaul B. Henson if (asy_intr_override & 1<<i) {
1335563191b4SPaul B. Henson (void) ndi_prop_update_int(
1336563191b4SPaul B. Henson DDI_DEV_T_NONE, xdip,
1337563191b4SPaul B. Henson "interrupts", asy_intrs[i]);
1338563191b4SPaul B. Henson }
1339563191b4SPaul B. Henson
13400d928757SGary Mills break;
1341dffe9ac5Sml40262 }
1342563191b4SPaul B. Henson }
1343dffe9ac5Sml40262
1344dffe9ac5Sml40262 /* If not found, then add it */
13450d928757SGary Mills if (!found && uart_exists(addr)) {
1346dffe9ac5Sml40262 ndi_devi_alloc_sleep(isa_dip, "asy",
1347dffe9ac5Sml40262 (pnode_t)DEVI_SID_NODEID, &xdip);
1348dffe9ac5Sml40262 (void) ndi_prop_update_string(DDI_DEV_T_NONE, xdip,
1349dffe9ac5Sml40262 "compatible", "PNP0500");
1350dffe9ac5Sml40262 /* This should be gotten from master file: */
1351dffe9ac5Sml40262 (void) ndi_prop_update_string(DDI_DEV_T_NONE, xdip,
1352dffe9ac5Sml40262 "model", "Standard PC COM port");
1353dffe9ac5Sml40262 (void) ndi_prop_update_int_array(DDI_DEV_T_NONE, xdip,
13540d928757SGary Mills "reg", (int *)&asy_regs[i], 3);
1355dffe9ac5Sml40262 (void) ndi_prop_update_int(DDI_DEV_T_NONE, xdip,
13560d928757SGary Mills "interrupts", asy_intrs[i]);
1357dffe9ac5Sml40262 (void) ndi_devi_bind_driver(xdip, 0);
13581d6b7b34SJudy Chen
13591d6b7b34SJudy Chen ASSERT(isa_extra_count < MAX_EXTRA_RESOURCE);
13600d928757SGary Mills bcopy(&asy_regs[i],
13611d6b7b34SJudy Chen isa_extra_resource + isa_extra_count,
13621d6b7b34SJudy Chen sizeof (struct regspec));
13631d6b7b34SJudy Chen isa_extra_count++;
1364dffe9ac5Sml40262 }
1365dffe9ac5Sml40262 }
1366349b53ddSStuart Maybee
1367843e1988Sjohnlev /*
1368349b53ddSStuart Maybee * An asy node may have been attached via ACPI enumeration, or
1369349b53ddSStuart Maybee * directly from this file. Check each serial port to see if it
1370349b53ddSStuart Maybee * is in use by the hypervisor. If it is in use, then remove
1371349b53ddSStuart Maybee * the node from the device tree.
1372843e1988Sjohnlev */
1373349b53ddSStuart Maybee #if defined(__xpv)
1374843e1988Sjohnlev i = 0;
1375349b53ddSStuart Maybee
1376843e1988Sjohnlev for (xdip = ddi_get_child(isa_dip); xdip != NULL; ) {
1377843e1988Sjohnlev dev_info_t *curdip;
1378843e1988Sjohnlev
1379843e1988Sjohnlev curdip = xdip;
1380843e1988Sjohnlev xdip = ddi_get_next_sibling(xdip);
1381843e1988Sjohnlev
1382349b53ddSStuart Maybee if (strncmp(ddi_node_name(curdip), "asy", 3) != 0)
1383843e1988Sjohnlev continue;
1384349b53ddSStuart Maybee
13850d928757SGary Mills if (cons == CONS_TTY && ttyn == i) {
1386843e1988Sjohnlev ret = ndi_devi_free(curdip);
1387349b53ddSStuart Maybee if (ret != DDI_SUCCESS) {
1388843e1988Sjohnlev cmn_err(CE_WARN,
1389843e1988Sjohnlev "could not remove asy%d node", i);
1390349b53ddSStuart Maybee }
1391349b53ddSStuart Maybee
1392843e1988Sjohnlev cmn_err(CE_NOTE, "!asy%d unavailable, reserved"
1393843e1988Sjohnlev " to hypervisor", i);
1394349b53ddSStuart Maybee }
1395349b53ddSStuart Maybee
1396843e1988Sjohnlev i++;
1397843e1988Sjohnlev }
1398349b53ddSStuart Maybee #endif
1399dffe9ac5Sml40262
1400dffe9ac5Sml40262 }
14011d6b7b34SJudy Chen
14021d6b7b34SJudy Chen /*
14031d6b7b34SJudy Chen * Some machine comes with an illegal parallel port size of 3
14041d6b7b34SJudy Chen * bytes in ACPI, even parallel port mode is ECP.
14051d6b7b34SJudy Chen */
14061d6b7b34SJudy Chen #define DEFAULT_PRT_SIZE 8
14071d6b7b34SJudy Chen static void
adjust_prtsz(dev_info_t * isa_dip)14081d6b7b34SJudy Chen adjust_prtsz(dev_info_t *isa_dip)
14091d6b7b34SJudy Chen {
14101d6b7b34SJudy Chen dev_info_t *cdip;
14111d6b7b34SJudy Chen struct regspec *regs_p, *extreg_p;
14121d6b7b34SJudy Chen int regs_len, nreg, i;
14131d6b7b34SJudy Chen char *name;
14141d6b7b34SJudy Chen
14151d6b7b34SJudy Chen for (cdip = ddi_get_child(isa_dip); cdip != NULL;
14161d6b7b34SJudy Chen cdip = ddi_get_next_sibling(cdip)) {
14171d6b7b34SJudy Chen name = ddi_node_name(cdip);
14181d6b7b34SJudy Chen if ((strncmp(name, "lp", 2) != 0) || (strnlen(name, 3) != 2))
14191d6b7b34SJudy Chen continue; /* skip non parallel */
14201d6b7b34SJudy Chen
14211d6b7b34SJudy Chen if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, cdip,
14221d6b7b34SJudy Chen DDI_PROP_DONTPASS, "reg", (int **)®s_p,
14231d6b7b34SJudy Chen (uint_t *)®s_len) != DDI_PROP_SUCCESS)
14241d6b7b34SJudy Chen continue;
14251d6b7b34SJudy Chen
14261d6b7b34SJudy Chen nreg = regs_len / (sizeof (struct regspec) / sizeof (int));
14271d6b7b34SJudy Chen for (i = 0; i < nreg; i++) {
14281d6b7b34SJudy Chen if (regs_p[i].regspec_size == DEFAULT_PRT_SIZE)
14291d6b7b34SJudy Chen continue;
14301d6b7b34SJudy Chen
14311d6b7b34SJudy Chen ASSERT(isa_extra_count < MAX_EXTRA_RESOURCE);
14321d6b7b34SJudy Chen extreg_p = &isa_extra_resource[isa_extra_count++];
14331d6b7b34SJudy Chen extreg_p->regspec_bustype = ISA_ADDR_IO;
14341d6b7b34SJudy Chen extreg_p->regspec_addr = regs_p[i].regspec_addr;
14351d6b7b34SJudy Chen extreg_p->regspec_size = DEFAULT_PRT_SIZE;
14361d6b7b34SJudy Chen }
14371d6b7b34SJudy Chen
14381d6b7b34SJudy Chen ddi_prop_free(regs_p);
14391d6b7b34SJudy Chen }
14401d6b7b34SJudy Chen }
1441