Re: [U-Boot] [PATCH 2/2] sun7i: Add PSCI v0.2 support
On Wed, 2014-12-31 at 12:57 +0100, Jan Kiszka wrote: On 2014-12-29 15:12, Ian Campbell wrote: On Mon, 2014-12-15 at 12:37 +0100, Jan Kiszka wrote: This extends the PSCI support for the A20 to a dual v0.2 and v0.1 interface. Recent OSes will prefer v0.2, olders will still find the original interface, just at v0.2 service IDs. In addition to the existing services, v0.2 requires us to implement both system off and reset. At least Linux will make use of them in favor of its own implementations and, thus, fail if they do not work. What functionality does v0.2 give us over v0.1 that you are aiming to expose here? For us, the added value is currently in next layer: we can simplify the Jailhouse hypervisor a bit when leaving out v0.1 support right from the beginning. But that means U-Boot has to support v0.2 on the platforms we target at. Understood, although we support both with Xen and it's really not very much code. v0.2 is the current standard, so I would expect new boards to use that one in the future by default. Given the extra complexity of v0.2 vs v0.1 for the firmware, and the lack of compelling new features added by v0.2 for platforms which don't run anything in secure world, I'm not sure that's a given. Indeed, that was the thrust of my original question... Ian. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] sun7i: Add PSCI v0.2 support
On 2014-12-29 15:12, Ian Campbell wrote: On Mon, 2014-12-15 at 12:37 +0100, Jan Kiszka wrote: This extends the PSCI support for the A20 to a dual v0.2 and v0.1 interface. Recent OSes will prefer v0.2, olders will still find the original interface, just at v0.2 service IDs. In addition to the existing services, v0.2 requires us to implement both system off and reset. At least Linux will make use of them in favor of its own implementations and, thus, fail if they do not work. What functionality does v0.2 give us over v0.1 that you are aiming to expose here? For us, the added value is currently in next layer: we can simplify the Jailhouse hypervisor a bit when leaving out v0.1 support right from the beginning. But that means U-Boot has to support v0.2 on the platforms we target at. v0.2 is the current standard, so I would expect new boards to use that one in the future by default. Thus, this lays the ground, though there will surely be more work required to make some code better reusable. Jan signature.asc Description: OpenPGP digital signature ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] sun7i: Add PSCI v0.2 support
On Mon, 2014-12-15 at 12:37 +0100, Jan Kiszka wrote: This extends the PSCI support for the A20 to a dual v0.2 and v0.1 interface. Recent OSes will prefer v0.2, olders will still find the original interface, just at v0.2 service IDs. In addition to the existing services, v0.2 requires us to implement both system off and reset. At least Linux will make use of them in favor of its own implementations and, thus, fail if they do not work. What functionality does v0.2 give us over v0.1 that you are aiming to expose here? Ian. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 2/2] sun7i: Add PSCI v0.2 support
This extends the PSCI support for the A20 to a dual v0.2 and v0.1 interface. Recent OSes will prefer v0.2, olders will still find the original interface, just at v0.2 service IDs. In addition to the existing services, v0.2 requires us to implement both system off and reset. At least Linux will make use of them in favor of its own implementations and, thus, fail if they do not work. Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- arch/arm/cpu/armv7/psci.S | 35 +- arch/arm/cpu/armv7/sunxi/psci.S | 117 ++ arch/arm/cpu/armv7/virt-dt.c | 5 +- arch/arm/include/asm/arch-sunxi/cpu.h | 2 + arch/arm/include/asm/psci.h | 24 +-- 5 files changed, 173 insertions(+), 10 deletions(-) diff --git a/arch/arm/cpu/armv7/psci.S b/arch/arm/cpu/armv7/psci.S index bf11a34..e2a38ca 100644 --- a/arch/arm/cpu/armv7/psci.S +++ b/arch/arm/cpu/armv7/psci.S @@ -49,8 +49,18 @@ ENTRY(psci_cpu_suspend) ENTRY(psci_cpu_off) ENTRY(psci_cpu_on) ENTRY(psci_migrate) +ENTRY(psci_affinity_info) +ENTRY(psci_migrate_info_type) +ENTRY(psci_migrate_info_up_cpu) +ENTRY(psci_system_off) +ENTRY(psci_system_reset) mov r0, #ARM_PSCI_RET_NI@ Return -1 (Not Implemented) mov pc, lr +ENDPROC(psci_system_reset) +ENDPROC(psci_system_off) +ENDPROC(psci_migrate_info_up_cpu) +ENDPROC(psci_migrate_info_type) +ENDPROC(psci_affinity_info) ENDPROC(psci_migrate) ENDPROC(psci_cpu_on) ENDPROC(psci_cpu_off) @@ -59,16 +69,33 @@ ENDPROC(psci_cpu_suspend) .weak psci_cpu_off .weak psci_cpu_on .weak psci_migrate +.weak psci_affinity_info +.weak psci_migrate_info_type +.weak psci_migrate_info_up_cpu +.weak psci_system_off +.weak psci_system_reset _psci_table: + .word ARM_PSCI_FN_PSCI_VERSION + .word psci_version .word ARM_PSCI_FN_CPU_SUSPEND .word psci_cpu_suspend .word ARM_PSCI_FN_CPU_OFF .word psci_cpu_off .word ARM_PSCI_FN_CPU_ON .word psci_cpu_on + .word ARM_PSCI_FN_AFFINITY_INFO + .word psci_affinity_info .word ARM_PSCI_FN_MIGRATE .word psci_migrate + .word ARM_PSCI_FN_MIGRATE_INFO_TYPE + .word psci_migrate_info_type + .word ARM_PSCI_FN_MIGRATE_INFO_UP_CPU + .word psci_migrate_info_up_cpu + .word ARM_PSCI_FN_SYSTEM_OFF + .word psci_system_off + .word ARM_PSCI_FN_SYSTEM_RESET + .word psci_system_reset .word 0 .word 0 @@ -86,7 +113,7 @@ _smc_psci: ldr r6, [r4, #4]@ Load target PC cmp r5, #0 @ If reach the end, bail out moveq r0, #ARM_PSCI_RET_INVAL @ Return -2 (Invalid) - beq 2f + beq return cmp r0, r5 @ If not matching, try next entry addne r4, r4, #8 bne 1b @@ -94,9 +121,13 @@ _smc_psci: blx r6 @ Execute PSCI function @ Switch back to non-secure -2: mcr p15, 0, r7, c1, c1, 0 +return:mcr p15, 0, r7, c1, c1, 0 pop {r4-r7, lr} movspc, lr @ Return to the kernel +psci_version: + mov r0, #0x0002 @ Version 0.2 + b return + .popsection diff --git a/arch/arm/cpu/armv7/sunxi/psci.S b/arch/arm/cpu/armv7/sunxi/psci.S index 0aa4007..bba1894 100644 --- a/arch/arm/cpu/armv7/sunxi/psci.S +++ b/arch/arm/cpu/armv7/sunxi/psci.S @@ -2,6 +2,9 @@ * Copyright (C) 2013 - ARM Ltd * Author: Marc Zyngier marc.zyng...@arm.com * + * Copyright (C) Siemens AG, 2014 + * Author: Jan Kiszka jan.kis...@siemens.com + * * Based on code by Carl van Schaik c...@ok-labs.com. * * This program is free software; you can redistribute it and/or modify @@ -42,6 +45,35 @@ #defineGICD_BASE 0x1c81000 #defineGICC_BASE 0x1c82000 +#defineTWI_DATA0x0008 +#defineTWI_CNTR0x000c +#defineTWI_STAT0x0010 +#defineTWI_CCR 0x0014 +#defineTWI_SRST0x0018 + +#defineTWI_CNTR_STOP (1 4) +#defineTWI_CNTR_START (1 5) +#defineTWI_CNTR_BUSEN (1 6) + +#defineTWI_STAT_START_SENT 0x08 +#defineTWI_STAT_ADDR_ACK 0x18 +#defineTWI_STAT_DATA_ACK 0x28 + +#defineTWI_CCR_100KHZ ((11 3) | 2) + +#defineAXP209_ADDR 0x34 +#defineAXP209_REG_SHUTDOWN 0x32 +#defineAXP209_SHUTDOWN_CTRL0x80 + +#defineWDOG_CTL0x00 +#defineWDOG_MODE 0x04 + +#defineWDOG_CTL_RSTART (1 0) + +#defineWDOG_MODE_EN(1 0) +#defineWDOG_MODE_RSTEN (1 1) +#defineWDOG_MODE_0_5_S (0x0 3) + .macro timer_wait reg, ticks @
Re: [U-Boot] [PATCH 2/2] sun7i: Add PSCI v0.2 support
Hi, On 15-12-14 12:37, Jan Kiszka wrote: This extends the PSCI support for the A20 to a dual v0.2 and v0.1 interface. Recent OSes will prefer v0.2, olders will still find the original interface, just at v0.2 service IDs. In addition to the existing services, v0.2 requires us to implement both system off and reset. At least Linux will make use of them in favor of its own implementations and, thus, fail if they do not work. Ugh, that may be a problem, as at least power off is highly SoC specific (different pmics, and newer pmics have a different bus) and somewhat board specific. I think we may avoid adding any board specific stuff for now, since we only want PSCI support on A20 and later and the only boards I know of which are not using the standard axp pmics are all A10 / A13 boards, but this might come back to bite us in the future. Can't we just return -ENOTSUPPORTED or some such ? Regards, Hans Signed-off-by: Jan Kiszka jan.kis...@siemens.com --- arch/arm/cpu/armv7/psci.S | 35 +- arch/arm/cpu/armv7/sunxi/psci.S | 117 ++ arch/arm/cpu/armv7/virt-dt.c | 5 +- arch/arm/include/asm/arch-sunxi/cpu.h | 2 + arch/arm/include/asm/psci.h | 24 +-- 5 files changed, 173 insertions(+), 10 deletions(-) diff --git a/arch/arm/cpu/armv7/psci.S b/arch/arm/cpu/armv7/psci.S index bf11a34..e2a38ca 100644 --- a/arch/arm/cpu/armv7/psci.S +++ b/arch/arm/cpu/armv7/psci.S @@ -49,8 +49,18 @@ ENTRY(psci_cpu_suspend) ENTRY(psci_cpu_off) ENTRY(psci_cpu_on) ENTRY(psci_migrate) +ENTRY(psci_affinity_info) +ENTRY(psci_migrate_info_type) +ENTRY(psci_migrate_info_up_cpu) +ENTRY(psci_system_off) +ENTRY(psci_system_reset) mov r0, #ARM_PSCI_RET_NI@ Return -1 (Not Implemented) mov pc, lr +ENDPROC(psci_system_reset) +ENDPROC(psci_system_off) +ENDPROC(psci_migrate_info_up_cpu) +ENDPROC(psci_migrate_info_type) +ENDPROC(psci_affinity_info) ENDPROC(psci_migrate) ENDPROC(psci_cpu_on) ENDPROC(psci_cpu_off) @@ -59,16 +69,33 @@ ENDPROC(psci_cpu_suspend) .weak psci_cpu_off .weak psci_cpu_on .weak psci_migrate +.weak psci_affinity_info +.weak psci_migrate_info_type +.weak psci_migrate_info_up_cpu +.weak psci_system_off +.weak psci_system_reset _psci_table: + .word ARM_PSCI_FN_PSCI_VERSION + .word psci_version .word ARM_PSCI_FN_CPU_SUSPEND .word psci_cpu_suspend .word ARM_PSCI_FN_CPU_OFF .word psci_cpu_off .word ARM_PSCI_FN_CPU_ON .word psci_cpu_on + .word ARM_PSCI_FN_AFFINITY_INFO + .word psci_affinity_info .word ARM_PSCI_FN_MIGRATE .word psci_migrate + .word ARM_PSCI_FN_MIGRATE_INFO_TYPE + .word psci_migrate_info_type + .word ARM_PSCI_FN_MIGRATE_INFO_UP_CPU + .word psci_migrate_info_up_cpu + .word ARM_PSCI_FN_SYSTEM_OFF + .word psci_system_off + .word ARM_PSCI_FN_SYSTEM_RESET + .word psci_system_reset .word 0 .word 0 @@ -86,7 +113,7 @@ _smc_psci: ldr r6, [r4, #4]@ Load target PC cmp r5, #0 @ If reach the end, bail out moveq r0, #ARM_PSCI_RET_INVAL @ Return -2 (Invalid) - beq 2f + beq return cmp r0, r5 @ If not matching, try next entry addne r4, r4, #8 bne 1b @@ -94,9 +121,13 @@ _smc_psci: blx r6 @ Execute PSCI function @ Switch back to non-secure -2: mcr p15, 0, r7, c1, c1, 0 +return:mcr p15, 0, r7, c1, c1, 0 pop {r4-r7, lr} movspc, lr @ Return to the kernel +psci_version: + mov r0, #0x0002 @ Version 0.2 + b return + .popsection diff --git a/arch/arm/cpu/armv7/sunxi/psci.S b/arch/arm/cpu/armv7/sunxi/psci.S index 0aa4007..bba1894 100644 --- a/arch/arm/cpu/armv7/sunxi/psci.S +++ b/arch/arm/cpu/armv7/sunxi/psci.S @@ -2,6 +2,9 @@ * Copyright (C) 2013 - ARM Ltd * Author: Marc Zyngier marc.zyng...@arm.com * + * Copyright (C) Siemens AG, 2014 + * Author: Jan Kiszka jan.kis...@siemens.com + * * Based on code by Carl van Schaik c...@ok-labs.com. * * This program is free software; you can redistribute it and/or modify @@ -42,6 +45,35 @@ #define GICD_BASE 0x1c81000 #define GICC_BASE 0x1c82000 +#defineTWI_DATA0x0008 +#defineTWI_CNTR0x000c +#defineTWI_STAT0x0010 +#defineTWI_CCR 0x0014 +#defineTWI_SRST0x0018 + +#defineTWI_CNTR_STOP (1 4) +#defineTWI_CNTR_START (1 5) +#defineTWI_CNTR_BUSEN (1 6) + +#defineTWI_STAT_START_SENT 0x08 +#defineTWI_STAT_ADDR_ACK 0x18 +#define
Re: [U-Boot] [PATCH 2/2] sun7i: Add PSCI v0.2 support
On 2014-12-15 12:44, Hans de Goede wrote: Hi, On 15-12-14 12:37, Jan Kiszka wrote: This extends the PSCI support for the A20 to a dual v0.2 and v0.1 interface. Recent OSes will prefer v0.2, olders will still find the original interface, just at v0.2 service IDs. In addition to the existing services, v0.2 requires us to implement both system off and reset. At least Linux will make use of them in favor of its own implementations and, thus, fail if they do not work. Ugh, that may be a problem, as at least power off is highly SoC specific (different pmics, and newer pmics have a different bus) and somewhat board specific. Yes, that was my first thought as well. I think we may avoid adding any board specific stuff for now, since we only want PSCI support on A20 and later and the only boards I know of which are not using the standard axp pmics are all A10 / A13 boards, but this might come back to bite us in the future. Good - so this is a conceptual ack for this patch? Can't we just return -ENOTSUPPORTED or some such ? Unfortunately not. I don't know what was the intention of the designed of this spec regarding mandatory SYSTEM_OFF and SYSTEM_RESET support. Both functions are not supposed to return at all, and the kernel panics when you return from SYSTEM_OFF. Jan -- Siemens AG, Corporate Technology, CT RTC ITP SES-DE Corporate Competence Center Embedded Linux ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] sun7i: Add PSCI v0.2 support
Hi, On 15-12-14 16:27, Jan Kiszka wrote: On 2014-12-15 12:44, Hans de Goede wrote: Hi, On 15-12-14 12:37, Jan Kiszka wrote: This extends the PSCI support for the A20 to a dual v0.2 and v0.1 interface. Recent OSes will prefer v0.2, olders will still find the original interface, just at v0.2 service IDs. In addition to the existing services, v0.2 requires us to implement both system off and reset. At least Linux will make use of them in favor of its own implementations and, thus, fail if they do not work. Ugh, that may be a problem, as at least power off is highly SoC specific (different pmics, and newer pmics have a different bus) and somewhat board specific. Yes, that was my first thought as well. I think we may avoid adding any board specific stuff for now, since we only want PSCI support on A20 and later and the only boards I know of which are not using the standard axp pmics are all A10 / A13 boards, but this might come back to bite us in the future. Good - so this is a conceptual ack for this patch? I guess so I'm still not enthusiastic, but given that there seems no other way (as you indicate below) and that for now I do not foresee any issues, as long as we do a different psci.S per SoC (one for each of sun6i sun7i and sun8i at least), we should be able to make this work. So yes I can live with this. Note it still does not make me happy though (not your fault). Can't we just return -ENOTSUPPORTED or some such ? Unfortunately not. I don't know what was the intention of the designed of this spec regarding mandatory SYSTEM_OFF and SYSTEM_RESET support. Both functions are not supposed to return at all, and the kernel panics when you return from SYSTEM_OFF. Not nice, but nothing we can do to fix the retroactively. Regards, Hans ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot