sunxi_mixer.c revision 1.1 1 1.1 jmcneill /* $NetBSD: sunxi_mixer.c,v 1.1 2019/01/30 01:24:00 jmcneill 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.1 jmcneill __KERNEL_RCSID(0, "$NetBSD: sunxi_mixer.c,v 1.1 2019/01/30 01:24:00 jmcneill 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 <drm/drmP.h>
41 1.1 jmcneill #include <drm/drm_crtc.h>
42 1.1 jmcneill #include <drm/drm_crtc_helper.h>
43 1.1 jmcneill #include <drm/drm_plane_helper.h>
44 1.1 jmcneill
45 1.1 jmcneill #include <dev/fdt/fdtvar.h>
46 1.1 jmcneill #include <dev/fdt/fdt_port.h>
47 1.1 jmcneill
48 1.1 jmcneill #include <arm/sunxi/sunxi_drm.h>
49 1.1 jmcneill
50 1.1 jmcneill #define SUNXI_MIXER_FREQ 432000000
51 1.1 jmcneill
52 1.1 jmcneill #define GLB_BASE 0x00000
53 1.1 jmcneill #define BLD_BASE 0x01000
54 1.1 jmcneill #define OVL_BASE(n) (0x02000 + (n) * 0x1000)
55 1.1 jmcneill #define OVL_UI_BASE OVL_BASE(1)
56 1.1 jmcneill
57 1.1 jmcneill /* GLB registers */
58 1.1 jmcneill #define GLB_CTL 0x000
59 1.1 jmcneill #define GLB_CTL_EN __BIT(0)
60 1.1 jmcneill #define GLB_STS 0x004
61 1.1 jmcneill #define GLB_DBUFFER 0x008
62 1.1 jmcneill #define GLB_DBUFFER_DOUBLE_BUFFER_RDY __BIT(0)
63 1.1 jmcneill #define GLB_SIZE 0x00c
64 1.1 jmcneill
65 1.1 jmcneill /* BLD registers */
66 1.1 jmcneill #define BLD_FILL_COLOR_CTL 0x000
67 1.1 jmcneill #define BLD_FILL_COLOR_CTL_P0_EN __BIT(8)
68 1.1 jmcneill #define BLD_CH_ISIZE(n) (0x008 + (n) * 0x10)
69 1.1 jmcneill #define BLD_CH_OFFSET(n) (0x00c + (n) * 0x10)
70 1.1 jmcneill #define BLD_CH_RTCTL 0x080
71 1.1 jmcneill #define BLD_CH_RTCTL_P0 __BITS(3,0)
72 1.1 jmcneill #define BLD_SIZE 0x08c
73 1.1 jmcneill #define BLD_CTL(n) (0x090 + (n) * 0x04)
74 1.1 jmcneill
75 1.1 jmcneill /* OVL_UI registers */
76 1.1 jmcneill #define OVL_UI_ATTR_CTL(n) (0x000 + (n) * 0x20)
77 1.1 jmcneill #define OVL_UI_ATTR_CTL_LAY_FBFMT __BITS(12,8)
78 1.1 jmcneill #define OVL_UI_ATTR_CTL_LAY_FBFMT_XRGB_8888 0x04
79 1.1 jmcneill #define OVL_UI_ATTR_CTL_LAY_EN __BIT(0)
80 1.1 jmcneill #define OVL_UI_MBSIZE(n) (0x004 + (n) * 0x20)
81 1.1 jmcneill #define OVL_UI_COOR(n) (0x008 + (n) * 0x20)
82 1.1 jmcneill #define OVL_UI_PITCH(n) (0x00c + (n) * 0x20)
83 1.1 jmcneill #define OVL_UI_TOP_LADD(n) (0x010 + (n) * 0x20)
84 1.1 jmcneill #define OVL_UI_TOP_HADD 0x080
85 1.1 jmcneill #define OVL_UI_TOP_HADD_LAYER0 __BITS(7,0)
86 1.1 jmcneill #define OVL_UI_SIZE 0x088
87 1.1 jmcneill
88 1.1 jmcneill enum {
89 1.1 jmcneill MIXER_PORT_OUTPUT = 1,
90 1.1 jmcneill };
91 1.1 jmcneill
92 1.1 jmcneill static const char * const compatible[] = {
93 1.1 jmcneill "allwinner,sun50i-a64-de2-mixer-0",
94 1.1 jmcneill "allwinner,sun50i-a64-de2-mixer-1",
95 1.1 jmcneill NULL
96 1.1 jmcneill };
97 1.1 jmcneill
98 1.1 jmcneill struct sunxi_mixer_softc;
99 1.1 jmcneill
100 1.1 jmcneill struct sunxi_mixer_crtc {
101 1.1 jmcneill struct drm_crtc base;
102 1.1 jmcneill struct sunxi_mixer_softc *sc;
103 1.1 jmcneill };
104 1.1 jmcneill
105 1.1 jmcneill struct sunxi_mixer_softc {
106 1.1 jmcneill device_t sc_dev;
107 1.1 jmcneill bus_space_tag_t sc_bst;
108 1.1 jmcneill bus_space_handle_t sc_bsh;
109 1.1 jmcneill int sc_phandle;
110 1.1 jmcneill
111 1.1 jmcneill struct sunxi_mixer_crtc sc_crtc;
112 1.1 jmcneill
113 1.1 jmcneill struct fdt_device_ports sc_ports;
114 1.1 jmcneill };
115 1.1 jmcneill
116 1.1 jmcneill #define GLB_READ(sc, reg) \
117 1.1 jmcneill bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, GLB_BASE + (reg))
118 1.1 jmcneill #define GLB_WRITE(sc, reg, val) \
119 1.1 jmcneill bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, GLB_BASE + (reg), (val))
120 1.1 jmcneill
121 1.1 jmcneill #define BLD_READ(sc, reg) \
122 1.1 jmcneill bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, BLD_BASE + (reg))
123 1.1 jmcneill #define BLD_WRITE(sc, reg, val) \
124 1.1 jmcneill bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, BLD_BASE + (reg), (val))
125 1.1 jmcneill
126 1.1 jmcneill #define OVL_UI_READ(sc, reg) \
127 1.1 jmcneill bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, OVL_UI_BASE + (reg))
128 1.1 jmcneill #define OVL_UI_WRITE(sc, reg, val) \
129 1.1 jmcneill bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, OVL_UI_BASE + (reg), (val))
130 1.1 jmcneill
131 1.1 jmcneill #define to_sunxi_mixer_crtc(x) container_of(x, struct sunxi_mixer_crtc, base)
132 1.1 jmcneill
133 1.1 jmcneill static void
134 1.1 jmcneill sunxi_mixer_destroy(struct drm_crtc *crtc)
135 1.1 jmcneill {
136 1.1 jmcneill drm_crtc_cleanup(crtc);
137 1.1 jmcneill }
138 1.1 jmcneill
139 1.1 jmcneill static const struct drm_crtc_funcs sunxi_mixer_crtc_funcs = {
140 1.1 jmcneill .set_config = drm_crtc_helper_set_config,
141 1.1 jmcneill .destroy = sunxi_mixer_destroy,
142 1.1 jmcneill };
143 1.1 jmcneill
144 1.1 jmcneill static void
145 1.1 jmcneill sunxi_mixer_dpms(struct drm_crtc *crtc, int mode)
146 1.1 jmcneill {
147 1.1 jmcneill }
148 1.1 jmcneill
149 1.1 jmcneill static bool
150 1.1 jmcneill sunxi_mixer_mode_fixup(struct drm_crtc *crtc,
151 1.1 jmcneill const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode)
152 1.1 jmcneill {
153 1.1 jmcneill return true;
154 1.1 jmcneill }
155 1.1 jmcneill
156 1.1 jmcneill static int
157 1.1 jmcneill sunxi_mixer_mode_do_set_base(struct drm_crtc *crtc, struct drm_framebuffer *fb,
158 1.1 jmcneill int x, int y, int atomic)
159 1.1 jmcneill {
160 1.1 jmcneill struct sunxi_mixer_crtc *mixer_crtc = to_sunxi_mixer_crtc(crtc);
161 1.1 jmcneill struct sunxi_mixer_softc * const sc = mixer_crtc->sc;
162 1.1 jmcneill struct sunxi_drm_framebuffer *sfb = atomic?
163 1.1 jmcneill to_sunxi_drm_framebuffer(fb) :
164 1.1 jmcneill to_sunxi_drm_framebuffer(crtc->primary->fb);
165 1.1 jmcneill
166 1.1 jmcneill uint64_t paddr = (uint64_t)sfb->obj->dmamap->dm_segs[0].ds_addr;
167 1.1 jmcneill
168 1.1 jmcneill uint32_t haddr = (paddr >> 32) & OVL_UI_TOP_HADD_LAYER0;
169 1.1 jmcneill uint32_t laddr = paddr & 0xffffffff;
170 1.1 jmcneill
171 1.1 jmcneill /* Framebuffer start address */
172 1.1 jmcneill OVL_UI_WRITE(sc, OVL_UI_TOP_HADD, haddr);
173 1.1 jmcneill OVL_UI_WRITE(sc, OVL_UI_TOP_LADD(0), laddr);
174 1.1 jmcneill
175 1.1 jmcneill return 0;
176 1.1 jmcneill }
177 1.1 jmcneill
178 1.1 jmcneill static int
179 1.1 jmcneill sunxi_mixer_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
180 1.1 jmcneill struct drm_display_mode *adjusted_mode, int x, int y,
181 1.1 jmcneill struct drm_framebuffer *old_fb)
182 1.1 jmcneill {
183 1.1 jmcneill struct sunxi_mixer_crtc *mixer_crtc = to_sunxi_mixer_crtc(crtc);
184 1.1 jmcneill struct sunxi_mixer_softc * const sc = mixer_crtc->sc;
185 1.1 jmcneill uint32_t val;
186 1.1 jmcneill
187 1.1 jmcneill const uint32_t size = ((adjusted_mode->vdisplay - 1) << 16) |
188 1.1 jmcneill (adjusted_mode->hdisplay - 1);
189 1.1 jmcneill const uint32_t offset = (y << 16) | x;
190 1.1 jmcneill
191 1.1 jmcneill /* Set global size */
192 1.1 jmcneill GLB_WRITE(sc, GLB_SIZE, size);
193 1.1 jmcneill
194 1.1 jmcneill /* Enable pipe 0 */
195 1.1 jmcneill BLD_WRITE(sc, BLD_FILL_COLOR_CTL, BLD_FILL_COLOR_CTL_P0_EN);
196 1.1 jmcneill
197 1.1 jmcneill /* Set blender 0 input size */
198 1.1 jmcneill BLD_WRITE(sc, BLD_CH_ISIZE(0), size);
199 1.1 jmcneill /* Set blender 0 offset */
200 1.1 jmcneill BLD_WRITE(sc, BLD_CH_OFFSET(0), offset);
201 1.1 jmcneill /* Route channel 1 to pipe 0 */
202 1.1 jmcneill BLD_WRITE(sc, BLD_CH_RTCTL, __SHIFTIN(1, BLD_CH_RTCTL_P0));
203 1.1 jmcneill /* Set blender output size */
204 1.1 jmcneill BLD_WRITE(sc, BLD_SIZE, size);
205 1.1 jmcneill
206 1.1 jmcneill /* Enable UI overlay in XRGB8888 mode */
207 1.1 jmcneill val = OVL_UI_ATTR_CTL_LAY_EN |
208 1.1 jmcneill __SHIFTIN(OVL_UI_ATTR_CTL_LAY_FBFMT_XRGB_8888, OVL_UI_ATTR_CTL_LAY_FBFMT);
209 1.1 jmcneill OVL_UI_WRITE(sc, OVL_UI_ATTR_CTL(0), val);
210 1.1 jmcneill /* Set UI overlay layer size */
211 1.1 jmcneill OVL_UI_WRITE(sc, OVL_UI_MBSIZE(0), size);
212 1.1 jmcneill /* Set UI overlay offset */
213 1.1 jmcneill OVL_UI_WRITE(sc, OVL_UI_COOR(0), offset);
214 1.1 jmcneill /* Set UI overlay line size */
215 1.1 jmcneill OVL_UI_WRITE(sc, OVL_UI_PITCH(0), adjusted_mode->hdisplay * 4);
216 1.1 jmcneill /* Set UI overlay window size */
217 1.1 jmcneill OVL_UI_WRITE(sc, OVL_UI_SIZE, size);
218 1.1 jmcneill
219 1.1 jmcneill sunxi_mixer_mode_do_set_base(crtc, old_fb, x, y, 0);
220 1.1 jmcneill
221 1.1 jmcneill return 0;
222 1.1 jmcneill }
223 1.1 jmcneill
224 1.1 jmcneill static int
225 1.1 jmcneill sunxi_mixer_mode_set_base(struct drm_crtc *crtc, int x, int y,
226 1.1 jmcneill struct drm_framebuffer *old_fb)
227 1.1 jmcneill {
228 1.1 jmcneill struct sunxi_mixer_crtc *mixer_crtc = to_sunxi_mixer_crtc(crtc);
229 1.1 jmcneill struct sunxi_mixer_softc * const sc = mixer_crtc->sc;
230 1.1 jmcneill
231 1.1 jmcneill sunxi_mixer_mode_do_set_base(crtc, old_fb, x, y, 0);
232 1.1 jmcneill
233 1.1 jmcneill /* Commit settings */
234 1.1 jmcneill GLB_WRITE(sc, GLB_DBUFFER, GLB_DBUFFER_DOUBLE_BUFFER_RDY);
235 1.1 jmcneill
236 1.1 jmcneill return 0;
237 1.1 jmcneill }
238 1.1 jmcneill
239 1.1 jmcneill static int
240 1.1 jmcneill sunxi_mixer_mode_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,
241 1.1 jmcneill int x, int y, enum mode_set_atomic state)
242 1.1 jmcneill {
243 1.1 jmcneill struct sunxi_mixer_crtc *mixer_crtc = to_sunxi_mixer_crtc(crtc);
244 1.1 jmcneill struct sunxi_mixer_softc * const sc = mixer_crtc->sc;
245 1.1 jmcneill
246 1.1 jmcneill sunxi_mixer_mode_do_set_base(crtc, fb, x, y, 1);
247 1.1 jmcneill
248 1.1 jmcneill /* Commit settings */
249 1.1 jmcneill GLB_WRITE(sc, GLB_DBUFFER, GLB_DBUFFER_DOUBLE_BUFFER_RDY);
250 1.1 jmcneill
251 1.1 jmcneill return 0;
252 1.1 jmcneill }
253 1.1 jmcneill
254 1.1 jmcneill static void
255 1.1 jmcneill sunxi_mixer_disable(struct drm_crtc *crtc)
256 1.1 jmcneill {
257 1.1 jmcneill }
258 1.1 jmcneill
259 1.1 jmcneill static void
260 1.1 jmcneill sunxi_mixer_prepare(struct drm_crtc *crtc)
261 1.1 jmcneill {
262 1.1 jmcneill struct sunxi_mixer_crtc *mixer_crtc = to_sunxi_mixer_crtc(crtc);
263 1.1 jmcneill struct sunxi_mixer_softc * const sc = mixer_crtc->sc;
264 1.1 jmcneill
265 1.1 jmcneill /* RT enable */
266 1.1 jmcneill GLB_WRITE(sc, GLB_CTL, GLB_CTL_EN);
267 1.1 jmcneill }
268 1.1 jmcneill
269 1.1 jmcneill static void
270 1.1 jmcneill sunxi_mixer_commit(struct drm_crtc *crtc)
271 1.1 jmcneill {
272 1.1 jmcneill struct sunxi_mixer_crtc *mixer_crtc = to_sunxi_mixer_crtc(crtc);
273 1.1 jmcneill struct sunxi_mixer_softc * const sc = mixer_crtc->sc;
274 1.1 jmcneill
275 1.1 jmcneill /* Commit settings */
276 1.1 jmcneill GLB_WRITE(sc, GLB_DBUFFER, GLB_DBUFFER_DOUBLE_BUFFER_RDY);
277 1.1 jmcneill }
278 1.1 jmcneill
279 1.1 jmcneill static const struct drm_crtc_helper_funcs sunxi_mixer_crtc_helper_funcs = {
280 1.1 jmcneill .dpms = sunxi_mixer_dpms,
281 1.1 jmcneill .mode_fixup = sunxi_mixer_mode_fixup,
282 1.1 jmcneill .mode_set = sunxi_mixer_mode_set,
283 1.1 jmcneill .mode_set_base = sunxi_mixer_mode_set_base,
284 1.1 jmcneill .mode_set_base_atomic = sunxi_mixer_mode_set_base_atomic,
285 1.1 jmcneill .disable = sunxi_mixer_disable,
286 1.1 jmcneill .prepare = sunxi_mixer_prepare,
287 1.1 jmcneill .commit = sunxi_mixer_commit,
288 1.1 jmcneill };
289 1.1 jmcneill
290 1.1 jmcneill static int
291 1.1 jmcneill sunxi_mixer_ep_activate(device_t dev, struct fdt_endpoint *ep, bool activate)
292 1.1 jmcneill {
293 1.1 jmcneill struct sunxi_mixer_softc * const sc = device_private(dev);
294 1.1 jmcneill struct drm_device *ddev;
295 1.1 jmcneill
296 1.1 jmcneill if (!activate)
297 1.1 jmcneill return EINVAL;
298 1.1 jmcneill
299 1.1 jmcneill ddev = sunxi_drm_endpoint_device(ep);
300 1.1 jmcneill if (ddev == NULL) {
301 1.1 jmcneill DRM_ERROR("couldn't find DRM device\n");
302 1.1 jmcneill return ENXIO;
303 1.1 jmcneill }
304 1.1 jmcneill
305 1.1 jmcneill sc->sc_crtc.sc = sc;
306 1.1 jmcneill
307 1.1 jmcneill drm_crtc_init(ddev, &sc->sc_crtc.base, &sunxi_mixer_crtc_funcs);
308 1.1 jmcneill drm_crtc_helper_add(&sc->sc_crtc.base, &sunxi_mixer_crtc_helper_funcs);
309 1.1 jmcneill
310 1.1 jmcneill return fdt_endpoint_activate(ep, activate);
311 1.1 jmcneill }
312 1.1 jmcneill
313 1.1 jmcneill static void *
314 1.1 jmcneill sunxi_mixer_ep_get_data(device_t dev, struct fdt_endpoint *ep)
315 1.1 jmcneill {
316 1.1 jmcneill struct sunxi_mixer_softc * const sc = device_private(dev);
317 1.1 jmcneill
318 1.1 jmcneill return &sc->sc_crtc;
319 1.1 jmcneill }
320 1.1 jmcneill
321 1.1 jmcneill static int
322 1.1 jmcneill sunxi_mixer_match(device_t parent, cfdata_t cf, void *aux)
323 1.1 jmcneill {
324 1.1 jmcneill struct fdt_attach_args * const faa = aux;
325 1.1 jmcneill
326 1.1 jmcneill return of_match_compatible(faa->faa_phandle, compatible);
327 1.1 jmcneill }
328 1.1 jmcneill
329 1.1 jmcneill static void
330 1.1 jmcneill sunxi_mixer_attach(device_t parent, device_t self, void *aux)
331 1.1 jmcneill {
332 1.1 jmcneill struct sunxi_mixer_softc * const sc = device_private(self);
333 1.1 jmcneill struct fdt_attach_args * const faa = aux;
334 1.1 jmcneill struct fdt_endpoint *out_ep;
335 1.1 jmcneill const int phandle = faa->faa_phandle;
336 1.1 jmcneill struct clk *clk_bus, *clk_mod;
337 1.1 jmcneill struct fdtbus_reset *rst;
338 1.1 jmcneill bus_addr_t addr;
339 1.1 jmcneill bus_size_t size;
340 1.1 jmcneill
341 1.1 jmcneill if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
342 1.1 jmcneill aprint_error(": couldn't get registers\n");
343 1.1 jmcneill return;
344 1.1 jmcneill }
345 1.1 jmcneill
346 1.1 jmcneill rst = fdtbus_reset_get_index(phandle, 0);
347 1.1 jmcneill if (rst == NULL || fdtbus_reset_deassert(rst) != 0) {
348 1.1 jmcneill aprint_error(": couldn't de-assert reset\n");
349 1.1 jmcneill return;
350 1.1 jmcneill }
351 1.1 jmcneill
352 1.1 jmcneill clk_bus = fdtbus_clock_get(phandle, "bus");
353 1.1 jmcneill if (clk_bus == NULL || clk_enable(clk_bus) != 0) {
354 1.1 jmcneill aprint_error(": couldn't enable bus clock\n");
355 1.1 jmcneill return;
356 1.1 jmcneill }
357 1.1 jmcneill
358 1.1 jmcneill clk_mod = fdtbus_clock_get(phandle, "mod");
359 1.1 jmcneill if (clk_mod == NULL ||
360 1.1 jmcneill clk_set_rate(clk_mod, SUNXI_MIXER_FREQ) != 0 ||
361 1.1 jmcneill clk_enable(clk_mod) != 0) {
362 1.1 jmcneill aprint_error(": couldn't enable mod clock\n");
363 1.1 jmcneill return;
364 1.1 jmcneill }
365 1.1 jmcneill
366 1.1 jmcneill sc->sc_dev = self;
367 1.1 jmcneill sc->sc_bst = faa->faa_bst;
368 1.1 jmcneill if (bus_space_map(sc->sc_bst, addr, size, 0, &sc->sc_bsh) != 0) {
369 1.1 jmcneill aprint_error(": couldn't map registers\n");
370 1.1 jmcneill return;
371 1.1 jmcneill }
372 1.1 jmcneill sc->sc_phandle = faa->faa_phandle;
373 1.1 jmcneill
374 1.1 jmcneill aprint_naive("\n");
375 1.1 jmcneill aprint_normal(": Display Engine Mixer\n");
376 1.1 jmcneill
377 1.1 jmcneill sc->sc_ports.dp_ep_activate = sunxi_mixer_ep_activate;
378 1.1 jmcneill sc->sc_ports.dp_ep_get_data = sunxi_mixer_ep_get_data;
379 1.1 jmcneill fdt_ports_register(&sc->sc_ports, self, phandle, EP_DRM_CRTC);
380 1.1 jmcneill
381 1.1 jmcneill out_ep = fdt_endpoint_get_from_index(&sc->sc_ports, MIXER_PORT_OUTPUT, 0);
382 1.1 jmcneill if (out_ep != NULL)
383 1.1 jmcneill sunxi_drm_register_endpoint(phandle, out_ep);
384 1.1 jmcneill }
385 1.1 jmcneill
386 1.1 jmcneill CFATTACH_DECL_NEW(sunxi_mixer, sizeof(struct sunxi_mixer_softc),
387 1.1 jmcneill sunxi_mixer_match, sunxi_mixer_attach, NULL, NULL);
388