isa.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* ISA bus nexus driver
*/
#include <sys/autoconf.h>
#include <sys/ddidmareq.h>
#include <sys/ddi_impldefs.h>
#include <sys/dma_engine.h>
extern int isa_resource_setup(void);
static char USED_RESOURCES[] = "used-resources";
static void isa_alloc_nodes(dev_info_t *);
/*
* #define ISA_DEBUG 1
*/
/*
* Local data
*/
static ddi_dma_lim_t ISA_dma_limits = {
0, /* address low */
0x00ffffff, /* address high */
0, /* counter max */
1, /* burstsize */
DMA_UNIT_8, /* minimum xfer */
0, /* dma speed */
0x0000ffff, /* address register */
0x0000ffff, /* counter register */
1, /* sector size */
};
static ddi_dma_attr_t ISA_dma_attr = {
(unsigned long long)0,
(unsigned long long)0x00ffffff,
0x0000ffff,
1,
1,
1,
(unsigned long long)0xffffffff,
(unsigned long long)0x0000ffff,
1,
1,
0
};
/*
* Config information
*/
static int
static int
static int
struct bus_ops isa_bus_ops = {
NULL,
NULL,
NULL,
NULL, /* (*bus_get_eventcookie)(); */
NULL, /* (*bus_add_eventcall)(); */
NULL, /* (*bus_remove_eventcall)(); */
NULL, /* (*bus_post_event)(); */
NULL, /* (*bus_intr_ctl)(); */
NULL, /* (*bus_config)(); */
NULL, /* (*bus_unconfig)(); */
NULL, /* (*bus_fm_init)(); */
NULL, /* (*bus_fm_fini)(); */
NULL, /* (*bus_fm_access_enter)(); */
NULL, /* (*bus_fm_access_exit)(); */
NULL, /* (*bus_power)(); */
i_ddi_intr_ops /* (*bus_intr_op)(); */
};
/*
* Internal isa ctlops support routines
*/
DEVO_REV, /* devo_rev, */
0, /* refcnt */
ddi_no_info, /* info */
nulldev, /* identify */
nulldev, /* probe */
isa_attach, /* attach */
nodev, /* detach */
nodev, /* reset */
(struct cb_ops *)0, /* driver operations */
&isa_bus_ops /* bus operations */
};
/*
* Module linkage information for the kernel.
*/
&mod_driverops, /* Type of module. This is ISA bus driver */
"isa nexus driver for 'ISA' %I%",
&isa_ops, /* driver ops */
};
static struct modlinkage modlinkage = {
&modldrv,
};
int
_init(void)
{
return (mod_install(&modlinkage));
}
int
_fini(void)
{
return (mod_remove(&modlinkage));
}
int
{
}
static int
{
int rval;
if (cmd != DDI_ATTACH)
return (DDI_FAILURE);
/*
* Enumerate children -- invoking ACPICA
* This is normally in bus_config(), but we need this
* to happen earlier to boot.
*/
}
return (rval);
}
static int
{
}
static int
{
int rval;
switch (request) {
case DDI_DMA_E_PROG:
case DDI_DMA_E_ACQUIRE:
case DDI_DMA_E_FREE:
case DDI_DMA_E_STOP:
return (DDI_SUCCESS);
case DDI_DMA_E_ENABLE:
return (DDI_SUCCESS);
case DDI_DMA_E_DISABLE:
return (DDI_SUCCESS);
case DDI_DMA_E_GETCNT:
return (DDI_SUCCESS);
case DDI_DMA_E_SWSETUP:
case DDI_DMA_E_SWSTART:
return (DDI_SUCCESS);
case DDI_DMA_E_GETLIM:
return (DDI_SUCCESS);
case DDI_DMA_E_GETATTR:
return (DDI_SUCCESS);
case DDI_DMA_E_1STPTY:
{
struct ddi_dmae_req req1stpty =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
if (arg == 0) {
} else {
}
}
case DDI_DMA_IOPB_ALLOC: /* get contiguous DMA-able memory */
case DDI_DMA_SMEM_ALLOC:
if (!offp) {
}
/*FALLTHROUGH*/
default:
}
return (rval);
}
/*
* Check if driver should be treated as an old pre 2.6 driver
*/
static int
{
extern int ignore_hardware_nodes; /* force flag from ddi_impl.c */
if (ndi_dev_is_persistent_node(dip)) {
return (1);
"ignore-hardware-nodes", -1) != -1)
return (1);
}
return (0);
}
typedef struct {
} isa_regs_t;
/*
* Return non-zero if device in tree is a PnP isa device
*/
static int
{
if (ndi_dev_is_persistent_node(dip) == 0)
return (0);
return (0);
}
/*
* free the memory allocated by ddi_getlongprop().
*/
if (pnpisa)
return (1);
else
return (0);
}
/*ARGSUSED*/
static int
{
switch (ctlop) {
case DDI_CTLOPS_REPORTDEV:
if (rdip == (dev_info_t *)0)
return (DDI_FAILURE);
return (DDI_SUCCESS);
case DDI_CTLOPS_INITCHILD:
/*
* older drivers aren't expecting the "standard" device
* node format used by the hardware nodes. these drivers
* only expect their own properties set in their driver.conf
* files. so they tell us not to call them with hardware
* nodes by setting the property "ignore-hardware-nodes".
*/
return (DDI_NOT_WELL_FORMED);
}
case DDI_CTLOPS_UNINITCHILD:
return (DDI_SUCCESS);
case DDI_CTLOPS_SIDDEV:
/*
* All ISA devices need to do confirming probes
* unless they are PnP ISA.
*/
return (DDI_SUCCESS);
else
return (DDI_FAILURE);
default:
}
}
static void
{
vendor[3] = 0;
}
/*
* Name a child
*/
static int
{
char vendor[8];
int device;
int func;
int bustype;
int proplen;
int pnpisa = 0;
/*
* older drivers aren't expecting the "standard" device
* node format used by the hardware nodes. these drivers
* only expect their own properties set in their driver.conf
* files. so they tell us not to call them with hardware
* nodes by setting the property "ignore-hardware-nodes".
*/
if (old_driver(child))
return (DDI_FAILURE);
/*
* Fill in parent-private data
*/
struct ddi_parent_private_data *pdptr;
}
if (ndi_dev_is_persistent_node(child) == 0) {
/*
* For .conf nodes, generate name from parent private data
*/
name[0] = '\0';
if (sparc_pd_getnreg(child) > 0) {
}
return (DDI_SUCCESS);
}
/*
* For hw nodes, look up "reg" property
*/
return (DDI_FAILURE);
}
/*
* extract the device identifications
*/
if (pnpisa) {
if (func != 0)
else
} else {
}
/*
* free the memory allocated by ddi_getlongprop().
*/
return (DDI_SUCCESS);
}
static int
{
char name[80];
return (DDI_FAILURE);
if (ndi_dev_is_persistent_node(child) != 0)
return (DDI_SUCCESS);
/*
* This is a .conf node, try merge properties onto a
* hw node with the same name.
*/
/*
* Return failure to remove node
*/
return (DDI_FAILURE);
}
/*
* Cannot merge node, permit pseudo children
*/
return (DDI_SUCCESS);
}
/*
* called when ACPI enumeration is not used
*/
static void
add_known_used_resources(void)
{
/* needs to be in increasing order */
int dma[] = {0x2};
0x778, 0x4};
}
(void) ndi_devi_bind_driver(usedrdip, 0);
}
static void
{
static int alloced = 0;
int circ, i;
/* hard coded isa stuff */
{1, 0x3f8, 0x8},
{1, 0x2f8, 0x8}
};
int lp_intr = 7;
struct regspec i8042_regs[] = {
{1, 0x60, 0x1},
{1, 0x64, 0x1}
};
char *acpi_prop;
if (alloced)
return;
if (alloced) { /* just in case we are multi-threaded */
return;
}
alloced = 1;
}
if (acpi_enum) {
if (acpi_isa_device_enum(isa_dip)) {
if (isa_resource_setup() != NDI_SUCCESS) {
"resource setup failed");
}
return;
}
}
/* serial ports */
for (i = 0; i < 2; i++) {
"interrupts", asy_intrs[i]);
(void) ndi_devi_bind_driver(xdip, 0);
}
/* parallel port */
"interrupts", lp_intr);
(void) ndi_devi_bind_driver(xdip, 0);
/* i8042 node */
"unit-address", "1,60");
(void) ndi_devi_bind_driver(xdip, 0);
}