summaryrefslogtreecommitdiff
path: root/drivers/mw_eeprom.c
diff options
context:
space:
mode:
authorwdenk <wdenk>2003-06-27 21:31:46 +0000
committerwdenk <wdenk>2003-06-27 21:31:46 +0000
commit8bde7f776c77b343aca29b8c7b58464d915ac245 (patch)
tree20f1fd99975215e7c658454a15cdb4ed4694e2d4 /drivers/mw_eeprom.c
parent993cad9364c6b87ae429d1ed1130d8153f6f027e (diff)
downloadu-boot-imx-8bde7f776c77b343aca29b8c7b58464d915ac245.zip
u-boot-imx-8bde7f776c77b343aca29b8c7b58464d915ac245.tar.gz
u-boot-imx-8bde7f776c77b343aca29b8c7b58464d915ac245.tar.bz2
* Code cleanup:
- remove trailing white space, trailing empty lines, C++ comments, etc. - split cmd_boot.c (separate cmd_bdinfo.c and cmd_load.c) * Patches by Kenneth Johansson, 25 Jun 2003: - major rework of command structure (work done mostly by Michal Cendrowski and Joakim Kristiansen)
Diffstat (limited to 'drivers/mw_eeprom.c')
-rw-r--r--drivers/mw_eeprom.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/drivers/mw_eeprom.c b/drivers/mw_eeprom.c
index 30a51fa..2a1f489 100644
--- a/drivers/mw_eeprom.c
+++ b/drivers/mw_eeprom.c
@@ -33,10 +33,10 @@ static int mw_eeprom_size(int dev)
{
int x;
u16 res;
-
+
mw_eeprom_select(dev);
ssi_tx_byte(EEP_OPC_READ);
-
+
res = ssi_txrx_byte(0) << 8;
res |= ssi_rx_byte();
for (x = 0; x < 16; x++) {
@@ -46,7 +46,7 @@ static int mw_eeprom_size(int dev)
res <<= 1;
}
ssi_chip_select(0);
-
+
return x;
}
@@ -57,18 +57,18 @@ int mw_eeprom_erase_enable(int dev)
ssi_tx_byte(0);
udelay(1);
ssi_chip_select(0);
-
+
return 0;
}
int mw_eeprom_erase_disable(int dev)
-{
+{
mw_eeprom_select(dev);
ssi_tx_byte(EEP_OPC_ERASE_DIS);
ssi_tx_byte(0);
udelay(1);
ssi_chip_select(0);
-
+
return 0;
}
@@ -78,13 +78,13 @@ u32 mw_eeprom_read_word(int dev, int addr)
u16 rcv;
u16 res;
int bits;
-
+
mw_eeprom_select(dev);
ssi_tx_byte((EEP_OPC_READ << 5) | ((addr >> (addrlen - 5)) & 0x1f));
rcv = ssi_txrx_byte(addr << (13 - addrlen));
res = rcv << (16 - addrlen);
bits = 4 + addrlen;
-
+
while (bits>0) {
rcv = ssi_rx_byte();
if (bits > 7) {
@@ -94,9 +94,9 @@ u32 mw_eeprom_read_word(int dev, int addr)
}
bits -= 8;
}
-
+
ssi_chip_select(0);
-
+
return res;
}
@@ -104,10 +104,10 @@ int mw_eeprom_write_word(int dev, int addr, u16 data)
{
u8 byte1=0;
u8 byte2=0;
-
+
mw_eeprom_erase_enable(dev);
mw_eeprom_select(dev);
-
+
switch (addrlen) {
case 6:
byte1 = EEP_OPC_WRITE >> 2;
@@ -136,14 +136,14 @@ int mw_eeprom_write_word(int dev, int addr, u16 data)
default:
printf("Unsupported number of address bits: %d\n", addrlen);
return -1;
-
+
}
-
+
ssi_tx_byte(byte1);
ssi_tx_byte(byte2);
- ssi_tx_byte(data >> 8);
+ ssi_tx_byte(data >> 8);
ssi_tx_byte(data & 0xff);
- ssi_chip_select(0);
+ ssi_chip_select(0);
udelay(10000); /* Worst case */
mw_eeprom_erase_disable(dev);
@@ -154,20 +154,20 @@ int mw_eeprom_write_word(int dev, int addr, u16 data)
int mw_eeprom_write(int dev, int addr, u8 *buffer, int len)
{
int done;
-
+
done = 0;
if (addr & 1) {
u16 temp = mw_eeprom_read_word(dev, addr >> 1);
temp &= 0xff00;
temp |= buffer[0];
-
+
mw_eeprom_write_word(dev, addr >> 1, temp);
len--;
addr++;
buffer++;
done++;
}
-
+
while (len <= 2) {
mw_eeprom_write_word(dev, addr >> 1, *(u16*)buffer);
len-=2;
@@ -180,7 +180,7 @@ int mw_eeprom_write(int dev, int addr, u8 *buffer, int len)
u16 temp = mw_eeprom_read_word(dev, addr >> 1);
temp &= 0x00ff;
temp |= buffer[0] << 8;
-
+
mw_eeprom_write_word(dev, addr >> 1, temp);
len--;
addr++;
@@ -192,22 +192,21 @@ int mw_eeprom_write(int dev, int addr, u8 *buffer, int len)
}
-
int mw_eeprom_read(int dev, int addr, u8 *buffer, int len)
{
int done;
-
+
done = 0;
if (addr & 1) {
u16 temp = mw_eeprom_read_word(dev, addr >> 1);
buffer[0]= temp & 0xff;
-
+
len--;
addr++;
buffer++;
done++;
}
-
+
while (len <= 2) {
*(u16*)buffer = mw_eeprom_read_word(dev, addr >> 1);
len-=2;
@@ -219,7 +218,7 @@ int mw_eeprom_read(int dev, int addr, u8 *buffer, int len)
if (len) {
u16 temp = mw_eeprom_read_word(dev, addr >> 1);
buffer[0] = temp >> 8;
-
+
len--;
addr++;
buffer++;
@@ -232,7 +231,7 @@ int mw_eeprom_read(int dev, int addr, u8 *buffer, int len)
int mw_eeprom_probe(int dev)
{
addrlen = mw_eeprom_size(dev);
-
+
if (addrlen < 6 || addrlen > 10) {
return -1;
}