Merge branch 'master' of git://git.denx.de/u-boot into resolve
[oweals/u-boot.git] / board / freescale / p1_p2_rdb / p1_p2_rdb.c
index d4b4b6811b1a86b04acfe4bb9f241ef646c2313d..437eaf0fdd6e0852aa791855abdebf8c138137df 100644 (file)
 #include <miiphy.h>
 #include <libfdt.h>
 #include <fdt_support.h>
+#include <fsl_mdio.h>
 #include <tsec.h>
 #include <vsc7385.h>
 #include <netdev.h>
 #include <rtc.h>
 #include <i2c.h>
+#include <hwconfig.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -46,6 +48,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define RGMII_PHY_RST_SET      0x02000000
 
 #define USB_RST_CLR            0x04000000
+#define USB2_PORT_OUT_EN        0x01000000
 
 #define GPIO_DIR               0x060f0000
 
@@ -107,6 +110,7 @@ int checkboard (void)
 
        cpu = gd->cpu;
        printf ("Board: %sRDB Rev%c\n", cpu->name, board_rev);
+
        setbits_be32(&pgpio->gpdir, GPIO_DIR);
 
 /*
@@ -124,6 +128,19 @@ int checkboard (void)
        return 0;
 }
 
+int misc_init_r(void)
+{
+#if defined(CONFIG_SDCARD) || defined(CONFIG_SPIFLASH)
+       ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
+       ccsr_gpio_t *gpio = (void *)CONFIG_SYS_MPC85xx_GPIO_ADDR;
+
+       setbits_be32(&gpio->gpdir, USB2_PORT_OUT_EN);
+       setbits_be32(&gpio->gpdat, USB2_PORT_OUT_EN);
+       setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_ELBC_OFF_USB2_ON);
+#endif
+       return 0;
+}
+
 int board_early_init_r(void)
 {
        const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
@@ -176,6 +193,7 @@ int board_early_init_r(void)
 #ifdef CONFIG_TSEC_ENET
 int board_eth_init(bd_t *bis)
 {
+       struct fsl_pq_mdio_info mdio_info;
        struct tsec_info_struct tsec_info[4];
        int num = 0;
        char *tmp;
@@ -213,6 +231,10 @@ int board_eth_init(bd_t *bis)
                puts("No address specified for VSC7385 microcode.\n");
 #endif
 
+       mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
+       mdio_info.name = DEFAULT_MII_NAME;
+       fsl_pq_mdio_init(bis, &mdio_info);
+
        tsec_eth_init(bis, tsec_info, num);
 
        return pci_eth_init(bis);
@@ -224,6 +246,8 @@ extern void ft_pci_board_setup(void *blob);
 
 void ft_board_setup(void *blob, bd_t *bd)
 {
+       const char *soc_usb_compat = "fsl-usb2-dr";
+       int err, usb1_off, usb2_off;
        phys_addr_t base;
        phys_size_t size;
 
@@ -237,5 +261,51 @@ void ft_board_setup(void *blob, bd_t *bd)
 #endif /* #if defined(CONFIG_PCI) */
 
        fdt_fixup_memory(blob, (u64)base, (u64)size);
+
+#if defined(CONFIG_HAS_FSL_DR_USB)
+       fdt_fixup_dr_usb(blob, bd);
+#endif
+
+#if defined(CONFIG_SDCARD) || defined(CONFIG_SPIFLASH)
+       /* Delete eLBC node as it is muxed with USB2 controller */
+       if (hwconfig("usb2")) {
+               const char *soc_elbc_compat = "fsl,p1020-elbc";
+               int off = fdt_node_offset_by_compatible(blob, -1,
+                       soc_elbc_compat);
+               if (off < 0) {
+                       printf("WARNING: could not find compatible node"
+                               " %s: %s.\n", soc_elbc_compat,
+                               fdt_strerror(off));
+                               return;
+               }
+               err = fdt_del_node(blob, off);
+               if (err < 0) {
+                       printf("WARNING: could not remove %s: %s.\n",
+                               soc_elbc_compat, fdt_strerror(err));
+               }
+               return;
+       }
+#endif
+       /* Delete USB2 node as it is muxed with eLBC */
+       usb1_off = fdt_node_offset_by_compatible(blob, -1,
+               soc_usb_compat);
+       if (usb1_off < 0) {
+               printf("WARNING: could not find compatible node"
+                       " %s: %s.\n", soc_usb_compat,
+                       fdt_strerror(usb1_off));
+               return;
+       }
+       usb2_off = fdt_node_offset_by_compatible(blob, usb1_off,
+                       soc_usb_compat);
+       if (usb2_off < 0) {
+               printf("WARNING: could not find compatible node"
+                       " %s: %s.\n", soc_usb_compat,
+                       fdt_strerror(usb2_off));
+               return;
+       }
+       err = fdt_del_node(blob, usb2_off);
+       if (err < 0)
+               printf("WARNING: could not remove %s: %s.\n",
+                       soc_usb_compat, fdt_strerror(err));
 }
 #endif