From f480e4ae237223b7bc93acc0e32551db571c8f1b Mon Sep 17 00:00:00 2001 From: Patrick Tjin Date: Wed, 22 Apr 2015 09:23:44 -0700 Subject: msm8994: add mmc kernel headers for secure-msm prebuilts Change-Id: I9356028bbb0a8b46216af722d9c30551282d5912 --- original-kernel-headers/linux/mmc/core.h | 36 ++++++++++ original-kernel-headers/linux/mmc/ioctl.h | 111 ++++++++++++++++++++++++++++++ original-kernel-headers/linux/mmc/mmc.h | 65 +++++++++++++++++ 3 files changed, 212 insertions(+) create mode 100644 original-kernel-headers/linux/mmc/core.h create mode 100644 original-kernel-headers/linux/mmc/ioctl.h create mode 100644 original-kernel-headers/linux/mmc/mmc.h (limited to 'original-kernel-headers/linux') diff --git a/original-kernel-headers/linux/mmc/core.h b/original-kernel-headers/linux/mmc/core.h new file mode 100644 index 0000000..04bf741 --- /dev/null +++ b/original-kernel-headers/linux/mmc/core.h @@ -0,0 +1,36 @@ +#ifndef UAPI_MMC_CORE_H +#define UAPI_MMC_CORE_H + +#define MMC_RSP_PRESENT (1 << 0) +#define MMC_RSP_136 (1 << 1) /* 136 bit response */ +#define MMC_RSP_CRC (1 << 2) /* expect valid crc */ +#define MMC_RSP_BUSY (1 << 3) /* card may send busy */ +#define MMC_RSP_OPCODE (1 << 4) /* response contains opcode */ + +#define MMC_CMD_MASK (3 << 5) /* non-SPI command type */ +#define MMC_CMD_AC (0 << 5) +#define MMC_CMD_ADTC (1 << 5) +#define MMC_CMD_BC (2 << 5) +#define MMC_CMD_BCR (3 << 5) + +#define MMC_RSP_SPI_S1 (1 << 7) /* one status byte */ +#define MMC_RSP_SPI_S2 (1 << 8) /* second byte */ +#define MMC_RSP_SPI_B4 (1 << 9) /* four data bytes */ +#define MMC_RSP_SPI_BUSY (1 << 10) /* card may send busy */ + +/* + * These are the native response types, and correspond to valid bit + * patterns of the above flags. One additional valid pattern + * is all zeros, which means we don't expect a response. + */ +#define MMC_RSP_NONE (0) +#define MMC_RSP_R1 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) +#define MMC_RSP_R1B (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE|MMC_RSP_BUSY) +#define MMC_RSP_R2 (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC) +#define MMC_RSP_R3 (MMC_RSP_PRESENT) +#define MMC_RSP_R4 (MMC_RSP_PRESENT) +#define MMC_RSP_R5 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) +#define MMC_RSP_R6 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) +#define MMC_RSP_R7 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) + +#endif /* UAPI_MMC_CORE_H */ diff --git a/original-kernel-headers/linux/mmc/ioctl.h b/original-kernel-headers/linux/mmc/ioctl.h new file mode 100644 index 0000000..befbdc2 --- /dev/null +++ b/original-kernel-headers/linux/mmc/ioctl.h @@ -0,0 +1,111 @@ +#ifndef LINUX_MMC_IOCTL_H +#define LINUX_MMC_IOCTL_H + +#include + +struct mmc_ioc_cmd { + /* Implies direction of data. true = write, false = read */ + int write_flag; + + /* Application-specific command. true = precede with CMD55 */ + int is_acmd; + + __u32 opcode; + __u32 arg; + __u32 response[4]; /* CMD response */ + unsigned int flags; + unsigned int blksz; + unsigned int blocks; + + /* + * Sleep at least postsleep_min_us useconds, and at most + * postsleep_max_us useconds *after* issuing command. Needed for + * some read commands for which cards have no other way of indicating + * they're ready for the next command (i.e. there is no equivalent of + * a "busy" indicator for read operations). + */ + unsigned int postsleep_min_us; + unsigned int postsleep_max_us; + + /* + * Override driver-computed timeouts. Note the difference in units! + */ + unsigned int data_timeout_ns; + unsigned int cmd_timeout_ms; + + /* + * For 64-bit machines, the next member, ``__u64 data_ptr``, wants to + * be 8-byte aligned. Make sure this struct is the same size when + * built for 32-bit. + */ + __u32 __pad; + + /* DAT buffer */ + __u64 data_ptr; +}; +#define mmc_ioc_cmd_set_data(ic, ptr) ic.data_ptr = (__u64)(unsigned long) ptr + +#define MMC_IOC_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct mmc_ioc_cmd) + +/** + * There are four request types that are applicable for rpmb accesses- two + * under read category and two under write. They are + * + * Reads + * ------- + * 1. Read Write Counter + * 2. Authenticated data read + * + * + * Writes + * ------- + * 1. Provision RPMB key (though it might be done in a secure environment) + * 2. Authenticated data write + * + * While its given that the rpmb data frames are going to have that + * information encoded in it and the frames should be generated by a secure + * piece of code, the request types can be classified as above. + * + * So here are the set of commands that should be executed atomically in the + * ioctl for rpmb read operation + * 1. Switch partition + * 2. Set block count + * 3. Write data frame - CMD25 to write the rpmb data frame + * 4. Set block count + * 5. Read the data - CMD18 to do the actual read + * + * Similarly for rpmb write operation, these are the commands that should be + * executed atomically in the ioctl for rpmb write operation + * 1. Switch partition + * 2. Set block count + * 3. Write data frame - CMD25 to write the rpmb data frame with data + * 4. Set block count + * 5. Read the data - CMD25 to write rpmb data frame indicating that rpmb + * result register is about to be read + * 6. Set block count + * 7. Read rpmb result - CMD18 to read the rpmb result register + * + * Each of the above commands should be sent individually via struct mmc_ioc_cmd + * and fields like is_acmd that are not needed for rpmb operations will be + * ignored. + */ +#define MMC_IOC_MAX_RPMB_CMD 3 +struct mmc_ioc_rpmb { + struct mmc_ioc_cmd cmds[MMC_IOC_MAX_RPMB_CMD]; +}; + +/* + * This ioctl is meant for use with rpmb partitions. This is needed since the + * access procedure for this particular partition is different from regular + * or normal partitions. + */ +#define MMC_IOC_RPMB_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct mmc_ioc_rpmb) + +/* + * Since this ioctl is only meant to enhance (and not replace) normal access + * to the mmc bus device, an upper data transfer limit of MMC_IOC_MAX_BYTES + * is enforced per ioctl call. For larger data transfers, use the normal + * block device operations. + */ +#define MMC_IOC_MAX_BYTES (512L * 256) +#endif /* LINUX_MMC_IOCTL_H */ diff --git a/original-kernel-headers/linux/mmc/mmc.h b/original-kernel-headers/linux/mmc/mmc.h new file mode 100644 index 0000000..9e6f113 --- /dev/null +++ b/original-kernel-headers/linux/mmc/mmc.h @@ -0,0 +1,65 @@ +#ifndef UAPI_MMC_MMC_H +#define UAPI_MMC_MMC_H + +/* Standard MMC commands (4.1) type argument response */ + /* class 1 */ +#define MMC_GO_IDLE_STATE 0 /* bc */ +#define MMC_SEND_OP_COND 1 /* bcr [31:0] OCR R3 */ +#define MMC_ALL_SEND_CID 2 /* bcr R2 */ +#define MMC_SET_RELATIVE_ADDR 3 /* ac [31:16] RCA R1 */ +#define MMC_SET_DSR 4 /* bc [31:16] RCA */ +#define MMC_SLEEP_AWAKE 5 /* ac [31:16] RCA 15:flg R1b */ +#define MMC_SWITCH 6 /* ac [31:0] See below R1b */ +#define MMC_SELECT_CARD 7 /* ac [31:16] RCA R1 */ +#define MMC_SEND_EXT_CSD 8 /* adtc R1 */ +#define MMC_SEND_CSD 9 /* ac [31:16] RCA R2 */ +#define MMC_SEND_CID 10 /* ac [31:16] RCA R2 */ +#define MMC_READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */ +#define MMC_STOP_TRANSMISSION 12 /* ac R1b */ +#define MMC_SEND_STATUS 13 /* ac [31:16] RCA R1 */ +#define MMC_BUS_TEST_R 14 /* adtc R1 */ +#define MMC_GO_INACTIVE_STATE 15 /* ac [31:16] RCA */ +#define MMC_BUS_TEST_W 19 /* adtc R1 */ +#define MMC_SPI_READ_OCR 58 /* spi spi_R3 */ +#define MMC_SPI_CRC_ON_OFF 59 /* spi [0:0] flag spi_R1 */ + + /* class 2 */ +#define MMC_SET_BLOCKLEN 16 /* ac [31:0] block len R1 */ +#define MMC_READ_SINGLE_BLOCK 17 /* adtc [31:0] data addr R1 */ +#define MMC_READ_MULTIPLE_BLOCK 18 /* adtc [31:0] data addr R1 */ +#define MMC_SEND_TUNING_BLOCK 19 /* adtc R1 */ +#define MMC_SEND_TUNING_BLOCK_HS200 21 /* adtc R1 */ +#define MMC_SEND_TUNING_BLOCK_HS400 MMC_SEND_TUNING_BLOCK_HS200 + + /* class 3 */ +#define MMC_WRITE_DAT_UNTIL_STOP 20 /* adtc [31:0] data addr R1 */ + + /* class 4 */ +#define MMC_SET_BLOCK_COUNT 23 /* adtc [31:0] data addr R1 */ +#define MMC_WRITE_BLOCK 24 /* adtc [31:0] data addr R1 */ +#define MMC_WRITE_MULTIPLE_BLOCK 25 /* adtc R1 */ +#define MMC_PROGRAM_CID 26 /* adtc R1 */ +#define MMC_PROGRAM_CSD 27 /* adtc R1 */ + + /* class 6 */ +#define MMC_SET_WRITE_PROT 28 /* ac [31:0] data addr R1b */ +#define MMC_CLR_WRITE_PROT 29 /* ac [31:0] data addr R1b */ +#define MMC_SEND_WRITE_PROT 30 /* adtc [31:0] wpdata addr R1 */ + + /* class 5 */ +#define MMC_ERASE_GROUP_START 35 /* ac [31:0] data addr R1 */ +#define MMC_ERASE_GROUP_END 36 /* ac [31:0] data addr R1 */ +#define MMC_ERASE 38 /* ac R1b */ + + /* class 9 */ +#define MMC_FAST_IO 39 /* ac R4 */ +#define MMC_GO_IRQ_STATE 40 /* bcr R5 */ + + /* class 7 */ +#define MMC_LOCK_UNLOCK 42 /* adtc R1b */ + + /* class 8 */ +#define MMC_APP_CMD 55 /* ac [31:16] RCA R1 */ +#define MMC_GEN_CMD 56 /* adtc [0] RD/WR R1 */ + +#endif /* UAPI_MMC_MMC_H */ -- cgit v1.2.3