aspeed_sdmc.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * ASPEED SDRAM Memory Controller
  3. *
  4. * Copyright (C) 2016 IBM Corp.
  5. *
  6. * This code is licensed under the GPL version 2 or later. See the
  7. * COPYING file in the top-level directory.
  8. */
  9. #ifndef ASPEED_SDMC_H
  10. #define ASPEED_SDMC_H
  11. #include "hw/sysbus.h"
  12. #include "qom/object.h"
  13. #define TYPE_ASPEED_SDMC "aspeed.sdmc"
  14. OBJECT_DECLARE_TYPE(AspeedSDMCState, AspeedSDMCClass, ASPEED_SDMC)
  15. #define TYPE_ASPEED_2400_SDMC TYPE_ASPEED_SDMC "-ast2400"
  16. #define TYPE_ASPEED_2500_SDMC TYPE_ASPEED_SDMC "-ast2500"
  17. #define TYPE_ASPEED_2600_SDMC TYPE_ASPEED_SDMC "-ast2600"
  18. /*
  19. * SDMC has 174 documented registers. In addition the u-boot device tree
  20. * describes the following regions:
  21. * - PHY status regs at offset 0x400, length 0x200
  22. * - PHY setting regs at offset 0x100, length 0x300
  23. *
  24. * There are two sets of MRS (Mode Registers) configuration in ast2600 memory
  25. * system: one is in the SDRAM MC (memory controller) which is used in run
  26. * time, and the other is in the DDR-PHY IP which is used during DDR-PHY
  27. * training.
  28. */
  29. #define ASPEED_SDMC_NR_REGS (0x500 >> 2)
  30. struct AspeedSDMCState {
  31. /*< private >*/
  32. SysBusDevice parent_obj;
  33. /*< public >*/
  34. MemoryRegion iomem;
  35. uint32_t regs[ASPEED_SDMC_NR_REGS];
  36. uint64_t ram_size;
  37. uint64_t max_ram_size;
  38. };
  39. struct AspeedSDMCClass {
  40. SysBusDeviceClass parent_class;
  41. uint64_t max_ram_size;
  42. const uint64_t *valid_ram_sizes;
  43. uint32_t (*compute_conf)(AspeedSDMCState *s, uint32_t data);
  44. void (*write)(AspeedSDMCState *s, uint32_t reg, uint32_t data);
  45. };
  46. #endif /* ASPEED_SDMC_H */