Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
reform-boundary-uboot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jack Humbert
reform-boundary-uboot
Commits
0052a051
Commit
0052a051
authored
15 years ago
by
Wolfgang Denk
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
git://git.denx.de/u-boot-i2c
parents
3ea43ff7
92477a63
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README
+7
-0
7 additions, 0 deletions
README
cpu/mpc5xxx/i2c.c
+49
-0
49 additions, 0 deletions
cpu/mpc5xxx/i2c.c
drivers/i2c/fsl_i2c.c
+20
-4
20 additions, 4 deletions
drivers/i2c/fsl_i2c.c
include/configs/galaxy5200.h
+1
-0
1 addition, 0 deletions
include/configs/galaxy5200.h
with
77 additions
and
4 deletions
README
+
7
−
0
View file @
0052a051
...
@@ -1366,6 +1366,13 @@ The following options need to be configured:
...
@@ -1366,6 +1366,13 @@ The following options need to be configured:
therefore be cleared to 0 (See, eg, MPC823e User's Manual
therefore be cleared to 0 (See, eg, MPC823e User's Manual
p.16-473). So, set CONFIG_SYS_I2C_SLAVE to 0.
p.16-473). So, set CONFIG_SYS_I2C_SLAVE to 0.
CONFIG_SYS_I2C_INIT_MPC5XXX
When a board is reset during an i2c bus transfer
chips might think that the current transfer is still
in progress. Reset the slave devices by sending start
commands until the slave device responds.
That's all that's required for CONFIG_HARD_I2C.
That's all that's required for CONFIG_HARD_I2C.
If you use the software i2c interface (CONFIG_SOFT_I2C)
If you use the software i2c interface (CONFIG_SOFT_I2C)
...
...
This diff is collapsed.
Click to expand it.
cpu/mpc5xxx/i2c.c
+
49
−
0
View file @
0052a051
...
@@ -207,6 +207,52 @@ static int receive_bytes(uchar chip, char *buf, int len)
...
@@ -207,6 +207,52 @@ static int receive_bytes(uchar chip, char *buf, int len)
return
0
;
return
0
;
}
}
#if defined(CONFIG_SYS_I2C_INIT_MPC5XXX)
#define FDR510(x) (u8) (((x & 0x20) >> 3) | (x & 0x3))
#define FDR432(x) (u8) ((x & 0x1C) >> 2)
/*
* Reset any i2c devices that may have been interrupted during a system reset.
* Normally this would be accomplished by clocking the line until SCL and SDA
* are released and then sending a start condtiion (From an Atmel datasheet).
* There is no direct access to the i2c pins so instead create start commands
* through the i2c interface. Send a start command then delay for the SDA Hold
* time, repeat this by disabling/enabling the bus a total of 9 times.
*/
static
void
send_reset
(
void
)
{
struct
mpc5xxx_i2c
*
regs
=
(
struct
mpc5xxx_i2c
*
)
I2C_BASE
;
int
i
;
u32
delay
;
u8
fdr
;
int
SDA_Tap
[]
=
{
3
,
3
,
4
,
4
,
1
,
1
,
2
,
2
};
struct
mpc5xxx_i2c_tap
scltap
[]
=
{
{
4
,
1
},
{
4
,
2
},
{
6
,
4
},
{
6
,
8
},
{
14
,
16
},
{
30
,
32
},
{
62
,
64
},
{
126
,
128
}
};
fdr
=
(
u8
)
mpc_reg_in
(
&
regs
->
mfdr
);
delay
=
scltap
[
FDR432
(
fdr
)].
scl2tap
+
((
SDA_Tap
[
FDR510
(
fdr
)]
-
1
)
*
\
scltap
[
FDR432
(
fdr
)].
tap2tap
)
+
3
;
for
(
i
=
0
;
i
<
9
;
i
++
)
{
mpc_reg_out
(
&
regs
->
mcr
,
I2C_EN
|
I2C_STA
|
I2C_TX
,
I2C_INIT_MASK
);
udelay
(
delay
);
mpc_reg_out
(
&
regs
->
mcr
,
0
,
I2C_INIT_MASK
);
udelay
(
delay
);
}
mpc_reg_out
(
&
regs
->
mcr
,
I2C_EN
,
I2C_INIT_MASK
);
}
#endif
/* CONFIG_SYS_I2c_INIT_MPC5XXX */
/**************** I2C API ****************/
/**************** I2C API ****************/
void
i2c_init
(
int
speed
,
int
saddr
)
void
i2c_init
(
int
speed
,
int
saddr
)
...
@@ -225,6 +271,9 @@ void i2c_init(int speed, int saddr)
...
@@ -225,6 +271,9 @@ void i2c_init(int speed, int saddr)
mpc_reg_out
(
&
regs
->
mcr
,
I2C_EN
,
I2C_INIT_MASK
);
mpc_reg_out
(
&
regs
->
mcr
,
I2C_EN
,
I2C_INIT_MASK
);
mpc_reg_out
(
&
regs
->
msr
,
0
,
I2C_IF
);
mpc_reg_out
(
&
regs
->
msr
,
0
,
I2C_IF
);
#if defined(CONFIG_SYS_I2C_INIT_MPC5XXX)
send_reset
();
#endif
return
;
return
;
}
}
...
...
This diff is collapsed.
Click to expand it.
drivers/i2c/fsl_i2c.c
+
20
−
4
View file @
0052a051
/*
/*
* Copyright 2006 Freescale Semiconductor, Inc.
* Copyright 2006
,2009
Freescale Semiconductor, Inc.
*
*
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* modify it under the terms of the GNU General Public License
...
@@ -26,7 +26,21 @@
...
@@ -26,7 +26,21 @@
#include
<asm/io.h>
#include
<asm/io.h>
#include
<asm/fsl_i2c.h>
/* HW definitions */
#include
<asm/fsl_i2c.h>
/* HW definitions */
#define I2C_TIMEOUT (CONFIG_SYS_HZ / 4)
/* The maximum number of microseconds we will wait until another master has
* released the bus. If not defined in the board header file, then use a
* generic value.
*/
#ifndef CONFIG_I2C_MBB_TIMEOUT
#define CONFIG_I2C_MBB_TIMEOUT 100000
#endif
/* The maximum number of microseconds we will wait for a read or write
* operation to complete. If not defined in the board header file, then use a
* generic value.
*/
#ifndef CONFIG_I2C_TIMEOUT
#define CONFIG_I2C_TIMEOUT 10000
#endif
#define I2C_READ_BIT 1
#define I2C_READ_BIT 1
#define I2C_WRITE_BIT 0
#define I2C_WRITE_BIT 0
...
@@ -213,9 +227,10 @@ static __inline__ int
...
@@ -213,9 +227,10 @@ static __inline__ int
i2c_wait4bus
(
void
)
i2c_wait4bus
(
void
)
{
{
unsigned
long
long
timeval
=
get_ticks
();
unsigned
long
long
timeval
=
get_ticks
();
const
unsigned
long
long
timeout
=
usec2ticks
(
CONFIG_I2C_MBB_TIMEOUT
);
while
(
readb
(
&
i2c_dev
[
i2c_bus_num
]
->
sr
)
&
I2C_SR_MBB
)
{
while
(
readb
(
&
i2c_dev
[
i2c_bus_num
]
->
sr
)
&
I2C_SR_MBB
)
{
if
((
get_ticks
()
-
timeval
)
>
usec2ticks
(
I2C_TIMEOUT
)
)
if
((
get_ticks
()
-
timeval
)
>
timeout
)
return
-
1
;
return
-
1
;
}
}
...
@@ -227,6 +242,7 @@ i2c_wait(int write)
...
@@ -227,6 +242,7 @@ i2c_wait(int write)
{
{
u32
csr
;
u32
csr
;
unsigned
long
long
timeval
=
get_ticks
();
unsigned
long
long
timeval
=
get_ticks
();
const
unsigned
long
long
timeout
=
usec2ticks
(
CONFIG_I2C_TIMEOUT
);
do
{
do
{
csr
=
readb
(
&
i2c_dev
[
i2c_bus_num
]
->
sr
);
csr
=
readb
(
&
i2c_dev
[
i2c_bus_num
]
->
sr
);
...
@@ -251,7 +267,7 @@ i2c_wait(int write)
...
@@ -251,7 +267,7 @@ i2c_wait(int write)
}
}
return
0
;
return
0
;
}
while
((
get_ticks
()
-
timeval
)
<
usec2ticks
(
I2C_TIMEOUT
)
);
}
while
((
get_ticks
()
-
timeval
)
<
timeout
);
debug
(
"i2c_wait: timed out
\n
"
);
debug
(
"i2c_wait: timed out
\n
"
);
return
-
1
;
return
-
1
;
...
...
This diff is collapsed.
Click to expand it.
include/configs/galaxy5200.h
+
1
−
0
View file @
0052a051
...
@@ -110,6 +110,7 @@
...
@@ -110,6 +110,7 @@
#define CONFIG_SYS_I2C_MODULE 2
/* Select I2C module #1 or #2 */
#define CONFIG_SYS_I2C_MODULE 2
/* Select I2C module #1 or #2 */
#define CONFIG_SYS_I2C_SPEED 100000
/* 100 kHz */
#define CONFIG_SYS_I2C_SPEED 100000
/* 100 kHz */
#define CONFIG_SYS_I2C_SLAVE 0x7F
#define CONFIG_SYS_I2C_SLAVE 0x7F
#define CONFIG_SYS_I2C_INIT_MPC5XXX
/* Reset devices on i2c bus */
/*
/*
* EEPROM CAT24WC32 configuration
* EEPROM CAT24WC32 configuration
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment