ram: starfive: cleanup size types and typos
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
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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 2/3 ram: starfive: use SZ_8G for 8GB memory size
In reply to E ShattowReplace 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
@@ -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
PATCH 3/3 ram: starfive: fix typo for unsupported DDR size
In reply to E ShattowFix 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
@@ -48,7 +48,7 @@ static int starfive_ddr_setup(struct udevice *dev, struct starfive_ddr_priv *pribreak ;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
Re: [PATCH v1 1/3] ram: starfive: drop references to 16GB memory size
In reply to E ShattowQuoted 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.
Signed-off-by E Shattow <[email protected]>--- 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@@ -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@@ -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@@ -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@@ -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);
Re: [PATCH v1 3/3] ram: starfive: fix typo for unsupported DDR size
In reply to E ShattowQuoted 3 lines · E Shattow
Fix typo for "unsupport" size and improve description to Unknown DDR size.
Signed-off-by E Shattow <[email protected]>
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@@ -48,7 +48,7 @@ static int starfive_ddr_setup(struct udevice *dev, struct starfive_ddr_priv *pribreak ;default : -pr_err ("unsupport size %lx\n" , priv->info.size); +pr_err ("Unknown DDR size %lx\n" , priv->info.size);return -EINVAL ; }
Re: [PATCH v1 2/3] ram: starfive: use SZ_8G for 8GB memory size
In reply to E ShattowQuoted 4 lines · E Shattow
Replace numeric literal with
SZ_8Gconsistent with other uses of types fromlinux/types.hSigned-off-by E Shattow <[email protected]>
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@@ -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 ;
RE: [PATCH v1 2/3] ram: starfive: use SZ_8G for 8GB memory size
In reply to E ShattowQuoted 5 lines · E Shattow
Replace numeric literal with
SZ_8Gconsistent with other uses of types fromlinux/types.hSigned-off-by E Shattow <[email protected]>
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@@ -43,7 +43,7 @@ static int starfive_ddr_setup(struct udevice *dev, struct
starfive_ddr_priv*pridrivers/ram/starfive/starfive_ddr.c +1
-2size =DDR_SIZE_4G ;break ; -case 0x200000000 : +case SZ_8G : size =DDR_SIZE_8G ;break ; --2.50.0
Re: [PATCH v1 1/3] ram: starfive: drop references to 16GB memory size
In reply to Heinrich SchuchardtQuoted 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.Signed-off-by E Shattow <[email protected]>---
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
index6764b3ed5cc..ece6f5aae94100644drivers/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
indexefe3f8a181a..f26bc9ccaad100644drivers/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
indexb31ed3bcf61..9e902f03ee9100644drivers/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;
- case0x400000000:
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
indexc29d26b510c..3ab0b0e8fa6100644
---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.hdrivers/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