ab@2201: /*******************************************************************************
ab@2201: 
ab@2201:   Intel PRO/1000 Linux driver
ab@2201:   Copyright(c) 1999 - 2006 Intel Corporation.
ab@2201: 
ab@2201:   This program is free software; you can redistribute it and/or modify it
ab@2201:   under the terms and conditions of the GNU General Public License,
ab@2201:   version 2, as published by the Free Software Foundation.
ab@2201: 
ab@2201:   This program is distributed in the hope it will be useful, but WITHOUT
ab@2201:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ab@2201:   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
ab@2201:   more details.
ab@2201: 
ab@2201:   You should have received a copy of the GNU General Public License along with
ab@2201:   this program; if not, write to the Free Software Foundation, Inc.,
ab@2201:   51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
ab@2201: 
ab@2201:   The full GNU General Public License is included in this distribution in
ab@2201:   the file called "COPYING".
ab@2201: 
ab@2201:   Contact Information:
ab@2201:   Linux NICS <linux.nics@intel.com>
ab@2201:   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
ab@2201:   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
ab@2201: 
ab@2201: *******************************************************************************/
ab@2201: 
ab@2201: 
ab@2201: /* glue for the OS independent part of e1000
ab@2201:  * includes register access macros
ab@2201:  */
ab@2201: 
ab@2201: #ifndef _E1000_OSDEP_H_
ab@2201: #define _E1000_OSDEP_H_
ab@2201: 
ab@2201: #include <linux/types.h>
ab@2201: #include <linux/pci.h>
ab@2201: #include <linux/delay.h>
ab@2201: #include <asm/io.h>
ab@2201: #include <linux/interrupt.h>
ab@2201: #include <linux/sched.h>
ab@2201: 
ab@2201: #ifdef DBG
ab@2201: #define DEBUGOUT(S)		printk(KERN_DEBUG S "\n")
ab@2201: #define DEBUGOUT1(S, A...)	printk(KERN_DEBUG S "\n", A)
ab@2201: #else
ab@2201: #define DEBUGOUT(S)
ab@2201: #define DEBUGOUT1(S, A...)
ab@2201: #endif
ab@2201: 
ab@2201: #define DEBUGFUNC(F) DEBUGOUT(F "\n")
ab@2201: #define DEBUGOUT2 DEBUGOUT1
ab@2201: #define DEBUGOUT3 DEBUGOUT2
ab@2201: #define DEBUGOUT7 DEBUGOUT3
ab@2201: 
ab@2201: 
ab@2201: #define er32(reg)							\
ab@2201: 	(readl(hw->hw_addr + ((hw->mac_type >= e1000_82543)		\
ab@2201: 			       ? E1000_##reg : E1000_82542_##reg)))
ab@2201: 
ab@2201: #define ew32(reg, value)						\
ab@2201: 	(writel((value), (hw->hw_addr + ((hw->mac_type >= e1000_82543)	\
ab@2201: 					 ? E1000_##reg : E1000_82542_##reg))))
ab@2201: 
ab@2201: #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \
ab@2201:     writel((value), ((a)->hw_addr + \
ab@2201:         (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
ab@2201:         ((offset) << 2))))
ab@2201: 
ab@2201: #define E1000_READ_REG_ARRAY(a, reg, offset) ( \
ab@2201:     readl((a)->hw_addr + \
ab@2201:         (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
ab@2201:         ((offset) << 2)))
ab@2201: 
ab@2201: #define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY
ab@2201: #define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY
ab@2201: 
ab@2201: #define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \
ab@2201:     writew((value), ((a)->hw_addr + \
ab@2201:         (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
ab@2201:         ((offset) << 1))))
ab@2201: 
ab@2201: #define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \
ab@2201:     readw((a)->hw_addr + \
ab@2201:         (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
ab@2201:         ((offset) << 1)))
ab@2201: 
ab@2201: #define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \
ab@2201:     writeb((value), ((a)->hw_addr + \
ab@2201:         (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
ab@2201:         (offset))))
ab@2201: 
ab@2201: #define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \
ab@2201:     readb((a)->hw_addr + \
ab@2201:         (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \
ab@2201:         (offset)))
ab@2201: 
ab@2201: #define E1000_WRITE_FLUSH() er32(STATUS)
ab@2201: 
ab@2201: #define E1000_WRITE_ICH_FLASH_REG(a, reg, value) ( \
ab@2201:     writel((value), ((a)->flash_address + reg)))
ab@2201: 
ab@2201: #define E1000_READ_ICH_FLASH_REG(a, reg) ( \
ab@2201:     readl((a)->flash_address + reg))
ab@2201: 
ab@2201: #define E1000_WRITE_ICH_FLASH_REG16(a, reg, value) ( \
ab@2201:     writew((value), ((a)->flash_address + reg)))
ab@2201: 
ab@2201: #define E1000_READ_ICH_FLASH_REG16(a, reg) ( \
ab@2201:     readw((a)->flash_address + reg))
ab@2201: 
ab@2201: #endif /* _E1000_OSDEP_H_ */