mmc-sec-sysfs.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Samsung Specific feature
  4. *
  5. * Copyright (C) 2024 Samsung Electronics Co., Ltd.
  6. *
  7. * Authors:
  8. * Storage Driver <[email protected]>
  9. */
  10. #ifndef __MMC_SEC_SYSFS_H__
  11. #define __MMC_SEC_SYSFS_H__
  12. #include <linux/sec_class.h>
  13. #include "mmc-sec-feature.h"
  14. #define MAX_REQ_TYPE_INDEX 5 // sbc, cmd, data, stop, busy
  15. #define MAX_ERR_TYPE_INDEX 2 // crc, timeout
  16. #define MAX_LOG_INDEX (MAX_REQ_TYPE_INDEX * MAX_ERR_TYPE_INDEX)
  17. #define SD_SBC_OFFSET 0
  18. #define SD_CMD_OFFSET 2
  19. #define SD_DATA_OFFSET 4
  20. #define SD_STOP_OFFSET 6
  21. #define SD_BUSY_OFFSET 8
  22. #define STATUS_MASK (R1_ERROR | R1_CC_ERROR | R1_CARD_ECC_FAILED | \
  23. R1_WP_VIOLATION | R1_OUT_OF_RANGE)
  24. enum {
  25. SEC_INVALID_SD_SLOT = 0,
  26. SEC_NO_DET_SD_SLOT,
  27. SEC_HOTPLUG_SD_SLOT,
  28. SEC_HYBRID_SD_SLOT,
  29. };
  30. struct mmc_sd_sec_err_info {
  31. char type[MAX_REQ_TYPE_INDEX]; // sbc, cmd, data, stop, busy
  32. int err_type;
  33. u32 status;
  34. u64 first_issue_time;
  35. u64 last_issue_time;
  36. u32 count;
  37. };
  38. struct mmc_sd_sec_status_err_info {
  39. u32 ge_cnt; // status[19] : general error or unknown error
  40. u32 cc_cnt; // status[20] : internal card controller error
  41. u32 ecc_cnt; // status[21] : ecc error
  42. u32 wp_cnt; // status[26] : write protection error
  43. u32 oor_cnt; // status[31] : out of range error
  44. u32 noti_cnt; // uevent notification count
  45. };
  46. struct mmc_sd_sec_device_info {
  47. struct mmc_host *mmc;
  48. unsigned int card_detect_cnt;
  49. int sd_slot_type;
  50. bool tray_status;
  51. unsigned long tstamp_last_cmd;
  52. struct work_struct noti_work;
  53. struct mmc_sd_sec_err_info err_info[MAX_LOG_INDEX];
  54. struct mmc_sd_sec_status_err_info status_err;
  55. struct mmc_sd_sec_err_info saved_err_info[MAX_LOG_INDEX];
  56. struct mmc_sd_sec_status_err_info saved_status_err;
  57. };
  58. void sd_sec_init_sysfs(struct mmc_host *host);
  59. extern struct mmc_sd_sec_device_info sdi;
  60. #endif