xref: /linux-6.15/include/uapi/linux/mmc/ioctl.h (revision 94dfc73e)
16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
260fe5771SDavid Howells #ifndef LINUX_MMC_IOCTL_H
360fe5771SDavid Howells #define LINUX_MMC_IOCTL_H
460fe5771SDavid Howells 
560fe5771SDavid Howells #include <linux/types.h>
683fc5dd5SJérôme Pouiller #include <linux/major.h>
760fe5771SDavid Howells 
860fe5771SDavid Howells struct mmc_ioc_cmd {
920427e5dSWolfram Sang 	/*
1020427e5dSWolfram Sang 	 * Direction of data: nonzero = write, zero = read.
1120427e5dSWolfram Sang 	 * Bit 31 selects 'Reliable Write' for RPMB.
1220427e5dSWolfram Sang 	 */
1360fe5771SDavid Howells 	int write_flag;
1460fe5771SDavid Howells 
1560fe5771SDavid Howells 	/* Application-specific command.  true = precede with CMD55 */
1660fe5771SDavid Howells 	int is_acmd;
1760fe5771SDavid Howells 
1860fe5771SDavid Howells 	__u32 opcode;
1960fe5771SDavid Howells 	__u32 arg;
2060fe5771SDavid Howells 	__u32 response[4];  /* CMD response */
2160fe5771SDavid Howells 	unsigned int flags;
2260fe5771SDavid Howells 	unsigned int blksz;
2360fe5771SDavid Howells 	unsigned int blocks;
2460fe5771SDavid Howells 
2560fe5771SDavid Howells 	/*
2660fe5771SDavid Howells 	 * Sleep at least postsleep_min_us useconds, and at most
2760fe5771SDavid Howells 	 * postsleep_max_us useconds *after* issuing command.  Needed for
2860fe5771SDavid Howells 	 * some read commands for which cards have no other way of indicating
2960fe5771SDavid Howells 	 * they're ready for the next command (i.e. there is no equivalent of
3060fe5771SDavid Howells 	 * a "busy" indicator for read operations).
3160fe5771SDavid Howells 	 */
3260fe5771SDavid Howells 	unsigned int postsleep_min_us;
3360fe5771SDavid Howells 	unsigned int postsleep_max_us;
3460fe5771SDavid Howells 
3560fe5771SDavid Howells 	/*
3660fe5771SDavid Howells 	 * Override driver-computed timeouts.  Note the difference in units!
3760fe5771SDavid Howells 	 */
3860fe5771SDavid Howells 	unsigned int data_timeout_ns;
3960fe5771SDavid Howells 	unsigned int cmd_timeout_ms;
4060fe5771SDavid Howells 
4160fe5771SDavid Howells 	/*
4260fe5771SDavid Howells 	 * For 64-bit machines, the next member, ``__u64 data_ptr``, wants to
4360fe5771SDavid Howells 	 * be 8-byte aligned.  Make sure this struct is the same size when
4460fe5771SDavid Howells 	 * built for 32-bit.
4560fe5771SDavid Howells 	 */
4660fe5771SDavid Howells 	__u32 __pad;
4760fe5771SDavid Howells 
4860fe5771SDavid Howells 	/* DAT buffer */
4960fe5771SDavid Howells 	__u64 data_ptr;
5060fe5771SDavid Howells };
5160fe5771SDavid Howells #define mmc_ioc_cmd_set_data(ic, ptr) ic.data_ptr = (__u64)(unsigned long) ptr
5260fe5771SDavid Howells 
53a5f5774cSJon Hunter /**
54a5f5774cSJon Hunter  * struct mmc_ioc_multi_cmd - multi command information
55a5f5774cSJon Hunter  * @num_of_cmds: Number of commands to send. Must be equal to or less than
56a5f5774cSJon Hunter  *	MMC_IOC_MAX_CMDS.
57a5f5774cSJon Hunter  * @cmds: Array of commands with length equal to 'num_of_cmds'
58a5f5774cSJon Hunter  */
59a5f5774cSJon Hunter struct mmc_ioc_multi_cmd {
60a5f5774cSJon Hunter 	__u64 num_of_cmds;
61*94dfc73eSGustavo A. R. Silva 	struct mmc_ioc_cmd cmds[];
62a5f5774cSJon Hunter };
6360fe5771SDavid Howells 
64a5f5774cSJon Hunter #define MMC_IOC_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct mmc_ioc_cmd)
65a5f5774cSJon Hunter /*
66a5f5774cSJon Hunter  * MMC_IOC_MULTI_CMD: Used to send an array of MMC commands described by
67a5f5774cSJon Hunter  *	the structure mmc_ioc_multi_cmd. The MMC driver will issue all
68a5f5774cSJon Hunter  *	commands in array in sequence to card.
69a5f5774cSJon Hunter  */
70a5f5774cSJon Hunter #define MMC_IOC_MULTI_CMD _IOWR(MMC_BLOCK_MAJOR, 1, struct mmc_ioc_multi_cmd)
7160fe5771SDavid Howells /*
7260fe5771SDavid Howells  * Since this ioctl is only meant to enhance (and not replace) normal access
7360fe5771SDavid Howells  * to the mmc bus device, an upper data transfer limit of MMC_IOC_MAX_BYTES
7460fe5771SDavid Howells  * is enforced per ioctl call.  For larger data transfers, use the normal
7560fe5771SDavid Howells  * block device operations.
7660fe5771SDavid Howells  */
77417b1bf8SJeonghan Kim #define MMC_IOC_MAX_BYTES  (512L * 1024)
78a5f5774cSJon Hunter #define MMC_IOC_MAX_CMDS    255
7960fe5771SDavid Howells #endif /* LINUX_MMC_IOCTL_H */
80