Annotation of sys/arch/arm/s3c2xx0/ohci_s3c24x0.c, Revision 1.1
1.1 ! nbrk 1: /* $NetBSD: ohci_s3c24x0.c,v 1.3 2005/12/11 12:16:51 christos Exp $ */
! 2:
! 3: /* derived from ohci_pci.c */
! 4:
! 5: /*
! 6: * Copyright (c) 1998 The NetBSD Foundation, Inc.
! 7: * All rights reserved.
! 8: *
! 9: * This code is derived from software contributed to The NetBSD Foundation
! 10: * by Lennart Augustsson (lennart@augustsson.net) at
! 11: * Carlstedt Research & Technology.
! 12: *
! 13: * Redistribution and use in source and binary forms, with or without
! 14: * modification, are permitted provided that the following conditions
! 15: * are met:
! 16: * 1. Redistributions of source code must retain the above copyright
! 17: * notice, this list of conditions and the following disclaimer.
! 18: * 2. Redistributions in binary form must reproduce the above copyright
! 19: * notice, this list of conditions and the following disclaimer in the
! 20: * documentation and/or other materials provided with the distribution.
! 21: * 3. All advertising materials mentioning features or use of this software
! 22: * must display the following acknowledgement:
! 23: * This product includes software developed by the NetBSD
! 24: * Foundation, Inc. and its contributors.
! 25: * 4. Neither the name of The NetBSD Foundation nor the names of its
! 26: * contributors may be used to endorse or promote products derived
! 27: * from this software without specific prior written permission.
! 28: *
! 29: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
! 30: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
! 31: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! 32: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
! 33: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
! 34: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
! 35: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
! 36: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
! 37: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
! 38: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
! 39: * POSSIBILITY OF SUCH DAMAGE.
! 40: */
! 41:
! 42: #include <sys/cdefs.h>
! 43: __KERNEL_RCSID(0, "$NetBSD: ohci_s3c24x0.c,v 1.3 2005/12/11 12:16:51 christos Exp $");
! 44:
! 45: #include <sys/param.h>
! 46: #include <sys/systm.h>
! 47: #include <sys/kernel.h>
! 48: #include <sys/device.h>
! 49: #include <sys/proc.h>
! 50: #include <sys/queue.h>
! 51:
! 52: #include <machine/bus.h>
! 53:
! 54: #include <arm/s3c2xx0/s3c24x0var.h>
! 55:
! 56: #include <dev/usb/usb.h>
! 57: #include <dev/usb/usbdi.h>
! 58: #include <dev/usb/usbdivar.h>
! 59: #include <dev/usb/usb_mem.h>
! 60:
! 61: #include <dev/usb/ohcireg.h>
! 62: #include <dev/usb/ohcivar.h>
! 63:
! 64: int ohci_ssio_match(struct device *, struct cfdata *, void *);
! 65: void ohci_ssio_attach(struct device *, struct device *, void *);
! 66: int ohci_ssio_detach(device_ptr_t, int);
! 67:
! 68: extern int ohcidebug;
! 69:
! 70: struct ohci_ssio_softc {
! 71: ohci_softc_t sc;
! 72:
! 73: void *sc_ih; /* interrupt vectoring */
! 74: };
! 75:
! 76: CFATTACH_DECL(ohci_ssio, sizeof(struct ohci_ssio_softc),
! 77: ohci_ssio_match, ohci_ssio_attach, ohci_ssio_detach, ohci_activate);
! 78:
! 79: int
! 80: ohci_ssio_match(struct device *parent, struct cfdata *match, void *aux)
! 81: {
! 82: struct s3c2xx0_attach_args *sa = (struct s3c2xx0_attach_args *)aux;
! 83: /* XXX: check some registers */
! 84:
! 85: if (sa->sa_dmat == NULL) {
! 86: /* busdma tag is not initialized. */
! 87: return 0;
! 88: }
! 89:
! 90: return 1;
! 91: }
! 92:
! 93: void
! 94: ohci_ssio_attach(struct device *parent, struct device *self, void *aux)
! 95: {
! 96: struct ohci_ssio_softc *sc = (struct ohci_ssio_softc *)self;
! 97: struct s3c2xx0_attach_args *sa = (struct s3c2xx0_attach_args *)aux;
! 98:
! 99: usbd_status r;
! 100: char *devname = sc->sc.sc_bus.bdev.dv_xname;
! 101:
! 102: aprint_normal("\n");
! 103:
! 104: sc->sc.iot = sa->sa_iot;
! 105: /*ohcidebug=15;*/
! 106:
! 107: /* Map I/O registers */
! 108: if (bus_space_map(sc->sc.iot, sa->sa_addr, 0x5c, 0, &sc->sc.ioh)) {
! 109: printf("%s: can't map mem space\n", devname);
! 110: return;
! 111: }
! 112:
! 113: /* Disable interrupts, so we don't get any spurious ones. */
! 114: bus_space_write_4(sc->sc.iot, sc->sc.ioh, OHCI_INTERRUPT_DISABLE,
! 115: OHCI_ALL_INTRS);
! 116:
! 117: sc->sc.sc_bus.dmatag = sa->sa_dmat;
! 118:
! 119: /* Enable the device. */
! 120: /* XXX: provide clock to USB block */
! 121:
! 122: /* establish the interrupt. */
! 123: sc->sc_ih = s3c24x0_intr_establish(sa->sa_intr, IPL_USB, IST_NONE, ohci_intr, sc);
! 124: if (sc->sc_ih == NULL) {
! 125: printf("%s: couldn't establish interrupt\n", devname);
! 126: return;
! 127: }
! 128:
! 129: strlcpy(sc->sc.sc_vendor, "Samsung", sizeof sc->sc.sc_vendor);
! 130:
! 131: r = ohci_init(&sc->sc);
! 132: if (r != USBD_NORMAL_COMPLETION) {
! 133: printf("%s: init failed, error=%d\n", devname, r);
! 134: return;
! 135: }
! 136:
! 137: /* Attach usb device. */
! 138: sc->sc.sc_child = config_found((void *)sc, &sc->sc.sc_bus,
! 139: usbctlprint);
! 140: }
! 141:
! 142: int
! 143: ohci_ssio_detach(device_ptr_t self, int flags)
! 144: {
! 145: return (0);
! 146: }
CVSweb