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 
mmc_retune_clear(struct mmc_host * host)24 static inline void mmc_retune_clear(struct mmc_host *host)
25 {
26 	host->retune_now = 0;
27 	host->need_retune = 0;
28 }
29 
mmc_retune_hold_now(struct mmc_host * host)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 
mmc_retune_recheck(struct mmc_host * host)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 
mmc_host_cmd23(struct mmc_host * host)42 static inline int mmc_host_cmd23(struct mmc_host *host)
43 {
44 	return host->caps & MMC_CAP_CMD23;
45 }
46 
mmc_host_done_complete(struct mmc_host * host)47 static inline bool mmc_host_done_complete(struct mmc_host *host)
48 {
49 	return host->caps & MMC_CAP_DONE_COMPLETE;
50 }
51 
mmc_boot_partition_access(struct mmc_host * host)52 static inline int mmc_boot_partition_access(struct mmc_host *host)
53 {
54 	return !(host->caps2 & MMC_CAP2_BOOTPART_NOACC);
55 }
56 
mmc_host_uhs(struct mmc_host * host)57 static inline int mmc_host_uhs(struct mmc_host *host)
58 {
59 	return host->caps &
60 		(MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
61 		 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 |
62 		 MMC_CAP_UHS_DDR50) &&
63 	       host->caps & MMC_CAP_4_BIT_DATA;
64 }
65 
mmc_card_hs200(struct mmc_card * card)66 static inline bool mmc_card_hs200(struct mmc_card *card)
67 {
68 	return card->host->ios.timing == MMC_TIMING_MMC_HS200;
69 }
70 
mmc_card_ddr52(struct mmc_card * card)71 static inline bool mmc_card_ddr52(struct mmc_card *card)
72 {
73 	return card->host->ios.timing == MMC_TIMING_MMC_DDR52;
74 }
75 
mmc_card_hs400(struct mmc_card * card)76 static inline bool mmc_card_hs400(struct mmc_card *card)
77 {
78 	return card->host->ios.timing == MMC_TIMING_MMC_HS400;
79 }
80 
mmc_card_hs400es(struct mmc_card * card)81 static inline bool mmc_card_hs400es(struct mmc_card *card)
82 {
83 	return card->host->ios.enhanced_strobe;
84 }
85 
mmc_card_sd_express(struct mmc_host * host)86 static inline bool mmc_card_sd_express(struct mmc_host *host)
87 {
88 	return host->ios.timing == MMC_TIMING_SD_EXP ||
89 		host->ios.timing == MMC_TIMING_SD_EXP_1_2V;
90 }
91 
92 #endif
93 
94