#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ohci_s3c24x0.c,v 1.12 2021/08/07 16:18:45 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/bus.h>
#include <arm/s3c2xx0/s3c24x0var.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdivar.h>
#include <dev/usb/usb_mem.h>
#include <dev/usb/ohcireg.h>
#include <dev/usb/ohcivar.h>
int ohci_ssio_match(device_t, cfdata_t, void *);
void ohci_ssio_attach(device_t, device_t, void *);
int ohci_ssio_detach(device_t, int);
extern int ohcidebug;
struct ohci_ssio_softc {
ohci_softc_t sc;
void *sc_ih;
};
CFATTACH_DECL_NEW(ohci_ssio, sizeof(struct ohci_ssio_softc),
ohci_ssio_match, ohci_ssio_attach, ohci_ssio_detach, ohci_activate);
int
ohci_ssio_match(device_t parent, cfdata_t match, void *aux)
{
struct s3c2xx0_attach_args *sa = (struct s3c2xx0_attach_args *)aux;
if (sa->sa_dmat == NULL) {
return 0;
}
return 1;
}
void
ohci_ssio_attach(device_t parent, device_t self, void *aux)
{
struct ohci_ssio_softc *sc = device_private(self);
struct s3c2xx0_attach_args *sa = (struct s3c2xx0_attach_args *)aux;
aprint_normal("\n");
aprint_naive("\n");
sc->sc.sc_dev = self;
sc->sc.sc_bus.ub_hcpriv = sc;
sc->sc.iot = sa->sa_iot;
if (bus_space_map(sc->sc.iot, sa->sa_addr, 0x5c, 0, &sc->sc.ioh)) {
aprint_error_dev(self, "can't map mem space\n");
return;
}
bus_space_write_4(sc->sc.iot, sc->sc.ioh, OHCI_INTERRUPT_DISABLE,
OHCI_ALL_INTRS);
sc->sc.sc_bus.ub_dmatag = sa->sa_dmat;
sc->sc_ih = s3c24x0_intr_establish(sa->sa_intr, IPL_USB, IST_NONE, ohci_intr, sc);
if (sc->sc_ih == NULL) {
aprint_error_dev(self, "couldn't establish interrupt\n");
return;
}
int err = ohci_init(&sc->sc);
if (err) {
aprint_error_dev(self, "init failed, error=%d\n", err);
return;
}
sc->sc.sc_child = config_found(self, &sc->sc.sc_bus, usbctlprint,
CFARGS_NONE);
}
int
ohci_ssio_detach(device_t self, int flags)
{
return 0;
}