Merge branch 'master' of git://www.denx.de/git/u-boot-mips
[oweals/u-boot.git] / include / asm-ppc / 4xx_pcie.h
index 17ac57b23bcd6a014de9eeb88de75926875b12c6..4c03b050fef28d689f8fe4089cd983d76e8e2fb2 100644 (file)
 /*
  * UTL register offsets
  */
+#define        PEUTL_PBCTL             0x00
 #define PEUTL_PBBSZ            0x20
 #define PEUTL_OPDBSZ           0x68
 #define PEUTL_IPHBSZ           0x70
 #define PEUTL_OUTTR            0x90
 #define PEUTL_INTR             0x98
 #define PEUTL_PCTL             0xa0
+#define        PEUTL_RCSTA             0xb0
 #define PEUTL_RCIRQEN          0xb8
 
 /*
 #define PECFG_BAR0LMPA         0x210
 #define PECFG_BAR0HMPA         0x214
 #define PECFG_BAR1MPA          0x218
-#define PECFG_BAR2MPA          0x220
+#define PECFG_BAR2LMPA         0x220
+#define PECFG_BAR2HMPA         0x224
 
 #define PECFG_PIMEN            0x33c
 #define PECFG_PIM0LAL          0x340
 #define U64_TO_U32_LOW(val)    ((u32)((val) & 0x00000000ffffffffULL))
 #define U64_TO_U32_HIGH(val)   ((u32)((val) >> 32))
 
+/*
+ * Prototypes
+ */
 int ppc4xx_init_pcie(void);
 int ppc4xx_init_pcie_rootport(int port);
 int ppc4xx_init_pcie_endport(int port);
@@ -251,6 +257,59 @@ void ppc4xx_setup_pcie_rootpoint(struct pci_controller *hose, int port);
 int ppc4xx_setup_pcie_endpoint(struct pci_controller *hose, int port);
 int pcie_hose_scan(struct pci_controller *hose, int bus);
 
+/*
+ * Function to determine root port or endport from env variable.
+ */
+static inline int is_end_point(int port)
+{
+       char s[10], *tk;
+       char *pcie_mode = getenv("pcie_mode");
+
+       if (pcie_mode == NULL)
+               return 0;
+
+       strcpy(s, pcie_mode);
+       tk = strtok(s, ":");
+
+       switch (port) {
+       case 0:
+               if (tk != NULL) {
+                       if (!(strcmp(tk, "ep") && strcmp(tk, "EP")))
+                               return 1;
+                       else
+                               return 0;
+               }
+               else
+                       return 0;
+
+       case 1:
+               tk = strtok(NULL, ":");
+               if (tk != NULL) {
+                       if (!(strcmp(tk, "ep") && strcmp(tk, "EP")))
+                               return 1;
+                       else
+                               return 0;
+               }
+               else
+                       return 0;
+
+       case 2:
+               tk = strtok(NULL, ":");
+               if (tk != NULL)
+                       tk = strtok(NULL, ":");
+               if (tk != NULL) {
+                       if (!(strcmp(tk, "ep") && strcmp(tk, "EP")))
+                               return 1;
+                       else
+                               return 0;
+               }
+               else
+                       return 0;
+       }
+
+       return 0;
+}
+
 static inline void mdelay(int n)
 {
        u32 ms = n;