xref: /rk3399_rockchip-uboot/drivers/ram/rockchip/sdram_rk3308.c (revision b8fa3d2a17dce6006a8a5f46cbc978a19a3fdf82)
1 /*
2  * (C) Copyright 2018 Rockchip Electronics Co., Ltd.
3  *
4  * SPDX-License-Identifier:     GPL-2.0
5  */
6 
7 #include <common.h>
8 #include <dm.h>
9 #include <ram.h>
10 #include <syscon.h>
11 #include <asm/arch/clock.h>
12 #include <asm/arch/grf_rk3308.h>
13 #include <asm/arch/sdram_common.h>
14 
15 DECLARE_GLOBAL_DATA_PTR;
16 
17 struct dram_info {
18 	struct ram_info info;
19 };
20 
21 static int rk3308_dmc_probe(struct udevice *dev)
22 {
23 	struct dram_info *priv = dev_get_priv(dev);
24 	struct rk3308_grf *grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
25 
26 	priv->info.base = CONFIG_SYS_SDRAM_BASE;
27 	priv->info.size = rockchip_sdram_size((phys_addr_t)&grf->os_reg2);
28 
29 	return 0;
30 }
31 
32 static int rk3308_dmc_get_info(struct udevice *dev, struct ram_info *info)
33 {
34 	struct dram_info *priv = dev_get_priv(dev);
35 
36 	*info = priv->info;
37 
38 	return 0;
39 }
40 
41 static struct ram_ops rk3308_dmc_ops = {
42 	.get_info = rk3308_dmc_get_info,
43 };
44 
45 
46 static const struct udevice_id rk3308_dmc_ids[] = {
47 	{ .compatible = "rockchip,rk3308-dmc" },
48 	{ }
49 };
50 
51 U_BOOT_DRIVER(dmc_rk3308) = {
52 	.name = "rockchip_rk3308_dmc",
53 	.id = UCLASS_RAM,
54 	.of_match = rk3308_dmc_ids,
55 	.ops = &rk3308_dmc_ops,
56 	.probe = rk3308_dmc_probe,
57 	.priv_auto_alloc_size = sizeof(struct dram_info),
58 };
59