From d573e461680d1642de2fb35e575dc9ef26fde56b Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Tue, 30 Jul 2019 19:16:38 +0200 Subject: [PATCH] stm32mp1: board: enable v1v2_hdmi and v3v3_hdmi regulator on dk2 boot As for Audio codec IC, HDMI IC is not "IO safe". HDMI regulators (v3v3 and v1v2) must be enabled to allow I2C1 bus usage. HDMI IC must be under reset during power up and keep HDMI and AUDIO devices in reset while they are not used in U-Boot to keep them in low power mode (each device can be kept in reset independently keeping their power supplies ON until kernel). Signed-off-by: Patrice Chotard Signed-off-by: Patrick Delaunay --- arch/arm/dts/stm32mp157c-dk2-u-boot.dtsi | 6 ++ board/st/stm32mp1/Kconfig | 4 ++ board/st/stm32mp1/stm32mp1.c | 70 ++++++++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/arch/arm/dts/stm32mp157c-dk2-u-boot.dtsi b/arch/arm/dts/stm32mp157c-dk2-u-boot.dtsi index 06ef3a4095..18ac1e3cb2 100644 --- a/arch/arm/dts/stm32mp157c-dk2-u-boot.dtsi +++ b/arch/arm/dts/stm32mp157c-dk2-u-boot.dtsi @@ -4,3 +4,9 @@ */ #include "stm32mp157a-dk1-u-boot.dtsi" + +&i2c1 { + hdmi-transmitter@39 { + reset-gpios = <&gpioa 10 GPIO_ACTIVE_LOW>; + }; +}; diff --git a/board/st/stm32mp1/Kconfig b/board/st/stm32mp1/Kconfig index 87216c0963..4fa2360b4f 100644 --- a/board/st/stm32mp1/Kconfig +++ b/board/st/stm32mp1/Kconfig @@ -22,4 +22,8 @@ config CMD_STBOARD This compile the stboard command to read and write the board in the OTP. +config TARGET_STM32MP157C_DK2 + bool "support of STMicroelectronics STM32MP157C-DK2 Discovery Board" + default y + endif diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index fdc4af3b64..e075f004b7 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -505,6 +505,73 @@ static void sysconf_init(void) #endif } +#ifdef CONFIG_DM_REGULATOR +/* Fix to make I2C1 usable on DK2 for touchscreen usage in kernel */ +static int dk2_i2c1_fix(void) +{ + ofnode node; + struct gpio_desc hdmi, audio; + int ret = 0; + + node = ofnode_path("/soc/i2c@40012000/hdmi-transmitter@39"); + if (!ofnode_valid(node)) { + pr_debug("%s: no hdmi-transmitter@39 ?\n", __func__); + return -ENOENT; + } + + if (gpio_request_by_name_nodev(node, "reset-gpios", 0, + &hdmi, GPIOD_IS_OUT)) { + pr_debug("%s: could not find reset-gpios\n", + __func__); + return -ENOENT; + } + + node = ofnode_path("/soc/i2c@40012000/cs42l51@4a"); + if (!ofnode_valid(node)) { + pr_debug("%s: no cs42l51@4a ?\n", __func__); + return -ENOENT; + } + + if (gpio_request_by_name_nodev(node, "reset-gpios", 0, + &audio, GPIOD_IS_OUT)) { + pr_debug("%s: could not find reset-gpios\n", + __func__); + return -ENOENT; + } + + /* before power up, insure that HDMI and AUDIO IC is under reset */ + ret = dm_gpio_set_value(&hdmi, 1); + if (ret) { + pr_err("%s: can't set_value for hdmi_nrst gpio", __func__); + goto error; + } + ret = dm_gpio_set_value(&audio, 1); + if (ret) { + pr_err("%s: can't set_value for audio_nrst gpio", __func__); + goto error; + } + + /* power-up audio IC */ + regulator_autoset_by_name("v1v8_audio", NULL); + + /* power-up HDMI IC */ + regulator_autoset_by_name("v1v2_hdmi", NULL); + regulator_autoset_by_name("v3v3_hdmi", NULL); + +error: + return ret; +} + +static bool board_is_dk2(void) +{ + if (CONFIG_IS_ENABLED(TARGET_STM32MP157C_DK2) && + of_machine_is_compatible("st,stm32mp157c-dk2")) + return true; + + return false; +} +#endif + /* board dependent setup after realloc */ int board_init(void) { @@ -523,6 +590,9 @@ int board_init(void) board_key_check(); #ifdef CONFIG_DM_REGULATOR + if (board_is_dk2()) + dk2_i2c1_fix(); + regulators_enable_boot_on(_DEBUG); #endif -- 2.39.5