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" 13db1015e9SEduardo Habkost #include "qom/object.h" 14c2da8a8bSCédric Le Goater 15c2da8a8bSCédric Le Goater #define TYPE_ASPEED_SDMC "aspeed.sdmc" 16*a489d195SEduardo Habkost OBJECT_DECLARE_TYPE(AspeedSDMCState, AspeedSDMCClass, ASPEED_SDMC) 178e00d1a9SCédric Le Goater #define TYPE_ASPEED_2400_SDMC TYPE_ASPEED_SDMC "-ast2400" 188e00d1a9SCédric Le Goater #define TYPE_ASPEED_2500_SDMC TYPE_ASPEED_SDMC "-ast2500" 191550d726SJoel Stanley #define TYPE_ASPEED_2600_SDMC TYPE_ASPEED_SDMC "-ast2600" 20c2da8a8bSCédric Le Goater 2114c17954SJoel Stanley /* 2214c17954SJoel Stanley * SDMC has 174 documented registers. In addition the u-boot device tree 2314c17954SJoel Stanley * describes the following regions: 2414c17954SJoel Stanley * - PHY status regs at offset 0x400, length 0x200 2514c17954SJoel Stanley * - PHY setting regs at offset 0x100, length 0x300 2614c17954SJoel Stanley * 2714c17954SJoel Stanley * There are two sets of MRS (Mode Registers) configuration in ast2600 memory 2814c17954SJoel Stanley * system: one is in the SDRAM MC (memory controller) which is used in run 2914c17954SJoel Stanley * time, and the other is in the DDR-PHY IP which is used during DDR-PHY 3014c17954SJoel Stanley * training. 3114c17954SJoel Stanley */ 3214c17954SJoel Stanley #define ASPEED_SDMC_NR_REGS (0x500 >> 2) 33c2da8a8bSCédric Le Goater 34db1015e9SEduardo Habkost struct AspeedSDMCState { 35c2da8a8bSCédric Le Goater /*< private >*/ 36c2da8a8bSCédric Le Goater SysBusDevice parent_obj; 37c2da8a8bSCédric Le Goater 38c2da8a8bSCédric Le Goater /*< public >*/ 39c2da8a8bSCédric Le Goater MemoryRegion iomem; 40c2da8a8bSCédric Le Goater 41c2da8a8bSCédric Le Goater uint32_t regs[ASPEED_SDMC_NR_REGS]; 42c6c7cfb0SCédric Le Goater uint64_t ram_size; 43ebe31c0aSCédric Le Goater uint64_t max_ram_size; 44db1015e9SEduardo Habkost }; 45c2da8a8bSCédric Le Goater 468e00d1a9SCédric Le Goater 47db1015e9SEduardo Habkost struct AspeedSDMCClass { 488e00d1a9SCédric Le Goater SysBusDeviceClass parent_class; 498e00d1a9SCédric Le Goater 508e00d1a9SCédric Le Goater uint64_t max_ram_size; 51533eb415SIgor Mammedov const uint64_t *valid_ram_sizes; 528e00d1a9SCédric Le Goater uint32_t (*compute_conf)(AspeedSDMCState *s, uint32_t data); 538e00d1a9SCédric Le Goater void (*write)(AspeedSDMCState *s, uint32_t reg, uint32_t data); 54db1015e9SEduardo Habkost }; 558e00d1a9SCédric Le Goater 56c2da8a8bSCédric Le Goater #endif /* ASPEED_SDMC_H */ 57