e1000_osdep.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*******************************************************************************
  2. Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
  3. This program is free software; you can redistribute it and/or modify it
  4. under the terms of the GNU General Public License as published by the Free
  5. Software Foundation; either version 2 of the License, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. this program; if not, write to the Free Software Foundation, Inc., 59
  13. Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. The full GNU General Public License is included in this distribution in the
  15. file called LICENSE.
  16. Contact Information:
  17. Linux NICS <linux.nics@intel.com>
  18. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  19. *******************************************************************************/
  20. /* glue for the OS independent part of e1000
  21. * includes register access macros
  22. */
  23. #ifndef _E1000_OSDEP_H_
  24. #define _E1000_OSDEP_H_
  25. #include <linux/types.h>
  26. #include <linux/pci.h>
  27. #include <linux/delay.h>
  28. #include <asm/io.h>
  29. #include <linux/interrupt.h>
  30. #include <linux/sched.h>
  31. #ifndef msec_delay
  32. #define msec_delay(x) do { if(in_interrupt()) { \
  33. /* Don't mdelay in interrupt context! */ \
  34. BUG(); \
  35. } else { \
  36. msleep(x); \
  37. } } while (0)
  38. /* Some workarounds require millisecond delays and are run during interrupt
  39. * context. Most notably, when establishing link, the phy may need tweaking
  40. * but cannot process phy register reads/writes faster than millisecond
  41. * intervals...and we establish link due to a "link status change" interrupt.
  42. */
  43. #define msec_delay_irq(x) mdelay(x)
  44. #endif
  45. #define PCI_COMMAND_REGISTER PCI_COMMAND
  46. #define CMD_MEM_WRT_INVALIDATE PCI_COMMAND_INVALIDATE
  47. typedef enum {
  48. #undef FALSE
  49. FALSE = 0,
  50. #undef TRUE
  51. TRUE = 1
  52. } boolean_t;
  53. #define MSGOUT(S, A, B) printk(KERN_DEBUG S "\n", A, B)
  54. #ifdef DBG
  55. #define DEBUGOUT(S) printk(KERN_DEBUG S "\n")
  56. #define DEBUGOUT1(S, A...) printk(KERN_DEBUG S "\n", A)
  57. #else
  58. #define DEBUGOUT(S)
  59. #define DEBUGOUT1(S, A...)
  60. #endif
  61. #define DEBUGFUNC(F) DEBUGOUT(F)
  62. #define DEBUGOUT2 DEBUGOUT1
  63. #define DEBUGOUT3 DEBUGOUT2
  64. #define DEBUGOUT7 DEBUGOUT3
  65. #define E1000_WRITE_REG(a, reg, value) ( \
  66. writel((value), ((a)->hw_addr + \
  67. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg))))
  68. #define E1000_READ_REG(a, reg) ( \
  69. readl((a)->hw_addr + \
  70. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg)))
  71. #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \
  72. writel((value), ((a)->hw_addr + \
  73. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  74. ((offset) << 2))))
  75. #define E1000_READ_REG_ARRAY(a, reg, offset) ( \
  76. readl((a)->hw_addr + \
  77. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  78. ((offset) << 2)))
  79. #define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY
  80. #define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY
  81. #define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \
  82. writew((value), ((a)->hw_addr + \
  83. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  84. ((offset) << 1))))
  85. #define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \
  86. readw((a)->hw_addr + \
  87. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  88. ((offset) << 1)))
  89. #define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \
  90. writeb((value), ((a)->hw_addr + \
  91. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  92. (offset))))
  93. #define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \
  94. readb((a)->hw_addr + \
  95. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  96. (offset)))
  97. #define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS)
  98. #endif /* _E1000_OSDEP_H_ */