162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* Copyright(c) 1999 - 2006 Intel Corporation. */ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci/* glue for the OS independent part of e1000 562306a36Sopenharmony_ci * includes register access macros 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#ifndef _E1000_OSDEP_H_ 962306a36Sopenharmony_ci#define _E1000_OSDEP_H_ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include <asm/io.h> 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#define CONFIG_RAM_BASE 0x60000 1462306a36Sopenharmony_ci#define GBE_CONFIG_OFFSET 0x0 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci#define GBE_CONFIG_RAM_BASE \ 1762306a36Sopenharmony_ci ((unsigned int)(CONFIG_RAM_BASE + GBE_CONFIG_OFFSET)) 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci#define GBE_CONFIG_BASE_VIRT \ 2062306a36Sopenharmony_ci ((void __iomem *)phys_to_virt(GBE_CONFIG_RAM_BASE)) 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci#define GBE_CONFIG_FLASH_WRITE(base, offset, count, data) \ 2362306a36Sopenharmony_ci (iowrite16_rep(base + offset, data, count)) 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#define GBE_CONFIG_FLASH_READ(base, offset, count, data) \ 2662306a36Sopenharmony_ci (ioread16_rep(base + (offset << 1), data, count)) 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#define er32(reg) \ 2962306a36Sopenharmony_ci (readl(hw->hw_addr + ((hw->mac_type >= e1000_82543) \ 3062306a36Sopenharmony_ci ? E1000_##reg : E1000_82542_##reg))) 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci#define ew32(reg, value) \ 3362306a36Sopenharmony_ci (writel((value), (hw->hw_addr + ((hw->mac_type >= e1000_82543) \ 3462306a36Sopenharmony_ci ? E1000_##reg : E1000_82542_##reg)))) 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci#define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \ 3762306a36Sopenharmony_ci writel((value), ((a)->hw_addr + \ 3862306a36Sopenharmony_ci (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \ 3962306a36Sopenharmony_ci ((offset) << 2)))) 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci#define E1000_READ_REG_ARRAY(a, reg, offset) ( \ 4262306a36Sopenharmony_ci readl((a)->hw_addr + \ 4362306a36Sopenharmony_ci (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \ 4462306a36Sopenharmony_ci ((offset) << 2))) 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci#define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY 4762306a36Sopenharmony_ci#define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci#define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \ 5062306a36Sopenharmony_ci writew((value), ((a)->hw_addr + \ 5162306a36Sopenharmony_ci (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \ 5262306a36Sopenharmony_ci ((offset) << 1)))) 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci#define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \ 5562306a36Sopenharmony_ci readw((a)->hw_addr + \ 5662306a36Sopenharmony_ci (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \ 5762306a36Sopenharmony_ci ((offset) << 1))) 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci#define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \ 6062306a36Sopenharmony_ci writeb((value), ((a)->hw_addr + \ 6162306a36Sopenharmony_ci (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \ 6262306a36Sopenharmony_ci (offset)))) 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci#define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \ 6562306a36Sopenharmony_ci readb((a)->hw_addr + \ 6662306a36Sopenharmony_ci (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \ 6762306a36Sopenharmony_ci (offset))) 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci#define E1000_WRITE_FLUSH() er32(STATUS) 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci#define E1000_WRITE_ICH_FLASH_REG(a, reg, value) ( \ 7262306a36Sopenharmony_ci writel((value), ((a)->flash_address + reg))) 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci#define E1000_READ_ICH_FLASH_REG(a, reg) ( \ 7562306a36Sopenharmony_ci readl((a)->flash_address + reg)) 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci#define E1000_WRITE_ICH_FLASH_REG16(a, reg, value) ( \ 7862306a36Sopenharmony_ci writew((value), ((a)->flash_address + reg))) 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci#define E1000_READ_ICH_FLASH_REG16(a, reg) ( \ 8162306a36Sopenharmony_ci readw((a)->flash_address + reg)) 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci#endif /* _E1000_OSDEP_H_ */ 84