Lines Matching +full:host +full:- +full:wake
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/include/linux/mmc/host.h
5 * Host driver specific definitions.
12 #include <linux/fault-inject.h>
17 #include <linux/dma-direction.h>
84 * It is optional for the host to implement pre_req and post_req in
91 void (*post_req)(struct mmc_host *host, struct mmc_request *req,
93 void (*pre_req)(struct mmc_host *host, struct mmc_request *req);
94 void (*request)(struct mmc_host *host, struct mmc_request *req);
95 /* Submit one request to host in atomic context. */
96 int (*request_atomic)(struct mmc_host *host,
108 * ios->clock might be 0. For some controllers, setting 0Hz
113 void (*set_ios)(struct mmc_host *host, struct mmc_ios *ios);
118 * 1 for a read-only card
119 * -ENOSYS when not supported (equal to NULL callback)
122 int (*get_ro)(struct mmc_host *host);
128 * -ENOSYS when not supported (equal to NULL callback)
131 int (*get_cd)(struct mmc_host *host);
133 void (*enable_sdio_irq)(struct mmc_host *host, int enable);
135 void (*ack_sdio_irq)(struct mmc_host *host);
138 void (*init_card)(struct mmc_host *host, struct mmc_card *card);
140 int (*start_signal_voltage_switch)(struct mmc_host *host, struct mmc_ios *ios);
143 int (*card_busy)(struct mmc_host *host);
146 int (*execute_tuning)(struct mmc_host *host, u32 opcode);
148 /* Prepare HS400 target operating frequency depending host driver */
149 int (*prepare_hs400_tuning)(struct mmc_host *host, struct mmc_ios *ios);
152 int (*hs400_prepare_ddr)(struct mmc_host *host);
155 void (*hs400_downgrade)(struct mmc_host *host);
158 void (*hs400_complete)(struct mmc_host *host);
160 /* Prepare enhanced strobe depending host driver */
161 void (*hs400_enhanced_strobe)(struct mmc_host *host,
167 void (*hw_reset)(struct mmc_host *host);
168 void (*card_event)(struct mmc_host *host);
180 int (*cqe_enable)(struct mmc_host *host, struct mmc_card *card);
181 /* Free resources, and make the CQE non-operational */
182 void (*cqe_disable)(struct mmc_host *host);
185 * effect of ->cqe_off().
187 int (*cqe_request)(struct mmc_host *host, struct mmc_request *mrq);
189 void (*cqe_post_req)(struct mmc_host *host, struct mmc_request *mrq);
191 * Prepare the CQE and host controller to accept non-CQ commands. There
192 * is no corresponding ->cqe_on(), instead ->cqe_request() is required
195 void (*cqe_off)(struct mmc_host *host);
200 int (*cqe_wait_for_idle)(struct mmc_host *host);
206 bool (*cqe_timeout)(struct mmc_host *host, struct mmc_request *mrq,
209 * Stop all CQE activity and prepare the CQE and host controller to
212 void (*cqe_recovery_start)(struct mmc_host *host);
216 * (data->error or cmd->error for DCMD). Requests that did not error
219 void (*cqe_recovery_finish)(struct mmc_host *host);
233 * struct mmc_slot - MMC slot functions
235 * @cd_irq: MMC/SD-card slot hotplug detection IRQ or -EINVAL
236 * @handler_priv: MMC/SD-card slot context
238 * Some MMC/SD host controllers implement slot-functions like card and
239 * write-protect detection natively. However, a large number of controllers
241 * such slot-function drivers.
250 * mmc_context_info - synchronization details for mmc context
251 * @is_done_rcv wake up reason was done request
252 * @is_new_req wake up reason was new request
285 u32 ocr_avail_sdio; /* SDIO-specific OCR */
286 u32 ocr_avail_sd; /* SD-specific OCR */
287 u32 ocr_avail_mmc; /* MMC-specific OCR */
296 #define MMC_VDD_165_195 0x00000080 /* VDD voltage 1.65 - 1.95 */
314 u32 caps; /* Host capabilities */
316 #define MMC_CAP_4_BIT_DATA (1 << 0) /* Can the host do 4 bit transfers */
317 #define MMC_CAP_MMC_HIGHSPEED (1 << 1) /* Can do MMC high-speed timing */
318 #define MMC_CAP_SD_HIGHSPEED (1 << 2) /* Can do SD high-speed timing */
321 #define MMC_CAP_NEEDS_POLL (1 << 5) /* Needs polling for card-detection */
322 #define MMC_CAP_8_BIT_DATA (1 << 6) /* Can the host do 8 bit transfers */
326 #define MMC_CAP_3_3V_DDR (1 << 11) /* Host supports eMMC DDR 3.3V */
327 #define MMC_CAP_1_8V_DDR (1 << 12) /* Host supports eMMC DDR 1.8V */
328 #define MMC_CAP_1_2V_DDR (1 << 13) /* Host supports eMMC DDR 1.2V */
333 #define MMC_CAP_UHS_SDR12 (1 << 16) /* Host supports UHS SDR12 mode */
334 #define MMC_CAP_UHS_SDR25 (1 << 17) /* Host supports UHS SDR25 mode */
335 #define MMC_CAP_UHS_SDR50 (1 << 18) /* Host supports UHS SDR50 mode */
336 #define MMC_CAP_UHS_SDR104 (1 << 19) /* Host supports UHS SDR104 mode */
337 #define MMC_CAP_UHS_DDR50 (1 << 20) /* Host supports UHS DDR50 mode */
343 #define MMC_CAP_DRIVER_TYPE_A (1 << 23) /* Host supports Driver Type A */
344 #define MMC_CAP_DRIVER_TYPE_C (1 << 24) /* Host supports Driver Type C */
345 #define MMC_CAP_DRIVER_TYPE_D (1 << 25) /* Host supports Driver Type D */
347 #define MMC_CAP_CD_WAKE (1 << 28) /* Enable card detect wake */
352 u32 caps2; /* More host capabilities */
361 #define MMC_CAP2_CD_ACTIVE_HIGH (1 << 10) /* Card-detect signal active high */
362 #define MMC_CAP2_RO_ACTIVE_HIGH (1 << 11) /* Write-protect signal active high */
371 …_WRITE_PROTECT (1 << 18) /* No physical write protect pin, assume that card is always read-write */
373 #define MMC_CAP2_HS400_ES (1 << 20) /* Host supports enhanced strobe */
378 #define MMC_CAP2_AVOID_3_3V (1 << 25) /* Host must negotiate down from 3.3V */
379 #define MMC_CAP2_MERGE_CAPABLE (1 << 26) /* Host can merge a segment over the segment size */
381 int fixed_drv_type; /* fixed driver type for non-removable media */
385 /* host specific block data */
401 unsigned int claimed:1; /* host exclusively claimed */
404 unsigned int can_retune:1; /* re-tuning can be used */
405 unsigned int doing_retune:1; /* re-tuning in progress */
406 unsigned int retune_now:1; /* do re-tuning at next req */
407 unsigned int retune_paused:1; /* re-tuning is temporarily disabled */
408 unsigned int use_blk_mq:1; /* use blk-mq */
415 int need_retune; /* re-tuning is needed */
416 int hold_retune; /* hold off re-tuning */
417 unsigned int retune_period; /* re-tuning period in secs */
418 struct timer_list retune_timer; /* for periodic re-tuning */
422 struct mmc_card *card; /* device attached to this host */
425 struct mmc_ctx *claimer; /* context that has host claimed */
474 /* Host Software Queue support */
486 int mmc_of_parse(struct mmc_host *host);
489 static inline void *mmc_priv(struct mmc_host *host) in mmc_priv() argument
491 return (void *)host->private; in mmc_priv()
499 #define mmc_host_is_spi(host) ((host)->caps & MMC_CAP_SPI) argument
501 #define mmc_dev(x) ((x)->parent)
502 #define mmc_classdev(x) (&(x)->class_dev)
503 #define mmc_hostname(x) (dev_name(&(x)->class_dev))
507 void mmc_command_done(struct mmc_host *host, struct mmc_request *mrq);
509 void mmc_cqe_request_done(struct mmc_host *host, struct mmc_request *mrq);
512 * May be called from host driver's system/runtime suspend/resume callbacks,
515 static inline bool sdio_irq_claimed(struct mmc_host *host) in sdio_irq_claimed() argument
517 return host->sdio_irqs > 0; in sdio_irq_claimed()
520 static inline void mmc_signal_sdio_irq(struct mmc_host *host) in mmc_signal_sdio_irq() argument
522 host->ops->enable_sdio_irq(host, 0); in mmc_signal_sdio_irq()
523 host->sdio_irq_pending = true; in mmc_signal_sdio_irq()
524 if (host->sdio_irq_thread) in mmc_signal_sdio_irq()
525 wake_up_process(host->sdio_irq_thread); in mmc_signal_sdio_irq()
528 void sdio_signal_irq(struct mmc_host *host);
546 return -EINVAL; in mmc_regulator_set_vqmmc()
552 static inline int mmc_card_is_removable(struct mmc_host *host) in mmc_card_is_removable() argument
554 return !(host->caps & MMC_CAP_NONREMOVABLE); in mmc_card_is_removable()
557 static inline int mmc_card_keep_power(struct mmc_host *host) in mmc_card_keep_power() argument
559 return host->pm_flags & MMC_PM_KEEP_POWER; in mmc_card_keep_power()
562 static inline int mmc_card_wake_sdio_irq(struct mmc_host *host) in mmc_card_wake_sdio_irq() argument
564 return host->pm_flags & MMC_PM_WAKE_SDIO_IRQ; in mmc_card_wake_sdio_irq()
570 return card->host->ios.timing == MMC_TIMING_SD_HS || in mmc_card_hs()
571 card->host->ios.timing == MMC_TIMING_MMC_HS; in mmc_card_hs()
577 return card->host->ios.timing >= MMC_TIMING_UHS_SDR12 && in mmc_card_uhs()
578 card->host->ios.timing <= MMC_TIMING_UHS_DDR50; in mmc_card_uhs()
581 void mmc_retune_timer_stop(struct mmc_host *host);
583 static inline void mmc_retune_needed(struct mmc_host *host) in mmc_retune_needed() argument
585 if (host->can_retune) in mmc_retune_needed()
586 host->need_retune = 1; in mmc_retune_needed()
589 static inline bool mmc_can_retune(struct mmc_host *host) in mmc_can_retune() argument
591 return host->can_retune == 1; in mmc_can_retune()
594 static inline bool mmc_doing_retune(struct mmc_host *host) in mmc_doing_retune() argument
596 return host->doing_retune == 1; in mmc_doing_retune()
599 static inline bool mmc_doing_tune(struct mmc_host *host) in mmc_doing_tune() argument
601 return host->doing_retune == 1 || host->doing_init_tune == 1; in mmc_doing_tune()
606 return data->flags & MMC_DATA_WRITE ? DMA_TO_DEVICE : DMA_FROM_DEVICE; in mmc_get_dma_dir()
609 int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
610 int mmc_abort_tuning(struct mmc_host *host, u32 opcode);