uboot/board/mscc/serval/serval.c
<<
>>
Prefs
   1// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
   2/*
   3 * Copyright (c) 2018 Microsemi Corporation
   4 */
   5
   6#include <common.h>
   7#include <image.h>
   8#include <init.h>
   9#include <asm/global_data.h>
  10#include <asm/io.h>
  11#include <led.h>
  12#include <miiphy.h>
  13
  14enum {
  15        BOARD_TYPE_PCB106 = 0xAABBCD00,
  16        BOARD_TYPE_PCB105,
  17};
  18
  19int board_early_init_r(void)
  20{
  21        /* Prepare SPI controller to be used in master mode */
  22        writel(0, BASE_CFG + ICPU_SW_MODE);
  23
  24        /* Address of boot parameters */
  25        gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE;
  26
  27        return 0;
  28}
  29
  30int board_phy_config(struct phy_device *phydev)
  31{
  32        phy_write(phydev, 0, 31, 0x10);
  33        phy_write(phydev, 0, 18, 0x80F0);
  34        while (phy_read(phydev, 0, 18) & 0x8000)
  35                ;
  36        phy_write(phydev, 0, 14, 0x800);
  37        phy_write(phydev, 0, 31, 0);
  38        return 0;
  39}
  40
  41static void do_board_detect(void)
  42{
  43        u16 gpio_in_reg;
  44
  45        /* Set MDIO and MDC */
  46        mscc_gpio_set_alternate(9, 2);
  47        mscc_gpio_set_alternate(10, 2);
  48
  49        /* Set GPIO page */
  50        mscc_phy_wr(1, 16, 31, 0x10);
  51        if (!mscc_phy_rd(1, 16, 15, &gpio_in_reg)) {
  52                if (gpio_in_reg & 0x200)
  53                        gd->board_type = BOARD_TYPE_PCB106;
  54                else
  55                        gd->board_type = BOARD_TYPE_PCB105;
  56        } else {
  57                gd->board_type = BOARD_TYPE_PCB105;
  58        }
  59        mscc_phy_wr(1, 16, 31, 0x0);
  60}
  61
  62#if defined(CONFIG_MULTI_DTB_FIT)
  63int board_fit_config_name_match(const char *name)
  64{
  65        if (gd->board_type == BOARD_TYPE_PCB106 &&
  66            strcmp(name, "serval_pcb106") == 0)
  67                return 0;
  68
  69        if (gd->board_type == BOARD_TYPE_PCB105 &&
  70            strcmp(name, "serval_pcb105") == 0)
  71                return 0;
  72
  73        return -1;
  74}
  75#endif
  76
  77#if defined(CONFIG_DTB_RESELECT)
  78int embedded_dtb_select(void)
  79{
  80        do_board_detect();
  81        fdtdec_setup();
  82
  83        return 0;
  84}
  85#endif
  86