Module Name:    src
Committed By:   bouyer
Date:           Tue Nov  3 18:38:03 UTC 2015

Modified Files:
        src/sys/arch/arm/allwinner: awin_debe.c awin_reg.h awin_tcon.c
        src/sys/arch/evbarm/awin: awin_machdep.c

Log Message:
A debe can't feed both tcon at the same time.
AWIN_DEBE_MODCTL_OUT_SEL will select which tcon instance will get data
(0 for tcon0, 1 for tcon1).
In tcon, AWIN_TCON_CTL_SRC_SEL_DE0 selects the default debe for this
tcon instance: debe0 for tcon0, debe1 for tcon1.
So always connect tcon0 to debe0 and tcon1 to debe1.
now display modes 0, 1 and 2 works; display modes 3 and 4 needs more work.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/allwinner/awin_debe.c
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/arm/allwinner/awin_reg.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/allwinner/awin_tcon.c
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/evbarm/awin/awin_machdep.c

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/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.17 src/sys/arch/arm/allwinner/awin_debe.c:1.18
--- src/sys/arch/arm/allwinner/awin_debe.c:1.17	Sun Oct 25 20:54:19 2015
+++ src/sys/arch/arm/allwinner/awin_debe.c	Tue Nov  3 18:38:03 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.17 2015/10/25 20:54:19 bouyer Exp $ */
+/* $NetBSD: awin_debe.c,v 1.18 2015/11/03 18:38:03 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill <jmcne...@invisible.ca>
@@ -37,7 +37,7 @@
 #define AWIN_DEBE_CURMAX	64
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.17 2015/10/25 20:54:19 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.18 2015/11/03 18:38:03 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -451,10 +451,11 @@ awin_debe_enable(int unit, bool enable)
 
 	dev = device_find_by_driver_unit("awindebe", unit);
 	if (dev == NULL) {
-		printf("DEBE: no driver found\n");
+		printf("DEBE%d: no driver found\n", unit);
 		return;
 	}
 	sc = device_private(dev);
+	KASSERT(device_unit(sc->sc_dev) == unit);
 
 	if (enable) {
 		val = DEBE_READ(sc, AWIN_DEBE_REGBUFFCTL_REG);
@@ -469,6 +470,11 @@ awin_debe_enable(int unit, bool enable)
 		val &= ~AWIN_DEBE_MODCTL_START_CTL;
 		DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, val);
 	}
+#if 0
+	for (int i = 0; i < 0x1000; i += 4) {
+		printf("DEBE 0x%04x: 0x%08x\n", i, DEBE_READ(sc, i));
+	}
+#endif
 }
 
 void
@@ -480,10 +486,11 @@ awin_debe_set_videomode(int unit, const 
 
 	dev = device_find_by_driver_unit("awindebe", unit);
 	if (dev == NULL) {
-		printf("DEBE: no driver found\n");
+		printf("DEBE%d: no driver found\n", unit);
 		return;
 	}
 	sc = device_private(dev);
+	KASSERT(device_unit(sc->sc_dev) == unit);
 
 	if (mode) {
 		const u_int interlace_p = !!(mode->flags & VID_INTERLACE);
@@ -545,6 +552,11 @@ awin_debe_set_videomode(int unit, const 
 		} else {
 			val &= ~AWIN_DEBE_MODCTL_ITLMOD_EN;
 		}
+		val &= ~AWIN_DEBE_MODCTL_OUT_SEL;
+		if (device_unit(sc->sc_dev) == 1) {
+			val |= __SHIFTIN(AWIN_DEBE_MODCTL_OUT_SEL_LCD1,
+			    AWIN_DEBE_MODCTL_OUT_SEL);
+		}
 		DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, val);
 	} else {
 		/* disable */

Index: src/sys/arch/arm/allwinner/awin_reg.h
diff -u src/sys/arch/arm/allwinner/awin_reg.h:1.81 src/sys/arch/arm/allwinner/awin_reg.h:1.82
--- src/sys/arch/arm/allwinner/awin_reg.h:1.81	Sun Oct 25 20:54:19 2015
+++ src/sys/arch/arm/allwinner/awin_reg.h	Tue Nov  3 18:38:03 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_reg.h,v 1.81 2015/10/25 20:54:19 bouyer Exp $ */
+/* $NetBSD: awin_reg.h,v 1.82 2015/11/03 18:38:03 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -1701,7 +1701,8 @@ struct awin_mmc_idma_descriptor {
 #define AWIN_DEBE_MODCTL_LINE_SEL	__BIT(29)
 #define AWIN_DEBE_MODCTL_ITLMOD_EN	__BIT(28)
 #define AWIN_DEBE_MODCTL_OUT_SEL	__BITS(22,20)
-#define AWIN_DEBE_MODCTL_OUT_SEL_LCD	0
+#define AWIN_DEBE_MODCTL_OUT_SEL_LCD0	0
+#define AWIN_DEBE_MODCTL_OUT_SEL_LCD1	0
 #define AWIN_DEBE_MODCTL_OUT_SEL_FE0	6
 #define AWIN_DEBE_MODCTL_OUT_SEL_FE1	7
 #define AWIN_DEBE_MODCTL_OSCA_EN	__BIT(17)

Index: src/sys/arch/arm/allwinner/awin_tcon.c
diff -u src/sys/arch/arm/allwinner/awin_tcon.c:1.6 src/sys/arch/arm/allwinner/awin_tcon.c:1.7
--- src/sys/arch/arm/allwinner/awin_tcon.c:1.6	Sun Oct 25 20:54:19 2015
+++ src/sys/arch/arm/allwinner/awin_tcon.c	Tue Nov  3 18:38:03 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_tcon.c,v 1.6 2015/10/25 20:54:19 bouyer Exp $ */
+/* $NetBSD: awin_tcon.c,v 1.7 2015/11/03 18:38:03 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill <jmcne...@invisible.ca>
@@ -29,7 +29,7 @@
 #include "opt_allwinner.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_tcon.c,v 1.6 2015/10/25 20:54:19 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_tcon.c,v 1.7 2015/11/03 18:38:03 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -56,7 +56,6 @@ struct awin_tcon_softc {
 	unsigned int sc_clk_pll;
 	unsigned int sc_clk_div;
 	bool sc_clk_dbl;
-	unsigned int sc_debe_unit;
 };
 
 static bus_space_handle_t tcon_mux_bsh;
@@ -114,7 +113,6 @@ awin_tcon_attach(device_t parent, device
 	struct awinio_attach_args * const aio = aux;
 	const struct awin_locators * const loc = &aio->aio_loc;
 	prop_dictionary_t cfg = device_properties(self);
-	int8_t debe_unit = -1;
 
 	sc->sc_dev = self;
 	sc->sc_bst = aio->aio_core_bst;
@@ -132,14 +130,6 @@ awin_tcon_attach(device_t parent, device
 		awin_tcon_clear_reset(aio, 0);
 	}
 
-	if (prop_dictionary_get_int8(cfg, "debe_unit", &debe_unit)) {
-		sc->sc_debe_unit = debe_unit;
-	} else {
-		sc->sc_debe_unit = 0; /* default value */
-	}
-
-		
-
 	aprint_naive("\n");
 	aprint_normal(": LCD/TV timing controller (TCON%d)\n", loc->loc_port);
 	switch (sc->sc_port) {
@@ -154,10 +144,9 @@ awin_tcon_attach(device_t parent, device
 	default:
 		panic("awin_tcon port\n");
 	}
-	if (debe_unit >= 0) {
-		aprint_verbose_dev(self, ": using DEBE%d, pll%d\n",
-		    sc->sc_debe_unit, sc->sc_clk_pll);
-	}
+
+	aprint_verbose_dev(self, ": using DEBE%d, pll%d\n",
+		    device_unit(self), sc->sc_clk_pll);
 
 	awin_tcon_clear_reset(aio, sc->sc_port);
 	
@@ -266,7 +255,7 @@ awin_tcon_enable(int unit, bool enable)
 	}
 	sc = device_private(dev);
 
-	awin_debe_enable(sc->sc_debe_unit, enable);
+	awin_debe_enable(device_unit(sc->sc_dev), enable);
 	delay(20000);
 	val = TCON_READ(sc, AWIN_TCON_GCTL_REG);
 	if (enable) {
@@ -322,7 +311,7 @@ awin_tcon_set_videomode(int unit, const 
 	}
 	sc = device_private(dev);
 
-	awin_debe_set_videomode(sc->sc_debe_unit, mode);
+	awin_debe_set_videomode(device_unit(sc->sc_dev), mode);
 	if (mode) {
 		const u_int interlace_p = !!(mode->flags & VID_INTERLACE);
 		const u_int phsync_p = !!(mode->flags & VID_PHSYNC);
@@ -340,17 +329,6 @@ awin_tcon_set_videomode(int unit, const 
 		val |= AWIN_TCON_GCTL_IO_MAP_SEL;
 		TCON_WRITE(sc, AWIN_TCON_GCTL_REG, val);
 
-		val = TCON_READ(sc, AWIN_TCON0_CTL_REG);
-		val &= ~0x00400003;
-		if (sc->sc_debe_unit == 0) {
-			val |= __SHIFTIN(AWIN_TCON_CTL_SRC_SEL_DE0,
-					 AWIN_TCON_CTL_SRC_SEL);
-		} else {
-			val |= __SHIFTIN(AWIN_TCON_CTL_SRC_SEL_DE1,
-					 AWIN_TCON_CTL_SRC_SEL);
-		}
-		TCON_WRITE(sc, AWIN_TCON0_CTL_REG, val);
-
 		/* enable */
 		val = AWIN_TCON_CTL_EN;
 		if (interlace_p)
@@ -360,13 +338,12 @@ awin_tcon_set_videomode(int unit, const 
 		val |= __SHIFTIN(AWIN_TCON_CTL_SRC_SEL_BLUEDATA,
 				 AWIN_TCON_CTL_SRC_SEL);
 #else
-		if (sc->sc_debe_unit == 0) {
-			val |= __SHIFTIN(AWIN_TCON_CTL_SRC_SEL_DE0,
-					 AWIN_TCON_CTL_SRC_SEL);
-		} else {
-			val |= __SHIFTIN(AWIN_TCON_CTL_SRC_SEL_DE1,
-					 AWIN_TCON_CTL_SRC_SEL);
-		}
+		/*
+		 * the DE selector selects the primary DEBE for this tcon:
+		 * 0 selects debe0 for tcon0 and debe1 for tcon1
+		 */
+		val |= __SHIFTIN(AWIN_TCON_CTL_SRC_SEL_DE0,
+				 AWIN_TCON_CTL_SRC_SEL);
 #endif
 		TCON_WRITE(sc, AWIN_TCON1_CTL_REG, val);
 

Index: src/sys/arch/evbarm/awin/awin_machdep.c
diff -u src/sys/arch/evbarm/awin/awin_machdep.c:1.45 src/sys/arch/evbarm/awin/awin_machdep.c:1.46
--- src/sys/arch/evbarm/awin/awin_machdep.c:1.45	Sun Oct 25 21:21:52 2015
+++ src/sys/arch/evbarm/awin/awin_machdep.c	Tue Nov  3 18:38:03 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: awin_machdep.c,v 1.45 2015/10/25 21:21:52 bouyer Exp $ */
+/*	$NetBSD: awin_machdep.c,v 1.46 2015/11/03 18:38:03 bouyer Exp $ */
 
 /*
  * Machine dependent functions for kernel setup for TI OSK5912 board.
@@ -125,7 +125,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_machdep.c,v 1.45 2015/10/25 21:21:52 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_machdep.c,v 1.46 2015/11/03 18:38:03 bouyer Exp $");
 
 #include "opt_machdep.h"
 #include "opt_ddb.h"
@@ -989,7 +989,7 @@ awin_display_sysconfig(prop_dictionary_t
 		break;
 	case 1:
 		/* screen1, fb0 */
-		prop_dictionary_set_bool(dict, "no-awindebe-1", true);
+		prop_dictionary_set_bool(dict, "no-awindebe-0", true);
 		prop_dictionary_set_bool(dict, "no-awintcon-0", true);
 		hdmi_used = (screen1_type == 3);
 		break;
@@ -1001,7 +1001,6 @@ awin_display_sysconfig(prop_dictionary_t
 		/* xinerama */
 	case 4:
 		/* clone */
-		prop_dictionary_set_bool(dict, "no-awindebe-1", true);
 		hdmi_used = (screen0_type == 3 || screen1_type == 3);
 		break;
 	default:
@@ -1054,7 +1053,6 @@ awin_tcon_sysconfig(device_t self, prop_
 		if (mode < 0)
 			return;
 
-		prop_dictionary_set_int8(dict, "debe_unit", 0);
 		type = awin_sysconfig_get_int("disp_init", "screen0_output_type");
 		if (type == 1) {
 			/* LCD/LVDS output */
@@ -1069,17 +1067,6 @@ awin_tcon_sysconfig(device_t self, prop_
 		return;
 	}
 	if (device_unit(self) == 1) {
-		switch (mode) {
-		case 0:
-			/* only mode where tcon1 is not used */
-			return;
-		case 2:
-			prop_dictionary_set_int8(dict, "debe_unit", 1);
-			break;
-		default:
-			prop_dictionary_set_int8(dict, "debe_unit", 0);
-			break;
-		}
 		type = awin_sysconfig_get_int("disp_init", "screen1_output_type");
 		if (type == 1) {
 			/* LCD/LVDS output */

Reply via email to