io.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * linux/arch/sh/boards/superh/microdev/io.c
  3. *
  4. * Copyright (C) 2003 Sean McGoogan (Sean.McGoogan@superh.com)
  5. * Copyright (C) 2003, 2004 SuperH, Inc.
  6. * Copyright (C) 2004 Paul Mundt
  7. *
  8. * SuperH SH4-202 MicroDev board support.
  9. *
  10. * May be copied or modified under the terms of the GNU General Public
  11. * License. See linux/COPYING for more information.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/pci.h>
  15. #include <linux/wait.h>
  16. #include <asm/io.h>
  17. #include <mach/microdev.h>
  18. /*
  19. * we need to have a 'safe' address to re-direct all I/O requests
  20. * that we do not explicitly wish to handle. This safe address
  21. * must have the following properies:
  22. *
  23. * * writes are ignored (no exception)
  24. * * reads are benign (no side-effects)
  25. * * accesses of width 1, 2 and 4-bytes are all valid.
  26. *
  27. * The Processor Version Register (PVR) has these properties.
  28. */
  29. #define PVR 0xff000030 /* Processor Version Register */
  30. #define IO_IDE2_BASE 0x170ul /* I/O base for SMSC FDC37C93xAPM IDE #2 */
  31. #define IO_IDE1_BASE 0x1f0ul /* I/O base for SMSC FDC37C93xAPM IDE #1 */
  32. #define IO_ISP1161_BASE 0x290ul /* I/O port for Philips ISP1161x USB chip */
  33. #define IO_SERIAL2_BASE 0x2f8ul /* I/O base for SMSC FDC37C93xAPM Serial #2 */
  34. #define IO_LAN91C111_BASE 0x300ul /* I/O base for SMSC LAN91C111 Ethernet chip */
  35. #define IO_IDE2_MISC 0x376ul /* I/O misc for SMSC FDC37C93xAPM IDE #2 */
  36. #define IO_SUPERIO_BASE 0x3f0ul /* I/O base for SMSC FDC37C93xAPM SuperIO chip */
  37. #define IO_IDE1_MISC 0x3f6ul /* I/O misc for SMSC FDC37C93xAPM IDE #1 */
  38. #define IO_SERIAL1_BASE 0x3f8ul /* I/O base for SMSC FDC37C93xAPM Serial #1 */
  39. #define IO_ISP1161_EXTENT 0x04ul /* I/O extent for Philips ISP1161x USB chip */
  40. #define IO_LAN91C111_EXTENT 0x10ul /* I/O extent for SMSC LAN91C111 Ethernet chip */
  41. #define IO_SUPERIO_EXTENT 0x02ul /* I/O extent for SMSC FDC37C93xAPM SuperIO chip */
  42. #define IO_IDE_EXTENT 0x08ul /* I/O extent for IDE Task Register set */
  43. #define IO_SERIAL_EXTENT 0x10ul
  44. #define IO_LAN91C111_PHYS 0xa7500000ul /* Physical address of SMSC LAN91C111 Ethernet chip */
  45. #define IO_ISP1161_PHYS 0xa7700000ul /* Physical address of Philips ISP1161x USB chip */
  46. #define IO_SUPERIO_PHYS 0xa7800000ul /* Physical address of SMSC FDC37C93xAPM SuperIO chip */
  47. /*
  48. * map I/O ports to memory-mapped addresses
  49. */
  50. void __iomem *microdev_ioport_map(unsigned long offset, unsigned int len)
  51. {
  52. unsigned long result;
  53. if ((offset >= IO_LAN91C111_BASE) &&
  54. (offset < IO_LAN91C111_BASE + IO_LAN91C111_EXTENT)) {
  55. /*
  56. * SMSC LAN91C111 Ethernet chip
  57. */
  58. result = IO_LAN91C111_PHYS + offset - IO_LAN91C111_BASE;
  59. } else if ((offset >= IO_SUPERIO_BASE) &&
  60. (offset < IO_SUPERIO_BASE + IO_SUPERIO_EXTENT)) {
  61. /*
  62. * SMSC FDC37C93xAPM SuperIO chip
  63. *
  64. * Configuration Registers
  65. */
  66. result = IO_SUPERIO_PHYS + (offset << 1);
  67. } else if (((offset >= IO_IDE1_BASE) &&
  68. (offset < IO_IDE1_BASE + IO_IDE_EXTENT)) ||
  69. (offset == IO_IDE1_MISC)) {
  70. /*
  71. * SMSC FDC37C93xAPM SuperIO chip
  72. *
  73. * IDE #1
  74. */
  75. result = IO_SUPERIO_PHYS + (offset << 1);
  76. } else if (((offset >= IO_IDE2_BASE) &&
  77. (offset < IO_IDE2_BASE + IO_IDE_EXTENT)) ||
  78. (offset == IO_IDE2_MISC)) {
  79. /*
  80. * SMSC FDC37C93xAPM SuperIO chip
  81. *
  82. * IDE #2
  83. */
  84. result = IO_SUPERIO_PHYS + (offset << 1);
  85. } else if ((offset >= IO_SERIAL1_BASE) &&
  86. (offset < IO_SERIAL1_BASE + IO_SERIAL_EXTENT)) {
  87. /*
  88. * SMSC FDC37C93xAPM SuperIO chip
  89. *
  90. * Serial #1
  91. */
  92. result = IO_SUPERIO_PHYS + (offset << 1);
  93. } else if ((offset >= IO_SERIAL2_BASE) &&
  94. (offset < IO_SERIAL2_BASE + IO_SERIAL_EXTENT)) {
  95. /*
  96. * SMSC FDC37C93xAPM SuperIO chip
  97. *
  98. * Serial #2
  99. */
  100. result = IO_SUPERIO_PHYS + (offset << 1);
  101. } else if ((offset >= IO_ISP1161_BASE) &&
  102. (offset < IO_ISP1161_BASE + IO_ISP1161_EXTENT)) {
  103. /*
  104. * Philips USB ISP1161x chip
  105. */
  106. result = IO_ISP1161_PHYS + offset - IO_ISP1161_BASE;
  107. } else {
  108. /*
  109. * safe default.
  110. */
  111. printk("Warning: unexpected port in %s( offset = 0x%lx )\n",
  112. __func__, offset);
  113. result = PVR;
  114. }
  115. return (void __iomem *)result;
  116. }