iomv.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2000-2003 Silicon Graphics, Inc. All rights reserved.
  7. */
  8. #include <linux/module.h>
  9. #include <asm/io.h>
  10. #include <asm/delay.h>
  11. #include <asm/sn/nodepda.h>
  12. #include <asm/sn/simulator.h>
  13. #include <asm/sn/pda.h>
  14. #include <asm/sn/sn_cpuid.h>
  15. #include <asm/sn/shub_mmr.h>
  16. /**
  17. * sn_io_addr - convert an in/out port to an i/o address
  18. * @port: port to convert
  19. *
  20. * Legacy in/out instructions are converted to ld/st instructions
  21. * on IA64. This routine will convert a port number into a valid
  22. * SN i/o address. Used by sn_in*() and sn_out*().
  23. */
  24. void *sn_io_addr(unsigned long port)
  25. {
  26. if (!IS_RUNNING_ON_SIMULATOR()) {
  27. /* On sn2, legacy I/O ports don't point at anything */
  28. if (port < (64 * 1024))
  29. return NULL;
  30. return ((void *)(port | __IA64_UNCACHED_OFFSET));
  31. } else {
  32. /* but the simulator uses them... */
  33. unsigned long addr;
  34. /*
  35. * word align port, but need more than 10 bits
  36. * for accessing registers in bedrock local block
  37. * (so we don't do port&0xfff)
  38. */
  39. addr = (is_shub2() ? 0xc00000028c000000UL : 0xc0000087cc000000UL) | ((port >> 2) << 12);
  40. if ((port >= 0x1f0 && port <= 0x1f7) || port == 0x3f6 || port == 0x3f7)
  41. addr |= port;
  42. return (void *)addr;
  43. }
  44. }
  45. EXPORT_SYMBOL(sn_io_addr);
  46. /**
  47. * __sn_mmiowb - I/O space memory barrier
  48. *
  49. * See include/asm-ia64/io.h and Documentation/DocBook/deviceiobook.tmpl
  50. * for details.
  51. *
  52. * On SN2, we wait for the PIO_WRITE_STATUS SHub register to clear.
  53. * See PV 871084 for details about the WAR about zero value.
  54. *
  55. */
  56. void __sn_mmiowb(void)
  57. {
  58. volatile unsigned long *adr = pda->pio_write_status_addr;
  59. unsigned long val = pda->pio_write_status_val;
  60. while ((*adr & SH_PIO_WRITE_STATUS_PENDING_WRITE_COUNT_MASK) != val)
  61. cpu_relax();
  62. }
  63. EXPORT_SYMBOL(__sn_mmiowb);