Add support for Allwinner D1 CLINT
cover Add support for Allwinner D1 CLINT
This series removes the clint,has-no-64bit-mmio property from the MTIMER driver, and instead uses the compatible string to determine if 64-bit MMIO is functional, as suggested on the list[1][2].
According to Guo Ren[3], this quirk only applies to the D1, not to the C9xx processors more generally, so I am using the SoC compatible without a fallback compatible for the CPU implementation.
One question I have: Now that the ACLINT specification is available, and since it is backward compatible, should we describe this hardware as a standard ACLINT MSWI plus a custom ACLINT MTIMER instead of as a custom CLINT? This would minimize the scope of the changes.
[1]: http://lists.infradead.org/pipermail/opensbi/2021-October/001815.html
[2]: http://lists.infradead.org/pipermail/opensbi/2021-October/001841.html
[3]: http://lists.infradead.org/pipermail/opensbi/2021-October/001863.html
docs/platform/thead-c9xx.md | 4 +-- include/sbi_utils/fdt/fdt_helper.h | 2 +- lib/utils/ipi/fdt_ipi_mswi.c | 3 ++- lib/utils/reset/fdt_reset_gpio.c | 4 +-- lib/utils/timer/fdt_timer_mtimer.c | 39 +++++++++++++++++++----------- 5 files changed, 31 insertions(+), 21 deletions(-)
Signature · 1 line
2.32.0
PATCH 1/2 lib: utils/fdt: Require match data to be const
Match data stores hardware attributes which do not change at runtime, so it does not need to be mutable. Make it const.
--- include/sbi_utils/fdt/fdt_helper.h | 2 +- lib/utils/ipi/fdt_ipi_mswi.c | 2 +- lib/utils/reset/fdt_reset_gpio.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
include/sbi_utils/fdt/fdt_helper.h +1 -1
@@ -14,7 +14,7 @@struct fdt_match {const char *compatible; -void *data; +const void *data; };#define FDT_MAX_PHANDLE_ARGS 16
lib/utils/ipi/fdt_ipi_mswi.c +1 -1
@@ -51,7 +51,7 @@ static int ipi_mswi_cold_init(void *fdt, int nodeoff,return 0 ; } -static unsigned long clint_offset =CLINT_MSWI_OFFSET ; +static const unsigned long clint_offset =CLINT_MSWI_OFFSET ;static const struct fdt_match ipi_mswi_match[] = { { .compatible ="riscv,clint0" , .data = &clint_offset },
lib/utils/reset/fdt_reset_gpio.c +2 -2
@@ -121,7 +121,7 @@ static int gpio_reset_init(void *fdt, int nodeoff, }static const struct fdt_match gpio_poweroff_match[] = { - { .compatible ="gpio-poweroff" , .data = (void *)FALSE }, + { .compatible ="gpio-poweroff" , .data = (const void *)FALSE }, { }, };
@@ -131,7 +131,7 @@ struct fdt_reset fdt_poweroff_gpio = { };static const struct fdt_match gpio_reset_match[] = { - { .compatible ="gpio-restart" , .data = (void *)TRUE }, + { .compatible ="gpio-restart" , .data = (const void *)TRUE }, { }, };
Signature · 1 line
2.32.0
PATCH 1/2 lib: utils/fdt: Require match data to be const
Quoted 62 lines · Samuel Holland
Match data stores hardware attributes which do not change at runtime, so it does not need to be mutable. Make it const.
Signed-off-by Samuel Holland <[email protected]>--- include/sbi_utils/fdt/fdt_helper.h | 2 +- lib/utils/ipi/fdt_ipi_mswi.c | 2 +- lib/utils/reset/fdt_reset_gpio.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)include/sbi_utils/fdt/fdt_helper.h +1
-1@@ -14,7 +14,7 @@struct fdt_match {const char *compatible; -void *data; +const void *data; };#define FDT_MAX_PHANDLE_ARGS 16lib/utils/ipi/fdt_ipi_mswi.c +1
-1@@ -51,7 +51,7 @@ static int ipi_mswi_cold_init(void *fdt, int nodeoff,return 0 ; } -static unsigned long clint_offset =CLINT_MSWI_OFFSET ; +static const unsigned long clint_offset =CLINT_MSWI_OFFSET ;static const struct fdt_match ipi_mswi_match[] = { { .compatible ="riscv,clint0" , .data = &clint_offset },lib/utils/reset/fdt_reset_gpio.c +2
-3@@ -121,7 +121,7 @@ static int gpio_reset_init(void *fdt, int nodeoff, }static const struct fdt_match gpio_poweroff_match[] = { - { .compatible ="gpio-poweroff" , .data = (void *)FALSE }, + { .compatible ="gpio-poweroff" , .data = (const void *)FALSE }, { }, };@@ -131,7 +131,7 @@ struct fdt_reset fdt_poweroff_gpio = { };static const struct fdt_match gpio_reset_match[] = { - { .compatible ="gpio-restart" , .data = (void *)TRUE }, + { .compatible ="gpio-restart" , .data = (const void *)TRUE }, { }, }; --2.32.0
Signature · 4 lines
Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/
PATCH 1/2 lib: utils/fdt: Require match data to be const
In reply to Samuel Holland? 2021-10-19???? 20:58 -0500?Samuel Holland???
Quoted 5 lines
Match data stores hardware attributes which do not change at runtime, so
it does not need to be mutable. Make it const.Signed-off-by Samuel Holland <[email protected]>
Quoted 64 lines
---
?include/sbi_utils/fdt/fdt_helper.h | 2 +- ?lib/utils/ipi/fdt_ipi_mswi.c?????? | 2 +- ?lib/utils/reset/fdt_reset_gpio.c?? | 4 ++--?3 files changed, 4 insertions(+), 4 deletions(-)
include/sbi_utils/fdt/fdt_helper.h +0
-0@@ -14,7 +14,7 @@?
?structfdt_match{
????????const char *compatible;
-???????void *data;
+???????const void *data;
?};
?
?#defineFDT_MAX_PHANDLE_ARGS16lib/utils/ipi/fdt_ipi_mswi.c +0
-0@@ -51,7 +51,7 @@ static int ipi_mswi_cold_init(void *fdt, int nodeoff, ????????return 0; ?}?
lib/utils/ipi/fdt_ipi_mswi.c +1
-1-static unsigned long clint_offset =CLINT_MSWI_OFFSET ; +static const unsigned long clint_offset =CLINT_MSWI_OFFSET ;?
?static const structfdt_matchipi_mswi_match[] = { ????????{ .compatible = "riscv,clint0", .data =&clint_offset},lib/utils/reset/fdt_reset_gpio.c +0
-0@@ -121,7 +121,7 @@ static int gpio_reset_init(void *fdt, int nodeoff, ?}?
?static const structfdt_matchgpio_poweroff_match[] = { -???????{ .compatible = "gpio-poweroff", .data = (void *)FALSE }, +???????{ .compatible = "gpio-poweroff", .data = (const void *)FALSE },
????????{ },
?};
?lib/utils/reset/fdt_reset_gpio.c +0
-0@@ -131,7 +131,7 @@ struct fdt_reset fdt_poweroff_gpio = { ?};?
?static const structfdt_matchgpio_reset_match[] = { -???????{ .compatible = "gpio-restart", .data = (void *)TRUE }, +???????{ .compatible = "gpio-restart", .data = (const void *)TRUE }, ????????{ },
?};
?Signature · 1 line
2.32.0
RFC PATCH 2/2 lib: utils/timer: Add a separate compatible for the D1 CLINT
In reply to Samuel HollandThe CLINT in the Allwinner D1 SoC apparently does not support 64-bit MMIO access. A property was added to support this quirk (and that property was copied to the ACLINT MTIMER code). However, since this difference in behavior makes the D1 CLINT incompatible with the SiFive CLINT's programming interface, a better solution is to use a separate compatible string.
--- docs/platform/thead-c9xx.md | 4 +-- lib/utils/ipi/fdt_ipi_mswi.c | 1 + lib/utils/timer/fdt_timer_mtimer.c | 39 +++++++++++++++++++----------- 3 files changed, 27 insertions(+), 17 deletions(-)
docs/platform/thead-c9xx.md +1 -3
@@ -52,12 +52,11 @@ DTS Example1: (Single core, eg: Allwinner D1 - c906) ranges; clint0: clint at 14000000 { - compatible = "riscv,clint0"; + compatible = "allwinner,sun20i-d1-clint"; interrupts-extended = < &cpu0_intc 3 &cpu0_intc 7 >; reg = <0x0 0x14000000 0x0 0x04000000>; - clint,has-no-64bit-mmio; }; intc: interrupt-controller at 10000000 {
@@ -163,7 +162,6 @@ DTS Example2: (Multi cores with soc reset-regs) &cpu4_intc 3 &cpu4_intc 7 >; reg = <0xff 0xdc000000 0x0 0x04000000>; - clint,has-no-64bit-mmio; }; intc: interrupt-controller at ffd8000000 {
lib/utils/ipi/fdt_ipi_mswi.c +1 -0
@@ -54,6 +54,7 @@ static int ipi_mswi_cold_init(void *fdt, int nodeoff,static const unsigned long clint_offset =CLINT_MSWI_OFFSET ;static const struct fdt_match ipi_mswi_match[] = { + { .compatible ="allwinner,sun20i-d1-clint" , .data = &clint_offset }, { .compatible ="riscv,clint0" , .data = &clint_offset }, { .compatible ="sifive,clint0" , .data = &clint_offset }, { .compatible ="riscv,aclint-mswi" },
lib/utils/timer/fdt_timer_mtimer.c +25 -14
@@ -15,6 +15,11 @@#define MTIMER_MAX_NR 16 +struct timer_mtimer_quirks { +unsigned int mtime_offset; +bool has_64bit_mmio; +}; +static unsigned long mtimer_count =0 ;static struct aclint_mtimer_data mtimer[MTIMER_MAX_NR ];static struct aclint_mtimer_data *mt_reference =NULL ;
@@ -23,7 +28,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, const struct fdt_match *match) {int i, rc; -unsigned long offset, addr[2 ], size[2 ]; +unsigned long addr[2 ], size[2 ];struct aclint_mtimer_data *mt;if (MTIMER_MAX_NR <= mtimer_count)
@@ -43,28 +48,25 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,return rc;if (match->data) {/* SiFive CLINT */ +const struct timer_mtimer_quirks *quirks = match->data; +/* Set CLINT addresses */ mt->mtimecmp_addr = addr[0 ] +ACLINT_DEFAULT_MTIMECMP_OFFSET ; mt->mtimecmp_size =ACLINT_DEFAULT_MTIMECMP_SIZE ; mt->mtime_addr = addr[0 ] +ACLINT_DEFAULT_MTIME_OFFSET ; mt->mtime_size = size[0 ] - mt->mtimecmp_size;/* Adjust MTIMER address and size for CLINT device */ - offset = *((unsigned long *)match->data); - mt->mtime_addr += offset; - mt->mtimecmp_addr += offset; - mt->mtime_size -= offset; -/* Parse additional CLINT properties */ -if (fdt_getprop (fdt, nodeoff,"clint,has-no-64bit-mmio" , &rc)) - mt->has_64bit_mmio = false; + mt->mtime_addr += quirks->mtime_offset; + mt->mtimecmp_addr += quirks->mtime_offset; + mt->mtime_size -= quirks->mtime_offset; +/* Apply additional CLINT quirks */ + mt->has_64bit_mmio = quirks->has_64bit_mmio; }else {/* RISC-V ACLINT MTIMER */ /* Set ACLINT MTIMER addresses */ mt->mtime_addr = addr[0 ]; mt->mtime_size = size[0 ]; mt->mtimecmp_addr = addr[1 ]; mt->mtimecmp_size = size[1 ]; -/* Parse additional ACLINT MTIMER properties */ -if (fdt_getprop (fdt, nodeoff,"mtimer,no-64bit-mmio" , &rc)) - mt->has_64bit_mmio = false; }/* Check if MTIMER device has shared MTIME address */
@@ -107,11 +109,20 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,return 0 ; } -static unsigned long clint_offset =CLINT_MTIMER_OFFSET ; +static const struct timer_mtimer_quirks d1_clint_quirks = { + .mtime_offset =CLINT_MTIMER_OFFSET , + .has_64bit_mmio = false, +}; + +static const struct timer_mtimer_quirks sifive_clint_quirks = { + .mtime_offset =CLINT_MTIMER_OFFSET , + .has_64bit_mmio = true, +};static const struct fdt_match timer_mtimer_match[] = { - { .compatible ="riscv,clint0" , .data = &clint_offset }, - { .compatible ="sifive,clint0" , .data = &clint_offset }, + { .compatible ="allwinner,sun20i-d1-clint" , .data = &d1_clint_quirks }, + { .compatible ="riscv,clint0" , .data = &sifive_clint_quirks }, + { .compatible ="sifive,clint0" , .data = &sifive_clint_quirks }, { .compatible ="riscv,aclint-mtimer" }, { }, };
Signature · 1 line
2.32.0
RFC PATCH 2/2 lib: utils/timer: Add a separate compatible for the D1 CLINT
Quoted 34 lines · Samuel Holland
The CLINT in the Allwinner D1 SoC apparently does not support 64-bit MMIO access. A property was added to support this quirk (and that property was copied to the ACLINT MTIMER code). However, since this difference in behavior makes the D1 CLINT incompatible with the SiFive CLINT's programming interface, a better solution is to use a separate compatible string.
Signed-off-by Samuel Holland <[email protected]>--- docs/platform/thead-c9xx.md | 4 +-- lib/utils/ipi/fdt_ipi_mswi.c | 1 + lib/utils/timer/fdt_timer_mtimer.c | 39 +++++++++++++++++++----------- 3 files changed, 27 insertions(+), 17 deletions(-)docs/platform/thead-c9xx.md +1
-2@@ -52,12 +52,11 @@ DTS Example1: (Single core, eg: Allwinner D1 - c906) ranges; clint0: clint at 14000000 { - compatible = "riscv,clint0"; + compatible = "allwinner,sun20i-d1-clint"; interrupts-extended = < &cpu0_intc 3 &cpu0_intc 7 >; reg = <0x0 0x14000000 0x0 0x04000000>; - clint,has-no-64bit-mmio; }; intc: interrupt-controller at 10000000 {
docs/platform/thead-c9xx.md DTS Example2: (Multi cores with soc reset-regs) · line 166
Quoted 4 lines
docs/platform/thead-c9xx.md +0
-1@@ -163,7 +162,6 @@ DTS Example2: (Multi cores with soc reset-regs) &cpu4_intc 3 &cpu4_intc 7 >; reg = <0xff 0xdc000000 0x0 0x04000000>; - clint,has-no-64bit-mmio;
Could we still keep clint,has-no-64bit-mmio for compatible? It has been widely used in our customers' dts.
Quoted 63 lines
docs/platform/thead-c9xx.md +0
-0}; intc: interrupt-controller at ffd8000000 {lib/utils/ipi/fdt_ipi_mswi.c +1
-0@@ -54,6 +54,7 @@ static int ipi_mswi_cold_init(void *fdt, int nodeoff,static const unsigned long clint_offset =CLINT_MSWI_OFFSET ;static const struct fdt_match ipi_mswi_match[] = { + { .compatible ="allwinner,sun20i-d1-clint" , .data = &clint_offset }, { .compatible ="riscv,clint0" , .data = &clint_offset }, { .compatible ="sifive,clint0" , .data = &clint_offset }, { .compatible ="riscv,aclint-mswi" },lib/utils/timer/fdt_timer_mtimer.c +12
-8@@ -15,6 +15,11 @@#define MTIMER_MAX_NR 16 +struct timer_mtimer_quirks { +unsigned int mtime_offset; +bool has_64bit_mmio; +}; +static unsigned long mtimer_count =0 ;static struct aclint_mtimer_data mtimer[MTIMER_MAX_NR ];static struct aclint_mtimer_data *mt_reference =NULL ;@@ -23,7 +28,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, const struct fdt_match *match) {int i, rc; -unsigned long offset, addr[2 ], size[2 ]; +unsigned long addr[2 ], size[2 ];struct aclint_mtimer_data *mt;if (MTIMER_MAX_NR <= mtimer_count)@@ -43,28 +48,25 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,return rc;if (match->data) {/* SiFive CLINT */ +const struct timer_mtimer_quirks *quirks = match->data; +/* Set CLINT addresses */ mt->mtimecmp_addr = addr[0 ] +ACLINT_DEFAULT_MTIMECMP_OFFSET ; mt->mtimecmp_size =ACLINT_DEFAULT_MTIMECMP_SIZE ; mt->mtime_addr = addr[0 ] +ACLINT_DEFAULT_MTIME_OFFSET ; mt->mtime_size = size[0 ] - mt->mtimecmp_size;/* Adjust MTIMER address and size for CLINT device */ - offset = *((unsigned long *)match->data); - mt->mtime_addr += offset; - mt->mtimecmp_addr += offset; - mt->mtime_size -= offset; -/* Parse additional CLINT properties */ -if (fdt_getprop (fdt, nodeoff,"clint,has-no-64bit-mmio" , &rc)) - mt->has_64bit_mmio = false; + mt->mtime_addr += quirks->mtime_offset; + mt->mtimecmp_addr += quirks->mtime_offset; + mt->mtime_size -= quirks->mtime_offset; +/* Apply additional CLINT quirks */
lib/utils/timer/fdt_timer_mtimer.c static int timer_mtimer_cold_init(void *fdt, int nodeoff, · line 67
Quoted 10 lines
lib/utils/timer/fdt_timer_mtimer.c +1
-3+ mt->has_64bit_mmio = quirks->has_64bit_mmio; }else {/* RISC-V ACLINT MTIMER */ /* Set ACLINT MTIMER addresses */ mt->mtime_addr = addr[0 ]; mt->mtime_size = size[0 ]; mt->mtimecmp_addr = addr[1 ]; mt->mtimecmp_size = size[1 ]; -/* Parse additional ACLINT MTIMER properties */ -if (fdt_getprop (fdt, nodeoff,"mtimer,no-64bit-mmio" , &rc)) - mt->has_64bit_mmio = false;
Dito.
Quoted 30 lines
lib/utils/timer/fdt_timer_mtimer.c +12
-4}/* Check if MTIMER device has shared MTIME address */ @@ -107,11 +109,20 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,return 0 ; } -static unsigned long clint_offset =CLINT_MTIMER_OFFSET ; +static const struct timer_mtimer_quirks d1_clint_quirks = { + .mtime_offset =CLINT_MTIMER_OFFSET , + .has_64bit_mmio = false, +}; + +static const struct timer_mtimer_quirks sifive_clint_quirks = { + .mtime_offset =CLINT_MTIMER_OFFSET , + .has_64bit_mmio = true, +};static const struct fdt_match timer_mtimer_match[] = { - { .compatible ="riscv,clint0" , .data = &clint_offset }, - { .compatible ="sifive,clint0" , .data = &clint_offset }, + { .compatible ="allwinner,sun20i-d1-clint" , .data = &d1_clint_quirks }, + { .compatible ="riscv,clint0" , .data = &sifive_clint_quirks }, + { .compatible ="sifive,clint0" , .data = &sifive_clint_quirks }, { .compatible ="riscv,aclint-mtimer" }, { }, }; --2.32.0
Signature · 4 lines
Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/
RFC PATCH 2/2 lib: utils/timer: Add a separate compatible for the D1 CLINT
Quoted 33 lines · Guo Ren
Quoted 32 lines · Samuel Holland
The CLINT in the Allwinner D1 SoC apparently does not support 64-bit MMIO access. A property was added to support this quirk (and that property was copied to the ACLINT MTIMER code). However, since this difference in behavior makes the D1 CLINT incompatible with the SiFive CLINT's programming interface, a better solution is to use a separate compatible string.
Signed-off-by Samuel Holland <[email protected]>--- docs/platform/thead-c9xx.md | 4 +-- lib/utils/ipi/fdt_ipi_mswi.c | 1 + lib/utils/timer/fdt_timer_mtimer.c | 39 +++++++++++++++++++----------- 3 files changed, 27 insertions(+), 17 deletions(-)docs/platform/thead-c9xx.md +1
-2@@ -52,12 +52,11 @@ DTS Example1: (Single core, eg: Allwinner D1 - c906) ranges; clint0: clint at 14000000 { - compatible = "riscv,clint0"; + compatible = "allwinner,sun20i-d1-clint"; interrupts-extended = < &cpu0_intc 3 &cpu0_intc 7 >; reg = <0x0 0x14000000 0x0 0x04000000>; - clint,has-no-64bit-mmio; };
Quoted 8 lines
docs/platform/thead-c9xx.md DTS Example2: (Multi cores with soc reset-regs) · line 166
Quoted 6 lines
docs/platform/thead-c9xx.md +0
-1intc: interrupt-controller at 10000000 {@@ -163,7 +162,6 @@ DTS Example2: (Multi cores with soc reset-regs) &cpu4_intc 3 &cpu4_intc 7 >; reg = <0xff 0xdc000000 0x0 0x04000000>; - clint,has-no-64bit-mmio;Could we still keep clint,has-no-64bit-mmio for compatible? It has been widely used in our customers' dts.
We need a description of the T-HEAD clint that is acceptable for the Linux kernel.
According to the discussion in
https://lore.kernel.org/all/CAAhSdy3JU6jitTWFk4CVRG5Xc7P7ueZzd=xmnKBNpx8eGaR6hw at mail.gmail.com/ we shall drop "clint,has-no-64bit-mmio;"
In
https://lore.kernel.org/all/7361287f-9c07-8b76-d405-35f287ac1706 at canonical.com/ it was suggested to use
}
compatible = {"allwinner,sun20i-d1-clint", "thead,clint0"}.
Should we check on "thead,clint0" in the code?
Best regards
Heinrich
Quoted 108 lines
Quoted 64 lines
docs/platform/thead-c9xx.md +0
-0}; intc: interrupt-controller at ffd8000000 {lib/utils/ipi/fdt_ipi_mswi.c +1
-0@@ -54,6 +54,7 @@ static int ipi_mswi_cold_init(void *fdt, int nodeoff,static const unsigned long clint_offset =CLINT_MSWI_OFFSET ;static const struct fdt_match ipi_mswi_match[] = { + { .compatible ="allwinner,sun20i-d1-clint" , .data = &clint_offset }, { .compatible ="riscv,clint0" , .data = &clint_offset }, { .compatible ="sifive,clint0" , .data = &clint_offset }, { .compatible ="riscv,aclint-mswi" },lib/utils/timer/fdt_timer_mtimer.c +12
-8@@ -15,6 +15,11 @@#define MTIMER_MAX_NR 16 +struct timer_mtimer_quirks { +unsigned int mtime_offset; +bool has_64bit_mmio; +}; +static unsigned long mtimer_count =0 ;static struct aclint_mtimer_data mtimer[MTIMER_MAX_NR ];static struct aclint_mtimer_data *mt_reference =NULL ;@@ -23,7 +28,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, const struct fdt_match *match) {int i, rc; -unsigned long offset, addr[2 ], size[2 ]; +unsigned long addr[2 ], size[2 ];struct aclint_mtimer_data *mt;if (MTIMER_MAX_NR <= mtimer_count)@@ -43,28 +48,25 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,return rc;if (match->data) {/* SiFive CLINT */ +const struct timer_mtimer_quirks *quirks = match->data; +/* Set CLINT addresses */ mt->mtimecmp_addr = addr[0 ] +ACLINT_DEFAULT_MTIMECMP_OFFSET ; mt->mtimecmp_size =ACLINT_DEFAULT_MTIMECMP_SIZE ; mt->mtime_addr = addr[0 ] +ACLINT_DEFAULT_MTIME_OFFSET ; mt->mtime_size = size[0 ] - mt->mtimecmp_size;/* Adjust MTIMER address and size for CLINT device */ - offset = *((unsigned long *)match->data); - mt->mtime_addr += offset; - mt->mtimecmp_addr += offset; - mt->mtime_size -= offset; -/* Parse additional CLINT properties */ -if (fdt_getprop (fdt, nodeoff,"clint,has-no-64bit-mmio" , &rc)) - mt->has_64bit_mmio = false; + mt->mtime_addr += quirks->mtime_offset; + mt->mtimecmp_addr += quirks->mtime_offset; + mt->mtime_size -= quirks->mtime_offset; +/* Apply additional CLINT quirks */ lib/utils/timer/fdt_timer_mtimer.c static int timer_mtimer_cold_init(void *fdt, int nodeoff, · line 67
Quoted 10 lines
lib/utils/timer/fdt_timer_mtimer.c +1
-3+ mt->has_64bit_mmio = quirks->has_64bit_mmio; }else {/* RISC-V ACLINT MTIMER */ /* Set ACLINT MTIMER addresses */ mt->mtime_addr = addr[0 ]; mt->mtime_size = size[0 ]; mt->mtimecmp_addr = addr[1 ]; mt->mtimecmp_size = size[1 ]; -/* Parse additional ACLINT MTIMER properties */ -if (fdt_getprop (fdt, nodeoff,"mtimer,no-64bit-mmio" , &rc)) - mt->has_64bit_mmio = false;Dito.
Quoted 30 lines
lib/utils/timer/fdt_timer_mtimer.c +12
-4}/* Check if MTIMER device has shared MTIME address */ @@ -107,11 +109,20 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,return 0 ; } -static unsigned long clint_offset =CLINT_MTIMER_OFFSET ; +static const struct timer_mtimer_quirks d1_clint_quirks = { + .mtime_offset =CLINT_MTIMER_OFFSET , + .has_64bit_mmio = false, +}; + +static const struct timer_mtimer_quirks sifive_clint_quirks = { + .mtime_offset =CLINT_MTIMER_OFFSET , + .has_64bit_mmio = true, +};static const struct fdt_match timer_mtimer_match[] = { - { .compatible ="riscv,clint0" , .data = &clint_offset }, - { .compatible ="sifive,clint0" , .data = &clint_offset }, + { .compatible ="allwinner,sun20i-d1-clint" , .data = &d1_clint_quirks }, + { .compatible ="riscv,clint0" , .data = &sifive_clint_quirks }, + { .compatible ="sifive,clint0" , .data = &sifive_clint_quirks }, { .compatible ="riscv,aclint-mtimer" }, { }, }; --2.32.0
RFC PATCH 2/2 lib: utils/timer: Add a separate compatible for the D1 CLINT
Quoted 44 lines · Heinrich Schuchardt
Quoted 33 lines · Guo Ren
Quoted 32 lines · Samuel Holland
The CLINT in the Allwinner D1 SoC apparently does not support 64-bit MMIO access. A property was added to support this quirk (and that property was copied to the ACLINT MTIMER code). However, since this difference in behavior makes the D1 CLINT incompatible with the SiFive CLINT's programming interface, a better solution is to use a separate compatible string.
Signed-off-by Samuel Holland <[email protected]>--- docs/platform/thead-c9xx.md | 4 +-- lib/utils/ipi/fdt_ipi_mswi.c | 1 + lib/utils/timer/fdt_timer_mtimer.c | 39 +++++++++++++++++++----------- 3 files changed, 27 insertions(+), 17 deletions(-)docs/platform/thead-c9xx.md +1
-2@@ -52,12 +52,11 @@ DTS Example1: (Single core, eg: Allwinner D1 - c906) ranges; clint0: clint at 14000000 { - compatible = "riscv,clint0"; + compatible = "allwinner,sun20i-d1-clint"; interrupts-extended = < &cpu0_intc 3 &cpu0_intc 7 >; reg = <0x0 0x14000000 0x0 0x04000000>; - clint,has-no-64bit-mmio; };Quoted 8 lines
docs/platform/thead-c9xx.md DTS Example2: (Multi cores with soc reset-regs) · line 166
Quoted 6 lines
docs/platform/thead-c9xx.md +0
-1intc: interrupt-controller at 10000000 {@@ -163,7 +162,6 @@ DTS Example2: (Multi cores with soc reset-regs) &cpu4_intc 3 &cpu4_intc 7 >; reg = <0xff 0xdc000000 0x0 0x04000000>; - clint,has-no-64bit-mmio;Could we still keep clint,has-no-64bit-mmio for compatible? It has been widely used in our customers' dts.
Quoted 6 lines
We need a description of the T-HEAD clint that is acceptable for the Linux kernel.
According to the discussion in
https://lore.kernel.org/all/CAAhSdy3JU6jitTWFk4CVRG5Xc7P7ueZzd=xmnKBNpx8eGaR6hw at mail.gmail.com/ we shall drop "clint,has-no-64bit-mmio;"
I suggest keeping it for compatibility. Others are okay.
Quoted 8 lines
In
https://lore.kernel.org/all/7361287f-9c07-8b76-d405-35f287ac1706 at canonical.com/ it was suggested to use
}
compatible = {"allwinner,sun20i-d1-clint", "thead,clint0"}.Should we check on "thead,clint0" in the code?
Yes, I suggest that.
Quoted 113 lines
Best regards
Heinrich
Quoted 108 lines
Quoted 64 lines
docs/platform/thead-c9xx.md +0
-0}; intc: interrupt-controller at ffd8000000 {lib/utils/ipi/fdt_ipi_mswi.c +1
-0@@ -54,6 +54,7 @@ static int ipi_mswi_cold_init(void *fdt, int nodeoff,static const unsigned long clint_offset =CLINT_MSWI_OFFSET ;static const struct fdt_match ipi_mswi_match[] = { + { .compatible ="allwinner,sun20i-d1-clint" , .data = &clint_offset }, { .compatible ="riscv,clint0" , .data = &clint_offset }, { .compatible ="sifive,clint0" , .data = &clint_offset }, { .compatible ="riscv,aclint-mswi" },lib/utils/timer/fdt_timer_mtimer.c +12
-8@@ -15,6 +15,11 @@#define MTIMER_MAX_NR 16 +struct timer_mtimer_quirks { +unsigned int mtime_offset; +bool has_64bit_mmio; +}; +static unsigned long mtimer_count =0 ;static struct aclint_mtimer_data mtimer[MTIMER_MAX_NR ];static struct aclint_mtimer_data *mt_reference =NULL ;@@ -23,7 +28,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, const struct fdt_match *match) {int i, rc; -unsigned long offset, addr[2 ], size[2 ]; +unsigned long addr[2 ], size[2 ];struct aclint_mtimer_data *mt;if (MTIMER_MAX_NR <= mtimer_count)@@ -43,28 +48,25 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,return rc;if (match->data) {/* SiFive CLINT */ +const struct timer_mtimer_quirks *quirks = match->data; +/* Set CLINT addresses */ mt->mtimecmp_addr = addr[0 ] +ACLINT_DEFAULT_MTIMECMP_OFFSET ; mt->mtimecmp_size =ACLINT_DEFAULT_MTIMECMP_SIZE ; mt->mtime_addr = addr[0 ] +ACLINT_DEFAULT_MTIME_OFFSET ; mt->mtime_size = size[0 ] - mt->mtimecmp_size;/* Adjust MTIMER address and size for CLINT device */ - offset = *((unsigned long *)match->data); - mt->mtime_addr += offset; - mt->mtimecmp_addr += offset; - mt->mtime_size -= offset; -/* Parse additional CLINT properties */ -if (fdt_getprop (fdt, nodeoff,"clint,has-no-64bit-mmio" , &rc)) - mt->has_64bit_mmio = false; + mt->mtime_addr += quirks->mtime_offset; + mt->mtimecmp_addr += quirks->mtime_offset; + mt->mtime_size -= quirks->mtime_offset; +/* Apply additional CLINT quirks */ lib/utils/timer/fdt_timer_mtimer.c static int timer_mtimer_cold_init(void *fdt, int nodeoff, · line 67
Quoted 10 lines
lib/utils/timer/fdt_timer_mtimer.c +1
-3+ mt->has_64bit_mmio = quirks->has_64bit_mmio; }else {/* RISC-V ACLINT MTIMER */ /* Set ACLINT MTIMER addresses */ mt->mtime_addr = addr[0 ]; mt->mtime_size = size[0 ]; mt->mtimecmp_addr = addr[1 ]; mt->mtimecmp_size = size[1 ]; -/* Parse additional ACLINT MTIMER properties */ -if (fdt_getprop (fdt, nodeoff,"mtimer,no-64bit-mmio" , &rc)) - mt->has_64bit_mmio = false;Dito.
Quoted 30 lines
lib/utils/timer/fdt_timer_mtimer.c +12
-4}/* Check if MTIMER device has shared MTIME address */ @@ -107,11 +109,20 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,return 0 ; } -static unsigned long clint_offset =CLINT_MTIMER_OFFSET ; +static const struct timer_mtimer_quirks d1_clint_quirks = { + .mtime_offset =CLINT_MTIMER_OFFSET , + .has_64bit_mmio = false, +}; + +static const struct timer_mtimer_quirks sifive_clint_quirks = { + .mtime_offset =CLINT_MTIMER_OFFSET , + .has_64bit_mmio = true, +};static const struct fdt_match timer_mtimer_match[] = { - { .compatible ="riscv,clint0" , .data = &clint_offset }, - { .compatible ="sifive,clint0" , .data = &clint_offset }, + { .compatible ="allwinner,sun20i-d1-clint" , .data = &d1_clint_quirks }, + { .compatible ="riscv,clint0" , .data = &sifive_clint_quirks }, + { .compatible ="sifive,clint0" , .data = &sifive_clint_quirks }, { .compatible ="riscv,aclint-mtimer" }, { }, }; --2.32.0
Signature · 4 lines
Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/
RFC PATCH 2/2 lib: utils/timer: Add a separate compatible for the D1 CLINT
In reply to Samuel Holland? 2021-10-19???? 20:58 -0500?Samuel Holland???
Quoted 89 lines
The CLINT in the Allwinner D1 SoC apparently does not support 64-bit MMIO access. A property was added to support this quirk (and that property was copied to the ACLINT MTIMER code). However, since this difference in behavior makes the D1 CLINT incompatible with the SiFive
CLINT's programming interface, a better solution is to use a separate compatible string.Signed-off-by Samuel Holland <[email protected]>---
?docs/platform/thead-c9xx.md??????? |? 4 +-- ?lib/utils/ipi/fdt_ipi_mswi.c?????? |? 1 + ?lib/utils/timer/fdt_timer_mtimer.c | 39 +++++++++++++++++++-----------
?3 files changed, 27 insertions(+), 17 deletions(-)docs/platform/thead- renamed from docs/platform/thead-c9xx.md +0
-0c9xx.md
index 3490ed5..ced784d 100644docs/platform/thead-c9xx.md +0
-0@@ -52,12 +52,11 @@ DTS Example1: (Single core, eg: Allwinner D1 - c906) ????????????????ranges;?
????????????????clint0: clint at 14000000 { -???????????????????????compatible = "riscv,clint0"; +???????????????????????compatible = "allwinner,sun20i-d1-clint"; ????????????????????????interrupts-extended = < ????????????????????????????????&cpu0_intc? 3&cpu0_intc? 7 ????????????????????????????????>; ????????????????????????reg = <0x00x140000000x00x04000000>; -???????????????????????clint,has-no-64bit-mmio; ????????????????};
?
????????????????intc: interrupt-controller at 10000000 {docs/platform/thead-c9xx.md +0
-0@@ -163,7 +162,6 @@ DTS Example2: (Multi cores with soc reset-regs)????????????????????????????????&cpu4_intc? 3
&cpu4_intc? 7 ????????????????????????????????>; ????????????????????????reg = <0xff0xdc0000000x00x04000000>; -???????????????????????clint,has-no-64bit-mmio; ????????????????};
?
????????????????intc: interrupt-controller atffd8000000{lib/utils/ipi/fdt_ipi_mswi.c +0
-0@@ -54,6 +54,7 @@ static int ipi_mswi_cold_init(void *fdt, int nodeoff, ?static const unsigned long clint_offset = CLINT_MSWI_OFFSET;?
?static const structfdt_matchipi_mswi_match[] = { +???????{ .compatible = "allwinner,sun20i-d1-clint", .data =&clint_offset},
????????{ .compatible = "riscv,clint0", .data =&clint_offset}, ????????{ .compatible = "sifive,clint0", .data =&clint_offset}, ????????{ .compatible = "riscv,aclint-mswi" },lib/utils/timer/fdt_timer_mtimer.c +0
-0@@ -15,6 +15,11 @@?
?#define MTIMER_MAX_NR??????????????????16
?lib/utils/timer/fdt_timer_mtimer.c +5
-0+struct timer_mtimer_quirks { +???????unsigned int????mtime_offset; +???????bool????????????has_64bit_mmio; +}; +?static unsigned long
mtimer_count= 0;
?static structaclint_mtimer_datamtimer[MTIMER_MAX_NR]; ?static structaclint_mtimer_data*mt_reference= NULL;lib/utils/timer/fdt_timer_mtimer.c +1
-1@@ -23,7 +28,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, ????????????????????????????????? const struct fdt_match *match) ?{ ????????int i, rc; -???????unsigned long offset, addr[2], size[2]; +???????unsigned long addr[2], size[2]; ????????struct aclint_mtimer_data *mt;?
????????if (MTIMER_MAX_NR<=mtimer_count)lib/utils/timer/fdt_timer_mtimer.c +0
-0@@ -43,28 +48,25 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, ????????????????return rc;
Quoted 4 lines
?
????????if (match->data) { /* SiFive CLINT */ +???????????????const structtimer_mtimer_quirks*quirks = match-Quoted 1 line
data;
This looks good!
When compatible is not ?allwinner, sun20i-d1-clint?, accessing quirks-
Quoted 1 line
has_64bit_mmiowill cause access to incorrect memory. Please correct
the data in ipi_mswi_match to timer_mtimer_quirks type.
Regards,
Xiang W
Quoted 67 lines
+
????????????????/* Set CLINT addresses */ ????????????????mt->mtimecmp_addr = addr[0] +ACLINT_DEFAULT_MTIMECMP_OFFSET; ????????????????mt->mtimecmp_size =ACLINT_DEFAULT_MTIMECMP_SIZE; ????????????????mt->mtime_addr = addr[0] +ACLINT_DEFAULT_MTIME_OFFSET; ????????????????mt->mtime_size = size[0] -mt->mtimecmp_size; ????????????????/* Adjust MTIMER address and size for CLINT device */ -???????????????offset = *((unsigned long *)match->data); -???????????????mt->mtime_addr += offset; -???????????????mt->mtimecmp_addr += offset; -???????????????mt->mtime_size -= offset; -???????????????/* Parse additional CLINT properties */ -???????????????if (fdt_getprop(fdt, nodeoff, "clint,has-no-64bit- mmio", &rc))
-???????????????????????mt->has_64bit_mmio = false; +???????????????mt->mtime_addr +=quirks->mtime_offset; +???????????????mt->mtimecmp_addr +=quirks->mtime_offset; +???????????????mt->mtime_size -=quirks->mtime_offset; +???????????????/* Apply additional CLINT quirks */ +???????????????mt->has_64bit_mmio =quirks->has_64bit_mmio; ????????} else { /* RISC-V ACLINT MTIMER */ ????????????????/* Set ACLINT MTIMER addresses */ ????????????????mt->mtime_addr = addr[0]; ????????????????mt->mtime_size = size[0]; ????????????????mt->mtimecmp_addr = addr[1]; ????????????????mt->mtimecmp_size = size[1]; -???????????????/* Parse additional ACLINT MTIMER properties */ -???????????????if (fdt_getprop(fdt, nodeoff, "mtimer,no-64bit-mmio", &rc))
-???????????????????????mt->has_64bit_mmio = false; ????????}
?
????????/* Check if MTIMER device has shared MTIME address */lib/utils/timer/fdt_timer_mtimer.c +0
-0@@ -107,11 +109,20 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, ????????return 0; ?}?
lib/utils/timer/fdt_timer_mtimer.c +9
-1-static unsigned long clint_offset =CLINT_MTIMER_OFFSET ; +static const struct timer_mtimer_quirks d1_clint_quirks = { +???????.mtime_offset???= CLINT_MTIMER_OFFSET, +???????.has_64bit_mmio?= false, +}; + +static const struct timer_mtimer_quirks sifive_clint_quirks = { +???????.mtime_offset???= CLINT_MTIMER_OFFSET, +???????.has_64bit_mmio?= true, +};?
?static const structfdt_matchtimer_mtimer_match[] = { -???????{ .compatible = "riscv,clint0", .data =&clint_offset}, -???????{ .compatible = "sifive,clint0", .data =&clint_offset}, +???????{ .compatible = "allwinner,sun20i-d1-clint", .data =&d1_clint_quirks},
+???????{ .compatible = "riscv,clint0", .data =&sifive_clint_quirks},
+???????{ .compatible = "sifive,clint0", .data =&sifive_clint_quirks},
????????{ .compatible = "riscv,aclint-mtimer" },
????????{ },
?};Signature · 1 line
2.32.0
RFC PATCH 2/2 lib: utils/timer: Add a separate compatible for the D1 CLINT
In reply to Samuel HollandQuoted 79 lines · Samuel Holland
The CLINT in the Allwinner D1 SoC apparently does not support 64-bit MMIO access. A property was added to support this quirk (and that property was copied to the ACLINT MTIMER code). However, since this difference in behavior makes the D1 CLINT incompatible with the SiFive CLINT's programming interface, a better solution is to use a separate compatible string.
Signed-off-by Samuel Holland <[email protected]>---
docs/platform/thead-c9xx.md | 4 +-- lib/utils/ipi/fdt_ipi_mswi.c | 1 + lib/utils/timer/fdt_timer_mtimer.c | 39 +++++++++++++++++++----------- 3 files changed, 27 insertions(+), 17 deletions(-)docs/platform/thead-c9xx.md +1
-3@@ -52,12 +52,11 @@ DTS Example1: (Single core, eg: Allwinner D1 - c906) ranges; clint0: clint at 14000000 { - compatible = "riscv,clint0"; + compatible = "allwinner,sun20i-d1-clint"; interrupts-extended = < &cpu0_intc 3 &cpu0_intc 7 >; reg = <0x0 0x14000000 0x0 0x04000000>; - clint,has-no-64bit-mmio; }; intc: interrupt-controller at 10000000 {@@ -163,7 +162,6 @@ DTS Example2: (Multi cores with soc reset-regs) &cpu4_intc 3 &cpu4_intc 7 >; reg = <0xff 0xdc000000 0x0 0x04000000>; - clint,has-no-64bit-mmio; }; intc: interrupt-controller at ffd8000000 {lib/utils/ipi/fdt_ipi_mswi.c +1
-0@@ -54,6 +54,7 @@ static int ipi_mswi_cold_init(void *fdt, int nodeoff,static const unsigned long clint_offset =CLINT_MSWI_OFFSET ;static const struct fdt_match ipi_mswi_match[] = { + { .compatible ="allwinner,sun20i-d1-clint" , .data = &clint_offset }, { .compatible ="riscv,clint0" , .data = &clint_offset }, { .compatible ="sifive,clint0" , .data = &clint_offset }, { .compatible ="riscv,aclint-mswi" },lib/utils/timer/fdt_timer_mtimer.c +6
-1@@ -15,6 +15,11 @@#define MTIMER_MAX_NR 16 +struct timer_mtimer_quirks { +unsigned int mtime_offset; +bool has_64bit_mmio; +}; +static unsigned long mtimer_count =0 ;static struct aclint_mtimer_data mtimer[MTIMER_MAX_NR ];static struct aclint_mtimer_data *mt_reference =NULL ;@@ -23,7 +28,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, const struct fdt_match *match) {int i, rc; -unsigned long offset, addr[2 ], size[2 ]; +unsigned long addr[2 ], size[2 ];struct aclint_mtimer_data *mt;if (MTIMER_MAX_NR <= mtimer_count)
lib/utils/timer/fdt_timer_mtimer.c static int timer_mtimer_cold_init(void *fdt, int nodeoff, · line 50
Quoted 3 lines
lib/utils/timer/fdt_timer_mtimer.c +0
-0@@ -43,28 +48,25 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,return rc;if (match->data) {/* SiFive CLINT */
Comment is stale.
Quoted 33 lines
lib/utils/timer/fdt_timer_mtimer.c +7
-10+const struct timer_mtimer_quirks *quirks = match->data; +/* Set CLINT addresses */ mt->mtimecmp_addr = addr[0 ] +ACLINT_DEFAULT_MTIMECMP_OFFSET ; mt->mtimecmp_size =ACLINT_DEFAULT_MTIMECMP_SIZE ; mt->mtime_addr = addr[0 ] +ACLINT_DEFAULT_MTIME_OFFSET ; mt->mtime_size = size[0 ] - mt->mtimecmp_size;/* Adjust MTIMER address and size for CLINT device */ - offset = *((unsigned long *)match->data); - mt->mtime_addr += offset; - mt->mtimecmp_addr += offset; - mt->mtime_size -= offset; -/* Parse additional CLINT properties */ -if (fdt_getprop (fdt, nodeoff,"clint,has-no-64bit-mmio" , &rc)) - mt->has_64bit_mmio = false; + mt->mtime_addr += quirks->mtime_offset; + mt->mtimecmp_addr += quirks->mtime_offset; + mt->mtime_size -= quirks->mtime_offset; +/* Apply additional CLINT quirks */ + mt->has_64bit_mmio = quirks->has_64bit_mmio; }else {/* RISC-V ACLINT MTIMER */ /* Set ACLINT MTIMER addresses */ mt->mtime_addr = addr[0 ]; mt->mtime_size = size[0 ]; mt->mtimecmp_addr = addr[1 ]; mt->mtimecmp_size = size[1 ]; -/* Parse additional ACLINT MTIMER properties */ -if (fdt_getprop (fdt, nodeoff,"mtimer,no-64bit-mmio" , &rc)) - mt->has_64bit_mmio = false; }/* Check if MTIMER device has shared MTIME address */
lib/utils/timer/fdt_timer_mtimer.c static int timer_mtimer_cold_init(void *fdt, int nodeoff, · line 113
Quoted 6 lines
lib/utils/timer/fdt_timer_mtimer.c +2
-1@@ -107,11 +109,20 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,return 0 ; } -static unsigned long clint_offset =CLINT_MTIMER_OFFSET ; +static const struct timer_mtimer_quirks d1_clint_quirks = { + .mtime_offset =CLINT_MTIMER_OFFSET ,
Having a generic global define mirrored into fields is weird.
lib/utils/timer/fdt_timer_mtimer.c static int timer_mtimer_cold_init(void *fdt, int nodeoff, · line 120
Quoted 7 lines
lib/utils/timer/fdt_timer_mtimer.c +7
-0+ .has_64bit_mmio = false, +}; + +static const struct timer_mtimer_quirks sifive_clint_quirks = { + .mtime_offset =CLINT_MTIMER_OFFSET , + .has_64bit_mmio = true, +};
The only quirk is that the D1 has no 64-bit MMIO. Everything else is just normal information about a conforming implementation, not quirks.
Jess
Anup Patel
AppliedRFC PATCH 2/2 lib: utils/timer: Add a separate compatible for the D1 CLINT
In reply to Samuel HollandQuoted 9 lines · Samuel Holland
The CLINT in the Allwinner D1 SoC apparently does not support 64-bit MMIO access. A property was added to support this quirk (and that property was copied to the ACLINT MTIMER code). However, since this difference in behavior makes the D1 CLINT incompatible with the SiFive CLINT's programming interface, a better solution is to use a separate compatible string.
Signed-off-by Samuel Holland <[email protected]>
Due to some unknown reason, this patch slipped through cracks and was never applied.
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
Quoted 137 lines
--- docs/platform/thead-c9xx.md | 4 +-- lib/utils/ipi/fdt_ipi_mswi.c | 1 + lib/utils/timer/fdt_timer_mtimer.c | 39 +++++++++++++++++++----------- 3 files changed, 27 insertions(+), 17 deletions(-)docs/platform/thead-c9xx.md +1
-3@@ -52,12 +52,11 @@ DTS Example1: (Single core, eg: Allwinner D1 - c906) ranges; clint0: clint at 14000000 { - compatible = "riscv,clint0"; + compatible = "allwinner,sun20i-d1-clint"; interrupts-extended = < &cpu0_intc 3 &cpu0_intc 7 >; reg = <0x0 0x14000000 0x0 0x04000000>; - clint,has-no-64bit-mmio; }; intc: interrupt-controller at 10000000 {@@ -163,7 +162,6 @@ DTS Example2: (Multi cores with soc reset-regs) &cpu4_intc 3 &cpu4_intc 7 >; reg = <0xff 0xdc000000 0x0 0x04000000>; - clint,has-no-64bit-mmio; }; intc: interrupt-controller at ffd8000000 {lib/utils/ipi/fdt_ipi_mswi.c +1
-0@@ -54,6 +54,7 @@ static int ipi_mswi_cold_init(void *fdt, int nodeoff,static const unsigned long clint_offset =CLINT_MSWI_OFFSET ;static const struct fdt_match ipi_mswi_match[] = { + { .compatible ="allwinner,sun20i-d1-clint" , .data = &clint_offset }, { .compatible ="riscv,clint0" , .data = &clint_offset }, { .compatible ="sifive,clint0" , .data = &clint_offset }, { .compatible ="riscv,aclint-mswi" },lib/utils/timer/fdt_timer_mtimer.c +25
-15@@ -15,6 +15,11 @@#define MTIMER_MAX_NR 16 +struct timer_mtimer_quirks { +unsigned int mtime_offset; +bool has_64bit_mmio; +}; +static unsigned long mtimer_count =0 ;static struct aclint_mtimer_data mtimer[MTIMER_MAX_NR ];static struct aclint_mtimer_data *mt_reference =NULL ;@@ -23,7 +28,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, const struct fdt_match *match) {int i, rc; -unsigned long offset, addr[2 ], size[2 ]; +unsigned long addr[2 ], size[2 ];struct aclint_mtimer_data *mt;if (MTIMER_MAX_NR <= mtimer_count)@@ -43,28 +48,25 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,return rc;if (match->data) {/* SiFive CLINT */ +const struct timer_mtimer_quirks *quirks = match->data; +/* Set CLINT addresses */ mt->mtimecmp_addr = addr[0 ] +ACLINT_DEFAULT_MTIMECMP_OFFSET ; mt->mtimecmp_size =ACLINT_DEFAULT_MTIMECMP_SIZE ; mt->mtime_addr = addr[0 ] +ACLINT_DEFAULT_MTIME_OFFSET ; mt->mtime_size = size[0 ] - mt->mtimecmp_size;/* Adjust MTIMER address and size for CLINT device */ - offset = *((unsigned long *)match->data); - mt->mtime_addr += offset; - mt->mtimecmp_addr += offset; - mt->mtime_size -= offset; -/* Parse additional CLINT properties */ -if (fdt_getprop (fdt, nodeoff,"clint,has-no-64bit-mmio" , &rc)) - mt->has_64bit_mmio = false; + mt->mtime_addr += quirks->mtime_offset; + mt->mtimecmp_addr += quirks->mtime_offset; + mt->mtime_size -= quirks->mtime_offset; +/* Apply additional CLINT quirks */ + mt->has_64bit_mmio = quirks->has_64bit_mmio; }else {/* RISC-V ACLINT MTIMER */ /* Set ACLINT MTIMER addresses */ mt->mtime_addr = addr[0 ]; mt->mtime_size = size[0 ]; mt->mtimecmp_addr = addr[1 ]; mt->mtimecmp_size = size[1 ]; -/* Parse additional ACLINT MTIMER properties */ -if (fdt_getprop (fdt, nodeoff,"mtimer,no-64bit-mmio" , &rc)) - mt->has_64bit_mmio = false; }/* Check if MTIMER device has shared MTIME address */ @@ -107,11 +109,20 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,return 0 ; } -static unsigned long clint_offset =CLINT_MTIMER_OFFSET ; +static const struct timer_mtimer_quirks d1_clint_quirks = { + .mtime_offset =CLINT_MTIMER_OFFSET , + .has_64bit_mmio = false, +}; + +static const struct timer_mtimer_quirks sifive_clint_quirks = { + .mtime_offset =CLINT_MTIMER_OFFSET , + .has_64bit_mmio = true, +};static const struct fdt_match timer_mtimer_match[] = { - { .compatible ="riscv,clint0" , .data = &clint_offset }, - { .compatible ="sifive,clint0" , .data = &clint_offset }, + { .compatible ="allwinner,sun20i-d1-clint" , .data = &d1_clint_quirks }, + { .compatible ="riscv,clint0" , .data = &sifive_clint_quirks }, + { .compatible ="sifive,clint0" , .data = &sifive_clint_quirks }, { .compatible ="riscv,aclint-mtimer" }, { }, }; --2.32.0
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
RFC PATCH 2/2 lib: utils/timer: Add a separate compatible for the D1 CLINT
Quoted 9 lines · Anup Patel
Quoted 8 lines · Samuel Holland
The CLINT in the Allwinner D1 SoC apparently does not support 64-bit MMIO access. A property was added to support this quirk (and that property was copied to the ACLINT MTIMER code). However, since this difference in behavior makes the D1 CLINT incompatible with the SiFive CLINT's programming interface, a better solution is to use a separate compatible string.
Quoted 4 lines
Quoted 1 line
Signed-off-by Samuel Holland <[email protected]>Due to some unknown reason, this patch slipped through cracks and was never applied.
Oh, I intentionally did not send a new version of the series because I later found out that C9xx CLINT has no mtime register at all[1][2]. The issue has nothing to do with 64-bit vs 32-bit access. So this change is wrong; I will need to send a follow-up removing the allwinner,sun20i-d1-clint compatibles.
Regards,
Samuel
[1]:
https://github.com/T-head-Semi/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/clint/rtl/clint_func.v#L217
[2]:
https://github.com/T-head-Semi/openc910/blob/main/C910_RTL_FACTORY/gen_rtl/clint/rtl/ct_clint_func.v#L247
Quoted 144 lines
Reviewed-by Anup Patel <[email protected]>Applied this patch to the riscv/opensbi repo.
Thanks,
AnupQuoted 137 lines
--- docs/platform/thead-c9xx.md | 4 +-- lib/utils/ipi/fdt_ipi_mswi.c | 1 + lib/utils/timer/fdt_timer_mtimer.c | 39 +++++++++++++++++++----------- 3 files changed, 27 insertions(+), 17 deletions(-)docs/platform/thead-c9xx.md +1
-3@@ -52,12 +52,11 @@ DTS Example1: (Single core, eg: Allwinner D1 - c906) ranges; clint0: clint at 14000000 { - compatible = "riscv,clint0"; + compatible = "allwinner,sun20i-d1-clint"; interrupts-extended = < &cpu0_intc 3 &cpu0_intc 7 >; reg = <0x0 0x14000000 0x0 0x04000000>; - clint,has-no-64bit-mmio; }; intc: interrupt-controller at 10000000 {@@ -163,7 +162,6 @@ DTS Example2: (Multi cores with soc reset-regs) &cpu4_intc 3 &cpu4_intc 7 >; reg = <0xff 0xdc000000 0x0 0x04000000>; - clint,has-no-64bit-mmio; }; intc: interrupt-controller at ffd8000000 {lib/utils/ipi/fdt_ipi_mswi.c +1
-0@@ -54,6 +54,7 @@ static int ipi_mswi_cold_init(void *fdt, int nodeoff,static const unsigned long clint_offset =CLINT_MSWI_OFFSET ;static const struct fdt_match ipi_mswi_match[] = { + { .compatible ="allwinner,sun20i-d1-clint" , .data = &clint_offset }, { .compatible ="riscv,clint0" , .data = &clint_offset }, { .compatible ="sifive,clint0" , .data = &clint_offset }, { .compatible ="riscv,aclint-mswi" },lib/utils/timer/fdt_timer_mtimer.c +25
-15@@ -15,6 +15,11 @@#define MTIMER_MAX_NR 16 +struct timer_mtimer_quirks { +unsigned int mtime_offset; +bool has_64bit_mmio; +}; +static unsigned long mtimer_count =0 ;static struct aclint_mtimer_data mtimer[MTIMER_MAX_NR ];static struct aclint_mtimer_data *mt_reference =NULL ;@@ -23,7 +28,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, const struct fdt_match *match) {int i, rc; -unsigned long offset, addr[2 ], size[2 ]; +unsigned long addr[2 ], size[2 ];struct aclint_mtimer_data *mt;if (MTIMER_MAX_NR <= mtimer_count)@@ -43,28 +48,25 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,return rc;if (match->data) {/* SiFive CLINT */ +const struct timer_mtimer_quirks *quirks = match->data; +/* Set CLINT addresses */ mt->mtimecmp_addr = addr[0 ] +ACLINT_DEFAULT_MTIMECMP_OFFSET ; mt->mtimecmp_size =ACLINT_DEFAULT_MTIMECMP_SIZE ; mt->mtime_addr = addr[0 ] +ACLINT_DEFAULT_MTIME_OFFSET ; mt->mtime_size = size[0 ] - mt->mtimecmp_size;/* Adjust MTIMER address and size for CLINT device */ - offset = *((unsigned long *)match->data); - mt->mtime_addr += offset; - mt->mtimecmp_addr += offset; - mt->mtime_size -= offset; -/* Parse additional CLINT properties */ -if (fdt_getprop (fdt, nodeoff,"clint,has-no-64bit-mmio" , &rc)) - mt->has_64bit_mmio = false; + mt->mtime_addr += quirks->mtime_offset; + mt->mtimecmp_addr += quirks->mtime_offset; + mt->mtime_size -= quirks->mtime_offset; +/* Apply additional CLINT quirks */ + mt->has_64bit_mmio = quirks->has_64bit_mmio; }else {/* RISC-V ACLINT MTIMER */ /* Set ACLINT MTIMER addresses */ mt->mtime_addr = addr[0 ]; mt->mtime_size = size[0 ]; mt->mtimecmp_addr = addr[1 ]; mt->mtimecmp_size = size[1 ]; -/* Parse additional ACLINT MTIMER properties */ -if (fdt_getprop (fdt, nodeoff,"mtimer,no-64bit-mmio" , &rc)) - mt->has_64bit_mmio = false; }/* Check if MTIMER device has shared MTIME address */ @@ -107,11 +109,20 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,return 0 ; } -static unsigned long clint_offset =CLINT_MTIMER_OFFSET ; +static const struct timer_mtimer_quirks d1_clint_quirks = { + .mtime_offset =CLINT_MTIMER_OFFSET , + .has_64bit_mmio = false, +}; + +static const struct timer_mtimer_quirks sifive_clint_quirks = { + .mtime_offset =CLINT_MTIMER_OFFSET , + .has_64bit_mmio = true, +};static const struct fdt_match timer_mtimer_match[] = { - { .compatible ="riscv,clint0" , .data = &clint_offset }, - { .compatible ="sifive,clint0" , .data = &clint_offset }, + { .compatible ="allwinner,sun20i-d1-clint" , .data = &d1_clint_quirks }, + { .compatible ="riscv,clint0" , .data = &sifive_clint_quirks }, + { .compatible ="sifive,clint0" , .data = &sifive_clint_quirks }, { .compatible ="riscv,aclint-mtimer" }, { }, }; --2.32.0
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
RFC PATCH 2/2 lib: utils/timer: Add a separate compatible for the D1 CLINT
Quoted 13 lines · Samuel Holland
Quoted 11 lines · Anup Patel
Quoted 9 lines · Samuel Holland
The CLINT in the Allwinner D1 SoC apparently does not support 64-bit MMIO access. A property was added to support this quirk (and that property was copied to the ACLINT MTIMER code). However, since this difference in behavior makes the D1 CLINT incompatible with the SiFive CLINT's programming interface, a better solution is to use a separate compatible string.
Signed-off-by Samuel Holland <[email protected]>
Quoted 7 lines
Quoted 2 lines
Due to some unknown reason, this patch slipped through cracks and was never applied.
Oh, I intentionally did not send a new version of the series because I later found out that C9xx CLINT has no mtime register at all[1][2]. The issue has nothing to do with 64-bit vs 32-bit access. So this change is wrong; I will need to send a follow-up removing the allwinner,sun20i-d1-clint compatibles.
I had tested on QEMU virt and sifive_u machine so at least this does not break anything on QEMU and SiFive boards.
Just a heads-up, we are planning to do OpenSBI v1.1 release sometime this week.
Do you have a list of things that are still missing to support upstream OpenSBI on D1 board ?
Regards,
Anup
Quoted 154 lines
Regards,
Samuel[1]:
https://github.com/T-head-Semi/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/clint/rtl/clint_func.v#L217
[2]:
https://github.com/T-head-Semi/openc910/blob/main/C910_RTL_FACTORY/gen_rtl/clint/rtl/ct_clint_func.v#L247Quoted 144 lines
Reviewed-by Anup Patel <[email protected]>Applied this patch to the riscv/opensbi repo.
Thanks,
AnupQuoted 137 lines
--- docs/platform/thead-c9xx.md | 4 +-- lib/utils/ipi/fdt_ipi_mswi.c | 1 + lib/utils/timer/fdt_timer_mtimer.c | 39 +++++++++++++++++++----------- 3 files changed, 27 insertions(+), 17 deletions(-)docs/platform/thead-c9xx.md +1
-3@@ -52,12 +52,11 @@ DTS Example1: (Single core, eg: Allwinner D1 - c906) ranges; clint0: clint at 14000000 { - compatible = "riscv,clint0"; + compatible = "allwinner,sun20i-d1-clint"; interrupts-extended = < &cpu0_intc 3 &cpu0_intc 7 >; reg = <0x0 0x14000000 0x0 0x04000000>; - clint,has-no-64bit-mmio; }; intc: interrupt-controller at 10000000 {@@ -163,7 +162,6 @@ DTS Example2: (Multi cores with soc reset-regs) &cpu4_intc 3 &cpu4_intc 7 >; reg = <0xff 0xdc000000 0x0 0x04000000>; - clint,has-no-64bit-mmio; }; intc: interrupt-controller at ffd8000000 {lib/utils/ipi/fdt_ipi_mswi.c +1
-0@@ -54,6 +54,7 @@ static int ipi_mswi_cold_init(void *fdt, int nodeoff,static const unsigned long clint_offset =CLINT_MSWI_OFFSET ;static const struct fdt_match ipi_mswi_match[] = { + { .compatible ="allwinner,sun20i-d1-clint" , .data = &clint_offset }, { .compatible ="riscv,clint0" , .data = &clint_offset }, { .compatible ="sifive,clint0" , .data = &clint_offset }, { .compatible ="riscv,aclint-mswi" },lib/utils/timer/fdt_timer_mtimer.c +25
-15@@ -15,6 +15,11 @@#define MTIMER_MAX_NR 16 +struct timer_mtimer_quirks { +unsigned int mtime_offset; +bool has_64bit_mmio; +}; +static unsigned long mtimer_count =0 ;static struct aclint_mtimer_data mtimer[MTIMER_MAX_NR ];static struct aclint_mtimer_data *mt_reference =NULL ;@@ -23,7 +28,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff, const struct fdt_match *match) {int i, rc; -unsigned long offset, addr[2 ], size[2 ]; +unsigned long addr[2 ], size[2 ];struct aclint_mtimer_data *mt;if (MTIMER_MAX_NR <= mtimer_count)@@ -43,28 +48,25 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,return rc;if (match->data) {/* SiFive CLINT */ +const struct timer_mtimer_quirks *quirks = match->data; +/* Set CLINT addresses */ mt->mtimecmp_addr = addr[0 ] +ACLINT_DEFAULT_MTIMECMP_OFFSET ; mt->mtimecmp_size =ACLINT_DEFAULT_MTIMECMP_SIZE ; mt->mtime_addr = addr[0 ] +ACLINT_DEFAULT_MTIME_OFFSET ; mt->mtime_size = size[0 ] - mt->mtimecmp_size;/* Adjust MTIMER address and size for CLINT device */ - offset = *((unsigned long *)match->data); - mt->mtime_addr += offset; - mt->mtimecmp_addr += offset; - mt->mtime_size -= offset; -/* Parse additional CLINT properties */ -if (fdt_getprop (fdt, nodeoff,"clint,has-no-64bit-mmio" , &rc)) - mt->has_64bit_mmio = false; + mt->mtime_addr += quirks->mtime_offset; + mt->mtimecmp_addr += quirks->mtime_offset; + mt->mtime_size -= quirks->mtime_offset; +/* Apply additional CLINT quirks */ + mt->has_64bit_mmio = quirks->has_64bit_mmio; }else {/* RISC-V ACLINT MTIMER */ /* Set ACLINT MTIMER addresses */ mt->mtime_addr = addr[0 ]; mt->mtime_size = size[0 ]; mt->mtimecmp_addr = addr[1 ]; mt->mtimecmp_size = size[1 ]; -/* Parse additional ACLINT MTIMER properties */ -if (fdt_getprop (fdt, nodeoff,"mtimer,no-64bit-mmio" , &rc)) - mt->has_64bit_mmio = false; }/* Check if MTIMER device has shared MTIME address */ @@ -107,11 +109,20 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,return 0 ; } -static unsigned long clint_offset =CLINT_MTIMER_OFFSET ; +static const struct timer_mtimer_quirks d1_clint_quirks = { + .mtime_offset =CLINT_MTIMER_OFFSET , + .has_64bit_mmio = false, +}; + +static const struct timer_mtimer_quirks sifive_clint_quirks = { + .mtime_offset =CLINT_MTIMER_OFFSET , + .has_64bit_mmio = true, +};static const struct fdt_match timer_mtimer_match[] = { - { .compatible ="riscv,clint0" , .data = &clint_offset }, - { .compatible ="sifive,clint0" , .data = &clint_offset }, + { .compatible ="allwinner,sun20i-d1-clint" , .data = &d1_clint_quirks }, + { .compatible ="riscv,clint0" , .data = &sifive_clint_quirks }, + { .compatible ="sifive,clint0" , .data = &sifive_clint_quirks }, { .compatible ="riscv,aclint-mtimer" }, { }, }; --2.32.0
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
RFC PATCH 2/2 lib: utils/timer: Add a separate compatible for the D1 CLINT
Quoted 17 lines · Anup Patel
Quoted 16 lines · Samuel Holland
Quoted 13 lines · Anup Patel
Quoted 9 lines · Samuel Holland
The CLINT in the Allwinner D1 SoC apparently does not support 64-bit MMIO access. A property was added to support this quirk (and that property was copied to the ACLINT MTIMER code). However, since this difference in behavior makes the D1 CLINT incompatible with the SiFive CLINT's programming interface, a better solution is to use a separate compatible string.
Signed-off-by Samuel Holland <[email protected]>Due to some unknown reason, this patch slipped through cracks and was never applied.
Quoted 7 lines
Quoted 4 lines
Oh, I intentionally did not send a new version of the series because I later found out that C9xx CLINT has no mtime register at all[1][2]. The issue has nothing to do with 64-bit vs 32-bit access. So this change is wrong; I will need to send a follow-up removing the allwinner,sun20i-d1-clint compatibles.
I had tested on QEMU virt and
sifive_umachine so at least this does not break anything on QEMU and SiFive boards.
OK, I will send a follow-up patch tomorrow.
Quoted 5 lines
Just a heads-up, we are planning to do OpenSBI v1.1 release sometime this week.
Do you have a list of things that are still missing to support upstream OpenSBI on D1 board ?
D1 already has enough support to boot/run with v1.0.
The only remaining functionality I know of is:
- CLINT, which needs a DT binding plus further driver changes, and
- PMU, which will be nontrivial to implement.
Lack of CLINT driver is no real problem, because D1 has several other MMIO timers available, so the SBI timer extension is not even used right now.
And the generic PMU code gracefully handles the lack of overflow interrupt support, so that can also be added later.
Regards,
Samuel
RFC PATCH 2/2 lib: utils/timer: Add a separate compatible for the D1 CLINT
Quoted 35 lines · Samuel Holland
Quoted 17 lines · Anup Patel
Quoted 16 lines · Samuel Holland
Quoted 13 lines · Anup Patel
Quoted 9 lines · Samuel Holland
The CLINT in the Allwinner D1 SoC apparently does not support 64-bit MMIO access. A property was added to support this quirk (and that property was copied to the ACLINT MTIMER code). However, since this difference in behavior makes the D1 CLINT incompatible with the SiFive CLINT's programming interface, a better solution is to use a separate compatible string.
Signed-off-by Samuel Holland <[email protected]>Due to some unknown reason, this patch slipped through cracks and was never applied.
Quoted 7 lines
Quoted 4 lines
Oh, I intentionally did not send a new version of the series because I later found out that C9xx CLINT has no mtime register at all[1][2]. The issue has nothing to do with 64-bit vs 32-bit access. So this change is wrong; I will need to send a follow-up removing the allwinner,sun20i-d1-clint compatibles.
I had tested on QEMU virt and
sifive_umachine so at least this does not break anything on QEMU and SiFive boards.OK, I will send a follow-up patch tomorrow.
Quoted 5 lines
Just a heads-up, we are planning to do OpenSBI v1.1 release sometime this week.
Do you have a list of things that are still missing to support upstream OpenSBI on D1 board ?
Quoted 8 lines
D1 already has enough support to boot/run with v1.0.
The only remaining functionality I know of is:
- CLINT, which needs a DT binding plus further driver changes, and
- PMU, which will be nontrivial to implement.Lack of CLINT driver is no real problem, because D1 has several other MMIO timers available, so the SBI timer extension is not even used right now.
Another solution is modifying [1]. Using get_cycles64() in clint_get_cycles64.
C906 has s-mode time cmp register:
parameter STIMECMP0 = 16'hD000;
parameter STIMECMPH0 = 16'hD004;
Quoted 6 lines
And the generic PMU code gracefully handles the lack of overflow interrupt support, so that can also be added later.
Regards,
Samuel
Signature · 4 lines
Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/
RFC PATCH 2/2 lib: utils/timer: Add a separate compatible for the D1 CLINT
In reply to Samuel HollandQuoted 24 lines · Samuel Holland
Quoted 22 lines · Anup Patel
Quoted 20 lines · Samuel Holland
Quoted 9 lines · Anup Patel
Quoted 8 lines · Samuel Holland
The CLINT in the Allwinner D1 SoC apparently does not support 64-bit MMIO access. A property was added to support this quirk (and that property was copied to the ACLINT MTIMER code). However, since this difference in behavior makes the D1 CLINT incompatible with the SiFive CLINT's programming interface, a better solution is to use a separate compatible string.
Quoted 4 lines
Quoted 1 line
Signed-off-by Samuel Holland <[email protected]>Due to some unknown reason, this patch slipped through cracks and was never applied.
Oh, I intentionally did not send a new version of the series because I later found out that C9xx CLINT has no mtime register at all[1][2]. The issue has nothing to do with 64-bit vs 32-bit access. So this change is wrong; I will need to send a follow-up removing the allwinner,sun20i-d1-clint compatibles.
Quoted 4 lines
Quoted 2 lines
I had tested on QEMU virt and
sifive_umachine so at least this does not break anything on QEMU and SiFive boards.OK, I will send a follow-up patch tomorrow.
Thanks. I was thinking of having a quirk in the mtimer driver for the D1 clint situation. I sent a quirk patch but I have tested only on QEMU RV32 and RV64.
Quoted 13 lines
Quoted 6 lines
Just a heads-up, we are planning to do OpenSBI v1.1 release sometime this week.
Do you have a list of things that are still missing to support upstream OpenSBI on D1 board ?
D1 already has enough support to boot/run with v1.0.
The only remaining functionality I know of is:
- CLINT, which needs a DT binding plus further driver changes, and
- PMU, which will be nontrivial to implement.
Quoted 8 lines
Lack of CLINT driver is no real problem, because D1 has several other MMIO timers available, so the SBI timer extension is not even used right now.
And the generic PMU code gracefully handles the lack of overflow interrupt support, so that can also be added later.
Regards,
Samuel
Regards,
Anup
RFC PATCH 2/2 lib: utils/timer: Add a separate compatible for the D1 CLINT
Quoted 25 lines · Anup Patel
Quoted 24 lines · Samuel Holland
Quoted 22 lines · Anup Patel
Quoted 20 lines · Samuel Holland
Quoted 9 lines · Anup Patel
Quoted 8 lines · Samuel Holland
The CLINT in the Allwinner D1 SoC apparently does not support 64-bit MMIO access. A property was added to support this quirk (and that property was copied to the ACLINT MTIMER code). However, since this difference in behavior makes the D1 CLINT incompatible with the SiFive CLINT's programming interface, a better solution is to use a separate compatible string.
Quoted 4 lines
Quoted 1 line
Signed-off-by Samuel Holland <[email protected]>Due to some unknown reason, this patch slipped through cracks and was never applied.
Oh, I intentionally did not send a new version of the series because I later found out that C9xx CLINT has no mtime register at all[1][2]. The issue has nothing to do with 64-bit vs 32-bit access. So this change is wrong; I will need to send a follow-up removing the allwinner,sun20i-d1-clint compatibles.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
I had tested on QEMU virt and
sifive_umachine so at least this does not break anything on QEMU and SiFive boards.OK, I will send a follow-up patch tomorrow.
Thanks. I was thinking of having a quirk in the mtimer driver for the D1 clint situation. I sent a quirk patch but I have tested only on QEMU RV32 and RV64.
I think your patch is what we want to do eventually, but I want to get the binding settled first.
Regards,
Samuel
cover Add support for Allwinner D1 CLINT
In reply to Samuel HollandQuoted 4 lines · Samuel Holland
This series removes the clint,has-no-64bit-mmio property from the MTIMER driver, and instead uses the compatible string to determine if 64-bit MMIO is functional, as suggested on the list[1][2].
Thanks for doing this change. I was also thinking of removing this DT property in favor of implementation specific compatible strings.
Quoted 9 lines
According to Guo Ren[3], this quirk only applies to the D1, not to the C9xx processors more generally, so I am using the SoC compatible without a fallback compatible for the CPU implementation.
One question I have: Now that the ACLINT specification is available, and since it is backward compatible, should we describe this hardware as a standard ACLINT MSWI plus a custom ACLINT MTIMER instead of as a custom CLINT? This would minimize the scope of the changes.
Yes, for newer platforms (such as Allwiner D1) we should insist everyone to move away from SiFive CLINT DT bindings and instead use ACLINT DT bindings (this applies for all three ACLINT devices).
Although, I am not sure if we should update existing DTS files in the upstream kernel.
Regards,
Anup
Quoted 20 lines
[1]: http://lists.infradead.org/pipermail/opensbi/2021-October/001815.html
[2]: http://lists.infradead.org/pipermail/opensbi/2021-October/001841.html
[3]: http://lists.infradead.org/pipermail/opensbi/2021-October/001863.htmldocs/platform/thead-c9xx.md | 4 +-- include/sbi_utils/fdt/fdt_helper.h | 2 +- lib/utils/ipi/fdt_ipi_mswi.c | 3 ++- lib/utils/reset/fdt_reset_gpio.c | 4 +-- lib/utils/timer/fdt_timer_mtimer.c | 39 +++++++++++++++++++----------- 5 files changed, 31 insertions(+), 21 deletions(-)--
2.32.0--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi