Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * Common PowerQUICC II code.
0004  *
0005  * Author: Scott Wood <scottwood@freescale.com>
0006  * Copyright (c) 2007 Freescale Semiconductor
0007  *
0008  * Based on code by Vitaly Bordug <vbordug@ru.mvista.com>
0009  * pq2_restart fix by Wade Farnsworth <wfarnsworth@mvista.com>
0010  * Copyright (c) 2006 MontaVista Software, Inc.
0011  */
0012 
0013 #include <linux/kprobes.h>
0014 
0015 #include <asm/cpm2.h>
0016 #include <asm/io.h>
0017 #include <asm/pci-bridge.h>
0018 
0019 #include <platforms/82xx/pq2.h>
0020 
0021 #define RMR_CSRE 0x00000001
0022 
0023 void __noreturn pq2_restart(char *cmd)
0024 {
0025     local_irq_disable();
0026     setbits32(&cpm2_immr->im_clkrst.car_rmr, RMR_CSRE);
0027 
0028     /* Clear the ME,EE,IR & DR bits in MSR to cause checkstop */
0029     mtmsr(mfmsr() & ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR));
0030     in_8(&cpm2_immr->im_clkrst.res[0]);
0031 
0032     panic("Restart failed\n");
0033 }
0034 NOKPROBE_SYMBOL(pq2_restart)
0035 
0036 #ifdef CONFIG_PCI
0037 static int pq2_pci_exclude_device(struct pci_controller *hose,
0038                                   u_char bus, u8 devfn)
0039 {
0040     if (bus == 0 && PCI_SLOT(devfn) == 0)
0041         return PCIBIOS_DEVICE_NOT_FOUND;
0042     else
0043         return PCIBIOS_SUCCESSFUL;
0044 }
0045 
0046 static void __init pq2_pci_add_bridge(struct device_node *np)
0047 {
0048     struct pci_controller *hose;
0049     struct resource r;
0050 
0051     if (of_address_to_resource(np, 0, &r) || r.end - r.start < 0x10b)
0052         goto err;
0053 
0054     pci_add_flags(PCI_REASSIGN_ALL_BUS);
0055 
0056     hose = pcibios_alloc_controller(np);
0057     if (!hose)
0058         return;
0059 
0060     hose->dn = np;
0061 
0062     setup_indirect_pci(hose, r.start + 0x100, r.start + 0x104, 0);
0063     pci_process_bridge_OF_ranges(hose, np, 1);
0064 
0065     return;
0066 
0067 err:
0068     printk(KERN_ERR "No valid PCI reg property in device tree\n");
0069 }
0070 
0071 void __init pq2_init_pci(void)
0072 {
0073     struct device_node *np;
0074 
0075     ppc_md.pci_exclude_device = pq2_pci_exclude_device;
0076 
0077     for_each_compatible_node(np, NULL, "fsl,pq2-pci")
0078         pq2_pci_add_bridge(np);
0079 }
0080 #endif