Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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
...

+336 -335
+4
Documentation/devicetree/bindings/mmc/fsl-esdhc.txt
··· 19 19 "bus-width = <1>" property. 20 20 - sdhci,auto-cmd12: specifies that a controller can only handle auto 21 21 CMD12. 22 + - voltage-ranges : two cells are required, first cell specifies minimum 23 + slot voltage (mV), second cell specifies maximum slot voltage (mV). 24 + Several ranges could be specified. 22 25 23 26 Example: 24 27 ··· 32 29 interrupt-parent = <&ipic>; 33 30 /* Filled in by U-Boot */ 34 31 clock-frequency = <0>; 32 + voltage-ranges = <3300 3300>; 35 33 };
+5 -52
arch/arm/mach-ep93xx/vision_ep9307.c
··· 224 224 #define VISION_SPI_MMC_WP EP93XX_GPIO_LINE_F(0) 225 225 #define VISION_SPI_MMC_CD EP93XX_GPIO_LINE_EGPIO15 226 226 227 - static struct gpio vision_spi_mmc_gpios[] = { 228 - { VISION_SPI_MMC_WP, GPIOF_DIR_IN, "mmc_spi:wp" }, 229 - { VISION_SPI_MMC_CD, GPIOF_DIR_IN, "mmc_spi:cd" }, 230 - }; 231 - 232 - static int vision_spi_mmc_init(struct device *pdev, 233 - irqreturn_t (*func)(int, void *), void *pdata) 234 - { 235 - int err; 236 - 237 - err = gpio_request_array(vision_spi_mmc_gpios, 238 - ARRAY_SIZE(vision_spi_mmc_gpios)); 239 - if (err) 240 - return err; 241 - 242 - err = gpio_set_debounce(VISION_SPI_MMC_CD, 1); 243 - if (err) 244 - goto exit_err; 245 - 246 - err = request_irq(gpio_to_irq(VISION_SPI_MMC_CD), func, 247 - IRQ_TYPE_EDGE_BOTH, "mmc_spi:cd", pdata); 248 - if (err) 249 - goto exit_err; 250 - 251 - return 0; 252 - 253 - exit_err: 254 - gpio_free_array(vision_spi_mmc_gpios, ARRAY_SIZE(vision_spi_mmc_gpios)); 255 - return err; 256 - 257 - } 258 - 259 - static void vision_spi_mmc_exit(struct device *pdev, void *pdata) 260 - { 261 - free_irq(gpio_to_irq(VISION_SPI_MMC_CD), pdata); 262 - gpio_free_array(vision_spi_mmc_gpios, ARRAY_SIZE(vision_spi_mmc_gpios)); 263 - } 264 - 265 - static int vision_spi_mmc_get_ro(struct device *pdev) 266 - { 267 - return !!gpio_get_value(VISION_SPI_MMC_WP); 268 - } 269 - 270 - static int vision_spi_mmc_get_cd(struct device *pdev) 271 - { 272 - return !gpio_get_value(VISION_SPI_MMC_CD); 273 - } 274 - 275 227 static struct mmc_spi_platform_data vision_spi_mmc_data = { 276 - .init = vision_spi_mmc_init, 277 - .exit = vision_spi_mmc_exit, 278 - .get_ro = vision_spi_mmc_get_ro, 279 - .get_cd = vision_spi_mmc_get_cd, 280 228 .detect_delay = 100, 281 229 .powerup_msecs = 100, 282 230 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 231 + .flags = MMC_SPI_USE_CD_GPIO | MMC_SPI_USE_RO_GPIO, 232 + .cd_gpio = VISION_SPI_MMC_CD, 233 + .cd_debounce = 1, 234 + .ro_gpio = VISION_SPI_MMC_WP, 235 + .caps2 = MMC_CAP2_RO_ACTIVE_HIGH, 283 236 }; 284 237 285 238 static int vision_spi_mmc_hw_setup(struct spi_device *spi)
+8 -81
arch/sh/boards/mach-ecovec24/setup.c
··· 600 600 }, 601 601 }; 602 602 603 - static void sdhi0_set_pwr(struct platform_device *pdev, int state) 604 - { 605 - static int power_gpio = -EINVAL; 606 - 607 - if (power_gpio < 0) { 608 - int ret = gpio_request(GPIO_PTB6, NULL); 609 - if (!ret) { 610 - power_gpio = GPIO_PTB6; 611 - gpio_direction_output(power_gpio, 0); 612 - } 613 - } 614 - 615 - /* 616 - * Toggle the GPIO regardless, whether we managed to grab it above or 617 - * the fixed regulator driver did. 618 - */ 619 - gpio_set_value(GPIO_PTB6, state); 620 - } 621 - 622 - static int sdhi0_get_cd(struct platform_device *pdev) 623 - { 624 - return !gpio_get_value(GPIO_PTY7); 625 - } 626 - 627 603 static struct sh_mobile_sdhi_info sdhi0_info = { 628 604 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, 629 605 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, 630 - .set_pwr = sdhi0_set_pwr, 631 606 .tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD | 632 607 MMC_CAP_NEEDS_POLL, 633 - .get_cd = sdhi0_get_cd, 608 + .tmio_flags = TMIO_MMC_USE_GPIO_CD, 609 + .cd_gpio = GPIO_PTY7, 634 610 }; 635 611 636 612 static struct resource sdhi0_resources[] = { ··· 632 656 }, 633 657 }; 634 658 635 - static void cn12_set_pwr(struct platform_device *pdev, int state) 636 - { 637 - static int power_gpio = -EINVAL; 638 - 639 - if (power_gpio < 0) { 640 - int ret = gpio_request(GPIO_PTB7, NULL); 641 - if (!ret) { 642 - power_gpio = GPIO_PTB7; 643 - gpio_direction_output(power_gpio, 0); 644 - } 645 - } 646 - 647 - /* 648 - * Toggle the GPIO regardless, whether we managed to grab it above or 649 - * the fixed regulator driver did. 650 - */ 651 - gpio_set_value(GPIO_PTB7, state); 652 - } 653 - 654 659 #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) 655 660 /* SDHI1 */ 656 - static int sdhi1_get_cd(struct platform_device *pdev) 657 - { 658 - return !gpio_get_value(GPIO_PTW7); 659 - } 660 - 661 661 static struct sh_mobile_sdhi_info sdhi1_info = { 662 662 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX, 663 663 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX, 664 664 .tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD | 665 665 MMC_CAP_NEEDS_POLL, 666 - .set_pwr = cn12_set_pwr, 667 - .get_cd = sdhi1_get_cd, 666 + .tmio_flags = TMIO_MMC_USE_GPIO_CD, 667 + .cd_gpio = GPIO_PTW7, 668 668 }; 669 669 670 670 static struct resource sdhi1_resources[] = { ··· 670 718 #else 671 719 672 720 /* MMC SPI */ 673 - static int mmc_spi_get_ro(struct device *dev) 674 - { 675 - return gpio_get_value(GPIO_PTY6); 676 - } 677 - 678 - static int mmc_spi_get_cd(struct device *dev) 679 - { 680 - return !gpio_get_value(GPIO_PTY7); 681 - } 682 - 683 721 static void mmc_spi_setpower(struct device *dev, unsigned int maskval) 684 722 { 685 723 gpio_set_value(GPIO_PTB6, maskval ? 1 : 0); 686 724 } 687 725 688 726 static struct mmc_spi_platform_data mmc_spi_info = { 689 - .get_ro = mmc_spi_get_ro, 690 - .get_cd = mmc_spi_get_cd, 691 727 .caps = MMC_CAP_NEEDS_POLL, 728 + .caps2 = MMC_CAP2_RO_ACTIVE_HIGH, 692 729 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */ 693 730 .setpower = mmc_spi_setpower, 731 + .flags = MMC_SPI_USE_CD_GPIO | MMC_SPI_USE_RO_GPIO, 732 + .cd_gpio = GPIO_PTY7, 733 + .ro_gpio = GPIO_PTY6, 694 734 }; 695 735 696 736 static struct spi_board_info spi_bus[] = { ··· 942 998 943 999 #if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE) 944 1000 /* SH_MMCIF */ 945 - static void mmcif_down_pwr(struct platform_device *pdev) 946 - { 947 - cn12_set_pwr(pdev, 0); 948 - } 949 - 950 1001 static struct resource sh_mmcif_resources[] = { 951 1002 [0] = { 952 1003 .name = "SH_MMCIF", ··· 962 1023 }; 963 1024 964 1025 static struct sh_mmcif_plat_data sh_mmcif_plat = { 965 - .set_pwr = cn12_set_pwr, 966 - .down_pwr = mmcif_down_pwr, 967 1026 .sup_pclk = 0, /* SH7724: Max Pclk/2 */ 968 1027 .caps = MMC_CAP_4_BIT_DATA | 969 1028 MMC_CAP_8_BIT_DATA | ··· 1278 1341 gpio_direction_input(GPIO_PTR6); 1279 1342 1280 1343 /* SD-card slot CN11 */ 1281 - /* Card-detect, used on CN11, either with SDHI0 or with SPI */ 1282 - gpio_request(GPIO_PTY7, NULL); 1283 - gpio_direction_input(GPIO_PTY7); 1284 - 1285 1344 #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) 1286 1345 /* enable SDHI0 on CN11 (needs DS2.4 set to ON) */ 1287 1346 gpio_request(GPIO_FN_SDHI0WP, NULL); ··· 1296 1363 gpio_direction_output(GPIO_PTM4, 1); /* active low CS */ 1297 1364 gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */ 1298 1365 gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */ 1299 - gpio_request(GPIO_PTY6, NULL); /* write protect */ 1300 - gpio_direction_input(GPIO_PTY6); 1301 1366 1302 1367 spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus)); 1303 1368 #endif ··· 1324 1393 gpio_request(GPIO_FN_SDHI1D2, NULL); 1325 1394 gpio_request(GPIO_FN_SDHI1D1, NULL); 1326 1395 gpio_request(GPIO_FN_SDHI1D0, NULL); 1327 - 1328 - /* Card-detect, used on CN12 with SDHI1 */ 1329 - gpio_request(GPIO_PTW7, NULL); 1330 - gpio_direction_input(GPIO_PTW7); 1331 1396 1332 1397 cn12_enabled = true; 1333 1398 #endif
+43 -4
drivers/mmc/card/block.c
··· 812 812 * Otherwise we don't understand what happened, so abort. 813 813 */ 814 814 static int mmc_blk_cmd_recovery(struct mmc_card *card, struct request *req, 815 - struct mmc_blk_request *brq, int *ecc_err) 815 + struct mmc_blk_request *brq, int *ecc_err, int *gen_err) 816 816 { 817 817 bool prev_cmd_status_valid = true; 818 818 u32 status, stop_status = 0; ··· 850 850 (brq->cmd.resp[0] & R1_CARD_ECC_FAILED)) 851 851 *ecc_err = 1; 852 852 853 + /* Flag General errors */ 854 + if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) 855 + if ((status & R1_ERROR) || 856 + (brq->stop.resp[0] & R1_ERROR)) { 857 + pr_err("%s: %s: general error sending stop or status command, stop cmd response %#x, card status %#x\n", 858 + req->rq_disk->disk_name, __func__, 859 + brq->stop.resp[0], status); 860 + *gen_err = 1; 861 + } 862 + 853 863 /* 854 864 * Check the current card state. If it is in some data transfer 855 865 * mode, tell it to stop (and hopefully transition back to TRAN.) ··· 879 869 return ERR_ABORT; 880 870 if (stop_status & R1_CARD_ECC_FAILED) 881 871 *ecc_err = 1; 872 + if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) 873 + if (stop_status & R1_ERROR) { 874 + pr_err("%s: %s: general error sending stop command, stop cmd response %#x\n", 875 + req->rq_disk->disk_name, __func__, 876 + stop_status); 877 + *gen_err = 1; 878 + } 882 879 } 883 880 884 881 /* Check for set block count errors */ ··· 1114 1097 mmc_active); 1115 1098 struct mmc_blk_request *brq = &mq_mrq->brq; 1116 1099 struct request *req = mq_mrq->req; 1117 - int ecc_err = 0; 1100 + int ecc_err = 0, gen_err = 0; 1118 1101 1119 1102 /* 1120 1103 * sbc.error indicates a problem with the set block count ··· 1128 1111 */ 1129 1112 if (brq->sbc.error || brq->cmd.error || brq->stop.error || 1130 1113 brq->data.error) { 1131 - switch (mmc_blk_cmd_recovery(card, req, brq, &ecc_err)) { 1114 + switch (mmc_blk_cmd_recovery(card, req, brq, &ecc_err, &gen_err)) { 1132 1115 case ERR_RETRY: 1133 1116 return MMC_BLK_RETRY; 1134 1117 case ERR_ABORT: ··· 1160 1143 u32 status; 1161 1144 unsigned long timeout; 1162 1145 1146 + /* Check stop command response */ 1147 + if (brq->stop.resp[0] & R1_ERROR) { 1148 + pr_err("%s: %s: general error sending stop command, stop cmd response %#x\n", 1149 + req->rq_disk->disk_name, __func__, 1150 + brq->stop.resp[0]); 1151 + gen_err = 1; 1152 + } 1153 + 1163 1154 timeout = jiffies + msecs_to_jiffies(MMC_BLK_TIMEOUT_MS); 1164 1155 do { 1165 1156 int err = get_card_status(card, &status, 5); ··· 1175 1150 pr_err("%s: error %d requesting status\n", 1176 1151 req->rq_disk->disk_name, err); 1177 1152 return MMC_BLK_CMD_ERR; 1153 + } 1154 + 1155 + if (status & R1_ERROR) { 1156 + pr_err("%s: %s: general error sending status command, card status %#x\n", 1157 + req->rq_disk->disk_name, __func__, 1158 + status); 1159 + gen_err = 1; 1178 1160 } 1179 1161 1180 1162 /* Timeout if the device never becomes ready for data ··· 1201 1169 */ 1202 1170 } while (!(status & R1_READY_FOR_DATA) || 1203 1171 (R1_CURRENT_STATE(status) == R1_STATE_PRG)); 1172 + } 1173 + 1174 + /* if general error occurs, retry the write operation. */ 1175 + if (gen_err) { 1176 + pr_warn("%s: retrying write for general error\n", 1177 + req->rq_disk->disk_name); 1178 + return MMC_BLK_RETRY; 1204 1179 } 1205 1180 1206 1181 if (brq->data.error) { ··· 2230 2191 * is freeing the queue that stops new requests 2231 2192 * from being accepted. 2232 2193 */ 2194 + card = md->queue.card; 2233 2195 mmc_cleanup_queue(&md->queue); 2234 2196 if (md->flags & MMC_BLK_PACKED_CMD) 2235 2197 mmc_packed_clean(&md->queue); 2236 - card = md->queue.card; 2237 2198 if (md->disk->flags & GENHD_FL_UP) { 2238 2199 device_remove_file(disk_to_dev(md->disk), &md->force_ro); 2239 2200 if ((md->area_type & MMC_BLK_DATA_AREA_BOOT) &&
+4 -10
drivers/mmc/card/mmc_test.c
··· 2849 2849 struct seq_file *sf = (struct seq_file *)file->private_data; 2850 2850 struct mmc_card *card = (struct mmc_card *)sf->private; 2851 2851 struct mmc_test_card *test; 2852 - char lbuf[12]; 2853 2852 long testcase; 2853 + int ret; 2854 2854 2855 - if (count >= sizeof(lbuf)) 2856 - return -EINVAL; 2857 - 2858 - if (copy_from_user(lbuf, buf, count)) 2859 - return -EFAULT; 2860 - lbuf[count] = '\0'; 2861 - 2862 - if (strict_strtol(lbuf, 10, &testcase)) 2863 - return -EINVAL; 2855 + ret = kstrtol_from_user(buf, count, 10, &testcase); 2856 + if (ret) 2857 + return ret; 2864 2858 2865 2859 test = kzalloc(sizeof(struct mmc_test_card), GFP_KERNEL); 2866 2860 if (!test)
+44
drivers/mmc/core/core.c
··· 27 27 #include <linux/fault-inject.h> 28 28 #include <linux/random.h> 29 29 #include <linux/slab.h> 30 + #include <linux/of.h> 30 31 31 32 #include <linux/mmc/card.h> 32 33 #include <linux/mmc/host.h> ··· 1196 1195 return mask; 1197 1196 } 1198 1197 EXPORT_SYMBOL(mmc_vddrange_to_ocrmask); 1198 + 1199 + #ifdef CONFIG_OF 1200 + 1201 + /** 1202 + * mmc_of_parse_voltage - return mask of supported voltages 1203 + * @np: The device node need to be parsed. 1204 + * @mask: mask of voltages available for MMC/SD/SDIO 1205 + * 1206 + * 1. Return zero on success. 1207 + * 2. Return negative errno: voltage-range is invalid. 1208 + */ 1209 + int mmc_of_parse_voltage(struct device_node *np, u32 *mask) 1210 + { 1211 + const u32 *voltage_ranges; 1212 + int num_ranges, i; 1213 + 1214 + voltage_ranges = of_get_property(np, "voltage-ranges", &num_ranges); 1215 + num_ranges = num_ranges / sizeof(*voltage_ranges) / 2; 1216 + if (!voltage_ranges || !num_ranges) { 1217 + pr_info("%s: voltage-ranges unspecified\n", np->full_name); 1218 + return -EINVAL; 1219 + } 1220 + 1221 + for (i = 0; i < num_ranges; i++) { 1222 + const int j = i * 2; 1223 + u32 ocr_mask; 1224 + 1225 + ocr_mask = mmc_vddrange_to_ocrmask( 1226 + be32_to_cpu(voltage_ranges[j]), 1227 + be32_to_cpu(voltage_ranges[j + 1])); 1228 + if (!ocr_mask) { 1229 + pr_err("%s: voltage-range #%d is invalid\n", 1230 + np->full_name, i); 1231 + return -EINVAL; 1232 + } 1233 + *mask |= ocr_mask; 1234 + } 1235 + 1236 + return 0; 1237 + } 1238 + EXPORT_SYMBOL(mmc_of_parse_voltage); 1239 + 1240 + #endif /* CONFIG_OF */ 1199 1241 1200 1242 #ifdef CONFIG_REGULATOR 1201 1243
+1 -1
drivers/mmc/core/host.c
··· 374 374 if (!(flags & OF_GPIO_ACTIVE_LOW)) 375 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 378 if (ret < 0) { 379 379 dev_err(host->parent, 380 380 "Failed to request CD GPIO #%d: %d!\n",
+1
drivers/mmc/core/mmc_ops.c
··· 531 531 532 532 data.sg = &sg; 533 533 data.sg_len = 1; 534 + mmc_set_data_timeout(&data, card); 534 535 sg_init_one(&sg, data_buf, len); 535 536 mmc_wait_for_req(host, &mrq); 536 537 err = 0;
+8 -5
drivers/mmc/core/sd.c
··· 215 215 static int mmc_read_ssr(struct mmc_card *card) 216 216 { 217 217 unsigned int au, es, et, eo; 218 - int err, i; 218 + int err, i, max_au; 219 219 u32 *ssr; 220 220 221 221 if (!(card->csd.cmdclass & CCC_APP_SPEC)) { ··· 239 239 for (i = 0; i < 16; i++) 240 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 246 * UNSTUFF_BITS only works with four u32s so we have to offset the 244 247 * bitfield positions accordingly. 245 248 */ 246 249 au = UNSTUFF_BITS(ssr, 428 - 384, 4); 247 - if (au > 0 && au <= 9) { 250 + if (au > 0 && au <= max_au) { 248 251 card->ssr.au = 1 << (au + 4); 249 252 es = UNSTUFF_BITS(ssr, 408 - 384, 16); 250 253 et = UNSTUFF_BITS(ssr, 402 - 384, 6); ··· 945 942 if (!mmc_host_is_spi(host)) { 946 943 err = mmc_send_relative_addr(host, &card->rca); 947 944 if (err) 948 - return err; 945 + goto free_card; 949 946 } 950 947 951 948 if (!oldcard) { 952 949 err = mmc_sd_get_csd(host, card); 953 950 if (err) 954 - return err; 951 + goto free_card; 955 952 956 953 mmc_decode_cid(card); 957 954 } ··· 962 959 if (!mmc_host_is_spi(host)) { 963 960 err = mmc_select_card(card); 964 961 if (err) 965 - return err; 962 + goto free_card; 966 963 } 967 964 968 965 err = mmc_sd_setup_card(host, card, oldcard != NULL);
+13 -1
drivers/mmc/core/slot-gpio.c
··· 135 135 * mmc_gpio_request_cd - request a gpio for card-detection 136 136 * @host: mmc host 137 137 * @gpio: gpio number requested 138 + * @debounce: debounce time in microseconds 138 139 * 139 140 * As devm_* managed functions are used in mmc_gpio_request_cd(), client 140 141 * drivers do not need to explicitly call mmc_gpio_free_cd() for freeing up, ··· 144 143 * switching for card-detection, they are responsible for calling 145 144 * mmc_gpio_request_cd() and mmc_gpio_free_cd() as a pair on their own. 146 145 * 146 + * If GPIO debouncing is desired, set the debounce parameter to a non-zero 147 + * value. The caller is responsible for ensuring that the GPIO driver associated 148 + * with the GPIO supports debouncing, otherwise an error will be returned. 149 + * 147 150 * Returns zero on success, else an error. 148 151 */ 149 - int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio) 152 + int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio, 153 + unsigned int debounce) 150 154 { 151 155 struct mmc_gpio *ctx; 152 156 int irq = gpio_to_irq(gpio); ··· 172 166 * is destroyed. 173 167 */ 174 168 return ret; 169 + 170 + if (debounce) { 171 + ret = gpio_set_debounce(gpio, debounce); 172 + if (ret < 0) 173 + return ret; 174 + } 175 175 176 176 /* 177 177 * Even if gpio_to_irq() returns a valid IRQ number, the platform might
+5 -5
drivers/mmc/host/Kconfig
··· 284 284 285 285 config MMC_OMAP_HS 286 286 tristate "TI OMAP High Speed Multimedia Card Interface support" 287 - depends on SOC_OMAP2430 || ARCH_OMAP3 || ARCH_OMAP4 287 + depends on ARCH_OMAP2PLUS || COMPILE_TEST 288 288 help 289 289 This selects the TI OMAP High Speed Multimedia card Interface. 290 - If you have an OMAP2430 or OMAP3 board or OMAP4 board with a 291 - Multimedia Card slot, say Y or M here. 290 + If you have an omap2plus board with a Multimedia Card slot, 291 + say Y or M here. 292 292 293 293 If unsure, say N. 294 294 ··· 530 530 531 531 config MMC_DW 532 532 tristate "Synopsys DesignWare Memory Card Interface" 533 - depends on ARM 533 + depends on ARC || ARM 534 534 help 535 535 This selects support for the Synopsys DesignWare Mobile Storage IP 536 536 block, this provides host support for SD and MMC interfaces, in both ··· 569 569 570 570 config MMC_DW_SOCFPGA 571 571 tristate "SOCFPGA specific extensions for Synopsys DW Memory Card Interface" 572 - depends on MMC_DW 572 + depends on MMC_DW && MFD_SYSCON 573 573 select MMC_DW_PLTFM 574 574 help 575 575 This selects support for Altera SoCFPGA specific extensions to the
-2
drivers/mmc/host/Makefile
··· 52 52 53 53 obj-$(CONFIG_MMC_REALTEK_PCI) += rtsx_pci_sdmmc.o 54 54 55 - obj-$(CONFIG_MMC_REALTEK_PCI) += rtsx_pci_sdmmc.o 56 - 57 55 obj-$(CONFIG_MMC_SDHCI_PLTFM) += sdhci-pltfm.o 58 56 obj-$(CONFIG_MMC_SDHCI_CNS3XXX) += sdhci-cns3xxx.o 59 57 obj-$(CONFIG_MMC_SDHCI_ESDHC_IMX) += sdhci-esdhc-imx.o
+27 -7
drivers/mmc/host/atmel-mci.c
··· 378 378 { 379 379 struct atmel_mci *host = s->private; 380 380 u32 *buf; 381 + int ret = 0; 382 + 381 383 382 384 buf = kmalloc(ATMCI_REGS_SIZE, GFP_KERNEL); 383 385 if (!buf) ··· 390 388 * not disabling interrupts, so IMR and SR may not be 391 389 * consistent. 392 390 */ 391 + ret = clk_prepare_enable(host->mck); 392 + if (ret) 393 + goto out; 394 + 393 395 spin_lock_bh(&host->lock); 394 - clk_enable(host->mck); 395 396 memcpy_fromio(buf, host->regs, ATMCI_REGS_SIZE); 396 - clk_disable(host->mck); 397 397 spin_unlock_bh(&host->lock); 398 + 399 + clk_disable_unprepare(host->mck); 398 400 399 401 seq_printf(s, "MR:\t0x%08x%s%s ", 400 402 buf[ATMCI_MR / 4], ··· 448 442 val & ATMCI_CFG_LSYNC ? " LSYNC" : ""); 449 443 } 450 444 445 + out: 451 446 kfree(buf); 452 447 453 - return 0; 448 + return ret; 454 449 } 455 450 456 451 static int atmci_regs_open(struct inode *inode, struct file *file) ··· 1269 1262 struct atmel_mci_slot *slot = mmc_priv(mmc); 1270 1263 struct atmel_mci *host = slot->host; 1271 1264 unsigned int i; 1265 + bool unprepare_clk; 1272 1266 1273 1267 slot->sdc_reg &= ~ATMCI_SDCBUS_MASK; 1274 1268 switch (ios->bus_width) { ··· 1285 1277 unsigned int clock_min = ~0U; 1286 1278 u32 clkdiv; 1287 1279 1280 + clk_prepare(host->mck); 1281 + unprepare_clk = true; 1282 + 1288 1283 spin_lock_bh(&host->lock); 1289 1284 if (!host->mode_reg) { 1290 1285 clk_enable(host->mck); 1286 + unprepare_clk = false; 1291 1287 atmci_writel(host, ATMCI_CR, ATMCI_CR_SWRST); 1292 1288 atmci_writel(host, ATMCI_CR, ATMCI_CR_MCIEN); 1293 1289 if (host->caps.has_cfg_reg) ··· 1359 1347 } else { 1360 1348 bool any_slot_active = false; 1361 1349 1350 + unprepare_clk = false; 1351 + 1362 1352 spin_lock_bh(&host->lock); 1363 1353 slot->clock = 0; 1364 1354 for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) { ··· 1374 1360 if (host->mode_reg) { 1375 1361 atmci_readl(host, ATMCI_MR); 1376 1362 clk_disable(host->mck); 1363 + unprepare_clk = true; 1377 1364 } 1378 1365 host->mode_reg = 0; 1379 1366 } 1380 1367 spin_unlock_bh(&host->lock); 1381 1368 } 1369 + 1370 + if (unprepare_clk) 1371 + clk_unprepare(host->mck); 1382 1372 1383 1373 switch (ios->power_mode) { 1384 1374 case MMC_POWER_UP: ··· 2394 2376 if (!host->regs) 2395 2377 goto err_ioremap; 2396 2378 2397 - clk_enable(host->mck); 2379 + ret = clk_prepare_enable(host->mck); 2380 + if (ret) 2381 + goto err_request_irq; 2398 2382 atmci_writel(host, ATMCI_CR, ATMCI_CR_SWRST); 2399 2383 host->bus_hz = clk_get_rate(host->mck); 2400 - clk_disable(host->mck); 2384 + clk_disable_unprepare(host->mck); 2401 2385 2402 2386 host->mapbase = regs->start; 2403 2387 ··· 2502 2482 atmci_cleanup_slot(host->slot[i], i); 2503 2483 } 2504 2484 2505 - clk_enable(host->mck); 2485 + clk_prepare_enable(host->mck); 2506 2486 atmci_writel(host, ATMCI_IDR, ~0UL); 2507 2487 atmci_writel(host, ATMCI_CR, ATMCI_CR_MCIDIS); 2508 2488 atmci_readl(host, ATMCI_SR); 2509 - clk_disable(host->mck); 2489 + clk_disable_unprepare(host->mck); 2510 2490 2511 2491 if (host->dma.chan) 2512 2492 dma_release_channel(host->dma.chan);
+8 -1
drivers/mmc/host/dw_mmc-exynos.c
··· 39 39 DW_MCI_TYPE_EXYNOS4210, 40 40 DW_MCI_TYPE_EXYNOS4412, 41 41 DW_MCI_TYPE_EXYNOS5250, 42 + DW_MCI_TYPE_EXYNOS5420, 42 43 }; 43 44 44 45 /* Exynos implementation specific driver private data */ ··· 63 62 }, { 64 63 .compatible = "samsung,exynos5250-dw-mshc", 65 64 .ctrl_type = DW_MCI_TYPE_EXYNOS5250, 65 + }, { 66 + .compatible = "samsung,exynos5420-dw-mshc", 67 + .ctrl_type = DW_MCI_TYPE_EXYNOS5420, 66 68 }, 67 69 }; 68 70 ··· 94 90 { 95 91 struct dw_mci_exynos_priv_data *priv = host->priv; 96 92 97 - if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS5250) 93 + if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS5250 || 94 + priv->ctrl_type == DW_MCI_TYPE_EXYNOS5420) 98 95 host->bus_hz /= (priv->ciu_div + 1); 99 96 else if (priv->ctrl_type == DW_MCI_TYPE_EXYNOS4412) 100 97 host->bus_hz /= EXYNOS4412_FIXED_CIU_CLK_DIV; ··· 177 172 { .compatible = "samsung,exynos4412-dw-mshc", 178 173 .data = &exynos_drv_data, }, 179 174 { .compatible = "samsung,exynos5250-dw-mshc", 175 + .data = &exynos_drv_data, }, 176 + { .compatible = "samsung,exynos5420-dw-mshc", 180 177 .data = &exynos_drv_data, }, 181 178 {}, 182 179 };
+3 -1
drivers/mmc/host/dw_mmc-pci.c
··· 59 59 if (ret) 60 60 return ret; 61 61 62 - host->regs = pcim_iomap_table(pdev)[0]; 62 + host->regs = pcim_iomap_table(pdev)[PCI_BAR_NO]; 63 + 64 + pci_set_master(pdev); 63 65 64 66 ret = dw_mci_probe(host); 65 67 if (ret)
+1
drivers/mmc/host/dw_mmc-pltfm.c
··· 23 23 #include <linux/of.h> 24 24 25 25 #include "dw_mmc.h" 26 + #include "dw_mmc-pltfm.h" 26 27 27 28 static void dw_mci_rockchip_prepare_command(struct dw_mci *host, u32 *cmdr) 28 29 {
+10 -11
drivers/mmc/host/dw_mmc.c
··· 1601 1601 1602 1602 pending = mci_readl(host, MINTSTS); /* read-only mask reg */ 1603 1603 1604 + /* 1605 + * DTO fix - version 2.10a and below, and only if internal DMA 1606 + * is configured. 1607 + */ 1608 + if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO) { 1609 + if (!pending && 1610 + ((mci_readl(host, STATUS) >> 17) & 0x1fff)) 1611 + pending |= SDMMC_INT_DATA_OVER; 1612 + } 1613 + 1604 1614 if (pending) { 1605 - 1606 - /* 1607 - * DTO fix - version 2.10a and below, and only if internal DMA 1608 - * is configured. 1609 - */ 1610 - if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO) { 1611 - if (!pending && 1612 - ((mci_readl(host, STATUS) >> 17) & 0x1fff)) 1613 - pending |= SDMMC_INT_DATA_OVER; 1614 - } 1615 - 1616 1615 if (pending & DW_MCI_CMD_ERROR_FLAGS) { 1617 1616 mci_writel(host, RINTSTS, DW_MCI_CMD_ERROR_FLAGS); 1618 1617 host->cmd_status = pending;
+3 -4
drivers/mmc/host/jz4740_mmc.c
··· 713 713 mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; 714 714 715 715 if (gpio_is_valid(pdata->gpio_card_detect)) { 716 - ret = mmc_gpio_request_cd(mmc, pdata->gpio_card_detect); 716 + ret = mmc_gpio_request_cd(mmc, pdata->gpio_card_detect, 0); 717 717 if (ret) 718 718 return ret; 719 719 } ··· 783 783 784 784 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 785 785 host->base = devm_ioremap_resource(&pdev->dev, res); 786 - if (!host->base) { 787 - ret = -EBUSY; 788 - dev_err(&pdev->dev, "Failed to ioremap base memory\n"); 786 + if (IS_ERR(host->base)) { 787 + ret = PTR_ERR(host->base); 789 788 goto err_free_host; 790 789 } 791 790
+22 -27
drivers/mmc/host/mmc_spi.c
··· 36 36 37 37 #include <linux/mmc/host.h> 38 38 #include <linux/mmc/mmc.h> /* for R1_SPI_* bit values */ 39 + #include <linux/mmc/slot-gpio.h> 39 40 40 41 #include <linux/spi/spi.h> 41 42 #include <linux/spi/mmc_spi.h> ··· 1273 1272 } 1274 1273 } 1275 1274 1276 - static int mmc_spi_get_ro(struct mmc_host *mmc) 1277 - { 1278 - struct mmc_spi_host *host = mmc_priv(mmc); 1279 - 1280 - if (host->pdata && host->pdata->get_ro) 1281 - return !!host->pdata->get_ro(mmc->parent); 1282 - /* 1283 - * Board doesn't support read only detection; let the mmc core 1284 - * decide what to do. 1285 - */ 1286 - return -ENOSYS; 1287 - } 1288 - 1289 - static int mmc_spi_get_cd(struct mmc_host *mmc) 1290 - { 1291 - struct mmc_spi_host *host = mmc_priv(mmc); 1292 - 1293 - if (host->pdata && host->pdata->get_cd) 1294 - return !!host->pdata->get_cd(mmc->parent); 1295 - return -ENOSYS; 1296 - } 1297 - 1298 1275 static const struct mmc_host_ops mmc_spi_ops = { 1299 1276 .request = mmc_spi_request, 1300 1277 .set_ios = mmc_spi_set_ios, 1301 - .get_ro = mmc_spi_get_ro, 1302 - .get_cd = mmc_spi_get_cd, 1278 + .get_ro = mmc_gpio_get_ro, 1279 + .get_cd = mmc_gpio_get_cd, 1303 1280 }; 1304 1281 1305 1282 ··· 1303 1324 struct mmc_host *mmc; 1304 1325 struct mmc_spi_host *host; 1305 1326 int status; 1327 + bool has_ro = false; 1306 1328 1307 1329 /* We rely on full duplex transfers, mostly to reduce 1308 1330 * per-transfer overheads (by making fewer transfers). ··· 1428 1448 } 1429 1449 1430 1450 /* pass platform capabilities, if any */ 1431 - if (host->pdata) 1451 + if (host->pdata) { 1432 1452 mmc->caps |= host->pdata->caps; 1453 + mmc->caps2 |= host->pdata->caps2; 1454 + } 1433 1455 1434 1456 status = mmc_add_host(mmc); 1435 1457 if (status != 0) 1436 1458 goto fail_add_host; 1437 1459 1460 + if (host->pdata && host->pdata->flags & MMC_SPI_USE_CD_GPIO) { 1461 + status = mmc_gpio_request_cd(mmc, host->pdata->cd_gpio, 1462 + host->pdata->cd_debounce); 1463 + if (status != 0) 1464 + goto fail_add_host; 1465 + } 1466 + 1467 + if (host->pdata && host->pdata->flags & MMC_SPI_USE_RO_GPIO) { 1468 + has_ro = true; 1469 + status = mmc_gpio_request_ro(mmc, host->pdata->ro_gpio); 1470 + if (status != 0) 1471 + goto fail_add_host; 1472 + } 1473 + 1438 1474 dev_info(&spi->dev, "SD/MMC host %s%s%s%s%s\n", 1439 1475 dev_name(&mmc->class_dev), 1440 1476 host->dma_dev ? "" : ", no DMA", 1441 - (host->pdata && host->pdata->get_ro) 1442 - ? "" : ", no WP", 1477 + has_ro ? "" : ", no WP", 1443 1478 (host->pdata && host->pdata->setpower) 1444 1479 ? "" : ", no poweroff", 1445 1480 (mmc->caps & MMC_CAP_NEEDS_POLL)
+2 -1
drivers/mmc/host/mvsdio.c
··· 757 757 if (mvsd_data->gpio_card_detect && 758 758 gpio_is_valid(mvsd_data->gpio_card_detect)) { 759 759 ret = mmc_gpio_request_cd(mmc, 760 - mvsd_data->gpio_card_detect); 760 + mvsd_data->gpio_card_detect, 761 + 0); 761 762 if (ret) 762 763 goto out; 763 764 } else {
+14 -8
drivers/mmc/host/mxs-mmc.c
··· 102 102 BM_SSP_STATUS_CARD_DETECT) ^ host->cd_inverted; 103 103 } 104 104 105 - static void mxs_mmc_reset(struct mxs_mmc_host *host) 105 + static int mxs_mmc_reset(struct mxs_mmc_host *host) 106 106 { 107 107 struct mxs_ssp *ssp = &host->ssp; 108 108 u32 ctrl0, ctrl1; 109 + int ret; 109 110 110 - stmp_reset_block(ssp->base); 111 + ret = stmp_reset_block(ssp->base); 112 + if (ret) 113 + return ret; 111 114 112 115 ctrl0 = BM_SSP_CTRL0_IGNORE_CRC; 113 116 ctrl1 = BF_SSP(0x3, CTRL1_SSP_MODE) | ··· 135 132 136 133 writel(ctrl0, ssp->base + HW_SSP_CTRL0); 137 134 writel(ctrl1, ssp->base + HW_SSP_CTRL1(ssp)); 135 + return 0; 138 136 } 139 137 140 138 static void mxs_mmc_start_cmd(struct mxs_mmc_host *host, ··· 622 618 } 623 619 } 624 620 625 - ssp->clk = clk_get(&pdev->dev, NULL); 621 + ssp->clk = devm_clk_get(&pdev->dev, NULL); 626 622 if (IS_ERR(ssp->clk)) { 627 623 ret = PTR_ERR(ssp->clk); 628 624 goto out_mmc_free; 629 625 } 630 626 clk_prepare_enable(ssp->clk); 631 627 632 - mxs_mmc_reset(host); 628 + ret = mxs_mmc_reset(host); 629 + if (ret) { 630 + dev_err(&pdev->dev, "Failed to reset mmc: %d\n", ret); 631 + goto out_clk_disable; 632 + } 633 633 634 634 ssp->dmach = dma_request_slave_channel(&pdev->dev, "rx-tx"); 635 635 if (!ssp->dmach) { 636 636 dev_err(mmc_dev(host->mmc), 637 637 "%s: failed to request dma\n", __func__); 638 638 ret = -ENODEV; 639 - goto out_clk_put; 639 + goto out_clk_disable; 640 640 } 641 641 642 642 /* set mmc core parameters */ ··· 693 685 out_free_dma: 694 686 if (ssp->dmach) 695 687 dma_release_channel(ssp->dmach); 696 - out_clk_put: 688 + out_clk_disable: 697 689 clk_disable_unprepare(ssp->clk); 698 - clk_put(ssp->clk); 699 690 out_mmc_free: 700 691 mmc_free_host(mmc); 701 692 return ret; ··· 712 705 dma_release_channel(ssp->dmach); 713 706 714 707 clk_disable_unprepare(ssp->clk); 715 - clk_put(ssp->clk); 716 708 717 709 mmc_free_host(mmc); 718 710
+12 -34
drivers/mmc/host/of_mmc_spi.c
··· 50 50 return container_of(dev->platform_data, struct of_mmc_spi, pdata); 51 51 } 52 52 53 - static int of_mmc_spi_read_gpio(struct device *dev, int gpio_num) 54 - { 55 - struct of_mmc_spi *oms = to_of_mmc_spi(dev); 56 - bool active_low = oms->alow_gpios[gpio_num]; 57 - bool value = gpio_get_value(oms->gpios[gpio_num]); 58 - 59 - return active_low ^ value; 60 - } 61 - 62 - static int of_mmc_spi_get_cd(struct device *dev) 63 - { 64 - return of_mmc_spi_read_gpio(dev, CD_GPIO); 65 - } 66 - 67 - static int of_mmc_spi_get_ro(struct device *dev) 68 - { 69 - return of_mmc_spi_read_gpio(dev, WP_GPIO); 70 - } 71 - 72 53 static int of_mmc_spi_init(struct device *dev, 73 54 irqreturn_t (*irqhandler)(int, void *), void *mmc) 74 55 { ··· 111 130 if (!gpio_is_valid(oms->gpios[i])) 112 131 continue; 113 132 114 - ret = gpio_request(oms->gpios[i], dev_name(dev)); 115 - if (ret < 0) { 116 - oms->gpios[i] = -EINVAL; 117 - continue; 118 - } 119 - 120 133 if (gpio_flags & OF_GPIO_ACTIVE_LOW) 121 134 oms->alow_gpios[i] = true; 122 135 } 123 136 124 - if (gpio_is_valid(oms->gpios[CD_GPIO])) 125 - oms->pdata.get_cd = of_mmc_spi_get_cd; 126 - if (gpio_is_valid(oms->gpios[WP_GPIO])) 127 - oms->pdata.get_ro = of_mmc_spi_get_ro; 137 + if (gpio_is_valid(oms->gpios[CD_GPIO])) { 138 + oms->pdata.cd_gpio = oms->gpios[CD_GPIO]; 139 + oms->pdata.flags |= MMC_SPI_USE_CD_GPIO; 140 + if (!oms->alow_gpios[CD_GPIO]) 141 + oms->pdata.caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; 142 + } 143 + if (gpio_is_valid(oms->gpios[WP_GPIO])) { 144 + oms->pdata.ro_gpio = oms->gpios[WP_GPIO]; 145 + oms->pdata.flags |= MMC_SPI_USE_RO_GPIO; 146 + if (!oms->alow_gpios[WP_GPIO]) 147 + oms->pdata.caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; 148 + } 128 149 129 150 oms->detect_irq = irq_of_parse_and_map(np, 0); 130 151 if (oms->detect_irq != 0) { ··· 149 166 struct device *dev = &spi->dev; 150 167 struct device_node *np = dev->of_node; 151 168 struct of_mmc_spi *oms = to_of_mmc_spi(dev); 152 - int i; 153 169 154 170 if (!dev->platform_data || !np) 155 171 return; 156 172 157 - for (i = 0; i < ARRAY_SIZE(oms->gpios); i++) { 158 - if (gpio_is_valid(oms->gpios[i])) 159 - gpio_free(oms->gpios[i]); 160 - } 161 173 kfree(oms); 162 174 dev->platform_data = NULL; 163 175 }
+2 -1
drivers/mmc/host/omap_hsmmc.c
··· 21 21 #include <linux/debugfs.h> 22 22 #include <linux/dmaengine.h> 23 23 #include <linux/seq_file.h> 24 + #include <linux/sizes.h> 24 25 #include <linux/interrupt.h> 25 26 #include <linux/delay.h> 26 27 #include <linux/dma-mapping.h> ··· 1042 1041 } 1043 1042 } 1044 1043 1044 + OMAP_HSMMC_WRITE(host->base, STAT, status); 1045 1045 if (end_cmd || ((status & CC_EN) && host->cmd)) 1046 1046 omap_hsmmc_cmd_done(host, host->cmd); 1047 1047 if ((end_trans || (status & TC_EN)) && host->mrq) ··· 1062 1060 omap_hsmmc_do_irq(host, status); 1063 1061 1064 1062 /* Flush posted write */ 1065 - OMAP_HSMMC_WRITE(host->base, STAT, status); 1066 1063 status = OMAP_HSMMC_READ(host->base, STAT); 1067 1064 } 1068 1065
+1 -1
drivers/mmc/host/sdhci-bcm2835.c
··· 119 119 return byte; 120 120 } 121 121 122 - unsigned int bcm2835_sdhci_get_min_clock(struct sdhci_host *host) 122 + static unsigned int bcm2835_sdhci_get_min_clock(struct sdhci_host *host) 123 123 { 124 124 return MIN_FREQ; 125 125 }
+1 -1
drivers/mmc/host/sdhci-esdhc-imx.c
··· 616 616 /* card_detect */ 617 617 switch (boarddata->cd_type) { 618 618 case ESDHC_CD_GPIO: 619 - err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio); 619 + err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio, 0); 620 620 if (err) { 621 621 dev_err(mmc_dev(host->mmc), 622 622 "failed to request card-detect gpio!\n");
+1
drivers/mmc/host/sdhci-of-esdhc.c
··· 316 316 317 317 /* call to generic mmc_of_parse to support additional capabilities */ 318 318 mmc_of_parse(host->mmc); 319 + mmc_of_parse_voltage(np, &host->ocr_mask); 319 320 320 321 ret = sdhci_add_host(host); 321 322 if (ret)
+2 -1
drivers/mmc/host/sdhci-pxav3.c
··· 278 278 host->mmc->pm_caps |= pdata->pm_caps; 279 279 280 280 if (gpio_is_valid(pdata->ext_cd_gpio)) { 281 - ret = mmc_gpio_request_cd(host->mmc, pdata->ext_cd_gpio); 281 + ret = mmc_gpio_request_cd(host->mmc, pdata->ext_cd_gpio, 282 + 0); 282 283 if (ret) { 283 284 dev_err(mmc_dev(host->mmc), 284 285 "failed to allocate card detect gpio\n");
+6 -2
drivers/mmc/host/sdhci-s3c.c
··· 296 296 unsigned long timeout; 297 297 u16 clk = 0; 298 298 299 - /* don't bother if the clock is going off */ 300 - if (clock == 0) 299 + /* If the clock is going off, set to 0 at clock control register */ 300 + if (clock == 0) { 301 + sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL); 302 + host->clock = clock; 301 303 return; 304 + } 302 305 303 306 sdhci_s3c_set_clock(host, clock); 304 307 ··· 611 608 host->hw_name = "samsung-hsmmc"; 612 609 host->ops = &sdhci_s3c_ops; 613 610 host->quirks = 0; 611 + host->quirks2 = 0; 614 612 host->irq = irq; 615 613 616 614 /* Setup quirks for the controller */
+1 -1
drivers/mmc/host/sdhci-sirf.c
··· 84 84 * gets setup in sdhci_add_host() and we oops. 85 85 */ 86 86 if (gpio_is_valid(priv->gpio_cd)) { 87 - ret = mmc_gpio_request_cd(host->mmc, priv->gpio_cd); 87 + ret = mmc_gpio_request_cd(host->mmc, priv->gpio_cd, 0); 88 88 if (ret) { 89 89 dev_err(&pdev->dev, "card detect irq request failed: %d\n", 90 90 ret);
+5 -2
drivers/mmc/host/sdhci.c
··· 3119 3119 SDHCI_MAX_CURRENT_MULTIPLIER; 3120 3120 } 3121 3121 3122 + if (host->ocr_mask) 3123 + ocr_avail = host->ocr_mask; 3124 + 3122 3125 mmc->ocr_avail = ocr_avail; 3123 3126 mmc->ocr_avail_sdio = ocr_avail; 3124 3127 if (host->ocr_avail_sdio) ··· 3216 3213 host->tuning_timer.function = sdhci_tuning_timer; 3217 3214 } 3218 3215 3216 + sdhci_init(host, 0); 3217 + 3219 3218 ret = request_irq(host->irq, sdhci_irq, IRQF_SHARED, 3220 3219 mmc_hostname(mmc), host); 3221 3220 if (ret) { ··· 3225 3220 mmc_hostname(mmc), host->irq, ret); 3226 3221 goto untasklet; 3227 3222 } 3228 - 3229 - sdhci_init(host, 0); 3230 3223 3231 3224 #ifdef CONFIG_MMC_DEBUG 3232 3225 sdhci_dumpregs(host);
+43 -20
drivers/mmc/host/sh_mmcif.c
··· 61 61 #include <linux/platform_device.h> 62 62 #include <linux/pm_qos.h> 63 63 #include <linux/pm_runtime.h> 64 + #include <linux/sh_dma.h> 64 65 #include <linux/spinlock.h> 65 66 #include <linux/module.h> 66 67 ··· 134 133 INT_BUFWEN | INT_CMD12DRE | INT_BUFRE | \ 135 134 INT_DTRANE | INT_CMD12RBE | INT_CMD12CRE) 136 135 136 + #define INT_CCS (INT_CCSTO | INT_CCSRCV | INT_CCSDE) 137 + 137 138 /* CE_INT_MASK */ 138 139 #define MASK_ALL 0x00000000 139 140 #define MASK_MCCSDE (1 << 29) ··· 164 161 165 162 #define MASK_START_CMD (MASK_MCMDVIO | MASK_MBUFVIO | MASK_MWDATERR | \ 166 163 MASK_MRDATERR | MASK_MRIDXERR | MASK_MRSPERR | \ 167 - MASK_MCCSTO | MASK_MCRCSTO | MASK_MWDATTO | \ 164 + MASK_MCRCSTO | MASK_MWDATTO | \ 168 165 MASK_MRDATTO | MASK_MRBSYTO | MASK_MRSPTO) 169 166 170 167 #define MASK_CLEAN (INT_ERR_STS | MASK_MRBSYE | MASK_MCRSPE | \ ··· 246 243 int sg_blkidx; 247 244 bool power; 248 245 bool card_present; 246 + bool ccs_enable; /* Command Completion Signal support */ 247 + bool clk_ctrl2_enable; 249 248 struct mutex thread_lock; 250 249 251 250 /* DMA support */ ··· 391 386 392 387 host->dma_active = false; 393 388 394 - if (!pdata) 389 + if (pdata) { 390 + if (pdata->slave_id_tx <= 0 || pdata->slave_id_rx <= 0) 391 + return; 392 + } else if (!host->pd->dev.of_node) { 395 393 return; 396 - 397 - if (pdata->slave_id_tx <= 0 || pdata->slave_id_rx <= 0) 398 - return; 394 + } 399 395 400 396 /* We can only either use DMA for both Tx and Rx or not use it at all */ 401 397 dma_cap_zero(mask); 402 398 dma_cap_set(DMA_SLAVE, mask); 403 399 404 - host->chan_tx = dma_request_channel(mask, shdma_chan_filter, 405 - (void *)pdata->slave_id_tx); 400 + host->chan_tx = dma_request_slave_channel_compat(mask, shdma_chan_filter, 401 + pdata ? (void *)pdata->slave_id_tx : NULL, 402 + &host->pd->dev, "tx"); 406 403 dev_dbg(&host->pd->dev, "%s: TX: got channel %p\n", __func__, 407 404 host->chan_tx); 408 405 409 406 if (!host->chan_tx) 410 407 return; 411 408 412 - cfg.slave_id = pdata->slave_id_tx; 409 + /* In the OF case the driver will get the slave ID from the DT */ 410 + if (pdata) 411 + cfg.slave_id = pdata->slave_id_tx; 413 412 cfg.direction = DMA_MEM_TO_DEV; 414 413 cfg.dst_addr = res->start + MMCIF_CE_DATA; 415 414 cfg.src_addr = 0; ··· 421 412 if (ret < 0) 422 413 goto ecfgtx; 423 414 424 - host->chan_rx = dma_request_channel(mask, shdma_chan_filter, 425 - (void *)pdata->slave_id_rx); 415 + host->chan_rx = dma_request_slave_channel_compat(mask, shdma_chan_filter, 416 + pdata ? (void *)pdata->slave_id_rx : NULL, 417 + &host->pd->dev, "rx"); 426 418 dev_dbg(&host->pd->dev, "%s: RX: got channel %p\n", __func__, 427 419 host->chan_rx); 428 420 429 421 if (!host->chan_rx) 430 422 goto erqrx; 431 423 432 - cfg.slave_id = pdata->slave_id_rx; 424 + if (pdata) 425 + cfg.slave_id = pdata->slave_id_rx; 433 426 cfg.direction = DMA_DEV_TO_MEM; 434 427 cfg.dst_addr = 0; 435 428 cfg.src_addr = res->start + MMCIF_CE_DATA; ··· 496 485 497 486 sh_mmcif_writel(host->addr, MMCIF_CE_VERSION, SOFT_RST_ON); 498 487 sh_mmcif_writel(host->addr, MMCIF_CE_VERSION, SOFT_RST_OFF); 488 + if (host->ccs_enable) 489 + tmp |= SCCSTO_29; 490 + if (host->clk_ctrl2_enable) 491 + sh_mmcif_writel(host->addr, MMCIF_CE_CLK_CTRL2, 0x0F0F0000); 499 492 sh_mmcif_bitset(host, MMCIF_CE_CLK_CTRL, tmp | 500 - SRSPTO_256 | SRBSYTO_29 | SRWDTO_29 | SCCSTO_29); 493 + SRSPTO_256 | SRBSYTO_29 | SRWDTO_29); 501 494 /* byte swap on */ 502 495 sh_mmcif_bitset(host, MMCIF_CE_BUF_ACC, BUF_ACC_ATYP); 503 496 } ··· 881 866 break; 882 867 } 883 868 869 + if (host->ccs_enable) 870 + mask |= MASK_MCCSTO; 871 + 884 872 if (mrq->data) { 885 873 sh_mmcif_writel(host->addr, MMCIF_CE_BLOCK_SET, 0); 886 874 sh_mmcif_writel(host->addr, MMCIF_CE_BLOCK_SET, ··· 891 873 } 892 874 opc = sh_mmcif_set_cmd(host, mrq); 893 875 894 - sh_mmcif_writel(host->addr, MMCIF_CE_INT, 0xD80430C0); 876 + if (host->ccs_enable) 877 + sh_mmcif_writel(host->addr, MMCIF_CE_INT, 0xD80430C0); 878 + else 879 + sh_mmcif_writel(host->addr, MMCIF_CE_INT, 0xD80430C0 | INT_CCS); 895 880 sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, mask); 896 881 /* set arg */ 897 882 sh_mmcif_writel(host->addr, MMCIF_CE_ARG, cmd->arg); ··· 977 956 978 957 static void sh_mmcif_set_power(struct sh_mmcif_host *host, struct mmc_ios *ios) 979 958 { 980 - struct sh_mmcif_plat_data *pd = host->pd->dev.platform_data; 981 959 struct mmc_host *mmc = host->mmc; 982 960 983 - if (pd && pd->set_pwr) 984 - pd->set_pwr(host->pd, ios->power_mode != MMC_POWER_OFF); 985 961 if (!IS_ERR(mmc->supply.vmmc)) 986 962 /* Errors ignored... */ 987 963 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ··· 1259 1241 static irqreturn_t sh_mmcif_intr(int irq, void *dev_id) 1260 1242 { 1261 1243 struct sh_mmcif_host *host = dev_id; 1262 - u32 state; 1244 + u32 state, mask; 1263 1245 1264 1246 state = sh_mmcif_readl(host->addr, MMCIF_CE_INT); 1265 - sh_mmcif_writel(host->addr, MMCIF_CE_INT, 1266 - ~(state & sh_mmcif_readl(host->addr, MMCIF_CE_INT_MASK))); 1247 + mask = sh_mmcif_readl(host->addr, MMCIF_CE_INT_MASK); 1248 + if (host->ccs_enable) 1249 + sh_mmcif_writel(host->addr, MMCIF_CE_INT, ~(state & mask)); 1250 + else 1251 + sh_mmcif_writel(host->addr, MMCIF_CE_INT, INT_CCS | ~(state & mask)); 1267 1252 sh_mmcif_bitclr(host, MMCIF_CE_INT_MASK, state & MASK_CLEAN); 1268 1253 1269 1254 if (state & ~MASK_CLEAN) ··· 1400 1379 host->mmc = mmc; 1401 1380 host->addr = reg; 1402 1381 host->timeout = msecs_to_jiffies(1000); 1382 + host->ccs_enable = !pd || !pd->ccs_unsupported; 1383 + host->clk_ctrl2_enable = pd && pd->clk_ctrl2_present; 1403 1384 1404 1385 host->pd = pdev; 1405 1386 ··· 1459 1436 } 1460 1437 1461 1438 if (pd && pd->use_cd_gpio) { 1462 - ret = mmc_gpio_request_cd(mmc, pd->cd_gpio); 1439 + ret = mmc_gpio_request_cd(mmc, pd->cd_gpio, 0); 1463 1440 if (ret < 0) 1464 1441 goto erqcd; 1465 1442 }
+5 -18
drivers/mmc/host/sh_mobile_sdhi.c
··· 70 70 clk_disable(priv->clk); 71 71 } 72 72 73 - static void sh_mobile_sdhi_set_pwr(struct platform_device *pdev, int state) 74 - { 75 - struct sh_mobile_sdhi_info *p = pdev->dev.platform_data; 76 - 77 - p->set_pwr(pdev, state); 78 - } 79 - 80 - static int sh_mobile_sdhi_get_cd(struct platform_device *pdev) 81 - { 82 - struct sh_mobile_sdhi_info *p = pdev->dev.platform_data; 83 - 84 - return p->get_cd(pdev); 85 - } 86 - 87 73 static int sh_mobile_sdhi_wait_idle(struct tmio_mmc_host *host) 88 74 { 89 75 int timeout = 1000; ··· 115 129 static const struct of_device_id sh_mobile_sdhi_of_match[] = { 116 130 { .compatible = "renesas,shmobile-sdhi" }, 117 131 { .compatible = "renesas,sh7372-sdhi" }, 132 + { .compatible = "renesas,sh73a0-sdhi", .data = &sh_mobile_sdhi_of_cfg[0], }, 133 + { .compatible = "renesas,r8a73a4-sdhi", .data = &sh_mobile_sdhi_of_cfg[0], }, 118 134 { .compatible = "renesas,r8a7740-sdhi", .data = &sh_mobile_sdhi_of_cfg[0], }, 135 + { .compatible = "renesas,r8a7778-sdhi", .data = &sh_mobile_sdhi_of_cfg[0], }, 136 + { .compatible = "renesas,r8a7779-sdhi", .data = &sh_mobile_sdhi_of_cfg[0], }, 137 + { .compatible = "renesas,r8a7790-sdhi", .data = &sh_mobile_sdhi_of_cfg[0], }, 119 138 {}, 120 139 }; 121 140 MODULE_DEVICE_TABLE(of, sh_mobile_sdhi_of_match); ··· 171 180 mmc_data->capabilities |= p->tmio_caps; 172 181 mmc_data->capabilities2 |= p->tmio_caps2; 173 182 mmc_data->cd_gpio = p->cd_gpio; 174 - if (p->set_pwr) 175 - mmc_data->set_pwr = sh_mobile_sdhi_set_pwr; 176 - if (p->get_cd) 177 - mmc_data->get_cd = sh_mobile_sdhi_get_cd; 178 183 179 184 if (p->dma_slave_tx > 0 && p->dma_slave_rx > 0) { 180 185 /*
+2 -2
drivers/mmc/host/tmio_mmc_dma.c
··· 104 104 pio: 105 105 if (!desc) { 106 106 /* DMA failed, fall back to PIO */ 107 + tmio_mmc_enable_dma(host, false); 107 108 if (ret >= 0) 108 109 ret = -EIO; 109 110 host->chan_rx = NULL; ··· 117 116 } 118 117 dev_warn(&host->pdev->dev, 119 118 "DMA failed: %d, falling back to PIO\n", ret); 120 - tmio_mmc_enable_dma(host, false); 121 119 } 122 120 123 121 dev_dbg(&host->pdev->dev, "%s(): desc %p, cookie %d, sg[%d]\n", __func__, ··· 185 185 pio: 186 186 if (!desc) { 187 187 /* DMA failed, fall back to PIO */ 188 + tmio_mmc_enable_dma(host, false); 188 189 if (ret >= 0) 189 190 ret = -EIO; 190 191 host->chan_tx = NULL; ··· 198 197 } 199 198 dev_warn(&host->pdev->dev, 200 199 "DMA failed: %d, falling back to PIO\n", ret); 201 - tmio_mmc_enable_dma(host, false); 202 200 } 203 201 204 202 dev_dbg(&host->pdev->dev, "%s(): desc %p, cookie %d\n", __func__,
+7 -17
drivers/mmc/host/tmio_mmc_pio.c
··· 795 795 * omap_hsmmc.c driver does. 796 796 */ 797 797 if (!IS_ERR(mmc->supply.vqmmc) && !ret) { 798 - regulator_enable(mmc->supply.vqmmc); 798 + ret = regulator_enable(mmc->supply.vqmmc); 799 799 udelay(200); 800 800 } 801 + 802 + if (ret < 0) 803 + dev_dbg(&host->pdev->dev, "Regulators failed to power up: %d\n", 804 + ret); 801 805 } 802 806 803 807 static void tmio_mmc_power_off(struct tmio_mmc_host *host) ··· 936 932 (sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT)); 937 933 } 938 934 939 - static int tmio_mmc_get_cd(struct mmc_host *mmc) 940 - { 941 - struct tmio_mmc_host *host = mmc_priv(mmc); 942 - struct tmio_mmc_data *pdata = host->pdata; 943 - int ret = mmc_gpio_get_cd(mmc); 944 - if (ret >= 0) 945 - return ret; 946 - 947 - if (!pdata->get_cd) 948 - return -ENOSYS; 949 - else 950 - return pdata->get_cd(host->pdev); 951 - } 952 - 953 935 static const struct mmc_host_ops tmio_mmc_ops = { 954 936 .request = tmio_mmc_request, 955 937 .set_ios = tmio_mmc_set_ios, 956 938 .get_ro = tmio_mmc_get_ro, 957 - .get_cd = tmio_mmc_get_cd, 939 + .get_cd = mmc_gpio_get_cd, 958 940 .enable_sdio_irq = tmio_mmc_enable_sdio_irq, 959 941 }; 960 942 ··· 1096 1106 dev_pm_qos_expose_latency_limit(&pdev->dev, 100); 1097 1107 1098 1108 if (pdata->flags & TMIO_MMC_USE_GPIO_CD) { 1099 - ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio); 1109 + ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio, 0); 1100 1110 if (ret < 0) { 1101 1111 tmio_mmc_host_remove(_host); 1102 1112 return ret;
+1 -1
drivers/mmc/host/vub300.c
··· 2079 2079 kref_put(&vub300->kref, vub300_delete); 2080 2080 } 2081 2081 2082 - void vub300_init_card(struct mmc_host *mmc, struct mmc_card *card) 2082 + static void vub300_init_card(struct mmc_host *mmc, struct mmc_card *card) 2083 2083 { /* NOT irq */ 2084 2084 struct vub300_mmc_host *vub300 = mmc_priv(mmc); 2085 2085 dev_info(&vub300->udev->dev, "NO host QUIRKS for this card\n");
-1
include/linux/mfd/tmio.h
··· 108 108 unsigned int cd_gpio; 109 109 void (*set_pwr)(struct platform_device *host, int state); 110 110 void (*set_clk_div)(struct platform_device *host, int state); 111 - int (*get_cd)(struct platform_device *host); 112 111 int (*write16_hook)(struct tmio_mmc_host *host, int addr); 113 112 /* clock management callbacks */ 114 113 int (*clk_enable)(struct platform_device *pdev, unsigned int *f);
+2
include/linux/mmc/core.h
··· 208 208 __mmc_claim_host(host, NULL); 209 209 } 210 210 211 + struct device_node; 211 212 extern u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max); 213 + extern int mmc_of_parse_voltage(struct device_node *np, u32 *mask); 212 214 213 215 #endif /* LINUX_MMC_CORE_H */
+1
include/linux/mmc/sdhci.h
··· 171 171 unsigned int ocr_avail_sdio; /* OCR bit masks */ 172 172 unsigned int ocr_avail_sd; 173 173 unsigned int ocr_avail_mmc; 174 + u32 ocr_mask; /* available voltages */ 174 175 175 176 wait_queue_head_t buf_ready_int; /* Waitqueue for Buffer Read Ready interrupt */ 176 177 unsigned int tuning_done; /* Condition flag set when CMD19 succeeds */
+3 -3
include/linux/mmc/sh_mmcif.h
··· 16 16 17 17 #include <linux/io.h> 18 18 #include <linux/platform_device.h> 19 - #include <linux/sh_dma.h> 20 19 21 20 /* 22 21 * MMCIF : CE_CLK_CTRL [19:16] ··· 32 33 */ 33 34 34 35 struct sh_mmcif_plat_data { 35 - void (*set_pwr)(struct platform_device *pdev, int state); 36 - void (*down_pwr)(struct platform_device *pdev); 37 36 int (*get_cd)(struct platform_device *pdef); 38 37 unsigned int slave_id_tx; /* embedded slave_id_[tr]x */ 39 38 unsigned int slave_id_rx; 40 39 bool use_cd_gpio : 1; 40 + bool ccs_unsupported : 1; 41 + bool clk_ctrl2_present : 1; 41 42 unsigned int cd_gpio; 42 43 u8 sup_pclk; /* 1 :SH7757, 0: SH7724/SH7372 */ 43 44 unsigned long caps; ··· 61 62 #define MMCIF_CE_INT_MASK 0x00000044 62 63 #define MMCIF_CE_HOST_STS1 0x00000048 63 64 #define MMCIF_CE_HOST_STS2 0x0000004C 65 + #define MMCIF_CE_CLK_CTRL2 0x00000070 64 66 #define MMCIF_CE_VERSION 0x0000007C 65 67 66 68 /* CE_BUF_ACC */
-2
include/linux/mmc/sh_mobile_sdhi.h
··· 25 25 unsigned long tmio_caps2; 26 26 u32 tmio_ocr_mask; /* available MMC voltages */ 27 27 unsigned int cd_gpio; 28 - void (*set_pwr)(struct platform_device *pdev, int state); 29 - int (*get_cd)(struct platform_device *pdev); 30 28 31 29 /* callbacks for board specific setup code */ 32 30 int (*init)(struct platform_device *pdev,
+2 -1
include/linux/mmc/slot-gpio.h
··· 18 18 void mmc_gpio_free_ro(struct mmc_host *host); 19 19 20 20 int mmc_gpio_get_cd(struct mmc_host *host); 21 - int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio); 21 + int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio, 22 + unsigned int debounce); 22 23 void mmc_gpio_free_cd(struct mmc_host *host); 23 24 24 25 #endif
+13 -6
include/linux/spi/mmc_spi.h
··· 7 7 struct device; 8 8 struct mmc_host; 9 9 10 + #define MMC_SPI_USE_CD_GPIO (1 << 0) 11 + #define MMC_SPI_USE_RO_GPIO (1 << 1) 12 + #define MMC_SPI_CD_GPIO_ACTIVE_LOW (1 << 2) 13 + #define MMC_SPI_RO_GPIO_ACTIVE_LOW (1 << 3) 14 + 10 15 /* Put this in platform_data of a device being used to manage an MMC/SD 11 16 * card slot. (Modeled after PXA mmc glue; see that for usage examples.) 12 17 * ··· 26 21 void *); 27 22 void (*exit)(struct device *, void *); 28 23 29 - /* sense switch on sd cards */ 30 - int (*get_ro)(struct device *); 31 - 32 24 /* 33 - * If board does not use CD interrupts, driver can optimize polling 34 - * using this function. 25 + * Card Detect and Read Only GPIOs. To enable debouncing on the card 26 + * detect GPIO, set the cd_debounce to the debounce time in 27 + * microseconds. 35 28 */ 36 - int (*get_cd)(struct device *); 29 + unsigned int flags; 30 + unsigned int cd_gpio; 31 + unsigned int cd_debounce; 32 + unsigned int ro_gpio; 37 33 38 34 /* Capabilities to pass into mmc core (e.g. MMC_CAP_NEEDS_POLL). */ 39 35 unsigned long caps; 36 + unsigned long caps2; 40 37 41 38 /* how long to debounce card detect, in msecs */ 42 39 u16 detect_delay;