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 | 1385674 | 2017-06-23 16:11:07 +0800 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2017 Rockchip Electronics Co., Ltd. |
Kever Yang | 1385674 | 2017-06-23 16:11:07 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
| 8 | #include <ram.h> |
| 9 | #include <syscon.h> |
Kever Yang | 9fbe17c | 2019-03-28 11:01:23 +0800 | [diff] [blame] | 10 | #include <asm/arch-rockchip/clock.h> |
| 11 | #include <asm/arch-rockchip/grf_rk3328.h> |
| 12 | #include <asm/arch-rockchip/sdram_common.h> |
Kever Yang | 1385674 | 2017-06-23 16:11:07 +0800 | [diff] [blame] | 13 | |
Kever Yang | 1385674 | 2017-06-23 16:11:07 +0800 | [diff] [blame] | 14 | struct dram_info { |
| 15 | struct ram_info info; |
| 16 | struct rk3328_grf_regs *grf; |
| 17 | }; |
| 18 | |
| 19 | static int rk3328_dmc_probe(struct udevice *dev) |
| 20 | { |
| 21 | struct dram_info *priv = dev_get_priv(dev); |
| 22 | |
| 23 | priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); |
| 24 | debug("%s: grf=%p\n", __func__, priv->grf); |
| 25 | priv->info.base = CONFIG_SYS_SDRAM_BASE; |
| 26 | priv->info.size = rockchip_sdram_size( |
| 27 | (phys_addr_t)&priv->grf->os_reg[2]); |
| 28 | |
| 29 | return 0; |
| 30 | } |
| 31 | |
| 32 | static int rk3328_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 rk3328_dmc_ops = { |
| 42 | .get_info = rk3328_dmc_get_info, |
| 43 | }; |
| 44 | |
| 45 | |
| 46 | static const struct udevice_id rk3328_dmc_ids[] = { |
| 47 | { .compatible = "rockchip,rk3328-dmc" }, |
| 48 | { } |
| 49 | }; |
| 50 | |
| 51 | U_BOOT_DRIVER(dmc_rk3328) = { |
| 52 | .name = "rockchip_rk3328_dmc", |
| 53 | .id = UCLASS_RAM, |
| 54 | .of_match = rk3328_dmc_ids, |
| 55 | .ops = &rk3328_dmc_ops, |
| 56 | .probe = rk3328_dmc_probe, |
| 57 | .priv_auto_alloc_size = sizeof(struct dram_info), |
| 58 | }; |