18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* Copyright(c) 1999 - 2006 Intel Corporation. */ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci/* glue for the OS independent part of e1000 58c2ecf20Sopenharmony_ci * includes register access macros 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _E1000_OSDEP_H_ 98c2ecf20Sopenharmony_ci#define _E1000_OSDEP_H_ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <asm/io.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#define CONFIG_RAM_BASE 0x60000 148c2ecf20Sopenharmony_ci#define GBE_CONFIG_OFFSET 0x0 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#define GBE_CONFIG_RAM_BASE \ 178c2ecf20Sopenharmony_ci ((unsigned int)(CONFIG_RAM_BASE + GBE_CONFIG_OFFSET)) 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#define GBE_CONFIG_BASE_VIRT \ 208c2ecf20Sopenharmony_ci ((void __iomem *)phys_to_virt(GBE_CONFIG_RAM_BASE)) 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define GBE_CONFIG_FLASH_WRITE(base, offset, count, data) \ 238c2ecf20Sopenharmony_ci (iowrite16_rep(base + offset, data, count)) 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#define GBE_CONFIG_FLASH_READ(base, offset, count, data) \ 268c2ecf20Sopenharmony_ci (ioread16_rep(base + (offset << 1), data, count)) 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define er32(reg) \ 298c2ecf20Sopenharmony_ci (readl(hw->hw_addr + ((hw->mac_type >= e1000_82543) \ 308c2ecf20Sopenharmony_ci ? E1000_##reg : E1000_82542_##reg))) 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define ew32(reg, value) \ 338c2ecf20Sopenharmony_ci (writel((value), (hw->hw_addr + ((hw->mac_type >= e1000_82543) \ 348c2ecf20Sopenharmony_ci ? E1000_##reg : E1000_82542_##reg)))) 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \ 378c2ecf20Sopenharmony_ci writel((value), ((a)->hw_addr + \ 388c2ecf20Sopenharmony_ci (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \ 398c2ecf20Sopenharmony_ci ((offset) << 2)))) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define E1000_READ_REG_ARRAY(a, reg, offset) ( \ 428c2ecf20Sopenharmony_ci readl((a)->hw_addr + \ 438c2ecf20Sopenharmony_ci (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \ 448c2ecf20Sopenharmony_ci ((offset) << 2))) 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define E1000_READ_REG_ARRAY_DWORD E1000_READ_REG_ARRAY 478c2ecf20Sopenharmony_ci#define E1000_WRITE_REG_ARRAY_DWORD E1000_WRITE_REG_ARRAY 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci#define E1000_WRITE_REG_ARRAY_WORD(a, reg, offset, value) ( \ 508c2ecf20Sopenharmony_ci writew((value), ((a)->hw_addr + \ 518c2ecf20Sopenharmony_ci (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \ 528c2ecf20Sopenharmony_ci ((offset) << 1)))) 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#define E1000_READ_REG_ARRAY_WORD(a, reg, offset) ( \ 558c2ecf20Sopenharmony_ci readw((a)->hw_addr + \ 568c2ecf20Sopenharmony_ci (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \ 578c2ecf20Sopenharmony_ci ((offset) << 1))) 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#define E1000_WRITE_REG_ARRAY_BYTE(a, reg, offset, value) ( \ 608c2ecf20Sopenharmony_ci writeb((value), ((a)->hw_addr + \ 618c2ecf20Sopenharmony_ci (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \ 628c2ecf20Sopenharmony_ci (offset)))) 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define E1000_READ_REG_ARRAY_BYTE(a, reg, offset) ( \ 658c2ecf20Sopenharmony_ci readb((a)->hw_addr + \ 668c2ecf20Sopenharmony_ci (((a)->mac_type >= e1000_82543) ? E1000_##reg : E1000_82542_##reg) + \ 678c2ecf20Sopenharmony_ci (offset))) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#define E1000_WRITE_FLUSH() er32(STATUS) 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci#define E1000_WRITE_ICH_FLASH_REG(a, reg, value) ( \ 728c2ecf20Sopenharmony_ci writel((value), ((a)->flash_address + reg))) 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#define E1000_READ_ICH_FLASH_REG(a, reg) ( \ 758c2ecf20Sopenharmony_ci readl((a)->flash_address + reg)) 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#define E1000_WRITE_ICH_FLASH_REG16(a, reg, value) ( \ 788c2ecf20Sopenharmony_ci writew((value), ((a)->flash_address + reg))) 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci#define E1000_READ_ICH_FLASH_REG16(a, reg) ( \ 818c2ecf20Sopenharmony_ci readw((a)->flash_address + reg)) 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#endif /* _E1000_OSDEP_H_ */ 84