Adding support to P3T1755 on Linux

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding support to P3T1755 on Linux

Adding support to P3T1755 on Linux

P3T1755DP is a ±0.5°C accurate temperature-to-digital converter with a -40 °C to +125 °C range. It uses an on-chip band gap temperature sensor and an A-to-D conversion technique with overtemperature detection. The temperature register always stores a 12-bit two's complement data, giving a temperature resolution of 0.0625 °C P3T1755DP which can be configured for different operation conditions: continuous conversion, one-shot mode, or shutdown mode.

 

The device has very good features but, unfortunately, is not supported by Linux yet!

 

The P31755 works very similarly to LM75, pct2075, and other compatibles.

 

We can add support to P3T1755 in the LM75.c program due to the process to communicate with the device is the same as LM75 and equivalents.

 

https://github.com/nxp-imx/linux-imx/blob/lf-6.1.55-2.2.0/drivers/hwmon/lm75.c

route:

drivers/hwmon/lm75.c

 

The modifications that we have to do are the next:

 

 1. We have to add the configurations to the kernel on the imx_v8_defconfig file

CONFIG_SENSORS_ARM_SCMI=y

 CONFIG_SENSORS_ARM_SCPI=y

 CONFIG_SENSORS_FP9931=y

+CONFIG_SENSORS_LM75=m

+CONFIG_HWMON=y

+CONFIG_I2C=y

+CONFIG_REGMAP_I2C=y

 CONFIG_SENSORS_LM90=m

 CONFIG_SENSORS_PWM_FAN=m

 CONFIG_SENSORS_SL28CPLD=m

 

 2. Add the part on the list of parts compatible with the driver LM75.c

enum lm75_type {   /* keep sorted in alphabetical order */

  max6626,

  max31725,

  mcp980x,

+ p3t1755,

  pct2075,

  stds75,

  stlm75,

 

3. Add the configuration in the structure lm75_params device_params[].

.default_resolution = 9,

    .default_sample_time = MSEC_PER_SEC / 18,

  },

+ [p3t1755] = {

+   .default_resolution = 12,

+   .default_sample_time = MSEC_PER_SEC / 10,

+ },

  [pct2075] = {

    .default_resolution = 11,

    .default_sample_time = MSEC_PER_SEC / 10,

 

Notes: You can change the configuration of the device using .set_mask and .clear_mask, see more details on LM75.c lines 57 to 78

 

4. Add the ID to the list in the structure i2c_device_id lm75_ids and of_device_id __maybe_unused lm75_of_match 

 

 { "max31725", max31725, },

  { "max31726", max31725, },

  { "mcp980x", mcp980x, },

+ { "p3t1755", p3t1755, },

  { "pct2075", pct2075, },

  { "stds75", stds75, },

  { "stlm75", stlm75, },

 

+ {

+   .compatible = "nxp,p3t1755",

+   .data = (void *)p3t1755

+ },

 

5. In addition to all modifications, I modify the device tree of my iMX8MP-EVK to connect the Sensor in I2C3 of the board. 

https://github.com/nxp-imx/linux-imx/blob/lf-6.1.55-2.2.0/arch/arm64/boot/dts/freescale/imx8mp-evk.d...

 

    };

  };

+

+ p3t1755: p3t1755@48 {

+   compatible = "nxp,p3t1755";

+   reg = <0x48>;

+ };

+

 };

 

Connections:

We will use the expansion connector of the iMX8MP-EVK and J9 of the P3T1755DP-ARD board.

 

P3T1755DP-ARD boardChavira_1-1714499607542.png

 

Chavira_2-1714499681249.png

iMX8MP-EVK

 

P3T1755DP-ARD ----> iMX8MP-EVK

J9              ---------->            J21

+3v3 (Pin 9) ---> +3v3 (Pin 1)

GND(Pin 7) ---> GND (PIN 9)

SCL (Pin 4) ---> SCL (Pin 5)

SDA (Pin 3) ---> SDA (Pin 3)

Chavira_3-1714500611037.jpegChavira_4-1714500618352.jpeg

 

 

Reading the Sensor

We can read the sensor using the next commands:

 

Read Temperature:

$ cat /sys/class/hwmon/hwmon1/temp1_input

Reading maximum temperature:

$ cat /sys/class/hwmon/hwmon1/temp1_max

Reading hysteresis:

$ cat /sys/class/hwmon/hwmon1/temp1_max_hyst
Chavira_0-1714498794795.png
 
 
 
No ratings
Version history
Last update:
‎04-30-2024 11:23 AM
Updated by: