io.c 4.0 KB

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