nicsensor/extension/pmbus_cmd_list.sh
leimingsheng 88f871c880 feat(master) update to 1.10 base dev 2
1.[新增功能]解耦脚本参数配置功能, 脚本配置全部放到project.config中
2.[新增功能]增加对pmbus set命令的支持
3.[新增功能]增加setup.sh, 用于一键部署脚本
4.[功能优化]代码结构目录重新归档
2026-04-17 17:09:43 +08:00

195 lines
5.2 KiB
Bash

#!/bin/sh
# Desc : This script used to find pmbus code and read size
# Changelist : 2025-12-25|v0.1 Create this file
# 2026-04-17|v1.1 Add PAGE command support
# How to use this pmbus plugin?
# Follow readme.md file to use this plugin or use setup.sh to install this plugin
EXTENSION_VERSION="v1.1"
# ---------------------------------------------------------
# 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] <data>"
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 " - <data> : The data which will set to the power manage chip, only set operation type is set"
echo " 3) E.G. : ./nicsensor.sh pcie1 pmbus 0x60 READ_TEMPERATURE_1"
echo " : ./nicsensor.sh pcie1 pmbus 0x60 PAGE 0x00"
echo ""
echo " *****************Pmbus Support Command List********************"
echo " Command Name Code op_type Read Size "
echo " PAGE 0x00 set Byte "
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
"PAGE")
hex_cmd=0x00
;;
"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
"PAGE")
op_type="set"
;;
"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
"PAGE")
read_size=$PMBUS_BYTE
;;
"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