Re: [PATCH v2 2/2] hwmon: Add driver for Texas Instruments TMP464 sensor chip

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Agathe,

On 2/11/22 02:11, Agathe Porte wrote:
[ ... ]

+
+static int tmp464_init_client(struct tmp464_data *data)
+{
+    int err;
+    int config, config_orig;
+    struct i2c_client *client = data->client;
+
+    config = i2c_smbus_read_word_swapped(client, TMP464_CONFIG_REG);
+    if (config < 0) {
+        dev_err(&client->dev,
+            "Could not read configuration register (%d)\n", config);
+        return config;
+    }
+
+    /* Set the conversion rate to 2 Hz */
+    config_orig = config;
+    config &= ~TMP464_CONFIG_CONVERSION_RATE_MASK;
+    config |= (0x05) << TMP464_CONFIG_CONVERSION_RATE_B0;
+
+    /* Start conversions (disable shutdown if necessary) */
+    config_orig = config;
+    config &= ~TMP464_CONFIG_SHUTDOWN;
+
+    if (config != config_orig) {
+        config = i2c_smbus_write_word_data(client, TMP464_CONFIG_REG, config);
+        if (config < 0) {
+            dev_err(&client->dev,
+                "Could not write configuration register (%d)\n", err);
+            return config;
+        }
+    }
+
+    return tmp464_enable_channels(data);
+}
+

Turns out the chip is by default locked, meaning all those configuration writes
fail unless I explicitly unlock the chip. How would you suggest to handle that
situation, and how do you handle it in your application ?

Thanks,
Guenter



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux