Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Add omapfb to FDT-ized TI port.
details: https://anonhg.NetBSD.org/src/rev/b231a1e5fe58
branches: trunk
changeset: 966489:b231a1e5fe58
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Thu Oct 31 17:08:54 2019 +0000
description:
Add omapfb to FDT-ized TI port.
diffstat:
sys/arch/arm/ti/files.ti | 7 +-
sys/arch/arm/ti/omap3_dss.c | 1260 ++++++++++++++++++++++++++++++++++++++++
sys/arch/arm/ti/omap3_dssreg.h | 373 +++++++++++
sys/arch/evbarm/conf/GENERIC | 3 +-
4 files changed, 1641 insertions(+), 2 deletions(-)
diffs (truncated from 1680 to 300 lines):
diff -r 17fb629b8b9a -r b231a1e5fe58 sys/arch/arm/ti/files.ti
--- a/sys/arch/arm/ti/files.ti Thu Oct 31 11:59:40 2019 +0000
+++ b/sys/arch/arm/ti/files.ti Thu Oct 31 17:08:54 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.ti,v 1.17 2019/10/30 21:41:40 jmcneill Exp $
+# $NetBSD: files.ti,v 1.18 2019/10/31 17:08:54 jmcneill Exp $
#
file arch/arm/ti/ti_cpufreq.c soc_ti
@@ -107,6 +107,11 @@
attach tirng at fdt with ti_rng
file arch/arm/ti/ti_rng.c ti_rng
+# Display adapter
+device omapfb: rasops16, rasops8, wsemuldisplaydev, vcons, edid
+attach omapfb at fdt with omap3_dss
+file arch/arm/ti/omap3_dss.c omap3_dss
+
# SOC parameters
defflag opt_soc.h SOC_TI
defflag opt_soc.h SOC_AM33XX: SOC_TI
diff -r 17fb629b8b9a -r b231a1e5fe58 sys/arch/arm/ti/omap3_dss.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/ti/omap3_dss.c Thu Oct 31 17:08:54 2019 +0000
@@ -0,0 +1,1260 @@
+/* $NetBSD: omap3_dss.c,v 1.1 2019/10/31 17:08:54 jmcneill Exp $ */
+
+/*
+ * Copyright (c) 2010 Michael Lorenz
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * A console driver for OMAP 3530's built-in video controller
+ * tested on beagleboard only so far
+ */
+
+#include "opt_wsdisplay_compat.h"
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: omap3_dss.c,v 1.1 2019/10/31 17:08:54 jmcneill Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/lwp.h>
+#include <sys/kauth.h>
+#include <sys/bus.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <dev/videomode/videomode.h>
+#include <dev/videomode/edidvar.h>
+
+#include <dev/fdt/fdtvar.h>
+
+#include <arm/ti/omap3_dssreg.h>
+
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/wscons/wsconsio.h>
+#include <dev/wsfont/wsfont.h>
+#include <dev/rasops/rasops.h>
+#include <dev/wscons/wsdisplay_vconsvar.h>
+
+struct omapfb_softc {
+ device_t sc_dev;
+
+ bus_space_tag_t sc_iot;
+ bus_dma_tag_t sc_dmat;
+ bus_space_handle_t sc_regh;
+ bus_dmamap_t sc_dmamap;
+ bus_dma_segment_t sc_dmamem[1];
+ size_t sc_vramsize;
+
+ int sc_width, sc_height, sc_depth, sc_stride;
+ int sc_locked;
+ void *sc_fbaddr, *sc_vramaddr;
+
+ int sc_cursor_offset;
+ uint32_t *sc_cursor_img;
+ int sc_cursor_x, sc_cursor_y;
+ int sc_hot_x, sc_hot_y;
+ uint8_t sc_cursor_bitmap[8 * 64];
+ uint8_t sc_cursor_mask[8 * 64];
+ uint32_t sc_cursor_cmap[4];
+
+ bus_addr_t sc_fbhwaddr;
+ uint32_t *sc_clut;
+ uint32_t sc_dispc_config;
+ int sc_video_is_on;
+ struct vcons_screen sc_console_screen;
+ struct wsscreen_descr sc_defaultscreen_descr;
+ const struct wsscreen_descr *sc_screens[1];
+ struct wsscreen_list sc_screenlist;
+ struct vcons_data vd;
+ int sc_mode;
+ uint8_t sc_cmap_red[256], sc_cmap_green[256], sc_cmap_blue[256];
+ void (*sc_putchar)(void *, int, int, u_int, long);
+
+ uint8_t sc_edid_data[1024];
+ size_t sc_edid_size;
+};
+
+static int omapfb_match(device_t, cfdata_t, void *);
+static void omapfb_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(omap3_dss, sizeof(struct omapfb_softc),
+ omapfb_match, omapfb_attach, NULL, NULL);
+
+static int omapfb_ioctl(void *, void *, u_long, void *, int,
+ struct lwp *);
+static paddr_t omapfb_mmap(void *, void *, off_t, int);
+static void omapfb_init_screen(void *, struct vcons_screen *, int, long *);
+
+static int omapfb_putcmap(struct omapfb_softc *, struct wsdisplay_cmap *);
+static int omapfb_getcmap(struct omapfb_softc *, struct wsdisplay_cmap *);
+static void omapfb_restore_palette(struct omapfb_softc *);
+static void omapfb_putpalreg(struct omapfb_softc *, int, uint8_t,
+ uint8_t, uint8_t);
+
+static int omapfb_set_depth(struct omapfb_softc *, int);
+static void omapfb_set_video(struct omapfb_softc *, int);
+
+static void omapfb_move_cursor(struct omapfb_softc *, int, int);
+static int omapfb_do_cursor(struct omapfb_softc *,
+ struct wsdisplay_cursor *);
+
+#if NOMAPDMA > 0
+static void omapfb_init(struct omapfb_softc *);
+static void omapfb_wait_idle(struct omapfb_softc *);
+static void omapfb_rectfill(struct omapfb_softc *, int, int, int, int,
+ uint32_t);
+static void omapfb_bitblt(struct omapfb_softc *, int, int, int, int, int,
+ int, int);
+
+static void omapfb_cursor(void *, int, int, int);
+static void omapfb_putchar(void *, int, int, u_int, long);
+static void omapfb_copycols(void *, int, int, int, int);
+static void omapfb_erasecols(void *, int, int, int, long);
+static void omapfb_copyrows(void *, int, int, int);
+static void omapfb_eraserows(void *, int, int, long);
+#endif /* NOMAPDMA > 0 */
+
+struct wsdisplay_accessops omapfb_accessops = {
+ omapfb_ioctl,
+ omapfb_mmap,
+ NULL, /* alloc_screen */
+ NULL, /* free_screen */
+ NULL, /* show_screen */
+ NULL, /* load_font */
+ NULL, /* pollc */
+ NULL /* scroll */
+};
+
+uint32_t venc_mode_ntsc[] = {
+ 0x00000000, 0x00000001, 0x00008040, 0x00000359,
+ 0x0000020c, 0x00000000, 0x043f2631, 0x00000000,
+ 0x00000102, 0x0000016c, 0x0000012f, 0x00000043,
+ 0x00000038, 0x00000007, 0x00000001, 0x00000038,
+ 0x21f07c1f, 0x00000000, 0x01310011, 0x0000f003,
+ 0x00000000, 0x069300f4, 0x0016020c, 0x00060107,
+ 0x008e0350, 0x000f0359, 0x01a00000, 0x020701a0,
+ 0x01ac0024, 0x020d01ac, 0x00000006, 0x03480078,
+ 0x02060024, 0x0001008a, 0x01ac0106, 0x01060006,
+ 0x00140001, 0x00010001, 0x00f90000, 0x0000000d,
+ 0x00000000};
+
+extern const u_char rasops_cmap[768];
+
+static const char * const compatible[] = {
+ "ti,omap3-dss",
+ NULL
+};
+
+static int omapfb_console_phandle = -1;
+
+static int
+omapfb_match(device_t parent, cfdata_t match, void *aux)
+{
+ struct fdt_attach_args * const faa = aux;
+
+ return of_match_compatible(faa->faa_phandle, compatible);
+}
+
+static void
+omapfb_attach(device_t parent, device_t self, void *aux)
+{
+ struct omapfb_softc *sc = device_private(self);
+ struct fdt_attach_args *faa = aux;
+ const int phandle = faa->faa_phandle;
+ struct rasops_info *ri;
+ struct wsemuldisplaydev_attach_args aa;
+ prop_dictionary_t dict;
+ prop_data_t edid_data;
+ unsigned long defattr;
+#ifdef WSDISPLAY_MULTICONS
+ bool is_console = true;
+#else
+ bool is_console = phandle == omapfb_console_phandle;
+#endif
+ uint32_t sz, reg;
+ int segs, i, j;
+ bus_addr_t addr;
+ bus_size_t size;
+
+ if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
+ aprint_error(": couldn't get registers\n");
+ return;
+ }
+
+ sc->sc_dev = self;
+ sc->sc_iot = faa->faa_bst;
+ sc->sc_dmat = faa->faa_dmat;
+
+ if (bus_space_map(sc->sc_iot, addr, size, 0, &sc->sc_regh) != 0) {
+ aprint_error(": couldn't map registers\n");
+ return;
+ }
+
+ aprint_naive("\n");
+ aprint_normal(": OMAP onboard video\n");
+
+ sc->sc_video_is_on = 1;
+
+ /*
+ * XXX
+ * different u-boot versions initialize the graphics controller in
+ * different ways, so we look for the display resolution in a few
+ * different places...
+ */
+ sz = bus_space_read_4(sc->sc_iot, sc->sc_regh, OMAPFB_DISPC_GFX_SIZE);
+ if (sz == 0) {
+ sz = bus_space_read_4(sc->sc_iot, sc->sc_regh,
+ OMAPFB_DISPC_SIZE_LCD);
+ }
+ if (sz == 0) {
+ sz = bus_space_read_4(sc->sc_iot, sc->sc_regh,
+ OMAPFB_DISPC_SIZE_DIG);
+ }
+
+ /* ... and make sure it ends up where we need it */
+ bus_space_write_4(sc->sc_iot, sc->sc_regh, OMAPFB_DISPC_GFX_SIZE, sz);
+
+ sc->sc_width = (sz & 0xfff) + 1;
+ sc->sc_height = ((sz & 0x0fff0000 ) >> 16) + 1;
+ sc->sc_depth = 16;
+ sc->sc_stride = sc->sc_width << 1;
+
+ if (sc->sc_width == 1 || sc->sc_height == 1) {
+ aprint_error_dev(self, "bogus display size, not attaching\n");
+ return;
+ }
+
+ printf("%s: firmware set up %d x %d\n", device_xname(self),
+ sc->sc_width, sc->sc_height);
+#if 0
+ printf("DSS revision: %08x\n",
+ bus_space_read_4(sc->sc_iot, sc->sc_regh, OMAPFB_DSS_REVISION));
+#endif
+ dict = device_properties(self);
+ edid_data = prop_dictionary_get(dict, "EDID");
+
+ if (edid_data != NULL) {
+ struct edid_info ei;
+
+ sc->sc_edid_size = uimin(prop_data_size(edid_data), 1024);
+ memset(sc->sc_edid_data, 0, sizeof(sc->sc_edid_data));
+ memcpy(sc->sc_edid_data, prop_data_data_nocopy(edid_data),
+ sc->sc_edid_size);
+
+ edid_parse(sc->sc_edid_data, &ei);
+ edid_print(&ei);
+ }
+
+ /* setup video DMA */
+ sc->sc_vramsize = (12 << 20) + PAGE_SIZE; /* 12MB + CLUT */
+
+ if (bus_dmamem_alloc(sc->sc_dmat, sc->sc_vramsize, 0, 0,
Home |
Main Index |
Thread Index |
Old Index