From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 01/12] video: Add S3C24xx framebuffer support
Date: Tue, 22 Jul 2014 02:34:42 +0200 [thread overview]
Message-ID: <1405989293-6629-1-git-send-email-marex@denx.de> (raw)
Add basic framebuffer driver for the S3C24xx family of CPUs.
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Anatolij Gustschin <agust@denx.de>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Cc: Minkyu Kang <mk7.kang@samsung.com>
Cc: Vladimir Zapolskiy <vz@mleia.com>
---
drivers/video/Makefile | 1 +
drivers/video/cfb_console.c | 2 +-
drivers/video/s3c-fb.c | 172 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 174 insertions(+), 1 deletion(-)
create mode 100644 drivers/video/s3c-fb.c
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 945f35d..7441783 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_VIDEO_MB86R0xGDC) += mb86r0xgdc.o videomodes.o
obj-$(CONFIG_VIDEO_MX3) += mx3fb.o videomodes.o
obj-$(CONFIG_VIDEO_IPUV3) += mxc_ipuv3_fb.o ipu_common.o ipu_disp.o
obj-$(CONFIG_VIDEO_MXS) += mxsfb.o videomodes.o
+obj-$(CONFIG_VIDEO_S3C) += s3c-fb.o videomodes.o
obj-$(CONFIG_VIDEO_OMAP3) += omap3_dss.o
obj-$(CONFIG_VIDEO_SANDBOX_SDL) += sandbox_sdl.o
obj-$(CONFIG_VIDEO_SED13806) += sed13806.o
diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index b52e9ed..4a56da8 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -135,7 +135,7 @@
#endif
#endif
-#ifdef CONFIG_VIDEO_MXS
+#if defined(CONFIG_VIDEO_MXS) || defined(CONFIG_VIDEO_S3C)
#define VIDEO_FB_16BPP_WORD_SWAP
#endif
diff --git a/drivers/video/s3c-fb.c b/drivers/video/s3c-fb.c
new file mode 100644
index 0000000..521eb75
--- /dev/null
+++ b/drivers/video/s3c-fb.c
@@ -0,0 +1,172 @@
+/*
+ * S3C24x0 LCD driver
+ *
+ * NOTE: Only 16/24 bpp operation with TFT LCD is supported.
+ *
+ * Copyright (C) 2014 Marek Vasut <marex@denx.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+#include <common.h>
+#include <malloc.h>
+#include <video_fb.h>
+
+#include <asm/errno.h>
+#include <asm/io.h>
+#include <asm/arch/s3c24x0_cpu.h>
+
+#include "videomodes.h"
+
+static GraphicDevice panel;
+
+/* S3C requires the FB to be 4MiB aligned. */
+#define S3CFB_ALIGN (4 << 20)
+
+#define S3CFB_LCDCON1_CLKVAL(x) ((x) << 8)
+#define S3CFB_LCDCON1_PNRMODE_TFT (0x3 << 5)
+#define S3CFB_LCDCON1_BPPMODE_TFT_16BPP (0xc << 1)
+#define S3CFB_LCDCON1_BPPMODE_TFT_24BPP (0xd << 1)
+
+#define S3CFB_LCDCON2_VBPD(x) ((x) << 24)
+#define S3CFB_LCDCON2_LINEVAL(x) ((x) << 14)
+#define S3CFB_LCDCON2_VFPD(x) ((x) << 6)
+#define S3CFB_LCDCON2_VSPW(x) ((x) << 0)
+
+#define S3CFB_LCDCON3_HBPD(x) ((x) << 19)
+#define S3CFB_LCDCON3_HOZVAL(x) ((x) << 8)
+#define S3CFB_LCDCON3_HFPD(x) ((x) << 0)
+
+#define S3CFB_LCDCON4_HSPW(x) ((x) << 0)
+
+#define S3CFB_LCDCON5_BPP24BL (1 << 12)
+#define S3CFB_LCDCON5_FRM565 (1 << 11)
+#define S3CFB_LCDCON5_HWSWP (1 << 0)
+
+#define PS2KHZ(ps) (1000000000UL / (ps))
+
+/*
+ * Example:
+ * setenv videomode video=ctfb:x:800,y:480,depth:16,mode:0,\
+ * pclk:30066,le:41,ri:89,up:45,lo:12,\
+ * hs:1,vs:1,sync:100663296,vmode:0
+ */
+static void s3c_lcd_init(GraphicDevice *panel,
+ struct ctfb_res_modes *mode, int bpp)
+{
+ uint32_t clk_divider;
+ struct s3c24x0_lcd *regs = s3c24x0_get_base_lcd();
+
+ /* Stop the controller. */
+ clrbits_le32(®s->lcdcon1, 1);
+
+ /* Calculate clock divider. */
+ clk_divider = (get_HCLK() / PS2KHZ(mode->pixclock)) / 1000;
+ clk_divider = DIV_ROUND_UP(clk_divider, 2);
+ if (clk_divider)
+ clk_divider -= 1;
+
+ /* Program LCD configuration. */
+ switch (bpp) {
+ case 16:
+ writel(S3CFB_LCDCON1_BPPMODE_TFT_16BPP |
+ S3CFB_LCDCON1_PNRMODE_TFT |
+ S3CFB_LCDCON1_CLKVAL(clk_divider),
+ ®s->lcdcon1);
+ writel(S3CFB_LCDCON5_HWSWP | S3CFB_LCDCON5_FRM565,
+ ®s->lcdcon5);
+ break;
+ case 24:
+ writel(S3CFB_LCDCON1_BPPMODE_TFT_24BPP |
+ S3CFB_LCDCON1_PNRMODE_TFT |
+ S3CFB_LCDCON1_CLKVAL(clk_divider),
+ ®s->lcdcon1);
+ writel(S3CFB_LCDCON5_BPP24BL, ®s->lcdcon5);
+ break;
+ }
+
+ writel(S3CFB_LCDCON2_LINEVAL(mode->yres - 1) |
+ S3CFB_LCDCON2_VBPD(mode->upper_margin - 1) |
+ S3CFB_LCDCON2_VFPD(mode->lower_margin - 1) |
+ S3CFB_LCDCON2_VSPW(mode->vsync_len - 1),
+ ®s->lcdcon2);
+
+ writel(S3CFB_LCDCON3_HBPD(mode->right_margin - 1) |
+ S3CFB_LCDCON3_HFPD(mode->left_margin - 1) |
+ S3CFB_LCDCON3_HOZVAL(mode->xres - 1),
+ ®s->lcdcon3);
+
+ writel(S3CFB_LCDCON4_HSPW(mode->hsync_len - 1),
+ ®s->lcdcon4);
+
+ /* Write FB address. */
+ writel(panel->frameAdrs >> 1, ®s->lcdsaddr1);
+ writel((panel->frameAdrs +
+ (mode->xres * mode->yres * panel->gdfBytesPP)) >> 1,
+ ®s->lcdsaddr2);
+ writel(mode->xres * bpp / 16, ®s->lcdsaddr3);
+
+ /* Start the controller. */
+ setbits_le32(®s->lcdcon1, 1);
+}
+
+void *video_hw_init(void)
+{
+ int bpp = -1;
+ char *penv;
+ void *fb;
+ struct ctfb_res_modes mode;
+
+ puts("Video: ");
+
+ /* Suck display configuration from "videomode" variable */
+ penv = getenv("videomode");
+ if (!penv) {
+ puts("S3CFB: 'videomode' variable not set!\n");
+ return NULL;
+ }
+
+ bpp = video_get_params(&mode, penv);
+
+ /* fill in Graphic device struct */
+ sprintf(panel.modeIdent, "%dx%dx%d", mode.xres, mode.yres, bpp);
+
+ panel.winSizeX = mode.xres;
+ panel.winSizeY = mode.yres;
+ panel.plnSizeX = mode.xres;
+ panel.plnSizeY = mode.yres;
+
+ switch (bpp) {
+ case 24:
+ panel.gdfBytesPP = 4;
+ panel.gdfIndex = GDF_32BIT_X888RGB;
+ break;
+ case 16:
+ panel.gdfBytesPP = 2;
+ panel.gdfIndex = GDF_16BIT_565RGB;
+ break;
+ default:
+ printf("S3CFB: Invalid BPP specified! (bpp = %i)\n", bpp);
+ return NULL;
+ }
+
+ panel.memSize = mode.xres * mode.yres * panel.gdfBytesPP;
+
+ /* Allocate framebuffer */
+ fb = memalign(S3CFB_ALIGN, roundup(panel.memSize, S3CFB_ALIGN));
+ if (!fb) {
+ printf("S3CFB: Error allocating framebuffer!\n");
+ return NULL;
+ }
+
+ /* Wipe framebuffer */
+ memset(fb, 0, panel.memSize);
+
+ panel.frameAdrs = (u32)fb;
+
+ printf("%s\n", panel.modeIdent);
+
+ /* Start framebuffer */
+ s3c_lcd_init(&panel, &mode, bpp);
+
+ return (void *)&panel;
+}
--
2.0.0.rc2
next reply other threads:[~2014-07-22 0:34 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-22 0:34 Marek Vasut [this message]
2014-07-22 0:34 ` [U-Boot] [PATCH 02/12] arm: s3c24xx: Fix incorrect CONFIG_SYS_S3C2410_NAND_HWECC name Marek Vasut
2014-07-22 0:34 ` [U-Boot] [PATCH 03/12] mtd: nand: s3c: Fix data type width in debug() Marek Vasut
2014-07-28 23:35 ` Scott Wood
2014-07-29 0:09 ` Marek Vasut
2014-07-29 0:12 ` Scott Wood
2014-07-29 1:11 ` Marek Vasut
2014-07-29 1:22 ` Scott Wood
2014-07-29 4:21 ` Marek Vasut
2014-07-22 0:34 ` [U-Boot] [PATCH 04/12] mtd: nand: s3c: Unify the register definition and naming Marek Vasut
2014-07-22 0:34 ` [U-Boot] [PATCH 05/12] mtd: nand: s3c: Add S3C2440 specifics Marek Vasut
2014-07-22 0:34 ` [U-Boot] [PATCH 06/12] mtd: nand: s3c: Add S3C2440 buffer reading Marek Vasut
2014-07-22 0:34 ` [U-Boot] [PATCH 07/12] mtd: nand: s3c: Add missing correction and select_chip functions Marek Vasut
2014-07-22 0:34 ` [U-Boot] [PATCH 08/12] i2c: s3c: Implant support for S3C2440 Marek Vasut
2014-07-22 0:34 ` [U-Boot] [PATCH 09/12] gpio: s3c: Fix the GPIO driver Marek Vasut
2014-07-22 0:34 ` [U-Boot] [PATCH 10/12] arm: s3c: Unify the S3C24xx SDI structure Marek Vasut
2014-07-22 0:34 ` [U-Boot] [PATCH 11/12] mmc: s3c: Add SD driver Marek Vasut
2014-08-01 16:25 ` Pantelis Antoniou
2014-08-01 16:26 ` Pantelis Antoniou
2014-07-22 0:34 ` [U-Boot] [PATCH 12/12] net: smc911x: Keep MAC programmed Marek Vasut
2014-07-22 20:43 ` Joe Hershberger
2014-07-22 9:25 ` [U-Boot] [PATCH 01/12] video: Add S3C24xx framebuffer support Wolfgang Denk
2014-07-23 3:00 ` Marek Vasut
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=1405989293-6629-1-git-send-email-marex@denx.de \
--to=marex@denx.de \
--cc=u-boot@lists.denx.de \
/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