ARM: OMAP2+: omap_device: maintain sane runtime pm status around suspend/resume

OMAP device hooks around suspend|resume_noirq ensures that hwmod
devices are forced to idle using omap_device_idle/enable as part of
the last stage of suspend activity.

For a device such as i2c who uses autosuspend, it is possible to enter
the suspend path with dev->power.runtime_status = RPM_ACTIVE.

As part of the suspend flow, the generic runtime logic would increment
it's dev->power.disable_depth to 1. This should prevent further
pm_runtime_get_sync from succeeding once the runtime_status has been
set to RPM_SUSPENDED.

Now, as part of the suspend_noirq handler in omap_device, we force the
following: if the device status is !suspended, we force the device
to idle using omap_device_idle (clocks are cut etc..). This ensures
that from a hardware perspective, the device is "suspended". However,
runtime_status is left to be active.

*if* an operation is attempted after this point to
pm_runtime_get_sync, runtime framework depends on runtime_status to
indicate accurately the device status, and since it sees it to be
ACTIVE, it assumes the module is functional and returns a non-error
value. As a result the user will see pm_runtime_get succeed, however a
register access will crash due to the lack of clocks.

To prevent this from happening, we should ensure that runtime_status
exactly indicates the device status. As a result of this change
any further calls to pm_runtime_get* would return -EACCES (since
disable_depth is 1). On resume, we restore the clocks and runtime
status exactly as we suspended with.

Reported-by: J Keerthy <j-keerthy@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
Acked-by: Rajendra Nayak <rnayak@ti.com>
mmc: omap_hsmmc: Fix pbias_disable for omap4

pbias_disable is set to protect the mmc pbias i/o cells in DT boot
by preventing voltage switch. Currently pbias_disable is enabled only
for omap3 and not for omap4 due to reg_offset difference of 0x100.
Enable pbias_disable for omap4+ too by using res->start
which does not include the reg_offset.

Signed-off-by: Balaji T K <balajitk@ti.com>
mmc: omap_hsmmc: correct max value of clkd

clock divisor can take a max value of 1023.
Update code so that card init can be handled at f_min even at
higher IP clock frequencies from which clock to the card is
derived.

Signed-off-by: Balaji T K <balajitk@ti.com>
mmc: omap_hsmmc: save clock rate to use in interrupt context

use cached clock rate in set_data_timeout, so
set_data_timeout can be called from interrupt context.
clk_get_rate throws DEBUG_LOCKS_WARN_ON(in_interrupt()) warning
if called from interrupt context.

Signed-off-by: Balaji T K <balajitk@ti.com>
mmc: omap_hsmmc: add support for Auto-CMD12

add Auto-CMD12 suuport for multi block read/write

Signed-off-by: Balaji T K <balajitk@ti.com>
mmc: omap_hsmmc: add cmd23 support

Add set block count command support for close ended
multiblock read/write.

Signed-off-by: Balaji T K <balajitk@ti.com>
mtd: tests: oobtest: fix test failures for oobsize which are not multiples of 4

If oobsize is not multiple of 4 then the generated data to write to flash
and data generated to verify are not same. This imapcts test cases 2,3 and 5.
If mtd->ecclayout->oobavail is not a multiple of 4 then while generating psuedo
random numbers to write to flash prandom_bytes_state () generates the extra
random bytes which wont be done if we do for the whole length. So check
for mtd->ecclayout->oobavail if its multiple of 4 then generate for full len
(mtd->ecclayout->oobavail * pgcnt)
else generate prandom of mtd->ecclayout->oobavail bytes pgcnt times.

Signed-off-by: George Cherian <george.cherian@ti.com>
mmc: omap_hsmmc: add autocmd23 support

Add support for autocmd23 support

Signed-off-by: Balaji T K <balajitk@ti.com>
mmc: omap_hsmmc: OMAP5/DRA7 enable autocmd23

enable autocmd23 for OMAP5 and DRA7 based on hsmmc revision

Signed-off-by: Balaji T K <balajitk@ti.com>
cpufreq: cpufreq-cpu0: do not allow transitions with regulators suspended

For platforms where regulators are used, regulator access tends to be
disabled as part of the suspend path. In SMP systems such as OMAP,
CPU1 is disabled as post suspend_noirq. This results in the following
tail end sequence of actions:
cpufreq_cpu_callback gets called with CPU_POST_DEAD
	__cpufreq_remove_dev_finish is invoked as a result
		__cpufreq_governor(policy, CPUFREQ_GOV_START) is
		triggered

At this point, with ondemand governor, if the cpu entered suspend path
at a lower OPP, this triggers a transition request. However, since
irqs are disabled, typically, regulator control using I2C operations
are not possible either, regulator operations will naturally fail
(even though clk_set_rate might succeed depending on the platform).

Unfortunately, cpufreq_driver->suspend|resume is too late as well, since
they are invoked as part of syscore_ops (after CPU1 is hotplugged out).

The proposal here is to use pm notifier suspend to disable any
requests to target, as we may very well expect this to fail at a later
suspend sequence.

Reported-by: J Keerthy <j-keerthy@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
ARM: OMAP2+: AM43XX: Add reserve function for AM43XX

AM33XX and AM43XX both share the same map_io function in
board_generic.c, but this function calls am33xx_dram_sync_init
which depends on a call to am33xx_reserve which is not set for
AM43XX. Add this to DT_MACHINE_INIT for AM43XX as it will
be needed later for suspend/resume but is needed now for boot.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
ARM: OMAP2+: AM33XX: Remove common omap_pm_ops from common pm init

Setting of omap_pm_ops removed in commit-id
436580d3d2f6fd9a6786c32757fa4b3e3bf14d4e but unintentionally added again in
commit-id 4fb93e13fa371e0d544dac45b3601d1e1f85ce49. Remove it again so
AM335x does not have suspend_ops set in the event that no firmware is
loaded for CM3. Further information about why this is necessary can be
found in commit-log of first commit mentioned.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Merge branch 'connectivity-ti-linux-3.12.y' of git://git.ti.com/connectivity-integration-tree/connectivity-ti-linux-kernel into ti-linux-3.12.y

TI-Feature: connectivity
TI-Tree: git://git.ti.com/connectivity-integration-tree/connectivity-ti-linux-kernel.git
TI-Branch: connectivity-ti-linux-3.12.y

* 'connectivity-ti-linux-3.12.y' of git://git.ti.com/connectivity-integration-tree/connectivity-ti-linux-kernel:
  mtd: tests: oobtest: fix test failures for oobsize which are not multiples of 4

Signed-off-by: Dan Murphy <DMurphy@ti.com>
Merge branch 'pm-ti-linux-3.12.y' of git://git.ti.com/~kristo/ti-linux-kernel/pm-linux-feature-tree into ti-linux-3.12.y

TI-Feature: power_management_base
TI-Tree: git://git.ti.com/~kristo/ti-linux-kernel/pm-linux-feature-tree.git
TI-Branch: pm-ti-linux-3.12.y

* 'pm-ti-linux-3.12.y' of git://git.ti.com/~kristo/ti-linux-kernel/pm-linux-feature-tree:
  ARM: OMAP2+: AM33XX: Remove common omap_pm_ops from common pm init
  ARM: OMAP2+: AM43XX: Add reserve function for AM43XX
  cpufreq: cpufreq-cpu0: do not allow transitions with regulators suspended

Signed-off-by: Dan Murphy <DMurphy@ti.com>
ARM: dts: omap5-uevm: Add rtc node for Palmas

TWL6037 Palmas PMIC used on OMAP5uEVM has RTC capability.
Further, the platform uses XH414HG as a backup battery for RTC function.
Hence add a node for the same to represent the hardware behavior.
Node follows the bindings described in
Documentation/devicetree/bindings/rtc/rtc-palmas.txt

Signed-off-by: Aparna Balasubramanian <aparnab@ti.com>
Signed-off-by: Keerthy <j-keerthy@ti.com>
Acked-by: Nishanth Menon <nm@ti.com>
ARM: omap2plus_defconfig: enable Palmas RTC

Enable Palmas RTC for support on OMAP5 uEVM platform.

Signed-off-by: Aparna Balasubramanian <aparnab@ti.com>
Signed-off-by: Keerthy <j-keerthy@ti.com>
Acked-by: Nishanth Menon <nm@ti.com>
ARM: dts: OMAP5-uevm: pull-up Palmas MSECURE line

Palmas MSECURE line must be pulled up, otherwise some of the PMIC
registers will be read-only. This fixes the problem with RTC
not updating properly.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Keerthy <j-keerthy@ti.com>
Merge branch 'sdmmc-autocmd23-ti-linux-3.12' of git://gitorious.ti.com/~balajitk/ti-linux-kernel/omap-hsmmc into connectivity-ti-linux-3.12.y
Merge branch 'connectivity-ti-linux-3.12.y' of git://git.ti.com/connectivity-integration-tree/connectivity-ti-linux-kernel into ti-linux-3.12.y

TI-Feature: connectivity
TI-Tree: git://git.ti.com/connectivity-integration-tree/connectivity-ti-linux-kernel.git
TI-Branch: connectivity-ti-linux-3.12.y

* 'connectivity-ti-linux-3.12.y' of git://git.ti.com/connectivity-integration-tree/connectivity-ti-linux-kernel:
  mmc: omap_hsmmc: OMAP5/DRA7 enable autocmd23
  mmc: omap_hsmmc: add autocmd23 support
  mmc: omap_hsmmc: add cmd23 support
  mmc: omap_hsmmc: add support for Auto-CMD12
  mmc: omap_hsmmc: save clock rate to use in interrupt context
  mmc: omap_hsmmc: correct max value of clkd
  mmc: omap_hsmmc: Fix pbias_disable for omap4

Signed-off-by: Dan Murphy <DMurphy@ti.com>
Merge branch 'platform-ti-linux-3.12.y' of git://git.ti.com/~rrnayak/ti-linux-kernel/platform-linux-feature-tree into ti-linux-3.12.y

TI-Feature: platform_base
TI-Tree: git://git.ti.com/~rrnayak/ti-linux-kernel/platform-linux-feature-tree.git
TI-Branch: platform-ti-linux-3.12.y

* 'platform-ti-linux-3.12.y' of git://git.ti.com/~rrnayak/ti-linux-kernel/platform-linux-feature-tree:
  ARM: dts: OMAP5-uevm: pull-up Palmas MSECURE line
  ARM: omap2plus_defconfig: enable Palmas RTC
  ARM: dts: omap5-uevm: Add rtc node for Palmas
  ARM: OMAP2+: omap_device: maintain sane runtime pm status around suspend/resume

Conflicts:
	arch/arm/boot/dts/omap5-uevm.dts

Signed-off-by: Dan Murphy <DMurphy@ti.com>