plmmc_ifpga.c revision 1.1 1 /* $NetBSD: plmmc_ifpga.c,v 1.1 2015/01/27 16:34:34 jmcneill 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.1 2015/01/27 16:34:34 jmcneill Exp $");
31
32 #include <sys/types.h>
33 #include <sys/device.h>
34 #include <sys/systm.h>
35 #include <sys/param.h>
36 #include <sys/malloc.h>
37
38 #include <sys/termios.h>
39
40 #include <machine/intr.h>
41 #include <sys/bus.h>
42
43 #include <dev/ic/pl181reg.h>
44 #include <dev/ic/pl181var.h>
45
46 #include <evbarm/ifpga/ifpgareg.h>
47 #include <evbarm/ifpga/ifpgavar.h>
48
49 static int plmmc_ifpga_match(device_t, cfdata_t, void *);
50 static void plmmc_ifpga_attach(device_t, device_t, void *);
51 static void plmmc_ifpga_attach_i(device_t);
52
53 CFATTACH_DECL_NEW(plmmc_ifpga, sizeof(struct plmmc_softc),
54 plmmc_ifpga_match, plmmc_ifpga_attach, NULL, NULL);
55
56 static int
57 plmmc_ifpga_match(device_t parent, cfdata_t cf, void *aux)
58 {
59 return 1;
60 }
61
62 static void
63 plmmc_ifpga_attach(device_t parent, device_t self, void *aux)
64 {
65 struct plmmc_softc *sc = device_private(self);
66 struct ifpga_attach_args *ifa = aux;
67
68 sc->sc_dev = self;
69 sc->sc_clock_freq = IFPGA_MMC_CLK;
70 sc->sc_bst = ifa->ifa_iot;
71 if (bus_space_map(ifa->ifa_iot, ifa->ifa_addr, IFPGA_MMC_SIZE, 0,
72 &sc->sc_bsh)) {
73 printf("%s: unable to map device\n", device_xname(sc->sc_dev));
74 return;
75 }
76
77 aprint_naive("\n");
78 aprint_normal("\n");
79
80 #if 0
81 sc->sc_ih = ifpga_intr_establish(ifa->ifa_irq, IPL_BIO, plmmc_intr, sc);
82 #endif
83
84 config_interrupts(self, plmmc_ifpga_attach_i);
85 }
86
87 static void
88 plmmc_ifpga_attach_i(device_t self)
89 {
90 struct plmmc_softc *sc = device_private(self);
91
92 plmmc_init(sc);
93 }
94