1 /* $OpenBSD: imxdwusb.c,v 1.1 2018/05/16 13:21:50 patrick Exp $ */ 2 /* 3 * Copyright (c) 2018 Patrick Wildt <patrick@blueri.se> 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 #include <sys/param.h> 19 #include <sys/systm.h> 20 #include <sys/device.h> 21 22 #include <machine/bus.h> 23 #include <machine/fdt.h> 24 25 #include <arm64/dev/simplebusvar.h> 26 27 #include <dev/ofw/openfirm.h> 28 #include <dev/ofw/ofw_clock.h> 29 #include <dev/ofw/fdt.h> 30 31 struct imxdwusb_softc { 32 struct simplebus_softc sc_sbus; 33 }; 34 35 int imxdwusb_match(struct device *, void *, void *); 36 void imxdwusb_attach(struct device *, struct device *, void *); 37 38 struct cfattach imxdwusb_ca = { 39 sizeof(struct imxdwusb_softc), imxdwusb_match, imxdwusb_attach 40 }; 41 42 struct cfdriver imxdwusb_cd = { 43 NULL, "imxdwusb", DV_DULL 44 }; 45 46 int 47 imxdwusb_match(struct device *parent, void *match, void *aux) 48 { 49 struct fdt_attach_args *faa = aux; 50 51 return OF_is_compatible(faa->fa_node, "fsl,imx8mq-dwc3"); 52 } 53 54 void 55 imxdwusb_attach(struct device *parent, struct device *self, void *aux) 56 { 57 struct imxdwusb_softc *sc = (struct imxdwusb_softc *)self; 58 struct fdt_attach_args *faa = aux; 59 60 clock_set_assigned(faa->fa_node); 61 clock_enable_all(faa->fa_node); 62 reset_deassert_all(faa->fa_node); 63 64 simplebus_attach(parent, &sc->sc_sbus.sc_dev, faa); 65 } 66