Deleted Added
full compact
26c26
< * $FreeBSD: head/sys/dev/atkbdc/atkbdc_subr.c 82555 2001-08-30 09:17:03Z msmith $
---
> * $FreeBSD: head/sys/dev/atkbdc/atkbdc_subr.c 83147 2001-09-06 12:09:26Z yokota $
50,51c50,51
< int flags; /* configuration flags */
< int irq; /* ISA IRQ mask */
---
> struct resource_list resources;
> int rid;
62a63,64
> static device_t atkbdc_add_child(device_t bus, int order, char *name,
> int unit);
67a70,77
> static struct resource_list
> *atkbdc_get_resource_list (device_t bus, device_t dev);
> static struct resource
> *atkbdc_alloc_resource(device_t bus, device_t dev, int type,
> int *rid, u_long start, u_long end,
> u_long count, u_int flags);
> static int atkbdc_release_resource(device_t bus, device_t dev, int type,
> int rid, struct resource *res);
74a85
> DEVMETHOD(bus_add_child, atkbdc_add_child),
78,79c89,91
< DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
< DEVMETHOD(bus_release_resource, bus_generic_release_resource),
---
> DEVMETHOD(bus_get_resource_list,atkbdc_get_resource_list),
> DEVMETHOD(bus_alloc_resource, atkbdc_alloc_resource),
> DEVMETHOD(bus_release_resource, atkbdc_release_resource),
81a94,96
> DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
> DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource),
> DEVMETHOD(bus_delete_resource, bus_generic_rl_delete_resource),
103a119,120
> u_long start;
> u_long count;
112a130,139
> /*
> * Adjust I/O port resources.
> * The AT keyboard controller uses two ports (a command/data port
> * 0x60 and a status port 0x64), which may be given to us in
> * one resource (0x60 through 0x64) or as two separate resources
> * (0x60 and 0x64). Furthermore, /boot/device.hints may contain
> * just one port, 0x60. We shall adjust resource settings
> * so that these two ports are available as two separate resources.
> */
> device_quiet(dev);
113a141,144
> if (bus_get_resource(dev, SYS_RES_IOPORT, rid, &start, &count) != 0)
> return ENXIO;
> if (count > 1) /* adjust the count */
> bus_set_resource(dev, SYS_RES_IOPORT, rid, start, 1);
118,122d148
< /* XXX */
< if (bus_get_resource_start(dev, SYS_RES_IOPORT, 1) <= 0) {
< bus_set_resource(dev, SYS_RES_IOPORT, 1,
< rman_get_start(port0) + KBD_STATUS_PORT, 1);
< }
123a150,152
> if (bus_get_resource(dev, SYS_RES_IOPORT, rid, NULL, NULL) != 0)
> bus_set_resource(dev, SYS_RES_IOPORT, 1,
> start + KBD_STATUS_PORT, 1);
129a159
> device_verbose(dev);
131a162,163
> if (error == 0)
> bus_generic_probe(dev);
139,167d170
< static void
< atkbdc_add_device(device_t dev, const char *name, int unit)
< {
< atkbdc_device_t *kdev;
< device_t child;
< int t;
<
< if (resource_int_value(name, unit, "disabled", &t) == 0 && t != 0)
< return;
<
< kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV,
< M_NOWAIT | M_ZERO);
< if (!kdev)
< return;
<
< if (resource_int_value(name, unit, "irq", &t) == 0)
< kdev->irq = t;
< else
< kdev->irq = -1;
<
< if (resource_int_value(name, unit, "flags", &t) == 0)
< kdev->flags = t;
< else
< kdev->flags = 0;
<
< child = device_add_child(dev, name, unit);
< device_set_ivars(child, kdev);
< }
<
172c175
< int unit, dunit;
---
> int unit;
175,176d177
< int i;
< const char *name, *dname;
214,220c215
< /*
< * Add all devices configured to be attached to atkbdc0.
< */
< name = device_get_nameunit(dev);
< i = 0;
< while ((resource_find_match(&i, &dname, &dunit, "at", name)) == 0)
< atkbdc_add_device(dev, dname, dunit);
---
> bus_generic_attach(dev);
221a217,240
> return 0;
> }
>
> static device_t
> atkbdc_add_child(device_t bus, int order, char *name, int unit)
> {
> atkbdc_device_t *ivar;
> device_t child;
> int t;
>
> ivar = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV,
> M_NOWAIT | M_ZERO);
> if (!ivar)
> return NULL;
>
> child = device_add_child(bus, NULL, -1);
> if (child == NULL) {
> free(ivar, M_ATKBDDEV);
> return child;
> }
>
> resource_list_init(&ivar->resources);
> ivar->rid = order;
>
223c242,243
< * and atkbdc?
---
> * If the device is not created by the PnP BIOS or ACPI,
> * refer to device hints for IRQ.
225,228c245,253
< name = device_get_name(dev);
< i = 0;
< while ((resource_find_match(&i, &dname, &dunit, "at", name)) == 0)
< atkbdc_add_device(dev, dname, dunit);
---
> if (ISA_PNP_PROBE(device_get_parent(bus), bus, atkbdc_ids) != 0) {
> if (resource_int_value(name, unit, "irq", &t) != 0)
> t = -1;
> } else {
> t = bus_get_resource_start(bus, SYS_RES_IRQ, ivar->rid);
> }
> if (t > 0)
> resource_list_add(&ivar->resources, SYS_RES_IRQ, ivar->rid,
> t, t, 1);
230c255,258
< bus_generic_attach(dev);
---
> if (resource_int_value(name, unit, "flags", &t) == 0)
> device_set_flags(child, t);
> if (resource_int_value(name, unit, "disabled", &t) == 0 && t != 0)
> device_disable(child);
232c260,262
< return 0;
---
> device_set_ivars(child, ivar);
>
> return child;
238a269,270
> u_long irq;
> int flags;
244,247c276,281
< if (kbdcdev->flags != 0)
< retval += printf(" flags 0x%x", kbdcdev->flags);
< if (kbdcdev->irq != -1)
< retval += printf(" irq %d", kbdcdev->irq);
---
> flags = device_get_flags(dev);
> if (flags != 0)
> retval += printf(" flags 0x%x", flags);
> irq = bus_get_resource_start(dev, SYS_RES_IRQ, kbdcdev->rid);
> if (irq != 0)
> retval += printf(" irq %ld", irq);
260,265d293
< case KBDC_IVAR_IRQ:
< *val = (u_long)ivar->irq;
< break;
< case KBDC_IVAR_FLAGS:
< *val = (u_long)ivar->flags;
< break;
291,296d318
< case KBDC_IVAR_IRQ:
< ivar->irq = (int)val;
< break;
< case KBDC_IVAR_FLAGS:
< ivar->flags = (int)val;
< break;
314a337,367
> static struct resource_list
> *atkbdc_get_resource_list (device_t bus, device_t dev)
> {
> atkbdc_device_t *ivar;
>
> ivar = (atkbdc_device_t *)device_get_ivars(dev);
> return &ivar->resources;
> }
>
> static struct resource
> *atkbdc_alloc_resource(device_t bus, device_t dev, int type, int *rid,
> u_long start, u_long end, u_long count, u_int flags)
> {
> atkbdc_device_t *ivar;
>
> ivar = (atkbdc_device_t *)device_get_ivars(dev);
> return resource_list_alloc(&ivar->resources, bus, dev, type, rid,
> start, end, count, flags);
> }
>
> static int
> atkbdc_release_resource(device_t bus, device_t dev, int type, int rid,
> struct resource *res)
> {
> atkbdc_device_t *ivar;
>
> ivar = (atkbdc_device_t *)device_get_ivars(dev);
> return resource_list_release(&ivar->resources, bus, dev, type, rid,
> res);
> }
>