aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Daudt <csd@broadcom.com>2013-06-20 17:26:37 -0400
committerChris Ball <cjb@laptop.org>2013-07-05 13:00:31 -0400
commit01ebea1b411aafc8eab440bf1d2037f01bbed99b (patch)
tree6982e64be2fb96087c93c10afadfed73e7cbd347
parent722e1280c932dd42c474390482429ce12aff9031 (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_defconfig7
-rw-r--r--drivers/mmc/host/Kconfig11
-rw-r--r--drivers/mmc/host/Makefile1
-rw-r--r--drivers/mmc/host/sdhci-bcm-kona.c348
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
78CONFIG_LCD_CLASS_DEVICE=y 78CONFIG_LCD_CLASS_DEVICE=y
79CONFIG_BACKLIGHT_CLASS_DEVICE=y 79CONFIG_BACKLIGHT_CLASS_DEVICE=y
80# CONFIG_USB_SUPPORT is not set 80# CONFIG_USB_SUPPORT is not set
81CONFIG_MMC=y
82CONFIG_MMC_UNSAFE_RESUME=y
83CONFIG_MMC_BLOCK_MINORS=32
84CONFIG_MMC_TEST=y
85CONFIG_MMC_SDHCI=y
86CONFIG_MMC_SDHCI_PLTFM=y
87CONFIG_MMC_SDHCI_BCM_KONA=y
81CONFIG_NEW_LEDS=y 88CONFIG_NEW_LEDS=y
82CONFIG_LEDS_CLASS=y 89CONFIG_LEDS_CLASS=y
83CONFIG_LEDS_TRIGGERS=y 90CONFIG_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
252config 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
252config MMC_SDHCI_BCM2835 263config 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
61obj-$(CONFIG_MMC_SDHCI_TEGRA) += sdhci-tegra.o 61obj-$(CONFIG_MMC_SDHCI_TEGRA) += sdhci-tegra.o
62obj-$(CONFIG_MMC_SDHCI_OF_ESDHC) += sdhci-of-esdhc.o 62obj-$(CONFIG_MMC_SDHCI_OF_ESDHC) += sdhci-of-esdhc.o
63obj-$(CONFIG_MMC_SDHCI_OF_HLWD) += sdhci-of-hlwd.o 63obj-$(CONFIG_MMC_SDHCI_OF_HLWD) += sdhci-of-hlwd.o
64obj-$(CONFIG_MMC_SDHCI_BCM_KONA) += sdhci-bcm-kona.o
64obj-$(CONFIG_MMC_SDHCI_BCM2835) += sdhci-bcm2835.o 65obj-$(CONFIG_MMC_SDHCI_BCM2835) += sdhci-bcm2835.o
65 66
66ifeq ($(CONFIG_CB710_DEBUG),y) 67ifeq ($(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
56struct sdhci_bcm_kona_dev {
57 struct mutex write_lock; /* protect back to back writes */
58};
59
60
61static 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
97static 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 */
126static 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