drivers:misc: ti-st: avoid a misleading dbg msg

Previously the private data of each protocol registered to use ST was
used to determine whether the protocol was registered to use shared
transport or otherwise.
However, now a flag is_registered is maintained to identify whether a
protocol intends to use ST.
Upon closing of the UART the error message relevant to this lack of
un-registration was misleading and this patch fixes that.

Change-Id: I1a452dccd7b4bd53cce923df5b61ce077b7aa466
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
drivers:misc:ti-st: platform hooks for chip states

Certain platform specific or Host-WiLink Interface specific actions would be
required to be taken when the chip is being enabled and after the chip is
disabled such as configuration of the mux modes for the GPIO of host connected
to the nshutdown of the chip or relinquishing UART after the chip is disabled.

Similar actions can also be taken when the chip is in deep sleep or when the
chip is awake. Performance enhancements such as configuring the host to run
faster when chip is awake and slower when chip is asleep can also be made
here.

Change-Id: I5baad900633e69740396bf1d6900feec4f2b596e
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
drivers:misc: ti-st: reinit completion on ver read

After the version information has been read, the completion which assists in
wait_for_completion during the firmware send/wait sequence is being re-used
and hence this needs to be re-initialised for fool proof firmware download
retries.

Change-Id: Ia75485b83992ecbdd70cfcf15a41f551a1d86c56
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
drivers:misc: ti-st: fail-safe on wrong pkt type

Texas Instrument's shared transport driver interpret incoming data from the
UART based on the various protocol drivers registered to the driver such as
btwilink driver or FM or GPS driver which provide logical channel IDs.

In case of bad-behavior from chip such as HCI Event response for a GPS command
or a HCI Event (h/w error event) for a FM response & In case of bad-behavior
from UART driver such as dropping data bytes a fail-safe is required to avoid
kernel panic.

Change-Id: I4a0b4b3152a27830ae85f986f5f2de922f007cd2
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Vijay Badawadagi <bvijay@ti.com>
drivers:misc: ti-st: reinit completion before send

download firmware behaves differently at different times, when logs are
enabled and the system is loaded, the wait_for_completion is able to wait for
every send, However during other times the wait does not happen.

So, for reliability reinitializing the completion before every send, makes
sure the wait happens for every send.

fixes: OMAPS00245110

Change-Id: Iff96d806a06338aadad65c43c272c205660c78d1
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
drivers:misc: ti-st: free skb on firmware download

If during validation of the firmware download the data doesn't match what is
expected out of the chip, this calls for a firmware download failure and a
retry.
Free the SKB which collects response during such scenarios.

Change-Id: I78dc3bdc4ea87faa5dce7eea61371718999d3f87
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
drivers:misc: ti-st: wait for completion at fail

When the line discipline install fails for reasons such as missing user-space
UIM or broken communication between UIM and ST driver, then the ST
attempts/retries to request for ldisc installation again.
based out of: OMAPS00246156

Change-Id: Ib1cd03ebd078bbbc2d93b68a37ba2ce1e7fa497e
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
drivers:misc: ti-st: fix unexpected UART close

If suppose the UIM were to die and hence UART were to close when the
Bluetooth/FM or GPS is turned on, prep the ST for a state where-in if
the UIM comes back up, Bluetooth/FM/GPS can be turned on.

Change-Id: If3a0f100c69d485c343e189c4a483db26961b6b7
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
drivers: misc: ti-st: Added BT enable/disable hook

Added functionality to call UART get sync/put sync
through pltform board file for run time PM adaptation.

Change-Id: Ieb9676391b1472d84355615eef9ba442fcb5fd81
Signed-off-by: x0099048 <x0099048@ti.com>
drivers:misc:ti-st: protect against bad packets

We encounter situations where we got bad packet type from the
UART (probably due to platform problem or UART driver issues)
which caused us out of boundary array access,
which eventually led to kernel panic.

Change-Id: I6f0f13168c69e46260c5abb7d7c0b854c61cab7d
Signed-off-by: Amir Ayun <amira@ti.com>
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
drivers:misc: ti-st: protect registrations

Concurrent access to UART2/combo-interface by multiple protocol drivers such
as BT, FM and GPS caused issues during firmware download failure cases or
cases when the firmware download took longer than usual.

This was because of un-safe access to protos_registered & st_states.
Protecting this will also make the registration complete callback un-safe for
sleep.

Change-Id: I1163587ee4ee7561ca591a874f5c403f7da84e58
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
drivers:misc: ti-st: flush UART upon fw failure

Upon failure to read firmware version from chip or upon failure in responses
to firmware download the UART needs to be flushed of its existing buffers so
that the UIM can restart UART properly.

Change-Id: I7eed959b80ead5dadc6ba4cccb8e6512e45fd047
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
drivers:misc:ti-st:remove redundant enable/disable

Platform specific chip enable/disable function need to be called only once
during the chip initialization routine.
This is to enable any platform specific initialization to be done for a given
platform.

Change-Id: I7fa815c073e424d745dd4a2d84efc07bf64a0490
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
drivers:misc: ti-st: DEBUG uart, baud rate mods

To debug different UARTs at different baud-rates connected to the WiLink
connectivity combo-chipset, this patch enables the debugging code so that upon
boot different UARTs at different baud-rates can be tried out to verify the
interface with WiLink.

Change-Id: Ib178e54c0e08b28e484efc60f330985da05ea0cc
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
drivers:misc:ti-st: Send wake_up_ack also in awake state

In case a wake_up_ack packet the host send to the BT device is lost,
the BT device will send another wake_up_indication.
Since the host was already in awake state, it did not answer the wake_up_indication.
It is safe to send wake_up_ack every time we get the wake_up_indication,
even if we are already in awake state or in transition state from sleep
to awake.

Change-Id: I99dd0872f8ef041b7886aa06a731071386ac4ad3
Signed-off-by: Amir Ayun <amira@ti.com>
drivers: misc: ti-st: Add missing carriage returns in print-functions calls

Due to missing carriage returns in print-functions calls
sometimes it's hard to read kernel log.
Fix this so now kernel log reading is more easy.

Change-Id: I033126f24e5819b2f97564bafd30b3156a95c06c
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>
GPS: GPS Char Driver for Texas Instrument's Connectivity Chip.

This enables the GPS driver for TI BT/FM/GPS combo devices.
It will provide a character device for the TI GPS host software to
access the GPS core.

Change-Id: I7ee0c058a649d19f83e603db89961b5daca26b33
Signed-off-by: Satish Chandra <x0141690@ti.com>
OMAP4: ST: Disabling UART if ldisc not installed.

In cases when there is no line discipline to be installed UART chip must be
disabled.

Rationale: if ldisc is not installed so it can't be uninstalled.
Thus UART chip still enabled and we have wakelock for it
(see plat_uart_enable() function in both blaze and 44xx-tablet board files).
In that case we can't go in suspend mode.

Motivation: when using busybox ramdisk (e.g. for testing kernel w/o AFS) we
have no ldisc that causes impossibility to go to suspend mode.

Change-Id: I6fac0b9411ed765e8e598328b89a41a50b5fbfea
Signed-off-by: Semen Protsenko <semen.protsenko@ti.com>