aboutsummaryrefslogtreecommitdiff
path: root/drivers/i2c/mvtwsi.c
diff options
context:
space:
mode:
authormario.six@gdsys.cc <mario.six@gdsys.cc>2016-07-21 11:57:07 +0200
committerHeiko Schocher <hs@denx.de>2016-07-26 10:19:49 +0200
commit61bc02b2608722204c1f16a74cd8851db5ee311d (patch)
tree1b8b942847e03b6e7d2dbe24292fcc123faafb54 /drivers/i2c/mvtwsi.c
parente075828128d961d873484bb02ac8101bc733a1d7 (diff)
downloadu-boot-61bc02b2608722204c1f16a74cd8851db5ee311d.zip
u-boot-61bc02b2608722204c1f16a74cd8851db5ee311d.tar.gz
u-boot-61bc02b2608722204c1f16a74cd8851db5ee311d.tar.bz2
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>
Diffstat (limited to 'drivers/i2c/mvtwsi.c')
-rw-r--r--drivers/i2c/mvtwsi.c47
1 files changed, 38 insertions, 9 deletions
diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index 9ddd3ee..f1bfd5d 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -341,8 +341,8 @@ static void twsi_reset(struct i2c_adapter *adap)
/*
* Sets baud to the highest possible value not exceeding the requested one.
*/
-static uint twsi_i2c_set_bus_speed(struct i2c_adapter *adap,
- uint requested_speed)
+static uint __twsi_i2c_set_bus_speed(struct i2c_adapter *adap,
+ uint requested_speed)
{
struct mvtwsi_registers *twsi = twsi_get_base(adap);
uint tmp_speed, highest_speed, n, m;
@@ -366,14 +366,14 @@ static uint twsi_i2c_set_bus_speed(struct i2c_adapter *adap,
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);
/* Reset controller */
twsi_reset(adap);
/* 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 */
writel(slaveadd, &twsi->slave_address);
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.
*/
-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;
int status;
@@ -432,8 +432,8 @@ 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
* will be a repeated start without a preceding stop.
*/
-static int twsi_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
- int alen, uchar *data, int length)
+static int __twsi_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
+ int alen, uchar *data, int length)
{
int status = 0;
int stop_status;
@@ -463,8 +463,8 @@ static int twsi_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
/*
* Begin write, send address byte(s), send data bytes, end.
*/
-static int twsi_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
- int alen, uchar *data, int length)
+static int __twsi_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
+ int alen, uchar *data, int length)
{
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;
}
+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
U_BOOT_I2C_ADAP_COMPLETE(twsi0, twsi_i2c_init, twsi_i2c_probe,
twsi_i2c_read, twsi_i2c_write,