exynos_ehci.c revision 1.3
1/* $NetBSD: exynos_ehci.c,v 1.3 2018/04/09 16:21:09 jakllsch 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_ehci.c,v 1.3 2018/04/09 16:21:09 jakllsch 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/ehcireg.h> 57#include <dev/usb/ehcivar.h> 58 59#include <arm/samsung/exynos_reg.h> 60#include <arm/samsung/exynos_var.h> 61 62#include <dev/fdt/fdtvar.h> 63 64static int exynos_ehci_match(device_t, cfdata_t, void *); 65static void exynos_ehci_attach(device_t, device_t, void *); 66 67CFATTACH_DECL_NEW(exynos_ehci, sizeof(struct ehci_softc), 68 exynos_ehci_match, exynos_ehci_attach, NULL, NULL); 69 70 71static int 72exynos_ehci_match(device_t parent, cfdata_t cf, void *aux) 73{ 74 const char * const compatible[] = { "samsung,exynos5-ehci", 75 NULL }; 76 struct fdt_attach_args * const faa = aux; 77 return of_match_compatible(faa->faa_phandle, compatible); 78} 79 80 81static void 82exynos_ehci_attach(device_t parent, device_t self, void *aux) 83{ 84 struct ehci_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 90 if (fdtbus_get_reg(faa->faa_phandle, 0, &addr, &size) != 0) { 91 aprint_error(": couldn't get registers\n"); 92 return; 93 } 94 95 sc->sc_dev = self; 96 sc->iot = faa->faa_bst; 97 sc->sc_size = size; 98 sc->sc_bus.ub_dmatag = faa->faa_dmat; 99 sc->sc_bus.ub_hcpriv = sc; 100 sc->sc_bus.ub_revision = USBREV_2_0; 101 sc->sc_ncomp = 0; 102 103 error = bus_space_map(sc->iot, addr, size, 0, &sc->ioh); 104 if (error) { 105 aprint_error(": couldn't map %#llx: %d", 106 (uint64_t)addr, error); 107 return; 108 } 109 110 111 aprint_naive(": EHCI USB controller\n"); 112 aprint_normal(": EHCI NOT IMPLEMENTED\n"); 113 114 /* attach */ 115 error = ehci_init(sc); 116 if (error) { 117 aprint_error_dev(self, "init failed, error = %d\n", error); 118 /* disable : TBD */ 119 return; 120 } 121 sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint); 122} 123