2 This files contains card eeprom (93c46 or 93c56) programming routines,
3 memory is addressed by 16 bits words.
5 This is part of rtl8180 OpenSource driver.
6 Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it>
7 Released under the terms of GPL (General Public Licence)
9 Parts of this driver are based on the GPL part of the
10 official realtek driver.
12 Parts of this driver are based on the rtl8180 driver skeleton
13 from Patric Schenke & Andres Salomon.
15 Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver.
17 We want to thank the Authors of those projects and the Ndiswrapper
21 #include "r8180_93cx6.h"
23 void eprom_cs(struct net_device *dev, short bit)
27 read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
30 write_nic_byte_E(dev, EPROM_CMD, cmdreg | EPROM_CS_BIT);
33 write_nic_byte_E(dev, EPROM_CMD, cmdreg & ~EPROM_CS_BIT);
35 force_pci_posting(dev);
40 void eprom_ck_cycle(struct net_device *dev)
44 read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
45 write_nic_byte_E(dev, EPROM_CMD, cmdreg | EPROM_CK_BIT);
46 force_pci_posting(dev);
49 read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
50 write_nic_byte_E(dev, EPROM_CMD, cmdreg & ~EPROM_CK_BIT);
51 force_pci_posting(dev);
56 void eprom_w(struct net_device *dev,short bit)
60 read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
62 write_nic_byte_E(dev, EPROM_CMD, cmdreg | EPROM_W_BIT);
64 write_nic_byte_E(dev, EPROM_CMD, cmdreg & ~EPROM_W_BIT);
66 force_pci_posting(dev);
71 short eprom_r(struct net_device *dev)
75 read_nic_byte_E(dev, EPROM_CMD, &bit);
78 if (bit & EPROM_R_BIT)
85 void eprom_send_bits_string(struct net_device *dev, short b[], int len)
96 u32 eprom_read(struct net_device *dev, u32 addr)
98 struct r8192_priv *priv = ieee80211_priv(dev);
99 short read_cmd[]={1,1,0};
106 //enable EPROM programming
107 write_nic_byte_E(dev, EPROM_CMD,
108 (EPROM_CMD_PROGRAM<<EPROM_CMD_OPERATING_MODE_SHIFT));
109 force_pci_posting(dev);
112 if (priv->epromtype==EPROM_93c56){
113 addr_str[7]=addr & 1;
114 addr_str[6]=addr & (1<<1);
115 addr_str[5]=addr & (1<<2);
116 addr_str[4]=addr & (1<<3);
117 addr_str[3]=addr & (1<<4);
118 addr_str[2]=addr & (1<<5);
119 addr_str[1]=addr & (1<<6);
120 addr_str[0]=addr & (1<<7);
123 addr_str[5]=addr & 1;
124 addr_str[4]=addr & (1<<1);
125 addr_str[3]=addr & (1<<2);
126 addr_str[2]=addr & (1<<3);
127 addr_str[1]=addr & (1<<4);
128 addr_str[0]=addr & (1<<5);
133 eprom_send_bits_string(dev, read_cmd, 3);
134 eprom_send_bits_string(dev, addr_str, addr_len);
136 //keep chip pin D to low state while reading.
137 //I'm unsure if it is necessary, but anyway shouldn't hurt
141 //eeprom needs a clk cycle between writing opcode&adr
142 //and reading data. (eeprom outs a dummy 0)
144 ret |= (eprom_r(dev)<<(15-i));
150 //disable EPROM programming
151 write_nic_byte_E(dev, EPROM_CMD,
152 (EPROM_CMD_NORMAL<<EPROM_CMD_OPERATING_MODE_SHIFT));