4 * Copyright (c) 2009 Jared D. McNeill <jmcneill@invisible.ca>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. The name of the author may not be used to endorse or promote products
13 * derived from this software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/cdefs.h>
29 __KERNEL_RCSID(0, "$NetBSD$");
31 #include <sys/param.h>
32 #include <sys/kernel.h>
33 #include <sys/systm.h>
34 #include <sys/errno.h>
35 #include <sys/ioctl.h>
36 #include <sys/syslog.h>
37 #include <sys/device.h>
42 #include <dev/isa/isavar.h>
43 #include <dev/isa/isadmavar.h>
45 #include <dev/ic/w83l518dreg.h>
46 #include <dev/ic/w83l518dvar.h>
47 #include <dev/ic/w83l518d_sdmmc.h>
50 wb_idx_read(struct wb_softc
*wb
, uint8_t reg
)
52 bus_space_write_1(wb
->wb_iot
, wb
->wb_ioh
, WB_SD_INDEX
, reg
);
53 return bus_space_read_1(wb
->wb_iot
, wb
->wb_ioh
, WB_SD_DATA
);
57 wb_idx_write(struct wb_softc
*wb
, uint8_t reg
, uint8_t val
)
59 bus_space_write_1(wb
->wb_iot
, wb
->wb_ioh
, WB_SD_INDEX
, reg
);
60 bus_space_write_1(wb
->wb_iot
, wb
->wb_ioh
, WB_SD_DATA
, val
);
64 wb_read(struct wb_softc
*wb
, uint8_t reg
)
66 return bus_space_read_1(wb
->wb_iot
, wb
->wb_ioh
, reg
);
70 wb_write(struct wb_softc
*wb
, uint8_t reg
, uint8_t val
)
72 bus_space_write_1(wb
->wb_iot
, wb
->wb_ioh
, reg
, val
);
76 wb_led(struct wb_softc
*wb
, bool enable
)
80 val
= wb_read(wb
, WB_SD_CSR
);
84 val
&= ~WB_CSR_MS_LED
;
85 wb_write(wb
, WB_SD_CSR
, val
);
89 wb_attach(struct wb_softc
*wb
)
91 switch (wb
->wb_type
) {
93 aprint_verbose_dev(wb
->wb_dev
,
98 aprint_verbose_dev(wb
->wb_dev
,
99 "Memory Stick Reader (not supported)\n");
102 aprint_verbose_dev(wb
->wb_dev
,
103 "Smart Card Reader (not supported)\n");
106 aprint_verbose_dev(wb
->wb_dev
,
107 "GPIO (not supported)\n");
113 wb_detach(struct wb_softc
*wb
, int flags
)
115 switch (wb
->wb_type
) {
117 wb_sdmmc_detach(wb
, flags
);
128 wb_intr(void *opaque
)
130 struct wb_softc
*wb
= opaque
;
132 switch (wb
->wb_type
) {
134 return wb_sdmmc_intr(wb
);