rockchip: use 'arch-rockchip' as header file path
[oweals/u-boot.git] / arch / arm / mach-rockchip / rk3288-board-spl.c
index 8a1066ccf886c31bcb262945ccd631c5b9fa61a2..937a99db53c3a628cbec04477a2697b0aec4ba86 100644 (file)
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2015 Google, Inc
- *
- * SPDX-License-Identifier:     GPL-2.0+
  */
 
 #include <common.h>
 #include <malloc.h>
 #include <ram.h>
 #include <spl.h>
-#include <asm/armv7.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
-#include <asm/arch/bootrom.h>
-#include <asm/arch/clock.h>
-#include <asm/arch/hardware.h>
-#include <asm/arch/periph.h>
-#include <asm/arch/sdram.h>
-#include <asm/arch/timer.h>
+#include <asm/arch-rockchip/bootrom.h>
+#include <asm/arch-rockchip/clock.h>
+#include <asm/arch-rockchip/hardware.h>
+#include <asm/arch-rockchip/periph.h>
+#include <asm/arch-rockchip/pmu_rk3288.h>
+#include <asm/arch-rockchip/sdram.h>
+#include <asm/arch-rockchip/sdram_common.h>
+#include <asm/arch-rockchip/sys_proto.h>
+#include <asm/arch-rockchip/timer.h>
 #include <dm/pinctrl.h>
 #include <dm/root.h>
 #include <dm/test.h>
@@ -50,7 +51,7 @@ u32 spl_boot_device(void)
                debug("node=%d\n", node);
                goto fallback;
        }
-       ret = device_get_global_by_of_offset(node, &dev);
+       ret = device_get_global_by_ofnode(offset_to_ofnode(node), &dev);
        if (ret) {
                debug("device at node %s/%d not found: %d\n", bootdev, node,
                      ret);
@@ -70,75 +71,13 @@ u32 spl_boot_device(void)
 fallback:
 #elif defined(CONFIG_TARGET_CHROMEBOOK_JERRY) || \
                defined(CONFIG_TARGET_CHROMEBIT_MICKEY) || \
-               defined(CONFIG_TARGET_CHROMEBOOK_MINNIE)
+               defined(CONFIG_TARGET_CHROMEBOOK_MINNIE) || \
+               defined(CONFIG_TARGET_CHROMEBOOK_SPEEDY)
        return BOOT_DEVICE_SPI;
 #endif
        return BOOT_DEVICE_MMC1;
 }
 
-u32 spl_boot_mode(const u32 boot_device)
-{
-       return MMCSD_MODE_RAW;
-}
-
-static void configure_l2ctlr(void)
-{
-       uint32_t l2ctlr;
-
-       l2ctlr = read_l2ctlr();
-       l2ctlr &= 0xfffc0000; /* clear bit0~bit17 */
-
-       /*
-       * Data RAM write latency: 2 cycles
-       * Data RAM read latency: 2 cycles
-       * Data RAM setup latency: 1 cycle
-       * Tag RAM write latency: 1 cycle
-       * Tag RAM read latency: 1 cycle
-       * Tag RAM setup latency: 1 cycle
-       */
-       l2ctlr |= (1 << 3 | 1 << 0);
-       write_l2ctlr(l2ctlr);
-}
-
-#ifdef CONFIG_SPL_MMC_SUPPORT
-static int configure_emmc(struct udevice *pinctrl)
-{
-#if defined(CONFIG_TARGET_CHROMEBOOK_JERRY)
-
-       struct gpio_desc desc;
-       int ret;
-
-       pinctrl_request_noflags(pinctrl, PERIPH_ID_EMMC);
-
-       /*
-        * TODO(sjg@chromium.org): Pick this up from device tree or perhaps
-        * use the EMMC_PWREN setting.
-        */
-       ret = dm_gpio_lookup_name("D9", &desc);
-       if (ret) {
-               debug("gpio ret=%d\n", ret);
-               return ret;
-       }
-       ret = dm_gpio_request(&desc, "emmc_pwren");
-       if (ret) {
-               debug("gpio_request ret=%d\n", ret);
-               return ret;
-       }
-       ret = dm_gpio_set_dir_flags(&desc, GPIOD_IS_OUT);
-       if (ret) {
-               debug("gpio dir ret=%d\n", ret);
-               return ret;
-       }
-       ret = dm_gpio_set_value(&desc, 1);
-       if (ret) {
-               debug("gpio value ret=%d\n", ret);
-               return ret;
-       }
-#endif
-       return 0;
-}
-#endif
-
 #if !defined(CONFIG_SPL_OF_PLATDATA)
 static int phycore_init(void)
 {
@@ -167,12 +106,11 @@ static int phycore_init(void)
 
 void board_init_f(ulong dummy)
 {
-       struct udevice *pinctrl;
        struct udevice *dev;
        int ret;
 
        /* Example code showing how to enable the debug UART on RK3288 */
-#include <asm/arch/grf_rk3288.h>
+#include <asm/arch-rockchip/grf_rk3288.h>
        /* Enable early UART on the RK3288 */
 #define GRF_BASE       0xff770000
        struct rk3288_grf * const grf = (void *)GRF_BASE;
@@ -206,12 +144,6 @@ void board_init_f(ulong dummy)
                return;
        }
 
-       ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
-       if (ret) {
-               debug("Pinctrl init failed: %d\n", ret);
-               return;
-       }
-
 #if !defined(CONFIG_SPL_OF_PLATDATA)
        if (of_machine_is_compatible("phytec,rk3288-phycore-som")) {
                ret = phycore_init();
@@ -223,14 +155,17 @@ void board_init_f(ulong dummy)
        }
 #endif
 
+#if !defined(CONFIG_SUPPORT_TPL)
        debug("\nspl:init dram\n");
        ret = uclass_get_device(UCLASS_RAM, 0, &dev);
        if (ret) {
                debug("DRAM init failed: %d\n", ret);
                return;
        }
+#endif
+
 #if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM) && !defined(CONFIG_SPL_BOARD_INIT)
-       back_to_bootrom();
+       back_to_bootrom(BROM_BOOT_NEXTSTAGE);
 #endif
 }
 
@@ -259,50 +194,32 @@ static int setup_led(void)
 
 void spl_board_init(void)
 {
-       struct udevice *pinctrl;
        int ret;
 
        ret = setup_led();
-
        if (ret) {
                debug("LED ret=%d\n", ret);
                hang();
        }
 
-       ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
-       if (ret) {
-               debug("%s: Cannot find pinctrl device\n", __func__);
-               goto err;
-       }
-
-#ifdef CONFIG_SPL_MMC_SUPPORT
-       ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_SDCARD);
-       if (ret) {
-               debug("%s: Failed to set up SD card\n", __func__);
-               goto err;
-       }
-       ret = configure_emmc(pinctrl);
-       if (ret) {
-               debug("%s: Failed to set up eMMC\n", __func__);
-               goto err;
-       }
-#endif
-
-       /* Enable debug UART */
-       ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_UART_DBG);
-       if (ret) {
-               debug("%s: Failed to set up console UART\n", __func__);
-               goto err;
-       }
-
        preloader_console_init();
 #if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM)
-       back_to_bootrom();
+       back_to_bootrom(BROM_BOOT_NEXTSTAGE);
 #endif
        return;
-err:
-       printf("spl_board_init: Error %d\n", ret);
+}
+
+#ifdef CONFIG_SPL_OS_BOOT
+
+#define PMU_BASE               0xff730000
+int dram_init_banksize(void)
+{
+       struct rk3288_pmu *const pmu = (void *)PMU_BASE;
+       size_t size = rockchip_sdram_size((phys_addr_t)&pmu->sys_reg[2]);
 
-       /* No way to report error here */
-       hang();
+       gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
+       gd->bd->bi_dram[0].size = size;
+
+       return 0;
 }
+#endif