adc.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * adc.h -- Driver for NXP PCF50633 ADC
  3. *
  4. * (C) 2006-2008 by Openmoko, Inc.
  5. * All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. */
  12. #ifndef __LINUX_MFD_PCF50633_ADC_H
  13. #define __LINUX_MFD_PCF50633_ADC_H
  14. #include <linux/mfd/pcf50633/core.h>
  15. #include <linux/platform_device.h>
  16. /* ADC Registers */
  17. #define PCF50633_REG_ADCC3 0x52
  18. #define PCF50633_REG_ADCC2 0x53
  19. #define PCF50633_REG_ADCC1 0x54
  20. #define PCF50633_REG_ADCS1 0x55
  21. #define PCF50633_REG_ADCS2 0x56
  22. #define PCF50633_REG_ADCS3 0x57
  23. #define PCF50633_ADCC1_ADCSTART 0x01
  24. #define PCF50633_ADCC1_RES_8BIT 0x02
  25. #define PCF50633_ADCC1_RES_10BIT 0x00
  26. #define PCF50633_ADCC1_AVERAGE_NO 0x00
  27. #define PCF50633_ADCC1_AVERAGE_4 0x04
  28. #define PCF50633_ADCC1_AVERAGE_8 0x08
  29. #define PCF50633_ADCC1_AVERAGE_16 0x0c
  30. #define PCF50633_ADCC1_MUX_BATSNS_RES 0x00
  31. #define PCF50633_ADCC1_MUX_BATSNS_SUBTR 0x10
  32. #define PCF50633_ADCC1_MUX_ADCIN2_RES 0x20
  33. #define PCF50633_ADCC1_MUX_ADCIN2_SUBTR 0x30
  34. #define PCF50633_ADCC1_MUX_BATTEMP 0x60
  35. #define PCF50633_ADCC1_MUX_ADCIN1 0x70
  36. #define PCF50633_ADCC1_AVERAGE_MASK 0x0c
  37. #define PCF50633_ADCC1_ADCMUX_MASK 0xf0
  38. #define PCF50633_ADCC2_RATIO_NONE 0x00
  39. #define PCF50633_ADCC2_RATIO_BATTEMP 0x01
  40. #define PCF50633_ADCC2_RATIO_ADCIN1 0x02
  41. #define PCF50633_ADCC2_RATIO_BOTH 0x03
  42. #define PCF50633_ADCC2_RATIOSETTL_100US 0x04
  43. #define PCF50633_ADCC3_ACCSW_EN 0x01
  44. #define PCF50633_ADCC3_NTCSW_EN 0x04
  45. #define PCF50633_ADCC3_RES_DIV_TWO 0x10
  46. #define PCF50633_ADCC3_RES_DIV_THREE 0x00
  47. #define PCF50633_ADCS3_REF_NTCSW 0x00
  48. #define PCF50633_ADCS3_REF_ACCSW 0x10
  49. #define PCF50633_ADCS3_REF_2V0 0x20
  50. #define PCF50633_ADCS3_REF_VISA 0x30
  51. #define PCF50633_ADCS3_REF_2V0_2 0x70
  52. #define PCF50633_ADCS3_ADCRDY 0x80
  53. #define PCF50633_ADCS3_ADCDAT1L_MASK 0x03
  54. #define PCF50633_ADCS3_ADCDAT2L_MASK 0x0c
  55. #define PCF50633_ADCS3_ADCDAT2L_SHIFT 2
  56. #define PCF50633_ASCS3_REF_MASK 0x70
  57. extern int
  58. pcf50633_adc_async_read(struct pcf50633 *pcf, int mux, int avg,
  59. void (*callback)(struct pcf50633 *, void *, int),
  60. void *callback_param);
  61. extern int
  62. pcf50633_adc_sync_read(struct pcf50633 *pcf, int mux, int avg);
  63. #endif /* __LINUX_PCF50633_ADC_H */