2019-03-29 09:18:19 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2015
|
|
|
|
* Dirk Eibach, Guntermann & Drunck GmbH, eibach@gdsys.de
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:03 +00:00
|
|
|
#include <command.h>
|
2019-03-29 09:18:19 +00:00
|
|
|
#include <dm.h>
|
2019-08-01 15:46:47 +00:00
|
|
|
#include <env.h>
|
2019-03-29 09:18:19 +00:00
|
|
|
#include <fdt_support.h>
|
|
|
|
#include <fsl_esdhc.h>
|
2019-11-14 19:57:46 +00:00
|
|
|
#include <init.h>
|
2019-03-29 09:18:19 +00:00
|
|
|
#include <miiphy.h>
|
|
|
|
#include <misc.h>
|
2020-11-05 13:32:05 +00:00
|
|
|
#include <sysinfo.h>
|
2019-03-29 09:18:19 +00:00
|
|
|
#include <tpm-v1.h>
|
|
|
|
#include <video_osd.h>
|
|
|
|
|
|
|
|
#include "../common/ihs_mdio.h"
|
2020-11-05 13:32:05 +00:00
|
|
|
#include "../../../drivers/sysinfo/gazerbeam.h"
|
2019-03-29 09:18:19 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
struct ihs_mdio_info ihs_mdio_info[] = {
|
|
|
|
{ .fpga = NULL, .name = "ihs0", .base = 0x58 },
|
|
|
|
{ .fpga = NULL, .name = "ihs1", .base = 0x58 },
|
|
|
|
};
|
|
|
|
|
|
|
|
static int get_tpm(struct udevice **devp)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = uclass_first_device_err(UCLASS_TPM, devp);
|
|
|
|
if (rc) {
|
|
|
|
printf("Could not find TPM (ret=%d)\n", rc);
|
|
|
|
return CMD_RET_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int board_early_init_r(void)
|
|
|
|
{
|
2020-11-05 13:32:05 +00:00
|
|
|
struct udevice *sysinfo;
|
2019-03-29 09:18:19 +00:00
|
|
|
struct udevice *serdes;
|
|
|
|
int mc = 0;
|
|
|
|
int con = 0;
|
|
|
|
|
2020-11-05 13:32:05 +00:00
|
|
|
if (sysinfo_get(&sysinfo))
|
|
|
|
puts("Could not find sysinfo information device.\n");
|
2019-03-29 09:18:19 +00:00
|
|
|
|
|
|
|
/* Initialize serdes */
|
2020-11-05 13:32:05 +00:00
|
|
|
uclass_get_device_by_phandle(UCLASS_MISC, sysinfo, "serdes", &serdes);
|
2019-03-29 09:18:19 +00:00
|
|
|
|
2020-11-05 13:32:05 +00:00
|
|
|
if (sysinfo_detect(sysinfo))
|
2019-03-29 09:18:19 +00:00
|
|
|
puts("Device information detection failed.\n");
|
|
|
|
|
2020-11-05 13:32:05 +00:00
|
|
|
sysinfo_get_int(sysinfo, BOARD_MULTICHANNEL, &mc);
|
|
|
|
sysinfo_get_int(sysinfo, BOARD_VARIANT, &con);
|
2019-03-29 09:18:19 +00:00
|
|
|
|
|
|
|
if (mc == 2 || mc == 1)
|
|
|
|
dev_disable_by_path("/immr@e0000000/i2c@3100/pca9698@22");
|
|
|
|
|
|
|
|
if (mc == 4) {
|
|
|
|
dev_disable_by_path("/immr@e0000000/i2c@3100/pca9698@20");
|
|
|
|
dev_enable_by_path("/localbus@e0005000/iocon_uart@2,0");
|
|
|
|
dev_enable_by_path("/fpga1bus");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mc == 2 || con == VAR_CON) {
|
|
|
|
dev_enable_by_path("/fpga0bus/fpga0_video1");
|
|
|
|
dev_enable_by_path("/fpga0bus/fpga0_iic_video1");
|
|
|
|
dev_enable_by_path("/fpga0bus/fpga0_axi_video1");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (con == VAR_CON) {
|
|
|
|
dev_enable_by_path("/fpga0bus/fpga0_video0");
|
|
|
|
dev_enable_by_path("/fpga0bus/fpga0_iic_video0");
|
|
|
|
dev_enable_by_path("/fpga0bus/fpga0_axi_video0");
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-11-05 13:32:05 +00:00
|
|
|
int checksysinfo(void)
|
2019-03-29 09:18:19 +00:00
|
|
|
{
|
2020-11-05 13:32:05 +00:00
|
|
|
struct udevice *sysinfo;
|
2019-03-29 09:18:19 +00:00
|
|
|
char *s = env_get("serial#");
|
|
|
|
int mc = 0;
|
|
|
|
int con = 0;
|
|
|
|
|
2020-11-05 13:32:05 +00:00
|
|
|
if (sysinfo_get(&sysinfo))
|
|
|
|
puts("Could not find sysinfo information device.\n");
|
2019-03-29 09:18:19 +00:00
|
|
|
|
2020-11-05 13:32:05 +00:00
|
|
|
sysinfo_get_int(sysinfo, BOARD_MULTICHANNEL, &mc);
|
|
|
|
sysinfo_get_int(sysinfo, BOARD_VARIANT, &con);
|
2019-03-29 09:18:19 +00:00
|
|
|
|
|
|
|
puts("Board: Gazerbeam ");
|
|
|
|
printf("%s ", mc == 4 ? "MC4" : mc == 2 ? "MC2" : "SC");
|
|
|
|
printf("%s", con == VAR_CON ? "CON" : "CPU");
|
|
|
|
|
|
|
|
if (s) {
|
|
|
|
puts(", serial# ");
|
|
|
|
puts(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
puts("\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void display_osd_info(struct udevice *osd,
|
|
|
|
struct video_osd_info *osd_info)
|
|
|
|
{
|
|
|
|
printf("OSD-%s: Digital-OSD version %01d.%02d, %d x %d characters\n",
|
|
|
|
osd->name, osd_info->major_version, osd_info->minor_version,
|
|
|
|
osd_info->width, osd_info->height);
|
|
|
|
}
|
|
|
|
|
|
|
|
int last_stage_init(void)
|
|
|
|
{
|
|
|
|
int fpga_hw_rev = 0;
|
|
|
|
int i;
|
2020-11-05 13:32:05 +00:00
|
|
|
struct udevice *sysinfo;
|
2019-03-29 09:18:19 +00:00
|
|
|
struct udevice *osd;
|
|
|
|
struct video_osd_info osd_info;
|
|
|
|
struct udevice *tpm;
|
|
|
|
int ret;
|
|
|
|
|
2020-11-05 13:32:05 +00:00
|
|
|
if (sysinfo_get(&sysinfo))
|
|
|
|
puts("Could not find sysinfo information device.\n");
|
2019-03-29 09:18:19 +00:00
|
|
|
|
2020-11-05 13:32:05 +00:00
|
|
|
if (sysinfo) {
|
|
|
|
int res = sysinfo_get_int(sysinfo, BOARD_HWVERSION,
|
|
|
|
&fpga_hw_rev);
|
2019-03-29 09:18:19 +00:00
|
|
|
|
|
|
|
if (res)
|
2020-11-05 13:32:05 +00:00
|
|
|
printf("Could not determind FPGA HW revision (res = %d)\n",
|
|
|
|
res);
|
2019-03-29 09:18:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
env_set_ulong("fpga_hw_rev", fpga_hw_rev);
|
|
|
|
|
|
|
|
ret = get_tpm(&tpm);
|
|
|
|
if (ret || tpm_init(tpm) || tpm_startup(tpm, TPM_ST_CLEAR) ||
|
|
|
|
tpm_continue_self_test(tpm)) {
|
|
|
|
printf("TPM init failed\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fpga_hw_rev >= 4) {
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
struct udevice *rxaui;
|
|
|
|
char name[8];
|
|
|
|
|
|
|
|
snprintf(name, sizeof(name), "rxaui%d", i);
|
|
|
|
/* Disable RXAUI polarity inversion */
|
2020-11-05 13:32:05 +00:00
|
|
|
ret = uclass_get_device_by_phandle(UCLASS_MISC, sysinfo,
|
|
|
|
name, &rxaui);
|
2019-03-29 09:18:19 +00:00
|
|
|
if (!ret)
|
|
|
|
misc_set_enabled(rxaui, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uclass_first_device(UCLASS_VIDEO_OSD, &osd);
|
|
|
|
osd;
|
|
|
|
uclass_next_device(&osd)) {
|
|
|
|
video_osd_get_info(osd, &osd_info);
|
|
|
|
display_osd_info(osd, &osd_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(CONFIG_OF_BOARD_SETUP)
|
2020-06-26 06:13:33 +00:00
|
|
|
int ft_board_setup(void *blob, struct bd_info *bd)
|
2019-03-29 09:18:19 +00:00
|
|
|
{
|
|
|
|
ft_cpu_setup(blob, bd);
|
|
|
|
fsl_fdt_fixup_dr_usb(blob, bd);
|
|
|
|
fdt_fixup_esdhc(blob, bd);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|