diff mbox series

[5/7] board: ti: am57xx-idk: Auto detect LCD Panel

Message ID 1485436049-19754-6-git-send-email-rogerq@ti.com
State New
Headers show
Series am57xx-idk LCD and am571x-idk 6 port ethernet pinmux | expand

Commit Message

Roger Quadros Jan. 26, 2017, 1:07 p.m. UTC
From: Nishanth Menon <nm@ti.com>


AM571x IDK and AM572x IDK have optional LCD Kits that can be purchased.
These can be one of OSD101T2045 or the newer OSD101T2587. The LCD panel
itself has no registers that can be used to identify the panel, however,
the touchscreen controllers on the panels are different.

Hence to ease user experience, we can use the touch screen controller's
ID information to detect what kind of panel we use and select the
appropriate kernel dtb for the platform configuration.

NOTE: AM572x IDK default configuration is for LCD Connectivity, however
the AM571x IDK has a jumper (J51) that needs to be mounted for the IDK
to operate with LCD (Vs two PRUSS ethernet port option).

Touchscreen ID information is documented in:
http://www.osddisplays.com/TI/OSD101T2587-53TS_A.1.pdf

Acked-by: Lokesh Vutla <lokeshvutla@ti.com>

Signed-off-by: Nishanth Menon <nm@ti.com>

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>

Signed-off-by: Roger Quadros <rogerq@ti.com>

---
 board/ti/am57xx/board.c           | 78 +++++++++++++++++++++++++++++++++++----
 include/configs/ti_omap5_common.h | 10 ++++-
 2 files changed, 78 insertions(+), 10 deletions(-)

-- 
2.7.4

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Comments

menon.nishanth@gmail.com Jan. 26, 2017, 5:33 p.m. UTC | #1
[...]


> diff --git a/include/configs/ti_omap5_common.h b/include/configs/ti_omap5_common.h

> index 6de19c2..1fa2f82 100644

> --- a/include/configs/ti_omap5_common.h

> +++ b/include/configs/ti_omap5_common.h

> @@ -91,16 +91,22 @@

>                         "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \

>                 "if test $board_name = beagle_x15_revb1; then " \

>                         "setenv fdtfile am57xx-beagle-x15-revb1.dtb; fi;" \

> -               "if test $board_name = am572x_idk; then " \

> -                       "setenv fdtfile am572x-idk.dtb; fi;" \

>                 "if test $board_name = am57xx_evm; then " \

>                         "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \

>                 "if test $board_name = am57xx_evm_reva3; then " \

>                         "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \

> +               "if test $board_name = am572x_idk && test $idk_lcd = no; then " \

> +                       "setenv fdtfile am572x-idk.dtb; fi;" \

> +               "if test $board_name = am572x_idk && test $idk_lcd = osd101t2045; then " \

> +                       "setenv fdtfile am572x-idk-lcd-osd.dtb; fi;" \

> +               "if test $board_name = am572x_idk && test $idk_lcd = osd101t2587; then " \

> +                       "setenv fdtfile am572x-idk-lcd-osd101t2587.dtb; fi;" \

>                 "if test $board_name = am571x_idk && test $idk_lcd = no; then " \

>                         "setenv fdtfile am571x-idk.dtb; fi;" \

>                 "if test $board_name = am571x_idk && test $idk_lcd = osd101t2045; then " \

>                         "setenv fdtfile am571x-idk-lcd-osd.dtb; fi;" \

> +               "if test $board_name = am571x_idk && test $idk_lcd = osd101t2587; then " \

> +                       "setenv fdtfile am571x-idk-lcd-osd101t2587.dtb; fi;" \



please drop the fdt selection from your patches. upstream will be
using dt overlay for these variations. rest of the detection code is
ok to go.

---
Regards,
Nishanth Menon
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Tom Rini Jan. 26, 2017, 5:41 p.m. UTC | #2
On Thu, Jan 26, 2017 at 03:07:27PM +0200, Roger Quadros wrote:

> From: Nishanth Menon <nm@ti.com>

> 

> AM571x IDK and AM572x IDK have optional LCD Kits that can be purchased.

> These can be one of OSD101T2045 or the newer OSD101T2587. The LCD panel

> itself has no registers that can be used to identify the panel, however,

> the touchscreen controllers on the panels are different.

> 

> Hence to ease user experience, we can use the touch screen controller's

> ID information to detect what kind of panel we use and select the

> appropriate kernel dtb for the platform configuration.

> 

> NOTE: AM572x IDK default configuration is for LCD Connectivity, however

> the AM571x IDK has a jumper (J51) that needs to be mounted for the IDK

> to operate with LCD (Vs two PRUSS ethernet port option).

> 

> Touchscreen ID information is documented in:

> http://www.osddisplays.com/TI/OSD101T2587-53TS_A.1.pdf

> 

> Acked-by: Lokesh Vutla <lokeshvutla@ti.com>

> Signed-off-by: Nishanth Menon <nm@ti.com>

> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>

> Signed-off-by: Roger Quadros <rogerq@ti.com>


Reviewed-by: Tom Rini <trini@konsulko.com>


-- 
Tom
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Roger Quadros Jan. 27, 2017, 8:54 a.m. UTC | #3
On 26/01/17 19:33, menon.nishanth@gmail.com wrote:
> [...]

> 

> 

>> diff --git a/include/configs/ti_omap5_common.h b/include/configs/ti_omap5_common.h

>> index 6de19c2..1fa2f82 100644

>> --- a/include/configs/ti_omap5_common.h

>> +++ b/include/configs/ti_omap5_common.h

>> @@ -91,16 +91,22 @@

>>                         "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \

>>                 "if test $board_name = beagle_x15_revb1; then " \

>>                         "setenv fdtfile am57xx-beagle-x15-revb1.dtb; fi;" \

>> -               "if test $board_name = am572x_idk; then " \

>> -                       "setenv fdtfile am572x-idk.dtb; fi;" \

>>                 "if test $board_name = am57xx_evm; then " \

>>                         "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \

>>                 "if test $board_name = am57xx_evm_reva3; then " \

>>                         "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \

>> +               "if test $board_name = am572x_idk && test $idk_lcd = no; then " \

>> +                       "setenv fdtfile am572x-idk.dtb; fi;" \

>> +               "if test $board_name = am572x_idk && test $idk_lcd = osd101t2045; then " \

>> +                       "setenv fdtfile am572x-idk-lcd-osd.dtb; fi;" \

>> +               "if test $board_name = am572x_idk && test $idk_lcd = osd101t2587; then " \

>> +                       "setenv fdtfile am572x-idk-lcd-osd101t2587.dtb; fi;" \

>>                 "if test $board_name = am571x_idk && test $idk_lcd = no; then " \

>>                         "setenv fdtfile am571x-idk.dtb; fi;" \

>>                 "if test $board_name = am571x_idk && test $idk_lcd = osd101t2045; then " \

>>                         "setenv fdtfile am571x-idk-lcd-osd.dtb; fi;" \

>> +               "if test $board_name = am571x_idk && test $idk_lcd = osd101t2587; then " \

>> +                       "setenv fdtfile am571x-idk-lcd-osd101t2587.dtb; fi;" \

> 

> 

> please drop the fdt selection from your patches. upstream will be

> using dt overlay for these variations. rest of the detection code is

> ok to go.

> 


OK.
Just to clarify, dt overlay code will use the idk_lcd variable to patch the DT right?

cheeers,
-roger
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
menon.nishanth@gmail.com Jan. 27, 2017, 10:40 a.m. UTC | #4
On Fri, Jan 27, 2017 at 2:54 AM, Roger Quadros <rogerq@ti.com> wrote:
> On 26/01/17 19:33, menon.nishanth@gmail.com wrote:

>> [...]

>>

>>

>>> diff --git a/include/configs/ti_omap5_common.h b/include/configs/ti_omap5_common.h

>>> index 6de19c2..1fa2f82 100644

>>> --- a/include/configs/ti_omap5_common.h

>>> +++ b/include/configs/ti_omap5_common.h

>>> @@ -91,16 +91,22 @@

>>>                         "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \

>>>                 "if test $board_name = beagle_x15_revb1; then " \

>>>                         "setenv fdtfile am57xx-beagle-x15-revb1.dtb; fi;" \

>>> -               "if test $board_name = am572x_idk; then " \

>>> -                       "setenv fdtfile am572x-idk.dtb; fi;" \

>>>                 "if test $board_name = am57xx_evm; then " \

>>>                         "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \

>>>                 "if test $board_name = am57xx_evm_reva3; then " \

>>>                         "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \

>>> +               "if test $board_name = am572x_idk && test $idk_lcd = no; then " \

>>> +                       "setenv fdtfile am572x-idk.dtb; fi;" \

>>> +               "if test $board_name = am572x_idk && test $idk_lcd = osd101t2045; then " \

>>> +                       "setenv fdtfile am572x-idk-lcd-osd.dtb; fi;" \

>>> +               "if test $board_name = am572x_idk && test $idk_lcd = osd101t2587; then " \

>>> +                       "setenv fdtfile am572x-idk-lcd-osd101t2587.dtb; fi;" \

>>>                 "if test $board_name = am571x_idk && test $idk_lcd = no; then " \

>>>                         "setenv fdtfile am571x-idk.dtb; fi;" \

>>>                 "if test $board_name = am571x_idk && test $idk_lcd = osd101t2045; then " \

>>>                         "setenv fdtfile am571x-idk-lcd-osd.dtb; fi;" \

>>> +               "if test $board_name = am571x_idk && test $idk_lcd = osd101t2587; then " \

>>> +                       "setenv fdtfile am571x-idk-lcd-osd101t2587.dtb; fi;" \

>>

>>

>> please drop the fdt selection from your patches. upstream will be

>> using dt overlay for these variations. rest of the detection code is

>> ok to go.

>>

>

> OK.

> Just to clarify, dt overlay code will use the idk_lcd variable to patch the DT right?


That'd make sense.

Regards,
Nishanth Menon
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
diff mbox series

Patch

diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index 81ad86c..9ec0448 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -54,6 +54,19 @@  DECLARE_GLOBAL_DATA_PTR;
 /* GPIO 7_11 */
 #define GPIO_DDR_VTT_EN 203
 
+/* Touch screen controller to identify the LCD */
+#define OSD_TS_FT_BUS_ADDRESS	0
+#define OSD_TS_FT_CHIP_ADDRESS	0x38
+#define OSD_TS_FT_REG_ID	0xA3
+/*
+ * Touchscreen IDs for various OSD panels
+ * Ref: http://www.osddisplays.com/TI/OSD101T2587-53TS_A.1.pdf
+ */
+/* Used on newer osd101t2587 Panels */
+#define OSD_TS_FT_ID_5x46	0x54
+/* Used on older osd101t2045 Panels */
+#define OSD_TS_FT_ID_5606	0x08
+
 #define SYSINFO_BOARD_NAME_MAX_LEN	45
 
 #define TPS65903X_PRIMARY_SECONDARY_PAD2	0xFB
@@ -473,10 +486,64 @@  int board_init(void)
 	return 0;
 }
 
-int board_late_init(void)
+void am57x_idk_lcd_detect(void)
 {
-	char *idk_lcd;
+	int r = -ENODEV;
+	char *idk_lcd = "no";
+	uint8_t buf = 0;
+
+	/* Only valid for IDKs */
+	if (board_is_x15() || board_is_am572x_evm())
+		return;
+
+	/* Only AM571x IDK has gpio control detect.. so check that */
+	if (board_is_am571x_idk() && !am571x_idk_needs_lcd())
+		goto out;
+
+	r = i2c_set_bus_num(OSD_TS_FT_BUS_ADDRESS);
+	if (r) {
+		printf("%s: Failed to set bus address to %d: %d\n",
+		       __func__, OSD_TS_FT_BUS_ADDRESS, r);
+		goto out;
+	}
+	r = i2c_probe(OSD_TS_FT_CHIP_ADDRESS);
+	if (r) {
+		/* AM572x IDK has no explicit settings for optional LCD kit */
+		if (board_is_am571x_idk()) {
+			printf("%s: Touch screen detect failed: %d!\n",
+			       __func__, r);
+		}
+		goto out;
+	}
+
+	/* Read FT ID */
+	r = i2c_read(OSD_TS_FT_CHIP_ADDRESS, OSD_TS_FT_REG_ID, 1, &buf, 1);
+	if (r) {
+		printf("%s: Touch screen ID read %d:0x%02x[0x%02x] failed:%d\n",
+		       __func__, OSD_TS_FT_BUS_ADDRESS, OSD_TS_FT_CHIP_ADDRESS,
+		       OSD_TS_FT_REG_ID, r);
+		goto out;
+	}
+
+	switch (buf) {
+	case OSD_TS_FT_ID_5606:
+		idk_lcd = "osd101t2045";
+		break;
+	case OSD_TS_FT_ID_5x46:
+		idk_lcd = "osd101t2587";
+		break;
+	default:
+		printf("%s: Unidentifed Touch screen ID 0x%02x\n",
+		       __func__, buf);
+		/* we will let default be "no lcd" */
+	}
+out:
+	setenv("idk_lcd", idk_lcd);
+	return;
+}
 
+int board_late_init(void)
+{
 	setup_board_eeprom_env();
 	u8 val;
 
@@ -505,12 +572,7 @@  int board_late_init(void)
 	palmas_i2c_write_u8(TPS65903X_CHIP_P1, TPS65903X_PRIMARY_SECONDARY_PAD2,
 			    val);
 
-	/* TBD: Add LCD panel detection once information is available */
-	if (am571x_idk_needs_lcd())
-		idk_lcd = "osd101t2045"; /* Default to legacy LCD */
-	else
-		idk_lcd = "no";
-	setenv("idk_lcd", idk_lcd);
+	am57x_idk_lcd_detect();
 
 #if !defined(CONFIG_SPL_BUILD)
 	board_ti_set_ethaddr(2);
diff --git a/include/configs/ti_omap5_common.h b/include/configs/ti_omap5_common.h
index 6de19c2..1fa2f82 100644
--- a/include/configs/ti_omap5_common.h
+++ b/include/configs/ti_omap5_common.h
@@ -91,16 +91,22 @@ 
 			"setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
 		"if test $board_name = beagle_x15_revb1; then " \
 			"setenv fdtfile am57xx-beagle-x15-revb1.dtb; fi;" \
-		"if test $board_name = am572x_idk; then " \
-			"setenv fdtfile am572x-idk.dtb; fi;" \
 		"if test $board_name = am57xx_evm; then " \
 			"setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
 		"if test $board_name = am57xx_evm_reva3; then " \
 			"setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
+		"if test $board_name = am572x_idk && test $idk_lcd = no; then " \
+			"setenv fdtfile am572x-idk.dtb; fi;" \
+		"if test $board_name = am572x_idk && test $idk_lcd = osd101t2045; then " \
+			"setenv fdtfile am572x-idk-lcd-osd.dtb; fi;" \
+		"if test $board_name = am572x_idk && test $idk_lcd = osd101t2587; then " \
+			"setenv fdtfile am572x-idk-lcd-osd101t2587.dtb; fi;" \
 		"if test $board_name = am571x_idk && test $idk_lcd = no; then " \
 			"setenv fdtfile am571x-idk.dtb; fi;" \
 		"if test $board_name = am571x_idk && test $idk_lcd = osd101t2045; then " \
 			"setenv fdtfile am571x-idk-lcd-osd.dtb; fi;" \
+		"if test $board_name = am571x_idk && test $idk_lcd = osd101t2587; then " \
+			"setenv fdtfile am571x-idk-lcd-osd101t2587.dtb; fi;" \
 		"if test $fdtfile = undefined; then " \
 			"echo WARNING: Could not determine device tree to use; fi; \0" \
 	DFUARGS \