All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] sunxi: add PRCM secure switch register definition
@ 2017-07-20  6:00 Icenowy Zheng
  2017-07-20  6:00 ` [U-Boot] [PATCH 2/2] sunxi: switch PRCM to non-secure on H3/H5 SoCs Icenowy Zheng
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Icenowy Zheng @ 2017-07-20  6:00 UTC (permalink / raw)
  To: u-boot

Some new Allwinner SoCs' PRCM has a secure switch register, which
controls the access to some clock and power registers in PRCM block.

Add the definition of this register and its bits in the PRCM header
file.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
---
 arch/arm/include/asm/arch-sunxi/prcm.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/include/asm/arch-sunxi/prcm.h b/arch/arm/include/asm/arch-sunxi/prcm.h
index ae3880b13b..ba4427c925 100644
--- a/arch/arm/include/asm/arch-sunxi/prcm.h
+++ b/arch/arm/include/asm/arch-sunxi/prcm.h
@@ -196,6 +196,10 @@
 #define PRCM_CPU3_PWR_CLAMP(n) (((n) & 0xff) << 0)
 #define PRCM_CPU3_PWR_CLAMP_MASK PRCM_CPU3_PWR_CLAMP(0xff)
 
+#define PRCM_SEC_SWITCH_APB0_CLK_NONSEC (0x1 << 0)
+#define PRCM_SEC_SWITCH_PLL_CFG_NONSEC (0x1 << 1)
+#define PRCM_SEC_SWITCH_PWR_GATE_NONSEC (0x1 << 2)
+
 #ifndef __ASSEMBLY__
 #include <linux/compiler.h>
 
@@ -233,6 +237,8 @@ struct __packed sunxi_prcm_reg {
 	u32 dram_pwr;		/* 0x180 */
 	u8 res12[0xc];		/* 0x184 */
 	u32 dram_tst;		/* 0x190 */
+	u8 res13[0x3c];		/* 0x194 */
+	u32 prcm_sec_switch;	/* 0x1d0 */
 };
 
 void prcm_apb0_enable(u32 flags);
-- 
2.13.0

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

* [U-Boot] [PATCH 2/2] sunxi: switch PRCM to non-secure on H3/H5 SoCs
  2017-07-20  6:00 [U-Boot] [PATCH 1/2] sunxi: add PRCM secure switch register definition Icenowy Zheng
@ 2017-07-20  6:00 ` Icenowy Zheng
  2017-07-26 11:55   ` icenowy at aosc.io
  2017-08-08  4:13 ` [U-Boot] [linux-sunxi] [PATCH 1/2] sunxi: add PRCM secure switch register definition Chen-Yu Tsai
  2017-08-11 10:21 ` [U-Boot] " Jagan Teki
  2 siblings, 1 reply; 10+ messages in thread
From: Icenowy Zheng @ 2017-07-20  6:00 UTC (permalink / raw)
  To: u-boot

The PRCM of H3/H5 SoCs have a secure/non-secure switch, which controls
the access to some clock/power related registers in PRCM.

Current Linux kernel will access the CPUS (AR100) clock in the PRCM
block, so the PRCM should be switched to non-secure.

Add code to switch the PRCM to non-secure.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
---
 arch/arm/mach-sunxi/clock_sun6i.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/mach-sunxi/clock_sun6i.c b/arch/arm/mach-sunxi/clock_sun6i.c
index ec5b026ef5..870ff5b1e0 100644
--- a/arch/arm/mach-sunxi/clock_sun6i.c
+++ b/arch/arm/mach-sunxi/clock_sun6i.c
@@ -66,11 +66,17 @@ void clock_init_sec(void)
 #ifdef CONFIG_MACH_SUNXI_H3_H5
 	struct sunxi_ccm_reg * const ccm =
 		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+	struct sunxi_prcm_reg * const prcm =
+		(struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
 
 	setbits_le32(&ccm->ccu_sec_switch,
 		     CCM_SEC_SWITCH_MBUS_NONSEC |
 		     CCM_SEC_SWITCH_BUS_NONSEC |
 		     CCM_SEC_SWITCH_PLL_NONSEC);
+	setbits_le32(&prcm->prcm_sec_switch,
+		     PRCM_SEC_SWITCH_APB0_CLK_NONSEC |
+		     PRCM_SEC_SWITCH_PLL_CFG_NONSEC |
+		     PRCM_SEC_SWITCH_PWR_GATE_NONSEC);
 #endif
 }
 
-- 
2.13.0

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

* [U-Boot] [PATCH 2/2] sunxi: switch PRCM to non-secure on H3/H5 SoCs
  2017-07-20  6:00 ` [U-Boot] [PATCH 2/2] sunxi: switch PRCM to non-secure on H3/H5 SoCs Icenowy Zheng
@ 2017-07-26 11:55   ` icenowy at aosc.io
  2017-07-26 19:31     ` Maxime Ripard
  0 siblings, 1 reply; 10+ messages in thread
From: icenowy at aosc.io @ 2017-07-26 11:55 UTC (permalink / raw)
  To: u-boot

在 2017-07-20 14:00,Icenowy Zheng 写道:
> The PRCM of H3/H5 SoCs have a secure/non-secure switch, which controls
> the access to some clock/power related registers in PRCM.
> 
> Current Linux kernel will access the CPUS (AR100) clock in the PRCM
> block, so the PRCM should be switched to non-secure.
> 
> Add code to switch the PRCM to non-secure.

Ping.

Maxime and Jagan, can you merge this patchset?

This is necessary for R_CCU to work properly on H3.

> 
> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> ---
>  arch/arm/mach-sunxi/clock_sun6i.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/arm/mach-sunxi/clock_sun6i.c
> b/arch/arm/mach-sunxi/clock_sun6i.c
> index ec5b026ef5..870ff5b1e0 100644
> --- a/arch/arm/mach-sunxi/clock_sun6i.c
> +++ b/arch/arm/mach-sunxi/clock_sun6i.c
> @@ -66,11 +66,17 @@ void clock_init_sec(void)
>  #ifdef CONFIG_MACH_SUNXI_H3_H5
>  	struct sunxi_ccm_reg * const ccm =
>  		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
> +	struct sunxi_prcm_reg * const prcm =
> +		(struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
> 
>  	setbits_le32(&ccm->ccu_sec_switch,
>  		     CCM_SEC_SWITCH_MBUS_NONSEC |
>  		     CCM_SEC_SWITCH_BUS_NONSEC |
>  		     CCM_SEC_SWITCH_PLL_NONSEC);
> +	setbits_le32(&prcm->prcm_sec_switch,
> +		     PRCM_SEC_SWITCH_APB0_CLK_NONSEC |
> +		     PRCM_SEC_SWITCH_PLL_CFG_NONSEC |
> +		     PRCM_SEC_SWITCH_PWR_GATE_NONSEC);
>  #endif
>  }

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

* [U-Boot] [PATCH 2/2] sunxi: switch PRCM to non-secure on H3/H5 SoCs
  2017-07-26 11:55   ` icenowy at aosc.io
@ 2017-07-26 19:31     ` Maxime Ripard
  2017-08-09  3:46       ` Chen-Yu Tsai
  0 siblings, 1 reply; 10+ messages in thread
From: Maxime Ripard @ 2017-07-26 19:31 UTC (permalink / raw)
  To: u-boot

On Wed, Jul 26, 2017 at 07:55:24PM +0800, icenowy at aosc.io wrote:
> 在 2017-07-20 14:00,Icenowy Zheng 写道:
> > The PRCM of H3/H5 SoCs have a secure/non-secure switch, which controls
> > the access to some clock/power related registers in PRCM.
> > 
> > Current Linux kernel will access the CPUS (AR100) clock in the PRCM
> > block, so the PRCM should be switched to non-secure.
> > 
> > Add code to switch the PRCM to non-secure.
> 
> Ping.
> 
> Maxime and Jagan, can you merge this patchset?
> 
> This is necessary for R_CCU to work properly on H3.

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170726/9c164f2d/attachment.sig>

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

* [U-Boot] [linux-sunxi] [PATCH 1/2] sunxi: add PRCM secure switch register definition
  2017-07-20  6:00 [U-Boot] [PATCH 1/2] sunxi: add PRCM secure switch register definition Icenowy Zheng
  2017-07-20  6:00 ` [U-Boot] [PATCH 2/2] sunxi: switch PRCM to non-secure on H3/H5 SoCs Icenowy Zheng
@ 2017-08-08  4:13 ` Chen-Yu Tsai
  2017-08-08  6:46   ` icenowy at aosc.io
  2017-08-11 10:21 ` [U-Boot] " Jagan Teki
  2 siblings, 1 reply; 10+ messages in thread
From: Chen-Yu Tsai @ 2017-08-08  4:13 UTC (permalink / raw)
  To: u-boot

On Thu, Jul 20, 2017 at 2:00 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
> Some new Allwinner SoCs' PRCM has a secure switch register, which
> controls the access to some clock and power registers in PRCM block.
>
> Add the definition of this register and its bits in the PRCM header
> file.
>
> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>

Could you provide a reference as to where or how you found out
about this?

Thanks
ChenYu

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

* [U-Boot] [linux-sunxi] [PATCH 1/2] sunxi: add PRCM secure switch register definition
  2017-08-08  4:13 ` [U-Boot] [linux-sunxi] [PATCH 1/2] sunxi: add PRCM secure switch register definition Chen-Yu Tsai
@ 2017-08-08  6:46   ` icenowy at aosc.io
  2017-08-09  3:46     ` Chen-Yu Tsai
  0 siblings, 1 reply; 10+ messages in thread
From: icenowy at aosc.io @ 2017-08-08  6:46 UTC (permalink / raw)
  To: u-boot

在 2017-08-08 12:13,Chen-Yu Tsai 写道:
> On Thu, Jul 20, 2017 at 2:00 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
>> Some new Allwinner SoCs' PRCM has a secure switch register, which
>> controls the access to some clock and power registers in PRCM block.
>> 
>> Add the definition of this register and its bits in the PRCM header
>> file.
>> 
>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
> 
> Could you provide a reference as to where or how you found out
> about this?

https://github.com/tinalinux/brandy/blob/r18-v0.9/arm-trusted-firmware-1.0/plat/sun50iw1p1/sunxi_security.c#L105

> 
> Thanks
> ChenYu

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

* [U-Boot] [linux-sunxi] [PATCH 1/2] sunxi: add PRCM secure switch register definition
  2017-08-08  6:46   ` icenowy at aosc.io
@ 2017-08-09  3:46     ` Chen-Yu Tsai
  2017-08-09  4:02       ` icenowy at aosc.io
  0 siblings, 1 reply; 10+ messages in thread
From: Chen-Yu Tsai @ 2017-08-09  3:46 UTC (permalink / raw)
  To: u-boot

On Tue, Aug 8, 2017 at 2:46 PM,  <icenowy@aosc.io> wrote:
> 在 2017-08-08 12:13,Chen-Yu Tsai 写道:
>>
>> On Thu, Jul 20, 2017 at 2:00 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
>>>
>>> Some new Allwinner SoCs' PRCM has a secure switch register, which
>>> controls the access to some clock and power registers in PRCM block.
>>>
>>> Add the definition of this register and its bits in the PRCM header
>>> file.
>>>
>>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
>>
>>
>> Could you provide a reference as to where or how you found out
>> about this?
>
>
> https://github.com/tinalinux/brandy/blob/r18-v0.9/arm-trusted-firmware-1.0/plat/sun50iw1p1/sunxi_security.c#L105

I assume you've mapped out what each bit means by testing it?

Tested-by: Chen-Yu Tsai <wens@csie.org>

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

* [U-Boot] [PATCH 2/2] sunxi: switch PRCM to non-secure on H3/H5 SoCs
  2017-07-26 19:31     ` Maxime Ripard
@ 2017-08-09  3:46       ` Chen-Yu Tsai
  0 siblings, 0 replies; 10+ messages in thread
From: Chen-Yu Tsai @ 2017-08-09  3:46 UTC (permalink / raw)
  To: u-boot

On Thu, Jul 27, 2017 at 3:31 AM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> On Wed, Jul 26, 2017 at 07:55:24PM +0800, icenowy at aosc.io wrote:
>> 在 2017-07-20 14:00,Icenowy Zheng 写道:
>> > The PRCM of H3/H5 SoCs have a secure/non-secure switch, which controls
>> > the access to some clock/power related registers in PRCM.
>> >
>> > Current Linux kernel will access the CPUS (AR100) clock in the PRCM
>> > block, so the PRCM should be switched to non-secure.
>> >
>> > Add code to switch the PRCM to non-secure.
>>
>> Ping.
>>
>> Maxime and Jagan, can you merge this patchset?
>>
>> This is necessary for R_CCU to work properly on H3.
>
> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Tested-by: Chen-Yu Tsai <wens@csie.org>

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

* [U-Boot] [linux-sunxi] [PATCH 1/2] sunxi: add PRCM secure switch register definition
  2017-08-09  3:46     ` Chen-Yu Tsai
@ 2017-08-09  4:02       ` icenowy at aosc.io
  0 siblings, 0 replies; 10+ messages in thread
From: icenowy at aosc.io @ 2017-08-09  4:02 UTC (permalink / raw)
  To: u-boot

在 2017-08-09 11:46,Chen-Yu Tsai 写道:
> On Tue, Aug 8, 2017 at 2:46 PM,  <icenowy@aosc.io> wrote:
>> 在 2017-08-08 12:13,Chen-Yu Tsai 写道:
>>> 
>>> On Thu, Jul 20, 2017 at 2:00 PM, Icenowy Zheng <icenowy@aosc.io> 
>>> wrote:
>>>> 
>>>> Some new Allwinner SoCs' PRCM has a secure switch register, which
>>>> controls the access to some clock and power registers in PRCM block.
>>>> 
>>>> Add the definition of this register and its bits in the PRCM header
>>>> file.
>>>> 
>>>> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
>>> 
>>> 
>>> Could you provide a reference as to where or how you found out
>>> about this?
>> 
>> 
>> https://github.com/tinalinux/brandy/blob/r18-v0.9/arm-trusted-firmware-1.0/plat/sun50iw1p1/sunxi_security.c#L105
> 
> I assume you've mapped out what each bit means by testing it?

Yes.

Toggling bit 0 will make at least 0x0 (CPUS_CFG_REG) inaccessible.
Toggling bit 1 will make at least 0x40 and 0x44 (PLL_CTRL_REG{0,1})
inaccessible.
Toggling bit 2 will make at least 0x120 (VDD_SYS_PWR_RST)
inaccessible.

(The register names are from http://linux-sunxi.org/PRCM )

> 
> Tested-by: Chen-Yu Tsai <wens@csie.org>

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

* [U-Boot] [PATCH 1/2] sunxi: add PRCM secure switch register definition
  2017-07-20  6:00 [U-Boot] [PATCH 1/2] sunxi: add PRCM secure switch register definition Icenowy Zheng
  2017-07-20  6:00 ` [U-Boot] [PATCH 2/2] sunxi: switch PRCM to non-secure on H3/H5 SoCs Icenowy Zheng
  2017-08-08  4:13 ` [U-Boot] [linux-sunxi] [PATCH 1/2] sunxi: add PRCM secure switch register definition Chen-Yu Tsai
@ 2017-08-11 10:21 ` Jagan Teki
  2 siblings, 0 replies; 10+ messages in thread
From: Jagan Teki @ 2017-08-11 10:21 UTC (permalink / raw)
  To: u-boot

On Thu, Jul 20, 2017 at 11:30 AM, Icenowy Zheng <icenowy@aosc.io> wrote:
> Some new Allwinner SoCs' PRCM has a secure switch register, which
> controls the access to some clock and power registers in PRCM block.
>
> Add the definition of this register and its bits in the PRCM header
> file.
>
> Signed-off-by: Icenowy Zheng <icenowy@aosc.io>

Applied both in u-boot-sunxi/master

thanks!
-- 
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.

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

end of thread, other threads:[~2017-08-11 10:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-20  6:00 [U-Boot] [PATCH 1/2] sunxi: add PRCM secure switch register definition Icenowy Zheng
2017-07-20  6:00 ` [U-Boot] [PATCH 2/2] sunxi: switch PRCM to non-secure on H3/H5 SoCs Icenowy Zheng
2017-07-26 11:55   ` icenowy at aosc.io
2017-07-26 19:31     ` Maxime Ripard
2017-08-09  3:46       ` Chen-Yu Tsai
2017-08-08  4:13 ` [U-Boot] [linux-sunxi] [PATCH 1/2] sunxi: add PRCM secure switch register definition Chen-Yu Tsai
2017-08-08  6:46   ` icenowy at aosc.io
2017-08-09  3:46     ` Chen-Yu Tsai
2017-08-09  4:02       ` icenowy at aosc.io
2017-08-11 10:21 ` [U-Boot] " Jagan Teki

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.