blob: a218278cb34ef138707ab3d1a9569b8b8e7840b1 [file] [log] [blame]
Sean Andersonedc32ab2020-06-24 06:41:25 -04001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2019-20 Sean Anderson <seanga2@gmail.com>
4 */
5
6#include <common.h>
7#include <clk.h>
8#include <dm.h>
9#include <fdt_support.h>
10#include <asm/io.h>
11
12phys_size_t get_effective_memsize(void)
13{
14 return CONFIG_SYS_SDRAM_SIZE;
15}
16
Sean Anderson628b5dc2021-04-08 22:13:10 -040017static int sram_init(void)
Sean Andersonedc32ab2020-06-24 06:41:25 -040018{
19 int ret, i;
Sean Anderson7be6d2b2021-04-08 22:13:11 -040020 const char * const banks[] = { "sram0", "sram1", "aisram" };
Sean Andersonedc32ab2020-06-24 06:41:25 -040021 ofnode memory;
22 struct clk clk;
23
24 /* Enable RAM clocks */
Damien Le Moal6e5a8b72022-03-01 10:35:39 +000025 memory = ofnode_by_compatible(ofnode_null(), "canaan,k210-sram");
Sean Andersonedc32ab2020-06-24 06:41:25 -040026 if (ofnode_equal(memory, ofnode_null()))
27 return -ENOENT;
28
29 for (i = 0; i < ARRAY_SIZE(banks); i++) {
30 ret = clk_get_by_name_nodev(memory, banks[i], &clk);
31 if (ret)
32 continue;
33
34 ret = clk_enable(&clk);
35 clk_free(&clk);
36 if (ret)
37 return ret;
38 }
39
Sean Anderson628b5dc2021-04-08 22:13:10 -040040 return 0;
41}
42
43int board_early_init_f(void)
44{
45 return sram_init();
46}
47
48int board_init(void)
49{
Sean Andersonedc32ab2020-06-24 06:41:25 -040050 return 0;
51}