Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/fdt Add console support.



details:   https://anonhg.NetBSD.org/src/rev/0b98335713a2
branches:  trunk
changeset: 826438:0b98335713a2
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Mon Sep 04 18:01:28 2017 +0000

description:
Add console support.

diffstat:

 sys/dev/fdt/simplefb.c |  36 ++++++++++++++++++++++++++++++++----
 1 files changed, 32 insertions(+), 4 deletions(-)

diffs (75 lines):

diff -r 727f22a27f8c -r 0b98335713a2 sys/dev/fdt/simplefb.c
--- a/sys/dev/fdt/simplefb.c    Mon Sep 04 17:26:06 2017 +0000
+++ b/sys/dev/fdt/simplefb.c    Mon Sep 04 18:01:28 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: simplefb.c,v 1.1 2017/08/27 19:14:32 jmcneill Exp $ */
+/* $NetBSD: simplefb.c,v 1.2 2017/09/04 18:01:28 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: simplefb.c,v 1.1 2017/08/27 19:14:32 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: simplefb.c,v 1.2 2017/09/04 18:01:28 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -52,6 +52,8 @@
        bus_addr_t sc_paddr;
 };
 
+static int simplefb_console_phandle = -1;
+
 static bool
 simplefb_shutdown(device_t self, int flags)
 {
@@ -118,6 +120,12 @@
                return ENXIO;
        }
 
+       if (size == 0) {
+               aprint_naive("\n");
+               aprint_normal(": disabled\n");
+               return ENXIO;
+       }
+
        if (of_getprop_uint32(phandle, "width", &width) != 0 ||
            of_getprop_uint32(phandle, "height", &height) != 0 ||
            of_getprop_uint32(phandle, "stride", &stride) != 0 ||
@@ -169,8 +177,8 @@
        ops.genfb_ioctl = simplefb_ioctl;
        ops.genfb_mmap = simplefb_mmap;
 
-       bool is_console = false;
-       prop_dictionary_get_bool(dict, "is_console", &is_console);
+       const bool is_console = phandle == simplefb_console_phandle;
+
        prop_dictionary_set_bool(dict, "is_console", is_console);
 
        if (is_console)
@@ -207,3 +215,23 @@
 
 CFATTACH_DECL_NEW(simplefb, sizeof(struct simplefb_softc),
        simplefb_match, simplefb_attach, NULL, NULL);
+
+static int
+simplefb_console_match(int phandle)
+{
+       return of_match_compatible(phandle, compatible);
+}
+
+static void
+simplefb_console_consinit(struct fdt_attach_args *faa, u_int uart_freq)
+{
+       simplefb_console_phandle = faa->faa_phandle;
+       genfb_cnattach();
+}
+
+static const struct fdt_console simplefb_fdt_console = {
+       .match = simplefb_console_match,
+       .consinit = simplefb_console_consinit
+};
+
+FDT_CONSOLE(simplefb, &simplefb_fdt_console);



Home | Main Index | Thread Index | Old Index