]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - board/motionpro/motionpro.c
Change initdram() return type to phys_size_t
[karo-tx-uboot.git] / board / motionpro / motionpro.c
index 1729ae74166f0478e796d36cf4cfa7cd58b1928f..3b340622266f5f2df8caf57e1cc2fdf69b114292 100644 (file)
 
 #include <common.h>
 #include <mpc5xxx.h>
-
-#if defined(CONFIG_OF_FLAT_TREE)
-#include <ft_build.h>
-#endif
+#include <miiphy.h>
+#include <libfdt.h>
 
 #if defined(CONFIG_STATUS_LED)
 #include <status_led.h>
@@ -82,11 +80,27 @@ int board_early_init_r(void)
 }
 
 
+/*
+ * Additional PHY intialization. After being reset in mpc5xxx_fec_init_phy(),
+ * PHY goes into FX mode.  To take it out of the FX mode and switch into
+ * desired TX operation, one needs to clear the FX_SEL bit of Mode Control
+ * Register.
+ */
+void reset_phy(void)
+{
+       unsigned short mode_control;
+
+       miiphy_read("FEC ETHERNET", CONFIG_PHY_ADDR, 0x15, &mode_control);
+       miiphy_write("FEC ETHERNET", CONFIG_PHY_ADDR, 0x15,
+                       mode_control & 0xfffe);
+       return;
+}
+
 #ifndef CFG_RAMBOOT
 /*
  * Helper function to initialize SDRAM controller.
  */
-static void sdram_start (int hi_addr)
+static void sdram_start(int hi_addr)
 {
        long hi_addr_bit = hi_addr ? 0x01000000 : 0;
 
@@ -118,12 +132,18 @@ static void sdram_start (int hi_addr)
 /*
  * Initalize SDRAM - configure SDRAM controller, detect memory size.
  */
-long int initdram (int board_type)
+phys_size_t initdram(int board_type)
 {
        ulong dramsize = 0;
 #ifndef CFG_RAMBOOT
        ulong test1, test2;
 
+       /* According to AN3221 (MPC5200B SDRAM Initialization and
+        * Configuration), the SDelay register must be written a value of
+        * 0x00000004 as the first step of the SDRAM contorller configuration.
+        */
+       *(vu_long *)MPC5XXX_SDRAM_SDELAY = 0x04;
+
        /* configure SDRAM start/end for detection */
        *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001e; /* 2G at 0x0 */
        *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x80000000; /* disabled */
@@ -148,11 +168,12 @@ long int initdram (int board_type)
                dramsize = 0;
 
        /* set SDRAM CS0 size according to the amount of RAM found */
-       if (dramsize > 0)
+       if (dramsize > 0) {
                *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 +
                        __builtin_ffs(dramsize >> 20) - 1;
-        else
+       } else {
                *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */
+       }
 
        /* let SDRAM CS1 start right after CS0 and disable it */
        *(vu_long *) MPC5XXX_SDRAM_CS1CFG = dramsize;
@@ -171,7 +192,7 @@ long int initdram (int board_type)
 }
 
 
-int checkboard (void)
+int checkboard(void)
 {
        uchar rev = *(vu_char *)CPLD_REV_REGISTER;
        printf("Board: Promess Motion-PRO board (CPLD rev. 0x%02x)\n", rev);
@@ -179,16 +200,16 @@ int checkboard (void)
 }
 
 
-#if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
+#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
 void ft_board_setup(void *blob, bd_t *bd)
 {
        ft_cpu_setup(blob, bd);
 }
-#endif /* defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) */
+#endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */
 
 
 #if defined(CONFIG_STATUS_LED)
-void __led_init (led_id_t regaddr, int state)
+void __led_init(led_id_t regaddr, int state)
 {
        *((vu_long *) regaddr) |= ENABLE_GPIO_OUT;
 
@@ -198,7 +219,7 @@ void __led_init (led_id_t regaddr, int state)
                *((vu_long *) regaddr) &= ~LED_ON;
 }
 
-void __led_set (led_id_t regaddr, int state)
+void __led_set(led_id_t regaddr, int state)
 {
        if (state == STATUS_LED_ON)
                *((vu_long *) regaddr) |= LED_ON;
@@ -206,7 +227,7 @@ void __led_set (led_id_t regaddr, int state)
                *((vu_long *) regaddr) &= ~LED_ON;
 }
 
-void __led_toggle (led_id_t regaddr)
+void __led_toggle(led_id_t regaddr)
 {
        *((vu_long *) regaddr) ^= LED_ON;
 }