public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] ram: k3-ddrss: Allow use of dt provided initial frequency
@ 2022-04-08 21:46 Dave Gerlach
  2022-04-11 12:32 ` Tom Rini
  2022-04-20 19:23 ` Tom Rini
  0 siblings, 2 replies; 5+ messages in thread
From: Dave Gerlach @ 2022-04-08 21:46 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot, Praneeth Bajjuri, Dave Gerlach

Allow device tree to provide ti,ddr-freq0 to be used as the initial DDR
frequency that is set for lpddr4 before initialization of the
controller. Make this optional and continue to use PLL bypass frequency
as is done currently if ti,ddr-freq0 is not provided.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
---
 .../memory-controller/k3-j721e-ddrss.txt          |  2 ++
 drivers/ram/k3-ddrss/k3-ddrss.c                   | 15 ++++++++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/doc/device-tree-bindings/memory-controller/k3-j721e-ddrss.txt b/doc/device-tree-bindings/memory-controller/k3-j721e-ddrss.txt
index df3290a6b9d9..1ea0a701143e 100644
--- a/doc/device-tree-bindings/memory-controller/k3-j721e-ddrss.txt
+++ b/doc/device-tree-bindings/memory-controller/k3-j721e-ddrss.txt
@@ -39,6 +39,8 @@ Optional properties:
 - reg:			Must add "ss" to list if the above ss region is included.
 - ti,ecc-enable:	Boolean flag to enable ECC. This will reduce available DDR
 			by 1/9.
+- ti,ddr-freq0:		Initial frequency set point, if not provided PLL bypass
+			frequency will be used.
 
 Example (J721E):
 ================
diff --git a/drivers/ram/k3-ddrss/k3-ddrss.c b/drivers/ram/k3-ddrss/k3-ddrss.c
index 2467f122a829..5c29e31a6f30 100644
--- a/drivers/ram/k3-ddrss/k3-ddrss.c
+++ b/drivers/ram/k3-ddrss/k3-ddrss.c
@@ -134,6 +134,7 @@ struct k3_ddrss_desc {
 	struct power_domain ddrdata_pwrdmn;
 	struct clk ddr_clk;
 	struct clk osc_clk;
+	u32 ddr_freq0;
 	u32 ddr_freq1;
 	u32 ddr_freq2;
 	u32 ddr_fhs_cnt;
@@ -223,9 +224,7 @@ static void k3_lpddr4_freq_update(struct k3_ddrss_desc *ddrss)
 		else if (req_type == 2)
 			clk_set_rate(&ddrss->ddr_clk, ddrss->ddr_freq2);
 		else if (req_type == 0)
-			/* Put DDR pll in bypass mode */
-			clk_set_rate(&ddrss->ddr_clk,
-				     clk_get_rate(&ddrss->osc_clk));
+			clk_set_rate(&ddrss->ddr_clk, ddrss->ddr_freq0);
 		else
 			printf("%s: Invalid freq request type\n", __func__);
 
@@ -276,8 +275,7 @@ static int k3_ddrss_init_freq(struct k3_ddrss_desc *ddrss)
 		ret = clk_set_rate(&ddrss->ddr_clk, ddrss->ddr_freq1);
 		break;
 	case DENALI_CTL_0_DRAM_CLASS_LPDDR4:
-		/* Set to bypass frequency for LPDDR4*/
-		ret = clk_set_rate(&ddrss->ddr_clk, clk_get_rate(&ddrss->osc_clk));
+		ret = clk_set_rate(&ddrss->ddr_clk, ddrss->ddr_freq0);
 		break;
 	default:
 		ret = -EINVAL;
@@ -394,6 +392,13 @@ static int k3_ddrss_ofdata_to_priv(struct udevice *dev)
 		ddrss->instance = 0;
 	}
 
+	ret = dev_read_u32(dev, "ti,ddr-freq0", &ddrss->ddr_freq0);
+	if (ret) {
+		ddrss->ddr_freq0 = clk_get_rate(&ddrss->osc_clk);
+		dev_dbg(dev,
+			"ddr freq0 not populated, using bypass frequency.\n");
+	}
+
 	ret = dev_read_u32(dev, "ti,ddr-freq1", &ddrss->ddr_freq1);
 	if (ret)
 		dev_err(dev, "ddr freq1 not populated %d\n", ret);
-- 
2.35.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ram: k3-ddrss: Allow use of dt provided initial frequency
  2022-04-08 21:46 [PATCH] ram: k3-ddrss: Allow use of dt provided initial frequency Dave Gerlach
@ 2022-04-11 12:32 ` Tom Rini
  2022-04-12 19:32   ` Dave Gerlach
  2022-04-20 19:23 ` Tom Rini
  1 sibling, 1 reply; 5+ messages in thread
From: Tom Rini @ 2022-04-11 12:32 UTC (permalink / raw)
  To: Dave Gerlach; +Cc: u-boot, Praneeth Bajjuri

[-- Attachment #1: Type: text/plain, Size: 725 bytes --]

On Fri, Apr 08, 2022 at 04:46:50PM -0500, Dave Gerlach wrote:

> Allow device tree to provide ti,ddr-freq0 to be used as the initial DDR
> frequency that is set for lpddr4 before initialization of the
> controller. Make this optional and continue to use PLL bypass frequency
> as is done currently if ti,ddr-freq0 is not provided.
> 
> Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
> ---
>  .../memory-controller/k3-j721e-ddrss.txt          |  2 ++
>  drivers/ram/k3-ddrss/k3-ddrss.c                   | 15 ++++++++++-----
>  2 files changed, 12 insertions(+), 5 deletions(-)

What's the status of getting this binding upstreamed?  I forget if this
is one I've asked about before or not.  Thanks.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ram: k3-ddrss: Allow use of dt provided initial frequency
  2022-04-11 12:32 ` Tom Rini
@ 2022-04-12 19:32   ` Dave Gerlach
  2022-04-12 20:08     ` Tom Rini
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Gerlach @ 2022-04-12 19:32 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot, Praneeth Bajjuri

Hi,

On 4/11/22 07:32, Tom Rini wrote:
> On Fri, Apr 08, 2022 at 04:46:50PM -0500, Dave Gerlach wrote:
> 
>> Allow device tree to provide ti,ddr-freq0 to be used as the initial DDR
>> frequency that is set for lpddr4 before initialization of the
>> controller. Make this optional and continue to use PLL bypass frequency
>> as is done currently if ti,ddr-freq0 is not provided.
>>
>> Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
>> ---
>>  .../memory-controller/k3-j721e-ddrss.txt          |  2 ++
>>  drivers/ram/k3-ddrss/k3-ddrss.c                   | 15 ++++++++++-----
>>  2 files changed, 12 insertions(+), 5 deletions(-)
> 
> What's the status of getting this binding upstreamed?  I forget if this
> is one I've asked about before or not.  Thanks.
> 

I am pretty sure nobody is looking at this one, but I'd be happy to take
it up.

Regards,
Dave

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ram: k3-ddrss: Allow use of dt provided initial frequency
  2022-04-12 19:32   ` Dave Gerlach
@ 2022-04-12 20:08     ` Tom Rini
  0 siblings, 0 replies; 5+ messages in thread
From: Tom Rini @ 2022-04-12 20:08 UTC (permalink / raw)
  To: Dave Gerlach; +Cc: u-boot, Praneeth Bajjuri

[-- Attachment #1: Type: text/plain, Size: 993 bytes --]

On Tue, Apr 12, 2022 at 02:32:16PM -0500, Dave Gerlach wrote:
> Hi,
> 
> On 4/11/22 07:32, Tom Rini wrote:
> > On Fri, Apr 08, 2022 at 04:46:50PM -0500, Dave Gerlach wrote:
> > 
> >> Allow device tree to provide ti,ddr-freq0 to be used as the initial DDR
> >> frequency that is set for lpddr4 before initialization of the
> >> controller. Make this optional and continue to use PLL bypass frequency
> >> as is done currently if ti,ddr-freq0 is not provided.
> >>
> >> Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
> >> ---
> >>  .../memory-controller/k3-j721e-ddrss.txt          |  2 ++
> >>  drivers/ram/k3-ddrss/k3-ddrss.c                   | 15 ++++++++++-----
> >>  2 files changed, 12 insertions(+), 5 deletions(-)
> > 
> > What's the status of getting this binding upstreamed?  I forget if this
> > is one I've asked about before or not.  Thanks.
> 
> I am pretty sure nobody is looking at this one, but I'd be happy to take
> it up.

Great, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ram: k3-ddrss: Allow use of dt provided initial frequency
  2022-04-08 21:46 [PATCH] ram: k3-ddrss: Allow use of dt provided initial frequency Dave Gerlach
  2022-04-11 12:32 ` Tom Rini
@ 2022-04-20 19:23 ` Tom Rini
  1 sibling, 0 replies; 5+ messages in thread
From: Tom Rini @ 2022-04-20 19:23 UTC (permalink / raw)
  To: Dave Gerlach; +Cc: u-boot, Praneeth Bajjuri

[-- Attachment #1: Type: text/plain, Size: 440 bytes --]

On Fri, Apr 08, 2022 at 04:46:50PM -0500, Dave Gerlach wrote:

> Allow device tree to provide ti,ddr-freq0 to be used as the initial DDR
> frequency that is set for lpddr4 before initialization of the
> controller. Make this optional and continue to use PLL bypass frequency
> as is done currently if ti,ddr-freq0 is not provided.
> 
> Signed-off-by: Dave Gerlach <d-gerlach@ti.com>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-04-20 19:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-08 21:46 [PATCH] ram: k3-ddrss: Allow use of dt provided initial frequency Dave Gerlach
2022-04-11 12:32 ` Tom Rini
2022-04-12 19:32   ` Dave Gerlach
2022-04-12 20:08     ` Tom Rini
2022-04-20 19:23 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox