blob: 767c7cf18a9c978f7b9b70f700ed5ca496fdfd73 [file] [log] [blame]
Kumar Gala2f3804e2008-07-02 01:36:15 -05001/*
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 Lu95f72d12010-07-12 14:36:09 +100020#include <linux/memblock.h>
Kumar Gala2f3804e2008-07-02 01:36:15 -050021
Kumar Gala2f3804e2008-07-02 01:36:15 -050022#include <asm/time.h>
23#include <asm/machdep.h>
24#include <asm/pci-bridge.h>
25#include <mm/mmu_decl.h>
26#include <asm/prom.h>
27#include <asm/udbg.h>
28#include <asm/mpic.h>
Kumar Gala152d0182009-05-15 00:37:35 -050029#include <asm/swiotlb.h>
Kumar Gala2f3804e2008-07-02 01:36:15 -050030
31#include <sysdev/fsl_soc.h>
32#include <sysdev/fsl_pci.h>
33
Dmitry Eremin-Solenikov543a07b2011-11-17 21:56:16 +040034#include "mpc85xx.h"
35
Kumar Gala2f3804e2008-07-02 01:36:15 -050036void __init mpc8536_ds_pic_init(void)
37{
Kyle Moffette55d7f72011-12-22 10:19:14 +000038 struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN,
Kumar Gala2f3804e2008-07-02 01:36:15 -050039 0, 256, " OpenPIC ");
40 BUG_ON(mpic == NULL);
Kumar Gala2f3804e2008-07-02 01:36:15 -050041 mpic_init(mpic);
42}
43
44/*
45 * Setup the architecture
46 */
47static void __init mpc8536_ds_setup_arch(void)
48{
49#ifdef CONFIG_PCI
50 struct device_node *np;
Kumar Gala152d0182009-05-15 00:37:35 -050051 struct pci_controller *hose;
Kumar Gala2f3804e2008-07-02 01:36:15 -050052#endif
Kumar Gala152d0182009-05-15 00:37:35 -050053 dma_addr_t max = 0xffffffff;
Kumar Gala2f3804e2008-07-02 01:36:15 -050054
55 if (ppc_md.progress)
56 ppc_md.progress("mpc8536_ds_setup_arch()", 0);
57
58#ifdef CONFIG_PCI
59 for_each_node_by_type(np, "pci") {
60 if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
61 of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
62 struct resource rsrc;
63 of_address_to_resource(np, 0, &rsrc);
64 if ((rsrc.start & 0xfffff) == 0x8000)
65 fsl_add_bridge(np, 1);
66 else
67 fsl_add_bridge(np, 0);
Kumar Gala152d0182009-05-15 00:37:35 -050068
69 hose = pci_find_hose_for_OF_device(np);
70 max = min(max, hose->dma_window_base_cur +
71 hose->dma_window_size);
Kumar Gala2f3804e2008-07-02 01:36:15 -050072 }
73 }
74
75#endif
76
Kumar Gala152d0182009-05-15 00:37:35 -050077#ifdef CONFIG_SWIOTLB
Bharat Bhushana5cb82d2012-06-05 03:55:04 +000078 if ((memblock_end_of_DRAM() - 1) > max) {
Kumar Gala152d0182009-05-15 00:37:35 -050079 ppc_swiotlb_enable = 1;
FUJITA Tomonori37029772009-08-04 19:08:23 +000080 set_pci_dma_ops(&swiotlb_dma_ops);
FUJITA Tomonori762afb72009-08-04 19:08:22 +000081 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
Kumar Gala152d0182009-05-15 00:37:35 -050082 }
83#endif
84
Kumar Gala2f3804e2008-07-02 01:36:15 -050085 printk("MPC8536 DS board from Freescale Semiconductor\n");
86}
87
Dmitry Eremin-Solenikov46d026a2011-11-17 21:56:17 +040088machine_device_initcall(mpc8536_ds, mpc85xx_common_publish_devices);
Kumar Gala2f3804e2008-07-02 01:36:15 -050089
Kumar Gala152d0182009-05-15 00:37:35 -050090machine_arch_initcall(mpc8536_ds, swiotlb_setup_bus_notifier);
91
Kumar Gala2f3804e2008-07-02 01:36:15 -050092/*
93 * Called very early, device-tree isn't unflattened
94 */
95static int __init mpc8536_ds_probe(void)
96{
97 unsigned long root = of_get_flat_dt_root();
98
99 return of_flat_dt_is_compatible(root, "fsl,mpc8536ds");
100}
101
102define_machine(mpc8536_ds) {
103 .name = "MPC8536 DS",
104 .probe = mpc8536_ds_probe,
105 .setup_arch = mpc8536_ds_setup_arch,
106 .init_IRQ = mpc8536_ds_pic_init,
107#ifdef CONFIG_PCI
108 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
109#endif
110 .get_irq = mpic_get_irq,
111 .restart = fsl_rstcr_restart,
112 .calibrate_decr = generic_calibrate_decr,
113 .progress = udbg_progress,
114};