e1000_osdep.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*******************************************************************************
  2. Intel PRO/1000 Linux driver
  3. Copyright(c) 1999 - 2006 Intel Corporation.
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms and conditions of the GNU General Public License,
  6. version 2, as published by the Free Software Foundation.
  7. This program is distributed in the hope 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.,
  13. 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  14. The full GNU General Public License is included in this distribution in
  15. the file called "COPYING".
  16. Contact Information:
  17. Linux NICS <linux.nics@intel.com>
  18. e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  19. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  20. *******************************************************************************/
  21. /* glue for the OS independent part of e1000
  22. * includes register access macros
  23. */
  24. #ifndef _E1000_OSDEP_H_
  25. #define _E1000_OSDEP_H_
  26. #include <linux/types.h>
  27. #include <linux/pci.h>
  28. #include <linux/delay.h>
  29. #include <asm/io.h>
  30. #include <linux/interrupt.h>
  31. #include <linux/sched.h>
  32. #ifdef DBG
  33. #define DEBUGOUT(S) printk(KERN_DEBUG S "\n")
  34. #define DEBUGOUT1(S, A...) printk(KERN_DEBUG S "\n", A)
  35. #else
  36. #define DEBUGOUT(S)
  37. #define DEBUGOUT1(S, A...)
  38. #endif
  39. #define DEBUGFUNC(F) DEBUGOUT(F "\n")
  40. #define DEBUGOUT2 DEBUGOUT1
  41. #define DEBUGOUT3 DEBUGOUT2
  42. #define DEBUGOUT7 DEBUGOUT3
  43. #define er32(reg) \
  44. (readl(hw->hw_addr + ((hw->mac_type >= e1000_82543) \
  45. ? E1000_##reg : E1000_82542_##reg)))
  46. #define ew32(reg, value) \
  47. (writel((value), (hw->hw_addr + ((hw->mac_type >= e1000_82543) \
  48. ? E1000_##reg : E1000_82542_##reg))))
  49. #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \
  50. writel((value), ((a)->hw_addr + \
  51. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  52. ((offset) << 2))))
  53. #define E1000_READ_REG_ARRAY(a, reg, offset) ( \
  54. readl((a)->hw_addr + \
  55. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  56. ((offset) << 2)))
  57. #define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY
  58. #define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY
  59. #define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \
  60. writew((value), ((a)->hw_addr + \
  61. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  62. ((offset) << 1))))
  63. #define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \
  64. readw((a)->hw_addr + \
  65. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  66. ((offset) << 1)))
  67. #define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \
  68. writeb((value), ((a)->hw_addr + \
  69. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  70. (offset))))
  71. #define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \
  72. readb((a)->hw_addr + \
  73. (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
  74. (offset)))
  75. #define E1000_WRITE_FLUSH() er32(STATUS)
  76. #define E1000_WRITE_ICH_FLASH_REG(a, reg, value) ( \
  77. writel((value), ((a)->flash_address + reg)))
  78. #define E1000_READ_ICH_FLASH_REG(a, reg) ( \
  79. readl((a)->flash_address + reg))
  80. #define E1000_WRITE_ICH_FLASH_REG16(a, reg, value) ( \
  81. writew((value), ((a)->flash_address + reg)))
  82. #define E1000_READ_ICH_FLASH_REG16(a, reg) ( \
  83. readw((a)->flash_address + reg))
  84. #endif /* _E1000_OSDEP_H_ */