pq2.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Common PowerQUICC II code.
  4. *
  5. * Author: Scott Wood <[email protected]>
  6. * Copyright (c) 2007 Freescale Semiconductor
  7. *
  8. * Based on code by Vitaly Bordug <[email protected]>
  9. * pq2_restart fix by Wade Farnsworth <[email protected]>
  10. * Copyright (c) 2006 MontaVista Software, Inc.
  11. */
  12. #include <linux/kprobes.h>
  13. #include <asm/cpm2.h>
  14. #include <asm/io.h>
  15. #include <asm/pci-bridge.h>
  16. #include <platforms/82xx/pq2.h>
  17. #define RMR_CSRE 0x00000001
  18. void __noreturn pq2_restart(char *cmd)
  19. {
  20. local_irq_disable();
  21. setbits32(&cpm2_immr->im_clkrst.car_rmr, RMR_CSRE);
  22. /* Clear the ME,EE,IR & DR bits in MSR to cause checkstop */
  23. mtmsr(mfmsr() & ~(MSR_ME | MSR_EE | MSR_IR | MSR_DR));
  24. in_8(&cpm2_immr->im_clkrst.res[0]);
  25. panic("Restart failed\n");
  26. }
  27. NOKPROBE_SYMBOL(pq2_restart)
  28. #ifdef CONFIG_PCI
  29. static int pq2_pci_exclude_device(struct pci_controller *hose,
  30. u_char bus, u8 devfn)
  31. {
  32. if (bus == 0 && PCI_SLOT(devfn) == 0)
  33. return PCIBIOS_DEVICE_NOT_FOUND;
  34. else
  35. return PCIBIOS_SUCCESSFUL;
  36. }
  37. static void __init pq2_pci_add_bridge(struct device_node *np)
  38. {
  39. struct pci_controller *hose;
  40. struct resource r;
  41. if (of_address_to_resource(np, 0, &r) || r.end - r.start < 0x10b)
  42. goto err;
  43. pci_add_flags(PCI_REASSIGN_ALL_BUS);
  44. hose = pcibios_alloc_controller(np);
  45. if (!hose)
  46. return;
  47. hose->dn = np;
  48. setup_indirect_pci(hose, r.start + 0x100, r.start + 0x104, 0);
  49. pci_process_bridge_OF_ranges(hose, np, 1);
  50. return;
  51. err:
  52. printk(KERN_ERR "No valid PCI reg property in device tree\n");
  53. }
  54. void __init pq2_init_pci(void)
  55. {
  56. struct device_node *np;
  57. ppc_md.pci_exclude_device = pq2_pci_exclude_device;
  58. for_each_compatible_node(np, NULL, "fsl,pq2-pci")
  59. pq2_pci_add_bridge(np);
  60. }
  61. #endif