Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / ic / w83l518d.c
blobf213036ed290222abe010ef5f2f92d4d63cfb180
1 /* $NetBSD$ */
3 /*
4 * Copyright (c) 2009 Jared D. McNeill <jmcneill@invisible.ca>
5 * All rights reserved.
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. 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
25 * SUCH DAMAGE.
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>
38 #include <sys/proc.h>
40 #include <sys/bus.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>
49 uint8_t
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);
56 void
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);
63 uint8_t
64 wb_read(struct wb_softc *wb, uint8_t reg)
66 return bus_space_read_1(wb->wb_iot, wb->wb_ioh, reg);
69 void
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);
75 void
76 wb_led(struct wb_softc *wb, bool enable)
78 uint8_t val;
80 val = wb_read(wb, WB_SD_CSR);
81 if (enable)
82 val |= WB_CSR_MS_LED;
83 else
84 val &= ~WB_CSR_MS_LED;
85 wb_write(wb, WB_SD_CSR, val);
88 void
89 wb_attach(struct wb_softc *wb)
91 switch (wb->wb_type) {
92 case WB_DEVNO_SD:
93 aprint_verbose_dev(wb->wb_dev,
94 "SD/MMC Reader\n");
95 wb_sdmmc_attach(wb);
96 break;
97 case WB_DEVNO_MS:
98 aprint_verbose_dev(wb->wb_dev,
99 "Memory Stick Reader (not supported)\n");
100 break;
101 case WB_DEVNO_SC:
102 aprint_verbose_dev(wb->wb_dev,
103 "Smart Card Reader (not supported)\n");
104 break;
105 case WB_DEVNO_GPIO:
106 aprint_verbose_dev(wb->wb_dev,
107 "GPIO (not supported)\n");
108 break;
113 wb_detach(struct wb_softc *wb, int flags)
115 switch (wb->wb_type) {
116 case WB_DEVNO_SD:
117 wb_sdmmc_detach(wb, flags);
118 break;
121 return 0;
125 * intr handler
128 wb_intr(void *opaque)
130 struct wb_softc *wb = opaque;
132 switch (wb->wb_type) {
133 case WB_DEVNO_SD:
134 return wb_sdmmc_intr(wb);
135 break;
138 return 0;