From patchwork Mon Dec 30 12:04:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 976 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 18ED53F03F for ; Mon, 30 Dec 2019 13:04:26 +0100 (CET) Received: by mail-pj1-f69.google.com with SMTP id s19sf11835863pjp.9 for ; Mon, 30 Dec 2019 04:04:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1577707464; cv=pass; d=google.com; s=arc-20160816; b=NR3J4cecurU6ZT3IfhHABJhTdRF7E1CnGy7aHa6L8TOCzK/51ONQiI4hXbaGWQnJFP dkkjMTOkyoFNxhgpl7CjfR8QRPyAzR4XIVVfNxv6lHigsOQgFdxu9aAj4vuiW8ky+wGb m1NyEaEbN/2h7RoksGtmPz7MbQZY1aKkiukiZgZwdzuEoxxrW7Qj5/onKPmR3PAO5qTC cct7ivB2nV1+GANnhCdbJemfaC3mqUr2Rf5SzkkffAEcN2Ld/71s5vZnFp9LilA0/VO0 h/IWUlpkQQwCzoKKodagSo9asrjSuXw9OZFr4+rE2FOVDL06wm/Z4cR2fmuk7n4vCO06 RY7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=GDTrMJr/4LKUMl1B5V9VIuNxrthgamfPHxNJqlswN+Y=; b=l+lA0Yr3lKdc3nohvXgUkncbhoZzve2MiTWOvDyaXQLsfISFugjQFwS0VKKKiPS3sl YGPbvwv1Xer+SPww0GWI8ksgfP8nZhIkFgIu8ls6ibNn+zPGS1LPGMkdg1yhLlruI6qh /hG8k9Hu6H1d3iqyQSnKHpdbUg7pM6ABLMRE2lUwj8iOLNuIsblC+3o+3mLEI1dii/66 BUDnx6PErgYvRkt4GiUqIqhJR0uHyW8H/em3/J7Iz8AMQFqyTZ4qAo2eI1htSZolrxET T0bLilCNbgPxzm+50a2fycPjCW5pQg6bZDcSw0H9oTiQm39PDUQjX4s0/zn1g9I5i99d mG6g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=LiImp19K; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=GDTrMJr/4LKUMl1B5V9VIuNxrthgamfPHxNJqlswN+Y=; b=XqnEqGANNtJO8sS9GXZx3m6ENW0BRMJnlekQrGI9fmrvP3/kKH1Jm48aNRjW2/eLsV 6Mw1stIlBqo05WJXTBse5nDBaMJd5laxv14y35g67zDy0augbYjj1mF9bWAL9crAPPFd x9vbL0kAXJnoDhlhpw1XEEMge7OcpjtQeDzho= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=GDTrMJr/4LKUMl1B5V9VIuNxrthgamfPHxNJqlswN+Y=; b=adinp8YSfQ3DqLUOZvaaktVNMZocvFpByObbA2LCPQqaYOrM49y2jlvui/5rPK8qu1 iaKfDwrCAssbD8M9daKR/sLWlvQWhbUbo8BidBdN1gWcs8EjX2MTxjstA8NoKZ9DGE38 1nX4NDRx6E/1FPwFzxye1FO5cwreLJfm9ualKzEOsaXGlTzqLIy5gnNghKTdggM3ldhJ tF0cqD4Bdr2h5ISgarrOKrMt6ZHAysXfM5LwMT677Hw60B4i4IE1FX0qvu0rbjZ+2lD8 75NmumfIlNHSi/HZARcNlQRYNcoVuSOEpL7TF/CnCxwij9T526o3Y0ugqll/N2/EHIpy cl/g== X-Gm-Message-State: APjAAAWMCGPl8SpkwASQX3RFfoTEd7aVPEMHGf3Jn93dTczdKAoxX0Hh JOi6za1bLi1IFHAjsUASQ0wJ6YEr X-Google-Smtp-Source: APXvYqynAB9we68kVmctTS3C1fmQy0y9HfBeGrzQ8wVeVnDnrYj2bDYRcSuL/ycjLi1MZHcqOsvagw== X-Received: by 2002:a17:902:ab84:: with SMTP id f4mr70204365plr.35.1577707464388; Mon, 30 Dec 2019 04:04:24 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a62:ab0b:: with SMTP id p11ls9877320pff.0.gmail; Mon, 30 Dec 2019 04:04:24 -0800 (PST) X-Received: by 2002:a63:303:: with SMTP id 3mr71264338pgd.372.1577707463886; Mon, 30 Dec 2019 04:04:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577707463; cv=none; d=google.com; s=arc-20160816; b=A/aukBiMaW7K+g2AFcRcebpXgSdXdTqfxSw0YvDODHr85hxXtFrkMiIPgOFk1QY+z0 DN3W3e9jOAtDQPq6/hw91ivP/d9XvgHUSBasId2zioXSzNgh6+8Ma3cJPAfyAjwcNhq/ lix3Phjr+R/wa+Ebzsx7YmQ+ehIoZVeFXUDqoiGPFIklSSLzCpXAKB4fDzpWx+NXTEdr VDMZwDnGUcMCC5eQKxMdHbmZTBOIjznqpIl47vFFnDBbI4ApRPXfB7RM3r+JzD08TwUI uIZWWsJ0OcytHGMIk4j7prpzBzNTgxcaBU7uwvvOQHDCN6dMoK+PkKrE8YMKH22pbs8h KJ/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=N4AXbwqBTtwQ0ItnN+FKO5sVPh3Kkm//IWDuhuVsEvc=; b=CkdQMoKnxkdGvNkhI70mFClq+z1VYxpqnzAGgaBZaNLS0Uj77O/RkUwRkpYv24d0be BHdqmGuYwL6lonZdZg/TbOw19IXtyt56I/c7nXA4ca/ox0TCCg4iQRRK3eelVl9tzTPq yEWM9fI04+C6jt85vxxtuFvHQ1oJABRuIKIgTbEvlqo5X66i8Qvu/c/4xdsx7DNELxs5 DChFlpmFXRDkrCbAZWUUo0Iou9rElXUo8b0GmcNMR9yjNFIZzMQIJ+pcQjANvbHsHxjN kXX8NVZEu5mkRER0SwOLDBg/ADIsURjLpe6p7uEGK0Zp5Ig4PtirdwEutCNWXomyd2bS 8YdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=LiImp19K; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id d24sor21119923pls.45.2019.12.30.04.04.23 for (Google Transport Security); Mon, 30 Dec 2019 04:04:23 -0800 (PST) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:5ac9:: with SMTP id g9mr54014438plm.69.1577707463569; Mon, 30 Dec 2019 04:04:23 -0800 (PST) Received: from localhost.localdomain ([49.206.202.131]) by smtp.gmail.com with ESMTPSA id n7sm24552620pjq.8.2019.12.30.04.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Dec 2019 04:04:22 -0800 (PST) From: Jagan Teki To: Stefano Babic , Fabio Estevam , uboot-imx@nxp.com Cc: Michael Trimarchi , u-boot@lists.denx.de, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH 1/8] board: engicam: Cleanup fdt file and board mapping Date: Mon, 30 Dec 2019 17:34:02 +0530 Message-Id: <20191230120409.884-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20191230120409.884-1-jagan@amarulasolutions.com> References: <20191230120409.884-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=LiImp19K; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Michael Trimarchi Make easy to map fdt file to board in order to use this information later to apply specific change to specific board combination. Signed-off-by: Michael Trimarchi Signed-off-by: Jagan Teki --- board/engicam/common/board.c | 67 ++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/board/engicam/common/board.c b/board/engicam/common/board.c index e5358b47f3..992d209cbd 100644 --- a/board/engicam/common/board.c +++ b/board/engicam/common/board.c @@ -35,35 +35,76 @@ static void mmc_late_init(void) } #endif -static void setenv_fdt_file(void) +enum engicam_boards { + IMX6Q_ICORE, + IMX6DL_ICORE, + IMX6Q_ICORE_MIPI, + IMX6DL_ICORE_MIPI, + IMX6Q_ICORE_RQS, + IMX6DL_ICORE_RQS, + IMX6UL_GEAM, + IMX6UL_ISIOT_EMMC, + IMX6UL_ISIOT_NAND, + ENGICAM_BOARDS, +}; + +static const char * const board_fdt_file[ENGICAM_BOARDS] = { + [IMX6Q_ICORE] = "imx6q-icore.dtb", + [IMX6DL_ICORE] = "imx6dl-icore.dtb", + [IMX6Q_ICORE_MIPI] = "imx6q-icore-mipi.dtb", + [IMX6DL_ICORE_MIPI] = "imx6dl-icore-mipi.dtb", + [IMX6Q_ICORE_RQS] = "imx6q-icore-rqs.dtb", + [IMX6DL_ICORE_RQS] = "imx6dl-icore-rqs.dtb", + [IMX6UL_GEAM] = "imx6ul-geam.dtb", + [IMX6UL_ISIOT_EMMC] = "imx6ul-isiot-emmc.dtb", + [IMX6UL_ISIOT_NAND] = "imx6ul-isiot-nand.dtb", +}; + +static int setenv_fdt_file(int board_detected) +{ + if (board_detected < 0 || board_detected >= ENGICAM_BOARDS) + return -EINVAL; + + if (!board_fdt_file[board_detected]) + return -ENODEV; + + env_set("fdt_file", board_fdt_file[board_detected]); + return 0; +} + +static enum engicam_boards engicam_board_detect(void) { const char *cmp_dtb = CONFIG_DEFAULT_DEVICE_TREE; if (!strcmp(cmp_dtb, "imx6q-icore")) { if (is_mx6dq()) - env_set("fdt_file", "imx6q-icore.dtb"); + return IMX6Q_ICORE; else if (is_mx6dl() || is_mx6solo()) - env_set("fdt_file", "imx6dl-icore.dtb"); + return IMX6DL_ICORE; } else if (!strcmp(cmp_dtb, "imx6q-icore-mipi")) { if (is_mx6dq()) - env_set("fdt_file", "imx6q-icore-mipi.dtb"); + return IMX6Q_ICORE_MIPI; else if (is_mx6dl() || is_mx6solo()) - env_set("fdt_file", "imx6dl-icore-mipi.dtb"); + return IMX6DL_ICORE_MIPI; } else if (!strcmp(cmp_dtb, "imx6q-icore-rqs")) { if (is_mx6dq()) - env_set("fdt_file", "imx6q-icore-rqs.dtb"); + return IMX6Q_ICORE_RQS; else if (is_mx6dl() || is_mx6solo()) - env_set("fdt_file", "imx6dl-icore-rqs.dtb"); + return IMX6DL_ICORE_RQS; } else if (!strcmp(cmp_dtb, "imx6ul-geam")) - env_set("fdt_file", "imx6ul-geam.dtb"); + return IMX6UL_GEAM; else if (!strcmp(cmp_dtb, "imx6ul-isiot-emmc")) - env_set("fdt_file", "imx6ul-isiot-emmc.dtb"); + return IMX6UL_ISIOT_EMMC; else if (!strcmp(cmp_dtb, "imx6ul-isiot-nand")) - env_set("fdt_file", "imx6ul-isiot-nand.dtb"); + return IMX6UL_ISIOT_NAND; + + return -EINVAL; } int board_late_init(void) { + enum engicam_boards board_detected = IMX6Q_ICORE; + switch ((imx6_src_get_boot_mode() & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) { case IMX6_BMODE_SD: @@ -88,7 +129,11 @@ int board_late_init(void) else env_set("console", "ttymxc3"); - setenv_fdt_file(); + board_detected = engicam_board_detect(); + if (board_detected < 0) + hang(); + + setenv_fdt_file(board_detected); #ifdef CONFIG_HW_WATCHDOG hw_watchdog_init();