Lines Matching full:mmc
3 * Driver for the MMC / SD / SDIO IP found in:
22 * Handle MMC errors better
35 #include <linux/mmc/card.h>
36 #include <linux/mmc/host.h>
37 #include <linux/mmc/mmc.h>
38 #include <linux/mmc/slot-gpio.h>
45 #include <linux/mmc/sdio.h>
137 static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable) in tmio_mmc_enable_sdio_irq() argument
139 struct tmio_mmc_host *host = mmc_priv(mmc); in tmio_mmc_enable_sdio_irq()
145 pm_runtime_get_sync(mmc_dev(mmc)); in tmio_mmc_enable_sdio_irq()
162 pm_runtime_mark_last_busy(mmc_dev(mmc)); in tmio_mmc_enable_sdio_irq()
163 pm_runtime_put_autosuspend(mmc_dev(mmc)); in tmio_mmc_enable_sdio_irq()
211 tmio_mmc_set_bus_width(host, host->mmc->ios.bus_width); in tmio_mmc_reset()
225 if (host->mmc->card) in tmio_mmc_reset()
226 mmc_retune_needed(host->mmc); in tmio_mmc_reset()
271 mmc_request_done(host->mmc, mrq); in tmio_mmc_reset_work()
274 /* These are the bitmasks the tmio chip requires to implement the MMC response
631 struct mmc_host *mmc = host->mmc; in __tmio_mmc_card_detect_irq() local
637 if ((((ireg & TMIO_STAT_CARD_REMOVE) && mmc->card) || in __tmio_mmc_card_detect_irq()
638 ((ireg & TMIO_STAT_CARD_INSERT) && !mmc->card)) && in __tmio_mmc_card_detect_irq()
639 !work_pending(&mmc->detect.work)) in __tmio_mmc_card_detect_irq()
640 mmc_detect_change(host->mmc, msecs_to_jiffies(100)); in __tmio_mmc_card_detect_irq()
680 struct mmc_host *mmc = host->mmc; in __tmio_mmc_sdio_irq() local
697 if (mmc->caps & MMC_CAP_SDIO_IRQ && ireg & TMIO_SDIO_STAT_IOIRQ) in __tmio_mmc_sdio_irq()
698 mmc_signal_sdio_irq(mmc); in __tmio_mmc_sdio_irq()
735 if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_4 || in tmio_mmc_start_data()
736 host->mmc->ios.bus_width == MMC_BUS_WIDTH_8) { in tmio_mmc_start_data()
741 mmc_hostname(host->mmc), data->blksz); in tmio_mmc_start_data()
752 if (host->mmc->max_blk_count >= SZ_64K) in tmio_mmc_start_data()
790 mmc_request_done(host->mmc, mrq); in tmio_process_mrq()
793 /* Process requests from the MMC layer */
794 static void tmio_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq) in tmio_mmc_request() argument
796 struct tmio_mmc_host *host = mmc_priv(mmc); in tmio_mmc_request()
806 mmc_request_done(mmc, mrq); in tmio_mmc_request()
853 mmc_retune_needed(host->mmc); in tmio_mmc_finish_request()
864 mmc_request_done(host->mmc, mrq); in tmio_mmc_finish_request()
876 struct mmc_host *mmc = host->mmc; in tmio_mmc_power_on() local
884 if (!IS_ERR(mmc->supply.vmmc)) { in tmio_mmc_power_on()
885 ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); in tmio_mmc_power_on()
898 if (!IS_ERR(mmc->supply.vqmmc) && !ret) { in tmio_mmc_power_on()
899 ret = regulator_enable(mmc->supply.vqmmc); in tmio_mmc_power_on()
910 struct mmc_host *mmc = host->mmc; in tmio_mmc_power_off() local
912 if (!IS_ERR(mmc->supply.vqmmc)) in tmio_mmc_power_off()
913 regulator_disable(mmc->supply.vqmmc); in tmio_mmc_power_off()
915 if (!IS_ERR(mmc->supply.vmmc)) in tmio_mmc_power_off()
916 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0); in tmio_mmc_power_off()
932 unsigned int clk_rate = host->mmc->actual_clock ?: host->mmc->f_max; in tmio_mmc_max_busy_timeout()
934 host->mmc->max_busy_timeout = host->get_timeout_cycles(host) / in tmio_mmc_max_busy_timeout()
938 /* Set MMC clock / power.
940 * run a MMC card at full speed (20MHz). The max clock is 24MHz on SD, but as
941 * MMC wont run that fast, it has to be clocked at 12MHz which is the next
944 static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) in tmio_mmc_set_ios() argument
946 struct tmio_mmc_host *host = mmc_priv(mmc); in tmio_mmc_set_ios()
1014 static int tmio_mmc_get_ro(struct mmc_host *mmc) in tmio_mmc_get_ro() argument
1016 struct tmio_mmc_host *host = mmc_priv(mmc); in tmio_mmc_get_ro()
1022 static int tmio_mmc_get_cd(struct mmc_host *mmc) in tmio_mmc_get_cd() argument
1024 struct tmio_mmc_host *host = mmc_priv(mmc); in tmio_mmc_get_cd()
1053 struct mmc_host *mmc = host->mmc; in tmio_mmc_init_ocr() local
1056 err = mmc_regulator_get_supply(mmc); in tmio_mmc_init_ocr()
1061 if (!mmc->ocr_avail) in tmio_mmc_init_ocr()
1062 mmc->ocr_avail = pdata->ocr_mask; in tmio_mmc_init_ocr()
1068 if (!mmc->ocr_avail) in tmio_mmc_init_ocr()
1075 struct mmc_host *mmc) in tmio_mmc_of_parse() argument
1085 * "toshiba,mmc-wrprotect-disable" in tmio_mmc_of_parse()
1087 if (of_property_read_bool(np, "toshiba,mmc-wrprotect-disable")) in tmio_mmc_of_parse()
1088 mmc->caps2 |= MMC_CAP2_NO_WRITE_PROTECT; in tmio_mmc_of_parse()
1095 struct mmc_host *mmc; in tmio_mmc_host_alloc() local
1103 mmc = mmc_alloc_host(sizeof(struct tmio_mmc_host), &pdev->dev); in tmio_mmc_host_alloc()
1104 if (!mmc) in tmio_mmc_host_alloc()
1107 host = mmc_priv(mmc); in tmio_mmc_host_alloc()
1109 host->mmc = mmc; in tmio_mmc_host_alloc()
1113 mmc->ops = &host->ops; in tmio_mmc_host_alloc()
1115 ret = mmc_of_parse(host->mmc); in tmio_mmc_host_alloc()
1121 tmio_mmc_of_parse(pdev, mmc); in tmio_mmc_host_alloc()
1127 mmc_free_host(mmc); in tmio_mmc_host_alloc()
1135 mmc_free_host(host->mmc); in tmio_mmc_host_free()
1143 struct mmc_host *mmc = _host->mmc; in tmio_mmc_host_probe() local
1147 * Check the sanity of mmc->f_min to prevent host->set_clock() from in tmio_mmc_host_probe()
1150 if (mmc->f_min == 0) in tmio_mmc_host_probe()
1169 ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0); in tmio_mmc_host_probe()
1173 mmc->caps |= MMC_CAP_4_BIT_DATA | pdata->capabilities; in tmio_mmc_host_probe()
1174 mmc->caps2 |= pdata->capabilities2; in tmio_mmc_host_probe()
1175 mmc->max_segs = pdata->max_segs ? : 32; in tmio_mmc_host_probe()
1176 mmc->max_blk_size = TMIO_MAX_BLK_SIZE; in tmio_mmc_host_probe()
1177 mmc->max_blk_count = pdata->max_blk_count ? : in tmio_mmc_host_probe()
1178 (PAGE_SIZE / mmc->max_blk_size) * mmc->max_segs; in tmio_mmc_host_probe()
1179 mmc->max_req_size = min_t(size_t, in tmio_mmc_host_probe()
1180 mmc->max_blk_size * mmc->max_blk_count, in tmio_mmc_host_probe()
1182 mmc->max_seg_size = mmc->max_req_size; in tmio_mmc_host_probe()
1184 if (mmc_can_gpio_ro(mmc)) in tmio_mmc_host_probe()
1187 if (mmc_can_gpio_cd(mmc)) in tmio_mmc_host_probe()
1191 _host->native_hotplug = !(mmc_can_gpio_cd(mmc) || in tmio_mmc_host_probe()
1192 mmc->caps & MMC_CAP_NEEDS_POLL || in tmio_mmc_host_probe()
1193 !mmc_card_is_removable(mmc)); in tmio_mmc_host_probe()
1228 ret = mmc_add_host(mmc); in tmio_mmc_host_probe()
1247 struct mmc_host *mmc = host->mmc; in tmio_mmc_host_remove() local
1256 mmc_remove_host(mmc); in tmio_mmc_host_remove()