1 /* $OpenBSD: rkdwusb.c,v 1.5 2023/09/22 01:10:44 jsg Exp $ */ 2 /* 3 * Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org> 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 #include <machine/simplebusvar.h> 25 26 #include <dev/ofw/openfirm.h> 27 #include <dev/ofw/ofw_clock.h> 28 #include <dev/ofw/fdt.h> 29 30 struct rkdwusb_softc { 31 struct simplebus_softc sc_sbus; 32 }; 33 34 int rkdwusb_match(struct device *, void *, void *); 35 void rkdwusb_attach(struct device *, struct device *, void *); 36 37 const struct cfattach rkdwusb_ca = { 38 sizeof(struct rkdwusb_softc), rkdwusb_match, rkdwusb_attach 39 }; 40 41 struct cfdriver rkdwusb_cd = { 42 NULL, "rkdwusb", DV_DULL 43 }; 44 45 int 46 rkdwusb_match(struct device *parent, void *match, void *aux) 47 { 48 struct fdt_attach_args *faa = aux; 49 50 return OF_is_compatible(faa->fa_node, "rockchip,rk3399-dwc3"); 51 } 52 53 void 54 rkdwusb_attach(struct device *parent, struct device *self, void *aux) 55 { 56 struct rkdwusb_softc *sc = (struct rkdwusb_softc *)self; 57 struct fdt_attach_args *faa = aux; 58 59 clock_enable_all(faa->fa_node); 60 reset_deassert_all(faa->fa_node); 61 62 simplebus_attach(parent, &sc->sc_sbus.sc_dev, faa); 63 } 64