blob: 46bc49df15e78e896a532666aa3aa6604c6a84d2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*******************************************************************************
2
3
Auke Kok3d41e302006-04-14 19:05:31 -07004 Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
15
16 You should have received a copy of the GNU General Public License along with
17 this program; if not, write to the Free Software Foundation, Inc., 59
18 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 The full GNU General Public License is included in this distribution in the
21 file called LICENSE.
22
23 Contact Information:
24 Linux NICS <linux.nics@intel.com>
Auke Kok3d41e302006-04-14 19:05:31 -070025 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27
28*******************************************************************************/
29
30
31/* glue for the OS independent part of e1000
32 * includes register access macros
33 */
34
35#ifndef _E1000_OSDEP_H_
36#define _E1000_OSDEP_H_
37
38#include <linux/types.h>
39#include <linux/pci.h>
40#include <linux/delay.h>
41#include <asm/io.h>
42#include <linux/interrupt.h>
43#include <linux/sched.h>
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045typedef enum {
46#undef FALSE
47 FALSE = 0,
48#undef TRUE
49 TRUE = 1
50} boolean_t;
51
52#define MSGOUT(S, A, B) printk(KERN_DEBUG S "\n", A, B)
53
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
62#define DEBUGFUNC(F) DEBUGOUT(F)
63#define DEBUGOUT2 DEBUGOUT1
64#define DEBUGOUT3 DEBUGOUT2
65#define DEBUGOUT7 DEBUGOUT3
66
67
68#define E1000_WRITE_REG(a, reg, value) ( \
69 writel((value), ((a)->hw_addr + \
70 (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg))))
71
72#define E1000_READ_REG(a, reg) ( \
73 readl((a)->hw_addr + \
74 (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg)))
75
76#define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \
77 writel((value), ((a)->hw_addr + \
78 (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
79 ((offset) << 2))))
80
81#define E1000_READ_REG_ARRAY(a, reg, offset) ( \
82 readl((a)->hw_addr + \
83 (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
84 ((offset) << 2)))
85
Malli Chilakala2d7edb92005-04-28 19:43:52 -070086#define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY
87#define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY
88
89#define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \
90 writew((value), ((a)->hw_addr + \
91 (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
92 ((offset) << 1))))
93
94#define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \
95 readw((a)->hw_addr + \
96 (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
97 ((offset) << 1)))
98
99#define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \
100 writeb((value), ((a)->hw_addr + \
101 (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
102 (offset))))
103
104#define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \
105 readb((a)->hw_addr + \
106 (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
107 (offset)))
108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109#define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS)
110
Auke Kokd37ea5d2006-06-27 09:08:17 -0700111#define E1000_WRITE_ICH8_REG(a, reg, value) ( \
112 writel((value), ((a)->flash_address + reg)))
113
114#define E1000_READ_ICH8_REG(a, reg) ( \
115 readl((a)->flash_address + reg))
116
117#define E1000_WRITE_ICH8_REG16(a, reg, value) ( \
118 writew((value), ((a)->flash_address + reg)))
119
120#define E1000_READ_ICH8_REG16(a, reg) ( \
121 readw((a)->flash_address + reg))
122
123
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124#endif /* _E1000_OSDEP_H_ */