projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
usb_hub: fix power cycling logic
[oweals/u-boot.git]
/
board
/
evb64260
/
i2c.c
diff --git
a/board/evb64260/i2c.c
b/board/evb64260/i2c.c
index 88d0dac469189d54f20f9c9f8a3d2dc08672a0a5..8119fced486926d7d174fdcd18c1d29f016d67e0 100644
(file)
--- a/
board/evb64260/i2c.c
+++ b/
board/evb64260/i2c.c
@@
-20,29
+20,25
@@
static void
i2c_init(int speed, int slaveaddr)
{
unsigned int n, m, freq, margin, power;
i2c_init(int speed, int slaveaddr)
{
unsigned int n, m, freq, margin, power;
- unsigned int actual
Freq, actualN=0, actualM=
0;
+ unsigned int actual
n = 0, actualm =
0;
unsigned int control, status;
unsigned int control, status;
- unsigned int min
M
argin = 0xffffffff;
+ unsigned int min
m
argin = 0xffffffff;
unsigned int tclk = 125000000;
DP(puts("i2c_init\n"));
unsigned int tclk = 125000000;
DP(puts("i2c_init\n"));
- for(n = 0 ; n < 8 ; n++)
- {
- for(m = 0 ; m < 16 ; m++)
- {
- power = 2<<n; /* power = 2^(n+1) */
- freq = tclk/(10*(m+1)*power);
+ for (n = 0 ; n < 8 ; n++) {
+ for (m = 0 ; m < 16 ; m++) {
+ power = 2 << n; /* power = 2^(n+1) */
+ freq = tclk / (10 * (m + 1) * power);
if (speed > freq)
margin = speed - freq;
else
margin = freq - speed;
if (speed > freq)
margin = speed - freq;
else
margin = freq - speed;
- if(margin < minMargin)
- {
- minMargin = margin;
- actualFreq = freq;
- actualN = n;
- actualM = m;
+ if (margin < minmargin) {
+ minmargin = margin;
+ actualn = n;
+ actualm = m;
}
}
}
}
}
}
@@
-59,7
+55,7
@@
i2c_init(int speed, int slaveaddr)
DP(puts("set baudrate\n"));
DP(puts("set baudrate\n"));
- GT_REG_WRITE(I2C_STATUS_BAUDE_RATE, (actual
M << 3) | actualN
);
+ GT_REG_WRITE(I2C_STATUS_BAUDE_RATE, (actual
m << 3) | actualn
);
GT_REG_WRITE(I2C_CONTROL, (0x1 << 2) | (0x1 << 6));
udelay(I2C_DELAY * 10);
GT_REG_WRITE(I2C_CONTROL, (0x1 << 2) | (0x1 << 6));
udelay(I2C_DELAY * 10);
@@
-91,13
+87,13
@@
i2c_start(void)
udelay(I2C_DELAY);
if (count > 20) {
GT_REG_WRITE(I2C_CONTROL, (0x1 << 4)); /*stop*/
udelay(I2C_DELAY);
if (count > 20) {
GT_REG_WRITE(I2C_CONTROL, (0x1 << 4)); /*stop*/
- return
(status)
;
+ return
status
;
}
GT_REG_READ(I2C_STATUS_BAUDE_RATE, &status);
count++;
}
}
GT_REG_READ(I2C_STATUS_BAUDE_RATE, &status);
count++;
}
- return
(0)
;
+ return
0
;
}
static uchar
}
static uchar
@@
-110,9
+106,8
@@
i2c_select_device(uchar dev_addr, uchar read, int ten_bit)
/* Output slave address */
/* Output slave address */
- if (ten_bit)
{
+ if (ten_bit)
bits = 10;
bits = 10;
- }
data = (dev_addr << 1);
/* set the read bit */
data = (dev_addr << 1);
/* set the read bit */
@@
-129,7
+124,7
@@
i2c_select_device(uchar dev_addr, uchar read, int ten_bit)
udelay(I2C_DELAY);
if (count > 20) {
GT_REG_WRITE(I2C_CONTROL, (0x1 << 4)); /*stop*/
udelay(I2C_DELAY);
if (count > 20) {
GT_REG_WRITE(I2C_CONTROL, (0x1 << 4)); /*stop*/
- return
(status)
;
+ return
status
;
}
GT_REG_READ(I2C_STATUS_BAUDE_RATE, &status);
count++;
}
GT_REG_READ(I2C_STATUS_BAUDE_RATE, &status);
count++;
@@
-137,14
+132,14
@@
i2c_select_device(uchar dev_addr, uchar read, int ten_bit)
if (bits == 10) {
printf("10 bit I2C addressing not yet implemented\n");
if (bits == 10) {
printf("10 bit I2C addressing not yet implemented\n");
- return
(0xff)
;
+ return
0xff
;
}
}
- return
(0)
;
+ return
0
;
}
static uchar
}
static uchar
-i2c_get_data(uchar
*
return_data, int len) {
+i2c_get_data(uchar
*
return_data, int len) {
unsigned int data, status = 0;
int count = 0;
unsigned int data, status = 0;
int count = 0;
@@
-163,7
+158,7
@@
i2c_get_data(uchar* return_data, int len) {
count++;
while ((status & 0xff) != 0x50) {
udelay(I2C_DELAY);
count++;
while ((status & 0xff) != 0x50) {
udelay(I2C_DELAY);
- if(count > 2) {
+ if
(count > 2) {
GT_REG_WRITE(I2C_CONTROL, (0x1 << 4)); /*stop*/
return 0;
}
GT_REG_WRITE(I2C_CONTROL, (0x1 << 4)); /*stop*/
return 0;
}
@@
-178,16
+173,16
@@
i2c_get_data(uchar* return_data, int len) {
RESET_REG_BITS(I2C_CONTROL, BIT2|BIT3);
while ((status & 0xff) != 0x58) {
udelay(I2C_DELAY);
RESET_REG_BITS(I2C_CONTROL, BIT2|BIT3);
while ((status & 0xff) != 0x58) {
udelay(I2C_DELAY);
- if(count > 200) {
+ if
(count > 200) {
GT_REG_WRITE(I2C_CONTROL, (0x1 << 4)); /*stop*/
GT_REG_WRITE(I2C_CONTROL, (0x1 << 4)); /*stop*/
- return
(status)
;
+ return
status
;
}
GT_REG_READ(I2C_STATUS_BAUDE_RATE, &status);
count++;
}
GT_REG_WRITE(I2C_CONTROL, (0x1 << 4)); /* stop */
}
GT_REG_READ(I2C_STATUS_BAUDE_RATE, &status);
count++;
}
GT_REG_WRITE(I2C_CONTROL, (0x1 << 4)); /* stop */
- return
(0)
;
+ return
0
;
}
static uchar
}
static uchar
@@
-213,9
+208,9
@@
i2c_write_data(unsigned int data, int len)
count++;
while ((status & 0xff) != 0x28) {
udelay(I2C_DELAY);
count++;
while ((status & 0xff) != 0x28) {
udelay(I2C_DELAY);
- if(count > 20) {
+ if
(count > 20) {
GT_REG_WRITE(I2C_CONTROL, (0x1 << 4)); /*stop*/
GT_REG_WRITE(I2C_CONTROL, (0x1 << 4)); /*stop*/
- return
(status)
;
+ return
status
;
}
GT_REG_READ(I2C_STATUS_BAUDE_RATE, &status);
count++;
}
GT_REG_READ(I2C_STATUS_BAUDE_RATE, &status);
count++;
@@
-227,7
+222,7
@@
i2c_write_data(unsigned int data, int len)
udelay(I2C_DELAY * 10);
udelay(I2C_DELAY * 10);
- return
(0)
;
+ return
0
;
}
static uchar
}
static uchar
@@
-254,19
+249,19
@@
i2c_set_dev_offset(uchar dev_addr, unsigned int offset, int ten_bit)
return status;
}
return status;
}
- return
(0)
;
+ return
0
;
}
uchar
}
uchar
-i2c_read(uchar dev_addr, unsigned int offset, int len, uchar
*
data,
+i2c_read(uchar dev_addr, unsigned int offset, int len, uchar
*
data,
int ten_bit)
{
uchar status = 0;
int ten_bit)
{
uchar status = 0;
- unsigned int i2c
F
req = 400000;
+ unsigned int i2c
f
req = 400000;
DP(puts("i2c_read\n"));
DP(puts("i2c_read\n"));
- i2c_init(i2c
Freq,
0);
+ i2c_init(i2c
freq,
0);
status = i2c_start();
status = i2c_start();
@@
-285,7
+280,7
@@
i2c_read(uchar dev_addr, unsigned int offset, int len, uchar* data,
return status;
}
return status;
}
- i2c_init(i2c
Freq,
0);
+ i2c_init(i2c
freq,
0);
status = i2c_start();
if (status) {
status = i2c_start();
if (status) {