Signed-off-by: Luc Verhaegen <l...@skynet.be> --- arch/arm/include/asm/arch-sunxi/sunxi_display.h | 21 ++++++++ board/sunxi/board.c | 14 +++++ drivers/video/sunxi_display.c | 61 +++++++++++++++++++++++ include/configs/sunxi-common.h | 8 +++ 4 files changed, 104 insertions(+), 0 deletions(-) create mode 100644 arch/arm/include/asm/arch-sunxi/sunxi_display.h
diff --git a/arch/arm/include/asm/arch-sunxi/sunxi_display.h b/arch/arm/include/asm/arch-sunxi/sunxi_display.h new file mode 100644 index 0000000..4456778 --- /dev/null +++ b/arch/arm/include/asm/arch-sunxi/sunxi_display.h @@ -0,0 +1,21 @@ +/* + * (C) Copyright 2014 Luc Verhaegen <l...@skynet.be> + * + * 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's version 2 and any + * later version the License. + * + * 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. + */ +#ifndef _SUNXI_DISPLAY_H_ +#define _SUNXI_DISPLAY_H_ + +#ifdef CONFIG_VIDEO_DT_SIMPLEFB +void sunxi_simplefb_setup(void *blob); +#endif + +#endif /* _SUNXI_DISPLAY_H_ */ diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 0f37d8d..1a5247e 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -29,6 +29,10 @@ #include <asm/io.h> #include <net.h> +#ifdef CONFIG_VIDEO +#include <asm/arch-sunxi/sunxi_display.h> +#endif + DECLARE_GLOBAL_DATA_PTR; /* add board specific code here */ @@ -237,3 +241,13 @@ int misc_init_r(void) return 0; } #endif + +#ifdef CONFIG_OF_BOARD_SETUP +void +ft_board_setup(void *blob, bd_t *bd) +{ +#ifdef CONFIG_VIDEO_DT_SIMPLEFB + sunxi_simplefb_setup(blob); +#endif +} +#endif /* CONFIG_OF_BOARD_SETUP */ diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c index ef0cd6e..d5bc88e 100644 --- a/drivers/video/sunxi_display.c +++ b/drivers/video/sunxi_display.c @@ -30,6 +30,12 @@ #include <asm/global_data.h> #include <video_fb.h> #include <linux/fb.h> +#include <asm/arch-sunxi/sunxi_display.h> + +/* for simplefb */ +#ifdef CONFIG_OF_BOARD_SETUP +#include <libfdt.h> +#endif DECLARE_GLOBAL_DATA_PTR; @@ -579,3 +585,58 @@ video_hw_init(void) return graphic_device; } + +/* + * Simplefb support. + */ +#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_VIDEO_DT_SIMPLEFB) +void +sunxi_simplefb_setup(void *blob) +{ + static GraphicDevice *graphic_device = sunxi_display->graphic_device; + const char *name = "simple-framebuffer"; + const char *format = "x8r8g8b8"; + fdt32_t cells[2]; + int offset, stride, ret; + + if (!sunxi_display->enabled) + return; + + offset = fdt_add_subnode(blob, 0, "framebuffer"); + if (offset < 0) { + printf("%s: add subnode failed", __func__); + return; + } + + ret = fdt_setprop(blob, offset, "compatible", name, strlen(name) + 1); + if (ret < 0) + return; + + stride = graphic_device->winSizeX * graphic_device->gdfBytesPP; + + cells[0] = cpu_to_fdt32(gd->fb_base); + cells[1] = cpu_to_fdt32(CONFIG_SUNXI_FB_SIZE); + ret = fdt_setprop(blob, offset, "reg", cells, sizeof(cells[0]) * 2); + if (ret < 0) + return; + + cells[0] = cpu_to_fdt32(graphic_device->winSizeX); + ret = fdt_setprop(blob, offset, "width", cells, sizeof(cells[0])); + if (ret < 0) + return; + + cells[0] = cpu_to_fdt32(graphic_device->winSizeY); + ret = fdt_setprop(blob, offset, "height", cells, sizeof(cells[0])); + if (ret < 0) + return; + + cells[0] = cpu_to_fdt32(stride); + ret = fdt_setprop(blob, offset, "stride", cells, sizeof(cells[0])); + if (ret < 0) + return; + + ret = fdt_setprop(blob, offset, "format", format, strlen(format) + 1); + if (ret < 0) + return; +} +#endif /* CONFIG_OF_BOARD_SETUP && CONFIG_VIDEO_DT_SIMPLEFB */ diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index c8a8777..81f893c 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -398,6 +398,9 @@ */ #define CONFIG_SUNXI_FB_SIZE (8 << 20) +/* Do we want to initialize a simple FB? */ +#define CONFIG_VIDEO_DT_SIMPLEFB + #define CONFIG_VIDEO_SUNXI #define CONFIG_CFB_CONSOLE @@ -410,6 +413,11 @@ #define CONFIG_SYS_MEM_TOP_HIDE ((CONFIG_SUNXI_FB_SIZE + 0xFFF) & ~0xFFF) +/* To be able to hook simplefb into dt */ +#ifdef CONFIG_VIDEO_DT_SIMPLEFB +#define CONFIG_OF_BOARD_SETUP +#endif + #endif /* CONFIG_VIDEO */ /* Ethernet support */ -- 1.7.7 -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.