blob: 816540e5821459fbfff4b5d953f3ee2e70cf2cf7 [file] [log] [blame]
Simon Glass2444dae2015-08-30 16:55:38 -06001/*
2 * (C) Copyright 2015 Google, Inc
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
Simon Glass74e53e02016-01-21 19:45:07 -07008#include <clk.h>
Simon Glass2444dae2015-08-30 16:55:38 -06009#include <dm.h>
10#include <ram.h>
huang linbe1d5e02015-11-17 14:20:27 +080011#include <asm/io.h>
Stephen Warren135aa952016-06-17 09:44:00 -060012#include <asm/arch/clock.h>
Simon Glass2444dae2015-08-30 16:55:38 -060013
14DECLARE_GLOBAL_DATA_PTR;
15
16int board_init(void)
17{
18 return 0;
19}
20
21int dram_init(void)
22{
23 struct ram_info ram;
24 struct udevice *dev;
25 int ret;
26
27 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
28 if (ret) {
29 debug("DRAM init failed: %d\n", ret);
30 return ret;
31 }
32 ret = ram_get_info(dev, &ram);
33 if (ret) {
34 debug("Cannot get DRAM size: %d\n", ret);
35 return ret;
36 }
37 debug("SDRAM base=%lx, size=%x\n", ram.base, ram.size);
38 gd->ram_size = ram.size;
39
40 return 0;
41}
42
43#ifndef CONFIG_SYS_DCACHE_OFF
44void enable_caches(void)
45{
46 /* Enable D-cache. I-cache is already enabled in start.S */
47 dcache_enable();
48}
49#endif
Simon Glassad443b72016-01-21 19:45:06 -070050
51void lowlevel_init(void)
52{
53}
Simon Glass74e53e02016-01-21 19:45:07 -070054
55static int do_clock(cmd_tbl_t *cmdtp, int flag, int argc,
56 char * const argv[])
57{
Stephen Warren135aa952016-06-17 09:44:00 -060058 static const struct {
59 char *name;
60 int id;
61 } clks[] = {
62 { "osc", CLK_OSC },
63 { "apll", CLK_ARM },
64 { "dpll", CLK_DDR },
65 { "cpll", CLK_CODEC },
66 { "gpll", CLK_GENERAL },
67#ifdef CONFIG_ROCKCHIP_RK3036
68 { "mpll", CLK_NEW },
69#else
70 { "npll", CLK_NEW },
71#endif
72 };
73 int ret, i;
Simon Glass74e53e02016-01-21 19:45:07 -070074 struct udevice *dev;
75
Stephen Warren135aa952016-06-17 09:44:00 -060076 ret = uclass_get_device(UCLASS_CLK, 0, &dev);
77 if (ret) {
78 printf("clk-uclass not found\n");
79 return 0;
80 }
81
82 for (i = 0; i < ARRAY_SIZE(clks); i++) {
83 struct clk clk;
Simon Glass74e53e02016-01-21 19:45:07 -070084 ulong rate;
85
Stephen Warren135aa952016-06-17 09:44:00 -060086 clk.id = clks[i].id;
87 ret = clk_request(dev, &clk);
88 if (ret < 0)
89 continue;
90
91 rate = clk_get_rate(&clk);
92 printf("%s: %lu\n", clks[i].name, rate);
93
94 clk_free(&clk);
Simon Glass74e53e02016-01-21 19:45:07 -070095 }
96
97 return 0;
98}
99
100U_BOOT_CMD(
101 clock, 2, 1, do_clock,
102 "display information about clocks",
103 ""
104);