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