bootctrl: Import missing MMC and UFS MediaTek headers
Change-Id: I342a2d6267a9e9548a5fe7647bba6317a1b7f69c
diff --git a/bootctrl/boot_region_control.cpp b/bootctrl/boot_region_control.cpp
index e9e8834..9fecc75 100644
--- a/bootctrl/boot_region_control.cpp
+++ b/bootctrl/boot_region_control.cpp
@@ -5,8 +5,8 @@
#include <android-base/logging.h>
#if !defined(ARCH_X86)
-#include <linux/mmc/mmc-mtk-ioctl.h>
-#include <linux/scsi/ufs/ufs-mtk-ioctl.h>
+#include "mmc-mtk-ioctl.h"
+#include "ufs-mtk-ioctl.h"
#include <sys/ioctl.h>
#endif
diff --git a/bootctrl/mmc-mtk-ioctl.h b/bootctrl/mmc-mtk-ioctl.h
new file mode 100644
index 0000000..53eeac9
--- /dev/null
+++ b/bootctrl/mmc-mtk-ioctl.h
@@ -0,0 +1,52 @@
+
+#ifndef EMMC_MTK_IOCTL_H__
+#define EMMC_MTK_IOCTL_H__
+
+#include <linux/mmc/ioctl.h>
+#define MMC_BLOCK_MAJOR 179
+#define MMC_SWITCH 6
+#define MMC_SEND_EXT_CSD 8
+
+/*
+* EXT_CSD fields
+*/
+#define EXT_CSD_PART_CONFIG 179
+
+/**/
+typedef enum {
+ EMMC_PART_UNKNOWN=0
+ ,EMMC_PART_BOOT1
+ ,EMMC_PART_BOOT2
+ ,EMMC_PART_RPMB
+ ,EMMC_PART_GP1
+ ,EMMC_PART_GP2
+ ,EMMC_PART_GP3
+ ,EMMC_PART_GP4
+ ,EMMC_PART_USER
+ ,EMMC_PART_END
+} Region;
+
+/* Copied from kernel linux/mmc/core.h */
+#define MMC_RSP_OPCODE (1 << 4) /* response contains opcode */
+#define MMC_RSP_BUSY (1 << 3) /* card may send busy */
+#define MMC_RSP_CRC (1 << 2) /* expect valid crc */
+#define MMC_RSP_136 (1 << 1) /* 136 bit response */
+#define MMC_RSP_PRESENT (1 << 0)
+
+#define MMC_CMD_ADTC (1 << 5)
+#define MMC_CMD_AC (0 << 5)
+
+#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)
+
+/* Copied from kernel linux/mmc/mmc.h */
+#define EXT_CSD_CMD_SET_NORMAL (1<<0)
+#define EXT_CSD_CMD_SET_SECURE (1<<1)
+#define EXT_CSD_CMD_SET_CPSECURE (1<<2)
+
+#define MMC_SWITCH_MODE_CMD_SET 0x00 /* Change the command set */
+#define MMC_SWITCH_MODE_SET_BITS 0x01 /* Set bits which are 1 in value */
+#define MMC_SWITCH_MODE_CLEAR_BITS 0x02 /* Clear bits which are 1 in value */
+#define MMC_SWITCH_MODE_WRITE_BYTE 0x03 /* Set target to value */
+
+#endif
diff --git a/bootctrl/ufs-mtk-ioctl-private.h b/bootctrl/ufs-mtk-ioctl-private.h
new file mode 100644
index 0000000..5228a60
--- /dev/null
+++ b/bootctrl/ufs-mtk-ioctl-private.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** This header was automatically generated from a Linux kernel header
+ *** of the same name, to make information necessary for userspace to
+ *** call into the kernel available to libc. It contains only constants,
+ *** structures, and macros generated from the original header, and thus,
+ *** contains no copyrightable information.
+ ***
+ *** To edit the content of this header, modify the corresponding
+ *** source file (e.g. under external/kernel-headers/original/) then
+ *** run bionic/libc/kernel/tools/update_all.py
+ ***
+ *** Any manual change here will be lost the next time this script will
+ *** be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef UFS_MTK_IOCTL_PRIVATE_H_
+#define UFS_MTK_IOCTL_PRIVATE_H_
+enum query_opcode {
+ UPIU_QUERY_OPCODE_READ_DESC = 0x1,
+ UPIU_QUERY_OPCODE_READ_ATTR = 0x3,
+ UPIU_QUERY_OPCODE_WRITE_ATTR = 0x4,
+ UPIU_QUERY_OPCODE_READ_FLAG = 0x5,
+};
+enum attr_idn {
+ QUERY_ATTR_IDN_BOOT_LUN_EN = 0x00,
+ QUERY_ATTR_IDN_DEVICE_FFU_STATUS = 0x14,
+};
+enum flag_idn {
+ QUERY_FLAG_IDN_PERMANENTLY_DISABLE_FW_UPDATE = 0xB,
+};
+enum desc_idn {
+ QUERY_DESC_IDN_DEVICE = 0x0,
+ QUERY_DESC_IDN_STRING = 0x5,
+};
+enum ufs_desc_max_size {
+ QUERY_DESC_DEVICE_MAX_SIZE = 0x40,
+};
+enum ufs_feature_support_list {
+ UFS_FEATURES_FFU = 0x1,
+};
+enum device_desc_param {
+ DEVICE_DESC_PARAM_MANF_ID = 0x18,
+ DEVICE_DESC_UFS_FEATURES_SUPPORT = 0x1F,
+ DEVICE_DESC_PARAM_PRL = 0x2A,
+};
+#endif
diff --git a/bootctrl/ufs-mtk-ioctl.h b/bootctrl/ufs-mtk-ioctl.h
new file mode 100644
index 0000000..bb733a5
--- /dev/null
+++ b/bootctrl/ufs-mtk-ioctl.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** This header was automatically generated from a Linux kernel header
+ *** of the same name, to make information necessary for userspace to
+ *** call into the kernel available to libc. It contains only constants,
+ *** structures, and macros generated from the original header, and thus,
+ *** contains no copyrightable information.
+ ***
+ *** To edit the content of this header, modify the corresponding
+ *** source file (e.g. under external/kernel-headers/original/) then
+ *** run bionic/libc/kernel/tools/update_all.py
+ ***
+ *** Any manual change here will be lost the next time this script will
+ *** be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef UFS_MTK_IOCTL_H__
+#define UFS_MTK_IOCTL_H__
+#include "ufs-mtk-ioctl-private.h"
+#define UFS_IOCTL_QUERY 0x5388
+#define UFS_IOCTL_FFU 0x5389
+#define UFS_IOCTL_GET_FW_VER 0x5390
+#define UFS_IOCTL_RPMB 0x5391
+#define HPB_QUERY_OPCODE 0x5500
+#define UFS_IOCTL_FFU_MAX_FW_SIZE_BYTES (512L * 1024)
+#define UFS_IOCTL_FFU_MAX_FW_VER_BYTES (4)
+#define UFS_IOCTL_FFU_MAX_FW_VER_STRING_DESCR_BYTES (10)
+struct ufs_ioctl_query_data {
+ __u32 opcode;
+ __u8 idn;
+ __u8 idx;
+ __u16 buf_byte;
+ __u8 * buf_ptr;
+};
+struct ufs_ioctl_query_data_hpb {
+ __u32 opcode;
+ __u8 idn;
+ __u16 buf_size;
+ __u8 buffer[0];
+};
+struct ufs_ioctl_ffu_data {
+ __u32 buf_byte;
+ __u8 * buf_ptr;
+};
+struct ufs_ioctl_query_fw_ver_data {
+ __u16 buf_byte;
+ __u8 * buf_ptr;
+};
+#endif