]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
board: asus: grouper: implement multi-DTB support
authorSvyatoslav Ryhel <clamor95@gmail.com>
Thu, 1 Aug 2024 13:42:24 +0000 (16:42 +0300)
committerSvyatoslav Ryhel <clamor95@gmail.com>
Sun, 13 Oct 2024 14:20:26 +0000 (17:20 +0300)
Use board revision detection mechanism to choose correct DTB.
Adjust documentation and build setup accordingly.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
board/asus/grouper/MAINTAINERS
board/asus/grouper/Makefile
board/asus/grouper/board-info.c [new file with mode: 0644]
board/asus/grouper/configs/grouper_E1565.config [deleted file]
board/asus/grouper/configs/grouper_PM269.config [deleted file]
board/asus/grouper/configs/tilapia.config [deleted file]
configs/grouper_defconfig [moved from configs/grouper_common_defconfig with 85% similarity]
doc/board/asus/grouper.rst [moved from doc/board/asus/grouper_common.rst with 93% similarity]
doc/board/asus/index.rst

index f4068d85623588a9fbf9e772a2ed62865c560769..3c59632451ffe9cce2e83c3839ea75c99ed14656 100644 (file)
@@ -2,6 +2,6 @@ GROUPER BOARD
 M:     Svyatoslav Ryhel <clamor95@gmail.com>
 S:     Maintained
 F:     board/asus/grouper/
-F:     configs/grouper_common_defconfig
-F:     doc/board/asus/grouper_common.rst
+F:     configs/grouper_defconfig
+F:     doc/board/asus/grouper.rst
 F:     include/configs/grouper.h
index c0e84c231fb3734a5a65040fc6fc9d65ffbb15a3..8a8e6530c861941f9864514d1eb1d68b1ebc2b13 100644 (file)
@@ -7,5 +7,6 @@
 #  Svyatoslav Ryhel <clamor95@gmail.com>
 
 obj-$(CONFIG_SPL_BUILD) += grouper-spl.o
+obj-$(CONFIG_MULTI_DTB_FIT) += board-info.o
 
 obj-y += grouper.o
diff --git a/board/asus/grouper/board-info.c b/board/asus/grouper/board-info.c
new file mode 100644 (file)
index 0000000..4892acc
--- /dev/null
@@ -0,0 +1,84 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ *  (C) Copyright 2024
+ *  Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <env.h>
+#include <spl_gpio.h>
+
+#include <asm/gpio.h>
+#include <asm/arch/pinmux.h>
+
+/*
+ *     PMIC_ID is GMI_CS2_N_PK3
+ *     MODEM_ID is GMI_CS4_N_PK2
+ *
+ *             Extended Project ID
+ *     ====================================
+ *     MODEM_ID  PMIC_ID       project name
+ *     0         0             grouper-E1565
+ *     0         1             grouper-PM269
+ *     1         0             tilapia
+ */
+enum project_rev {
+       E1565, PM269, TILAPIA, COUNT,
+};
+
+static const char * const project_id_to_fdt[] = {
+       [E1565] = "tegra30-asus-nexus7-grouper-E1565",
+       [PM269] = "tegra30-asus-nexus7-grouper-PM269",
+       [TILAPIA] = "tegra30-asus-nexus7-tilapia-E1565",
+};
+
+static int id_gpio_get_value(u32 pingrp, u32 pin)
+{
+       /* Configure pinmux */
+       pinmux_set_func(pingrp, PMUX_FUNC_GMI);
+       pinmux_set_pullupdown(pingrp, PMUX_PULL_DOWN);
+       pinmux_tristate_enable(pingrp);
+       pinmux_set_io(pingrp, PMUX_PIN_INPUT);
+
+       /*
+        * Since this function may be called
+        * during DM reload we should use SPL
+        * GPIO functions which do not depend
+        * on DM.
+        */
+       spl_gpio_input(NULL, pin);
+       return spl_gpio_get_value(NULL, pin);
+}
+
+static int get_project_id(void)
+{
+       u32 pmic_id, modem_id, proj_id;
+
+       modem_id = id_gpio_get_value(PMUX_PINGRP_GMI_CS4_N_PK2,
+                                    TEGRA_GPIO(K, 2));
+       pmic_id = id_gpio_get_value(PMUX_PINGRP_GMI_CS2_N_PK3,
+                                   TEGRA_GPIO(K, 3));
+
+       proj_id = (modem_id << 1 | pmic_id) & COUNT;
+
+       log_debug("[GROUPER]: project id %d (%s)\n", proj_id,
+                 project_id_to_fdt[proj_id]);
+
+       return proj_id;
+}
+
+int board_fit_config_name_match(const char *name)
+{
+       if (!strcmp(name, project_id_to_fdt[get_project_id()]))
+               return 0;
+
+       return -1;
+}
+
+void nvidia_board_late_init(void)
+{
+       char dt_path[64] = { 0 };
+
+       snprintf(dt_path, sizeof(dt_path), "%s.dtb",
+                project_id_to_fdt[get_project_id()]);
+       env_set("fdtfile", dt_path);
+}
diff --git a/board/asus/grouper/configs/grouper_E1565.config b/board/asus/grouper/configs/grouper_E1565.config
deleted file mode 100644 (file)
index 265295c..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-CONFIG_DEFAULT_DEVICE_TREE="tegra30-asus-nexus7-grouper-E1565"
-CONFIG_CMD_POWEROFF=y
-# CONFIG_MAX77663_GPIO is not set
-CONFIG_DM_PMIC_MAX77663=y
-CONFIG_DM_REGULATOR_MAX77663=y
-CONFIG_SYSRESET_MAX77663=y
diff --git a/board/asus/grouper/configs/grouper_PM269.config b/board/asus/grouper/configs/grouper_PM269.config
deleted file mode 100644 (file)
index a7ee358..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-CONFIG_DEFAULT_DEVICE_TREE="tegra30-asus-nexus7-grouper-PM269"
-CONFIG_CMD_POWEROFF=y
-CONFIG_DM_PMIC_TPS65910=y
-# CONFIG_DM_REGULATOR_TPS65910 is not set
-CONFIG_DM_REGULATOR_TPS65911=y
-CONFIG_SYSRESET_TPS65910=y
diff --git a/board/asus/grouper/configs/tilapia.config b/board/asus/grouper/configs/tilapia.config
deleted file mode 100644 (file)
index d461b47..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG_DEFAULT_DEVICE_TREE="tegra30-asus-nexus7-tilapia-E1565"
-CONFIG_SYS_PROMPT="Tegra30 (Tilapia) # "
-CONFIG_CMD_POWEROFF=y
-# CONFIG_MAX77663_GPIO is not set
-CONFIG_DM_PMIC_MAX77663=y
-CONFIG_DM_REGULATOR_MAX77663=y
-CONFIG_SYSRESET_MAX77663=y
similarity index 85%
rename from configs/grouper_common_defconfig
rename to configs/grouper_defconfig
index a7b7209c6a5c0e3680fd3ae954053bd6bcd4f851..d07d74025d0733cc5acf60cbbf61b072f72dbcb4 100644 (file)
@@ -39,6 +39,7 @@ CONFIG_CMD_GPT=y
 CONFIG_CMD_GPT_RENAME=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_POWEROFF=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_UMS_ABORT_KEYED=y
@@ -48,6 +49,9 @@ CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_OF_LIST="tegra30-asus-nexus7-grouper-E1565 tegra30-asus-nexus7-grouper-PM269 tegra30-asus-nexus7-tilapia-E1565"
+CONFIG_DTB_RESELECT=y
+CONFIG_MULTI_DTB_FIT=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_SYS_MMC_ENV_PART=2
@@ -62,10 +66,16 @@ CONFIG_GPIO_HOG=y
 CONFIG_SYS_I2C_TEGRA=y
 CONFIG_BUTTON_KEYBOARD=y
 CONFIG_DM_PMIC=y
+CONFIG_DM_PMIC_MAX77663=y
+CONFIG_DM_PMIC_TPS65910=y
 CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_MAX77663=y
 CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_DM_REGULATOR_TPS65911=y
 CONFIG_PWM_TEGRA=y
 CONFIG_SYS_NS16550=y
+CONFIG_SYSRESET_MAX77663=y
+CONFIG_SYSRESET_TPS65910=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_TEGRA=y
similarity index 93%
rename from doc/board/asus/grouper_common.rst
rename to doc/board/asus/grouper.rst
index 47a854e916379b925a3bc092f5800897790c04ff..d56a9ca3921ca0b74ce6b94c696cfdd094c4f2ce 100644 (file)
@@ -19,14 +19,14 @@ Quick Start
 Build U-Boot
 ------------
 
-Device support is implemented by applying config fragment to a generic board
-defconfig. Valid fragments are ``tilapia.config``, ``grouper_E1565.config``
-and ``grouper_PM269.config``.
+U-Boot features ability to detect grouper board revision on which it is
+loaded. Currently are supported both TI and MAXIM based WiFi-only models
+along with cellular one.
 
 .. code-block:: bash
 
     $ export CROSS_COMPILE=arm-linux-gnueabi-
-    $ make grouper_common_defconfig grouper_E1565.config # For maxim based grouper
+    $ make grouper_defconfig # For all grouper versions and tilapia
     $ make
 
 After the build succeeds, you will obtain the final ``u-boot-dtb-tegra.bin``
index 2b103287905d1fc8b1bfbccef6b461212fe5d4c9..2cac04ce04aacf46b88fef3c3843c8d420f7aea7 100644 (file)
@@ -6,6 +6,6 @@ ASUS
 .. toctree::
    :maxdepth: 2
 
-   grouper_common
+   grouper
    transformer_t20
    transformer_t30