Wed Dec 31 08:00:31 2008 UTC ()
Search all of mfp(4)'s children automatically, instead of
attaching hard-coded children.  mfp(4) was trying to attach
pow(4) though pow(4) was a pseudo-device for a long time.


(isaki)
diff -r1.20 -r1.21 src/sys/arch/x68k/dev/mfp.c

cvs diff -r1.20 -r1.21 src/sys/arch/x68k/dev/mfp.c (expand / switch to unified diff)

--- src/sys/arch/x68k/dev/mfp.c 2008/12/18 02:27:41 1.20
+++ src/sys/arch/x68k/dev/mfp.c 2008/12/31 08:00:31 1.21
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mfp.c,v 1.20 2008/12/18 02:27:41 isaki Exp $ */ 1/* $NetBSD: mfp.c,v 1.21 2008/12/31 08:00:31 isaki Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998 NetBSD Foundation, Inc. 4 * Copyright (c) 1998 NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -32,41 +32,42 @@ @@ -32,41 +32,42 @@
32 * POSSIBILITY OF SUCH DAMAGE. 32 * POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35/* 35/*
36 * MC68901 MFP (multi function periferal) driver for NetBSD/x68k 36 * MC68901 MFP (multi function periferal) driver for NetBSD/x68k
37 */ 37 */
38 38
39/* 39/*
40 * MFP is used as keyboard controller, which may be used before 40 * MFP is used as keyboard controller, which may be used before
41 * ordinary initialization. 41 * ordinary initialization.
42 */ 42 */
43 43
44#include <sys/cdefs.h> 44#include <sys/cdefs.h>
45__KERNEL_RCSID(0, "$NetBSD: mfp.c,v 1.20 2008/12/18 02:27:41 isaki Exp $"); 45__KERNEL_RCSID(0, "$NetBSD: mfp.c,v 1.21 2008/12/31 08:00:31 isaki Exp $");
46 46
47#include <sys/param.h> 47#include <sys/param.h>
48#include <sys/systm.h> 48#include <sys/systm.h>
49#include <sys/device.h> 49#include <sys/device.h>
50#include <sys/malloc.h> 50#include <sys/malloc.h>
51 51
52#include <machine/bus.h> 52#include <machine/bus.h>
53#include <machine/cpu.h> 53#include <machine/cpu.h>
54 54
55#include <arch/x68k/dev/intiovar.h> 55#include <arch/x68k/dev/intiovar.h>
56#include <arch/x68k/dev/mfp.h> 56#include <arch/x68k/dev/mfp.h>
57 57
58static int mfp_match(struct device *, struct cfdata *, void *); 58static int mfp_match(struct device *, struct cfdata *, void *);
59static void mfp_attach(struct device *, struct device *, void *); 59static void mfp_attach(struct device *, struct device *, void *);
 60static int mfp_search(device_t, cfdata_t, const int *, void *);
60static void mfp_init(void); 61static void mfp_init(void);
61static void mfp_calibrate_delay(void); 62static void mfp_calibrate_delay(void);
62 63
63CFATTACH_DECL(mfp, sizeof(struct mfp_softc), 64CFATTACH_DECL(mfp, sizeof(struct mfp_softc),
64 mfp_match, mfp_attach, NULL, NULL); 65 mfp_match, mfp_attach, NULL, NULL);
65 66
66static int mfp_attached; 67static int mfp_attached;
67 68
68static int 69static int
69mfp_match(struct device *parent, struct cfdata *cf, void *aux) 70mfp_match(struct device *parent, struct cfdata *cf, void *aux)
70{ 71{
71 struct intio_attach_args *ia = aux; 72 struct intio_attach_args *ia = aux;
72 73
@@ -105,38 +106,44 @@ mfp_attach(struct device *parent, struct @@ -105,38 +106,44 @@ mfp_attach(struct device *parent, struct
105 106
106 printf("\n"); 107 printf("\n");
107 108
108 mfp_attached = 1; 109 mfp_attached = 1;
109 sc->sc_bst = ia->ia_bst; 110 sc->sc_bst = ia->ia_bst;
110 sc->sc_intr = ia->ia_intr; 111 sc->sc_intr = ia->ia_intr;
111 ia->ia_size = 0x30; 112 ia->ia_size = 0x30;
112 r = intio_map_allocate_region(parent, ia, INTIO_MAP_ALLOCATE); 113 r = intio_map_allocate_region(parent, ia, INTIO_MAP_ALLOCATE);
113#ifdef DIAGNOSTIC 114#ifdef DIAGNOSTIC
114 if (r) 115 if (r)
115 panic("IO map for MFP corruption??"); 116 panic("IO map for MFP corruption??");
116#endif 117#endif
117 bus_space_map(ia->ia_bst, ia->ia_addr, 0x2000, 0, &sc->sc_bht); 118 bus_space_map(ia->ia_bst, ia->ia_addr, 0x2000, 0, &sc->sc_bht);
118 config_found(self, __UNCONST("kbd"), NULL); 119 config_search_ia(mfp_search, self, "mfp", NULL);
119 config_found(self, __UNCONST("clock"), NULL); 
120 config_found(self, __UNCONST("pow"), NULL); 
121 } else { 120 } else {
122 /* 121 /*
123 * Called from config_console; 122 * Called from config_console;
124 * calibrate the DELAY loop counter 123 * calibrate the DELAY loop counter
125 */ 124 */
126 mfp_calibrate_delay(); 125 mfp_calibrate_delay();
127 } 126 }
128} 127}
129 128
 129static int
 130mfp_search(device_t parent, cfdata_t cf, const int *loc, void *aux)
 131{
 132 if (config_match(parent, cf, __UNCONST(cf->cf_name)) > 0)
 133 config_attach(parent, cf, __UNCONST(cf->cf_name), NULL);
 134 return 0;
 135}
 136
130static void 137static void
131mfp_init(void) 138mfp_init(void)
132{ 139{
133 mfp_set_vr(MFP_INTR); 140 mfp_set_vr(MFP_INTR);
134 141
135 /* stop all interrupts */ 142 /* stop all interrupts */
136 mfp_set_iera(0); 143 mfp_set_iera(0);
137 mfp_set_ierb(0); 144 mfp_set_ierb(0);
138 145
139 /* make MSCTRL 'High', XXX where should I do it? */ 146 /* make MSCTRL 'High', XXX where should I do it? */
140 mfp_send_usart(0x41); 147 mfp_send_usart(0x41);
141 148
142 /* Timer A settings */ 149 /* Timer A settings */