From: Svyatoslav Ryhel Date: Thu, 1 Aug 2024 13:50:41 +0000 (+0300) Subject: board: asus: transformer: implement multi-DTB support X-Git-Url: http://git.dujemihanovic.xyz/%22http:/www.sics.se/static/%7B%7B%20%24style.Permalink%20%7D%7D?a=commitdiff_plain;h=8768ade2b5cd2c39a55832322a0aabf2145fb24d;p=u-boot.git board: asus: transformer: implement multi-DTB support Use board revision detection mechanism to choose correct DTB. Adjust documentation and build setup accordingly. Signed-off-by: Svyatoslav Ryhel --- diff --git a/board/asus/transformer-t30/MAINTAINERS b/board/asus/transformer-t30/MAINTAINERS index 071a9c04b8..869cc5aeb9 100644 --- a/board/asus/transformer-t30/MAINTAINERS +++ b/board/asus/transformer-t30/MAINTAINERS @@ -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 diff --git a/board/asus/transformer-t30/Makefile b/board/asus/transformer-t30/Makefile index c083f2289b..22b6160f75 100644 --- a/board/asus/transformer-t30/Makefile +++ b/board/asus/transformer-t30/Makefile @@ -7,5 +7,6 @@ # Svyatoslav Ryhel 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 index 0000000000..a2b540c90b --- /dev/null +++ b/board/asus/transformer-t30/board-info.c @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2024 + * Svyatoslav Ryhel + */ + +#include +#include + +#include +#include + +/* + * 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 index f378f54570..0000000000 --- a/board/asus/transformer-t30/configs/p1801-t.config +++ /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 index e4fd30378a..0000000000 --- a/board/asus/transformer-t30/configs/tf201.config +++ /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 index 9ad2ebd98e..0000000000 --- a/board/asus/transformer-t30/configs/tf300t.config +++ /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 index 7b44a91acc..0000000000 --- a/board/asus/transformer-t30/configs/tf300tg.config +++ /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 index 81e96d5df6..0000000000 --- a/board/asus/transformer-t30/configs/tf300tl.config +++ /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 index a452a19fe4..0000000000 --- a/board/asus/transformer-t30/configs/tf600t.config +++ /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 index 887c25fbf2..0000000000 --- a/board/asus/transformer-t30/configs/tf700t.config +++ /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 index 7bc2b80c48..0000000000 --- a/board/asus/transformer-t30/tf600t.env +++ /dev/null @@ -1,16 +0,0 @@ -#include - -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 diff --git a/board/asus/transformer-t30/transformer-t30.env b/board/asus/transformer-t30/transformer-t30.env index 2f7e8206c2..9b6f4079f8 100644 --- a/board/asus/transformer-t30/transformer-t30.env +++ b/board/asus/transformer-t30/transformer-t30.env @@ -1,7 +1,7 @@ #include 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} diff --git a/configs/transformer_t30_defconfig b/configs/transformer_t30_defconfig index 11ea7176d8..9102dcc88b 100644 --- a/configs/transformer_t30_defconfig +++ b/configs/transformer_t30_defconfig @@ -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 diff --git a/doc/board/asus/transformer_t30.rst b/doc/board/asus/transformer_t30.rst index ff9792dc0f..bebc4b9fad 100644 --- a/doc/board/asus/transformer_t30.rst +++ b/doc/board/asus/transformer_t30.rst @@ -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``