Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uboot-i9100
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
Model registry
Operate
Environments
Monitor
Incidents
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
onny
uboot-i9100
Commits
3364b189
Commit
3364b189
authored
10 years ago
by
Tom Rini
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
git://git.denx.de/u-boot-i2c
parents
c68112f3
a17fd10f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
drivers/i2c/fsl_i2c.c
+20
-2
20 additions, 2 deletions
drivers/i2c/fsl_i2c.c
drivers/i2c/omap24xx_i2c.c
+57
-0
57 additions, 0 deletions
drivers/i2c/omap24xx_i2c.c
with
77 additions
and
2 deletions
drivers/i2c/fsl_i2c.c
+
20
−
2
View file @
3364b189
...
@@ -46,10 +46,16 @@
...
@@ -46,10 +46,16 @@
DECLARE_GLOBAL_DATA_PTR
;
DECLARE_GLOBAL_DATA_PTR
;
static
const
struct
fsl_i2c
*
i2c_dev
[
2
]
=
{
static
const
struct
fsl_i2c
*
i2c_dev
[
4
]
=
{
(
struct
fsl_i2c
*
)(
CONFIG_SYS_IMMR
+
CONFIG_SYS_FSL_I2C_OFFSET
),
(
struct
fsl_i2c
*
)(
CONFIG_SYS_IMMR
+
CONFIG_SYS_FSL_I2C_OFFSET
),
#ifdef CONFIG_SYS_FSL_I2C2_OFFSET
#ifdef CONFIG_SYS_FSL_I2C2_OFFSET
(
struct
fsl_i2c
*
)(
CONFIG_SYS_IMMR
+
CONFIG_SYS_FSL_I2C2_OFFSET
)
(
struct
fsl_i2c
*
)(
CONFIG_SYS_IMMR
+
CONFIG_SYS_FSL_I2C2_OFFSET
),
#endif
#ifdef CONFIG_SYS_FSL_I2C3_OFFSET
(
struct
fsl_i2c
*
)(
CONFIG_SYS_IMMR
+
CONFIG_SYS_FSL_I2C3_OFFSET
),
#endif
#ifdef CONFIG_SYS_FSL_I2C4_OFFSET
(
struct
fsl_i2c
*
)(
CONFIG_SYS_IMMR
+
CONFIG_SYS_FSL_I2C4_OFFSET
)
#endif
#endif
};
};
...
@@ -539,3 +545,15 @@ U_BOOT_I2C_ADAP_COMPLETE(fsl_1, fsl_i2c_init, fsl_i2c_probe, fsl_i2c_read,
...
@@ -539,3 +545,15 @@ U_BOOT_I2C_ADAP_COMPLETE(fsl_1, fsl_i2c_init, fsl_i2c_probe, fsl_i2c_read,
CONFIG_SYS_FSL_I2C2_SPEED
,
CONFIG_SYS_FSL_I2C2_SLAVE
,
CONFIG_SYS_FSL_I2C2_SPEED
,
CONFIG_SYS_FSL_I2C2_SLAVE
,
1
)
1
)
#endif
#endif
#ifdef CONFIG_SYS_FSL_I2C3_OFFSET
U_BOOT_I2C_ADAP_COMPLETE
(
fsl_2
,
fsl_i2c_init
,
fsl_i2c_probe
,
fsl_i2c_read
,
fsl_i2c_write
,
fsl_i2c_set_bus_speed
,
CONFIG_SYS_FSL_I2C3_SPEED
,
CONFIG_SYS_FSL_I2C3_SLAVE
,
2
)
#endif
#ifdef CONFIG_SYS_FSL_I2C4_OFFSET
U_BOOT_I2C_ADAP_COMPLETE
(
fsl_3
,
fsl_i2c_init
,
fsl_i2c_probe
,
fsl_i2c_read
,
fsl_i2c_write
,
fsl_i2c_set_bus_speed
,
CONFIG_SYS_FSL_I2C4_SPEED
,
CONFIG_SYS_FSL_I2C4_SLAVE
,
3
)
#endif
This diff is collapsed.
Click to expand it.
drivers/i2c/omap24xx_i2c.c
+
57
−
0
View file @
3364b189
...
@@ -153,11 +153,60 @@ static uint omap24_i2c_setspeed(struct i2c_adapter *adap, uint speed)
...
@@ -153,11 +153,60 @@ static uint omap24_i2c_setspeed(struct i2c_adapter *adap, uint speed)
return
0
;
return
0
;
}
}
static
void
omap24_i2c_deblock
(
struct
i2c_adapter
*
adap
)
{
struct
i2c
*
i2c_base
=
omap24_get_base
(
adap
);
int
i
;
u16
systest
;
u16
orgsystest
;
/* set test mode ST_EN = 1 */
orgsystest
=
readw
(
&
i2c_base
->
systest
);
systest
=
orgsystest
;
/* enable testmode */
systest
|=
I2C_SYSTEST_ST_EN
;
writew
(
systest
,
&
i2c_base
->
systest
);
systest
&=
~
I2C_SYSTEST_TMODE_MASK
;
systest
|=
3
<<
I2C_SYSTEST_TMODE_SHIFT
;
writew
(
systest
,
&
i2c_base
->
systest
);
/* set SCL, SDA = 1 */
systest
|=
I2C_SYSTEST_SCL_O
|
I2C_SYSTEST_SDA_O
;
writew
(
systest
,
&
i2c_base
->
systest
);
udelay
(
10
);
/* toggle scl 9 clocks */
for
(
i
=
0
;
i
<
9
;
i
++
)
{
/* SCL = 0 */
systest
&=
~
I2C_SYSTEST_SCL_O
;
writew
(
systest
,
&
i2c_base
->
systest
);
udelay
(
10
);
/* SCL = 1 */
systest
|=
I2C_SYSTEST_SCL_O
;
writew
(
systest
,
&
i2c_base
->
systest
);
udelay
(
10
);
}
/* send stop */
systest
&=
~
I2C_SYSTEST_SDA_O
;
writew
(
systest
,
&
i2c_base
->
systest
);
udelay
(
10
);
systest
|=
I2C_SYSTEST_SCL_O
|
I2C_SYSTEST_SDA_O
;
writew
(
systest
,
&
i2c_base
->
systest
);
udelay
(
10
);
/* restore original mode */
writew
(
orgsystest
,
&
i2c_base
->
systest
);
}
static
void
omap24_i2c_init
(
struct
i2c_adapter
*
adap
,
int
speed
,
int
slaveadd
)
static
void
omap24_i2c_init
(
struct
i2c_adapter
*
adap
,
int
speed
,
int
slaveadd
)
{
{
struct
i2c
*
i2c_base
=
omap24_get_base
(
adap
);
struct
i2c
*
i2c_base
=
omap24_get_base
(
adap
);
int
timeout
=
I2C_TIMEOUT
;
int
timeout
=
I2C_TIMEOUT
;
int
deblock
=
1
;
retry:
if
(
readw
(
&
i2c_base
->
con
)
&
I2C_CON_EN
)
{
if
(
readw
(
&
i2c_base
->
con
)
&
I2C_CON_EN
)
{
writew
(
0
,
&
i2c_base
->
con
);
writew
(
0
,
&
i2c_base
->
con
);
udelay
(
50000
);
udelay
(
50000
);
...
@@ -194,6 +243,14 @@ static void omap24_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
...
@@ -194,6 +243,14 @@ static void omap24_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
udelay
(
1000
);
udelay
(
1000
);
flush_fifo
(
adap
);
flush_fifo
(
adap
);
writew
(
0xFFFF
,
&
i2c_base
->
stat
);
writew
(
0xFFFF
,
&
i2c_base
->
stat
);
/* Handle possible failed I2C state */
if
(
wait_for_bb
(
adap
))
if
(
deblock
==
1
)
{
omap24_i2c_deblock
(
adap
);
deblock
=
0
;
goto
retry
;
}
}
}
static
void
flush_fifo
(
struct
i2c_adapter
*
adap
)
static
void
flush_fifo
(
struct
i2c_adapter
*
adap
)
...
...
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