windfarm_mpu.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Windfarm PowerMac thermal control
  3. *
  4. * Copyright 2012 Benjamin Herrenschmidt, IBM Corp.
  5. *
  6. * Released under the term of the GNU GPL v2.
  7. */
  8. #ifndef __WINDFARM_MPU_H
  9. #define __WINDFARM_MPU_H
  10. typedef unsigned short fu16;
  11. typedef int fs32;
  12. typedef short fs16;
  13. /* Definition of the MPU data structure which contains per CPU
  14. * calibration information (among others) for the G5 machines
  15. */
  16. struct mpu_data
  17. {
  18. u8 signature; /* 0x00 - EEPROM sig. */
  19. u8 bytes_used; /* 0x01 - Bytes used in eeprom (160 ?) */
  20. u8 size; /* 0x02 - EEPROM size (256 ?) */
  21. u8 version; /* 0x03 - EEPROM version */
  22. u32 data_revision; /* 0x04 - Dataset revision */
  23. u8 processor_bin_code[3]; /* 0x08 - Processor BIN code */
  24. u8 bin_code_expansion; /* 0x0b - ??? (padding ?) */
  25. u8 processor_num; /* 0x0c - Number of CPUs on this MPU */
  26. u8 input_mul_bus_div; /* 0x0d - Clock input multiplier/bus divider */
  27. u8 reserved1[2]; /* 0x0e - */
  28. u32 input_clk_freq_high; /* 0x10 - Input clock frequency high */
  29. u8 cpu_nb_target_cycles; /* 0x14 - ??? */
  30. u8 cpu_statlat; /* 0x15 - ??? */
  31. u8 cpu_snooplat; /* 0x16 - ??? */
  32. u8 cpu_snoopacc; /* 0x17 - ??? */
  33. u8 nb_paamwin; /* 0x18 - ??? */
  34. u8 nb_statlat; /* 0x19 - ??? */
  35. u8 nb_snooplat; /* 0x1a - ??? */
  36. u8 nb_snoopwin; /* 0x1b - ??? */
  37. u8 api_bus_mode; /* 0x1c - ??? */
  38. u8 reserved2[3]; /* 0x1d - */
  39. u32 input_clk_freq_low; /* 0x20 - Input clock frequency low */
  40. u8 processor_card_slot; /* 0x24 - Processor card slot number */
  41. u8 reserved3[2]; /* 0x25 - */
  42. u8 padjmax; /* 0x27 - Max power adjustment (Not in OF!) */
  43. u8 ttarget; /* 0x28 - Target temperature */
  44. u8 tmax; /* 0x29 - Max temperature */
  45. u8 pmaxh; /* 0x2a - Max power */
  46. u8 tguardband; /* 0x2b - Guardband temp ??? Hist. len in OSX */
  47. fs32 pid_gp; /* 0x2c - PID proportional gain */
  48. fs32 pid_gr; /* 0x30 - PID reset gain */
  49. fs32 pid_gd; /* 0x34 - PID derivative gain */
  50. fu16 voph; /* 0x38 - Vop High */
  51. fu16 vopl; /* 0x3a - Vop Low */
  52. fs16 nactual_die; /* 0x3c - nActual Die */
  53. fs16 nactual_heatsink; /* 0x3e - nActual Heatsink */
  54. fs16 nactual_system; /* 0x40 - nActual System */
  55. u16 calibration_flags; /* 0x42 - Calibration flags */
  56. fu16 mdiode; /* 0x44 - Diode M value (scaling factor) */
  57. fs16 bdiode; /* 0x46 - Diode B value (offset) */
  58. fs32 theta_heat_sink; /* 0x48 - Theta heat sink */
  59. u16 rminn_intake_fan; /* 0x4c - Intake fan min RPM */
  60. u16 rmaxn_intake_fan; /* 0x4e - Intake fan max RPM */
  61. u16 rminn_exhaust_fan; /* 0x50 - Exhaust fan min RPM */
  62. u16 rmaxn_exhaust_fan; /* 0x52 - Exhaust fan max RPM */
  63. u8 processor_part_num[8]; /* 0x54 - Processor part number XX pumps min/max */
  64. u32 processor_lot_num; /* 0x5c - Processor lot number */
  65. u8 orig_card_sernum[0x10]; /* 0x60 - Card original serial number */
  66. u8 curr_card_sernum[0x10]; /* 0x70 - Card current serial number */
  67. u8 mlb_sernum[0x18]; /* 0x80 - MLB serial number */
  68. u32 checksum1; /* 0x98 - */
  69. u32 checksum2; /* 0x9c - */
  70. }; /* Total size = 0xa0 */
  71. static inline const struct mpu_data *wf_get_mpu(int cpu)
  72. {
  73. struct device_node *np;
  74. char nodename[64];
  75. const void *data;
  76. int len;
  77. /*
  78. * prom.c routine for finding a node by path is a bit brain dead
  79. * and requires exact @xxx unit numbers. This is a bit ugly but
  80. * will work for these machines
  81. */
  82. sprintf(nodename, "/u3@0,f8000000/i2c@f8001000/cpuid@a%d", cpu ? 2 : 0);
  83. np = of_find_node_by_path(nodename);
  84. if (!np)
  85. return NULL;
  86. data = of_get_property(np, "cpuid", &len);
  87. of_node_put(np);
  88. if (!data)
  89. return NULL;
  90. /*
  91. * We are naughty, we have dropped the reference to the device
  92. * node and still return a pointer to the content. We know we
  93. * can do that though as this is only ever called on PowerMac
  94. * which cannot remove those nodes
  95. */
  96. return data;
  97. }
  98. #endif /* __WINDFARM_MPU_H */