uboot/arch/arm/mach-rockchip/rk3188-board.c
<<
>>
Prefs
   1/*
   2 * (C) Copyright 2015 Google, Inc
   3 *
   4 * SPDX-License-Identifier:     GPL-2.0+
   5 */
   6
   7#include <common.h>
   8#include <clk.h>
   9#include <dm.h>
  10#include <ram.h>
  11#include <syscon.h>
  12#include <asm/io.h>
  13#include <asm/arch/clock.h>
  14#include <asm/arch/grf_rk3188.h>
  15#include <asm/arch/periph.h>
  16#include <asm/arch/pmu_rk3288.h>
  17#include <asm/arch/boot_mode.h>
  18#include <asm/gpio.h>
  19#include <dm/pinctrl.h>
  20
  21DECLARE_GLOBAL_DATA_PTR;
  22
  23int board_late_init(void)
  24{
  25        struct rk3188_grf *grf;
  26
  27        grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
  28        if (IS_ERR(grf)) {
  29                error("grf syscon returned %ld\n", PTR_ERR(grf));
  30        } else {
  31                /* enable noc remap to mimic legacy loaders */
  32                rk_clrsetreg(&grf->soc_con0,
  33                        NOC_REMAP_MASK << NOC_REMAP_SHIFT,
  34                        NOC_REMAP_MASK << NOC_REMAP_SHIFT);
  35        }
  36
  37        return 0;
  38}
  39
  40int board_init(void)
  41{
  42#if defined(CONFIG_ROCKCHIP_SPL_BACK_TO_BROM)
  43        struct udevice *pinctrl;
  44        int ret;
  45
  46        /*
  47         * We need to implement sdcard iomux here for the further
  48         * initialization, otherwise, it'll hit sdcard command sending
  49         * timeout exception.
  50         */
  51        ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
  52        if (ret) {
  53                debug("%s: Cannot find pinctrl device\n", __func__);
  54                goto err;
  55        }
  56        ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_SDCARD);
  57        if (ret) {
  58                debug("%s: Failed to set up SD card\n", __func__);
  59                goto err;
  60        }
  61
  62        return 0;
  63err:
  64        printf("board_init: Error %d\n", ret);
  65
  66        /* No way to report error here */
  67        hang();
  68
  69        return -1;
  70#else
  71        return 0;
  72#endif
  73}
  74
  75int dram_init(void)
  76{
  77        struct ram_info ram;
  78        struct udevice *dev;
  79        int ret;
  80
  81        ret = uclass_get_device(UCLASS_RAM, 0, &dev);
  82        if (ret) {
  83                debug("DRAM init failed: %d\n", ret);
  84                return ret;
  85        }
  86        ret = ram_get_info(dev, &ram);
  87        if (ret) {
  88                debug("Cannot get DRAM size: %d\n", ret);
  89                return ret;
  90        }
  91        debug("SDRAM base=%lx, size=%x\n", ram.base, ram.size);
  92        gd->ram_size = ram.size;
  93
  94        return 0;
  95}
  96
  97#ifndef CONFIG_SYS_DCACHE_OFF
  98void enable_caches(void)
  99{
 100        /* Enable D-cache. I-cache is already enabled in start.S */
 101        dcache_enable();
 102}
 103#endif
 104