From: Anatolij Gustschin <agust@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] video: Add new driver for Silicon Motion SM501/SM502 Part 1/2
Date: Mon, 08 Dec 2008 14:03:14 +0100 [thread overview]
Message-ID: <493D1B12.8050506@denx.de> (raw)
In-Reply-To: <ghg782$ta5$1@ger.gmane.org>
Hello Stefan,
Stefan Althoefer wrote:
> Dear All,
>
>> Dear Anatolij & Stefan,
>>
>> In message <493AD29C.80409@denx.de> you wrote:
>>>> Use CONFIG_VIDEO_SM501NEW to enable the driver.
>>> not sure if CONFIG_VIDEO_SM501NEW is a good chose here. Maybe
>>> we should use s.th. like CONFIG_VIDEO_SM50x. This applies to
>>> the file names too: sm50x.h, sm50x.c, etc. Even better would
>>> be a merge with the existing driver.
>> I agree with Anatolij here. A merge would definitely be best.
>
> Before I start to implement the good suggestions, I'd like
> to know how such a merge would look like in your opinion.
see inlined patch below how it could be done without removing
old sm501 code. Defining CONFIG_VIDEO_SM501_PCI enables using
new sm501 driver code.
> Over the long term, I see the old driver vanishing, as it is too
> complicated to use (you need to be a video and SMI register
> expert). It is not much more than a jump into the board specific
> setup routines. However, removing the old driver would break half
> a dozen of boards (inacceptable).
we do not have to remove old code. Everyone who doesn't
additionally define CONFIG_VIDEO_SM501_PCI will be able to
use it. The advantage of the old code is that it is small.
This is fundamental design principle #1 of U-Boot:
http://www.denx.de/wiki/view/U-Boot/DesignPrinciples#1_Keep_it_Small
I agree that the old sm501 code is suboptimal and could be
improved.
diff --git a/drivers/video/sm501.c b/drivers/video/sm501.c
index 283d2d9..20a5335 100644
--- a/drivers/video/sm501.c
+++ b/drivers/video/sm501.c
@@ -33,30 +33,35 @@
#include <video_fb.h>
#include <sm501.h>
-
-#define read8(ptrReg) \
- *(volatile unsigned char *)(sm501.isaBase + ptrReg)
-
-#define write8(ptrReg,value) \
- *(volatile unsigned char *)(sm501.isaBase + ptrReg) = value
-
-#define read16(ptrReg) \
- (*(volatile unsigned short *)(sm501.isaBase + ptrReg))
-
-#define write16(ptrReg,value) \
- (*(volatile unsigned short *)(sm501.isaBase + ptrReg) = value)
-
-#define read32(ptrReg) \
- (*(volatile unsigned int *)(sm501.isaBase + ptrReg))
-
-#define write32(ptrReg, value) \
- (*(volatile unsigned int *)(sm501.isaBase + ptrReg) = value)
+#ifdef CONFIG_VIDEO_SM501_PCI
+#include <pci.h>
+#include "videomodes.h"
+#include "sm50x-regs.h"
+#include "sm50x.h"
+#endif
GraphicDevice sm501;
-/*-----------------------------------------------------------------------------
- * SmiSetRegs --
- *-----------------------------------------------------------------------------
+#ifdef CONFIG_VIDEO_SM501_PCI
+/*
+ * code used in sm501_pci_init()
+ * comes here.
+ */
+
+static int sm501_pci_init(void)
+{
+ GraphicDevice *pGD = (GraphicDevice *)&sm501;
+ /*
+ * Code to find the pci devide, setup video mode and
+ * init sm501 struct comes here.
+ * return 0 on success, non-zero otherwise.
+ * This is mainly the code you currently have
+ * in video_hw_init() in sm501new.c file.
+ */
+}
+#else
+/*
+ * SmiSetRegs
*/
static void SmiSetRegs (void)
{
@@ -66,7 +71,7 @@ static void SmiSetRegs (void)
*/
const SMI_REGS *preg = board_get_regs ();
while (preg->Index) {
- write32 (preg->Index, preg->Value);
+ writel (preg->Value, sm501.isaBase + preg->Index);
/*
* Insert a delay between
*/
@@ -74,10 +79,10 @@ static void SmiSetRegs (void)
preg ++;
}
}
+#endif
-/*-----------------------------------------------------------------------------
- * video_hw_init --
- *-----------------------------------------------------------------------------
+/*
+ * video_hw_init
*/
void *video_hw_init (void)
{
@@ -85,6 +90,7 @@ void *video_hw_init (void)
memset (&sm501, 0, sizeof (GraphicDevice));
+#ifndef CONFIG_VIDEO_SM501_PCI
/*
* Initialization of the access to the graphic chipset Retreive base
* address of the chipset (see board/RPXClassic/eccx.c)
@@ -122,6 +128,10 @@ void *video_hw_init (void)
/* (see board/RPXClassic/RPXClassic.c) */
board_validate_screen (sm501.isaBase);
+#else
+ if (!sm501_pci_init())
+ return 0;
+#endif /* CONFIG_VIDEO_SM501_PCI */
/* Clear video memory */
i = sm501.memSize/4;
@@ -132,9 +142,8 @@ void *video_hw_init (void)
return (&sm501);
}
-/*-----------------------------------------------------------------------------
- * video_set_lut --
- *-----------------------------------------------------------------------------
+/*
+ * video_set_lut
*/
void video_set_lut (
unsigned int index, /* color number */
--
Better suggestions are always welcome.
Best regards,
Anatolij
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
prev parent reply other threads:[~2008-12-08 13:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-04 21:10 [U-Boot] [PATCH] video: Add new driver for Silicon Motion SM501/SM502 Part 1/2 Stefan Althoefer
2008-12-06 19:29 ` Anatolij Gustschin
2008-12-06 22:35 ` Stefan Althoefer
2008-12-07 0:47 ` Wolfgang Denk
2008-12-07 6:33 ` ksi at koi8.net
2008-12-07 9:44 ` Wolfgang Denk
2008-12-07 18:19 ` ksi at koi8.net
2008-12-07 21:23 ` Wolfgang Denk
2008-12-07 22:21 ` ksi at koi8.net
2008-12-07 10:07 ` Stefan Althoefer
2008-12-08 13:03 ` Anatolij Gustschin [this message]
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=493D1B12.8050506@denx.de \
--to=agust@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