Lines Matching full:host

3  *  linux/drivers/mmc/core/host.c
9 * MMC host class device management
23 #include <linux/mmc/host.h>
28 #include "host.h"
39 struct mmc_host *host = cls_dev_to_mmc_host(dev); in mmc_host_classdev_release() local
40 wakeup_source_unregister(host->ws); in mmc_host_classdev_release()
41 ida_simple_remove(&mmc_host_ida, host->index); in mmc_host_classdev_release()
42 kfree(host); in mmc_host_classdev_release()
60 void mmc_retune_enable(struct mmc_host *host) in mmc_retune_enable() argument
62 host->can_retune = 1; in mmc_retune_enable()
63 if (host->retune_period) in mmc_retune_enable()
64 mod_timer(&host->retune_timer, in mmc_retune_enable()
65 jiffies + host->retune_period * HZ); in mmc_retune_enable()
72 void mmc_retune_pause(struct mmc_host *host) in mmc_retune_pause() argument
74 if (!host->retune_paused) { in mmc_retune_pause()
75 host->retune_paused = 1; in mmc_retune_pause()
76 mmc_retune_needed(host); in mmc_retune_pause()
77 mmc_retune_hold(host); in mmc_retune_pause()
82 void mmc_retune_unpause(struct mmc_host *host) in mmc_retune_unpause() argument
84 if (host->retune_paused) { in mmc_retune_unpause()
85 host->retune_paused = 0; in mmc_retune_unpause()
86 mmc_retune_release(host); in mmc_retune_unpause()
91 void mmc_retune_disable(struct mmc_host *host) in mmc_retune_disable() argument
93 mmc_retune_unpause(host); in mmc_retune_disable()
94 host->can_retune = 0; in mmc_retune_disable()
95 del_timer_sync(&host->retune_timer); in mmc_retune_disable()
96 host->retune_now = 0; in mmc_retune_disable()
97 host->need_retune = 0; in mmc_retune_disable()
100 void mmc_retune_timer_stop(struct mmc_host *host) in mmc_retune_timer_stop() argument
102 del_timer_sync(&host->retune_timer); in mmc_retune_timer_stop()
106 void mmc_retune_hold(struct mmc_host *host) in mmc_retune_hold() argument
108 if (!host->hold_retune) in mmc_retune_hold()
109 host->retune_now = 1; in mmc_retune_hold()
110 host->hold_retune += 1; in mmc_retune_hold()
113 void mmc_retune_release(struct mmc_host *host) in mmc_retune_release() argument
115 if (host->hold_retune) in mmc_retune_release()
116 host->hold_retune -= 1; in mmc_retune_release()
122 int mmc_retune(struct mmc_host *host) in mmc_retune() argument
127 if (host->retune_now) in mmc_retune()
128 host->retune_now = 0; in mmc_retune()
132 if (!host->need_retune || host->doing_retune || !host->card) in mmc_retune()
135 host->need_retune = 0; in mmc_retune()
137 host->doing_retune = 1; in mmc_retune()
139 if (host->ios.timing == MMC_TIMING_MMC_HS400) { in mmc_retune()
140 err = mmc_hs400_to_hs200(host->card); in mmc_retune()
147 err = mmc_execute_tuning(host->card); in mmc_retune()
152 err = mmc_hs200_to_hs400(host->card); in mmc_retune()
154 host->doing_retune = 0; in mmc_retune()
161 struct mmc_host *host = from_timer(host, t, retune_timer); in mmc_retune_timer() local
163 mmc_retune_needed(host); in mmc_retune_timer()
167 * mmc_of_parse() - parse host's device-tree node
168 * @host: host whose node should be parsed.
171 * used to to instantiate and configure this host instance or not, we
172 * parse the properties and set respective generic mmc-host flags and
175 int mmc_of_parse(struct mmc_host *host) in mmc_of_parse() argument
177 struct device *dev = host->parent; in mmc_of_parse()
186 dev_dbg(host->parent, in mmc_of_parse()
193 host->caps |= MMC_CAP_8_BIT_DATA; in mmc_of_parse()
196 host->caps |= MMC_CAP_4_BIT_DATA; in mmc_of_parse()
201 dev_err(host->parent, in mmc_of_parse()
207 device_property_read_u32(dev, "max-frequency", &host->f_max); in mmc_of_parse()
224 host->caps |= MMC_CAP_NONREMOVABLE; in mmc_of_parse()
227 host->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; in mmc_of_parse()
234 host->caps |= MMC_CAP_NEEDS_POLL; in mmc_of_parse()
236 ret = mmc_gpiod_request_cd(host, "cd", 0, false, in mmc_of_parse()
239 dev_info(host->parent, "Got CD GPIO\n"); in mmc_of_parse()
247 host->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; in mmc_of_parse()
249 ret = mmc_gpiod_request_ro(host, "wp", 0, 0); in mmc_of_parse()
251 dev_info(host->parent, "Got WP GPIO\n"); in mmc_of_parse()
256 host->caps2 |= MMC_CAP2_NO_WRITE_PROTECT; in mmc_of_parse()
259 host->caps |= MMC_CAP_SD_HIGHSPEED; in mmc_of_parse()
261 host->caps |= MMC_CAP_MMC_HIGHSPEED; in mmc_of_parse()
263 host->caps |= MMC_CAP_UHS_SDR12; in mmc_of_parse()
265 host->caps |= MMC_CAP_UHS_SDR25; in mmc_of_parse()
267 host->caps |= MMC_CAP_UHS_SDR50; in mmc_of_parse()
269 host->caps |= MMC_CAP_UHS_SDR104; in mmc_of_parse()
271 host->caps |= MMC_CAP_UHS_DDR50; in mmc_of_parse()
273 host->caps |= MMC_CAP_POWER_OFF_CARD; in mmc_of_parse()
275 host->caps |= MMC_CAP_HW_RESET; in mmc_of_parse()
277 host->caps |= MMC_CAP_SDIO_IRQ; in mmc_of_parse()
279 host->caps2 |= MMC_CAP2_FULL_PWR_CYCLE; in mmc_of_parse()
281 host->caps2 |= MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND; in mmc_of_parse()
283 host->pm_caps |= MMC_PM_KEEP_POWER; in mmc_of_parse()
286 host->pm_caps |= MMC_PM_WAKE_SDIO_IRQ; in mmc_of_parse()
288 host->caps |= MMC_CAP_3_3V_DDR; in mmc_of_parse()
290 host->caps |= MMC_CAP_1_8V_DDR; in mmc_of_parse()
292 host->caps |= MMC_CAP_1_2V_DDR; in mmc_of_parse()
294 host->caps2 |= MMC_CAP2_HS200_1_8V_SDR; in mmc_of_parse()
296 host->caps2 |= MMC_CAP2_HS200_1_2V_SDR; in mmc_of_parse()
298 host->caps2 |= MMC_CAP2_HS400_1_8V | MMC_CAP2_HS200_1_8V_SDR; in mmc_of_parse()
300 host->caps2 |= MMC_CAP2_HS400_1_2V | MMC_CAP2_HS200_1_2V_SDR; in mmc_of_parse()
302 host->caps2 |= MMC_CAP2_HS400_ES; in mmc_of_parse()
304 host->caps2 |= MMC_CAP2_NO_SDIO; in mmc_of_parse()
306 host->caps2 |= MMC_CAP2_NO_SD; in mmc_of_parse()
308 host->caps2 |= MMC_CAP2_NO_MMC; in mmc_of_parse()
312 if (host->caps & MMC_CAP_NONREMOVABLE) in mmc_of_parse()
313 host->fixed_drv_type = drv_type; in mmc_of_parse()
315 dev_err(host->parent, in mmc_of_parse()
319 host->dsr_req = !device_property_read_u32(dev, "dsr", &host->dsr); in mmc_of_parse()
320 if (host->dsr_req && (host->dsr & ~0xffff)) { in mmc_of_parse()
321 dev_err(host->parent, in mmc_of_parse()
323 host->dsr); in mmc_of_parse()
324 host->dsr_req = 0; in mmc_of_parse()
328 &host->ios.power_delay_ms); in mmc_of_parse()
330 return mmc_pwrseq_alloc(host); in mmc_of_parse()
394 * mmc_alloc_host - initialise the per-host structure.
396 * @dev: pointer to host device model structure
398 * Initialise the per-host structure.
403 struct mmc_host *host; in mmc_alloc_host() local
406 host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL); in mmc_alloc_host()
407 if (!host) in mmc_alloc_host()
411 host->rescan_disable = 1; in mmc_alloc_host()
424 kfree(host); in mmc_alloc_host()
428 host->index = err; in mmc_alloc_host()
430 dev_set_name(&host->class_dev, "mmc%d", host->index); in mmc_alloc_host()
431 host->ws = wakeup_source_register(NULL, dev_name(&host->class_dev)); in mmc_alloc_host()
433 host->parent = dev; in mmc_alloc_host()
434 host->class_dev.parent = dev; in mmc_alloc_host()
435 host->class_dev.class = &mmc_host_class; in mmc_alloc_host()
436 device_initialize(&host->class_dev); in mmc_alloc_host()
437 device_enable_async_suspend(&host->class_dev); in mmc_alloc_host()
439 if (mmc_gpio_alloc(host)) { in mmc_alloc_host()
440 put_device(&host->class_dev); in mmc_alloc_host()
444 spin_lock_init(&host->lock); in mmc_alloc_host()
445 init_waitqueue_head(&host->wq); in mmc_alloc_host()
446 INIT_DELAYED_WORK(&host->detect, mmc_rescan); in mmc_alloc_host()
447 INIT_DELAYED_WORK(&host->sdio_irq_work, sdio_irq_work); in mmc_alloc_host()
448 timer_setup(&host->retune_timer, mmc_retune_timer, 0); in mmc_alloc_host()
454 host->max_segs = 1; in mmc_alloc_host()
455 host->max_seg_size = PAGE_SIZE; in mmc_alloc_host()
457 host->max_req_size = PAGE_SIZE; in mmc_alloc_host()
458 host->max_blk_size = 512; in mmc_alloc_host()
459 host->max_blk_count = PAGE_SIZE / 512; in mmc_alloc_host()
461 host->fixed_drv_type = -EINVAL; in mmc_alloc_host()
462 host->ios.power_delay_ms = 10; in mmc_alloc_host()
463 host->ios.power_mode = MMC_POWER_UNDEFINED; in mmc_alloc_host()
465 return host; in mmc_alloc_host()
471 * mmc_add_host - initialise host hardware
472 * @host: mmc host
474 * Register the host with the driver model. The host must be
478 int mmc_add_host(struct mmc_host *host) in mmc_add_host() argument
482 WARN_ON((host->caps & MMC_CAP_SDIO_IRQ) && in mmc_add_host()
483 !host->ops->enable_sdio_irq); in mmc_add_host()
485 err = device_add(&host->class_dev); in mmc_add_host()
489 led_trigger_register_simple(dev_name(&host->class_dev), &host->led); in mmc_add_host()
492 mmc_add_host_debugfs(host); in mmc_add_host()
495 mmc_start_host(host); in mmc_add_host()
496 mmc_register_pm_notifier(host); in mmc_add_host()
504 * mmc_remove_host - remove host hardware
505 * @host: mmc host
507 * Unregister and remove all cards associated with this host,
511 void mmc_remove_host(struct mmc_host *host) in mmc_remove_host() argument
513 mmc_unregister_pm_notifier(host); in mmc_remove_host()
514 mmc_stop_host(host); in mmc_remove_host()
517 mmc_remove_host_debugfs(host); in mmc_remove_host()
520 device_del(&host->class_dev); in mmc_remove_host()
522 led_trigger_unregister_simple(host->led); in mmc_remove_host()
528 * mmc_free_host - free the host structure
529 * @host: mmc host
531 * Free the host once all references to it have been dropped.
533 void mmc_free_host(struct mmc_host *host) in mmc_free_host() argument
535 mmc_pwrseq_free(host); in mmc_free_host()
536 put_device(&host->class_dev); in mmc_free_host()