Merge tag 'hwmon-for-linus-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon updates from Guenter Roeck:

- new drivers:
- Lantiq CPU temperature sensor
- IBM CFF power supply
- TPS53679 PMBus driver

- new support:
- LM5066I (lm25066 PMBus driver)
- Intel VID protocol VR13 (PMBus drivers)
- CAT34TS02C, GT30TS00, GT34TS02, and CAT34TS04 (jc42 driver)

- cleanup and minor improvements in several drivers

* tag 'hwmon-for-linus-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (36 commits)
hwmon: (ltq-cputemp) add cpu temp sensor driver
hwmon: (ltq-cputemp) add devicetree bindings documentation
hwmon: (pmbus) Add support for Texas Instruments tps53679 device
hwmon: (asc7621) make several arrays static const
hwmon: (pmbus/lm25066) Add support for TI LM5066I
hwmon: (pmbus/lm25066) Offset coefficient depends on CL
hwmon: (pmbus) Add support for Intel VID protocol VR13
Documentation: hwmon: Document the IBM CFF power supply
hwmon: (pmbus) Add IBM Common Form Factor (CFF) power supply driver
dt-bindings: hwmon: Document the IBM CCF power supply version 1
hwmon: (ftsteutates) constify i2c_device_id
hwmon: da9052: Add support for TSI channel
mfd: da9052: Make touchscreen registration optional
hwmon: da9052: Replace S_IRUGO with 0444
mfd: da9052: Add register details for TSI
hwmon: (aspeed-pwm) add THERMAL dependency
hwmon: (pmbus) Add debugfs for status registers
hwmon: (aspeed-pwm-tacho) cooling device support.
Documentation: dt-bindings: aspeed-pwm-tacho cooling device.
hwmon: (pmbus): Add generic alarm bit for iin and pin
...

+1505 -138
+9
Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt
··· 11 11 12 12 - #size-cells : should be 1. 13 13 14 + - #cooling-cells: should be 2. 15 + 14 16 - reg : address and length of the register set for the device. 15 17 16 18 - pinctrl-names : a pinctrl state named "default" must be defined. ··· 30 28 Under fan subnode there can upto 8 child nodes, with each child node 31 29 representing a fan. If there are 8 fans each fan can have one PWM port and 32 30 one/two Fan tach inputs. 31 + For PWM port can be configured cooling-levels to create cooling device. 32 + Cooling device could be bound to a thermal zone for the thermal control. 33 33 34 34 Required properties for each child node: 35 35 - reg : should specify PWM source port. 36 36 integer value in the range 0 to 7 with 0 indicating PWM port A and 37 37 7 indicating PWM port H. 38 + 39 + - cooling-levels: PWM duty cycle values in a range from 0 to 255 40 + which correspond to thermal cooling states. 38 41 39 42 - aspeed,fan-tach-ch : should specify the Fan tach input channel. 40 43 integer value in the range 0 through 15, with 0 indicating ··· 57 50 pwm_tacho: pwmtachocontroller@1e786000 { 58 51 #address-cells = <1>; 59 52 #size-cells = <1>; 53 + #cooling-cells = <2>; 60 54 reg = <0x1E786000 0x1000>; 61 55 compatible = "aspeed,ast2500-pwm-tacho"; 62 56 clocks = <&pwm_tacho_fixed_clk>; ··· 66 58 67 59 fan@0 { 68 60 reg = <0x00>; 61 + cooling-levels = /bits/ 8 <125 151 177 203 229 255>; 69 62 aspeed,fan-tach-ch = /bits/ 8 <0x00>; 70 63 }; 71 64
+21
Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt
··· 1 + Device-tree bindings for IBM Common Form Factor Power Supply Version 1 2 + ---------------------------------------------------------------------- 3 + 4 + Required properties: 5 + - compatible = "ibm,cffps1"; 6 + - reg = < I2C bus address >; : Address of the power supply on the 7 + I2C bus. 8 + 9 + Example: 10 + 11 + i2c-bus@100 { 12 + #address-cells = <1>; 13 + #size-cells = <0>; 14 + #interrupt-cells = <1>; 15 + < more properties > 16 + 17 + power-supply@68 { 18 + compatible = "ibm,cffps1"; 19 + reg = <0x68>; 20 + }; 21 + };
+10
Documentation/devicetree/bindings/hwmon/ltq-cputemp.txt
··· 1 + Lantiq cpu temperatur sensor 2 + 3 + Requires node properties: 4 + - compatible value : 5 + "lantiq,cputemp" 6 + 7 + Example: 8 + cputemp@0 { 9 + compatible = "lantiq,cputemp"; 10 + };
+4
Documentation/hwmon/ftsteutates
··· 18 18 8 fans. It also contains an integrated watchdog which is currently 19 19 implemented in this driver. 20 20 21 + To clear a temperature or fan alarm, execute the following command with the 22 + correct path to the alarm file: 23 + echo 0 >XXXX_alarm 24 + 21 25 Specification of the chip can be found here: 22 26 ftp://ftp.ts.fujitsu.com/pub/Mainboard-OEM-Sales/Services/Software&Tools/Linux_SystemMonitoring&Watchdog&GPIO/BMC-Teutates_Specification_V1.21.pdf 23 27 ftp://ftp.ts.fujitsu.com/pub/Mainboard-OEM-Sales/Services/Software&Tools/Linux_SystemMonitoring&Watchdog&GPIO/Fujitsu_mainboards-1-Sensors_HowTo-en-US.pdf
+54
Documentation/hwmon/ibm-cffps
··· 1 + Kernel driver ibm-cffps 2 + ======================= 3 + 4 + Supported chips: 5 + * IBM Common Form Factor power supply 6 + 7 + Author: Eddie James <eajames@us.ibm.com> 8 + 9 + Description 10 + ----------- 11 + 12 + This driver supports IBM Common Form Factor (CFF) power supplies. This driver 13 + is a client to the core PMBus driver. 14 + 15 + Usage Notes 16 + ----------- 17 + 18 + This driver does not auto-detect devices. You will have to instantiate the 19 + devices explicitly. Please see Documentation/i2c/instantiating-devices for 20 + details. 21 + 22 + Sysfs entries 23 + ------------- 24 + 25 + The following attributes are supported: 26 + 27 + curr1_alarm Output current over-current alarm. 28 + curr1_input Measured output current in mA. 29 + curr1_label "iout1" 30 + 31 + fan1_alarm Fan 1 warning. 32 + fan1_fault Fan 1 fault. 33 + fan1_input Fan 1 speed in RPM. 34 + fan2_alarm Fan 2 warning. 35 + fan2_fault Fan 2 fault. 36 + fan2_input Fan 2 speed in RPM. 37 + 38 + in1_alarm Input voltage under-voltage alarm. 39 + in1_input Measured input voltage in mV. 40 + in1_label "vin" 41 + in2_alarm Output voltage over-voltage alarm. 42 + in2_input Measured output voltage in mV. 43 + in2_label "vout1" 44 + 45 + power1_alarm Input fault or alarm. 46 + power1_input Measured input power in uW. 47 + power1_label "pin" 48 + 49 + temp1_alarm PSU inlet ambient temperature over-temperature alarm. 50 + temp1_input Measured PSU inlet ambient temp in millidegrees C. 51 + temp2_alarm Secondary rectifier temp over-temperature alarm. 52 + temp2_input Measured secondary rectifier temp in millidegrees C. 53 + temp3_alarm ORing FET temperature over-temperature alarm. 54 + temp3_input Measured ORing FET temperature in millidegrees C.
+7 -2
Documentation/hwmon/lm25066
··· 29 29 Addresses scanned: - 30 30 Datasheet: 31 31 http://www.national.com/pf/LM/LM5066.html 32 + * Texas Instruments LM5066I 33 + Prefix: 'lm5066i' 34 + Addresses scanned: - 35 + Datasheet: 36 + http://www.ti.com/product/LM5066I 32 37 33 38 Author: Guenter Roeck <linux@roeck-us.net> 34 39 ··· 42 37 ----------- 43 38 44 39 This driver supports hardware monitoring for National Semiconductor / TI LM25056, 45 - LM25063, LM25066, LM5064, and LM5066 Power Management, Monitoring, Control, and 46 - Protection ICs. 40 + LM25063, LM25066, LM5064, and LM5066/LM5066I Power Management, Monitoring, 41 + Control, and Protection ICs. 47 42 48 43 The driver is a client driver to the core PMBus driver. Please see 49 44 Documentation/hwmon/pmbus for details on PMBus client drivers.
+8
drivers/hwmon/Kconfig
··· 343 343 344 344 config SENSORS_ASPEED 345 345 tristate "ASPEED AST2400/AST2500 PWM and Fan tach driver" 346 + depends on THERMAL || THERMAL=n 346 347 select REGMAP 347 348 help 348 349 This driver provides support for ASPEED AST2400/AST2500 PWM ··· 790 789 791 790 This driver can also be built as a module. If so, the module will 792 791 be called ltc4261. 792 + 793 + config SENSORS_LTQ_CPUTEMP 794 + bool "Lantiq cpu temperature sensor driver" 795 + depends on LANTIQ 796 + help 797 + If you say yes here you get support for the temperature 798 + sensor inside your CPU. 793 799 794 800 config SENSORS_MAX1111 795 801 tristate "Maxim MAX1111 Serial 8-bit ADC chip and compatibles"
+1
drivers/hwmon/Makefile
··· 110 110 obj-$(CONFIG_SENSORS_LTC4245) += ltc4245.o 111 111 obj-$(CONFIG_SENSORS_LTC4260) += ltc4260.o 112 112 obj-$(CONFIG_SENSORS_LTC4261) += ltc4261.o 113 + obj-$(CONFIG_SENSORS_LTQ_CPUTEMP) += ltq-cputemp.o 113 114 obj-$(CONFIG_SENSORS_MAX1111) += max1111.o 114 115 obj-$(CONFIG_SENSORS_MAX16065) += max16065.o 115 116 obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
+1 -1
drivers/hwmon/adc128d818.c
··· 384 384 NULL 385 385 }; 386 386 387 - static struct attribute_group adc128_group = { 387 + static const struct attribute_group adc128_group = { 388 388 .attrs = adc128_attrs, 389 389 .is_visible = adc128_is_visible, 390 390 };
+6 -8
drivers/hwmon/ads1015.c
··· 191 191 unsigned int data_rate = ADS1015_DEFAULT_DATA_RATE; 192 192 193 193 if (of_property_read_u32(node, "reg", &pval)) { 194 - dev_err(&client->dev, "invalid reg on %s\n", 195 - node->full_name); 194 + dev_err(&client->dev, "invalid reg on %pOF\n", node); 196 195 continue; 197 196 } 198 197 199 198 channel = pval; 200 199 if (channel >= ADS1015_CHANNELS) { 201 200 dev_err(&client->dev, 202 - "invalid channel index %d on %s\n", 203 - channel, node->full_name); 201 + "invalid channel index %d on %pOF\n", 202 + channel, node); 204 203 continue; 205 204 } 206 205 207 206 if (!of_property_read_u32(node, "ti,gain", &pval)) { 208 207 pga = pval; 209 208 if (pga > 6) { 210 - dev_err(&client->dev, "invalid gain on %s\n", 211 - node->full_name); 209 + dev_err(&client->dev, "invalid gain on %pOF\n", 210 + node); 212 211 return -EINVAL; 213 212 } 214 213 } ··· 216 217 data_rate = pval; 217 218 if (data_rate > 7) { 218 219 dev_err(&client->dev, 219 - "invalid data_rate on %s\n", 220 - node->full_name); 220 + "invalid data_rate on %pOF\n", node); 221 221 return -EINVAL; 222 222 } 223 223 }
+8 -8
drivers/hwmon/adt7475.c
··· 1319 1319 NULL 1320 1320 }; 1321 1321 1322 - static struct attribute_group adt7475_attr_group = { .attrs = adt7475_attrs }; 1323 - static struct attribute_group fan4_attr_group = { .attrs = fan4_attrs }; 1324 - static struct attribute_group pwm2_attr_group = { .attrs = pwm2_attrs }; 1325 - static struct attribute_group in0_attr_group = { .attrs = in0_attrs }; 1326 - static struct attribute_group in3_attr_group = { .attrs = in3_attrs }; 1327 - static struct attribute_group in4_attr_group = { .attrs = in4_attrs }; 1328 - static struct attribute_group in5_attr_group = { .attrs = in5_attrs }; 1329 - static struct attribute_group vid_attr_group = { .attrs = vid_attrs }; 1322 + static const struct attribute_group adt7475_attr_group = { .attrs = adt7475_attrs }; 1323 + static const struct attribute_group fan4_attr_group = { .attrs = fan4_attrs }; 1324 + static const struct attribute_group pwm2_attr_group = { .attrs = pwm2_attrs }; 1325 + static const struct attribute_group in0_attr_group = { .attrs = in0_attrs }; 1326 + static const struct attribute_group in3_attr_group = { .attrs = in3_attrs }; 1327 + static const struct attribute_group in4_attr_group = { .attrs = in4_attrs }; 1328 + static const struct attribute_group in5_attr_group = { .attrs = in5_attrs }; 1329 + static const struct attribute_group vid_attr_group = { .attrs = vid_attrs }; 1330 1330 1331 1331 static int adt7475_detect(struct i2c_client *client, 1332 1332 struct i2c_board_info *info)
+2 -2
drivers/hwmon/asc7621.c
··· 512 512 { 513 513 SETUP_SHOW_DATA_PARAM(dev, attr); 514 514 u8 config, altbit, regval; 515 - const u8 map[] = { 515 + static const u8 map[] = { 516 516 0x01, 0x02, 0x04, 0x1f, 0x00, 0x06, 0x07, 0x10, 517 517 0x08, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f 518 518 }; ··· 533 533 SETUP_STORE_DATA_PARAM(dev, attr); 534 534 unsigned long reqval; 535 535 u8 currval, config, altbit, newval; 536 - const u16 map[] = { 536 + static const u16 map[] = { 537 537 0x04, 0x00, 0x01, 0xff, 0x02, 0xff, 0x05, 0x06, 538 538 0x08, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 539 539 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+114 -2
drivers/hwmon/aspeed-pwm-tacho.c
··· 20 20 #include <linux/platform_device.h> 21 21 #include <linux/sysfs.h> 22 22 #include <linux/regmap.h> 23 + #include <linux/thermal.h> 23 24 24 25 /* ASPEED PWM & FAN Tach Register Definition */ 25 26 #define ASPEED_PTCR_CTRL 0x00 ··· 167 166 /* How long we sleep in us while waiting for an RPM result. */ 168 167 #define ASPEED_RPM_STATUS_SLEEP_USEC 500 169 168 169 + #define MAX_CDEV_NAME_LEN 16 170 + 171 + struct aspeed_cooling_device { 172 + char name[16]; 173 + struct aspeed_pwm_tacho_data *priv; 174 + struct thermal_cooling_device *tcdev; 175 + int pwm_port; 176 + u8 *cooling_levels; 177 + u8 max_state; 178 + u8 cur_state; 179 + }; 180 + 170 181 struct aspeed_pwm_tacho_data { 171 182 struct regmap *regmap; 172 183 unsigned long clk_freq; ··· 193 180 u8 pwm_port_type[8]; 194 181 u8 pwm_port_fan_ctrl[8]; 195 182 u8 fan_tach_ch_source[16]; 183 + struct aspeed_cooling_device *cdev[8]; 196 184 const struct attribute_group *groups[3]; 197 185 }; 198 186 ··· 779 765 } 780 766 } 781 767 768 + static int 769 + aspeed_pwm_cz_get_max_state(struct thermal_cooling_device *tcdev, 770 + unsigned long *state) 771 + { 772 + struct aspeed_cooling_device *cdev = tcdev->devdata; 773 + 774 + *state = cdev->max_state; 775 + 776 + return 0; 777 + } 778 + 779 + static int 780 + aspeed_pwm_cz_get_cur_state(struct thermal_cooling_device *tcdev, 781 + unsigned long *state) 782 + { 783 + struct aspeed_cooling_device *cdev = tcdev->devdata; 784 + 785 + *state = cdev->cur_state; 786 + 787 + return 0; 788 + } 789 + 790 + static int 791 + aspeed_pwm_cz_set_cur_state(struct thermal_cooling_device *tcdev, 792 + unsigned long state) 793 + { 794 + struct aspeed_cooling_device *cdev = tcdev->devdata; 795 + 796 + if (state > cdev->max_state) 797 + return -EINVAL; 798 + 799 + cdev->cur_state = state; 800 + cdev->priv->pwm_port_fan_ctrl[cdev->pwm_port] = 801 + cdev->cooling_levels[cdev->cur_state]; 802 + aspeed_set_pwm_port_fan_ctrl(cdev->priv, cdev->pwm_port, 803 + cdev->cooling_levels[cdev->cur_state]); 804 + 805 + return 0; 806 + } 807 + 808 + static const struct thermal_cooling_device_ops aspeed_pwm_cool_ops = { 809 + .get_max_state = aspeed_pwm_cz_get_max_state, 810 + .get_cur_state = aspeed_pwm_cz_get_cur_state, 811 + .set_cur_state = aspeed_pwm_cz_set_cur_state, 812 + }; 813 + 814 + static int aspeed_create_pwm_cooling(struct device *dev, 815 + struct device_node *child, 816 + struct aspeed_pwm_tacho_data *priv, 817 + u32 pwm_port, u8 num_levels) 818 + { 819 + int ret; 820 + struct aspeed_cooling_device *cdev; 821 + 822 + cdev = devm_kzalloc(dev, sizeof(*cdev), GFP_KERNEL); 823 + 824 + if (!cdev) 825 + return -ENOMEM; 826 + 827 + cdev->cooling_levels = devm_kzalloc(dev, num_levels, GFP_KERNEL); 828 + if (!cdev->cooling_levels) 829 + return -ENOMEM; 830 + 831 + cdev->max_state = num_levels - 1; 832 + ret = of_property_read_u8_array(child, "cooling-levels", 833 + cdev->cooling_levels, 834 + num_levels); 835 + if (ret) { 836 + dev_err(dev, "Property 'cooling-levels' cannot be read.\n"); 837 + return ret; 838 + } 839 + snprintf(cdev->name, MAX_CDEV_NAME_LEN, "%s%d", child->name, pwm_port); 840 + 841 + cdev->tcdev = thermal_of_cooling_device_register(child, 842 + cdev->name, 843 + cdev, 844 + &aspeed_pwm_cool_ops); 845 + if (IS_ERR(cdev->tcdev)) 846 + return PTR_ERR(cdev->tcdev); 847 + 848 + cdev->priv = priv; 849 + cdev->pwm_port = pwm_port; 850 + 851 + priv->cdev[pwm_port] = cdev; 852 + 853 + return 0; 854 + } 855 + 782 856 static int aspeed_create_fan(struct device *dev, 783 857 struct device_node *child, 784 858 struct aspeed_pwm_tacho_data *priv) ··· 879 777 if (ret) 880 778 return ret; 881 779 aspeed_create_pwm_port(priv, (u8)pwm_port); 780 + 781 + ret = of_property_count_u8_elems(child, "cooling-levels"); 782 + 783 + if (ret > 0) { 784 + ret = aspeed_create_pwm_cooling(dev, child, priv, pwm_port, 785 + ret); 786 + if (ret) 787 + return ret; 788 + } 882 789 883 790 count = of_property_count_u8_elems(child, "aspeed,fan-tach-ch"); 884 791 if (count < 1) ··· 945 834 946 835 for_each_child_of_node(np, child) { 947 836 ret = aspeed_create_fan(dev, child, priv); 948 - of_node_put(child); 949 - if (ret) 837 + if (ret) { 838 + of_node_put(child); 950 839 return ret; 840 + } 951 841 } 952 842 953 843 priv->groups[0] = &pwm_dev_group;
+263 -22
drivers/hwmon/da9052-hwmon.c
··· 20 20 #include <linux/module.h> 21 21 #include <linux/slab.h> 22 22 #include <linux/platform_device.h> 23 + #include <linux/property.h> 23 24 24 25 #include <linux/mfd/da9052/da9052.h> 25 26 #include <linux/mfd/da9052/reg.h> 27 + #include <linux/regulator/consumer.h> 26 28 27 29 struct da9052_hwmon { 28 - struct da9052 *da9052; 29 - struct mutex hwmon_lock; 30 + struct da9052 *da9052; 31 + struct mutex hwmon_lock; 32 + bool tsi_as_adc; 33 + int tsiref_mv; 34 + struct regulator *tsiref; 35 + struct completion tsidone; 30 36 }; 31 37 32 38 static const char * const input_names[] = { ··· 43 37 [DA9052_ADC_IN4] = "ADC IN4", 44 38 [DA9052_ADC_IN5] = "ADC IN5", 45 39 [DA9052_ADC_IN6] = "ADC IN6", 40 + [DA9052_ADC_TSI_XP] = "ADC TS X+", 41 + [DA9052_ADC_TSI_YP] = "ADC TS Y+", 42 + [DA9052_ADC_TSI_XN] = "ADC TS X-", 43 + [DA9052_ADC_TSI_YN] = "ADC TS Y-", 46 44 [DA9052_ADC_TJUNC] = "BATTERY JUNCTION TEMP", 47 45 [DA9052_ADC_VBBAT] = "BACK-UP BATTERY VOLTAGE", 48 46 }; ··· 67 57 static inline int vbbat_reg_to_mv(int value) 68 58 { 69 59 return DIV_ROUND_CLOSEST(value * 5000, 1023); 60 + } 61 + 62 + static inline int input_tsireg_to_mv(struct da9052_hwmon *hwmon, int value) 63 + { 64 + return DIV_ROUND_CLOSEST(value * hwmon->tsiref_mv, 1023); 70 65 } 71 66 72 67 static inline int da9052_enable_vddout_channel(struct da9052 *da9052) ··· 169 154 return sprintf(buf, "%d\n", input_reg_to_mv(ret)); 170 155 } 171 156 157 + static int da9052_request_tsi_read(struct da9052_hwmon *hwmon, int channel) 158 + { 159 + u8 val = DA9052_TSICONTB_TSIMAN; 160 + 161 + switch (channel) { 162 + case DA9052_ADC_TSI_XP: 163 + val |= DA9052_TSICONTB_TSIMUX_XP; 164 + break; 165 + case DA9052_ADC_TSI_YP: 166 + val |= DA9052_TSICONTB_TSIMUX_YP; 167 + break; 168 + case DA9052_ADC_TSI_XN: 169 + val |= DA9052_TSICONTB_TSIMUX_XN; 170 + break; 171 + case DA9052_ADC_TSI_YN: 172 + val |= DA9052_TSICONTB_TSIMUX_YN; 173 + break; 174 + } 175 + 176 + return da9052_reg_write(hwmon->da9052, DA9052_TSI_CONT_B_REG, val); 177 + } 178 + 179 + static int da9052_get_tsi_result(struct da9052_hwmon *hwmon, int channel) 180 + { 181 + u8 regs[3]; 182 + int msb, lsb, err; 183 + 184 + /* block read to avoid separation of MSB and LSB */ 185 + err = da9052_group_read(hwmon->da9052, DA9052_TSI_X_MSB_REG, 186 + ARRAY_SIZE(regs), regs); 187 + if (err) 188 + return err; 189 + 190 + switch (channel) { 191 + case DA9052_ADC_TSI_XP: 192 + case DA9052_ADC_TSI_XN: 193 + msb = regs[0] << DA9052_TSILSB_TSIXL_BITS; 194 + lsb = regs[2] & DA9052_TSILSB_TSIXL; 195 + lsb >>= DA9052_TSILSB_TSIXL_SHIFT; 196 + break; 197 + case DA9052_ADC_TSI_YP: 198 + case DA9052_ADC_TSI_YN: 199 + msb = regs[1] << DA9052_TSILSB_TSIYL_BITS; 200 + lsb = regs[2] & DA9052_TSILSB_TSIYL; 201 + lsb >>= DA9052_TSILSB_TSIYL_SHIFT; 202 + break; 203 + default: 204 + return -EINVAL; 205 + } 206 + 207 + return msb | lsb; 208 + } 209 + 210 + 211 + static ssize_t __da9052_read_tsi(struct device *dev, int channel) 212 + { 213 + struct da9052_hwmon *hwmon = dev_get_drvdata(dev); 214 + int ret; 215 + 216 + reinit_completion(&hwmon->tsidone); 217 + 218 + ret = da9052_request_tsi_read(hwmon, channel); 219 + if (ret < 0) 220 + return ret; 221 + 222 + /* Wait for an conversion done interrupt */ 223 + if (!wait_for_completion_timeout(&hwmon->tsidone, 224 + msecs_to_jiffies(500))) 225 + return -ETIMEDOUT; 226 + 227 + return da9052_get_tsi_result(hwmon, channel); 228 + } 229 + 230 + static ssize_t da9052_read_tsi(struct device *dev, 231 + struct device_attribute *devattr, 232 + char *buf) 233 + { 234 + struct da9052_hwmon *hwmon = dev_get_drvdata(dev); 235 + int channel = to_sensor_dev_attr(devattr)->index; 236 + int ret; 237 + 238 + mutex_lock(&hwmon->hwmon_lock); 239 + ret = __da9052_read_tsi(dev, channel); 240 + mutex_unlock(&hwmon->hwmon_lock); 241 + 242 + if (ret < 0) 243 + return ret; 244 + else 245 + return sprintf(buf, "%d\n", input_tsireg_to_mv(hwmon, ret)); 246 + } 247 + 172 248 static ssize_t da9052_read_tjunc(struct device *dev, 173 249 struct device_attribute *devattr, char *buf) 174 250 { ··· 302 196 input_names[to_sensor_dev_attr(devattr)->index]); 303 197 } 304 198 305 - static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, da9052_read_vddout, NULL, 199 + static umode_t da9052_channel_is_visible(struct kobject *kobj, 200 + struct attribute *attr, int index) 201 + { 202 + struct device *dev = container_of(kobj, struct device, kobj); 203 + struct da9052_hwmon *hwmon = dev_get_drvdata(dev); 204 + struct device_attribute *dattr = container_of(attr, 205 + struct device_attribute, attr); 206 + struct sensor_device_attribute *sattr = to_sensor_dev_attr(dattr); 207 + 208 + if (!hwmon->tsi_as_adc) { 209 + switch (sattr->index) { 210 + case DA9052_ADC_TSI_XP: 211 + case DA9052_ADC_TSI_YP: 212 + case DA9052_ADC_TSI_XN: 213 + case DA9052_ADC_TSI_YN: 214 + return 0; 215 + } 216 + } 217 + 218 + return attr->mode; 219 + } 220 + 221 + static SENSOR_DEVICE_ATTR(in0_input, 0444, da9052_read_vddout, NULL, 306 222 DA9052_ADC_VDDOUT); 307 - static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, show_label, NULL, 223 + static SENSOR_DEVICE_ATTR(in0_label, 0444, show_label, NULL, 308 224 DA9052_ADC_VDDOUT); 309 - static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, da9052_read_vbat, NULL, 225 + static SENSOR_DEVICE_ATTR(in3_input, 0444, da9052_read_vbat, NULL, 310 226 DA9052_ADC_VBAT); 311 - static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_label, NULL, 227 + static SENSOR_DEVICE_ATTR(in3_label, 0444, show_label, NULL, 312 228 DA9052_ADC_VBAT); 313 - static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, da9052_read_misc_channel, NULL, 229 + static SENSOR_DEVICE_ATTR(in4_input, 0444, da9052_read_misc_channel, NULL, 314 230 DA9052_ADC_IN4); 315 - static SENSOR_DEVICE_ATTR(in4_label, S_IRUGO, show_label, NULL, 231 + static SENSOR_DEVICE_ATTR(in4_label, 0444, show_label, NULL, 316 232 DA9052_ADC_IN4); 317 - static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, da9052_read_misc_channel, NULL, 233 + static SENSOR_DEVICE_ATTR(in5_input, 0444, da9052_read_misc_channel, NULL, 318 234 DA9052_ADC_IN5); 319 - static SENSOR_DEVICE_ATTR(in5_label, S_IRUGO, show_label, NULL, 235 + static SENSOR_DEVICE_ATTR(in5_label, 0444, show_label, NULL, 320 236 DA9052_ADC_IN5); 321 - static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, da9052_read_misc_channel, NULL, 237 + static SENSOR_DEVICE_ATTR(in6_input, 0444, da9052_read_misc_channel, NULL, 322 238 DA9052_ADC_IN6); 323 - static SENSOR_DEVICE_ATTR(in6_label, S_IRUGO, show_label, NULL, 239 + static SENSOR_DEVICE_ATTR(in6_label, 0444, show_label, NULL, 324 240 DA9052_ADC_IN6); 325 - static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, da9052_read_vbbat, NULL, 241 + static SENSOR_DEVICE_ATTR(in9_input, 0444, da9052_read_vbbat, NULL, 326 242 DA9052_ADC_VBBAT); 327 - static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, show_label, NULL, 243 + static SENSOR_DEVICE_ATTR(in9_label, 0444, show_label, NULL, 328 244 DA9052_ADC_VBBAT); 329 245 330 - static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, da9052_read_ich, NULL, 246 + static SENSOR_DEVICE_ATTR(in70_input, 0444, da9052_read_tsi, NULL, 247 + DA9052_ADC_TSI_XP); 248 + static SENSOR_DEVICE_ATTR(in70_label, 0444, show_label, NULL, 249 + DA9052_ADC_TSI_XP); 250 + static SENSOR_DEVICE_ATTR(in71_input, 0444, da9052_read_tsi, NULL, 251 + DA9052_ADC_TSI_XN); 252 + static SENSOR_DEVICE_ATTR(in71_label, 0444, show_label, NULL, 253 + DA9052_ADC_TSI_XN); 254 + static SENSOR_DEVICE_ATTR(in72_input, 0444, da9052_read_tsi, NULL, 255 + DA9052_ADC_TSI_YP); 256 + static SENSOR_DEVICE_ATTR(in72_label, 0444, show_label, NULL, 257 + DA9052_ADC_TSI_YP); 258 + static SENSOR_DEVICE_ATTR(in73_input, 0444, da9052_read_tsi, NULL, 259 + DA9052_ADC_TSI_YN); 260 + static SENSOR_DEVICE_ATTR(in73_label, 0444, show_label, NULL, 261 + DA9052_ADC_TSI_YN); 262 + 263 + static SENSOR_DEVICE_ATTR(curr1_input, 0444, da9052_read_ich, NULL, 331 264 DA9052_ADC_ICH); 332 - static SENSOR_DEVICE_ATTR(curr1_label, S_IRUGO, show_label, NULL, 265 + static SENSOR_DEVICE_ATTR(curr1_label, 0444, show_label, NULL, 333 266 DA9052_ADC_ICH); 334 267 335 - static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, da9052_read_tbat, NULL, 268 + static SENSOR_DEVICE_ATTR(temp2_input, 0444, da9052_read_tbat, NULL, 336 269 DA9052_ADC_TBAT); 337 - static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, show_label, NULL, 270 + static SENSOR_DEVICE_ATTR(temp2_label, 0444, show_label, NULL, 338 271 DA9052_ADC_TBAT); 339 - static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, da9052_read_tjunc, NULL, 272 + static SENSOR_DEVICE_ATTR(temp8_input, 0444, da9052_read_tjunc, NULL, 340 273 DA9052_ADC_TJUNC); 341 - static SENSOR_DEVICE_ATTR(temp8_label, S_IRUGO, show_label, NULL, 274 + static SENSOR_DEVICE_ATTR(temp8_label, 0444, show_label, NULL, 342 275 DA9052_ADC_TJUNC); 343 276 344 277 static struct attribute *da9052_attrs[] = { ··· 391 246 &sensor_dev_attr_in5_label.dev_attr.attr, 392 247 &sensor_dev_attr_in6_input.dev_attr.attr, 393 248 &sensor_dev_attr_in6_label.dev_attr.attr, 249 + &sensor_dev_attr_in70_input.dev_attr.attr, 250 + &sensor_dev_attr_in70_label.dev_attr.attr, 251 + &sensor_dev_attr_in71_input.dev_attr.attr, 252 + &sensor_dev_attr_in71_label.dev_attr.attr, 253 + &sensor_dev_attr_in72_input.dev_attr.attr, 254 + &sensor_dev_attr_in72_label.dev_attr.attr, 255 + &sensor_dev_attr_in73_input.dev_attr.attr, 256 + &sensor_dev_attr_in73_label.dev_attr.attr, 394 257 &sensor_dev_attr_in9_input.dev_attr.attr, 395 258 &sensor_dev_attr_in9_label.dev_attr.attr, 396 259 &sensor_dev_attr_curr1_input.dev_attr.attr, ··· 410 257 NULL 411 258 }; 412 259 413 - ATTRIBUTE_GROUPS(da9052); 260 + static const struct attribute_group da9052_group = { 261 + .attrs = da9052_attrs, 262 + .is_visible = da9052_channel_is_visible, 263 + }; 264 + __ATTRIBUTE_GROUPS(da9052); 265 + 266 + static irqreturn_t da9052_tsi_datardy_irq(int irq, void *data) 267 + { 268 + struct da9052_hwmon *hwmon = data; 269 + 270 + complete(&hwmon->tsidone); 271 + return IRQ_HANDLED; 272 + } 414 273 415 274 static int da9052_hwmon_probe(struct platform_device *pdev) 416 275 { 417 276 struct device *dev = &pdev->dev; 418 277 struct da9052_hwmon *hwmon; 419 278 struct device *hwmon_dev; 279 + int err; 420 280 421 281 hwmon = devm_kzalloc(dev, sizeof(struct da9052_hwmon), GFP_KERNEL); 422 282 if (!hwmon) 423 283 return -ENOMEM; 424 284 285 + platform_set_drvdata(pdev, hwmon); 286 + 425 287 mutex_init(&hwmon->hwmon_lock); 426 288 hwmon->da9052 = dev_get_drvdata(pdev->dev.parent); 289 + 290 + init_completion(&hwmon->tsidone); 291 + 292 + hwmon->tsi_as_adc = 293 + device_property_read_bool(pdev->dev.parent, "dlg,tsi-as-adc"); 294 + 295 + if (hwmon->tsi_as_adc) { 296 + hwmon->tsiref = devm_regulator_get(pdev->dev.parent, "tsiref"); 297 + if (IS_ERR(hwmon->tsiref)) { 298 + err = PTR_ERR(hwmon->tsiref); 299 + dev_err(&pdev->dev, "failed to get tsiref: %d", err); 300 + return err; 301 + } 302 + 303 + err = regulator_enable(hwmon->tsiref); 304 + if (err) 305 + return err; 306 + 307 + hwmon->tsiref_mv = regulator_get_voltage(hwmon->tsiref); 308 + if (hwmon->tsiref_mv < 0) { 309 + err = hwmon->tsiref_mv; 310 + goto exit_regulator; 311 + } 312 + 313 + /* convert from microvolt (DT) to millivolt (hwmon) */ 314 + hwmon->tsiref_mv /= 1000; 315 + 316 + /* TSIREF limits from datasheet */ 317 + if (hwmon->tsiref_mv < 1800 || hwmon->tsiref_mv > 2600) { 318 + dev_err(hwmon->da9052->dev, "invalid TSIREF voltage: %d", 319 + hwmon->tsiref_mv); 320 + err = -ENXIO; 321 + goto exit_regulator; 322 + } 323 + 324 + /* disable touchscreen features */ 325 + da9052_reg_write(hwmon->da9052, DA9052_TSI_CONT_A_REG, 0x00); 326 + 327 + err = da9052_request_irq(hwmon->da9052, DA9052_IRQ_TSIREADY, 328 + "tsiready-irq", da9052_tsi_datardy_irq, 329 + hwmon); 330 + if (err) { 331 + dev_err(&pdev->dev, "Failed to register TSIRDY IRQ: %d", 332 + err); 333 + goto exit_regulator; 334 + } 335 + } 427 336 428 337 hwmon_dev = devm_hwmon_device_register_with_groups(dev, "da9052", 429 338 hwmon, 430 339 da9052_groups); 431 - return PTR_ERR_OR_ZERO(hwmon_dev); 340 + err = PTR_ERR_OR_ZERO(hwmon_dev); 341 + if (err) 342 + goto exit_irq; 343 + 344 + return 0; 345 + 346 + exit_irq: 347 + if (hwmon->tsi_as_adc) 348 + da9052_free_irq(hwmon->da9052, DA9052_IRQ_TSIREADY, hwmon); 349 + exit_regulator: 350 + if (hwmon->tsiref) 351 + regulator_disable(hwmon->tsiref); 352 + 353 + return err; 354 + } 355 + 356 + static int da9052_hwmon_remove(struct platform_device *pdev) 357 + { 358 + struct da9052_hwmon *hwmon = platform_get_drvdata(pdev); 359 + 360 + if (hwmon->tsi_as_adc) { 361 + da9052_free_irq(hwmon->da9052, DA9052_IRQ_TSIREADY, hwmon); 362 + regulator_disable(hwmon->tsiref); 363 + } 364 + 365 + return 0; 432 366 } 433 367 434 368 static struct platform_driver da9052_hwmon_driver = { 435 369 .probe = da9052_hwmon_probe, 370 + .remove = da9052_hwmon_remove, 436 371 .driver = { 437 372 .name = "da9052-hwmon", 438 373 },
+3 -1
drivers/hwmon/ftsteutates.c
··· 60 60 61 61 static const unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; 62 62 63 - static struct i2c_device_id fts_id[] = { 63 + static const struct i2c_device_id fts_id[] = { 64 64 { "ftsteutates", 0 }, 65 65 { } 66 66 }; ··· 435 435 goto error; 436 436 437 437 data->valid = false; 438 + ret = count; 438 439 error: 439 440 mutex_unlock(&data->update_lock); 440 441 return ret; ··· 509 508 goto error; 510 509 511 510 data->valid = false; 511 + ret = count; 512 512 error: 513 513 mutex_unlock(&data->update_lock); 514 514 return ret;
+2 -2
drivers/hwmon/hwmon.c
··· 85 85 return attr->mode; 86 86 } 87 87 88 - static struct attribute_group hwmon_dev_attr_group = { 88 + static const struct attribute_group hwmon_dev_attr_group = { 89 89 .attrs = hwmon_dev_attrs, 90 90 .is_visible = hwmon_dev_name_is_visible, 91 91 }; ··· 135 135 return 0; 136 136 } 137 137 138 - static struct thermal_zone_of_device_ops hwmon_thermal_ops = { 138 + static const struct thermal_zone_of_device_ops hwmon_thermal_ops = { 139 139 .get_temp = hwmon_thermal_get_temp, 140 140 }; 141 141
+1 -1
drivers/hwmon/i5k_amb.c
··· 495 495 }; 496 496 497 497 #ifdef MODULE 498 - static struct pci_device_id i5k_amb_ids[] = { 498 + static const struct pci_device_id i5k_amb_ids[] = { 499 499 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5000_ERR) }, 500 500 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5400_ERR) }, 501 501 { 0, }
+162 -52
drivers/hwmon/it87.c
··· 497 497 #define has_vin3_5v(data) ((data)->features & FEAT_VIN3_5V) 498 498 499 499 struct it87_sio_data { 500 + int sioaddr; 500 501 enum chips type; 501 502 /* Values read from Super-I/O config space */ 502 503 u8 revision; 503 504 u8 vid_value; 504 505 u8 beep_pin; 505 506 u8 internal; /* Internal sensors can be labeled */ 507 + bool need_in7_reroute; 506 508 /* Features skipped based on config or DMI */ 507 509 u16 skip_in; 508 510 u8 skip_vid; ··· 519 517 */ 520 518 struct it87_data { 521 519 const struct attribute_group *groups[7]; 520 + int sioaddr; 522 521 enum chips type; 523 522 u32 features; 524 523 u8 peci_mask; ··· 535 532 u16 in_internal; /* Bitfield, internal sensors (for labels) */ 536 533 u16 has_in; /* Bitfield, voltage sensors enabled */ 537 534 u8 in[NUM_VIN][3]; /* [nr][0]=in, [1]=min, [2]=max */ 535 + bool need_in7_reroute; 538 536 u8 has_fan; /* Bitfield, fans enabled */ 539 537 u16 fan[NUM_FAN][2]; /* Register values, [nr][0]=fan, [1]=min */ 540 538 u8 has_temp; /* Bitfield, temp sensors enabled */ ··· 2491 2487 } 2492 2488 2493 2489 err = 0; 2490 + sio_data->sioaddr = sioaddr; 2494 2491 sio_data->revision = superio_inb(sioaddr, DEVREV) & 0x0f; 2495 2492 pr_info("Found IT%04x%s chip at 0x%x, revision %d\n", chip_type, 2496 2493 it87_devices[sio_data->type].suffix, ··· 2580 2575 reg2c |= BIT(1); 2581 2576 superio_outb(sioaddr, IT87_SIO_PINX2_REG, 2582 2577 reg2c); 2578 + sio_data->need_in7_reroute = true; 2583 2579 pr_notice("Routing internal VCCH5V to in7.\n"); 2584 2580 } 2585 2581 pr_notice("in7 routed to internal voltage divider, with external pin disabled.\n"); ··· 2767 2761 uart6 = sio_data->type == it8782 && (reg & BIT(2)); 2768 2762 2769 2763 /* 2770 - * The IT8720F has no VIN7 pin, so VCCH should always be 2764 + * The IT8720F has no VIN7 pin, so VCCH5V should always be 2771 2765 * routed internally to VIN7 with an internal divider. 2772 2766 * Curiously, there still is a configuration bit to control 2773 2767 * this, which means it can be set incorrectly. And even 2774 2768 * more curiously, many boards out there are improperly 2775 2769 * configured, even though the IT8720F datasheet claims 2776 - * that the internal routing of VCCH to VIN7 is the default 2770 + * that the internal routing of VCCH5V to VIN7 is the default 2777 2771 * setting. So we force the internal routing in this case. 2778 2772 * 2779 2773 * On IT8782F, VIN7 is multiplexed with one of the UART6 pins. ··· 2783 2777 if ((sio_data->type == it8720 || uart6) && !(reg & BIT(1))) { 2784 2778 reg |= BIT(1); 2785 2779 superio_outb(sioaddr, IT87_SIO_PINX2_REG, reg); 2786 - pr_notice("Routing internal VCCH to in7\n"); 2780 + sio_data->need_in7_reroute = true; 2781 + pr_notice("Routing internal VCCH5V to in7\n"); 2787 2782 } 2788 2783 if (reg & BIT(0)) 2789 2784 sio_data->internal |= BIT(0); ··· 2835 2828 return err; 2836 2829 } 2837 2830 2831 + /* 2832 + * Some chips seem to have default value 0xff for all limit 2833 + * registers. For low voltage limits it makes no sense and triggers 2834 + * alarms, so change to 0 instead. For high temperature limits, it 2835 + * means -1 degree C, which surprisingly doesn't trigger an alarm, 2836 + * but is still confusing, so change to 127 degrees C. 2837 + */ 2838 + static void it87_check_limit_regs(struct it87_data *data) 2839 + { 2840 + int i, reg; 2841 + 2842 + for (i = 0; i < NUM_VIN_LIMIT; i++) { 2843 + reg = it87_read_value(data, IT87_REG_VIN_MIN(i)); 2844 + if (reg == 0xff) 2845 + it87_write_value(data, IT87_REG_VIN_MIN(i), 0); 2846 + } 2847 + for (i = 0; i < NUM_TEMP_LIMIT; i++) { 2848 + reg = it87_read_value(data, IT87_REG_TEMP_HIGH(i)); 2849 + if (reg == 0xff) 2850 + it87_write_value(data, IT87_REG_TEMP_HIGH(i), 127); 2851 + } 2852 + } 2853 + 2854 + /* Check if voltage monitors are reset manually or by some reason */ 2855 + static void it87_check_voltage_monitors_reset(struct it87_data *data) 2856 + { 2857 + int reg; 2858 + 2859 + reg = it87_read_value(data, IT87_REG_VIN_ENABLE); 2860 + if ((reg & 0xff) == 0) { 2861 + /* Enable all voltage monitors */ 2862 + it87_write_value(data, IT87_REG_VIN_ENABLE, 0xff); 2863 + } 2864 + } 2865 + 2866 + /* Check if tachometers are reset manually or by some reason */ 2867 + static void it87_check_tachometers_reset(struct platform_device *pdev) 2868 + { 2869 + struct it87_sio_data *sio_data = dev_get_platdata(&pdev->dev); 2870 + struct it87_data *data = platform_get_drvdata(pdev); 2871 + u8 mask, fan_main_ctrl; 2872 + 2873 + mask = 0x70 & ~(sio_data->skip_fan << 4); 2874 + fan_main_ctrl = it87_read_value(data, IT87_REG_FAN_MAIN_CTRL); 2875 + if ((fan_main_ctrl & mask) == 0) { 2876 + /* Enable all fan tachometers */ 2877 + fan_main_ctrl |= mask; 2878 + it87_write_value(data, IT87_REG_FAN_MAIN_CTRL, 2879 + fan_main_ctrl); 2880 + } 2881 + } 2882 + 2883 + /* Set tachometers to 16-bit mode if needed */ 2884 + static void it87_check_tachometers_16bit_mode(struct platform_device *pdev) 2885 + { 2886 + struct it87_data *data = platform_get_drvdata(pdev); 2887 + int reg; 2888 + 2889 + if (!has_fan16_config(data)) 2890 + return; 2891 + 2892 + reg = it87_read_value(data, IT87_REG_FAN_16BIT); 2893 + if (~reg & 0x07 & data->has_fan) { 2894 + dev_dbg(&pdev->dev, 2895 + "Setting fan1-3 to 16-bit mode\n"); 2896 + it87_write_value(data, IT87_REG_FAN_16BIT, 2897 + reg | 0x07); 2898 + } 2899 + } 2900 + 2901 + static void it87_start_monitoring(struct it87_data *data) 2902 + { 2903 + it87_write_value(data, IT87_REG_CONFIG, 2904 + (it87_read_value(data, IT87_REG_CONFIG) & 0x3e) 2905 + | (update_vbat ? 0x41 : 0x01)); 2906 + } 2907 + 2838 2908 /* Called when we have found a new IT87. */ 2839 2909 static void it87_init_device(struct platform_device *pdev) 2840 2910 { 2841 2911 struct it87_sio_data *sio_data = dev_get_platdata(&pdev->dev); 2842 2912 struct it87_data *data = platform_get_drvdata(pdev); 2843 2913 int tmp, i; 2844 - u8 mask; 2845 2914 2846 2915 /* 2847 2916 * For each PWM channel: ··· 2938 2855 data->auto_pwm[i][3] = 0x7f; /* Full speed, hard-coded */ 2939 2856 } 2940 2857 2941 - /* 2942 - * Some chips seem to have default value 0xff for all limit 2943 - * registers. For low voltage limits it makes no sense and triggers 2944 - * alarms, so change to 0 instead. For high temperature limits, it 2945 - * means -1 degree C, which surprisingly doesn't trigger an alarm, 2946 - * but is still confusing, so change to 127 degrees C. 2947 - */ 2948 - for (i = 0; i < NUM_VIN_LIMIT; i++) { 2949 - tmp = it87_read_value(data, IT87_REG_VIN_MIN(i)); 2950 - if (tmp == 0xff) 2951 - it87_write_value(data, IT87_REG_VIN_MIN(i), 0); 2952 - } 2953 - for (i = 0; i < NUM_TEMP_LIMIT; i++) { 2954 - tmp = it87_read_value(data, IT87_REG_TEMP_HIGH(i)); 2955 - if (tmp == 0xff) 2956 - it87_write_value(data, IT87_REG_TEMP_HIGH(i), 127); 2957 - } 2858 + it87_check_limit_regs(data); 2958 2859 2959 2860 /* 2960 2861 * Temperature channels are not forcibly enabled, as they can be ··· 2947 2880 * run-time through the temp{1-3}_type sysfs accessors if needed. 2948 2881 */ 2949 2882 2950 - /* Check if voltage monitors are reset manually or by some reason */ 2951 - tmp = it87_read_value(data, IT87_REG_VIN_ENABLE); 2952 - if ((tmp & 0xff) == 0) { 2953 - /* Enable all voltage monitors */ 2954 - it87_write_value(data, IT87_REG_VIN_ENABLE, 0xff); 2955 - } 2883 + it87_check_voltage_monitors_reset(data); 2956 2884 2957 - /* Check if tachometers are reset manually or by some reason */ 2958 - mask = 0x70 & ~(sio_data->skip_fan << 4); 2885 + it87_check_tachometers_reset(pdev); 2886 + 2959 2887 data->fan_main_ctrl = it87_read_value(data, IT87_REG_FAN_MAIN_CTRL); 2960 - if ((data->fan_main_ctrl & mask) == 0) { 2961 - /* Enable all fan tachometers */ 2962 - data->fan_main_ctrl |= mask; 2963 - it87_write_value(data, IT87_REG_FAN_MAIN_CTRL, 2964 - data->fan_main_ctrl); 2965 - } 2966 2888 data->has_fan = (data->fan_main_ctrl >> 4) & 0x07; 2967 2889 2968 - tmp = it87_read_value(data, IT87_REG_FAN_16BIT); 2969 - 2970 - /* Set tachometers to 16-bit mode if needed */ 2971 - if (has_fan16_config(data)) { 2972 - if (~tmp & 0x07 & data->has_fan) { 2973 - dev_dbg(&pdev->dev, 2974 - "Setting fan1-3 to 16-bit mode\n"); 2975 - it87_write_value(data, IT87_REG_FAN_16BIT, 2976 - tmp | 0x07); 2977 - } 2978 - } 2890 + it87_check_tachometers_16bit_mode(pdev); 2979 2891 2980 2892 /* Check for additional fans */ 2981 2893 if (has_five_fans(data)) { 2894 + tmp = it87_read_value(data, IT87_REG_FAN_16BIT); 2895 + 2982 2896 if (tmp & BIT(4)) 2983 2897 data->has_fan |= BIT(3); /* fan4 enabled */ 2984 2898 if (tmp & BIT(5)) ··· 2981 2933 sio_data->skip_pwm |= BIT(5); 2982 2934 } 2983 2935 2984 - /* Start monitoring */ 2985 - it87_write_value(data, IT87_REG_CONFIG, 2986 - (it87_read_value(data, IT87_REG_CONFIG) & 0x3e) 2987 - | (update_vbat ? 0x41 : 0x01)); 2936 + it87_start_monitoring(data); 2988 2937 } 2989 2938 2990 2939 /* Return 1 if and only if the PWM interface is safe to use */ ··· 3031 2986 "PWM configuration is too broken to be fixed\n"); 3032 2987 } 3033 2988 3034 - dev_info(dev, 3035 - "Detected broken BIOS defaults, disabling PWM interface\n"); 3036 2989 return 0; 3037 2990 } else if (fix_pwm_polarity) { 3038 2991 dev_info(dev, ··· 3063 3020 return -ENOMEM; 3064 3021 3065 3022 data->addr = res->start; 3023 + data->sioaddr = sio_data->sioaddr; 3066 3024 data->type = sio_data->type; 3067 3025 data->features = it87_devices[sio_data->type].features; 3068 3026 data->peci_mask = it87_devices[sio_data->type].peci_mask; ··· 3102 3058 3103 3059 /* Check PWM configuration */ 3104 3060 enable_pwm_interface = it87_check_pwm(dev); 3061 + if (!enable_pwm_interface) 3062 + dev_info(dev, 3063 + "Detected broken BIOS defaults, disabling PWM interface\n"); 3105 3064 3106 3065 /* Starting with IT8721F, we handle scaling of internal voltages */ 3107 3066 if (has_12mv_adc(data)) { ··· 3132 3085 } 3133 3086 3134 3087 data->in_internal = sio_data->internal; 3088 + data->need_in7_reroute = sio_data->need_in7_reroute; 3135 3089 data->has_in = 0x3ff & ~sio_data->skip_in; 3136 3090 3137 3091 if (has_six_temp(data)) { ··· 3188 3140 return PTR_ERR_OR_ZERO(hwmon_dev); 3189 3141 } 3190 3142 3143 + static void __maybe_unused it87_resume_sio(struct platform_device *pdev) 3144 + { 3145 + struct it87_data *data = dev_get_drvdata(&pdev->dev); 3146 + int err; 3147 + int reg2c; 3148 + 3149 + if (!data->need_in7_reroute) 3150 + return; 3151 + 3152 + err = superio_enter(data->sioaddr); 3153 + if (err) { 3154 + dev_warn(&pdev->dev, 3155 + "Unable to enter Super I/O to reroute in7 (%d)", 3156 + err); 3157 + return; 3158 + } 3159 + 3160 + superio_select(data->sioaddr, GPIO); 3161 + 3162 + reg2c = superio_inb(data->sioaddr, IT87_SIO_PINX2_REG); 3163 + if (!(reg2c & BIT(1))) { 3164 + dev_dbg(&pdev->dev, 3165 + "Routing internal VCCH5V to in7 again"); 3166 + 3167 + reg2c |= BIT(1); 3168 + superio_outb(data->sioaddr, IT87_SIO_PINX2_REG, 3169 + reg2c); 3170 + } 3171 + 3172 + superio_exit(data->sioaddr); 3173 + } 3174 + 3175 + static int __maybe_unused it87_resume(struct device *dev) 3176 + { 3177 + struct platform_device *pdev = to_platform_device(dev); 3178 + struct it87_data *data = dev_get_drvdata(dev); 3179 + 3180 + it87_resume_sio(pdev); 3181 + 3182 + mutex_lock(&data->update_lock); 3183 + 3184 + it87_check_pwm(dev); 3185 + it87_check_limit_regs(data); 3186 + it87_check_voltage_monitors_reset(data); 3187 + it87_check_tachometers_reset(pdev); 3188 + it87_check_tachometers_16bit_mode(pdev); 3189 + 3190 + it87_start_monitoring(data); 3191 + 3192 + /* force update */ 3193 + data->valid = 0; 3194 + 3195 + mutex_unlock(&data->update_lock); 3196 + 3197 + it87_update_device(dev); 3198 + 3199 + return 0; 3200 + } 3201 + 3202 + static SIMPLE_DEV_PM_OPS(it87_dev_pm_ops, NULL, it87_resume); 3203 + 3191 3204 static struct platform_driver it87_driver = { 3192 3205 .driver = { 3193 3206 .name = DRVNAME, 3207 + .pm = &it87_dev_pm_ops, 3194 3208 }, 3195 3209 .probe = it87_probe, 3196 3210 };
+19
drivers/hwmon/jc42.c
··· 72 72 #define NXP_MANID 0x1131 /* NXP Semiconductors */ 73 73 #define ONS_MANID 0x1b09 /* ON Semiconductor */ 74 74 #define STM_MANID 0x104a /* ST Microelectronics */ 75 + #define GT_MANID 0x1c68 /* Giantec */ 76 + #define GT_MANID2 0x132d /* Giantec, 2nd mfg ID */ 75 77 76 78 /* Supported chips */ 77 79 ··· 87 85 88 86 #define AT30TSE004_DEVID 0x2200 89 87 #define AT30TSE004_DEVID_MASK 0xffff 88 + 89 + /* Giantec */ 90 + #define GT30TS00_DEVID 0x2200 91 + #define GT30TS00_DEVID_MASK 0xff00 92 + 93 + #define GT34TS02_DEVID 0x3300 94 + #define GT34TS02_DEVID_MASK 0xff00 90 95 91 96 /* IDT */ 92 97 #define TSE2004_DEVID 0x2200 ··· 139 130 #define CAT6095_DEVID 0x0800 /* Also matches CAT34TS02 */ 140 131 #define CAT6095_DEVID_MASK 0xffe0 141 132 133 + #define CAT34TS02C_DEVID 0x0a00 134 + #define CAT34TS02C_DEVID_MASK 0xfff0 135 + 136 + #define CAT34TS04_DEVID 0x2200 137 + #define CAT34TS04_DEVID_MASK 0xfff0 138 + 142 139 /* ST Microelectronics */ 143 140 #define STTS424_DEVID 0x0101 144 141 #define STTS424_DEVID_MASK 0xffff ··· 173 158 { ADT_MANID, ADT7408_DEVID, ADT7408_DEVID_MASK }, 174 159 { ATMEL_MANID, AT30TS00_DEVID, AT30TS00_DEVID_MASK }, 175 160 { ATMEL_MANID2, AT30TSE004_DEVID, AT30TSE004_DEVID_MASK }, 161 + { GT_MANID, GT30TS00_DEVID, GT30TS00_DEVID_MASK }, 162 + { GT_MANID2, GT34TS02_DEVID, GT34TS02_DEVID_MASK }, 176 163 { IDT_MANID, TSE2004_DEVID, TSE2004_DEVID_MASK }, 177 164 { IDT_MANID, TS3000_DEVID, TS3000_DEVID_MASK }, 178 165 { IDT_MANID, TS3001_DEVID, TS3001_DEVID_MASK }, ··· 187 170 { MCP_MANID, MCP9843_DEVID, MCP9843_DEVID_MASK }, 188 171 { NXP_MANID, SE97_DEVID, SE97_DEVID_MASK }, 189 172 { ONS_MANID, CAT6095_DEVID, CAT6095_DEVID_MASK }, 173 + { ONS_MANID, CAT34TS02C_DEVID, CAT34TS02C_DEVID_MASK }, 174 + { ONS_MANID, CAT34TS04_DEVID, CAT34TS04_DEVID_MASK }, 190 175 { NXP_MANID, SE98_DEVID, SE98_DEVID_MASK }, 191 176 { STM_MANID, STTS424_DEVID, STTS424_DEVID_MASK }, 192 177 { STM_MANID, STTS424E_DEVID, STTS424E_DEVID_MASK },
+163
drivers/hwmon/ltq-cputemp.c
··· 1 + /* Lantiq cpu temperature sensor driver 2 + * 3 + * Copyright (C) 2017 Florian Eckert <fe@dev.tdt.de> 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License as published by 7 + * the Free Software Foundation; either version 2 of the License, or 8 + * (at your option) any later version 9 + * 10 + * This program is distributed in the hope that it will be useful 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details 14 + * 15 + * You should have received a copy of the GNU General Public License 16 + * along with this program; if not, see <http://www.gnu.org/licenses/> 17 + */ 18 + 19 + #include <linux/bitops.h> 20 + #include <linux/delay.h> 21 + #include <linux/hwmon.h> 22 + #include <linux/hwmon-sysfs.h> 23 + #include <linux/init.h> 24 + #include <linux/module.h> 25 + #include <linux/of_device.h> 26 + 27 + #include <lantiq_soc.h> 28 + 29 + /* gphy1 configuration register contains cpu temperature */ 30 + #define CGU_GPHY1_CR 0x0040 31 + #define CGU_TEMP_PD BIT(19) 32 + 33 + static void ltq_cputemp_enable(void) 34 + { 35 + ltq_cgu_w32(ltq_cgu_r32(CGU_GPHY1_CR) | CGU_TEMP_PD, CGU_GPHY1_CR); 36 + } 37 + 38 + static void ltq_cputemp_disable(void *data) 39 + { 40 + ltq_cgu_w32(ltq_cgu_r32(CGU_GPHY1_CR) & ~CGU_TEMP_PD, CGU_GPHY1_CR); 41 + } 42 + 43 + static int ltq_read(struct device *dev, enum hwmon_sensor_types type, 44 + u32 attr, int channel, long *temp) 45 + { 46 + int value; 47 + 48 + switch (attr) { 49 + case hwmon_temp_input: 50 + /* get the temperature including one decimal place */ 51 + value = (ltq_cgu_r32(CGU_GPHY1_CR) >> 9) & 0x01FF; 52 + value = value * 5; 53 + /* range -38 to +154 °C, register value zero is -38.0 °C */ 54 + value -= 380; 55 + /* scale temp to millidegree */ 56 + value = value * 100; 57 + break; 58 + default: 59 + return -EOPNOTSUPP; 60 + } 61 + 62 + *temp = value; 63 + return 0; 64 + } 65 + 66 + static umode_t ltq_is_visible(const void *_data, enum hwmon_sensor_types type, 67 + u32 attr, int channel) 68 + { 69 + if (type != hwmon_temp) 70 + return 0; 71 + 72 + switch (attr) { 73 + case hwmon_temp_input: 74 + return 0444; 75 + default: 76 + return 0; 77 + } 78 + } 79 + 80 + static const u32 ltq_chip_config[] = { 81 + HWMON_C_REGISTER_TZ, 82 + 0 83 + }; 84 + 85 + static const struct hwmon_channel_info ltq_chip = { 86 + .type = hwmon_chip, 87 + .config = ltq_chip_config, 88 + }; 89 + 90 + static const u32 ltq_temp_config[] = { 91 + HWMON_T_INPUT, 92 + 0 93 + }; 94 + 95 + static const struct hwmon_channel_info ltq_temp = { 96 + .type = hwmon_temp, 97 + .config = ltq_temp_config, 98 + }; 99 + 100 + static const struct hwmon_channel_info *ltq_info[] = { 101 + &ltq_chip, 102 + &ltq_temp, 103 + NULL 104 + }; 105 + 106 + static const struct hwmon_ops ltq_hwmon_ops = { 107 + .is_visible = ltq_is_visible, 108 + .read = ltq_read, 109 + }; 110 + 111 + static const struct hwmon_chip_info ltq_chip_info = { 112 + .ops = &ltq_hwmon_ops, 113 + .info = ltq_info, 114 + }; 115 + 116 + static int ltq_cputemp_probe(struct platform_device *pdev) 117 + { 118 + struct device *hwmon_dev; 119 + int err = 0; 120 + 121 + /* available on vr9 v1.2 SoCs only */ 122 + if (ltq_soc_type() != SOC_TYPE_VR9_2) 123 + return -ENODEV; 124 + 125 + err = devm_add_action(&pdev->dev, ltq_cputemp_disable, NULL); 126 + if (err) 127 + return err; 128 + 129 + ltq_cputemp_enable(); 130 + 131 + hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev, 132 + "ltq_cputemp", 133 + NULL, 134 + &ltq_chip_info, 135 + NULL); 136 + 137 + if (IS_ERR(hwmon_dev)) { 138 + dev_err(&pdev->dev, "Failed to register as hwmon device"); 139 + return PTR_ERR(hwmon_dev); 140 + } 141 + 142 + return 0; 143 + } 144 + 145 + const struct of_device_id ltq_cputemp_match[] = { 146 + { .compatible = "lantiq,cputemp" }, 147 + {}, 148 + }; 149 + MODULE_DEVICE_TABLE(of, ltq_cputemp_match); 150 + 151 + static struct platform_driver ltq_cputemp_driver = { 152 + .probe = ltq_cputemp_probe, 153 + .driver = { 154 + .name = "ltq-cputemp", 155 + .of_match_table = ltq_cputemp_match, 156 + }, 157 + }; 158 + 159 + module_platform_driver(ltq_cputemp_driver); 160 + 161 + MODULE_AUTHOR("Florian Eckert <fe@dev.tdt.de>"); 162 + MODULE_DESCRIPTION("Lantiq cpu temperature sensor driver"); 163 + MODULE_LICENSE("GPL");
+5 -5
drivers/hwmon/nct7802.c
··· 704 704 return attr->mode; 705 705 } 706 706 707 - static struct attribute_group nct7802_temp_group = { 707 + static const struct attribute_group nct7802_temp_group = { 708 708 .attrs = nct7802_temp_attrs, 709 709 .is_visible = nct7802_temp_is_visible, 710 710 }; ··· 802 802 return attr->mode; 803 803 } 804 804 805 - static struct attribute_group nct7802_in_group = { 805 + static const struct attribute_group nct7802_in_group = { 806 806 .attrs = nct7802_in_attrs, 807 807 .is_visible = nct7802_in_is_visible, 808 808 }; ··· 880 880 return attr->mode; 881 881 } 882 882 883 - static struct attribute_group nct7802_fan_group = { 883 + static const struct attribute_group nct7802_fan_group = { 884 884 .attrs = nct7802_fan_attrs, 885 885 .is_visible = nct7802_fan_is_visible, 886 886 }; ··· 898 898 NULL 899 899 }; 900 900 901 - static struct attribute_group nct7802_pwm_group = { 901 + static const struct attribute_group nct7802_pwm_group = { 902 902 .attrs = nct7802_pwm_attrs, 903 903 }; 904 904 ··· 1011 1011 NULL 1012 1012 }; 1013 1013 1014 - static struct attribute_group nct7802_auto_point_group = { 1014 + static const struct attribute_group nct7802_auto_point_group = { 1015 1015 .attrs = nct7802_auto_point_attrs, 1016 1016 }; 1017 1017
+18
drivers/hwmon/pmbus/Kconfig
··· 37 37 This driver can also be built as a module. If so, the module will 38 38 be called adm1275. 39 39 40 + config SENSORS_IBM_CFFPS 41 + tristate "IBM Common Form Factor Power Supply" 42 + help 43 + If you say yes here you get hardware monitoring support for the IBM 44 + Common Form Factor power supply. 45 + 46 + This driver can also be built as a module. If so, the module will 47 + be called ibm-cffps. 48 + 40 49 config SENSORS_IR35221 41 50 tristate "Infineon IR35221" 42 51 default n ··· 143 134 144 135 This driver can also be built as a module. If so, the module will 145 136 be called tps40422. 137 + 138 + config SENSORS_TPS53679 139 + tristate "TI TPS53679" 140 + help 141 + If you say yes here you get hardware monitoring support for TI 142 + TPS53679. 143 + 144 + This driver can also be built as a module. If so, the module will 145 + be called tps53679. 146 146 147 147 config SENSORS_UCD9000 148 148 tristate "TI UCD90120, UCD90124, UCD90160, UCD9090, UCD90910"
+2
drivers/hwmon/pmbus/Makefile
··· 5 5 obj-$(CONFIG_PMBUS) += pmbus_core.o 6 6 obj-$(CONFIG_SENSORS_PMBUS) += pmbus.o 7 7 obj-$(CONFIG_SENSORS_ADM1275) += adm1275.o 8 + obj-$(CONFIG_SENSORS_IBM_CFFPS) += ibm-cffps.o 8 9 obj-$(CONFIG_SENSORS_IR35221) += ir35221.o 9 10 obj-$(CONFIG_SENSORS_LM25066) += lm25066.o 10 11 obj-$(CONFIG_SENSORS_LTC2978) += ltc2978.o ··· 15 14 obj-$(CONFIG_SENSORS_MAX34440) += max34440.o 16 15 obj-$(CONFIG_SENSORS_MAX8688) += max8688.o 17 16 obj-$(CONFIG_SENSORS_TPS40422) += tps40422.o 17 + obj-$(CONFIG_SENSORS_TPS53679) += tps53679.o 18 18 obj-$(CONFIG_SENSORS_UCD9000) += ucd9000.o 19 19 obj-$(CONFIG_SENSORS_UCD9200) += ucd9200.o 20 20 obj-$(CONFIG_SENSORS_ZL6100) += zl6100.o
+151
drivers/hwmon/pmbus/ibm-cffps.c
··· 1 + /* 2 + * Copyright 2017 IBM Corp. 3 + * 4 + * This program is free software; you can redistribute it and/or modify 5 + * it under the terms of the GNU General Public License as published by 6 + * the Free Software Foundation; either version 2 of the License, or 7 + * (at your option) any later version. 8 + */ 9 + 10 + #include <linux/bitops.h> 11 + #include <linux/device.h> 12 + #include <linux/i2c.h> 13 + #include <linux/module.h> 14 + 15 + #include "pmbus.h" 16 + 17 + /* STATUS_MFR_SPECIFIC bits */ 18 + #define CFFPS_MFR_FAN_FAULT BIT(0) 19 + #define CFFPS_MFR_THERMAL_FAULT BIT(1) 20 + #define CFFPS_MFR_OV_FAULT BIT(2) 21 + #define CFFPS_MFR_UV_FAULT BIT(3) 22 + #define CFFPS_MFR_PS_KILL BIT(4) 23 + #define CFFPS_MFR_OC_FAULT BIT(5) 24 + #define CFFPS_MFR_VAUX_FAULT BIT(6) 25 + #define CFFPS_MFR_CURRENT_SHARE_WARNING BIT(7) 26 + 27 + static int ibm_cffps_read_byte_data(struct i2c_client *client, int page, 28 + int reg) 29 + { 30 + int rc, mfr; 31 + 32 + switch (reg) { 33 + case PMBUS_STATUS_VOUT: 34 + case PMBUS_STATUS_IOUT: 35 + case PMBUS_STATUS_TEMPERATURE: 36 + case PMBUS_STATUS_FAN_12: 37 + rc = pmbus_read_byte_data(client, page, reg); 38 + if (rc < 0) 39 + return rc; 40 + 41 + mfr = pmbus_read_byte_data(client, page, 42 + PMBUS_STATUS_MFR_SPECIFIC); 43 + if (mfr < 0) 44 + /* 45 + * Return the status register instead of an error, 46 + * since we successfully read status. 47 + */ 48 + return rc; 49 + 50 + /* Add MFR_SPECIFIC bits to the standard pmbus status regs. */ 51 + if (reg == PMBUS_STATUS_FAN_12) { 52 + if (mfr & CFFPS_MFR_FAN_FAULT) 53 + rc |= PB_FAN_FAN1_FAULT; 54 + } else if (reg == PMBUS_STATUS_TEMPERATURE) { 55 + if (mfr & CFFPS_MFR_THERMAL_FAULT) 56 + rc |= PB_TEMP_OT_FAULT; 57 + } else if (reg == PMBUS_STATUS_VOUT) { 58 + if (mfr & (CFFPS_MFR_OV_FAULT | CFFPS_MFR_VAUX_FAULT)) 59 + rc |= PB_VOLTAGE_OV_FAULT; 60 + if (mfr & CFFPS_MFR_UV_FAULT) 61 + rc |= PB_VOLTAGE_UV_FAULT; 62 + } else if (reg == PMBUS_STATUS_IOUT) { 63 + if (mfr & CFFPS_MFR_OC_FAULT) 64 + rc |= PB_IOUT_OC_FAULT; 65 + if (mfr & CFFPS_MFR_CURRENT_SHARE_WARNING) 66 + rc |= PB_CURRENT_SHARE_FAULT; 67 + } 68 + break; 69 + default: 70 + rc = -ENODATA; 71 + break; 72 + } 73 + 74 + return rc; 75 + } 76 + 77 + static int ibm_cffps_read_word_data(struct i2c_client *client, int page, 78 + int reg) 79 + { 80 + int rc, mfr; 81 + 82 + switch (reg) { 83 + case PMBUS_STATUS_WORD: 84 + rc = pmbus_read_word_data(client, page, reg); 85 + if (rc < 0) 86 + return rc; 87 + 88 + mfr = pmbus_read_byte_data(client, page, 89 + PMBUS_STATUS_MFR_SPECIFIC); 90 + if (mfr < 0) 91 + /* 92 + * Return the status register instead of an error, 93 + * since we successfully read status. 94 + */ 95 + return rc; 96 + 97 + if (mfr & CFFPS_MFR_PS_KILL) 98 + rc |= PB_STATUS_OFF; 99 + break; 100 + default: 101 + rc = -ENODATA; 102 + break; 103 + } 104 + 105 + return rc; 106 + } 107 + 108 + static struct pmbus_driver_info ibm_cffps_info = { 109 + .pages = 1, 110 + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | 111 + PMBUS_HAVE_PIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_TEMP | 112 + PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_VOUT | 113 + PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_INPUT | 114 + PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_STATUS_FAN12, 115 + .read_byte_data = ibm_cffps_read_byte_data, 116 + .read_word_data = ibm_cffps_read_word_data, 117 + }; 118 + 119 + static int ibm_cffps_probe(struct i2c_client *client, 120 + const struct i2c_device_id *id) 121 + { 122 + return pmbus_do_probe(client, id, &ibm_cffps_info); 123 + } 124 + 125 + static const struct i2c_device_id ibm_cffps_id[] = { 126 + { "ibm_cffps1", 1 }, 127 + {} 128 + }; 129 + MODULE_DEVICE_TABLE(i2c, ibm_cffps_id); 130 + 131 + static const struct of_device_id ibm_cffps_of_match[] = { 132 + { .compatible = "ibm,cffps1" }, 133 + {} 134 + }; 135 + MODULE_DEVICE_TABLE(of, ibm_cffps_of_match); 136 + 137 + static struct i2c_driver ibm_cffps_driver = { 138 + .driver = { 139 + .name = "ibm-cffps", 140 + .of_match_table = ibm_cffps_of_match, 141 + }, 142 + .probe = ibm_cffps_probe, 143 + .remove = pmbus_do_remove, 144 + .id_table = ibm_cffps_id, 145 + }; 146 + 147 + module_i2c_driver(ibm_cffps_driver); 148 + 149 + MODULE_AUTHOR("Eddie James"); 150 + MODULE_DESCRIPTION("PMBus driver for IBM Common Form Factor power supplies"); 151 + MODULE_LICENSE("GPL");
+43 -4
drivers/hwmon/pmbus/lm25066.c
··· 28 28 #include <linux/i2c.h> 29 29 #include "pmbus.h" 30 30 31 - enum chips { lm25056, lm25063, lm25066, lm5064, lm5066 }; 31 + enum chips { lm25056, lm25063, lm25066, lm5064, lm5066, lm5066i }; 32 32 33 33 #define LM25066_READ_VAUX 0xd0 34 34 #define LM25066_MFR_READ_IIN 0xd1 ··· 65 65 #define PSC_CURRENT_IN_L (PSC_NUM_CLASSES) 66 66 #define PSC_POWER_L (PSC_NUM_CLASSES + 1) 67 67 68 - static struct __coeff lm25066_coeff[5][PSC_NUM_CLASSES + 2] = { 68 + static struct __coeff lm25066_coeff[6][PSC_NUM_CLASSES + 2] = { 69 69 [lm25056] = { 70 70 [PSC_VOLTAGE_IN] = { 71 71 .m = 16296, ··· 210 210 .m = 16, 211 211 }, 212 212 }, 213 + [lm5066i] = { 214 + [PSC_VOLTAGE_IN] = { 215 + .m = 4617, 216 + .b = -140, 217 + .R = -2, 218 + }, 219 + [PSC_VOLTAGE_OUT] = { 220 + .m = 4602, 221 + .b = 500, 222 + .R = -2, 223 + }, 224 + [PSC_CURRENT_IN] = { 225 + .m = 15076, 226 + .b = -504, 227 + .R = -2, 228 + }, 229 + [PSC_CURRENT_IN_L] = { 230 + .m = 7645, 231 + .b = 100, 232 + .R = -2, 233 + }, 234 + [PSC_POWER] = { 235 + .m = 1701, 236 + .b = -4000, 237 + .R = -3, 238 + }, 239 + [PSC_POWER_L] = { 240 + .m = 861, 241 + .b = -965, 242 + .R = -3, 243 + }, 244 + [PSC_TEMPERATURE] = { 245 + .m = 16, 246 + }, 247 + }, 213 248 }; 214 249 215 250 struct lm25066_data { ··· 285 250 ret = DIV_ROUND_CLOSEST(ret * 70, 453); 286 251 break; 287 252 case lm5066: 253 + case lm5066i: 288 254 /* VIN: 2.18 mV VAUX: 725 uV LSB */ 289 255 ret = DIV_ROUND_CLOSEST(ret * 725, 2180); 290 256 break; ··· 524 488 info->m[PSC_VOLTAGE_OUT] = coeff[PSC_VOLTAGE_OUT].m; 525 489 info->b[PSC_VOLTAGE_OUT] = coeff[PSC_VOLTAGE_OUT].b; 526 490 info->R[PSC_VOLTAGE_OUT] = coeff[PSC_VOLTAGE_OUT].R; 527 - info->b[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN].b; 528 491 info->R[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN].R; 529 - info->b[PSC_POWER] = coeff[PSC_POWER].b; 530 492 info->R[PSC_POWER] = coeff[PSC_POWER].R; 531 493 if (config & LM25066_DEV_SETUP_CL) { 532 494 info->m[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN_L].m; 495 + info->b[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN_L].b; 533 496 info->m[PSC_POWER] = coeff[PSC_POWER_L].m; 497 + info->b[PSC_POWER] = coeff[PSC_POWER_L].b; 534 498 } else { 535 499 info->m[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN].m; 500 + info->b[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN].b; 536 501 info->m[PSC_POWER] = coeff[PSC_POWER].m; 502 + info->b[PSC_POWER] = coeff[PSC_POWER].b; 537 503 } 538 504 539 505 return pmbus_do_probe(client, id, info); ··· 547 509 {"lm25066", lm25066}, 548 510 {"lm5064", lm5064}, 549 511 {"lm5066", lm5066}, 512 + {"lm5066i", lm5066i}, 550 513 { } 551 514 }; 552 515
+1 -1
drivers/hwmon/pmbus/pmbus.h
··· 341 341 #define PMBUS_HAVE_STATUS_VMON BIT(19) 342 342 343 343 enum pmbus_data_format { linear = 0, direct, vid }; 344 - enum vrm_version { vr11 = 0, vr12 }; 344 + enum vrm_version { vr11 = 0, vr12, vr13 }; 345 345 346 346 struct pmbus_driver_info { 347 347 int pages; /* Total number of pages */
+270 -22
drivers/hwmon/pmbus/pmbus_core.c
··· 19 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 20 */ 21 21 22 + #include <linux/debugfs.h> 22 23 #include <linux/kernel.h> 23 24 #include <linux/module.h> 24 25 #include <linux/init.h> ··· 102 101 int num_attributes; 103 102 struct attribute_group group; 104 103 const struct attribute_group *groups[2]; 104 + struct dentry *debugfs; /* debugfs device directory */ 105 105 106 106 struct pmbus_sensor *sensors; 107 107 ··· 114 112 * A single status register covers multiple attributes, 115 113 * so we keep them all together. 116 114 */ 117 - u8 status[PB_NUM_STATUS_REG]; 118 - u8 status_register; 115 + u16 status[PB_NUM_STATUS_REG]; 116 + 117 + bool has_status_word; /* device uses STATUS_WORD register */ 118 + int (*read_status)(struct i2c_client *client, int page); 119 119 120 120 u8 currpage; 121 + }; 122 + 123 + struct pmbus_debugfs_entry { 124 + struct i2c_client *client; 125 + u8 page; 126 + u8 reg; 121 127 }; 122 128 123 129 void pmbus_clear_cache(struct i2c_client *client) ··· 334 324 struct pmbus_data *data = i2c_get_clientdata(client); 335 325 int status, status2; 336 326 337 - status = _pmbus_read_byte_data(client, -1, data->status_register); 327 + status = data->read_status(client, -1); 338 328 if (status < 0 || (status & PB_STATUS_CML)) { 339 329 status2 = _pmbus_read_byte_data(client, -1, PMBUS_STATUS_CML); 340 330 if (status2 < 0 || (status2 & PB_CML_FAULT_INVALID_COMMAND)) ··· 356 346 rv = pmbus_check_status_cml(client); 357 347 pmbus_clear_fault_page(client, -1); 358 348 return rv >= 0; 349 + } 350 + 351 + static bool pmbus_check_status_register(struct i2c_client *client, int page) 352 + { 353 + int status; 354 + struct pmbus_data *data = i2c_get_clientdata(client); 355 + 356 + status = data->read_status(client, page); 357 + if (status >= 0 && !(data->flags & PMBUS_SKIP_STATUS_CHECK) && 358 + (status & PB_STATUS_CML)) { 359 + status = _pmbus_read_byte_data(client, -1, PMBUS_STATUS_CML); 360 + if (status < 0 || (status & PB_CML_FAULT_INVALID_COMMAND)) 361 + status = -EIO; 362 + } 363 + 364 + pmbus_clear_fault_page(client, -1); 365 + return status >= 0; 359 366 } 360 367 361 368 bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg) ··· 421 394 422 395 for (i = 0; i < info->pages; i++) { 423 396 data->status[PB_STATUS_BASE + i] 424 - = _pmbus_read_byte_data(client, i, 425 - data->status_register); 397 + = data->read_status(client, i); 426 398 for (j = 0; j < ARRAY_SIZE(pmbus_status); j++) { 427 399 struct _pmbus_status *s = &pmbus_status[j]; 428 400 ··· 556 530 case vr12: 557 531 if (val >= 0x01) 558 532 rv = 250 + (val - 1) * 5; 533 + break; 534 + case vr13: 535 + if (val >= 0x01) 536 + rv = 500 + (val - 1) * 10; 559 537 break; 560 538 } 561 539 return rv; ··· 746 716 { 747 717 struct pmbus_sensor *s1 = b->s1; 748 718 struct pmbus_sensor *s2 = b->s2; 749 - u16 reg = (index >> 8) & 0xffff; 750 - u8 mask = index & 0xff; 719 + u16 reg = (index >> 16) & 0xffff; 720 + u16 mask = index & 0xffff; 751 721 int ret, status; 752 - u8 regval; 722 + u16 regval; 753 723 754 724 status = data->status[reg]; 755 725 if (status < 0) ··· 890 860 const char *name, const char *type, int seq, 891 861 struct pmbus_sensor *s1, 892 862 struct pmbus_sensor *s2, 893 - u16 reg, u8 mask) 863 + u16 reg, u16 mask) 894 864 { 895 865 struct pmbus_boolean *boolean; 896 866 struct sensor_device_attribute *a; ··· 906 876 boolean->s1 = s1; 907 877 boolean->s2 = s2; 908 878 pmbus_attr_init(a, boolean->name, S_IRUGO, pmbus_show_boolean, NULL, 909 - (reg << 8) | mask); 879 + (reg << 16) | mask); 910 880 911 881 return pmbus_add_attribute(data, &a->dev_attr.attr); 912 882 } ··· 992 962 */ 993 963 struct pmbus_sensor_attr { 994 964 u16 reg; /* sensor register */ 995 - u8 gbit; /* generic status bit */ 965 + u16 gbit; /* generic status bit */ 996 966 u8 nlimit; /* # of limit registers */ 997 967 enum pmbus_sensor_classes class;/* sensor class */ 998 968 const char *label; /* sensor label */ ··· 1058 1028 const struct pmbus_sensor_attr *attr) 1059 1029 { 1060 1030 struct pmbus_sensor *base; 1031 + bool upper = !!(attr->gbit & 0xff00); /* need to check STATUS_WORD */ 1061 1032 int ret; 1062 1033 1063 1034 if (attr->label) { ··· 1079 1048 /* 1080 1049 * Add generic alarm attribute only if there are no individual 1081 1050 * alarm attributes, if there is a global alarm bit, and if 1082 - * the generic status register for this page is accessible. 1051 + * the generic status register (word or byte, depending on 1052 + * which global bit is set) for this page is accessible. 1083 1053 */ 1084 1054 if (!ret && attr->gbit && 1085 - pmbus_check_byte_register(client, page, 1086 - data->status_register)) { 1055 + (!upper || (upper && data->has_status_word)) && 1056 + pmbus_check_status_register(client, page)) { 1087 1057 ret = pmbus_add_boolean(data, name, "alarm", index, 1088 1058 NULL, NULL, 1089 1059 PB_STATUS_BASE + page, ··· 1340 1308 .func = PMBUS_HAVE_IIN, 1341 1309 .sfunc = PMBUS_HAVE_STATUS_INPUT, 1342 1310 .sbase = PB_STATUS_INPUT_BASE, 1311 + .gbit = PB_STATUS_INPUT, 1343 1312 .limit = iin_limit_attrs, 1344 1313 .nlimit = ARRAY_SIZE(iin_limit_attrs), 1345 1314 }, { ··· 1425 1392 .func = PMBUS_HAVE_PIN, 1426 1393 .sfunc = PMBUS_HAVE_STATUS_INPUT, 1427 1394 .sbase = PB_STATUS_INPUT_BASE, 1395 + .gbit = PB_STATUS_INPUT, 1428 1396 .limit = pin_limit_attrs, 1429 1397 .nlimit = ARRAY_SIZE(pin_limit_attrs), 1430 1398 }, { ··· 1763 1729 return 0; 1764 1730 } 1765 1731 1732 + static int pmbus_read_status_byte(struct i2c_client *client, int page) 1733 + { 1734 + return _pmbus_read_byte_data(client, page, PMBUS_STATUS_BYTE); 1735 + } 1736 + 1737 + static int pmbus_read_status_word(struct i2c_client *client, int page) 1738 + { 1739 + return _pmbus_read_word_data(client, page, PMBUS_STATUS_WORD); 1740 + } 1741 + 1766 1742 static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data, 1767 1743 struct pmbus_driver_info *info) 1768 1744 { ··· 1780 1736 int page, ret; 1781 1737 1782 1738 /* 1783 - * Some PMBus chips don't support PMBUS_STATUS_BYTE, so try 1784 - * to use PMBUS_STATUS_WORD instead if that is the case. 1739 + * Some PMBus chips don't support PMBUS_STATUS_WORD, so try 1740 + * to use PMBUS_STATUS_BYTE instead if that is the case. 1785 1741 * Bail out if both registers are not supported. 1786 1742 */ 1787 - data->status_register = PMBUS_STATUS_BYTE; 1788 - ret = i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE); 1789 - if (ret < 0 || ret == 0xff) { 1790 - data->status_register = PMBUS_STATUS_WORD; 1791 - ret = i2c_smbus_read_word_data(client, PMBUS_STATUS_WORD); 1792 - if (ret < 0 || ret == 0xffff) { 1743 + data->read_status = pmbus_read_status_word; 1744 + ret = i2c_smbus_read_word_data(client, PMBUS_STATUS_WORD); 1745 + if (ret < 0 || ret == 0xffff) { 1746 + data->read_status = pmbus_read_status_byte; 1747 + ret = i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE); 1748 + if (ret < 0 || ret == 0xff) { 1793 1749 dev_err(dev, "PMBus status register not found\n"); 1794 1750 return -ENODEV; 1795 1751 } 1752 + } else { 1753 + data->has_status_word = true; 1796 1754 } 1797 1755 1798 1756 /* Enable PEC if the controller supports it */ ··· 1905 1859 } 1906 1860 #endif 1907 1861 1862 + static struct dentry *pmbus_debugfs_dir; /* pmbus debugfs directory */ 1863 + 1864 + #if IS_ENABLED(CONFIG_DEBUG_FS) 1865 + static int pmbus_debugfs_get(void *data, u64 *val) 1866 + { 1867 + int rc; 1868 + struct pmbus_debugfs_entry *entry = data; 1869 + 1870 + rc = _pmbus_read_byte_data(entry->client, entry->page, entry->reg); 1871 + if (rc < 0) 1872 + return rc; 1873 + 1874 + *val = rc; 1875 + 1876 + return 0; 1877 + } 1878 + DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops, pmbus_debugfs_get, NULL, 1879 + "0x%02llx\n"); 1880 + 1881 + static int pmbus_debugfs_get_status(void *data, u64 *val) 1882 + { 1883 + int rc; 1884 + struct pmbus_debugfs_entry *entry = data; 1885 + struct pmbus_data *pdata = i2c_get_clientdata(entry->client); 1886 + 1887 + rc = pdata->read_status(entry->client, entry->page); 1888 + if (rc < 0) 1889 + return rc; 1890 + 1891 + *val = rc; 1892 + 1893 + return 0; 1894 + } 1895 + DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_status, pmbus_debugfs_get_status, 1896 + NULL, "0x%04llx\n"); 1897 + 1898 + static int pmbus_init_debugfs(struct i2c_client *client, 1899 + struct pmbus_data *data) 1900 + { 1901 + int i, idx = 0; 1902 + char name[PMBUS_NAME_SIZE]; 1903 + struct pmbus_debugfs_entry *entries; 1904 + 1905 + if (!pmbus_debugfs_dir) 1906 + return -ENODEV; 1907 + 1908 + /* 1909 + * Create the debugfs directory for this device. Use the hwmon device 1910 + * name to avoid conflicts (hwmon numbers are globally unique). 1911 + */ 1912 + data->debugfs = debugfs_create_dir(dev_name(data->hwmon_dev), 1913 + pmbus_debugfs_dir); 1914 + if (IS_ERR_OR_NULL(data->debugfs)) { 1915 + data->debugfs = NULL; 1916 + return -ENODEV; 1917 + } 1918 + 1919 + /* Allocate the max possible entries we need. */ 1920 + entries = devm_kzalloc(data->dev, 1921 + sizeof(*entries) * (data->info->pages * 10), 1922 + GFP_KERNEL); 1923 + if (!entries) 1924 + return -ENOMEM; 1925 + 1926 + for (i = 0; i < data->info->pages; ++i) { 1927 + /* Check accessibility of status register if it's not page 0 */ 1928 + if (!i || pmbus_check_status_register(client, i)) { 1929 + /* No need to set reg as we have special read op. */ 1930 + entries[idx].client = client; 1931 + entries[idx].page = i; 1932 + scnprintf(name, PMBUS_NAME_SIZE, "status%d", i); 1933 + debugfs_create_file(name, 0444, data->debugfs, 1934 + &entries[idx++], 1935 + &pmbus_debugfs_ops_status); 1936 + } 1937 + 1938 + if (data->info->func[i] & PMBUS_HAVE_STATUS_VOUT) { 1939 + entries[idx].client = client; 1940 + entries[idx].page = i; 1941 + entries[idx].reg = PMBUS_STATUS_VOUT; 1942 + scnprintf(name, PMBUS_NAME_SIZE, "status%d_vout", i); 1943 + debugfs_create_file(name, 0444, data->debugfs, 1944 + &entries[idx++], 1945 + &pmbus_debugfs_ops); 1946 + } 1947 + 1948 + if (data->info->func[i] & PMBUS_HAVE_STATUS_IOUT) { 1949 + entries[idx].client = client; 1950 + entries[idx].page = i; 1951 + entries[idx].reg = PMBUS_STATUS_IOUT; 1952 + scnprintf(name, PMBUS_NAME_SIZE, "status%d_iout", i); 1953 + debugfs_create_file(name, 0444, data->debugfs, 1954 + &entries[idx++], 1955 + &pmbus_debugfs_ops); 1956 + } 1957 + 1958 + if (data->info->func[i] & PMBUS_HAVE_STATUS_INPUT) { 1959 + entries[idx].client = client; 1960 + entries[idx].page = i; 1961 + entries[idx].reg = PMBUS_STATUS_INPUT; 1962 + scnprintf(name, PMBUS_NAME_SIZE, "status%d_input", i); 1963 + debugfs_create_file(name, 0444, data->debugfs, 1964 + &entries[idx++], 1965 + &pmbus_debugfs_ops); 1966 + } 1967 + 1968 + if (data->info->func[i] & PMBUS_HAVE_STATUS_TEMP) { 1969 + entries[idx].client = client; 1970 + entries[idx].page = i; 1971 + entries[idx].reg = PMBUS_STATUS_TEMPERATURE; 1972 + scnprintf(name, PMBUS_NAME_SIZE, "status%d_temp", i); 1973 + debugfs_create_file(name, 0444, data->debugfs, 1974 + &entries[idx++], 1975 + &pmbus_debugfs_ops); 1976 + } 1977 + 1978 + if (pmbus_check_byte_register(client, i, PMBUS_STATUS_CML)) { 1979 + entries[idx].client = client; 1980 + entries[idx].page = i; 1981 + entries[idx].reg = PMBUS_STATUS_CML; 1982 + scnprintf(name, PMBUS_NAME_SIZE, "status%d_cml", i); 1983 + debugfs_create_file(name, 0444, data->debugfs, 1984 + &entries[idx++], 1985 + &pmbus_debugfs_ops); 1986 + } 1987 + 1988 + if (pmbus_check_byte_register(client, i, PMBUS_STATUS_OTHER)) { 1989 + entries[idx].client = client; 1990 + entries[idx].page = i; 1991 + entries[idx].reg = PMBUS_STATUS_OTHER; 1992 + scnprintf(name, PMBUS_NAME_SIZE, "status%d_other", i); 1993 + debugfs_create_file(name, 0444, data->debugfs, 1994 + &entries[idx++], 1995 + &pmbus_debugfs_ops); 1996 + } 1997 + 1998 + if (pmbus_check_byte_register(client, i, 1999 + PMBUS_STATUS_MFR_SPECIFIC)) { 2000 + entries[idx].client = client; 2001 + entries[idx].page = i; 2002 + entries[idx].reg = PMBUS_STATUS_MFR_SPECIFIC; 2003 + scnprintf(name, PMBUS_NAME_SIZE, "status%d_mfr", i); 2004 + debugfs_create_file(name, 0444, data->debugfs, 2005 + &entries[idx++], 2006 + &pmbus_debugfs_ops); 2007 + } 2008 + 2009 + if (data->info->func[i] & PMBUS_HAVE_STATUS_FAN12) { 2010 + entries[idx].client = client; 2011 + entries[idx].page = i; 2012 + entries[idx].reg = PMBUS_STATUS_FAN_12; 2013 + scnprintf(name, PMBUS_NAME_SIZE, "status%d_fan12", i); 2014 + debugfs_create_file(name, 0444, data->debugfs, 2015 + &entries[idx++], 2016 + &pmbus_debugfs_ops); 2017 + } 2018 + 2019 + if (data->info->func[i] & PMBUS_HAVE_STATUS_FAN34) { 2020 + entries[idx].client = client; 2021 + entries[idx].page = i; 2022 + entries[idx].reg = PMBUS_STATUS_FAN_34; 2023 + scnprintf(name, PMBUS_NAME_SIZE, "status%d_fan34", i); 2024 + debugfs_create_file(name, 0444, data->debugfs, 2025 + &entries[idx++], 2026 + &pmbus_debugfs_ops); 2027 + } 2028 + } 2029 + 2030 + return 0; 2031 + } 2032 + #else 2033 + static int pmbus_init_debugfs(struct i2c_client *client, 2034 + struct pmbus_data *data) 2035 + { 2036 + return 0; 2037 + } 2038 + #endif /* IS_ENABLED(CONFIG_DEBUG_FS) */ 2039 + 1908 2040 int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, 1909 2041 struct pmbus_driver_info *info) 1910 2042 { ··· 2142 1918 if (ret) 2143 1919 goto out_unregister; 2144 1920 1921 + ret = pmbus_init_debugfs(client, data); 1922 + if (ret) 1923 + dev_warn(dev, "Failed to register debugfs\n"); 1924 + 2145 1925 return 0; 2146 1926 2147 1927 out_unregister: ··· 2159 1931 int pmbus_do_remove(struct i2c_client *client) 2160 1932 { 2161 1933 struct pmbus_data *data = i2c_get_clientdata(client); 1934 + 1935 + debugfs_remove_recursive(data->debugfs); 1936 + 2162 1937 hwmon_device_unregister(data->hwmon_dev); 2163 1938 kfree(data->group.attrs); 2164 1939 return 0; 2165 1940 } 2166 1941 EXPORT_SYMBOL_GPL(pmbus_do_remove); 1942 + 1943 + static int __init pmbus_core_init(void) 1944 + { 1945 + pmbus_debugfs_dir = debugfs_create_dir("pmbus", NULL); 1946 + if (IS_ERR(pmbus_debugfs_dir)) 1947 + pmbus_debugfs_dir = NULL; 1948 + 1949 + return 0; 1950 + } 1951 + 1952 + static void __exit pmbus_core_exit(void) 1953 + { 1954 + debugfs_remove_recursive(pmbus_debugfs_dir); 1955 + } 1956 + 1957 + module_init(pmbus_core_init); 1958 + module_exit(pmbus_core_exit); 2167 1959 2168 1960 MODULE_AUTHOR("Guenter Roeck"); 2169 1961 MODULE_DESCRIPTION("PMBus core driver");
+113
drivers/hwmon/pmbus/tps53679.c
··· 1 + /* 2 + * Hardware monitoring driver for Texas Instruments TPS53679 3 + * 4 + * Copyright (c) 2017 Mellanox Technologies. All rights reserved. 5 + * Copyright (c) 2017 Vadim Pasternak <vadimp@mellanox.com> 6 + * 7 + * This program is free software; you can redistribute it and/or modify 8 + * it under the terms of the GNU General Public License as published by 9 + * the Free Software Foundation; either version 2 of the License, or 10 + * (at your option) any later version. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + */ 17 + 18 + #include <linux/err.h> 19 + #include <linux/i2c.h> 20 + #include <linux/init.h> 21 + #include <linux/kernel.h> 22 + #include <linux/module.h> 23 + #include "pmbus.h" 24 + 25 + #define TPS53679_PROT_VR12_5MV 0x01 /* VR12.0 mode, 5-mV DAC */ 26 + #define TPS53679_PROT_VR12_5_10MV 0x02 /* VR12.5 mode, 10-mV DAC */ 27 + #define TPS53679_PROT_VR13_10MV 0x04 /* VR13.0 mode, 10-mV DAC */ 28 + #define TPS53679_PROT_IMVP8_5MV 0x05 /* IMVP8 mode, 5-mV DAC */ 29 + #define TPS53679_PROT_VR13_5MV 0x07 /* VR13.0 mode, 5-mV DAC */ 30 + #define TPS53679_PAGE_NUM 2 31 + 32 + static int tps53679_identify(struct i2c_client *client, 33 + struct pmbus_driver_info *info) 34 + { 35 + u8 vout_params; 36 + int ret; 37 + 38 + /* Read the register with VOUT scaling value.*/ 39 + ret = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE); 40 + if (ret < 0) 41 + return ret; 42 + 43 + vout_params = ret & GENMASK(4, 0); 44 + 45 + switch (vout_params) { 46 + case TPS53679_PROT_VR13_10MV: 47 + case TPS53679_PROT_VR12_5_10MV: 48 + info->vrm_version = vr13; 49 + break; 50 + case TPS53679_PROT_VR13_5MV: 51 + case TPS53679_PROT_VR12_5MV: 52 + case TPS53679_PROT_IMVP8_5MV: 53 + info->vrm_version = vr12; 54 + break; 55 + default: 56 + return -EINVAL; 57 + } 58 + 59 + return 0; 60 + } 61 + 62 + static struct pmbus_driver_info tps53679_info = { 63 + .pages = TPS53679_PAGE_NUM, 64 + .format[PSC_VOLTAGE_IN] = linear, 65 + .format[PSC_VOLTAGE_OUT] = vid, 66 + .format[PSC_TEMPERATURE] = linear, 67 + .format[PSC_CURRENT_OUT] = linear, 68 + .format[PSC_POWER] = linear, 69 + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | 70 + PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | 71 + PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | 72 + PMBUS_HAVE_POUT, 73 + .func[1] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | 74 + PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | 75 + PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | 76 + PMBUS_HAVE_POUT, 77 + .identify = tps53679_identify, 78 + }; 79 + 80 + static int tps53679_probe(struct i2c_client *client, 81 + const struct i2c_device_id *id) 82 + { 83 + return pmbus_do_probe(client, id, &tps53679_info); 84 + } 85 + 86 + static const struct i2c_device_id tps53679_id[] = { 87 + {"tps53679", 0}, 88 + {} 89 + }; 90 + 91 + MODULE_DEVICE_TABLE(i2c, tps53679_id); 92 + 93 + static const struct of_device_id tps53679_of_match[] = { 94 + {.compatible = "ti,tps53679"}, 95 + {} 96 + }; 97 + MODULE_DEVICE_TABLE(of, tps53679_of_match); 98 + 99 + static struct i2c_driver tps53679_driver = { 100 + .driver = { 101 + .name = "tps53679", 102 + .of_match_table = of_match_ptr(tps53679_of_match), 103 + }, 104 + .probe = tps53679_probe, 105 + .remove = pmbus_do_remove, 106 + .id_table = tps53679_id, 107 + }; 108 + 109 + module_i2c_driver(tps53679_driver); 110 + 111 + MODULE_AUTHOR("Vadim Pasternak <vadimp@mellanox.com>"); 112 + MODULE_DESCRIPTION("PMBus driver for Texas Instruments TPS53679"); 113 + MODULE_LICENSE("GPL");
+1 -1
drivers/hwmon/scpi-hwmon.c
··· 120 120 return sprintf(buf, "%s\n", sensor->info.name); 121 121 } 122 122 123 - static struct thermal_zone_of_device_ops scpi_sensor_ops = { 123 + static const struct thermal_zone_of_device_ops scpi_sensor_ops = { 124 124 .get_temp = scpi_read_temp, 125 125 }; 126 126
+4
drivers/hwmon/stts751.c
··· 718 718 ret = i2c_smbus_read_byte_data(priv->client, STTS751_REG_RATE); 719 719 if (ret < 0) 720 720 return ret; 721 + if (ret >= ARRAY_SIZE(stts751_intervals)) { 722 + dev_err(priv->dev, "Unrecognized conversion rate 0x%x\n", ret); 723 + return -ENODEV; 724 + } 721 725 priv->interval = ret; 722 726 723 727 ret = stts751_read_reg16(priv, &priv->event_max,
+23 -3
drivers/mfd/da9052-core.c
··· 18 18 #include <linux/mfd/core.h> 19 19 #include <linux/slab.h> 20 20 #include <linux/module.h> 21 + #include <linux/property.h> 21 22 22 23 #include <linux/mfd/da9052/da9052.h> 23 24 #include <linux/mfd/da9052/pdata.h> ··· 520 519 .name = "da9052-wled3", 521 520 }, 522 521 { 523 - .name = "da9052-tsi", 524 - }, 525 - { 526 522 .name = "da9052-bat", 527 523 }, 528 524 { 529 525 .name = "da9052-watchdog", 530 526 }, 527 + }; 528 + 529 + static const struct mfd_cell da9052_tsi_subdev_info[] = { 530 + { .name = "da9052-tsi" }, 531 531 }; 532 532 533 533 const struct regmap_config da9052_regmap_config = { ··· 621 619 goto err; 622 620 } 623 621 622 + /* 623 + * Check if touchscreen pins are used are analogue input instead 624 + * of having a touchscreen connected to them. The analogue input 625 + * functionality will be provided by hwmon driver (if enabled). 626 + */ 627 + if (!device_property_read_bool(da9052->dev, "dlg,tsi-as-adc")) { 628 + ret = mfd_add_devices(da9052->dev, PLATFORM_DEVID_AUTO, 629 + da9052_tsi_subdev_info, 630 + ARRAY_SIZE(da9052_tsi_subdev_info), 631 + NULL, 0, NULL); 632 + if (ret) { 633 + dev_err(da9052->dev, "failed to add TSI subdev: %d\n", 634 + ret); 635 + goto err; 636 + } 637 + } 638 + 624 639 return 0; 625 640 626 641 err: 642 + mfd_remove_devices(da9052->dev); 627 643 da9052_irq_exit(da9052); 628 644 629 645 return ret;
+6
include/linux/mfd/da9052/da9052.h
··· 45 45 #define DA9052_ADC_TJUNC 8 46 46 #define DA9052_ADC_VBBAT 9 47 47 48 + /* TSI channel has its own 4 channel mux */ 49 + #define DA9052_ADC_TSI_XP 70 50 + #define DA9052_ADC_TSI_XN 71 51 + #define DA9052_ADC_TSI_YP 72 52 + #define DA9052_ADC_TSI_YN 73 53 + 48 54 #define DA9052_IRQ_DCIN 0 49 55 #define DA9052_IRQ_VBUS 1 50 56 #define DA9052_IRQ_DCINREM 2
+10 -1
include/linux/mfd/da9052/reg.h
··· 690 690 /* TSI CONTROL REGISTER B BITS */ 691 691 #define DA9052_TSICONTB_ADCREF 0X80 692 692 #define DA9052_TSICONTB_TSIMAN 0X40 693 - #define DA9052_TSICONTB_TSIMUX 0X30 693 + #define DA9052_TSICONTB_TSIMUX_XP 0X00 694 + #define DA9052_TSICONTB_TSIMUX_YP 0X10 695 + #define DA9052_TSICONTB_TSIMUX_XN 0X20 696 + #define DA9052_TSICONTB_TSIMUX_YN 0X30 694 697 #define DA9052_TSICONTB_TSISEL3 0X08 695 698 #define DA9052_TSICONTB_TSISEL2 0X04 696 699 #define DA9052_TSICONTB_TSISEL1 0X02 ··· 708 705 /* TSI CO-ORDINATE LSB RESULT REGISTER BITS */ 709 706 #define DA9052_TSILSB_PENDOWN 0X40 710 707 #define DA9052_TSILSB_TSIZL 0X30 708 + #define DA9052_TSILSB_TSIZL_SHIFT 4 709 + #define DA9052_TSILSB_TSIZL_BITS 2 711 710 #define DA9052_TSILSB_TSIYL 0X0C 711 + #define DA9052_TSILSB_TSIYL_SHIFT 2 712 + #define DA9052_TSILSB_TSIYL_BITS 2 712 713 #define DA9052_TSILSB_TSIXL 0X03 714 + #define DA9052_TSILSB_TSIXL_SHIFT 0 715 + #define DA9052_TSILSB_TSIXL_BITS 2 713 716 714 717 /* TSI Z MEASUREMENT MSB RESULT REGISTER BIT */ 715 718 #define DA9052_TSIZMSB_TSIZM 0XFF