Skip to main content

Device Driver

改 driver 通常會動到的是 Driver 及 Device Tree

smbus

alt text alt text

pmbus

Linear11 Floating-Point Format

alt text

Value Represented=Y×2N\text{Value Represented} = Y \times 2^N
user space(例如:sensors) 

PMBus core

mpc42013_read_word_data(client, page, reg)

底層實際透過 I2C 傳送 command code(reg) → 取得 word 資料

可以用 i2cdetect 查看是否有 driver 佔用

alt text

上圖代表在 i2c-7 有 address 0x63 的裝置, 63 代表 no device driver,UU 代表目前有 driver 佔用。

Files

  • Kconfig linux/drivers/hwmon/pmbus/Kconfig
config {driver}
...
  • Driver Documentation

    • 位置: linux/Documentation/devicetree/bindings/hwmon/{driver}.yaml
  • Makefile

    • 位置: linux/drivers/hwmon/pmbus/Makefile
    obj-$(CONFIG_{driver}) += {driver}.o
  • Driver Code

    • 位置: linux/drivers/hwmon/pmbus/{driver}.c
  • Device Tree Alias

    • 位置: linux/arch/arm/boot/dts/{board}-i2c-aliases.dtsi
      alias {
      i2c99 = &{sensor}
      }

Driver Structure

alt text

Functions

  • probe alt text
int pmbus_read_word_data(struct i2c_client *client, u8 page, u8 phase, u8 reg);
int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg);
int pmbus_write_word_data(struct i2c_client *client, u8 page, u8 reg, u16 word);

觀察

  • ls /sys/class/hwmon/hwmon16 alt text

Ref