All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard
@ 2012-01-15  0:47 Simon Glass
  2012-01-15  0:47 ` [U-Boot] [PATCH 04/17] tegra: Add display support to funcmux Simon Glass
                   ` (13 more replies)
  0 siblings, 14 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

This series adds support for the Tegra2x's display peripheral. This
supports the LCD display on Seaboard and we use this to enable console
output in U-Boot on the LCD.

Configuration is via the device tree. Proposed bindings are included
in this series.

To improve performance two optimisations are offered:

1. The LCD frame buffer is cached, with the cache being flushed after
each call puts(). This dramatically increases performance (around 10x).
This requires a few additions to the ARM cache support.

2. The console supports scrolling in steps of more than 1 line. This
speeds up scrolling output considerably, particularly commands like
'printenv' which display a lot of output. This requires a new CONFIG
and a change to the console_scrollup() function.


Mayuresh Kulkarni (1):
  tegra: Enable display/lcd support on Seaboard

Simon Glass (15):
  fdt: Add function to look up a phandle's register address
  fdt: Add header guard to fdtdec.h
  fdt: Correct GPIO name access in fdtdec
  tegra: Add display support to funcmux
  tegra: fdt: Add LCD definitions for Tegra
  tegra: Add support for PWFM
  tegra: Add LCD driver
  tegra: Add LCD support to Nvidia boards
  arm: Add control over cachability of memory regions
  lcd: Add CONFIG_ALIGN_LCD_TO_SECTION to align lcd for MMU
  lcd: Add support for flushing LCD fb from dcache after update
  tegra: Align LCD frame buffer to section boundary
  tegra: Support control of cache settings for LCD
  tegra: fdt: Add LCD definitions for Seaboard
  lcd: Add CONSOLE_SCROLL_LINES option to speed console

Wei Ni (1):
  tegra: Add SOC support for display/lcd

 README                                          |   16 +
 arch/arm/cpu/armv7/cache_v7.c                   |   11 +
 arch/arm/cpu/armv7/tegra2/Makefile              |    1 +
 arch/arm/cpu/armv7/tegra2/display.c             |  271 +++++++++++
 arch/arm/cpu/armv7/tegra2/funcmux.c             |   39 ++
 arch/arm/cpu/armv7/tegra2/pwfm.c                |   40 ++
 arch/arm/dts/tegra20.dtsi                       |   25 +
 arch/arm/include/asm/arch-tegra2/dc.h           |  544 +++++++++++++++++++++++
 arch/arm/include/asm/arch-tegra2/display.h      |  133 ++++++
 arch/arm/include/asm/arch-tegra2/pwfm.h         |   54 +++
 arch/arm/include/asm/system.h                   |   30 ++
 arch/arm/lib/cache-cp15.c                       |   62 +++-
 board/nvidia/common/board.c                     |   21 +-
 board/nvidia/dts/tegra2-seaboard.dts            |   21 +
 common/cmd_echo.c                               |    3 +-
 common/lcd.c                                    |   85 +++-
 doc/device-tree-bindings/video/nvidia-video.txt |   92 ++++
 drivers/video/Makefile                          |    1 +
 drivers/video/tegra.c                           |  388 ++++++++++++++++
 include/configs/seaboard.h                      |   12 +-
 include/configs/tegra2-common.h                 |    1 +
 include/fdtdec.h                                |   17 +
 include/lcd.h                                   |   11 +
 lib/fdtdec.c                                    |   15 +-
 24 files changed, 1862 insertions(+), 31 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/tegra2/display.c
 create mode 100644 arch/arm/cpu/armv7/tegra2/pwfm.c
 create mode 100644 arch/arm/include/asm/arch-tegra2/dc.h
 create mode 100644 arch/arm/include/asm/arch-tegra2/display.h
 create mode 100644 arch/arm/include/asm/arch-tegra2/pwfm.h
 create mode 100644 doc/device-tree-bindings/video/nvidia-video.txt
 create mode 100644 drivers/video/tegra.c

-- 
1.7.7.3

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH 01/17] fdt: Add function to look up a phandle's register address
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
@ 2012-01-15  0:47     ` Simon Glass
       [not found] ` <1326588449-1794-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
                       ` (12 subsequent siblings)
  13 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Devicetree Discuss, Tom Warren, Jerry Van Baren

This is a commonly-used requirement, so add a function to support it
easily.

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 include/fdtdec.h |   13 +++++++++++++
 lib/fdtdec.c     |   11 +++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index e705124..81ce3f6 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -239,6 +239,19 @@ const char *fdtdec_get_compatible(enum fdt_compat_id id);
 int fdtdec_lookup_phandle(const void *blob, int node, const char *prop_name);
 
 /**
+ * Look up a phandle and follow it to its node. Then return the register
+ * address of that node as a pointer. This can be used to access the
+ * peripheral directly.
+ *
+ * @param blob		FDT blob
+ * @param node		node to examine
+ * @param prop_name	name of property to find
+ * @return pointer to node's register address
+ */
+void *fdtdec_lookup_phandle_reg(const void *blob, int node,
+		const char *prop_name);
+
+/**
  * Look up a property in a node and return its contents in an integer
  * array of given length. The property must have at least enough data for
  * the array (4*count bytes). It may have more, but this will be ignored.
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 48abf02..bcb2343 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -311,6 +311,17 @@ int fdtdec_lookup_phandle(const void *blob, int node, const char *prop_name)
 	return lookup;
 }
 
+void *fdtdec_lookup_phandle_reg(const void *blob, int node,
+		const char *prop_name)
+{
+	int lookup;
+
+	lookup = fdtdec_lookup_phandle(blob, node, prop_name);
+	if (lookup < 0)
+		return NULL;
+	return (void *)fdtdec_get_addr(blob, lookup, "reg");
+}
+
 /**
  * Look up a property in a node and check that it has a minimum length.
  *
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 01/17] fdt: Add function to look up a phandle's register address
@ 2012-01-15  0:47     ` Simon Glass
  0 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

This is a commonly-used requirement, so add a function to support it
easily.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 include/fdtdec.h |   13 +++++++++++++
 lib/fdtdec.c     |   11 +++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index e705124..81ce3f6 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -239,6 +239,19 @@ const char *fdtdec_get_compatible(enum fdt_compat_id id);
 int fdtdec_lookup_phandle(const void *blob, int node, const char *prop_name);
 
 /**
+ * Look up a phandle and follow it to its node. Then return the register
+ * address of that node as a pointer. This can be used to access the
+ * peripheral directly.
+ *
+ * @param blob		FDT blob
+ * @param node		node to examine
+ * @param prop_name	name of property to find
+ * @return pointer to node's register address
+ */
+void *fdtdec_lookup_phandle_reg(const void *blob, int node,
+		const char *prop_name);
+
+/**
  * Look up a property in a node and return its contents in an integer
  * array of given length. The property must have at least enough data for
  * the array (4*count bytes). It may have more, but this will be ignored.
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 48abf02..bcb2343 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -311,6 +311,17 @@ int fdtdec_lookup_phandle(const void *blob, int node, const char *prop_name)
 	return lookup;
 }
 
+void *fdtdec_lookup_phandle_reg(const void *blob, int node,
+		const char *prop_name)
+{
+	int lookup;
+
+	lookup = fdtdec_lookup_phandle(blob, node, prop_name);
+	if (lookup < 0)
+		return NULL;
+	return (void *)fdtdec_get_addr(blob, lookup, "reg");
+}
+
 /**
  * Look up a property in a node and check that it has a minimum length.
  *
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 02/17] fdt: Add header guard to fdtdec.h
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
@ 2012-01-15  0:47     ` Simon Glass
       [not found] ` <1326588449-1794-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
                       ` (12 subsequent siblings)
  13 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Devicetree Discuss, Tom Warren, Jerry Van Baren

This makes it easier to include this header from other headers.

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 include/fdtdec.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index 81ce3f6..f60c969 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -19,6 +19,8 @@
  * MA 02111-1307 USA
  */
 
+#ifndef __fdtdec_h
+#define __fdtdec_h
 
 /*
  * This file contains convenience functions for decoding useful and
@@ -371,3 +373,4 @@ int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name,
  */
 const u8 *fdtdec_locate_byte_array(const void *blob, int node,
 			     const char *prop_name, int count);
+#endif
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 02/17] fdt: Add header guard to fdtdec.h
@ 2012-01-15  0:47     ` Simon Glass
  0 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

This makes it easier to include this header from other headers.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 include/fdtdec.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index 81ce3f6..f60c969 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -19,6 +19,8 @@
  * MA 02111-1307 USA
  */
 
+#ifndef __fdtdec_h
+#define __fdtdec_h
 
 /*
  * This file contains convenience functions for decoding useful and
@@ -371,3 +373,4 @@ int fdtdec_get_byte_array(const void *blob, int node, const char *prop_name,
  */
 const u8 *fdtdec_locate_byte_array(const void *blob, int node,
 			     const char *prop_name, int count);
+#endif
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 03/17] fdt: Correct GPIO name access in fdtdec
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
@ 2012-01-15  0:47     ` Simon Glass
       [not found] ` <1326588449-1794-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
                       ` (12 subsequent siblings)
  13 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Devicetree Discuss, Tom Warren, Jerry Van Baren

This was missing an fdt32_to_cpu() call so got the name pointer wrong.
If the GPIO module looks at it, this would cause a problem.

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 lib/fdtdec.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index bcb2343..f7d0c95 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -418,7 +418,7 @@ static int fdtdec_decode_gpios(const void *blob, int node,
 	}
 
 	/* We will use the name to tag the GPIO */
-	name = fdt_string(blob, prop->nameoff);
+	name = fdt_string(blob, fdt32_to_cpu(prop->nameoff));
 	cell = (u32 *)prop->data;
 	len /= sizeof(u32) * 3;		/* 3 cells per GPIO record */
 	if (len > max_count) {
@@ -444,6 +444,7 @@ int fdtdec_decode_gpio(const void *blob, int node, const char *prop_name,
 
 	debug("%s: %s\n", __func__, prop_name);
 	gpio->gpio = FDT_GPIO_NONE;
+	gpio->name = NULL;
 	err = fdtdec_decode_gpios(blob, node, prop_name, gpio, 1);
 	return err == 1 ? 0 : err;
 }
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 03/17] fdt: Correct GPIO name access in fdtdec
@ 2012-01-15  0:47     ` Simon Glass
  0 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

This was missing an fdt32_to_cpu() call so got the name pointer wrong.
If the GPIO module looks at it, this would cause a problem.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 lib/fdtdec.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index bcb2343..f7d0c95 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -418,7 +418,7 @@ static int fdtdec_decode_gpios(const void *blob, int node,
 	}
 
 	/* We will use the name to tag the GPIO */
-	name = fdt_string(blob, prop->nameoff);
+	name = fdt_string(blob, fdt32_to_cpu(prop->nameoff));
 	cell = (u32 *)prop->data;
 	len /= sizeof(u32) * 3;		/* 3 cells per GPIO record */
 	if (len > max_count) {
@@ -444,6 +444,7 @@ int fdtdec_decode_gpio(const void *blob, int node, const char *prop_name,
 
 	debug("%s: %s\n", __func__, prop_name);
 	gpio->gpio = FDT_GPIO_NONE;
+	gpio->name = NULL;
 	err = fdtdec_decode_gpios(blob, node, prop_name, gpio, 1);
 	return err == 1 ? 0 : err;
 }
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 04/17] tegra: Add display support to funcmux
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
@ 2012-01-15  0:47 ` Simon Glass
  2012-01-15  1:36   ` Mike Frysinger
       [not found] ` <1326588449-1794-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

Add support for a default pin mapping for display1.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 arch/arm/cpu/armv7/tegra2/funcmux.c |   39 +++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/arch/arm/cpu/armv7/tegra2/funcmux.c b/arch/arm/cpu/armv7/tegra2/funcmux.c
index a5ff890..edddf03 100644
--- a/arch/arm/cpu/armv7/tegra2/funcmux.c
+++ b/arch/arm/cpu/armv7/tegra2/funcmux.c
@@ -25,6 +25,31 @@
 #include <asm/arch/funcmux.h>
 #include <asm/arch/pinmux.h>
 
+/*
+ * The PINMUX macro is used to set up pinmux tables.
+ */
+#define PINMUX(grp, mux, pupd, tri)                   \
+	{PINGRP_##grp, PMUX_FUNC_##mux, PMUX_PULL_##pupd, PMUX_TRI_##tri}
+
+struct pingroup_config disp1_default[] = {
+	PINMUX(LDI,   DISPA,      NORMAL,    NORMAL),
+	PINMUX(LHP0,  DISPA,      NORMAL,    NORMAL),
+	PINMUX(LHP1,  DISPA,      NORMAL,    NORMAL),
+	PINMUX(LHP2,  DISPA,      NORMAL,    NORMAL),
+	PINMUX(LHS,   DISPA,      NORMAL,    NORMAL),
+	PINMUX(LM0,   RSVD4,      NORMAL,    NORMAL),
+	PINMUX(LPP,   DISPA,      NORMAL,    NORMAL),
+	PINMUX(LPW0,  DISPA,      NORMAL,    NORMAL),
+	PINMUX(LPW1,  RSVD4,      NORMAL,    TRISTATE),
+	PINMUX(LPW2,  DISPA,      NORMAL,    NORMAL),
+	PINMUX(LSC0,  DISPA,      NORMAL,    NORMAL),
+	PINMUX(LSPI,  DISPA,      NORMAL,    NORMAL),
+	PINMUX(LVP1,  DISPA,      NORMAL,    NORMAL),
+	PINMUX(LVS,   DISPA,      NORMAL,    NORMAL),
+	PINMUX(SLXD,  SPDIF,      NORMAL,    NORMAL),
+};
+
+
 int funcmux_select(enum periph_id id, int config)
 {
 	int bad_config = config != FUNCMUX_DEFAULT;
@@ -179,6 +204,20 @@ int funcmux_select(enum periph_id id, int config)
 			break;
 		}
 
+	case PERIPH_ID_DISP1:
+		if (config == FUNCMUX_DEFAULT) {
+			int i;
+
+			for (i = PINGRP_LD0; i <= PINGRP_LD17; i++) {
+				pinmux_set_func(i, PMUX_FUNC_DISPA);
+				pinmux_tristate_disable(i);
+				pinmux_set_pullupdown(i, PMUX_PULL_NORMAL);
+			}
+			pinmux_config_table(disp1_default,
+					    ARRAY_SIZE(disp1_default));
+		}
+		break;
+
 	default:
 		debug("%s: invalid periph_id %d", __func__, id);
 		return -1;
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 05/17] tegra: fdt: Add LCD definitions for Tegra
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
@ 2012-01-15  0:47     ` Simon Glass
       [not found] ` <1326588449-1794-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
                       ` (12 subsequent siblings)
  13 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Devicetree Discuss, Tom Warren, Jerry Van Baren

Add LCD definitions and also a proposed binding for LCD displays.

The PWFM is in progress on the device-tree-discuss list, so only a
very basic binding is offered here.

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 arch/arm/dts/tegra20.dtsi                       |   25 ++++++
 doc/device-tree-bindings/video/nvidia-video.txt |   92 +++++++++++++++++++++++
 2 files changed, 117 insertions(+), 0 deletions(-)
 create mode 100644 doc/device-tree-bindings/video/nvidia-video.txt

diff --git a/arch/arm/dts/tegra20.dtsi b/arch/arm/dts/tegra20.dtsi
index 3d435aa..85c8bf6 100644
--- a/arch/arm/dts/tegra20.dtsi
+++ b/arch/arm/dts/tegra20.dtsi
@@ -221,4 +221,29 @@
 		compatible = "nvidia,tegra20-kbc";
 		reg = <0x7000e200 0x0078>;
 	};
+
+	pwfm0: pwm@7000a000 {
+		compatible = "nvidia,tegra20-pwfm";
+		reg = <0x7000a000 0x4>;
+	};
+
+	pwfm1: pwm@7000a010 {
+		compatible = "nvidia,tegra20-pwfm";
+		reg = <0x7000a010 0x4>;
+	};
+
+	pwfm2: pwm@7000a020 {
+		compatible = "nvidia,tegra20-pwfm";
+		reg = <0x7000a020 0x4>;
+	};
+
+	pwfm3: pwm@7000a030 {
+		compatible = "nvidia,tegra20-pwfm";
+		reg = <0x7000a030 0x4>;
+	};
+
+	display1: display@0x54200000 {
+		compatible = "nvidia,tegra20-display";
+		reg = <0x54200000 0x40000>;
+	};
 };
diff --git a/doc/device-tree-bindings/video/nvidia-video.txt b/doc/device-tree-bindings/video/nvidia-video.txt
new file mode 100644
index 0000000..ede9260
--- /dev/null
+++ b/doc/device-tree-bindings/video/nvidia-video.txt
@@ -0,0 +1,92 @@
+LCD Display
+-----------
+
+(there isn't yet a generic binding in Linux, so this describes what is in
+U-Boot)
+
+The device node for a display device is as described in the document
+"Open Firmware Recommended Practice : Universal Serial Bus" with the
+following modifications and additions :
+
+Required properties :
+ - compatible : Should be "nvidia,tegra20-display"
+ - pwfm: phandle of PWFM to use for backlight
+
+Note: This is just a phande and provides no information, nor a backlight
+node. The PWM is still under discussion I think:
+	http://patchwork.ozlabs.org/patch/132386/
+
+We don't support any parameters as yet - the setting is hard-coded.
+
+ - width: width of display in pixels
+ - height: height of display in pixels
+ - bits-per-pixel: number of bits per pixel (depth)
+ - pixel-clock : Pixel clock in Hz
+ - horiz-timing; horizontal timing: ref_to_sync, sync_width. back_porch,
+	front_porch
+ - vert-timing; vertical timing: ref_to_sync, sync_width. back_porch,
+	front_porch
+
+This node should sit inside its controller.
+
+
+Nvidia Tegra2x Display Controller
+---------------------------------
+
+The device node for a NAND flash controller is as described in the document
+"Open Firmware Recommended Practice : Universal Serial Bus" with the
+following modifications and additions :
+
+Required properties:
+ - compatible: should be "tegra20-display"
+ - panel-timings: 4 cells containing required timings in ms:
+	* delay between panel_vdd-rise and data-rise
+	* delay between data-rise and backlight_vdd-rise
+	* delay between backlight_vdd and pwm-rise
+	* delay between pwm-rise and backlight_en-rise
+
+(should we use us here, or perhaps call it panel-timings-ms?)
+
+Optional properties:
+ - frame-buffer: address of frame buffer (if omitted it will be calculated)
+	- This may be useful to share an address between U-Boot and Linux and
+		avoid boot-time corruption / flicker
+
+Optional GPIO properies all have (phandle, GPIO number, flags):
+ - backlight-enable-gpio: backlight enable GPIO
+ - lvds-shutdown-gpio: LVDS power shutdown GPIO
+ - backlight-vdd-gpio: backlight power GPIO
+ - panel-vdd-gpio: panel power GPIO
+
+(should those have an "nvidia," prefix? Perhap use polariy bit so that
+lvds-shutdown becomes lvds-enable?)
+
+I have put these into the display controller since I don't think they are
+generic enough to go in the lcd node.
+
+Example:
+
+display@0x54200000 {
+	pwfm = <&pwfm2>;
+
+	/* frame-buffer location to share with Linux */
+	frame-buffer = <0x2f680000>;
+
+	/* Parameter 3 bit 0:1=output, 0=input; bit 1:1=high, 0=low */
+	backlight-enable = <&gpio 28 0>;	/* PD4 */
+	lvds-shutdown = <&gpio 10 0>;		/* PB2 */
+	backlight-vdd = <&gpio 176 0>;		/* PW0 */
+	panel-vdd = <&gpio 22 0>;		/* PC6 */
+	panel-timings = <4 203 17 15>;
+
+	lcd {
+		compatible = "generic,lcd";
+		width = <1366>;
+		height = <768>;
+		bits-per-pixel = <16>;
+		pixel-clock = <70600000>;
+
+		horiz-timing = <11 58 58 58>;
+		vert-timing = <1 4 4 4>;
+	};
+};
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 05/17] tegra: fdt: Add LCD definitions for Tegra
@ 2012-01-15  0:47     ` Simon Glass
  0 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

Add LCD definitions and also a proposed binding for LCD displays.

The PWFM is in progress on the device-tree-discuss list, so only a
very basic binding is offered here.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 arch/arm/dts/tegra20.dtsi                       |   25 ++++++
 doc/device-tree-bindings/video/nvidia-video.txt |   92 +++++++++++++++++++++++
 2 files changed, 117 insertions(+), 0 deletions(-)
 create mode 100644 doc/device-tree-bindings/video/nvidia-video.txt

diff --git a/arch/arm/dts/tegra20.dtsi b/arch/arm/dts/tegra20.dtsi
index 3d435aa..85c8bf6 100644
--- a/arch/arm/dts/tegra20.dtsi
+++ b/arch/arm/dts/tegra20.dtsi
@@ -221,4 +221,29 @@
 		compatible = "nvidia,tegra20-kbc";
 		reg = <0x7000e200 0x0078>;
 	};
+
+	pwfm0: pwm at 7000a000 {
+		compatible = "nvidia,tegra20-pwfm";
+		reg = <0x7000a000 0x4>;
+	};
+
+	pwfm1: pwm at 7000a010 {
+		compatible = "nvidia,tegra20-pwfm";
+		reg = <0x7000a010 0x4>;
+	};
+
+	pwfm2: pwm at 7000a020 {
+		compatible = "nvidia,tegra20-pwfm";
+		reg = <0x7000a020 0x4>;
+	};
+
+	pwfm3: pwm at 7000a030 {
+		compatible = "nvidia,tegra20-pwfm";
+		reg = <0x7000a030 0x4>;
+	};
+
+	display1: display at 0x54200000 {
+		compatible = "nvidia,tegra20-display";
+		reg = <0x54200000 0x40000>;
+	};
 };
diff --git a/doc/device-tree-bindings/video/nvidia-video.txt b/doc/device-tree-bindings/video/nvidia-video.txt
new file mode 100644
index 0000000..ede9260
--- /dev/null
+++ b/doc/device-tree-bindings/video/nvidia-video.txt
@@ -0,0 +1,92 @@
+LCD Display
+-----------
+
+(there isn't yet a generic binding in Linux, so this describes what is in
+U-Boot)
+
+The device node for a display device is as described in the document
+"Open Firmware Recommended Practice : Universal Serial Bus" with the
+following modifications and additions :
+
+Required properties :
+ - compatible : Should be "nvidia,tegra20-display"
+ - pwfm: phandle of PWFM to use for backlight
+
+Note: This is just a phande and provides no information, nor a backlight
+node. The PWM is still under discussion I think:
+	http://patchwork.ozlabs.org/patch/132386/
+
+We don't support any parameters as yet - the setting is hard-coded.
+
+ - width: width of display in pixels
+ - height: height of display in pixels
+ - bits-per-pixel: number of bits per pixel (depth)
+ - pixel-clock : Pixel clock in Hz
+ - horiz-timing; horizontal timing: ref_to_sync, sync_width. back_porch,
+	front_porch
+ - vert-timing; vertical timing: ref_to_sync, sync_width. back_porch,
+	front_porch
+
+This node should sit inside its controller.
+
+
+Nvidia Tegra2x Display Controller
+---------------------------------
+
+The device node for a NAND flash controller is as described in the document
+"Open Firmware Recommended Practice : Universal Serial Bus" with the
+following modifications and additions :
+
+Required properties:
+ - compatible: should be "tegra20-display"
+ - panel-timings: 4 cells containing required timings in ms:
+	* delay between panel_vdd-rise and data-rise
+	* delay between data-rise and backlight_vdd-rise
+	* delay between backlight_vdd and pwm-rise
+	* delay between pwm-rise and backlight_en-rise
+
+(should we use us here, or perhaps call it panel-timings-ms?)
+
+Optional properties:
+ - frame-buffer: address of frame buffer (if omitted it will be calculated)
+	- This may be useful to share an address between U-Boot and Linux and
+		avoid boot-time corruption / flicker
+
+Optional GPIO properies all have (phandle, GPIO number, flags):
+ - backlight-enable-gpio: backlight enable GPIO
+ - lvds-shutdown-gpio: LVDS power shutdown GPIO
+ - backlight-vdd-gpio: backlight power GPIO
+ - panel-vdd-gpio: panel power GPIO
+
+(should those have an "nvidia," prefix? Perhap use polariy bit so that
+lvds-shutdown becomes lvds-enable?)
+
+I have put these into the display controller since I don't think they are
+generic enough to go in the lcd node.
+
+Example:
+
+display at 0x54200000 {
+	pwfm = <&pwfm2>;
+
+	/* frame-buffer location to share with Linux */
+	frame-buffer = <0x2f680000>;
+
+	/* Parameter 3 bit 0:1=output, 0=input; bit 1:1=high, 0=low */
+	backlight-enable = <&gpio 28 0>;	/* PD4 */
+	lvds-shutdown = <&gpio 10 0>;		/* PB2 */
+	backlight-vdd = <&gpio 176 0>;		/* PW0 */
+	panel-vdd = <&gpio 22 0>;		/* PC6 */
+	panel-timings = <4 203 17 15>;
+
+	lcd {
+		compatible = "generic,lcd";
+		width = <1366>;
+		height = <768>;
+		bits-per-pixel = <16>;
+		pixel-clock = <70600000>;
+
+		horiz-timing = <11 58 58 58>;
+		vert-timing = <1 4 4 4>;
+	};
+};
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 06/17] tegra: Add support for PWFM
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
  2012-01-15  0:47 ` [U-Boot] [PATCH 04/17] tegra: Add display support to funcmux Simon Glass
       [not found] ` <1326588449-1794-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2012-01-15  0:47 ` Simon Glass
  2012-01-15  0:47 ` [U-Boot] [PATCH 07/17] tegra: Add SOC support for display/lcd Simon Glass
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

The pulse width/frequency modulation peripheral supports generating
a repeating pulse. It is useful for controlling LCD brightness.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 arch/arm/cpu/armv7/tegra2/Makefile      |    1 +
 arch/arm/cpu/armv7/tegra2/pwfm.c        |   40 +++++++++++++++++++++++
 arch/arm/include/asm/arch-tegra2/pwfm.h |   54 +++++++++++++++++++++++++++++++
 3 files changed, 95 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/tegra2/pwfm.c
 create mode 100644 arch/arm/include/asm/arch-tegra2/pwfm.h

diff --git a/arch/arm/cpu/armv7/tegra2/Makefile b/arch/arm/cpu/armv7/tegra2/Makefile
index 08c4137..9779e9e 100644
--- a/arch/arm/cpu/armv7/tegra2/Makefile
+++ b/arch/arm/cpu/armv7/tegra2/Makefile
@@ -39,6 +39,7 @@ COBJS-$(CONFIG_TEGRA_CLOCK_SCALING) += emc.o
 COBJS-$(CONFIG_TEGRA_PMU) += pmu.o
 COBJS-$(CONFIG_USB_EHCI_TEGRA) += usb.o
 COBJS-$(CONFIG_TEGRA2_LP0) += crypto.o warmboot.o warmboot_avp.o
+COBJS-$(CONFIG_VIDEO_TEGRA) += pwfm.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
diff --git a/arch/arm/cpu/armv7/tegra2/pwfm.c b/arch/arm/cpu/armv7/tegra2/pwfm.c
new file mode 100644
index 0000000..cdb0cbe
--- /dev/null
+++ b/arch/arm/cpu/armv7/tegra2/pwfm.c
@@ -0,0 +1,40 @@
+/*
+ * Tegra2 pulse width frequency modulator definitions
+ *
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/pwfm.h>
+
+void pwfm_enable(struct pwfm_ctlr *pwfm, int rate, int pulse_width,
+		int freq_divider)
+{
+	u32 reg;
+
+	/* TODO: Can we use clock_adjust_periph_pll_div() here? */
+	clock_start_periph_pll(PERIPH_ID_PWM, CLOCK_ID_SFROM32KHZ, rate);
+
+	reg = PWFM_ENABLE_MASK;
+	reg |= pulse_width << PWFM_WIDTH_SHIFT;
+	reg |= freq_divider << PWFM_DIVIDER_SHIFT;
+	writel(reg, &pwfm->control);
+}
diff --git a/arch/arm/include/asm/arch-tegra2/pwfm.h b/arch/arm/include/asm/arch-tegra2/pwfm.h
new file mode 100644
index 0000000..69e2edd
--- /dev/null
+++ b/arch/arm/include/asm/arch-tegra2/pwfm.h
@@ -0,0 +1,54 @@
+/*
+ * Tegra pulse width frequency modulator definitions
+ *
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_ARCH_TEGRA_PWFM_H
+#define __ASM_ARCH_TEGRA_PWFM_H
+
+/* This is a single PWFM channel */
+struct pwfm_ctlr {
+	uint control;		/* Control register */
+};
+
+/* PWM_CONTROLLER_PWM_CSR_0/1/2/3_0 */
+#define PWFM_ENABLE_SHIFT	31
+#define PWFM_ENABLE_MASK	(0x1 << PWFM_ENABLE_SHIFT)
+
+#define PWFM_WIDTH_SHIFT	16
+#define PWFM_WIDTH_MASK		(0x7FFF << PWFM_WIDTH_SHIFT)
+
+#define PWFM_DIVIDER_SHIFT	0
+#define PWFM_DIVIDER_MASK	(0x1FFF << PWFM_DIVIDER_SHIFT)
+
+/**
+ * Program the PWFM with the given parameters.
+ *
+ * @param pwfm		Pointer to PWFM register
+ * @param rate		Clock rate to use for PWFM
+ * @param pulse_width	high pulse width: 0=always low, 1=1/256 pulse high,
+ *			n = n/256 pulse high
+ * @param freq_divider	frequency divider value (1 to use rate as is)
+ */
+void pwfm_enable(struct pwfm_ctlr *pwfm, int rate, int pulse_width,
+		int freq_divider);
+
+#endif	/* __ASM_ARCH_TEGRA_PWFM_H */
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 07/17] tegra: Add SOC support for display/lcd
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
                   ` (2 preceding siblings ...)
  2012-01-15  0:47 ` [U-Boot] [PATCH 06/17] tegra: Add support for PWFM Simon Glass
@ 2012-01-15  0:47 ` Simon Glass
  2012-01-15  0:47 ` [U-Boot] [PATCH 08/17] tegra: Add LCD driver Simon Glass
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

From: Wei Ni <wni@nvidia.com>

Add support for the LCD peripheral at the Tegra2 SOC level. A separate
LCD driver will use this functionality to configure the display.

Mayuresh Kulkarni:
- changes to remove bitfields and clean up for submission

Simon Glass:
- simplify code, move clock control into here, clean-up

Signed-off-by: Mayuresh Kulkarni <mkulkarni@nvidia.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
---
 arch/arm/cpu/armv7/tegra2/Makefile         |    2 +-
 arch/arm/cpu/armv7/tegra2/display.c        |  271 ++++++++++++++
 arch/arm/include/asm/arch-tegra2/dc.h      |  544 ++++++++++++++++++++++++++++
 arch/arm/include/asm/arch-tegra2/display.h |  133 +++++++
 4 files changed, 949 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/tegra2/display.c
 create mode 100644 arch/arm/include/asm/arch-tegra2/dc.h
 create mode 100644 arch/arm/include/asm/arch-tegra2/display.h

diff --git a/arch/arm/cpu/armv7/tegra2/Makefile b/arch/arm/cpu/armv7/tegra2/Makefile
index 9779e9e..413f8c9 100644
--- a/arch/arm/cpu/armv7/tegra2/Makefile
+++ b/arch/arm/cpu/armv7/tegra2/Makefile
@@ -39,7 +39,7 @@ COBJS-$(CONFIG_TEGRA_CLOCK_SCALING) += emc.o
 COBJS-$(CONFIG_TEGRA_PMU) += pmu.o
 COBJS-$(CONFIG_USB_EHCI_TEGRA) += usb.o
 COBJS-$(CONFIG_TEGRA2_LP0) += crypto.o warmboot.o warmboot_avp.o
-COBJS-$(CONFIG_VIDEO_TEGRA) += pwfm.o
+COBJS-$(CONFIG_VIDEO_TEGRA) += display.o pwfm.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
diff --git a/arch/arm/cpu/armv7/tegra2/display.c b/arch/arm/cpu/armv7/tegra2/display.c
new file mode 100644
index 0000000..f4f4c85
--- /dev/null
+++ b/arch/arm/cpu/armv7/tegra2/display.c
@@ -0,0 +1,271 @@
+/*
+ *  (C) Copyright 2010
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/clk_rst.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/timer.h>
+#include <asm/arch/tegra2.h>
+#include <asm/arch/display.h>
+#include <asm/arch/dc.h>
+
+static void update_window(struct dc_ctlr *dc, struct disp_ctl_win *win)
+{
+	unsigned h_dda, v_dda;
+	unsigned long val;
+
+	val = readl(&dc->cmd.disp_win_header);
+	val |= WINDOW_A_SELECT;
+	writel(val, &dc->cmd.disp_win_header);
+
+	writel(win->fmt, &dc->win.color_depth);
+
+	val = readl(&dc->win.byte_swap);
+	val |= BYTE_SWAP_NOSWAP << BYTE_SWAP_SHIFT;
+	writel(val, &dc->win.byte_swap);
+
+	val = win->out_x << H_POSITION_SHIFT;
+	val |= win->out_y << V_POSITION_SHIFT;
+	writel(val, &dc->win.pos);
+
+	val = win->out_w << H_SIZE_SHIFT;
+	val |= win->out_h << V_SIZE_SHIFT;
+	writel(val, &dc->win.size);
+
+	val = (win->w * win->bpp / 8) << H_PRESCALED_SIZE_SHIFT;
+	val |= win->h << V_PRESCALED_SIZE_SHIFT;
+	writel(val, &dc->win.prescaled_size);
+
+	writel(0, &dc->win.h_initial_dda);
+	writel(0, &dc->win.v_initial_dda);
+
+	h_dda = (win->w * 0x1000) / max(win->out_w - 1, 1);
+	v_dda = (win->h * 0x1000) / max(win->out_h - 1, 1);
+
+	val = h_dda << H_DDA_INC_SHIFT;
+	val |= v_dda << V_DDA_INC_SHIFT;
+	writel(val, &dc->win.dda_increment);
+
+	writel(win->stride, &dc->win.line_stride);
+	writel(0, &dc->win.buf_stride);
+
+	val = WIN_ENABLE;
+	if (win->bpp < 24)
+		val |= COLOR_EXPAND;
+	writel(val, &dc->win.win_opt);
+
+	writel((unsigned long)win->phys_addr, &dc->winbuf.start_addr);
+	writel(win->x, &dc->winbuf.addr_h_offset);
+	writel(win->y, &dc->winbuf.addr_v_offset);
+
+	writel(0xff00, &dc->win.blend_nokey);
+	writel(0xff00, &dc->win.blend_1win);
+
+	val = GENERAL_ACT_REQ | WIN_A_ACT_REQ;
+	val |= GENERAL_UPDATE | WIN_A_UPDATE;
+	writel(val, &dc->cmd.state_ctrl);
+}
+
+static void write_pair(struct fdt_lcd *config, int item, u32 *reg)
+{
+	writel(config->horiz_timing[item] |
+			(config->vert_timing[item] << 16), reg);
+}
+
+static int update_display_mode(struct dc_disp_reg *disp,
+		struct fdt_lcd *config)
+{
+	unsigned long val;
+	unsigned long rate;
+	unsigned long div;
+
+	writel(0x0, &disp->disp_timing_opt);
+	write_pair(config, FDT_LCD_TIMING_REF_TO_SYNC, &disp->ref_to_sync);
+	write_pair(config, FDT_LCD_TIMING_SYNC_WIDTH, &disp->sync_width);
+	write_pair(config, FDT_LCD_TIMING_BACK_PORCH, &disp->back_porch);
+	write_pair(config, FDT_LCD_TIMING_FRONT_PORCH, &disp->front_porch);
+
+	writel(config->width | (config->height << 16), &disp->disp_active);
+
+	val = DE_SELECT_ACTIVE << DE_SELECT_SHIFT;
+	val |= DE_CONTROL_NORMAL << DE_CONTROL_SHIFT;
+	writel(val, &disp->data_enable_opt);
+
+	val = DATA_FORMAT_DF1P1C << DATA_FORMAT_SHIFT;
+	val |= DATA_ALIGNMENT_MSB << DATA_ALIGNMENT_SHIFT;
+	val |= DATA_ORDER_RED_BLUE << DATA_ORDER_SHIFT;
+	writel(val, &disp->disp_interface_ctrl);
+
+	/*
+	 * The pixel clock divider is in 7.1 format (where the bottom bit
+	 * represents 0.5). Here we calculate the divider needed to get from
+	 * the display clock (typically 600MHz) to the pixel clock. We round
+	 * up or down as requried.
+	 */
+	rate = clock_get_periph_rate(PERIPH_ID_DISP1, CLOCK_ID_CGENERAL);
+	div = ((rate * 2 + config->pixel_clock / 2) / config->pixel_clock) - 2;
+	debug("Display clock %lu, divider %lu\n", rate, div);
+
+	writel(0x00010001, &disp->shift_clk_opt);
+
+	val = PIXEL_CLK_DIVIDER_PCD1 << PIXEL_CLK_DIVIDER_SHIFT;
+	val |= div << SHIFT_CLK_DIVIDER_SHIFT;
+	writel(val, &disp->disp_clk_ctrl);
+
+	return 0;
+}
+
+/* Start up the display and turn on power to PWMs */
+static void basic_init(struct dc_cmd_reg *cmd)
+{
+	u32 val;
+
+	writel(0x00000100, &cmd->gen_incr_syncpt_ctrl);
+	writel(0x0000011a, &cmd->cont_syncpt_vsync);
+	writel(0x00000000, &cmd->int_type);
+	writel(0x00000000, &cmd->int_polarity);
+	writel(0x00000000, &cmd->int_mask);
+	writel(0x00000000, &cmd->int_enb);
+
+	val = PW0_ENABLE | PW1_ENABLE | PW2_ENABLE;
+	val |= PW3_ENABLE | PW4_ENABLE | PM0_ENABLE;
+	val |= PM1_ENABLE;
+	writel(val, &cmd->disp_pow_ctrl);
+
+	val = readl(&cmd->disp_cmd);
+	val |= CTRL_MODE_C_DISPLAY << CTRL_MODE_SHIFT;
+	writel(val, &cmd->disp_cmd);
+}
+
+static void basic_init_timer(struct dc_disp_reg *disp)
+{
+	writel(0x00000020, &disp->mem_high_pri);
+	writel(0x00000001, &disp->mem_high_pri_timer);
+}
+
+static const u32 rgb_enb_tab[PIN_REG_COUNT] = {
+	0x00000000,
+	0x00000000,
+	0x00000000,
+	0x00000000,
+};
+
+static const u32 rgb_polarity_tab[PIN_REG_COUNT] = {
+	0x00000000,
+	0x01000000,
+	0x00000000,
+	0x00000000,
+};
+
+static const u32 rgb_data_tab[PIN_REG_COUNT] = {
+	0x00000000,
+	0x00000000,
+	0x00000000,
+	0x00000000,
+};
+
+static const u32 rgb_sel_tab[PIN_OUTPUT_SEL_COUNT] = {
+	0x00000000,
+	0x00000000,
+	0x00000000,
+	0x00000000,
+	0x00210222,
+	0x00002200,
+	0x00020000,
+};
+
+static void rgb_enable(struct dc_com_reg *com)
+{
+	int i;
+
+	for (i = 0; i < PIN_REG_COUNT; i++) {
+		writel(rgb_enb_tab[i], &com->pin_output_enb[i]);
+		writel(rgb_polarity_tab[i], &com->pin_output_polarity[i]);
+		writel(rgb_data_tab[i], &com->pin_output_data[i]);
+	}
+
+	for (i = 0; i < PIN_OUTPUT_SEL_COUNT; i++)
+		writel(rgb_sel_tab[i], &com->pin_output_sel[i]);
+}
+
+int setup_window(struct disp_ctl_win *win, struct fdt_lcd *config)
+{
+	win->x = 0;
+	win->y = 0;
+	win->w = config->width;
+	win->h = config->height;
+	win->out_x = 0;
+	win->out_y = 0;
+	win->out_w = config->width;
+	win->out_h = config->height;
+	win->phys_addr = config->frame_buffer;
+	win->stride = config->width * (1 << config->log2_bpp) / 8;
+	debug("%s: depth = %d\n", __func__, config->log2_bpp);
+	switch (config->log2_bpp) {
+	case 5:
+	case 24:
+		win->fmt = COLOR_DEPTH_R8G8B8A8;
+		win->bpp = 32;
+		break;
+	case 4:
+		win->fmt = COLOR_DEPTH_B5G6R5;
+		win->bpp = 16;
+		break;
+
+	default:
+		debug("Unsupported LCD bit depth");
+		return -1;
+	}
+
+	return 0;
+}
+
+int tegra2_display_register(struct fdt_lcd *config)
+{
+	struct disp_ctl_win window;
+	struct dc_ctlr *dc = (struct dc_ctlr *)config->disp;
+
+	/*
+	 * A header file for clock constants was NAKed upstream.
+	 * TODO: Put this into the FDT and fdt_lcd struct when we have clock
+	 * support there
+	 */
+	clock_start_periph_pll(PERIPH_ID_HOST1X, CLOCK_ID_PERIPH,
+			       144 * 1000000);
+	clock_start_periph_pll(PERIPH_ID_DISP1, CLOCK_ID_CGENERAL,
+			       600 * 1000000);
+	basic_init(&dc->cmd);
+	basic_init_timer(&dc->disp);
+	rgb_enable(&dc->com);
+
+	if (config->pixel_clock)
+		update_display_mode(&dc->disp, config);
+
+	if (setup_window(&window, config))
+		return -1;
+
+	update_window(dc, &window);
+
+	return 0;
+}
diff --git a/arch/arm/include/asm/arch-tegra2/dc.h b/arch/arm/include/asm/arch-tegra2/dc.h
new file mode 100644
index 0000000..46c4137
--- /dev/null
+++ b/arch/arm/include/asm/arch-tegra2/dc.h
@@ -0,0 +1,544 @@
+/*
+ *  (C) Copyright 2010
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_ARCH_TEGRA_DC_H
+#define __ASM_ARCH_TEGRA_DC_H
+
+/* Register definitions for the Tegra display controller */
+
+/* CMD register 0x000 ~ 0x43 */
+struct dc_cmd_reg {
+	/* Address 0x000 ~ 0x002 */
+	uint gen_incr_syncpt;		/* _CMD_GENERAL_INCR_SYNCPT_0 */
+	uint gen_incr_syncpt_ctrl;	/* _CMD_GENERAL_INCR_SYNCPT_CNTRL_0 */
+	uint gen_incr_syncpt_err;	/* _CMD_GENERAL_INCR_SYNCPT_ERROR_0 */
+
+	uint reserved0[5];		/* reserved_0[5] */
+
+	/* Address 0x008 ~ 0x00a */
+	uint win_a_incr_syncpt;		/* _CMD_WIN_A_INCR_SYNCPT_0 */
+	uint win_a_incr_syncpt_ctrl;	/* _CMD_WIN_A_INCR_SYNCPT_CNTRL_0 */
+	uint win_a_incr_syncpt_err;	/* _CMD_WIN_A_INCR_SYNCPT_ERROR_0 */
+
+	uint reserved1[5];		/* reserved_1[5] */
+
+	/* Address 0x010 ~ 0x012 */
+	uint win_b_incr_syncpt;		/* _CMD_WIN_B_INCR_SYNCPT_0 */
+	uint win_b_incr_syncpt_ctrl;	/* _CMD_WIN_B_INCR_SYNCPT_CNTRL_0 */
+	uint win_b_incr_syncpt_err;	/* _CMD_WIN_B_INCR_SYNCPT_ERROR_0 */
+
+	uint reserved2[5];		/* reserved_2[5] */
+
+	/* Address 0x018 ~ 0x01a */
+	uint win_c_incr_syncpt;		/* _CMD_WIN_C_INCR_SYNCPT_0 */
+	uint win_c_incr_syncpt_ctrl;	/* _CMD_WIN_C_INCR_SYNCPT_CNTRL_0 */
+	uint win_c_incr_syncpt_err;	/* _CMD_WIN_C_INCR_SYNCPT_ERROR_0 */
+
+	uint reserved3[13];		/* reserved_3[13] */
+
+	/* Address 0x028 */
+	uint cont_syncpt_vsync;		/* _CMD_CONT_SYNCPT_VSYNC_0 */
+
+	uint reserved4[7];		/* reserved_4[7] */
+
+	/* Address 0x030 ~ 0x033 */
+	uint ctxsw;			/* _CMD_CTXSW_0 */
+	uint disp_cmd_opt0;		/* _CMD_DISPLAY_COMMAND_OPTION0_0 */
+	uint disp_cmd;			/* _CMD_DISPLAY_COMMAND_0 */
+	uint sig_raise;			/* _CMD_SIGNAL_RAISE_0 */
+
+	uint reserved5[2];		/* reserved_0[2] */
+
+	/* Address 0x036 ~ 0x03e */
+	uint disp_pow_ctrl;		/* _CMD_DISPLAY_POWER_CONTROL_0 */
+	uint int_stat;			/* _CMD_INT_STATUS_0 */
+	uint int_mask;			/* _CMD_INT_MASK_0 */
+	uint int_enb;			/* _CMD_INT_ENABLE_0 */
+	uint int_type;			/* _CMD_INT_TYPE_0 */
+	uint int_polarity;		/* _CMD_INT_POLARITY_0 */
+	uint sig_raise1;		/* _CMD_SIGNAL_RAISE1_0 */
+	uint sig_raise2;		/* _CMD_SIGNAL_RAISE2_0 */
+	uint sig_raise3;		/* _CMD_SIGNAL_RAISE3_0 */
+
+	uint reserved6;			/* reserved_6 */
+
+	/* Address 0x040 ~ 0x043 */
+	uint state_access;		/* _CMD_STATE_ACCESS_0 */
+	uint state_ctrl;		/* _CMD_STATE_CONTROL_0 */
+	uint disp_win_header;		/* _CMD_DISPLAY_WINDOW_HEADER_0 */
+	uint reg_act_ctrl;		/* _CMD_REG_ACT_CONTROL_0 */
+};
+
+enum {
+	PIN_REG_COUNT		= 4,
+	PIN_OUTPUT_SEL_COUNT	= 7,
+};
+
+/* COM register 0x300 ~ 0x329 */
+struct dc_com_reg {
+	/* Address 0x300 ~ 0x301 */
+	uint crc_ctrl;			/* _COM_CRC_CONTROL_0 */
+	uint crc_checksum;		/* _COM_CRC_CHECKSUM_0 */
+
+	/* _COM_PIN_OUTPUT_ENABLE0/1/2/3_0: Address 0x302 ~ 0x305 */
+	uint pin_output_enb[PIN_REG_COUNT];
+
+	/* _COM_PIN_OUTPUT_POLARITY0/1/2/3_0: Address 0x306 ~ 0x309 */
+	uint pin_output_polarity[PIN_REG_COUNT];
+
+	/* _COM_PIN_OUTPUT_DATA0/1/2/3_0: Address 0x30a ~ 0x30d */
+	uint pin_output_data[PIN_REG_COUNT];
+
+	/* _COM_PIN_INPUT_ENABLE0_0: Address 0x30e ~ 0x311 */
+	uint pin_input_enb[PIN_REG_COUNT];
+
+	/* Address 0x312 ~ 0x313 */
+	uint pin_input_data0;		/* _COM_PIN_INPUT_DATA0_0 */
+	uint pin_input_data1;		/* _COM_PIN_INPUT_DATA1_0 */
+
+	/* _COM_PIN_OUTPUT_SELECT0/1/2/3/4/5/6_0: Address 0x314 ~ 0x31a */
+	uint pin_output_sel[PIN_OUTPUT_SEL_COUNT];
+
+	/* Address 0x31b ~ 0x329 */
+	uint pin_misc_ctrl;		/* _COM_PIN_MISC_CONTROL_0 */
+	uint pm0_ctrl;			/* _COM_PM0_CONTROL_0 */
+	uint pm0_duty_cycle;		/* _COM_PM0_DUTY_CYCLE_0 */
+	uint pm1_ctrl;			/* _COM_PM1_CONTROL_0 */
+	uint pm1_duty_cycle;		/* _COM_PM1_DUTY_CYCLE_0 */
+	uint spi_ctrl;			/* _COM_SPI_CONTROL_0 */
+	uint spi_start_byte;		/* _COM_SPI_START_BYTE_0 */
+	uint hspi_wr_data_ab;		/* _COM_HSPI_WRITE_DATA_AB_0 */
+	uint hspi_wr_data_cd;		/* _COM_HSPI_WRITE_DATA_CD */
+	uint hspi_cs_dc;		/* _COM_HSPI_CS_DC_0 */
+	uint scratch_reg_a;		/* _COM_SCRATCH_REGISTER_A_0 */
+	uint scratch_reg_b;		/* _COM_SCRATCH_REGISTER_B_0 */
+	uint gpio_ctrl;			/* _COM_GPIO_CTRL_0 */
+	uint gpio_debounce_cnt;		/* _COM_GPIO_DEBOUNCE_COUNTER_0 */
+	uint crc_checksum_latched;	/* _COM_CRC_CHECKSUM_LATCHED_0 */
+};
+
+enum dc_disp_h_pulse_pos {
+	H_PULSE0_POSITION_A,
+	H_PULSE0_POSITION_B,
+	H_PULSE0_POSITION_C,
+	H_PULSE0_POSITION_D,
+	H_PULSE0_POSITION_COUNT,
+};
+
+struct _disp_h_pulse {
+	/* _DISP_H_PULSE0/1/2_CONTROL_0 */
+	uint h_pulse_ctrl;
+	/* _DISP_H_PULSE0/1/2_POSITION_A/B/C/D_0 */
+	uint h_pulse_pos[H_PULSE0_POSITION_COUNT];
+};
+
+enum dc_disp_v_pulse_pos {
+	V_PULSE0_POSITION_A,
+	V_PULSE0_POSITION_B,
+	V_PULSE0_POSITION_C,
+	V_PULSE0_POSITION_COUNT,
+};
+
+struct _disp_v_pulse0 {
+	/* _DISP_H_PULSE0/1_CONTROL_0 */
+	uint v_pulse_ctrl;
+	/* _DISP_H_PULSE0/1_POSITION_A/B/C_0 */
+	uint v_pulse_pos[V_PULSE0_POSITION_COUNT];
+};
+
+struct _disp_v_pulse2 {
+	/* _DISP_H_PULSE2/3_CONTROL_0 */
+	uint v_pulse_ctrl;
+	/* _DISP_H_PULSE2/3_POSITION_A_0 */
+	uint v_pulse_pos_a;
+};
+
+enum dc_disp_h_pulse_reg {
+	H_PULSE0,
+	H_PULSE1,
+	H_PULSE2,
+	H_PULSE_COUNT,
+};
+
+enum dc_disp_pp_select {
+	PP_SELECT_A,
+	PP_SELECT_B,
+	PP_SELECT_C,
+	PP_SELECT_D,
+	PP_SELECT_COUNT,
+};
+
+/* DISP register 0x400 ~ 0x4c1 */
+struct dc_disp_reg {
+	/* Address 0x400 ~ 0x40a */
+	uint disp_signal_opt0;		/* _DISP_DISP_SIGNAL_OPTIONS0_0 */
+	uint disp_signal_opt1;		/* _DISP_DISP_SIGNAL_OPTIONS1_0 */
+	uint disp_win_opt;		/* _DISP_DISP_WIN_OPTIONS_0 */
+	uint mem_high_pri;		/* _DISP_MEM_HIGH_PRIORITY_0 */
+	uint mem_high_pri_timer;	/* _DISP_MEM_HIGH_PRIORITY_TIMER_0 */
+	uint disp_timing_opt;		/* _DISP_DISP_TIMING_OPTIONS_0 */
+	uint ref_to_sync;		/* _DISP_REF_TO_SYNC_0 */
+	uint sync_width;		/* _DISP_SYNC_WIDTH_0 */
+	uint back_porch;		/* _DISP_BACK_PORCH_0 */
+	uint disp_active;		/* _DISP_DISP_ACTIVE_0 */
+	uint front_porch;		/* _DISP_FRONT_PORCH_0 */
+
+	/* Address 0x40b ~ 0x419: _DISP_H_PULSE0/1/2_  */
+	struct _disp_h_pulse h_pulse[H_PULSE_COUNT];
+
+	/* Address 0x41a ~ 0x421 */
+	struct _disp_v_pulse0 v_pulse0;	/* _DISP_V_PULSE0_ */
+	struct _disp_v_pulse0 v_pulse1;	/* _DISP_V_PULSE1_ */
+
+	/* Address 0x422 ~ 0x425 */
+	struct _disp_v_pulse2 v_pulse3;	/* _DISP_V_PULSE2_ */
+	struct _disp_v_pulse2 v_pulse4;	/* _DISP_V_PULSE3_ */
+
+	/* Address 0x426 ~ 0x429 */
+	uint m0_ctrl;			/* _DISP_M0_CONTROL_0 */
+	uint m1_ctrl;			/* _DISP_M1_CONTROL_0 */
+	uint di_ctrl;			/* _DISP_DI_CONTROL_0 */
+	uint pp_ctrl;			/* _DISP_PP_CONTROL_0 */
+
+	/* Address 0x42a ~ 0x42d: _DISP_PP_SELECT_A/B/C/D_0 */
+	uint pp_select[PP_SELECT_COUNT];
+
+	/* Address 0x42e ~ 0x435 */
+	uint disp_clk_ctrl;		/* _DISP_DISP_CLOCK_CONTROL_0 */
+	uint disp_interface_ctrl;	/* _DISP_DISP_INTERFACE_CONTROL_0 */
+	uint disp_color_ctrl;		/* _DISP_DISP_COLOR_CONTROL_0 */
+	uint shift_clk_opt;		/* _DISP_SHIFT_CLOCK_OPTIONS_0 */
+	uint data_enable_opt;		/* _DISP_DATA_ENABLE_OPTIONS_0 */
+	uint serial_interface_opt;	/* _DISP_SERIAL_INTERFACE_OPTIONS_0 */
+	uint lcd_spi_opt;		/* _DISP_LCD_SPI_OPTIONS_0 */
+	uint border_color;		/* _DISP_BORDER_COLOR_0 */
+
+	/* Address 0x436 ~ 0x439 */
+	uint color_key0_lower;		/* _DISP_COLOR_KEY0_LOWER_0 */
+	uint color_key0_upper;		/* _DISP_COLOR_KEY0_UPPER_0 */
+	uint color_key1_lower;		/* _DISP_COLOR_KEY1_LOWER_0 */
+	uint color_key1_upper;		/* _DISP_COLOR_KEY1_UPPER_0 */
+
+	uint reserved0[2];		/* reserved_0[2] */
+
+	/* Address 0x43c ~ 0x442 */
+	uint cursor_foreground;		/* _DISP_CURSOR_FOREGROUND_0 */
+	uint cursor_background;		/* _DISP_CURSOR_BACKGROUND_0 */
+	uint cursor_start_addr;		/* _DISP_CURSOR_START_ADDR_0 */
+	uint cursor_start_addr_ns;	/* _DISP_CURSOR_START_ADDR_NS_0 */
+	uint cursor_pos;		/* _DISP_CURSOR_POSITION_0 */
+	uint cursor_pos_ns;		/* _DISP_CURSOR_POSITION_NS_0 */
+	uint seq_ctrl;			/* _DISP_INIT_SEQ_CONTROL_0 */
+
+	/* Address 0x442 ~ 0x446 */
+	uint spi_init_seq_data_a;	/* _DISP_SPI_INIT_SEQ_DATA_A_0 */
+	uint spi_init_seq_data_b;	/* _DISP_SPI_INIT_SEQ_DATA_B_0 */
+	uint spi_init_seq_data_c;	/* _DISP_SPI_INIT_SEQ_DATA_C_0 */
+	uint spi_init_seq_data_d;	/* _DISP_SPI_INIT_SEQ_DATA_D_0 */
+
+	uint reserved1[0x39];		/* reserved1[0x39], */
+
+	/* Address 0x480 ~ 0x484 */
+	uint dc_mccif_fifoctrl;		/* _DISP_DC_MCCIF_FIFOCTRL_0 */
+	uint mccif_disp0a_hyst;		/* _DISP_MCCIF_DISPLAY0A_HYST_0 */
+	uint mccif_disp0b_hyst;		/* _DISP_MCCIF_DISPLAY0B_HYST_0 */
+	uint mccif_disp0c_hyst;		/* _DISP_MCCIF_DISPLAY0C_HYST_0 */
+	uint mccif_disp1b_hyst;		/* _DISP_MCCIF_DISPLAY1B_HYST_0 */
+
+	uint reserved2[0x3b];		/* reserved2[0x3b] */
+
+	/* Address 0x4c0 ~ 0x4c1 */
+	uint dac_crt_ctrl;		/* _DISP_DAC_CRT_CTRL_0 */
+	uint disp_misc_ctrl;		/* _DISP_DISP_MISC_CONTROL_0 */
+};
+
+enum dc_winc_filter_p {
+	WINC_FILTER_COUNT	= 0x10,
+};
+
+/* Window A/B/C register 0x500 ~ 0x628 */
+struct dc_winc_reg {
+
+	/* Address 0x500 */
+	uint color_palette;		/* _WINC_COLOR_PALETTE_0 */
+
+	uint reserved0[0xff];		/* reserved_0[0xff] */
+
+	/* Address 0x600 */
+	uint palette_color_ext;		/* _WINC_PALETTE_COLOR_EXT_0 */
+
+	/* _WINC_H_FILTER_P00~0F_0 */
+	/* Address 0x601 ~ 0x610 */
+	uint h_filter_p[WINC_FILTER_COUNT];
+
+	/* Address 0x611 ~ 0x618 */
+	uint csc_yof;			/* _WINC_CSC_YOF_0 */
+	uint csc_kyrgb;			/* _WINC_CSC_KYRGB_0 */
+	uint csc_kur;			/* _WINC_CSC_KUR_0 */
+	uint csc_kvr;			/* _WINC_CSC_KVR_0 */
+	uint csc_kug;			/* _WINC_CSC_KUG_0 */
+	uint csc_kvg;			/* _WINC_CSC_KVG_0 */
+	uint csc_kub;			/* _WINC_CSC_KUB_0 */
+	uint csc_kvb;			/* _WINC_CSC_KVB_0 */
+
+	/* Address 0x619 ~ 0x628: _WINC_V_FILTER_P00~0F_0 */
+	uint v_filter_p[WINC_FILTER_COUNT];
+};
+
+/* WIN A/B/C Register 0x700 ~ 0x714*/
+struct dc_win_reg {
+	/* Address 0x700 ~ 0x714 */
+	uint win_opt;			/* _WIN_WIN_OPTIONS_0 */
+	uint byte_swap;			/* _WIN_BYTE_SWAP_0 */
+	uint buffer_ctrl;		/* _WIN_BUFFER_CONTROL_0 */
+	uint color_depth;		/* _WIN_COLOR_DEPTH_0 */
+	uint pos;			/* _WIN_POSITION_0 */
+	uint size;			/* _WIN_SIZE_0 */
+	uint prescaled_size;		/* _WIN_PRESCALED_SIZE_0 */
+	uint h_initial_dda;		/* _WIN_H_INITIAL_DDA_0 */
+	uint v_initial_dda;		/* _WIN_V_INITIAL_DDA_0 */
+	uint dda_increment;		/* _WIN_DDA_INCREMENT_0 */
+	uint line_stride;		/* _WIN_LINE_STRIDE_0 */
+	uint buf_stride;		/* _WIN_BUF_STRIDE_0 */
+	uint uv_buf_stride;		/* _WIN_UV_BUF_STRIDE_0 */
+	uint buffer_addr_mode;		/* _WIN_BUFFER_ADDR_MODE_0 */
+	uint dv_ctrl;			/* _WIN_DV_CONTROL_0 */
+	uint blend_nokey;		/* _WIN_BLEND_NOKEY_0 */
+	uint blend_1win;		/* _WIN_BLEND_1WIN_0 */
+	uint blend_2win_x;		/* _WIN_BLEND_2WIN_X_0 */
+	uint blend_2win_y;		/* _WIN_BLEND_2WIN_Y_0 */
+	uint blend_3win_xy;		/* _WIN_BLEND_3WIN_XY_0 */
+	uint hp_fetch_ctrl;		/* _WIN_HP_FETCH_CONTROL_0 */
+};
+
+/* WINBUF A/B/C Register 0x800 ~ 0x80a */
+struct dc_winbuf_reg {
+	/* Address 0x800 ~ 0x80a */
+	uint start_addr;		/* _WINBUF_START_ADDR_0 */
+	uint start_addr_ns;		/* _WINBUF_START_ADDR_NS_0 */
+	uint start_addr_u;		/* _WINBUF_START_ADDR_U_0 */
+	uint start_addr_u_ns;		/* _WINBUF_START_ADDR_U_NS_0 */
+	uint start_addr_v;		/* _WINBUF_START_ADDR_V_0 */
+	uint start_addr_v_ns;		/* _WINBUF_START_ADDR_V_NS_0 */
+	uint addr_h_offset;		/* _WINBUF_ADDR_H_OFFSET_0 */
+	uint addr_h_offset_ns;		/* _WINBUF_ADDR_H_OFFSET_NS_0 */
+	uint addr_v_offset;		/* _WINBUF_ADDR_V_OFFSET_0 */
+	uint addr_v_offset_ns;		/* _WINBUF_ADDR_V_OFFSET_NS_0 */
+	uint uflow_status;		/* _WINBUF_UFLOW_STATUS_0 */
+};
+
+/* Display Controller (DC_) regs */
+struct dc_ctlr {
+	struct dc_cmd_reg cmd;		/* CMD register 0x000 ~ 0x43 */
+	uint reserved0[0x2bc];
+
+	struct dc_com_reg com;		/* COM register 0x300 ~ 0x329 */
+	uint reserved1[0xd6];
+
+	struct dc_disp_reg disp;	/* DISP register 0x400 ~ 0x4c1 */
+	uint reserved2[0x3e];
+
+	struct dc_winc_reg winc;	/* Window A/B/C 0x500 ~ 0x628 */
+	uint reserved3[0xd7];
+
+	struct dc_win_reg win;		/* WIN A/B/C 0x700 ~ 0x714*/
+	uint reserved4[0xeb];
+
+	struct dc_winbuf_reg winbuf;	/* WINBUF A/B/C 0x800 ~ 0x80a */
+};
+
+#define BIT(pos)	(1U << pos)
+
+/* DC_CMD_DISPLAY_COMMAND 0x032 */
+#define CTRL_MODE_SHIFT		5
+#define CTRL_MODE_MASK		(0x3 << CTRL_MODE_SHIFT)
+enum {
+	CTRL_MODE_STOP,
+	CTRL_MODE_C_DISPLAY,
+	CTRL_MODE_NC_DISPLAY,
+};
+
+/* _WIN_COLOR_DEPTH_0 */
+enum win_color_depth_id {
+	COLOR_DEPTH_P1,
+	COLOR_DEPTH_P2,
+	COLOR_DEPTH_P4,
+	COLOR_DEPTH_P8,
+	COLOR_DEPTH_B4G4R4A4,
+	COLOR_DEPTH_B5G5R5A,
+	COLOR_DEPTH_B5G6R5,
+	COLOR_DEPTH_AB5G5R5,
+	COLOR_DEPTH_B8G8R8A8 = 12,
+	COLOR_DEPTH_R8G8B8A8,
+	COLOR_DEPTH_B6x2G6x2R6x2A8,
+	COLOR_DEPTH_R6x2G6x2B6x2A8,
+	COLOR_DEPTH_YCbCr422,
+	COLOR_DEPTH_YUV422,
+	COLOR_DEPTH_YCbCr420P,
+	COLOR_DEPTH_YUV420P,
+	COLOR_DEPTH_YCbCr422P,
+	COLOR_DEPTH_YUV422P,
+	COLOR_DEPTH_YCbCr422R,
+	COLOR_DEPTH_YUV422R,
+	COLOR_DEPTH_YCbCr422RA,
+	COLOR_DEPTH_YUV422RA,
+};
+
+/* DC_CMD_DISPLAY_POWER_CONTROL 0x036 */
+#define PW0_ENABLE		BIT(0)
+#define PW1_ENABLE		BIT(2)
+#define PW2_ENABLE		BIT(4)
+#define PW3_ENABLE		BIT(6)
+#define PW4_ENABLE		BIT(8)
+#define PM0_ENABLE		BIT(16)
+#define PM1_ENABLE		BIT(18)
+#define SPI_ENABLE		BIT(24)
+#define HSPI_ENABLE		BIT(25)
+
+/* DC_CMD_STATE_CONTROL 0x041 */
+#define GENERAL_ACT_REQ		BIT(0)
+#define WIN_A_ACT_REQ		BIT(1)
+#define WIN_B_ACT_REQ		BIT(2)
+#define WIN_C_ACT_REQ		BIT(3)
+#define GENERAL_UPDATE		BIT(8)
+#define WIN_A_UPDATE		BIT(9)
+#define WIN_B_UPDATE		BIT(10)
+#define WIN_C_UPDATE		BIT(11)
+
+/* DC_CMD_DISPLAY_WINDOW_HEADER 0x042 */
+#define WINDOW_A_SELECT		BIT(4)
+#define WINDOW_B_SELECT		BIT(5)
+#define WINDOW_C_SELECT		BIT(6)
+
+/* DC_DISP_DISP_CLOCK_CONTROL 0x42e */
+#define SHIFT_CLK_DIVIDER_SHIFT	0
+#define SHIFT_CLK_DIVIDER_MASK	(0xff << SHIFT_CLK_DIVIDER_SHIFT)
+#define	PIXEL_CLK_DIVIDER_SHIFT	8
+#define	PIXEL_CLK_DIVIDER_MSK	(0xf << PIXEL_CLK_DIVIDER_SHIFT)
+enum {
+	PIXEL_CLK_DIVIDER_PCD1,
+	PIXEL_CLK_DIVIDER_PCD1H,
+	PIXEL_CLK_DIVIDER_PCD2,
+	PIXEL_CLK_DIVIDER_PCD3,
+	PIXEL_CLK_DIVIDER_PCD4,
+	PIXEL_CLK_DIVIDER_PCD6,
+	PIXEL_CLK_DIVIDER_PCD8,
+	PIXEL_CLK_DIVIDER_PCD9,
+	PIXEL_CLK_DIVIDER_PCD12,
+	PIXEL_CLK_DIVIDER_PCD16,
+	PIXEL_CLK_DIVIDER_PCD18,
+	PIXEL_CLK_DIVIDER_PCD24,
+	PIXEL_CLK_DIVIDER_PCD13,
+};
+
+/* DC_DISP_DISP_INTERFACE_CONTROL 0x42f */
+#define DATA_FORMAT_SHIFT	0
+#define DATA_FORMAT_MASK	(0xf << DATA_FORMAT_SHIFT)
+enum {
+	DATA_FORMAT_DF1P1C,
+	DATA_FORMAT_DF1P2C24B,
+	DATA_FORMAT_DF1P2C18B,
+	DATA_FORMAT_DF1P2C16B,
+	DATA_FORMAT_DF2S,
+	DATA_FORMAT_DF3S,
+	DATA_FORMAT_DFSPI,
+	DATA_FORMAT_DF1P3C24B,
+	DATA_FORMAT_DF1P3C18B,
+};
+#define DATA_ALIGNMENT_SHIFT	8
+enum {
+	DATA_ALIGNMENT_MSB,
+	DATA_ALIGNMENT_LSB,
+};
+#define DATA_ORDER_SHIFT	9
+enum {
+	DATA_ORDER_RED_BLUE,
+	DATA_ORDER_BLUE_RED,
+};
+
+/* DC_DISP_DATA_ENABLE_OPTIONS 0x432 */
+#define DE_SELECT_SHIFT		0
+#define DE_SELECT_MASK		(0x3 << DE_SELECT_SHIFT)
+#define DE_SELECT_ACTIVE_BLANK	0x0
+#define DE_SELECT_ACTIVE	0x1
+#define DE_SELECT_ACTIVE_IS	0x2
+#define DE_CONTROL_SHIFT	2
+#define DE_CONTROL_MASK		(0x7 << DE_CONTROL_SHIFT)
+enum {
+	DE_CONTROL_ONECLK,
+	DE_CONTROL_NORMAL,
+	DE_CONTROL_EARLY_EXT,
+	DE_CONTROL_EARLY,
+	DE_CONTROL_ACTIVE_BLANK,
+};
+
+/* DC_WIN_WIN_OPTIONS 0x700 */
+#define H_DIRECTION		BIT(0)
+enum {
+	H_DIRECTION_INCREMENT,
+	H_DIRECTION_DECREMENT,
+};
+#define V_DIRECTION		BIT(2)
+enum {
+	V_DIRECTION_INCREMENT,
+	V_DIRECTION_DECREMENT,
+};
+#define COLOR_EXPAND		BIT(6)
+#define CP_ENABLE		BIT(16)
+#define DV_ENABLE		BIT(20)
+#define WIN_ENABLE		BIT(30)
+
+/* DC_WIN_BYTE_SWAP 0x701 */
+#define BYTE_SWAP_SHIFT		0
+enum {
+	BYTE_SWAP_NOSWAP,
+	BYTE_SWAP_SWAP2,
+	BYTE_SWAP_SWAP4,
+	BYTE_SWAP_SWAP4HW
+};
+
+/* DC_WIN_POSITION 0x704 */
+#define H_POSITION_SHIFT	0
+#define H_POSITION_MASK		(0x1FFF << H_POSITION_SHIFT)
+#define V_POSITION_SHIFT	16
+#define V_POSITION_MASK		(0x1FFF << V_POSITION_SHIFT)
+
+/* DC_WIN_SIZE 0x705 */
+#define H_SIZE_SHIFT		0
+#define H_SIZE_MASK		(0x1FFF << H_SIZE_SHIFT)
+#define V_SIZE_SHIFT		16
+#define V_SIZE_MASK		(0x1FFF << V_SIZE_SHIFT)
+
+/* DC_WIN_PRESCALED_SIZE 0x706 */
+#define H_PRESCALED_SIZE_SHIFT	0
+#define H_PRESCALED_SIZE_MASK	(0x7FFF << H_PRESCALED_SIZE)
+#define V_PRESCALED_SIZE_SHIFT	16
+#define V_PRESCALED_SIZE_MASK	(0x1FFF << V_PRESCALED_SIZE)
+
+/* DC_WIN_DDA_INCREMENT 0x709 */
+#define H_DDA_INC_SHIFT		0
+#define H_DDA_INC_MASK		(0xFFFF << H_DDA_INC_SHIFT)
+#define V_DDA_INC_SHIFT		16
+#define V_DDA_INC_MASK		(0xFFFF << V_DDA_INC_SHIFT)
+
+#endif /* __ASM_ARCH_TEGRA_DC_H */
diff --git a/arch/arm/include/asm/arch-tegra2/display.h b/arch/arm/include/asm/arch-tegra2/display.h
new file mode 100644
index 0000000..4f9f395
--- /dev/null
+++ b/arch/arm/include/asm/arch-tegra2/display.h
@@ -0,0 +1,133 @@
+/*
+ *  (C) Copyright 2010
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __ASM_ARCH_TEGRA_DISPLAY_H
+#define __ASM_ARCH_TEGRA_DISPLAY_H
+
+#include <asm/arch-tegra2/dc.h>
+#include <fdtdec.h>
+
+/* This holds information about a window which can be displayed */
+struct disp_ctl_win {
+	enum win_color_depth_id fmt;	/* Color depth/format */
+	unsigned	bpp;		/* Bits per pixel */
+	phys_addr_t	phys_addr;	/* Physical address in memory */
+	unsigned	x;		/* Horizontal address offset (bytes) */
+	unsigned	y;		/* Veritical address offset (bytes) */
+	unsigned	w;		/* Width of source window */
+	unsigned	h;		/* Height of source window */
+	unsigned	stride;		/* Number of bytes per line */
+	unsigned	out_x;		/* Left edge of output window (col) */
+	unsigned	out_y;		/* Top edge of output window (row) */
+	unsigned	out_w;		/* Width of output window in pixels */
+	unsigned	out_h;		/* Height of output window in pixels */
+};
+
+#define FDT_LCD_TIMINGS	4
+
+enum {
+	FDT_LCD_TIMING_REF_TO_SYNC,
+	FDT_LCD_TIMING_SYNC_WIDTH,
+	FDT_LCD_TIMING_BACK_PORCH,
+	FDT_LCD_TIMING_FRONT_PORCH,
+
+	FDT_LCD_TIMING_COUNT,
+};
+
+enum lcd_cache_t {
+	FDT_LCD_CACHE_OFF		= 0,
+	FDT_LCD_CACHE_WRITE_THROUGH	= 1 << 0,
+	FDT_LCD_CACHE_WRITE_BACK	= 1 << 1,
+	FDT_LCD_CACHE_FLUSH		= 1 << 2,
+	FDT_LCD_CACHE_WRITE_BACK_FLUSH	= FDT_LCD_CACHE_WRITE_BACK |
+						FDT_LCD_CACHE_FLUSH,
+};
+
+/* Information about the LCD */
+struct fdt_lcd {
+	int width;		/* width in pixels */
+	int height;		/* height in pixels */
+	int bpp;		/* number of bits per pixel */
+
+	/*
+	 * log2 of number of bpp, in general, unless it bpp is 24 in which
+	 * case this field holds 24 also! This is a U-Boot thing.
+	 */
+	int log2_bpp;
+	struct pwfm_ctlr *pwfm;		/* PWM to use for backlight */
+	struct disp_ctlr *disp;		/* Display controller to use */
+	fdt_addr_t frame_buffer;	/* Address of frame buffer */
+	unsigned pixel_clock;		/* Pixel clock in Hz */
+	uint horiz_timing[FDT_LCD_TIMING_COUNT];	/* Horizontal timing */
+	uint vert_timing[FDT_LCD_TIMING_COUNT];		/* Vertical timing */
+	enum lcd_cache_t cache_type;
+
+	struct fdt_gpio_state backlight_en;	/* GPIO for backlight enable */
+	struct fdt_gpio_state lvds_shutdown;	/* GPIO for lvds shutdown */
+	struct fdt_gpio_state backlight_vdd;	/* GPIO for backlight vdd */
+	struct fdt_gpio_state panel_vdd;	/* GPIO for panel vdd */
+	/*
+	 * Panel required timings
+	 * Timing 1: delay between panel_vdd-rise and data-rise
+	 * Timing 2: delay between data-rise and backlight_vdd-rise
+	 * Timing 3: delay between backlight_vdd and pwm-rise
+	 * Timing 4: delay between pwm-rise and backlight_en-rise
+	 */
+	uint panel_timings[FDT_LCD_TIMINGS];
+};
+
+/**
+ * Register a new display based on the given configuration
+ *
+ * @param config	Configuration to use
+ * @return 0 if ok, -1 on error (unsupported bits per pixel)
+ */
+int tegra2_display_register(struct fdt_lcd *config);
+
+/**
+ * Perform the next stage of the LCD init if it is time to do so.
+ *
+ * LCD init can be time-consuming because of the number of delays we need
+ * while waiting for the backlight power supply, etc. This function can
+ * be called@various times during U-Boot operation to advance the
+ * initialization of the LCD to the next stage if sufficient time has
+ * passed since the last stage. It keeps track of what stage it is up to
+ * and the time that it is permitted to move to the next stage.
+ *
+ * The final call should have wait=1 to complete the init.
+ *
+ * @param blob	fdt blob containing LCD information
+ * @param wait	1 to wait until all init is complete, and then return
+ *		0 to return immediately, potentially doing nothing if it is
+ *		not yet time for the next init.
+ */
+int tegra_lcd_check_next_stage(const void *blob, int wait);
+
+/*
+ * Set up the maximum LCD size so we can size the frame buffer.
+ *
+ * @param blob	fdt blob containing LCD information
+ */
+void tegra_lcd_early_init(const void *blob);
+
+#endif /*__ASM_ARCH_TEGRA_DISPLAY_H*/
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 08/17] tegra: Add LCD driver
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
                   ` (3 preceding siblings ...)
  2012-01-15  0:47 ` [U-Boot] [PATCH 07/17] tegra: Add SOC support for display/lcd Simon Glass
@ 2012-01-15  0:47 ` Simon Glass
  2012-01-15  0:47 ` [U-Boot] [PATCH 09/17] tegra: Add LCD support to Nvidia boards Simon Glass
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

This driver supports driving a single LCD and providing a U-Boot console
on it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 drivers/video/Makefile |    1 +
 drivers/video/tegra.c  |  379 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/fdtdec.h       |    1 +
 lib/fdtdec.c           |    1 +
 4 files changed, 382 insertions(+), 0 deletions(-)
 create mode 100644 drivers/video/tegra.c

diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 6252f6a..ff043a1 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -42,6 +42,7 @@ COBJS-$(CONFIG_VIDEO_OMAP3) += omap3_dss.o videomodes.o
 COBJS-$(CONFIG_VIDEO_SED13806) += sed13806.o
 COBJS-$(CONFIG_VIDEO_SM501) += sm501.o
 COBJS-$(CONFIG_VIDEO_SMI_LYNXEM) += smiLynxEM.o videomodes.o
+COBJS-$(CONFIG_VIDEO_TEGRA) += tegra.o
 COBJS-$(CONFIG_VIDEO_VCXK) += bus_vcxk.o
 
 COBJS	:= $(sort $(COBJS-y))
diff --git a/drivers/video/tegra.c b/drivers/video/tegra.c
new file mode 100644
index 0000000..7622d2d
--- /dev/null
+++ b/drivers/video/tegra.c
@@ -0,0 +1,379 @@
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <fdtdec.h>
+#include <lcd.h>
+
+#include <asm/system.h>
+#include <asm/gpio.h>
+
+#include <asm/arch/clock.h>
+#include <asm/arch/funcmux.h>
+#include <asm/arch/pinmux.h>
+#include <asm/arch/pwfm.h>
+#include <asm/arch/display.h>
+#include <asm/arch/timer.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* These are the stages we go throuh in enabling the LCD */
+enum stage_t {
+	STAGE_START,
+	STAGE_LVDS,
+	STAGE_BACKLIGHT_VDD,
+	STAGE_PWFM,
+	STAGE_BACKLIGHT_EN,
+	STAGE_DONE,
+};
+
+static enum stage_t stage;	/* Current stage we are at */
+static unsigned long timer_next; /* Time we can move onto next stage */
+static struct fdt_lcd config;	/* Our LCD config, set up in handle_stage() */
+
+enum {
+	/* Maximum LCD size we support */
+	LCD_MAX_WIDTH		= 1366,
+	LCD_MAX_HEIGHT		= 768,
+	LCD_MAX_LOG2_BPP	= 4,		/* 2^4 = 16 bpp */
+};
+
+int lcd_line_length;
+int lcd_color_fg;
+int lcd_color_bg;
+
+void *lcd_base;			/* Start of framebuffer memory	*/
+void *lcd_console_address;	/* Start of console buffer	*/
+
+short console_col;
+short console_row;
+
+vidinfo_t panel_info = {
+	/* Insert a value here so that we don't end up in the BSS */
+	.vl_col = -1,
+};
+
+char lcd_cursor_enabled;
+
+ushort lcd_cursor_width;
+ushort lcd_cursor_height;
+
+#ifndef CONFIG_OF_CONTROL
+#error "You must enable CONFIG_OF_CONTROL to get Tegra LCD support"
+#endif
+
+void lcd_cursor_size(ushort width, ushort height)
+{
+	lcd_cursor_width = width;
+	lcd_cursor_height = height;
+}
+
+void lcd_toggle_cursor(void)
+{
+	ushort x, y;
+	uchar *dest;
+	ushort row;
+
+	x = console_col * lcd_cursor_width;
+	y = console_row * lcd_cursor_height;
+	dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) /
+			8);
+
+	for (row = 0; row < lcd_cursor_height; ++row, dest += lcd_line_length) {
+		ushort *d = (ushort *)dest;
+		ushort color;
+		int i;
+
+		for (i = 0; i < lcd_cursor_width; ++i) {
+			color = *d;
+			color ^= lcd_color_fg;
+			*d = color;
+			++d;
+		}
+	}
+}
+
+void lcd_cursor_on(void)
+{
+	lcd_cursor_enabled = 1;
+	lcd_toggle_cursor();
+}
+void lcd_cursor_off(void)
+{
+	lcd_cursor_enabled = 0;
+	lcd_toggle_cursor();
+}
+
+char lcd_is_cursor_enabled(void)
+{
+	return lcd_cursor_enabled;
+}
+
+static void update_panel_size(struct fdt_lcd *config)
+{
+	panel_info.vl_col = config->width;
+	panel_info.vl_row = config->height;
+	panel_info.vl_bpix = config->log2_bpp;
+}
+
+/*
+ *  Main init function called by lcd driver.
+ *  Inits and then prints test pattern if required.
+ */
+
+void lcd_ctrl_init(void *lcdbase)
+{
+	int line_length, size;
+
+	/*
+	 * The framebuffer address should be specified in the device tree.
+	 * This FDT value should be the same as the one defined in Linux kernel;
+	 * otherwise, it causes screen flicker. The FDT value overrides the
+	 * framebuffer allocated at the top of memory by board_init_f().
+	 *
+	 * If the framebuffer address is not defined in the FDT, falls back to
+	 * use the address allocated by board_init_f().
+	 */
+	if (config.frame_buffer != FDT_ADDR_T_NONE) {
+		gd->fb_base = config.frame_buffer;
+		lcd_base = (void *)(gd->fb_base);
+	} else {
+		config.frame_buffer = (u32)lcd_base;
+	}
+
+	/* Make sure that we can acommodate the selected LCD */
+	assert(config.width <= LCD_MAX_WIDTH);
+	assert(config.height <= LCD_MAX_HEIGHT);
+	assert(config.log2_bpp <= LCD_MAX_LOG2_BPP);
+	if (config.width <= LCD_MAX_WIDTH && config.height <= LCD_MAX_HEIGHT &&
+			config.log2_bpp <= LCD_MAX_LOG2_BPP)
+		update_panel_size(&config);
+	size = lcd_get_size(&line_length);
+
+	/* Initialize the Tegra display controller */
+	if (tegra2_display_register(&config)) {
+		printf("%s: Failed to register with display driver\n",
+		       __func__);
+		return;
+	}
+
+	debug("LCD frame buffer@%p\n", lcd_base);
+}
+
+ulong calc_fbsize(void)
+{
+	return (panel_info.vl_col * panel_info.vl_row *
+		NBITS(panel_info.vl_bpix)) / 8;
+}
+
+void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
+{
+}
+
+void tegra_lcd_early_init(const void *blob)
+{
+	/*
+	 * Go with the maximum size for now. We will fix this up after
+	 * relocation. These values are only used for memory alocation.
+	 */
+	panel_info.vl_col = LCD_MAX_WIDTH;
+	panel_info.vl_row = LCD_MAX_HEIGHT;
+	panel_info.vl_bpix = LCD_MAX_LOG2_BPP;
+}
+
+int fdt_decode_lcd(const void *blob, struct fdt_lcd *config)
+{
+	int err, bpp, bit;
+	int lcd_node, display_node;
+
+	display_node = fdtdec_next_compatible(gd->fdt_blob, 0,
+				      COMPAT_NVIDIA_TEGRA20_DISPLAY);
+	if (display_node < 0)
+		return display_node;
+
+	lcd_node = fdt_next_node(blob, display_node, NULL);
+	if (lcd_node < 0)
+		return lcd_node;
+
+	config->width = fdtdec_get_int(blob, lcd_node, "width", -1);
+	config->height = fdtdec_get_int(blob, lcd_node, "height", -1);
+	bpp = fdtdec_get_int(blob, lcd_node, "bits-per-pixel", -1);
+	bit = ffs(bpp) - 1;
+	if (bpp == (1 << bit))
+		config->log2_bpp = bit;
+	else
+		config->log2_bpp = bpp;
+	config->bpp = bpp;
+	config->pixel_clock = fdtdec_get_int(blob, lcd_node, "pixel-clock", 0);
+	if (!config->pixel_clock || bpp == -1 ||
+			config->width == -1 || config->height == -1)
+		return -FDT_ERR_NOTFOUND;
+	err = fdtdec_get_int_array(blob, lcd_node, "horiz-timing",
+			config->horiz_timing, FDT_LCD_TIMING_COUNT);
+	if (!err)
+		err = fdtdec_get_int_array(blob, lcd_node, "vert-timing",
+				config->vert_timing, FDT_LCD_TIMING_COUNT);
+	if (err)
+		return err;
+
+	config->disp = (struct disp_ctlr *)fdtdec_get_addr(blob,
+						display_node, "reg");
+	config->pwfm = fdtdec_lookup_phandle_reg(blob, display_node, "pwfm");
+	if ((fdt_addr_t)config->disp == FDT_ADDR_T_NONE ||
+			(fdt_addr_t)config->pwfm == FDT_ADDR_T_NONE)
+		return -1;
+	config->cache_type = fdtdec_get_int(blob, display_node, "cache-type",
+			FDT_LCD_CACHE_WRITE_BACK_FLUSH);
+	config->frame_buffer = fdtdec_get_addr(blob, display_node,
+					       "frame-buffer");
+
+	err |= fdtdec_decode_gpio(blob, display_node, "backlight-enable-gpio",
+			   &config->backlight_en);
+	err |= fdtdec_decode_gpio(blob, display_node, "lvds-shutdown-gpio",
+			   &config->lvds_shutdown);
+	fdtdec_decode_gpio(blob, display_node, "backlight-vdd-gpio",
+			   &config->backlight_vdd);
+	err |= fdtdec_decode_gpio(blob, display_node, "panel-vdd-gpio",
+				  &config->panel_vdd);
+	if (err)
+		return -FDT_ERR_NOTFOUND;
+
+	return fdtdec_get_int_array(blob, display_node, "panel-timings",
+			config->panel_timings, FDT_LCD_TIMINGS);
+}
+
+/**
+ * Handle the next stage of device init
+ */
+static int handle_stage(const void *blob)
+{
+	debug("%s: stage %d\n", __func__, stage);
+
+	/* do the things for this stage */
+	switch (stage) {
+	case STAGE_START:
+		/* get panel details */
+		if (fdt_decode_lcd(blob, &config)) {
+			printf("No LCD information in device tree\n");
+			return -1;
+		}
+
+		/*
+		 * It is possible that the FDT has requested that the LCD be
+		 * disabled. We currently don't support this. It would require
+		 * changes to U-Boot LCD subsystem to have LCD support
+		 * compiled in but not used. An easier option might be to
+		 * still have a frame buffer, but leave the backlight off and
+		 * remove all mention of lcd in the stdout environment
+		 * variable.
+		 */
+
+		funcmux_select(PERIPH_ID_DISP1, FUNCMUX_DEFAULT);
+
+		fdtdec_setup_gpio(&config.panel_vdd);
+		fdtdec_setup_gpio(&config.lvds_shutdown);
+		fdtdec_setup_gpio(&config.backlight_vdd);
+		fdtdec_setup_gpio(&config.backlight_en);
+
+		/*
+		 * TODO: If fdt includes output flag we can omit this code
+		 * since fdtdec_setup_gpio will do it for us.
+		 */
+		gpio_direction_output(config.panel_vdd.gpio, 1);
+		gpio_direction_output(config.lvds_shutdown.gpio, 0);
+		gpio_direction_output(config.backlight_vdd.gpio, 0);
+		gpio_direction_output(config.backlight_en.gpio, 0);
+		break;
+
+	case STAGE_LVDS:
+		gpio_set_value(config.lvds_shutdown.gpio, 1);
+		break;
+
+	case STAGE_BACKLIGHT_VDD:
+		if (fdt_gpio_isvalid(&config.backlight_vdd))
+			gpio_set_value(config.backlight_vdd.gpio, 1);
+		break;
+
+	case STAGE_PWFM:
+		/* Enable PWM at 15/16 high, 32768 Hz with divider 1 */
+		pinmux_set_func(PINGRP_GPU, PMUX_FUNC_PWM);
+		pinmux_tristate_disable(PINGRP_GPU);
+		pwfm_enable(config.pwfm, 32768, 0xdf, 1);
+		break;
+
+	case STAGE_BACKLIGHT_EN:
+		gpio_set_value(config.backlight_en.gpio, 1);
+		break;
+
+	case STAGE_DONE:
+		break;
+	}
+
+	/* set up timer for next stage */
+	timer_next = timer_get_us() + config.panel_timings[stage] * 1000;
+
+	/* move to next stage */
+	stage++;
+	return 0;
+}
+
+int tegra_lcd_check_next_stage(const void *blob, int wait)
+{
+	if (stage == STAGE_DONE)
+		return 0;
+
+	do {
+		/* wait if we need to */
+		debug("%s: stage %d\n", __func__, stage);
+		if (stage != STAGE_START) {
+			int delay = timer_next - timer_get_us();
+
+			if (delay > 0) {
+				if (wait)
+					udelay(delay);
+				else
+					return 0;
+			}
+		}
+
+		if (handle_stage(blob))
+			return -1;
+	} while (wait && stage != STAGE_DONE);
+	return 0;
+}
+
+void lcd_enable(void)
+{
+	/*
+	 * Backlight and power init will be done separately in
+	 * tegra_lcd_check_next_stage(), which should be called in
+	 * board_late_init().
+	 *
+	 * U-Boot code supports only colour depth, selected at compile time.
+	 * The device tree setting should match this. Otherwise the display
+	 * will not look right, and U-Boot may crash.
+	 */
+	if (config.log2_bpp != LCD_BPP) {
+		printf("%s: Error: LCD depth configured in FDT (%d = %dbpp)"
+			" must match setting of LCD_BPP (%d)\n", __func__,
+		       config.log2_bpp, config.bpp, LCD_BPP);
+	}
+}
diff --git a/include/fdtdec.h b/include/fdtdec.h
index f60c969..d8bc80e 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -66,6 +66,7 @@ enum fdt_compat_id {
 	COMPAT_NVIDIA_TEGRA20_EMC_TABLE, /* Tegra2 memory timing table */
 	COMPAT_NVIDIA_TEGRA20_NAND,	/* Tegra2 NAND controller */
 	COMPAT_NVIDIA_TEGRA20_KBC,	/* Tegra2 Keyboard */
+	COMPAT_NVIDIA_TEGRA20_DISPLAY,	/* Tegra 2 Display controller */
 
 	COMPAT_COUNT,
 };
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index f7d0c95..82dcbbd 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -44,6 +44,7 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(NVIDIA_TEGRA20_EMC_TABLE, "nvidia,tegra20-emc-table"),
 	COMPAT(NVIDIA_TEGRA20_NAND, "nvidia,tegra20-nand"),
 	COMPAT(NVIDIA_TEGRA20_KBC, "nvidia,tegra20-kbc"),
+	COMPAT(NVIDIA_TEGRA20_DISPLAY, "nvidia,tegra20-display"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 09/17] tegra: Add LCD support to Nvidia boards
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
                   ` (4 preceding siblings ...)
  2012-01-15  0:47 ` [U-Boot] [PATCH 08/17] tegra: Add LCD driver Simon Glass
@ 2012-01-15  0:47 ` Simon Glass
  2012-01-15  0:47 ` [U-Boot] [PATCH 10/17] arm: Add control over cachability of memory regions Simon Glass
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

Add calls to the LCD driver from Nvidia board code.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 board/nvidia/common/board.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c
index 04990bf..1c3387d 100644
--- a/board/nvidia/common/board.c
+++ b/board/nvidia/common/board.c
@@ -28,6 +28,7 @@
 #include <asm/arch/sys_proto.h>
 
 #include <asm/arch/board.h>
+#include <asm/arch/display.h>
 #include <asm/arch/clk_rst.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/emc.h>
@@ -78,6 +79,9 @@ static void power_det_init(void)
  */
 int board_init(void)
 {
+#ifdef CONFIG_VIDEO_TEGRA2
+	tegra_lcd_check_next_stage(gd->blob, 0);
+#endif
 	/* Do clocks and UART first so that printf() works */
 	clock_init();
 	clock_verify();
@@ -114,6 +118,9 @@ int board_init(void)
 
 	board_usb_init(gd->fdt_blob);
 #endif
+#if defined(CONFIG_VIDEO_TEGRA)
+	tegra_lcd_check_next_stage(gd->fdt_blob, 0);
+#endif
 
 #ifdef CONFIG_TEGRA2_LP0
 	/* prepare the WB code to LP0 location */
@@ -134,6 +141,18 @@ int board_early_init_f(void)
 #else
 	gpio_config_uart();
 #endif
-	return 0;
+#if defined(CONFIG_VIDEO_TEGRA)
+	tegra_lcd_early_init(gd->fdt_blob);
+#endif
+return 0;
 }
 #endif	/* EARLY_INIT */
+
+int board_late_init(void)
+{
+#ifdef CONFIG_VIDEO_TEGRA
+	/* Make sure we finish initing the LCD */
+	tegra_lcd_check_next_stage(gd->fdt_blob, 1);
+#endif
+	return 0;
+}
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 10/17] arm: Add control over cachability of memory regions
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
                   ` (5 preceding siblings ...)
  2012-01-15  0:47 ` [U-Boot] [PATCH 09/17] tegra: Add LCD support to Nvidia boards Simon Glass
@ 2012-01-15  0:47 ` Simon Glass
  2012-02-10 20:38   ` Albert ARIBAUD
  2012-01-15  0:47 ` [U-Boot] [PATCH 11/17] lcd: Add CONFIG_ALIGN_LCD_TO_SECTION to align lcd for MMU Simon Glass
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

Add support for adjusting the cachability of an L1 section by updating
the MMU. The mmu_set_region_dcache() function allows drivers to make
these changes after the MMU is set up.

It is implemented only for ARMv7 at present.

This is needed for LCD support, where we want to make the LCD frame buffer
write-through (or off) rather than write-back.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 arch/arm/cpu/armv7/cache_v7.c |   11 +++++++
 arch/arm/include/asm/system.h |   30 ++++++++++++++++++++
 arch/arm/lib/cache-cp15.c     |   62 +++++++++++++++++++++++++++++++++-------
 3 files changed, 92 insertions(+), 11 deletions(-)

diff --git a/arch/arm/cpu/armv7/cache_v7.c b/arch/arm/cpu/armv7/cache_v7.c
index 1b4e808..5f6d039 100644
--- a/arch/arm/cpu/armv7/cache_v7.c
+++ b/arch/arm/cpu/armv7/cache_v7.c
@@ -297,6 +297,12 @@ void arm_init_before_mmu(void)
 	v7_inval_tlb();
 }
 
+void mmu_page_table_flush(unsigned long start, unsigned long stop)
+{
+	flush_dcache_range(start, stop);
+	v7_inval_tlb();
+}
+
 /*
  * Flush range from all levels of d-cache/unified-cache used:
  * Affects the range [start, start + size - 1]
@@ -329,6 +335,11 @@ void arm_init_before_mmu(void)
 void  flush_cache(unsigned long start, unsigned long size)
 {
 }
+
+void mmu_page_table_flush(unsigned long start, unsigned long stop)
+{
+}
+
 #endif /* #ifndef CONFIG_SYS_DCACHE_OFF */
 
 #ifndef CONFIG_SYS_ICACHE_OFF
diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 2b28a26..f52a4fc 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -75,6 +75,36 @@ static inline void set_cr(unsigned int val)
 	isb();
 }
 
+/* options available for data cache on each page */
+enum dcache_option {
+	DCACHE_OFF,
+	DCACHE_WRITETHROUGH,
+	DCACHE_WRITEBACK,
+};
+
+/* Size of an MMU section */
+enum {
+	MMU_SECTION_SHIFT	= 20,
+	MMU_SECTION_SIZE	= 1 << MMU_SECTION_SHIFT,
+};
+
+/**
+ * Change the cache settings for a region.
+ *
+ * \param start		start address of memory region to change
+ * \param size		size of memory region to change
+ * \param option	dcache option to select
+ */
+void mmu_set_region_dcache(u32 start, int size, enum dcache_option option);
+
+/**
+ * Register an update to the page tables, and flush the TLB
+ *
+ * \param start		start address of update in page table
+ * \param stop		stop address of update in page table
+ */
+void mmu_page_table_flush(unsigned long start, unsigned long stop);
+
 #endif /* __ASSEMBLY__ */
 
 #define arch_align_stack(x) (x)
diff --git a/arch/arm/lib/cache-cp15.c b/arch/arm/lib/cache-cp15.c
index e6c3eae..facb1a7 100644
--- a/arch/arm/lib/cache-cp15.c
+++ b/arch/arm/lib/cache-cp15.c
@@ -26,12 +26,6 @@
 
 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
 
-#if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH)
-#define CACHE_SETUP	0x1a
-#else
-#define CACHE_SETUP	0x1e
-#endif
-
 DECLARE_GLOBAL_DATA_PTR;
 
 void __arm_init_before_mmu(void)
@@ -50,9 +44,52 @@ static void cp_delay (void)
 	asm volatile("" : : : "memory");
 }
 
-static inline void dram_bank_mmu_setup(int bank)
+void set_section_dcache(int section, enum dcache_option option)
 {
+	u32 value = section << MMU_SECTION_SHIFT | (3 << 10);
 	u32 *page_table = (u32 *)gd->tlb_addr;
+
+	switch (option) {
+	case DCACHE_WRITETHROUGH:
+		value |= 0x1a;
+		break;
+
+	case DCACHE_WRITEBACK:
+		value |= 0x1e;
+		break;
+
+	case DCACHE_OFF:
+		value |= 0x12;
+		break;
+	}
+
+	page_table[section] = value;
+}
+
+void __mmu_page_table_flush(unsigned long start, unsigned long stop)
+{
+	debug("%s: Warning: not implemented\n", __func__);
+}
+
+void mmu_page_table_flush(unsigned long start, unsigned long stop)
+	__attribute__((weak, alias("__mmu_page_table_flush")));
+
+void mmu_set_region_dcache(u32 start, int size, enum dcache_option option)
+{
+	u32 *page_table = (u32 *)gd->tlb_addr;
+	u32 upto, end;
+
+	end = ALIGN(start + size, MMU_SECTION_SIZE) >> MMU_SECTION_SHIFT;
+	start = start >> MMU_SECTION_SHIFT;
+	debug("mmu_set_region_dcache start=%x, size=%x, option=%d\n",
+	      start, size, option);
+	for (upto = start; upto < end; upto++)
+		set_section_dcache(upto, option);
+	mmu_page_table_flush((u32)&page_table[start], (u32)&page_table[end]);
+}
+
+static inline void dram_bank_mmu_setup(int bank)
+{
 	bd_t *bd = gd->bd;
 	int	i;
 
@@ -60,21 +97,24 @@ static inline void dram_bank_mmu_setup(int bank)
 	for (i = bd->bi_dram[bank].start >> 20;
 	     i < (bd->bi_dram[bank].start + bd->bi_dram[bank].size) >> 20;
 	     i++) {
-		page_table[i] = i << 20 | (3 << 10) | CACHE_SETUP;
+#if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH)
+		set_section_dcache(i, DCACHE_WRITETHROUGH);
+#else
+		set_section_dcache(i, DCACHE_WRITEBACK);
+#endif
 	}
 }
 
 /* to activate the MMU we need to set up virtual memory: use 1M areas */
 static inline void mmu_setup(void)
 {
-	u32 *page_table = (u32 *)gd->tlb_addr;
 	int i;
 	u32 reg;
 
 	arm_init_before_mmu();
 	/* Set up an identity-mapping for all 4GB, rw for everyone */
 	for (i = 0; i < 4096; i++)
-		page_table[i] = i << 20 | (3 << 10) | 0x12;
+		set_section_dcache(i, DCACHE_OFF);
 
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
 		dram_bank_mmu_setup(i);
@@ -82,7 +122,7 @@ static inline void mmu_setup(void)
 
 	/* Copy the page table address to cp15 */
 	asm volatile("mcr p15, 0, %0, c2, c0, 0"
-		     : : "r" (page_table) : "memory");
+		     : : "r" (gd->tlb_addr) : "memory");
 	/* Set the access control to all-supervisor */
 	asm volatile("mcr p15, 0, %0, c3, c0, 0"
 		     : : "r" (~0));
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 11/17] lcd: Add CONFIG_ALIGN_LCD_TO_SECTION to align lcd for MMU
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
                   ` (6 preceding siblings ...)
  2012-01-15  0:47 ` [U-Boot] [PATCH 10/17] arm: Add control over cachability of memory regions Simon Glass
@ 2012-01-15  0:47 ` Simon Glass
  2012-01-15  1:38   ` Mike Frysinger
  2012-01-15  0:47 ` [U-Boot] [PATCH 12/17] lcd: Add support for flushing LCD fb from dcache after update Simon Glass
                   ` (5 subsequent siblings)
  13 siblings, 1 reply; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

We want to make the display section-aligned on ARM so that we can easily
turn off data caching for this.

Is this useful for other architectures? We could perhaps generalise it by
adding the ability to specify the alignment size, but at least for ARM
it is easier to have it be an architecture feature set by the MMU's
system.h header.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 README        |   10 ++++++++++
 common/lcd.c  |   25 ++++++++++++++++++++-----
 include/lcd.h |    3 +++
 3 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/README b/README
index 7adf7c7..d0b891f 100644
--- a/README
+++ b/README
@@ -1380,6 +1380,16 @@ The following options need to be configured:
 		Normally display is black on white background; define
 		CONFIG_SYS_WHITE_ON_BLACK to get it inverted.
 
+
+		CONFIG_ALIGN_LCD_TO_SECTION
+
+		Normally the LCD is page-aligned (tyically 4KB). If this is
+		defined then the LCD will be aligned to MMU_SECTION_SIZE
+		instead. This is useful for architectures where it is cheaper
+		to change data cache settings on a per-section basis (such as
+		ARM). Only enabled on ARM at present.
+
+
 - Splash Screen Support: CONFIG_SPLASH_SCREEN
 
 		If this option is set, the environment is checked for
diff --git a/common/lcd.c b/common/lcd.c
index bf1a6a9..be69d0d 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -35,6 +35,9 @@
 #include <stdarg.h>
 #include <linux/types.h>
 #include <stdio_dev.h>
+#ifdef CONFIG_ARM
+#include <asm/system.h>
+#endif
 #if defined(CONFIG_POST)
 #include <post.h>
 #endif
@@ -330,6 +333,12 @@ static void test_pattern (void)
 /* ** GENERIC Initialization Routines					*/
 /************************************************************************/
 
+int lcd_get_size(int *line_length)
+{
+	*line_length = (panel_info.vl_col * NBITS(panel_info.vl_bpix)) / 8;
+	return *line_length * panel_info.vl_row;
+}
+
 int drv_lcd_init (void)
 {
 	struct stdio_dev lcddev;
@@ -337,7 +346,7 @@ int drv_lcd_init (void)
 
 	lcd_base = (void *)(gd->fb_base);
 
-	lcd_line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
+	lcd_get_size(&lcd_line_length);
 
 	lcd_init (lcd_base);		/* LCD initialization */
 
@@ -449,15 +458,21 @@ static int lcd_init (void *lcdbase)
 ulong lcd_setmem (ulong addr)
 {
 	ulong size;
-	int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
+	int line_length;
 
 	debug ("LCD panel info: %d x %d, %d bit/pix\n",
 		panel_info.vl_col, panel_info.vl_row, NBITS (panel_info.vl_bpix) );
 
-	size = line_length * panel_info.vl_row;
+	size = lcd_get_size(&line_length);
 
-	/* Round up to nearest full page */
-	size = (size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
+	/* Round up to nearest full page, or MMU section if defined */
+#ifdef CONFIG_ALIGN_LCD_TO_SECTION
+	size = ALIGN(size, MMU_SECTION_SIZE);
+	addr = ALIGN(addr - MMU_SECTION_SIZE + 1, MMU_SECTION_SIZE);
+#else
+	size = ALIGN(size, PAGE_SIZE);
+	addr = ALIGN(addr - PAGE_SIZE + 1, PAGE_SIZE);
+#endif
 
 	/* Allocate pages for the frame buffer. */
 	addr -= size;
diff --git a/include/lcd.h b/include/lcd.h
index d95feeb..148bb54 100644
--- a/include/lcd.h
+++ b/include/lcd.h
@@ -217,6 +217,9 @@ int	lcd_display_bitmap(ulong bmp_image, int x, int y);
 /* Allow boards to customize the information displayed */
 void lcd_show_board_info(void);
 
+/* Return the size of the LCD frame buffer, and the line length */
+int lcd_get_size(int *line_length);
+
 /************************************************************************/
 /* ** BITMAP DISPLAY SUPPORT						*/
 /************************************************************************/
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 12/17] lcd: Add support for flushing LCD fb from dcache after update
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
                   ` (7 preceding siblings ...)
  2012-01-15  0:47 ` [U-Boot] [PATCH 11/17] lcd: Add CONFIG_ALIGN_LCD_TO_SECTION to align lcd for MMU Simon Glass
@ 2012-01-15  0:47 ` Simon Glass
  2012-01-15  1:42   ` Mike Frysinger
  2012-01-15  0:47 ` [U-Boot] [PATCH 13/17] tegra: Align LCD frame buffer to section boundary Simon Glass
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

This provides an option for the LCD to flush the dcache after each update
(puts, scroll or clear).

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 common/cmd_echo.c |    3 ++-
 common/lcd.c      |   44 +++++++++++++++++++++++++++++++++++++-------
 include/lcd.h     |    8 ++++++++
 3 files changed, 47 insertions(+), 8 deletions(-)

diff --git a/common/cmd_echo.c b/common/cmd_echo.c
index 43a6da5..12efbab 100644
--- a/common/cmd_echo.c
+++ b/common/cmd_echo.c
@@ -44,8 +44,9 @@ int do_echo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		}
 	}
 
+	/* Use puts() so that the LCD sees it as a new line */
 	if (putnl)
-		putc('\n');
+		puts("\n");
 
 	return 0;
 }
diff --git a/common/lcd.c b/common/lcd.c
index be69d0d..707f785 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -93,6 +93,9 @@ static void lcd_setbgcolor (int color);
 
 char lcd_is_enabled = 0;
 
+static char lcd_flush_dcache;	/* 1 to flush dcache after each lcd update */
+
+
 #ifdef	NOT_USED_SO_FAR
 static void lcd_getcolreg (ushort regno,
 				ushort *red, ushort *green, ushort *blue);
@@ -101,6 +104,28 @@ static int lcd_getfgcolor (void);
 
 /************************************************************************/
 
+/* Flush LCD activity to the caches */
+void lcd_sync(void)
+{
+	/*
+	 * flush_dcache_range() is declared in common.h but it seems that some
+	 * architectures do not actually implement it. Is there a way to find
+	 * out whether it exists? For now, ARM is safe.
+	 */
+#ifdef CONFIG_ARM
+	int line_length;
+
+	if (lcd_flush_dcache)
+		flush_dcache_range((u32)lcd_base,
+			(u32)(lcd_base + lcd_get_size(&line_length)));
+#endif
+}
+
+void lcd_set_flush_dcache(int flush)
+{
+	lcd_flush_dcache = (flush != 0);
+}
+
 /*----------------------------------------------------------------------*/
 
 static void console_scrollup (void)
@@ -110,6 +135,7 @@ static void console_scrollup (void)
 
 	/* Clear the last one */
 	memset (CONSOLE_ROW_LAST, COLOR_MASK(lcd_color_bg), CONSOLE_ROW_SIZE);
+	lcd_sync();
 }
 
 /*----------------------------------------------------------------------*/
@@ -194,6 +220,7 @@ void lcd_puts (const char *s)
 	while (*s) {
 		lcd_putc (*s++);
 	}
+	lcd_sync();
 }
 
 /*----------------------------------------------------------------------*/
@@ -365,13 +392,6 @@ int drv_lcd_init (void)
 }
 
 /*----------------------------------------------------------------------*/
-static
-int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
-{
-	lcd_clear();
-	return 0;
-}
-
 void lcd_clear(void)
 {
 #if LCD_BPP == LCD_MONOCHROME
@@ -413,6 +433,14 @@ void lcd_clear(void)
 
 	console_col = 0;
 	console_row = 0;
+	lcd_sync();
+}
+
+static int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc,
+			char *const argv[])
+{
+	lcd_clear();
+	return 0;
 }
 
 U_BOOT_CMD(
@@ -612,6 +640,7 @@ void bitmap_plot (int x, int y)
 	}
 
 	WATCHDOG_RESET();
+	lcd_sync();
 }
 #endif /* CONFIG_LCD_LOGO */
 
@@ -810,6 +839,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
 		break;
 	};
 
+	lcd_sync();
 	return (0);
 }
 #endif
diff --git a/include/lcd.h b/include/lcd.h
index 148bb54..ab3e79d 100644
--- a/include/lcd.h
+++ b/include/lcd.h
@@ -56,6 +56,14 @@ extern void lcd_initcolregs (void);
 /* gunzip_bmp used if CONFIG_VIDEO_BMP_GZIP */
 extern struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp);
 
+/**
+ * Set whether we need to flush the dcache when changing the LCD image. This
+ * defaults to off.
+ *
+ * @param flush		non-zero to flush cache after update, 0 to skip
+ */
+void lcd_set_flush_dcache(int flush);
+
 #if defined CONFIG_MPC823
 /*
  * LCD controller stucture for MPC823 CPU
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 13/17] tegra: Align LCD frame buffer to section boundary
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
                   ` (8 preceding siblings ...)
  2012-01-15  0:47 ` [U-Boot] [PATCH 12/17] lcd: Add support for flushing LCD fb from dcache after update Simon Glass
@ 2012-01-15  0:47 ` Simon Glass
  2012-01-15  0:47 ` [U-Boot] [PATCH 14/17] tegra: Support control of cache settings for LCD Simon Glass
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

For tegra we want to enable the cache for the LCD. This is easier if
we can avoid using L2 page tages, so align the LCD to a section
boundary.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 include/configs/tegra2-common.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/configs/tegra2-common.h b/include/configs/tegra2-common.h
index 97ac6cd..ff4d90d 100644
--- a/include/configs/tegra2-common.h
+++ b/include/configs/tegra2-common.h
@@ -44,6 +44,7 @@
 #define CONFIG_SYS_CACHELINE_SIZE	32
 
 #define CONFIG_ARCH_CPU_INIT		/* Fire up the A9 core */
+#define CONFIG_ALIGN_LCD_TO_SECTION	/* Align LCD to 1MB boundary */
 
 #include <asm/arch/tegra2.h>		/* get chip and board defs */
 
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 14/17] tegra: Support control of cache settings for LCD
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
                   ` (9 preceding siblings ...)
  2012-01-15  0:47 ` [U-Boot] [PATCH 13/17] tegra: Align LCD frame buffer to section boundary Simon Glass
@ 2012-01-15  0:47 ` Simon Glass
  2012-01-15  0:47 ` [U-Boot] [PATCH 16/17] lcd: Add CONSOLE_SCROLL_LINES option to speed console Simon Glass
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

Add support for selecting the required cache mode for the LCD:
off, write-through or write-back.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 drivers/video/tegra.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/video/tegra.c b/drivers/video/tegra.c
index 7622d2d..f244cc1 100644
--- a/drivers/video/tegra.c
+++ b/drivers/video/tegra.c
@@ -175,6 +175,15 @@ void lcd_ctrl_init(void *lcdbase)
 		return;
 	}
 
+	/* For write-through or cache off, change the LCD memory region */
+	if (!(config.cache_type & FDT_LCD_CACHE_WRITE_BACK))
+		mmu_set_region_dcache(config.frame_buffer, size,
+			config.cache_type & FDT_LCD_CACHE_WRITE_THROUGH ?
+				DCACHE_WRITETHROUGH : DCACHE_OFF);
+
+	/* Enable flushing after LCD writes if requested */
+	lcd_set_flush_dcache(config.cache_type & FDT_LCD_CACHE_FLUSH);
+
 	debug("LCD frame buffer at %p\n", lcd_base);
 }
 
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH 15/17] tegra: fdt: Add LCD definitions for Seaboard
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
@ 2012-01-15  0:47     ` Simon Glass
       [not found] ` <1326588449-1794-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
                       ` (12 subsequent siblings)
  13 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Devicetree Discuss, Tom Warren, Jerry Van Baren

The Seaboard has a 1366x768 16bpp LCD. The backlight is controlled
by one of the PWMs.

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 board/nvidia/dts/tegra2-seaboard.dts |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/board/nvidia/dts/tegra2-seaboard.dts b/board/nvidia/dts/tegra2-seaboard.dts
index b847215..710b254 100644
--- a/board/nvidia/dts/tegra2-seaboard.dts
+++ b/board/nvidia/dts/tegra2-seaboard.dts
@@ -210,4 +210,25 @@
 				 00  00  00  11  00  00  00  00
 				 00  00  00  00  00  00  00  00];
 	};
+
+	display@0x54200000 {
+		pwfm = <&pwfm2>;
+		frame-buffer = <0x2f680000>;
+		backlight-enable-gpio = <&gpio 28 0>;		/* PD4 */
+		lvds-shutdown-gpio = <&gpio 10 0>;		/* PB2 */
+		backlight-vdd-gpio = <&gpio 176 0>;		/* PW0 */
+		panel-vdd-gpio = <&gpio 22 0>;			/* PC6 */
+		panel-timings = <4 203 17 15>;
+
+		lcd {
+			compatible = "generic,lcd";
+			width = <1366>;
+			height = <768>;
+			bits-per-pixel = <16>;
+			pixel-clock = <70600000>;
+
+			horiz-timing = <11 58 58 58>;
+			vert-timing = <1 4 4 4>;
+		};
+	};
 };
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 15/17] tegra: fdt: Add LCD definitions for Seaboard
@ 2012-01-15  0:47     ` Simon Glass
  0 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

The Seaboard has a 1366x768 16bpp LCD. The backlight is controlled
by one of the PWMs.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 board/nvidia/dts/tegra2-seaboard.dts |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/board/nvidia/dts/tegra2-seaboard.dts b/board/nvidia/dts/tegra2-seaboard.dts
index b847215..710b254 100644
--- a/board/nvidia/dts/tegra2-seaboard.dts
+++ b/board/nvidia/dts/tegra2-seaboard.dts
@@ -210,4 +210,25 @@
 				 00  00  00  11  00  00  00  00
 				 00  00  00  00  00  00  00  00];
 	};
+
+	display at 0x54200000 {
+		pwfm = <&pwfm2>;
+		frame-buffer = <0x2f680000>;
+		backlight-enable-gpio = <&gpio 28 0>;		/* PD4 */
+		lvds-shutdown-gpio = <&gpio 10 0>;		/* PB2 */
+		backlight-vdd-gpio = <&gpio 176 0>;		/* PW0 */
+		panel-vdd-gpio = <&gpio 22 0>;			/* PC6 */
+		panel-timings = <4 203 17 15>;
+
+		lcd {
+			compatible = "generic,lcd";
+			width = <1366>;
+			height = <768>;
+			bits-per-pixel = <16>;
+			pixel-clock = <70600000>;
+
+			horiz-timing = <11 58 58 58>;
+			vert-timing = <1 4 4 4>;
+		};
+	};
 };
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 16/17] lcd: Add CONSOLE_SCROLL_LINES option to speed console
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
                   ` (10 preceding siblings ...)
  2012-01-15  0:47 ` [U-Boot] [PATCH 14/17] tegra: Support control of cache settings for LCD Simon Glass
@ 2012-01-15  0:47 ` Simon Glass
  2012-01-15  0:47 ` [U-Boot] [PATCH 17/17] tegra: Enable display/lcd support on Seaboard Simon Glass
  2012-04-19 12:41 ` [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Christian Kroehnert
  13 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

When the cursor position gets to the end of the LCD console we normally
scroll by one line. This adds an option to increase that value.

Console scrolling is often slow, and if a large amount of output is
being sent, increasing this option to 10 or so will speed things up
considerably.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 README       |    6 ++++++
 common/lcd.c |   16 +++++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/README b/README
index d0b891f..c2f6699 100644
--- a/README
+++ b/README
@@ -1389,6 +1389,12 @@ The following options need to be configured:
 		to change data cache settings on a per-section basis (such as
 		ARM). Only enabled on ARM at present.
 
+		CONSOLE_SCROLL_LINES
+
+		When the console need to be scrolled, this is the number of
+		lines to scroll by. It defaults to 1. Increasing this makes
+		the console jump but can help speed up operation when scrolling
+		is slow.
 
 - Splash Screen Support: CONFIG_SPLASH_SCREEN
 
diff --git a/common/lcd.c b/common/lcd.c
index 707f785..b6da10e 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -130,12 +130,23 @@ void lcd_set_flush_dcache(int flush)
 
 static void console_scrollup (void)
 {
+	int rows = 1;
+
+#ifdef CONSOLE_SCROLL_LINES
+	rows = CONSOLE_SCROLL_LINES;
+#endif
 	/* Copy up rows ignoring the first one */
-	memcpy (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE);
+	memcpy(CONSOLE_ROW_FIRST,
+	       lcd_console_address + CONSOLE_ROW_SIZE * rows,
+	       CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows);
 
 	/* Clear the last one */
-	memset (CONSOLE_ROW_LAST, COLOR_MASK(lcd_color_bg), CONSOLE_ROW_SIZE);
+	memset(lcd_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows,
+		COLOR_MASK(lcd_color_bg),
+	       CONSOLE_ROW_SIZE * rows);
+
 	lcd_sync();
+	console_row -= rows;
 }
 
 /*----------------------------------------------------------------------*/
@@ -165,7 +176,6 @@ static inline void console_newline (void)
 	if (console_row >= CONSOLE_ROWS) {
 		/* Scroll everything up */
 		console_scrollup () ;
-		--console_row;
 	}
 }
 
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 17/17] tegra: Enable display/lcd support on Seaboard
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
                   ` (11 preceding siblings ...)
  2012-01-15  0:47 ` [U-Boot] [PATCH 16/17] lcd: Add CONSOLE_SCROLL_LINES option to speed console Simon Glass
@ 2012-01-15  0:47 ` Simon Glass
  2012-04-19 12:41 ` [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Christian Kroehnert
  13 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-01-15  0:47 UTC (permalink / raw)
  To: u-boot

From: Mayuresh Kulkarni <mkulkarni@nvidia.com>

Enable the Seaboard's 16bpp LCD and use it as the console.

Signed-off-by: Mayuresh Kulkarni <mkulkarni@nvidia.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
---
 include/configs/seaboard.h |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/configs/seaboard.h b/include/configs/seaboard.h
index fe60b38..09c4196 100644
--- a/include/configs/seaboard.h
+++ b/include/configs/seaboard.h
@@ -64,6 +64,7 @@
 #define CONFIG_SYS_BOARD_ODMDATA	0x300d8011 /* lp1, 1GB */
 
 #define CONFIG_BOARD_EARLY_INIT_F
+#define CONFIG_BOARD_LATE_INIT		/* Make sure LCD init is complete */
 
 /* SPI */
 #define CONFIG_TEGRA2_SPI
@@ -123,6 +124,13 @@
 
 #undef TEGRA2_DEVICE_SETTINGS
 #define TEGRA2_DEVICE_SETTINGS	"stdin=serial,tegra-kbc\0" \
-					"stdout=serial\0" \
-					"stderr=serial\0"
+					"stdout=serial,lcd\0" \
+					"stderr=serial,lcd\0"
+
+/* LCD support */
+#define CONFIG_LCD
+#define CONFIG_VIDEO_TEGRA
+#define LCD_BPP				LCD_COLOR16
+#define CONFIG_SYS_WHITE_ON_BLACK
+#define CONSOLE_SCROLL_LINES		10
 #endif /* __CONFIG_H */
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 04/17] tegra: Add display support to funcmux
  2012-01-15  0:47 ` [U-Boot] [PATCH 04/17] tegra: Add display support to funcmux Simon Glass
@ 2012-01-15  1:36   ` Mike Frysinger
  2012-06-13 12:15     ` Simon Glass
  0 siblings, 1 reply; 39+ messages in thread
From: Mike Frysinger @ 2012-01-15  1:36 UTC (permalink / raw)
  To: u-boot

On Saturday 14 January 2012 19:47:16 Simon Glass wrote:
> --- a/arch/arm/cpu/armv7/tegra2/funcmux.c
> +++ b/arch/arm/cpu/armv7/tegra2/funcmux.c
> 
> +struct pingroup_config disp1_default[] = {

const ?  although it looks like we need to fix pinmux_config_table() first ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120114/9219da05/attachment.pgp>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 11/17] lcd: Add CONFIG_ALIGN_LCD_TO_SECTION to align lcd for MMU
  2012-01-15  0:47 ` [U-Boot] [PATCH 11/17] lcd: Add CONFIG_ALIGN_LCD_TO_SECTION to align lcd for MMU Simon Glass
@ 2012-01-15  1:38   ` Mike Frysinger
  2012-06-13 12:23     ` Simon Glass
  0 siblings, 1 reply; 39+ messages in thread
From: Mike Frysinger @ 2012-01-15  1:38 UTC (permalink / raw)
  To: u-boot

On Saturday 14 January 2012 19:47:23 Simon Glass wrote:
> We want to make the display section-aligned on ARM so that we can easily
> turn off data caching for this.
> 
> Is this useful for other architectures? We could perhaps generalise it by
> adding the ability to specify the alignment size, but at least for ARM
> it is easier to have it be an architecture feature set by the MMU's
> system.h header.

seems like a generally useful thing, but the exact alignment is a bit hackish.  
so perhaps the CONFIG knob should instead be the size you want to align things 
to ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120114/68675d80/attachment.pgp>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 12/17] lcd: Add support for flushing LCD fb from dcache after update
  2012-01-15  0:47 ` [U-Boot] [PATCH 12/17] lcd: Add support for flushing LCD fb from dcache after update Simon Glass
@ 2012-01-15  1:42   ` Mike Frysinger
  2012-01-15  1:57     ` Simon Glass
  0 siblings, 1 reply; 39+ messages in thread
From: Mike Frysinger @ 2012-01-15  1:42 UTC (permalink / raw)
  To: u-boot

On Saturday 14 January 2012 19:47:24 Simon Glass wrote:
> --- a/common/cmd_echo.c
> +++ b/common/cmd_echo.c
> @@ -44,8 +44,9 @@ int do_echo(cmd_tbl_t *cmdtp, int flag, int argc, char *
> const argv[]) }
>  	}
> 
> +	/* Use puts() so that the LCD sees it as a new line */
>  	if (putnl)
> -		putc('\n');
> +		puts("\n");
> 
>  	return 0;
>  }

this sounds like a hack for a broken LCD core and so the fix should be 
somewhere in there

> --- a/common/lcd.c
> +++ b/common/lcd.c
> 
> +static char lcd_flush_dcache;

seems like it'd be better as a CONFIG knob

> +	/*
> +	 * flush_dcache_range() is declared in common.h but it seems that some
> +	 * architectures do not actually implement it. Is there a way to find
> +	 * out whether it exists? For now, ARM is safe.
> +	 */

if those arches don't implement this func, then the failure is on their head.  
people should feel free to use the cache api we expose in common.h.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120114/bf47057f/attachment.pgp>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 12/17] lcd: Add support for flushing LCD fb from dcache after update
  2012-01-15  1:42   ` Mike Frysinger
@ 2012-01-15  1:57     ` Simon Glass
  2012-01-15  2:16       ` Mike Frysinger
  0 siblings, 1 reply; 39+ messages in thread
From: Simon Glass @ 2012-01-15  1:57 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Sat, Jan 14, 2012 at 5:42 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Saturday 14 January 2012 19:47:24 Simon Glass wrote:
>> --- a/common/cmd_echo.c
>> +++ b/common/cmd_echo.c
>> @@ -44,8 +44,9 @@ int do_echo(cmd_tbl_t *cmdtp, int flag, int argc, char *
>> const argv[]) }
>> ? ? ? }
>>
>> + ? ? /* Use puts() so that the LCD sees it as a new line */
>> ? ? ? if (putnl)
>> - ? ? ? ? ? ? putc('\n');
>> + ? ? ? ? ? ? puts("\n");
>>
>> ? ? ? return 0;
>> ?}
>
> this sounds like a hack for a broken LCD core and so the fix should be
> somewhere in there

Well it's actually that I don't want to flush after every character
(it slows things down a lot) so puts is a good place to look. I
suppose we could flush after every newline we see in lcd_putc().

>
>> --- a/common/lcd.c
>> +++ b/common/lcd.c
>>
>> +static char lcd_flush_dcache;
>
> seems like it'd be better as a CONFIG knob

OK, will see if I can do that.

>
>> + ? ? /*
>> + ? ? ?* flush_dcache_range() is declared in common.h but it seems that some
>> + ? ? ?* architectures do not actually implement it. Is there a way to find
>> + ? ? ?* out whether it exists? For now, ARM is safe.
>> + ? ? ?*/
>
> if those arches don't implement this func, then the failure is on their head.
> people should feel free to use the cache api we expose in common.h.

I sort-of agree, except that I saw masses of failures. I will look a bit harder.

Regards,
Simon

> -mike

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 12/17] lcd: Add support for flushing LCD fb from dcache after update
  2012-01-15  1:57     ` Simon Glass
@ 2012-01-15  2:16       ` Mike Frysinger
  2012-06-13 12:25         ` Simon Glass
  0 siblings, 1 reply; 39+ messages in thread
From: Mike Frysinger @ 2012-01-15  2:16 UTC (permalink / raw)
  To: u-boot

On Saturday 14 January 2012 20:57:25 Simon Glass wrote:
> On Sat, Jan 14, 2012 at 5:42 PM, Mike Frysinger wrote:
> > On Saturday 14 January 2012 19:47:24 Simon Glass wrote:
> >> --- a/common/cmd_echo.c
> >> +++ b/common/cmd_echo.c
> >> @@ -44,8 +44,9 @@ int do_echo(cmd_tbl_t *cmdtp, int flag, int argc, char
> >> * const argv[]) }
> >>       }
> >> 
> >> +     /* Use puts() so that the LCD sees it as a new line */
> >>       if (putnl)
> >> -             putc('\n');
> >> +             puts("\n");
> >> 
> >>       return 0;
> >>  }
> > 
> > this sounds like a hack for a broken LCD core and so the fix should be
> > somewhere in there
> 
> Well it's actually that I don't want to flush after every character
> (it slows things down a lot)

right, but ...

> so puts is a good place to look

most puts() that i've seen are simple loops that call putc()

> I suppose we could flush after every newline we see in lcd_putc().

that would be the right way to go i think
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120114/f59220b9/attachment.pgp>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 10/17] arm: Add control over cachability of memory regions
  2012-01-15  0:47 ` [U-Boot] [PATCH 10/17] arm: Add control over cachability of memory regions Simon Glass
@ 2012-02-10 20:38   ` Albert ARIBAUD
  2012-03-04  6:20     ` Simon Glass
  0 siblings, 1 reply; 39+ messages in thread
From: Albert ARIBAUD @ 2012-02-10 20:38 UTC (permalink / raw)
  To: u-boot

Hi Simon,

Le 15/01/2012 01:47, Simon Glass a ?crit :
> Add support for adjusting the cachability of an L1 section by updating
> the MMU. The mmu_set_region_dcache() function allows drivers to make
> these changes after the MMU is set up.
>
> It is implemented only for ARMv7 at present.
>
> This is needed for LCD support, where we want to make the LCD frame buffer
> write-through (or off) rather than write-back.
>
> Signed-off-by: Simon Glass<sjg@chromium.org>
> ---
>   arch/arm/cpu/armv7/cache_v7.c |   11 +++++++
>   arch/arm/include/asm/system.h |   30 ++++++++++++++++++++
>   arch/arm/lib/cache-cp15.c     |   62 +++++++++++++++++++++++++++++++++-------
>   3 files changed, 92 insertions(+), 11 deletions(-)
>
> diff --git a/arch/arm/cpu/armv7/cache_v7.c b/arch/arm/cpu/armv7/cache_v7.c
> index 1b4e808..5f6d039 100644
> --- a/arch/arm/cpu/armv7/cache_v7.c
> +++ b/arch/arm/cpu/armv7/cache_v7.c
> @@ -297,6 +297,12 @@ void arm_init_before_mmu(void)
>   	v7_inval_tlb();
>   }
>
> +void mmu_page_table_flush(unsigned long start, unsigned long stop)
> +{
> +	flush_dcache_range(start, stop);
> +	v7_inval_tlb();

If that means "invalidate", then spell it out.

> +}
> +
>   /*
>    * Flush range from all levels of d-cache/unified-cache used:
>    * Affects the range [start, start + size - 1]
> @@ -329,6 +335,11 @@ void arm_init_before_mmu(void)
>   void  flush_cache(unsigned long start, unsigned long size)
>   {
>   }
> +
> +void mmu_page_table_flush(unsigned long start, unsigned long stop)
> +{
> +}
> +
>   #endif /* #ifndef CONFIG_SYS_DCACHE_OFF */
>
>   #ifndef CONFIG_SYS_ICACHE_OFF
> diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
> index 2b28a26..f52a4fc 100644
> --- a/arch/arm/include/asm/system.h
> +++ b/arch/arm/include/asm/system.h
> @@ -75,6 +75,36 @@ static inline void set_cr(unsigned int val)
>   	isb();
>   }
>
> +/* options available for data cache on each page */
> +enum dcache_option {
> +	DCACHE_OFF,
> +	DCACHE_WRITETHROUGH,
> +	DCACHE_WRITEBACK,
> +};
> +
> +/* Size of an MMU section */
> +enum {
> +	MMU_SECTION_SHIFT	= 20,
> +	MMU_SECTION_SIZE	= 1<<  MMU_SECTION_SHIFT,
> +};
> +
> +/**
> + * Change the cache settings for a region.
> + *
> + * \param start		start address of memory region to change
> + * \param size		size of memory region to change
> + * \param option	dcache option to select
> + */
> +void mmu_set_region_dcache(u32 start, int size, enum dcache_option option);
> +
> +/**
> + * Register an update to the page tables, and flush the TLB
> + *
> + * \param start		start address of update in page table
> + * \param stop		stop address of update in page table
> + */
> +void mmu_page_table_flush(unsigned long start, unsigned long stop);
> +
>   #endif /* __ASSEMBLY__ */
>
>   #define arch_align_stack(x) (x)
> diff --git a/arch/arm/lib/cache-cp15.c b/arch/arm/lib/cache-cp15.c
> index e6c3eae..facb1a7 100644
> --- a/arch/arm/lib/cache-cp15.c
> +++ b/arch/arm/lib/cache-cp15.c
> @@ -26,12 +26,6 @@
>
>   #if !(defined(CONFIG_SYS_ICACHE_OFF)&&  defined(CONFIG_SYS_DCACHE_OFF))
>
> -#if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH)
> -#define CACHE_SETUP	0x1a
> -#else
> -#define CACHE_SETUP	0x1e
> -#endif
> -
>   DECLARE_GLOBAL_DATA_PTR;
>
>   void __arm_init_before_mmu(void)
> @@ -50,9 +44,52 @@ static void cp_delay (void)
>   	asm volatile("" : : : "memory");
>   }
>
> -static inline void dram_bank_mmu_setup(int bank)
> +void set_section_dcache(int section, enum dcache_option option)
>   {
> +	u32 value = section<<  MMU_SECTION_SHIFT | (3<<  10);
>   	u32 *page_table = (u32 *)gd->tlb_addr;
> +
> +	switch (option) {
> +	case DCACHE_WRITETHROUGH:
> +		value |= 0x1a;
> +		break;
> +
> +	case DCACHE_WRITEBACK:
> +		value |= 0x1e;
> +		break;
> +
> +	case DCACHE_OFF:
> +		value |= 0x12;
> +		break;
> +	}
> +
> +	page_table[section] = value;
> +}
> +
> +void __mmu_page_table_flush(unsigned long start, unsigned long stop)
> +{
> +	debug("%s: Warning: not implemented\n", __func__);
> +}
> +
> +void mmu_page_table_flush(unsigned long start, unsigned long stop)
> +	__attribute__((weak, alias("__mmu_page_table_flush")));
> +
> +void mmu_set_region_dcache(u32 start, int size, enum dcache_option option)
> +{
> +	u32 *page_table = (u32 *)gd->tlb_addr;
> +	u32 upto, end;
> +
> +	end = ALIGN(start + size, MMU_SECTION_SIZE)>>  MMU_SECTION_SHIFT;
> +	start = start>>  MMU_SECTION_SHIFT;
> +	debug("mmu_set_region_dcache start=%x, size=%x, option=%d\n",
> +	      start, size, option);
> +	for (upto = start; upto<  end; upto++)
> +		set_section_dcache(upto, option);
> +	mmu_page_table_flush((u32)&page_table[start], (u32)&page_table[end]);
> +}
> +
> +static inline void dram_bank_mmu_setup(int bank)
> +{
>   	bd_t *bd = gd->bd;
>   	int	i;
>
> @@ -60,21 +97,24 @@ static inline void dram_bank_mmu_setup(int bank)
>   	for (i = bd->bi_dram[bank].start>>  20;
>   	     i<  (bd->bi_dram[bank].start + bd->bi_dram[bank].size)>>  20;
>   	     i++) {
> -		page_table[i] = i<<  20 | (3<<  10) | CACHE_SETUP;
> +#if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH)
> +		set_section_dcache(i, DCACHE_WRITETHROUGH);
> +#else
> +		set_section_dcache(i, DCACHE_WRITEBACK);
> +#endif
>   	}
>   }
>
>   /* to activate the MMU we need to set up virtual memory: use 1M areas */
>   static inline void mmu_setup(void)
>   {
> -	u32 *page_table = (u32 *)gd->tlb_addr;
>   	int i;
>   	u32 reg;
>
>   	arm_init_before_mmu();
>   	/* Set up an identity-mapping for all 4GB, rw for everyone */
>   	for (i = 0; i<  4096; i++)
> -		page_table[i] = i<<  20 | (3<<  10) | 0x12;

Maybe give names to some of the magic numbers here (and in other places 
where they appear).

> +		set_section_dcache(i, DCACHE_OFF);
>
>   	for (i = 0; i<  CONFIG_NR_DRAM_BANKS; i++) {
>   		dram_bank_mmu_setup(i);
> @@ -82,7 +122,7 @@ static inline void mmu_setup(void)
>
>   	/* Copy the page table address to cp15 */
>   	asm volatile("mcr p15, 0, %0, c2, c0, 0"
> -		     : : "r" (page_table) : "memory");
> +		     : : "r" (gd->tlb_addr) : "memory");
>   	/* Set the access control to all-supervisor */
>   	asm volatile("mcr p15, 0, %0, c3, c0, 0"
>   		     : : "r" (~0));

Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 10/17] arm: Add control over cachability of memory regions
  2012-02-10 20:38   ` Albert ARIBAUD
@ 2012-03-04  6:20     ` Simon Glass
  0 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-03-04  6:20 UTC (permalink / raw)
  To: u-boot

Hi Albert,

On Fri, Feb 10, 2012 at 12:38 PM, Albert ARIBAUD
<albert.u.boot@aribaud.net> wrote:
> Hi Simon,
>
> Le 15/01/2012 01:47, Simon Glass a ?crit :
>
>> Add support for adjusting the cachability of an L1 section by updating
>> the MMU. The mmu_set_region_dcache() function allows drivers to make
>> these changes after the MMU is set up.
>>
>> It is implemented only for ARMv7 at present.
>>
>> This is needed for LCD support, where we want to make the LCD frame buffer
>> write-through (or off) rather than write-back.
>>
>> Signed-off-by: Simon Glass<sjg@chromium.org>
>> ---
>> ?arch/arm/cpu/armv7/cache_v7.c | ? 11 +++++++
>> ?arch/arm/include/asm/system.h | ? 30 ++++++++++++++++++++
>> ?arch/arm/lib/cache-cp15.c ? ? | ? 62
>> +++++++++++++++++++++++++++++++++-------
>> ?3 files changed, 92 insertions(+), 11 deletions(-)
>>
>> diff --git a/arch/arm/cpu/armv7/cache_v7.c b/arch/arm/cpu/armv7/cache_v7.c
>> index 1b4e808..5f6d039 100644
>> --- a/arch/arm/cpu/armv7/cache_v7.c
>> +++ b/arch/arm/cpu/armv7/cache_v7.c
>> @@ -297,6 +297,12 @@ void arm_init_before_mmu(void)
>> ? ? ? ?v7_inval_tlb();
>> ?}
>>
>> +void mmu_page_table_flush(unsigned long start, unsigned long stop)
>> +{
>> + ? ? ? flush_dcache_range(start, stop);
>> + ? ? ? v7_inval_tlb();
>
>
> If that means "invalidate", then spell it out.

Are you asking for a patch to rename v7_inval_tlb()? That is an
existing function - I agree it is a bit cryptic.

>
>> +}
>> +
>> ?/*
>> ? * Flush range from all levels of d-cache/unified-cache used:
>> ? * Affects the range [start, start + size - 1]
>> @@ -329,6 +335,11 @@ void arm_init_before_mmu(void)
>> ?void ?flush_cache(unsigned long start, unsigned long size)
>> ?{
>> ?}
>> +
>> +void mmu_page_table_flush(unsigned long start, unsigned long stop)
>> +{
>> +}
>> +
>> ?#endif /* #ifndef CONFIG_SYS_DCACHE_OFF */
>>
>> ?#ifndef CONFIG_SYS_ICACHE_OFF
>> diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
>> index 2b28a26..f52a4fc 100644
>> --- a/arch/arm/include/asm/system.h
>> +++ b/arch/arm/include/asm/system.h
>> @@ -75,6 +75,36 @@ static inline void set_cr(unsigned int val)
>> ? ? ? ?isb();
>> ?}
>>
>> +/* options available for data cache on each page */
>> +enum dcache_option {
>> + ? ? ? DCACHE_OFF,
>> + ? ? ? DCACHE_WRITETHROUGH,
>> + ? ? ? DCACHE_WRITEBACK,
>> +};
>> +
>> +/* Size of an MMU section */
>> +enum {
>> + ? ? ? MMU_SECTION_SHIFT ? ? ? = 20,
>> + ? ? ? MMU_SECTION_SIZE ? ? ? ?= 1<< ?MMU_SECTION_SHIFT,
>> +};
>> +
>> +/**
>> + * Change the cache settings for a region.
>> + *
>> + * \param start ? ? ? ? ? ? ? ?start address of memory region to change
>> + * \param size ? ? ? ? size of memory region to change
>> + * \param option ? ? ? dcache option to select
>> + */
>> +void mmu_set_region_dcache(u32 start, int size, enum dcache_option
>> option);
>> +
>> +/**
>> + * Register an update to the page tables, and flush the TLB
>> + *
>> + * \param start ? ? ? ? ? ? ? ?start address of update in page table
>> + * \param stop ? ? ? ? stop address of update in page table
>> + */
>> +void mmu_page_table_flush(unsigned long start, unsigned long stop);
>> +
>> ?#endif /* __ASSEMBLY__ */
>>
>> ?#define arch_align_stack(x) (x)
>> diff --git a/arch/arm/lib/cache-cp15.c b/arch/arm/lib/cache-cp15.c
>> index e6c3eae..facb1a7 100644
>> --- a/arch/arm/lib/cache-cp15.c
>> +++ b/arch/arm/lib/cache-cp15.c
>> @@ -26,12 +26,6 @@
>>
>> ?#if !(defined(CONFIG_SYS_ICACHE_OFF)&& ?defined(CONFIG_SYS_DCACHE_OFF))
>>
>>
>> -#if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH)
>> -#define CACHE_SETUP ? ?0x1a
>> -#else
>> -#define CACHE_SETUP ? ?0x1e
>> -#endif
>> -
>> ?DECLARE_GLOBAL_DATA_PTR;
>>
>> ?void __arm_init_before_mmu(void)
>> @@ -50,9 +44,52 @@ static void cp_delay (void)
>> ? ? ? ?asm volatile("" : : : "memory");
>> ?}
>>
>> -static inline void dram_bank_mmu_setup(int bank)
>> +void set_section_dcache(int section, enum dcache_option option)
>> ?{
>> + ? ? ? u32 value = section<< ?MMU_SECTION_SHIFT | (3<< ?10);
>> ? ? ? ?u32 *page_table = (u32 *)gd->tlb_addr;
>> +
>> + ? ? ? switch (option) {
>> + ? ? ? case DCACHE_WRITETHROUGH:
>> + ? ? ? ? ? ? ? value |= 0x1a;
>> + ? ? ? ? ? ? ? break;
>> +
>> + ? ? ? case DCACHE_WRITEBACK:
>> + ? ? ? ? ? ? ? value |= 0x1e;
>> + ? ? ? ? ? ? ? break;
>> +
>> + ? ? ? case DCACHE_OFF:
>> + ? ? ? ? ? ? ? value |= 0x12;
>> + ? ? ? ? ? ? ? break;
>> + ? ? ? }
>> +
>> + ? ? ? page_table[section] = value;
>> +}
>> +
>> +void __mmu_page_table_flush(unsigned long start, unsigned long stop)
>> +{
>> + ? ? ? debug("%s: Warning: not implemented\n", __func__);
>> +}
>> +
>> +void mmu_page_table_flush(unsigned long start, unsigned long stop)
>> + ? ? ? __attribute__((weak, alias("__mmu_page_table_flush")));
>> +
>> +void mmu_set_region_dcache(u32 start, int size, enum dcache_option
>> option)
>> +{
>> + ? ? ? u32 *page_table = (u32 *)gd->tlb_addr;
>> + ? ? ? u32 upto, end;
>> +
>> + ? ? ? end = ALIGN(start + size, MMU_SECTION_SIZE)>> ?MMU_SECTION_SHIFT;
>> + ? ? ? start = start>> ?MMU_SECTION_SHIFT;
>> + ? ? ? debug("mmu_set_region_dcache start=%x, size=%x, option=%d\n",
>> + ? ? ? ? ? ? start, size, option);
>> + ? ? ? for (upto = start; upto< ?end; upto++)
>> + ? ? ? ? ? ? ? set_section_dcache(upto, option);
>> + ? ? ? mmu_page_table_flush((u32)&page_table[start],
>> (u32)&page_table[end]);
>> +}
>> +
>> +static inline void dram_bank_mmu_setup(int bank)
>> +{
>> ? ? ? ?bd_t *bd = gd->bd;
>> ? ? ? ?int ? ? i;
>>
>> @@ -60,21 +97,24 @@ static inline void dram_bank_mmu_setup(int bank)
>> ? ? ? ?for (i = bd->bi_dram[bank].start>> ?20;
>> ? ? ? ? ? ? i< ?(bd->bi_dram[bank].start + bd->bi_dram[bank].size)>> ?20;
>> ? ? ? ? ? ? i++) {
>> - ? ? ? ? ? ? ? page_table[i] = i<< ?20 | (3<< ?10) | CACHE_SETUP;
>> +#if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH)
>> + ? ? ? ? ? ? ? set_section_dcache(i, DCACHE_WRITETHROUGH);
>> +#else
>> + ? ? ? ? ? ? ? set_section_dcache(i, DCACHE_WRITEBACK);
>> +#endif
>> ? ? ? ?}
>> ?}
>>
>> ?/* to activate the MMU we need to set up virtual memory: use 1M areas */
>> ?static inline void mmu_setup(void)
>> ?{
>> - ? ? ? u32 *page_table = (u32 *)gd->tlb_addr;
>> ? ? ? ?int i;
>> ? ? ? ?u32 reg;
>>
>> ? ? ? ?arm_init_before_mmu();
>> ? ? ? ?/* Set up an identity-mapping for all 4GB, rw for everyone */
>> ? ? ? ?for (i = 0; i< ?4096; i++)
>> - ? ? ? ? ? ? ? page_table[i] = i<< ?20 | (3<< ?10) | 0x12;
>
>
> Maybe give names to some of the magic numbers here (and in other places
> where they appear).

OK - this line is actually being removed but I will add constants for
the values in set_section_dcache().

>
>
>> + ? ? ? ? ? ? ? set_section_dcache(i, DCACHE_OFF);
>>
>> ? ? ? ?for (i = 0; i< ?CONFIG_NR_DRAM_BANKS; i++) {
>> ? ? ? ? ? ? ? ?dram_bank_mmu_setup(i);
>> @@ -82,7 +122,7 @@ static inline void mmu_setup(void)
>>
>> ? ? ? ?/* Copy the page table address to cp15 */
>> ? ? ? ?asm volatile("mcr p15, 0, %0, c2, c0, 0"
>> - ? ? ? ? ? ? ? ? ? ?: : "r" (page_table) : "memory");
>> + ? ? ? ? ? ? ? ? ? ?: : "r" (gd->tlb_addr) : "memory");
>> ? ? ? ?/* Set the access control to all-supervisor */
>> ? ? ? ?asm volatile("mcr p15, 0, %0, c3, c0, 0"
>> ? ? ? ? ? ? ? ? ? ? : : "r" (~0));
>
>
> Amicalement,
> --
> Albert.

Regards,
Simon

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard
  2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
                   ` (12 preceding siblings ...)
  2012-01-15  0:47 ` [U-Boot] [PATCH 17/17] tegra: Enable display/lcd support on Seaboard Simon Glass
@ 2012-04-19 12:41 ` Christian Kroehnert
  2012-07-14  8:03   ` Simon Glass
  13 siblings, 1 reply; 39+ messages in thread
From: Christian Kroehnert @ 2012-04-19 12:41 UTC (permalink / raw)
  To: u-boot

On 15.01.2012 01:47, Simon Glass wrote:
> This series adds support for the Tegra2x's display peripheral. This
> supports the LCD display on Seaboard and we use this to enable console
> output in U-Boot on the LCD.
>
> Configuration is via the device tree. Proposed bindings are included
> in this series.
>
> To improve performance two optimisations are offered:
>
> 1. The LCD frame buffer is cached, with the cache being flushed after
> each call puts(). This dramatically increases performance (around 10x).
> This requires a few additions to the ARM cache support.
>
> 2. The console supports scrolling in steps of more than 1 line. This
> speeds up scrolling output considerably, particularly commands like
> 'printenv' which display a lot of output. This requires a new CONFIG
> and a change to the console_scrollup() function.
>
>
> Mayuresh Kulkarni (1):
>    tegra: Enable display/lcd support on Seaboard
>
> Simon Glass (15):
>    fdt: Add function to look up a phandle's register address
>    fdt: Add header guard to fdtdec.h
>    fdt: Correct GPIO name access in fdtdec
>    tegra: Add display support to funcmux
>    tegra: fdt: Add LCD definitions for Tegra
>    tegra: Add support for PWFM
>    tegra: Add LCD driver
>    tegra: Add LCD support to Nvidia boards
>    arm: Add control over cachability of memory regions
>    lcd: Add CONFIG_ALIGN_LCD_TO_SECTION to align lcd for MMU
>    lcd: Add support for flushing LCD fb from dcache after update
>    tegra: Align LCD frame buffer to section boundary
>    tegra: Support control of cache settings for LCD
>    tegra: fdt: Add LCD definitions for Seaboard
>    lcd: Add CONSOLE_SCROLL_LINES option to speed console
>
> Wei Ni (1):
>    tegra: Add SOC support for display/lcd
>
>   README                                          |   16 +
>   arch/arm/cpu/armv7/cache_v7.c                   |   11 +
>   arch/arm/cpu/armv7/tegra2/Makefile              |    1 +
>   arch/arm/cpu/armv7/tegra2/display.c             |  271 +++++++++++
>   arch/arm/cpu/armv7/tegra2/funcmux.c             |   39 ++
>   arch/arm/cpu/armv7/tegra2/pwfm.c                |   40 ++
>   arch/arm/dts/tegra20.dtsi                       |   25 +
>   arch/arm/include/asm/arch-tegra2/dc.h           |  544 +++++++++++++++++++++++
>   arch/arm/include/asm/arch-tegra2/display.h      |  133 ++++++
>   arch/arm/include/asm/arch-tegra2/pwfm.h         |   54 +++
>   arch/arm/include/asm/system.h                   |   30 ++
>   arch/arm/lib/cache-cp15.c                       |   62 +++-
>   board/nvidia/common/board.c                     |   21 +-
>   board/nvidia/dts/tegra2-seaboard.dts            |   21 +
>   common/cmd_echo.c                               |    3 +-
>   common/lcd.c                                    |   85 +++-
>   doc/device-tree-bindings/video/nvidia-video.txt |   92 ++++
>   drivers/video/Makefile                          |    1 +
>   drivers/video/tegra.c                           |  388 ++++++++++++++++
>   include/configs/seaboard.h                      |   12 +-
>   include/configs/tegra2-common.h                 |    1 +
>   include/fdtdec.h                                |   17 +
>   include/lcd.h                                   |   11 +
>   lib/fdtdec.c                                    |   15 +-
>   24 files changed, 1862 insertions(+), 31 deletions(-)
>   create mode 100644 arch/arm/cpu/armv7/tegra2/display.c
>   create mode 100644 arch/arm/cpu/armv7/tegra2/pwfm.c
>   create mode 100644 arch/arm/include/asm/arch-tegra2/dc.h
>   create mode 100644 arch/arm/include/asm/arch-tegra2/display.h
>   create mode 100644 arch/arm/include/asm/arch-tegra2/pwfm.h
>   create mode 100644 doc/device-tree-bindings/video/nvidia-video.txt
>   create mode 100644 drivers/video/tegra.c
>

Hi Simon,

I have added your patch sources manually into the "Prepare v2012.04-rc1 
release", because I got errors at apply. Also I added a device tree 
source file for Harmony.

I tested the device tree source file for Harmony and your patch sources 
on our Harmony hardware and generated a new patch file:

http://poeggi.dotsec.net/nvidia/uboot-lvds-init-patch/0001-Add-display-driver-and-LCD-support-for-Harmony-board.patch

I hope it's all okay, this my first patch release.

In the display.c source file I implemented a bug fix, because I get 
garbled images on the LCD without this fix.

Greetings
Christian

Changes:

- Add device tree source file for Harmony board
- Add bug fix in display.c
- Patch based on the "Prepare v2012.04-rc1" release

---
  README                                          |    7 +
  arch/arm/cpu/armv7/cache_v7.c                   |   11 +
  arch/arm/cpu/armv7/tegra2/Makefile              |    1 +
  arch/arm/cpu/armv7/tegra2/display.c             |  282 ++++++++++++
  arch/arm/cpu/armv7/tegra2/funcmux.c             |   41 ++
  arch/arm/cpu/armv7/tegra2/pwfm.c                |   45 ++
  arch/arm/dts/tegra20.dtsi                       |   26 ++
  arch/arm/include/asm/arch-tegra2/dc.h           |  544 
+++++++++++++++++++++++
  arch/arm/include/asm/arch-tegra2/display.h      |  133 ++++++
  arch/arm/include/asm/arch-tegra2/pwfm.h         |   54 +++
  arch/arm/include/asm/system.h                   |   30 ++
  arch/arm/lib/cache-cp15.c                       |   61 +++-
  board/nvidia/common/board.c                     |   20 +
  board/nvidia/dts/tegra2-harmony.dts             |   97 ++++
  board/nvidia/dts/tegra2-seaboard.dts            |   21 +
  common/cmd_echo.c                               |    2 +-
  common/lcd.c                                    |   86 +++-
  doc/device-tree-bindings/video/nvidia-video.txt |   92 ++++
  drivers/video/Makefile                          |    1 +
  drivers/video/tegra.c                           |  397 +++++++++++++++++
  dts/Makefile                                    |    2 +-
  include/configs/harmony.h                       |   39 ++-
  include/configs/tegra2-common.h                 |  218 +++++++++-
  include/fdtdec.h                                |   19 +-
  include/lcd.h                                   |   12 +
  lib/fdtdec.c                                    |   12 +
  26 files changed, 2206 insertions(+), 47 deletions(-)
  create mode 100644 arch/arm/cpu/armv7/tegra2/display.c
  create mode 100644 arch/arm/cpu/armv7/tegra2/pwfm.c
  create mode 100644 arch/arm/include/asm/arch-tegra2/dc.h
  create mode 100644 arch/arm/include/asm/arch-tegra2/display.h
  create mode 100644 arch/arm/include/asm/arch-tegra2/pwfm.h
  create mode 100644 board/nvidia/dts/tegra2-harmony.dts
  create mode 100644 doc/device-tree-bindings/video/nvidia-video.txt
  create mode 100644 drivers/video/tegra.c

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 04/17] tegra: Add display support to funcmux
  2012-01-15  1:36   ` Mike Frysinger
@ 2012-06-13 12:15     ` Simon Glass
  0 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-06-13 12:15 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Sat, Jan 14, 2012 at 5:36 PM, Mike Frysinger <vapier@gentoo.org> wrote:

> On Saturday 14 January 2012 19:47:16 Simon Glass wrote:
> > --- a/arch/arm/cpu/armv7/tegra2/funcmux.c
> > +++ b/arch/arm/cpu/armv7/tegra2/funcmux.c
> >
> > +struct pingroup_config disp1_default[] = {
>
> const ?  although it looks like we need to fix pinmux_config_table() first
> ...
> -mike
>

done

(With everything except NAND on Tegra in I am trying to get back to this
now.)

Regards,
Simon

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 11/17] lcd: Add CONFIG_ALIGN_LCD_TO_SECTION to align lcd for MMU
  2012-01-15  1:38   ` Mike Frysinger
@ 2012-06-13 12:23     ` Simon Glass
  0 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-06-13 12:23 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Sat, Jan 14, 2012 at 5:38 PM, Mike Frysinger <vapier@gentoo.org> wrote:

> On Saturday 14 January 2012 19:47:23 Simon Glass wrote:
> > We want to make the display section-aligned on ARM so that we can easily
> > turn off data caching for this.
> >
> > Is this useful for other architectures? We could perhaps generalise it by
> > adding the ability to specify the alignment size, but at least for ARM
> > it is easier to have it be an architecture feature set by the MMU's
> > system.h header.
>
> seems like a generally useful thing, but the exact alignment is a bit
> hackish.
> so perhaps the CONFIG knob should instead be the size you want to align
> things
> to ?
>

OK I will do that.


> -mike
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 12/17] lcd: Add support for flushing LCD fb from dcache after update
  2012-01-15  2:16       ` Mike Frysinger
@ 2012-06-13 12:25         ` Simon Glass
  0 siblings, 0 replies; 39+ messages in thread
From: Simon Glass @ 2012-06-13 12:25 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On Sat, Jan 14, 2012 at 6:16 PM, Mike Frysinger <vapier@gentoo.org> wrote:

> On Saturday 14 January 2012 20:57:25 Simon Glass wrote:
> > On Sat, Jan 14, 2012 at 5:42 PM, Mike Frysinger wrote:
> > > On Saturday 14 January 2012 19:47:24 Simon Glass wrote:
> > >> --- a/common/cmd_echo.c
> > >> +++ b/common/cmd_echo.c
> > >> @@ -44,8 +44,9 @@ int do_echo(cmd_tbl_t *cmdtp, int flag, int argc,
> char
> > >> * const argv[]) }
> > >>       }
> > >>
> > >> +     /* Use puts() so that the LCD sees it as a new line */
> > >>       if (putnl)
> > >> -             putc('\n');
> > >> +             puts("\n");
> > >>
> > >>       return 0;
> > >>  }
> > >
> > > this sounds like a hack for a broken LCD core and so the fix should be
> > > somewhere in there
> >
> > Well it's actually that I don't want to flush after every character
> > (it slows things down a lot)
>
> right, but ...
>
> > so puts is a good place to look
>
> most puts() that i've seen are simple loops that call putc()
>
> > I suppose we could flush after every newline we see in lcd_putc().
>
> that would be the right way to go i think
>

Yes indeed, will fix.


> -mike
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard
  2012-04-19 12:41 ` [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Christian Kroehnert
@ 2012-07-14  8:03   ` Simon Glass
  2012-07-17 16:11     ` Thierry Reding
  0 siblings, 1 reply; 39+ messages in thread
From: Simon Glass @ 2012-07-14  8:03 UTC (permalink / raw)
  To: u-boot

Hi Christian,

On Thu, Apr 19, 2012 at 2:41 PM, Christian Kroehnert
<christian.kroehnert@avionic-design.de> wrote:
> On 15.01.2012 01:47, Simon Glass wrote:
>>
>> This series adds support for the Tegra2x's display peripheral. This
>> supports the LCD display on Seaboard and we use this to enable console
>> output in U-Boot on the LCD.
>>
>> Configuration is via the device tree. Proposed bindings are included
>> in this series.
>>
>> To improve performance two optimisations are offered:
>>
>> 1. The LCD frame buffer is cached, with the cache being flushed after
>> each call puts(). This dramatically increases performance (around 10x).
>> This requires a few additions to the ARM cache support.
>>
>> 2. The console supports scrolling in steps of more than 1 line. This
>> speeds up scrolling output considerably, particularly commands like
>> 'printenv' which display a lot of output. This requires a new CONFIG
>> and a change to the console_scrollup() function.
>>
>>
>> Mayuresh Kulkarni (1):
>>    tegra: Enable display/lcd support on Seaboard
>>
>> Simon Glass (15):
>>    fdt: Add function to look up a phandle's register address
>>    fdt: Add header guard to fdtdec.h
>>    fdt: Correct GPIO name access in fdtdec
>>    tegra: Add display support to funcmux
>>    tegra: fdt: Add LCD definitions for Tegra
>>    tegra: Add support for PWFM
>>    tegra: Add LCD driver
>>    tegra: Add LCD support to Nvidia boards
>>    arm: Add control over cachability of memory regions
>>    lcd: Add CONFIG_ALIGN_LCD_TO_SECTION to align lcd for MMU
>>    lcd: Add support for flushing LCD fb from dcache after update
>>    tegra: Align LCD frame buffer to section boundary
>>    tegra: Support control of cache settings for LCD
>>    tegra: fdt: Add LCD definitions for Seaboard
>>    lcd: Add CONSOLE_SCROLL_LINES option to speed console
>>
>> Wei Ni (1):
>>    tegra: Add SOC support for display/lcd
>>
>>   README                                          |   16 +
>>   arch/arm/cpu/armv7/cache_v7.c                   |   11 +
>>   arch/arm/cpu/armv7/tegra2/Makefile              |    1 +
>>   arch/arm/cpu/armv7/tegra2/display.c             |  271 +++++++++++
>>   arch/arm/cpu/armv7/tegra2/funcmux.c             |   39 ++
>>   arch/arm/cpu/armv7/tegra2/pwfm.c                |   40 ++
>>   arch/arm/dts/tegra20.dtsi                       |   25 +
>>   arch/arm/include/asm/arch-tegra2/dc.h           |  544
>> +++++++++++++++++++++++
>>   arch/arm/include/asm/arch-tegra2/display.h      |  133 ++++++
>>   arch/arm/include/asm/arch-tegra2/pwfm.h         |   54 +++
>>   arch/arm/include/asm/system.h                   |   30 ++
>>   arch/arm/lib/cache-cp15.c                       |   62 +++-
>>   board/nvidia/common/board.c                     |   21 +-
>>   board/nvidia/dts/tegra2-seaboard.dts            |   21 +
>>   common/cmd_echo.c                               |    3 +-
>>   common/lcd.c                                    |   85 +++-
>>   doc/device-tree-bindings/video/nvidia-video.txt |   92 ++++
>>   drivers/video/Makefile                          |    1 +
>>   drivers/video/tegra.c                           |  388 ++++++++++++++++
>>   include/configs/seaboard.h                      |   12 +-
>>   include/configs/tegra2-common.h                 |    1 +
>>   include/fdtdec.h                                |   17 +
>>   include/lcd.h                                   |   11 +
>>   lib/fdtdec.c                                    |   15 +-
>>   24 files changed, 1862 insertions(+), 31 deletions(-)
>>   create mode 100644 arch/arm/cpu/armv7/tegra2/display.c
>>   create mode 100644 arch/arm/cpu/armv7/tegra2/pwfm.c
>>   create mode 100644 arch/arm/include/asm/arch-tegra2/dc.h
>>   create mode 100644 arch/arm/include/asm/arch-tegra2/display.h
>>   create mode 100644 arch/arm/include/asm/arch-tegra2/pwfm.h
>>   create mode 100644 doc/device-tree-bindings/video/nvidia-video.txt
>>   create mode 100644 drivers/video/tegra.c
>>
>
> Hi Simon,
>
> I have added your patch sources manually into the "Prepare v2012.04-rc1
> release", because I got errors at apply. Also I added a device tree source
> file for Harmony.
>
> I tested the device tree source file for Harmony and your patch sources on
> our Harmony hardware and generated a new patch file:
>
> http://poeggi.dotsec.net/nvidia/uboot-lvds-init-patch/0001-Add-display-driver-and-LCD-support-for-Harmony-board.patch
>
> I hope it's all okay, this my first patch release.
>
> In the display.c source file I implemented a bug fix, because I get garbled
> images on the LCD without this fix.

I see this code:

	u32 m_value;

	m_value = readl(0x54202e04);
	m_value &= ~0x2;
	writel(m_value, 0x54202e04);

What register are you actually writing here? I can't find it in my
manual, but maybe I just haven't seen that address.

Also I notice you have changed the memorypriorites:

 	writel(0x00202020, &disp->mem_high_pri);
 	writel(0x00010101, &disp->mem_high_pri_timer);

Does that make a difference in your system?

Regards,
Simon

>
> Greetings
> Christian
>
> Changes:
>
> - Add device tree source file for Harmony board
> - Add bug fix in display.c
> - Patch based on the "Prepare v2012.04-rc1" release
>
> ---
>  README                                          |    7 +
>
>  arch/arm/cpu/armv7/cache_v7.c                   |   11 +
>  arch/arm/cpu/armv7/tegra2/Makefile              |    1 +
>  arch/arm/cpu/armv7/tegra2/display.c             |  282 ++++++++++++
>  arch/arm/cpu/armv7/tegra2/funcmux.c             |   41 ++
>  arch/arm/cpu/armv7/tegra2/pwfm.c                |   45 ++
>  arch/arm/dts/tegra20.dtsi                       |   26 ++
>
>  arch/arm/include/asm/arch-tegra2/dc.h           |  544
> +++++++++++++++++++++++
>  arch/arm/include/asm/arch-tegra2/display.h      |  133 ++++++
>  arch/arm/include/asm/arch-tegra2/pwfm.h         |   54 +++
>  arch/arm/include/asm/system.h                   |   30 ++
>  arch/arm/lib/cache-cp15.c                       |   61 +++-
>  board/nvidia/common/board.c                     |   20 +
>  board/nvidia/dts/tegra2-harmony.dts             |   97 ++++
>  board/nvidia/dts/tegra2-seaboard.dts            |   21 +
>  common/cmd_echo.c                               |    2 +-
>  common/lcd.c                                    |   86 +++-
>
>  doc/device-tree-bindings/video/nvidia-video.txt |   92 ++++
>  drivers/video/Makefile                          |    1 +
>  drivers/video/tegra.c                           |  397 +++++++++++++++++
>  dts/Makefile                                    |    2 +-
>  include/configs/harmony.h                       |   39 ++-
>  include/configs/tegra2-common.h                 |  218 +++++++++-
>  include/fdtdec.h                                |   19 +-
>  include/lcd.h                                   |   12 +
>  lib/fdtdec.c                                    |   12 +
>  26 files changed, 2206 insertions(+), 47 deletions(-)
>
>  create mode 100644 arch/arm/cpu/armv7/tegra2/display.c
>  create mode 100644 arch/arm/cpu/armv7/tegra2/pwfm.c
>  create mode 100644 arch/arm/include/asm/arch-tegra2/dc.h
>  create mode 100644 arch/arm/include/asm/arch-tegra2/display.h
>  create mode 100644 arch/arm/include/asm/arch-tegra2/pwfm.h
>  create mode 100644 board/nvidia/dts/tegra2-harmony.dts
>
>  create mode 100644 doc/device-tree-bindings/video/nvidia-video.txt
>  create mode 100644 drivers/video/tegra.c
>
>
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard
  2012-07-14  8:03   ` Simon Glass
@ 2012-07-17 16:11     ` Thierry Reding
  2012-07-18  6:51       ` Simon Glass
  0 siblings, 1 reply; 39+ messages in thread
From: Thierry Reding @ 2012-07-17 16:11 UTC (permalink / raw)
  To: u-boot

On Sat, Jul 14, 2012 at 10:03:31AM +0200, Simon Glass wrote:
> Hi Christian,
> 
> On Thu, Apr 19, 2012 at 2:41 PM, Christian Kroehnert
> <christian.kroehnert@avionic-design.de> wrote:
> > On 15.01.2012 01:47, Simon Glass wrote:
> >>
> >> This series adds support for the Tegra2x's display peripheral. This
> >> supports the LCD display on Seaboard and we use this to enable console
> >> output in U-Boot on the LCD.
> >>
> >> Configuration is via the device tree. Proposed bindings are included
> >> in this series.
> >>
> >> To improve performance two optimisations are offered:
> >>
> >> 1. The LCD frame buffer is cached, with the cache being flushed after
> >> each call puts(). This dramatically increases performance (around 10x).
> >> This requires a few additions to the ARM cache support.
> >>
> >> 2. The console supports scrolling in steps of more than 1 line. This
> >> speeds up scrolling output considerably, particularly commands like
> >> 'printenv' which display a lot of output. This requires a new CONFIG
> >> and a change to the console_scrollup() function.
> >>
> >>
> >> Mayuresh Kulkarni (1):
> >>    tegra: Enable display/lcd support on Seaboard
> >>
> >> Simon Glass (15):
> >>    fdt: Add function to look up a phandle's register address
> >>    fdt: Add header guard to fdtdec.h
> >>    fdt: Correct GPIO name access in fdtdec
> >>    tegra: Add display support to funcmux
> >>    tegra: fdt: Add LCD definitions for Tegra
> >>    tegra: Add support for PWFM
> >>    tegra: Add LCD driver
> >>    tegra: Add LCD support to Nvidia boards
> >>    arm: Add control over cachability of memory regions
> >>    lcd: Add CONFIG_ALIGN_LCD_TO_SECTION to align lcd for MMU
> >>    lcd: Add support for flushing LCD fb from dcache after update
> >>    tegra: Align LCD frame buffer to section boundary
> >>    tegra: Support control of cache settings for LCD
> >>    tegra: fdt: Add LCD definitions for Seaboard
> >>    lcd: Add CONSOLE_SCROLL_LINES option to speed console
> >>
> >> Wei Ni (1):
> >>    tegra: Add SOC support for display/lcd
> >>
> >>   README                                          |   16 +
> >>   arch/arm/cpu/armv7/cache_v7.c                   |   11 +
> >>   arch/arm/cpu/armv7/tegra2/Makefile              |    1 +
> >>   arch/arm/cpu/armv7/tegra2/display.c             |  271 +++++++++++
> >>   arch/arm/cpu/armv7/tegra2/funcmux.c             |   39 ++
> >>   arch/arm/cpu/armv7/tegra2/pwfm.c                |   40 ++
> >>   arch/arm/dts/tegra20.dtsi                       |   25 +
> >>   arch/arm/include/asm/arch-tegra2/dc.h           |  544
> >> +++++++++++++++++++++++
> >>   arch/arm/include/asm/arch-tegra2/display.h      |  133 ++++++
> >>   arch/arm/include/asm/arch-tegra2/pwfm.h         |   54 +++
> >>   arch/arm/include/asm/system.h                   |   30 ++
> >>   arch/arm/lib/cache-cp15.c                       |   62 +++-
> >>   board/nvidia/common/board.c                     |   21 +-
> >>   board/nvidia/dts/tegra2-seaboard.dts            |   21 +
> >>   common/cmd_echo.c                               |    3 +-
> >>   common/lcd.c                                    |   85 +++-
> >>   doc/device-tree-bindings/video/nvidia-video.txt |   92 ++++
> >>   drivers/video/Makefile                          |    1 +
> >>   drivers/video/tegra.c                           |  388 ++++++++++++++++
> >>   include/configs/seaboard.h                      |   12 +-
> >>   include/configs/tegra2-common.h                 |    1 +
> >>   include/fdtdec.h                                |   17 +
> >>   include/lcd.h                                   |   11 +
> >>   lib/fdtdec.c                                    |   15 +-
> >>   24 files changed, 1862 insertions(+), 31 deletions(-)
> >>   create mode 100644 arch/arm/cpu/armv7/tegra2/display.c
> >>   create mode 100644 arch/arm/cpu/armv7/tegra2/pwfm.c
> >>   create mode 100644 arch/arm/include/asm/arch-tegra2/dc.h
> >>   create mode 100644 arch/arm/include/asm/arch-tegra2/display.h
> >>   create mode 100644 arch/arm/include/asm/arch-tegra2/pwfm.h
> >>   create mode 100644 doc/device-tree-bindings/video/nvidia-video.txt
> >>   create mode 100644 drivers/video/tegra.c
> >>
> >
> > Hi Simon,
> >
> > I have added your patch sources manually into the "Prepare v2012.04-rc1
> > release", because I got errors at apply. Also I added a device tree source
> > file for Harmony.
> >
> > I tested the device tree source file for Harmony and your patch sources on
> > our Harmony hardware and generated a new patch file:
> >
> > http://poeggi.dotsec.net/nvidia/uboot-lvds-init-patch/0001-Add-display-driver-and-LCD-support-for-Harmony-board.patch
> >
> > I hope it's all okay, this my first patch release.
> >
> > In the display.c source file I implemented a bug fix, because I get garbled
> > images on the LCD without this fix.
> 
> I see this code:
> 
> 	u32 m_value;
> 
> 	m_value = readl(0x54202e04);
> 	m_value &= ~0x2;
> 	writel(m_value, 0x54202e04);
> 
> What register are you actually writing here? I can't find it in my
> manual, but maybe I just haven't seen that address.

At the time I did look for that register as well but couldn't find
anything. But I believe that we saw the garbled display issue that
has been mentioned in another thread. If I remember correctly this
particular register write was the fix for it.

But I wasn't very much involved at the time, so maybe Christian can
clarify. However I was going to test your newest version of the LCD
patch series on our hardware and see if the issue is still there.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120717/8e1ef6bf/attachment.pgp>

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard
  2012-07-17 16:11     ` Thierry Reding
@ 2012-07-18  6:51       ` Simon Glass
  2012-07-19 12:01         ` Christian Kroehnert
  2012-07-24 19:16         ` Stephen Warren
  0 siblings, 2 replies; 39+ messages in thread
From: Simon Glass @ 2012-07-18  6:51 UTC (permalink / raw)
  To: u-boot

+Tom, Stephen

On Tue, Jul 17, 2012 at 5:11 PM, Thierry Reding
<thierry.reding@avionic-design.de> wrote:
> On Sat, Jul 14, 2012 at 10:03:31AM +0200, Simon Glass wrote:
>> Hi Christian,
>>
>> On Thu, Apr 19, 2012 at 2:41 PM, Christian Kroehnert
>> <christian.kroehnert@avionic-design.de> wrote:
>> > On 15.01.2012 01:47, Simon Glass wrote:
>> >>
>> >> This series adds support for the Tegra2x's display peripheral. This
>> >> supports the LCD display on Seaboard and we use this to enable console
>> >> output in U-Boot on the LCD.
>> >>
>> >> Configuration is via the device tree. Proposed bindings are included
>> >> in this series.
>> >>
>> >> To improve performance two optimisations are offered:
>> >>
>> >> 1. The LCD frame buffer is cached, with the cache being flushed after
>> >> each call puts(). This dramatically increases performance (around 10x).
>> >> This requires a few additions to the ARM cache support.
>> >>
>> >> 2. The console supports scrolling in steps of more than 1 line. This
>> >> speeds up scrolling output considerably, particularly commands like
>> >> 'printenv' which display a lot of output. This requires a new CONFIG
>> >> and a change to the console_scrollup() function.
>> >>
>> >>
>> >> Mayuresh Kulkarni (1):
>> >>    tegra: Enable display/lcd support on Seaboard
>> >>
>> >> Simon Glass (15):
>> >>    fdt: Add function to look up a phandle's register address
>> >>    fdt: Add header guard to fdtdec.h
>> >>    fdt: Correct GPIO name access in fdtdec
>> >>    tegra: Add display support to funcmux
>> >>    tegra: fdt: Add LCD definitions for Tegra
>> >>    tegra: Add support for PWFM
>> >>    tegra: Add LCD driver
>> >>    tegra: Add LCD support to Nvidia boards
>> >>    arm: Add control over cachability of memory regions
>> >>    lcd: Add CONFIG_ALIGN_LCD_TO_SECTION to align lcd for MMU
>> >>    lcd: Add support for flushing LCD fb from dcache after update
>> >>    tegra: Align LCD frame buffer to section boundary
>> >>    tegra: Support control of cache settings for LCD
>> >>    tegra: fdt: Add LCD definitions for Seaboard
>> >>    lcd: Add CONSOLE_SCROLL_LINES option to speed console
>> >>
>> >> Wei Ni (1):
>> >>    tegra: Add SOC support for display/lcd
>> >>
>> >>   README                                          |   16 +
>> >>   arch/arm/cpu/armv7/cache_v7.c                   |   11 +
>> >>   arch/arm/cpu/armv7/tegra2/Makefile              |    1 +
>> >>   arch/arm/cpu/armv7/tegra2/display.c             |  271 +++++++++++
>> >>   arch/arm/cpu/armv7/tegra2/funcmux.c             |   39 ++
>> >>   arch/arm/cpu/armv7/tegra2/pwfm.c                |   40 ++
>> >>   arch/arm/dts/tegra20.dtsi                       |   25 +
>> >>   arch/arm/include/asm/arch-tegra2/dc.h           |  544
>> >> +++++++++++++++++++++++
>> >>   arch/arm/include/asm/arch-tegra2/display.h      |  133 ++++++
>> >>   arch/arm/include/asm/arch-tegra2/pwfm.h         |   54 +++
>> >>   arch/arm/include/asm/system.h                   |   30 ++
>> >>   arch/arm/lib/cache-cp15.c                       |   62 +++-
>> >>   board/nvidia/common/board.c                     |   21 +-
>> >>   board/nvidia/dts/tegra2-seaboard.dts            |   21 +
>> >>   common/cmd_echo.c                               |    3 +-
>> >>   common/lcd.c                                    |   85 +++-
>> >>   doc/device-tree-bindings/video/nvidia-video.txt |   92 ++++
>> >>   drivers/video/Makefile                          |    1 +
>> >>   drivers/video/tegra.c                           |  388 ++++++++++++++++
>> >>   include/configs/seaboard.h                      |   12 +-
>> >>   include/configs/tegra2-common.h                 |    1 +
>> >>   include/fdtdec.h                                |   17 +
>> >>   include/lcd.h                                   |   11 +
>> >>   lib/fdtdec.c                                    |   15 +-
>> >>   24 files changed, 1862 insertions(+), 31 deletions(-)
>> >>   create mode 100644 arch/arm/cpu/armv7/tegra2/display.c
>> >>   create mode 100644 arch/arm/cpu/armv7/tegra2/pwfm.c
>> >>   create mode 100644 arch/arm/include/asm/arch-tegra2/dc.h
>> >>   create mode 100644 arch/arm/include/asm/arch-tegra2/display.h
>> >>   create mode 100644 arch/arm/include/asm/arch-tegra2/pwfm.h
>> >>   create mode 100644 doc/device-tree-bindings/video/nvidia-video.txt
>> >>   create mode 100644 drivers/video/tegra.c
>> >>
>> >
>> > Hi Simon,
>> >
>> > I have added your patch sources manually into the "Prepare v2012.04-rc1
>> > release", because I got errors at apply. Also I added a device tree source
>> > file for Harmony.
>> >
>> > I tested the device tree source file for Harmony and your patch sources on
>> > our Harmony hardware and generated a new patch file:
>> >
>> > http://poeggi.dotsec.net/nvidia/uboot-lvds-init-patch/0001-Add-display-driver-and-LCD-support-for-Harmony-board.patch
>> >
>> > I hope it's all okay, this my first patch release.
>> >
>> > In the display.c source file I implemented a bug fix, because I get garbled
>> > images on the LCD without this fix.
>>
>> I see this code:
>>
>>       u32 m_value;
>>
>>       m_value = readl(0x54202e04);
>>       m_value &= ~0x2;
>>       writel(m_value, 0x54202e04);
>>
>> What register are you actually writing here? I can't find it in my
>> manual, but maybe I just haven't seen that address.
>
> At the time I did look for that register as well but couldn't find
> anything. But I believe that we saw the garbled display issue that
> has been mentioned in another thread. If I remember correctly this
> particular register write was the fix for it.
>
> But I wasn't very much involved at the time, so maybe Christian can
> clarify. However I was going to test your newest version of the LCD
> patch series on our hardware and see if the issue is still there.

Does anyone know what this register is for? I am reluctant to add this
code to the patch without at least a comment.

>
> Thierry

Regards,
Simon

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard
  2012-07-18  6:51       ` Simon Glass
@ 2012-07-19 12:01         ` Christian Kroehnert
  2012-07-24 19:16         ` Stephen Warren
  1 sibling, 0 replies; 39+ messages in thread
From: Christian Kroehnert @ 2012-07-19 12:01 UTC (permalink / raw)
  To: u-boot

Am 18.07.2012 08:51, schrieb Simon Glass:
> +Tom, Stephen
>
> On Tue, Jul 17, 2012 at 5:11 PM, Thierry Reding
> <thierry.reding@avionic-design.de> wrote:
>> On Sat, Jul 14, 2012 at 10:03:31AM +0200, Simon Glass wrote:
>>> Hi Christian,
>>>
>>> On Thu, Apr 19, 2012 at 2:41 PM, Christian Kroehnert
>>> <christian.kroehnert@avionic-design.de> wrote:
>>>> On 15.01.2012 01:47, Simon Glass wrote:
>>>>>
>>>>> This series adds support for the Tegra2x's display peripheral. This
>>>>> supports the LCD display on Seaboard and we use this to enable console
>>>>> output in U-Boot on the LCD.
>>>>>
>>>>> Configuration is via the device tree. Proposed bindings are included
>>>>> in this series.
>>>>>
>>>>> To improve performance two optimisations are offered:
>>>>>
>>>>> 1. The LCD frame buffer is cached, with the cache being flushed after
>>>>> each call puts(). This dramatically increases performance (around 10x).
>>>>> This requires a few additions to the ARM cache support.
>>>>>
>>>>> 2. The console supports scrolling in steps of more than 1 line. This
>>>>> speeds up scrolling output considerably, particularly commands like
>>>>> 'printenv' which display a lot of output. This requires a new CONFIG
>>>>> and a change to the console_scrollup() function.
>>>>>
>>>>>
>>>>> Mayuresh Kulkarni (1):
>>>>>     tegra: Enable display/lcd support on Seaboard
>>>>>
>>>>> Simon Glass (15):
>>>>>     fdt: Add function to look up a phandle's register address
>>>>>     fdt: Add header guard to fdtdec.h
>>>>>     fdt: Correct GPIO name access in fdtdec
>>>>>     tegra: Add display support to funcmux
>>>>>     tegra: fdt: Add LCD definitions for Tegra
>>>>>     tegra: Add support for PWFM
>>>>>     tegra: Add LCD driver
>>>>>     tegra: Add LCD support to Nvidia boards
>>>>>     arm: Add control over cachability of memory regions
>>>>>     lcd: Add CONFIG_ALIGN_LCD_TO_SECTION to align lcd for MMU
>>>>>     lcd: Add support for flushing LCD fb from dcache after update
>>>>>     tegra: Align LCD frame buffer to section boundary
>>>>>     tegra: Support control of cache settings for LCD
>>>>>     tegra: fdt: Add LCD definitions for Seaboard
>>>>>     lcd: Add CONSOLE_SCROLL_LINES option to speed console
>>>>>
>>>>> Wei Ni (1):
>>>>>     tegra: Add SOC support for display/lcd
>>>>>
>>>>>    README                                          |   16 +
>>>>>    arch/arm/cpu/armv7/cache_v7.c                   |   11 +
>>>>>    arch/arm/cpu/armv7/tegra2/Makefile              |    1 +
>>>>>    arch/arm/cpu/armv7/tegra2/display.c             |  271 +++++++++++
>>>>>    arch/arm/cpu/armv7/tegra2/funcmux.c             |   39 ++
>>>>>    arch/arm/cpu/armv7/tegra2/pwfm.c                |   40 ++
>>>>>    arch/arm/dts/tegra20.dtsi                       |   25 +
>>>>>    arch/arm/include/asm/arch-tegra2/dc.h           |  544
>>>>> +++++++++++++++++++++++
>>>>>    arch/arm/include/asm/arch-tegra2/display.h      |  133 ++++++
>>>>>    arch/arm/include/asm/arch-tegra2/pwfm.h         |   54 +++
>>>>>    arch/arm/include/asm/system.h                   |   30 ++
>>>>>    arch/arm/lib/cache-cp15.c                       |   62 +++-
>>>>>    board/nvidia/common/board.c                     |   21 +-
>>>>>    board/nvidia/dts/tegra2-seaboard.dts            |   21 +
>>>>>    common/cmd_echo.c                               |    3 +-
>>>>>    common/lcd.c                                    |   85 +++-
>>>>>    doc/device-tree-bindings/video/nvidia-video.txt |   92 ++++
>>>>>    drivers/video/Makefile                          |    1 +
>>>>>    drivers/video/tegra.c                           |  388 ++++++++++++++++
>>>>>    include/configs/seaboard.h                      |   12 +-
>>>>>    include/configs/tegra2-common.h                 |    1 +
>>>>>    include/fdtdec.h                                |   17 +
>>>>>    include/lcd.h                                   |   11 +
>>>>>    lib/fdtdec.c                                    |   15 +-
>>>>>    24 files changed, 1862 insertions(+), 31 deletions(-)
>>>>>    create mode 100644 arch/arm/cpu/armv7/tegra2/display.c
>>>>>    create mode 100644 arch/arm/cpu/armv7/tegra2/pwfm.c
>>>>>    create mode 100644 arch/arm/include/asm/arch-tegra2/dc.h
>>>>>    create mode 100644 arch/arm/include/asm/arch-tegra2/display.h
>>>>>    create mode 100644 arch/arm/include/asm/arch-tegra2/pwfm.h
>>>>>    create mode 100644 doc/device-tree-bindings/video/nvidia-video.txt
>>>>>    create mode 100644 drivers/video/tegra.c
>>>>>
>>>>
>>>> Hi Simon,
>>>>
>>>> I have added your patch sources manually into the "Prepare v2012.04-rc1
>>>> release", because I got errors at apply. Also I added a device tree source
>>>> file for Harmony.
>>>>
>>>> I tested the device tree source file for Harmony and your patch sources on
>>>> our Harmony hardware and generated a new patch file:
>>>>
>>>> http://poeggi.dotsec.net/nvidia/uboot-lvds-init-patch/0001-Add-display-driver-and-LCD-support-for-Harmony-board.patch
>>>>
>>>> I hope it's all okay, this my first patch release.
>>>>
>>>> In the display.c source file I implemented a bug fix, because I get garbled
>>>> images on the LCD without this fix.
>>>
>>> I see this code:
>>>
>>>        u32 m_value;
>>>
>>>        m_value = readl(0x54202e04);
>>>        m_value &= ~0x2;
>>>        writel(m_value, 0x54202e04);
>>>
>>> What register are you actually writing here? I can't find it in my
>>> manual, but maybe I just haven't seen that address.
>>
>> At the time I did look for that register as well but couldn't find
>> anything. But I believe that we saw the garbled display issue that
>> has been mentioned in another thread. If I remember correctly this
>> particular register write was the fix for it.
>>
>> But I wasn't very much involved at the time, so maybe Christian can
>> clarify. However I was going to test your newest version of the LCD
>> patch series on our hardware and see if the issue is still there.
>
> Does anyone know what this register is for? I am reluctant to add this
> code to the patch without at least a comment.
>
>>
>> Thierry
>
> Regards,
> Simon
>

Also in our manual this register is not documented. The garbed images 
emerged when the tempature of ARM processor was high (after 2min standby 
and then a reboot) or if I cool it down with ice spay before the boot 
up. So when I didn't cleared this register, I got garbled images. I 
don't have the device here, on which I have tested, so I can reproduce 
it. Thierry have tested it on a other device with the newest version of 
the LCD patch and he can't reproduce the garbed images.

Best regards
Christian

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard
  2012-07-18  6:51       ` Simon Glass
  2012-07-19 12:01         ` Christian Kroehnert
@ 2012-07-24 19:16         ` Stephen Warren
  1 sibling, 0 replies; 39+ messages in thread
From: Stephen Warren @ 2012-07-24 19:16 UTC (permalink / raw)
  To: u-boot

On 07/18/2012 12:51 AM, Simon Glass wrote:
> +Tom, Stephen
> 
> On Tue, Jul 17, 2012 at 5:11 PM, Thierry Reding
> <thierry.reding@avionic-design.de> wrote:
>> On Sat, Jul 14, 2012 at 10:03:31AM +0200, Simon Glass wrote:
>>> Hi Christian,
>>>
>>> On Thu, Apr 19, 2012 at 2:41 PM, Christian Kroehnert
>>> <christian.kroehnert@avionic-design.de> wrote:
...
>>>> In the display.c source file I implemented a bug fix, because I get garbled
>>>> images on the LCD without this fix.
>>>
>>> I see this code:
>>>
>>>       u32 m_value;
>>>
>>>       m_value = readl(0x54202e04);
>>>       m_value &= ~0x2;
>>>       writel(m_value, 0x54202e04);
>>>
>>> What register are you actually writing here? I can't find it in my
>>> manual, but maybe I just haven't seen that address.
>>
>> At the time I did look for that register as well but couldn't find
>> anything. But I believe that we saw the garbled display issue that
>> has been mentioned in another thread. If I remember correctly this
>> particular register write was the fix for it.
>>
>> But I wasn't very much involved at the time, so maybe Christian can
>> clarify. However I was going to test your newest version of the LCD
>> patch series on our hardware and see if the issue is still there.
> 
> Does anyone know what this register is for? I am reluctant to add this
> code to the patch without at least a comment.

That address is an alias for DC_WIN_A_BYTE_SWAP_0 (offset 0x701), which
is documented in the TRM. It seems unlikely this was solve the issue at
hand, if I remember it correctly.

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2012-07-24 19:16 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-15  0:47 [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 04/17] tegra: Add display support to funcmux Simon Glass
2012-01-15  1:36   ` Mike Frysinger
2012-06-13 12:15     ` Simon Glass
     [not found] ` <1326588449-1794-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2012-01-15  0:47   ` [PATCH 01/17] fdt: Add function to look up a phandle's register address Simon Glass
2012-01-15  0:47     ` [U-Boot] " Simon Glass
2012-01-15  0:47   ` [PATCH 02/17] fdt: Add header guard to fdtdec.h Simon Glass
2012-01-15  0:47     ` [U-Boot] " Simon Glass
2012-01-15  0:47   ` [PATCH 03/17] fdt: Correct GPIO name access in fdtdec Simon Glass
2012-01-15  0:47     ` [U-Boot] " Simon Glass
2012-01-15  0:47   ` [PATCH 05/17] tegra: fdt: Add LCD definitions for Tegra Simon Glass
2012-01-15  0:47     ` [U-Boot] " Simon Glass
2012-01-15  0:47   ` [PATCH 15/17] tegra: fdt: Add LCD definitions for Seaboard Simon Glass
2012-01-15  0:47     ` [U-Boot] " Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 06/17] tegra: Add support for PWFM Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 07/17] tegra: Add SOC support for display/lcd Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 08/17] tegra: Add LCD driver Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 09/17] tegra: Add LCD support to Nvidia boards Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 10/17] arm: Add control over cachability of memory regions Simon Glass
2012-02-10 20:38   ` Albert ARIBAUD
2012-03-04  6:20     ` Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 11/17] lcd: Add CONFIG_ALIGN_LCD_TO_SECTION to align lcd for MMU Simon Glass
2012-01-15  1:38   ` Mike Frysinger
2012-06-13 12:23     ` Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 12/17] lcd: Add support for flushing LCD fb from dcache after update Simon Glass
2012-01-15  1:42   ` Mike Frysinger
2012-01-15  1:57     ` Simon Glass
2012-01-15  2:16       ` Mike Frysinger
2012-06-13 12:25         ` Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 13/17] tegra: Align LCD frame buffer to section boundary Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 14/17] tegra: Support control of cache settings for LCD Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 16/17] lcd: Add CONSOLE_SCROLL_LINES option to speed console Simon Glass
2012-01-15  0:47 ` [U-Boot] [PATCH 17/17] tegra: Enable display/lcd support on Seaboard Simon Glass
2012-04-19 12:41 ` [U-Boot] [PATCH 0/17] tegra: Add display driver and LCD support for Seaboard Christian Kroehnert
2012-07-14  8:03   ` Simon Glass
2012-07-17 16:11     ` Thierry Reding
2012-07-18  6:51       ` Simon Glass
2012-07-19 12:01         ` Christian Kroehnert
2012-07-24 19:16         ` Stephen Warren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.