ufs_aio_core.h 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* Copyright Statement:
  2. *
  3. * This software/firmware and related documentation ("MediaTek Software") are
  4. * protected under relevant copyright laws. The information contained herein
  5. * is confidential and proprietary to MediaTek Inc. and/or its licensors.
  6. * Without the prior written permission of MediaTek inc. and/or its licensors,
  7. * any reproduction, modification, use or disclosure of MediaTek Software,
  8. * and information contained herein, in whole or in part, shall be strictly prohibited.
  9. */
  10. /* MediaTek Inc. (C) 2015. All rights reserved.
  11. *
  12. * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  13. * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  14. * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
  15. * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  18. * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  19. * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  20. * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
  21. * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
  22. * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
  23. * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
  24. * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
  25. * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
  26. * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  27. * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  28. * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
  29. * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  30. */
  31. #ifndef __UFS_AIO_CORE_H
  32. #define __UFS_AIO_CORE_H
  33. #include "ufs_aio_cfg.h"
  34. #include "ufs_aio_types.h"
  35. #include "ufs_aio.h"
  36. #include "ufs_aio_hcd.h"
  37. typedef enum {
  38. UFS_LU_UNKNOWN = 0
  39. ,UFS_LU_BOOT1
  40. ,UFS_LU_BOOT2
  41. ,UFS_LU_USER
  42. ,UFS_LU_RPMB
  43. ,UFS_LU_END
  44. } ufs_logical_unit;
  45. enum {
  46. UFS_MODE_DEFAULT = 0
  47. ,UFS_MODE_DMA = 1
  48. ,UFS_MODE_PIO = 2
  49. ,UFS_MODE_MAX = 3
  50. };
  51. #define UFS_TYPE_UNKNOWN (0) /* Unknown UFS */
  52. #define UFS_TYPE_EMBEDDED_UFS (0x00000003) /* Embedded UFS */
  53. /* Well-known LUN */
  54. #define WLUN_ID (1<<7)
  55. #define WLUN_REPORT_LUNS (WLUN_ID | 0x1)
  56. #define WLUN_UFS_DEVICE (WLUN_ID | 0x50)
  57. #define WLUN_BOOT (WLUN_ID | 0x30)
  58. #define WLUN_RPMB (WLUN_ID | 0x44)
  59. int ufs_aio_block_read(u32 host_id, u32 lun, u32 blk_start, u32 blk_cnt, unsigned long * buf);
  60. int ufs_aio_block_write(u32 host_id, u32 lun, u32 blk_start, u32 blk_cnt, unsigned long * buf);
  61. int ufs_aio_cfg_mode(u32 host_id, u8 mode);
  62. #if defined(MTK_UFS_DRV_DA)
  63. int ufs_aio_generic_read(u64 address, u8* buffer, u64 length);
  64. int ufs_aio_generic_write(u64 address, u8* buffer, u64 length);
  65. int ufs_aio_otp_get_lock_status(struct ufs_hba * hba, u64 otp_start_addr);
  66. int ufs_aio_otp_lock(struct ufs_hba * hba, u64 otp_start_addr);
  67. int ufs_aio_otp_unlock(struct ufs_hba * hba, u64 otp_start_addr);
  68. #endif
  69. #if defined(MTK_UFS_DRV_LK)
  70. int ufs_aio_otp_lock_req(char *otp_part_name);
  71. int ufs_aio_otp_read(u32 current_user_id, off_t offset, u8* data, size_t size);
  72. int ufs_aio_otp_write(u32 current_user_id, off_t offset, u8* data, size_t size);
  73. int ufs_aio_otp_lock(void);
  74. #endif
  75. void ufs_aio_scsi_cmd_inquiry(struct ufs_aio_scsi_cmd * cmd, u32 tag, u32 lun, unsigned long * buf);
  76. void ufs_aio_scsi_cmd_read_capacity(struct ufs_aio_scsi_cmd * cmd, u32 tag, u32 lun, unsigned long * buf);
  77. void ufs_aio_scsi_cmd_read10(struct ufs_aio_scsi_cmd * cmd, u32 tag, u32 lun, u32 lba, u32 blk_cnt, unsigned long * buf, u32 attr);
  78. void ufs_aio_scsi_cmd_write10(struct ufs_aio_scsi_cmd * cmd, u32 tag, u32 lun, u32 lba, u32 blk_cnt, unsigned long * buf, u32 attr);
  79. void ufs_aio_scsi_cmd_test_unit_ready(struct ufs_aio_scsi_cmd *cmd, u32 tag, u32 lun);
  80. int ufs_switch_part(u32 part_id);
  81. #endif // __UFS_AIO_CORE_H