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

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
14 files changed:
board/asus/transformer-t30/MAINTAINERS
board/asus/transformer-t30/Makefile
board/asus/transformer-t30/board-info.c [new file with mode: 0644]
board/asus/transformer-t30/configs/p1801-t.config [deleted file]
board/asus/transformer-t30/configs/tf201.config [deleted file]
board/asus/transformer-t30/configs/tf300t.config [deleted file]
board/asus/transformer-t30/configs/tf300tg.config [deleted file]
board/asus/transformer-t30/configs/tf300tl.config [deleted file]
board/asus/transformer-t30/configs/tf600t.config [deleted file]
board/asus/transformer-t30/configs/tf700t.config [deleted file]
board/asus/transformer-t30/tf600t.env [deleted file]
board/asus/transformer-t30/transformer-t30.env
configs/transformer_t30_defconfig
doc/board/asus/transformer_t30.rst

index 071a9c04b86f952e593eb98935618af5fa4b7c61..869cc5aeb91077f837652084342f3fb95a652eb9 100644 (file)
@@ -4,5 +4,4 @@ S:      Maintained
 F:     board/asus/transformer-t30/
 F:     configs/transformer_t30_defconfig
 F:     doc/board/asus/transformer_t30.rst
-F:     include/configs/transformer-common.h
 F:     include/configs/transformer-t30.h
index c083f2289baa661f60e7edfe44e3eee29190f963..22b6160f757662376c6f6c3fedde55159d898804 100644 (file)
@@ -7,5 +7,6 @@
 #  Svyatoslav Ryhel <clamor95@gmail.com>
 
 obj-$(CONFIG_SPL_BUILD) += transformer-t30-spl.o
+obj-$(CONFIG_MULTI_DTB_FIT) += board-info.o
 
 obj-y += transformer-t30.o
diff --git a/board/asus/transformer-t30/board-info.c b/board/asus/transformer-t30/board-info.c
new file mode 100644 (file)
index 0000000..a2b540c
--- /dev/null
@@ -0,0 +1,110 @@
+// 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>
+
+/*
+ *     PCB_ID[1] is kb_row5_pr5
+ *     PCB_ID[3] is kb_col7_pq7
+ *     PCB_ID[4] is kb_row2_pr2
+ *     PCB_ID[5] is kb_col5_pq5
+ *
+ *                       Project ID
+ *     =====================================================
+ *     PCB_ID[1] PCB_ID[5] PCB_ID[4] PCB_ID[3] Project
+ *     0         0         0         0         TF201
+ *     0         0         0         1         P1801
+ *     0         0         1         0         TF300T
+ *     0         0         1         1         TF300TG
+ *     0         1         0         0         TF700T
+ *     0         1         0         1         TF300TL
+ *     0         1         1         0         Extension
+ *     0         1         1         1         TF500T
+ *     1         0         0         0         TF502T/TF600T
+ *     =====================================================
+ */
+enum project_rev {
+       TF201, P1801, TF300T, TF300TG, TF700T,
+       TF300TL, EXT, TF500T, TF600T
+};
+
+static const char * const project_id_to_fdt[] = {
+       [TF201] = "tegra30-asus-tf201",
+       [P1801] = "tegra30-asus-p1801-t",
+       [TF300T] = "tegra30-asus-tf300t",
+       [TF300TG] = "tegra30-asus-tf300tg",
+       [TF700T] = "tegra30-asus-tf700t",
+       [TF300TL] = "tegra30-asus-tf300tl",
+       [TF600T] = "tegra30-asus-tf600t",
+};
+
+static int id_gpio_get_value(u32 pingrp, u32 pin)
+{
+       /* Configure pinmux */
+       pinmux_set_func(pingrp, PMUX_FUNC_KBC);
+       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 pcb_id1, pcb_id3, pcb_id4, pcb_id5;
+
+       pcb_id1 = id_gpio_get_value(PMUX_PINGRP_KB_ROW5_PR5,
+                                   TEGRA_GPIO(R, 5));
+       pcb_id3 = id_gpio_get_value(PMUX_PINGRP_KB_COL7_PQ7,
+                                   TEGRA_GPIO(Q, 7));
+       pcb_id4 = id_gpio_get_value(PMUX_PINGRP_KB_ROW2_PR2,
+                                   TEGRA_GPIO(R, 2));
+       pcb_id5 = id_gpio_get_value(PMUX_PINGRP_KB_COL5_PQ5,
+                                   TEGRA_GPIO(Q, 5));
+
+       /* Construct board ID */
+       int proj_id = pcb_id1 << 3 | pcb_id5 << 2 |
+                     pcb_id4 << 1 | pcb_id3;
+
+       log_debug("[TRANSFORMER]: project id %d (%s)\n", proj_id,
+                 project_id_to_fdt[proj_id]);
+
+       /* Mark tablet with SPI flash */
+       if (proj_id == TF600T)
+               env_set_hex("spiflash", true);
+       else
+               env_set_hex("spiflash", false);
+
+       return proj_id & 0xf;
+}
+
+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/transformer-t30/configs/p1801-t.config b/board/asus/transformer-t30/configs/p1801-t.config
deleted file mode 100644 (file)
index f378f54..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_DEFAULT_DEVICE_TREE="tegra30-asus-p1801-t"
-# CONFIG_I2C_MUX is not set
-CONFIG_USB_GADGET_PRODUCT_NUM=0x4cb0
diff --git a/board/asus/transformer-t30/configs/tf201.config b/board/asus/transformer-t30/configs/tf201.config
deleted file mode 100644 (file)
index e4fd303..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_DEFAULT_DEVICE_TREE="tegra30-asus-tf201"
-# CONFIG_I2C_MUX is not set
-CONFIG_USB_GADGET_PRODUCT_NUM=0x4d00
diff --git a/board/asus/transformer-t30/configs/tf300t.config b/board/asus/transformer-t30/configs/tf300t.config
deleted file mode 100644 (file)
index 9ad2ebd..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_DEFAULT_DEVICE_TREE="tegra30-asus-tf300t"
-# CONFIG_I2C_MUX is not set
-CONFIG_USB_GADGET_PRODUCT_NUM=0x4d00
diff --git a/board/asus/transformer-t30/configs/tf300tg.config b/board/asus/transformer-t30/configs/tf300tg.config
deleted file mode 100644 (file)
index 7b44a91..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_DEFAULT_DEVICE_TREE="tegra30-asus-tf300tg"
-# CONFIG_I2C_MUX is not set
-CONFIG_USB_GADGET_PRODUCT_NUM=0x4c80
diff --git a/board/asus/transformer-t30/configs/tf300tl.config b/board/asus/transformer-t30/configs/tf300tl.config
deleted file mode 100644 (file)
index 81e96d5..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_DEFAULT_DEVICE_TREE="tegra30-asus-tf300tl"
-# CONFIG_I2C_MUX is not set
-CONFIG_USB_GADGET_PRODUCT_NUM=0x4d00
diff --git a/board/asus/transformer-t30/configs/tf600t.config b/board/asus/transformer-t30/configs/tf600t.config
deleted file mode 100644 (file)
index a452a19..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG_ENV_SOURCE_FILE="tf600t"
-CONFIG_DEFAULT_DEVICE_TREE="tegra30-asus-tf600t"
-CONFIG_BOOTCOMMAND="setenv gpio_button 222; if run check_button; then poweroff; fi; setenv gpio_button 132; if run check_button; then echo Starting SPI flash update ...; run update_spi; fi; run bootcmd_usb0; run bootcmd_mmc1; run bootcmd_mmc0; poweroff;"
-# CONFIG_I2C_MUX is not set
-CONFIG_TEGRA20_SLINK=y
-CONFIG_SPI_FLASH_WINBOND=y
-CONFIG_USB_GADGET_PRODUCT_NUM=0x4d00
diff --git a/board/asus/transformer-t30/configs/tf700t.config b/board/asus/transformer-t30/configs/tf700t.config
deleted file mode 100644 (file)
index 887c25f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_DEFAULT_DEVICE_TREE="tegra30-asus-tf700t"
-CONFIG_CLK_GPIO=y
-CONFIG_USB_GADGET_PRODUCT_NUM=0x4c90
-CONFIG_VIDEO_BRIDGE_TOSHIBA_TC358768=y
diff --git a/board/asus/transformer-t30/tf600t.env b/board/asus/transformer-t30/tf600t.env
deleted file mode 100644 (file)
index 7bc2b80..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <env/nvidia/prod_upd.env>
-
-button_cmd_0_name=Volume Down
-button_cmd_0=bootmenu
-button_cmd_1_name=Lid sensor
-button_cmd_1=poweroff
-partitions=name=emmc,start=0,size=-,uuid=${uuid_gpt_rootfs}
-
-bootmenu_0=mount internal storage=usb start && ums 0 mmc 0; bootmenu
-bootmenu_1=mount external storage=usb start && ums 0 mmc 1; bootmenu
-bootmenu_2=fastboot=echo Starting Fastboot protocol ...; fastboot usb 0; bootmenu
-bootmenu_3=update bootloader=run update_spi
-bootmenu_4=reboot RCM=enterrcm
-bootmenu_5=reboot=reset
-bootmenu_6=power off=poweroff
-bootmenu_delay=-1
index 2f7e8206c24be4c05320933c1de9bc4303dfef97..9b6f4079f84c8b7ada2eea34b41730feb2839640 100644 (file)
@@ -1,7 +1,7 @@
 #include <env/nvidia/prod_upd.env>
 
 button_cmd_0_name=Volume Down
-button_cmd_0=bootmenu
+button_cmd_0=if spiflash; then run update_spi; else bootmenu; fi
 button_cmd_1_name=Lid sensor
 button_cmd_1=poweroff
 partitions=name=emmc,start=0,size=-,uuid=${uuid_gpt_rootfs}
index 11ea7176d8023fe2a5894d3d589635e91b903171..9102dcc88b2f2b02bf4e4739dd8a0f0e86959a1a 100644 (file)
@@ -50,10 +50,14 @@ 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-p1801-t tegra30-asus-tf201 tegra30-asus-tf300t tegra30-asus-tf300tg tegra30-asus-tf300tl tegra30-asus-tf600t tegra30-asus-tf700t"
+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
 CONFIG_BUTTON=y
+CONFIG_CLK_GPIO=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x91000000
 CONFIG_FASTBOOT_BUF_SIZE=0x10000000
@@ -65,6 +69,7 @@ CONFIG_SYS_I2C_TEGRA=y
 CONFIG_I2C_MUX=y
 CONFIG_I2C_MUX_GPIO=y
 CONFIG_BUTTON_KEYBOARD=y
+CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_DM_PMIC=y
 CONFIG_DM_PMIC_TPS65910=y
 CONFIG_DM_REGULATOR=y
@@ -72,6 +77,7 @@ CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_TPS65911=y
 CONFIG_PWM_TEGRA=y
 CONFIG_SYS_NS16550=y
+CONFIG_TEGRA20_SLINK=y
 CONFIG_SYSRESET_TPS65910=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
@@ -80,7 +86,9 @@ CONFIG_USB_KEYBOARD=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="ASUS"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0b05
+CONFIG_USB_GADGET_PRODUCT_NUM=0x4daf
 CONFIG_CI_UDC=y
 CONFIG_VIDEO=y
 # CONFIG_VIDEO_LOGO is not set
+CONFIG_VIDEO_BRIDGE_TOSHIBA_TC358768=y
 CONFIG_VIDEO_TEGRA20=y
index ff9792dc0fc5dc7fba8c0f6122b5d365b7dd3174..bebc4b9fad31afbcc35cce2e4b4b993bb5d1f796 100644 (file)
@@ -20,15 +20,18 @@ Quick Start
 Build U-Boot
 ------------
 
-Device support is implemented by applying a config fragment to a generic board
-defconfig. Valid fragments are ``tf201.config``, ``tf300t.config``,
-``tf300tg.config``, ``tf300tl.config``, ``tf700t.config``, ``tf600t.config`` and
-``p1801-t.config``.
+U-Boot features ability to detect transformer device model on which it is
+loaded. The list of supported devices include:
+- ASUS Transformer Prime TF201
+- ASUS Transformer Pad (3G/LTE) TF300T/TG/TL
+- ASUS Transformer Infinity TF700T
+- ASUS Portable AiO P1801-T
+- ASUS VivoTab RT TF600T
 
 .. code-block:: bash
 
     $ export CROSS_COMPILE=arm-linux-gnueabi-
-    $ make transformer_t30_defconfig tf201.config # For TF201
+    $ make transformer_t30_defconfig
     $ make
 
 After the build succeeds, you will obtain the final ``u-boot-dtb-tegra.bin``