xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Tim Deegan <tim@xen.org>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: xen-devel@lists.xensource.com, Ian.Campbell@citrix.com
Subject: Re: [PATCH 6/6] xen/arm: introduce a driver for the ARM HDLCD controller
Date: Thu, 6 Dec 2012 12:53:26 +0000	[thread overview]
Message-ID: <20121206125326.GP82725@ocelot.phlegethon.org> (raw)
In-Reply-To: <1354731588-32579-6-git-send-email-stefano.stabellini@eu.citrix.com>

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@eu.citrix.com>
> ---
>  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@eu.citrix.com>
> + * 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.

> +    set_fixmap(FIXMAP_MISC, hdlcd_start >> PAGE_SHIFT, DEV_SHARED);
> +    HDLCD[HDLCD_COMMAND] = 0;
> +
> +    HDLCD[HDLCD_LINELENGTH] = XRES * BPP;
> +    HDLCD[HDLCD_LINECOUNT] = YRES - 1;
> +    HDLCD[HDLCD_LINEPITCH] = XRES * BPP;
> +    HDLCD[HDLCD_PF] = ((BPP - 1) << 3);
> +    HDLCD[HDLCD_INTMASK] = 0;
> +    HDLCD[HDLCD_FBBASE] = framebuffer_start;
> +    HDLCD[HDLCD_BUS] = 0xf00|(1<<4);
> +    HDLCD[HDLCD_VBACK] = upper_margin - 1;
> +    HDLCD[HDLCD_VSYNC] = vsync_len - 1;
> +    HDLCD[HDLCD_VDATA] = YRES - 1;
> +    HDLCD[HDLCD_VFRONT] = lower_margin - 1;
> +    HDLCD[HDLCD_HBACK] = left_margin - 1;
> +    HDLCD[HDLCD_HSYNC] = hsync_len - 1;
> +    HDLCD[HDLCD_HDATA] = XRES - 1;
> +    HDLCD[HDLCD_HFRONT] = right_margin - 1;
> +    HDLCD[HDLCD_POLARITIES] = (1<<2)|(1<<3);
> +    HDLCD[HDLCD_RED] = (8<<8)|0;
> +    HDLCD[HDLCD_GREEN] = (8<<8)|8;
> +    HDLCD[HDLCD_BLUE] = (8<<8)|16;
> +
> +    HDLCD[HDLCD_COMMAND] = 1;
> +    clear_fixmap(FIXMAP_MISC);
> +
> +    fbp.lfb = lfb;
> +    fbp.font = &font_vga_8x16;
> +    fbp.pixel_on = 0xffffff;
> +    fbp.bits_per_pixel = BPP*8;
> +    fbp.bytes_per_line = BPP*XRES;
> +    fbp.width = XRES;
> +    fbp.height = YRES;
> +    fbp.flush = hdlcd_flush;
> +    fbp.text_columns = XRES / 8;
> +    fbp.text_rows = YRES / 16;
> +    if ( fb_init(fbp) < 0 )
> +            return;
> +    video_puts = fb_scroll_puts;
> +}
> +
> +void video_endboot(void)
> +{
> +    if ( video_puts != vga_noop_puts )
> +        fb_alloc();
> +}
> diff --git a/xen/include/asm-arm/config.h b/xen/include/asm-arm/config.h
> index 2a05539..9727562 100644
> --- a/xen/include/asm-arm/config.h
> +++ b/xen/include/asm-arm/config.h
> @@ -19,6 +19,8 @@
>  
>  #define CONFIG_DOMAIN_PAGE 1
>  
> +#define CONFIG_VIDEO 1
> +
>  #define OPT_CONSOLE_STR "com1"
>  
>  #ifdef MAX_PHYS_CPUS
> @@ -73,6 +75,7 @@
>  #define FIXMAP_ADDR(n)        (mk_unsigned_long(0x00400000) + (n) * PAGE_SIZE)
>  #define BOOT_MISC_VIRT_START   mk_unsigned_long(0x00600000)
>  #define FRAMETABLE_VIRT_START  mk_unsigned_long(0x02000000)
> +#define VRAM_VIRT_START        mk_unsigned_long(0x10000000)

Please update the comments above to reflect this change.

Cheers,

Tim.

>  #define XENHEAP_VIRT_START     mk_unsigned_long(0x40000000)
>  #define DOMHEAP_VIRT_START     mk_unsigned_long(0x80000000)
>  
> -- 
> 1.7.2.5
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel

  parent reply	other threads:[~2012-12-06 12:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-05 18:19 [PATCH 0/6] xen: ARM HDLCD video driver Stefano Stabellini
2012-12-05 18:19 ` [PATCH 1/6] xen/arm: introduce map_phys_range Stefano Stabellini
2012-12-06  9:55   ` Ian Campbell
2012-12-06 16:06     ` Stefano Stabellini
2012-12-07  9:53       ` Ian Campbell
2012-12-06 12:44   ` Tim Deegan
2012-12-05 18:19 ` [PATCH 2/6] xen: infrastructure to have cross-platform video drivers Stefano Stabellini
2012-12-06  9:57   ` Ian Campbell
2012-12-06 11:25   ` Jan Beulich
2012-12-06 12:46   ` Tim Deegan
2012-12-05 18:19 ` [PATCH 3/6] xen: introduce a generic framebuffer driver Stefano Stabellini
2012-12-05 18:19 ` [PATCH 4/6] xen/vesa: use the new fb_* functions Stefano Stabellini
2012-12-06 11:28   ` Jan Beulich
2012-12-06 11:36     ` Ian Campbell
2012-12-06 15:39       ` Stefano Stabellini
2012-12-06 15:18     ` Stefano Stabellini
2012-12-05 18:19 ` [PATCH 5/6] xen/device_tree: introduce find_compatible_node Stefano Stabellini
2012-12-06 10:14   ` Ian Campbell
2012-12-06 12:55     ` Stefano Stabellini
2012-12-05 18:19 ` [PATCH 6/6] xen/arm: introduce a driver for the ARM HDLCD controller Stefano Stabellini
2012-12-06 10:28   ` Ian Campbell
2012-12-07 15:50     ` Stefano Stabellini
2012-12-06 12:53   ` Tim Deegan [this message]
2012-12-06 16:35     ` Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121206125326.GP82725@ocelot.phlegethon.org \
    --to=tim@xen.org \
    --cc=Ian.Campbell@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).