aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-09-10 16:33:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-10 16:33:09 -0400
commitd0048f0b91ee35ab940ec6cbdfdd238c55b12a14 (patch)
tree72914692414729a14ec1308c326d92359a3825a3 /drivers/mmc/core
parent7426d62871dafbeeed087d609c6469a515c88389 (diff)
parent9d731e7539713acc0ec7b67a5a91357c455d2334 (diff)
Merge tag 'mmc-updates-for-3.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc
Pull MMC updates from Chris Ball: "MMC highlights for 3.12: Core: - Support Allocation Units 8MB-64MB in SD3.0, previous max was 4MB. - The slot-gpio helper can now handle GPIO debouncing card-detect. - Read supported voltages from DT "voltage-ranges" property. Drivers: - dw_mmc: Add support for ARC architecture, and support exynos5420. - mmc_spi: Support CD/RO GPIOs. - sh_mobile_sdhi: Add compatibility for more Renesas SoCs. - sh_mmcif: Add DT support for DMA channels" * tag 'mmc-updates-for-3.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc: (50 commits) Revert "mmc: tmio-mmc: Remove .set_pwr() callback from platform data" mmc: dw_mmc: Add support for ARC mmc: sdhci-s3c: initialize host->quirks2 for using quirks2 mmc: sdhci-s3c: fix the wrong register value, when clock is disabled mmc: esdhc: add support to get voltage from device-tree mmc: sdhci: get voltage from sdhc host mmc: core: parse voltage from device-tree mmc: omap_hsmmc: use the generic config for omap2plus devices mmc: omap_hsmmc: clear status flags before starting a new command mmc: dw_mmc: exynos: Add a new compatible string for exynos5420 mmc: sh_mmcif: revision-specific CLK_CTRL2 handling mmc: sh_mmcif: revision-specific Command Completion Signal handling mmc: sh_mmcif: add support for Device Tree DMA bindings mmc: sh_mmcif: move header include from header into .c mmc: SDHI: add DT compatibility strings for further SoCs mmc: dw_mmc-pci: enable bus-mastering mode mmc: dw_mmc-pci: get resources from a proper BAR mmc: tmio-mmc: Remove .set_pwr() callback from platform data mmc: tmio-mmc: Remove .get_cd() callback from platform data mmc: sh_mobile_sdhi: Remove .set_pwr() callback from platform data ...
Diffstat (limited to 'drivers/mmc/core')
-rw-r--r--drivers/mmc/core/core.c44
-rw-r--r--drivers/mmc/core/host.c2
-rw-r--r--drivers/mmc/core/mmc_ops.c1
-rw-r--r--drivers/mmc/core/sd.c13
-rw-r--r--drivers/mmc/core/slot-gpio.c14
5 files changed, 67 insertions, 7 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 5d088551196b..bf18b6bfce48 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -27,6 +27,7 @@
27#include <linux/fault-inject.h> 27#include <linux/fault-inject.h>
28#include <linux/random.h> 28#include <linux/random.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/of.h>
30 31
31#include <linux/mmc/card.h> 32#include <linux/mmc/card.h>
32#include <linux/mmc/host.h> 33#include <linux/mmc/host.h>
@@ -1196,6 +1197,49 @@ u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max)
1196} 1197}
1197EXPORT_SYMBOL(mmc_vddrange_to_ocrmask); 1198EXPORT_SYMBOL(mmc_vddrange_to_ocrmask);
1198 1199
1200#ifdef CONFIG_OF
1201
1202/**
1203 * mmc_of_parse_voltage - return mask of supported voltages
1204 * @np: The device node need to be parsed.
1205 * @mask: mask of voltages available for MMC/SD/SDIO
1206 *
1207 * 1. Return zero on success.
1208 * 2. Return negative errno: voltage-range is invalid.
1209 */
1210int mmc_of_parse_voltage(struct device_node *np, u32 *mask)
1211{
1212 const u32 *voltage_ranges;
1213 int num_ranges, i;
1214
1215 voltage_ranges = of_get_property(np, "voltage-ranges", &num_ranges);
1216 num_ranges = num_ranges / sizeof(*voltage_ranges) / 2;
1217 if (!voltage_ranges || !num_ranges) {
1218 pr_info("%s: voltage-ranges unspecified\n", np->full_name);
1219 return -EINVAL;
1220 }
1221
1222 for (i = 0; i < num_ranges; i++) {
1223 const int j = i * 2;
1224 u32 ocr_mask;
1225
1226 ocr_mask = mmc_vddrange_to_ocrmask(
1227 be32_to_cpu(voltage_ranges[j]),
1228 be32_to_cpu(voltage_ranges[j + 1]));
1229 if (!ocr_mask) {
1230 pr_err("%s: voltage-range #%d is invalid\n",
1231 np->full_name, i);
1232 return -EINVAL;
1233 }
1234 *mask |= ocr_mask;
1235 }
1236
1237 return 0;
1238}
1239EXPORT_SYMBOL(mmc_of_parse_voltage);
1240
1241#endif /* CONFIG_OF */
1242
1199#ifdef CONFIG_REGULATOR 1243#ifdef CONFIG_REGULATOR
1200 1244
1201/** 1245/**
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 6fb6f77450cb..49bc403e31f0 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -374,7 +374,7 @@ int mmc_of_parse(struct mmc_host *host)
374 if (!(flags & OF_GPIO_ACTIVE_LOW)) 374 if (!(flags & OF_GPIO_ACTIVE_LOW))
375 gpio_inv_cd = true; 375 gpio_inv_cd = true;
376 376
377 ret = mmc_gpio_request_cd(host, gpio); 377 ret = mmc_gpio_request_cd(host, gpio, 0);
378 if (ret < 0) { 378 if (ret < 0) {
379 dev_err(host->parent, 379 dev_err(host->parent,
380 "Failed to request CD GPIO #%d: %d!\n", 380 "Failed to request CD GPIO #%d: %d!\n",
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 837fc7386e23..ef183483d5b6 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -531,6 +531,7 @@ mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode,
531 531
532 data.sg = &sg; 532 data.sg = &sg;
533 data.sg_len = 1; 533 data.sg_len = 1;
534 mmc_set_data_timeout(&data, card);
534 sg_init_one(&sg, data_buf, len); 535 sg_init_one(&sg, data_buf, len);
535 mmc_wait_for_req(host, &mrq); 536 mmc_wait_for_req(host, &mrq);
536 err = 0; 537 err = 0;
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 176d125f5b57..5e8823dc3ef6 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -215,7 +215,7 @@ static int mmc_decode_scr(struct mmc_card *card)
215static int mmc_read_ssr(struct mmc_card *card) 215static int mmc_read_ssr(struct mmc_card *card)
216{ 216{
217 unsigned int au, es, et, eo; 217 unsigned int au, es, et, eo;
218 int err, i; 218 int err, i, max_au;
219 u32 *ssr; 219 u32 *ssr;
220 220
221 if (!(card->csd.cmdclass & CCC_APP_SPEC)) { 221 if (!(card->csd.cmdclass & CCC_APP_SPEC)) {
@@ -239,12 +239,15 @@ static int mmc_read_ssr(struct mmc_card *card)
239 for (i = 0; i < 16; i++) 239 for (i = 0; i < 16; i++)
240 ssr[i] = be32_to_cpu(ssr[i]); 240 ssr[i] = be32_to_cpu(ssr[i]);
241 241
242 /* SD3.0 increases max AU size to 64MB (0xF) from 4MB (0x9) */
243 max_au = card->scr.sda_spec3 ? 0xF : 0x9;
244
242 /* 245 /*
243 * UNSTUFF_BITS only works with four u32s so we have to offset the 246 * UNSTUFF_BITS only works with four u32s so we have to offset the
244 * bitfield positions accordingly. 247 * bitfield positions accordingly.
245 */ 248 */
246 au = UNSTUFF_BITS(ssr, 428 - 384, 4); 249 au = UNSTUFF_BITS(ssr, 428 - 384, 4);
247 if (au > 0 && au <= 9) { 250 if (au > 0 && au <= max_au) {
248 card->ssr.au = 1 << (au + 4); 251 card->ssr.au = 1 << (au + 4);
249 es = UNSTUFF_BITS(ssr, 408 - 384, 16); 252 es = UNSTUFF_BITS(ssr, 408 - 384, 16);
250 et = UNSTUFF_BITS(ssr, 402 - 384, 6); 253 et = UNSTUFF_BITS(ssr, 402 - 384, 6);
@@ -942,13 +945,13 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
942 if (!mmc_host_is_spi(host)) { 945 if (!mmc_host_is_spi(host)) {
943 err = mmc_send_relative_addr(host, &card->rca); 946 err = mmc_send_relative_addr(host, &card->rca);
944 if (err) 947 if (err)
945 return err; 948 goto free_card;
946 } 949 }
947 950
948 if (!oldcard) { 951 if (!oldcard) {
949 err = mmc_sd_get_csd(host, card); 952 err = mmc_sd_get_csd(host, card);
950 if (err) 953 if (err)
951 return err; 954 goto free_card;
952 955
953 mmc_decode_cid(card); 956 mmc_decode_cid(card);
954 } 957 }
@@ -959,7 +962,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
959 if (!mmc_host_is_spi(host)) { 962 if (!mmc_host_is_spi(host)) {
960 err = mmc_select_card(card); 963 err = mmc_select_card(card);
961 if (err) 964 if (err)
962 return err; 965 goto free_card;
963 } 966 }
964 967
965 err = mmc_sd_setup_card(host, card, oldcard != NULL); 968 err = mmc_sd_setup_card(host, card, oldcard != NULL);
diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
index 324235105519..46596b71a32f 100644
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -135,6 +135,7 @@ EXPORT_SYMBOL(mmc_gpio_request_ro);
135 * mmc_gpio_request_cd - request a gpio for card-detection 135 * mmc_gpio_request_cd - request a gpio for card-detection
136 * @host: mmc host 136 * @host: mmc host
137 * @gpio: gpio number requested 137 * @gpio: gpio number requested
138 * @debounce: debounce time in microseconds
138 * 139 *
139 * As devm_* managed functions are used in mmc_gpio_request_cd(), client 140 * As devm_* managed functions are used in mmc_gpio_request_cd(), client
140 * drivers do not need to explicitly call mmc_gpio_free_cd() for freeing up, 141 * drivers do not need to explicitly call mmc_gpio_free_cd() for freeing up,
@@ -143,9 +144,14 @@ EXPORT_SYMBOL(mmc_gpio_request_ro);
143 * switching for card-detection, they are responsible for calling 144 * switching for card-detection, they are responsible for calling
144 * mmc_gpio_request_cd() and mmc_gpio_free_cd() as a pair on their own. 145 * mmc_gpio_request_cd() and mmc_gpio_free_cd() as a pair on their own.
145 * 146 *
147 * If GPIO debouncing is desired, set the debounce parameter to a non-zero
148 * value. The caller is responsible for ensuring that the GPIO driver associated
149 * with the GPIO supports debouncing, otherwise an error will be returned.
150 *
146 * Returns zero on success, else an error. 151 * Returns zero on success, else an error.
147 */ 152 */
148int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio) 153int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio,
154 unsigned int debounce)
149{ 155{
150 struct mmc_gpio *ctx; 156 struct mmc_gpio *ctx;
151 int irq = gpio_to_irq(gpio); 157 int irq = gpio_to_irq(gpio);
@@ -167,6 +173,12 @@ int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio)
167 */ 173 */
168 return ret; 174 return ret;
169 175
176 if (debounce) {
177 ret = gpio_set_debounce(gpio, debounce);
178 if (ret < 0)
179 return ret;
180 }
181
170 /* 182 /*
171 * Even if gpio_to_irq() returns a valid IRQ number, the platform might 183 * Even if gpio_to_irq() returns a valid IRQ number, the platform might
172 * still prefer to poll, e.g., because that IRQ number is already used 184 * still prefer to poll, e.g., because that IRQ number is already used