diff mbox series

[U-Boot,1/2] arm: Add minimal support for Cortex-R5

Message ID 0662f83f37aa9e9fe96cb1b940ea9bac947512a9.1524232297.git.michal.simek@xilinx.com
State Changes Requested
Delegated to: Tom Rini
Headers show
Series [U-Boot,1/2] arm: Add minimal support for Cortex-R5 | expand

Commit Message

Michal Simek April 20, 2018, 1:51 p.m. UTC
This minimal support will be used by Xilinx ZynqMP R5 cpu.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 arch/arm/Kconfig              |  6 ++++++
 arch/arm/cpu/armv7r/Makefile  |  4 ++++
 arch/arm/cpu/armv7r/config.mk |  3 +++
 arch/arm/cpu/armv7r/cpu.c     | 24 ++++++++++++++++++++++++
 arch/arm/cpu/armv7r/start.S   | 17 +++++++++++++++++
 5 files changed, 54 insertions(+)
 create mode 100644 arch/arm/cpu/armv7r/Makefile
 create mode 100644 arch/arm/cpu/armv7r/config.mk
 create mode 100644 arch/arm/cpu/armv7r/cpu.c
 create mode 100644 arch/arm/cpu/armv7r/start.S

Comments

Lokesh Vutla April 23, 2018, 3:53 a.m. UTC | #1
On Friday 20 April 2018 07:21 PM, Michal Simek wrote:
> This minimal support will be used by Xilinx ZynqMP R5 cpu.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
>  arch/arm/Kconfig              |  6 ++++++
>  arch/arm/cpu/armv7r/Makefile  |  4 ++++
>  arch/arm/cpu/armv7r/config.mk |  3 +++
>  arch/arm/cpu/armv7r/cpu.c     | 24 ++++++++++++++++++++++++
>  arch/arm/cpu/armv7r/start.S   | 17 +++++++++++++++++
>  5 files changed, 54 insertions(+)
>  create mode 100644 arch/arm/cpu/armv7r/Makefile
>  create mode 100644 arch/arm/cpu/armv7r/config.mk
>  create mode 100644 arch/arm/cpu/armv7r/cpu.c
>  create mode 100644 arch/arm/cpu/armv7r/start.S
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index b5fbce03667d..b10804f55224 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -192,6 +192,10 @@ config CPU_V7M
>  	select THUMB2_KERNEL
>  	select SYS_CACHE_SHIFT_5
>  
> +config CPU_V7R
> +	bool
> +	select SYS_CACHE_SHIFT_6

select HAS_THUMB2 might be a good option?

> +
>  config CPU_PXA
>  	bool
>  	select SYS_CACHE_SHIFT_5
> @@ -209,6 +213,7 @@ config SYS_CPU
>  	default "arm1176" if CPU_ARM1176
>  	default "armv7" if CPU_V7
>  	default "armv7m" if CPU_V7M
> +	default "armv7r" if CPU_V7R
>  	default "pxa" if CPU_PXA
>  	default "sa1100" if CPU_SA1100
>  	default "armv8" if ARM64
> @@ -223,6 +228,7 @@ config SYS_ARM_ARCH
>  	default 6 if CPU_ARM1176
>  	default 7 if CPU_V7
>  	default 7 if CPU_V7M
> +	default 7 if CPU_V7R
>  	default 5 if CPU_PXA
>  	default 4 if CPU_SA1100
>  	default 8 if ARM64

I did a grep of CPU_V7, and you might want to update for CPU_V7R in the
following places:

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 4fa8b38397..f4bc1f250d 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -18,6 +18,7 @@ arch-$(CONFIG_CPU_ARM1136)	=-march=armv5
 arch-$(CONFIG_CPU_ARM1176)	=-march=armv5t
 arch-$(CONFIG_CPU_V7)		=$(call cc-option, -march=armv7-a, \
 				 $(call cc-option, -march=armv7, -march=armv5))
+arch-$(CONFIG_CPU_V7R)		=-march=armv7-r
 arch-$(CONFIG_ARM64)		=-march=armv8-a

 # On Tegra systems we must build SPL for the armv4 core on the device
@@ -41,6 +42,7 @@ tune-$(CONFIG_CPU_PXA)		=-mcpu=xscale
 tune-$(CONFIG_CPU_ARM1136)	=
 tune-$(CONFIG_CPU_ARM1176)	=
 tune-$(CONFIG_CPU_V7)		=
+tune-$(CONFIG_CPU_V7R)		=
 tune-$(CONFIG_ARM64)		=

 # Evaluate tune cc-option calls now


> diff --git a/arch/arm/cpu/armv7r/Makefile b/arch/arm/cpu/armv7r/Makefile
> new file mode 100644
> index 000000000000..3c66976dfa62
> --- /dev/null
> +++ b/arch/arm/cpu/armv7r/Makefile

hmm..do we really need to create a separate folder? IIUC, the main
difference between V7 and V7R is MMU vs MPU. IMHO, we should be able to
get it using Kconfigs.

Thanks and regards,
Lokesh

> @@ -0,0 +1,4 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +extra-y := start.o
> +obj-y += cpu.o
> diff --git a/arch/arm/cpu/armv7r/config.mk b/arch/arm/cpu/armv7r/config.mk
> new file mode 100644
> index 000000000000..224d191ff846
> --- /dev/null
> +++ b/arch/arm/cpu/armv7r/config.mk
> @@ -0,0 +1,3 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +PLATFORM_CPPFLAGS += -mcpu=cortex-r5 -DARMR5
> diff --git a/arch/arm/cpu/armv7r/cpu.c b/arch/arm/cpu/armv7r/cpu.c
> new file mode 100644
> index 000000000000..e384a530c5e0
> --- /dev/null
> +++ b/arch/arm/cpu/armv7r/cpu.c
> @@ -0,0 +1,24 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * (C) Copyright 2018 Xilinx, Inc. (Michal Simek)
> + */
> +
> +#include <common.h>
> +
> +/*
> + * This is called right before passing control to
> + * the Linux kernel point.
> + */
> +int cleanup_before_linux(void)
> +{
> +	return 0;
> +}
> +
> +/*
> + * Perform the low-level reset.
> + */
> +void reset_cpu(ulong addr)
> +{
> +	while (1)
> +		;
> +}
> diff --git a/arch/arm/cpu/armv7r/start.S b/arch/arm/cpu/armv7r/start.S
> new file mode 100644
> index 000000000000..d6e8eecf54b7
> --- /dev/null
> +++ b/arch/arm/cpu/armv7r/start.S
> @@ -0,0 +1,17 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * (C) Copyright 2015
> + * Kamil Lulko, <kamil.lulko@gmail.com>
> + *
> + */
> +
> +#include <asm/assembler.h>
> +
> +.globl	reset
> +.type reset, %function
> +reset:
> +	W(b)	_main
> +
> +.globl	c_runtime_cpu_setup
> +c_runtime_cpu_setup:
> +	mov	pc, lr
>
Michal Simek April 23, 2018, 6:26 a.m. UTC | #2
On 23.4.2018 05:53, Lokesh Vutla wrote:
> 
> 
> On Friday 20 April 2018 07:21 PM, Michal Simek wrote:
>> This minimal support will be used by Xilinx ZynqMP R5 cpu.
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> ---
>>
>>  arch/arm/Kconfig              |  6 ++++++
>>  arch/arm/cpu/armv7r/Makefile  |  4 ++++
>>  arch/arm/cpu/armv7r/config.mk |  3 +++
>>  arch/arm/cpu/armv7r/cpu.c     | 24 ++++++++++++++++++++++++
>>  arch/arm/cpu/armv7r/start.S   | 17 +++++++++++++++++
>>  5 files changed, 54 insertions(+)
>>  create mode 100644 arch/arm/cpu/armv7r/Makefile
>>  create mode 100644 arch/arm/cpu/armv7r/config.mk
>>  create mode 100644 arch/arm/cpu/armv7r/cpu.c
>>  create mode 100644 arch/arm/cpu/armv7r/start.S
>>
>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>> index b5fbce03667d..b10804f55224 100644
>> --- a/arch/arm/Kconfig
>> +++ b/arch/arm/Kconfig
>> @@ -192,6 +192,10 @@ config CPU_V7M
>>  	select THUMB2_KERNEL
>>  	select SYS_CACHE_SHIFT_5
>>  
>> +config CPU_V7R
>> +	bool
>> +	select SYS_CACHE_SHIFT_6
> 
> select HAS_THUMB2 might be a good option?

I didn't enable it because I didn't test it.
It can be added when someone tests this.

> 
>> +
>>  config CPU_PXA
>>  	bool
>>  	select SYS_CACHE_SHIFT_5
>> @@ -209,6 +213,7 @@ config SYS_CPU
>>  	default "arm1176" if CPU_ARM1176
>>  	default "armv7" if CPU_V7
>>  	default "armv7m" if CPU_V7M
>> +	default "armv7r" if CPU_V7R
>>  	default "pxa" if CPU_PXA
>>  	default "sa1100" if CPU_SA1100
>>  	default "armv8" if ARM64
>> @@ -223,6 +228,7 @@ config SYS_ARM_ARCH
>>  	default 6 if CPU_ARM1176
>>  	default 7 if CPU_V7
>>  	default 7 if CPU_V7M
>> +	default 7 if CPU_V7R
>>  	default 5 if CPU_PXA
>>  	default 4 if CPU_SA1100
>>  	default 8 if ARM64
> 
> I did a grep of CPU_V7, and you might want to update for CPU_V7R in the
> following places:
> 
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index 4fa8b38397..f4bc1f250d 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -18,6 +18,7 @@ arch-$(CONFIG_CPU_ARM1136)	=-march=armv5
>  arch-$(CONFIG_CPU_ARM1176)	=-march=armv5t
>  arch-$(CONFIG_CPU_V7)		=$(call cc-option, -march=armv7-a, \
>  				 $(call cc-option, -march=armv7, -march=armv5))
> +arch-$(CONFIG_CPU_V7R)		=-march=armv7-r

I have setup PLATFORM_CPPFLAGS via config.mk

If both options are selected I am getting this compilation warning.
cc1: warning: switch -mcpu=cortex-r5 conflicts with -march=armv7-r switch

Not sure which one is better or if it is better to have this arch flag
via this makefile or as platform cppflags via config.mk.
I choose the second option because it seems to me better if this is in
subfolder. But not a problem to use different flag and put it to this
Makefile.

The same style is used for cpu_v7m.

>  arch-$(CONFIG_ARM64)		=-march=armv8-a
> 
>  # On Tegra systems we must build SPL for the armv4 core on the device
> @@ -41,6 +42,7 @@ tune-$(CONFIG_CPU_PXA)		=-mcpu=xscale
>  tune-$(CONFIG_CPU_ARM1136)	=
>  tune-$(CONFIG_CPU_ARM1176)	=
>  tune-$(CONFIG_CPU_V7)		=
> +tune-$(CONFIG_CPU_V7R)		=

Again as above. I used v7m as pattern and there is also empty tune
parameter. Is there any good reason to have it empty?

>  tune-$(CONFIG_ARM64)		=
> 
>  # Evaluate tune cc-option calls now
> 
> 
>> diff --git a/arch/arm/cpu/armv7r/Makefile b/arch/arm/cpu/armv7r/Makefile
>> new file mode 100644
>> index 000000000000..3c66976dfa62
>> --- /dev/null
>> +++ b/arch/arm/cpu/armv7r/Makefile
> 
> hmm..do we really need to create a separate folder? IIUC, the main
> difference between V7 and V7R is MMU vs MPU. IMHO, we should be able to
> get it using Kconfigs.

I have used V7 for the initial port and then was checking V7M which is
already there and used it as pattern for writing this patch.

I have debugged V7 and found that I need to disable CONFIG_HAS_VBAR
that's why I have created new symbol as for V7M.

Definitely I am open to hear your suggestions.

Thanks,
Michal
Lokesh Vutla April 24, 2018, 4:45 a.m. UTC | #3
Hi Michal,

On Monday 23 April 2018 11:56 AM, Michal Simek wrote:
> On 23.4.2018 05:53, Lokesh Vutla wrote:
>>
>>
>> On Friday 20 April 2018 07:21 PM, Michal Simek wrote:
>>> This minimal support will be used by Xilinx ZynqMP R5 cpu.
>>>
>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>>> ---
>>>
>>>  arch/arm/Kconfig              |  6 ++++++
>>>  arch/arm/cpu/armv7r/Makefile  |  4 ++++
>>>  arch/arm/cpu/armv7r/config.mk |  3 +++
>>>  arch/arm/cpu/armv7r/cpu.c     | 24 ++++++++++++++++++++++++
>>>  arch/arm/cpu/armv7r/start.S   | 17 +++++++++++++++++
>>>  5 files changed, 54 insertions(+)
>>>  create mode 100644 arch/arm/cpu/armv7r/Makefile
>>>  create mode 100644 arch/arm/cpu/armv7r/config.mk
>>>  create mode 100644 arch/arm/cpu/armv7r/cpu.c
>>>  create mode 100644 arch/arm/cpu/armv7r/start.S
>>>
>>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>>> index b5fbce03667d..b10804f55224 100644
>>> --- a/arch/arm/Kconfig
>>> +++ b/arch/arm/Kconfig
>>> @@ -192,6 +192,10 @@ config CPU_V7M
>>>  	select THUMB2_KERNEL
>>>  	select SYS_CACHE_SHIFT_5
>>>  
>>> +config CPU_V7R
>>> +	bool
>>> +	select SYS_CACHE_SHIFT_6
>>
>> select HAS_THUMB2 might be a good option?
> 
> I didn't enable it because I didn't test it.
> It can be added when someone tests this.
> 
>>
>>> +
>>>  config CPU_PXA
>>>  	bool
>>>  	select SYS_CACHE_SHIFT_5
>>> @@ -209,6 +213,7 @@ config SYS_CPU
>>>  	default "arm1176" if CPU_ARM1176
>>>  	default "armv7" if CPU_V7
>>>  	default "armv7m" if CPU_V7M
>>> +	default "armv7r" if CPU_V7R
>>>  	default "pxa" if CPU_PXA
>>>  	default "sa1100" if CPU_SA1100
>>>  	default "armv8" if ARM64
>>> @@ -223,6 +228,7 @@ config SYS_ARM_ARCH
>>>  	default 6 if CPU_ARM1176
>>>  	default 7 if CPU_V7
>>>  	default 7 if CPU_V7M
>>> +	default 7 if CPU_V7R
>>>  	default 5 if CPU_PXA
>>>  	default 4 if CPU_SA1100
>>>  	default 8 if ARM64
>>
>> I did a grep of CPU_V7, and you might want to update for CPU_V7R in the
>> following places:
>>
>> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
>> index 4fa8b38397..f4bc1f250d 100644
>> --- a/arch/arm/Makefile
>> +++ b/arch/arm/Makefile
>> @@ -18,6 +18,7 @@ arch-$(CONFIG_CPU_ARM1136)	=-march=armv5
>>  arch-$(CONFIG_CPU_ARM1176)	=-march=armv5t
>>  arch-$(CONFIG_CPU_V7)		=$(call cc-option, -march=armv7-a, \
>>  				 $(call cc-option, -march=armv7, -march=armv5))
>> +arch-$(CONFIG_CPU_V7R)		=-march=armv7-r
> 
> I have setup PLATFORM_CPPFLAGS via config.mk
> 
> If both options are selected I am getting this compilation warning.
> cc1: warning: switch -mcpu=cortex-r5 conflicts with -march=armv7-r switch

hmm..that's strange. I guess it should be reported to gcc? Something
similar has been reported for a15 as well[1].

But looking at the implementation of armv7 we just included march. may
be we should stick to it?

> 
> Not sure which one is better or if it is better to have this arch flag
> via this makefile or as platform cppflags via config.mk.
> I choose the second option because it seems to me better if this is in
> subfolder. But not a problem to use different flag and put it to this
> Makefile.
> 
> The same style is used for cpu_v7m.

v7-r is very much close to v7. I would prefer to compare with v7
implementation than v7-m :)

> 
>>  arch-$(CONFIG_ARM64)		=-march=armv8-a
>>
>>  # On Tegra systems we must build SPL for the armv4 core on the device
>> @@ -41,6 +42,7 @@ tune-$(CONFIG_CPU_PXA)		=-mcpu=xscale
>>  tune-$(CONFIG_CPU_ARM1136)	=
>>  tune-$(CONFIG_CPU_ARM1176)	=
>>  tune-$(CONFIG_CPU_V7)		=
>> +tune-$(CONFIG_CPU_V7R)		=
> 
> Again as above. I used v7m as pattern and there is also empty tune
> parameter. Is there any good reason to have it empty?
> 
>>  tune-$(CONFIG_ARM64)		=
>>
>>  # Evaluate tune cc-option calls now
>>
>>
>>> diff --git a/arch/arm/cpu/armv7r/Makefile b/arch/arm/cpu/armv7r/Makefile
>>> new file mode 100644
>>> index 000000000000..3c66976dfa62
>>> --- /dev/null
>>> +++ b/arch/arm/cpu/armv7r/Makefile
>>
>> hmm..do we really need to create a separate folder? IIUC, the main
>> difference between V7 and V7R is MMU vs MPU. IMHO, we should be able to
>> get it using Kconfigs.
> 
> I have used V7 for the initial port and then was checking V7M which is
> already there and used it as pattern for writing this patch.
> 
> I have debugged V7 and found that I need to disable CONFIG_HAS_VBAR
> that's why I have created new symbol as for V7M.

We should be able to create a kconfig symbol for that and select
accordingly. Kernel does it the same way.

> 
> Definitely I am open to hear your suggestion
I just did a couple of quick experiments and able to get v7-r support
along with v7 support. let me know if you would like to take a look at
it. Then Ill pick your patch 1/2 and post the series.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57907

Thanks and regards,
Lokesh

> 
> Thanks,
> Michal
>
Michal Simek April 24, 2018, 12:24 p.m. UTC | #4
Hi,

On 24.4.2018 06:45, Lokesh Vutla wrote:
> Hi Michal,
> 
> On Monday 23 April 2018 11:56 AM, Michal Simek wrote:
>> On 23.4.2018 05:53, Lokesh Vutla wrote:
>>>
>>>
>>> On Friday 20 April 2018 07:21 PM, Michal Simek wrote:
>>>> This minimal support will be used by Xilinx ZynqMP R5 cpu.
>>>>
>>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>>>> ---
>>>>
>>>>  arch/arm/Kconfig              |  6 ++++++
>>>>  arch/arm/cpu/armv7r/Makefile  |  4 ++++
>>>>  arch/arm/cpu/armv7r/config.mk |  3 +++
>>>>  arch/arm/cpu/armv7r/cpu.c     | 24 ++++++++++++++++++++++++
>>>>  arch/arm/cpu/armv7r/start.S   | 17 +++++++++++++++++
>>>>  5 files changed, 54 insertions(+)
>>>>  create mode 100644 arch/arm/cpu/armv7r/Makefile
>>>>  create mode 100644 arch/arm/cpu/armv7r/config.mk
>>>>  create mode 100644 arch/arm/cpu/armv7r/cpu.c
>>>>  create mode 100644 arch/arm/cpu/armv7r/start.S
>>>>
>>>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>>>> index b5fbce03667d..b10804f55224 100644
>>>> --- a/arch/arm/Kconfig
>>>> +++ b/arch/arm/Kconfig
>>>> @@ -192,6 +192,10 @@ config CPU_V7M
>>>>  	select THUMB2_KERNEL
>>>>  	select SYS_CACHE_SHIFT_5
>>>>  
>>>> +config CPU_V7R
>>>> +	bool
>>>> +	select SYS_CACHE_SHIFT_6
>>>
>>> select HAS_THUMB2 might be a good option?
>>
>> I didn't enable it because I didn't test it.
>> It can be added when someone tests this.
>>
>>>
>>>> +
>>>>  config CPU_PXA
>>>>  	bool
>>>>  	select SYS_CACHE_SHIFT_5
>>>> @@ -209,6 +213,7 @@ config SYS_CPU
>>>>  	default "arm1176" if CPU_ARM1176
>>>>  	default "armv7" if CPU_V7
>>>>  	default "armv7m" if CPU_V7M
>>>> +	default "armv7r" if CPU_V7R
>>>>  	default "pxa" if CPU_PXA
>>>>  	default "sa1100" if CPU_SA1100
>>>>  	default "armv8" if ARM64
>>>> @@ -223,6 +228,7 @@ config SYS_ARM_ARCH
>>>>  	default 6 if CPU_ARM1176
>>>>  	default 7 if CPU_V7
>>>>  	default 7 if CPU_V7M
>>>> +	default 7 if CPU_V7R
>>>>  	default 5 if CPU_PXA
>>>>  	default 4 if CPU_SA1100
>>>>  	default 8 if ARM64
>>>
>>> I did a grep of CPU_V7, and you might want to update for CPU_V7R in the
>>> following places:
>>>
>>> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
>>> index 4fa8b38397..f4bc1f250d 100644
>>> --- a/arch/arm/Makefile
>>> +++ b/arch/arm/Makefile
>>> @@ -18,6 +18,7 @@ arch-$(CONFIG_CPU_ARM1136)	=-march=armv5
>>>  arch-$(CONFIG_CPU_ARM1176)	=-march=armv5t
>>>  arch-$(CONFIG_CPU_V7)		=$(call cc-option, -march=armv7-a, \
>>>  				 $(call cc-option, -march=armv7, -march=armv5))
>>> +arch-$(CONFIG_CPU_V7R)		=-march=armv7-r
>>
>> I have setup PLATFORM_CPPFLAGS via config.mk
>>
>> If both options are selected I am getting this compilation warning.
>> cc1: warning: switch -mcpu=cortex-r5 conflicts with -march=armv7-r switch
> 
> hmm..that's strange. I guess it should be reported to gcc? Something
> similar has been reported for a15 as well[1].
> 
> But looking at the implementation of armv7 we just included march. may
> be we should stick to it?

As I said I have not a problem to add there -march=armv7-r instead of
-mcpu=cortex-r5.



>> Not sure which one is better or if it is better to have this arch flag
>> via this makefile or as platform cppflags via config.mk.
>> I choose the second option because it seems to me better if this is in
>> subfolder. But not a problem to use different flag and put it to this
>> Makefile.
>>
>> The same style is used for cpu_v7m.
> 
> v7-r is very much close to v7. I would prefer to compare with v7
> implementation than v7-m :)

I started with symlink to v7. And I didn't play with MPU. Anyway both
ways works for me.


>>
>>>  arch-$(CONFIG_ARM64)		=-march=armv8-a
>>>
>>>  # On Tegra systems we must build SPL for the armv4 core on the device
>>> @@ -41,6 +42,7 @@ tune-$(CONFIG_CPU_PXA)		=-mcpu=xscale
>>>  tune-$(CONFIG_CPU_ARM1136)	=
>>>  tune-$(CONFIG_CPU_ARM1176)	=
>>>  tune-$(CONFIG_CPU_V7)		=
>>> +tune-$(CONFIG_CPU_V7R)		=
>>
>> Again as above. I used v7m as pattern and there is also empty tune
>> parameter. Is there any good reason to have it empty?
>>
>>>  tune-$(CONFIG_ARM64)		=
>>>
>>>  # Evaluate tune cc-option calls now
>>>
>>>
>>>> diff --git a/arch/arm/cpu/armv7r/Makefile b/arch/arm/cpu/armv7r/Makefile
>>>> new file mode 100644
>>>> index 000000000000..3c66976dfa62
>>>> --- /dev/null
>>>> +++ b/arch/arm/cpu/armv7r/Makefile
>>>
>>> hmm..do we really need to create a separate folder? IIUC, the main
>>> difference between V7 and V7R is MMU vs MPU. IMHO, we should be able to
>>> get it using Kconfigs.
>>
>> I have used V7 for the initial port and then was checking V7M which is
>> already there and used it as pattern for writing this patch.
>>
>> I have debugged V7 and found that I need to disable CONFIG_HAS_VBAR
>> that's why I have created new symbol as for V7M.
> 
> We should be able to create a kconfig symbol for that and select
> accordingly. Kernel does it the same way.

What kernel Kconfig option are you talking about?  (I didn't look at
Linux running on R5 but it is reasonable step).

It is really a question if adding new Kconfig symbol for VBAR is the
right thing to do. I would need to add VBAR to every platform which has
CPU_V7.


>>
>> Definitely I am open to hear your suggestion
> I just did a couple of quick experiments and able to get v7-r support
> along with v7 support. let me know if you would like to take a look at
> it. Then Ill pick your patch 1/2 and post the series.

I am definitely confident that this will work because I used that in
past. Definitely feel free to send it and I will take a look at retest
on R5.

Thanks,
Michal
Lokesh Vutla April 24, 2018, 12:49 p.m. UTC | #5
Hi Michal,

On Tuesday 24 April 2018 05:54 PM, Michal Simek wrote:
> Hi,
> 
> On 24.4.2018 06:45, Lokesh Vutla wrote:
>> Hi Michal,
>>
>> On Monday 23 April 2018 11:56 AM, Michal Simek wrote:
>>> On 23.4.2018 05:53, Lokesh Vutla wrote:
>>>>
>>>>
>>>> On Friday 20 April 2018 07:21 PM, Michal Simek wrote:
>>>>> This minimal support will be used by Xilinx ZynqMP R5 cpu.
>>>>>
>>>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>>>>> ---
>>>>>
>>>>>  arch/arm/Kconfig              |  6 ++++++
>>>>>  arch/arm/cpu/armv7r/Makefile  |  4 ++++
>>>>>  arch/arm/cpu/armv7r/config.mk |  3 +++
>>>>>  arch/arm/cpu/armv7r/cpu.c     | 24 ++++++++++++++++++++++++
>>>>>  arch/arm/cpu/armv7r/start.S   | 17 +++++++++++++++++
>>>>>  5 files changed, 54 insertions(+)
>>>>>  create mode 100644 arch/arm/cpu/armv7r/Makefile
>>>>>  create mode 100644 arch/arm/cpu/armv7r/config.mk
>>>>>  create mode 100644 arch/arm/cpu/armv7r/cpu.c
>>>>>  create mode 100644 arch/arm/cpu/armv7r/start.S
>>>>>
>>>>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>>>>> index b5fbce03667d..b10804f55224 100644
>>>>> --- a/arch/arm/Kconfig
>>>>> +++ b/arch/arm/Kconfig
>>>>> @@ -192,6 +192,10 @@ config CPU_V7M
>>>>>  	select THUMB2_KERNEL
>>>>>  	select SYS_CACHE_SHIFT_5
>>>>>  
>>>>> +config CPU_V7R
>>>>> +	bool
>>>>> +	select SYS_CACHE_SHIFT_6
>>>>
>>>> select HAS_THUMB2 might be a good option?
>>>
>>> I didn't enable it because I didn't test it.
>>> It can be added when someone tests this.
>>>
>>>>
>>>>> +
>>>>>  config CPU_PXA
>>>>>  	bool
>>>>>  	select SYS_CACHE_SHIFT_5
>>>>> @@ -209,6 +213,7 @@ config SYS_CPU
>>>>>  	default "arm1176" if CPU_ARM1176
>>>>>  	default "armv7" if CPU_V7
>>>>>  	default "armv7m" if CPU_V7M
>>>>> +	default "armv7r" if CPU_V7R
>>>>>  	default "pxa" if CPU_PXA
>>>>>  	default "sa1100" if CPU_SA1100
>>>>>  	default "armv8" if ARM64
>>>>> @@ -223,6 +228,7 @@ config SYS_ARM_ARCH
>>>>>  	default 6 if CPU_ARM1176
>>>>>  	default 7 if CPU_V7
>>>>>  	default 7 if CPU_V7M
>>>>> +	default 7 if CPU_V7R
>>>>>  	default 5 if CPU_PXA
>>>>>  	default 4 if CPU_SA1100
>>>>>  	default 8 if ARM64
>>>>
>>>> I did a grep of CPU_V7, and you might want to update for CPU_V7R in the
>>>> following places:
>>>>
>>>> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
>>>> index 4fa8b38397..f4bc1f250d 100644
>>>> --- a/arch/arm/Makefile
>>>> +++ b/arch/arm/Makefile
>>>> @@ -18,6 +18,7 @@ arch-$(CONFIG_CPU_ARM1136)	=-march=armv5
>>>>  arch-$(CONFIG_CPU_ARM1176)	=-march=armv5t
>>>>  arch-$(CONFIG_CPU_V7)		=$(call cc-option, -march=armv7-a, \
>>>>  				 $(call cc-option, -march=armv7, -march=armv5))
>>>> +arch-$(CONFIG_CPU_V7R)		=-march=armv7-r
>>>
>>> I have setup PLATFORM_CPPFLAGS via config.mk
>>>
>>> If both options are selected I am getting this compilation warning.
>>> cc1: warning: switch -mcpu=cortex-r5 conflicts with -march=armv7-r switch
>>
>> hmm..that's strange. I guess it should be reported to gcc? Something
>> similar has been reported for a15 as well[1].
>>
>> But looking at the implementation of armv7 we just included march. may
>> be we should stick to it?
> 
> As I said I have not a problem to add there -march=armv7-r instead of
> -mcpu=cortex-r5.
> 
> 
> 
>>> Not sure which one is better or if it is better to have this arch flag
>>> via this makefile or as platform cppflags via config.mk.
>>> I choose the second option because it seems to me better if this is in
>>> subfolder. But not a problem to use different flag and put it to this
>>> Makefile.
>>>
>>> The same style is used for cpu_v7m.
>>
>> v7-r is very much close to v7. I would prefer to compare with v7
>> implementation than v7-m :)
> 
> I started with symlink to v7. And I didn't play with MPU. Anyway both
> ways works for me.
> 
> 
>>>
>>>>  arch-$(CONFIG_ARM64)		=-march=armv8-a
>>>>
>>>>  # On Tegra systems we must build SPL for the armv4 core on the device
>>>> @@ -41,6 +42,7 @@ tune-$(CONFIG_CPU_PXA)		=-mcpu=xscale
>>>>  tune-$(CONFIG_CPU_ARM1136)	=
>>>>  tune-$(CONFIG_CPU_ARM1176)	=
>>>>  tune-$(CONFIG_CPU_V7)		=
>>>> +tune-$(CONFIG_CPU_V7R)		=
>>>
>>> Again as above. I used v7m as pattern and there is also empty tune
>>> parameter. Is there any good reason to have it empty?
>>>
>>>>  tune-$(CONFIG_ARM64)		=
>>>>
>>>>  # Evaluate tune cc-option calls now
>>>>
>>>>
>>>>> diff --git a/arch/arm/cpu/armv7r/Makefile b/arch/arm/cpu/armv7r/Makefile
>>>>> new file mode 100644
>>>>> index 000000000000..3c66976dfa62
>>>>> --- /dev/null
>>>>> +++ b/arch/arm/cpu/armv7r/Makefile
>>>>
>>>> hmm..do we really need to create a separate folder? IIUC, the main
>>>> difference between V7 and V7R is MMU vs MPU. IMHO, we should be able to
>>>> get it using Kconfigs.
>>>
>>> I have used V7 for the initial port and then was checking V7M which is
>>> already there and used it as pattern for writing this patch.
>>>
>>> I have debugged V7 and found that I need to disable CONFIG_HAS_VBAR
>>> that's why I have created new symbol as for V7M.
>>
>> We should be able to create a kconfig symbol for that and select
>> accordingly. Kernel does it the same way.
> 
> What kernel Kconfig option are you talking about?  (I didn't look at
> Linux running on R5 but it is reasonable step).
> 
> It is really a question if adding new Kconfig symbol for VBAR is the
> right thing to do. I would need to add VBAR to every platform which has
> CPU_V7.
> 
> 
>>>
>>> Definitely I am open to hear your suggestion
>> I just did a couple of quick experiments and able to get v7-r support
>> along with v7 support. let me know if you would like to take a look at
>> it. Then Ill pick your patch 1/2 and post the series.
> 
> I am definitely confident that this will work because I used that in
> past. Definitely feel free to send it and I will take a look at retest
> on R5.

Sorry, I did not mean this patch does not work. It definitely works. I
am trying to tell that with some kconfig changes we should be able to
re-use armv7 folder instead of creating new folder. Apologies if my
reply has communicated wrongly.

Will post an RFC series for R5 support.

Thanks and regards,
Lokesh
Michal Simek April 24, 2018, 12:53 p.m. UTC | #6
On 24.4.2018 14:49, Lokesh Vutla wrote:
> Hi Michal,
> 
> On Tuesday 24 April 2018 05:54 PM, Michal Simek wrote:
>> Hi,
>>
>> On 24.4.2018 06:45, Lokesh Vutla wrote:
>>> Hi Michal,
>>>
>>> On Monday 23 April 2018 11:56 AM, Michal Simek wrote:
>>>> On 23.4.2018 05:53, Lokesh Vutla wrote:
>>>>>
>>>>>
>>>>> On Friday 20 April 2018 07:21 PM, Michal Simek wrote:
>>>>>> This minimal support will be used by Xilinx ZynqMP R5 cpu.
>>>>>>
>>>>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>>>>>> ---
>>>>>>
>>>>>>  arch/arm/Kconfig              |  6 ++++++
>>>>>>  arch/arm/cpu/armv7r/Makefile  |  4 ++++
>>>>>>  arch/arm/cpu/armv7r/config.mk |  3 +++
>>>>>>  arch/arm/cpu/armv7r/cpu.c     | 24 ++++++++++++++++++++++++
>>>>>>  arch/arm/cpu/armv7r/start.S   | 17 +++++++++++++++++
>>>>>>  5 files changed, 54 insertions(+)
>>>>>>  create mode 100644 arch/arm/cpu/armv7r/Makefile
>>>>>>  create mode 100644 arch/arm/cpu/armv7r/config.mk
>>>>>>  create mode 100644 arch/arm/cpu/armv7r/cpu.c
>>>>>>  create mode 100644 arch/arm/cpu/armv7r/start.S
>>>>>>
>>>>>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>>>>>> index b5fbce03667d..b10804f55224 100644
>>>>>> --- a/arch/arm/Kconfig
>>>>>> +++ b/arch/arm/Kconfig
>>>>>> @@ -192,6 +192,10 @@ config CPU_V7M
>>>>>>  	select THUMB2_KERNEL
>>>>>>  	select SYS_CACHE_SHIFT_5
>>>>>>  
>>>>>> +config CPU_V7R
>>>>>> +	bool
>>>>>> +	select SYS_CACHE_SHIFT_6
>>>>>
>>>>> select HAS_THUMB2 might be a good option?
>>>>
>>>> I didn't enable it because I didn't test it.
>>>> It can be added when someone tests this.
>>>>
>>>>>
>>>>>> +
>>>>>>  config CPU_PXA
>>>>>>  	bool
>>>>>>  	select SYS_CACHE_SHIFT_5
>>>>>> @@ -209,6 +213,7 @@ config SYS_CPU
>>>>>>  	default "arm1176" if CPU_ARM1176
>>>>>>  	default "armv7" if CPU_V7
>>>>>>  	default "armv7m" if CPU_V7M
>>>>>> +	default "armv7r" if CPU_V7R
>>>>>>  	default "pxa" if CPU_PXA
>>>>>>  	default "sa1100" if CPU_SA1100
>>>>>>  	default "armv8" if ARM64
>>>>>> @@ -223,6 +228,7 @@ config SYS_ARM_ARCH
>>>>>>  	default 6 if CPU_ARM1176
>>>>>>  	default 7 if CPU_V7
>>>>>>  	default 7 if CPU_V7M
>>>>>> +	default 7 if CPU_V7R
>>>>>>  	default 5 if CPU_PXA
>>>>>>  	default 4 if CPU_SA1100
>>>>>>  	default 8 if ARM64
>>>>>
>>>>> I did a grep of CPU_V7, and you might want to update for CPU_V7R in the
>>>>> following places:
>>>>>
>>>>> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
>>>>> index 4fa8b38397..f4bc1f250d 100644
>>>>> --- a/arch/arm/Makefile
>>>>> +++ b/arch/arm/Makefile
>>>>> @@ -18,6 +18,7 @@ arch-$(CONFIG_CPU_ARM1136)	=-march=armv5
>>>>>  arch-$(CONFIG_CPU_ARM1176)	=-march=armv5t
>>>>>  arch-$(CONFIG_CPU_V7)		=$(call cc-option, -march=armv7-a, \
>>>>>  				 $(call cc-option, -march=armv7, -march=armv5))
>>>>> +arch-$(CONFIG_CPU_V7R)		=-march=armv7-r
>>>>
>>>> I have setup PLATFORM_CPPFLAGS via config.mk
>>>>
>>>> If both options are selected I am getting this compilation warning.
>>>> cc1: warning: switch -mcpu=cortex-r5 conflicts with -march=armv7-r switch
>>>
>>> hmm..that's strange. I guess it should be reported to gcc? Something
>>> similar has been reported for a15 as well[1].
>>>
>>> But looking at the implementation of armv7 we just included march. may
>>> be we should stick to it?
>>
>> As I said I have not a problem to add there -march=armv7-r instead of
>> -mcpu=cortex-r5.
>>
>>
>>
>>>> Not sure which one is better or if it is better to have this arch flag
>>>> via this makefile or as platform cppflags via config.mk.
>>>> I choose the second option because it seems to me better if this is in
>>>> subfolder. But not a problem to use different flag and put it to this
>>>> Makefile.
>>>>
>>>> The same style is used for cpu_v7m.
>>>
>>> v7-r is very much close to v7. I would prefer to compare with v7
>>> implementation than v7-m :)
>>
>> I started with symlink to v7. And I didn't play with MPU. Anyway both
>> ways works for me.
>>
>>
>>>>
>>>>>  arch-$(CONFIG_ARM64)		=-march=armv8-a
>>>>>
>>>>>  # On Tegra systems we must build SPL for the armv4 core on the device
>>>>> @@ -41,6 +42,7 @@ tune-$(CONFIG_CPU_PXA)		=-mcpu=xscale
>>>>>  tune-$(CONFIG_CPU_ARM1136)	=
>>>>>  tune-$(CONFIG_CPU_ARM1176)	=
>>>>>  tune-$(CONFIG_CPU_V7)		=
>>>>> +tune-$(CONFIG_CPU_V7R)		=
>>>>
>>>> Again as above. I used v7m as pattern and there is also empty tune
>>>> parameter. Is there any good reason to have it empty?
>>>>
>>>>>  tune-$(CONFIG_ARM64)		=
>>>>>
>>>>>  # Evaluate tune cc-option calls now
>>>>>
>>>>>
>>>>>> diff --git a/arch/arm/cpu/armv7r/Makefile b/arch/arm/cpu/armv7r/Makefile
>>>>>> new file mode 100644
>>>>>> index 000000000000..3c66976dfa62
>>>>>> --- /dev/null
>>>>>> +++ b/arch/arm/cpu/armv7r/Makefile
>>>>>
>>>>> hmm..do we really need to create a separate folder? IIUC, the main
>>>>> difference between V7 and V7R is MMU vs MPU. IMHO, we should be able to
>>>>> get it using Kconfigs.
>>>>
>>>> I have used V7 for the initial port and then was checking V7M which is
>>>> already there and used it as pattern for writing this patch.
>>>>
>>>> I have debugged V7 and found that I need to disable CONFIG_HAS_VBAR
>>>> that's why I have created new symbol as for V7M.
>>>
>>> We should be able to create a kconfig symbol for that and select
>>> accordingly. Kernel does it the same way.
>>
>> What kernel Kconfig option are you talking about?  (I didn't look at
>> Linux running on R5 but it is reasonable step).
>>
>> It is really a question if adding new Kconfig symbol for VBAR is the
>> right thing to do. I would need to add VBAR to every platform which has
>> CPU_V7.
>>
>>
>>>>
>>>> Definitely I am open to hear your suggestion
>>> I just did a couple of quick experiments and able to get v7-r support
>>> along with v7 support. let me know if you would like to take a look at
>>> it. Then Ill pick your patch 1/2 and post the series.
>>
>> I am definitely confident that this will work because I used that in
>> past. Definitely feel free to send it and I will take a look at retest
>> on R5.
> 
> Sorry, I did not mean this patch does not work. It definitely works. I
> am trying to tell that with some kconfig changes we should be able to
> re-use armv7 folder instead of creating new folder. Apologies if my
> reply has communicated wrongly.

I know that it will work. Please send it and I will take a look. The
same is for v7m which can be also squashed with v7 + some Kconfig options.

Thanks,
Michal
diff mbox series

Patch

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index b5fbce03667d..b10804f55224 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -192,6 +192,10 @@  config CPU_V7M
 	select THUMB2_KERNEL
 	select SYS_CACHE_SHIFT_5
 
+config CPU_V7R
+	bool
+	select SYS_CACHE_SHIFT_6
+
 config CPU_PXA
 	bool
 	select SYS_CACHE_SHIFT_5
@@ -209,6 +213,7 @@  config SYS_CPU
 	default "arm1176" if CPU_ARM1176
 	default "armv7" if CPU_V7
 	default "armv7m" if CPU_V7M
+	default "armv7r" if CPU_V7R
 	default "pxa" if CPU_PXA
 	default "sa1100" if CPU_SA1100
 	default "armv8" if ARM64
@@ -223,6 +228,7 @@  config SYS_ARM_ARCH
 	default 6 if CPU_ARM1176
 	default 7 if CPU_V7
 	default 7 if CPU_V7M
+	default 7 if CPU_V7R
 	default 5 if CPU_PXA
 	default 4 if CPU_SA1100
 	default 8 if ARM64
diff --git a/arch/arm/cpu/armv7r/Makefile b/arch/arm/cpu/armv7r/Makefile
new file mode 100644
index 000000000000..3c66976dfa62
--- /dev/null
+++ b/arch/arm/cpu/armv7r/Makefile
@@ -0,0 +1,4 @@ 
+# SPDX-License-Identifier: GPL-2.0
+
+extra-y := start.o
+obj-y += cpu.o
diff --git a/arch/arm/cpu/armv7r/config.mk b/arch/arm/cpu/armv7r/config.mk
new file mode 100644
index 000000000000..224d191ff846
--- /dev/null
+++ b/arch/arm/cpu/armv7r/config.mk
@@ -0,0 +1,3 @@ 
+# SPDX-License-Identifier: GPL-2.0
+
+PLATFORM_CPPFLAGS += -mcpu=cortex-r5 -DARMR5
diff --git a/arch/arm/cpu/armv7r/cpu.c b/arch/arm/cpu/armv7r/cpu.c
new file mode 100644
index 000000000000..e384a530c5e0
--- /dev/null
+++ b/arch/arm/cpu/armv7r/cpu.c
@@ -0,0 +1,24 @@ 
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * (C) Copyright 2018 Xilinx, Inc. (Michal Simek)
+ */
+
+#include <common.h>
+
+/*
+ * This is called right before passing control to
+ * the Linux kernel point.
+ */
+int cleanup_before_linux(void)
+{
+	return 0;
+}
+
+/*
+ * Perform the low-level reset.
+ */
+void reset_cpu(ulong addr)
+{
+	while (1)
+		;
+}
diff --git a/arch/arm/cpu/armv7r/start.S b/arch/arm/cpu/armv7r/start.S
new file mode 100644
index 000000000000..d6e8eecf54b7
--- /dev/null
+++ b/arch/arm/cpu/armv7r/start.S
@@ -0,0 +1,17 @@ 
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2015
+ * Kamil Lulko, <kamil.lulko@gmail.com>
+ *
+ */
+
+#include <asm/assembler.h>
+
+.globl	reset
+.type reset, %function
+reset:
+	W(b)	_main
+
+.globl	c_runtime_cpu_setup
+c_runtime_cpu_setup:
+	mov	pc, lr