Tue Jan 17 16:32:04 2012 UTC ()
Add and enable detachment and child detachment functions.


(jakllsch)
diff -r1.4 -r1.5 src/sys/dev/isa/wbsio.c

cvs diff -r1.4 -r1.5 src/sys/dev/isa/wbsio.c (expand / switch to unified diff)

--- src/sys/dev/isa/wbsio.c 2012/01/17 16:28:33 1.4
+++ src/sys/dev/isa/wbsio.c 2012/01/17 16:32:03 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: wbsio.c,v 1.4 2012/01/17 16:28:33 jakllsch Exp $ */ 1/* $NetBSD: wbsio.c,v 1.5 2012/01/17 16:32:03 jakllsch Exp $ */
2/* $OpenBSD: wbsio.c,v 1.5 2009/03/29 21:53:52 sthen Exp $ */ 2/* $OpenBSD: wbsio.c,v 1.5 2009/03/29 21:53:52 sthen Exp $ */
3/* 3/*
4 * Copyright (c) 2008 Mark Kettenis <kettenis@openbsd.org> 4 * Copyright (c) 2008 Mark Kettenis <kettenis@openbsd.org>
5 * 5 *
6 * Permission to use, copy, modify, and distribute this software for any 6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above 7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies. 8 * copyright notice and this permission notice appear in all copies.
9 * 9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
@@ -59,30 +59,32 @@ @@ -59,30 +59,32 @@
59/* Hardware Monitor Control Registers (LDN B) */ 59/* Hardware Monitor Control Registers (LDN B) */
60#define WBSIO_HM_ADDR_MSB 0x60 /* Address [15:8] */ 60#define WBSIO_HM_ADDR_MSB 0x60 /* Address [15:8] */
61#define WBSIO_HM_ADDR_LSB 0x61 /* Address [7:0] */ 61#define WBSIO_HM_ADDR_LSB 0x61 /* Address [7:0] */
62 62
63struct wbsio_softc { 63struct wbsio_softc {
64 struct device sc_dev; 64 struct device sc_dev;
65 65
66 bus_space_tag_t sc_iot; 66 bus_space_tag_t sc_iot;
67 bus_space_handle_t sc_ioh; 67 bus_space_handle_t sc_ioh;
68}; 68};
69 69
70int wbsio_probe(device_t, cfdata_t, void *); 70int wbsio_probe(device_t, cfdata_t, void *);
71void wbsio_attach(device_t, device_t, void *); 71void wbsio_attach(device_t, device_t, void *);
 72int wbsio_detach(device_t, int);
 73void wbsio_childdet(device_t, device_t);
72int wbsio_print(void *, const char *); 74int wbsio_print(void *, const char *);
73 75
74CFATTACH_DECL_NEW(wbsio, sizeof(struct wbsio_softc), 76CFATTACH_DECL2_NEW(wbsio, sizeof(struct wbsio_softc),
75 wbsio_probe, wbsio_attach, NULL, NULL); 77 wbsio_probe, wbsio_attach, wbsio_detach, NULL, NULL, wbsio_childdet);
76 78
77static __inline void 79static __inline void
78wbsio_conf_enable(bus_space_tag_t iot, bus_space_handle_t ioh) 80wbsio_conf_enable(bus_space_tag_t iot, bus_space_handle_t ioh)
79{ 81{
80 bus_space_write_1(iot, ioh, WBSIO_INDEX, WBSIO_CONF_EN_MAGIC); 82 bus_space_write_1(iot, ioh, WBSIO_INDEX, WBSIO_CONF_EN_MAGIC);
81 bus_space_write_1(iot, ioh, WBSIO_INDEX, WBSIO_CONF_EN_MAGIC); 83 bus_space_write_1(iot, ioh, WBSIO_INDEX, WBSIO_CONF_EN_MAGIC);
82} 84}
83 85
84static __inline void 86static __inline void
85wbsio_conf_disable(bus_space_tag_t iot, bus_space_handle_t ioh) 87wbsio_conf_disable(bus_space_tag_t iot, bus_space_handle_t ioh)
86{ 88{
87 bus_space_write_1(iot, ioh, WBSIO_INDEX, WBSIO_CONF_DS_MAGIC); 89 bus_space_write_1(iot, ioh, WBSIO_INDEX, WBSIO_CONF_DS_MAGIC);
88} 90}
@@ -218,26 +220,44 @@ wbsio_attach(device_t parent, device_t s @@ -218,26 +220,44 @@ wbsio_attach(device_t parent, device_t s
218 220
219 if (!pmf_device_register(self, NULL, NULL)) 221 if (!pmf_device_register(self, NULL, NULL))
220 aprint_error_dev(self, "couldn't establish power handler\n"); 222 aprint_error_dev(self, "couldn't establish power handler\n");
221 223
222 if (iobase == 0) 224 if (iobase == 0)
223 return; 225 return;
224 226
225 nia = *ia; 227 nia = *ia;
226 nia.ia_io[0].ir_addr = iobase; 228 nia.ia_io[0].ir_addr = iobase;
227 config_found(self, &nia, wbsio_print); 229 config_found(self, &nia, wbsio_print);
228} 230}
229 231
230int 232int
 233wbsio_detach(device_t self, int flags)
 234{
 235 int rc;
 236
 237 if ((rc = config_detach_children(self, flags)) != 0)
 238 return rc;
 239 bus_space_unmap(sc->sc_iot, sc->sc_ioh, WBSIO_IOSIZE);
 240 pmf_device_deregister(self);
 241 return 0;
 242}
 243
 244void
 245wbsio_childdet(device_t self, device_t child)
 246{
 247 return;
 248}
 249
 250int
231wbsio_print(void *aux, const char *pnp) 251wbsio_print(void *aux, const char *pnp)
232{ 252{
233 struct isa_attach_args *ia = aux; 253 struct isa_attach_args *ia = aux;
234 254
235 if (pnp) 255 if (pnp)
236 aprint_normal("%s", pnp); 256 aprint_normal("%s", pnp);
237 if (ia->ia_io[0].ir_size) 257 if (ia->ia_io[0].ir_size)
238 aprint_normal(" port 0x%x", ia->ia_io[0].ir_addr); 258 aprint_normal(" port 0x%x", ia->ia_io[0].ir_addr);
239 if (ia->ia_io[0].ir_size > 1) 259 if (ia->ia_io[0].ir_size > 1)
240 aprint_normal("-0x%x", ia->ia_io[0].ir_addr + 260 aprint_normal("-0x%x", ia->ia_io[0].ir_addr +
241 ia->ia_io[0].ir_size - 1); 261 ia->ia_io[0].ir_size - 1);
242 return (UNCONF); 262 return (UNCONF);
243} 263}