smu.h
来自「linux 内核源代码」· C头文件 代码 · 共 577 行 · 第 1/2 页
H
577 行
* to ease sending simple SMU commands from the stack */struct smu_simple_cmd{ struct smu_cmd cmd; u8 buffer[16];};/* * Queues a simple command. All fields will be initialized by that * function */extern int smu_queue_simple(struct smu_simple_cmd *scmd, u8 command, unsigned int data_len, void (*done)(struct smu_cmd *cmd, void *misc), void *misc, ...);/* * Completion helper. Pass it to smu_queue_simple or as 'done' * member to smu_queue_cmd, it will call complete() on the struct * completion passed in the "misc" argument */extern void smu_done_complete(struct smu_cmd *cmd, void *misc);/* * Synchronous helpers. Will spin-wait for completion of a command */extern void smu_spinwait_cmd(struct smu_cmd *cmd);static inline void smu_spinwait_simple(struct smu_simple_cmd *scmd){ smu_spinwait_cmd(&scmd->cmd);}/* * Poll routine to call if blocked with irqs off */extern void smu_poll(void);/* * Init routine, presence check.... */extern int smu_init(void);extern int smu_present(void);struct of_device;extern struct of_device *smu_get_ofdev(void);/* * Common command wrappers */extern void smu_shutdown(void);extern void smu_restart(void);struct rtc_time;extern int smu_get_rtc_time(struct rtc_time *time, int spinwait);extern int smu_set_rtc_time(struct rtc_time *time, int spinwait);/* * SMU command buffer absolute address, exported by pmac_setup, * this is allocated very early during boot. */extern unsigned long smu_cmdbuf_abs;/* * Kenrel asynchronous i2c interface */#define SMU_I2C_READ_MAX 0x1d#define SMU_I2C_WRITE_MAX 0x15/* SMU i2c header, exactly matches i2c header on wire */struct smu_i2c_param{ u8 bus; /* SMU bus ID (from device tree) */ u8 type; /* i2c transfer type */ u8 devaddr; /* device address (includes direction) */ u8 sublen; /* subaddress length */ u8 subaddr[3]; /* subaddress */ u8 caddr; /* combined address, filled by SMU driver */ u8 datalen; /* length of transfer */ u8 data[SMU_I2C_READ_MAX]; /* data */};struct smu_i2c_cmd{ /* public */ struct smu_i2c_param info; void (*done)(struct smu_i2c_cmd *cmd, void *misc); void *misc; int status; /* 1 = pending, 0 = ok, <0 = fail */ /* private */ struct smu_cmd scmd; int read; int stage; int retries; u8 pdata[32]; struct list_head link;};/* * Call this to queue an i2c command to the SMU. You must fill info, * including info.data for a write, done and misc. * For now, no polling interface is provided so you have to use completion * callback. */extern int smu_queue_i2c(struct smu_i2c_cmd *cmd);#endif /* __KERNEL__ *//* * - SMU "sdb" partitions informations - *//* * Partition header format */struct smu_sdbp_header { __u8 id; __u8 len; __u8 version; __u8 flags;}; /* * demangle 16 and 32 bits integer in some SMU partitions * (currently, afaik, this concerns only the FVT partition * (0x12) */#define SMU_U16_MIX(x) le16_to_cpu(x);#define SMU_U32_MIX(x) ((((x) & 0xff00ff00u) >> 8)|(((x) & 0x00ff00ffu) << 8))/* This is the definition of the SMU sdb-partition-0x12 table (called * CPU F/V/T operating points in Darwin). The definition for all those * SMU tables should be moved to some separate file */#define SMU_SDB_FVT_ID 0x12struct smu_sdbp_fvt { __u32 sysclk; /* Base SysClk frequency in Hz for * this operating point. Value need to * be unmixed with SMU_U32_MIX() */ __u8 pad; __u8 maxtemp; /* Max temp. supported by this * operating point */ __u16 volts[3]; /* CPU core voltage for the 3 * PowerTune modes, a mode with * 0V = not supported. Value need * to be unmixed with SMU_U16_MIX() */};/* This partition contains voltage & current sensor calibration * informations */#define SMU_SDB_CPUVCP_ID 0x21struct smu_sdbp_cpuvcp { __u16 volt_scale; /* u4.12 fixed point */ __s16 volt_offset; /* s4.12 fixed point */ __u16 curr_scale; /* u4.12 fixed point */ __s16 curr_offset; /* s4.12 fixed point */ __s32 power_quads[3]; /* s4.28 fixed point */};/* This partition contains CPU thermal diode calibration */#define SMU_SDB_CPUDIODE_ID 0x18struct smu_sdbp_cpudiode { __u16 m_value; /* u1.15 fixed point */ __s16 b_value; /* s10.6 fixed point */};/* This partition contains Slots power calibration */#define SMU_SDB_SLOTSPOW_ID 0x78struct smu_sdbp_slotspow { __u16 pow_scale; /* u4.12 fixed point */ __s16 pow_offset; /* s4.12 fixed point */};/* This partition contains machine specific version information about * the sensor/control layout */#define SMU_SDB_SENSORTREE_ID 0x25struct smu_sdbp_sensortree { __u8 model_id; __u8 unknown[3];};/* This partition contains CPU thermal control PID informations. So far * only single CPU machines have been seen with an SMU, so we assume this * carries only informations for those */#define SMU_SDB_CPUPIDDATA_ID 0x17struct smu_sdbp_cpupiddata { __u8 unknown1; __u8 target_temp_delta; __u8 unknown2; __u8 history_len; __s16 power_adj; __u16 max_power; __s32 gp,gr,gd;};/* Other partitions without known structures */#define SMU_SDB_DEBUG_SWITCHES_ID 0x05#ifdef __KERNEL__/* * This returns the pointer to an SMU "sdb" partition data or NULL * if not found. The data format is described below */extern const struct smu_sdbp_header *smu_get_sdb_partition(int id, unsigned int *size);/* Get "sdb" partition data from an SMU satellite */extern struct smu_sdbp_header *smu_sat_get_sdb_partition(unsigned int sat_id, int id, unsigned int *size);#endif /* __KERNEL__ *//* * - Userland interface - *//* * A given instance of the device can be configured for 2 different * things at the moment: * * - sending SMU commands (default at open() time) * - receiving SMU events (not yet implemented) * * Commands are written with write() of a command block. They can be * "driver" commands (for example to switch to event reception mode) * or real SMU commands. They are made of a header followed by command * data if any. * * For SMU commands (not for driver commands), you can then read() back * a reply. The reader will be blocked or not depending on how the device * file is opened. poll() isn't implemented yet. The reply will consist * of a header as well, followed by the reply data if any. You should * always provide a buffer large enough for the maximum reply data, I * recommand one page. * * It is illegal to send SMU commands through a file descriptor configured * for events reception * */struct smu_user_cmd_hdr{ __u32 cmdtype;#define SMU_CMDTYPE_SMU 0 /* SMU command */#define SMU_CMDTYPE_WANTS_EVENTS 1 /* switch fd to events mode */#define SMU_CMDTYPE_GET_PARTITION 2 /* retrieve an sdb partition */ __u8 cmd; /* SMU command byte */ __u8 pad[3]; /* padding */ __u32 data_len; /* Lenght of data following */};struct smu_user_reply_hdr{ __u32 status; /* Command status */ __u32 reply_len; /* Lenght of data follwing */};#endif /* _SMU_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?