w1_ds2780.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * 1-Wire implementation for the ds2780 chip
  4. *
  5. * Copyright (C) 2010 Indesign, LLC
  6. *
  7. * Author: Clifton Barnes <[email protected]>
  8. *
  9. * Based on w1-ds2760 driver
  10. */
  11. #ifndef _W1_DS2780_H
  12. #define _W1_DS2780_H
  13. /* Function commands */
  14. #define W1_DS2780_READ_DATA 0x69
  15. #define W1_DS2780_WRITE_DATA 0x6C
  16. #define W1_DS2780_COPY_DATA 0x48
  17. #define W1_DS2780_RECALL_DATA 0xB8
  18. #define W1_DS2780_LOCK 0x6A
  19. /* Register map */
  20. /* Register 0x00 Reserved */
  21. #define DS2780_STATUS_REG 0x01
  22. #define DS2780_RAAC_MSB_REG 0x02
  23. #define DS2780_RAAC_LSB_REG 0x03
  24. #define DS2780_RSAC_MSB_REG 0x04
  25. #define DS2780_RSAC_LSB_REG 0x05
  26. #define DS2780_RARC_REG 0x06
  27. #define DS2780_RSRC_REG 0x07
  28. #define DS2780_IAVG_MSB_REG 0x08
  29. #define DS2780_IAVG_LSB_REG 0x09
  30. #define DS2780_TEMP_MSB_REG 0x0A
  31. #define DS2780_TEMP_LSB_REG 0x0B
  32. #define DS2780_VOLT_MSB_REG 0x0C
  33. #define DS2780_VOLT_LSB_REG 0x0D
  34. #define DS2780_CURRENT_MSB_REG 0x0E
  35. #define DS2780_CURRENT_LSB_REG 0x0F
  36. #define DS2780_ACR_MSB_REG 0x10
  37. #define DS2780_ACR_LSB_REG 0x11
  38. #define DS2780_ACRL_MSB_REG 0x12
  39. #define DS2780_ACRL_LSB_REG 0x13
  40. #define DS2780_AS_REG 0x14
  41. #define DS2780_SFR_REG 0x15
  42. #define DS2780_FULL_MSB_REG 0x16
  43. #define DS2780_FULL_LSB_REG 0x17
  44. #define DS2780_AE_MSB_REG 0x18
  45. #define DS2780_AE_LSB_REG 0x19
  46. #define DS2780_SE_MSB_REG 0x1A
  47. #define DS2780_SE_LSB_REG 0x1B
  48. /* Register 0x1C - 0x1E Reserved */
  49. #define DS2780_EEPROM_REG 0x1F
  50. #define DS2780_EEPROM_BLOCK0_START 0x20
  51. /* Register 0x20 - 0x2F User EEPROM */
  52. #define DS2780_EEPROM_BLOCK0_END 0x2F
  53. /* Register 0x30 - 0x5F Reserved */
  54. #define DS2780_EEPROM_BLOCK1_START 0x60
  55. #define DS2780_CONTROL_REG 0x60
  56. #define DS2780_AB_REG 0x61
  57. #define DS2780_AC_MSB_REG 0x62
  58. #define DS2780_AC_LSB_REG 0x63
  59. #define DS2780_VCHG_REG 0x64
  60. #define DS2780_IMIN_REG 0x65
  61. #define DS2780_VAE_REG 0x66
  62. #define DS2780_IAE_REG 0x67
  63. #define DS2780_AE_40_REG 0x68
  64. #define DS2780_RSNSP_REG 0x69
  65. #define DS2780_FULL_40_MSB_REG 0x6A
  66. #define DS2780_FULL_40_LSB_REG 0x6B
  67. #define DS2780_FULL_3040_SLOPE_REG 0x6C
  68. #define DS2780_FULL_2030_SLOPE_REG 0x6D
  69. #define DS2780_FULL_1020_SLOPE_REG 0x6E
  70. #define DS2780_FULL_0010_SLOPE_REG 0x6F
  71. #define DS2780_AE_3040_SLOPE_REG 0x70
  72. #define DS2780_AE_2030_SLOPE_REG 0x71
  73. #define DS2780_AE_1020_SLOPE_REG 0x72
  74. #define DS2780_AE_0010_SLOPE_REG 0x73
  75. #define DS2780_SE_3040_SLOPE_REG 0x74
  76. #define DS2780_SE_2030_SLOPE_REG 0x75
  77. #define DS2780_SE_1020_SLOPE_REG 0x76
  78. #define DS2780_SE_0010_SLOPE_REG 0x77
  79. #define DS2780_RSGAIN_MSB_REG 0x78
  80. #define DS2780_RSGAIN_LSB_REG 0x79
  81. #define DS2780_RSTC_REG 0x7A
  82. #define DS2780_FRSGAIN_MSB_REG 0x7B
  83. #define DS2780_FRSGAIN_LSB_REG 0x7C
  84. #define DS2780_EEPROM_BLOCK1_END 0x7C
  85. /* Register 0x7D - 0xFF Reserved */
  86. /* Number of valid register addresses */
  87. #define DS2780_DATA_SIZE 0x80
  88. /* Status register bits */
  89. #define DS2780_STATUS_REG_CHGTF (1 << 7)
  90. #define DS2780_STATUS_REG_AEF (1 << 6)
  91. #define DS2780_STATUS_REG_SEF (1 << 5)
  92. #define DS2780_STATUS_REG_LEARNF (1 << 4)
  93. /* Bit 3 Reserved */
  94. #define DS2780_STATUS_REG_UVF (1 << 2)
  95. #define DS2780_STATUS_REG_PORF (1 << 1)
  96. /* Bit 0 Reserved */
  97. /* Control register bits */
  98. /* Bit 7 Reserved */
  99. #define DS2780_CONTROL_REG_UVEN (1 << 6)
  100. #define DS2780_CONTROL_REG_PMOD (1 << 5)
  101. #define DS2780_CONTROL_REG_RNAOP (1 << 4)
  102. /* Bit 0 - 3 Reserved */
  103. /* Special feature register bits */
  104. /* Bit 1 - 7 Reserved */
  105. #define DS2780_SFR_REG_PIOSC (1 << 0)
  106. /* EEPROM register bits */
  107. #define DS2780_EEPROM_REG_EEC (1 << 7)
  108. #define DS2780_EEPROM_REG_LOCK (1 << 6)
  109. /* Bit 2 - 6 Reserved */
  110. #define DS2780_EEPROM_REG_BL1 (1 << 1)
  111. #define DS2780_EEPROM_REG_BL0 (1 << 0)
  112. extern int w1_ds2780_io(struct device *dev, char *buf, int addr, size_t count,
  113. int io);
  114. extern int w1_ds2780_eeprom_cmd(struct device *dev, int addr, int cmd);
  115. #endif /* !_W1_DS2780_H */