anxedp.c revision 1.4 1 1.4 thorpej /* $NetBSD: anxedp.c,v 1.4 2021/01/17 21:42:35 thorpej Exp $ */
2 1.1 jmcneill
3 1.1 jmcneill /*-
4 1.1 jmcneill * Copyright (c) 2019 Jared D. McNeill <jmcneill (at) invisible.ca>
5 1.1 jmcneill * All rights reserved.
6 1.1 jmcneill *
7 1.1 jmcneill * Redistribution and use in source and binary forms, with or without
8 1.1 jmcneill * modification, are permitted provided that the following conditions
9 1.1 jmcneill * are met:
10 1.1 jmcneill * 1. Redistributions of source code must retain the above copyright
11 1.1 jmcneill * notice, this list of conditions and the following disclaimer.
12 1.1 jmcneill * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 jmcneill * notice, this list of conditions and the following disclaimer in the
14 1.1 jmcneill * documentation and/or other materials provided with the distribution.
15 1.1 jmcneill *
16 1.1 jmcneill * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.1 jmcneill * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.1 jmcneill * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.1 jmcneill * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.1 jmcneill * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 1.1 jmcneill * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 1.1 jmcneill * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 1.1 jmcneill * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 1.1 jmcneill * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1 jmcneill * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1 jmcneill * SUCH DAMAGE.
27 1.1 jmcneill */
28 1.1 jmcneill
29 1.1 jmcneill #include <sys/cdefs.h>
30 1.4 thorpej __KERNEL_RCSID(0, "$NetBSD: anxedp.c,v 1.4 2021/01/17 21:42:35 thorpej Exp $");
31 1.1 jmcneill
32 1.1 jmcneill #include <sys/param.h>
33 1.1 jmcneill #include <sys/bus.h>
34 1.1 jmcneill #include <sys/device.h>
35 1.1 jmcneill #include <sys/intr.h>
36 1.1 jmcneill #include <sys/systm.h>
37 1.1 jmcneill #include <sys/kernel.h>
38 1.1 jmcneill #include <sys/conf.h>
39 1.1 jmcneill
40 1.1 jmcneill #include <dev/ic/dw_hdmi.h>
41 1.1 jmcneill
42 1.1 jmcneill #include <dev/i2c/i2cvar.h>
43 1.1 jmcneill #include <dev/i2c/ddcvar.h>
44 1.1 jmcneill #include <dev/i2c/ddcreg.h>
45 1.1 jmcneill #include <dev/videomode/videomode.h>
46 1.1 jmcneill #include <dev/videomode/edidvar.h>
47 1.1 jmcneill
48 1.1 jmcneill #include <dev/fdt/fdtvar.h>
49 1.1 jmcneill #include <dev/fdt/fdt_port.h>
50 1.1 jmcneill
51 1.1 jmcneill #include <drm/drmP.h>
52 1.1 jmcneill #include <drm/drm_crtc.h>
53 1.1 jmcneill #include <drm/drm_crtc_helper.h>
54 1.1 jmcneill #include <drm/drm_edid.h>
55 1.1 jmcneill
56 1.1 jmcneill #define ANX_DP_AUX_CH_CTL_1 0xe5
57 1.1 jmcneill #define ANX_AUX_LENGTH __BITS(7,4)
58 1.1 jmcneill #define ANX_AUX_TX_COMM __BITS(3,0)
59 1.1 jmcneill #define ANX_AUX_TX_COMM_MOT 4
60 1.1 jmcneill #define ANX_AUX_TX_COMM_READ 1
61 1.1 jmcneill #define ANX_DP_AUX_ADDR(n) (0xe6 + (n))
62 1.1 jmcneill #define ANX_DP_AUX_CH_CTL_2 0xe9
63 1.1 jmcneill #define ANX_ADDR_ONLY __BIT(1)
64 1.1 jmcneill #define ANX_AUX_EN __BIT(0)
65 1.1 jmcneill #define ANX_BUF_DATA(n) (0xf0 + (n))
66 1.1 jmcneill
67 1.1 jmcneill #define ANX_DP_INT_STA 0xf7
68 1.1 jmcneill #define ANX_RPLY_RECEIV __BIT(1)
69 1.1 jmcneill
70 1.1 jmcneill static const struct device_compatible_entry compat_data[] = {
71 1.4 thorpej { .compat = "analogix,anx6345" },
72 1.4 thorpej
73 1.4 thorpej { 0 }
74 1.1 jmcneill };
75 1.1 jmcneill
76 1.1 jmcneill struct anxedp_softc;
77 1.1 jmcneill
78 1.1 jmcneill struct anxedp_connector {
79 1.1 jmcneill struct drm_connector base;
80 1.1 jmcneill struct anxedp_softc *sc;
81 1.1 jmcneill };
82 1.1 jmcneill
83 1.1 jmcneill struct anxedp_softc {
84 1.1 jmcneill device_t sc_dev;
85 1.1 jmcneill i2c_tag_t sc_i2c;
86 1.1 jmcneill i2c_addr_t sc_addr;
87 1.1 jmcneill int sc_phandle;
88 1.1 jmcneill
89 1.1 jmcneill struct anxedp_connector sc_connector;
90 1.1 jmcneill struct drm_bridge sc_bridge;
91 1.1 jmcneill
92 1.1 jmcneill struct fdt_device_ports sc_ports;
93 1.1 jmcneill struct drm_display_mode sc_curmode;
94 1.1 jmcneill };
95 1.1 jmcneill
96 1.1 jmcneill #define to_anxedp_connector(x) container_of(x, struct anxedp_connector, base)
97 1.1 jmcneill
98 1.1 jmcneill static uint8_t
99 1.1 jmcneill anxedp_read(struct anxedp_softc *sc, u_int off, uint8_t reg)
100 1.1 jmcneill {
101 1.1 jmcneill uint8_t val;
102 1.1 jmcneill
103 1.3 thorpej if (iic_smbus_read_byte(sc->sc_i2c, sc->sc_addr + off, reg, &val, 0) != 0)
104 1.1 jmcneill val = 0xff;
105 1.1 jmcneill
106 1.1 jmcneill return val;
107 1.1 jmcneill }
108 1.1 jmcneill
109 1.1 jmcneill static void
110 1.1 jmcneill anxedp_write(struct anxedp_softc *sc, u_int off, uint8_t reg, uint8_t val)
111 1.1 jmcneill {
112 1.3 thorpej (void)iic_smbus_write_byte(sc->sc_i2c, sc->sc_addr + off, reg, val, 0);
113 1.1 jmcneill }
114 1.1 jmcneill
115 1.2 jmcneill static int
116 1.2 jmcneill anxedp_connector_dpms(struct drm_connector *connector, int mode)
117 1.2 jmcneill {
118 1.2 jmcneill int error;
119 1.2 jmcneill
120 1.2 jmcneill if (mode != DRM_MODE_DPMS_ON)
121 1.2 jmcneill pmf_event_inject(NULL, PMFE_DISPLAY_OFF);
122 1.2 jmcneill
123 1.2 jmcneill error = drm_helper_connector_dpms(connector, mode);
124 1.2 jmcneill
125 1.2 jmcneill if (mode == DRM_MODE_DPMS_ON)
126 1.2 jmcneill pmf_event_inject(NULL, PMFE_DISPLAY_ON);
127 1.2 jmcneill
128 1.2 jmcneill return error;
129 1.2 jmcneill }
130 1.2 jmcneill
131 1.1 jmcneill static enum drm_connector_status
132 1.1 jmcneill anxedp_connector_detect(struct drm_connector *connector, bool force)
133 1.1 jmcneill {
134 1.1 jmcneill return connector_status_connected;
135 1.1 jmcneill }
136 1.1 jmcneill
137 1.1 jmcneill static void
138 1.1 jmcneill anxedp_connector_destroy(struct drm_connector *connector)
139 1.1 jmcneill {
140 1.1 jmcneill drm_connector_unregister(connector);
141 1.1 jmcneill drm_connector_cleanup(connector);
142 1.1 jmcneill }
143 1.1 jmcneill
144 1.1 jmcneill static const struct drm_connector_funcs anxedp_connector_funcs = {
145 1.2 jmcneill .dpms = anxedp_connector_dpms,
146 1.1 jmcneill .detect = anxedp_connector_detect,
147 1.1 jmcneill .fill_modes = drm_helper_probe_single_connector_modes,
148 1.1 jmcneill .destroy = anxedp_connector_destroy,
149 1.1 jmcneill };
150 1.1 jmcneill
151 1.1 jmcneill static int
152 1.1 jmcneill anxedp_aux_wait(struct anxedp_softc *sc)
153 1.1 jmcneill {
154 1.1 jmcneill uint8_t val;
155 1.1 jmcneill int retry;
156 1.1 jmcneill
157 1.1 jmcneill for (retry = 1000; retry > 0; retry--) {
158 1.1 jmcneill val = anxedp_read(sc, 0, ANX_DP_AUX_CH_CTL_2);
159 1.1 jmcneill if ((val & ANX_AUX_EN) == 0)
160 1.1 jmcneill break;
161 1.1 jmcneill delay(100);
162 1.1 jmcneill }
163 1.1 jmcneill if (retry == 0) {
164 1.1 jmcneill device_printf(sc->sc_dev, "aux transfer timeout\n");
165 1.1 jmcneill return ETIMEDOUT;
166 1.1 jmcneill }
167 1.1 jmcneill
168 1.1 jmcneill for (retry = 1000; retry > 0; retry--) {
169 1.1 jmcneill val = anxedp_read(sc, 1, ANX_DP_INT_STA);
170 1.1 jmcneill if ((val & ANX_RPLY_RECEIV) != 0) {
171 1.1 jmcneill anxedp_write(sc, 1, ANX_DP_INT_STA, val);
172 1.1 jmcneill break;
173 1.1 jmcneill }
174 1.1 jmcneill delay(100);
175 1.1 jmcneill }
176 1.1 jmcneill if (retry == 0) {
177 1.1 jmcneill device_printf(sc->sc_dev, "aux transfer timeout\n");
178 1.1 jmcneill return ETIMEDOUT;
179 1.1 jmcneill }
180 1.1 jmcneill
181 1.1 jmcneill return 0;
182 1.1 jmcneill }
183 1.1 jmcneill
184 1.1 jmcneill static int
185 1.1 jmcneill anxedp_aux_transfer(struct anxedp_softc *sc, uint8_t comm, uint32_t addr,
186 1.1 jmcneill uint8_t *buf, int buflen)
187 1.1 jmcneill {
188 1.1 jmcneill uint8_t ctrl[2];
189 1.1 jmcneill int n, error;
190 1.1 jmcneill
191 1.1 jmcneill ctrl[0] = __SHIFTIN(comm, ANX_AUX_TX_COMM);
192 1.1 jmcneill if (buflen > 0)
193 1.1 jmcneill ctrl[0] |= __SHIFTIN(buflen - 1, ANX_AUX_LENGTH);
194 1.1 jmcneill ctrl[1] = ANX_AUX_EN;
195 1.1 jmcneill if (buflen == 0)
196 1.1 jmcneill ctrl[1] |= ANX_ADDR_ONLY;
197 1.1 jmcneill
198 1.1 jmcneill if (comm != ANX_AUX_TX_COMM_READ) {
199 1.1 jmcneill for (n = 0; n < buflen; n++)
200 1.1 jmcneill anxedp_write(sc, 0, ANX_BUF_DATA(n), buf[n]);
201 1.1 jmcneill }
202 1.1 jmcneill
203 1.1 jmcneill anxedp_write(sc, 0, ANX_DP_AUX_ADDR(0), addr & 0xff);
204 1.1 jmcneill anxedp_write(sc, 0, ANX_DP_AUX_ADDR(1), (addr >> 8) & 0xff);
205 1.1 jmcneill anxedp_write(sc, 0, ANX_DP_AUX_ADDR(2), (addr >> 16) & 0xf);
206 1.1 jmcneill anxedp_write(sc, 0, ANX_DP_AUX_CH_CTL_1, ctrl[0]);
207 1.1 jmcneill anxedp_write(sc, 0, ANX_DP_AUX_CH_CTL_2, ctrl[1]);
208 1.1 jmcneill
209 1.1 jmcneill error = anxedp_aux_wait(sc);
210 1.1 jmcneill if (error != 0)
211 1.1 jmcneill return error;
212 1.1 jmcneill
213 1.1 jmcneill if (comm == ANX_AUX_TX_COMM_READ) {
214 1.1 jmcneill for (n = 0; n < buflen; n++)
215 1.1 jmcneill buf[n] = anxedp_read(sc, 0, ANX_BUF_DATA(n));
216 1.1 jmcneill }
217 1.1 jmcneill
218 1.1 jmcneill return 0;
219 1.1 jmcneill }
220 1.1 jmcneill
221 1.1 jmcneill static int
222 1.1 jmcneill anxedp_read_edid(struct anxedp_softc *sc, uint8_t *edid, int edidlen)
223 1.1 jmcneill {
224 1.1 jmcneill int error;
225 1.1 jmcneill uint8_t n;
226 1.1 jmcneill
227 1.1 jmcneill for (n = 0; n < edidlen; n += 16) {
228 1.1 jmcneill const int xferlen = MIN(edidlen - n, 16);
229 1.1 jmcneill
230 1.1 jmcneill error = anxedp_aux_transfer(sc, ANX_AUX_TX_COMM_MOT, DDC_ADDR, &n, 1);
231 1.1 jmcneill if (error != 0)
232 1.1 jmcneill return error;
233 1.1 jmcneill
234 1.1 jmcneill error = anxedp_aux_transfer(sc, ANX_AUX_TX_COMM_READ, DDC_ADDR, &edid[n], xferlen);
235 1.1 jmcneill if (error != 0)
236 1.1 jmcneill return error;
237 1.1 jmcneill }
238 1.1 jmcneill
239 1.1 jmcneill return 0;
240 1.1 jmcneill }
241 1.1 jmcneill
242 1.1 jmcneill static int
243 1.1 jmcneill anxedp_connector_get_modes(struct drm_connector *connector)
244 1.1 jmcneill {
245 1.1 jmcneill struct anxedp_connector *anxedp_connector = to_anxedp_connector(connector);
246 1.1 jmcneill struct anxedp_softc * const sc = anxedp_connector->sc;
247 1.1 jmcneill char edid[EDID_LENGTH];
248 1.1 jmcneill struct edid *pedid = NULL;
249 1.1 jmcneill int error;
250 1.1 jmcneill
251 1.3 thorpej iic_acquire_bus(sc->sc_i2c, 0);
252 1.1 jmcneill error = anxedp_read_edid(sc, edid, sizeof(edid));
253 1.3 thorpej iic_release_bus(sc->sc_i2c, 0);
254 1.1 jmcneill if (error == 0)
255 1.1 jmcneill pedid = (struct edid *)edid;
256 1.1 jmcneill
257 1.1 jmcneill drm_mode_connector_update_edid_property(connector, pedid);
258 1.1 jmcneill if (pedid == NULL)
259 1.1 jmcneill return 0;
260 1.1 jmcneill
261 1.1 jmcneill error = drm_add_edid_modes(connector, pedid);
262 1.1 jmcneill drm_edid_to_eld(connector, pedid);
263 1.1 jmcneill
264 1.1 jmcneill return error;
265 1.1 jmcneill }
266 1.1 jmcneill
267 1.1 jmcneill static struct drm_encoder *
268 1.1 jmcneill anxedp_connector_best_encoder(struct drm_connector *connector)
269 1.1 jmcneill {
270 1.1 jmcneill int enc_id = connector->encoder_ids[0];
271 1.1 jmcneill struct drm_mode_object *obj;
272 1.1 jmcneill struct drm_encoder *encoder = NULL;
273 1.1 jmcneill
274 1.1 jmcneill if (enc_id) {
275 1.1 jmcneill obj = drm_mode_object_find(connector->dev, enc_id,
276 1.1 jmcneill DRM_MODE_OBJECT_ENCODER);
277 1.1 jmcneill if (obj == NULL)
278 1.1 jmcneill return NULL;
279 1.1 jmcneill encoder = obj_to_encoder(obj);
280 1.1 jmcneill }
281 1.1 jmcneill
282 1.1 jmcneill return encoder;
283 1.1 jmcneill }
284 1.1 jmcneill
285 1.1 jmcneill static const struct drm_connector_helper_funcs anxedp_connector_helper_funcs = {
286 1.1 jmcneill .get_modes = anxedp_connector_get_modes,
287 1.1 jmcneill .best_encoder = anxedp_connector_best_encoder,
288 1.1 jmcneill };
289 1.1 jmcneill
290 1.1 jmcneill static int
291 1.1 jmcneill anxedp_bridge_attach(struct drm_bridge *bridge)
292 1.1 jmcneill {
293 1.1 jmcneill struct anxedp_softc * const sc = bridge->driver_private;
294 1.1 jmcneill struct anxedp_connector *anxedp_connector = &sc->sc_connector;
295 1.1 jmcneill struct drm_connector *connector = &anxedp_connector->base;
296 1.1 jmcneill int error;
297 1.1 jmcneill
298 1.1 jmcneill anxedp_connector->sc = sc;
299 1.1 jmcneill
300 1.1 jmcneill connector->polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT;
301 1.1 jmcneill connector->interlace_allowed = 0;
302 1.1 jmcneill connector->doublescan_allowed = 0;
303 1.1 jmcneill
304 1.1 jmcneill drm_connector_init(bridge->dev, connector, &anxedp_connector_funcs,
305 1.1 jmcneill connector->connector_type);
306 1.1 jmcneill drm_connector_helper_add(connector, &anxedp_connector_helper_funcs);
307 1.1 jmcneill
308 1.1 jmcneill error = drm_mode_connector_attach_encoder(connector, bridge->encoder);
309 1.1 jmcneill if (error != 0)
310 1.1 jmcneill return error;
311 1.1 jmcneill
312 1.1 jmcneill return drm_connector_register(connector);
313 1.1 jmcneill }
314 1.1 jmcneill
315 1.1 jmcneill static void
316 1.1 jmcneill anxedp_bridge_enable(struct drm_bridge *bridge)
317 1.1 jmcneill {
318 1.1 jmcneill }
319 1.1 jmcneill
320 1.1 jmcneill static void
321 1.1 jmcneill anxedp_bridge_pre_enable(struct drm_bridge *bridge)
322 1.1 jmcneill {
323 1.1 jmcneill }
324 1.1 jmcneill
325 1.1 jmcneill static void
326 1.1 jmcneill anxedp_bridge_disable(struct drm_bridge *bridge)
327 1.1 jmcneill {
328 1.1 jmcneill }
329 1.1 jmcneill
330 1.1 jmcneill static void
331 1.1 jmcneill anxedp_bridge_post_disable(struct drm_bridge *bridge)
332 1.1 jmcneill {
333 1.1 jmcneill }
334 1.1 jmcneill
335 1.1 jmcneill static void
336 1.1 jmcneill anxedp_bridge_mode_set(struct drm_bridge *bridge,
337 1.1 jmcneill struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode)
338 1.1 jmcneill {
339 1.1 jmcneill struct anxedp_softc * const sc = bridge->driver_private;
340 1.1 jmcneill
341 1.1 jmcneill sc->sc_curmode = *adjusted_mode;
342 1.1 jmcneill }
343 1.1 jmcneill
344 1.1 jmcneill static bool
345 1.1 jmcneill anxedp_bridge_mode_fixup(struct drm_bridge *bridge,
346 1.1 jmcneill const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode)
347 1.1 jmcneill {
348 1.1 jmcneill return true;
349 1.1 jmcneill }
350 1.1 jmcneill
351 1.1 jmcneill static const struct drm_bridge_funcs anxedp_bridge_funcs = {
352 1.1 jmcneill .attach = anxedp_bridge_attach,
353 1.1 jmcneill .enable = anxedp_bridge_enable,
354 1.1 jmcneill .pre_enable = anxedp_bridge_pre_enable,
355 1.1 jmcneill .disable = anxedp_bridge_disable,
356 1.1 jmcneill .post_disable = anxedp_bridge_post_disable,
357 1.1 jmcneill .mode_set = anxedp_bridge_mode_set,
358 1.1 jmcneill .mode_fixup = anxedp_bridge_mode_fixup,
359 1.1 jmcneill };
360 1.1 jmcneill
361 1.1 jmcneill static int
362 1.1 jmcneill anxedp_ep_activate(device_t dev, struct fdt_endpoint *ep, bool activate)
363 1.1 jmcneill {
364 1.1 jmcneill struct anxedp_softc * const sc = device_private(dev);
365 1.1 jmcneill struct fdt_endpoint *in_ep = fdt_endpoint_remote(ep);
366 1.1 jmcneill struct drm_encoder *encoder;
367 1.1 jmcneill struct drm_bridge *bridge;
368 1.1 jmcneill int error;
369 1.1 jmcneill
370 1.1 jmcneill if (!activate)
371 1.1 jmcneill return EINVAL;
372 1.1 jmcneill
373 1.1 jmcneill if (fdt_endpoint_port_index(ep) != 0)
374 1.1 jmcneill return EINVAL;
375 1.1 jmcneill
376 1.1 jmcneill switch (fdt_endpoint_type(in_ep)) {
377 1.1 jmcneill case EP_DRM_ENCODER:
378 1.1 jmcneill encoder = fdt_endpoint_get_data(in_ep);
379 1.1 jmcneill break;
380 1.1 jmcneill case EP_DRM_BRIDGE:
381 1.1 jmcneill bridge = fdt_endpoint_get_data(in_ep);
382 1.1 jmcneill encoder = bridge->encoder;
383 1.1 jmcneill break;
384 1.1 jmcneill default:
385 1.1 jmcneill encoder = NULL;
386 1.1 jmcneill break;
387 1.1 jmcneill }
388 1.1 jmcneill
389 1.1 jmcneill if (encoder == NULL)
390 1.1 jmcneill return EINVAL;
391 1.1 jmcneill
392 1.1 jmcneill sc->sc_connector.base.connector_type = DRM_MODE_CONNECTOR_eDP;
393 1.1 jmcneill
394 1.1 jmcneill sc->sc_bridge.driver_private = sc;
395 1.1 jmcneill sc->sc_bridge.funcs = &anxedp_bridge_funcs;
396 1.1 jmcneill sc->sc_bridge.encoder = encoder;
397 1.1 jmcneill
398 1.1 jmcneill error = drm_bridge_attach(encoder->dev, &sc->sc_bridge);
399 1.1 jmcneill if (error != 0)
400 1.1 jmcneill return EIO;
401 1.1 jmcneill
402 1.1 jmcneill encoder->bridge = &sc->sc_bridge;
403 1.1 jmcneill
404 1.1 jmcneill return 0;
405 1.1 jmcneill }
406 1.1 jmcneill
407 1.1 jmcneill static void *
408 1.1 jmcneill anxedp_ep_get_data(device_t dev, struct fdt_endpoint *ep)
409 1.1 jmcneill {
410 1.1 jmcneill struct anxedp_softc * const sc = device_private(dev);
411 1.1 jmcneill
412 1.1 jmcneill return &sc->sc_bridge;
413 1.1 jmcneill }
414 1.1 jmcneill
415 1.1 jmcneill static int
416 1.1 jmcneill anxedp_match(device_t parent, cfdata_t match, void *aux)
417 1.1 jmcneill {
418 1.1 jmcneill struct i2c_attach_args *ia = aux;
419 1.1 jmcneill int match_result;
420 1.1 jmcneill
421 1.1 jmcneill if (iic_use_direct_match(ia, match, compat_data, &match_result))
422 1.1 jmcneill return match_result;
423 1.1 jmcneill
424 1.1 jmcneill /* This device is direct-config only */
425 1.1 jmcneill
426 1.1 jmcneill return 0;
427 1.1 jmcneill }
428 1.1 jmcneill
429 1.1 jmcneill static void
430 1.1 jmcneill anxedp_attach(device_t parent, device_t self, void *aux)
431 1.1 jmcneill {
432 1.1 jmcneill struct anxedp_softc * const sc = device_private(self);
433 1.1 jmcneill struct i2c_attach_args * const ia = aux;
434 1.1 jmcneill
435 1.1 jmcneill sc->sc_dev = self;
436 1.1 jmcneill sc->sc_i2c = ia->ia_tag;
437 1.1 jmcneill sc->sc_addr = ia->ia_addr;
438 1.1 jmcneill sc->sc_phandle = ia->ia_cookie;
439 1.1 jmcneill
440 1.1 jmcneill aprint_naive("\n");
441 1.1 jmcneill aprint_normal(": eDP TX\n");
442 1.1 jmcneill
443 1.1 jmcneill sc->sc_ports.dp_ep_activate = anxedp_ep_activate;
444 1.1 jmcneill sc->sc_ports.dp_ep_get_data = anxedp_ep_get_data;
445 1.1 jmcneill fdt_ports_register(&sc->sc_ports, self, sc->sc_phandle, EP_DRM_BRIDGE);
446 1.1 jmcneill }
447 1.1 jmcneill
448 1.1 jmcneill CFATTACH_DECL_NEW(anxedp, sizeof(struct anxedp_softc),
449 1.1 jmcneill anxedp_match, anxedp_attach, NULL, NULL);
450