xref: /linux/drivers/mmc/core/host.h (revision d6743a8a1ae38269a41094ad14d7ef86199f661d)
1b93931a6SPierre Ossman /*
2b93931a6SPierre Ossman  *  linux/drivers/mmc/core/host.h
3b93931a6SPierre Ossman  *
4b93931a6SPierre Ossman  *  Copyright (C) 2003 Russell King, All Rights Reserved.
5b93931a6SPierre Ossman  *  Copyright 2007 Pierre Ossman
6b93931a6SPierre Ossman  *
7b93931a6SPierre Ossman  * This program is free software; you can redistribute it and/or modify
8b93931a6SPierre Ossman  * it under the terms of the GNU General Public License version 2 as
9b93931a6SPierre Ossman  * published by the Free Software Foundation.
10b93931a6SPierre Ossman  */
11b93931a6SPierre Ossman #ifndef _MMC_CORE_HOST_H
12b93931a6SPierre Ossman #define _MMC_CORE_HOST_H
13066185d6SUlf Hansson 
145857b29bSUlf Hansson #include <linux/mmc/host.h>
15b93931a6SPierre Ossman 
16b93931a6SPierre Ossman int mmc_register_host_class(void);
17b93931a6SPierre Ossman void mmc_unregister_host_class(void);
188ea926b2SAdrian Hunter 
19dfa13ebbSAdrian Hunter void mmc_retune_enable(struct mmc_host *host);
20dfa13ebbSAdrian Hunter void mmc_retune_disable(struct mmc_host *host);
21dfa13ebbSAdrian Hunter void mmc_retune_hold(struct mmc_host *host);
22dfa13ebbSAdrian Hunter void mmc_retune_release(struct mmc_host *host);
23dfa13ebbSAdrian Hunter int mmc_retune(struct mmc_host *host);
245857b29bSUlf Hansson void mmc_retune_pause(struct mmc_host *host);
255857b29bSUlf Hansson void mmc_retune_unpause(struct mmc_host *host);
265857b29bSUlf Hansson 
27cb39f61eSAdrian Hunter static inline void mmc_retune_hold_now(struct mmc_host *host)
28cb39f61eSAdrian Hunter {
29cb39f61eSAdrian Hunter 	host->retune_now = 0;
30cb39f61eSAdrian Hunter 	host->hold_retune += 1;
31cb39f61eSAdrian Hunter }
32cb39f61eSAdrian Hunter 
335857b29bSUlf Hansson static inline void mmc_retune_recheck(struct mmc_host *host)
345857b29bSUlf Hansson {
355857b29bSUlf Hansson 	if (host->hold_retune <= 1)
365857b29bSUlf Hansson 		host->retune_now = 1;
375857b29bSUlf Hansson }
385857b29bSUlf Hansson 
395857b29bSUlf Hansson static inline int mmc_host_cmd23(struct mmc_host *host)
405857b29bSUlf Hansson {
415857b29bSUlf Hansson 	return host->caps & MMC_CAP_CMD23;
425857b29bSUlf Hansson }
435857b29bSUlf Hansson 
4410f21df4SAdrian Hunter static inline bool mmc_host_done_complete(struct mmc_host *host)
4510f21df4SAdrian Hunter {
4610f21df4SAdrian Hunter 	return host->caps & MMC_CAP_DONE_COMPLETE;
4710f21df4SAdrian Hunter }
4810f21df4SAdrian Hunter 
495857b29bSUlf Hansson static inline int mmc_boot_partition_access(struct mmc_host *host)
505857b29bSUlf Hansson {
515857b29bSUlf Hansson 	return !(host->caps2 & MMC_CAP2_BOOTPART_NOACC);
525857b29bSUlf Hansson }
535857b29bSUlf Hansson 
545857b29bSUlf Hansson static inline int mmc_host_uhs(struct mmc_host *host)
555857b29bSUlf Hansson {
565857b29bSUlf Hansson 	return host->caps &
575857b29bSUlf Hansson 		(MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
585857b29bSUlf Hansson 		 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 |
59*d6743a8aSShawn Lin 		 MMC_CAP_UHS_DDR50) &&
60*d6743a8aSShawn Lin 	       host->caps & MMC_CAP_4_BIT_DATA;
615857b29bSUlf Hansson }
625857b29bSUlf Hansson 
635857b29bSUlf Hansson static inline bool mmc_card_hs200(struct mmc_card *card)
645857b29bSUlf Hansson {
655857b29bSUlf Hansson 	return card->host->ios.timing == MMC_TIMING_MMC_HS200;
665857b29bSUlf Hansson }
675857b29bSUlf Hansson 
685857b29bSUlf Hansson static inline bool mmc_card_ddr52(struct mmc_card *card)
695857b29bSUlf Hansson {
705857b29bSUlf Hansson 	return card->host->ios.timing == MMC_TIMING_MMC_DDR52;
715857b29bSUlf Hansson }
725857b29bSUlf Hansson 
735857b29bSUlf Hansson static inline bool mmc_card_hs400(struct mmc_card *card)
745857b29bSUlf Hansson {
755857b29bSUlf Hansson 	return card->host->ios.timing == MMC_TIMING_MMC_HS400;
765857b29bSUlf Hansson }
775857b29bSUlf Hansson 
785857b29bSUlf Hansson static inline bool mmc_card_hs400es(struct mmc_card *card)
795857b29bSUlf Hansson {
805857b29bSUlf Hansson 	return card->host->ios.enhanced_strobe;
815857b29bSUlf Hansson }
825857b29bSUlf Hansson 
83b93931a6SPierre Ossman #endif
84b93931a6SPierre Ossman 
85