.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Driver for Lineage Compact Power Line series of power entry modules. |
---|
3 | 4 | * |
---|
.. | .. |
---|
5 | 6 | * |
---|
6 | 7 | * Documentation: |
---|
7 | 8 | * http://www.lineagepower.com/oem/pdf/CPLI2C.pdf |
---|
8 | | - * |
---|
9 | | - * This program is free software; you can redistribute it and/or modify |
---|
10 | | - * it under the terms of the GNU General Public License as published by |
---|
11 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
12 | | - * (at your option) any later version. |
---|
13 | | - * |
---|
14 | | - * This program is distributed in the hope that it will be useful, |
---|
15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | | - * GNU General Public License for more details. |
---|
18 | | - * |
---|
19 | | - * You should have received a copy of the GNU General Public License |
---|
20 | | - * along with this program; if not, write to the Free Software |
---|
21 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
22 | 9 | */ |
---|
23 | 10 | |
---|
24 | 11 | #include <linux/kernel.h> |
---|
.. | .. |
---|
282 | 269 | * Show boolean, either a fault or an alarm. |
---|
283 | 270 | * .nr points to the register, .index is the bit mask to check |
---|
284 | 271 | */ |
---|
285 | | -static ssize_t pem_show_bool(struct device *dev, |
---|
286 | | - struct device_attribute *da, char *buf) |
---|
| 272 | +static ssize_t pem_bool_show(struct device *dev, struct device_attribute *da, |
---|
| 273 | + char *buf) |
---|
287 | 274 | { |
---|
288 | 275 | struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(da); |
---|
289 | 276 | struct pem_data *data = pem_update_device(dev); |
---|
.. | .. |
---|
296 | 283 | return snprintf(buf, PAGE_SIZE, "%d\n", !!status); |
---|
297 | 284 | } |
---|
298 | 285 | |
---|
299 | | -static ssize_t pem_show_data(struct device *dev, struct device_attribute *da, |
---|
| 286 | +static ssize_t pem_data_show(struct device *dev, struct device_attribute *da, |
---|
300 | 287 | char *buf) |
---|
301 | 288 | { |
---|
302 | 289 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
---|
.. | .. |
---|
312 | 299 | return snprintf(buf, PAGE_SIZE, "%ld\n", value); |
---|
313 | 300 | } |
---|
314 | 301 | |
---|
315 | | -static ssize_t pem_show_input(struct device *dev, struct device_attribute *da, |
---|
| 302 | +static ssize_t pem_input_show(struct device *dev, struct device_attribute *da, |
---|
316 | 303 | char *buf) |
---|
317 | 304 | { |
---|
318 | 305 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
---|
.. | .. |
---|
328 | 315 | return snprintf(buf, PAGE_SIZE, "%ld\n", value); |
---|
329 | 316 | } |
---|
330 | 317 | |
---|
331 | | -static ssize_t pem_show_fan(struct device *dev, struct device_attribute *da, |
---|
| 318 | +static ssize_t pem_fan_show(struct device *dev, struct device_attribute *da, |
---|
332 | 319 | char *buf) |
---|
333 | 320 | { |
---|
334 | 321 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
---|
.. | .. |
---|
345 | 332 | } |
---|
346 | 333 | |
---|
347 | 334 | /* Voltages */ |
---|
348 | | -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, pem_show_data, NULL, |
---|
349 | | - PEM_DATA_VOUT_LSB); |
---|
350 | | -static SENSOR_DEVICE_ATTR_2(in1_alarm, S_IRUGO, pem_show_bool, NULL, |
---|
351 | | - PEM_DATA_ALARM_1, ALRM1_VOUT_OUT_LIMIT); |
---|
352 | | -static SENSOR_DEVICE_ATTR_2(in1_crit_alarm, S_IRUGO, pem_show_bool, NULL, |
---|
353 | | - PEM_DATA_ALARM_1, ALRM1_OV_VOLT_SHUTDOWN); |
---|
354 | | -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, pem_show_input, NULL, |
---|
355 | | - PEM_INPUT_VOLTAGE); |
---|
356 | | -static SENSOR_DEVICE_ATTR_2(in2_alarm, S_IRUGO, pem_show_bool, NULL, |
---|
357 | | - PEM_DATA_ALARM_1, |
---|
358 | | - ALRM1_VIN_OUT_LIMIT | ALRM1_PRIMARY_FAULT); |
---|
| 335 | +static SENSOR_DEVICE_ATTR_RO(in1_input, pem_data, PEM_DATA_VOUT_LSB); |
---|
| 336 | +static SENSOR_DEVICE_ATTR_2_RO(in1_alarm, pem_bool, PEM_DATA_ALARM_1, |
---|
| 337 | + ALRM1_VOUT_OUT_LIMIT); |
---|
| 338 | +static SENSOR_DEVICE_ATTR_2_RO(in1_crit_alarm, pem_bool, PEM_DATA_ALARM_1, |
---|
| 339 | + ALRM1_OV_VOLT_SHUTDOWN); |
---|
| 340 | +static SENSOR_DEVICE_ATTR_RO(in2_input, pem_input, PEM_INPUT_VOLTAGE); |
---|
| 341 | +static SENSOR_DEVICE_ATTR_2_RO(in2_alarm, pem_bool, PEM_DATA_ALARM_1, |
---|
| 342 | + ALRM1_VIN_OUT_LIMIT | ALRM1_PRIMARY_FAULT); |
---|
359 | 343 | |
---|
360 | 344 | /* Currents */ |
---|
361 | | -static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, pem_show_data, NULL, |
---|
362 | | - PEM_DATA_CURRENT); |
---|
363 | | -static SENSOR_DEVICE_ATTR_2(curr1_alarm, S_IRUGO, pem_show_bool, NULL, |
---|
364 | | - PEM_DATA_ALARM_1, ALRM1_VIN_OVERCURRENT); |
---|
| 345 | +static SENSOR_DEVICE_ATTR_RO(curr1_input, pem_data, PEM_DATA_CURRENT); |
---|
| 346 | +static SENSOR_DEVICE_ATTR_2_RO(curr1_alarm, pem_bool, PEM_DATA_ALARM_1, |
---|
| 347 | + ALRM1_VIN_OVERCURRENT); |
---|
365 | 348 | |
---|
366 | 349 | /* Power */ |
---|
367 | | -static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, pem_show_input, NULL, |
---|
368 | | - PEM_INPUT_POWER_LSB); |
---|
369 | | -static SENSOR_DEVICE_ATTR_2(power1_alarm, S_IRUGO, pem_show_bool, NULL, |
---|
370 | | - PEM_DATA_ALARM_1, ALRM1_POWER_LIMIT); |
---|
| 350 | +static SENSOR_DEVICE_ATTR_RO(power1_input, pem_input, PEM_INPUT_POWER_LSB); |
---|
| 351 | +static SENSOR_DEVICE_ATTR_2_RO(power1_alarm, pem_bool, PEM_DATA_ALARM_1, |
---|
| 352 | + ALRM1_POWER_LIMIT); |
---|
371 | 353 | |
---|
372 | 354 | /* Fans */ |
---|
373 | | -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, pem_show_fan, NULL, |
---|
374 | | - PEM_FAN_FAN1); |
---|
375 | | -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, pem_show_fan, NULL, |
---|
376 | | - PEM_FAN_FAN2); |
---|
377 | | -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, pem_show_fan, NULL, |
---|
378 | | - PEM_FAN_FAN3); |
---|
379 | | -static SENSOR_DEVICE_ATTR_2(fan1_alarm, S_IRUGO, pem_show_bool, NULL, |
---|
380 | | - PEM_DATA_ALARM_2, ALRM2_FAN_FAULT); |
---|
| 355 | +static SENSOR_DEVICE_ATTR_RO(fan1_input, pem_fan, PEM_FAN_FAN1); |
---|
| 356 | +static SENSOR_DEVICE_ATTR_RO(fan2_input, pem_fan, PEM_FAN_FAN2); |
---|
| 357 | +static SENSOR_DEVICE_ATTR_RO(fan3_input, pem_fan, PEM_FAN_FAN3); |
---|
| 358 | +static SENSOR_DEVICE_ATTR_2_RO(fan1_alarm, pem_bool, PEM_DATA_ALARM_2, |
---|
| 359 | + ALRM2_FAN_FAULT); |
---|
381 | 360 | |
---|
382 | 361 | /* Temperatures */ |
---|
383 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, pem_show_data, NULL, |
---|
384 | | - PEM_DATA_TEMP); |
---|
385 | | -static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, pem_show_data, NULL, |
---|
386 | | - PEM_DATA_TEMP_MAX); |
---|
387 | | -static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, pem_show_data, NULL, |
---|
388 | | - PEM_DATA_TEMP_CRIT); |
---|
389 | | -static SENSOR_DEVICE_ATTR_2(temp1_alarm, S_IRUGO, pem_show_bool, NULL, |
---|
390 | | - PEM_DATA_ALARM_1, ALRM1_TEMP_WARNING); |
---|
391 | | -static SENSOR_DEVICE_ATTR_2(temp1_crit_alarm, S_IRUGO, pem_show_bool, NULL, |
---|
392 | | - PEM_DATA_ALARM_1, ALRM1_TEMP_SHUTDOWN); |
---|
393 | | -static SENSOR_DEVICE_ATTR_2(temp1_fault, S_IRUGO, pem_show_bool, NULL, |
---|
394 | | - PEM_DATA_ALARM_2, ALRM2_TEMP_FAULT); |
---|
| 362 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, pem_data, PEM_DATA_TEMP); |
---|
| 363 | +static SENSOR_DEVICE_ATTR_RO(temp1_max, pem_data, PEM_DATA_TEMP_MAX); |
---|
| 364 | +static SENSOR_DEVICE_ATTR_RO(temp1_crit, pem_data, PEM_DATA_TEMP_CRIT); |
---|
| 365 | +static SENSOR_DEVICE_ATTR_2_RO(temp1_alarm, pem_bool, PEM_DATA_ALARM_1, |
---|
| 366 | + ALRM1_TEMP_WARNING); |
---|
| 367 | +static SENSOR_DEVICE_ATTR_2_RO(temp1_crit_alarm, pem_bool, PEM_DATA_ALARM_1, |
---|
| 368 | + ALRM1_TEMP_SHUTDOWN); |
---|
| 369 | +static SENSOR_DEVICE_ATTR_2_RO(temp1_fault, pem_bool, PEM_DATA_ALARM_2, |
---|
| 370 | + ALRM2_TEMP_FAULT); |
---|
395 | 371 | |
---|
396 | 372 | static struct attribute *pem_attributes[] = { |
---|
397 | 373 | &sensor_dev_attr_in1_input.dev_attr.attr, |
---|
.. | .. |
---|
441 | 417 | .attrs = pem_fan_attributes, |
---|
442 | 418 | }; |
---|
443 | 419 | |
---|
444 | | -static int pem_probe(struct i2c_client *client, |
---|
445 | | - const struct i2c_device_id *id) |
---|
| 420 | +static int pem_probe(struct i2c_client *client) |
---|
446 | 421 | { |
---|
447 | 422 | struct i2c_adapter *adapter = client->adapter; |
---|
448 | 423 | struct device *dev = &client->dev; |
---|
.. | .. |
---|
536 | 511 | .driver = { |
---|
537 | 512 | .name = "lineage_pem", |
---|
538 | 513 | }, |
---|
539 | | - .probe = pem_probe, |
---|
| 514 | + .probe_new = pem_probe, |
---|
540 | 515 | .id_table = pem_id, |
---|
541 | 516 | }; |
---|
542 | 517 | |
---|