Lines Matching +full:sc +full:- +full:resource

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
38 #include <machine/resource.h>
52 static struct resource *atkbdc_isa_alloc_resource(device_t dev, device_t child,
56 struct resource *r);
97 struct resource *port0; in atkbdc_isa_probe()
98 struct resource *port1; in atkbdc_isa_probe()
120 * one resource (0x60 through 0x64) or as two separate resources in atkbdc_isa_probe()
121 * (0x60 and 0x64). Some brain-damaged ACPI BIOS has reversed in atkbdc_isa_probe()
123 * may contain just one port, 0x60. We shall adjust resource settings in atkbdc_isa_probe()
156 * on the fact that reading from non-existing in/out port returns in atkbdc_isa_probe()
189 atkbdc_softc_t *sc; in atkbdc_isa_attach() local
195 sc = *(atkbdc_softc_t **)device_get_softc(dev); in atkbdc_isa_attach()
196 if (sc == NULL) { in atkbdc_isa_attach()
199 * as the low-level console needs to have access to the in atkbdc_isa_attach()
204 sc = atkbdc_get_softc(unit); in atkbdc_isa_attach()
205 if (sc == NULL) in atkbdc_isa_attach()
210 sc->retry = 5000; in atkbdc_isa_attach()
211 sc->port0 = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, in atkbdc_isa_attach()
213 if (sc->port0 == NULL) in atkbdc_isa_attach()
216 sc->port1 = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, in atkbdc_isa_attach()
218 if (sc->port1 == NULL) { in atkbdc_isa_attach()
219 bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->port0); in atkbdc_isa_attach()
229 sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); in atkbdc_isa_attach()
231 error = atkbdc_attach_unit(unit, sc, sc->port0, sc->port1); in atkbdc_isa_attach()
233 bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->port0); in atkbdc_isa_attach()
234 bus_release_resource(dev, SYS_RES_IOPORT, 1, sc->port1); in atkbdc_isa_attach()
235 if (sc->irq != NULL) in atkbdc_isa_attach()
236 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq); in atkbdc_isa_attach()
239 *(atkbdc_softc_t **)device_get_softc(dev) = sc; in atkbdc_isa_attach()
251 atkbdc_softc_t *sc; in atkbdc_isa_add_child() local
255 sc = *(atkbdc_softc_t **)device_get_softc(bus); in atkbdc_isa_add_child()
267 resource_list_init(&ivar->resources); in atkbdc_isa_add_child()
268 ivar->rid = order; in atkbdc_isa_add_child()
272 * to device hints for IRQ. We always populate the resource in atkbdc_isa_add_child()
277 if (sc->irq == NULL) { in atkbdc_isa_add_child()
279 t = -1; in atkbdc_isa_add_child()
281 t = rman_get_start(sc->irq); in atkbdc_isa_add_child()
283 resource_list_add(&ivar->resources, SYS_RES_IRQ, in atkbdc_isa_add_child()
284 ivar->rid, t, t, 1); in atkbdc_isa_add_child()
295 struct resource *
299 atkbdc_softc_t *sc; in atkbdc_isa_alloc_resource() local
301 sc = *(atkbdc_softc_t **)device_get_softc(dev); in atkbdc_isa_alloc_resource()
302 if (type == SYS_RES_IRQ && *rid == KBDC_RID_KBD && sc->irq != NULL) in atkbdc_isa_alloc_resource()
303 return (sc->irq); in atkbdc_isa_alloc_resource()
309 atkbdc_isa_release_resource(device_t dev, device_t child, struct resource *r) in atkbdc_isa_release_resource()
311 atkbdc_softc_t *sc; in atkbdc_isa_release_resource() local
313 sc = *(atkbdc_softc_t **)device_get_softc(dev); in atkbdc_isa_release_resource()
314 if (r == sc->irq) in atkbdc_isa_release_resource()