Kever Yang | 6fc9ebf | 2018-12-20 11:33:42 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause |
Kever Yang | 7ae2d9f | 2017-11-28 16:04:21 +0800 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2017 Rockchip Electronics Co., Ltd. |
Kever Yang | 7ae2d9f | 2017-11-28 16:04:21 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 8 | #include <log.h> |
Kever Yang | 7ae2d9f | 2017-11-28 16:04:21 +0800 | [diff] [blame] | 9 | #include <ram.h> |
| 10 | #include <syscon.h> |
Kever Yang | 9fbe17c | 2019-03-28 11:01:23 +0800 | [diff] [blame] | 11 | #include <asm/arch-rockchip/clock.h> |
| 12 | #include <asm/arch-rockchip/grf_rk3128.h> |
Kever Yang | e47db83 | 2019-11-15 11:04:33 +0800 | [diff] [blame] | 13 | #include <asm/arch-rockchip/sdram.h> |
Kever Yang | 7ae2d9f | 2017-11-28 16:04:21 +0800 | [diff] [blame] | 14 | |
Kever Yang | 7ae2d9f | 2017-11-28 16:04:21 +0800 | [diff] [blame] | 15 | struct dram_info { |
| 16 | struct ram_info info; |
| 17 | struct rk3128_grf *grf; |
| 18 | }; |
| 19 | |
| 20 | static int rk3128_dmc_probe(struct udevice *dev) |
| 21 | { |
| 22 | struct dram_info *priv = dev_get_priv(dev); |
| 23 | |
| 24 | priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); |
| 25 | debug("%s: grf=%p\n", __func__, priv->grf); |
| 26 | priv->info.base = CONFIG_SYS_SDRAM_BASE; |
| 27 | priv->info.size = rockchip_sdram_size( |
| 28 | (phys_addr_t)&priv->grf->os_reg[1]); |
| 29 | |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | static int rk3128_dmc_get_info(struct udevice *dev, struct ram_info *info) |
| 34 | { |
| 35 | struct dram_info *priv = dev_get_priv(dev); |
| 36 | |
| 37 | *info = priv->info; |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | static struct ram_ops rk3128_dmc_ops = { |
| 43 | .get_info = rk3128_dmc_get_info, |
| 44 | }; |
| 45 | |
| 46 | static const struct udevice_id rk3128_dmc_ids[] = { |
| 47 | { .compatible = "rockchip,rk3128-dmc" }, |
| 48 | { } |
| 49 | }; |
| 50 | |
| 51 | U_BOOT_DRIVER(dmc_rk3128) = { |
| 52 | .name = "rockchip_rk3128_dmc", |
| 53 | .id = UCLASS_RAM, |
| 54 | .of_match = rk3128_dmc_ids, |
| 55 | .ops = &rk3128_dmc_ops, |
| 56 | .probe = rk3128_dmc_probe, |
| 57 | .priv_auto_alloc_size = sizeof(struct dram_info), |
| 58 | }; |