Lines Matching +full:alert +full:- +full:celsius
1 // SPDX-License-Identifier: GPL-2.0+
3 * mcp9600.c - Support for Microchip MCP9600 thermocouple EMF converter
31 #define MCP9600_ALERT_CFG(x) (MCP9600_ALERT_CFG1 + (x - 1))
37 #define MCP9600_ALERT_HYSTERESIS(x) (MCP9600_ALERT_HYSTERESIS1 + (x - 1))
39 #define MCP9600_ALERT_LIMIT(x) (MCP9600_ALERT_LIMIT1 + (x - 1))
48 #define MCP9600_MIN_TEMP_HOT_JUNCTION_MICRO -200000000
51 #define MCP9600_MIN_TEMP_COLD_JUNCTION_MICRO -40000000
108 MCP9600_CHANNELS(0, 0, 0, 0), /* Alerts: - - - - */
109 MCP9600_CHANNELS(1, 0, 0, 0), /* Alerts: 1 - - - */
110 MCP9600_CHANNELS(1, 1, 0, 0), /* Alerts: - 2 - - */
111 MCP9600_CHANNELS(2, 0, 0, 0), /* Alerts: 1 2 - - */
112 MCP9600_CHANNELS(0, 0, 1, 0), /* Alerts: - - 3 - */
113 MCP9600_CHANNELS(1, 0, 1, 0), /* Alerts: 1 - 3 - */
114 MCP9600_CHANNELS(1, 1, 1, 0), /* Alerts: - 2 3 - */
115 MCP9600_CHANNELS(2, 0, 1, 0), /* Alerts: 1 2 3 - */
116 MCP9600_CHANNELS(0, 0, 1, 1), /* Alerts: - - - 4 */
117 MCP9600_CHANNELS(1, 0, 1, 1), /* Alerts: 1 - - 4 */
118 MCP9600_CHANNELS(1, 1, 1, 1), /* Alerts: - 2 - 4 */
119 MCP9600_CHANNELS(2, 0, 1, 1), /* Alerts: 1 2 - 4 */
120 MCP9600_CHANNELS(0, 0, 2, 0), /* Alerts: - - 3 4 */
121 MCP9600_CHANNELS(1, 0, 2, 0), /* Alerts: 1 - 3 4 */
122 MCP9600_CHANNELS(1, 1, 2, 0), /* Alerts: - 2 3 4 */
135 ret = i2c_smbus_read_word_swapped(data->client, chan->address); in mcp9600_read()
163 return -EINVAL; in mcp9600_read_raw()
188 struct i2c_client *client = data->client; in mcp9600_read_event_config()
191 i = mcp9600_get_alert_index(chan->channel2, dir); in mcp9600_read_event_config()
206 struct i2c_client *client = data->client; in mcp9600_write_event_config()
209 i = mcp9600_get_alert_index(chan->channel2, dir); in mcp9600_write_event_config()
229 struct i2c_client *client = data->client; in mcp9600_read_thresh()
233 i = mcp9600_get_alert_index(chan->channel2, dir); in mcp9600_read_thresh()
241 * bits(15:2), LSB is 0.25 degree celsius. in mcp9600_read_thresh()
254 return -EINVAL; in mcp9600_read_thresh()
265 struct i2c_client *client = data->client; in mcp9600_write_thresh()
270 i = mcp9600_get_alert_index(chan->channel2, dir); in mcp9600_write_thresh()
274 s_val = (val < 0) ? ((val * 1000000) - val2) : in mcp9600_write_thresh()
276 if (chan->channel2 == IIO_MOD_TEMP_AMBIENT) { in mcp9600_write_thresh()
298 return -EINVAL; in mcp9600_write_thresh()
311 enum mcp9600_alert alert, in mcp9600_alert_handler() argument
319 ret = i2c_smbus_read_byte_data(data->client, MCP9600_STATUS); in mcp9600_alert_handler()
323 if (!(ret & MCP9600_STATUS_ALERT(alert))) in mcp9600_alert_handler()
368 struct i2c_client *client = data->client; in mcp9600_probe_alerts()
369 struct device *dev = &client->dev; in mcp9600_probe_alerts()
425 return dev_err_probe(&client->dev, ret, "Failed to read device ID\n"); in mcp9600_probe()
427 dev_warn(&client->dev, "Expected ID %x, got %x\n", in mcp9600_probe()
430 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); in mcp9600_probe()
432 return -ENOMEM; in mcp9600_probe()
435 data->client = client; in mcp9600_probe()
441 indio_dev->info = &mcp9600_info; in mcp9600_probe()
442 indio_dev->name = "mcp9600"; in mcp9600_probe()
443 indio_dev->modes = INDIO_DIRECT_MODE; in mcp9600_probe()
444 indio_dev->channels = mcp9600_channels[ch_sel]; in mcp9600_probe()
445 indio_dev->num_channels = ARRAY_SIZE(mcp9600_channels[ch_sel]); in mcp9600_probe()
447 return devm_iio_device_register(&client->dev, indio_dev); in mcp9600_probe()