ee_dev.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* By Thomas.Lange@Corelatus.com 001025
  2. $Revision: 1.6 $
  3. Definitions for EEPROM/VOLT METER DS2438
  4. Copyright (C) 2000-2001 Corelatus AB */
  5. #ifndef INCeedevh
  6. #define INCeedevh
  7. #define E_DEBUG(fmt,args...) if( Debug ) printk(KERN_DEBUG"EE: " fmt, ##args)
  8. #define PORT_B_PAR ((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbpar
  9. #define PORT_B_ODR ((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbodr
  10. #define PORT_B_DIR ((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdir
  11. #define PORT_B_DAT ((volatile immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat
  12. #define SET_PORT_B_INPUT(Mask) PORT_B_DIR &= ~(Mask)
  13. #define SET_PORT_B_OUTPUT(Mask) PORT_B_DIR |= Mask
  14. #define WRITE_PORT_B(Mask,Value) { \
  15. if (Value) PORT_B_DAT |= Mask; \
  16. else PORT_B_DAT &= ~(Mask); \
  17. }
  18. #define WRITE_PORT(Value) WRITE_PORT_B(PB_EEPROM,Value)
  19. #define READ_PORT (PORT_B_DAT&PB_EEPROM)
  20. /* 64 bytes chip */
  21. #define EE_CHIP_SIZE 64
  22. /* We use this resistor for measuring the current drain on 3.3V */
  23. #define CURRENT_RESISTOR 0.022
  24. /* microsecs
  25. Pull line down at least this long for reset pulse */
  26. #define RESET_LOW_TIME 490
  27. /* Read presence pulse after we release reset pulse */
  28. #define PRESENCE_TIMEOUT 100
  29. #define PRESENCE_LOW_TIME 200
  30. #define WRITE_0_LOW 80
  31. #define WRITE_1_LOW 2
  32. #define TOTAL_WRITE_LOW 80
  33. #define READ_LOW 2
  34. #define READ_TIMEOUT 10
  35. #define TOTAL_READ_LOW 80
  36. /*** Rom function commands ***/
  37. #define READ_ROM 0x33
  38. #define MATCH_ROM 0x55
  39. #define SKIP_ROM 0xCC
  40. #define SEARCH_ROM 0xF0
  41. /*** Memory_command_function ***/
  42. #define WRITE_SCRATCHPAD 0x4E
  43. #define READ_SCRATCHPAD 0xBE
  44. #define COPY_SCRATCHPAD 0x48
  45. #define RECALL_MEMORY 0xB8
  46. #define CONVERT_TEMP 0x44
  47. #define CONVERT_VOLTAGE 0xB4
  48. /* Chip is divided in 8 pages, 8 bytes each */
  49. #define EE_PAGE_SIZE 8
  50. /* All chip data we want are in page 0 */
  51. /* Bytes in page 0 */
  52. #define EE_P0_STATUS 0
  53. #define EE_P0_TEMP_LSB 1
  54. #define EE_P0_TEMP_MSB 2
  55. #define EE_P0_VOLT_LSB 3
  56. #define EE_P0_VOLT_MSB 4
  57. #define EE_P0_CURRENT_LSB 5
  58. #define EE_P0_CURRENT_MSB 6
  59. /* 40 byte user data is located at page 3-7 */
  60. #define EE_USER_PAGE_0 3
  61. #define USER_PAGES 5
  62. #endif /* INCeedevh */