2 * Copyright (c) 2012 Robert N. M. Watson
5 * This software was developed by SRI International and the University of
6 * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
7 * ("CTSRD"), as part of the DARPA CRASH research programme.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
34 #include "opt_syscons.h"
36 #include <sys/param.h>
38 #include <sys/condvar.h>
40 #include <sys/consio.h> /* struct vt_mode */
41 #include <sys/endian.h>
42 #include <sys/fbio.h> /* video_adapter_t */
43 #include <sys/kernel.h>
45 #include <sys/malloc.h>
46 #include <sys/module.h>
47 #include <sys/mutex.h>
49 #include <sys/systm.h>
51 #include <machine/bus.h>
52 #include <machine/resource.h>
54 #include <dev/terasic/mtl/terasic_mtl.h>
57 * Device driver for the Terasic Multitouch LCD (MTL). Three separate
58 * sub-drivers that support, respectively, access to device control registers,
59 * the pixel frame buffer, and the text frame buffer. The pixel frame buffer
60 * is hooked up to vt(4), and the text frame buffer to syscons(4).
62 * Eventually, the frame buffer control registers and touch screen input FIFO
63 * will end up being separate sub-drivers as well.
65 * Note: sub-driver detach routines must check whether or not they have
66 * attached as they may be called even if the attach routine hasn't been, on
70 devclass_t terasic_mtl_devclass;
73 terasic_mtl_attach(struct terasic_mtl_softc *sc)
77 error = terasic_mtl_reg_attach(sc);
80 error = terasic_mtl_pixel_attach(sc);
83 error = terasic_mtl_text_attach(sc);
87 * XXXRW: Once we've attached syscons or vt, we can't detach it, so do
91 terasic_mtl_reg_pixel_endian_set(sc, BYTE_ORDER == BIG_ENDIAN);
92 error = terasic_mtl_fbd_attach(sc);
95 terasic_mtl_blend_pixel_set(sc, TERASIC_MTL_ALPHA_OPAQUE);
96 terasic_mtl_blend_textfg_set(sc, TERASIC_MTL_ALPHA_TRANSPARENT);
97 terasic_mtl_blend_textbg_set(sc, TERASIC_MTL_ALPHA_TRANSPARENT);
100 error = terasic_mtl_syscons_attach(sc);
103 terasic_mtl_blend_pixel_set(sc, TERASIC_MTL_ALPHA_TRANSPARENT);
104 terasic_mtl_blend_textfg_set(sc, TERASIC_MTL_ALPHA_OPAQUE);
105 terasic_mtl_blend_textbg_set(sc, TERASIC_MTL_ALPHA_OPAQUE);
107 terasic_mtl_blend_default_set(sc, TERASIC_MTL_COLOR_BLACK);
110 terasic_mtl_text_detach(sc);
111 terasic_mtl_pixel_detach(sc);
112 terasic_mtl_reg_detach(sc);
117 terasic_mtl_detach(struct terasic_mtl_softc *sc)
120 /* XXXRW: syscons and vt can't detach, but try anyway, only to panic. */
122 terasic_mtl_syscons_detach(sc);
125 terasic_mtl_fbd_detach(sc);
128 /* All other aspects of the driver can detach just fine. */
129 terasic_mtl_text_detach(sc);
130 terasic_mtl_pixel_detach(sc);
131 terasic_mtl_reg_detach(sc);