]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - cpu/mpc8260/commproc.c
rename CFG_ macros to CONFIG_SYS
[people/ms/u-boot.git] / cpu / mpc8260 / commproc.c
index dcbffc4412a46a8a42c03be8ef0f259e305b6750..94f6bc224fdab8403998163ddc8a4fdfd096d30b 100644 (file)
 #include <common.h>
 #include <asm/cpm_8260.h>
 
-/*
- * because we have stack and init data in dual port ram
- * we must reduce the size
- */
-#undef CPM_DATAONLY_SIZE
-#define CPM_DATAONLY_SIZE      ((uint)(8 * 1024) - CPM_DATAONLY_BASE)
+DECLARE_GLOBAL_DATA_PTR;
 
 void
 m8260_cpm_reset(void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
-       volatile immap_t *immr = (immap_t *)CFG_IMMR;
+       volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
        volatile ulong count;
 
        /* Reclaim the DP memory for our use.
@@ -61,9 +54,7 @@ m8260_cpm_reset(void)
 uint
 m8260_cpm_dpalloc(uint size, uint align)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
-       volatile immap_t *immr = (immap_t *)CFG_IMMR;
+       volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
        uint    retloc;
        uint    align_mask, off;
        uint    savebase;
@@ -111,21 +102,20 @@ m8260_cpm_hostalloc(uint size, uint align)
  * to port numbers).  Documentation uses 1-based numbering.
  */
 #define BRG_INT_CLK    gd->brg_clk
-#define BRG_UART_CLK   ((BRG_INT_CLK + 15) / 16)
+#define BRG_UART_CLK   (BRG_INT_CLK / 16)
 
-/* This function is used by UARTS, or anything else that uses a 16x
+/* This function is used by UARTs, or anything else that uses a 16x
  * oversampled clock.
  */
 void
 m8260_cpm_setbrg(uint brg, uint rate)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
-       volatile immap_t *immr = (immap_t *)CFG_IMMR;
+       volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
        volatile uint   *bp;
+       uint cd = BRG_UART_CLK / rate;
 
-       /* This is good enough to get SMCs running.....
-       */
+       if ((BRG_UART_CLK % rate) < (rate / 2))
+               cd--;
        if (brg < 4) {
                bp = (uint *)&immr->im_brgc1;
        }
@@ -134,7 +124,7 @@ m8260_cpm_setbrg(uint brg, uint rate)
                brg -= 4;
        }
        bp += brg;
-       *bp = (((((BRG_UART_CLK+rate-1)/rate)-1)&0xfff)<<1)|CPM_BRG_EN;
+       *bp = (cd << 1) | CPM_BRG_EN;
 }
 
 /* This function is used to set high speed synchronous baud rate
@@ -143,9 +133,7 @@ m8260_cpm_setbrg(uint brg, uint rate)
 void
 m8260_cpm_fastbrg(uint brg, uint rate, int div16)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
-       volatile immap_t *immr = (immap_t *)CFG_IMMR;
+       volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
        volatile uint   *bp;
 
        /* This is good enough to get SMCs running.....
@@ -170,7 +158,7 @@ m8260_cpm_fastbrg(uint brg, uint rate, int div16)
 void
 m8260_cpm_extcbrg(uint brg, uint rate, uint extclk, int pinsel)
 {
-       volatile immap_t *immr = (immap_t *)CFG_IMMR;
+       volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
        volatile uint   *bp;
 
        if (brg < 4) {
@@ -188,12 +176,12 @@ m8260_cpm_extcbrg(uint brg, uint rate, uint extclk, int pinsel)
                *bp |= CPM_BRG_EXTC_CLK5_15;
 }
 
-#ifdef CONFIG_POST
+#if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER)
 
 void post_word_store (ulong a)
 {
        volatile ulong *save_addr =
-               (volatile ulong *)(CFG_IMMR + CPM_POST_WORD_ADDR);
+               (volatile ulong *)(CONFIG_SYS_IMMR + CPM_POST_WORD_ADDR);
 
        *save_addr = a;
 }
@@ -201,9 +189,33 @@ void post_word_store (ulong a)
 ulong post_word_load (void)
 {
        volatile ulong *save_addr =
-               (volatile ulong *)(CFG_IMMR + CPM_POST_WORD_ADDR);
+               (volatile ulong *)(CONFIG_SYS_IMMR + CPM_POST_WORD_ADDR);
 
        return *save_addr;
 }
 
-#endif /* CONFIG_POST */
+#endif /* CONFIG_POST || CONFIG_LOGBUFFER*/
+
+#ifdef CONFIG_BOOTCOUNT_LIMIT
+
+void bootcount_store (ulong a)
+{
+       volatile ulong *save_addr =
+               (volatile ulong *)(CONFIG_SYS_IMMR + CPM_BOOTCOUNT_ADDR);
+
+       save_addr[0] = a;
+       save_addr[1] = BOOTCOUNT_MAGIC;
+}
+
+ulong bootcount_load (void)
+{
+       volatile ulong *save_addr =
+               (volatile ulong *)(CONFIG_SYS_IMMR + CPM_BOOTCOUNT_ADDR);
+
+       if (save_addr[1] != BOOTCOUNT_MAGIC)
+               return 0;
+       else
+               return save_addr[0];
+}
+
+#endif /* CONFIG_BOOTCOUNT_LIMIT */