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