sdram_rk3128.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
  2. /*
  3. * (C) Copyright 2017 Rockchip Electronics Co., Ltd.
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <ram.h>
  8. #include <syscon.h>
  9. #include <asm/arch-rockchip/clock.h>
  10. #include <asm/arch-rockchip/grf_rk3128.h>
  11. #include <asm/arch-rockchip/sdram_common.h>
  12. struct dram_info {
  13. struct ram_info info;
  14. struct rk3128_grf *grf;
  15. };
  16. static int rk3128_dmc_probe(struct udevice *dev)
  17. {
  18. struct dram_info *priv = dev_get_priv(dev);
  19. priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
  20. debug("%s: grf=%p\n", __func__, priv->grf);
  21. priv->info.base = CONFIG_SYS_SDRAM_BASE;
  22. priv->info.size = rockchip_sdram_size(
  23. (phys_addr_t)&priv->grf->os_reg[1]);
  24. return 0;
  25. }
  26. static int rk3128_dmc_get_info(struct udevice *dev, struct ram_info *info)
  27. {
  28. struct dram_info *priv = dev_get_priv(dev);
  29. *info = priv->info;
  30. return 0;
  31. }
  32. static struct ram_ops rk3128_dmc_ops = {
  33. .get_info = rk3128_dmc_get_info,
  34. };
  35. static const struct udevice_id rk3128_dmc_ids[] = {
  36. { .compatible = "rockchip,rk3128-dmc" },
  37. { }
  38. };
  39. U_BOOT_DRIVER(dmc_rk3128) = {
  40. .name = "rockchip_rk3128_dmc",
  41. .id = UCLASS_RAM,
  42. .of_match = rk3128_dmc_ids,
  43. .ops = &rk3128_dmc_ops,
  44. .probe = rk3128_dmc_probe,
  45. .priv_auto_alloc_size = sizeof(struct dram_info),
  46. };