xref: /qemu/include/hw/misc/aspeed_sdmc.h (revision 14c179541bbf083f4b215ddb389828ad8b9d0b28) !
1c2da8a8bSCédric Le Goater /*
2c2da8a8bSCédric Le Goater  * ASPEED SDRAM Memory Controller
3c2da8a8bSCédric Le Goater  *
4c2da8a8bSCédric Le Goater  * Copyright (C) 2016 IBM Corp.
5c2da8a8bSCédric Le Goater  *
6c2da8a8bSCédric Le Goater  * This code is licensed under the GPL version 2 or later. See the
7c2da8a8bSCédric Le Goater  * COPYING file in the top-level directory.
8c2da8a8bSCédric Le Goater  */
9c2da8a8bSCédric Le Goater #ifndef ASPEED_SDMC_H
10c2da8a8bSCédric Le Goater #define ASPEED_SDMC_H
11c2da8a8bSCédric Le Goater 
12c2da8a8bSCédric Le Goater #include "hw/sysbus.h"
13c2da8a8bSCédric Le Goater 
14c2da8a8bSCédric Le Goater #define TYPE_ASPEED_SDMC "aspeed.sdmc"
15c2da8a8bSCédric Le Goater #define ASPEED_SDMC(obj) OBJECT_CHECK(AspeedSDMCState, (obj), TYPE_ASPEED_SDMC)
168e00d1a9SCédric Le Goater #define TYPE_ASPEED_2400_SDMC TYPE_ASPEED_SDMC "-ast2400"
178e00d1a9SCédric Le Goater #define TYPE_ASPEED_2500_SDMC TYPE_ASPEED_SDMC "-ast2500"
181550d726SJoel Stanley #define TYPE_ASPEED_2600_SDMC TYPE_ASPEED_SDMC "-ast2600"
19c2da8a8bSCédric Le Goater 
20*14c17954SJoel Stanley /*
21*14c17954SJoel Stanley  * SDMC has 174 documented registers. In addition the u-boot device tree
22*14c17954SJoel Stanley  * describes the following regions:
23*14c17954SJoel Stanley  *  - PHY status regs at offset 0x400, length 0x200
24*14c17954SJoel Stanley  *  - PHY setting regs at offset 0x100, length 0x300
25*14c17954SJoel Stanley  *
26*14c17954SJoel Stanley  * There are two sets of MRS (Mode Registers) configuration in ast2600 memory
27*14c17954SJoel Stanley  * system: one is in the SDRAM MC (memory controller) which is used in run
28*14c17954SJoel Stanley  * time, and the other is in the DDR-PHY IP which is used during DDR-PHY
29*14c17954SJoel Stanley  * training.
30*14c17954SJoel Stanley  */
31*14c17954SJoel Stanley #define ASPEED_SDMC_NR_REGS (0x500 >> 2)
32c2da8a8bSCédric Le Goater 
33c2da8a8bSCédric Le Goater typedef struct AspeedSDMCState {
34c2da8a8bSCédric Le Goater     /*< private >*/
35c2da8a8bSCédric Le Goater     SysBusDevice parent_obj;
36c2da8a8bSCédric Le Goater 
37c2da8a8bSCédric Le Goater     /*< public >*/
38c2da8a8bSCédric Le Goater     MemoryRegion iomem;
39c2da8a8bSCédric Le Goater 
40c2da8a8bSCédric Le Goater     uint32_t regs[ASPEED_SDMC_NR_REGS];
41c6c7cfb0SCédric Le Goater     uint64_t ram_size;
42ebe31c0aSCédric Le Goater     uint64_t max_ram_size;
43c2da8a8bSCédric Le Goater } AspeedSDMCState;
44c2da8a8bSCédric Le Goater 
458e00d1a9SCédric Le Goater #define ASPEED_SDMC_CLASS(klass) \
468e00d1a9SCédric Le Goater      OBJECT_CLASS_CHECK(AspeedSDMCClass, (klass), TYPE_ASPEED_SDMC)
478e00d1a9SCédric Le Goater #define ASPEED_SDMC_GET_CLASS(obj) \
488e00d1a9SCédric Le Goater      OBJECT_GET_CLASS(AspeedSDMCClass, (obj), TYPE_ASPEED_SDMC)
498e00d1a9SCédric Le Goater 
508e00d1a9SCédric Le Goater typedef struct AspeedSDMCClass {
518e00d1a9SCédric Le Goater     SysBusDeviceClass parent_class;
528e00d1a9SCédric Le Goater 
538e00d1a9SCédric Le Goater     uint64_t max_ram_size;
54533eb415SIgor Mammedov     const uint64_t *valid_ram_sizes;
558e00d1a9SCédric Le Goater     uint32_t (*compute_conf)(AspeedSDMCState *s, uint32_t data);
568e00d1a9SCédric Le Goater     void (*write)(AspeedSDMCState *s, uint32_t reg, uint32_t data);
578e00d1a9SCédric Le Goater } AspeedSDMCClass;
588e00d1a9SCédric Le Goater 
59c2da8a8bSCédric Le Goater #endif /* ASPEED_SDMC_H */
60