Module Name:    src
Committed By:   jmcneill
Date:           Tue Jan  8 23:52:48 UTC 2013

Modified Files:
        src/sys/arch/arm/broadcom: files.bcm2835
Added Files:
        src/sys/arch/arm/broadcom: bcm2835_genfb.c

Log Message:
add genfb glue


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/broadcom/bcm2835_genfb.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/broadcom/files.bcm2835

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/broadcom/files.bcm2835
diff -u src/sys/arch/arm/broadcom/files.bcm2835:1.10 src/sys/arch/arm/broadcom/files.bcm2835:1.11
--- src/sys/arch/arm/broadcom/files.bcm2835:1.10	Tue Jan  8 16:24:23 2013
+++ src/sys/arch/arm/broadcom/files.bcm2835	Tue Jan  8 23:52:48 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: files.bcm2835,v 1.10 2013/01/08 16:24:23 skrll Exp $
+#	$NetBSD: files.bcm2835,v 1.11 2013/01/08 23:52:48 jmcneill Exp $
 #
 # Configuration info for Broadcom BCM2835 ARM Peripherals
 #
@@ -63,3 +63,7 @@ file	arch/arm/broadcom/bcm2835_spi.c		bc
 device	bsciic: i2cbus, bcm2835_gpio_subr
 attach	bsciic at obio
 file	arch/arm/broadcom/bcm2835_bsc.c		bsciic	needs-flag
+
+# Generic framebuffer console driver
+attach	genfb at obio with bcmgenfb: edid
+file	arch/arm/broadcom/bcm2835_genfb.c	bcmgenfb	needs-flag

Added files:

Index: src/sys/arch/arm/broadcom/bcm2835_genfb.c
diff -u /dev/null src/sys/arch/arm/broadcom/bcm2835_genfb.c:1.1
--- /dev/null	Tue Jan  8 23:52:48 2013
+++ src/sys/arch/arm/broadcom/bcm2835_genfb.c	Tue Jan  8 23:52:48 2013
@@ -0,0 +1,138 @@
+/* $NetBSD: bcm2835_genfb.c,v 1.1 2013/01/08 23:52:48 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2013 Jared D. McNeill <[email protected]>
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+/*
+ * Generic framebuffer console driver
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_genfb.c,v 1.1 2013/01/08 23:52:48 jmcneill Exp $");
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/conf.h>
+#include <sys/bus.h>
+#include <sys/kmem.h>
+
+#include <arm/broadcom/bcm_amba.h>
+
+#include <dev/wsfb/genfbvar.h>
+
+struct bcmgenfb_softc {
+	struct genfb_softc	sc_gen;
+	bus_space_tag_t		sc_iot;
+	bus_space_handle_t	sc_ioh;
+};
+
+static int	bcmgenfb_match(device_t, cfdata_t, void *);
+static void	bcmgenfb_attach(device_t, device_t, void *);
+
+static int	bcmgenfb_ioctl(void *, void *, u_long, void *, int, lwp_t *);
+static paddr_t	bcmgenfb_mmap(void *, void *, off_t, int);
+
+CFATTACH_DECL_NEW(bcmgenfb, sizeof(struct bcmgenfb_softc),
+    bcmgenfb_match, bcmgenfb_attach, NULL, NULL);
+
+static int
+bcmgenfb_match(device_t parent, cfdata_t match, void *aux)
+{
+	struct amba_attach_args *aaa = aux;
+
+	return !strcmp(aaa->aaa_name, "fb");
+}
+
+static void
+bcmgenfb_attach(device_t parent, device_t self, void *aux)
+{
+	struct bcmgenfb_softc *sc = device_private(self);
+	struct amba_attach_args *aaa = aux;
+	struct genfb_ops ops;
+	int error;
+
+	sc->sc_gen.sc_dev = self;
+	sc->sc_iot = aaa->aaa_iot;
+
+	genfb_init(&sc->sc_gen);
+
+	if (sc->sc_gen.sc_width == 0 ||
+	    sc->sc_gen.sc_fbsize == 0) {
+		aprint_normal(": disabled\n");
+		return;
+	}
+
+	error = bus_space_map(sc->sc_iot, sc->sc_gen.sc_fboffset,
+	    sc->sc_gen.sc_fbsize,
+	    BUS_SPACE_MAP_LINEAR|BUS_SPACE_MAP_PREFETCHABLE, &sc->sc_ioh);
+	if (error) {
+		aprint_error_dev(self, "couldn't map framebuffer (%d)\n",
+		    error);
+		return;
+	}
+	sc->sc_gen.sc_fbaddr = bus_space_vaddr(sc->sc_iot, sc->sc_ioh);
+
+	memset(&ops, 0, sizeof(ops));
+	ops.genfb_ioctl = bcmgenfb_ioctl;
+	ops.genfb_mmap = bcmgenfb_mmap;
+
+	aprint_naive("\n");
+	aprint_normal(": switching to framebuffer console\n");
+
+	genfb_attach(&sc->sc_gen, &ops);
+}
+
+static int
+bcmgenfb_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, lwp_t *l)
+{
+	struct wsdisplayio_bus_id *busid;
+
+	switch (cmd) {
+	case WSDISPLAYIO_GTYPE:
+		*(u_int *)data = WSDISPLAY_TYPE_VC4;
+		return 0;
+	case WSDISPLAYIO_GET_BUSID:
+		busid = data;
+		busid->bus_type = WSDISPLAYIO_BUS_SOC;
+		return 0;
+	default:
+		return EPASSTHROUGH;
+	}
+}
+
+static paddr_t
+bcmgenfb_mmap(void *v, void *vs, off_t offset, int prot)
+{
+	struct bcmgenfb_softc *sc = v;
+
+	if (offset < 0 || offset >= sc->sc_gen.sc_fbsize)
+		return -1;
+
+	return bus_space_mmap(sc->sc_iot, sc->sc_gen.sc_fboffset, offset,
+	    prot, BUS_SPACE_MAP_LINEAR|BUS_SPACE_MAP_PREFETCHABLE);
+}

Reply via email to