@@ -12,7 +12,9 @@
#include <dm.h>
#include <log.h>
#include <panel.h>
+#include <regmap.h>
#include <reset.h>
+#include <syscon.h>
#include <video.h>
#include <video_bridge.h>
#include <asm/io.h>
@@ -275,6 +277,12 @@ static const u32 layer_regs_a2[] = {
#define HWVER_40100 0x040100
#define HWVER_40101 0x040101
+/* STM32MP25 SYSCFG pixel clock mux, described by the "ref" clock */
+#define SYSCFG_DISPLAYCLKCR 0x5000
+#define DISPLAYCLKCR_DPIVSLVDS GENMASK(1, 0)
+#define DISPLAYCLKCR_LVDS 1
+#define DISPLAYCLKCR_DPI 2
+
enum stm32_ltdc_pix_fmt {
PF_ARGB8888 = 0, /* ARGB [32 bits] */
PF_ABGR8888, /* ABGR [32 bits] */
@@ -707,6 +715,44 @@ static int stm32_ltdc_of_to_plat(struct udevice *dev)
return ret;
}
+/*
+ * On STM32MP25 the LTDC pixel clock is selected in SYSCFG_DISPLAYCLKCR
+ * among the DSI byte lane clock, the LVDS PHY pixel clock (reset value)
+ * and the LTDC kernel clock, which is used with the RGB output. Select
+ * it according to the device connected to the LTDC.
+ */
+static int stm32_ltdc_set_pixel_clock_source(struct udevice *dev)
+{
+ struct stm32_ltdc_plat *plat = dev_get_plat(dev);
+ struct ofnode_phandle_args args;
+ struct regmap *regmap;
+ int index, ret;
+ u32 src;
+
+ index = dev_read_stringlist_search(dev, "clock-names", "ref");
+ if (index < 0)
+ return 0;
+
+ if (!plat->bridge)
+ src = DISPLAYCLKCR_DPI;
+ else if (device_is_compatible(plat->bridge, "st,stm32mp25-lvds"))
+ src = DISPLAYCLKCR_LVDS;
+ else
+ return 0;
+
+ ret = dev_read_phandle_with_args(dev, "clocks", "#clock-cells", 0,
+ index, &args);
+ if (ret)
+ return ret;
+
+ regmap = syscon_node_to_regmap(args.node);
+ if (IS_ERR(regmap))
+ return PTR_ERR(regmap);
+
+ return regmap_update_bits(regmap, SYSCFG_DISPLAYCLKCR,
+ DISPLAYCLKCR_DPIVSLVDS, src);
+}
+
static int stm32_ltdc_probe(struct udevice *dev)
{
struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
@@ -717,6 +763,12 @@ static int stm32_ltdc_probe(struct udevice *dev)
ulong rate;
int ret;
+ ret = stm32_ltdc_set_pixel_clock_source(dev);
+ if (ret) {
+ dev_err(dev, "pixel clock source selection error %d\n", ret);
+ return ret;
+ }
+
ret = clk_enable(&plat->bclk);
if (ret) {
dev_err(dev, "bus clock enable error %d\n", ret);
On STM32MP25 the LTDC pixel clock is selected by the SYSCFG DISPLAYCLKCR mux, referenced by the "ref" clock of the LTDC, whose reset value is the LVDS PHY clock. As nothing programs it, a panel connected directly to the LTDC gets no pixel clock. Select the LTDC kernel clock when a panel is connected directly to the LTDC, and the LVDS PHY clock when the LTDC feeds the LVDS bridge. Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> --- drivers/video/stm32/stm32_ltdc.c | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)