Re: [U-Boot] [PATCH] p1022ds: allow for board-specific ngPIXIS functions

2011-01-17 Thread Wolfgang Denk
Dear Timur Tabi,

In message <1295304993-19369-1-git-send-email-ti...@freescale.com> you wrote:
> The ngPIXIS is an FPGA used on the reference boards of most Freescale PowerPC
> SOCs.  Although programming the ngPIXIS is mostly standard on all boards that
> have it, the P1022DS is unique in that the ngPIXIS needs to be programmed in
> "indirect" mode whenever the video display (DIU) is active.
> 
> To support indirect mode, and to make it easier to support other quirks on
> future reference boards, the low-level ngPIXIS functions are all marked as
> weak, so that board-specific code can override any of them.  We take advantage
> of this feature on the P1022DS, so that we can properly reset the board when
> the DIU is active.
> 
> Signed-off-by: Timur Tabi 
> ---
>  board/freescale/common/ngpixis.c |   54 
>  board/freescale/common/ngpixis.h |6 +++
>  board/freescale/p1022ds/diu.c|   64 -
>  3 files changed, 109 insertions(+), 15 deletions(-)

Just for the record: the merge window is closed, so this is "next"
stuff.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
How much net work could a network work, if a network could net work?
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] p1022ds: allow for board-specific ngPIXIS functions

2011-01-17 Thread Timur Tabi
The ngPIXIS is an FPGA used on the reference boards of most Freescale PowerPC
SOCs.  Although programming the ngPIXIS is mostly standard on all boards that
have it, the P1022DS is unique in that the ngPIXIS needs to be programmed in
"indirect" mode whenever the video display (DIU) is active.

To support indirect mode, and to make it easier to support other quirks on
future reference boards, the low-level ngPIXIS functions are all marked as
weak, so that board-specific code can override any of them.  We take advantage
of this feature on the P1022DS, so that we can properly reset the board when
the DIU is active.

Signed-off-by: Timur Tabi 
---
 board/freescale/common/ngpixis.c |   54 
 board/freescale/common/ngpixis.h |6 +++
 board/freescale/p1022ds/diu.c|   64 -
 3 files changed, 109 insertions(+), 15 deletions(-)

diff --git a/board/freescale/common/ngpixis.c b/board/freescale/common/ngpixis.c
index a135fbe..a432e33 100644
--- a/board/freescale/common/ngpixis.c
+++ b/board/freescale/common/ngpixis.c
@@ -35,61 +35,89 @@
 
 #include 
 #include 
-#include 
-#include 
 #include 
 
 #include "ngpixis.h"
 
+static u8 __pixis_read(unsigned int reg)
+{
+   void *p = (void *)PIXIS_BASE;
+
+   return in_8(p + reg);
+}
+u8 pixis_read(unsigned int reg) __attribute__((weak, alias("__pixis_read")));
+
+static void __pixis_write(unsigned int reg, u8 value)
+{
+   void *p = (void *)PIXIS_BASE;
+
+   out_8(p + reg, value);
+}
+void pixis_write(unsigned int reg, u8 value)
+   __attribute__((weak, alias("__pixis_write")));
+
 /*
  * Reset the board. This ignores the ENx registers.
  */
-void pixis_reset(void)
+void __pixis_reset(void)
 {
-   out_8(&pixis->rst, 0);
+   PIXIS_WRITE(rst, 0);
 
while (1);
 }
+void pixis_reset(void) __attribute__((weak, alias("__pixis_reset")));
 
 /*
  * Reset the board.  Like pixis_reset(), but it honors the ENx registers.
  */
-void pixis_bank_reset(void)
+void __pixis_bank_reset(void)
 {
-   out_8(&pixis->vctl, 0);
-   out_8(&pixis->vctl, 1);
+   PIXIS_WRITE(vctl, 0);
+   PIXIS_WRITE(vctl, 1);
 
while (1);
 }
+void pixis_bank_reset(void) __attribute__((weak, alias("__pixis_bank_reset")));
 
 /**
  * Set the boot bank to the power-on default bank
  */
-void clear_altbank(void)
+void __clear_altbank(void)
 {
+   u8 reg;
+
/* Tell the ngPIXIS to use this the bits in the physical switch for the
 * boot bank value, instead of the SWx register.  We need to be careful
 * only to set the bits in SWx that correspond to the boot bank.
 */
-   clrbits_8(&PIXIS_EN(PIXIS_LBMAP_SWITCH), PIXIS_LBMAP_MASK);
+   reg = PIXIS_READ(s[PIXIS_LBMAP_SWITCH - 1].en);
+   reg &= ~PIXIS_LBMAP_MASK;
+   PIXIS_WRITE(s[PIXIS_LBMAP_SWITCH - 1].en, reg);
 }
+void clear_altbank(void) __attribute__((weak, alias("__clear_altbank")));
 
 /**
  * Set the boot bank to the alternate bank
  */
-void set_altbank(void)
+void __set_altbank(void)
 {
+   u8 reg;
+
/* Program the alternate bank number into the SWx register.
 */
-   clrsetbits_8(&PIXIS_SW(PIXIS_LBMAP_SWITCH), PIXIS_LBMAP_MASK,
-PIXIS_LBMAP_ALTBANK);
+   reg = PIXIS_READ(s[PIXIS_LBMAP_SWITCH - 1].sw);
+   reg = (reg & ~PIXIS_LBMAP_MASK) | PIXIS_LBMAP_ALTBANK;
+   PIXIS_WRITE(s[PIXIS_LBMAP_SWITCH - 1].sw, reg);
 
/* Tell the ngPIXIS to use this the bits in the SWx register for the
 * boot bank value, instead of the physical switch.  We need to be
 * careful only to set the bits in SWx that correspond to the boot bank.
 */
-   setbits_8(&PIXIS_EN(PIXIS_LBMAP_SWITCH), PIXIS_LBMAP_MASK);
+   reg = PIXIS_READ(s[PIXIS_LBMAP_SWITCH - 1].en);
+   reg |= PIXIS_LBMAP_MASK;
+   PIXIS_WRITE(s[PIXIS_LBMAP_SWITCH - 1].en, reg);
 }
+void set_altbank(void) __attribute__((weak, alias("__set_altbank")));
 
 
 int pixis_reset_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
diff --git a/board/freescale/common/ngpixis.h b/board/freescale/common/ngpixis.h
index 089408b..8a7ddfa 100644
--- a/board/freescale/common/ngpixis.h
+++ b/board/freescale/common/ngpixis.h
@@ -55,3 +55,9 @@ typedef struct ngpixis {
 
 /* The PIXIS EN register that corresponds to board switch X, where x >= 1 */
 #define PIXIS_EN(x)(pixis->s[(x) - 1].en)
+
+u8 pixis_read(unsigned int reg);
+void pixis_write(unsigned int reg, u8 value);
+
+#define PIXIS_READ(reg) pixis_read(offsetof(ngpixis_t, reg))
+#define PIXIS_WRITE(reg, value) pixis_write(offsetof(ngpixis_t, reg), value)
diff --git a/board/freescale/p1022ds/diu.c b/board/freescale/p1022ds/diu.c
index 8f5305c..61679ac 100644
--- a/board/freescale/p1022ds/diu.c
+++ b/board/freescale/p1022ds/diu.c
@@ -139,8 +139,6 @@ int platform_diu_init(unsigned int *xres, unsigned int 
*yres)
return fsl_diu_init(*xres, pixel_format, 0);
 }
 
-#ifdef CONFIG_CFI_FLASH