linux/arch/powerpc/platforms/85xx/mpc8536_ds.c
<<
>>
Prefs
   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>
  20#include <linux/memblock.h>
  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>
  30#include <asm/swiotlb.h>
  31
  32#include <sysdev/fsl_soc.h>
  33#include <sysdev/fsl_pci.h>
  34
  35#include "mpc85xx.h"
  36
  37void __init mpc8536_ds_pic_init(void)
  38{
  39        struct mpic *mpic = mpic_alloc(NULL, 0,
  40                          MPIC_WANTS_RESET |
  41                          MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
  42                        0, 256, " OpenPIC  ");
  43        BUG_ON(mpic == NULL);
  44        mpic_init(mpic);
  45}
  46
  47/*
  48 * Setup the architecture
  49 */
  50static void __init mpc8536_ds_setup_arch(void)
  51{
  52#ifdef CONFIG_PCI
  53        struct device_node *np;
  54        struct pci_controller *hose;
  55#endif
  56        dma_addr_t max = 0xffffffff;
  57
  58        if (ppc_md.progress)
  59                ppc_md.progress("mpc8536_ds_setup_arch()", 0);
  60
  61#ifdef CONFIG_PCI
  62        for_each_node_by_type(np, "pci") {
  63                if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
  64                    of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
  65                        struct resource rsrc;
  66                        of_address_to_resource(np, 0, &rsrc);
  67                        if ((rsrc.start & 0xfffff) == 0x8000)
  68                                fsl_add_bridge(np, 1);
  69                        else
  70                                fsl_add_bridge(np, 0);
  71
  72                        hose = pci_find_hose_for_OF_device(np);
  73                        max = min(max, hose->dma_window_base_cur +
  74                                        hose->dma_window_size);
  75                }
  76        }
  77
  78#endif
  79
  80#ifdef CONFIG_SWIOTLB
  81        if (memblock_end_of_DRAM() > max) {
  82                ppc_swiotlb_enable = 1;
  83                set_pci_dma_ops(&swiotlb_dma_ops);
  84                ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
  85        }
  86#endif
  87
  88        printk("MPC8536 DS board from Freescale Semiconductor\n");
  89}
  90
  91machine_device_initcall(mpc8536_ds, mpc85xx_common_publish_devices);
  92
  93machine_arch_initcall(mpc8536_ds, swiotlb_setup_bus_notifier);
  94
  95/*
  96 * Called very early, device-tree isn't unflattened
  97 */
  98static int __init mpc8536_ds_probe(void)
  99{
 100        unsigned long root = of_get_flat_dt_root();
 101
 102        return of_flat_dt_is_compatible(root, "fsl,mpc8536ds");
 103}
 104
 105define_machine(mpc8536_ds) {
 106        .name                   = "MPC8536 DS",
 107        .probe                  = mpc8536_ds_probe,
 108        .setup_arch             = mpc8536_ds_setup_arch,
 109        .init_IRQ               = mpc8536_ds_pic_init,
 110#ifdef CONFIG_PCI
 111        .pcibios_fixup_bus      = fsl_pcibios_fixup_bus,
 112#endif
 113        .get_irq                = mpic_get_irq,
 114        .restart                = fsl_rstcr_restart,
 115        .calibrate_decr         = generic_calibrate_decr,
 116        .progress               = udbg_progress,
 117};
 118