hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/include/linux/mmc/host.h
....@@ -1,9 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * linux/include/linux/mmc/host.h
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License version 2 as
6
- * published by the Free Software Foundation.
74 *
85 * Host driver specific definitions.
96 */
....@@ -18,6 +15,10 @@
1815 #include <linux/mmc/card.h>
1916 #include <linux/mmc/pm.h>
2017 #include <linux/dma-direction.h>
18
+#include <linux/keyslot-manager.h>
19
+#include <linux/android_kabi.h>
20
+
21
+#include <linux/android_vendor.h>
2122
2223 struct mmc_ios {
2324 unsigned int clock; /* clock rate */
....@@ -134,6 +135,7 @@
134135 int (*get_cd)(struct mmc_host *host);
135136
136137 void (*enable_sdio_irq)(struct mmc_host *host, int enable);
138
+ /* Mandatory callback when using MMC_CAP2_SDIO_IRQ_NOTHREAD. */
137139 void (*ack_sdio_irq)(struct mmc_host *host);
138140
139141 /* optional callback for HC quirks */
....@@ -143,13 +145,15 @@
143145
144146 /* Check if the card is pulling dat[0:3] low */
145147 int (*card_busy)(struct mmc_host *host);
146
- int (*set_sdio_status)(struct mmc_host *host, int val);
147148
148149 /* The tuning command opcode value is different for SD and eMMC cards */
149150 int (*execute_tuning)(struct mmc_host *host, u32 opcode);
150151
151152 /* Prepare HS400 target operating frequency depending host driver */
152153 int (*prepare_hs400_tuning)(struct mmc_host *host, struct mmc_ios *ios);
154
+
155
+ /* Prepare switch to DDR during the HS400 init sequence */
156
+ int (*hs400_prepare_ddr)(struct mmc_host *host);
153157
154158 /* Prepare for switching from HS400 to HS200 */
155159 void (*hs400_downgrade)(struct mmc_host *host);
....@@ -163,6 +167,7 @@
163167 int (*select_drive_strength)(struct mmc_card *card,
164168 unsigned int max_dtr, int host_drv,
165169 int card_drv, int *drv_type);
170
+ /* Reset the eMMC card via RST_n */
166171 void (*hw_reset)(struct mmc_host *host);
167172 void (*card_event)(struct mmc_host *host);
168173
....@@ -172,6 +177,9 @@
172177 */
173178 int (*multi_io_quirk)(struct mmc_card *card,
174179 unsigned int direction, int blk_size);
180
+
181
+ ANDROID_KABI_RESERVE(1);
182
+ ANDROID_KABI_RESERVE(2);
175183 };
176184
177185 struct mmc_cqe_ops {
....@@ -216,6 +224,9 @@
216224 * will have zero data bytes transferred.
217225 */
218226 void (*cqe_recovery_finish)(struct mmc_host *host);
227
+
228
+ ANDROID_KABI_RESERVE(1);
229
+ ANDROID_KABI_RESERVE(2);
219230 };
220231
221232 struct mmc_async_req {
....@@ -242,6 +253,7 @@
242253 struct mmc_slot {
243254 int cd_irq;
244255 bool cd_wake_enabled;
256
+ ANDROID_OEM_DATA_ARRAY(1, 2);
245257 void *handler_priv;
246258 };
247259
....@@ -284,9 +296,7 @@
284296 u32 ocr_avail_sdio; /* SDIO-specific OCR */
285297 u32 ocr_avail_sd; /* SD-specific OCR */
286298 u32 ocr_avail_mmc; /* MMC-specific OCR */
287
-#ifdef CONFIG_PM_SLEEP
288
- struct notifier_block pm_notify;
289
-#endif
299
+ struct wakeup_source *ws; /* Enable consume of uevents */
290300 u32 max_current_330;
291301 u32 max_current_300;
292302 u32 max_current_180;
....@@ -321,10 +331,11 @@
321331 #define MMC_CAP_AGGRESSIVE_PM (1 << 7) /* Suspend (e)MMC/SD at idle */
322332 #define MMC_CAP_NONREMOVABLE (1 << 8) /* Nonremovable e.g. eMMC */
323333 #define MMC_CAP_WAIT_WHILE_BUSY (1 << 9) /* Waits while card is busy */
324
-#define MMC_CAP_ERASE (1 << 10) /* Allow erase/trim commands */
325334 #define MMC_CAP_3_3V_DDR (1 << 11) /* Host supports eMMC DDR 3.3V */
326335 #define MMC_CAP_1_8V_DDR (1 << 12) /* Host supports eMMC DDR 1.8V */
327336 #define MMC_CAP_1_2V_DDR (1 << 13) /* Host supports eMMC DDR 1.2V */
337
+#define MMC_CAP_DDR (MMC_CAP_3_3V_DDR | MMC_CAP_1_8V_DDR | \
338
+ MMC_CAP_1_2V_DDR)
328339 #define MMC_CAP_POWER_OFF_CARD (1 << 14) /* Can power off after boot */
329340 #define MMC_CAP_BUS_WIDTH_TEST (1 << 15) /* CMD14/CMD19 bus width ok */
330341 #define MMC_CAP_UHS_SDR12 (1 << 16) /* Host supports UHS SDR12 mode */
....@@ -335,7 +346,7 @@
335346 #define MMC_CAP_UHS (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | \
336347 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | \
337348 MMC_CAP_UHS_DDR50)
338
-/* (1 << 21) is free for reuse */
349
+#define MMC_CAP_SYNC_RUNTIME_PM (1 << 21) /* Synced runtime PM suspends. */
339350 #define MMC_CAP_NEED_RSP_BUSY (1 << 22) /* Commands with R1B can't use R1. */
340351 #define MMC_CAP_DRIVER_TYPE_A (1 << 23) /* Host supports Driver Type A */
341352 #define MMC_CAP_DRIVER_TYPE_C (1 << 24) /* Host supports Driver Type C */
....@@ -344,12 +355,13 @@
344355 #define MMC_CAP_CD_WAKE (1 << 28) /* Enable card detect wake */
345356 #define MMC_CAP_CMD_DURING_TFR (1 << 29) /* Commands during data transfer */
346357 #define MMC_CAP_CMD23 (1 << 30) /* CMD23 supported. */
347
-#define MMC_CAP_HW_RESET (1 << 31) /* Hardware reset */
358
+#define MMC_CAP_HW_RESET (1 << 31) /* Reset the eMMC card via RST_n */
348359
349360 u32 caps2; /* More host capabilities */
350361
351362 #define MMC_CAP2_BOOTPART_NOACC (1 << 0) /* Boot partition no access */
352363 #define MMC_CAP2_FULL_PWR_CYCLE (1 << 2) /* Can do full power cycle */
364
+#define MMC_CAP2_FULL_PWR_CYCLE_IN_SUSPEND (1 << 3) /* Can do full power cycle in suspend */
353365 #define MMC_CAP2_HS200_1_8V_SDR (1 << 5) /* can support */
354366 #define MMC_CAP2_HS200_1_2V_SDR (1 << 6) /* can support */
355367 #define MMC_CAP2_HS200 (MMC_CAP2_HS200_1_8V_SDR | \
....@@ -372,21 +384,16 @@
372384 #define MMC_CAP2_CQE (1 << 23) /* Has eMMC command queue engine */
373385 #define MMC_CAP2_CQE_DCMD (1 << 24) /* CQE can issue a direct command */
374386 #define MMC_CAP2_AVOID_3_3V (1 << 25) /* Host must negotiate down from 3.3V */
387
+#define MMC_CAP2_MERGE_CAPABLE (1 << 26) /* Host can merge a segment over the segment size */
388
+#ifdef CONFIG_MMC_CRYPTO
375389 #define MMC_CAP2_CRYPTO (1 << 27) /* Host supports inline encryption */
390
+#else
391
+#define MMC_CAP2_CRYPTO 0
392
+#endif
376393
377394 int fixed_drv_type; /* fixed driver type for non-removable media */
378395
379396 mmc_pm_flag_t pm_caps; /* supported pm features */
380
- u32 restrict_caps; /* Indicate slot specific card type */
381
-#define RESTRICT_CARD_TYPE_SD (1 << 0) /* Can support Secure-Digital Card */
382
-#define RESTRICT_CARD_TYPE_SDIO (1 << 1) /* Can support Secure-Digital I/O Card or Combo-Mem */
383
-#define RESTRICT_CARD_TYPE_EMMC (1 << 2) /* Can support embedded Multi-Media Card */
384
-
385
-#ifdef CONFIG_SDIO_KEEPALIVE
386
- bool support_chip_alive;
387
- bool chip_alive;
388
- bool logic_remove_card;
389
-#endif
390397
391398 /* host specific block data */
392399 unsigned int max_seg_size; /* see blk_queue_max_segment_size */
....@@ -406,12 +413,14 @@
406413 unsigned int use_spi_crc:1;
407414 unsigned int claimed:1; /* host exclusively claimed */
408415 unsigned int bus_dead:1; /* bus has been released */
416
+ unsigned int doing_init_tune:1; /* initial tuning in progress */
409417 unsigned int can_retune:1; /* re-tuning can be used */
410418 unsigned int doing_retune:1; /* re-tuning in progress */
411419 unsigned int retune_now:1; /* do re-tuning at next req */
412420 unsigned int retune_paused:1; /* re-tuning is temporarily disabled */
413421 unsigned int use_blk_mq:1; /* use blk-mq */
414422 unsigned int retune_crc_disable:1; /* don't trigger retune upon crc */
423
+ unsigned int can_dma_map_merge:1; /* merging can be used */
415424
416425 int rescan_disable; /* disable card detection */
417426 int rescan_entered; /* used with nonremovable devices */
....@@ -474,14 +483,21 @@
474483 int cqe_qdepth;
475484 bool cqe_enabled;
476485 bool cqe_on;
486
+
487
+ /* Inline encryption support */
477488 #ifdef CONFIG_MMC_CRYPTO
478
- struct keyslot_manager *ksm;
479
-#endif /* CONFIG_MMC_CRYPTO */
489
+ struct blk_keyslot_manager ksm;
490
+#endif
480491
481492 /* Host Software Queue support */
482493 bool hsq_enabled;
483494
484
- unsigned long private[0] ____cacheline_aligned;
495
+ ANDROID_KABI_RESERVE(1);
496
+ ANDROID_KABI_RESERVE(2);
497
+ ANDROID_VENDOR_DATA(1);
498
+ ANDROID_OEM_DATA(1);
499
+
500
+ unsigned long private[] ____cacheline_aligned;
485501 };
486502
487503 struct device_node;
....@@ -493,12 +509,14 @@
493509 int mmc_of_parse(struct mmc_host *host);
494510 int mmc_of_parse_voltage(struct device_node *np, u32 *mask);
495511
496
-extern struct mmc_host *primary_sdio_host;
497
-int mmc_host_rescan(struct mmc_host *host, int val, int is_cap_sdio_irq);
498
-
499512 static inline void *mmc_priv(struct mmc_host *host)
500513 {
501514 return (void *)host->private;
515
+}
516
+
517
+static inline struct mmc_host *mmc_from_priv(void *priv)
518
+{
519
+ return container_of(priv, struct mmc_host, private);
502520 }
503521
504522 #define mmc_host_is_spi(host) ((host)->caps & MMC_CAP_SPI)
....@@ -530,21 +548,14 @@
530548 wake_up_process(host->sdio_irq_thread);
531549 }
532550
533
-void sdio_run_irqs(struct mmc_host *host);
534551 void sdio_signal_irq(struct mmc_host *host);
535552
536553 #ifdef CONFIG_REGULATOR
537
-int mmc_regulator_get_ocrmask(struct regulator *supply);
538554 int mmc_regulator_set_ocr(struct mmc_host *mmc,
539555 struct regulator *supply,
540556 unsigned short vdd_bit);
541557 int mmc_regulator_set_vqmmc(struct mmc_host *mmc, struct mmc_ios *ios);
542558 #else
543
-static inline int mmc_regulator_get_ocrmask(struct regulator *supply)
544
-{
545
- return 0;
546
-}
547
-
548559 static inline int mmc_regulator_set_ocr(struct mmc_host *mmc,
549560 struct regulator *supply,
550561 unsigned short vdd_bit)
....@@ -559,7 +570,6 @@
559570 }
560571 #endif
561572
562
-u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max);
563573 int mmc_regulator_get_supply(struct mmc_host *mmc);
564574
565575 static inline int mmc_card_is_removable(struct mmc_host *host)
....@@ -604,6 +614,16 @@
604614 return host->can_retune == 1;
605615 }
606616
617
+static inline bool mmc_doing_retune(struct mmc_host *host)
618
+{
619
+ return host->doing_retune == 1;
620
+}
621
+
622
+static inline bool mmc_doing_tune(struct mmc_host *host)
623
+{
624
+ return host->doing_retune == 1 || host->doing_init_tune == 1;
625
+}
626
+
607627 static inline enum dma_data_direction mmc_get_dma_dir(struct mmc_data *data)
608628 {
609629 return data->flags & MMC_DATA_WRITE ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
....@@ -611,7 +631,5 @@
611631
612632 int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
613633 int mmc_abort_tuning(struct mmc_host *host, u32 opcode);
614
-void mmc_retune_enable(struct mmc_host *host);
615
-void mmc_retune_disable(struct mmc_host *host);
616634
617635 #endif /* LINUX_MMC_HOST_H */