smu.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. #ifndef _SMU_H
  2. #define _SMU_H
  3. /*
  4. * Definitions for talking to the SMU chip in newer G5 PowerMacs
  5. */
  6. #ifdef __KERNEL__
  7. #include <linux/list.h>
  8. #endif
  9. #include <linux/types.h>
  10. /*
  11. * Known SMU commands
  12. *
  13. * Most of what is below comes from looking at the Open Firmware driver,
  14. * though this is still incomplete and could use better documentation here
  15. * or there...
  16. */
  17. /*
  18. * Partition info commands
  19. *
  20. * These commands are used to retrieve the sdb-partition-XX datas from
  21. * the SMU. The length is always 2. First byte is the subcommand code
  22. * and second byte is the partition ID.
  23. *
  24. * The reply is 6 bytes:
  25. *
  26. * - 0..1 : partition address
  27. * - 2 : a byte containing the partition ID
  28. * - 3 : length (maybe other bits are rest of header ?)
  29. *
  30. * The data must then be obtained with calls to another command:
  31. * SMU_CMD_MISC_ee_GET_DATABLOCK_REC (described below).
  32. */
  33. #define SMU_CMD_PARTITION_COMMAND 0x3e
  34. #define SMU_CMD_PARTITION_LATEST 0x01
  35. #define SMU_CMD_PARTITION_BASE 0x02
  36. #define SMU_CMD_PARTITION_UPDATE 0x03
  37. /*
  38. * Fan control
  39. *
  40. * This is a "mux" for fan control commands. The command seem to
  41. * act differently based on the number of arguments. With 1 byte
  42. * of argument, this seem to be queries for fans status, setpoint,
  43. * etc..., while with 0xe arguments, we will set the fans speeds.
  44. *
  45. * Queries (1 byte arg):
  46. * ---------------------
  47. *
  48. * arg=0x01: read RPM fans status
  49. * arg=0x02: read RPM fans setpoint
  50. * arg=0x11: read PWM fans status
  51. * arg=0x12: read PWM fans setpoint
  52. *
  53. * the "status" queries return the current speed while the "setpoint" ones
  54. * return the programmed/target speed. It _seems_ that the result is a bit
  55. * mask in the first byte of active/available fans, followed by 6 words (16
  56. * bits) containing the requested speed.
  57. *
  58. * Setpoint (14 bytes arg):
  59. * ------------------------
  60. *
  61. * first arg byte is 0 for RPM fans and 0x10 for PWM. Second arg byte is the
  62. * mask of fans affected by the command. Followed by 6 words containing the
  63. * setpoint value for selected fans in the mask (or 0 if mask value is 0)
  64. */
  65. #define SMU_CMD_FAN_COMMAND 0x4a
  66. /*
  67. * Battery access
  68. *
  69. * Same command number as the PMU, could it be same syntax ?
  70. */
  71. #define SMU_CMD_BATTERY_COMMAND 0x6f
  72. #define SMU_CMD_GET_BATTERY_INFO 0x00
  73. /*
  74. * Real time clock control
  75. *
  76. * This is a "mux", first data byte contains the "sub" command.
  77. * The "RTC" part of the SMU controls the date, time, powerup
  78. * timer, but also a PRAM
  79. *
  80. * Dates are in BCD format on 7 bytes:
  81. * [sec] [min] [hour] [weekday] [month day] [month] [year]
  82. * with month being 1 based and year minus 100
  83. */
  84. #define SMU_CMD_RTC_COMMAND 0x8e
  85. #define SMU_CMD_RTC_SET_PWRUP_TIMER 0x00 /* i: 7 bytes date */
  86. #define SMU_CMD_RTC_GET_PWRUP_TIMER 0x01 /* o: 7 bytes date */
  87. #define SMU_CMD_RTC_STOP_PWRUP_TIMER 0x02
  88. #define SMU_CMD_RTC_SET_PRAM_BYTE_ACC 0x20 /* i: 1 byte (address?) */
  89. #define SMU_CMD_RTC_SET_PRAM_AUTOINC 0x21 /* i: 1 byte (data?) */
  90. #define SMU_CMD_RTC_SET_PRAM_LO_BYTES 0x22 /* i: 10 bytes */
  91. #define SMU_CMD_RTC_SET_PRAM_HI_BYTES 0x23 /* i: 10 bytes */
  92. #define SMU_CMD_RTC_GET_PRAM_BYTE 0x28 /* i: 1 bytes (address?) */
  93. #define SMU_CMD_RTC_GET_PRAM_LO_BYTES 0x29 /* o: 10 bytes */
  94. #define SMU_CMD_RTC_GET_PRAM_HI_BYTES 0x2a /* o: 10 bytes */
  95. #define SMU_CMD_RTC_SET_DATETIME 0x80 /* i: 7 bytes date */
  96. #define SMU_CMD_RTC_GET_DATETIME 0x81 /* o: 7 bytes date */
  97. /*
  98. * i2c commands
  99. *
  100. * To issue an i2c command, first is to send a parameter block to the
  101. * the SMU. This is a command of type 0x9a with 9 bytes of header
  102. * eventually followed by data for a write:
  103. *
  104. * 0: bus number (from device-tree usually, SMU has lots of busses !)
  105. * 1: transfer type/format (see below)
  106. * 2: device address. For combined and combined4 type transfers, this
  107. * is the "write" version of the address (bit 0x01 cleared)
  108. * 3: subaddress length (0..3)
  109. * 4: subaddress byte 0 (or only byte for subaddress length 1)
  110. * 5: subaddress byte 1
  111. * 6: subaddress byte 2
  112. * 7: combined address (device address for combined mode data phase)
  113. * 8: data length
  114. *
  115. * The transfer types are the same good old Apple ones it seems,
  116. * that is:
  117. * - 0x00: Simple transfer
  118. * - 0x01: Subaddress transfer (addr write + data tx, no restart)
  119. * - 0x02: Combined transfer (addr write + restart + data tx)
  120. *
  121. * This is then followed by actual data for a write.
  122. *
  123. * At this point, the OF driver seems to have a limitation on transfer
  124. * sizes of 0xd bytes on reads and 0x5 bytes on writes. I do not know
  125. * whether this is just an OF limit due to some temporary buffer size
  126. * or if this is an SMU imposed limit. This driver has the same limitation
  127. * for now as I use a 0x10 bytes temporary buffer as well
  128. *
  129. * Once that is completed, a response is expected from the SMU. This is
  130. * obtained via a command of type 0x9a with a length of 1 byte containing
  131. * 0 as the data byte. OF also fills the rest of the data buffer with 0xff's
  132. * though I can't tell yet if this is actually necessary. Once this command
  133. * is complete, at this point, all I can tell is what OF does. OF tests
  134. * byte 0 of the reply:
  135. * - on read, 0xfe or 0xfc : bus is busy, wait (see below) or nak ?
  136. * - on read, 0x00 or 0x01 : reply is in buffer (after the byte 0)
  137. * - on write, < 0 -> failure (immediate exit)
  138. * - else, OF just exists (without error, weird)
  139. *
  140. * So on read, there is this wait-for-busy thing when getting a 0xfc or
  141. * 0xfe result. OF does a loop of up to 64 retries, waiting 20ms and
  142. * doing the above again until either the retries expire or the result
  143. * is no longer 0xfe or 0xfc
  144. *
  145. * The Darwin I2C driver is less subtle though. On any non-success status
  146. * from the response command, it waits 5ms and tries again up to 20 times,
  147. * it doesn't differentiate between fatal errors or "busy" status.
  148. *
  149. * This driver provides an asynchronous paramblock based i2c command
  150. * interface to be used either directly by low level code or by a higher
  151. * level driver interfacing to the linux i2c layer. The current
  152. * implementation of this relies on working timers & timer interrupts
  153. * though, so be careful of calling context for now. This may be "fixed"
  154. * in the future by adding a polling facility.
  155. */
  156. #define SMU_CMD_I2C_COMMAND 0x9a
  157. /* transfer types */
  158. #define SMU_I2C_TRANSFER_SIMPLE 0x00
  159. #define SMU_I2C_TRANSFER_STDSUB 0x01
  160. #define SMU_I2C_TRANSFER_COMBINED 0x02
  161. /*
  162. * Power supply control
  163. *
  164. * The "sub" command is an ASCII string in the data, the
  165. * data length is that of the string.
  166. *
  167. * The VSLEW command can be used to get or set the voltage slewing.
  168. * - length 5 (only "VSLEW") : it returns "DONE" and 3 bytes of
  169. * reply at data offset 6, 7 and 8.
  170. * - length 8 ("VSLEWxyz") has 3 additional bytes appended, and is
  171. * used to set the voltage slewing point. The SMU replies with "DONE"
  172. * I yet have to figure out their exact meaning of those 3 bytes in
  173. * both cases. They seem to be:
  174. * x = processor mask
  175. * y = op. point index
  176. * z = processor freq. step index
  177. * I haven't yet deciphered result codes
  178. *
  179. */
  180. #define SMU_CMD_POWER_COMMAND 0xaa
  181. #define SMU_CMD_POWER_RESTART "RESTART"
  182. #define SMU_CMD_POWER_SHUTDOWN "SHUTDOWN"
  183. #define SMU_CMD_POWER_VOLTAGE_SLEW "VSLEW"
  184. /*
  185. * Read ADC sensors
  186. *
  187. * This command takes one byte of parameter: the sensor ID (or "reg"
  188. * value in the device-tree) and returns a 16 bits value
  189. */
  190. #define SMU_CMD_READ_ADC 0xd8
  191. /* Misc commands
  192. *
  193. * This command seem to be a grab bag of various things
  194. *
  195. * Parameters:
  196. * 1: subcommand
  197. */
  198. #define SMU_CMD_MISC_df_COMMAND 0xdf
  199. /*
  200. * Sets "system ready" status
  201. *
  202. * I did not yet understand how it exactly works or what it does.
  203. *
  204. * Guessing from OF code, 0x02 activates the display backlight. Apple uses/used
  205. * the same codebase for all OF versions. On PowerBooks, this command would
  206. * enable the backlight. For the G5s, it only activates the front LED. However,
  207. * don't take this for granted.
  208. *
  209. * Parameters:
  210. * 2: status [0x00, 0x01 or 0x02]
  211. */
  212. #define SMU_CMD_MISC_df_SET_DISPLAY_LIT 0x02
  213. /*
  214. * Sets mode of power switch.
  215. *
  216. * What this actually does is not yet known. Maybe it enables some interrupt.
  217. *
  218. * Parameters:
  219. * 2: enable power switch? [0x00 or 0x01]
  220. * 3 (optional): enable nmi? [0x00 or 0x01]
  221. *
  222. * Returns:
  223. * If parameter 2 is 0x00 and parameter 3 is not specified, returns whether
  224. * NMI is enabled. Otherwise unknown.
  225. */
  226. #define SMU_CMD_MISC_df_NMI_OPTION 0x04
  227. /* Sets LED dimm offset.
  228. *
  229. * The front LED dimms itself during sleep. Its brightness (or, well, the PWM
  230. * frequency) depends on current time. Therefore, the SMU needs to know the
  231. * timezone.
  232. *
  233. * Parameters:
  234. * 2-8: unknown (BCD coding)
  235. */
  236. #define SMU_CMD_MISC_df_DIMM_OFFSET 0x99
  237. /*
  238. * Version info commands
  239. *
  240. * Parameters:
  241. * 1 (optional): Specifies version part to retrieve
  242. *
  243. * Returns:
  244. * Version value
  245. */
  246. #define SMU_CMD_VERSION_COMMAND 0xea
  247. #define SMU_VERSION_RUNNING 0x00
  248. #define SMU_VERSION_BASE 0x01
  249. #define SMU_VERSION_UPDATE 0x02
  250. /*
  251. * Switches
  252. *
  253. * These are switches whose status seems to be known to the SMU.
  254. *
  255. * Parameters:
  256. * none
  257. *
  258. * Result:
  259. * Switch bits (ORed, see below)
  260. */
  261. #define SMU_CMD_SWITCHES 0xdc
  262. /* Switches bits */
  263. #define SMU_SWITCH_CASE_CLOSED 0x01
  264. #define SMU_SWITCH_AC_POWER 0x04
  265. #define SMU_SWITCH_POWER_SWITCH 0x08
  266. /*
  267. * Misc commands
  268. *
  269. * This command seem to be a grab bag of various things
  270. *
  271. * SMU_CMD_MISC_ee_GET_DATABLOCK_REC is used, among others, to
  272. * transfer blocks of data from the SMU. So far, I've decrypted it's
  273. * usage to retrieve partition data. In order to do that, you have to
  274. * break your transfer in "chunks" since that command cannot transfer
  275. * more than a chunk at a time. The chunk size used by OF is 0xe bytes,
  276. * but it seems that the darwin driver will let you do 0x1e bytes if
  277. * your "PMU" version is >= 0x30. You can get the "PMU" version apparently
  278. * either in the last 16 bits of property "smu-version-pmu" or as the 16
  279. * bytes at offset 1 of "smu-version-info"
  280. *
  281. * For each chunk, the command takes 7 bytes of arguments:
  282. * byte 0: subcommand code (0x02)
  283. * byte 1: 0x04 (always, I don't know what it means, maybe the address
  284. * space to use or some other nicety. It's hard coded in OF)
  285. * byte 2..5: SMU address of the chunk (big endian 32 bits)
  286. * byte 6: size to transfer (up to max chunk size)
  287. *
  288. * The data is returned directly
  289. */
  290. #define SMU_CMD_MISC_ee_COMMAND 0xee
  291. #define SMU_CMD_MISC_ee_GET_DATABLOCK_REC 0x02
  292. /* Retrieves currently used watts.
  293. *
  294. * Parameters:
  295. * 1: 0x03 (Meaning unknown)
  296. */
  297. #define SMU_CMD_MISC_ee_GET_WATTS 0x03
  298. #define SMU_CMD_MISC_ee_LEDS_CTRL 0x04 /* i: 00 (00,01) [00] */
  299. #define SMU_CMD_MISC_ee_GET_DATA 0x05 /* i: 00 , o: ?? */
  300. /*
  301. * Power related commands
  302. *
  303. * Parameters:
  304. * 1: subcommand
  305. */
  306. #define SMU_CMD_POWER_EVENTS_COMMAND 0x8f
  307. /* SMU_POWER_EVENTS subcommands */
  308. enum {
  309. SMU_PWR_GET_POWERUP_EVENTS = 0x00,
  310. SMU_PWR_SET_POWERUP_EVENTS = 0x01,
  311. SMU_PWR_CLR_POWERUP_EVENTS = 0x02,
  312. SMU_PWR_GET_WAKEUP_EVENTS = 0x03,
  313. SMU_PWR_SET_WAKEUP_EVENTS = 0x04,
  314. SMU_PWR_CLR_WAKEUP_EVENTS = 0x05,
  315. /*
  316. * Get last shutdown cause
  317. *
  318. * Returns:
  319. * 1 byte (signed char): Last shutdown cause. Exact meaning unknown.
  320. */
  321. SMU_PWR_LAST_SHUTDOWN_CAUSE = 0x07,
  322. /*
  323. * Sets or gets server ID. Meaning or use is unknown.
  324. *
  325. * Parameters:
  326. * 2 (optional): Set server ID (1 byte)
  327. *
  328. * Returns:
  329. * 1 byte (server ID?)
  330. */
  331. SMU_PWR_SERVER_ID = 0x08,
  332. };
  333. /* Power events wakeup bits */
  334. enum {
  335. SMU_PWR_WAKEUP_KEY = 0x01, /* Wake on key press */
  336. SMU_PWR_WAKEUP_AC_INSERT = 0x02, /* Wake on AC adapter plug */
  337. SMU_PWR_WAKEUP_AC_CHANGE = 0x04,
  338. SMU_PWR_WAKEUP_LID_OPEN = 0x08,
  339. SMU_PWR_WAKEUP_RING = 0x10,
  340. };
  341. /*
  342. * - Kernel side interface -
  343. */
  344. #ifdef __KERNEL__
  345. /*
  346. * Asynchronous SMU commands
  347. *
  348. * Fill up this structure and submit it via smu_queue_command(),
  349. * and get notified by the optional done() callback, or because
  350. * status becomes != 1
  351. */
  352. struct smu_cmd;
  353. struct smu_cmd
  354. {
  355. /* public */
  356. u8 cmd; /* command */
  357. int data_len; /* data len */
  358. int reply_len; /* reply len */
  359. void *data_buf; /* data buffer */
  360. void *reply_buf; /* reply buffer */
  361. int status; /* command status */
  362. void (*done)(struct smu_cmd *cmd, void *misc);
  363. void *misc;
  364. /* private */
  365. struct list_head link;
  366. };
  367. /*
  368. * Queues an SMU command, all fields have to be initialized
  369. */
  370. extern int smu_queue_cmd(struct smu_cmd *cmd);
  371. /*
  372. * Simple command wrapper. This structure embeds a small buffer
  373. * to ease sending simple SMU commands from the stack
  374. */
  375. struct smu_simple_cmd
  376. {
  377. struct smu_cmd cmd;
  378. u8 buffer[16];
  379. };
  380. /*
  381. * Queues a simple command. All fields will be initialized by that
  382. * function
  383. */
  384. extern int smu_queue_simple(struct smu_simple_cmd *scmd, u8 command,
  385. unsigned int data_len,
  386. void (*done)(struct smu_cmd *cmd, void *misc),
  387. void *misc,
  388. ...);
  389. /*
  390. * Completion helper. Pass it to smu_queue_simple or as 'done'
  391. * member to smu_queue_cmd, it will call complete() on the struct
  392. * completion passed in the "misc" argument
  393. */
  394. extern void smu_done_complete(struct smu_cmd *cmd, void *misc);
  395. /*
  396. * Synchronous helpers. Will spin-wait for completion of a command
  397. */
  398. extern void smu_spinwait_cmd(struct smu_cmd *cmd);
  399. static inline void smu_spinwait_simple(struct smu_simple_cmd *scmd)
  400. {
  401. smu_spinwait_cmd(&scmd->cmd);
  402. }
  403. /*
  404. * Poll routine to call if blocked with irqs off
  405. */
  406. extern void smu_poll(void);
  407. /*
  408. * Init routine, presence check....
  409. */
  410. extern int smu_init(void);
  411. extern int smu_present(void);
  412. struct platform_device;
  413. extern struct platform_device *smu_get_ofdev(void);
  414. /*
  415. * Common command wrappers
  416. */
  417. extern void smu_shutdown(void);
  418. extern void smu_restart(void);
  419. struct rtc_time;
  420. extern int smu_get_rtc_time(struct rtc_time *time, int spinwait);
  421. extern int smu_set_rtc_time(struct rtc_time *time, int spinwait);
  422. /*
  423. * Kernel asynchronous i2c interface
  424. */
  425. #define SMU_I2C_READ_MAX 0x1d
  426. #define SMU_I2C_WRITE_MAX 0x15
  427. /* SMU i2c header, exactly matches i2c header on wire */
  428. struct smu_i2c_param
  429. {
  430. u8 bus; /* SMU bus ID (from device tree) */
  431. u8 type; /* i2c transfer type */
  432. u8 devaddr; /* device address (includes direction) */
  433. u8 sublen; /* subaddress length */
  434. u8 subaddr[3]; /* subaddress */
  435. u8 caddr; /* combined address, filled by SMU driver */
  436. u8 datalen; /* length of transfer */
  437. u8 data[SMU_I2C_READ_MAX]; /* data */
  438. };
  439. struct smu_i2c_cmd
  440. {
  441. /* public */
  442. struct smu_i2c_param info;
  443. void (*done)(struct smu_i2c_cmd *cmd, void *misc);
  444. void *misc;
  445. int status; /* 1 = pending, 0 = ok, <0 = fail */
  446. /* private */
  447. struct smu_cmd scmd;
  448. int read;
  449. int stage;
  450. int retries;
  451. u8 pdata[32];
  452. struct list_head link;
  453. };
  454. /*
  455. * Call this to queue an i2c command to the SMU. You must fill info,
  456. * including info.data for a write, done and misc.
  457. * For now, no polling interface is provided so you have to use completion
  458. * callback.
  459. */
  460. extern int smu_queue_i2c(struct smu_i2c_cmd *cmd);
  461. #endif /* __KERNEL__ */
  462. /*
  463. * - SMU "sdb" partitions informations -
  464. */
  465. /*
  466. * Partition header format
  467. */
  468. struct smu_sdbp_header {
  469. __u8 id;
  470. __u8 len;
  471. __u8 version;
  472. __u8 flags;
  473. };
  474. /*
  475. * demangle 16 and 32 bits integer in some SMU partitions
  476. * (currently, afaik, this concerns only the FVT partition
  477. * (0x12)
  478. */
  479. #define SMU_U16_MIX(x) le16_to_cpu(x)
  480. #define SMU_U32_MIX(x) ((((x) & 0xff00ff00u) >> 8)|(((x) & 0x00ff00ffu) << 8))
  481. /* This is the definition of the SMU sdb-partition-0x12 table (called
  482. * CPU F/V/T operating points in Darwin). The definition for all those
  483. * SMU tables should be moved to some separate file
  484. */
  485. #define SMU_SDB_FVT_ID 0x12
  486. struct smu_sdbp_fvt {
  487. __u32 sysclk; /* Base SysClk frequency in Hz for
  488. * this operating point. Value need to
  489. * be unmixed with SMU_U32_MIX()
  490. */
  491. __u8 pad;
  492. __u8 maxtemp; /* Max temp. supported by this
  493. * operating point
  494. */
  495. __u16 volts[3]; /* CPU core voltage for the 3
  496. * PowerTune modes, a mode with
  497. * 0V = not supported. Value need
  498. * to be unmixed with SMU_U16_MIX()
  499. */
  500. };
  501. /* This partition contains voltage & current sensor calibration
  502. * informations
  503. */
  504. #define SMU_SDB_CPUVCP_ID 0x21
  505. struct smu_sdbp_cpuvcp {
  506. __u16 volt_scale; /* u4.12 fixed point */
  507. __s16 volt_offset; /* s4.12 fixed point */
  508. __u16 curr_scale; /* u4.12 fixed point */
  509. __s16 curr_offset; /* s4.12 fixed point */
  510. __s32 power_quads[3]; /* s4.28 fixed point */
  511. };
  512. /* This partition contains CPU thermal diode calibration
  513. */
  514. #define SMU_SDB_CPUDIODE_ID 0x18
  515. struct smu_sdbp_cpudiode {
  516. __u16 m_value; /* u1.15 fixed point */
  517. __s16 b_value; /* s10.6 fixed point */
  518. };
  519. /* This partition contains Slots power calibration
  520. */
  521. #define SMU_SDB_SLOTSPOW_ID 0x78
  522. struct smu_sdbp_slotspow {
  523. __u16 pow_scale; /* u4.12 fixed point */
  524. __s16 pow_offset; /* s4.12 fixed point */
  525. };
  526. /* This partition contains machine specific version information about
  527. * the sensor/control layout
  528. */
  529. #define SMU_SDB_SENSORTREE_ID 0x25
  530. struct smu_sdbp_sensortree {
  531. __u8 model_id;
  532. __u8 unknown[3];
  533. };
  534. /* This partition contains CPU thermal control PID informations. So far
  535. * only single CPU machines have been seen with an SMU, so we assume this
  536. * carries only informations for those
  537. */
  538. #define SMU_SDB_CPUPIDDATA_ID 0x17
  539. struct smu_sdbp_cpupiddata {
  540. __u8 unknown1;
  541. __u8 target_temp_delta;
  542. __u8 unknown2;
  543. __u8 history_len;
  544. __s16 power_adj;
  545. __u16 max_power;
  546. __s32 gp,gr,gd;
  547. };
  548. /* Other partitions without known structures */
  549. #define SMU_SDB_DEBUG_SWITCHES_ID 0x05
  550. #ifdef __KERNEL__
  551. /*
  552. * This returns the pointer to an SMU "sdb" partition data or NULL
  553. * if not found. The data format is described below
  554. */
  555. extern const struct smu_sdbp_header *smu_get_sdb_partition(int id,
  556. unsigned int *size);
  557. /* Get "sdb" partition data from an SMU satellite */
  558. extern struct smu_sdbp_header *smu_sat_get_sdb_partition(unsigned int sat_id,
  559. int id, unsigned int *size);
  560. #endif /* __KERNEL__ */
  561. /*
  562. * - Userland interface -
  563. */
  564. /*
  565. * A given instance of the device can be configured for 2 different
  566. * things at the moment:
  567. *
  568. * - sending SMU commands (default at open() time)
  569. * - receiving SMU events (not yet implemented)
  570. *
  571. * Commands are written with write() of a command block. They can be
  572. * "driver" commands (for example to switch to event reception mode)
  573. * or real SMU commands. They are made of a header followed by command
  574. * data if any.
  575. *
  576. * For SMU commands (not for driver commands), you can then read() back
  577. * a reply. The reader will be blocked or not depending on how the device
  578. * file is opened. poll() isn't implemented yet. The reply will consist
  579. * of a header as well, followed by the reply data if any. You should
  580. * always provide a buffer large enough for the maximum reply data, I
  581. * recommand one page.
  582. *
  583. * It is illegal to send SMU commands through a file descriptor configured
  584. * for events reception
  585. *
  586. */
  587. struct smu_user_cmd_hdr
  588. {
  589. __u32 cmdtype;
  590. #define SMU_CMDTYPE_SMU 0 /* SMU command */
  591. #define SMU_CMDTYPE_WANTS_EVENTS 1 /* switch fd to events mode */
  592. #define SMU_CMDTYPE_GET_PARTITION 2 /* retrieve an sdb partition */
  593. __u8 cmd; /* SMU command byte */
  594. __u8 pad[3]; /* padding */
  595. __u32 data_len; /* Length of data following */
  596. };
  597. struct smu_user_reply_hdr
  598. {
  599. __u32 status; /* Command status */
  600. __u32 reply_len; /* Length of data follwing */
  601. };
  602. #endif /* _SMU_H */