summaryrefslogtreecommitdiff
path: root/board/tq/common/tq_sysinfo.c
blob: 8d21d1e97c62ce2f639ff424c24486f38aa64f57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Common sysinfo helpers for TQ-Systems SOMs
 *
 * Copyright (c) 2020-2026 TQ-Systems GmbH <[email protected]>
 * D-82229 Seefeld, Germany.
 * Author: Nora Schiffer
 */

#include <env.h>
#include <log.h>
#include <sysinfo/tq_eeprom.h>

#include "tq_sysinfo.h"

#define MAX_NAME_LENGTH	80

int tq_common_sysinfo_setup(void)
{
	struct udevice *sysinfo;
	char buf[MAX_NAME_LENGTH];
	int ret;

	ret = sysinfo_get_and_detect(&sysinfo);
	if (ret) {
		log_debug("Failed to get sysinfo data: %d\n", ret);
		return ret;
	}

	if (!sysinfo_get_str(sysinfo, SYSID_TQ_MODEL, sizeof(buf), buf))
		env_set_runtime("boardtype", buf);

	if (!sysinfo_get_str(sysinfo, SYSID_TQ_SERIAL, sizeof(buf), buf))
		env_set_runtime("serial#", buf);

	return 0;
}