uboot/board/gdsys/mpc8308/gazerbeam.c
<<
>>
Prefs
   1/*
   2 * (C) Copyright 2015
   3 * Dirk Eibach,  Guntermann & Drunck GmbH, eibach@gdsys.de
   4 *
   5 * SPDX-License-Identifier:     GPL-2.0+
   6 */
   7
   8#include <common.h>
   9#include <command.h>
  10#include <dm.h>
  11#include <env.h>
  12#include <fdt_support.h>
  13#include <fsl_esdhc.h>
  14#include <init.h>
  15#include <miiphy.h>
  16#include <misc.h>
  17#include <sysinfo.h>
  18#include <tpm-v1.h>
  19#include <video_osd.h>
  20
  21#include "../common/ihs_mdio.h"
  22#include "../../../drivers/sysinfo/gazerbeam.h"
  23
  24DECLARE_GLOBAL_DATA_PTR;
  25
  26struct ihs_mdio_info ihs_mdio_info[] = {
  27        { .fpga = NULL, .name = "ihs0", .base = 0x58 },
  28        { .fpga = NULL, .name = "ihs1", .base = 0x58 },
  29};
  30
  31static int get_tpm(struct udevice **devp)
  32{
  33        int rc;
  34
  35        rc = uclass_first_device_err(UCLASS_TPM, devp);
  36        if (rc) {
  37                printf("Could not find TPM (ret=%d)\n", rc);
  38                return CMD_RET_FAILURE;
  39        }
  40
  41        return 0;
  42}
  43
  44int board_early_init_r(void)
  45{
  46        struct udevice *sysinfo;
  47        struct udevice *serdes;
  48        int mc = 0;
  49        int con = 0;
  50
  51        if (sysinfo_get(&sysinfo))
  52                puts("Could not find sysinfo information device.\n");
  53
  54        /* Initialize serdes */
  55        uclass_get_device_by_phandle(UCLASS_MISC, sysinfo, "serdes", &serdes);
  56
  57        if (sysinfo_detect(sysinfo))
  58                puts("Device information detection failed.\n");
  59
  60        sysinfo_get_int(sysinfo, BOARD_MULTICHANNEL, &mc);
  61        sysinfo_get_int(sysinfo, BOARD_VARIANT, &con);
  62
  63        if (mc == 2 || mc == 1)
  64                dev_disable_by_path("/immr@e0000000/i2c@3100/pca9698@22");
  65
  66        if (mc == 4) {
  67                dev_disable_by_path("/immr@e0000000/i2c@3100/pca9698@20");
  68                dev_enable_by_path("/localbus@e0005000/iocon_uart@2,0");
  69                dev_enable_by_path("/fpga1bus");
  70        }
  71
  72        if (mc == 2 || con == VAR_CON) {
  73                dev_enable_by_path("/fpga0bus/fpga0_video1");
  74                dev_enable_by_path("/fpga0bus/fpga0_iic_video1");
  75                dev_enable_by_path("/fpga0bus/fpga0_axi_video1");
  76        }
  77
  78        if (con == VAR_CON) {
  79                dev_enable_by_path("/fpga0bus/fpga0_video0");
  80                dev_enable_by_path("/fpga0bus/fpga0_iic_video0");
  81                dev_enable_by_path("/fpga0bus/fpga0_axi_video0");
  82        }
  83
  84        return 0;
  85}
  86
  87int checksysinfo(void)
  88{
  89        struct udevice *sysinfo;
  90        char *s = env_get("serial#");
  91        int mc = 0;
  92        int con = 0;
  93
  94        if (sysinfo_get(&sysinfo))
  95                puts("Could not find sysinfo information device.\n");
  96
  97        sysinfo_get_int(sysinfo, BOARD_MULTICHANNEL, &mc);
  98        sysinfo_get_int(sysinfo, BOARD_VARIANT, &con);
  99
 100        puts("Board: Gazerbeam ");
 101        printf("%s ", mc == 4 ? "MC4" : mc == 2 ? "MC2" : "SC");
 102        printf("%s", con == VAR_CON ? "CON" : "CPU");
 103
 104        if (s) {
 105                puts(", serial# ");
 106                puts(s);
 107        }
 108
 109        puts("\n");
 110
 111        return 0;
 112}
 113
 114static void display_osd_info(struct udevice *osd,
 115                             struct video_osd_info *osd_info)
 116{
 117        printf("OSD-%s: Digital-OSD version %01d.%02d, %d x %d characters\n",
 118               osd->name, osd_info->major_version, osd_info->minor_version,
 119               osd_info->width, osd_info->height);
 120}
 121
 122int last_stage_init(void)
 123{
 124        int fpga_hw_rev = 0;
 125        int i;
 126        struct udevice *sysinfo;
 127        struct udevice *osd;
 128        struct video_osd_info osd_info;
 129        struct udevice *tpm;
 130        int ret;
 131
 132        if (sysinfo_get(&sysinfo))
 133                puts("Could not find sysinfo information device.\n");
 134
 135        if (sysinfo) {
 136                int res = sysinfo_get_int(sysinfo, BOARD_HWVERSION,
 137                                          &fpga_hw_rev);
 138
 139                if (res)
 140                        printf("Could not determind FPGA HW revision (res = %d)\n",
 141                               res);
 142        }
 143
 144        env_set_ulong("fpga_hw_rev", fpga_hw_rev);
 145
 146        ret = get_tpm(&tpm);
 147        if (ret || tpm_init(tpm) || tpm_startup(tpm, TPM_ST_CLEAR) ||
 148            tpm_continue_self_test(tpm)) {
 149                printf("TPM init failed\n");
 150        }
 151
 152        if (fpga_hw_rev >= 4) {
 153                for (i = 0; i < 4; i++) {
 154                        struct udevice *rxaui;
 155                        char name[8];
 156
 157                        snprintf(name, sizeof(name), "rxaui%d", i);
 158                        /* Disable RXAUI polarity inversion */
 159                        ret = uclass_get_device_by_phandle(UCLASS_MISC, sysinfo,
 160                                                           name, &rxaui);
 161                        if (!ret)
 162                                misc_set_enabled(rxaui, false);
 163                }
 164        }
 165
 166        for (uclass_first_device(UCLASS_VIDEO_OSD, &osd);
 167             osd;
 168             uclass_next_device(&osd)) {
 169                video_osd_get_info(osd, &osd_info);
 170                display_osd_info(osd, &osd_info);
 171        }
 172
 173        return 0;
 174}
 175
 176#if defined(CONFIG_OF_BOARD_SETUP)
 177int ft_board_setup(void *blob, struct bd_info *bd)
 178{
 179        ft_cpu_setup(blob, bd);
 180        fsl_fdt_fixup_dr_usb(blob, bd);
 181        fdt_fixup_esdhc(blob, bd);
 182
 183        return 0;
 184}
 185#endif
 186