xref: /linux/drivers/mmc/core/host.h (revision ead49373d2916080509f51fc6a4ee8f9bc021b9b)
1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2b93931a6SPierre Ossman /*
3b93931a6SPierre Ossman  *  linux/drivers/mmc/core/host.h
4b93931a6SPierre Ossman  *
5b93931a6SPierre Ossman  *  Copyright (C) 2003 Russell King, All Rights Reserved.
6b93931a6SPierre Ossman  *  Copyright 2007 Pierre Ossman
7b93931a6SPierre Ossman  */
8b93931a6SPierre Ossman #ifndef _MMC_CORE_HOST_H
9b93931a6SPierre Ossman #define _MMC_CORE_HOST_H
10066185d6SUlf Hansson 
115857b29bSUlf Hansson #include <linux/mmc/host.h>
12b93931a6SPierre Ossman 
13b93931a6SPierre Ossman int mmc_register_host_class(void);
14b93931a6SPierre Ossman void mmc_unregister_host_class(void);
158ea926b2SAdrian Hunter 
16dfa13ebbSAdrian Hunter void mmc_retune_enable(struct mmc_host *host);
17dfa13ebbSAdrian Hunter void mmc_retune_disable(struct mmc_host *host);
18dfa13ebbSAdrian Hunter void mmc_retune_hold(struct mmc_host *host);
19dfa13ebbSAdrian Hunter void mmc_retune_release(struct mmc_host *host);
20dfa13ebbSAdrian Hunter int mmc_retune(struct mmc_host *host);
215857b29bSUlf Hansson void mmc_retune_pause(struct mmc_host *host);
225857b29bSUlf Hansson void mmc_retune_unpause(struct mmc_host *host);
235857b29bSUlf Hansson 
24cb39f61eSAdrian Hunter static inline void mmc_retune_hold_now(struct mmc_host *host)
25cb39f61eSAdrian Hunter {
26cb39f61eSAdrian Hunter 	host->retune_now = 0;
27cb39f61eSAdrian Hunter 	host->hold_retune += 1;
28cb39f61eSAdrian Hunter }
29cb39f61eSAdrian Hunter 
305857b29bSUlf Hansson static inline void mmc_retune_recheck(struct mmc_host *host)
315857b29bSUlf Hansson {
325857b29bSUlf Hansson 	if (host->hold_retune <= 1)
335857b29bSUlf Hansson 		host->retune_now = 1;
345857b29bSUlf Hansson }
355857b29bSUlf Hansson 
365857b29bSUlf Hansson static inline int mmc_host_cmd23(struct mmc_host *host)
375857b29bSUlf Hansson {
385857b29bSUlf Hansson 	return host->caps & MMC_CAP_CMD23;
395857b29bSUlf Hansson }
405857b29bSUlf Hansson 
4110f21df4SAdrian Hunter static inline bool mmc_host_done_complete(struct mmc_host *host)
4210f21df4SAdrian Hunter {
4310f21df4SAdrian Hunter 	return host->caps & MMC_CAP_DONE_COMPLETE;
4410f21df4SAdrian Hunter }
4510f21df4SAdrian Hunter 
465857b29bSUlf Hansson static inline int mmc_boot_partition_access(struct mmc_host *host)
475857b29bSUlf Hansson {
485857b29bSUlf Hansson 	return !(host->caps2 & MMC_CAP2_BOOTPART_NOACC);
495857b29bSUlf Hansson }
505857b29bSUlf Hansson 
515857b29bSUlf Hansson static inline int mmc_host_uhs(struct mmc_host *host)
525857b29bSUlf Hansson {
535857b29bSUlf Hansson 	return host->caps &
545857b29bSUlf Hansson 		(MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
555857b29bSUlf Hansson 		 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 |
56d6743a8aSShawn Lin 		 MMC_CAP_UHS_DDR50) &&
57d6743a8aSShawn Lin 	       host->caps & MMC_CAP_4_BIT_DATA;
585857b29bSUlf Hansson }
595857b29bSUlf Hansson 
605857b29bSUlf Hansson static inline bool mmc_card_hs200(struct mmc_card *card)
615857b29bSUlf Hansson {
625857b29bSUlf Hansson 	return card->host->ios.timing == MMC_TIMING_MMC_HS200;
635857b29bSUlf Hansson }
645857b29bSUlf Hansson 
655857b29bSUlf Hansson static inline bool mmc_card_ddr52(struct mmc_card *card)
665857b29bSUlf Hansson {
675857b29bSUlf Hansson 	return card->host->ios.timing == MMC_TIMING_MMC_DDR52;
685857b29bSUlf Hansson }
695857b29bSUlf Hansson 
705857b29bSUlf Hansson static inline bool mmc_card_hs400(struct mmc_card *card)
715857b29bSUlf Hansson {
725857b29bSUlf Hansson 	return card->host->ios.timing == MMC_TIMING_MMC_HS400;
735857b29bSUlf Hansson }
745857b29bSUlf Hansson 
755857b29bSUlf Hansson static inline bool mmc_card_hs400es(struct mmc_card *card)
765857b29bSUlf Hansson {
775857b29bSUlf Hansson 	return card->host->ios.enhanced_strobe;
785857b29bSUlf Hansson }
795857b29bSUlf Hansson 
80*ead49373SUlf Hansson static inline bool mmc_card_sd_express(struct mmc_host *host)
81*ead49373SUlf Hansson {
82*ead49373SUlf Hansson 	return host->ios.timing == MMC_TIMING_SD_EXP ||
83*ead49373SUlf Hansson 		host->ios.timing == MMC_TIMING_SD_EXP_1_2V;
84*ead49373SUlf Hansson }
85*ead49373SUlf Hansson 
86b93931a6SPierre Ossman #endif
87b93931a6SPierre Ossman 
88