drivers: i2c: several updates

qup_i2c: set up node before calling of_i2c_register_devices

Device-tree framework for I2C expects adapter of device's
of_node to be initialized before adding I2C slave devices
on the bus.

---

qup_i2c: turn off the ahb clock conditionally

Each GSBI has QUP-I2C and UART cores which can be
used independently. However, the AHB clock is
shared by these blocks. So we keep it on if the
cores are used independently from different processors.

---

qup_i2c: Add runtime PM support to I2C QUP controller

Runtime PM is used to turn clocks on and off when the
controller is not in use. When the controller is used
for messaging, pm_runtime_get_sync is called before
sending the message. pm_runtime_mark_last_busy and
pm_runtime_put_autosuspend are called when message
is sent and/or response is received.

---

qup_i2c: Manage gpio configuration from runtime pm

Due to gpio_request and gpio_free calls are made from
multiple places in i2c driver code and can cause erroneous
condition where same gpios are assigned/freed multiple times.

Move the gpio reques/free calls under runtime pm to
manage better.

---

qup_i2c: Set parent device to enable runtime PM support for clients

Register the current device as parent of the adaptor device in order to
allow the client drivers to use runtime PM.  Client drivers can vote to
enable and disable clocks as needed.

---

i2c_qup: always set rate and log a message when fail

Clock set rate is failing silently when clock rate is not
available. Additionally clock rate is not set when no rate
is specified in platform data. This patch always set the
clock's rate and logs a message if it fails to set rate
or if no rate is set by platfrom data.

---

qup_i2c: Avoid potential panic issue

I2c register access is happening in isr before PM runtime
status check. This can lead to potential hang because of
unwanted interrupts and i2c clocks are off.

Update the i2c driver code to have register access
after PM runtime status check.

---

qup_i2c: Use separate variables to store i2c gpios settings

In i2c bus recovery function GPIO settings for both
SCL and SDA are stored in one variable in this order
before writing recovery settings.
So, SCL setting is overwritten with SDA setting.
And when saved gpios settings write it back after
recovery, the setting for SDA is written both on SCL and SDA.
It means the setting of SCL is broken.

Use separate instances of variables to store GPIO settings
of SDA and SCL separately

---

qup_i2c: Update clock ready check condition

While doing i2c transfer that involved write and
immediate read, the driver will put the controller
to RESET and do an immediate read before the write completes.
This issue is hard to produce internally because clock stretch
from slave device is involved during the failure time. CLK
state in QUP status register will be FORCED_LOW_STATE.

O/p fifo empty check added to determine clock idle.

---

msm: i2c-qup: Add Device Tree support for i2c GPIOs

i2c_qup driver can execute i2c recovery only when it knows
the i2c bus GPIO numbers. The driver has facility to read
these values from board files but not from device tree.
This patch allows to specify the i2c GPIO numbers from
the device tree.

---

qup_i2c: Add vote for clock path

Currently the i2c driver votes for its core clock. However, it is
possible that the core-clock's source will be off. When the source
is off, the i2c core is not clocked. This patch adds voting for
the entire clock path, thus guarantee clocking to the i2c core.
Voting for the path cost a few msecs. A client may choose when
to pay this overhead. By default the votes takes place in the
runtime-pm callbacks which tie to transaction requests. A client
may choose to invoke these callbacks itself whenever it likes
by directly calling the driver's runtime-pm. A third option is
to set the active_only flag in platform data which results in the
callbacks being called when the application processor power state
changes.

---

i2c-qup: Verify that mem resource exists prior to redirection

Redirection may cause a system crush in the case of a missing
memory resource specification. Now when reading a memory resource
from platform data, the return value is checked before doing
redirection on the resource.