xref: /linux/drivers/mmc/core/host.h (revision 5ea5880764cbb164afb17a62e76ca75dc371409d)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  *  linux/drivers/mmc/core/host.h
4  *
5  *  Copyright (C) 2003 Russell King, All Rights Reserved.
6  *  Copyright 2007 Pierre Ossman
7  */
8 #ifndef _MMC_CORE_HOST_H
9 #define _MMC_CORE_HOST_H
10 
11 #include <linux/mmc/host.h>
12 
13 int mmc_register_host_class(void);
14 void mmc_unregister_host_class(void);
15 
16 void mmc_retune_enable(struct mmc_host *host);
17 void mmc_retune_disable(struct mmc_host *host);
18 void mmc_retune_hold(struct mmc_host *host);
19 void mmc_retune_release(struct mmc_host *host);
20 int mmc_retune(struct mmc_host *host);
21 void mmc_retune_pause(struct mmc_host *host);
22 void mmc_retune_unpause(struct mmc_host *host);
23 
24 static inline void mmc_retune_clear(struct mmc_host *host)
25 {
26 	host->retune_now = 0;
27 	host->need_retune = 0;
28 }
29 
30 static inline void mmc_retune_hold_now(struct mmc_host *host)
31 {
32 	host->retune_now = 0;
33 	host->hold_retune += 1;
34 }
35 
36 static inline void mmc_retune_recheck(struct mmc_host *host)
37 {
38 	if (host->hold_retune <= 1)
39 		host->retune_now = 1;
40 }
41 
42 static inline int mmc_host_can_cmd23(struct mmc_host *host)
43 {
44 	return host->caps & MMC_CAP_CMD23;
45 }
46 
47 static inline bool mmc_host_can_done_complete(struct mmc_host *host)
48 {
49 	return host->caps & MMC_CAP_DONE_COMPLETE;
50 }
51 
52 static inline int mmc_host_can_access_boot(struct mmc_host *host)
53 {
54 	return !(host->caps2 & MMC_CAP2_BOOTPART_NOACC);
55 }
56 
57 static inline int mmc_host_can_uhs(struct mmc_host *host)
58 {
59 	return host->caps & MMC_CAP_UHS;
60 }
61 
62 static inline bool mmc_card_hs200(struct mmc_card *card)
63 {
64 	return card->host->ios.timing == MMC_TIMING_MMC_HS200;
65 }
66 
67 static inline bool mmc_card_ddr52(struct mmc_card *card)
68 {
69 	return card->host->ios.timing == MMC_TIMING_MMC_DDR52;
70 }
71 
72 static inline bool mmc_card_hs400(struct mmc_card *card)
73 {
74 	return card->host->ios.timing == MMC_TIMING_MMC_HS400;
75 }
76 
77 static inline bool mmc_card_hs400es(struct mmc_card *card)
78 {
79 	return card->host->ios.enhanced_strobe;
80 }
81 
82 static inline bool mmc_card_sd_express(struct mmc_host *host)
83 {
84 	return host->ios.timing == MMC_TIMING_SD_EXP ||
85 		host->ios.timing == MMC_TIMING_SD_EXP_1_2V;
86 }
87 
88 #endif
89 
90