ARM: amba: add amba_device allocation/add/put functions

Add functions to allocate and initialize AMBA device structures, and
add them to the Linux device manager.  This allows us to kill this
type of operation from individual platforms, moving it to core code.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
ARM: 7369/1: amba: add functions to add devices dynamically

Add two functions to add APB and AHB devices to the amba (PrimeCell)
bus dynamically. This is modeled after the static definition
macros recently introduced into <linux/amba/bus.h> and can
help us in factoring out a bunch of code across the kernel.
Since a lot of call sites seem to be using a returned struct
amba device* pointer, let's use that.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
ARM: 6243/1: mmci: pass power_mode to the translate_vdd callback

Platforms may have some external power control which need to be
controlled from board specific code.  Rename the translate_vdd()
callback to vdd_handler() and pass it the power mode.

Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
omap_hsmmc: Move gpio and regulator control from board file

This patch moves the setup code for GPIO's and Voltage
Regulators from the board file mmc-twl4030.c to the
driver omap_hsmmc.c.  PBIAS and other system control
configuration remains in the board file.

Moving GPIO code to the driver makes the board initialisation
code independent of when GPIO's are defined.  That makes the
board initialisation now entirely independent of its original
twl4030 roots.

Moving Voltage Regulator code to the driver allows for further
development of regulator support in the core MMC code.  It also
permits the MMC core to be compiled as a module, because the
board code no longer calls MMC core functions.

Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
omap_hsmmc: Ensure regulator enable / disable are paired

Stop using 'regulator_is_enabled()' and just pair enables
with disables so that the regulator reference counts can
work correctly.

Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
mmc: Move regulator handling closer to core

After discovering a problem in regulator reference counting I took Mark
Brown's advice to move the reference count into the MMC core by making the
regulator status a member of struct mmc_host.

I took this opportunity to also implement NULL versions of
the regulator functions so as to rid the driver code from
some ugly #ifdef CONFIG_REGULATOR clauses.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Adrian Hunter <adrian.hunter@nokia.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Sundar Iyer <sundar.iyer@stericsson.com>
Cc: Daniel Mack <daniel@caiaq.de>
Cc: Pierre Ossman <pierre@ossman.eu>
Cc: Matt Fleming <matt@console-pimps.org>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Cliff Brake <cbrake@bec-systems.com>
Cc: Jarkko Lavinen <jarkko.lavinen@nokia.com>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
ARM: 6438/2: mmci: add SDIO support for ST Variants

This adds some minor variant data and trickery to enable SDIO
on the ST Micro variants of MMCI/PL180.

Signed-off-by: Marcin Mielczarczyk <marcin.mielczarczyk@tieto.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

Conflicts:

	drivers/mmc/host/mmci.c (trivial)
ARM: 6526/1: mmci: corrected calculation of clock div for ux500

The Ux500 variant of this block has a different divider.
The value used right now is too big and which means a loss
in performance. This fix corrects it. Also expand the math
comments a bit so it's clear what's happening. Further
the Ux500 variant does not like if we use the BYPASS bit,
instead we are supposed to set the clock divider to zero.

Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

Conflicts:

	drivers/mmc/host/mmci.c (trivial)
ARM: 6785/1: mmci: separate out ST Micro register defines

The mmci.h header contained a few registers not clearly marked
as ST Micro only, rectify this and remove the HWFC magic in the
process. The idea is to make the mmci.h header file more ordered
so other vendors with PL180 derivates can see where to put in
their custom register defines.

Includes portions of an earlier patch from Sebastian Rasmussen.

Acked-by: Sebastian Rasmussen <sebastian.rasmussen@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
ARM: 7217/1: mmc: mmci: Put power register deviations in variant data

Use variant data to store hardware controller deviations concerning
power registers to improve readability of the code.

Signed-off-by: Sebastian Rasmussen <sebastian.rasmussen@stericsson.com>
Tested-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

Conflicts:

	drivers/mmc/host/mmci.c (trivial)
ARM: 7219/1: mmc: mmci: Change vdd_handler to a generic ios_handler

The purpose of the vdd_handler does not make sense. We remove it
and use a generic approach instead. A new ios_handler is added, the
purpose of which e.g. can be to control GPIO pins to a levelshifter.

Previously the vdd_handler was also used for making additional
changes to the power register bits. This option is superfluous and is
therefore removed.

Adaptaptions from the old vdd_handler to the new ios_handler is done for
mach-ux500 board, which was the only one using the vdd_handler.

This patch is based upon a patch from Sebastian Rasmussen.

Tested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Rasmussen <sebastian.rasmussen@stericsson.com>
Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

Conflicts:

	arch/arm/mach-ux500/board-mop500-sdi.c (removed)
ARM: 6437/2: mmci: add some register defines for ST Micro variants

This adds a few registers to the MMCI/PL180 derivates that
is used for some odd control stuff like SDIO.

Signed-off-by: Marcin Mielczarczyk <marcin.mielczarczyk@tieto.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
RT79682. ARM: amba: Fix build after applying d5dc927 and 6026aa9
RT79682. stm32 clock: Implement clock driver; register SDIO clock

 * Implement clock driver for STM32 using the clock driver for Kinetis
arch/arm/mach-kinetis/clock.c) as a reference.
 * Register the SDIO controller clock "mmci0", calculate its frequency
at run-time. We will use this registered clock with the MMCI driver
(drivers/mmc/host/mmci.c).
RT79682. stm32 iomux: Add SDIO pin configuration for STM3220G-EVAL

 * Add support for the SDIO IOMUX "role" in stm32f2_gpio_config().
 * Add SDIO pin configuration for the STM3220G-EVAL board (CLK, CMD,
D0, D1, D2, D3).
 * This pin configuration also supports STM3240G-EVAL, since these two
boards are pin-compatible.
 * Do not configure the "card detect" pin, because we will not support
reading of its status for now.
RT79682. stm32 sdcard: Add SD card support, no DMA

 * Force enable CONFIG_ARM_AMBA to make the MMCI driver available for
selection (drivers/mmc/host/mmci.c).
 * Register the SD card controller by calling amba_ahb_device_add().
We cannot use amba_device_register() like we did on LPC178x/7x, because
the SD controller on STM32 does not have AMBA device IDs in its register
map.
 * Register the SD card controller only when CONFIG_MMC_ARMMMCI enabled.
 * Register the SD card controller on known boards only (STM3220G-EVAL
and STM3240G-EVAL).
 * The SD card controller on STM32 has one incompatibility with the MMCI
driver: there is no "OD" bit in the SDIO_POWER register. We workaround
this by implementing an ".ios_handler" callback to hide the "open-drain"
bus mode from the MMCI driver, so that the SDIO_POWER[OD] is never set.
This is important, because the SD card controller stops working after
writing "1" into SDIO_POWER[OD].
 * Make the MMCI driver use the "ux500" controller variant
(variant_ux500) by setting the AMBA device ID to U8500_SDI_V2_PERIPHID.
 * Do not support "write-protect" and "card detect" pins.
 * Declare support for voltages around 3.3V (3.2V to 3.4V), since V_{DD}
on the STM3220G-EVAL board is 3.3V.
 * Limit SD card clock frequency to 400kHz to make the SD card work
reliably without DMA.
RT79682. stm32 iomux: Remove unused array usart_gpio_role[]
RT79682. kinetis dma: Fix error code return value

Error code must be negative.
RT79682. serial: stm32_usart: Remove unused local variable

Fix compiler warning.
RT79682. stm32 dma: Move definition of DMA controller register map to mach/dmaregs.h

 * We do this to reuse these definitions in the upcoming DMA controller
driver for STM32F2.
 * Move the following:
   * DMA controller register map bases;
   * Masks for the DMA{1,2}_EN bits in the RCC_AHB1ENR register;
   * Definitions of bit fields in the DMA controller registers;
   * DMA controller register map structure (struct stm32_dma_regs).