msm_fb: display: Enable MDP clock's overlay block during panel on

MDP clock's overlay block is enabled during first update after panel
on currently. This is now moved to panel on to keep clock enabled
right from display on time.

Signed-off-by: Ravishangar Kalyanam <rkalya@codeaurora.org>
CRs-fixed: 368167
(cherry picked from commit 24502cb2cfd176d72cc6884dbeb375c7fb054766)

Change-Id: I6c23396cad4f9ec4d520d82c276bb079b48757cd
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp4_overlay_lcdc.c
mmc: msm_sdcc: Revert to the older clock-APIs

Use the clock APIs which can be called from the atomic context.

CRs-Fixed: 377874
Change-Id: I0b711e946ad74f953f67f491d767e381c2b0d41b
Signed-off-by: Pratibhasagar V <pratibha@codeaurora.org>
msm: smd_pkt: Fix wakelock concurrency issue

In failure conditions, some clients violate the SMD PKT restriction of
single-threaded access resulting in overlapping open requests which
corrupt the wakelock list.

Move the wakelock initialization into the channel mutex to prevent
concurrent access from corrupting the wakelock.

CRs-Fixed: 374644
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>

(cherry picked from commit b399a4fbce9c9b20ef258e3245e916cd9ce788e2)

Conflicts:

	arch/arm/mach-msm/smd_pkt.c

Change-Id: I43df498cbf3480b8e345900be49c16afc4669f4a
Signed-off-by: Subrahmanyam Uppala <csuppal@codeaurora.org>
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
power_supply: add change the scope property

The scope property indicates the operating mode of the system. This
property could be used to switch to and from usb host mode.

Add a helper api to update this property.

CRs-fixed: 373365 368475
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 59d890ff84c431d1cf56118ba0c5892b7d9b7a06)

Change-Id: I3ed91574dddedc795fd6bdce7abb729c3116221a
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
power: pm8921-charger: support dc charging while in usb host mode

The current code disables charging when the usb is operating in host
mode. This unnecessarily stops charging from the DC path. The board
layout (the ovp fet and otg path) is assumed to support host mode and
charging from dc path.

Also make the usb driver change the power supply framework's scope
property instead of calling 8921 charger apis directly.

CRs-fixed: 373365 368475
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 5e96aaa4c667b34b354a100cbe7b0c3da01cc3d4)

Conflicts:

	drivers/power/pm8921-charger.c

Change-Id: I852fbee9f1fec6d9f55b8f5583023f029cb6ec63
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
power_supply: add SCOPE attribute to power supplies

This adds a "scope" attribute to a power_supply, which indicates how
much of the system it powers.  It appears in sysfs as "scope" or in
the uevent file as POWER_SUPPLY_SCOPE=.  There are presently three
possible values:
	Unknown - unknown power topology
	System - the power supply powers the whole system
	Device - it powers a specific device, or tree of devices

A power supply which doesn't have a "scope" attribute should be assumed to
have "System" scope.

In general, usermode should assume that loss of all System-scoped power
supplies will power off the whole system, but any single one is sufficient
to power the system.

Change-Id: Ib0d844dc7f0c175ee0ccb5307df7f85bf8797658
Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Richard Hughes <richard@hughsie.com>
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
Bluetooth: Update Local COD to bluez userspace on write complete.

Class of device information is required to the bluez userspace
to write to persistant storage and also update upper layers on
request. So update the local CoD info to bluez once the hci write
is successful.

CRs-fixed: 375304
Signed-off-by: Srinivas Krovvidi <skrovvid@codeaurora.org>
(cherry picked from commit 58562d8177e97893c27d04a378867e714029e620)

Change-Id: I88355cbf128f8e5f9b85f2a4bcfcdea4ab3b0f78
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
msm-fb: display: lm2 writeback support on mpq platfroms

lm2 writeback has broken on mpq platfroms as lm1 and lm2 are
selecting the same axi writeback path. It adds the support
to select the right axi writeback path based the availability
of the write master

CRs-fixed: 375340
Signed-off-by: Nagamalleswararao Ganji <nganji@codeaurora.org>
(cherry picked from commit b411a253ea37acbe8cc817bf004ae08d877d9bd1)

Change-Id: I06917794b08fa4dadb5ecf0ec6867b26cba106c5
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
diag: Add missing SSID range

OEMs use SSID in a specific range. Recently DIAG changed the mask
update algorithm and this range was missed as its not used internally.
This change adds it back.

CRs-fixed: 359379
Change-Id: Ib7249f157e4e37294b6da6580fcf19995afeef8f
Signed-off-by: Shalabh Jain <shalabhj@codeaurora.org>
(cherry picked from commit 44b79b7bb5aeeaa2c956ce0fd1e605d840c55a73)

Conflicts:

	include/linux/diagchar.h

Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
msm: bam_dmux: Add locking around platform device calls

The channel state is used to determine if a platform device has been
registered on a particular channel.  In the case of a subsystem restart
while a channel is being opened, the subsystem restart can occur between
the channel state being set to opened and the platform device being
added.  This will result in the subsystem restart code seeing that the
channel is open and attempting to remove a platform device that has been
added.

This change adds mutex protection around the channel state updates and
the platform device add/remove calls to handle any race conditions.

CRs-fixed: 378060
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit a623da8bda62e95acf5991905af2847e8e326e09)

Change-Id: I8eef024141a2c81552439856aa9c77fc491354a3
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
hwmon: pm8xxx-adc: Update pa_therm mapping table

Inaccurate temperature readings are reported for
pa_therm when read from the apps. This is because
an inaccurate B constant was used while calculating
the voltage to temperature mapping table. Fix it
by generating the table using the correct B constant
for the thermistor.

CRs-fixed: 374589
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
(cherry picked from commit 9ae3efba35a5291df925bc645662dd2c5fbd4efb)

Change-Id: I879f6281efe6afed8ff5a3037ca34d2988d231a5
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
msm_fb: Check for Histogram NULL while queuing work

Don't queue the work if the user hasn't requested for the
histogram data

CRs-Fixed: 365729 363763
Signed-off-by: Jeevan Shriram <jshriram@codeaurora.org>
(cherry picked from commit ff42a9a426ab9a76d75a29464412807dd72ceb13)

Change-Id: If5e6a5ad525e895ff7c2f27666cc7a445c485cb4
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
video: msm: Always queue histogram work

Always queue histogram read worker in order to gain concurrency protection
from the histogram management mutex (move previous checks/calls into worker
itself).

CRs-fixed: 363763
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit c0d815c2a4118d1ba51e316c6cb59bee4d68eb9b)

Change-Id: I8970021ff300c08131bdc1fbf3efdc74623bdb90
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
video: msm: Always queue histogram work & lock histogram calls

Always queue histogram read worker in order to gain concurrency protection
from the histogram management mutex (move previous checks/calls into worker
itself).

Lock the mdp_histogram_start and mdp_histogram_stop calls with the same
lock used currently by mdp_do_histogram to maintain that every do_histogram
called between a start and stop will be completed.

Add a timeout to do_histogram wait_for_completion so that it will unlock
and yield to other histogram calls if it waits for longer than 33 msec.

CRs-fixed: 363763
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 56a123baaab84af584fbbf5cbb29955ec5c92f39)

Change-Id: I803b6457523d1af13cc83e459a8b0fe2829badf8
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm_fb: Handle multiple histogram reader errors during suspend/resume

If a histogram reader waits for completion in the do_histogram ioctl
and during this time the device is suspended, the complete for this
gets called from mdp_histogram_ctrl_all() in the panel_next_off()
sequence. This results in mgmt->hist not set to NULL. The subsequent
do_histogram ioctls after device resume fail due to multiple reader
failure condition since the histogram irq will be enabled now from
the same mdp_histogram_ctrl_all() during panel_next_on() sequence and
this by-passes mgmt->hist getting set to NULL that is present in
histogram_start() ioctl. Handle this scenario.

CRs-fixed: 363763
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
(cherry picked from commit a43f44b44ee221df11ad84b8536c1c8d5373cbaf)

Change-Id: If0a45a8215a969bf6f137e19f2536d6d4abce156
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
video: msm: Fix corner cases of "read twice" error

Fix several cases where histogram's completion structure is completed
multiple times which causes the next histogram read to force the histogram
software state machine into believing that the histogram is always being
read by someone.

When the timeout in mdp_do_histogram times out and then soon after the work
that was being waited on completes, the next do_histogram call that is
processed will not wait (and thus will not have its hist field set to
NULL). This will cause all subsequent do_histograms to think that the
histogram is currently being read, and will cause the "read twice" message
to flood the kernel logs.

This error is fixed by always initializing the completion structure before
waiting for the histogram to complete. That way if the completion happens
after the timeout, instead of causing the error, the completion's internal
counter is reset to zero, which prevents the next histogram read from
completing without waiting.

CRs-fixed: 363763
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 3d297368b8199b07bda815915e94ecb5761561b0)

Change-Id: Ibb47ceae75fdd7347b1c3474cb16a394eff40446
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: camera: Send camif error notification to user.

In case of CAMIF errors, notify the user so that it
can cleanup resources and exit gracefully.

CRs-Fixed: 371688
Change-Id: I8340627931ce07788abc1418100826f1ac94ef6c
Signed-off-by: Kiran Kumar H N <hurlisal@codeaurora.org>
msm: kgsl: Add TLB flush for each submit in case of 8x25/7x2xa

Add TLB flush for each submit to prevent target freeze
in case of 8x25/7x27a/7x25a targets.

CRs-fixed: 379991
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>
(cherry picked from commit 22a06d18c6eb100419616ddf7a2c4ac403420a9e)

Change-Id: I7c34660128c791c9329b41246af39879625d64d3
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>