mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-16 09:54:35 +00:00
Merge patch series "Add fdt-fixups for AM62P variants"
Aparna Patra <a-patra@ti.com> says: This series implements fdt fixups, by reading hardware information from registers and accordingly delete/modify the DT nodes, at run-time. Logs for AM62P boot: https://gist.github.com/itsme-aparna/b889fe59882c1acf0ef25a644bd325c4 Link: https://lore.kernel.org/r/20250108044939.392785-1-a-patra@ti.com
This commit is contained in:
commit
e26a9ac4c6
3 changed files with 210 additions and 0 deletions
|
@ -7,8 +7,91 @@
|
|||
#include "../common_fdt.h"
|
||||
#include <fdt_support.h>
|
||||
|
||||
static void fdt_fixup_cores_wdt_nodes_am62p(void *blob, int core_nr)
|
||||
{
|
||||
char node_path[32];
|
||||
|
||||
if (core_nr < 1)
|
||||
return;
|
||||
|
||||
for (; core_nr < 4; core_nr++) {
|
||||
snprintf(node_path, sizeof(node_path), "/cpus/cpu@%d", core_nr);
|
||||
fdt_del_node_path(blob, node_path);
|
||||
snprintf(node_path, sizeof(node_path), "/cpus/cpu-map/cluster0/core%d", core_nr);
|
||||
fdt_del_node_path(blob, node_path);
|
||||
snprintf(node_path, sizeof(node_path), "/bus@f0000/watchdog@e0%d0000", core_nr);
|
||||
fdt_del_node_path(blob, node_path);
|
||||
}
|
||||
}
|
||||
|
||||
static void fdt_fixup_video_codec_nodes_am62p(void *blob, bool has_video_codec)
|
||||
{
|
||||
if (!has_video_codec)
|
||||
fdt_del_node_path(blob, "/bus@f0000/video-codec@30210000");
|
||||
}
|
||||
|
||||
static void fdt_fixup_canfd_nodes_am62p(void *blob, bool has_canfd)
|
||||
{
|
||||
if (!has_canfd) {
|
||||
fdt_del_node_path(blob, "/bus@f0000/can@20701000");
|
||||
fdt_del_node_path(blob, "/bus@f0000/can@20711000");
|
||||
}
|
||||
}
|
||||
|
||||
static int fdt_fixup_trips_node(void *blob, int zoneoffset, int maxc)
|
||||
{
|
||||
int node, trip;
|
||||
|
||||
node = fdt_subnode_offset(blob, zoneoffset, "trips");
|
||||
if (node < 0)
|
||||
return -1;
|
||||
|
||||
fdt_for_each_subnode(trip, blob, node) {
|
||||
const char *type = fdt_getprop(blob, trip, "type", NULL);
|
||||
|
||||
if (!type || (strncmp(type, "critical", 8) != 0))
|
||||
continue;
|
||||
|
||||
if (fdt_setprop_u32(blob, trip, "temperature", 1000 * maxc) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fdt_fixup_thermal_zone_nodes_am62p(void *blob, int maxc)
|
||||
{
|
||||
int node, zone;
|
||||
|
||||
node = fdt_path_offset(blob, "/thermal-zones");
|
||||
if (node < 0)
|
||||
return;
|
||||
|
||||
fdt_for_each_subnode(zone, blob, node) {
|
||||
if (fdt_fixup_trips_node(blob, zone, maxc) < 0)
|
||||
printf("Failed to set temperature in %s critical trips\n",
|
||||
fdt_get_name(blob, zone, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
static void fdt_fixup_cpu_freq_nodes_am62p(void *blob, int max_freq)
|
||||
{
|
||||
if (max_freq >= 1250000000)
|
||||
return;
|
||||
|
||||
if (max_freq <= 1000000000) {
|
||||
fdt_del_node_path(blob, "/opp-table/opp-1250000000");
|
||||
fdt_del_node_path(blob, "/opp-table/opp-1400000000");
|
||||
}
|
||||
}
|
||||
|
||||
int ft_system_setup(void *blob, struct bd_info *bd)
|
||||
{
|
||||
fdt_fixup_cores_wdt_nodes_am62p(blob, k3_get_core_nr());
|
||||
fdt_fixup_video_codec_nodes_am62p(blob, k3_has_video_codec());
|
||||
fdt_fixup_canfd_nodes_am62p(blob, k3_has_canfd());
|
||||
fdt_fixup_thermal_zone_nodes_am62p(blob, k3_get_max_temp());
|
||||
fdt_fixup_cpu_freq_nodes_am62p(blob, k3_get_a53_max_frequency());
|
||||
fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
|
||||
fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
|
||||
|
||||
|
|
|
@ -11,10 +11,14 @@
|
|||
#include <dm.h>
|
||||
#include <dm/uclass-internal.h>
|
||||
#include <dm/pinctrl.h>
|
||||
#include <dm/ofnode.h>
|
||||
|
||||
#include "../sysfw-loader.h"
|
||||
#include "../common.h"
|
||||
|
||||
/* TISCI DEV ID for A53 Clock */
|
||||
#define AM62PX_DEV_A53SS0_CORE_0_DEV_ID 135
|
||||
|
||||
struct fwl_data cbass_main_fwls[] = {
|
||||
{ "FSS_DAT_REG3", 7, 8 },
|
||||
};
|
||||
|
@ -67,6 +71,62 @@ static void ctrl_mmr_unlock(void)
|
|||
mmr_unlock(PADCFG_MMR1_BASE, 1);
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(OF_CONTROL)
|
||||
static int get_a53_cpu_clock_index(ofnode node)
|
||||
{
|
||||
int count, i;
|
||||
struct ofnode_phandle_args *args;
|
||||
ofnode clknode;
|
||||
|
||||
clknode = ofnode_path("/bus@f0000/system-controller@44043000/clock-controller");
|
||||
if (!ofnode_valid(clknode))
|
||||
return -1;
|
||||
|
||||
count = ofnode_count_phandle_with_args(node, "assigned-clocks", "#clock-cells", 0);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (!ofnode_parse_phandle_with_args(node, "assigned-clocks",
|
||||
"#clock-cells", 0, i, args)) {
|
||||
if (ofnode_equal(clknode, args->node) &&
|
||||
args->args[0] == AM62PX_DEV_A53SS0_CORE_0_DEV_ID)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void fixup_a53_cpu_freq_by_speed_grade(void)
|
||||
{
|
||||
int index, size;
|
||||
u32 *rates;
|
||||
ofnode node;
|
||||
|
||||
node = ofnode_path("/a53@0");
|
||||
if (!ofnode_valid(node))
|
||||
return;
|
||||
|
||||
rates = fdt_getprop_w(ofnode_to_fdt(node), ofnode_to_offset(node),
|
||||
"assigned-clock-rates", &size);
|
||||
|
||||
index = get_a53_cpu_clock_index(node);
|
||||
|
||||
if (!rates || index < 0 || index >= (size / sizeof(u32))) {
|
||||
printf("Wrong A53 assigned-clocks configuration\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rates[index] = cpu_to_fdt32(k3_get_a53_max_frequency());
|
||||
|
||||
printf("Changed A53 CPU frequency to %dHz (%c grade) in DT\n",
|
||||
k3_get_a53_max_frequency(), k3_get_speed_grade());
|
||||
}
|
||||
#else
|
||||
static void fixup_a53_cpu_freq_by_speed_grade(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
void board_init_f(ulong dummy)
|
||||
{
|
||||
struct udevice *dev;
|
||||
|
@ -162,6 +222,8 @@ void board_init_f(ulong dummy)
|
|||
|
||||
setup_qos();
|
||||
debug("am62px_init: %s done\n", __func__);
|
||||
|
||||
fixup_a53_cpu_freq_by_speed_grade();
|
||||
}
|
||||
|
||||
u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
|
||||
|
|
|
@ -19,6 +19,22 @@
|
|||
#define MCU_CTRL_MMR0_BASE 0x04500000
|
||||
#define WKUP_CTRL_MMR0_BASE 0x43000000
|
||||
|
||||
#define CTRLMMR_WKUP_JTAG_DEVICE_ID (WKUP_CTRL_MMR0_BASE + 0x18)
|
||||
#define JTAG_DEV_CORE_NR_MASK GENMASK(19, 18)
|
||||
#define JTAG_DEV_CORE_NR_SHIFT 18
|
||||
#define JTAG_DEV_CANFD_MASK BIT(15)
|
||||
#define JTAG_DEV_CANFD_SHIFT 15
|
||||
#define JTAG_DEV_VIDEO_CODEC_MASK BIT(14)
|
||||
#define JTAG_DEV_VIDEO_CODEC_SHIFT 14
|
||||
#define JTAG_DEV_SPEED_MASK GENMASK(10, 6)
|
||||
#define JTAG_DEV_SPEED_SHIFT 6
|
||||
#define JTAG_DEV_TEMP_MASK GENMASK(5, 3)
|
||||
#define JTAG_DEV_TEMP_SHIFT 3
|
||||
|
||||
#define JTAG_DEV_TEMP_AUTOMOTIVE 0x5
|
||||
#define JTAG_DEV_TEMP_EXTENDED_VALUE 105
|
||||
#define JTAG_DEV_TEMP_AUTOMOTIVE_VALUE 125
|
||||
|
||||
#define CTRLMMR_MAIN_DEVSTAT (WKUP_CTRL_MMR0_BASE + 0x30)
|
||||
#define MAIN_DEVSTAT_PRIMARY_BOOTMODE_MASK GENMASK(6, 3)
|
||||
#define MAIN_DEVSTAT_PRIMARY_BOOTMODE_SHIFT 3
|
||||
|
@ -72,6 +88,55 @@
|
|||
|
||||
#define TI_SRAM_SCRATCH_BOARD_EEPROM_START 0x43c30000
|
||||
|
||||
static inline int k3_get_core_nr(void)
|
||||
{
|
||||
u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
|
||||
|
||||
return ((dev_id & JTAG_DEV_CORE_NR_MASK) >> JTAG_DEV_CORE_NR_SHIFT) + 1;
|
||||
}
|
||||
|
||||
static inline int k3_has_video_codec(void)
|
||||
{
|
||||
u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
|
||||
|
||||
return !((dev_id & JTAG_DEV_VIDEO_CODEC_MASK) >> JTAG_DEV_VIDEO_CODEC_SHIFT);
|
||||
}
|
||||
|
||||
static inline int k3_has_canfd(void)
|
||||
{
|
||||
u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
|
||||
|
||||
return (dev_id & JTAG_DEV_CANFD_MASK) >> JTAG_DEV_CANFD_SHIFT;
|
||||
}
|
||||
|
||||
static inline int k3_get_max_temp(void)
|
||||
{
|
||||
u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
|
||||
u32 dev_temp = (dev_id & JTAG_DEV_TEMP_MASK) >> JTAG_DEV_TEMP_SHIFT;
|
||||
|
||||
if (dev_temp == JTAG_DEV_TEMP_AUTOMOTIVE)
|
||||
return JTAG_DEV_TEMP_AUTOMOTIVE_VALUE;
|
||||
else
|
||||
return JTAG_DEV_TEMP_EXTENDED_VALUE;
|
||||
}
|
||||
|
||||
static inline char k3_get_speed_grade(void)
|
||||
{
|
||||
u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
|
||||
u32 speed_grade = (dev_id & JTAG_DEV_SPEED_MASK) >>
|
||||
JTAG_DEV_SPEED_SHIFT;
|
||||
|
||||
return 'A' - 1 + speed_grade;
|
||||
}
|
||||
|
||||
static inline int k3_get_a53_max_frequency(void)
|
||||
{
|
||||
if (k3_get_speed_grade() == 'O')
|
||||
return 1000000000;
|
||||
else
|
||||
return 1250000000;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__)
|
||||
|
||||
static const u32 put_device_ids[] = {};
|
||||
|
|
Loading…
Add table
Reference in a new issue