Timur Tabi | 30be4c9 | 2010-07-02 17:25:03 -0500 | [diff] [blame] | 1 | /* |
| 2 | * P1022DS board specific routines |
| 3 | * |
| 4 | * Authors: Travis Wheatley <travis.wheatley@freescale.com> |
| 5 | * Dave Liu <daveliu@freescale.com> |
| 6 | * Timur Tabi <timur@freescale.com> |
| 7 | * |
| 8 | * Copyright 2010 Freescale Semiconductor, Inc. |
| 9 | * |
| 10 | * This file is taken from the Freescale P1022DS BSP, with modifications: |
| 11 | * 1) No DIU support (pending rewrite of DIU code) |
| 12 | * 2) No AMP support |
| 13 | * 3) No PCI endpoint support |
| 14 | * |
| 15 | * This file is licensed under the terms of the GNU General Public License |
| 16 | * version 2. This program is licensed "as is" without any warranty of any |
| 17 | * kind, whether express or implied. |
| 18 | */ |
| 19 | |
| 20 | #include <linux/pci.h> |
| 21 | #include <linux/of_platform.h> |
Kumar Gala | dc1c41f | 2010-08-31 11:39:25 -0500 | [diff] [blame] | 22 | #include <linux/memblock.h> |
Timur Tabi | 30be4c9 | 2010-07-02 17:25:03 -0500 | [diff] [blame] | 23 | |
| 24 | #include <asm/mpic.h> |
| 25 | #include <asm/swiotlb.h> |
| 26 | |
| 27 | #include <sysdev/fsl_soc.h> |
| 28 | #include <sysdev/fsl_pci.h> |
| 29 | |
| 30 | void __init p1022_ds_pic_init(void) |
| 31 | { |
| 32 | struct mpic *mpic; |
| 33 | struct resource r; |
| 34 | struct device_node *np; |
| 35 | |
| 36 | np = of_find_node_by_type(NULL, "open-pic"); |
| 37 | if (!np) { |
| 38 | pr_err("Could not find open-pic node\n"); |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | if (of_address_to_resource(np, 0, &r)) { |
| 43 | pr_err("Failed to map mpic register space\n"); |
| 44 | of_node_put(np); |
| 45 | return; |
| 46 | } |
| 47 | |
| 48 | mpic = mpic_alloc(np, r.start, |
| 49 | MPIC_PRIMARY | MPIC_WANTS_RESET | |
| 50 | MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | |
| 51 | MPIC_SINGLE_DEST_CPU, |
| 52 | 0, 256, " OpenPIC "); |
| 53 | |
| 54 | BUG_ON(mpic == NULL); |
| 55 | of_node_put(np); |
| 56 | |
| 57 | mpic_init(mpic); |
| 58 | } |
| 59 | |
| 60 | #ifdef CONFIG_SMP |
| 61 | void __init mpc85xx_smp_init(void); |
| 62 | #endif |
| 63 | |
| 64 | /* |
| 65 | * Setup the architecture |
| 66 | */ |
| 67 | static void __init p1022_ds_setup_arch(void) |
| 68 | { |
| 69 | #ifdef CONFIG_PCI |
| 70 | struct device_node *np; |
| 71 | #endif |
| 72 | dma_addr_t max = 0xffffffff; |
| 73 | |
| 74 | if (ppc_md.progress) |
| 75 | ppc_md.progress("p1022_ds_setup_arch()", 0); |
| 76 | |
| 77 | #ifdef CONFIG_PCI |
| 78 | for_each_compatible_node(np, "pci", "fsl,p1022-pcie") { |
| 79 | struct resource rsrc; |
| 80 | struct pci_controller *hose; |
| 81 | |
| 82 | of_address_to_resource(np, 0, &rsrc); |
| 83 | |
| 84 | if ((rsrc.start & 0xfffff) == 0x8000) |
| 85 | fsl_add_bridge(np, 1); |
| 86 | else |
| 87 | fsl_add_bridge(np, 0); |
| 88 | |
| 89 | hose = pci_find_hose_for_OF_device(np); |
| 90 | max = min(max, hose->dma_window_base_cur + |
| 91 | hose->dma_window_size); |
| 92 | } |
| 93 | #endif |
| 94 | |
| 95 | #ifdef CONFIG_SMP |
| 96 | mpc85xx_smp_init(); |
| 97 | #endif |
| 98 | |
| 99 | #ifdef CONFIG_SWIOTLB |
Kumar Gala | dc1c41f | 2010-08-31 11:39:25 -0500 | [diff] [blame] | 100 | if (memblock_end_of_DRAM() > max) { |
Timur Tabi | 30be4c9 | 2010-07-02 17:25:03 -0500 | [diff] [blame] | 101 | ppc_swiotlb_enable = 1; |
| 102 | set_pci_dma_ops(&swiotlb_dma_ops); |
| 103 | ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; |
| 104 | } |
| 105 | #endif |
| 106 | |
| 107 | pr_info("Freescale P1022 DS reference board\n"); |
| 108 | } |
| 109 | |
| 110 | static struct of_device_id __initdata p1022_ds_ids[] = { |
| 111 | { .type = "soc", }, |
| 112 | { .compatible = "soc", }, |
| 113 | { .compatible = "simple-bus", }, |
| 114 | { .compatible = "gianfar", }, |
Timur Tabi | f7a07fd | 2010-08-19 16:28:12 -0500 | [diff] [blame^] | 115 | /* So that the DMA channel nodes can be probed individually: */ |
| 116 | { .compatible = "fsl,eloplus-dma", }, |
Timur Tabi | 30be4c9 | 2010-07-02 17:25:03 -0500 | [diff] [blame] | 117 | {}, |
| 118 | }; |
| 119 | |
| 120 | static int __init p1022_ds_publish_devices(void) |
| 121 | { |
| 122 | return of_platform_bus_probe(NULL, p1022_ds_ids, NULL); |
| 123 | } |
| 124 | machine_device_initcall(p1022_ds, p1022_ds_publish_devices); |
| 125 | |
| 126 | machine_arch_initcall(p1022_ds, swiotlb_setup_bus_notifier); |
| 127 | |
| 128 | /* |
| 129 | * Called very early, device-tree isn't unflattened |
| 130 | */ |
| 131 | static int __init p1022_ds_probe(void) |
| 132 | { |
| 133 | unsigned long root = of_get_flat_dt_root(); |
| 134 | |
| 135 | return of_flat_dt_is_compatible(root, "fsl,p1022ds"); |
| 136 | } |
| 137 | |
| 138 | define_machine(p1022_ds) { |
| 139 | .name = "P1022 DS", |
| 140 | .probe = p1022_ds_probe, |
| 141 | .setup_arch = p1022_ds_setup_arch, |
| 142 | .init_IRQ = p1022_ds_pic_init, |
| 143 | #ifdef CONFIG_PCI |
| 144 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, |
| 145 | #endif |
| 146 | .get_irq = mpic_get_irq, |
| 147 | .restart = fsl_rstcr_restart, |
| 148 | .calibrate_decr = generic_calibrate_decr, |
| 149 | .progress = udbg_progress, |
| 150 | }; |