2 * Allwinner R40 SDRAM Controller emulation
4 * Copyright (C) 2023 qianfan Zhao <qianfanguijin@163.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef HW_MISC_ALLWINNER_R40_DRAMC_H
21 #define HW_MISC_ALLWINNER_R40_DRAMC_H
23 #include "qom/object.h"
24 #include "hw/sysbus.h"
25 #include "exec/hwaddr.h"
32 /** Highest register address used by DRAMCOM module */
33 #define AW_R40_DRAMCOM_REGS_MAXADDR (0x804)
35 /** Total number of known DRAMCOM registers */
36 #define AW_R40_DRAMCOM_REGS_NUM (AW_R40_DRAMCOM_REGS_MAXADDR / \
39 /** Highest register address used by DRAMCTL module */
40 #define AW_R40_DRAMCTL_REGS_MAXADDR (0x88c)
42 /** Total number of known DRAMCTL registers */
43 #define AW_R40_DRAMCTL_REGS_NUM (AW_R40_DRAMCTL_REGS_MAXADDR / \
46 /** Highest register address used by DRAMPHY module */
47 #define AW_R40_DRAMPHY_REGS_MAXADDR (0x4)
49 /** Total number of known DRAMPHY registers */
50 #define AW_R40_DRAMPHY_REGS_NUM (AW_R40_DRAMPHY_REGS_MAXADDR / \
60 #define TYPE_AW_R40_DRAMC "allwinner-r40-dramc"
61 OBJECT_DECLARE_SIMPLE_TYPE(AwR40DramCtlState
, AW_R40_DRAMC
)
66 * Allwinner R40 SDRAM Controller object instance state.
68 struct AwR40DramCtlState
{
70 SysBusDevice parent_obj
;
73 /** Physical base address for start of RAM */
76 /** Total RAM size in megabytes */
80 uint8_t set_bank_bits
;
84 * @name Memory Regions
87 MemoryRegion dramcom_iomem
; /**< DRAMCOM module I/O registers */
88 MemoryRegion dramctl_iomem
; /**< DRAMCTL module I/O registers */
89 MemoryRegion dramphy_iomem
; /**< DRAMPHY module I/O registers */
90 MemoryRegion dram_high
; /**< The high 1G dram for dualrank detect */
91 MemoryRegion detect_cells
; /**< DRAM memory cells for auto detect */
96 * @name Hardware Registers
100 uint32_t dramcom
[AW_R40_DRAMCOM_REGS_NUM
]; /**< DRAMCOM registers */
101 uint32_t dramctl
[AW_R40_DRAMCTL_REGS_NUM
]; /**< DRAMCTL registers */
102 uint32_t dramphy
[AW_R40_DRAMPHY_REGS_NUM
] ;/**< DRAMPHY registers */
108 #endif /* HW_MISC_ALLWINNER_R40_DRAMC_H */