Skip to content

Commit

Permalink
Merge branch '2024-01-24-assorted-fixes-and-updates'
Browse files Browse the repository at this point in the history
- Increase SYS_MAXARGS default, verdin-am62 improvements (and required
  cleanup), assorted cleanups throughout the code base.
  • Loading branch information
trini committed Jan 25, 2024
2 parents 15e7927 + 53c3e38 commit e7f9e5e
Show file tree
Hide file tree
Showing 23 changed files with 160 additions and 55 deletions.
23 changes: 0 additions & 23 deletions arch/arm/mach-k3/am625_fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,6 @@ static void fdt_fixup_pru_node_am625(void *blob, int has_pru)
fdt_del_node_path(blob, "/bus@f0000/pruss@30040000");
}

static int k3_get_core_nr(void)
{
u32 full_devid = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);

return (full_devid & JTAG_DEV_CORE_NR_MASK) >> JTAG_DEV_CORE_NR_SHIFT;
}

static int k3_has_pru(void)
{
u32 full_devid = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
u32 feature_mask = (full_devid & JTAG_DEV_FEATURES_MASK) >>
JTAG_DEV_FEATURES_SHIFT;

return !(feature_mask & JTAG_DEV_FEATURE_NO_PRU);
}

static int k3_has_gpu(void)
{
u32 full_devid = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);

return (full_devid & JTAG_DEV_GPU_MASK) >> JTAG_DEV_GPU_SHIFT;
}

int ft_system_setup(void *blob, struct bd_info *bd)
{
fdt_fixup_cores_nodes_am625(blob, k3_get_core_nr());
Expand Down
39 changes: 39 additions & 0 deletions arch/arm/mach-k3/include/mach/am62_hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,45 @@

#define TI_SRAM_SCRATCH_BOARD_EEPROM_START 0x43c30000

static inline int k3_get_core_nr(void)
{
u32 full_devid = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);

return (full_devid & JTAG_DEV_CORE_NR_MASK) >> JTAG_DEV_CORE_NR_SHIFT;
}

static inline char k3_get_speed_grade(void)
{
u32 full_devid = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
u32 speed_grade = (full_devid & JTAG_DEV_SPEED_MASK) >>
JTAG_DEV_SPEED_SHIFT;

return 'A' - 1 + speed_grade;
}

static inline int k3_get_temp_grade(void)
{
u32 full_devid = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);

return (full_devid & JTAG_DEV_TEMP_MASK) >> JTAG_DEV_TEMP_SHIFT;
}

static inline int k3_has_pru(void)
{
u32 full_devid = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
u32 feature_mask = (full_devid & JTAG_DEV_FEATURES_MASK) >>
JTAG_DEV_FEATURES_SHIFT;

return !(feature_mask & JTAG_DEV_FEATURE_NO_PRU);
}

static inline int k3_has_gpu(void)
{
u32 full_devid = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);

return (full_devid & JTAG_DEV_GPU_MASK) >> JTAG_DEV_GPU_SHIFT;
}

#if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__)

static const u32 put_device_ids[] = {};
Expand Down
4 changes: 2 additions & 2 deletions board/ti/common/board_detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,

rc = dm_i2c_read(dev, 0x1, &offset_test, sizeof(offset_test));

if (*((u32 *)ep) != (header & 0xFF))
if (offset_test != ((header >> 8) & 0xFF))
one_byte_addressing = false;

/* Corrupted data??? */
Expand Down Expand Up @@ -181,7 +181,7 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr,

rc = i2c_read(dev_addr, 0x1, byte, &offset_test, sizeof(offset_test));

if (*((u32 *)ep) != (header & 0xFF))
if (offset_test != ((header >> 8) & 0xFF))
one_byte_addressing = false;

/* Corrupted data??? */
Expand Down
52 changes: 50 additions & 2 deletions board/toradex/verdin-am62/verdin-am62.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
#include <fdt_support.h>
#include <init.h>
#include <k3-ddrss.h>
#include <power/regulator.h>
#include <spl.h>

#include "../common/tdx-cfg-block.h"

#define VDD_CORE_REG "buck1"

DECLARE_GLOBAL_DATA_PTR;

int board_init(void)
Expand Down Expand Up @@ -50,9 +53,37 @@ int board_fit_config_name_match(const char *name)
}
#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)
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);
}
#endif
Expand Down Expand Up @@ -87,6 +118,22 @@ static void select_dt_from_module_version(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();

return 0;
Expand All @@ -102,12 +149,13 @@ void spl_board_init(void)
{
u32 val;

/* Set USB0 PHY core voltage to 0.85V */
/* Clear USB0_PHY_CTRL_CORE_VOLTAGE */
/* TI recommends to clear the bit independent of VDDA_CORE_USB */
val = readl(CTRLMMR_USB0_PHY_CTRL);
val &= ~(CORE_VOLTAGE);
writel(val, CTRLMMR_USB0_PHY_CTRL);

/* Set USB1 PHY core voltage to 0.85V */
/* Clear USB1_PHY_CTRL_CORE_VOLTAGE */
val = readl(CTRLMMR_USB1_PHY_CTRL);
val &= ~(CORE_VOLTAGE);
writel(val, CTRLMMR_USB1_PHY_CTRL);
Expand Down
2 changes: 1 addition & 1 deletion cmd/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ config SYS_PROMPT_HUSH_PS2

config SYS_MAXARGS
int "Maximum number arguments accepted by commands"
default 16
default 64

config SYS_XTRACE
bool "Command execution tracer"
Expand Down
10 changes: 5 additions & 5 deletions cmd/bootmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static char *bootmenu_choice_entry(void *data)
iter = iter->next;
return iter->key;
case BKEY_QUIT:
/* Quit by choosing the last entry - U-Boot console */
/* Quit by choosing the last entry */
iter = menu->first;
while (iter->next)
iter = iter->next;
Expand Down Expand Up @@ -361,15 +361,15 @@ static struct bootmenu_data *bootmenu_create(int delay)
}
#endif

/* Add U-Boot console entry at the end */
/* Add Exit entry at the end */
if (i <= MAX_COUNT - 1) {
entry = malloc(sizeof(struct bootmenu_entry));
if (!entry)
goto cleanup;

/* Add Quit entry if entering U-Boot console is disabled */
/* Add Quit entry if exiting bootmenu is disabled */
if (!IS_ENABLED(CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE))
entry->title = strdup("U-Boot console");
entry->title = strdup("Exit");
else
entry->title = strdup("Quit");

Expand Down Expand Up @@ -532,7 +532,7 @@ static enum bootmenu_ret bootmenu_show(int delay)
title = strdup(iter->title);
command = strdup(iter->command);

/* last entry is U-Boot console or Quit */
/* last entry exits bootmenu */
if (iter->num == iter->menu->count - 1) {
ret = BOOTMENU_RET_QUIT;
goto cleanup;
Expand Down
27 changes: 12 additions & 15 deletions common/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -1049,32 +1049,29 @@ int console_clear(void)
return 0;
}

static char *get_stdio(const u8 std)
{
return stdio_devices[std] ? stdio_devices[std]->name : "No devices available!";
}

static void stdio_print_current_devices(void)
{
char *stdinname, *stdoutname, *stderrname;
char *stdinname = NULL;
char *stdoutname = NULL;
char *stderrname = NULL;

if (CONFIG_IS_ENABLED(CONSOLE_MUX) &&
CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)) {
/* stdin stdout and stderr are in environment */
stdinname = env_get("stdin");
stdoutname = env_get("stdout");
stderrname = env_get("stderr");

stdinname = stdinname ? : "No input devices available!";
stdoutname = stdoutname ? : "No output devices available!";
stderrname = stderrname ? : "No error devices available!";
} else {
stdinname = stdio_devices[stdin] ?
stdio_devices[stdin]->name :
"No input devices available!";
stdoutname = stdio_devices[stdout] ?
stdio_devices[stdout]->name :
"No output devices available!";
stderrname = stdio_devices[stderr] ?
stdio_devices[stderr]->name :
"No error devices available!";
}

stdinname = stdinname ? : get_stdio(stdin);
stdoutname = stdoutname ? : get_stdio(stdout);
stderrname = stderrname ? : get_stdio(stderr);

/* Print information */
puts("In: ");
printf("%s\n", stdinname);
Expand Down
15 changes: 13 additions & 2 deletions drivers/reset/reset-hisilicon.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,26 @@ static int hisi_reset_assert(struct reset_ctl *rst)
static int hisi_reset_of_xlate(struct reset_ctl *rst,
struct ofnode_phandle_args *args)
{
if (args->args_count != 3) {
unsigned long polarity;

switch (args->args_count) {
case 2:
polarity = ASSERT_SET;
break;

case 3:
polarity = args->args[2];
break;

default:
debug("Invalid args_count: %d\n", args->args_count);
return -EINVAL;
}

/* Use .data field as register offset and .id field as bit shift */
rst->data = args->args[0];
rst->id = args->args[1];
rst->polarity = args->args[2];
rst->polarity = polarity;

return 0;
}
Expand Down
1 change: 1 addition & 0 deletions include/dfu.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#ifndef __DFU_ENTITY_H_
#define __DFU_ENTITY_H_

#include <linux/errno.h>
#include <linux/list.h>
#include <mmc.h>
#include <spi_flash.h>
Expand Down
2 changes: 2 additions & 0 deletions include/dm/pinctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ifndef __PINCTRL_H
#define __PINCTRL_H

#include <linux/errno.h>

#define PINNAME_SIZE 10
#define PINMUX_SIZE 90

Expand Down
2 changes: 2 additions & 0 deletions include/hwspinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ifndef _HWSPINLOCK_H_
#define _HWSPINLOCK_H_

#include <linux/errno.h>

/**
* Implement a hwspinlock uclass.
* Hardware spinlocks are used to perform hardware protection of
Expand Down
2 changes: 2 additions & 0 deletions include/i2c_eeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ifndef __I2C_EEPROM
#define __I2C_EEPROM

#include <linux/errno.h>

struct udevice;

struct i2c_eeprom_ops {
Expand Down
2 changes: 2 additions & 0 deletions include/nvmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ifndef NVMEM_H
#define NVMEM_H

#include <linux/errno.h>

/**
* DOC: Design
*
Expand Down
2 changes: 2 additions & 0 deletions include/power-domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ifndef _POWER_DOMAIN_H
#define _POWER_DOMAIN_H

#include <linux/errno.h>

/**
* A power domain is a portion of an SoC or chip that is powered by a
* switchable source of power. In many cases, software has control over the
Expand Down
2 changes: 2 additions & 0 deletions include/power/regulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#ifndef _INCLUDE_REGULATOR_H_
#define _INCLUDE_REGULATOR_H_

#include <linux/errno.h>

struct udevice;

/**
Expand Down
1 change: 1 addition & 0 deletions include/remoteproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* platforms have moved to dm/fdt.
*/
#include <dm/platdata.h> /* For platform data support - non dt world */
#include <linux/errno.h>

/**
* struct fw_rsc_hdr - firmware resource entry header
Expand Down
2 changes: 2 additions & 0 deletions include/soc.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#ifndef __SOC_H
#define __SOC_H

#include <linux/errno.h>

#define SOC_MAX_STR_SIZE 128

struct udevice;
Expand Down
2 changes: 2 additions & 0 deletions include/spi-mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#ifndef __UBOOT_SPI_MEM_H
#define __UBOOT_SPI_MEM_H

#include <linux/errno.h>

struct udevice;

#define SPI_MEM_OP_CMD(__opcode, __buswidth) \
Expand Down
Loading

0 comments on commit e7f9e5e

Please sign in to comment.