aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-powerpc/smu.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-powerpc/smu.h')
-rw-r--r--include/asm-powerpc/smu.h199
1 files changed, 195 insertions, 4 deletions
diff --git a/include/asm-powerpc/smu.h b/include/asm-powerpc/smu.h
index dee8eefe47bc..76c29a9784dd 100644
--- a/include/asm-powerpc/smu.h
+++ b/include/asm-powerpc/smu.h
@@ -20,16 +20,52 @@
20/* 20/*
21 * Partition info commands 21 * Partition info commands
22 * 22 *
23 * I do not know what those are for at this point 23 * These commands are used to retreive the sdb-partition-XX datas from
24 * the SMU. The lenght is always 2. First byte is the subcommand code
25 * and second byte is the partition ID.
26 *
27 * The reply is 6 bytes:
28 *
29 * - 0..1 : partition address
30 * - 2 : a byte containing the partition ID
31 * - 3 : length (maybe other bits are rest of header ?)
32 *
33 * The data must then be obtained with calls to another command:
34 * SMU_CMD_MISC_ee_GET_DATABLOCK_REC (described below).
24 */ 35 */
25#define SMU_CMD_PARTITION_COMMAND 0x3e 36#define SMU_CMD_PARTITION_COMMAND 0x3e
37#define SMU_CMD_PARTITION_LATEST 0x01
38#define SMU_CMD_PARTITION_BASE 0x02
39#define SMU_CMD_PARTITION_UPDATE 0x03
26 40
27 41
28/* 42/*
29 * Fan control 43 * Fan control
30 * 44 *
31 * This is a "mux" for fan control commands, first byte is the 45 * This is a "mux" for fan control commands. The command seem to
32 * "sub" command. 46 * act differently based on the number of arguments. With 1 byte
47 * of argument, this seem to be queries for fans status, setpoint,
48 * etc..., while with 0xe arguments, we will set the fans speeds.
49 *
50 * Queries (1 byte arg):
51 * ---------------------
52 *
53 * arg=0x01: read RPM fans status
54 * arg=0x02: read RPM fans setpoint
55 * arg=0x11: read PWM fans status
56 * arg=0x12: read PWM fans setpoint
57 *
58 * the "status" queries return the current speed while the "setpoint" ones
59 * return the programmed/target speed. It _seems_ that the result is a bit
60 * mask in the first byte of active/available fans, followed by 6 words (16
61 * bits) containing the requested speed.
62 *
63 * Setpoint (14 bytes arg):
64 * ------------------------
65 *
66 * first arg byte is 0 for RPM fans and 0x10 for PWM. Second arg byte is the
67 * mask of fans affected by the command. Followed by 6 words containing the
68 * setpoint value for selected fans in the mask (or 0 if mask value is 0)
33 */ 69 */
34#define SMU_CMD_FAN_COMMAND 0x4a 70#define SMU_CMD_FAN_COMMAND 0x4a
35 71
@@ -144,7 +180,11 @@
144 * - lenght 8 ("VSLEWxyz") has 3 additional bytes appended, and is 180 * - lenght 8 ("VSLEWxyz") has 3 additional bytes appended, and is
145 * used to set the voltage slewing point. The SMU replies with "DONE" 181 * used to set the voltage slewing point. The SMU replies with "DONE"
146 * I yet have to figure out their exact meaning of those 3 bytes in 182 * I yet have to figure out their exact meaning of those 3 bytes in
147 * both cases. 183 * both cases. They seem to be:
184 * x = processor mask
185 * y = op. point index
186 * z = processor freq. step index
187 * I haven't yet decyphered result codes
148 * 188 *
149 */ 189 */
150#define SMU_CMD_POWER_COMMAND 0xaa 190#define SMU_CMD_POWER_COMMAND 0xaa
@@ -152,6 +192,14 @@
152#define SMU_CMD_POWER_SHUTDOWN "SHUTDOWN" 192#define SMU_CMD_POWER_SHUTDOWN "SHUTDOWN"
153#define SMU_CMD_POWER_VOLTAGE_SLEW "VSLEW" 193#define SMU_CMD_POWER_VOLTAGE_SLEW "VSLEW"
154 194
195/*
196 * Read ADC sensors
197 *
198 * This command takes one byte of parameter: the sensor ID (or "reg"
199 * value in the device-tree) and returns a 16 bits value
200 */
201#define SMU_CMD_READ_ADC 0xd8
202
155/* Misc commands 203/* Misc commands
156 * 204 *
157 * This command seem to be a grab bag of various things 205 * This command seem to be a grab bag of various things
@@ -172,6 +220,25 @@
172 * Misc commands 220 * Misc commands
173 * 221 *
174 * This command seem to be a grab bag of various things 222 * This command seem to be a grab bag of various things
223 *
224 * SMU_CMD_MISC_ee_GET_DATABLOCK_REC is used, among others, to
225 * transfer blocks of data from the SMU. So far, I've decrypted it's
226 * usage to retreive partition data. In order to do that, you have to
227 * break your transfer in "chunks" since that command cannot transfer
228 * more than a chunk at a time. The chunk size used by OF is 0xe bytes,
229 * but it seems that the darwin driver will let you do 0x1e bytes if
230 * your "PMU" version is >= 0x30. You can get the "PMU" version apparently
231 * either in the last 16 bits of property "smu-version-pmu" or as the 16
232 * bytes at offset 1 of "smu-version-info"
233 *
234 * For each chunk, the command takes 7 bytes of arguments:
235 * byte 0: subcommand code (0x02)
236 * byte 1: 0x04 (always, I don't know what it means, maybe the address
237 * space to use or some other nicety. It's hard coded in OF)
238 * byte 2..5: SMU address of the chunk (big endian 32 bits)
239 * byte 6: size to transfer (up to max chunk size)
240 *
241 * The data is returned directly
175 */ 242 */
176#define SMU_CMD_MISC_ee_COMMAND 0xee 243#define SMU_CMD_MISC_ee_COMMAND 0xee
177#define SMU_CMD_MISC_ee_GET_DATABLOCK_REC 0x02 244#define SMU_CMD_MISC_ee_GET_DATABLOCK_REC 0x02
@@ -333,6 +400,128 @@ extern int smu_queue_i2c(struct smu_i2c_cmd *cmd);
333 400
334#endif /* __KERNEL__ */ 401#endif /* __KERNEL__ */
335 402
403
404/*
405 * - SMU "sdb" partitions informations -
406 */
407
408
409/*
410 * Partition header format
411 */
412struct smu_sdbp_header {
413 __u8 id;
414 __u8 len;
415 __u8 version;
416 __u8 flags;
417};
418
419
420 /*
421 * demangle 16 and 32 bits integer in some SMU partitions
422 * (currently, afaik, this concerns only the FVT partition
423 * (0x12)
424 */
425#define SMU_U16_MIX(x) le16_to_cpu(x);
426#define SMU_U32_MIX(x) ((((x) & 0xff00ff00u) >> 8)|(((x) & 0x00ff00ffu) << 8))
427
428
429/* This is the definition of the SMU sdb-partition-0x12 table (called
430 * CPU F/V/T operating points in Darwin). The definition for all those
431 * SMU tables should be moved to some separate file
432 */
433#define SMU_SDB_FVT_ID 0x12
434
435struct smu_sdbp_fvt {
436 __u32 sysclk; /* Base SysClk frequency in Hz for
437 * this operating point. Value need to
438 * be unmixed with SMU_U32_MIX()
439 */
440 __u8 pad;
441 __u8 maxtemp; /* Max temp. supported by this
442 * operating point
443 */
444
445 __u16 volts[3]; /* CPU core voltage for the 3
446 * PowerTune modes, a mode with
447 * 0V = not supported. Value need
448 * to be unmixed with SMU_U16_MIX()
449 */
450};
451
452/* This partition contains voltage & current sensor calibration
453 * informations
454 */
455#define SMU_SDB_CPUVCP_ID 0x21
456
457struct smu_sdbp_cpuvcp {
458 __u16 volt_scale; /* u4.12 fixed point */
459 __s16 volt_offset; /* s4.12 fixed point */
460 __u16 curr_scale; /* u4.12 fixed point */
461 __s16 curr_offset; /* s4.12 fixed point */
462 __s32 power_quads[3]; /* s4.28 fixed point */
463};
464
465/* This partition contains CPU thermal diode calibration
466 */
467#define SMU_SDB_CPUDIODE_ID 0x18
468
469struct smu_sdbp_cpudiode {
470 __u16 m_value; /* u1.15 fixed point */
471 __s16 b_value; /* s10.6 fixed point */
472
473};
474
475/* This partition contains Slots power calibration
476 */
477#define SMU_SDB_SLOTSPOW_ID 0x78
478
479struct smu_sdbp_slotspow {
480 __u16 pow_scale; /* u4.12 fixed point */
481 __s16 pow_offset; /* s4.12 fixed point */
482};
483
484/* This partition contains machine specific version information about
485 * the sensor/control layout
486 */
487#define SMU_SDB_SENSORTREE_ID 0x25
488
489struct smu_sdbp_sensortree {
490 u8 model_id;
491 u8 unknown[3];
492};
493
494/* This partition contains CPU thermal control PID informations. So far
495 * only single CPU machines have been seen with an SMU, so we assume this
496 * carries only informations for those
497 */
498#define SMU_SDB_CPUPIDDATA_ID 0x17
499
500struct smu_sdbp_cpupiddata {
501 u8 unknown1;
502 u8 target_temp_delta;
503 u8 unknown2;
504 u8 history_len;
505 s16 power_adj;
506 u16 max_power;
507 s32 gp,gr,gd;
508};
509
510
511/* Other partitions without known structures */
512#define SMU_SDB_DEBUG_SWITCHES_ID 0x05
513
514#ifdef __KERNEL__
515/*
516 * This returns the pointer to an SMU "sdb" partition data or NULL
517 * if not found. The data format is described below
518 */
519extern struct smu_sdbp_header *smu_get_sdb_partition(int id,
520 unsigned int *size);
521
522#endif /* __KERNEL__ */
523
524
336/* 525/*
337 * - Userland interface - 526 * - Userland interface -
338 */ 527 */
@@ -365,8 +554,10 @@ struct smu_user_cmd_hdr
365 __u32 cmdtype; 554 __u32 cmdtype;
366#define SMU_CMDTYPE_SMU 0 /* SMU command */ 555#define SMU_CMDTYPE_SMU 0 /* SMU command */
367#define SMU_CMDTYPE_WANTS_EVENTS 1 /* switch fd to events mode */ 556#define SMU_CMDTYPE_WANTS_EVENTS 1 /* switch fd to events mode */
557#define SMU_CMDTYPE_GET_PARTITION 2 /* retreive an sdb partition */
368 558
369 __u8 cmd; /* SMU command byte */ 559 __u8 cmd; /* SMU command byte */
560 __u8 pad[3]; /* padding */
370 __u32 data_len; /* Lenght of data following */ 561 __u32 data_len; /* Lenght of data following */
371}; 562};
372 563