UDM-hwmon.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. The U-Boot Driver Model Project
  2. ===============================
  3. Hwmon device subsystem analysis
  4. ===============================
  5. Tomas Hlavacek <tmshlvck@gmail.com>
  6. 2012-03-02
  7. I) Overview
  8. -----------
  9. U-Boot currently implements one API for HW monitoring devices. The
  10. interface is defined in include/dtt.h and comprises of functions:
  11. void dtt_init(void);
  12. int dtt_init_one(int);
  13. int dtt_read(int sensor, int reg);
  14. int dtt_write(int sensor, int reg, int val);
  15. int dtt_get_temp(int sensor);
  16. The functions are implemented by a proper device driver in drivers/hwmon
  17. directory and the driver to be compiled in is selected in a Makefile.
  18. Drivers are mutually exclusive.
  19. Drivers depends on I2O code and naturally on board specific data. There are
  20. few ad-hoc constants put in dtt.h file and driver headers and code. This
  21. has to be consolidated into board specific data or driver headers if those
  22. constants makes sense globally.
  23. II) Approach
  24. ------------
  25. 1) New API
  26. ----------
  27. In the UDM each hwmon driver would register itself by a function
  28. int hwmon_device_register(struct instance *i,
  29. struct hwmon_device_ops *o);
  30. The structure being defined as follows:
  31. struct hwmon_device_ops {
  32. int (*read)(struct instance *i, int sensor, int reg);
  33. int (*write)(struct instance *i, int sensor, int reg,
  34. int val);
  35. int (*get_temp)(struct instance *i, int sensor);
  36. };
  37. 2) Conversion thougths
  38. ----------------------
  39. U-Boot hwmon drivers exports virtually the same functions (with exceptions)
  40. and we are considering low number of drivers and code anyway. The interface
  41. is already similar and unified by the interface defined in dtt.h.
  42. Current initialization functions dtt_init() and dtt_init_one() will be
  43. converted into probe() and hwmon_device_register(), so the funcionality will
  44. be kept in more proper places. Besides implementing core registration and
  45. initialization we need to do code cleanup, especially separate
  46. driver-specific and HW specific constants.
  47. 3) Special consideration due to early initialization
  48. ----------------------------------------------------
  49. The dtt_init() function call is used during early initialization in
  50. board/gdsys/405ex/io64.c for starting up fans. The dtt code is perfectly
  51. usable in the early stage because it uses only local variables and no heap
  52. memory is required at this level. However the underlying code of I2C has to
  53. keep the same properties with regard to possibility of running in early
  54. initialization stage.
  55. III) Analysis of in-tree drivers
  56. --------------------------------
  57. 1) drivers/hwmon/lm81.c
  58. -----------------------
  59. The driver is standard dtt. Simple conversion is possible.
  60. 2) drivers/hwmon/ds1722.c
  61. -------------------------
  62. The driver is not standard dtt, but interface is similar to dtt.
  63. The interface has to be changed in order to comply to above mentioned
  64. specification.
  65. 3) drivers/hwmon/ds1775.c
  66. -------------------------
  67. The driver is standard dtt. Simple conversion is possible.
  68. 4) drivers/hwmon/lm73.c
  69. -----------------------
  70. The driver is standard dtt. Simple conversion is possible.
  71. 5) drivers/hwmon/lm63.c
  72. -----------------------
  73. The driver is standard dtt. Simple conversion is possible.
  74. 6) drivers/hwmon/adt7460.c
  75. --------------------------
  76. The driver is standard dtt. Simple conversion is possible.
  77. 7) drivers/hwmon/lm75.c
  78. -----------------------
  79. The driver is standard dtt. Simple conversion is possible.
  80. 8) drivers/hwmon/ds1621.c
  81. -------------------------
  82. The driver is standard dtt. Simple conversion is possible.
  83. 9) drivers/hwmon/adm1021.c
  84. --------------------------
  85. The driver is standard dtt. Simple conversion is possible.