mirror of
https://github.com/smaeul/u-boot.git
synced 2025-10-18 22:58:13 +01:00
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
100 lines
1.9 KiB
C
100 lines
1.9 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* (C) Copyright 2004, Psyent Corporation <www.psyent.com>
|
|
* Scott McNutt <smcnutt@psyent.com>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <command.h>
|
|
#include <dm.h>
|
|
#include <errno.h>
|
|
#include <misc.h>
|
|
#include <linux/time.h>
|
|
#include <asm/io.h>
|
|
|
|
struct altera_sysid_regs {
|
|
u32 id; /* The system build id */
|
|
u32 timestamp; /* Timestamp */
|
|
};
|
|
|
|
struct altera_sysid_plat {
|
|
struct altera_sysid_regs *regs;
|
|
};
|
|
|
|
void display_sysid(void)
|
|
{
|
|
struct udevice *dev;
|
|
u32 sysid[2];
|
|
struct tm t;
|
|
char asc[32];
|
|
time_t stamp;
|
|
int ret;
|
|
|
|
/* the first misc device will be used */
|
|
ret = uclass_first_device_err(UCLASS_MISC, &dev);
|
|
if (ret)
|
|
return;
|
|
ret = misc_read(dev, 0, &sysid, sizeof(sysid));
|
|
if (ret < 0)
|
|
return;
|
|
|
|
stamp = sysid[1];
|
|
localtime_r(&stamp, &t);
|
|
asctime_r(&t, asc);
|
|
printf("SYSID: %08x, %s", sysid[0], asc);
|
|
}
|
|
|
|
int do_sysid(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|
{
|
|
display_sysid();
|
|
return 0;
|
|
}
|
|
|
|
U_BOOT_CMD(
|
|
sysid, 1, 1, do_sysid,
|
|
"display Nios-II system id",
|
|
""
|
|
);
|
|
|
|
static int altera_sysid_read(struct udevice *dev,
|
|
int offset, void *buf, int size)
|
|
{
|
|
struct altera_sysid_plat *plat = dev_get_plat(dev);
|
|
struct altera_sysid_regs *const regs = plat->regs;
|
|
u32 *sysid = buf;
|
|
|
|
sysid[0] = readl(®s->id);
|
|
sysid[1] = readl(®s->timestamp);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int altera_sysid_of_to_plat(struct udevice *dev)
|
|
{
|
|
struct altera_sysid_plat *plat = dev_get_plat(dev);
|
|
|
|
plat->regs = map_physmem(dev_read_addr(dev),
|
|
sizeof(struct altera_sysid_regs),
|
|
MAP_NOCACHE);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct misc_ops altera_sysid_ops = {
|
|
.read = altera_sysid_read,
|
|
};
|
|
|
|
static const struct udevice_id altera_sysid_ids[] = {
|
|
{ .compatible = "altr,sysid-1.0" },
|
|
{}
|
|
};
|
|
|
|
U_BOOT_DRIVER(altera_sysid) = {
|
|
.name = "altera_sysid",
|
|
.id = UCLASS_MISC,
|
|
.of_match = altera_sysid_ids,
|
|
.of_to_plat = altera_sysid_of_to_plat,
|
|
.plat_auto = sizeof(struct altera_sysid_plat),
|
|
.ops = &altera_sysid_ops,
|
|
};
|