This source file includes following definitions.
- iicbus_print
- iic_print
- iic_search
- iic_match
- iic_attach
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/device.h>
42 #include <sys/event.h>
43 #include <sys/conf.h>
44
45 #define _I2C_PRIVATE
46 #include <dev/i2c/i2cvar.h>
47
48 #define IICCF_ADDR 0
49 #define IICCF_SIZE 1
50
51 #include "ipmi.h"
52
53 struct iic_softc {
54 struct device sc_dev;
55 i2c_tag_t sc_tag;
56 };
57
58 int iic_match(struct device *, void *, void *);
59 void iic_attach(struct device *, struct device *, void *);
60 int iic_search(struct device *, void *, void *);
61
62 struct cfattach iic_ca = {
63 sizeof (struct iic_softc),
64 iic_match,
65 iic_attach
66 };
67
68 struct cfdriver iic_cd = {
69 NULL, "iic", DV_DULL
70 };
71
72 int
73 iicbus_print(void *aux, const char *pnp)
74 {
75 struct i2cbus_attach_args *iba = aux;
76
77 if (pnp != NULL)
78 printf("%s at %s", iba->iba_name, pnp);
79
80 return (UNCONF);
81 }
82
83 int
84 iic_print(void *aux, const char *pnp)
85 {
86 struct i2c_attach_args *ia = aux;
87
88 if (pnp != NULL)
89 printf("\"%s\" at %s", ia->ia_name, pnp);
90 printf(" addr 0x%x", ia->ia_addr);
91
92 return (UNCONF);
93 }
94
95 int
96 iic_search(struct device *parent, void *arg, void *aux)
97 {
98 struct iic_softc *sc = (void *) parent;
99 struct cfdata *cf = arg;
100 struct i2c_attach_args ia;
101
102 if (cf->cf_loc[IICCF_ADDR] != -1) {
103 memset(&ia, 0, sizeof(ia));
104 ia.ia_tag = sc->sc_tag;
105 ia.ia_addr = cf->cf_loc[IICCF_ADDR];
106 ia.ia_size = cf->cf_loc[IICCF_SIZE];
107 ia.ia_name = "unknown";
108
109 if (cf->cf_attach->ca_match(parent, cf, &ia) > 0)
110 config_attach(parent, cf, &ia, iic_print);
111 }
112 return (0);
113 }
114
115 int
116 iic_match(struct device *parent, void *arg, void *aux)
117 {
118 struct cfdata *cf = arg;
119 struct i2cbus_attach_args *iba = aux;
120
121
122 return (strcmp(iba->iba_name, cf->cf_driver->cd_name) == 0);
123 }
124
125 void
126 iic_attach(struct device *parent, struct device *self, void *aux)
127 {
128 struct iic_softc *sc = (void *) self;
129 struct i2cbus_attach_args *iba = aux;
130
131 sc->sc_tag = iba->iba_tag;
132
133 #if NIPMI > 0
134 extern int ipmi_enabled;
135
136 if (ipmi_enabled) {
137 printf(": disabled to avoid ipmi0 interactions\n");
138 return;
139 }
140 #endif
141
142 printf("\n");
143
144
145
146
147
148 config_search(iic_search, self, NULL);
149
150
151
152
153 if (iba->iba_bus_scan)
154 (iba->iba_bus_scan)(self, aux, iba->iba_bus_scan_arg);
155 else
156 iic_scan(self, aux);
157 }