All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] imx8m: clock_imx8mq: Add the ecspi clocks
@ 2022-02-14 20:51 Angus Ainslie
  2022-02-15  0:25 ` Marek Vasut
  0 siblings, 1 reply; 9+ messages in thread
From: Angus Ainslie @ 2022-02-14 20:51 UTC (permalink / raw)
  To: NXP i.MX U-Boot Team
  Cc: Stefano Babic, Fabio Estevam, Peng Fan, Marek Vasut, Ye Li,
	Alice Guo, Angus Ainslie, Patrick Wildt, u-boot, kernel

Enable the clocks for spi buses 1 through 3

Signed-off-by: Angus Ainslie <angus@akkea.ca>
---

Changes since v1:

added MXC_CSPI_CLK to ECSPI1_CLK_ROOT mapping

 arch/arm/include/asm/arch-imx8m/imx-regs.h |  9 +++++
 arch/arm/mach-imx/imx8m/clock_imx8mq.c     | 40 ++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git a/arch/arm/include/asm/arch-imx8m/imx-regs.h b/arch/arm/include/asm/arch-imx8m/imx-regs.h
index b800da13a1..8cb499d3a3 100644
--- a/arch/arm/include/asm/arch-imx8m/imx-regs.h
+++ b/arch/arm/include/asm/arch-imx8m/imx-regs.h
@@ -94,6 +94,15 @@
 #define SRC_DDR1_RCR_CORE_RESET_N_MASK	BIT(1)
 #define SRC_DDR1_RCR_PRESET_N_MASK	BIT(0)
 
+#define IMX_CSPI1_BASE		0x30820000
+#define IMX_CSPI2_BASE		0x30830000
+#define IMX_CSPI3_BASE		0x30840000
+
+#define MXC_SPI_BASE_ADDRESSES \
+	IMX_CSPI1_BASE, \
+	IMX_CSPI2_BASE, \
+	IMX_CSPI3_BASE
+
 struct iomuxc_gpr_base_regs {
 	u32 gpr[47];
 };
diff --git a/arch/arm/mach-imx/imx8m/clock_imx8mq.c b/arch/arm/mach-imx/imx8m/clock_imx8mq.c
index 60e2218a3c..ef0249cd58 100644
--- a/arch/arm/mach-imx/imx8m/clock_imx8mq.c
+++ b/arch/arm/mach-imx/imx8m/clock_imx8mq.c
@@ -359,6 +359,8 @@ unsigned int mxc_get_clock(enum mxc_clock clk)
 		clock_get_target_val(IPG_CLK_ROOT, &val);
 		val = val & 0x3;
 		return get_root_clk(AHB_CLK_ROOT) / (val + 1);
+	case MXC_CSPI_CLK:
+		return get_root_clk(ECSPI1_CLK_ROOT);
 	case MXC_ESDHC_CLK:
 		return get_root_clk(USDHC1_CLK_ROOT);
 	case MXC_ESDHC2_CLK:
@@ -505,6 +507,31 @@ int set_clk_qspi(void)
 	return 0;
 }
 
+int set_clk_ecspi(int sel)
+{
+	int clk = ECSPI1_CLK_ROOT;
+
+	switch (sel) {
+	case 1:
+		clk = ECSPI1_CLK_ROOT;
+		break;
+	case 2:
+		clk = ECSPI2_CLK_ROOT;
+		break;
+	case 3:
+		clk = ECSPI3_CLK_ROOT;
+		break;
+	}
+
+	clock_enable(clk, 0);
+	/*
+	 * TODO: configure clock
+	 */
+	clock_enable(clk, 1);
+
+	return 0;
+}
+
 #ifdef CONFIG_FEC_MXC
 int set_clk_enet(enum enet_freq type)
 {
@@ -772,6 +799,19 @@ int clock_init(void)
 	clock_enable(CCGR_TSENSOR, 1);
 	clock_enable(CCGR_OCOTP, 1);
 
+	/*
+	 * set ecspi roots
+	 */
+	clock_enable(CCGR_ECSPI1, 0);
+	clock_enable(CCGR_ECSPI2, 0);
+	clock_enable(CCGR_ECSPI3, 0);
+	clock_set_target_val(ECSPI1_CLK_ROOT, CLK_ROOT_ON | CLK_ROOT_SOURCE_SEL(0));
+	clock_set_target_val(ECSPI2_CLK_ROOT, CLK_ROOT_ON | CLK_ROOT_SOURCE_SEL(0));
+	clock_set_target_val(ECSPI3_CLK_ROOT, CLK_ROOT_ON | CLK_ROOT_SOURCE_SEL(0));
+	clock_enable(CCGR_ECSPI1, 1);
+	clock_enable(CCGR_ECSPI2, 1);
+	clock_enable(CCGR_ECSPI3, 1);
+
 	/* config GIC ROOT to sys_pll2_200m */
 	clock_enable(CCGR_GIC, 0);
 	clock_set_target_val(GIC_CLK_ROOT,
-- 
2.25.1


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

* Re: [PATCH v2] imx8m: clock_imx8mq: Add the ecspi clocks
  2022-02-14 20:51 [PATCH v2] imx8m: clock_imx8mq: Add the ecspi clocks Angus Ainslie
@ 2022-02-15  0:25 ` Marek Vasut
  2022-02-15  0:51   ` Angus Ainslie
  0 siblings, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2022-02-15  0:25 UTC (permalink / raw)
  To: Angus Ainslie, NXP i.MX U-Boot Team
  Cc: Stefano Babic, Fabio Estevam, Peng Fan, Ye Li, Alice Guo,
	Patrick Wildt, u-boot, kernel

On 2/14/22 21:51, Angus Ainslie wrote:
> Enable the clocks for spi buses 1 through 3
> 
> Signed-off-by: Angus Ainslie <angus@akkea.ca>
> ---
> 
> Changes since v1:
> 
> added MXC_CSPI_CLK to ECSPI1_CLK_ROOT mapping
> 
>   arch/arm/include/asm/arch-imx8m/imx-regs.h |  9 +++++
>   arch/arm/mach-imx/imx8m/clock_imx8mq.c     | 40 ++++++++++++++++++++++
>   2 files changed, 49 insertions(+)

Shouldn't all this come from DT ?

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

* Re: [PATCH v2] imx8m: clock_imx8mq: Add the ecspi clocks
  2022-02-15  0:25 ` Marek Vasut
@ 2022-02-15  0:51   ` Angus Ainslie
  2022-02-15  8:01     ` Marek Vasut
  0 siblings, 1 reply; 9+ messages in thread
From: Angus Ainslie @ 2022-02-15  0:51 UTC (permalink / raw)
  To: Marek Vasut
  Cc: NXP i.MX U-Boot Team, Stefano Babic, Fabio Estevam, Peng Fan,
	Ye Li, Alice Guo, Patrick Wildt, u-boot, kernel

Hi Marek,

On 2022-02-14 16:25, Marek Vasut wrote:
> On 2/14/22 21:51, Angus Ainslie wrote:
>> Enable the clocks for spi buses 1 through 3
>> 
>> Signed-off-by: Angus Ainslie <angus@akkea.ca>
>> ---
>> 
>> Changes since v1:
>> 
>> added MXC_CSPI_CLK to ECSPI1_CLK_ROOT mapping
>> 
>>   arch/arm/include/asm/arch-imx8m/imx-regs.h |  9 +++++
>>   arch/arm/mach-imx/imx8m/clock_imx8mq.c     | 40 
>> ++++++++++++++++++++++
>>   2 files changed, 49 insertions(+)
> 
> Shouldn't all this come from DT ?

This is used in the SPL.

The imx8mq also doesn't have a DM clock driver.

Thanks
Angus

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

* Re: [PATCH v2] imx8m: clock_imx8mq: Add the ecspi clocks
  2022-02-15  0:51   ` Angus Ainslie
@ 2022-02-15  8:01     ` Marek Vasut
  2022-02-15 14:55       ` Angus Ainslie
  0 siblings, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2022-02-15  8:01 UTC (permalink / raw)
  To: Angus Ainslie
  Cc: NXP i.MX U-Boot Team, Stefano Babic, Fabio Estevam, Peng Fan,
	Ye Li, Alice Guo, Patrick Wildt, u-boot, kernel

On 2/15/22 01:51, Angus Ainslie wrote:
> Hi Marek,

Hi,

> On 2022-02-14 16:25, Marek Vasut wrote:
>> On 2/14/22 21:51, Angus Ainslie wrote:
>>> Enable the clocks for spi buses 1 through 3
>>>
>>> Signed-off-by: Angus Ainslie <angus@akkea.ca>
>>> ---
>>>
>>> Changes since v1:
>>>
>>> added MXC_CSPI_CLK to ECSPI1_CLK_ROOT mapping
>>>
>>>   arch/arm/include/asm/arch-imx8m/imx-regs.h |  9 +++++
>>>   arch/arm/mach-imx/imx8m/clock_imx8mq.c     | 40 ++++++++++++++++++++++
>>>   2 files changed, 49 insertions(+)
>>
>> Shouldn't all this come from DT ?
> 
> This is used in the SPL.
> 
> The imx8mq also doesn't have a DM clock driver.

Hmm, would it be possible to take one of the other Ms clock drivers, 
fork it into MQ one, and fill in the tables from Linux, thus creating 
the missing MQ clock driver?

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

* Re: [PATCH v2] imx8m: clock_imx8mq: Add the ecspi clocks
  2022-02-15  8:01     ` Marek Vasut
@ 2022-02-15 14:55       ` Angus Ainslie
  2022-02-15 16:45         ` Marek Vasut
  0 siblings, 1 reply; 9+ messages in thread
From: Angus Ainslie @ 2022-02-15 14:55 UTC (permalink / raw)
  To: Marek Vasut
  Cc: NXP i.MX U-Boot Team, Stefano Babic, Fabio Estevam, Peng Fan,
	Ye Li, Alice Guo, Patrick Wildt, u-boot, kernel

On 2022-02-15 00:01, Marek Vasut wrote:
> On 2/15/22 01:51, Angus Ainslie wrote:
>> On 2022-02-14 16:25, Marek Vasut wrote:
>>> On 2/14/22 21:51, Angus Ainslie wrote:
>>>> Enable the clocks for spi buses 1 through 3
>>>> 
>>>> Signed-off-by: Angus Ainslie <angus@akkea.ca>
>>>> ---
>>>> 
>>>> Changes since v1:
>>>> 
>>>> added MXC_CSPI_CLK to ECSPI1_CLK_ROOT mapping
>>>> 
>>>>   arch/arm/include/asm/arch-imx8m/imx-regs.h |  9 +++++
>>>>   arch/arm/mach-imx/imx8m/clock_imx8mq.c     | 40 
>>>> ++++++++++++++++++++++
>>>>   2 files changed, 49 insertions(+)
>>> 
>>> Shouldn't all this come from DT ?
>> 
>> This is used in the SPL.
>> 
>> The imx8mq also doesn't have a DM clock driver.
> 
> Hmm, would it be possible to take one of the other Ms clock drivers,
> fork it into MQ one, and fill in the tables from Linux, thus creating
> the missing MQ clock driver?

I've begun working on that as well. I'll send the patches once I get 
Linux to boot.

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

* Re: [PATCH v2] imx8m: clock_imx8mq: Add the ecspi clocks
  2022-02-15 14:55       ` Angus Ainslie
@ 2022-02-15 16:45         ` Marek Vasut
  2022-02-15 17:58           ` Angus Ainslie
  0 siblings, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2022-02-15 16:45 UTC (permalink / raw)
  To: Angus Ainslie
  Cc: NXP i.MX U-Boot Team, Stefano Babic, Fabio Estevam, Peng Fan,
	Ye Li, Alice Guo, Patrick Wildt, u-boot, kernel

On 2/15/22 15:55, Angus Ainslie wrote:
> On 2022-02-15 00:01, Marek Vasut wrote:
>> On 2/15/22 01:51, Angus Ainslie wrote:
>>> On 2022-02-14 16:25, Marek Vasut wrote:
>>>> On 2/14/22 21:51, Angus Ainslie wrote:
>>>>> Enable the clocks for spi buses 1 through 3
>>>>>
>>>>> Signed-off-by: Angus Ainslie <angus@akkea.ca>
>>>>> ---
>>>>>
>>>>> Changes since v1:
>>>>>
>>>>> added MXC_CSPI_CLK to ECSPI1_CLK_ROOT mapping
>>>>>
>>>>>   arch/arm/include/asm/arch-imx8m/imx-regs.h |  9 +++++
>>>>>   arch/arm/mach-imx/imx8m/clock_imx8mq.c     | 40 
>>>>> ++++++++++++++++++++++
>>>>>   2 files changed, 49 insertions(+)
>>>>
>>>> Shouldn't all this come from DT ?
>>>
>>> This is used in the SPL.
>>>
>>> The imx8mq also doesn't have a DM clock driver.
>>
>> Hmm, would it be possible to take one of the other Ms clock drivers,
>> fork it into MQ one, and fill in the tables from Linux, thus creating
>> the missing MQ clock driver?
> 
> I've begun working on that as well. I'll send the patches once I get 
> Linux to boot.

Thanks

Does it make sense to wait with this patch for after 2022.04 , when it 
might not be needed ?

I'll let Stefano decide ...

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

* Re: [PATCH v2] imx8m: clock_imx8mq: Add the ecspi clocks
  2022-02-15 16:45         ` Marek Vasut
@ 2022-02-15 17:58           ` Angus Ainslie
  2022-02-15 20:26             ` Marek Vasut
  0 siblings, 1 reply; 9+ messages in thread
From: Angus Ainslie @ 2022-02-15 17:58 UTC (permalink / raw)
  To: Marek Vasut
  Cc: NXP i.MX U-Boot Team, Stefano Babic, Fabio Estevam, Peng Fan,
	Ye Li, Alice Guo, Patrick Wildt, u-boot, kernel

On 2022-02-15 08:45, Marek Vasut wrote:
> On 2/15/22 15:55, Angus Ainslie wrote:
>> On 2022-02-15 00:01, Marek Vasut wrote:
>>> On 2/15/22 01:51, Angus Ainslie wrote:
>>>> On 2022-02-14 16:25, Marek Vasut wrote:
>>>>> On 2/14/22 21:51, Angus Ainslie wrote:
>>>>>> Enable the clocks for spi buses 1 through 3
>>>>>> 
>>>>>> Signed-off-by: Angus Ainslie <angus@akkea.ca>
>>>>>> ---
>>>>>> 
>>>>>> Changes since v1:
>>>>>> 
>>>>>> added MXC_CSPI_CLK to ECSPI1_CLK_ROOT mapping
>>>>>> 
>>>>>>   arch/arm/include/asm/arch-imx8m/imx-regs.h |  9 +++++
>>>>>>   arch/arm/mach-imx/imx8m/clock_imx8mq.c     | 40 
>>>>>> ++++++++++++++++++++++
>>>>>>   2 files changed, 49 insertions(+)
>>>>> 
>>>>> Shouldn't all this come from DT ?
>>>> 
>>>> This is used in the SPL.
>>>> 
>>>> The imx8mq also doesn't have a DM clock driver.
>>> 
>>> Hmm, would it be possible to take one of the other Ms clock drivers,
>>> fork it into MQ one, and fill in the tables from Linux, thus creating
>>> the missing MQ clock driver?
>> 
>> I've begun working on that as well. I'll send the patches once I get 
>> Linux to boot.
> 
> Thanks
> 
> Does it make sense to wait with this patch for after 2022.04 , when it
> might not be needed ?
> 
> I'll let Stefano decide ...

Ok, I'm not sure why it should get held back as it fixes ECSPI 
initialization and use in the SPL.

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

* Re: [PATCH v2] imx8m: clock_imx8mq: Add the ecspi clocks
  2022-02-15 17:58           ` Angus Ainslie
@ 2022-02-15 20:26             ` Marek Vasut
  2022-02-19 22:26               ` Stefano Babic
  0 siblings, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2022-02-15 20:26 UTC (permalink / raw)
  To: Angus Ainslie
  Cc: NXP i.MX U-Boot Team, Stefano Babic, Fabio Estevam, Peng Fan,
	Ye Li, Alice Guo, Patrick Wildt, u-boot, kernel

On 2/15/22 18:58, Angus Ainslie wrote:
> On 2022-02-15 08:45, Marek Vasut wrote:
>> On 2/15/22 15:55, Angus Ainslie wrote:
>>> On 2022-02-15 00:01, Marek Vasut wrote:
>>>> On 2/15/22 01:51, Angus Ainslie wrote:
>>>>> On 2022-02-14 16:25, Marek Vasut wrote:
>>>>>> On 2/14/22 21:51, Angus Ainslie wrote:
>>>>>>> Enable the clocks for spi buses 1 through 3
>>>>>>>
>>>>>>> Signed-off-by: Angus Ainslie <angus@akkea.ca>
>>>>>>> ---
>>>>>>>
>>>>>>> Changes since v1:
>>>>>>>
>>>>>>> added MXC_CSPI_CLK to ECSPI1_CLK_ROOT mapping
>>>>>>>
>>>>>>>   arch/arm/include/asm/arch-imx8m/imx-regs.h |  9 +++++
>>>>>>>   arch/arm/mach-imx/imx8m/clock_imx8mq.c     | 40 
>>>>>>> ++++++++++++++++++++++
>>>>>>>   2 files changed, 49 insertions(+)
>>>>>>
>>>>>> Shouldn't all this come from DT ?
>>>>>
>>>>> This is used in the SPL.
>>>>>
>>>>> The imx8mq also doesn't have a DM clock driver.
>>>>
>>>> Hmm, would it be possible to take one of the other Ms clock drivers,
>>>> fork it into MQ one, and fill in the tables from Linux, thus creating
>>>> the missing MQ clock driver?
>>>
>>> I've begun working on that as well. I'll send the patches once I get 
>>> Linux to boot.
>>
>> Thanks
>>
>> Does it make sense to wait with this patch for after 2022.04 , when it
>> might not be needed ?
>>
>> I'll let Stefano decide ...
> 
> Ok, I'm not sure why it should get held back as it fixes ECSPI 
> initialization and use in the SPL.

It also enables extra clock unconditionally and there is this "TODO" 
right in the middle of the patch.

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

* Re: [PATCH v2] imx8m: clock_imx8mq: Add the ecspi clocks
  2022-02-15 20:26             ` Marek Vasut
@ 2022-02-19 22:26               ` Stefano Babic
  0 siblings, 0 replies; 9+ messages in thread
From: Stefano Babic @ 2022-02-19 22:26 UTC (permalink / raw)
  To: Marek Vasut, Angus Ainslie
  Cc: NXP i.MX U-Boot Team, Stefano Babic, Fabio Estevam, Peng Fan,
	Ye Li, Alice Guo, Patrick Wildt, u-boot, kernel



On 15.02.22 21:26, Marek Vasut wrote:
> On 2/15/22 18:58, Angus Ainslie wrote:
>> On 2022-02-15 08:45, Marek Vasut wrote:
>>> On 2/15/22 15:55, Angus Ainslie wrote:
>>>> On 2022-02-15 00:01, Marek Vasut wrote:
>>>>> On 2/15/22 01:51, Angus Ainslie wrote:
>>>>>> On 2022-02-14 16:25, Marek Vasut wrote:
>>>>>>> On 2/14/22 21:51, Angus Ainslie wrote:
>>>>>>>> Enable the clocks for spi buses 1 through 3
>>>>>>>>
>>>>>>>> Signed-off-by: Angus Ainslie <angus@akkea.ca>
>>>>>>>> ---
>>>>>>>>
>>>>>>>> Changes since v1:
>>>>>>>>
>>>>>>>> added MXC_CSPI_CLK to ECSPI1_CLK_ROOT mapping
>>>>>>>>
>>>>>>>>   arch/arm/include/asm/arch-imx8m/imx-regs.h |  9 +++++
>>>>>>>>   arch/arm/mach-imx/imx8m/clock_imx8mq.c     | 40 
>>>>>>>> ++++++++++++++++++++++
>>>>>>>>   2 files changed, 49 insertions(+)
>>>>>>>
>>>>>>> Shouldn't all this come from DT ?
>>>>>>
>>>>>> This is used in the SPL.
>>>>>>
>>>>>> The imx8mq also doesn't have a DM clock driver.
>>>>>
>>>>> Hmm, would it be possible to take one of the other Ms clock drivers,
>>>>> fork it into MQ one, and fill in the tables from Linux, thus creating
>>>>> the missing MQ clock driver?
>>>>
>>>> I've begun working on that as well. I'll send the patches once I get 
>>>> Linux to boot.
>>>
>>> Thanks
>>>
>>> Does it make sense to wait with this patch for after 2022.04 , when it
>>> might not be needed ?
>>>
>>> I'll let Stefano decide ...
>>
>> Ok, I'm not sure why it should get held back as it fixes ECSPI 
>> initialization and use in the SPL.
> 
> It also enables extra clock unconditionally and there is this "TODO" 
> right in the middle of the patch.

Right, I agree.

Regards,
Stefano

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

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

end of thread, other threads:[~2022-02-19 22:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-14 20:51 [PATCH v2] imx8m: clock_imx8mq: Add the ecspi clocks Angus Ainslie
2022-02-15  0:25 ` Marek Vasut
2022-02-15  0:51   ` Angus Ainslie
2022-02-15  8:01     ` Marek Vasut
2022-02-15 14:55       ` Angus Ainslie
2022-02-15 16:45         ` Marek Vasut
2022-02-15 17:58           ` Angus Ainslie
2022-02-15 20:26             ` Marek Vasut
2022-02-19 22:26               ` Stefano Babic

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.