w1_ds2780.h 3.9 KB

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