Commit graph

570530 commits

Author SHA1 Message Date
Asutosh Das
a4ec42db59 mmc: sd: Set the card removed if card detect fails
Currently, the card state is not being set as removed, even
when the card is actually removed. We still wait for the
next request to fail and then check the error and set the
card to be removed.

With the new runtime-pm in place, the card device would be
removed on physical removal of card and the corresponding
parent would be suspended as well. Hence, when the queue is
flushed during clean-up, mmc_rpm_hold would be invoked,
which would fail, since the runtime-pm was disabled when the
card device was removed. Thus, it won't resume the card/host/
platform device. The request would continue and since the
controller is in suspended state nasty things would happen.

This patch sets the card as removed during mmc_sd_detect
itself, so that when a clean-up of queue happens during
card removal, it is known that the card has been removed
and the request is errored out there itself.

Change-Id: Id5022f8d7db43750edf137d4293796615b56ae36
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2016-05-31 15:20:48 -07:00
Subhash Jadavani
20537f4aae mmc: card: abort the suspend if the card is busy
mmc_blk_suspend() is triggered when system is going into suspend which
then waits for the mmcqd thread (which processes active MMC transfer
requests) to complete all queued transfer requests but if mmcqd has
multiple requests to be processed at this point, mmc_blk_suspend() may
very well sleep for duration longer than DPM (Device Power Management)
timeout (currently 12 sec) causing the DPM timeout bug.

To fix this issue, mmc_blk_suspend() checks if there are any more pending
MMC requests in progress or not and if there are any, it returns error
which should abort the ongoing system suspend.

CRs-Fixed: 439192
Change-Id: Ic7ba2f013d10a1952c30ea2ed93f74b831fcc27d
[subhashj@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-31 15:20:25 -07:00
Sujit Reddy Thumma
7d7218224b mmc: core: Add a debugfs entry to set max clock rate
Limiting the max frequency supported by host controller
to a certain value can be useful for testing power consumption
at various frequencies that are supported by the host.

Note: If the card supports less than desired value then the
frequency of operation would be limited to that frequency.

Usage:
mount -t debugfs none /sys/kernel/debug
echo <desired_frequency> > /sys/kernel/debug/mmcX/max_clock
cat /sys/kernel/debug/mmcX/max_clock

Change-Id: I9e9a7e368f56d8e16548780288211bd8775fd048
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
2016-05-27 10:29:15 -07:00
Sujit Reddy Thumma
f3bca6c776 mmc: core: Allow changing bus frequency for SD/eMMC cards in runtime
Currently, bus frequency is set during the card initialization and
never changed until a new card is inserted. In some low power use
cases, scaling the clock frequencies while the card is in transfer
state would allow power savings. This change allows bus frequency
to be changed after the card initialization.

Change-Id: Iac064221199f69d162d91f5311becd735c15700a
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
[merez@codeaurora.org: remove mmc and sd ops_unsafe settings as they are not in 3.14]
Signed-off-by: Maya Erez <merez@codeaurora.org>
[venkatg@codeaurora.org: Fix refactor of mmc_card_* functions as used
in 3.14 kernel]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts & fixed
compilation error]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-27 10:29:15 -07:00
Subhash Jadavani
3d6d2ddeaf mmc: core: Attribute the IO wait time properly in mmc_wait_for_req_done()
In mmc_wait_for_req_done() function, change the call wait_for_completion()
to wait_for_compltion_io(). This change makes the kernel account for
wait time as I/O wait and through another configuration, this io wait
is treated as busy which makes the acpu clock to scale up.

Change-Id: Iebdc7b1b22871bf845f10a55e2272816c72d9964
Signed-off-by: Murali Palnati <palnatim@codeaurora.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-27 10:29:14 -07:00
Sahitya Tummala
7c957dec83 mmc: sdhci: rate limit sdhci_dumpregs() prints
Rate limit sdhci_dumpregs() prints to avoid unnecessary
and exessive logging which can sometimes lead to watchdog
timeouts (especially due to bad cards).

Change-Id: Ib6be6d563e47c2d2e9e1b6b0410c2c45712a9b17
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2016-05-27 10:29:14 -07:00
Maya Erez
e5bd1357a1 mmc: host: sdhci: allow definition of pm QoS via dts file
Add a new dts entry to define the CPU affinity in order to maintain
the IRQ pm_qos (Quality of Service) for targets that don't have little
cluster and allow setting the pm_qos to the little cluster,
to improve its performance.

Change-Id: Icf6125066d96331392d98a387974e54c96553306
Signed-off-by: Vince Leung <vincentl@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
2016-05-27 10:29:13 -07:00
Gilad Broner
7cda2fabdb mmc: sdhci-msm: force 32bit ADMA descriptors
SDCC AXI master uses 32-bit addressing so there's no need to use
64-bit descriptors. Using 32-bit descriptors instead will reduce
the memory footprint.
This change masks the 64-bit capability to force 32-bit ADMA
descriptors.

CRs-Fixed: 719303
Change-Id: Ifb8095763136bbc795227bdfcb346d1e1fae42c7
Signed-off-by: Gilad Broner <gbroner@codeaurora.org>
2016-05-27 10:29:13 -07:00
Venkat Gopalakrishnan
9e36f69ea1 mmc: sdhci-msm: Add dual voltage capability
SDCC5 controller doesn't advertise 1.8v capability by default.
Dual voltage capability is required for SD3.0 support. Add this
capability for controllers that support this based on
device tree configuration.

Change-Id: Ie4cd6db2e7230bc22cd393c8e37d99f49c777cd0
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-05-27 10:29:12 -07:00
Guoping Yu
9ce1e0b186 mmc: sdhci-msm: add nonhotplug support
With some devices like QRD SKUK, SD card could not support
hotplug as there is no cd-gpio, and also could not use polling
way due to power comsumption. So add nonhotplug to meet such
requirement and when SD card lost or removed manually, device
will not crash until next reboot process to detect SD card.

Change-Id: I318d3db72fc09248c5dada2fb6d69ade1bbf85cb
Signed-off-by: Guoping Yu <guopingy@codeaurora.org>
2016-05-27 10:29:11 -07:00
Guoping Yu
eef1739c44 mmc: sdhci: add support nonhotplug
With some devices, SD card could not support hotplug as there is
no cd-gpio, and also could not use polling way due to power
comsumption. So add nonhotplug to meet such requirement and when
SD card lost or removed manually, device will not crash until
next reboot process to detect SD card.

Change-Id: Ie8ea8ec57015f36689a119249003eeaa48391393
Signed-off-by: Guoping Yu <guopingy@codeaurora.org>
[subhashj@codeaurora.org: fixed minor merge conflict]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-27 10:29:11 -07:00
Asutosh Das
195613ce19 mmc: sdhci-msm: fix possible NULL pointer dereference
The platform_get_resource API may return NULL, hence check
the return value before using the mapped memory.

Change-Id: I28741554f8e1b5843671ee0d6b08bdcf8e4469c9
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2016-05-27 10:29:10 -07:00
Venkat Gopalakrishnan
902d330476 mmc: sdhci-msm: Reduce the max descriptors
8K is the max descriptors supported by the hardware per transfer.
On normal use cases we never use that many descriptors even if
the memory is extremely fragmented. The memory allocated for these
descriptors are never freed hence wasting memory otherwise
available for the system. Reduce the max descriptors to 512 to save
memory (128K with 8K descriptors vs 8K with 512 descriptors) and
still support maximum performance.

CRs-fixed: 684185
Change-Id: Ib57ce03834d741c0fda4195a58d6b287ee9fb0a0
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-05-27 10:29:10 -07:00
Venkat Gopalakrishnan
10cf95ae77 mmc: sdhci: Add tracepoints to enhance debugging
Instrument the sdhci driver with tracepoints to aid in
debugging issues and identifying latencies in the following
path:
* CMD completion
* DATA completion
* DMA preparation
* Post DMA cleanup

Change-Id: Ie8cd0c2fb6c1bd6ab13883123be021081f8b8f78
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
[subhashj@codeaurora.org: fixed minor merge conflict]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-27 10:29:09 -07:00
Sahitya Tummala
9ecd592125 mmc: sdhci: Vote for new IRQ specific QoS request
The current vote applies to all CPUs and hence may have power
impact, especially when there are more number of CPUs. The new
IRQ specific QoS request shall update the vote only for one
CPU to which the IRQ's smp_affinity attribute is set to.

Change-Id: I55298f729949c39ebfa3eecd4746d77e40cb2e5c
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2016-05-27 10:29:09 -07:00
Subhash Jadavani
2e08a5f0a4 mmc: sdhci-msm: configure CORE_CSR_CDC_DELAY_CFG to recommended value
Program CORE_CSR_CDC_DELAY_CFG for hardware recommended 1.25ns delay.
We may see data CRC errors if it's programmed for any other delay
value.

CRs-Fixed: 683894
Change-Id: Id7de28b7b9222c35e6b419e416f72bd8f98cbaf8
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-27 10:29:08 -07:00
Krishna Konda
a2fbfacff0 sdhci: sdhci-msm: fix issue with hs400 mode
In HS400 mode, command line is still operated in SDR mode and not
DDR mode like data lines. So in order to correctly process command
responses, the hardware needs to be set appropriately or else there
will command crc or similar errors due to incorrect sampling of the
response.

Change-Id: I426ff4fc4798afae254d11a608c800dc0b7bf765
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
2016-05-27 10:29:08 -07:00
Krishna Konda
7302266f4c sdhci: sdhci-msm: update dll configuration
The newer msm sdhci's cores use a different DLL hardware for HS400.
Update the configuration and calibration of the newer DLL block.

The HS400 DLL block used previously is CDC LP 533 and requires
programming multiple registers and waiting for configuration to
complete and then enable it. It has about 18 register writes and
two register reads.

The newer HS400 DLL block is SDC4 DLL and requires two register
writes for configuration and one register read to confirm that it
is initialized. There is an additional register write to enable
the power save mode for SDC4 DLL block.

Change-Id: I20ddeaee9309c43cd51bebdfc02d70553c9d2a87
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
2016-05-27 10:29:07 -07:00
Sahitya Tummala
87baaf7467 mmc: sdhci-msm: Fix issue with SD card detect GPIO
Set up the card detect GPIO in active configuration before
configuring it as an IRQ. Otherwise, it can be in some
weird/inconsistent state resulting in flood of interrupts.

Change-Id: I8f2344a72acbd48df745cc9b2602fe4ac6f034d4
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2016-05-27 10:29:07 -07:00
Matt Wagantall
28f9d7aa7b mmc: sdhci-msm: Correct usage of readl_poll_timeout() API
The intention of sdhci_msm_probe() was to wait up to 1ms for
CORE_SW_RST to be set, but only a 10us timeout was passed to
readl_poll_timeout().

Correct the timeout value to be 1ms, and decrease the sleep
time between read attempts to only 10us so that it's less
than the expected wait time of 40us.

Change-Id: I7007a68232bfba76409e2dbae3060622fa5c1913
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
2016-05-27 10:29:06 -07:00
Venkat Gopalakrishnan
81dd76ac07 mmc: sdhci: Poll for register status much tightly
On fast path, waiting for 1ms interval to poll registers cause
performance degradation. Also having 1ms delays for polling with
interrupts disabled cause considerable system latencies, hence
poll at 1us interval.

Change-Id: I40113ccf56050b3c46604112846e9b37b254d2be
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
2016-05-27 10:29:06 -07:00
Sahitya Tummala
93a9fa1e47 mmc: sdhci: Fix issue with host op card_event()
For controllers that doesn't support card insertion/removal i.e.,
when the quirk SDHCI_QUIRK_BROKEN_CARD_DETECTION is defined,
card_event() host op must not rely on present state register
to check the card's status.

CRs-fixed: 644221
Change-Id: Icff6db0d8fe17f01cf751896ae09aee215edc548
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2016-05-27 10:29:05 -07:00
Sahitya Tummala
80a4d5b5a5 mmc: sdhci-msm: fix issue with SD card tuning functionality
The commit 'e2598c - mmc: sdhci-msm: improve tuning process'
introduces NULL pointer dereference bug for SD 3.0 cards
when all the tuning phases pass. It uses mmc_card_mmc(card)
for checking the card type but card is initialized after
tuning is done for SD card and thus resulting in NULL
pointer dereference issue.

CRs-fixed: 640424
Change-Id: I59a8d5f017243d8391269bc98998bb37fc44f685
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2016-05-27 10:29:05 -07:00
Sahitya Tummala
1eb5446550 mmc: sdhci-msm: fix issue with tuning command
As of now we ignore CRC/INDEX command failures to tuning command
and still wait for data from card but in case the card did not
receive the command, it won't send the data. This is causing
software request timeout for tuning commands. Hence, software
must not ignore such cmd errors for tuning commands but end the
request immediately after resetting the controller for both CMD
and DATA. Also, wait for 146 MCLK cycles for card to send out the
data and thus to move to transfer state. Its corresponding phase must
also be considered as bad phase.

CRs-fixed: 625855
Change-Id: Ic8462dd9c67e4f18a3ce73d972591772be8c6d10
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
[subhashj@codeaurora.org: fixed minor merge conflict]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-27 10:29:04 -07:00
Krishna Konda
b0d11d554c mmc: sdhci-msm: improve tuning process
In newer hardware, the tuning process is not able to always
find a reliable phase to use for sampling data. This is mostly
due to hardware. This problem manifests itself as all successful
tuning phases, which means that the phase choosen could be a bad
one but is not identified as such at the time of tuning. So in
order to work around this, rely on optional drive types implemented
by the eMMC card, in addition to the mandatory drive type (50 ohm).

By using drive types supported by the card, when all phases are
sucessful in tuning, change drive type to a different value in the
list of supported drive types and retune. This will continue for all
tuning phases until a valid one is found. After that the drive type
is reset to the default one, if changed.

Change-Id: I348fb30daa43d97c58f83f7e4a22019f94ef4954
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
[venkatg@codeaurora.org: rename cmd_timeout_ms to busy_timeout as
part of 3.14 kernel upgrade]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
[subhashj@codeaurora.org: fixed minor merge conflict & compilation
error]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-27 10:29:04 -07:00
Sahitya Tummala
21a9ae94b5 mmc: sdhci-msm: remove mach/gpio.h
This is needed for supporting 64-bit kernel.

Change-Id: Id4f60dc15688a6f02f31d77705ad1ef0181a1ce9
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2016-05-27 10:29:03 -07:00
Asutosh Das
03cfbbc1fc mmc: sdhci: finish the request if sdhc is in bad state
In the current code, if sdhci_check_state returns true a tasklet is
scheduled which doesn't complete the request if host->mrq is NULL,
which is the case, if sdhci is in bad state. This would make the
mmcqd thread wait for completion infinitely.
Hence, complete the request if sdhci_check_state returns true instead
of scheduling the tasklet.

CRs-Fixed: 615537
Change-Id: I8e2950c3999ac3806f9d631c52d86f0dc13b992f
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2016-05-27 10:29:03 -07:00
Sujit Reddy Thumma
1fc0342450 mmc: sdhci: clear interrupt status during controller reset
In some cases, it is possible that the hardware might trigger
an interrupt just about the same time the software tries to
reset the controller. In such case, the hardware interrupt will
be handled after the current thread release spin lock. This leads
to spurious interrupt handling after the completion of reset.

Change-Id: I75211adee1179b0636a918f5ceb68a072ad02a6c
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
2016-05-27 10:29:02 -07:00
Asutosh Das
c0a43df5f6 mmc: sdhci-msm: add default qos
If cpu-dma-latency is not defined in dts files, set it
to 200usec

Change-Id: I27b0357b4d88842a258332250bae66efac3ee5e2
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2016-05-27 10:29:02 -07:00
Raviv Shvili
da2e2cbd57 mmc: sdhci: change msm bus header file
There is a new header file for 64bit platforms.

Change-Id: Iead9ccab1fd0b7249baf670e67872fcffeccf21d
Signed-off-by: Raviv Shvili <rshvili@codeaurora.org>
2016-05-27 10:29:01 -07:00
Pratibhasagar V
5e8e7c2098 mmc: sdhci: Add support for pinctrl interface
Add support for Linux pin control framework while also supporting
the older TLMM configuration for backward compatibility

CRs-Fixed: 568232
Change-Id: Ib6b8f41fd6ced9aa62c980d7e4a73469603cbc5b
Signed-off-by: Pratibhasagar V <pratibha@codeaurora.org>
2016-05-27 10:29:01 -07:00
Sujit Reddy Thumma
d621731e5f mmc: sdhci: Fix possible spec. violation during voltage switch sequence
With commit 0797e5f145 (mmc: core: Fixup signal voltage switch), voltage
switch sequence for UHS-I cards is broken if used with sdhci driver.
The commit expects the SD clock to be disabled when mmc_set_ios() is
issued but sdhci_do_set_ios() re-enables the SD clock for few cycles
after disabling which is a specification violation during voltage
switch sequence. This failure is observed only for a small group of
cards where they ultimately fall-back into high-speed mode even if
UHS-I modes are supported.

Change-Id: Ie275326627a84bfcd4352637a043296c01c175a6
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
2016-05-27 10:29:00 -07:00
Sujit Reddy Thumma
d90d5901fa mmc: sdhci-msm: Fix clock gating while voltage switch is in progress
CLK_PWRSAVE bit in vendor specific register gates the output clock to
card automatically if there are no data/cmd operations.

According the SD3.0 voltage switch sequence the host should provide
clock to the card for atleast one millisecond before DAT[3:0] lines
are pulled high by the card. In this case if power save bit is enabled
it might auto-gate clocks even before the card completes voltage
switch sequence.

Fix this by disabling power save operation when the clocks are turned
off and enable only when clock rate is >400KHz i.e., end of initialization.

CRs-Fixed: 589992
Change-Id: If82d6d2e303b8d1189b76712e514f41fe6e2cf8b
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
2016-05-27 10:29:00 -07:00
Asutosh Das
e8279c9021 mmc: sdhci: do not use maximum timeout for all cards
Remove maximum timeout for all cards, since this causes
a long resume time for SD cards. Now only Hynix cards would
have this maximum timeout and this would be decided at the core
layer.

Change-Id: I758f9e5ecf407aba371928a86c313cf69e3cda63
CRs-fixed: 587284
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2016-05-27 10:28:59 -07:00
Pratibhasagar V
ef8a870827 mmc: sdhci-msm: Add software capabilities for 8-bit slot
With SDCC5 the capabilities register is not advertising the
8-bit capability feature (except for 8974 and 8084).

So add the software capabilities for 8-bit slot for rest of
the targets with SDCC5.

Change-Id: I288292f37d77507bf5aaa44bf156496b4df87234
Signed-off-by: Pratibhasagar V <pratibha@codeaurora.org>
2016-05-27 10:28:58 -07:00
Pratibhasagar V
7eba9c3c95 mmc: sdhci-msm: Add software capabilities for voltage init
With SDCC5 the capabilities register is not advertising the
3.0 voltage features (except for 8974 and 8084).

So add the software capabilities for voltage initialization
for rest of the targets with SDCC5.

CRs-Fixed: 568227
Change-Id: Ida53f5ad7249cd0cd8428b4839dfd932b04e31fa
Signed-off-by: Pratibhasagar V <pratibha@codeaurora.org>
2016-05-27 10:28:58 -07:00
Asutosh Das
21512ff949 mmc: sdhci-msm: enable controller clocks at MMC_POWER_UP
A callback to turn-on the controller clocks is implemented.
This callback would ensure that the pclk and mclk are enabled
but the output clock to the card is disabled.

CRs-Fixed: 567658
Change-Id: Ic97e600a6388fb64f1267a097b201f31d114a1fb
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
2016-05-27 10:28:57 -07:00
Asutosh Das
deba741527 mmc: sdhci: Turn on controller clocks and card power at MMC_POWER_UP
Currently, the clock to the card is enabled prior to enabling
the power to card. Specification requires that the power be
supplied first and then a delay of 10ms and then clock be
provided to the card.

In this, during MMC_POWER_UP mode, the controller clocks would be
ON and the power would be supplied to the card. In the MMC_POWER_ON
mode, the clocks to the card would be enabled and the rate set.
A callback has been provided to facilitate the enabling of
controller clocks.

CRs-Fixed: 567658
Change-Id: I2d66eae1581b9b136faaba4cafc330aeb6a3f364
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
[venkatg@codeaurora.org: Fix sdhci_set_power fn signature
as it changed in 3.14 kernel]
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
[subhashj@codeaurora.org: fixed minor merge conflict]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-27 10:28:57 -07:00
Asutosh Das
2c530476d3 mmc: sdhci: Use max timeout and skip timeout calculation
Several data-timeout issues were seen, most of which were
due to the card taking a longer time to respond. This patch
increases the timeout of the controller to 0xF i.e. max
possible.

Change-Id: I6739de3eb5d9cccf8e39d9dc4730056782334162
CRs-Fixed: 536832
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2016-05-27 10:28:56 -07:00
Krishna Konda
9df7e24765 mmc: sdhci-msm: set dma mask for lpae/64-bit machines
On machines that support more than 32-bit address via lpae or 64-bit buses
set the dma mask as 64-bit.

Change-Id: Ida88f3999fd5e7d09ebe73bb3481d3f1f4cf30c2
Signed-off-by: Krishna Konda <kkonda@codeaurora.org>
2016-05-27 10:28:56 -07:00
Sahitya Tummala
29ff049489 mmc: sdhci: Add new callback to enable/disable CDR
MSM SDHCI has CDR mechanism (clock-data recovery) to
automatically adjust the sampling point based on the
voltage/temperature variations. This must be enabled
for only read. Hence, add new host op toggle_cdr to
control CDR.

Change-Id: I75940cfca15fe88de6d46fe58cb33620a3b7ced1
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
[subhashj@codeaurora.org: fixed minor merge conflict]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-27 10:28:55 -07:00
Sahitya Tummala
f9359ba80e mmc: sdhci: initialize sdhci_host lock in sdhci_alloc_host()
Currently, the sdhci host lock is initialized in sdhci_add_host()
but there can be a case where it is required even before that.
Hence, initialize it in sdhci_alloc_host() where sdhci_host
structure is allocated.

Change-Id: If99d82679c07bc2d36e0aad9354757288aa400b8
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2016-05-27 10:28:55 -07:00
Asutosh Das
a45d072d68 mmc: sdhci: add support for configurable request size
Some platform drivers support more than 128 adma descriptors
and allows more than 512KB maximum request size per transfer.
Add a callback to get maximum supported adma descriptors from
platform driver instead of limiting host capabilities to
128 descriptors.

Change-Id: I0ac0ffbd0e792a76931e21b321b39c35195ac8d6
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
[subhashj@codeaurora.org: fixed minor merge conflict]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-27 10:28:54 -07:00
Stepan Moskovchenko
6d26067be7 mmc: sdhci-msm: set core in proper mode before reset
During probe disable the HC mode since the reset is done in
SDCC mode. HC mode will get set after the reset is complete
before the rest of the initialization is done.

Change-Id: I1fdc633c218447c15c8caad24e2805e7510088f2
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
2016-05-27 10:28:54 -07:00
Sahitya Tummala
c2037aa944 mmc: sdhci-msm: Fix issue with 1.8v switch sequence in 3.10 kernel
The SD3.0 voltage switch sequence to 1.8v would involve stopping the
SDCLK before changing the voltage level and with recent changes in 3.10
kernel, the peripheral clocks are also getting disabled instead of
just stopping the clock to the card. This patch makes sure this doesn't
happen by marking the flag card_clock_off in struct mmc_host before
starting the voltage switch sequence and checking it in host controller
driver.

Change-Id: If62378ba1dd369e69524365a4421d57317c22ca2
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2016-05-27 10:28:53 -07:00
Sahitya Tummala
2ba264341c mmc: sdhci-msm: Fix issue with power save bit enablement
The power save bit is currently enabled based on the clock
rate (clk_rate > 400KHz) within struct sdhci_msm_host. But this
clk_rate is updated with the latest value down in this function
sdhci_msm_set_clock(). So during runtime/system resume when the
card is still in initialization phase, the power save bit is
getting enabled when sdhci_msm_set_clock() is called for the
first time based on the previous rate which is wrong.

Change-Id: I05dc8a4a760f658935de3831aaf8dd3b2b996466
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
2016-05-27 10:28:53 -07:00
Sahitya Tummala
3118da1c32 mmc: sdhci-msm: Enable controller power save feature
Enable power save feature within controller by setting bit 1
in vendor specific register (0x10C). This allows controller to
disable SD clock when bus is idle to save power.

Change-Id: I916a5a414adb3f21dc3a75f3f86c3a81d6956dc8
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2016-05-27 10:28:52 -07:00
Asutosh Das
fb6a81715b mmc: sdhci-msm: Enable auto-calibration using auto-cmd21
This patch enables automatic calibration for eMMC devices
in using auto-command21. This feature is disabled by default
and can be enabled using the sysfs attribute
'enable_auto_cmd21'.

CRs-Fixed: 516314
Change-Id: I020c61cb9dee56c0ebe37864e67e4753ddee1adc
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
2016-05-27 10:28:52 -07:00
Asutosh Das
d938b50db5 mmc: sdhci: Add support for auto-calibration
This patch adds Programmable Delay Line auto-calibration
support if supported by respective hosts.If the host
supports auto-calibration this change would enable
sending CMD19/CMD21 before any read operation.

CRs-Fixed: 516314
Change-Id: I8a0f51206dc0e174519dd71f0c75267a9e08e7f7
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
[subhashj@codeaurora.org: fixed minor merge conflict]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-27 10:28:51 -07:00
Sahitya Tummala
d453e3e1ff mmc: sdhci: fix issue with auto cmd err detection
As per specification, auto cmd error status register is valid only
when auto cmd error bit is set in Error interrupt status register.

CRs-fixed: 515513
Change-Id: Id1013e1705d8efdba0171dcad14f783607d38ef3
Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
[subhashj@codeaurora.org: fixed minor merge conflict]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
2016-05-27 10:28:51 -07:00