![]() |
|
|||
0001 // SPDX-License-Identifier: GPL-2.0+ 0002 /* 0003 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. 0004 * All rights reserved. 0005 * 0006 * Purpose:Implement functions to access eeprom 0007 * 0008 * Author: Jerry Chen 0009 * 0010 * Date: Jan 29, 2003 0011 * 0012 * Functions: 0013 * SROMbyReadEmbedded - Embedded read eeprom via MAC 0014 * SROMbWriteEmbedded - Embedded write eeprom via MAC 0015 * SROMvRegBitsOn - Set Bits On in eeprom 0016 * SROMvRegBitsOff - Clear Bits Off in eeprom 0017 * SROMbIsRegBitsOn - Test if Bits On in eeprom 0018 * SROMbIsRegBitsOff - Test if Bits Off in eeprom 0019 * SROMvReadAllContents - Read all contents in eeprom 0020 * SROMvWriteAllContents - Write all contents in eeprom 0021 * SROMvReadEtherAddress - Read Ethernet Address in eeprom 0022 * SROMvWriteEtherAddress - Write Ethernet Address in eeprom 0023 * SROMvReadSubSysVenId - Read Sub_VID and Sub_SysId in eeprom 0024 * SROMbAutoLoad - Auto Load eeprom to MAC register 0025 * 0026 * Revision History: 0027 * 0028 */ 0029 0030 #include "device.h" 0031 #include "mac.h" 0032 #include "srom.h" 0033 0034 /*--------------------- Static Definitions -------------------------*/ 0035 0036 /*--------------------- Static Classes ----------------------------*/ 0037 0038 /*--------------------- Static Variables --------------------------*/ 0039 0040 /*--------------------- Static Functions --------------------------*/ 0041 0042 /*--------------------- Export Variables --------------------------*/ 0043 0044 /*--------------------- Export Functions --------------------------*/ 0045 0046 /* 0047 * Description: Read a byte from EEPROM, by MAC I2C 0048 * 0049 * Parameters: 0050 * In: 0051 * iobase - I/O base address 0052 * byContntOffset - address of EEPROM 0053 * Out: 0054 * none 0055 * 0056 * Return Value: data read 0057 * 0058 */ 0059 unsigned char SROMbyReadEmbedded(void __iomem *iobase, 0060 unsigned char byContntOffset) 0061 { 0062 unsigned short wDelay, wNoACK; 0063 unsigned char byWait; 0064 unsigned char byData; 0065 unsigned char byOrg; 0066 0067 byData = 0xFF; 0068 byOrg = ioread8(iobase + MAC_REG_I2MCFG); 0069 /* turn off hardware retry for getting NACK */ 0070 iowrite8(byOrg & (~I2MCFG_NORETRY), iobase + MAC_REG_I2MCFG); 0071 for (wNoACK = 0; wNoACK < W_MAX_I2CRETRY; wNoACK++) { 0072 iowrite8(EEP_I2C_DEV_ID, iobase + MAC_REG_I2MTGID); 0073 iowrite8(byContntOffset, iobase + MAC_REG_I2MTGAD); 0074 0075 /* issue read command */ 0076 iowrite8(I2MCSR_EEMR, iobase + MAC_REG_I2MCSR); 0077 /* wait DONE be set */ 0078 for (wDelay = 0; wDelay < W_MAX_TIMEOUT; wDelay++) { 0079 byWait = ioread8(iobase + MAC_REG_I2MCSR); 0080 if (byWait & (I2MCSR_DONE | I2MCSR_NACK)) 0081 break; 0082 udelay(CB_DELAY_LOOP_WAIT); 0083 } 0084 if ((wDelay < W_MAX_TIMEOUT) && 0085 (!(byWait & I2MCSR_NACK))) { 0086 break; 0087 } 0088 } 0089 byData = ioread8(iobase + MAC_REG_I2MDIPT); 0090 iowrite8(byOrg, iobase + MAC_REG_I2MCFG); 0091 return byData; 0092 } 0093 0094 /* 0095 * Description: Read all contents of eeprom to buffer 0096 * 0097 * Parameters: 0098 * In: 0099 * iobase - I/O base address 0100 * Out: 0101 * pbyEepromRegs - EEPROM content Buffer 0102 * 0103 * Return Value: none 0104 * 0105 */ 0106 void SROMvReadAllContents(void __iomem *iobase, unsigned char *pbyEepromRegs) 0107 { 0108 int ii; 0109 0110 /* ii = Rom Address */ 0111 for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) { 0112 *pbyEepromRegs = SROMbyReadEmbedded(iobase, 0113 (unsigned char)ii); 0114 pbyEepromRegs++; 0115 } 0116 } 0117 0118 /* 0119 * Description: Read Ethernet Address from eeprom to buffer 0120 * 0121 * Parameters: 0122 * In: 0123 * iobase - I/O base address 0124 * Out: 0125 * pbyEtherAddress - Ethernet Address buffer 0126 * 0127 * Return Value: none 0128 * 0129 */ 0130 void SROMvReadEtherAddress(void __iomem *iobase, 0131 unsigned char *pbyEtherAddress) 0132 { 0133 unsigned char ii; 0134 0135 /* ii = Rom Address */ 0136 for (ii = 0; ii < ETH_ALEN; ii++) { 0137 *pbyEtherAddress = SROMbyReadEmbedded(iobase, ii); 0138 pbyEtherAddress++; 0139 } 0140 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |