hw/display: Add i.MX6UL LCDIF device model
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/3 hw/display: Add i.MX6UL LCDIF device model
Implement a basic i.MX6UL LCDIF controller model with MMIO\nregisters, frame-done interrupt behavior, and framebuffer-backed\ndisplay updates for RGB565 and XRGB8888 inputs.\n\nModel the register fields using registerfields.h helpers, provide\nmigration support via vmstate, and place the device under hw/display/\nas a standalone display device.
--- MAINTAINERS | 2 + hw/display/imx6ul_lcdif.c | 435 ++++++++++++++++++++++++++++++ include/hw/display/imx6ul_lcdif.h | 36 +++ 3 files changed, 473 insertions(+) create mode 100644 hw/display/imx6ul_lcdif.c create mode 100644 include/hw/display/imx6ul_lcdif.h
MAINTAINERS +2 -0
@@ -895,8 +895,10 @@ L: [email protected] S: Odd Fixes F: hw/arm/mcimx6ul-evk.c F: hw/arm/fsl-imx6ul.c +F: hw/display/imx6ul_lcdif.c F: hw/misc/imx6ul_ccm.c F: include/hw/arm/fsl-imx6ul.h +F: include/hw/display/imx6ul_lcdif.h F: include/hw/misc/imx6ul_ccm.h F: docs/system/arm/mcimx6ul-evk.rst
hw/display/imx6ul_lcdif.c new file +435 -0
435 lines not on this page · raw message
include/hw/display/imx6ul_lcdif.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* i.MX6UL LCDIF controller +* +* Copyright (c) 2026 Yucai Liu <[email protected]> +*/ + +#ifndef IMX6UL_LCDIF_H +#define IMX6UL_LCDIF_H + +#include "hw/core/sysbus.h" +#include "qom/object.h" +#include "qemu/timer.h" +#include "ui/console.h" + +#define TYPE_IMX6UL_LCDIF "imx6ul-lcdif" +OBJECT_DECLARE_SIMPLE_TYPE(IMX6ULLCDIFState, IMX6UL_LCDIF) + +struct IMX6ULLCDIFState { +SysBusDevice parent_obj; + +MemoryRegion iomem; +MemoryRegionSection fbsection; +qemu_irq irq; +QemuConsole *con; +QEMUTimer *frame_timer; +uint32_t fb_base; +uint32_t src_width; +uint32_t rows; +uint8_t src_bpp; +bool invalidate; +uint32_t regs[0x1000 /sizeof (uint32_t )]; +}; + +#endif /* IMX6UL_LCDIF_H */
Signature · 1 line
2.53.0
Quoted 2 lines · Yucai Liu
Implement a basic i.MX6UL LCDIF controller model with MMIO\nregisters, frame-done interrupt behavior, and framebuffer-backed\ndisplay updates for RGB565 and XRGB8888 inputs.\n\nModel the register fields using
registerfields.hhelpers, provide\nmigration support via vmstate, and place the device under hw/display/\nas a standalone display device.
Something odd seems to have happened to your commit message -- looks like it's ended up with literal "\n" instead of newlines ?
Quoted 40 lines
Signed-off-by Yucai Liu <[email protected]>--- MAINTAINERS | 2 + hw/display/imx6ul_lcdif.c | 435 ++++++++++++++++++++++++++++++ include/hw/display/imx6ul_lcdif.h | 36 +++ 3 files changed, 473 insertions(+) create mode 100644 hw/display/imx6ul_lcdif.c create mode 100644 include/hw/display/imx6ul_lcdif.hMAINTAINERS +2
-0@@ -895,8 +895,10 @@ L: [email protected] S: Odd Fixes F: hw/arm/mcimx6ul-evk.c F: hw/arm/fsl-imx6ul.c +F: hw/display/imx6ul_lcdif.c F: hw/misc/imx6ul_ccm.c F: include/hw/arm/fsl-imx6ul.h +F: include/hw/display/imx6ul_lcdif.h F: include/hw/misc/imx6ul_ccm.h F: docs/system/arm/mcimx6ul-evk.rsthw/display/imx6ul_lcdif.c new file +10
-0@@ -0,0 +1,435 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* i.MX6UL LCDIF controller +* +* Copyright (c) 2026 Yucai Liu <[email protected]> +*/ + +#include "qemu/osdep.h" +#include "hw/display/imx6ul_lcdif.h"
hw/display/imx6ul_lcdif.c line 20
Quoted 10 lines
hw/display/imx6ul_lcdif.c new file +10
-0+#include "hw/core/irq.h" +#include "hw/core/registerfields.h" +#include "hw/display/framebuffer.h" +#include "migration/vmstate.h" +#include "system/address-spaces.h" +#include "qapi/error.h" +#include "qemu/module.h" +#include "ui/pixel_ops.h" + +#define LCDIF_MMIO_SIZE 0x1000
Where do we get this size from ? The datasheet I have suggests the block for the LCDIF in the memory map is 16K, and on the other hand the last register is at offset 0x290.
Quoted 16 lines
hw/display/imx6ul_lcdif.c new file +16
-0+ +REG32(CTRL, 0x00) + FIELD(CTRL, RUN, 0, 1) + FIELD(CTRL, WORD_LENGTH, 8, 2) +REG32(CTRL1, 0x10) + FIELD(CTRL1, CUR_FRAME_DONE_IRQ, 9, 1) + FIELD(CTRL1, CUR_FRAME_DONE_IRQ_EN, 13, 1) +REG32(V4_TRANSFER_COUNT, 0x30) + FIELD(V4_TRANSFER_COUNT, H_COUNT, 0, 16) + FIELD(V4_TRANSFER_COUNT, V_COUNT, 16, 16) +REG32(V4_CUR_BUF, 0x40) +REG32(V4_NEXT_BUF, 0x50) +REG32(AS_NEXT_BUF, 0x230) + +#define REG_SET 0x4 +#define REG_CLR 0x8
hw/display/imx6ul_lcdif.c line 46
Quoted 10 lines
hw/display/imx6ul_lcdif.c new file +10
-0+#define REG_TOG 0xc + +#define CTRL_WORD_LENGTH_16 0 +#define CTRL_WORD_LENGTH_24 3 + +#define FRAME_PERIOD_NS (16 * 1000 * 1000ULL) + +static inline uint32_t imx6ul_lcdif_reg_idx (hwaddr offset) +{ +return (offset & ~0xf ) >>2 ;
Why >> 2 ? The device seems to have registers at address offsets 0x00, 0x10, etc, with in some cases also pseudo-regs for set/clear/toggle at 0x4, 0x8, 0xc, so I see why & ~0xf. But if we only shift by 2 then we get indexes 0, 4, 8, etc and we're not using all the array elements.
Quoted 6 lines
hw/display/imx6ul_lcdif.c new file +6
-0+} + +static inline uint32_t imx6ul_lcdif_reg_read (IMX6ULLCDIFState *s,hwaddr offset) +{ +return s->regs[imx6ul_lcdif_reg_idx (offset)]; +}
hw/display/imx6ul_lcdif.c line 62
Quoted 10 lines
hw/display/imx6ul_lcdif.c new file +10
-0+ +static inline void imx6ul_lcdif_reg_write (IMX6ULLCDIFState *s,hwaddr offset, +uint32_t value) +{ + s->regs[imx6ul_lcdif_reg_idx (offset)] = value; +} + +static inline bool imx6ul_lcdif_is_running (IMX6ULLCDIFState *s) +{ +uint32_t ctrl =imx6ul_lcdif_reg_read (s,A_CTRL );
Consider following how the imx6ul_ccm device handles its registers (it seems to be the other one we have that has some of this SET/CLR/TOG stuff). Then you could write
return FIELD_EX32(s->regs[LCDIF_RL], CTRL, RUN);
and save some of the extra wrapper function stuff.
Quoted 44 lines
hw/display/imx6ul_lcdif.c new file +44
-0+ +return FIELD_EX32 (ctrl,CTRL ,RUN ); +} + +static inline bool imx6ul_lcdif_frame_done_pending (IMX6ULLCDIFState *s) +{ +uint32_t ctrl1 =imx6ul_lcdif_reg_read (s,A_CTRL1 ); + +return FIELD_EX32 (ctrl1,CTRL1 ,CUR_FRAME_DONE_IRQ ); +} + +static void imx6ul_lcdif_schedule_frame (IMX6ULLCDIFState *s) +{ +int64_t now =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); + +timer_mod (s->frame_timer, now +FRAME_PERIOD_NS ); +} + +static void imx6ul_lcdif_maybe_schedule_frame (IMX6ULLCDIFState *s) +{ +if (imx6ul_lcdif_is_running (s) && !imx6ul_lcdif_frame_done_pending (s)) { +imx6ul_lcdif_schedule_frame (s); + }else { +timer_del (s->frame_timer); + } +} + +static void imx6ul_lcdif_update_irq (IMX6ULLCDIFState *s) +{ +uint32_t ctrl1 =imx6ul_lcdif_reg_read (s,A_CTRL1 ); +bool level =FIELD_EX32 (ctrl1,CTRL1 ,CUR_FRAME_DONE_IRQ_EN ) && +FIELD_EX32 (ctrl1,CTRL1 ,CUR_FRAME_DONE_IRQ ); + +qemu_set_irq (s->irq, level); +} + +static void imx6ul_lcdif_frame_done (IMX6ULLCDIFState *s) +{ +uint32_t ctrl1 =imx6ul_lcdif_reg_read (s,A_CTRL1 ); + + ctrl1 =FIELD_DP32 (ctrl1,CTRL1 ,CUR_FRAME_DONE_IRQ ,1 ); +imx6ul_lcdif_reg_write (s,A_CTRL1 , ctrl1); +imx6ul_lcdif_update_irq (s); +}
hw/display/imx6ul_lcdif.c line 116
Quoted 10 lines
hw/display/imx6ul_lcdif.c new file +10
-0+ +static void imx6ul_lcdif_draw_line_rgb565 (void *opaque,uint8_t *dst, +const uint8_t *src,int width, +int dststep) +{ +uint32_t *dst32 = (uint32_t *)dst; +int i; + + (void )opaque; + (void )dststep;
You don't need to use this to mark arguments as not used; QEMU's build system does not get the compilers to complain about unused arguments.
Quoted 146 lines
hw/display/imx6ul_lcdif.c new file +146
-0+ +for (i =0 ; i < width; i++) { +uint16_t pixel =lduw_le_p (src); +uint8_t r = ((pixel >>11 ) &0x1f ) <<3 ; +uint8_t g = ((pixel >>5 ) &0x3f ) <<2 ; +uint8_t b = (pixel &0x1f ) <<3 ; + + *dst32++ =rgb_to_pixel32 (r, g, b); + src +=2 ; + } +} + +static void imx6ul_lcdif_draw_line_xrgb8888 (void *opaque,uint8_t *dst, +const uint8_t *src,int width, +int dststep) +{ +uint32_t *dst32 = (uint32_t *)dst; +int i; + + (void )opaque; + (void )dststep; + +for (i =0 ; i < width; i++) { +uint32_t pixel =ldl_le_p (src); +uint8_t r = (pixel >>16 ) &0xff ; +uint8_t g = (pixel >>8 ) &0xff ; +uint8_t b = pixel &0xff ; + + *dst32++ =rgb_to_pixel32 (r, g, b); + src +=4 ; + } +} + +static void imx6ul_lcdif_update_display (void *opaque) +{ +IMX6ULLCDIFState *s = opaque; +DisplaySurface *surface =qemu_console_surface (s->con); +uint32_t transfer_count =imx6ul_lcdif_reg_read (s,A_V4_TRANSFER_COUNT ); +uint32_t width =FIELD_EX32 (transfer_count,V4_TRANSFER_COUNT ,H_COUNT ); +uint32_t height =FIELD_EX32 (transfer_count,V4_TRANSFER_COUNT ,V_COUNT ); +uint32_t ctrl =imx6ul_lcdif_reg_read (s,A_CTRL ); +uint32_t frame_base =imx6ul_lcdif_reg_read (s,A_V4_CUR_BUF ); +drawfn fn; +int first =0 ; +int last =0 ; +int src_width; + +if (!imx6ul_lcdif_is_running (s) || width ==0 || height ==0 ) { +return ; + } + +if (surface_bits_per_pixel (surface) !=32 ) { +return ; + } + +switch (FIELD_EX32 (ctrl,CTRL ,WORD_LENGTH )) { +case CTRL_WORD_LENGTH_16 : + s->src_bpp =2 ; + fn = imx6ul_lcdif_draw_line_rgb565; +break ; +case CTRL_WORD_LENGTH_24 : + s->src_bpp =4 ; + fn = imx6ul_lcdif_draw_line_xrgb8888; +break ; +default : +return ; + } + +if (surface_width (surface) != width ||surface_height (surface) != height) { +qemu_console_resize (s->con, width, height); + surface =qemu_console_surface (s->con); + s->invalidate = true; + } + + src_width = width * s->src_bpp; +if (s->invalidate || s->fb_base != frame_base || + s->src_width != src_width || s->rows != height) { +framebuffer_update_memory_section (&s->fbsection,get_system_memory (), + frame_base, height, src_width); + s->fb_base = frame_base; + s->src_width = src_width; + s->rows = height; + } + +framebuffer_update_display (surface, &s->fbsection, width, height, + src_width,surface_stride (surface),0 , + s->invalidate, fn, s, &first, &last); +if (first >=0 ) { +dpy_gfx_update (s->con,0 , first, width, last - first +1 ); + } + + s->invalidate = false; +} + +static void imx6ul_lcdif_invalidate_display (void *opaque) +{ +IMX6ULLCDIFState *s = opaque; + + s->invalidate = true; +} + +static const GraphicHwOps imx6ul_lcdif_graphic_ops = { + .invalidate = imx6ul_lcdif_invalidate_display, + .gfx_update = imx6ul_lcdif_update_display, +}; + +static void imx6ul_lcdif_frame_timer_cb (void *opaque) +{ +IMX6ULLCDIFState *s = opaque; + +if (!imx6ul_lcdif_is_running (s) ||imx6ul_lcdif_frame_done_pending (s)) { +return ; + } + +imx6ul_lcdif_frame_done (s); +} + +static uint64_t imx6ul_lcdif_read (void *opaque,hwaddr offset,unsigned size) +{ +IMX6ULLCDIFState *s = opaque; + +assert (size ==4 ); +assert (!(offset &0x3 )); +assert (offset <LCDIF_MMIO_SIZE ); + +return s->regs[imx6ul_lcdif_reg_idx (offset)]; +} + +static void imx6ul_lcdif_write (void *opaque,hwaddr offset, +uint64_t value,unsigned size) +{ +IMX6ULLCDIFState *s = opaque; +hwaddr reg = offset & ~0xf ; +uint32_t idx; +uint32_t oldv; + +assert (size ==4 ); +assert (!(offset &0x3 )); +assert (offset <LCDIF_MMIO_SIZE ); + + idx =imx6ul_lcdif_reg_idx (reg); + oldv = s->regs[idx]; + +switch (offset &0xf ) { +case REG_SET : + s->regs[idx] |= (uint32_t )value;
hw/display/imx6ul_lcdif.c line 272
Quoted 10 lines
hw/display/imx6ul_lcdif.c new file +10
-0+break ; +case REG_CLR : + s->regs[idx] &= ~(uint32_t )value; +break ; +case REG_TOG : + s->regs[idx] ^= (uint32_t )value; +break ; +default : + s->regs[idx] = (uint32_t )value; +break ;
Not every register has the SET/CLR/TOG extra registers.
Quoted 54 lines
hw/display/imx6ul_lcdif.c new file +54
-0+ } + +switch (reg) { +case A_CTRL : +if (!FIELD_EX32 (oldv,CTRL ,RUN ) && +FIELD_EX32 (s->regs[idx],CTRL ,RUN )) { + s->invalidate = true; +graphic_hw_invalidate (s->con); +imx6ul_lcdif_maybe_schedule_frame (s); +break ; + } +if (FIELD_EX32 (oldv,CTRL ,RUN ) && + !FIELD_EX32 (s->regs[idx],CTRL ,RUN )) { +timer_del (s->frame_timer); + } +break ; +case A_CTRL1 : +if (FIELD_EX32 (oldv,CTRL1 ,CUR_FRAME_DONE_IRQ ) && + !FIELD_EX32 (s->regs[idx],CTRL1 ,CUR_FRAME_DONE_IRQ )) { +imx6ul_lcdif_maybe_schedule_frame (s); + } +break ; +case A_V4_TRANSFER_COUNT : + s->invalidate = true; +graphic_hw_invalidate (s->con); +break ; +case A_V4_CUR_BUF : + s->invalidate = true; +graphic_hw_invalidate (s->con); +break ; +case A_V4_NEXT_BUF : +imx6ul_lcdif_reg_write (s,A_V4_CUR_BUF , s->regs[idx]); +imx6ul_lcdif_frame_done (s); + s->invalidate = true; +graphic_hw_invalidate (s->con); +imx6ul_lcdif_maybe_schedule_frame (s); +return ; +case A_AS_NEXT_BUF : +imx6ul_lcdif_frame_done (s); +imx6ul_lcdif_maybe_schedule_frame (s); +return ; +default : +break ; + } + +imx6ul_lcdif_update_irq (s); +} + +static const MemoryRegionOps imx6ul_lcdif_ops = { + .read = imx6ul_lcdif_read, + .write = imx6ul_lcdif_write, + .endianness =DEVICE_LITTLE_ENDIAN , + .valid = { + .min_access_size =4 ,
hw/display/imx6ul_lcdif.c line 336
Quoted 10 lines
hw/display/imx6ul_lcdif.c new file +10
-0+ .max_access_size = 4, + .unaligned = false, + }, +}; + +static void imx6ul_lcdif_reset (DeviceState *dev) +{ +IMX6ULLCDIFState *s =IMX6UL_LCDIF (dev); + +memset (s->regs,0 ,sizeof (s->regs));
The datasheet defines some registers as having non-zero reset values, notably CTRL1.
Quoted 46 lines
hw/display/imx6ul_lcdif.c new file +46
-0+ s->fb_base =0 ; + s->src_width =0 ; + s->rows =0 ; + s->src_bpp =0 ; + s->invalidate = true; +timer_del (s->frame_timer); +qemu_set_irq (s->irq,0 ); +} + +static int imx6ul_lcdif_post_load (void *opaque,int version_id) +{ +IMX6ULLCDIFState *s = opaque; + + s->fb_base =0 ; + s->src_width =0 ; + s->rows =0 ; + s->src_bpp =0 ; + s->invalidate = true; + +imx6ul_lcdif_update_irq (s); +if (imx6ul_lcdif_is_running (s) && + !imx6ul_lcdif_frame_done_pending (s) && + !timer_pending (s->frame_timer)) { +imx6ul_lcdif_schedule_frame (s); + } + +return 0 ; +} + +static const VMStateDescription vmstate_imx6ul_lcdif = { + .name =TYPE_IMX6UL_LCDIF , + .version_id =1 , + .minimum_version_id =1 , + .post_load = imx6ul_lcdif_post_load, + .fields = (const VMStateField []) { +VMSTATE_UINT32_ARRAY (regs, IMX6ULLCDIFState, +LCDIF_MMIO_SIZE /sizeof (uint32_t )), +VMSTATE_TIMER_PTR (frame_timer, IMX6ULLCDIFState), +VMSTATE_END_OF_LIST () + }, +}; + +static void imx6ul_lcdif_realize (DeviceState *dev,Error **errp) +{ +IMX6ULLCDIFState *s =IMX6UL_LCDIF (dev); +
hw/display/imx6ul_lcdif.c line 392
Quoted 10 lines
hw/display/imx6ul_lcdif.c new file +10
-0+ s->frame_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , + imx6ul_lcdif_frame_timer_cb, s); + s->invalidate = true; +memory_region_init_io (&s->iomem,OBJECT (dev), &imx6ul_lcdif_ops, s, +TYPE_IMX6UL_LCDIF ,LCDIF_MMIO_SIZE ); +sysbus_init_mmio (SYS_BUS_DEVICE (dev), &s->iomem); +sysbus_init_irq (SYS_BUS_DEVICE (dev), &s->irq); + s->con =graphic_console_init (dev,0 , &imx6ul_lcdif_graphic_ops, s); + +if (surface_bits_per_pixel (qemu_console_surface (s->con)) !=32 ) {
This is always true, you don't need to test it.
hw/display/imx6ul_lcdif.c line 402
Quoted 10 lines
hw/display/imx6ul_lcdif.c new file +10
-0+error_setg (errp,"%s requires a 32bpp host surface" ,TYPE_IMX6UL_LCDIF ); + } +} + +static void imx6ul_lcdif_finalize (Object *obj) +{ +IMX6ULLCDIFState *s =IMX6UL_LCDIF (obj); + +if (s->fbsection.mr) { +memory_region_set_log (s->fbsection.mr, false,DIRTY_MEMORY_VGA );
No other display device seems to be doing this -- why do we need to ?
hw/display/imx6ul_lcdif.c line 409
Quoted 7 lines
hw/display/imx6ul_lcdif.c new file +7
-0+memory_region_unref (s->fbsection.mr); + s->fbsection.mr =NULL ; + } +if (s->con) { +graphic_console_close (s->con); + } +timer_free (s->frame_timer);
Cleanup of things done in realize should go in unrealize. (instance_finalize pairs with instance_init).
Quoted 55 lines
hw/display/imx6ul_lcdif.c new file +26
-0+} + +static void imx6ul_lcdif_class_init (ObjectClass *klass,const void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); + + dc->realize = imx6ul_lcdif_realize; + dc->vmsd = &vmstate_imx6ul_lcdif; +device_class_set_legacy_reset (dc, imx6ul_lcdif_reset); + dc->desc ="i.MX6UL LCDIF" ; +} + +static const TypeInfo imx6ul_lcdif_info = { + .name =TYPE_IMX6UL_LCDIF , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (IMX6ULLCDIFState), + .instance_finalize = imx6ul_lcdif_finalize, + .class_init = imx6ul_lcdif_class_init, +}; + +static void imx6ul_lcdif_register_types (void ) +{ +type_register_static (&imx6ul_lcdif_info); +} + +type_init (imx6ul_lcdif_register_types)include/hw/display/imx6ul_lcdif.h new file +23
-0@@ -0,0 +1,36 @@ +/* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* i.MX6UL LCDIF controller +* +* Copyright (c) 2026 Yucai Liu <[email protected]> +*/ + +#ifndef IMX6UL_LCDIF_H +#define IMX6UL_LCDIF_H + +#include "hw/core/sysbus.h" +#include "qom/object.h" +#include "qemu/timer.h" +#include "ui/console.h" + +#define TYPE_IMX6UL_LCDIF "imx6ul-lcdif" +OBJECT_DECLARE_SIMPLE_TYPE(IMX6ULLCDIFState, IMX6UL_LCDIF) + +struct IMX6ULLCDIFState { + SysBusDevice parent_obj; + + MemoryRegion iomem;
include/hw/display/imx6ul_lcdif.h line 33
Quoted 10 lines
include/hw/display/imx6ul_lcdif.h new file +10
-0+MemoryRegionSection fbsection; +qemu_irq irq; +QemuConsole *con; +QEMUTimer *frame_timer; +uint32_t fb_base; +uint32_t src_width; +uint32_t rows; +uint8_t src_bpp; +bool invalidate; +uint32_t regs[0x1000 /sizeof (uint32_t )];
This is much more space than you actually need; see earlier remarks.
include/hw/display/imx6ul_lcdif.h line 34
Quoted 1 line
include/hw/display/imx6ul_lcdif.h new file +1
-0+};
thanks
-- PMM
PATCH v2 2/3 hw/display: Build i.MX6UL LCDIF via its own config symbol
In reply to a message not in the archiveIntroduce CONFIG_IMX6UL_LCDIF in hw/display/Kconfig and compile\nthe device from hw/display/meson.build.\n\nStop compiling the LCDIF source from hw/arm/meson.build so the\ndisplay device follows the standard per-device symbol pattern.
--- hw/arm/meson.build | 4 +++- hw/display/Kconfig | 4 ++++ hw/display/meson.build | 1 + 3 files changed, 8 insertions(+), 1 deletion(-)
hw/arm/meson.build +3 -1
@@ -87,7 +87,9 @@ arm_common_ss.add(when: 'CONFIG_FSL_IMX8MP', if_true: files('fsl-imx8mp.c')) arm_common_ss.add(when: 'CONFIG_FSL_IMX8MP_EVK', if_true: files('imx8mp-evk.c')) arm_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmuv3.c')) arm_ss.add(when: 'CONFIG_ARM_SMMUV3_ACCEL', if_true: files('smmuv3-accel.c')) -arm_common_ss.add(when: 'CONFIG_FSL_IMX6UL', if_true: files('fsl-imx6ul.c', 'mcimx6ul-evk.c')) +arm_common_ss.add(when: 'CONFIG_FSL_IMX6UL', + if_true: files('fsl-imx6ul.c', + 'mcimx6ul-evk.c')) arm_common_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_soc.c')) arm_common_ss.add(when: 'CONFIG_XEN', if_true: files( 'xen-stubs.c',
hw/display/Kconfig +4 -0
@@ -25,6 +25,10 @@ config PL110 bool select FRAMEBUFFER +config IMX6UL_LCDIF + bool + select FRAMEBUFFER + config SII9022 bool depends on I2C
hw/display/meson.build +1 -0
@@ -11,6 +11,7 @@ system_ss.add(when: ['CONFIG_VGA_CIRRUS', 'CONFIG_VGA_ISA'], if_true: files('cir system_ss.add(when: 'CONFIG_G364FB', if_true: files('g364fb.c')) system_ss.add(when: 'CONFIG_JAZZ_LED', if_true: files('jazz_led.c')) system_ss.add(when: 'CONFIG_PL110', if_true: files('pl110.c')) +system_ss.add(when: 'CONFIG_IMX6UL_LCDIF', if_true: files('imx6ul_lcdif.c')) system_ss.add(when: 'CONFIG_SII9022', if_true: files('sii9022.c')) system_ss.add(when: 'CONFIG_SSD0303', if_true: files('ssd0303.c')) system_ss.add(when: 'CONFIG_SSD0323', if_true: files('ssd0323.c'))
Signature · 1 line
2.53.0
Re: [PATCH v2 2/3] hw/display: Build i.MX6UL LCDIF via its own config symbol
Quoted 15 lines · Yucai Liu
Introduce
CONFIG_IMX6UL_LCDIFin hw/display/Kconfig and compile\nthe device from hw/display/meson.build.\n\nStop compiling the LCDIF source from hw/arm/meson.build so the\ndisplay device follows the standard per-device symbol pattern.Signed-off-by Yucai Liu <[email protected]>--- hw/arm/meson.build | 4 +++- hw/display/Kconfig | 4 ++++ hw/display/meson.build | 1 + 3 files changed, 8 insertions(+), 1 deletion(-)hw/arm/meson.build +0
-0
hw/arm/meson.build arm_common_ss.add(when: 'CONFIG_FSL_IMX8MP', if_true: files('fsl-imx8mp.c')) · line 92
Quoted 7 lines
hw/arm/meson.build +3
-1@@ -87,7 +87,9 @@ arm_common_ss.add(when: 'CONFIG_FSL_IMX8MP', if_true: files('fsl-imx8mp.c')) arm_common_ss.add(when: 'CONFIG_FSL_IMX8MP_EVK', if_true: files('imx8mp-evk.c')) arm_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmuv3.c')) arm_ss.add(when: 'CONFIG_ARM_SMMUV3_ACCEL', if_true: files('smmuv3-accel.c')) -arm_common_ss.add(when: 'CONFIG_FSL_IMX6UL', if_true: files('fsl-imx6ul.c', 'mcimx6ul-evk.c')) +arm_common_ss.add(when: 'CONFIG_FSL_IMX6UL', + if_true: files('fsl-imx6ul.c', + 'mcimx6ul-evk.c'))
This change is unrelated to LCDIF and is only changing the line-wrap -- I think we can drop it.
Quoted 23 lines
hw/arm/meson.build +0
-0arm_common_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_soc.c')) arm_common_ss.add(when: 'CONFIG_XEN', if_true: files( 'xen-stubs.c',hw/display/Kconfig +4
-0@@ -25,6 +25,10 @@ config PL110 bool select FRAMEBUFFER +config IMX6UL_LCDIF + bool + select FRAMEBUFFER + config SII9022 bool depends on I2Chw/display/meson.build +0
-0
hw/display/meson.build system_ss.add(when: ['CONFIG_VGA_CIRRUS', 'CONFIG_VGA_ISA'], if_true: files('cir · line 17
Quoted 7 lines
hw/display/meson.build +1
-0@@ -11,6 +11,7 @@ system_ss.add(when: ['CONFIG_VGA_CIRRUS', 'CONFIG_VGA_ISA'], if_true: files('cir system_ss.add(when: 'CONFIG_G364FB', if_true: files('g364fb.c')) system_ss.add(when: 'CONFIG_JAZZ_LED', if_true: files('jazz_led.c')) system_ss.add(when: 'CONFIG_PL110', if_true: files('pl110.c')) +system_ss.add(when: 'CONFIG_IMX6UL_LCDIF', if_true: files('imx6ul_lcdif.c')) system_ss.add(when: 'CONFIG_SII9022', if_true: files('sii9022.c')) system_ss.add(when: 'CONFIG_SSD0303', if_true: files('ssd0303.c')) system_ss.add(when: 'CONFIG_SSD0323', if_true: files('ssd0323.c'))
These two parts should go in the preceding patch.
thanks
-- PMM
PATCH v2 3/3 hw/arm/fsl-imx6ul: Wire in the LCDIF device model
In reply to a message not in the archiveInstantiate LCDIF as a child object of the i.MX6UL SoC and realize\nit in the SoC realize path before MMIO/IRQ hookup.\n\nAlso make FSL_IMX6UL select CONFIG_IMX6UL_LCDIF and adjust the LCDIF\nMMIO size to 0x1000.
--- hw/arm/Kconfig | 1 + hw/arm/fsl-imx6ul.c | 12 ++++++++++-- include/hw/arm/fsl-imx6ul.h | 4 +++- 3 files changed, 14 insertions(+), 3 deletions(-)
hw/arm/Kconfig +1 -0
@@ -641,6 +641,7 @@ config FSL_IMX6UL imply I2C_DEVICES select A15MPCORE select IMX + select IMX6UL_LCDIF select IMX_FEC select IMX_I2C select IMX_USBPHY
hw/arm/fsl-imx6ul.c +10 -2
@@ -19,6 +19,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/arm/fsl-imx6ul.h" +#include "hw/display/imx6ul_lcdif.h" #include "hw/misc/unimp.h" #include "hw/usb/imx-usb-phy.h" #include "hw/core/boards.h"
@@ -136,6 +137,11 @@ static void fsl_imx6ul_init(Object *obj)object_initialize_child (obj, name, &s->usb[i],TYPE_CHIPIDEA ); } +/* +* LCDIF +*/ +object_initialize_child (obj,"lcdif" , &s->lcdif,TYPE_IMX6UL_LCDIF ); +/* * SDHCIs */
@@ -656,8 +662,10 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)/* * LCD */ -create_unimplemented_device ("lcdif" ,FSL_IMX6UL_LCDIF_ADDR , -FSL_IMX6UL_LCDIF_SIZE ); +sysbus_realize (SYS_BUS_DEVICE (&s->lcdif), &error_abort); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->lcdif),0 ,FSL_IMX6UL_LCDIF_ADDR ); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->lcdif),0 , +qdev_get_gpio_in (gic,FSL_IMX6UL_LCDIF_IRQ ));/* * CSU
include/hw/arm/fsl-imx6ul.h +3 -1
@@ -33,6 +33,7 @@#include "hw/net/imx_fec.h" #include "hw/usb/chipidea.h" #include "hw/usb/imx-usb-phy.h" +#include "hw/display/imx6ul_lcdif.h" #include "system/memory.h" #include "cpu.h" #include "qom/object.h"
@@ -84,6 +85,7 @@ struct FslIMX6ULState {IMX2WdtState wdt[FSL_IMX6UL_NUM_WDTS ];IMXUSBPHYState usbphy[FSL_IMX6UL_NUM_USB_PHYS ];ChipideaState usb[FSL_IMX6UL_NUM_USBS ]; +IMX6ULLCDIFState lcdif;MemoryRegion rom;MemoryRegion caam;MemoryRegion ocram;
@@ -143,7 +145,7 @@ enum FslIMX6ULMemoryMap {FSL_IMX6UL_PXP_SIZE = (16 * KiB),FSL_IMX6UL_LCDIF_ADDR =0x021C8000 , -FSL_IMX6UL_LCDIF_SIZE =0x100 , +FSL_IMX6UL_LCDIF_SIZE =0x1000 ,FSL_IMX6UL_CSI_ADDR =0x021C4000 , FSL_IMX6UL_CSI_SIZE = 0x100,
Signature · 1 line
2.53.0
Re: [PATCH v2 3/3] hw/arm/fsl-imx6ul: Wire in the LCDIF device model
Quoted 80 lines · Yucai Liu
Instantiate LCDIF as a child object of the i.MX6UL SoC and realize\nit in the SoC realize path before MMIO/IRQ hookup.\n\nAlso make
FSL_IMX6ULselectCONFIG_IMX6UL_LCDIFand adjust the LCDIF\nMMIO size to0x1000.Signed-off-by Yucai Liu <[email protected]>--- hw/arm/Kconfig | 1 + hw/arm/fsl-imx6ul.c | 12 ++++++++++-- include/hw/arm/fsl-imx6ul.h | 4 +++- 3 files changed, 14 insertions(+), 3 deletions(-)hw/arm/Kconfig +1
-0@@ -641,6 +641,7 @@ config FSL_IMX6UL imply I2C_DEVICES select A15MPCORE select IMX + select IMX6UL_LCDIF select IMX_FEC select IMX_I2C select IMX_USBPHYhw/arm/fsl-imx6ul.c +10
-2@@ -19,6 +19,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/arm/fsl-imx6ul.h" +#include "hw/display/imx6ul_lcdif.h" #include "hw/misc/unimp.h" #include "hw/usb/imx-usb-phy.h" #include "hw/core/boards.h" @@ -136,6 +137,11 @@ static void fsl_imx6ul_init(Object *obj)object_initialize_child (obj, name, &s->usb[i],TYPE_CHIPIDEA ); } +/* +* LCDIF +*/ +object_initialize_child (obj,"lcdif" , &s->lcdif,TYPE_IMX6UL_LCDIF ); +/* * SDHCIs */ @@ -656,8 +662,10 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)/* * LCD */ -create_unimplemented_device ("lcdif" ,FSL_IMX6UL_LCDIF_ADDR , -FSL_IMX6UL_LCDIF_SIZE ); +sysbus_realize (SYS_BUS_DEVICE (&s->lcdif), &error_abort); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->lcdif),0 ,FSL_IMX6UL_LCDIF_ADDR ); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->lcdif),0 , +qdev_get_gpio_in (gic,FSL_IMX6UL_LCDIF_IRQ ));/* * CSU include/hw/arm/fsl-imx6ul.h +2
-0@@ -33,6 +33,7 @@#include "hw/net/imx_fec.h" #include "hw/usb/chipidea.h" #include "hw/usb/imx-usb-phy.h" +#include "hw/display/imx6ul_lcdif.h" #include "system/memory.h" #include "cpu.h" #include "qom/object.h" @@ -84,6 +85,7 @@ struct FslIMX6ULState {IMX2WdtState wdt[FSL_IMX6UL_NUM_WDTS ];IMXUSBPHYState usbphy[FSL_IMX6UL_NUM_USB_PHYS ];ChipideaState usb[FSL_IMX6UL_NUM_USBS ]; +IMX6ULLCDIFState lcdif;MemoryRegion rom;MemoryRegion caam;MemoryRegion ocram;
include/hw/arm/fsl-imx6ul.h enum FslIMX6ULMemoryMap { · line 148
Quoted 5 lines
include/hw/arm/fsl-imx6ul.h +1
-1@@ -143,7 +145,7 @@ enum FslIMX6ULMemoryMap {FSL_IMX6UL_PXP_SIZE = (16 * KiB),FSL_IMX6UL_LCDIF_ADDR =0x021C8000 , - FSL_IMX6UL_LCDIF_SIZE = 0x100, + FSL_IMX6UL_LCDIF_SIZE = 0x1000,
Are you sure this (4K) is right? The IMX6ULRM reference manual I have says the LCDIF block is 16K, so SIZE should be (16 * KiB).
Otherwise this patch looks good.
include/hw/arm/fsl-imx6ul.h enum FslIMX6ULMemoryMap {
Quoted 4 lines
include/hw/arm/fsl-imx6ul.h +0
-1FSL_IMX6UL_CSI_ADDR =0x021C4000 , FSL_IMX6UL_CSI_SIZE = 0x100, --
thanks
-- PMM