diff --git a/Add-video-damage-tracking.patch b/Add-video-damage-tracking.patch deleted file mode 100644 index 1aea71e..0000000 --- a/Add-video-damage-tracking.patch +++ /dev/null @@ -1,2399 +0,0 @@ -From 26fad18312fe9cb0ed97ed8550b1c704d0985ebe Mon Sep 17 00:00:00 2001 -From: Alper Nebi Yasak -Date: Mon, 21 Aug 2023 16:50:58 +0300 -Subject: [PATCH 01/13] video: test: Split copy frame buffer check into a - function - -While checking frame buffer contents, the video tests also check if the -copy frame buffer contents match the main frame buffer. To test if only -the modified regions are updated after a sync, we will need to create -situations where the two are mismatched. Split this check into another -function that we can skip calling, since we won't want it to error on -those mismatched cases. - -Signed-off-by: Alper Nebi Yasak -Reviewed-by: Simon Glass ---- - test/dm/video.c | 69 +++++++++++++++++++++++++++++++++++++++++-------- - 1 file changed, 58 insertions(+), 11 deletions(-) - -diff --git a/test/dm/video.c b/test/dm/video.c -index d907f681600..641a6250100 100644 ---- a/test/dm/video.c -+++ b/test/dm/video.c -@@ -55,9 +55,6 @@ DM_TEST(dm_test_video_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); - * size of the compressed data. This provides a pretty good level of - * certainty and the resulting tests need only check a single value. - * -- * If the copy framebuffer is enabled, this compares it to the main framebuffer -- * too. -- * - * @uts: Test state - * @dev: Video device - * Return: compressed size of the frame buffer, or -ve on error -@@ -66,7 +63,6 @@ static int compress_frame_buffer(struct unit_test_state *uts, - struct udevice *dev) - { - struct video_priv *priv = dev_get_uclass_priv(dev); -- struct video_priv *uc_priv = dev_get_uclass_priv(dev); - uint destlen; - void *dest; - int ret; -@@ -82,16 +78,34 @@ static int compress_frame_buffer(struct unit_test_state *uts, - if (ret) - return ret; - -- /* Check here that the copy frame buffer is working correctly */ -- if (IS_ENABLED(CONFIG_VIDEO_COPY)) { -- ut_assertf(!memcmp(uc_priv->fb, uc_priv->copy_fb, -- uc_priv->fb_size), -- "Copy framebuffer does not match fb"); -- } -- - return destlen; - } - -+/** -+ * check_copy_frame_buffer() - Compare main frame buffer to copy -+ * -+ * If the copy frame buffer is enabled, this compares it to the main -+ * frame buffer. Normally they should have the same contents after a -+ * sync. -+ * -+ * @uts: Test state -+ * @dev: Video device -+ * Return: 0, or -ve on error -+ */ -+static int check_copy_frame_buffer(struct unit_test_state *uts, -+ struct udevice *dev) -+{ -+ struct video_priv *priv = dev_get_uclass_priv(dev); -+ -+ if (!IS_ENABLED(CONFIG_VIDEO_COPY)) -+ return 0; -+ -+ ut_assertf(!memcmp(priv->fb, priv->copy_fb, priv->fb_size), -+ "Copy framebuffer does not match fb"); -+ -+ return 0; -+} -+ - /* - * Call this function at any point to halt and show the current display. Be - * sure to run the test with the -l flag. -@@ -155,24 +169,30 @@ static int dm_test_video_text(struct unit_test_state *uts) - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, "8x16", 0)); - ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - vidconsole_putc_xy(con, 0, 0, 'a'); - ut_asserteq(79, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - vidconsole_putc_xy(con, 0, 0, ' '); - ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - for (i = 0; i < 20; i++) - vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); - ut_asserteq(273, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - vidconsole_set_row(con, 0, WHITE); - ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - for (i = 0; i < 20; i++) - vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); - ut_asserteq(273, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } -@@ -191,24 +211,30 @@ static int dm_test_video_text_12x22(struct unit_test_state *uts) - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, "12x22", 0)); - ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - vidconsole_putc_xy(con, 0, 0, 'a'); - ut_asserteq(89, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - vidconsole_putc_xy(con, 0, 0, ' '); - ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - for (i = 0; i < 20; i++) - vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); - ut_asserteq(363, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - vidconsole_set_row(con, 0, WHITE); - ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - for (i = 0; i < 20; i++) - vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); - ut_asserteq(363, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } -@@ -226,6 +252,7 @@ static int dm_test_video_chars(struct unit_test_state *uts) - ut_assertok(vidconsole_select_font(con, "8x16", 0)); - vidconsole_put_string(con, test_string); - ut_asserteq(466, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } -@@ -247,19 +274,23 @@ static int dm_test_video_ansi(struct unit_test_state *uts) - video_clear(con->parent); - video_sync(con->parent, false); - ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - /* test clear escape sequence: [2J */ - vidconsole_put_string(con, "A\tB\tC"ANSI_ESC"[2J"); - ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - /* test set-cursor: [%d;%df */ - vidconsole_put_string(con, "abc"ANSI_ESC"[2;2fab"ANSI_ESC"[4;4fcd"); - ut_asserteq(143, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - /* test colors (30-37 fg color, 40-47 bg color) */ - vidconsole_put_string(con, ANSI_ESC"[30;41mfoo"); /* black on red */ - vidconsole_put_string(con, ANSI_ESC"[33;44mbar"); /* yellow on blue */ - ut_asserteq(272, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } -@@ -292,11 +323,13 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot, - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, "8x16", 0)); - ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - /* Check display wrap */ - for (i = 0; i < 120; i++) - vidconsole_put_char(con, 'A' + i % 50); - ut_asserteq(wrap_size, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - /* Check display scrolling */ - for (i = 0; i < SCROLL_LINES; i++) { -@@ -304,11 +337,13 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot, - vidconsole_put_char(con, '\n'); - } - ut_asserteq(scroll_size, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - /* If we scroll enough, the screen becomes blank again */ - for (i = 0; i < SCROLL_LINES; i++) - vidconsole_put_char(con, '\n'); - ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } -@@ -383,6 +418,7 @@ static int dm_test_video_bmp(struct unit_test_state *uts) - - ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); - ut_asserteq(1368, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } -@@ -402,6 +438,7 @@ static int dm_test_video_bmp8(struct unit_test_state *uts) - - ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); - ut_asserteq(1247, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } -@@ -425,6 +462,7 @@ static int dm_test_video_bmp16(struct unit_test_state *uts) - - ut_assertok(video_bmp_display(dev, dst, 0, 0, false)); - ut_asserteq(3700, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } -@@ -448,6 +486,7 @@ static int dm_test_video_bmp24(struct unit_test_state *uts) - - ut_assertok(video_bmp_display(dev, dst, 0, 0, false)); - ut_asserteq(3656, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } -@@ -471,6 +510,7 @@ static int dm_test_video_bmp24_32(struct unit_test_state *uts) - - ut_assertok(video_bmp_display(dev, dst, 0, 0, false)); - ut_asserteq(6827, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } -@@ -489,6 +529,7 @@ static int dm_test_video_bmp32(struct unit_test_state *uts) - - ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); - ut_asserteq(2024, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } -@@ -505,6 +546,7 @@ static int dm_test_video_bmp_comp(struct unit_test_state *uts) - - ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); - ut_asserteq(1368, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } -@@ -524,6 +566,7 @@ static int dm_test_video_comp_bmp32(struct unit_test_state *uts) - - ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); - ut_asserteq(2024, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } -@@ -543,6 +586,7 @@ static int dm_test_video_comp_bmp8(struct unit_test_state *uts) - - ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); - ut_asserteq(1247, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } -@@ -558,6 +602,7 @@ static int dm_test_video_truetype(struct unit_test_state *uts) - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - vidconsole_put_string(con, test_string); - ut_asserteq(12174, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } -@@ -579,6 +624,7 @@ static int dm_test_video_truetype_scroll(struct unit_test_state *uts) - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - vidconsole_put_string(con, test_string); - ut_asserteq(34287, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } -@@ -600,6 +646,7 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts) - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - vidconsole_put_string(con, test_string); - ut_asserteq(29471, compress_frame_buffer(uts, dev)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; - } --- -2.45.1 - -From 6c7cff43f374242ed4d585f7359fa5c334332a0a Mon Sep 17 00:00:00 2001 -From: Alper Nebi Yasak -Date: Mon, 21 Aug 2023 16:50:59 +0300 -Subject: [PATCH 02/13] video: test: Support checking copy frame buffer - contents - -The video tests have a helper function to generate a pseudo-digest of -frame buffer contents, but it only does so for the main one. There is -another check that the copy frame buffer is the same as that. But -neither is enough to test if only the modified regions are copied to the -copy frame buffer, since we will want the two to be different in very -specific ways. - -Add a boolean argument to the existing helper function to indicate which -frame buffer we want to inspect, and update the existing callers. - -Signed-off-by: Alper Nebi Yasak -Reviewed-by: Simon Glass ---- - test/dm/video.c | 76 ++++++++++++++++++++++++++----------------------- - 1 file changed, 41 insertions(+), 35 deletions(-) - -diff --git a/test/dm/video.c b/test/dm/video.c -index 641a6250100..b9ff3da10c1 100644 ---- a/test/dm/video.c -+++ b/test/dm/video.c -@@ -57,22 +57,28 @@ DM_TEST(dm_test_video_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); - * - * @uts: Test state - * @dev: Video device -+ * @use_copy: Use copy frame buffer if available - * Return: compressed size of the frame buffer, or -ve on error - */ - static int compress_frame_buffer(struct unit_test_state *uts, -- struct udevice *dev) -+ struct udevice *dev, -+ bool use_copy) - { - struct video_priv *priv = dev_get_uclass_priv(dev); - uint destlen; - void *dest; - int ret; - -+ if (!IS_ENABLED(CONFIG_VIDEO_COPY)) -+ use_copy = false; -+ - destlen = priv->fb_size; - dest = malloc(priv->fb_size); - if (!dest) - return -ENOMEM; - ret = BZ2_bzBuffToBuffCompress(dest, &destlen, -- priv->fb, priv->fb_size, -+ use_copy ? priv->copy_fb : priv->fb, -+ priv->fb_size, - 3, 0, 0); - free(dest); - if (ret) -@@ -168,30 +174,30 @@ static int dm_test_video_text(struct unit_test_state *uts) - ut_assertok(video_get_nologo(uts, &dev)); - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, "8x16", 0)); -- ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - vidconsole_putc_xy(con, 0, 0, 'a'); -- ut_asserteq(79, compress_frame_buffer(uts, dev)); -+ ut_asserteq(79, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - vidconsole_putc_xy(con, 0, 0, ' '); -- ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - for (i = 0; i < 20; i++) - vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); -- ut_asserteq(273, compress_frame_buffer(uts, dev)); -+ ut_asserteq(273, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - vidconsole_set_row(con, 0, WHITE); -- ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - for (i = 0; i < 20; i++) - vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); -- ut_asserteq(273, compress_frame_buffer(uts, dev)); -+ ut_asserteq(273, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; -@@ -210,30 +216,30 @@ static int dm_test_video_text_12x22(struct unit_test_state *uts) - ut_assertok(video_get_nologo(uts, &dev)); - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, "12x22", 0)); -- ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - vidconsole_putc_xy(con, 0, 0, 'a'); -- ut_asserteq(89, compress_frame_buffer(uts, dev)); -+ ut_asserteq(89, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - vidconsole_putc_xy(con, 0, 0, ' '); -- ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - for (i = 0; i < 20; i++) - vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); -- ut_asserteq(363, compress_frame_buffer(uts, dev)); -+ ut_asserteq(363, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - vidconsole_set_row(con, 0, WHITE); -- ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - for (i = 0; i < 20; i++) - vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); -- ut_asserteq(363, compress_frame_buffer(uts, dev)); -+ ut_asserteq(363, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; -@@ -251,7 +257,7 @@ static int dm_test_video_chars(struct unit_test_state *uts) - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, "8x16", 0)); - vidconsole_put_string(con, test_string); -- ut_asserteq(466, compress_frame_buffer(uts, dev)); -+ ut_asserteq(466, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; -@@ -273,23 +279,23 @@ static int dm_test_video_ansi(struct unit_test_state *uts) - /* reference clear: */ - video_clear(con->parent); - video_sync(con->parent, false); -- ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - /* test clear escape sequence: [2J */ - vidconsole_put_string(con, "A\tB\tC"ANSI_ESC"[2J"); -- ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - /* test set-cursor: [%d;%df */ - vidconsole_put_string(con, "abc"ANSI_ESC"[2;2fab"ANSI_ESC"[4;4fcd"); -- ut_asserteq(143, compress_frame_buffer(uts, dev)); -+ ut_asserteq(143, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - /* test colors (30-37 fg color, 40-47 bg color) */ - vidconsole_put_string(con, ANSI_ESC"[30;41mfoo"); /* black on red */ - vidconsole_put_string(con, ANSI_ESC"[33;44mbar"); /* yellow on blue */ -- ut_asserteq(272, compress_frame_buffer(uts, dev)); -+ ut_asserteq(272, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; -@@ -322,13 +328,13 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot, - ut_assertok(video_get_nologo(uts, &dev)); - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, "8x16", 0)); -- ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - /* Check display wrap */ - for (i = 0; i < 120; i++) - vidconsole_put_char(con, 'A' + i % 50); -- ut_asserteq(wrap_size, compress_frame_buffer(uts, dev)); -+ ut_asserteq(wrap_size, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - /* Check display scrolling */ -@@ -336,13 +342,13 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot, - vidconsole_put_char(con, 'A' + i % 50); - vidconsole_put_char(con, '\n'); - } -- ut_asserteq(scroll_size, compress_frame_buffer(uts, dev)); -+ ut_asserteq(scroll_size, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - /* If we scroll enough, the screen becomes blank again */ - for (i = 0; i < SCROLL_LINES; i++) - vidconsole_put_char(con, '\n'); -- ut_asserteq(46, compress_frame_buffer(uts, dev)); -+ ut_asserteq(46, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; -@@ -417,7 +423,7 @@ static int dm_test_video_bmp(struct unit_test_state *uts) - ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); - - ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); -- ut_asserteq(1368, compress_frame_buffer(uts, dev)); -+ ut_asserteq(1368, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; -@@ -437,7 +443,7 @@ static int dm_test_video_bmp8(struct unit_test_state *uts) - ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); - - ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); -- ut_asserteq(1247, compress_frame_buffer(uts, dev)); -+ ut_asserteq(1247, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; -@@ -461,7 +467,7 @@ static int dm_test_video_bmp16(struct unit_test_state *uts) - &src_len)); - - ut_assertok(video_bmp_display(dev, dst, 0, 0, false)); -- ut_asserteq(3700, compress_frame_buffer(uts, dev)); -+ ut_asserteq(3700, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; -@@ -485,7 +491,7 @@ static int dm_test_video_bmp24(struct unit_test_state *uts) - &src_len)); - - ut_assertok(video_bmp_display(dev, dst, 0, 0, false)); -- ut_asserteq(3656, compress_frame_buffer(uts, dev)); -+ ut_asserteq(3656, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; -@@ -509,7 +515,7 @@ static int dm_test_video_bmp24_32(struct unit_test_state *uts) - &src_len)); - - ut_assertok(video_bmp_display(dev, dst, 0, 0, false)); -- ut_asserteq(6827, compress_frame_buffer(uts, dev)); -+ ut_asserteq(6827, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; -@@ -528,7 +534,7 @@ static int dm_test_video_bmp32(struct unit_test_state *uts) - ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); - - ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); -- ut_asserteq(2024, compress_frame_buffer(uts, dev)); -+ ut_asserteq(2024, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; -@@ -545,7 +551,7 @@ static int dm_test_video_bmp_comp(struct unit_test_state *uts) - ut_assertok(read_file(uts, "tools/logos/denx-comp.bmp", &addr)); - - ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); -- ut_asserteq(1368, compress_frame_buffer(uts, dev)); -+ ut_asserteq(1368, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; -@@ -565,7 +571,7 @@ static int dm_test_video_comp_bmp32(struct unit_test_state *uts) - ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); - - ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); -- ut_asserteq(2024, compress_frame_buffer(uts, dev)); -+ ut_asserteq(2024, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; -@@ -585,7 +591,7 @@ static int dm_test_video_comp_bmp8(struct unit_test_state *uts) - ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); - - ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); -- ut_asserteq(1247, compress_frame_buffer(uts, dev)); -+ ut_asserteq(1247, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; -@@ -601,7 +607,7 @@ static int dm_test_video_truetype(struct unit_test_state *uts) - ut_assertok(video_get_nologo(uts, &dev)); - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - vidconsole_put_string(con, test_string); -- ut_asserteq(12174, compress_frame_buffer(uts, dev)); -+ ut_asserteq(12174, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; -@@ -623,7 +629,7 @@ static int dm_test_video_truetype_scroll(struct unit_test_state *uts) - ut_assertok(video_get_nologo(uts, &dev)); - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - vidconsole_put_string(con, test_string); -- ut_asserteq(34287, compress_frame_buffer(uts, dev)); -+ ut_asserteq(34287, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; -@@ -645,7 +651,7 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts) - ut_assertok(video_get_nologo(uts, &dev)); - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - vidconsole_put_string(con, test_string); -- ut_asserteq(29471, compress_frame_buffer(uts, dev)); -+ ut_asserteq(29471, compress_frame_buffer(uts, dev, false)); - ut_assertok(check_copy_frame_buffer(uts, dev)); - - return 0; --- -2.45.1 - -From 1020e92b30457fa042a78395dabce0f50d07de8e Mon Sep 17 00:00:00 2001 -From: Alper Nebi Yasak -Date: Mon, 21 Aug 2023 16:51:00 +0300 -Subject: [PATCH 03/13] video: test: Test partial updates of hardware frame - buffer - -With VIDEO_COPY enabled, only the modified parts of the frame buffer are -intended to be copied to the hardware. Add a test that checks this, by -overwriting contents we prepared without telling the video uclass and -then checking if the overwritten contents have been redrawn on the next -sync. - -Signed-off-by: Alper Nebi Yasak -Reviewed-by: Simon Glass ---- - test/dm/video.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 54 insertions(+) - -diff --git a/test/dm/video.c b/test/dm/video.c -index b9ff3da10c1..e4bd27a6b76 100644 ---- a/test/dm/video.c -+++ b/test/dm/video.c -@@ -657,3 +657,57 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts) - return 0; - } - DM_TEST(dm_test_video_truetype_bs, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); -+ -+/* Test partial rendering onto hardware frame buffer */ -+static int dm_test_video_copy(struct unit_test_state *uts) -+{ -+ struct sandbox_sdl_plat *plat; -+ struct video_uc_plat *uc_plat; -+ struct udevice *dev, *con; -+ struct video_priv *priv; -+ const char *test_string = "\n\tCriticism may not be agreeable, but it is necessary.\t"; -+ ulong addr; -+ -+ if (!IS_ENABLED(CONFIG_VIDEO_COPY)) -+ return -EAGAIN; -+ -+ ut_assertok(uclass_find_first_device(UCLASS_VIDEO, &dev)); -+ ut_assertnonnull(dev); -+ uc_plat = dev_get_uclass_plat(dev); -+ uc_plat->hide_logo = true; -+ plat = dev_get_plat(dev); -+ plat->font_size = 32; -+ ut_assert(!device_active(dev)); -+ ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev)); -+ ut_assertnonnull(dev); -+ priv = dev_get_uclass_priv(dev); -+ -+ ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); -+ ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); -+ -+ ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); -+ vidconsole_put_string(con, "\n\n\n\n\n"); -+ vidconsole_put_string(con, test_string); -+ vidconsole_put_string(con, test_string); -+ -+ ut_asserteq(6678, compress_frame_buffer(uts, dev, false)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); -+ -+ /* -+ * Secretly clear the hardware frame buffer, but in a different -+ * color (black) to see which parts will be overwritten. -+ */ -+ memset(priv->copy_fb, 0, priv->fb_size); -+ -+ /* -+ * We should have the full content on the main buffer, but only -+ * the new content should have been copied to the copy buffer. -+ */ -+ vidconsole_put_string(con, test_string); -+ vidconsole_put_string(con, test_string); -+ ut_asserteq(7589, compress_frame_buffer(uts, dev, false)); -+ ut_asserteq(5278, compress_frame_buffer(uts, dev, true)); -+ -+ return 0; -+} -+DM_TEST(dm_test_video_copy, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); --- -2.45.1 - -From 57b3429b596c7ed89c1858663c87865e11d965e2 Mon Sep 17 00:00:00 2001 -From: Alexander Graf -Date: Mon, 21 Aug 2023 16:51:01 +0300 -Subject: [PATCH 04/13] dm: video: Add damage tracking API - -We are going to introduce image damage tracking to fasten up screen -refresh on large displays. This patch adds damage tracking for up to -one rectangle of the screen which is typically enough to hold blt or -text print updates. Callers into this API and a reduced dcache flush -code path will follow in later patches. - -Signed-off-by: Alexander Graf -Reported-by: Da Xue -[Alper: Use xstart/yend, document new fields, return void from - video_damage(), declare priv, drop headers, use IS_ENABLED()] -Co-developed-by: Alper Nebi Yasak -Signed-off-by: Alper Nebi Yasak -Reviewed-by: Simon Glass ---- - drivers/video/Kconfig | 13 ++++++++++++ - drivers/video/video-uclass.c | 41 +++++++++++++++++++++++++++++++++--- - include/video.h | 32 ++++++++++++++++++++++++++-- - 3 files changed, 81 insertions(+), 5 deletions(-) - -diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig -index 7808ae7919e..7815b590481 100644 ---- a/drivers/video/Kconfig -+++ b/drivers/video/Kconfig -@@ -92,6 +92,19 @@ config VIDEO_COPY - To use this, your video driver must set @copy_base in - struct video_uc_plat. - -+config VIDEO_DAMAGE -+ bool "Enable damage tracking of frame buffer regions" -+ help -+ On some machines (most ARM), the display frame buffer resides in -+ RAM. To make the display controller pick up screen updates, we -+ have to flush frame buffer contents from CPU caches into RAM which -+ can be a slow operation. -+ -+ This feature adds damage tracking to collect information about regions -+ that received updates. When we want to sync, we then only flush -+ regions of the frame buffer that were modified before, speeding up -+ screen refreshes significantly. -+ - config BACKLIGHT_PWM - bool "Generic PWM based Backlight Driver" - depends on BACKLIGHT && DM_PWM -diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c -index 7b5d1dfbb3b..99a8458199a 100644 ---- a/drivers/video/video-uclass.c -+++ b/drivers/video/video-uclass.c -@@ -347,9 +347,39 @@ void video_set_default_colors(struct udevice *dev, bool invert) - priv->colour_bg = video_index_to_colour(priv, back); - } - -+/* Notify about changes in the frame buffer */ -+void video_damage(struct udevice *vid, int x, int y, int width, int height) -+{ -+ struct video_priv *priv = dev_get_uclass_priv(vid); -+ int xend = x + width; -+ int yend = y + height; -+ -+ if (!IS_ENABLED(CONFIG_VIDEO_DAMAGE)) -+ return; -+ -+ if (x > priv->xsize) -+ return; -+ -+ if (y > priv->ysize) -+ return; -+ -+ if (xend > priv->xsize) -+ xend = priv->xsize; -+ -+ if (yend > priv->ysize) -+ yend = priv->ysize; -+ -+ /* Span a rectangle across all old and new damage */ -+ priv->damage.xstart = min(x, priv->damage.xstart); -+ priv->damage.ystart = min(y, priv->damage.ystart); -+ priv->damage.xend = max(xend, priv->damage.xend); -+ priv->damage.yend = max(yend, priv->damage.yend); -+} -+ - /* Flush video activity to the caches */ - int video_sync(struct udevice *vid, bool force) - { -+ struct video_priv *priv = dev_get_uclass_priv(vid); - struct video_ops *ops = video_get_ops(vid); - int ret; - -@@ -365,15 +395,12 @@ int video_sync(struct udevice *vid, bool force) - * out whether it exists? For now, ARM is safe. - */ - #if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) -- struct video_priv *priv = dev_get_uclass_priv(vid); -- - if (priv->flush_dcache) { - flush_dcache_range((ulong)priv->fb, - ALIGN((ulong)priv->fb + priv->fb_size, - CONFIG_SYS_CACHELINE_SIZE)); - } - #elif defined(CONFIG_VIDEO_SANDBOX_SDL) -- struct video_priv *priv = dev_get_uclass_priv(vid); - static ulong last_sync; - - if (force || get_timer(last_sync) > 100) { -@@ -381,6 +408,14 @@ int video_sync(struct udevice *vid, bool force) - last_sync = get_timer(0); - } - #endif -+ -+ if (IS_ENABLED(CONFIG_VIDEO_DAMAGE)) { -+ priv->damage.xstart = priv->xsize; -+ priv->damage.ystart = priv->ysize; -+ priv->damage.xend = 0; -+ priv->damage.yend = 0; -+ } -+ - return 0; - } - -diff --git a/include/video.h b/include/video.h -index 4d8df9baaad..1310195f307 100644 ---- a/include/video.h -+++ b/include/video.h -@@ -88,6 +88,11 @@ enum video_format { - * @fb_size: Frame buffer size - * @copy_fb: Copy of the frame buffer to keep up to date; see struct - * video_uc_plat -+ * @damage: A bounding box of framebuffer regions updated since last sync -+ * @damage.xstart: X start position in pixels from the left -+ * @damage.ystart: Y start position in pixels from the top -+ * @damage.xend: X end position in pixels from the left -+ * @damage.xend: Y end position in pixels from the top - * @line_length: Length of each frame buffer line, in bytes. This can be - * set by the driver, but if not, the uclass will set it after - * probing -@@ -115,6 +120,12 @@ struct video_priv { - void *fb; - int fb_size; - void *copy_fb; -+ struct { -+ int xstart; -+ int ystart; -+ int xend; -+ int yend; -+ } damage; - int line_length; - u32 colour_fg; - u32 colour_bg; -@@ -257,8 +268,9 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend, - * @return: 0 on success, error code otherwise - * - * Some frame buffers are cached or have a secondary frame buffer. This -- * function syncs these up so that the current contents of the U-Boot frame -- * buffer are displayed to the user. -+ * function syncs the damaged parts of them up so that the current contents -+ * of the U-Boot frame buffer are displayed to the user. It clears the damage -+ * buffer. - */ - int video_sync(struct udevice *vid, bool force); - -@@ -378,6 +390,22 @@ static inline int video_sync_copy_all(struct udevice *dev) - - #endif - -+/** -+ * video_damage() - Notify the video subsystem about screen updates. -+ * -+ * @vid: Device to sync -+ * @x: Upper left X coordinate of the damaged rectangle -+ * @y: Upper left Y coordinate of the damaged rectangle -+ * @width: Width of the damaged rectangle -+ * @height: Height of the damaged rectangle -+ * -+ * Some frame buffers are cached or have a secondary frame buffer. This -+ * function notifies the video subsystem about rectangles that were updated -+ * within the frame buffer. They may only get written to the screen on the -+ * next call to video_sync(). -+ */ -+void video_damage(struct udevice *vid, int x, int y, int width, int height); -+ - /** - * video_is_active() - Test if one video device it active - * --- -2.45.1 - -From 6677746b0fc8b653af608513bdef54b379b4ee7d Mon Sep 17 00:00:00 2001 -From: Alexander Graf -Date: Mon, 21 Aug 2023 16:51:02 +0300 -Subject: [PATCH 05/13] dm: video: Add damage notification on display fills - -Let's report the video damage when we fill parts of the screen. This -way we can later lazily flush only relevant regions to hardware. - -Signed-off-by: Alexander Graf -Reported-by: Da Xue -[Alper: Call video_damage() in video_fill_part(), edit commit message] -Signed-off-by: Alper Nebi Yasak -Reviewed-by: Simon Glass ---- - drivers/video/video-uclass.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c -index 99a8458199a..96b8962b8de 100644 ---- a/drivers/video/video-uclass.c -+++ b/drivers/video/video-uclass.c -@@ -196,6 +196,8 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend, - if (ret) - return ret; - -+ video_damage(dev, xstart, ystart, xend - xstart, yend - ystart); -+ - return 0; - } - -@@ -245,6 +247,8 @@ int video_fill(struct udevice *dev, u32 colour) - if (ret) - return ret; - -+ video_damage(dev, 0, 0, priv->xsize, priv->ysize); -+ - return video_sync(dev, false); - } - --- -2.45.1 - -From 96ee787a7966c0357e5f028317b85a8593757883 Mon Sep 17 00:00:00 2001 -From: Alexander Graf -Date: Mon, 21 Aug 2023 16:51:03 +0300 -Subject: [PATCH 06/13] vidconsole: Add damage notifications to all vidconsole - drivers - -Now that we have a damage tracking API, let's populate damage done by -vidconsole drivers. We try to declare as little memory as damaged as -possible. - -Signed-off-by: Alexander Graf -Reported-by: Da Xue -[Alper: Rebase for met->baseline, fontdata->height/width, make rotated - console_putc_xy() damages pass tests, edit patch message] -Co-developed-by: Alper Nebi Yasak -Signed-off-by: Alper Nebi Yasak -Reviewed-by: Simon Glass ---- - drivers/video/console_normal.c | 18 +++++++++++ - drivers/video/console_rotate.c | 54 ++++++++++++++++++++++++++++++++ - drivers/video/console_truetype.c | 21 +++++++++++++ - drivers/video/video-uclass.c | 1 + - 4 files changed, 94 insertions(+) - -diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c -index 34ef5a52294..6634d3f27da 100644 ---- a/drivers/video/console_normal.c -+++ b/drivers/video/console_normal.c -@@ -40,6 +40,12 @@ static int console_set_row(struct udevice *dev, uint row, int clr) - if (ret) - return ret; - -+ video_damage(dev->parent, -+ 0, -+ fontdata->height * row, -+ vid_priv->xsize, -+ fontdata->height); -+ - return 0; - } - -@@ -61,6 +67,12 @@ static int console_move_rows(struct udevice *dev, uint rowdst, - if (ret) - return ret; - -+ video_damage(dev->parent, -+ 0, -+ fontdata->height * rowdst, -+ vid_priv->xsize, -+ fontdata->height * count); -+ - return 0; - } - -@@ -92,6 +104,12 @@ static int console_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp) - if (ret) - return ret; - -+ video_damage(dev->parent, -+ x, -+ y, -+ fontdata->width, -+ fontdata->height); -+ - ret = vidconsole_sync_copy(dev, start, line); - if (ret) - return ret; -diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c -index e4303dfb364..8129c7b2aa7 100644 ---- a/drivers/video/console_rotate.c -+++ b/drivers/video/console_rotate.c -@@ -37,6 +37,12 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr) - if (ret) - return ret; - -+ video_damage(dev->parent, -+ vid_priv->xsize - ((row + 1) * fontdata->height), -+ 0, -+ fontdata->height, -+ vid_priv->ysize); -+ - return 0; - } - -@@ -65,6 +71,12 @@ static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc, - dst += vid_priv->line_length; - } - -+ video_damage(dev->parent, -+ vid_priv->xsize - ((rowdst + count) * fontdata->height), -+ 0, -+ count * fontdata->height, -+ vid_priv->ysize); -+ - return 0; - } - -@@ -98,6 +110,12 @@ static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, int cp) - if (ret) - return ret; - -+ video_damage(dev->parent, -+ vid_priv->xsize - y - fontdata->height, -+ linenum - 1, -+ fontdata->height, -+ fontdata->width); -+ - return VID_TO_POS(fontdata->width); - } - -@@ -123,6 +141,12 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr) - if (ret) - return ret; - -+ video_damage(dev->parent, -+ 0, -+ vid_priv->ysize - (row + 1) * fontdata->height, -+ vid_priv->xsize, -+ fontdata->height); -+ - return 0; - } - -@@ -144,6 +168,12 @@ static int console_move_rows_2(struct udevice *dev, uint rowdst, uint rowsrc, - vidconsole_memmove(dev, dst, src, - fontdata->height * vid_priv->line_length * count); - -+ video_damage(dev->parent, -+ 0, -+ vid_priv->ysize - (rowdst + count) * fontdata->height, -+ vid_priv->xsize, -+ count * fontdata->height); -+ - return 0; - } - -@@ -177,6 +207,12 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, int cp) - if (ret) - return ret; - -+ video_damage(dev->parent, -+ x - fontdata->width + 1, -+ linenum - fontdata->height + 1, -+ fontdata->width, -+ fontdata->height); -+ - return VID_TO_POS(fontdata->width); - } - -@@ -201,6 +237,12 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr) - if (ret) - return ret; - -+ video_damage(dev->parent, -+ row * fontdata->height, -+ 0, -+ fontdata->height, -+ vid_priv->ysize); -+ - return 0; - } - -@@ -227,6 +269,12 @@ static int console_move_rows_3(struct udevice *dev, uint rowdst, uint rowsrc, - dst += vid_priv->line_length; - } - -+ video_damage(dev->parent, -+ rowdst * fontdata->height, -+ 0, -+ count * fontdata->height, -+ vid_priv->ysize); -+ - return 0; - } - -@@ -259,6 +307,12 @@ static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, int cp) - if (ret) - return ret; - -+ video_damage(dev->parent, -+ y, -+ linenum - fontdata->width + 1, -+ fontdata->height, -+ fontdata->width); -+ - return VID_TO_POS(fontdata->width); - } - -diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c -index 28665a32757..ed6c9cbb4f4 100644 ---- a/drivers/video/console_truetype.c -+++ b/drivers/video/console_truetype.c -@@ -191,6 +191,7 @@ struct console_tt_store { - static int console_truetype_set_row(struct udevice *dev, uint row, int clr) - { - struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); -+ struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); - struct console_tt_priv *priv = dev_get_priv(dev); - struct console_tt_metrics *met = priv->cur_met; - void *end, *line; -@@ -234,6 +235,12 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr) - if (ret) - return ret; - -+ video_damage(dev->parent, -+ 0, -+ vc_priv->y_charsize * row, -+ vid_priv->xsize, -+ vc_priv->y_charsize); -+ - return 0; - } - -@@ -241,6 +248,7 @@ static int console_truetype_move_rows(struct udevice *dev, uint rowdst, - uint rowsrc, uint count) - { - struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); -+ struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); - struct console_tt_priv *priv = dev_get_priv(dev); - struct console_tt_metrics *met = priv->cur_met; - void *dst; -@@ -259,6 +267,12 @@ static int console_truetype_move_rows(struct udevice *dev, uint rowdst, - for (i = 0; i < priv->pos_ptr; i++) - priv->pos[i].ypos -= diff; - -+ video_damage(dev->parent, -+ 0, -+ vc_priv->y_charsize * rowdst, -+ vid_priv->xsize, -+ vc_priv->y_charsize * count); -+ - return 0; - } - -@@ -419,6 +433,13 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y, - - line += vid_priv->line_length; - } -+ -+ video_damage(dev->parent, -+ VID_TO_PIXEL(x) + xoff, -+ y + met->baseline + yoff, -+ width, -+ height); -+ - ret = vidconsole_sync_copy(dev, start, line); - if (ret) - return ret; -diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c -index 96b8962b8de..cbdda274f2d 100644 ---- a/drivers/video/video-uclass.c -+++ b/drivers/video/video-uclass.c -@@ -192,6 +192,7 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend, - } - line += priv->line_length; - } -+ - ret = video_sync_copy(dev, start, line); - if (ret) - return ret; --- -2.45.1 - -From 077a499a8fc2ccad28114264c8792d342bf8536c Mon Sep 17 00:00:00 2001 -From: Alper Nebi Yasak -Date: Mon, 21 Aug 2023 16:51:04 +0300 -Subject: [PATCH 07/13] video: test: Test video damage tracking via vidconsole - -With VIDEO_DAMAGE, the video uclass tracks updated regions of the frame -buffer in order to avoid unnecessary work during a video sync. Enable -the config in sandbox and add a test for it, by printing strings at a -few locations and checking the tracked region. - -Signed-off-by: Alper Nebi Yasak -Reviewed-by: Simon Glass ---- - configs/sandbox_defconfig | 1 + - test/dm/video.c | 56 +++++++++++++++++++++++++++++++++++++++ - 2 files changed, 57 insertions(+) - -diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig -index 93b52f2de5c..2051f0a3d7a 100644 ---- a/configs/sandbox_defconfig -+++ b/configs/sandbox_defconfig -@@ -319,6 +319,7 @@ CONFIG_USB_ETH_CDC=y - CONFIG_VIDEO=y - CONFIG_VIDEO_FONT_SUN12X22=y - CONFIG_VIDEO_COPY=y -+CONFIG_VIDEO_DAMAGE=y - CONFIG_CONSOLE_ROTATION=y - CONFIG_CONSOLE_TRUETYPE=y - CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y -diff --git a/test/dm/video.c b/test/dm/video.c -index e4bd27a6b76..8c7d9800a42 100644 ---- a/test/dm/video.c -+++ b/test/dm/video.c -@@ -711,3 +711,59 @@ static int dm_test_video_copy(struct unit_test_state *uts) - return 0; - } - DM_TEST(dm_test_video_copy, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); -+ -+/* Test video damage tracking */ -+static int dm_test_video_damage(struct unit_test_state *uts) -+{ -+ struct sandbox_sdl_plat *plat; -+ struct udevice *dev, *con; -+ struct video_priv *priv; -+ const char *test_string_1 = "Criticism may not be agreeable, "; -+ const char *test_string_2 = "but it is necessary."; -+ const char *test_string_3 = "It fulfils the same function as pain in the human body."; -+ -+ if (!IS_ENABLED(CONFIG_VIDEO_DAMAGE)) -+ return -EAGAIN; -+ -+ ut_assertok(uclass_find_device(UCLASS_VIDEO, 0, &dev)); -+ ut_assert(!device_active(dev)); -+ plat = dev_get_plat(dev); -+ plat->font_size = 32; -+ -+ ut_assertok(video_get_nologo(uts, &dev)); -+ ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); -+ priv = dev_get_uclass_priv(dev); -+ -+ vidconsole_position_cursor(con, 14, 10); -+ vidconsole_put_string(con, test_string_2); -+ ut_asserteq(449, priv->damage.xstart); -+ ut_asserteq(325, priv->damage.ystart); -+ ut_asserteq(661, priv->damage.xend); -+ ut_asserteq(350, priv->damage.yend); -+ -+ vidconsole_position_cursor(con, 7, 5); -+ vidconsole_put_string(con, test_string_1); -+ ut_asserteq(225, priv->damage.xstart); -+ ut_asserteq(164, priv->damage.ystart); -+ ut_asserteq(661, priv->damage.xend); -+ ut_asserteq(350, priv->damage.yend); -+ -+ vidconsole_position_cursor(con, 21, 15); -+ vidconsole_put_string(con, test_string_3); -+ ut_asserteq(225, priv->damage.xstart); -+ ut_asserteq(164, priv->damage.ystart); -+ ut_asserteq(1280, priv->damage.xend); -+ ut_asserteq(510, priv->damage.yend); -+ -+ video_sync(dev, false); -+ ut_asserteq(priv->xsize, priv->damage.xstart); -+ ut_asserteq(priv->ysize, priv->damage.ystart); -+ ut_asserteq(0, priv->damage.xend); -+ ut_asserteq(0, priv->damage.yend); -+ -+ ut_asserteq(7339, compress_frame_buffer(uts, dev, false)); -+ ut_assertok(check_copy_frame_buffer(uts, dev)); -+ -+ return 0; -+} -+DM_TEST(dm_test_video_damage, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); --- -2.45.1 - -From e5b927255d0375408a5ff14403a978aca09fa68f Mon Sep 17 00:00:00 2001 -From: Alexander Graf -Date: Mon, 21 Aug 2023 16:51:05 +0300 -Subject: [PATCH 08/13] video: Add damage notification on bmp display - -Let's report the video damage when we draw a bitmap on the screen. This -way we can later lazily flush only relevant regions to hardware. - -Signed-off-by: Alexander Graf -Reported-by: Da Xue -Reviewed-by: Simon Glass -Signed-off-by: Alper Nebi Yasak ---- - drivers/video/video_bmp.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c -index 45f003c8251..10943b9ca19 100644 ---- a/drivers/video/video_bmp.c -+++ b/drivers/video/video_bmp.c -@@ -460,6 +460,8 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, - break; - }; - -+ video_damage(dev, x, y, width, height); -+ - /* Find the position of the top left of the image in the framebuffer */ - fb = (uchar *)(priv->fb + y * priv->line_length + x * bpix / 8); - ret = video_sync_copy(dev, start, fb); --- -2.45.1 - -From d31ef2b17c98d0b7b1040e5abda99bb1720eb8c0 Mon Sep 17 00:00:00 2001 -From: Alexander Graf -Date: Mon, 21 Aug 2023 16:51:06 +0300 -Subject: [PATCH 09/13] efi_loader: GOP: Add damage notification on BLT - -Now that we have a damage tracking API, let's populate damage done by -UEFI payloads when they BLT data onto the screen. - -Signed-off-by: Alexander Graf -Reported-by: Da Xue -Reviewed-by: Heinrich Schuchardt -[Alper: Add struct comment for new member] -Signed-off-by: Alper Nebi Yasak -Reviewed-by: Simon Glass ---- - lib/efi_loader/efi_gop.c | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c -index 41e12fa7246..1694e23dcc6 100644 ---- a/lib/efi_loader/efi_gop.c -+++ b/lib/efi_loader/efi_gop.c -@@ -24,6 +24,7 @@ static const efi_guid_t efi_gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; - * @ops: graphical output protocol interface - * @info: graphical output mode information - * @mode: graphical output mode -+ * @vdev: backing video device - * @bpix: bits per pixel - * @fb: frame buffer - */ -@@ -32,6 +33,7 @@ struct efi_gop_obj { - struct efi_gop ops; - struct efi_gop_mode_info info; - struct efi_gop_mode mode; -+ struct udevice *vdev; - /* Fields we only have access to during init */ - u32 bpix; - void *fb; -@@ -120,6 +122,7 @@ static __always_inline efi_status_t gop_blt_int(struct efi_gop *this, - u32 *fb32 = gopobj->fb; - u16 *fb16 = gopobj->fb; - struct efi_gop_pixel *buffer = __builtin_assume_aligned(bufferp, 4); -+ bool blt_to_video = (operation != EFI_BLT_VIDEO_TO_BLT_BUFFER); - - if (delta) { - /* Check for 4 byte alignment */ -@@ -243,6 +246,9 @@ static __always_inline efi_status_t gop_blt_int(struct efi_gop *this, - dlineoff += dwidth; - } - -+ if (blt_to_video) -+ video_damage(gopobj->vdev, dx, dy, width, height); -+ - return EFI_SUCCESS; - } - -@@ -549,6 +555,7 @@ efi_status_t efi_gop_register(void) - gopobj->info.pixels_per_scanline = col; - gopobj->bpix = bpix; - gopobj->fb = map_sysmem(fb_base, fb_size); -+ gopobj->vdev = vdev; - - return EFI_SUCCESS; - } --- -2.45.1 - -From 63e4c90e38c476d89148f4328778af0adcbe7adf Mon Sep 17 00:00:00 2001 -From: Alexander Graf -Date: Mon, 21 Aug 2023 16:51:07 +0300 -Subject: [PATCH 10/13] video: Only dcache flush damaged lines - -Now that we have a damage area tells us which parts of the frame buffer -actually need updating, let's only dcache flush those on video_sync() -calls. With this optimization in place, frame buffer updates - especially -on large screen such as 4k displays - speed up significantly. - -Signed-off-by: Alexander Graf -Reported-by: Da Xue -[Alper: Use damage.xstart/yend, IS_ENABLED()] -Co-developed-by: Alper Nebi Yasak -Signed-off-by: Alper Nebi Yasak ---- - drivers/video/video-uclass.c | 41 +++++++++++++++++++++++++++++++----- - 1 file changed, 36 insertions(+), 5 deletions(-) - -diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c -index cbdda274f2d..e009be4f55d 100644 ---- a/drivers/video/video-uclass.c -+++ b/drivers/video/video-uclass.c -@@ -381,6 +381,41 @@ void video_damage(struct udevice *vid, int x, int y, int width, int height) - priv->damage.yend = max(yend, priv->damage.yend); - } - -+#if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) -+static void video_flush_dcache(struct udevice *vid) -+{ -+ struct video_priv *priv = dev_get_uclass_priv(vid); -+ -+ if (!priv->flush_dcache) -+ return; -+ -+ if (!IS_ENABLED(CONFIG_VIDEO_DAMAGE)) { -+ flush_dcache_range((ulong)priv->fb, -+ ALIGN((ulong)priv->fb + priv->fb_size, -+ CONFIG_SYS_CACHELINE_SIZE)); -+ -+ return; -+ } -+ -+ if (priv->damage.xend && priv->damage.yend) { -+ int lstart = priv->damage.xstart * VNBYTES(priv->bpix); -+ int lend = priv->damage.xend * VNBYTES(priv->bpix); -+ int y; -+ -+ for (y = priv->damage.ystart; y < priv->damage.yend; y++) { -+ ulong fb = (ulong)priv->fb; -+ ulong start = fb + (y * priv->line_length) + lstart; -+ ulong end = start + lend - lstart; -+ -+ start = ALIGN_DOWN(start, CONFIG_SYS_CACHELINE_SIZE); -+ end = ALIGN(end, CONFIG_SYS_CACHELINE_SIZE); -+ -+ flush_dcache_range(start, end); -+ } -+ } -+} -+#endif -+ - /* Flush video activity to the caches */ - int video_sync(struct udevice *vid, bool force) - { -@@ -400,11 +435,7 @@ int video_sync(struct udevice *vid, bool force) - * out whether it exists? For now, ARM is safe. - */ - #if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) -- if (priv->flush_dcache) { -- flush_dcache_range((ulong)priv->fb, -- ALIGN((ulong)priv->fb + priv->fb_size, -- CONFIG_SYS_CACHELINE_SIZE)); -- } -+ video_flush_dcache(vid); - #elif defined(CONFIG_VIDEO_SANDBOX_SDL) - static ulong last_sync; - --- -2.45.1 - -From 09e504af253b3f3062891d59ad17c4fb8193dcc7 Mon Sep 17 00:00:00 2001 -From: Peter Robinson -Date: Sat, 25 May 2024 12:18:41 +0100 -Subject: [PATCH 11/13] From e9d51b4dcbfa43aa0e4d2b4f285bf94c295603e4 Mon Sep - 17 00:00:00 2001 From: Alexander Graf Date: Mon, 21 Aug - 2023 16:51:08 +0300 Subject: [PATCH 11/13] video: Use VIDEO_DAMAGE for - VIDEO_COPY - -CONFIG_VIDEO_COPY implemented a range-based copying mechanism: If we -print a single character, it will always copy the full range of bytes -from the top left corner of the character to the lower right onto the -uncached frame buffer. This includes pretty much the full line contents -of the printed character. - -Since we now have proper damage tracking, let's make use of that to reduce -the amount of data we need to copy. With this patch applied, we will only -copy the tiny rectangle surrounding characters when we print them, -speeding up the video console. - -After this, changes to the main frame buffer are not immediately copied -to the copy frame buffer, but postponed until the next video device -sync. So issue an explicit sync before inspecting the copy frame buffer -contents for the video tests. - -Signed-off-by: Alexander Graf -[Alper: Rebase for fontdata->height/w, fill_part(), fix memmove(dev), - drop from defconfig, use damage.xstart/yend, use IS_ENABLED(), - call video_sync() before copy_fb check, update video_copy test] -Co-developed-by: Alper Nebi Yasak -Signed-off-by: Alper Nebi Yasak -Signed-off-by: Peter Robinson ---- - configs/sandbox_defconfig | 1 - - drivers/video/Kconfig | 5 ++ - drivers/video/console_normal.c | 13 +---- - drivers/video/console_rotate.c | 44 +++----------- - drivers/video/console_truetype.c | 16 +---- - drivers/video/vidconsole-uclass.c | 16 ----- - drivers/video/video-uclass.c | 97 ++++++++----------------------- - drivers/video/video_bmp.c | 7 --- - include/video.h | 37 ------------ - include/video_console.h | 52 ----------------- - test/dm/video.c | 3 +- - 11 files changed, 43 insertions(+), 248 deletions(-) - -diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig -index 2051f0a3d7a..93b52f2de5c 100644 ---- a/configs/sandbox_defconfig -+++ b/configs/sandbox_defconfig -@@ -319,7 +319,6 @@ CONFIG_USB_ETH_CDC=y - CONFIG_VIDEO=y - CONFIG_VIDEO_FONT_SUN12X22=y - CONFIG_VIDEO_COPY=y --CONFIG_VIDEO_DAMAGE=y - CONFIG_CONSOLE_ROTATION=y - CONFIG_CONSOLE_TRUETYPE=y - CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y -diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig -index 7815b590481..88c6f8e6897 100644 ---- a/drivers/video/Kconfig -+++ b/drivers/video/Kconfig -@@ -83,11 +83,14 @@ config VIDEO_PCI_DEFAULT_FB_SIZE - - config VIDEO_COPY - bool "Enable copying the frame buffer to a hardware copy" -+ select VIDEO_DAMAGE - help - On some machines (e.g. x86), reading from the frame buffer is very - slow because it is uncached. To improve performance, this feature - allows the frame buffer to be kept in cached memory (allocated by - U-Boot) and then copied to the hardware frame-buffer as needed. -+ It uses the VIDEO_DAMAGE feature to keep track of regions to copy -+ and will only copy actually touched regions. - - To use this, your video driver must set @copy_base in - struct video_uc_plat. -@@ -105,6 +108,8 @@ config VIDEO_DAMAGE - regions of the frame buffer that were modified before, speeding up - screen refreshes significantly. - -+ It is also used by VIDEO_COPY to identify which regions changed. -+ - config BACKLIGHT_PWM - bool "Generic PWM based Backlight Driver" - depends on BACKLIGHT && DM_PWM -diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c -index 6634d3f27da..fbfd2caabc6 100644 ---- a/drivers/video/console_normal.c -+++ b/drivers/video/console_normal.c -@@ -36,10 +36,6 @@ static int console_set_row(struct udevice *dev, uint row, int clr) - fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes); - end = dst; - -- ret = vidconsole_sync_copy(dev, line, end); -- if (ret) -- return ret; -- - video_damage(dev->parent, - 0, - fontdata->height * row, -@@ -58,14 +54,11 @@ static int console_move_rows(struct udevice *dev, uint rowdst, - void *dst; - void *src; - int size; -- int ret; - - dst = vid_priv->fb + rowdst * fontdata->height * vid_priv->line_length; - src = vid_priv->fb + rowsrc * fontdata->height * vid_priv->line_length; - size = fontdata->height * vid_priv->line_length * count; -- ret = vidconsole_memmove(dev, dst, src, size); -- if (ret) -- return ret; -+ memmove(dst, src, size); - - video_damage(dev->parent, - 0, -@@ -110,10 +103,6 @@ static int console_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp) - fontdata->width, - fontdata->height); - -- ret = vidconsole_sync_copy(dev, start, line); -- if (ret) -- return ret; -- - return VID_TO_POS(fontdata->width); - } - -diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c -index 8129c7b2aa7..fa0b4faf63b 100644 ---- a/drivers/video/console_rotate.c -+++ b/drivers/video/console_rotate.c -@@ -22,7 +22,6 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr) - int pbytes = VNBYTES(vid_priv->bpix); - void *start, *dst, *line; - int i, j; -- int ret; - - start = vid_priv->fb + vid_priv->line_length - - (row + 1) * fontdata->height * pbytes; -@@ -33,9 +32,6 @@ static int console_set_row_1(struct udevice *dev, uint row, int clr) - fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes); - line += vid_priv->line_length; - } -- ret = vidconsole_sync_copy(dev, start, line); -- if (ret) -- return ret; - - video_damage(dev->parent, - vid_priv->xsize - ((row + 1) * fontdata->height), -@@ -55,7 +51,7 @@ static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc, - int pbytes = VNBYTES(vid_priv->bpix); - void *dst; - void *src; -- int j, ret; -+ int j; - - dst = vid_priv->fb + vid_priv->line_length - - (rowdst + count) * fontdata->height * pbytes; -@@ -63,10 +59,7 @@ static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc, - (rowsrc + count) * fontdata->height * pbytes; - - for (j = 0; j < vid_priv->ysize; j++) { -- ret = vidconsole_memmove(dev, dst, src, -- fontdata->height * pbytes * count); -- if (ret) -- return ret; -+ memmove(dst, src, fontdata->height * pbytes * count); - src += vid_priv->line_length; - dst += vid_priv->line_length; - } -@@ -106,10 +99,6 @@ static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, int cp) - return ret; - - /* We draw backwards from 'start, so account for the first line */ -- ret = vidconsole_sync_copy(dev, start - vid_priv->line_length, line); -- if (ret) -- return ret; -- - video_damage(dev->parent, - vid_priv->xsize - y - fontdata->height, - linenum - 1, -@@ -127,7 +116,7 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr) - struct video_fontdata *fontdata = priv->fontdata; - void *start, *line, *dst, *end; - int pixels = fontdata->height * vid_priv->xsize; -- int i, ret; -+ int i; - int pbytes = VNBYTES(vid_priv->bpix); - - start = vid_priv->fb + vid_priv->ysize * vid_priv->line_length - -@@ -137,9 +126,6 @@ static int console_set_row_2(struct udevice *dev, uint row, int clr) - for (i = 0; i < pixels; i++) - fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes); - end = dst; -- ret = vidconsole_sync_copy(dev, start, end); -- if (ret) -- return ret; - - video_damage(dev->parent, - 0, -@@ -165,8 +151,7 @@ static int console_move_rows_2(struct udevice *dev, uint rowdst, uint rowsrc, - vid_priv->line_length; - src = end - (rowsrc + count) * fontdata->height * - vid_priv->line_length; -- vidconsole_memmove(dev, dst, src, -- fontdata->height * vid_priv->line_length * count); -+ memmove(dst, src, fontdata->height * vid_priv->line_length * count); - - video_damage(dev->parent, - 0, -@@ -202,11 +187,6 @@ static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, int cp) - if (ret) - return ret; - -- /* Add 4 bytes to allow for the first pixel writen */ -- ret = vidconsole_sync_copy(dev, start + 4, line); -- if (ret) -- return ret; -- - video_damage(dev->parent, - x - fontdata->width + 1, - linenum - fontdata->height + 1, -@@ -223,7 +203,7 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr) - struct video_fontdata *fontdata = priv->fontdata; - int pbytes = VNBYTES(vid_priv->bpix); - void *start, *dst, *line; -- int i, j, ret; -+ int i, j; - - start = vid_priv->fb + row * fontdata->height * pbytes; - line = start; -@@ -233,9 +213,6 @@ static int console_set_row_3(struct udevice *dev, uint row, int clr) - fill_pixel_and_goto_next(&dst, clr, pbytes, pbytes); - line += vid_priv->line_length; - } -- ret = vidconsole_sync_copy(dev, start, line); -- if (ret) -- return ret; - - video_damage(dev->parent, - row * fontdata->height, -@@ -255,16 +232,13 @@ static int console_move_rows_3(struct udevice *dev, uint rowdst, uint rowsrc, - int pbytes = VNBYTES(vid_priv->bpix); - void *dst; - void *src; -- int j, ret; -+ int j; - - dst = vid_priv->fb + rowdst * fontdata->height * pbytes; - src = vid_priv->fb + rowsrc * fontdata->height * pbytes; - - for (j = 0; j < vid_priv->ysize; j++) { -- ret = vidconsole_memmove(dev, dst, src, -- fontdata->height * pbytes * count); -- if (ret) -- return ret; -+ memmove(dst, src, fontdata->height * pbytes * count); - src += vid_priv->line_length; - dst += vid_priv->line_length; - } -@@ -300,10 +274,6 @@ static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, int cp) - line = start; - - ret = fill_char_horizontally(pfont, &line, vid_priv, fontdata, NORMAL_DIRECTION); -- if (ret) -- return ret; -- /* Add a line to allow for the first pixels writen */ -- ret = vidconsole_sync_copy(dev, start + vid_priv->line_length, line); - if (ret) - return ret; - -diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c -index ed6c9cbb4f4..4cf9b013293 100644 ---- a/drivers/video/console_truetype.c -+++ b/drivers/video/console_truetype.c -@@ -195,7 +195,6 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr) - struct console_tt_priv *priv = dev_get_priv(dev); - struct console_tt_metrics *met = priv->cur_met; - void *end, *line; -- int ret; - - line = vid_priv->fb + row * met->font_size * vid_priv->line_length; - end = line + met->font_size * vid_priv->line_length; -@@ -231,9 +230,6 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr) - default: - return -ENOSYS; - } -- ret = vidconsole_sync_copy(dev, line, end); -- if (ret) -- return ret; - - video_damage(dev->parent, - 0, -@@ -253,14 +249,11 @@ static int console_truetype_move_rows(struct udevice *dev, uint rowdst, - struct console_tt_metrics *met = priv->cur_met; - void *dst; - void *src; -- int i, diff, ret; -+ int i, diff; - - dst = vid_priv->fb + rowdst * met->font_size * vid_priv->line_length; - src = vid_priv->fb + rowsrc * met->font_size * vid_priv->line_length; -- ret = vidconsole_memmove(dev, dst, src, met->font_size * -- vid_priv->line_length * count); -- if (ret) -- return ret; -+ memmove(dst, src, met->font_size * vid_priv->line_length * count); - - /* Scroll up our position history */ - diff = (rowsrc - rowdst) * met->font_size; -@@ -293,7 +286,7 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y, - u8 *bits, *data; - int advance; - void *start, *end, *line; -- int row, ret; -+ int row; - - /* First get some basic metrics about this character */ - stbtt_GetCodepointHMetrics(font, cp, &advance, &lsb); -@@ -440,9 +433,6 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y, - width, - height); - -- ret = vidconsole_sync_copy(dev, start, line); -- if (ret) -- return ret; - free(data); - - return width_frac; -diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c -index 5d06e51ff23..5f1dd0aaa41 100644 ---- a/drivers/video/vidconsole-uclass.c -+++ b/drivers/video/vidconsole-uclass.c -@@ -760,22 +760,6 @@ UCLASS_DRIVER(vidconsole) = { - .per_device_auto = sizeof(struct vidconsole_priv), - }; - --#ifdef CONFIG_VIDEO_COPY --int vidconsole_sync_copy(struct udevice *dev, void *from, void *to) --{ -- struct udevice *vid = dev_get_parent(dev); -- -- return video_sync_copy(vid, from, to); --} -- --int vidconsole_memmove(struct udevice *dev, void *dst, const void *src, -- int size) --{ -- memmove(dst, src, size); -- return vidconsole_sync_copy(dev, dst, dst + size); --} --#endif -- - int vidconsole_clear_and_reset(struct udevice *dev) - { - int ret; -diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c -index e009be4f55d..b3eeccb996d 100644 ---- a/drivers/video/video-uclass.c -+++ b/drivers/video/video-uclass.c -@@ -153,7 +153,7 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend, - struct video_priv *priv = dev_get_uclass_priv(dev); - void *start, *line; - int pixels = xend - xstart; -- int row, i, ret; -+ int row, i; - - start = priv->fb + ystart * priv->line_length; - start += xstart * VNBYTES(priv->bpix); -@@ -193,10 +193,6 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend, - line += priv->line_length; - } - -- ret = video_sync_copy(dev, start, line); -- if (ret) -- return ret; -- - video_damage(dev, xstart, ystart, xend - xstart, yend - ystart); - - return 0; -@@ -219,7 +215,6 @@ int video_reserve_from_bloblist(struct video_handoff *ho) - int video_fill(struct udevice *dev, u32 colour) - { - struct video_priv *priv = dev_get_uclass_priv(dev); -- int ret; - - switch (priv->bpix) { - case VIDEO_BPP16: -@@ -244,9 +239,6 @@ int video_fill(struct udevice *dev, u32 colour) - memset(priv->fb, colour, priv->fb_size); - break; - } -- ret = video_sync_copy(dev, priv->fb, priv->fb + priv->fb_size); -- if (ret) -- return ret; - - video_damage(dev, 0, 0, priv->xsize, priv->ysize); - -@@ -416,6 +408,27 @@ static void video_flush_dcache(struct udevice *vid) - } - #endif - -+static void video_flush_copy(struct udevice *vid) -+{ -+ struct video_priv *priv = dev_get_uclass_priv(vid); -+ -+ if (!priv->copy_fb) -+ return; -+ -+ if (priv->damage.xend && priv->damage.yend) { -+ int lstart = priv->damage.xstart * VNBYTES(priv->bpix); -+ int lend = priv->damage.xend * VNBYTES(priv->bpix); -+ int y; -+ -+ for (y = priv->damage.ystart; y < priv->damage.yend; y++) { -+ ulong offset = (y * priv->line_length) + lstart; -+ ulong len = lend - lstart; -+ -+ memcpy(priv->copy_fb + offset, priv->fb + offset, len); -+ } -+ } -+} -+ - /* Flush video activity to the caches */ - int video_sync(struct udevice *vid, bool force) - { -@@ -423,6 +436,9 @@ int video_sync(struct udevice *vid, bool force) - struct video_ops *ops = video_get_ops(vid); - int ret; - -+ if (IS_ENABLED(CONFIG_VIDEO_COPY)) -+ video_flush_copy(vid); -+ - if (ops && ops->video_sync) { - ret = ops->video_sync(vid); - if (ret) -@@ -503,69 +519,6 @@ int video_get_ysize(struct udevice *dev) - return priv->ysize; - } - --#ifdef CONFIG_VIDEO_COPY --int video_sync_copy(struct udevice *dev, void *from, void *to) --{ -- struct video_priv *priv = dev_get_uclass_priv(dev); -- -- if (priv->copy_fb) { -- long offset, size; -- -- /* Find the offset of the first byte to copy */ -- if ((ulong)to > (ulong)from) { -- size = to - from; -- offset = from - priv->fb; -- } else { -- size = from - to; -- offset = to - priv->fb; -- } -- -- /* -- * Allow a bit of leeway for valid requests somewhere near the -- * frame buffer -- */ -- if (offset < -priv->fb_size || offset > 2 * priv->fb_size) { --#ifdef DEBUG -- char str[120]; -- -- snprintf(str, sizeof(str), -- "[** FAULT sync_copy fb=%p, from=%p, to=%p, offset=%lx]", -- priv->fb, from, to, offset); -- console_puts_select_stderr(true, str); --#endif -- return -EFAULT; -- } -- -- /* -- * Silently crop the memcpy. This allows callers to avoid doing -- * this themselves. It is common for the end pointer to go a -- * few lines after the end of the frame buffer, since most of -- * the update algorithms terminate a line after their last write -- */ -- if (offset + size > priv->fb_size) { -- size = priv->fb_size - offset; -- } else if (offset < 0) { -- size += offset; -- offset = 0; -- } -- -- memcpy(priv->copy_fb + offset, priv->fb + offset, size); -- } -- -- return 0; --} -- --int video_sync_copy_all(struct udevice *dev) --{ -- struct video_priv *priv = dev_get_uclass_priv(dev); -- -- video_sync_copy(dev, priv->fb, priv->fb + priv->fb_size); -- -- return 0; --} -- --#endif -- - #define SPLASH_DECL(_name) \ - extern u8 __splash_ ## _name ## _begin[]; \ - extern u8 __splash_ ## _name ## _end[] -diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c -index 10943b9ca19..da2bbe864a0 100644 ---- a/drivers/video/video_bmp.c -+++ b/drivers/video/video_bmp.c -@@ -268,7 +268,6 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, - enum video_format eformat; - struct bmp_color_table_entry *palette; - int hdr_size; -- int ret; - - if (!bmp || !(bmp->header.signature[0] == 'B' && - bmp->header.signature[1] == 'M')) { -@@ -462,11 +461,5 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, - - video_damage(dev, x, y, width, height); - -- /* Find the position of the top left of the image in the framebuffer */ -- fb = (uchar *)(priv->fb + y * priv->line_length + x * bpix / 8); -- ret = video_sync_copy(dev, start, fb); -- if (ret) -- return log_ret(ret); -- - return video_sync(dev, false); - } -diff --git a/include/video.h b/include/video.h -index 1310195f307..29eff3c0900 100644 ---- a/include/video.h -+++ b/include/video.h -@@ -353,43 +353,6 @@ void video_set_default_colors(struct udevice *dev, bool invert); - */ - int video_default_font_height(struct udevice *dev); - --#ifdef CONFIG_VIDEO_COPY --/** -- * vidconsole_sync_copy() - Sync back to the copy framebuffer -- * -- * This ensures that the copy framebuffer has the same data as the framebuffer -- * for a particular region. It should be called after the framebuffer is updated -- * -- * @from and @to can be in either order. The region between them is synced. -- * -- * @dev: Vidconsole device being updated -- * @from: Start/end address within the framebuffer (->fb) -- * @to: Other address within the frame buffer -- * Return: 0 if OK, -EFAULT if the start address is before the start of the -- * frame buffer start -- */ --int video_sync_copy(struct udevice *dev, void *from, void *to); -- --/** -- * video_sync_copy_all() - Sync the entire framebuffer to the copy -- * -- * @dev: Vidconsole device being updated -- * Return: 0 (always) -- */ --int video_sync_copy_all(struct udevice *dev); --#else --static inline int video_sync_copy(struct udevice *dev, void *from, void *to) --{ -- return 0; --} -- --static inline int video_sync_copy_all(struct udevice *dev) --{ -- return 0; --} -- --#endif -- - /** - * video_damage() - Notify the video subsystem about screen updates. - * -diff --git a/include/video_console.h b/include/video_console.h -index 8b5928dc5eb..8806d10f946 100644 ---- a/include/video_console.h -+++ b/include/video_console.h -@@ -529,56 +529,4 @@ void vidconsole_list_fonts(struct udevice *dev); - */ - int vidconsole_get_font_size(struct udevice *dev, const char **name, uint *sizep); - --#ifdef CONFIG_VIDEO_COPY --/** -- * vidconsole_sync_copy() - Sync back to the copy framebuffer -- * -- * This ensures that the copy framebuffer has the same data as the framebuffer -- * for a particular region. It should be called after the framebuffer is updated -- * -- * @from and @to can be in either order. The region between them is synced. -- * -- * @dev: Vidconsole device being updated -- * @from: Start/end address within the framebuffer (->fb) -- * @to: Other address within the frame buffer -- * Return: 0 if OK, -EFAULT if the start address is before the start of the -- * frame buffer start -- */ --int vidconsole_sync_copy(struct udevice *dev, void *from, void *to); -- --/** -- * vidconsole_memmove() - Perform a memmove() within the frame buffer -- * -- * This handles a memmove(), e.g. for scrolling. It also updates the copy -- * framebuffer. -- * -- * @dev: Vidconsole device being updated -- * @dst: Destination address within the framebuffer (->fb) -- * @src: Source address within the framebuffer (->fb) -- * @size: Number of bytes to transfer -- * Return: 0 if OK, -EFAULT if the start address is before the start of the -- * frame buffer start -- */ --int vidconsole_memmove(struct udevice *dev, void *dst, const void *src, -- int size); --#else -- --#include -- --static inline int vidconsole_sync_copy(struct udevice *dev, void *from, -- void *to) --{ -- return 0; --} -- --static inline int vidconsole_memmove(struct udevice *dev, void *dst, -- const void *src, int size) --{ -- memmove(dst, src, size); -- -- return 0; --} -- --#endif -- - #endif -diff --git a/test/dm/video.c b/test/dm/video.c -index 8c7d9800a42..4c3bcd26e94 100644 ---- a/test/dm/video.c -+++ b/test/dm/video.c -@@ -106,6 +106,7 @@ static int check_copy_frame_buffer(struct unit_test_state *uts, - if (!IS_ENABLED(CONFIG_VIDEO_COPY)) - return 0; - -+ video_sync(dev, false); - ut_assertf(!memcmp(priv->fb, priv->copy_fb, priv->fb_size), - "Copy framebuffer does not match fb"); - -@@ -706,7 +707,7 @@ static int dm_test_video_copy(struct unit_test_state *uts) - vidconsole_put_string(con, test_string); - vidconsole_put_string(con, test_string); - ut_asserteq(7589, compress_frame_buffer(uts, dev, false)); -- ut_asserteq(5278, compress_frame_buffer(uts, dev, true)); -+ ut_asserteq(4127, compress_frame_buffer(uts, dev, true)); - - return 0; - } --- -2.45.1 - -From 6b90fed4745a705c1ca660a346a3563f0da8def5 Mon Sep 17 00:00:00 2001 -From: Alexander Graf -Date: Mon, 21 Aug 2023 16:51:09 +0300 -Subject: [PATCH 12/13] video: Always compile cache flushing code - -The dcache flushing code path was conditional on ARM && !DCACHE config -options. However, dcaches exist on other platforms as well and may need -clearing if their driver requires it. - -Simplify the compile logic and always enable the dcache flush logic in -the video core. That way, drivers can always rely on it to call the arch -specific callbacks. - -This will increase code size for non-ARM platforms with CONFIG_VIDEO=y -slightly. - -Reported-by: Heinrich Schuchardt -Signed-off-by: Alexander Graf -Reviewed-by: Simon Glass -Signed-off-by: Alper Nebi Yasak ---- - drivers/video/video-uclass.c | 14 +++++--------- - 1 file changed, 5 insertions(+), 9 deletions(-) - -diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c -index b3eeccb996d..33ad9ff3fab 100644 ---- a/drivers/video/video-uclass.c -+++ b/drivers/video/video-uclass.c -@@ -373,11 +373,13 @@ void video_damage(struct udevice *vid, int x, int y, int width, int height) - priv->damage.yend = max(yend, priv->damage.yend); - } - --#if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) - static void video_flush_dcache(struct udevice *vid) - { - struct video_priv *priv = dev_get_uclass_priv(vid); - -+ if (CONFIG_IS_ENABLED(SYS_DCACHE_OFF)) -+ return; -+ - if (!priv->flush_dcache) - return; - -@@ -406,7 +408,6 @@ static void video_flush_dcache(struct udevice *vid) - } - } - } --#endif - - static void video_flush_copy(struct udevice *vid) - { -@@ -445,14 +446,9 @@ int video_sync(struct udevice *vid, bool force) - return ret; - } - -- /* -- * flush_dcache_range() is declared in common.h but it seems that some -- * architectures do not actually implement it. Is there a way to find -- * out whether it exists? For now, ARM is safe. -- */ --#if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) - video_flush_dcache(vid); --#elif defined(CONFIG_VIDEO_SANDBOX_SDL) -+ -+#if defined(CONFIG_VIDEO_SANDBOX_SDL) - static ulong last_sync; - - if (force || get_timer(last_sync) > 100) { --- -2.45.1 - -From 7cfa667a11f245596e4b31842b0d646929be24e9 Mon Sep 17 00:00:00 2001 -From: Alexander Graf -Date: Mon, 21 Aug 2023 16:51:10 +0300 -Subject: [PATCH 13/13] video: Enable VIDEO_DAMAGE for drivers that need it - -Some drivers call video_set_flush_dcache() to indicate that they want to -have the dcache flushed for the frame buffer. These drivers benefit from -our new video damage control, because we can reduce the amount of memory -that gets flushed significantly. - -This patch enables video damage control for all device drivers that call -video_set_flush_dcache() to make sure they benefit from it. - -Signed-off-by: Alexander Graf -[Alper: Add to VIDEO_TIDSS, imply instead of select] -Co-developed-by: Alper Nebi Yasak -Signed-off-by: Alper Nebi Yasak -Reviewed-by: Simon Glass ---- - arch/arm/mach-sunxi/Kconfig | 1 + - drivers/video/Kconfig | 8 ++++++++ - drivers/video/exynos/Kconfig | 1 + - drivers/video/imx/Kconfig | 1 + - drivers/video/meson/Kconfig | 1 + - drivers/video/rockchip/Kconfig | 1 + - drivers/video/stm32/Kconfig | 1 + - drivers/video/tegra20/Kconfig | 1 + - drivers/video/tidss/Kconfig | 1 + - 9 files changed, 16 insertions(+) - -diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig -index ddf9414b08e..3c9745065ba 100644 ---- a/arch/arm/mach-sunxi/Kconfig -+++ b/arch/arm/mach-sunxi/Kconfig -@@ -863,6 +863,7 @@ config VIDEO_SUNXI - depends on !SUNXI_GEN_NCAT2 - select VIDEO - select DISPLAY -+ imply VIDEO_DAMAGE - imply VIDEO_DT_SIMPLEFB - default y - ---help--- -diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig -index 88c6f8e6897..06d3ed8a736 100644 ---- a/drivers/video/Kconfig -+++ b/drivers/video/Kconfig -@@ -499,6 +499,7 @@ config VIDEO_LCD_ANX9804 - - config ATMEL_LCD - bool "Atmel LCD panel support" -+ imply VIDEO_DAMAGE - depends on ARCH_AT91 - - config ATMEL_LCD_BGR555 -@@ -508,6 +509,7 @@ config ATMEL_LCD_BGR555 - - config VIDEO_BCM2835 - bool "Display support for BCM2835" -+ imply VIDEO_DAMAGE - help - The graphics processor already sets up the display so this driver - simply checks the resolution and then sets up the frame buffer with -@@ -671,6 +673,7 @@ source "drivers/video/meson/Kconfig" - - config VIDEO_MVEBU - bool "Armada XP LCD controller" -+ imply VIDEO_DAMAGE - ---help--- - Support for the LCD controller integrated in the Marvell - Armada XP SoC. -@@ -705,6 +708,7 @@ config NXP_TDA19988 - - config ATMEL_HLCD - bool "Enable ATMEL video support using HLCDC" -+ imply VIDEO_DAMAGE - help - HLCDC supports video output to an attached LCD panel. - -@@ -781,6 +785,7 @@ source "drivers/video/tidss/Kconfig" - - config VIDEO_TEGRA124 - bool "Enable video support on Tegra124" -+ imply VIDEO_DAMAGE - help - Tegra124 supports many video output options including eDP and - HDMI. At present only eDP is supported by U-Boot. This option -@@ -795,6 +800,7 @@ source "drivers/video/imx/Kconfig" - - config VIDEO_MXS - bool "Enable video support on i.MX28/i.MX6UL/i.MX7 SoCs" -+ imply VIDEO_DAMAGE - help - Enable framebuffer driver for i.MX28/i.MX6UL/i.MX7 processors - -@@ -857,6 +863,7 @@ config VIDEO_DW_MIPI_DSI - - config VIDEO_SIMPLE - bool "Simple display driver for preconfigured display" -+ imply VIDEO_DAMAGE - help - Enables a simple generic display driver which utilizes the - simple-framebuffer devicetree bindings. -@@ -875,6 +882,7 @@ config VIDEO_DT_SIMPLEFB - - config VIDEO_MCDE_SIMPLE - bool "Simple driver for ST-Ericsson MCDE with preconfigured display" -+ imply VIDEO_DAMAGE - help - Enables a simple display driver for ST-Ericsson MCDE - (Multichannel Display Engine), which reads the configuration from -diff --git a/drivers/video/exynos/Kconfig b/drivers/video/exynos/Kconfig -index 599d19d5ecc..a2cf752aac0 100644 ---- a/drivers/video/exynos/Kconfig -+++ b/drivers/video/exynos/Kconfig -@@ -12,6 +12,7 @@ config EXYNOS_DP - - config EXYNOS_FB - bool "Exynos FIMD support" -+ imply VIDEO_DAMAGE - - config EXYNOS_MIPI_DSIM - bool "Exynos MIPI DSI support" -diff --git a/drivers/video/imx/Kconfig b/drivers/video/imx/Kconfig -index 34e8b640595..5db3e5c0499 100644 ---- a/drivers/video/imx/Kconfig -+++ b/drivers/video/imx/Kconfig -@@ -2,6 +2,7 @@ - config VIDEO_IPUV3 - bool "i.MX IPUv3 Core video support" - depends on VIDEO && (MX5 || MX6) -+ imply VIDEO_DAMAGE - help - This enables framebuffer driver for i.MX processors working - on the IPUv3(Image Processing Unit) internal graphic processor. -diff --git a/drivers/video/meson/Kconfig b/drivers/video/meson/Kconfig -index 3c2d72d019b..fcf486ca0a3 100644 ---- a/drivers/video/meson/Kconfig -+++ b/drivers/video/meson/Kconfig -@@ -8,5 +8,6 @@ config VIDEO_MESON - bool "Enable Amlogic Meson video support" - depends on VIDEO - select DISPLAY -+ imply VIDEO_DAMAGE - help - Enable Amlogic Meson Video Processing Unit video support. -diff --git a/drivers/video/rockchip/Kconfig b/drivers/video/rockchip/Kconfig -index 01804dcb1cc..0f4550a29e3 100644 ---- a/drivers/video/rockchip/Kconfig -+++ b/drivers/video/rockchip/Kconfig -@@ -11,6 +11,7 @@ - menuconfig VIDEO_ROCKCHIP - bool "Enable Rockchip Video Support" - depends on VIDEO -+ imply VIDEO_DAMAGE - help - Rockchip SoCs provide video output capabilities for High-Definition - Multimedia Interface (HDMI), Low-voltage Differential Signalling -diff --git a/drivers/video/stm32/Kconfig b/drivers/video/stm32/Kconfig -index 48066063e4c..c354c402c28 100644 ---- a/drivers/video/stm32/Kconfig -+++ b/drivers/video/stm32/Kconfig -@@ -8,6 +8,7 @@ - menuconfig VIDEO_STM32 - bool "Enable STM32 video support" - depends on VIDEO -+ imply VIDEO_DAMAGE - help - STM32 supports many video output options including RGB and - DSI. This option enables these supports which can be used on -diff --git a/drivers/video/tegra20/Kconfig b/drivers/video/tegra20/Kconfig -index f5c4843e119..2232b0b3ff5 100644 ---- a/drivers/video/tegra20/Kconfig -+++ b/drivers/video/tegra20/Kconfig -@@ -1,6 +1,7 @@ - config VIDEO_TEGRA20 - bool "Enable Display Controller support on Tegra20 and Tegra 30" - depends on OF_CONTROL -+ imply VIDEO_DAMAGE - help - T20/T30 support video output to an attached LCD panel as well as - other options such as HDMI. Only the LCD is supported in U-Boot. -diff --git a/drivers/video/tidss/Kconfig b/drivers/video/tidss/Kconfig -index 95086f3a5d6..3291b3ceb8d 100644 ---- a/drivers/video/tidss/Kconfig -+++ b/drivers/video/tidss/Kconfig -@@ -11,6 +11,7 @@ - menuconfig VIDEO_TIDSS - bool "Enable TIDSS video support" - depends on VIDEO -+ imply VIDEO_DAMAGE - help - TIDSS supports video output options LVDS and - DPI . This option enables these supports which can be used on --- -2.45.1 - diff --git a/Allwinner-fix-booting-on-a-number-of-devices.patch b/Allwinner-fix-booting-on-a-number-of-devices.patch new file mode 100644 index 0000000..2b08e13 --- /dev/null +++ b/Allwinner-fix-booting-on-a-number-of-devices.patch @@ -0,0 +1,27 @@ +From b8ea3cebde98866b7cbb4e8f9bb6dfdee529a549 Mon Sep 17 00:00:00 2001 +From: Peter Robinson +Date: Wed, 27 Aug 2025 00:23:28 +0100 +Subject: [PATCH] Allwinner: fix booting on a number of devices + +Revert "sunxi: enable MMU_PGPROT proper page table protection" + +This reverts commit 16cfccda4dbf0b53473b8212897f5c63bfbeb6e1. +--- + arch/arm/Kconfig | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig +index 40368abc297..b8be270e4d7 100644 +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -1207,7 +1207,6 @@ config ARCH_SUNXI + select DM_SPI_FLASH if SPI && MTD + select DM_KEYBOARD + select DM_SERIAL +- select MMU_PGPROT if ARM64 + select OF_BOARD_SETUP + select OF_CONTROL + select PINCTRL +-- +2.51.0 + diff --git a/FUSB302-USB-C-controller-support.patch b/FUSB302-USB-C-controller-support.patch deleted file mode 100644 index a25f8dd..0000000 --- a/FUSB302-USB-C-controller-support.patch +++ /dev/null @@ -1,6018 +0,0 @@ -From patchwork Thu Sep 5 15:08:37 2024 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Sebastian Reichel -X-Patchwork-Id: 1981315 -X-Patchwork-Delegate: ykai007@gmail.com -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - dkim=pass (2048-bit key; - unprotected) header.d=collabora.com header.i=@collabora.com - header.a=rsa-sha256 header.s=mail header.b=VOvjn+x1; - dkim-atps=neutral -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de - [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1)) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4X02zx1gZpz1yXY - for ; Fri, 6 Sep 2024 01:18:05 +1000 (AEST) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id E002A88CD2; - Thu, 5 Sep 2024 17:17:16 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=collabora.com -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de -Authentication-Results: phobos.denx.de; - dkim=pass (2048-bit key; - unprotected) header.d=collabora.com header.i=@collabora.com - header.b="VOvjn+x1"; - dkim-atps=neutral -Received: by phobos.denx.de (Postfix, from userid 109) - id 9ED9788CD2; Thu, 5 Sep 2024 17:17:16 +0200 (CEST) -X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de -X-Spam-Level: -X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, - DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, - T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no - version=3.4.2 -Received: from bali.collaboradmins.com (bali.collaboradmins.com - [IPv6:2a01:4f8:201:9162::2]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) - (No client certificate requested) - by phobos.denx.de (Postfix) with ESMTPS id 8F95B88CC0 - for ; Thu, 5 Sep 2024 17:17:08 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=collabora.com -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=sebastian.reichel@collabora.com -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; - s=mail; t=1725549428; - bh=GUi0ELUr54qxRL+zUYIh2cpnf8aAbxP3km5z9ihBLiA=; - h=From:To:Cc:Subject:Date:In-Reply-To:References:From; - b=VOvjn+x1YAGL8uuX8oe/eA1AShGOQ+65YCdPN4UIul65K52PZGC4Rh30foWYR3GYv - ksyxZc+jsHQcN72mVdV3njT/SIGekJFu683r6aomMjm3Mrc+uUUF7QcQdx2QgObWXW - 3RmaT4So9PLApr20wdqN8mqL3PND0cpUJiGoZG18Nu+sX+XJYGTtQ3qo+p00ZjT6TY - TXhYMaIJeqISS7ocTqHwKpWZQ/5uXBBLOuLnlKRVhjHEVg6Ds0DFB8/XFwU24CB0VM - Xutwxqot6qKBLUt/yDrX8upercY5M0tia9Ymno4ezs/mVrRI6ztNPgNmjPUzaBq/T2 - 9q+TUcwqV3v1A== -Received: from jupiter.universe (dyndsl-091-248-189-231.ewe-ip-backbone.de - [91.248.189.231]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest - SHA256) - (No client certificate requested) (Authenticated sender: sre) - by bali.collaboradmins.com (Postfix) with ESMTPSA id EC7AC17E1167; - Thu, 5 Sep 2024 17:17:07 +0200 (CEST) -Received: by jupiter.universe (Postfix, from userid 1000) - id 9F52C4800EB; Thu, 05 Sep 2024 17:17:07 +0200 (CEST) -From: Sebastian Reichel -To: Marek Vasut , u-boot@lists.denx.de, - Jonas Karlman , Soeren Moch -Cc: Eugen Hristev , - Tim Harvey , Kever Yang , - Philipp Tomsich , Simon Glass , - Sebastian Reichel -Subject: [PATCH v6 1/6] usb: tcpm: add core framework -Date: Thu, 5 Sep 2024 17:08:37 +0200 -Message-ID: <20240905151707.59101-2-sebastian.reichel@collabora.com> -X-Mailer: git-send-email 2.45.2 -In-Reply-To: <20240905151707.59101-1-sebastian.reichel@collabora.com> -References: <20240905151707.59101-1-sebastian.reichel@collabora.com> -MIME-Version: 1.0 -X-BeenThere: u-boot@lists.denx.de -X-Mailman-Version: 2.1.39 -Precedence: list -List-Id: U-Boot discussion -List-Unsubscribe: , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: , - -Errors-To: u-boot-bounces@lists.denx.de -Sender: "U-Boot" -X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de -X-Virus-Status: Clean - -This adds TCPM framework in preparation for fusb302 support, which can -handle USB power delivery messages. This is needed to solve issues with -devices, that are running from a USB-C port supporting USB-PD, but not -having a battery. - -Such a device currently boots to the kernel without interacting with -the power-supply at all. If there are no USB-PD message replies within -5 seconds, the power-supply assumes the peripheral is not capable of -USB-PD. It usually takes more than 5 seconds for the system to reach -the kernel and probe the I2C based fusb302 chip driver. Thus the -system always runs into this state. The power-supply's solution to -fix this error state is a hard reset, which involves removing the -power from VBUS. Boards without a battery (or huge capacitors) will -reset at this point resulting in a boot loop. - -This imports the TCPM framework from the kernel. The porting has -originally been done by Rockchip using hardware timers and the Linux -kernel's TCPM code from some years ago. - -I had a look at upgrading to the latest TCPM kernel code, but that -beast became a lot more complex due to adding more USB-C features. -I believe these features are not needed in U-Boot and with multiple -kthreads and hrtimers being involved it is non-trivial to port them. -Instead I worked on stripping down features from the Rockchip port -to an even more basic level. Also the TCPM code has been reworked -to avoid complete use of any timers (Rockchip used SoC specific -hardware timers + IRQ to implement delayed work mechanism). Instead -the delayed state changes are handled directly from the poll loop. - -Note, that (in contrast to the original Rockchip port) the state -machine has the same hard reset quirk, that the kernel has - i.e. -it avoids disabling the CC pin resistors for devices that are not -self-powered. Without that quirk, the Radxa Rock 5B will not just -end up doing a machine reset when a hard reset is triggered, but will -not even recover, because the CPU will loose power and the FUSB302 -will keep this state because of leak voltage arriving through the RX -serial pin (assuming a serial adapter is connected). - -This also includes a 'tcpm' command, which can be used to get -information about the current state and the negotiated voltage -and current. - -Co-developed-by: Wang Jie -Signed-off-by: Wang Jie -Tested-by: Soeren Moch -Signed-off-by: Sebastian Reichel ---- - Makefile | 1 + - cmd/Kconfig | 7 + - cmd/Makefile | 1 + - cmd/tcpm.c | 136 ++ - doc/usage/cmd/tcpm.rst | 66 + - doc/usage/index.rst | 1 + - drivers/usb/Kconfig | 2 + - drivers/usb/tcpm/Kconfig | 8 + - drivers/usb/tcpm/Makefile | 3 + - drivers/usb/tcpm/tcpm-internal.h | 173 +++ - drivers/usb/tcpm/tcpm-uclass.c | 149 ++ - drivers/usb/tcpm/tcpm.c | 2288 ++++++++++++++++++++++++++++++ - include/dm/uclass-id.h | 1 + - include/usb/pd.h | 516 +++++++ - include/usb/tcpm.h | 99 ++ - 15 files changed, 3451 insertions(+) - create mode 100644 cmd/tcpm.c - create mode 100644 doc/usage/cmd/tcpm.rst - create mode 100644 drivers/usb/tcpm/Kconfig - create mode 100644 drivers/usb/tcpm/Makefile - create mode 100644 drivers/usb/tcpm/tcpm-internal.h - create mode 100644 drivers/usb/tcpm/tcpm-uclass.c - create mode 100644 drivers/usb/tcpm/tcpm.c - create mode 100644 include/usb/pd.h - create mode 100644 include/usb/tcpm.h - -diff --git a/Makefile b/Makefile -index 74df5d177c1f..5a581199c170 100644 ---- a/Makefile -+++ b/Makefile -@@ -879,6 +879,7 @@ libs-y += drivers/usb/musb/ - libs-y += drivers/usb/musb-new/ - libs-y += drivers/usb/isp1760/ - libs-y += drivers/usb/phy/ -+libs-y += drivers/usb/tcpm/ - libs-y += drivers/usb/ulpi/ - ifdef CONFIG_POST - libs-y += post/ -diff --git a/cmd/Kconfig b/cmd/Kconfig -index 978f44eda426..7710bee22ace 100644 ---- a/cmd/Kconfig -+++ b/cmd/Kconfig -@@ -221,6 +221,13 @@ config CMD_REGINFO - help - Register dump - -+config CMD_TCPM -+ bool "tcpm" -+ depends on TYPEC_TCPM -+ help -+ Show voltage and current negotiated via USB PD as well as the -+ current state of the Type C Port Manager (TCPM) state machine. -+ - config CMD_TLV_EEPROM - bool "tlv_eeprom" - depends on I2C_EEPROM -diff --git a/cmd/Makefile b/cmd/Makefile -index 87133cc27a8a..bd0b23ef1013 100644 ---- a/cmd/Makefile -+++ b/cmd/Makefile -@@ -172,6 +172,7 @@ obj-$(CONFIG_CMD_SMBIOS) += smbios.o - obj-$(CONFIG_CMD_SMC) += smccc.o - obj-$(CONFIG_CMD_SYSBOOT) += sysboot.o - obj-$(CONFIG_CMD_STACKPROTECTOR_TEST) += stackprot_test.o -+obj-$(CONFIG_CMD_TCPM) += tcpm.o - obj-$(CONFIG_CMD_TEMPERATURE) += temperature.o - obj-$(CONFIG_CMD_TERMINAL) += terminal.o - obj-$(CONFIG_CMD_TIME) += time.o -diff --git a/cmd/tcpm.c b/cmd/tcpm.c -new file mode 100644 -index 000000000000..962cd234a869 ---- /dev/null -+++ b/cmd/tcpm.c -@@ -0,0 +1,136 @@ -+// SPDX-License-Identifier: GPL-2.0+ -+/* -+ * (C) Copyright 2024 Collabora -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+#define LIMIT_DEV 32 -+#define LIMIT_PARENT 20 -+ -+static struct udevice *currdev; -+ -+static int do_dev(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -+{ -+ char *name; -+ int ret = -ENODEV; -+ -+ switch (argc) { -+ case 2: -+ name = argv[1]; -+ ret = tcpm_get(name, &currdev); -+ if (ret) { -+ log_err("Can't get TCPM %s: %d (%s)!\n", name, ret, errno_str(ret)); -+ return CMD_RET_FAILURE; -+ } -+ case 1: -+ if (!currdev) { -+ log_err("TCPM device is not set!\n\n"); -+ return CMD_RET_USAGE; -+ } -+ -+ printf("dev: %d @ %s\n", dev_seq(currdev), currdev->name); -+ } -+ -+ return CMD_RET_SUCCESS; -+} -+ -+static int do_list(struct cmd_tbl *cmdtp, int flag, int argc, -+ char *const argv[]) -+{ -+ struct udevice *dev; -+ int ret, err = 0; -+ -+ printf("| %-*.*s| %-*.*s| %s @ %s\n", -+ LIMIT_DEV, LIMIT_DEV, "Name", -+ LIMIT_PARENT, LIMIT_PARENT, "Parent name", -+ "Parent uclass", "seq"); -+ -+ for (ret = uclass_first_device_check(UCLASS_TCPM, &dev); dev; -+ ret = uclass_next_device_check(&dev)) { -+ if (ret) -+ err = ret; -+ -+ printf("| %-*.*s| %-*.*s| %s @ %d | status: %i\n", -+ LIMIT_DEV, LIMIT_DEV, dev->name, -+ LIMIT_PARENT, LIMIT_PARENT, dev->parent->name, -+ dev_get_uclass_name(dev->parent), dev_seq(dev->parent), -+ ret); -+ } -+ -+ if (err) -+ return CMD_RET_FAILURE; -+ -+ return CMD_RET_SUCCESS; -+} -+ -+int do_print_info(struct udevice *dev) -+{ -+ enum typec_orientation orientation = tcpm_get_orientation(dev); -+ const char *state = tcpm_get_state(dev); -+ int pd_rev = tcpm_get_pd_rev(dev); -+ int mv = tcpm_get_voltage(dev); -+ int ma = tcpm_get_current(dev); -+ enum typec_role pwr_role = tcpm_get_pwr_role(dev); -+ enum typec_data_role data_role = tcpm_get_data_role(dev); -+ bool connected = tcpm_is_connected(dev); -+ -+ if (!connected) { -+ printf("TCPM State: %s\n", state); -+ return 0; -+ } -+ -+ printf("Orientation: %s\n", typec_orientation_name[orientation]); -+ printf("PD Revision: %s\n", typec_pd_rev_name[pd_rev]); -+ printf("Power Role: %s\n", typec_role_name[pwr_role]); -+ printf("Data Role: %s\n", typec_data_role_name[data_role]); -+ printf("Voltage: %2d.%03d V\n", mv / 1000, mv % 1000); -+ printf("Current: %2d.%03d A\n", ma / 1000, ma % 1000); -+ -+ return 0; -+} -+ -+static int do_info(struct cmd_tbl *cmdtp, int flag, int argc, -+ char *const argv[]) -+{ -+ if (!currdev) { -+ printf("First, set the TCPM device!\n"); -+ return CMD_RET_USAGE; -+ } -+ -+ return do_print_info(currdev); -+} -+ -+static struct cmd_tbl subcmd[] = { -+ U_BOOT_CMD_MKENT(dev, 2, 1, do_dev, "", ""), -+ U_BOOT_CMD_MKENT(list, 1, 1, do_list, "", ""), -+ U_BOOT_CMD_MKENT(info, 1, 1, do_info, "", ""), -+}; -+ -+static int do_tcpm(struct cmd_tbl *cmdtp, int flag, int argc, -+ char *const argv[]) -+{ -+ struct cmd_tbl *cmd; -+ -+ argc--; -+ argv++; -+ -+ cmd = find_cmd_tbl(argv[0], subcmd, ARRAY_SIZE(subcmd)); -+ if (!cmd || argc > cmd->maxargs) -+ return CMD_RET_USAGE; -+ -+ return cmd->cmd(cmdtp, flag, argc, argv); -+} -+ -+ /**************************************************/ -+ -+U_BOOT_CMD(tcpm, CONFIG_SYS_MAXARGS, 1, do_tcpm, -+ "TCPM sub-system", -+ "list - list TCPM devices\n" -+ "tcpm dev [name] - show or [set] operating TCPM device\n" -+ "tcpm info - dump information\n" -+); -diff --git a/doc/usage/cmd/tcpm.rst b/doc/usage/cmd/tcpm.rst -new file mode 100644 -index 000000000000..1e8199c0f89c ---- /dev/null -+++ b/doc/usage/cmd/tcpm.rst -@@ -0,0 +1,66 @@ -+.. SPDX-License-Identifier: GPL-2.0+: -+ -+.. index:: -+ single: tcpm (command) -+ -+tcpm command -+============ -+ -+Synopsis -+-------- -+ -+:: -+ -+ tcpm dev [devname] -+ tcpm info -+ tcpm list -+ -+Description -+----------- -+ -+The tcpm command is used to control USB-PD controllers, also known as TypeC Port Manager (TCPM). -+ -+The 'tcpm dev' command shows or set current TCPM device. -+ -+ devname -+ device name to change -+ -+The 'tcpm info' command displays the current state of the device -+ -+The 'tcpm list' command displays the list available devices. -+ -+Examples -+-------- -+ -+The 'tcpm info' command displays device's status: -+:: -+ -+ => tcpm info -+ Orientation: normal -+ PD Revision: rev3 -+ Power Role: sink -+ Data Role: device -+ Voltage: 20.000 V -+ Current: 2.250 A -+ -+The current device can be shown or set via 'tcpm dev' command: -+:: -+ -+ => tcpm dev -+ TCPM device is not set! -+ => tcpm dev usb-typec@22 -+ dev: 0 @ usb-typec@22 -+ => tcpm dev -+ dev: 0 @ usb-typec@22 -+ -+The list of available devices can be shown via 'tcpm list' command: -+:: -+ -+ => tcpm list -+ | Name | Parent name | Parent uclass @ seq -+ | usb-typec@22 | i2c@feac0000 | i2c @ 4 | status: 0 -+ -+Configuration -+------------- -+ -+The tcpm command is only available if CONFIG_CMD_TCPM=y. -diff --git a/doc/usage/index.rst b/doc/usage/index.rst -index 6a218c46b4e4..b4be42f59119 100644 ---- a/doc/usage/index.rst -+++ b/doc/usage/index.rst -@@ -111,6 +111,7 @@ Shell commands - cmd/smbios - cmd/sound - cmd/source -+ cmd/tcpm - cmd/temperature - cmd/tftpput - cmd/trace -diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig -index a972d87c7ad4..985d3a9ef7e6 100644 ---- a/drivers/usb/Kconfig -+++ b/drivers/usb/Kconfig -@@ -85,6 +85,8 @@ source "drivers/usb/emul/Kconfig" - - source "drivers/usb/phy/Kconfig" - -+source "drivers/usb/tcpm/Kconfig" -+ - source "drivers/usb/ulpi/Kconfig" - - if USB_HOST -diff --git a/drivers/usb/tcpm/Kconfig b/drivers/usb/tcpm/Kconfig -new file mode 100644 -index 000000000000..55bf8e202b90 ---- /dev/null -+++ b/drivers/usb/tcpm/Kconfig -@@ -0,0 +1,8 @@ -+# SPDX-License-Identifier: GPL-2.0 -+ -+config TYPEC_TCPM -+ tristate "USB Type-C Port Controller Manager" -+ depends on DM -+ help -+ The Type-C Port Controller Manager provides a USB PD and USB Type-C -+ state machine for use with Type-C Port Controllers. -diff --git a/drivers/usb/tcpm/Makefile b/drivers/usb/tcpm/Makefile -new file mode 100644 -index 000000000000..a0f76436f3fd ---- /dev/null -+++ b/drivers/usb/tcpm/Makefile -@@ -0,0 +1,3 @@ -+# SPDX-License-Identifier: GPL-2.0 -+ -+obj-$(CONFIG_TYPEC_TCPM) += tcpm.o tcpm-uclass.o -diff --git a/drivers/usb/tcpm/tcpm-internal.h b/drivers/usb/tcpm/tcpm-internal.h -new file mode 100644 -index 000000000000..561442090027 ---- /dev/null -+++ b/drivers/usb/tcpm/tcpm-internal.h -@@ -0,0 +1,173 @@ -+/* SPDX-License-Identifier: GPL-2.0-or-later */ -+/* -+ * Copyright 2015-2017 Google, Inc -+ * Copyright 2024 Collabora -+ */ -+ -+#ifndef __LINUX_USB_TCPM_INTERNAL_H -+#define __LINUX_USB_TCPM_INTERNAL_H -+ -+#define FOREACH_TCPM_STATE(S) \ -+ S(INVALID_STATE), \ -+ S(TOGGLING), \ -+ S(SRC_UNATTACHED), \ -+ S(SRC_ATTACH_WAIT), \ -+ S(SRC_ATTACHED), \ -+ S(SRC_STARTUP), \ -+ S(SRC_SEND_CAPABILITIES), \ -+ S(SRC_SEND_CAPABILITIES_TIMEOUT), \ -+ S(SRC_NEGOTIATE_CAPABILITIES), \ -+ S(SRC_TRANSITION_SUPPLY), \ -+ S(SRC_READY), \ -+ S(SRC_WAIT_NEW_CAPABILITIES), \ -+ \ -+ S(SNK_UNATTACHED), \ -+ S(SNK_ATTACH_WAIT), \ -+ S(SNK_DEBOUNCED), \ -+ S(SNK_ATTACHED), \ -+ S(SNK_STARTUP), \ -+ S(SNK_DISCOVERY), \ -+ S(SNK_DISCOVERY_DEBOUNCE), \ -+ S(SNK_DISCOVERY_DEBOUNCE_DONE), \ -+ S(SNK_WAIT_CAPABILITIES), \ -+ S(SNK_NEGOTIATE_CAPABILITIES), \ -+ S(SNK_TRANSITION_SINK), \ -+ S(SNK_TRANSITION_SINK_VBUS), \ -+ S(SNK_READY), \ -+ \ -+ S(HARD_RESET_SEND), \ -+ S(HARD_RESET_START), \ -+ S(SRC_HARD_RESET_VBUS_OFF), \ -+ S(SRC_HARD_RESET_VBUS_ON), \ -+ S(SNK_HARD_RESET_SINK_OFF), \ -+ S(SNK_HARD_RESET_WAIT_VBUS), \ -+ S(SNK_HARD_RESET_SINK_ON), \ -+ \ -+ S(SOFT_RESET), \ -+ S(SOFT_RESET_SEND), \ -+ \ -+ S(DR_SWAP_ACCEPT), \ -+ S(DR_SWAP_CHANGE_DR), \ -+ \ -+ S(ERROR_RECOVERY), \ -+ S(PORT_RESET), \ -+ S(PORT_RESET_WAIT_OFF) -+ -+#define GENERATE_TCPM_ENUM(e) e -+#define GENERATE_TCPM_STRING(s) #s -+#define TCPM_POLL_EVENT_TIME_OUT 2000 -+ -+enum tcpm_state { -+ FOREACH_TCPM_STATE(GENERATE_TCPM_ENUM) -+}; -+ -+enum pd_msg_request { -+ PD_MSG_NONE = 0, -+ PD_MSG_CTRL_REJECT, -+ PD_MSG_CTRL_WAIT, -+ PD_MSG_CTRL_NOT_SUPP, -+ PD_MSG_DATA_SINK_CAP, -+ PD_MSG_DATA_SOURCE_CAP, -+}; -+ -+struct tcpm_port { -+ enum typec_port_type typec_type; -+ int typec_prefer_role; -+ -+ enum typec_role vconn_role; -+ enum typec_role pwr_role; -+ enum typec_data_role data_role; -+ -+ struct typec_partner *partner; -+ -+ enum typec_cc_status cc_req; -+ enum typec_cc_status cc1; -+ enum typec_cc_status cc2; -+ enum typec_cc_polarity polarity; -+ -+ bool attached; -+ bool connected; -+ int poll_event_cnt; -+ enum typec_port_type port_type; -+ -+ /* -+ * Set to true when vbus is greater than VSAFE5V min. -+ * Set to false when vbus falls below vSinkDisconnect max threshold. -+ */ -+ bool vbus_present; -+ -+ /* -+ * Set to true when vbus is less than VSAFE0V max. -+ * Set to false when vbus is greater than VSAFE0V max. -+ */ -+ bool vbus_vsafe0v; -+ -+ bool vbus_never_low; -+ bool vbus_source; -+ bool vbus_charge; -+ -+ int try_role; -+ -+ enum pd_msg_request queued_message; -+ -+ enum tcpm_state enter_state; -+ enum tcpm_state prev_state; -+ enum tcpm_state state; -+ enum tcpm_state delayed_state; -+ unsigned long delay_ms; -+ -+ bool state_machine_running; -+ -+ bool tx_complete; -+ enum tcpm_transmit_status tx_status; -+ -+ unsigned int negotiated_rev; -+ unsigned int message_id; -+ unsigned int caps_count; -+ unsigned int hard_reset_count; -+ bool pd_capable; -+ bool explicit_contract; -+ unsigned int rx_msgid; -+ -+ /* Partner capabilities/requests */ -+ u32 sink_request; -+ u32 source_caps[PDO_MAX_OBJECTS]; -+ unsigned int nr_source_caps; -+ u32 sink_caps[PDO_MAX_OBJECTS]; -+ unsigned int nr_sink_caps; -+ -+ /* -+ * whether to wait for the Type-C device to send the DR_SWAP Message flag -+ * For Type-C device with Dual-Role Power and Dual-Role Data, the port side -+ * is used as sink + ufp, then the tcpm framework needs to wait for Type-C -+ * device to initiate DR_swap Message. -+ */ -+ bool wait_dr_swap_message; -+ -+ /* Local capabilities */ -+ u32 src_pdo[PDO_MAX_OBJECTS]; -+ unsigned int nr_src_pdo; -+ u32 snk_pdo[PDO_MAX_OBJECTS]; -+ unsigned int nr_snk_pdo; -+ -+ unsigned int operating_snk_mw; -+ bool update_sink_caps; -+ -+ /* Requested current / voltage to the port partner */ -+ u32 req_current_limit; -+ u32 req_supply_voltage; -+ /* Actual current / voltage limit of the local port */ -+ u32 current_limit; -+ u32 supply_voltage; -+ -+ /* port belongs to a self powered device */ -+ bool self_powered; -+ -+ unsigned long delay_target; -+}; -+ -+extern const char * const tcpm_states[]; -+ -+int tcpm_post_probe(struct udevice *dev); -+ -+#endif -diff --git a/drivers/usb/tcpm/tcpm-uclass.c b/drivers/usb/tcpm/tcpm-uclass.c -new file mode 100644 -index 000000000000..92f9eff1ada6 ---- /dev/null -+++ b/drivers/usb/tcpm/tcpm-uclass.c -@@ -0,0 +1,149 @@ -+// SPDX-License-Identifier: GPL-2.0+ -+/* -+ * Copyright 2024 Collabora Ltd. -+ * -+ * USB Power Delivery protocol stack. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include "tcpm-internal.h" -+ -+int tcpm_get_voltage(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ return port->supply_voltage; -+} -+ -+int tcpm_get_current(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ return port->current_limit; -+} -+ -+enum typec_orientation tcpm_get_orientation(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ switch (port->polarity) { -+ case TYPEC_POLARITY_CC1: -+ return TYPEC_ORIENTATION_NORMAL; -+ case TYPEC_POLARITY_CC2: -+ return TYPEC_ORIENTATION_REVERSE; -+ default: -+ return TYPEC_ORIENTATION_NONE; -+ } -+} -+ -+const char *tcpm_get_state(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ return tcpm_states[port->state]; -+} -+ -+int tcpm_get_pd_rev(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ return port->negotiated_rev; -+} -+ -+enum typec_role tcpm_get_pwr_role(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ return port->pwr_role; -+} -+ -+enum typec_data_role tcpm_get_data_role(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ return port->data_role; -+} -+ -+bool tcpm_is_connected(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ return port->connected; -+} -+ -+int tcpm_get(const char *name, struct udevice **devp) -+{ -+ return uclass_get_device_by_name(UCLASS_TCPM, name, devp); -+} -+ -+static int tcpm_post_bind(struct udevice *dev) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ const char *cap_str; -+ ofnode node; -+ int ret; -+ -+ /* -+ * USB Power Delivery (USB PD) specification requires, that communication -+ * with a sink happens within roughly 5 seconds. Otherwise the source -+ * might assume that the sink does not support USB PD. Starting to do -+ * USB PD communication after that results in a hard reset, which briefly -+ * removes any power from the USB-C port. -+ * -+ * On systems with alternative power supplies this is not an issue, but -+ * systems, which get soleley powered through their USB-C port will end -+ * up losing their power supply and doing a board level reset. The hard -+ * reset will also restart the 5 second timeout. That means a operating -+ * system initializing USB PD will put the system into a boot loop when -+ * it takes more than 5 seconds from cold boot to the operating system -+ * starting to transmit USB PD messages. -+ * -+ * The issue can be avoided by doing the initial USB PD communication -+ * in U-Boot. The operating system can then re-negotiate by doing a -+ * soft reset, which does not trigger removal of the supply voltage. -+ * -+ * Since the TCPM state machine is quite complex and depending on the -+ * remote side can take quite some time to finish, this tries to limit -+ * the automatic probing to systems probably relying on power being -+ * provided by the USB-C port(s): -+ * -+ * 1. self-powered devices won't reset when the USB-C port looses power -+ * 2. if the power is allowed to go into anything else than sink mode -+ * it is not the only power source -+ */ -+ ret = drvops->get_connector_node(dev, &node); -+ if (ret) -+ return ret; -+ -+ if (ofnode_read_bool(node, "self-powered")) -+ return 0; -+ -+ cap_str = ofnode_read_string(node, "power-role"); -+ if (!cap_str) -+ return -EINVAL; -+ -+ if (strcmp("sink", cap_str)) -+ return 0; -+ -+ /* Do not auto-probe PD controller when PD is disabled */ -+ if (ofnode_read_bool(node, "pd-disable")) -+ return 0; -+ -+ dev_info(dev, "probing Type-C port manager..."); -+ -+ dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND); -+ -+ return 0; -+} -+ -+UCLASS_DRIVER(tcpm) = { -+ .id = UCLASS_TCPM, -+ .name = "tcpm", -+ .per_device_plat_auto = sizeof(struct tcpm_port), -+ .post_bind = tcpm_post_bind, -+ .post_probe = tcpm_post_probe, -+}; -diff --git a/drivers/usb/tcpm/tcpm.c b/drivers/usb/tcpm/tcpm.c -new file mode 100644 -index 000000000000..0aee57cb2f4a ---- /dev/null -+++ b/drivers/usb/tcpm/tcpm.c -@@ -0,0 +1,2288 @@ -+// SPDX-License-Identifier: GPL-2.0+ -+/* -+ * Copyright 2015-2017 Google, Inc -+ * -+ * USB Power Delivery protocol stack. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include "tcpm-internal.h" -+ -+DECLARE_GLOBAL_DATA_PTR; -+ -+const char * const tcpm_states[] = { -+ FOREACH_TCPM_STATE(GENERATE_TCPM_STRING) -+}; -+ -+const char * const typec_pd_rev_name[] = { -+ [PD_REV10] = "rev1", -+ [PD_REV20] = "rev2", -+ [PD_REV30] = "rev3", -+}; -+ -+const char * const typec_role_name[] = { -+ [TYPEC_SINK] = "sink", -+ [TYPEC_SOURCE] = "source", -+}; -+ -+const char * const typec_data_role_name[] = { -+ [TYPEC_DEVICE] = "device", -+ [TYPEC_HOST] = "host", -+}; -+ -+const char * const typec_orientation_name[] = { -+ [TYPEC_ORIENTATION_NONE] = "none", -+ [TYPEC_ORIENTATION_NORMAL] = "normal", -+ [TYPEC_ORIENTATION_REVERSE] = "reverse", -+}; -+ -+const char * const typec_cc_status_name[] = { -+ [TYPEC_CC_OPEN] = "open", -+ [TYPEC_CC_RA] = "ra", -+ [TYPEC_CC_RD] = "rd", -+ [TYPEC_CC_RP_DEF] = "rp-def", -+ [TYPEC_CC_RP_1_5] = "rp-1.5", -+ [TYPEC_CC_RP_3_0] = "rp-3.0", -+}; -+ -+static inline bool tcpm_cc_is_sink(enum typec_cc_status cc) -+{ -+ return cc == TYPEC_CC_RP_DEF || -+ cc == TYPEC_CC_RP_1_5 || -+ cc == TYPEC_CC_RP_3_0; -+} -+ -+static inline bool tcpm_port_is_sink(struct tcpm_port *port) -+{ -+ bool cc1_is_snk = tcpm_cc_is_sink(port->cc1); -+ bool cc2_is_snk = tcpm_cc_is_sink(port->cc2); -+ -+ return (cc1_is_snk && !cc2_is_snk) || -+ (cc2_is_snk && !cc1_is_snk); -+} -+ -+static inline bool tcpm_cc_is_source(enum typec_cc_status cc) -+{ -+ return cc == TYPEC_CC_RD; -+} -+ -+static inline bool tcpm_port_is_source(struct tcpm_port *port) -+{ -+ bool cc1_is_src = tcpm_cc_is_source(port->cc1); -+ bool cc2_is_src = tcpm_cc_is_source(port->cc2); -+ -+ return (cc1_is_src && !cc2_is_src) || -+ (cc2_is_src && !cc1_is_src); -+} -+ -+static inline bool tcpm_try_src(struct tcpm_port *port) -+{ -+ return port->try_role == TYPEC_SOURCE && -+ port->port_type == TYPEC_PORT_DRP; -+} -+ -+static inline void tcpm_reset_event_cnt(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ port->poll_event_cnt = 0; -+} -+ -+static enum tcpm_state tcpm_default_state(struct tcpm_port *port) -+{ -+ if (port->port_type == TYPEC_PORT_DRP) { -+ if (port->try_role == TYPEC_SINK) -+ return SNK_UNATTACHED; -+ else if (port->try_role == TYPEC_SOURCE) -+ return SRC_UNATTACHED; -+ } else if (port->port_type == TYPEC_PORT_SNK) { -+ return SNK_UNATTACHED; -+ } -+ return SRC_UNATTACHED; -+} -+ -+static bool tcpm_port_is_disconnected(struct tcpm_port *port) -+{ -+ return (!port->attached && port->cc1 == TYPEC_CC_OPEN && -+ port->cc2 == TYPEC_CC_OPEN) || -+ (port->attached && ((port->polarity == TYPEC_POLARITY_CC1 && -+ port->cc1 == TYPEC_CC_OPEN) || -+ (port->polarity == TYPEC_POLARITY_CC2 && -+ port->cc2 == TYPEC_CC_OPEN))); -+} -+ -+static void tcpm_set_cc(struct udevice *dev, enum typec_cc_status cc) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ dev_dbg(dev, "TCPM: set cc = %d\n", cc); -+ port->cc_req = cc; -+ drvops->set_cc(dev, cc); -+} -+ -+/* -+ * Determine RP value to set based on maximum current supported -+ * by a port if configured as source. -+ * Returns CC value to report to link partner. -+ */ -+static enum typec_cc_status tcpm_rp_cc(struct tcpm_port *port) -+{ -+ const u32 *src_pdo = port->src_pdo; -+ int nr_pdo = port->nr_src_pdo; -+ int i; -+ -+ /* -+ * Search for first entry with matching voltage. -+ * It should report the maximum supported current. -+ */ -+ for (i = 0; i < nr_pdo; i++) { -+ const u32 pdo = src_pdo[i]; -+ -+ if (pdo_type(pdo) == PDO_TYPE_FIXED && -+ pdo_fixed_voltage(pdo) == 5000) { -+ unsigned int curr = pdo_max_current(pdo); -+ -+ if (curr >= 3000) -+ return TYPEC_CC_RP_3_0; -+ else if (curr >= 1500) -+ return TYPEC_CC_RP_1_5; -+ return TYPEC_CC_RP_DEF; -+ } -+ } -+ -+ return TYPEC_CC_RP_DEF; -+} -+ -+static void tcpm_check_and_run_delayed_work(struct udevice *dev); -+ -+static bool tcpm_transmit_helper(struct udevice *dev) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ drvops->poll_event(dev); -+ udelay(500); -+ tcpm_check_and_run_delayed_work(dev); -+ return port->tx_complete; -+} -+ -+static int tcpm_pd_transmit(struct udevice *dev, -+ enum tcpm_transmit_type type, -+ const struct pd_message *msg) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ u32 timeout_us = PD_T_TCPC_TX_TIMEOUT * 1000; -+ bool tx_complete; -+ int ret; -+ -+ if (msg) -+ dev_dbg(dev, "TCPM: PD TX, header: %#x\n", -+ le16_to_cpu(msg->header)); -+ else -+ dev_dbg(dev, "TCPM: PD TX, type: %#x\n", type); -+ -+ port->tx_complete = false; -+ ret = drvops->pd_transmit(dev, type, msg, port->negotiated_rev); -+ if (ret < 0) -+ return ret; -+ -+ /* -+ * At this point we basically need to block until the TCPM controller -+ * returns successful transmission. Since this is usually done using -+ * the generic interrupt status bits, we poll for any events. That -+ * will clear the interrupt status, so we also need to process any -+ * of the incoming events. This means we will do more processing and -+ * thus let's give everything a bit more time. -+ */ -+ timeout_us *= 5; -+ ret = read_poll_timeout(tcpm_transmit_helper, tx_complete, -+ !tx_complete, false, timeout_us, dev); -+ if (ret < 0) { -+ dev_err(dev, "TCPM: PD transmit data failed: %d\n", ret); -+ return ret; -+ } -+ -+ switch (port->tx_status) { -+ case TCPC_TX_SUCCESS: -+ port->message_id = (port->message_id + 1) & PD_HEADER_ID_MASK; -+ break; -+ case TCPC_TX_DISCARDED: -+ ret = -EAGAIN; -+ break; -+ case TCPC_TX_FAILED: -+ default: -+ ret = -EIO; -+ break; -+ } -+ -+ return ret; -+} -+ -+void tcpm_pd_transmit_complete(struct udevice *dev, -+ enum tcpm_transmit_status status) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ dev_dbg(dev, "TCPM: PD TX complete, status: %u\n", status); -+ tcpm_reset_event_cnt(dev); -+ port->tx_status = status; -+ port->tx_complete = true; -+} -+ -+static int tcpm_set_polarity(struct udevice *dev, -+ enum typec_cc_polarity polarity) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ int ret; -+ -+ dev_dbg(dev, "TCPM: set polarity = %d\n", polarity); -+ -+ if (drvops->set_polarity) { -+ ret = drvops->set_polarity(dev, polarity); -+ if (ret < 0) -+ return ret; -+ } -+ -+ port->polarity = polarity; -+ -+ return 0; -+} -+ -+static int tcpm_set_vconn(struct udevice *dev, bool enable) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ int ret; -+ -+ dev_dbg(dev, "TCPM: set vconn = %d\n", enable); -+ -+ ret = drvops->set_vconn(dev, enable); -+ if (!ret) -+ port->vconn_role = enable ? TYPEC_SOURCE : TYPEC_SINK; -+ -+ return ret; -+} -+ -+static inline u32 tcpm_get_current_limit(struct tcpm_port *port) -+{ -+ switch (port->polarity ? port->cc2 : port->cc1) { -+ case TYPEC_CC_RP_1_5: -+ return 1500; -+ case TYPEC_CC_RP_3_0: -+ return 3000; -+ case TYPEC_CC_RP_DEF: -+ default: -+ return 0; -+ } -+} -+ -+static int tcpm_set_current_limit(struct udevice *dev, u32 max_ma, u32 mv) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ int ret = -EOPNOTSUPP; -+ -+ dev_info(dev, "TCPM: set voltage limit = %u mV\n", mv); -+ dev_info(dev, "TCPM: set current limit = %u mA\n", max_ma); -+ -+ port->supply_voltage = mv; -+ port->current_limit = max_ma; -+ -+ return ret; -+} -+ -+static int tcpm_set_attached_state(struct udevice *dev, bool attached) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ return drvops->set_roles(dev, attached, port->pwr_role, -+ port->data_role); -+} -+ -+static int tcpm_set_roles(struct udevice *dev, bool attached, -+ enum typec_role role, enum typec_data_role data) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ int ret; -+ -+ ret = drvops->set_roles(dev, attached, role, data); -+ if (ret < 0) -+ return ret; -+ -+ port->pwr_role = role; -+ port->data_role = data; -+ -+ return 0; -+} -+ -+static int tcpm_pd_send_source_caps(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ struct pd_message msg; -+ int i; -+ -+ memset(&msg, 0, sizeof(msg)); -+ -+ if (!port->nr_src_pdo) { -+ /* No source capabilities defined, sink only */ -+ msg.header = PD_HEADER_LE(PD_CTRL_REJECT, -+ port->pwr_role, -+ port->data_role, -+ port->negotiated_rev, -+ port->message_id, 0); -+ } else { -+ msg.header = PD_HEADER_LE(PD_DATA_SOURCE_CAP, -+ port->pwr_role, -+ port->data_role, -+ port->negotiated_rev, -+ port->message_id, -+ port->nr_src_pdo); -+ } -+ -+ for (i = 0; i < port->nr_src_pdo; i++) -+ msg.payload[i] = cpu_to_le32(port->src_pdo[i]); -+ -+ return tcpm_pd_transmit(dev, TCPC_TX_SOP, &msg); -+} -+ -+static int tcpm_pd_send_sink_caps(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ struct pd_message msg; -+ unsigned int i; -+ -+ memset(&msg, 0, sizeof(msg)); -+ -+ if (!port->nr_snk_pdo) { -+ /* No sink capabilities defined, source only */ -+ msg.header = PD_HEADER_LE(PD_CTRL_REJECT, -+ port->pwr_role, -+ port->data_role, -+ port->negotiated_rev, -+ port->message_id, 0); -+ } else { -+ msg.header = PD_HEADER_LE(PD_DATA_SINK_CAP, -+ port->pwr_role, -+ port->data_role, -+ port->negotiated_rev, -+ port->message_id, -+ port->nr_snk_pdo); -+ } -+ -+ for (i = 0; i < port->nr_snk_pdo; i++) -+ msg.payload[i] = cpu_to_le32(port->snk_pdo[i]); -+ -+ return tcpm_pd_transmit(dev, TCPC_TX_SOP, &msg); -+} -+ -+static void tcpm_state_machine(struct udevice *dev); -+ -+static inline void tcpm_timer_uninit(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ port->delay_target = 0; -+} -+ -+static void tcpm_timer_init(struct udevice *dev, uint32_t ms) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ unsigned long time_us = ms * 1000; -+ -+ port->delay_target = timer_get_us() + time_us; -+} -+ -+static void tcpm_check_and_run_delayed_work(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ /* no delayed state changes scheduled */ -+ if (port->delay_target == 0) -+ return; -+ -+ /* it's not yet time */ -+ if (timer_get_us() < port->delay_target) -+ return; -+ -+ tcpm_timer_uninit(dev); -+ tcpm_state_machine(dev); -+} -+ -+static void mod_tcpm_delayed_work(struct udevice *dev, unsigned int delay_ms) -+{ -+ if (delay_ms) { -+ tcpm_timer_init(dev, delay_ms); -+ } else { -+ tcpm_timer_uninit(dev); -+ tcpm_state_machine(dev); -+ } -+} -+ -+static void tcpm_set_state(struct udevice *dev, enum tcpm_state state, -+ unsigned int delay_ms) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ if (delay_ms) { -+ dev_dbg(dev, "TCPM: pending state change %s -> %s @ %u ms [%s]\n", -+ tcpm_states[port->state], tcpm_states[state], delay_ms, -+ typec_pd_rev_name[port->negotiated_rev]); -+ port->delayed_state = state; -+ mod_tcpm_delayed_work(dev, delay_ms); -+ port->delay_ms = delay_ms; -+ } else { -+ dev_dbg(dev, "TCPM: state change %s -> %s\n", -+ tcpm_states[port->state], tcpm_states[state]); -+ port->delayed_state = INVALID_STATE; -+ port->prev_state = port->state; -+ port->state = state; -+ /* -+ * Don't re-queue the state machine work item if we're currently -+ * in the state machine and we're immediately changing states. -+ * tcpm_state_machine_work() will continue running the state -+ * machine. -+ */ -+ if (!port->state_machine_running) -+ mod_tcpm_delayed_work(dev, 0); -+ } -+} -+ -+static void tcpm_set_state_cond(struct udevice *dev, enum tcpm_state state, -+ unsigned int delay_ms) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ if (port->enter_state == port->state) -+ tcpm_set_state(dev, state, delay_ms); -+ else -+ dev_dbg(dev, "TCPM: skipped %sstate change %s -> %s [%u ms], context state %s [%s]\n", -+ delay_ms ? "delayed " : "", -+ tcpm_states[port->state], tcpm_states[state], -+ delay_ms, tcpm_states[port->enter_state], -+ typec_pd_rev_name[port->negotiated_rev]); -+} -+ -+static void tcpm_queue_message(struct udevice *dev, -+ enum pd_msg_request message) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ port->queued_message = message; -+ mod_tcpm_delayed_work(dev, 0); -+} -+ -+enum pdo_err { -+ PDO_NO_ERR, -+ PDO_ERR_NO_VSAFE5V, -+ PDO_ERR_VSAFE5V_NOT_FIRST, -+ PDO_ERR_PDO_TYPE_NOT_IN_ORDER, -+ PDO_ERR_FIXED_NOT_SORTED, -+ PDO_ERR_VARIABLE_BATT_NOT_SORTED, -+ PDO_ERR_DUPE_PDO, -+ PDO_ERR_PPS_APDO_NOT_SORTED, -+ PDO_ERR_DUPE_PPS_APDO, -+}; -+ -+static const char * const pdo_err_msg[] = { -+ [PDO_ERR_NO_VSAFE5V] = -+ " err: source/sink caps should at least have vSafe5V", -+ [PDO_ERR_VSAFE5V_NOT_FIRST] = -+ " err: vSafe5V Fixed Supply Object Shall always be the first object", -+ [PDO_ERR_PDO_TYPE_NOT_IN_ORDER] = -+ " err: PDOs should be in the following order: Fixed; Battery; Variable", -+ [PDO_ERR_FIXED_NOT_SORTED] = -+ " err: Fixed supply pdos should be in increasing order of their fixed voltage", -+ [PDO_ERR_VARIABLE_BATT_NOT_SORTED] = -+ " err: Variable/Battery supply pdos should be in increasing order of their minimum voltage", -+ [PDO_ERR_DUPE_PDO] = -+ " err: Variable/Batt supply pdos cannot have same min/max voltage", -+ [PDO_ERR_PPS_APDO_NOT_SORTED] = -+ " err: Programmable power supply apdos should be in increasing order of their maximum voltage", -+ [PDO_ERR_DUPE_PPS_APDO] = -+ " err: Programmable power supply apdos cannot have same min/max voltage and max current", -+}; -+ -+static enum pdo_err tcpm_caps_err(struct udevice *dev, const u32 *pdo, -+ unsigned int nr_pdo) -+{ -+ unsigned int i; -+ -+ /* Should at least contain vSafe5v */ -+ if (nr_pdo < 1) -+ return PDO_ERR_NO_VSAFE5V; -+ -+ /* The vSafe5V Fixed Supply Object Shall always be the first object */ -+ if (pdo_type(pdo[0]) != PDO_TYPE_FIXED || -+ pdo_fixed_voltage(pdo[0]) != VSAFE5V) -+ return PDO_ERR_VSAFE5V_NOT_FIRST; -+ -+ for (i = 1; i < nr_pdo; i++) { -+ if (pdo_type(pdo[i]) < pdo_type(pdo[i - 1])) { -+ return PDO_ERR_PDO_TYPE_NOT_IN_ORDER; -+ } else if (pdo_type(pdo[i]) == pdo_type(pdo[i - 1])) { -+ enum pd_pdo_type type = pdo_type(pdo[i]); -+ -+ switch (type) { -+ /* -+ * The remaining Fixed Supply Objects, if -+ * present, shall be sent in voltage order; -+ * lowest to highest. -+ */ -+ case PDO_TYPE_FIXED: -+ if (pdo_fixed_voltage(pdo[i]) <= -+ pdo_fixed_voltage(pdo[i - 1])) -+ return PDO_ERR_FIXED_NOT_SORTED; -+ break; -+ /* -+ * The Battery Supply Objects and Variable -+ * supply, if present shall be sent in Minimum -+ * Voltage order; lowest to highest. -+ */ -+ case PDO_TYPE_VAR: -+ case PDO_TYPE_BATT: -+ if (pdo_min_voltage(pdo[i]) < -+ pdo_min_voltage(pdo[i - 1])) -+ return PDO_ERR_VARIABLE_BATT_NOT_SORTED; -+ else if ((pdo_min_voltage(pdo[i]) == -+ pdo_min_voltage(pdo[i - 1])) && -+ (pdo_max_voltage(pdo[i]) == -+ pdo_max_voltage(pdo[i - 1]))) -+ return PDO_ERR_DUPE_PDO; -+ break; -+ /* -+ * The Programmable Power Supply APDOs, if present, -+ * shall be sent in Maximum Voltage order; -+ * lowest to highest. -+ */ -+ case PDO_TYPE_APDO: -+ if (pdo_apdo_type(pdo[i]) != APDO_TYPE_PPS) -+ break; -+ -+ if (pdo_pps_apdo_max_voltage(pdo[i]) < -+ pdo_pps_apdo_max_voltage(pdo[i - 1])) -+ return PDO_ERR_PPS_APDO_NOT_SORTED; -+ else if (pdo_pps_apdo_min_voltage(pdo[i]) == -+ pdo_pps_apdo_min_voltage(pdo[i - 1]) && -+ pdo_pps_apdo_max_voltage(pdo[i]) == -+ pdo_pps_apdo_max_voltage(pdo[i - 1]) && -+ pdo_pps_apdo_max_current(pdo[i]) == -+ pdo_pps_apdo_max_current(pdo[i - 1])) -+ return PDO_ERR_DUPE_PPS_APDO; -+ break; -+ default: -+ dev_err(dev, "TCPM: Unknown pdo type\n"); -+ } -+ } -+ } -+ -+ return PDO_NO_ERR; -+} -+ -+static int tcpm_validate_caps(struct udevice *dev, const u32 *pdo, -+ unsigned int nr_pdo) -+{ -+ enum pdo_err err_index = tcpm_caps_err(dev, pdo, nr_pdo); -+ -+ if (err_index != PDO_NO_ERR) { -+ dev_err(dev, "TCPM:%s\n", pdo_err_msg[err_index]); -+ return -EINVAL; -+ } -+ -+ return 0; -+} -+ -+/* -+ * PD (data, control) command handling functions -+ */ -+static inline enum tcpm_state ready_state(struct tcpm_port *port) -+{ -+ if (port->pwr_role == TYPEC_SOURCE) -+ return SRC_READY; -+ else -+ return SNK_READY; -+} -+ -+static void tcpm_pd_data_request(struct udevice *dev, -+ const struct pd_message *msg) -+{ -+ enum pd_data_msg_type type = pd_header_type_le(msg->header); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ unsigned int cnt = pd_header_cnt_le(msg->header); -+ unsigned int rev = pd_header_rev_le(msg->header); -+ unsigned int i; -+ -+ switch (type) { -+ case PD_DATA_SOURCE_CAP: -+ for (i = 0; i < cnt; i++) -+ port->source_caps[i] = le32_to_cpu(msg->payload[i]); -+ -+ port->nr_source_caps = cnt; -+ -+ tcpm_validate_caps(dev, port->source_caps, -+ port->nr_source_caps); -+ -+ /* -+ * Adjust revision in subsequent message headers, as required, -+ * to comply with 6.2.1.1.5 of the USB PD 3.0 spec. We don't -+ * support Rev 1.0 so just do nothing in that scenario. -+ */ -+ if (rev == PD_REV10) -+ break; -+ -+ if (rev < PD_MAX_REV) -+ port->negotiated_rev = rev; -+ -+ if ((pdo_type(port->source_caps[0]) == PDO_TYPE_FIXED) && -+ (port->source_caps[0] & PDO_FIXED_DUAL_ROLE) && -+ (port->source_caps[0] & PDO_FIXED_DATA_SWAP)) { -+ /* Dual role power and data, eg: self-powered Type-C */ -+ port->wait_dr_swap_message = true; -+ } else { -+ /* Non-Dual role power, eg: adapter */ -+ port->wait_dr_swap_message = false; -+ } -+ -+ /* -+ * This message may be received even if VBUS is not -+ * present. This is quite unexpected; see USB PD -+ * specification, sections 8.3.3.6.3.1 and 8.3.3.6.3.2. -+ * However, at the same time, we must be ready to -+ * receive this message and respond to it 15ms after -+ * receiving PS_RDY during power swap operations, no matter -+ * if VBUS is available or not (USB PD specification, -+ * section 6.5.9.2). -+ * So we need to accept the message either way, -+ * but be prepared to keep waiting for VBUS after it was -+ * handled. -+ */ -+ tcpm_set_state(dev, SNK_NEGOTIATE_CAPABILITIES, 0); -+ break; -+ case PD_DATA_REQUEST: -+ /* -+ * Adjust revision in subsequent message headers, as required, -+ * to comply with 6.2.1.1.5 of the USB PD 3.0 spec. We don't -+ * support Rev 1.0 so just reject in that scenario. -+ */ -+ if (rev == PD_REV10) { -+ tcpm_queue_message(dev, PD_MSG_CTRL_REJECT); -+ break; -+ } -+ -+ if (rev < PD_MAX_REV) -+ port->negotiated_rev = rev; -+ -+ port->sink_request = le32_to_cpu(msg->payload[0]); -+ -+ tcpm_set_state(dev, SRC_NEGOTIATE_CAPABILITIES, 0); -+ break; -+ case PD_DATA_SINK_CAP: -+ /* We don't do anything with this at the moment... */ -+ for (i = 0; i < cnt; i++) -+ port->sink_caps[i] = le32_to_cpu(msg->payload[i]); -+ -+ port->nr_sink_caps = cnt; -+ break; -+ default: -+ break; -+ } -+} -+ -+static void tcpm_pd_ctrl_request(struct udevice *dev, -+ const struct pd_message *msg) -+{ -+ enum pd_ctrl_msg_type type = pd_header_type_le(msg->header); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ enum tcpm_state next_state; -+ -+ switch (type) { -+ case PD_CTRL_GOOD_CRC: -+ case PD_CTRL_PING: -+ break; -+ case PD_CTRL_GET_SOURCE_CAP: -+ switch (port->state) { -+ case SRC_READY: -+ case SNK_READY: -+ tcpm_queue_message(dev, PD_MSG_DATA_SOURCE_CAP); -+ break; -+ default: -+ tcpm_queue_message(dev, PD_MSG_CTRL_REJECT); -+ break; -+ } -+ break; -+ case PD_CTRL_GET_SINK_CAP: -+ switch (port->state) { -+ case SRC_READY: -+ case SNK_READY: -+ tcpm_queue_message(dev, PD_MSG_DATA_SINK_CAP); -+ break; -+ default: -+ tcpm_queue_message(dev, PD_MSG_CTRL_REJECT); -+ break; -+ } -+ break; -+ case PD_CTRL_GOTO_MIN: -+ break; -+ case PD_CTRL_PS_RDY: -+ switch (port->state) { -+ case SNK_TRANSITION_SINK: -+ if (port->vbus_present) { -+ tcpm_set_current_limit(dev, -+ port->req_current_limit, -+ port->req_supply_voltage); -+ port->explicit_contract = true; -+ tcpm_set_state(dev, SNK_READY, 0); -+ } else { -+ /* -+ * Seen after power swap. Keep waiting for VBUS -+ * in a transitional state. -+ */ -+ tcpm_set_state(dev, -+ SNK_TRANSITION_SINK_VBUS, 0); -+ } -+ break; -+ default: -+ break; -+ } -+ break; -+ case PD_CTRL_REJECT: -+ case PD_CTRL_WAIT: -+ case PD_CTRL_NOT_SUPP: -+ switch (port->state) { -+ case SNK_NEGOTIATE_CAPABILITIES: -+ /* USB PD specification, Figure 8-43 */ -+ if (port->explicit_contract) -+ next_state = SNK_READY; -+ else -+ next_state = SNK_WAIT_CAPABILITIES; -+ -+ tcpm_set_state(dev, next_state, 0); -+ break; -+ default: -+ break; -+ } -+ break; -+ case PD_CTRL_ACCEPT: -+ switch (port->state) { -+ case SNK_NEGOTIATE_CAPABILITIES: -+ tcpm_set_state(dev, SNK_TRANSITION_SINK, 0); -+ break; -+ case SOFT_RESET_SEND: -+ port->message_id = 0; -+ port->rx_msgid = -1; -+ if (port->pwr_role == TYPEC_SOURCE) -+ next_state = SRC_SEND_CAPABILITIES; -+ else -+ next_state = SNK_WAIT_CAPABILITIES; -+ tcpm_set_state(dev, next_state, 0); -+ break; -+ default: -+ break; -+ } -+ break; -+ case PD_CTRL_SOFT_RESET: -+ tcpm_set_state(dev, SOFT_RESET, 0); -+ break; -+ case PD_CTRL_DR_SWAP: -+ if (port->port_type != TYPEC_PORT_DRP) { -+ tcpm_queue_message(dev, PD_MSG_CTRL_REJECT); -+ break; -+ } -+ /* -+ * 6.3.9: If an alternate mode is active, a request to swap -+ * alternate modes shall trigger a port reset. -+ */ -+ switch (port->state) { -+ case SRC_READY: -+ case SNK_READY: -+ tcpm_set_state(dev, DR_SWAP_ACCEPT, 0); -+ break; -+ default: -+ tcpm_queue_message(dev, PD_MSG_CTRL_WAIT); -+ break; -+ } -+ break; -+ case PD_CTRL_PR_SWAP: -+ case PD_CTRL_VCONN_SWAP: -+ case PD_CTRL_GET_SOURCE_CAP_EXT: -+ case PD_CTRL_GET_STATUS: -+ case PD_CTRL_FR_SWAP: -+ case PD_CTRL_GET_PPS_STATUS: -+ case PD_CTRL_GET_COUNTRY_CODES: -+ /* Currently not supported */ -+ dev_err(dev, "TCPM: Currently not supported type %#x\n", type); -+ tcpm_queue_message(dev, PD_MSG_CTRL_NOT_SUPP); -+ break; -+ default: -+ dev_err(dev, "TCPM: Unrecognized ctrl message type %#x\n", type); -+ break; -+ } -+} -+ -+static void tcpm_pd_rx_handler(struct udevice *dev, -+ const struct pd_message *msg) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ unsigned int cnt = pd_header_cnt_le(msg->header); -+ bool remote_is_host, local_is_host; -+ -+ dev_dbg(dev, "TCPM: PD RX, header: %#x [%d]\n", -+ le16_to_cpu(msg->header), port->attached); -+ -+ if (port->attached) { -+ enum pd_ctrl_msg_type type = pd_header_type_le(msg->header); -+ unsigned int msgid = pd_header_msgid_le(msg->header); -+ -+ /* -+ * USB PD standard, 6.6.1.2: -+ * "... if MessageID value in a received Message is the -+ * same as the stored value, the receiver shall return a -+ * GoodCRC Message with that MessageID value and drop -+ * the Message (this is a retry of an already received -+ * Message). Note: this shall not apply to the Soft_Reset -+ * Message which always has a MessageID value of zero." -+ */ -+ if (msgid == port->rx_msgid && type != PD_CTRL_SOFT_RESET) -+ return; -+ port->rx_msgid = msgid; -+ -+ /* -+ * If both ends believe to be DFP/host, we have a data role -+ * mismatch. -+ */ -+ remote_is_host = !!(le16_to_cpu(msg->header) & PD_HEADER_DATA_ROLE); -+ local_is_host = port->data_role == TYPEC_HOST; -+ if (remote_is_host == local_is_host) { -+ dev_err(dev, "TCPM: data role mismatch, initiating error recovery\n"); -+ tcpm_set_state(dev, ERROR_RECOVERY, 0); -+ } else { -+ if (cnt) -+ tcpm_pd_data_request(dev, msg); -+ else -+ tcpm_pd_ctrl_request(dev, msg); -+ } -+ } -+} -+ -+void tcpm_pd_receive(struct udevice *dev, const struct pd_message *msg) -+{ -+ tcpm_reset_event_cnt(dev); -+ tcpm_pd_rx_handler(dev, msg); -+} -+ -+static int tcpm_pd_send_control(struct udevice *dev, -+ enum pd_ctrl_msg_type type) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ struct pd_message msg; -+ -+ memset(&msg, 0, sizeof(msg)); -+ msg.header = PD_HEADER_LE(type, port->pwr_role, -+ port->data_role, -+ port->negotiated_rev, -+ port->message_id, 0); -+ -+ return tcpm_pd_transmit(dev, TCPC_TX_SOP, &msg); -+} -+ -+/* -+ * Send queued message without affecting state. -+ * Return true if state machine should go back to sleep, -+ * false otherwise. -+ */ -+static bool tcpm_send_queued_message(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ enum pd_msg_request queued_message; -+ int max_messages = 100; -+ -+ do { -+ queued_message = port->queued_message; -+ port->queued_message = PD_MSG_NONE; -+ max_messages--; -+ -+ switch (queued_message) { -+ case PD_MSG_CTRL_WAIT: -+ tcpm_pd_send_control(dev, PD_CTRL_WAIT); -+ break; -+ case PD_MSG_CTRL_REJECT: -+ tcpm_pd_send_control(dev, PD_CTRL_REJECT); -+ break; -+ case PD_MSG_CTRL_NOT_SUPP: -+ tcpm_pd_send_control(dev, PD_CTRL_NOT_SUPP); -+ break; -+ case PD_MSG_DATA_SINK_CAP: -+ tcpm_pd_send_sink_caps(dev); -+ break; -+ case PD_MSG_DATA_SOURCE_CAP: -+ tcpm_pd_send_source_caps(dev); -+ break; -+ default: -+ break; -+ } -+ } while (max_messages > 0 && port->queued_message != PD_MSG_NONE); -+ -+ if (!max_messages) -+ dev_err(dev, "Aborted sending of too many queued messages\n"); -+ -+ return false; -+} -+ -+static int tcpm_pd_check_request(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ u32 pdo, rdo = port->sink_request; -+ unsigned int max, op, pdo_max, index; -+ enum pd_pdo_type type; -+ -+ index = rdo_index(rdo); -+ if (!index || index > port->nr_src_pdo) -+ return -EINVAL; -+ -+ pdo = port->src_pdo[index - 1]; -+ type = pdo_type(pdo); -+ switch (type) { -+ case PDO_TYPE_FIXED: -+ case PDO_TYPE_VAR: -+ max = rdo_max_current(rdo); -+ op = rdo_op_current(rdo); -+ pdo_max = pdo_max_current(pdo); -+ -+ if (op > pdo_max) -+ return -EINVAL; -+ if (max > pdo_max && !(rdo & RDO_CAP_MISMATCH)) -+ return -EINVAL; -+ -+ if (type == PDO_TYPE_FIXED) -+ dev_dbg(dev, "TCPM: Requested %u mV, %u mA for %u / %u mA\n", -+ pdo_fixed_voltage(pdo), pdo_max, op, max); -+ else -+ dev_dbg(dev, "TCPM: Requested %u -> %u mV, %u mA for %u / %u mA\n", -+ pdo_min_voltage(pdo), pdo_max_voltage(pdo), -+ pdo_max, op, max); -+ break; -+ case PDO_TYPE_BATT: -+ max = rdo_max_power(rdo); -+ op = rdo_op_power(rdo); -+ pdo_max = pdo_max_power(pdo); -+ -+ if (op > pdo_max) -+ return -EINVAL; -+ if (max > pdo_max && !(rdo & RDO_CAP_MISMATCH)) -+ return -EINVAL; -+ dev_info(dev, "TCPM: Requested %u -> %u mV, %u mW for %u / %u mW\n", -+ pdo_min_voltage(pdo), pdo_max_voltage(pdo), -+ pdo_max, op, max); -+ break; -+ default: -+ return -EINVAL; -+ } -+ -+ return 0; -+} -+ -+#define min_power(x, y) min(pdo_max_power(x), pdo_max_power(y)) -+#define min_current(x, y) min(pdo_max_current(x), pdo_max_current(y)) -+ -+static int tcpm_pd_select_pdo(struct udevice *dev, int *sink_pdo, -+ int *src_pdo) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ unsigned int i, j, max_src_mv = 0, min_src_mv = 0, max_mw = 0, -+ max_mv = 0, src_mw = 0, src_ma = 0, max_snk_mv = 0, -+ min_snk_mv = 0; -+ int ret = -EINVAL; -+ -+ /* -+ * Select the source PDO providing the most power which has a -+ * matchig sink cap. -+ */ -+ for (i = 0; i < port->nr_source_caps; i++) { -+ u32 pdo = port->source_caps[i]; -+ enum pd_pdo_type type = pdo_type(pdo); -+ -+ switch (type) { -+ case PDO_TYPE_FIXED: -+ max_src_mv = pdo_fixed_voltage(pdo); -+ min_src_mv = max_src_mv; -+ break; -+ case PDO_TYPE_BATT: -+ case PDO_TYPE_VAR: -+ max_src_mv = pdo_max_voltage(pdo); -+ min_src_mv = pdo_min_voltage(pdo); -+ break; -+ case PDO_TYPE_APDO: -+ continue; -+ default: -+ dev_err(dev, "TCPM: Invalid source PDO type, ignoring\n"); -+ continue; -+ } -+ -+ switch (type) { -+ case PDO_TYPE_FIXED: -+ case PDO_TYPE_VAR: -+ src_ma = pdo_max_current(pdo); -+ src_mw = src_ma * min_src_mv / 1000; -+ break; -+ case PDO_TYPE_BATT: -+ src_mw = pdo_max_power(pdo); -+ break; -+ case PDO_TYPE_APDO: -+ continue; -+ default: -+ dev_err(dev, "TCPM: Invalid source PDO type, ignoring\n"); -+ continue; -+ } -+ -+ for (j = 0; j < port->nr_snk_pdo; j++) { -+ pdo = port->snk_pdo[j]; -+ -+ switch (pdo_type(pdo)) { -+ case PDO_TYPE_FIXED: -+ max_snk_mv = pdo_fixed_voltage(pdo); -+ min_snk_mv = max_snk_mv; -+ break; -+ case PDO_TYPE_BATT: -+ case PDO_TYPE_VAR: -+ max_snk_mv = pdo_max_voltage(pdo); -+ min_snk_mv = pdo_min_voltage(pdo); -+ break; -+ case PDO_TYPE_APDO: -+ continue; -+ default: -+ dev_err(dev, "TCPM: Invalid sink PDO type, ignoring\n"); -+ continue; -+ } -+ -+ if (max_src_mv <= max_snk_mv && min_src_mv >= min_snk_mv) { -+ /* Prefer higher voltages if available */ -+ if ((src_mw == max_mw && min_src_mv > max_mv) || -+ src_mw > max_mw) { -+ *src_pdo = i; -+ *sink_pdo = j; -+ max_mw = src_mw; -+ max_mv = min_src_mv; -+ ret = 0; -+ } -+ } -+ } -+ } -+ -+ return ret; -+} -+ -+static int tcpm_pd_build_request(struct udevice *dev, u32 *rdo) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ unsigned int mv, ma, mw, flags; -+ unsigned int max_ma, max_mw; -+ enum pd_pdo_type type; -+ u32 pdo, matching_snk_pdo; -+ int src_pdo_index = 0; -+ int snk_pdo_index = 0; -+ int ret; -+ -+ ret = tcpm_pd_select_pdo(dev, &snk_pdo_index, &src_pdo_index); -+ if (ret < 0) -+ return ret; -+ -+ pdo = port->source_caps[src_pdo_index]; -+ matching_snk_pdo = port->snk_pdo[snk_pdo_index]; -+ type = pdo_type(pdo); -+ -+ switch (type) { -+ case PDO_TYPE_FIXED: -+ mv = pdo_fixed_voltage(pdo); -+ break; -+ case PDO_TYPE_BATT: -+ case PDO_TYPE_VAR: -+ mv = pdo_min_voltage(pdo); -+ break; -+ default: -+ dev_err(dev, "TCPM: Invalid PDO selected!\n"); -+ return -EINVAL; -+ } -+ -+ /* Select maximum available current within the sink pdo's limit */ -+ if (type == PDO_TYPE_BATT) { -+ mw = min_power(pdo, matching_snk_pdo); -+ ma = 1000 * mw / mv; -+ } else { -+ ma = min_current(pdo, matching_snk_pdo); -+ mw = ma * mv / 1000; -+ } -+ -+ flags = RDO_USB_COMM | RDO_NO_SUSPEND; -+ -+ /* Set mismatch bit if offered power is less than operating power */ -+ max_ma = ma; -+ max_mw = mw; -+ if (mw < port->operating_snk_mw) { -+ flags |= RDO_CAP_MISMATCH; -+ if (type == PDO_TYPE_BATT && -+ (pdo_max_power(matching_snk_pdo) > pdo_max_power(pdo))) -+ max_mw = pdo_max_power(matching_snk_pdo); -+ else if (pdo_max_current(matching_snk_pdo) > -+ pdo_max_current(pdo)) -+ max_ma = pdo_max_current(matching_snk_pdo); -+ } -+ -+ dev_dbg(dev, "TCPM: cc=%d cc1=%d cc2=%d vbus=%d vconn=%s polarity=%d\n", -+ port->cc_req, port->cc1, port->cc2, port->vbus_source, -+ port->vconn_role == TYPEC_SOURCE ? "source" : "sink", -+ port->polarity); -+ -+ if (type == PDO_TYPE_BATT) { -+ *rdo = RDO_BATT(src_pdo_index + 1, mw, max_mw, flags); -+ -+ dev_info(dev, "TCPM: requesting PDO %d: %u mV, %u mW%s\n", -+ src_pdo_index, mv, mw, -+ flags & RDO_CAP_MISMATCH ? " [mismatch]" : ""); -+ } else { -+ *rdo = RDO_FIXED(src_pdo_index + 1, ma, max_ma, flags); -+ -+ dev_info(dev, "TCPM: requesting PDO %d: %u mV, %u mA%s\n", -+ src_pdo_index, mv, ma, -+ flags & RDO_CAP_MISMATCH ? " [mismatch]" : ""); -+ } -+ -+ port->req_current_limit = ma; -+ port->req_supply_voltage = mv; -+ -+ return 0; -+} -+ -+static int tcpm_pd_send_request(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ struct pd_message msg; -+ int ret; -+ u32 rdo; -+ -+ ret = tcpm_pd_build_request(dev, &rdo); -+ if (ret < 0) -+ return ret; -+ -+ memset(&msg, 0, sizeof(msg)); -+ msg.header = PD_HEADER_LE(PD_DATA_REQUEST, -+ port->pwr_role, -+ port->data_role, -+ port->negotiated_rev, -+ port->message_id, 1); -+ msg.payload[0] = cpu_to_le32(rdo); -+ -+ return tcpm_pd_transmit(dev, TCPC_TX_SOP, &msg); -+} -+ -+static int tcpm_set_vbus(struct udevice *dev, bool enable) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ int ret; -+ -+ if (enable && port->vbus_charge) -+ return -EINVAL; -+ -+ dev_dbg(dev, "TCPM: set vbus = %d charge = %d\n", -+ enable, port->vbus_charge); -+ -+ ret = drvops->set_vbus(dev, enable, port->vbus_charge); -+ if (ret < 0) -+ return ret; -+ -+ port->vbus_source = enable; -+ return 0; -+} -+ -+static int tcpm_set_charge(struct udevice *dev, bool charge) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ int ret; -+ -+ if (charge && port->vbus_source) -+ return -EINVAL; -+ -+ if (charge != port->vbus_charge) { -+ dev_dbg(dev, "TCPM: set vbus = %d charge = %d\n", -+ port->vbus_source, charge); -+ ret = drvops->set_vbus(dev, port->vbus_source, -+ charge); -+ if (ret < 0) -+ return ret; -+ } -+ port->vbus_charge = charge; -+ return 0; -+} -+ -+static bool tcpm_start_toggling(struct udevice *dev, enum typec_cc_status cc) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ int ret; -+ -+ if (!drvops->start_toggling) -+ return false; -+ -+ dev_dbg(dev, "TCPM: Start toggling\n"); -+ ret = drvops->start_toggling(dev, port->port_type, cc); -+ return ret == 0; -+} -+ -+static int tcpm_init_vbus(struct udevice *dev) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ int ret; -+ -+ ret = drvops->set_vbus(dev, false, false); -+ port->vbus_source = false; -+ port->vbus_charge = false; -+ return ret; -+} -+ -+static int tcpm_init_vconn(struct udevice *dev) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ int ret; -+ -+ ret = drvops->set_vconn(dev, false); -+ port->vconn_role = TYPEC_SINK; -+ return ret; -+} -+ -+static inline void tcpm_typec_connect(struct tcpm_port *port) -+{ -+ if (!port->connected) -+ port->connected = true; -+} -+ -+static int tcpm_src_attach(struct udevice *dev) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ enum typec_cc_polarity polarity = -+ port->cc2 == TYPEC_CC_RD ? TYPEC_POLARITY_CC2 -+ : TYPEC_POLARITY_CC1; -+ int ret; -+ -+ if (port->attached) -+ return 0; -+ -+ ret = tcpm_set_polarity(dev, polarity); -+ if (ret < 0) -+ return ret; -+ -+ ret = tcpm_set_roles(dev, true, TYPEC_SOURCE, TYPEC_HOST); -+ if (ret < 0) -+ return ret; -+ -+ ret = drvops->set_pd_rx(dev, true); -+ if (ret < 0) -+ goto out_disable_mux; -+ -+ /* -+ * USB Type-C specification, version 1.2, -+ * chapter 4.5.2.2.8.1 (Attached.SRC Requirements) -+ * Enable VCONN only if the non-RD port is set to RA. -+ */ -+ if ((polarity == TYPEC_POLARITY_CC1 && port->cc2 == TYPEC_CC_RA) || -+ (polarity == TYPEC_POLARITY_CC2 && port->cc1 == TYPEC_CC_RA)) { -+ ret = tcpm_set_vconn(dev, true); -+ if (ret < 0) -+ goto out_disable_pd; -+ } -+ -+ ret = tcpm_set_vbus(dev, true); -+ if (ret < 0) -+ goto out_disable_vconn; -+ -+ port->pd_capable = false; -+ -+ port->partner = NULL; -+ -+ port->attached = true; -+ -+ return 0; -+ -+out_disable_vconn: -+ tcpm_set_vconn(dev, false); -+out_disable_pd: -+ drvops->set_pd_rx(dev, false); -+out_disable_mux: -+ dev_err(dev, "TCPM: CC connected in %s as DFP\n", -+ polarity ? "CC2" : "CC1"); -+ return 0; -+} -+ -+static inline void tcpm_typec_disconnect(struct tcpm_port *port) -+{ -+ if (port->connected) { -+ port->partner = NULL; -+ port->connected = false; -+ } -+} -+ -+static void tcpm_reset_port(struct udevice *dev) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ tcpm_timer_uninit(dev); -+ tcpm_typec_disconnect(port); -+ tcpm_reset_event_cnt(dev); -+ port->wait_dr_swap_message = false; -+ port->attached = false; -+ port->pd_capable = false; -+ -+ /* -+ * First Rx ID should be 0; set this to a sentinel of -1 so that -+ * we can check tcpm_pd_rx_handler() if we had seen it before. -+ */ -+ port->rx_msgid = -1; -+ -+ drvops->set_pd_rx(dev, false); -+ tcpm_init_vbus(dev); /* also disables charging */ -+ tcpm_init_vconn(dev); -+ tcpm_set_current_limit(dev, 0, 0); -+ tcpm_set_polarity(dev, TYPEC_POLARITY_CC1); -+ tcpm_set_attached_state(dev, false); -+ port->nr_sink_caps = 0; -+} -+ -+static void tcpm_detach(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ if (tcpm_port_is_disconnected(port)) -+ port->hard_reset_count = 0; -+ -+ if (!port->attached) -+ return; -+ -+ tcpm_reset_port(dev); -+} -+ -+static void tcpm_src_detach(struct udevice *dev) -+{ -+ tcpm_detach(dev); -+} -+ -+static int tcpm_snk_attach(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ int ret; -+ -+ if (port->attached) -+ return 0; -+ -+ ret = tcpm_set_polarity(dev, port->cc2 != TYPEC_CC_OPEN ? -+ TYPEC_POLARITY_CC2 : TYPEC_POLARITY_CC1); -+ if (ret < 0) -+ return ret; -+ -+ ret = tcpm_set_roles(dev, true, TYPEC_SINK, TYPEC_DEVICE); -+ if (ret < 0) -+ return ret; -+ -+ port->pd_capable = false; -+ -+ port->partner = NULL; -+ -+ port->attached = true; -+ dev_info(dev, "TCPM: CC connected in %s as UFP\n", -+ port->cc1 != TYPEC_CC_OPEN ? "CC1" : "CC2"); -+ -+ return 0; -+} -+ -+static void tcpm_snk_detach(struct udevice *dev) -+{ -+ tcpm_detach(dev); -+} -+ -+static inline enum tcpm_state hard_reset_state(struct tcpm_port *port) -+{ -+ if (port->hard_reset_count < PD_N_HARD_RESET_COUNT) -+ return HARD_RESET_SEND; -+ if (port->pd_capable) -+ return ERROR_RECOVERY; -+ if (port->pwr_role == TYPEC_SOURCE) -+ return SRC_UNATTACHED; -+ if (port->state == SNK_WAIT_CAPABILITIES) -+ return SNK_READY; -+ return SNK_UNATTACHED; -+} -+ -+static inline enum tcpm_state unattached_state(struct tcpm_port *port) -+{ -+ if (port->port_type == TYPEC_PORT_DRP) { -+ if (port->pwr_role == TYPEC_SOURCE) -+ return SRC_UNATTACHED; -+ else -+ return SNK_UNATTACHED; -+ } else if (port->port_type == TYPEC_PORT_SRC) { -+ return SRC_UNATTACHED; -+ } -+ -+ return SNK_UNATTACHED; -+} -+ -+static void run_state_machine(struct udevice *dev) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ int ret; -+ -+ port->enter_state = port->state; -+ switch (port->state) { -+ case TOGGLING: -+ break; -+ /* SRC states */ -+ case SRC_UNATTACHED: -+ tcpm_src_detach(dev); -+ if (tcpm_start_toggling(dev, tcpm_rp_cc(port))) { -+ tcpm_set_state(dev, TOGGLING, 0); -+ break; -+ } -+ tcpm_set_cc(dev, tcpm_rp_cc(port)); -+ if (port->port_type == TYPEC_PORT_DRP) -+ tcpm_set_state(dev, SNK_UNATTACHED, PD_T_DRP_SNK); -+ break; -+ case SRC_ATTACH_WAIT: -+ if (tcpm_port_is_source(port)) -+ tcpm_set_state(dev, SRC_ATTACHED, PD_T_CC_DEBOUNCE); -+ break; -+ -+ case SRC_ATTACHED: -+ ret = tcpm_src_attach(dev); -+ /* -+ * Currently, vbus control is not implemented, -+ * and the SRC detection process cannot be fully implemented. -+ */ -+ tcpm_set_state(dev, SRC_READY, 0); -+ break; -+ case SRC_STARTUP: -+ port->caps_count = 0; -+ port->negotiated_rev = PD_MAX_REV; -+ port->message_id = 0; -+ port->rx_msgid = -1; -+ port->explicit_contract = false; -+ tcpm_set_state(dev, SRC_SEND_CAPABILITIES, 0); -+ break; -+ case SRC_SEND_CAPABILITIES: -+ port->caps_count++; -+ if (port->caps_count > PD_N_CAPS_COUNT) { -+ tcpm_set_state(dev, SRC_READY, 0); -+ break; -+ } -+ ret = tcpm_pd_send_source_caps(dev); -+ if (ret < 0) { -+ tcpm_set_state(dev, SRC_SEND_CAPABILITIES, -+ PD_T_SEND_SOURCE_CAP); -+ } else { -+ /* -+ * Per standard, we should clear the reset counter here. -+ * However, that can result in state machine hang-ups. -+ * Reset it only in READY state to improve stability. -+ */ -+ /* port->hard_reset_count = 0; */ -+ port->caps_count = 0; -+ port->pd_capable = true; -+ tcpm_set_state_cond(dev, SRC_SEND_CAPABILITIES_TIMEOUT, -+ PD_T_SEND_SOURCE_CAP); -+ } -+ break; -+ case SRC_SEND_CAPABILITIES_TIMEOUT: -+ /* -+ * Error recovery for a PD_DATA_SOURCE_CAP reply timeout. -+ * -+ * PD 2.0 sinks are supposed to accept src-capabilities with a -+ * 3.0 header and simply ignore any src PDOs which the sink does -+ * not understand such as PPS but some 2.0 sinks instead ignore -+ * the entire PD_DATA_SOURCE_CAP message, causing contract -+ * negotiation to fail. -+ * -+ * After PD_N_HARD_RESET_COUNT hard-reset attempts, we try -+ * sending src-capabilities with a lower PD revision to -+ * make these broken sinks work. -+ */ -+ if (port->hard_reset_count < PD_N_HARD_RESET_COUNT) { -+ tcpm_set_state(dev, HARD_RESET_SEND, 0); -+ } else if (port->negotiated_rev > PD_REV20) { -+ port->negotiated_rev--; -+ port->hard_reset_count = 0; -+ tcpm_set_state(dev, SRC_SEND_CAPABILITIES, 0); -+ } else { -+ tcpm_set_state(dev, hard_reset_state(port), 0); -+ } -+ break; -+ case SRC_NEGOTIATE_CAPABILITIES: -+ ret = tcpm_pd_check_request(dev); -+ if (ret < 0) { -+ tcpm_pd_send_control(dev, PD_CTRL_REJECT); -+ if (!port->explicit_contract) { -+ tcpm_set_state(dev, -+ SRC_WAIT_NEW_CAPABILITIES, 0); -+ } else { -+ tcpm_set_state(dev, SRC_READY, 0); -+ } -+ } else { -+ tcpm_pd_send_control(dev, PD_CTRL_ACCEPT); -+ tcpm_set_state(dev, SRC_TRANSITION_SUPPLY, -+ PD_T_SRC_TRANSITION); -+ } -+ break; -+ case SRC_TRANSITION_SUPPLY: -+ /* XXX: regulator_set_voltage(vbus, ...) */ -+ tcpm_pd_send_control(dev, PD_CTRL_PS_RDY); -+ port->explicit_contract = true; -+ tcpm_set_state_cond(dev, SRC_READY, 0); -+ break; -+ case SRC_READY: -+ port->hard_reset_count = 0; -+ -+ tcpm_typec_connect(port); -+ break; -+ case SRC_WAIT_NEW_CAPABILITIES: -+ /* Nothing to do... */ -+ break; -+ -+ /* SNK states */ -+ case SNK_UNATTACHED: -+ tcpm_snk_detach(dev); -+ if (tcpm_start_toggling(dev, TYPEC_CC_RD)) { -+ tcpm_set_state(dev, TOGGLING, 0); -+ break; -+ } -+ tcpm_set_cc(dev, TYPEC_CC_RD); -+ if (port->port_type == TYPEC_PORT_DRP) -+ tcpm_set_state(dev, SRC_UNATTACHED, PD_T_DRP_SRC); -+ break; -+ case SNK_ATTACH_WAIT: -+ if ((port->cc1 == TYPEC_CC_OPEN && -+ port->cc2 != TYPEC_CC_OPEN) || -+ (port->cc1 != TYPEC_CC_OPEN && -+ port->cc2 == TYPEC_CC_OPEN)) -+ tcpm_set_state(dev, SNK_DEBOUNCED, -+ PD_T_CC_DEBOUNCE); -+ else if (tcpm_port_is_disconnected(port)) -+ tcpm_set_state(dev, SNK_UNATTACHED, -+ PD_T_CC_DEBOUNCE); -+ break; -+ case SNK_DEBOUNCED: -+ if (tcpm_port_is_disconnected(port)) -+ tcpm_set_state(dev, SNK_UNATTACHED, PD_T_PD_DEBOUNCE); -+ else if (port->vbus_present) -+ tcpm_set_state(dev, SNK_ATTACHED, 0); -+ else -+ /* Wait for VBUS, but not forever */ -+ tcpm_set_state(dev, PORT_RESET, PD_T_PS_SOURCE_ON); -+ break; -+ case SNK_ATTACHED: -+ ret = tcpm_snk_attach(dev); -+ if (ret < 0) -+ tcpm_set_state(dev, SNK_UNATTACHED, 0); -+ else -+ tcpm_set_state(dev, SNK_STARTUP, 0); -+ break; -+ case SNK_STARTUP: -+ port->negotiated_rev = PD_MAX_REV; -+ port->message_id = 0; -+ port->rx_msgid = -1; -+ port->explicit_contract = false; -+ tcpm_set_state(dev, SNK_DISCOVERY, 0); -+ break; -+ case SNK_DISCOVERY: -+ if (port->vbus_present) { -+ tcpm_set_current_limit(dev, -+ tcpm_get_current_limit(port), -+ 5000); -+ tcpm_set_charge(dev, true); -+ tcpm_set_state(dev, SNK_WAIT_CAPABILITIES, 0); -+ break; -+ } -+ /* -+ * For DRP, timeouts differ. Also, handling is supposed to be -+ * different and much more complex (dead battery detection; -+ * see USB power delivery specification, section 8.3.3.6.1.5.1). -+ */ -+ tcpm_set_state(dev, hard_reset_state(port), -+ port->port_type == TYPEC_PORT_DRP ? -+ PD_T_DB_DETECT : PD_T_NO_RESPONSE); -+ break; -+ case SNK_DISCOVERY_DEBOUNCE: -+ tcpm_set_state(dev, SNK_DISCOVERY_DEBOUNCE_DONE, -+ PD_T_CC_DEBOUNCE); -+ break; -+ case SNK_DISCOVERY_DEBOUNCE_DONE: -+ tcpm_set_state(dev, unattached_state(port), 0); -+ break; -+ case SNK_WAIT_CAPABILITIES: -+ ret = drvops->set_pd_rx(dev, true); -+ if (ret < 0) { -+ tcpm_set_state(dev, SNK_READY, 0); -+ break; -+ } -+ /* -+ * If VBUS has never been low, and we time out waiting -+ * for source cap, try a soft reset first, in case we -+ * were already in a stable contract before this boot. -+ * Do this only once. -+ */ -+ if (port->vbus_never_low) { -+ port->vbus_never_low = false; -+ tcpm_set_state(dev, SOFT_RESET_SEND, -+ PD_T_SINK_WAIT_CAP); -+ } else { -+ tcpm_set_state(dev, hard_reset_state(port), -+ PD_T_SINK_WAIT_CAP); -+ } -+ break; -+ case SNK_NEGOTIATE_CAPABILITIES: -+ port->pd_capable = true; -+ port->hard_reset_count = 0; -+ ret = tcpm_pd_send_request(dev); -+ if (ret < 0) { -+ /* Let the Source send capabilities again. */ -+ tcpm_set_state(dev, SNK_WAIT_CAPABILITIES, 0); -+ } else { -+ tcpm_set_state_cond(dev, hard_reset_state(port), -+ PD_T_SENDER_RESPONSE); -+ } -+ break; -+ case SNK_TRANSITION_SINK: -+ case SNK_TRANSITION_SINK_VBUS: -+ tcpm_set_state(dev, hard_reset_state(port), -+ PD_T_PS_TRANSITION); -+ break; -+ case SNK_READY: -+ port->update_sink_caps = false; -+ tcpm_typec_connect(port); -+ /* -+ * Here poll_event_cnt is cleared, waiting for self-powered Type-C devices -+ * to send DR_swap Messge until 1s (TCPM_POLL_EVENT_TIME_OUT * 500us)timeout -+ */ -+ if (port->wait_dr_swap_message) -+ tcpm_reset_event_cnt(dev); -+ -+ break; -+ -+ /* Hard_Reset states */ -+ case HARD_RESET_SEND: -+ tcpm_pd_transmit(dev, TCPC_TX_HARD_RESET, NULL); -+ tcpm_set_state(dev, HARD_RESET_START, 0); -+ port->wait_dr_swap_message = false; -+ break; -+ case HARD_RESET_START: -+ port->hard_reset_count++; -+ drvops->set_pd_rx(dev, false); -+ port->nr_sink_caps = 0; -+ if (port->pwr_role == TYPEC_SOURCE) -+ tcpm_set_state(dev, SRC_HARD_RESET_VBUS_OFF, -+ PD_T_PS_HARD_RESET); -+ else -+ tcpm_set_state(dev, SNK_HARD_RESET_SINK_OFF, 0); -+ break; -+ case SRC_HARD_RESET_VBUS_OFF: -+ tcpm_set_vconn(dev, true); -+ tcpm_set_vbus(dev, false); -+ tcpm_set_roles(dev, port->self_powered, TYPEC_SOURCE, -+ TYPEC_HOST); -+ tcpm_set_state(dev, SRC_HARD_RESET_VBUS_ON, PD_T_SRC_RECOVER); -+ break; -+ case SRC_HARD_RESET_VBUS_ON: -+ tcpm_set_vconn(dev, true); -+ tcpm_set_vbus(dev, true); -+ drvops->set_pd_rx(dev, true); -+ tcpm_set_attached_state(dev, true); -+ tcpm_set_state(dev, SRC_UNATTACHED, PD_T_PS_SOURCE_ON); -+ break; -+ case SNK_HARD_RESET_SINK_OFF: -+ tcpm_set_vconn(dev, false); -+ if (port->pd_capable) -+ tcpm_set_charge(dev, false); -+ tcpm_set_roles(dev, port->self_powered, TYPEC_SINK, -+ TYPEC_DEVICE); -+ /* -+ * VBUS may or may not toggle, depending on the adapter. -+ * If it doesn't toggle, transition to SNK_HARD_RESET_SINK_ON -+ * directly after timeout. -+ */ -+ tcpm_set_state(dev, SNK_HARD_RESET_SINK_ON, PD_T_SAFE_0V); -+ break; -+ case SNK_HARD_RESET_WAIT_VBUS: -+ /* Assume we're disconnected if VBUS doesn't come back. */ -+ tcpm_set_state(dev, SNK_UNATTACHED, -+ PD_T_SRC_RECOVER_MAX + PD_T_SRC_TURN_ON); -+ break; -+ case SNK_HARD_RESET_SINK_ON: -+ /* Note: There is no guarantee that VBUS is on in this state */ -+ /* -+ * XXX: -+ * The specification suggests that dual mode ports in sink -+ * mode should transition to state PE_SRC_Transition_to_default. -+ * See USB power delivery specification chapter 8.3.3.6.1.3. -+ * This would mean to -+ * - turn off VCONN, reset power supply -+ * - request hardware reset -+ * - turn on VCONN -+ * - Transition to state PE_Src_Startup -+ * SNK only ports shall transition to state Snk_Startup -+ * (see chapter 8.3.3.3.8). -+ * Similar, dual-mode ports in source mode should transition -+ * to PE_SNK_Transition_to_default. -+ */ -+ if (port->pd_capable) { -+ tcpm_set_current_limit(dev, -+ tcpm_get_current_limit(port), -+ 5000); -+ tcpm_set_charge(dev, true); -+ } -+ tcpm_set_attached_state(dev, true); -+ tcpm_set_state(dev, SNK_STARTUP, 0); -+ break; -+ -+ /* Soft_Reset states */ -+ case SOFT_RESET: -+ port->message_id = 0; -+ port->rx_msgid = -1; -+ tcpm_pd_send_control(dev, PD_CTRL_ACCEPT); -+ if (port->pwr_role == TYPEC_SOURCE) -+ tcpm_set_state(dev, SRC_SEND_CAPABILITIES, 0); -+ else -+ tcpm_set_state(dev, SNK_WAIT_CAPABILITIES, 0); -+ break; -+ case SOFT_RESET_SEND: -+ port->message_id = 0; -+ port->rx_msgid = -1; -+ if (tcpm_pd_send_control(dev, PD_CTRL_SOFT_RESET)) -+ tcpm_set_state_cond(dev, hard_reset_state(port), 0); -+ else -+ tcpm_set_state_cond(dev, hard_reset_state(port), -+ PD_T_SENDER_RESPONSE); -+ break; -+ -+ /* DR_Swap states */ -+ case DR_SWAP_ACCEPT: -+ tcpm_pd_send_control(dev, PD_CTRL_ACCEPT); -+ tcpm_set_state_cond(dev, DR_SWAP_CHANGE_DR, 0); -+ break; -+ case DR_SWAP_CHANGE_DR: -+ if (port->data_role == TYPEC_HOST) { -+ tcpm_set_roles(dev, true, port->pwr_role, -+ TYPEC_DEVICE); -+ } else { -+ tcpm_set_roles(dev, true, port->pwr_role, -+ TYPEC_HOST); -+ } -+ /* DR_swap process complete, wait_dr_swap_message is cleared */ -+ port->wait_dr_swap_message = false; -+ tcpm_set_state(dev, ready_state(port), 0); -+ break; -+ case ERROR_RECOVERY: -+ tcpm_set_state(dev, PORT_RESET, 0); -+ break; -+ case PORT_RESET: -+ tcpm_reset_port(dev); -+ if (port->self_powered) -+ tcpm_set_cc(dev, TYPEC_CC_OPEN); -+ else -+ tcpm_set_cc(dev, tcpm_default_state(port) == SNK_UNATTACHED ? -+ TYPEC_CC_RD : tcpm_rp_cc(port)); -+ tcpm_set_state(dev, PORT_RESET_WAIT_OFF, -+ PD_T_ERROR_RECOVERY); -+ break; -+ case PORT_RESET_WAIT_OFF: -+ tcpm_set_state(dev, -+ tcpm_default_state(port), -+ port->vbus_present ? PD_T_PS_SOURCE_OFF : 0); -+ break; -+ default: -+ dev_err(dev, "TCPM: Unexpected port state %d\n", port->state); -+ break; -+ } -+} -+ -+static void tcpm_state_machine(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ enum tcpm_state prev_state; -+ -+ mutex_lock(&port->lock); -+ port->state_machine_running = true; -+ -+ if (port->queued_message && tcpm_send_queued_message(dev)) -+ goto done; -+ -+ /* If we were queued due to a delayed state change, update it now */ -+ if (port->delayed_state) { -+ dev_dbg(dev, "TCPM: state change %s -> %s [delayed %ld ms]\n", -+ tcpm_states[port->state], -+ tcpm_states[port->delayed_state], port->delay_ms); -+ port->prev_state = port->state; -+ port->state = port->delayed_state; -+ port->delayed_state = INVALID_STATE; -+ } -+ -+ /* -+ * Continue running as long as we have (non-delayed) state changes -+ * to make. -+ */ -+ do { -+ prev_state = port->state; -+ run_state_machine(dev); -+ if (port->queued_message) -+ tcpm_send_queued_message(dev); -+ } while (port->state != prev_state && !port->delayed_state); -+ -+done: -+ port->state_machine_running = false; -+ mutex_unlock(&port->lock); -+} -+ -+static void _tcpm_cc_change(struct udevice *dev, enum typec_cc_status cc1, -+ enum typec_cc_status cc2) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ enum typec_cc_status old_cc1, old_cc2; -+ enum tcpm_state new_state; -+ -+ old_cc1 = port->cc1; -+ old_cc2 = port->cc2; -+ port->cc1 = cc1; -+ port->cc2 = cc2; -+ -+ dev_dbg(dev, "TCPM: CC1: %u -> %u, CC2: %u -> %u [state %s, polarity %d, %s]\n", -+ old_cc1, cc1, old_cc2, cc2, tcpm_states[port->state], -+ port->polarity, -+ tcpm_port_is_disconnected(port) ? "disconnected" : "connected"); -+ -+ switch (port->state) { -+ case TOGGLING: -+ if (tcpm_port_is_source(port)) -+ tcpm_set_state(dev, SRC_ATTACH_WAIT, 0); -+ else if (tcpm_port_is_sink(port)) -+ tcpm_set_state(dev, SNK_ATTACH_WAIT, 0); -+ break; -+ case SRC_UNATTACHED: -+ case SRC_ATTACH_WAIT: -+ if (tcpm_port_is_disconnected(port)) -+ tcpm_set_state(dev, SRC_UNATTACHED, 0); -+ else if (cc1 != old_cc1 || cc2 != old_cc2) -+ tcpm_set_state(dev, SRC_ATTACH_WAIT, 0); -+ break; -+ case SRC_ATTACHED: -+ case SRC_SEND_CAPABILITIES: -+ case SRC_READY: -+ if (tcpm_port_is_disconnected(port) || -+ !tcpm_port_is_source(port)) -+ tcpm_set_state(dev, SRC_UNATTACHED, 0); -+ break; -+ case SNK_UNATTACHED: -+ if (tcpm_port_is_sink(port)) -+ tcpm_set_state(dev, SNK_ATTACH_WAIT, 0); -+ break; -+ case SNK_ATTACH_WAIT: -+ if ((port->cc1 == TYPEC_CC_OPEN && -+ port->cc2 != TYPEC_CC_OPEN) || -+ (port->cc1 != TYPEC_CC_OPEN && -+ port->cc2 == TYPEC_CC_OPEN)) -+ new_state = SNK_DEBOUNCED; -+ else if (tcpm_port_is_disconnected(port)) -+ new_state = SNK_UNATTACHED; -+ else -+ break; -+ if (new_state != port->delayed_state) -+ tcpm_set_state(dev, SNK_ATTACH_WAIT, 0); -+ break; -+ case SNK_DEBOUNCED: -+ if (tcpm_port_is_disconnected(port)) -+ new_state = SNK_UNATTACHED; -+ else if (port->vbus_present) -+ new_state = tcpm_try_src(port) ? INVALID_STATE : SNK_ATTACHED; -+ else -+ new_state = SNK_UNATTACHED; -+ if (new_state != port->delayed_state) -+ tcpm_set_state(dev, SNK_DEBOUNCED, 0); -+ break; -+ case SNK_READY: -+ if (tcpm_port_is_disconnected(port)) -+ tcpm_set_state(dev, unattached_state(port), 0); -+ else if (!port->pd_capable && -+ (cc1 != old_cc1 || cc2 != old_cc2)) -+ tcpm_set_current_limit(dev, -+ tcpm_get_current_limit(port), -+ 5000); -+ break; -+ -+ case SNK_DISCOVERY: -+ /* CC line is unstable, wait for debounce */ -+ if (tcpm_port_is_disconnected(port)) -+ tcpm_set_state(dev, SNK_DISCOVERY_DEBOUNCE, 0); -+ break; -+ case SNK_DISCOVERY_DEBOUNCE: -+ break; -+ -+ case PORT_RESET: -+ case PORT_RESET_WAIT_OFF: -+ /* -+ * State set back to default mode once the timer completes. -+ * Ignore CC changes here. -+ */ -+ break; -+ default: -+ /* -+ * While acting as sink and auto vbus discharge is enabled, Allow disconnect -+ * to be driven by vbus disconnect. -+ */ -+ if (tcpm_port_is_disconnected(port)) -+ tcpm_set_state(dev, unattached_state(port), 0); -+ break; -+ } -+} -+ -+static void _tcpm_pd_vbus_on(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ dev_dbg(dev, "TCPM: VBUS on event\n"); -+ port->vbus_present = true; -+ /* -+ * When vbus_present is true i.e. Voltage at VBUS is greater than VSAFE5V implicitly -+ * states that vbus is not at VSAFE0V, hence clear the vbus_vsafe0v flag here. -+ */ -+ port->vbus_vsafe0v = false; -+ -+ switch (port->state) { -+ case SNK_TRANSITION_SINK_VBUS: -+ port->explicit_contract = true; -+ tcpm_set_state(dev, SNK_READY, 0); -+ break; -+ case SNK_DISCOVERY: -+ tcpm_set_state(dev, SNK_DISCOVERY, 0); -+ break; -+ case SNK_DEBOUNCED: -+ tcpm_set_state(dev, SNK_ATTACHED, 0); -+ break; -+ case SNK_HARD_RESET_WAIT_VBUS: -+ tcpm_set_state(dev, SNK_HARD_RESET_SINK_ON, 0); -+ break; -+ case SRC_ATTACHED: -+ tcpm_set_state(dev, SRC_STARTUP, 0); -+ break; -+ case SRC_HARD_RESET_VBUS_ON: -+ tcpm_set_state(dev, SRC_STARTUP, 0); -+ break; -+ -+ case PORT_RESET: -+ case PORT_RESET_WAIT_OFF: -+ /* -+ * State set back to default mode once the timer completes. -+ * Ignore vbus changes here. -+ */ -+ break; -+ -+ default: -+ break; -+ } -+} -+ -+static void _tcpm_pd_vbus_off(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ dev_dbg(dev, "TCPM: VBUS off event\n"); -+ port->vbus_present = false; -+ port->vbus_never_low = false; -+ switch (port->state) { -+ case SNK_HARD_RESET_SINK_OFF: -+ tcpm_set_state(dev, SNK_HARD_RESET_WAIT_VBUS, 0); -+ break; -+ case HARD_RESET_SEND: -+ break; -+ case SNK_ATTACH_WAIT: -+ tcpm_set_state(dev, SNK_UNATTACHED, 0); -+ break; -+ -+ case SNK_NEGOTIATE_CAPABILITIES: -+ break; -+ -+ case PORT_RESET_WAIT_OFF: -+ tcpm_set_state(dev, tcpm_default_state(port), 0); -+ break; -+ -+ case PORT_RESET: -+ /* -+ * State set back to default mode once the timer completes. -+ * Ignore vbus changes here. -+ */ -+ break; -+ -+ default: -+ if (port->pwr_role == TYPEC_SINK && port->attached) -+ tcpm_set_state(dev, SNK_UNATTACHED, 0); -+ break; -+ } -+} -+ -+void tcpm_cc_change(struct udevice *dev) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ enum typec_cc_status cc1, cc2; -+ -+ tcpm_reset_event_cnt(dev); -+ if (drvops->get_cc(dev, &cc1, &cc2) == 0) -+ _tcpm_cc_change(dev, cc1, cc2); -+} -+ -+void tcpm_vbus_change(struct udevice *dev) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ bool vbus; -+ -+ tcpm_reset_event_cnt(dev); -+ vbus = drvops->get_vbus(dev); -+ if (vbus) -+ _tcpm_pd_vbus_on(dev); -+ else -+ _tcpm_pd_vbus_off(dev); -+} -+ -+void tcpm_pd_hard_reset(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ tcpm_reset_event_cnt(dev); -+ dev_dbg(dev, "TCPM: Received hard reset\n"); -+ -+ /* If a hard reset message is received during the port reset process, -+ * we should ignore it, that is, do not set port->state to HARD_RESET_START. -+ */ -+ if (port->state == PORT_RESET || port->state == PORT_RESET_WAIT_OFF) -+ return; -+ -+ /* -+ * If we keep receiving hard reset requests, executing the hard reset -+ * must have failed. Revert to error recovery if that happens. -+ */ -+ tcpm_set_state(dev, -+ port->hard_reset_count < PD_N_HARD_RESET_COUNT ? -+ HARD_RESET_START : ERROR_RECOVERY, -+ 0); -+} -+ -+static void tcpm_init(struct udevice *dev) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ enum typec_cc_status cc1, cc2; -+ -+ drvops->init(dev); -+ -+ tcpm_reset_port(dev); -+ -+ /* -+ * XXX -+ * Should possibly wait for VBUS to settle if it was enabled locally -+ * since tcpm_reset_port() will disable VBUS. -+ */ -+ port->vbus_present = drvops->get_vbus(dev); -+ if (port->vbus_present) -+ port->vbus_never_low = true; -+ -+ /* -+ * 1. When vbus_present is true, voltage on VBUS is already at VSAFE5V. -+ * So implicitly vbus_vsafe0v = false. -+ * -+ * 2. When vbus_present is false and TCPC does NOT support querying -+ * vsafe0v status, then, it's best to assume vbus is at VSAFE0V i.e. -+ * vbus_vsafe0v is true. -+ * -+ * 3. When vbus_present is false and TCPC does support querying vsafe0v, -+ * then, query tcpc for vsafe0v status. -+ */ -+ if (port->vbus_present) -+ port->vbus_vsafe0v = false; -+ else -+ port->vbus_vsafe0v = true; -+ -+ tcpm_set_state(dev, tcpm_default_state(port), 0); -+ -+ if (drvops->get_cc(dev, &cc1, &cc2) == 0) -+ _tcpm_cc_change(dev, cc1, cc2); -+} -+ -+static int tcpm_fw_get_caps(struct udevice *dev) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ ofnode node; -+ const char *cap_str; -+ int ret; -+ u32 mw; -+ -+ ret = drvops->get_connector_node(dev, &node); -+ if (ret) -+ return ret; -+ -+ cap_str = ofnode_read_string(node, "power-role"); -+ if (!cap_str) -+ return -EINVAL; -+ -+ if (!strcmp("dual", cap_str)) -+ port->typec_type = TYPEC_PORT_DRP; -+ else if (!strcmp("source", cap_str)) -+ port->typec_type = TYPEC_PORT_SRC; -+ else if (!strcmp("sink", cap_str)) -+ port->typec_type = TYPEC_PORT_SNK; -+ else -+ return -EINVAL; -+ -+ port->port_type = port->typec_type; -+ -+ if (port->port_type == TYPEC_PORT_SNK) -+ goto sink; -+ -+ /* Get source pdos */ -+ ret = ofnode_read_size(node, "source-pdos") / sizeof(u32); -+ if (ret <= 0) -+ return -EINVAL; -+ -+ port->nr_src_pdo = min(ret, PDO_MAX_OBJECTS); -+ ret = ofnode_read_u32_array(node, "source-pdos", -+ port->src_pdo, port->nr_src_pdo); -+ if (ret || tcpm_validate_caps(dev, port->src_pdo, port->nr_src_pdo)) -+ return -EINVAL; -+ -+ if (port->port_type == TYPEC_PORT_SRC) -+ return 0; -+ -+ /* Get the preferred power role for DRP */ -+ cap_str = ofnode_read_string(node, "try-power-role"); -+ if (!cap_str) -+ return -EINVAL; -+ -+ if (!strcmp("sink", cap_str)) -+ port->typec_prefer_role = TYPEC_SINK; -+ else if (!strcmp("source", cap_str)) -+ port->typec_prefer_role = TYPEC_SOURCE; -+ else -+ return -EINVAL; -+ -+ if (port->typec_prefer_role < 0) -+ return -EINVAL; -+sink: -+ /* Get sink pdos */ -+ ret = ofnode_read_size(node, "sink-pdos") / sizeof(u32); -+ if (ret <= 0) -+ return -EINVAL; -+ -+ port->nr_snk_pdo = min(ret, PDO_MAX_OBJECTS); -+ ret = ofnode_read_u32_array(node, "sink-pdos", -+ port->snk_pdo, port->nr_snk_pdo); -+ if (ret || tcpm_validate_caps(dev, port->snk_pdo, port->nr_snk_pdo)) -+ return -EINVAL; -+ -+ if (ofnode_read_u32_array(node, "op-sink-microwatt", &mw, 1)) -+ return -EINVAL; -+ port->operating_snk_mw = mw / 1000; -+ -+ port->self_powered = ofnode_read_bool(node, "self-powered"); -+ -+ return 0; -+} -+ -+static int tcpm_port_init(struct udevice *dev) -+{ -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ int err; -+ -+ err = tcpm_fw_get_caps(dev); -+ if (err < 0) { -+ dev_err(dev, "TCPM: please check the dts config: %d\n", err); -+ return err; -+ } -+ -+ port->try_role = port->typec_prefer_role; -+ port->port_type = port->typec_type; -+ -+ tcpm_init(dev); -+ -+ dev_info(dev, "TCPM: init finished\n"); -+ -+ return 0; -+} -+ -+static void tcpm_poll_event(struct udevice *dev) -+{ -+ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); -+ struct tcpm_port *port = dev_get_uclass_plat(dev); -+ -+ if (!drvops->get_vbus(dev)) -+ return; -+ -+ while (port->poll_event_cnt < TCPM_POLL_EVENT_TIME_OUT) { -+ if (!port->wait_dr_swap_message && -+ (port->state == SNK_READY || port->state == SRC_READY)) -+ break; -+ -+ drvops->poll_event(dev); -+ port->poll_event_cnt++; -+ udelay(500); -+ tcpm_check_and_run_delayed_work(dev); -+ } -+ -+ if (port->state != SNK_READY && port->state != SRC_READY) -+ dev_warn(dev, "TCPM: exit in state %s\n", -+ tcpm_states[port->state]); -+ -+ /* -+ * At this time, call the callback function of the respective pd chip -+ * to enter the low-power mode. In order to reduce the time spent on -+ * the PD chip driver as much as possible, the tcpm framework does not -+ * fully process the communication initiated by the device,so it should -+ * be noted that we can disable the internal oscillator, etc., but do -+ * not turn off the power of the transceiver module, otherwise the -+ * self-powered Type-C device will initiate a Message(eg: self-powered -+ * Type-C hub initiates a SINK capability request(PD_CTRL_GET_SINK_CAP)) -+ * and the pd chip cannot reply to GoodCRC, causing the self-powered Type-C -+ * device to switch vbus to vSafe5v, or even turn off vbus. -+ */ -+ if (!drvops->enter_low_power_mode) -+ return; -+ -+ if (drvops->enter_low_power_mode(dev, port->attached, port->pd_capable)) -+ dev_err(dev, "TCPM: failed to enter low power\n"); -+ else -+ dev_info(dev, "TCPM: PD chip enter low power mode\n"); -+} -+ -+int tcpm_post_probe(struct udevice *dev) -+{ -+ int ret = tcpm_port_init(dev); -+ -+ if (ret < 0) { -+ dev_err(dev, "failed to tcpm port init\n"); -+ return ret; -+ } -+ -+ tcpm_poll_event(dev); -+ -+ return 0; -+} -diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h -index 5271e646bb16..270088ad94f7 100644 ---- a/include/dm/uclass-id.h -+++ b/include/dm/uclass-id.h -@@ -139,6 +139,7 @@ enum uclass_id { - UCLASS_SYSCON, /* System configuration device */ - UCLASS_SYSINFO, /* Device information from hardware */ - UCLASS_SYSRESET, /* System reset device */ -+ UCLASS_TCPM, /* TypeC port manager */ - UCLASS_TEE, /* Trusted Execution Environment device */ - UCLASS_THERMAL, /* Thermal sensor */ - UCLASS_TIMER, /* Timer device */ -diff --git a/include/usb/pd.h b/include/usb/pd.h -new file mode 100644 -index 000000000000..cacda322d7c6 ---- /dev/null -+++ b/include/usb/pd.h -@@ -0,0 +1,516 @@ -+/* SPDX-License-Identifier: GPL-2.0-or-later */ -+/* -+ * Copyright 2015-2017 Google, Inc -+ */ -+ -+#ifndef __LINUX_USB_PD_H -+#define __LINUX_USB_PD_H -+ -+#include -+#include -+ -+enum typec_port_type { -+ TYPEC_PORT_SRC, -+ TYPEC_PORT_SNK, -+ TYPEC_PORT_DRP, -+}; -+ -+enum typec_data_role { -+ TYPEC_DEVICE, -+ TYPEC_HOST, -+}; -+ -+enum typec_role { -+ TYPEC_SINK, -+ TYPEC_SOURCE, -+}; -+ -+/* USB PD Messages */ -+enum pd_ctrl_msg_type { -+ /* 0 Reserved */ -+ PD_CTRL_GOOD_CRC = 1, -+ PD_CTRL_GOTO_MIN = 2, -+ PD_CTRL_ACCEPT = 3, -+ PD_CTRL_REJECT = 4, -+ PD_CTRL_PING = 5, -+ PD_CTRL_PS_RDY = 6, -+ PD_CTRL_GET_SOURCE_CAP = 7, -+ PD_CTRL_GET_SINK_CAP = 8, -+ PD_CTRL_DR_SWAP = 9, -+ PD_CTRL_PR_SWAP = 10, -+ PD_CTRL_VCONN_SWAP = 11, -+ PD_CTRL_WAIT = 12, -+ PD_CTRL_SOFT_RESET = 13, -+ /* 14-15 Reserved */ -+ PD_CTRL_NOT_SUPP = 16, -+ PD_CTRL_GET_SOURCE_CAP_EXT = 17, -+ PD_CTRL_GET_STATUS = 18, -+ PD_CTRL_FR_SWAP = 19, -+ PD_CTRL_GET_PPS_STATUS = 20, -+ PD_CTRL_GET_COUNTRY_CODES = 21, -+ /* 22-31 Reserved */ -+}; -+ -+enum pd_data_msg_type { -+ /* 0 Reserved */ -+ PD_DATA_SOURCE_CAP = 1, -+ PD_DATA_REQUEST = 2, -+ PD_DATA_BIST = 3, -+ PD_DATA_SINK_CAP = 4, -+ PD_DATA_BATT_STATUS = 5, -+ PD_DATA_ALERT = 6, -+ PD_DATA_GET_COUNTRY_INFO = 7, -+ PD_DATA_ENTER_USB = 8, -+ /* 9-14 Reserved */ -+ PD_DATA_VENDOR_DEF = 15, -+ /* 16-31 Reserved */ -+}; -+ -+enum pd_ext_msg_type { -+ /* 0 Reserved */ -+ PD_EXT_SOURCE_CAP_EXT = 1, -+ PD_EXT_STATUS = 2, -+ PD_EXT_GET_BATT_CAP = 3, -+ PD_EXT_GET_BATT_STATUS = 4, -+ PD_EXT_BATT_CAP = 5, -+ PD_EXT_GET_MANUFACTURER_INFO = 6, -+ PD_EXT_MANUFACTURER_INFO = 7, -+ PD_EXT_SECURITY_REQUEST = 8, -+ PD_EXT_SECURITY_RESPONSE = 9, -+ PD_EXT_FW_UPDATE_REQUEST = 10, -+ PD_EXT_FW_UPDATE_RESPONSE = 11, -+ PD_EXT_PPS_STATUS = 12, -+ PD_EXT_COUNTRY_INFO = 13, -+ PD_EXT_COUNTRY_CODES = 14, -+ /* 15-31 Reserved */ -+}; -+ -+#define PD_REV10 0x0 -+#define PD_REV20 0x1 -+#define PD_REV30 0x2 -+#define PD_MAX_REV PD_REV30 -+ -+#define PD_HEADER_EXT_HDR BIT(15) -+#define PD_HEADER_CNT_SHIFT 12 -+#define PD_HEADER_CNT_MASK 0x7 -+#define PD_HEADER_ID_SHIFT 9 -+#define PD_HEADER_ID_MASK 0x7 -+#define PD_HEADER_PWR_ROLE BIT(8) -+#define PD_HEADER_REV_SHIFT 6 -+#define PD_HEADER_REV_MASK 0x3 -+#define PD_HEADER_DATA_ROLE BIT(5) -+#define PD_HEADER_TYPE_SHIFT 0 -+#define PD_HEADER_TYPE_MASK 0x1f -+ -+#define PD_HEADER(type, pwr, data, rev, id, cnt, ext_hdr) \ -+ ((((type) & PD_HEADER_TYPE_MASK) << PD_HEADER_TYPE_SHIFT) | \ -+ ((pwr) == TYPEC_SOURCE ? PD_HEADER_PWR_ROLE : 0) | \ -+ ((data) == TYPEC_HOST ? PD_HEADER_DATA_ROLE : 0) | \ -+ ((rev) << PD_HEADER_REV_SHIFT) | \ -+ (((id) & PD_HEADER_ID_MASK) << PD_HEADER_ID_SHIFT) | \ -+ (((cnt) & PD_HEADER_CNT_MASK) << PD_HEADER_CNT_SHIFT) | \ -+ ((ext_hdr) ? PD_HEADER_EXT_HDR : 0)) -+ -+#define PD_HEADER_LE(type, pwr, data, rev, id, cnt) \ -+ cpu_to_le16(PD_HEADER((type), (pwr), (data), (rev), (id), (cnt), (0))) -+ -+static inline unsigned int pd_header_cnt(u16 header) -+{ -+ return (header >> PD_HEADER_CNT_SHIFT) & PD_HEADER_CNT_MASK; -+} -+ -+static inline unsigned int pd_header_cnt_le(__le16 header) -+{ -+ return pd_header_cnt(le16_to_cpu(header)); -+} -+ -+static inline unsigned int pd_header_type(u16 header) -+{ -+ return (header >> PD_HEADER_TYPE_SHIFT) & PD_HEADER_TYPE_MASK; -+} -+ -+static inline unsigned int pd_header_type_le(__le16 header) -+{ -+ return pd_header_type(le16_to_cpu(header)); -+} -+ -+static inline unsigned int pd_header_msgid(u16 header) -+{ -+ return (header >> PD_HEADER_ID_SHIFT) & PD_HEADER_ID_MASK; -+} -+ -+static inline unsigned int pd_header_msgid_le(__le16 header) -+{ -+ return pd_header_msgid(le16_to_cpu(header)); -+} -+ -+static inline unsigned int pd_header_rev(u16 header) -+{ -+ return (header >> PD_HEADER_REV_SHIFT) & PD_HEADER_REV_MASK; -+} -+ -+static inline unsigned int pd_header_rev_le(__le16 header) -+{ -+ return pd_header_rev(le16_to_cpu(header)); -+} -+ -+#define PD_EXT_HDR_CHUNKED BIT(15) -+#define PD_EXT_HDR_CHUNK_NUM_SHIFT 11 -+#define PD_EXT_HDR_CHUNK_NUM_MASK 0xf -+#define PD_EXT_HDR_REQ_CHUNK BIT(10) -+#define PD_EXT_HDR_DATA_SIZE_SHIFT 0 -+#define PD_EXT_HDR_DATA_SIZE_MASK 0x1ff -+ -+#define PD_EXT_HDR(data_size, req_chunk, chunk_num, chunked) \ -+ ((((data_size) & PD_EXT_HDR_DATA_SIZE_MASK) << PD_EXT_HDR_DATA_SIZE_SHIFT) | \ -+ ((req_chunk) ? PD_EXT_HDR_REQ_CHUNK : 0) | \ -+ (((chunk_num) & PD_EXT_HDR_CHUNK_NUM_MASK) << PD_EXT_HDR_CHUNK_NUM_SHIFT) | \ -+ ((chunked) ? PD_EXT_HDR_CHUNKED : 0)) -+ -+#define PD_EXT_HDR_LE(data_size, req_chunk, chunk_num, chunked) \ -+ cpu_to_le16(PD_EXT_HDR((data_size), (req_chunk), (chunk_num), (chunked))) -+ -+static inline unsigned int pd_ext_header_chunk_num(u16 ext_header) -+{ -+ return (ext_header >> PD_EXT_HDR_CHUNK_NUM_SHIFT) & -+ PD_EXT_HDR_CHUNK_NUM_MASK; -+} -+ -+static inline unsigned int pd_ext_header_data_size(u16 ext_header) -+{ -+ return (ext_header >> PD_EXT_HDR_DATA_SIZE_SHIFT) & -+ PD_EXT_HDR_DATA_SIZE_MASK; -+} -+ -+static inline unsigned int pd_ext_header_data_size_le(__le16 ext_header) -+{ -+ return pd_ext_header_data_size(le16_to_cpu(ext_header)); -+} -+ -+#define PD_MAX_PAYLOAD 7 -+#define PD_EXT_MAX_CHUNK_DATA 26 -+ -+/* -+ * struct pd_chunked_ext_message_data - PD chunked extended message data as -+ * seen on wire -+ * @header: PD extended message header -+ * @data: PD extended message data -+ */ -+struct pd_chunked_ext_message_data { -+ __le16 header; -+ u8 data[PD_EXT_MAX_CHUNK_DATA]; -+} __packed; -+ -+/* -+ * struct pd_message - PD message as seen on wire -+ * @header: PD message header -+ * @payload: PD message payload -+ * @ext_msg: PD message chunked extended message data -+ */ -+struct pd_message { -+ __le16 header; -+ union { -+ __le32 payload[PD_MAX_PAYLOAD]; -+ struct pd_chunked_ext_message_data ext_msg; -+ }; -+} __packed; -+ -+/* PDO: Power Data Object */ -+#define PDO_MAX_OBJECTS 7 -+ -+enum pd_pdo_type { -+ PDO_TYPE_FIXED = 0, -+ PDO_TYPE_BATT = 1, -+ PDO_TYPE_VAR = 2, -+ PDO_TYPE_APDO = 3, -+}; -+ -+#define PDO_TYPE_SHIFT 30 -+#define PDO_TYPE_MASK 0x3 -+ -+#define PDO_TYPE(t) ((t) << PDO_TYPE_SHIFT) -+ -+#define PDO_VOLT_MASK 0x3ff -+#define PDO_CURR_MASK 0x3ff -+#define PDO_PWR_MASK 0x3ff -+ -+#define PDO_FIXED_DUAL_ROLE BIT(29) /* Power role swap supported */ -+#define PDO_FIXED_SUSPEND BIT(28) /* USB Suspend supported (Source) */ -+#define PDO_FIXED_HIGHER_CAP BIT(28) /* Requires more than vSafe5V (Sink) */ -+#define PDO_FIXED_EXTPOWER BIT(27) /* Externally powered */ -+#define PDO_FIXED_USB_COMM BIT(26) /* USB communications capable */ -+#define PDO_FIXED_DATA_SWAP BIT(25) /* Data role swap supported */ -+#define PDO_FIXED_UNCHUNK_EXT BIT(24) /* Unchunked Extended Message supported (Source) */ -+#define PDO_FIXED_FRS_CURR_MASK (BIT(24) | BIT(23)) /* FR_Swap Current (Sink) */ -+#define PDO_FIXED_FRS_CURR_SHIFT 23 -+#define PDO_FIXED_VOLT_SHIFT 10 /* 50mV units */ -+#define PDO_FIXED_CURR_SHIFT 0 /* 10mA units */ -+ -+#define PDO_FIXED_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_FIXED_VOLT_SHIFT) -+#define PDO_FIXED_CURR(ma) ((((ma) / 10) & PDO_CURR_MASK) << PDO_FIXED_CURR_SHIFT) -+ -+#define PDO_FIXED(mv, ma, flags) \ -+ (PDO_TYPE(PDO_TYPE_FIXED) | (flags) | \ -+ PDO_FIXED_VOLT(mv) | PDO_FIXED_CURR(ma)) -+ -+#define VSAFE5V 5000 /* mv units */ -+ -+#define PDO_BATT_MAX_VOLT_SHIFT 20 /* 50mV units */ -+#define PDO_BATT_MIN_VOLT_SHIFT 10 /* 50mV units */ -+#define PDO_BATT_MAX_PWR_SHIFT 0 /* 250mW units */ -+ -+#define PDO_BATT_MIN_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MIN_VOLT_SHIFT) -+#define PDO_BATT_MAX_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MAX_VOLT_SHIFT) -+#define PDO_BATT_MAX_POWER(mw) ((((mw) / 250) & PDO_PWR_MASK) << PDO_BATT_MAX_PWR_SHIFT) -+ -+#define PDO_BATT(min_mv, max_mv, max_mw) \ -+ (PDO_TYPE(PDO_TYPE_BATT) | PDO_BATT_MIN_VOLT(min_mv) | \ -+ PDO_BATT_MAX_VOLT(max_mv) | PDO_BATT_MAX_POWER(max_mw)) -+ -+#define PDO_VAR_MAX_VOLT_SHIFT 20 /* 50mV units */ -+#define PDO_VAR_MIN_VOLT_SHIFT 10 /* 50mV units */ -+#define PDO_VAR_MAX_CURR_SHIFT 0 /* 10mA units */ -+ -+#define PDO_VAR_MIN_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MIN_VOLT_SHIFT) -+#define PDO_VAR_MAX_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MAX_VOLT_SHIFT) -+#define PDO_VAR_MAX_CURR(ma) ((((ma) / 10) & PDO_CURR_MASK) << PDO_VAR_MAX_CURR_SHIFT) -+ -+#define PDO_VAR(min_mv, max_mv, max_ma) \ -+ (PDO_TYPE(PDO_TYPE_VAR) | PDO_VAR_MIN_VOLT(min_mv) | \ -+ PDO_VAR_MAX_VOLT(max_mv) | PDO_VAR_MAX_CURR(max_ma)) -+ -+enum pd_apdo_type { -+ APDO_TYPE_PPS = 0, -+}; -+ -+#define PDO_APDO_TYPE_SHIFT 28 /* Only valid value currently is 0x0 - PPS */ -+#define PDO_APDO_TYPE_MASK 0x3 -+ -+#define PDO_APDO_TYPE(t) ((t) << PDO_APDO_TYPE_SHIFT) -+ -+#define PDO_PPS_APDO_MAX_VOLT_SHIFT 17 /* 100mV units */ -+#define PDO_PPS_APDO_MIN_VOLT_SHIFT 8 /* 100mV units */ -+#define PDO_PPS_APDO_MAX_CURR_SHIFT 0 /* 50mA units */ -+ -+#define PDO_PPS_APDO_VOLT_MASK 0xff -+#define PDO_PPS_APDO_CURR_MASK 0x7f -+ -+#define PDO_PPS_APDO_MIN_VOLT(mv) \ -+ ((((mv) / 100) & PDO_PPS_APDO_VOLT_MASK) << PDO_PPS_APDO_MIN_VOLT_SHIFT) -+#define PDO_PPS_APDO_MAX_VOLT(mv) \ -+ ((((mv) / 100) & PDO_PPS_APDO_VOLT_MASK) << PDO_PPS_APDO_MAX_VOLT_SHIFT) -+#define PDO_PPS_APDO_MAX_CURR(ma) \ -+ ((((ma) / 50) & PDO_PPS_APDO_CURR_MASK) << PDO_PPS_APDO_MAX_CURR_SHIFT) -+ -+#define PDO_PPS_APDO(min_mv, max_mv, max_ma) \ -+ (PDO_TYPE(PDO_TYPE_APDO) | PDO_APDO_TYPE(APDO_TYPE_PPS) | \ -+ PDO_PPS_APDO_MIN_VOLT(min_mv) | PDO_PPS_APDO_MAX_VOLT(max_mv) | \ -+ PDO_PPS_APDO_MAX_CURR(max_ma)) -+ -+static inline enum pd_pdo_type pdo_type(u32 pdo) -+{ -+ return (pdo >> PDO_TYPE_SHIFT) & PDO_TYPE_MASK; -+} -+ -+static inline unsigned int pdo_fixed_voltage(u32 pdo) -+{ -+ return ((pdo >> PDO_FIXED_VOLT_SHIFT) & PDO_VOLT_MASK) * 50; -+} -+ -+static inline unsigned int pdo_min_voltage(u32 pdo) -+{ -+ return ((pdo >> PDO_VAR_MIN_VOLT_SHIFT) & PDO_VOLT_MASK) * 50; -+} -+ -+static inline unsigned int pdo_max_voltage(u32 pdo) -+{ -+ return ((pdo >> PDO_VAR_MAX_VOLT_SHIFT) & PDO_VOLT_MASK) * 50; -+} -+ -+static inline unsigned int pdo_max_current(u32 pdo) -+{ -+ return ((pdo >> PDO_VAR_MAX_CURR_SHIFT) & PDO_CURR_MASK) * 10; -+} -+ -+static inline unsigned int pdo_max_power(u32 pdo) -+{ -+ return ((pdo >> PDO_BATT_MAX_PWR_SHIFT) & PDO_PWR_MASK) * 250; -+} -+ -+static inline enum pd_apdo_type pdo_apdo_type(u32 pdo) -+{ -+ return (pdo >> PDO_APDO_TYPE_SHIFT) & PDO_APDO_TYPE_MASK; -+} -+ -+static inline unsigned int pdo_pps_apdo_min_voltage(u32 pdo) -+{ -+ return ((pdo >> PDO_PPS_APDO_MIN_VOLT_SHIFT) & -+ PDO_PPS_APDO_VOLT_MASK) * 100; -+} -+ -+static inline unsigned int pdo_pps_apdo_max_voltage(u32 pdo) -+{ -+ return ((pdo >> PDO_PPS_APDO_MAX_VOLT_SHIFT) & -+ PDO_PPS_APDO_VOLT_MASK) * 100; -+} -+ -+static inline unsigned int pdo_pps_apdo_max_current(u32 pdo) -+{ -+ return ((pdo >> PDO_PPS_APDO_MAX_CURR_SHIFT) & -+ PDO_PPS_APDO_CURR_MASK) * 50; -+} -+ -+/* RDO: Request Data Object */ -+#define RDO_OBJ_POS_SHIFT 28 -+#define RDO_OBJ_POS_MASK 0x7 -+#define RDO_GIVE_BACK BIT(27) /* Supports reduced operating current */ -+#define RDO_CAP_MISMATCH BIT(26) /* Not satisfied by source caps */ -+#define RDO_USB_COMM BIT(25) /* USB communications capable */ -+#define RDO_NO_SUSPEND BIT(24) /* USB Suspend not supported */ -+ -+#define RDO_PWR_MASK 0x3ff -+#define RDO_CURR_MASK 0x3ff -+ -+#define RDO_FIXED_OP_CURR_SHIFT 10 -+#define RDO_FIXED_MAX_CURR_SHIFT 0 -+ -+#define RDO_OBJ(idx) (((idx) & RDO_OBJ_POS_MASK) << RDO_OBJ_POS_SHIFT) -+ -+#define PDO_FIXED_OP_CURR(ma) ((((ma) / 10) & RDO_CURR_MASK) << RDO_FIXED_OP_CURR_SHIFT) -+#define PDO_FIXED_MAX_CURR(ma) ((((ma) / 10) & RDO_CURR_MASK) << RDO_FIXED_MAX_CURR_SHIFT) -+ -+#define RDO_FIXED(idx, op_ma, max_ma, flags) \ -+ (RDO_OBJ(idx) | (flags) | \ -+ PDO_FIXED_OP_CURR(op_ma) | PDO_FIXED_MAX_CURR(max_ma)) -+ -+#define RDO_BATT_OP_PWR_SHIFT 10 /* 250mW units */ -+#define RDO_BATT_MAX_PWR_SHIFT 0 /* 250mW units */ -+ -+#define RDO_BATT_OP_PWR(mw) ((((mw) / 250) & RDO_PWR_MASK) << RDO_BATT_OP_PWR_SHIFT) -+#define RDO_BATT_MAX_PWR(mw) ((((mw) / 250) & RDO_PWR_MASK) << RDO_BATT_MAX_PWR_SHIFT) -+ -+#define RDO_BATT(idx, op_mw, max_mw, flags) \ -+ (RDO_OBJ(idx) | (flags) | \ -+ RDO_BATT_OP_PWR(op_mw) | RDO_BATT_MAX_PWR(max_mw)) -+ -+#define RDO_PROG_VOLT_MASK 0x7ff -+#define RDO_PROG_CURR_MASK 0x7f -+ -+#define RDO_PROG_VOLT_SHIFT 9 -+#define RDO_PROG_CURR_SHIFT 0 -+ -+#define RDO_PROG_VOLT_MV_STEP 20 -+#define RDO_PROG_CURR_MA_STEP 50 -+ -+#define PDO_PROG_OUT_VOLT(mv) \ -+ ((((mv) / RDO_PROG_VOLT_MV_STEP) & RDO_PROG_VOLT_MASK) << RDO_PROG_VOLT_SHIFT) -+#define PDO_PROG_OP_CURR(ma) \ -+ ((((ma) / RDO_PROG_CURR_MA_STEP) & RDO_PROG_CURR_MASK) << RDO_PROG_CURR_SHIFT) -+ -+#define RDO_PROG(idx, out_mv, op_ma, flags) \ -+ (RDO_OBJ(idx) | (flags) | \ -+ PDO_PROG_OUT_VOLT(out_mv) | PDO_PROG_OP_CURR(op_ma)) -+ -+static inline unsigned int rdo_index(u32 rdo) -+{ -+ return (rdo >> RDO_OBJ_POS_SHIFT) & RDO_OBJ_POS_MASK; -+} -+ -+static inline unsigned int rdo_op_current(u32 rdo) -+{ -+ return ((rdo >> RDO_FIXED_OP_CURR_SHIFT) & RDO_CURR_MASK) * 10; -+} -+ -+static inline unsigned int rdo_max_current(u32 rdo) -+{ -+ return ((rdo >> RDO_FIXED_MAX_CURR_SHIFT) & -+ RDO_CURR_MASK) * 10; -+} -+ -+static inline unsigned int rdo_op_power(u32 rdo) -+{ -+ return ((rdo >> RDO_BATT_OP_PWR_SHIFT) & RDO_PWR_MASK) * 250; -+} -+ -+static inline unsigned int rdo_max_power(u32 rdo) -+{ -+ return ((rdo >> RDO_BATT_MAX_PWR_SHIFT) & RDO_PWR_MASK) * 250; -+} -+ -+/* Enter_USB Data Object */ -+#define EUDO_USB_MODE_MASK GENMASK(30, 28) -+#define EUDO_USB_MODE_SHIFT 28 -+#define EUDO_USB_MODE_USB2 0 -+#define EUDO_USB_MODE_USB3 1 -+#define EUDO_USB_MODE_USB4 2 -+#define EUDO_USB4_DRD BIT(26) -+#define EUDO_USB3_DRD BIT(25) -+#define EUDO_CABLE_SPEED_MASK GENMASK(23, 21) -+#define EUDO_CABLE_SPEED_SHIFT 21 -+#define EUDO_CABLE_SPEED_USB2 0 -+#define EUDO_CABLE_SPEED_USB3_GEN1 1 -+#define EUDO_CABLE_SPEED_USB4_GEN2 2 -+#define EUDO_CABLE_SPEED_USB4_GEN3 3 -+#define EUDO_CABLE_TYPE_MASK GENMASK(20, 19) -+#define EUDO_CABLE_TYPE_SHIFT 19 -+#define EUDO_CABLE_TYPE_PASSIVE 0 -+#define EUDO_CABLE_TYPE_RE_TIMER 1 -+#define EUDO_CABLE_TYPE_RE_DRIVER 2 -+#define EUDO_CABLE_TYPE_OPTICAL 3 -+#define EUDO_CABLE_CURRENT_MASK GENMASK(18, 17) -+#define EUDO_CABLE_CURRENT_SHIFT 17 -+#define EUDO_CABLE_CURRENT_NOTSUPP 0 -+#define EUDO_CABLE_CURRENT_3A 2 -+#define EUDO_CABLE_CURRENT_5A 3 -+#define EUDO_PCIE_SUPPORT BIT(16) -+#define EUDO_DP_SUPPORT BIT(15) -+#define EUDO_TBT_SUPPORT BIT(14) -+#define EUDO_HOST_PRESENT BIT(13) -+ -+/* USB PD timers and counters */ -+#define PD_T_NO_RESPONSE 5000 /* 4.5 - 5.5 seconds */ -+#define PD_T_DB_DETECT 10000 /* 10 - 15 seconds */ -+#define PD_T_SEND_SOURCE_CAP 150 /* 100 - 200 ms */ -+#define PD_T_SENDER_RESPONSE 60 /* 24 - 30 ms, relaxed */ -+#define PD_T_RECEIVER_RESPONSE 15 /* 15ms max */ -+#define PD_T_SOURCE_ACTIVITY 45 -+#define PD_T_SINK_ACTIVITY 135 -+#define PD_T_SINK_WAIT_CAP 310 /* 310 - 620 ms */ -+#define PD_T_PS_TRANSITION 500 -+#define PD_T_SRC_TRANSITION 35 -+#define PD_T_DRP_SNK 40 -+#define PD_T_DRP_SRC 30 -+#define PD_T_PS_SOURCE_OFF 920 -+#define PD_T_PS_SOURCE_ON 480 -+#define PD_T_PS_SOURCE_ON_PRS 450 /* 390 - 480ms */ -+#define PD_T_PS_HARD_RESET 30 -+#define PD_T_SRC_RECOVER 760 -+#define PD_T_SRC_RECOVER_MAX 1000 -+#define PD_T_SRC_TURN_ON 275 -+#define PD_T_SAFE_0V 650 -+#define PD_T_VCONN_SOURCE_ON 100 -+#define PD_T_SINK_REQUEST 100 /* 100 ms minimum */ -+#define PD_T_ERROR_RECOVERY 100 /* minimum 25 is insufficient */ -+#define PD_T_SRCSWAPSTDBY 625 /* Maximum of 650ms */ -+#define PD_T_NEWSRC 250 /* Maximum of 275ms */ -+#define PD_T_SWAP_SRC_START 20 /* Minimum of 20ms */ -+#define PD_T_BIST_CONT_MODE 50 /* 30 - 60 ms */ -+#define PD_T_SINK_TX 16 /* 16 - 20 ms */ -+#define PD_T_CHUNK_NOT_SUPP 42 /* 40 - 50 ms */ -+ -+#define PD_T_DRP_TRY 100 /* 75 - 150 ms */ -+#define PD_T_DRP_TRYWAIT 600 /* 400 - 800 ms */ -+ -+#define PD_T_CC_DEBOUNCE 200 /* 100 - 200 ms */ -+#define PD_T_PD_DEBOUNCE 20 /* 10 - 20 ms */ -+#define PD_T_TRY_CC_DEBOUNCE 15 /* 10 - 20 ms */ -+ -+#define PD_N_CAPS_COUNT (PD_T_NO_RESPONSE / PD_T_SEND_SOURCE_CAP) -+#define PD_N_HARD_RESET_COUNT 1 -+ -+#define PD_P_SNK_STDBY_MW 2500 /* 2500 mW */ -+ -+/* Time to wait for TCPC to complete transmit */ -+#define PD_T_TCPC_TX_TIMEOUT 100 /* in ms */ -+ -+#endif /* __LINUX_USB_PD_H */ -diff --git a/include/usb/tcpm.h b/include/usb/tcpm.h -new file mode 100644 -index 000000000000..4574a5175ddb ---- /dev/null -+++ b/include/usb/tcpm.h -@@ -0,0 +1,99 @@ -+/* SPDX-License-Identifier: GPL-2.0-or-later */ -+/* -+ * Copyright 2015-2017 Google, Inc -+ * Copyright 2024 Collabora -+ */ -+ -+#ifndef __LINUX_USB_TCPM_H -+#define __LINUX_USB_TCPM_H -+ -+#include -+#include -+#include "pd.h" -+ -+enum typec_orientation { -+ TYPEC_ORIENTATION_NONE, -+ TYPEC_ORIENTATION_NORMAL, -+ TYPEC_ORIENTATION_REVERSE, -+}; -+ -+enum typec_cc_status { -+ TYPEC_CC_OPEN, -+ TYPEC_CC_RA, -+ TYPEC_CC_RD, -+ TYPEC_CC_RP_DEF, -+ TYPEC_CC_RP_1_5, -+ TYPEC_CC_RP_3_0, -+}; -+ -+enum typec_cc_polarity { -+ TYPEC_POLARITY_CC1, -+ TYPEC_POLARITY_CC2, -+}; -+ -+enum tcpm_transmit_status { -+ TCPC_TX_SUCCESS = 0, -+ TCPC_TX_DISCARDED = 1, -+ TCPC_TX_FAILED = 2, -+}; -+ -+enum tcpm_transmit_type { -+ TCPC_TX_SOP = 0, -+ TCPC_TX_SOP_PRIME = 1, -+ TCPC_TX_SOP_PRIME_PRIME = 2, -+ TCPC_TX_SOP_DEBUG_PRIME = 3, -+ TCPC_TX_SOP_DEBUG_PRIME_PRIME = 4, -+ TCPC_TX_HARD_RESET = 5, -+ TCPC_TX_CABLE_RESET = 6, -+ TCPC_TX_BIST_MODE_2 = 7 -+}; -+ -+struct dm_tcpm_ops { -+ int (*get_connector_node)(struct udevice *dev, ofnode *connector_node); -+ int (*init)(struct udevice *dev); -+ int (*get_vbus)(struct udevice *dev); -+ int (*set_cc)(struct udevice *dev, enum typec_cc_status cc); -+ int (*get_cc)(struct udevice *dev, enum typec_cc_status *cc1, -+ enum typec_cc_status *cc2); -+ int (*set_polarity)(struct udevice *dev, -+ enum typec_cc_polarity polarity); -+ int (*set_vconn)(struct udevice *dev, bool on); -+ int (*set_vbus)(struct udevice *dev, bool on, bool charge); -+ int (*set_pd_rx)(struct udevice *dev, bool on); -+ int (*set_roles)(struct udevice *dev, bool attached, -+ enum typec_role role, enum typec_data_role data); -+ int (*start_toggling)(struct udevice *dev, -+ enum typec_port_type port_type, -+ enum typec_cc_status cc); -+ int (*pd_transmit)(struct udevice *dev, enum tcpm_transmit_type type, -+ const struct pd_message *msg, unsigned int negotiated_rev); -+ void (*poll_event)(struct udevice *dev); -+ int (*enter_low_power_mode)(struct udevice *dev, bool attached, bool pd_capable); -+}; -+ -+/* API for drivers */ -+void tcpm_vbus_change(struct udevice *dev); -+void tcpm_cc_change(struct udevice *dev); -+void tcpm_pd_receive(struct udevice *dev, const struct pd_message *msg); -+void tcpm_pd_transmit_complete(struct udevice *dev, -+ enum tcpm_transmit_status status); -+void tcpm_pd_hard_reset(struct udevice *dev); -+ -+/* API for boards */ -+extern const char * const typec_pd_rev_name[]; -+extern const char * const typec_orientation_name[]; -+extern const char * const typec_role_name[]; -+extern const char * const typec_data_role_name[]; -+extern const char * const typec_cc_status_name[]; -+ -+int tcpm_get(const char *name, struct udevice **devp); -+int tcpm_get_pd_rev(struct udevice *dev); -+int tcpm_get_current(struct udevice *dev); -+int tcpm_get_voltage(struct udevice *dev); -+enum typec_orientation tcpm_get_orientation(struct udevice *dev); -+enum typec_role tcpm_get_pwr_role(struct udevice *dev); -+enum typec_data_role tcpm_get_data_role(struct udevice *dev); -+bool tcpm_is_connected(struct udevice *dev); -+const char *tcpm_get_state(struct udevice *dev); -+ -+#endif /* __LINUX_USB_TCPM_H */ - -From patchwork Thu Sep 5 15:08:38 2024 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Sebastian Reichel -X-Patchwork-Id: 1981316 -X-Patchwork-Delegate: ykai007@gmail.com -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - dkim=pass (2048-bit key; - unprotected) header.d=collabora.com header.i=@collabora.com - header.a=rsa-sha256 header.s=mail header.b=d3aozlfW; - dkim-atps=neutral -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de - [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1)) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4X030913Sdz1yXY - for ; Fri, 6 Sep 2024 01:18:17 +1000 (AEST) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id 4C12888CC2; - Thu, 5 Sep 2024 17:17:19 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=collabora.com -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de -Authentication-Results: phobos.denx.de; - dkim=pass (2048-bit key; - unprotected) header.d=collabora.com header.i=@collabora.com - header.b="d3aozlfW"; - dkim-atps=neutral -Received: by phobos.denx.de (Postfix, from userid 109) - id F400788CC2; Thu, 5 Sep 2024 17:17:17 +0200 (CEST) -X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de -X-Spam-Level: -X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, - DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, - T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no - version=3.4.2 -Received: from bali.collaboradmins.com (bali.collaboradmins.com - [IPv6:2a01:4f8:201:9162::2]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) - (No client certificate requested) - by phobos.denx.de (Postfix) with ESMTPS id 4C6CB88CB8 - for ; Thu, 5 Sep 2024 17:17:13 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=collabora.com -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=sebastian.reichel@collabora.com -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; - s=mail; t=1725549433; - bh=fuHT4MalSjyQfKUjWdVq0nVnduu/AbWGeUChYJaCIeY=; - h=From:To:Cc:Subject:Date:In-Reply-To:References:From; - b=d3aozlfWwAG+KQBk/EM6vpvcIoIEEksahdSc+LhMi76PX8NNsu3zOQomQcug5dlmD - kqV/SDj3yszJBox46C1h2pfHNNLn7CD/u95G6BwH0A4cv33ZsWN3fEhJQKbkS9sUOB - hFzSWoKr7kCx/KDvBcjoS9Q5063JFZ6CJ1MF7XGgxT3H7WOMEybvC26Mp+j1/c1HNn - vWSjbh5lkW/dpx1unm3PUgMYNy2yrfANnaSFG7vKNtHyq0xHhs2qgOb4fATE80nKVY - RAY1F8b1JTYImazFA3NryRuA50InmvmHjpu9pyx8OQjy05tbnuScyau9SuyjO7usip - Q4lcqzzIB8AlQ== -Received: from jupiter.universe (dyndsl-091-248-189-231.ewe-ip-backbone.de - [91.248.189.231]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest - SHA256) - (No client certificate requested) (Authenticated sender: sre) - by bali.collaboradmins.com (Postfix) with ESMTPSA id ED3E617E0FD9; - Thu, 5 Sep 2024 17:17:12 +0200 (CEST) -Received: by jupiter.universe (Postfix, from userid 1000) - id A19EE4800F4; Thu, 05 Sep 2024 17:17:07 +0200 (CEST) -From: Sebastian Reichel -To: Marek Vasut , u-boot@lists.denx.de, - Jonas Karlman , Soeren Moch -Cc: Eugen Hristev , - Tim Harvey , Kever Yang , - Philipp Tomsich , Simon Glass , - Sebastian Reichel -Subject: [PATCH v6 2/6] usb: tcpm: fusb302: add driver -Date: Thu, 5 Sep 2024 17:08:38 +0200 -Message-ID: <20240905151707.59101-3-sebastian.reichel@collabora.com> -X-Mailer: git-send-email 2.45.2 -In-Reply-To: <20240905151707.59101-1-sebastian.reichel@collabora.com> -References: <20240905151707.59101-1-sebastian.reichel@collabora.com> -MIME-Version: 1.0 -X-BeenThere: u-boot@lists.denx.de -X-Mailman-Version: 2.1.39 -Precedence: list -List-Id: U-Boot discussion -List-Unsubscribe: , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: , - -Errors-To: u-boot-bounces@lists.denx.de -Sender: "U-Boot" -X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de -X-Virus-Status: Clean - -Now that the TCPM framework exists we can introduce fusb302 -driver using it. This chip is a very common USB-C controller -chip with PD support, which can be found in the Radxa Rock 5B -among many other boards. Apart from Power Delivery, it also -handles detection of the cable orientation. That can be used -to control a mux for connecting the right USB3 lane pair to -the USB3 controller. - -The driver is originally from the Linux kernel, but has been -adapted to the requirements of U-Boot and its TCPM framework. - -Co-developed-by: Wang Jie -Signed-off-by: Wang Jie -Tested-by: Soeren Moch -Signed-off-by: Sebastian Reichel ---- - drivers/usb/tcpm/Kconfig | 8 + - drivers/usb/tcpm/Makefile | 1 + - drivers/usb/tcpm/fusb302.c | 1323 ++++++++++++++++++++++++++++++++ - drivers/usb/tcpm/fusb302_reg.h | 177 +++++ - 4 files changed, 1509 insertions(+) - create mode 100644 drivers/usb/tcpm/fusb302.c - create mode 100644 drivers/usb/tcpm/fusb302_reg.h - -diff --git a/drivers/usb/tcpm/Kconfig b/drivers/usb/tcpm/Kconfig -index 55bf8e202b90..9be4b496e82f 100644 ---- a/drivers/usb/tcpm/Kconfig -+++ b/drivers/usb/tcpm/Kconfig -@@ -6,3 +6,11 @@ config TYPEC_TCPM - help - The Type-C Port Controller Manager provides a USB PD and USB Type-C - state machine for use with Type-C Port Controllers. -+ -+config TYPEC_FUSB302 -+ tristate "Fairchild FUSB302 Type-C chip driver" -+ depends on DM && DM_I2C && TYPEC_TCPM -+ help -+ The Fairchild FUSB302 Type-C chip driver that works with -+ Type-C Port Controller Manager to provide USB PD and USB -+ Type-C functionalities. -diff --git a/drivers/usb/tcpm/Makefile b/drivers/usb/tcpm/Makefile -index a0f76436f3fd..668d33155bf1 100644 ---- a/drivers/usb/tcpm/Makefile -+++ b/drivers/usb/tcpm/Makefile -@@ -1,3 +1,4 @@ - # SPDX-License-Identifier: GPL-2.0 - - obj-$(CONFIG_TYPEC_TCPM) += tcpm.o tcpm-uclass.o -+obj-$(CONFIG_TYPEC_FUSB302) += fusb302.o -diff --git a/drivers/usb/tcpm/fusb302.c b/drivers/usb/tcpm/fusb302.c -new file mode 100644 -index 000000000000..fe93ff3d3397 ---- /dev/null -+++ b/drivers/usb/tcpm/fusb302.c -@@ -0,0 +1,1323 @@ -+// SPDX-License-Identifier: GPL-2.0+ -+/* -+ * Copyright 2016-2017 Google, Inc -+ * -+ * Fairchild FUSB302 Type-C Chip Driver -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include "fusb302_reg.h" -+ -+#define FUSB302_MAX_MSG_LEN 0x1F -+ -+enum toggling_mode { -+ TOGGLING_MODE_OFF, -+ TOGGLING_MODE_DRP, -+ TOGGLING_MODE_SNK, -+ TOGGLING_MODE_SRC, -+}; -+ -+enum src_current_status { -+ SRC_CURRENT_DEFAULT, -+ SRC_CURRENT_MEDIUM, -+ SRC_CURRENT_HIGH, -+}; -+ -+static const u8 ra_mda_value[] = { -+ [SRC_CURRENT_DEFAULT] = 4, /* 210mV */ -+ [SRC_CURRENT_MEDIUM] = 9, /* 420mV */ -+ [SRC_CURRENT_HIGH] = 18, /* 798mV */ -+}; -+ -+static const u8 rd_mda_value[] = { -+ [SRC_CURRENT_DEFAULT] = 38, /* 1638mV */ -+ [SRC_CURRENT_MEDIUM] = 38, /* 1638mV */ -+ [SRC_CURRENT_HIGH] = 61, /* 2604mV */ -+}; -+ -+struct fusb302_chip { -+ enum toggling_mode toggling_mode; -+ enum src_current_status src_current_status; -+ bool intr_togdone; -+ bool intr_bc_lvl; -+ bool intr_comp_chng; -+ -+ /* port status */ -+ bool vconn_on; -+ bool vbus_present; -+ enum typec_cc_polarity cc_polarity; -+ enum typec_cc_status cc1; -+ enum typec_cc_status cc2; -+}; -+ -+static int fusb302_i2c_write(struct udevice *dev, u8 address, u8 data) -+{ -+ int ret; -+ -+ ret = dm_i2c_write(dev, address, &data, 1); -+ if (ret) -+ dev_err(dev, "cannot write 0x%02x to 0x%02x, ret=%d\n", -+ data, address, ret); -+ -+ return ret; -+} -+ -+static int fusb302_i2c_block_write(struct udevice *dev, u8 address, -+ u8 length, const u8 *data) -+{ -+ int ret; -+ -+ if (!length) -+ return 0; -+ -+ ret = dm_i2c_write(dev, address, data, length); -+ if (ret) -+ dev_err(dev, "cannot block write 0x%02x, len=%d, ret=%d\n", -+ address, length, ret); -+ -+ return ret; -+} -+ -+static int fusb302_i2c_read(struct udevice *dev, u8 address, u8 *data) -+{ -+ int ret, retries; -+ -+ for (retries = 0; retries < 3; retries++) { -+ ret = dm_i2c_read(dev, address, data, 1); -+ if (ret == 0) -+ return ret; -+ dev_err(dev, "cannot read %02x, ret=%d\n", address, ret); -+ } -+ -+ return ret; -+} -+ -+static int fusb302_i2c_block_read(struct udevice *dev, u8 address, -+ u8 length, u8 *data) -+{ -+ int ret; -+ -+ if (!length) -+ return 0; -+ -+ ret = dm_i2c_read(dev, address, data, length); -+ if (ret) -+ dev_err(dev, "cannot block read 0x%02x, len=%d, ret=%d\n", -+ address, length, ret); -+ return ret; -+} -+ -+static int fusb302_i2c_mask_write(struct udevice *dev, u8 address, -+ u8 mask, u8 value) -+{ -+ int ret; -+ u8 data; -+ -+ ret = fusb302_i2c_read(dev, address, &data); -+ if (ret) -+ return ret; -+ data &= ~mask; -+ data |= value; -+ ret = fusb302_i2c_write(dev, address, data); -+ if (ret) -+ return ret; -+ -+ return ret; -+} -+ -+static int fusb302_i2c_set_bits(struct udevice *dev, u8 address, u8 set_bits) -+{ -+ return fusb302_i2c_mask_write(dev, address, 0x00, set_bits); -+} -+ -+static int fusb302_i2c_clear_bits(struct udevice *dev, u8 address, u8 clear_bits) -+{ -+ return fusb302_i2c_mask_write(dev, address, clear_bits, 0x00); -+} -+ -+static int fusb302_sw_reset(struct udevice *dev) -+{ -+ int ret = fusb302_i2c_write(dev, FUSB_REG_RESET, FUSB_REG_RESET_SW_RESET); -+ -+ if (ret) -+ dev_err(dev, "cannot sw reset the fusb302: %d\n", ret); -+ -+ return ret; -+} -+ -+static int fusb302_enable_tx_auto_retries(struct udevice *dev, u8 retry_count) -+{ -+ int ret; -+ -+ ret = fusb302_i2c_set_bits(dev, FUSB_REG_CONTROL3, retry_count | -+ FUSB_REG_CONTROL3_AUTO_RETRY); -+ -+ return ret; -+} -+ -+/* -+ * mask all interrupt on the chip -+ */ -+static int fusb302_mask_interrupt(struct udevice *dev) -+{ -+ int ret; -+ -+ ret = fusb302_i2c_write(dev, FUSB_REG_MASK, 0xFF); -+ if (ret) -+ return ret; -+ ret = fusb302_i2c_write(dev, FUSB_REG_MASKA, 0xFF); -+ if (ret) -+ return ret; -+ ret = fusb302_i2c_write(dev, FUSB_REG_MASKB, 0xFF); -+ if (ret) -+ return ret; -+ ret = fusb302_i2c_set_bits(dev, FUSB_REG_CONTROL0, -+ FUSB_REG_CONTROL0_INT_MASK); -+ return ret; -+} -+ -+/* -+ * initialize interrupt on the chip -+ * - unmasked interrupt: VBUS_OK -+ */ -+static int fusb302_init_interrupt(struct udevice *dev) -+{ -+ int ret; -+ -+ ret = fusb302_i2c_write(dev, FUSB_REG_MASK, -+ 0xFF & ~FUSB_REG_MASK_VBUSOK); -+ if (ret) -+ return ret; -+ ret = fusb302_i2c_write(dev, FUSB_REG_MASKA, 0xFF); -+ if (ret) -+ return ret; -+ ret = fusb302_i2c_write(dev, FUSB_REG_MASKB, 0xFF); -+ if (ret) -+ return ret; -+ ret = fusb302_i2c_clear_bits(dev, FUSB_REG_CONTROL0, -+ FUSB_REG_CONTROL0_INT_MASK); -+ return ret; -+} -+ -+static int fusb302_set_power_mode(struct udevice *dev, u8 power_mode) -+{ -+ int ret; -+ -+ ret = fusb302_i2c_write(dev, FUSB_REG_POWER, power_mode); -+ -+ return ret; -+} -+ -+static int fusb302_init(struct udevice *dev) -+{ -+ struct fusb302_chip *chip = dev_get_priv(dev); -+ int ret; -+ u8 data; -+ -+ ret = fusb302_sw_reset(dev); -+ if (ret) -+ return ret; -+ ret = fusb302_enable_tx_auto_retries(dev, FUSB_REG_CONTROL3_N_RETRIES_3); -+ if (ret) -+ return ret; -+ ret = fusb302_init_interrupt(dev); -+ if (ret) -+ return ret; -+ ret = fusb302_set_power_mode(dev, FUSB_REG_POWER_PWR_ALL); -+ if (ret) -+ return ret; -+ ret = fusb302_i2c_read(dev, FUSB_REG_STATUS0, &data); -+ if (ret) -+ return ret; -+ chip->vbus_present = !!(data & FUSB_REG_STATUS0_VBUSOK); -+ ret = fusb302_i2c_read(dev, FUSB_REG_DEVICE_ID, &data); -+ if (ret) -+ return ret; -+ dev_info(dev, "fusb302 device ID: 0x%02x\n", data); -+ -+ return ret; -+} -+ -+static int fusb302_get_vbus(struct udevice *dev) -+{ -+ struct fusb302_chip *chip = dev_get_priv(dev); -+ -+ return chip->vbus_present ? 1 : 0; -+} -+ -+static int fusb302_set_src_current(struct udevice *dev, -+ enum src_current_status status) -+{ -+ struct fusb302_chip *chip = dev_get_priv(dev); -+ int ret; -+ -+ chip->src_current_status = status; -+ switch (status) { -+ case SRC_CURRENT_DEFAULT: -+ ret = fusb302_i2c_mask_write(dev, FUSB_REG_CONTROL0, -+ FUSB_REG_CONTROL0_HOST_CUR_MASK, -+ FUSB_REG_CONTROL0_HOST_CUR_DEF); -+ break; -+ case SRC_CURRENT_MEDIUM: -+ ret = fusb302_i2c_mask_write(dev, FUSB_REG_CONTROL0, -+ FUSB_REG_CONTROL0_HOST_CUR_MASK, -+ FUSB_REG_CONTROL0_HOST_CUR_MED); -+ break; -+ case SRC_CURRENT_HIGH: -+ ret = fusb302_i2c_mask_write(dev, FUSB_REG_CONTROL0, -+ FUSB_REG_CONTROL0_HOST_CUR_MASK, -+ FUSB_REG_CONTROL0_HOST_CUR_HIGH); -+ break; -+ default: -+ ret = -EINVAL; -+ break; -+ } -+ -+ return ret; -+} -+ -+static int fusb302_set_toggling(struct udevice *dev, -+ enum toggling_mode mode) -+{ -+ struct fusb302_chip *chip = dev_get_priv(dev); -+ int ret; -+ -+ /* first disable toggling */ -+ ret = fusb302_i2c_clear_bits(dev, FUSB_REG_CONTROL2, -+ FUSB_REG_CONTROL2_TOGGLE); -+ if (ret) -+ return ret; -+ /* mask interrupts for SRC or SNK */ -+ ret = fusb302_i2c_set_bits(dev, FUSB_REG_MASK, -+ FUSB_REG_MASK_BC_LVL | -+ FUSB_REG_MASK_COMP_CHNG); -+ if (ret) -+ return ret; -+ chip->intr_bc_lvl = false; -+ chip->intr_comp_chng = false; -+ /* configure toggling mode: none/snk/src/drp */ -+ switch (mode) { -+ case TOGGLING_MODE_OFF: -+ ret = fusb302_i2c_mask_write(dev, FUSB_REG_CONTROL2, -+ FUSB_REG_CONTROL2_MODE_MASK, -+ FUSB_REG_CONTROL2_MODE_NONE); -+ break; -+ case TOGGLING_MODE_SNK: -+ ret = fusb302_i2c_mask_write(dev, FUSB_REG_CONTROL2, -+ FUSB_REG_CONTROL2_MODE_MASK, -+ FUSB_REG_CONTROL2_MODE_UFP); -+ break; -+ case TOGGLING_MODE_SRC: -+ ret = fusb302_i2c_mask_write(dev, FUSB_REG_CONTROL2, -+ FUSB_REG_CONTROL2_MODE_MASK, -+ FUSB_REG_CONTROL2_MODE_DFP); -+ break; -+ case TOGGLING_MODE_DRP: -+ ret = fusb302_i2c_mask_write(dev, FUSB_REG_CONTROL2, -+ FUSB_REG_CONTROL2_MODE_MASK, -+ FUSB_REG_CONTROL2_MODE_DRP); -+ break; -+ default: -+ break; -+ } -+ -+ if (ret) -+ return ret; -+ -+ if (mode == TOGGLING_MODE_OFF) { -+ /* mask TOGDONE interrupt */ -+ ret = fusb302_i2c_set_bits(dev, FUSB_REG_MASKA, -+ FUSB_REG_MASKA_TOGDONE); -+ if (ret) -+ return ret; -+ chip->intr_togdone = false; -+ } else { -+ /* Datasheet says vconn MUST be off when toggling */ -+ if (chip->vconn_on) -+ dev_warn(dev, "Vconn is on during toggle start\n"); -+ /* unmask TOGDONE interrupt */ -+ ret = fusb302_i2c_clear_bits(dev, FUSB_REG_MASKA, -+ FUSB_REG_MASKA_TOGDONE); -+ if (ret) -+ return ret; -+ chip->intr_togdone = true; -+ /* start toggling */ -+ ret = fusb302_i2c_set_bits(dev, FUSB_REG_CONTROL2, -+ FUSB_REG_CONTROL2_TOGGLE); -+ if (ret) -+ return ret; -+ /* during toggling, consider cc as Open */ -+ chip->cc1 = TYPEC_CC_OPEN; -+ chip->cc2 = TYPEC_CC_OPEN; -+ } -+ chip->toggling_mode = mode; -+ -+ return ret; -+} -+ -+static const enum src_current_status cc_src_current[] = { -+ [TYPEC_CC_OPEN] = SRC_CURRENT_DEFAULT, -+ [TYPEC_CC_RA] = SRC_CURRENT_DEFAULT, -+ [TYPEC_CC_RD] = SRC_CURRENT_DEFAULT, -+ [TYPEC_CC_RP_DEF] = SRC_CURRENT_DEFAULT, -+ [TYPEC_CC_RP_1_5] = SRC_CURRENT_MEDIUM, -+ [TYPEC_CC_RP_3_0] = SRC_CURRENT_HIGH, -+}; -+ -+static int fusb302_set_cc(struct udevice *dev, enum typec_cc_status cc) -+{ -+ struct fusb302_chip *chip = dev_get_priv(dev); -+ const u8 switches0_mask = FUSB_REG_SWITCHES0_CC1_PU_EN | -+ FUSB_REG_SWITCHES0_CC2_PU_EN | -+ FUSB_REG_SWITCHES0_CC1_PD_EN | -+ FUSB_REG_SWITCHES0_CC2_PD_EN; -+ u8 rd_mda, switches0_data = 0x00; -+ int ret; -+ -+ switch (cc) { -+ case TYPEC_CC_OPEN: -+ break; -+ case TYPEC_CC_RD: -+ switches0_data |= FUSB_REG_SWITCHES0_CC1_PD_EN | -+ FUSB_REG_SWITCHES0_CC2_PD_EN; -+ break; -+ case TYPEC_CC_RP_DEF: -+ case TYPEC_CC_RP_1_5: -+ case TYPEC_CC_RP_3_0: -+ switches0_data |= (chip->cc_polarity == TYPEC_POLARITY_CC1) ? -+ FUSB_REG_SWITCHES0_CC1_PU_EN : -+ FUSB_REG_SWITCHES0_CC2_PU_EN; -+ break; -+ default: -+ dev_err(dev, "unsupported CC value: %s\n", -+ typec_cc_status_name[cc]); -+ ret = -EINVAL; -+ goto done; -+ } -+ -+ ret = fusb302_set_toggling(dev, TOGGLING_MODE_OFF); -+ if (ret) { -+ dev_err(dev, "cannot set toggling mode: %d\n", ret); -+ goto done; -+ } -+ -+ ret = fusb302_i2c_mask_write(dev, FUSB_REG_SWITCHES0, -+ switches0_mask, switches0_data); -+ if (ret) { -+ dev_err(dev, "cannot set pull-up/-down: %d\n", ret); -+ goto done; -+ } -+ /* reset the cc status */ -+ chip->cc1 = TYPEC_CC_OPEN; -+ chip->cc2 = TYPEC_CC_OPEN; -+ -+ /* adjust current for SRC */ -+ ret = fusb302_set_src_current(dev, cc_src_current[cc]); -+ if (ret) { -+ dev_err(dev, "cannot set src current %s: %d\n", -+ typec_cc_status_name[cc], ret); -+ goto done; -+ } -+ -+ /* enable/disable interrupts, BC_LVL for SNK and COMP_CHNG for SRC */ -+ switch (cc) { -+ case TYPEC_CC_RP_DEF: -+ case TYPEC_CC_RP_1_5: -+ case TYPEC_CC_RP_3_0: -+ rd_mda = rd_mda_value[cc_src_current[cc]]; -+ ret = fusb302_i2c_write(dev, FUSB_REG_MEASURE, rd_mda); -+ if (ret) { -+ dev_err(dev, "cannot set SRC measure value: %d\n", ret); -+ goto done; -+ } -+ ret = fusb302_i2c_mask_write(dev, FUSB_REG_MASK, -+ FUSB_REG_MASK_BC_LVL | -+ FUSB_REG_MASK_COMP_CHNG, -+ FUSB_REG_MASK_BC_LVL); -+ if (ret) { -+ dev_err(dev, "cannot set SRC irq: %d\n", ret); -+ goto done; -+ } -+ chip->intr_comp_chng = true; -+ break; -+ case TYPEC_CC_RD: -+ ret = fusb302_i2c_mask_write(dev, FUSB_REG_MASK, -+ FUSB_REG_MASK_BC_LVL | -+ FUSB_REG_MASK_COMP_CHNG, -+ FUSB_REG_MASK_COMP_CHNG); -+ if (ret) { -+ dev_err(dev, "cannot set SRC irq: %d\n", ret); -+ goto done; -+ } -+ chip->intr_bc_lvl = true; -+ break; -+ default: -+ break; -+ } -+done: -+ return ret; -+} -+ -+static int fusb302_get_cc(struct udevice *dev, enum typec_cc_status *cc1, -+ enum typec_cc_status *cc2) -+{ -+ struct fusb302_chip *chip = dev_get_priv(dev); -+ -+ *cc1 = chip->cc1; -+ *cc2 = chip->cc2; -+ dev_dbg(dev, "get cc1 = %s, cc2 = %s\n", typec_cc_status_name[*cc1], -+ typec_cc_status_name[*cc2]); -+ -+ return 0; -+} -+ -+static int fusb302_set_vconn(struct udevice *dev, bool on) -+{ -+ struct fusb302_chip *chip = dev_get_priv(dev); -+ int ret; -+ u8 switches0_data = 0x00; -+ u8 switches0_mask = FUSB_REG_SWITCHES0_VCONN_CC1 | -+ FUSB_REG_SWITCHES0_VCONN_CC2; -+ -+ if (chip->vconn_on == on) { -+ ret = 0; -+ dev_dbg(dev, "vconn is already %s\n", on ? "on" : "off"); -+ goto done; -+ } -+ if (on) { -+ switches0_data = (chip->cc_polarity == TYPEC_POLARITY_CC1) ? -+ FUSB_REG_SWITCHES0_VCONN_CC2 : -+ FUSB_REG_SWITCHES0_VCONN_CC1; -+ } -+ ret = fusb302_i2c_mask_write(dev, FUSB_REG_SWITCHES0, -+ switches0_mask, switches0_data); -+ if (ret) -+ goto done; -+ dev_dbg(dev, "set vconn = %s\n", on ? "on" : "off"); -+done: -+ return ret; -+} -+ -+static int fusb302_set_vbus(struct udevice *dev, bool on, bool charge) -+{ -+ return 0; -+} -+ -+static int fusb302_pd_tx_flush(struct udevice *dev) -+{ -+ return fusb302_i2c_set_bits(dev, FUSB_REG_CONTROL0, -+ FUSB_REG_CONTROL0_TX_FLUSH); -+} -+ -+static int fusb302_pd_rx_flush(struct udevice *dev) -+{ -+ return fusb302_i2c_set_bits(dev, FUSB_REG_CONTROL1, -+ FUSB_REG_CONTROL1_RX_FLUSH); -+} -+ -+static int fusb302_pd_set_auto_goodcrc(struct udevice *dev, bool on) -+{ -+ if (on) -+ return fusb302_i2c_set_bits(dev, FUSB_REG_SWITCHES1, -+ FUSB_REG_SWITCHES1_AUTO_GCRC); -+ return fusb302_i2c_clear_bits(dev, FUSB_REG_SWITCHES1, -+ FUSB_REG_SWITCHES1_AUTO_GCRC); -+} -+ -+static int fusb302_pd_set_interrupts(struct udevice *dev, bool on) -+{ -+ int ret; -+ u8 mask_interrupts = FUSB_REG_MASK_COLLISION; -+ u8 maska_interrupts = FUSB_REG_MASKA_RETRYFAIL | -+ FUSB_REG_MASKA_HARDSENT | -+ FUSB_REG_MASKA_TX_SUCCESS | -+ FUSB_REG_MASKA_HARDRESET; -+ u8 maskb_interrupts = FUSB_REG_MASKB_GCRCSENT; -+ -+ ret = on ? -+ fusb302_i2c_clear_bits(dev, FUSB_REG_MASK, mask_interrupts) : -+ fusb302_i2c_set_bits(dev, FUSB_REG_MASK, mask_interrupts); -+ if (ret) -+ return ret; -+ ret = on ? -+ fusb302_i2c_clear_bits(dev, FUSB_REG_MASKA, maska_interrupts) : -+ fusb302_i2c_set_bits(dev, FUSB_REG_MASKA, maska_interrupts); -+ if (ret) -+ return ret; -+ ret = on ? -+ fusb302_i2c_clear_bits(dev, FUSB_REG_MASKB, maskb_interrupts) : -+ fusb302_i2c_set_bits(dev, FUSB_REG_MASKB, maskb_interrupts); -+ return ret; -+} -+ -+static int fusb302_set_pd_rx(struct udevice *dev, bool on) -+{ -+ int ret; -+ -+ ret = fusb302_pd_rx_flush(dev); -+ if (ret) { -+ dev_err(dev, "cannot flush pd rx buffer: %d\n", ret); -+ goto done; -+ } -+ ret = fusb302_pd_tx_flush(dev); -+ if (ret) { -+ dev_err(dev, "cannot flush pd tx buffer: %d\n", ret); -+ goto done; -+ } -+ ret = fusb302_pd_set_auto_goodcrc(dev, on); -+ if (ret) { -+ dev_err(dev, "cannot turn %s auto GoodCRC: %d\n", -+ on ? "on" : "off", ret); -+ goto done; -+ } -+ ret = fusb302_pd_set_interrupts(dev, on); -+ if (ret) { -+ dev_err(dev, "cannot turn %s pd interrupts: %d\n", -+ on ? "on" : "off", ret); -+ goto done; -+ } -+ dev_dbg(dev, "set pd RX %s\n", on ? "on" : "off"); -+done: -+ return ret; -+} -+ -+static int fusb302_set_roles(struct udevice *dev, bool attached, -+ enum typec_role pwr, enum typec_data_role data) -+{ -+ int ret; -+ u8 switches1_mask = FUSB_REG_SWITCHES1_POWERROLE | -+ FUSB_REG_SWITCHES1_DATAROLE; -+ u8 switches1_data = 0x00; -+ -+ if (pwr == TYPEC_SOURCE) -+ switches1_data |= FUSB_REG_SWITCHES1_POWERROLE; -+ if (data == TYPEC_HOST) -+ switches1_data |= FUSB_REG_SWITCHES1_DATAROLE; -+ ret = fusb302_i2c_mask_write(dev, FUSB_REG_SWITCHES1, -+ switches1_mask, switches1_data); -+ if (ret) { -+ dev_err(dev, "unable to set pd header %s, %s, ret=%d\n", -+ typec_role_name[pwr], typec_data_role_name[data], ret); -+ goto done; -+ } -+ dev_dbg(dev, "pd header : %s, %s\n", typec_role_name[pwr], -+ typec_data_role_name[data]); -+done: -+ -+ return ret; -+} -+ -+static int fusb302_start_toggling(struct udevice *dev, -+ enum typec_port_type port_type, -+ enum typec_cc_status cc) -+{ -+ enum toggling_mode mode = TOGGLING_MODE_OFF; -+ int ret; -+ -+ switch (port_type) { -+ case TYPEC_PORT_SRC: -+ mode = TOGGLING_MODE_SRC; -+ break; -+ case TYPEC_PORT_SNK: -+ mode = TOGGLING_MODE_SNK; -+ break; -+ case TYPEC_PORT_DRP: -+ mode = TOGGLING_MODE_DRP; -+ break; -+ } -+ -+ ret = fusb302_set_src_current(dev, cc_src_current[cc]); -+ if (ret) { -+ dev_err(dev, "unable to set src current %s, ret=%d", -+ typec_cc_status_name[cc], ret); -+ goto done; -+ } -+ ret = fusb302_set_toggling(dev, mode); -+ if (ret) { -+ dev_err(dev, "unable to start drp toggling: %d\n", ret); -+ goto done; -+ } -+ dev_info(dev, "fusb302 start drp toggling\n"); -+done: -+ -+ return ret; -+} -+ -+static int fusb302_pd_send_message(struct udevice *dev, -+ const struct pd_message *msg) -+{ -+ int ret; -+ /* SOP tokens */ -+ u8 buf[40] = {FUSB302_TKN_SYNC1, FUSB302_TKN_SYNC1, FUSB302_TKN_SYNC1, -+ FUSB302_TKN_SYNC2}; -+ u8 pos = 4; -+ int len; -+ -+ len = pd_header_cnt_le(msg->header) * 4; -+ /* plug 2 for header */ -+ len += 2; -+ if (len > FUSB302_MAX_MSG_LEN) { -+ dev_err(dev, "PD message too long %d (incl. header)", len); -+ return -EINVAL; -+ } -+ /* packsym tells the FUSB302 chip that the next X bytes are payload */ -+ buf[pos++] = FUSB302_TKN_PACKSYM | (len & FUSB302_MAX_MSG_LEN); -+ memcpy(&buf[pos], &msg->header, sizeof(msg->header)); -+ pos += sizeof(msg->header); -+ -+ len -= 2; -+ memcpy(&buf[pos], msg->payload, len); -+ pos += len; -+ -+ /* CRC */ -+ buf[pos++] = FUSB302_TKN_JAMCRC; -+ /* EOP */ -+ buf[pos++] = FUSB302_TKN_EOP; -+ /* turn tx off after sending message */ -+ buf[pos++] = FUSB302_TKN_TXOFF; -+ /* start transmission */ -+ buf[pos++] = FUSB302_TKN_TXON; -+ -+ ret = fusb302_i2c_block_write(dev, FUSB_REG_FIFOS, pos, buf); -+ if (ret) -+ return ret; -+ dev_dbg(dev, "Send PD message (header=0x%x len=%d)\n", msg->header, len); -+ -+ return ret; -+} -+ -+static int fusb302_pd_send_hardreset(struct udevice *dev) -+{ -+ return fusb302_i2c_set_bits(dev, FUSB_REG_CONTROL3, -+ FUSB_REG_CONTROL3_SEND_HARDRESET); -+} -+ -+static const char * const transmit_type_name[] = { -+ [TCPC_TX_SOP] = "SOP", -+ [TCPC_TX_SOP_PRIME] = "SOP'", -+ [TCPC_TX_SOP_PRIME_PRIME] = "SOP''", -+ [TCPC_TX_SOP_DEBUG_PRIME] = "DEBUG'", -+ [TCPC_TX_SOP_DEBUG_PRIME_PRIME] = "DEBUG''", -+ [TCPC_TX_HARD_RESET] = "HARD_RESET", -+ [TCPC_TX_CABLE_RESET] = "CABLE_RESET", -+ [TCPC_TX_BIST_MODE_2] = "BIST_MODE_2", -+}; -+ -+static int fusb302_pd_transmit(struct udevice *dev, enum tcpm_transmit_type type, -+ const struct pd_message *msg, unsigned int negotiated_rev) -+{ -+ int ret; -+ -+ switch (type) { -+ case TCPC_TX_SOP: -+ /* nRetryCount 3 in P2.0 spec, whereas 2 in PD3.0 spec */ -+ ret = fusb302_enable_tx_auto_retries(dev, negotiated_rev > PD_REV20 ? -+ FUSB_REG_CONTROL3_N_RETRIES_2 : -+ FUSB_REG_CONTROL3_N_RETRIES_3); -+ if (ret) -+ dev_err(dev, "cannot update retry count: %d\n", ret); -+ -+ ret = fusb302_pd_send_message(dev, msg); -+ if (ret) -+ dev_err(dev, "cannot send PD message: %d\n", ret); -+ break; -+ case TCPC_TX_HARD_RESET: -+ ret = fusb302_pd_send_hardreset(dev); -+ if (ret) -+ dev_err(dev, "cannot send hardreset: %d\n", ret); -+ break; -+ default: -+ dev_err(dev, "type %s not supported", transmit_type_name[type]); -+ ret = -EINVAL; -+ } -+ -+ return ret; -+} -+ -+static enum typec_cc_status fusb302_bc_lvl_to_cc(u8 bc_lvl) -+{ -+ if (bc_lvl == FUSB_REG_STATUS0_BC_LVL_1230_MAX) -+ return TYPEC_CC_RP_3_0; -+ if (bc_lvl == FUSB_REG_STATUS0_BC_LVL_600_1230) -+ return TYPEC_CC_RP_1_5; -+ if (bc_lvl == FUSB_REG_STATUS0_BC_LVL_200_600) -+ return TYPEC_CC_RP_DEF; -+ return TYPEC_CC_OPEN; -+} -+ -+static void fusb302_bc_lvl_handler(struct udevice *dev) -+{ -+ struct fusb302_chip *chip = dev_get_priv(dev); -+ enum typec_cc_status cc_status; -+ u8 status0, bc_lvl; -+ int ret; -+ -+ if (!chip->intr_bc_lvl) { -+ dev_err(dev, "BC_LVL interrupt is turned off, abort\n"); -+ goto done; -+ } -+ ret = fusb302_i2c_read(dev, FUSB_REG_STATUS0, &status0); -+ if (ret) -+ goto done; -+ -+ dev_dbg(dev, "BC_LVL handler, status0 = 0x%02x\n", status0); -+ if (status0 & FUSB_REG_STATUS0_ACTIVITY) -+ dev_info(dev, "CC activities detected, delay handling\n"); -+ bc_lvl = status0 & FUSB_REG_STATUS0_BC_LVL_MASK; -+ cc_status = fusb302_bc_lvl_to_cc(bc_lvl); -+ if (chip->cc_polarity == TYPEC_POLARITY_CC1) { -+ if (chip->cc1 != cc_status) { -+ dev_dbg(dev, "cc1: %s -> %s\n", -+ typec_cc_status_name[chip->cc1], -+ typec_cc_status_name[cc_status]); -+ chip->cc1 = cc_status; -+ tcpm_cc_change(dev); -+ } -+ } else { -+ if (chip->cc2 != cc_status) { -+ dev_dbg(dev, "cc2: %s -> %s\n", -+ typec_cc_status_name[chip->cc2], -+ typec_cc_status_name[cc_status]); -+ chip->cc2 = cc_status; -+ tcpm_cc_change(dev); -+ } -+ } -+ -+done: -+ return; -+} -+ -+static int fusb302_enter_low_power_mode(struct udevice *dev, -+ bool attached, bool pd_capable) -+{ -+ unsigned int reg; -+ int ret; -+ -+ ret = fusb302_mask_interrupt(dev); -+ if (ret) -+ return ret; -+ if (attached && pd_capable) -+ reg = FUSB_REG_POWER_PWR_MEDIUM; -+ else if (attached) -+ reg = FUSB_REG_POWER_PWR_LOW; -+ else -+ reg = 0; -+ -+ return fusb302_set_power_mode(dev, reg); -+} -+ -+static const char * const cc_polarity_name[] = { -+ [TYPEC_POLARITY_CC1] = "Polarity_CC1", -+ [TYPEC_POLARITY_CC2] = "Polarity_CC2", -+}; -+ -+static int fusb302_set_cc_polarity_and_pull(struct udevice *dev, -+ enum typec_cc_polarity cc_polarity, -+ bool pull_up, bool pull_down) -+{ -+ struct fusb302_chip *chip = dev_get_priv(dev); -+ int ret; -+ u8 switches0_data = 0x00; -+ u8 switches1_mask = FUSB_REG_SWITCHES1_TXCC1_EN | -+ FUSB_REG_SWITCHES1_TXCC2_EN; -+ u8 switches1_data = 0x00; -+ -+ if (pull_down) -+ switches0_data |= FUSB_REG_SWITCHES0_CC1_PD_EN | -+ FUSB_REG_SWITCHES0_CC2_PD_EN; -+ -+ if (cc_polarity == TYPEC_POLARITY_CC1) { -+ switches0_data |= FUSB_REG_SWITCHES0_MEAS_CC1; -+ if (chip->vconn_on) -+ switches0_data |= FUSB_REG_SWITCHES0_VCONN_CC2; -+ if (pull_up) -+ switches0_data |= FUSB_REG_SWITCHES0_CC1_PU_EN; -+ switches1_data = FUSB_REG_SWITCHES1_TXCC1_EN; -+ } else { -+ switches0_data |= FUSB_REG_SWITCHES0_MEAS_CC2; -+ if (chip->vconn_on) -+ switches0_data |= FUSB_REG_SWITCHES0_VCONN_CC1; -+ if (pull_up) -+ switches0_data |= FUSB_REG_SWITCHES0_CC2_PU_EN; -+ switches1_data = FUSB_REG_SWITCHES1_TXCC2_EN; -+ } -+ ret = fusb302_i2c_write(dev, FUSB_REG_SWITCHES0, switches0_data); -+ if (ret) -+ return ret; -+ ret = fusb302_i2c_mask_write(dev, FUSB_REG_SWITCHES1, -+ switches1_mask, switches1_data); -+ if (ret) -+ return ret; -+ chip->cc_polarity = cc_polarity; -+ -+ return ret; -+} -+ -+static int fusb302_handle_togdone_snk(struct udevice *dev, -+ u8 togdone_result) -+{ -+ struct fusb302_chip *chip = dev_get_priv(dev); -+ int ret; -+ u8 status0; -+ u8 bc_lvl; -+ enum typec_cc_polarity cc_polarity; -+ enum typec_cc_status cc_status_active, cc1, cc2; -+ -+ /* set polarity and pull_up, pull_down */ -+ cc_polarity = (togdone_result == FUSB_REG_STATUS1A_TOGSS_SNK1) ? -+ TYPEC_POLARITY_CC1 : TYPEC_POLARITY_CC2; -+ ret = fusb302_set_cc_polarity_and_pull(dev, cc_polarity, false, true); -+ if (ret) { -+ dev_err(dev, "cannot set cc polarity %s, ret = %d\n", -+ cc_polarity_name[cc_polarity], ret); -+ return ret; -+ } -+ /* fusb302_set_cc_polarity() has set the correct measure block */ -+ ret = fusb302_i2c_read(dev, FUSB_REG_STATUS0, &status0); -+ if (ret < 0) -+ return ret; -+ bc_lvl = status0 & FUSB_REG_STATUS0_BC_LVL_MASK; -+ cc_status_active = fusb302_bc_lvl_to_cc(bc_lvl); -+ /* restart toggling if the cc status on the active line is OPEN */ -+ if (cc_status_active == TYPEC_CC_OPEN) { -+ dev_info(dev, "restart toggling as CC_OPEN detected\n"); -+ ret = fusb302_set_toggling(dev, chip->toggling_mode); -+ return ret; -+ } -+ /* update tcpm with the new cc value */ -+ cc1 = (cc_polarity == TYPEC_POLARITY_CC1) ? -+ cc_status_active : TYPEC_CC_OPEN; -+ cc2 = (cc_polarity == TYPEC_POLARITY_CC2) ? -+ cc_status_active : TYPEC_CC_OPEN; -+ if (chip->cc1 != cc1 || chip->cc2 != cc2) { -+ chip->cc1 = cc1; -+ chip->cc2 = cc2; -+ tcpm_cc_change(dev); -+ } -+ /* turn off toggling */ -+ ret = fusb302_set_toggling(dev, TOGGLING_MODE_OFF); -+ if (ret) { -+ dev_err(dev, "cannot set toggling mode off, ret=%d\n", ret); -+ return ret; -+ } -+ /* unmask bc_lvl interrupt */ -+ ret = fusb302_i2c_clear_bits(dev, FUSB_REG_MASK, FUSB_REG_MASK_BC_LVL); -+ if (ret) { -+ dev_err(dev, "cannot unmask bc_lcl irq, ret=%d\n", ret); -+ return ret; -+ } -+ chip->intr_bc_lvl = true; -+ dev_dbg(dev, "detected cc1=%s, cc2=%s\n", -+ typec_cc_status_name[cc1], -+ typec_cc_status_name[cc2]); -+ -+ return ret; -+} -+ -+/* On error returns < 0, otherwise a typec_cc_status value */ -+static int fusb302_get_src_cc_status(struct udevice *dev, -+ enum typec_cc_polarity cc_polarity, -+ enum typec_cc_status *cc) -+{ -+ struct fusb302_chip *chip = dev_get_priv(dev); -+ u8 ra_mda = ra_mda_value[chip->src_current_status]; -+ u8 rd_mda = rd_mda_value[chip->src_current_status]; -+ u8 switches0_data, status0; -+ int ret; -+ -+ /* Step 1: Set switches so that we measure the right CC pin */ -+ switches0_data = (cc_polarity == TYPEC_POLARITY_CC1) ? -+ FUSB_REG_SWITCHES0_CC1_PU_EN | FUSB_REG_SWITCHES0_MEAS_CC1 : -+ FUSB_REG_SWITCHES0_CC2_PU_EN | FUSB_REG_SWITCHES0_MEAS_CC2; -+ ret = fusb302_i2c_write(dev, FUSB_REG_SWITCHES0, switches0_data); -+ if (ret < 0) -+ return ret; -+ -+ fusb302_i2c_read(dev, FUSB_REG_SWITCHES0, &status0); -+ dev_dbg(dev, "get_src_cc_status switches: 0x%0x", status0); -+ -+ /* Step 2: Set compararator volt to differentiate between Open and Rd */ -+ ret = fusb302_i2c_write(dev, FUSB_REG_MEASURE, rd_mda); -+ if (ret) -+ return ret; -+ -+ udelay(100); -+ ret = fusb302_i2c_read(dev, FUSB_REG_STATUS0, &status0); -+ if (ret) -+ return ret; -+ -+ dev_dbg(dev, "get_src_cc_status rd_mda status0: 0x%0x", status0); -+ if (status0 & FUSB_REG_STATUS0_COMP) { -+ *cc = TYPEC_CC_OPEN; -+ return 0; -+ } -+ -+ /* Step 3: Set compararator input to differentiate between Rd and Ra. */ -+ ret = fusb302_i2c_write(dev, FUSB_REG_MEASURE, ra_mda); -+ if (ret) -+ return ret; -+ -+ udelay(100); -+ ret = fusb302_i2c_read(dev, FUSB_REG_STATUS0, &status0); -+ if (ret) -+ return ret; -+ -+ dev_dbg(dev, "get_src_cc_status ra_mda status0: 0x%0x", status0); -+ if (status0 & FUSB_REG_STATUS0_COMP) -+ *cc = TYPEC_CC_RD; -+ else -+ *cc = TYPEC_CC_RA; -+ -+ return 0; -+} -+ -+static int fusb302_handle_togdone_src(struct udevice *dev, -+ u8 togdone_result) -+{ -+ /* -+ * - set polarity (measure cc, vconn, tx) -+ * - set pull_up, pull_down -+ * - set cc1, cc2, and update to tcpm state machine -+ * - set I_COMP interrupt on -+ */ -+ struct fusb302_chip *chip = dev_get_priv(dev); -+ u8 rd_mda = rd_mda_value[chip->src_current_status]; -+ enum toggling_mode toggling_mode = chip->toggling_mode; -+ enum typec_cc_polarity cc_polarity; -+ enum typec_cc_status cc1, cc2; -+ int ret; -+ -+ /* -+ * The toggle-engine will stop in a src state if it sees either Ra or -+ * Rd. Determine the status for both CC pins, starting with the one -+ * where toggling stopped, as that is where the switches point now. -+ */ -+ if (togdone_result == FUSB_REG_STATUS1A_TOGSS_SRC1) -+ ret = fusb302_get_src_cc_status(dev, TYPEC_POLARITY_CC1, &cc1); -+ else -+ ret = fusb302_get_src_cc_status(dev, TYPEC_POLARITY_CC2, &cc2); -+ if (ret) -+ return ret; -+ /* we must turn off toggling before we can measure the other pin */ -+ ret = fusb302_set_toggling(dev, TOGGLING_MODE_OFF); -+ if (ret) { -+ dev_err(dev, "cannot set toggling mode off, ret=%d\n", ret); -+ return ret; -+ } -+ /* get the status of the other pin */ -+ if (togdone_result == FUSB_REG_STATUS1A_TOGSS_SRC1) -+ ret = fusb302_get_src_cc_status(dev, TYPEC_POLARITY_CC2, &cc2); -+ else -+ ret = fusb302_get_src_cc_status(dev, TYPEC_POLARITY_CC1, &cc1); -+ if (ret) -+ return ret; -+ -+ /* determine polarity based on the status of both pins */ -+ if (cc1 == TYPEC_CC_RD && (cc2 == TYPEC_CC_OPEN || cc2 == TYPEC_CC_RA)) { -+ cc_polarity = TYPEC_POLARITY_CC1; -+ } else if (cc2 == TYPEC_CC_RD && -+ (cc1 == TYPEC_CC_OPEN || cc1 == TYPEC_CC_RA)) { -+ cc_polarity = TYPEC_POLARITY_CC2; -+ } else { -+ dev_err(dev, "unexpected CC status cc1=%s, cc2=%s, restarting toggling\n", -+ typec_cc_status_name[cc1], -+ typec_cc_status_name[cc2]); -+ return fusb302_set_toggling(dev, toggling_mode); -+ } -+ /* set polarity and pull_up, pull_down */ -+ ret = fusb302_set_cc_polarity_and_pull(dev, cc_polarity, true, false); -+ if (ret < 0) { -+ dev_err(dev, "cannot set cc polarity %s, ret=%d\n", -+ cc_polarity_name[cc_polarity], ret); -+ return ret; -+ } -+ /* update tcpm with the new cc value */ -+ if (chip->cc1 != cc1 || chip->cc2 != cc2) { -+ chip->cc1 = cc1; -+ chip->cc2 = cc2; -+ tcpm_cc_change(dev); -+ } -+ /* set MDAC to Rd threshold, and unmask I_COMP for unplug detection */ -+ ret = fusb302_i2c_write(dev, FUSB_REG_MEASURE, rd_mda); -+ if (ret) -+ return ret; -+ /* unmask comp_chng interrupt */ -+ ret = fusb302_i2c_clear_bits(dev, FUSB_REG_MASK, -+ FUSB_REG_MASK_COMP_CHNG); -+ if (ret) { -+ dev_err(dev, "cannot unmask comp_chng irq, ret=%d\n", ret); -+ return ret; -+ } -+ chip->intr_comp_chng = true; -+ dev_dbg(dev, "detected cc1=%s, cc2=%s\n", -+ typec_cc_status_name[cc1], -+ typec_cc_status_name[cc2]); -+ -+ return ret; -+} -+ -+static int fusb302_handle_togdone(struct udevice *dev) -+{ -+ struct fusb302_chip *chip = dev_get_priv(dev); -+ u8 togdone_result, status1a; -+ int ret; -+ -+ ret = fusb302_i2c_read(dev, FUSB_REG_STATUS1A, &status1a); -+ if (ret < 0) -+ return ret; -+ togdone_result = (status1a >> FUSB_REG_STATUS1A_TOGSS_POS) & -+ FUSB_REG_STATUS1A_TOGSS_MASK; -+ switch (togdone_result) { -+ case FUSB_REG_STATUS1A_TOGSS_SNK1: -+ case FUSB_REG_STATUS1A_TOGSS_SNK2: -+ return fusb302_handle_togdone_snk(dev, togdone_result); -+ case FUSB_REG_STATUS1A_TOGSS_SRC1: -+ case FUSB_REG_STATUS1A_TOGSS_SRC2: -+ return fusb302_handle_togdone_src(dev, togdone_result); -+ case FUSB_REG_STATUS1A_TOGSS_AA: -+ /* doesn't support */ -+ dev_err(dev, "AudioAccessory not supported\n"); -+ fusb302_set_toggling(dev, chip->toggling_mode); -+ break; -+ default: -+ dev_err(dev, "TOGDONE with an invalid state: %d\n", -+ togdone_result); -+ fusb302_set_toggling(dev, chip->toggling_mode); -+ break; -+ } -+ return ret; -+} -+ -+static int fusb302_pd_reset(struct udevice *dev) -+{ -+ return fusb302_i2c_set_bits(dev, FUSB_REG_RESET, -+ FUSB_REG_RESET_PD_RESET); -+} -+ -+static int fusb302_pd_read_message(struct udevice *dev, -+ struct pd_message *msg) -+{ -+ int len, ret; -+ u8 crc[4]; -+ u8 token; -+ -+ /* first SOP token */ -+ ret = fusb302_i2c_read(dev, FUSB_REG_FIFOS, &token); -+ if (ret) -+ return ret; -+ ret = fusb302_i2c_block_read(dev, FUSB_REG_FIFOS, 2, -+ (u8 *)&msg->header); -+ if (ret) -+ return ret; -+ len = pd_header_cnt_le(msg->header) * 4; -+ /* add 4 to length to include the CRC */ -+ if (len > PD_MAX_PAYLOAD * 4) { -+ dev_err(dev, "PD message too long %d\n", len); -+ return -EINVAL; -+ } -+ if (len > 0) { -+ ret = fusb302_i2c_block_read(dev, FUSB_REG_FIFOS, len, -+ (u8 *)msg->payload); -+ if (ret) -+ return ret; -+ } -+ /* another 4 bytes to read CRC out */ -+ ret = fusb302_i2c_block_read(dev, FUSB_REG_FIFOS, 4, crc); -+ if (ret) -+ return ret; -+ dev_dbg(dev, "Received PD message (header=0x%x len=%d)\n", msg->header, len); -+ -+ /* -+ * Check if we've read off a GoodCRC message. If so then indicate to -+ * TCPM that the previous transmission has completed. Otherwise we pass -+ * the received message over to TCPM for processing. -+ * -+ * We make this check here instead of basing the reporting decision on -+ * the IRQ event type, as it's possible for the chip to report the -+ * TX_SUCCESS and GCRCSENT events out of order on occasion, so we need -+ * to check the message type to ensure correct reporting to TCPM. -+ */ -+ if (!len && (pd_header_type_le(msg->header) == PD_CTRL_GOOD_CRC)) -+ tcpm_pd_transmit_complete(dev, TCPC_TX_SUCCESS); -+ else -+ tcpm_pd_receive(dev, msg); -+ -+ return ret; -+} -+ -+static void fusb302_interrupt_handle(struct udevice *dev) -+{ -+ struct fusb302_chip *chip = dev_get_priv(dev); -+ u8 interrupt; -+ u8 interrupta; -+ u8 interruptb; -+ u8 status0; -+ bool vbus_present; -+ bool comp_result; -+ bool intr_togdone; -+ bool intr_bc_lvl; -+ bool intr_comp_chng; -+ struct pd_message pd_msg; -+ int ret; -+ -+ /* grab a snapshot of intr flags */ -+ intr_togdone = chip->intr_togdone; -+ intr_bc_lvl = chip->intr_bc_lvl; -+ intr_comp_chng = chip->intr_comp_chng; -+ -+ ret = fusb302_i2c_read(dev, FUSB_REG_INTERRUPT, &interrupt); -+ if (ret) -+ return; -+ ret = fusb302_i2c_read(dev, FUSB_REG_INTERRUPTA, &interrupta); -+ if (ret) -+ return; -+ ret = fusb302_i2c_read(dev, FUSB_REG_INTERRUPTB, &interruptb); -+ if (ret) -+ return; -+ ret = fusb302_i2c_read(dev, FUSB_REG_STATUS0, &status0); -+ if (ret) -+ return; -+ -+ /* -+ * Since we are polling the IRQs, avoid printing messages when there -+ * no interrupts at all to avoid spamming the log. -+ */ -+ if (interrupt != 0 || interrupta != 0 || interruptb != 0) -+ dev_dbg(dev, "IRQ: 0x%02x, a: 0x%02x, b: 0x%02x, status0: 0x%02x\n", -+ interrupt, interrupta, interruptb, status0); -+ -+ if (interrupt & FUSB_REG_INTERRUPT_VBUSOK) { -+ vbus_present = !!(status0 & FUSB_REG_STATUS0_VBUSOK); -+ dev_dbg(dev, "IRQ: VBUS_OK, vbus=%s\n", -+ vbus_present ? "On" : "Off"); -+ if (vbus_present != chip->vbus_present) { -+ chip->vbus_present = vbus_present; -+ tcpm_vbus_change(dev); -+ } -+ } -+ -+ if ((interrupta & FUSB_REG_INTERRUPTA_TOGDONE) && intr_togdone) { -+ dev_dbg(dev, "IRQ: TOGDONE\n"); -+ ret = fusb302_handle_togdone(dev); -+ if (ret) { -+ dev_err(dev, "handle togdone error: %d\n", ret); -+ return; -+ } -+ } -+ -+ if ((interrupt & FUSB_REG_INTERRUPT_BC_LVL) && intr_bc_lvl) { -+ dev_dbg(dev, "IRQ: BC_LVL, handler pending\n"); -+ fusb302_bc_lvl_handler(dev); -+ } -+ -+ if ((interrupt & FUSB_REG_INTERRUPT_COMP_CHNG) && intr_comp_chng) { -+ comp_result = !!(status0 & FUSB_REG_STATUS0_COMP); -+ dev_dbg(dev, "IRQ: COMP_CHNG, comp=%s\n", -+ comp_result ? "true" : "false"); -+ if (comp_result) { -+ /* cc level > Rd_threshold, detach */ -+ chip->cc1 = TYPEC_CC_OPEN; -+ chip->cc2 = TYPEC_CC_OPEN; -+ tcpm_cc_change(dev); -+ } -+ } -+ -+ if (interrupt & FUSB_REG_INTERRUPT_COLLISION) { -+ dev_dbg(dev, "IRQ: PD collision\n"); -+ tcpm_pd_transmit_complete(dev, TCPC_TX_FAILED); -+ } -+ -+ if (interrupta & FUSB_REG_INTERRUPTA_RETRYFAIL) { -+ dev_dbg(dev, "IRQ: PD retry failed\n"); -+ tcpm_pd_transmit_complete(dev, TCPC_TX_FAILED); -+ } -+ -+ if (interrupta & FUSB_REG_INTERRUPTA_HARDSENT) { -+ dev_dbg(dev, "IRQ: PD hardreset sent\n"); -+ ret = fusb302_pd_reset(dev); -+ if (ret) { -+ dev_err(dev, "cannot PD reset, ret=%d\n", ret); -+ return; -+ } -+ tcpm_pd_transmit_complete(dev, TCPC_TX_SUCCESS); -+ } -+ -+ if (interrupta & FUSB_REG_INTERRUPTA_TX_SUCCESS) { -+ dev_dbg(dev, "IRQ: PD tx success\n"); -+ ret = fusb302_pd_read_message(dev, &pd_msg); -+ if (ret) { -+ dev_err(dev, "cannot read in PD message, ret=%d\n", ret); -+ return; -+ } -+ } -+ -+ if (interrupta & FUSB_REG_INTERRUPTA_HARDRESET) { -+ dev_dbg(dev, "IRQ: PD received hardreset\n"); -+ ret = fusb302_pd_reset(dev); -+ if (ret) { -+ dev_err(dev, "cannot PD reset, ret=%d\n", ret); -+ return; -+ } -+ tcpm_pd_hard_reset(dev); -+ } -+ -+ if (interruptb & FUSB_REG_INTERRUPTB_GCRCSENT) { -+ dev_dbg(dev, "IRQ: PD sent good CRC\n"); -+ ret = fusb302_pd_read_message(dev, &pd_msg); -+ if (ret) { -+ dev_err(dev, "cannot read in PD message, ret=%d\n", ret); -+ return; -+ } -+ } -+} -+ -+static void fusb302_poll_event(struct udevice *dev) -+{ -+ fusb302_interrupt_handle(dev); -+} -+ -+static int fusb302_get_connector_node(struct udevice *dev, ofnode *connector_node) -+{ -+ *connector_node = dev_read_subnode(dev, "connector"); -+ if (!ofnode_valid(*connector_node)) { -+ dev_err(dev, "'connector' node is not found\n"); -+ return -ENODEV; -+ } -+ -+ return 0; -+} -+ -+static struct dm_tcpm_ops fusb302_ops = { -+ .get_connector_node = fusb302_get_connector_node, -+ .init = fusb302_init, -+ .get_vbus = fusb302_get_vbus, -+ .set_cc = fusb302_set_cc, -+ .get_cc = fusb302_get_cc, -+ .set_vconn = fusb302_set_vconn, -+ .set_vbus = fusb302_set_vbus, -+ .set_pd_rx = fusb302_set_pd_rx, -+ .set_roles = fusb302_set_roles, -+ .start_toggling = fusb302_start_toggling, -+ .pd_transmit = fusb302_pd_transmit, -+ .poll_event = fusb302_poll_event, -+ .enter_low_power_mode = fusb302_enter_low_power_mode, -+}; -+ -+static const struct udevice_id fusb302_ids[] = { -+ { .compatible = "fcs,fusb302" }, -+ { } -+}; -+ -+U_BOOT_DRIVER(fusb302) = { -+ .name = "fusb302", -+ .id = UCLASS_TCPM, -+ .of_match = fusb302_ids, -+ .ops = &fusb302_ops, -+ .priv_auto = sizeof(struct fusb302_chip), -+}; -diff --git a/drivers/usb/tcpm/fusb302_reg.h b/drivers/usb/tcpm/fusb302_reg.h -new file mode 100644 -index 000000000000..edc0e4b0f1e6 ---- /dev/null -+++ b/drivers/usb/tcpm/fusb302_reg.h -@@ -0,0 +1,177 @@ -+/* SPDX-License-Identifier: GPL-2.0+ */ -+/* -+ * Copyright 2016-2017 Google, Inc -+ * -+ * Fairchild FUSB302 Type-C Chip Driver -+ */ -+ -+#ifndef FUSB302_REG_H -+#define FUSB302_REG_H -+ -+#define FUSB_REG_DEVICE_ID 0x01 -+#define FUSB_REG_SWITCHES0 0x02 -+#define FUSB_REG_SWITCHES0_CC2_PU_EN BIT(7) -+#define FUSB_REG_SWITCHES0_CC1_PU_EN BIT(6) -+#define FUSB_REG_SWITCHES0_VCONN_CC2 BIT(5) -+#define FUSB_REG_SWITCHES0_VCONN_CC1 BIT(4) -+#define FUSB_REG_SWITCHES0_MEAS_CC2 BIT(3) -+#define FUSB_REG_SWITCHES0_MEAS_CC1 BIT(2) -+#define FUSB_REG_SWITCHES0_CC2_PD_EN BIT(1) -+#define FUSB_REG_SWITCHES0_CC1_PD_EN BIT(0) -+#define FUSB_REG_SWITCHES1 0x03 -+#define FUSB_REG_SWITCHES1_POWERROLE BIT(7) -+#define FUSB_REG_SWITCHES1_SPECREV1 BIT(6) -+#define FUSB_REG_SWITCHES1_SPECREV0 BIT(5) -+#define FUSB_REG_SWITCHES1_DATAROLE BIT(4) -+#define FUSB_REG_SWITCHES1_AUTO_GCRC BIT(2) -+#define FUSB_REG_SWITCHES1_TXCC2_EN BIT(1) -+#define FUSB_REG_SWITCHES1_TXCC1_EN BIT(0) -+#define FUSB_REG_MEASURE 0x04 -+#define FUSB_REG_MEASURE_MDAC5 BIT(7) -+#define FUSB_REG_MEASURE_MDAC4 BIT(6) -+#define FUSB_REG_MEASURE_MDAC3 BIT(5) -+#define FUSB_REG_MEASURE_MDAC2 BIT(4) -+#define FUSB_REG_MEASURE_MDAC1 BIT(3) -+#define FUSB_REG_MEASURE_MDAC0 BIT(2) -+#define FUSB_REG_MEASURE_VBUS BIT(1) -+#define FUSB_REG_MEASURE_XXXX5 BIT(0) -+#define FUSB_REG_CONTROL0 0x06 -+#define FUSB_REG_CONTROL0_TX_FLUSH BIT(6) -+#define FUSB_REG_CONTROL0_INT_MASK BIT(5) -+#define FUSB_REG_CONTROL0_HOST_CUR_MASK (0xC) -+#define FUSB_REG_CONTROL0_HOST_CUR_HIGH (0xC) -+#define FUSB_REG_CONTROL0_HOST_CUR_MED (0x8) -+#define FUSB_REG_CONTROL0_HOST_CUR_DEF (0x4) -+#define FUSB_REG_CONTROL0_TX_START BIT(0) -+#define FUSB_REG_CONTROL1 0x07 -+#define FUSB_REG_CONTROL1_ENSOP2DB BIT(6) -+#define FUSB_REG_CONTROL1_ENSOP1DB BIT(5) -+#define FUSB_REG_CONTROL1_BIST_MODE2 BIT(4) -+#define FUSB_REG_CONTROL1_RX_FLUSH BIT(2) -+#define FUSB_REG_CONTROL1_ENSOP2 BIT(1) -+#define FUSB_REG_CONTROL1_ENSOP1 BIT(0) -+#define FUSB_REG_CONTROL2 0x08 -+#define FUSB_REG_CONTROL2_MODE BIT(1) -+#define FUSB_REG_CONTROL2_MODE_MASK (0x6) -+#define FUSB_REG_CONTROL2_MODE_DFP (0x6) -+#define FUSB_REG_CONTROL2_MODE_UFP (0x4) -+#define FUSB_REG_CONTROL2_MODE_DRP (0x2) -+#define FUSB_REG_CONTROL2_MODE_NONE (0x0) -+#define FUSB_REG_CONTROL2_TOGGLE BIT(0) -+#define FUSB_REG_CONTROL3 0x09 -+#define FUSB_REG_CONTROL3_SEND_HARDRESET BIT(6) -+#define FUSB_REG_CONTROL3_BIST_TMODE BIT(5) /* 302B Only */ -+#define FUSB_REG_CONTROL3_AUTO_HARDRESET BIT(4) -+#define FUSB_REG_CONTROL3_AUTO_SOFTRESET BIT(3) -+#define FUSB_REG_CONTROL3_N_RETRIES BIT(1) -+#define FUSB_REG_CONTROL3_N_RETRIES_MASK (0x6) -+#define FUSB_REG_CONTROL3_N_RETRIES_3 (0x6) -+#define FUSB_REG_CONTROL3_N_RETRIES_2 (0x4) -+#define FUSB_REG_CONTROL3_N_RETRIES_1 (0x2) -+#define FUSB_REG_CONTROL3_AUTO_RETRY BIT(0) -+#define FUSB_REG_MASK 0x0A -+#define FUSB_REG_MASK_VBUSOK BIT(7) -+#define FUSB_REG_MASK_ACTIVITY BIT(6) -+#define FUSB_REG_MASK_COMP_CHNG BIT(5) -+#define FUSB_REG_MASK_CRC_CHK BIT(4) -+#define FUSB_REG_MASK_ALERT BIT(3) -+#define FUSB_REG_MASK_WAKE BIT(2) -+#define FUSB_REG_MASK_COLLISION BIT(1) -+#define FUSB_REG_MASK_BC_LVL BIT(0) -+#define FUSB_REG_POWER 0x0B -+#define FUSB_REG_POWER_PWR BIT(0) -+#define FUSB_REG_POWER_PWR_LOW 0x1 -+#define FUSB_REG_POWER_PWR_MEDIUM 0x3 -+#define FUSB_REG_POWER_PWR_HIGH 0x7 -+#define FUSB_REG_POWER_PWR_ALL 0xF -+#define FUSB_REG_RESET 0x0C -+#define FUSB_REG_RESET_PD_RESET BIT(1) -+#define FUSB_REG_RESET_SW_RESET BIT(0) -+#define FUSB_REG_MASKA 0x0E -+#define FUSB_REG_MASKA_OCP_TEMP BIT(7) -+#define FUSB_REG_MASKA_TOGDONE BIT(6) -+#define FUSB_REG_MASKA_SOFTFAIL BIT(5) -+#define FUSB_REG_MASKA_RETRYFAIL BIT(4) -+#define FUSB_REG_MASKA_HARDSENT BIT(3) -+#define FUSB_REG_MASKA_TX_SUCCESS BIT(2) -+#define FUSB_REG_MASKA_SOFTRESET BIT(1) -+#define FUSB_REG_MASKA_HARDRESET BIT(0) -+#define FUSB_REG_MASKB 0x0F -+#define FUSB_REG_MASKB_GCRCSENT BIT(0) -+#define FUSB_REG_STATUS0A 0x3C -+#define FUSB_REG_STATUS0A_SOFTFAIL BIT(5) -+#define FUSB_REG_STATUS0A_RETRYFAIL BIT(4) -+#define FUSB_REG_STATUS0A_POWER BIT(2) -+#define FUSB_REG_STATUS0A_RX_SOFT_RESET BIT(1) -+#define FUSB_REG_STATUS0A_RX_HARD_RESET BIT(0) -+#define FUSB_REG_STATUS1A 0x3D -+#define FUSB_REG_STATUS1A_TOGSS BIT(3) -+#define FUSB_REG_STATUS1A_TOGSS_RUNNING 0x0 -+#define FUSB_REG_STATUS1A_TOGSS_SRC1 0x1 -+#define FUSB_REG_STATUS1A_TOGSS_SRC2 0x2 -+#define FUSB_REG_STATUS1A_TOGSS_SNK1 0x5 -+#define FUSB_REG_STATUS1A_TOGSS_SNK2 0x6 -+#define FUSB_REG_STATUS1A_TOGSS_AA 0x7 -+#define FUSB_REG_STATUS1A_TOGSS_POS (3) -+#define FUSB_REG_STATUS1A_TOGSS_MASK (0x7) -+#define FUSB_REG_STATUS1A_RXSOP2DB BIT(2) -+#define FUSB_REG_STATUS1A_RXSOP1DB BIT(1) -+#define FUSB_REG_STATUS1A_RXSOP BIT(0) -+#define FUSB_REG_INTERRUPTA 0x3E -+#define FUSB_REG_INTERRUPTA_OCP_TEMP BIT(7) -+#define FUSB_REG_INTERRUPTA_TOGDONE BIT(6) -+#define FUSB_REG_INTERRUPTA_SOFTFAIL BIT(5) -+#define FUSB_REG_INTERRUPTA_RETRYFAIL BIT(4) -+#define FUSB_REG_INTERRUPTA_HARDSENT BIT(3) -+#define FUSB_REG_INTERRUPTA_TX_SUCCESS BIT(2) -+#define FUSB_REG_INTERRUPTA_SOFTRESET BIT(1) -+#define FUSB_REG_INTERRUPTA_HARDRESET BIT(0) -+#define FUSB_REG_INTERRUPTB 0x3F -+#define FUSB_REG_INTERRUPTB_GCRCSENT BIT(0) -+#define FUSB_REG_STATUS0 0x40 -+#define FUSB_REG_STATUS0_VBUSOK BIT(7) -+#define FUSB_REG_STATUS0_ACTIVITY BIT(6) -+#define FUSB_REG_STATUS0_COMP BIT(5) -+#define FUSB_REG_STATUS0_CRC_CHK BIT(4) -+#define FUSB_REG_STATUS0_ALERT BIT(3) -+#define FUSB_REG_STATUS0_WAKE BIT(2) -+#define FUSB_REG_STATUS0_BC_LVL_MASK 0x03 -+#define FUSB_REG_STATUS0_BC_LVL_0_200 0x0 -+#define FUSB_REG_STATUS0_BC_LVL_200_600 0x1 -+#define FUSB_REG_STATUS0_BC_LVL_600_1230 0x2 -+#define FUSB_REG_STATUS0_BC_LVL_1230_MAX 0x3 -+#define FUSB_REG_STATUS0_BC_LVL1 BIT(1) -+#define FUSB_REG_STATUS0_BC_LVL0 BIT(0) -+#define FUSB_REG_STATUS1 0x41 -+#define FUSB_REG_STATUS1_RXSOP2 BIT(7) -+#define FUSB_REG_STATUS1_RXSOP1 BIT(6) -+#define FUSB_REG_STATUS1_RX_EMPTY BIT(5) -+#define FUSB_REG_STATUS1_RX_FULL BIT(4) -+#define FUSB_REG_STATUS1_TX_EMPTY BIT(3) -+#define FUSB_REG_STATUS1_TX_FULL BIT(2) -+#define FUSB_REG_INTERRUPT 0x42 -+#define FUSB_REG_INTERRUPT_VBUSOK BIT(7) -+#define FUSB_REG_INTERRUPT_ACTIVITY BIT(6) -+#define FUSB_REG_INTERRUPT_COMP_CHNG BIT(5) -+#define FUSB_REG_INTERRUPT_CRC_CHK BIT(4) -+#define FUSB_REG_INTERRUPT_ALERT BIT(3) -+#define FUSB_REG_INTERRUPT_WAKE BIT(2) -+#define FUSB_REG_INTERRUPT_COLLISION BIT(1) -+#define FUSB_REG_INTERRUPT_BC_LVL BIT(0) -+#define FUSB_REG_FIFOS 0x43 -+ -+/* Tokens defined for the FUSB302 TX FIFO */ -+enum fusb302_txfifo_tokens { -+ FUSB302_TKN_TXON = 0xA1, -+ FUSB302_TKN_SYNC1 = 0x12, -+ FUSB302_TKN_SYNC2 = 0x13, -+ FUSB302_TKN_SYNC3 = 0x1B, -+ FUSB302_TKN_RST1 = 0x15, -+ FUSB302_TKN_RST2 = 0x16, -+ FUSB302_TKN_PACKSYM = 0x80, -+ FUSB302_TKN_JAMCRC = 0xFF, -+ FUSB302_TKN_EOP = 0x14, -+ FUSB302_TKN_TXOFF = 0xFE, -+}; -+ -+#endif - -From patchwork Thu Sep 5 15:08:39 2024 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Sebastian Reichel -X-Patchwork-Id: 1981310 -X-Patchwork-Delegate: ykai007@gmail.com -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - dkim=pass (2048-bit key; - unprotected) header.d=collabora.com header.i=@collabora.com - header.a=rsa-sha256 header.s=mail header.b=OlVGM1CY; - dkim-atps=neutral -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de - [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4X02yx4Yhtz1yXY - for ; Fri, 6 Sep 2024 01:17:13 +1000 (AEST) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id DA19F88CC4; - Thu, 5 Sep 2024 17:17:10 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=collabora.com -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de -Authentication-Results: phobos.denx.de; - dkim=pass (2048-bit key; - unprotected) header.d=collabora.com header.i=@collabora.com - header.b="OlVGM1CY"; - dkim-atps=neutral -Received: by phobos.denx.de (Postfix, from userid 109) - id 818FF88CD1; Thu, 5 Sep 2024 17:17:10 +0200 (CEST) -X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de -X-Spam-Level: -X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, - DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_VALIDITY_RPBL_BLOCKED, - RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE,SPF_PASS, - T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 -Received: from bali.collaboradmins.com (bali.collaboradmins.com - [148.251.105.195]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) - (No client certificate requested) - by phobos.denx.de (Postfix) with ESMTPS id 6EA7A88C91 - for ; Thu, 5 Sep 2024 17:17:08 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=collabora.com -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=sebastian.reichel@collabora.com -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; - s=mail; t=1725549428; - bh=MaX9knvNNlkcoU7y63UAKlXcI2FWJjBx6Z541dTO9i4=; - h=From:To:Cc:Subject:Date:In-Reply-To:References:From; - b=OlVGM1CYARH8jR7hX1JCyzjLoOvYonq4dVpddV7tqHKv1GFwV9kFs0BQ4idvjHy/T - 8dmf8Dp7LkEStFeQOeVF3FgD3kjcRIYq3a5QWQFKwba/sLcp1VQ7mycHrCP+uN1RoX - /uKEccUu41G7R4ERpXHJ6QrLVyWLcW1x86YZPE/mq17AETdmUfj2OUO/vCeoZ4lpvg - zTniAnbJTy/4BLPaDtK760efy5eYghMStjR8BfjQNKUWA1h2UAW5anloE/cgSsgWjT - m9wxvIxG3UqPf1YKEMUUgxOAyu/gjKrdK4rCKEY/ox+UAyg1Q2EQaHWm50UFUlNLjj - q0jLt7uyLlMvg== -Received: from jupiter.universe (dyndsl-091-248-189-231.ewe-ip-backbone.de - [91.248.189.231]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest - SHA256) - (No client certificate requested) (Authenticated sender: sre) - by bali.collaboradmins.com (Postfix) with ESMTPSA id EDB4F17E145D; - Thu, 5 Sep 2024 17:17:07 +0200 (CEST) -Received: by jupiter.universe (Postfix, from userid 1000) - id A34D14800F6; Thu, 05 Sep 2024 17:17:07 +0200 (CEST) -From: Sebastian Reichel -To: Marek Vasut , u-boot@lists.denx.de, - Jonas Karlman , Soeren Moch -Cc: Eugen Hristev , - Tim Harvey , Kever Yang , - Philipp Tomsich , Simon Glass , - Sebastian Reichel -Subject: [PATCH v6 3/6] board: rock5b-rk3588: enable USB-C in operating system -Date: Thu, 5 Sep 2024 17:08:39 +0200 -Message-ID: <20240905151707.59101-4-sebastian.reichel@collabora.com> -X-Mailer: git-send-email 2.45.2 -In-Reply-To: <20240905151707.59101-1-sebastian.reichel@collabora.com> -References: <20240905151707.59101-1-sebastian.reichel@collabora.com> -MIME-Version: 1.0 -X-BeenThere: u-boot@lists.denx.de -X-Mailman-Version: 2.1.39 -Precedence: list -List-Id: U-Boot discussion -List-Unsubscribe: , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: , - -Errors-To: u-boot-bounces@lists.denx.de -Sender: "U-Boot" -X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de -X-Virus-Status: Clean - -Since older U-Boot releases do not negotiate USB PD, the kernel -DT may not enable the USB-C controller by default to avoid a -regression. The plan is to upstream it with 'status = "fail";' -instead. U-Boot should then mark it as 'status = "okay";' if -it negotiated USB PD. Currently existing upstream kernel DTs do -not yet have the USB-C controller at all, so we ignore any -failures. - -Reviewed-by: Kever Yang -Tested-by: Soeren Moch -Signed-off-by: Sebastian Reichel ---- - board/radxa/rock5b-rk3588/Makefile | 6 ++++++ - board/radxa/rock5b-rk3588/rock5b-rk3588.c | 16 ++++++++++++++++ - 2 files changed, 22 insertions(+) - create mode 100644 board/radxa/rock5b-rk3588/Makefile - create mode 100644 board/radxa/rock5b-rk3588/rock5b-rk3588.c - -diff --git a/board/radxa/rock5b-rk3588/Makefile b/board/radxa/rock5b-rk3588/Makefile -new file mode 100644 -index 000000000000..95d813596da4 ---- /dev/null -+++ b/board/radxa/rock5b-rk3588/Makefile -@@ -0,0 +1,6 @@ -+# SPDX-License-Identifier: GPL-2.0+ -+# -+# Copyright (c) 2022 Collabora Ltd. -+# -+ -+obj-y += rock5b-rk3588.o -diff --git a/board/radxa/rock5b-rk3588/rock5b-rk3588.c b/board/radxa/rock5b-rk3588/rock5b-rk3588.c -new file mode 100644 -index 000000000000..fc2f69db2241 ---- /dev/null -+++ b/board/radxa/rock5b-rk3588/rock5b-rk3588.c -@@ -0,0 +1,16 @@ -+// SPDX-License-Identifier: GPL-2.0+ -+/* -+ * Copyright (c) 2023-2024 Collabora Ltd. -+ */ -+ -+#include -+#include -+ -+#ifdef CONFIG_OF_BOARD_SETUP -+int ft_board_setup(void *blob, struct bd_info *bd) -+{ -+ if (IS_ENABLED(CONFIG_TYPEC_FUSB302)) -+ fdt_status_okay_by_compatible(blob, "fcs,fusb302"); -+ return 0; -+} -+#endif - -From patchwork Thu Sep 5 15:08:40 2024 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Sebastian Reichel -X-Patchwork-Id: 1981311 -X-Patchwork-Delegate: ykai007@gmail.com -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - dkim=pass (2048-bit key; - unprotected) header.d=collabora.com header.i=@collabora.com - header.a=rsa-sha256 header.s=mail header.b=Hn8Z4MVu; - dkim-atps=neutral -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=85.214.62.61; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4X02z82c6zz1yXY - for ; Fri, 6 Sep 2024 01:17:24 +1000 (AEST) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id 3EDBD88CA2; - Thu, 5 Sep 2024 17:17:13 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=collabora.com -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de -Authentication-Results: phobos.denx.de; - dkim=pass (2048-bit key; - unprotected) header.d=collabora.com header.i=@collabora.com - header.b="Hn8Z4MVu"; - dkim-atps=neutral -Received: by phobos.denx.de (Postfix, from userid 109) - id 710CF88CA2; Thu, 5 Sep 2024 17:17:12 +0200 (CEST) -X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de -X-Spam-Level: -X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, - DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, - T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no - version=3.4.2 -Received: from bali.collaboradmins.com (bali.collaboradmins.com - [IPv6:2a01:4f8:201:9162::2]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) - (No client certificate requested) - by phobos.denx.de (Postfix) with ESMTPS id 7D4DC88CAC - for ; Thu, 5 Sep 2024 17:17:08 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=collabora.com -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=sebastian.reichel@collabora.com -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; - s=mail; t=1725549428; - bh=kRtQV3aUzqRixo2bcjF9nXzgL+cYAS6B3o857NdybTM=; - h=From:To:Cc:Subject:Date:In-Reply-To:References:From; - b=Hn8Z4MVuPomOScWvWRuPJHT3m84jMoUdUdcI4V6fC8w0zfN0PSB22YMSaMxRDqiQR - D1gyzQpG0bCWuGp89DNtLngEOXCfXPqQh98ArUJFVvn5FVbYDlml9cXwVW02zXglIb - KP92KXxaQTgjWDb6QntmbJHNZVhAMNOCCqIknf4YFMc4/7yGTUsOxI5VD/oY5bbwVJ - aTVCT3SuwJvmXu7Dj150fFYeT0furN5MZT1P/MPFXd1/bnC9Dj+YTT6lm3kw6waCZN - OcRx6P7sRha82dm44zV4xjWnpHPDGGYqTyWNSD72Xj7/CASin5aosS6NbZFpndvcfx - 30yLrCrJPsm3g== -Received: from jupiter.universe (dyndsl-091-248-189-231.ewe-ip-backbone.de - [91.248.189.231]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest - SHA256) - (No client certificate requested) (Authenticated sender: sre) - by bali.collaboradmins.com (Postfix) with ESMTPSA id EF4D117E14D6; - Thu, 5 Sep 2024 17:17:07 +0200 (CEST) -Received: by jupiter.universe (Postfix, from userid 1000) - id A518D4800F8; Thu, 05 Sep 2024 17:17:07 +0200 (CEST) -From: Sebastian Reichel -To: Marek Vasut , u-boot@lists.denx.de, - Jonas Karlman , Soeren Moch -Cc: Eugen Hristev , - Tim Harvey , Kever Yang , - Philipp Tomsich , Simon Glass , - Sebastian Reichel -Subject: [PATCH v6 4/6] rockchip: rk3588-rock-5b: Add USB-C controller to - u-boot.dtsi -Date: Thu, 5 Sep 2024 17:08:40 +0200 -Message-ID: <20240905151707.59101-5-sebastian.reichel@collabora.com> -X-Mailer: git-send-email 2.45.2 -In-Reply-To: <20240905151707.59101-1-sebastian.reichel@collabora.com> -References: <20240905151707.59101-1-sebastian.reichel@collabora.com> -MIME-Version: 1.0 -X-BeenThere: u-boot@lists.denx.de -X-Mailman-Version: 2.1.39 -Precedence: list -List-Id: U-Boot discussion -List-Unsubscribe: , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: , - -Errors-To: u-boot-bounces@lists.denx.de -Sender: "U-Boot" -X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de -X-Virus-Status: Clean - -Add USB-C controller (fusb302), which will be used by U-Boot to -initialize USB-PD. This is needed, because USB-PD communication -must happen within 5 seconds after the USB-C connector got plugged. -On my Rock 5B it often takes 5 seconds to jump to the Linux binary, -so it must happen before Linux is initialized. - -This adds the DT node to the U-Boot specific file, since the Linux -kernel DT currently does not describe it to avoid a system reset. -The plan is to add it to the Linux DT with status = 'fail' and then -let U-Boot mark it as status = 'okay' if it properly dealt with -early USB-PD initialization. Until the Kernel DT has the node, let's -add it in U-Boot to get things going. - -Reviewed-by: Kever Yang -Tested-by: Soeren Moch -Signed-off-by: Sebastian Reichel ---- - arch/arm/dts/rk3588-rock-5b-u-boot.dtsi | 28 +++++++++++++++++++++++++ - 1 file changed, 28 insertions(+) - -diff --git a/arch/arm/dts/rk3588-rock-5b-u-boot.dtsi b/arch/arm/dts/rk3588-rock-5b-u-boot.dtsi -index 4dd17ff408cb..b0ad1158854c 100644 ---- a/arch/arm/dts/rk3588-rock-5b-u-boot.dtsi -+++ b/arch/arm/dts/rk3588-rock-5b-u-boot.dtsi -@@ -3,6 +3,7 @@ - * Copyright (c) 2023 Collabora Ltd. - */ - -+#include - #include "rk3588-u-boot.dtsi" - - &fspim2_pins { -@@ -10,6 +11,33 @@ - bootph-some-ram; - }; - -+&i2c4 { -+ pinctrl-names = "default"; -+ pinctrl-0 = <&i2c4m1_xfer>; -+ status = "okay"; -+ -+ usbc0: usb-typec@22 { -+ compatible = "fcs,fusb302"; -+ reg = <0x22>; -+ interrupt-parent = <&gpio3>; -+ interrupts = ; -+ pinctrl-names = "default"; -+ status = "okay"; -+ -+ usb_con: connector { -+ compatible = "usb-c-connector"; -+ label = "USB-C"; -+ data-role = "dual"; -+ power-role = "sink"; -+ try-power-role = "sink"; -+ op-sink-microwatt = <1000000>; -+ sink-pdos = -+ , -+ ; -+ }; -+ }; -+}; -+ - &sdhci { - cap-mmc-highspeed; - mmc-hs200-1_8v; - -From patchwork Thu Sep 5 15:08:41 2024 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Sebastian Reichel -X-Patchwork-Id: 1981313 -X-Patchwork-Delegate: ykai007@gmail.com -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - dkim=pass (2048-bit key; - unprotected) header.d=collabora.com header.i=@collabora.com - header.a=rsa-sha256 header.s=mail header.b=q3YksfJp; - dkim-atps=neutral -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de - [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1)) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4X02zX1GHQz1yXY - for ; Fri, 6 Sep 2024 01:17:44 +1000 (AEST) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id 23B9E88C91; - Thu, 5 Sep 2024 17:17:15 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=collabora.com -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de -Authentication-Results: phobos.denx.de; - dkim=pass (2048-bit key; - unprotected) header.d=collabora.com header.i=@collabora.com - header.b="q3YksfJp"; - dkim-atps=neutral -Received: by phobos.denx.de (Postfix, from userid 109) - id 4A27388CC2; Thu, 5 Sep 2024 17:17:14 +0200 (CEST) -X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de -X-Spam-Level: -X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, - DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, - T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no - version=3.4.2 -Received: from bali.collaboradmins.com (bali.collaboradmins.com - [IPv6:2a01:4f8:201:9162::2]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) - (No client certificate requested) - by phobos.denx.de (Postfix) with ESMTPS id AA9CC88CCA - for ; Thu, 5 Sep 2024 17:17:08 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=collabora.com -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=sebastian.reichel@collabora.com -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; - s=mail; t=1725549428; - bh=2Lc5Z/YfVP+p0ckRM3rvfdY5jCUdmYScP+mrStWhXgc=; - h=From:To:Cc:Subject:Date:In-Reply-To:References:From; - b=q3YksfJpB4KE3b6jOT8upI79aMX8TsaVAMMBCfHQfd81c94VAOjQE0sKeQG7MZhks - 8MtawvxDPZLokcfL/SI5h7MM+BY3PUAHRF0055L3SENSD8jyNOgSjkmmOOLY27PFGF - LNYyTuhYLE7uZyVOevaq9skCiKVRhV7HtSQcv1ac6YuIyinwrpCN42yaHFG/m6SpO+ - lTxi9/43YenBpHkbZHxt8llNxRKcPbDdXMQcwZE6f0ksz92jfSioU5dJEMwJnFYvLm - XSuzTPYuERV+/O82eUGYarkAczW2F0SfMOKWdb6C85FiS1hNj2Wqo6bM4G+GNyDUWz - ORIxUtmwVAgwg== -Received: from jupiter.universe (dyndsl-091-248-189-231.ewe-ip-backbone.de - [91.248.189.231]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature RSA-PSS (4096 bits)) - (No client certificate requested) (Authenticated sender: sre) - by bali.collaboradmins.com (Postfix) with ESMTPSA id 3C7D917E14D7; - Thu, 5 Sep 2024 17:17:08 +0200 (CEST) -Received: by jupiter.universe (Postfix, from userid 1000) - id A72CD4800FF; Thu, 05 Sep 2024 17:17:07 +0200 (CEST) -From: Sebastian Reichel -To: Marek Vasut , u-boot@lists.denx.de, - Jonas Karlman , Soeren Moch -Cc: Eugen Hristev , - Tim Harvey , Kever Yang , - Philipp Tomsich , Simon Glass , - Sebastian Reichel -Subject: [PATCH v6 5/6] rockchip: rock5b-rk3588: Enable USB-C PD support -Date: Thu, 5 Sep 2024 17:08:41 +0200 -Message-ID: <20240905151707.59101-6-sebastian.reichel@collabora.com> -X-Mailer: git-send-email 2.45.2 -In-Reply-To: <20240905151707.59101-1-sebastian.reichel@collabora.com> -References: <20240905151707.59101-1-sebastian.reichel@collabora.com> -MIME-Version: 1.0 -X-BeenThere: u-boot@lists.denx.de -X-Mailman-Version: 2.1.39 -Precedence: list -List-Id: U-Boot discussion -List-Unsubscribe: , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: , - -Errors-To: u-boot-bounces@lists.denx.de -Sender: "U-Boot" -X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de -X-Virus-Status: Clean - -Now that all code has been prepared update the default configuration to -make use of it. - -Reviewed-by: Kever Yang -Tested-by: Soeren Moch -Signed-off-by: Sebastian Reichel ---- - configs/rock5b-rk3588_defconfig | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/configs/rock5b-rk3588_defconfig b/configs/rock5b-rk3588_defconfig -index 80a2f2fed586..82c942a52d62 100644 ---- a/configs/rock5b-rk3588_defconfig -+++ b/configs/rock5b-rk3588_defconfig -@@ -23,6 +23,7 @@ CONFIG_FIT_VERBOSE=y - CONFIG_SPL_FIT_SIGNATURE=y - CONFIG_SPL_LOAD_FIT=y - CONFIG_LEGACY_IMAGE_FORMAT=y -+CONFIG_OF_BOARD_SETUP=y - CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588-rock-5b.dtb" - # CONFIG_DISPLAY_CPUINFO is not set - CONFIG_DISPLAY_BOARDINFO_LATE=y -@@ -103,3 +104,6 @@ CONFIG_USB_GADGET=y - CONFIG_USB_GADGET_DOWNLOAD=y - CONFIG_USB_FUNCTION_ROCKUSB=y - CONFIG_ERRNO_STR=y -+CONFIG_TYPEC_TCPM=y -+CONFIG_TYPEC_FUSB302=y -+CONFIG_CMD_TCPM=y - -From patchwork Thu Sep 5 15:08:42 2024 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Sebastian Reichel -X-Patchwork-Id: 1981314 -X-Patchwork-Delegate: ykai007@gmail.com -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - dkim=pass (2048-bit key; - unprotected) header.d=collabora.com header.i=@collabora.com - header.a=rsa-sha256 header.s=mail header.b=Ci2PO1GU; - dkim-atps=neutral -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=85.214.62.61; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1)) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4X02zk6YyNz1yXY - for ; Fri, 6 Sep 2024 01:17:54 +1000 (AEST) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id 7F41A88CE5; - Thu, 5 Sep 2024 17:17:15 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=collabora.com -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de -Authentication-Results: phobos.denx.de; - dkim=pass (2048-bit key; - unprotected) header.d=collabora.com header.i=@collabora.com - header.b="Ci2PO1GU"; - dkim-atps=neutral -Received: by phobos.denx.de (Postfix, from userid 109) - id 6ED1888CC2; Thu, 5 Sep 2024 17:17:14 +0200 (CEST) -X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de -X-Spam-Level: -X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, - DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, - T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 -Received: from bali.collaboradmins.com (bali.collaboradmins.com - [IPv6:2a01:4f8:201:9162::2]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) - (No client certificate requested) - by phobos.denx.de (Postfix) with ESMTPS id CD5F888CD0 - for ; Thu, 5 Sep 2024 17:17:08 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=collabora.com -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=sebastian.reichel@collabora.com -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; - s=mail; t=1725549428; - bh=l4Xv+BpciSynhuTx8UEne0BTouVROBqh6qBZSM+vxDg=; - h=From:To:Cc:Subject:Date:In-Reply-To:References:From; - b=Ci2PO1GUFnjJQSAIA8bOSaKduXeFJwF8D+1yGRBAT9+M+oNdtaLQKmdPE/XuBAMBF - hEDngnCgvcZdH4Q3uiLUEDi1jZqjU3+VPGTR6fECGe8zriHIja8R6NQR3NCHsfcQMr - E74ZH8bkjhX6S3MYLjZMLTrFBjTAGvshUtI7gKh7Xyet03KYD1xZlvJV71d196Ygty - pr1imuqccIOh7cUE8V2YsSoaibrkiiA9uEpvNr0u9JxE2dvd5HrVR+Uftjzh21ATyo - RERAB90Lf6rr4hdtA1KaFrpuFgWMWKwVL2OKtE8wxPHaUo23Cq36LXmMeeho8nL73T - 5XslHm2u6aESA== -Received: from jupiter.universe (dyndsl-091-248-189-231.ewe-ip-backbone.de - [91.248.189.231]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature RSA-PSS (4096 bits)) - (No client certificate requested) (Authenticated sender: sre) - by bali.collaboradmins.com (Postfix) with ESMTPSA id 3F1DD17E14D8; - Thu, 5 Sep 2024 17:17:08 +0200 (CEST) -Received: by jupiter.universe (Postfix, from userid 1000) - id A909F480100; Thu, 05 Sep 2024 17:17:07 +0200 (CEST) -From: Sebastian Reichel -To: Marek Vasut , u-boot@lists.denx.de, - Jonas Karlman , Soeren Moch -Cc: Eugen Hristev , - Tim Harvey , Kever Yang , - Philipp Tomsich , Simon Glass , - Sebastian Reichel -Subject: [PATCH v6 6/6] MAINTAINERS: add TCPM section -Date: Thu, 5 Sep 2024 17:08:42 +0200 -Message-ID: <20240905151707.59101-7-sebastian.reichel@collabora.com> -X-Mailer: git-send-email 2.45.2 -In-Reply-To: <20240905151707.59101-1-sebastian.reichel@collabora.com> -References: <20240905151707.59101-1-sebastian.reichel@collabora.com> -MIME-Version: 1.0 -X-BeenThere: u-boot@lists.denx.de -X-Mailman-Version: 2.1.39 -Precedence: list -List-Id: U-Boot discussion -List-Unsubscribe: , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: , - -Errors-To: u-boot-bounces@lists.denx.de -Sender: "U-Boot" -X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de -X-Virus-Status: Clean - -Add new section for USB TypeC Port Manager (TCPM) support, which -is needed to figure out cable orientation of USB-C plus and to do -USB PD communication. - -Signed-off-by: Sebastian Reichel ---- - MAINTAINERS | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/MAINTAINERS b/MAINTAINERS -index 2050ae24df82..f3cf84d20dbd 100644 ---- a/MAINTAINERS -+++ b/MAINTAINERS -@@ -1721,6 +1721,15 @@ F: common/usb_kbd.c - F: common/usb_storage.c - F: include/usb.h - -+USB TCPM -+M: Sebastian Reichel -+S: Maintained -+F: cmd/tcpm.c -+F: doc/usage/cmd/tcpm.rst -+F: drivers/usb/tcpm/ -+F: include/usb/pd.h -+F: include/usb/tcpm.h -+ - USB xHCI - M: Bin Meng - S: Maintained diff --git a/Fix-NVMe-not-only-on-Raspberry-Pi-5.patch b/Fix-NVMe-not-only-on-Raspberry-Pi-5.patch new file mode 100644 index 0000000..a52ce84 --- /dev/null +++ b/Fix-NVMe-not-only-on-Raspberry-Pi-5.patch @@ -0,0 +1,405 @@ +From patchwork Mon Jul 6 17:21:47 2026 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Torsten Duwe +X-Patchwork-Id: 2265604 +Return-Path: +X-Original-To: incoming@patchwork.ozlabs.org +Delivered-To: patchwork-incoming@legolas.ozlabs.org +Authentication-Results: legolas.ozlabs.org; + spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de + (client-ip=85.214.62.61; helo=phobos.denx.de; + envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) +Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) + key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) + (No client certificate requested) + by legolas.ozlabs.org (Postfix) with ESMTPS id 4gvB431Qwzz1xqc + for ; Tue, 07 Jul 2026 03:21:55 +1000 (AEST) +Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) + by phobos.denx.de (Postfix) with ESMTP id 179C084942; + Mon, 6 Jul 2026 19:21:52 +0200 (CEST) +Authentication-Results: phobos.denx.de; + dmarc=fail (p=none dis=none) header.from=lst.de +Authentication-Results: phobos.denx.de; + spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de +Received: by phobos.denx.de (Postfix, from userid 109) + id 82ADE8490A; Mon, 6 Jul 2026 19:21:51 +0200 (CEST) +X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de +X-Spam-Level: +X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, + RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham + autolearn_force=no version=3.4.2 +Received: from verein.lst.de (verein.lst.de [213.95.11.211]) + (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) + (No client certificate requested) + by phobos.denx.de (Postfix) with ESMTPS id 9F24C846B4 + for ; Mon, 6 Jul 2026 19:21:49 +0200 (CEST) +Authentication-Results: phobos.denx.de; + dmarc=fail (p=none dis=none) header.from=lst.de +Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=duwe@lst.de +Received: by verein.lst.de (Postfix, from userid 2005) + id C934268B05; Mon, 6 Jul 2026 19:21:47 +0200 (CEST) +In-Reply-To: <20260706172028.C148E68BEB@verein.lst.de> +References: <20260706172028.C148E68BEB@verein.lst.de> +Subject: [PATCH v2 1/4] core: Skip parent device nodes without a DT reference + when looking for dma-ranges +To: Neil Armstrong , + Andrew Goodbody , Bin Meng , + Simon Glass +Cc: Tom Rini , Matthias Brugger , + Peter Robinson , + Mattijs Korpershoek , + Marek Vasut , + Heiko Schocher , Svyatoslav Ryhel , + "Lucien.Jheng" , Rasmus Villemoes , + Martin Schwan , + "Markus Schneider-Pargmann (TI.com)" , + Prashant Kamble , + Denis Mukhin , Sughosh Ganu , + u-boot@lists.denx.de +Message-Id: <20260706172147.C934268B05@verein.lst.de> +Date: Mon, 6 Jul 2026 19:21:47 +0200 (CEST) +From: duwe@lst.de (Torsten Duwe) +X-BeenThere: u-boot@lists.denx.de +X-Mailman-Version: 2.1.39 +Precedence: list +List-Id: U-Boot discussion +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Errors-To: u-boot-bounces@lists.denx.de +Sender: "U-Boot" +X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de +X-Virus-Status: Clean + +From: Torsten Duwe + +If a device node got created dynamically, there is no guarantee that the +parent node has an associated device tree node which could specify dma +constraints. Especially PCI(e) enumeration adds intermediate "bus nodes", +also dynamically. + +Try harder to find the correct configuration by walking up the tree until +a DT association is found. + +Suggested-by: Neil Armstrong +Signed-off-by: Torsten Duwe +Reviewed-by: Peter Robinson +Tested-by: Peter Robinson +--- + drivers/core/device.c | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +diff --git a/drivers/core/device.c b/drivers/core/device.c +index d365204ba11..b6d00cf4714 100644 +--- a/drivers/core/device.c ++++ b/drivers/core/device.c +@@ -459,7 +459,19 @@ static int device_get_dma_constraints(struct udevice *dev) + u64 size = 0; + int ret; + +- if (!CONFIG_IS_ENABLED(DM_DMA) || !parent || !dev_has_ofnode(parent)) ++ if (!CONFIG_IS_ENABLED(DM_DMA) || !parent) ++ return 0; ++ ++ /* Look for the first node in the parent chain */ ++ while (parent) { ++ if (dev_has_ofnode(parent)) ++ break; ++ ++ parent = dev_get_parent(parent); ++ } ++ ++ /* No parents have a node, bail out */ ++ if (!parent) + return 0; + + /* + +From patchwork Mon Jul 6 17:21:50 2026 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Torsten Duwe +X-Patchwork-Id: 2265605 +Return-Path: +X-Original-To: incoming@patchwork.ozlabs.org +Delivered-To: patchwork-incoming@legolas.ozlabs.org +Authentication-Results: legolas.ozlabs.org; + spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de + (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; + envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) +Received: from phobos.denx.de (phobos.denx.de + [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) + key-exchange x25519) + (No client certificate requested) + by legolas.ozlabs.org (Postfix) with ESMTPS id 4gvB481pfXz1xqc + for ; Tue, 07 Jul 2026 03:22:00 +1000 (AEST) +Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) + by phobos.denx.de (Postfix) with ESMTP id 9A59684994; + Mon, 6 Jul 2026 19:21:55 +0200 (CEST) +Authentication-Results: phobos.denx.de; + dmarc=fail (p=none dis=none) header.from=lst.de +Authentication-Results: phobos.denx.de; + spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de +Received: by phobos.denx.de (Postfix, from userid 109) + id EB7D384979; Mon, 6 Jul 2026 19:21:53 +0200 (CEST) +X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de +X-Spam-Level: +X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, + RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham + autolearn_force=no version=3.4.2 +Received: from verein.lst.de (verein.lst.de [213.95.11.211]) + (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) + (No client certificate requested) + by phobos.denx.de (Postfix) with ESMTPS id EE61C846B4 + for ; Mon, 6 Jul 2026 19:21:51 +0200 (CEST) +Authentication-Results: phobos.denx.de; + dmarc=fail (p=none dis=none) header.from=lst.de +Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=duwe@lst.de +Received: by verein.lst.de (Postfix, from userid 2005) + id 464E868BEB; Mon, 6 Jul 2026 19:21:50 +0200 (CEST) +In-Reply-To: <20260706172028.C148E68BEB@verein.lst.de> +References: <20260706172028.C148E68BEB@verein.lst.de> +Subject: [PATCH v2 2/4] test: Add a unit test in phys_to_bus for dynamically + created device nodes +To: Neil Armstrong , + Andrew Goodbody , Bin Meng , + Simon Glass +Cc: Tom Rini , Matthias Brugger , + Peter Robinson , + Mattijs Korpershoek , + Marek Vasut , + Heiko Schocher , Svyatoslav Ryhel , + "Lucien.Jheng" , Rasmus Villemoes , + Martin Schwan , + "Markus Schneider-Pargmann (TI.com)" , + Prashant Kamble , + Denis Mukhin , Sughosh Ganu , + u-boot@lists.denx.de +Message-Id: <20260706172150.464E868BEB@verein.lst.de> +Date: Mon, 6 Jul 2026 19:21:50 +0200 (CEST) +From: duwe@lst.de (Torsten Duwe) +X-BeenThere: u-boot@lists.denx.de +X-Mailman-Version: 2.1.39 +Precedence: list +List-Id: U-Boot discussion +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Errors-To: u-boot-bounces@lists.denx.de +Sender: "U-Boot" +X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de +X-Virus-Status: Clean + +From: Torsten Duwe + +In order to test whether device_get_dma_constraints() is now able to skip +device nodes without a DT association, temporarily remove those on 2 newly- +created nodes. + +Signed-off-by: Torsten Duwe +--- + +This test indeed makes a different whether the previous change is +applied or not, but *only* reliably for the non-flat-tree case (!?). +On the flat tree, it always fails after (reverse) applying it. + +Either the previous patch is incomplete, or, more likely, the test +assumptions here are not all valid. Suggestions welcome (especially +how to create device nodes from a device tree without a reference to +their origin ;-) + +--- + arch/sandbox/dts/test.dts | 9 +++++++++ + test/dm/phys2bus.c | 25 ++++++++++++++++++++++++- + 2 files changed, 33 insertions(+), 1 deletion(-) + +diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts +index 0887de4333b..1d92e85c739 100644 +--- a/arch/sandbox/dts/test.dts ++++ b/arch/sandbox/dts/test.dts +@@ -656,6 +656,15 @@ + subnode@0 { + compatible = "denx,u-boot-fdt-test"; + }; ++ bus@7 { ++ #address-cells = <1>; ++ #size-cells = <1>; ++ compatible = "denx,u-boot-test-bus"; ++ ++ subnode@8 { ++ compatible = "denx,u-boot-fdt-test"; ++ }; ++ }; + }; + + mmio-bus@1 { +diff --git a/test/dm/phys2bus.c b/test/dm/phys2bus.c +index 67f33904943..858ed5410e2 100644 +--- a/test/dm/phys2bus.c ++++ b/test/dm/phys2bus.c +@@ -15,7 +15,8 @@ + + static int dm_test_phys_to_bus(struct unit_test_state *uts) + { +- struct udevice *dev; ++ struct udevice *dev, *pdev; ++ ofnode psave, nsave; + ofnode node; + + node = ofnode_path("/mmio-bus@0"); +@@ -31,6 +32,29 @@ static int dm_test_phys_to_bus(struct unit_test_state *uts) + ut_asserteq_addr((void*)0x1003ffffULL, (void*)dev_phys_to_bus(dev, 0x3ffff)); + ut_asserteq_addr((void*)0x3ffffULL, (void*)(ulong)dev_bus_to_phys(dev, 0x1003ffff)); + ++#if CONFIG_IS_ENABLED(OF_REAL) ++ /* dma-ranges are on the grandparent bus node, ++ * OF nodes neither here nor at parent ++ */ ++ node = ofnode_path("/mmio-bus@0/bus@7"); ++ ut_assert(ofnode_valid(node)); ++ ut_assertok(uclass_get_device_by_ofnode(UCLASS_TEST_BUS, node, &pdev)); ++ ++ /* pretend the devices were discovered dynamically and have no OF node */ ++ psave = pdev->node_; ++ pdev->node_.np = NULL; ++ node = ofnode_path("/mmio-bus@0/bus@7/subnode@8"); ++ ut_assert(ofnode_valid(node)); ++ nsave = dev->node_; ++ dev->node_.np = NULL; ++ ut_assertok(uclass_get_device_by_ofnode(UCLASS_TEST_FDT, node, &dev)); ++ ++ ut_asserteq_addr((void *)0x1003ffffULL, (void *)dev_phys_to_bus(dev, 0x3ffff)); ++ ut_asserteq_addr((void *)0x3ffffULL, (void *)(ulong)dev_bus_to_phys(dev, 0x1003ffff)); ++ ++ pdev->node_ = psave; ++ dev->node_ = nsave; ++#endif + return 0; + } + DM_TEST(dm_test_phys_to_bus, UTF_SCAN_PDATA | UTF_SCAN_FDT); + +From patchwork Mon Jul 6 17:21:54 2026 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Torsten Duwe +X-Patchwork-Id: 2265607 +Return-Path: +X-Original-To: incoming@patchwork.ozlabs.org +Delivered-To: patchwork-incoming@legolas.ozlabs.org +Authentication-Results: legolas.ozlabs.org; + spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de + (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; + envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) +Received: from phobos.denx.de (phobos.denx.de + [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) + key-exchange x25519) + (No client certificate requested) + by legolas.ozlabs.org (Postfix) with ESMTPS id 4gvB4R378Lz1xqc + for ; Tue, 07 Jul 2026 03:22:15 +1000 (AEST) +Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) + by phobos.denx.de (Postfix) with ESMTP id 3FDAE8490A; + Mon, 6 Jul 2026 19:21:59 +0200 (CEST) +Authentication-Results: phobos.denx.de; + dmarc=fail (p=none dis=none) header.from=lst.de +Authentication-Results: phobos.denx.de; + spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de +Received: by phobos.denx.de (Postfix, from userid 109) + id 17F418490A; Mon, 6 Jul 2026 19:21:58 +0200 (CEST) +X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de +X-Spam-Level: +X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, + RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham + autolearn_force=no version=3.4.2 +Received: from verein.lst.de (verein.lst.de [213.95.11.211]) + (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) + (No client certificate requested) + by phobos.denx.de (Postfix) with ESMTPS id 1D593849A4 + for ; Mon, 6 Jul 2026 19:21:56 +0200 (CEST) +Authentication-Results: phobos.denx.de; + dmarc=fail (p=none dis=none) header.from=lst.de +Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=duwe@lst.de +Received: by verein.lst.de (Postfix, from userid 2005) + id B506B68CFE; Mon, 6 Jul 2026 19:21:54 +0200 (CEST) +In-Reply-To: <20260706172028.C148E68BEB@verein.lst.de> +References: <20260706172028.C148E68BEB@verein.lst.de> +Subject: [PATCH v2 4/4] configs: enable NVMe +To: Neil Armstrong , + Andrew Goodbody , Bin Meng , + Simon Glass +Cc: Tom Rini , Matthias Brugger , + Peter Robinson , + Mattijs Korpershoek , + Marek Vasut , + Heiko Schocher , Svyatoslav Ryhel , + "Lucien.Jheng" , Rasmus Villemoes , + Martin Schwan , + "Markus Schneider-Pargmann (TI.com)" , + Prashant Kamble , + Denis Mukhin , Sughosh Ganu , + u-boot@lists.denx.de +Message-Id: <20260706172154.B506B68CFE@verein.lst.de> +Date: Mon, 6 Jul 2026 19:21:54 +0200 (CEST) +From: duwe@lst.de (Torsten Duwe) +X-BeenThere: u-boot@lists.denx.de +X-Mailman-Version: 2.1.39 +Precedence: list +List-Id: U-Boot discussion +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Errors-To: u-boot-bounces@lists.denx.de +Sender: "U-Boot" +X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de +X-Virus-Status: Clean + +From: Torsten Duwe + +Enable NVMe in the Raspberry Pi 64-Bit default config and scan for devices. + +Signed-off-by: Torsten Duwe +Reviewed-by: Peter Robinson +Tested-by: Peter Robinson +--- + configs/rpi_arm64_defconfig | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/configs/rpi_arm64_defconfig b/configs/rpi_arm64_defconfig +index cdcf05ea6db..fb0fdce1d7f 100644 +--- a/configs/rpi_arm64_defconfig ++++ b/configs/rpi_arm64_defconfig +@@ -16,7 +16,7 @@ CONFIG_BOOTSTD_DEFAULTS=y + CONFIG_OF_BOARD_SETUP=y + CONFIG_FDT_SIMPLEFB=y + CONFIG_USE_PREBOOT=y +-CONFIG_PREBOOT="pci enum; usb start;" ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_SYS_PBSIZE=1049 + # CONFIG_DISPLAY_CPUINFO is not set + # CONFIG_DISPLAY_BOARDINFO is not set +@@ -44,6 +44,7 @@ CONFIG_MMC_SDHCI_SDMA=y + CONFIG_MMC_SDHCI_BCM2835=y + CONFIG_MMC_SDHCI_BCMSTB=y + CONFIG_BCMGENET=y ++CONFIG_NVME_PCI=y + CONFIG_PCI_BRCMSTB=y + CONFIG_PINCTRL=y + # CONFIG_PINCTRL_GENERIC is not set diff --git a/JetsonTX2-Fix-upstream-device-tree-naming.patch b/JetsonTX2-Fix-upstream-device-tree-naming.patch new file mode 100644 index 0000000..14242ce --- /dev/null +++ b/JetsonTX2-Fix-upstream-device-tree-naming.patch @@ -0,0 +1,50 @@ +From 4ee5ba36570d94ce27e4023f15b8b3a6b8b9daf9 Mon Sep 17 00:00:00 2001 +From: Peter Robinson +Date: Mon, 13 Oct 2025 21:41:13 +0100 +Subject: [PATCH] config: JetsonTX2: Fix upstream device tree naming + +The upstream naming for the Jetson TX2 is p2771-0000 so fix +the device tree name so the firmware will find the right +name on disk. + +Signed-off-by: Peter Robinson +--- + arch/arm/dts/Makefile | 2 +- + .../{tegra186-p2771-0000-500.dts => tegra186-p2771-0000.dts} | 0 + configs/p2771-0000-500_defconfig | 2 +- + 3 files changed, 2 insertions(+), 2 deletions(-) + rename arch/arm/dts/{tegra186-p2771-0000-500.dts => tegra186-p2771-0000.dts} (100%) + +diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile +index 7c8cf3a5a1d..86a7b4fda35 100644 +--- a/arch/arm/dts/Makefile ++++ b/arch/arm/dts/Makefile +@@ -134,7 +134,7 @@ dtb-$(CONFIG_ARCH_TEGRA) += \ + tegra124-venice2.dtb \ + tegra124-xiaomi-mocha.dtb \ + tegra186-p2771-0000-000.dtb \ +- tegra186-p2771-0000-500.dtb \ ++ tegra186-p2771-0000.dtb \ + tegra210-p2371-0000.dtb \ + tegra210-p2371-2180.dtb \ + tegra210-p2571.dtb \ +diff --git a/arch/arm/dts/tegra186-p2771-0000-500.dts b/arch/arm/dts/tegra186-p2771-0000.dts +similarity index 100% +rename from arch/arm/dts/tegra186-p2771-0000-500.dts +rename to arch/arm/dts/tegra186-p2771-0000.dts +diff --git a/configs/p2771-0000-500_defconfig b/configs/p2771-0000-500_defconfig +index 42043277e2d..e1e5c47ddfa 100644 +--- a/configs/p2771-0000-500_defconfig ++++ b/configs/p2771-0000-500_defconfig +@@ -7,7 +7,7 @@ CONFIG_TEXT_BASE=0x80080000 + CONFIG_NR_DRAM_BANKS=1026 + CONFIG_ENV_SIZE=0x2000 + CONFIG_ENV_OFFSET=0xFFFFE000 +-CONFIG_DEFAULT_DEVICE_TREE="tegra186-p2771-0000-500" ++CONFIG_DEFAULT_DEVICE_TREE="tegra186-p2771-0000" + CONFIG_SYS_BOOTM_LEN=0x800000 + CONFIG_SYS_LOAD_ADDR=0x80080000 + CONFIG_TEGRA186=y +-- +2.51.0 + diff --git a/Qualcomm-add-support-for-SC7280-and-the-RB3-Gen-2.patch b/Qualcomm-add-support-for-SC7280-and-the-RB3-Gen-2.patch deleted file mode 100644 index 0dec1ea..0000000 --- a/Qualcomm-add-support-for-SC7280-and-the-RB3-Gen-2.patch +++ /dev/null @@ -1,1414 +0,0 @@ -From patchwork Wed Aug 21 13:41:46 2024 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Caleb Connolly -X-Patchwork-Id: 1974970 -X-Patchwork-Delegate: caleb.connolly@linaro.org -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - dkim=pass (2048-bit key; - unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 - header.s=google header.b=BpF9pRLA; - dkim-atps=neutral -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de - [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1)) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4WpnZD73RJz1yXf - for ; Wed, 21 Aug 2024 23:42:12 +1000 (AEST) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id 99F6188D9B; - Wed, 21 Aug 2024 15:42:00 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=linaro.org -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de -Authentication-Results: phobos.denx.de; - dkim=pass (2048-bit key; - unprotected) header.d=linaro.org header.i=@linaro.org header.b="BpF9pRLA"; - dkim-atps=neutral -Received: by phobos.denx.de (Postfix, from userid 109) - id 86A7E88D9B; Wed, 21 Aug 2024 15:41:58 +0200 (CEST) -X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de -X-Spam-Level: -X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, - DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, - T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 -Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com - [IPv6:2a00:1450:4864:20::133]) - (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) - (No client certificate requested) - by phobos.denx.de (Postfix) with ESMTPS id 896B7887D4 - for ; Wed, 21 Aug 2024 15:41:55 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=linaro.org -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=caleb.connolly@linaro.org -Received: by mail-lf1-x133.google.com with SMTP id - 2adb3069b0e04-5333b2fbedaso4381657e87.0 - for ; Wed, 21 Aug 2024 06:41:55 -0700 (PDT) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=linaro.org; s=google; t=1724247715; x=1724852515; darn=lists.denx.de; - h=cc:to:in-reply-to:references:message-id:content-transfer-encoding - :mime-version:subject:date:from:from:to:cc:subject:date:message-id - :reply-to; bh=vYpvXZhAM0wjWc6QeTnHyYsF2xjKAb2Bg/9VNGJ7oC4=; - b=BpF9pRLArbhamTTSvF+LPOjqIaruq3137+Td+Y4qA32sBPKjZN2zyabjh/Rafnr5O1 - 9d/0nOcXmbKi3CTtdUN3qV19169r8d2lAuPiUwXoxGf4v9wPlXv1TnQilC0/IpdephxJ - oRj9+5DwMh1C/THNGdn6N9M7PrZ33uVwOawlqlGPGaBUlZzEtdpeQt8mGBT72vsWTwEc - g9XIuP7GYNy3Ztzy8JMYfvFT0MCUQmkDb9anAIfRkARVMxMTI3X0lz9nXqhgNHGXF/vc - tw9UbbFQc5bsonufEXl0cg3x4yHX3dzV2NcPvnGJWBUgHbNoQ1dUvmUD8ivz8xpCGh95 - /uLg== -X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=1e100.net; s=20230601; t=1724247715; x=1724852515; - h=cc:to:in-reply-to:references:message-id:content-transfer-encoding - :mime-version:subject:date:from:x-gm-message-state:from:to:cc - :subject:date:message-id:reply-to; - bh=vYpvXZhAM0wjWc6QeTnHyYsF2xjKAb2Bg/9VNGJ7oC4=; - b=F/jmt2BY3txUp2Xo6ouNkmlNd7uQWuOBEkIGKUIwLL3jKl7uBJ/Ptt5k5n2REXJ3RX - qQv2x7FQlJXgvIfdnyr82QJx4EA7lV3SciLcJsTQMrrE0URCNMdIzUgMi0Su+QUw2rkH - 3F6BNFc2AUknW7ohrfLBnJWKHecIEJy7NbLcVve5RxNTga9md5WoIqlyL0PMo+pbTH/P - t4upinI57g3mt/aAFxlETKF7TY9fUiDnKfmp6NNkTAYVemvziHPE4LO78hHLLRggdYJE - li/V+pZa6jdmhd9c2wPO7Qlhlw3i48ti0LmA6PBMgebLO+YTAXf2pUpLQl4gdayX4WJr - 21qA== -X-Gm-Message-State: AOJu0YzCxBg0ApyZrMj/flKnSEzT/WdNXsTISMZEYTB2A2c9+9pYoTt8 - Y4o4D/Wn7JKEhGJS9pejsVJGp3BVDAbME2fz2uL63aeV9h8aeA7aQIfST443wEE= -X-Google-Smtp-Source: - AGHT+IHwtmpvp1KyCpCFrQ9m8b9mZocGdoGZKOOBbCOdWXgPOOaJpvIzD+wO9cPMXI0xJJ299Vb3aw== -X-Received: by 2002:a05:6512:2526:b0:533:4b07:a8dc with SMTP id - 2adb3069b0e04-5334b07a924mr853860e87.35.1724247714485; - Wed, 21 Aug 2024 06:41:54 -0700 (PDT) -Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::676e]) - by smtp.gmail.com with ESMTPSA id - a640c23a62f3a-a83839342f6sm904164066b.137.2024.08.21.06.41.53 - (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); - Wed, 21 Aug 2024 06:41:53 -0700 (PDT) -From: Caleb Connolly -Date: Wed, 21 Aug 2024 15:41:46 +0200 -Subject: [PATCH v2 1/7] clk/qcom: add initial clock driver for sc7280 -MIME-Version: 1.0 -Message-Id: <20240821-b4-rb3gen2-v2-1-49b07633f3a8@linaro.org> -References: <20240821-b4-rb3gen2-v2-0-49b07633f3a8@linaro.org> -In-Reply-To: <20240821-b4-rb3gen2-v2-0-49b07633f3a8@linaro.org> -To: Tom Rini , Lukasz Majewski , - Sean Anderson , - Caleb Connolly , - Neil Armstrong , - Sumit Garg -Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io -X-Mailer: b4 0.14-dev -X-Developer-Signature: v=1; a=openpgp-sha256; l=6610; - i=caleb.connolly@linaro.org; h=from:subject:message-id; - bh=Ml3U758Os52kpw+GNgmPmB5Bs0weI+7Cu8LeGmVUjJs=; - b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmxe6dj9dkbc0E3zPhQL/6lm1ahALcexDRPoBcO - ng26jm+QUiJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZsXunQAKCRAFgzErGV9k - ttaKD/9DtqMqfY7Do5CxJU3qRYk5ZmdeMIF9JTXN0APLu1fGGMznfgoUn93safNuzgw/exm5CNI - rSoCXHGtBpKM+SWjYe9ir4C7PQqdJt0J5vgdUOHVqfy87jgC4RQkE6HUDCtd9s1HitZNCtiZGrs - BeJ7SVOrAakL3QgXCssgvhDmNmQoMDd5l1lTXL9p5RQTVAZuQuihQJ1fcVtXVH9DlYidlvNdwKZ - wLXps20Hc7uStWohI/+MtDq5OzwxfEXVLBOktJ8cR26UZ1N5pFItdarRZpmJCJFtWU4ORyamCKW - EcPSjaDo7r2GT7CbiILoXpsQLGX5SNrEWFAFQJKUjAyHe0x2H0394aVGd4Yt9kFBG8KSvhzwsVq - tVzpKmy0oe/2CCcVsRHhT4b1j7H+MiudmxYpUByqcljtWKm/0Nd6C42oqHSs4NP+DRHHPzDGpxm - Bzaex1Y5tkwivXqgISlHEX99R605X8KWM3LJnKMPBU5qdHN7x1/8tdcpsnCHd/+AobL+Ty7gaH4 - CXqmB2zZY/1VAhboMRJnDaOooBlBlGfaiMu9/sOpQJo0xWPYtANjyli/9TIsBSBkctEAa4rv0WN - ruiueb3HXdDqzPGpcaVMnApPjkNEUGiMlhaJKTJPcBuIDaC0uNwquaRv7fmLRE5oqWlX1uQ7Seu - fUzYzzESEzLWSGg== -X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; - fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 -X-BeenThere: u-boot@lists.denx.de -X-Mailman-Version: 2.1.39 -Precedence: list -List-Id: U-Boot discussion -List-Unsubscribe: , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: , - -Errors-To: u-boot-bounces@lists.denx.de -Sender: "U-Boot" -X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de -X-Virus-Status: Clean - -We don't actually need any clocks to get UFS up and running, resets are -useful though. - -Reviewed-by: Neil Armstrong -Signed-off-by: Caleb Connolly ---- - drivers/clk/qcom/Kconfig | 8 +++ - drivers/clk/qcom/Makefile | 1 + - drivers/clk/qcom/clock-qcom.h | 1 + - drivers/clk/qcom/clock-sc7280.c | 132 ++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 142 insertions(+) - -diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig -index 45d63c6d6dbf..0d2c0ac225c5 100644 ---- a/drivers/clk/qcom/Kconfig -+++ b/drivers/clk/qcom/Kconfig -@@ -85,7 +85,15 @@ config CLK_QCOM_SM8650 - Say Y here to enable support for the Global Clock Controller - on the Snapdragon SM8650 SoC. This driver supports the clocks - and resets exposed by the GCC hardware block. - -+config CLK_QCOM_SC7280 -+ bool "Qualcomm SC7280 GCC" -+ select CLK_QCOM -+ help -+ Say Y here to enable support for the Global Clock Controller -+ on the Snapdragon SC7280 SoC. This driver supports the clocks -+ and resets exposed by the GCC hardware block. -+ - endmenu - - endif -diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile -index dec20e4b5943..e223c131ee4d 100644 ---- a/drivers/clk/qcom/Makefile -+++ b/drivers/clk/qcom/Makefile -@@ -8,8 +8,9 @@ obj-$(CONFIG_CLK_QCOM_APQ8016) += clock-apq8016.o - obj-$(CONFIG_CLK_QCOM_APQ8096) += clock-apq8096.o - obj-$(CONFIG_CLK_QCOM_IPQ4019) += clock-ipq4019.o - obj-$(CONFIG_CLK_QCOM_QCM2290) += clock-qcm2290.o - obj-$(CONFIG_CLK_QCOM_QCS404) += clock-qcs404.o -+obj-$(CONFIG_CLK_QCOM_SC7280) += clock-sc7280.o - obj-$(CONFIG_CLK_QCOM_SM6115) += clock-sm6115.o - obj-$(CONFIG_CLK_QCOM_SM8250) += clock-sm8250.o - obj-$(CONFIG_CLK_QCOM_SM8550) += clock-sm8550.o - obj-$(CONFIG_CLK_QCOM_SM8650) += clock-sm8650.o -diff --git a/drivers/clk/qcom/clock-qcom.h b/drivers/clk/qcom/clock-qcom.h -index f6445c8f566f..7aa6ca59aad5 100644 ---- a/drivers/clk/qcom/clock-qcom.h -+++ b/drivers/clk/qcom/clock-qcom.h -@@ -10,8 +10,9 @@ - #define CFG_CLK_SRC_CXO (0 << 8) - #define CFG_CLK_SRC_GPLL0 (1 << 8) - #define CFG_CLK_SRC_GPLL0_AUX2 (2 << 8) - #define CFG_CLK_SRC_GPLL9 (2 << 8) -+#define CFG_CLK_SRC_GPLL0_ODD (3 << 8) - #define CFG_CLK_SRC_GPLL6 (4 << 8) - #define CFG_CLK_SRC_GPLL7 (3 << 8) - #define CFG_CLK_SRC_GPLL4 (5 << 8) - #define CFG_CLK_SRC_GPLL0_EVEN (6 << 8) -diff --git a/drivers/clk/qcom/clock-sc7280.c b/drivers/clk/qcom/clock-sc7280.c -new file mode 100644 -index 000000000000..5d343f120519 ---- /dev/null -+++ b/drivers/clk/qcom/clock-sc7280.c -@@ -0,0 +1,132 @@ -+// SPDX-License-Identifier: GPL-2.0 -+/* -+ * Clock drivers for Qualcomm sc7280 -+ * -+ * (C) Copyright 2024 Linaro Ltd. -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "clock-qcom.h" -+ -+#define USB30_PRIM_MOCK_UTMI_CLK_CMD_RCGR 0xf038 -+#define USB30_PRIM_MASTER_CLK_CMD_RCGR 0xf020 -+ -+static ulong sc7280_set_rate(struct clk *clk, ulong rate) -+{ -+ struct msm_clk_priv *priv = dev_get_priv(clk->dev); -+ -+ if (clk->id < priv->data->num_clks) -+ debug("%s: %s, requested rate=%ld\n", __func__, priv->data->clks[clk->id].name, rate); -+ -+ switch (clk->id) { -+ case GCC_USB30_PRIM_MOCK_UTMI_CLK: -+ WARN(rate != 19200000, "Unexpected rate for USB30_PRIM_MOCK_UTMI_CLK: %lu\n", rate); -+ clk_rcg_set_rate(priv->base, USB30_PRIM_MASTER_CLK_CMD_RCGR, 0, CFG_CLK_SRC_CXO); -+ return rate; -+ case GCC_USB30_PRIM_MASTER_CLK: -+ WARN(rate != 200000000, "Unexpected rate for USB30_PRIM_MASTER_CLK: %lu\n", rate); -+ clk_rcg_set_rate_mnd(priv->base, USB30_PRIM_MASTER_CLK_CMD_RCGR, -+ 1, 0, 0, CFG_CLK_SRC_GPLL0_ODD, 8); -+ clk_rcg_set_rate(priv->base, 0xf064, 0, 0); -+ return rate; -+ default: -+ return 0; -+ } -+} -+ -+static const struct gate_clk sc7280_clks[] = { -+ GATE_CLK(GCC_CFG_NOC_USB3_PRIM_AXI_CLK, 0xf07c, 1), -+ GATE_CLK(GCC_USB30_PRIM_MASTER_CLK, 0xf010, 1), -+ GATE_CLK(GCC_AGGRE_USB3_PRIM_AXI_CLK, 0xf080, 1), -+ GATE_CLK(GCC_USB30_PRIM_SLEEP_CLK, 0xf018, 1), -+ GATE_CLK(GCC_USB30_PRIM_MOCK_UTMI_CLK, 0xf01c, 1), -+ GATE_CLK(GCC_USB3_PRIM_PHY_AUX_CLK, 0xf054, 1), -+ GATE_CLK(GCC_USB3_PRIM_PHY_COM_AUX_CLK, 0xf058, 1), -+}; -+ -+static int sc7280_enable(struct clk *clk) -+{ -+ struct msm_clk_priv *priv = dev_get_priv(clk->dev); -+ -+ if (priv->data->num_clks < clk->id) { -+ debug("%s: unknown clk id %lu\n", __func__, clk->id); -+ return 0; -+ } -+ -+ debug("%s: clk %ld: %s\n", __func__, clk->id, sc7280_clks[clk->id].name); -+ -+ switch (clk->id) { -+ case GCC_AGGRE_USB3_PRIM_AXI_CLK: -+ qcom_gate_clk_en(priv, GCC_USB30_PRIM_MASTER_CLK); -+ fallthrough; -+ case GCC_USB30_PRIM_MASTER_CLK: -+ qcom_gate_clk_en(priv, GCC_USB3_PRIM_PHY_AUX_CLK); -+ qcom_gate_clk_en(priv, GCC_USB3_PRIM_PHY_COM_AUX_CLK); -+ break; -+ } -+ -+ qcom_gate_clk_en(priv, clk->id); -+ -+ return 0; -+} -+ -+static const struct qcom_reset_map sc7280_gcc_resets[] = { -+ [GCC_PCIE_0_BCR] = { 0x6b000 }, -+ [GCC_PCIE_0_PHY_BCR] = { 0x6c01c }, -+ [GCC_PCIE_1_BCR] = { 0x8d000 }, -+ [GCC_PCIE_1_PHY_BCR] = { 0x8e01c }, -+ [GCC_QUSB2PHY_PRIM_BCR] = { 0x12000 }, -+ [GCC_QUSB2PHY_SEC_BCR] = { 0x12004 }, -+ [GCC_SDCC1_BCR] = { 0x75000 }, -+ [GCC_SDCC2_BCR] = { 0x14000 }, -+ [GCC_SDCC4_BCR] = { 0x16000 }, -+ [GCC_UFS_PHY_BCR] = { 0x77000 }, -+ [GCC_USB30_PRIM_BCR] = { 0xf000 }, -+ [GCC_USB30_SEC_BCR] = { 0x9e000 }, -+ [GCC_USB3_DP_PHY_PRIM_BCR] = { 0x50008 }, -+ [GCC_USB3_PHY_PRIM_BCR] = { 0x50000 }, -+ [GCC_USB3PHY_PHY_PRIM_BCR] = { 0x50004 }, -+ [GCC_USB_PHY_CFG_AHB2PHY_BCR] = { 0x6a000 }, -+}; -+ -+static const struct qcom_power_map sc7280_gdscs[] = { -+ [GCC_UFS_PHY_GDSC] = { 0x77004 }, -+ [GCC_USB30_PRIM_GDSC] = { 0xf004 }, -+}; -+ -+static struct msm_clk_data qcs404_gcc_data = { -+ .resets = sc7280_gcc_resets, -+ .num_resets = ARRAY_SIZE(sc7280_gcc_resets), -+ .clks = sc7280_clks, -+ .num_clks = ARRAY_SIZE(sc7280_clks), -+ -+ .power_domains = sc7280_gdscs, -+ .num_power_domains = ARRAY_SIZE(sc7280_gdscs), -+ -+ .enable = sc7280_enable, -+ .set_rate = sc7280_set_rate, -+}; -+ -+static const struct udevice_id gcc_sc7280_of_match[] = { -+ { -+ .compatible = "qcom,gcc-sc7280", -+ .data = (ulong)&qcs404_gcc_data, -+ }, -+ { } -+}; -+ -+U_BOOT_DRIVER(gcc_sc7280) = { -+ .name = "gcc_sc7280", -+ .id = UCLASS_NOP, -+ .of_match = gcc_sc7280_of_match, -+ .bind = qcom_cc_bind, -+ .flags = DM_FLAG_PRE_RELOC | DM_FLAG_DEFAULT_PD_CTRL_OFF, -+}; - -From patchwork Wed Aug 21 13:41:47 2024 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Caleb Connolly -X-Patchwork-Id: 1974971 -X-Patchwork-Delegate: caleb.connolly@linaro.org -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - dkim=pass (2048-bit key; - unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 - header.s=google header.b=D8cipZN8; - dkim-atps=neutral -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de - [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1)) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4WpnZS1lFqz1yXf - for ; Wed, 21 Aug 2024 23:42:24 +1000 (AEST) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id 2404B88DB7; - Wed, 21 Aug 2024 15:42:01 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=linaro.org -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de -Authentication-Results: phobos.denx.de; - dkim=pass (2048-bit key; - unprotected) header.d=linaro.org header.i=@linaro.org header.b="D8cipZN8"; - dkim-atps=neutral -Received: by phobos.denx.de (Postfix, from userid 109) - id CF84288B3C; Wed, 21 Aug 2024 15:41:58 +0200 (CEST) -X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de -X-Spam-Level: -X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, - DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, - T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 -Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com - [IPv6:2a00:1450:4864:20::22f]) - (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) - (No client certificate requested) - by phobos.denx.de (Postfix) with ESMTPS id BC82A88AC0 - for ; Wed, 21 Aug 2024 15:41:56 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=linaro.org -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=caleb.connolly@linaro.org -Received: by mail-lj1-x22f.google.com with SMTP id - 38308e7fff4ca-2f136e23229so67636651fa.1 - for ; Wed, 21 Aug 2024 06:41:56 -0700 (PDT) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=linaro.org; s=google; t=1724247716; x=1724852516; darn=lists.denx.de; - h=cc:to:in-reply-to:references:message-id:content-transfer-encoding - :mime-version:subject:date:from:from:to:cc:subject:date:message-id - :reply-to; bh=BtQqdiFk/5BGUCz4O21vl/84vcKElfs3QSU/TjahAhA=; - b=D8cipZN8vnM60gNnxvkm4MeJi0YUs2ejIG0MSF/WWYvpmyESE3mh38i9CQho0bxU6i - iX63Dsb/6xtE1YF26oNdy6430/ePndpn9VXSnZ4+c+0j1Er/qSEXlX7/BzwYSxhKFXP2 - /F6RsyF3R5s2HPndcU3OSppiLYNDSZZFa5XBwBVgNsjEoAOmVBZspDGJXberoFWSw1Xd - jvCW7H8KY4DgeuHAJAF1udHYqYfpDTGmijGk1cl6yddFZ4BX5AHEetjJMm6/Sfs0rYEE - D0REEYmHiwa1dm8mN6J+XMp2tgzg/8RPlQ5p4k9lcZlrCuZ7TnFF+HgnR7TLnMaOY5WI - DeWw== -X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=1e100.net; s=20230601; t=1724247716; x=1724852516; - h=cc:to:in-reply-to:references:message-id:content-transfer-encoding - :mime-version:subject:date:from:x-gm-message-state:from:to:cc - :subject:date:message-id:reply-to; - bh=BtQqdiFk/5BGUCz4O21vl/84vcKElfs3QSU/TjahAhA=; - b=P16tCzEGlwXh2HUe2zkd2EwD+lVsUJ2nv3xZT1gSdJfgv9uFCy5uHQOHx+GfyeFiFB - ZTZeGSznoCm+BqR4Rw1gx+Pw4M5rk38MOzZj6eb1PVfM7DKBk1C0g3ddxLBWvXwGky/P - /PMojneROHfJG+HpIjemGUIP4Cnbl+J0M1VqM1cJazIQocK+IpbqphhjI7IDKfPwZz0O - Cxn70edXPpLuZvBwbSJEk5zEyh+2b0oiyPP8VwzVfimOrP0nSJ/TkZiKVgEAVBmiRq1c - hpW2xFrDixDe+Ioa2hCXcbsIoDf8EyCdmxWVIiA8h4xsXfXpSbgDCAgBz0wi9Uw3Jy/h - LRZg== -X-Gm-Message-State: AOJu0Yz5oP45hJMUwyK8DU9sBL6vYfuGjHAeVLt3bxXXNCuBLvCzIx7F - gF97feq0wgpXLIEQ7uqwcBXQ46wbHQs8IEvoNGTarDCXSFeggfCqEC7oDzM4U48= -X-Google-Smtp-Source: - AGHT+IFRfsXmk97RBDrPRNGuRiWGpZ4udOpM/gdavhIAP7Vw5jIX1oJ1BZ6+tqyctFDutWKn/+6X5g== -X-Received: by 2002:ac2:4e09:0:b0:52f:2ea:499f with SMTP id - 2adb3069b0e04-5334855d512mr1561479e87.24.1724247715821; - Wed, 21 Aug 2024 06:41:55 -0700 (PDT) -Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::676e]) - by smtp.gmail.com with ESMTPSA id - a640c23a62f3a-a83839342f6sm904164066b.137.2024.08.21.06.41.54 - (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); - Wed, 21 Aug 2024 06:41:55 -0700 (PDT) -From: Caleb Connolly -Date: Wed, 21 Aug 2024 15:41:47 +0200 -Subject: [PATCH v2 2/7] dts: qcs6490-rb3gen2-u-boot: add override dtsi -MIME-Version: 1.0 -Message-Id: <20240821-b4-rb3gen2-v2-2-49b07633f3a8@linaro.org> -References: <20240821-b4-rb3gen2-v2-0-49b07633f3a8@linaro.org> -In-Reply-To: <20240821-b4-rb3gen2-v2-0-49b07633f3a8@linaro.org> -To: Tom Rini , Lukasz Majewski , - Sean Anderson , - Caleb Connolly , - Neil Armstrong , - Sumit Garg -Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io -X-Mailer: b4 0.14-dev -X-Developer-Signature: v=1; a=openpgp-sha256; l=1273; - i=caleb.connolly@linaro.org; h=from:subject:message-id; - bh=WycUvGIX1Vb2Dt9TSRhlFTIc8lgmewYYBQWg2kxs6NI=; - b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmxe6djNLXRIVPQZZW1FVYvOn/tPtr3vGLbnTcN - EIiqQUfY2uJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZsXunQAKCRAFgzErGV9k - tnN7D/0d90bQBLWvZQ8d0lHinZ/3zwe3FEdaLK31OGRD7VJd7Q8ckuOxOF/eO8TLmksQovgvrTY - 68llyxkNZe/nnmY9UX+DJ+i5pzqINuLlGRqANukMePwwJxJZilb6dRXB9sR+hSBHC+YTyfY67xk - 78ILyZhMmZqmi/ya6lBqxLieP+CnHq1V9n07s3jljhE1oSp4NucQzFXpv48MGEpOt/sIyjtzQ5w - aw7r1Wsay9w+xmNly+kBT+05q5dp/CTnqMp1koKGG/fWWkSZUgo5yODYeRAiieb7ZQ5JaVmxJkf - G3K0BPkFJ+kaPyU6Mbe0d573tY+oZsWDWEBFP/diduz8lw27tIDOmpTIyT8lMsu1vL7dcj38NsS - 50a7smXimMWcKwJsEQV32Tw0QYv4kfJyqjxXVj6kJ+DWL1bm15LZ6fZpXy3tbTHzJvWRr2Lx/AZ - mWXbylc+uUx4tQkb+7+OhSN376NPfWUNlGHMdHSfQHgzcFuGbMmf9v58sPXa7ZKb3UFkKk2MAzA - 8kiDEMgp/6k55lHxdc4ndxK/vXTKxiU59H2k+okeAQ2iMnA39r/M7yOe6a8vyXDyeuCmJHncNAX - /Uy4yr757EQpUKygo3DjdfRcZQ/h5hQ2TFiWm3BlU87k8MlQl5JEGwxqpkM+9JXFjRwiGcR2ZSO - fOkmL+X6FXNHw3A== -X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; - fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 -X-BeenThere: u-boot@lists.denx.de -X-Mailman-Version: 2.1.39 -Precedence: list -List-Id: U-Boot discussion -List-Unsubscribe: , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: , - -Errors-To: u-boot-bounces@lists.denx.de -Sender: "U-Boot" -X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de -X-Virus-Status: Clean - -For running U-Boot as primary bootloader we must define the memory -layout statically. - -Signed-off-by: Caleb Connolly ---- - arch/arm/dts/qcs6490-rb3gen2-u-boot.dtsi | 23 +++++++++++++++++++++++ - 1 file changed, 23 insertions(+) - -diff --git a/arch/arm/dts/qcs6490-rb3gen2-u-boot.dtsi b/arch/arm/dts/qcs6490-rb3gen2-u-boot.dtsi -new file mode 100644 -index 000000000000..c3ec4a317f7c ---- /dev/null -+++ b/arch/arm/dts/qcs6490-rb3gen2-u-boot.dtsi -@@ -0,0 +1,23 @@ -+// SPDX-License-Identifier: BSD-3-Clause -+/* -+ * Copyright (c) 2024 Linaro Ltd. -+ */ -+/ { -+ /* When running as the primary bootloader there is no prior -+ * stage to populate the memory layout for us. We *should* -+ * have two nodes here, but ABL does NOT like that. -+ * sooo we're stuck with this. -+ */ -+ memory@80000000 { -+ device_type = "memory"; -+ reg = <0 0x80000000 0 0x3A800000>, -+ <0 0xC0000000 0 0x01800000>, -+ <0 0xC3400000 0 0x3CC00000>, -+ <1 0x00000000 1 0x00000000>; -+ }; -+}; -+ -+// RAM Entry 0 : Base 0x0080000000 Size 0x003A800000 -+// RAM Entry 1 : Base 0x00C0000000 Size 0x0001800000 -+// RAM Entry 2 : Base 0x00C3400000 Size 0x003CC00000 -+// RAM Entry 3 : Base 0x0100000000 Size 0x0100000000 - -From patchwork Wed Aug 21 13:41:48 2024 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Caleb Connolly -X-Patchwork-Id: 1974972 -X-Patchwork-Delegate: caleb.connolly@linaro.org -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - dkim=pass (2048-bit key; - unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 - header.s=google header.b=W/enKPtj; - dkim-atps=neutral -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de - [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1)) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4WpnZg6XLXz1yXf - for ; Wed, 21 Aug 2024 23:42:35 +1000 (AEST) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id 8FCF188DD8; - Wed, 21 Aug 2024 15:42:03 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=linaro.org -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de -Authentication-Results: phobos.denx.de; - dkim=pass (2048-bit key; - unprotected) header.d=linaro.org header.i=@linaro.org header.b="W/enKPtj"; - dkim-atps=neutral -Received: by phobos.denx.de (Postfix, from userid 109) - id 7430788BF6; Wed, 21 Aug 2024 15:42:00 +0200 (CEST) -X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de -X-Spam-Level: -X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, - DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, - T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 -Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com - [IPv6:2a00:1450:4864:20::436]) - (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) - (No client certificate requested) - by phobos.denx.de (Postfix) with ESMTPS id BB78388C7E - for ; Wed, 21 Aug 2024 15:41:57 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=linaro.org -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=caleb.connolly@linaro.org -Received: by mail-wr1-x436.google.com with SMTP id - ffacd0b85a97d-3718706cf8aso4087426f8f.3 - for ; Wed, 21 Aug 2024 06:41:57 -0700 (PDT) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=linaro.org; s=google; t=1724247717; x=1724852517; darn=lists.denx.de; - h=cc:to:in-reply-to:references:message-id:content-transfer-encoding - :mime-version:subject:date:from:from:to:cc:subject:date:message-id - :reply-to; bh=zLolcdfhpnv2Sr4+jU2o0ZvxpFWa2r7z1o+vmKY3kNM=; - b=W/enKPtjbLPpOfXBJ95XWpBN74SHMzSf7YfqzclhQ8DglD54/Ubm8hmtMAJr3dU4oc - 7QSmg2IojIWCgmF7ZVpPpPipkl0d0NJdhrbZgltHWn6DI5oa5z8H/oPL2qgfxOvi1mol - GkNDzmOd9DogYJbDxazFLX/yuyObHE0Frbk1+5S+dUC9Mk6TEn/kAnphDP0/pIcoFqNS - MHhPWfxQj8qNWFF683e2CNpiiQmhvIyxMnx2XDqHqr0sARkmDhEdmDt6/J2uDEpAXIqS - gfb2ryOgrf0ymsrNXXmgtPBlJ1Nk+WvqQNZ+fFud6rDTMI7k3T6vg9LtuKRk5l0ZeW9z - 9ukA== -X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=1e100.net; s=20230601; t=1724247717; x=1724852517; - h=cc:to:in-reply-to:references:message-id:content-transfer-encoding - :mime-version:subject:date:from:x-gm-message-state:from:to:cc - :subject:date:message-id:reply-to; - bh=zLolcdfhpnv2Sr4+jU2o0ZvxpFWa2r7z1o+vmKY3kNM=; - b=Bk58APruZpAfRV6OKvJFR/r6nSOZTRk1lGotJZ/7Ps1APRn4QEUIEES/nAymFAlsZK - IuAn5ixOz3aQip+GhlTd5ZX/4G2D90T9SLGu+jKI2zHbc9HfYsLUaLImDouZanKiy3DN - rSF/DzczN7mNahfl++0WXyuhXE1l5coIb99U116QJ4etTFEC+YvBD2zWg7RpfxE6F2MA - tu2L+KZX2xor/7JzMfyV/FeFyAo5X53e7JPAVpvXa6vGTXfyZa8kzv4oIa1vTbwsuxLK - D4AcwfMHj4eyGTilDPHRn292bg79eS+R3MX3EpFEW6J/Zr5fKhsyDSDcjBuR2TYJ7Gcv - BDrw== -X-Gm-Message-State: AOJu0YxuxBBsFKKWph/SGz+J1lDRx2i4hMnvb9KUEI3p7sCb122LZSOU - lTiuOgJUeGU0ryXFmDTRlVFUVDC+WlMh98BjXmGjDc74hcUPn0EuM1QELuQYSNk= -X-Google-Smtp-Source: - AGHT+IFF8AJ5Hu9iRBb/BV7cCxp9j5UJEcpMy4SVnJcq2ijih+8KFAvBMsil1LfJlPGBheg9LAatHw== -X-Received: by 2002:adf:cc82:0:b0:368:6633:c550 with SMTP id - ffacd0b85a97d-372fd82f325mr1509038f8f.52.1724247717163; - Wed, 21 Aug 2024 06:41:57 -0700 (PDT) -Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::676e]) - by smtp.gmail.com with ESMTPSA id - a640c23a62f3a-a83839342f6sm904164066b.137.2024.08.21.06.41.56 - (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); - Wed, 21 Aug 2024 06:41:56 -0700 (PDT) -From: Caleb Connolly -Date: Wed, 21 Aug 2024 15:41:48 +0200 -Subject: [PATCH v2 3/7] dts: qcs6490-rb3gen2-u-boot: USB host mode -MIME-Version: 1.0 -Message-Id: <20240821-b4-rb3gen2-v2-3-49b07633f3a8@linaro.org> -References: <20240821-b4-rb3gen2-v2-0-49b07633f3a8@linaro.org> -In-Reply-To: <20240821-b4-rb3gen2-v2-0-49b07633f3a8@linaro.org> -To: Tom Rini , Lukasz Majewski , - Sean Anderson , - Caleb Connolly , - Neil Armstrong , - Sumit Garg -Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io -X-Mailer: b4 0.14-dev -X-Developer-Signature: v=1; a=openpgp-sha256; l=955; - i=caleb.connolly@linaro.org; h=from:subject:message-id; - bh=HTbXxsrMd17GClJdrUxqmv1t42K8cKHfbuWdCzpCB0M=; - b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmxe6djkazDSIeIn+UGkfv2WCzgyN2+Nv9IFp8u - /7f/kVTNzKJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZsXunQAKCRAFgzErGV9k - tt0qEACLN54DQLVEpmwhpZIBzCPjtaeMTHKNrVejy201O3Ts9I8BmKyuCQmcJReF8E1oTvhVE2p - RRdEnopYd86hGyIc6pZZ1tNwmwCxeADAERIygNKEAGK6f6v29CJZt0OMSVRx7emdUn6wDP0/6FQ - W7zfmxJKZMNp1gEMS80FJSa+PkI148T6WzfmKEfNbENYTwwIwC/e8yqlKXp+joiPv269f/nYbtY - ZR6mW3re0fvIoCbUjHcIRmu5ZWB92qqfwAiSCLLlajpzIF8iDrDyOYOdb7/TxM5eWZloPwDYHaK - 0eJde2EIysMA1TJFP8ynVnUe1c4sZxDLB+ZnVUpbvGTvHjguamxfazEZlUmd1kV6m+ilTqAIlUP - 2v5eY2KUjx+MD8qm5FLgpj6JHDE9jszg3LSETAPwJDk0MICXQoY9HMu03kO8KE62j2HrRwVn7/G - i1agSOBRJyNDHqTiUh2vYQnwwBPANZPjipnQgPkZ6Ebd98KbzzHr9Dh+kR7eC/caSf0V82YK4G8 - mPCaznXAPS+VNfT+JZQxQz7Axm1O7bWfIuSdLGqVGBRj4+4W3k1PzFWI7S46Vj4qWbpJXuWKl6I - UlE67yw71FwYzQt6B7xLMSCr2O8bFmlv42AVl6bNjG53CZ8HmBo5AuKrhbdhpLv5HfjWK1j58tW - Ci+WPJUvj2lPPfg== -X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; - fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 -X-BeenThere: u-boot@lists.denx.de -X-Mailman-Version: 2.1.39 -Precedence: list -List-Id: U-Boot discussion -List-Unsubscribe: , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: , - -Errors-To: u-boot-bounces@lists.denx.de -Sender: "U-Boot" -X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de -X-Virus-Status: Clean - -Adjust DTS so USB runs in host mode. The type-c port is the only -supported port (since the others need PCIe). Booting from USB is -possible with a powered type-c dock. - -Signed-off-by: Caleb Connolly ---- - arch/arm/dts/qcs6490-rb3gen2-u-boot.dtsi | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/arch/arm/dts/qcs6490-rb3gen2-u-boot.dtsi b/arch/arm/dts/qcs6490-rb3gen2-u-boot.dtsi -index c3ec4a317f7c..fbe72595f5ac 100644 ---- a/arch/arm/dts/qcs6490-rb3gen2-u-boot.dtsi -+++ b/arch/arm/dts/qcs6490-rb3gen2-u-boot.dtsi -@@ -16,8 +16,13 @@ - <1 0x00000000 1 0x00000000>; - }; - }; - -+&usb_1_dwc3 { -+ dr_mode = "host"; -+ /delete-property/ usb-role-switch; -+}; -+ - // RAM Entry 0 : Base 0x0080000000 Size 0x003A800000 - // RAM Entry 1 : Base 0x00C0000000 Size 0x0001800000 - // RAM Entry 2 : Base 0x00C3400000 Size 0x003CC00000 - // RAM Entry 3 : Base 0x0100000000 Size 0x0100000000 - -From patchwork Wed Aug 21 13:41:49 2024 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Caleb Connolly -X-Patchwork-Id: 1974973 -X-Patchwork-Delegate: caleb.connolly@linaro.org -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - dkim=pass (2048-bit key; - unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 - header.s=google header.b=fxhzRRWP; - dkim-atps=neutral -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de - [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1)) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4WpnZv2VSTz1yXf - for ; Wed, 21 Aug 2024 23:42:47 +1000 (AEST) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id F1A1E88DBB; - Wed, 21 Aug 2024 15:42:03 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=linaro.org -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de -Authentication-Results: phobos.denx.de; - dkim=pass (2048-bit key; - unprotected) header.d=linaro.org header.i=@linaro.org header.b="fxhzRRWP"; - dkim-atps=neutral -Received: by phobos.denx.de (Postfix, from userid 109) - id 5F28288DBF; Wed, 21 Aug 2024 15:42:01 +0200 (CEST) -X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de -X-Spam-Level: -X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, - DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, - T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 -Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com - [IPv6:2a00:1450:4864:20::12c]) - (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) - (No client certificate requested) - by phobos.denx.de (Postfix) with ESMTPS id 5838488AC0 - for ; Wed, 21 Aug 2024 15:41:59 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=linaro.org -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=caleb.connolly@linaro.org -Received: by mail-lf1-x12c.google.com with SMTP id - 2adb3069b0e04-52efc60a6e6so9447535e87.1 - for ; Wed, 21 Aug 2024 06:41:59 -0700 (PDT) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=linaro.org; s=google; t=1724247718; x=1724852518; darn=lists.denx.de; - h=cc:to:in-reply-to:references:message-id:content-transfer-encoding - :mime-version:subject:date:from:from:to:cc:subject:date:message-id - :reply-to; bh=cqF2st4G7Whhok3VZo6aDGC//+kV3J+exZKhkiiSLFQ=; - b=fxhzRRWPt+qpJciGSAITWCo8l8X60UfTDq85wh8FY7dCx3uklUdpEcoF9mZQvZEARc - JdrCoNahI2M7n7uxXFkWNU8HAYP8adAfEIdzL9A74GE5HVYfUWU28+jLirmyAHbts2I/ - SdPX01laMMuUBZNO1+eQTpYWK/pAO7J5BnazS9JOOedrSlBLeiX74zICTx9l/ogHIvar - oyR9/w28as1z3kdFFAACkxGoDrWsz0kGqhEBXGOOnKRQeXi16Wyq/ZOkZwrDs+ZaOCj0 - Np0K2VryzXH+5acK/T8VFyaO/kiwyVE+oBQ9+t4QRslHCVoK+vniJFjWJmyiLbcrR+VF - Ug3g== -X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=1e100.net; s=20230601; t=1724247718; x=1724852518; - h=cc:to:in-reply-to:references:message-id:content-transfer-encoding - :mime-version:subject:date:from:x-gm-message-state:from:to:cc - :subject:date:message-id:reply-to; - bh=cqF2st4G7Whhok3VZo6aDGC//+kV3J+exZKhkiiSLFQ=; - b=luGrCmqihUFezhJWv4e5vJ9xNHo14vlaEyeUAxelx59D64ZJJ1t0Wp71nzKQ4MjeF1 - +a5ZoV7GeqYCdriLcYtSAm+mGfHYq6wqLK7MUxTJJXQiQ+8YNOE8O5jZPRQOnykhrHyv - SGgBu95T4t2+iops0PoEG1WJgUFfQdguMeIxCF/3egeF2vbuiLdkag3f/P1oZ+WId9d8 - CdjoDP22VLYkI737XGw5dPYXjw8n5aElyW4w8a8+s/+LSHr2DqhP6jBRBHoEr96u9caD - MD/ZJMxHUIF5HVF49slrJCvxOVaE1BLLfvGg6DsgTGbiJ1R04nnqmP4eIiihjxGfokAz - ayDA== -X-Gm-Message-State: AOJu0YyYd+xZ/CF0vx8K/xUigIplSGcNj9+ZYg92++5jyNrmeP/Dw2mb - YdY8603ttFOxzF77F9uZemMCCMk9Yqe06DIg4zk9AmmXVSdjOM16xI4mPU3kNko= -X-Google-Smtp-Source: - AGHT+IEiWiQ2+rnq9ygkkGwKWRO1l7vPXtE6nv9tq+GTkhXNeXOlV9Q+YJri22fWRmcjXR32eVPTAg== -X-Received: by 2002:a05:6512:696:b0:52e:f77b:bb58 with SMTP id - 2adb3069b0e04-5334858e2dbmr1246801e87.36.1724247718271; - Wed, 21 Aug 2024 06:41:58 -0700 (PDT) -Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::676e]) - by smtp.gmail.com with ESMTPSA id - a640c23a62f3a-a83839342f6sm904164066b.137.2024.08.21.06.41.57 - (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); - Wed, 21 Aug 2024 06:41:57 -0700 (PDT) -From: Caleb Connolly -Date: Wed, 21 Aug 2024 15:41:49 +0200 -Subject: [PATCH v2 4/7] iommu: qcom-smmu: add sc7280-smmu-500 compatible -MIME-Version: 1.0 -Message-Id: <20240821-b4-rb3gen2-v2-4-49b07633f3a8@linaro.org> -References: <20240821-b4-rb3gen2-v2-0-49b07633f3a8@linaro.org> -In-Reply-To: <20240821-b4-rb3gen2-v2-0-49b07633f3a8@linaro.org> -To: Tom Rini , Lukasz Majewski , - Sean Anderson , - Caleb Connolly , - Neil Armstrong , - Sumit Garg -Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io -X-Mailer: b4 0.14-dev -X-Developer-Signature: v=1; a=openpgp-sha256; l=735; - i=caleb.connolly@linaro.org; h=from:subject:message-id; - bh=kxKBScKaYeuETfEZtkdyvgk1CIJk9dkzDtE1GYwaPOI=; - b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmxe6dVYUKBuKYzxniyjNVxYEoPmLImzpJJVKSN - fZ8OGllgq+JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZsXunQAKCRAFgzErGV9k - thhHD/sEX0G2aVw1Y8dD02U8Fg111EK/PNvDyUlifhchP/sTDJHxyzWJc0zxsb1FtSosTWlnv1i - tgFSLVCLklzMwrcUCZb5Fe/9bWGRL6Uz0dEbDXZohGWagR4SC9MoM/shyb6R7Xm2ywwaR1dBkHM - alh2af0YAoJi0TljeQz70GlUCBAyLiLhLD9/V7JDfkdAgUj1R7tGibGbz7plVk1ySD/JUbXLyRD - Oj3l66FUGleJAA+KrvbPR5sVcA8Zt+Mak0xp5xyjQ0T8TUNfwJF0VUgWEpiVHWZGPgOgw2OnE5U - Iv4mBGteHGHC0WjCdjt/thyn2+QCx/LjPwrBDrsyw6FFyg43yWEmDkEgfCiTDSHMtTMSPLvYbXM - b00Egv5OZrrhIGahpHxdd2Ui/6zicLanexZopGSaMu4DnMnhfm7GGdRxNphtP9VMWwgy+vePa+a - ghVuG+oIgtIOoEwE/SN2zBpMIxLNuzTi3c80xsxh6uA+5VH9X937eNFlB0fouXJjG27Jo4NSbKL - oeSE2rLXYtJ2bCV0ee7E5InyvUsdzHynjewLM0usEvnFHn433yCibXdQ1VjAZJVOJlFwxt85evc - Y/3ckT+iau+N7Z8un7Vhsp2FKf/IR5/QGd1NrfOyZuZ4V3ojqtD71Hymz1874HoW492BdpUytut - 5WHbOvM4jWAm5dQ== -X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; - fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 -X-BeenThere: u-boot@lists.denx.de -X-Mailman-Version: 2.1.39 -Precedence: list -List-Id: U-Boot discussion -List-Unsubscribe: , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: , - -Errors-To: u-boot-bounces@lists.denx.de -Sender: "U-Boot" -X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de -X-Virus-Status: Clean - -This soc doesn't have the generic compatible. - -Reviewed-by: Neil Armstrong -Signed-off-by: Caleb Connolly -Reviewed-by: Simon Glass ---- - drivers/iommu/qcom-hyp-smmu.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/drivers/iommu/qcom-hyp-smmu.c b/drivers/iommu/qcom-hyp-smmu.c -index 7b646d840dd4..1b5a09bb7b39 100644 ---- a/drivers/iommu/qcom-hyp-smmu.c -+++ b/drivers/iommu/qcom-hyp-smmu.c -@@ -380,8 +380,9 @@ static struct iommu_ops qcom_smmu_ops = { - }; - - static const struct udevice_id qcom_smmu500_ids[] = { - { .compatible = "qcom,sdm845-smmu-500" }, -+ { .compatible = "qcom,sc7280-smmu-500" }, - { .compatible = "qcom,smmu-500", }, - { /* sentinel */ } - }; - - -From patchwork Wed Aug 21 13:41:50 2024 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Caleb Connolly -X-Patchwork-Id: 1974974 -X-Patchwork-Delegate: caleb.connolly@linaro.org -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - dkim=pass (2048-bit key; - unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 - header.s=google header.b=yOMaz64l; - dkim-atps=neutral -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=85.214.62.61; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wpnb85tThz1yXf - for ; Wed, 21 Aug 2024 23:43:00 +1000 (AEST) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id 6572A88DE5; - Wed, 21 Aug 2024 15:42:04 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=linaro.org -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de -Authentication-Results: phobos.denx.de; - dkim=pass (2048-bit key; - unprotected) header.d=linaro.org header.i=@linaro.org header.b="yOMaz64l"; - dkim-atps=neutral -Received: by phobos.denx.de (Postfix, from userid 109) - id 47E5388AFF; Wed, 21 Aug 2024 15:42:02 +0200 (CEST) -X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de -X-Spam-Level: -X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, - DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, - T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 -Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com - [IPv6:2a00:1450:4864:20::62b]) - (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) - (No client certificate requested) - by phobos.denx.de (Postfix) with ESMTPS id 2E9D188C36 - for ; Wed, 21 Aug 2024 15:42:00 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=linaro.org -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=caleb.connolly@linaro.org -Received: by mail-ej1-x62b.google.com with SMTP id - a640c23a62f3a-a7a81bd549eso556008566b.3 - for ; Wed, 21 Aug 2024 06:42:00 -0700 (PDT) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=linaro.org; s=google; t=1724247719; x=1724852519; darn=lists.denx.de; - h=cc:to:in-reply-to:references:message-id:content-transfer-encoding - :mime-version:subject:date:from:from:to:cc:subject:date:message-id - :reply-to; bh=VGpHi3k7vxgehhynkHpyKJwxi4oKfB4A2A00OXKPkFQ=; - b=yOMaz64lma1hQ0+Gt5CgMdElox51jZtnVyBitVGl6NvVmTuRWyklxImOrmwqsD3xYC - LGVcaLqh6/Q1W84/a/VQjQXnjBnf7rwjs1wqMs2mxBSvIXqX84EaEYJsYQK255NuFmeY - NXA0Iw/mLc/lgHAufmAUkAE02OVXH7AAyOjuEUceM/a6s9P5xPF82ucP7uH1adqOkAZQ - MTmKJK30kZjuhrZasD0UafyDCfMinXHhHFqlIcrhxmitRK4qDTzbktP/Atn3wfIJpVyh - Zbfra3N7AwxLidGI4lgrZSdfJWx7xo7f78GLzrxxtf9EQNN97axpLHFCTql16lK6z8qx - 3Psg== -X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=1e100.net; s=20230601; t=1724247719; x=1724852519; - h=cc:to:in-reply-to:references:message-id:content-transfer-encoding - :mime-version:subject:date:from:x-gm-message-state:from:to:cc - :subject:date:message-id:reply-to; - bh=VGpHi3k7vxgehhynkHpyKJwxi4oKfB4A2A00OXKPkFQ=; - b=wjTgODezMYlCn5sKcCnnp1Vd0OLBd5uCD0eBpdaJdRReSR2EsRO7RyUqvKoOvz7NPc - O7v24bEyP8vKrldHxpNvN9R6RqnobFMDUq1urWi4ObeXiFLrgH/iVa6h8fQXs239YyyD - x2v2ZGzHy5LuWMQItcPDAfgV1NMl9e9Whd1LOS9mJBgHAuX64ve4uf3jQhpIAG52PGNG - PqZklpeuYNZrK/gG7RZSuSUlrHkd3f3UF6b7jqC16TpwDc+4RuW5vF35uLCqnjMjHRPK - jxAj6zbq1QxznhNSLn6wMt4SHd44YvPRET9SWyLNJ69jL8f3LA+/2vyrgQdg3UYIUTaf - WunQ== -X-Gm-Message-State: AOJu0YyYxzvh/Kq2TnmE45KUz4jNc/HfUkc2DCE5IqW05whgtX84/Uou - QvsSOrpkiSoyoRX00nQTJ6PEghMnyz/il1CvQOq6oIHOYo7ZMLMN86AVf2+SA9g= -X-Google-Smtp-Source: - AGHT+IF2/DupIr7S3Tf/n9l6fXvTAbuD5E3nSTqZnLUH17vrwUpiB2tHgdlyQp8XysNBhZpXN+tPXA== -X-Received: by 2002:a17:907:d864:b0:a86:6cb1:4d49 with SMTP id - a640c23a62f3a-a866f0fd56emr197816466b.13.1724247719583; - Wed, 21 Aug 2024 06:41:59 -0700 (PDT) -Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::676e]) - by smtp.gmail.com with ESMTPSA id - a640c23a62f3a-a83839342f6sm904164066b.137.2024.08.21.06.41.58 - (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); - Wed, 21 Aug 2024 06:41:58 -0700 (PDT) -From: Caleb Connolly -Date: Wed, 21 Aug 2024 15:41:50 +0200 -Subject: [PATCH v2 5/7] qcom_defconfig: enable SC7280 clocks -MIME-Version: 1.0 -Message-Id: <20240821-b4-rb3gen2-v2-5-49b07633f3a8@linaro.org> -References: <20240821-b4-rb3gen2-v2-0-49b07633f3a8@linaro.org> -In-Reply-To: <20240821-b4-rb3gen2-v2-0-49b07633f3a8@linaro.org> -To: Tom Rini , Lukasz Majewski , - Sean Anderson , - Caleb Connolly , - Neil Armstrong , - Sumit Garg -Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io -X-Mailer: b4 0.14-dev -X-Developer-Signature: v=1; a=openpgp-sha256; l=670; - i=caleb.connolly@linaro.org; h=from:subject:message-id; - bh=yS4s6QOgfiWQfzfc4REiZuaFQ3cRc+UaGAPzZhg/0tY=; - b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmxe6dlBkL0sqAHkV82+rSk3ED8IQyQvi4gHZz1 - YfE45yCF8SJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZsXunQAKCRAFgzErGV9k - trAoD/9/6KH2Cobld2UEMHFj+Lh80HJIGWdNHdhodfzYtlvCFU8pC/pmYwgBd9Opd24rU+Xh7dU - 8f+9HBKcRKgLmbuUy1fAn84B+kgl/IJtVeHpaP6LRp12NuJudZYl+woPx3mAgz9Wqv/+74nKYok - lVr1q9hbq4ZuMItcuzU5fWoyh7iC3th7KYUhh6939F1PQ8FFeF/5+9jJpRBMpuNZPFETxhlBTwY - YDXZL75cWg6ImurwaM4Hj1zQpHnR8V8HDa5GTTDNMxHOBFYCL+cJ3Bfd0FjqXFsL2/zjefqsewa - 0rWWQPMC8az8WvyczZAvB5JTq+M3VbP7kEWemCdedXmHiJ33dO6+jabm0ikvLooz1z7G6rlwZxZ - P7Rgc3ewW+RHOYbVYFLRKCdFVOFtiwOcEke50gPqQr/sbz0p39olzaE+D8WdNvgjW2uBRzLJDnR - EqyAYWncrWyAANXM3RSiICge87zZ/l4iUb8t8qm/8dYAs8KgPk6YNYVgLxtQqfVFNqnkHlmyy43 - 82JCgSSVggB9phNSVn/poUjlMlaImqGWB+zHDgf968J0a7mz/uFRgVgb8cjuG/Y5oX0xhNMkfqW - 2VymGoOrNlNvBNHyYEoEWgOMRiPvB/lL7PwbM9FFXmNyMMkx6FkzFgyopVkSWvCzKZQfgwBaUev - z00CkhnUndrSe5w== -X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; - fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 -X-BeenThere: u-boot@lists.denx.de -X-Mailman-Version: 2.1.39 -Precedence: list -List-Id: U-Boot discussion -List-Unsubscribe: , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: , - -Errors-To: u-boot-bounces@lists.denx.de -Sender: "U-Boot" -X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de -X-Virus-Status: Clean - -Enable clocks on SC7280 - -Reviewed-by: Neil Armstrong -Signed-off-by: Caleb Connolly -Reviewed-by: Simon Glass ---- - configs/qcom_defconfig | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/configs/qcom_defconfig b/configs/qcom_defconfig -index 24b71ba7be29..1a079264a554 100644 ---- a/configs/qcom_defconfig -+++ b/configs/qcom_defconfig -@@ -44,8 +44,9 @@ CONFIG_CLK=y - CONFIG_CLK_QCOM_APQ8016=y - CONFIG_CLK_QCOM_APQ8096=y - CONFIG_CLK_QCOM_QCM2290=y - CONFIG_CLK_QCOM_QCS404=y -+CONFIG_CLK_QCOM_SC7280=y - CONFIG_CLK_QCOM_SDM845=y - CONFIG_CLK_QCOM_SM6115=y - CONFIG_CLK_QCOM_SM8250=y - CONFIG_CLK_QCOM_SM8550=y - -From patchwork Wed Aug 21 13:41:51 2024 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Caleb Connolly -X-Patchwork-Id: 1974975 -X-Patchwork-Delegate: caleb.connolly@linaro.org -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - dkim=pass (2048-bit key; - unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 - header.s=google header.b=K30ji2S3; - dkim-atps=neutral -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=85.214.62.61; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1)) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4WpnbM59VXz1yXf - for ; Wed, 21 Aug 2024 23:43:11 +1000 (AEST) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id D2D6288C25; - Wed, 21 Aug 2024 15:42:06 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=linaro.org -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de -Authentication-Results: phobos.denx.de; - dkim=pass (2048-bit key; - unprotected) header.d=linaro.org header.i=@linaro.org header.b="K30ji2S3"; - dkim-atps=neutral -Received: by phobos.denx.de (Postfix, from userid 109) - id 9300088DD4; Wed, 21 Aug 2024 15:42:03 +0200 (CEST) -X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de -X-Spam-Level: -X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, - DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, - T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 -Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com - [IPv6:2a00:1450:4864:20::62f]) - (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) - (No client certificate requested) - by phobos.denx.de (Postfix) with ESMTPS id 3E8D188DBE - for ; Wed, 21 Aug 2024 15:42:01 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=linaro.org -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=caleb.connolly@linaro.org -Received: by mail-ej1-x62f.google.com with SMTP id - a640c23a62f3a-a7a94478a4eso147841366b.1 - for ; Wed, 21 Aug 2024 06:42:01 -0700 (PDT) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=linaro.org; s=google; t=1724247721; x=1724852521; darn=lists.denx.de; - h=cc:to:in-reply-to:references:message-id:content-transfer-encoding - :mime-version:subject:date:from:from:to:cc:subject:date:message-id - :reply-to; bh=yPrDPgQU7/bvZow9laSNg4WMEx5CRzVugf/oAUblCT4=; - b=K30ji2S3yioeE5/M0vSF0qrx1STvg5+c45nG5Kg+dcjyT1GMIsiX0GbpHc8+aTeWpp - Bd16xS5DE9TAuA1s2WmMq1TNdKHCyyx3MSSHMP9S9SctgsZSxIypHfGf7m6duOmEf5I8 - HBAumCuGiHTW3NkqIl8H2yZjkAbajsM1Q98+NyYJskO8owlNVyczk44QEbJ16Jtmntq6 - u+v7SADVhB3LrWu30OOWnwu/Z/9TVapcDx+ZAGflSfCy5P54TgqYIRYrBtjn9huobmaJ - XJED4Ak8A7iJHUQ5Savv+T4lTPHHfD+J+1NZDr1ciKMujXdnFUuZYcUZLoAn0PHLVsDD - +S6A== -X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=1e100.net; s=20230601; t=1724247721; x=1724852521; - h=cc:to:in-reply-to:references:message-id:content-transfer-encoding - :mime-version:subject:date:from:x-gm-message-state:from:to:cc - :subject:date:message-id:reply-to; - bh=yPrDPgQU7/bvZow9laSNg4WMEx5CRzVugf/oAUblCT4=; - b=RTxkaBLhQgRZeSdTWakNQdltrcGw4Cw+6Jge9dwNM3Q/YJMSuM1z7N2JGOntXjHxD2 - NZzz61S7FHFOOjYJoubSodORxK53ddoKFuwUvxurdOy+9Y67fPtAweqdd8NJnDdvBrEh - 35wnkzs6ItOpaYe1StAVW06cFPwhqK7ajV3yVdoyKwzCfp8oTYHC5QFJUhi0EM4KnF97 - HepCXvJdv+Qm1/hOVJu19Y6L2RKwXEWztyS53XVwtLOeyKO5x4Qk4PuhnZEAcGkT5lBB - 0kaoF4zSuIX8CVYMJ4oa/4TJg/epJPEtpdDjPDJ2KEWVWbay4/E7PLlgi/tDNndUgOGI - 5vvw== -X-Gm-Message-State: AOJu0Ywpr+aZcIll1/M3ZGdzXawgIEMgRfu4GacRerzZeNne6pIDfvz0 - FBjk4XnDaPXHLxU60pO20RaUjuXG+96oqxwOdmGkP/6Hf3yiMbOJc/ikC/obqxQ= -X-Google-Smtp-Source: - AGHT+IFBBHXs1fwWXLXlqsclsjPN/CITy3andQbbeClu6l28M7g0bUERMexbKgeMqQwwLkcBMwvMRA== -X-Received: by 2002:a17:907:1b2a:b0:a86:668a:8b28 with SMTP id - a640c23a62f3a-a8670182bd0mr296134266b.30.1724247720548; - Wed, 21 Aug 2024 06:42:00 -0700 (PDT) -Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::676e]) - by smtp.gmail.com with ESMTPSA id - a640c23a62f3a-a83839342f6sm904164066b.137.2024.08.21.06.41.59 - (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); - Wed, 21 Aug 2024 06:42:00 -0700 (PDT) -From: Caleb Connolly -Date: Wed, 21 Aug 2024 15:41:51 +0200 -Subject: [PATCH v2 6/7] configs: add qcm6490_defconfig -MIME-Version: 1.0 -Message-Id: <20240821-b4-rb3gen2-v2-6-49b07633f3a8@linaro.org> -References: <20240821-b4-rb3gen2-v2-0-49b07633f3a8@linaro.org> -In-Reply-To: <20240821-b4-rb3gen2-v2-0-49b07633f3a8@linaro.org> -To: Tom Rini , Lukasz Majewski , - Sean Anderson , - Caleb Connolly , - Neil Armstrong , - Sumit Garg -Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io -X-Mailer: b4 0.14-dev -X-Developer-Signature: v=1; a=openpgp-sha256; l=1579; - i=caleb.connolly@linaro.org; h=from:subject:message-id; - bh=ACfbGsu6Qfhpulh7cWGr4R2PHD6f1xBOaMcu/oMTV/k=; - b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmxe6eltJAuAi418HOLC6BvAwvNrE6K+OD4tmaU - 8Agtuwf3TuJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZsXungAKCRAFgzErGV9k - tp2fD/4izqkO8vl46KJDMg5exEAzqayxPJyZcBnhIQyekkEfHowP0Hnr0xDZqbYbl6BAapt+ZBA - 237lBMrvuWc45PJO228GrtQw+7AcU8UqYXvy0mhiS+xUJHhirFotdPZX8jly9sRdw54SUINx7vl - HThC3BXeYgmzugZXoSGA3Dw/d8NZXgf5aCjqXW/pIMBWK4RB/4r84gPQG3dgNT12yTVuNtN81ng - 7UMKgDHnK5kaXNh630td4ZmmJQ2jhUU/DShNLmKJnpe67xiK6DjHJiQqgqqj2ZZ38qvlRRpNYgx - 0iwUSyvlnNrB6dHAyzgUjMFaqxReb+rJKvr7+k9YB1dbmysbh9MM3WlWKmf9P39qLjJp1zBwd5z - 9lolc/k+9FT0hziFLDd1sMPQ0oBSZQQNFxZCEtncn387cDFCvJb/nUZnyt6XVzimfnSfssBGQ/g - A04MCaVXei5UeDZHc2kuv4yi7bWWnN3hZVdkoSHMe5esd0cYlVmz2tBkPzTDWIckquNRo/2dWyE - k5yQoqRVqg/V1GTE0f3B9aL/diPmJdYp+Z2FAAihFEUEOAKSPr+BfGIm2bNoMHUUQRGecjNoitg - qLmRTfs21gQs6x1ZivJ1tm3WGl2u+FUm9uuyYwB0bGnXasAzIBB+F4K2AL3dcULGf3Au2Q4w7Y1 - ULXtGjABlmE9Z5w== -X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; - fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 -X-BeenThere: u-boot@lists.denx.de -X-Mailman-Version: 2.1.39 -Precedence: list -List-Id: U-Boot discussion -List-Unsubscribe: , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: , - -Errors-To: u-boot-bounces@lists.denx.de -Sender: "U-Boot" -X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de -X-Virus-Status: Clean - -Introduce a defconfig for the RB3 Gen 2 and other QCM6490 boards with a -dedicated uefi partition. These can replace EDK2 entirely with U-Boot. - -Signed-off-by: Caleb Connolly -Reviewed-by: Simon Glass ---- - MAINTAINERS | 1 + - configs/qcm6490_defconfig | 18 ++++++++++++++++++ - 2 files changed, 19 insertions(+) - -diff --git a/MAINTAINERS b/MAINTAINERS -index daaf0345d0e8..7ab39d91a553 100644 ---- a/MAINTAINERS -+++ b/MAINTAINERS -@@ -616,8 +616,9 @@ M: Neil Armstrong - R: Sumit Garg - L: u-boot-qcom@groups.io - S: Maintained - T: git https://source.denx.de/u-boot/custodians/u-boot-snapdragon.git -+F: configs/qcm6490_defconfig - F: drivers/*/*/pm8???-* - F: drivers/gpio/msm_gpio.c - F: drivers/mmc/msm_sdhci.c - F: drivers/phy/msm8916-usbh-phy.c -diff --git a/configs/qcm6490_defconfig b/configs/qcm6490_defconfig -new file mode 100644 -index 000000000000..25413ac9ed5a ---- /dev/null -+++ b/configs/qcm6490_defconfig -@@ -0,0 +1,18 @@ -+# Configuration for building U-Boot to be flashed -+# to the uefi partition of QCM6490 dev boards with -+# the "Linux Embedded" partition layout (which have -+# a dedicated "uefi" partition for edk2/U-Boot) -+ -+#include "qcom_defconfig" -+ -+CONFIG_DEBUG_UART=y -+CONFIG_DEBUG_UART_ANNOUNCE=y -+CONFIG_DEBUG_UART_BASE=0x994000 -+CONFIG_DEBUG_UART_MSM_GENI=y -+CONFIG_DEBUG_UART_CLOCK=14745600 -+ -+# Address where U-Boot will be loaded -+CONFIG_TEXT_BASE=0x9fc00000 -+CONFIG_REMAKE_ELF=y -+ -+CONFIG_DEFAULT_DEVICE_TREE="qcom/qcs6490-rb3gen2" - -From patchwork Wed Aug 21 13:41:52 2024 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Caleb Connolly -X-Patchwork-Id: 1974976 -X-Patchwork-Delegate: caleb.connolly@linaro.org -Return-Path: -X-Original-To: incoming@patchwork.ozlabs.org -Delivered-To: patchwork-incoming@legolas.ozlabs.org -Authentication-Results: legolas.ozlabs.org; - dkim=pass (2048-bit key; - unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 - header.s=google header.b=N7ncWeh3; - dkim-atps=neutral -Authentication-Results: legolas.ozlabs.org; - spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de - (client-ip=85.214.62.61; helo=phobos.denx.de; - envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) -Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) - (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) - key-exchange X25519 server-signature ECDSA (secp384r1)) - (No client certificate requested) - by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wpnbc6Cbtz1yXf - for ; Wed, 21 Aug 2024 23:43:24 +1000 (AEST) -Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) - by phobos.denx.de (Postfix) with ESMTP id 3D6FC88C7E; - Wed, 21 Aug 2024 15:42:07 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=linaro.org -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de -Authentication-Results: phobos.denx.de; - dkim=pass (2048-bit key; - unprotected) header.d=linaro.org header.i=@linaro.org header.b="N7ncWeh3"; - dkim-atps=neutral -Received: by phobos.denx.de (Postfix, from userid 109) - id 78A2D88BF6; Wed, 21 Aug 2024 15:42:05 +0200 (CEST) -X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de -X-Spam-Level: -X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, - DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, - T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 -Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com - [IPv6:2a00:1450:4864:20::22a]) - (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) - (No client certificate requested) - by phobos.denx.de (Postfix) with ESMTPS id 0804988BBC - for ; Wed, 21 Aug 2024 15:42:02 +0200 (CEST) -Authentication-Results: phobos.denx.de; - dmarc=pass (p=none dis=none) header.from=linaro.org -Authentication-Results: phobos.denx.de; - spf=pass smtp.mailfrom=caleb.connolly@linaro.org -Received: by mail-lj1-x22a.google.com with SMTP id - 38308e7fff4ca-2f3bfcc2727so47717401fa.0 - for ; Wed, 21 Aug 2024 06:42:02 -0700 (PDT) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=linaro.org; s=google; t=1724247722; x=1724852522; darn=lists.denx.de; - h=cc:to:in-reply-to:references:message-id:content-transfer-encoding - :mime-version:subject:date:from:from:to:cc:subject:date:message-id - :reply-to; bh=IvOluZPLzD78/HF1gfteCSftNGDnvO7+RNQKT4a8rSE=; - b=N7ncWeh3cbNIFm16gC0ycocqUu7FjIH/X5KUs3ng3VOMDiDB9bx6yqvhqYvjQxyBc0 - NtX/AEn+6kLdyYda7FlKDaCMV9zQy5kNC993I5rZ4A9iW9QyJTuwBSzH7qa4sO6gQ1ol - 8Lo1+ZJhhBum9Ni+61giewvGR09iEusCmwVImeU5GAZaibju4E3OPBByXLzP8iW1CXee - Td0YEp/5GqF/suNSfz0LIe3u7qAf4ym1XGfXSuoSZTlAKYusX8Hr8p7r6eeQe98FId8k - K8EtjvWCpjafWWcaMyS2hMQJ9qVg2oN+O0BWIVzab1rmcZfKqTsdCdRmT5zJ8/UuskiJ - ovww== -X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=1e100.net; s=20230601; t=1724247722; x=1724852522; - h=cc:to:in-reply-to:references:message-id:content-transfer-encoding - :mime-version:subject:date:from:x-gm-message-state:from:to:cc - :subject:date:message-id:reply-to; - bh=IvOluZPLzD78/HF1gfteCSftNGDnvO7+RNQKT4a8rSE=; - b=irJmZUIlQ9YqUetM6kgCgWcp0L2t2cRcBdc7BANQ6GSkyblKM0IhcjmShs/YQLTvfD - kcy+qKFJUBLqwl/GS2t28MNGXs5+jyhkJJtmlWXg0jksArLnCgxQNWggqkJHxHr4QXWm - yQUR1tfzoSdEPgisANBnh6pIR2x4I+INopwPke0bJOnMgq6gauZ6e7Sb5DK8+XfB+ub7 - 4BwZrBRNSgdQL4GZy7yJ7/tDy+Rb77CKeC82GlbeYSYWjhnyNHiApHXii7b3P9K1dIpH - TuIXX+CoDUWK9SpsTDPZQ9TKah8sMs4lll+6bxADx28pav2gXGoDzIq8+8njC4mnAW8D - QRKA== -X-Gm-Message-State: AOJu0YxQDsjOdfe21vx3pm9NQzQM6F9uuV8kmavTQJuc2Dc6UIFEBXIw - Yp6RPVVelZ9sExmiTtDcpYm6jM3fkV9MKKhMmd5jCa8HvsIjbjln6JXyuICIMFA= -X-Google-Smtp-Source: - AGHT+IFOXObF674O6U9t5YWoWgiOsh1cr3c2B3a47ilhjVWpLEAWrw7hptc9n6o8T5A7NFea+26OwA== -X-Received: by 2002:a05:6512:118f:b0:52f:d17e:46b with SMTP id - 2adb3069b0e04-533485eff58mr1798728e87.54.1724247721704; - Wed, 21 Aug 2024 06:42:01 -0700 (PDT) -Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::676e]) - by smtp.gmail.com with ESMTPSA id - a640c23a62f3a-a83839342f6sm904164066b.137.2024.08.21.06.42.00 - (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); - Wed, 21 Aug 2024 06:42:01 -0700 (PDT) -From: Caleb Connolly -Date: Wed, 21 Aug 2024 15:41:52 +0200 -Subject: [PATCH v2 7/7] doc: board/qualcomm: document rb3gen2 - building/flashing -MIME-Version: 1.0 -Message-Id: <20240821-b4-rb3gen2-v2-7-49b07633f3a8@linaro.org> -References: <20240821-b4-rb3gen2-v2-0-49b07633f3a8@linaro.org> -In-Reply-To: <20240821-b4-rb3gen2-v2-0-49b07633f3a8@linaro.org> -To: Tom Rini , Lukasz Majewski , - Sean Anderson , - Caleb Connolly , - Neil Armstrong , - Sumit Garg -Cc: u-boot@lists.denx.de, u-boot-qcom@groups.io -X-Mailer: b4 0.14-dev -X-Developer-Signature: v=1; a=openpgp-sha256; l=3002; - i=caleb.connolly@linaro.org; h=from:subject:message-id; - bh=Zfbm5IKZooOMQaYWVdjsboSGnZBH9tpLor1DsgqeCLA=; - b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmxe6eOpavbRRq/Mmd1u2iOzwt3wx46uoOvpDbB - SjdW6jqdcuJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZsXungAKCRAFgzErGV9k - th2IEACXQhOGwtEPSr0Jpv9CdMJZvP6O7/us/hUgF9Bir4ETF1KQoReZ18goCIPH2bfLWQIT4eN - CS7gQ46J/jZfFKYl2ORIB7BUUfe58/nB4VvbfGfmskbHi4sdVSemgHxu04xNtj1ttCaiVKX58D5 - GLThMjr4w80H1RLlEnlJmDf8RC/bp6PPHv1a9f0mDH3y00HDTJInV1+p8Bp5T/foomvjYfdcB86 - okdAJzhvNDYeA+xQxp5zTAzDoGI1K/5NYiLyqYoNzpb2sVBTjEBl6fiQqZ6q9b6TWoP5H64s3VC - OsD4ZgATKSXgEYuNYGx5XwDd66lN31jnu4BRhav643sBpOwpN/UN3cLVeqHbD5K3QiI6j+afC7w - o1QNNxNE9pBp3ZBWWWWFbbOv+rwy5npvZHZKWUSNC21l2/4hI6XwAFLDlu5nm+yQ+fYdb4HnMc0 - 1kGJhpGz0/guwKXxpSVxijQT5lFbr81ADvFLzoRD33x8EnbG4aFGa6PhIU+H/9TNpDOaDWHQdIb - 18rqauYLxwejAvFKDC8EIWM9n+6Qkn8caR37H11EnKkNX15ZRKn3Oiv7n8Wy6CukVoFquvjL4IU - t/2E8nV32ksuehndbsDXnpRpSAefggkQ9TjkuGaV29j0nvSrlJiCud0Dzj0lTdjxBvJKpaXG7XN - YCCZ/x5nTtnxdyg== -X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; - fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 -X-BeenThere: u-boot@lists.denx.de -X-Mailman-Version: 2.1.39 -Precedence: list -List-Id: U-Boot discussion -List-Unsubscribe: , - -List-Archive: -List-Post: -List-Help: -List-Subscribe: , - -Errors-To: u-boot-bounces@lists.denx.de -Sender: "U-Boot" -X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de -X-Virus-Status: Clean - -The process here is almost identical to the Dragonboard 410c, we've come -full circle! - -Signed-off-by: Caleb Connolly -Reviewed-by: Simon Glass ---- - doc/board/qualcomm/index.rst | 1 + - doc/board/qualcomm/rb3gen2.rst | 53 ++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 54 insertions(+) - -diff --git a/doc/board/qualcomm/index.rst b/doc/board/qualcomm/index.rst -index 4955274a39bc..8c7969987a97 100644 ---- a/doc/board/qualcomm/index.rst -+++ b/doc/board/qualcomm/index.rst -@@ -6,6 +6,7 @@ Qualcomm - .. toctree:: - :maxdepth: 2 - - dragonboard410c -+ rb3gen2 - board - debugging -diff --git a/doc/board/qualcomm/rb3gen2.rst b/doc/board/qualcomm/rb3gen2.rst -new file mode 100644 -index 000000000000..4240606224f5 ---- /dev/null -+++ b/doc/board/qualcomm/rb3gen2.rst -@@ -0,0 +1,53 @@ -+.. SPDX-License-Identifier: GPL-2.0+ -+.. sectionauthor:: Caleb Connolly -+ -+Qualcomm Robotics RB3 Gen 2 -+=========================== -+ -+The RB3 Gen 2 is a development board based on the Qualcomm QCM6490 SoC (a derivative -+of SC7280). More information can be found on `Qualcomm's product page`_. -+ -+U-Boot can be used as a replacement for Qualcomm's original EDK2 bootloader by -+flashing it directly to the uefi_a (or _b) partition. -+ -+.. _Qualcomm's product page: https://www.qualcomm.com/developer/hardware/rb3-gen-2-development-kit -+ -+Installation -+------------ -+First, setup ``CROSS_COMPILE`` for aarch64. Then, build U-Boot for ``qcm6490``:: -+ -+ $ export CROSS_COMPILE= -+ $ make qcm6490_defconfig -+ $ make -j8 -+ -+This will build ``u-boot.elf`` in the configured output directory. -+ -+Although the RB3 Gen 2 does not have secure boot set up by default, -+the firmware still expects firmware ELF images to be "signed". The signature -+does not provide any security in this case, but it provides the firmware with -+some required metadata. -+ -+To "sign" ``u-boot.elf`` you can use e.g. `qtestsign`_:: -+ -+ $ qtestsign -v6 aboot -o u-boot.mbn u-boot.elf -+ -+Then install the resulting ``u-boot.mbn`` to the ``uefi_a`` partition -+on your device with ``fastboot flash uefi_a u-boot.mbn``. -+ -+U-Boot should be running after a reboot (``fastboot reboot``). -+ -+Note that fastboot is not yet supported in U-Boot on this board, as a result, -+to flash back the original firmware, or new versoins of the U-Boot, EDL mode -+must be used. This can be accessed by pressing the EDL mode button as described -+in the Qualcomm Linux documentation. A tool like bkerler's `edl`_ can be used -+for flashing with the firehose loader binary appropriate for the board. -+ -+.. _qtestsign: https://github.com/msm8916-mainline/qtestsign -+.. _edl: https://github.com/bkerler/edl -+ -+Usage -+----- -+ -+The USB Type-A ports are connected via a PCIe USB hub, which is not supported yet. -+However, the Type-C port can be used with a powered USB dock to connect peripherals -+like a USB stick. diff --git a/USB-PD-TCPM-improvements.patch b/USB-PD-TCPM-improvements.patch new file mode 100644 index 0000000..f84e6f3 --- /dev/null +++ b/USB-PD-TCPM-improvements.patch @@ -0,0 +1,717 @@ +From patchwork Wed Feb 26 18:44:44 2025 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Sebastian Reichel +X-Patchwork-Id: 2052544 +X-Patchwork-Delegate: marek.vasut@gmail.com +Return-Path: +X-Original-To: incoming@patchwork.ozlabs.org +Delivered-To: patchwork-incoming@legolas.ozlabs.org +Authentication-Results: legolas.ozlabs.org; + dkim=pass (2048-bit key; + unprotected) header.d=collabora.com header.i=@collabora.com + header.a=rsa-sha256 header.s=mail header.b=IthL1Z+m; + dkim-atps=neutral +Authentication-Results: legolas.ozlabs.org; + spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de + (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; + envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) +Received: from phobos.denx.de (phobos.denx.de + [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) + key-exchange X25519 server-signature ECDSA (secp384r1)) + (No client certificate requested) + by legolas.ozlabs.org (Postfix) with ESMTPS id 4Z33M03Hhjz1yCp + for ; Thu, 27 Feb 2025 05:45:32 +1100 (AEDT) +Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) + by phobos.denx.de (Postfix) with ESMTP id BFF7680FF0; + Wed, 26 Feb 2025 19:45:16 +0100 (CET) +Authentication-Results: phobos.denx.de; + dmarc=pass (p=none dis=none) header.from=collabora.com +Authentication-Results: phobos.denx.de; + spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de +Authentication-Results: phobos.denx.de; + dkim=pass (2048-bit key; + unprotected) header.d=collabora.com header.i=@collabora.com + header.b="IthL1Z+m"; + dkim-atps=neutral +Received: by phobos.denx.de (Postfix, from userid 109) + id 7614F810F9; Wed, 26 Feb 2025 19:45:13 +0100 (CET) +X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de +X-Spam-Level: +X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, + DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, + SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 +Received: from bali.collaboradmins.com (bali.collaboradmins.com + [IPv6:2a01:4f8:201:9162::2]) + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) + (No client certificate requested) + by phobos.denx.de (Postfix) with ESMTPS id 2173180FDE + for ; Wed, 26 Feb 2025 19:45:08 +0100 (CET) +Authentication-Results: phobos.denx.de; + dmarc=pass (p=none dis=none) header.from=collabora.com +Authentication-Results: phobos.denx.de; + spf=pass smtp.mailfrom=sebastian.reichel@collabora.com +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; + s=mail; t=1740595507; + bh=Fnp6a8opSCXiH5NJdu5uivbBBZF3pe1CXyluh8+n8/c=; + h=From:To:Cc:Subject:Date:In-Reply-To:References:From; + b=IthL1Z+mDeIRy9MWEa0lGyJWuHk/Pu+yUpLly7RG6NIpC0lCgla3ssiy2x+8/G+bz + DWjrKUMxgWtqfjfffRiKEJZ6Z2sAXJ1ePvDmMtbGoolWSrzsV2+cWh0byYrEBuVBe9 + Vp0ye7gJ4Wt610s4QHa4xoYcm7h9KGmE3IEjb+XYFv1HMJIOoACl04BwkLctza1KBr + XlIqC+snvRP/yQxa2+6RYGXgQD5JnJxCM1orXVIJxyyJxTzb3XgNir60Gb4HI9724H + LDZy0Hq7NQ1zF0h1yVUOklDotw17isbNoI4K3JCExR+r7GsdESsGY6cwAbZY71iWlf + OsSSrV6TZtAMg== +Received: from jupiter.universe (dyndsl-091-249-076-032.ewe-ip-backbone.de + [91.249.76.32]) + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) + key-exchange X25519 server-signature RSA-PSS (4096 bits)) + (No client certificate requested) (Authenticated sender: sre) + by bali.collaboradmins.com (Postfix) with ESMTPSA id A18CC17E0881; + Wed, 26 Feb 2025 19:45:07 +0100 (CET) +Received: by jupiter.universe (Postfix, from userid 1000) + id 32E35480034; Wed, 26 Feb 2025 19:45:07 +0100 (CET) +From: Sebastian Reichel +To: Marek Vasut , u-boot@lists.denx.de, + Jonas Karlman , Soeren Moch +Cc: Tim Harvey , + Philipp Tomsich , + Anand Moon , Maxim Kiselev , + Sebastian Reichel +Subject: [PATCH v2 1/4] usb: tcpm: improve handling of some power-supplies +Date: Wed, 26 Feb 2025 19:44:44 +0100 +Message-ID: <20250226184506.64114-2-sebastian.reichel@collabora.com> +X-Mailer: git-send-email 2.47.2 +In-Reply-To: <20250226184506.64114-1-sebastian.reichel@collabora.com> +References: <20250226184506.64114-1-sebastian.reichel@collabora.com> +MIME-Version: 1.0 +X-BeenThere: u-boot@lists.denx.de +X-Mailman-Version: 2.1.39 +Precedence: list +List-Id: U-Boot discussion +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Errors-To: u-boot-bounces@lists.denx.de +Sender: "U-Boot" +X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de +X-Virus-Status: Clean + +When the Rock 5B is booted with the current TCPM with its power supplied +by a "Cambrionix PDSync-C4" port it reaches the power-supply ready state. +Once that has happened the hub starts sending GetSinkCap messages, but +U-Boot already stopped processing PD messages. After retrying a bunch of +times the hub instead sends soft resets. Since U-Boot will also not +react to them, the USB hub will follow-up with a hard reset and that +cuts off the supply voltage. + +Since the state machine is already prepared to handle GetSinkCap +messages, try to avoid this by handling incoming messages for another +50ms after reaching the ready state. + +Fixes: 1db4c0ac77e3 ("usb: tcpm: add core framework") +Signed-off-by: Sebastian Reichel +--- + drivers/usb/tcpm/tcpm.c | 31 ++++++++++++++++++++++++++----- + 1 file changed, 26 insertions(+), 5 deletions(-) + +diff --git a/drivers/usb/tcpm/tcpm.c b/drivers/usb/tcpm/tcpm.c +index 0aee57cb2f4a..b754b4dcd0b5 100644 +--- a/drivers/usb/tcpm/tcpm.c ++++ b/drivers/usb/tcpm/tcpm.c +@@ -2229,6 +2229,17 @@ static int tcpm_port_init(struct udevice *dev) + return 0; + } + ++static inline void tcpm_poll_one_event(struct udevice *dev) ++{ ++ const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); ++ struct tcpm_port *port = dev_get_uclass_plat(dev); ++ ++ drvops->poll_event(dev); ++ port->poll_event_cnt++; ++ udelay(500); ++ tcpm_check_and_run_delayed_work(dev); ++} ++ + static void tcpm_poll_event(struct udevice *dev) + { + const struct dm_tcpm_ops *drvops = dev_get_driver_ops(dev); +@@ -2242,15 +2253,25 @@ static void tcpm_poll_event(struct udevice *dev) + (port->state == SNK_READY || port->state == SRC_READY)) + break; + +- drvops->poll_event(dev); +- port->poll_event_cnt++; +- udelay(500); +- tcpm_check_and_run_delayed_work(dev); ++ tcpm_poll_one_event(dev); + } + +- if (port->state != SNK_READY && port->state != SRC_READY) ++ /* ++ * Some power-supplies send GetSinkCap shortly after they are ready. ++ * If they do not receive a response after a few retries they will issue ++ * a soft-reset followed by a hard reset, which kills the board power. ++ * Let's poll for 50ms after reaching the ready state to check if the ++ * power-supply wants something from us. ++ */ ++ if (port->state == SNK_READY) { ++ port->poll_event_cnt = 0; ++ ++ while (port->poll_event_cnt < 100) ++ tcpm_poll_one_event(dev); ++ } else { + dev_warn(dev, "TCPM: exit in state %s\n", + tcpm_states[port->state]); ++ } + + /* + * At this time, call the callback function of the respective pd chip + +From patchwork Wed Feb 26 18:44:45 2025 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Sebastian Reichel +X-Patchwork-Id: 2052546 +X-Patchwork-Delegate: marek.vasut@gmail.com +Return-Path: +X-Original-To: incoming@patchwork.ozlabs.org +Delivered-To: patchwork-incoming@legolas.ozlabs.org +Authentication-Results: legolas.ozlabs.org; + dkim=pass (2048-bit key; + unprotected) header.d=collabora.com header.i=@collabora.com + header.a=rsa-sha256 header.s=mail header.b=hgX6o5vZ; + dkim-atps=neutral +Authentication-Results: legolas.ozlabs.org; + spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de + (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; + envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) +Received: from phobos.denx.de (phobos.denx.de + [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) + key-exchange X25519 server-signature ECDSA (secp384r1)) + (No client certificate requested) + by legolas.ozlabs.org (Postfix) with ESMTPS id 4Z33MJ5sFGz1yCp + for ; Thu, 27 Feb 2025 05:45:48 +1100 (AEDT) +Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) + by phobos.denx.de (Postfix) with ESMTP id 69A29811C5; + Wed, 26 Feb 2025 19:45:17 +0100 (CET) +Authentication-Results: phobos.denx.de; + dmarc=pass (p=none dis=none) header.from=collabora.com +Authentication-Results: phobos.denx.de; + spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de +Authentication-Results: phobos.denx.de; + dkim=pass (2048-bit key; + unprotected) header.d=collabora.com header.i=@collabora.com + header.b="hgX6o5vZ"; + dkim-atps=neutral +Received: by phobos.denx.de (Postfix, from userid 109) + id 832B180FB9; Wed, 26 Feb 2025 19:45:14 +0100 (CET) +X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de +X-Spam-Level: +X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, + DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, + RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, + SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 +Received: from bali.collaboradmins.com (bali.collaboradmins.com + [148.251.105.195]) + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) + (No client certificate requested) + by phobos.denx.de (Postfix) with ESMTPS id 2178380FF0 + for ; Wed, 26 Feb 2025 19:45:08 +0100 (CET) +Authentication-Results: phobos.denx.de; + dmarc=pass (p=none dis=none) header.from=collabora.com +Authentication-Results: phobos.denx.de; + spf=pass smtp.mailfrom=sebastian.reichel@collabora.com +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; + s=mail; t=1740595507; + bh=H/gQCZCWVmLNRIaBLvWsE35SaDMWvta2+rTkymkHQJE=; + h=From:To:Cc:Subject:Date:In-Reply-To:References:From; + b=hgX6o5vZwM72CR2hgo76tgo2eE00qHM7oNja381ACl8gIUUVioy8RTeqXtum89tBf + aIwKm/oNQNvGxy92pX5/1Jg/MwYZKS8jDukz6ZgsLKu22rJXf58FFoV095AcEkUMB2 + lrO4KJgFW/x1FK8GmSVSXXH+iUYJLkzsfZKgHKoQYHZcVXJRgFjHR5ytGKsA/fq4el + 7Wrx3lmLNjL7fYlDF5AyY+Wl6hqzjDq58nFedXHv8TEHx6fzfB0IBzOL/F8bGqVcyy + lal7bjJvMPoA9zfgIC77R1neWktg5FSro75YciSRSj9lmMNCmESnSPCgsZ4wBW0V6f + ppD77gOtjDfLQ== +Received: from jupiter.universe (dyndsl-091-249-076-032.ewe-ip-backbone.de + [91.249.76.32]) + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) + key-exchange X25519 server-signature RSA-PSS (4096 bits)) + (No client certificate requested) (Authenticated sender: sre) + by bali.collaboradmins.com (Postfix) with ESMTPSA id 9725D17E087F; + Wed, 26 Feb 2025 19:45:07 +0100 (CET) +Received: by jupiter.universe (Postfix, from userid 1000) + id 34511480037; Wed, 26 Feb 2025 19:45:07 +0100 (CET) +From: Sebastian Reichel +To: Marek Vasut , u-boot@lists.denx.de, + Jonas Karlman , Soeren Moch +Cc: Tim Harvey , + Philipp Tomsich , + Anand Moon , Maxim Kiselev , + Sebastian Reichel +Subject: [PATCH v2 2/4] usb: tcpm: avoid resets for missing source capability + messages +Date: Wed, 26 Feb 2025 19:44:45 +0100 +Message-ID: <20250226184506.64114-3-sebastian.reichel@collabora.com> +X-Mailer: git-send-email 2.47.2 +In-Reply-To: <20250226184506.64114-1-sebastian.reichel@collabora.com> +References: <20250226184506.64114-1-sebastian.reichel@collabora.com> +MIME-Version: 1.0 +X-BeenThere: u-boot@lists.denx.de +X-Mailman-Version: 2.1.39 +Precedence: list +List-Id: U-Boot discussion +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Errors-To: u-boot-bounces@lists.denx.de +Sender: "U-Boot" +X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de +X-Virus-Status: Clean + +The current TCPM code implements source capability message handling +according to the USB-PD specification. Unfortunately some USB PD +sources do not properly follow the specification and do not send +source capability messages after a soft reset when they already +negotiated a specific contract before. The currently implemented way +(and what is described in the specificiation) to resolve this problem +is triggering a hard reset. + +But a hard reset is fatal on batteryless platforms powered via USB-C PD, +since that removes VBUS for some time. Since this is triggered at boot +time, the system may get stuck in a boot loop. + +For example I noticed the following behaviour on a Radxa Rock 5B +combined with an affected power-supply: + +1. The system is booted up with current code +2. A reboot is requested +3. U-Boot TCPM / fusb302 driver sends soft reset and waits for the + source capability message +4. No new source capability message is send by the power-supply + after the soft reset +5. U-Boot sends a hard reset +6. The board resets, but the fusb302 registers are not reset. This + is because of a hardware glitch. The serial pins are high when + no data is exchanged. Apparently the RK3588 has protection diodes, + which leak some voltage into the power-domain. The Rock 5B serial + pins and the fusb302 are using the same 3.3V power domain and the + leaked voltage is enough to keep the fusb302 registers alive. +7. After the hard reset the power-supply sends another source capability + message, which is auto-acked by fusb302 (because the register state + is kept) even though the U-Boot driver has not yet probed. Once the + U-Boot driver probes it sends another soft reset and waits for a new + source capability message, which never arrives. + +Fortunately the affected power-supplies (I have two setups showing this +behaviour) support sending a source capability message when explicitly +being asked. Thus an easy workaround to handle this is deviating from +the USB-PD specification and sending a Get_Source_Cap message and +waiting some time longer before doing the hard reset. + +Note, that I recently added the same workaround to the Linux kernel +with a slightly different rationale (since it needs to take over from +U-Boot). + +Fixes: 1db4c0ac77e3 ("usb: tcpm: add core framework") +Signed-off-by: Sebastian Reichel +--- + drivers/usb/tcpm/tcpm-internal.h | 1 + + drivers/usb/tcpm/tcpm.c | 32 +++++++++++++++++++++++++++++--- + 2 files changed, 30 insertions(+), 3 deletions(-) + +diff --git a/drivers/usb/tcpm/tcpm-internal.h b/drivers/usb/tcpm/tcpm-internal.h +index 561442090027..4861f4d13866 100644 +--- a/drivers/usb/tcpm/tcpm-internal.h ++++ b/drivers/usb/tcpm/tcpm-internal.h +@@ -30,6 +30,7 @@ + S(SNK_DISCOVERY_DEBOUNCE), \ + S(SNK_DISCOVERY_DEBOUNCE_DONE), \ + S(SNK_WAIT_CAPABILITIES), \ ++ S(SNK_WAIT_CAPABILITIES_TIMEOUT), \ + S(SNK_NEGOTIATE_CAPABILITIES), \ + S(SNK_TRANSITION_SINK), \ + S(SNK_TRANSITION_SINK_VBUS), \ +diff --git a/drivers/usb/tcpm/tcpm.c b/drivers/usb/tcpm/tcpm.c +index b754b4dcd0b5..786d92fa4c6f 100644 +--- a/drivers/usb/tcpm/tcpm.c ++++ b/drivers/usb/tcpm/tcpm.c +@@ -1424,7 +1424,8 @@ static inline enum tcpm_state hard_reset_state(struct tcpm_port *port) + return ERROR_RECOVERY; + if (port->pwr_role == TYPEC_SOURCE) + return SRC_UNATTACHED; +- if (port->state == SNK_WAIT_CAPABILITIES) ++ if (port->state == SNK_WAIT_CAPABILITIES || ++ port->state == SNK_WAIT_CAPABILITIES_TIMEOUT) + return SNK_READY; + return SNK_UNATTACHED; + } +@@ -1650,10 +1651,35 @@ static void run_state_machine(struct udevice *dev) + tcpm_set_state(dev, SOFT_RESET_SEND, + PD_T_SINK_WAIT_CAP); + } else { +- tcpm_set_state(dev, hard_reset_state(port), +- PD_T_SINK_WAIT_CAP); ++ if (!port->self_powered) ++ tcpm_set_state(dev, SNK_WAIT_CAPABILITIES_TIMEOUT, ++ PD_T_SINK_WAIT_CAP); ++ else ++ tcpm_set_state(dev, hard_reset_state(port), ++ PD_T_SINK_WAIT_CAP); + } + break; ++ case SNK_WAIT_CAPABILITIES_TIMEOUT: ++ /* ++ * There are some USB PD sources in the field, which do not ++ * properly implement the specification and fail to start ++ * sending Source Capability messages after a soft reset. The ++ * specification suggests to do a hard reset when no Source ++ * capability message is received within PD_T_SINK_WAIT_CAP, ++ * but that might effectively kil the machine's power source. ++ * ++ * This slightly diverges from the specification and tries to ++ * recover from this by explicitly asking for the capabilities ++ * using the Get_Source_Cap control message before falling back ++ * to a hard reset. The control message should also be supported ++ * and handled by all USB PD source and dual role devices ++ * according to the specification. ++ */ ++ if (tcpm_pd_send_control(dev, PD_CTRL_GET_SOURCE_CAP)) ++ tcpm_set_state_cond(dev, hard_reset_state(port), 0); ++ else ++ tcpm_set_state(dev, hard_reset_state(port), PD_T_SINK_WAIT_CAP); ++ break; + case SNK_NEGOTIATE_CAPABILITIES: + port->pd_capable = true; + port->hard_reset_count = 0; + +From patchwork Wed Feb 26 18:44:46 2025 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Sebastian Reichel +X-Patchwork-Id: 2052545 +X-Patchwork-Delegate: marek.vasut@gmail.com +Return-Path: +X-Original-To: incoming@patchwork.ozlabs.org +Delivered-To: patchwork-incoming@legolas.ozlabs.org +Authentication-Results: legolas.ozlabs.org; + dkim=pass (2048-bit key; + unprotected) header.d=collabora.com header.i=@collabora.com + header.a=rsa-sha256 header.s=mail header.b=BxTv7Lfo; + dkim-atps=neutral +Authentication-Results: legolas.ozlabs.org; + spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de + (client-ip=85.214.62.61; helo=phobos.denx.de; + envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) +Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) + key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) + (No client certificate requested) + by legolas.ozlabs.org (Postfix) with ESMTPS id 4Z33M971h7z1yCp + for ; Thu, 27 Feb 2025 05:45:41 +1100 (AEDT) +Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) + by phobos.denx.de (Postfix) with ESMTP id 1B09C8118B; + Wed, 26 Feb 2025 19:45:17 +0100 (CET) +Authentication-Results: phobos.denx.de; + dmarc=pass (p=none dis=none) header.from=collabora.com +Authentication-Results: phobos.denx.de; + spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de +Authentication-Results: phobos.denx.de; + dkim=pass (2048-bit key; + unprotected) header.d=collabora.com header.i=@collabora.com + header.b="BxTv7Lfo"; + dkim-atps=neutral +Received: by phobos.denx.de (Postfix, from userid 109) + id 4399E810F9; Wed, 26 Feb 2025 19:45:14 +0100 (CET) +X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de +X-Spam-Level: +X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, + DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, + SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 +Received: from bali.collaboradmins.com (bali.collaboradmins.com + [IPv6:2a01:4f8:201:9162::2]) + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) + (No client certificate requested) + by phobos.denx.de (Postfix) with ESMTPS id 2163F80FB9 + for ; Wed, 26 Feb 2025 19:45:08 +0100 (CET) +Authentication-Results: phobos.denx.de; + dmarc=pass (p=none dis=none) header.from=collabora.com +Authentication-Results: phobos.denx.de; + spf=pass smtp.mailfrom=sebastian.reichel@collabora.com +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; + s=mail; t=1740595507; + bh=7OaDpd2idE5ETWAiOZte0kuOU6ZYitEVWkDgDmqaQU8=; + h=From:To:Cc:Subject:Date:In-Reply-To:References:From; + b=BxTv7LfoAae43YSXPquVPmmwStgQirXCxaSBD0fo554R5O/si/Iif5L+zXXJocATJ + z7+I7ZKbknkTeVyzoRDCXvXIVz2bFdTRWQN4Z2iwJbVI1covAv/Gn4wIE2Q6hbNKbU + qV5AKg7gvrKkbztbo7N9bHNjkrlAbd8B4Ew3SR8FM46DMAOwNzVsoX3rLMcPtlWzHj + 4OBKCx22H/4ASIWjMbYoDE09DyQ+CPOf8JcX8OPwFcH9j6vW6cEWvyjiAyDj6LnwOq + KD+ZYVIkWhkIzAkE2NHB2IpA4xlxW8i18BJzNBD8N1eBx/HCgb0camb4KanY1Hta/d + 4ipLyuFaCkMog== +Received: from jupiter.universe (dyndsl-091-249-076-032.ewe-ip-backbone.de + [91.249.76.32]) + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) + key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest + SHA256) + (No client certificate requested) (Authenticated sender: sre) + by bali.collaboradmins.com (Postfix) with ESMTPSA id 816AA17E0861; + Wed, 26 Feb 2025 19:45:07 +0100 (CET) +Received: by jupiter.universe (Postfix, from userid 1000) + id 361F2480038; Wed, 26 Feb 2025 19:45:07 +0100 (CET) +From: Sebastian Reichel +To: Marek Vasut , u-boot@lists.denx.de, + Jonas Karlman , Soeren Moch +Cc: Tim Harvey , + Philipp Tomsich , + Anand Moon , Maxim Kiselev , + Sebastian Reichel +Subject: [PATCH v2 3/4] usb: tcpm: print error on hard reset +Date: Wed, 26 Feb 2025 19:44:46 +0100 +Message-ID: <20250226184506.64114-4-sebastian.reichel@collabora.com> +X-Mailer: git-send-email 2.47.2 +In-Reply-To: <20250226184506.64114-1-sebastian.reichel@collabora.com> +References: <20250226184506.64114-1-sebastian.reichel@collabora.com> +MIME-Version: 1.0 +X-BeenThere: u-boot@lists.denx.de +X-Mailman-Version: 2.1.39 +Precedence: list +List-Id: U-Boot discussion +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Errors-To: u-boot-bounces@lists.denx.de +Sender: "U-Boot" +X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de +X-Virus-Status: Clean + +A USB-PD hard reset involves removing the voltage from VBUS for some +time. So basically it has the same effect as removing the USB-C plug +for a short moment. If the machine is powered from the USB-C port and +does not have a fallback supply (e.g. a battery), this will result in +a full machine reset due to power loss. + +Ideally we want to avoid triggering a hard reset on these boards. A +non-working USB-C port is probably better than unplanned reboots. But +boards with a backup supply should do the hard reset to get everything +working again. + +In theory it would be enough to check the self_powered property, but +it seems the property might not be configured consistently enough in +system firmwares. + +USB-PD hard resets should happen rarely in general, so let's at least +print an error message before the potential board reset happens. This +is also useful, since it immediately gives away which device triggered +the hard reset. + +Fixes: 1db4c0ac77e3 ("usb: tcpm: add core framework") +Signed-off-by: Sebastian Reichel +--- + drivers/usb/tcpm/tcpm.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/usb/tcpm/tcpm.c b/drivers/usb/tcpm/tcpm.c +index 786d92fa4c6f..909fe2ef4fcb 100644 +--- a/drivers/usb/tcpm/tcpm.c ++++ b/drivers/usb/tcpm/tcpm.c +@@ -1711,6 +1711,8 @@ static void run_state_machine(struct udevice *dev) + + /* Hard_Reset states */ + case HARD_RESET_SEND: ++ if (!port->self_powered && port->port_type == TYPEC_PORT_SNK) ++ dev_err(dev, "Initiating hard-reset, which might result in machine power-loss.\n"); + tcpm_pd_transmit(dev, TCPC_TX_HARD_RESET, NULL); + tcpm_set_state(dev, HARD_RESET_START, 0); + port->wait_dr_swap_message = false; + +From patchwork Wed Feb 26 18:44:47 2025 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Sebastian Reichel +X-Patchwork-Id: 2052542 +X-Patchwork-Delegate: marek.vasut@gmail.com +Return-Path: +X-Original-To: incoming@patchwork.ozlabs.org +Delivered-To: patchwork-incoming@legolas.ozlabs.org +Authentication-Results: legolas.ozlabs.org; + dkim=pass (2048-bit key; + unprotected) header.d=collabora.com header.i=@collabora.com + header.a=rsa-sha256 header.s=mail header.b=K4mNmlOy; + dkim-atps=neutral +Authentication-Results: legolas.ozlabs.org; + spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de + (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; + envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) +Received: from phobos.denx.de (phobos.denx.de + [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) + key-exchange X25519 server-signature ECDSA (secp384r1)) + (No client certificate requested) + by legolas.ozlabs.org (Postfix) with ESMTPS id 4Z33Lk40FPz1yCp + for ; Thu, 27 Feb 2025 05:45:18 +1100 (AEDT) +Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) + by phobos.denx.de (Postfix) with ESMTP id DAFC780FF2; + Wed, 26 Feb 2025 19:45:12 +0100 (CET) +Authentication-Results: phobos.denx.de; + dmarc=pass (p=none dis=none) header.from=collabora.com +Authentication-Results: phobos.denx.de; + spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de +Authentication-Results: phobos.denx.de; + dkim=pass (2048-bit key; + unprotected) header.d=collabora.com header.i=@collabora.com + header.b="K4mNmlOy"; + dkim-atps=neutral +Received: by phobos.denx.de (Postfix, from userid 109) + id 56A22810F9; Wed, 26 Feb 2025 19:45:11 +0100 (CET) +X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de +X-Spam-Level: +X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, + DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, + SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 +Received: from bali.collaboradmins.com (bali.collaboradmins.com + [IPv6:2a01:4f8:201:9162::2]) + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) + (No client certificate requested) + by phobos.denx.de (Postfix) with ESMTPS id 217E080FF2 + for ; Wed, 26 Feb 2025 19:45:08 +0100 (CET) +Authentication-Results: phobos.denx.de; + dmarc=pass (p=none dis=none) header.from=collabora.com +Authentication-Results: phobos.denx.de; + spf=pass smtp.mailfrom=sebastian.reichel@collabora.com +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; + s=mail; t=1740595507; + bh=FeXZr6pfjIqGXvnsLHDigD702EmgVNH91IWVsD16udQ=; + h=From:To:Cc:Subject:Date:In-Reply-To:References:From; + b=K4mNmlOycXzLuJnNeDxyXLVCeZWNr//ycRqDt3ld9634ThDvJ0+y49X3z2nYW+fei + HCqH2AoFiXj7khjiFpwCA4xOlYaTrF9yb0M9ApRxJ8vGuslNIK2k9osj8IJMoWmY8S + fEez4H6Wso4VamCnXKCze2G5np5mhola5QxSnIJ2CXdFP9TM1x54P+XyeJMX6IZK0X + lpZ0R8mACHGgXnkBASRMbo0CnLfSVrUgA83A0FHT7UgxfW8399wHol/FBakg5WS8nt + 47154TDW4ikoGF4dHBeD0KemJSR7I4F+nnUVQfgg8sXZKVm4yilBT+yx3WWBVCjQDl + 3igqfexnaUKnA== +Received: from jupiter.universe (dyndsl-091-249-076-032.ewe-ip-backbone.de + [91.249.76.32]) + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) + key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest + SHA256) + (No client certificate requested) (Authenticated sender: sre) + by bali.collaboradmins.com (Postfix) with ESMTPSA id 7FBB317E065A; + Wed, 26 Feb 2025 19:45:07 +0100 (CET) +Received: by jupiter.universe (Postfix, from userid 1000) + id 37B6A480039; Wed, 26 Feb 2025 19:45:07 +0100 (CET) +From: Sebastian Reichel +To: Marek Vasut , u-boot@lists.denx.de, + Jonas Karlman , Soeren Moch +Cc: Tim Harvey , + Philipp Tomsich , + Anand Moon , Maxim Kiselev , + Sebastian Reichel +Subject: [PATCH v2 4/4] usb: tcpm: improve data role mismatch error recovery +Date: Wed, 26 Feb 2025 19:44:47 +0100 +Message-ID: <20250226184506.64114-5-sebastian.reichel@collabora.com> +X-Mailer: git-send-email 2.47.2 +In-Reply-To: <20250226184506.64114-1-sebastian.reichel@collabora.com> +References: <20250226184506.64114-1-sebastian.reichel@collabora.com> +MIME-Version: 1.0 +X-BeenThere: u-boot@lists.denx.de +X-Mailman-Version: 2.1.39 +Precedence: list +List-Id: U-Boot discussion +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Errors-To: u-boot-bounces@lists.denx.de +Sender: "U-Boot" +X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de +X-Virus-Status: Clean + +On Radxa ROCK 5B I managed to get U-Boot into an endless loop of +printing + +fusb302 usb-typec@22: TCPM: data role mismatch, initiating error recovery + +messages by changing the data role in Linux and then rebooting the +system. This is happening because the external device (A cheap USB-C hub +powered through a USB-C PD power-supply) kept its state and the error +recovery path for non self-powered devices is not enough to change it. + +Avoid this by swapping our own data role when the error recovery stage +is reached for a port, which is not self-powered. Right now data support +is limited anyways and once proper support is added we can use the data +role swap request to get the desired data direction after the initial +negotiation completed. + +Fixes: 1db4c0ac77e3 ("usb: tcpm: add core framework") +Signed-off-by: Sebastian Reichel +--- + drivers/usb/tcpm/tcpm.c | 30 +++++++++++++++++++++++++++--- + 1 file changed, 27 insertions(+), 3 deletions(-) + +diff --git a/drivers/usb/tcpm/tcpm.c b/drivers/usb/tcpm/tcpm.c +index 909fe2ef4fcb..12d66d470f9a 100644 +--- a/drivers/usb/tcpm/tcpm.c ++++ b/drivers/usb/tcpm/tcpm.c +@@ -833,6 +833,28 @@ static void tcpm_pd_ctrl_request(struct udevice *dev, + } + } + ++static void tcpm_recover_data_role_mismatch(struct udevice *dev) ++{ ++ struct tcpm_port *port = dev_get_uclass_plat(dev); ++ ++ dev_err(dev, "TCPM: data role mismatch, initiating error recovery\n"); ++ if (port->self_powered) { ++ tcpm_set_state(dev, ERROR_RECOVERY, 0); ++ return; ++ } ++ ++ /* ++ * The error recovery will not help for devices, which are not ++ * self-powered because the error recovery avoids killing the board ++ * power. Since this can happen early on sending ++ * a DR_SWAP request is not sensible. Instead let's change our own ++ * data role. It can be swapped back once USB-PD reached the ready ++ * state. ++ */ ++ tcpm_set_roles(dev, true, port->pwr_role, ++ port->data_role == TYPEC_HOST ? TYPEC_DEVICE : TYPEC_HOST); ++} ++ + static void tcpm_pd_rx_handler(struct udevice *dev, + const struct pd_message *msg) + { +@@ -867,9 +889,11 @@ static void tcpm_pd_rx_handler(struct udevice *dev, + remote_is_host = !!(le16_to_cpu(msg->header) & PD_HEADER_DATA_ROLE); + local_is_host = port->data_role == TYPEC_HOST; + if (remote_is_host == local_is_host) { +- dev_err(dev, "TCPM: data role mismatch, initiating error recovery\n"); +- tcpm_set_state(dev, ERROR_RECOVERY, 0); +- } else { ++ tcpm_recover_data_role_mismatch(dev); ++ local_is_host = port->data_role == TYPEC_HOST; ++ } ++ ++ if (remote_is_host != local_is_host) { + if (cnt) + tcpm_pd_data_request(dev, msg); + else diff --git a/aarch64-boards b/aarch64-boards index 0530e42..366d0c8 100644 --- a/aarch64-boards +++ b/aarch64-boards @@ -1,6 +1,7 @@ a64-olinuxino a64-olinuxino-emmc amarula_a64_relic +anbernic_rg35xx_h700 apple_m1 bananapi_m2_plus_h5 bananapi_m64 @@ -44,6 +45,7 @@ nanopi_neo_plus2 nanopi_r1s_h5 nanopi-r2c-plus-rk3328 nanopi-r2c-rk3328 +nanopi-r2s-plus-rk3328 nanopi-r2s-rk3328 nanopi-r4s-rk3399 oceanic_5205_5inmfd @@ -65,7 +67,6 @@ orangepi_zero_plus2 p212 p2371-2180 p2771-0000-500 -p3450-0000 pine64-lts pine64_plus pinebook @@ -78,7 +79,10 @@ poplar puma-rk3399 qcm6490 qcom +qcom_qcs8300 +qcom_qcs9100 qemu_arm64 +qemu_arm64_lwip roc-cc-rk3328 rock-4c-plus-rk3399 rock-4se-rk3399 @@ -100,4 +104,3 @@ transpeed-8k618-t turris_mox vexpress_aemv8a_juno x96_mate -xilinx_zynqmp_virt diff --git a/disable-VBE-by-default.patch b/disable-VBE-by-default.patch index dffa9fc..1f1b710 100644 --- a/disable-VBE-by-default.patch +++ b/disable-VBE-by-default.patch @@ -1,10 +1,14 @@ -From 02513d9ecc38d11ffc051ed59529e11f82164785 Mon Sep 17 00:00:00 2001 +From d9e3a49bc2a29922da5bddd95772279f6edba802 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Fri, 18 Aug 2023 13:28:05 +0100 Subject: [PATCH] disable VBE by default -Fedora doesn't support the VBE boot method, disable it -to reduce size and remove a possible boot attack vector. +The VBE protocol needs explicit device support and as +such isn't particularly useful by itself without that, +it also adds size and the potential of an attack vector +so devices that wish to use this protocol should +explicitly opt in to it like all other large features +in U-Boot. Signed-off-by: Peter Robinson --- @@ -12,10 +16,10 @@ Signed-off-by: Peter Robinson 1 file changed, 1 deletion(-) diff --git a/boot/Kconfig b/boot/Kconfig -index e8fb03b8016..467b09e2350 100644 +index 30eb5b328d7..e8c3fbcb11d 100644 --- a/boot/Kconfig +++ b/boot/Kconfig -@@ -526,7 +526,6 @@ config BOOTMETH_EFILOADER +@@ -635,7 +635,6 @@ config BOOTMETH_QFW config BOOTMETH_VBE bool "Bootdev support for Verified Boot for Embedded" depends on FIT @@ -24,5 +28,5 @@ index e8fb03b8016..467b09e2350 100644 select EVENT help -- -2.41.0 +2.49.0 diff --git a/p3450-fix-board.patch b/p3450-fix-board.patch new file mode 100644 index 0000000..74475d5 --- /dev/null +++ b/p3450-fix-board.patch @@ -0,0 +1,25 @@ +From c9b65320d64a60cde74c4c1f9cb4a05198a456c2 Mon Sep 17 00:00:00 2001 +From: Peter Robinson +Date: Wed, 10 Sep 2025 13:27:52 +0100 +Subject: [PATCH] further size reductions + +--- + configs/p3450-0000_defconfig | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/configs/p3450-0000_defconfig b/configs/p3450-0000_defconfig +index 2ebcf8b83fc..a5e717a02ed 100644 +--- a/configs/p3450-0000_defconfig ++++ b/configs/p3450-0000_defconfig +@@ -27,6 +27,8 @@ CONFIG_CONSOLE_MUX=y + CONFIG_SYS_STDIO_DEREGISTER=y + CONFIG_SYS_PROMPT="Tegra210 (P3450-0000) # " + # CONFIG_BOOTM_PLAN9 is not set ++# CONFIG_SYS_DTC_PAD_BYTES is not set ++# CONFIG_LEGACY_IMAGE_FORMAT is not set + # CONFIG_BOOTM_RTEMS is not set + # CONFIG_BOOTM_VXWORKS is not set + # CONFIG_CMD_ELF is not set +-- +2.51.0 + diff --git a/raspberrypi-Add-quirk-for-RPi5-2Gb-rev-1.0.patch b/raspberrypi-Add-quirk-for-RPi5-2Gb-rev-1.0.patch new file mode 100644 index 0000000..d6612ee --- /dev/null +++ b/raspberrypi-Add-quirk-for-RPi5-2Gb-rev-1.0.patch @@ -0,0 +1,32 @@ +From 72fd4fdb54721a31d2b4e9f95fdd3b3e398bb2c0 Mon Sep 17 00:00:00 2001 +From: Peter Robinson +Date: Sun, 12 Apr 2026 01:14:12 +0100 +Subject: [PATCH] board/raspberrypi: Add quirk for RPi5 2Gb rev 1.0 + +All 2Gb Raspberry Pi 5s use the BCM2712D0 silicon, but +the early boards were still rev 1.0 so we need a quirk +to ensure the correct device tree is used. + +Signed-off-by: Peter Robinson +--- + board/raspberrypi/rpi/rpi.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c +index b0a1484c0fa..ff9cab6521b 100644 +--- a/board/raspberrypi/rpi/rpi.c ++++ b/board/raspberrypi/rpi/rpi.c +@@ -371,6 +371,10 @@ static void set_fdtfile(void) + const char *fdtfile; + int rev = revision & 0x0f; + ++ /* 2GB Pi 5B board rev 1.0 always has BCM2712D0 silicon */ ++ if (revision == 0xb04170) ++ rev = 1; ++ + if (env_get("fdtfile")) + return; + +-- +2.53.0 + diff --git a/riscv64-boards b/riscv64-boards new file mode 100644 index 0000000..f96e775 --- /dev/null +++ b/riscv64-boards @@ -0,0 +1,4 @@ +qemu-riscv64_spl +sifive_unleashed +sifive_unmatched +starfive_visionfive2 diff --git a/rockchip-Enable-preboot-start-for-pci-usb.patch b/rockchip-Enable-preboot-start-for-pci-usb.patch index 0542ab0..30aad4d 100644 --- a/rockchip-Enable-preboot-start-for-pci-usb.patch +++ b/rockchip-Enable-preboot-start-for-pci-usb.patch @@ -1,177 +1,10 @@ -From 3665ff79304fcb47427651125ccc2cfac01cb9f1 Mon Sep 17 00:00:00 2001 +From a6909a16b4cc301f1007d9e75d02abb6d06a1ea7 Mon Sep 17 00:00:00 2001 From: Peter Robinson -Date: Sat, 25 May 2024 12:23:42 +0100 +Date: Thu, 28 May 2026 21:29:29 +0100 Subject: [PATCH] rockchip: Enable preboot start for pci/usb Enable the preboot so nvme works OOTB -Signed-off-by: Peter Robinson ---- - configs/firefly-rk3399_defconfig | 2 ++ - configs/nanopc-t4-rk3399_defconfig | 2 ++ - configs/pinebook-pro-rk3399_defconfig | 1 + - configs/roc-pc-mezzanine-rk3399_defconfig | 2 ++ - configs/rock-4c-plus-rk3399_defconfig | 2 ++ - configs/rock-4se-rk3399_defconfig | 2 ++ - configs/rock-pi-4-rk3399_defconfig | 2 ++ - configs/rock-pi-4c-rk3399_defconfig | 2 ++ - configs/rock-pi-n10-rk3399pro_defconfig | 2 ++ - configs/rock960-rk3399_defconfig | 2 ++ - configs/rockpro64-rk3399_defconfig | 2 ++ - 11 files changed, 21 insertions(+) - -diff --git a/configs/firefly-rk3399_defconfig b/configs/firefly-rk3399_defconfig -index edacef29edf..71db7b7834e 100644 ---- a/configs/firefly-rk3399_defconfig -+++ b/configs/firefly-rk3399_defconfig -@@ -14,6 +14,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0x800800 - CONFIG_PCI=y - CONFIG_DEBUG_UART=y -+CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-firefly.dtb" - CONFIG_DISPLAY_BOARDINFO_LATE=y - CONFIG_SPL_MAX_SIZE=0x40000 -diff --git a/configs/nanopc-t4-rk3399_defconfig b/configs/nanopc-t4-rk3399_defconfig -index c63f4c076d5..7174b82cfa4 100644 ---- a/configs/nanopc-t4-rk3399_defconfig -+++ b/configs/nanopc-t4-rk3399_defconfig -@@ -14,6 +14,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0x800800 - CONFIG_PCI=y - CONFIG_DEBUG_UART=y -+CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-nanopc-t4.dtb" - CONFIG_DISPLAY_BOARDINFO_LATE=y - CONFIG_SPL_MAX_SIZE=0x40000 -diff --git a/configs/pinebook-pro-rk3399_defconfig b/configs/pinebook-pro-rk3399_defconfig -index 5d3e32f9108..c9b3615f2ff 100644 ---- a/configs/pinebook-pro-rk3399_defconfig -+++ b/configs/pinebook-pro-rk3399_defconfig -@@ -21,6 +21,7 @@ CONFIG_PCI=y - CONFIG_DEBUG_UART=y - CONFIG_BOOTDELAY=3 - CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-pinebook-pro.dtb" - CONFIG_DISPLAY_BOARDINFO_LATE=y - CONFIG_SPL_MAX_SIZE=0x40000 -diff --git a/configs/roc-pc-mezzanine-rk3399_defconfig b/configs/roc-pc-mezzanine-rk3399_defconfig -index a57899bfdfa..bd7030b237c 100644 ---- a/configs/roc-pc-mezzanine-rk3399_defconfig -+++ b/configs/roc-pc-mezzanine-rk3399_defconfig -@@ -20,6 +20,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0x800800 - CONFIG_PCI=y - CONFIG_DEBUG_UART=y -+CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - # CONFIG_ANDROID_BOOT_IMAGE is not set - CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-roc-pc-mezzanine.dtb" - CONFIG_DISPLAY_BOARDINFO_LATE=y -diff --git a/configs/rock-4c-plus-rk3399_defconfig b/configs/rock-4c-plus-rk3399_defconfig -index 80dc44986e7..0ff8afe8e1e 100644 ---- a/configs/rock-4c-plus-rk3399_defconfig -+++ b/configs/rock-4c-plus-rk3399_defconfig -@@ -16,6 +16,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y - CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0x800800 - CONFIG_DEBUG_UART=y -+CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - # CONFIG_ANDROID_BOOT_IMAGE is not set - CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rock-4c-plus.dtb" - CONFIG_DISPLAY_BOARDINFO_LATE=y -diff --git a/configs/rock-4se-rk3399_defconfig b/configs/rock-4se-rk3399_defconfig -index f52d4bf9913..72ff304cff7 100644 ---- a/configs/rock-4se-rk3399_defconfig -+++ b/configs/rock-4se-rk3399_defconfig -@@ -17,6 +17,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0x800800 - CONFIG_PCI=y - CONFIG_DEBUG_UART=y -+CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y - # CONFIG_ANDROID_BOOT_IMAGE is not set - CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rock-4se.dtb" -diff --git a/configs/rock-pi-4-rk3399_defconfig b/configs/rock-pi-4-rk3399_defconfig -index e71c4588b94..387dbf83be3 100644 ---- a/configs/rock-pi-4-rk3399_defconfig -+++ b/configs/rock-pi-4-rk3399_defconfig -@@ -17,6 +17,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0x800800 - CONFIG_PCI=y - CONFIG_DEBUG_UART=y -+CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y - # CONFIG_ANDROID_BOOT_IMAGE is not set - CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rock-pi-4a.dtb" -diff --git a/configs/rock-pi-4c-rk3399_defconfig b/configs/rock-pi-4c-rk3399_defconfig -index 14373933a34..34e09eeccd2 100644 ---- a/configs/rock-pi-4c-rk3399_defconfig -+++ b/configs/rock-pi-4c-rk3399_defconfig -@@ -17,6 +17,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0x800800 - CONFIG_PCI=y - CONFIG_DEBUG_UART=y -+CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y - # CONFIG_ANDROID_BOOT_IMAGE is not set - CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rock-pi-4c.dtb" -diff --git a/configs/rock-pi-n10-rk3399pro_defconfig b/configs/rock-pi-n10-rk3399pro_defconfig -index ec995a54a0e..1a973ea2c97 100644 ---- a/configs/rock-pi-n10-rk3399pro_defconfig -+++ b/configs/rock-pi-n10-rk3399pro_defconfig -@@ -13,6 +13,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0x800800 - CONFIG_PCI=y - CONFIG_DEBUG_UART=y -+CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - # CONFIG_ANDROID_BOOT_IMAGE is not set - CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399pro-rock-pi-n10.dtb" - # CONFIG_CONSOLE_MUX is not set -diff --git a/configs/rock960-rk3399_defconfig b/configs/rock960-rk3399_defconfig -index 8fff3ed17c2..ea6d6d4a319 100644 ---- a/configs/rock960-rk3399_defconfig -+++ b/configs/rock960-rk3399_defconfig -@@ -12,6 +12,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0x800800 - CONFIG_PCI=y - CONFIG_DEBUG_UART=y -+CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rock960.dtb" - CONFIG_SYS_PBSIZE=1052 - CONFIG_DISPLAY_BOARDINFO_LATE=y -diff --git a/configs/rockpro64-rk3399_defconfig b/configs/rockpro64-rk3399_defconfig -index fc0804a0b80..9a94d96b148 100644 ---- a/configs/rockpro64-rk3399_defconfig -+++ b/configs/rockpro64-rk3399_defconfig -@@ -19,6 +19,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0x800800 - CONFIG_PCI=y - CONFIG_DEBUG_UART=y -+CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_BOOTSTAGE=y - CONFIG_BOOTSTAGE_REPORT=y - CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rockpro64.dtb" --- -2.45.1 - -From 5116720be74a92417c69229fc45a97502869ff9b Mon Sep 17 00:00:00 2001 -From: Peter Robinson -Date: Mon, 23 Sep 2024 19:51:00 +0100 -Subject: [PATCH] rockchip: rk35xx: Enable preboot start for pci/usb - -Enable the preboot so nvme works OOTB - Signed-off-by: Peter Robinson --- configs/anbernic-rgxx3-rk3566_defconfig | 2 ++ @@ -181,10 +14,12 @@ Signed-off-by: Peter Robinson configs/coolpi-cm5-evb-rk3588_defconfig | 2 ++ configs/evb-rk3568_defconfig | 2 ++ configs/evb-rk3588_defconfig | 2 ++ + configs/firefly-rk3399_defconfig | 2 ++ configs/generic-rk3568_defconfig | 2 ++ configs/generic-rk3588_defconfig | 2 ++ configs/jaguar-rk3588_defconfig | 2 ++ configs/lubancat-2-rk3568_defconfig | 2 ++ + configs/nanopc-t4-rk3399_defconfig | 2 ++ configs/nanopc-t6-rk3588_defconfig | 2 ++ configs/nanopi-r5c-rk3568_defconfig | 2 ++ configs/nanopi-r5s-rk3568_defconfig | 2 ++ @@ -194,23 +29,37 @@ Signed-off-by: Peter Robinson configs/neu6b-io-rk3588_defconfig | 2 ++ configs/nova-rk3588s_defconfig | 2 ++ configs/odroid-m1-rk3568_defconfig | 2 ++ + configs/odroid-m1s-rk3566_defconfig | 2 ++ + configs/odroid-m2-rk3588s_defconfig | 2 ++ configs/orangepi-3b-rk3566_defconfig | 2 ++ + configs/orangepi-5-max-rk3588_defconfig | 2 ++ configs/orangepi-5-plus-rk3588_defconfig | 2 ++ configs/orangepi-5-rk3588s_defconfig | 2 ++ + configs/orangepi-5-ultra-rk3588_defconfig | 2 ++ + configs/pinebook-pro-rk3399_defconfig | 1 + configs/pinetab2-rk3566_defconfig | 2 ++ configs/powkiddy-x55-rk3566_defconfig | 2 ++ configs/quartz64-a-rk3566_defconfig | 2 ++ - configs/quartz64-b-rk3566_defconfig | 2 ++ + configs/quartz64-b-rk3566_defconfig | 4 ++++ configs/quartzpro64-rk3588_defconfig | 2 ++ configs/radxa-cm3-io-rk3566_defconfig | 2 ++ configs/radxa-e25-rk3568_defconfig | 2 ++ configs/radxa-zero-3-rk3566_defconfig | 2 ++ + configs/roc-pc-mezzanine-rk3399_defconfig | 2 ++ configs/rock-3a-rk3568_defconfig | 2 ++ configs/rock-3b-rk3568_defconfig | 2 ++ configs/rock-3c-rk3566_defconfig | 2 ++ + configs/rock-4c-plus-rk3399_defconfig | 2 ++ + configs/rock-4se-rk3399_defconfig | 2 ++ configs/rock-5-itx-rk3588_defconfig | 2 ++ + configs/rock-5c-rk3588s_defconfig | 2 ++ + configs/rock-pi-4-rk3399_defconfig | 2 ++ + configs/rock-pi-4c-rk3399_defconfig | 2 ++ + configs/rock-pi-n10-rk3399pro_defconfig | 2 ++ configs/rock5a-rk3588s_defconfig | 2 ++ configs/rock5b-rk3588_defconfig | 2 ++ + configs/rock960-rk3399_defconfig | 2 ++ + configs/rockpro64-rk3399_defconfig | 2 ++ configs/sige7-rk3588_defconfig | 2 ++ configs/soquartz-blade-rk3566_defconfig | 2 ++ configs/soquartz-cm4-rk3566_defconfig | 2 ++ @@ -218,40 +67,40 @@ Signed-off-by: Peter Robinson configs/tiger-rk3588_defconfig | 2 ++ configs/toybrick-rk3588_defconfig | 2 ++ configs/turing-rk1-rk3588_defconfig | 2 ++ - 44 files changed, 88 insertions(+) + 60 files changed, 121 insertions(+) diff --git a/configs/anbernic-rgxx3-rk3566_defconfig b/configs/anbernic-rgxx3-rk3566_defconfig -index a03509bf467..45cfaf5deb7 100644 +index 854de8b00a4..cd91f18ba80 100644 --- a/configs/anbernic-rgxx3-rk3566_defconfig +++ b/configs/anbernic-rgxx3-rk3566_defconfig -@@ -12,6 +12,8 @@ CONFIG_DEBUG_UART_BASE=0xFE660000 +@@ -12,6 +12,8 @@ CONFIG_SYS_LOAD_ADDR=0xc00800 + CONFIG_DEBUG_UART_BASE=0xFE660000 + CONFIG_DEBUG_UART_CLOCK=24000000 + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + # CONFIG_EFI_LOADER is not set + CONFIG_FIT=y + CONFIG_FIT_VERBOSE=y +diff --git a/configs/bpi-r2-pro-rk3568_defconfig b/configs/bpi-r2-pro-rk3568_defconfig +index c5199a39448..603e07f2456 100644 +--- a/configs/bpi-r2-pro-rk3568_defconfig ++++ b/configs/bpi-r2-pro-rk3568_defconfig +@@ -9,6 +9,8 @@ CONFIG_SYS_LOAD_ADDR=0xc00800 + CONFIG_DEBUG_UART_BASE=0xFE660000 CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y -diff --git a/configs/bpi-r2-pro-rk3568_defconfig b/configs/bpi-r2-pro-rk3568_defconfig -index eccc15a0ae5..57d4fafbef4 100644 ---- a/configs/bpi-r2-pro-rk3568_defconfig -+++ b/configs/bpi-r2-pro-rk3568_defconfig -@@ -9,6 +9,8 @@ CONFIG_DEBUG_UART_BASE=0xFE660000 - CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 - CONFIG_DEBUG_UART=y -+CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y - CONFIG_FIT=y - CONFIG_FIT_VERBOSE=y diff --git a/configs/cm3588-nas-rk3588_defconfig b/configs/cm3588-nas-rk3588_defconfig -index d6d82757a2d..7ef75dfedeb 100644 +index 5b5ef8d5ac1..53147d115dd 100644 --- a/configs/cm3588-nas-rk3588_defconfig +++ b/configs/cm3588-nas-rk3588_defconfig -@@ -12,6 +12,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -12,6 +12,8 @@ CONFIG_DEBUG_UART_BASE=0xFEB50000 + CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y @@ -260,38 +109,38 @@ index d6d82757a2d..7ef75dfedeb 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/coolpi-4b-rk3588s_defconfig b/configs/coolpi-4b-rk3588s_defconfig -index 3d45d939abb..6005d0b556b 100644 +index e6772622403..75e0b373ce9 100644 --- a/configs/coolpi-4b-rk3588s_defconfig +++ b/configs/coolpi-4b-rk3588s_defconfig -@@ -16,6 +16,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -17,6 +17,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/coolpi-cm5-evb-rk3588_defconfig b/configs/coolpi-cm5-evb-rk3588_defconfig -index 5190d69c1c5..30f1690fe4d 100644 +index 4326e116849..a005e4441d3 100644 --- a/configs/coolpi-cm5-evb-rk3588_defconfig +++ b/configs/coolpi-cm5-evb-rk3588_defconfig -@@ -16,6 +16,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -17,6 +17,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/evb-rk3568_defconfig b/configs/evb-rk3568_defconfig -index 2076f55122b..543c1a7d6ba 100644 +index 4a5a7454e10..7ec199a08af 100644 --- a/configs/evb-rk3568_defconfig +++ b/configs/evb-rk3568_defconfig -@@ -9,6 +9,8 @@ CONFIG_DEBUG_UART_BASE=0xFE660000 +@@ -9,6 +9,8 @@ CONFIG_SYS_LOAD_ADDR=0xc00800 + CONFIG_DEBUG_UART_BASE=0xFE660000 CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" @@ -299,25 +148,38 @@ index 2076f55122b..543c1a7d6ba 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/evb-rk3588_defconfig b/configs/evb-rk3588_defconfig -index 1d5585677a4..44ef0fd0f54 100644 +index c7f6256a626..cfa73c660e7 100644 --- a/configs/evb-rk3588_defconfig +++ b/configs/evb-rk3588_defconfig -@@ -10,6 +10,8 @@ CONFIG_DEBUG_UART_BASE=0xFEB50000 +@@ -10,6 +10,8 @@ CONFIG_SYS_LOAD_ADDR=0xc00800 + CONFIG_DEBUG_UART_BASE=0xFEB50000 CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y +diff --git a/configs/firefly-rk3399_defconfig b/configs/firefly-rk3399_defconfig +index 83b9de5feb9..2ba8f5029c3 100644 +--- a/configs/firefly-rk3399_defconfig ++++ b/configs/firefly-rk3399_defconfig +@@ -14,6 +14,8 @@ CONFIG_DEBUG_UART_BASE=0xFF1A0000 + CONFIG_DEBUG_UART_CLOCK=24000000 + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-firefly.dtb" + CONFIG_DISPLAY_BOARDINFO_LATE=y + CONFIG_SPL_MAX_SIZE=0x40000 diff --git a/configs/generic-rk3568_defconfig b/configs/generic-rk3568_defconfig -index 66a33afbbaf..b1bfb831aa5 100644 +index a33c3af9255..20966793568 100644 --- a/configs/generic-rk3568_defconfig +++ b/configs/generic-rk3568_defconfig -@@ -13,6 +13,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y +@@ -14,6 +14,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 + CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" @@ -325,12 +187,12 @@ index 66a33afbbaf..b1bfb831aa5 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/generic-rk3588_defconfig b/configs/generic-rk3588_defconfig -index 42bc2c9a765..6c713094bf0 100644 +index ac450e6d757..b5424ac9f16 100644 --- a/configs/generic-rk3588_defconfig +++ b/configs/generic-rk3588_defconfig -@@ -10,6 +10,8 @@ CONFIG_DEBUG_UART_BASE=0xFEB50000 +@@ -10,6 +10,8 @@ CONFIG_SYS_LOAD_ADDR=0xc00800 + CONFIG_DEBUG_UART_BASE=0xFEB50000 CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" @@ -338,11 +200,11 @@ index 42bc2c9a765..6c713094bf0 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/jaguar-rk3588_defconfig b/configs/jaguar-rk3588_defconfig -index 18006467dde..a5d7612d9a5 100644 +index ed3883b4f9c..47dbd834f30 100644 --- a/configs/jaguar-rk3588_defconfig +++ b/configs/jaguar-rk3588_defconfig -@@ -15,6 +15,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -16,6 +16,8 @@ CONFIG_DEBUG_UART_BASE=0xfeb50000 + CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y @@ -351,24 +213,37 @@ index 18006467dde..a5d7612d9a5 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/lubancat-2-rk3568_defconfig b/configs/lubancat-2-rk3568_defconfig -index 88593bfa705..870d8f72317 100644 +index 7548bf60b06..2fb8a432503 100644 --- a/configs/lubancat-2-rk3568_defconfig +++ b/configs/lubancat-2-rk3568_defconfig -@@ -9,6 +9,8 @@ CONFIG_DEBUG_UART_BASE=0xFE660000 +@@ -9,6 +9,8 @@ CONFIG_SYS_LOAD_ADDR=0xc00800 + CONFIG_DEBUG_UART_BASE=0xFE660000 CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_EFI_VAR_BUF_SIZE=16384 CONFIG_FIT=y CONFIG_FIT_VERBOSE=y - CONFIG_SPL_FIT_SIGNATURE=y +diff --git a/configs/nanopc-t4-rk3399_defconfig b/configs/nanopc-t4-rk3399_defconfig +index f8ae436a1ee..7aa8e1a8d42 100644 +--- a/configs/nanopc-t4-rk3399_defconfig ++++ b/configs/nanopc-t4-rk3399_defconfig +@@ -15,6 +15,8 @@ CONFIG_DEBUG_UART_BASE=0xFF1A0000 + CONFIG_DEBUG_UART_CLOCK=24000000 + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-nanopc-t4.dtb" + CONFIG_DISPLAY_BOARDINFO_LATE=y + CONFIG_SPL_MAX_SIZE=0x40000 diff --git a/configs/nanopc-t6-rk3588_defconfig b/configs/nanopc-t6-rk3588_defconfig -index 926267f93ad..7b0ac43d8c1 100644 +index ba9a5adece7..eaf7fa5a0fc 100644 --- a/configs/nanopc-t6-rk3588_defconfig +++ b/configs/nanopc-t6-rk3588_defconfig -@@ -17,6 +17,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -18,6 +18,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y @@ -377,37 +252,37 @@ index 926267f93ad..7b0ac43d8c1 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/nanopi-r5c-rk3568_defconfig b/configs/nanopi-r5c-rk3568_defconfig -index 8e30093ed9d..2c1d7b7435b 100644 +index e75a24dadc8..159ef033932 100644 --- a/configs/nanopi-r5c-rk3568_defconfig +++ b/configs/nanopi-r5c-rk3568_defconfig -@@ -11,6 +11,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -11,6 +11,8 @@ CONFIG_DEBUG_UART_BASE=0xFE660000 + CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" ++CONFIG_PREBOOT="usb start;" CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/nanopi-r5s-rk3568_defconfig b/configs/nanopi-r5s-rk3568_defconfig -index e1865b2e171..1afce812b22 100644 +index c971f376b38..60b5e8fa014 100644 --- a/configs/nanopi-r5s-rk3568_defconfig +++ b/configs/nanopi-r5s-rk3568_defconfig -@@ -11,6 +11,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -11,6 +11,8 @@ CONFIG_DEBUG_UART_BASE=0xFE660000 + CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" ++CONFIG_PREBOOT="usb start;" CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/nanopi-r6c-rk3588s_defconfig b/configs/nanopi-r6c-rk3588s_defconfig -index f8d2d67bd35..e6e9cf1101a 100644 +index 861e3234d29..bb6e2082e3b 100644 --- a/configs/nanopi-r6c-rk3588s_defconfig +++ b/configs/nanopi-r6c-rk3588s_defconfig -@@ -12,6 +12,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -12,6 +12,8 @@ CONFIG_DEBUG_UART_BASE=0xFEB50000 + CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y @@ -416,11 +291,11 @@ index f8d2d67bd35..e6e9cf1101a 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/nanopi-r6s-rk3588s_defconfig b/configs/nanopi-r6s-rk3588s_defconfig -index f7b364655ff..fd28485db93 100644 +index 743dfca441b..903ec56ad6f 100644 --- a/configs/nanopi-r6s-rk3588s_defconfig +++ b/configs/nanopi-r6s-rk3588s_defconfig -@@ -12,6 +12,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -12,6 +12,8 @@ CONFIG_DEBUG_UART_BASE=0xFEB50000 + CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y @@ -429,12 +304,12 @@ index f7b364655ff..fd28485db93 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/neu6a-io-rk3588_defconfig b/configs/neu6a-io-rk3588_defconfig -index ac281e65392..3338f0a3160 100644 +index 19f129e96f0..08ed699b01d 100644 --- a/configs/neu6a-io-rk3588_defconfig +++ b/configs/neu6a-io-rk3588_defconfig -@@ -10,6 +10,8 @@ CONFIG_DEBUG_UART_BASE=0xFEB50000 +@@ -10,6 +10,8 @@ CONFIG_SYS_LOAD_ADDR=0xc00800 + CONFIG_DEBUG_UART_BASE=0xFEB50000 CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" @@ -442,12 +317,12 @@ index ac281e65392..3338f0a3160 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/neu6b-io-rk3588_defconfig b/configs/neu6b-io-rk3588_defconfig -index c01e5fb0d04..73cc8e6d0ff 100644 +index 2cf5aeccf51..8cafd779a1c 100644 --- a/configs/neu6b-io-rk3588_defconfig +++ b/configs/neu6b-io-rk3588_defconfig -@@ -10,6 +10,8 @@ CONFIG_DEBUG_UART_BASE=0xFEB50000 +@@ -10,6 +10,8 @@ CONFIG_SYS_LOAD_ADDR=0xc00800 + CONFIG_DEBUG_UART_BASE=0xFEB50000 CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" @@ -455,11 +330,11 @@ index c01e5fb0d04..73cc8e6d0ff 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/nova-rk3588s_defconfig b/configs/nova-rk3588s_defconfig -index a2e2440359c..45862f403fb 100644 +index f7d7492ff46..5abb6ebbe18 100644 --- a/configs/nova-rk3588s_defconfig +++ b/configs/nova-rk3588s_defconfig -@@ -11,6 +11,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -11,6 +11,8 @@ CONFIG_DEBUG_UART_BASE=0xFEB50000 + CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y @@ -468,64 +343,128 @@ index a2e2440359c..45862f403fb 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/odroid-m1-rk3568_defconfig b/configs/odroid-m1-rk3568_defconfig -index b5263caff6d..a2217b530d1 100644 +index b00985b0405..19d7af53c7f 100644 --- a/configs/odroid-m1-rk3568_defconfig +++ b/configs/odroid-m1-rk3568_defconfig -@@ -16,6 +16,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 - CONFIG_PCI=y - CONFIG_DEBUG_UART=y -+CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y - CONFIG_FIT=y - CONFIG_FIT_VERBOSE=y -diff --git a/configs/orangepi-3b-rk3566_defconfig b/configs/orangepi-3b-rk3566_defconfig -index 575dc4340d3..817de7b69e6 100644 ---- a/configs/orangepi-3b-rk3566_defconfig -+++ b/configs/orangepi-3b-rk3566_defconfig -@@ -17,6 +17,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 - CONFIG_PCI=y - CONFIG_DEBUG_UART=y -+CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y - CONFIG_FIT=y - CONFIG_FIT_VERBOSE=y -diff --git a/configs/orangepi-5-plus-rk3588_defconfig b/configs/orangepi-5-plus-rk3588_defconfig -index 138a633f320..e0aaa8dfb15 100644 ---- a/configs/orangepi-5-plus-rk3588_defconfig -+++ b/configs/orangepi-5-plus-rk3588_defconfig -@@ -17,6 +17,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 - CONFIG_PCI=y - CONFIG_DEBUG_UART=y -+CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y - CONFIG_FIT=y - CONFIG_FIT_VERBOSE=y -diff --git a/configs/orangepi-5-rk3588s_defconfig b/configs/orangepi-5-rk3588s_defconfig -index 33529d4cac3..09d8475d051 100644 ---- a/configs/orangepi-5-rk3588s_defconfig -+++ b/configs/orangepi-5-rk3588s_defconfig -@@ -16,6 +16,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 - CONFIG_PCI=y - CONFIG_DEBUG_UART=y -+CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y - CONFIG_FIT=y - CONFIG_FIT_VERBOSE=y -diff --git a/configs/pinetab2-rk3566_defconfig b/configs/pinetab2-rk3566_defconfig -index 2d075d12174..fcb3c474044 100644 ---- a/configs/pinetab2-rk3566_defconfig -+++ b/configs/pinetab2-rk3566_defconfig @@ -17,6 +17,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_FIT=y + CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y +diff --git a/configs/odroid-m1s-rk3566_defconfig b/configs/odroid-m1s-rk3566_defconfig +index d59882a2a59..20f6dc3c26e 100644 +--- a/configs/odroid-m1s-rk3566_defconfig ++++ b/configs/odroid-m1s-rk3566_defconfig +@@ -11,6 +11,8 @@ CONFIG_DEBUG_UART_BASE=0xFE660000 + CONFIG_DEBUG_UART_CLOCK=24000000 + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_FIT=y + CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y +diff --git a/configs/odroid-m2-rk3588s_defconfig b/configs/odroid-m2-rk3588s_defconfig +index e71e61ddb0b..561c2b28b7a 100644 +--- a/configs/odroid-m2-rk3588s_defconfig ++++ b/configs/odroid-m2-rk3588s_defconfig +@@ -11,6 +11,8 @@ CONFIG_DEBUG_UART_BASE=0xFEB50000 + CONFIG_DEBUG_UART_CLOCK=24000000 + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_FIT=y + CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y +diff --git a/configs/orangepi-3b-rk3566_defconfig b/configs/orangepi-3b-rk3566_defconfig +index 1cd78789fa1..dcf182231da 100644 +--- a/configs/orangepi-3b-rk3566_defconfig ++++ b/configs/orangepi-3b-rk3566_defconfig +@@ -18,6 +18,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_FIT=y + CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y +diff --git a/configs/orangepi-5-max-rk3588_defconfig b/configs/orangepi-5-max-rk3588_defconfig +index 0861df962cf..744aad89c4a 100644 +--- a/configs/orangepi-5-max-rk3588_defconfig ++++ b/configs/orangepi-5-max-rk3588_defconfig +@@ -18,6 +18,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_FIT=y + CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y +diff --git a/configs/orangepi-5-plus-rk3588_defconfig b/configs/orangepi-5-plus-rk3588_defconfig +index 52523f87aec..e3bb4e43da9 100644 +--- a/configs/orangepi-5-plus-rk3588_defconfig ++++ b/configs/orangepi-5-plus-rk3588_defconfig +@@ -18,6 +18,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_FIT=y + CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y +diff --git a/configs/orangepi-5-rk3588s_defconfig b/configs/orangepi-5-rk3588s_defconfig +index e0eba389289..33fe68add7b 100644 +--- a/configs/orangepi-5-rk3588s_defconfig ++++ b/configs/orangepi-5-rk3588s_defconfig +@@ -17,6 +17,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_FIT=y + CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y +diff --git a/configs/orangepi-5-ultra-rk3588_defconfig b/configs/orangepi-5-ultra-rk3588_defconfig +index fb7f4432983..62419609695 100644 +--- a/configs/orangepi-5-ultra-rk3588_defconfig ++++ b/configs/orangepi-5-ultra-rk3588_defconfig +@@ -18,6 +18,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_FIT=y + CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y +diff --git a/configs/pinebook-pro-rk3399_defconfig b/configs/pinebook-pro-rk3399_defconfig +index cbf95b4692f..9e4d1b1061d 100644 +--- a/configs/pinebook-pro-rk3399_defconfig ++++ b/configs/pinebook-pro-rk3399_defconfig +@@ -22,6 +22,7 @@ CONFIG_PCI=y + CONFIG_DEBUG_UART=y + CONFIG_BOOTDELAY=3 + CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-pinebook-pro.dtb" + CONFIG_DISPLAY_BOARDINFO_LATE=y + CONFIG_SPL_MAX_SIZE=0x40000 +diff --git a/configs/pinetab2-rk3566_defconfig b/configs/pinetab2-rk3566_defconfig +index f284dadb99d..d87849f0a45 100644 +--- a/configs/pinetab2-rk3566_defconfig ++++ b/configs/pinetab2-rk3566_defconfig +@@ -18,6 +18,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 + CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" @@ -533,12 +472,12 @@ index 2d075d12174..fcb3c474044 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/powkiddy-x55-rk3566_defconfig b/configs/powkiddy-x55-rk3566_defconfig -index 2360bdbe84b..afb7f3ffafb 100644 +index 37a359c91a9..70bc5ab6402 100644 --- a/configs/powkiddy-x55-rk3566_defconfig +++ b/configs/powkiddy-x55-rk3566_defconfig -@@ -9,6 +9,8 @@ CONFIG_DEBUG_UART_BASE=0xFE660000 +@@ -9,6 +9,8 @@ CONFIG_SYS_LOAD_ADDR=0xc00800 + CONFIG_DEBUG_UART_BASE=0xFE660000 CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" @@ -546,51 +485,58 @@ index 2360bdbe84b..afb7f3ffafb 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/quartz64-a-rk3566_defconfig b/configs/quartz64-a-rk3566_defconfig -index 1ea8e0f40cc..a4211afb6a9 100644 +index 780fd581f0a..7938b5c0d1b 100644 --- a/configs/quartz64-a-rk3566_defconfig +++ b/configs/quartz64-a-rk3566_defconfig -@@ -17,6 +17,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -18,6 +18,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/quartz64-b-rk3566_defconfig b/configs/quartz64-b-rk3566_defconfig -index f61b2c181a1..408b63dbb08 100644 +index 4d92a67cd73..fe8a168373d 100644 --- a/configs/quartz64-b-rk3566_defconfig +++ b/configs/quartz64-b-rk3566_defconfig -@@ -16,6 +16,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -1,4 +1,6 @@ + CONFIG_ARM=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_SKIP_LOWLEVEL_INIT=y + CONFIG_COUNTER_FREQUENCY=24000000 + CONFIG_ARCH_ROCKCHIP=y +@@ -17,6 +19,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/quartzpro64-rk3588_defconfig b/configs/quartzpro64-rk3588_defconfig -index 06c5cff3ca5..dccc550d4ef 100644 +index 0ad74e8bbef..b9cbddfae77 100644 --- a/configs/quartzpro64-rk3588_defconfig +++ b/configs/quartzpro64-rk3588_defconfig -@@ -12,6 +12,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -12,6 +12,8 @@ CONFIG_DEBUG_UART_BASE=0xFEB50000 + CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/radxa-cm3-io-rk3566_defconfig b/configs/radxa-cm3-io-rk3566_defconfig -index 48c8fcf5a66..65198e4a507 100644 +index 875f0b76fa5..2523dccd6a3 100644 --- a/configs/radxa-cm3-io-rk3566_defconfig +++ b/configs/radxa-cm3-io-rk3566_defconfig -@@ -9,6 +9,8 @@ CONFIG_DEBUG_UART_BASE=0xFE660000 +@@ -9,6 +9,8 @@ CONFIG_SYS_LOAD_ADDR=0xc00800 + CONFIG_DEBUG_UART_BASE=0xFE660000 CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" @@ -598,90 +544,181 @@ index 48c8fcf5a66..65198e4a507 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/radxa-e25-rk3568_defconfig b/configs/radxa-e25-rk3568_defconfig -index 496fee0e0a4..b726e47c3e0 100644 +index 779d540e22d..7e003e74520 100644 --- a/configs/radxa-e25-rk3568_defconfig +++ b/configs/radxa-e25-rk3568_defconfig -@@ -11,6 +11,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 - CONFIG_PCI=y - CONFIG_DEBUG_UART=y -+CONFIG_USE_PREBOOT=y -+CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y - CONFIG_FIT=y - CONFIG_FIT_VERBOSE=y -diff --git a/configs/radxa-zero-3-rk3566_defconfig b/configs/radxa-zero-3-rk3566_defconfig -index 7606edf393e..d1611a638ae 100644 ---- a/configs/radxa-zero-3-rk3566_defconfig -+++ b/configs/radxa-zero-3-rk3566_defconfig @@ -11,6 +11,8 @@ CONFIG_DEBUG_UART_BASE=0xFE660000 CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 + CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y +diff --git a/configs/radxa-zero-3-rk3566_defconfig b/configs/radxa-zero-3-rk3566_defconfig +index f5cf09a5e4a..7db7e3fcd3d 100644 +--- a/configs/radxa-zero-3-rk3566_defconfig ++++ b/configs/radxa-zero-3-rk3566_defconfig +@@ -11,6 +11,8 @@ CONFIG_SYS_LOAD_ADDR=0xc00800 + CONFIG_DEBUG_UART_BASE=0xFE660000 + CONFIG_DEBUG_UART_CLOCK=24000000 + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_FIT=y + CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y +diff --git a/configs/roc-pc-mezzanine-rk3399_defconfig b/configs/roc-pc-mezzanine-rk3399_defconfig +index 8b4d8c1b0aa..54baa07aeae 100644 +--- a/configs/roc-pc-mezzanine-rk3399_defconfig ++++ b/configs/roc-pc-mezzanine-rk3399_defconfig +@@ -21,6 +21,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + # CONFIG_ANDROID_BOOT_IMAGE is not set + CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-roc-pc-mezzanine.dtb" + CONFIG_DISPLAY_BOARDINFO_LATE=y diff --git a/configs/rock-3a-rk3568_defconfig b/configs/rock-3a-rk3568_defconfig -index 66ac2f6d7aa..1500691419d 100644 +index e753185610f..19d303e7f70 100644 --- a/configs/rock-3a-rk3568_defconfig +++ b/configs/rock-3a-rk3568_defconfig -@@ -15,6 +15,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -16,6 +16,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/rock-3b-rk3568_defconfig b/configs/rock-3b-rk3568_defconfig -index 937796811a9..38d048439ed 100644 +index c3bf48b9e34..0cfa8eba168 100644 --- a/configs/rock-3b-rk3568_defconfig +++ b/configs/rock-3b-rk3568_defconfig -@@ -15,6 +15,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -16,6 +16,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/rock-3c-rk3566_defconfig b/configs/rock-3c-rk3566_defconfig -index f44b202c8c3..488b1c4e0c3 100644 +index 417aa33a663..61d0e1b8c6a 100644 --- a/configs/rock-3c-rk3566_defconfig +++ b/configs/rock-3c-rk3566_defconfig -@@ -15,6 +15,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -16,6 +16,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y +diff --git a/configs/rock-4c-plus-rk3399_defconfig b/configs/rock-4c-plus-rk3399_defconfig +index 0f6bdfdfb06..f31cb061a83 100644 +--- a/configs/rock-4c-plus-rk3399_defconfig ++++ b/configs/rock-4c-plus-rk3399_defconfig +@@ -17,6 +17,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 + CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_EFI_CAPSULE_ON_DISK=y + CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y + # CONFIG_ANDROID_BOOT_IMAGE is not set +diff --git a/configs/rock-4se-rk3399_defconfig b/configs/rock-4se-rk3399_defconfig +index 7f22aede912..caf8e02bece 100644 +--- a/configs/rock-4se-rk3399_defconfig ++++ b/configs/rock-4se-rk3399_defconfig +@@ -18,6 +18,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_EFI_CAPSULE_ON_DISK=y + CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y + # CONFIG_ANDROID_BOOT_IMAGE is not set diff --git a/configs/rock-5-itx-rk3588_defconfig b/configs/rock-5-itx-rk3588_defconfig -index bb9f148692a..1d6a9e9465b 100644 +index cb014de4188..e26a126533c 100644 --- a/configs/rock-5-itx-rk3588_defconfig +++ b/configs/rock-5-itx-rk3588_defconfig -@@ -17,6 +17,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -18,6 +18,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y +diff --git a/configs/rock-5c-rk3588s_defconfig b/configs/rock-5c-rk3588s_defconfig +index 3d044a81498..27234c250d1 100644 +--- a/configs/rock-5c-rk3588s_defconfig ++++ b/configs/rock-5c-rk3588s_defconfig +@@ -12,6 +12,8 @@ CONFIG_DEBUG_UART_BASE=0xFEB50000 + CONFIG_DEBUG_UART_CLOCK=24000000 + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_FIT=y + CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y +diff --git a/configs/rock-pi-4-rk3399_defconfig b/configs/rock-pi-4-rk3399_defconfig +index e5c9072c27f..35852c017da 100644 +--- a/configs/rock-pi-4-rk3399_defconfig ++++ b/configs/rock-pi-4-rk3399_defconfig +@@ -18,6 +18,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_EFI_CAPSULE_ON_DISK=y + CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y + # CONFIG_ANDROID_BOOT_IMAGE is not set +diff --git a/configs/rock-pi-4c-rk3399_defconfig b/configs/rock-pi-4c-rk3399_defconfig +index 4be7b0f8130..eeee446a5bd 100644 +--- a/configs/rock-pi-4c-rk3399_defconfig ++++ b/configs/rock-pi-4c-rk3399_defconfig +@@ -18,6 +18,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_EFI_CAPSULE_ON_DISK=y + CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y + # CONFIG_ANDROID_BOOT_IMAGE is not set +diff --git a/configs/rock-pi-n10-rk3399pro_defconfig b/configs/rock-pi-n10-rk3399pro_defconfig +index 602a723ea7d..3dcc2932ae3 100644 +--- a/configs/rock-pi-n10-rk3399pro_defconfig ++++ b/configs/rock-pi-n10-rk3399pro_defconfig +@@ -13,6 +13,8 @@ CONFIG_DEBUG_UART_BASE=0xFF1A0000 + CONFIG_DEBUG_UART_CLOCK=24000000 + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + # CONFIG_ANDROID_BOOT_IMAGE is not set + CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399pro-rock-pi-n10.dtb" + # CONFIG_CONSOLE_MUX is not set diff --git a/configs/rock5a-rk3588s_defconfig b/configs/rock5a-rk3588s_defconfig -index c09e6655f02..39602d86845 100644 +index 24b2eef35f2..c5830054921 100644 --- a/configs/rock5a-rk3588s_defconfig +++ b/configs/rock5a-rk3588s_defconfig -@@ -10,6 +10,8 @@ CONFIG_DEBUG_UART_BASE=0xFEB50000 +@@ -10,6 +10,8 @@ CONFIG_SYS_LOAD_ADDR=0xc00800 + CONFIG_DEBUG_UART_BASE=0xFEB50000 CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" @@ -689,76 +726,102 @@ index c09e6655f02..39602d86845 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/rock5b-rk3588_defconfig b/configs/rock5b-rk3588_defconfig -index 80a2f2fed58..d3cc8a19cfd 100644 +index da5fb3a2c30..053346fc035 100644 --- a/configs/rock5b-rk3588_defconfig +++ b/configs/rock5b-rk3588_defconfig -@@ -17,6 +17,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -18,6 +18,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y +diff --git a/configs/rock960-rk3399_defconfig b/configs/rock960-rk3399_defconfig +index db121f03ae6..e55f1b6a034 100644 +--- a/configs/rock960-rk3399_defconfig ++++ b/configs/rock960-rk3399_defconfig +@@ -12,6 +12,8 @@ CONFIG_DEBUG_UART_BASE=0xFF1A0000 + CONFIG_DEBUG_UART_CLOCK=24000000 + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rock960.dtb" + CONFIG_SYS_PBSIZE=1052 + CONFIG_DISPLAY_BOARDINFO_LATE=y +diff --git a/configs/rockpro64-rk3399_defconfig b/configs/rockpro64-rk3399_defconfig +index 1d2bff35fc0..ea8e90b9f6a 100644 +--- a/configs/rockpro64-rk3399_defconfig ++++ b/configs/rockpro64-rk3399_defconfig +@@ -20,6 +20,8 @@ CONFIG_SPL_SPI_FLASH_SUPPORT=y + CONFIG_SPL_SPI=y + CONFIG_PCI=y + CONFIG_DEBUG_UART=y ++CONFIG_USE_PREBOOT=y ++CONFIG_PREBOOT="pci enum; usb start; nvme scan;" + CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rockpro64.dtb" + CONFIG_DISPLAY_BOARDINFO_LATE=y + CONFIG_SPL_MAX_SIZE=0x40000 diff --git a/configs/sige7-rk3588_defconfig b/configs/sige7-rk3588_defconfig -index d15fc09fc8d..c77919cac79 100644 +index 00b9759715b..1b837bd554c 100644 --- a/configs/sige7-rk3588_defconfig +++ b/configs/sige7-rk3588_defconfig -@@ -13,6 +13,8 @@ CONFIG_SPL_SPI=y - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -13,6 +13,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 + CONFIG_SPL_SPI=y CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/soquartz-blade-rk3566_defconfig b/configs/soquartz-blade-rk3566_defconfig -index 82910daf7cc..09fc6b6b6e5 100644 +index 7de159a8881..4137f0459b5 100644 --- a/configs/soquartz-blade-rk3566_defconfig +++ b/configs/soquartz-blade-rk3566_defconfig -@@ -11,6 +11,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -11,6 +11,8 @@ CONFIG_DEBUG_UART_BASE=0xFE660000 + CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/soquartz-cm4-rk3566_defconfig b/configs/soquartz-cm4-rk3566_defconfig -index 5744f1baa81..e5a9ee1938b 100644 +index 4455ee5b5aa..ad63ba0204f 100644 --- a/configs/soquartz-cm4-rk3566_defconfig +++ b/configs/soquartz-cm4-rk3566_defconfig -@@ -11,6 +11,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -11,6 +11,8 @@ CONFIG_DEBUG_UART_BASE=0xFE660000 + CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/soquartz-model-a-rk3566_defconfig b/configs/soquartz-model-a-rk3566_defconfig -index 920df9b622d..efcd3f5bc77 100644 +index abdab514496..9e01345bdaa 100644 --- a/configs/soquartz-model-a-rk3566_defconfig +++ b/configs/soquartz-model-a-rk3566_defconfig -@@ -11,6 +11,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -11,6 +11,8 @@ CONFIG_DEBUG_UART_BASE=0xFE660000 + CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/tiger-rk3588_defconfig b/configs/tiger-rk3588_defconfig -index 8eb1027e449..39e4946b0bf 100644 +index 105e8e10e0b..bcc2ae302a5 100644 --- a/configs/tiger-rk3588_defconfig +++ b/configs/tiger-rk3588_defconfig -@@ -16,6 +16,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -17,6 +17,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 + # CONFIG_DEBUG_UART_BOARD_INIT is not set CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y @@ -767,12 +830,12 @@ index 8eb1027e449..39e4946b0bf 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/toybrick-rk3588_defconfig b/configs/toybrick-rk3588_defconfig -index 12a076aeeae..c70210c0dee 100644 +index 14b231ae3e2..7af393731cd 100644 --- a/configs/toybrick-rk3588_defconfig +++ b/configs/toybrick-rk3588_defconfig -@@ -10,6 +10,8 @@ CONFIG_DEBUG_UART_BASE=0xFEB50000 +@@ -10,6 +10,8 @@ CONFIG_SYS_LOAD_ADDR=0xc00800 + CONFIG_DEBUG_UART_BASE=0xFEB50000 CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" @@ -780,18 +843,18 @@ index 12a076aeeae..c70210c0dee 100644 CONFIG_FIT_VERBOSE=y CONFIG_SPL_FIT_SIGNATURE=y diff --git a/configs/turing-rk1-rk3588_defconfig b/configs/turing-rk1-rk3588_defconfig -index e6e1bda7ec1..e1bf365edc8 100644 +index 0b3efec23e6..515db2a2b0c 100644 --- a/configs/turing-rk1-rk3588_defconfig +++ b/configs/turing-rk1-rk3588_defconfig -@@ -12,6 +12,8 @@ CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0xc00800 +@@ -12,6 +12,8 @@ CONFIG_DEBUG_UART_BASE=0xFEBC0000 + CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_PCI=y CONFIG_DEBUG_UART=y +CONFIG_USE_PREBOOT=y +CONFIG_PREBOOT="pci enum; usb start; nvme scan;" - CONFIG_AHCI=y CONFIG_FIT=y CONFIG_FIT_VERBOSE=y + CONFIG_SPL_FIT_SIGNATURE=y -- -2.46.1 +2.54.0 diff --git a/rockchip-Modernise-Geekbox-config.patch b/rockchip-Modernise-Geekbox-config.patch deleted file mode 100644 index ee49fcf..0000000 --- a/rockchip-Modernise-Geekbox-config.patch +++ /dev/null @@ -1,189 +0,0 @@ -From 45d8808e95ddf0702ed78acde7678291ae52abdb Mon Sep 17 00:00:00 2001 -From: Peter Robinson -Date: Fri, 11 Oct 2024 17:14:26 +0100 -Subject: [PATCH] configs: rockchip: Modernise Geekbox config - -Modernise and move the Geekbox config to use SPL/TPL with -upstream TF-A, enable MMC/USB/Eth to make the device more -useful and work like other Rockchip devices. Update the -readme to reflect the changes to the build process. - -Signed-off-by: Peter Robinson ---- - arch/arm/dts/rk3368-geekbox-u-boot.dtsi | 10 ++++ - board/geekbuying/geekbox/README | 40 +++++++++++++- - configs/geekbox_defconfig | 71 ++++++++++++++++++++++++- - 3 files changed, 118 insertions(+), 3 deletions(-) - -diff --git a/arch/arm/dts/rk3368-geekbox-u-boot.dtsi b/arch/arm/dts/rk3368-geekbox-u-boot.dtsi -index cfc8b9340a8..55d007f7ab8 100644 ---- a/arch/arm/dts/rk3368-geekbox-u-boot.dtsi -+++ b/arch/arm/dts/rk3368-geekbox-u-boot.dtsi -@@ -26,6 +26,16 @@ - bootph-all; - }; - -+&dmc { -+ bootph-all; -+ -+ rockchip,memory-schedule = ; -+ rockchip,ddr-frequency = <800000000>; -+ rockchip,ddr-speed-bin = ; -+ -+ status = "okay"; -+}; -+ - &grf { - bootph-all; - }; -diff --git a/board/geekbuying/geekbox/README b/board/geekbuying/geekbox/README -index de980f2f233..bd4d8cdd084 100644 ---- a/board/geekbuying/geekbox/README -+++ b/board/geekbuying/geekbox/README -@@ -1 +1,39 @@ --see board/rockchip/sheep_rk3368/README -+Here is the step-by-step to boot to U-Boot on the Geekbox -+ -+Get the Source and build ATF -+============================ -+ -+ > git clone https://github.com/TrustedFirmware-A/trusted-firmware-a.git -+ > cd arm-trusted-firmware -+ > make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3368 bl31 -+ -+Configure U-Boot -+================ -+ -+ > cd ../u-boot -+ > export BL31=../arm-trusted-firmware/build/rk3368/release/bl31.bin -+ > make geekbox_defconfig -+ -+Build the full U-Boot/ATF firmware stack -+======================================== -+ -+ > make CROSS_COMPILE=aarch64-unknown-elf- -+ -+Flash the image -+=============== -+ -+Copy the SPL to offset 32k and the FIT image containing the payloads -+(U-Boot proper, ATF, devicetree) to offset 256k card. -+ -+eMMC -+---- -+ -+rkdeveloptool allows to flash the on-board eMMC via the USB OTG interface with -+help of the Rockchip loader binary. -+ -+ > git clone https://github.com/rockchip-linux/rkdeveloptool -+ > cd rkdeveloptool -+ > autoreconf -i && && ./configure && make -+ > git clone https://github.com/rockchip-linux/rkbin.git -+ > ./rkdeveloptool db rkbin/rk33/rk3368_loader_v2.00.256.bin -+ > ./rkdeveloptool wl 64 ../u-boot-rockchip.bin -diff --git a/configs/geekbox_defconfig b/configs/geekbox_defconfig -index 8f4be79831a..1b116fa8602 100644 ---- a/configs/geekbox_defconfig -+++ b/configs/geekbox_defconfig -@@ -3,29 +3,96 @@ CONFIG_SKIP_LOWLEVEL_INIT=y - CONFIG_COUNTER_FREQUENCY=24000000 - CONFIG_ARCH_ROCKCHIP=y - CONFIG_TEXT_BASE=0x00200000 --CONFIG_SYS_MALLOC_F_LEN=0x1000 - CONFIG_NR_DRAM_BANKS=1 - CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y - CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x300000 - CONFIG_DEFAULT_DEVICE_TREE="rk3368-geekbox" -+CONFIG_SPL_TEXT_BASE=0x00000000 - CONFIG_ROCKCHIP_RK3368=y -+CONFIG_TPL_LIBCOMMON_SUPPORT=y -+CONFIG_TPL_LIBGENERIC_SUPPORT=y -+CONFIG_SPL_DRIVERS_MISC=y -+CONFIG_SPL_STACK=0x188000 -+CONFIG_SPL_HAS_BSS_LINKER_SECTION=y -+CONFIG_SPL_BSS_START_ADDR=0x400000 -+CONFIG_SPL_BSS_MAX_SIZE=0x20000 -+CONFIG_SPL_STACK_R=y -+CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x4000 -+CONFIG_SPL=y - CONFIG_TARGET_GEEKBOX=y - CONFIG_DEBUG_UART_BASE=0xFF690000 - CONFIG_DEBUG_UART_CLOCK=24000000 - CONFIG_SYS_LOAD_ADDR=0x800800 - CONFIG_DEBUG_UART=y -+CONFIG_FIT=y -+CONFIG_FIT_VERBOSE=y -+CONFIG_SPL_LOAD_FIT=y - CONFIG_DEFAULT_FDT_FILE="rockchip/rk3368-geekbox.dtb" - # CONFIG_DISPLAY_CPUINFO is not set - CONFIG_DISPLAY_BOARDINFO_LATE=y -+CONFIG_SPL_MAX_SIZE=0x40000 -+CONFIG_SPL_PAD_TO=0x7f8000 -+CONFIG_SPL_BOOTROM_SUPPORT=y -+# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set -+# CONFIG_SPL_SHARES_INIT_SP_ADDR is not set -+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x200 -+CONFIG_SPL_ATF=y -+CONFIG_TPL=y -+CONFIG_TPL_SYS_MALLOC_SIMPLE=y -+CONFIG_TPL_DRIVERS_MISC=y -+CONFIG_CMD_GPIO=y -+CONFIG_CMD_MMC=y -+CONFIG_CMD_REGULATOR=y -+CONFIG_CMD_USB=y -+CONFIG_SPL_OF_CONTROL=y -+CONFIG_TPL_OF_CONTROL=y -+CONFIG_OF_LIVE=y -+CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names interrupt-parent" -+CONFIG_TPL_OF_PLATDATA=y -+CONFIG_ENV_IS_IN_MMC=y - CONFIG_SYS_RELOC_GD_ENV_ADDR=y -+CONFIG_NET_RANDOM_ETHADDR=y -+CONFIG_TPL_DM=y - CONFIG_REGMAP=y -+CONFIG_SPL_REGMAP=y -+CONFIG_TPL_REGMAP=y - CONFIG_SYSCON=y --CONFIG_BOUNCE_BUFFER=y -+CONFIG_SPL_SYSCON=y -+CONFIG_TPL_SYSCON=y - CONFIG_CLK=y -+CONFIG_SPL_CLK=y -+CONFIG_TPL_CLK=y -+CONFIG_ROCKCHIP_GPIO=y -+CONFIG_SYS_I2C_ROCKCHIP=y -+CONFIG_MMC_DW=y -+CONFIG_MMC_DW_ROCKCHIP=y - CONFIG_PINCTRL=y -+CONFIG_PHY_REALTEK=y -+CONFIG_DM_ETH_PHY=y -+CONFIG_ETH_DESIGNWARE=y -+CONFIG_RGMII=y -+CONFIG_GMAC_ROCKCHIP=y -+CONFIG_PINCTRL=y -+CONFIG_SPL_PINCTRL=y -+CONFIG_DM_PMIC=y -+CONFIG_PMIC_RK8XX=y -+CONFIG_DM_REGULATOR_FIXED=y -+CONFIG_REGULATOR_RK8XX=y - CONFIG_RAM=y -+CONFIG_SPL_RAM=y -+CONFIG_TPL_RAM=y - CONFIG_DEBUG_UART_SHIFT=2 - CONFIG_DEBUG_UART_ANNOUNCE=y - CONFIG_SYS_NS16550_MEM32=y -+CONFIG_SYSINFO=y -+CONFIG_SYSINFO_SMBIOS=y - CONFIG_SYSRESET=y -+CONFIG_USB=y -+CONFIG_USB_EHCI_HCD=y -+CONFIG_USB_EHCI_GENERIC=y -+CONFIG_USB_DWC2=y -+CONFIG_USB_GADGET=y -+CONFIG_USB_GADGET_DWC2_OTG=y -+CONFIG_SPL_TINY_MEMSET=y -+CONFIG_LZO=y - CONFIG_ERRNO_STR=y --- -2.47.0 - diff --git a/rockchip-rk3568-nanopi-r5-Drop-duplicated-extra-sdhc.patch b/rockchip-rk3568-nanopi-r5-Drop-duplicated-extra-sdhc.patch new file mode 100644 index 0000000..bef5a9e --- /dev/null +++ b/rockchip-rk3568-nanopi-r5-Drop-duplicated-extra-sdhc.patch @@ -0,0 +1,39 @@ +From aef38432fbc93621b434836b95b10c28aa880e84 Mon Sep 17 00:00:00 2001 +From: Peter Robinson +Date: Tue, 9 Dec 2025 20:51:06 +0000 +Subject: [PATCH 1/2] rockchip: rk3568-nanopi-r5: Drop duplicated/extra sdhci + +The pinctrl settings are now upstream, with the upstream +voltage supplies, and the HS200 mode is confirmed to work +fine but the HS400 mode had reported issues so let's just +consume what the upstream DT has now as it's all known good. + +Reported-by: Dusty Mabe +Tested-by: Dusty Mabe +Signed-off-by: Peter Robinson +--- + arch/arm/dts/rk3568-nanopi-r5s-u-boot.dtsi | 8 -------- + 1 file changed, 8 deletions(-) + +diff --git a/arch/arm/dts/rk3568-nanopi-r5s-u-boot.dtsi b/arch/arm/dts/rk3568-nanopi-r5s-u-boot.dtsi +index 64c43374c04..7e24be1a5e7 100644 +--- a/arch/arm/dts/rk3568-nanopi-r5s-u-boot.dtsi ++++ b/arch/arm/dts/rk3568-nanopi-r5s-u-boot.dtsi +@@ -12,14 +12,6 @@ + /delete-property/ vpcie3v3-supply; + }; + +-&sdhci { +- cap-mmc-highspeed; +- mmc-hs200-1_8v; +- mmc-hs400-1_8v; +- mmc-hs400-enhanced-strobe; +- pinctrl-0 = <&emmc_bus8 &emmc_clk &emmc_cmd &emmc_datastrobe>; +-}; +- + &vcc5v0_usb_host { + /delete-property/ regulator-always-on; + /delete-property/ regulator-boot-on; +-- +2.52.0 + diff --git a/rockchip-rk356x-Stop-overriding-sdhci-mmc-aliases.patch b/rockchip-rk356x-Stop-overriding-sdhci-mmc-aliases.patch new file mode 100644 index 0000000..c67e4af --- /dev/null +++ b/rockchip-rk356x-Stop-overriding-sdhci-mmc-aliases.patch @@ -0,0 +1,33 @@ +From 29efc0396809384cf37bfcfb01c62e63216fa998 Mon Sep 17 00:00:00 2001 +From: Peter Robinson +Date: Tue, 9 Dec 2025 21:13:46 +0000 +Subject: [PATCH 2/2] rockchip: rk356x: Stop overriding sdhci/mmc aliases + +Upstream device tree has rules where the aliases are board +specific settings, no SoC settings. Looking at upstream +rk356x boards there's a lot of variation in the setting of +mmc0/mmc1 based on the device so we should not be overriding +this here and now we sync to upstream we should just consume +those settings, to do otherwise confuses users. + +Signed-off-by: Peter Robinson +--- + arch/arm/dts/rk356x-u-boot.dtsi | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/arch/arm/dts/rk356x-u-boot.dtsi b/arch/arm/dts/rk356x-u-boot.dtsi +index 738b9673d35..f25c7970208 100644 +--- a/arch/arm/dts/rk356x-u-boot.dtsi ++++ b/arch/arm/dts/rk356x-u-boot.dtsi +@@ -7,8 +7,6 @@ + + / { + aliases { +- mmc0 = &sdhci; +- mmc1 = &sdmmc0; + spi4 = &sfc; + }; + +-- +2.52.0 + diff --git a/rpi-Pass-CMA-through-from-firmware-DT.patch b/rpi-Pass-CMA-through-from-firmware-DT.patch deleted file mode 100644 index 1185095..0000000 --- a/rpi-Pass-CMA-through-from-firmware-DT.patch +++ /dev/null @@ -1,40 +0,0 @@ -From c449955f6aece3148ccf67890df1083fb3a41884 Mon Sep 17 00:00:00 2001 -From: Peter Robinson -Date: Fri, 11 Oct 2024 12:04:10 +0100 -Subject: [PATCH] board: rpi: Pass CMA through from firmware DT - -For a lot of usecases, such as display, camera, media -the Raspberry Pi needs a lot more CMA than distros -configure as default so we should pass this parameter -through so things work as expected. Fix a spelling -mistake while we're at it. - -Signed-off-by: Peter Robinson ---- - board/raspberrypi/rpi/rpi.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c -index ab5ea85cf9f..dd5a318d239 100644 ---- a/board/raspberrypi/rpi/rpi.c -+++ b/board/raspberrypi/rpi/rpi.c -@@ -540,12 +540,15 @@ void update_fdt_from_fw(void *fdt, void *fw_fdt) - if (fdt == fw_fdt) - return; - -- /* The firmware provides a more precie model; so copy that */ -+ /* The firmware provides a more precise model; so copy that */ - copy_property(fdt, fw_fdt, "/", "model"); - - /* memory reserve as suggested by the firmware */ - copy_property(fdt, fw_fdt, "/", "memreserve"); - -+ /* copy the CMA memory setting from the firmware DT to linux */ -+ copy_property(fdt, fw_fdt, "/reserved-memory/linux,cma", "size"); -+ - /* Adjust dma-ranges for the SD card and PCI bus as they can depend on - * the SoC revision - */ --- -2.47.0 - diff --git a/rpi-copy-chosen-bootloader-partition-and-set-boot_partition.patch b/rpi-copy-chosen-bootloader-partition-and-set-boot_partition.patch new file mode 100644 index 0000000..6d54fa7 --- /dev/null +++ b/rpi-copy-chosen-bootloader-partition-and-set-boot_partition.patch @@ -0,0 +1,256 @@ +From patchwork Tue Aug 4 13:39:15 2026 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Gregor Herburger +X-Patchwork-Id: 2280865 +X-Patchwork-Delegate: pbrobinson@gmail.com +Return-Path: +X-Original-To: incoming@patchwork.ozlabs.org +Delivered-To: patchwork-incoming@legolas.ozlabs.org +Authentication-Results: legolas.ozlabs.org; + dkim=fail reason="signature verification failed" (2048-bit key; + unprotected) header.d=lists.u-boot-project.org + header.i=@lists.u-boot-project.org header.a=rsa-sha256 header.s=default + header.b=DFFhfbAr; + dkim-atps=neutral +Authentication-Results: legolas.ozlabs.org; + spf=pass (sender SPF authorized) smtp.mailfrom=lists.u-boot-project.org + (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; + envelope-from=u-boot-bounces@lists.u-boot-project.org; + receiver=patchwork.ozlabs.org) +Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) + (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) + key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) + (No client certificate requested) + by legolas.ozlabs.org (Postfix) with ESMTPS id 4hDvm8025rz1xqD + for ; Tue, 04 Aug 2026 23:39:35 +1000 (AEST) +Received: from localhost (localhost [127.0.0.1]) + by smtp3.osuosl.org (Postfix) with ESMTP id 2536960600; + Tue, 4 Aug 2026 13:39:34 +0000 (UTC) +X-Virus-Scanned: amavis at osuosl.org +Received: from smtp3.osuosl.org ([127.0.0.1]) + by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP + id T9Kb3BtsvOX4; Tue, 4 Aug 2026 13:39:33 +0000 (UTC) +X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; + helo=lists1.osuosl.org; + envelope-from=u-boot-bounces@lists.u-boot-project.org; receiver= +DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 4350560615 +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=lists.u-boot-project.org ; s=default; t=1785850773; + bh=Tj3LONeiWXn0Cn5KPSYhoff9avwde4nWUGEguAWdLbE=; + h=From:Date:Subject:To:Cc:List-Id:List-Unsubscribe:List-Archive: + List-Post:List-Help:List-Subscribe:From; + b=DFFhfbArDuHrxJEuZryw3QEVVVcavwAril7tcxulQVs6jkVOCAjh7GEuhkq8EyLIq + suopR14b5dkKpVbbSr23u2v9jRgpynJQ5WBq6kIJSqjmZt58tZeMbaX76PRHjOs8+s + QHatP0Vxf1ny0BOpVlZLZ/LlAsQhypNhW6/qjH0X9OLeNq0IFjSZ5faD3z463b62m0 + yMuPrAXa/kuPPInxGG6HsCPkRzFH3x9hM15r7ipSbXODTRXaVBSVScp03eAeo6zw/d + nll/wcjCEe/78XX5o1Tsug951g7H8meDRnGQHJZtvbEmHdDB1wkTXYdFI2EGwnDxsz + W3dcHoUveJgqQ== +Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) + by smtp3.osuosl.org (Postfix) with ESMTP id 4350560615; + Tue, 4 Aug 2026 13:39:33 +0000 (UTC) +X-Original-To: u-boot@lists.u-boot-project.org +Delivered-To: u-boot@lists.u-boot-project.org +Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) + by lists1.osuosl.org (Postfix) with ESMTP id 3009E2BF + for ; Tue, 4 Aug 2026 13:39:31 +0000 (UTC) +Received: from localhost (localhost [127.0.0.1]) + by smtp1.osuosl.org (Postfix) with ESMTP id 222DC8086C + for ; Tue, 4 Aug 2026 13:39:31 +0000 (UTC) +X-Virus-Scanned: amavis at osuosl.org +Received: from smtp1.osuosl.org ([127.0.0.1]) + by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP + id W5OoNRat257d for ; + Tue, 4 Aug 2026 13:39:30 +0000 (UTC) +X-Greylist: delayed 94239 seconds by postgrey-1.37 at util1.osuosl.org; + Tue, 04 Aug 2026 13:39:29 UTC +DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org 1B0B580827 +DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 1B0B580827 +Received-SPF: Pass (mailfrom) identity=mailfrom; + client-ip=2a0a:51c0:0:12e:550::1; helo=galois.linutronix.de; + envelope-from=gregor.herburger@linutronix.de; receiver= +Received: from galois.linutronix.de (Galois.linutronix.de + [IPv6:2a0a:51c0:0:12e:550::1]) + by smtp1.osuosl.org (Postfix) with ESMTPS id 1B0B580827 + for ; Tue, 4 Aug 2026 13:39:29 +0000 (UTC) +From: Gregor Herburger +Date: Tue, 04 Aug 2026 15:39:15 +0200 +Subject: [PATCH v3] rpi: copy /chosen/bootloader partition and set + boot_partition +MIME-Version: 1.0 +Message-Id: <20260804-tryboot2-v3-1-b0bc282a923b@linutronix.de> +X-B4-Tracking: v=1; b=H4sIAILrcWoC/22OywrCMBBFf0WyNpKHbYor/0O6SNOJjWgiSRpaS + v/dpCKCyKwO3HvmLiiANxDQabcgD8kE42wGvt8hNUh7BWz6zIgRVpOGcBz93DkXGW5UxRjlooZ + Kohx/etBm2lSX9s1h7G6gYumXhPbugePgQX6VgjQfJU4U5+OSHiVIpQU9340do3fWTIceimIwI + To/b3MTK6/+LEssezhRRFDNAGj142nXdX0BG/Mh6/kAAAA= +X-Change-ID: 20260803-tryboot2-8c5221376e5a +To: u-boot@lists.u-boot-project.org +Cc: Matthias Brugger , + Peter Robinson , Tom Rini , + =?utf-8?q?Filip_Kokosi=C5=84ski?= , + Ilias Apalodimas , + Gregor Herburger +X-Developer-Signature: v=1; a=ed25519-sha256; t=1785850764; l=3191; + i=gregor.herburger@linutronix.de; s=20260226; h=from:subject:message-id; + bh=4mVT/kFDHBnjUUlqljWBZ+t7aLa+t+gE+t/hUJ4uc5g=; + b=TBKoGScdkXGUfpGLvpVtYHkg4LDoOR/8M/do2dqU2QlR+9Z9YFNN6x88pDC7UIDeXrJS+Hpeg + e3YsfK6fOcoBgXOuzz3Aabmmn9//OQN7WG6Vz15rSxX0uVZ96TFcvf5 +X-Developer-Key: i=gregor.herburger@linutronix.de; a=ed25519; + pk=u72Lv7+/lS5CC1hmSrb17lv/6CK7HBh4Lvz77PHA5LM= +X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=linutronix.de; s=2020; t=1785850765; + h=from:from:reply-to:subject:subject:date:date:message-id:message-id: + to:to:cc:cc:mime-version:mime-version:content-type:content-type: + content-transfer-encoding:content-transfer-encoding; + bh=Tj3LONeiWXn0Cn5KPSYhoff9avwde4nWUGEguAWdLbE=; + b=plU5oAFojHvTlDhOGINsdXnnc0AnS9OY0C4LB9dSy9uyrPKBBpLWGWj3xmNoX87lLZlhO9 + z0H+R5gqw5NfxbTVYFHqZnW+pW4xJQFW9fMYSU8/k2RRg9JEqP+NrZ8Y720ujlycxn05vP + sF7cD+TEsxvyBhnbRyq82obvpdQIYj0D6T3UkHyz0U4G+5k8dVhhv/mqGaSfY8xW4cCl5G + gIE2QIsuzB4g4pQoW70DrLd7cyqqDM0iDrrXFZL2a7DlnYgbe1ULVXMl05UMMQGfBkHmog + pt8e+zvO4AVA3G8CKcUQhhWOZm7uycUpdrNuyPKg9K7JB6MEd9dHbucVa+v8Yg== +X-Mailman-Original-DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; + d=linutronix.de; s=2020e; t=1785850765; + h=from:from:reply-to:subject:subject:date:date:message-id:message-id: + to:to:cc:cc:mime-version:mime-version:content-type:content-type: + content-transfer-encoding:content-transfer-encoding; + bh=Tj3LONeiWXn0Cn5KPSYhoff9avwde4nWUGEguAWdLbE=; + b=NAMrZHs0ETYIMiwBHLvCoR3NOcg/kwkAxVRq6Q/pdhfkQJjxtHU3mZFV520QjbE1yeix0S + nJyAqHgyKVlRiZCw== +X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; + dmarc=pass (p=none dis=none) + header.from=linutronix.de +X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; + dkim=pass (2048-bit key, unprotected) header.d=linutronix.de + header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=plU5oAFo; + dkim=pass header.d=linutronix.de header.i=@linutronix.de + header.a=ed25519-sha256 header.s=2020e header.b=NAMrZHs0 +X-BeenThere: u-boot@lists.u-boot-project.org +X-Mailman-Version: 2.1.30 +Precedence: list +List-Id: U-Boot discussion +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +Errors-To: u-boot-bounces@lists.u-boot-project.org +Sender: "U-Boot" + +The Raspberry Pi has the "tryboot" feature where it can boot from a +different partition enabling failsafe A/B updates. After boot the +firmware sets 'partition' property in /chosen/bootloader. + +Copy the /chosen/bootloader node to the device tree. + +Set the env variable boot_partition accordingly to allow boards to +create a bootcmd based on the boot partition. + +Reviewed-by: Matthias Brugger +Signed-off-by: Gregor Herburger +--- +Changes in v3: +- Copy the complete '/chosen/bootloader' node instead of only the + partition property +- Link to v2: https://patch.msgid.link/20260803-tryboot2-v2-1-30c071f2ee15@linutronix.de + +Changes in v2: +- update Reviewed-by tag +--- + board/raspberrypi/rpi/rpi.c | 51 +++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 51 insertions(+) + + +--- +base-commit: baa64b2f892890f00a377eac4a3e685472bb56b5 +change-id: 20260803-tryboot2-8c5221376e5a + +Best regards, +-- +Gregor Herburger + +diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c +index 1da5df92351c..ba8a2c1ba4cf 100644 +--- a/board/raspberrypi/rpi/rpi.c ++++ b/board/raspberrypi/rpi/rpi.c +@@ -480,6 +480,20 @@ static void set_serial_number(void) + env_set("serial#", serial_string); + } + ++static void set_boot_partition_fdt(void) ++{ ++ void *fdtp = (void *)gd->fdt_blob; ++ u32 partition; ++ ++ partition = fdt_getprop_u32_default(fdtp, "/chosen/bootloader", "partition", 1); ++ if (!partition) { ++ printf("Failed to the get partition property.\n"); ++ return; ++ } ++ ++ env_set_ulong("boot_partition", partition); ++} ++ + int misc_init_r(void) + { + set_fdt_addr(); +@@ -489,6 +503,7 @@ int misc_init_r(void) + set_board_info(); + #endif + set_serial_number(); ++ set_boot_partition_fdt(); + + return 0; + } +@@ -579,6 +594,39 @@ int board_fdt_blob_setup(void **fdtp) + return 0; + } + ++int copy_node_all_properties(void *dst, void *src, const char *path, const char *node) ++{ ++ int src_parent, dst_parent; ++ int src_node, dst_node; ++ int prop; ++ int len; ++ ++ src_parent = fdt_path_offset(src, path); ++ dst_parent = fdt_path_offset(dst, path); ++ if (src_parent < 0 || dst_parent < 0) ++ return -1; ++ ++ src_node = fdt_subnode_offset(src, src_parent, node); ++ if (src_node < 0) ++ return -1; ++ ++ dst_node = fdt_find_or_add_subnode(dst, dst_parent, node); ++ if (dst_node < 0) ++ return -1; ++ ++ fdt_for_each_property_offset(prop, src, src_node) { ++ const char *name; ++ const void *value = fdt_getprop_by_offset(src, prop, &name, &len); ++ ++ if (!value || !name) ++ continue; ++ ++ fdt_setprop(dst, dst_node, name, value, len); ++ } ++ ++ return 0; ++} ++ + int copy_property(void *dst, void *src, char *path, char *property) + { + int dst_offset, src_offset; +@@ -641,6 +689,9 @@ void update_fdt_from_fw(void *fdt, void *fw_fdt) + + /* copy uart clk as provided by the firmware */ + copy_property(fdt, fw_fdt, "/clocks/clk-uart", "clock-frequency"); ++ ++ /* Copy the bootloader node */ ++ copy_node_all_properties(fdt, fw_fdt, "/chosen", "bootloader"); + } + + int ft_board_setup(void *blob, struct bd_info *bd) diff --git a/sources b/sources index 82c8edc..08618e7 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (u-boot-2024.10.tar.bz2) = ef817c9b5ae8dc6cd9e3f57811e90acc6a4d4394f0356aa5923e3e3c8559168f977bd5bf82824cd3650aa8e5e3c3d1b00e20818d21368151748682f1fc51152c +SHA512 (u-boot-v2026.10-rc3.tar.bz2) = e993f5d78a1ac0eb11f00e3730ff23eb880e206036f78c3eb74852b846a23d59111b4b07f4ced2c88c61a8c1627036c3cc32717c0efcf819376c5cd0a34183d2 diff --git a/uboot-tools.spec b/uboot-tools.spec index 9eeb08e..056cc94 100644 --- a/uboot-tools.spec +++ b/uboot-tools.spec @@ -1,42 +1,56 @@ -#global candidate rc0 +%global candidate rc3 %if 0%{?rhel} %bcond_with toolsonly %else %bcond_without toolsonly %endif +# Set it to "opensbi" (stable) or "opensbi-unstable" (unstable, git) +%global opensbi opensbi + Name: uboot-tools -Version: 2024.10 -Release: 1%{?candidate:.%{candidate}}%{?dist} +Version: 2026.10 +Release: 0.3%{?candidate:.%{candidate}}%{?dist} Epoch: 1 Summary: U-Boot utilities # Automatically converted from old format: GPLv2+ BSD LGPL-2.1+ LGPL-2.0+ - review is highly recommended. License: GPL-2.0-or-later AND LicenseRef-Callaway-BSD AND LGPL-2.1-or-later AND LGPL-2.0-or-later -URL: http://www.denx.de/wiki/U-Boot +URL: https://u-boot-project.org/ ExcludeArch: s390x -Source0: https://ftp.denx.de/pub/u-boot/u-boot-%{version}%{?candidate:-%{candidate}}.tar.bz2 +Source0: https://git.u-boot-project.org/u-boot/u-boot/-/archive/v%{version}%{?candidate:-%{candidate}}/u-boot-v%{version}%{?candidate:-%{candidate}}.tar.bz2 Source1: aarch64-boards +Source2: riscv64-boards +Source3: x86_64-boards -# This is now legacy, most devices use bootflow, we keep this for the laggards -Patch1: uefi-distro-load-FDT-from-any-partition-on-boot-device.patch -# Identify VFAT partitions as ESP, allows EFI setvar on our images -Patch2: uefi-Add-all-options-for-EFI-System-Partitions.patch -# New function to find fdt for loading from disk -Patch3: uefi-initial-find_fdt_location-for-finding-the-DT-on-disk.patch # Fedora patches to enable/disable features -Patch4: disable-VBE-by-default.patch -Patch5: enable-bootmenu-by-default.patch -# Should be upstream but it's taking time -#Patch6: Add-video-damage-tracking.patch +Patch1: disable-VBE-by-default.patch +Patch2: enable-bootmenu-by-default.patch +# This is now legacy, most devices use bootflow, we keep this for the laggards +Patch3: uefi-distro-load-FDT-from-any-partition-on-boot-device.patch +# Identify VFAT partitions as ESP, allows EFI setvar on our images +Patch4: uefi-Add-all-options-for-EFI-System-Partitions.patch +# New function to find fdt for loading from disk +Patch5: uefi-initial-find_fdt_location-for-finding-the-DT-on-disk.patch +# Enable UEFI SetVariable for devices without backed storage +Patch6: uefi-enable-SetVariableRT-with-volotile-storage.patch +# Enable UEFI HTTPS boot for all Fedora firmware +Patch7: uefi-enable-https-boot-by-default.patch +# Device improvments +# USB-PD improvements +Patch10: USB-PD-TCPM-improvements.patch # Rockchips improvements -Patch10: rockchip-Enable-preboot-start-for-pci-usb.patch -Patch11: FUSB302-USB-C-controller-support.patch -Patch12: rockchip-Modernise-Geekbox-config.patch -# QCom -Patch15: Qualcomm-add-support-for-SC7280-and-the-RB3-Gen-2.patch +Patch11: rockchip-Enable-preboot-start-for-pci-usb.patch +Patch13: rockchip-rk356x-Stop-overriding-sdhci-mmc-aliases.patch +# Jetson fixes +Patch14: p3450-fix-board.patch +Patch15: JetsonTX2-Fix-upstream-device-tree-naming.patch +# Fix AllWinner +Patch16: Allwinner-fix-booting-on-a-number-of-devices.patch # RPi -Patch20: rpi-Pass-CMA-through-from-firmware-DT.patch +Patch20: Fix-NVMe-not-only-on-Raspberry-Pi-5.patch +Patch21: raspberrypi-Add-quirk-for-RPi5-2Gb-rev-1.0.patch +Patch22: rpi-copy-chosen-bootloader-partition-and-set-boot_partition.patch BuildRequires: bc BuildRequires: bison @@ -47,8 +61,13 @@ BuildRequires: gnutls-devel BuildRequires: libuuid-devel BuildRequires: make BuildRequires: ncurses-devel +%if 0%{?fedora} > 44 +BuildRequires: openssl3-devel +BuildRequires: openssl3-devel-engine +%else BuildRequires: openssl-devel BuildRequires: openssl-devel-engine +%endif BuildRequires: perl-interpreter BuildRequires: python3-devel BuildRequires: python3-setuptools @@ -58,10 +77,14 @@ BuildRequires: swig %if %{with toolsonly} %ifarch aarch64 BuildRequires: arm-trusted-firmware-armv8 +BuildRequires: optee-os-firmware-armv8 BuildRequires: crust-firmware BuildRequires: python3-pyelftools BuildRequires: xxd %endif +%ifarch riscv64 +BuildRequires: %{opensbi} +%endif %endif Requires: dtc @@ -78,12 +101,30 @@ BuildArch: noarch %description -n uboot-images-armv8 U-Boot firmware binaries for aarch64 boards %endif + +%ifarch riscv64 +%package -n uboot-images-riscv64 +Summary: U-Boot firmware images for riscv64 boards +BuildArch: noarch + +%description -n uboot-images-riscv64 +U-Boot firmware binaries for riscv64 boards +%endif + +%ifarch x86_64 +%package -n uboot-images-x86_64 +Summary: U-Boot firmware images for x86_64 boards +BuildArch: noarch + +%description -n uboot-images-x86_64 +U-Boot firmware binaries for x86_64 boards +%endif %endif %prep -%autosetup -p1 -n u-boot-%{version}%{?candidate:-%{candidate}} +%autosetup -p1 -n u-boot-v%{version}%{?candidate:-%{candidate}} -cp %SOURCE1 . +cp %SOURCE1 %SOURCE2 %SOURCE3 . %build mkdir builds @@ -92,7 +133,12 @@ mkdir builds %make_build HOSTCC="gcc $RPM_OPT_FLAGS" CROSS_COMPILE="" tools-all O=builds/ %if %{with toolsonly} -%ifarch aarch64 +# OpenSBI firmware is distributed in U-Boot SPL images +%ifarch riscv64 +export OPENSBI=%{_datadir}/%{opensbi}/generic/firmware/fw_dynamic.bin +%endif + +%ifarch aarch64 riscv64 x86_64 for board in $(cat %{_arch}-boards) do echo "Building board: $board" @@ -117,12 +163,12 @@ do cp /usr/share/arm-trusted-firmware/sun50i_h6/bl31.bin builds/$(echo $board)/atf-bl31 cp /usr/share/crust-firmware/h6/scp.bin builds/$(echo $board)/ fi - sun50i_h616=(orangepi_zero2 orangepi_zero2w orangepi_zero3 transpeed-8k618-t x96_mate) + sun50i_h616=(anbernic_rg35xx_h700 orangepi_zero2 orangepi_zero2w orangepi_zero3 transpeed-8k618-t x96_mate) if [[ " ${sun50i_h616[*]} " == *" $board "* ]]; then echo "Board: $board using sun50i_h616" cp /usr/share/arm-trusted-firmware/sun50i_h616/bl31.bin builds/$(echo $board)/atf-bl31 fi - rk3328=(evb-rk3328 nanopi-r2c-plus-rk3328 nanopi-r2c-rk3328 nanopi-r2s-rk3328 orangepi-r1-plus-lts-rk3328 orangepi-r1-plus-rk3328 roc-cc-rk3328 rock64-rk3328 rock-pi-e-rk3328 rock-pi-e-v3-rk3328) + rk3328=(evb-rk3328 generic-rk3328 nanopi-r2c-plus-rk3328 nanopi-r2c-rk3328 nanopi-r2s-rk3328 nanopi-r2s-plus-rk3328 orangepi-r1-plus-lts-rk3328 orangepi-r1-plus-rk3328 roc-cc-rk3328 rock64-rk3328 rock-pi-e-rk3328 rock-pi-e-v3-rk3328) if [[ " ${rk3328[*]} " == *" $board "* ]]; then echo "Board: $board using rk3328" cp /usr/share/arm-trusted-firmware/rk3328/bl31.elf builds/$(echo $board)/atf-bl31 @@ -132,12 +178,17 @@ do echo "Board: $board using rk3368" cp /usr/share/arm-trusted-firmware/rk3368/bl31.elf builds/$(echo $board)/atf-bl31 fi - rk3399=(eaidk-610-rk3399 evb-rk3399 ficus-rk3399 firefly-rk3399 khadas-edge-captain-rk3399 khadas-edge-rk3399 khadas-edge-v-rk3399 leez-rk3399 nanopc-t4-rk3399 nanopi-m4-2gb-rk3399 nanopi-m4b-rk3399 nanopi-m4-rk3399 nanopi-neo4-rk3399 nanopi-r4s-rk3399 orangepi-rk3399 pinebook-pro-rk3399 pinephone-pro-rk3399 puma-rk3399 rock-4c-plus-rk3399 rock-4se-rk3399 rock960-rk3399 rock-pi-4c-rk3399 rock-pi-4-rk3399 rock-pi-n10-rk3399pro rockpro64-rk3399 roc-pc-mezzanine-rk3399 roc-pc-rk3399) + rk3399=(eaidk-610-rk3399 evb-rk3399 ficus-rk3399 firefly-rk3399 generic-rk3399 khadas-edge-captain-rk3399 khadas-edge-rk3399 khadas-edge-v-rk3399 leez-rk3399 nanopc-t4-rk3399 nanopi-m4-2gb-rk3399 nanopi-m4b-rk3399 nanopi-m4-rk3399 nanopi-neo4-rk3399 nanopi-r4s-rk3399 orangepi-rk3399 pinebook-pro-rk3399 pinephone-pro-rk3399 puma-rk3399 rock-4c-plus-rk3399 rock-4se-rk3399 rock960-rk3399 rock-pi-4c-rk3399 rock-pi-4-rk3399 rock-pi-n10-rk3399pro rockpro64-rk3399 roc-pc-mezzanine-rk3399 roc-pc-rk3399) if [[ " ${rk3399[*]} " == *" $board "* ]]; then echo "Board: $board using rk3399" cp /usr/share/arm-trusted-firmware/rk3399/* builds/$(echo $board)/ cp builds/$(echo $board)/bl31.elf builds/$(echo $board)/atf-bl31 fi + zynqmp=(xilinx_zynqmp_kria xilinx_zynqmp_virt) + if [[ " ${zynqmp[*]} " == *" $board "* ]]; then + echo "Board: $board using zynqmp" + cp /usr/share/arm-trusted-firmware/zynqmp/bl31.bin builds/$(echo $board)/atf-bl31 + fi # End ATF make $(echo $board)_defconfig O=builds/$(echo $board)/ @@ -157,7 +208,18 @@ mkdir -p %{buildroot}%{_datadir}/uboot/ %ifarch aarch64 for board in $(ls builds) do - for file in u-boot.bin u-boot.img u-boot-dtb.img u-boot.itb u-boot-sunxi-with-spl.bin u-boot-rockchip-spi.bin u-boot-rockchip.bin idbloader.img idbloader-spi.img spl/boot.bin + for file in u-boot.bin u-boot.img u-boot-dtb.img u-boot-sunxi-with-spl.bin u-boot-rockchip-spi.bin u-boot-rockchip.bin + do + if [ -f builds/$(echo $board)/$(echo $file) ]; then + install -pD -m 0644 builds/$(echo $board)/$(echo $file) %{buildroot}%{_datadir}/uboot/$(echo $board)/$(echo $file) + fi + done +done + +# Just for xilinx_zynqmp +for board in "xilinx_zynqmp_kria xilinx_zynqmp_virt" +do + for file in u-boot.itb spl/boot.bin do if [ -f builds/$(echo $board)/$(echo $file) ]; then install -pD -m 0644 builds/$(echo $board)/$(echo $file) %{buildroot}%{_datadir}/uboot/$(echo $board)/$(echo $file) @@ -167,6 +229,31 @@ done # For Apple M-series we also need the nodtb variant install -pD -m 0644 builds/apple_m1/u-boot-nodtb.bin %{buildroot}%{_datadir}/uboot/apple_m1/u-boot-nodtb.bin +%endif + +%ifarch riscv64 +for board in $(ls builds) +do + for file in u-boot.itb spl/u-boot-spl.bin spl/u-boot-spl.bin.normal.out + do + if [ -f builds/$(echo $board)/$(echo $file) ]; then + install -pD -m 0644 builds/$(echo $board)/$(echo $file) %{buildroot}%{_datadir}/uboot/$(echo $board)/$(echo $file) + fi + done +done +%endif + +%ifarch x86_64 +for board in $(ls builds) +do + for file in u-boot.rom + do + if [ -f builds/$(echo $board)/$(echo $file) ]; then + install -pD -m 0644 builds/$(echo $board)/$(echo $file) %{buildroot}%{_datadir}/uboot/$(echo $board)/$(echo $file) + fi + done +done +%endif # Bit of a hack to remove binaries we don't use as they're large for board in $(ls builds) @@ -174,21 +261,21 @@ do rm -f %{buildroot}%{_datadir}/uboot/$(echo $board)/u-boot.dtb if [ -f %{buildroot}%{_datadir}/uboot/$(echo $board)/u-boot-sunxi-with-spl.bin ]; then rm -f %{buildroot}%{_datadir}/uboot/$(echo $board)/u-boot{,-dtb}.* - rm -f %{buildroot}%{_datadir}/uboot/$(echo $board)/sunxi-spl.bin fi - if [ -f %{buildroot}%{_datadir}/uboot/$(echo $board)/idbloader.img ]; then - rm -f %{buildroot}%{_datadir}/uboot/$(echo $board)/u-boot.bin - rm -f %{buildroot}%{_datadir}/uboot/$(echo $board)/u-boot{,-dtb}.img + if [ -f %{buildroot}%{_datadir}/uboot/$(echo $board)/u-boot-rockchip.bin ]; then + rm -f %{buildroot}%{_datadir}/uboot/$(echo $board)/u-boot{,-dtb}.* fi done %endif -%endif -for tool in dumpimage env/fw_printenv fit_check_sign fit_info gdb/gdbcont gdb/gdbsend gen_eth_addr gen_ethaddr_crc ifwitool img2srec kwboot mkeficapsule mkenvimage mkimage mksunxiboot ncb proftool sunxi-spl-image-builder +for tool in dumpimage env/fw_printenv fdt_add_pubkey fit_check_sign fit_info gdb/gdbcont gdb/gdbsend gen_eth_addr gen_ethaddr_crc ifwitool img2srec kwboot mkeficapsule mkenvimage mkimage mksunxiboot ncb proftool sunxi-spl-image-builder do install -p -m 0755 builds/tools/$tool %{buildroot}%{_bindir} done -install -p -m 0644 doc/mkimage.1 %{buildroot}%{_mandir}/man1 +for tool in dumpimage kwboot mkeficapsule mkimage +do +install -p -m 0644 doc/$tool.1 %{buildroot}%{_mandir}/man1 +done install -p -m 0755 builds/tools/env/fw_printenv %{buildroot}%{_bindir} ( cd %{buildroot}%{_bindir}; ln -sf fw_printenv fw_setenv ) @@ -198,6 +285,9 @@ install -p -m 0755 builds/tools/env/fw_printenv %{buildroot}%{_bindir} %doc README doc/develop/distro.rst doc/README.gpt %doc doc/develop/uefi doc/usage doc/arch/arm64.rst %{_bindir}/* +%{_mandir}/man1/dumpimage.1* +%{_mandir}/man1/kwboot.1* +%{_mandir}/man1/mkeficapsule.1* %{_mandir}/man1/mkimage.1* %if %{with toolsonly} @@ -207,9 +297,201 @@ install -p -m 0755 builds/tools/env/fw_printenv %{buildroot}%{_bindir} %dir %{_datadir}/uboot/ %{_datadir}/uboot/* %endif + +%ifarch riscv64 +%files -n uboot-images-riscv64 +%license Licenses/* +%dir %{_datadir}/uboot/ +%{_datadir}/uboot/* +%endif + +%ifarch x86_64 +%files -n uboot-images-x86_64 +%license Licenses/* +%dir %{_datadir}/uboot/ +%{_datadir}/uboot/* +%endif %endif %changelog +* Thu Aug 27 2026 Peter Robinson - 1:2026.10-0.3.rc3 +- Update to 2026.10 RC3 + +* Wed Aug 12 2026 Peter Robinson - 1:2026.10-0.2.rc2 +- Update to 2026.10 RC2 + +* Thu Jul 30 2026 Peter Robinson - 1:2026.10-0.1.rc1 +- Update to 2026.10 RC1 +- Update source URL + +* Fri Jul 17 2026 Fedora Release Engineering - 1:2026.07-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild + +* Tue Jul 07 2026 Peter Robinson - 1:2026.07-1 +- Update to 2026.07 GA + +* Tue Jun 23 2026 Peter Robinson - 1:2026.07-0.4.rc5 +- Update to 2026.07 RC5 + +* Mon Jun 08 2026 Peter Robinson - 1:2026.07-0.3.rc4 +- Update to 2026.07 RC4 + +* Fri May 29 2026 Peter Robinson - 1:2026.07-0.2.rc3 +- Update to 2026.07 RC3 +- Update U-Boot Project URL +- Update RPi PCIe patches +- Various RPi fixes + +* Fri May 01 2026 Peter Robinson - 1:2026.07-0.1.rc1 +- Update to 2026.07 RC1 + +* Sat Apr 11 2026 Peter Robinson - 1:2026.04-2 +- Fix PCIe/USB on Raspberry Pi 4 (rhbz#2448365) +- Fix detection of some revisions of RPi5 + +* Tue Apr 07 2026 Peter Robinson - 1:2026.04-1 +- Update to 2026.04 GA + +* Sun Mar 29 2026 Peter Robinson - 1:2026.04-0.9.rc5 +- Enable NVME booting on RPi5 + +* Tue Mar 24 2026 Peter Robinson - 1:2026.04-0.8.rc5 +- Update to 2026.04 RC5 + +* Sat Mar 14 2026 Peter Robinson - 1:2026.04-0.7.rc4 +- Raspberry Pi fixes + +* Tue Mar 10 2026 Peter Robinson - 1:2026.04-0.6.rc4 +- Update to 2026.04 RC4 + +* Fri Feb 27 2026 Peter Robinson - 1:2026.04-0.5.rc3 +- Update to 2026.04 RC3 + +* Tue Feb 17 2026 Peter Robinson - 1:2026.04-0.4.rc2 +- Add initial bcm2712d0 identification + +* Mon Feb 09 2026 Peter Robinson - 1:2026.04-0.3.rc2 +- Update to 2026.04 RC2 + +* Tue Jan 27 2026 Peter Robinson - 1:2026.04-0.2.rc1 +- Update to 2026.04 RC1 + +* Mon Jan 19 2026 Javier Martinez Canillas - 1:2026.01-3 +- Add a uboot-images-x86_64 subpackage + +* Sat Jan 17 2026 Fedora Release Engineering - 1:2026.01-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild + +* Tue Jan 06 2026 Peter Robinson - 1:2026.01-1 +- Update to 2026.01 GA + +* Mon Dec 29 2025 Peter Robinson - 1:2026.01-0.4.rc5 +- Update to 2026.01 RC5 + +* Mon Dec 08 2025 Peter Robinson - 1:2026.01-0.3.rc4 +- Update to 2026.01 RC4 + +* Fri Nov 28 2025 Peter Robinson - 1:2026.01-0.2.rc3 +- Updates for RPi + +* Mon Nov 24 2025 Peter Robinson - 1:2026.01-0.1.rc3 +- Update to 2026.01 RC3 + +* Thu Oct 16 2025 Peter Robinson - 1:2025.10-2 +- Drop residual Rockchip firmware (saves ~150Mb) + +* Mon Oct 13 2025 Peter Robinson - 1:2025.10-1 +- Update to 2025.10 GA (rhbz#2401964) +- Fix booting when using FW device-tree (rhbz#2402498) +- Fix for some variants of Raspberry Pi +- Fixes for Jetson device booting + +* Fri Sep 26 2025 Peter Robinson - 1:2025.10-0.7.rc5 +- Update to 2025.10 RC5 + +* Mon Sep 08 2025 Peter Robinson - 1:2025.10-0.6.rc4 +- Update to 2025.10 RC4 + +* Sun Sep 07 2025 Peter Robinson - 1:2025.10-0.5.rc3 +- Boot fixes for some Raspberry Pi variants + +* Wed Aug 27 2025 Peter Robinson - 1:2025.10-0.4.rc3 +- Fix booting on some Allwinner devices + +* Mon Aug 25 2025 Peter Robinson - 1:2025.10-0.3.rc3 +- Update to 2025.10 RC3 + +* Tue Aug 19 2025 Peter Robinson - 1:2025.10-0.2.rc2 +- Fix and re-enable Jetson Nano + +* Mon Aug 18 2025 Peter Robinson - 1:2025.10-0.1.rc2 +- Update to 2025.10 RC2 + +* Fri Jul 25 2025 Fedora Release Engineering - 1:2025.07-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + +* Thu Jul 10 2025 Peter Robinson - 1:2025.07-2 +- Update patch for rebase issue + +* Wed Jul 09 2025 Peter Robinson - 1:2025.07-1 +- Update to 2025.07 GA + +* Fri Jun 27 2025 Peter Robinson - 1:2025.07-0.5.rc5 +- Update to 2025.07 RC5 +- Enable LWIP stack by default +- Enable HTTP(s) boot support + +* Thu Jun 26 2025 Javier Martinez Canillas - 1:2025.07-0.4.rc4 +- Add EFI_PARTITION_INFO_PROTOCOL support + +* Sun Jun 15 2025 Peter Robinson - 1:2025.07-0.3.rc4 +- Update to 2025.07 RC4 + +* Tue May 13 2025 Peter Robinson - 1:2025.07-0.2.rc2 +- Update to 2025.07 RC2 + +* Thu May 01 2025 Peter Robinson - 1:2025.07-0.1.rc1 +- Update to 2025.07 RC1 + +* Sun Apr 20 2025 Peter Robinson - 1:2025.04-2 +- Fix for RPi5 serial console + +* Tue Apr 08 2025 Peter Robinson - 1:2025.04-1 +- Update to 2025.04 GA + +* Tue Mar 25 2025 Peter Robinson - 1:2025.04-0.7.rc5 +- Update to 2025.04 RC5 + +* Wed Mar 12 2025 Peter Robinson - 1:2025.04-0.6.rc4 +- Update to 2025.04 RC4 + +* Wed Feb 26 2025 Peter Robinson - 1:2025.04-0.5.rc3 +- Update to 2025.04 RC3 + +* Tue Feb 18 2025 David Abdurachmanov - 1:2025.04-0.4.rc2 +- Add support for riscv64 + +* Tue Feb 11 2025 Peter Robinson - 1:2025.04-0.3.rc2 +- Update to 2025.05 RC2 + +* Tue Feb 11 2025 Peter Robinson - 1:2025.04-0.2.rc1 +- Update to 2025.05 RC1 + +* Tue Jan 28 2025 Peter Robinson - 1:2025.01-3 +- Add new fdt_add_pubkey tool + +* Sun Jan 19 2025 Fedora Release Engineering - 1:2025.01-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + +* Tue Jan 07 2025 Peter Robinson - 1:2025.01-1 +- Update to 2025.01 GA + +* Mon Jan 06 2025 Peter Robinson - 1:2025.01-0.2.rc6 +- Rebuild for TF-A 2.12 + +* Tue Dec 31 2024 Peter Robinson - 1:2025.01-0.1.rc6 +- Update to 2025.01 RC6 + * Fri Oct 11 2024 Peter Robinson - 1:2024.10-1 - Update to 2024.10 GA - Fix passing RPi firmware CMA setting to kernel DT diff --git a/uefi-enable-SetVariableRT-with-volotile-storage.patch b/uefi-enable-SetVariableRT-with-volotile-storage.patch new file mode 100644 index 0000000..ee9bcf4 --- /dev/null +++ b/uefi-enable-SetVariableRT-with-volotile-storage.patch @@ -0,0 +1,33 @@ +From fd736dd720b29fa69a4bb87492f3f94dc6076996 Mon Sep 17 00:00:00 2001 +From: Peter Robinson +Date: Tue, 25 Mar 2025 17:13:44 +0000 +Subject: [PATCH] efi: enable SetVariableRT with volotile storage + +Signed-off-by: Peter Robinson +--- + lib/efi_loader/Kconfig | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig +index d4f6b56afaa..3e522131b01 100644 +--- a/lib/efi_loader/Kconfig ++++ b/lib/efi_loader/Kconfig +@@ -108,6 +108,7 @@ choice + config EFI_VARIABLE_FILE_STORE + bool "Store non-volatile UEFI variables as file" + depends on FAT_WRITE ++ default y + help + Select this option if you want non-volatile UEFI variables to be + stored as file /ubootefi.var on the EFI system partition. +@@ -115,6 +116,7 @@ config EFI_VARIABLE_FILE_STORE + config EFI_RT_VOLATILE_STORE + bool "Allow variable runtime services in volatile storage (e.g RAM)" + depends on EFI_VARIABLE_FILE_STORE ++ default y + help + When EFI variables are stored on file we don't allow SetVariableRT, + since the OS doesn't know how to write that file. At the same time +-- +2.49.0 + diff --git a/uefi-enable-https-boot-by-default.patch b/uefi-enable-https-boot-by-default.patch new file mode 100644 index 0000000..dc0a683 --- /dev/null +++ b/uefi-enable-https-boot-by-default.patch @@ -0,0 +1,82 @@ +From 7eabab2fda12b7a4417e5c7f29a507dfa9e7fffd Mon Sep 17 00:00:00 2001 +From: Peter Robinson +Date: Sun, 3 May 2026 09:24:34 +0100 +Subject: [PATCH] enable https boot by default + +Signed-off-by: Peter Robinson +--- + cmd/Kconfig | 1 + + lib/efi_loader/Kconfig | 1 + + lib/mbedtls/Kconfig | 3 ++- + net/Kconfig | 3 ++- + 4 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/cmd/Kconfig b/cmd/Kconfig +index c71c6824a19..8ff14adffe1 100644 +--- a/cmd/Kconfig ++++ b/cmd/Kconfig +@@ -2289,6 +2289,7 @@ config CMD_WGET + + config WGET_HTTPS + bool "wget https" ++ default y + depends on CMD_WGET + depends on PROT_TCP_LWIP + depends on MBEDTLS_LIB +diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig +index 4cb13ae7c8a..20733429962 100644 +--- a/lib/efi_loader/Kconfig ++++ b/lib/efi_loader/Kconfig +@@ -609,6 +609,7 @@ config EFI_BOOTMGR + + config EFI_HTTP_BOOT + bool "EFI HTTP Boot support" ++ default y + depends on NET + depends on CMDLINE + select CMD_NET +diff --git a/lib/mbedtls/Kconfig b/lib/mbedtls/Kconfig +index 789721ee6cd..7a241c2bc26 100644 +--- a/lib/mbedtls/Kconfig ++++ b/lib/mbedtls/Kconfig +@@ -2,7 +2,7 @@ + + choice + prompt "Crypto libraries (U-Boot Proper)" +- default LEGACY_HASHING_AND_CRYPTO ++ default MBEDTLS_LIB + help + Select crypto libraries. + LEGACY_HASHING_AND_CRYPTO for legacy crypto libraries, +@@ -15,6 +15,7 @@ config LEGACY_HASHING_AND_CRYPTO + + config MBEDTLS_LIB + bool "MbedTLS libraries" ++ default y + select MBEDTLS_LIB_X509 + endchoice + +diff --git a/net/Kconfig b/net/Kconfig +index e712a0dd2ac..3158d37dff7 100644 +--- a/net/Kconfig ++++ b/net/Kconfig +@@ -16,7 +16,7 @@ if NET + + choice + prompt "Networking stack" +- default NET_LEGACY ++ default NET_LWIP + + config NET_LEGACY + bool "Legacy U-Boot networking stack" +@@ -27,6 +27,7 @@ config NET_LEGACY + + config NET_LWIP + bool "Use lwIP for networking stack" ++ default y + select NETDEVICES + help + Include networking support based on the lwIP (lightweight IP) +-- +2.54.0 + diff --git a/uefi-initial-find_fdt_location-for-finding-the-DT-on-disk.patch b/uefi-initial-find_fdt_location-for-finding-the-DT-on-disk.patch index 232e121..ac58bad 100644 --- a/uefi-initial-find_fdt_location-for-finding-the-DT-on-disk.patch +++ b/uefi-initial-find_fdt_location-for-finding-the-DT-on-disk.patch @@ -1,6 +1,6 @@ -From 8abb44f89aefd25cda27c54c08b68b3a60bea7c3 Mon Sep 17 00:00:00 2001 +From 56a985cec8592a8de88e7f254df82f5d444a5ecc Mon Sep 17 00:00:00 2001 From: Peter Robinson -Date: Thu, 21 Mar 2024 13:43:24 +0000 +Date: Thu, 28 May 2026 22:08:07 +0100 Subject: [PATCH] initial find_fdt_location for finding the DT on disk The old distro boot looked for a DT on the first boot partition @@ -16,29 +16,16 @@ so that devices will continue to work as they did previously. Signed-off-by: Peter Robinson --- - cmd/bootefi.c | 1 + cmd/bootmenu.c | 5 ++ include/efi_loader.h | 2 + - lib/efi_loader/efi_helper.c | 105 +++++++++++++++++++++++++++++++++++- - 4 files changed, 112 insertions(+), 1 deletion(-) + lib/efi_loader/efi_helper.c | 106 +++++++++++++++++++++++++++++++++++- + 3 files changed, 112 insertions(+), 1 deletion(-) -diff --git a/cmd/bootefi.c b/cmd/bootefi.c -index 9cf9027bf40..8b6194a8702 100644 ---- a/cmd/bootefi.c -+++ b/cmd/bootefi.c -@@ -144,6 +144,7 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc, - if (argc > 2) { - uintptr_t fdt_addr; - -+ /* Do we need to run find_fdt_location here?*/ - fdt_addr = hextoul(argv[2], NULL); - fdt = map_sysmem(fdt_addr, 0); - } else { diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c -index 78184fccab2..48368c8d42e 100644 +index 528afd221d0..a10ea35a687 100644 --- a/cmd/bootmenu.c +++ b/cmd/bootmenu.c -@@ -448,6 +448,11 @@ static void handle_uefi_bootnext(void) +@@ -502,6 +502,11 @@ static void handle_uefi_bootnext(void) u16 bootnext; efi_status_t ret; efi_uintn_t size; @@ -51,10 +38,10 @@ index 78184fccab2..48368c8d42e 100644 /* Initialize EFI drivers */ ret = efi_init_obj_list(); diff --git a/include/efi_loader.h b/include/efi_loader.h -index 7daca0afba2..a969378ff2f 100644 +index 3a4d502631c..b11f8a2cb42 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h -@@ -524,6 +524,8 @@ struct efi_register_notify_event { +@@ -574,6 +574,8 @@ struct efi_register_notify_event { struct list_head handles; }; @@ -64,20 +51,20 @@ index 7daca0afba2..a969378ff2f 100644 int efi_init_early(void); /* Initialize efi execution environment */ diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c -index 5dd9cc876e4..a33ec39ff74 100644 +index 44b806aadc4..61e982091b9 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c -@@ -12,6 +12,7 @@ +@@ -15,6 +15,7 @@ #include #include #include +#include + #include #include #include - #include -@@ -24,6 +25,99 @@ - const efi_guid_t efi_lf2_initrd_guid = EFI_INITRD_MEDIA_GUID; - #endif +@@ -98,6 +99,99 @@ int efi_get_pxe_arch(void) + return -EINVAL; + } +/* We need to pass a blk device in and return a location, or a loaded DT */ +char *find_fdt_location(void) @@ -175,14 +162,15 @@ index 5dd9cc876e4..a33ec39ff74 100644 /** * efi_create_current_boot_var() - Return Boot#### name were #### is replaced by * the value of BootCurrent -@@ -432,11 +526,20 @@ efi_status_t efi_install_fdt(void *fdt) - /* Look for device tree that is already installed */ - if (efi_get_configuration_table(&efi_guid_fdt)) - return EFI_SUCCESS; +@@ -558,11 +652,21 @@ efi_status_t efi_install_fdt(void *fdt) + const char *fdt_opt; + uintptr_t fdt_addr; + + /* Check if there is device tree loaded from disk */ + fdt_opt = find_fdt_location(); + if (fdt_opt) -+ log_debug("Found DTB on disk\n"); ++ log_info("Found DTB on disk\n"); ++ /* Check if there is a hardware device tree */ - fdt_opt = env_get("fdt_addr"); + if (!fdt_opt) { @@ -193,10 +181,10 @@ index 5dd9cc876e4..a33ec39ff74 100644 /* Use our own device tree as fallback */ if (!fdt_opt) { fdt_opt = env_get("fdtcontroladdr"); -+ log_debug("Using DT from U-Boot\n"); ++ log_info("Using DT from U-Boot\n"); if (!fdt_opt) { - log_err("ERROR: need device tree\n"); + log_err("need device tree\n"); return EFI_NOT_FOUND; -- -2.44.0 +2.54.0 diff --git a/x86_64-boards b/x86_64-boards new file mode 100644 index 0000000..dec8df3 --- /dev/null +++ b/x86_64-boards @@ -0,0 +1 @@ +qemu-x86_64