grackle.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Functions for setting up and using a MPC106 northbridge
  3. * Extracted from arch/powerpc/platforms/powermac/pci.c.
  4. *
  5. * Copyright (C) 2003 Benjamin Herrenschmuidt (benh@kernel.crashing.org)
  6. * Copyright (C) 1997 Paul Mackerras (paulus@samba.org)
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version
  11. * 2 of the License, or (at your option) any later version.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/pci.h>
  15. #include <linux/init.h>
  16. #include <asm/io.h>
  17. #include <asm/prom.h>
  18. #include <asm/pci-bridge.h>
  19. #include <asm/grackle.h>
  20. #define GRACKLE_CFA(b, d, o) (0x80 | ((b) << 8) | ((d) << 16) \
  21. | (((o) & ~3) << 24))
  22. #define GRACKLE_PICR1_STG 0x00000040
  23. #define GRACKLE_PICR1_LOOPSNOOP 0x00000010
  24. /* N.B. this is called before bridges is initialized, so we can't
  25. use grackle_pcibios_{read,write}_config_dword. */
  26. static inline void grackle_set_stg(struct pci_controller* bp, int enable)
  27. {
  28. unsigned int val;
  29. out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
  30. val = in_le32(bp->cfg_data);
  31. val = enable? (val | GRACKLE_PICR1_STG) :
  32. (val & ~GRACKLE_PICR1_STG);
  33. out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
  34. out_le32(bp->cfg_data, val);
  35. (void)in_le32(bp->cfg_data);
  36. }
  37. static inline void grackle_set_loop_snoop(struct pci_controller *bp, int enable)
  38. {
  39. unsigned int val;
  40. out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
  41. val = in_le32(bp->cfg_data);
  42. val = enable? (val | GRACKLE_PICR1_LOOPSNOOP) :
  43. (val & ~GRACKLE_PICR1_LOOPSNOOP);
  44. out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
  45. out_le32(bp->cfg_data, val);
  46. (void)in_le32(bp->cfg_data);
  47. }
  48. void __init setup_grackle(struct pci_controller *hose)
  49. {
  50. setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
  51. if (of_machine_is_compatible("PowerMac1,1"))
  52. pci_add_flags(PCI_REASSIGN_ALL_BUS);
  53. if (of_machine_is_compatible("AAPL,PowerBook1998"))
  54. grackle_set_loop_snoop(hose, 1);
  55. #if 0 /* Disabled for now, HW problems ??? */
  56. grackle_set_stg(hose, 1);
  57. #endif
  58. }