summaryrefslogtreecommitdiff
path: root/drivers/i2c/mxs_i2c.c
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2014-10-20 00:23:40 +0200
committerHeiko Schocher <hs@denx.de>2014-10-29 08:55:37 +0100
commit9536099d5083cb2c9657cf5c13e22a01567dbd2d (patch)
treee47bb135b65a497f205168a798cc7f47dbf24bfd /drivers/i2c/mxs_i2c.c
parentd58a9451e7339ed4cf2b2627e534611f427fb791 (diff)
downloadu-boot-imx-9536099d5083cb2c9657cf5c13e22a01567dbd2d.zip
u-boot-imx-9536099d5083cb2c9657cf5c13e22a01567dbd2d.tar.gz
u-boot-imx-9536099d5083cb2c9657cf5c13e22a01567dbd2d.tar.bz2
i2c: mxs: Consolidate hard-coded bus address
This patch prepares the MXS I2C driver for the conversion to the new I2C driver framework by pulling out the hard-coded I2C0 address from all the places. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Stefano Babic <sbabic@denx.de> Cc: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/i2c/mxs_i2c.c')
-rw-r--r--drivers/i2c/mxs_i2c.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/i2c/mxs_i2c.c b/drivers/i2c/mxs_i2c.c
index de3b194..cc313a6 100644
--- a/drivers/i2c/mxs_i2c.c
+++ b/drivers/i2c/mxs_i2c.c
@@ -24,9 +24,14 @@
#define MXS_I2C_MAX_TIMEOUT 1000000
+static struct mxs_i2c_regs *mxs_i2c_get_base(struct i2c_adapter *adap)
+{
+ return (struct mxs_i2c_regs *)MXS_I2C0_BASE;
+}
+
static void mxs_i2c_reset(void)
{
- struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
+ struct mxs_i2c_regs *i2c_regs = mxs_i2c_get_base(NULL);
int ret;
int speed = i2c_get_bus_speed();
@@ -48,7 +53,7 @@ static void mxs_i2c_reset(void)
static void mxs_i2c_setup_read(uint8_t chip, int len)
{
- struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
+ struct mxs_i2c_regs *i2c_regs = mxs_i2c_get_base(NULL);
writel(I2C_QUEUECMD_RETAIN_CLOCK | I2C_QUEUECMD_PRE_SEND_START |
I2C_QUEUECMD_MASTER_MODE | I2C_QUEUECMD_DIRECTION |
@@ -67,7 +72,7 @@ static void mxs_i2c_setup_read(uint8_t chip, int len)
static int mxs_i2c_write(uchar chip, uint addr, int alen,
uchar *buf, int blen, int stop)
{
- struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
+ struct mxs_i2c_regs *i2c_regs = mxs_i2c_get_base(NULL);
uint32_t data, tmp;
int i, remain, off;
int timeout = MXS_I2C_MAX_TIMEOUT;
@@ -124,7 +129,7 @@ static int mxs_i2c_write(uchar chip, uint addr, int alen,
static int mxs_i2c_wait_for_ack(void)
{
- struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
+ struct mxs_i2c_regs *i2c_regs = mxs_i2c_get_base(NULL);
uint32_t tmp;
int timeout = MXS_I2C_MAX_TIMEOUT;
@@ -162,7 +167,7 @@ err:
int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
{
- struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
+ struct mxs_i2c_regs *i2c_regs = mxs_i2c_get_base(NULL);
uint32_t tmp = 0;
int timeout = MXS_I2C_MAX_TIMEOUT;
int ret;
@@ -237,7 +242,7 @@ int i2c_probe(uchar chip)
int i2c_set_bus_speed(unsigned int speed)
{
- struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
+ struct mxs_i2c_regs *i2c_regs = mxs_i2c_get_base(NULL);
/*
* The timing derivation algorithm. There is no documentation for this
* algorithm available, it was derived by using the scope and fiddling
@@ -278,7 +283,7 @@ int i2c_set_bus_speed(unsigned int speed)
unsigned int i2c_get_bus_speed(void)
{
- struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
+ struct mxs_i2c_regs *i2c_regs = mxs_i2c_get_base(NULL);
uint32_t clk = mxc_get_clock(MXC_XTAL_CLK);
uint32_t timing0;