[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 6/6] xen/arm: introduce a driver for the ARM HDLCD controller



On Thu, 6 Dec 2012, Tim Deegan wrote:
> At 18:19 +0000 on 05 Dec (1354731588), Stefano Stabellini wrote:
> > For the moment the resolution is hardcoded to 1280x1024@60.
> > Use the generic framebuffer functions to print on the screen.
> > 
> > Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
> > ---
> >  xen/arch/arm/Rules.mk         |    1 +
> >  xen/drivers/video/Makefile    |    1 +
> >  xen/drivers/video/arm_hdlcd.c |  165 
> > +++++++++++++++++++++++++++++++++++++++++
> >  xen/include/asm-arm/config.h  |    3 +
> >  4 files changed, 170 insertions(+), 0 deletions(-)
> >  create mode 100644 xen/drivers/video/arm_hdlcd.c
> > 
> > diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk
> > index fa9f9c1..9580e6b 100644
> > --- a/xen/arch/arm/Rules.mk
> > +++ b/xen/arch/arm/Rules.mk
> > @@ -8,6 +8,7 @@
> >  
> >  HAS_DEVICE_TREE := y
> >  HAS_VIDEO := y
> > +HAS_ARM_HDLCD := y
> >  
> >  CFLAGS += -fno-builtin -fno-common -Wredundant-decls
> >  CFLAGS += -iwithprefix include -Werror -Wno-pointer-arith -pipe
> > diff --git a/xen/drivers/video/Makefile b/xen/drivers/video/Makefile
> > index 3b3eb43..8a6f5da 100644
> > --- a/xen/drivers/video/Makefile
> > +++ b/xen/drivers/video/Makefile
> > @@ -4,3 +4,4 @@ obj-$(HAS_VIDEO) += font_8x16.o
> >  obj-$(HAS_VIDEO) += font_8x8.o
> >  obj-$(HAS_VIDEO) += fb.o
> >  obj-$(HAS_VGA) += vesa.o
> > +obj-$(HAS_ARM_HDLCD) += arm_hdlcd.o
> > diff --git a/xen/drivers/video/arm_hdlcd.c b/xen/drivers/video/arm_hdlcd.c
> > new file mode 100644
> > index 0000000..68f588c
> > --- /dev/null
> > +++ b/xen/drivers/video/arm_hdlcd.c
> > @@ -0,0 +1,165 @@
> > +/*
> > + * xen/drivers/video/arm_hdlcd.c
> > + *
> > + * Driver for ARM HDLCD Controller
> > + *
> > + * Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
> > + * Copyright (c) 2012 Citrix Systems.
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License as published by
> > + * the Free Software Foundation; either version 2 of the License, or
> > + * (at your option) any later version.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > + * GNU General Public License for more details.
> > + */
> > +
> > +#include <asm/delay.h>
> > +#include <asm/types.h>
> > +#include <xen/config.h>
> > +#include <xen/device_tree.h>
> > +#include <xen/libfdt/libfdt.h>
> > +#include <xen/init.h>
> > +#include <xen/mm.h>
> > +#include "font.h"
> > +#include "fb.h"
> > +
> > +#define HDLCD ((volatile uint32_t *) FIXMAP_ADDR(FIXMAP_MISC))
> > +
> > +#define HDLCD_INTMASK       (0x18/4)
> > +#define HDLCD_FBBASE        (0x100/4)
> > +#define HDLCD_LINELENGTH    (0x104/4)
> > +#define HDLCD_LINECOUNT     (0x108/4)
> > +#define HDLCD_LINEPITCH     (0x10C/4)
> > +#define HDLCD_BUS           (0x110/4)
> > +#define HDLCD_VSYNC         (0x200/4)
> > +#define HDLCD_VBACK         (0x204/4)
> > +#define HDLCD_VDATA         (0x208/4)
> > +#define HDLCD_VFRONT        (0x20C/4)
> > +#define HDLCD_HSYNC         (0x210/4)
> > +#define HDLCD_HBACK         (0x214/4)
> > +#define HDLCD_HDATA         (0x218/4)
> > +#define HDLCD_HFRONT        (0x21C/4)
> > +#define HDLCD_POLARITIES    (0x220/4)
> > +#define HDLCD_COMMAND       (0x230/4)
> > +#define HDLCD_PF            (0x240/4)
> > +#define HDLCD_RED           (0x244/4)
> > +#define HDLCD_GREEN         (0x248/4)
> > +#define HDLCD_BLUE          (0x24C/4)
> > +
> > +#define BPP             4
> > +#define XRES            1280
> > +#define YRES            1024
> > +#define refresh         60
> > +#define pixclock        108 /* in Mhz, needs to be set in the board config 
> > for OSC5 */
> > +#define left_margin     80
> > +#define hback left_margin
> > +#define right_margin    48
> > +#define hfront right_margin
> > +#define upper_margin    21
> > +#define vback upper_margin
> > +#define lower_margin    3
> > +#define vfront lower_margin
> > +#define hsync_len       32
> > +#define vsync_len       6
> > +
> > +#define HDLCD_SIZE (XRES*YRES*BPP)
> > +
> > +static void vga_noop_puts(const char *s) {}
> > +void (*video_puts)(const char *) = vga_noop_puts;
> > +
> > +static void hdlcd_flush(void)
> > +{
> > +    dsb();
> > +}
> > +
> > +void __init video_init(void)
> > +{
> > +    int node, depth;
> > +    u32 address_cells, size_cells;
> > +    struct fb_prop fbp;
> > +    unsigned char *lfb = (unsigned char *) VRAM_VIRT_START;
> > +    paddr_t hdlcd_start, hdlcd_size;
> > +    paddr_t framebuffer_start, framebuffer_size;
> > +    const struct fdt_property *prop;
> > +    const u32 *cell;
> > +
> > +    if ( find_compatible_node("arm,hdlcd", &node, &depth,
> > +                &address_cells, &size_cells) <= 0 )
> > +        return;
> > +
> > +    prop = fdt_get_property(device_tree_flattened, node, "reg", NULL);
> > +    if ( !prop )
> > +        return;
> > +
> > +    cell = (const u32 *)prop->data;
> > +    device_tree_get_reg(&cell, address_cells, size_cells,
> > +            &hdlcd_start, &hdlcd_size); 
> > +
> > +    prop = fdt_get_property(device_tree_flattened, node, "framebuffer", 
> > NULL);
> > +    if ( !prop )
> > +        return;
> > +
> > +    cell = (const u32 *)prop->data;
> > +    device_tree_get_reg(&cell, address_cells, size_cells,
> > +            &framebuffer_start, &framebuffer_size); 
> > +
> > +    if ( !hdlcd_start || !framebuffer_start )
> > +        return;
> > +
> > +    printk("Initializing HDLCD driver\n");
> > +
> > +    map_phys_range(framebuffer_start,
> > +                    framebuffer_start + framebuffer_size,
> > +                    VRAM_VIRT_START, DEV_WC);
> > +    memset(lfb, 0x00, HDLCD_SIZE);
> 
> This needs some checks that framebuffer_size >= HDLCD_SIZE, and that
> framebuffer_size <= XENHEAP_VIRT_START - VRAM_VIRT_START.

You are right, I'll add those checks.
I think I'll turn map_phys_range into early_ioremap and have
early_ioremap return NULL if the range passed as an argument is too
big.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.