mirror of
				https://github.com/smaeul/u-boot.git
				synced 2025-11-03 21:48:15 +00:00 
			
		
		
		
	Merge branch '2024-02-13-assorted-updates'
- Add the button command patch, update MAINTAINERS entry for a platform, fix a problem with the hash command, fix a problem on K3 platforms and revert a change on verdin-am62.
This commit is contained in:
		
						commit
						0b66c54a97
					
				@ -1,6 +1,7 @@
 | 
				
			|||||||
Poplar BOARD
 | 
					Poplar BOARD
 | 
				
			||||||
M:     Jorge Ramirez-Ortiz <jorge.ramirez.ortiz@gmail.com>
 | 
					M:     Jorge Ramirez-Ortiz <jorge.ramirez.ortiz@gmail.com>
 | 
				
			||||||
M:     Shawn Guo <shawn.guo@linaro.org>
 | 
					M:     Shawn Guo <shawn.guo@linaro.org>
 | 
				
			||||||
 | 
					M:     Igor Opaniuk <igor.opaniuk@gmail.com>
 | 
				
			||||||
S:     Maintained
 | 
					S:     Maintained
 | 
				
			||||||
F:     board/hisilicon/poplar
 | 
					F:     board/hisilicon/poplar
 | 
				
			||||||
F:     doc/board/hisilicon/poplar.rst
 | 
					F:     doc/board/hisilicon/poplar.rst
 | 
				
			||||||
 | 
				
			|||||||
@ -14,13 +14,10 @@
 | 
				
			|||||||
#include <fdt_support.h>
 | 
					#include <fdt_support.h>
 | 
				
			||||||
#include <init.h>
 | 
					#include <init.h>
 | 
				
			||||||
#include <k3-ddrss.h>
 | 
					#include <k3-ddrss.h>
 | 
				
			||||||
#include <power/regulator.h>
 | 
					 | 
				
			||||||
#include <spl.h>
 | 
					#include <spl.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "../common/tdx-cfg-block.h"
 | 
					#include "../common/tdx-cfg-block.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define VDD_CORE_REG "buck1"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
DECLARE_GLOBAL_DATA_PTR;
 | 
					DECLARE_GLOBAL_DATA_PTR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int board_init(void)
 | 
					int board_init(void)
 | 
				
			||||||
@ -53,37 +50,9 @@ int board_fit_config_name_match(const char *name)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static u32 get_vdd_core_nominal(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int core_uvolt;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	switch (k3_get_speed_grade()) {
 | 
					 | 
				
			||||||
	case 'G':
 | 
					 | 
				
			||||||
	case 'K':
 | 
					 | 
				
			||||||
	case 'S':
 | 
					 | 
				
			||||||
		core_uvolt = 750000;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case 'T':
 | 
					 | 
				
			||||||
	default:
 | 
					 | 
				
			||||||
		core_uvolt = 850000;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return core_uvolt;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if IS_ENABLED(CONFIG_OF_LIBFDT) && IS_ENABLED(CONFIG_OF_BOARD_SETUP)
 | 
					#if IS_ENABLED(CONFIG_OF_LIBFDT) && IS_ENABLED(CONFIG_OF_BOARD_SETUP)
 | 
				
			||||||
int ft_board_setup(void *blob, struct bd_info *bd)
 | 
					int ft_board_setup(void *blob, struct bd_info *bd)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int core_uvolt;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	core_uvolt = get_vdd_core_nominal();
 | 
					 | 
				
			||||||
	if (core_uvolt != 850000) {
 | 
					 | 
				
			||||||
		do_fixup_by_path_u32(blob, "/bus@f0000/i2c@20000000/pmic@30/regulators/buck1",
 | 
					 | 
				
			||||||
				     "regulator-max-microvolt", core_uvolt, 0);
 | 
					 | 
				
			||||||
		do_fixup_by_path_u32(blob, "/bus@f0000/i2c@20000000/pmic@30/regulators/buck1",
 | 
					 | 
				
			||||||
				     "regulator-min-microvolt", core_uvolt, 0);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ft_common_board_setup(blob, bd);
 | 
						return ft_common_board_setup(blob, bd);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@ -118,22 +87,6 @@ static void select_dt_from_module_version(void)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
int board_late_init(void)
 | 
					int board_late_init(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int ret;
 | 
					 | 
				
			||||||
	int core_uvolt;
 | 
					 | 
				
			||||||
	struct udevice *dev = NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	core_uvolt = get_vdd_core_nominal();
 | 
					 | 
				
			||||||
	if (core_uvolt != 850000) {
 | 
					 | 
				
			||||||
		/* Set CPU core voltage to 0.75V for slower speed grades */
 | 
					 | 
				
			||||||
		ret = regulator_get_by_devname(VDD_CORE_REG, &dev);
 | 
					 | 
				
			||||||
		if (ret)
 | 
					 | 
				
			||||||
			pr_err("VDD CORE Regulator get error: %d\n", ret);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		ret = regulator_set_value_force(dev, core_uvolt);
 | 
					 | 
				
			||||||
		if (ret)
 | 
					 | 
				
			||||||
			pr_err("VDD CORE Regulator value setting error: %d\n", ret);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	select_dt_from_module_version();
 | 
						select_dt_from_module_version();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										15
									
								
								boot/Kconfig
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								boot/Kconfig
									
									
									
									
									
								
							@ -20,6 +20,21 @@ config TIMESTAMP
 | 
				
			|||||||
	  loaded that does not, the message 'Wrong FIT format: no timestamp'
 | 
						  loaded that does not, the message 'Wrong FIT format: no timestamp'
 | 
				
			||||||
	  is shown.
 | 
						  is shown.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					config BUTTON_CMD
 | 
				
			||||||
 | 
						bool "Support for running a command if a button is held during boot"
 | 
				
			||||||
 | 
						depends on CMDLINE
 | 
				
			||||||
 | 
						depends on BUTTON
 | 
				
			||||||
 | 
						help
 | 
				
			||||||
 | 
						  For many embedded devices it's useful to enter a special flashing mode
 | 
				
			||||||
 | 
						  such as fastboot mode when a button is held during boot. This option
 | 
				
			||||||
 | 
						  allows arbitrary commands to be assigned to specific buttons. These will
 | 
				
			||||||
 | 
						  be run after "preboot" if the button is held. Configuration is done via
 | 
				
			||||||
 | 
						  the environment variables "button_cmd_N_name" and "button_cmd_N" where n is
 | 
				
			||||||
 | 
						  the button number (starting from 0). e.g:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						    "button_cmd_0_name=vol_down"
 | 
				
			||||||
 | 
						    "button_cmd_0=fastboot usb 0"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
menuconfig FIT
 | 
					menuconfig FIT
 | 
				
			||||||
	bool "Flattened Image Tree (FIT)"
 | 
						bool "Flattened Image Tree (FIT)"
 | 
				
			||||||
	select HASH
 | 
						select HASH
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										19
									
								
								cmd/hash.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								cmd/hash.c
									
									
									
									
									
								
							@ -14,15 +14,22 @@
 | 
				
			|||||||
#include <hash.h>
 | 
					#include <hash.h>
 | 
				
			||||||
#include <linux/ctype.h>
 | 
					#include <linux/ctype.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if IS_ENABLED(CONFIG_HASH_VERIFY)
 | 
				
			||||||
 | 
					#define HARGS 6
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					#define HARGS 5
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int do_hash(struct cmd_tbl *cmdtp, int flag, int argc,
 | 
					static int do_hash(struct cmd_tbl *cmdtp, int flag, int argc,
 | 
				
			||||||
		   char *const argv[])
 | 
							   char *const argv[])
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char *s;
 | 
						char *s;
 | 
				
			||||||
	int flags = HASH_FLAG_ENV;
 | 
						int flags = HASH_FLAG_ENV;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_HASH_VERIFY
 | 
						if (argc < (HARGS - 1))
 | 
				
			||||||
	if (argc < 4)
 | 
					 | 
				
			||||||
		return CMD_RET_USAGE;
 | 
							return CMD_RET_USAGE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if IS_ENABLED(CONFIG_HASH_VERIFY)
 | 
				
			||||||
	if (!strcmp(argv[1], "-v")) {
 | 
						if (!strcmp(argv[1], "-v")) {
 | 
				
			||||||
		flags |= HASH_FLAG_VERIFY;
 | 
							flags |= HASH_FLAG_VERIFY;
 | 
				
			||||||
		argc--;
 | 
							argc--;
 | 
				
			||||||
@ -37,18 +44,12 @@ static int do_hash(struct cmd_tbl *cmdtp, int flag, int argc,
 | 
				
			|||||||
	return hash_command(*argv, flags, cmdtp, flag, argc - 1, argv + 1);
 | 
						return hash_command(*argv, flags, cmdtp, flag, argc - 1, argv + 1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_HASH_VERIFY
 | 
					 | 
				
			||||||
#define HARGS 6
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
#define HARGS 5
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
U_BOOT_CMD(
 | 
					U_BOOT_CMD(
 | 
				
			||||||
	hash,	HARGS,	1,	do_hash,
 | 
						hash,	HARGS,	1,	do_hash,
 | 
				
			||||||
	"compute hash message digest",
 | 
						"compute hash message digest",
 | 
				
			||||||
	"algorithm address count [[*]hash_dest]\n"
 | 
						"algorithm address count [[*]hash_dest]\n"
 | 
				
			||||||
		"    - compute message digest [save to env var / *address]"
 | 
							"    - compute message digest [save to env var / *address]"
 | 
				
			||||||
#ifdef CONFIG_HASH_VERIFY
 | 
					#if IS_ENABLED(CONFIG_HASH_VERIFY)
 | 
				
			||||||
	"\nhash -v algorithm address count [*]hash\n"
 | 
						"\nhash -v algorithm address count [*]hash\n"
 | 
				
			||||||
		"    - verify message digest of memory area to immediate value, \n"
 | 
							"    - verify message digest of memory area to immediate value, \n"
 | 
				
			||||||
		"      env var or *address"
 | 
							"      env var or *address"
 | 
				
			||||||
 | 
				
			|||||||
@ -12,6 +12,7 @@ obj-y += cli_getch.o cli_simple.o cli_readline.o
 | 
				
			|||||||
obj-$(CONFIG_HUSH_OLD_PARSER) += cli_hush.o
 | 
					obj-$(CONFIG_HUSH_OLD_PARSER) += cli_hush.o
 | 
				
			||||||
obj-$(CONFIG_HUSH_MODERN_PARSER) += cli_hush_modern.o
 | 
					obj-$(CONFIG_HUSH_MODERN_PARSER) += cli_hush_modern.o
 | 
				
			||||||
obj-$(CONFIG_AUTOBOOT) += autoboot.o
 | 
					obj-$(CONFIG_AUTOBOOT) += autoboot.o
 | 
				
			||||||
 | 
					obj-$(CONFIG_BUTTON_CMD) += button_cmd.o
 | 
				
			||||||
obj-y += version.o
 | 
					obj-y += version.o
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# # boards
 | 
					# # boards
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										83
									
								
								common/button_cmd.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								common/button_cmd.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,83 @@
 | 
				
			|||||||
 | 
					// SPDX-License-Identifier: GPL-2.0+
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (c) 2023 Linaro Ltd.
 | 
				
			||||||
 | 
					 *   Author: Caleb Connolly <caleb.connolly@linaro.org>
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <button.h>
 | 
				
			||||||
 | 
					#include <command.h>
 | 
				
			||||||
 | 
					#include <env.h>
 | 
				
			||||||
 | 
					#include <log.h>
 | 
				
			||||||
 | 
					#include <vsprintf.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Some sane limit "just in case" */
 | 
				
			||||||
 | 
					#define MAX_BTN_CMDS 32
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct button_cmd {
 | 
				
			||||||
 | 
						bool pressed;
 | 
				
			||||||
 | 
						const char *btn_name;
 | 
				
			||||||
 | 
						const char *cmd;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Button commands are set via environment variables, e.g.:
 | 
				
			||||||
 | 
					 * button_cmd_N_name=Volume Up
 | 
				
			||||||
 | 
					 * button_cmd_N=fastboot usb 0
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function will retrieve the command for the given button N
 | 
				
			||||||
 | 
					 * and populate the cmd struct with the command string and pressed
 | 
				
			||||||
 | 
					 * state of the button.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Returns 1 if a command was found, 0 otherwise.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					static int get_button_cmd(int n, struct button_cmd *cmd)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						const char *cmd_str;
 | 
				
			||||||
 | 
						struct udevice *btn;
 | 
				
			||||||
 | 
						char buf[24];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						snprintf(buf, sizeof(buf), "button_cmd_%d_name", n);
 | 
				
			||||||
 | 
						cmd->btn_name = env_get(buf);
 | 
				
			||||||
 | 
						if (!cmd->btn_name)
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						button_get_by_label(cmd->btn_name, &btn);
 | 
				
			||||||
 | 
						if (!btn) {
 | 
				
			||||||
 | 
							log_err("No button labelled '%s'\n", cmd->btn_name);
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cmd->pressed = button_get_state(btn) == BUTTON_ON;
 | 
				
			||||||
 | 
						/* If the button isn't pressed then cmd->cmd will be unused so don't waste
 | 
				
			||||||
 | 
						 * cycles reading it
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						if (!cmd->pressed)
 | 
				
			||||||
 | 
							return 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						snprintf(buf, sizeof(buf), "button_cmd_%d", n);
 | 
				
			||||||
 | 
						cmd_str = env_get(buf);
 | 
				
			||||||
 | 
						if (!cmd_str) {
 | 
				
			||||||
 | 
							log_err("No command set for button '%s'\n", cmd->btn_name);
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cmd->cmd = cmd_str;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void process_button_cmds(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct button_cmd cmd = {0};
 | 
				
			||||||
 | 
						int i = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						while (get_button_cmd(i++, &cmd) && i < MAX_BTN_CMDS) {
 | 
				
			||||||
 | 
							if (!cmd.pressed)
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							log_info("BTN '%s'> %s\n", cmd.btn_name, cmd.cmd);
 | 
				
			||||||
 | 
							run_command(cmd.cmd, CMD_FLAG_ENV);
 | 
				
			||||||
 | 
							/* Don't run commands for multiple buttons */
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -8,6 +8,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <common.h>
 | 
					#include <common.h>
 | 
				
			||||||
#include <autoboot.h>
 | 
					#include <autoboot.h>
 | 
				
			||||||
 | 
					#include <button.h>
 | 
				
			||||||
#include <bootstage.h>
 | 
					#include <bootstage.h>
 | 
				
			||||||
#include <bootstd.h>
 | 
					#include <bootstd.h>
 | 
				
			||||||
#include <cli.h>
 | 
					#include <cli.h>
 | 
				
			||||||
@ -62,6 +63,8 @@ void main_loop(void)
 | 
				
			|||||||
			efi_launch_capsules();
 | 
								efi_launch_capsules();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						process_button_cmds();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	s = bootdelay_process();
 | 
						s = bootdelay_process();
 | 
				
			||||||
	if (cli_process_fdt(&s))
 | 
						if (cli_process_fdt(&s))
 | 
				
			||||||
		cli_secure_boot_cmd(s);
 | 
							cli_secure_boot_cmd(s);
 | 
				
			||||||
 | 
				
			|||||||
@ -190,6 +190,10 @@ bootm_size
 | 
				
			|||||||
bootstopkeysha256, bootdelaykey, bootstopkey
 | 
					bootstopkeysha256, bootdelaykey, bootstopkey
 | 
				
			||||||
    See README.autoboot
 | 
					    See README.autoboot
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					button_cmd_0, button_cmd_0_name ... button_cmd_N, button_cmd_N_name
 | 
				
			||||||
 | 
					    Used to map commands to run when a button is held during boot.
 | 
				
			||||||
 | 
					    See CONFIG_BUTTON_CMD.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
updatefile
 | 
					updatefile
 | 
				
			||||||
    Location of the software update file on a TFTP server, used
 | 
					    Location of the software update file on a TFTP server, used
 | 
				
			||||||
    by the automatic software update feature. Please refer to
 | 
					    by the automatic software update feature. Please refer to
 | 
				
			||||||
 | 
				
			|||||||
@ -1196,6 +1196,12 @@ static int gpmc_probe(struct udevice *dev)
 | 
				
			|||||||
	gpmc_cfg = (struct gpmc *)priv->base;
 | 
						gpmc_cfg = (struct gpmc *)priv->base;
 | 
				
			||||||
	gpmc_base = priv->base;
 | 
						gpmc_base = priv->base;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * Disable all IRQs as some bootroms might leave them enabled
 | 
				
			||||||
 | 
						 * and that will cause a lock-up later
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						gpmc_write_reg(GPMC_IRQENABLE, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	priv->l3_clk = devm_clk_get(dev, "fck");
 | 
						priv->l3_clk = devm_clk_get(dev, "fck");
 | 
				
			||||||
	if (IS_ERR(priv->l3_clk))
 | 
						if (IS_ERR(priv->l3_clk))
 | 
				
			||||||
		return PTR_ERR(priv->l3_clk);
 | 
							return PTR_ERR(priv->l3_clk);
 | 
				
			||||||
 | 
				
			|||||||
@ -74,4 +74,13 @@ enum button_state_t button_get_state(struct udevice *dev);
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
int button_get_code(struct udevice *dev);
 | 
					int button_get_code(struct udevice *dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if IS_ENABLED(CONFIG_BUTTON_CMD)
 | 
				
			||||||
 | 
					/* Process button command mappings specified in the environment,
 | 
				
			||||||
 | 
					 * running the commands for buttons which are pressed
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void process_button_cmds(void);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					static inline void process_button_cmds(void) {}
 | 
				
			||||||
 | 
					#endif /* CONFIG_BUTTON_CMD */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user