2 * Copyright (c) 2014 Ed Maste
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 <sys/param.h>
37 #include <sys/kernel.h>
38 #include <sys/module.h>
41 #include <dev/fdt/fdt_common.h>
42 #include <dev/ofw/ofw_bus.h>
43 #include <dev/ofw/ofw_bus_subr.h>
45 #include <dev/terasic/mtl/terasic_mtl.h>
47 #include <dev/vt/colors/vt_termcolors.h>
50 * Terasic Multitouch LCD (MTL) vt(4) framebuffer driver.
57 terasic_mtl_fbd_panel_info(struct terasic_mtl_softc *sc, struct fb_info *info)
63 if ((node = ofw_bus_get_node(sc->mtl_dev)) == -1)
67 if ((len = OF_getproplen(node, "panel-size")) != sizeof(dts_value))
69 OF_getencprop(node, "panel-size", dts_value, len);
70 info->fb_width = dts_value[0];
71 info->fb_height = dts_value[1];
72 info->fb_bpp = info->fb_depth = 32;
73 info->fb_stride = info->fb_width * (info->fb_depth / 8);
76 * Safety belt to ensure framebuffer params are as expected. May be
77 * removed when we have full confidence in fdt / hints params.
79 if (info->fb_width != TERASIC_MTL_FB_WIDTH ||
80 info->fb_height != TERASIC_MTL_FB_HEIGHT ||
81 info->fb_stride != 3200 ||
82 info->fb_bpp != 32 || info->fb_depth != 32) {
83 device_printf(sc->mtl_dev,
84 "rejecting invalid panel params width=%u height=%u\n",
85 (unsigned)info->fb_width, (unsigned)info->fb_height);
93 terasic_mtl_fbd_attach(struct terasic_mtl_softc *sc)
98 info = &sc->mtl_fb_info;
99 info->fb_name = device_get_nameunit(sc->mtl_dev);
100 info->fb_pbase = rman_get_start(sc->mtl_pixel_res);
101 info->fb_size = rman_get_size(sc->mtl_pixel_res);
102 info->fb_vbase = (intptr_t)pmap_mapdev(info->fb_pbase, info->fb_size);
103 if (terasic_mtl_fbd_panel_info(sc, info) != 0) {
104 device_printf(sc->mtl_dev, "using default panel params\n");
105 info->fb_bpp = info->fb_depth = 32;
106 info->fb_width = 800;
107 info->fb_height = 480;
108 info->fb_stride = info->fb_width * (info->fb_depth / 8);
111 fbd = device_add_child(sc->mtl_dev, "fbd",
112 device_get_unit(sc->mtl_dev));
114 device_printf(sc->mtl_dev, "Failed to attach fbd child\n");
117 if (device_probe_and_attach(fbd) != 0) {
118 device_printf(sc->mtl_dev,
119 "Failed to attach fbd device\n");
126 terasic_mtl_fbd_detach(struct terasic_mtl_softc *sc)
128 panic("%s: detach not implemented", __func__);
131 extern device_t fbd_driver;
132 extern devclass_t fbd_devclass;
133 DRIVER_MODULE(fbd, terasic_mtl, fbd_driver, fbd_devclass, 0, 0);