mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-22 23:21:31 +00:00
i2c: mvtwsi: Add compatibility functions
To prepare for the DM conversion, we add a layer of compatibility functions to be used by both the legacy and the DM functions. Signed-off-by: Mario Six <mario.six@gdsys.cc> Reviewed-by: Stefan Roese <sr@denx.de>
This commit is contained in:
parent
e075828128
commit
61bc02b260
1 changed files with 38 additions and 9 deletions
|
@ -341,7 +341,7 @@ static void twsi_reset(struct i2c_adapter *adap)
|
||||||
/*
|
/*
|
||||||
* Sets baud to the highest possible value not exceeding the requested one.
|
* Sets baud to the highest possible value not exceeding the requested one.
|
||||||
*/
|
*/
|
||||||
static uint twsi_i2c_set_bus_speed(struct i2c_adapter *adap,
|
static uint __twsi_i2c_set_bus_speed(struct i2c_adapter *adap,
|
||||||
uint requested_speed)
|
uint requested_speed)
|
||||||
{
|
{
|
||||||
struct mvtwsi_registers *twsi = twsi_get_base(adap);
|
struct mvtwsi_registers *twsi = twsi_get_base(adap);
|
||||||
|
@ -366,14 +366,14 @@ static uint twsi_i2c_set_bus_speed(struct i2c_adapter *adap,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void twsi_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
|
static void __twsi_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
|
||||||
{
|
{
|
||||||
struct mvtwsi_registers *twsi = twsi_get_base(adap);
|
struct mvtwsi_registers *twsi = twsi_get_base(adap);
|
||||||
|
|
||||||
/* Reset controller */
|
/* Reset controller */
|
||||||
twsi_reset(adap);
|
twsi_reset(adap);
|
||||||
/* Set speed */
|
/* Set speed */
|
||||||
twsi_i2c_set_bus_speed(adap, speed);
|
__twsi_i2c_set_bus_speed(adap, speed);
|
||||||
/* Set slave address; even though we don't use it */
|
/* Set slave address; even though we don't use it */
|
||||||
writel(slaveadd, &twsi->slave_address);
|
writel(slaveadd, &twsi->slave_address);
|
||||||
writel(0, &twsi->xtnd_slave_addr);
|
writel(0, &twsi->xtnd_slave_addr);
|
||||||
|
@ -408,7 +408,7 @@ static int i2c_begin(struct i2c_adapter *adap, int expected_start_status,
|
||||||
/*
|
/*
|
||||||
* Begin read, nak data byte, end.
|
* Begin read, nak data byte, end.
|
||||||
*/
|
*/
|
||||||
static int twsi_i2c_probe(struct i2c_adapter *adap, uchar chip)
|
static int __twsi_i2c_probe_chip(struct i2c_adapter *adap, uchar chip)
|
||||||
{
|
{
|
||||||
u8 dummy_byte;
|
u8 dummy_byte;
|
||||||
int status;
|
int status;
|
||||||
|
@ -432,7 +432,7 @@ static int twsi_i2c_probe(struct i2c_adapter *adap, uchar chip)
|
||||||
* higher level APIs, we need to make a decision here, and for the moment that
|
* higher level APIs, we need to make a decision here, and for the moment that
|
||||||
* will be a repeated start without a preceding stop.
|
* will be a repeated start without a preceding stop.
|
||||||
*/
|
*/
|
||||||
static int twsi_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
|
static int __twsi_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
|
||||||
int alen, uchar *data, int length)
|
int alen, uchar *data, int length)
|
||||||
{
|
{
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
@ -463,7 +463,7 @@ static int twsi_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
|
||||||
/*
|
/*
|
||||||
* Begin write, send address byte(s), send data bytes, end.
|
* Begin write, send address byte(s), send data bytes, end.
|
||||||
*/
|
*/
|
||||||
static int twsi_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
|
static int __twsi_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
|
||||||
int alen, uchar *data, int length)
|
int alen, uchar *data, int length)
|
||||||
{
|
{
|
||||||
int status, stop_status;
|
int status, stop_status;
|
||||||
|
@ -484,6 +484,35 @@ static int twsi_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
|
||||||
return status != 0 ? status : stop_status;
|
return status != 0 ? status : stop_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void twsi_i2c_init(struct i2c_adapter *adap, int speed,
|
||||||
|
int slaveadd)
|
||||||
|
{
|
||||||
|
__twsi_i2c_init(adap, speed, slaveadd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint twsi_i2c_set_bus_speed(struct i2c_adapter *adap,
|
||||||
|
uint requested_speed)
|
||||||
|
{
|
||||||
|
return __twsi_i2c_set_bus_speed(adap, requested_speed);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int twsi_i2c_probe(struct i2c_adapter *adap, uchar chip)
|
||||||
|
{
|
||||||
|
return __twsi_i2c_probe_chip(adap, chip);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int twsi_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
|
||||||
|
int alen, uchar *data, int length)
|
||||||
|
{
|
||||||
|
return __twsi_i2c_read(adap, chip, addr, alen, data, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int twsi_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
|
||||||
|
int alen, uchar *data, int length)
|
||||||
|
{
|
||||||
|
return __twsi_i2c_write(adap, chip, addr, alen, data, length);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_I2C_MVTWSI_BASE0
|
#ifdef CONFIG_I2C_MVTWSI_BASE0
|
||||||
U_BOOT_I2C_ADAP_COMPLETE(twsi0, twsi_i2c_init, twsi_i2c_probe,
|
U_BOOT_I2C_ADAP_COMPLETE(twsi0, twsi_i2c_init, twsi_i2c_probe,
|
||||||
twsi_i2c_read, twsi_i2c_write,
|
twsi_i2c_read, twsi_i2c_write,
|
||||||
|
|
Loading…
Add table
Reference in a new issue