Home | History | Annotate | Line # | Download | only in samsung
exynos_ohci.c revision 1.1
      1 /*	$NetBSD: exynos_ohci.c,v 1.1 2015/12/27 02:54:12 marty Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2014 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Reinoud Zandijk.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #include "locators.h"
     33 #include "ohci.h"
     34 #include "ehci.h"
     35 
     36 #include <sys/cdefs.h>
     37 
     38 __KERNEL_RCSID(1, "$NetBSD: exynos_ohci.c,v 1.1 2015/12/27 02:54:12 marty Exp $");
     39 
     40 #include <sys/param.h>
     41 #include <sys/systm.h>
     42 #include <sys/kernel.h>
     43 #include <sys/intr.h>
     44 #include <sys/bus.h>
     45 #include <sys/device.h>
     46 #include <sys/proc.h>
     47 #include <sys/queue.h>
     48 #include <sys/kmem.h>
     49 #include <sys/gpio.h>
     50 
     51 #include <dev/usb/usb.h>
     52 #include <dev/usb/usbdi.h>
     53 #include <dev/usb/usbdivar.h>
     54 #include <dev/usb/usb_mem.h>
     55 
     56 #include <dev/usb/ohcireg.h>
     57 #include <dev/usb/ohcivar.h>
     58 
     59 #include <arm/samsung/exynos_reg.h>
     60 #include <arm/samsung/exynos_var.h>
     61 
     62 #include <dev/fdt/fdtvar.h>
     63 
     64 static int	exynos_ohci_match(device_t, cfdata_t, void *);
     65 static void	exynos_ohci_attach(device_t, device_t, void *);
     66 
     67 CFATTACH_DECL_NEW(exynos_ohci, sizeof(struct ohci_softc),
     68     exynos_ohci_match, exynos_ohci_attach, NULL, NULL);
     69 
     70 
     71 static int
     72 exynos_ohci_match(device_t parent, cfdata_t cf, void *aux)
     73 {
     74 	const char * const compatible[] = { "samsung,exynos5-ohci",
     75 					    NULL };
     76 	struct fdt_attach_args * const faa = aux;
     77 	return of_match_compatible(faa->faa_phandle, compatible);
     78 }
     79 
     80 
     81 static void
     82 exynos_ohci_attach(device_t parent, device_t self, void *aux)
     83 {
     84 	struct ohci_softc *sc = device_private(self);
     85 	struct fdt_attach_args * const faa = aux;
     86 	bus_addr_t addr;
     87 	bus_size_t size;
     88 	int error;
     89 	int r;
     90 
     91 	if (fdtbus_get_reg(faa->faa_phandle, 0, &addr, &size) != 0) {
     92 		aprint_error(": couldn't get registers\n");
     93 		return;
     94 	}
     95 
     96 	sc->sc_dev = self;
     97 	sc->iot = faa->faa_bst;
     98 	sc->sc_size = size;
     99 	sc->sc_bus.dmatag = faa->faa_dmat;
    100 	sc->sc_bus.hci_private = sc;
    101 
    102 	error = bus_space_map(sc->iot, addr, size, 0, &sc->ioh);
    103 	if (error) {
    104 		aprint_error(": couldn't map %#llx: %d",
    105 			     (uint64_t)addr, error);
    106 		return;
    107 	}
    108 
    109 	aprint_naive(": OHCI USB controller\n");
    110 	aprint_normal(": OHCI NOT IMPLEMENTED\n");
    111 
    112 	/* attach */
    113 	r = ohci_init(sc);
    114 	if (r != USBD_NORMAL_COMPLETION) {
    115 		aprint_error_dev(self, "init failed, error = %d\n", r);
    116 		/* disable : TBD */
    117 		return;
    118 	}
    119 	sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint);
    120 }
    121 
    122