meta-phosphor: u-boot: Refresh patch disabling unnecessary features

(From meta-phosphor rev: 80d39ceccaca886168f65dc9bc708759cddd0940)

Change-Id: Ieb2781db3825c924173ca58878682924ca07da98
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/meta-phosphor/aspeed-layer/recipes-bsp/u-boot/files/0001-aspeed-Disable-unnecessary-features.patch b/meta-phosphor/aspeed-layer/recipes-bsp/u-boot/files/0001-aspeed-Disable-unnecessary-features.patch
index 1fbf7d4..3ba91f5 100644
--- a/meta-phosphor/aspeed-layer/recipes-bsp/u-boot/files/0001-aspeed-Disable-unnecessary-features.patch
+++ b/meta-phosphor/aspeed-layer/recipes-bsp/u-boot/files/0001-aspeed-Disable-unnecessary-features.patch
@@ -1,4 +1,4 @@
-From f3082ce0d919a0f3fbe938ee8f86c28db031953b Mon Sep 17 00:00:00 2001
+From 97566253f336d85d23abef777b54dc572ca7ac9a Mon Sep 17 00:00:00 2001
 From: Andrew Jeffery <andrew@aj.id.au>
 Date: Mon, 23 Jul 2018 15:22:34 +0930
 Subject: [PATCH] aspeed: Disable unnecessary features
@@ -8,12 +8,12 @@
 
 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
 ---
- arch/arm/include/asm/arch-aspeed/regs-lpc.h  | 29 +++++++++++++
- arch/arm/include/asm/arch-aspeed/regs-scu.h  |  8 +++-
- arch/arm/include/asm/arch-aspeed/regs-sdmc.h | 17 ++++++++
- board/aspeed/ast-g4/ast-g4.c                 | 38 ++++++++++++++++-
- board/aspeed/ast-g5/ast-g5.c                 | 44 +++++++++++++++++++-
- 5 files changed, 133 insertions(+), 3 deletions(-)
+ arch/arm/include/asm/arch-aspeed/regs-lpc.h  | 29 +++++++++++
+ arch/arm/include/asm/arch-aspeed/regs-scu.h  |  8 ++-
+ arch/arm/include/asm/arch-aspeed/regs-sdmc.h | 17 +++++++
+ board/aspeed/ast-g4/ast-g4.c                 | 46 ++++++++++++++++-
+ board/aspeed/ast-g5/ast-g5.c                 | 52 +++++++++++++++++++-
+ 5 files changed, 149 insertions(+), 3 deletions(-)
  create mode 100644 arch/arm/include/asm/arch-aspeed/regs-lpc.h
 
 diff --git a/arch/arm/include/asm/arch-aspeed/regs-lpc.h b/arch/arm/include/asm/arch-aspeed/regs-lpc.h
@@ -130,7 +130,7 @@
 +
  #endif
 diff --git a/board/aspeed/ast-g4/ast-g4.c b/board/aspeed/ast-g4/ast-g4.c
-index 656495307b03..51fb5d46bf7f 100644
+index 656495307b03..5b137e7d74bc 100644
 --- a/board/aspeed/ast-g4/ast-g4.c
 +++ b/board/aspeed/ast-g4/ast-g4.c
 @@ -1,6 +1,6 @@
@@ -141,7 +141,7 @@
   *
   * SPDX-License-Identifier:     GPL-2.0+
   */
-@@ -12,13 +12,49 @@
+@@ -12,13 +12,57 @@
  #include <asm/arch/ast-sdmc.h>
  #include <asm/arch/ast_scu.h>
  #include <asm/arch/regs-ahbc.h>
@@ -154,6 +154,7 @@
  
  int board_init(void)
  {
++	bool sdmc_unlocked;
 +	u32 val;
 +
 +	/* iLPC2AHB */
@@ -174,6 +175,10 @@
 +	writel(val, AST_SCU_BASE + AST_SCU_PCIE_CONFIG_SET);
 +
 +	/* X-DMA */
++	sdmc_unlocked = readl(AST_SDMC_BASE + AST_SDMC_PROTECT);
++	if (!sdmc_unlocked)
++		writel(SDMC_PROTECT_UNLOCK, AST_SDMC_BASE + AST_SDMC_PROTECT);
++
 +	val = readl(AST_SDMC_BASE + AST_SDMC_GFX_PROT);
 +	val |= (SDMC_GFX_PROT_VGA_CURSOR
 +			| SDMC_GFX_PROT_VGA_CG_READ
@@ -183,6 +188,9 @@
 +			| SDMC_GFX_PROT_XDMA);
 +	writel(val, AST_SDMC_BASE + AST_SDMC_GFX_PROT);
 +
++	if (!sdmc_unlocked)
++		writel(~SDMC_PROTECT_UNLOCK, AST_SDMC_BASE + AST_SDMC_PROTECT);
++
 +	/* LPC2AHB */
 +	val = readl(AST_LPC_BASE + AST_LPC_HICR5);
 +	val &= ~LPC_HICR5_ENFWH;
@@ -192,7 +200,7 @@
  	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  	gd->flags = 0;
 diff --git a/board/aspeed/ast-g5/ast-g5.c b/board/aspeed/ast-g5/ast-g5.c
-index e67a4bf8b2b4..50670a8f5ecc 100644
+index e67a4bf8b2b4..12496cea09b7 100644
 --- a/board/aspeed/ast-g5/ast-g5.c
 +++ b/board/aspeed/ast-g5/ast-g5.c
 @@ -1,5 +1,5 @@
@@ -202,7 +210,7 @@
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
-@@ -12,12 +12,54 @@
+@@ -12,12 +12,62 @@
  
  #include <asm/arch/ast_scu.h>
  #include <asm/arch/ast-sdmc.h>
@@ -215,6 +223,7 @@
  
  int board_init(void)
  {
++	bool sdmc_unlocked;
 +	u32 val;
 +
 +	/* iLPC2AHB */
@@ -240,6 +249,10 @@
 +	writel(val, AST_SCU_BASE + AST_SCU_MISC1_CTRL);
 +
 +	/* X-DMA */
++	sdmc_unlocked = readl(AST_SDMC_BASE + AST_SDMC_PROTECT);
++	if (!sdmc_unlocked)
++		writel(SDMC_PROTECT_UNLOCK, AST_SDMC_BASE + AST_SDMC_PROTECT);
++
 +	val = readl(AST_SDMC_BASE + AST_SDMC_GFX_PROT);
 +	val |= (SDMC_GFX_PROT_VGA_CURSOR
 +			| SDMC_GFX_PROT_VGA_CG_READ
@@ -249,6 +262,9 @@
 +			| SDMC_GFX_PROT_XDMA);
 +	writel(val, AST_SDMC_BASE + AST_SDMC_GFX_PROT);
 +
++	if (!sdmc_unlocked)
++		writel(~SDMC_PROTECT_UNLOCK, AST_SDMC_BASE + AST_SDMC_PROTECT);
++
 +	/* LPC2AHB */
 +	val = readl(AST_LPC_BASE + AST_LPC_HICR5);
 +	val &= ~LPC_HICR5_ENFWH;
@@ -258,5 +274,5 @@
  	gd->flags = 0;
  
 -- 
-2.17.1
+2.19.1