1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

Refine ACPI/PnP BIOS probe/attach routines a bit.

- Add workaround for the problematic PnP BIOS which does not assign
  irq resource for the PS/2 mouse device node; if there is no irq
  assigned for the PS/2 mouse node, refer to device.hints for an
  irq number. If we still don't find an irq number in the hints
  database, use a hard-coded value.
- Delete unused ivars.
- Bit of clean up in probe/attach.
- Add PnP ID for the PS/2 mouse port on some IBM ThinkPad models.
This commit is contained in:
Kazutaka YOKOTA 2001-09-15 04:38:20 +00:00
parent b519f9d660
commit cd6cd68d18
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=83492
7 changed files with 75 additions and 33 deletions

View File

@ -77,7 +77,7 @@ atkbdidentify(driver_t *driver, device_t parent)
{
/* always add at least one child */
BUS_ADD_CHILD(parent, KBDC_RID_KBD, driver->name, 0);
BUS_ADD_CHILD(parent, KBDC_RID_KBD, driver->name, device_get_unit(parent));
}
static int

View File

@ -77,7 +77,7 @@ atkbdidentify(driver_t *driver, device_t parent)
{
/* always add at least one child */
BUS_ADD_CHILD(parent, KBDC_RID_KBD, driver->name, 0);
BUS_ADD_CHILD(parent, KBDC_RID_KBD, driver->name, device_get_unit(parent));
}
static int

View File

@ -200,8 +200,6 @@ typedef struct atkbdc_softc {
} atkbdc_softc_t;
enum kbdc_device_ivar {
KBDC_IVAR_IRQ,
KBDC_IVAR_FLAGS,
KBDC_IVAR_VENDORID,
KBDC_IVAR_SERIAL,
KBDC_IVAR_LOGICALID,

View File

@ -95,6 +95,8 @@
/* end of driver specific options */
#define PSM_DRIVER_NAME "psm"
/* input queue */
#define PSM_BUFSIZE 960
#define PSM_SMALLBUFSIZE 240
@ -311,7 +313,7 @@ static device_method_t psm_methods[] = {
};
static driver_t psm_driver = {
"psm",
PSM_DRIVER_NAME,
psm_methods,
sizeof(struct psm_softc),
};
@ -327,7 +329,7 @@ static struct cdevsw psm_cdevsw = {
/* poll */ psmpoll,
/* mmap */ nommap,
/* strategy */ nostrategy,
/* name */ "psm",
/* name */ PSM_DRIVER_NAME,
/* maj */ CDEV_MAJOR,
/* dump */ nodump,
/* psize */ nopsize,
@ -780,7 +782,7 @@ psmidentify(driver_t *driver, device_t parent)
{
/* always add at least one child */
BUS_ADD_CHILD(parent, KBDC_RID_AUX, driver->name, 0);
BUS_ADD_CHILD(parent, KBDC_RID_AUX, driver->name, device_get_unit(parent));
}
#define endprobe(v) { if (bootverbose) \
@ -2798,6 +2800,7 @@ static driver_t psmcpnp_driver = {
static struct isa_pnp_id psmcpnp_ids[] = {
{ 0x130fd041, "PS/2 mouse port" }, /* PNP0F13 */
{ 0x1303d041, "PS/2 port" }, /* PNP0313, XXX */
{ 0x80374d24, "IBM PS/2 mouse port" }, /* IBM3780, ThinkPad */
{ 0 }
};
@ -2806,12 +2809,28 @@ create_a_copy(device_t atkbdc, device_t me)
{
device_t psm;
u_long irq;
char *name;
int unit;
name = PSM_DRIVER_NAME;
unit = device_get_unit(atkbdc);
/*
* The PnP BIOS and ACPI are supposed to assign an IRQ (12)
* to the PS/2 mouse device node. But, some buggy PnP BIOS
* declares the PS/2 mouse device node without the IRQ!
* If this happens, we shall refer to device hints.
* If we still don't find it there, use a hardcoded value... XXX
*/
irq = bus_get_resource_start(me, SYS_RES_IRQ, 0);
if (irq <= 0)
return ENXIO; /* shouldn't happen */
if (irq <= 0) {
if (resource_long_value(name, unit, "irq", &irq) != 0)
irq = 12; /* XXX */
device_printf(me, "irq resource info is missing; "
"assuming irq %ld\n", irq);
}
psm = BUS_ADD_CHILD(atkbdc, 1, "psm", 0);
psm = BUS_ADD_CHILD(atkbdc, KBDC_RID_AUX, name, unit);
if (psm == NULL)
return ENXIO;
@ -2831,27 +2850,31 @@ psmcpnp_probe(device_t dev)
if (ISA_PNP_PROBE(device_get_parent(dev), dev, psmcpnp_ids))
return ENXIO;
/*
* If we find an atkbdc device on the same bus,
* create our copy there.
*/
/* If we don't find an atkbdc device on the same bus, quit. */
atkbdc = device_find_child(device_get_parent(dev), ATKBDC_DRIVER_NAME,
device_get_unit(dev));
if (atkbdc == NULL)
return ENXIO;
if (device_get_state(atkbdc) == DS_ATTACHED)
create_a_copy(atkbdc, dev);
/* keep quiet */
if (!bootverbose)
device_quiet(dev);
return 0;
}
static int
psmcpnp_attach(device_t dev)
{
device_t atkbdc;
/* create our copy under the keyboard controller on the same bus. */
atkbdc = device_find_child(device_get_parent(dev), ATKBDC_DRIVER_NAME,
device_get_unit(dev));
if (atkbdc == NULL)
return ENXIO;
if (device_get_state(atkbdc) == DS_ATTACHED)
create_a_copy(atkbdc, dev);
return 0;
}

View File

@ -200,8 +200,6 @@ typedef struct atkbdc_softc {
} atkbdc_softc_t;
enum kbdc_device_ivar {
KBDC_IVAR_IRQ,
KBDC_IVAR_FLAGS,
KBDC_IVAR_VENDORID,
KBDC_IVAR_SERIAL,
KBDC_IVAR_LOGICALID,

View File

@ -77,7 +77,7 @@ atkbdidentify(driver_t *driver, device_t parent)
{
/* always add at least one child */
BUS_ADD_CHILD(parent, KBDC_RID_KBD, driver->name, 0);
BUS_ADD_CHILD(parent, KBDC_RID_KBD, driver->name, device_get_unit(parent));
}
static int

View File

@ -95,6 +95,8 @@
/* end of driver specific options */
#define PSM_DRIVER_NAME "psm"
/* input queue */
#define PSM_BUFSIZE 960
#define PSM_SMALLBUFSIZE 240
@ -311,7 +313,7 @@ static device_method_t psm_methods[] = {
};
static driver_t psm_driver = {
"psm",
PSM_DRIVER_NAME,
psm_methods,
sizeof(struct psm_softc),
};
@ -327,7 +329,7 @@ static struct cdevsw psm_cdevsw = {
/* poll */ psmpoll,
/* mmap */ nommap,
/* strategy */ nostrategy,
/* name */ "psm",
/* name */ PSM_DRIVER_NAME,
/* maj */ CDEV_MAJOR,
/* dump */ nodump,
/* psize */ nopsize,
@ -780,7 +782,7 @@ psmidentify(driver_t *driver, device_t parent)
{
/* always add at least one child */
BUS_ADD_CHILD(parent, KBDC_RID_AUX, driver->name, 0);
BUS_ADD_CHILD(parent, KBDC_RID_AUX, driver->name, device_get_unit(parent));
}
#define endprobe(v) { if (bootverbose) \
@ -2798,6 +2800,7 @@ static driver_t psmcpnp_driver = {
static struct isa_pnp_id psmcpnp_ids[] = {
{ 0x130fd041, "PS/2 mouse port" }, /* PNP0F13 */
{ 0x1303d041, "PS/2 port" }, /* PNP0313, XXX */
{ 0x80374d24, "IBM PS/2 mouse port" }, /* IBM3780, ThinkPad */
{ 0 }
};
@ -2806,12 +2809,28 @@ create_a_copy(device_t atkbdc, device_t me)
{
device_t psm;
u_long irq;
char *name;
int unit;
name = PSM_DRIVER_NAME;
unit = device_get_unit(atkbdc);
/*
* The PnP BIOS and ACPI are supposed to assign an IRQ (12)
* to the PS/2 mouse device node. But, some buggy PnP BIOS
* declares the PS/2 mouse device node without the IRQ!
* If this happens, we shall refer to device hints.
* If we still don't find it there, use a hardcoded value... XXX
*/
irq = bus_get_resource_start(me, SYS_RES_IRQ, 0);
if (irq <= 0)
return ENXIO; /* shouldn't happen */
if (irq <= 0) {
if (resource_long_value(name, unit, "irq", &irq) != 0)
irq = 12; /* XXX */
device_printf(me, "irq resource info is missing; "
"assuming irq %ld\n", irq);
}
psm = BUS_ADD_CHILD(atkbdc, 1, "psm", 0);
psm = BUS_ADD_CHILD(atkbdc, KBDC_RID_AUX, name, unit);
if (psm == NULL)
return ENXIO;
@ -2831,27 +2850,31 @@ psmcpnp_probe(device_t dev)
if (ISA_PNP_PROBE(device_get_parent(dev), dev, psmcpnp_ids))
return ENXIO;
/*
* If we find an atkbdc device on the same bus,
* create our copy there.
*/
/* If we don't find an atkbdc device on the same bus, quit. */
atkbdc = device_find_child(device_get_parent(dev), ATKBDC_DRIVER_NAME,
device_get_unit(dev));
if (atkbdc == NULL)
return ENXIO;
if (device_get_state(atkbdc) == DS_ATTACHED)
create_a_copy(atkbdc, dev);
/* keep quiet */
if (!bootverbose)
device_quiet(dev);
return 0;
}
static int
psmcpnp_attach(device_t dev)
{
device_t atkbdc;
/* create our copy under the keyboard controller on the same bus. */
atkbdc = device_find_child(device_get_parent(dev), ATKBDC_DRIVER_NAME,
device_get_unit(dev));
if (atkbdc == NULL)
return ENXIO;
if (device_get_state(atkbdc) == DS_ATTACHED)
create_a_copy(atkbdc, dev);
return 0;
}