blob: dcdda1ec5b49bb5cf208f22e9684fdcb2dbcac62 [file] [log] [blame]
Svyatoslav Ryhel7a25c382023-06-30 10:29:03 +03001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (c) 2022, Svyatoslav Ryhel <clamor95@gmail.com>.
4 */
5
6#ifndef __TRANSFORMER_COMMON_H
7#define __TRANSFORMER_COMMON_H
8
9/* High-level configuration options */
10#define CFG_TEGRA_BOARD_STRING "ASUS Transformer"
11
12#define TRANSFORMER_FLASH_UBOOT \
13 "flash_uboot=echo Preparing RAM;" \
14 "mw ${kernel_addr_r} 0 ${boot_block_size_r};" \
15 "mw ${ramdisk_addr_r} 0 ${boot_block_size_r};" \
16 "echo Reading BCT;" \
17 "mmc dev 0 1;" \
18 "mmc read ${kernel_addr_r} 0 ${boot_block_size};" \
19 "echo Reading bootloader;" \
20 "if load mmc 1:1 ${ramdisk_addr_r} ${bootloader_file};" \
21 "then echo Calculating bootloader size;" \
22 "size mmc 1:1 ${bootloader_file};" \
23 "ebtupdate ${kernel_addr_r} ${ramdisk_addr_r} ${filesize};" \
24 "echo Writing bootloader to eMMC;" \
25 "mmc dev 0 1;" \
26 "mmc write ${kernel_addr_r} 0 ${boot_block_size};" \
27 "mmc dev 0 2;" \
28 "mmc write ${ramdisk_addr_r} 0 ${boot_block_size};" \
29 "echo Bootloader written successfully;" \
30 "pause 'Press ANY key to reboot device...'; reset;" \
31 "else echo Reading bootloader failed;" \
32 "pause 'Press ANY key to return to bootmenu...'; bootmenu; fi\0"
33
34#define TRANSFORMER_FLASH_SPI \
35 "update_spi=sf probe 0:1;" \
36 "echo Dumping current SPI flash content ...;" \
37 "sf read ${kernel_addr_r} 0x0 ${spi_size};" \
38 "if fatwrite mmc 1:1 ${kernel_addr_r} spi-flash-backup.bin ${spi_size};" \
39 "then echo SPI flash content was successfully written into spi-flash-backup.bin;" \
40 "echo Reading SPI flash binary;" \
41 "if load mmc 1:1 ${kernel_addr_r} repart-block.bin;" \
42 "then echo Writing bootloader into SPI flash;" \
43 "sf probe 0:1;" \
44 "sf update ${kernel_addr_r} 0x0 ${spi_size};" \
45 "poweroff;" \
46 "else echo Preparing RAM;" \
47 "mw ${kernel_addr_r} 0 ${boot_block_size_r};" \
48 "mw ${ramdisk_addr_r} 0 ${boot_block_size_r};" \
49 "echo Reading BCT;" \
50 "sf read ${kernel_addr_r} 0x0 ${boot_block_size_r};" \
51 "echo Reading bootloader;" \
52 "if load mmc 1:1 ${ramdisk_addr_r} ${bootloader_file};" \
53 "then echo Calculating bootloader size;" \
54 "size mmc 1:1 ${bootloader_file};" \
55 "ebtupdate ${kernel_addr_r} ${ramdisk_addr_r} ${filesize};" \
56 "echo Writing bootloader into SPI flash;" \
57 "sf probe 0:1;" \
58 "sf update ${kernel_addr_r} 0x0 ${boot_block_size_r};" \
59 "sf update ${ramdisk_addr_r} ${boot_block_size_r} ${boot_block_size_r};" \
60 "echo Bootloader written successfully; poweroff;" \
61 "else echo Reading bootloader failed;" \
62 "poweroff; fi;" \
63 "fi;" \
64 "else echo SPI flash backup FAILED! Aborting ...;" \
65 "poweroff; fi\0"
66
67#define TRANSFORMER_REFRESH_USB \
68 "refresh_usb=usb start; usb reset; usb tree; usb info;" \
69 "pause 'Press ANY key to return to bootmenu...'; bootmenu\0"
70
71#define TRANSFORMER_BOOTMENU \
72 TRANSFORMER_FLASH_UBOOT \
73 TRANSFORMER_FLASH_SPI \
74 TRANSFORMER_REFRESH_USB \
75 "bootmenu_0=mount internal storage=usb start && ums 0 mmc 0; bootmenu\0" \
76 "bootmenu_1=mount external storage=usb start && ums 0 mmc 1; bootmenu\0" \
77 "bootmenu_2=fastboot=echo Starting Fastboot protocol ...; fastboot usb 0; bootmenu\0" \
78 "bootmenu_3=update bootloader=run flash_uboot\0" \
79 "bootmenu_4=refresh USB=run refresh_usb\0" \
80 "bootmenu_5=reboot RCM=enterrcm\0" \
81 "bootmenu_6=reboot=reset\0" \
82 "bootmenu_7=power off=poweroff\0" \
83 "bootmenu_delay=-1\0"
84
85#define BOARD_EXTRA_ENV_SETTINGS \
86 "spi_size=0x400000\0" \
87 "boot_block_size_r=0x200000\0" \
88 "boot_block_size=0x1000\0" \
89 "check_button=gpio input ${gpio_button}; test $? -eq 0;\0" \
90 "bootloader_file=u-boot-dtb-tegra.bin\0" \
91 "partitions=name=emmc,start=0,size=-,uuid=${uuid_gpt_rootfs}\0" \
92 TRANSFORMER_BOOTMENU
93
94#endif /* __CONFIG_H */