]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/lwmon5/lwmon5.c
ppc4xx: Add matrix kbd support to lwmon5 board (440EPx based)
[karo-tx-uboot.git] / board / lwmon5 / lwmon5.c
index 69b45acac7e7bdc14fc4a2ef7bc0c9a979b85927..0958194ecaa4cb86c22021b029626e48469cd9dd 100644 (file)
  */
 
 #include <common.h>
-#include <asm/processor.h>
 #include <ppc440.h>
+#include <asm/processor.h>
 #include <asm/gpio.h>
+#include <asm/io.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 extern flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips   */
 
-ulong flash_get_size (ulong base, int banknum);
+ulong flash_get_size(ulong base, int banknum);
+int misc_init_r_kbd(void);
 
 int board_early_init_f(void)
 {
        u32 sdr0_pfc1, sdr0_pfc2;
        u32 reg;
 
-        /* PLB Write pipelining disabled. Denali Core workaround */
-       mtdcr(plb0_acr, 0xDE000000);
-       mtdcr(plb1_acr, 0xDE000000);
+       /* PLB Write pipelining disabled. Denali Core workaround */
+       mtdcr(plb0_acr, 0xDE000000);
+       mtdcr(plb1_acr, 0xDE000000);
 
        /*--------------------------------------------------------------------
         * Setup the interrupt controller polarities, triggers, etc.
@@ -44,16 +46,16 @@ int board_early_init_f(void)
        mtdcr(uic0sr, 0xffffffff);  /* clear all. if write with 1 then the status is cleared  */
        mtdcr(uic0er, 0x00000000);  /* disable all */
        mtdcr(uic0cr, 0x00000000);  /* we have not critical interrupts at the moment */
-       mtdcr(uic0pr, 0xfffff7ff);  /* Adjustment of the polarity */
-       mtdcr(uic0tr, 0x00000810);  /* per ref-board manual */
+       mtdcr(uic0pr, 0xFFBFF1EF);  /* Adjustment of the polarity */
+       mtdcr(uic0tr, 0x00000900);  /* per ref-board manual */
        mtdcr(uic0vr, 0x00000000);  /* int31 highest, base=0x000 is within DDRAM */
        mtdcr(uic0sr, 0xffffffff);  /* clear all */
 
        mtdcr(uic1sr, 0xffffffff);  /* clear all */
        mtdcr(uic1er, 0x00000000);  /* disable all */
        mtdcr(uic1cr, 0x00000000);  /* all non-critical */
-       mtdcr(uic1pr, 0xFFFFC7AD);  /* Adjustment of the polarity */
-       mtdcr(uic1tr, 0x0600384A);  /* per ref-board manual */
+       mtdcr(uic1pr, 0xFFFFC6A5);  /* Adjustment of the polarity */
+       mtdcr(uic1tr, 0x60000040);  /* per ref-board manual */
        mtdcr(uic1vr, 0x00000000);  /* int31 highest, base=0x000 is within DDRAM */
        mtdcr(uic1sr, 0xffffffff);  /* clear all */
 
@@ -61,9 +63,9 @@ int board_early_init_f(void)
        mtdcr(uic2er, 0x00000000);  /* disable all */
        mtdcr(uic2cr, 0x00000000);  /* all non-critical */
        mtdcr(uic2pr, 0x27C00000);  /* Adjustment of the polarity */
-       mtdcr(uic2tr, 0xDFC00000);  /* per ref-board manual */
+       mtdcr(uic2tr, 0x3C000000);  /* per ref-board manual */
        mtdcr(uic2vr, 0x00000000);  /* int31 highest, base=0x000 is within DDRAM */
-       mtdcr(uic2sr, 0xffffffff);  /* clear all. Why this??? */
+       mtdcr(uic2sr, 0xffffffff);  /* clear all */
 
        /* Trace Pins are disabled. SDR0_PFC0 Register */
        mtsdr(SDR0_PFC0, 0x0);
@@ -86,9 +88,9 @@ int board_early_init_f(void)
        mtsdr(SDR0_PFC4, 0x80000000);
 
        /* PCI arbiter disabled */
-        /* PCI Host Configuration disbaled */
+       /* PCI Host Configuration disbaled */
        mfsdr(sdr_pci0, reg);
-        reg = 0;
+       reg = 0;
        mtsdr(sdr_pci0, 0x00000000 | reg);
 
        gpio_write_bit(CFG_GPIO_FLASH_WP, 1);
@@ -157,13 +159,13 @@ int misc_init_r(void)
        (void)flash_protect(FLAG_PROTECT_SET,
                            -CFG_MONITOR_LEN,
                            0xffffffff,
-                           &flash_info[0]);
+                           &flash_info[1]);
 
        /* Env protection ON by default */
        (void)flash_protect(FLAG_PROTECT_SET,
                            CFG_ENV_ADDR_REDUND,
                            CFG_ENV_ADDR_REDUND + 2*CFG_ENV_SECT_SIZE - 1,
-                           &flash_info[0]);
+                           &flash_info[1]);
 
        /*
         * USB suff...
@@ -220,6 +222,13 @@ int misc_init_r(void)
        udelay(500);
        gpio_write_bit(CFG_GPIO_LIME_RST, 1);
 
+       /* Lime memory clock adjusted to 100MHz */
+       out_be32((void *)CFG_LIME_SDRAM_CLOCK, CFG_LIME_CLOCK_100MHZ);
+       /* Wait untill time expired. Because of requirements in lime manual */
+       udelay(300);
+       /* Write lime controller memory parameters */
+       out_be32((void *)CFG_LIME_MMR, CFG_LIME_MMR_VALUE);
+
        /*
         * Reset PHY's
         */
@@ -230,11 +239,67 @@ int misc_init_r(void)
        gpio_write_bit(CFG_GPIO_PHY1_RST, 1);
 
        /*
-        * Reset USB hub
+        * Init display controller
         */
-       gpio_write_bit(CFG_GPIO_HUB_RST, 0);
-       udelay(100);
-       gpio_write_bit(CFG_GPIO_HUB_RST, 1);
+       /* Setup dot clock (internal PLL, division rate 1/16) */
+       out_be32((void *)0xc1fd0100, 0x00000f00);
+
+       /* Lime L0 init (16 bpp, 640x480) */
+       out_be32((void *)0xc1fd0020, 0x801401df);
+       out_be32((void *)0xc1fd0024, 0x0);
+       out_be32((void *)0xc1fd0028, 0x0);
+       out_be32((void *)0xc1fd002c, 0x0);
+       out_be32((void *)0xc1fd0110, 0x0);
+       out_be32((void *)0xc1fd0114, 0x0);
+       out_be32((void *)0xc1fd0118, 0x01df0280);
+
+       /* Display timing init */
+       out_be32((void *)0xc1fd0004, 0x031f0000);
+       out_be32((void *)0xc1fd0008, 0x027f027f);
+       out_be32((void *)0xc1fd000c, 0x015f028f);
+       out_be32((void *)0xc1fd0010, 0x020c0000);
+       out_be32((void *)0xc1fd0014, 0x01df01ea);
+       out_be32((void *)0xc1fd0018, 0x0);
+       out_be32((void *)0xc1fd001c, 0x01e00280);
+
+#if 1
+       /*
+        * Clear framebuffer using Lime's drawing engine
+        * (draw blue rect. with white border around it)
+        */
+       /* Setup mode and fbbase, xres, fg, bg */
+       out_be32((void *)0xc1ff0420, 0x8300);
+       out_be32((void *)0xc1ff0440, 0x0000);
+       out_be32((void *)0xc1ff0444, 0x0280);
+       out_be32((void *)0xc1ff0480, 0x7fff);
+       out_be32((void *)0xc1ff0484, 0x0000);
+       /* Reset clipping rectangle */
+       out_be32((void *)0xc1ff0454, 0x0000);
+       out_be32((void *)0xc1ff0458, 0x0280);
+       out_be32((void *)0xc1ff045c, 0x0000);
+       out_be32((void *)0xc1ff0460, 0x01e0);
+       /* Draw white rect. */
+       out_be32((void *)0xc1ff04a0, 0x09410000);
+       out_be32((void *)0xc1ff04a0, 0x00000000);
+       out_be32((void *)0xc1ff04a0, 0x01e00280);
+       udelay(2000);
+       /* Draw blue rect. */
+       out_be32((void *)0xc1ff0480, 0x001f);
+       out_be32((void *)0xc1ff04a0, 0x09410000);
+       out_be32((void *)0xc1ff04a0, 0x00010001);
+       out_be32((void *)0xc1ff04a0, 0x01de027e);
+#endif
+       /* Display enable, L0 layer */
+       out_be32((void *)0xc1fd0100, 0x80010f00);
+
+       /* TFT-LCD enable - PWM duty, lamp on */
+       out_be32((void *)0xc4000024, 0x64);
+       out_be32((void *)0xc4000020, 0x701);
+
+       /*
+        * Init matrix keyboard
+        */
+       misc_init_r_kbd();
 
        return 0;
 }
@@ -304,7 +369,7 @@ int testdram(void)
  *     certain pre-initialization actions.
  *
  ************************************************************************/
-#if defined(CONFIG_PCI) && defined(CFG_PCI_PRE_INIT)
+#if defined(CONFIG_PCI)
 int pci_pre_init(struct pci_controller *hose)
 {
        unsigned long addr;
@@ -345,7 +410,7 @@ int pci_pre_init(struct pci_controller *hose)
 
        return 1;
 }
-#endif                         /* defined(CONFIG_PCI) && defined(CFG_PCI_PRE_INIT) */
+#endif /* defined(CONFIG_PCI) */
 
 /*************************************************************************
  *  pci_target_init