Home | History | Annotate | Line # | Download | only in ifpga
      1 /* $NetBSD: plmmc_ifpga.c,v 1.2 2021/07/27 21:13:41 skrll Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2015 Jared D. McNeill <jmcneill (at) invisible.ca>
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  * SUCH DAMAGE.
     27  */
     28 #include <sys/cdefs.h>
     29 
     30 __KERNEL_RCSID(0, "$NetBSD: plmmc_ifpga.c,v 1.2 2021/07/27 21:13:41 skrll Exp $");
     31 
     32 #include <sys/param.h>
     33 #include <sys/types.h>
     34 
     35 #include <sys/bus.h>
     36 #include <sys/device.h>
     37 #include <sys/systm.h>
     38 #include <sys/termios.h>
     39 
     40 #include <machine/intr.h>
     41 
     42 #include <dev/ic/pl181reg.h>
     43 #include <dev/ic/pl181var.h>
     44 
     45 #include <evbarm/ifpga/ifpgareg.h>
     46 #include <evbarm/ifpga/ifpgavar.h>
     47 
     48 static int  plmmc_ifpga_match(device_t, cfdata_t, void *);
     49 static void plmmc_ifpga_attach(device_t, device_t, void *);
     50 static void plmmc_ifpga_attach_i(device_t);
     51 
     52 CFATTACH_DECL_NEW(plmmc_ifpga, sizeof(struct plmmc_softc),
     53     plmmc_ifpga_match, plmmc_ifpga_attach, NULL, NULL);
     54 
     55 static int
     56 plmmc_ifpga_match(device_t parent, cfdata_t cf, void *aux)
     57 {
     58 	return 1;
     59 }
     60 
     61 static void
     62 plmmc_ifpga_attach(device_t parent, device_t self, void *aux)
     63 {
     64 	struct plmmc_softc *sc = device_private(self);
     65 	struct ifpga_attach_args *ifa = aux;
     66 
     67 	sc->sc_dev = self;
     68 	sc->sc_clock_freq = IFPGA_MMC_CLK;
     69 	sc->sc_bst = ifa->ifa_iot;
     70 	if (bus_space_map(ifa->ifa_iot, ifa->ifa_addr, IFPGA_MMC_SIZE, 0,
     71 	    &sc->sc_bsh)) {
     72 		printf("%s: unable to map device\n", device_xname(sc->sc_dev));
     73 		return;
     74 	}
     75 
     76 	aprint_naive("\n");
     77 	aprint_normal("\n");
     78 
     79 #if 0
     80 	sc->sc_ih = ifpga_intr_establish(ifa->ifa_irq, IPL_BIO, plmmc_intr, sc);
     81 #endif
     82 
     83 	config_interrupts(self, plmmc_ifpga_attach_i);
     84 }
     85 
     86 static void
     87 plmmc_ifpga_attach_i(device_t self)
     88 {
     89 	struct plmmc_softc *sc = device_private(self);
     90 
     91 	plmmc_init(sc);
     92 }
     93