Skip to contentSkip to conversation

tegra: Add display driver and LCD support for Seaboard

PATCH Superseded Simon Glass 7 participants 54 messages Jun 13, 2012 – Sep 27, 2012 2 messages not in the archive

Subsystems (5)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v2 cover tegra: Add display driver and LCD support for Seaboard

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.

I looked at the message "[RFC 4/4] drm: Add NVIDIA Tegra support" on device-tree-discuss. There does not seem to be any conclusion for now.

While I agree EDID is convenient for machines I would prefer to provide a user-friendly way of selecting LCD settings as well, with EDID more as a fallback and auto-detection when available.

To improve performance two optimisations are offered:

1. The LCD frame buffer is cached, with the cache being flushed after each newline sent to putc(), and in a few other situations. 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.

Changes in v2:
- Add new patch to use const in pinmux_config_pingroup/table()
- Add nvidia prefix to device tree properties
- Align tegra display using new CONFIG_LCD_ALIGNMENT feature
- Put the LCD cache flush logic into lcd_putc() instead of lcd_puts()
- Update LCD driver to deal with new fdt bindings
- Update seaboard LCD definitions for new fdt binding
- Use a more generic config CONFIG_LCD_ALIGNMENT for lcd alignment
- Use const where possible in funcmux

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

Simon Glass (17):
Add gpio_request() to asm-generic header
fdt: Add debugging to fdtdec_get_int/addr()
fdt: Add function to look up a phandle's register address
fdt: Add header guard to fdtdec.h
tegra: Use const for pinmux_config_pingroup/table()
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_LCD_ALIGNMENT to select frame buffer alignment
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/pinmux.c              |    4 +-
 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/pinmux.h       |    4 +-
 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                                    |   84 +++-
 doc/device-tree-bindings/video/nvidia-video.txt |   88 ++++
 drivers/video/Makefile                          |    1 +
 drivers/video/tegra.c                           |  392 ++++++++++++++++
 include/asm-generic/gpio.h                      |    9 +
 include/configs/seaboard.h                      |   12 +-
 include/configs/tegra2-common.h                 |    3 +
 include/fdtdec.h                                |   17 +
 include/lcd.h                                   |   11 +
 lib/fdtdec.c                                    |   34 ++-
 27 files changed, 1891 insertions(+), 39 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
Signature · 1 line
1.7.7.3
#1 lore raw

PATCH v2 1/19 Add gpio_request() to asm-generic header

This function should also be part of the GPIO API, so add it.

---

 include/asm-generic/gpio.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
include/asm-generic/gpio.h +9 -0
index c19e16c..23c9649 100644
@@ -94,4 +94,13 @@ int gpio_get_value(unsigned gpio);
  */
 int gpio_set_value(unsigned gpio, int value);
 
+/**
+ * Request a gpio. This should be called before any of the other functions
+ * are used on this gpio.
+ *
+ * @param gp	GPIO number
+ * @param label	User label for this GPIO
+ * @return 0 if ok, -1 on error
+ */
+int gpio_request(unsigned gpio, const char *label);
 #endif	/* _ASM_GENERIC_GPIO_H_ */
Signature · 1 line
1.7.7.3
#2 lore raw

PATCH v2 1/19 Add gpio_request() to asm-generic header

Hi Simon,

Quoted 7 lines · On Wed, 13 Jun 2012 09:19:37 -0700 Simon Glass <[email protected]> wrote:

This function should also be part of the GPIO API, so add it.

---

 include/asm-generic/gpio.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

Applied to staging/agust at denx.de.

Thanks,
Anatolij

#3 lore raw

PATCH v2 1/19 Add gpio_request() to asm-generic header

Hi Anatolij,

Quoted 7 lines · Anatolij Gustschin

Hi Simon,

Quoted 2 lines · On Wed, 13 Jun 2012 09:19:37 -0700 Simon Glass <[email protected]> wrote:

This function should also be part of the GPIO API, so add it.

Quoted 7 lines
Quoted 5 lines

---

 include/asm-generic/gpio.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

Applied to staging/agust at denx.de.

Thanks. I'm sorry to say that another patch has already done this (and done a better job). It isn't particularly important, but you could revert this since the code already exists at the top of the file. Sorry I didn't spot this earlier - I think the patch was on the mailing list but not merged.

Regards,
Simon

Quoted 3 lines

Thanks,
Anatolij

A message that is not in the archive (sent off-list or not yet received): 1339604395-6621-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org

#5 lore raw

PATCH v2 2/19 fdt: Add debugging to fdtdec_get_int/addr()

The new debugging shows the value of integers and addresses read from the device tree.

---

 lib/fdtdec.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)
lib/fdtdec.c +16 -6
index cc09e06..61056f1 100644
@@ -80,11 +80,16 @@ fdt_addr_t fdtdec_get_addr(const void *blob, int node,
 	const fdt_addr_t *cell;
 	int len;
 
-	debug("get_addr: %s\n", prop_name);
+	debug("%s: %s\n", __func__, prop_name);
 	cell = fdt_getprop(blob, node, prop_name, &len);
 	if (cell && (len == sizeof(fdt_addr_t) ||
-			len == sizeof(fdt_addr_t) * 2))
-		return fdt_addr_to_cpu(*cell);
+			len == sizeof(fdt_addr_t) * 2)) {
+		fdt_addr_t addr = fdt_addr_to_cpu(*cell);
+
+		debug("%p\n", (void *)addr);
+		return addr;
+	}
+	debug("(not found)\n");
 	return FDT_ADDR_T_NONE;
 }
 
@@ -94,10 +99,15 @@ s32 fdtdec_get_int(const void *blob, int node, const char *prop_name,
 	const s32 *cell;
 	int len;
 
-	debug("get_size: %s\n", prop_name);
+	debug("%s: %s: ", __func__, prop_name);
 	cell = fdt_getprop(blob, node, prop_name, &len);
-	if (cell && len >= sizeof(s32))
-		return fdt32_to_cpu(cell[0]);
+	if (cell && len >= sizeof(s32)) {
+		s32 val = fdt32_to_cpu(cell[0]);
+
+		debug("%#x (%d)\n", val, val);
+		return val;
+	}
+	debug("(not found)\n");
 	return default_val;
 }
 
Signature · 1 line
1.7.7.3
#6 lore raw

PATCH v2 2/19 fdt: Add debugging to fdtdec_get_int/addr()

Quoted 8 lines · On Wed, 13 Jun 2012 09:19:38 -0700 Simon Glass <[email protected]> wrote:

The new debugging shows the value of integers and addresses read from the device tree.

---

 lib/fdtdec.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

Applied to staging/agust at denx.de.

Thanks,
Anatolij

#7 lore raw

PATCH v2 2/19 fdt: Add debugging to fdtdec_get_int/addr()

Quoted 6 lines · On Fri, 21 Sep 2012 21:39:39 +0200 Anatolij Gustschin <[email protected]> wrote:
Quoted 3 lines · On Wed, 13 Jun 2012 09:19:38 -0700 Simon Glass <[email protected]> wrote:

The new debugging shows the value of integers and addresses read from the device tree.

Quoted 7 lines
Quoted 5 lines

---

 lib/fdtdec.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

Applied to staging/agust at denx.de.

now I see a newer version of this patch. I'll drop this one and will apply v3 instead.

Thanks,
Anatolij

#8 lore raw

PATCH v2 3/19 fdt: Add function to look up a phandle's register address

In reply to a message not in the archive

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

---

 include/fdtdec.h |   13 +++++++++++++
 lib/fdtdec.c     |   11 +++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)
include/fdtdec.h +13 -0
index fab577e..d7bef6c 100644
@@ -276,6 +276,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.
lib/fdtdec.c +11 -0
index 61056f1..8185d8f 100644
@@ -347,6 +347,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.
  *
Signature · 1 line
1.7.7.3
#9 lore raw

Re: [PATCH v2 03/19] fdt: Add function to look up a phandle's register address

Quoted 2 lines · Simon Glass

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

Uggh. Why would this ever be needed; shouldn't the driver for the node referenced by the phandle fully control its own registers; why would any other driver randomly trample on them?

#10 lore raw

Re: [PATCH v2 03/19] fdt: Add function to look up a phandle's register address

Hi Stephen,

Quoted 8 lines · Stephen Warren
Quoted 2 lines · Simon Glass

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

Uggh. Why would this ever be needed; shouldn't the driver for the node referenced by the phandle fully control its own registers; why would any other driver randomly trample on them?

You are making assumptions. This is used for the pwm and only accessed by the pwm driver.

It's basically to allow a simple and efficient way of getting access to a peripheral. Since the new binding you pointed me to uses a single pwm with multiple channels, this doesn't offer any benefit so I will punt it.

Regards,
Simon

_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

#11 lore raw

PATCH v2 4/19 fdt: Add header guard to fdtdec.h

In reply to a message not in the archive

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

---

 include/fdtdec.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/fdtdec.h +3 -0
index d7bef6c..627d077 100644
@@ -19,6 +19,8 @@
  * MA 02111-1307 USA
  */
 
+#ifndef __fdtdec_h
+#define __fdtdec_h
 
 /*
  * This file contains convenience functions for decoding useful and
@@ -395,3 +397,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
Signature · 1 line
1.7.7.3
#12 lore raw

PATCH v2 17/19 tegra: fdt: Add LCD definitions for Seaboard

In reply to a message not in the archive

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

---
Changes in v2:
- Update seaboard LCD definitions for new fdt binding

 board/nvidia/dts/tegra2-seaboard.dts |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
board/nvidia/dts/tegra2-seaboard.dts +21 -0
index 3352539..3b16f84 100644
@@ -153,4 +153,25 @@
 			0x1f04008a>;
 		linux,fn-keymap = <0x05040002>;
 	};
+
+	display@0x54200000 {
+		nvidia,pwfm = <&pwfm2>;
+		nvidia,frame-buffer = <0x2f680000>;
+		nvidia,backlight-enable-gpios = <&gpio 28 0>;	/* PD4 */
+		nvidia,lvds-shutdown-gpios = <&gpio 10 0>;	/* PB2 */
+		nvidia,backlight-vdd-gpios = <&gpio 176 0>;	/* PW0 */
+		nvidia,panel-vdd-gpios = <&gpio 22 0>;		/* PC6 */
+		nvidia,panel-timings = <4 203 17 15>;
+
+		lcd {
+			compatible = "nvidia,lcd";
+			nvidia,width = <1366>;
+			nvidia,height = <768>;
+			nvidia,bits-per-pixel = <16>;
+			nvidia,pixel-clock = <70600000>;
+
+			nvidia,horiz-timing = <11 58 58 58>;
+			nvidia,vert-timing = <1 4 4 4>;
+		};
+	};
 };
Signature · 1 line
1.7.7.3
#13 lore raw

PATCH v2 5/19 tegra: Use const for pinmux_config_pingroup/table()

In reply to Simon Glass

These two functions don't actually modify their arguments so add a const keyword.

---
Changes in v2:
- Add new patch to use const in pinmux_config_pingroup/table()

 arch/arm/cpu/armv7/tegra2/pinmux.c        |    4 ++--
 arch/arm/include/asm/arch-tegra2/pinmux.h |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/cpu/armv7/tegra2/pinmux.c +2 -2
index b053f90..bf6d40d 100644
@@ -554,7 +554,7 @@ void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func)
 	writel(reg, muxctl);
 }
 
-void pinmux_config_pingroup(struct pingroup_config *config)
+void pinmux_config_pingroup(const struct pingroup_config *config)
 {
 	enum pmux_pingrp pin = config->pingroup;
 
@@ -563,7 +563,7 @@ void pinmux_config_pingroup(struct pingroup_config *config)
 	pinmux_set_tristate(pin, config->tristate);
 }
 
-void pinmux_config_table(struct pingroup_config *config, int len)
+void pinmux_config_table(const struct pingroup_config *config, int len)
 {
 	int i;
 
arch/arm/include/asm/arch-tegra2/pinmux.h +2 -2
index 469d742..13ee790 100644
@@ -339,7 +339,7 @@ void pinmux_set_pullupdown(enum pmux_pingrp pin, enum pmux_pull pupd);
 void pinmux_set_func(enum pmux_pingrp pin, enum pmux_func func);
 
 /* Set the complete configuration for a pin group */
-void pinmux_config_pingroup(struct pingroup_config *config);
+void pinmux_config_pingroup(const struct pingroup_config *config);
 
 void pinmux_set_tristate(enum pmux_pingrp pin, int enable);
 
@@ -349,6 +349,6 @@ void pinmux_set_tristate(enum pmux_pingrp pin, int enable);
  * @param config	List of config items
  * @param len		Number of config items in list
  */
-void pinmux_config_table(struct pingroup_config *config, int len);
+void pinmux_config_table(const struct pingroup_config *config, int len);
 
 #endif	/* PINMUX_H */
Signature · 1 line
1.7.7.3
#14 lore raw

PATCH v2 6/19 tegra: Add display support to funcmux

In reply to Simon Glass

Add support for a default pin mapping for display1.

---
Changes in v2:
- Use const where possible in funcmux

 arch/arm/cpu/armv7/tegra2/funcmux.c |   39 +++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/tegra2/funcmux.c +39 -0
index 0ef7753..9a339cd 100644
@@ -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}
+
+static const 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;
@@ -185,6 +210,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;
Signature · 1 line
1.7.7.3
#15 lore raw

PATCH v2 6/19 tegra: Add display support to funcmux

arch/arm/cpu/armv7/tegra2/funcmux.c line 43

Quoted 5 lines · Simon Glass

Add support for a default pin mapping for display1.

arch/arm/cpu/armv7/tegra2/funcmux.c +3 -0
+static const struct pingroup_config disp1_default[] = {
+	PINMUX(LM0,   RSVD4,      NORMAL,    NORMAL),
+	PINMUX(LPW1,  RSVD4,      NORMAL,    TRISTATE),

Do you really need to explicitly program these pingroups that aren't used by display? It seems like it'll probably still work fine irrespective of whether those are actually configured to output display controller signals or not. However, if those pingroups are used by something else, then changing their configuration here may stop the other functionality from working.

arch/arm/cpu/armv7/tegra2/funcmux.c line 49

Quoted 1 line
arch/arm/cpu/armv7/tegra2/funcmux.c +1 -0
+	PINMUX(SLXD,  SPDIF,      NORMAL,    NORMAL),

Similarly here, yet SLXD doesn't ever support any display functionality, so there should definitely be no need for this entry.

arch/arm/cpu/armv7/tegra2/funcmux.c int funcmux_select(enum periph_id id, int config) · line 212

Quoted 4 lines
arch/arm/cpu/armv7/tegra2/funcmux.c +2 -0
@@ -185,6 +210,20 @@ int funcmux_select(enum periph_id id, int config)
 
+	case PERIPH_ID_DISP1:
+		if (config == FUNCMUX_DEFAULT) {

Shouldn't this option have some kind of name in funcmux.h; there are many many many possible configurations for display, so just assuming this as some kind of default seems a little presumptuous.

But, given the number of possibilities, I wonder if it isn't time to replace funcmux with the device tree pinctrl bindings?

#16 lore raw

PATCH v2 6/19 tegra: Add display support to funcmux

Hi Stephen,

Quoted 14 lines · Stephen Warren

arch/arm/cpu/armv7/tegra2/funcmux.c line 43

Quoted 5 lines · Simon Glass

Add support for a default pin mapping for display1.

arch/arm/cpu/armv7/tegra2/funcmux.c +3 -0
+static const struct pingroup_config disp1_default[] = {
+     PINMUX(LM0,   RSVD4,      NORMAL,    NORMAL),
+     PINMUX(LPW1,  RSVD4,      NORMAL,    TRISTATE),

Do you really need to explicitly program these pingroups that aren't used by display? It seems like it'll probably still work fine irrespective of whether those are actually configured to output display controller signals or not. However, if those pingroups are used by something else, then changing their configuration here may stop the other functionality from working.

Quoted 5 lines
Quoted 1 line

+ PINMUX(SLXD, SPDIF, NORMAL, NORMAL),

Similarly here, yet SLXD doesn't ever support any display functionality, so there should definitely be no need for this entry.

I will remove LPW1, but if I remove any others the LCD stops working.

Quoted 10 lines

arch/arm/cpu/armv7/tegra2/funcmux.c int funcmux_select(enum periph_id id, int config) · line 212

Quoted 5 lines
arch/arm/cpu/armv7/tegra2/funcmux.c +2 -0
@@ -185,6 +210,20 @@ int funcmux_select(enum periph_id id, int config)
 
+     case PERIPH_ID_DISP1:
+             if (config == FUNCMUX_DEFAULT) {

Shouldn't this option have some kind of name in funcmux.h; there are many many many possible configurations for display, so just assuming this as some kind of default seems a little presumptuous.

It could have a name, but what would we call it? Until there is a second option implemented, it seems reasonable to call it the default. That is what was done with keyboard.

Quoted 4 lines

But, given the number of possibilities, I wonder if it isn't time to replace funcmux with the device tree pinctrl bindings?

I suggest we look at this after we get LCD, NAND and all the other pending things in. I haven't seen an fdt binding for Tegra LCD in the kernel yet, so our binding will need looking at as well when it eventually happens.

Regards,
Simon

#17 lore raw

PATCH v2 7/19 tegra: fdt: Add LCD definitions for Tegra

In reply to Simon Glass

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.

I am not sure if it is better to have the lcd within the display controller as with i2c/spi, or a separate node. From a hardware point of view the LCD is certainly connected to the display controller, so perhaps this version makes most sense. We could have a stand-alone top-level lcd node with a phandle pointing to the display controller, but these doesn't seem to be an obvious advantage to that approach.

---
Changes in v2:
- Add nvidia prefix to device tree properties

 arch/arm/dts/tegra20.dtsi                       |   25 +++++++
 doc/device-tree-bindings/video/nvidia-video.txt |   88 +++++++++++++++++++++++
 2 files changed, 113 insertions(+), 0 deletions(-)
 create mode 100644 doc/device-tree-bindings/video/nvidia-video.txt
arch/arm/dts/tegra20.dtsi +25 -0
index f95be58..4e59e9b 100644
@@ -204,4 +204,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>;
+	};
 };
doc/device-tree-bindings/video/nvidia-video.txt new file +88 -0

88 lines not on this page · raw message

Signature · 1 line
1.7.7.3
#18 lore raw

Re: [PATCH v2 07/19] tegra: fdt: Add LCD definitions for Tegra

Quoted 4 lines · Simon Glass

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.

I believe we have settled on a final representation, it just hasn't been added into linux-next yet. See:

http://gitorious.org/linux-pwm/linux-pwm/commit/d3ce73e5dc86646a6302f2b0f7dd40e8c552fa04

Quoted 6 lines

I am not sure if it is better to have the lcd within the display controller as with i2c/spi, or a separate node. From a hardware point of view the LCD is certainly connected to the display controller, so perhaps this version makes most sense. We could have a stand-alone top-level lcd node with a phandle pointing to the display controller, but these doesn't seem to be an obvious advantage to that approach.

Equally, there's been extensive discussion re: how to represent the NVIDIA display controller in DT. I strongly believe that U-Boot shouldn't go ahead in isolation with a binding that's completely unrelated to what's happening in the kernel. Please can you take what Thierry is working on for the kernel, and/or contribute to that binding etc., so we don't end up with multiple ways of doing the same thing. Part of the whole point of DT is to have a single way of representing HW that multiple OSs (or perhaps bootloaders) cna use. If everyone just goes and does their own thing, we've lost.

#19 lore raw

Re: [PATCH v2 07/19] tegra: fdt: Add LCD definitions for Tegra

Hi Stephen,

Quoted 11 lines · Stephen Warren
Quoted 4 lines · Simon Glass

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.

I believe we have settled on a final representation, it just hasn't been added into linux-next yet. See:

http://gitorious.org/linux-pwm/linux-pwm/commit/d3ce73e5dc86646a6302f2b0f7dd40e8c552fa04

Thanks for the pointer. I suppose this doesn't address clocks as yet, but that's fine.

Quoted 9 lines
Quoted 8 lines

I am not sure if it is better to have the lcd within the display controller as with i2c/spi, or a separate node. From a hardware point of view the LCD is certainly connected to the display controller, so perhaps this version makes most sense. We could have a stand-alone top-level lcd node with a phandle pointing to the display controller, but these doesn't seem to be an obvious advantage to that approach.

Quoted 10 lines

Equally, there's been extensive discussion re: how to represent the NVIDIA display controller in DT. I strongly believe that U-Boot shouldn't go ahead in isolation with a binding that's completely unrelated to what's happening in the kernel. Please can you take what Thierry is working on for the kernel, and/or contribute to that binding etc., so we don't end up with multiple ways of doing the same thing. Part of the whole point of DT is to have a single way of representing HW that multiple OSs (or perhaps bootloaders) cna use. If everyone just goes and does their own thing, we've lost.

I can see the email here.

http://lists.freedesktop.org/archives/dri-devel/2012-April/021223.html

I posted this series originally in January. That email is from April, and I don't see activity in the last 2 months. As previously discussed it is not productive to chase a moving target.

Thierry, have you settled on a binding yet? If not do you have something sort-of close that I could use in U-Boot?

Regards.
Simon

_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

#20 lore raw

Re: [PATCH v2 07/19] tegra: fdt: Add LCD definitions for Tegra

Quoted 14 lines · Simon Glass

Hi Stephen,

Quoted 10 lines · Stephen Warren
Quoted 4 lines · Simon Glass

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.

I believe we have settled on a final representation, it just hasn't been added into linux-next yet. See:

Quoted 5 lines
Quoted 1 line

http://gitorious.org/linux-pwm/linux-pwm/commit/d3ce73e5dc86646a6302f2b0f7dd40e8c552fa04

Thanks for the pointer. I suppose this doesn't address clocks as yet, but that's fine.

I was waiting for the common clock framework and DT bindings to get ready. This should happen RSN for Tegra so I will probably look at adding support for it in.

By the way, the PWM tree has now been in linux-next for a couple of weeks and I plan to submit it for inclusion in 3.6.

Quoted 18 lines
Quoted 7 lines
Quoted 6 lines

I am not sure if it is better to have the lcd within the display controller as with i2c/spi, or a separate node. From a hardware point of view the LCD is certainly connected to the display controller, so perhaps this version makes most sense. We could have a stand-alone top-level lcd node with a phandle pointing to the display controller, but these doesn't seem to be an obvious advantage to that approach.

Quoted 10 lines

Equally, there's been extensive discussion re: how to represent the NVIDIA display controller in DT. I strongly believe that U-Boot shouldn't go ahead in isolation with a binding that's completely unrelated to what's happening in the kernel. Please can you take what Thierry is working on for the kernel, and/or contribute to that binding etc., so we don't end up with multiple ways of doing the same thing. Part of the whole point of DT is to have a single way of representing HW that multiple OSs (or perhaps bootloaders) cna use. If everyone just goes and does their own thing, we've lost.

Quoted 7 lines

I can see the email here.

http://lists.freedesktop.org/archives/dri-devel/2012-April/021223.html

I posted this series originally in January. That email is from April, and I don't see activity in the last 2 months. As previously discussed it is not productive to chase a moving target.

I had hoped I could get this finished much faster, but then things happened. However there has been quite some progress in the meantime.

I actually based that very first version on what you had in the earlier Tegra LCD series with a couple of additions to support DRM specificities. However the proposal was shot down pretty early mainly because the display timing description was very Tegra specific. One proposal was to include an EDID blob directly into the DT and pass it on to DRM, which is what the current code does.

Lately there's been some work on adding a generic description for display timings:

	http://lists.freedesktop.org/archives/dri-devel/2012-July/024875.html

I haven't tested that code yet, but it might turn out to be an interesting replacement for the EDID blob.

Quoted 2 lines

Thierry, have you settled on a binding yet? If not do you have something sort-of close that I could use in U-Boot?

The currently accepted form (as in "Stephen said it looks reasonable") is here:

	http://lists.freedesktop.org/archives/dri-devel/2012-July/024899.html

It currently only defines the bindings for the RGB and HDMI outputs, but that should be fine since from what I can tell your U-Boot driver supports RGB only anyway. It is probably also way more than you really need in U-Boot because it has DT nodes for all the graphics-related modules.

Thierry

_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

#21 lore raw

Re: [PATCH v2 07/19] tegra: fdt: Add LCD definitions for Tegra

Hi Thierry,

Quoted 18 lines · Thierry Reding
Quoted 17 lines · Simon Glass

Hi Stephen,

Quoted 11 lines · Stephen Warren
Quoted 4 lines · Simon Glass

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.

I believe we have settled on a final representation, it just hasn't been added into linux-next yet. See:

http://gitorious.org/linux-pwm/linux-pwm/commit/d3ce73e5dc86646a6302f2b0f7dd40e8c552fa04

Quoted 6 lines
Quoted 2 lines

Thanks for the pointer. I suppose this doesn't address clocks as yet, but that's fine.

I was waiting for the common clock framework and DT bindings to get ready. This should happen RSN for Tegra so I will probably look at adding support for it in.

OK, are you looking at adding it in U-Boot?

Quoted 3 lines

By the way, the PWM tree has now been in linux-next for a couple of weeks and I plan to submit it for inclusion in 3.6.

Yes Stephen pointed me to that so I picked it up, thanks.

Quoted 37 lines
Quoted 19 lines
Quoted 8 lines
Quoted 7 lines

I am not sure if it is better to have the lcd within the display controller as with i2c/spi, or a separate node. From a hardware point of view the LCD is certainly connected to the display controller, so perhaps this version makes most sense. We could have a stand-alone top-level lcd node with a phandle pointing to the display controller, but these doesn't seem to be an obvious advantage to that approach.

Quoted 10 lines

Equally, there's been extensive discussion re: how to represent the NVIDIA display controller in DT. I strongly believe that U-Boot shouldn't go ahead in isolation with a binding that's completely unrelated to what's happening in the kernel. Please can you take what Thierry is working on for the kernel, and/or contribute to that binding etc., so we don't end up with multiple ways of doing the same thing. Part of the whole point of DT is to have a single way of representing HW that multiple OSs (or perhaps bootloaders) cna use. If everyone just goes and does their own thing, we've lost.

Quoted 7 lines

I can see the email here.

http://lists.freedesktop.org/archives/dri-devel/2012-April/021223.html

I posted this series originally in January. That email is from April, and I don't see activity in the last 2 months. As previously discussed it is not productive to chase a moving target.

I had hoped I could get this finished much faster, but then things happened. However there has been quite some progress in the meantime.

I actually based that very first version on what you had in the earlier Tegra LCD series with a couple of additions to support DRM specificities. However the proposal was shot down pretty early mainly because the display timing description was very Tegra specific. One proposal was to include an EDID blob directly into the DT and pass it on to DRM, which is what the current code does.

Quoted 7 lines

Lately there's been some work on adding a generic description for display timings:

        http://lists.freedesktop.org/archives/dri-devel/2012-July/024875.html

I haven't tested that code yet, but it might turn out to be an interesting replacement for the EDID blob.

Yes I prefer it, it is much easier to see what is going on. I will put something together based on that.

Quoted 7 lines
Quoted 3 lines

Thierry, have you settled on a binding yet? If not do you have something sort-of close that I could use in U-Boot?

The currently accepted form (as in "Stephen said it looks reasonable") is here:

Quoted 7 lines
        http://lists.freedesktop.org/archives/dri-devel/2012-July/024899.html

It currently only defines the bindings for the RGB and HDMI outputs, but that should be fine since from what I can tell your U-Boot driver supports RGB only anyway. It is probably also way more than you really need in U-Boot because it has DT nodes for all the graphics-related modules.

I also need a place to put the pwm and GPIOs for the panel itself. Something like this:

		nvidia,pwm = <&pwm 2 0>;
		nvidia,backlight-enable-gpios = <&gpio 28 0>;	/* PD4 */
		nvidia,lvds-shutdown-gpios = <&gpio 10 0>;	/* PB2 */
		nvidia,backlight-vdd-gpios = <&gpio 176 0>;	/* PW0 */
		nvidia,panel-vdd-gpios = <&gpio 22 0>;		/* PC6 */
		nvidia,panel-timings = <4 203 17 15>;  (number of ms before turning
on the next gpio)
		nvidia,bits-per-pixel = <16>;    (er, TBD)

I am thinking of something like a phandle in your rgb node:

	host1x {
		dc@54200000 {
			rgb {
				nvidia-panel = <&lcd_panel>;

...

	lcd_panel: panel {
		nvidia,pwm = <&pwm 2 0>;
                ...
        }

Or have you already solved this problem another way?

Regards,
Simon

Quoted 2 lines

Thierry

#22 lore raw

Re: [PATCH v2 07/19] tegra: fdt: Add LCD definitions for Tegra

Quoted 22 lines · Simon Glass

Hi Thierry,

Quoted 18 lines · Thierry Reding
Quoted 17 lines · Simon Glass

Hi Stephen,

Quoted 11 lines · Stephen Warren
Quoted 4 lines · Simon Glass

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.

I believe we have settled on a final representation, it just hasn't been added into linux-next yet. See:

http://gitorious.org/linux-pwm/linux-pwm/commit/d3ce73e5dc86646a6302f2b0f7dd40e8c552fa04

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Thanks for the pointer. I suppose this doesn't address clocks as yet, but that's fine.

I was waiting for the common clock framework and DT bindings to get ready. This should happen RSN for Tegra so I will probably look at adding support for it in.

OK, are you looking at adding it in U-Boot?

No. I don't have much time to spend on U-Boot right now.

[...]

Quoted 18 lines

I also need a place to put the pwm and GPIOs for the panel itself. Something like this:

		nvidia,pwm = <&pwm 2 0>;
		nvidia,backlight-enable-gpios = <&gpio 28 0>;	/* PD4 */
		nvidia,lvds-shutdown-gpios = <&gpio 10 0>;	/* PB2 */
		nvidia,backlight-vdd-gpios = <&gpio 176 0>;	/* PW0 */
		nvidia,panel-vdd-gpios = <&gpio 22 0>;		/* PC6 */
		nvidia,panel-timings = <4 203 17 15>;  (number of ms before turning
on the next gpio)
		nvidia,bits-per-pixel = <16>;    (er, TBD)

I am thinking of something like a phandle in your rgb node:

	host1x {
		dc@54200000 {
			rgb {
				nvidia-panel = <&lcd_panel>;
Quoted 8 lines

...

	lcd_panel: panel {
		nvidia,pwm = <&pwm 2 0>;
                ...
        }

Or have you already solved this problem another way?

Linux has a generic PWM backlight driver. This is currently solved by using this in the DT:

	backlight {
		compatible = "pwm-backlight";
		pwms = <&pwm 0 5000000>;

		brightness-levels = <0 4 8 16 32 64 128 255>;
		default-brightness-level = <6>;
	};

Alex Courbot (Cc'd) has been working on adding a generic way to add GPIO and regulator support to that. I don't know exactly what the lvds-shutdown-gpios and panel-vdd-gpios properties do. If they control hardware connected behind the display controller I suppose they could go into the rgb node.

The panel alternative that you propose sounds interesting as well. Maybe the panel should itself contain either a phandle or a subnode for the backlight and collect the properties that you listed above.

Thierry

_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

#23 lore raw

Re: [PATCH v2 07/19] tegra: fdt: Add LCD definitions for Tegra

Quoted 11 lines · Thierry Reding

Linux has a generic PWM backlight driver. This is currently solved by using this in the DT:

	backlight {
		compatible = "pwm-backlight";
		pwms = <&pwm 0 5000000>;

		brightness-levels = <0 4 8 16 32 64 128 255>;
		default-brightness-level = <6>;
	};
Quoted 5 lines

Alex Courbot (Cc'd) has been working on adding a generic way to add GPIO and regulator support to that. I don't know exactly what the lvds-shutdown-gpios and panel-vdd-gpios properties do. If they control hardware connected behind the display controller I suppose they could go into the rgb node.

Thanks for bringing that back to light - the patches did not receive any feedback so far. If Simon wants to have a look, the one in the series that touches the device tree is here: https://lkml.org/lkml/2012/7/9/30

The idea is to extend pwm-backlight to support the GPIOs and regulators that may be related to the backlight, and order them into proper power sequences that were so far done by callbacks in board files. So your nvidia,pwm , nvidia,backlight-enable-gpios and nvidia,backlight-vdd-gpios properties would be moved into the backlight node and their appropriate power sequences (including any delay required by the panel specification) would be written.

Actually, the power sequences code is independent from the backlight and could be used in other areas as well. Looking at your panel node, which also uses gpios and has a timings table, it might make sense to use them there as well.

Quoted 3 lines

The panel alternative that you propose sounds interesting as well. Maybe the panel should itself contain either a phandle or a subnode for the backlight and collect the properties that you listed above.

The panel and backlight should definitely be connected in some way. But since they are controlled independantly, I'm not sure about the implications of having them represented hierarchically in the DT.

Alex.

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

#24 lore raw

PATCH v2 8/19 tegra: Add support for PWFM

In reply to Simon Glass

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

---

 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
arch/arm/cpu/armv7/tegra2/Makefile +1 -0
index 08c4137..9779e9e 100644
@@ -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)
arch/arm/cpu/armv7/tegra2/pwfm.c new file +40 -0
new file mode 100644
index 0000000..cdb0cbe
@@ -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);
+}
arch/arm/include/asm/arch-tegra2/pwfm.h new file +54 -0

54 lines not on this page · raw message

Signature · 1 line
1.7.7.3
#25 lore raw

PATCH v2 8/19 tegra: Add support for PWFM

Quoted 2 lines · Simon Glass

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

Surely this should be modeled as a driver that's instantiated from DT, which provides n PWMs. As such, I'd expect the driver to have some kind of init/probe function, and:

arch/arm/include/asm/arch-tegra2/pwfm.h line 52

Quoted 2 lines
arch/arm/include/asm/arch-tegra2/pwfm.h new file +2 -0
+void pwfm_enable(struct pwfm_ctlr *pwfm, int rate, int pulse_width,
+		int freq_divider);

to take a pwm_id parameter too.

#26 lore raw

PATCH v2 8/19 tegra: Add support for PWFM

Hi Stephen,

Quoted 4 lines · Stephen Warren
Quoted 2 lines · Simon Glass

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

Quoted 9 lines

Surely this should be modeled as a driver that's instantiated from DT, which provides n PWMs. As such, I'd expect the driver to have some kind of init/probe function, and:

arch/arm/include/asm/arch-tegra2/pwfm.h line 52

Quoted 2 lines
arch/arm/include/asm/arch-tegra2/pwfm.h new file +2 -0
+void pwfm_enable(struct pwfm_ctlr *pwfm, int rate, int pulse_width,
+             int freq_divider);

to take a pwm_id parameter too.

OK I will do something along those lines.

Regards,
Simon

#27 lore raw

PATCH v2 9/19 tegra: Add SOC support for display/lcd

In reply to Simon Glass

From: Wei Ni <[email protected]>

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

---

 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
arch/arm/cpu/armv7/tegra2/Makefile +1 -1
index 9779e9e..413f8c9 100644
@@ -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)
arch/arm/cpu/armv7/tegra2/display.c new file +271 -0

271 lines not on this page · raw message

arch/arm/include/asm/arch-tegra2/dc.h new file +544 -0

544 lines not on this page · raw message

arch/arm/include/asm/arch-tegra2/display.h new file +133 -0

133 lines not on this page · raw message

Signature · 1 line
1.7.7.3
#28 lore raw

PATCH v2 9/19 tegra: Add SOC support for display/lcd

Quoted 15 lines · Simon Glass

From: Wei Ni <[email protected]>

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

arch/arm/include/asm/arch-tegra2/display.h +8 -0
 
+/**
+ * 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 at 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

arch/arm/include/asm/arch-tegra2/display.h line 124

Quoted 10 lines
arch/arm/include/asm/arch-tegra2/display.h +10 -0
+ * 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);

The prototype in the header seems to be the only mention of this function.

A message that is not in the archive (sent off-list or not yet received): CAPnjgZ2bqPx+dHD9m+NuFrAbBeP1PQxHokLMwvD1-3OnC6ZHtg@mail.gmail.com

#30 lore raw

PATCH v2 9/19 tegra: Add SOC support for display/lcd

Quoted 47 lines · Simon Glass

Hi Stephen,

Quoted 25 lines · Stephen Warren

Review

Quoted 6 lines · Simon Glass

From: Wei Ni <[email protected]>

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

(quoted diff) +0 -0

b/arch/arm/include/asm/arch-tegra2/display.h

Quoted 4 lines

+/**
+ * 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

Quoted 4 lines

+ * while waiting for the backlight power supply, etc. This function can
+ * be called at 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

Quoted 6 lines

+ * 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

Quoted 9 lines

return

Quoted 1 line

+ * 0 to return immediately, potentially doing nothing if it

is

Quoted 3 lines

+ * not yet time for the next init.
+ */
+int tegra_lcd_check_next_stage(const void *blob, int wait);

The prototype in the header seems to be the only mention of this function.

In my copy of the patches it is defined in the driver (drivers/video/tegra.c). I will move it to the same patch.

Regards,
Simon

#31 lore raw

PATCH v2 10/19 tegra: Add LCD driver

In reply to Simon Glass

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

---
Changes in v2:
- Update LCD driver to deal with new fdt bindings

 drivers/video/Makefile |    1 +
 drivers/video/tegra.c  |  383 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/fdtdec.h       |    1 +
 lib/fdtdec.c           |    1 +
 4 files changed, 386 insertions(+), 0 deletions(-)
 create mode 100644 drivers/video/tegra.c
drivers/video/Makefile +1 -0
index 4fad20d..d7518c4 100644
@@ -46,6 +46,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))
drivers/video/tegra.c new file +383 -0

383 lines not on this page · raw message

include/fdtdec.h +1 -0
index 627d077..c1aad5c 100644
@@ -65,6 +65,7 @@ enum fdt_compat_id {
 	COMPAT_NVIDIA_TEGRA20_EMC,	/* Tegra2 memory controller */
 	COMPAT_NVIDIA_TEGRA20_EMC_TABLE, /* Tegra2 memory timing table */
 	COMPAT_NVIDIA_TEGRA20_KBC,	/* Tegra2 Keyboard */
+	COMPAT_NVIDIA_TEGRA20_DISPLAY,	/* Tegra 2 Display controller */
 
 	COMPAT_COUNT,
 };
lib/fdtdec.c +1 -0
index 8185d8f..2d68c17 100644
@@ -43,6 +43,7 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(NVIDIA_TEGRA20_EMC, "nvidia,tegra20-emc"),
 	COMPAT(NVIDIA_TEGRA20_EMC_TABLE, "nvidia,tegra20-emc-table"),
 	COMPAT(NVIDIA_TEGRA20_KBC, "nvidia,tegra20-kbc"),
+	COMPAT(NVIDIA_TEGRA20_DISPLAY, "nvidia,tegra20-display"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
Signature · 1 line
1.7.7.3
#32 lore raw

PATCH v2 10/19 tegra: Add LCD driver

drivers/video/tegra.c line 257

Quoted 7 lines · Simon Glass

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

drivers/video/tegra.c new file +3 -0
+int fdt_decode_lcd(const void *blob, struct fdt_lcd *config)
 
+	fdtdec_decode_gpio(blob, display_node, "nvidia,backlight-vdd-gpios",
+			   &config->backlight_vdd);

Given that's a power supply control, I expect this to be represented as a regulator in the DT, not as a simple GPIO (it could be controlled by a register bit in a PMU on some boards).

Quoted 7 lines
drivers/video/tegra.c new file +7 -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().
+	 *

drivers/video/tegra.c line 383

Quoted 10 lines
drivers/video/tegra.c new file +10 -0
+	 * 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);
+	}
+}

I wonder why even read the configuration from DT if the value can't be used?

lib/fdtdec.c static const char * const compat_names[COMPAT_COUNT] = { · line 44

Quoted 5 lines
lib/fdtdec.c +1 -0
@@ -43,6 +43,7 @@ static const char * const compat_names[COMPAT_COUNT] = {
 
+	COMPAT(NVIDIA_TEGRA20_DISPLAY, "nvidia,tegra20-display"),

Surely all the DT plumbing for the display controller itself should be in the previous patch that adds the display controller driver.

The LCD stuff that sits on top of that seems like it should be a separate node in DT, and the two patches kept much more separate.

#33 lore raw

PATCH v2 10/19 tegra: Add LCD driver

Hi Stephen,

Quoted 6 lines · Stephen Warren
Quoted 4 lines · Simon Glass

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

+int fdt_decode_lcd(const void *blob, struct fdt_lcd *config)

Quoted 8 lines
Quoted 1 line

+ fdtdec_decode_gpio(blob, display_node,

"nvidia,backlight-vdd-gpios",

Quoted 1 line

+ &config->backlight_vdd);

Given that's a power supply control, I expect this to be represented as a regulator in the DT, not as a simple GPIO (it could be controlled by a register bit in a PMU on some boards).

Hmm we don't have regulator support in U-Boot as yet. Any ideas? It is possible that it might come towards the end of the year as part of some other upstreaming work, but I am not sure. At lot of these sorts of things are really hard in U-Boot until we have a device model.

Quoted 14 lines

drivers/video/tegra.c

Quoted 8 lines
drivers/video/tegra.c new file +8 -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.

drivers/video/tegra.c

Quoted 5 lines
drivers/video/tegra.c new file +5 -0
+      * 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 =
Quoted 9 lines

%dbpp)"

drivers/video/tegra.c line 383

Quoted 4 lines
drivers/video/tegra.c new file +4 -0
+                     " must match setting of LCD_BPP (%d)\n", __func__,
+                    config.log2_bpp, config.bpp, LCD_BPP);
+     }
+}

I wonder why even read the configuration from DT if the value can't be used?

The conflict is in one place and has a clear warning, so if U-Boot does support this in the future, we can adjust it.

Quoted 6 lines

lib/fdtdec.c static const char * const compat_names[COMPAT_COUNT] =

Quoted 4 lines
lib/fdtdec.c +0 -0
@@ -43,6 +43,7 @@ static const char * const compat_names[COMPAT_COUNT] =

{

Quoted 8 lines

lib/fdtdec.c static const char * const compat_names[COMPAT_COUNT] = { · line 46

Quoted 1 line
lib/fdtdec.c +1 -0
+     COMPAT(NVIDIA_TEGRA20_DISPLAY, "nvidia,tegra20-display"),

Surely all the DT plumbing for the display controller itself should be in the previous patch that adds the display controller driver.

The LCD stuff that sits on top of that seems like it should be a separate node in DT, and the two patches kept much more separate.

I have made the LCD a subnode of the display controller. Let's see what Thierry says about the kernel binding.

I will move this compatible string to the previous patch.

Regards,
Simon

#34 lore raw

PATCH v2 11/19 tegra: Add LCD support to Nvidia boards

In reply to Simon Glass

Add calls to the LCD driver from Nvidia board code.

---

 board/nvidia/common/board.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
board/nvidia/common/board.c +20 -1
index 2e22133..7666691 100644
@@ -29,6 +29,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>
@@ -87,6 +88,9 @@ int board_init(void)
 {
 	__maybe_unused int err;
 
+#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();
@@ -122,6 +126,9 @@ int board_init(void)
 	pin_mux_usb();
 	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 */
@@ -142,6 +149,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;
+}
Signature · 1 line
1.7.7.3
#35 lore raw

PATCH v2 11/19 tegra: Add LCD support to Nvidia boards

board/nvidia/common/board.c int board_init(void) · line 91

Quoted 9 lines · Simon Glass

Add calls to the LCD driver from Nvidia board code.

board/nvidia/common/board.c +3 -0
@@ -87,6 +88,9 @@ int board_init(void)
 
+#ifdef CONFIG_VIDEO_TEGRA2
+	tegra_lcd_check_next_stage(gd->blob, 0);
+#endif

This seems to be conflating video support with LCD support. It would be quite possible to have a board with no LCD, yet supporting display over HDMI for example. In other words, shouldn't the ifdef above be something more like:

#if define(CONFIG_LCD_SUPPORT)
	register_lcd_driver();
#endif
#if defined(CONFIG_VIDEO_TEGRA2)
	tegra_display_init(...);

#endif

and internal to tegra_display_init(), the DT is searched for LCD controller nodes, and if any are found, they're matched to the LCD driver registered by the first call above.

#36 lore raw

PATCH v2 11/19 tegra: Add LCD support to Nvidia boards

Hi Stephen,

Quoted 21 lines · Stephen Warren

board/nvidia/common/board.c int board_init(void) · line 91

Quoted 9 lines · Simon Glass

Add calls to the LCD driver from Nvidia board code.

board/nvidia/common/board.c +3 -0
@@ -87,6 +88,9 @@ int board_init(void)
 
+#ifdef CONFIG_VIDEO_TEGRA2
+     tegra_lcd_check_next_stage(gd->blob, 0);
+#endif

This seems to be conflating video support with LCD support. It would be quite possible to have a board with no LCD, yet supporting display over HDMI for example. In other words, shouldn't the ifdef above be something more like:

#if define(CONFIG_LCD_SUPPORT)
        register_lcd_driver();
#endif
#if defined(CONFIG_VIDEO_TEGRA2)
        tegra_display_init(...);
Quoted 6 lines

#endif

and internal to tegra_display_init(), the DT is searched for LCD controller nodes, and if any are found, they're matched to the LCD driver registered by the first call above.

Yes that sounds great, but again we don't really have this infrastructure in U-Boot. We would be inventing it just for Tegra, and I would prefer to wait until the device model stuff is done before being too fancy.

We don't have an HDMI driver at present, so perhaps if/when that appears in U-Boot it would be a good time to add support for that?

Regards,
Simon

#37 lore raw

PATCH v2 11/19 tegra: Add LCD support to Nvidia boards

Quoted 33 lines · Simon Glass

Hi Stephen,

On Fri, Jun 15, 2012 at 1:47 AM, Stephen Warren <[email protected] <mailto:[email protected]>> wrote:

    On 06/13/2012 10:19 AM, Simon Glass wrote:
    > Add calls to the LCD driver from Nvidia board code.

    > diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c

    > @@ -87,6 +88,9 @@ int board_init(void)

    > +#ifdef CONFIG_VIDEO_TEGRA2
    > +     tegra_lcd_check_next_stage(gd->blob, 0);
    > +#endif

    This seems to be conflating video support with LCD support. It would be
    quite possible to have a board with no LCD, yet supporting display over
    HDMI for example. In other words, shouldn't the ifdef above be something
    more like:

    #if define(CONFIG_LCD_SUPPORT)
            register_lcd_driver();
    #endif
    #if defined(CONFIG_VIDEO_TEGRA2)
            tegra_display_init(...);
    #endif

    and internal to tegra_display_init(), the DT is searched for LCD
    controller nodes, and if any are found, they're matched to the LCD
    driver registered by the first call above.
Quoted 4 lines

Yes that sounds great, but again we don't really have this infrastructure in U-Boot. We would be inventing it just for Tegra, and I would prefer to wait until the device model stuff is done before being too fancy.

What is "the device model stuff" you mention?

Quoted 2 lines

We don't have an HDMI driver at present, so perhaps if/when that appears in U-Boot it would be a good time to add support for that?

Certainly adding code for HDMI can wait until later. However, I do think that we should use the correct ifdefs up-front, so that e.g. adding HDMI support only means adding a bunch of code, not going through the existing code and untangling conflated ifdefs.

#38 lore raw

PATCH v2 11/19 tegra: Add LCD support to Nvidia boards

Hi Stephen,

Quoted 34 lines · Stephen Warren
Quoted 33 lines · Simon Glass

Hi Stephen,

On Fri, Jun 15, 2012 at 1:47 AM, Stephen Warren <[email protected] <mailto:[email protected]>> wrote:

    On 06/13/2012 10:19 AM, Simon Glass wrote:
    > Add calls to the LCD driver from Nvidia board code.

    > diff --git a/board/nvidia/common/board.c b/board/nvidia/common/board.c

    > @@ -87,6 +88,9 @@ int board_init(void)

    > +#ifdef CONFIG_VIDEO_TEGRA2
    > +     tegra_lcd_check_next_stage(gd->blob, 0);
    > +#endif

    This seems to be conflating video support with LCD support. It would be
    quite possible to have a board with no LCD, yet supporting display over
    HDMI for example. In other words, shouldn't the ifdef above be something
    more like:

    #if define(CONFIG_LCD_SUPPORT)
            register_lcd_driver();
    #endif
    #if defined(CONFIG_VIDEO_TEGRA2)
            tegra_display_init(...);
    #endif

    and internal to tegra_display_init(), the DT is searched for LCD
    controller nodes, and if any are found, they're matched to the LCD
    driver registered by the first call above.
Quoted 6 lines
Quoted 4 lines

Yes that sounds great, but again we don't really have this infrastructure in U-Boot. We would be inventing it just for Tegra, and I would prefer to wait until the device model stuff is done before being too fancy.

What is "the device model stuff" you mention?

There is an effort in U-Boot to create a unified device model, which would permit things like the register_lcd_driver() call you show above. At present we have hard-coded calls to various things in U-Boot. This means that in many cases it is only possible to have one driver of each time.

This also applied to LCD - at present it wouldn't be possible to support HDMI separate from LCD, unless the HDMI stuff was perhaps done through the separate CONFIG_VIDEO option. That would be odd though, since we are using the display controller.

Maybe I am wrong, but this doesn't seem like the right time to address this issue. Once the device model is in, we will find this sort of thing much easier and cleaner.

Quoted 8 lines
Quoted 3 lines

We don't have an HDMI driver at present, so perhaps if/when that appears in U-Boot it would be a good time to add support for that?

Certainly adding code for HDMI can wait until later. However, I do think that we should use the correct ifdefs up-front, so that e.g. adding HDMI support only means adding a bunch of code, not going through the existing code and untangling conflated ifdefs.

Well you are right, it is conflated, although not only in the ifdefs! I'm afraid that all the code currently deals with setting up the display driver for an LCD - e.g. the code in display.c which sets up clocks and LCD outputs/pinmux, plus the whole of drivers/video/tegra.c. To be honest, the ifdefs are the least of our problems.

For HDMI the whole thing would need another look I believe. But the purpose of this series is to provide LCD support on Tegra and unfortunately it isn't clear to me what the differences might be for HDMI.

I will change this to use CONFIG_LCD since it is definitely more correct.

Regards,
Simon

#39 lore raw

PATCH v2 12/19 arm: Add control over cachability of memory regions

In reply to Simon Glass

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.

---

 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(-)
arch/arm/cpu/armv7/cache_v7.c +11 -0
index 1b4e808..5f6d039 100644
@@ -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
arch/arm/include/asm/system.h +30 -0
index 2b28a26..f52a4fc 100644
@@ -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)
arch/arm/lib/cache-cp15.c +51 -11

100 lines not on this page · raw message

Signature · 1 line
1.7.7.3
#40 lore raw

PATCH v2 12/19 arm: Add control over cachability of memory regions

Quoted 8 lines · Simon Glass

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.

Wouldn't performance be significantly better if the region was fully cached, but flushed after each display surface update?

#41 lore raw

PATCH v2 12/19 arm: Add control over cachability of memory regions

Hi Stephen,

Quoted 5 lines · Stephen Warren
Quoted 4 lines · Simon Glass

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.

Quoted 9 lines
Quoted 3 lines

It is implemented only for ARMv7 at present.

This is needed for LCD support, where we want to make the LCD frame

buffer

Quoted 1 line

write-through (or off) rather than write-back.

Wouldn't performance be significantly better if the region was fully cached, but flushed after each display surface update?

That is the setting used on Tegra, yes. This function permits selection of the three options.

Regards,
Simon

#42 lore raw

PATCH v2 13/19 lcd: Add CONFIG_LCD_ALIGNMENT to select frame buffer alignment

In reply to Simon Glass

The normal alignment is PAGE_SIZE, but if this is defined, we can support other alignments.

The motivation for this change is to make the display section-aligned on ARM so that we can easily turn off data caching for the frame buffer region without resorting to level 2 page tables.

---
Changes in v2:
- Use a more generic config CONFIG_LCD_ALIGNMENT for lcd alignment

 README        |   10 ++++++++++
 common/lcd.c  |   24 +++++++++++++++++++-----
 include/lcd.h |    3 +++
 3 files changed, 32 insertions(+), 5 deletions(-)
README +10 -0
index 67dc444..ccdddbf 100644
@@ -1398,6 +1398,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_LCD_ALIGNMENT
+
+		Normally the LCD is page-aligned (tyically 4KB). If this is
+		defined then the LCD will be aligned to this value instead.
+		For ARM it is sometimes useful to use MMU_SECTION_SIZE
+		here, since it is cheaper to change data cache settings on
+		a per-section basis.
+
+
 - Splash Screen Support: CONFIG_SPLASH_SCREEN
 
 		If this option is set, the environment is checked for
common/lcd.c +19 -5
index bf1a6a9..c915a49 100644
@@ -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
@@ -72,6 +75,10 @@
 # endif
 #endif
 
+#ifndef CONFIG_LCD_ALIGNMENT
+#define CONFIG_LCD_ALIGNMENT PAGE_SIZE
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 ulong lcd_setmem (ulong addr);
@@ -330,6 +337,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 +350,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 +462,16 @@ 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 */
+	size = ALIGN(size, CONFIG_LCD_ALIGNMENT);
+	addr = ALIGN(addr - CONFIG_LCD_ALIGNMENT + 1, CONFIG_LCD_ALIGNMENT);
 
 	/* Allocate pages for the frame buffer. */
 	addr -= size;
include/lcd.h +3 -0
index 3d9ef16..5016d6b 100644
@@ -281,6 +281,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						*/
 /************************************************************************/
Signature · 1 line
1.7.7.3
#43 lore raw

PATCH v2 14/19 lcd: Add support for flushing LCD fb from dcache after update

In reply to Simon Glass

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

---
Changes in v2:
- Put the LCD cache flush logic into lcd_putc() instead of lcd_puts()

 common/cmd_echo.c |    3 ++-
 common/lcd.c      |   45 ++++++++++++++++++++++++++++++++++++++-------
 include/lcd.h     |    8 ++++++++
 3 files changed, 48 insertions(+), 8 deletions(-)
common/cmd_echo.c +2 -1
index 43a6da5..12efbab 100644
@@ -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;
 }
common/lcd.c +38 -7

93 lines not on this page · raw message

include/lcd.h +8 -0
index 5016d6b..7c2dae2 100644
@@ -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
Signature · 1 line
1.7.7.3
#44 lore raw

PATCH v2 14/19 lcd: Add support for flushing LCD fb from dcache after update

common/cmd_echo.c int do_echo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 49

Quoted 9 lines · Simon Glass

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

common/cmd_echo.c +2 -1
 
+	/* Use puts() so that the LCD sees it as a new line */
 	if (putnl)
-		putc('\n');
+		puts("\n");

That seems fragile - what if someone comes along and uses putc() in some other code without having a clue that this requirement exists? What stops putc() from detecting \n just like puts()?

#45 lore raw

PATCH v2 14/19 lcd: Add support for flushing LCD fb from dcache after update

Hi Stephen,

Quoted 6 lines · Stephen Warren
Quoted 4 lines · Simon Glass

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

common/cmd_echo.c +0 -0
Quoted 9 lines

common/cmd_echo.c int do_echo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 49

Quoted 4 lines
common/cmd_echo.c +2 -1
+     /* Use puts() so that the LCD sees it as a new line */
      if (putnl)
-             putc('\n');
+             puts("\n");

That seems fragile - what if someone comes along and uses putc() in some other code without having a clue that this requirement exists? What stops putc() from detecting \n just like puts()?

Yes, actually that change isn't needed, I will remove it.

Regards,
Simon

#46 lore raw

PATCH v2 15/19 tegra: Align LCD frame buffer to section boundary

In reply to Simon Glass

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.

---
Changes in v2:
- Align tegra display using new CONFIG_LCD_ALIGNMENT feature

 include/configs/tegra2-common.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
include/configs/tegra2-common.h +3 -0
index 068ce88..0420098 100644
@@ -45,6 +45,9 @@
 
 #define CONFIG_ARCH_CPU_INIT		/* Fire up the A9 core */
 
+/* Align LCD to 1MB boundary */
+#define CONFIG_LCD_ALIGNMENT	MMU_SECTION_SIZE
+
 #include <asm/arch/tegra2.h>		/* get chip and board defs */
 
 /*
Signature · 1 line
1.7.7.3
#47 lore raw

PATCH v2 16/19 tegra: Support control of cache settings for LCD

In reply to Simon Glass

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

---

 drivers/video/tegra.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
drivers/video/tegra.c +9 -0
index 12518b2..15e10f7 100644
@@ -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);
 }
 
Signature · 1 line
1.7.7.3
#48 lore raw

PATCH v2 18/19 lcd: Add CONSOLE_SCROLL_LINES option to speed console

In reply to Simon Glass

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.

---

 README       |    6 ++++++
 common/lcd.c |   15 +++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)
README +6 -0
index ccdddbf..cb2c6cf 100644
@@ -1407,6 +1407,12 @@ The following options need to be configured:
 		here, since it is cheaper to change data cache settings on
 		a per-section basis.
 
+		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
 
common/lcd.c +13 -2
index 758f158..b4e0853 100644
@@ -134,12 +134,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;
 }
 
 /*----------------------------------------------------------------------*/
Signature · 1 line
1.7.7.3
#49 lore raw

PATCH v2 19/19 tegra: Enable display/lcd support on Seaboard

In reply to Simon Glass

From: Mayuresh Kulkarni <[email protected]>

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

---

 include/configs/seaboard.h |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
include/configs/seaboard.h +10 -2
index 1d1176a..ed87bbe 100644
@@ -62,6 +62,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
@@ -111,6 +112,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 */
Signature · 1 line
1.7.7.3
#50 lore raw

v2 cover tegra: Add display driver and LCD support for Seaboard

In reply to Simon Glass
Quoted 3 lines · Simon Glass

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.

Simon,

This series doesn't apply to u-boot-tegra/master cleanly; there are a couple trivial conflicts in arch/arm/cpu/armv7/tegra2/Makefile to resolve, but I had to apply the final patch completely by hand.

When I run the resultant binary, I see the LCD backlight turn on, but the image on the LCD is wrong; it starts completely black without any text showing, then slowly fills in to white/gray with many horizontal and vertical black lines; I guess the LCD timing is incorrect - are there multiple different LCD models? Note that I am using a real Seaboard not a Springbank for this test.

#51 lore raw

v2 cover tegra: Add display driver and LCD support for Seaboard

Quoted 11 lines · Stephen Warren
Quoted 3 lines · Simon Glass

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.

Simon,

This series doesn't apply to u-boot-tegra/master cleanly; there are a couple trivial conflicts in arch/arm/cpu/armv7/tegra2/Makefile to resolve, but I had to apply the final patch completely by hand.

Quoted 6 lines

When I run the resultant binary, I see the LCD backlight turn on, but the image on the LCD is wrong; it starts completely black without any text showing, then slowly fills in to white/gray with many horizontal and vertical black lines; I guess the LCD timing is incorrect - are there multiple different LCD models? Note that I am using a real Seaboard not a Springbank for this test.

Oh, false alarm on this second point - the LCD is screwed up after using nvflash to flash the device, but when power-cycling it rather than just resetting it, the LCD works fine. I guess this means the driver is not initializing something that nvflash changed, and relying on a power-on default. I suppose it might not be worth fixing that given it works from cold power on.

#52 lore raw

v2 cover tegra: Add display driver and LCD support for Seaboard

Quoted 19 lines · Stephen Warren
Quoted 11 lines · Stephen Warren
Quoted 3 lines · Simon Glass

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.

Simon,

This series doesn't apply to u-boot-tegra/master cleanly; there are a couple trivial conflicts in arch/arm/cpu/armv7/tegra2/Makefile to resolve, but I had to apply the final patch completely by hand.

Quoted 6 lines

When I run the resultant binary, I see the LCD backlight turn on, but the image on the LCD is wrong; it starts completely black without any text showing, then slowly fills in to white/gray with many horizontal and vertical black lines; I guess the LCD timing is incorrect - are there multiple different LCD models? Note that I am using a real Seaboard not a Springbank for this test.

Quoted 6 lines

Oh, false alarm on this second point - the LCD is screwed up after using nvflash to flash the device, but when power-cycling it rather than just resetting it, the LCD works fine. I guess this means the driver is not initializing something that nvflash changed, and relying on a power-on default. I suppose it might not be worth fixing that given it works from cold power on.

Oops, there is a problem - executing "reset" in U-Boot, or "reboot" from the kernel (one without any display support at least; mainline Linux) will get into the "bad LCD" state too. So, I guess there is something that needs to be fixed.

Sorry for the back-to-back emails.

#53 lore raw

v2 cover tegra: Add display driver and LCD support for Seaboard

In reply to Stephen Warren

Simon,

Quoted 19 lines

-----Original Message-----
From: Stephen Warren [mailto:swarren at wwwdotorg.org]
Sent: Wednesday, June 13, 2012 3:58 PM
To: Simon Glass
Cc: U-Boot Mailing List; Tom Warren
Subject: Re: [PATCH v2 0/19] tegra: Add display driver and LCD support for Seaboard

Quoted 3 lines · Simon Glass

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.

Simon,

This series doesn't apply to u-boot-tegra/master cleanly; there are a couple trivial conflicts in arch/arm/cpu/armv7/tegra2/Makefile to resolve, but I had to apply the final patch completely by hand.

Quoted 6 lines

When I run the resultant binary, I see the LCD backlight turn on, but the image on the LCD is wrong; it starts completely black without any text showing, then slowly fills in to white/gray with many horizontal and vertical black lines; I guess the LCD timing is incorrect - are there multiple different LCD models? Note that I am using a real Seaboard not a Springbank for this test.

I don't see Stephen's LCD problems, but I don't see clear text on my Seaboard T20-A03 dev system LCD, either. The text is blurred / almost unreadable, especially the last line (cmd prompt). I don't know if it's the scrolling change or the cache change, as previous incarnations (in the Google repo, at least) were just fine. Power-cycling doesn't fix it. I didn't test Ventana or Harmony.

Please update the patchset so it (a) applies to u-boot-tegra/master and/or /next, and (b) fixes the text corruption on the LCD.

Tom

Signature · 1 line
nvpublic
#54 lore raw

v2 cover tegra: Add display driver and LCD support for Seaboard

Hi Tom,

Quoted 37 lines · Tom Warren

Simon,

Quoted 6 lines

-----Original Message-----
From: Stephen Warren [mailto:swarren at wwwdotorg.org]
Sent: Wednesday, June 13, 2012 3:58 PM
To: Simon Glass
Cc: U-Boot Mailing List; Tom Warren
Subject: Re: [PATCH v2 0/19] tegra: Add display driver and LCD support

for

Quoted 10 lines

Seaboard

Quoted 3 lines · Simon Glass

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.

Simon,

This series doesn't apply to u-boot-tegra/master cleanly; there are a

couple

Quoted 9 lines

trivial conflicts in arch/arm/cpu/armv7/tegra2/Makefile to resolve, but I had to apply the final patch completely by hand.

When I run the resultant binary, I see the LCD backlight turn on, but the image on the LCD is wrong; it starts completely black without any text showing, then slowly fills in to white/gray with many horizontal and vertical black lines; I guess the LCD timing is incorrect - are there multiple different LCD models? Note that I am using a real Seaboard not a Springbank for this test.

I don't see Stephen's LCD problems, but I don't see clear text on my Seaboard T20-A03 dev system LCD, either. The text is blurred / almost unreadable, especially the last line (cmd prompt). I don't know if it's the scrolling change or the cache change, as previous incarnations (in the Google repo, at least) were just fine. Power-cycling doesn't fix it. I didn't test Ventana or Harmony.

Quoted 3 lines

Please update the patchset so it (a) applies to u-boot-tegra/master and/or /next, and (b) fixes the text corruption on the LCD.

Yes will do.

I am not sure about the text corruption as I didn't see that, but perhaps the rebase has caused something to change. Will take a look.

Regards
Simon

Quoted 5 lines

Tom
--
nvpublic

#55 lore raw

v2 cover tegra: Add display driver and LCD support for Seaboard

Hi Tom,

Quoted 44 lines · Simon Glass

Hi Tom,

Quoted 40 lines · Tom Warren

Simon,

Quoted 6 lines

-----Original Message-----
From: Stephen Warren [mailto:swarren at wwwdotorg.org]
Sent: Wednesday, June 13, 2012 3:58 PM
To: Simon Glass
Cc: U-Boot Mailing List; Tom Warren
Subject: Re: [PATCH v2 0/19] tegra: Add display driver and LCD support

for

Quoted 10 lines

Seaboard

Quoted 3 lines · Simon Glass

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.

Simon,

This series doesn't apply to u-boot-tegra/master cleanly; there are a

couple

Quoted 1 line

trivial conflicts in arch/arm/cpu/armv7/tegra2/Makefile to resolve, but

I

Quoted 3 lines

had to apply the final patch completely by hand.

When I run the resultant binary, I see the LCD backlight turn on, but

the

Quoted 4 lines

image on the LCD is wrong; it starts completely black without any text showing, then slowly fills in to white/gray with many horizontal and vertical black lines; I guess the LCD timing is incorrect - are there multiple different LCD models? Note that I am using a real Seaboard not

a

Quoted 1 line

Springbank for this test.

I don't see Stephen's LCD problems, but I don't see clear text on my Seaboard T20-A03 dev system LCD, either. The text is blurred / almost unreadable, especially the last line (cmd prompt). I don't know if it's the scrolling change or the cache change, as previous incarnations (in the Google repo, at least) were just fine. Power-cycling doesn't fix it. I didn't test Ventana or Harmony.

Quoted 9 lines
Quoted 3 lines

Please update the patchset so it (a) applies to u-boot-tegra/master and/or /next, and (b) fixes the text corruption on the LCD.

Yes will do.

I am not sure about the text corruption as I didn't see that, but perhaps the rebase has caused something to change. Will take a look.

I am still not seeing any text corruption here, nor Stephen's LCD problems. Are you running with the cache on or off? (not that it should matter - have tested both).

Regards,
Simon

Quoted 12 lines

Regards
Simon

Quoted 5 lines

Tom
--
nvpublic