calibration.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * calibration.h -- Calibration defines for Cirrus Logic CS35L41 codec
  3. *
  4. * Copyright 2017 Cirrus Logic
  5. *
  6. * Author: David Rhodes <[email protected]>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/notifier.h>
  13. #include <sound/soc.h>
  14. #define CS35L41_NG_ENABLE_MASK 0x00010000
  15. #define CSPL_STATE_RUNNING 0x00000000
  16. #define CSPL_STATE_ERROR 0x00000001
  17. #define CS35L41_VBST_CTL_11 0xAA
  18. #define CIRRUS_CAL_CLASSH_DELAY_50MS 0x32
  19. #define CIRRUS_CAL_CLASSD_DELAY_50MS 0x32
  20. #define CIRRUS_CAL_VIMON_STATUS_INVALID 1
  21. #define CIRRUS_CAL_VIMON_STATUS_SUCCESS 2
  22. #define CSPL_STATUS_OUT_OF_RANGE 0x00000003
  23. #define CSPL_STATUS_INCOMPLETE 0x00000002
  24. #define CIRRUS_CAL_AMP_CONSTANT 5.85714
  25. #define CIRRUS_CAL_AMP_CONSTANT_NUM 292857
  26. #define CIRRUS_CAL_AMP_CONSTANT_DENOM 50000
  27. #define CIRRUS_CAL_RDC_RADIX 13
  28. #define CIRRUS_CAL_RDC_DEFAULT 8580
  29. #define CIRRUS_CAL_VFS_MV 12300
  30. #define CIRRUS_CAL_IFS_MA 2100
  31. #define CIRRUS_CAL_V_VAL_UB_MV 2000
  32. #define CIRRUS_CAL_V_VAL_LB_MV 50
  33. #define CIRRUS_CAL_VIMON_CAL_VSC_UB 0x00010624
  34. #define CIRRUS_CAL_VIMON_CAL_VSC_LB 0x00FEF9DC
  35. #define CIRRUS_CAL_VIMON_CAL_ISC_UB 0x00004189
  36. #define CIRRUS_CAL_VIMON_CAL_ISC_LB 0x00FFBE77
  37. #define CS35L41_CAL_RTLOG_ID_V_PEAK 947
  38. #define CS35L41_CAL_RTLOG_ID_I_PEAK 948
  39. #define CIRRUS_CAL_RTLOG_ID_V_PEAK 1064
  40. #define CIRRUS_CAL_RTLOG_ID_I_PEAK 1065
  41. #define CIRRUS_CAL_RTLOG_ID_TEMP 111
  42. #define CIRRUS_CAL_RTLOG_RADIX_TEMP 14
  43. #define CS35L41_MPU_UNLOCK_CODE_0 0x5555
  44. #define CS35L41_MPU_UNLOCK_CODE_1 0xaaaa
  45. #ifdef CONFIG_SND_SOC_CIRRUS_REINIT_SYSFS
  46. #define CIRRUS_CAL_NUM_ATTRS_BASE 4
  47. #else
  48. #define CIRRUS_CAL_NUM_ATTRS_BASE 3
  49. #endif
  50. #define CIRRUS_CAL_NUM_ATTRS_AMP 7
  51. extern struct cirrus_cal_ops cirrus_cspl_cal_ops;
  52. extern struct cirrus_cal_ops cirrus_cs35l43_cal_ops;
  53. /* needs to match ops container struct in cirrus-amp.c */
  54. enum cirrus_cal_ops_idx {
  55. CIRRUS_CAL_OPS_INVALID,
  56. CIRRUS_CAL_CSPL_CAL_OPS_IDX,
  57. CIRRUS_CAL_CS35L43_CAL_OPS_IDX,
  58. };
  59. int cirrus_cal_read_temp(const char *mfd_suffix);
  60. int cirrus_cal_apply(const char *mfd_suffix);
  61. int cirrus_cal_set_surface_temp(const char *suffix, int temperature);
  62. int cirrus_cal_init(void);
  63. void cirrus_cal_exit(void);