Skip to content

Commit

Permalink
powerpc/fsl-pci: Unify pci/pcie initialization code
Browse files Browse the repository at this point in the history
We unified the Freescale pci/pcie initialization by changing the fsl_pci
to a platform driver. In previous PCI code architecture the initialization
routine is called at board_setup_arch stage. Now the initialization is done
in probe function which is architectural better. Also It's convenient for
adding PM support for PCI controller in later patch.

Now we registered pci controllers as platform devices. So we combine two
initialization code as one platform driver.

Signed-off-by: Jia Hongtao <[email protected]>
Signed-off-by: Li Yang <[email protected]>
Signed-off-by: Chunhe Lan <[email protected]>
Signed-off-by: Kumar Gala <[email protected]>
  • Loading branch information
Jia Hongtao authored and kumargala committed Sep 12, 2012
1 parent 9e67886 commit 905e75c
Show file tree
Hide file tree
Showing 33 changed files with 249 additions and 537 deletions.
10 changes: 10 additions & 0 deletions arch/powerpc/platforms/85xx/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ static struct of_device_id __initdata mpc85xx_common_ids[] = {
{ .compatible = "fsl,mpc8548-guts", },
/* Probably unnecessary? */
{ .compatible = "gpio-leds", },
/* For all PCI controllers */
{ .compatible = "fsl,mpc8540-pci", },
{ .compatible = "fsl,mpc8548-pcie", },
{ .compatible = "fsl,p1022-pcie", },
{ .compatible = "fsl,p1010-pcie", },
{ .compatible = "fsl,p1023-pcie", },
{ .compatible = "fsl,p4080-pcie", },
{ .compatible = "fsl,qoriq-pcie-v2.4", },
{ .compatible = "fsl,qoriq-pcie-v2.3", },
{ .compatible = "fsl,qoriq-pcie-v2.2", },
{},
};

Expand Down
34 changes: 5 additions & 29 deletions arch/powerpc/platforms/85xx/corenet_ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <linux/kdev_t.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/memblock.h>

#include <asm/time.h>
#include <asm/machdep.h>
Expand Down Expand Up @@ -52,39 +51,16 @@ void __init corenet_ds_pic_init(void)
*/
void __init corenet_ds_setup_arch(void)
{
#ifdef CONFIG_PCI
struct device_node *np;
struct pci_controller *hose;
#endif
dma_addr_t max = 0xffffffff;

mpc85xx_smp_init();

#ifdef CONFIG_PCI
for_each_node_by_type(np, "pci") {
if (of_device_is_compatible(np, "fsl,p4080-pcie") ||
of_device_is_compatible(np, "fsl,qoriq-pcie-v2.2") ||
of_device_is_compatible(np, "fsl,qoriq-pcie-v2.3") ||
of_device_is_compatible(np, "fsl,qoriq-pcie-v2.4")) {
fsl_add_bridge(np, 0);
hose = pci_find_hose_for_OF_device(np);
max = min(max, hose->dma_window_base_cur +
hose->dma_window_size);
}
}

#ifdef CONFIG_PPC64
#if defined(CONFIG_PCI) && defined(CONFIG_PPC64)
pci_devs_phb_init();
#endif
#endif

#ifdef CONFIG_SWIOTLB
if ((memblock_end_of_DRAM() - 1) > max) {
ppc_swiotlb_enable = 1;
set_pci_dma_ops(&swiotlb_dma_ops);
ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
}
#endif
fsl_pci_assign_primary();

swiotlb_detect_4g();

pr_info("%s board from Freescale Semiconductor\n", ppc_md.name);
}

Expand Down
62 changes: 20 additions & 42 deletions arch/powerpc/platforms/85xx/ge_imp3a.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <linux/seq_file.h>
#include <linux/interrupt.h>
#include <linux/of_platform.h>
#include <linux/memblock.h>

#include <asm/time.h>
#include <asm/machdep.h>
Expand Down Expand Up @@ -84,53 +83,39 @@ void __init ge_imp3a_pic_init(void)
of_node_put(cascade_node);
}

#ifdef CONFIG_PCI
static int primary_phb_addr;
#endif /* CONFIG_PCI */

/*
* Setup the architecture
*/
static void __init ge_imp3a_setup_arch(void)
static void ge_imp3a_pci_assign_primary(void)
{
struct device_node *regs;
#ifdef CONFIG_PCI
struct device_node *np;
struct pci_controller *hose;
#endif
dma_addr_t max = 0xffffffff;
struct resource rsrc;

if (ppc_md.progress)
ppc_md.progress("ge_imp3a_setup_arch()", 0);

#ifdef CONFIG_PCI
for_each_node_by_type(np, "pci") {
if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
of_device_is_compatible(np, "fsl,mpc8548-pcie") ||
of_device_is_compatible(np, "fsl,p2020-pcie")) {
struct resource rsrc;
of_address_to_resource(np, 0, &rsrc);
if ((rsrc.start & 0xfffff) == primary_phb_addr)
fsl_add_bridge(np, 1);
else
fsl_add_bridge(np, 0);

hose = pci_find_hose_for_OF_device(np);
max = min(max, hose->dma_window_base_cur +
hose->dma_window_size);
if ((rsrc.start & 0xfffff) == 0x9000)
fsl_pci_primary = np;
}
}
#endif
}

/*
* Setup the architecture
*/
static void __init ge_imp3a_setup_arch(void)
{
struct device_node *regs;

if (ppc_md.progress)
ppc_md.progress("ge_imp3a_setup_arch()", 0);

mpc85xx_smp_init();

#ifdef CONFIG_SWIOTLB
if ((memblock_end_of_DRAM() - 1) > max) {
ppc_swiotlb_enable = 1;
set_pci_dma_ops(&swiotlb_dma_ops);
ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
}
#endif
ge_imp3a_pci_assign_primary();

swiotlb_detect_4g();

/* Remap basic board registers */
regs = of_find_compatible_node(NULL, NULL, "ge,imp3a-fpga-regs");
Expand Down Expand Up @@ -215,17 +200,10 @@ static int __init ge_imp3a_probe(void)
{
unsigned long root = of_get_flat_dt_root();

if (of_flat_dt_is_compatible(root, "ge,IMP3A")) {
#ifdef CONFIG_PCI
primary_phb_addr = 0x9000;
#endif
return 1;
}

return 0;
return of_flat_dt_is_compatible(root, "ge,IMP3A");
}

machine_device_initcall(ge_imp3a, mpc85xx_common_publish_devices);
machine_arch_initcall(ge_imp3a, mpc85xx_common_publish_devices);

machine_arch_initcall(ge_imp3a, swiotlb_setup_bus_notifier);

Expand Down
36 changes: 3 additions & 33 deletions arch/powerpc/platforms/85xx/mpc8536_ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <linux/seq_file.h>
#include <linux/interrupt.h>
#include <linux/of_platform.h>
#include <linux/memblock.h>

#include <asm/time.h>
#include <asm/machdep.h>
Expand Down Expand Up @@ -46,46 +45,17 @@ void __init mpc8536_ds_pic_init(void)
*/
static void __init mpc8536_ds_setup_arch(void)
{
#ifdef CONFIG_PCI
struct device_node *np;
struct pci_controller *hose;
#endif
dma_addr_t max = 0xffffffff;

if (ppc_md.progress)
ppc_md.progress("mpc8536_ds_setup_arch()", 0);

#ifdef CONFIG_PCI
for_each_node_by_type(np, "pci") {
if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
struct resource rsrc;
of_address_to_resource(np, 0, &rsrc);
if ((rsrc.start & 0xfffff) == 0x8000)
fsl_add_bridge(np, 1);
else
fsl_add_bridge(np, 0);

hose = pci_find_hose_for_OF_device(np);
max = min(max, hose->dma_window_base_cur +
hose->dma_window_size);
}
}

#endif
fsl_pci_assign_primary();

#ifdef CONFIG_SWIOTLB
if ((memblock_end_of_DRAM() - 1) > max) {
ppc_swiotlb_enable = 1;
set_pci_dma_ops(&swiotlb_dma_ops);
ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
}
#endif
swiotlb_detect_4g();

printk("MPC8536 DS board from Freescale Semiconductor\n");
}

machine_device_initcall(mpc8536_ds, mpc85xx_common_publish_devices);
machine_arch_initcall(mpc8536_ds, mpc85xx_common_publish_devices);

machine_arch_initcall(mpc8536_ds, swiotlb_setup_bus_notifier);

Expand Down
11 changes: 3 additions & 8 deletions arch/powerpc/platforms/85xx/mpc85xx_ads.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ static void __init init_ioports(void)

static void __init mpc85xx_ads_setup_arch(void)
{
#ifdef CONFIG_PCI
struct device_node *np;
#endif

if (ppc_md.progress)
ppc_md.progress("mpc85xx_ads_setup_arch()", 0);

Expand All @@ -150,11 +146,10 @@ static void __init mpc85xx_ads_setup_arch(void)
#endif

#ifdef CONFIG_PCI
for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
fsl_add_bridge(np, 1);

ppc_md.pci_exclude_device = mpc85xx_exclude_device;
#endif

fsl_pci_assign_primary();
}

static void mpc85xx_ads_show_cpuinfo(struct seq_file *m)
Expand All @@ -173,7 +168,7 @@ static void mpc85xx_ads_show_cpuinfo(struct seq_file *m)
seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
}

machine_device_initcall(mpc85xx_ads, mpc85xx_common_publish_devices);
machine_arch_initcall(mpc85xx_ads, mpc85xx_common_publish_devices);

/*
* Called very early, device-tree isn't unflattened
Expand Down
44 changes: 31 additions & 13 deletions arch/powerpc/platforms/85xx/mpc85xx_cds.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,33 @@ machine_device_initcall(mpc85xx_cds, mpc85xx_cds_8259_attach);

#endif /* CONFIG_PPC_I8259 */

static void mpc85xx_cds_pci_assign_primary(void)
{
#ifdef CONFIG_PCI
struct device_node *np;

if (fsl_pci_primary)
return;

/*
* MPC85xx_CDS has ISA bridge but unfortunately there is no
* isa node in device tree. We now looking for i8259 node as
* a workaround for such a broken device tree. This routine
* is for complying to all device trees.
*/
np = of_find_node_by_name(NULL, "i8259");
while ((fsl_pci_primary = of_get_parent(np))) {
of_node_put(np);
np = fsl_pci_primary;

if ((of_device_is_compatible(np, "fsl,mpc8540-pci") ||
of_device_is_compatible(np, "fsl,mpc8548-pcie")) &&
of_device_is_available(np))
return;
}
#endif
}

/*
* Setup the architecture
*/
Expand Down Expand Up @@ -309,21 +336,12 @@ static void __init mpc85xx_cds_setup_arch(void)
}

#ifdef CONFIG_PCI
for_each_node_by_type(np, "pci") {
if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
struct resource rsrc;
of_address_to_resource(np, 0, &rsrc);
if ((rsrc.start & 0xfffff) == 0x8000)
fsl_add_bridge(np, 1);
else
fsl_add_bridge(np, 0);
}
}

ppc_md.pci_irq_fixup = mpc85xx_cds_pci_irq_fixup;
ppc_md.pci_exclude_device = mpc85xx_exclude_device;
#endif

mpc85xx_cds_pci_assign_primary();
fsl_pci_assign_primary();
}

static void mpc85xx_cds_show_cpuinfo(struct seq_file *m)
Expand Down Expand Up @@ -355,7 +373,7 @@ static int __init mpc85xx_cds_probe(void)
return of_flat_dt_is_compatible(root, "MPC85xxCDS");
}

machine_device_initcall(mpc85xx_cds, mpc85xx_common_publish_devices);
machine_arch_initcall(mpc85xx_cds, mpc85xx_common_publish_devices);

define_machine(mpc85xx_cds) {
.name = "MPC85xx CDS",
Expand Down
14 changes: 6 additions & 8 deletions arch/powerpc/platforms/85xx/mpc85xx_ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <linux/seq_file.h>
#include <linux/interrupt.h>
#include <linux/of_platform.h>
#include <linux/memblock.h>

#include <asm/time.h>
#include <asm/machdep.h>
Expand Down Expand Up @@ -129,13 +128,11 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,
}
#endif /* CONFIG_PCI */

static void __init mpc85xx_ds_pci_init(void)
static void __init mpc85xx_ds_uli_init(void)
{
#ifdef CONFIG_PCI
struct device_node *node;

fsl_pci_init();

/* See if we have a ULI under the primary */

node = of_find_node_by_name(NULL, "uli1575");
Expand All @@ -160,7 +157,8 @@ static void __init mpc85xx_ds_setup_arch(void)
ppc_md.progress("mpc85xx_ds_setup_arch()", 0);

swiotlb_detect_4g();
mpc85xx_ds_pci_init();
fsl_pci_assign_primary();
mpc85xx_ds_uli_init();
mpc85xx_smp_init();

printk("MPC85xx DS board from Freescale Semiconductor\n");
Expand All @@ -176,9 +174,9 @@ static int __init mpc8544_ds_probe(void)
return !!of_flat_dt_is_compatible(root, "MPC8544DS");
}

machine_device_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
machine_device_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
machine_device_initcall(p2020_ds, mpc85xx_common_publish_devices);
machine_arch_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
machine_arch_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices);

machine_arch_initcall(mpc8544_ds, swiotlb_setup_bus_notifier);
machine_arch_initcall(mpc8572_ds, swiotlb_setup_bus_notifier);
Expand Down
Loading

0 comments on commit 905e75c

Please sign in to comment.