Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (pmbus) Add tps40422 front-end driver

For TI power management chip TPS40422, READ_TEMPERATURE_2 command is supported on
page 1 of the chip, but the original driver(pmbus.c) only tried to detect this command
on page 0, this will lead to a result that the temperature sensor in page 1 couldn't
be detected. This change is to isolate the tps40422 driver from pmbus.c into a solo
front-end driver.

Signed-off-by: Zhu Laiwen <richard.zhu@nsn.com>
[Guenter Roeck: Dropped unnecessary license text (fixes checkpatch warning)]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Zhu, Richard \(NSN - CN/Beijing\) and committed by
Guenter Roeck
a8bfeceb 012cb5e2

+142 -6
+2 -3
Documentation/hwmon/pmbus
··· 23 23 http://www.lineagepower.com/oem/pdf/PDT012A0X.pdf 24 24 http://www.lineagepower.com/oem/pdf/UDT020A0X.pdf 25 25 http://www.lineagepower.com/oem/pdf/MDT040A0X.pdf 26 - * Texas Instruments TPS40400, TPS40422 27 - Prefixes: 'tps40400', 'tps40422' 26 + * Texas Instruments TPS40400 27 + Prefixes: 'tps40400' 28 28 Addresses scanned: - 29 29 Datasheets: 30 30 http://www.ti.com/lit/gpn/tps40400 31 - http://www.ti.com/lit/gpn/tps40422 32 31 * Generic PMBus devices 33 32 Prefix: 'pmbus' 34 33 Addresses scanned: -
+64
Documentation/hwmon/tps40422
··· 1 + Kernel driver tps40422 2 + ====================== 3 + 4 + Supported chips: 5 + * TI TPS40422 6 + Prefix: 'tps40422' 7 + Addresses scanned: - 8 + Datasheet: http://www.ti.com/lit/gpn/tps40422 9 + 10 + Author: Zhu Laiwen <richard.zhu@nsn.com> 11 + 12 + 13 + Description 14 + ----------- 15 + 16 + This driver supports TI TPS40422 Dual-Output or Two-Phase Synchronous Buck 17 + Controller with PMBus 18 + 19 + The driver is a client driver to the core PMBus driver. 20 + Please see Documentation/hwmon/pmbus for details on PMBus client drivers. 21 + 22 + 23 + Usage Notes 24 + ----------- 25 + 26 + This driver does not auto-detect devices. You will have to instantiate the 27 + devices explicitly. Please see Documentation/i2c/instantiating-devices for 28 + details. 29 + 30 + 31 + Platform data support 32 + --------------------- 33 + 34 + The driver supports standard PMBus driver platform data. 35 + 36 + 37 + Sysfs entries 38 + ------------- 39 + 40 + The following attributes are supported. 41 + 42 + in[1-2]_label "vout[1-2]" 43 + in[1-2]_input Measured voltage. From READ_VOUT register. 44 + in[1-2]_alarm voltage alarm. 45 + 46 + curr[1-2]_input Measured current. From READ_IOUT register. 47 + curr[1-2]_label "iout[1-2]" 48 + curr1_max Maximum current. From IOUT_OC_WARN_LIMIT register. 49 + curr1_crit Critical maximum current. From IOUT_OC_FAULT_LIMIT register. 50 + curr1_max_alarm Current high alarm. From IOUT_OC_WARN_LIMIT status. 51 + curr1_crit_alarm Current critical high alarm. From IOUT_OC_FAULT status. 52 + curr2_alarm Current high alarm. From IOUT_OC_WARNING status. 53 + 54 + temp1_input Measured temperature. From READ_TEMPERATURE_2 register on page 0. 55 + temp1_max Maximum temperature. From OT_WARN_LIMIT register. 56 + temp1_crit Critical high temperature. From OT_FAULT_LIMIT register. 57 + temp1_max_alarm Chip temperature high alarm. Set by comparing 58 + READ_TEMPERATURE_2 on page 0 with OT_WARN_LIMIT if TEMP_OT_WARNING 59 + status is set. 60 + temp1_crit_alarm Chip temperature critical high alarm. Set by comparing 61 + READ_TEMPERATURE_2 on page 0 with OT_FAULT_LIMIT if TEMP_OT_FAULT 62 + status is set. 63 + temp2_input Measured temperature. From READ_TEMPERATURE_2 register on page 1. 64 + temp2_alarm Chip temperature alarm on page 1.
+11 -2
drivers/hwmon/pmbus/Kconfig
··· 20 20 help 21 21 If you say yes here you get hardware monitoring support for generic 22 22 PMBus devices, including but not limited to ADP4000, BMR453, BMR454, 23 - MDT040, NCP4200, NCP4208, PDT003, PDT006, PDT012, UDT020, TPS40400, 24 - and TPS40422. 23 + MDT040, NCP4200, NCP4208, PDT003, PDT006, PDT012, UDT020, and TPS40400. 25 24 26 25 This driver can also be built as a module. If so, the module will 27 26 be called pmbus. ··· 85 86 86 87 This driver can also be built as a module. If so, the module will 87 88 be called max8688. 89 + 90 + config SENSORS_TPS40422 91 + tristate "TI TPS40422" 92 + default n 93 + help 94 + If you say yes here you get hardware monitoring support for TI 95 + TPS40422. 96 + 97 + This driver can also be built as a module. If so, the module will 98 + be called tps40422. 88 99 89 100 config SENSORS_UCD9000 90 101 tristate "TI UCD90120, UCD90124, UCD9090, UCD90910"
+1
drivers/hwmon/pmbus/Makefile
··· 10 10 obj-$(CONFIG_SENSORS_MAX16064) += max16064.o 11 11 obj-$(CONFIG_SENSORS_MAX34440) += max34440.o 12 12 obj-$(CONFIG_SENSORS_MAX8688) += max8688.o 13 + obj-$(CONFIG_SENSORS_TPS40422) += tps40422.o 13 14 obj-$(CONFIG_SENSORS_UCD9000) += ucd9000.o 14 15 obj-$(CONFIG_SENSORS_UCD9200) += ucd9200.o 15 16 obj-$(CONFIG_SENSORS_ZL6100) += zl6100.o
-1
drivers/hwmon/pmbus/pmbus.c
··· 193 193 {"pdt012", 1}, 194 194 {"pmbus", 0}, 195 195 {"tps40400", 1}, 196 - {"tps40422", 2}, 197 196 {"udt020", 1}, 198 197 {} 199 198 };
+64
drivers/hwmon/pmbus/tps40422.c
··· 1 + /* 2 + * Hardware monitoring driver for TI TPS40422 3 + * 4 + * Copyright (c) 2014 Nokia Solutions and Networks. 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License as published by 8 + * the Free Software Foundation; either version 2 of the License, or 9 + * (at your option) any later version. 10 + * 11 + * This program is distributed in the hope that it will be useful, 12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + * GNU General Public License for more details. 15 + */ 16 + 17 + #include <linux/kernel.h> 18 + #include <linux/module.h> 19 + #include <linux/init.h> 20 + #include <linux/err.h> 21 + #include <linux/i2c.h> 22 + #include "pmbus.h" 23 + 24 + static struct pmbus_driver_info tps40422_info = { 25 + .pages = 2, 26 + .format[PSC_VOLTAGE_IN] = linear, 27 + .format[PSC_VOLTAGE_OUT] = linear, 28 + .format[PSC_TEMPERATURE] = linear, 29 + .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_TEMP2 30 + | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_TEMP 31 + | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT, 32 + .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_TEMP2 33 + | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_TEMP 34 + | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT, 35 + }; 36 + 37 + static int tps40422_probe(struct i2c_client *client, 38 + const struct i2c_device_id *id) 39 + { 40 + return pmbus_do_probe(client, id, &tps40422_info); 41 + } 42 + 43 + static const struct i2c_device_id tps40422_id[] = { 44 + {"tps40422", 0}, 45 + {} 46 + }; 47 + 48 + MODULE_DEVICE_TABLE(i2c, tps40422_id); 49 + 50 + /* This is the driver that will be inserted */ 51 + static struct i2c_driver tps40422_driver = { 52 + .driver = { 53 + .name = "tps40422", 54 + }, 55 + .probe = tps40422_probe, 56 + .remove = pmbus_do_remove, 57 + .id_table = tps40422_id, 58 + }; 59 + 60 + module_i2c_driver(tps40422_driver); 61 + 62 + MODULE_AUTHOR("Zhu Laiwen <richard.zhu@nsn.com>"); 63 + MODULE_DESCRIPTION("PMBus driver for TI TPS40422"); 64 + MODULE_LICENSE("GPL");