diff mbox series

[09/16] board: stm32mp1: gt9147 IRQ before reset on EV1

Message ID 20200331180330.9.I5d296f8fd82b60a592b51029e7e420672d0e855b@changeid
State Superseded
Delegated to: Patrick Delaunay
Headers show
Series [01/16] arm: stm32mp: update dependency for STM32_ETZPC | expand

Commit Message

Patrick Delaunay March 31, 2020, 4:04 p.m. UTC
Software workaround for I2C issue on EV1 board,
configure the IRQ line for touchscreen before LCD reset
to fix the used I2C address.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 board/st/stm32mp1/stm32mp1.c | 41 ++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

Comments

Patrice CHOTARD April 1, 2020, 7:53 a.m. UTC | #1
HI Patrick

On 3/31/20 6:04 PM, Patrick Delaunay wrote:
> Software workaround for I2C issue on EV1 board,
> configure the IRQ line for touchscreen before LCD reset
> to fix the used I2C address.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
>  board/st/stm32mp1/stm32mp1.c | 41 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 41 insertions(+)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 6ca47509b3..52881adef7 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -626,6 +626,44 @@ static bool board_is_dk2(void)
>  }
>  #endif
>  
> +static bool board_is_ev1(void)
> +{
> +	if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) &&
> +	    (of_machine_is_compatible("st,stm32mp157a-ev1") ||
> +	     of_machine_is_compatible("st,stm32mp157c-ev1") ||
> +	     of_machine_is_compatible("st,stm32mp157d-ev1") ||
> +	     of_machine_is_compatible("st,stm32mp157f-ev1")))
> +		return true;
> +
> +	return false;
> +}
> +
> +/* touchscreen driver: only used for pincontrol configuration */
> +static const struct udevice_id goodix_ids[] = {
> +	{ .compatible = "goodix,gt9147", },
> +	{ }
> +};
> +
> +U_BOOT_DRIVER(goodix) = {
> +	.name		= "goodix",
> +	.id		= UCLASS_NOP,
> +	.of_match	= goodix_ids,
> +};
> +
> +static int board_ev1_init(void)
> +{
> +	struct udevice *dev;
> +	int ret;
> +
> +	/* configure IRQ line on EV1 for touchscreen before LCD reset */
> +	ret = uclass_get_device_by_driver(UCLASS_NOP, DM_GET_DRIVER(goodix),
> +					  &dev);
> +	if (ret)
> +		debug("goodix init failed: %d\n", ret);
> +
> +	return ret;
> +}
> +
>  /* board dependent setup after realloc */
>  int board_init(void)
>  {
> @@ -643,6 +681,9 @@ int board_init(void)
>  
>  	board_key_check();
>  
> +	if (board_is_ev1())
> +		board_ev1_init();
> +
>  #ifdef CONFIG_DM_REGULATOR
>  	if (board_is_dk2())
>  		dk2_i2c1_fix();

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

Thanks
Wolfgang Denk April 1, 2020, 11:34 a.m. UTC | #2
Dear Patrick Delaunay,

In message <20200331180330.9.I5d296f8fd82b60a592b51029e7e420672d0e855b@changeid> you wrote:
> Software workaround for I2C issue on EV1 board,
> configure the IRQ line for touchscreen before LCD reset
> to fix the used I2C address.
...

> +	ret = uclass_get_device_by_driver(UCLASS_NOP, DM_GET_DRIVER(goodix),
> +					  &dev);
> +	if (ret)
> +		debug("goodix init failed: %d\n", ret);

If this is an error condition, you should use printf(), and not
paper over it with a debug().

Best regards,

Wolfgang Denk
diff mbox series

Patch

diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 6ca47509b3..52881adef7 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -626,6 +626,44 @@  static bool board_is_dk2(void)
 }
 #endif
 
+static bool board_is_ev1(void)
+{
+	if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) &&
+	    (of_machine_is_compatible("st,stm32mp157a-ev1") ||
+	     of_machine_is_compatible("st,stm32mp157c-ev1") ||
+	     of_machine_is_compatible("st,stm32mp157d-ev1") ||
+	     of_machine_is_compatible("st,stm32mp157f-ev1")))
+		return true;
+
+	return false;
+}
+
+/* touchscreen driver: only used for pincontrol configuration */
+static const struct udevice_id goodix_ids[] = {
+	{ .compatible = "goodix,gt9147", },
+	{ }
+};
+
+U_BOOT_DRIVER(goodix) = {
+	.name		= "goodix",
+	.id		= UCLASS_NOP,
+	.of_match	= goodix_ids,
+};
+
+static int board_ev1_init(void)
+{
+	struct udevice *dev;
+	int ret;
+
+	/* configure IRQ line on EV1 for touchscreen before LCD reset */
+	ret = uclass_get_device_by_driver(UCLASS_NOP, DM_GET_DRIVER(goodix),
+					  &dev);
+	if (ret)
+		debug("goodix init failed: %d\n", ret);
+
+	return ret;
+}
+
 /* board dependent setup after realloc */
 int board_init(void)
 {
@@ -643,6 +681,9 @@  int board_init(void)
 
 	board_key_check();
 
+	if (board_is_ev1())
+		board_ev1_init();
+
 #ifdef CONFIG_DM_REGULATOR
 	if (board_is_dk2())
 		dk2_i2c1_fix();