From patchwork Sun Feb 20 22:47:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 544277 Delivered-To: patch@linaro.org Received: by 2002:ac0:e142:0:0:0:0:0 with SMTP id r2csp2823230imn; Sun, 20 Feb 2022 14:49:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYjiIVz0ulsf1pTXiGr3mugf+DwfLyyEpkpAiBtJGKIJKZ03p+FnSYzcUjYAKGdOIEitRq X-Received: by 2002:a17:906:edb5:b0:6b8:1a5a:f3a0 with SMTP id sa21-20020a170906edb500b006b81a5af3a0mr14296485ejb.501.1645397358252; Sun, 20 Feb 2022 14:49:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645397358; cv=none; d=google.com; s=arc-20160816; b=lx6DqefWHSwBogLW7lt2exQwt+fuWqzwLHRTc62tjCrWy9ZrfiekQbovhb7DFWMERJ +qgL9/7NNL56ZX4I+bfmsBMhdayovFpQbjkcrbIqzns9lQBXYnRv7MchV99s6W3MDyCF /Jekxm7UTrdxJygWdXLaJQvfnIezg6blnTwOpcWhnOBnPZl6MVrDRb/yYYswGEnkjTpX fsV5PJ1Lxbz77mfyv+i0LY5b0J5bo3N6wtt1uwDagtvtW1fPY76kJXFB5t3vBdlf1sAa 0hWBX5qYmzsBvGPQiNCa+u0z5I322piL226Be5uIwBvh/qPXV7kHkycil6lWd2Ye4sIe 1xjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=pjuhCwoYy6CTvHsbXnPSLn8fs4WPa5yn8GzuoVDT06w=; b=Tbwn8J6E4Va5i/yBbKC8hxme9uVyverb1f8TgOASXO+VyVvOUYYDZaNOOFniUZA2kt qtguAvAIAlHytxUydcMpMuKjJyOulict7NqI6GsrVfxoLXWAyTzMtaElgxGMh/Cr1OkN fQKaLDWgUA2BA2h+JurjSrysjQRH3aX8wBUUukODCY7FySToav4Y3W/fopmgetcsei8e i37EaTG5wcxhvoFLXdhIxrWWBFSPpvIpXE+9ve37vz/Ns/sn+mhHBO8LtOtypUiI6xDG /ZAZ1Qcuew4Pu+5jYs9TrneGkeeLFr9t8XWbL6OEdS3ztopVl/XKlH0FFyZK4A4SaBB8 BUxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fCErSZSY; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id h22si5116479edr.166.2022.02.20.14.49.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 14:49:18 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fCErSZSY; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3EE7883BCA; Sun, 20 Feb 2022 23:49:14 +0100 (CET) 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="fCErSZSY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5822C83BCD; Sun, 20 Feb 2022 23:49: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,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) (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 5DC2983BBD for ; Sun, 20 Feb 2022 23:49:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=linus.walleij@linaro.org Received: by mail-lf1-x12d.google.com with SMTP id y24so2985599lfg.1 for ; Sun, 20 Feb 2022 14:49:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pjuhCwoYy6CTvHsbXnPSLn8fs4WPa5yn8GzuoVDT06w=; b=fCErSZSYgR+JLgiPjLk6V4daXiuHzwEisu5cU+ghgVR75baTPIO7zde0CegmazVk01 3aswXj+3R2d7XG13e5+yKJ5xtOXcp1IeAMns26PzJJQGE672sl0vHSrt/OLPU69d2i2z +xPH83/sPD3rNIA8n6yZ2qrkYbjyXwfaJunDela0y2F4w/a3pQw6ltsIPfwqoEW1ZXmM cITL7RQ5UsNHkxSkUPQqpBgqP4v0akfG8Hb9RDw09FDLn5QgwBmhMEWxmsgHoHZXkgxG nkIFbnUOSpITEq1R3XTfMPfhAkHGWsflhXNZSXj1Y0SxYQkhva6wRHVaeCwIYeNd1O1Y kHZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pjuhCwoYy6CTvHsbXnPSLn8fs4WPa5yn8GzuoVDT06w=; b=dxYLM6BwJmlXm8qQxFHYxd9YDWjqapM9zKHnwSwYgPfCa47VPEMajdt91WJxBgEfWg CA3jafZRJCWNcbDjoRP4Zn1EugnNUtYDSEU4y1d4+S9XyRuONGnMEOjGIL53HaHlw5+f W+ftQnPGfquesqadoxoW4FJoFA7NE4rpz0faTAVU5P+wjQupbWmOabzNmuB5ZgYDS3mY 5m/PtO5yXoe4bcphRPAl7YZXXGHe9uaqxc+CJlxOhtBBfPXn8N55qqN9L4IPa2LyKQMm kKt528xEZHEnGN7ElZ7PM4RPtTzfJoKIfqsypZTyWZSANyf9v/9svW8WtPZjTaLQd5up xEKg== X-Gm-Message-State: AOAM531VTt3ToQ2/9fPFMTUhQCWPe5pYpHqvvuldzGkEO0wLPi0NZRpp Z11RBqyMIb08nbHLGfehT2/wvhPDKq33Aqqz X-Received: by 2002:a05:6512:1053:b0:443:967f:bc45 with SMTP id c19-20020a056512105300b00443967fbc45mr12997987lfb.128.1645397344852; Sun, 20 Feb 2022 14:49:04 -0800 (PST) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id o5sm935360lfg.195.2022.02.20.14.49.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 14:49:04 -0800 (PST) From: Linus Walleij To: u-boot@lists.denx.de, Tom Rini Cc: Linus Walleij , Markuss Broks , Stephan Gerhold Subject: [PATCH v2] board: stemmy: Detect board variants and patch DTB Date: Sun, 20 Feb 2022 23:47:01 +0100 Message-Id: <20220220224701.1675823-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.34.1 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.5 at phobos.denx.de X-Virus-Status: Clean This patch scans the cmdline from the Samsung SBL (second stage bootloader) and stores the parameters board_id=N and lcdtype=N in order to augment the DTB for different board and LCD types. We then add a custom ft_board_setup() callback that will inspect the DTB and patch it using the stored LCD type. At this point we know which product we are dealing with, so using the passed board_id we can also print the board variant for diagnostics. We patch the Codina, Skomer and Kyle DTBs to use the right LCD type as passed in lcdtype from the SBL. This also creates an infrastructure for handling any other Samsung U8500 board variants that may need a slightly augmented DTB. Cc: Markuss Broks Cc: Stephan Gerhold Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Use ft_board_setup() like everyone else. The patch refers to samsung,codina-tmo which is a device tree which is not yet in the upstream Linux kernel but it is on its way there. --- board/ste/stemmy/stemmy.c | 315 ++++++++++++++++++++++++++++++++++++++ configs/stemmy_defconfig | 2 + 2 files changed, 317 insertions(+) diff --git a/board/ste/stemmy/stemmy.c b/board/ste/stemmy/stemmy.c index a16be6143dc3..60f27374c3c5 100644 --- a/board/ste/stemmy/stemmy.c +++ b/board/ste/stemmy/stemmy.c @@ -4,6 +4,7 @@ */ #include #include +#include #include #include #include @@ -157,6 +158,33 @@ static void parse_serial(const struct tag_serialnr *serialnr) env_set("serial#", serial); } +#define SBL_BOARD "board_id=" +#define SBL_LCDTYPE "lcdtype=" +static ulong board_id = 0; +static ulong lcdtype = 0; + +static void parse_cmdline(const struct tag_cmdline *cmdline) +{ + char *buf; + + /* Export this to sbl_cmdline (secondary boot loader command line) */ + env_set("sbl_cmdline", cmdline->cmdline); + + buf = strstr(cmdline->cmdline, SBL_BOARD); + if (!buf) + return; + buf += strlen(SBL_BOARD); + + board_id = simple_strtoul(buf, NULL, 10); + + buf = strstr(cmdline->cmdline, SBL_LCDTYPE); + if (!buf) + return; + buf += strlen(SBL_LCDTYPE); + + lcdtype = simple_strtoul(buf, NULL, 10); +} + /* * The downstream/vendor kernel (provided by Samsung) uses ATAGS for booting. * It also requires an extremely long cmdline provided by the primary bootloader @@ -188,6 +216,9 @@ static void copy_atags(const struct tag *tags) if (t->hdr.tag == ATAG_SERIAL) parse_serial(&t->u.serialnr); + if (t->hdr.tag == ATAG_CMDLINE) + parse_cmdline(&t->u.cmdline); + fw_atags_size += t->hdr.size * sizeof(u32); } @@ -228,3 +259,287 @@ void setup_board_tags(struct tag **in_params) memcpy(*in_params, fw_atags_copy, fw_atags_size); *(u8 **)in_params += fw_atags_size; } + +/* These numbers are unique per product but not across all products */ +#define SAMSUNG_CODINA_LCD_LMS380KF01 4 +#define SAMSUNG_CODINA_LCD_S6D27A1 13 +#define SAMSUNG_SKOMER_LCD_HVA40WV1 10 +#define SAMSUNG_SKOMER_LCD_NT35512 12 + +static void codina_patch_display(void *fdt) +{ + int node; + int ret; + + node = fdt_path_offset(fdt, "/spi-gpio-0/panel"); + if (node < 0) { + printf("cannot find Codina panel node\n"); + return; + } + if (lcdtype == SAMSUNG_CODINA_LCD_LMS380KF01) { + ret = fdt_setprop_string(fdt, node, "compatible", "samsung,lms380kf01"); + if (ret < 0) + printf("could not set LCD compatible\n"); + else + printf("updated LCD compatible to LMS380KF01\n"); + } else if (lcdtype == SAMSUNG_CODINA_LCD_S6D27A1) { + ret = fdt_setprop_string(fdt, node, "compatible", "samsung,s6d27a1"); + if (ret < 0) + printf("could not set LCD compatible\n"); + else + printf("updated LCD compatible to S6D27A1\n"); + } else { + printf("unknown LCD type\n"); + } +} + +static void skomer_kyle_patch_display(void *fdt) +{ + int node; + int ret; + + node = fdt_path_offset(fdt, "/soc/mcde/dsi/panel"); + if (node < 0) { + printf("cannot find Skomer/Kyle panel node\n"); + return; + } + if (lcdtype == SAMSUNG_SKOMER_LCD_HVA40WV1) { + ret = fdt_setprop_string(fdt, node, "compatible", "hydis,hva40wv1"); + if (ret < 0) + printf("could not set LCD compatible\n"); + else + printf("updated LCD compatible to Hydis HVA40WV1\n"); + } else if (lcdtype == SAMSUNG_SKOMER_LCD_NT35512) { + /* + * FIXME: This panel is actually a BOE product, but we don't know + * the exact product name, so the compatible for the NT35512 + * is used for the time being. The vendor drivers also call it NT35512. + */ + ret = fdt_setprop_string(fdt, node, "compatible", "novatek,nt35512"); + if (ret < 0) + printf("could not set LCD compatible\n"); + else + printf("updated LCD compatible to Novatek NT35512\n"); + } else { + printf("unknown LCD type\n"); + } +} + +int ft_board_setup(void *fdt, struct bd_info *bd) +{ + const char *str; + int node; + int ret; + + printf("stemmy patch: DTB at 0x%08lx\n", (ulong)fdt); + + /* Inspect FDT to see what we've got here */ + ret = fdt_check_header(fdt); + if (ret < 0) { + printf("invalid DTB\n"); + return ret; + } + node = fdt_path_offset(fdt, "/"); + if (node < 0) { + printf("cannot find root node\n"); + return node; + } + str = fdt_stringlist_get(fdt, node, "compatible", 0, NULL); + if (!str) { + printf("could not find board compatible\n"); + return -1; + } + + if (!strcmp(str, "samsung,janice")) { + switch(board_id) { + case 7: + printf("Janice GT-I9070 Board Rev 0.0\n"); + break; + case 8: + printf("Janice GT-I9070 Board Rev 0.1\n"); + break; + case 9: + printf("Janice GT-I9070 Board Rev 0.2\n"); + break; + case 10: + printf("Janice GT-I9070 Board Rev 0.3\n"); + break; + case 11: + printf("Janice GT-I9070 Board Rev 0.4\n"); + break; + case 12: + printf("Janice GT-I9070 Board Rev 0.5\n"); + break; + case 13: + printf("Janice GT-I9070 Board Rev 0.6\n"); + break; + default: + break; + } + } else if (!strcmp(str, "samsung,gavini")) { + switch(board_id) { + case 7: + printf("Gavini GT-I8530 Board Rev 0.0\n"); + break; + case 8: + printf("Gavini GT-I8530 Board Rev 0.0A\n"); + break; + case 9: + printf("Gavini GT-I8530 Board Rev 0.0B\n"); + break; + case 10: + printf("Gavini GT-I8530 Board Rev 0.0A_EMUL\n"); + break; + case 11: + printf("Gavini GT-I8530 Board Rev 0.0C\n"); + break; + case 12: + printf("Gavini GT-I8530 Board Rev 0.0D\n"); + break; + case 13: + printf("Gavini GT-I8530 Board Rev 0.1\n"); + break; + case 14: + printf("Gavini GT-I8530 Board Rev 0.3\n"); + break; + default: + break; + } + } else if (!strcmp(str, "samsung,codina")) { + switch(board_id) { + case 7: + printf("Codina GT-I8160 Board Rev 0.0\n"); + break; + case 8: + printf("Codina GT-I8160 Board Rev 0.1\n"); + break; + case 9: + printf("Codina GT-I8160 Board Rev 0.2\n"); + break; + case 10: + printf("Codina GT-I8160 Board Rev 0.3\n"); + break; + case 11: + printf("Codina GT-I8160 Board Rev 0.4\n"); + break; + case 12: + printf("Codina GT-I8160 Board Rev 0.5\n"); + break; + default: + break; + } + codina_patch_display(fdt); + } else if (!strcmp(str, "samsung,codina-tmo")) { + switch(board_id) { + case 0x101: + printf("Codina SGH-T599 Board pre-Rev 0.0\n"); + break; + case 0x102: + printf("Codina SGH-T599 Board Rev 0.0\n"); + break; + case 0x103: + printf("Codina SGH-T599 Board Rev 0.1\n"); + break; + case 0x104: + printf("Codina SGH-T599 Board Rev 0.2\n"); + break; + case 0x105: + printf("Codina SGH-T599 Board Rev 0.4\n"); + break; + case 0x106: + printf("Codina SGH-T599 Board Rev 0.6\n"); + break; + case 0x107: + printf("Codina SGH-T599 Board Rev 0.7\n"); + break; + default: + break; + } + codina_patch_display(fdt); + } else if (!strcmp(str, "samsung,golden")) { + switch(board_id) { + case 0x102: + printf("Golden GT-I8190 Board SW bringup\n"); + break; + case 0x103: + printf("Golden GT-I8190 Board Rev 0.2\n"); + break; + case 0x104: + printf("Golden GT-I8190 Board Rev 0.3\n"); + break; + case 0x105: + printf("Golden GT-I8190 Board Rev 0.4\n"); + break; + case 0x106: + printf("Golden GT-I8190 Board Rev 0.5\n"); + break; + case 0x107: + printf("Golden GT-I8190 Board Rev 0.6\n"); + break; + default: + break; + } + } else if (!strcmp(str, "samsung,skomer")) { + switch(board_id) { + case 0x101: + printf("Skomer GT-S7710 Board Rev 0.0\n"); + break; + case 0x102: + printf("Skomer GT-S7710 Board Rev 0.1\n"); + break; + case 0x103: + printf("Skomer GT-S7710 Board Rev 0.2\n"); + break; + case 0x104: + printf("Skomer GT-S7710 Board Rev 0.3\n"); + break; + case 0x105: + printf("Skomer GT-S7710 Board Rev 0.4\n"); + break; + case 0x106: + printf("Skomer GT-S7710 Board Rev 0.5\n"); + break; + case 0x107: + printf("Skomer GT-S7710 Board Rev 0.6\n"); + break; + case 0x108: + printf("Skomer GT-S7710 Board Rev 0.7\n"); + break; + case 0x109: + printf("Skomer GT-S7710 Board Rev 0.8\n"); + break; + default: + break; + } + skomer_kyle_patch_display(fdt); + } else if (!strcmp(str, "samsung,kyle")) { + switch(board_id) { + case 0x101: + printf("Kyle SGH-I407 Board Rev 0.0\n"); + break; + case 0x102: + printf("Kyle SGH-I407 Board Rev 0.1\n"); + break; + case 0x103: + printf("Kyle SGH-I407 Board Rev 0.2\n"); + break; + case 0x104: + printf("Kyle SGH-I407 Board Rev 0.3\n"); + break; + case 0x105: + printf("Kyle SGH-I407 Board Rev 0.4\n"); + break; + case 0x106: + printf("Kyle SGH-I407 Board Rev 0.5\n"); + break; + case 0x107: + printf("Kyle SGH-I407 Board Rev 0.6\n"); + break; + default: + break; + } + skomer_kyle_patch_display(fdt); + } + + return 0; +} diff --git a/configs/stemmy_defconfig b/configs/stemmy_defconfig index 8e1ff704cf95..d6cce7436cad 100644 --- a/configs/stemmy_defconfig +++ b/configs/stemmy_defconfig @@ -37,3 +37,5 @@ CONFIG_DM_VIDEO=y CONFIG_SYS_WHITE_ON_BLACK=y CONFIG_VIDEO_MCDE_SIMPLE=y # CONFIG_EFI_LOADER is not set +CONFIG_OF_BOARD_SETUP=y +CONFIG_OF_LIBFDT=y