Path: blob/master/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
10818 views
/*1* MPC86xx HPCN board specific routines2*3* Recode: ZHANG WEI <[email protected]>4* Initial author: Xianghua Xiao <[email protected]>5*6* Copyright 2006 Freescale Semiconductor Inc.7*8* This program is free software; you can redistribute it and/or modify it9* under the terms of the GNU General Public License as published by the10* Free Software Foundation; either version 2 of the License, or (at your11* option) any later version.12*/1314#include <linux/stddef.h>15#include <linux/kernel.h>16#include <linux/pci.h>17#include <linux/kdev_t.h>18#include <linux/delay.h>19#include <linux/seq_file.h>20#include <linux/of_platform.h>21#include <linux/memblock.h>2223#include <asm/system.h>24#include <asm/time.h>25#include <asm/machdep.h>26#include <asm/pci-bridge.h>27#include <asm/prom.h>28#include <mm/mmu_decl.h>29#include <asm/udbg.h>30#include <asm/swiotlb.h>3132#include <asm/mpic.h>3334#include <sysdev/fsl_pci.h>35#include <sysdev/fsl_soc.h>3637#include "mpc86xx.h"3839#undef DEBUG4041#ifdef DEBUG42#define DBG(fmt...) do { printk(KERN_ERR fmt); } while(0)43#else44#define DBG(fmt...) do { } while(0)45#endif4647#ifdef CONFIG_PCI48extern int uli_exclude_device(struct pci_controller *hose,49u_char bus, u_char devfn);5051static int mpc86xx_exclude_device(struct pci_controller *hose,52u_char bus, u_char devfn)53{54struct device_node* node;55struct resource rsrc;5657node = hose->dn;58of_address_to_resource(node, 0, &rsrc);5960if ((rsrc.start & 0xfffff) == 0x8000) {61return uli_exclude_device(hose, bus, devfn);62}6364return PCIBIOS_SUCCESSFUL;65}66#endif /* CONFIG_PCI */676869static void __init70mpc86xx_hpcn_setup_arch(void)71{72#ifdef CONFIG_PCI73struct device_node *np;74struct pci_controller *hose;75#endif76dma_addr_t max = 0xffffffff;7778if (ppc_md.progress)79ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0);8081#ifdef CONFIG_PCI82for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {83struct resource rsrc;84of_address_to_resource(np, 0, &rsrc);85if ((rsrc.start & 0xfffff) == 0x8000)86fsl_add_bridge(np, 1);87else88fsl_add_bridge(np, 0);89hose = pci_find_hose_for_OF_device(np);90max = min(max, hose->dma_window_base_cur +91hose->dma_window_size);92}9394ppc_md.pci_exclude_device = mpc86xx_exclude_device;9596#endif9798printk("MPC86xx HPCN board from Freescale Semiconductor\n");99100#ifdef CONFIG_SMP101mpc86xx_smp_init();102#endif103104#ifdef CONFIG_SWIOTLB105if (memblock_end_of_DRAM() > max) {106ppc_swiotlb_enable = 1;107set_pci_dma_ops(&swiotlb_dma_ops);108ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;109}110#endif111}112113114static void115mpc86xx_hpcn_show_cpuinfo(struct seq_file *m)116{117uint svid = mfspr(SPRN_SVR);118119seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");120121seq_printf(m, "SVR\t\t: 0x%x\n", svid);122}123124125/*126* Called very early, device-tree isn't unflattened127*/128static int __init mpc86xx_hpcn_probe(void)129{130unsigned long root = of_get_flat_dt_root();131132if (of_flat_dt_is_compatible(root, "fsl,mpc8641hpcn"))133return 1; /* Looks good */134135/* Be nice and don't give silent boot death. Delete this in 2.6.27 */136if (of_flat_dt_is_compatible(root, "mpc86xx")) {137pr_warning("WARNING: your dts/dtb is old. You must update before the next kernel release\n");138return 1;139}140141return 0;142}143144static long __init145mpc86xx_time_init(void)146{147unsigned int temp;148149/* Set the time base to zero */150mtspr(SPRN_TBWL, 0);151mtspr(SPRN_TBWU, 0);152153temp = mfspr(SPRN_HID0);154temp |= HID0_TBEN;155mtspr(SPRN_HID0, temp);156asm volatile("isync");157158return 0;159}160161static __initdata struct of_device_id of_bus_ids[] = {162{ .compatible = "simple-bus", },163{ .compatible = "fsl,rapidio-delta", },164{ .compatible = "gianfar", },165{},166};167168static int __init declare_of_platform_devices(void)169{170of_platform_bus_probe(NULL, of_bus_ids, NULL);171172return 0;173}174machine_device_initcall(mpc86xx_hpcn, declare_of_platform_devices);175machine_arch_initcall(mpc86xx_hpcn, swiotlb_setup_bus_notifier);176177define_machine(mpc86xx_hpcn) {178.name = "MPC86xx HPCN",179.probe = mpc86xx_hpcn_probe,180.setup_arch = mpc86xx_hpcn_setup_arch,181.init_IRQ = mpc86xx_init_irq,182.show_cpuinfo = mpc86xx_hpcn_show_cpuinfo,183.get_irq = mpic_get_irq,184.restart = fsl_rstcr_restart,185.time_init = mpc86xx_time_init,186.calibrate_decr = generic_calibrate_decr,187.progress = udbg_progress,188#ifdef CONFIG_PCI189.pcibios_fixup_bus = fsl_pcibios_fixup_bus,190#endif191};192193194