hw: aspeed: Init all UART's with serial devices
v2 cover hw: aspeed: Init all UART's with serial devices
v2:
- Rebased on Cedric's irq proposal. [1]
- Added "Introduce common UART init function" patch
- Added "Add uarts_num SoC attribute" patch
- Rewrote last commit's message for clarity
I tried testing this by running acceptance tests, particularly the boot_linux_console.py file, but I had to disable the raspi2_initrd case. It's not related to my changes (A/B tested and it fails on upstream/master too), but thought I would mention that.
I also manually tested several machines:
AST2400: https://github.com/facebook/openbmc/releases/download/v2021.49.0/wedge100.mtd
AST2500: https://github.com/facebook/openbmc/releases/download/v2021.49.0/fby3.mtd
AST2600: https://github.com/facebook/openbmc/releases/download/v2021.49.0/fuji.mtd
AST1030: https://github.com/peterdelevoryas/OpenBIC/releases/download/oby35-cl-2022.13.01/Y35BCL.elf
[1] https://lore.kernel.org/qemu-devel/[email protected]/
Peter Delevoryas (5):
hw: aspeed: Add missing UART's
hw: aspeed: Add uarts_num SoC attribute
hw: aspeed: Ensure AST1030 respects uart-default
hw: aspeed: Introduce common UART init function
hw: aspeed: Init all UART's with serial devices
hw/arm/aspeed_ast10x0.c | 32 +++++++++++++++++++++++++++----- hw/arm/aspeed_ast2600.c | 27 ++++++++++++++++++++++----- hw/arm/aspeed_soc.c | 33 +++++++++++++++++++++++++++++---- include/hw/arm/aspeed_soc.h | 10 ++++++++++ 4 files changed, 88 insertions(+), 14 deletions(-)
Signature · 1 line
2.30.2
PATCH v2 1/5 hw: aspeed: Add missing UART's
This adds the missing UART memory and IRQ mappings for the AST2400, AST2500, AST2600, and AST1030.
This also includes the new UART interfaces added in the AST2600 and AST1030 from UART6 to UART13. The addresses and interrupt numbers for these two later chips are identical.
--- hw/arm/aspeed_ast10x0.c | 24 ++++++++++++++++++++++++ hw/arm/aspeed_ast2600.c | 19 +++++++++++++++++++ hw/arm/aspeed_soc.c | 6 ++++++ include/hw/arm/aspeed_soc.h | 8 ++++++++ 4 files changed, 57 insertions(+)
hw/arm/aspeed_ast10x0.c +24 -0
@@ -33,14 +33,38 @@ static const hwaddr aspeed_soc_ast1030_memmap[] = { [ASPEED_DEV_SBC] = 0x7E6F2000, [ASPEED_DEV_GPIO] = 0x7E780000, [ASPEED_DEV_TIMER1] = 0x7E782000, + [ASPEED_DEV_UART1] = 0x7E783000, + [ASPEED_DEV_UART2] = 0x7E78D000, + [ASPEED_DEV_UART3] = 0x7E78E000, + [ASPEED_DEV_UART4] = 0x7E78F000, [ASPEED_DEV_UART5] = 0x7E784000, + [ASPEED_DEV_UART6] = 0x7E790000, + [ASPEED_DEV_UART7] = 0x7E790100, + [ASPEED_DEV_UART8] = 0x7E790200, + [ASPEED_DEV_UART9] = 0x7E790300, + [ASPEED_DEV_UART10] = 0x7E790400, + [ASPEED_DEV_UART11] = 0x7E790500, + [ASPEED_DEV_UART12] = 0x7E790600, + [ASPEED_DEV_UART13] = 0x7E790700, [ASPEED_DEV_WDT] = 0x7E785000, [ASPEED_DEV_LPC] = 0x7E789000, [ASPEED_DEV_I2C] = 0x7E7B0000, };static const int aspeed_soc_ast1030_irqmap[] = { + [ASPEED_DEV_UART1 ] =47 , + [ASPEED_DEV_UART2 ] =48 , + [ASPEED_DEV_UART3 ] =49 , + [ASPEED_DEV_UART4 ] =50 , [ASPEED_DEV_UART5 ] =8 , + [ASPEED_DEV_UART6 ] =57 , + [ASPEED_DEV_UART7 ] =58 , + [ASPEED_DEV_UART8 ] =59 , + [ASPEED_DEV_UART9 ] =60 , + [ASPEED_DEV_UART10 ] =61 , + [ASPEED_DEV_UART11 ] =62 , + [ASPEED_DEV_UART12 ] =63 , + [ASPEED_DEV_UART13 ] =64 , [ASPEED_DEV_GPIO ] =11 , [ASPEED_DEV_TIMER1 ] =16 , [ASPEED_DEV_TIMER2 ] =17 ,
hw/arm/aspeed_ast2600.c +19 -0
@@ -61,7 +61,18 @@ static const hwaddr aspeed_soc_ast2600_memmap[] = { [ASPEED_DEV_IBT] = 0x1E789140, [ASPEED_DEV_I2C] = 0x1E78A000, [ASPEED_DEV_UART1] = 0x1E783000, + [ASPEED_DEV_UART2] = 0x1E78D000, + [ASPEED_DEV_UART3] = 0x1E78E000, + [ASPEED_DEV_UART4] = 0x1E78F000, [ASPEED_DEV_UART5] = 0x1E784000, + [ASPEED_DEV_UART6] = 0x1E790000, + [ASPEED_DEV_UART7] = 0x1E790100, + [ASPEED_DEV_UART8] = 0x1E790200, + [ASPEED_DEV_UART9] = 0x1E790300, + [ASPEED_DEV_UART10] = 0x1E790400, + [ASPEED_DEV_UART11] = 0x1E790500, + [ASPEED_DEV_UART12] = 0x1E790600, + [ASPEED_DEV_UART13] = 0x1E790700, [ASPEED_DEV_VUART] = 0x1E787000, [ASPEED_DEV_I3C] = 0x1E7A0000, [ASPEED_DEV_SDRAM] = 0x80000000,
@@ -78,6 +89,14 @@ static const int aspeed_soc_ast2600_irqmap[] = { [ASPEED_DEV_UART3] = 49, [ASPEED_DEV_UART4] = 50, [ASPEED_DEV_UART5] = 8, + [ASPEED_DEV_UART6] = 57, + [ASPEED_DEV_UART7] = 58, + [ASPEED_DEV_UART8] = 59, + [ASPEED_DEV_UART9] = 60, + [ASPEED_DEV_UART10] = 61, + [ASPEED_DEV_UART11] = 62, + [ASPEED_DEV_UART12] = 63, + [ASPEED_DEV_UART13] = 64, [ASPEED_DEV_VUART] = 8, [ASPEED_DEV_FMC] = 39, [ASPEED_DEV_SDMC] = 0,
hw/arm/aspeed_soc.c +6 -0
@@ -48,6 +48,9 @@ static const hwaddr aspeed_soc_ast2400_memmap[] = { [ASPEED_DEV_ETH1] = 0x1E660000, [ASPEED_DEV_ETH2] = 0x1E680000, [ASPEED_DEV_UART1] = 0x1E783000, + [ASPEED_DEV_UART2] = 0x1E78D000, + [ASPEED_DEV_UART3] = 0x1E78E000, + [ASPEED_DEV_UART4] = 0x1E78F000, [ASPEED_DEV_UART5] = 0x1E784000, [ASPEED_DEV_VUART] = 0x1E787000, [ASPEED_DEV_SDRAM] = 0x40000000,
@@ -80,6 +83,9 @@ static const hwaddr aspeed_soc_ast2500_memmap[] = { [ASPEED_DEV_ETH1] = 0x1E660000, [ASPEED_DEV_ETH2] = 0x1E680000, [ASPEED_DEV_UART1] = 0x1E783000, + [ASPEED_DEV_UART2] = 0x1E78D000, + [ASPEED_DEV_UART3] = 0x1E78E000, + [ASPEED_DEV_UART4] = 0x1E78F000, [ASPEED_DEV_UART5] = 0x1E784000, [ASPEED_DEV_VUART] = 0x1E787000, [ASPEED_DEV_SDRAM] = 0x80000000,
include/hw/arm/aspeed_soc.h +8 -0
@@ -105,6 +105,14 @@ enum {ASPEED_DEV_UART3 ,ASPEED_DEV_UART4 ,ASPEED_DEV_UART5 , +ASPEED_DEV_UART6 , +ASPEED_DEV_UART7 , +ASPEED_DEV_UART8 , +ASPEED_DEV_UART9 , +ASPEED_DEV_UART10 , +ASPEED_DEV_UART11 , +ASPEED_DEV_UART12 , +ASPEED_DEV_UART13 ,ASPEED_DEV_VUART ,ASPEED_DEV_FMC , ASPEED_DEV_SPI1,
Signature · 1 line
2.30.2
Re: [PATCH v2 1/5] hw: aspeed: Add missing UART's
Quoted 8 lines · Peter Delevoryas
This adds the missing UART memory and IRQ mappings for the AST2400, AST2500, AST2600, and AST1030.
This also includes the new UART interfaces added in the AST2600 and AST1030 from UART6 to UART13. The addresses and interrupt numbers for these two later chips are identical.
Signed-off-by Peter Delevoryas <[email protected]>
Thanks,
C.
Quoted 131 lines
--- hw/arm/aspeed_ast10x0.c | 24 ++++++++++++++++++++++++ hw/arm/aspeed_ast2600.c | 19 +++++++++++++++++++ hw/arm/aspeed_soc.c | 6 ++++++ include/hw/arm/aspeed_soc.h | 8 ++++++++ 4 files changed, 57 insertions(+)hw/arm/aspeed_ast10x0.c +24
-0@@ -33,14 +33,38 @@ static const hwaddr aspeed_soc_ast1030_memmap[] = { [ASPEED_DEV_SBC] = 0x7E6F2000, [ASPEED_DEV_GPIO] = 0x7E780000, [ASPEED_DEV_TIMER1] = 0x7E782000, + [ASPEED_DEV_UART1] = 0x7E783000, + [ASPEED_DEV_UART2] = 0x7E78D000, + [ASPEED_DEV_UART3] = 0x7E78E000, + [ASPEED_DEV_UART4] = 0x7E78F000, [ASPEED_DEV_UART5] = 0x7E784000, + [ASPEED_DEV_UART6] = 0x7E790000, + [ASPEED_DEV_UART7] = 0x7E790100, + [ASPEED_DEV_UART8] = 0x7E790200, + [ASPEED_DEV_UART9] = 0x7E790300, + [ASPEED_DEV_UART10] = 0x7E790400, + [ASPEED_DEV_UART11] = 0x7E790500, + [ASPEED_DEV_UART12] = 0x7E790600, + [ASPEED_DEV_UART13] = 0x7E790700, [ASPEED_DEV_WDT] = 0x7E785000, [ASPEED_DEV_LPC] = 0x7E789000, [ASPEED_DEV_I2C] = 0x7E7B0000, };static const int aspeed_soc_ast1030_irqmap[] = { + [ASPEED_DEV_UART1 ] =47 , + [ASPEED_DEV_UART2 ] =48 , + [ASPEED_DEV_UART3 ] =49 , + [ASPEED_DEV_UART4 ] =50 , [ASPEED_DEV_UART5 ] =8 , + [ASPEED_DEV_UART6 ] =57 , + [ASPEED_DEV_UART7 ] =58 , + [ASPEED_DEV_UART8 ] =59 , + [ASPEED_DEV_UART9 ] =60 , + [ASPEED_DEV_UART10 ] =61 , + [ASPEED_DEV_UART11 ] =62 , + [ASPEED_DEV_UART12 ] =63 , + [ASPEED_DEV_UART13 ] =64 , [ASPEED_DEV_GPIO ] =11 , [ASPEED_DEV_TIMER1 ] =16 , [ASPEED_DEV_TIMER2 ] =17 ,hw/arm/aspeed_ast2600.c +19
-0@@ -61,7 +61,18 @@ static const hwaddr aspeed_soc_ast2600_memmap[] = { [ASPEED_DEV_IBT] = 0x1E789140, [ASPEED_DEV_I2C] = 0x1E78A000, [ASPEED_DEV_UART1] = 0x1E783000, + [ASPEED_DEV_UART2] = 0x1E78D000, + [ASPEED_DEV_UART3] = 0x1E78E000, + [ASPEED_DEV_UART4] = 0x1E78F000, [ASPEED_DEV_UART5] = 0x1E784000, + [ASPEED_DEV_UART6] = 0x1E790000, + [ASPEED_DEV_UART7] = 0x1E790100, + [ASPEED_DEV_UART8] = 0x1E790200, + [ASPEED_DEV_UART9] = 0x1E790300, + [ASPEED_DEV_UART10] = 0x1E790400, + [ASPEED_DEV_UART11] = 0x1E790500, + [ASPEED_DEV_UART12] = 0x1E790600, + [ASPEED_DEV_UART13] = 0x1E790700, [ASPEED_DEV_VUART] = 0x1E787000, [ASPEED_DEV_I3C] = 0x1E7A0000, [ASPEED_DEV_SDRAM] = 0x80000000,@@ -78,6 +89,14 @@ static const int aspeed_soc_ast2600_irqmap[] = { [ASPEED_DEV_UART3] = 49, [ASPEED_DEV_UART4] = 50, [ASPEED_DEV_UART5] = 8, + [ASPEED_DEV_UART6] = 57, + [ASPEED_DEV_UART7] = 58, + [ASPEED_DEV_UART8] = 59, + [ASPEED_DEV_UART9] = 60, + [ASPEED_DEV_UART10] = 61, + [ASPEED_DEV_UART11] = 62, + [ASPEED_DEV_UART12] = 63, + [ASPEED_DEV_UART13] = 64, [ASPEED_DEV_VUART] = 8, [ASPEED_DEV_FMC] = 39, [ASPEED_DEV_SDMC] = 0,hw/arm/aspeed_soc.c +6
-0@@ -48,6 +48,9 @@ static const hwaddr aspeed_soc_ast2400_memmap[] = { [ASPEED_DEV_ETH1] = 0x1E660000, [ASPEED_DEV_ETH2] = 0x1E680000, [ASPEED_DEV_UART1] = 0x1E783000, + [ASPEED_DEV_UART2] = 0x1E78D000, + [ASPEED_DEV_UART3] = 0x1E78E000, + [ASPEED_DEV_UART4] = 0x1E78F000, [ASPEED_DEV_UART5] = 0x1E784000, [ASPEED_DEV_VUART] = 0x1E787000, [ASPEED_DEV_SDRAM] = 0x40000000,@@ -80,6 +83,9 @@ static const hwaddr aspeed_soc_ast2500_memmap[] = { [ASPEED_DEV_ETH1] = 0x1E660000, [ASPEED_DEV_ETH2] = 0x1E680000, [ASPEED_DEV_UART1] = 0x1E783000, + [ASPEED_DEV_UART2] = 0x1E78D000, + [ASPEED_DEV_UART3] = 0x1E78E000, + [ASPEED_DEV_UART4] = 0x1E78F000, [ASPEED_DEV_UART5] = 0x1E784000, [ASPEED_DEV_VUART] = 0x1E787000, [ASPEED_DEV_SDRAM] = 0x80000000,include/hw/arm/aspeed_soc.h +8
-0@@ -105,6 +105,14 @@ enum {ASPEED_DEV_UART3 ,ASPEED_DEV_UART4 ,ASPEED_DEV_UART5 , +ASPEED_DEV_UART6 , +ASPEED_DEV_UART7 , +ASPEED_DEV_UART8 , +ASPEED_DEV_UART9 , +ASPEED_DEV_UART10 , +ASPEED_DEV_UART11 , +ASPEED_DEV_UART12 , +ASPEED_DEV_UART13 ,ASPEED_DEV_VUART ,ASPEED_DEV_FMC , ASPEED_DEV_SPI1,
PATCH v2 2/5 hw: aspeed: Add uarts_num SoC attribute
In reply to Peter DelevoryasAST2400 and AST2500 have 5 UART's, while the AST2600 and AST1030 have 13.
--- hw/arm/aspeed_ast10x0.c | 1 + hw/arm/aspeed_ast2600.c | 1 + hw/arm/aspeed_soc.c | 2 ++ include/hw/arm/aspeed_soc.h | 1 + 4 files changed, 5 insertions(+)
hw/arm/aspeed_ast10x0.c +1 -0
@@ -301,6 +301,7 @@ static void aspeed_soc_ast1030_class_init(ObjectClass *klass, void *data) sc->ehcis_num =0 ; sc->wdts_num =4 ; sc->macs_num =1 ; + sc->uarts_num =13 ; sc->irqmap = aspeed_soc_ast1030_irqmap; sc->memmap = aspeed_soc_ast1030_memmap; sc->num_cpus =1 ;
hw/arm/aspeed_ast2600.c +1 -0
@@ -588,6 +588,7 @@ static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data) sc->ehcis_num =2 ; sc->wdts_num =4 ; sc->macs_num =4 ; + sc->uarts_num =13 ; sc->irqmap = aspeed_soc_ast2600_irqmap; sc->memmap = aspeed_soc_ast2600_memmap; sc->num_cpus =2 ;
hw/arm/aspeed_soc.c +2 -0
@@ -490,6 +490,7 @@ static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data) sc->ehcis_num =1 ; sc->wdts_num =2 ; sc->macs_num =2 ; + sc->uarts_num =5 ; sc->irqmap = aspeed_soc_ast2400_irqmap; sc->memmap = aspeed_soc_ast2400_memmap; sc->num_cpus =1 ;
@@ -516,6 +517,7 @@ static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data) sc->ehcis_num =2 ; sc->wdts_num =3 ; sc->macs_num =2 ; + sc->uarts_num =5 ; sc->irqmap = aspeed_soc_ast2500_irqmap; sc->memmap = aspeed_soc_ast2500_memmap; sc->num_cpus =1 ;
include/hw/arm/aspeed_soc.h +1 -0
@@ -91,6 +91,7 @@ struct AspeedSoCClass {int ehcis_num;int wdts_num;int macs_num; +int uarts_num;const int *irqmap;const hwaddr *memmap;uint32_t num_cpus;
Signature · 1 line
2.30.2
Re: [PATCH v2 2/5] hw: aspeed: Add uarts_num SoC attribute
Quoted 3 lines · Peter Delevoryas
AST2400 and AST2500 have 5 UART's, while the AST2600 and AST1030 have 13.
Signed-off-by Peter Delevoryas <[email protected]>
Thanks,
C.
Quoted 63 lines
--- hw/arm/aspeed_ast10x0.c | 1 + hw/arm/aspeed_ast2600.c | 1 + hw/arm/aspeed_soc.c | 2 ++ include/hw/arm/aspeed_soc.h | 1 + 4 files changed, 5 insertions(+)hw/arm/aspeed_ast10x0.c +1
-0@@ -301,6 +301,7 @@ static void aspeed_soc_ast1030_class_init(ObjectClass *klass, void *data) sc->ehcis_num =0 ; sc->wdts_num =4 ; sc->macs_num =1 ; + sc->uarts_num =13 ; sc->irqmap = aspeed_soc_ast1030_irqmap; sc->memmap = aspeed_soc_ast1030_memmap; sc->num_cpus =1 ;hw/arm/aspeed_ast2600.c +1
-0@@ -588,6 +588,7 @@ static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data) sc->ehcis_num =2 ; sc->wdts_num =4 ; sc->macs_num =4 ; + sc->uarts_num =13 ; sc->irqmap = aspeed_soc_ast2600_irqmap; sc->memmap = aspeed_soc_ast2600_memmap; sc->num_cpus =2 ;hw/arm/aspeed_soc.c +2
-0@@ -490,6 +490,7 @@ static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data) sc->ehcis_num =1 ; sc->wdts_num =2 ; sc->macs_num =2 ; + sc->uarts_num =5 ; sc->irqmap = aspeed_soc_ast2400_irqmap; sc->memmap = aspeed_soc_ast2400_memmap; sc->num_cpus =1 ;@@ -516,6 +517,7 @@ static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data) sc->ehcis_num =2 ; sc->wdts_num =3 ; sc->macs_num =2 ; + sc->uarts_num =5 ; sc->irqmap = aspeed_soc_ast2500_irqmap; sc->memmap = aspeed_soc_ast2500_memmap; sc->num_cpus =1 ;include/hw/arm/aspeed_soc.h +1
-0@@ -91,6 +91,7 @@ struct AspeedSoCClass {int ehcis_num;int wdts_num;int macs_num; +int uarts_num;const int *irqmap;const hwaddr *memmap;uint32_t num_cpus;
PATCH v2 3/5 hw: aspeed: Ensure AST1030 respects uart-default
In reply to Peter DelevoryasThe AST1030 machine initialization was not respecting the Aspeed SoC property "uart-default", which specifies which UART should be connected to the first serial device, it was just always connecting UART5. This doesn't change any behavior, because the default value for "uart-default" is UART5, but it makes it possible to override this in new machine definitions using the AST1030.
--- hw/arm/aspeed_ast10x0.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/arm/aspeed_ast10x0.c +3 -3
@@ -215,9 +215,9 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)qdev_get_gpio_in (DEVICE (&s->armv7m), sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_4)); -/* UART5 - attach an 8250 to the IO space as our UART */ -serial_mm_init (get_system_memory (), sc->memmap[ASPEED_DEV_UART5 ],2 , -aspeed_soc_get_irq (s,ASPEED_DEV_UART5 ), +/* UART - attach an 8250 to the IO space as our UART */ +serial_mm_init (get_system_memory (), sc->memmap[s->uart_default],2 , +aspeed_soc_get_irq (s, s->uart_default),38400 ,serial_hd (0 ),DEVICE_LITTLE_ENDIAN );/* Timer */
Signature · 1 line
2.30.2
Re: [PATCH v2 3/5] hw: aspeed: Ensure AST1030 respects uart-default
Quoted 8 lines · Peter Delevoryas
The AST1030 machine initialization was not respecting the Aspeed SoC property "uart-default", which specifies which UART should be connected to the first serial device, it was just always connecting UART5. This doesn't change any behavior, because the default value for "uart-default" is UART5, but it makes it possible to override this in new machine definitions using the AST1030.
Signed-off-by Peter Delevoryas <[email protected]>
Thanks,
C.
Quoted 21 lines
--- hw/arm/aspeed_ast10x0.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)hw/arm/aspeed_ast10x0.c +3
-3@@ -215,9 +215,9 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)qdev_get_gpio_in (DEVICE (&s->armv7m), sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_4)); -/* UART5 - attach an 8250 to the IO space as our UART */ -serial_mm_init (get_system_memory (), sc->memmap[ASPEED_DEV_UART5 ],2 , -aspeed_soc_get_irq (s,ASPEED_DEV_UART5 ), +/* UART - attach an 8250 to the IO space as our UART */ +serial_mm_init (get_system_memory (), sc->memmap[s->uart_default],2 , +aspeed_soc_get_irq (s, s->uart_default),38400 ,serial_hd (0 ),DEVICE_LITTLE_ENDIAN );/* Timer */
PATCH v2 4/5 hw: aspeed: Introduce common UART init function
In reply to Peter Delevoryas--- hw/arm/aspeed_ast10x0.c | 7 ++----- hw/arm/aspeed_ast2600.c | 7 ++----- hw/arm/aspeed_soc.c | 16 ++++++++++++---- include/hw/arm/aspeed_soc.h | 1 + 4 files changed, 17 insertions(+), 14 deletions(-)
hw/arm/aspeed_ast10x0.c +2 -5
@@ -15,7 +15,6 @@#include "sysemu/sysemu.h" #include "hw/qdev-clock.h" #include "hw/misc/unimp.h" -#include "hw/char/serial.h" #include "hw/arm/aspeed_soc.h" #define ASPEED_SOC_IOMEM_SIZE 0x00200000
@@ -215,10 +214,8 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)qdev_get_gpio_in (DEVICE (&s->armv7m), sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_4)); -/* UART - attach an 8250 to the IO space as our UART */ -serial_mm_init (get_system_memory (), sc->memmap[s->uart_default],2 , -aspeed_soc_get_irq (s, s->uart_default), -38400 ,serial_hd (0 ),DEVICE_LITTLE_ENDIAN ); +/* UART */ +aspeed_soc_uart_init (s);/* Timer */ object_property_set_link(OBJECT(&s->timerctrl), "scu", OBJECT(&s->scu),
hw/arm/aspeed_ast2600.c +2 -5
@@ -11,7 +11,6 @@#include "qapi/error.h" #include "hw/misc/unimp.h" #include "hw/arm/aspeed_soc.h" -#include "hw/char/serial.h" #include "qemu/module.h" #include "qemu/error-report.h" #include "hw/i2c/aspeed_i2c.h"
@@ -372,10 +371,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->adc),0 ,aspeed_soc_get_irq (s,ASPEED_DEV_ADC )); -/* UART - attach an 8250 to the IO space as our UART */ -serial_mm_init (get_system_memory (), sc->memmap[s->uart_default],2 , -aspeed_soc_get_irq (s, s->uart_default),38400 , -serial_hd (0 ),DEVICE_LITTLE_ENDIAN ); +/* UART */ +aspeed_soc_uart_init (s);/* I2C */ object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr),
hw/arm/aspeed_soc.c +12 -4
@@ -303,10 +303,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->adc),0 ,aspeed_soc_get_irq (s,ASPEED_DEV_ADC )); -/* UART - attach an 8250 to the IO space as our UART */ -serial_mm_init (get_system_memory (), sc->memmap[s->uart_default],2 , -aspeed_soc_get_irq (s, s->uart_default),38400 , -serial_hd (0 ),DEVICE_LITTLE_ENDIAN ); +/* UART */ +aspeed_soc_uart_init (s);/* I2C */ object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr),
@@ -544,3 +542,13 @@ qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev) {return ASPEED_SOC_GET_CLASS (s)->get_irq (s, dev); } + +void aspeed_soc_uart_init (AspeedSoCState *s) +{ +AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); + +/* Attach an 8250 to the IO space as our UART */ +serial_mm_init (get_system_memory (), sc->memmap[s->uart_default],2 , +aspeed_soc_get_irq (s, s->uart_default),38400 , +serial_hd (0 ),DEVICE_LITTLE_ENDIAN ); +}
include/hw/arm/aspeed_soc.h +1 -0
@@ -164,5 +164,6 @@ enum { };qemu_irq aspeed_soc_get_irq (AspeedSoCState *s,int dev); +void aspeed_soc_uart_init (AspeedSoCState *s);#endif /* ASPEED_SOC_H */
Signature · 1 line
2.30.2
Re: [PATCH v2 4/5] hw: aspeed: Introduce common UART init function
Quoted 1 line · Peter Delevoryas
Signed-off-by Peter Delevoryas <[email protected]>
Thanks,
C.
Quoted 99 lines
--- hw/arm/aspeed_ast10x0.c | 7 ++----- hw/arm/aspeed_ast2600.c | 7 ++----- hw/arm/aspeed_soc.c | 16 ++++++++++++---- include/hw/arm/aspeed_soc.h | 1 + 4 files changed, 17 insertions(+), 14 deletions(-)hw/arm/aspeed_ast10x0.c +2
-5@@ -15,7 +15,6 @@#include "sysemu/sysemu.h" #include "hw/qdev-clock.h" #include "hw/misc/unimp.h" -#include "hw/char/serial.h" #include "hw/arm/aspeed_soc.h" #define ASPEED_SOC_IOMEM_SIZE 0x00200000@@ -215,10 +214,8 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)qdev_get_gpio_in (DEVICE (&s->armv7m), sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_4)); -/* UART - attach an 8250 to the IO space as our UART */ -serial_mm_init (get_system_memory (), sc->memmap[s->uart_default],2 , -aspeed_soc_get_irq (s, s->uart_default), -38400 ,serial_hd (0 ),DEVICE_LITTLE_ENDIAN ); +/* UART */ +aspeed_soc_uart_init (s);/* Timer */ object_property_set_link(OBJECT(&s->timerctrl), "scu", OBJECT(&s->scu),hw/arm/aspeed_ast2600.c +2
-5@@ -11,7 +11,6 @@#include "qapi/error.h" #include "hw/misc/unimp.h" #include "hw/arm/aspeed_soc.h" -#include "hw/char/serial.h" #include "qemu/module.h" #include "qemu/error-report.h" #include "hw/i2c/aspeed_i2c.h" @@ -372,10 +371,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->adc),0 ,aspeed_soc_get_irq (s,ASPEED_DEV_ADC )); -/* UART - attach an 8250 to the IO space as our UART */ -serial_mm_init (get_system_memory (), sc->memmap[s->uart_default],2 , -aspeed_soc_get_irq (s, s->uart_default),38400 , -serial_hd (0 ),DEVICE_LITTLE_ENDIAN ); +/* UART */ +aspeed_soc_uart_init (s);/* I2C */ object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr),hw/arm/aspeed_soc.c +12
-4@@ -303,10 +303,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->adc),0 ,aspeed_soc_get_irq (s,ASPEED_DEV_ADC )); -/* UART - attach an 8250 to the IO space as our UART */ -serial_mm_init (get_system_memory (), sc->memmap[s->uart_default],2 , -aspeed_soc_get_irq (s, s->uart_default),38400 , -serial_hd (0 ),DEVICE_LITTLE_ENDIAN ); +/* UART */ +aspeed_soc_uart_init (s);/* I2C */ object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr),@@ -544,3 +542,13 @@ qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev) {return ASPEED_SOC_GET_CLASS (s)->get_irq (s, dev); } + +void aspeed_soc_uart_init (AspeedSoCState *s) +{ +AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); + +/* Attach an 8250 to the IO space as our UART */ +serial_mm_init (get_system_memory (), sc->memmap[s->uart_default],2 , +aspeed_soc_get_irq (s, s->uart_default),38400 , +serial_hd (0 ),DEVICE_LITTLE_ENDIAN ); +}include/hw/arm/aspeed_soc.h +1
-0@@ -164,5 +164,6 @@ enum { };qemu_irq aspeed_soc_get_irq (AspeedSoCState *s,int dev); +void aspeed_soc_uart_init (AspeedSoCState *s);#endif /* ASPEED_SOC_H */
PATCH v2 5/5 hw: aspeed: Init all UART's with serial devices
In reply to Peter DelevoryasBackground:
AspeedMachineClass.uart_default specifies the serial console UART, which usually corresponds to the "stdout-path" in the device tree.
The default value is UART5, since most boards use UART5 for this:
amc->uart_default = ASPEED_DEV_UART5;
Users can override AspeedMachineClass.uart_default in their board's machine class init to specify something besides UART5. For example, for fuji-bmc:
amc->uart_default = ASPEED_DEV_UART1;
We only connect this one UART, of the 5 UART's on the AST2400 and AST2500 and the 13 UART's on the AST2600 and AST1030, to a serial device that QEMU users can use. None of the other UART's are initialized, and the only way to override this attribute is by creating a specialized board definition, requiring QEMU source code changes and rebuilding.
The result of this is that if you want to get serial console output on a board that uses UART3, you need to add a board definition. This was encountered by Zev in OpenBMC. [1]
Changes:
This commit initializes all of the UART's present on each Aspeed chip with serial devices and allows the QEMU user to connect as many or few as they like to serial devices. For example, you can still run QEMU and just connect stdout to the machine's default UART, without specifying any additional serial devices:
qemu-system-arm -machine fuji-bmc \
-drive file=fuji.mtd,format=raw,if=mtd \
-nographicHowever, if you don't want to add a special machine definition, you can now manually configure UART1 to connect to stdout and get serial console output, even if the machine's default is UART5:
qemu-system-arm -machine ast2600-evb \
-drive file=fuji.mtd,format=raw,if=mtd \
-serial null -serial mon:stdio -display noneIn the example above, the first "-serial null" argument is connected to UART5, and "-serial mon:stdio" is connected to UART1.
Another example: you can get serial console output from Wedge100, which uses UART3, by reusing the palmetto AST2400 machine and rewiring the serial device arguments:
qemu-system-arm -machine palmetto-bmc \
-drive file=wedge100.mtd,format=raw,if=mtd \
-serial null -serial null -serial null \
-serial mon:stdio -display noneThere is a slight change in behavior introduced with this change: now, each UART's memory-mapped IO region will have a serial device model connected to it. Previously, all reads and writes to those regions would be ineffective and return zero values, but now some values will be nonzero, even when the user doesn't connect a serial device backend (like a socket, file, etc). For example, the line status register might indicate that the transmit buffer is empty now, whereas previously it might have always indicated it was full.
[1] https://lore.kernel.org/openbmc/[email protected]/
[2] https://github.com/facebook/openbmc/releases/download/v2021.49.0/fuji.mtd
[3] https://github.com/facebook/openbmc/releases/download/v2021.49.0/wedge100.mtd
--- hw/arm/aspeed_soc.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/arm/aspeed_soc.c +9 -0
@@ -546,9 +546,18 @@ qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev)void aspeed_soc_uart_init (AspeedSoCState *s) {AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); +int i, uart;/* Attach an 8250 to the IO space as our UART */ serial_mm_init (get_system_memory (), sc->memmap[s->uart_default],2 ,aspeed_soc_get_irq (s, s->uart_default),38400 ,serial_hd (0 ),DEVICE_LITTLE_ENDIAN ); +for (i =1 , uart =ASPEED_DEV_UART1 ; i < sc->uarts_num; i++, uart++) { +if (uart == s->uart_default) { + uart++; + } +serial_mm_init (get_system_memory (), sc->memmap[uart],2 , +aspeed_soc_get_irq (s, uart),38400 , +serial_hd (i),DEVICE_LITTLE_ENDIAN ); + } }
Signature · 1 line
2.30.2
Quoted 64 lines · Peter Delevoryas
Background:
AspeedMachineClass.uart_default specifies the serial console UART, which usually corresponds to the "stdout-path" in the device tree.
The default value is UART5, since most boards use UART5 for this:
amc->uart_default = ASPEED_DEV_UART5;Users can override AspeedMachineClass.uart_default in their board's machine class init to specify something besides UART5. For example, for fuji-bmc:
amc->uart_default = ASPEED_DEV_UART1;We only connect this one UART, of the 5 UART's on the AST2400 and AST2500 and the 13 UART's on the AST2600 and AST1030, to a serial device that QEMU users can use. None of the other UART's are initialized, and the only way to override this attribute is by creating a specialized board definition, requiring QEMU source code changes and rebuilding.
The result of this is that if you want to get serial console output on a board that uses UART3, you need to add a board definition. This was encountered by Zev in OpenBMC. [1]
Changes:
This commit initializes all of the UART's present on each Aspeed chip with serial devices and allows the QEMU user to connect as many or few as they like to serial devices. For example, you can still run QEMU and just connect stdout to the machine's default UART, without specifying any additional serial devices:
qemu-system-arm -machine fuji-bmc \ -drive file=fuji.mtd,format=raw,if=mtd \ -nographicHowever, if you don't want to add a special machine definition, you can now manually configure UART1 to connect to stdout and get serial console output, even if the machine's default is UART5:
qemu-system-arm -machine ast2600-evb \ -drive file=fuji.mtd,format=raw,if=mtd \ -serial null -serial mon:stdio -display noneIn the example above, the first "-serial null" argument is connected to UART5, and "-serial mon:stdio" is connected to UART1.
Another example: you can get serial console output from Wedge100, which uses UART3, by reusing the palmetto AST2400 machine and rewiring the serial device arguments:
qemu-system-arm -machine palmetto-bmc \ -drive file=wedge100.mtd,format=raw,if=mtd \ -serial null -serial null -serial null \ -serial mon:stdio -display noneThere is a slight change in behavior introduced with this change: now, each UART's memory-mapped IO region will have a serial device model connected to it. Previously, all reads and writes to those regions would be ineffective and return zero values, but now some values will be nonzero, even when the user doesn't connect a serial device backend (like a socket, file, etc). For example, the line status register might indicate that the transmit buffer is empty now, whereas previously it might have always indicated it was full.
Quoted 5 lines
[1] https://lore.kernel.org/openbmc/[email protected]/
[2] https://github.com/facebook/openbmc/releases/download/v2021.49.0/fuji.mtd
[3] https://github.com/facebook/openbmc/releases/download/v2021.49.0/wedge100.mtdSigned-off-by Peter Delevoryas <[email protected]>
Thanks,
C.
Quoted 27 lines
--- hw/arm/aspeed_soc.c | 9 +++++++++ 1 file changed, 9 insertions(+)hw/arm/aspeed_soc.c +9
-0@@ -546,9 +546,18 @@ qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev)void aspeed_soc_uart_init (AspeedSoCState *s) {AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); +int i, uart;/* Attach an 8250 to the IO space as our UART */ serial_mm_init (get_system_memory (), sc->memmap[s->uart_default],2 ,aspeed_soc_get_irq (s, s->uart_default),38400 ,serial_hd (0 ),DEVICE_LITTLE_ENDIAN ); +for (i =1 , uart =ASPEED_DEV_UART1 ; i < sc->uarts_num; i++, uart++) { +if (uart == s->uart_default) { + uart++; + } +serial_mm_init (get_system_memory (), sc->memmap[uart],2 , +aspeed_soc_get_irq (s, uart),38400 , +serial_hd (i),DEVICE_LITTLE_ENDIAN ); + } }
Quoted 5 lines · Peter Delevoryas
v2:
- Rebased on Cedric's irq proposal. [1]
- Added "Introduce common UART init function" patch
- Added "Adduarts_numSoC attribute" patch
- Rewrote last commit's message for clarity
Looks good to me.
Quoted 6 lines
I tried testing this by running acceptance tests, particularly the
boot_linux_console.pyfile, but I had to disable theraspi2_initrdcase. It's not related to my changes (A/B tested and it fails on upstream/master too), but thought I would mention that.>
I also manually tested several machines:
Quoted 6 lines
AST2400: https://github.com/facebook/openbmc/releases/download/v2021.49.0/wedge100.mtd
AST2500: https://github.com/facebook/openbmc/releases/download/v2021.49.0/fby3.mtd
AST2600: https://github.com/facebook/openbmc/releases/download/v2021.49.0/fuji.mtd
AST1030: https://github.com/peterdelevoryas/OpenBIC/releases/download/oby35-cl-2022.13.01/Y35BCL.elf
I have quite a few images which I run manually. OpenBMC is providing images, Aspeed also. Joel did a small tool for the IBM rainier :
https://github.com/shenki/qemu-boot-test
Having an automated framework for Aspeed machines pulling images from different places would be nice but we cannot put all under QEMU.
I like the buildroot CI using the QEMU boards. See a pipeline example:
https://gitlab.com/legoater/buildroot/-/pipelines/539559209
but that's buildroot only and integrating a custom uboot might be difficult.
For my ppc needs, I did a quick-and-dirty non-regression test suite :
https://github.com/legoater/qemu-ppc-boot
Anyway, I haven't found a solution nor spent much time on it but I am interested !
C.
Quoted 14 lines
Peter Delevoryas (5):
hw: aspeed: Add missing UART's
hw: aspeed: Adduarts_numSoC attribute
hw: aspeed: Ensure AST1030 respects uart-default
hw: aspeed: Introduce common UART init function
hw: aspeed: Init all UART's with serial deviceshw/arm/aspeed_ast10x0.c | 32 +++++++++++++++++++++++++++----- hw/arm/aspeed_ast2600.c | 27 ++++++++++++++++++++++----- hw/arm/aspeed_soc.c | 33 +++++++++++++++++++++++++++++---- include/hw/arm/aspeed_soc.h | 10 ++++++++++ 4 files changed, 88 insertions(+), 14 deletions(-)
Quoted 21 lines · Cédric Le Goater
Quoted 5 lines · Peter Delevoryas
v2:
- Rebased on Cedric's irq proposal. [1]
- Added "Introduce common UART init function" patch
- Added "Adduarts_numSoC attribute" patch
- Rewrote last commit's message for clarityLooks good to me.
Quoted 6 lines
I tried testing this by running acceptance tests, particularly the
boot_linux_console.pyfile, but I had to disable theraspi2_initrdcase. It's not related to my changes (A/B tested and it fails on upstream/master too), but thought I would mention that.>
I also manually tested several machines:Quoted 6 lines
AST2400: https://github.com/facebook/openbmc/releases/download/v2021.49.0/wedge100.mtd
AST2500: https://github.com/facebook/openbmc/releases/download/v2021.49.0/fby3.mtd
AST2600: https://github.com/facebook/openbmc/releases/download/v2021.49.0/fuji.mtd
AST1030: https://github.com/peterdelevoryas/OpenBIC/releases/download/oby35-cl-2022.13.01/Y35BCL.elf
Quoted 8 lines
I have quite a few images which I run manually. OpenBMC is providing images, Aspeed also. Joel did a small tool for the IBM rainier :
https://github.com/shenki/qemu-boot-test
Having an automated framework for Aspeed machines pulling images from different places would be nice but we cannot put all under QEMU.
For what it's worth I run this as a smoke test before pushing updates to openbmc/qemu:
https://github.com/openbmc/openbmc-build-scripts/blob/master/scripts/test-qemu
Andrew
Quoted 39 lines · Cédric Le Goater
Quoted 5 lines · Peter Delevoryas
v2:
- Rebased on Cedric's irq proposal. [1]
- Added "Introduce common UART init function" patch
- Added "Adduarts_numSoC attribute" patch
- Rewrote last commit's message for clarityLooks good to me.
Quoted 10 lines
I tried testing this by running acceptance tests, particularly the
boot_linux_console.pyfile, but I had to disable theraspi2_initrdcase.
It's not related to my changes (A/B tested and it fails on upstream/master
too), but thought I would mention that.>
I also manually tested several machines:
AST2400: https://github.com/facebook/openbmc/releases/download/v2021.49.0/wedge100.mtd
AST2500: https://github.com/facebook/openbmc/releases/download/v2021.49.0/fby3.mtd
AST2600: https://github.com/facebook/openbmc/releases/download/v2021.49.0/fuji.mtd
AST1030: https://github.com/peterdelevoryas/OpenBIC/releases/download/oby35-cl-2022.13.01/Y35BCL.elf
[1] https://lore.kernel.org/qemu-devel/[email protected]/I have quite a few images which I run manually. OpenBMC is providing images, Aspeed also. Joel did a small tool for the IBM rainier :
https://github.com/shenki/qemu-boot-test
Having an automated framework for Aspeed machines pulling images from different places would be nice but we cannot put all under QEMU.
I like the buildroot CI using the QEMU boards. See a pipeline example:
https://gitlab.com/legoater/buildroot/-/pipelines/539559209
but that's buildroot only and integrating a custom uboot might be difficult.
Quoted 7 lines
For my ppc needs, I did a quick-and-dirty non-regression test suite :
https://github.com/legoater/qemu-ppc-boot
Anyway, I haven't found a solution nor spent much time on it but I am interested !
Oh thanks for the links, I’m somewhat interested in looking into this further.
Quoted 19 lines
C.
Quoted 11 lines
Peter Delevoryas (5):
hw: aspeed: Add missing UART's
hw: aspeed: Adduarts_numSoC attribute
hw: aspeed: Ensure AST1030 respects uart-default
hw: aspeed: Introduce common UART init function
hw: aspeed: Init all UART's with serial deviceshw/arm/aspeed_ast10x0.c | 32 +++++++++++++++++++++++++++----- hw/arm/aspeed_ast2600.c | 27 ++++++++++++++++++++++----- hw/arm/aspeed_soc.c | 33 +++++++++++++++++++++++++++++---- include/hw/arm/aspeed_soc.h | 10 ++++++++++ 4 files changed, 88 insertions(+), 14 deletions(-)