2009-11-03 09:17:11 +00:00
|
|
|
/*
|
|
|
|
This files contains card eeprom (93c46 or 93c56) programming routines,
|
|
|
|
memory is addressed by 16 bits words.
|
|
|
|
|
|
|
|
This is part of rtl8180 OpenSource driver.
|
2013-08-26 11:53:30 +00:00
|
|
|
Copyright (C) Andrea Merello 2004 <andrea.merello@gmail.com>
|
2009-11-03 09:17:11 +00:00
|
|
|
Released under the terms of GPL (General Public Licence)
|
|
|
|
|
|
|
|
Parts of this driver are based on the GPL part of the
|
|
|
|
official realtek driver.
|
|
|
|
|
|
|
|
Parts of this driver are based on the rtl8180 driver skeleton
|
|
|
|
from Patric Schenke & Andres Salomon.
|
|
|
|
|
|
|
|
Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver.
|
|
|
|
|
2012-04-30 20:45:41 +00:00
|
|
|
We want to thank the Authors of those projects and the Ndiswrapper
|
2009-11-03 09:17:11 +00:00
|
|
|
project Authors.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "r8180_93cx6.h"
|
|
|
|
|
2014-03-13 11:36:37 +00:00
|
|
|
static void eprom_cs(struct net_device *dev, short bit)
|
2009-11-03 09:17:11 +00:00
|
|
|
{
|
staging: rtl8192u: fix read_nic_* functions
read_nic_*() functions are defined in r8192U_core.c.
They call internally usb_control_msg() to read the
nic registers and return the value read.
Following a remark made by Dan Carpenter, if usb_control_msg()
fails, the value returned will be invalid.
To accommodate for this, this patch changes the functions
to take a pointer as argument to set the value read and
return 0 on success and the error status on failure, so
that callers of read_nic_*() can check the return status.
Some other fixes introduced in read_nic_*() functions are:
The expressions (1<<EPROM_*_SHIFT) used to address and set
the individual bits of the eeprom register were replaced
with EPROM_*_BIT bitmasks to make the code more intuitive.
EPROM_*_BIT bitmasks were defined in r8192U_hw.h and
EPROM_*_SHIFT were removed.
In netdev_err(), which is called in case of failure,
the hardcoded function name in the error log message was
replaced with __func__ to reduce line size.
Also, from the error log message, it was omitted the word
"Timeout" and it is just reported the error code since the
failure can not only be due to timeout expiration but also
due to a memory allocation failure. In case of timeout
expiration, usb_start_wait_urb() prints an appropriate log
message when debug is enabled.
Finally, some minor fixes to the coding style were applied in
lines affected by the above changes, including the removal
of ifdef DEBUG_RX (the debugging of reads and writes of the
nic registers shall be done with explicit check on their
return status which will be added in a follow on patch).
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 13:40:51 +00:00
|
|
|
u8 cmdreg;
|
|
|
|
|
|
|
|
read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
|
2013-05-13 17:15:49 +00:00
|
|
|
if (bit)
|
staging: rtl8192u: fix read_nic_* functions
read_nic_*() functions are defined in r8192U_core.c.
They call internally usb_control_msg() to read the
nic registers and return the value read.
Following a remark made by Dan Carpenter, if usb_control_msg()
fails, the value returned will be invalid.
To accommodate for this, this patch changes the functions
to take a pointer as argument to set the value read and
return 0 on success and the error status on failure, so
that callers of read_nic_*() can check the return status.
Some other fixes introduced in read_nic_*() functions are:
The expressions (1<<EPROM_*_SHIFT) used to address and set
the individual bits of the eeprom register were replaced
with EPROM_*_BIT bitmasks to make the code more intuitive.
EPROM_*_BIT bitmasks were defined in r8192U_hw.h and
EPROM_*_SHIFT were removed.
In netdev_err(), which is called in case of failure,
the hardcoded function name in the error log message was
replaced with __func__ to reduce line size.
Also, from the error log message, it was omitted the word
"Timeout" and it is just reported the error code since the
failure can not only be due to timeout expiration but also
due to a memory allocation failure. In case of timeout
expiration, usb_start_wait_urb() prints an appropriate log
message when debug is enabled.
Finally, some minor fixes to the coding style were applied in
lines affected by the above changes, including the removal
of ifdef DEBUG_RX (the debugging of reads and writes of the
nic registers shall be done with explicit check on their
return status which will be added in a follow on patch).
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 13:40:51 +00:00
|
|
|
/* enable EPROM */
|
|
|
|
write_nic_byte_E(dev, EPROM_CMD, cmdreg | EPROM_CS_BIT);
|
2009-11-03 09:17:11 +00:00
|
|
|
else
|
staging: rtl8192u: fix read_nic_* functions
read_nic_*() functions are defined in r8192U_core.c.
They call internally usb_control_msg() to read the
nic registers and return the value read.
Following a remark made by Dan Carpenter, if usb_control_msg()
fails, the value returned will be invalid.
To accommodate for this, this patch changes the functions
to take a pointer as argument to set the value read and
return 0 on success and the error status on failure, so
that callers of read_nic_*() can check the return status.
Some other fixes introduced in read_nic_*() functions are:
The expressions (1<<EPROM_*_SHIFT) used to address and set
the individual bits of the eeprom register were replaced
with EPROM_*_BIT bitmasks to make the code more intuitive.
EPROM_*_BIT bitmasks were defined in r8192U_hw.h and
EPROM_*_SHIFT were removed.
In netdev_err(), which is called in case of failure,
the hardcoded function name in the error log message was
replaced with __func__ to reduce line size.
Also, from the error log message, it was omitted the word
"Timeout" and it is just reported the error code since the
failure can not only be due to timeout expiration but also
due to a memory allocation failure. In case of timeout
expiration, usb_start_wait_urb() prints an appropriate log
message when debug is enabled.
Finally, some minor fixes to the coding style were applied in
lines affected by the above changes, including the removal
of ifdef DEBUG_RX (the debugging of reads and writes of the
nic registers shall be done with explicit check on their
return status which will be added in a follow on patch).
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 13:40:51 +00:00
|
|
|
/* disable EPROM */
|
|
|
|
write_nic_byte_E(dev, EPROM_CMD, cmdreg & ~EPROM_CS_BIT);
|
2009-11-03 09:17:11 +00:00
|
|
|
|
|
|
|
force_pci_posting(dev);
|
|
|
|
udelay(EPROM_DELAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-13 11:36:37 +00:00
|
|
|
static void eprom_ck_cycle(struct net_device *dev)
|
2009-11-03 09:17:11 +00:00
|
|
|
{
|
staging: rtl8192u: fix read_nic_* functions
read_nic_*() functions are defined in r8192U_core.c.
They call internally usb_control_msg() to read the
nic registers and return the value read.
Following a remark made by Dan Carpenter, if usb_control_msg()
fails, the value returned will be invalid.
To accommodate for this, this patch changes the functions
to take a pointer as argument to set the value read and
return 0 on success and the error status on failure, so
that callers of read_nic_*() can check the return status.
Some other fixes introduced in read_nic_*() functions are:
The expressions (1<<EPROM_*_SHIFT) used to address and set
the individual bits of the eeprom register were replaced
with EPROM_*_BIT bitmasks to make the code more intuitive.
EPROM_*_BIT bitmasks were defined in r8192U_hw.h and
EPROM_*_SHIFT were removed.
In netdev_err(), which is called in case of failure,
the hardcoded function name in the error log message was
replaced with __func__ to reduce line size.
Also, from the error log message, it was omitted the word
"Timeout" and it is just reported the error code since the
failure can not only be due to timeout expiration but also
due to a memory allocation failure. In case of timeout
expiration, usb_start_wait_urb() prints an appropriate log
message when debug is enabled.
Finally, some minor fixes to the coding style were applied in
lines affected by the above changes, including the removal
of ifdef DEBUG_RX (the debugging of reads and writes of the
nic registers shall be done with explicit check on their
return status which will be added in a follow on patch).
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 13:40:51 +00:00
|
|
|
u8 cmdreg;
|
|
|
|
|
|
|
|
read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
|
|
|
|
write_nic_byte_E(dev, EPROM_CMD, cmdreg | EPROM_CK_BIT);
|
2009-11-03 09:17:11 +00:00
|
|
|
force_pci_posting(dev);
|
|
|
|
udelay(EPROM_DELAY);
|
staging: rtl8192u: fix read_nic_* functions
read_nic_*() functions are defined in r8192U_core.c.
They call internally usb_control_msg() to read the
nic registers and return the value read.
Following a remark made by Dan Carpenter, if usb_control_msg()
fails, the value returned will be invalid.
To accommodate for this, this patch changes the functions
to take a pointer as argument to set the value read and
return 0 on success and the error status on failure, so
that callers of read_nic_*() can check the return status.
Some other fixes introduced in read_nic_*() functions are:
The expressions (1<<EPROM_*_SHIFT) used to address and set
the individual bits of the eeprom register were replaced
with EPROM_*_BIT bitmasks to make the code more intuitive.
EPROM_*_BIT bitmasks were defined in r8192U_hw.h and
EPROM_*_SHIFT were removed.
In netdev_err(), which is called in case of failure,
the hardcoded function name in the error log message was
replaced with __func__ to reduce line size.
Also, from the error log message, it was omitted the word
"Timeout" and it is just reported the error code since the
failure can not only be due to timeout expiration but also
due to a memory allocation failure. In case of timeout
expiration, usb_start_wait_urb() prints an appropriate log
message when debug is enabled.
Finally, some minor fixes to the coding style were applied in
lines affected by the above changes, including the removal
of ifdef DEBUG_RX (the debugging of reads and writes of the
nic registers shall be done with explicit check on their
return status which will be added in a follow on patch).
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 13:40:51 +00:00
|
|
|
|
|
|
|
read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
|
|
|
|
write_nic_byte_E(dev, EPROM_CMD, cmdreg & ~EPROM_CK_BIT);
|
2009-11-03 09:17:11 +00:00
|
|
|
force_pci_posting(dev);
|
|
|
|
udelay(EPROM_DELAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-27 22:35:09 +00:00
|
|
|
static void eprom_w(struct net_device *dev, short bit)
|
2009-11-03 09:17:11 +00:00
|
|
|
{
|
staging: rtl8192u: fix read_nic_* functions
read_nic_*() functions are defined in r8192U_core.c.
They call internally usb_control_msg() to read the
nic registers and return the value read.
Following a remark made by Dan Carpenter, if usb_control_msg()
fails, the value returned will be invalid.
To accommodate for this, this patch changes the functions
to take a pointer as argument to set the value read and
return 0 on success and the error status on failure, so
that callers of read_nic_*() can check the return status.
Some other fixes introduced in read_nic_*() functions are:
The expressions (1<<EPROM_*_SHIFT) used to address and set
the individual bits of the eeprom register were replaced
with EPROM_*_BIT bitmasks to make the code more intuitive.
EPROM_*_BIT bitmasks were defined in r8192U_hw.h and
EPROM_*_SHIFT were removed.
In netdev_err(), which is called in case of failure,
the hardcoded function name in the error log message was
replaced with __func__ to reduce line size.
Also, from the error log message, it was omitted the word
"Timeout" and it is just reported the error code since the
failure can not only be due to timeout expiration but also
due to a memory allocation failure. In case of timeout
expiration, usb_start_wait_urb() prints an appropriate log
message when debug is enabled.
Finally, some minor fixes to the coding style were applied in
lines affected by the above changes, including the removal
of ifdef DEBUG_RX (the debugging of reads and writes of the
nic registers shall be done with explicit check on their
return status which will be added in a follow on patch).
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 13:40:51 +00:00
|
|
|
u8 cmdreg;
|
|
|
|
|
|
|
|
read_nic_byte_E(dev, EPROM_CMD, &cmdreg);
|
2013-05-13 17:15:49 +00:00
|
|
|
if (bit)
|
staging: rtl8192u: fix read_nic_* functions
read_nic_*() functions are defined in r8192U_core.c.
They call internally usb_control_msg() to read the
nic registers and return the value read.
Following a remark made by Dan Carpenter, if usb_control_msg()
fails, the value returned will be invalid.
To accommodate for this, this patch changes the functions
to take a pointer as argument to set the value read and
return 0 on success and the error status on failure, so
that callers of read_nic_*() can check the return status.
Some other fixes introduced in read_nic_*() functions are:
The expressions (1<<EPROM_*_SHIFT) used to address and set
the individual bits of the eeprom register were replaced
with EPROM_*_BIT bitmasks to make the code more intuitive.
EPROM_*_BIT bitmasks were defined in r8192U_hw.h and
EPROM_*_SHIFT were removed.
In netdev_err(), which is called in case of failure,
the hardcoded function name in the error log message was
replaced with __func__ to reduce line size.
Also, from the error log message, it was omitted the word
"Timeout" and it is just reported the error code since the
failure can not only be due to timeout expiration but also
due to a memory allocation failure. In case of timeout
expiration, usb_start_wait_urb() prints an appropriate log
message when debug is enabled.
Finally, some minor fixes to the coding style were applied in
lines affected by the above changes, including the removal
of ifdef DEBUG_RX (the debugging of reads and writes of the
nic registers shall be done with explicit check on their
return status which will be added in a follow on patch).
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 13:40:51 +00:00
|
|
|
write_nic_byte_E(dev, EPROM_CMD, cmdreg | EPROM_W_BIT);
|
2009-11-03 09:17:11 +00:00
|
|
|
else
|
staging: rtl8192u: fix read_nic_* functions
read_nic_*() functions are defined in r8192U_core.c.
They call internally usb_control_msg() to read the
nic registers and return the value read.
Following a remark made by Dan Carpenter, if usb_control_msg()
fails, the value returned will be invalid.
To accommodate for this, this patch changes the functions
to take a pointer as argument to set the value read and
return 0 on success and the error status on failure, so
that callers of read_nic_*() can check the return status.
Some other fixes introduced in read_nic_*() functions are:
The expressions (1<<EPROM_*_SHIFT) used to address and set
the individual bits of the eeprom register were replaced
with EPROM_*_BIT bitmasks to make the code more intuitive.
EPROM_*_BIT bitmasks were defined in r8192U_hw.h and
EPROM_*_SHIFT were removed.
In netdev_err(), which is called in case of failure,
the hardcoded function name in the error log message was
replaced with __func__ to reduce line size.
Also, from the error log message, it was omitted the word
"Timeout" and it is just reported the error code since the
failure can not only be due to timeout expiration but also
due to a memory allocation failure. In case of timeout
expiration, usb_start_wait_urb() prints an appropriate log
message when debug is enabled.
Finally, some minor fixes to the coding style were applied in
lines affected by the above changes, including the removal
of ifdef DEBUG_RX (the debugging of reads and writes of the
nic registers shall be done with explicit check on their
return status which will be added in a follow on patch).
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 13:40:51 +00:00
|
|
|
write_nic_byte_E(dev, EPROM_CMD, cmdreg & ~EPROM_W_BIT);
|
2009-11-03 09:17:11 +00:00
|
|
|
|
|
|
|
force_pci_posting(dev);
|
|
|
|
udelay(EPROM_DELAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-13 11:36:37 +00:00
|
|
|
static short eprom_r(struct net_device *dev)
|
2009-11-03 09:17:11 +00:00
|
|
|
{
|
staging: rtl8192u: fix read_nic_* functions
read_nic_*() functions are defined in r8192U_core.c.
They call internally usb_control_msg() to read the
nic registers and return the value read.
Following a remark made by Dan Carpenter, if usb_control_msg()
fails, the value returned will be invalid.
To accommodate for this, this patch changes the functions
to take a pointer as argument to set the value read and
return 0 on success and the error status on failure, so
that callers of read_nic_*() can check the return status.
Some other fixes introduced in read_nic_*() functions are:
The expressions (1<<EPROM_*_SHIFT) used to address and set
the individual bits of the eeprom register were replaced
with EPROM_*_BIT bitmasks to make the code more intuitive.
EPROM_*_BIT bitmasks were defined in r8192U_hw.h and
EPROM_*_SHIFT were removed.
In netdev_err(), which is called in case of failure,
the hardcoded function name in the error log message was
replaced with __func__ to reduce line size.
Also, from the error log message, it was omitted the word
"Timeout" and it is just reported the error code since the
failure can not only be due to timeout expiration but also
due to a memory allocation failure. In case of timeout
expiration, usb_start_wait_urb() prints an appropriate log
message when debug is enabled.
Finally, some minor fixes to the coding style were applied in
lines affected by the above changes, including the removal
of ifdef DEBUG_RX (the debugging of reads and writes of the
nic registers shall be done with explicit check on their
return status which will be added in a follow on patch).
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 13:40:51 +00:00
|
|
|
u8 bit;
|
2009-11-03 09:17:11 +00:00
|
|
|
|
staging: rtl8192u: fix read_nic_* functions
read_nic_*() functions are defined in r8192U_core.c.
They call internally usb_control_msg() to read the
nic registers and return the value read.
Following a remark made by Dan Carpenter, if usb_control_msg()
fails, the value returned will be invalid.
To accommodate for this, this patch changes the functions
to take a pointer as argument to set the value read and
return 0 on success and the error status on failure, so
that callers of read_nic_*() can check the return status.
Some other fixes introduced in read_nic_*() functions are:
The expressions (1<<EPROM_*_SHIFT) used to address and set
the individual bits of the eeprom register were replaced
with EPROM_*_BIT bitmasks to make the code more intuitive.
EPROM_*_BIT bitmasks were defined in r8192U_hw.h and
EPROM_*_SHIFT were removed.
In netdev_err(), which is called in case of failure,
the hardcoded function name in the error log message was
replaced with __func__ to reduce line size.
Also, from the error log message, it was omitted the word
"Timeout" and it is just reported the error code since the
failure can not only be due to timeout expiration but also
due to a memory allocation failure. In case of timeout
expiration, usb_start_wait_urb() prints an appropriate log
message when debug is enabled.
Finally, some minor fixes to the coding style were applied in
lines affected by the above changes, including the removal
of ifdef DEBUG_RX (the debugging of reads and writes of the
nic registers shall be done with explicit check on their
return status which will be added in a follow on patch).
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 13:40:51 +00:00
|
|
|
read_nic_byte_E(dev, EPROM_CMD, &bit);
|
2009-11-03 09:17:11 +00:00
|
|
|
udelay(EPROM_DELAY);
|
|
|
|
|
staging: rtl8192u: fix read_nic_* functions
read_nic_*() functions are defined in r8192U_core.c.
They call internally usb_control_msg() to read the
nic registers and return the value read.
Following a remark made by Dan Carpenter, if usb_control_msg()
fails, the value returned will be invalid.
To accommodate for this, this patch changes the functions
to take a pointer as argument to set the value read and
return 0 on success and the error status on failure, so
that callers of read_nic_*() can check the return status.
Some other fixes introduced in read_nic_*() functions are:
The expressions (1<<EPROM_*_SHIFT) used to address and set
the individual bits of the eeprom register were replaced
with EPROM_*_BIT bitmasks to make the code more intuitive.
EPROM_*_BIT bitmasks were defined in r8192U_hw.h and
EPROM_*_SHIFT were removed.
In netdev_err(), which is called in case of failure,
the hardcoded function name in the error log message was
replaced with __func__ to reduce line size.
Also, from the error log message, it was omitted the word
"Timeout" and it is just reported the error code since the
failure can not only be due to timeout expiration but also
due to a memory allocation failure. In case of timeout
expiration, usb_start_wait_urb() prints an appropriate log
message when debug is enabled.
Finally, some minor fixes to the coding style were applied in
lines affected by the above changes, including the removal
of ifdef DEBUG_RX (the debugging of reads and writes of the
nic registers shall be done with explicit check on their
return status which will be added in a follow on patch).
Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-06-06 13:40:51 +00:00
|
|
|
if (bit & EPROM_R_BIT)
|
|
|
|
return 1;
|
|
|
|
|
2009-11-03 09:17:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-13 11:36:37 +00:00
|
|
|
static void eprom_send_bits_string(struct net_device *dev, short b[], int len)
|
2009-11-03 09:17:11 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2014-05-27 22:35:09 +00:00
|
|
|
for (i = 0; i < len; i++) {
|
2009-11-03 09:17:11 +00:00
|
|
|
eprom_w(dev, b[i]);
|
|
|
|
eprom_ck_cycle(dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
u32 eprom_read(struct net_device *dev, u32 addr)
|
|
|
|
{
|
|
|
|
struct r8192_priv *priv = ieee80211_priv(dev);
|
2014-05-27 22:35:09 +00:00
|
|
|
short read_cmd[] = {1, 1, 0};
|
2009-11-03 09:17:11 +00:00
|
|
|
short addr_str[8];
|
|
|
|
int i;
|
|
|
|
int addr_len;
|
|
|
|
u32 ret;
|
|
|
|
|
2014-05-27 22:35:09 +00:00
|
|
|
ret = 0;
|
2014-07-31 05:43:29 +00:00
|
|
|
/* enable EPROM programming */
|
2009-11-03 09:17:11 +00:00
|
|
|
write_nic_byte_E(dev, EPROM_CMD,
|
|
|
|
(EPROM_CMD_PROGRAM<<EPROM_CMD_OPERATING_MODE_SHIFT));
|
|
|
|
force_pci_posting(dev);
|
|
|
|
udelay(EPROM_DELAY);
|
|
|
|
|
2014-05-27 22:35:09 +00:00
|
|
|
if (priv->epromtype == EPROM_93c56) {
|
|
|
|
addr_str[7] = addr & 1;
|
|
|
|
addr_str[6] = addr & (1<<1);
|
|
|
|
addr_str[5] = addr & (1<<2);
|
|
|
|
addr_str[4] = addr & (1<<3);
|
|
|
|
addr_str[3] = addr & (1<<4);
|
|
|
|
addr_str[2] = addr & (1<<5);
|
|
|
|
addr_str[1] = addr & (1<<6);
|
|
|
|
addr_str[0] = addr & (1<<7);
|
|
|
|
addr_len = 8;
|
|
|
|
} else {
|
|
|
|
addr_str[5] = addr & 1;
|
|
|
|
addr_str[4] = addr & (1<<1);
|
|
|
|
addr_str[3] = addr & (1<<2);
|
|
|
|
addr_str[2] = addr & (1<<3);
|
|
|
|
addr_str[1] = addr & (1<<4);
|
|
|
|
addr_str[0] = addr & (1<<5);
|
|
|
|
addr_len = 6;
|
2009-11-03 09:17:11 +00:00
|
|
|
}
|
|
|
|
eprom_cs(dev, 1);
|
|
|
|
eprom_ck_cycle(dev);
|
|
|
|
eprom_send_bits_string(dev, read_cmd, 3);
|
|
|
|
eprom_send_bits_string(dev, addr_str, addr_len);
|
|
|
|
|
2014-07-31 05:43:29 +00:00
|
|
|
/*
|
|
|
|
* keep chip pin D to low state while reading.
|
|
|
|
* I'm unsure if it is necessary, but anyway shouldn't hurt
|
|
|
|
*/
|
2009-11-03 09:17:11 +00:00
|
|
|
eprom_w(dev, 0);
|
|
|
|
|
2014-05-27 22:35:09 +00:00
|
|
|
for (i = 0; i < 16; i++) {
|
2014-07-31 05:43:29 +00:00
|
|
|
/* eeprom needs a clk cycle between writing opcode&adr
|
|
|
|
* and reading data. (eeprom outs a dummy 0)
|
|
|
|
*/
|
2009-11-03 09:17:11 +00:00
|
|
|
eprom_ck_cycle(dev);
|
|
|
|
ret |= (eprom_r(dev)<<(15-i));
|
|
|
|
}
|
|
|
|
|
|
|
|
eprom_cs(dev, 0);
|
|
|
|
eprom_ck_cycle(dev);
|
|
|
|
|
2014-07-31 05:43:29 +00:00
|
|
|
/* disable EPROM programming */
|
2009-11-03 09:17:11 +00:00
|
|
|
write_nic_byte_E(dev, EPROM_CMD,
|
|
|
|
(EPROM_CMD_NORMAL<<EPROM_CMD_OPERATING_MODE_SHIFT));
|
|
|
|
return ret;
|
|
|
|
}
|