]>
Commit | Line | Data |
---|---|---|
c2da8a8b CLG |
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 | ||
12 | #include "hw/sysbus.h" | |
db1015e9 | 13 | #include "qom/object.h" |
c2da8a8b CLG |
14 | |
15 | #define TYPE_ASPEED_SDMC "aspeed.sdmc" | |
db1015e9 EH |
16 | typedef struct AspeedSDMCClass AspeedSDMCClass; |
17 | typedef struct AspeedSDMCState AspeedSDMCState; | |
c2da8a8b | 18 | #define ASPEED_SDMC(obj) OBJECT_CHECK(AspeedSDMCState, (obj), TYPE_ASPEED_SDMC) |
8e00d1a9 CLG |
19 | #define TYPE_ASPEED_2400_SDMC TYPE_ASPEED_SDMC "-ast2400" |
20 | #define TYPE_ASPEED_2500_SDMC TYPE_ASPEED_SDMC "-ast2500" | |
1550d726 | 21 | #define TYPE_ASPEED_2600_SDMC TYPE_ASPEED_SDMC "-ast2600" |
c2da8a8b | 22 | |
14c17954 JS |
23 | /* |
24 | * SDMC has 174 documented registers. In addition the u-boot device tree | |
25 | * describes the following regions: | |
26 | * - PHY status regs at offset 0x400, length 0x200 | |
27 | * - PHY setting regs at offset 0x100, length 0x300 | |
28 | * | |
29 | * There are two sets of MRS (Mode Registers) configuration in ast2600 memory | |
30 | * system: one is in the SDRAM MC (memory controller) which is used in run | |
31 | * time, and the other is in the DDR-PHY IP which is used during DDR-PHY | |
32 | * training. | |
33 | */ | |
34 | #define ASPEED_SDMC_NR_REGS (0x500 >> 2) | |
c2da8a8b | 35 | |
db1015e9 | 36 | struct AspeedSDMCState { |
c2da8a8b CLG |
37 | /*< private >*/ |
38 | SysBusDevice parent_obj; | |
39 | ||
40 | /*< public >*/ | |
41 | MemoryRegion iomem; | |
42 | ||
43 | uint32_t regs[ASPEED_SDMC_NR_REGS]; | |
c6c7cfb0 | 44 | uint64_t ram_size; |
ebe31c0a | 45 | uint64_t max_ram_size; |
db1015e9 | 46 | }; |
c2da8a8b | 47 | |
8e00d1a9 CLG |
48 | #define ASPEED_SDMC_CLASS(klass) \ |
49 | OBJECT_CLASS_CHECK(AspeedSDMCClass, (klass), TYPE_ASPEED_SDMC) | |
50 | #define ASPEED_SDMC_GET_CLASS(obj) \ | |
51 | OBJECT_GET_CLASS(AspeedSDMCClass, (obj), TYPE_ASPEED_SDMC) | |
52 | ||
db1015e9 | 53 | struct AspeedSDMCClass { |
8e00d1a9 CLG |
54 | SysBusDeviceClass parent_class; |
55 | ||
56 | uint64_t max_ram_size; | |
533eb415 | 57 | const uint64_t *valid_ram_sizes; |
8e00d1a9 CLG |
58 | uint32_t (*compute_conf)(AspeedSDMCState *s, uint32_t data); |
59 | void (*write)(AspeedSDMCState *s, uint32_t reg, uint32_t data); | |
db1015e9 | 60 | }; |
8e00d1a9 | 61 | |
c2da8a8b | 62 | #endif /* ASPEED_SDMC_H */ |