Lines Matching full:host
3 * linux/drivers/mmc/core/host.c
9 * MMC host class device management
23 #include <linux/mmc/host.h>
29 #include "host.h"
41 struct mmc_host *host = cls_dev_to_mmc_host(dev); in mmc_host_class_prepare() local
47 if (!host->bus_ops) in mmc_host_class_prepare()
51 if (host->bus_ops->pre_suspend) in mmc_host_class_prepare()
52 return host->bus_ops->pre_suspend(host); in mmc_host_class_prepare()
59 struct mmc_host *host = cls_dev_to_mmc_host(dev); in mmc_host_class_complete() local
61 _mmc_detect_change(host, 0, false); in mmc_host_class_complete()
76 struct mmc_host *host = cls_dev_to_mmc_host(dev); in mmc_host_classdev_release() local
77 wakeup_source_unregister(host->ws); in mmc_host_classdev_release()
78 if (of_alias_get_id(host->parent->of_node, "mmc") < 0) in mmc_host_classdev_release()
79 ida_simple_remove(&mmc_host_ida, host->index); in mmc_host_classdev_release()
80 kfree(host); in mmc_host_classdev_release()
101 * @host: host which should retune now
103 void mmc_retune_enable(struct mmc_host *host) in mmc_retune_enable() argument
105 host->can_retune = 1; in mmc_retune_enable()
106 if (host->retune_period) in mmc_retune_enable()
107 mod_timer(&host->retune_timer, in mmc_retune_enable()
108 jiffies + host->retune_period * HZ); in mmc_retune_enable()
115 void mmc_retune_pause(struct mmc_host *host) in mmc_retune_pause() argument
117 if (!host->retune_paused) { in mmc_retune_pause()
118 host->retune_paused = 1; in mmc_retune_pause()
119 mmc_retune_needed(host); in mmc_retune_pause()
120 mmc_retune_hold(host); in mmc_retune_pause()
125 void mmc_retune_unpause(struct mmc_host *host) in mmc_retune_unpause() argument
127 if (host->retune_paused) { in mmc_retune_unpause()
128 host->retune_paused = 0; in mmc_retune_unpause()
129 mmc_retune_release(host); in mmc_retune_unpause()
136 * @host: host which should not retune anymore
140 void mmc_retune_disable(struct mmc_host *host) in mmc_retune_disable() argument
142 mmc_retune_unpause(host); in mmc_retune_disable()
143 host->can_retune = 0; in mmc_retune_disable()
144 del_timer_sync(&host->retune_timer); in mmc_retune_disable()
145 mmc_retune_clear(host); in mmc_retune_disable()
148 void mmc_retune_timer_stop(struct mmc_host *host) in mmc_retune_timer_stop() argument
150 del_timer_sync(&host->retune_timer); in mmc_retune_timer_stop()
154 void mmc_retune_hold(struct mmc_host *host) in mmc_retune_hold() argument
156 if (!host->hold_retune) in mmc_retune_hold()
157 host->retune_now = 1; in mmc_retune_hold()
158 host->hold_retune += 1; in mmc_retune_hold()
161 void mmc_retune_release(struct mmc_host *host) in mmc_retune_release() argument
163 if (host->hold_retune) in mmc_retune_release()
164 host->hold_retune -= 1; in mmc_retune_release()
170 int mmc_retune(struct mmc_host *host) in mmc_retune() argument
175 if (host->retune_now) in mmc_retune()
176 host->retune_now = 0; in mmc_retune()
180 if (!host->need_retune || host->doing_retune || !host->card) in mmc_retune()
183 host->need_retune = 0; in mmc_retune()
185 host->doing_retune = 1; in mmc_retune()
187 if (host->ios.timing == MMC_TIMING_MMC_HS400) { in mmc_retune()
188 err = mmc_hs400_to_hs200(host->card); in mmc_retune()
195 err = mmc_execute_tuning(host->card); in mmc_retune()
200 err = mmc_hs200_to_hs400(host->card); in mmc_retune()
202 host->doing_retune = 0; in mmc_retune()
209 struct mmc_host *host = from_timer(host, t, retune_timer); in mmc_retune_timer() local
211 mmc_retune_needed(host); in mmc_retune_timer()
229 mmc_of_parse_clk_phase(struct mmc_host *host, struct mmc_clk_phase_map *map) in mmc_of_parse_clk_phase() argument
231 struct device *dev = host->parent; in mmc_of_parse_clk_phase()
259 * mmc_of_parse() - parse host's device properties
260 * @host: host whose properties should be parsed.
263 * used to to instantiate and configure this host instance or not, we
264 * parse the properties and set respective generic mmc-host flags and
267 int mmc_of_parse(struct mmc_host *host) in mmc_of_parse() argument
269 struct device *dev = host->parent; in mmc_of_parse()
278 dev_dbg(host->parent, in mmc_of_parse()
285 host->caps |= MMC_CAP_8_BIT_DATA; in mmc_of_parse()
288 host->caps |= MMC_CAP_4_BIT_DATA; in mmc_of_parse()
293 dev_err(host->parent, in mmc_of_parse()
299 device_property_read_u32(dev, "max-frequency", &host->f_max); in mmc_of_parse()
316 host->caps |= MMC_CAP_NONREMOVABLE; in mmc_of_parse()
319 host->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; in mmc_of_parse()
326 host->caps |= MMC_CAP_NEEDS_POLL; in mmc_of_parse()
328 ret = mmc_gpiod_request_cd(host, "cd", 0, false, in mmc_of_parse()
331 dev_info(host->parent, "Got CD GPIO\n"); in mmc_of_parse()
339 host->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; in mmc_of_parse()
341 ret = mmc_gpiod_request_ro(host, "wp", 0, 0); in mmc_of_parse()
343 dev_info(host->parent, "Got WP GPIO\n"); in mmc_of_parse()
348 host->caps2 |= MMC_CAP2_NO_WRITE_PROTECT; in mmc_of_parse()
351 host->caps |= MMC_CAP_SD_HIGHSPEED; in mmc_of_parse()
353 host->caps |= MMC_CAP_MMC_HIGHSPEED; in mmc_of_parse()
355 host->caps |= MMC_CAP_UHS_SDR12; in mmc_of_parse()
357 host->caps |= MMC_CAP_UHS_SDR25; in mmc_of_parse()
359 host->caps |= MMC_CAP_UHS_SDR50; in mmc_of_parse()
361 host->caps |= MMC_CAP_UHS_SDR104; in mmc_of_parse()
363 host->caps |= MMC_CAP_UHS_DDR50; in mmc_of_parse()
365 host->caps |= MMC_CAP_POWER_OFF_CARD; in mmc_of_parse()
367 host->caps |= MMC_CAP_HW_RESET; in mmc_of_parse()
369 host->caps |= MMC_CAP_SDIO_IRQ; in mmc_of_parse()
371 host->caps2 |= MMC_CAP2_FULL_PWR_CYCLE; in mmc_of_parse()
373 host->caps2 |= MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND; in mmc_of_parse()
375 host->pm_caps |= MMC_PM_KEEP_POWER; in mmc_of_parse()
378 host->pm_caps |= MMC_PM_WAKE_SDIO_IRQ; in mmc_of_parse()
380 host->caps |= MMC_CAP_3_3V_DDR; in mmc_of_parse()
382 host->caps |= MMC_CAP_1_8V_DDR; in mmc_of_parse()
384 host->caps |= MMC_CAP_1_2V_DDR; in mmc_of_parse()
386 host->caps2 |= MMC_CAP2_HS200_1_8V_SDR; in mmc_of_parse()
388 host->caps2 |= MMC_CAP2_HS200_1_2V_SDR; in mmc_of_parse()
390 host->caps2 |= MMC_CAP2_HS400_1_8V | MMC_CAP2_HS200_1_8V_SDR; in mmc_of_parse()
392 host->caps2 |= MMC_CAP2_HS400_1_2V | MMC_CAP2_HS200_1_2V_SDR; in mmc_of_parse()
394 host->caps2 |= MMC_CAP2_HS400_ES; in mmc_of_parse()
396 host->caps2 |= MMC_CAP2_NO_SDIO; in mmc_of_parse()
398 host->caps2 |= MMC_CAP2_NO_SD; in mmc_of_parse()
400 host->caps2 |= MMC_CAP2_NO_MMC; in mmc_of_parse()
402 host->caps2 &= ~(MMC_CAP2_HS400_1_8V | MMC_CAP2_HS400_1_2V | in mmc_of_parse()
407 if (host->caps & MMC_CAP_NONREMOVABLE) in mmc_of_parse()
408 host->fixed_drv_type = drv_type; in mmc_of_parse()
410 dev_err(host->parent, in mmc_of_parse()
414 host->dsr_req = !device_property_read_u32(dev, "dsr", &host->dsr); in mmc_of_parse()
415 if (host->dsr_req && (host->dsr & ~0xffff)) { in mmc_of_parse()
416 dev_err(host->parent, in mmc_of_parse()
418 host->dsr); in mmc_of_parse()
419 host->dsr_req = 0; in mmc_of_parse()
423 &host->ios.power_delay_ms); in mmc_of_parse()
425 return mmc_pwrseq_alloc(host); in mmc_of_parse()
432 * @host: host whose properties should be parsed.
439 int mmc_of_parse_voltage(struct mmc_host *host, u32 *mask) in mmc_of_parse_voltage() argument
442 struct device *dev = host->parent; in mmc_of_parse_voltage()
507 * mmc_alloc_host - initialise the per-host structure.
509 * @dev: pointer to host device model structure
511 * Initialise the per-host structure.
516 struct mmc_host *host; in mmc_alloc_host() local
519 host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL); in mmc_alloc_host()
520 if (!host) in mmc_alloc_host()
524 host->rescan_disable = 1; in mmc_alloc_host()
535 kfree(host); in mmc_alloc_host()
540 host->index = index; in mmc_alloc_host()
542 dev_set_name(&host->class_dev, "mmc%d", host->index); in mmc_alloc_host()
543 host->ws = wakeup_source_register(NULL, dev_name(&host->class_dev)); in mmc_alloc_host()
545 host->parent = dev; in mmc_alloc_host()
546 host->class_dev.parent = dev; in mmc_alloc_host()
547 host->class_dev.class = &mmc_host_class; in mmc_alloc_host()
548 device_initialize(&host->class_dev); in mmc_alloc_host()
549 device_enable_async_suspend(&host->class_dev); in mmc_alloc_host()
551 if (mmc_gpio_alloc(host)) { in mmc_alloc_host()
552 put_device(&host->class_dev); in mmc_alloc_host()
556 spin_lock_init(&host->lock); in mmc_alloc_host()
557 init_waitqueue_head(&host->wq); in mmc_alloc_host()
558 INIT_DELAYED_WORK(&host->detect, mmc_rescan); in mmc_alloc_host()
559 INIT_DELAYED_WORK(&host->sdio_irq_work, sdio_irq_work); in mmc_alloc_host()
560 timer_setup(&host->retune_timer, mmc_retune_timer, 0); in mmc_alloc_host()
566 host->max_segs = 1; in mmc_alloc_host()
567 host->max_seg_size = PAGE_SIZE; in mmc_alloc_host()
569 host->max_req_size = PAGE_SIZE; in mmc_alloc_host()
570 host->max_blk_size = 512; in mmc_alloc_host()
571 host->max_blk_count = PAGE_SIZE / 512; in mmc_alloc_host()
573 host->fixed_drv_type = -EINVAL; in mmc_alloc_host()
574 host->ios.power_delay_ms = 10; in mmc_alloc_host()
575 host->ios.power_mode = MMC_POWER_UNDEFINED; in mmc_alloc_host()
577 return host; in mmc_alloc_host()
583 * mmc_add_host - initialise host hardware
584 * @host: mmc host
586 * Register the host with the driver model. The host must be
590 int mmc_add_host(struct mmc_host *host) in mmc_add_host() argument
594 WARN_ON((host->caps & MMC_CAP_SDIO_IRQ) && in mmc_add_host()
595 !host->ops->enable_sdio_irq); in mmc_add_host()
597 err = device_add(&host->class_dev); in mmc_add_host()
601 led_trigger_register_simple(dev_name(&host->class_dev), &host->led); in mmc_add_host()
604 mmc_add_host_debugfs(host); in mmc_add_host()
607 mmc_start_host(host); in mmc_add_host()
614 * mmc_remove_host - remove host hardware
615 * @host: mmc host
617 * Unregister and remove all cards associated with this host,
621 void mmc_remove_host(struct mmc_host *host) in mmc_remove_host() argument
623 mmc_stop_host(host); in mmc_remove_host()
626 mmc_remove_host_debugfs(host); in mmc_remove_host()
629 device_del(&host->class_dev); in mmc_remove_host()
631 led_trigger_unregister_simple(host->led); in mmc_remove_host()
637 * mmc_free_host - free the host structure
638 * @host: mmc host
640 * Free the host once all references to it have been dropped.
642 void mmc_free_host(struct mmc_host *host) in mmc_free_host() argument
644 mmc_pwrseq_free(host); in mmc_free_host()
645 put_device(&host->class_dev); in mmc_free_host()