Skip to contentSkip to conversation

ram: starfive: cleanup size types and typos

PATCH In review E Shattow 3 participants 9 messages Oct 30, 2025 – Nov 3, 2025

lore
Share & tools
lore

E Shattow

author
#0 lore raw

cover ram: starfive: cleanup size types and typos

Fix some low-hanging fruit for StarFive JH-7110 SoC DDR code.

E Shattow (3):
ram: starfive: drop references to 16GB memory size
ram: starfive: use SZ_8G for 8GB memory size
ram: starfive: fix typo for unsupported DDR size

 drivers/ram/starfive/ddrcsr_boot.c  | 3 ---
 drivers/ram/starfive/ddrphy_start.c | 1 -
 drivers/ram/starfive/starfive_ddr.c | 5 ++---
 drivers/ram/starfive/starfive_ddr.h | 1 -
 4 files changed, 2 insertions(+), 8 deletions(-)

base-commit: e34d01d23e45e007368685ffa6dfd674b6dd7b17

Signature · 1 line
2.50.0
author
#1 lore raw

PATCH 1/3 ram: starfive: drop references to 16GB memory size

16GB memory size is not addressable on StarFive JH-7110 SoC because the DRAM uncached alias begins at +8GB offset from start of DRAM. The logic for 16GB memory size is a fall-through to the default for an unknown size. Let's drop this unnecessary 16GB memory size and rely on the case default.

---
 drivers/ram/starfive/ddrcsr_boot.c  | 3 ---
 drivers/ram/starfive/ddrphy_start.c | 1 -
 drivers/ram/starfive/starfive_ddr.c | 1 -
 drivers/ram/starfive/starfive_ddr.h | 1 -
 4 files changed, 6 deletions(-)
drivers/ram/starfive/ddrcsr_boot.c +0 -3
index 6764b3ed5cc..ece6f5aae94 100644
@@ -231,7 +231,6 @@ void ddrcsr_boot(u32 *csrreg, u32 *secreg, u32 *phyreg, enum ddr_size_t size)
 		mask = REG8G;
 		break;
 
-	case DDR_SIZE_16G:
 	default:
 		return;
 	};
@@ -260,7 +259,6 @@ void ddrcsr_boot(u32 *csrreg, u32 *secreg, u32 *phyreg, enum ddr_size_t size)
 		out_le32(csrreg + REGOFFSET(0x10), 0x3c);
 		break;
 
-	case DDR_SIZE_16G:
 	default:
 		break;
 	};
@@ -286,7 +284,6 @@ void ddrcsr_boot(u32 *csrreg, u32 *secreg, u32 *phyreg, enum ddr_size_t size)
 		break;
 
 	case DDR_SIZE_2G:
-	case DDR_SIZE_16G:
 	default:
 		break;
 	};
drivers/ram/starfive/ddrphy_start.c +0 -1
index efe3f8a181a..f26bc9ccaad 100644
@@ -267,7 +267,6 @@ void ddr_phy_start(u32 *phyreg, enum ddr_size_t size)
 		mask = REG8G;
 		break;
 
-	case DDR_SIZE_16G:
 	default:
 		return;
 	};
drivers/ram/starfive/starfive_ddr.c +0 -1
index b31ed3bcf61..9e902f03ee9 100644
@@ -47,7 +47,6 @@ static int starfive_ddr_setup(struct udevice *dev, struct starfive_ddr_priv *pri
 		size = DDR_SIZE_8G;
 		break;
 
-	case 0x400000000:
 	default:
 		pr_err("unsupport size %lx\n", priv->info.size);
 		return -EINVAL;
drivers/ram/starfive/starfive_ddr.h +0 -1
index c29d26b510c..3ab0b0e8fa6 100644
@@ -48,7 +48,6 @@ enum ddr_size_t {
 	DDR_SIZE_2G,
 	DDR_SIZE_4G,
 	DDR_SIZE_8G,
-	DDR_SIZE_16G,
 };
 
 void ddr_phy_train(u32 *phyreg);
Signature · 1 line
2.50.0
#2 lore raw

Re: [PATCH v1 1/3] ram: starfive: drop references to 16GB memory size

Quoted 34 lines · E Shattow

16GB memory size is not addressable on StarFive JH-7110 SoC because the DRAM uncached alias begins at +8GB offset from start of DRAM. The logic for 16GB memory size is a fall-through to the default for an unknown size. Let's drop this unnecessary 16GB memory size and rely on the case default.

---
  drivers/ram/starfive/ddrcsr_boot.c  | 3 ---
  drivers/ram/starfive/ddrphy_start.c | 1 -
  drivers/ram/starfive/starfive_ddr.c | 1 -
  drivers/ram/starfive/starfive_ddr.h | 1 -
  4 files changed, 6 deletions(-)
drivers/ram/starfive/ddrcsr_boot.c +0 -2
index 6764b3ed5cc..ece6f5aae94 100644
@@ -231,7 +231,6 @@ void ddrcsr_boot(u32 *csrreg, u32 *secreg, u32 *phyreg, enum ddr_size_t size)
  		mask = REG8G;
  		break;
 
-	case DDR_SIZE_16G:
  	default:
  		return;
  	};
@@ -260,7 +259,6 @@ void ddrcsr_boot(u32 *csrreg, u32 *secreg, u32 *phyreg, enum ddr_size_t size)
  		out_le32(csrreg + REGOFFSET(0x10), 0x3c);
  		break;
 
-	case DDR_SIZE_16G:
  	default:
  		break;
  	};

drivers/ram/starfive/ddrcsr_boot.c void ddrcsr_boot(u32 *csrreg, u32 *secreg, u32 *phyreg, enum ddr_size_t size) · line 286

Quoted 3 lines
drivers/ram/starfive/ddrcsr_boot.c +0 -0
@@ -286,7 +284,6 @@ void ddrcsr_boot(u32 *csrreg, u32 *secreg, u32 *phyreg, enum ddr_size_t size)
  		break;
 
  	case DDR_SIZE_2G:

Why don't we drop the line above? It is just falling through to default.

Best regards

Heinrich

Quoted 40 lines
drivers/ram/starfive/ddrcsr_boot.c +0 -1
-	case DDR_SIZE_16G:
  	default:
  		break;
  	};
drivers/ram/starfive/ddrphy_start.c +0 -1
index efe3f8a181a..f26bc9ccaad 100644
@@ -267,7 +267,6 @@ void ddr_phy_start(u32 *phyreg, enum ddr_size_t size)
  		mask = REG8G;
  		break;
 
-	case DDR_SIZE_16G:
  	default:
  		return;
  	};
drivers/ram/starfive/starfive_ddr.c +0 -1
index b31ed3bcf61..9e902f03ee9 100644
@@ -47,7 +47,6 @@ static int starfive_ddr_setup(struct udevice *dev, struct starfive_ddr_priv *pri
  		size = DDR_SIZE_8G;
  		break;
 
-	case 0x400000000:
  	default:
  		pr_err("unsupport size %lx\n", priv->info.size);
  		return -EINVAL;
drivers/ram/starfive/starfive_ddr.h +0 -1
index c29d26b510c..3ab0b0e8fa6 100644
@@ -48,7 +48,6 @@ enum ddr_size_t {
  	DDR_SIZE_2G,
  	DDR_SIZE_4G,
  	DDR_SIZE_8G,
-	DDR_SIZE_16G,
  };
 
  void ddr_phy_train(u32 *phyreg);
author
#3 lore raw

Re: [PATCH v1 1/3] ram: starfive: drop references to 16GB memory size

Quoted 44 lines · Heinrich Schuchardt
Quoted 39 lines · E Shattow

16GB memory size is not addressable on StarFive JH-7110 SoC because the DRAM uncached alias begins at +8GB offset from start of DRAM. The logic for 16GB memory size is a fall-through to the default for an unknown size.
Let's drop this unnecessary 16GB memory size and rely on the case default.

---
  drivers/ram/starfive/ddrcsr_boot.c  | 3 ---

  drivers/ram/starfive/ddrphy_start.c | 1 -
  drivers/ram/starfive/starfive_ddr.c | 1 -
  drivers/ram/starfive/starfive_ddr.h | 1 -
  4 files changed, 6 deletions(-)
drivers/ram/ renamed from drivers/ram/starfive/ddrcsr_boot.c +0 -0

starfive/ddrcsr_boot.c
index 6764b3ed5cc..ece6f5aae94 100644

drivers/ram/starfive/ddrcsr_boot.c +0 -0
@@ -231,7 +231,6 @@ void ddrcsr_boot(u32 *csrreg, u32 *secreg, u32
 *phyreg, enum ddr_size_t size)
           mask = REG8G;
           break;

  -    case DDR_SIZE_16G:
      default:
          return;
      };

drivers/ram/starfive/ddrcsr_boot.c +0 -0
@@ -260,7 +259,6 @@ void ddrcsr_boot(u32 *csrreg, u32 *secreg, u32
 *phyreg, enum ddr_size_t size)
           out_le32(csrreg + REGOFFSET(0x10), 0x3c);
           break;

  -    case DDR_SIZE_16G:
      default:
          break;
      };

drivers/ram/starfive/ddrcsr_boot.c +0 -0
@@ -286,7 +284,6 @@ void ddrcsr_boot(u32 *csrreg, u32 *secreg, u32
 *phyreg, enum ddr_size_t size)
           break;
Quoted 1 line

        case DDR_SIZE_2G:

Why don't we drop the line above? It is just falling through to default.

Quoted 4 lines

Best regards

Heinrich

I hesitate to remove reachable code that is more readable and easily searchable, without a technical document published to refer to about how to initialize DDR memory. Here is code-as-documentation and the verbosity is helpful.

Quoted 33 lines
Quoted 33 lines

-    case DDR_SIZE_16G:
      default:
          break;
      };

drivers/ram/ renamed from drivers/ram/starfive/ddrphy_start.c +0 -0

starfive/ddrphy_start.c
index efe3f8a181a..f26bc9ccaad 100644

drivers/ram/starfive/ddrphy_start.c +0 -0
@@ -267,7 +267,6 @@ void ddr_phy_start(u32 *phyreg, enum ddr_size_t size)
           mask = REG8G;
           break;

  -    case DDR_SIZE_16G:
      default:
          return;
      };

drivers/ram/ renamed from drivers/ram/starfive/starfive_ddr.c +0 -0

starfive/starfive_ddr.c
index b31ed3bcf61..9e902f03ee9 100644

drivers/ram/starfive/starfive_ddr.c +0 -0
@@ -47,7 +47,6 @@ static int starfive_ddr_setup(struct udevice *dev,

struct starfive_ddr_priv *pri
          size = DDR_SIZE_8G;
          break;
  -    case 0x400000000:
      default:
          pr_err("unsupport size %lx\n", priv->info.size); return -EINVAL;

drivers/ram/ renamed from drivers/ram/starfive/starfive_ddr.h +0 -0

starfive/starfive_ddr.h
index c29d26b510c..3ab0b0e8fa6 100644
--- a/drivers/ram/starfive/starfive_ddr.h

Quoted 9 lines

drivers/ram/ enum ddr_size_t { · line 52

Quoted 8 lines

+++ b/drivers/ram/starfive/starfive_ddr.h

drivers/ram/ renamed from drivers/ram/starfive/starfive_ddr.h +0 -1
@@ -48,7 +48,6 @@ enum ddr_size_t {
       DDR_SIZE_2G,
       DDR_SIZE_4G,
       DDR_SIZE_8G,
-    DDR_SIZE_16G,
   };
     void ddr_phy_train(u32 *phyreg);

-E

author
#4 lore raw

PATCH 2/3 ram: starfive: use SZ_8G for 8GB memory size

In reply to E Shattow

Replace numeric literal with SZ_8G consistent with other uses of types from linux/types.h

---
 drivers/ram/starfive/starfive_ddr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ram/starfive/starfive_ddr.c +1 -1
index 9e902f03ee9..f030192f6f4 100644
@@ -43,7 +43,7 @@ static int starfive_ddr_setup(struct udevice *dev, struct starfive_ddr_priv *pri
 		size = DDR_SIZE_4G;
 		break;
 
-	case 0x200000000:
+	case SZ_8G:
 		size = DDR_SIZE_8G;
 		break;
 
Signature · 1 line
2.50.0
Reviewed-by on v1 2/3
#5 lore raw

Re: [PATCH v1 2/3] ram: starfive: use SZ_8G for 8GB memory size

Quoted 4 lines · E Shattow

Replace numeric literal with SZ_8G consistent with other uses of types from linux/types.h

Quoted 17 lines
---
  drivers/ram/starfive/starfive_ddr.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ram/starfive/starfive_ddr.c +1 -1
index 9e902f03ee9..f030192f6f4 100644
@@ -43,7 +43,7 @@ static int starfive_ddr_setup(struct udevice *dev, struct starfive_ddr_priv *pri
  		size = DDR_SIZE_4G;
  		break;
 
-	case 0x200000000:
+	case SZ_8G:
  		size = DDR_SIZE_8G;
  		break;
 
Acked-by on v1 2/3
#6 lore raw

RE: [PATCH v1 2/3] ram: starfive: use SZ_8G for 8GB memory size

In reply to E Shattow
Quoted 5 lines · E Shattow

Replace numeric literal with SZ_8G consistent with other uses of types from linux/types.h

Best regards,
Hal

Quoted 21 lines
---
 drivers/ram/starfive/starfive_ddr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ram/starfive/starfive_ddr.c +0 -0
index 9e902f03ee9..f030192f6f4 100644
@@ -43,7 +43,7 @@ static int starfive_ddr_setup(struct udevice *dev, struct

starfive_ddr_priv *pri

drivers/ram/starfive/starfive_ddr.c +1 -2
 		size = DDR_SIZE_4G;
 		break;
 
-	case 0x200000000:
+	case SZ_8G:
 		size = DDR_SIZE_8G;
 		break;
 
--

2.50.0

author
#7 lore raw

PATCH 3/3 ram: starfive: fix typo for unsupported DDR size

In reply to E Shattow

Fix typo for "unsupport" size and improve description to Unknown DDR size.

---
 drivers/ram/starfive/starfive_ddr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ram/starfive/starfive_ddr.c +1 -1
index f030192f6f4..e151179398f 100644
@@ -48,7 +48,7 @@ static int starfive_ddr_setup(struct udevice *dev, struct starfive_ddr_priv *pri
 		break;
 
 	default:
-		pr_err("unsupport size %lx\n", priv->info.size);
+		pr_err("Unknown DDR size %lx\n", priv->info.size);
 		return -EINVAL;
 	}
 
Signature · 1 line
2.50.0
Reviewed-by on v1 3/3
#8 lore raw

Re: [PATCH v1 3/3] ram: starfive: fix typo for unsupported DDR size

Quoted 3 lines · E Shattow

Fix typo for "unsupport" size and improve description to Unknown DDR size.

Quoted 17 lines
---
  drivers/ram/starfive/starfive_ddr.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ram/starfive/starfive_ddr.c +1 -1
index f030192f6f4..e151179398f 100644
@@ -48,7 +48,7 @@ static int starfive_ddr_setup(struct udevice *dev, struct starfive_ddr_priv *pri
  		break;
 
  	default:
-		pr_err("unsupport size %lx\n", priv->info.size);
+		pr_err("Unknown DDR size %lx\n", priv->info.size);
  		return -EINVAL;
  	}