]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
powerpc/85xx & 86xx: Rework ft_fsl_pci_setup to not require aliases
authorKumar Gala <galak@kernel.crashing.org>
Fri, 9 Jul 2010 03:37:44 +0000 (22:37 -0500)
committerKumar Gala <galak@kernel.crashing.org>
Tue, 20 Jul 2010 09:40:06 +0000 (04:40 -0500)
Previously we used an alias the pci node to determine which node to
fixup or delete.  Now we use the new fdt_node_offset_by_compat_reg to
find the node to update.

Additionally, we replace the code in each board with a single macro call
that makes assumes uniform naming and reduces duplication in this area.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
18 files changed:
arch/powerpc/include/asm/fsl_pci.h
board/atum8548/atum8548.c
board/freescale/mpc8536ds/mpc8536ds.c
board/freescale/mpc8544ds/mpc8544ds.c
board/freescale/mpc8548cds/mpc8548cds.c
board/freescale/mpc8568mds/mpc8568mds.c
board/freescale/mpc8569mds/mpc8569mds.c
board/freescale/mpc8572ds/mpc8572ds.c
board/freescale/mpc8610hpcd/mpc8610hpcd.c
board/freescale/mpc8641hpcn/mpc8641hpcn.c
board/freescale/p1022ds/p1022ds.c
board/freescale/p1_p2_rdb/pci.c
board/freescale/p2020ds/p2020ds.c
board/sbc8548/sbc8548.c
board/sbc8641d/sbc8641d.c
board/tqc/tqm85xx/tqm85xx.c
board/xes/common/fsl_8xxx_pci.c
drivers/pci/fsl_pci_init.c

index bb875435d33a1c15a55a6e597a74c5fd18c7fab1..dc5c579e1ae9cfccb60abc19cf44fa3b799ce722 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007,2009 Freescale Semiconductor, Inc.
+ * Copyright 2007,2009-2010 Freescale Semiconductor, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -29,8 +29,8 @@ int fsl_setup_hose(struct pci_controller *hose, unsigned long addr);
 int fsl_is_pci_agent(struct pci_controller *hose);
 void fsl_pci_init(struct pci_controller *hose, u32 cfg_addr, u32 cfg_data);
 void fsl_pci_config_unlock(struct pci_controller *hose);
-void ft_fsl_pci_setup(void *blob, const char *pci_alias,
-                       struct pci_controller *hose);
+void ft_fsl_pci_setup(void *blob, const char *pci_compat,
+                       struct pci_controller *hose, unsigned long ctrl_addr);
 
 /*
  * Common PCI/PCIE Register structure for mpc85xx and mpc86xx
@@ -202,4 +202,82 @@ int fsl_pci_init_port(struct fsl_pci_info *pci_info,
        x.pci_num = num; \
 }
 
+#define __FT_FSL_PCI_SETUP(blob, compat, num) \
+       ft_fsl_pci_setup(blob, compat, &pci##num##_hose, \
+                        CONFIG_SYS_PCI##num##_ADDR)
+
+#define __FT_FSL_PCI_DEL(blob, compat, num) \
+       ft_fsl_pci_setup(blob, compat, NULL, CONFIG_SYS_PCI##num##_ADDR)
+
+#define __FT_FSL_PCIE_SETUP(blob, compat, num) \
+       ft_fsl_pci_setup(blob, compat, &pcie##num##_hose, \
+                        CONFIG_SYS_PCIE##num##_ADDR)
+
+#define __FT_FSL_PCIE_DEL(blob, compat, num) \
+       ft_fsl_pci_setup(blob, compat, NULL, CONFIG_SYS_PCIE##num##_ADDR)
+
+#ifdef CONFIG_PCI1
+#define FT_FSL_PCI1_SETUP __FT_FSL_PCI_SETUP(blob, FSL_PCI_COMPAT, 1)
+#else
+#define FT_FSL_PCI1_SETUP __FT_FSL_PCI_DEL(blob, FSL_PCI_COMPAT, 1)
+#endif
+
+#ifdef CONFIG_PCI2
+#define FT_FSL_PCI2_SETUP __FT_FSL_PCI_SETUP(blob, FSL_PCI_COMPAT, 2)
+#else
+#define FT_FSL_PCI2_SETUP __FT_FSL_PCI_DEL(blob, FSL_PCI_COMPAT, 2)
+#endif
+
+#ifdef CONFIG_PCIE1
+#define FT_FSL_PCIE1_SETUP __FT_FSL_PCIE_SETUP(blob, FSL_PCIE_COMPAT, 1)
+#else
+#define FT_FSL_PCIE1_SETUP __FT_FSL_PCIE_DEL(blob, FSL_PCIE_COMPAT, 1)
+#endif
+
+#ifdef CONFIG_PCIE2
+#define FT_FSL_PCIE2_SETUP __FT_FSL_PCIE_SETUP(blob, FSL_PCIE_COMPAT, 2)
+#else
+#define FT_FSL_PCIE2_SETUP __FT_FSL_PCIE_DEL(blob, FSL_PCIE_COMPAT, 2)
+#endif
+
+#ifdef CONFIG_PCIE3
+#define FT_FSL_PCIE3_SETUP __FT_FSL_PCIE_SETUP(blob, FSL_PCIE_COMPAT, 3)
+#else
+#define FT_FSL_PCIE3_SETUP __FT_FSL_PCIE_DEL(blob, FSL_PCIE_COMPAT, 3)
+#endif
+
+#ifdef CONFIG_PCIE4
+#define FT_FSL_PCIE4_SETUP __FT_FSL_PCIE_SETUP(blob, FSL_PCIE_COMPAT, 4)
+#else
+#define FT_FSL_PCIE4_SETUP __FT_FSL_PCIE_DEL(blob, FSL_PCIE_COMPAT, 4)
+#endif
+
+#if defined(CONFIG_FSL_CORENET)
+#define FSL_PCIE_COMPAT        "fsl,p4080-pcie"
+#define FT_FSL_PCI_SETUP \
+       FT_FSL_PCIE1_SETUP; \
+       FT_FSL_PCIE2_SETUP; \
+       FT_FSL_PCIE3_SETUP; \
+       FT_FSL_PCIE4_SETUP;
+#elif defined(CONFIG_MPC85xx)
+#define FSL_PCI_COMPAT "fsl,mpc8540-pci"
+#define FSL_PCIE_COMPAT        "fsl,mpc8548-pcie"
+#define FT_FSL_PCI_SETUP \
+       FT_FSL_PCI1_SETUP; \
+       FT_FSL_PCI2_SETUP; \
+       FT_FSL_PCIE1_SETUP; \
+       FT_FSL_PCIE2_SETUP; \
+       FT_FSL_PCIE3_SETUP;
+#elif defined(CONFIG_MPC86xx)
+#define FSL_PCI_COMPAT "fsl,mpc8610-pci"
+#define FSL_PCIE_COMPAT        "fsl,mpc8641-pcie"
+#define FT_FSL_PCI_SETUP \
+       FT_FSL_PCI1_SETUP; \
+       FT_FSL_PCIE1_SETUP; \
+       FT_FSL_PCIE2_SETUP;
+#else
+#error FT_FSL_PCI_SETUP not defined
+#endif
+
+
 #endif
index 4f7d935df3d11de0c29c08049396b064cb7a6d78..671f9e985364ef2084bd465d1998fef569755987 100644 (file)
@@ -292,14 +292,6 @@ void ft_board_setup(void *blob, bd_t *bd)
 {
        ft_cpu_setup(blob, bd);
 
-#ifdef CONFIG_PCI1
-       ft_fsl_pci_setup(blob, "pci0", &pci1_hose);
-#endif
-#ifdef CONFIG_PCI2
-       ft_fsl_pci_setup(blob, "pci1", &pci2_hose);
-#endif
-#ifdef CONFIG_PCIE1
-       ft_fsl_pci_setup(blob, "pci2", &pcie1_hose);
-#endif
+       FT_FSL_PCI_SETUP;
 }
 #endif
index 50ca3cae9fcf65ebb064ec336c3e60bd0124b02a..c8e08563b6a749e25c99bc79e337325f7dc27ac6 100644 (file)
@@ -396,26 +396,8 @@ void ft_board_setup(void *blob, bd_t *bd)
 {
        ft_cpu_setup(blob, bd);
 
-#ifdef CONFIG_PCI1
-       ft_fsl_pci_setup(blob, "pci0", &pci1_hose);
-#else
-       ft_fsl_pci_setup(blob, "pci0", NULL);
-#endif
-#ifdef CONFIG_PCIE2
-       ft_fsl_pci_setup(blob, "pci1", &pcie2_hose);
-#else
-       ft_fsl_pci_setup(blob, "pci1", NULL);
-#endif
-#ifdef CONFIG_PCIE2
-       ft_fsl_pci_setup(blob, "pci2", &pcie1_hose);
-#else
-       ft_fsl_pci_setup(blob, "pci2", NULL);
-#endif
-#ifdef CONFIG_PCIE1
-       ft_fsl_pci_setup(blob, "pci3", &pcie3_hose);
-#else
-       ft_fsl_pci_setup(blob, "pci3", NULL);
-#endif
+       FT_FSL_PCI_SETUP;
+
 #ifdef CONFIG_FSL_SGMII_RISER
        fsl_sgmii_riser_fdt_fixup(blob);
 #endif
index 581d5f26edba8bd260f3b062fe405cccb55eeafd..da3a2b6eecda939b015cbe530650f829d405648f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007,2009 Freescale Semiconductor, Inc.
+ * Copyright 2007,2009-2010 Freescale Semiconductor, Inc.
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -360,19 +360,8 @@ void ft_board_setup(void *blob, bd_t *bd)
 {
        ft_cpu_setup(blob, bd);
 
+       FT_FSL_PCI_SETUP;
 
-#ifdef CONFIG_PCI1
-       ft_fsl_pci_setup(blob, "pci0", &pci1_hose);
-#endif
-#ifdef CONFIG_PCIE2
-       ft_fsl_pci_setup(blob, "pci1", &pcie1_hose);
-#endif
-#ifdef CONFIG_PCIE1
-       ft_fsl_pci_setup(blob, "pci2", &pcie3_hose);
-#endif
-#ifdef CONFIG_PCIE3
-       ft_fsl_pci_setup(blob, "pci3", &pcie2_hose);
-#endif
 #ifdef CONFIG_FSL_SGMII_RISER
        fsl_sgmii_riser_fdt_fixup(blob);
 #endif
index f0169959af407740732fca54c58b64eda69d556c..23e552bde7732e58d70f0bc1cc5a61d8a0630840 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004, 2007, 200 Freescale Semiconductor, Inc.
+ * Copyright 2004, 2007, 2009-2010 Freescale Semiconductor, Inc.
  *
  * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
  *
@@ -388,11 +388,6 @@ int last_stage_init(void)
 #if defined(CONFIG_OF_BOARD_SETUP)
 void ft_pci_setup(void *blob, bd_t *bd)
 {
-#ifdef CONFIG_PCI1
-       ft_fsl_pci_setup(blob, "pci0", &pci1_hose);
-#endif
-#ifdef CONFIG_PCIE1
-       ft_fsl_pci_setup(blob, "pci1", &pcie1_hose);
-#endif
+       FT_FSL_PCI_SETUP;
 }
 #endif
index 036bf9528b7202868f9fb3ff999d886398bb3c68..bd859e4ee4bcbf2ae32ff9290e445ca59a1ac6bf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007,2009 Freescale Semiconductor, Inc.
+ * Copyright 2007,2009-2010 Freescale Semiconductor, Inc.
  *
  * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
  *
@@ -426,11 +426,6 @@ void ft_board_setup(void *blob, bd_t *bd)
 {
        ft_cpu_setup(blob, bd);
 
-#ifdef CONFIG_PCI1
-       ft_fsl_pci_setup(blob, "pci0", &pci1_hose);
-#endif
-#ifdef CONFIG_PCIE1
-       ft_fsl_pci_setup(blob, "pci1", &pcie1_hose);
-#endif
+       FT_FSL_PCI_SETUP;
 }
 #endif
index 81e8ff51e9f7a0cd84c5fe0edaf097796d813aef..01b7dcb70cb142b2aab16a4e6dcbfe97f2c18cb0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009 Freescale Semiconductor.
+ * Copyright 2009-2010 Freescale Semiconductor.
  *
  * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
  *
@@ -635,9 +635,8 @@ void ft_board_setup(void *blob, bd_t *bd)
 #endif
        ft_cpu_setup(blob, bd);
 
-#ifdef CONFIG_PCIE1
-       ft_fsl_pci_setup(blob, "pci1", &pcie1_hose);
-#endif
+       FT_FSL_PCI_SETUP;
+
        fdt_board_fixup_esdhc(blob, bd);
        fdt_board_fixup_qe_uart(blob, bd);
        fdt_board_fixup_qe_usb(blob, bd);
index 81d481a1719a38f2f71ff672950cd9fa0ddf5e0a..6b96dfc16581ba48870a6c0e7c84055ac22f65ac 100644 (file)
@@ -345,15 +345,8 @@ void ft_board_setup(void *blob, bd_t *bd)
 
        fdt_fixup_memory(blob, (u64)base, (u64)size);
 
-#ifdef CONFIG_PCIE3
-       ft_fsl_pci_setup(blob, "pci0", &pcie3_hose);
-#endif
-#ifdef CONFIG_PCIE2
-       ft_fsl_pci_setup(blob, "pci1", &pcie2_hose);
-#endif
-#ifdef CONFIG_PCIE1
-       ft_fsl_pci_setup(blob, "pci2", &pcie1_hose);
-#endif
+       FT_FSL_PCI_SETUP;
+
 #ifdef CONFIG_FSL_SGMII_RISER
        fsl_sgmii_riser_fdt_fixup(blob);
 #endif
index 2ef7b2323da1cec2e51f0b6c0e459956aad28f85..6578f58dbfee1319afc49b2dd29889fd1da9a323 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007,2009 Freescale Semiconductor, Inc.
+ * Copyright 2007,2009-2010 Freescale Semiconductor, Inc.
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -309,15 +309,7 @@ ft_board_setup(void *blob, bd_t *bd)
 {
        ft_cpu_setup(blob, bd);
 
-#ifdef CONFIG_PCI1
-       ft_fsl_pci_setup(blob, "pci0", &pci1_hose);
-#endif
-#ifdef CONFIG_PCIE1
-       ft_fsl_pci_setup(blob, "pci1", &pcie1_hose);
-#endif
-#ifdef CONFIG_PCIE2
-       ft_fsl_pci_setup(blob, "pci2", &pcie2_hose);
-#endif
+       FT_FSL_PCI_SETUP;
 }
 #endif
 
index a88be5a0d6d14f89734a8016c3df759c59118131..d86ca12aaf17ff15c574b4f2a90bcf18345c92cd 100644 (file)
@@ -253,12 +253,7 @@ ft_board_setup(void *blob, bd_t *bd)
 
        ft_cpu_setup(blob, bd);
 
-#ifdef CONFIG_PCIE1
-       ft_fsl_pci_setup(blob, "pci0", &pcie1_hose);
-#endif
-#ifdef CONFIG_PCIE2
-       ft_fsl_pci_setup(blob, "pci1", &pcie2_hose);
-#endif
+       FT_FSL_PCI_SETUP;
 
        /*
         * Warn if it looks like the device tree doesn't match u-boot.
index be692cb4584d9d6001034bbe77c364ff952c6e94..5cdee9ff70f03cafbffd397f04c8e1ae909fd562 100644 (file)
@@ -322,23 +322,7 @@ void ft_board_setup(void *blob, bd_t *bd)
 
        fdt_fixup_memory(blob, (u64)base, (u64)size);
 
-#ifdef CONFIG_PCIE1
-       ft_fsl_pci_setup(blob, "pci0", &pcie1_hose);
-#else
-       ft_fsl_pci_setup(blob, "pci0", NULL);
-#endif
-
-#ifdef CONFIG_PCIE2
-       ft_fsl_pci_setup(blob, "pci1", &pcie2_hose);
-#else
-       ft_fsl_pci_setup(blob, "pci1", NULL);
-#endif
-
-#ifdef CONFIG_PCIE3
-       ft_fsl_pci_setup(blob, "pci2", &pcie3_hose);
-#else
-       ft_fsl_pci_setup(blob, "pci2", NULL);
-#endif
+       FT_FSL_PCI_SETUP;
 
 #ifdef CONFIG_FSL_SGMII_RISER
        fsl_sgmii_riser_fdt_fixup(blob);
index aa2f64ca9103f8f0abd6a5911f2f1a454f869274..97d4f834b08ed700de6c6418a6066fbce43b2b33 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009 Freescale Semiconductor, Inc.
+ * Copyright 2009-2010 Freescale Semiconductor, Inc.
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -100,16 +100,5 @@ void pci_init_board(void)
 
 void ft_pci_board_setup(void *blob)
 {
-/* According to h/w manual, PCIE2 is at lower address(0x9000)
- * than PCIE1(0xa000).
- * Hence PCIE2 is made to occupy the pci1 position in dts to
- * keep the addresses sorted there.
- * Generally the case with all FSL SOCs.
- */
-#ifdef CONFIG_PCIE2
-       ft_fsl_pci_setup(blob, "pci1", &pcie2_hose);
-#endif
-#ifdef CONFIG_PCIE1
-       ft_fsl_pci_setup(blob, "pci2", &pcie1_hose);
-#endif
+       FT_FSL_PCI_SETUP;
 }
index be4b2eb478b208cbba013d6dbd8460ab3e3fe684..3fd1b347abb61ffa59ef6e6ba8582bb4ce5939d8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007-2009 Freescale Semiconductor, Inc.
+ * Copyright 2007-2010 Freescale Semiconductor, Inc.
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -366,15 +366,8 @@ void ft_board_setup(void *blob, bd_t *bd)
 
        fdt_fixup_memory(blob, (u64)base, (u64)size);
 
-#ifdef CONFIG_PCIE3
-       ft_fsl_pci_setup(blob, "pci0", &pcie3_hose);
-#endif
-#ifdef CONFIG_PCIE2
-       ft_fsl_pci_setup(blob, "pci1", &pcie2_hose);
-#endif
-#ifdef CONFIG_PCIE1
-       ft_fsl_pci_setup(blob, "pci2", &pcie1_hose);
-#endif
+       FT_FSL_PCI_SETUP;
+
 #ifdef CONFIG_FSL_SGMII_RISER
        fsl_sgmii_riser_fdt_fixup(blob);
 #endif
index d62cfd1befad01c65b0076016db5d6195159802d..733979c6190e01d47cafadffeea064b062d0ffb7 100644 (file)
@@ -398,11 +398,9 @@ int last_stage_init(void)
 void ft_board_setup(void *blob, bd_t *bd)
 {
        ft_cpu_setup(blob, bd);
-#ifdef CONFIG_PCI1
-       ft_fsl_pci_setup(blob, "pci0", &pci1_hose);
-#endif
-#ifdef CONFIG_PCIE1
-       ft_fsl_pci_setup(blob, "pci1", &pcie1_hose);
+
+#ifdef CONFIG_FSL_PCI_INIT
+       FT_FSL_PCI_SETUP;
 #endif
 }
 #endif
index b1dda1082b1acac17e08e6f9f8416fdc04eaf0ad..54b2d0b166b71d434dc3de3a2d3b7abd353064a8 100644 (file)
@@ -308,12 +308,7 @@ void ft_board_setup (void *blob, bd_t *bd)
 {
        ft_cpu_setup(blob, bd);
 
-#ifdef CONFIG_PCIE1
-       ft_fsl_pci_setup(blob, "pci0", &pcie1_hose);
-#endif
-#ifdef CONFIG_PCIE2
-       ft_fsl_pci_setup(blob, "pci1", &pcie2_hose);
-#endif
+       FT_FSL_PCI_SETUP;
 }
 #endif
 
index fc2a6cbdb54fb4b0b9b1a8ba461e822f64f785d7..dda2cb6ed10c707f822a3a11fc5d158de57c29a7 100644 (file)
@@ -687,12 +687,7 @@ void ft_board_setup (void *blob, bd_t *bd)
 {
        ft_cpu_setup (blob, bd);
 
-#ifdef CONFIG_PCI1
-       ft_fsl_pci_setup(blob, "pci0", &pci1_hose);
-#endif
-#ifdef CONFIG_PCIE1
-       ft_fsl_pci_setup(blob, "pci1", &pcie1_hose);
-#endif
+       FT_FSL_PCI_SETUP;
 }
 #endif /* CONFIG_OF_BOARD_SETUP */
 
index 3a8182715bee24524f9a5ae3258d275b3c547436..ece7882577852c5faca67d0a453226e99ddcd3c6 100644 (file)
@@ -398,18 +398,6 @@ void pci_init_board(void)
 #if defined(CONFIG_OF_BOARD_SETUP)
 void ft_board_pci_setup(void *blob, bd_t *bd)
 {
-       /* TODO - make node name (eg pci0) dynamic */
-#ifdef CONFIG_PCI1
-       ft_fsl_pci_setup(blob, "pci0", &pci1_hose);
-#endif
-#ifdef CONFIG_PCIE1
-       ft_fsl_pci_setup(blob, "pci2", &pcie1_hose);
-#endif
-#ifdef CONFIG_PCIE2
-       ft_fsl_pci_setup(blob, "pci1", &pcie2_hose);
-#endif
-#ifdef CONFIG_PCIE3
-       ft_fsl_pci_setup(blob, "pci0", &pcie3_hose);
-#endif
+       FT_FSL_PCI_SETUP;
 }
 #endif /* CONFIG_OF_BOARD_SETUP */
index 5a63fa216835ef28a3dfd2a54e4c05d621310730..001e6eb900701185c46f981aa62c1426ff8e7116 100644 (file)
@@ -510,18 +510,25 @@ void fsl_pci_config_unlock(struct pci_controller *hose)
 #include <libfdt.h>
 #include <fdt_support.h>
 
-void ft_fsl_pci_setup(void *blob, const char *pci_alias,
-                       struct pci_controller *hose)
+void ft_fsl_pci_setup(void *blob, const char *pci_compat,
+                       struct pci_controller *hose, unsigned long ctrl_addr)
 {
-       int off = fdt_path_offset(blob, pci_alias);
+       int off;
        u32 bus_range[2];
+       phys_addr_t p_ctrl_addr = (phys_addr_t)ctrl_addr;
+
+       /* convert ctrl_addr to true physical address */
+       p_ctrl_addr = (phys_addr_t)ctrl_addr - CONFIG_SYS_CCSRBAR;
+       p_ctrl_addr += CONFIG_SYS_CCSRBAR_PHYS;
+
+       off = fdt_node_offset_by_compat_reg(blob, pci_compat, p_ctrl_addr);
 
        if (off < 0)
                return;
 
        /* We assume a cfg_addr not being set means we didn't setup the controller */
        if ((hose == NULL) || (hose->cfg_addr == NULL)) {
-               fdt_del_node_and_alias(blob, pci_alias);
+               fdt_del_node(blob, off);
        } else {
                bus_range[0] = 0;
                bus_range[1] = hose->last_busno - hose->first_busno;