ade7759.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef _ADE7759_H
  2. #define _ADE7759_H
  3. #define ADE7759_WAVEFORM 0x01
  4. #define ADE7759_AENERGY 0x02
  5. #define ADE7759_RSTENERGY 0x03
  6. #define ADE7759_STATUS 0x04
  7. #define ADE7759_RSTSTATUS 0x05
  8. #define ADE7759_MODE 0x06
  9. #define ADE7759_CFDEN 0x07
  10. #define ADE7759_CH1OS 0x08
  11. #define ADE7759_CH2OS 0x09
  12. #define ADE7759_GAIN 0x0A
  13. #define ADE7759_APGAIN 0x0B
  14. #define ADE7759_PHCAL 0x0C
  15. #define ADE7759_APOS 0x0D
  16. #define ADE7759_ZXTOUT 0x0E
  17. #define ADE7759_SAGCYC 0x0F
  18. #define ADE7759_IRQEN 0x10
  19. #define ADE7759_SAGLVL 0x11
  20. #define ADE7759_TEMP 0x12
  21. #define ADE7759_LINECYC 0x13
  22. #define ADE7759_LENERGY 0x14
  23. #define ADE7759_CFNUM 0x15
  24. #define ADE7759_CHKSUM 0x1E
  25. #define ADE7759_DIEREV 0x1F
  26. #define ADE7759_READ_REG(a) a
  27. #define ADE7759_WRITE_REG(a) ((a) | 0x80)
  28. #define ADE7759_MAX_TX 6
  29. #define ADE7759_MAX_RX 6
  30. #define ADE7759_STARTUP_DELAY 1
  31. #define ADE7759_SPI_SLOW (u32)(300 * 1000)
  32. #define ADE7759_SPI_BURST (u32)(1000 * 1000)
  33. #define ADE7759_SPI_FAST (u32)(2000 * 1000)
  34. /**
  35. * struct ade7759_state - device instance specific data
  36. * @us: actual spi_device
  37. * @buf_lock: mutex to protect tx and rx
  38. * @tx: transmit buffer
  39. * @rx: receive buffer
  40. **/
  41. struct ade7759_state {
  42. struct spi_device *us;
  43. struct mutex buf_lock;
  44. u8 tx[ADE7759_MAX_TX] ____cacheline_aligned;
  45. u8 rx[ADE7759_MAX_RX];
  46. };
  47. #endif