Kumar Gala | 2f3804e | 2008-07-02 01:36:15 -0500 | [diff] [blame] | 1 | /* |
| 2 | * MPC8536 DS Board Setup |
| 3 | * |
| 4 | * Copyright 2008 Freescale Semiconductor, Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2 of the License, or (at your |
| 9 | * option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/stddef.h> |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/pci.h> |
| 15 | #include <linux/kdev_t.h> |
| 16 | #include <linux/delay.h> |
| 17 | #include <linux/seq_file.h> |
| 18 | #include <linux/interrupt.h> |
| 19 | #include <linux/of_platform.h> |
Yinghai Lu | 95f72d1 | 2010-07-12 14:36:09 +1000 | [diff] [blame] | 20 | #include <linux/memblock.h> |
Kumar Gala | 2f3804e | 2008-07-02 01:36:15 -0500 | [diff] [blame] | 21 | |
| 22 | #include <asm/system.h> |
| 23 | #include <asm/time.h> |
| 24 | #include <asm/machdep.h> |
| 25 | #include <asm/pci-bridge.h> |
| 26 | #include <mm/mmu_decl.h> |
| 27 | #include <asm/prom.h> |
| 28 | #include <asm/udbg.h> |
| 29 | #include <asm/mpic.h> |
Kumar Gala | 152d018 | 2009-05-15 00:37:35 -0500 | [diff] [blame] | 30 | #include <asm/swiotlb.h> |
Kumar Gala | 2f3804e | 2008-07-02 01:36:15 -0500 | [diff] [blame] | 31 | |
| 32 | #include <sysdev/fsl_soc.h> |
| 33 | #include <sysdev/fsl_pci.h> |
| 34 | |
Dmitry Eremin-Solenikov | 543a07b | 2011-11-17 21:56:16 +0400 | [diff] [blame^] | 35 | #include "mpc85xx.h" |
| 36 | |
Kumar Gala | 2f3804e | 2008-07-02 01:36:15 -0500 | [diff] [blame] | 37 | void __init mpc8536_ds_pic_init(void) |
| 38 | { |
| 39 | struct mpic *mpic; |
| 40 | struct resource r; |
| 41 | struct device_node *np; |
| 42 | |
Jason Jin | b93eeba | 2008-07-08 09:21:08 +0800 | [diff] [blame] | 43 | np = of_find_node_by_type(NULL, "open-pic"); |
Kumar Gala | 2f3804e | 2008-07-02 01:36:15 -0500 | [diff] [blame] | 44 | if (np == NULL) { |
| 45 | printk(KERN_ERR "Could not find open-pic node\n"); |
| 46 | return; |
| 47 | } |
| 48 | |
| 49 | if (of_address_to_resource(np, 0, &r)) { |
| 50 | printk(KERN_ERR "Failed to map mpic register space\n"); |
| 51 | of_node_put(np); |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | mpic = mpic_alloc(np, r.start, |
| 56 | MPIC_PRIMARY | MPIC_WANTS_RESET | |
| 57 | MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS, |
| 58 | 0, 256, " OpenPIC "); |
| 59 | BUG_ON(mpic == NULL); |
| 60 | of_node_put(np); |
| 61 | |
| 62 | mpic_init(mpic); |
| 63 | } |
| 64 | |
| 65 | /* |
| 66 | * Setup the architecture |
| 67 | */ |
| 68 | static void __init mpc8536_ds_setup_arch(void) |
| 69 | { |
| 70 | #ifdef CONFIG_PCI |
| 71 | struct device_node *np; |
Kumar Gala | 152d018 | 2009-05-15 00:37:35 -0500 | [diff] [blame] | 72 | struct pci_controller *hose; |
Kumar Gala | 2f3804e | 2008-07-02 01:36:15 -0500 | [diff] [blame] | 73 | #endif |
Kumar Gala | 152d018 | 2009-05-15 00:37:35 -0500 | [diff] [blame] | 74 | dma_addr_t max = 0xffffffff; |
Kumar Gala | 2f3804e | 2008-07-02 01:36:15 -0500 | [diff] [blame] | 75 | |
| 76 | if (ppc_md.progress) |
| 77 | ppc_md.progress("mpc8536_ds_setup_arch()", 0); |
| 78 | |
| 79 | #ifdef CONFIG_PCI |
| 80 | for_each_node_by_type(np, "pci") { |
| 81 | if (of_device_is_compatible(np, "fsl,mpc8540-pci") || |
| 82 | of_device_is_compatible(np, "fsl,mpc8548-pcie")) { |
| 83 | struct resource rsrc; |
| 84 | of_address_to_resource(np, 0, &rsrc); |
| 85 | if ((rsrc.start & 0xfffff) == 0x8000) |
| 86 | fsl_add_bridge(np, 1); |
| 87 | else |
| 88 | fsl_add_bridge(np, 0); |
Kumar Gala | 152d018 | 2009-05-15 00:37:35 -0500 | [diff] [blame] | 89 | |
| 90 | hose = pci_find_hose_for_OF_device(np); |
| 91 | max = min(max, hose->dma_window_base_cur + |
| 92 | hose->dma_window_size); |
Kumar Gala | 2f3804e | 2008-07-02 01:36:15 -0500 | [diff] [blame] | 93 | } |
| 94 | } |
| 95 | |
| 96 | #endif |
| 97 | |
Kumar Gala | 152d018 | 2009-05-15 00:37:35 -0500 | [diff] [blame] | 98 | #ifdef CONFIG_SWIOTLB |
Yinghai Lu | 95f72d1 | 2010-07-12 14:36:09 +1000 | [diff] [blame] | 99 | if (memblock_end_of_DRAM() > max) { |
Kumar Gala | 152d018 | 2009-05-15 00:37:35 -0500 | [diff] [blame] | 100 | ppc_swiotlb_enable = 1; |
FUJITA Tomonori | 3702977 | 2009-08-04 19:08:23 +0000 | [diff] [blame] | 101 | set_pci_dma_ops(&swiotlb_dma_ops); |
FUJITA Tomonori | 762afb7 | 2009-08-04 19:08:22 +0000 | [diff] [blame] | 102 | ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; |
Kumar Gala | 152d018 | 2009-05-15 00:37:35 -0500 | [diff] [blame] | 103 | } |
| 104 | #endif |
| 105 | |
Kumar Gala | 2f3804e | 2008-07-02 01:36:15 -0500 | [diff] [blame] | 106 | printk("MPC8536 DS board from Freescale Semiconductor\n"); |
| 107 | } |
| 108 | |
| 109 | static struct of_device_id __initdata mpc8536_ds_ids[] = { |
| 110 | { .type = "soc", }, |
| 111 | { .compatible = "soc", }, |
Kim Phillips | cf0d19f | 2008-07-29 15:29:24 -0500 | [diff] [blame] | 112 | { .compatible = "simple-bus", }, |
Anton Vorontsov | 84ba4a5 | 2009-03-19 21:01:48 +0300 | [diff] [blame] | 113 | { .compatible = "gianfar", }, |
Kumar Gala | 2f3804e | 2008-07-02 01:36:15 -0500 | [diff] [blame] | 114 | {}, |
| 115 | }; |
| 116 | |
| 117 | static int __init mpc8536_ds_publish_devices(void) |
| 118 | { |
| 119 | return of_platform_bus_probe(NULL, mpc8536_ds_ids, NULL); |
| 120 | } |
| 121 | machine_device_initcall(mpc8536_ds, mpc8536_ds_publish_devices); |
| 122 | |
Kumar Gala | 152d018 | 2009-05-15 00:37:35 -0500 | [diff] [blame] | 123 | machine_arch_initcall(mpc8536_ds, swiotlb_setup_bus_notifier); |
| 124 | |
Kumar Gala | 2f3804e | 2008-07-02 01:36:15 -0500 | [diff] [blame] | 125 | /* |
| 126 | * Called very early, device-tree isn't unflattened |
| 127 | */ |
| 128 | static int __init mpc8536_ds_probe(void) |
| 129 | { |
| 130 | unsigned long root = of_get_flat_dt_root(); |
| 131 | |
| 132 | return of_flat_dt_is_compatible(root, "fsl,mpc8536ds"); |
| 133 | } |
| 134 | |
| 135 | define_machine(mpc8536_ds) { |
| 136 | .name = "MPC8536 DS", |
| 137 | .probe = mpc8536_ds_probe, |
| 138 | .setup_arch = mpc8536_ds_setup_arch, |
| 139 | .init_IRQ = mpc8536_ds_pic_init, |
| 140 | #ifdef CONFIG_PCI |
| 141 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, |
| 142 | #endif |
| 143 | .get_irq = mpic_get_irq, |
| 144 | .restart = fsl_rstcr_restart, |
| 145 | .calibrate_decr = generic_calibrate_decr, |
| 146 | .progress = udbg_progress, |
| 147 | }; |