#!/bin/sh # Desc : This script used to find pmbus code and read size # Todo : Support PMBUS Setting Function # Version : 0.1 # Date : 2025-12-25 # Changelist : 2025-12-25|v0.1 Create this file # How to use this pmbus plugin? # Copy this file to the dir as same as nicsensor.sh EXTENSION_VERSION="v1.0" # --------------------------------------------------------- # Varible Define # --------------------------------------------------------- operation_type=$1 str_cmd=$2 hex_cmd=0xff read_size=0 PMBUS_BYTE=1 PMBUS_WORD=2 PMBUS_BLOCK=3 PMBUS_RAW=4 # --------------------------------------------------------- # Function Define # --------------------------------------------------------- pmbus_command_help(){ echo " Extend Function - PMBUS command test" echo " Version : $EXTENSION_VERSION" echo " 1) Command Format : ./nicsensor.sh [slot] pmbus [slave] [command]" echo " 2) Option Detail" echo " - [slot] : 0 1 2 3 4 5 ..." echo " - [slave] : power manage chip slave address , please provide 7 bit address" echo " - [command] : The pmbus command which will set to the power manage chip" echo " 3) E.G. : ./nicsensor.sh pcie1 pmbus 0x60 READ_TEMPERATURE_1" echo "" echo " *****************Pmbus Support Command List********************" echo " Command Name Code op_type Read Size " echo " READ_VIN 0x88 get Word " echo " READ_IIN 0x89 get Word " echo " READ_VOUT 0x8b get Word " echo " READ_IOUT 0x8c get Word " echo " READ_TEMPERATURE_1 0x8d get Word " echo " READ_TEMPERATURE_2 0x8e get Word " echo " READ_TEMPERATURE_3 0x8f get Word " echo " READ_POUT 0x96 get Word " echo " READ_PIN 0x97 get Word " echo " ***************************************************************" echo "" } find_pmbus_hex_code(){ case ${str_cmd} in "READ_VIN") hex_cmd=0x88 ;; "READ_IIN") hex_cmd=0x89 ;; "READ_VOUT") hex_cmd=0x8b ;; "READ_IOUT") hex_cmd=0x8c ;; "READ_TEMPERATURE_1") hex_cmd=0x8d ;; "READ_TEMPERATURE_2") hex_cmd=0x8e ;; "READ_TEMPERATURE_3") hex_cmd=0x8f ;; "READ_POUT") hex_cmd=0x96 ;; "READ_PIN") hex_cmd=0x97 ;; *) hex_cmd=0xff ;; esac echo $hex_cmd } find_pmbus_operation_type(){ case ${str_cmd} in "READ_VIN") op_type="get" ;; "READ_IIN") op_type="get" ;; "READ_VOUT") op_type="get" ;; "READ_IOUT") op_type="get" ;; "READ_TEMPERATURE_1") op_type="get" ;; "READ_TEMPERATURE_2") op_type="get" ;; "READ_TEMPERATURE_3") op_type="get" ;; "READ_POUT") op_type="get" ;; "READ_PIN") op_type="get" ;; *) op_type="" ;; esac echo $op_type } find_pmbus_read_size(){ case ${str_cmd} in "READ_VIN") read_size=$PMBUS_WORD ;; "READ_IIN") read_size=$PMBUS_WORD ;; "READ_VOUT") read_size=$PMBUS_WORD ;; "READ_IOUT") read_size=$PMBUS_WORD ;; "READ_TEMPERATURE_1") read_size=$PMBUS_WORD ;; "READ_TEMPERATURE_2") read_size=$PMBUS_WORD ;; "READ_TEMPERATURE_3") read_size=$PMBUS_WORD ;; "READ_POUT") read_size=$PMBUS_WORD ;; "READ_PIN") read_size=$PMBUS_WORD ;; *) read_size=0 ;; esac echo $read_size } main(){ case ${operation_type} in "code") find_pmbus_hex_code ;; "operation") find_pmbus_operation_type ;; "size") find_pmbus_read_size ;; "help") pmbus_command_help ;; *) echo "Error command type" ;; esac } # --------------------------------------------------------- # Start Execute Script(main) # --------------------------------------------------------- main