Lines Matching refs:dev
31 __FBSDID("$FreeBSD: releng/11.0/sys/dev/pcf/envctrl.c 181332 2008-08-05 17:39:37Z jhb $");
51 #include <dev/ofw/ofw_bus.h>
58 #include <dev/iicbus/iicbus.h>
59 #include <dev/iicbus/iiconf.h>
60 #include <dev/pcf/pcfvar.h>
96 envctrl_probe(device_t dev)
99 if (strcmp("SUNW,envctrl", ofw_bus_get_name(dev)) == 0) {
100 device_set_desc(dev, "EBus SUNW,envctrl");
107 envctrl_attach(device_t dev)
112 sc = DEVTOSOFTC(dev);
113 mtx_init(&sc->pcf_lock, device_get_nameunit(dev), "pcf", MTX_DEF);
116 sc->res_ioport = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
119 device_printf(dev, "cannot reserve I/O port range\n");
123 sc->pcf_flags = device_get_flags(dev);
126 sc->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->rid_irq,
129 device_printf(dev, "can't reserve irq, polled mode.\n");
135 pcf_rst_card(dev, IIC_FASTEST, PCF_DEFAULT_ADDR, NULL);
137 rv = bus_setup_intr(dev, sc->res_irq,
141 device_printf(dev, "could not setup IRQ\n");
145 if ((sc->iicbus = device_add_child(dev, "iicbus", -1)) == NULL)
146 device_printf(dev, "could not allocate iicbus instance\n");
149 bus_generic_attach(dev);
155 bus_release_resource(dev, SYS_RES_IRQ, sc->rid_irq,
159 bus_release_resource(dev, SYS_RES_MEMORY, sc->rid_ioport,
167 envctrl_detach(device_t dev)
172 sc = DEVTOSOFTC(dev);
174 if ((rv = bus_generic_detach(dev)) != 0)
177 if ((rv = device_delete_child(dev, sc->iicbus)) != 0)
181 bus_teardown_intr(dev, sc->res_irq, sc->intr_cookie);
182 bus_release_resource(dev, SYS_RES_IRQ, sc->rid_irq, sc->res_irq);
185 bus_release_resource(dev, SYS_RES_MEMORY, sc->rid_ioport, sc->res_ioport);