[PATCH v2 4/5] hw: aspeed: Introduce common UART init function

Cédric Le Goater clg at kaod.org
Mon May 16 17:20:56 AEST 2022


On 5/16/22 08:23, Peter Delevoryas wrote:
> Signed-off-by: Peter Delevoryas <pdel at fb.com>

Reviewed-by: Cédric Le Goater <clg at kaod.org>

Thanks,

C.




> ---
>   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(-)
> 
> diff --git a/hw/arm/aspeed_ast10x0.c b/hw/arm/aspeed_ast10x0.c
> index faafb800f3..938615d55f 100644
> --- a/hw/arm/aspeed_ast10x0.c
> +++ b/hw/arm/aspeed_ast10x0.c
> @@ -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),
> diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
> index a9523074a0..b0a4199b69 100644
> --- a/hw/arm/aspeed_ast2600.c
> +++ b/hw/arm/aspeed_ast2600.c
> @@ -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),
> diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
> index 7008cd1af7..912798a9c9 100644
> --- a/hw/arm/aspeed_soc.c
> +++ b/hw/arm/aspeed_soc.c
> @@ -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);
> +}
> diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
> index 669bc49855..02a5a9ffcb 100644
> --- a/include/hw/arm/aspeed_soc.h
> +++ b/include/hw/arm/aspeed_soc.h
> @@ -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 */



More information about the openbmc mailing list