RE: [PATCH v4 05/16] aspeed/sdmc: Add AST2700 support

2024-05-28 Thread Jamin Lin
Hi Cedric,
> From: Cédric Le Goater 
> [ ... ]
> 
> >> I don't think this is necessary to do so now. Possibly, increase the
> >> version number in the vmstate when resending a v5.
> >>
> > If I understand your request, do you mean to change as following in this
> patch?
> >
> > static const VMStateDescription vmstate_aspeed_sdmc = {
> >  .name = "aspeed.sdmc",
> >  .version_id = 1,  ---> Change 2
> >  .minimum_version_id = 1, ---> Change 2 };
> 
> yes.
> 
> 
> >> Also, all Aspeed models should be addressed and that's beyond the
> >> scope of this series.
> >>
> >
> > And create a new patch series to update all vmstate version for all ASPEED
> models?
> 
> That would be to remove migration support for Aspeed machines. For later.
> Let's address AST2700 first.
> 
> Thanks,
>
> C.
Will fix it in v5.
Thanks-Jamin


Re: [PATCH v4 05/16] aspeed/sdmc: Add AST2700 support

2024-05-28 Thread Cédric Le Goater

[ ... ]


I don't think this is necessary to do so now. Possibly, increase the version
number in the vmstate when resending a v5.


If I understand your request, do you mean to change as following in this patch?

static const VMStateDescription vmstate_aspeed_sdmc = {
 .name = "aspeed.sdmc",
 .version_id = 1,  ---> Change 2
 .minimum_version_id = 1, ---> Change 2
};


yes.



Also, all Aspeed models should be addressed and that's beyond the scope of
this series.



And create a new patch series to update all vmstate version for all ASPEED 
models?


That would be to remove migration support for Aspeed machines. For later.
Let's address AST2700 first.

Thanks,

C.



RE: [PATCH v4 05/16] aspeed/sdmc: Add AST2700 support

2024-05-28 Thread Jamin Lin
Hi Cedric,
> -Original Message-
> From: Cédric Le Goater 
> Sent: Tuesday, May 28, 2024 2:34 PM
> To: Jamin Lin ; Philippe Mathieu-Daudé
> ; Peter Maydell ; Andrew
> Jeffery ; Joel Stanley ;
> Alistair Francis ; Cleber Rosa ;
> Wainer dos Santos Moschetta ; Beraldo Leal
> ; open list:ASPEED BMCs ; open
> list:All patches CC here 
> Cc: Troy Lee ; Yunlin Tang
> 
> Subject: Re: [PATCH v4 05/16] aspeed/sdmc: Add AST2700 support
> 
> On 5/28/24 03:26, Jamin Lin wrote:
> > Hi Philippe, Cedric
> >
> >> On 27/5/24 13:18, Cédric Le Goater wrote:
> >>> On 5/27/24 12:24, Philippe Mathieu-Daudé wrote:
> >>>> Hi Jamin,
> >>>>
> >>>> On 27/5/24 10:02, Jamin Lin wrote:
> >>>>> The SDRAM memory controller(DRAMC) controls the access to external
> >>>>> DDR4 and DDR5 SDRAM and power up to DDR4 and DDR5 PHY.
> >>>>>
> >>>>> The DRAM memory controller of AST2700 is not backward compatible
> >>>>> to previous chips such AST2600, AST2500 and AST2400.
> >>>>>
> >>>>> Max memory is now 8GiB on the AST2700. Introduce new
> >>>>> aspeed_2700_sdmc and class with read/write operation and reset
> >>>>> handlers.
> >>>>>
> >>>>> Define DRAMC necessary protected registers and unprotected
> >>>>> registers for AST2700 and increase the register set to 0x1000.
> >>>>>
> >>>>> Add unlocked property to change controller protected status.
> >>>>>
> >>>>> Signed-off-by: Troy Lee 
> >>>>> Signed-off-by: Jamin Lin 
> >>>>> Reviewed-by: Cédric Le Goater 
> >>>>> ---
> >>>>>    hw/misc/aspeed_sdmc.c | 190
> >>>>> +-
> >>>>>    include/hw/misc/aspeed_sdmc.h |   5 +-
> >>>>>    2 files changed, 193 insertions(+), 2 deletions(-)
> >>>>
> >>>>
> >>>>> diff --git a/include/hw/misc/aspeed_sdmc.h
> >>>>> b/include/hw/misc/aspeed_sdmc.h index ec2d59a14f..61c979583a
> >>>>> 100644
> >>>>> --- a/include/hw/misc/aspeed_sdmc.h
> >>>>> +++ b/include/hw/misc/aspeed_sdmc.h
> >>>>> @@ -17,6 +17,7 @@ OBJECT_DECLARE_TYPE(AspeedSDMCState,
> >>>>> AspeedSDMCClass, ASPEED_SDMC)
> >>>>>    #define TYPE_ASPEED_2400_SDMC TYPE_ASPEED_SDMC
> "-ast2400"
> >>>>>    #define TYPE_ASPEED_2500_SDMC TYPE_ASPEED_SDMC
> "-ast2500"
> >>>>>    #define TYPE_ASPEED_2600_SDMC TYPE_ASPEED_SDMC
> "-ast2600"
> >>>>> +#define TYPE_ASPEED_2700_SDMC TYPE_ASPEED_SDMC "-ast2700"
> >>>>>    /*
> >>>>>     * SDMC has 174 documented registers. In addition the u-boot
> >>>>> device tree @@ -29,7 +30,7 @@
> >> OBJECT_DECLARE_TYPE(AspeedSDMCState,
> >>>>> AspeedSDMCClass, ASPEED_SDMC)
> >>>>>     * time, and the other is in the DDR-PHY IP which is used
> >>>>> during DDR-PHY
> >>>>>     * training.
> >>>>>     */
> >>>>> -#define ASPEED_SDMC_NR_REGS (0x500 >> 2)
> >>>>> +#define ASPEED_SDMC_NR_REGS (0x1000 >> 2)
> >>>>
> >>>> This change breaks the migration stream.
> >>>
> >>> Do you mean migration compat ? We never cared much about that for
> >>> the Aspeed machines.
> >>
> >> So let's just remove the VMSTATE to reduce code burden?
> >>
> >> Otherwise incrementing the vmstate.version is enough.
> >>
> >> Regards,
> >>
> >> Phil.
> > If you both okay, I will remove it.
> > Do I need to create a new patch or just update in this patch?
> 
> I don't think this is necessary to do so now. Possibly, increase the version
> number in the vmstate when resending a v5.
> 
If I understand your request, do you mean to change as following in this patch?

static const VMStateDescription vmstate_aspeed_sdmc = {
.name = "aspeed.sdmc",
.version_id = 1,  ---> Change 2
.minimum_version_id = 1, ---> Change 2
};
> Also, all Aspeed models should be addressed and that's beyond the scope of
> this series.
>

And create a new patch series to update all vmstate version for all ASPEED 
models?
Take asoeed_gpio.c for example:
static const VMStateDescription vmstate_gpio_regs = {
.name = TYPE_ASPEED_GPIO"/regs",
.version_id = 1, ---> Change 2
.minimum_version_id = 1, ---> Change --> 2
}

Thanks-Jamin
> 
> Thanks,
> 
> C.
> 



Re: [PATCH v4 05/16] aspeed/sdmc: Add AST2700 support

2024-05-28 Thread Cédric Le Goater

On 5/28/24 03:26, Jamin Lin wrote:

Hi Philippe, Cedric


On 27/5/24 13:18, Cédric Le Goater wrote:

On 5/27/24 12:24, Philippe Mathieu-Daudé wrote:

Hi Jamin,

On 27/5/24 10:02, Jamin Lin wrote:

The SDRAM memory controller(DRAMC) controls the access to external
DDR4 and DDR5 SDRAM and power up to DDR4 and DDR5 PHY.

The DRAM memory controller of AST2700 is not backward compatible to
previous chips such AST2600, AST2500 and AST2400.

Max memory is now 8GiB on the AST2700. Introduce new
aspeed_2700_sdmc and class with read/write operation and reset
handlers.

Define DRAMC necessary protected registers and unprotected registers
for AST2700 and increase the register set to 0x1000.

Add unlocked property to change controller protected status.

Signed-off-by: Troy Lee 
Signed-off-by: Jamin Lin 
Reviewed-by: Cédric Le Goater 
---
   hw/misc/aspeed_sdmc.c | 190
+-
   include/hw/misc/aspeed_sdmc.h |   5 +-
   2 files changed, 193 insertions(+), 2 deletions(-)




diff --git a/include/hw/misc/aspeed_sdmc.h
b/include/hw/misc/aspeed_sdmc.h index ec2d59a14f..61c979583a 100644
--- a/include/hw/misc/aspeed_sdmc.h
+++ b/include/hw/misc/aspeed_sdmc.h
@@ -17,6 +17,7 @@ OBJECT_DECLARE_TYPE(AspeedSDMCState,
AspeedSDMCClass, ASPEED_SDMC)
   #define TYPE_ASPEED_2400_SDMC TYPE_ASPEED_SDMC "-ast2400"
   #define TYPE_ASPEED_2500_SDMC TYPE_ASPEED_SDMC "-ast2500"
   #define TYPE_ASPEED_2600_SDMC TYPE_ASPEED_SDMC "-ast2600"
+#define TYPE_ASPEED_2700_SDMC TYPE_ASPEED_SDMC "-ast2700"
   /*
    * SDMC has 174 documented registers. In addition the u-boot
device tree @@ -29,7 +30,7 @@

OBJECT_DECLARE_TYPE(AspeedSDMCState,

AspeedSDMCClass, ASPEED_SDMC)
    * time, and the other is in the DDR-PHY IP which is used during
DDR-PHY
    * training.
    */
-#define ASPEED_SDMC_NR_REGS (0x500 >> 2)
+#define ASPEED_SDMC_NR_REGS (0x1000 >> 2)


This change breaks the migration stream.


Do you mean migration compat ? We never cared much about that for the
Aspeed machines.


So let's just remove the VMSTATE to reduce code burden?

Otherwise incrementing the vmstate.version is enough.

Regards,

Phil.

If you both okay, I will remove it.
Do I need to create a new patch or just update in this patch?


I don't think this is necessary to do so now. Possibly, increase the
version number in the vmstate when resending a v5.

Also, all Aspeed models should be addressed and that's beyond the scope
of this series.


Thanks,

C.





RE: [PATCH v4 05/16] aspeed/sdmc: Add AST2700 support

2024-05-27 Thread Jamin Lin
Hi Philippe, Cedric

> On 27/5/24 13:18, Cédric Le Goater wrote:
> > On 5/27/24 12:24, Philippe Mathieu-Daudé wrote:
> >> Hi Jamin,
> >>
> >> On 27/5/24 10:02, Jamin Lin wrote:
> >>> The SDRAM memory controller(DRAMC) controls the access to external
> >>> DDR4 and DDR5 SDRAM and power up to DDR4 and DDR5 PHY.
> >>>
> >>> The DRAM memory controller of AST2700 is not backward compatible to
> >>> previous chips such AST2600, AST2500 and AST2400.
> >>>
> >>> Max memory is now 8GiB on the AST2700. Introduce new
> >>> aspeed_2700_sdmc and class with read/write operation and reset
> >>> handlers.
> >>>
> >>> Define DRAMC necessary protected registers and unprotected registers
> >>> for AST2700 and increase the register set to 0x1000.
> >>>
> >>> Add unlocked property to change controller protected status.
> >>>
> >>> Signed-off-by: Troy Lee 
> >>> Signed-off-by: Jamin Lin 
> >>> Reviewed-by: Cédric Le Goater 
> >>> ---
> >>>   hw/misc/aspeed_sdmc.c | 190
> >>> +-
> >>>   include/hw/misc/aspeed_sdmc.h |   5 +-
> >>>   2 files changed, 193 insertions(+), 2 deletions(-)
> >>
> >>
> >>> diff --git a/include/hw/misc/aspeed_sdmc.h
> >>> b/include/hw/misc/aspeed_sdmc.h index ec2d59a14f..61c979583a 100644
> >>> --- a/include/hw/misc/aspeed_sdmc.h
> >>> +++ b/include/hw/misc/aspeed_sdmc.h
> >>> @@ -17,6 +17,7 @@ OBJECT_DECLARE_TYPE(AspeedSDMCState,
> >>> AspeedSDMCClass, ASPEED_SDMC)
> >>>   #define TYPE_ASPEED_2400_SDMC TYPE_ASPEED_SDMC "-ast2400"
> >>>   #define TYPE_ASPEED_2500_SDMC TYPE_ASPEED_SDMC "-ast2500"
> >>>   #define TYPE_ASPEED_2600_SDMC TYPE_ASPEED_SDMC "-ast2600"
> >>> +#define TYPE_ASPEED_2700_SDMC TYPE_ASPEED_SDMC "-ast2700"
> >>>   /*
> >>>    * SDMC has 174 documented registers. In addition the u-boot
> >>> device tree @@ -29,7 +30,7 @@
> OBJECT_DECLARE_TYPE(AspeedSDMCState,
> >>> AspeedSDMCClass, ASPEED_SDMC)
> >>>    * time, and the other is in the DDR-PHY IP which is used during
> >>> DDR-PHY
> >>>    * training.
> >>>    */
> >>> -#define ASPEED_SDMC_NR_REGS (0x500 >> 2)
> >>> +#define ASPEED_SDMC_NR_REGS (0x1000 >> 2)
> >>
> >> This change breaks the migration stream.
> >
> > Do you mean migration compat ? We never cared much about that for the
> > Aspeed machines.
> 
> So let's just remove the VMSTATE to reduce code burden?
> 
> Otherwise incrementing the vmstate.version is enough.
> 
> Regards,
> 
> Phil.
If you both okay, I will remove it.
Do I need to create a new patch or just update in this patch?
Thanks-Jamin





Re: [PATCH v4 05/16] aspeed/sdmc: Add AST2700 support

2024-05-27 Thread Philippe Mathieu-Daudé

On 27/5/24 13:18, Cédric Le Goater wrote:

On 5/27/24 12:24, Philippe Mathieu-Daudé wrote:

Hi Jamin,

On 27/5/24 10:02, Jamin Lin wrote:

The SDRAM memory controller(DRAMC) controls the access to external
DDR4 and DDR5 SDRAM and power up to DDR4 and DDR5 PHY.

The DRAM memory controller of AST2700 is not backward compatible
to previous chips such AST2600, AST2500 and AST2400.

Max memory is now 8GiB on the AST2700. Introduce new
aspeed_2700_sdmc and class with read/write operation and
reset handlers.

Define DRAMC necessary protected registers and
unprotected registers for AST2700 and increase
the register set to 0x1000.

Add unlocked property to change controller protected status.

Signed-off-by: Troy Lee 
Signed-off-by: Jamin Lin 
Reviewed-by: Cédric Le Goater 
---
  hw/misc/aspeed_sdmc.c | 190 +-
  include/hw/misc/aspeed_sdmc.h |   5 +-
  2 files changed, 193 insertions(+), 2 deletions(-)



diff --git a/include/hw/misc/aspeed_sdmc.h 
b/include/hw/misc/aspeed_sdmc.h

index ec2d59a14f..61c979583a 100644
--- a/include/hw/misc/aspeed_sdmc.h
+++ b/include/hw/misc/aspeed_sdmc.h
@@ -17,6 +17,7 @@ OBJECT_DECLARE_TYPE(AspeedSDMCState, 
AspeedSDMCClass, ASPEED_SDMC)

  #define TYPE_ASPEED_2400_SDMC TYPE_ASPEED_SDMC "-ast2400"
  #define TYPE_ASPEED_2500_SDMC TYPE_ASPEED_SDMC "-ast2500"
  #define TYPE_ASPEED_2600_SDMC TYPE_ASPEED_SDMC "-ast2600"
+#define TYPE_ASPEED_2700_SDMC TYPE_ASPEED_SDMC "-ast2700"
  /*
   * SDMC has 174 documented registers. In addition the u-boot device 
tree
@@ -29,7 +30,7 @@ OBJECT_DECLARE_TYPE(AspeedSDMCState, 
AspeedSDMCClass, ASPEED_SDMC)
   * time, and the other is in the DDR-PHY IP which is used during 
DDR-PHY

   * training.
   */
-#define ASPEED_SDMC_NR_REGS (0x500 >> 2)
+#define ASPEED_SDMC_NR_REGS (0x1000 >> 2)


This change breaks the migration stream.


Do you mean migration compat ? We never cared much about that
for the Aspeed machines.


So let's just remove the VMSTATE to reduce code burden?

Otherwise incrementing the vmstate.version is enough.

Regards,

Phil.



Re: [PATCH v4 05/16] aspeed/sdmc: Add AST2700 support

2024-05-27 Thread Cédric Le Goater

On 5/27/24 12:24, Philippe Mathieu-Daudé wrote:

Hi Jamin,

On 27/5/24 10:02, Jamin Lin wrote:

The SDRAM memory controller(DRAMC) controls the access to external
DDR4 and DDR5 SDRAM and power up to DDR4 and DDR5 PHY.

The DRAM memory controller of AST2700 is not backward compatible
to previous chips such AST2600, AST2500 and AST2400.

Max memory is now 8GiB on the AST2700. Introduce new
aspeed_2700_sdmc and class with read/write operation and
reset handlers.

Define DRAMC necessary protected registers and
unprotected registers for AST2700 and increase
the register set to 0x1000.

Add unlocked property to change controller protected status.

Signed-off-by: Troy Lee 
Signed-off-by: Jamin Lin 
Reviewed-by: Cédric Le Goater 
---
  hw/misc/aspeed_sdmc.c | 190 +-
  include/hw/misc/aspeed_sdmc.h |   5 +-
  2 files changed, 193 insertions(+), 2 deletions(-)




diff --git a/include/hw/misc/aspeed_sdmc.h b/include/hw/misc/aspeed_sdmc.h
index ec2d59a14f..61c979583a 100644
--- a/include/hw/misc/aspeed_sdmc.h
+++ b/include/hw/misc/aspeed_sdmc.h
@@ -17,6 +17,7 @@ OBJECT_DECLARE_TYPE(AspeedSDMCState, AspeedSDMCClass, 
ASPEED_SDMC)
  #define TYPE_ASPEED_2400_SDMC TYPE_ASPEED_SDMC "-ast2400"
  #define TYPE_ASPEED_2500_SDMC TYPE_ASPEED_SDMC "-ast2500"
  #define TYPE_ASPEED_2600_SDMC TYPE_ASPEED_SDMC "-ast2600"
+#define TYPE_ASPEED_2700_SDMC TYPE_ASPEED_SDMC "-ast2700"
  /*
   * SDMC has 174 documented registers. In addition the u-boot device tree
@@ -29,7 +30,7 @@ OBJECT_DECLARE_TYPE(AspeedSDMCState, AspeedSDMCClass, 
ASPEED_SDMC)
   * time, and the other is in the DDR-PHY IP which is used during DDR-PHY
   * training.
   */
-#define ASPEED_SDMC_NR_REGS (0x500 >> 2)
+#define ASPEED_SDMC_NR_REGS (0x1000 >> 2)


This change breaks the migration stream.


Do you mean migration compat ? We never cared much about that
for the Aspeed machines.

Thanks,

C.






  struct AspeedSDMCState {
  /*< private >*/
@@ -41,6 +42,7 @@ struct AspeedSDMCState {
  uint32_t regs[ASPEED_SDMC_NR_REGS];
  uint64_t ram_size;
  uint64_t max_ram_size;
+    bool unlocked;
  };







Re: [PATCH v4 05/16] aspeed/sdmc: Add AST2700 support

2024-05-27 Thread Philippe Mathieu-Daudé

Hi Jamin,

On 27/5/24 10:02, Jamin Lin wrote:

The SDRAM memory controller(DRAMC) controls the access to external
DDR4 and DDR5 SDRAM and power up to DDR4 and DDR5 PHY.

The DRAM memory controller of AST2700 is not backward compatible
to previous chips such AST2600, AST2500 and AST2400.

Max memory is now 8GiB on the AST2700. Introduce new
aspeed_2700_sdmc and class with read/write operation and
reset handlers.

Define DRAMC necessary protected registers and
unprotected registers for AST2700 and increase
the register set to 0x1000.

Add unlocked property to change controller protected status.

Signed-off-by: Troy Lee 
Signed-off-by: Jamin Lin 
Reviewed-by: Cédric Le Goater 
---
  hw/misc/aspeed_sdmc.c | 190 +-
  include/hw/misc/aspeed_sdmc.h |   5 +-
  2 files changed, 193 insertions(+), 2 deletions(-)




diff --git a/include/hw/misc/aspeed_sdmc.h b/include/hw/misc/aspeed_sdmc.h
index ec2d59a14f..61c979583a 100644
--- a/include/hw/misc/aspeed_sdmc.h
+++ b/include/hw/misc/aspeed_sdmc.h
@@ -17,6 +17,7 @@ OBJECT_DECLARE_TYPE(AspeedSDMCState, AspeedSDMCClass, 
ASPEED_SDMC)
  #define TYPE_ASPEED_2400_SDMC TYPE_ASPEED_SDMC "-ast2400"
  #define TYPE_ASPEED_2500_SDMC TYPE_ASPEED_SDMC "-ast2500"
  #define TYPE_ASPEED_2600_SDMC TYPE_ASPEED_SDMC "-ast2600"
+#define TYPE_ASPEED_2700_SDMC TYPE_ASPEED_SDMC "-ast2700"
  
  /*

   * SDMC has 174 documented registers. In addition the u-boot device tree
@@ -29,7 +30,7 @@ OBJECT_DECLARE_TYPE(AspeedSDMCState, AspeedSDMCClass, 
ASPEED_SDMC)
   * time, and the other is in the DDR-PHY IP which is used during DDR-PHY
   * training.
   */
-#define ASPEED_SDMC_NR_REGS (0x500 >> 2)
+#define ASPEED_SDMC_NR_REGS (0x1000 >> 2)


This change breaks the migration stream.


  struct AspeedSDMCState {
  /*< private >*/
@@ -41,6 +42,7 @@ struct AspeedSDMCState {
  uint32_t regs[ASPEED_SDMC_NR_REGS];
  uint64_t ram_size;
  uint64_t max_ram_size;
+bool unlocked;
  };





[PATCH v4 05/16] aspeed/sdmc: Add AST2700 support

2024-05-27 Thread Jamin Lin via
The SDRAM memory controller(DRAMC) controls the access to external
DDR4 and DDR5 SDRAM and power up to DDR4 and DDR5 PHY.

The DRAM memory controller of AST2700 is not backward compatible
to previous chips such AST2600, AST2500 and AST2400.

Max memory is now 8GiB on the AST2700. Introduce new
aspeed_2700_sdmc and class with read/write operation and
reset handlers.

Define DRAMC necessary protected registers and
unprotected registers for AST2700 and increase
the register set to 0x1000.

Add unlocked property to change controller protected status.

Signed-off-by: Troy Lee 
Signed-off-by: Jamin Lin 
Reviewed-by: Cédric Le Goater 
---
 hw/misc/aspeed_sdmc.c | 190 +-
 include/hw/misc/aspeed_sdmc.h |   5 +-
 2 files changed, 193 insertions(+), 2 deletions(-)

diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c
index 873d67c592..69a34903db 100644
--- a/hw/misc/aspeed_sdmc.c
+++ b/hw/misc/aspeed_sdmc.c
@@ -27,6 +27,7 @@
 #define   PROT_SOFTLOCKED0x00
 
 #define   PROT_KEY_UNLOCK 0xFC600309
+#define   PROT_2700_KEY_UNLOCK  0x1688A8A8
 #define   PROT_KEY_HARDLOCK   0xDEADDEAD /* AST2600 */
 
 /* Configuration Register */
@@ -54,6 +55,46 @@
 #define R_DRAM_TIME   (0x8c / 4)
 #define R_ECC_ERR_INJECT  (0xb4 / 4)
 
+/* AST2700 Register */
+#define R_2700_PROT (0x00 / 4)
+#define R_INT_STATUS(0x04 / 4)
+#define R_INT_CLEAR (0x08 / 4)
+#define R_INT_MASK  (0x0c / 4)
+#define R_MAIN_CONF (0x10 / 4)
+#define R_MAIN_CONTROL  (0x14 / 4)
+#define R_MAIN_STATUS   (0x18 / 4)
+#define R_ERR_STATUS(0x1c / 4)
+#define R_ECC_FAIL_STATUS   (0x78 / 4)
+#define R_ECC_FAIL_ADDR (0x7c / 4)
+#define R_ECC_TESTING_CONTROL   (0x80 / 4)
+#define R_PROT_REGION_LOCK_STATUS   (0x94 / 4)
+#define R_TEST_FAIL_ADDR(0xd4 / 4)
+#define R_TEST_FAIL_D0  (0xd8 / 4)
+#define R_TEST_FAIL_D1  (0xdc / 4)
+#define R_TEST_FAIL_D2  (0xe0 / 4)
+#define R_TEST_FAIL_D3  (0xe4 / 4)
+#define R_DBG_STATUS(0xf4 / 4)
+#define R_PHY_INTERFACE_STATUS  (0xf8 / 4)
+#define R_GRAPHIC_MEM_BASE_ADDR (0x10c / 4)
+#define R_PORT0_INTERFACE_MONITOR0  (0x240 / 4)
+#define R_PORT0_INTERFACE_MONITOR1  (0x244 / 4)
+#define R_PORT0_INTERFACE_MONITOR2  (0x248 / 4)
+#define R_PORT1_INTERFACE_MONITOR0  (0x2c0 / 4)
+#define R_PORT1_INTERFACE_MONITOR1  (0x2c4 / 4)
+#define R_PORT1_INTERFACE_MONITOR2  (0x2c8 / 4)
+#define R_PORT2_INTERFACE_MONITOR0  (0x340 / 4)
+#define R_PORT2_INTERFACE_MONITOR1  (0x344 / 4)
+#define R_PORT2_INTERFACE_MONITOR2  (0x348 / 4)
+#define R_PORT3_INTERFACE_MONITOR0  (0x3c0 / 4)
+#define R_PORT3_INTERFACE_MONITOR1  (0x3c4 / 4)
+#define R_PORT3_INTERFACE_MONITOR2  (0x3c8 / 4)
+#define R_PORT4_INTERFACE_MONITOR0  (0x440 / 4)
+#define R_PORT4_INTERFACE_MONITOR1  (0x444 / 4)
+#define R_PORT4_INTERFACE_MONITOR2  (0x448 / 4)
+#define R_PORT5_INTERFACE_MONITOR0  (0x4c0 / 4)
+#define R_PORT5_INTERFACE_MONITOR1  (0x4c4 / 4)
+#define R_PORT5_INTERFACE_MONITOR2  (0x4c8 / 4)
+
 /*
  * Configuration register Ox4 (for Aspeed AST2400 SOC)
  *
@@ -101,6 +142,19 @@
  ASPEED_SDMC_AST2500_RESERVED | ASPEED_SDMC_VGA_COMPAT |\
  ASPEED_SDMC_VGA_APERTURE(ASPEED_SDMC_VGA_64MB))
 
+/*
+ * Main Configuration register Ox10 (for Aspeed AST2700 SOC and higher)
+ *
+ */
+#define ASPEED_SDMC_AST2700_RESERVED0x2082 /* 31:16, 13, 7, 1 */
+#define ASPEED_SDMC_AST2700_DATA_SCRAMBLE   (1 << 8)
+#define ASPEED_SDMC_AST2700_ECC_ENABLE  (1 << 6)
+#define ASPEED_SDMC_AST2700_PAGE_MATCHING_ENABLE(1 << 5)
+#define ASPEED_SDMC_AST2700_DRAM_SIZE(x)((x & 0x7) << 2)
+
+#define ASPEED_SDMC_AST2700_READONLY_MASK   \
+ (ASPEED_SDMC_AST2700_RESERVED)
+
 static uint64_t aspeed_sdmc_read(void *opaque, hwaddr addr, unsigned size)
 {
 AspeedSDMCState *s = ASPEED_SDMC(opaque);
@@ -216,7 +270,7 @@ static void aspeed_sdmc_realize(DeviceState *dev, Error 
**errp)
 AspeedSDMCState *s = ASPEED_SDMC(dev);
 AspeedSDMCClass *asc = ASPEED_SDMC_GET_CLASS(s);
 
-assert(asc->max_ram_size < 4 * GiB); /* 32-bit address bus */
+assert(asc->max_ram_size < 4 * GiB || asc->is_bus64bit);
 s->max_ram_size = asc->max_ram_size;
 
 memory_region_init_io(>iomem, OBJECT(s), _sdmc_ops, s,
@@ -236,6 +290,7 @@ static const VMStateDescription vmstate_aspeed_sdmc = {
 
 static Property aspeed_sdmc_properties[] = {
 DEFINE_PROP_UINT64("max-ram-size", AspeedSDMCState, max_ram_size, 0),
+DEFINE_PROP_BOOL("unlocked", AspeedSDMCState, unlocked, false),
 DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -500,12 +555,145 @@ static const TypeInfo aspeed_2600_sdmc_info = {
 .class_init = aspeed_2600_sdmc_class_init,
 };
 
+static void aspeed_2700_sdmc_reset(DeviceState *dev)
+{
+AspeedSDMCState *s = ASPEED_SDMC(dev);
+AspeedSDMCClass *asc =