mxc_i2c: fix i2c_imx_stop

Instead of clearing 2 bits, all the other
bits were set because '|=' was used instead
of '&='.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Acked-by: Marek Vasut <marex@denx.de>
Acked-by: Stefano Babic <sbabic@denx.de>

---
V2: add acks
mxc_i2c: remove ifdef of CONFIG_HARD_I2C

This is always selected when CONFIG_I2C_MXC is
selected, so it adds no value.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Acked-by: Marek Vasut <marex@denx.de>

---
v2: add ack
mxc_i2c: create tx_byte function

Use tx_byte function instead of having 3 copies
of the code.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Acked-by: Marek Vasut <marex@denx.de>

---
v2: add ack
change ret to integer from unsigned
mxc_i2c: clear i2sr before waiting for bit

Let's clear the sr register before waiting for
bit to be set, instead of clearing it after
hardware sets it. No real operational difference here,
but allows combining of i2c_imx_trx_complete and
i2c_imx_bus_busy in later patches.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Acked-by: Marek Vasut <marex@denx.de>

---
v2: add ack
add clear of i2sr in i2c_read
mxc_i2c: create i2c_init_transfer

Initial code of i2c_read and i2c_write
is identical, move to subroutine.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Acked-by: Marek Vasut <marex@denx.de>
Acked-by: Stefano Babic <sbabic@denx.de>

---
v2: add ack
mxc_i2c: call i2c_imx_stop on error in i2c_read/i2c_write

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
mxc_i2c.c: code i2c_probe as a 0 length i2c_write

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Acked-by: Marek Vasut <marex@denx.de>
Acked-by: Stefano Babic <sbabic@denx.de>

---
v2: add acks
change comment
---
mxc_i2c: combine i2c_imx_bus_busy and i2c_imx_trx_complete into wait_for_sr_state

Not using udelay gives a more accurate timeout. The current implementation of udelay
in imx-common does not seem to wait at all for a udelay(1).

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Acked-by: Marek Vasut <marex@denx.de>

----
V2: Added WATCHDOG_RESET as suggested by Marek Vasut
add error message when stop fails

mxc_i2c: code i2c_probe as a 0 length i2c_write

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Acked-by: Marek Vasut <marex@denx.de>
Acked-by: Stefano Babic <sbabic@denx.de>

---
v2: add acks
mxc_i2c: remove redundant read

wait_for_sr_state returns i2sr on success
so no need to read again.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Acked-by: Marek Vasut <marex@denx.de>

---
v2: add ack
mxc_i2c: place imx_start code inline

imx_start is only referenced once so
move to that location.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Acked-by: Marek Vasut <marex@denx.de>

---
v2: add ack
mxc_i2c: place i2c_reset code inline

imx_reset is only referenced once so
move to that location.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Acked-by: Marek Vasut <marex@denx.de>

---
v2: add ack
mxc_i2c: don't disable controller after every transaction

This helps in a multiple bus master environment which
is why I also added a wait for bus idle.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>

---
v2: no change
mxc_i2c: change slave addr if conflicts with destination.

The i2c controller cannot be both master and slave in the
same transaction.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>

---
v2: no change
mxc_i2c: check for arbitration lost

No need to continue waiting if arbitration lost.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Acked-by: Marek Vasut <marex@denx.de>

---
v2: add ack
mxc_i2c: add retries

Retry unexpected hardware errors. This
will not retry a received NAK.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>

---
v2: if i2c_init_transfer_ returns no error, then return 0
mxc_i2c: add i2c_regs argument to i2c_imx_stop

This is prep work for CONFIG_I2C_MULTI_BUS.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Acked-by: Marek Vasut <marex@denx.de>

---
v2: add ack
mxc_i2c: prep work for multiple busses support

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>

---
v2: moved global data to static ram section available before ram
is initialized and removed typedef as suggested by Marek Vasut
and Heiko Schocher

make toggle_fn return int.

v3: rename toggle to idle_bus
mxc_i2c: add bus recovery support

Add support for calling a function that will toggle the
SCL line to return the bus to idle condition.

The actual toggling function is added in a later patch.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>

---
v2: commit log change, global data in sram section.
make toggle_i2c return int

v3: rename toggle to idle_bus
mxc_i2c: finish adding CONFIG_I2C_MULTI_BUS support

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>

---
v2: global data in sram section
iomux-v3: remove include of mx6x_pins.h

This include is not needed.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>

---
v2: no change