Lines Matching refs:dev

28 __FBSDID("$FreeBSD: releng/11.0/sys/dev/gpio/gpiopps.c 300811 2016-05-26 23:56:12Z ian $");
39 #include <dev/gpio/gpiobusvar.h>
44 #include <dev/ofw/ofw_bus.h>
55 device_t dev;
69 gpiopps_open(struct cdev *dev, int flags, int fmt, struct thread *td)
71 struct pps_softc *sc = dev->si_drv1;
75 if (device_get_state(sc->dev) < DS_BUSY) {
76 device_busy(sc->dev);
84 gpiopps_close(struct cdev *dev, int flags, int fmt, struct thread *td)
86 struct pps_softc *sc = dev->si_drv1;
93 device_unbusy(sc->dev);
100 gpiopps_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td)
102 struct pps_softc *sc = dev->si_drv1;
161 gpiopps_detach(device_t dev)
163 struct pps_softc *sc = device_get_softc(dev);
168 bus_teardown_intr(dev, sc->ires, sc->ihandler);
170 bus_release_resource(dev, SYS_RES_IRQ, sc->irid, sc->ires);
172 gpiobus_release_pin(GPIO_GET_BUS(sc->gpin->dev), sc->gpin->pin);
178 gpiopps_fdt_attach(device_t dev)
186 sc = device_get_softc(dev);
187 sc->dev = dev;
189 mtx_init(&sc->pps_mtx, device_get_nameunit(dev), NULL, MTX_DEF);
198 if (ofw_bus_has_prop(dev, "assert-falling-edge"))
207 node = ofw_bus_get_node(dev);
208 if ((err = gpio_pin_get_by_ofw_idx(dev, node, 0, &sc->gpin)) != 0) {
209 device_printf(dev, "Cannot obtain gpio pin\n");
212 device_printf(dev, "PPS input on %s pin %u\n",
213 device_get_nameunit(sc->gpin->dev), sc->gpin->pin);
216 device_printf(dev, "Cannot query capabilities of gpio pin\n");
217 gpiopps_detach(dev);
221 device_printf(dev, "Pin cannot be configured for the requested signal edge\n");
222 gpiopps_detach(dev);
230 if ((sc->ires = gpio_alloc_intr_resource(dev, &sc->irid, RF_ACTIVE,
232 device_printf(dev, "Cannot allocate an IRQ for the GPIO\n");
233 gpiopps_detach(dev);
237 err = bus_setup_intr(dev, sc->ires, INTR_TYPE_CLK | INTR_MPSAFE,
240 device_printf(dev, "Unable to setup pps irq handler\n");
241 gpiopps_detach(dev);
253 device_get_unit(dev));
255 device_printf(dev, "Unable to create pps cdev\n");
256 gpiopps_detach(dev);
264 gpiopps_fdt_probe(device_t dev)
267 if (!ofw_bus_status_okay(dev))
270 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data != 0) {
271 device_set_desc(dev, "GPIO PPS");