diff options
| author | Christian Daudt <csd@broadcom.com> | 2013-06-20 17:26:37 -0400 |
|---|---|---|
| committer | Chris Ball <cjb@laptop.org> | 2013-07-05 13:00:31 -0400 |
| commit | 01ebea1b411aafc8eab440bf1d2037f01bbed99b (patch) | |
| tree | 6982e64be2fb96087c93c10afadfed73e7cbd347 | |
| parent | 722e1280c932dd42c474390482429ce12aff9031 (diff) | |
mmc: bcm281xx SDHCI driver
Add SDHCI driver for the Broadcom 281xx SoCs.
Still missing:
- power managemement
Signed-off-by: Christian Daudt <csd@broadcom.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Chris Ball <cjb@laptop.org>
| -rw-r--r-- | arch/arm/configs/bcm_defconfig | 7 | ||||
| -rw-r--r-- | drivers/mmc/host/Kconfig | 11 | ||||
| -rw-r--r-- | drivers/mmc/host/Makefile | 1 | ||||
| -rw-r--r-- | drivers/mmc/host/sdhci-bcm-kona.c | 348 |
4 files changed, 367 insertions, 0 deletions
diff --git a/arch/arm/configs/bcm_defconfig b/arch/arm/configs/bcm_defconfig index e3bf2d65618e..65edf6d47215 100644 --- a/arch/arm/configs/bcm_defconfig +++ b/arch/arm/configs/bcm_defconfig | |||
| @@ -78,6 +78,13 @@ CONFIG_BACKLIGHT_LCD_SUPPORT=y | |||
| 78 | CONFIG_LCD_CLASS_DEVICE=y | 78 | CONFIG_LCD_CLASS_DEVICE=y |
| 79 | CONFIG_BACKLIGHT_CLASS_DEVICE=y | 79 | CONFIG_BACKLIGHT_CLASS_DEVICE=y |
| 80 | # CONFIG_USB_SUPPORT is not set | 80 | # CONFIG_USB_SUPPORT is not set |
| 81 | CONFIG_MMC=y | ||
| 82 | CONFIG_MMC_UNSAFE_RESUME=y | ||
| 83 | CONFIG_MMC_BLOCK_MINORS=32 | ||
| 84 | CONFIG_MMC_TEST=y | ||
| 85 | CONFIG_MMC_SDHCI=y | ||
| 86 | CONFIG_MMC_SDHCI_PLTFM=y | ||
| 87 | CONFIG_MMC_SDHCI_BCM_KONA=y | ||
| 81 | CONFIG_NEW_LEDS=y | 88 | CONFIG_NEW_LEDS=y |
| 82 | CONFIG_LEDS_CLASS=y | 89 | CONFIG_LEDS_CLASS=y |
| 83 | CONFIG_LEDS_TRIGGERS=y | 90 | CONFIG_LEDS_TRIGGERS=y |
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 1be228998c81..8a4c066787d7 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig | |||
| @@ -249,6 +249,17 @@ config MMC_SDHCI_S3C_DMA | |||
| 249 | 249 | ||
| 250 | YMMV. | 250 | YMMV. |
| 251 | 251 | ||
| 252 | config MMC_SDHCI_BCM_KONA | ||
| 253 | tristate "SDHCI support on Broadcom KONA platform" | ||
| 254 | depends on ARCH_BCM | ||
| 255 | select MMC_SDHCI_PLTFM | ||
| 256 | help | ||
| 257 | This selects the Broadcom Kona Secure Digital Host Controller | ||
| 258 | Interface(SDHCI) support. | ||
| 259 | This is used in Broadcom mobile SoCs. | ||
| 260 | |||
| 261 | If you have a controller with this interface, say Y or M here. | ||
| 262 | |||
| 252 | config MMC_SDHCI_BCM2835 | 263 | config MMC_SDHCI_BCM2835 |
| 253 | tristate "SDHCI platform support for the BCM2835 SD/MMC Controller" | 264 | tristate "SDHCI platform support for the BCM2835 SD/MMC Controller" |
| 254 | depends on ARCH_BCM2835 | 265 | depends on ARCH_BCM2835 |
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile index 67718c1b79ce..d422e2167e19 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile | |||
| @@ -61,6 +61,7 @@ obj-$(CONFIG_MMC_SDHCI_DOVE) += sdhci-dove.o | |||
| 61 | obj-$(CONFIG_MMC_SDHCI_TEGRA) += sdhci-tegra.o | 61 | obj-$(CONFIG_MMC_SDHCI_TEGRA) += sdhci-tegra.o |
| 62 | obj-$(CONFIG_MMC_SDHCI_OF_ESDHC) += sdhci-of-esdhc.o | 62 | obj-$(CONFIG_MMC_SDHCI_OF_ESDHC) += sdhci-of-esdhc.o |
| 63 | obj-$(CONFIG_MMC_SDHCI_OF_HLWD) += sdhci-of-hlwd.o | 63 | obj-$(CONFIG_MMC_SDHCI_OF_HLWD) += sdhci-of-hlwd.o |
| 64 | obj-$(CONFIG_MMC_SDHCI_BCM_KONA) += sdhci-bcm-kona.o | ||
| 64 | obj-$(CONFIG_MMC_SDHCI_BCM2835) += sdhci-bcm2835.o | 65 | obj-$(CONFIG_MMC_SDHCI_BCM2835) += sdhci-bcm2835.o |
| 65 | 66 | ||
| 66 | ifeq ($(CONFIG_CB710_DEBUG),y) | 67 | ifeq ($(CONFIG_CB710_DEBUG),y) |
diff --git a/drivers/mmc/host/sdhci-bcm-kona.c b/drivers/mmc/host/sdhci-bcm-kona.c new file mode 100644 index 000000000000..87175f9817c2 --- /dev/null +++ b/drivers/mmc/host/sdhci-bcm-kona.c | |||
| @@ -0,0 +1,348 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2013 Broadcom Corporation | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU General Public License as | ||
| 6 | * published by the Free Software Foundation version 2. | ||
| 7 | * | ||
| 8 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
| 9 | * kind, whether express or implied; without even the implied warranty | ||
| 10 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <linux/kernel.h> | ||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/delay.h> | ||
| 17 | #include <linux/highmem.h> | ||
| 18 | #include <linux/platform_device.h> | ||
| 19 | #include <linux/mmc/host.h> | ||
| 20 | #include <linux/io.h> | ||
| 21 | #include <linux/gpio.h> | ||
| 22 | #include <linux/clk.h> | ||
| 23 | #include <linux/regulator/consumer.h> | ||
| 24 | #include <linux/of.h> | ||
| 25 | #include <linux/of_device.h> | ||
| 26 | #include <linux/of_gpio.h> | ||
| 27 | #include <linux/version.h> | ||
| 28 | #include <linux/mmc/slot-gpio.h> | ||
| 29 | |||
| 30 | #include "sdhci-pltfm.h" | ||
| 31 | #include "sdhci.h" | ||
| 32 | |||
| 33 | #define SDHCI_SOFT_RESET 0x01000000 | ||
| 34 | #define KONA_SDHOST_CORECTRL 0x8000 | ||
| 35 | #define KONA_SDHOST_CD_PINCTRL 0x00000008 | ||
| 36 | #define KONA_SDHOST_STOP_HCLK 0x00000004 | ||
| 37 | #define KONA_SDHOST_RESET 0x00000002 | ||
| 38 | #define KONA_SDHOST_EN 0x00000001 | ||
| 39 | |||
| 40 | #define KONA_SDHOST_CORESTAT 0x8004 | ||
| 41 | #define KONA_SDHOST_WP 0x00000002 | ||
| 42 | #define KONA_SDHOST_CD_SW 0x00000001 | ||
| 43 | |||
| 44 | #define KONA_SDHOST_COREIMR 0x8008 | ||
| 45 | #define KONA_SDHOST_IP 0x00000001 | ||
| 46 | |||
| 47 | #define KONA_SDHOST_COREISR 0x800C | ||
| 48 | #define KONA_SDHOST_COREIMSR 0x8010 | ||
| 49 | #define KONA_SDHOST_COREDBG1 0x8014 | ||
| 50 | #define KONA_SDHOST_COREGPO_MASK 0x8018 | ||
| 51 | |||
| 52 | #define SD_DETECT_GPIO_DEBOUNCE_128MS 128 | ||
| 53 | |||
| 54 | #define KONA_MMC_AUTOSUSPEND_DELAY (50) | ||
| 55 | |||
| 56 | struct sdhci_bcm_kona_dev { | ||
| 57 | struct mutex write_lock; /* protect back to back writes */ | ||
| 58 | }; | ||
| 59 | |||
| 60 | |||
| 61 | static int sdhci_bcm_kona_sd_reset(struct sdhci_host *host) | ||
| 62 | { | ||
| 63 | unsigned int val; | ||
| 64 | unsigned long timeout; | ||
| 65 | |||
| 66 | /* This timeout should be sufficent for core to reset */ | ||
| 67 | timeout = jiffies + msecs_to_jiffies(100); | ||
| 68 | |||
| 69 | /* reset the host using the top level reset */ | ||
| 70 | val = sdhci_readl(host, KONA_SDHOST_CORECTRL); | ||
| 71 | val |= KONA_SDHOST_RESET; | ||
| 72 | sdhci_writel(host, val, KONA_SDHOST_CORECTRL); | ||
| 73 | |||
| 74 | while (!(sdhci_readl(host, KONA_SDHOST_CORECTRL) & KONA_SDHOST_RESET)) { | ||
| 75 | if (time_is_before_jiffies(timeout)) { | ||
| 76 | pr_err("Error: sd host is stuck in reset!!!\n"); | ||
| 77 | return -EFAULT; | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | /* bring the host out of reset */ | ||
| 82 | val = sdhci_readl(host, KONA_SDHOST_CORECTRL); | ||
| 83 | val &= ~KONA_SDHOST_RESET; | ||
| 84 | |||
| 85 | /* | ||
| 86 | * Back-to-Back register write needs a delay of 1ms at bootup (min 10uS) | ||
| 87 | * Back-to-Back writes to same register needs delay when SD bus clock | ||
| 88 | * is very low w.r.t AHB clock, mainly during boot-time and during card | ||
| 89 | * insert-removal. | ||
| 90 | */ | ||
| 91 | usleep_range(1000, 5000); | ||
| 92 | sdhci_writel(host, val, KONA_SDHOST_CORECTRL); | ||
| 93 | |||
| 94 | return 0; | ||
| 95 | } | ||
| 96 | |||
| 97 | static void sdhci_bcm_kona_sd_init(struct sdhci_host *host) | ||
| 98 | { | ||
| 99 | unsigned int val; | ||
| 100 | |||
| 101 | /* enable the interrupt from the IP core */ | ||
| 102 | val = sdhci_readl(host, KONA_SDHOST_COREIMR); | ||
| 103 | val |= KONA_SDHOST_IP; | ||
| 104 | sdhci_writel(host, val, KONA_SDHOST_COREIMR); | ||
| 105 | |||
| 106 | /* Enable the AHB clock gating module to the host */ | ||
| 107 | val = sdhci_readl(host, KONA_SDHOST_CORECTRL); | ||
| 108 | val |= KONA_SDHOST_EN; | ||
| 109 | |||
| 110 | /* | ||
| 111 | * Back-to-Back register write needs a delay of 1ms at bootup (min 10uS) | ||
| 112 | * Back-to-Back writes to same register needs delay when SD bus clock | ||
| 113 | * is very low w.r.t AHB clock, mainly during boot-time and during card | ||
| 114 | * insert-removal. | ||
| 115 | */ | ||
| 116 | usleep_range(1000, 5000); | ||
| 117 | sdhci_writel(host, val, KONA_SDHOST_CORECTRL); | ||
| 118 | } | ||
| 119 | |||
| 120 | /* | ||
| 121 | * Software emulation of the SD card insertion/removal. Set insert=1 for insert | ||
| 122 | * and insert=0 for removal. The card detection is done by GPIO. For Broadcom | ||
| 123 | * IP to function properly the bit 0 of CORESTAT register needs to be set/reset | ||
| 124 | * to generate the CD IRQ handled in sdhci.c which schedules card_tasklet. | ||
| 125 | */ | ||
| 126 | static int sdhci_bcm_kona_sd_card_emulate(struct sdhci_host *host, int insert) | ||
| 127 | { | ||
| 128 | struct sdhci_pltfm_host *pltfm_priv = sdhci_priv(host); | ||
| 129 | struct sdhci_bcm_kona_dev *kona_dev = sdhci_pltfm_priv(pltfm_priv); | ||
| 130 | u32 val; | ||
| 131 | |||
| 132 | /* | ||
| 133 | * Back-to-Back register write needs a delay of min 10uS. | ||
| 134 | * Back-to-Back writes to same register needs delay when SD bus clock | ||
