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()
85 struct mmc_host *host = cls_dev_to_mmc_host(dev); in mmc_host_classdev_shutdown() local
87 __mmc_stop_host(host); in mmc_host_classdev_shutdown()
110 * @host: host which should retune now
112 void mmc_retune_enable(struct mmc_host *host) in mmc_retune_enable() argument
114 host->can_retune = 1; in mmc_retune_enable()
115 if (host->retune_period) in mmc_retune_enable()
116 mod_timer(&host->retune_timer, in mmc_retune_enable()
117 jiffies + host->retune_period * HZ); in mmc_retune_enable()
124 void mmc_retune_pause(struct mmc_host *host) in mmc_retune_pause() argument
126 if (!host->retune_paused) { in mmc_retune_pause()
127 host->retune_paused = 1; in mmc_retune_pause()
128 mmc_retune_needed(host); in mmc_retune_pause()
129 mmc_retune_hold(host); in mmc_retune_pause()
134 void mmc_retune_unpause(struct mmc_host *host) in mmc_retune_unpause() argument
136 if (host->retune_paused) { in mmc_retune_unpause()
137 host->retune_paused = 0; in mmc_retune_unpause()
138 mmc_retune_release(host); in mmc_retune_unpause()
145 * @host: host which should not retune anymore
149 void mmc_retune_disable(struct mmc_host *host) in mmc_retune_disable() argument
151 mmc_retune_unpause(host); in mmc_retune_disable()
152 host->can_retune = 0; in mmc_retune_disable()
153 del_timer_sync(&host->retune_timer); in mmc_retune_disable()
154 mmc_retune_clear(host); in mmc_retune_disable()
157 void mmc_retune_timer_stop(struct mmc_host *host) in mmc_retune_timer_stop() argument
159 del_timer_sync(&host->retune_timer); in mmc_retune_timer_stop()
163 void mmc_retune_hold(struct mmc_host *host) in mmc_retune_hold() argument
165 if (!host->hold_retune) in mmc_retune_hold()
166 host->retune_now = 1; in mmc_retune_hold()
167 host->hold_retune += 1; in mmc_retune_hold()
170 void mmc_retune_release(struct mmc_host *host) in mmc_retune_release() argument
172 if (host->hold_retune) in mmc_retune_release()
173 host->hold_retune -= 1; in mmc_retune_release()
179 int mmc_retune(struct mmc_host *host) in mmc_retune() argument
184 if (host->retune_now) in mmc_retune()
185 host->retune_now = 0; in mmc_retune()
189 if (!host->need_retune || host->doing_retune || !host->card) in mmc_retune()
192 host->need_retune = 0; in mmc_retune()
194 host->doing_retune = 1; in mmc_retune()
196 if (host->ios.timing == MMC_TIMING_MMC_HS400) { in mmc_retune()
197 err = mmc_hs400_to_hs200(host->card); in mmc_retune()
204 err = mmc_execute_tuning(host->card); in mmc_retune()
209 err = mmc_hs200_to_hs400(host->card); in mmc_retune()
211 host->doing_retune = 0; in mmc_retune()
218 struct mmc_host *host = from_timer(host, t, retune_timer); in mmc_retune_timer() local
220 mmc_retune_needed(host); in mmc_retune_timer()
238 mmc_of_parse_clk_phase(struct mmc_host *host, struct mmc_clk_phase_map *map) in mmc_of_parse_clk_phase() argument
240 struct device *dev = host->parent; in mmc_of_parse_clk_phase()
268 * mmc_of_parse() - parse host's device properties
269 * @host: host whose properties should be parsed.
272 * used to to instantiate and configure this host instance or not, we
273 * parse the properties and set respective generic mmc-host flags and
276 int mmc_of_parse(struct mmc_host *host) in mmc_of_parse() argument
278 struct device *dev = host->parent; in mmc_of_parse()
287 dev_dbg(host->parent, in mmc_of_parse()
294 host->caps |= MMC_CAP_8_BIT_DATA; in mmc_of_parse()
297 host->caps |= MMC_CAP_4_BIT_DATA; in mmc_of_parse()
302 dev_err(host->parent, in mmc_of_parse()
308 device_property_read_u32(dev, "max-frequency", &host->f_max); in mmc_of_parse()
325 host->caps |= MMC_CAP_NONREMOVABLE; in mmc_of_parse()
328 host->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; in mmc_of_parse()
335 host->caps |= MMC_CAP_NEEDS_POLL; in mmc_of_parse()
337 ret = mmc_gpiod_request_cd(host, "cd", 0, false, in mmc_of_parse()
340 dev_info(host->parent, "Got CD GPIO\n"); in mmc_of_parse()
348 host->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; in mmc_of_parse()
350 ret = mmc_gpiod_request_ro(host, "wp", 0, 0); in mmc_of_parse()
352 dev_info(host->parent, "Got WP GPIO\n"); in mmc_of_parse()
357 host->caps2 |= MMC_CAP2_NO_WRITE_PROTECT; in mmc_of_parse()
360 host->caps |= MMC_CAP_SD_HIGHSPEED; in mmc_of_parse()
362 host->caps |= MMC_CAP_MMC_HIGHSPEED; in mmc_of_parse()
364 host->caps |= MMC_CAP_UHS_SDR12; in mmc_of_parse()
366 host->caps |= MMC_CAP_UHS_SDR25; in mmc_of_parse()
368 host->caps |= MMC_CAP_UHS_SDR50; in mmc_of_parse()
370 host->caps |= MMC_CAP_UHS_SDR104; in mmc_of_parse()
372 host->caps |= MMC_CAP_UHS_DDR50; in mmc_of_parse()
374 host->caps |= MMC_CAP_POWER_OFF_CARD; in mmc_of_parse()
376 host->caps |= MMC_CAP_HW_RESET; in mmc_of_parse()
378 host->caps |= MMC_CAP_SDIO_IRQ; in mmc_of_parse()
380 host->caps2 |= MMC_CAP2_FULL_PWR_CYCLE; in mmc_of_parse()
382 host->caps2 |= MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND; in mmc_of_parse()
384 host->pm_caps |= MMC_PM_KEEP_POWER; in mmc_of_parse()
387 host->pm_caps |= MMC_PM_WAKE_SDIO_IRQ; in mmc_of_parse()
389 host->caps |= MMC_CAP_3_3V_DDR; in mmc_of_parse()
391 host->caps |= MMC_CAP_1_8V_DDR; in mmc_of_parse()
393 host->caps |= MMC_CAP_1_2V_DDR; in mmc_of_parse()
395 host->caps2 |= MMC_CAP2_HS200_1_8V_SDR; in mmc_of_parse()
397 host->caps2 |= MMC_CAP2_HS200_1_2V_SDR; in mmc_of_parse()
399 host->caps2 |= MMC_CAP2_HS400_1_8V | MMC_CAP2_HS200_1_8V_SDR; in mmc_of_parse()
401 host->caps2 |= MMC_CAP2_HS400_1_2V | MMC_CAP2_HS200_1_2V_SDR; in mmc_of_parse()
403 host->caps2 |= MMC_CAP2_HS400_ES; in mmc_of_parse()
405 host->caps2 |= MMC_CAP2_NO_SDIO; in mmc_of_parse()
407 host->caps2 |= MMC_CAP2_NO_SD; in mmc_of_parse()
409 host->caps2 |= MMC_CAP2_NO_MMC; in mmc_of_parse()
411 host->caps2 &= ~(MMC_CAP2_HS400_1_8V | MMC_CAP2_HS400_1_2V | in mmc_of_parse()
416 if (host->caps & MMC_CAP_NONREMOVABLE) in mmc_of_parse()
417 host->fixed_drv_type = drv_type; in mmc_of_parse()
419 dev_err(host->parent, in mmc_of_parse()
423 host->dsr_req = !device_property_read_u32(dev, "dsr", &host->dsr); in mmc_of_parse()
424 if (host->dsr_req && (host->dsr & ~0xffff)) { in mmc_of_parse()
425 dev_err(host->parent, in mmc_of_parse()
427 host->dsr); in mmc_of_parse()
428 host->dsr_req = 0; in mmc_of_parse()
432 &host->ios.power_delay_ms); in mmc_of_parse()
434 return mmc_pwrseq_alloc(host); in mmc_of_parse()
441 * @host: host whose properties should be parsed.
448 int mmc_of_parse_voltage(struct mmc_host *host, u32 *mask) in mmc_of_parse_voltage() argument
451 struct device *dev = host->parent; in mmc_of_parse_voltage()
516 * mmc_alloc_host - initialise the per-host structure.
518 * @dev: pointer to host device model structure
520 * Initialise the per-host structure.
525 struct mmc_host *host; in mmc_alloc_host() local
528 host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL); in mmc_alloc_host()
529 if (!host) in mmc_alloc_host()
533 host->rescan_disable = 1; in mmc_alloc_host()
544 kfree(host); in mmc_alloc_host()
549 host->index = index; in mmc_alloc_host()
551 dev_set_name(&host->class_dev, "mmc%d", host->index); in mmc_alloc_host()
552 host->ws = wakeup_source_register(NULL, dev_name(&host->class_dev)); in mmc_alloc_host()
554 host->parent = dev; in mmc_alloc_host()
555 host->class_dev.parent = dev; in mmc_alloc_host()
556 host->class_dev.class = &mmc_host_class; in mmc_alloc_host()
557 device_initialize(&host->class_dev); in mmc_alloc_host()
558 device_enable_async_suspend(&host->class_dev); in mmc_alloc_host()
560 if (mmc_gpio_alloc(host)) { in mmc_alloc_host()
561 put_device(&host->class_dev); in mmc_alloc_host()
565 spin_lock_init(&host->lock); in mmc_alloc_host()
566 init_waitqueue_head(&host->wq); in mmc_alloc_host()
567 INIT_DELAYED_WORK(&host->detect, mmc_rescan); in mmc_alloc_host()
568 INIT_WORK(&host->sdio_irq_work, sdio_irq_work); in mmc_alloc_host()
569 timer_setup(&host->retune_timer, mmc_retune_timer, 0); in mmc_alloc_host()
575 host->max_segs = 1; in mmc_alloc_host()
576 host->max_seg_size = PAGE_SIZE; in mmc_alloc_host()
578 host->max_req_size = PAGE_SIZE; in mmc_alloc_host()
579 host->max_blk_size = 512; in mmc_alloc_host()
580 host->max_blk_count = PAGE_SIZE / 512; in mmc_alloc_host()
582 host->fixed_drv_type = -EINVAL; in mmc_alloc_host()
583 host->ios.power_delay_ms = 10; in mmc_alloc_host()
584 host->ios.power_mode = MMC_POWER_UNDEFINED; in mmc_alloc_host()
586 return host; in mmc_alloc_host()
591 static int mmc_validate_host_caps(struct mmc_host *host) in mmc_validate_host_caps() argument
593 struct device *dev = host->parent; in mmc_validate_host_caps()
594 u32 caps = host->caps, caps2 = host->caps2; in mmc_validate_host_caps()
596 if (caps & MMC_CAP_SDIO_IRQ && !host->ops->enable_sdio_irq) { in mmc_validate_host_caps()
604 host->caps2 = caps2 & ~MMC_CAP2_HS400_ES & ~MMC_CAP2_HS400; in mmc_validate_host_caps()
611 * mmc_add_host - initialise host hardware
612 * @host: mmc host
614 * Register the host with the driver model. The host must be
618 int mmc_add_host(struct mmc_host *host) in mmc_add_host() argument
622 err = mmc_validate_host_caps(host); in mmc_add_host()
626 err = device_add(&host->class_dev); in mmc_add_host()
630 led_trigger_register_simple(dev_name(&host->class_dev), &host->led); in mmc_add_host()
633 mmc_add_host_debugfs(host); in mmc_add_host()
636 mmc_start_host(host); in mmc_add_host()
643 * mmc_remove_host - remove host hardware
644 * @host: mmc host
646 * Unregister and remove all cards associated with this host,
650 void mmc_remove_host(struct mmc_host *host) in mmc_remove_host() argument
652 mmc_stop_host(host); in mmc_remove_host()
655 mmc_remove_host_debugfs(host); in mmc_remove_host()
658 device_del(&host->class_dev); in mmc_remove_host()
660 led_trigger_unregister_simple(host->led); in mmc_remove_host()
666 * mmc_free_host - free the host structure
667 * @host: mmc host
669 * Free the host once all references to it have been dropped.
671 void mmc_free_host(struct mmc_host *host) in mmc_free_host() argument
673 mmc_pwrseq_free(host); in mmc_free_host()
674 put_device(&host->class_dev); in mmc_free_host()