18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _SMU_H 38c2ecf20Sopenharmony_ci#define _SMU_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* 68c2ecf20Sopenharmony_ci * Definitions for talking to the SMU chip in newer G5 PowerMacs 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 98c2ecf20Sopenharmony_ci#include <linux/list.h> 108c2ecf20Sopenharmony_ci#endif 118c2ecf20Sopenharmony_ci#include <linux/types.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* 148c2ecf20Sopenharmony_ci * Known SMU commands 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * Most of what is below comes from looking at the Open Firmware driver, 178c2ecf20Sopenharmony_ci * though this is still incomplete and could use better documentation here 188c2ecf20Sopenharmony_ci * or there... 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci/* 238c2ecf20Sopenharmony_ci * Partition info commands 248c2ecf20Sopenharmony_ci * 258c2ecf20Sopenharmony_ci * These commands are used to retrieve the sdb-partition-XX datas from 268c2ecf20Sopenharmony_ci * the SMU. The length is always 2. First byte is the subcommand code 278c2ecf20Sopenharmony_ci * and second byte is the partition ID. 288c2ecf20Sopenharmony_ci * 298c2ecf20Sopenharmony_ci * The reply is 6 bytes: 308c2ecf20Sopenharmony_ci * 318c2ecf20Sopenharmony_ci * - 0..1 : partition address 328c2ecf20Sopenharmony_ci * - 2 : a byte containing the partition ID 338c2ecf20Sopenharmony_ci * - 3 : length (maybe other bits are rest of header ?) 348c2ecf20Sopenharmony_ci * 358c2ecf20Sopenharmony_ci * The data must then be obtained with calls to another command: 368c2ecf20Sopenharmony_ci * SMU_CMD_MISC_ee_GET_DATABLOCK_REC (described below). 378c2ecf20Sopenharmony_ci */ 388c2ecf20Sopenharmony_ci#define SMU_CMD_PARTITION_COMMAND 0x3e 398c2ecf20Sopenharmony_ci#define SMU_CMD_PARTITION_LATEST 0x01 408c2ecf20Sopenharmony_ci#define SMU_CMD_PARTITION_BASE 0x02 418c2ecf20Sopenharmony_ci#define SMU_CMD_PARTITION_UPDATE 0x03 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* 458c2ecf20Sopenharmony_ci * Fan control 468c2ecf20Sopenharmony_ci * 478c2ecf20Sopenharmony_ci * This is a "mux" for fan control commands. The command seem to 488c2ecf20Sopenharmony_ci * act differently based on the number of arguments. With 1 byte 498c2ecf20Sopenharmony_ci * of argument, this seem to be queries for fans status, setpoint, 508c2ecf20Sopenharmony_ci * etc..., while with 0xe arguments, we will set the fans speeds. 518c2ecf20Sopenharmony_ci * 528c2ecf20Sopenharmony_ci * Queries (1 byte arg): 538c2ecf20Sopenharmony_ci * --------------------- 548c2ecf20Sopenharmony_ci * 558c2ecf20Sopenharmony_ci * arg=0x01: read RPM fans status 568c2ecf20Sopenharmony_ci * arg=0x02: read RPM fans setpoint 578c2ecf20Sopenharmony_ci * arg=0x11: read PWM fans status 588c2ecf20Sopenharmony_ci * arg=0x12: read PWM fans setpoint 598c2ecf20Sopenharmony_ci * 608c2ecf20Sopenharmony_ci * the "status" queries return the current speed while the "setpoint" ones 618c2ecf20Sopenharmony_ci * return the programmed/target speed. It _seems_ that the result is a bit 628c2ecf20Sopenharmony_ci * mask in the first byte of active/available fans, followed by 6 words (16 638c2ecf20Sopenharmony_ci * bits) containing the requested speed. 648c2ecf20Sopenharmony_ci * 658c2ecf20Sopenharmony_ci * Setpoint (14 bytes arg): 668c2ecf20Sopenharmony_ci * ------------------------ 678c2ecf20Sopenharmony_ci * 688c2ecf20Sopenharmony_ci * first arg byte is 0 for RPM fans and 0x10 for PWM. Second arg byte is the 698c2ecf20Sopenharmony_ci * mask of fans affected by the command. Followed by 6 words containing the 708c2ecf20Sopenharmony_ci * setpoint value for selected fans in the mask (or 0 if mask value is 0) 718c2ecf20Sopenharmony_ci */ 728c2ecf20Sopenharmony_ci#define SMU_CMD_FAN_COMMAND 0x4a 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* 768c2ecf20Sopenharmony_ci * Battery access 778c2ecf20Sopenharmony_ci * 788c2ecf20Sopenharmony_ci * Same command number as the PMU, could it be same syntax ? 798c2ecf20Sopenharmony_ci */ 808c2ecf20Sopenharmony_ci#define SMU_CMD_BATTERY_COMMAND 0x6f 818c2ecf20Sopenharmony_ci#define SMU_CMD_GET_BATTERY_INFO 0x00 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci/* 848c2ecf20Sopenharmony_ci * Real time clock control 858c2ecf20Sopenharmony_ci * 868c2ecf20Sopenharmony_ci * This is a "mux", first data byte contains the "sub" command. 878c2ecf20Sopenharmony_ci * The "RTC" part of the SMU controls the date, time, powerup 888c2ecf20Sopenharmony_ci * timer, but also a PRAM 898c2ecf20Sopenharmony_ci * 908c2ecf20Sopenharmony_ci * Dates are in BCD format on 7 bytes: 918c2ecf20Sopenharmony_ci * [sec] [min] [hour] [weekday] [month day] [month] [year] 928c2ecf20Sopenharmony_ci * with month being 1 based and year minus 100 938c2ecf20Sopenharmony_ci */ 948c2ecf20Sopenharmony_ci#define SMU_CMD_RTC_COMMAND 0x8e 958c2ecf20Sopenharmony_ci#define SMU_CMD_RTC_SET_PWRUP_TIMER 0x00 /* i: 7 bytes date */ 968c2ecf20Sopenharmony_ci#define SMU_CMD_RTC_GET_PWRUP_TIMER 0x01 /* o: 7 bytes date */ 978c2ecf20Sopenharmony_ci#define SMU_CMD_RTC_STOP_PWRUP_TIMER 0x02 988c2ecf20Sopenharmony_ci#define SMU_CMD_RTC_SET_PRAM_BYTE_ACC 0x20 /* i: 1 byte (address?) */ 998c2ecf20Sopenharmony_ci#define SMU_CMD_RTC_SET_PRAM_AUTOINC 0x21 /* i: 1 byte (data?) */ 1008c2ecf20Sopenharmony_ci#define SMU_CMD_RTC_SET_PRAM_LO_BYTES 0x22 /* i: 10 bytes */ 1018c2ecf20Sopenharmony_ci#define SMU_CMD_RTC_SET_PRAM_HI_BYTES 0x23 /* i: 10 bytes */ 1028c2ecf20Sopenharmony_ci#define SMU_CMD_RTC_GET_PRAM_BYTE 0x28 /* i: 1 bytes (address?) */ 1038c2ecf20Sopenharmony_ci#define SMU_CMD_RTC_GET_PRAM_LO_BYTES 0x29 /* o: 10 bytes */ 1048c2ecf20Sopenharmony_ci#define SMU_CMD_RTC_GET_PRAM_HI_BYTES 0x2a /* o: 10 bytes */ 1058c2ecf20Sopenharmony_ci#define SMU_CMD_RTC_SET_DATETIME 0x80 /* i: 7 bytes date */ 1068c2ecf20Sopenharmony_ci#define SMU_CMD_RTC_GET_DATETIME 0x81 /* o: 7 bytes date */ 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci /* 1098c2ecf20Sopenharmony_ci * i2c commands 1108c2ecf20Sopenharmony_ci * 1118c2ecf20Sopenharmony_ci * To issue an i2c command, first is to send a parameter block to 1128c2ecf20Sopenharmony_ci * the SMU. This is a command of type 0x9a with 9 bytes of header 1138c2ecf20Sopenharmony_ci * eventually followed by data for a write: 1148c2ecf20Sopenharmony_ci * 1158c2ecf20Sopenharmony_ci * 0: bus number (from device-tree usually, SMU has lots of busses !) 1168c2ecf20Sopenharmony_ci * 1: transfer type/format (see below) 1178c2ecf20Sopenharmony_ci * 2: device address. For combined and combined4 type transfers, this 1188c2ecf20Sopenharmony_ci * is the "write" version of the address (bit 0x01 cleared) 1198c2ecf20Sopenharmony_ci * 3: subaddress length (0..3) 1208c2ecf20Sopenharmony_ci * 4: subaddress byte 0 (or only byte for subaddress length 1) 1218c2ecf20Sopenharmony_ci * 5: subaddress byte 1 1228c2ecf20Sopenharmony_ci * 6: subaddress byte 2 1238c2ecf20Sopenharmony_ci * 7: combined address (device address for combined mode data phase) 1248c2ecf20Sopenharmony_ci * 8: data length 1258c2ecf20Sopenharmony_ci * 1268c2ecf20Sopenharmony_ci * The transfer types are the same good old Apple ones it seems, 1278c2ecf20Sopenharmony_ci * that is: 1288c2ecf20Sopenharmony_ci * - 0x00: Simple transfer 1298c2ecf20Sopenharmony_ci * - 0x01: Subaddress transfer (addr write + data tx, no restart) 1308c2ecf20Sopenharmony_ci * - 0x02: Combined transfer (addr write + restart + data tx) 1318c2ecf20Sopenharmony_ci * 1328c2ecf20Sopenharmony_ci * This is then followed by actual data for a write. 1338c2ecf20Sopenharmony_ci * 1348c2ecf20Sopenharmony_ci * At this point, the OF driver seems to have a limitation on transfer 1358c2ecf20Sopenharmony_ci * sizes of 0xd bytes on reads and 0x5 bytes on writes. I do not know 1368c2ecf20Sopenharmony_ci * whether this is just an OF limit due to some temporary buffer size 1378c2ecf20Sopenharmony_ci * or if this is an SMU imposed limit. This driver has the same limitation 1388c2ecf20Sopenharmony_ci * for now as I use a 0x10 bytes temporary buffer as well 1398c2ecf20Sopenharmony_ci * 1408c2ecf20Sopenharmony_ci * Once that is completed, a response is expected from the SMU. This is 1418c2ecf20Sopenharmony_ci * obtained via a command of type 0x9a with a length of 1 byte containing 1428c2ecf20Sopenharmony_ci * 0 as the data byte. OF also fills the rest of the data buffer with 0xff's 1438c2ecf20Sopenharmony_ci * though I can't tell yet if this is actually necessary. Once this command 1448c2ecf20Sopenharmony_ci * is complete, at this point, all I can tell is what OF does. OF tests 1458c2ecf20Sopenharmony_ci * byte 0 of the reply: 1468c2ecf20Sopenharmony_ci * - on read, 0xfe or 0xfc : bus is busy, wait (see below) or nak ? 1478c2ecf20Sopenharmony_ci * - on read, 0x00 or 0x01 : reply is in buffer (after the byte 0) 1488c2ecf20Sopenharmony_ci * - on write, < 0 -> failure (immediate exit) 1498c2ecf20Sopenharmony_ci * - else, OF just exists (without error, weird) 1508c2ecf20Sopenharmony_ci * 1518c2ecf20Sopenharmony_ci * So on read, there is this wait-for-busy thing when getting a 0xfc or 1528c2ecf20Sopenharmony_ci * 0xfe result. OF does a loop of up to 64 retries, waiting 20ms and 1538c2ecf20Sopenharmony_ci * doing the above again until either the retries expire or the result 1548c2ecf20Sopenharmony_ci * is no longer 0xfe or 0xfc 1558c2ecf20Sopenharmony_ci * 1568c2ecf20Sopenharmony_ci * The Darwin I2C driver is less subtle though. On any non-success status 1578c2ecf20Sopenharmony_ci * from the response command, it waits 5ms and tries again up to 20 times, 1588c2ecf20Sopenharmony_ci * it doesn't differentiate between fatal errors or "busy" status. 1598c2ecf20Sopenharmony_ci * 1608c2ecf20Sopenharmony_ci * This driver provides an asynchronous paramblock based i2c command 1618c2ecf20Sopenharmony_ci * interface to be used either directly by low level code or by a higher 1628c2ecf20Sopenharmony_ci * level driver interfacing to the linux i2c layer. The current 1638c2ecf20Sopenharmony_ci * implementation of this relies on working timers & timer interrupts 1648c2ecf20Sopenharmony_ci * though, so be careful of calling context for now. This may be "fixed" 1658c2ecf20Sopenharmony_ci * in the future by adding a polling facility. 1668c2ecf20Sopenharmony_ci */ 1678c2ecf20Sopenharmony_ci#define SMU_CMD_I2C_COMMAND 0x9a 1688c2ecf20Sopenharmony_ci /* transfer types */ 1698c2ecf20Sopenharmony_ci#define SMU_I2C_TRANSFER_SIMPLE 0x00 1708c2ecf20Sopenharmony_ci#define SMU_I2C_TRANSFER_STDSUB 0x01 1718c2ecf20Sopenharmony_ci#define SMU_I2C_TRANSFER_COMBINED 0x02 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci/* 1748c2ecf20Sopenharmony_ci * Power supply control 1758c2ecf20Sopenharmony_ci * 1768c2ecf20Sopenharmony_ci * The "sub" command is an ASCII string in the data, the 1778c2ecf20Sopenharmony_ci * data length is that of the string. 1788c2ecf20Sopenharmony_ci * 1798c2ecf20Sopenharmony_ci * The VSLEW command can be used to get or set the voltage slewing. 1808c2ecf20Sopenharmony_ci * - length 5 (only "VSLEW") : it returns "DONE" and 3 bytes of 1818c2ecf20Sopenharmony_ci * reply at data offset 6, 7 and 8. 1828c2ecf20Sopenharmony_ci * - length 8 ("VSLEWxyz") has 3 additional bytes appended, and is 1838c2ecf20Sopenharmony_ci * used to set the voltage slewing point. The SMU replies with "DONE" 1848c2ecf20Sopenharmony_ci * I yet have to figure out their exact meaning of those 3 bytes in 1858c2ecf20Sopenharmony_ci * both cases. They seem to be: 1868c2ecf20Sopenharmony_ci * x = processor mask 1878c2ecf20Sopenharmony_ci * y = op. point index 1888c2ecf20Sopenharmony_ci * z = processor freq. step index 1898c2ecf20Sopenharmony_ci * I haven't yet deciphered result codes 1908c2ecf20Sopenharmony_ci * 1918c2ecf20Sopenharmony_ci */ 1928c2ecf20Sopenharmony_ci#define SMU_CMD_POWER_COMMAND 0xaa 1938c2ecf20Sopenharmony_ci#define SMU_CMD_POWER_RESTART "RESTART" 1948c2ecf20Sopenharmony_ci#define SMU_CMD_POWER_SHUTDOWN "SHUTDOWN" 1958c2ecf20Sopenharmony_ci#define SMU_CMD_POWER_VOLTAGE_SLEW "VSLEW" 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci/* 1988c2ecf20Sopenharmony_ci * Read ADC sensors 1998c2ecf20Sopenharmony_ci * 2008c2ecf20Sopenharmony_ci * This command takes one byte of parameter: the sensor ID (or "reg" 2018c2ecf20Sopenharmony_ci * value in the device-tree) and returns a 16 bits value 2028c2ecf20Sopenharmony_ci */ 2038c2ecf20Sopenharmony_ci#define SMU_CMD_READ_ADC 0xd8 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci/* Misc commands 2078c2ecf20Sopenharmony_ci * 2088c2ecf20Sopenharmony_ci * This command seem to be a grab bag of various things 2098c2ecf20Sopenharmony_ci * 2108c2ecf20Sopenharmony_ci * Parameters: 2118c2ecf20Sopenharmony_ci * 1: subcommand 2128c2ecf20Sopenharmony_ci */ 2138c2ecf20Sopenharmony_ci#define SMU_CMD_MISC_df_COMMAND 0xdf 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci/* 2168c2ecf20Sopenharmony_ci * Sets "system ready" status 2178c2ecf20Sopenharmony_ci * 2188c2ecf20Sopenharmony_ci * I did not yet understand how it exactly works or what it does. 2198c2ecf20Sopenharmony_ci * 2208c2ecf20Sopenharmony_ci * Guessing from OF code, 0x02 activates the display backlight. Apple uses/used 2218c2ecf20Sopenharmony_ci * the same codebase for all OF versions. On PowerBooks, this command would 2228c2ecf20Sopenharmony_ci * enable the backlight. For the G5s, it only activates the front LED. However, 2238c2ecf20Sopenharmony_ci * don't take this for granted. 2248c2ecf20Sopenharmony_ci * 2258c2ecf20Sopenharmony_ci * Parameters: 2268c2ecf20Sopenharmony_ci * 2: status [0x00, 0x01 or 0x02] 2278c2ecf20Sopenharmony_ci */ 2288c2ecf20Sopenharmony_ci#define SMU_CMD_MISC_df_SET_DISPLAY_LIT 0x02 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci/* 2318c2ecf20Sopenharmony_ci * Sets mode of power switch. 2328c2ecf20Sopenharmony_ci * 2338c2ecf20Sopenharmony_ci * What this actually does is not yet known. Maybe it enables some interrupt. 2348c2ecf20Sopenharmony_ci * 2358c2ecf20Sopenharmony_ci * Parameters: 2368c2ecf20Sopenharmony_ci * 2: enable power switch? [0x00 or 0x01] 2378c2ecf20Sopenharmony_ci * 3 (optional): enable nmi? [0x00 or 0x01] 2388c2ecf20Sopenharmony_ci * 2398c2ecf20Sopenharmony_ci * Returns: 2408c2ecf20Sopenharmony_ci * If parameter 2 is 0x00 and parameter 3 is not specified, returns whether 2418c2ecf20Sopenharmony_ci * NMI is enabled. Otherwise unknown. 2428c2ecf20Sopenharmony_ci */ 2438c2ecf20Sopenharmony_ci#define SMU_CMD_MISC_df_NMI_OPTION 0x04 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci/* Sets LED dimm offset. 2468c2ecf20Sopenharmony_ci * 2478c2ecf20Sopenharmony_ci * The front LED dimms itself during sleep. Its brightness (or, well, the PWM 2488c2ecf20Sopenharmony_ci * frequency) depends on current time. Therefore, the SMU needs to know the 2498c2ecf20Sopenharmony_ci * timezone. 2508c2ecf20Sopenharmony_ci * 2518c2ecf20Sopenharmony_ci * Parameters: 2528c2ecf20Sopenharmony_ci * 2-8: unknown (BCD coding) 2538c2ecf20Sopenharmony_ci */ 2548c2ecf20Sopenharmony_ci#define SMU_CMD_MISC_df_DIMM_OFFSET 0x99 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci/* 2588c2ecf20Sopenharmony_ci * Version info commands 2598c2ecf20Sopenharmony_ci * 2608c2ecf20Sopenharmony_ci * Parameters: 2618c2ecf20Sopenharmony_ci * 1 (optional): Specifies version part to retrieve 2628c2ecf20Sopenharmony_ci * 2638c2ecf20Sopenharmony_ci * Returns: 2648c2ecf20Sopenharmony_ci * Version value 2658c2ecf20Sopenharmony_ci */ 2668c2ecf20Sopenharmony_ci#define SMU_CMD_VERSION_COMMAND 0xea 2678c2ecf20Sopenharmony_ci#define SMU_VERSION_RUNNING 0x00 2688c2ecf20Sopenharmony_ci#define SMU_VERSION_BASE 0x01 2698c2ecf20Sopenharmony_ci#define SMU_VERSION_UPDATE 0x02 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci/* 2738c2ecf20Sopenharmony_ci * Switches 2748c2ecf20Sopenharmony_ci * 2758c2ecf20Sopenharmony_ci * These are switches whose status seems to be known to the SMU. 2768c2ecf20Sopenharmony_ci * 2778c2ecf20Sopenharmony_ci * Parameters: 2788c2ecf20Sopenharmony_ci * none 2798c2ecf20Sopenharmony_ci * 2808c2ecf20Sopenharmony_ci * Result: 2818c2ecf20Sopenharmony_ci * Switch bits (ORed, see below) 2828c2ecf20Sopenharmony_ci */ 2838c2ecf20Sopenharmony_ci#define SMU_CMD_SWITCHES 0xdc 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci/* Switches bits */ 2868c2ecf20Sopenharmony_ci#define SMU_SWITCH_CASE_CLOSED 0x01 2878c2ecf20Sopenharmony_ci#define SMU_SWITCH_AC_POWER 0x04 2888c2ecf20Sopenharmony_ci#define SMU_SWITCH_POWER_SWITCH 0x08 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci/* 2928c2ecf20Sopenharmony_ci * Misc commands 2938c2ecf20Sopenharmony_ci * 2948c2ecf20Sopenharmony_ci * This command seem to be a grab bag of various things 2958c2ecf20Sopenharmony_ci * 2968c2ecf20Sopenharmony_ci * SMU_CMD_MISC_ee_GET_DATABLOCK_REC is used, among others, to 2978c2ecf20Sopenharmony_ci * transfer blocks of data from the SMU. So far, I've decrypted it's 2988c2ecf20Sopenharmony_ci * usage to retrieve partition data. In order to do that, you have to 2998c2ecf20Sopenharmony_ci * break your transfer in "chunks" since that command cannot transfer 3008c2ecf20Sopenharmony_ci * more than a chunk at a time. The chunk size used by OF is 0xe bytes, 3018c2ecf20Sopenharmony_ci * but it seems that the darwin driver will let you do 0x1e bytes if 3028c2ecf20Sopenharmony_ci * your "PMU" version is >= 0x30. You can get the "PMU" version apparently 3038c2ecf20Sopenharmony_ci * either in the last 16 bits of property "smu-version-pmu" or as the 16 3048c2ecf20Sopenharmony_ci * bytes at offset 1 of "smu-version-info" 3058c2ecf20Sopenharmony_ci * 3068c2ecf20Sopenharmony_ci * For each chunk, the command takes 7 bytes of arguments: 3078c2ecf20Sopenharmony_ci * byte 0: subcommand code (0x02) 3088c2ecf20Sopenharmony_ci * byte 1: 0x04 (always, I don't know what it means, maybe the address 3098c2ecf20Sopenharmony_ci * space to use or some other nicety. It's hard coded in OF) 3108c2ecf20Sopenharmony_ci * byte 2..5: SMU address of the chunk (big endian 32 bits) 3118c2ecf20Sopenharmony_ci * byte 6: size to transfer (up to max chunk size) 3128c2ecf20Sopenharmony_ci * 3138c2ecf20Sopenharmony_ci * The data is returned directly 3148c2ecf20Sopenharmony_ci */ 3158c2ecf20Sopenharmony_ci#define SMU_CMD_MISC_ee_COMMAND 0xee 3168c2ecf20Sopenharmony_ci#define SMU_CMD_MISC_ee_GET_DATABLOCK_REC 0x02 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ci/* Retrieves currently used watts. 3198c2ecf20Sopenharmony_ci * 3208c2ecf20Sopenharmony_ci * Parameters: 3218c2ecf20Sopenharmony_ci * 1: 0x03 (Meaning unknown) 3228c2ecf20Sopenharmony_ci */ 3238c2ecf20Sopenharmony_ci#define SMU_CMD_MISC_ee_GET_WATTS 0x03 3248c2ecf20Sopenharmony_ci 3258c2ecf20Sopenharmony_ci#define SMU_CMD_MISC_ee_LEDS_CTRL 0x04 /* i: 00 (00,01) [00] */ 3268c2ecf20Sopenharmony_ci#define SMU_CMD_MISC_ee_GET_DATA 0x05 /* i: 00 , o: ?? */ 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ci/* 3308c2ecf20Sopenharmony_ci * Power related commands 3318c2ecf20Sopenharmony_ci * 3328c2ecf20Sopenharmony_ci * Parameters: 3338c2ecf20Sopenharmony_ci * 1: subcommand 3348c2ecf20Sopenharmony_ci */ 3358c2ecf20Sopenharmony_ci#define SMU_CMD_POWER_EVENTS_COMMAND 0x8f 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci/* SMU_POWER_EVENTS subcommands */ 3388c2ecf20Sopenharmony_cienum { 3398c2ecf20Sopenharmony_ci SMU_PWR_GET_POWERUP_EVENTS = 0x00, 3408c2ecf20Sopenharmony_ci SMU_PWR_SET_POWERUP_EVENTS = 0x01, 3418c2ecf20Sopenharmony_ci SMU_PWR_CLR_POWERUP_EVENTS = 0x02, 3428c2ecf20Sopenharmony_ci SMU_PWR_GET_WAKEUP_EVENTS = 0x03, 3438c2ecf20Sopenharmony_ci SMU_PWR_SET_WAKEUP_EVENTS = 0x04, 3448c2ecf20Sopenharmony_ci SMU_PWR_CLR_WAKEUP_EVENTS = 0x05, 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci /* 3478c2ecf20Sopenharmony_ci * Get last shutdown cause 3488c2ecf20Sopenharmony_ci * 3498c2ecf20Sopenharmony_ci * Returns: 3508c2ecf20Sopenharmony_ci * 1 byte (signed char): Last shutdown cause. Exact meaning unknown. 3518c2ecf20Sopenharmony_ci */ 3528c2ecf20Sopenharmony_ci SMU_PWR_LAST_SHUTDOWN_CAUSE = 0x07, 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ci /* 3558c2ecf20Sopenharmony_ci * Sets or gets server ID. Meaning or use is unknown. 3568c2ecf20Sopenharmony_ci * 3578c2ecf20Sopenharmony_ci * Parameters: 3588c2ecf20Sopenharmony_ci * 2 (optional): Set server ID (1 byte) 3598c2ecf20Sopenharmony_ci * 3608c2ecf20Sopenharmony_ci * Returns: 3618c2ecf20Sopenharmony_ci * 1 byte (server ID?) 3628c2ecf20Sopenharmony_ci */ 3638c2ecf20Sopenharmony_ci SMU_PWR_SERVER_ID = 0x08, 3648c2ecf20Sopenharmony_ci}; 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci/* Power events wakeup bits */ 3678c2ecf20Sopenharmony_cienum { 3688c2ecf20Sopenharmony_ci SMU_PWR_WAKEUP_KEY = 0x01, /* Wake on key press */ 3698c2ecf20Sopenharmony_ci SMU_PWR_WAKEUP_AC_INSERT = 0x02, /* Wake on AC adapter plug */ 3708c2ecf20Sopenharmony_ci SMU_PWR_WAKEUP_AC_CHANGE = 0x04, 3718c2ecf20Sopenharmony_ci SMU_PWR_WAKEUP_LID_OPEN = 0x08, 3728c2ecf20Sopenharmony_ci SMU_PWR_WAKEUP_RING = 0x10, 3738c2ecf20Sopenharmony_ci}; 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_ci/* 3778c2ecf20Sopenharmony_ci * - Kernel side interface - 3788c2ecf20Sopenharmony_ci */ 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_ci/* 3838c2ecf20Sopenharmony_ci * Asynchronous SMU commands 3848c2ecf20Sopenharmony_ci * 3858c2ecf20Sopenharmony_ci * Fill up this structure and submit it via smu_queue_command(), 3868c2ecf20Sopenharmony_ci * and get notified by the optional done() callback, or because 3878c2ecf20Sopenharmony_ci * status becomes != 1 3888c2ecf20Sopenharmony_ci */ 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_cistruct smu_cmd; 3918c2ecf20Sopenharmony_ci 3928c2ecf20Sopenharmony_cistruct smu_cmd 3938c2ecf20Sopenharmony_ci{ 3948c2ecf20Sopenharmony_ci /* public */ 3958c2ecf20Sopenharmony_ci u8 cmd; /* command */ 3968c2ecf20Sopenharmony_ci int data_len; /* data len */ 3978c2ecf20Sopenharmony_ci int reply_len; /* reply len */ 3988c2ecf20Sopenharmony_ci void *data_buf; /* data buffer */ 3998c2ecf20Sopenharmony_ci void *reply_buf; /* reply buffer */ 4008c2ecf20Sopenharmony_ci int status; /* command status */ 4018c2ecf20Sopenharmony_ci void (*done)(struct smu_cmd *cmd, void *misc); 4028c2ecf20Sopenharmony_ci void *misc; 4038c2ecf20Sopenharmony_ci 4048c2ecf20Sopenharmony_ci /* private */ 4058c2ecf20Sopenharmony_ci struct list_head link; 4068c2ecf20Sopenharmony_ci}; 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_ci/* 4098c2ecf20Sopenharmony_ci * Queues an SMU command, all fields have to be initialized 4108c2ecf20Sopenharmony_ci */ 4118c2ecf20Sopenharmony_ciextern int smu_queue_cmd(struct smu_cmd *cmd); 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_ci/* 4148c2ecf20Sopenharmony_ci * Simple command wrapper. This structure embeds a small buffer 4158c2ecf20Sopenharmony_ci * to ease sending simple SMU commands from the stack 4168c2ecf20Sopenharmony_ci */ 4178c2ecf20Sopenharmony_cistruct smu_simple_cmd 4188c2ecf20Sopenharmony_ci{ 4198c2ecf20Sopenharmony_ci struct smu_cmd cmd; 4208c2ecf20Sopenharmony_ci u8 buffer[16]; 4218c2ecf20Sopenharmony_ci}; 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_ci/* 4248c2ecf20Sopenharmony_ci * Queues a simple command. All fields will be initialized by that 4258c2ecf20Sopenharmony_ci * function 4268c2ecf20Sopenharmony_ci */ 4278c2ecf20Sopenharmony_ciextern int smu_queue_simple(struct smu_simple_cmd *scmd, u8 command, 4288c2ecf20Sopenharmony_ci unsigned int data_len, 4298c2ecf20Sopenharmony_ci void (*done)(struct smu_cmd *cmd, void *misc), 4308c2ecf20Sopenharmony_ci void *misc, 4318c2ecf20Sopenharmony_ci ...); 4328c2ecf20Sopenharmony_ci 4338c2ecf20Sopenharmony_ci/* 4348c2ecf20Sopenharmony_ci * Completion helper. Pass it to smu_queue_simple or as 'done' 4358c2ecf20Sopenharmony_ci * member to smu_queue_cmd, it will call complete() on the struct 4368c2ecf20Sopenharmony_ci * completion passed in the "misc" argument 4378c2ecf20Sopenharmony_ci */ 4388c2ecf20Sopenharmony_ciextern void smu_done_complete(struct smu_cmd *cmd, void *misc); 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_ci/* 4418c2ecf20Sopenharmony_ci * Synchronous helpers. Will spin-wait for completion of a command 4428c2ecf20Sopenharmony_ci */ 4438c2ecf20Sopenharmony_ciextern void smu_spinwait_cmd(struct smu_cmd *cmd); 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_cistatic inline void smu_spinwait_simple(struct smu_simple_cmd *scmd) 4468c2ecf20Sopenharmony_ci{ 4478c2ecf20Sopenharmony_ci smu_spinwait_cmd(&scmd->cmd); 4488c2ecf20Sopenharmony_ci} 4498c2ecf20Sopenharmony_ci 4508c2ecf20Sopenharmony_ci/* 4518c2ecf20Sopenharmony_ci * Poll routine to call if blocked with irqs off 4528c2ecf20Sopenharmony_ci */ 4538c2ecf20Sopenharmony_ciextern void smu_poll(void); 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci 4568c2ecf20Sopenharmony_ci/* 4578c2ecf20Sopenharmony_ci * Init routine, presence check.... 4588c2ecf20Sopenharmony_ci */ 4598c2ecf20Sopenharmony_ciextern int smu_init(void); 4608c2ecf20Sopenharmony_ciextern int smu_present(void); 4618c2ecf20Sopenharmony_cistruct platform_device; 4628c2ecf20Sopenharmony_ciextern struct platform_device *smu_get_ofdev(void); 4638c2ecf20Sopenharmony_ci 4648c2ecf20Sopenharmony_ci 4658c2ecf20Sopenharmony_ci/* 4668c2ecf20Sopenharmony_ci * Common command wrappers 4678c2ecf20Sopenharmony_ci */ 4688c2ecf20Sopenharmony_ciextern void smu_shutdown(void); 4698c2ecf20Sopenharmony_ciextern void smu_restart(void); 4708c2ecf20Sopenharmony_cistruct rtc_time; 4718c2ecf20Sopenharmony_ciextern int smu_get_rtc_time(struct rtc_time *time, int spinwait); 4728c2ecf20Sopenharmony_ciextern int smu_set_rtc_time(struct rtc_time *time, int spinwait); 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_ci/* 4758c2ecf20Sopenharmony_ci * Kernel asynchronous i2c interface 4768c2ecf20Sopenharmony_ci */ 4778c2ecf20Sopenharmony_ci 4788c2ecf20Sopenharmony_ci#define SMU_I2C_READ_MAX 0x1d 4798c2ecf20Sopenharmony_ci#define SMU_I2C_WRITE_MAX 0x15 4808c2ecf20Sopenharmony_ci 4818c2ecf20Sopenharmony_ci/* SMU i2c header, exactly matches i2c header on wire */ 4828c2ecf20Sopenharmony_cistruct smu_i2c_param 4838c2ecf20Sopenharmony_ci{ 4848c2ecf20Sopenharmony_ci u8 bus; /* SMU bus ID (from device tree) */ 4858c2ecf20Sopenharmony_ci u8 type; /* i2c transfer type */ 4868c2ecf20Sopenharmony_ci u8 devaddr; /* device address (includes direction) */ 4878c2ecf20Sopenharmony_ci u8 sublen; /* subaddress length */ 4888c2ecf20Sopenharmony_ci u8 subaddr[3]; /* subaddress */ 4898c2ecf20Sopenharmony_ci u8 caddr; /* combined address, filled by SMU driver */ 4908c2ecf20Sopenharmony_ci u8 datalen; /* length of transfer */ 4918c2ecf20Sopenharmony_ci u8 data[SMU_I2C_READ_MAX]; /* data */ 4928c2ecf20Sopenharmony_ci}; 4938c2ecf20Sopenharmony_ci 4948c2ecf20Sopenharmony_cistruct smu_i2c_cmd 4958c2ecf20Sopenharmony_ci{ 4968c2ecf20Sopenharmony_ci /* public */ 4978c2ecf20Sopenharmony_ci struct smu_i2c_param info; 4988c2ecf20Sopenharmony_ci void (*done)(struct smu_i2c_cmd *cmd, void *misc); 4998c2ecf20Sopenharmony_ci void *misc; 5008c2ecf20Sopenharmony_ci int status; /* 1 = pending, 0 = ok, <0 = fail */ 5018c2ecf20Sopenharmony_ci 5028c2ecf20Sopenharmony_ci /* private */ 5038c2ecf20Sopenharmony_ci struct smu_cmd scmd; 5048c2ecf20Sopenharmony_ci int read; 5058c2ecf20Sopenharmony_ci int stage; 5068c2ecf20Sopenharmony_ci int retries; 5078c2ecf20Sopenharmony_ci u8 pdata[32]; 5088c2ecf20Sopenharmony_ci struct list_head link; 5098c2ecf20Sopenharmony_ci}; 5108c2ecf20Sopenharmony_ci 5118c2ecf20Sopenharmony_ci/* 5128c2ecf20Sopenharmony_ci * Call this to queue an i2c command to the SMU. You must fill info, 5138c2ecf20Sopenharmony_ci * including info.data for a write, done and misc. 5148c2ecf20Sopenharmony_ci * For now, no polling interface is provided so you have to use completion 5158c2ecf20Sopenharmony_ci * callback. 5168c2ecf20Sopenharmony_ci */ 5178c2ecf20Sopenharmony_ciextern int smu_queue_i2c(struct smu_i2c_cmd *cmd); 5188c2ecf20Sopenharmony_ci 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 5218c2ecf20Sopenharmony_ci 5228c2ecf20Sopenharmony_ci 5238c2ecf20Sopenharmony_ci/* 5248c2ecf20Sopenharmony_ci * - SMU "sdb" partitions informations - 5258c2ecf20Sopenharmony_ci */ 5268c2ecf20Sopenharmony_ci 5278c2ecf20Sopenharmony_ci 5288c2ecf20Sopenharmony_ci/* 5298c2ecf20Sopenharmony_ci * Partition header format 5308c2ecf20Sopenharmony_ci */ 5318c2ecf20Sopenharmony_cistruct smu_sdbp_header { 5328c2ecf20Sopenharmony_ci __u8 id; 5338c2ecf20Sopenharmony_ci __u8 len; 5348c2ecf20Sopenharmony_ci __u8 version; 5358c2ecf20Sopenharmony_ci __u8 flags; 5368c2ecf20Sopenharmony_ci}; 5378c2ecf20Sopenharmony_ci 5388c2ecf20Sopenharmony_ci 5398c2ecf20Sopenharmony_ci /* 5408c2ecf20Sopenharmony_ci * demangle 16 and 32 bits integer in some SMU partitions 5418c2ecf20Sopenharmony_ci * (currently, afaik, this concerns only the FVT partition 5428c2ecf20Sopenharmony_ci * (0x12) 5438c2ecf20Sopenharmony_ci */ 5448c2ecf20Sopenharmony_ci#define SMU_U16_MIX(x) le16_to_cpu(x) 5458c2ecf20Sopenharmony_ci#define SMU_U32_MIX(x) ((((x) & 0xff00ff00u) >> 8)|(((x) & 0x00ff00ffu) << 8)) 5468c2ecf20Sopenharmony_ci 5478c2ecf20Sopenharmony_ci 5488c2ecf20Sopenharmony_ci/* This is the definition of the SMU sdb-partition-0x12 table (called 5498c2ecf20Sopenharmony_ci * CPU F/V/T operating points in Darwin). The definition for all those 5508c2ecf20Sopenharmony_ci * SMU tables should be moved to some separate file 5518c2ecf20Sopenharmony_ci */ 5528c2ecf20Sopenharmony_ci#define SMU_SDB_FVT_ID 0x12 5538c2ecf20Sopenharmony_ci 5548c2ecf20Sopenharmony_cistruct smu_sdbp_fvt { 5558c2ecf20Sopenharmony_ci __u32 sysclk; /* Base SysClk frequency in Hz for 5568c2ecf20Sopenharmony_ci * this operating point. Value need to 5578c2ecf20Sopenharmony_ci * be unmixed with SMU_U32_MIX() 5588c2ecf20Sopenharmony_ci */ 5598c2ecf20Sopenharmony_ci __u8 pad; 5608c2ecf20Sopenharmony_ci __u8 maxtemp; /* Max temp. supported by this 5618c2ecf20Sopenharmony_ci * operating point 5628c2ecf20Sopenharmony_ci */ 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_ci __u16 volts[3]; /* CPU core voltage for the 3 5658c2ecf20Sopenharmony_ci * PowerTune modes, a mode with 5668c2ecf20Sopenharmony_ci * 0V = not supported. Value need 5678c2ecf20Sopenharmony_ci * to be unmixed with SMU_U16_MIX() 5688c2ecf20Sopenharmony_ci */ 5698c2ecf20Sopenharmony_ci}; 5708c2ecf20Sopenharmony_ci 5718c2ecf20Sopenharmony_ci/* This partition contains voltage & current sensor calibration 5728c2ecf20Sopenharmony_ci * informations 5738c2ecf20Sopenharmony_ci */ 5748c2ecf20Sopenharmony_ci#define SMU_SDB_CPUVCP_ID 0x21 5758c2ecf20Sopenharmony_ci 5768c2ecf20Sopenharmony_cistruct smu_sdbp_cpuvcp { 5778c2ecf20Sopenharmony_ci __u16 volt_scale; /* u4.12 fixed point */ 5788c2ecf20Sopenharmony_ci __s16 volt_offset; /* s4.12 fixed point */ 5798c2ecf20Sopenharmony_ci __u16 curr_scale; /* u4.12 fixed point */ 5808c2ecf20Sopenharmony_ci __s16 curr_offset; /* s4.12 fixed point */ 5818c2ecf20Sopenharmony_ci __s32 power_quads[3]; /* s4.28 fixed point */ 5828c2ecf20Sopenharmony_ci}; 5838c2ecf20Sopenharmony_ci 5848c2ecf20Sopenharmony_ci/* This partition contains CPU thermal diode calibration 5858c2ecf20Sopenharmony_ci */ 5868c2ecf20Sopenharmony_ci#define SMU_SDB_CPUDIODE_ID 0x18 5878c2ecf20Sopenharmony_ci 5888c2ecf20Sopenharmony_cistruct smu_sdbp_cpudiode { 5898c2ecf20Sopenharmony_ci __u16 m_value; /* u1.15 fixed point */ 5908c2ecf20Sopenharmony_ci __s16 b_value; /* s10.6 fixed point */ 5918c2ecf20Sopenharmony_ci 5928c2ecf20Sopenharmony_ci}; 5938c2ecf20Sopenharmony_ci 5948c2ecf20Sopenharmony_ci/* This partition contains Slots power calibration 5958c2ecf20Sopenharmony_ci */ 5968c2ecf20Sopenharmony_ci#define SMU_SDB_SLOTSPOW_ID 0x78 5978c2ecf20Sopenharmony_ci 5988c2ecf20Sopenharmony_cistruct smu_sdbp_slotspow { 5998c2ecf20Sopenharmony_ci __u16 pow_scale; /* u4.12 fixed point */ 6008c2ecf20Sopenharmony_ci __s16 pow_offset; /* s4.12 fixed point */ 6018c2ecf20Sopenharmony_ci}; 6028c2ecf20Sopenharmony_ci 6038c2ecf20Sopenharmony_ci/* This partition contains machine specific version information about 6048c2ecf20Sopenharmony_ci * the sensor/control layout 6058c2ecf20Sopenharmony_ci */ 6068c2ecf20Sopenharmony_ci#define SMU_SDB_SENSORTREE_ID 0x25 6078c2ecf20Sopenharmony_ci 6088c2ecf20Sopenharmony_cistruct smu_sdbp_sensortree { 6098c2ecf20Sopenharmony_ci __u8 model_id; 6108c2ecf20Sopenharmony_ci __u8 unknown[3]; 6118c2ecf20Sopenharmony_ci}; 6128c2ecf20Sopenharmony_ci 6138c2ecf20Sopenharmony_ci/* This partition contains CPU thermal control PID informations. So far 6148c2ecf20Sopenharmony_ci * only single CPU machines have been seen with an SMU, so we assume this 6158c2ecf20Sopenharmony_ci * carries only informations for those 6168c2ecf20Sopenharmony_ci */ 6178c2ecf20Sopenharmony_ci#define SMU_SDB_CPUPIDDATA_ID 0x17 6188c2ecf20Sopenharmony_ci 6198c2ecf20Sopenharmony_cistruct smu_sdbp_cpupiddata { 6208c2ecf20Sopenharmony_ci __u8 unknown1; 6218c2ecf20Sopenharmony_ci __u8 target_temp_delta; 6228c2ecf20Sopenharmony_ci __u8 unknown2; 6238c2ecf20Sopenharmony_ci __u8 history_len; 6248c2ecf20Sopenharmony_ci __s16 power_adj; 6258c2ecf20Sopenharmony_ci __u16 max_power; 6268c2ecf20Sopenharmony_ci __s32 gp,gr,gd; 6278c2ecf20Sopenharmony_ci}; 6288c2ecf20Sopenharmony_ci 6298c2ecf20Sopenharmony_ci 6308c2ecf20Sopenharmony_ci/* Other partitions without known structures */ 6318c2ecf20Sopenharmony_ci#define SMU_SDB_DEBUG_SWITCHES_ID 0x05 6328c2ecf20Sopenharmony_ci 6338c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 6348c2ecf20Sopenharmony_ci/* 6358c2ecf20Sopenharmony_ci * This returns the pointer to an SMU "sdb" partition data or NULL 6368c2ecf20Sopenharmony_ci * if not found. The data format is described below 6378c2ecf20Sopenharmony_ci */ 6388c2ecf20Sopenharmony_ciextern const struct smu_sdbp_header *smu_get_sdb_partition(int id, 6398c2ecf20Sopenharmony_ci unsigned int *size); 6408c2ecf20Sopenharmony_ci 6418c2ecf20Sopenharmony_ci/* Get "sdb" partition data from an SMU satellite */ 6428c2ecf20Sopenharmony_ciextern struct smu_sdbp_header *smu_sat_get_sdb_partition(unsigned int sat_id, 6438c2ecf20Sopenharmony_ci int id, unsigned int *size); 6448c2ecf20Sopenharmony_ci 6458c2ecf20Sopenharmony_ci 6468c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 6478c2ecf20Sopenharmony_ci 6488c2ecf20Sopenharmony_ci 6498c2ecf20Sopenharmony_ci/* 6508c2ecf20Sopenharmony_ci * - Userland interface - 6518c2ecf20Sopenharmony_ci */ 6528c2ecf20Sopenharmony_ci 6538c2ecf20Sopenharmony_ci/* 6548c2ecf20Sopenharmony_ci * A given instance of the device can be configured for 2 different 6558c2ecf20Sopenharmony_ci * things at the moment: 6568c2ecf20Sopenharmony_ci * 6578c2ecf20Sopenharmony_ci * - sending SMU commands (default at open() time) 6588c2ecf20Sopenharmony_ci * - receiving SMU events (not yet implemented) 6598c2ecf20Sopenharmony_ci * 6608c2ecf20Sopenharmony_ci * Commands are written with write() of a command block. They can be 6618c2ecf20Sopenharmony_ci * "driver" commands (for example to switch to event reception mode) 6628c2ecf20Sopenharmony_ci * or real SMU commands. They are made of a header followed by command 6638c2ecf20Sopenharmony_ci * data if any. 6648c2ecf20Sopenharmony_ci * 6658c2ecf20Sopenharmony_ci * For SMU commands (not for driver commands), you can then read() back 6668c2ecf20Sopenharmony_ci * a reply. The reader will be blocked or not depending on how the device 6678c2ecf20Sopenharmony_ci * file is opened. poll() isn't implemented yet. The reply will consist 6688c2ecf20Sopenharmony_ci * of a header as well, followed by the reply data if any. You should 6698c2ecf20Sopenharmony_ci * always provide a buffer large enough for the maximum reply data, I 6708c2ecf20Sopenharmony_ci * recommand one page. 6718c2ecf20Sopenharmony_ci * 6728c2ecf20Sopenharmony_ci * It is illegal to send SMU commands through a file descriptor configured 6738c2ecf20Sopenharmony_ci * for events reception 6748c2ecf20Sopenharmony_ci * 6758c2ecf20Sopenharmony_ci */ 6768c2ecf20Sopenharmony_cistruct smu_user_cmd_hdr 6778c2ecf20Sopenharmony_ci{ 6788c2ecf20Sopenharmony_ci __u32 cmdtype; 6798c2ecf20Sopenharmony_ci#define SMU_CMDTYPE_SMU 0 /* SMU command */ 6808c2ecf20Sopenharmony_ci#define SMU_CMDTYPE_WANTS_EVENTS 1 /* switch fd to events mode */ 6818c2ecf20Sopenharmony_ci#define SMU_CMDTYPE_GET_PARTITION 2 /* retrieve an sdb partition */ 6828c2ecf20Sopenharmony_ci 6838c2ecf20Sopenharmony_ci __u8 cmd; /* SMU command byte */ 6848c2ecf20Sopenharmony_ci __u8 pad[3]; /* padding */ 6858c2ecf20Sopenharmony_ci __u32 data_len; /* Length of data following */ 6868c2ecf20Sopenharmony_ci}; 6878c2ecf20Sopenharmony_ci 6888c2ecf20Sopenharmony_cistruct smu_user_reply_hdr 6898c2ecf20Sopenharmony_ci{ 6908c2ecf20Sopenharmony_ci __u32 status; /* Command status */ 6918c2ecf20Sopenharmony_ci __u32 reply_len; /* Length of data follwing */ 6928c2ecf20Sopenharmony_ci}; 6938c2ecf20Sopenharmony_ci 6948c2ecf20Sopenharmony_ci#endif /* _SMU_H */ 695