* [PATCH v1 0/3] ram: starfive: cleanup size types and typos
@ 2025-10-30 6:23 E Shattow
2025-10-30 6:23 ` [PATCH v1 1/3] ram: starfive: drop references to 16GB memory size E Shattow
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: E Shattow @ 2025-10-30 6:23 UTC (permalink / raw)
To: Minda Chen, Hal Feng, Leo Liang, Heinrich Schuchardt; +Cc: u-boot, E Shattow
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
--
2.50.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v1 1/3] ram: starfive: drop references to 16GB memory size
2025-10-30 6:23 [PATCH v1 0/3] ram: starfive: cleanup size types and typos E Shattow
@ 2025-10-30 6:23 ` E Shattow
2025-10-30 7:53 ` Heinrich Schuchardt
2025-10-30 6:23 ` [PATCH v1 2/3] ram: starfive: use SZ_8G for 8GB " E Shattow
2025-10-30 6:23 ` [PATCH v1 3/3] ram: starfive: fix typo for unsupported DDR size E Shattow
2 siblings, 1 reply; 9+ messages in thread
From: E Shattow @ 2025-10-30 6:23 UTC (permalink / raw)
To: Minda Chen, Hal Feng, Leo Liang, Heinrich Schuchardt, Tom Rini
Cc: u-boot, 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 <e@freeshell.de>
---
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(-)
diff --git a/drivers/ram/starfive/ddrcsr_boot.c b/drivers/ram/starfive/ddrcsr_boot.c
index 6764b3ed5cc..ece6f5aae94 100644
--- a/drivers/ram/starfive/ddrcsr_boot.c
+++ b/drivers/ram/starfive/ddrcsr_boot.c
@@ -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;
};
diff --git a/drivers/ram/starfive/ddrphy_start.c b/drivers/ram/starfive/ddrphy_start.c
index efe3f8a181a..f26bc9ccaad 100644
--- a/drivers/ram/starfive/ddrphy_start.c
+++ b/drivers/ram/starfive/ddrphy_start.c
@@ -267,7 +267,6 @@ void ddr_phy_start(u32 *phyreg, enum ddr_size_t size)
mask = REG8G;
break;
- case DDR_SIZE_16G:
default:
return;
};
diff --git a/drivers/ram/starfive/starfive_ddr.c b/drivers/ram/starfive/starfive_ddr.c
index b31ed3bcf61..9e902f03ee9 100644
--- a/drivers/ram/starfive/starfive_ddr.c
+++ b/drivers/ram/starfive/starfive_ddr.c
@@ -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;
diff --git a/drivers/ram/starfive/starfive_ddr.h b/drivers/ram/starfive/starfive_ddr.h
index c29d26b510c..3ab0b0e8fa6 100644
--- a/drivers/ram/starfive/starfive_ddr.h
+++ b/drivers/ram/starfive/starfive_ddr.h
@@ -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);
--
2.50.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v1 2/3] ram: starfive: use SZ_8G for 8GB memory size
2025-10-30 6:23 [PATCH v1 0/3] ram: starfive: cleanup size types and typos E Shattow
2025-10-30 6:23 ` [PATCH v1 1/3] ram: starfive: drop references to 16GB memory size E Shattow
@ 2025-10-30 6:23 ` E Shattow
2025-10-30 6:31 ` Hal Feng
2025-10-30 7:56 ` Heinrich Schuchardt
2025-10-30 6:23 ` [PATCH v1 3/3] ram: starfive: fix typo for unsupported DDR size E Shattow
2 siblings, 2 replies; 9+ messages in thread
From: E Shattow @ 2025-10-30 6:23 UTC (permalink / raw)
To: Minda Chen, Hal Feng, Leo Liang, Heinrich Schuchardt, Tom Rini
Cc: u-boot, E Shattow
Replace numeric literal with SZ_8G consistent with other uses of types
from linux/types.h
Signed-off-by: E Shattow <e@freeshell.de>
---
drivers/ram/starfive/starfive_ddr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/ram/starfive/starfive_ddr.c b/drivers/ram/starfive/starfive_ddr.c
index 9e902f03ee9..f030192f6f4 100644
--- a/drivers/ram/starfive/starfive_ddr.c
+++ b/drivers/ram/starfive/starfive_ddr.c
@@ -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;
--
2.50.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v1 3/3] ram: starfive: fix typo for unsupported DDR size
2025-10-30 6:23 [PATCH v1 0/3] ram: starfive: cleanup size types and typos E Shattow
2025-10-30 6:23 ` [PATCH v1 1/3] ram: starfive: drop references to 16GB memory size E Shattow
2025-10-30 6:23 ` [PATCH v1 2/3] ram: starfive: use SZ_8G for 8GB " E Shattow
@ 2025-10-30 6:23 ` E Shattow
2025-10-30 7:55 ` Heinrich Schuchardt
2 siblings, 1 reply; 9+ messages in thread
From: E Shattow @ 2025-10-30 6:23 UTC (permalink / raw)
To: Minda Chen, Hal Feng, Leo Liang, Heinrich Schuchardt, Tom Rini
Cc: u-boot, E Shattow
Fix typo for "unsupport" size and improve description to Unknown DDR size.
Signed-off-by: E Shattow <e@freeshell.de>
---
drivers/ram/starfive/starfive_ddr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/ram/starfive/starfive_ddr.c b/drivers/ram/starfive/starfive_ddr.c
index f030192f6f4..e151179398f 100644
--- a/drivers/ram/starfive/starfive_ddr.c
+++ b/drivers/ram/starfive/starfive_ddr.c
@@ -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;
}
--
2.50.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* RE: [PATCH v1 2/3] ram: starfive: use SZ_8G for 8GB memory size
2025-10-30 6:23 ` [PATCH v1 2/3] ram: starfive: use SZ_8G for 8GB " E Shattow
@ 2025-10-30 6:31 ` Hal Feng
2025-10-30 7:56 ` Heinrich Schuchardt
1 sibling, 0 replies; 9+ messages in thread
From: Hal Feng @ 2025-10-30 6:31 UTC (permalink / raw)
To: E Shattow, Leo Liang, Heinrich Schuchardt, Tom Rini; +Cc: u-boot@lists.denx.de
> On 30.10.25 14:24, E Shattow wrote:
> Replace numeric literal with SZ_8G consistent with other uses of types from
> linux/types.h
>
> Signed-off-by: E Shattow <e@freeshell.de>
Acked-by: Hal Feng <hal.feng@starfivetech.com>
Best regards,
Hal
> ---
> drivers/ram/starfive/starfive_ddr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/ram/starfive/starfive_ddr.c
> b/drivers/ram/starfive/starfive_ddr.c
> index 9e902f03ee9..f030192f6f4 100644
> --- a/drivers/ram/starfive/starfive_ddr.c
> +++ b/drivers/ram/starfive/starfive_ddr.c
> @@ -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;
>
> --
> 2.50.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/3] ram: starfive: drop references to 16GB memory size
2025-10-30 6:23 ` [PATCH v1 1/3] ram: starfive: drop references to 16GB memory size E Shattow
@ 2025-10-30 7:53 ` Heinrich Schuchardt
2025-11-03 4:21 ` E Shattow
0 siblings, 1 reply; 9+ messages in thread
From: Heinrich Schuchardt @ 2025-10-30 7:53 UTC (permalink / raw)
To: E Shattow; +Cc: u-boot, Minda Chen, Hal Feng, Leo Liang, Tom Rini
On 10/30/25 07:23, E Shattow wrote:
> 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 <e@freeshell.de>
> ---
> 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(-)
>
> diff --git a/drivers/ram/starfive/ddrcsr_boot.c b/drivers/ram/starfive/ddrcsr_boot.c
> index 6764b3ed5cc..ece6f5aae94 100644
> --- a/drivers/ram/starfive/ddrcsr_boot.c
> +++ b/drivers/ram/starfive/ddrcsr_boot.c
> @@ -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:
Why don't we drop the line above? It is just falling through to default.
Best regards
Heinrich
> - case DDR_SIZE_16G:
> default:
> break;
> };
> diff --git a/drivers/ram/starfive/ddrphy_start.c b/drivers/ram/starfive/ddrphy_start.c
> index efe3f8a181a..f26bc9ccaad 100644
> --- a/drivers/ram/starfive/ddrphy_start.c
> +++ b/drivers/ram/starfive/ddrphy_start.c
> @@ -267,7 +267,6 @@ void ddr_phy_start(u32 *phyreg, enum ddr_size_t size)
> mask = REG8G;
> break;
>
> - case DDR_SIZE_16G:
> default:
> return;
> };
> diff --git a/drivers/ram/starfive/starfive_ddr.c b/drivers/ram/starfive/starfive_ddr.c
> index b31ed3bcf61..9e902f03ee9 100644
> --- a/drivers/ram/starfive/starfive_ddr.c
> +++ b/drivers/ram/starfive/starfive_ddr.c
> @@ -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;
> diff --git a/drivers/ram/starfive/starfive_ddr.h b/drivers/ram/starfive/starfive_ddr.h
> index c29d26b510c..3ab0b0e8fa6 100644
> --- a/drivers/ram/starfive/starfive_ddr.h
> +++ b/drivers/ram/starfive/starfive_ddr.h
> @@ -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);
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 3/3] ram: starfive: fix typo for unsupported DDR size
2025-10-30 6:23 ` [PATCH v1 3/3] ram: starfive: fix typo for unsupported DDR size E Shattow
@ 2025-10-30 7:55 ` Heinrich Schuchardt
0 siblings, 0 replies; 9+ messages in thread
From: Heinrich Schuchardt @ 2025-10-30 7:55 UTC (permalink / raw)
To: E Shattow; +Cc: u-boot, Minda Chen, Hal Feng, Leo Liang, Tom Rini
On 10/30/25 07:23, E Shattow wrote:
> Fix typo for "unsupport" size and improve description to Unknown DDR size.
>
> Signed-off-by: E Shattow <e@freeshell.de>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> drivers/ram/starfive/starfive_ddr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/ram/starfive/starfive_ddr.c b/drivers/ram/starfive/starfive_ddr.c
> index f030192f6f4..e151179398f 100644
> --- a/drivers/ram/starfive/starfive_ddr.c
> +++ b/drivers/ram/starfive/starfive_ddr.c
> @@ -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;
> }
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 2/3] ram: starfive: use SZ_8G for 8GB memory size
2025-10-30 6:23 ` [PATCH v1 2/3] ram: starfive: use SZ_8G for 8GB " E Shattow
2025-10-30 6:31 ` Hal Feng
@ 2025-10-30 7:56 ` Heinrich Schuchardt
1 sibling, 0 replies; 9+ messages in thread
From: Heinrich Schuchardt @ 2025-10-30 7:56 UTC (permalink / raw)
To: E Shattow; +Cc: u-boot, Minda Chen, Hal Feng, Leo Liang, Tom Rini
On 10/30/25 07:23, E Shattow wrote:
> Replace numeric literal with SZ_8G consistent with other uses of types
> from linux/types.h
>
> Signed-off-by: E Shattow <e@freeshell.de>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> drivers/ram/starfive/starfive_ddr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/ram/starfive/starfive_ddr.c b/drivers/ram/starfive/starfive_ddr.c
> index 9e902f03ee9..f030192f6f4 100644
> --- a/drivers/ram/starfive/starfive_ddr.c
> +++ b/drivers/ram/starfive/starfive_ddr.c
> @@ -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;
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/3] ram: starfive: drop references to 16GB memory size
2025-10-30 7:53 ` Heinrich Schuchardt
@ 2025-11-03 4:21 ` E Shattow
0 siblings, 0 replies; 9+ messages in thread
From: E Shattow @ 2025-11-03 4:21 UTC (permalink / raw)
To: Heinrich Schuchardt; +Cc: u-boot, Minda Chen, Hal Feng, Leo Liang, Tom Rini
On 10/30/25 00:53, Heinrich Schuchardt wrote:
> On 10/30/25 07:23, E Shattow wrote:
>> 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 <e@freeshell.de>
>> ---
>> 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(-)
>>
>> diff --git a/drivers/ram/starfive/ddrcsr_boot.c b/drivers/ram/
>> starfive/ddrcsr_boot.c
>> index 6764b3ed5cc..ece6f5aae94 100644
>> --- a/drivers/ram/starfive/ddrcsr_boot.c
>> +++ b/drivers/ram/starfive/ddrcsr_boot.c
>> @@ -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:
>
> Why don't we drop the line above? It is just falling through to default.
>
> 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.
>> - case DDR_SIZE_16G:
>> default:
>> break;
>> };
>> diff --git a/drivers/ram/starfive/ddrphy_start.c b/drivers/ram/
>> starfive/ddrphy_start.c
>> index efe3f8a181a..f26bc9ccaad 100644
>> --- a/drivers/ram/starfive/ddrphy_start.c
>> +++ b/drivers/ram/starfive/ddrphy_start.c
>> @@ -267,7 +267,6 @@ void ddr_phy_start(u32 *phyreg, enum ddr_size_t size)
>> mask = REG8G;
>> break;
>> - case DDR_SIZE_16G:
>> default:
>> return;
>> };
>> diff --git a/drivers/ram/starfive/starfive_ddr.c b/drivers/ram/
>> starfive/starfive_ddr.c
>> index b31ed3bcf61..9e902f03ee9 100644
>> --- a/drivers/ram/starfive/starfive_ddr.c
>> +++ b/drivers/ram/starfive/starfive_ddr.c
>> @@ -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;
>> diff --git a/drivers/ram/starfive/starfive_ddr.h b/drivers/ram/
>> starfive/starfive_ddr.h
>> index c29d26b510c..3ab0b0e8fa6 100644
>> --- a/drivers/ram/starfive/starfive_ddr.h
>> +++ b/drivers/ram/starfive/starfive_ddr.h
>> @@ -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
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-11-03 4:22 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-30 6:23 [PATCH v1 0/3] ram: starfive: cleanup size types and typos E Shattow
2025-10-30 6:23 ` [PATCH v1 1/3] ram: starfive: drop references to 16GB memory size E Shattow
2025-10-30 7:53 ` Heinrich Schuchardt
2025-11-03 4:21 ` E Shattow
2025-10-30 6:23 ` [PATCH v1 2/3] ram: starfive: use SZ_8G for 8GB " E Shattow
2025-10-30 6:31 ` Hal Feng
2025-10-30 7:56 ` Heinrich Schuchardt
2025-10-30 6:23 ` [PATCH v1 3/3] ram: starfive: fix typo for unsupported DDR size E Shattow
2025-10-30 7:55 ` Heinrich Schuchardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox