Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/i2c-2.6

+8321 -1261
+10
Documentation/feature-removal-schedule.txt
··· 83 83 more efficient. You should really be using libraw1394 for raw1394 84 84 access anyway. 85 85 Who: Jody McIntyre <scjody@steamballoon.com> 86 + 87 + --------------------------- 88 + 89 + What: i2c sysfs name change: in1_ref, vid deprecated in favour of cpu0_vid 90 + When: November 2005 91 + Files: drivers/i2c/chips/adm1025.c, drivers/i2c/chips/adm1026.c 92 + Why: Match the other drivers' name for the same function, duplicate names 93 + will be available until removal of old names. 94 + Who: Grant Coady <gcoady@gmail.com> 95 +
+1 -1
Documentation/i2c/busses/i2c-sis69x
··· 42 42 chipsets as well: 635, and 635T. If anyone owns a board with those chips 43 43 AND is willing to risk crashing & burning an otherwise well-behaved kernel 44 44 in the name of progress... please contact me at <mhoffman@lightlink.com> or 45 - via the project's mailing list: <sensors@stimpy.netroedge.com>. Please 45 + via the project's mailing list: <lm-sensors@lm-sensors.org>. Please 46 46 send bug reports and/or success stories as well. 47 47 48 48
+111
Documentation/i2c/chips/adm1021
··· 1 + Kernel driver adm1021 2 + ===================== 3 + 4 + Supported chips: 5 + * Analog Devices ADM1021 6 + Prefix: 'adm1021' 7 + Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 8 + Datasheet: Publicly available at the Analog Devices website 9 + * Analog Devices ADM1021A/ADM1023 10 + Prefix: 'adm1023' 11 + Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 12 + Datasheet: Publicly available at the Analog Devices website 13 + * Genesys Logic GL523SM 14 + Prefix: 'gl523sm' 15 + Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 16 + Datasheet: 17 + * Intel Xeon Processor 18 + Prefix: - any other - may require 'force_adm1021' parameter 19 + Addresses scanned: none 20 + Datasheet: Publicly available at Intel website 21 + * Maxim MAX1617 22 + Prefix: 'max1617' 23 + Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 24 + Datasheet: Publicly available at the Maxim website 25 + * Maxim MAX1617A 26 + Prefix: 'max1617a' 27 + Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 28 + Datasheet: Publicly available at the Maxim website 29 + * National Semiconductor LM84 30 + Prefix: 'lm84' 31 + Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 32 + Datasheet: Publicly available at the National Semiconductor website 33 + * Philips NE1617 34 + Prefix: 'max1617' (probably detected as a max1617) 35 + Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 36 + Datasheet: Publicly available at the Philips website 37 + * Philips NE1617A 38 + Prefix: 'max1617' (probably detected as a max1617) 39 + Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 40 + Datasheet: Publicly available at the Philips website 41 + * TI THMC10 42 + Prefix: 'thmc10' 43 + Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 44 + Datasheet: Publicly available at the TI website 45 + * Onsemi MC1066 46 + Prefix: 'mc1066' 47 + Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 48 + Datasheet: Publicly available at the Onsemi website 49 + 50 + 51 + Authors: 52 + Frodo Looijaard <frodol@dds.nl>, 53 + Philip Edelbrock <phil@netroedge.com> 54 + 55 + Module Parameters 56 + ----------------- 57 + 58 + * read_only: int 59 + Don't set any values, read only mode 60 + 61 + 62 + Description 63 + ----------- 64 + 65 + The chips supported by this driver are very similar. The Maxim MAX1617 is 66 + the oldest; it has the problem that it is not very well detectable. The 67 + MAX1617A solves that. The ADM1021 is a straight clone of the MAX1617A. 68 + Ditto for the THMC10. From here on, we will refer to all these chips as 69 + ADM1021-clones. 70 + 71 + The ADM1021 and MAX1617A reports a die code, which is a sort of revision 72 + code. This can help us pinpoint problems; it is not very useful 73 + otherwise. 74 + 75 + ADM1021-clones implement two temperature sensors. One of them is internal, 76 + and measures the temperature of the chip itself; the other is external and 77 + is realised in the form of a transistor-like device. A special alarm 78 + indicates whether the remote sensor is connected. 79 + 80 + Each sensor has its own low and high limits. When they are crossed, the 81 + corresponding alarm is set and remains on as long as the temperature stays 82 + out of range. Temperatures are measured in degrees Celsius. Measurements 83 + are possible between -65 and +127 degrees, with a resolution of one degree. 84 + 85 + If an alarm triggers, it will remain triggered until the hardware register 86 + is read at least once. This means that the cause for the alarm may already 87 + have disappeared! 88 + 89 + This driver only updates its values each 1.5 seconds; reading it more often 90 + will do no harm, but will return 'old' values. It is possible to make 91 + ADM1021-clones do faster measurements, but there is really no good reason 92 + for that. 93 + 94 + Xeon support 95 + ------------ 96 + 97 + Some Xeon processors have real max1617, adm1021, or compatible chips 98 + within them, with two temperature sensors. 99 + 100 + Other Xeons have chips with only one sensor. 101 + 102 + If you have a Xeon, and the adm1021 module loads, and both temperatures 103 + appear valid, then things are good. 104 + 105 + If the adm1021 module doesn't load, you should try this: 106 + modprobe adm1021 force_adm1021=BUS,ADDRESS 107 + ADDRESS can only be 0x18, 0x1a, 0x29, 0x2b, 0x4c, or 0x4e. 108 + 109 + If you have dual Xeons you may have appear to have two separate 110 + adm1021-compatible chips, or two single-temperature sensors, at distinct 111 + addresses.
+51
Documentation/i2c/chips/adm1025
··· 1 + Kernel driver adm1025 2 + ===================== 3 + 4 + Supported chips: 5 + * Analog Devices ADM1025, ADM1025A 6 + Prefix: 'adm1025' 7 + Addresses scanned: I2C 0x2c - 0x2e 8 + Datasheet: Publicly available at the Analog Devices website 9 + * Philips NE1619 10 + Prefix: 'ne1619' 11 + Addresses scanned: I2C 0x2c - 0x2d 12 + Datasheet: Publicly available at the Philips website 13 + 14 + The NE1619 presents some differences with the original ADM1025: 15 + * Only two possible addresses (0x2c - 0x2d). 16 + * No temperature offset register, but we don't use it anyway. 17 + * No INT mode for pin 16. We don't play with it anyway. 18 + 19 + Authors: 20 + Chen-Yuan Wu <gwu@esoft.com>, 21 + Jean Delvare <khali@linux-fr.org> 22 + 23 + Description 24 + ----------- 25 + 26 + (This is from Analog Devices.) The ADM1025 is a complete system hardware 27 + monitor for microprocessor-based systems, providing measurement and limit 28 + comparison of various system parameters. Five voltage measurement inputs 29 + are provided, for monitoring +2.5V, +3.3V, +5V and +12V power supplies and 30 + the processor core voltage. The ADM1025 can monitor a sixth power-supply 31 + voltage by measuring its own VCC. One input (two pins) is dedicated to a 32 + remote temperature-sensing diode and an on-chip temperature sensor allows 33 + ambient temperature to be monitored. 34 + 35 + One specificity of this chip is that the pin 11 can be hardwired in two 36 + different manners. It can act as the +12V power-supply voltage analog 37 + input, or as the a fifth digital entry for the VID reading (bit 4). It's 38 + kind of strange since both are useful, and the reason for designing the 39 + chip that way is obscure at least to me. The bit 5 of the configuration 40 + register can be used to define how the chip is hardwired. Please note that 41 + it is not a choice you have to make as the user. The choice was already 42 + made by your motherboard's maker. If the configuration bit isn't set 43 + properly, you'll have a wrong +12V reading or a wrong VID reading. The way 44 + the driver handles that is to preserve this bit through the initialization 45 + process, assuming that the BIOS set it up properly beforehand. If it turns 46 + out not to be true in some cases, we'll provide a module parameter to force 47 + modes. 48 + 49 + This driver also supports the ADM1025A, which differs from the ADM1025 50 + only in that it has "open-drain VID inputs while the ADM1025 has on-chip 51 + 100k pull-ups on the VID inputs". It doesn't make any difference for us.
+93
Documentation/i2c/chips/adm1026
··· 1 + Kernel driver adm1026 2 + ===================== 3 + 4 + Supported chips: 5 + * Analog Devices ADM1026 6 + Prefix: 'adm1026' 7 + Addresses scanned: I2C 0x2c, 0x2d, 0x2e 8 + Datasheet: Publicly available at the Analog Devices website 9 + http://www.analog.com/en/prod/0,,766_825_ADM1026,00.html 10 + 11 + Authors: 12 + Philip Pokorny <ppokorny@penguincomputing.com> for Penguin Computing 13 + Justin Thiessen <jthiessen@penguincomputing.com> 14 + 15 + Module Parameters 16 + ----------------- 17 + 18 + * gpio_input: int array (min = 1, max = 17) 19 + List of GPIO pins (0-16) to program as inputs 20 + * gpio_output: int array (min = 1, max = 17) 21 + List of GPIO pins (0-16) to program as outputs 22 + * gpio_inverted: int array (min = 1, max = 17) 23 + List of GPIO pins (0-16) to program as inverted 24 + * gpio_normal: int array (min = 1, max = 17) 25 + List of GPIO pins (0-16) to program as normal/non-inverted 26 + * gpio_fan: int array (min = 1, max = 8) 27 + List of GPIO pins (0-7) to program as fan tachs 28 + 29 + 30 + Description 31 + ----------- 32 + 33 + This driver implements support for the Analog Devices ADM1026. Analog 34 + Devices calls it a "complete thermal system management controller." 35 + 36 + The ADM1026 implements three (3) temperature sensors, 17 voltage sensors, 37 + 16 general purpose digital I/O lines, eight (8) fan speed sensors (8-bit), 38 + an analog output and a PWM output along with limit, alarm and mask bits for 39 + all of the above. There is even 8k bytes of EEPROM memory on chip. 40 + 41 + Temperatures are measured in degrees Celsius. There are two external 42 + sensor inputs and one internal sensor. Each sensor has a high and low 43 + limit. If the limit is exceeded, an interrupt (#SMBALERT) can be 44 + generated. The interrupts can be masked. In addition, there are over-temp 45 + limits for each sensor. If this limit is exceeded, the #THERM output will 46 + be asserted. The current temperature and limits have a resolution of 1 47 + degree. 48 + 49 + Fan rotation speeds are reported in RPM (rotations per minute) but measured 50 + in counts of a 22.5kHz internal clock. Each fan has a high limit which 51 + corresponds to a minimum fan speed. If the limit is exceeded, an interrupt 52 + can be generated. Each fan can be programmed to divide the reference clock 53 + by 1, 2, 4 or 8. Not all RPM values can accurately be represented, so some 54 + rounding is done. With a divider of 8, the slowest measurable speed of a 55 + two pulse per revolution fan is 661 RPM. 56 + 57 + There are 17 voltage sensors. An alarm is triggered if the voltage has 58 + crossed a programmable minimum or maximum limit. Note that minimum in this 59 + case always means 'closest to zero'; this is important for negative voltage 60 + measurements. Several inputs have integrated attenuators so they can measure 61 + higher voltages directly. 3.3V, 5V, 12V, -12V and battery voltage all have 62 + dedicated inputs. There are several inputs scaled to 0-3V full-scale range 63 + for SCSI terminator power. The remaining inputs are not scaled and have 64 + a 0-2.5V full-scale range. A 2.5V or 1.82V reference voltage is provided 65 + for negative voltage measurements. 66 + 67 + If an alarm triggers, it will remain triggered until the hardware register 68 + is read at least once. This means that the cause for the alarm may already 69 + have disappeared! Note that in the current implementation, all hardware 70 + registers are read whenever any data is read (unless it is less than 2.0 71 + seconds since the last update). This means that you can easily miss 72 + once-only alarms. 73 + 74 + The ADM1026 measures continuously. Analog inputs are measured about 4 75 + times a second. Fan speed measurement time depends on fan speed and 76 + divisor. It can take as long as 1.5 seconds to measure all fan speeds. 77 + 78 + The ADM1026 has the ability to automatically control fan speed based on the 79 + temperature sensor inputs. Both the PWM output and the DAC output can be 80 + used to control fan speed. Usually only one of these two outputs will be 81 + used. Write the minimum PWM or DAC value to the appropriate control 82 + register. Then set the low temperature limit in the tmin values for each 83 + temperature sensor. The range of control is fixed at 20 �C, and the 84 + largest difference between current and tmin of the temperature sensors sets 85 + the control output. See the datasheet for several example circuits for 86 + controlling fan speed with the PWM and DAC outputs. The fan speed sensors 87 + do not have PWM compensation, so it is probably best to control the fan 88 + voltage from the power lead rather than on the ground lead. 89 + 90 + The datasheet shows an example application with VID signals attached to 91 + GPIO lines. Unfortunately, the chip may not be connected to the VID lines 92 + in this way. The driver assumes that the chips *is* connected this way to 93 + get a VID voltage.
+35
Documentation/i2c/chips/adm1031
··· 1 + Kernel driver adm1031 2 + ===================== 3 + 4 + Supported chips: 5 + * Analog Devices ADM1030 6 + Prefix: 'adm1030' 7 + Addresses scanned: I2C 0x2c to 0x2e 8 + Datasheet: Publicly available at the Analog Devices website 9 + http://products.analog.com/products/info.asp?product=ADM1030 10 + 11 + * Analog Devices ADM1031 12 + Prefix: 'adm1031' 13 + Addresses scanned: I2C 0x2c to 0x2e 14 + Datasheet: Publicly available at the Analog Devices website 15 + http://products.analog.com/products/info.asp?product=ADM1031 16 + 17 + Authors: 18 + Alexandre d'Alton <alex@alexdalton.org> 19 + Jean Delvare <khali@linux-fr.org> 20 + 21 + Description 22 + ----------- 23 + 24 + The ADM1030 and ADM1031 are digital temperature sensors and fan controllers. 25 + They sense their own temperature as well as the temperature of up to one 26 + (ADM1030) or two (ADM1031) external diodes. 27 + 28 + All temperature values are given in degrees Celsius. Resolution is 0.5 29 + degree for the local temperature, 0.125 degree for the remote temperatures. 30 + 31 + Each temperature channel has its own high and low limits, plus a critical 32 + limit. 33 + 34 + The ADM1030 monitors a single fan speed, while the ADM1031 monitors up to 35 + two. Each fan channel has its own low speed limit.
+177
Documentation/i2c/chips/adm9240
··· 1 + Kernel driver adm9240 2 + ===================== 3 + 4 + Supported chips: 5 + * Analog Devices ADM9240 6 + Prefix: 'adm9240' 7 + Addresses scanned: I2C 0x2c - 0x2f 8 + Datasheet: Publicly available at the Analog Devices website 9 + http://www.analog.com/UploadedFiles/Data_Sheets/79857778ADM9240_0.pdf 10 + 11 + * Dallas Semiconductor DS1780 12 + Prefix: 'ds1780' 13 + Addresses scanned: I2C 0x2c - 0x2f 14 + Datasheet: Publicly available at the Dallas Semiconductor (Maxim) website 15 + http://pdfserv.maxim-ic.com/en/ds/DS1780.pdf 16 + 17 + * National Semiconductor LM81 18 + Prefix: 'lm81' 19 + Addresses scanned: I2C 0x2c - 0x2f 20 + Datasheet: Publicly available at the National Semiconductor website 21 + http://www.national.com/ds.cgi/LM/LM81.pdf 22 + 23 + Authors: 24 + Frodo Looijaard <frodol@dds.nl>, 25 + Philip Edelbrock <phil@netroedge.com>, 26 + Michiel Rook <michiel@grendelproject.nl>, 27 + Grant Coady <gcoady@gmail.com> with guidance 28 + from Jean Delvare <khali@linux-fr.org> 29 + 30 + Interface 31 + --------- 32 + The I2C addresses listed above assume BIOS has not changed the 33 + chip MSB 5-bit address. Each chip reports a unique manufacturer 34 + identification code as well as the chip revision/stepping level. 35 + 36 + Description 37 + ----------- 38 + [From ADM9240] The ADM9240 is a complete system hardware monitor for 39 + microprocessor-based systems, providing measurement and limit comparison 40 + of up to four power supplies and two processor core voltages, plus 41 + temperature, two fan speeds and chassis intrusion. Measured values can 42 + be read out via an I2C-compatible serial System Management Bus, and values 43 + for limit comparisons can be programmed in over the same serial bus. The 44 + high speed successive approximation ADC allows frequent sampling of all 45 + analog channels to ensure a fast interrupt response to any out-of-limit 46 + measurement. 47 + 48 + The ADM9240, DS1780 and LM81 are register compatible, the following 49 + details are common to the three chips. Chip differences are described 50 + after this section. 51 + 52 + 53 + Measurements 54 + ------------ 55 + The measurement cycle 56 + 57 + The adm9240 driver will take a measurement reading no faster than once 58 + each two seconds. User-space may read sysfs interface faster than the 59 + measurement update rate and will receive cached data from the most 60 + recent measurement. 61 + 62 + ADM9240 has a very fast 320us temperature and voltage measurement cycle 63 + with independent fan speed measurement cycles counting alternating rising 64 + edges of the fan tacho inputs. 65 + 66 + DS1780 measurement cycle is about once per second including fan speed. 67 + 68 + LM81 measurement cycle is about once per 400ms including fan speed. 69 + The LM81 12-bit extended temperature measurement mode is not supported. 70 + 71 + Temperature 72 + ----------- 73 + On chip temperature is reported as degrees Celsius as 9-bit signed data 74 + with resolution of 0.5 degrees Celsius. High and low temperature limits 75 + are 8-bit signed data with resolution of one degree Celsius. 76 + 77 + Temperature alarm is asserted once the temperature exceeds the high limit, 78 + and is cleared when the temperature falls below the temp1_max_hyst value. 79 + 80 + Fan Speed 81 + --------- 82 + Two fan tacho inputs are provided, the ADM9240 gates an internal 22.5kHz 83 + clock via a divider to an 8-bit counter. Fan speed (rpm) is calculated by: 84 + 85 + rpm = (22500 * 60) / (count * divider) 86 + 87 + Automatic fan clock divider 88 + 89 + * User sets 0 to fan_min limit 90 + - low speed alarm is disabled 91 + - fan clock divider not changed 92 + - auto fan clock adjuster enabled for valid fan speed reading 93 + 94 + * User sets fan_min limit too low 95 + - low speed alarm is enabled 96 + - fan clock divider set to max 97 + - fan_min set to register value 254 which corresponds 98 + to 664 rpm on adm9240 99 + - low speed alarm will be asserted if fan speed is 100 + less than minimum measurable speed 101 + - auto fan clock adjuster disabled 102 + 103 + * User sets reasonable fan speed 104 + - low speed alarm is enabled 105 + - fan clock divider set to suit fan_min 106 + - auto fan clock adjuster enabled: adjusts fan_min 107 + 108 + * User sets unreasonably high low fan speed limit 109 + - resolution of the low speed limit may be reduced 110 + - alarm will be asserted 111 + - auto fan clock adjuster enabled: adjusts fan_min 112 + 113 + * fan speed may be displayed as zero until the auto fan clock divider 114 + adjuster brings fan speed clock divider back into chip measurement 115 + range, this will occur within a few measurement cycles. 116 + 117 + Analog Output 118 + ------------- 119 + An analog output provides a 0 to 1.25 volt signal intended for an external 120 + fan speed amplifier circuit. The analog output is set to maximum value on 121 + power up or reset. This doesn't do much on the test Intel SE440BX-2. 122 + 123 + Voltage Monitor 124 + 125 + Voltage (IN) measurement is internally scaled: 126 + 127 + nr label nominal maximum resolution 128 + mV mV mV 129 + 0 +2.5V 2500 3320 13.0 130 + 1 Vccp1 2700 3600 14.1 131 + 2 +3.3V 3300 4380 17.2 132 + 3 +5V 5000 6640 26.0 133 + 4 +12V 12000 15940 62.5 134 + 5 Vccp2 2700 3600 14.1 135 + 136 + The reading is an unsigned 8-bit value, nominal voltage measurement is 137 + represented by a reading of 192, being 3/4 of the measurement range. 138 + 139 + An alarm is asserted for any voltage going below or above the set limits. 140 + 141 + The driver reports and accepts voltage limits scaled to the above table. 142 + 143 + VID Monitor 144 + ----------- 145 + The chip has five inputs to read the 5-bit VID and reports the mV value 146 + based on detected CPU type. 147 + 148 + Chassis Intrusion 149 + ----------------- 150 + An alarm is asserted when the CI pin goes active high. The ADM9240 151 + Datasheet has an example of an external temperature sensor driving 152 + this pin. On an Intel SE440BX-2 the Chassis Intrusion header is 153 + connected to a normally open switch. 154 + 155 + The ADM9240 provides an internal open drain on this line, and may output 156 + a 20 ms active low pulse to reset an external Chassis Intrusion latch. 157 + 158 + Clear the CI latch by writing value 1 to the sysfs chassis_clear file. 159 + 160 + Alarm flags reported as 16-bit word 161 + 162 + bit label comment 163 + --- ------------- -------------------------- 164 + 0 +2.5 V_Error high or low limit exceeded 165 + 1 VCCP_Error high or low limit exceeded 166 + 2 +3.3 V_Error high or low limit exceeded 167 + 3 +5 V_Error high or low limit exceeded 168 + 4 Temp_Error temperature error 169 + 6 FAN1_Error fan low limit exceeded 170 + 7 FAN2_Error fan low limit exceeded 171 + 8 +12 V_Error high or low limit exceeded 172 + 9 VCCP2_Error high or low limit exceeded 173 + 12 Chassis_Error CI pin went high 174 + 175 + Remaining bits are reserved and thus undefined. It is important to note 176 + that alarm bits may be cleared on read, user-space may latch alarms and 177 + provide the end-user with a method to clear alarm memory.
+72
Documentation/i2c/chips/asb100
··· 1 + Kernel driver asb100 2 + ==================== 3 + 4 + Supported Chips: 5 + * Asus ASB100 and ASB100-A "Bach" 6 + Prefix: 'asb100' 7 + Addresses scanned: I2C 0x2d 8 + Datasheet: none released 9 + 10 + Author: Mark M. Hoffman <mhoffman@lightlink.com> 11 + 12 + Description 13 + ----------- 14 + 15 + This driver implements support for the Asus ASB100 and ASB100-A "Bach". 16 + These are custom ASICs available only on Asus mainboards. Asus refuses to 17 + supply a datasheet for these chips. Thanks go to many people who helped 18 + investigate their hardware, including: 19 + 20 + Vitaly V. Bursov 21 + Alexander van Kaam (author of MBM for Windows) 22 + Bertrik Sikken 23 + 24 + The ASB100 implements seven voltage sensors, three fan rotation speed 25 + sensors, four temperature sensors, VID lines and alarms. In addition to 26 + these, the ASB100-A also implements a single PWM controller for fans 2 and 27 + 3 (i.e. one setting controls both.) If you have a plain ASB100, the PWM 28 + controller will simply not work (or maybe it will for you... it doesn't for 29 + me). 30 + 31 + Temperatures are measured and reported in degrees Celsius. 32 + 33 + Fan speeds are reported in RPM (rotations per minute). An alarm is 34 + triggered if the rotation speed has dropped below a programmable limit. 35 + 36 + Voltage sensors (also known as IN sensors) report values in volts. 37 + 38 + The VID lines encode the core voltage value: the voltage level your 39 + processor should work with. This is hardcoded by the mainboard and/or 40 + processor itself. It is a value in volts. 41 + 42 + Alarms: (TODO question marks indicate may or may not work) 43 + 44 + 0x0001 => in0 (?) 45 + 0x0002 => in1 (?) 46 + 0x0004 => in2 47 + 0x0008 => in3 48 + 0x0010 => temp1 (1) 49 + 0x0020 => temp2 50 + 0x0040 => fan1 51 + 0x0080 => fan2 52 + 0x0100 => in4 53 + 0x0200 => in5 (?) (2) 54 + 0x0400 => in6 (?) (2) 55 + 0x0800 => fan3 56 + 0x1000 => chassis switch 57 + 0x2000 => temp3 58 + 59 + Alarm Notes: 60 + 61 + (1) This alarm will only trigger if the hysteresis value is 127C. 62 + I.e. it behaves the same as w83781d. 63 + 64 + (2) The min and max registers for these values appear to 65 + be read-only or otherwise stuck at 0x00. 66 + 67 + TODO: 68 + * Experiment with fan divisors > 8. 69 + * Experiment with temp. sensor types. 70 + * Are there really 13 voltage inputs? Probably not... 71 + * Cleanups, no doubt... 72 +
+108
Documentation/i2c/chips/ds1621
··· 1 + Kernel driver ds1621 2 + ==================== 3 + 4 + Supported chips: 5 + * Dallas Semiconductor DS1621 6 + Prefix: 'ds1621' 7 + Addresses scanned: I2C 0x48 - 0x4f 8 + Datasheet: Publicly available at the Dallas Semiconductor website 9 + http://www.dalsemi.com/ 10 + * Dallas Semiconductor DS1625 11 + Prefix: 'ds1621' 12 + Addresses scanned: I2C 0x48 - 0x4f 13 + Datasheet: Publicly available at the Dallas Semiconductor website 14 + http://www.dalsemi.com/ 15 + 16 + Authors: 17 + Christian W. Zuckschwerdt <zany@triq.net> 18 + valuable contributions by Jan M. Sendler <sendler@sendler.de> 19 + ported to 2.6 by Aurelien Jarno <aurelien@aurel32.net> 20 + with the help of Jean Delvare <khali@linux-fr.org> 21 + 22 + Module Parameters 23 + ------------------ 24 + 25 + * polarity int 26 + Output's polarity: 0 = active high, 1 = active low 27 + 28 + Description 29 + ----------- 30 + 31 + The DS1621 is a (one instance) digital thermometer and thermostat. It has 32 + both high and low temperature limits which can be user defined (i.e. 33 + programmed into non-volatile on-chip registers). Temperature range is -55 34 + degree Celsius to +125 in 0.5 increments. You may convert this into a 35 + Fahrenheit range of -67 to +257 degrees with 0.9 steps. If polarity 36 + parameter is not provided, original value is used. 37 + 38 + As for the thermostat, behavior can also be programmed using the polarity 39 + toggle. On the one hand ("heater"), the thermostat output of the chip, 40 + Tout, will trigger when the low limit temperature is met or underrun and 41 + stays high until the high limit is met or exceeded. On the other hand 42 + ("cooler"), vice versa. That way "heater" equals "active low", whereas 43 + "conditioner" equals "active high". Please note that the DS1621 data sheet 44 + is somewhat misleading in this point since setting the polarity bit does 45 + not simply invert Tout. 46 + 47 + A second thing is that, during extensive testing, Tout showed a tolerance 48 + of up to +/- 0.5 degrees even when compared against precise temperature 49 + readings. Be sure to have a high vs. low temperature limit gap of al least 50 + 1.0 degree Celsius to avoid Tout "bouncing", though! 51 + 52 + As for alarms, you can read the alarm status of the DS1621 via the 'alarms' 53 + /sys file interface. The result consists mainly of bit 6 and 5 of the 54 + configuration register of the chip; bit 6 (0x40 or 64) is the high alarm 55 + bit and bit 5 (0x20 or 32) the low one. These bits are set when the high or 56 + low limits are met or exceeded and are reset by the module as soon as the 57 + respective temperature ranges are left. 58 + 59 + The alarm registers are in no way suitable to find out about the actual 60 + status of Tout. They will only tell you about its history, whether or not 61 + any of the limits have ever been met or exceeded since last power-up or 62 + reset. Be aware: When testing, it showed that the status of Tout can change 63 + with neither of the alarms set. 64 + 65 + Temperature conversion of the DS1621 takes up to 1000ms; internal access to 66 + non-volatile registers may last for 10ms or below. 67 + 68 + High Accuracy Temperature Reading 69 + --------------------------------- 70 + 71 + As said before, the temperature issued via the 9-bit i2c-bus data is 72 + somewhat arbitrary. Internally, the temperature conversion is of a 73 + different kind that is explained (not so...) well in the DS1621 data sheet. 74 + To cut the long story short: Inside the DS1621 there are two oscillators, 75 + both of them biassed by a temperature coefficient. 76 + 77 + Higher resolution of the temperature reading can be achieved using the 78 + internal projection, which means taking account of REG_COUNT and REG_SLOPE 79 + (the driver manages them): 80 + 81 + Taken from Dallas Semiconductors App Note 068: 'Increasing Temperature 82 + Resolution on the DS1620' and App Note 105: 'High Resolution Temperature 83 + Measurement with Dallas Direct-to-Digital Temperature Sensors' 84 + 85 + - Read the 9-bit temperature and strip the LSB (Truncate the .5 degs) 86 + - The resulting value is TEMP_READ. 87 + - Then, read REG_COUNT. 88 + - And then, REG_SLOPE. 89 + 90 + TEMP = TEMP_READ - 0.25 + ((REG_SLOPE - REG_COUNT) / REG_SLOPE) 91 + 92 + Note that this is what the DONE bit in the DS1621 configuration register is 93 + good for: Internally, one temperature conversion takes up to 1000ms. Before 94 + that conversion is complete you will not be able to read valid things out 95 + of REG_COUNT and REG_SLOPE. The DONE bit, as you may have guessed by now, 96 + tells you whether the conversion is complete ("done", in plain English) and 97 + thus, whether the values you read are good or not. 98 + 99 + The DS1621 has two modes of operation: "Continuous" conversion, which can 100 + be understood as the default stand-alone mode where the chip gets the 101 + temperature and controls external devices via its Tout pin or tells other 102 + i2c's about it if they care. The other mode is called "1SHOT", that means 103 + that it only figures out about the temperature when it is explicitly told 104 + to do so; this can be seen as power saving mode. 105 + 106 + Now if you want to read REG_COUNT and REG_SLOPE, you have to either stop 107 + the continuous conversions until the contents of these registers are valid, 108 + or, in 1SHOT mode, you have to have one conversion made.
+96
Documentation/i2c/chips/eeprom
··· 1 + Kernel driver eeprom 2 + ==================== 3 + 4 + Supported chips: 5 + * Any EEPROM chip in the designated address range 6 + Prefix: 'eeprom' 7 + Addresses scanned: I2C 0x50 - 0x57 8 + Datasheets: Publicly available from: 9 + Atmel (www.atmel.com), 10 + Catalyst (www.catsemi.com), 11 + Fairchild (www.fairchildsemi.com), 12 + Microchip (www.microchip.com), 13 + Philips (www.semiconductor.philips.com), 14 + Rohm (www.rohm.com), 15 + ST (www.st.com), 16 + Xicor (www.xicor.com), 17 + and others. 18 + 19 + Chip Size (bits) Address 20 + 24C01 1K 0x50 (shadows at 0x51 - 0x57) 21 + 24C01A 1K 0x50 - 0x57 (Typical device on DIMMs) 22 + 24C02 2K 0x50 - 0x57 23 + 24C04 4K 0x50, 0x52, 0x54, 0x56 24 + (additional data at 0x51, 0x53, 0x55, 0x57) 25 + 24C08 8K 0x50, 0x54 (additional data at 0x51, 0x52, 26 + 0x53, 0x55, 0x56, 0x57) 27 + 24C16 16K 0x50 (additional data at 0x51 - 0x57) 28 + Sony 2K 0x57 29 + 30 + Atmel 34C02B 2K 0x50 - 0x57, SW write protect at 0x30-37 31 + Catalyst 34FC02 2K 0x50 - 0x57, SW write protect at 0x30-37 32 + Catalyst 34RC02 2K 0x50 - 0x57, SW write protect at 0x30-37 33 + Fairchild 34W02 2K 0x50 - 0x57, SW write protect at 0x30-37 34 + Microchip 24AA52 2K 0x50 - 0x57, SW write protect at 0x30-37 35 + ST M34C02 2K 0x50 - 0x57, SW write protect at 0x30-37 36 + 37 + 38 + Authors: 39 + Frodo Looijaard <frodol@dds.nl>, 40 + Philip Edelbrock <phil@netroedge.com>, 41 + Jean Delvare <khali@linux-fr.org>, 42 + Greg Kroah-Hartman <greg@kroah.com>, 43 + IBM Corp. 44 + 45 + Description 46 + ----------- 47 + 48 + This is a simple EEPROM module meant to enable reading the first 256 bytes 49 + of an EEPROM (on a SDRAM DIMM for example). However, it will access serial 50 + EEPROMs on any I2C adapter. The supported devices are generically called 51 + 24Cxx, and are listed above; however the numbering for these 52 + industry-standard devices may vary by manufacturer. 53 + 54 + This module was a programming exercise to get used to the new project 55 + organization laid out by Frodo, but it should be at least completely 56 + effective for decoding the contents of EEPROMs on DIMMs. 57 + 58 + DIMMS will typically contain a 24C01A or 24C02, or the 34C02 variants. 59 + The other devices will not be found on a DIMM because they respond to more 60 + than one address. 61 + 62 + DDC Monitors may contain any device. Often a 24C01, which responds to all 8 63 + addresses, is found. 64 + 65 + Recent Sony Vaio laptops have an EEPROM at 0x57. We couldn't get the 66 + specification, so it is guess work and far from being complete. 67 + 68 + The Microchip 24AA52/24LCS52, ST M34C02, and others support an additional 69 + software write protect register at 0x30 - 0x37 (0x20 less than the memory 70 + location). The chip responds to "write quick" detection at this address but 71 + does not respond to byte reads. If this register is present, the lower 128 72 + bytes of the memory array are not write protected. Any byte data write to 73 + this address will write protect the memory array permanently, and the 74 + device will no longer respond at the 0x30-37 address. The eeprom driver 75 + does not support this register. 76 + 77 + Lacking functionality: 78 + 79 + * Full support for larger devices (24C04, 24C08, 24C16). These are not 80 + typically found on a PC. These devices will appear as separate devices at 81 + multiple addresses. 82 + 83 + * Support for really large devices (24C32, 24C64, 24C128, 24C256, 24C512). 84 + These devices require two-byte address fields and are not supported. 85 + 86 + * Enable Writing. Again, no technical reason why not, but making it easy 87 + to change the contents of the EEPROMs (on DIMMs anyway) also makes it easy 88 + to disable the DIMMs (potentially preventing the computer from booting) 89 + until the values are restored somehow. 90 + 91 + Use: 92 + 93 + After inserting the module (and any other required SMBus/i2c modules), you 94 + should have some EEPROM directories in /sys/bus/i2c/devices/* of names such 95 + as "0-0050". Inside each of these is a series of files, the eeprom file 96 + contains the binary data from EEPROM.
+169
Documentation/i2c/chips/fscher
··· 1 + Kernel driver fscher 2 + ==================== 3 + 4 + Supported chips: 5 + * Fujitsu-Siemens Hermes chip 6 + Prefix: 'fscher' 7 + Addresses scanned: I2C 0x73 8 + 9 + Authors: 10 + Reinhard Nissl <rnissl@gmx.de> based on work 11 + from Hermann Jung <hej@odn.de>, 12 + Frodo Looijaard <frodol@dds.nl>, 13 + Philip Edelbrock <phil@netroedge.com> 14 + 15 + Description 16 + ----------- 17 + 18 + This driver implements support for the Fujitsu-Siemens Hermes chip. It is 19 + described in the 'Register Set Specification BMC Hermes based Systemboard' 20 + from Fujitsu-Siemens. 21 + 22 + The Hermes chip implements a hardware-based system management, e.g. for 23 + controlling fan speed and core voltage. There is also a watchdog counter on 24 + the chip which can trigger an alarm and even shut the system down. 25 + 26 + The chip provides three temperature values (CPU, motherboard and 27 + auxiliary), three voltage values (+12V, +5V and battery) and three fans 28 + (power supply, CPU and auxiliary). 29 + 30 + Temperatures are measured in degrees Celsius. The resolution is 1 degree. 31 + 32 + Fan rotation speeds are reported in RPM (rotations per minute). The value 33 + can be divided by a programmable divider (1, 2 or 4) which is stored on 34 + the chip. 35 + 36 + Voltage sensors (also known as "in" sensors) report their values in volts. 37 + 38 + All values are reported as final values from the driver. There is no need 39 + for further calculations. 40 + 41 + 42 + Detailed description 43 + -------------------- 44 + 45 + Below you'll find a single line description of all the bit values. With 46 + this information, you're able to decode e. g. alarms, wdog, etc. To make 47 + use of the watchdog, you'll need to set the watchdog time and enable the 48 + watchdog. After that it is necessary to restart the watchdog time within 49 + the specified period of time, or a system reset will occur. 50 + 51 + * revision 52 + READING & 0xff = 0x??: HERMES revision identification 53 + 54 + * alarms 55 + READING & 0x80 = 0x80: CPU throttling active 56 + READING & 0x80 = 0x00: CPU running at full speed 57 + 58 + READING & 0x10 = 0x10: software event (see control:1) 59 + READING & 0x10 = 0x00: no software event 60 + 61 + READING & 0x08 = 0x08: watchdog event (see wdog:2) 62 + READING & 0x08 = 0x00: no watchdog event 63 + 64 + READING & 0x02 = 0x02: thermal event (see temp*:1) 65 + READING & 0x02 = 0x00: no thermal event 66 + 67 + READING & 0x01 = 0x01: fan event (see fan*:1) 68 + READING & 0x01 = 0x00: no fan event 69 + 70 + READING & 0x13 ! 0x00: ALERT LED is flashing 71 + 72 + * control 73 + READING & 0x01 = 0x01: software event 74 + READING & 0x01 = 0x00: no software event 75 + 76 + WRITING & 0x01 = 0x01: set software event 77 + WRITING & 0x01 = 0x00: clear software event 78 + 79 + * watchdog_control 80 + READING & 0x80 = 0x80: power off on watchdog event while thermal event 81 + READING & 0x80 = 0x00: watchdog power off disabled (just system reset enabled) 82 + 83 + READING & 0x40 = 0x40: watchdog timebase 60 seconds (see also wdog:1) 84 + READING & 0x40 = 0x00: watchdog timebase 2 seconds 85 + 86 + READING & 0x10 = 0x10: watchdog enabled 87 + READING & 0x10 = 0x00: watchdog disabled 88 + 89 + WRITING & 0x80 = 0x80: enable "power off on watchdog event while thermal event" 90 + WRITING & 0x80 = 0x00: disable "power off on watchdog event while thermal event" 91 + 92 + WRITING & 0x40 = 0x40: set watchdog timebase to 60 seconds 93 + WRITING & 0x40 = 0x00: set watchdog timebase to 2 seconds 94 + 95 + WRITING & 0x20 = 0x20: disable watchdog 96 + 97 + WRITING & 0x10 = 0x10: enable watchdog / restart watchdog time 98 + 99 + * watchdog_state 100 + READING & 0x02 = 0x02: watchdog system reset occurred 101 + READING & 0x02 = 0x00: no watchdog system reset occurred 102 + 103 + WRITING & 0x02 = 0x02: clear watchdog event 104 + 105 + * watchdog_preset 106 + READING & 0xff = 0x??: configured watch dog time in units (see wdog:3 0x40) 107 + 108 + WRITING & 0xff = 0x??: configure watch dog time in units 109 + 110 + * in* (0: +5V, 1: +12V, 2: onboard 3V battery) 111 + READING: actual voltage value 112 + 113 + * temp*_status (1: CPU sensor, 2: onboard sensor, 3: auxiliary sensor) 114 + READING & 0x02 = 0x02: thermal event (overtemperature) 115 + READING & 0x02 = 0x00: no thermal event 116 + 117 + READING & 0x01 = 0x01: sensor is working 118 + READING & 0x01 = 0x00: sensor is faulty 119 + 120 + WRITING & 0x02 = 0x02: clear thermal event 121 + 122 + * temp*_input (1: CPU sensor, 2: onboard sensor, 3: auxiliary sensor) 123 + READING: actual temperature value 124 + 125 + * fan*_status (1: power supply fan, 2: CPU fan, 3: auxiliary fan) 126 + READING & 0x04 = 0x04: fan event (fan fault) 127 + READING & 0x04 = 0x00: no fan event 128 + 129 + WRITING & 0x04 = 0x04: clear fan event 130 + 131 + * fan*_div (1: power supply fan, 2: CPU fan, 3: auxiliary fan) 132 + Divisors 2,4 and 8 are supported, both for reading and writing 133 + 134 + * fan*_pwm (1: power supply fan, 2: CPU fan, 3: auxiliary fan) 135 + READING & 0xff = 0x00: fan may be switched off 136 + READING & 0xff = 0x01: fan must run at least at minimum speed (supply: 6V) 137 + READING & 0xff = 0xff: fan must run at maximum speed (supply: 12V) 138 + READING & 0xff = 0x??: fan must run at least at given speed (supply: 6V..12V) 139 + 140 + WRITING & 0xff = 0x00: fan may be switched off 141 + WRITING & 0xff = 0x01: fan must run at least at minimum speed (supply: 6V) 142 + WRITING & 0xff = 0xff: fan must run at maximum speed (supply: 12V) 143 + WRITING & 0xff = 0x??: fan must run at least at given speed (supply: 6V..12V) 144 + 145 + * fan*_input (1: power supply fan, 2: CPU fan, 3: auxiliary fan) 146 + READING: actual RPM value 147 + 148 + 149 + Limitations 150 + ----------- 151 + 152 + * Measuring fan speed 153 + It seems that the chip counts "ripples" (typical fans produce 2 ripples per 154 + rotation while VERAX fans produce 18) in a 9-bit register. This register is 155 + read out every second, then the ripple prescaler (2, 4 or 8) is applied and 156 + the result is stored in the 8 bit output register. Due to the limitation of 157 + the counting register to 9 bits, it is impossible to measure a VERAX fan 158 + properly (even with a prescaler of 8). At its maximum speed of 3500 RPM the 159 + fan produces 1080 ripples per second which causes the counting register to 160 + overflow twice, leading to only 186 RPM. 161 + 162 + * Measuring input voltages 163 + in2 ("battery") reports the voltage of the onboard lithium battery and not 164 + +3.3V from the power supply. 165 + 166 + * Undocumented features 167 + Fujitsu-Siemens Computers has not documented all features of the chip so 168 + far. Their software, System Guard, shows that there are a still some 169 + features which cannot be controlled by this implementation.
+74
Documentation/i2c/chips/gl518sm
··· 1 + Kernel driver gl518sm 2 + ===================== 3 + 4 + Supported chips: 5 + * Genesys Logic GL518SM release 0x00 6 + Prefix: 'gl518sm' 7 + Addresses scanned: I2C 0x2c and 0x2d 8 + Datasheet: http://www.genesyslogic.com/pdf 9 + * Genesys Logic GL518SM release 0x80 10 + Prefix: 'gl518sm' 11 + Addresses scanned: I2C 0x2c and 0x2d 12 + Datasheet: http://www.genesyslogic.com/pdf 13 + 14 + Authors: 15 + Frodo Looijaard <frodol@dds.nl>, 16 + Ky�sti M�lkki <kmalkki@cc.hut.fi> 17 + Hong-Gunn Chew <hglinux@gunnet.org> 18 + Jean Delvare <khali@linux-fr.org> 19 + 20 + Description 21 + ----------- 22 + 23 + IMPORTANT: 24 + 25 + For the revision 0x00 chip, the in0, in1, and in2 values (+5V, +3V, 26 + and +12V) CANNOT be read. This is a limitation of the chip, not the driver. 27 + 28 + This driver supports the Genesys Logic GL518SM chip. There are at least 29 + two revision of this chip, which we call revision 0x00 and 0x80. Revision 30 + 0x80 chips support the reading of all voltages and revision 0x00 only 31 + for VIN3. 32 + 33 + The GL518SM implements one temperature sensor, two fan rotation speed 34 + sensors, and four voltage sensors. It can report alarms through the 35 + computer speakers. 36 + 37 + Temperatures are measured in degrees Celsius. An alarm goes off while the 38 + temperature is above the over temperature limit, and has not yet dropped 39 + below the hysteresis limit. The alarm always reflects the current 40 + situation. Measurements are guaranteed between -10 degrees and +110 41 + degrees, with a accuracy of +/-3 degrees. 42 + 43 + Rotation speeds are reported in RPM (rotations per minute). An alarm is 44 + triggered if the rotation speed has dropped below a programmable limit. In 45 + case when you have selected to turn fan1 off, no fan1 alarm is triggered. 46 + 47 + Fan readings can be divided by a programmable divider (1, 2, 4 or 8) to 48 + give the readings more range or accuracy. Not all RPM values can 49 + accurately be represented, so some rounding is done. With a divider 50 + of 2, the lowest representable value is around 1900 RPM. 51 + 52 + Voltage sensors (also known as VIN sensors) report their values in volts. 53 + An alarm is triggered if the voltage has crossed a programmable minimum or 54 + maximum limit. Note that minimum in this case always means 'closest to 55 + zero'; this is important for negative voltage measurements. The VDD input 56 + measures voltages between 0.000 and 5.865 volt, with a resolution of 0.023 57 + volt. The other inputs measure voltages between 0.000 and 4.845 volt, with 58 + a resolution of 0.019 volt. Note that revision 0x00 chips do not support 59 + reading the current voltage of any input except for VIN3; limit setting and 60 + alarms work fine, though. 61 + 62 + When an alarm is triggered, you can be warned by a beeping signal through your 63 + computer speaker. It is possible to enable all beeping globally, or only the 64 + beeping for some alarms. 65 + 66 + If an alarm triggers, it will remain triggered until the hardware register 67 + is read at least once (except for temperature alarms). This means that the 68 + cause for the alarm may already have disappeared! Note that in the current 69 + implementation, all hardware registers are read whenever any data is read 70 + (unless it is less than 1.5 seconds since the last update). This means that 71 + you can easily miss once-only alarms. 72 + 73 + The GL518SM only updates its values each 1.5 seconds; reading it more often 74 + will do no harm, but will return 'old' values.
+96
Documentation/i2c/chips/it87
··· 1 + Kernel driver it87 2 + ================== 3 + 4 + Supported chips: 5 + * IT8705F 6 + Prefix: 'it87' 7 + Addresses scanned: from Super I/O config space, or default ISA 0x290 (8 I/O ports) 8 + Datasheet: Publicly available at the ITE website 9 + http://www.ite.com.tw/ 10 + * IT8712F 11 + Prefix: 'it8712' 12 + Addresses scanned: I2C 0x28 - 0x2f 13 + from Super I/O config space, or default ISA 0x290 (8 I/O ports) 14 + Datasheet: Publicly available at the ITE website 15 + http://www.ite.com.tw/ 16 + * SiS950 [clone of IT8705F] 17 + Prefix: 'sis950' 18 + Addresses scanned: from Super I/O config space, or default ISA 0x290 (8 I/O ports) 19 + Datasheet: No longer be available 20 + 21 + Author: Christophe Gauthron <chrisg@0-in.com> 22 + 23 + 24 + Module Parameters 25 + ----------------- 26 + 27 + * update_vbat: int 28 + 29 + 0 if vbat should report power on value, 1 if vbat should be updated after 30 + each read. Default is 0. On some boards the battery voltage is provided 31 + by either the battery or the onboard power supply. Only the first reading 32 + at power on will be the actual battery voltage (which the chip does 33 + automatically). On other boards the battery voltage is always fed to 34 + the chip so can be read at any time. Excessive reading may decrease 35 + battery life but no information is given in the datasheet. 36 + 37 + * fix_pwm_polarity int 38 + 39 + Force PWM polarity to active high (DANGEROUS). Some chips are 40 + misconfigured by BIOS - PWM values would be inverted. This option tries 41 + to fix this. Please contact your BIOS manufacturer and ask him for fix. 42 + 43 + Description 44 + ----------- 45 + 46 + This driver implements support for the IT8705F, IT8712F and SiS950 chips. 47 + 48 + This driver also supports IT8712F, which adds SMBus access, and a VID 49 + input, used to report the Vcore voltage of the Pentium processor. 50 + The IT8712F additionally features VID inputs. 51 + 52 + These chips are 'Super I/O chips', supporting floppy disks, infrared ports, 53 + joysticks and other miscellaneous stuff. For hardware monitoring, they 54 + include an 'environment controller' with 3 temperature sensors, 3 fan 55 + rotation speed sensors, 8 voltage sensors, and associated alarms. 56 + 57 + Temperatures are measured in degrees Celsius. An alarm is triggered once 58 + when the Overtemperature Shutdown limit is crossed. 59 + 60 + Fan rotation speeds are reported in RPM (rotations per minute). An alarm is 61 + triggered if the rotation speed has dropped below a programmable limit. Fan 62 + readings can be divided by a programmable divider (1, 2, 4 or 8) to give the 63 + readings more range or accuracy. Not all RPM values can accurately be 64 + represented, so some rounding is done. With a divider of 2, the lowest 65 + representable value is around 2600 RPM. 66 + 67 + Voltage sensors (also known as IN sensors) report their values in volts. An 68 + alarm is triggered if the voltage has crossed a programmable minimum or 69 + maximum limit. Note that minimum in this case always means 'closest to 70 + zero'; this is important for negative voltage measurements. All voltage 71 + inputs can measure voltages between 0 and 4.08 volts, with a resolution of 72 + 0.016 volt. The battery voltage in8 does not have limit registers. 73 + 74 + The VID lines (IT8712F only) encode the core voltage value: the voltage 75 + level your processor should work with. This is hardcoded by the mainboard 76 + and/or processor itself. It is a value in volts. 77 + 78 + If an alarm triggers, it will remain triggered until the hardware register 79 + is read at least once. This means that the cause for the alarm may already 80 + have disappeared! Note that in the current implementation, all hardware 81 + registers are read whenever any data is read (unless it is less than 1.5 82 + seconds since the last update). This means that you can easily miss 83 + once-only alarms. 84 + 85 + The IT87xx only updates its values each 1.5 seconds; reading it more often 86 + will do no harm, but will return 'old' values. 87 + 88 + To change sensor N to a thermistor, 'echo 2 > tempN_type' where N is 1, 2, 89 + or 3. To change sensor N to a thermal diode, 'echo 3 > tempN_type'. 90 + Give 0 for unused sensor. Any other value is invalid. To configure this at 91 + startup, consult lm_sensors's /etc/sensors.conf. (2 = thermistor; 92 + 3 = thermal diode) 93 + 94 + The fan speed control features are limited to manual PWM mode. Automatic 95 + "Smart Guardian" mode control handling is not implemented. However 96 + if you want to go for "manual mode" just write 1 to pwmN_enable.
+57
Documentation/i2c/chips/lm63
··· 1 + Kernel driver lm63 2 + ================== 3 + 4 + Supported chips: 5 + * National Semiconductor LM63 6 + Prefix: 'lm63' 7 + Addresses scanned: I2C 0x4c 8 + Datasheet: Publicly available at the National Semiconductor website 9 + http://www.national.com/pf/LM/LM63.html 10 + 11 + Author: Jean Delvare <khali@linux-fr.org> 12 + 13 + Thanks go to Tyan and especially Alex Buckingham for setting up a remote 14 + access to their S4882 test platform for this driver. 15 + http://www.tyan.com/ 16 + 17 + Description 18 + ----------- 19 + 20 + The LM63 is a digital temperature sensor with integrated fan monitoring 21 + and control. 22 + 23 + The LM63 is basically an LM86 with fan speed monitoring and control 24 + capabilities added. It misses some of the LM86 features though: 25 + - No low limit for local temperature. 26 + - No critical limit for local temperature. 27 + - Critical limit for remote temperature can be changed only once. We 28 + will consider that the critical limit is read-only. 29 + 30 + The datasheet isn't very clear about what the tachometer reading is. 31 + 32 + An explanation from National Semiconductor: The two lower bits of the read 33 + value have to be masked out. The value is still 16 bit in width. 34 + 35 + All temperature values are given in degrees Celsius. Resolution is 1.0 36 + degree for the local temperature, 0.125 degree for the remote temperature. 37 + 38 + The fan speed is measured using a tachometer. Contrary to most chips which 39 + store the value in an 8-bit register and have a selectable clock divider 40 + to make sure that the result will fit in the register, the LM63 uses 16-bit 41 + value for measuring the speed of the fan. It can measure fan speeds down to 42 + 83 RPM, at least in theory. 43 + 44 + Note that the pin used for fan monitoring is shared with an alert out 45 + function. Depending on how the board designer wanted to use the chip, fan 46 + speed monitoring will or will not be possible. The proper chip configuration 47 + is left to the BIOS, and the driver will blindly trust it. 48 + 49 + A PWM output can be used to control the speed of the fan. The LM63 has two 50 + PWM modes: manual and automatic. Automatic mode is not fully implemented yet 51 + (you cannot define your custom PWM/temperature curve), and mode change isn't 52 + supported either. 53 + 54 + The lm63 driver will not update its values more frequently than every 55 + second; reading them more often will do no harm, but will return 'old' 56 + values. 57 +
+65
Documentation/i2c/chips/lm75
··· 1 + Kernel driver lm75 2 + ================== 3 + 4 + Supported chips: 5 + * National Semiconductor LM75 6 + Prefix: 'lm75' 7 + Addresses scanned: I2C 0x48 - 0x4f 8 + Datasheet: Publicly available at the National Semiconductor website 9 + http://www.national.com/ 10 + * Dallas Semiconductor DS75 11 + Prefix: 'lm75' 12 + Addresses scanned: I2C 0x48 - 0x4f 13 + Datasheet: Publicly available at the Dallas Semiconductor website 14 + http://www.maxim-ic.com/ 15 + * Dallas Semiconductor DS1775 16 + Prefix: 'lm75' 17 + Addresses scanned: I2C 0x48 - 0x4f 18 + Datasheet: Publicly available at the Dallas Semiconductor website 19 + http://www.maxim-ic.com/ 20 + * Maxim MAX6625, MAX6626 21 + Prefix: 'lm75' 22 + Addresses scanned: I2C 0x48 - 0x4b 23 + Datasheet: Publicly available at the Maxim website 24 + http://www.maxim-ic.com/ 25 + * Microchip (TelCom) TCN75 26 + Prefix: 'lm75' 27 + Addresses scanned: I2C 0x48 - 0x4f 28 + Datasheet: Publicly available at the Microchip website 29 + http://www.microchip.com/ 30 + 31 + Author: Frodo Looijaard <frodol@dds.nl> 32 + 33 + Description 34 + ----------- 35 + 36 + The LM75 implements one temperature sensor. Limits can be set through the 37 + Overtemperature Shutdown register and Hysteresis register. Each value can be 38 + set and read to half-degree accuracy. 39 + An alarm is issued (usually to a connected LM78) when the temperature 40 + gets higher then the Overtemperature Shutdown value; it stays on until 41 + the temperature falls below the Hysteresis value. 42 + All temperatures are in degrees Celsius, and are guaranteed within a 43 + range of -55 to +125 degrees. 44 + 45 + The LM75 only updates its values each 1.5 seconds; reading it more often 46 + will do no harm, but will return 'old' values. 47 + 48 + The LM75 is usually used in combination with LM78-like chips, to measure 49 + the temperature of the processor(s). 50 + 51 + The DS75, DS1775, MAX6625, and MAX6626 are supported as well. 52 + They are not distinguished from an LM75. While most of these chips 53 + have three additional bits of accuracy (12 vs. 9 for the LM75), 54 + the additional bits are not supported. Not only that, but these chips will 55 + not be detected if not in 9-bit precision mode (use the force parameter if 56 + needed). 57 + 58 + The TCN75 is supported as well, and is not distinguished from an LM75. 59 + 60 + The LM75 is essentially an industry standard; there may be other 61 + LM75 clones not listed here, with or without various enhancements, 62 + that are supported. 63 + 64 + The LM77 is not supported, contrary to what we pretended for a long time. 65 + Both chips are simply not compatible, value encoding differs.
+22
Documentation/i2c/chips/lm77
··· 1 + Kernel driver lm77 2 + ================== 3 + 4 + Supported chips: 5 + * National Semiconductor LM77 6 + Prefix: 'lm77' 7 + Addresses scanned: I2C 0x48 - 0x4b 8 + Datasheet: Publicly available at the National Semiconductor website 9 + http://www.national.com/ 10 + 11 + Author: Andras BALI <drewie@freemail.hu> 12 + 13 + Description 14 + ----------- 15 + 16 + The LM77 implements one temperature sensor. The temperature 17 + sensor incorporates a band-gap type temperature sensor, 18 + 10-bit ADC, and a digital comparator with user-programmable upper 19 + and lower limit values. 20 + 21 + Limits can be set through the Overtemperature Shutdown register and 22 + Hysteresis register.
+82
Documentation/i2c/chips/lm78
··· 1 + Kernel driver lm78 2 + ================== 3 + 4 + Supported chips: 5 + * National Semiconductor LM78 6 + Prefix: 'lm78' 7 + Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) 8 + Datasheet: Publicly available at the National Semiconductor website 9 + http://www.national.com/ 10 + * National Semiconductor LM78-J 11 + Prefix: 'lm78-j' 12 + Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) 13 + Datasheet: Publicly available at the National Semiconductor website 14 + http://www.national.com/ 15 + * National Semiconductor LM79 16 + Prefix: 'lm79' 17 + Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) 18 + Datasheet: Publicly available at the National Semiconductor website 19 + http://www.national.com/ 20 + 21 + Author: Frodo Looijaard <frodol@dds.nl> 22 + 23 + Description 24 + ----------- 25 + 26 + This driver implements support for the National Semiconductor LM78, LM78-J 27 + and LM79. They are described as 'Microprocessor System Hardware Monitors'. 28 + 29 + There is almost no difference between the three supported chips. Functionally, 30 + the LM78 and LM78-J are exactly identical. The LM79 has one more VID line, 31 + which is used to report the lower voltages newer Pentium processors use. 32 + From here on, LM7* means either of these three types. 33 + 34 + The LM7* implements one temperature sensor, three fan rotation speed sensors, 35 + seven voltage sensors, VID lines, alarms, and some miscellaneous stuff. 36 + 37 + Temperatures are measured in degrees Celsius. An alarm is triggered once 38 + when the Overtemperature Shutdown limit is crossed; it is triggered again 39 + as soon as it drops below the Hysteresis value. A more useful behavior 40 + can be found by setting the Hysteresis value to +127 degrees Celsius; in 41 + this case, alarms are issued during all the time when the actual temperature 42 + is above the Overtemperature Shutdown value. Measurements are guaranteed 43 + between -55 and +125 degrees, with a resolution of 1 degree. 44 + 45 + Fan rotation speeds are reported in RPM (rotations per minute). An alarm is 46 + triggered if the rotation speed has dropped below a programmable limit. Fan 47 + readings can be divided by a programmable divider (1, 2, 4 or 8) to give 48 + the readings more range or accuracy. Not all RPM values can accurately be 49 + represented, so some rounding is done. With a divider of 2, the lowest 50 + representable value is around 2600 RPM. 51 + 52 + Voltage sensors (also known as IN sensors) report their values in volts. 53 + An alarm is triggered if the voltage has crossed a programmable minimum 54 + or maximum limit. Note that minimum in this case always means 'closest to 55 + zero'; this is important for negative voltage measurements. All voltage 56 + inputs can measure voltages between 0 and 4.08 volts, with a resolution 57 + of 0.016 volt. 58 + 59 + The VID lines encode the core voltage value: the voltage level your processor 60 + should work with. This is hardcoded by the mainboard and/or processor itself. 61 + It is a value in volts. When it is unconnected, you will often find the 62 + value 3.50 V here. 63 + 64 + In addition to the alarms described above, there are a couple of additional 65 + ones. There is a BTI alarm, which gets triggered when an external chip has 66 + crossed its limits. Usually, this is connected to all LM75 chips; if at 67 + least one crosses its limits, this bit gets set. The CHAS alarm triggers 68 + if your computer case is open. The FIFO alarms should never trigger; it 69 + indicates an internal error. The SMI_IN alarm indicates some other chip 70 + has triggered an SMI interrupt. As we do not use SMI interrupts at all, 71 + this condition usually indicates there is a problem with some other 72 + device. 73 + 74 + If an alarm triggers, it will remain triggered until the hardware register 75 + is read at least once. This means that the cause for the alarm may 76 + already have disappeared! Note that in the current implementation, all 77 + hardware registers are read whenever any data is read (unless it is less 78 + than 1.5 seconds since the last update). This means that you can easily 79 + miss once-only alarms. 80 + 81 + The LM7* only updates its values each 1.5 seconds; reading it more often 82 + will do no harm, but will return 'old' values.
+56
Documentation/i2c/chips/lm80
··· 1 + Kernel driver lm80 2 + ================== 3 + 4 + Supported chips: 5 + * National Semiconductor LM80 6 + Prefix: 'lm80' 7 + Addresses scanned: I2C 0x28 - 0x2f 8 + Datasheet: Publicly available at the National Semiconductor website 9 + http://www.national.com/ 10 + 11 + Authors: 12 + Frodo Looijaard <frodol@dds.nl>, 13 + Philip Edelbrock <phil@netroedge.com> 14 + 15 + Description 16 + ----------- 17 + 18 + This driver implements support for the National Semiconductor LM80. 19 + It is described as a 'Serial Interface ACPI-Compatible Microprocessor 20 + System Hardware Monitor'. 21 + 22 + The LM80 implements one temperature sensor, two fan rotation speed sensors, 23 + seven voltage sensors, alarms, and some miscellaneous stuff. 24 + 25 + Temperatures are measured in degrees Celsius. There are two sets of limits 26 + which operate independently. When the HOT Temperature Limit is crossed, 27 + this will cause an alarm that will be reasserted until the temperature 28 + drops below the HOT Hysteresis. The Overtemperature Shutdown (OS) limits 29 + should work in the same way (but this must be checked; the datasheet 30 + is unclear about this). Measurements are guaranteed between -55 and 31 + +125 degrees. The current temperature measurement has a resolution of 32 + 0.0625 degrees; the limits have a resolution of 1 degree. 33 + 34 + Fan rotation speeds are reported in RPM (rotations per minute). An alarm is 35 + triggered if the rotation speed has dropped below a programmable limit. Fan 36 + readings can be divided by a programmable divider (1, 2, 4 or 8) to give 37 + the readings more range or accuracy. Not all RPM values can accurately be 38 + represented, so some rounding is done. With a divider of 2, the lowest 39 + representable value is around 2600 RPM. 40 + 41 + Voltage sensors (also known as IN sensors) report their values in volts. 42 + An alarm is triggered if the voltage has crossed a programmable minimum 43 + or maximum limit. Note that minimum in this case always means 'closest to 44 + zero'; this is important for negative voltage measurements. All voltage 45 + inputs can measure voltages between 0 and 2.55 volts, with a resolution 46 + of 0.01 volt. 47 + 48 + If an alarm triggers, it will remain triggered until the hardware register 49 + is read at least once. This means that the cause for the alarm may 50 + already have disappeared! Note that in the current implementation, all 51 + hardware registers are read whenever any data is read (unless it is less 52 + than 2.0 seconds since the last update). This means that you can easily 53 + miss once-only alarms. 54 + 55 + The LM80 only updates its values each 1.5 seconds; reading it more often 56 + will do no harm, but will return 'old' values.
+76
Documentation/i2c/chips/lm83
··· 1 + Kernel driver lm83 2 + ================== 3 + 4 + Supported chips: 5 + * National Semiconductor LM83 6 + Prefix: 'lm83' 7 + Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e 8 + Datasheet: Publicly available at the National Semiconductor website 9 + http://www.national.com/pf/LM/LM83.html 10 + 11 + 12 + Author: Jean Delvare <khali@linux-fr.org> 13 + 14 + Description 15 + ----------- 16 + 17 + The LM83 is a digital temperature sensor. It senses its own temperature as 18 + well as the temperature of up to three external diodes. It is compatible 19 + with many other devices such as the LM84 and all other ADM1021 clones. 20 + The main difference between the LM83 and the LM84 in that the later can 21 + only sense the temperature of one external diode. 22 + 23 + Using the adm1021 driver for a LM83 should work, but only two temperatures 24 + will be reported instead of four. 25 + 26 + The LM83 is only found on a handful of motherboards. Both a confirmed 27 + list and an unconfirmed list follow. If you can confirm or infirm the 28 + fact that any of these motherboards do actually have an LM83, please 29 + contact us. Note that the LM90 can easily be misdetected as a LM83. 30 + 31 + Confirmed motherboards: 32 + SBS P014 33 + 34 + Unconfirmed motherboards: 35 + Gigabyte GA-8IK1100 36 + Iwill MPX2 37 + Soltek SL-75DRV5 38 + 39 + The driver has been successfully tested by Magnus Forsstr�m, who I'd 40 + like to thank here. More testers will be of course welcome. 41 + 42 + The fact that the LM83 is only scarcely used can be easily explained. 43 + Most motherboards come with more than just temperature sensors for 44 + health monitoring. They also have voltage and fan rotation speed 45 + sensors. This means that temperature-only chips are usually used as 46 + secondary chips coupled with another chip such as an IT8705F or similar 47 + chip, which provides more features. Since systems usually need three 48 + temperature sensors (motherboard, processor, power supply) and primary 49 + chips provide some temperature sensors, the secondary chip, if needed, 50 + won't have to handle more than two temperatures. Thus, ADM1021 clones 51 + are sufficient, and there is no need for a four temperatures sensor 52 + chip such as the LM83. The only case where using an LM83 would make 53 + sense is on SMP systems, such as the above-mentioned Iwill MPX2, 54 + because you want an additional temperature sensor for each additional 55 + CPU. 56 + 57 + On the SBS P014, this is different, since the LM83 is the only hardware 58 + monitoring chipset. One temperature sensor is used for the motherboard 59 + (actually measuring the LM83's own temperature), one is used for the 60 + CPU. The two other sensors must be used to measure the temperature of 61 + two other points of the motherboard. We suspect these points to be the 62 + north and south bridges, but this couldn't be confirmed. 63 + 64 + All temperature values are given in degrees Celsius. Local temperature 65 + is given within a range of 0 to +85 degrees. Remote temperatures are 66 + given within a range of 0 to +125 degrees. Resolution is 1.0 degree, 67 + accuracy is guaranteed to 3.0 degrees (see the datasheet for more 68 + details). 69 + 70 + Each sensor has its own high limit, but the critical limit is common to 71 + all four sensors. There is no hysteresis mechanism as found on most 72 + recent temperature sensors. 73 + 74 + The lm83 driver will not update its values more frequently than every 75 + other second; reading them more often will do no harm, but will return 76 + 'old' values.
+221
Documentation/i2c/chips/lm85
··· 1 + Kernel driver lm85 2 + ================== 3 + 4 + Supported chips: 5 + * National Semiconductor LM85 (B and C versions) 6 + Prefix: 'lm85' 7 + Addresses scanned: I2C 0x2c, 0x2d, 0x2e 8 + Datasheet: http://www.national.com/pf/LM/LM85.html 9 + * Analog Devices ADM1027 10 + Prefix: 'adm1027' 11 + Addresses scanned: I2C 0x2c, 0x2d, 0x2e 12 + Datasheet: http://www.analog.com/en/prod/0,,766_825_ADM1027,00.html 13 + * Analog Devices ADT7463 14 + Prefix: 'adt7463' 15 + Addresses scanned: I2C 0x2c, 0x2d, 0x2e 16 + Datasheet: http://www.analog.com/en/prod/0,,766_825_ADT7463,00.html 17 + * SMSC EMC6D100, SMSC EMC6D101 18 + Prefix: 'emc6d100' 19 + Addresses scanned: I2C 0x2c, 0x2d, 0x2e 20 + Datasheet: http://www.smsc.com/main/tools/discontinued/6d100.pdf 21 + * SMSC EMC6D102 22 + Prefix: 'emc6d102' 23 + Addresses scanned: I2C 0x2c, 0x2d, 0x2e 24 + Datasheet: http://www.smsc.com/main/catalog/emc6d102.html 25 + 26 + Authors: 27 + Philip Pokorny <ppokorny@penguincomputing.com>, 28 + Frodo Looijaard <frodol@dds.nl>, 29 + Richard Barrington <rich_b_nz@clear.net.nz>, 30 + Margit Schubert-While <margitsw@t-online.de>, 31 + Justin Thiessen <jthiessen@penguincomputing.com> 32 + 33 + Description 34 + ----------- 35 + 36 + This driver implements support for the National Semiconductor LM85 and 37 + compatible chips including the Analog Devices ADM1027, ADT7463 and 38 + SMSC EMC6D10x chips family. 39 + 40 + The LM85 uses the 2-wire interface compatible with the SMBUS 2.0 41 + specification. Using an analog to digital converter it measures three (3) 42 + temperatures and five (5) voltages. It has four (4) 16-bit counters for 43 + measuring fan speed. Five (5) digital inputs are provided for sampling the 44 + VID signals from the processor to the VRM. Lastly, there are three (3) PWM 45 + outputs that can be used to control fan speed. 46 + 47 + The voltage inputs have internal scaling resistors so that the following 48 + voltage can be measured without external resistors: 49 + 50 + 2.5V, 3.3V, 5V, 12V, and CPU core voltage (2.25V) 51 + 52 + The temperatures measured are one internal diode, and two remote diodes. 53 + Remote 1 is generally the CPU temperature. These inputs are designed to 54 + measure a thermal diode like the one in a Pentium 4 processor in a socket 55 + 423 or socket 478 package. They can also measure temperature using a 56 + transistor like the 2N3904. 57 + 58 + A sophisticated control system for the PWM outputs is designed into the 59 + LM85 that allows fan speed to be adjusted automatically based on any of the 60 + three temperature sensors. Each PWM output is individually adjustable and 61 + programmable. Once configured, the LM85 will adjust the PWM outputs in 62 + response to the measured temperatures without further host intervention. 63 + This feature can also be disabled for manual control of the PWM's. 64 + 65 + Each of the measured inputs (voltage, temperature, fan speed) has 66 + corresponding high/low limit values. The LM85 will signal an ALARM if any 67 + measured value exceeds either limit. 68 + 69 + The LM85 samples all inputs continuously. The lm85 driver will not read 70 + the registers more often than once a second. Further, configuration data is 71 + only read once each 5 minutes. There is twice as much config data as 72 + measurements, so this would seem to be a worthwhile optimization. 73 + 74 + Special Features 75 + ---------------- 76 + 77 + The LM85 has four fan speed monitoring modes. The ADM1027 has only two. 78 + Both have special circuitry to compensate for PWM interactions with the 79 + TACH signal from the fans. The ADM1027 can be configured to measure the 80 + speed of a two wire fan, but the input conditioning circuitry is different 81 + for 3-wire and 2-wire mode. For this reason, the 2-wire fan modes are not 82 + exposed to user control. The BIOS should initialize them to the correct 83 + mode. If you've designed your own ADM1027, you'll have to modify the 84 + init_client function and add an insmod parameter to set this up. 85 + 86 + To smooth the response of fans to changes in temperature, the LM85 has an 87 + optional filter for smoothing temperatures. The ADM1027 has the same 88 + config option but uses it to rate limit the changes to fan speed instead. 89 + 90 + The ADM1027 and ADT7463 have a 10-bit ADC and can therefore measure 91 + temperatures with 0.25 degC resolution. They also provide an offset to the 92 + temperature readings that is automatically applied during measurement. 93 + This offset can be used to zero out any errors due to traces and placement. 94 + The documentation says that the offset is in 0.25 degC steps, but in 95 + initial testing of the ADM1027 it was 1.00 degC steps. Analog Devices has 96 + confirmed this "bug". The ADT7463 is reported to work as described in the 97 + documentation. The current lm85 driver does not show the offset register. 98 + 99 + The ADT7463 has a THERM asserted counter. This counter has a 22.76ms 100 + resolution and a range of 5.8 seconds. The driver implements a 32-bit 101 + accumulator of the counter value to extend the range to over a year. The 102 + counter will stay at it's max value until read. 103 + 104 + See the vendor datasheets for more information. There is application note 105 + from National (AN-1260) with some additional information about the LM85. 106 + The Analog Devices datasheet is very detailed and describes a procedure for 107 + determining an optimal configuration for the automatic PWM control. 108 + 109 + The SMSC EMC6D100 & EMC6D101 monitor external voltages, temperatures, and 110 + fan speeds. They use this monitoring capability to alert the system to out 111 + of limit conditions and can automatically control the speeds of multiple 112 + fans in a PC or embedded system. The EMC6D101, available in a 24-pin SSOP 113 + package, and the EMC6D100, available in a 28-pin SSOP package, are designed 114 + to be register compatible. The EMC6D100 offers all the features of the 115 + EMC6D101 plus additional voltage monitoring and system control features. 116 + Unfortunately it is not possible to distinguish between the package 117 + versions on register level so these additional voltage inputs may read 118 + zero. The EMC6D102 features addtional ADC bits thus extending precision 119 + of voltage and temperature channels. 120 + 121 + 122 + Hardware Configurations 123 + ----------------------- 124 + 125 + The LM85 can be jumpered for 3 different SMBus addresses. There are 126 + no other hardware configuration options for the LM85. 127 + 128 + The lm85 driver detects both LM85B and LM85C revisions of the chip. See the 129 + datasheet for a complete description of the differences. Other than 130 + identifying the chip, the driver behaves no differently with regard to 131 + these two chips. The LM85B is recommended for new designs. 132 + 133 + The ADM1027 and ADT7463 chips have an optional SMBALERT output that can be 134 + used to signal the chipset in case a limit is exceeded or the temperature 135 + sensors fail. Individual sensor interrupts can be masked so they won't 136 + trigger SMBALERT. The SMBALERT output if configured replaces one of the other 137 + functions (PWM2 or IN0). This functionality is not implemented in current 138 + driver. 139 + 140 + The ADT7463 also has an optional THERM output/input which can be connected 141 + to the processor PROC_HOT output. If available, the autofan control 142 + dynamic Tmin feature can be enabled to keep the system temperature within 143 + spec (just?!) with the least possible fan noise. 144 + 145 + Configuration Notes 146 + ------------------- 147 + 148 + Besides standard interfaces driver adds following: 149 + 150 + * Temperatures and Zones 151 + 152 + Each temperature sensor is associated with a Zone. There are three 153 + sensors and therefore three zones (# 1, 2 and 3). Each zone has the following 154 + temperature configuration points: 155 + 156 + * temp#_auto_temp_off - temperature below which fans should be off or spinning very low. 157 + * temp#_auto_temp_min - temperature over which fans start to spin. 158 + * temp#_auto_temp_max - temperature when fans spin at full speed. 159 + * temp#_auto_temp_crit - temperature when all fans will run full speed. 160 + 161 + * PWM Control 162 + 163 + There are three PWM outputs. The LM85 datasheet suggests that the 164 + pwm3 output control both fan3 and fan4. Each PWM can be individually 165 + configured and assigned to a zone for it's control value. Each PWM can be 166 + configured individually according to the following options. 167 + 168 + * pwm#_auto_pwm_min - this specifies the PWM value for temp#_auto_temp_off 169 + temperature. (PWM value from 0 to 255) 170 + 171 + * pwm#_auto_pwm_freq - select base frequency of PWM output. You can select 172 + in range of 10.0 to 94.0 Hz in .1 Hz units. 173 + (Values 100 to 940). 174 + 175 + The pwm#_auto_pwm_freq can be set to one of the following 8 values. Setting the 176 + frequency to a value not on this list, will result in the next higher frequency 177 + being selected. The actual device frequency may vary slightly from this 178 + specification as designed by the manufacturer. Consult the datasheet for more 179 + details. (PWM Frequency values: 100, 150, 230, 300, 380, 470, 620, 940) 180 + 181 + * pwm#_auto_pwm_minctl - this flags selects for temp#_auto_temp_off temperature 182 + the bahaviour of fans. Write 1 to let fans spinning at 183 + pwm#_auto_pwm_min or write 0 to let them off. 184 + 185 + NOTE: It has been reported that there is a bug in the LM85 that causes the flag 186 + to be associated with the zones not the PWMs. This contradicts all the 187 + published documentation. Setting pwm#_min_ctl in this case actually affects all 188 + PWMs controlled by zone '#'. 189 + 190 + * PWM Controlling Zone selection 191 + 192 + * pwm#_auto_channels - controls zone that is associated with PWM 193 + 194 + Configuration choices: 195 + 196 + Value Meaning 197 + ------ ------------------------------------------------ 198 + 1 Controlled by Zone 1 199 + 2 Controlled by Zone 2 200 + 3 Controlled by Zone 3 201 + 23 Controlled by higher temp of Zone 2 or 3 202 + 123 Controlled by highest temp of Zone 1, 2 or 3 203 + 0 PWM always 0% (off) 204 + -1 PWM always 100% (full on) 205 + -2 Manual control (write to 'pwm#' to set) 206 + 207 + The National LM85's have two vendor specific configuration 208 + features. Tach. mode and Spinup Control. For more details on these, 209 + see the LM85 datasheet or Application Note AN-1260. 210 + 211 + The Analog Devices ADM1027 has several vendor specific enhancements. 212 + The number of pulses-per-rev of the fans can be set, Tach monitoring 213 + can be optimized for PWM operation, and an offset can be applied to 214 + the temperatures to compensate for systemic errors in the 215 + measurements. 216 + 217 + In addition to the ADM1027 features, the ADT7463 also has Tmin control 218 + and THERM asserted counts. Automatic Tmin control acts to adjust the 219 + Tmin value to maintain the measured temperature sensor at a specified 220 + temperature. There isn't much documentation on this feature in the 221 + ADT7463 data sheet. This is not supported by current driver.
+73
Documentation/i2c/chips/lm87
··· 1 + Kernel driver lm87 2 + ================== 3 + 4 + Supported chips: 5 + * National Semiconductor LM87 6 + Prefix: 'lm87' 7 + Addresses scanned: I2C 0x2c - 0x2f 8 + Datasheet: http://www.national.com/pf/LM/LM87.html 9 + 10 + Authors: 11 + Frodo Looijaard <frodol@dds.nl>, 12 + Philip Edelbrock <phil@netroedge.com>, 13 + Mark Studebaker <mdsxyz123@yahoo.com>, 14 + Stephen Rousset <stephen.rousset@rocketlogix.com>, 15 + Dan Eaton <dan.eaton@rocketlogix.com>, 16 + Jean Delvare <khali@linux-fr.org>, 17 + Original 2.6 port Jeff Oliver 18 + 19 + Description 20 + ----------- 21 + 22 + This driver implements support for the National Semiconductor LM87. 23 + 24 + The LM87 implements up to three temperature sensors, up to two fan 25 + rotation speed sensors, up to seven voltage sensors, alarms, and some 26 + miscellaneous stuff. 27 + 28 + Temperatures are measured in degrees Celsius. Each input has a high 29 + and low alarm settings. A high limit produces an alarm when the value 30 + goes above it, and an alarm is also produced when the value goes below 31 + the low limit. 32 + 33 + Fan rotation speeds are reported in RPM (rotations per minute). An alarm is 34 + triggered if the rotation speed has dropped below a programmable limit. Fan 35 + readings can be divided by a programmable divider (1, 2, 4 or 8) to give 36 + the readings more range or accuracy. Not all RPM values can accurately be 37 + represented, so some rounding is done. With a divider of 2, the lowest 38 + representable value is around 2600 RPM. 39 + 40 + Voltage sensors (also known as IN sensors) report their values in 41 + volts. An alarm is triggered if the voltage has crossed a programmable 42 + minimum or maximum limit. Note that minimum in this case always means 43 + 'closest to zero'; this is important for negative voltage measurements. 44 + 45 + If an alarm triggers, it will remain triggered until the hardware register 46 + is read at least once. This means that the cause for the alarm may 47 + already have disappeared! Note that in the current implementation, all 48 + hardware registers are read whenever any data is read (unless it is less 49 + than 1.0 seconds since the last update). This means that you can easily 50 + miss once-only alarms. 51 + 52 + The lm87 driver only updates its values each 1.0 seconds; reading it more 53 + often will do no harm, but will return 'old' values. 54 + 55 + 56 + Hardware Configurations 57 + ----------------------- 58 + 59 + The LM87 has four pins which can serve one of two possible functions, 60 + depending on the hardware configuration. 61 + 62 + Some functions share pins, so not all functions are available at the same 63 + time. Which are depends on the hardware setup. This driver assumes that 64 + the BIOS configured the chip correctly. In that respect, it differs from 65 + the original driver (from lm_sensors for Linux 2.4), which would force the 66 + LM87 to an arbitrary, compile-time chosen mode, regardless of the actual 67 + chipset wiring. 68 + 69 + For reference, here is the list of exclusive functions: 70 + - in0+in5 (default) or temp3 71 + - fan1 (default) or in6 72 + - fan2 (default) or in7 73 + - VID lines (default) or IRQ lines (not handled by this driver)
+121
Documentation/i2c/chips/lm90
··· 1 + Kernel driver lm90 2 + ================== 3 + 4 + Supported chips: 5 + * National Semiconductor LM90 6 + Prefix: 'lm90' 7 + Addresses scanned: I2C 0x4c 8 + Datasheet: Publicly available at the National Semiconductor website 9 + http://www.national.com/pf/LM/LM90.html 10 + * National Semiconductor LM89 11 + Prefix: 'lm99' 12 + Addresses scanned: I2C 0x4c and 0x4d 13 + Datasheet: Publicly available at the National Semiconductor website 14 + http://www.national.com/pf/LM/LM89.html 15 + * National Semiconductor LM99 16 + Prefix: 'lm99' 17 + Addresses scanned: I2C 0x4c and 0x4d 18 + Datasheet: Publicly available at the National Semiconductor website 19 + http://www.national.com/pf/LM/LM99.html 20 + * National Semiconductor LM86 21 + Prefix: 'lm86' 22 + Addresses scanned: I2C 0x4c 23 + Datasheet: Publicly available at the National Semiconductor website 24 + http://www.national.com/pf/LM/LM86.html 25 + * Analog Devices ADM1032 26 + Prefix: 'adm1032' 27 + Addresses scanned: I2C 0x4c 28 + Datasheet: Publicly available at the Analog Devices website 29 + http://products.analog.com/products/info.asp?product=ADM1032 30 + * Analog Devices ADT7461 31 + Prefix: 'adt7461' 32 + Addresses scanned: I2C 0x4c 33 + Datasheet: Publicly available at the Analog Devices website 34 + http://products.analog.com/products/info.asp?product=ADT7461 35 + Note: Only if in ADM1032 compatibility mode 36 + * Maxim MAX6657 37 + Prefix: 'max6657' 38 + Addresses scanned: I2C 0x4c 39 + Datasheet: Publicly available at the Maxim website 40 + http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 41 + * Maxim MAX6658 42 + Prefix: 'max6657' 43 + Addresses scanned: I2C 0x4c 44 + Datasheet: Publicly available at the Maxim website 45 + http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 46 + * Maxim MAX6659 47 + Prefix: 'max6657' 48 + Addresses scanned: I2C 0x4c, 0x4d (unsupported 0x4e) 49 + Datasheet: Publicly available at the Maxim website 50 + http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 51 + 52 + 53 + Author: Jean Delvare <khali@linux-fr.org> 54 + 55 + 56 + Description 57 + ----------- 58 + 59 + The LM90 is a digital temperature sensor. It senses its own temperature as 60 + well as the temperature of up to one external diode. It is compatible 61 + with many other devices such as the LM86, the LM89, the LM99, the ADM1032, 62 + the MAX6657, MAX6658 and the MAX6659 all of which are supported by this driver. 63 + Note that there is no easy way to differentiate between the last three 64 + variants. The extra address and features of the MAX6659 are not supported by 65 + this driver. Additionally, the ADT7461 is supported if found in ADM1032 66 + compatibility mode. 67 + 68 + The specificity of this family of chipsets over the ADM1021/LM84 69 + family is that it features critical limits with hysteresis, and an 70 + increased resolution of the remote temperature measurement. 71 + 72 + The different chipsets of the family are not strictly identical, although 73 + very similar. This driver doesn't handle any specific feature for now, 74 + but could if there ever was a need for it. For reference, here comes a 75 + non-exhaustive list of specific features: 76 + 77 + LM90: 78 + * Filter and alert configuration register at 0xBF. 79 + * ALERT is triggered by temperatures over critical limits. 80 + 81 + LM86 and LM89: 82 + * Same as LM90 83 + * Better external channel accuracy 84 + 85 + LM99: 86 + * Same as LM89 87 + * External temperature shifted by 16 degrees down 88 + 89 + ADM1032: 90 + * Consecutive alert register at 0x22. 91 + * Conversion averaging. 92 + * Up to 64 conversions/s. 93 + * ALERT is triggered by open remote sensor. 94 + 95 + ADT7461 96 + * Extended temperature range (breaks compatibility) 97 + * Lower resolution for remote temperature 98 + 99 + MAX6657 and MAX6658: 100 + * Remote sensor type selection 101 + 102 + MAX6659 103 + * Selectable address 104 + * Second critical temperature limit 105 + * Remote sensor type selection 106 + 107 + All temperature values are given in degrees Celsius. Resolution 108 + is 1.0 degree for the local temperature, 0.125 degree for the remote 109 + temperature. 110 + 111 + Each sensor has its own high and low limits, plus a critical limit. 112 + Additionally, there is a relative hysteresis value common to both critical 113 + values. To make life easier to user-space applications, two absolute values 114 + are exported, one for each channel, but these values are of course linked. 115 + Only the local hysteresis can be set from user-space, and the same delta 116 + applies to the remote hysteresis. 117 + 118 + The lm90 driver will not update its values more frequently than every 119 + other second; reading them more often will do no harm, but will return 120 + 'old' values. 121 +
+37
Documentation/i2c/chips/lm92
··· 1 + Kernel driver lm92 2 + ================== 3 + 4 + Supported chips: 5 + * National Semiconductor LM92 6 + Prefix: 'lm92' 7 + Addresses scanned: I2C 0x48 - 0x4b 8 + Datasheet: http://www.national.com/pf/LM/LM92.html 9 + * National Semiconductor LM76 10 + Prefix: 'lm92' 11 + Addresses scanned: none, force parameter needed 12 + Datasheet: http://www.national.com/pf/LM/LM76.html 13 + * Maxim MAX6633/MAX6634/MAX6635 14 + Prefix: 'lm92' 15 + Addresses scanned: I2C 0x48 - 0x4b 16 + MAX6633 with address in 0x40 - 0x47, 0x4c - 0x4f needs force parameter 17 + and MAX6634 with address in 0x4c - 0x4f needs force parameter 18 + Datasheet: http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3074 19 + 20 + Authors: 21 + Abraham van der Merwe <abraham@2d3d.co.za> 22 + Jean Delvare <khali@linux-fr.org> 23 + 24 + 25 + Description 26 + ----------- 27 + 28 + This driver implements support for the National Semiconductor LM92 29 + temperature sensor. 30 + 31 + Each LM92 temperature sensor supports a single temperature sensor. There are 32 + alarms for high, low, and critical thresholds. There's also an hysteresis to 33 + control the thresholds for resetting alarms. 34 + 35 + Support was added later for the LM76 and Maxim MAX6633/MAX6634/MAX6635, 36 + which are mostly compatible. They have not all been tested, so you 37 + may need to use the force parameter.
+29
Documentation/i2c/chips/max1619
··· 1 + Kernel driver max1619 2 + ===================== 3 + 4 + Supported chips: 5 + * Maxim MAX1619 6 + Prefix: 'max1619' 7 + Addresses scanned: I2C 0x18-0x1a, 0x29-0x2b, 0x4c-0x4e 8 + Datasheet: Publicly available at the Maxim website 9 + http://pdfserv.maxim-ic.com/en/ds/MAX1619.pdf 10 + 11 + Authors: 12 + Alexey Fisher <fishor@mail.ru>, 13 + Jean Delvare <khali@linux-fr.org> 14 + 15 + Description 16 + ----------- 17 + 18 + The MAX1619 is a digital temperature sensor. It senses its own temperature as 19 + well as the temperature of up to one external diode. 20 + 21 + All temperature values are given in degrees Celsius. Resolution 22 + is 1.0 degree for the local temperature and for the remote temperature. 23 + 24 + Only the external sensor has high and low limits. 25 + 26 + The max1619 driver will not update its values more frequently than every 27 + other second; reading them more often will do no harm, but will return 28 + 'old' values. 29 +
+54
Documentation/i2c/chips/max6875
··· 1 + Kernel driver max6875 2 + ===================== 3 + 4 + Supported chips: 5 + * Maxim max6874, max6875 6 + Prefixes: 'max6875' 7 + Addresses scanned: 0x50, 0x52 8 + Datasheets: 9 + http://pdfserv.maxim-ic.com/en/ds/MAX6874-MAX6875.pdf 10 + 11 + Author: Ben Gardner <bgardner@wabtec.com> 12 + 13 + 14 + Module Parameters 15 + ----------------- 16 + 17 + * allow_write int 18 + Set to non-zero to enable write permission: 19 + *0: Read only 20 + 1: Read and write 21 + 22 + 23 + Description 24 + ----------- 25 + 26 + The MAXIM max6875 is a EEPROM-programmable power-supply sequencer/supervisor. 27 + It provides timed outputs that can be used as a watchdog, if properly wired. 28 + It also provides 512 bytes of user EEPROM. 29 + 30 + At reset, the max6875 reads the configuration eeprom into its configuration 31 + registers. The chip then begins to operate according to the values in the 32 + registers. 33 + 34 + See the datasheet for details on how to program the EEPROM. 35 + 36 + 37 + Sysfs entries 38 + ------------- 39 + 40 + eeprom_user - 512 bytes of user-defined EEPROM space. Only writable if 41 + allow_write was set and register 0x43 is 0. 42 + 43 + eeprom_config - 70 bytes of config EEPROM. Note that changes will not get 44 + loaded into register space until a power cycle or device reset. 45 + 46 + reg_config - 70 bytes of register space. Any changes take affect immediately. 47 + 48 + 49 + General Remarks 50 + --------------- 51 + 52 + A typical application will require that the EEPROMs be programmed once and 53 + never altered afterwards. 54 +
+189
Documentation/i2c/chips/pc87360
··· 1 + Kernel driver pc87360 2 + ===================== 3 + 4 + Supported chips: 5 + * National Semiconductor PC87360, PC87363, PC87364, PC87365 and PC87366 6 + Prefixes: 'pc87360', 'pc87363', 'pc87364', 'pc87365', 'pc87366' 7 + Addresses scanned: none, address read from Super I/O config space 8 + Datasheets: 9 + http://www.national.com/pf/PC/PC87360.html 10 + http://www.national.com/pf/PC/PC87363.html 11 + http://www.national.com/pf/PC/PC87364.html 12 + http://www.national.com/pf/PC/PC87365.html 13 + http://www.national.com/pf/PC/PC87366.html 14 + 15 + Authors: Jean Delvare <khali@linux-fr.org> 16 + 17 + Thanks to Sandeep Mehta, Tonko de Rooy and Daniel Ceregatti for testing. 18 + Thanks to Rudolf Marek for helping me investigate conversion issues. 19 + 20 + 21 + Module Parameters 22 + ----------------- 23 + 24 + * init int 25 + Chip initialization level: 26 + 0: None 27 + *1: Forcibly enable internal voltage and temperature channels, except in9 28 + 2: Forcibly enable all voltage and temperature channels, except in9 29 + 3: Forcibly enable all voltage and temperature channels, including in9 30 + 31 + Note that this parameter has no effect for the PC87360, PC87363 and PC87364 32 + chips. 33 + 34 + Also note that for the PC87366, initialization levels 2 and 3 don't enable 35 + all temperature channels, because some of them share pins with each other, 36 + so they can't be used at the same time. 37 + 38 + 39 + Description 40 + ----------- 41 + 42 + The National Semiconductor PC87360 Super I/O chip contains monitoring and 43 + PWM control circuitry for two fans. The PC87363 chip is similar, and the 44 + PC87364 chip has monitoring and PWM control for a third fan. 45 + 46 + The National Semiconductor PC87365 and PC87366 Super I/O chips are complete 47 + hardware monitoring chipsets, not only controlling and monitoring three fans, 48 + but also monitoring eleven voltage inputs and two (PC87365) or up to four 49 + (PC87366) temperatures. 50 + 51 + Chip #vin #fan #pwm #temp devid 52 + 53 + PC87360 - 2 2 - 0xE1 54 + PC87363 - 2 2 - 0xE8 55 + PC87364 - 3 3 - 0xE4 56 + PC87365 11 3 3 2 0xE5 57 + PC87366 11 3 3 3-4 0xE9 58 + 59 + The driver assumes that no more than one chip is present, and one of the 60 + standard Super I/O addresses is used (0x2E/0x2F or 0x4E/0x4F) 61 + 62 + Fan Monitoring 63 + -------------- 64 + 65 + Fan rotation speeds are reported in RPM (revolutions per minute). An alarm 66 + is triggered if the rotation speed has dropped below a programmable limit. 67 + A different alarm is triggered if the fan speed is too low to be measured. 68 + 69 + Fan readings are affected by a programmable clock divider, giving the 70 + readings more range or accuracy. Usually, users have to learn how it works, 71 + but this driver implements dynamic clock divider selection, so you don't 72 + have to care no more. 73 + 74 + For reference, here are a few values about clock dividers: 75 + 76 + slowest accuracy highest 77 + measurable around 3000 accurate 78 + divider speed (RPM) RPM (RPM) speed (RPM) 79 + 1 1882 18 6928 80 + 2 941 37 4898 81 + 4 470 74 3464 82 + 8 235 150 2449 83 + 84 + For the curious, here is how the values above were computed: 85 + * slowest measurable speed: clock/(255*divider) 86 + * accuracy around 3000 RPM: 3000^2/clock 87 + * highest accurate speed: sqrt(clock*100) 88 + The clock speed for the PC87360 family is 480 kHz. I arbitrarily chose 100 89 + RPM as the lowest acceptable accuracy. 90 + 91 + As mentioned above, you don't have to care about this no more. 92 + 93 + Note that not all RPM values can be represented, even when the best clock 94 + divider is selected. This is not only true for the measured speeds, but 95 + also for the programmable low limits, so don't be surprised if you try to 96 + set, say, fan1_min to 2900 and it finally reads 2909. 97 + 98 + 99 + Fan Control 100 + ----------- 101 + 102 + PWM (pulse width modulation) values range from 0 to 255, with 0 meaning 103 + that the fan is stopped, and 255 meaning that the fan goes at full speed. 104 + 105 + Be extremely careful when changing PWM values. Low PWM values, even 106 + non-zero, can stop the fan, which may cause irreversible damage to your 107 + hardware if temperature increases too much. When changing PWM values, go 108 + step by step and keep an eye on temperatures. 109 + 110 + One user reported problems with PWM. Changing PWM values would break fan 111 + speed readings. No explanation nor fix could be found. 112 + 113 + 114 + Temperature Monitoring 115 + ---------------------- 116 + 117 + Temperatures are reported in degrees Celsius. Each temperature measured has 118 + associated low, high and overtemperature limits, each of which triggers an 119 + alarm when crossed. 120 + 121 + The first two temperature channels are external. The third one (PC87366 122 + only) is internal. 123 + 124 + The PC87366 has three additional temperature channels, based on 125 + thermistors (as opposed to thermal diodes for the first three temperature 126 + channels). For technical reasons, these channels are held by the VLM 127 + (voltage level monitor) logical device, not the TMS (temperature 128 + measurement) one. As a consequence, these temperatures are exported as 129 + voltages, and converted into temperatures in user-space. 130 + 131 + Note that these three additional channels share their pins with the 132 + external thermal diode channels, so you (physically) can't use them all at 133 + the same time. Although it should be possible to mix the two sensor types, 134 + the documents from National Semiconductor suggest that motherboard 135 + manufacturers should choose one type and stick to it. So you will more 136 + likely have either channels 1 to 3 (thermal diodes) or 3 to 6 (internal 137 + thermal diode, and thermistors). 138 + 139 + 140 + Voltage Monitoring 141 + ------------------ 142 + 143 + Voltages are reported relatively to a reference voltage, either internal or 144 + external. Some of them (in7:Vsb, in8:Vdd and in10:AVdd) are divided by two 145 + internally, you will have to compensate in sensors.conf. Others (in0 to in6) 146 + are likely to be divided externally. The meaning of each of these inputs as 147 + well as the values of the resistors used for division is left to the 148 + motherboard manufacturers, so you will have to document yourself and edit 149 + sensors.conf accordingly. National Semiconductor has a document with 150 + recommended resistor values for some voltages, but this still leaves much 151 + room for per motherboard specificities, unfortunately. Even worse, 152 + motherboard manufacturers don't seem to care about National Semiconductor's 153 + recommendations. 154 + 155 + Each voltage measured has associated low and high limits, each of which 156 + triggers an alarm when crossed. 157 + 158 + When available, VID inputs are used to provide the nominal CPU Core voltage. 159 + The driver will default to VRM 9.0, but this can be changed from user-space. 160 + The chipsets can handle two sets of VID inputs (on dual-CPU systems), but 161 + the driver will only export one for now. This may change later if there is 162 + a need. 163 + 164 + 165 + General Remarks 166 + --------------- 167 + 168 + If an alarm triggers, it will remain triggered until the hardware register 169 + is read at least once. This means that the cause for the alarm may already 170 + have disappeared! Note that all hardware registers are read whenever any 171 + data is read (unless it is less than 2 seconds since the last update, in 172 + which case cached values are returned instead). As a consequence, when 173 + a once-only alarm triggers, it may take 2 seconds for it to show, and 2 174 + more seconds for it to disappear. 175 + 176 + Monitoring of in9 isn't enabled at lower init levels (<3) because that 177 + channel measures the battery voltage (Vbat). It is a known fact that 178 + repeatedly sampling the battery voltage reduces its lifetime. National 179 + Semiconductor smartly designed their chipset so that in9 is sampled only 180 + once every 1024 sampling cycles (that is every 34 minutes at the default 181 + sampling rate), so the effect is attenuated, but still present. 182 + 183 + 184 + Limitations 185 + ----------- 186 + 187 + The datasheets suggests that some values (fan mins, fan dividers) 188 + shouldn't be changed once the monitoring has started, but we ignore that 189 + recommendation. We'll reconsider if it actually causes trouble.
+47
Documentation/i2c/chips/pca9539
··· 1 + Kernel driver pca9539 2 + ===================== 3 + 4 + Supported chips: 5 + * Philips PCA9539 6 + Prefix: 'pca9539' 7 + Addresses scanned: 0x74 - 0x77 8 + Datasheet: 9 + http://www.semiconductors.philips.com/acrobat/datasheets/PCA9539_2.pdf 10 + 11 + Author: Ben Gardner <bgardner@wabtec.com> 12 + 13 + 14 + Description 15 + ----------- 16 + 17 + The Philips PCA9539 is a 16 bit low power I/O device. 18 + All 16 lines can be individually configured as an input or output. 19 + The input sense can also be inverted. 20 + The 16 lines are split between two bytes. 21 + 22 + 23 + Sysfs entries 24 + ------------- 25 + 26 + Each is a byte that maps to the 8 I/O bits. 27 + A '0' suffix is for bits 0-7, while '1' is for bits 8-15. 28 + 29 + input[01] - read the current value 30 + output[01] - sets the output value 31 + direction[01] - direction of each bit: 1=input, 0=output 32 + invert[01] - toggle the input bit sense 33 + 34 + input reads the actual state of the line and is always available. 35 + The direction defaults to input for all channels. 36 + 37 + 38 + General Remarks 39 + --------------- 40 + 41 + Note that each output, direction, and invert entry controls 8 lines. 42 + You should use the read, modify, write sequence. 43 + For example. to set output bit 0 of 1. 44 + val=$(cat output0) 45 + val=$(( $val | 1 )) 46 + echo $val > output0 47 +
+69
Documentation/i2c/chips/pcf8574
··· 1 + Kernel driver pcf8574 2 + ===================== 3 + 4 + Supported chips: 5 + * Philips PCF8574 6 + Prefix: 'pcf8574' 7 + Addresses scanned: I2C 0x20 - 0x27 8 + Datasheet: Publicly available at the Philips Semiconductors website 9 + http://www.semiconductors.philips.com/pip/PCF8574P.html 10 + 11 + * Philips PCF8574A 12 + Prefix: 'pcf8574a' 13 + Addresses scanned: I2C 0x38 - 0x3f 14 + Datasheet: Publicly available at the Philips Semiconductors website 15 + http://www.semiconductors.philips.com/pip/PCF8574P.html 16 + 17 + Authors: 18 + Frodo Looijaard <frodol@dds.nl>, 19 + Philip Edelbrock <phil@netroedge.com>, 20 + Dan Eaton <dan.eaton@rocketlogix.com>, 21 + Aurelien Jarno <aurelien@aurel32.net>, 22 + Jean Delvare <khali@linux-fr.org>, 23 + 24 + 25 + Description 26 + ----------- 27 + The PCF8574(A) is an 8-bit I/O expander for the I2C bus produced by Philips 28 + Semiconductors. It is designed to provide a byte I2C interface to up to 16 29 + separate devices (8 x PCF8574 and 8 x PCF8574A). 30 + 31 + This device consists of a quasi-bidirectional port. Each of the eight I/Os 32 + can be independently used as an input or output. To setup an I/O as an 33 + input, you have to write a 1 to the corresponding output. 34 + 35 + For more informations see the datasheet. 36 + 37 + 38 + Accessing PCF8574(A) via /sys interface 39 + ------------------------------------- 40 + 41 + ! Be careful ! 42 + The PCF8574(A) is plainly impossible to detect ! Stupid chip. 43 + So every chip with address in the interval [20..27] and [38..3f] are 44 + detected as PCF8574(A). If you have other chips in this address 45 + range, the workaround is to load this module after the one 46 + for your others chips. 47 + 48 + On detection (i.e. insmod, modprobe et al.), directories are being 49 + created for each detected PCF8574(A): 50 + 51 + /sys/bus/i2c/devices/<0>-<1>/ 52 + where <0> is the bus the chip was detected on (e. g. i2c-0) 53 + and <1> the chip address ([20..27] or [38..3f]): 54 + 55 + (example: /sys/bus/i2c/devices/1-0020/) 56 + 57 + Inside these directories, there are two files each: 58 + read and write (and one file with chip name). 59 + 60 + The read file is read-only. Reading gives you the current I/O input 61 + if the corresponding output is set as 1, otherwise the current output 62 + value, that is to say 0. 63 + 64 + The write file is read/write. Writing a value outputs it on the I/O 65 + port. Reading returns the last written value. 66 + 67 + On module initialization the chip is configured as eight inputs (all 68 + outputs to 1), so you can connect any circuit to the PCF8574(A) without 69 + being afraid of short-circuit.
+90
Documentation/i2c/chips/pcf8591
··· 1 + Kernel driver pcf8591 2 + ===================== 3 + 4 + Supported chips: 5 + * Philips PCF8591 6 + Prefix: 'pcf8591' 7 + Addresses scanned: I2C 0x48 - 0x4f 8 + Datasheet: Publicly available at the Philips Semiconductor website 9 + http://www.semiconductors.philips.com/pip/PCF8591P.html 10 + 11 + Authors: 12 + Aurelien Jarno <aurelien@aurel32.net> 13 + valuable contributions by Jan M. Sendler <sendler@sendler.de>, 14 + Jean Delvare <khali@linux-fr.org> 15 + 16 + 17 + Description 18 + ----------- 19 + The PCF8591 is an 8-bit A/D and D/A converter (4 analog inputs and one 20 + analog output) for the I2C bus produced by Philips Semiconductors. It 21 + is designed to provide a byte I2C interface to up to 4 separate devices. 22 + 23 + The PCF8591 has 4 analog inputs programmable as single-ended or 24 + differential inputs : 25 + - mode 0 : four single ended inputs 26 + Pins AIN0 to AIN3 are single ended inputs for channels 0 to 3 27 + 28 + - mode 1 : three differential inputs 29 + Pins AIN3 is the common negative differential input 30 + Pins AIN0 to AIN2 are positive differential inputs for channels 0 to 2 31 + 32 + - mode 2 : single ended and differential mixed 33 + Pins AIN0 and AIN1 are single ended inputs for channels 0 and 1 34 + Pins AIN2 is the positive differential input for channel 3 35 + Pins AIN3 is the negative differential input for channel 3 36 + 37 + - mode 3 : two differential inputs 38 + Pins AIN0 is the positive differential input for channel 0 39 + Pins AIN1 is the negative differential input for channel 0 40 + Pins AIN2 is the positive differential input for channel 1 41 + Pins AIN3 is the negative differential input for channel 1 42 + 43 + See the datasheet for details. 44 + 45 + Module parameters 46 + ----------------- 47 + 48 + * input_mode int 49 + 50 + Analog input mode: 51 + 0 = four single ended inputs 52 + 1 = three differential inputs 53 + 2 = single ended and differential mixed 54 + 3 = two differential inputs 55 + 56 + 57 + Accessing PCF8591 via /sys interface 58 + ------------------------------------- 59 + 60 + ! Be careful ! 61 + The PCF8591 is plainly impossible to detect ! Stupid chip. 62 + So every chip with address in the interval [48..4f] is 63 + detected as PCF8591. If you have other chips in this address 64 + range, the workaround is to load this module after the one 65 + for your others chips. 66 + 67 + On detection (i.e. insmod, modprobe et al.), directories are being 68 + created for each detected PCF8591: 69 + 70 + /sys/bus/devices/<0>-<1>/ 71 + where <0> is the bus the chip was detected on (e. g. i2c-0) 72 + and <1> the chip address ([48..4f]) 73 + 74 + Inside these directories, there are such files: 75 + in0, in1, in2, in3, out0_enable, out0_output, name 76 + 77 + Name contains chip name. 78 + 79 + The in0, in1, in2 and in3 files are RO. Reading gives the value of the 80 + corresponding channel. Depending on the current analog inputs configuration, 81 + files in2 and/or in3 do not exist. Values range are from 0 to 255 for single 82 + ended inputs and -128 to +127 for differential inputs (8-bit ADC). 83 + 84 + The out0_enable file is RW. Reading gives "1" for analog output enabled and 85 + "0" for analog output disabled. Writing accepts "0" and "1" accordingly. 86 + 87 + The out0_output file is RW. Writing a number between 0 and 255 (8-bit DAC), send 88 + the value to the digital-to-analog converter. Note that a voltage will 89 + only appears on AOUT pin if aout0_enable equals 1. Reading returns the last 90 + value written.
+106
Documentation/i2c/chips/sis5595
··· 1 + Kernel driver sis5595 2 + ===================== 3 + 4 + Supported chips: 5 + * Silicon Integrated Systems Corp. SiS5595 Southbridge Hardware Monitor 6 + Prefix: 'sis5595' 7 + Addresses scanned: ISA in PCI-space encoded address 8 + Datasheet: Publicly available at the Silicon Integrated Systems Corp. site. 9 + 10 + Authors: 11 + Ky�sti M�lkki <kmalkki@cc.hut.fi>, 12 + Mark D. Studebaker <mdsxyz123@yahoo.com>, 13 + Aurelien Jarno <aurelien@aurel32.net> 2.6 port 14 + 15 + SiS southbridge has a LM78-like chip integrated on the same IC. 16 + This driver is a customized copy of lm78.c 17 + 18 + Supports following revisions: 19 + Version PCI ID PCI Revision 20 + 1 1039/0008 AF or less 21 + 2 1039/0008 B0 or greater 22 + 23 + Note: these chips contain a 0008 device which is incompatible with the 24 + 5595. We recognize these by the presence of the listed 25 + "blacklist" PCI ID and refuse to load. 26 + 27 + NOT SUPPORTED PCI ID BLACKLIST PCI ID 28 + 540 0008 0540 29 + 550 0008 0550 30 + 5513 0008 5511 31 + 5581 0008 5597 32 + 5582 0008 5597 33 + 5597 0008 5597 34 + 630 0008 0630 35 + 645 0008 0645 36 + 730 0008 0730 37 + 735 0008 0735 38 + 39 + 40 + Module Parameters 41 + ----------------- 42 + force_addr=0xaddr Set the I/O base address. Useful for boards 43 + that don't set the address in the BIOS. Does not do a 44 + PCI force; the device must still be present in lspci. 45 + Don't use this unless the driver complains that the 46 + base address is not set. 47 + Example: 'modprobe sis5595 force_addr=0x290' 48 + 49 + 50 + Description 51 + ----------- 52 + 53 + The SiS5595 southbridge has integrated hardware monitor functions. It also 54 + has an I2C bus, but this driver only supports the hardware monitor. For the 55 + I2C bus driver see i2c-sis5595. 56 + 57 + The SiS5595 implements zero or one temperature sensor, two fan speed 58 + sensors, four or five voltage sensors, and alarms. 59 + 60 + On the first version of the chip, there are four voltage sensors and one 61 + temperature sensor. 62 + 63 + On the second version of the chip, the temperature sensor (temp) and the 64 + fifth voltage sensor (in4) share a pin which is configurable, but not 65 + through the driver. Sorry. The driver senses the configuration of the pin, 66 + which was hopefully set by the BIOS. 67 + 68 + Temperatures are measured in degrees Celsius. An alarm is triggered once 69 + when the max is crossed; it is also triggered when it drops below the min 70 + value. Measurements are guaranteed between -55 and +125 degrees, with a 71 + resolution of 1 degree. 72 + 73 + Fan rotation speeds are reported in RPM (rotations per minute). An alarm is 74 + triggered if the rotation speed has dropped below a programmable limit. Fan 75 + readings can be divided by a programmable divider (1, 2, 4 or 8) to give 76 + the readings more range or accuracy. Not all RPM values can accurately be 77 + represented, so some rounding is done. With a divider of 2, the lowest 78 + representable value is around 2600 RPM. 79 + 80 + Voltage sensors (also known as IN sensors) report their values in volts. An 81 + alarm is triggered if the voltage has crossed a programmable minimum or 82 + maximum limit. Note that minimum in this case always means 'closest to 83 + zero'; this is important for negative voltage measurements. All voltage 84 + inputs can measure voltages between 0 and 4.08 volts, with a resolution of 85 + 0.016 volt. 86 + 87 + In addition to the alarms described above, there is a BTI alarm, which gets 88 + triggered when an external chip has crossed its limits. Usually, this is 89 + connected to some LM75-like chip; if at least one crosses its limits, this 90 + bit gets set. 91 + 92 + If an alarm triggers, it will remain triggered until the hardware register 93 + is read at least once. This means that the cause for the alarm may already 94 + have disappeared! Note that in the current implementation, all hardware 95 + registers are read whenever any data is read (unless it is less than 1.5 96 + seconds since the last update). This means that you can easily miss 97 + once-only alarms. 98 + 99 + The SiS5595 only updates its values each 1.5 seconds; reading it more often 100 + will do no harm, but will return 'old' values. 101 + 102 + Problems 103 + -------- 104 + Some chips refuse to be enabled. We don't know why. 105 + The driver will recognize this and print a message in dmesg. 106 +
+29 -17
Documentation/i2c/chips/smsc47b397.txt Documentation/i2c/chips/smsc47b397
··· 1 + Kernel driver smsc47b397 2 + ======================== 3 + 4 + Supported chips: 5 + * SMSC LPC47B397-NC 6 + Prefix: 'smsc47b397' 7 + Addresses scanned: none, address read from Super I/O config space 8 + Datasheet: In this file 9 + 10 + Authors: Mark M. Hoffman <mhoffman@lightlink.com> 11 + Utilitek Systems, Inc. 12 + 1 13 November 23, 2004 2 14 3 15 The following specification describes the SMSC LPC47B397-NC sensor chip 4 - (for which there is no public datasheet available). This document was 16 + (for which there is no public datasheet available). This document was 5 17 provided by Craig Kelly (In-Store Broadcast Network) and edited/corrected 6 18 by Mark M. Hoffman <mhoffman@lightlink.com>. 7 19 ··· 22 10 Methods for detecting the HP SIO and reading the thermal data on a dc7100. 23 11 24 12 The thermal information on the dc7100 is contained in the SIO Hardware Monitor 25 - (HWM). The information is accessed through an index/data pair. The index/data 26 - pair is located at the HWM Base Address + 0 and the HWM Base Address + 1. The 13 + (HWM). The information is accessed through an index/data pair. The index/data 14 + pair is located at the HWM Base Address + 0 and the HWM Base Address + 1. The 27 15 HWM Base address can be obtained from Logical Device 8, registers 0x60 (MSB) 28 - and 0x61 (LSB). Currently we are using 0x480 for the HWM Base Address and 16 + and 0x61 (LSB). Currently we are using 0x480 for the HWM Base Address and 29 17 0x480 and 0x481 for the index/data pair. 30 18 31 19 Reading temperature information. ··· 62 50 The LSB Must be read first. 63 51 64 52 How to convert the tach reading to RPM. 65 - The tach reading (TCount) is given by: (Tach MSB * 256) + (Tach LSB) 53 + The tach reading (TCount) is given by: (Tach MSB * 256) + (Tach LSB) 66 54 The SIO counts the number of 90kHz (11.111us) pulses per revolution. 67 55 RPM = 60/(TCount * 11.111us) 68 56 ··· 84 72 85 73 Enter Configuration Mode 86 74 To place the chip into the Configuration State The config key (0x55) is written 87 - to the CONFIG PORT (0x2E). 75 + to the CONFIG PORT (0x2E). 88 76 89 77 Configuration Mode 90 78 In configuration mode, the INDEX PORT is located at the CONFIG PORT address and 91 79 the DATA PORT is at INDEX PORT address + 1. 92 80 93 - The desired configuration registers are accessed in two steps: 81 + The desired configuration registers are accessed in two steps: 94 82 a. Write the index of the Logical Device Number Configuration Register 95 83 (i.e., 0x07) to the INDEX PORT and then write the number of the 96 84 desired logical device to the DATA PORT. 97 85 98 86 b. Write the address of the desired configuration register within the 99 87 logical device to the INDEX PORT and then write or read the config- 100 - uration register through the DATA PORT. 88 + uration register through the DATA PORT. 101 89 102 90 Note: If accessing the Global Configuration Registers, step (a) is not required. 103 91 ··· 108 96 Programming Example 109 97 The following is an example of how to read the SIO Device ID located at 0x20 110 98 111 - ; ENTER CONFIGURATION MODE 99 + ; ENTER CONFIGURATION MODE 112 100 MOV DX,02EH 113 101 MOV AX,055H 114 102 OUT DX,AL 115 - ; GLOBAL CONFIGURATION REGISTER 103 + ; GLOBAL CONFIGURATION REGISTER 116 104 MOV DX,02EH 117 105 MOV AL,20H 118 - OUT DX,AL 106 + OUT DX,AL 119 107 ; READ THE DATA 120 108 MOV DX,02FH 121 109 IN AL,DX 122 - ; EXIT CONFIGURATION MODE 110 + ; EXIT CONFIGURATION MODE 123 111 MOV DX,02EH 124 112 MOV AX,0AAH 125 113 OUT DX,AL ··· 134 122 The following is an example of how to read the HWM Base Address located in 135 123 Logical Device 8. 136 124 137 - ; ENTER CONFIGURATION MODE 125 + ; ENTER CONFIGURATION MODE 138 126 MOV DX,02EH 139 127 MOV AX,055H 140 128 OUT DX,AL 141 - ; CONFIGURE REGISTER CRE0, 142 - ; LOGICAL DEVICE 8 129 + ; CONFIGURE REGISTER CRE0, 130 + ; LOGICAL DEVICE 8 143 131 MOV DX,02EH 144 132 MOV AL,07H 145 133 OUT DX,AL ;Point to LD# Config Reg ··· 147 135 MOV AL, 08H 148 136 OUT DX,AL;Point to Logical Device 8 149 137 ; 150 - MOV DX,02EH 138 + MOV DX,02EH 151 139 MOV AL,60H 152 140 OUT DX,AL ; Point to HWM Base Addr MSB 153 141 MOV DX,02FH 154 142 IN AL,DX ; Get MSB of HWM Base Addr 155 - ; EXIT CONFIGURATION MODE 143 + ; EXIT CONFIGURATION MODE 156 144 MOV DX,02EH 157 145 MOV AX,0AAH 158 146 OUT DX,AL
+52
Documentation/i2c/chips/smsc47m1
··· 1 + Kernel driver smsc47m1 2 + ====================== 3 + 4 + Supported chips: 5 + * SMSC LPC47B27x, LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x and LPC47M192 6 + Addresses scanned: none, address read from Super I/O config space 7 + Prefix: 'smsc47m1' 8 + Datasheets: 9 + http://www.smsc.com/main/datasheets/47b27x.pdf 10 + http://www.smsc.com/main/datasheets/47m10x.pdf 11 + http://www.smsc.com/main/tools/discontinued/47m13x.pdf 12 + http://www.smsc.com/main/datasheets/47m14x.pdf 13 + http://www.smsc.com/main/tools/discontinued/47m15x.pdf 14 + http://www.smsc.com/main/datasheets/47m192.pdf 15 + 16 + Authors: 17 + Mark D. Studebaker <mdsxyz123@yahoo.com>, 18 + With assistance from Bruce Allen <ballen@uwm.edu>, and his 19 + fan.c program: http://www.lsc-group.phys.uwm.edu/%7Eballen/driver/ 20 + Gabriele Gorla <gorlik@yahoo.com>, 21 + Jean Delvare <khali@linux-fr.org> 22 + 23 + Description 24 + ----------- 25 + 26 + The Standard Microsystems Corporation (SMSC) 47M1xx Super I/O chips 27 + contain monitoring and PWM control circuitry for two fans. 28 + 29 + The 47M15x and 47M192 chips contain a full 'hardware monitoring block' 30 + in addition to the fan monitoring and control. The hardware monitoring 31 + block is not supported by the driver. 32 + 33 + Fan rotation speeds are reported in RPM (rotations per minute). An alarm is 34 + triggered if the rotation speed has dropped below a programmable limit. Fan 35 + readings can be divided by a programmable divider (1, 2, 4 or 8) to give 36 + the readings more range or accuracy. Not all RPM values can accurately be 37 + represented, so some rounding is done. With a divider of 2, the lowest 38 + representable value is around 2600 RPM. 39 + 40 + PWM values are from 0 to 255. 41 + 42 + If an alarm triggers, it will remain triggered until the hardware register 43 + is read at least once. This means that the cause for the alarm may 44 + already have disappeared! Note that in the current implementation, all 45 + hardware registers are read whenever any data is read (unless it is less 46 + than 1.5 seconds since the last update). This means that you can easily 47 + miss once-only alarms. 48 + 49 + 50 + ********************** 51 + The lm_sensors project gratefully acknowledges the support of 52 + Intel in the development of this driver.
+65
Documentation/i2c/chips/via686a
··· 1 + Kernel driver via686a 2 + ===================== 3 + 4 + Supported chips: 5 + * Via VT82C686A, VT82C686B Southbridge Integrated Hardware Monitor 6 + Prefix: 'via686a' 7 + Addresses scanned: ISA in PCI-space encoded address 8 + Datasheet: On request through web form (http://www.via.com.tw/en/support/datasheets/) 9 + 10 + Authors: 11 + Ky�sti M�lkki <kmalkki@cc.hut.fi>, 12 + Mark D. Studebaker <mdsxyz123@yahoo.com> 13 + Bob Dougherty <bobd@stanford.edu> 14 + (Some conversion-factor data were contributed by 15 + Jonathan Teh Soon Yew <j.teh@iname.com> 16 + and Alex van Kaam <darkside@chello.nl>.) 17 + 18 + Module Parameters 19 + ----------------- 20 + 21 + force_addr=0xaddr Set the I/O base address. Useful for Asus A7V boards 22 + that don't set the address in the BIOS. Does not do a 23 + PCI force; the via686a must still be present in lspci. 24 + Don't use this unless the driver complains that the 25 + base address is not set. 26 + Example: 'modprobe via686a force_addr=0x6000' 27 + 28 + Description 29 + ----------- 30 + 31 + The driver does not distinguish between the chips and reports 32 + all as a 686A. 33 + 34 + The Via 686a southbridge has integrated hardware monitor functionality. 35 + It also has an I2C bus, but this driver only supports the hardware monitor. 36 + For the I2C bus driver, see <file:Documentation/i2c/busses/i2c-viapro> 37 + 38 + The Via 686a implements three temperature sensors, two fan rotation speed 39 + sensors, five voltage sensors and alarms. 40 + 41 + Temperatures are measured in degrees Celsius. An alarm is triggered once 42 + when the Overtemperature Shutdown limit is crossed; it is triggered again 43 + as soon as it drops below the hysteresis value. 44 + 45 + Fan rotation speeds are reported in RPM (rotations per minute). An alarm is 46 + triggered if the rotation speed has dropped below a programmable limit. Fan 47 + readings can be divided by a programmable divider (1, 2, 4 or 8) to give 48 + the readings more range or accuracy. Not all RPM values can accurately be 49 + represented, so some rounding is done. With a divider of 2, the lowest 50 + representable value is around 2600 RPM. 51 + 52 + Voltage sensors (also known as IN sensors) report their values in volts. 53 + An alarm is triggered if the voltage has crossed a programmable minimum 54 + or maximum limit. Voltages are internally scalled, so each voltage channel 55 + has a different resolution and range. 56 + 57 + If an alarm triggers, it will remain triggered until the hardware register 58 + is read at least once. This means that the cause for the alarm may 59 + already have disappeared! Note that in the current implementation, all 60 + hardware registers are read whenever any data is read (unless it is less 61 + than 1.5 seconds since the last update). This means that you can easily 62 + miss once-only alarms. 63 + 64 + The driver only updates its values each 1.5 seconds; reading it more often 65 + will do no harm, but will return 'old' values.
+66
Documentation/i2c/chips/w83627hf
··· 1 + Kernel driver w83627hf 2 + ====================== 3 + 4 + Supported chips: 5 + * Winbond W83627HF (ISA accesses ONLY) 6 + Prefix: 'w83627hf' 7 + Addresses scanned: ISA address retrieved from Super I/O registers 8 + Datasheet: http://www.winbond.com/PDF/sheet/w83627hf.pdf 9 + * Winbond W83627THF 10 + Prefix: 'w83627thf' 11 + Addresses scanned: ISA address retrieved from Super I/O registers 12 + Datasheet: http://www.winbond.com/PDF/sheet/w83627thf.pdf 13 + * Winbond W83697HF 14 + Prefix: 'w83697hf' 15 + Addresses scanned: ISA address retrieved from Super I/O registers 16 + Datasheet: http://www.winbond.com/PDF/sheet/697hf.pdf 17 + * Winbond W83637HF 18 + Prefix: 'w83637hf' 19 + Addresses scanned: ISA address retrieved from Super I/O registers 20 + Datasheet: http://www.winbond.com/PDF/sheet/w83637hf.pdf 21 + 22 + Authors: 23 + Frodo Looijaard <frodol@dds.nl>, 24 + Philip Edelbrock <phil@netroedge.com>, 25 + Mark Studebaker <mdsxyz123@yahoo.com>, 26 + Bernhard C. Schrenk <clemy@clemy.org> 27 + 28 + Module Parameters 29 + ----------------- 30 + 31 + * force_addr: int 32 + Initialize the ISA address of the sensors 33 + * force_i2c: int 34 + Initialize the I2C address of the sensors 35 + * init: int 36 + (default is 1) 37 + Use 'init=0' to bypass initializing the chip. 38 + Try this if your computer crashes when you load the module. 39 + 40 + Description 41 + ----------- 42 + 43 + This driver implements support for ISA accesses *only* for 44 + the Winbond W83627HF, W83627THF, W83697HF and W83637HF Super I/O chips. 45 + We will refer to them collectively as Winbond chips. 46 + 47 + This driver supports ISA accesses, which should be more reliable 48 + than i2c accesses. Also, for Tyan boards which contain both a 49 + Super I/O chip and a second i2c-only Winbond chip (often a W83782D), 50 + using this driver will avoid i2c address conflicts and complex 51 + initialization that were required in the w83781d driver. 52 + 53 + If you really want i2c accesses for these Super I/O chips, 54 + use the w83781d driver. However this is not the preferred method 55 + now that this ISA driver has been developed. 56 + 57 + Technically, the w83627thf does not support a VID reading. However, it's 58 + possible or even likely that your mainboard maker has routed these signals 59 + to a specific set of general purpose IO pins (the Asus P4C800-E is one such 60 + board). The w83627thf driver now interprets these as VID. If the VID on 61 + your board doesn't work, first see doc/vid in the lm_sensors package. If 62 + that still doesn't help, email us at lm-sensors@lm-sensors.org. 63 + 64 + For further information on this driver see the w83781d driver 65 + documentation. 66 +
+402
Documentation/i2c/chips/w83781d
··· 1 + Kernel driver w83781d 2 + ===================== 3 + 4 + Supported chips: 5 + * Winbond W83781D 6 + Prefix: 'w83781d' 7 + Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) 8 + Datasheet: http://www.winbond-usa.com/products/winbond_products/pdfs/PCIC/w83781d.pdf 9 + * Winbond W83782D 10 + Prefix: 'w83782d' 11 + Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) 12 + Datasheet: http://www.winbond.com/PDF/sheet/w83782d.pdf 13 + * Winbond W83783S 14 + Prefix: 'w83783s' 15 + Addresses scanned: I2C 0x2d 16 + Datasheet: http://www.winbond-usa.com/products/winbond_products/pdfs/PCIC/w83783s.pdf 17 + * Winbond W83627HF 18 + Prefix: 'w83627hf' 19 + Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports) 20 + Datasheet: http://www.winbond.com/PDF/sheet/w83627hf.pdf 21 + * Asus AS99127F 22 + Prefix: 'as99127f' 23 + Addresses scanned: I2C 0x28 - 0x2f 24 + Datasheet: Unavailable from Asus 25 + 26 + Authors: 27 + Frodo Looijaard <frodol@dds.nl>, 28 + Philip Edelbrock <phil@netroedge.com>, 29 + Mark Studebaker <mdsxyz123@yahoo.com> 30 + 31 + Module parameters 32 + ----------------- 33 + 34 + * init int 35 + (default 1) 36 + Use 'init=0' to bypass initializing the chip. 37 + Try this if your computer crashes when you load the module. 38 + 39 + force_subclients=bus,caddr,saddr,saddr 40 + This is used to force the i2c addresses for subclients of 41 + a certain chip. Typical usage is `force_subclients=0,0x2d,0x4a,0x4b' 42 + to force the subclients of chip 0x2d on bus 0 to i2c addresses 43 + 0x4a and 0x4b. This parameter is useful for certain Tyan boards. 44 + 45 + Description 46 + ----------- 47 + 48 + This driver implements support for the Winbond W83781D, W83782D, W83783S, 49 + W83627HF chips, and the Asus AS99127F chips. We will refer to them 50 + collectively as W8378* chips. 51 + 52 + There is quite some difference between these chips, but they are similar 53 + enough that it was sensible to put them together in one driver. 54 + The W83627HF chip is assumed to be identical to the ISA W83782D. 55 + The Asus chips are similar to an I2C-only W83782D. 56 + 57 + Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA 58 + as99127f 7 3 0 3 0x31 0x12c3 yes no 59 + as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no 60 + w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes 61 + w83627hf 9 3 2 3 0x21 0x5ca3 yes yes(LPC) 62 + w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes 63 + w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no 64 + 65 + Detection of these chips can sometimes be foiled because they can be in 66 + an internal state that allows no clean access. If you know the address 67 + of the chip, use a 'force' parameter; this will put them into a more 68 + well-behaved state first. 69 + 70 + The W8378* implements temperature sensors (three on the W83781D and W83782D, 71 + two on the W83783S), three fan rotation speed sensors, voltage sensors 72 + (seven on the W83781D, nine on the W83782D and six on the W83783S), VID 73 + lines, alarms with beep warnings, and some miscellaneous stuff. 74 + 75 + Temperatures are measured in degrees Celsius. There is always one main 76 + temperature sensor, and one (W83783S) or two (W83781D and W83782D) other 77 + sensors. An alarm is triggered for the main sensor once when the 78 + Overtemperature Shutdown limit is crossed; it is triggered again as soon as 79 + it drops below the Hysteresis value. A more useful behavior 80 + can be found by setting the Hysteresis value to +127 degrees Celsius; in 81 + this case, alarms are issued during all the time when the actual temperature 82 + is above the Overtemperature Shutdown value. The driver sets the 83 + hysteresis value for temp1 to 127 at initialization. 84 + 85 + For the other temperature sensor(s), an alarm is triggered when the 86 + temperature gets higher then the Overtemperature Shutdown value; it stays 87 + on until the temperature falls below the Hysteresis value. But on the 88 + W83781D, there is only one alarm that functions for both other sensors! 89 + Temperatures are guaranteed within a range of -55 to +125 degrees. The 90 + main temperature sensors has a resolution of 1 degree; the other sensor(s) 91 + of 0.5 degree. 92 + 93 + Fan rotation speeds are reported in RPM (rotations per minute). An alarm is 94 + triggered if the rotation speed has dropped below a programmable limit. Fan 95 + readings can be divided by a programmable divider (1, 2, 4 or 8 for the 96 + W83781D; 1, 2, 4, 8, 16, 32, 64 or 128 for the others) to give 97 + the readings more range or accuracy. Not all RPM values can accurately 98 + be represented, so some rounding is done. With a divider of 2, the lowest 99 + representable value is around 2600 RPM. 100 + 101 + Voltage sensors (also known as IN sensors) report their values in volts. 102 + An alarm is triggered if the voltage has crossed a programmable minimum 103 + or maximum limit. Note that minimum in this case always means 'closest to 104 + zero'; this is important for negative voltage measurements. All voltage 105 + inputs can measure voltages between 0 and 4.08 volts, with a resolution 106 + of 0.016 volt. 107 + 108 + The VID lines encode the core voltage value: the voltage level your processor 109 + should work with. This is hardcoded by the mainboard and/or processor itself. 110 + It is a value in volts. When it is unconnected, you will often find the 111 + value 3.50 V here. 112 + 113 + The W83782D and W83783S temperature conversion machine understands about 114 + several kinds of temperature probes. You can program the so-called 115 + beta value in the sensor files. '1' is the PII/Celeron diode, '2' is the 116 + TN3904 transistor, and 3435 the default thermistor value. Other values 117 + are (not yet) supported. 118 + 119 + In addition to the alarms described above, there is a CHAS alarm on the 120 + chips which triggers if your computer case is open. 121 + 122 + When an alarm goes off, you can be warned by a beeping signal through 123 + your computer speaker. It is possible to enable all beeping globally, 124 + or only the beeping for some alarms. 125 + 126 + If an alarm triggers, it will remain triggered until the hardware register 127 + is read at least once. This means that the cause for the alarm may 128 + already have disappeared! Note that in the current implementation, all 129 + hardware registers are read whenever any data is read (unless it is less 130 + than 1.5 seconds since the last update). This means that you can easily 131 + miss once-only alarms. 132 + 133 + The chips only update values each 1.5 seconds; reading them more often 134 + will do no harm, but will return 'old' values. 135 + 136 + AS99127F PROBLEMS 137 + ----------------- 138 + The as99127f support was developed without the benefit of a datasheet. 139 + In most cases it is treated as a w83781d (although revision 2 of the 140 + AS99127F looks more like a w83782d). 141 + This support will be BETA until a datasheet is released. 142 + One user has reported problems with fans stopping 143 + occasionally. 144 + 145 + Note that the individual beep bits are inverted from the other chips. 146 + The driver now takes care of this so that user-space applications 147 + don't have to know about it. 148 + 149 + Known problems: 150 + - Problems with diode/thermistor settings (supported?) 151 + - One user reports fans stopping under high server load. 152 + - Revision 2 seems to have 2 PWM registers but we don't know 153 + how to handle them. More details below. 154 + 155 + These will not be fixed unless we get a datasheet. 156 + If you have problems, please lobby Asus to release a datasheet. 157 + Unfortunately several others have without success. 158 + Please do not send mail to us asking for better as99127f support. 159 + We have done the best we can without a datasheet. 160 + Please do not send mail to the author or the sensors group asking for 161 + a datasheet or ideas on how to convince Asus. We can't help. 162 + 163 + 164 + NOTES: 165 + ----- 166 + 783s has no in1 so that in[2-6] are compatible with the 781d/782d. 167 + 168 + 783s pin is programmable for -5V or temp1; defaults to -5V, 169 + no control in driver so temp1 doesn't work. 170 + 171 + 782d and 783s datasheets differ on which is pwm1 and which is pwm2. 172 + We chose to follow 782d. 173 + 174 + 782d and 783s pin is programmable for fan3 input or pwm2 output; 175 + defaults to fan3 input. 176 + If pwm2 is enabled (with echo 255 1 > pwm2), then 177 + fan3 will report 0. 178 + 179 + 782d has pwm1-2 for ISA, pwm1-4 for i2c. (pwm3-4 share pins with 180 + the ISA pins) 181 + 182 + Data sheet updates: 183 + ------------------ 184 + - PWM clock registers: 185 + 186 + 000: master / 512 187 + 001: master / 1024 188 + 010: master / 2048 189 + 011: master / 4096 190 + 100: master / 8192 191 + 192 + 193 + Answers from Winbond tech support 194 + --------------------------------- 195 + > 196 + > 1) In the W83781D data sheet section 7.2 last paragraph, it talks about 197 + > reprogramming the R-T table if the Beta of the thermistor is not 198 + > 3435K. The R-T table is described briefly in section 8.20. 199 + > What formulas do I use to program a new R-T table for a given Beta? 200 + > 201 + We are sorry that the calculation for R-T table value is 202 + confidential. If you have another Beta value of thermistor, we can help 203 + to calculate the R-T table for you. But you should give us real R-T 204 + Table which can be gotten by thermistor vendor. Therefore we will calculate 205 + them and obtain 32-byte data, and you can fill the 32-byte data to the 206 + register in Bank0.CR51 of W83781D. 207 + 208 + 209 + > 2) In the W83782D data sheet, it mentions that pins 38, 39, and 40 are 210 + > programmable to be either thermistor or Pentium II diode inputs. 211 + > How do I program them for diode inputs? I can't find any register 212 + > to program these to be diode inputs. 213 + --> You may program Bank0 CR[5Dh] and CR[59h] registers. 214 + 215 + CR[5Dh] bit 1(VTIN1) bit 2(VTIN2) bit 3(VTIN3) 216 + 217 + thermistor 0 0 0 218 + diode 1 1 1 219 + 220 + 221 + (error) CR[59h] bit 4(VTIN1) bit 2(VTIN2) bit 3(VTIN3) 222 + (right) CR[59h] bit 4(VTIN1) bit 5(VTIN2) bit 6(VTIN3) 223 + 224 + PII thermal diode 1 1 1 225 + 2N3904 diode 0 0 0 226 + 227 + 228 + Asus Clones 229 + ----------- 230 + 231 + We have no datasheets for the Asus clones (AS99127F and ASB100 Bach). 232 + Here are some very useful information that were given to us by Alex Van 233 + Kaam about how to detect these chips, and how to read their values. He 234 + also gives advice for another Asus chipset, the Mozart-2 (which we 235 + don't support yet). Thanks Alex! 236 + I reworded some parts and added personal comments. 237 + 238 + # Detection: 239 + 240 + AS99127F rev.1, AS99127F rev.2 and ASB100: 241 + - I2C address range: 0x29 - 0x2F 242 + - If register 0x58 holds 0x31 then we have an Asus (either ASB100 or 243 + AS99127F) 244 + - Which one depends on register 0x4F (manufacturer ID): 245 + 0x06 or 0x94: ASB100 246 + 0x12 or 0xC3: AS99127F rev.1 247 + 0x5C or 0xA3: AS99127F rev.2 248 + Note that 0x5CA3 is Winbond's ID (WEC), which let us think Asus get their 249 + AS99127F rev.2 direct from Winbond. The other codes mean ATT and DVC, 250 + respectively. ATT could stand for Asustek something (although it would be 251 + very badly chosen IMHO), I don't know what DVC could stand for. Maybe 252 + these codes simply aren't meant to be decoded that way. 253 + 254 + Mozart-2: 255 + - I2C address: 0x77 256 + - If register 0x58 holds 0x56 or 0x10 then we have a Mozart-2 257 + - Of the Mozart there are 3 types: 258 + 0x58=0x56, 0x4E=0x94, 0x4F=0x36: Asus ASM58 Mozart-2 259 + 0x58=0x56, 0x4E=0x94, 0x4F=0x06: Asus AS2K129R Mozart-2 260 + 0x58=0x10, 0x4E=0x5C, 0x4F=0xA3: Asus ??? Mozart-2 261 + You can handle all 3 the exact same way :) 262 + 263 + # Temperature sensors: 264 + 265 + ASB100: 266 + - sensor 1: register 0x27 267 + - sensor 2 & 3 are the 2 LM75's on the SMBus 268 + - sensor 4: register 0x17 269 + Remark: I noticed that on Intel boards sensor 2 is used for the CPU 270 + and 4 is ignored/stuck, on AMD boards sensor 4 is the CPU and sensor 2 is 271 + either ignored or a socket temperature. 272 + 273 + AS99127F (rev.1 and 2 alike): 274 + - sensor 1: register 0x27 275 + - sensor 2 & 3 are the 2 LM75's on the SMBus 276 + Remark: Register 0x5b is suspected to be temperature type selector. Bit 1 277 + would control temp1, bit 3 temp2 and bit 5 temp3. 278 + 279 + Mozart-2: 280 + - sensor 1: register 0x27 281 + - sensor 2: register 0x13 282 + 283 + # Fan sensors: 284 + 285 + ASB100, AS99127F (rev.1 and 2 alike): 286 + - 3 fans, identical to the W83781D 287 + 288 + Mozart-2: 289 + - 2 fans only, 1350000/RPM/div 290 + - fan 1: register 0x28, divisor on register 0xA1 (bits 4-5) 291 + - fan 2: register 0x29, divisor on register 0xA1 (bits 6-7) 292 + 293 + # Voltages: 294 + 295 + This is where there is a difference between AS99127F rev.1 and 2. 296 + Remark: The difference is similar to the difference between 297 + W83781D and W83782D. 298 + 299 + ASB100: 300 + in0=r(0x20)*0.016 301 + in1=r(0x21)*0.016 302 + in2=r(0x22)*0.016 303 + in3=r(0x23)*0.016*1.68 304 + in4=r(0x24)*0.016*3.8 305 + in5=r(0x25)*(-0.016)*3.97 306 + in6=r(0x26)*(-0.016)*1.666 307 + 308 + AS99127F rev.1: 309 + in0=r(0x20)*0.016 310 + in1=r(0x21)*0.016 311 + in2=r(0x22)*0.016 312 + in3=r(0x23)*0.016*1.68 313 + in4=r(0x24)*0.016*3.8 314 + in5=r(0x25)*(-0.016)*3.97 315 + in6=r(0x26)*(-0.016)*1.503 316 + 317 + AS99127F rev.2: 318 + in0=r(0x20)*0.016 319 + in1=r(0x21)*0.016 320 + in2=r(0x22)*0.016 321 + in3=r(0x23)*0.016*1.68 322 + in4=r(0x24)*0.016*3.8 323 + in5=(r(0x25)*0.016-3.6)*5.14+3.6 324 + in6=(r(0x26)*0.016-3.6)*3.14+3.6 325 + 326 + Mozart-2: 327 + in0=r(0x20)*0.016 328 + in1=255 329 + in2=r(0x22)*0.016 330 + in3=r(0x23)*0.016*1.68 331 + in4=r(0x24)*0.016*4 332 + in5=255 333 + in6=255 334 + 335 + 336 + # PWM 337 + 338 + Additional info about PWM on the AS99127F (may apply to other Asus 339 + chips as well) by Jean Delvare as of 2004-04-09: 340 + 341 + AS99127F revision 2 seems to have two PWM registers at 0x59 and 0x5A, 342 + and a temperature sensor type selector at 0x5B (which basically means 343 + that they swapped registers 0x59 and 0x5B when you compare with Winbond 344 + chips). 345 + Revision 1 of the chip also has the temperature sensor type selector at 346 + 0x5B, but PWM registers have no effect. 347 + 348 + We don't know exactly how the temperature sensor type selection works. 349 + Looks like bits 1-0 are for temp1, bits 3-2 for temp2 and bits 5-4 for 350 + temp3, although it is possible that only the most significant bit matters 351 + each time. So far, values other than 0 always broke the readings. 352 + 353 + PWM registers seem to be split in two parts: bit 7 is a mode selector, 354 + while the other bits seem to define a value or threshold. 355 + 356 + When bit 7 is clear, bits 6-0 seem to hold a threshold value. If the value 357 + is below a given limit, the fan runs at low speed. If the value is above 358 + the limit, the fan runs at full speed. We have no clue as to what the limit 359 + represents. Note that there seem to be some inertia in this mode, speed 360 + changes may need some time to trigger. Also, an hysteresis mechanism is 361 + suspected since walking through all the values increasingly and then 362 + decreasingly led to slightly different limits. 363 + 364 + When bit 7 is set, bits 3-0 seem to hold a threshold value, while bits 6-4 365 + would not be significant. If the value is below a given limit, the fan runs 366 + at full speed, while if it is above the limit it runs at low speed (so this 367 + is the contrary of the other mode, in a way). Here again, we don't know 368 + what the limit is supposed to represent. 369 + 370 + One remarkable thing is that the fans would only have two or three 371 + different speeds (transitional states left apart), not a whole range as 372 + you usually get with PWM. 373 + 374 + As a conclusion, you can write 0x00 or 0x8F to the PWM registers to make 375 + fans run at low speed, and 0x7F or 0x80 to make them run at full speed. 376 + 377 + Please contact us if you can figure out how it is supposed to work. As 378 + long as we don't know more, the w83781d driver doesn't handle PWM on 379 + AS99127F chips at all. 380 + 381 + Additional info about PWM on the AS99127F rev.1 by Hector Martin: 382 + 383 + I've been fiddling around with the (in)famous 0x59 register and 384 + found out the following values do work as a form of coarse pwm: 385 + 386 + 0x80 - seems to turn fans off after some time(1-2 minutes)... might be 387 + some form of auto-fan-control based on temp? hmm (Qfan? this mobo is an 388 + old ASUS, it isn't marketed as Qfan. Maybe some beta pre-attemp at Qfan 389 + that was dropped at the BIOS) 390 + 0x81 - off 391 + 0x82 - slightly "on-ner" than off, but my fans do not get to move. I can 392 + hear the high-pitched PWM sound that motors give off at too-low-pwm. 393 + 0x83 - now they do move. Estimate about 70% speed or so. 394 + 0x84-0x8f - full on 395 + 396 + Changing the high nibble doesn't seem to do much except the high bit 397 + (0x80) must be set for PWM to work, else the current pwm doesn't seem to 398 + change. 399 + 400 + My mobo is an ASUS A7V266-E. This behavior is similar to what I got 401 + with speedfan under Windows, where 0-15% would be off, 15-2x% (can't 402 + remember the exact value) would be 70% and higher would be full on.
+39
Documentation/i2c/chips/w83l785ts
··· 1 + Kernel driver w83l785ts 2 + ======================= 3 + 4 + Supported chips: 5 + * Winbond W83L785TS-S 6 + Prefix: 'w83l785ts' 7 + Addresses scanned: I2C 0x2e 8 + Datasheet: Publicly available at the Winbond USA website 9 + http://www.winbond-usa.com/products/winbond_products/pdfs/PCIC/W83L785TS-S.pdf 10 + 11 + Authors: 12 + Jean Delvare <khali@linux-fr.org> 13 + 14 + Description 15 + ----------- 16 + 17 + The W83L785TS-S is a digital temperature sensor. It senses the 18 + temperature of a single external diode. The high limit is 19 + theoretically defined as 85 or 100 degrees C through a combination 20 + of external resistors, so the user cannot change it. Values seen so 21 + far suggest that the two possible limits are actually 95 and 110 22 + degrees C. The datasheet is rather poor and obviously inaccurate 23 + on several points including this one. 24 + 25 + All temperature values are given in degrees Celsius. Resolution 26 + is 1.0 degree. See the datasheet for details. 27 + 28 + The w83l785ts driver will not update its values more frequently than 29 + every other second; reading them more often will do no harm, but will 30 + return 'old' values. 31 + 32 + Known Issues 33 + ------------ 34 + 35 + On some systems (Asus), the BIOS is known to interfere with the driver 36 + and cause read errors. The driver will retry a given number of times 37 + (5 by default) and then give up, returning the old value (or 0 if 38 + there is no old value). It seems to work well enough so that you should 39 + not notice anything. Thanks to James Bolt for helping test this feature.
+1 -1
Documentation/i2c/porting-clients
··· 57 57 Documentation/i2c/sysfs-interface for the individual files. Also 58 58 convert the units these files read and write to the specified ones. 59 59 If you need to add a new type of file, please discuss it on the 60 - sensors mailing list <sensors@stimpy.netroedge.com> by providing a 60 + sensors mailing list <lm-sensors@lm-sensors.org> by providing a 61 61 patch to the Documentation/i2c/sysfs-interface file. 62 62 63 63 * [Attach] For I2C drivers, the attach function should make sure
+39
Documentation/i2c/userspace-tools
··· 1 + Introduction 2 + ------------ 3 + 4 + Most mainboards have sensor chips to monitor system health (like temperatures, 5 + voltages, fans speed). They are often connected through an I2C bus, but some 6 + are also connected directly through the ISA bus. 7 + 8 + The kernel drivers make the data from the sensor chips available in the /sys 9 + virtual filesystem. Userspace tools are then used to display or set or the 10 + data in a more friendly manner. 11 + 12 + Lm-sensors 13 + ---------- 14 + 15 + Core set of utilites that will allow you to obtain health information, 16 + setup monitoring limits etc. You can get them on their homepage 17 + http://www.lm-sensors.nu/ or as a package from your Linux distribution. 18 + 19 + If from website: 20 + Get lmsensors from project web site. Please note, you need only userspace 21 + part, so compile with "make user_install" target. 22 + 23 + General hints to get things working: 24 + 25 + 0) get lm-sensors userspace utils 26 + 1) compile all drivers in I2C section as modules in your kernel 27 + 2) run sensors-detect script, it will tell you what modules you need to load. 28 + 3) load them and run "sensors" command, you should see some results. 29 + 4) fix sensors.conf, labels, limits, fan divisors 30 + 5) if any more problems consult FAQ, or documentation 31 + 32 + Other utilites 33 + -------------- 34 + 35 + If you want some graphical indicators of system health look for applications 36 + like: gkrellm, ksensors, xsensors, wmtemp, wmsensors, wmgtemp, ksysguardd, 37 + hardware-monitor 38 + 39 + If you are server administrator you can try snmpd or mrtgutils.
+12 -50
Documentation/i2c/writing-clients
··· 171 171 172 172 normal_i2c: filled in by the module writer. 173 173 A list of I2C addresses which should normally be examined. 174 - normal_i2c_range: filled in by the module writer. 175 - A list of pairs of I2C addresses, each pair being an inclusive range of 176 - addresses which should normally be examined. 177 174 probe: insmod parameter. 178 175 A list of pairs. The first value is a bus number (-1 for any I2C bus), 179 176 the second is the address. These addresses are also probed, as if they 180 177 were in the 'normal' list. 181 - probe_range: insmod parameter. 182 - A list of triples. The first value is a bus number (-1 for any I2C bus), 183 - the second and third are addresses. These form an inclusive range of 184 - addresses that are also probed, as if they were in the 'normal' list. 185 178 ignore: insmod parameter. 186 179 A list of pairs. The first value is a bus number (-1 for any I2C bus), 187 180 the second is the I2C address. These addresses are never probed. 188 - This parameter overrules 'normal' and 'probe', but not the 'force' lists. 189 - ignore_range: insmod parameter. 190 - A list of triples. The first value is a bus number (-1 for any I2C bus), 191 - the second and third are addresses. These form an inclusive range of 192 - I2C addresses that are never probed. 193 181 This parameter overrules 'normal' and 'probe', but not the 'force' lists. 194 182 force: insmod parameter. 195 183 A list of pairs. The first value is a bus number (-1 for any I2C bus), 196 184 the second is the I2C address. A device is blindly assumed to be on 197 185 the given address, no probing is done. 198 186 199 - Fortunately, as a module writer, you just have to define the `normal' 200 - and/or `normal_range' parameters. The complete declaration could look 201 - like this: 187 + Fortunately, as a module writer, you just have to define the `normal_i2c' 188 + parameter. The complete declaration could look like this: 202 189 203 - /* Scan 0x20 to 0x2f, 0x37, and 0x40 to 0x4f */ 204 - static unsigned short normal_i2c[] = { 0x37,I2C_CLIENT_END }; 205 - static unsigned short normal_i2c_range[] = { 0x20, 0x2f, 0x40, 0x4f, 206 - I2C_CLIENT_END }; 190 + /* Scan 0x37, and 0x48 to 0x4f */ 191 + static unsigned short normal_i2c[] = { 0x37, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 192 + 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; 207 193 208 194 /* Magic definition of all other variables and things */ 209 195 I2C_CLIENT_INSMOD; 210 196 211 - Note that you *have* to call the two defined variables `normal_i2c' and 212 - `normal_i2c_range', without any prefix! 197 + Note that you *have* to call the defined variable `normal_i2c', 198 + without any prefix! 213 199 214 200 215 201 Probing classes (sensors) ··· 209 223 210 224 normal_i2c: filled in by the module writer. Terminated by SENSORS_I2C_END. 211 225 A list of I2C addresses which should normally be examined. 212 - normal_i2c_range: filled in by the module writer. Terminated by 213 - SENSORS_I2C_END 214 - A list of pairs of I2C addresses, each pair being an inclusive range of 215 - addresses which should normally be examined. 216 226 normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END. 217 227 A list of ISA addresses which should normally be examined. 218 - normal_isa_range: filled in by the module writer. Terminated by 219 - SENSORS_ISA_END 220 - A list of triples. The first two elements are ISA addresses, being an 221 - range of addresses which should normally be examined. The third is the 222 - modulo parameter: only addresses which are 0 module this value relative 223 - to the first address of the range are actually considered. 224 228 probe: insmod parameter. Initialize this list with SENSORS_I2C_END values. 225 229 A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for 226 230 the ISA bus, -1 for any I2C bus), the second is the address. These 227 231 addresses are also probed, as if they were in the 'normal' list. 228 - probe_range: insmod parameter. Initialize this list with SENSORS_I2C_END 229 - values. 230 - A list of triples. The first value is a bus number (SENSORS_ISA_BUS for 231 - the ISA bus, -1 for any I2C bus), the second and third are addresses. 232 - These form an inclusive range of addresses that are also probed, as 233 - if they were in the 'normal' list. 234 232 ignore: insmod parameter. Initialize this list with SENSORS_I2C_END values. 235 233 A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for 236 234 the ISA bus, -1 for any I2C bus), the second is the I2C address. These 237 235 addresses are never probed. This parameter overrules 'normal' and 238 236 'probe', but not the 'force' lists. 239 - ignore_range: insmod parameter. Initialize this list with SENSORS_I2C_END 240 - values. 241 - A list of triples. The first value is a bus number (SENSORS_ISA_BUS for 242 - the ISA bus, -1 for any I2C bus), the second and third are addresses. 243 - These form an inclusive range of I2C addresses that are never probed. 244 - This parameter overrules 'normal' and 'probe', but not the 'force' lists. 245 237 246 238 Also used is a list of pointers to sensors_force_data structures: 247 239 force_data: insmod parameters. A list, ending with an element of which ··· 233 269 So we have a generic insmod variabled `force', and chip-specific variables 234 270 `force_CHIPNAME'. 235 271 236 - Fortunately, as a module writer, you just have to define the `normal' 237 - and/or `normal_range' parameters, and define what chip names are used. 272 + Fortunately, as a module writer, you just have to define the `normal_i2c' 273 + and `normal_isa' parameters, and define what chip names are used. 238 274 The complete declaration could look like this: 239 - /* Scan i2c addresses 0x20 to 0x2f, 0x37, and 0x40 to 0x4f 240 - static unsigned short normal_i2c[] = {0x37,SENSORS_I2C_END}; 241 - static unsigned short normal_i2c_range[] = {0x20,0x2f,0x40,0x4f, 242 - SENSORS_I2C_END}; 275 + /* Scan i2c addresses 0x37, and 0x48 to 0x4f */ 276 + static unsigned short normal_i2c[] = { 0x37, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 277 + 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; 243 278 /* Scan ISA address 0x290 */ 244 279 static unsigned int normal_isa[] = {0x0290,SENSORS_ISA_END}; 245 - static unsigned int normal_isa_range[] = {SENSORS_ISA_END}; 246 280 247 281 /* Define chips foo and bar, as well as all module parameters and things */ 248 282 SENSORS_INSMOD_2(foo,bar);
+8 -8
MAINTAINERS
··· 194 194 ADM1025 HARDWARE MONITOR DRIVER 195 195 P: Jean Delvare 196 196 M: khali@linux-fr.org 197 - L: sensors@stimpy.netroedge.com 197 + L: lm-sensors@lm-sensors.org 198 198 S: Maintained 199 199 200 200 ADT746X FAN DRIVER ··· 242 242 ALI1563 I2C DRIVER 243 243 P: Rudolf Marek 244 244 M: r.marek@sh.cvut.cz 245 - L: sensors@stimpy.netroedge.com 245 + L: lm-sensors@lm-sensors.org 246 246 S: Maintained 247 247 248 248 ALPHA PORT ··· 1002 1002 M: greg@kroah.com 1003 1003 P: Jean Delvare 1004 1004 M: khali@linux-fr.org 1005 - L: sensors@stimpy.netroedge.com 1005 + L: lm-sensors@lm-sensors.org 1006 1006 W: http://www.lm-sensors.nu/ 1007 1007 S: Maintained 1008 1008 ··· 1430 1430 LM83 HARDWARE MONITOR DRIVER 1431 1431 P: Jean Delvare 1432 1432 M: khali@linux-fr.org 1433 - L: sensors@stimpy.netroedge.com 1433 + L: lm-sensors@lm-sensors.org 1434 1434 S: Maintained 1435 1435 1436 1436 LM90 HARDWARE MONITOR DRIVER 1437 1437 P: Jean Delvare 1438 1438 M: khali@linux-fr.org 1439 - L: sensors@stimpy.netroedge.com 1439 + L: lm-sensors@lm-sensors.org 1440 1440 S: Maintained 1441 1441 1442 1442 LOGICAL DISK MANAGER SUPPORT (LDM, Windows 2000/XP Dynamic Disks) ··· 2075 2075 SMSC47M1 HARDWARE MONITOR DRIVER 2076 2076 P: Jean Delvare 2077 2077 M: khali@linux-fr.org 2078 - L: sensors@stimpy.netroedge.com 2078 + L: lm-sensors@lm-sensors.org 2079 2079 S: Odd Fixes 2080 2080 2081 2081 SMB FILESYSTEM ··· 2614 2614 W1 DALLAS'S 1-WIRE BUS 2615 2615 P: Evgeniy Polyakov 2616 2616 M: johnpol@2ka.mipt.ru 2617 - L: sensors@stimpy.netroedge.com 2617 + L: lm-sensors@lm-sensors.org 2618 2618 S: Maintained 2619 2619 2620 2620 W83L51xD SD/MMC CARD INTERFACE DRIVER ··· 2627 2627 W83L785TS HARDWARE MONITOR DRIVER 2628 2628 P: Jean Delvare 2629 2629 M: khali@linux-fr.org 2630 - L: sensors@stimpy.netroedge.com 2630 + L: lm-sensors@lm-sensors.org 2631 2631 S: Odd Fixes 2632 2632 2633 2633 WAN ROUTER & SANGOMA WANPIPE DRIVERS & API (X.25, FRAME RELAY, PPP, CISCO HDLC)
+20
arch/ppc/platforms/83xx/mpc834x_sys.c
··· 185 185 ipic_set_default_priority(); 186 186 } 187 187 188 + #if defined(CONFIG_I2C_MPC) && defined(CONFIG_SENSORS_DS1374) 189 + extern ulong ds1374_get_rtc_time(void); 190 + extern int ds1374_set_rtc_time(ulong); 191 + 192 + static int __init 193 + mpc834x_rtc_hookup(void) 194 + { 195 + struct timespec tv; 196 + 197 + ppc_md.get_rtc_time = ds1374_get_rtc_time; 198 + ppc_md.set_rtc_time = ds1374_set_rtc_time; 199 + 200 + tv.tv_nsec = 0; 201 + tv.tv_sec = (ppc_md.get_rtc_time)(); 202 + do_settimeofday(&tv); 203 + 204 + return 0; 205 + } 206 + late_initcall(mpc834x_rtc_hookup); 207 + #endif 188 208 static __inline__ void 189 209 mpc834x_sys_set_bat(void) 190 210 {
-3
drivers/acorn/char/pcf8583.c
··· 26 26 27 27 static struct i2c_client_address_data addr_data = { 28 28 .normal_i2c = normal_addr, 29 - .normal_i2c_range = ignore, 30 29 .probe = ignore, 31 - .probe_range = ignore, 32 30 .ignore = ignore, 33 - .ignore_range = ignore, 34 31 .force = ignore, 35 32 }; 36 33
+4 -4
drivers/i2c/algos/i2c-algo-pca.c
··· 49 49 /* 50 50 * Generate a start condition on the i2c bus. 51 51 * 52 - * returns after the start condition has occured 52 + * returns after the start condition has occurred 53 53 */ 54 54 static void pca_start(struct i2c_algo_pca_data *adap) 55 55 { ··· 62 62 } 63 63 64 64 /* 65 - * Generate a repeated start condition on the i2c bus 65 + * Generate a repeated start condition on the i2c bus 66 66 * 67 - * return after the repeated start condition has occured 67 + * return after the repeated start condition has occurred 68 68 */ 69 69 static void pca_repeated_start(struct i2c_algo_pca_data *adap) 70 70 { ··· 82 82 * returns after the stop condition has been generated 83 83 * 84 84 * STOPs do not generate an interrupt or set the SI flag, since the 85 - * part returns the the idle state (0xf8). Hence we don't need to 85 + * part returns the idle state (0xf8). Hence we don't need to 86 86 * pca_wait here. 87 87 */ 88 88 static void pca_stop(struct i2c_algo_pca_data *adap)
-1
drivers/i2c/algos/i2c-algo-sibyte.c
··· 24 24 25 25 /* Ported for SiByte SOCs by Broadcom Corporation. */ 26 26 27 - #include <linux/config.h> 28 27 #include <linux/kernel.h> 29 28 #include <linux/module.h> 30 29 #include <linux/init.h>
+17 -17
drivers/i2c/busses/Kconfig
··· 7 7 8 8 config I2C_ALI1535 9 9 tristate "ALI 1535" 10 - depends on I2C && PCI && EXPERIMENTAL 10 + depends on I2C && PCI 11 11 help 12 12 If you say yes to this option, support will be included for the SMB 13 13 Host controller on Acer Labs Inc. (ALI) M1535 South Bridges. The SMB ··· 31 31 32 32 config I2C_ALI15X3 33 33 tristate "ALI 15x3" 34 - depends on I2C && PCI && EXPERIMENTAL 34 + depends on I2C && PCI 35 35 help 36 36 If you say yes to this option, support will be included for the 37 37 Acer Labs Inc. (ALI) M1514 and M1543 motherboard I2C interfaces. ··· 41 41 42 42 config I2C_AMD756 43 43 tristate "AMD 756/766/768/8111 and nVidia nForce" 44 - depends on I2C && PCI && EXPERIMENTAL 44 + depends on I2C && PCI 45 45 help 46 46 If you say yes to this option, support will be included for the AMD 47 47 756/766/768 mainboard I2C interfaces. The driver also includes ··· 66 66 67 67 config I2C_AMD8111 68 68 tristate "AMD 8111" 69 - depends on I2C && PCI && EXPERIMENTAL 69 + depends on I2C && PCI 70 70 help 71 71 If you say yes to this option, support will be included for the 72 72 second (SMBus 2.0) AMD 8111 mainboard I2C interface. ··· 109 109 110 110 config I2C_I801 111 111 tristate "Intel 82801 (ICH)" 112 - depends on I2C && PCI && EXPERIMENTAL 112 + depends on I2C && PCI 113 113 help 114 114 If you say yes to this option, support will be included for the Intel 115 115 801 family of mainboard I2C interfaces. Specifically, the following ··· 130 130 131 131 config I2C_I810 132 132 tristate "Intel 810/815" 133 - depends on I2C && PCI && EXPERIMENTAL 133 + depends on I2C && PCI 134 134 select I2C_ALGOBIT 135 135 help 136 136 If you say yes to this option, support will be included for the Intel ··· 183 183 184 184 config I2C_ISA 185 185 tristate "ISA Bus support" 186 - depends on I2C && EXPERIMENTAL 186 + depends on I2C 187 187 help 188 188 If you say yes to this option, support will be included for i2c 189 189 interfaces that are on the ISA bus. ··· 248 248 will be called i2c-mpc. 249 249 250 250 config I2C_NFORCE2 251 - tristate "Nvidia Nforce2" 252 - depends on I2C && PCI && EXPERIMENTAL 251 + tristate "Nvidia nForce2, nForce3 and nForce4" 252 + depends on I2C && PCI 253 253 help 254 254 If you say yes to this option, support will be included for the Nvidia 255 - Nforce2 family of mainboard I2C interfaces. 256 - This driver also supports the nForce3 Pro 150 MCP. 255 + nForce2, nForce3 and nForce4 families of mainboard I2C interfaces. 257 256 258 257 This driver can also be built as a module. If so, the module 259 258 will be called i2c-nforce2. ··· 304 305 305 306 config I2C_PROSAVAGE 306 307 tristate "S3/VIA (Pro)Savage" 307 - depends on I2C && PCI && EXPERIMENTAL 308 + depends on I2C && PCI 308 309 select I2C_ALGOBIT 309 310 help 310 311 If you say yes to this option, support will be included for the ··· 387 388 388 389 config I2C_SIS5595 389 390 tristate "SiS 5595" 390 - depends on I2C && PCI && EXPERIMENTAL 391 + depends on I2C && PCI 391 392 help 392 393 If you say yes to this option, support will be included for the 393 394 SiS5595 SMBus (a subset of I2C) interface. ··· 397 398 398 399 config I2C_SIS630 399 400 tristate "SiS 630/730" 400 - depends on I2C && PCI && EXPERIMENTAL 401 + depends on I2C && PCI 401 402 help 402 403 If you say yes to this option, support will be included for the 403 404 SiS630 and SiS730 SMBus (a subset of I2C) interface. ··· 407 408 408 409 config I2C_SIS96X 409 410 tristate "SiS 96x" 410 - depends on I2C && PCI && EXPERIMENTAL 411 + depends on I2C && PCI 411 412 help 412 413 If you say yes to this option, support will be included for the SiS 413 414 96x SMBus (a subset of I2C) interfaces. Specifically, the following ··· 418 419 648/961 419 420 650/961 420 421 735 422 + 745 421 423 422 424 This driver can also be built as a module. If so, the module 423 425 will be called i2c-sis96x. ··· 449 449 450 450 config I2C_VIAPRO 451 451 tristate "VIA 82C596/82C686/823x" 452 - depends on I2C && PCI && EXPERIMENTAL 452 + depends on I2C && PCI 453 453 help 454 454 If you say yes to this option, support will be included for the VIA 455 455 82C596/82C686/823x I2C interfaces. Specifically, the following ··· 467 467 468 468 config I2C_VOODOO3 469 469 tristate "Voodoo 3" 470 - depends on I2C && PCI && EXPERIMENTAL 470 + depends on I2C && PCI 471 471 select I2C_ALGOBIT 472 472 help 473 473 If you say yes to this option, support will be included for the
-1
drivers/i2c/busses/i2c-ali1535.c
··· 53 53 54 54 /* Note: we assume there can only be one ALI1535, with one SMBus interface */ 55 55 56 - #include <linux/config.h> 57 56 #include <linux/module.h> 58 57 #include <linux/pci.h> 59 58 #include <linux/kernel.h>
-1
drivers/i2c/busses/i2c-ali15x3.c
··· 60 60 61 61 /* Note: we assume there can only be one ALI15X3, with one SMBus interface */ 62 62 63 - #include <linux/config.h> 64 63 #include <linux/module.h> 65 64 #include <linux/pci.h> 66 65 #include <linux/kernel.h>
-1
drivers/i2c/busses/i2c-amd756.c
··· 37 37 Note: we assume there can only be one device, with one SMBus interface. 38 38 */ 39 39 40 - #include <linux/config.h> 41 40 #include <linux/module.h> 42 41 #include <linux/pci.h> 43 42 #include <linux/kernel.h>
-1
drivers/i2c/busses/i2c-amd8111.c
··· 8 8 * the Free Software Foundation version 2. 9 9 */ 10 10 11 - #include <linux/config.h> 12 11 #include <linux/module.h> 13 12 #include <linux/pci.h> 14 13 #include <linux/kernel.h>
-1
drivers/i2c/busses/i2c-au1550.c
··· 27 27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 28 */ 29 29 30 - #include <linux/config.h> 31 30 #include <linux/delay.h> 32 31 #include <linux/kernel.h> 33 32 #include <linux/module.h>
-1
drivers/i2c/busses/i2c-elektor.c
··· 25 25 /* Partialy rewriten by Oleg I. Vdovikin for mmapped support of 26 26 for Alpha Processor Inc. UP-2000(+) boards */ 27 27 28 - #include <linux/config.h> 29 28 #include <linux/kernel.h> 30 29 #include <linux/ioport.h> 31 30 #include <linux/module.h>
-1
drivers/i2c/busses/i2c-frodo.c
··· 12 12 * version 2 as published by the Free Software Foundation. 13 13 */ 14 14 15 - #include <linux/config.h> 16 15 #include <linux/module.h> 17 16 #include <linux/kernel.h> 18 17 #include <linux/init.h>
-1
drivers/i2c/busses/i2c-i801.c
··· 41 41 42 42 /* Note: we assume there can only be one I801, with one SMBus interface */ 43 43 44 - #include <linux/config.h> 45 44 #include <linux/module.h> 46 45 #include <linux/pci.h> 47 46 #include <linux/kernel.h>
-1
drivers/i2c/busses/i2c-i810.c
··· 34 34 i815 1132 35 35 */ 36 36 37 - #include <linux/config.h> 38 37 #include <linux/kernel.h> 39 38 #include <linux/module.h> 40 39 #include <linux/init.h>
+1 -1
drivers/i2c/busses/i2c-ibm_iic.c
··· 695 695 696 696 dev->irq = iic_force_poll ? -1 : ocp->def->irq; 697 697 if (dev->irq >= 0){ 698 - /* Disable interrupts until we finish intialization, 698 + /* Disable interrupts until we finish initialization, 699 699 assumes level-sensitive IRQ setup... 700 700 */ 701 701 iic_interrupt_mode(dev, 0);
-1
drivers/i2c/busses/i2c-ibm_iic.h
··· 22 22 #ifndef __I2C_IBM_IIC_H_ 23 23 #define __I2C_IBM_IIC_H_ 24 24 25 - #include <linux/config.h> 26 25 #include <linux/i2c.h> 27 26 28 27 struct iic_regs {
+1 -1
drivers/i2c/busses/i2c-iop3xx.c
··· 85 85 u32 cr = IOP3XX_ICR_GCD | IOP3XX_ICR_SCLEN | IOP3XX_ICR_UE; 86 86 87 87 /* 88 - * Everytime unit enable is asserted, GPOD needs to be cleared 88 + * Every time unit enable is asserted, GPOD needs to be cleared 89 89 * on IOP321 to avoid data corruption on the bus. 90 90 */ 91 91 #ifdef CONFIG_ARCH_IOP321
-1
drivers/i2c/busses/i2c-isa.c
··· 24 24 the SMBus and the ISA bus very much easier. See lm78.c for an example 25 25 of this. */ 26 26 27 - #include <linux/config.h> 28 27 #include <linux/init.h> 29 28 #include <linux/module.h> 30 29 #include <linux/kernel.h>
-1
drivers/i2c/busses/i2c-ite.c
··· 33 33 /* With some changes from Ky�sti M�lkki <kmalkki@cc.hut.fi> and even 34 34 Frodo Looijaard <frodol@dds.nl> */ 35 35 36 - #include <linux/config.h> 37 36 #include <linux/kernel.h> 38 37 #include <linux/ioport.h> 39 38 #include <linux/module.h>
-5
drivers/i2c/busses/i2c-ixp2000.c
··· 26 26 * 'enabled' to drive the GPIOs. 27 27 */ 28 28 29 - #include <linux/config.h> 30 - #ifdef CONFIG_I2C_DEBUG_BUS 31 - #define DEBUG 1 32 - #endif 33 - 34 29 #include <linux/kernel.h> 35 30 #include <linux/init.h> 36 31 #include <linux/device.h>
-5
drivers/i2c/busses/i2c-ixp4xx.c
··· 26 26 * that is passed as the platform_data to this driver. 27 27 */ 28 28 29 - #include <linux/config.h> 30 - #ifdef CONFIG_I2C_DEBUG_BUS 31 - #define DEBUG 1 32 - #endif 33 - 34 29 #include <linux/kernel.h> 35 30 #include <linux/init.h> 36 31 #include <linux/device.h>
-1
drivers/i2c/busses/i2c-keywest.c
··· 46 46 sound driver to be happy 47 47 */ 48 48 49 - #include <linux/config.h> 50 49 #include <linux/module.h> 51 50 #include <linux/kernel.h> 52 51 #include <linux/ioport.h>
+10 -8
drivers/i2c/busses/i2c-mpc.c
··· 325 325 if (i2c->irq != OCP_IRQ_NA) 326 326 { 327 327 if ((result = request_irq(ocp->def->irq, mpc_i2c_isr, 328 - 0, "i2c-mpc", i2c)) < 0) { 328 + SA_SHIRQ, "i2c-mpc", i2c)) < 0) { 329 329 printk(KERN_ERR 330 330 "i2c-mpc - failed to attach interrupt\n"); 331 331 goto fail_irq; 332 332 } 333 333 } else 334 334 i2c->irq = 0; 335 + 336 + mpc_i2c_setclock(i2c); 337 + ocp_set_drvdata(ocp, i2c); 335 338 336 339 i2c->adap = mpc_ops; 337 340 i2c_set_adapdata(&i2c->adap, i2c); ··· 344 341 goto fail_add; 345 342 } 346 343 347 - mpc_i2c_setclock(i2c); 348 - ocp_set_drvdata(ocp, i2c); 349 344 return result; 350 345 351 346 fail_add: ··· 359 358 static void __devexit mpc_i2c_remove(struct ocp_device *ocp) 360 359 { 361 360 struct mpc_i2c *i2c = ocp_get_drvdata(ocp); 362 - ocp_set_drvdata(ocp, NULL); 363 361 i2c_del_adapter(&i2c->adap); 362 + ocp_set_drvdata(ocp, NULL); 364 363 365 364 if (ocp->def->irq != OCP_IRQ_NA) 366 365 free_irq(i2c->irq, i2c); ··· 425 424 426 425 if (i2c->irq != 0) 427 426 if ((result = request_irq(i2c->irq, mpc_i2c_isr, 428 - 0, "fsl-i2c", i2c)) < 0) { 427 + SA_SHIRQ, "i2c-mpc", i2c)) < 0) { 429 428 printk(KERN_ERR 430 429 "i2c-mpc - failed to attach interrupt\n"); 431 430 goto fail_irq; 432 431 } 432 + 433 + mpc_i2c_setclock(i2c); 434 + dev_set_drvdata(device, i2c); 433 435 434 436 i2c->adap = mpc_ops; 435 437 i2c_set_adapdata(&i2c->adap, i2c); ··· 442 438 goto fail_add; 443 439 } 444 440 445 - mpc_i2c_setclock(i2c); 446 - dev_set_drvdata(device, i2c); 447 441 return result; 448 442 449 443 fail_add: ··· 458 456 { 459 457 struct mpc_i2c *i2c = dev_get_drvdata(device); 460 458 461 - dev_set_drvdata(device, NULL); 462 459 i2c_del_adapter(&i2c->adap); 460 + dev_set_drvdata(device, NULL); 463 461 464 462 if (i2c->irq != 0) 465 463 free_irq(i2c->irq, i2c);
-1
drivers/i2c/busses/i2c-nforce2.c
··· 37 37 38 38 /* Note: we assume there can only be one nForce2, with two SMBus interfaces */ 39 39 40 - #include <linux/config.h> 41 40 #include <linux/module.h> 42 41 #include <linux/pci.h> 43 42 #include <linux/kernel.h>
-1
drivers/i2c/busses/i2c-parport-light.c
··· 24 24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 25 * ------------------------------------------------------------------------ */ 26 26 27 - #include <linux/config.h> 28 27 #include <linux/kernel.h> 29 28 #include <linux/module.h> 30 29 #include <linux/init.h>
+1 -2
drivers/i2c/busses/i2c-parport.c
··· 24 24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 25 * ------------------------------------------------------------------------ */ 26 26 27 - #include <linux/config.h> 28 27 #include <linux/kernel.h> 29 28 #include <linux/module.h> 30 29 #include <linux/init.h> ··· 130 131 /* Encapsulate the functions above in the correct structure. 131 132 Note that this is only a template, from which the real structures are 132 133 copied. The attaching code will set getscl to NULL for adapters that 133 - cannot read SCL back, and will also make the the data field point to 134 + cannot read SCL back, and will also make the data field point to 134 135 the parallel port structure. */ 135 136 static struct i2c_algo_bit_data parport_algo_data = { 136 137 .setsda = parport_setsda,
-1
drivers/i2c/busses/i2c-pca-isa.c
··· 17 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 18 */ 19 19 20 - #include <linux/config.h> 21 20 #include <linux/kernel.h> 22 21 #include <linux/ioport.h> 23 22 #include <linux/module.h>
-1
drivers/i2c/busses/i2c-piix4.c
··· 28 28 Note: we assume there can only be one device, with one SMBus interface. 29 29 */ 30 30 31 - #include <linux/config.h> 32 31 #include <linux/module.h> 33 32 #include <linux/moduleparam.h> 34 33 #include <linux/pci.h>
-1
drivers/i2c/busses/i2c-prosavage.c
··· 54 54 * (Additional documentation needed :( 55 55 */ 56 56 57 - #include <linux/config.h> 58 57 #include <linux/module.h> 59 58 #include <linux/init.h> 60 59 #include <linux/pci.h>
-1
drivers/i2c/busses/i2c-rpx.c
··· 11 11 * changed to eliminate RPXLite references. 12 12 */ 13 13 14 - #include <linux/config.h> 15 14 #include <linux/kernel.h> 16 15 #include <linux/module.h> 17 16 #include <linux/init.h>
+2 -1
drivers/i2c/busses/i2c-s3c2410.c
··· 20 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 21 */ 22 22 23 + #include <linux/config.h> 23 24 #include <linux/kernel.h> 24 25 #include <linux/module.h> 25 26 ··· 534 533 /* s3c24xx_i2c_xfer 535 534 * 536 535 * first port of call from the i2c bus code when an message needs 537 - * transfering across the i2c bus. 536 + * transferring across the i2c bus. 538 537 */ 539 538 540 539 static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
-1
drivers/i2c/busses/i2c-savage4.c
··· 29 29 it easier to add later. 30 30 */ 31 31 32 - #include <linux/config.h> 33 32 #include <linux/kernel.h> 34 33 #include <linux/module.h> 35 34 #include <linux/init.h>
-1
drivers/i2c/busses/i2c-sibyte.c
··· 17 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 18 */ 19 19 20 - #include <linux/config.h> 21 20 #include <linux/module.h> 22 21 #include <linux/i2c-algo-sibyte.h> 23 22 #include <asm/sibyte/sb1250_regs.h>
-1
drivers/i2c/busses/i2c-sis5595.c
··· 55 55 * Add adapter resets 56 56 */ 57 57 58 - #include <linux/config.h> 59 58 #include <linux/kernel.h> 60 59 #include <linux/module.h> 61 60 #include <linux/delay.h>
-1
drivers/i2c/busses/i2c-sis630.c
··· 48 48 Note: we assume there can only be one device, with one SMBus interface. 49 49 */ 50 50 51 - #include <linux/config.h> 52 51 #include <linux/kernel.h> 53 52 #include <linux/module.h> 54 53 #include <linux/delay.h>
-1
drivers/i2c/busses/i2c-sis96x.c
··· 32 32 We assume there can only be one SiS96x with one SMBus interface. 33 33 */ 34 34 35 - #include <linux/config.h> 36 35 #include <linux/module.h> 37 36 #include <linux/pci.h> 38 37 #include <linux/kernel.h>
-1
drivers/i2c/busses/i2c-stub.c
··· 21 21 22 22 #define DEBUG 1 23 23 24 - #include <linux/config.h> 25 24 #include <linux/init.h> 26 25 #include <linux/module.h> 27 26 #include <linux/kernel.h>
-1
drivers/i2c/busses/i2c-via.c
··· 21 21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 22 */ 23 23 24 - #include <linux/config.h> 25 24 #include <linux/kernel.h> 26 25 #include <linux/module.h> 27 26 #include <linux/pci.h>
-1
drivers/i2c/busses/i2c-viapro.c
··· 33 33 Note: we assume there can only be one device, with one SMBus interface. 34 34 */ 35 35 36 - #include <linux/config.h> 37 36 #include <linux/module.h> 38 37 #include <linux/delay.h> 39 38 #include <linux/pci.h>
-1
drivers/i2c/busses/i2c-voodoo3.c
··· 27 27 /* This interfaces to the I2C bus of the Voodoo3 to gain access to 28 28 the BT869 and possibly other I2C devices. */ 29 29 30 - #include <linux/config.h> 31 30 #include <linux/kernel.h> 32 31 #include <linux/module.h> 33 32 #include <linux/init.h>
-1
drivers/i2c/busses/scx200_acb.c
··· 24 24 25 25 */ 26 26 27 - #include <linux/config.h> 28 27 #include <linux/module.h> 29 28 #include <linux/errno.h> 30 29 #include <linux/kernel.h>
+104 -13
drivers/i2c/chips/Kconfig
··· 1 1 # 2 - # I2C Sensor device configuration 2 + # I2C Sensor and "other" chip configuration 3 3 # 4 4 5 5 menu "Hardware Sensors Chip support" ··· 11 11 12 12 config SENSORS_ADM1021 13 13 tristate "Analog Devices ADM1021 and compatibles" 14 - depends on I2C && EXPERIMENTAL 14 + depends on I2C 15 15 select I2C_SENSOR 16 16 help 17 17 If you say yes here you get support for Analog Devices ADM1021 ··· 29 29 help 30 30 If you say yes here you get support for Analog Devices ADM1025 31 31 and Philips NE1619 sensor chips. 32 + 32 33 This driver can also be built as a module. If so, the module 33 34 will be called adm1025. 34 35 ··· 39 38 select I2C_SENSOR 40 39 help 41 40 If you say yes here you get support for Analog Devices ADM1026 41 + sensor chip. 42 + 42 43 This driver can also be built as a module. If so, the module 43 44 will be called adm1026. 44 45 ··· 51 48 help 52 49 If you say yes here you get support for Analog Devices ADM1031 53 50 and ADM1030 sensor chips. 51 + 54 52 This driver can also be built as a module. If so, the module 55 53 will be called adm1031. 54 + 55 + config SENSORS_ADM9240 56 + tristate "Analog Devices ADM9240 and compatibles" 57 + depends on I2C && EXPERIMENTAL 58 + select I2C_SENSOR 59 + help 60 + If you say yes here you get support for Analog Devices ADM9240, 61 + Dallas DS1780, National Semiconductor LM81 sensor chips. 62 + 63 + This driver can also be built as a module. If so, the module 64 + will be called adm9240. 56 65 57 66 config SENSORS_ASB100 58 67 tristate "Asus ASB100 Bach" ··· 76 61 77 62 This driver can also be built as a module. If so, the module 78 63 will be called asb100. 64 + 65 + config SENSORS_ATXP1 66 + tristate "Attansic ATXP1 VID controller" 67 + depends on I2C && EXPERIMENTAL 68 + help 69 + If you say yes here you get support for the Attansic ATXP1 VID 70 + controller. 71 + 72 + If your board have such a chip, you are able to control your CPU 73 + core and other voltages. 74 + 75 + This driver can also be built as a module. If so, the module 76 + will be called atxp1. 79 77 80 78 config SENSORS_DS1621 81 79 tristate "Dallas Semiconductor DS1621 and DS1625" ··· 125 97 126 98 config SENSORS_GL518SM 127 99 tristate "Genesys Logic GL518SM" 128 - depends on I2C && EXPERIMENTAL 100 + depends on I2C 129 101 select I2C_SENSOR 130 102 help 131 103 If you say yes here you get support for Genesys Logic GL518SM ··· 147 119 148 120 config SENSORS_IT87 149 121 tristate "ITE IT87xx and compatibles" 150 - depends on I2C && EXPERIMENTAL 122 + depends on I2C 151 123 select I2C_SENSOR 152 124 help 153 125 If you say yes here you get support for ITE IT87xx sensor chips ··· 171 143 172 144 config SENSORS_LM75 173 145 tristate "National Semiconductor LM75 and compatibles" 174 - depends on I2C && EXPERIMENTAL 146 + depends on I2C 175 147 select I2C_SENSOR 176 148 help 177 149 If you say yes here you get support for National Semiconductor LM75 ··· 202 174 select I2C_SENSOR 203 175 help 204 176 If you say yes here you get support for National Semiconductor LM78, 205 - LM78-J and LM79. This can also be built as a module which can be 206 - inserted and removed while the kernel is running. 177 + LM78-J and LM79. 207 178 208 179 This driver can also be built as a module. If so, the module 209 180 will be called lm78. ··· 235 208 select I2C_SENSOR 236 209 help 237 210 If you say yes here you get support for National Semiconductor LM85 238 - sensor chips and clones: ADT7463 and ADM1027. 211 + sensor chips and clones: ADT7463, EMC6D100, EMC6D102 and ADM1027. 239 212 240 213 This driver can also be built as a module. If so, the module 241 214 will be called lm85. ··· 334 307 help 335 308 If you say yes here you get support for the integrated fan 336 309 monitoring and control capabilities of the SMSC LPC47B27x, 337 - LPC47M10x, LPC47M13x and LPC47M14x chips. 310 + LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x and LPC47M192 chips. 338 311 339 312 This driver can also be built as a module. If so, the module 340 313 will be called smsc47m1. 341 314 342 315 config SENSORS_VIA686A 343 316 tristate "VIA686A" 344 - depends on I2C && PCI && EXPERIMENTAL 317 + depends on I2C && PCI 345 318 select I2C_SENSOR 346 319 select I2C_ISA 347 320 help ··· 353 326 354 327 config SENSORS_W83781D 355 328 tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" 356 - depends on I2C && EXPERIMENTAL 329 + depends on I2C 357 330 select I2C_SENSOR 358 331 help 359 332 If you say yes here you get support for the Winbond W8378x series ··· 387 360 This driver can also be built as a module. If so, the module 388 361 will be called w83627hf. 389 362 363 + config SENSORS_W83627EHF 364 + tristate "Winbond W83627EHF" 365 + depends on I2C && EXPERIMENTAL 366 + select I2C_SENSOR 367 + select I2C_ISA 368 + help 369 + If you say yes here you get preliminary support for the hardware 370 + monitoring functionality of the Winbond W83627EHF Super-I/O chip. 371 + Only fan and temperature inputs are supported at the moment, while 372 + the chip does much more than that. 373 + 374 + This driver can also be built as a module. If so, the module 375 + will be called w83627ehf. 376 + 390 377 endmenu 391 378 392 379 menu "Other I2C Chip support" 393 380 depends on I2C 394 381 395 382 config SENSORS_DS1337 396 - tristate "Dallas Semiconductor DS1337 Real Time Clock" 383 + tristate "Dallas Semiconductor DS1337 and DS1339 Real Time Clock" 397 384 depends on I2C && EXPERIMENTAL 398 385 select I2C_SENSOR 399 386 help 400 387 If you say yes here you get support for Dallas Semiconductor 401 - DS1337 real-time clock chips. 388 + DS1337 and DS1339 real-time clock chips. 402 389 403 390 This driver can also be built as a module. If so, the module 404 391 will be called ds1337. 392 + 393 + config SENSORS_DS1374 394 + tristate "Maxim/Dallas Semiconductor DS1374 Real Time Clock" 395 + depends on I2C && EXPERIMENTAL 396 + select I2C_SENSOR 397 + help 398 + If you say yes here you get support for Dallas Semiconductor 399 + DS1374 real-time clock chips. 400 + 401 + This driver can also be built as a module. If so, the module 402 + will be called ds1374. 405 403 406 404 config SENSORS_EEPROM 407 405 tristate "EEPROM reader" ··· 450 398 451 399 This driver can also be built as a module. If so, the module 452 400 will be called pcf8574. 401 + 402 + config SENSORS_PCA9539 403 + tristate "Philips PCA9539 16-bit I/O port" 404 + depends on I2C && EXPERIMENTAL 405 + help 406 + If you say yes here you get support for the Philips PCA9539 407 + 16-bit I/O port. 408 + 409 + This driver can also be built as a module. If so, the module 410 + will be called pca9539. 453 411 454 412 config SENSORS_PCF8591 455 413 tristate "Philips PCF8591" ··· 493 431 This driver can also be built as a module. If so, the module 494 432 will be called isp1301_omap. 495 433 434 + # NOTE: This isn't really OMAP-specific, except for the current 435 + # interface location in <include/asm-arm/arch-omap/tps65010.h> 436 + # and having mostly OMAP-specific board support 437 + config TPS65010 438 + tristate "TPS6501x Power Management chips" 439 + depends on I2C && ARCH_OMAP 440 + default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK 441 + help 442 + If you say yes here you get support for the TPS6501x series of 443 + Power Management chips. These include voltage regulators, 444 + lithium ion/polymer battery charging, and other features that 445 + are often used in portable devices like cell phones and cameras. 446 + 447 + This driver can also be built as a module. If so, the module 448 + will be called tps65010. 449 + 450 + 496 451 config SENSORS_M41T00 497 452 tristate "ST M41T00 RTC chip" 498 453 depends on I2C && PPC32 ··· 518 439 519 440 This driver can also be built as a module. If so, the module 520 441 will be called m41t00. 442 + 443 + config SENSORS_MAX6875 444 + tristate "MAXIM MAX6875 Power supply supervisor" 445 + depends on I2C && EXPERIMENTAL 446 + help 447 + If you say yes here you get support for the MAX6875 448 + EEPROM-Programmable, Hex/Quad, Power-Suppy Sequencers/Supervisors. 449 + 450 + This provides a interface to program the EEPROM and reset the chip. 451 + 452 + This driver can also be built as a module. If so, the module 453 + will be called max6875. 521 454 522 455 endmenu
+9 -1
drivers/i2c/chips/Makefile
··· 1 1 # 2 - # Makefile for the kernel hardware sensors chip drivers. 2 + # Makefile for sensor and "other" I2C chip drivers. 3 3 # 4 4 5 5 # asb100, then w83781d go first, as they can override other drivers' addresses. ··· 11 11 obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o 12 12 obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o 13 13 obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o 14 + obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o 15 + obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o 14 16 obj-$(CONFIG_SENSORS_DS1337) += ds1337.o 17 + obj-$(CONFIG_SENSORS_DS1374) += ds1374.o 15 18 obj-$(CONFIG_SENSORS_DS1621) += ds1621.o 16 19 obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o 17 20 obj-$(CONFIG_SENSORS_FSCHER) += fscher.o ··· 33 30 obj-$(CONFIG_SENSORS_LM90) += lm90.o 34 31 obj-$(CONFIG_SENSORS_LM92) += lm92.o 35 32 obj-$(CONFIG_SENSORS_MAX1619) += max1619.o 33 + obj-$(CONFIG_SENSORS_MAX6875) += max6875.o 36 34 obj-$(CONFIG_SENSORS_M41T00) += m41t00.o 37 35 obj-$(CONFIG_SENSORS_PC87360) += pc87360.o 36 + obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o 38 37 obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o 39 38 obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o 40 39 obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o ··· 44 39 obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o 45 40 obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o 46 41 obj-$(CONFIG_SENSORS_VIA686A) += via686a.o 42 + obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o 47 43 obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o 44 + 48 45 obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o 46 + obj-$(CONFIG_TPS65010) += tps65010.o 49 47 50 48 ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) 51 49 EXTRA_CFLAGS += -DDEBUG
-9
drivers/i2c/chips/adm1021.c
··· 19 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 20 */ 21 21 22 - #include <linux/config.h> 23 22 #include <linux/module.h> 24 23 #include <linux/init.h> 25 24 #include <linux/slab.h> ··· 102 103 u8 remote_temp_hyst; 103 104 u8 remote_temp_input; 104 105 u8 alarms; 105 - /* special values for ADM1021 only */ 106 - u8 die_code; 107 106 /* Special values for ADM1023 only */ 108 107 u8 remote_temp_prec; 109 108 u8 remote_temp_os_prec; ··· 153 156 return sprintf(buf, "%d\n", data->value); \ 154 157 } 155 158 show2(alarms); 156 - show2(die_code); 157 159 158 160 #define set(value, reg) \ 159 161 static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ ··· 179 183 static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_remote_temp_hyst, set_remote_temp_hyst); 180 184 static DEVICE_ATTR(temp2_input, S_IRUGO, show_remote_temp_input, NULL); 181 185 static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 182 - static DEVICE_ATTR(die_code, S_IRUGO, show_die_code, NULL); 183 186 184 187 185 188 static int adm1021_attach_adapter(struct i2c_adapter *adapter) ··· 302 307 device_create_file(&new_client->dev, &dev_attr_temp2_min); 303 308 device_create_file(&new_client->dev, &dev_attr_temp2_input); 304 309 device_create_file(&new_client->dev, &dev_attr_alarms); 305 - if (data->type == adm1021) 306 - device_create_file(&new_client->dev, &dev_attr_die_code); 307 310 308 311 return 0; 309 312 ··· 364 371 data->remote_temp_max = adm1021_read_value(client, ADM1021_REG_REMOTE_TOS_R); 365 372 data->remote_temp_hyst = adm1021_read_value(client, ADM1021_REG_REMOTE_THYST_R); 366 373 data->alarms = adm1021_read_value(client, ADM1021_REG_STATUS) & 0x7c; 367 - if (data->type == adm1021) 368 - data->die_code = adm1021_read_value(client, ADM1021_REG_DIE_CODE); 369 374 if (data->type == adm1023) { 370 375 data->remote_temp_prec = adm1021_read_value(client, ADM1021_REG_REM_TEMP_PREC); 371 376 data->remote_temp_os_prec = adm1021_read_value(client, ADM1021_REG_REM_TOS_PREC);
+4 -1
drivers/i2c/chips/adm1025.c
··· 45 45 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 46 46 */ 47 47 48 - #include <linux/config.h> 49 48 #include <linux/module.h> 50 49 #include <linux/init.h> 51 50 #include <linux/slab.h> ··· 286 287 struct adm1025_data *data = adm1025_update_device(dev); 287 288 return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); 288 289 } 290 + /* in1_ref is deprecated in favour of cpu0_vid, remove after 2005-11-11 */ 289 291 static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL); 292 + static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); 290 293 291 294 static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) 292 295 { ··· 438 437 device_create_file(&new_client->dev, &dev_attr_temp1_max); 439 438 device_create_file(&new_client->dev, &dev_attr_temp2_max); 440 439 device_create_file(&new_client->dev, &dev_attr_alarms); 440 + /* in1_ref is deprecated, remove after 2005-11-11 */ 441 441 device_create_file(&new_client->dev, &dev_attr_in1_ref); 442 + device_create_file(&new_client->dev, &dev_attr_cpu0_vid); 442 443 device_create_file(&new_client->dev, &dev_attr_vrm); 443 444 444 445 /* Pin 11 is either in4 (+12V) or VID4 */
+5 -3
drivers/i2c/chips/adm1026.c
··· 23 23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 24 */ 25 25 26 - #include <linux/config.h> 27 26 #include <linux/module.h> 28 27 #include <linux/init.h> 29 28 #include <linux/slab.h> 30 29 #include <linux/jiffies.h> 31 30 #include <linux/i2c.h> 32 31 #include <linux/i2c-sensor.h> 33 - #include <linux/i2c-sysfs.h> 34 32 #include <linux/i2c-vid.h> 33 + #include <linux/hwmon-sysfs.h> 35 34 36 35 /* Addresses to scan */ 37 36 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; ··· 1224 1225 struct adm1026_data *data = adm1026_update_device(dev); 1225 1226 return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm)); 1226 1227 } 1227 - 1228 + /* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */ 1228 1229 static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL); 1230 + static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); 1229 1231 1230 1232 static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) 1231 1233 { ··· 1666 1666 device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable); 1667 1667 device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable); 1668 1668 device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable); 1669 + /* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */ 1669 1670 device_create_file(&new_client->dev, &dev_attr_vid); 1671 + device_create_file(&new_client->dev, &dev_attr_cpu0_vid); 1670 1672 device_create_file(&new_client->dev, &dev_attr_vrm); 1671 1673 device_create_file(&new_client->dev, &dev_attr_alarms); 1672 1674 device_create_file(&new_client->dev, &dev_attr_alarm_mask);
+1 -1
drivers/i2c/chips/adm1031.c
··· 440 440 441 441 /* 442 442 * That function checks the cases where the fan reading is not 443 - * relevent. It is used to provide 0 as fan reading when the fan is 443 + * relevant. It is used to provide 0 as fan reading when the fan is 444 444 * not supposed to run 445 445 */ 446 446 static int trust_fan_readings(struct adm1031_data *data, int chan)
+791
drivers/i2c/chips/adm9240.c
··· 1 + /* 2 + * adm9240.c Part of lm_sensors, Linux kernel modules for hardware 3 + * monitoring 4 + * 5 + * Copyright (C) 1999 Frodo Looijaard <frodol@dds.nl> 6 + * Philip Edelbrock <phil@netroedge.com> 7 + * Copyright (C) 2003 Michiel Rook <michiel@grendelproject.nl> 8 + * Copyright (C) 2005 Grant Coady <gcoady@gmail.com> with valuable 9 + * guidance from Jean Delvare 10 + * 11 + * Driver supports Analog Devices ADM9240 12 + * Dallas Semiconductor DS1780 13 + * National Semiconductor LM81 14 + * 15 + * ADM9240 is the reference, DS1780 and LM81 are register compatibles 16 + * 17 + * Voltage Six inputs are scaled by chip, VID also reported 18 + * Temperature Chip temperature to 0.5'C, maximum and max_hysteris 19 + * Fans 2 fans, low speed alarm, automatic fan clock divider 20 + * Alarms 16-bit map of active alarms 21 + * Analog Out 0..1250 mV output 22 + * 23 + * Chassis Intrusion: clear CI latch with 'echo 1 > chassis_clear' 24 + * 25 + * Test hardware: Intel SE440BX-2 desktop motherboard --Grant 26 + * 27 + * LM81 extended temp reading not implemented 28 + * 29 + * This program is free software; you can redistribute it and/or modify 30 + * it under the terms of the GNU General Public License as published by 31 + * the Free Software Foundation; either version 2 of the License, or 32 + * (at your option) any later version. 33 + * 34 + * This program is distributed in the hope that it will be useful, 35 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 36 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 37 + * GNU General Public License for more details. 38 + * 39 + * You should have received a copy of the GNU General Public License 40 + * along with this program; if not, write to the Free Software 41 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 42 + */ 43 + 44 + #include <linux/init.h> 45 + #include <linux/module.h> 46 + #include <linux/slab.h> 47 + #include <linux/i2c.h> 48 + #include <linux/i2c-sensor.h> 49 + #include <linux/i2c-vid.h> 50 + 51 + /* Addresses to scan */ 52 + static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, 53 + I2C_CLIENT_END }; 54 + 55 + static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; 56 + 57 + /* Insmod parameters */ 58 + SENSORS_INSMOD_3(adm9240, ds1780, lm81); 59 + 60 + /* ADM9240 registers */ 61 + #define ADM9240_REG_MAN_ID 0x3e 62 + #define ADM9240_REG_DIE_REV 0x3f 63 + #define ADM9240_REG_CONFIG 0x40 64 + 65 + #define ADM9240_REG_IN(nr) (0x20 + (nr)) /* 0..5 */ 66 + #define ADM9240_REG_IN_MAX(nr) (0x2b + (nr) * 2) 67 + #define ADM9240_REG_IN_MIN(nr) (0x2c + (nr) * 2) 68 + #define ADM9240_REG_FAN(nr) (0x28 + (nr)) /* 0..1 */ 69 + #define ADM9240_REG_FAN_MIN(nr) (0x3b + (nr)) 70 + #define ADM9240_REG_INT(nr) (0x41 + (nr)) 71 + #define ADM9240_REG_INT_MASK(nr) (0x43 + (nr)) 72 + #define ADM9240_REG_TEMP 0x27 73 + #define ADM9240_REG_TEMP_HIGH 0x39 74 + #define ADM9240_REG_TEMP_HYST 0x3a 75 + #define ADM9240_REG_ANALOG_OUT 0x19 76 + #define ADM9240_REG_CHASSIS_CLEAR 0x46 77 + #define ADM9240_REG_VID_FAN_DIV 0x47 78 + #define ADM9240_REG_I2C_ADDR 0x48 79 + #define ADM9240_REG_VID4 0x49 80 + #define ADM9240_REG_TEMP_CONF 0x4b 81 + 82 + /* generalised scaling with integer rounding */ 83 + static inline int SCALE(long val, int mul, int div) 84 + { 85 + if (val < 0) 86 + return (val * mul - div / 2) / div; 87 + else 88 + return (val * mul + div / 2) / div; 89 + } 90 + 91 + /* adm9240 internally scales voltage measurements */ 92 + static const u16 nom_mv[] = { 2500, 2700, 3300, 5000, 12000, 2700 }; 93 + 94 + static inline unsigned int IN_FROM_REG(u8 reg, int n) 95 + { 96 + return SCALE(reg, nom_mv[n], 192); 97 + } 98 + 99 + static inline u8 IN_TO_REG(unsigned long val, int n) 100 + { 101 + return SENSORS_LIMIT(SCALE(val, 192, nom_mv[n]), 0, 255); 102 + } 103 + 104 + /* temperature range: -40..125, 127 disables temperature alarm */ 105 + static inline s8 TEMP_TO_REG(long val) 106 + { 107 + return SENSORS_LIMIT(SCALE(val, 1, 1000), -40, 127); 108 + } 109 + 110 + /* two fans, each with low fan speed limit */ 111 + static inline unsigned int FAN_FROM_REG(u8 reg, u8 div) 112 + { 113 + if (!reg) /* error */ 114 + return -1; 115 + 116 + if (reg == 255) 117 + return 0; 118 + 119 + return SCALE(1350000, 1, reg * div); 120 + } 121 + 122 + /* analog out 0..1250mV */ 123 + static inline u8 AOUT_TO_REG(unsigned long val) 124 + { 125 + return SENSORS_LIMIT(SCALE(val, 255, 1250), 0, 255); 126 + } 127 + 128 + static inline unsigned int AOUT_FROM_REG(u8 reg) 129 + { 130 + return SCALE(reg, 1250, 255); 131 + } 132 + 133 + static int adm9240_attach_adapter(struct i2c_adapter *adapter); 134 + static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind); 135 + static void adm9240_init_client(struct i2c_client *client); 136 + static int adm9240_detach_client(struct i2c_client *client); 137 + static struct adm9240_data *adm9240_update_device(struct device *dev); 138 + 139 + /* driver data */ 140 + static struct i2c_driver adm9240_driver = { 141 + .owner = THIS_MODULE, 142 + .name = "adm9240", 143 + .id = I2C_DRIVERID_ADM9240, 144 + .flags = I2C_DF_NOTIFY, 145 + .attach_adapter = adm9240_attach_adapter, 146 + .detach_client = adm9240_detach_client, 147 + }; 148 + 149 + /* per client data */ 150 + struct adm9240_data { 151 + enum chips type; 152 + struct i2c_client client; 153 + struct semaphore update_lock; 154 + char valid; 155 + unsigned long last_updated_measure; 156 + unsigned long last_updated_config; 157 + 158 + u8 in[6]; /* ro in0_input */ 159 + u8 in_max[6]; /* rw in0_max */ 160 + u8 in_min[6]; /* rw in0_min */ 161 + u8 fan[2]; /* ro fan1_input */ 162 + u8 fan_min[2]; /* rw fan1_min */ 163 + u8 fan_div[2]; /* rw fan1_div, read-only accessor */ 164 + s16 temp; /* ro temp1_input, 9-bit sign-extended */ 165 + s8 temp_high; /* rw temp1_max */ 166 + s8 temp_hyst; /* rw temp1_max_hyst */ 167 + u16 alarms; /* ro alarms */ 168 + u8 aout; /* rw aout_output */ 169 + u8 vid; /* ro vid */ 170 + u8 vrm; /* -- vrm set on startup, no accessor */ 171 + }; 172 + 173 + /* i2c byte read/write interface */ 174 + static int adm9240_read_value(struct i2c_client *client, u8 reg) 175 + { 176 + return i2c_smbus_read_byte_data(client, reg); 177 + } 178 + 179 + static int adm9240_write_value(struct i2c_client *client, u8 reg, u8 value) 180 + { 181 + return i2c_smbus_write_byte_data(client, reg, value); 182 + } 183 + 184 + /*** sysfs accessors ***/ 185 + 186 + /* temperature */ 187 + #define show_temp(value, scale) \ 188 + static ssize_t show_##value(struct device *dev, \ 189 + struct device_attribute *attr, \ 190 + char *buf) \ 191 + { \ 192 + struct adm9240_data *data = adm9240_update_device(dev); \ 193 + return sprintf(buf, "%d\n", data->value * scale); \ 194 + } 195 + show_temp(temp_high, 1000); 196 + show_temp(temp_hyst, 1000); 197 + show_temp(temp, 500); /* 0.5'C per bit */ 198 + 199 + #define set_temp(value, reg) \ 200 + static ssize_t set_##value(struct device *dev, \ 201 + struct device_attribute *attr, \ 202 + const char *buf, size_t count) \ 203 + { \ 204 + struct i2c_client *client = to_i2c_client(dev); \ 205 + struct adm9240_data *data = adm9240_update_device(dev); \ 206 + long temp = simple_strtoul(buf, NULL, 10); \ 207 + \ 208 + down(&data->update_lock); \ 209 + data->value = TEMP_TO_REG(temp); \ 210 + adm9240_write_value(client, reg, data->value); \ 211 + up(&data->update_lock); \ 212 + return count; \ 213 + } 214 + 215 + set_temp(temp_high, ADM9240_REG_TEMP_HIGH); 216 + set_temp(temp_hyst, ADM9240_REG_TEMP_HYST); 217 + 218 + static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, 219 + show_temp_high, set_temp_high); 220 + static DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, 221 + show_temp_hyst, set_temp_hyst); 222 + static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); 223 + 224 + /* voltage */ 225 + static ssize_t show_in(struct device *dev, char *buf, int nr) 226 + { 227 + struct adm9240_data *data = adm9240_update_device(dev); 228 + return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr], nr)); 229 + } 230 + 231 + static ssize_t show_in_min(struct device *dev, char *buf, int nr) 232 + { 233 + struct adm9240_data *data = adm9240_update_device(dev); 234 + return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr], nr)); 235 + } 236 + 237 + static ssize_t show_in_max(struct device *dev, char *buf, int nr) 238 + { 239 + struct adm9240_data *data = adm9240_update_device(dev); 240 + return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr], nr)); 241 + } 242 + 243 + static ssize_t set_in_min(struct device *dev, const char *buf, 244 + size_t count, int nr) 245 + { 246 + struct i2c_client *client = to_i2c_client(dev); 247 + struct adm9240_data *data = i2c_get_clientdata(client); 248 + unsigned long val = simple_strtoul(buf, NULL, 10); 249 + 250 + down(&data->update_lock); 251 + data->in_min[nr] = IN_TO_REG(val, nr); 252 + adm9240_write_value(client, ADM9240_REG_IN_MIN(nr), data->in_min[nr]); 253 + up(&data->update_lock); 254 + return count; 255 + } 256 + 257 + static ssize_t set_in_max(struct device *dev, const char *buf, 258 + size_t count, int nr) 259 + { 260 + struct i2c_client *client = to_i2c_client(dev); 261 + struct adm9240_data *data = i2c_get_clientdata(client); 262 + unsigned long val = simple_strtoul(buf, NULL, 10); 263 + 264 + down(&data->update_lock); 265 + data->in_max[nr] = IN_TO_REG(val, nr); 266 + adm9240_write_value(client, ADM9240_REG_IN_MAX(nr), data->in_max[nr]); 267 + up(&data->update_lock); 268 + return count; 269 + } 270 + 271 + #define show_in_offset(offset) \ 272 + static ssize_t show_in##offset(struct device *dev, \ 273 + struct device_attribute *attr, \ 274 + char *buf) \ 275 + { \ 276 + return show_in(dev, buf, offset); \ 277 + } \ 278 + static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \ 279 + static ssize_t show_in##offset##_min(struct device *dev, \ 280 + struct device_attribute *attr, \ 281 + char *buf) \ 282 + { \ 283 + return show_in_min(dev, buf, offset); \ 284 + } \ 285 + static ssize_t show_in##offset##_max(struct device *dev, \ 286 + struct device_attribute *attr, \ 287 + char *buf) \ 288 + { \ 289 + return show_in_max(dev, buf, offset); \ 290 + } \ 291 + static ssize_t \ 292 + set_in##offset##_min(struct device *dev, \ 293 + struct device_attribute *attr, const char *buf, \ 294 + size_t count) \ 295 + { \ 296 + return set_in_min(dev, buf, count, offset); \ 297 + } \ 298 + static ssize_t \ 299 + set_in##offset##_max(struct device *dev, \ 300 + struct device_attribute *attr, const char *buf, \ 301 + size_t count) \ 302 + { \ 303 + return set_in_max(dev, buf, count, offset); \ 304 + } \ 305 + static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ 306 + show_in##offset##_min, set_in##offset##_min); \ 307 + static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ 308 + show_in##offset##_max, set_in##offset##_max); 309 + 310 + show_in_offset(0); 311 + show_in_offset(1); 312 + show_in_offset(2); 313 + show_in_offset(3); 314 + show_in_offset(4); 315 + show_in_offset(5); 316 + 317 + /* fans */ 318 + static ssize_t show_fan(struct device *dev, char *buf, int nr) 319 + { 320 + struct adm9240_data *data = adm9240_update_device(dev); 321 + return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], 322 + 1 << data->fan_div[nr])); 323 + } 324 + 325 + static ssize_t show_fan_min(struct device *dev, char *buf, int nr) 326 + { 327 + struct adm9240_data *data = adm9240_update_device(dev); 328 + return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], 329 + 1 << data->fan_div[nr])); 330 + } 331 + 332 + static ssize_t show_fan_div(struct device *dev, char *buf, int nr) 333 + { 334 + struct adm9240_data *data = adm9240_update_device(dev); 335 + return sprintf(buf, "%d\n", 1 << data->fan_div[nr]); 336 + } 337 + 338 + /* write new fan div, callers must hold data->update_lock */ 339 + static void adm9240_write_fan_div(struct i2c_client *client, int nr, 340 + u8 fan_div) 341 + { 342 + u8 reg, old, shift = (nr + 2) * 2; 343 + 344 + reg = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); 345 + old = (reg >> shift) & 3; 346 + reg &= ~(3 << shift); 347 + reg |= (fan_div << shift); 348 + adm9240_write_value(client, ADM9240_REG_VID_FAN_DIV, reg); 349 + dev_dbg(&client->dev, "fan%d clock divider changed from %u " 350 + "to %u\n", nr + 1, 1 << old, 1 << fan_div); 351 + } 352 + 353 + /* 354 + * set fan speed low limit: 355 + * 356 + * - value is zero: disable fan speed low limit alarm 357 + * 358 + * - value is below fan speed measurement range: enable fan speed low 359 + * limit alarm to be asserted while fan speed too slow to measure 360 + * 361 + * - otherwise: select fan clock divider to suit fan speed low limit, 362 + * measurement code may adjust registers to ensure fan speed reading 363 + */ 364 + static ssize_t set_fan_min(struct device *dev, const char *buf, 365 + size_t count, int nr) 366 + { 367 + struct i2c_client *client = to_i2c_client(dev); 368 + struct adm9240_data *data = i2c_get_clientdata(client); 369 + unsigned long val = simple_strtoul(buf, NULL, 10); 370 + u8 new_div; 371 + 372 + down(&data->update_lock); 373 + 374 + if (!val) { 375 + data->fan_min[nr] = 255; 376 + new_div = data->fan_div[nr]; 377 + 378 + dev_dbg(&client->dev, "fan%u low limit set disabled\n", 379 + nr + 1); 380 + 381 + } else if (val < 1350000 / (8 * 254)) { 382 + new_div = 3; 383 + data->fan_min[nr] = 254; 384 + 385 + dev_dbg(&client->dev, "fan%u low limit set minimum %u\n", 386 + nr + 1, FAN_FROM_REG(254, 1 << new_div)); 387 + 388 + } else { 389 + unsigned int new_min = 1350000 / val; 390 + 391 + new_div = 0; 392 + while (new_min > 192 && new_div < 3) { 393 + new_div++; 394 + new_min /= 2; 395 + } 396 + if (!new_min) /* keep > 0 */ 397 + new_min++; 398 + 399 + data->fan_min[nr] = new_min; 400 + 401 + dev_dbg(&client->dev, "fan%u low limit set fan speed %u\n", 402 + nr + 1, FAN_FROM_REG(new_min, 1 << new_div)); 403 + } 404 + 405 + if (new_div != data->fan_div[nr]) { 406 + data->fan_div[nr] = new_div; 407 + adm9240_write_fan_div(client, nr, new_div); 408 + } 409 + adm9240_write_value(client, ADM9240_REG_FAN_MIN(nr), 410 + data->fan_min[nr]); 411 + 412 + up(&data->update_lock); 413 + return count; 414 + } 415 + 416 + #define show_fan_offset(offset) \ 417 + static ssize_t show_fan_##offset (struct device *dev, \ 418 + struct device_attribute *attr, \ 419 + char *buf) \ 420 + { \ 421 + return show_fan(dev, buf, offset - 1); \ 422 + } \ 423 + static ssize_t show_fan_##offset##_div (struct device *dev, \ 424 + struct device_attribute *attr, \ 425 + char *buf) \ 426 + { \ 427 + return show_fan_div(dev, buf, offset - 1); \ 428 + } \ 429 + static ssize_t show_fan_##offset##_min (struct device *dev, \ 430 + struct device_attribute *attr, \ 431 + char *buf) \ 432 + { \ 433 + return show_fan_min(dev, buf, offset - 1); \ 434 + } \ 435 + static ssize_t set_fan_##offset##_min (struct device *dev, \ 436 + struct device_attribute *attr, \ 437 + const char *buf, size_t count) \ 438 + { \ 439 + return set_fan_min(dev, buf, count, offset - 1); \ 440 + } \ 441 + static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ 442 + show_fan_##offset, NULL); \ 443 + static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ 444 + show_fan_##offset##_div, NULL); \ 445 + static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ 446 + show_fan_##offset##_min, set_fan_##offset##_min); 447 + 448 + show_fan_offset(1); 449 + show_fan_offset(2); 450 + 451 + /* alarms */ 452 + static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 453 + { 454 + struct adm9240_data *data = adm9240_update_device(dev); 455 + return sprintf(buf, "%u\n", data->alarms); 456 + } 457 + static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 458 + 459 + /* vid */ 460 + static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) 461 + { 462 + struct adm9240_data *data = adm9240_update_device(dev); 463 + return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm)); 464 + } 465 + static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); 466 + 467 + /* analog output */ 468 + static ssize_t show_aout(struct device *dev, struct device_attribute *attr, char *buf) 469 + { 470 + struct adm9240_data *data = adm9240_update_device(dev); 471 + return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout)); 472 + } 473 + 474 + static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 475 + { 476 + struct i2c_client *client = to_i2c_client(dev); 477 + struct adm9240_data *data = i2c_get_clientdata(client); 478 + unsigned long val = simple_strtol(buf, NULL, 10); 479 + 480 + down(&data->update_lock); 481 + data->aout = AOUT_TO_REG(val); 482 + adm9240_write_value(client, ADM9240_REG_ANALOG_OUT, data->aout); 483 + up(&data->update_lock); 484 + return count; 485 + } 486 + static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout); 487 + 488 + /* chassis_clear */ 489 + static ssize_t chassis_clear(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 490 + { 491 + struct i2c_client *client = to_i2c_client(dev); 492 + unsigned long val = simple_strtol(buf, NULL, 10); 493 + 494 + if (val == 1) { 495 + adm9240_write_value(client, ADM9240_REG_CHASSIS_CLEAR, 0x80); 496 + dev_dbg(&client->dev, "chassis intrusion latch cleared\n"); 497 + } 498 + return count; 499 + } 500 + static DEVICE_ATTR(chassis_clear, S_IWUSR, NULL, chassis_clear); 501 + 502 + 503 + /*** sensor chip detect and driver install ***/ 504 + 505 + static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind) 506 + { 507 + struct i2c_client *new_client; 508 + struct adm9240_data *data; 509 + int err = 0; 510 + const char *name = ""; 511 + u8 man_id, die_rev; 512 + 513 + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 514 + goto exit; 515 + 516 + if (!(data = kmalloc(sizeof(struct adm9240_data), GFP_KERNEL))) { 517 + err = -ENOMEM; 518 + goto exit; 519 + } 520 + memset(data, 0, sizeof(struct adm9240_data)); 521 + 522 + new_client = &data->client; 523 + i2c_set_clientdata(new_client, data); 524 + new_client->addr = address; 525 + new_client->adapter = adapter; 526 + new_client->driver = &adm9240_driver; 527 + new_client->flags = 0; 528 + 529 + if (kind == 0) { 530 + kind = adm9240; 531 + } 532 + 533 + if (kind < 0) { 534 + 535 + /* verify chip: reg address should match i2c address */ 536 + if (adm9240_read_value(new_client, ADM9240_REG_I2C_ADDR) 537 + != address) { 538 + dev_err(&adapter->dev, "detect fail: address match, " 539 + "0x%02x\n", address); 540 + goto exit_free; 541 + } 542 + 543 + /* check known chip manufacturer */ 544 + man_id = adm9240_read_value(new_client, ADM9240_REG_MAN_ID); 545 + 546 + if (man_id == 0x23) { 547 + kind = adm9240; 548 + } else if (man_id == 0xda) { 549 + kind = ds1780; 550 + } else if (man_id == 0x01) { 551 + kind = lm81; 552 + } else { 553 + dev_err(&adapter->dev, "detect fail: unknown manuf, " 554 + "0x%02x\n", man_id); 555 + goto exit_free; 556 + } 557 + 558 + /* successful detect, print chip info */ 559 + die_rev = adm9240_read_value(new_client, ADM9240_REG_DIE_REV); 560 + dev_info(&adapter->dev, "found %s revision %u\n", 561 + man_id == 0x23 ? "ADM9240" : 562 + man_id == 0xda ? "DS1780" : "LM81", die_rev); 563 + } 564 + 565 + /* either forced or detected chip kind */ 566 + if (kind == adm9240) { 567 + name = "adm9240"; 568 + } else if (kind == ds1780) { 569 + name = "ds1780"; 570 + } else if (kind == lm81) { 571 + name = "lm81"; 572 + } 573 + 574 + /* fill in the remaining client fields and attach */ 575 + strlcpy(new_client->name, name, I2C_NAME_SIZE); 576 + data->type = kind; 577 + init_MUTEX(&data->update_lock); 578 + 579 + if ((err = i2c_attach_client(new_client))) 580 + goto exit_free; 581 + 582 + adm9240_init_client(new_client); 583 + 584 + /* populate sysfs filesystem */ 585 + device_create_file(&new_client->dev, &dev_attr_in0_input); 586 + device_create_file(&new_client->dev, &dev_attr_in0_min); 587 + device_create_file(&new_client->dev, &dev_attr_in0_max); 588 + device_create_file(&new_client->dev, &dev_attr_in1_input); 589 + device_create_file(&new_client->dev, &dev_attr_in1_min); 590 + device_create_file(&new_client->dev, &dev_attr_in1_max); 591 + device_create_file(&new_client->dev, &dev_attr_in2_input); 592 + device_create_file(&new_client->dev, &dev_attr_in2_min); 593 + device_create_file(&new_client->dev, &dev_attr_in2_max); 594 + device_create_file(&new_client->dev, &dev_attr_in3_input); 595 + device_create_file(&new_client->dev, &dev_attr_in3_min); 596 + device_create_file(&new_client->dev, &dev_attr_in3_max); 597 + device_create_file(&new_client->dev, &dev_attr_in4_input); 598 + device_create_file(&new_client->dev, &dev_attr_in4_min); 599 + device_create_file(&new_client->dev, &dev_attr_in4_max); 600 + device_create_file(&new_client->dev, &dev_attr_in5_input); 601 + device_create_file(&new_client->dev, &dev_attr_in5_min); 602 + device_create_file(&new_client->dev, &dev_attr_in5_max); 603 + device_create_file(&new_client->dev, &dev_attr_temp1_max); 604 + device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); 605 + device_create_file(&new_client->dev, &dev_attr_temp1_input); 606 + device_create_file(&new_client->dev, &dev_attr_fan1_input); 607 + device_create_file(&new_client->dev, &dev_attr_fan1_div); 608 + device_create_file(&new_client->dev, &dev_attr_fan1_min); 609 + device_create_file(&new_client->dev, &dev_attr_fan2_input); 610 + device_create_file(&new_client->dev, &dev_attr_fan2_div); 611 + device_create_file(&new_client->dev, &dev_attr_fan2_min); 612 + device_create_file(&new_client->dev, &dev_attr_alarms); 613 + device_create_file(&new_client->dev, &dev_attr_aout_output); 614 + device_create_file(&new_client->dev, &dev_attr_chassis_clear); 615 + device_create_file(&new_client->dev, &dev_attr_cpu0_vid); 616 + 617 + return 0; 618 + exit_free: 619 + kfree(new_client); 620 + exit: 621 + return err; 622 + } 623 + 624 + static int adm9240_attach_adapter(struct i2c_adapter *adapter) 625 + { 626 + if (!(adapter->class & I2C_CLASS_HWMON)) 627 + return 0; 628 + return i2c_detect(adapter, &addr_data, adm9240_detect); 629 + } 630 + 631 + static int adm9240_detach_client(struct i2c_client *client) 632 + { 633 + int err; 634 + 635 + if ((err = i2c_detach_client(client))) { 636 + dev_err(&client->dev, "Client deregistration failed, " 637 + "client not detached.\n"); 638 + return err; 639 + } 640 + 641 + kfree(i2c_get_clientdata(client)); 642 + return 0; 643 + } 644 + 645 + static void adm9240_init_client(struct i2c_client *client) 646 + { 647 + struct adm9240_data *data = i2c_get_clientdata(client); 648 + u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG); 649 + u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3; 650 + 651 + data->vrm = i2c_which_vrm(); /* need this to report vid as mV */ 652 + 653 + dev_info(&client->dev, "Using VRM: %d.%d\n", data->vrm / 10, 654 + data->vrm % 10); 655 + 656 + if (conf & 1) { /* measurement cycle running: report state */ 657 + 658 + dev_info(&client->dev, "status: config 0x%02x mode %u\n", 659 + conf, mode); 660 + 661 + } else { /* cold start: open limits before starting chip */ 662 + int i; 663 + 664 + for (i = 0; i < 6; i++) 665 + { 666 + adm9240_write_value(client, 667 + ADM9240_REG_IN_MIN(i), 0); 668 + adm9240_write_value(client, 669 + ADM9240_REG_IN_MAX(i), 255); 670 + } 671 + adm9240_write_value(client, ADM9240_REG_FAN_MIN(0), 255); 672 + adm9240_write_value(client, ADM9240_REG_FAN_MIN(1), 255); 673 + adm9240_write_value(client, ADM9240_REG_TEMP_HIGH, 127); 674 + adm9240_write_value(client, ADM9240_REG_TEMP_HYST, 127); 675 + 676 + /* start measurement cycle */ 677 + adm9240_write_value(client, ADM9240_REG_CONFIG, 1); 678 + 679 + dev_info(&client->dev, "cold start: config was 0x%02x " 680 + "mode %u\n", conf, mode); 681 + } 682 + } 683 + 684 + static struct adm9240_data *adm9240_update_device(struct device *dev) 685 + { 686 + struct i2c_client *client = to_i2c_client(dev); 687 + struct adm9240_data *data = i2c_get_clientdata(client); 688 + int i; 689 + 690 + down(&data->update_lock); 691 + 692 + /* minimum measurement cycle: 1.75 seconds */ 693 + if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4)) 694 + || !data->valid) { 695 + 696 + for (i = 0; i < 6; i++) /* read voltages */ 697 + { 698 + data->in[i] = adm9240_read_value(client, 699 + ADM9240_REG_IN(i)); 700 + } 701 + data->alarms = adm9240_read_value(client, 702 + ADM9240_REG_INT(0)) | 703 + adm9240_read_value(client, 704 + ADM9240_REG_INT(1)) << 8; 705 + 706 + /* read temperature: assume temperature changes less than 707 + * 0.5'C per two measurement cycles thus ignore possible 708 + * but unlikely aliasing error on lsb reading. --Grant */ 709 + data->temp = ((adm9240_read_value(client, 710 + ADM9240_REG_TEMP) << 8) | 711 + adm9240_read_value(client, 712 + ADM9240_REG_TEMP_CONF)) / 128; 713 + 714 + for (i = 0; i < 2; i++) /* read fans */ 715 + { 716 + data->fan[i] = adm9240_read_value(client, 717 + ADM9240_REG_FAN(i)); 718 + 719 + /* adjust fan clock divider on overflow */ 720 + if (data->valid && data->fan[i] == 255 && 721 + data->fan_div[i] < 3) { 722 + 723 + adm9240_write_fan_div(client, i, 724 + ++data->fan_div[i]); 725 + 726 + /* adjust fan_min if active, but not to 0 */ 727 + if (data->fan_min[i] < 255 && 728 + data->fan_min[i] >= 2) 729 + data->fan_min[i] /= 2; 730 + } 731 + } 732 + data->last_updated_measure = jiffies; 733 + } 734 + 735 + /* minimum config reading cycle: 300 seconds */ 736 + if (time_after(jiffies, data->last_updated_config + (HZ * 300)) 737 + || !data->valid) { 738 + 739 + for (i = 0; i < 6; i++) 740 + { 741 + data->in_min[i] = adm9240_read_value(client, 742 + ADM9240_REG_IN_MIN(i)); 743 + data->in_max[i] = adm9240_read_value(client, 744 + ADM9240_REG_IN_MAX(i)); 745 + } 746 + for (i = 0; i < 2; i++) 747 + { 748 + data->fan_min[i] = adm9240_read_value(client, 749 + ADM9240_REG_FAN_MIN(i)); 750 + } 751 + data->temp_high = adm9240_read_value(client, 752 + ADM9240_REG_TEMP_HIGH); 753 + data->temp_hyst = adm9240_read_value(client, 754 + ADM9240_REG_TEMP_HYST); 755 + 756 + /* read fan divs and 5-bit VID */ 757 + i = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV); 758 + data->fan_div[0] = (i >> 4) & 3; 759 + data->fan_div[1] = (i >> 6) & 3; 760 + data->vid = i & 0x0f; 761 + data->vid |= (adm9240_read_value(client, 762 + ADM9240_REG_VID4) & 1) << 4; 763 + /* read analog out */ 764 + data->aout = adm9240_read_value(client, 765 + ADM9240_REG_ANALOG_OUT); 766 + 767 + data->last_updated_config = jiffies; 768 + data->valid = 1; 769 + } 770 + up(&data->update_lock); 771 + return data; 772 + } 773 + 774 + static int __init sensors_adm9240_init(void) 775 + { 776 + return i2c_add_driver(&adm9240_driver); 777 + } 778 + 779 + static void __exit sensors_adm9240_exit(void) 780 + { 781 + i2c_del_driver(&adm9240_driver); 782 + } 783 + 784 + MODULE_AUTHOR("Michiel Rook <michiel@grendelproject.nl>, " 785 + "Grant Coady <gcoady@gmail.com> and others"); 786 + MODULE_DESCRIPTION("ADM9240/DS1780/LM81 driver"); 787 + MODULE_LICENSE("GPL"); 788 + 789 + module_init(sensors_adm9240_init); 790 + module_exit(sensors_adm9240_exit); 791 +
+2 -3
drivers/i2c/chips/asb100.c
··· 42 42 #include <linux/i2c-sensor.h> 43 43 #include <linux/i2c-vid.h> 44 44 #include <linux/init.h> 45 + #include <linux/jiffies.h> 45 46 #include "lm75.h" 46 47 47 48 /* ··· 168 167 { 169 168 return reg * 16; 170 169 } 171 - 172 - #define ALARMS_FROM_REG(val) (val) 173 170 174 171 #define DIV_FROM_REG(val) (1 << (val)) 175 172 ··· 555 556 static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 556 557 { 557 558 struct asb100_data *data = asb100_update_device(dev); 558 - return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->alarms)); 559 + return sprintf(buf, "%u\n", data->alarms); 559 560 } 560 561 561 562 static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
+361
drivers/i2c/chips/atxp1.c
··· 1 + /* 2 + atxp1.c - kernel module for setting CPU VID and general purpose 3 + I/Os using the Attansic ATXP1 chip. 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, write to the Free Software 17 + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 + 19 + */ 20 + 21 + #include <linux/kernel.h> 22 + #include <linux/init.h> 23 + #include <linux/module.h> 24 + #include <linux/i2c.h> 25 + #include <linux/i2c-sensor.h> 26 + #include <linux/i2c-vid.h> 27 + 28 + MODULE_LICENSE("GPL"); 29 + MODULE_DESCRIPTION("System voltages control via Attansic ATXP1"); 30 + MODULE_VERSION("0.6.2"); 31 + MODULE_AUTHOR("Sebastian Witt <se.witt@gmx.net>"); 32 + 33 + #define ATXP1_VID 0x00 34 + #define ATXP1_CVID 0x01 35 + #define ATXP1_GPIO1 0x06 36 + #define ATXP1_GPIO2 0x0a 37 + #define ATXP1_VIDENA 0x20 38 + #define ATXP1_VIDMASK 0x1f 39 + #define ATXP1_GPIO1MASK 0x0f 40 + 41 + static unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END }; 42 + static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END }; 43 + 44 + SENSORS_INSMOD_1(atxp1); 45 + 46 + static int atxp1_attach_adapter(struct i2c_adapter * adapter); 47 + static int atxp1_detach_client(struct i2c_client * client); 48 + static struct atxp1_data * atxp1_update_device(struct device *dev); 49 + static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind); 50 + 51 + static struct i2c_driver atxp1_driver = { 52 + .owner = THIS_MODULE, 53 + .name = "atxp1", 54 + .flags = I2C_DF_NOTIFY, 55 + .attach_adapter = atxp1_attach_adapter, 56 + .detach_client = atxp1_detach_client, 57 + }; 58 + 59 + struct atxp1_data { 60 + struct i2c_client client; 61 + struct semaphore update_lock; 62 + unsigned long last_updated; 63 + u8 valid; 64 + struct { 65 + u8 vid; /* VID output register */ 66 + u8 cpu_vid; /* VID input from CPU */ 67 + u8 gpio1; /* General purpose I/O register 1 */ 68 + u8 gpio2; /* General purpose I/O register 2 */ 69 + } reg; 70 + u8 vrm; /* Detected CPU VRM */ 71 + }; 72 + 73 + static struct atxp1_data * atxp1_update_device(struct device *dev) 74 + { 75 + struct i2c_client *client; 76 + struct atxp1_data *data; 77 + 78 + client = to_i2c_client(dev); 79 + data = i2c_get_clientdata(client); 80 + 81 + down(&data->update_lock); 82 + 83 + if ((jiffies - data->last_updated > HZ) || 84 + (jiffies < data->last_updated) || 85 + !data->valid) { 86 + 87 + /* Update local register data */ 88 + data->reg.vid = i2c_smbus_read_byte_data(client, ATXP1_VID); 89 + data->reg.cpu_vid = i2c_smbus_read_byte_data(client, ATXP1_CVID); 90 + data->reg.gpio1 = i2c_smbus_read_byte_data(client, ATXP1_GPIO1); 91 + data->reg.gpio2 = i2c_smbus_read_byte_data(client, ATXP1_GPIO2); 92 + 93 + data->valid = 1; 94 + } 95 + 96 + up(&data->update_lock); 97 + 98 + return(data); 99 + } 100 + 101 + /* sys file functions for cpu0_vid */ 102 + static ssize_t atxp1_showvcore(struct device *dev, struct device_attribute *attr, char *buf) 103 + { 104 + int size; 105 + struct atxp1_data *data; 106 + 107 + data = atxp1_update_device(dev); 108 + 109 + size = sprintf(buf, "%d\n", vid_from_reg(data->reg.vid & ATXP1_VIDMASK, data->vrm)); 110 + 111 + return size; 112 + } 113 + 114 + static ssize_t atxp1_storevcore(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 115 + { 116 + struct atxp1_data *data; 117 + struct i2c_client *client; 118 + char vid; 119 + char cvid; 120 + unsigned int vcore; 121 + 122 + client = to_i2c_client(dev); 123 + data = atxp1_update_device(dev); 124 + 125 + vcore = simple_strtoul(buf, NULL, 10); 126 + vcore /= 25; 127 + vcore *= 25; 128 + 129 + /* Calculate VID */ 130 + vid = vid_to_reg(vcore, data->vrm); 131 + 132 + if (vid < 0) { 133 + dev_err(dev, "VID calculation failed.\n"); 134 + return -1; 135 + } 136 + 137 + /* If output enabled, use control register value. Otherwise original CPU VID */ 138 + if (data->reg.vid & ATXP1_VIDENA) 139 + cvid = data->reg.vid & ATXP1_VIDMASK; 140 + else 141 + cvid = data->reg.cpu_vid; 142 + 143 + /* Nothing changed, aborting */ 144 + if (vid == cvid) 145 + return count; 146 + 147 + dev_info(dev, "Setting VCore to %d mV (0x%02x)\n", vcore, vid); 148 + 149 + /* Write every 25 mV step to increase stability */ 150 + if (cvid > vid) { 151 + for (; cvid >= vid; cvid--) { 152 + i2c_smbus_write_byte_data(client, ATXP1_VID, cvid | ATXP1_VIDENA); 153 + } 154 + } 155 + else { 156 + for (; cvid <= vid; cvid++) { 157 + i2c_smbus_write_byte_data(client, ATXP1_VID, cvid | ATXP1_VIDENA); 158 + } 159 + } 160 + 161 + data->valid = 0; 162 + 163 + return count; 164 + } 165 + 166 + /* CPU core reference voltage 167 + unit: millivolt 168 + */ 169 + static DEVICE_ATTR(cpu0_vid, S_IRUGO | S_IWUSR, atxp1_showvcore, atxp1_storevcore); 170 + 171 + /* sys file functions for GPIO1 */ 172 + static ssize_t atxp1_showgpio1(struct device *dev, struct device_attribute *attr, char *buf) 173 + { 174 + int size; 175 + struct atxp1_data *data; 176 + 177 + data = atxp1_update_device(dev); 178 + 179 + size = sprintf(buf, "0x%02x\n", data->reg.gpio1 & ATXP1_GPIO1MASK); 180 + 181 + return size; 182 + } 183 + 184 + static ssize_t atxp1_storegpio1(struct device *dev, struct device_attribute *attr, const char*buf, size_t count) 185 + { 186 + struct atxp1_data *data; 187 + struct i2c_client *client; 188 + unsigned int value; 189 + 190 + client = to_i2c_client(dev); 191 + data = atxp1_update_device(dev); 192 + 193 + value = simple_strtoul(buf, NULL, 16); 194 + 195 + value &= ATXP1_GPIO1MASK; 196 + 197 + if (value != (data->reg.gpio1 & ATXP1_GPIO1MASK)) { 198 + dev_info(dev, "Writing 0x%x to GPIO1.\n", value); 199 + 200 + i2c_smbus_write_byte_data(client, ATXP1_GPIO1, value); 201 + 202 + data->valid = 0; 203 + } 204 + 205 + return count; 206 + } 207 + 208 + /* GPIO1 data register 209 + unit: Four bit as hex (e.g. 0x0f) 210 + */ 211 + static DEVICE_ATTR(gpio1, S_IRUGO | S_IWUSR, atxp1_showgpio1, atxp1_storegpio1); 212 + 213 + /* sys file functions for GPIO2 */ 214 + static ssize_t atxp1_showgpio2(struct device *dev, struct device_attribute *attr, char *buf) 215 + { 216 + int size; 217 + struct atxp1_data *data; 218 + 219 + data = atxp1_update_device(dev); 220 + 221 + size = sprintf(buf, "0x%02x\n", data->reg.gpio2); 222 + 223 + return size; 224 + } 225 + 226 + static ssize_t atxp1_storegpio2(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 227 + { 228 + struct atxp1_data *data; 229 + struct i2c_client *client; 230 + unsigned int value; 231 + 232 + client = to_i2c_client(dev); 233 + data = atxp1_update_device(dev); 234 + 235 + value = simple_strtoul(buf, NULL, 16) & 0xff; 236 + 237 + if (value != data->reg.gpio2) { 238 + dev_info(dev, "Writing 0x%x to GPIO1.\n", value); 239 + 240 + i2c_smbus_write_byte_data(client, ATXP1_GPIO2, value); 241 + 242 + data->valid = 0; 243 + } 244 + 245 + return count; 246 + } 247 + 248 + /* GPIO2 data register 249 + unit: Eight bit as hex (e.g. 0xff) 250 + */ 251 + static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2); 252 + 253 + 254 + static int atxp1_attach_adapter(struct i2c_adapter *adapter) 255 + { 256 + return i2c_detect(adapter, &addr_data, &atxp1_detect); 257 + }; 258 + 259 + static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind) 260 + { 261 + struct i2c_client * new_client; 262 + struct atxp1_data * data; 263 + int err = 0; 264 + u8 temp; 265 + 266 + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 267 + goto exit; 268 + 269 + if (!(data = kmalloc(sizeof(struct atxp1_data), GFP_KERNEL))) { 270 + err = -ENOMEM; 271 + goto exit; 272 + } 273 + 274 + memset(data, 0, sizeof(struct atxp1_data)); 275 + new_client = &data->client; 276 + i2c_set_clientdata(new_client, data); 277 + 278 + new_client->addr = address; 279 + new_client->adapter = adapter; 280 + new_client->driver = &atxp1_driver; 281 + new_client->flags = 0; 282 + 283 + /* Detect ATXP1, checking if vendor ID registers are all zero */ 284 + if (!((i2c_smbus_read_byte_data(new_client, 0x3e) == 0) && 285 + (i2c_smbus_read_byte_data(new_client, 0x3f) == 0) && 286 + (i2c_smbus_read_byte_data(new_client, 0xfe) == 0) && 287 + (i2c_smbus_read_byte_data(new_client, 0xff) == 0) )) { 288 + 289 + /* No vendor ID, now checking if registers 0x10,0x11 (non-existent) 290 + * showing the same as register 0x00 */ 291 + temp = i2c_smbus_read_byte_data(new_client, 0x00); 292 + 293 + if (!((i2c_smbus_read_byte_data(new_client, 0x10) == temp) && 294 + (i2c_smbus_read_byte_data(new_client, 0x11) == temp) )) 295 + goto exit_free; 296 + } 297 + 298 + /* Get VRM */ 299 + data->vrm = i2c_which_vrm(); 300 + 301 + if ((data->vrm != 90) && (data->vrm != 91)) { 302 + dev_err(&new_client->dev, "Not supporting VRM %d.%d\n", 303 + data->vrm / 10, data->vrm % 10); 304 + goto exit_free; 305 + } 306 + 307 + strncpy(new_client->name, "atxp1", I2C_NAME_SIZE); 308 + 309 + data->valid = 0; 310 + 311 + init_MUTEX(&data->update_lock); 312 + 313 + err = i2c_attach_client(new_client); 314 + 315 + if (err) 316 + { 317 + dev_err(&new_client->dev, "Attach client error.\n"); 318 + goto exit_free; 319 + } 320 + 321 + device_create_file(&new_client->dev, &dev_attr_gpio1); 322 + device_create_file(&new_client->dev, &dev_attr_gpio2); 323 + device_create_file(&new_client->dev, &dev_attr_cpu0_vid); 324 + 325 + dev_info(&new_client->dev, "Using VRM: %d.%d\n", 326 + data->vrm / 10, data->vrm % 10); 327 + 328 + return 0; 329 + 330 + exit_free: 331 + kfree(data); 332 + exit: 333 + return err; 334 + }; 335 + 336 + static int atxp1_detach_client(struct i2c_client * client) 337 + { 338 + int err; 339 + 340 + err = i2c_detach_client(client); 341 + 342 + if (err) 343 + dev_err(&client->dev, "Failed to detach client.\n"); 344 + else 345 + kfree(i2c_get_clientdata(client)); 346 + 347 + return err; 348 + }; 349 + 350 + static int __init atxp1_init(void) 351 + { 352 + return i2c_add_driver(&atxp1_driver); 353 + }; 354 + 355 + static void __exit atxp1_exit(void) 356 + { 357 + i2c_del_driver(&atxp1_driver); 358 + }; 359 + 360 + module_init(atxp1_init); 361 + module_exit(atxp1_exit);
+40 -57
drivers/i2c/chips/ds1337.c
··· 3 3 * 4 4 * Copyright (C) 2005 James Chapman <jchapman@katalix.com> 5 5 * 6 - * based on linux/drivers/acron/char/pcf8583.c 6 + * based on linux/drivers/acorn/char/pcf8583.c 7 7 * Copyright (C) 2000 Russell King 8 8 * 9 9 * This program is free software; you can redistribute it and/or modify 10 10 * it under the terms of the GNU General Public License version 2 as 11 11 * published by the Free Software Foundation. 12 12 * 13 - * Driver for Dallas Semiconductor DS1337 real time clock chip 13 + * Driver for Dallas Semiconductor DS1337 and DS1339 real time clock chip 14 14 */ 15 15 16 - #include <linux/config.h> 17 16 #include <linux/module.h> 18 17 #include <linux/init.h> 19 18 #include <linux/slab.h> ··· 68 69 struct ds1337_data { 69 70 struct i2c_client client; 70 71 struct list_head list; 71 - int id; 72 72 }; 73 73 74 74 /* 75 75 * Internal variables 76 76 */ 77 - static int ds1337_id; 78 77 static LIST_HEAD(ds1337_clients); 79 78 80 79 static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value) ··· 92 95 */ 93 96 static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt) 94 97 { 95 - struct ds1337_data *data = i2c_get_clientdata(client); 96 98 int result; 97 99 u8 buf[7]; 98 100 u8 val; ··· 99 103 u8 offs = 0; 100 104 101 105 if (!dt) { 102 - dev_dbg(&client->adapter->dev, "%s: EINVAL: dt=NULL\n", 103 - __FUNCTION__); 104 - 106 + dev_dbg(&client->dev, "%s: EINVAL: dt=NULL\n", __FUNCTION__); 105 107 return -EINVAL; 106 108 } 107 109 ··· 113 119 msg[1].len = sizeof(buf); 114 120 msg[1].buf = &buf[0]; 115 121 116 - result = client->adapter->algo->master_xfer(client->adapter, 117 - &msg[0], 2); 122 + result = i2c_transfer(client->adapter, msg, 2); 118 123 119 - dev_dbg(&client->adapter->dev, 120 - "%s: [%d] %02x %02x %02x %02x %02x %02x %02x\n", 124 + dev_dbg(&client->dev, "%s: [%d] %02x %02x %02x %02x %02x %02x %02x\n", 121 125 __FUNCTION__, result, buf[0], buf[1], buf[2], buf[3], 122 126 buf[4], buf[5], buf[6]); 123 127 124 - if (result >= 0) { 125 - dt->tm_sec = BCD_TO_BIN(buf[0]); 126 - dt->tm_min = BCD_TO_BIN(buf[1]); 128 + if (result == 2) { 129 + dt->tm_sec = BCD2BIN(buf[0]); 130 + dt->tm_min = BCD2BIN(buf[1]); 127 131 val = buf[2] & 0x3f; 128 - dt->tm_hour = BCD_TO_BIN(val); 129 - dt->tm_wday = BCD_TO_BIN(buf[3]) - 1; 130 - dt->tm_mday = BCD_TO_BIN(buf[4]); 132 + dt->tm_hour = BCD2BIN(val); 133 + dt->tm_wday = BCD2BIN(buf[3]) - 1; 134 + dt->tm_mday = BCD2BIN(buf[4]); 131 135 val = buf[5] & 0x7f; 132 - dt->tm_mon = BCD_TO_BIN(val); 133 - dt->tm_year = 1900 + BCD_TO_BIN(buf[6]); 136 + dt->tm_mon = BCD2BIN(val) - 1; 137 + dt->tm_year = BCD2BIN(buf[6]); 134 138 if (buf[5] & 0x80) 135 139 dt->tm_year += 100; 136 140 137 - dev_dbg(&client->adapter->dev, "%s: secs=%d, mins=%d, " 141 + dev_dbg(&client->dev, "%s: secs=%d, mins=%d, " 138 142 "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n", 139 143 __FUNCTION__, dt->tm_sec, dt->tm_min, 140 144 dt->tm_hour, dt->tm_mday, 141 145 dt->tm_mon, dt->tm_year, dt->tm_wday); 142 - } else { 143 - dev_err(&client->adapter->dev, "ds1337[%d]: error reading " 144 - "data! %d\n", data->id, result); 145 - result = -EIO; 146 + 147 + return 0; 146 148 } 147 149 148 - return result; 150 + dev_err(&client->dev, "error reading data! %d\n", result); 151 + return -EIO; 149 152 } 150 153 151 154 static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt) 152 155 { 153 - struct ds1337_data *data = i2c_get_clientdata(client); 154 156 int result; 155 157 u8 buf[8]; 156 158 u8 val; 157 159 struct i2c_msg msg[1]; 158 160 159 161 if (!dt) { 160 - dev_dbg(&client->adapter->dev, "%s: EINVAL: dt=NULL\n", 161 - __FUNCTION__); 162 - 162 + dev_dbg(&client->dev, "%s: EINVAL: dt=NULL\n", __FUNCTION__); 163 163 return -EINVAL; 164 164 } 165 165 166 - dev_dbg(&client->adapter->dev, "%s: secs=%d, mins=%d, hours=%d, " 166 + dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, " 167 167 "mday=%d, mon=%d, year=%d, wday=%d\n", __FUNCTION__, 168 168 dt->tm_sec, dt->tm_min, dt->tm_hour, 169 169 dt->tm_mday, dt->tm_mon, dt->tm_year, dt->tm_wday); 170 170 171 171 buf[0] = 0; /* reg offset */ 172 - buf[1] = BIN_TO_BCD(dt->tm_sec); 173 - buf[2] = BIN_TO_BCD(dt->tm_min); 174 - buf[3] = BIN_TO_BCD(dt->tm_hour) | (1 << 6); 175 - buf[4] = BIN_TO_BCD(dt->tm_wday) + 1; 176 - buf[5] = BIN_TO_BCD(dt->tm_mday); 177 - buf[6] = BIN_TO_BCD(dt->tm_mon); 178 - if (dt->tm_year >= 2000) { 179 - val = dt->tm_year - 2000; 172 + buf[1] = BIN2BCD(dt->tm_sec); 173 + buf[2] = BIN2BCD(dt->tm_min); 174 + buf[3] = BIN2BCD(dt->tm_hour) | (1 << 6); 175 + buf[4] = BIN2BCD(dt->tm_wday) + 1; 176 + buf[5] = BIN2BCD(dt->tm_mday); 177 + buf[6] = BIN2BCD(dt->tm_mon) + 1; 178 + val = dt->tm_year; 179 + if (val >= 100) { 180 + val -= 100; 180 181 buf[6] |= (1 << 7); 181 - } else { 182 - val = dt->tm_year - 1900; 183 182 } 184 - buf[7] = BIN_TO_BCD(val); 183 + buf[7] = BIN2BCD(val); 185 184 186 185 msg[0].addr = client->addr; 187 186 msg[0].flags = 0; 188 187 msg[0].len = sizeof(buf); 189 188 msg[0].buf = &buf[0]; 190 189 191 - result = client->adapter->algo->master_xfer(client->adapter, 192 - &msg[0], 1); 193 - if (result < 0) { 194 - dev_err(&client->adapter->dev, "ds1337[%d]: error " 195 - "writing data! %d\n", data->id, result); 196 - result = -EIO; 197 - } else { 198 - result = 0; 199 - } 190 + result = i2c_transfer(client->adapter, msg, 1); 191 + if (result == 1) 192 + return 0; 200 193 201 - return result; 194 + dev_err(&client->dev, "error writing data! %d\n", result); 195 + return -EIO; 202 196 } 203 197 204 198 static int ds1337_command(struct i2c_client *client, unsigned int cmd, 205 199 void *arg) 206 200 { 207 - dev_dbg(&client->adapter->dev, "%s: cmd=%d\n", __FUNCTION__, cmd); 201 + dev_dbg(&client->dev, "%s: cmd=%d\n", __FUNCTION__, cmd); 208 202 209 203 switch (cmd) { 210 204 case DS1337_GET_DATE: ··· 210 228 * Public API for access to specific device. Useful for low-level 211 229 * RTC access from kernel code. 212 230 */ 213 - int ds1337_do_command(int id, int cmd, void *arg) 231 + int ds1337_do_command(int bus, int cmd, void *arg) 214 232 { 215 233 struct list_head *walk; 216 234 struct list_head *tmp; ··· 218 236 219 237 list_for_each_safe(walk, tmp, &ds1337_clients) { 220 238 data = list_entry(walk, struct ds1337_data, list); 221 - if (data->id == id) 239 + if (data->client.adapter->nr == bus) 222 240 return ds1337_command(&data->client, cmd, arg); 223 241 } 224 242 ··· 328 346 ds1337_init_client(new_client); 329 347 330 348 /* Add client to local list */ 331 - data->id = ds1337_id++; 332 349 list_add(&data->list, &ds1337_clients); 333 350 334 351 return 0; ··· 378 397 MODULE_AUTHOR("James Chapman <jchapman@katalix.com>"); 379 398 MODULE_DESCRIPTION("DS1337 RTC driver"); 380 399 MODULE_LICENSE("GPL"); 400 + 401 + EXPORT_SYMBOL_GPL(ds1337_do_command); 381 402 382 403 module_init(ds1337_init); 383 404 module_exit(ds1337_exit);
+260
drivers/i2c/chips/ds1374.c
··· 1 + /* 2 + * drivers/i2c/chips/ds1374.c 3 + * 4 + * I2C client/driver for the Maxim/Dallas DS1374 Real-Time Clock 5 + * 6 + * Author: Randy Vinson <rvinson@mvista.com> 7 + * 8 + * Based on the m41t00.c by Mark Greer <mgreer@mvista.com> 9 + * 10 + * 2005 (c) MontaVista Software, Inc. This file is licensed under 11 + * the terms of the GNU General Public License version 2. This program 12 + * is licensed "as is" without any warranty of any kind, whether express 13 + * or implied. 14 + */ 15 + /* 16 + * This i2c client/driver wedges between the drivers/char/genrtc.c RTC 17 + * interface and the SMBus interface of the i2c subsystem. 18 + * It would be more efficient to use i2c msgs/i2c_transfer directly but, as 19 + * recommened in .../Documentation/i2c/writing-clients section 20 + * "Sending and receiving", using SMBus level communication is preferred. 21 + */ 22 + 23 + #include <linux/kernel.h> 24 + #include <linux/module.h> 25 + #include <linux/interrupt.h> 26 + #include <linux/i2c.h> 27 + #include <linux/rtc.h> 28 + #include <linux/bcd.h> 29 + 30 + #define DS1374_REG_TOD0 0x00 31 + #define DS1374_REG_TOD1 0x01 32 + #define DS1374_REG_TOD2 0x02 33 + #define DS1374_REG_TOD3 0x03 34 + #define DS1374_REG_WDALM0 0x04 35 + #define DS1374_REG_WDALM1 0x05 36 + #define DS1374_REG_WDALM2 0x06 37 + #define DS1374_REG_CR 0x07 38 + #define DS1374_REG_SR 0x08 39 + #define DS1374_REG_SR_OSF 0x80 40 + #define DS1374_REG_TCR 0x09 41 + 42 + #define DS1374_DRV_NAME "ds1374" 43 + 44 + static DECLARE_MUTEX(ds1374_mutex); 45 + 46 + static struct i2c_driver ds1374_driver; 47 + static struct i2c_client *save_client; 48 + 49 + static unsigned short ignore[] = { I2C_CLIENT_END }; 50 + static unsigned short normal_addr[] = { 0x68, I2C_CLIENT_END }; 51 + 52 + static struct i2c_client_address_data addr_data = { 53 + .normal_i2c = normal_addr, 54 + .probe = ignore, 55 + .ignore = ignore, 56 + .force = ignore, 57 + }; 58 + 59 + static ulong ds1374_read_rtc(void) 60 + { 61 + ulong time = 0; 62 + int reg = DS1374_REG_WDALM0; 63 + 64 + while (reg--) { 65 + s32 tmp; 66 + if ((tmp = i2c_smbus_read_byte_data(save_client, reg)) < 0) { 67 + dev_warn(&save_client->dev, 68 + "can't read from rtc chip\n"); 69 + return 0; 70 + } 71 + time = (time << 8) | (tmp & 0xff); 72 + } 73 + return time; 74 + } 75 + 76 + static void ds1374_write_rtc(ulong time) 77 + { 78 + int reg; 79 + 80 + for (reg = DS1374_REG_TOD0; reg < DS1374_REG_WDALM0; reg++) { 81 + if (i2c_smbus_write_byte_data(save_client, reg, time & 0xff) 82 + < 0) { 83 + dev_warn(&save_client->dev, 84 + "can't write to rtc chip\n"); 85 + break; 86 + } 87 + time = time >> 8; 88 + } 89 + } 90 + 91 + static void ds1374_check_rtc_status(void) 92 + { 93 + s32 tmp; 94 + 95 + tmp = i2c_smbus_read_byte_data(save_client, DS1374_REG_SR); 96 + if (tmp < 0) { 97 + dev_warn(&save_client->dev, 98 + "can't read status from rtc chip\n"); 99 + return; 100 + } 101 + if (tmp & DS1374_REG_SR_OSF) { 102 + dev_warn(&save_client->dev, 103 + "oscillator discontinuity flagged, time unreliable\n"); 104 + tmp &= ~DS1374_REG_SR_OSF; 105 + tmp = i2c_smbus_write_byte_data(save_client, DS1374_REG_SR, 106 + tmp & 0xff); 107 + if (tmp < 0) 108 + dev_warn(&save_client->dev, 109 + "can't clear discontinuity notification\n"); 110 + } 111 + } 112 + 113 + ulong ds1374_get_rtc_time(void) 114 + { 115 + ulong t1, t2; 116 + int limit = 10; /* arbitrary retry limit */ 117 + 118 + down(&ds1374_mutex); 119 + 120 + /* 121 + * Since the reads are being performed one byte at a time using 122 + * the SMBus vs a 4-byte i2c transfer, there is a chance that a 123 + * carry will occur during the read. To detect this, 2 reads are 124 + * performed and compared. 125 + */ 126 + do { 127 + t1 = ds1374_read_rtc(); 128 + t2 = ds1374_read_rtc(); 129 + } while (t1 != t2 && limit--); 130 + 131 + up(&ds1374_mutex); 132 + 133 + if (t1 != t2) { 134 + dev_warn(&save_client->dev, 135 + "can't get consistent time from rtc chip\n"); 136 + t1 = 0; 137 + } 138 + 139 + return t1; 140 + } 141 + 142 + static void ds1374_set_tlet(ulong arg) 143 + { 144 + ulong t1, t2; 145 + int limit = 10; /* arbitrary retry limit */ 146 + 147 + t1 = *(ulong *) arg; 148 + 149 + down(&ds1374_mutex); 150 + 151 + /* 152 + * Since the writes are being performed one byte at a time using 153 + * the SMBus vs a 4-byte i2c transfer, there is a chance that a 154 + * carry will occur during the write. To detect this, the write 155 + * value is read back and compared. 156 + */ 157 + do { 158 + ds1374_write_rtc(t1); 159 + t2 = ds1374_read_rtc(); 160 + } while (t1 != t2 && limit--); 161 + 162 + up(&ds1374_mutex); 163 + 164 + if (t1 != t2) 165 + dev_warn(&save_client->dev, 166 + "can't confirm time set from rtc chip\n"); 167 + } 168 + 169 + ulong new_time; 170 + 171 + DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, (ulong) & new_time); 172 + 173 + int ds1374_set_rtc_time(ulong nowtime) 174 + { 175 + new_time = nowtime; 176 + 177 + if (in_interrupt()) 178 + tasklet_schedule(&ds1374_tasklet); 179 + else 180 + ds1374_set_tlet((ulong) & new_time); 181 + 182 + return 0; 183 + } 184 + 185 + /* 186 + ***************************************************************************** 187 + * 188 + * Driver Interface 189 + * 190 + ***************************************************************************** 191 + */ 192 + static int ds1374_probe(struct i2c_adapter *adap, int addr, int kind) 193 + { 194 + struct i2c_client *client; 195 + int rc; 196 + 197 + client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); 198 + if (!client) 199 + return -ENOMEM; 200 + 201 + memset(client, 0, sizeof(struct i2c_client)); 202 + strncpy(client->name, DS1374_DRV_NAME, I2C_NAME_SIZE); 203 + client->flags = I2C_DF_NOTIFY; 204 + client->addr = addr; 205 + client->adapter = adap; 206 + client->driver = &ds1374_driver; 207 + 208 + if ((rc = i2c_attach_client(client)) != 0) { 209 + kfree(client); 210 + return rc; 211 + } 212 + 213 + save_client = client; 214 + 215 + ds1374_check_rtc_status(); 216 + 217 + return 0; 218 + } 219 + 220 + static int ds1374_attach(struct i2c_adapter *adap) 221 + { 222 + return i2c_probe(adap, &addr_data, ds1374_probe); 223 + } 224 + 225 + static int ds1374_detach(struct i2c_client *client) 226 + { 227 + int rc; 228 + 229 + if ((rc = i2c_detach_client(client)) == 0) { 230 + kfree(i2c_get_clientdata(client)); 231 + tasklet_kill(&ds1374_tasklet); 232 + } 233 + return rc; 234 + } 235 + 236 + static struct i2c_driver ds1374_driver = { 237 + .owner = THIS_MODULE, 238 + .name = DS1374_DRV_NAME, 239 + .id = I2C_DRIVERID_DS1374, 240 + .flags = I2C_DF_NOTIFY, 241 + .attach_adapter = ds1374_attach, 242 + .detach_client = ds1374_detach, 243 + }; 244 + 245 + static int __init ds1374_init(void) 246 + { 247 + return i2c_add_driver(&ds1374_driver); 248 + } 249 + 250 + static void __exit ds1374_exit(void) 251 + { 252 + i2c_del_driver(&ds1374_driver); 253 + } 254 + 255 + module_init(ds1374_init); 256 + module_exit(ds1374_exit); 257 + 258 + MODULE_AUTHOR("Randy Vinson <rvinson@mvista.com>"); 259 + MODULE_DESCRIPTION("Maxim/Dallas DS1374 RTC I2C Client Driver"); 260 + MODULE_LICENSE("GPL");
+2 -2
drivers/i2c/chips/ds1621.c
··· 121 121 static void ds1621_init_client(struct i2c_client *client) 122 122 { 123 123 int reg = ds1621_read_value(client, DS1621_REG_CONF); 124 - /* switch to continous conversion mode */ 124 + /* switch to continuous conversion mode */ 125 125 reg &= ~ DS1621_REG_CONFIG_1SHOT; 126 126 127 127 /* setup output polarity */ ··· 303 303 data->temp_max = ds1621_read_value(client, 304 304 DS1621_REG_TEMP_MAX); 305 305 306 - /* reset alarms if neccessary */ 306 + /* reset alarms if necessary */ 307 307 new_conf = data->conf; 308 308 if (data->temp < data->temp_min) 309 309 new_conf &= ~DS1621_ALARM_TEMP_LOW;
-1
drivers/i2c/chips/eeprom.c
··· 26 26 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 27 */ 28 28 29 - #include <linux/config.h> 30 29 #include <linux/kernel.h> 31 30 #include <linux/init.h> 32 31 #include <linux/module.h>
-1
drivers/i2c/chips/fscher.c
··· 26 26 * and Philip Edelbrock <phil@netroedge.com> 27 27 */ 28 28 29 - #include <linux/config.h> 30 29 #include <linux/module.h> 31 30 #include <linux/init.h> 32 31 #include <linux/slab.h>
-1
drivers/i2c/chips/gl518sm.c
··· 36 36 * 2004-01-31 Code review and approval. (Jean Delvare) 37 37 */ 38 38 39 - #include <linux/config.h> 40 39 #include <linux/module.h> 41 40 #include <linux/init.h> 42 41 #include <linux/slab.h>
-1
drivers/i2c/chips/isp1301_omap.c
··· 145 145 static unsigned short normal_i2c[] = { 146 146 ISP_BASE, ISP_BASE + 1, 147 147 I2C_CLIENT_END }; 148 - static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 149 148 150 149 I2C_CLIENT_INSMOD; 151 150
+186 -210
drivers/i2c/chips/it87.c
··· 31 31 type at module load time. 32 32 */ 33 33 34 - #include <linux/config.h> 35 34 #include <linux/module.h> 36 35 #include <linux/init.h> 37 36 #include <linux/slab.h> ··· 38 39 #include <linux/i2c.h> 39 40 #include <linux/i2c-sensor.h> 40 41 #include <linux/i2c-vid.h> 42 + #include <linux/hwmon-sysfs.h> 41 43 #include <asm/io.h> 42 44 43 45 ··· 173 173 ((val)+500)/1000),-128,127)) 174 174 #define TEMP_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*1000) 175 175 176 - #define ALARMS_FROM_REG(val) (val) 177 - 178 176 #define PWM_TO_REG(val) ((val) >> 1) 179 177 #define PWM_FROM_REG(val) (((val)&0x7f) << 1) 180 178 ··· 239 241 .detach_client = it87_detach_client, 240 242 }; 241 243 242 - static ssize_t show_in(struct device *dev, char *buf, int nr) 244 + static ssize_t show_in(struct device *dev, struct device_attribute *attr, 245 + char *buf) 243 246 { 247 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 248 + int nr = sensor_attr->index; 249 + 244 250 struct it87_data *data = it87_update_device(dev); 245 251 return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr])); 246 252 } 247 253 248 - static ssize_t show_in_min(struct device *dev, char *buf, int nr) 254 + static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, 255 + char *buf) 249 256 { 257 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 258 + int nr = sensor_attr->index; 259 + 250 260 struct it87_data *data = it87_update_device(dev); 251 261 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr])); 252 262 } 253 263 254 - static ssize_t show_in_max(struct device *dev, char *buf, int nr) 264 + static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, 265 + char *buf) 255 266 { 267 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 268 + int nr = sensor_attr->index; 269 + 256 270 struct it87_data *data = it87_update_device(dev); 257 271 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr])); 258 272 } 259 273 260 - static ssize_t set_in_min(struct device *dev, const char *buf, 261 - size_t count, int nr) 274 + static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, 275 + const char *buf, size_t count) 262 276 { 277 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 278 + int nr = sensor_attr->index; 279 + 263 280 struct i2c_client *client = to_i2c_client(dev); 264 281 struct it87_data *data = i2c_get_clientdata(client); 265 282 unsigned long val = simple_strtoul(buf, NULL, 10); ··· 286 273 up(&data->update_lock); 287 274 return count; 288 275 } 289 - static ssize_t set_in_max(struct device *dev, const char *buf, 290 - size_t count, int nr) 276 + static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, 277 + const char *buf, size_t count) 291 278 { 279 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 280 + int nr = sensor_attr->index; 281 + 292 282 struct i2c_client *client = to_i2c_client(dev); 293 283 struct it87_data *data = i2c_get_clientdata(client); 294 284 unsigned long val = simple_strtoul(buf, NULL, 10); ··· 305 289 } 306 290 307 291 #define show_in_offset(offset) \ 308 - static ssize_t \ 309 - show_in##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 310 - { \ 311 - return show_in(dev, buf, offset); \ 312 - } \ 313 - static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); 292 + static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ 293 + show_in, NULL, offset); 314 294 315 295 #define limit_in_offset(offset) \ 316 - static ssize_t \ 317 - show_in##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ 318 - { \ 319 - return show_in_min(dev, buf, offset); \ 320 - } \ 321 - static ssize_t \ 322 - show_in##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ 323 - { \ 324 - return show_in_max(dev, buf, offset); \ 325 - } \ 326 - static ssize_t set_in##offset##_min (struct device *dev, struct device_attribute *attr, \ 327 - const char *buf, size_t count) \ 328 - { \ 329 - return set_in_min(dev, buf, count, offset); \ 330 - } \ 331 - static ssize_t set_in##offset##_max (struct device *dev, struct device_attribute *attr, \ 332 - const char *buf, size_t count) \ 333 - { \ 334 - return set_in_max(dev, buf, count, offset); \ 335 - } \ 336 - static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ 337 - show_in##offset##_min, set_in##offset##_min); \ 338 - static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ 339 - show_in##offset##_max, set_in##offset##_max); 296 + static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ 297 + show_in_min, set_in_min, offset); \ 298 + static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ 299 + show_in_max, set_in_max, offset); 340 300 341 301 show_in_offset(0); 342 302 limit_in_offset(0); ··· 333 341 show_in_offset(8); 334 342 335 343 /* 3 temperatures */ 336 - static ssize_t show_temp(struct device *dev, char *buf, int nr) 344 + static ssize_t show_temp(struct device *dev, struct device_attribute *attr, 345 + char *buf) 337 346 { 347 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 348 + int nr = sensor_attr->index; 349 + 338 350 struct it87_data *data = it87_update_device(dev); 339 351 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])); 340 352 } 341 - static ssize_t show_temp_max(struct device *dev, char *buf, int nr) 353 + static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, 354 + char *buf) 342 355 { 356 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 357 + int nr = sensor_attr->index; 358 + 343 359 struct it87_data *data = it87_update_device(dev); 344 360 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr])); 345 361 } 346 - static ssize_t show_temp_min(struct device *dev, char *buf, int nr) 362 + static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, 363 + char *buf) 347 364 { 365 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 366 + int nr = sensor_attr->index; 367 + 348 368 struct it87_data *data = it87_update_device(dev); 349 369 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[nr])); 350 370 } 351 - static ssize_t set_temp_max(struct device *dev, const char *buf, 352 - size_t count, int nr) 371 + static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, 372 + const char *buf, size_t count) 353 373 { 374 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 375 + int nr = sensor_attr->index; 376 + 354 377 struct i2c_client *client = to_i2c_client(dev); 355 378 struct it87_data *data = i2c_get_clientdata(client); 356 379 int val = simple_strtol(buf, NULL, 10); ··· 376 369 up(&data->update_lock); 377 370 return count; 378 371 } 379 - static ssize_t set_temp_min(struct device *dev, const char *buf, 380 - size_t count, int nr) 372 + static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, 373 + const char *buf, size_t count) 381 374 { 375 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 376 + int nr = sensor_attr->index; 377 + 382 378 struct i2c_client *client = to_i2c_client(dev); 383 379 struct it87_data *data = i2c_get_clientdata(client); 384 380 int val = simple_strtol(buf, NULL, 10); ··· 393 383 return count; 394 384 } 395 385 #define show_temp_offset(offset) \ 396 - static ssize_t show_temp_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 397 - { \ 398 - return show_temp(dev, buf, offset - 1); \ 399 - } \ 400 - static ssize_t \ 401 - show_temp_##offset##_max (struct device *dev, struct device_attribute *attr, char *buf) \ 402 - { \ 403 - return show_temp_max(dev, buf, offset - 1); \ 404 - } \ 405 - static ssize_t \ 406 - show_temp_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ 407 - { \ 408 - return show_temp_min(dev, buf, offset - 1); \ 409 - } \ 410 - static ssize_t set_temp_##offset##_max (struct device *dev, struct device_attribute *attr, \ 411 - const char *buf, size_t count) \ 412 - { \ 413 - return set_temp_max(dev, buf, count, offset - 1); \ 414 - } \ 415 - static ssize_t set_temp_##offset##_min (struct device *dev, struct device_attribute *attr, \ 416 - const char *buf, size_t count) \ 417 - { \ 418 - return set_temp_min(dev, buf, count, offset - 1); \ 419 - } \ 420 - static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \ 421 - static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ 422 - show_temp_##offset##_max, set_temp_##offset##_max); \ 423 - static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ 424 - show_temp_##offset##_min, set_temp_##offset##_min); 386 + static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ 387 + show_temp, NULL, offset - 1); \ 388 + static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ 389 + show_temp_max, set_temp_max, offset - 1); \ 390 + static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ 391 + show_temp_min, set_temp_min, offset - 1); 425 392 426 393 show_temp_offset(1); 427 394 show_temp_offset(2); 428 395 show_temp_offset(3); 429 396 430 - static ssize_t show_sensor(struct device *dev, char *buf, int nr) 397 + static ssize_t show_sensor(struct device *dev, struct device_attribute *attr, 398 + char *buf) 431 399 { 400 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 401 + int nr = sensor_attr->index; 402 + 432 403 struct it87_data *data = it87_update_device(dev); 433 404 u8 reg = data->sensor; /* In case the value is updated while we use it */ 434 405 ··· 419 428 return sprintf(buf, "2\n"); /* thermistor */ 420 429 return sprintf(buf, "0\n"); /* disabled */ 421 430 } 422 - static ssize_t set_sensor(struct device *dev, const char *buf, 423 - size_t count, int nr) 431 + static ssize_t set_sensor(struct device *dev, struct device_attribute *attr, 432 + const char *buf, size_t count) 424 433 { 434 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 435 + int nr = sensor_attr->index; 436 + 425 437 struct i2c_client *client = to_i2c_client(dev); 426 438 struct it87_data *data = i2c_get_clientdata(client); 427 439 int val = simple_strtol(buf, NULL, 10); ··· 447 453 return count; 448 454 } 449 455 #define show_sensor_offset(offset) \ 450 - static ssize_t show_sensor_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 451 - { \ 452 - return show_sensor(dev, buf, offset - 1); \ 453 - } \ 454 - static ssize_t set_sensor_##offset (struct device *dev, struct device_attribute *attr, \ 455 - const char *buf, size_t count) \ 456 - { \ 457 - return set_sensor(dev, buf, count, offset - 1); \ 458 - } \ 459 - static DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \ 460 - show_sensor_##offset, set_sensor_##offset); 456 + static SENSOR_DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \ 457 + show_sensor, set_sensor, offset - 1); 461 458 462 459 show_sensor_offset(1); 463 460 show_sensor_offset(2); 464 461 show_sensor_offset(3); 465 462 466 463 /* 3 Fans */ 467 - static ssize_t show_fan(struct device *dev, char *buf, int nr) 464 + static ssize_t show_fan(struct device *dev, struct device_attribute *attr, 465 + char *buf) 468 466 { 467 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 468 + int nr = sensor_attr->index; 469 + 469 470 struct it87_data *data = it87_update_device(dev); 470 471 return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], 471 472 DIV_FROM_REG(data->fan_div[nr]))); 472 473 } 473 - static ssize_t show_fan_min(struct device *dev, char *buf, int nr) 474 + static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, 475 + char *buf) 474 476 { 477 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 478 + int nr = sensor_attr->index; 479 + 475 480 struct it87_data *data = it87_update_device(dev); 476 481 return sprintf(buf,"%d\n", 477 482 FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr]))); 478 483 } 479 - static ssize_t show_fan_div(struct device *dev, char *buf, int nr) 484 + static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, 485 + char *buf) 480 486 { 487 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 488 + int nr = sensor_attr->index; 489 + 481 490 struct it87_data *data = it87_update_device(dev); 482 491 return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr])); 483 492 } 484 - static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr) 493 + static ssize_t show_pwm_enable(struct device *dev, struct device_attribute *attr, 494 + char *buf) 485 495 { 496 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 497 + int nr = sensor_attr->index; 498 + 486 499 struct it87_data *data = it87_update_device(dev); 487 500 return sprintf(buf,"%d\n", (data->fan_main_ctrl & (1 << nr)) ? 1 : 0); 488 501 } 489 - static ssize_t show_pwm(struct device *dev, char *buf, int nr) 502 + static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, 503 + char *buf) 490 504 { 505 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 506 + int nr = sensor_attr->index; 507 + 491 508 struct it87_data *data = it87_update_device(dev); 492 509 return sprintf(buf,"%d\n", data->manual_pwm_ctl[nr]); 493 510 } 494 - static ssize_t set_fan_min(struct device *dev, const char *buf, 495 - size_t count, int nr) 511 + static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, 512 + const char *buf, size_t count) 496 513 { 514 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 515 + int nr = sensor_attr->index; 516 + 497 517 struct i2c_client *client = to_i2c_client(dev); 498 518 struct it87_data *data = i2c_get_clientdata(client); 499 519 int val = simple_strtol(buf, NULL, 10); ··· 518 510 up(&data->update_lock); 519 511 return count; 520 512 } 521 - static ssize_t set_fan_div(struct device *dev, const char *buf, 522 - size_t count, int nr) 513 + static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, 514 + const char *buf, size_t count) 523 515 { 516 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 517 + int nr = sensor_attr->index; 518 + 524 519 struct i2c_client *client = to_i2c_client(dev); 525 520 struct it87_data *data = i2c_get_clientdata(client); 526 521 int val = simple_strtol(buf, NULL, 10); ··· 561 550 up(&data->update_lock); 562 551 return count; 563 552 } 564 - static ssize_t set_pwm_enable(struct device *dev, const char *buf, 565 - size_t count, int nr) 553 + static ssize_t set_pwm_enable(struct device *dev, 554 + struct device_attribute *attr, const char *buf, size_t count) 566 555 { 556 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 557 + int nr = sensor_attr->index; 558 + 567 559 struct i2c_client *client = to_i2c_client(dev); 568 560 struct it87_data *data = i2c_get_clientdata(client); 569 561 int val = simple_strtol(buf, NULL, 10); ··· 595 581 up(&data->update_lock); 596 582 return count; 597 583 } 598 - static ssize_t set_pwm(struct device *dev, const char *buf, 599 - size_t count, int nr) 584 + static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, 585 + const char *buf, size_t count) 600 586 { 587 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 588 + int nr = sensor_attr->index; 589 + 601 590 struct i2c_client *client = to_i2c_client(dev); 602 591 struct it87_data *data = i2c_get_clientdata(client); 603 592 int val = simple_strtol(buf, NULL, 10); ··· 616 599 return count; 617 600 } 618 601 619 - #define show_fan_offset(offset) \ 620 - static ssize_t show_fan_##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 621 - { \ 622 - return show_fan(dev, buf, offset - 1); \ 623 - } \ 624 - static ssize_t show_fan_##offset##_min (struct device *dev, struct device_attribute *attr, char *buf) \ 625 - { \ 626 - return show_fan_min(dev, buf, offset - 1); \ 627 - } \ 628 - static ssize_t show_fan_##offset##_div (struct device *dev, struct device_attribute *attr, char *buf) \ 629 - { \ 630 - return show_fan_div(dev, buf, offset - 1); \ 631 - } \ 632 - static ssize_t set_fan_##offset##_min (struct device *dev, struct device_attribute *attr, \ 633 - const char *buf, size_t count) \ 634 - { \ 635 - return set_fan_min(dev, buf, count, offset - 1); \ 636 - } \ 637 - static ssize_t set_fan_##offset##_div (struct device *dev, struct device_attribute *attr, \ 638 - const char *buf, size_t count) \ 639 - { \ 640 - return set_fan_div(dev, buf, count, offset - 1); \ 641 - } \ 642 - static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL); \ 643 - static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ 644 - show_fan_##offset##_min, set_fan_##offset##_min); \ 645 - static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ 646 - show_fan_##offset##_div, set_fan_##offset##_div); 602 + #define show_fan_offset(offset) \ 603 + static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ 604 + show_fan, NULL, offset - 1); \ 605 + static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ 606 + show_fan_min, set_fan_min, offset - 1); \ 607 + static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ 608 + show_fan_div, set_fan_div, offset - 1); 647 609 648 610 show_fan_offset(1); 649 611 show_fan_offset(2); 650 612 show_fan_offset(3); 651 613 652 614 #define show_pwm_offset(offset) \ 653 - static ssize_t show_pwm##offset##_enable (struct device *dev, struct device_attribute *attr, \ 654 - char *buf) \ 655 - { \ 656 - return show_pwm_enable(dev, buf, offset - 1); \ 657 - } \ 658 - static ssize_t show_pwm##offset (struct device *dev, struct device_attribute *attr, char *buf) \ 659 - { \ 660 - return show_pwm(dev, buf, offset - 1); \ 661 - } \ 662 - static ssize_t set_pwm##offset##_enable (struct device *dev, struct device_attribute *attr, \ 663 - const char *buf, size_t count) \ 664 - { \ 665 - return set_pwm_enable(dev, buf, count, offset - 1); \ 666 - } \ 667 - static ssize_t set_pwm##offset (struct device *dev, struct device_attribute *attr, \ 668 - const char *buf, size_t count) \ 669 - { \ 670 - return set_pwm(dev, buf, count, offset - 1); \ 671 - } \ 672 - static DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ 673 - show_pwm##offset##_enable, \ 674 - set_pwm##offset##_enable); \ 675 - static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ 676 - show_pwm##offset , set_pwm##offset ); 615 + static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ 616 + show_pwm_enable, set_pwm_enable, offset - 1); \ 617 + static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ 618 + show_pwm, set_pwm, offset - 1); 677 619 678 620 show_pwm_offset(1); 679 621 show_pwm_offset(2); ··· 642 666 static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 643 667 { 644 668 struct it87_data *data = it87_update_device(dev); 645 - return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms)); 669 + return sprintf(buf, "%u\n", data->alarms); 646 670 } 647 671 static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 648 672 ··· 840 864 it87_init_client(new_client, data); 841 865 842 866 /* Register sysfs hooks */ 843 - device_create_file(&new_client->dev, &dev_attr_in0_input); 844 - device_create_file(&new_client->dev, &dev_attr_in1_input); 845 - device_create_file(&new_client->dev, &dev_attr_in2_input); 846 - device_create_file(&new_client->dev, &dev_attr_in3_input); 847 - device_create_file(&new_client->dev, &dev_attr_in4_input); 848 - device_create_file(&new_client->dev, &dev_attr_in5_input); 849 - device_create_file(&new_client->dev, &dev_attr_in6_input); 850 - device_create_file(&new_client->dev, &dev_attr_in7_input); 851 - device_create_file(&new_client->dev, &dev_attr_in8_input); 852 - device_create_file(&new_client->dev, &dev_attr_in0_min); 853 - device_create_file(&new_client->dev, &dev_attr_in1_min); 854 - device_create_file(&new_client->dev, &dev_attr_in2_min); 855 - device_create_file(&new_client->dev, &dev_attr_in3_min); 856 - device_create_file(&new_client->dev, &dev_attr_in4_min); 857 - device_create_file(&new_client->dev, &dev_attr_in5_min); 858 - device_create_file(&new_client->dev, &dev_attr_in6_min); 859 - device_create_file(&new_client->dev, &dev_attr_in7_min); 860 - device_create_file(&new_client->dev, &dev_attr_in0_max); 861 - device_create_file(&new_client->dev, &dev_attr_in1_max); 862 - device_create_file(&new_client->dev, &dev_attr_in2_max); 863 - device_create_file(&new_client->dev, &dev_attr_in3_max); 864 - device_create_file(&new_client->dev, &dev_attr_in4_max); 865 - device_create_file(&new_client->dev, &dev_attr_in5_max); 866 - device_create_file(&new_client->dev, &dev_attr_in6_max); 867 - device_create_file(&new_client->dev, &dev_attr_in7_max); 868 - device_create_file(&new_client->dev, &dev_attr_temp1_input); 869 - device_create_file(&new_client->dev, &dev_attr_temp2_input); 870 - device_create_file(&new_client->dev, &dev_attr_temp3_input); 871 - device_create_file(&new_client->dev, &dev_attr_temp1_max); 872 - device_create_file(&new_client->dev, &dev_attr_temp2_max); 873 - device_create_file(&new_client->dev, &dev_attr_temp3_max); 874 - device_create_file(&new_client->dev, &dev_attr_temp1_min); 875 - device_create_file(&new_client->dev, &dev_attr_temp2_min); 876 - device_create_file(&new_client->dev, &dev_attr_temp3_min); 877 - device_create_file(&new_client->dev, &dev_attr_temp1_type); 878 - device_create_file(&new_client->dev, &dev_attr_temp2_type); 879 - device_create_file(&new_client->dev, &dev_attr_temp3_type); 880 - device_create_file(&new_client->dev, &dev_attr_fan1_input); 881 - device_create_file(&new_client->dev, &dev_attr_fan2_input); 882 - device_create_file(&new_client->dev, &dev_attr_fan3_input); 883 - device_create_file(&new_client->dev, &dev_attr_fan1_min); 884 - device_create_file(&new_client->dev, &dev_attr_fan2_min); 885 - device_create_file(&new_client->dev, &dev_attr_fan3_min); 886 - device_create_file(&new_client->dev, &dev_attr_fan1_div); 887 - device_create_file(&new_client->dev, &dev_attr_fan2_div); 888 - device_create_file(&new_client->dev, &dev_attr_fan3_div); 867 + device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); 868 + device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr); 869 + device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr); 870 + device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr); 871 + device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr); 872 + device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr); 873 + device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr); 874 + device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr); 875 + device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr); 876 + device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr); 877 + device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr); 878 + device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr); 879 + device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr); 880 + device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr); 881 + device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr); 882 + device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr); 883 + device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr); 884 + device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr); 885 + device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr); 886 + device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr); 887 + device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr); 888 + device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr); 889 + device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr); 890 + device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr); 891 + device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr); 892 + device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr); 893 + device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr); 894 + device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr); 895 + device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr); 896 + device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr); 897 + device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr); 898 + device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr); 899 + device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr); 900 + device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr); 901 + device_create_file(&new_client->dev, &sensor_dev_attr_temp1_type.dev_attr); 902 + device_create_file(&new_client->dev, &sensor_dev_attr_temp2_type.dev_attr); 903 + device_create_file(&new_client->dev, &sensor_dev_attr_temp3_type.dev_attr); 904 + device_create_file(&new_client->dev, &sensor_dev_attr_fan1_input.dev_attr); 905 + device_create_file(&new_client->dev, &sensor_dev_attr_fan2_input.dev_attr); 906 + device_create_file(&new_client->dev, &sensor_dev_attr_fan3_input.dev_attr); 907 + device_create_file(&new_client->dev, &sensor_dev_attr_fan1_min.dev_attr); 908 + device_create_file(&new_client->dev, &sensor_dev_attr_fan2_min.dev_attr); 909 + device_create_file(&new_client->dev, &sensor_dev_attr_fan3_min.dev_attr); 910 + device_create_file(&new_client->dev, &sensor_dev_attr_fan1_div.dev_attr); 911 + device_create_file(&new_client->dev, &sensor_dev_attr_fan2_div.dev_attr); 912 + device_create_file(&new_client->dev, &sensor_dev_attr_fan3_div.dev_attr); 889 913 device_create_file(&new_client->dev, &dev_attr_alarms); 890 914 if (enable_pwm_interface) { 891 - device_create_file(&new_client->dev, &dev_attr_pwm1_enable); 892 - device_create_file(&new_client->dev, &dev_attr_pwm2_enable); 893 - device_create_file(&new_client->dev, &dev_attr_pwm3_enable); 894 - device_create_file(&new_client->dev, &dev_attr_pwm1); 895 - device_create_file(&new_client->dev, &dev_attr_pwm2); 896 - device_create_file(&new_client->dev, &dev_attr_pwm3); 915 + device_create_file(&new_client->dev, &sensor_dev_attr_pwm1_enable.dev_attr); 916 + device_create_file(&new_client->dev, &sensor_dev_attr_pwm2_enable.dev_attr); 917 + device_create_file(&new_client->dev, &sensor_dev_attr_pwm3_enable.dev_attr); 918 + device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr); 919 + device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr); 920 + device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr); 897 921 } 898 922 899 923 if (data->type == it8712) { ··· 930 954 return 0; 931 955 } 932 956 933 - /* The SMBus locks itself, but ISA access must be locked explicitely! 957 + /* The SMBus locks itself, but ISA access must be locked explicitly! 934 958 We don't want to lock the whole ISA bus, so we lock each client 935 959 separately. 936 960 We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks, ··· 950 974 return i2c_smbus_read_byte_data(client, reg); 951 975 } 952 976 953 - /* The SMBus locks itself, but ISA access muse be locked explicitely! 977 + /* The SMBus locks itself, but ISA access muse be locked explicitly! 954 978 We don't want to lock the whole ISA bus, so we lock each client 955 979 separately. 956 980 We ignore the IT87 BUSY flag at this moment - it could lead to deadlocks,
+139 -123
drivers/i2c/chips/lm63.c
··· 1 1 /* 2 2 * lm63.c - driver for the National Semiconductor LM63 temperature sensor 3 3 * with integrated fan control 4 - * Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> 4 + * Copyright (C) 2004-2005 Jean Delvare <khali@linux-fr.org> 5 5 * Based on the lm90 driver. 6 6 * 7 7 * The LM63 is a sensor chip made by National Semiconductor. It measures ··· 37 37 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 38 38 */ 39 39 40 - #include <linux/config.h> 41 40 #include <linux/module.h> 42 41 #include <linux/init.h> 43 42 #include <linux/slab.h> 44 43 #include <linux/jiffies.h> 45 44 #include <linux/i2c.h> 46 45 #include <linux/i2c-sensor.h> 46 + #include <linux/hwmon-sysfs.h> 47 47 48 48 /* 49 49 * Addresses to scan ··· 99 99 * Conversions and various macros 100 100 * For tachometer counts, the LM63 uses 16-bit values. 101 101 * For local temperature and high limit, remote critical limit and hysteresis 102 - * value, it uses signed 8-bit values with LSB = 1 degree Celcius. 102 + * value, it uses signed 8-bit values with LSB = 1 degree Celsius. 103 103 * For remote temperature, low and high limits, it uses signed 11-bit values 104 - * with LSB = 0.125 degree Celcius, left-justified in 16-bit registers. 104 + * with LSB = 0.125 degree Celsius, left-justified in 16-bit registers. 105 105 */ 106 106 107 107 #define FAN_FROM_REG(reg) ((reg) == 0xFFFC || (reg) == 0 ? 0 : \ ··· 158 158 159 159 /* registers values */ 160 160 u8 config, config_fan; 161 - u16 fan1_input; 162 - u16 fan1_low; 161 + u16 fan[2]; /* 0: input 162 + 1: low limit */ 163 163 u8 pwm1_freq; 164 164 u8 pwm1_value; 165 - s8 temp1_input; 166 - s8 temp1_high; 167 - s16 temp2_input; 168 - s16 temp2_high; 169 - s16 temp2_low; 170 - s8 temp2_crit; 165 + s8 temp8[3]; /* 0: local input 166 + 1: local high limit 167 + 2: remote critical limit */ 168 + s16 temp11[3]; /* 0: remote input 169 + 1: remote low limit 170 + 2: remote high limit */ 171 171 u8 temp2_crit_hyst; 172 172 u8 alarms; 173 173 }; ··· 176 176 * Sysfs callback functions and files 177 177 */ 178 178 179 - #define show_fan(value) \ 180 - static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ 181 - { \ 182 - struct lm63_data *data = lm63_update_device(dev); \ 183 - return sprintf(buf, "%d\n", FAN_FROM_REG(data->value)); \ 179 + static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, 180 + char *buf) 181 + { 182 + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 183 + struct lm63_data *data = lm63_update_device(dev); 184 + return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[attr->index])); 184 185 } 185 - show_fan(fan1_input); 186 - show_fan(fan1_low); 187 186 188 - static ssize_t set_fan1_low(struct device *dev, struct device_attribute *attr, const char *buf, 189 - size_t count) 187 + static ssize_t set_fan(struct device *dev, struct device_attribute *dummy, 188 + const char *buf, size_t count) 190 189 { 191 190 struct i2c_client *client = to_i2c_client(dev); 192 191 struct lm63_data *data = i2c_get_clientdata(client); 193 192 unsigned long val = simple_strtoul(buf, NULL, 10); 194 193 195 194 down(&data->update_lock); 196 - data->fan1_low = FAN_TO_REG(val); 195 + data->fan[1] = FAN_TO_REG(val); 197 196 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB, 198 - data->fan1_low & 0xFF); 197 + data->fan[1] & 0xFF); 199 198 i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB, 200 - data->fan1_low >> 8); 199 + data->fan[1] >> 8); 201 200 up(&data->update_lock); 202 201 return count; 203 202 } 204 203 205 - static ssize_t show_pwm1(struct device *dev, struct device_attribute *attr, char *buf) 204 + static ssize_t show_pwm1(struct device *dev, struct device_attribute *dummy, 205 + char *buf) 206 206 { 207 207 struct lm63_data *data = lm63_update_device(dev); 208 208 return sprintf(buf, "%d\n", data->pwm1_value >= 2 * data->pwm1_freq ? ··· 210 210 (2 * data->pwm1_freq)); 211 211 } 212 212 213 - static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 213 + static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy, 214 + const char *buf, size_t count) 214 215 { 215 216 struct i2c_client *client = to_i2c_client(dev); 216 217 struct lm63_data *data = i2c_get_clientdata(client); ··· 230 229 return count; 231 230 } 232 231 233 - static ssize_t show_pwm1_enable(struct device *dev, struct device_attribute *attr, char *buf) 232 + static ssize_t show_pwm1_enable(struct device *dev, struct device_attribute *dummy, 233 + char *buf) 234 234 { 235 235 struct lm63_data *data = lm63_update_device(dev); 236 236 return sprintf(buf, "%d\n", data->config_fan & 0x20 ? 1 : 2); 237 237 } 238 238 239 - #define show_temp8(value) \ 240 - static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ 241 - { \ 242 - struct lm63_data *data = lm63_update_device(dev); \ 243 - return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->value)); \ 239 + static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr, 240 + char *buf) 241 + { 242 + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 243 + struct lm63_data *data = lm63_update_device(dev); 244 + return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[attr->index])); 244 245 } 245 - #define show_temp11(value) \ 246 - static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ 247 - { \ 248 - struct lm63_data *data = lm63_update_device(dev); \ 249 - return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->value)); \ 250 - } 251 - show_temp8(temp1_input); 252 - show_temp8(temp1_high); 253 - show_temp11(temp2_input); 254 - show_temp11(temp2_high); 255 - show_temp11(temp2_low); 256 - show_temp8(temp2_crit); 257 246 258 - #define set_temp8(value, reg) \ 259 - static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ 260 - size_t count) \ 261 - { \ 262 - struct i2c_client *client = to_i2c_client(dev); \ 263 - struct lm63_data *data = i2c_get_clientdata(client); \ 264 - long val = simple_strtol(buf, NULL, 10); \ 265 - \ 266 - down(&data->update_lock); \ 267 - data->value = TEMP8_TO_REG(val); \ 268 - i2c_smbus_write_byte_data(client, reg, data->value); \ 269 - up(&data->update_lock); \ 270 - return count; \ 247 + static ssize_t set_temp8(struct device *dev, struct device_attribute *dummy, 248 + const char *buf, size_t count) 249 + { 250 + struct i2c_client *client = to_i2c_client(dev); 251 + struct lm63_data *data = i2c_get_clientdata(client); 252 + long val = simple_strtol(buf, NULL, 10); 253 + 254 + down(&data->update_lock); 255 + data->temp8[1] = TEMP8_TO_REG(val); 256 + i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]); 257 + up(&data->update_lock); 258 + return count; 271 259 } 272 - #define set_temp11(value, reg_msb, reg_lsb) \ 273 - static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ 274 - size_t count) \ 275 - { \ 276 - struct i2c_client *client = to_i2c_client(dev); \ 277 - struct lm63_data *data = i2c_get_clientdata(client); \ 278 - long val = simple_strtol(buf, NULL, 10); \ 279 - \ 280 - down(&data->update_lock); \ 281 - data->value = TEMP11_TO_REG(val); \ 282 - i2c_smbus_write_byte_data(client, reg_msb, data->value >> 8); \ 283 - i2c_smbus_write_byte_data(client, reg_lsb, data->value & 0xff); \ 284 - up(&data->update_lock); \ 285 - return count; \ 260 + 261 + static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr, 262 + char *buf) 263 + { 264 + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 265 + struct lm63_data *data = lm63_update_device(dev); 266 + return sprintf(buf, "%d\n", TEMP11_FROM_REG(data->temp11[attr->index])); 286 267 } 287 - set_temp8(temp1_high, LM63_REG_LOCAL_HIGH); 288 - set_temp11(temp2_high, LM63_REG_REMOTE_HIGH_MSB, LM63_REG_REMOTE_HIGH_LSB); 289 - set_temp11(temp2_low, LM63_REG_REMOTE_LOW_MSB, LM63_REG_REMOTE_LOW_LSB); 268 + 269 + static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, 270 + const char *buf, size_t count) 271 + { 272 + static const u8 reg[4] = { 273 + LM63_REG_REMOTE_LOW_MSB, 274 + LM63_REG_REMOTE_LOW_LSB, 275 + LM63_REG_REMOTE_HIGH_MSB, 276 + LM63_REG_REMOTE_HIGH_LSB, 277 + }; 278 + 279 + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 280 + struct i2c_client *client = to_i2c_client(dev); 281 + struct lm63_data *data = i2c_get_clientdata(client); 282 + long val = simple_strtol(buf, NULL, 10); 283 + int nr = attr->index; 284 + 285 + down(&data->update_lock); 286 + data->temp11[nr] = TEMP11_TO_REG(val); 287 + i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], 288 + data->temp11[nr] >> 8); 289 + i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], 290 + data->temp11[nr] & 0xff); 291 + up(&data->update_lock); 292 + return count; 293 + } 290 294 291 295 /* Hysteresis register holds a relative value, while we want to present 292 296 an absolute to user-space */ 293 - static ssize_t show_temp2_crit_hyst(struct device *dev, struct device_attribute *attr, char *buf) 297 + static ssize_t show_temp2_crit_hyst(struct device *dev, struct device_attribute *dummy, 298 + char *buf) 294 299 { 295 300 struct lm63_data *data = lm63_update_device(dev); 296 - return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp2_crit) 301 + return sprintf(buf, "%d\n", TEMP8_FROM_REG(data->temp8[2]) 297 302 - TEMP8_FROM_REG(data->temp2_crit_hyst)); 298 303 } 299 304 300 305 /* And now the other way around, user-space provides an absolute 301 306 hysteresis value and we have to store a relative one */ 302 - static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *attr, const char *buf, 303 - size_t count) 307 + static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *dummy, 308 + const char *buf, size_t count) 304 309 { 305 310 struct i2c_client *client = to_i2c_client(dev); 306 311 struct lm63_data *data = i2c_get_clientdata(client); ··· 314 307 long hyst; 315 308 316 309 down(&data->update_lock); 317 - hyst = TEMP8_FROM_REG(data->temp2_crit) - val; 310 + hyst = TEMP8_FROM_REG(data->temp8[2]) - val; 318 311 i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST, 319 312 HYST_TO_REG(hyst)); 320 313 up(&data->update_lock); 321 314 return count; 322 315 } 323 316 324 - static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 317 + static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy, 318 + char *buf) 325 319 { 326 320 struct lm63_data *data = lm63_update_device(dev); 327 321 return sprintf(buf, "%u\n", data->alarms); 328 322 } 329 323 330 - static DEVICE_ATTR(fan1_input, S_IRUGO, show_fan1_input, NULL); 331 - static DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan1_low, 332 - set_fan1_low); 324 + static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); 325 + static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan, 326 + set_fan, 1); 333 327 334 328 static DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm1, set_pwm1); 335 329 static DEVICE_ATTR(pwm1_enable, S_IRUGO, show_pwm1_enable, NULL); 336 330 337 - static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1_input, NULL); 338 - static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp1_high, 339 - set_temp1_high); 331 + static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp8, NULL, 0); 332 + static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8, 333 + set_temp8, 1); 340 334 341 - static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp2_input, NULL); 342 - static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp2_low, 343 - set_temp2_low); 344 - static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp2_high, 345 - set_temp2_high); 346 - static DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp2_crit, NULL); 335 + static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0); 336 + static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11, 337 + set_temp11, 1); 338 + static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11, 339 + set_temp11, 2); 340 + static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp8, NULL, 2); 347 341 static DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp2_crit_hyst, 348 342 set_temp2_crit_hyst); 349 343 ··· 438 430 439 431 /* Register sysfs hooks */ 440 432 if (data->config & 0x04) { /* tachometer enabled */ 441 - device_create_file(&new_client->dev, &dev_attr_fan1_input); 442 - device_create_file(&new_client->dev, &dev_attr_fan1_min); 433 + device_create_file(&new_client->dev, 434 + &sensor_dev_attr_fan1_input.dev_attr); 435 + device_create_file(&new_client->dev, 436 + &sensor_dev_attr_fan1_min.dev_attr); 443 437 } 444 438 device_create_file(&new_client->dev, &dev_attr_pwm1); 445 439 device_create_file(&new_client->dev, &dev_attr_pwm1_enable); 446 - device_create_file(&new_client->dev, &dev_attr_temp1_input); 447 - device_create_file(&new_client->dev, &dev_attr_temp2_input); 448 - device_create_file(&new_client->dev, &dev_attr_temp2_min); 449 - device_create_file(&new_client->dev, &dev_attr_temp1_max); 450 - device_create_file(&new_client->dev, &dev_attr_temp2_max); 451 - device_create_file(&new_client->dev, &dev_attr_temp2_crit); 440 + device_create_file(&new_client->dev, 441 + &sensor_dev_attr_temp1_input.dev_attr); 442 + device_create_file(&new_client->dev, 443 + &sensor_dev_attr_temp2_input.dev_attr); 444 + device_create_file(&new_client->dev, 445 + &sensor_dev_attr_temp2_min.dev_attr); 446 + device_create_file(&new_client->dev, 447 + &sensor_dev_attr_temp1_max.dev_attr); 448 + device_create_file(&new_client->dev, 449 + &sensor_dev_attr_temp2_max.dev_attr); 450 + device_create_file(&new_client->dev, 451 + &sensor_dev_attr_temp2_crit.dev_attr); 452 452 device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst); 453 453 device_create_file(&new_client->dev, &dev_attr_alarms); 454 454 ··· 527 511 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { 528 512 if (data->config & 0x04) { /* tachometer enabled */ 529 513 /* order matters for fan1_input */ 530 - data->fan1_input = i2c_smbus_read_byte_data(client, 531 - LM63_REG_TACH_COUNT_LSB) & 0xFC; 532 - data->fan1_input |= i2c_smbus_read_byte_data(client, 533 - LM63_REG_TACH_COUNT_MSB) << 8; 534 - data->fan1_low = (i2c_smbus_read_byte_data(client, 535 - LM63_REG_TACH_LIMIT_LSB) & 0xFC) 536 - | (i2c_smbus_read_byte_data(client, 537 - LM63_REG_TACH_LIMIT_MSB) << 8); 514 + data->fan[0] = i2c_smbus_read_byte_data(client, 515 + LM63_REG_TACH_COUNT_LSB) & 0xFC; 516 + data->fan[0] |= i2c_smbus_read_byte_data(client, 517 + LM63_REG_TACH_COUNT_MSB) << 8; 518 + data->fan[1] = (i2c_smbus_read_byte_data(client, 519 + LM63_REG_TACH_LIMIT_LSB) & 0xFC) 520 + | (i2c_smbus_read_byte_data(client, 521 + LM63_REG_TACH_LIMIT_MSB) << 8); 538 522 } 539 523 540 524 data->pwm1_freq = i2c_smbus_read_byte_data(client, ··· 544 528 data->pwm1_value = i2c_smbus_read_byte_data(client, 545 529 LM63_REG_PWM_VALUE); 546 530 547 - data->temp1_input = i2c_smbus_read_byte_data(client, 548 - LM63_REG_LOCAL_TEMP); 549 - data->temp1_high = i2c_smbus_read_byte_data(client, 550 - LM63_REG_LOCAL_HIGH); 531 + data->temp8[0] = i2c_smbus_read_byte_data(client, 532 + LM63_REG_LOCAL_TEMP); 533 + data->temp8[1] = i2c_smbus_read_byte_data(client, 534 + LM63_REG_LOCAL_HIGH); 551 535 552 536 /* order matters for temp2_input */ 553 - data->temp2_input = i2c_smbus_read_byte_data(client, 554 - LM63_REG_REMOTE_TEMP_MSB) << 8; 555 - data->temp2_input |= i2c_smbus_read_byte_data(client, 556 - LM63_REG_REMOTE_TEMP_LSB); 557 - data->temp2_high = (i2c_smbus_read_byte_data(client, 558 - LM63_REG_REMOTE_HIGH_MSB) << 8) 559 - | i2c_smbus_read_byte_data(client, 560 - LM63_REG_REMOTE_HIGH_LSB); 561 - data->temp2_low = (i2c_smbus_read_byte_data(client, 537 + data->temp11[0] = i2c_smbus_read_byte_data(client, 538 + LM63_REG_REMOTE_TEMP_MSB) << 8; 539 + data->temp11[0] |= i2c_smbus_read_byte_data(client, 540 + LM63_REG_REMOTE_TEMP_LSB); 541 + data->temp11[1] = (i2c_smbus_read_byte_data(client, 562 542 LM63_REG_REMOTE_LOW_MSB) << 8) 563 543 | i2c_smbus_read_byte_data(client, 564 544 LM63_REG_REMOTE_LOW_LSB); 565 - data->temp2_crit = i2c_smbus_read_byte_data(client, 566 - LM63_REG_REMOTE_TCRIT); 545 + data->temp11[2] = (i2c_smbus_read_byte_data(client, 546 + LM63_REG_REMOTE_HIGH_MSB) << 8) 547 + | i2c_smbus_read_byte_data(client, 548 + LM63_REG_REMOTE_HIGH_LSB); 549 + data->temp8[2] = i2c_smbus_read_byte_data(client, 550 + LM63_REG_REMOTE_TCRIT); 567 551 data->temp2_crit_hyst = i2c_smbus_read_byte_data(client, 568 552 LM63_REG_REMOTE_TCRIT_HYST); 569 553
-1
drivers/i2c/chips/lm75.c
··· 18 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 19 */ 20 20 21 - #include <linux/config.h> 22 21 #include <linux/module.h> 23 22 #include <linux/init.h> 24 23 #include <linux/slab.h>
-1
drivers/i2c/chips/lm77.c
··· 25 25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 26 */ 27 27 28 - #include <linux/config.h> 29 28 #include <linux/module.h> 30 29 #include <linux/init.h> 31 30 #include <linux/slab.h>
+2 -3
drivers/i2c/chips/lm78.c
··· 18 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 19 */ 20 20 21 - #include <linux/config.h> 22 21 #include <linux/module.h> 23 22 #include <linux/init.h> 24 23 #include <linux/slab.h> ··· 670 671 return 0; 671 672 } 672 673 673 - /* The SMBus locks itself, but ISA access must be locked explicitely! 674 + /* The SMBus locks itself, but ISA access must be locked explicitly! 674 675 We don't want to lock the whole ISA bus, so we lock each client 675 676 separately. 676 677 We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks, ··· 689 690 return i2c_smbus_read_byte_data(client, reg); 690 691 } 691 692 692 - /* The SMBus locks itself, but ISA access muse be locked explicitely! 693 + /* The SMBus locks itself, but ISA access muse be locked explicitly! 693 694 We don't want to lock the whole ISA bus, so we lock each client 694 695 separately. 695 696 We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks,
-1
drivers/i2c/chips/lm80.c
··· 21 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 22 */ 23 23 24 - #include <linux/config.h> 25 24 #include <linux/module.h> 26 25 #include <linux/init.h> 27 26 #include <linux/slab.h>
+77 -81
drivers/i2c/chips/lm83.c
··· 1 1 /* 2 2 * lm83.c - Part of lm_sensors, Linux kernel modules for hardware 3 3 * monitoring 4 - * Copyright (C) 2003 Jean Delvare <khali@linux-fr.org> 4 + * Copyright (C) 2003-2005 Jean Delvare <khali@linux-fr.org> 5 5 * 6 6 * Heavily inspired from the lm78, lm75 and adm1021 drivers. The LM83 is 7 7 * a sensor chip made by National Semiconductor. It reports up to four ··· 27 27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 28 28 */ 29 29 30 - #include <linux/config.h> 31 30 #include <linux/module.h> 32 31 #include <linux/init.h> 33 32 #include <linux/slab.h> 34 33 #include <linux/jiffies.h> 35 34 #include <linux/i2c.h> 36 35 #include <linux/i2c-sensor.h> 36 + #include <linux/hwmon-sysfs.h> 37 37 38 38 /* 39 39 * Addresses to scan ··· 81 81 82 82 /* 83 83 * Conversions and various macros 84 - * The LM83 uses signed 8-bit values with LSB = 1 degree Celcius. 84 + * The LM83 uses signed 8-bit values with LSB = 1 degree Celsius. 85 85 */ 86 86 87 87 #define TEMP_FROM_REG(val) ((val) * 1000) ··· 94 94 LM83_REG_R_LOCAL_TEMP, 95 95 LM83_REG_R_REMOTE1_TEMP, 96 96 LM83_REG_R_REMOTE2_TEMP, 97 - LM83_REG_R_REMOTE3_TEMP 98 - }; 99 - 100 - static const u8 LM83_REG_R_HIGH[] = { 97 + LM83_REG_R_REMOTE3_TEMP, 101 98 LM83_REG_R_LOCAL_HIGH, 102 99 LM83_REG_R_REMOTE1_HIGH, 103 100 LM83_REG_R_REMOTE2_HIGH, 104 - LM83_REG_R_REMOTE3_HIGH 101 + LM83_REG_R_REMOTE3_HIGH, 102 + LM83_REG_R_TCRIT, 105 103 }; 106 104 107 105 static const u8 LM83_REG_W_HIGH[] = { 108 106 LM83_REG_W_LOCAL_HIGH, 109 107 LM83_REG_W_REMOTE1_HIGH, 110 108 LM83_REG_W_REMOTE2_HIGH, 111 - LM83_REG_W_REMOTE3_HIGH 109 + LM83_REG_W_REMOTE3_HIGH, 110 + LM83_REG_W_TCRIT, 112 111 }; 113 112 114 113 /* ··· 143 144 unsigned long last_updated; /* in jiffies */ 144 145 145 146 /* registers values */ 146 - s8 temp_input[4]; 147 - s8 temp_high[4]; 148 - s8 temp_crit; 147 + s8 temp[9]; /* 0..3: input 1-4, 148 + 4..7: high limit 1-4, 149 + 8 : critical limit */ 149 150 u16 alarms; /* bitvector, combined */ 150 151 }; 151 152 ··· 153 154 * Sysfs stuff 154 155 */ 155 156 156 - #define show_temp(suffix, value) \ 157 - static ssize_t show_temp_##suffix(struct device *dev, struct device_attribute *attr, char *buf) \ 158 - { \ 159 - struct lm83_data *data = lm83_update_device(dev); \ 160 - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->value)); \ 157 + static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, 158 + char *buf) 159 + { 160 + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 161 + struct lm83_data *data = lm83_update_device(dev); 162 + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index])); 161 163 } 162 - show_temp(input1, temp_input[0]); 163 - show_temp(input2, temp_input[1]); 164 - show_temp(input3, temp_input[2]); 165 - show_temp(input4, temp_input[3]); 166 - show_temp(high1, temp_high[0]); 167 - show_temp(high2, temp_high[1]); 168 - show_temp(high3, temp_high[2]); 169 - show_temp(high4, temp_high[3]); 170 - show_temp(crit, temp_crit); 171 164 172 - #define set_temp(suffix, value, reg) \ 173 - static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *attr, const char *buf, \ 174 - size_t count) \ 175 - { \ 176 - struct i2c_client *client = to_i2c_client(dev); \ 177 - struct lm83_data *data = i2c_get_clientdata(client); \ 178 - long val = simple_strtol(buf, NULL, 10); \ 179 - \ 180 - down(&data->update_lock); \ 181 - data->value = TEMP_TO_REG(val); \ 182 - i2c_smbus_write_byte_data(client, reg, data->value); \ 183 - up(&data->update_lock); \ 184 - return count; \ 165 + static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, 166 + const char *buf, size_t count) 167 + { 168 + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 169 + struct i2c_client *client = to_i2c_client(dev); 170 + struct lm83_data *data = i2c_get_clientdata(client); 171 + long val = simple_strtol(buf, NULL, 10); 172 + int nr = attr->index; 173 + 174 + down(&data->update_lock); 175 + data->temp[nr] = TEMP_TO_REG(val); 176 + i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4], 177 + data->temp[nr]); 178 + up(&data->update_lock); 179 + return count; 185 180 } 186 - set_temp(high1, temp_high[0], LM83_REG_W_LOCAL_HIGH); 187 - set_temp(high2, temp_high[1], LM83_REG_W_REMOTE1_HIGH); 188 - set_temp(high3, temp_high[2], LM83_REG_W_REMOTE2_HIGH); 189 - set_temp(high4, temp_high[3], LM83_REG_W_REMOTE3_HIGH); 190 - set_temp(crit, temp_crit, LM83_REG_W_TCRIT); 191 181 192 - static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 182 + static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy, 183 + char *buf) 193 184 { 194 185 struct lm83_data *data = lm83_update_device(dev); 195 186 return sprintf(buf, "%d\n", data->alarms); 196 187 } 197 188 198 - static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL); 199 - static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input2, NULL); 200 - static DEVICE_ATTR(temp3_input, S_IRUGO, show_temp_input3, NULL); 201 - static DEVICE_ATTR(temp4_input, S_IRUGO, show_temp_input4, NULL); 202 - static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_high1, 203 - set_temp_high1); 204 - static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_high2, 205 - set_temp_high2); 206 - static DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp_high3, 207 - set_temp_high3); 208 - static DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp_high4, 209 - set_temp_high4); 210 - static DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp_crit, NULL); 211 - static DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp_crit, NULL); 212 - static DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp_crit, 213 - set_temp_crit); 214 - static DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp_crit, NULL); 189 + static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); 190 + static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); 191 + static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); 192 + static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3); 193 + static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp, 194 + set_temp, 4); 195 + static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp, 196 + set_temp, 5); 197 + static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp, 198 + set_temp, 6); 199 + static SENSOR_DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp, 200 + set_temp, 7); 201 + static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp, NULL, 8); 202 + static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp, NULL, 8); 203 + static SENSOR_DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp, 204 + set_temp, 8); 205 + static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp, NULL, 8); 215 206 static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 216 207 217 208 /* ··· 312 323 */ 313 324 314 325 /* Register sysfs hooks */ 315 - device_create_file(&new_client->dev, &dev_attr_temp1_input); 316 - device_create_file(&new_client->dev, &dev_attr_temp2_input); 317 - device_create_file(&new_client->dev, &dev_attr_temp3_input); 318 - device_create_file(&new_client->dev, &dev_attr_temp4_input); 319 - device_create_file(&new_client->dev, &dev_attr_temp1_max); 320 - device_create_file(&new_client->dev, &dev_attr_temp2_max); 321 - device_create_file(&new_client->dev, &dev_attr_temp3_max); 322 - device_create_file(&new_client->dev, &dev_attr_temp4_max); 323 - device_create_file(&new_client->dev, &dev_attr_temp1_crit); 324 - device_create_file(&new_client->dev, &dev_attr_temp2_crit); 325 - device_create_file(&new_client->dev, &dev_attr_temp3_crit); 326 - device_create_file(&new_client->dev, &dev_attr_temp4_crit); 326 + device_create_file(&new_client->dev, 327 + &sensor_dev_attr_temp1_input.dev_attr); 328 + device_create_file(&new_client->dev, 329 + &sensor_dev_attr_temp2_input.dev_attr); 330 + device_create_file(&new_client->dev, 331 + &sensor_dev_attr_temp3_input.dev_attr); 332 + device_create_file(&new_client->dev, 333 + &sensor_dev_attr_temp4_input.dev_attr); 334 + device_create_file(&new_client->dev, 335 + &sensor_dev_attr_temp1_max.dev_attr); 336 + device_create_file(&new_client->dev, 337 + &sensor_dev_attr_temp2_max.dev_attr); 338 + device_create_file(&new_client->dev, 339 + &sensor_dev_attr_temp3_max.dev_attr); 340 + device_create_file(&new_client->dev, 341 + &sensor_dev_attr_temp4_max.dev_attr); 342 + device_create_file(&new_client->dev, 343 + &sensor_dev_attr_temp1_crit.dev_attr); 344 + device_create_file(&new_client->dev, 345 + &sensor_dev_attr_temp2_crit.dev_attr); 346 + device_create_file(&new_client->dev, 347 + &sensor_dev_attr_temp3_crit.dev_attr); 348 + device_create_file(&new_client->dev, 349 + &sensor_dev_attr_temp4_crit.dev_attr); 327 350 device_create_file(&new_client->dev, &dev_attr_alarms); 328 351 329 352 return 0; ··· 371 370 int nr; 372 371 373 372 dev_dbg(&client->dev, "Updating lm83 data.\n"); 374 - for (nr = 0; nr < 4 ; nr++) { 375 - data->temp_input[nr] = 373 + for (nr = 0; nr < 9; nr++) { 374 + data->temp[nr] = 376 375 i2c_smbus_read_byte_data(client, 377 376 LM83_REG_R_TEMP[nr]); 378 - data->temp_high[nr] = 379 - i2c_smbus_read_byte_data(client, 380 - LM83_REG_R_HIGH[nr]); 381 377 } 382 - data->temp_crit = 383 - i2c_smbus_read_byte_data(client, LM83_REG_R_TCRIT); 384 378 data->alarms = 385 379 i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS1) 386 380 + (i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS2)
+1 -4
drivers/i2c/chips/lm85.c
··· 23 23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 24 */ 25 25 26 - #include <linux/config.h> 27 26 #include <linux/module.h> 28 27 #include <linux/init.h> 29 28 #include <linux/slab.h> ··· 284 285 /* i2c-vid.h defines vid_from_reg() */ 285 286 #define VID_FROM_REG(val,vrm) (vid_from_reg((val),(vrm))) 286 287 287 - #define ALARMS_FROM_REG(val) (val) 288 - 289 288 /* Unlike some other drivers we DO NOT set initial limits. Use 290 289 * the config file to set limits. Some users have reported 291 290 * motherboards shutting down when we set limits in a previous ··· 478 481 static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) 479 482 { 480 483 struct lm85_data *data = lm85_update_device(dev); 481 - return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms)); 484 + return sprintf(buf, "%u\n", data->alarms); 482 485 } 483 486 484 487 static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
-1
drivers/i2c/chips/lm87.c
··· 52 52 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 53 53 */ 54 54 55 - #include <linux/config.h> 56 55 #include <linux/module.h> 57 56 #include <linux/init.h> 58 57 #include <linux/slab.h>
+152 -123
drivers/i2c/chips/lm90.c
··· 1 1 /* 2 2 * lm90.c - Part of lm_sensors, Linux kernel modules for hardware 3 3 * monitoring 4 - * Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org> 4 + * Copyright (C) 2003-2005 Jean Delvare <khali@linux-fr.org> 5 5 * 6 6 * Based on the lm83 driver. The LM90 is a sensor chip made by National 7 7 * Semiconductor. It reports up to two temperatures (its own plus up to ··· 19 19 * Complete datasheets can be obtained from National's website at: 20 20 * http://www.national.com/pf/LM/LM89.html 21 21 * http://www.national.com/pf/LM/LM99.html 22 - * Note that there is no way to differenciate between both chips. 22 + * Note that there is no way to differentiate between both chips. 23 23 * 24 24 * This driver also supports the LM86, another sensor chip made by 25 25 * National Semiconductor. It is exactly similar to the LM90 except it ··· 39 39 * chips made by Maxim. These chips are similar to the LM86. Complete 40 40 * datasheet can be obtained at Maxim's website at: 41 41 * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2578 42 - * Note that there is no easy way to differenciate between the three 42 + * Note that there is no easy way to differentiate between the three 43 43 * variants. The extra address and features of the MAX6659 are not 44 44 * supported by this driver. 45 45 * ··· 70 70 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 71 71 */ 72 72 73 - #include <linux/config.h> 74 73 #include <linux/module.h> 75 74 #include <linux/init.h> 76 75 #include <linux/slab.h> 77 76 #include <linux/jiffies.h> 78 77 #include <linux/i2c.h> 79 78 #include <linux/i2c-sensor.h> 79 + #include <linux/hwmon-sysfs.h> 80 80 81 81 /* 82 82 * Addresses to scan ··· 139 139 /* 140 140 * Conversions and various macros 141 141 * For local temperatures and limits, critical limits and the hysteresis 142 - * value, the LM90 uses signed 8-bit values with LSB = 1 degree Celcius. 142 + * value, the LM90 uses signed 8-bit values with LSB = 1 degree Celsius. 143 143 * For remote temperatures and limits, it uses signed 11-bit values with 144 - * LSB = 0.125 degree Celcius, left-justified in 16-bit registers. 144 + * LSB = 0.125 degree Celsius, left-justified in 16-bit registers. 145 145 */ 146 146 147 147 #define TEMP1_FROM_REG(val) ((val) * 1000) ··· 206 206 int kind; 207 207 208 208 /* registers values */ 209 - s8 temp_input1, temp_low1, temp_high1; /* local */ 210 - s16 temp_input2, temp_low2, temp_high2; /* remote, combined */ 211 - s8 temp_crit1, temp_crit2; 209 + s8 temp8[5]; /* 0: local input 210 + 1: local low limit 211 + 2: local high limit 212 + 3: local critical limit 213 + 4: remote critical limit */ 214 + s16 temp11[3]; /* 0: remote input 215 + 1: remote low limit 216 + 2: remote high limit */ 212 217 u8 temp_hyst; 213 218 u8 alarms; /* bitvector */ 214 219 }; ··· 222 217 * Sysfs stuff 223 218 */ 224 219 225 - #define show_temp(value, converter) \ 226 - static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ 227 - { \ 228 - struct lm90_data *data = lm90_update_device(dev); \ 229 - return sprintf(buf, "%d\n", converter(data->value)); \ 220 + static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr, 221 + char *buf) 222 + { 223 + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 224 + struct lm90_data *data = lm90_update_device(dev); 225 + return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp8[attr->index])); 230 226 } 231 - show_temp(temp_input1, TEMP1_FROM_REG); 232 - show_temp(temp_input2, TEMP2_FROM_REG); 233 - show_temp(temp_low1, TEMP1_FROM_REG); 234 - show_temp(temp_low2, TEMP2_FROM_REG); 235 - show_temp(temp_high1, TEMP1_FROM_REG); 236 - show_temp(temp_high2, TEMP2_FROM_REG); 237 - show_temp(temp_crit1, TEMP1_FROM_REG); 238 - show_temp(temp_crit2, TEMP1_FROM_REG); 239 227 240 - #define set_temp1(value, reg) \ 241 - static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ 242 - size_t count) \ 243 - { \ 244 - struct i2c_client *client = to_i2c_client(dev); \ 245 - struct lm90_data *data = i2c_get_clientdata(client); \ 246 - long val = simple_strtol(buf, NULL, 10); \ 247 - \ 248 - down(&data->update_lock); \ 249 - if (data->kind == adt7461) \ 250 - data->value = TEMP1_TO_REG_ADT7461(val); \ 251 - else \ 252 - data->value = TEMP1_TO_REG(val); \ 253 - i2c_smbus_write_byte_data(client, reg, data->value); \ 254 - up(&data->update_lock); \ 255 - return count; \ 256 - } 257 - #define set_temp2(value, regh, regl) \ 258 - static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \ 259 - size_t count) \ 260 - { \ 261 - struct i2c_client *client = to_i2c_client(dev); \ 262 - struct lm90_data *data = i2c_get_clientdata(client); \ 263 - long val = simple_strtol(buf, NULL, 10); \ 264 - \ 265 - down(&data->update_lock); \ 266 - if (data->kind == adt7461) \ 267 - data->value = TEMP2_TO_REG_ADT7461(val); \ 268 - else \ 269 - data->value = TEMP2_TO_REG(val); \ 270 - i2c_smbus_write_byte_data(client, regh, data->value >> 8); \ 271 - i2c_smbus_write_byte_data(client, regl, data->value & 0xff); \ 272 - up(&data->update_lock); \ 273 - return count; \ 274 - } 275 - set_temp1(temp_low1, LM90_REG_W_LOCAL_LOW); 276 - set_temp2(temp_low2, LM90_REG_W_REMOTE_LOWH, LM90_REG_W_REMOTE_LOWL); 277 - set_temp1(temp_high1, LM90_REG_W_LOCAL_HIGH); 278 - set_temp2(temp_high2, LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL); 279 - set_temp1(temp_crit1, LM90_REG_W_LOCAL_CRIT); 280 - set_temp1(temp_crit2, LM90_REG_W_REMOTE_CRIT); 228 + static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, 229 + const char *buf, size_t count) 230 + { 231 + static const u8 reg[4] = { 232 + LM90_REG_W_LOCAL_LOW, 233 + LM90_REG_W_LOCAL_HIGH, 234 + LM90_REG_W_LOCAL_CRIT, 235 + LM90_REG_W_REMOTE_CRIT, 236 + }; 281 237 282 - #define show_temp_hyst(value, basereg) \ 283 - static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \ 284 - { \ 285 - struct lm90_data *data = lm90_update_device(dev); \ 286 - return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->basereg) \ 287 - - TEMP1_FROM_REG(data->temp_hyst)); \ 288 - } 289 - show_temp_hyst(temp_hyst1, temp_crit1); 290 - show_temp_hyst(temp_hyst2, temp_crit2); 238 + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 239 + struct i2c_client *client = to_i2c_client(dev); 240 + struct lm90_data *data = i2c_get_clientdata(client); 241 + long val = simple_strtol(buf, NULL, 10); 242 + int nr = attr->index; 291 243 292 - static ssize_t set_temp_hyst1(struct device *dev, struct device_attribute *attr, const char *buf, 293 - size_t count) 244 + down(&data->update_lock); 245 + if (data->kind == adt7461) 246 + data->temp8[nr] = TEMP1_TO_REG_ADT7461(val); 247 + else 248 + data->temp8[nr] = TEMP1_TO_REG(val); 249 + i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]); 250 + up(&data->update_lock); 251 + return count; 252 + } 253 + 254 + static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr, 255 + char *buf) 256 + { 257 + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 258 + struct lm90_data *data = lm90_update_device(dev); 259 + return sprintf(buf, "%d\n", TEMP2_FROM_REG(data->temp11[attr->index])); 260 + } 261 + 262 + static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, 263 + const char *buf, size_t count) 264 + { 265 + static const u8 reg[4] = { 266 + LM90_REG_W_REMOTE_LOWH, 267 + LM90_REG_W_REMOTE_LOWL, 268 + LM90_REG_W_REMOTE_HIGHH, 269 + LM90_REG_W_REMOTE_HIGHL, 270 + }; 271 + 272 + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 273 + struct i2c_client *client = to_i2c_client(dev); 274 + struct lm90_data *data = i2c_get_clientdata(client); 275 + long val = simple_strtol(buf, NULL, 10); 276 + int nr = attr->index; 277 + 278 + down(&data->update_lock); 279 + if (data->kind == adt7461) 280 + data->temp11[nr] = TEMP2_TO_REG_ADT7461(val); 281 + else 282 + data->temp11[nr] = TEMP2_TO_REG(val); 283 + i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], 284 + data->temp11[nr] >> 8); 285 + i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], 286 + data->temp11[nr] & 0xff); 287 + up(&data->update_lock); 288 + return count; 289 + } 290 + 291 + static ssize_t show_temphyst(struct device *dev, struct device_attribute *devattr, 292 + char *buf) 293 + { 294 + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 295 + struct lm90_data *data = lm90_update_device(dev); 296 + return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp8[attr->index]) 297 + - TEMP1_FROM_REG(data->temp_hyst)); 298 + } 299 + 300 + static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy, 301 + const char *buf, size_t count) 294 302 { 295 303 struct i2c_client *client = to_i2c_client(dev); 296 304 struct lm90_data *data = i2c_get_clientdata(client); ··· 311 293 long hyst; 312 294 313 295 down(&data->update_lock); 314 - hyst = TEMP1_FROM_REG(data->temp_crit1) - val; 296 + hyst = TEMP1_FROM_REG(data->temp8[3]) - val; 315 297 i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, 316 298 HYST_TO_REG(hyst)); 317 299 up(&data->update_lock); 318 300 return count; 319 301 } 320 302 321 - static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) 303 + static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy, 304 + char *buf) 322 305 { 323 306 struct lm90_data *data = lm90_update_device(dev); 324 307 return sprintf(buf, "%d\n", data->alarms); 325 308 } 326 309 327 - static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL); 328 - static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input2, NULL); 329 - static DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_low1, 330 - set_temp_low1); 331 - static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_low2, 332 - set_temp_low2); 333 - static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_high1, 334 - set_temp_high1); 335 - static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_high2, 336 - set_temp_high2); 337 - static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp_crit1, 338 - set_temp_crit1); 339 - static DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp_crit2, 340 - set_temp_crit2); 341 - static DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temp_hyst1, 342 - set_temp_hyst1); 343 - static DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temp_hyst2, NULL); 310 + static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp8, NULL, 0); 311 + static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0); 312 + static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp8, 313 + set_temp8, 1); 314 + static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11, 315 + set_temp11, 1); 316 + static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8, 317 + set_temp8, 2); 318 + static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11, 319 + set_temp11, 2); 320 + static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp8, 321 + set_temp8, 3); 322 + static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp8, 323 + set_temp8, 4); 324 + static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst, 325 + set_temphyst, 3); 326 + static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4); 344 327 static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 345 328 346 329 /* ··· 500 481 lm90_init_client(new_client); 501 482 502 483 /* Register sysfs hooks */ 503 - device_create_file(&new_client->dev, &dev_attr_temp1_input); 504 - device_create_file(&new_client->dev, &dev_attr_temp2_input); 505 - device_create_file(&new_client->dev, &dev_attr_temp1_min); 506 - device_create_file(&new_client->dev, &dev_attr_temp2_min); 507 - device_create_file(&new_client->dev, &dev_attr_temp1_max); 508 - device_create_file(&new_client->dev, &dev_attr_temp2_max); 509 - device_create_file(&new_client->dev, &dev_attr_temp1_crit); 510 - device_create_file(&new_client->dev, &dev_attr_temp2_crit); 511 - device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst); 512 - device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst); 484 + device_create_file(&new_client->dev, 485 + &sensor_dev_attr_temp1_input.dev_attr); 486 + device_create_file(&new_client->dev, 487 + &sensor_dev_attr_temp2_input.dev_attr); 488 + device_create_file(&new_client->dev, 489 + &sensor_dev_attr_temp1_min.dev_attr); 490 + device_create_file(&new_client->dev, 491 + &sensor_dev_attr_temp2_min.dev_attr); 492 + device_create_file(&new_client->dev, 493 + &sensor_dev_attr_temp1_max.dev_attr); 494 + device_create_file(&new_client->dev, 495 + &sensor_dev_attr_temp2_max.dev_attr); 496 + device_create_file(&new_client->dev, 497 + &sensor_dev_attr_temp1_crit.dev_attr); 498 + device_create_file(&new_client->dev, 499 + &sensor_dev_attr_temp2_crit.dev_attr); 500 + device_create_file(&new_client->dev, 501 + &sensor_dev_attr_temp1_crit_hyst.dev_attr); 502 + device_create_file(&new_client->dev, 503 + &sensor_dev_attr_temp2_crit_hyst.dev_attr); 513 504 device_create_file(&new_client->dev, &dev_attr_alarms); 514 505 515 506 return 0; ··· 570 541 u8 oldh, newh; 571 542 572 543 dev_dbg(&client->dev, "Updating lm90 data.\n"); 573 - data->temp_input1 = i2c_smbus_read_byte_data(client, 574 - LM90_REG_R_LOCAL_TEMP); 575 - data->temp_high1 = i2c_smbus_read_byte_data(client, 576 - LM90_REG_R_LOCAL_HIGH); 577 - data->temp_low1 = i2c_smbus_read_byte_data(client, 578 - LM90_REG_R_LOCAL_LOW); 579 - data->temp_crit1 = i2c_smbus_read_byte_data(client, 580 - LM90_REG_R_LOCAL_CRIT); 581 - data->temp_crit2 = i2c_smbus_read_byte_data(client, 582 - LM90_REG_R_REMOTE_CRIT); 544 + data->temp8[0] = i2c_smbus_read_byte_data(client, 545 + LM90_REG_R_LOCAL_TEMP); 546 + data->temp8[1] = i2c_smbus_read_byte_data(client, 547 + LM90_REG_R_LOCAL_LOW); 548 + data->temp8[2] = i2c_smbus_read_byte_data(client, 549 + LM90_REG_R_LOCAL_HIGH); 550 + data->temp8[3] = i2c_smbus_read_byte_data(client, 551 + LM90_REG_R_LOCAL_CRIT); 552 + data->temp8[4] = i2c_smbus_read_byte_data(client, 553 + LM90_REG_R_REMOTE_CRIT); 583 554 data->temp_hyst = i2c_smbus_read_byte_data(client, 584 555 LM90_REG_R_TCRIT_HYST); 585 556 ··· 599 570 */ 600 571 oldh = i2c_smbus_read_byte_data(client, 601 572 LM90_REG_R_REMOTE_TEMPH); 602 - data->temp_input2 = i2c_smbus_read_byte_data(client, 603 - LM90_REG_R_REMOTE_TEMPL); 573 + data->temp11[0] = i2c_smbus_read_byte_data(client, 574 + LM90_REG_R_REMOTE_TEMPL); 604 575 newh = i2c_smbus_read_byte_data(client, 605 576 LM90_REG_R_REMOTE_TEMPH); 606 577 if (newh != oldh) { 607 - data->temp_input2 = i2c_smbus_read_byte_data(client, 608 - LM90_REG_R_REMOTE_TEMPL); 578 + data->temp11[0] = i2c_smbus_read_byte_data(client, 579 + LM90_REG_R_REMOTE_TEMPL); 609 580 #ifdef DEBUG 610 581 oldh = i2c_smbus_read_byte_data(client, 611 582 LM90_REG_R_REMOTE_TEMPH); ··· 615 586 "wrong.\n"); 616 587 #endif 617 588 } 618 - data->temp_input2 |= (newh << 8); 589 + data->temp11[0] |= (newh << 8); 619 590 620 - data->temp_high2 = (i2c_smbus_read_byte_data(client, 591 + data->temp11[1] = (i2c_smbus_read_byte_data(client, 592 + LM90_REG_R_REMOTE_LOWH) << 8) + 593 + i2c_smbus_read_byte_data(client, 594 + LM90_REG_R_REMOTE_LOWL); 595 + data->temp11[2] = (i2c_smbus_read_byte_data(client, 621 596 LM90_REG_R_REMOTE_HIGHH) << 8) + 622 597 i2c_smbus_read_byte_data(client, 623 598 LM90_REG_R_REMOTE_HIGHL); 624 - data->temp_low2 = (i2c_smbus_read_byte_data(client, 625 - LM90_REG_R_REMOTE_LOWH) << 8) + 626 - i2c_smbus_read_byte_data(client, 627 - LM90_REG_R_REMOTE_LOWL); 628 599 data->alarms = i2c_smbus_read_byte_data(client, 629 600 LM90_REG_R_STATUS); 630 601
-3
drivers/i2c/chips/m41t00.c
··· 40 40 41 41 static struct i2c_client_address_data addr_data = { 42 42 .normal_i2c = normal_addr, 43 - .normal_i2c_range = ignore, 44 43 .probe = ignore, 45 - .probe_range = ignore, 46 44 .ignore = ignore, 47 - .ignore_range = ignore, 48 45 .force = ignore, 49 46 }; 50 47
-1
drivers/i2c/chips/max1619.c
··· 26 26 */ 27 27 28 28 29 - #include <linux/config.h> 30 29 #include <linux/module.h> 31 30 #include <linux/init.h> 32 31 #include <linux/slab.h>
+473
drivers/i2c/chips/max6875.c
··· 1 + /* 2 + max6875.c - driver for MAX6874/MAX6875 3 + 4 + Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com> 5 + 6 + Based on i2c/chips/eeprom.c 7 + 8 + The MAX6875 has two EEPROM sections: config and user. 9 + At reset, the config EEPROM is read into the registers. 10 + 11 + This driver make 3 binary files available in sysfs: 12 + reg_config - direct access to the registers 13 + eeprom_config - acesses configuration eeprom space 14 + eeprom_user - free for application use 15 + 16 + In our application, we put device serial & model numbers in user eeprom. 17 + 18 + Notes: 19 + 1) The datasheet says that register 0x44 / EEPROM 0x8044 should NOT 20 + be overwritten, so the driver explicitly prevents that. 21 + 2) It's a good idea to keep the config (0x45) locked in config EEPROM. 22 + You can temporarily enable config writes by changing register 0x45. 23 + 24 + This program is free software; you can redistribute it and/or modify 25 + it under the terms of the GNU General Public License as published by 26 + the Free Software Foundation; version 2 of the License. 27 + */ 28 + 29 + #include <linux/config.h> 30 + #include <linux/kernel.h> 31 + #include <linux/init.h> 32 + #include <linux/module.h> 33 + #include <linux/slab.h> 34 + #include <linux/sched.h> 35 + #include <linux/delay.h> 36 + #include <linux/i2c.h> 37 + #include <linux/i2c-sensor.h> 38 + 39 + /* Addresses to scan */ 40 + static unsigned short normal_i2c[] = {0x50, 0x52, I2C_CLIENT_END}; 41 + static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END}; 42 + 43 + /* Insmod parameters */ 44 + SENSORS_INSMOD_1(max6875); 45 + 46 + /* this param will prevent 'accidental' writes to the eeprom */ 47 + static int allow_write = 0; 48 + module_param(allow_write, int, 0); 49 + MODULE_PARM_DESC(allow_write, 50 + "Enable write access:\n" 51 + "*0: Read only\n" 52 + " 1: Read/Write access"); 53 + 54 + /* The MAX6875 can only read/write 16 bytes at a time */ 55 + #define SLICE_SIZE 16 56 + #define SLICE_BITS 4 57 + 58 + /* CONFIG EEPROM is at addresses 0x8000 - 0x8045, registers are at 0 - 0x45 */ 59 + #define CONFIG_EEPROM_BASE 0x8000 60 + #define CONFIG_EEPROM_SIZE 0x0046 61 + #define CONFIG_EEPROM_SLICES 5 62 + 63 + /* USER EEPROM is at addresses 0x8100 - 0x82FF */ 64 + #define USER_EEPROM_BASE 0x8100 65 + #define USER_EEPROM_SIZE 0x0200 66 + #define USER_EEPROM_SLICES 32 67 + 68 + /* MAX6875 commands */ 69 + #define MAX6875_CMD_BLOCK_WRITE 0x83 70 + #define MAX6875_CMD_BLOCK_READ 0x84 71 + #define MAX6875_CMD_REBOOT 0x88 72 + 73 + enum max6875_area_type { 74 + max6875_register_config=0, 75 + max6875_eeprom_config, 76 + max6875_eeprom_user, 77 + max6857_max 78 + }; 79 + 80 + struct eeprom_block { 81 + enum max6875_area_type type; 82 + u8 slices; 83 + u32 size; 84 + u32 valid; 85 + u32 base; 86 + unsigned long *updated; 87 + u8 *data; 88 + }; 89 + 90 + /* Each client has this additional data */ 91 + struct max6875_data { 92 + struct i2c_client client; 93 + struct semaphore update_lock; 94 + struct eeprom_block blocks[max6857_max]; 95 + /* the above structs point into the arrays below */ 96 + u8 data[USER_EEPROM_SIZE + (CONFIG_EEPROM_SIZE*2)]; 97 + unsigned long last_updated[USER_EEPROM_SLICES + (CONFIG_EEPROM_SLICES*2)]; 98 + }; 99 + 100 + static int max6875_attach_adapter(struct i2c_adapter *adapter); 101 + static int max6875_detect(struct i2c_adapter *adapter, int address, int kind); 102 + static int max6875_detach_client(struct i2c_client *client); 103 + 104 + /* This is the driver that will be inserted */ 105 + static struct i2c_driver max6875_driver = { 106 + .owner = THIS_MODULE, 107 + .name = "max6875", 108 + .flags = I2C_DF_NOTIFY, 109 + .attach_adapter = max6875_attach_adapter, 110 + .detach_client = max6875_detach_client, 111 + }; 112 + 113 + static int max6875_update_slice(struct i2c_client *client, 114 + struct eeprom_block *blk, 115 + int slice) 116 + { 117 + struct max6875_data *data = i2c_get_clientdata(client); 118 + int i, j, addr, count; 119 + u8 rdbuf[SLICE_SIZE]; 120 + int retval = 0; 121 + 122 + if (slice >= blk->slices) 123 + return -1; 124 + 125 + down(&data->update_lock); 126 + 127 + if (!(blk->valid & (1 << slice)) || 128 + (jiffies - blk->updated[slice] > 300 * HZ) || 129 + (jiffies < blk->updated[slice])) { 130 + dev_dbg(&client->dev, "Starting eeprom update, slice %u, base %u\n", 131 + slice, blk->base); 132 + 133 + addr = blk->base + (slice << SLICE_BITS); 134 + count = blk->size - (slice << SLICE_BITS); 135 + if (count > SLICE_SIZE) { 136 + count = SLICE_SIZE; 137 + } 138 + 139 + /* Preset the read address */ 140 + if (addr < 0x100) { 141 + /* select the register */ 142 + if (i2c_smbus_write_byte(client, addr & 0xFF)) { 143 + dev_dbg(&client->dev, "max6875 register select has failed!\n"); 144 + retval = -1; 145 + goto exit; 146 + } 147 + } else { 148 + /* select the eeprom */ 149 + if (i2c_smbus_write_byte_data(client, addr >> 8, addr & 0xFF)) { 150 + dev_dbg(&client->dev, "max6875 address set has failed!\n"); 151 + retval = -1; 152 + goto exit; 153 + } 154 + } 155 + 156 + if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { 157 + if (i2c_smbus_read_i2c_block_data(client, MAX6875_CMD_BLOCK_READ, 158 + rdbuf) != SLICE_SIZE) 159 + { 160 + retval = -1; 161 + goto exit; 162 + } 163 + 164 + memcpy(&blk->data[slice << SLICE_BITS], rdbuf, count); 165 + } else { 166 + for (i = 0; i < count; i++) { 167 + j = i2c_smbus_read_byte(client); 168 + if (j < 0) 169 + { 170 + retval = -1; 171 + goto exit; 172 + } 173 + blk->data[(slice << SLICE_BITS) + i] = (u8) j; 174 + } 175 + } 176 + blk->updated[slice] = jiffies; 177 + blk->valid |= (1 << slice); 178 + } 179 + exit: 180 + up(&data->update_lock); 181 + return retval; 182 + } 183 + 184 + static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, size_t count, 185 + enum max6875_area_type area_type) 186 + { 187 + struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); 188 + struct max6875_data *data = i2c_get_clientdata(client); 189 + struct eeprom_block *blk; 190 + int slice; 191 + 192 + blk = &data->blocks[area_type]; 193 + 194 + if (off > blk->size) 195 + return 0; 196 + if (off + count > blk->size) 197 + count = blk->size - off; 198 + 199 + /* Only refresh slices which contain requested bytes */ 200 + for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++) 201 + max6875_update_slice(client, blk, slice); 202 + 203 + memcpy(buf, &blk->data[off], count); 204 + 205 + return count; 206 + } 207 + 208 + static ssize_t max6875_user_read(struct kobject *kobj, char *buf, loff_t off, size_t count) 209 + { 210 + return max6875_read(kobj, buf, off, count, max6875_eeprom_user); 211 + } 212 + 213 + static ssize_t max6875_config_read(struct kobject *kobj, char *buf, loff_t off, size_t count) 214 + { 215 + return max6875_read(kobj, buf, off, count, max6875_eeprom_config); 216 + } 217 + 218 + static ssize_t max6875_cfgreg_read(struct kobject *kobj, char *buf, loff_t off, size_t count) 219 + { 220 + return max6875_read(kobj, buf, off, count, max6875_register_config); 221 + } 222 + 223 + 224 + static ssize_t max6875_write(struct kobject *kobj, char *buf, loff_t off, size_t count, 225 + enum max6875_area_type area_type) 226 + { 227 + struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); 228 + struct max6875_data *data = i2c_get_clientdata(client); 229 + struct eeprom_block *blk; 230 + int slice, addr, retval; 231 + ssize_t sent = 0; 232 + 233 + blk = &data->blocks[area_type]; 234 + 235 + if (off > blk->size) 236 + return 0; 237 + if ((off + count) > blk->size) 238 + count = blk->size - off; 239 + 240 + if (down_interruptible(&data->update_lock)) 241 + return -EAGAIN; 242 + 243 + /* writing to a register is done with i2c_smbus_write_byte_data() */ 244 + if (blk->type == max6875_register_config) { 245 + for (sent = 0; sent < count; sent++) { 246 + addr = off + sent; 247 + if (addr == 0x44) 248 + continue; 249 + 250 + retval = i2c_smbus_write_byte_data(client, addr, buf[sent]); 251 + } 252 + } else { 253 + int cmd, val; 254 + 255 + /* We are writing to EEPROM */ 256 + for (sent = 0; sent < count; sent++) { 257 + addr = blk->base + off + sent; 258 + cmd = addr >> 8; 259 + val = (addr & 0xff) | (buf[sent] << 8); // reversed 260 + 261 + if (addr == 0x8044) 262 + continue; 263 + 264 + retval = i2c_smbus_write_word_data(client, cmd, val); 265 + 266 + if (retval) { 267 + goto error_exit; 268 + } 269 + 270 + /* A write takes up to 11 ms */ 271 + msleep(11); 272 + } 273 + } 274 + 275 + /* Invalidate the scratch buffer */ 276 + for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++) 277 + blk->valid &= ~(1 << slice); 278 + 279 + error_exit: 280 + up(&data->update_lock); 281 + 282 + return sent; 283 + } 284 + 285 + static ssize_t max6875_user_write(struct kobject *kobj, char *buf, loff_t off, size_t count) 286 + { 287 + return max6875_write(kobj, buf, off, count, max6875_eeprom_user); 288 + } 289 + 290 + static ssize_t max6875_config_write(struct kobject *kobj, char *buf, loff_t off, size_t count) 291 + { 292 + return max6875_write(kobj, buf, off, count, max6875_eeprom_config); 293 + } 294 + 295 + static ssize_t max6875_cfgreg_write(struct kobject *kobj, char *buf, loff_t off, size_t count) 296 + { 297 + return max6875_write(kobj, buf, off, count, max6875_register_config); 298 + } 299 + 300 + static struct bin_attribute user_eeprom_attr = { 301 + .attr = { 302 + .name = "eeprom_user", 303 + .mode = S_IRUGO | S_IWUSR | S_IWGRP, 304 + .owner = THIS_MODULE, 305 + }, 306 + .size = USER_EEPROM_SIZE, 307 + .read = max6875_user_read, 308 + .write = max6875_user_write, 309 + }; 310 + 311 + static struct bin_attribute config_eeprom_attr = { 312 + .attr = { 313 + .name = "eeprom_config", 314 + .mode = S_IRUGO | S_IWUSR, 315 + .owner = THIS_MODULE, 316 + }, 317 + .size = CONFIG_EEPROM_SIZE, 318 + .read = max6875_config_read, 319 + .write = max6875_config_write, 320 + }; 321 + 322 + static struct bin_attribute config_register_attr = { 323 + .attr = { 324 + .name = "reg_config", 325 + .mode = S_IRUGO | S_IWUSR, 326 + .owner = THIS_MODULE, 327 + }, 328 + .size = CONFIG_EEPROM_SIZE, 329 + .read = max6875_cfgreg_read, 330 + .write = max6875_cfgreg_write, 331 + }; 332 + 333 + static int max6875_attach_adapter(struct i2c_adapter *adapter) 334 + { 335 + return i2c_detect(adapter, &addr_data, max6875_detect); 336 + } 337 + 338 + /* This function is called by i2c_detect */ 339 + static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) 340 + { 341 + struct i2c_client *new_client; 342 + struct max6875_data *data; 343 + int err = 0; 344 + 345 + /* There are three ways we can read the EEPROM data: 346 + (1) I2C block reads (faster, but unsupported by most adapters) 347 + (2) Consecutive byte reads (100% overhead) 348 + (3) Regular byte data reads (200% overhead) 349 + The third method is not implemented by this driver because all 350 + known adapters support at least the second. */ 351 + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA | 352 + I2C_FUNC_SMBUS_BYTE | 353 + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) 354 + goto exit; 355 + 356 + /* OK. For now, we presume we have a valid client. We now create the 357 + client structure, even though we cannot fill it completely yet. 358 + But it allows us to access eeprom_{read,write}_value. */ 359 + if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) { 360 + err = -ENOMEM; 361 + goto exit; 362 + } 363 + memset(data, 0, sizeof(struct max6875_data)); 364 + 365 + new_client = &data->client; 366 + i2c_set_clientdata(new_client, data); 367 + new_client->addr = address; 368 + new_client->adapter = adapter; 369 + new_client->driver = &max6875_driver; 370 + new_client->flags = 0; 371 + 372 + /* Setup the user section */ 373 + data->blocks[max6875_eeprom_user].type = max6875_eeprom_user; 374 + data->blocks[max6875_eeprom_user].slices = USER_EEPROM_SLICES; 375 + data->blocks[max6875_eeprom_user].size = USER_EEPROM_SIZE; 376 + data->blocks[max6875_eeprom_user].base = USER_EEPROM_BASE; 377 + data->blocks[max6875_eeprom_user].data = data->data; 378 + data->blocks[max6875_eeprom_user].updated = data->last_updated; 379 + 380 + /* Setup the config section */ 381 + data->blocks[max6875_eeprom_config].type = max6875_eeprom_config; 382 + data->blocks[max6875_eeprom_config].slices = CONFIG_EEPROM_SLICES; 383 + data->blocks[max6875_eeprom_config].size = CONFIG_EEPROM_SIZE; 384 + data->blocks[max6875_eeprom_config].base = CONFIG_EEPROM_BASE; 385 + data->blocks[max6875_eeprom_config].data = &data->data[USER_EEPROM_SIZE]; 386 + data->blocks[max6875_eeprom_config].updated = &data->last_updated[USER_EEPROM_SLICES]; 387 + 388 + /* Setup the register section */ 389 + data->blocks[max6875_register_config].type = max6875_register_config; 390 + data->blocks[max6875_register_config].slices = CONFIG_EEPROM_SLICES; 391 + data->blocks[max6875_register_config].size = CONFIG_EEPROM_SIZE; 392 + data->blocks[max6875_register_config].base = 0; 393 + data->blocks[max6875_register_config].data = &data->data[USER_EEPROM_SIZE+CONFIG_EEPROM_SIZE]; 394 + data->blocks[max6875_register_config].updated = &data->last_updated[USER_EEPROM_SLICES+CONFIG_EEPROM_SLICES]; 395 + 396 + /* Init the data */ 397 + memset(data->data, 0xff, sizeof(data->data)); 398 + 399 + /* Fill in the remaining client fields */ 400 + strlcpy(new_client->name, "max6875", I2C_NAME_SIZE); 401 + init_MUTEX(&data->update_lock); 402 + 403 + /* Verify that the chip is really what we think it is */ 404 + if ((max6875_update_slice(new_client, &data->blocks[max6875_eeprom_config], 4) < 0) || 405 + (max6875_update_slice(new_client, &data->blocks[max6875_register_config], 4) < 0)) 406 + goto exit_kfree; 407 + 408 + /* 0x41,0x42 must be zero and 0x40 must match in eeprom and registers */ 409 + if ((data->blocks[max6875_eeprom_config].data[0x41] != 0) || 410 + (data->blocks[max6875_eeprom_config].data[0x42] != 0) || 411 + (data->blocks[max6875_register_config].data[0x41] != 0) || 412 + (data->blocks[max6875_register_config].data[0x42] != 0) || 413 + (data->blocks[max6875_eeprom_config].data[0x40] != 414 + data->blocks[max6875_register_config].data[0x40])) 415 + goto exit_kfree; 416 + 417 + /* Tell the I2C layer a new client has arrived */ 418 + if ((err = i2c_attach_client(new_client))) 419 + goto exit_kfree; 420 + 421 + /* create the sysfs eeprom files with the correct permissions */ 422 + if (allow_write == 0) { 423 + user_eeprom_attr.attr.mode &= ~S_IWUGO; 424 + user_eeprom_attr.write = NULL; 425 + config_eeprom_attr.attr.mode &= ~S_IWUGO; 426 + config_eeprom_attr.write = NULL; 427 + config_register_attr.attr.mode &= ~S_IWUGO; 428 + config_register_attr.write = NULL; 429 + } 430 + sysfs_create_bin_file(&new_client->dev.kobj, &user_eeprom_attr); 431 + sysfs_create_bin_file(&new_client->dev.kobj, &config_eeprom_attr); 432 + sysfs_create_bin_file(&new_client->dev.kobj, &config_register_attr); 433 + 434 + return 0; 435 + 436 + exit_kfree: 437 + kfree(data); 438 + exit: 439 + return err; 440 + } 441 + 442 + static int max6875_detach_client(struct i2c_client *client) 443 + { 444 + int err; 445 + 446 + err = i2c_detach_client(client); 447 + if (err) { 448 + dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); 449 + return err; 450 + } 451 + 452 + kfree(i2c_get_clientdata(client)); 453 + 454 + return 0; 455 + } 456 + 457 + static int __init max6875_init(void) 458 + { 459 + return i2c_add_driver(&max6875_driver); 460 + } 461 + 462 + static void __exit max6875_exit(void) 463 + { 464 + i2c_del_driver(&max6875_driver); 465 + } 466 + 467 + 468 + MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>"); 469 + MODULE_DESCRIPTION("MAX6875 driver"); 470 + MODULE_LICENSE("GPL"); 471 + 472 + module_init(max6875_init); 473 + module_exit(max6875_exit);
-1
drivers/i2c/chips/pc87360.c
··· 33 33 * the standard Super-I/O addresses is used (0x2E/0x2F or 0x4E/0x4F). 34 34 */ 35 35 36 - #include <linux/config.h> 37 36 #include <linux/module.h> 38 37 #include <linux/init.h> 39 38 #include <linux/slab.h>
+192
drivers/i2c/chips/pca9539.c
··· 1 + /* 2 + pca9539.c - 16-bit I/O port with interrupt and reset 3 + 4 + Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com> 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; version 2 of the License. 9 + */ 10 + 11 + #include <linux/module.h> 12 + #include <linux/init.h> 13 + #include <linux/slab.h> 14 + #include <linux/i2c.h> 15 + #include <linux/hwmon-sysfs.h> 16 + #include <linux/i2c-sensor.h> 17 + 18 + /* Addresses to scan */ 19 + static unsigned short normal_i2c[] = {0x74, 0x75, 0x76, 0x77, I2C_CLIENT_END}; 20 + static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END}; 21 + 22 + /* Insmod parameters */ 23 + SENSORS_INSMOD_1(pca9539); 24 + 25 + enum pca9539_cmd 26 + { 27 + PCA9539_INPUT_0 = 0, 28 + PCA9539_INPUT_1 = 1, 29 + PCA9539_OUTPUT_0 = 2, 30 + PCA9539_OUTPUT_1 = 3, 31 + PCA9539_INVERT_0 = 4, 32 + PCA9539_INVERT_1 = 5, 33 + PCA9539_DIRECTION_0 = 6, 34 + PCA9539_DIRECTION_1 = 7, 35 + }; 36 + 37 + static int pca9539_attach_adapter(struct i2c_adapter *adapter); 38 + static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind); 39 + static int pca9539_detach_client(struct i2c_client *client); 40 + 41 + /* This is the driver that will be inserted */ 42 + static struct i2c_driver pca9539_driver = { 43 + .owner = THIS_MODULE, 44 + .name = "pca9539", 45 + .flags = I2C_DF_NOTIFY, 46 + .attach_adapter = pca9539_attach_adapter, 47 + .detach_client = pca9539_detach_client, 48 + }; 49 + 50 + struct pca9539_data { 51 + struct i2c_client client; 52 + }; 53 + 54 + /* following are the sysfs callback functions */ 55 + static ssize_t pca9539_show(struct device *dev, struct device_attribute *attr, 56 + char *buf) 57 + { 58 + struct sensor_device_attribute *psa = to_sensor_dev_attr(attr); 59 + struct i2c_client *client = to_i2c_client(dev); 60 + return sprintf(buf, "%d\n", i2c_smbus_read_byte_data(client, 61 + psa->index)); 62 + } 63 + 64 + static ssize_t pca9539_store(struct device *dev, struct device_attribute *attr, 65 + const char *buf, size_t count) 66 + { 67 + struct sensor_device_attribute *psa = to_sensor_dev_attr(attr); 68 + struct i2c_client *client = to_i2c_client(dev); 69 + unsigned long val = simple_strtoul(buf, NULL, 0); 70 + if (val > 0xff) 71 + return -EINVAL; 72 + i2c_smbus_write_byte_data(client, psa->index, val); 73 + return count; 74 + } 75 + 76 + /* Define the device attributes */ 77 + 78 + #define PCA9539_ENTRY_RO(name, cmd_idx) \ 79 + static SENSOR_DEVICE_ATTR(name, S_IRUGO, pca9539_show, NULL, cmd_idx) 80 + 81 + #define PCA9539_ENTRY_RW(name, cmd_idx) \ 82 + static SENSOR_DEVICE_ATTR(name, S_IRUGO | S_IWUSR, pca9539_show, \ 83 + pca9539_store, cmd_idx) 84 + 85 + PCA9539_ENTRY_RO(input0, PCA9539_INPUT_0); 86 + PCA9539_ENTRY_RO(input1, PCA9539_INPUT_1); 87 + PCA9539_ENTRY_RW(output0, PCA9539_OUTPUT_0); 88 + PCA9539_ENTRY_RW(output1, PCA9539_OUTPUT_1); 89 + PCA9539_ENTRY_RW(invert0, PCA9539_INVERT_0); 90 + PCA9539_ENTRY_RW(invert1, PCA9539_INVERT_1); 91 + PCA9539_ENTRY_RW(direction0, PCA9539_DIRECTION_0); 92 + PCA9539_ENTRY_RW(direction1, PCA9539_DIRECTION_1); 93 + 94 + static struct attribute *pca9539_attributes[] = { 95 + &sensor_dev_attr_input0.dev_attr.attr, 96 + &sensor_dev_attr_input1.dev_attr.attr, 97 + &sensor_dev_attr_output0.dev_attr.attr, 98 + &sensor_dev_attr_output1.dev_attr.attr, 99 + &sensor_dev_attr_invert0.dev_attr.attr, 100 + &sensor_dev_attr_invert1.dev_attr.attr, 101 + &sensor_dev_attr_direction0.dev_attr.attr, 102 + &sensor_dev_attr_direction1.dev_attr.attr, 103 + NULL 104 + }; 105 + 106 + static struct attribute_group pca9539_defattr_group = { 107 + .attrs = pca9539_attributes, 108 + }; 109 + 110 + static int pca9539_attach_adapter(struct i2c_adapter *adapter) 111 + { 112 + return i2c_detect(adapter, &addr_data, pca9539_detect); 113 + } 114 + 115 + /* This function is called by i2c_detect */ 116 + static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind) 117 + { 118 + struct i2c_client *new_client; 119 + struct pca9539_data *data; 120 + int err = 0; 121 + 122 + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 123 + goto exit; 124 + 125 + /* OK. For now, we presume we have a valid client. We now create the 126 + client structure, even though we cannot fill it completely yet. */ 127 + if (!(data = kmalloc(sizeof(struct pca9539_data), GFP_KERNEL))) { 128 + err = -ENOMEM; 129 + goto exit; 130 + } 131 + memset(data, 0, sizeof(struct pca9539_data)); 132 + 133 + new_client = &data->client; 134 + i2c_set_clientdata(new_client, data); 135 + new_client->addr = address; 136 + new_client->adapter = adapter; 137 + new_client->driver = &pca9539_driver; 138 + new_client->flags = 0; 139 + 140 + /* Detection: the pca9539 only has 8 registers (0-7). 141 + A read of 7 should succeed, but a read of 8 should fail. */ 142 + if ((i2c_smbus_read_byte_data(new_client, 7) < 0) || 143 + (i2c_smbus_read_byte_data(new_client, 8) >= 0)) 144 + goto exit_kfree; 145 + 146 + strlcpy(new_client->name, "pca9539", I2C_NAME_SIZE); 147 + 148 + /* Tell the I2C layer a new client has arrived */ 149 + if ((err = i2c_attach_client(new_client))) 150 + goto exit_kfree; 151 + 152 + /* Register sysfs hooks (don't care about failure) */ 153 + sysfs_create_group(&new_client->dev.kobj, &pca9539_defattr_group); 154 + 155 + return 0; 156 + 157 + exit_kfree: 158 + kfree(data); 159 + exit: 160 + return err; 161 + } 162 + 163 + static int pca9539_detach_client(struct i2c_client *client) 164 + { 165 + int err; 166 + 167 + if ((err = i2c_detach_client(client))) { 168 + dev_err(&client->dev, "Client deregistration failed.\n"); 169 + return err; 170 + } 171 + 172 + kfree(i2c_get_clientdata(client)); 173 + return 0; 174 + } 175 + 176 + static int __init pca9539_init(void) 177 + { 178 + return i2c_add_driver(&pca9539_driver); 179 + } 180 + 181 + static void __exit pca9539_exit(void) 182 + { 183 + i2c_del_driver(&pca9539_driver); 184 + } 185 + 186 + MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>"); 187 + MODULE_DESCRIPTION("PCA9539 driver"); 188 + MODULE_LICENSE("GPL"); 189 + 190 + module_init(pca9539_init); 191 + module_exit(pca9539_exit); 192 +
+2 -4
drivers/i2c/chips/pcf8574.c
··· 57 57 struct pcf8574_data { 58 58 struct i2c_client client; 59 59 60 - u8 read, write; /* Register values */ 60 + u8 write; /* Remember last written value */ 61 61 }; 62 62 63 63 static int pcf8574_attach_adapter(struct i2c_adapter *adapter); ··· 79 79 static ssize_t show_read(struct device *dev, struct device_attribute *attr, char *buf) 80 80 { 81 81 struct i2c_client *client = to_i2c_client(dev); 82 - struct pcf8574_data *data = i2c_get_clientdata(client); 83 - data->read = i2c_smbus_read_byte(client); 84 - return sprintf(buf, "%u\n", data->read); 82 + return sprintf(buf, "%u\n", i2c_smbus_read_byte(client)); 85 83 } 86 84 87 85 static DEVICE_ATTR(read, S_IRUGO, show_read, NULL);
-4
drivers/i2c/chips/rtc8564.c
··· 19 19 #include <linux/string.h> 20 20 #include <linux/rtc.h> /* get the user-level API */ 21 21 #include <linux/init.h> 22 - #include <linux/init.h> 23 22 24 23 #include "rtc8564.h" 25 24 ··· 65 66 66 67 static struct i2c_client_address_data addr_data = { 67 68 .normal_i2c = normal_addr, 68 - .normal_i2c_range = ignore, 69 69 .probe = ignore, 70 - .probe_range = ignore, 71 70 .ignore = ignore, 72 - .ignore_range = ignore, 73 71 .force = ignore, 74 72 }; 75 73
+1
drivers/i2c/chips/sis5595.c
··· 57 57 #include <linux/i2c.h> 58 58 #include <linux/i2c-sensor.h> 59 59 #include <linux/init.h> 60 + #include <linux/jiffies.h> 60 61 #include <asm/io.h> 61 62 62 63
+6 -4
drivers/i2c/chips/smsc47m1.c
··· 372 372 * SMSC LPC47M10x/LPC47M13x (device id 0x59), LPC47M14x (device id 373 373 * 0x5F) and LPC47B27x (device id 0x51) have fan control. 374 374 * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" 375 - * can do much more besides (device id 0x60, unsupported). 375 + * can do much more besides (device id 0x60). 376 376 */ 377 377 if (val == 0x51) 378 - printk(KERN_INFO "smsc47m1: Found SMSC47B27x\n"); 378 + printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n"); 379 379 else if (val == 0x59) 380 - printk(KERN_INFO "smsc47m1: Found SMSC47M10x/SMSC47M13x\n"); 380 + printk(KERN_INFO "smsc47m1: Found SMSC LPC47M10x/LPC47M13x\n"); 381 381 else if (val == 0x5F) 382 - printk(KERN_INFO "smsc47m1: Found SMSC47M14x\n"); 382 + printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n"); 383 + else if (val == 0x60) 384 + printk(KERN_INFO "smsc47m1: Found SMSC LPC47M15x/LPC47M192\n"); 383 385 else { 384 386 superio_exit(); 385 387 return -ENODEV;
+1072
drivers/i2c/chips/tps65010.c
··· 1 + /* 2 + * tps65010 - driver for tps6501x power management chips 3 + * 4 + * Copyright (C) 2004 Texas Instruments 5 + * Copyright (C) 2004-2005 David Brownell 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 + * You should have received a copy of the GNU General Public License 18 + * along with this program; if not, write to the Free Software 19 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 + */ 21 + #undef DEBUG 22 + 23 + #include <linux/config.h> 24 + #include <linux/kernel.h> 25 + #include <linux/module.h> 26 + #include <linux/init.h> 27 + #include <linux/slab.h> 28 + #include <linux/interrupt.h> 29 + #include <linux/device.h> 30 + #include <linux/i2c.h> 31 + #include <linux/delay.h> 32 + #include <linux/workqueue.h> 33 + #include <linux/suspend.h> 34 + #include <linux/debugfs.h> 35 + #include <linux/seq_file.h> 36 + 37 + #include <asm/irq.h> 38 + #include <asm/mach-types.h> 39 + 40 + #include <asm/arch/gpio.h> 41 + #include <asm/arch/mux.h> 42 + #include <asm/arch/tps65010.h> 43 + 44 + /*-------------------------------------------------------------------------*/ 45 + 46 + #define DRIVER_VERSION "2 May 2005" 47 + #define DRIVER_NAME (tps65010_driver.name) 48 + 49 + MODULE_DESCRIPTION("TPS6501x Power Management Driver"); 50 + MODULE_LICENSE("GPL"); 51 + 52 + /* only two addresses possible */ 53 + #define TPS_BASE 0x48 54 + static unsigned short normal_i2c[] = { 55 + TPS_BASE, 56 + I2C_CLIENT_END }; 57 + static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 58 + 59 + I2C_CLIENT_INSMOD; 60 + 61 + static struct i2c_driver tps65010_driver; 62 + 63 + /*-------------------------------------------------------------------------*/ 64 + 65 + /* This driver handles a family of multipurpose chips, which incorporate 66 + * voltage regulators, lithium ion/polymer battery charging, GPIOs, LEDs, 67 + * and other features often needed in portable devices like cell phones 68 + * or digital cameras. 69 + * 70 + * The tps65011 and tps65013 have different voltage settings compared 71 + * to tps65010 and tps65012. The tps65013 has a NO_CHG status/irq. 72 + * All except tps65010 have "wait" mode, possibly defaulted so that 73 + * battery-insert != device-on. 74 + * 75 + * We could distinguish between some models by checking VDCDC1.UVLO or 76 + * other registers, unless they've been changed already after powerup 77 + * as part of board setup by a bootloader. 78 + */ 79 + enum tps_model { 80 + TPS_UNKNOWN = 0, 81 + TPS65010, 82 + TPS65011, 83 + TPS65012, 84 + TPS65013, 85 + }; 86 + 87 + struct tps65010 { 88 + struct i2c_client client; 89 + struct semaphore lock; 90 + int irq; 91 + struct work_struct work; 92 + struct dentry *file; 93 + unsigned charging:1; 94 + unsigned por:1; 95 + unsigned model:8; 96 + u16 vbus; 97 + unsigned long flags; 98 + #define FLAG_VBUS_CHANGED 0 99 + #define FLAG_IRQ_ENABLE 1 100 + 101 + /* copies of last register state */ 102 + u8 chgstatus, regstatus, chgconf; 103 + u8 nmask1, nmask2; 104 + 105 + /* plus four GPIOs, probably used to switch power */ 106 + }; 107 + 108 + #define POWER_POLL_DELAY msecs_to_jiffies(800) 109 + 110 + /*-------------------------------------------------------------------------*/ 111 + 112 + #if defined(DEBUG) || defined(CONFIG_DEBUG_FS) 113 + 114 + static void dbg_chgstat(char *buf, size_t len, u8 chgstatus) 115 + { 116 + snprintf(buf, len, "%02x%s%s%s%s%s%s%s%s\n", 117 + chgstatus, 118 + (chgstatus & TPS_CHG_USB) ? " USB" : "", 119 + (chgstatus & TPS_CHG_AC) ? " AC" : "", 120 + (chgstatus & TPS_CHG_THERM) ? " therm" : "", 121 + (chgstatus & TPS_CHG_TERM) ? " done" : 122 + ((chgstatus & (TPS_CHG_USB|TPS_CHG_AC)) 123 + ? " (charging)" : ""), 124 + (chgstatus & TPS_CHG_TAPER_TMO) ? " taper_tmo" : "", 125 + (chgstatus & TPS_CHG_CHG_TMO) ? " charge_tmo" : "", 126 + (chgstatus & TPS_CHG_PRECHG_TMO) ? " prechg_tmo" : "", 127 + (chgstatus & TPS_CHG_TEMP_ERR) ? " temp_err" : ""); 128 + } 129 + 130 + static void dbg_regstat(char *buf, size_t len, u8 regstatus) 131 + { 132 + snprintf(buf, len, "%02x %s%s%s%s%s%s%s%s\n", 133 + regstatus, 134 + (regstatus & TPS_REG_ONOFF) ? "off" : "(on)", 135 + (regstatus & TPS_REG_COVER) ? " uncover" : "", 136 + (regstatus & TPS_REG_UVLO) ? " UVLO" : "", 137 + (regstatus & TPS_REG_NO_CHG) ? " NO_CHG" : "", 138 + (regstatus & TPS_REG_PG_LD02) ? " ld01_bad" : "", 139 + (regstatus & TPS_REG_PG_LD01) ? " ld01_bad" : "", 140 + (regstatus & TPS_REG_PG_MAIN) ? " main_bad" : "", 141 + (regstatus & TPS_REG_PG_CORE) ? " core_bad" : ""); 142 + } 143 + 144 + static void dbg_chgconf(int por, char *buf, size_t len, u8 chgconfig) 145 + { 146 + char *hibit; 147 + 148 + if (por) 149 + hibit = (chgconfig & TPS_CHARGE_POR) 150 + ? "POR=69ms" : "POR=1sec"; 151 + else 152 + hibit = (chgconfig & TPS65013_AUA) ? "AUA" : ""; 153 + 154 + snprintf(buf, len, "%02x %s%s%s AC=%d%% USB=%dmA %sCharge\n", 155 + chgconfig, hibit, 156 + (chgconfig & TPS_CHARGE_RESET) ? " reset" : "", 157 + (chgconfig & TPS_CHARGE_FAST) ? " fast" : "", 158 + ({int p; switch ((chgconfig >> 3) & 3) { 159 + case 3: p = 100; break; 160 + case 2: p = 75; break; 161 + case 1: p = 50; break; 162 + default: p = 25; break; 163 + }; p; }), 164 + (chgconfig & TPS_VBUS_CHARGING) 165 + ? ((chgconfig & TPS_VBUS_500MA) ? 500 : 100) 166 + : 0, 167 + (chgconfig & TPS_CHARGE_ENABLE) ? "" : "No"); 168 + } 169 + 170 + #endif 171 + 172 + #ifdef DEBUG 173 + 174 + static void show_chgstatus(const char *label, u8 chgstatus) 175 + { 176 + char buf [100]; 177 + 178 + dbg_chgstat(buf, sizeof buf, chgstatus); 179 + pr_debug("%s: %s %s", DRIVER_NAME, label, buf); 180 + } 181 + 182 + static void show_regstatus(const char *label, u8 regstatus) 183 + { 184 + char buf [100]; 185 + 186 + dbg_regstat(buf, sizeof buf, regstatus); 187 + pr_debug("%s: %s %s", DRIVER_NAME, label, buf); 188 + } 189 + 190 + static void show_chgconfig(int por, const char *label, u8 chgconfig) 191 + { 192 + char buf [100]; 193 + 194 + dbg_chgconf(por, buf, sizeof buf, chgconfig); 195 + pr_debug("%s: %s %s", DRIVER_NAME, label, buf); 196 + } 197 + 198 + #else 199 + 200 + static inline void show_chgstatus(const char *label, u8 chgstatus) { } 201 + static inline void show_regstatus(const char *label, u8 chgstatus) { } 202 + static inline void show_chgconfig(int por, const char *label, u8 chgconfig) { } 203 + 204 + #endif 205 + 206 + #ifdef CONFIG_DEBUG_FS 207 + 208 + static int dbg_show(struct seq_file *s, void *_) 209 + { 210 + struct tps65010 *tps = s->private; 211 + u8 value, v2; 212 + unsigned i; 213 + char buf[100]; 214 + const char *chip; 215 + 216 + switch (tps->model) { 217 + case TPS65010: chip = "tps65010"; break; 218 + case TPS65011: chip = "tps65011"; break; 219 + case TPS65012: chip = "tps65012"; break; 220 + case TPS65013: chip = "tps65013"; break; 221 + default: chip = NULL; break; 222 + } 223 + seq_printf(s, "driver %s\nversion %s\nchip %s\n\n", 224 + DRIVER_NAME, DRIVER_VERSION, chip); 225 + 226 + down(&tps->lock); 227 + 228 + /* FIXME how can we tell whether a battery is present? 229 + * likely involves a charge gauging chip (like BQ26501). 230 + */ 231 + 232 + seq_printf(s, "%scharging\n\n", tps->charging ? "" : "(not) "); 233 + 234 + 235 + /* registers for monitoring battery charging and status; note 236 + * that reading chgstat and regstat may ack IRQs... 237 + */ 238 + value = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG); 239 + dbg_chgconf(tps->por, buf, sizeof buf, value); 240 + seq_printf(s, "chgconfig %s", buf); 241 + 242 + value = i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS); 243 + dbg_chgstat(buf, sizeof buf, value); 244 + seq_printf(s, "chgstat %s", buf); 245 + value = i2c_smbus_read_byte_data(&tps->client, TPS_MASK1); 246 + dbg_chgstat(buf, sizeof buf, value); 247 + seq_printf(s, "mask1 %s", buf); 248 + /* ignore ackint1 */ 249 + 250 + value = i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS); 251 + dbg_regstat(buf, sizeof buf, value); 252 + seq_printf(s, "regstat %s", buf); 253 + value = i2c_smbus_read_byte_data(&tps->client, TPS_MASK2); 254 + dbg_regstat(buf, sizeof buf, value); 255 + seq_printf(s, "mask2 %s\n", buf); 256 + /* ignore ackint2 */ 257 + 258 + (void) schedule_delayed_work(&tps->work, POWER_POLL_DELAY); 259 + 260 + 261 + /* VMAIN voltage, enable lowpower, etc */ 262 + value = i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC1); 263 + seq_printf(s, "vdcdc1 %02x\n", value); 264 + 265 + /* VCORE voltage, vibrator on/off */ 266 + value = i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC2); 267 + seq_printf(s, "vdcdc2 %02x\n", value); 268 + 269 + /* both LD0s, and their lowpower behavior */ 270 + value = i2c_smbus_read_byte_data(&tps->client, TPS_VREGS1); 271 + seq_printf(s, "vregs1 %02x\n\n", value); 272 + 273 + 274 + /* LEDs and GPIOs */ 275 + value = i2c_smbus_read_byte_data(&tps->client, TPS_LED1_ON); 276 + v2 = i2c_smbus_read_byte_data(&tps->client, TPS_LED1_PER); 277 + seq_printf(s, "led1 %s, on=%02x, per=%02x, %d/%d msec\n", 278 + (value & 0x80) 279 + ? ((v2 & 0x80) ? "on" : "off") 280 + : ((v2 & 0x80) ? "blink" : "(nPG)"), 281 + value, v2, 282 + (value & 0x7f) * 10, (v2 & 0x7f) * 100); 283 + 284 + value = i2c_smbus_read_byte_data(&tps->client, TPS_LED2_ON); 285 + v2 = i2c_smbus_read_byte_data(&tps->client, TPS_LED2_PER); 286 + seq_printf(s, "led2 %s, on=%02x, per=%02x, %d/%d msec\n", 287 + (value & 0x80) 288 + ? ((v2 & 0x80) ? "on" : "off") 289 + : ((v2 & 0x80) ? "blink" : "off"), 290 + value, v2, 291 + (value & 0x7f) * 10, (v2 & 0x7f) * 100); 292 + 293 + value = i2c_smbus_read_byte_data(&tps->client, TPS_DEFGPIO); 294 + v2 = i2c_smbus_read_byte_data(&tps->client, TPS_MASK3); 295 + seq_printf(s, "defgpio %02x mask3 %02x\n", value, v2); 296 + 297 + for (i = 0; i < 4; i++) { 298 + if (value & (1 << (4 +i))) 299 + seq_printf(s, " gpio%d-out %s\n", i + 1, 300 + (value & (1 << i)) ? "low" : "hi "); 301 + else 302 + seq_printf(s, " gpio%d-in %s %s %s\n", i + 1, 303 + (value & (1 << i)) ? "hi " : "low", 304 + (v2 & (1 << i)) ? "no-irq" : "irq", 305 + (v2 & (1 << (4 + i))) ? "rising" : "falling"); 306 + } 307 + 308 + up(&tps->lock); 309 + return 0; 310 + } 311 + 312 + static int dbg_tps_open(struct inode *inode, struct file *file) 313 + { 314 + return single_open(file, dbg_show, inode->u.generic_ip); 315 + } 316 + 317 + static struct file_operations debug_fops = { 318 + .open = dbg_tps_open, 319 + .read = seq_read, 320 + .llseek = seq_lseek, 321 + .release = single_release, 322 + }; 323 + 324 + #define DEBUG_FOPS &debug_fops 325 + 326 + #else 327 + #define DEBUG_FOPS NULL 328 + #endif 329 + 330 + /*-------------------------------------------------------------------------*/ 331 + 332 + /* handle IRQS in a task context, so we can use I2C calls */ 333 + static void tps65010_interrupt(struct tps65010 *tps) 334 + { 335 + u8 tmp = 0, mask, poll; 336 + 337 + /* IRQs won't trigger irqs for certain events, but we can get 338 + * others by polling (normally, with external power applied). 339 + */ 340 + poll = 0; 341 + 342 + /* regstatus irqs */ 343 + if (tps->nmask2) { 344 + tmp = i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS); 345 + mask = tmp ^ tps->regstatus; 346 + tps->regstatus = tmp; 347 + mask &= tps->nmask2; 348 + } else 349 + mask = 0; 350 + if (mask) { 351 + tps->regstatus = tmp; 352 + /* may need to shut something down ... */ 353 + 354 + /* "off" usually means deep sleep */ 355 + if (tmp & TPS_REG_ONOFF) { 356 + pr_info("%s: power off button\n", DRIVER_NAME); 357 + #if 0 358 + /* REVISIT: this might need its own workqueue 359 + * plus tweaks including deadlock avoidance ... 360 + */ 361 + software_suspend(); 362 + #endif 363 + poll = 1; 364 + } 365 + } 366 + 367 + /* chgstatus irqs */ 368 + if (tps->nmask1) { 369 + tmp = i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS); 370 + mask = tmp ^ tps->chgstatus; 371 + tps->chgstatus = tmp; 372 + mask &= tps->nmask1; 373 + } else 374 + mask = 0; 375 + if (mask) { 376 + unsigned charging = 0; 377 + 378 + show_chgstatus("chg/irq", tmp); 379 + if (tmp & (TPS_CHG_USB|TPS_CHG_AC)) 380 + show_chgconfig(tps->por, "conf", tps->chgconf); 381 + 382 + /* Unless it was turned off or disabled, we charge any 383 + * battery whenever there's power available for it 384 + * and the charger hasn't been disabled. 385 + */ 386 + if (!(tps->chgstatus & ~(TPS_CHG_USB|TPS_CHG_AC)) 387 + && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC)) 388 + && (tps->chgconf & TPS_CHARGE_ENABLE) 389 + ) { 390 + if (tps->chgstatus & TPS_CHG_USB) { 391 + /* VBUS options are readonly until reconnect */ 392 + if (mask & TPS_CHG_USB) 393 + set_bit(FLAG_VBUS_CHANGED, &tps->flags); 394 + charging = 1; 395 + } else if (tps->chgstatus & TPS_CHG_AC) 396 + charging = 1; 397 + } 398 + if (charging != tps->charging) { 399 + tps->charging = charging; 400 + pr_info("%s: battery %scharging\n", 401 + DRIVER_NAME, charging ? "" : 402 + ((tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC)) 403 + ? "NOT " : "dis")); 404 + } 405 + } 406 + 407 + /* always poll to detect (a) power removal, without tps65013 408 + * NO_CHG IRQ; or (b) restart of charging after stop. 409 + */ 410 + if ((tps->model != TPS65013 || !tps->charging) 411 + && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))) 412 + poll = 1; 413 + if (poll) 414 + (void) schedule_delayed_work(&tps->work, POWER_POLL_DELAY); 415 + 416 + /* also potentially gpio-in rise or fall */ 417 + } 418 + 419 + /* handle IRQs and polling using keventd for now */ 420 + static void tps65010_work(void *_tps) 421 + { 422 + struct tps65010 *tps = _tps; 423 + 424 + down(&tps->lock); 425 + 426 + tps65010_interrupt(tps); 427 + 428 + if (test_and_clear_bit(FLAG_VBUS_CHANGED, &tps->flags)) { 429 + int status; 430 + u8 chgconfig, tmp; 431 + 432 + chgconfig = i2c_smbus_read_byte_data(&tps->client, 433 + TPS_CHGCONFIG); 434 + chgconfig &= ~(TPS_VBUS_500MA | TPS_VBUS_CHARGING); 435 + if (tps->vbus == 500) 436 + chgconfig |= TPS_VBUS_500MA | TPS_VBUS_CHARGING; 437 + else if (tps->vbus >= 100) 438 + chgconfig |= TPS_VBUS_CHARGING; 439 + 440 + status = i2c_smbus_write_byte_data(&tps->client, 441 + TPS_CHGCONFIG, chgconfig); 442 + 443 + /* vbus update fails unless VBUS is connected! */ 444 + tmp = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG); 445 + tps->chgconf = tmp; 446 + show_chgconfig(tps->por, "update vbus", tmp); 447 + } 448 + 449 + if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags)) 450 + enable_irq(tps->irq); 451 + 452 + up(&tps->lock); 453 + } 454 + 455 + static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs) 456 + { 457 + struct tps65010 *tps = _tps; 458 + 459 + disable_irq_nosync(irq); 460 + set_bit(FLAG_IRQ_ENABLE, &tps->flags); 461 + (void) schedule_work(&tps->work); 462 + return IRQ_HANDLED; 463 + } 464 + 465 + /*-------------------------------------------------------------------------*/ 466 + 467 + static struct tps65010 *the_tps; 468 + 469 + static int __exit tps65010_detach_client(struct i2c_client *client) 470 + { 471 + struct tps65010 *tps; 472 + 473 + tps = container_of(client, struct tps65010, client); 474 + #ifdef CONFIG_ARM 475 + if (machine_is_omap_h2()) 476 + omap_free_gpio(58); 477 + if (machine_is_omap_osk()) 478 + omap_free_gpio(OMAP_MPUIO(1)); 479 + #endif 480 + free_irq(tps->irq, tps); 481 + debugfs_remove(tps->file); 482 + if (i2c_detach_client(client) == 0) 483 + kfree(tps); 484 + the_tps = 0; 485 + return 0; 486 + } 487 + 488 + static int tps65010_noscan(struct i2c_adapter *bus) 489 + { 490 + /* pure paranoia, in case someone adds another i2c bus 491 + * after our init section's gone... 492 + */ 493 + return -ENODEV; 494 + } 495 + 496 + /* no error returns, they'd just make bus scanning stop */ 497 + static int __init 498 + tps65010_probe(struct i2c_adapter *bus, int address, int kind) 499 + { 500 + struct tps65010 *tps; 501 + int status; 502 + 503 + if (the_tps) { 504 + dev_dbg(&bus->dev, "only one %s for now\n", DRIVER_NAME); 505 + return 0; 506 + } 507 + 508 + tps = kmalloc(sizeof *tps, GFP_KERNEL); 509 + if (!tps) 510 + return 0; 511 + 512 + memset(tps, 0, sizeof *tps); 513 + init_MUTEX(&tps->lock); 514 + INIT_WORK(&tps->work, tps65010_work, tps); 515 + tps->irq = -1; 516 + tps->client.addr = address; 517 + i2c_set_clientdata(&tps->client, tps); 518 + tps->client.adapter = bus; 519 + tps->client.driver = &tps65010_driver; 520 + strlcpy(tps->client.name, DRIVER_NAME, I2C_NAME_SIZE); 521 + 522 + status = i2c_attach_client(&tps->client); 523 + if (status < 0) { 524 + dev_dbg(&bus->dev, "can't attach %s to device %d, err %d\n", 525 + DRIVER_NAME, address, status); 526 + fail1: 527 + kfree(tps); 528 + return 0; 529 + } 530 + 531 + #ifdef CONFIG_ARM 532 + if (machine_is_omap_h2()) { 533 + tps->model = TPS65010; 534 + omap_cfg_reg(W4_GPIO58); 535 + tps->irq = OMAP_GPIO_IRQ(58); 536 + omap_request_gpio(58); 537 + omap_set_gpio_direction(58, 1); 538 + omap_set_gpio_edge_ctrl(58, OMAP_GPIO_FALLING_EDGE); 539 + } 540 + if (machine_is_omap_osk()) { 541 + tps->model = TPS65010; 542 + // omap_cfg_reg(U19_1610_MPUIO1); 543 + tps->irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1)); 544 + omap_request_gpio(OMAP_MPUIO(1)); 545 + omap_set_gpio_direction(OMAP_MPUIO(1), 1); 546 + omap_set_gpio_edge_ctrl(OMAP_MPUIO(1), OMAP_GPIO_FALLING_EDGE); 547 + } 548 + if (machine_is_omap_h3()) { 549 + tps->model = TPS65013; 550 + 551 + // FIXME set up this board's IRQ ... 552 + } 553 + #else 554 + #define set_irq_type(num,trigger) do{}while(0) 555 + #endif 556 + 557 + if (tps->irq > 0) { 558 + set_irq_type(tps->irq, IRQT_LOW); 559 + status = request_irq(tps->irq, tps65010_irq, 560 + SA_SAMPLE_RANDOM, DRIVER_NAME, tps); 561 + if (status < 0) { 562 + dev_dbg(&tps->client.dev, "can't get IRQ %d, err %d\n", 563 + tps->irq, status); 564 + i2c_detach_client(&tps->client); 565 + goto fail1; 566 + } 567 + #ifdef CONFIG_ARM 568 + /* annoying race here, ideally we'd have an option 569 + * to claim the irq now and enable it later. 570 + */ 571 + disable_irq(tps->irq); 572 + set_bit(FLAG_IRQ_ENABLE, &tps->flags); 573 + #endif 574 + } else 575 + printk(KERN_WARNING "%s: IRQ not configured!\n", 576 + DRIVER_NAME); 577 + 578 + 579 + switch (tps->model) { 580 + case TPS65010: 581 + case TPS65012: 582 + tps->por = 1; 583 + break; 584 + case TPS_UNKNOWN: 585 + printk(KERN_WARNING "%s: unknown TPS chip\n", DRIVER_NAME); 586 + break; 587 + /* else CHGCONFIG.POR is replaced by AUA, enabling a WAIT mode */ 588 + } 589 + tps->chgconf = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG); 590 + show_chgconfig(tps->por, "conf/init", tps->chgconf); 591 + 592 + show_chgstatus("chg/init", 593 + i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS)); 594 + show_regstatus("reg/init", 595 + i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS)); 596 + 597 + pr_debug("%s: vdcdc1 0x%02x, vdcdc2 %02x, vregs1 %02x\n", DRIVER_NAME, 598 + i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC1), 599 + i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC2), 600 + i2c_smbus_read_byte_data(&tps->client, TPS_VREGS1)); 601 + pr_debug("%s: defgpio 0x%02x, mask3 0x%02x\n", DRIVER_NAME, 602 + i2c_smbus_read_byte_data(&tps->client, TPS_DEFGPIO), 603 + i2c_smbus_read_byte_data(&tps->client, TPS_MASK3)); 604 + 605 + tps65010_driver.attach_adapter = tps65010_noscan; 606 + the_tps = tps; 607 + 608 + #if defined(CONFIG_USB_GADGET) && !defined(CONFIG_USB_OTG) 609 + /* USB hosts can't draw VBUS. OTG devices could, later 610 + * when OTG infrastructure enables it. USB peripherals 611 + * could be relying on VBUS while booting, though. 612 + */ 613 + tps->vbus = 100; 614 + #endif 615 + 616 + /* unmask the "interesting" irqs, then poll once to 617 + * kickstart monitoring, initialize shadowed status 618 + * registers, and maybe disable VBUS draw. 619 + */ 620 + tps->nmask1 = ~0; 621 + (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK1, ~tps->nmask1); 622 + 623 + tps->nmask2 = TPS_REG_ONOFF; 624 + if (tps->model == TPS65013) 625 + tps->nmask2 |= TPS_REG_NO_CHG; 626 + (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK2, ~tps->nmask2); 627 + 628 + (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK3, 0x0f 629 + | i2c_smbus_read_byte_data(&tps->client, TPS_MASK3)); 630 + 631 + tps65010_work(tps); 632 + 633 + tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL, 634 + tps, DEBUG_FOPS); 635 + return 0; 636 + } 637 + 638 + static int __init tps65010_scan_bus(struct i2c_adapter *bus) 639 + { 640 + if (!i2c_check_functionality(bus, I2C_FUNC_SMBUS_BYTE_DATA)) 641 + return -EINVAL; 642 + return i2c_probe(bus, &addr_data, tps65010_probe); 643 + } 644 + 645 + static struct i2c_driver tps65010_driver = { 646 + .owner = THIS_MODULE, 647 + .name = "tps65010", 648 + .id = 888, /* FIXME assign "official" value */ 649 + .flags = I2C_DF_NOTIFY, 650 + .attach_adapter = tps65010_scan_bus, 651 + .detach_client = __exit_p(tps65010_detach_client), 652 + }; 653 + 654 + /*-------------------------------------------------------------------------*/ 655 + 656 + /* Draw from VBUS: 657 + * 0 mA -- DON'T DRAW (might supply power instead) 658 + * 100 mA -- usb unit load (slowest charge rate) 659 + * 500 mA -- usb high power (fast battery charge) 660 + */ 661 + int tps65010_set_vbus_draw(unsigned mA) 662 + { 663 + unsigned long flags; 664 + 665 + if (!the_tps) 666 + return -ENODEV; 667 + 668 + /* assumes non-SMP */ 669 + local_irq_save(flags); 670 + if (mA >= 500) 671 + mA = 500; 672 + else if (mA >= 100) 673 + mA = 100; 674 + else 675 + mA = 0; 676 + the_tps->vbus = mA; 677 + if ((the_tps->chgstatus & TPS_CHG_USB) 678 + && test_and_set_bit( 679 + FLAG_VBUS_CHANGED, &the_tps->flags)) { 680 + /* gadget drivers call this in_irq() */ 681 + (void) schedule_work(&the_tps->work); 682 + } 683 + local_irq_restore(flags); 684 + 685 + return 0; 686 + } 687 + EXPORT_SYMBOL(tps65010_set_vbus_draw); 688 + 689 + /*-------------------------------------------------------------------------*/ 690 + /* tps65010_set_gpio_out_value parameter: 691 + * gpio: GPIO1, GPIO2, GPIO3 or GPIO4 692 + * value: LOW or HIGH 693 + */ 694 + int tps65010_set_gpio_out_value(unsigned gpio, unsigned value) 695 + { 696 + int status; 697 + unsigned defgpio; 698 + 699 + if (!the_tps) 700 + return -ENODEV; 701 + if ((gpio < GPIO1) || (gpio > GPIO4)) 702 + return -EINVAL; 703 + 704 + down(&the_tps->lock); 705 + 706 + defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO); 707 + 708 + /* Configure GPIO for output */ 709 + defgpio |= 1 << (gpio + 3); 710 + 711 + /* Writing 1 forces a logic 0 on that GPIO and vice versa */ 712 + switch (value) { 713 + case LOW: 714 + defgpio |= 1 << (gpio - 1); /* set GPIO low by writing 1 */ 715 + break; 716 + /* case HIGH: */ 717 + default: 718 + defgpio &= ~(1 << (gpio - 1)); /* set GPIO high by writing 0 */ 719 + break; 720 + } 721 + 722 + status = i2c_smbus_write_byte_data(&the_tps->client, 723 + TPS_DEFGPIO, defgpio); 724 + 725 + pr_debug("%s: gpio%dout = %s, defgpio 0x%02x\n", DRIVER_NAME, 726 + gpio, value ? "high" : "low", 727 + i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO)); 728 + 729 + up(&the_tps->lock); 730 + return status; 731 + } 732 + EXPORT_SYMBOL(tps65010_set_gpio_out_value); 733 + 734 + /*-------------------------------------------------------------------------*/ 735 + /* tps65010_set_led parameter: 736 + * led: LED1 or LED2 737 + * mode: ON, OFF or BLINK 738 + */ 739 + int tps65010_set_led(unsigned led, unsigned mode) 740 + { 741 + int status; 742 + unsigned led_on, led_per, offs; 743 + 744 + if (!the_tps) 745 + return -ENODEV; 746 + 747 + if(led == LED1) 748 + offs = 0; 749 + else { 750 + offs = 2; 751 + led = LED2; 752 + } 753 + 754 + down(&the_tps->lock); 755 + 756 + dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led, 757 + i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs)); 758 + 759 + dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led, 760 + i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs)); 761 + 762 + switch (mode) { 763 + case OFF: 764 + led_on = 1 << 7; 765 + led_per = 0 << 7; 766 + break; 767 + case ON: 768 + led_on = 1 << 7; 769 + led_per = 1 << 7; 770 + break; 771 + case BLINK: 772 + led_on = 0x30 | (0 << 7); 773 + led_per = 0x08 | (1 << 7); 774 + break; 775 + default: 776 + printk(KERN_ERR "%s: Wrong mode parameter for tps65010_set_led()\n", 777 + DRIVER_NAME); 778 + up(&the_tps->lock); 779 + return -EINVAL; 780 + } 781 + 782 + status = i2c_smbus_write_byte_data(&the_tps->client, 783 + TPS_LED1_ON + offs, led_on); 784 + 785 + if (status != 0) { 786 + printk(KERN_ERR "%s: Failed to write led%i_on register\n", 787 + DRIVER_NAME, led); 788 + up(&the_tps->lock); 789 + return status; 790 + } 791 + 792 + dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led, 793 + i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs)); 794 + 795 + status = i2c_smbus_write_byte_data(&the_tps->client, 796 + TPS_LED1_PER + offs, led_per); 797 + 798 + if (status != 0) { 799 + printk(KERN_ERR "%s: Failed to write led%i_per register\n", 800 + DRIVER_NAME, led); 801 + up(&the_tps->lock); 802 + return status; 803 + } 804 + 805 + dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led, 806 + i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs)); 807 + 808 + up(&the_tps->lock); 809 + 810 + return status; 811 + } 812 + EXPORT_SYMBOL(tps65010_set_led); 813 + 814 + /*-------------------------------------------------------------------------*/ 815 + /* tps65010_set_vib parameter: 816 + * value: ON or OFF 817 + */ 818 + int tps65010_set_vib(unsigned value) 819 + { 820 + int status; 821 + unsigned vdcdc2; 822 + 823 + if (!the_tps) 824 + return -ENODEV; 825 + 826 + down(&the_tps->lock); 827 + 828 + vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2); 829 + vdcdc2 &= ~(1 << 1); 830 + if (value) 831 + vdcdc2 |= (1 << 1); 832 + status = i2c_smbus_write_byte_data(&the_tps->client, 833 + TPS_VDCDC2, vdcdc2); 834 + 835 + pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off"); 836 + 837 + up(&the_tps->lock); 838 + return status; 839 + } 840 + EXPORT_SYMBOL(tps65010_set_vib); 841 + 842 + /*-------------------------------------------------------------------------*/ 843 + /* tps65010_set_low_pwr parameter: 844 + * mode: ON or OFF 845 + */ 846 + int tps65010_set_low_pwr(unsigned mode) 847 + { 848 + int status; 849 + unsigned vdcdc1; 850 + 851 + if (!the_tps) 852 + return -ENODEV; 853 + 854 + down(&the_tps->lock); 855 + 856 + pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME, 857 + mode ? "enable" : "disable", 858 + i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); 859 + 860 + vdcdc1 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1); 861 + 862 + switch (mode) { 863 + case OFF: 864 + vdcdc1 &= ~TPS_ENABLE_LP; /* disable ENABLE_LP bit */ 865 + break; 866 + /* case ON: */ 867 + default: 868 + vdcdc1 |= TPS_ENABLE_LP; /* enable ENABLE_LP bit */ 869 + break; 870 + } 871 + 872 + status = i2c_smbus_write_byte_data(&the_tps->client, 873 + TPS_VDCDC1, vdcdc1); 874 + 875 + if (status != 0) 876 + printk(KERN_ERR "%s: Failed to write vdcdc1 register\n", 877 + DRIVER_NAME); 878 + else 879 + pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, 880 + i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); 881 + 882 + up(&the_tps->lock); 883 + 884 + return status; 885 + } 886 + EXPORT_SYMBOL(tps65010_set_low_pwr); 887 + 888 + /*-------------------------------------------------------------------------*/ 889 + /* tps65010_config_vregs1 parameter: 890 + * value to be written to VREGS1 register 891 + * Note: The complete register is written, set all bits you need 892 + */ 893 + int tps65010_config_vregs1(unsigned value) 894 + { 895 + int status; 896 + 897 + if (!the_tps) 898 + return -ENODEV; 899 + 900 + down(&the_tps->lock); 901 + 902 + pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, 903 + i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); 904 + 905 + status = i2c_smbus_write_byte_data(&the_tps->client, 906 + TPS_VREGS1, value); 907 + 908 + if (status != 0) 909 + printk(KERN_ERR "%s: Failed to write vregs1 register\n", 910 + DRIVER_NAME); 911 + else 912 + pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, 913 + i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); 914 + 915 + up(&the_tps->lock); 916 + 917 + return status; 918 + } 919 + EXPORT_SYMBOL(tps65010_config_vregs1); 920 + 921 + /*-------------------------------------------------------------------------*/ 922 + /* tps65013_set_low_pwr parameter: 923 + * mode: ON or OFF 924 + */ 925 + 926 + /* FIXME: Assumes AC or USB power is present. Setting AUA bit is not 927 + required if power supply is through a battery */ 928 + 929 + int tps65013_set_low_pwr(unsigned mode) 930 + { 931 + int status; 932 + unsigned vdcdc1, chgconfig; 933 + 934 + if (!the_tps || the_tps->por) 935 + return -ENODEV; 936 + 937 + down(&the_tps->lock); 938 + 939 + pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n", 940 + DRIVER_NAME, 941 + mode ? "enable" : "disable", 942 + i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG), 943 + i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); 944 + 945 + chgconfig = i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG); 946 + vdcdc1 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1); 947 + 948 + switch (mode) { 949 + case OFF: 950 + chgconfig &= ~TPS65013_AUA; /* disable AUA bit */ 951 + vdcdc1 &= ~TPS_ENABLE_LP; /* disable ENABLE_LP bit */ 952 + break; 953 + /* case ON: */ 954 + default: 955 + chgconfig |= TPS65013_AUA; /* enable AUA bit */ 956 + vdcdc1 |= TPS_ENABLE_LP; /* enable ENABLE_LP bit */ 957 + break; 958 + } 959 + 960 + status = i2c_smbus_write_byte_data(&the_tps->client, 961 + TPS_CHGCONFIG, chgconfig); 962 + if (status != 0) { 963 + printk(KERN_ERR "%s: Failed to write chconfig register\n", 964 + DRIVER_NAME); 965 + up(&the_tps->lock); 966 + return status; 967 + } 968 + 969 + chgconfig = i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG); 970 + the_tps->chgconf = chgconfig; 971 + show_chgconfig(0, "chgconf", chgconfig); 972 + 973 + status = i2c_smbus_write_byte_data(&the_tps->client, 974 + TPS_VDCDC1, vdcdc1); 975 + 976 + if (status != 0) 977 + printk(KERN_ERR "%s: Failed to write vdcdc1 register\n", 978 + DRIVER_NAME); 979 + else 980 + pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, 981 + i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); 982 + 983 + up(&the_tps->lock); 984 + 985 + return status; 986 + } 987 + EXPORT_SYMBOL(tps65013_set_low_pwr); 988 + 989 + /*-------------------------------------------------------------------------*/ 990 + 991 + static int __init tps_init(void) 992 + { 993 + u32 tries = 3; 994 + int status = -ENODEV; 995 + 996 + printk(KERN_INFO "%s: version %s\n", DRIVER_NAME, DRIVER_VERSION); 997 + 998 + /* some boards have startup glitches */ 999 + while (tries--) { 1000 + status = i2c_add_driver(&tps65010_driver); 1001 + if (the_tps) 1002 + break; 1003 + i2c_del_driver(&tps65010_driver); 1004 + if (!tries) { 1005 + printk(KERN_ERR "%s: no chip?\n", DRIVER_NAME); 1006 + return -ENODEV; 1007 + } 1008 + pr_debug("%s: re-probe ...\n", DRIVER_NAME); 1009 + msleep(10); 1010 + } 1011 + 1012 + #if defined(CONFIG_ARM) 1013 + if (machine_is_omap_osk()) { 1014 + 1015 + // FIXME: More should be placed in the initialization code 1016 + // of the submodules (DSP, ethernet, power management, 1017 + // board-osk.c). Careful: I2C is initialized "late". 1018 + 1019 + /* Let LED1 (D9) blink */ 1020 + tps65010_set_led(LED1, BLINK); 1021 + 1022 + /* Disable LED 2 (D2) */ 1023 + tps65010_set_led(LED2, OFF); 1024 + 1025 + /* Set GPIO 1 HIGH to disable VBUS power supply; 1026 + * OHCI driver powers it up/down as needed. 1027 + */ 1028 + tps65010_set_gpio_out_value(GPIO1, HIGH); 1029 + 1030 + /* Set GPIO 2 low to turn on LED D3 */ 1031 + tps65010_set_gpio_out_value(GPIO2, HIGH); 1032 + 1033 + /* Set GPIO 3 low to take ethernet out of reset */ 1034 + tps65010_set_gpio_out_value(GPIO3, LOW); 1035 + 1036 + /* gpio4 for VDD_DSP */ 1037 + 1038 + /* Enable LOW_PWR */ 1039 + tps65010_set_low_pwr(ON); 1040 + 1041 + /* Switch VLDO2 to 3.0V for AIC23 */ 1042 + tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V | TPS_LDO1_ENABLE); 1043 + 1044 + } else if (machine_is_omap_h2()) { 1045 + /* gpio3 for SD, gpio4 for VDD_DSP */ 1046 + 1047 + /* Enable LOW_PWR */ 1048 + tps65010_set_low_pwr(ON); 1049 + } else if (machine_is_omap_h3()) { 1050 + /* gpio4 for SD, gpio3 for VDD_DSP */ 1051 + #ifdef CONFIG_PM 1052 + /* Enable LOW_PWR */ 1053 + tps65013_set_low_pwr(ON); 1054 + #endif 1055 + } 1056 + #endif 1057 + 1058 + return status; 1059 + } 1060 + /* NOTE: this MUST be initialized before the other parts of the system 1061 + * that rely on it ... but after the i2c bus on which this relies. 1062 + * That is, much earlier than on PC-type systems, which don't often use 1063 + * I2C as a core system bus. 1064 + */ 1065 + subsys_initcall(tps_init); 1066 + 1067 + static void __exit tps_exit(void) 1068 + { 1069 + i2c_del_driver(&tps65010_driver); 1070 + } 1071 + module_exit(tps_exit); 1072 +
+147 -150
drivers/i2c/chips/via686a.c
··· 1 1 /* 2 2 via686a.c - Part of lm_sensors, Linux kernel modules 3 3 for hardware monitoring 4 - 4 + 5 5 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, 6 6 Ky�sti M�lkki <kmalkki@cc.hut.fi>, 7 7 Mark Studebaker <mdsxyz123@yahoo.com>, 8 8 and Bob Dougherty <bobd@stanford.edu> 9 - (Some conversion-factor data were contributed by Jonathan Teh Soon Yew 9 + (Some conversion-factor data were contributed by Jonathan Teh Soon Yew 10 10 <j.teh@iname.com> and Alex van Kaam <darkside@chello.nl>.) 11 11 12 12 This program is free software; you can redistribute it and/or modify ··· 30 30 Warning - only supports a single device. 31 31 */ 32 32 33 - #include <linux/config.h> 34 33 #include <linux/module.h> 35 34 #include <linux/slab.h> 36 35 #include <linux/pci.h> 37 - #include <linux/delay.h> 38 36 #include <linux/jiffies.h> 39 37 #include <linux/i2c.h> 40 38 #include <linux/i2c-sensor.h> ··· 64 66 /* Many VIA686A constants specified below */ 65 67 66 68 /* Length of ISA address segment */ 67 - #define VIA686A_EXTENT 0x80 68 - #define VIA686A_BASE_REG 0x70 69 - #define VIA686A_ENABLE_REG 0x74 69 + #define VIA686A_EXTENT 0x80 70 + #define VIA686A_BASE_REG 0x70 71 + #define VIA686A_ENABLE_REG 0x74 70 72 71 73 /* The VIA686A registers */ 72 74 /* ins numbered 0-4 */ 73 - #define VIA686A_REG_IN_MAX(nr) (0x2b + ((nr) * 2)) 74 - #define VIA686A_REG_IN_MIN(nr) (0x2c + ((nr) * 2)) 75 - #define VIA686A_REG_IN(nr) (0x22 + (nr)) 75 + #define VIA686A_REG_IN_MAX(nr) (0x2b + ((nr) * 2)) 76 + #define VIA686A_REG_IN_MIN(nr) (0x2c + ((nr) * 2)) 77 + #define VIA686A_REG_IN(nr) (0x22 + (nr)) 76 78 77 79 /* fans numbered 1-2 */ 78 - #define VIA686A_REG_FAN_MIN(nr) (0x3a + (nr)) 79 - #define VIA686A_REG_FAN(nr) (0x28 + (nr)) 80 - 81 - /* the following values are as speced by VIA: */ 82 - static const u8 regtemp[] = { 0x20, 0x21, 0x1f }; 83 - static const u8 regover[] = { 0x39, 0x3d, 0x1d }; 84 - static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e }; 80 + #define VIA686A_REG_FAN_MIN(nr) (0x3a + (nr)) 81 + #define VIA686A_REG_FAN(nr) (0x28 + (nr)) 85 82 86 83 /* temps numbered 1-3 */ 87 - #define VIA686A_REG_TEMP(nr) (regtemp[nr]) 88 - #define VIA686A_REG_TEMP_OVER(nr) (regover[nr]) 89 - #define VIA686A_REG_TEMP_HYST(nr) (reghyst[nr]) 90 - #define VIA686A_REG_TEMP_LOW1 0x4b // bits 7-6 91 - #define VIA686A_REG_TEMP_LOW23 0x49 // 2 = bits 5-4, 3 = bits 7-6 84 + static const u8 VIA686A_REG_TEMP[] = { 0x20, 0x21, 0x1f }; 85 + static const u8 VIA686A_REG_TEMP_OVER[] = { 0x39, 0x3d, 0x1d }; 86 + static const u8 VIA686A_REG_TEMP_HYST[] = { 0x3a, 0x3e, 0x1e }; 87 + /* bits 7-6 */ 88 + #define VIA686A_REG_TEMP_LOW1 0x4b 89 + /* 2 = bits 5-4, 3 = bits 7-6 */ 90 + #define VIA686A_REG_TEMP_LOW23 0x49 92 91 93 - #define VIA686A_REG_ALARM1 0x41 94 - #define VIA686A_REG_ALARM2 0x42 95 - #define VIA686A_REG_FANDIV 0x47 96 - #define VIA686A_REG_CONFIG 0x40 97 - /* The following register sets temp interrupt mode (bits 1-0 for temp1, 92 + #define VIA686A_REG_ALARM1 0x41 93 + #define VIA686A_REG_ALARM2 0x42 94 + #define VIA686A_REG_FANDIV 0x47 95 + #define VIA686A_REG_CONFIG 0x40 96 + /* The following register sets temp interrupt mode (bits 1-0 for temp1, 98 97 3-2 for temp2, 5-4 for temp3). Modes are: 99 98 00 interrupt stays as long as value is out-of-range 100 99 01 interrupt is cleared once register is read (default) 101 100 10 comparator mode- like 00, but ignores hysteresis 102 101 11 same as 00 */ 103 - #define VIA686A_REG_TEMP_MODE 0x4b 102 + #define VIA686A_REG_TEMP_MODE 0x4b 104 103 /* We'll just assume that you want to set all 3 simultaneously: */ 105 - #define VIA686A_TEMP_MODE_MASK 0x3F 106 - #define VIA686A_TEMP_MODE_CONTINUOUS (0x00) 104 + #define VIA686A_TEMP_MODE_MASK 0x3F 105 + #define VIA686A_TEMP_MODE_CONTINUOUS 0x00 107 106 108 107 /* Conversions. Limit checking is only done on the TO_REG 109 - variants. 108 + variants. 110 109 111 110 ********* VOLTAGE CONVERSIONS (Bob Dougherty) ******** 112 111 From HWMon.cpp (Copyright 1998-2000 Jonathan Teh Soon Yew): ··· 116 121 That is: 117 122 volts = (25*regVal+133)*factor 118 123 regVal = (volts/factor-133)/25 119 - (These conversions were contributed by Jonathan Teh Soon Yew 124 + (These conversions were contributed by Jonathan Teh Soon Yew 120 125 <j.teh@iname.com>) */ 121 126 static inline u8 IN_TO_REG(long val, int inNum) 122 127 { ··· 177 182 else 178 183 return double(temp)*0.924-127.33; 179 184 180 - A fifth-order polynomial fits the unofficial data (provided by Alex van 181 - Kaam <darkside@chello.nl>) a bit better. It also give more reasonable 182 - numbers on my machine (ie. they agree with what my BIOS tells me). 185 + A fifth-order polynomial fits the unofficial data (provided by Alex van 186 + Kaam <darkside@chello.nl>) a bit better. It also give more reasonable 187 + numbers on my machine (ie. they agree with what my BIOS tells me). 183 188 Here's the fifth-order fit to the 8-bit data: 184 - temp = 1.625093e-10*val^5 - 1.001632e-07*val^4 + 2.457653e-05*val^3 - 189 + temp = 1.625093e-10*val^5 - 1.001632e-07*val^4 + 2.457653e-05*val^3 - 185 190 2.967619e-03*val^2 + 2.175144e-01*val - 7.090067e+0. 186 191 187 - (2000-10-25- RFD: thanks to Uwe Andersen <uandersen@mayah.com> for 192 + (2000-10-25- RFD: thanks to Uwe Andersen <uandersen@mayah.com> for 188 193 finding my typos in this formula!) 189 194 190 - Alas, none of the elegant function-fit solutions will work because we 191 - aren't allowed to use floating point in the kernel and doing it with 192 - integers doesn't rpovide enough precision. So we'll do boring old 193 - look-up table stuff. The unofficial data (see below) have effectively 194 - 7-bit resolution (they are rounded to the nearest degree). I'm assuming 195 - that the transfer function of the device is monotonic and smooth, so a 196 - smooth function fit to the data will allow us to get better precision. 195 + Alas, none of the elegant function-fit solutions will work because we 196 + aren't allowed to use floating point in the kernel and doing it with 197 + integers doesn't provide enough precision. So we'll do boring old 198 + look-up table stuff. The unofficial data (see below) have effectively 199 + 7-bit resolution (they are rounded to the nearest degree). I'm assuming 200 + that the transfer function of the device is monotonic and smooth, so a 201 + smooth function fit to the data will allow us to get better precision. 197 202 I used the 5th-order poly fit described above and solved for 198 - VIA register values 0-255. I *10 before rounding, so we get tenth-degree 199 - precision. (I could have done all 1024 values for our 10-bit readings, 200 - but the function is very linear in the useful range (0-80 deg C), so 201 - we'll just use linear interpolation for 10-bit readings.) So, tempLUT 203 + VIA register values 0-255. I *10 before rounding, so we get tenth-degree 204 + precision. (I could have done all 1024 values for our 10-bit readings, 205 + but the function is very linear in the useful range (0-80 deg C), so 206 + we'll just use linear interpolation for 10-bit readings.) So, tempLUT 202 207 is the temp at via register values 0-255: */ 203 208 static const long tempLUT[] = 204 - { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, 205 - -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, 206 - -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, 207 - -255, -246, -237, -229, -220, -212, -204, -196, -188, -180, 208 - -173, -166, -159, -152, -145, -139, -132, -126, -120, -114, 209 - -108, -102, -96, -91, -85, -80, -74, -69, -64, -59, -54, -49, 210 - -44, -39, -34, -29, -25, -20, -15, -11, -6, -2, 3, 7, 12, 16, 211 - 20, 25, 29, 33, 37, 42, 46, 50, 54, 59, 63, 67, 71, 75, 79, 84, 212 - 88, 92, 96, 100, 104, 109, 113, 117, 121, 125, 130, 134, 138, 213 - 142, 146, 151, 155, 159, 163, 168, 172, 176, 181, 185, 189, 214 - 193, 198, 202, 206, 211, 215, 219, 224, 228, 232, 237, 241, 215 - 245, 250, 254, 259, 263, 267, 272, 276, 281, 285, 290, 294, 216 - 299, 303, 307, 312, 316, 321, 325, 330, 334, 339, 344, 348, 217 - 353, 357, 362, 366, 371, 376, 380, 385, 390, 395, 399, 404, 218 - 409, 414, 419, 423, 428, 433, 438, 443, 449, 454, 459, 464, 219 - 469, 475, 480, 486, 491, 497, 502, 508, 514, 520, 526, 532, 220 - 538, 544, 551, 557, 564, 571, 578, 584, 592, 599, 606, 614, 221 - 621, 629, 637, 645, 654, 662, 671, 680, 689, 698, 708, 718, 222 - 728, 738, 749, 759, 770, 782, 793, 805, 818, 830, 843, 856, 223 - 870, 883, 898, 912, 927, 943, 958, 975, 991, 1008, 1026, 1044, 224 - 1062, 1081, 1101, 1121, 1141, 1162, 1184, 1206, 1229, 1252, 225 - 1276, 1301, 1326, 1352, 1378, 1406, 1434, 1462 209 + { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, 210 + -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, 211 + -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, 212 + -255, -246, -237, -229, -220, -212, -204, -196, -188, -180, 213 + -173, -166, -159, -152, -145, -139, -132, -126, -120, -114, 214 + -108, -102, -96, -91, -85, -80, -74, -69, -64, -59, -54, -49, 215 + -44, -39, -34, -29, -25, -20, -15, -11, -6, -2, 3, 7, 12, 16, 216 + 20, 25, 29, 33, 37, 42, 46, 50, 54, 59, 63, 67, 71, 75, 79, 84, 217 + 88, 92, 96, 100, 104, 109, 113, 117, 121, 125, 130, 134, 138, 218 + 142, 146, 151, 155, 159, 163, 168, 172, 176, 181, 185, 189, 219 + 193, 198, 202, 206, 211, 215, 219, 224, 228, 232, 237, 241, 220 + 245, 250, 254, 259, 263, 267, 272, 276, 281, 285, 290, 294, 221 + 299, 303, 307, 312, 316, 321, 325, 330, 334, 339, 344, 348, 222 + 353, 357, 362, 366, 371, 376, 380, 385, 390, 395, 399, 404, 223 + 409, 414, 419, 423, 428, 433, 438, 443, 449, 454, 459, 464, 224 + 469, 475, 480, 486, 491, 497, 502, 508, 514, 520, 526, 532, 225 + 538, 544, 551, 557, 564, 571, 578, 584, 592, 599, 606, 614, 226 + 621, 629, 637, 645, 654, 662, 671, 680, 689, 698, 708, 718, 227 + 728, 738, 749, 759, 770, 782, 793, 805, 818, 830, 843, 856, 228 + 870, 883, 898, 912, 927, 943, 958, 975, 991, 1008, 1026, 1044, 229 + 1062, 1081, 1101, 1121, 1141, 1162, 1184, 1206, 1229, 1252, 230 + 1276, 1301, 1326, 1352, 1378, 1406, 1434, 1462 226 231 }; 227 232 228 - /* the original LUT values from Alex van Kaam <darkside@chello.nl> 233 + /* the original LUT values from Alex van Kaam <darkside@chello.nl> 229 234 (for via register values 12-240): 230 235 {-50,-49,-47,-45,-43,-41,-39,-38,-37,-35,-34,-33,-32,-31, 231 236 -30,-29,-28,-27,-26,-25,-24,-24,-23,-22,-21,-20,-20,-19,-18,-17,-17,-16,-15, ··· 240 245 241 246 242 247 Here's the reverse LUT. I got it by doing a 6-th order poly fit (needed 243 - an extra term for a good fit to these inverse data!) and then 244 - solving for each temp value from -50 to 110 (the useable range for 245 - this chip). Here's the fit: 246 - viaRegVal = -1.160370e-10*val^6 +3.193693e-08*val^5 - 1.464447e-06*val^4 248 + an extra term for a good fit to these inverse data!) and then 249 + solving for each temp value from -50 to 110 (the useable range for 250 + this chip). Here's the fit: 251 + viaRegVal = -1.160370e-10*val^6 +3.193693e-08*val^5 - 1.464447e-06*val^4 247 252 - 2.525453e-04*val^3 + 1.424593e-02*val^2 + 2.148941e+00*val +7.275808e+01) 248 253 Note that n=161: */ 249 254 static const u8 viaLUT[] = 250 - { 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 23, 251 - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40, 252 - 41, 43, 45, 46, 48, 49, 51, 53, 55, 57, 59, 60, 62, 64, 66, 253 - 69, 71, 73, 75, 77, 79, 82, 84, 86, 88, 91, 93, 95, 98, 100, 254 - 103, 105, 107, 110, 112, 115, 117, 119, 122, 124, 126, 129, 255 - 131, 134, 136, 138, 140, 143, 145, 147, 150, 152, 154, 156, 256 - 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 257 - 182, 183, 185, 187, 188, 190, 192, 193, 195, 196, 198, 199, 258 - 200, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 213, 259 - 214, 215, 216, 217, 218, 219, 220, 221, 222, 222, 223, 224, 260 - 225, 226, 226, 227, 228, 228, 229, 230, 230, 231, 232, 232, 261 - 233, 233, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239, 262 - 239, 240 255 + { 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 23, 256 + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40, 257 + 41, 43, 45, 46, 48, 49, 51, 53, 55, 57, 59, 60, 62, 64, 66, 258 + 69, 71, 73, 75, 77, 79, 82, 84, 86, 88, 91, 93, 95, 98, 100, 259 + 103, 105, 107, 110, 112, 115, 117, 119, 122, 124, 126, 129, 260 + 131, 134, 136, 138, 140, 143, 145, 147, 150, 152, 154, 156, 261 + 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 262 + 182, 183, 185, 187, 188, 190, 192, 193, 195, 196, 198, 199, 263 + 200, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 213, 264 + 214, 215, 216, 217, 218, 219, 220, 221, 222, 222, 223, 224, 265 + 225, 226, 226, 227, 228, 228, 229, 230, 230, 231, 232, 232, 266 + 233, 233, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239, 267 + 239, 240 263 268 }; 264 269 265 270 /* Converting temps to (8-bit) hyst and over registers ··· 267 272 The +50 is because the temps start at -50 */ 268 273 static inline u8 TEMP_TO_REG(long val) 269 274 { 270 - return viaLUT[val <= -50000 ? 0 : val >= 110000 ? 160 : 275 + return viaLUT[val <= -50000 ? 0 : val >= 110000 ? 160 : 271 276 (val < 0 ? val - 500 : val + 500) / 1000 + 50]; 272 277 } 273 278 ··· 286 291 287 292 /* do some linear interpolation */ 288 293 return (tempLUT[eightBits] * (4 - twoBits) + 289 - tempLUT[eightBits + 1] * twoBits) * 25; 294 + tempLUT[eightBits + 1] * twoBits) * 25; 290 295 } 291 - 292 - #define ALARMS_FROM_REG(val) (val) 293 296 294 297 #define DIV_FROM_REG(val) (1 << (val)) 295 298 #define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) ··· 351 358 return sprintf(buf, "%ld\n", IN_FROM_REG(data->in_max[nr], nr)); 352 359 } 353 360 354 - static ssize_t set_in_min(struct device *dev, const char *buf, 361 + static ssize_t set_in_min(struct device *dev, const char *buf, 355 362 size_t count, int nr) { 356 363 struct i2c_client *client = to_i2c_client(dev); 357 364 struct via686a_data *data = i2c_get_clientdata(client); 358 365 unsigned long val = simple_strtoul(buf, NULL, 10); 359 366 360 367 down(&data->update_lock); 361 - data->in_min[nr] = IN_TO_REG(val,nr); 362 - via686a_write_value(client, VIA686A_REG_IN_MIN(nr), 368 + data->in_min[nr] = IN_TO_REG(val, nr); 369 + via686a_write_value(client, VIA686A_REG_IN_MIN(nr), 363 370 data->in_min[nr]); 364 371 up(&data->update_lock); 365 372 return count; 366 373 } 367 - static ssize_t set_in_max(struct device *dev, const char *buf, 374 + static ssize_t set_in_max(struct device *dev, const char *buf, 368 375 size_t count, int nr) { 369 376 struct i2c_client *client = to_i2c_client(dev); 370 377 struct via686a_data *data = i2c_get_clientdata(client); 371 378 unsigned long val = simple_strtoul(buf, NULL, 10); 372 379 373 380 down(&data->update_lock); 374 - data->in_max[nr] = IN_TO_REG(val,nr); 375 - via686a_write_value(client, VIA686A_REG_IN_MAX(nr), 381 + data->in_max[nr] = IN_TO_REG(val, nr); 382 + via686a_write_value(client, VIA686A_REG_IN_MAX(nr), 376 383 data->in_max[nr]); 377 384 up(&data->update_lock); 378 385 return count; ··· 428 435 struct via686a_data *data = via686a_update_device(dev); 429 436 return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp_hyst[nr])); 430 437 } 431 - static ssize_t set_temp_over(struct device *dev, const char *buf, 438 + static ssize_t set_temp_over(struct device *dev, const char *buf, 432 439 size_t count, int nr) { 433 440 struct i2c_client *client = to_i2c_client(dev); 434 441 struct via686a_data *data = i2c_get_clientdata(client); ··· 436 443 437 444 down(&data->update_lock); 438 445 data->temp_over[nr] = TEMP_TO_REG(val); 439 - via686a_write_value(client, VIA686A_REG_TEMP_OVER(nr), data->temp_over[nr]); 446 + via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr], 447 + data->temp_over[nr]); 440 448 up(&data->update_lock); 441 449 return count; 442 450 } 443 - static ssize_t set_temp_hyst(struct device *dev, const char *buf, 451 + static ssize_t set_temp_hyst(struct device *dev, const char *buf, 444 452 size_t count, int nr) { 445 453 struct i2c_client *client = to_i2c_client(dev); 446 454 struct via686a_data *data = i2c_get_clientdata(client); ··· 449 455 450 456 down(&data->update_lock); 451 457 data->temp_hyst[nr] = TEMP_TO_REG(val); 452 - via686a_write_value(client, VIA686A_REG_TEMP_HYST(nr), data->temp_hyst[nr]); 458 + via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr], 459 + data->temp_hyst[nr]); 453 460 up(&data->update_lock); 454 461 return count; 455 462 } ··· 483 488 static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ 484 489 show_temp_##offset##_over, set_temp_##offset##_over); \ 485 490 static DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ 486 - show_temp_##offset##_hyst, set_temp_##offset##_hyst); 491 + show_temp_##offset##_hyst, set_temp_##offset##_hyst); 487 492 488 493 show_temp_offset(1); 489 494 show_temp_offset(2); ··· 492 497 /* 2 Fans */ 493 498 static ssize_t show_fan(struct device *dev, char *buf, int nr) { 494 499 struct via686a_data *data = via686a_update_device(dev); 495 - return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], 500 + return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], 496 501 DIV_FROM_REG(data->fan_div[nr])) ); 497 502 } 498 503 static ssize_t show_fan_min(struct device *dev, char *buf, int nr) { 499 504 struct via686a_data *data = via686a_update_device(dev); 500 - return sprintf(buf,"%d\n", 505 + return sprintf(buf, "%d\n", 501 506 FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])) ); 502 507 } 503 508 static ssize_t show_fan_div(struct device *dev, char *buf, int nr) { 504 509 struct via686a_data *data = via686a_update_device(dev); 505 - return sprintf(buf,"%d\n", DIV_FROM_REG(data->fan_div[nr]) ); 510 + return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]) ); 506 511 } 507 - static ssize_t set_fan_min(struct device *dev, const char *buf, 512 + static ssize_t set_fan_min(struct device *dev, const char *buf, 508 513 size_t count, int nr) { 509 514 struct i2c_client *client = to_i2c_client(dev); 510 515 struct via686a_data *data = i2c_get_clientdata(client); ··· 516 521 up(&data->update_lock); 517 522 return count; 518 523 } 519 - static ssize_t set_fan_div(struct device *dev, const char *buf, 524 + static ssize_t set_fan_div(struct device *dev, const char *buf, 520 525 size_t count, int nr) { 521 526 struct i2c_client *client = to_i2c_client(dev); 522 527 struct via686a_data *data = i2c_get_clientdata(client); ··· 567 572 /* Alarms */ 568 573 static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) { 569 574 struct via686a_data *data = via686a_update_device(dev); 570 - return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms)); 575 + return sprintf(buf, "%u\n", data->alarms); 571 576 } 572 577 static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 573 578 ··· 607 612 } 608 613 609 614 /* 8231 requires multiple of 256, we enforce that on 686 as well */ 610 - if(force_addr) 615 + if (force_addr) 611 616 address = force_addr & 0xFF00; 612 617 613 - if(force_addr) { 614 - dev_warn(&adapter->dev,"forcing ISA address 0x%04X\n", address); 618 + if (force_addr) { 619 + dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", 620 + address); 615 621 if (PCIBIOS_SUCCESSFUL != 616 622 pci_write_config_word(s_bridge, VIA686A_BASE_REG, address)) 617 623 return -ENODEV; ··· 621 625 pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) 622 626 return -ENODEV; 623 627 if (!(val & 0x0001)) { 624 - dev_warn(&adapter->dev,"enabling sensors\n"); 628 + dev_warn(&adapter->dev, "enabling sensors\n"); 625 629 if (PCIBIOS_SUCCESSFUL != 626 630 pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, 627 - val | 0x0001)) 631 + val | 0x0001)) 628 632 return -ENODEV; 629 633 } 630 634 631 635 /* Reserve the ISA region */ 632 636 if (!request_region(address, VIA686A_EXTENT, via686a_driver.name)) { 633 - dev_err(&adapter->dev,"region 0x%x already in use!\n", 634 - address); 637 + dev_err(&adapter->dev, "region 0x%x already in use!\n", 638 + address); 635 639 return -ENODEV; 636 640 } 637 641 ··· 656 660 /* Tell the I2C layer a new client has arrived */ 657 661 if ((err = i2c_attach_client(new_client))) 658 662 goto ERROR3; 659 - 663 + 660 664 /* Initialize the VIA686A chip */ 661 665 via686a_init_client(new_client); 662 666 ··· 695 699 696 700 return 0; 697 701 698 - ERROR3: 702 + ERROR3: 699 703 kfree(data); 700 - ERROR0: 704 + ERROR0: 701 705 release_region(address, VIA686A_EXTENT); 702 706 return err; 703 707 } ··· 728 732 via686a_write_value(client, VIA686A_REG_CONFIG, (reg|0x01)&0x7F); 729 733 730 734 /* Configure temp interrupt mode for continuous-interrupt operation */ 731 - via686a_write_value(client, VIA686A_REG_TEMP_MODE, 735 + via686a_write_value(client, VIA686A_REG_TEMP_MODE, 732 736 via686a_read_value(client, VIA686A_REG_TEMP_MODE) & 733 737 !(VIA686A_TEMP_MODE_MASK | VIA686A_TEMP_MODE_CONTINUOUS)); 734 738 } ··· 760 764 } 761 765 for (i = 0; i <= 2; i++) { 762 766 data->temp[i] = via686a_read_value(client, 763 - VIA686A_REG_TEMP(i)) << 2; 767 + VIA686A_REG_TEMP[i]) << 2; 764 768 data->temp_over[i] = 765 769 via686a_read_value(client, 766 - VIA686A_REG_TEMP_OVER(i)); 770 + VIA686A_REG_TEMP_OVER[i]); 767 771 data->temp_hyst[i] = 768 772 via686a_read_value(client, 769 - VIA686A_REG_TEMP_HYST(i)); 773 + VIA686A_REG_TEMP_HYST[i]); 770 774 } 771 - /* add in lower 2 bits 775 + /* add in lower 2 bits 772 776 temp1 uses bits 7-6 of VIA686A_REG_TEMP_LOW1 773 777 temp2 uses bits 5-4 of VIA686A_REG_TEMP_LOW23 774 778 temp3 uses bits 7-6 of VIA686A_REG_TEMP_LOW23 ··· 800 804 } 801 805 802 806 static struct pci_device_id via686a_pci_ids[] = { 803 - { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4) }, 804 - { 0, } 807 + { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4) }, 808 + { 0, } 805 809 }; 806 810 807 811 MODULE_DEVICE_TABLE(pci, via686a_pci_ids); 808 812 809 813 static int __devinit via686a_pci_probe(struct pci_dev *dev, 810 - const struct pci_device_id *id) 814 + const struct pci_device_id *id) 811 815 { 812 - u16 val; 813 - int addr = 0; 816 + u16 val; 817 + int addr = 0; 814 818 815 - if (PCIBIOS_SUCCESSFUL != 816 - pci_read_config_word(dev, VIA686A_BASE_REG, &val)) 817 - return -ENODEV; 819 + if (PCIBIOS_SUCCESSFUL != 820 + pci_read_config_word(dev, VIA686A_BASE_REG, &val)) 821 + return -ENODEV; 818 822 819 - addr = val & ~(VIA686A_EXTENT - 1); 820 - if (addr == 0 && force_addr == 0) { 821 - dev_err(&dev->dev,"base address not set - upgrade BIOS or use force_addr=0xaddr\n"); 822 - return -ENODEV; 823 - } 824 - if (force_addr) 825 - addr = force_addr; /* so detect will get called */ 823 + addr = val & ~(VIA686A_EXTENT - 1); 824 + if (addr == 0 && force_addr == 0) { 825 + dev_err(&dev->dev, "base address not set - upgrade BIOS " 826 + "or use force_addr=0xaddr\n"); 827 + return -ENODEV; 828 + } 829 + if (force_addr) 830 + addr = force_addr; /* so detect will get called */ 826 831 827 - if (!addr) { 828 - dev_err(&dev->dev,"No Via 686A sensors found.\n"); 829 - return -ENODEV; 830 - } 831 - normal_isa[0] = addr; 832 + if (!addr) { 833 + dev_err(&dev->dev, "No Via 686A sensors found.\n"); 834 + return -ENODEV; 835 + } 836 + normal_isa[0] = addr; 832 837 833 838 s_bridge = pci_dev_get(dev); 834 839 if (i2c_add_driver(&via686a_driver)) { ··· 845 848 } 846 849 847 850 static struct pci_driver via686a_pci_driver = { 848 - .name = "via686a", 849 - .id_table = via686a_pci_ids, 850 - .probe = via686a_pci_probe, 851 + .name = "via686a", 852 + .id_table = via686a_pci_ids, 853 + .probe = via686a_pci_probe, 851 854 }; 852 855 853 856 static int __init sm_via686a_init(void) 854 857 { 855 - return pci_register_driver(&via686a_pci_driver); 858 + return pci_register_driver(&via686a_pci_driver); 856 859 } 857 860 858 861 static void __exit sm_via686a_exit(void) ··· 866 869 } 867 870 868 871 MODULE_AUTHOR("Ky�sti M�lkki <kmalkki@cc.hut.fi>, " 869 - "Mark Studebaker <mdsxyz123@yahoo.com> " 870 - "and Bob Dougherty <bobd@stanford.edu>"); 872 + "Mark Studebaker <mdsxyz123@yahoo.com> " 873 + "and Bob Dougherty <bobd@stanford.edu>"); 871 874 MODULE_DESCRIPTION("VIA 686A Sensor device"); 872 875 MODULE_LICENSE("GPL"); 873 876
+846
drivers/i2c/chips/w83627ehf.c
··· 1 + /* 2 + w83627ehf - Driver for the hardware monitoring functionality of 3 + the Winbond W83627EHF Super-I/O chip 4 + Copyright (C) 2005 Jean Delvare <khali@linux-fr.org> 5 + 6 + Shamelessly ripped from the w83627hf driver 7 + Copyright (C) 2003 Mark Studebaker 8 + 9 + Thanks to Leon Moonen, Steve Cliffe and Grant Coady for their help 10 + in testing and debugging this driver. 11 + 12 + This program is free software; you can redistribute it and/or modify 13 + it under the terms of the GNU General Public License as published by 14 + the Free Software Foundation; either version 2 of the License, or 15 + (at your option) any later version. 16 + 17 + This program is distributed in the hope that it will be useful, 18 + but WITHOUT ANY WARRANTY; without even the implied warranty of 19 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 + GNU General Public License for more details. 21 + 22 + You should have received a copy of the GNU General Public License 23 + along with this program; if not, write to the Free Software 24 + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 + 26 + 27 + Supports the following chips: 28 + 29 + Chip #vin #fan #pwm #temp chip_id man_id 30 + w83627ehf - 5 - 3 0x88 0x5ca3 31 + 32 + This is a preliminary version of the driver, only supporting the 33 + fan and temperature inputs. The chip does much more than that. 34 + */ 35 + 36 + #include <linux/module.h> 37 + #include <linux/init.h> 38 + #include <linux/slab.h> 39 + #include <linux/i2c.h> 40 + #include <linux/i2c-sensor.h> 41 + #include <asm/io.h> 42 + #include "lm75.h" 43 + 44 + /* Addresses to scan 45 + The actual ISA address is read from Super-I/O configuration space */ 46 + static unsigned short normal_i2c[] = { I2C_CLIENT_END }; 47 + static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END }; 48 + 49 + /* Insmod parameters */ 50 + SENSORS_INSMOD_1(w83627ehf); 51 + 52 + /* 53 + * Super-I/O constants and functions 54 + */ 55 + 56 + static int REG; /* The register to read/write */ 57 + static int VAL; /* The value to read/write */ 58 + 59 + #define W83627EHF_LD_HWM 0x0b 60 + 61 + #define SIO_REG_LDSEL 0x07 /* Logical device select */ 62 + #define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */ 63 + #define SIO_REG_ENABLE 0x30 /* Logical device enable */ 64 + #define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */ 65 + 66 + #define SIO_W83627EHF_ID 0x8840 67 + #define SIO_ID_MASK 0xFFC0 68 + 69 + static inline void 70 + superio_outb(int reg, int val) 71 + { 72 + outb(reg, REG); 73 + outb(val, VAL); 74 + } 75 + 76 + static inline int 77 + superio_inb(int reg) 78 + { 79 + outb(reg, REG); 80 + return inb(VAL); 81 + } 82 + 83 + static inline void 84 + superio_select(int ld) 85 + { 86 + outb(SIO_REG_LDSEL, REG); 87 + outb(ld, VAL); 88 + } 89 + 90 + static inline void 91 + superio_enter(void) 92 + { 93 + outb(0x87, REG); 94 + outb(0x87, REG); 95 + } 96 + 97 + static inline void 98 + superio_exit(void) 99 + { 100 + outb(0x02, REG); 101 + outb(0x02, VAL); 102 + } 103 + 104 + /* 105 + * ISA constants 106 + */ 107 + 108 + #define REGION_LENGTH 8 109 + #define ADDR_REG_OFFSET 5 110 + #define DATA_REG_OFFSET 6 111 + 112 + #define W83627EHF_REG_BANK 0x4E 113 + #define W83627EHF_REG_CONFIG 0x40 114 + #define W83627EHF_REG_CHIP_ID 0x49 115 + #define W83627EHF_REG_MAN_ID 0x4F 116 + 117 + static const u16 W83627EHF_REG_FAN[] = { 0x28, 0x29, 0x2a, 0x3f, 0x553 }; 118 + static const u16 W83627EHF_REG_FAN_MIN[] = { 0x3b, 0x3c, 0x3d, 0x3e, 0x55c }; 119 + 120 + #define W83627EHF_REG_TEMP1 0x27 121 + #define W83627EHF_REG_TEMP1_HYST 0x3a 122 + #define W83627EHF_REG_TEMP1_OVER 0x39 123 + static const u16 W83627EHF_REG_TEMP[] = { 0x150, 0x250 }; 124 + static const u16 W83627EHF_REG_TEMP_HYST[] = { 0x153, 0x253 }; 125 + static const u16 W83627EHF_REG_TEMP_OVER[] = { 0x155, 0x255 }; 126 + static const u16 W83627EHF_REG_TEMP_CONFIG[] = { 0x152, 0x252 }; 127 + 128 + /* Fan clock dividers are spread over the following five registers */ 129 + #define W83627EHF_REG_FANDIV1 0x47 130 + #define W83627EHF_REG_FANDIV2 0x4B 131 + #define W83627EHF_REG_VBAT 0x5D 132 + #define W83627EHF_REG_DIODE 0x59 133 + #define W83627EHF_REG_SMI_OVT 0x4C 134 + 135 + /* 136 + * Conversions 137 + */ 138 + 139 + static inline unsigned int 140 + fan_from_reg(u8 reg, unsigned int div) 141 + { 142 + if (reg == 0 || reg == 255) 143 + return 0; 144 + return 1350000U / (reg * div); 145 + } 146 + 147 + static inline unsigned int 148 + div_from_reg(u8 reg) 149 + { 150 + return 1 << reg; 151 + } 152 + 153 + static inline int 154 + temp1_from_reg(s8 reg) 155 + { 156 + return reg * 1000; 157 + } 158 + 159 + static inline s8 160 + temp1_to_reg(int temp) 161 + { 162 + if (temp <= -128000) 163 + return -128; 164 + if (temp >= 127000) 165 + return 127; 166 + if (temp < 0) 167 + return (temp - 500) / 1000; 168 + return (temp + 500) / 1000; 169 + } 170 + 171 + /* 172 + * Data structures and manipulation thereof 173 + */ 174 + 175 + struct w83627ehf_data { 176 + struct i2c_client client; 177 + struct semaphore lock; 178 + 179 + struct semaphore update_lock; 180 + char valid; /* !=0 if following fields are valid */ 181 + unsigned long last_updated; /* In jiffies */ 182 + 183 + /* Register values */ 184 + u8 fan[5]; 185 + u8 fan_min[5]; 186 + u8 fan_div[5]; 187 + u8 has_fan; /* some fan inputs can be disabled */ 188 + s8 temp1; 189 + s8 temp1_max; 190 + s8 temp1_max_hyst; 191 + s16 temp[2]; 192 + s16 temp_max[2]; 193 + s16 temp_max_hyst[2]; 194 + }; 195 + 196 + static inline int is_word_sized(u16 reg) 197 + { 198 + return (((reg & 0xff00) == 0x100 199 + || (reg & 0xff00) == 0x200) 200 + && ((reg & 0x00ff) == 0x50 201 + || (reg & 0x00ff) == 0x53 202 + || (reg & 0x00ff) == 0x55)); 203 + } 204 + 205 + /* We assume that the default bank is 0, thus the following two functions do 206 + nothing for registers which live in bank 0. For others, they respectively 207 + set the bank register to the correct value (before the register is 208 + accessed), and back to 0 (afterwards). */ 209 + static inline void w83627ehf_set_bank(struct i2c_client *client, u16 reg) 210 + { 211 + if (reg & 0xff00) { 212 + outb_p(W83627EHF_REG_BANK, client->addr + ADDR_REG_OFFSET); 213 + outb_p(reg >> 8, client->addr + DATA_REG_OFFSET); 214 + } 215 + } 216 + 217 + static inline void w83627ehf_reset_bank(struct i2c_client *client, u16 reg) 218 + { 219 + if (reg & 0xff00) { 220 + outb_p(W83627EHF_REG_BANK, client->addr + ADDR_REG_OFFSET); 221 + outb_p(0, client->addr + DATA_REG_OFFSET); 222 + } 223 + } 224 + 225 + static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg) 226 + { 227 + struct w83627ehf_data *data = i2c_get_clientdata(client); 228 + int res, word_sized = is_word_sized(reg); 229 + 230 + down(&data->lock); 231 + 232 + w83627ehf_set_bank(client, reg); 233 + outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); 234 + res = inb_p(client->addr + DATA_REG_OFFSET); 235 + if (word_sized) { 236 + outb_p((reg & 0xff) + 1, 237 + client->addr + ADDR_REG_OFFSET); 238 + res = (res << 8) + inb_p(client->addr + DATA_REG_OFFSET); 239 + } 240 + w83627ehf_reset_bank(client, reg); 241 + 242 + up(&data->lock); 243 + 244 + return res; 245 + } 246 + 247 + static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value) 248 + { 249 + struct w83627ehf_data *data = i2c_get_clientdata(client); 250 + int word_sized = is_word_sized(reg); 251 + 252 + down(&data->lock); 253 + 254 + w83627ehf_set_bank(client, reg); 255 + outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET); 256 + if (word_sized) { 257 + outb_p(value >> 8, client->addr + DATA_REG_OFFSET); 258 + outb_p((reg & 0xff) + 1, 259 + client->addr + ADDR_REG_OFFSET); 260 + } 261 + outb_p(value & 0xff, client->addr + DATA_REG_OFFSET); 262 + w83627ehf_reset_bank(client, reg); 263 + 264 + up(&data->lock); 265 + return 0; 266 + } 267 + 268 + /* This function assumes that the caller holds data->update_lock */ 269 + static void w83627ehf_write_fan_div(struct i2c_client *client, int nr) 270 + { 271 + struct w83627ehf_data *data = i2c_get_clientdata(client); 272 + u8 reg; 273 + 274 + switch (nr) { 275 + case 0: 276 + reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0xcf) 277 + | ((data->fan_div[0] & 0x03) << 4); 278 + w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg); 279 + reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xdf) 280 + | ((data->fan_div[0] & 0x04) << 3); 281 + w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg); 282 + break; 283 + case 1: 284 + reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0x3f) 285 + | ((data->fan_div[1] & 0x03) << 6); 286 + w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg); 287 + reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xbf) 288 + | ((data->fan_div[1] & 0x04) << 4); 289 + w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg); 290 + break; 291 + case 2: 292 + reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV2) & 0x3f) 293 + | ((data->fan_div[2] & 0x03) << 6); 294 + w83627ehf_write_value(client, W83627EHF_REG_FANDIV2, reg); 295 + reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0x7f) 296 + | ((data->fan_div[2] & 0x04) << 5); 297 + w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg); 298 + break; 299 + case 3: 300 + reg = (w83627ehf_read_value(client, W83627EHF_REG_DIODE) & 0xfc) 301 + | (data->fan_div[3] & 0x03); 302 + w83627ehf_write_value(client, W83627EHF_REG_DIODE, reg); 303 + reg = (w83627ehf_read_value(client, W83627EHF_REG_SMI_OVT) & 0x7f) 304 + | ((data->fan_div[3] & 0x04) << 5); 305 + w83627ehf_write_value(client, W83627EHF_REG_SMI_OVT, reg); 306 + break; 307 + case 4: 308 + reg = (w83627ehf_read_value(client, W83627EHF_REG_DIODE) & 0x73) 309 + | ((data->fan_div[4] & 0x03) << 3) 310 + | ((data->fan_div[4] & 0x04) << 5); 311 + w83627ehf_write_value(client, W83627EHF_REG_DIODE, reg); 312 + break; 313 + } 314 + } 315 + 316 + static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) 317 + { 318 + struct i2c_client *client = to_i2c_client(dev); 319 + struct w83627ehf_data *data = i2c_get_clientdata(client); 320 + int i; 321 + 322 + down(&data->update_lock); 323 + 324 + if (time_after(jiffies, data->last_updated + HZ) 325 + || !data->valid) { 326 + /* Fan clock dividers */ 327 + i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1); 328 + data->fan_div[0] = (i >> 4) & 0x03; 329 + data->fan_div[1] = (i >> 6) & 0x03; 330 + i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV2); 331 + data->fan_div[2] = (i >> 6) & 0x03; 332 + i = w83627ehf_read_value(client, W83627EHF_REG_VBAT); 333 + data->fan_div[0] |= (i >> 3) & 0x04; 334 + data->fan_div[1] |= (i >> 4) & 0x04; 335 + data->fan_div[2] |= (i >> 5) & 0x04; 336 + if (data->has_fan & ((1 << 3) | (1 << 4))) { 337 + i = w83627ehf_read_value(client, W83627EHF_REG_DIODE); 338 + data->fan_div[3] = i & 0x03; 339 + data->fan_div[4] = ((i >> 2) & 0x03) 340 + | ((i >> 5) & 0x04); 341 + } 342 + if (data->has_fan & (1 << 3)) { 343 + i = w83627ehf_read_value(client, W83627EHF_REG_SMI_OVT); 344 + data->fan_div[3] |= (i >> 5) & 0x04; 345 + } 346 + 347 + /* Measured fan speeds and limits */ 348 + for (i = 0; i < 5; i++) { 349 + if (!(data->has_fan & (1 << i))) 350 + continue; 351 + 352 + data->fan[i] = w83627ehf_read_value(client, 353 + W83627EHF_REG_FAN[i]); 354 + data->fan_min[i] = w83627ehf_read_value(client, 355 + W83627EHF_REG_FAN_MIN[i]); 356 + 357 + /* If we failed to measure the fan speed and clock 358 + divider can be increased, let's try that for next 359 + time */ 360 + if (data->fan[i] == 0xff 361 + && data->fan_div[i] < 0x07) { 362 + dev_dbg(&client->dev, "Increasing fan %d " 363 + "clock divider from %u to %u\n", 364 + i, div_from_reg(data->fan_div[i]), 365 + div_from_reg(data->fan_div[i] + 1)); 366 + data->fan_div[i]++; 367 + w83627ehf_write_fan_div(client, i); 368 + /* Preserve min limit if possible */ 369 + if (data->fan_min[i] >= 2 370 + && data->fan_min[i] != 255) 371 + w83627ehf_write_value(client, 372 + W83627EHF_REG_FAN_MIN[i], 373 + (data->fan_min[i] /= 2)); 374 + } 375 + } 376 + 377 + /* Measured temperatures and limits */ 378 + data->temp1 = w83627ehf_read_value(client, 379 + W83627EHF_REG_TEMP1); 380 + data->temp1_max = w83627ehf_read_value(client, 381 + W83627EHF_REG_TEMP1_OVER); 382 + data->temp1_max_hyst = w83627ehf_read_value(client, 383 + W83627EHF_REG_TEMP1_HYST); 384 + for (i = 0; i < 2; i++) { 385 + data->temp[i] = w83627ehf_read_value(client, 386 + W83627EHF_REG_TEMP[i]); 387 + data->temp_max[i] = w83627ehf_read_value(client, 388 + W83627EHF_REG_TEMP_OVER[i]); 389 + data->temp_max_hyst[i] = w83627ehf_read_value(client, 390 + W83627EHF_REG_TEMP_HYST[i]); 391 + } 392 + 393 + data->last_updated = jiffies; 394 + data->valid = 1; 395 + } 396 + 397 + up(&data->update_lock); 398 + return data; 399 + } 400 + 401 + /* 402 + * Sysfs callback functions 403 + */ 404 + 405 + #define show_fan_reg(reg) \ 406 + static ssize_t \ 407 + show_##reg(struct device *dev, char *buf, int nr) \ 408 + { \ 409 + struct w83627ehf_data *data = w83627ehf_update_device(dev); \ 410 + return sprintf(buf, "%d\n", \ 411 + fan_from_reg(data->reg[nr], \ 412 + div_from_reg(data->fan_div[nr]))); \ 413 + } 414 + show_fan_reg(fan); 415 + show_fan_reg(fan_min); 416 + 417 + static ssize_t 418 + show_fan_div(struct device *dev, char *buf, int nr) 419 + { 420 + struct w83627ehf_data *data = w83627ehf_update_device(dev); 421 + return sprintf(buf, "%u\n", 422 + div_from_reg(data->fan_div[nr])); 423 + } 424 + 425 + static ssize_t 426 + store_fan_min(struct device *dev, const char *buf, size_t count, int nr) 427 + { 428 + struct i2c_client *client = to_i2c_client(dev); 429 + struct w83627ehf_data *data = i2c_get_clientdata(client); 430 + unsigned int val = simple_strtoul(buf, NULL, 10); 431 + unsigned int reg; 432 + u8 new_div; 433 + 434 + down(&data->update_lock); 435 + if (!val) { 436 + /* No min limit, alarm disabled */ 437 + data->fan_min[nr] = 255; 438 + new_div = data->fan_div[nr]; /* No change */ 439 + dev_info(dev, "fan%u low limit and alarm disabled\n", nr + 1); 440 + } else if ((reg = 1350000U / val) >= 128 * 255) { 441 + /* Speed below this value cannot possibly be represented, 442 + even with the highest divider (128) */ 443 + data->fan_min[nr] = 254; 444 + new_div = 7; /* 128 == (1 << 7) */ 445 + dev_warn(dev, "fan%u low limit %u below minimum %u, set to " 446 + "minimum\n", nr + 1, val, fan_from_reg(254, 128)); 447 + } else if (!reg) { 448 + /* Speed above this value cannot possibly be represented, 449 + even with the lowest divider (1) */ 450 + data->fan_min[nr] = 1; 451 + new_div = 0; /* 1 == (1 << 0) */ 452 + dev_warn(dev, "fan%u low limit %u above maximum %u, set to " 453 + "maximum\n", nr + 1, val, fan_from_reg(1, 1)); 454 + } else { 455 + /* Automatically pick the best divider, i.e. the one such 456 + that the min limit will correspond to a register value 457 + in the 96..192 range */ 458 + new_div = 0; 459 + while (reg > 192 && new_div < 7) { 460 + reg >>= 1; 461 + new_div++; 462 + } 463 + data->fan_min[nr] = reg; 464 + } 465 + 466 + /* Write both the fan clock divider (if it changed) and the new 467 + fan min (unconditionally) */ 468 + if (new_div != data->fan_div[nr]) { 469 + if (new_div > data->fan_div[nr]) 470 + data->fan[nr] >>= (data->fan_div[nr] - new_div); 471 + else 472 + data->fan[nr] <<= (new_div - data->fan_div[nr]); 473 + 474 + dev_dbg(dev, "fan%u clock divider changed from %u to %u\n", 475 + nr + 1, div_from_reg(data->fan_div[nr]), 476 + div_from_reg(new_div)); 477 + data->fan_div[nr] = new_div; 478 + w83627ehf_write_fan_div(client, nr); 479 + } 480 + w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr], 481 + data->fan_min[nr]); 482 + up(&data->update_lock); 483 + 484 + return count; 485 + } 486 + 487 + #define sysfs_fan_offset(offset) \ 488 + static ssize_t \ 489 + show_reg_fan_##offset(struct device *dev, struct device_attribute *attr, \ 490 + char *buf) \ 491 + { \ 492 + return show_fan(dev, buf, offset-1); \ 493 + } \ 494 + static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ 495 + show_reg_fan_##offset, NULL); 496 + 497 + #define sysfs_fan_min_offset(offset) \ 498 + static ssize_t \ 499 + show_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ 500 + char *buf) \ 501 + { \ 502 + return show_fan_min(dev, buf, offset-1); \ 503 + } \ 504 + static ssize_t \ 505 + store_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \ 506 + const char *buf, size_t count) \ 507 + { \ 508 + return store_fan_min(dev, buf, count, offset-1); \ 509 + } \ 510 + static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ 511 + show_reg_fan##offset##_min, \ 512 + store_reg_fan##offset##_min); 513 + 514 + #define sysfs_fan_div_offset(offset) \ 515 + static ssize_t \ 516 + show_reg_fan##offset##_div(struct device *dev, struct device_attribute *attr, \ 517 + char *buf) \ 518 + { \ 519 + return show_fan_div(dev, buf, offset - 1); \ 520 + } \ 521 + static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \ 522 + show_reg_fan##offset##_div, NULL); 523 + 524 + sysfs_fan_offset(1); 525 + sysfs_fan_min_offset(1); 526 + sysfs_fan_div_offset(1); 527 + sysfs_fan_offset(2); 528 + sysfs_fan_min_offset(2); 529 + sysfs_fan_div_offset(2); 530 + sysfs_fan_offset(3); 531 + sysfs_fan_min_offset(3); 532 + sysfs_fan_div_offset(3); 533 + sysfs_fan_offset(4); 534 + sysfs_fan_min_offset(4); 535 + sysfs_fan_div_offset(4); 536 + sysfs_fan_offset(5); 537 + sysfs_fan_min_offset(5); 538 + sysfs_fan_div_offset(5); 539 + 540 + #define show_temp1_reg(reg) \ 541 + static ssize_t \ 542 + show_##reg(struct device *dev, struct device_attribute *attr, \ 543 + char *buf) \ 544 + { \ 545 + struct w83627ehf_data *data = w83627ehf_update_device(dev); \ 546 + return sprintf(buf, "%d\n", temp1_from_reg(data->reg)); \ 547 + } 548 + show_temp1_reg(temp1); 549 + show_temp1_reg(temp1_max); 550 + show_temp1_reg(temp1_max_hyst); 551 + 552 + #define store_temp1_reg(REG, reg) \ 553 + static ssize_t \ 554 + store_temp1_##reg(struct device *dev, struct device_attribute *attr, \ 555 + const char *buf, size_t count) \ 556 + { \ 557 + struct i2c_client *client = to_i2c_client(dev); \ 558 + struct w83627ehf_data *data = i2c_get_clientdata(client); \ 559 + u32 val = simple_strtoul(buf, NULL, 10); \ 560 + \ 561 + down(&data->update_lock); \ 562 + data->temp1_##reg = temp1_to_reg(val); \ 563 + w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \ 564 + data->temp1_##reg); \ 565 + up(&data->update_lock); \ 566 + return count; \ 567 + } 568 + store_temp1_reg(OVER, max); 569 + store_temp1_reg(HYST, max_hyst); 570 + 571 + static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL); 572 + static DEVICE_ATTR(temp1_max, S_IRUGO| S_IWUSR, 573 + show_temp1_max, store_temp1_max); 574 + static DEVICE_ATTR(temp1_max_hyst, S_IRUGO| S_IWUSR, 575 + show_temp1_max_hyst, store_temp1_max_hyst); 576 + 577 + #define show_temp_reg(reg) \ 578 + static ssize_t \ 579 + show_##reg (struct device *dev, char *buf, int nr) \ 580 + { \ 581 + struct w83627ehf_data *data = w83627ehf_update_device(dev); \ 582 + return sprintf(buf, "%d\n", \ 583 + LM75_TEMP_FROM_REG(data->reg[nr])); \ 584 + } 585 + show_temp_reg(temp); 586 + show_temp_reg(temp_max); 587 + show_temp_reg(temp_max_hyst); 588 + 589 + #define store_temp_reg(REG, reg) \ 590 + static ssize_t \ 591 + store_##reg (struct device *dev, const char *buf, size_t count, int nr) \ 592 + { \ 593 + struct i2c_client *client = to_i2c_client(dev); \ 594 + struct w83627ehf_data *data = i2c_get_clientdata(client); \ 595 + u32 val = simple_strtoul(buf, NULL, 10); \ 596 + \ 597 + down(&data->update_lock); \ 598 + data->reg[nr] = LM75_TEMP_TO_REG(val); \ 599 + w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \ 600 + data->reg[nr]); \ 601 + up(&data->update_lock); \ 602 + return count; \ 603 + } 604 + store_temp_reg(OVER, temp_max); 605 + store_temp_reg(HYST, temp_max_hyst); 606 + 607 + #define sysfs_temp_offset(offset) \ 608 + static ssize_t \ 609 + show_reg_temp##offset (struct device *dev, struct device_attribute *attr, \ 610 + char *buf) \ 611 + { \ 612 + return show_temp(dev, buf, offset - 2); \ 613 + } \ 614 + static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ 615 + show_reg_temp##offset, NULL); 616 + 617 + #define sysfs_temp_reg_offset(reg, offset) \ 618 + static ssize_t \ 619 + show_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ 620 + char *buf) \ 621 + { \ 622 + return show_temp_##reg(dev, buf, offset - 2); \ 623 + } \ 624 + static ssize_t \ 625 + store_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \ 626 + const char *buf, size_t count) \ 627 + { \ 628 + return store_temp_##reg(dev, buf, count, offset - 2); \ 629 + } \ 630 + static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \ 631 + show_reg_temp##offset##_##reg, \ 632 + store_reg_temp##offset##_##reg); 633 + 634 + sysfs_temp_offset(2); 635 + sysfs_temp_reg_offset(max, 2); 636 + sysfs_temp_reg_offset(max_hyst, 2); 637 + sysfs_temp_offset(3); 638 + sysfs_temp_reg_offset(max, 3); 639 + sysfs_temp_reg_offset(max_hyst, 3); 640 + 641 + /* 642 + * Driver and client management 643 + */ 644 + 645 + static struct i2c_driver w83627ehf_driver; 646 + 647 + static void w83627ehf_init_client(struct i2c_client *client) 648 + { 649 + int i; 650 + u8 tmp; 651 + 652 + /* Start monitoring is needed */ 653 + tmp = w83627ehf_read_value(client, W83627EHF_REG_CONFIG); 654 + if (!(tmp & 0x01)) 655 + w83627ehf_write_value(client, W83627EHF_REG_CONFIG, 656 + tmp | 0x01); 657 + 658 + /* Enable temp2 and temp3 if needed */ 659 + for (i = 0; i < 2; i++) { 660 + tmp = w83627ehf_read_value(client, 661 + W83627EHF_REG_TEMP_CONFIG[i]); 662 + if (tmp & 0x01) 663 + w83627ehf_write_value(client, 664 + W83627EHF_REG_TEMP_CONFIG[i], 665 + tmp & 0xfe); 666 + } 667 + } 668 + 669 + static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind) 670 + { 671 + struct i2c_client *client; 672 + struct w83627ehf_data *data; 673 + int i, err = 0; 674 + 675 + if (!i2c_is_isa_adapter(adapter)) 676 + return 0; 677 + 678 + if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) { 679 + err = -EBUSY; 680 + goto exit; 681 + } 682 + 683 + if (!(data = kmalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) { 684 + err = -ENOMEM; 685 + goto exit_release; 686 + } 687 + memset(data, 0, sizeof(struct w83627ehf_data)); 688 + 689 + client = &data->client; 690 + i2c_set_clientdata(client, data); 691 + client->addr = address; 692 + init_MUTEX(&data->lock); 693 + client->adapter = adapter; 694 + client->driver = &w83627ehf_driver; 695 + client->flags = 0; 696 + 697 + strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE); 698 + data->valid = 0; 699 + init_MUTEX(&data->update_lock); 700 + 701 + /* Tell the i2c layer a new client has arrived */ 702 + if ((err = i2c_attach_client(client))) 703 + goto exit_free; 704 + 705 + /* Initialize the chip */ 706 + w83627ehf_init_client(client); 707 + 708 + /* A few vars need to be filled upon startup */ 709 + for (i = 0; i < 5; i++) 710 + data->fan_min[i] = w83627ehf_read_value(client, 711 + W83627EHF_REG_FAN_MIN[i]); 712 + 713 + /* It looks like fan4 and fan5 pins can be alternatively used 714 + as fan on/off switches */ 715 + data->has_fan = 0x07; /* fan1, fan2 and fan3 */ 716 + i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1); 717 + if (i & (1 << 2)) 718 + data->has_fan |= (1 << 3); 719 + if (i & (1 << 0)) 720 + data->has_fan |= (1 << 4); 721 + 722 + /* Register sysfs hooks */ 723 + device_create_file(&client->dev, &dev_attr_fan1_input); 724 + device_create_file(&client->dev, &dev_attr_fan1_min); 725 + device_create_file(&client->dev, &dev_attr_fan1_div); 726 + device_create_file(&client->dev, &dev_attr_fan2_input); 727 + device_create_file(&client->dev, &dev_attr_fan2_min); 728 + device_create_file(&client->dev, &dev_attr_fan2_div); 729 + device_create_file(&client->dev, &dev_attr_fan3_input); 730 + device_create_file(&client->dev, &dev_attr_fan3_min); 731 + device_create_file(&client->dev, &dev_attr_fan3_div); 732 + 733 + if (data->has_fan & (1 << 3)) { 734 + device_create_file(&client->dev, &dev_attr_fan4_input); 735 + device_create_file(&client->dev, &dev_attr_fan4_min); 736 + device_create_file(&client->dev, &dev_attr_fan4_div); 737 + } 738 + if (data->has_fan & (1 << 4)) { 739 + device_create_file(&client->dev, &dev_attr_fan5_input); 740 + device_create_file(&client->dev, &dev_attr_fan5_min); 741 + device_create_file(&client->dev, &dev_attr_fan5_div); 742 + } 743 + 744 + device_create_file(&client->dev, &dev_attr_temp1_input); 745 + device_create_file(&client->dev, &dev_attr_temp1_max); 746 + device_create_file(&client->dev, &dev_attr_temp1_max_hyst); 747 + device_create_file(&client->dev, &dev_attr_temp2_input); 748 + device_create_file(&client->dev, &dev_attr_temp2_max); 749 + device_create_file(&client->dev, &dev_attr_temp2_max_hyst); 750 + device_create_file(&client->dev, &dev_attr_temp3_input); 751 + device_create_file(&client->dev, &dev_attr_temp3_max); 752 + device_create_file(&client->dev, &dev_attr_temp3_max_hyst); 753 + 754 + return 0; 755 + 756 + exit_free: 757 + kfree(data); 758 + exit_release: 759 + release_region(address, REGION_LENGTH); 760 + exit: 761 + return err; 762 + } 763 + 764 + static int w83627ehf_attach_adapter(struct i2c_adapter *adapter) 765 + { 766 + if (!(adapter->class & I2C_CLASS_HWMON)) 767 + return 0; 768 + return i2c_detect(adapter, &addr_data, w83627ehf_detect); 769 + } 770 + 771 + static int w83627ehf_detach_client(struct i2c_client *client) 772 + { 773 + int err; 774 + 775 + if ((err = i2c_detach_client(client))) { 776 + dev_err(&client->dev, "Client deregistration failed, " 777 + "client not detached.\n"); 778 + return err; 779 + } 780 + release_region(client->addr, REGION_LENGTH); 781 + kfree(i2c_get_clientdata(client)); 782 + 783 + return 0; 784 + } 785 + 786 + static struct i2c_driver w83627ehf_driver = { 787 + .owner = THIS_MODULE, 788 + .name = "w83627ehf", 789 + .flags = I2C_DF_NOTIFY, 790 + .attach_adapter = w83627ehf_attach_adapter, 791 + .detach_client = w83627ehf_detach_client, 792 + }; 793 + 794 + static int __init w83627ehf_find(int sioaddr, int *address) 795 + { 796 + u16 val; 797 + 798 + REG = sioaddr; 799 + VAL = sioaddr + 1; 800 + superio_enter(); 801 + 802 + val = (superio_inb(SIO_REG_DEVID) << 8) 803 + | superio_inb(SIO_REG_DEVID + 1); 804 + if ((val & SIO_ID_MASK) != SIO_W83627EHF_ID) { 805 + superio_exit(); 806 + return -ENODEV; 807 + } 808 + 809 + superio_select(W83627EHF_LD_HWM); 810 + val = (superio_inb(SIO_REG_ADDR) << 8) 811 + | superio_inb(SIO_REG_ADDR + 1); 812 + *address = val & ~(REGION_LENGTH - 1); 813 + if (*address == 0) { 814 + superio_exit(); 815 + return -ENODEV; 816 + } 817 + 818 + /* Activate logical device if needed */ 819 + val = superio_inb(SIO_REG_ENABLE); 820 + if (!(val & 0x01)) 821 + superio_outb(SIO_REG_ENABLE, val | 0x01); 822 + 823 + superio_exit(); 824 + return 0; 825 + } 826 + 827 + static int __init sensors_w83627ehf_init(void) 828 + { 829 + if (w83627ehf_find(0x2e, &normal_isa[0]) 830 + && w83627ehf_find(0x4e, &normal_isa[0])) 831 + return -ENODEV; 832 + 833 + return i2c_add_driver(&w83627ehf_driver); 834 + } 835 + 836 + static void __exit sensors_w83627ehf_exit(void) 837 + { 838 + i2c_del_driver(&w83627ehf_driver); 839 + } 840 + 841 + MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); 842 + MODULE_DESCRIPTION("W83627EHF driver"); 843 + MODULE_LICENSE("GPL"); 844 + 845 + module_init(sensors_w83627ehf_init); 846 + module_exit(sensors_w83627ehf_exit);
+1 -1
drivers/i2c/chips/w83627hf.c
··· 264 264 { 265 265 int i; 266 266 val = SENSORS_LIMIT(val, 1, 128) >> 1; 267 - for (i = 0; i < 6; i++) { 267 + for (i = 0; i < 7; i++) { 268 268 if (val == 0) 269 269 break; 270 270 val >>= 1;
+23 -55
drivers/i2c/chips/w83781d.c
··· 28 28 as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no 29 29 w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes 30 30 w83627hf 9 3 2 3 0x21 0x5ca3 yes yes(LPC) 31 - w83627thf 9 3 2 3 0x90 0x5ca3 no yes(LPC) 32 31 w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes 33 32 w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no 34 - w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC) 35 33 36 34 */ 37 35 38 - #include <linux/config.h> 39 36 #include <linux/module.h> 40 37 #include <linux/init.h> 41 38 #include <linux/slab.h> ··· 50 53 static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; 51 54 52 55 /* Insmod parameters */ 53 - SENSORS_INSMOD_6(w83781d, w83782d, w83783s, w83627hf, as99127f, w83697hf); 56 + SENSORS_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f); 54 57 I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " 55 58 "{bus, clientaddr, subclientaddr1, subclientaddr2}"); 56 59 ··· 170 173 : (val)) / 1000, 0, 0xff)) 171 174 #define TEMP_FROM_REG(val) (((val) & 0x80 ? (val)-0x100 : (val)) * 1000) 172 175 173 - #define ALARMS_FROM_REG(val) (val) 174 176 #define PWM_FROM_REG(val) (val) 175 177 #define PWM_TO_REG(val) (SENSORS_LIMIT((val),0,255)) 176 178 #define BEEP_MASK_FROM_REG(val,type) ((type) == as99127f ? \ ··· 189 193 val = SENSORS_LIMIT(val, 1, 190 194 ((type == w83781d 191 195 || type == as99127f) ? 8 : 128)) >> 1; 192 - for (i = 0; i < 6; i++) { 196 + for (i = 0; i < 7; i++) { 193 197 if (val == 0) 194 198 break; 195 199 val >>= 1; ··· 520 524 show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) 521 525 { 522 526 struct w83781d_data *data = w83781d_update_device(dev); 523 - return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms)); 527 + return sprintf(buf, "%u\n", data->alarms); 524 528 } 525 529 526 530 static ··· 996 1000 err = -EINVAL; 997 1001 goto ERROR0; 998 1002 } 999 - if (!is_isa && kind == w83697hf) { 1000 - dev_err(&adapter->dev, 1001 - "Cannot force ISA-only chip for I2C address 0x%02x.\n", 1002 - address); 1003 - err = -EINVAL; 1004 - goto ERROR0; 1005 - } 1006 1003 1007 1004 if (is_isa) 1008 1005 if (!request_region(address, W83781D_EXTENT, ··· 1128 1139 else if (val1 == 0x40 && vendid == winbond && !is_isa 1129 1140 && address == 0x2d) 1130 1141 kind = w83783s; 1131 - else if ((val1 == 0x21 || val1 == 0x90) && vendid == winbond) 1142 + else if (val1 == 0x21 && vendid == winbond) 1132 1143 kind = w83627hf; 1133 1144 else if (val1 == 0x31 && !is_isa && address >= 0x28) 1134 1145 kind = as99127f; 1135 - else if (val1 == 0x60 && vendid == winbond && is_isa) 1136 - kind = w83697hf; 1137 1146 else { 1138 1147 if (kind == 0) 1139 1148 dev_warn(&new_client->dev, "Ignoring 'force' " ··· 1150 1163 } else if (kind == w83783s) { 1151 1164 client_name = "w83783s"; 1152 1165 } else if (kind == w83627hf) { 1153 - if (val1 == 0x90) 1154 - client_name = "w83627thf"; 1155 - else 1156 - client_name = "w83627hf"; 1166 + client_name = "w83627hf"; 1157 1167 } else if (kind == as99127f) { 1158 1168 client_name = "as99127f"; 1159 - } else if (kind == w83697hf) { 1160 - client_name = "w83697hf"; 1161 1169 } 1162 1170 1163 1171 /* Fill in the remaining client fields and put into the global list */ ··· 1190 1208 1191 1209 /* Register sysfs hooks */ 1192 1210 device_create_file_in(new_client, 0); 1193 - if (kind != w83783s && kind != w83697hf) 1211 + if (kind != w83783s) 1194 1212 device_create_file_in(new_client, 1); 1195 1213 device_create_file_in(new_client, 2); 1196 1214 device_create_file_in(new_client, 3); ··· 1204 1222 1205 1223 device_create_file_fan(new_client, 1); 1206 1224 device_create_file_fan(new_client, 2); 1207 - if (kind != w83697hf) 1208 - device_create_file_fan(new_client, 3); 1225 + device_create_file_fan(new_client, 3); 1209 1226 1210 1227 device_create_file_temp(new_client, 1); 1211 1228 device_create_file_temp(new_client, 2); 1212 - if (kind != w83783s && kind != w83697hf) 1229 + if (kind != w83783s) 1213 1230 device_create_file_temp(new_client, 3); 1214 1231 1215 - if (kind != w83697hf) 1216 - device_create_file_vid(new_client); 1217 - 1218 - if (kind != w83697hf) 1219 - device_create_file_vrm(new_client); 1232 + device_create_file_vid(new_client); 1233 + device_create_file_vrm(new_client); 1220 1234 1221 1235 device_create_file_fan_div(new_client, 1); 1222 1236 device_create_file_fan_div(new_client, 2); 1223 - if (kind != w83697hf) 1224 - device_create_file_fan_div(new_client, 3); 1237 + device_create_file_fan_div(new_client, 3); 1225 1238 1226 1239 device_create_file_alarms(new_client); 1227 1240 ··· 1235 1258 if (kind != as99127f && kind != w83781d) { 1236 1259 device_create_file_sensor(new_client, 1); 1237 1260 device_create_file_sensor(new_client, 2); 1238 - if (kind != w83783s && kind != w83697hf) 1261 + if (kind != w83783s) 1239 1262 device_create_file_sensor(new_client, 3); 1240 1263 } 1241 1264 ··· 1458 1481 else 1459 1482 data->sens[i - 1] = 2; 1460 1483 } 1461 - if ((type == w83783s || type == w83697hf) && (i == 2)) 1484 + if (type == w83783s && i == 2) 1462 1485 break; 1463 1486 } 1464 1487 } ··· 1474 1497 } 1475 1498 1476 1499 /* Enable temp3 */ 1477 - if (type != w83783s && type != w83697hf) { 1500 + if (type != w83783s) { 1478 1501 tmp = w83781d_read_value(client, 1479 1502 W83781D_REG_TEMP3_CONFIG); 1480 1503 if (tmp & 0x01) { ··· 1515 1538 dev_dbg(dev, "Starting device update\n"); 1516 1539 1517 1540 for (i = 0; i <= 8; i++) { 1518 - if ((data->type == w83783s || data->type == w83697hf) 1519 - && (i == 1)) 1541 + if (data->type == w83783s && i == 1) 1520 1542 continue; /* 783S has no in1 */ 1521 1543 data->in[i] = 1522 1544 w83781d_read_value(client, W83781D_REG_IN(i)); ··· 1523 1547 w83781d_read_value(client, W83781D_REG_IN_MIN(i)); 1524 1548 data->in_max[i] = 1525 1549 w83781d_read_value(client, W83781D_REG_IN_MAX(i)); 1526 - if ((data->type != w83782d) && (data->type != w83697hf) 1550 + if ((data->type != w83782d) 1527 1551 && (data->type != w83627hf) && (i == 6)) 1528 1552 break; 1529 1553 } ··· 1559 1583 w83781d_read_value(client, W83781D_REG_TEMP_OVER(2)); 1560 1584 data->temp_max_hyst_add[0] = 1561 1585 w83781d_read_value(client, W83781D_REG_TEMP_HYST(2)); 1562 - if (data->type != w83783s && data->type != w83697hf) { 1586 + if (data->type != w83783s) { 1563 1587 data->temp_add[1] = 1564 1588 w83781d_read_value(client, W83781D_REG_TEMP(3)); 1565 1589 data->temp_max_add[1] = ··· 1570 1594 W83781D_REG_TEMP_HYST(3)); 1571 1595 } 1572 1596 i = w83781d_read_value(client, W83781D_REG_VID_FANDIV); 1573 - if (data->type != w83697hf) { 1574 - data->vid = i & 0x0f; 1575 - data->vid |= 1576 - (w83781d_read_value(client, W83781D_REG_CHIPID) & 1577 - 0x01) 1578 - << 4; 1579 - } 1597 + data->vid = i & 0x0f; 1598 + data->vid |= (w83781d_read_value(client, 1599 + W83781D_REG_CHIPID) & 0x01) << 4; 1580 1600 data->fan_div[0] = (i >> 4) & 0x03; 1581 1601 data->fan_div[1] = (i >> 6) & 0x03; 1582 - if (data->type != w83697hf) { 1583 - data->fan_div[2] = (w83781d_read_value(client, 1584 - W83781D_REG_PIN) 1585 - >> 6) & 0x03; 1586 - } 1602 + data->fan_div[2] = (w83781d_read_value(client, 1603 + W83781D_REG_PIN) >> 6) & 0x03; 1587 1604 if ((data->type != w83781d) && (data->type != as99127f)) { 1588 1605 i = w83781d_read_value(client, W83781D_REG_VBAT); 1589 1606 data->fan_div[0] |= (i >> 3) & 0x04; 1590 1607 data->fan_div[1] |= (i >> 4) & 0x04; 1591 - if (data->type != w83697hf) 1592 - data->fan_div[2] |= (i >> 5) & 0x04; 1608 + data->fan_div[2] |= (i >> 5) & 0x04; 1593 1609 } 1594 1610 data->alarms = 1595 1611 w83781d_read_value(client,
-1
drivers/i2c/chips/w83l785ts.c
··· 30 30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 31 31 */ 32 32 33 - #include <linux/config.h> 34 33 #include <linux/module.h> 35 34 #include <linux/delay.h> 36 35 #include <linux/init.h>
+20 -80
drivers/i2c/i2c-core.c
··· 21 21 All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl> 22 22 SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> */ 23 23 24 - #include <linux/config.h> 25 24 #include <linux/module.h> 26 25 #include <linux/kernel.h> 27 26 #include <linux/errno.h> ··· 238 239 } 239 240 240 241 /* detach any active clients. This must be done first, because 241 - * it can fail; in which case we give upp. */ 242 + * it can fail; in which case we give up. */ 242 243 list_for_each_safe(item, _n, &adap->clients) { 243 244 client = list_entry(item, struct i2c_client, list); 244 245 ··· 611 612 struct i2c_adapter *adap=client->adapter; 612 613 struct i2c_msg msg; 613 614 614 - if (client->adapter->algo->master_xfer) { 615 - msg.addr = client->addr; 616 - msg.flags = client->flags & I2C_M_TEN; 617 - msg.len = count; 618 - msg.buf = (char *)buf; 615 + msg.addr = client->addr; 616 + msg.flags = client->flags & I2C_M_TEN; 617 + msg.len = count; 618 + msg.buf = (char *)buf; 619 619 620 - dev_dbg(&client->adapter->dev, "master_send: writing %d bytes.\n", 621 - count); 622 - 623 - down(&adap->bus_lock); 624 - ret = adap->algo->master_xfer(adap,&msg,1); 625 - up(&adap->bus_lock); 620 + ret = i2c_transfer(adap, &msg, 1); 626 621 627 - /* if everything went ok (i.e. 1 msg transmitted), return #bytes 628 - * transmitted, else error code. 629 - */ 630 - return (ret == 1 )? count : ret; 631 - } else { 632 - dev_err(&client->adapter->dev, "I2C level transfers not supported\n"); 633 - return -ENOSYS; 634 - } 622 + /* If everything went ok (i.e. 1 msg transmitted), return #bytes 623 + transmitted, else error code. */ 624 + return (ret == 1) ? count : ret; 635 625 } 636 626 637 627 int i2c_master_recv(struct i2c_client *client, char *buf ,int count) ··· 628 640 struct i2c_adapter *adap=client->adapter; 629 641 struct i2c_msg msg; 630 642 int ret; 631 - if (client->adapter->algo->master_xfer) { 632 - msg.addr = client->addr; 633 - msg.flags = client->flags & I2C_M_TEN; 634 - msg.flags |= I2C_M_RD; 635 - msg.len = count; 636 - msg.buf = buf; 637 643 638 - dev_dbg(&client->adapter->dev, "master_recv: reading %d bytes.\n", 639 - count); 640 - 641 - down(&adap->bus_lock); 642 - ret = adap->algo->master_xfer(adap,&msg,1); 643 - up(&adap->bus_lock); 644 - 645 - dev_dbg(&client->adapter->dev, "master_recv: return:%d (count:%d, addr:0x%02x)\n", 646 - ret, count, client->addr); 647 - 648 - /* if everything went ok (i.e. 1 msg transmitted), return #bytes 649 - * transmitted, else error code. 650 - */ 651 - return (ret == 1 )? count : ret; 652 - } else { 653 - dev_err(&client->adapter->dev, "I2C level transfers not supported\n"); 654 - return -ENOSYS; 655 - } 644 + msg.addr = client->addr; 645 + msg.flags = client->flags & I2C_M_TEN; 646 + msg.flags |= I2C_M_RD; 647 + msg.len = count; 648 + msg.buf = buf; 649 + 650 + ret = i2c_transfer(adap, &msg, 1); 651 + 652 + /* If everything went ok (i.e. 1 msg transmitted), return #bytes 653 + transmitted, else error code. */ 654 + return (ret == 1) ? count : ret; 656 655 } 657 656 658 657 ··· 717 742 found = 1; 718 743 } 719 744 } 720 - for (i = 0; 721 - !found && (address_data->ignore_range[i] != I2C_CLIENT_END); 722 - i += 3) { 723 - if (((adap_id == address_data->ignore_range[i]) || 724 - ((address_data->ignore_range[i]==ANY_I2C_BUS))) && 725 - (addr >= address_data->ignore_range[i+1]) && 726 - (addr <= address_data->ignore_range[i+2])) { 727 - dev_dbg(&adapter->dev, "found ignore_range parameter for adapter %d, " 728 - "addr %04x\n", adap_id,addr); 729 - found = 1; 730 - } 731 - } 732 745 if (found) 733 746 continue; 734 747 ··· 733 770 } 734 771 735 772 for (i = 0; 736 - !found && (address_data->normal_i2c_range[i] != I2C_CLIENT_END); 737 - i += 2) { 738 - if ((addr >= address_data->normal_i2c_range[i]) && 739 - (addr <= address_data->normal_i2c_range[i+1])) { 740 - found = 1; 741 - dev_dbg(&adapter->dev, "found normal i2c_range entry for adapter %d, " 742 - "addr %04x\n", adap_id,addr); 743 - } 744 - } 745 - 746 - for (i = 0; 747 773 !found && (address_data->probe[i] != I2C_CLIENT_END); 748 774 i += 2) { 749 775 if (((adap_id == address_data->probe[i]) || ··· 740 788 (addr == address_data->probe[i+1])) { 741 789 found = 1; 742 790 dev_dbg(&adapter->dev, "found probe parameter for adapter %d, " 743 - "addr %04x\n", adap_id,addr); 744 - } 745 - } 746 - for (i = 0; 747 - !found && (address_data->probe_range[i] != I2C_CLIENT_END); 748 - i += 3) { 749 - if (((adap_id == address_data->probe_range[i]) || 750 - (address_data->probe_range[i] == ANY_I2C_BUS)) && 751 - (addr >= address_data->probe_range[i+1]) && 752 - (addr <= address_data->probe_range[i+2])) { 753 - found = 1; 754 - dev_dbg(&adapter->dev, "found probe_range parameter for adapter %d, " 755 791 "addr %04x\n", adap_id,addr); 756 792 } 757 793 }
+1 -2
drivers/i2c/i2c-dev.c
··· 29 29 /* The devfs code is contributed by Philipp Matthias Hahn 30 30 <pmhahn@titan.lahn.de> */ 31 31 32 - #include <linux/config.h> 33 32 #include <linux/kernel.h> 34 33 #include <linux/module.h> 35 34 #include <linux/fs.h> ··· 213 214 sizeof(rdwr_arg))) 214 215 return -EFAULT; 215 216 216 - /* Put an arbritrary limit on the number of messages that can 217 + /* Put an arbitrary limit on the number of messages that can 217 218 * be sent at once */ 218 219 if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS) 219 220 return -EINVAL;
+4 -2
drivers/macintosh/therm_windtunnel.c
··· 51 51 static int do_probe( struct i2c_adapter *adapter, int addr, int kind); 52 52 53 53 /* scan 0x48-0x4f (DS1775) and 0x2c-2x2f (ADM1030) */ 54 - static unsigned short normal_i2c[] = { 0x49, 0x2c, I2C_CLIENT_END }; 55 - static unsigned short normal_i2c_range[] = { 0x48, 0x4f, 0x2c, 0x2f, I2C_CLIENT_END }; 54 + static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 55 + 0x4c, 0x4d, 0x4e, 0x4f, 56 + 0x2c, 0x2d, 0x2e, 0x2f, 57 + I2C_CLIENT_END }; 56 58 57 59 I2C_CLIENT_INSMOD; 58 60
+4 -12
drivers/media/video/adv7170.c
··· 384 384 I2C_ADV7171 >> 1, (I2C_ADV7171 >> 1) + 1, 385 385 I2C_CLIENT_END 386 386 }; 387 - static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 388 387 389 - static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 390 - static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 391 - static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 392 - static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 393 - static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; 388 + static unsigned short ignore = I2C_CLIENT_END; 394 389 395 390 static struct i2c_client_address_data addr_data = { 396 391 .normal_i2c = normal_i2c, 397 - .normal_i2c_range = normal_i2c_range, 398 - .probe = probe, 399 - .probe_range = probe_range, 400 - .ignore = ignore, 401 - .ignore_range = ignore_range, 402 - .force = force 392 + .probe = &ignore, 393 + .ignore = &ignore, 394 + .force = &ignore, 403 395 }; 404 396 405 397 static struct i2c_driver i2c_driver_adv7170;
+4 -12
drivers/media/video/adv7175.c
··· 434 434 I2C_ADV7176 >> 1, (I2C_ADV7176 >> 1) + 1, 435 435 I2C_CLIENT_END 436 436 }; 437 - static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 438 437 439 - static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 440 - static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 441 - static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 442 - static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 443 - static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; 438 + static unsigned short ignore = I2C_CLIENT_END; 444 439 445 440 static struct i2c_client_address_data addr_data = { 446 441 .normal_i2c = normal_i2c, 447 - .normal_i2c_range = normal_i2c_range, 448 - .probe = probe, 449 - .probe_range = probe_range, 450 - .ignore = ignore, 451 - .ignore_range = ignore_range, 452 - .force = force 442 + .probe = &ignore, 443 + .ignore = &ignore, 444 + .force = &ignore, 453 445 }; 454 446 455 447 static struct i2c_driver i2c_driver_adv7175;
+4 -12
drivers/media/video/bt819.c
··· 500 500 I2C_BT819 >> 1, 501 501 I2C_CLIENT_END, 502 502 }; 503 - static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 504 503 505 - static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 506 - static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 507 - static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 508 - static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 509 - static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; 504 + static unsigned short ignore = I2C_CLIENT_END; 510 505 511 506 static struct i2c_client_address_data addr_data = { 512 507 .normal_i2c = normal_i2c, 513 - .normal_i2c_range = normal_i2c_range, 514 - .probe = probe, 515 - .probe_range = probe_range, 516 - .ignore = ignore, 517 - .ignore_range = ignore_range, 518 - .force = force 508 + .probe = &ignore, 509 + .ignore = &ignore, 510 + .force = &ignore, 519 511 }; 520 512 521 513 static struct i2c_driver i2c_driver_bt819;
+2 -2
drivers/media/video/bt832.c
··· 39 39 MODULE_LICENSE("GPL"); 40 40 41 41 /* Addresses to scan */ 42 - static unsigned short normal_i2c[] = {I2C_CLIENT_END}; 43 - static unsigned short normal_i2c_range[] = {I2C_BT832_ALT1>>1,I2C_BT832_ALT2>>1,I2C_CLIENT_END}; 42 + static unsigned short normal_i2c[] = { I2C_BT832_ALT1>>1, I2C_BT832_ALT2>>1, 43 + I2C_CLIENT_END }; 44 44 I2C_CLIENT_INSMOD; 45 45 46 46 /* ---------------------------------------------------------------------- */
+4 -12
drivers/media/video/bt856.c
··· 288 288 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 289 289 */ 290 290 static unsigned short normal_i2c[] = { I2C_BT856 >> 1, I2C_CLIENT_END }; 291 - static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 292 291 293 - static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 294 - static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 295 - static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 296 - static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 297 - static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; 292 + static unsigned short ignore = I2C_CLIENT_END; 298 293 299 294 static struct i2c_client_address_data addr_data = { 300 295 .normal_i2c = normal_i2c, 301 - .normal_i2c_range = normal_i2c_range, 302 - .probe = probe, 303 - .probe_range = probe_range, 304 - .ignore = ignore, 305 - .ignore_range = ignore_range, 306 - .force = force 296 + .probe = &ignore, 297 + .ignore = &ignore, 298 + .force = &ignore, 307 299 }; 308 300 309 301 static struct i2c_driver i2c_driver_bt856;
-1
drivers/media/video/msp3400.c
··· 147 147 I2C_MSP3400C_ALT >> 1, 148 148 I2C_CLIENT_END 149 149 }; 150 - static unsigned short normal_i2c_range[] = {I2C_CLIENT_END,I2C_CLIENT_END}; 151 150 I2C_CLIENT_INSMOD; 152 151 153 152 /* ----------------------------------------------------------------------- */
-1
drivers/media/video/saa5246a.c
··· 64 64 65 65 /* Addresses to scan */ 66 66 static unsigned short normal_i2c[] = { I2C_ADDRESS, I2C_CLIENT_END }; 67 - static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 68 67 I2C_CLIENT_INSMOD; 69 68 70 69 static struct i2c_client client_template;
-1
drivers/media/video/saa5249.c
··· 132 132 133 133 /* Addresses to scan */ 134 134 static unsigned short normal_i2c[] = {34>>1,I2C_CLIENT_END}; 135 - static unsigned short normal_i2c_range[] = {I2C_CLIENT_END}; 136 135 I2C_CLIENT_INSMOD; 137 136 138 137 static struct i2c_client client_template;
+4 -12
drivers/media/video/saa7110.c
··· 463 463 (I2C_SAA7110 >> 1) + 1, 464 464 I2C_CLIENT_END 465 465 }; 466 - static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 467 466 468 - static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 469 - static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 470 - static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 471 - static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 472 - static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; 467 + static unsigned short ignore = I2C_CLIENT_END; 473 468 474 469 static struct i2c_client_address_data addr_data = { 475 470 .normal_i2c = normal_i2c, 476 - .normal_i2c_range = normal_i2c_range, 477 - .probe = probe, 478 - .probe_range = probe_range, 479 - .ignore = ignore, 480 - .ignore_range = ignore_range, 481 - .force = force 471 + .probe = &ignore, 472 + .ignore = &ignore, 473 + .force = &ignore, 482 474 }; 483 475 484 476 static struct i2c_driver i2c_driver_saa7110;
+4 -12
drivers/media/video/saa7111.c
··· 482 482 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 483 483 */ 484 484 static unsigned short normal_i2c[] = { I2C_SAA7111 >> 1, I2C_CLIENT_END }; 485 - static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 486 485 487 - static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 488 - static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 489 - static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 490 - static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 491 - static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; 486 + static unsigned short ignore = I2C_CLIENT_END; 492 487 493 488 static struct i2c_client_address_data addr_data = { 494 489 .normal_i2c = normal_i2c, 495 - .normal_i2c_range = normal_i2c_range, 496 - .probe = probe, 497 - .probe_range = probe_range, 498 - .ignore = ignore, 499 - .ignore_range = ignore_range, 500 - .force = force 490 + .probe = &ignore, 491 + .ignore = &ignore, 492 + .force = &ignore, 501 493 }; 502 494 503 495 static struct i2c_driver i2c_driver_saa7111;
+4 -12
drivers/media/video/saa7114.c
··· 820 820 */ 821 821 static unsigned short normal_i2c[] = 822 822 { I2C_SAA7114 >> 1, I2C_SAA7114A >> 1, I2C_CLIENT_END }; 823 - static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 824 823 825 - static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 826 - static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 827 - static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 828 - static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 829 - static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; 824 + static unsigned short ignore = I2C_CLIENT_END; 830 825 831 826 static struct i2c_client_address_data addr_data = { 832 827 .normal_i2c = normal_i2c, 833 - .normal_i2c_range = normal_i2c_range, 834 - .probe = probe, 835 - .probe_range = probe_range, 836 - .ignore = ignore, 837 - .ignore_range = ignore_range, 838 - .force = force 828 + .probe = &ignore, 829 + .ignore = &ignore, 830 + .force = &ignore, 839 831 }; 840 832 841 833 static struct i2c_driver i2c_driver_saa7114;
-1
drivers/media/video/saa7134/saa6752hs.c
··· 22 22 23 23 /* Addresses to scan */ 24 24 static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END}; 25 - static unsigned short normal_i2c_range[] = {I2C_CLIENT_END}; 26 25 I2C_CLIENT_INSMOD; 27 26 28 27 MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder");
+4 -12
drivers/media/video/saa7185.c
··· 380 380 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' 381 381 */ 382 382 static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END }; 383 - static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 384 383 385 - static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 386 - static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 387 - static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 388 - static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 389 - static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; 384 + static unsigned short ignore = I2C_CLIENT_END; 390 385 391 386 static struct i2c_client_address_data addr_data = { 392 387 .normal_i2c = normal_i2c, 393 - .normal_i2c_range = normal_i2c_range, 394 - .probe = probe, 395 - .probe_range = probe_range, 396 - .ignore = ignore, 397 - .ignore_range = ignore_range, 398 - .force = force 388 + .probe = &ignore, 389 + .ignore = &ignore, 390 + .force = &ignore, 399 391 }; 400 392 401 393 static struct i2c_driver i2c_driver_saa7185;
-1
drivers/media/video/tda7432.c
··· 74 74 I2C_TDA7432 >> 1, 75 75 I2C_CLIENT_END, 76 76 }; 77 - static unsigned short normal_i2c_range[] = { I2C_CLIENT_END, I2C_CLIENT_END }; 78 77 I2C_CLIENT_INSMOD; 79 78 80 79 /* Structure of address and subaddresses for the tda7432 */
-1
drivers/media/video/tda9840.c
··· 43 43 44 44 /* addresses to scan, found only at 0x42 (7-Bit) */ 45 45 static unsigned short normal_i2c[] = { I2C_TDA9840, I2C_CLIENT_END }; 46 - static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 47 46 48 47 /* magic definition of all other variables and things */ 49 48 I2C_CLIENT_INSMOD;
-1
drivers/media/video/tda9875.c
··· 44 44 I2C_TDA9875 >> 1, 45 45 I2C_CLIENT_END 46 46 }; 47 - static unsigned short normal_i2c_range[] = {I2C_CLIENT_END}; 48 47 I2C_CLIENT_INSMOD; 49 48 50 49 /* This is a superset of the TDA9875 */
-1
drivers/media/video/tda9887.c
··· 33 33 0x96 >>1, 34 34 I2C_CLIENT_END, 35 35 }; 36 - static unsigned short normal_i2c_range[] = {I2C_CLIENT_END,I2C_CLIENT_END}; 37 36 I2C_CLIENT_INSMOD; 38 37 39 38 /* insmod options */
-1
drivers/media/video/tea6415c.c
··· 43 43 44 44 /* addresses to scan, found only at 0x03 and/or 0x43 (7-bit) */ 45 45 static unsigned short normal_i2c[] = { I2C_TEA6415C_1, I2C_TEA6415C_2, I2C_CLIENT_END }; 46 - static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 47 46 48 47 /* magic definition of all other variables and things */ 49 48 I2C_CLIENT_INSMOD;
-1
drivers/media/video/tea6420.c
··· 40 40 41 41 /* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */ 42 42 static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END }; 43 - static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 44 43 45 44 /* magic definition of all other variables and things */ 46 45 I2C_CLIENT_INSMOD;
+6 -11
drivers/media/video/tuner-3036.c
··· 34 34 static struct i2c_client client_template; 35 35 36 36 /* Addresses to scan */ 37 - static unsigned short normal_i2c[] = {I2C_CLIENT_END}; 38 - static unsigned short normal_i2c_range[] = {0x60, 0x61, I2C_CLIENT_END}; 39 - static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 40 - static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 41 - static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 42 - static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 43 - static unsigned short force[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 37 + static unsigned short normal_i2c[] = { 0x60, 0x61, I2C_CLIENT_END }; 38 + static unsigned short ignore = I2C_CLIENT_END; 44 39 45 40 static struct i2c_client_address_data addr_data = { 46 - normal_i2c, normal_i2c_range, 47 - probe, probe_range, 48 - ignore, ignore_range, 49 - force 41 + .normal_i2c = normal_i2c, 42 + .probe = &ignore, 43 + .ignore = &ignore, 44 + .force = &ignore, 50 45 }; 51 46 52 47 /* ---------------------------------------------------------------------- */
+4 -7
drivers/media/video/tuner-core.c
··· 28 28 /* standard i2c insmod options */ 29 29 static unsigned short normal_i2c[] = { 30 30 0x4b, /* tda8290 */ 31 - I2C_CLIENT_END 32 - }; 33 - static unsigned short normal_i2c_range[] = { 34 - 0x60, 0x6f, 31 + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 32 + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 35 33 I2C_CLIENT_END 36 34 }; 37 35 I2C_CLIENT_INSMOD; ··· 223 225 static int tuner_probe(struct i2c_adapter *adap) 224 226 { 225 227 if (0 != addr) { 226 - normal_i2c[0] = addr; 227 - normal_i2c_range[0] = addr; 228 - normal_i2c_range[1] = addr; 228 + normal_i2c[0] = addr; 229 + normal_i2c[1] = I2C_CLIENT_END; 229 230 } 230 231 this_adap = 0; 231 232
-1
drivers/media/video/tvaudio.c
··· 148 148 I2C_TDA9874 >> 1, 149 149 I2C_PIC16C54 >> 1, 150 150 I2C_CLIENT_END }; 151 - static unsigned short normal_i2c_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 152 151 I2C_CLIENT_INSMOD; 153 152 154 153 static struct i2c_driver driver;
-1
drivers/media/video/tveeprom.c
··· 482 482 0xa0 >> 1, 483 483 I2C_CLIENT_END, 484 484 }; 485 - static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 486 485 I2C_CLIENT_INSMOD; 487 486 488 487 struct i2c_driver i2c_driver_tveeprom;
+4 -12
drivers/media/video/vpx3220.c
··· 569 569 { I2C_VPX3220 >> 1, (I2C_VPX3220 >> 1) + 4, 570 570 I2C_CLIENT_END 571 571 }; 572 - static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; 573 572 574 - static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 575 - static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 576 - static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 577 - static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END }; 578 - static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END }; 573 + static unsigned short ignore = I2C_CLIENT_END; 579 574 580 575 static struct i2c_client_address_data addr_data = { 581 576 .normal_i2c = normal_i2c, 582 - .normal_i2c_range = normal_i2c_range, 583 - .probe = probe, 584 - .probe_range = probe_range, 585 - .ignore = ignore, 586 - .ignore_range = ignore_range, 587 - .force = force 577 + .probe = &ignore, 578 + .ignore = &ignore, 579 + .force = &ignore, 588 580 }; 589 581 590 582 static struct i2c_driver vpx3220_i2c_driver;
-1
drivers/video/matrox/matroxfb_maven.c
··· 1230 1230 } 1231 1231 1232 1232 static unsigned short normal_i2c[] = { MAVEN_I2CID, I2C_CLIENT_END }; 1233 - static unsigned short normal_i2c_range[] = { MAVEN_I2CID, MAVEN_I2CID, I2C_CLIENT_END }; 1234 1233 I2C_CLIENT_INSMOD; 1235 1234 1236 1235 static struct i2c_driver maven_driver;
+76
include/asm-arm/arch-omap/tps65010.h
··· 30 30 31 31 /* 32 32 * ---------------------------------------------------------------------------- 33 + * Registers, all 8 bits 34 + * ---------------------------------------------------------------------------- 35 + */ 36 + 37 + #define TPS_CHGSTATUS 0x01 38 + # define TPS_CHG_USB (1 << 7) 39 + # define TPS_CHG_AC (1 << 6) 40 + # define TPS_CHG_THERM (1 << 5) 41 + # define TPS_CHG_TERM (1 << 4) 42 + # define TPS_CHG_TAPER_TMO (1 << 3) 43 + # define TPS_CHG_CHG_TMO (1 << 2) 44 + # define TPS_CHG_PRECHG_TMO (1 << 1) 45 + # define TPS_CHG_TEMP_ERR (1 << 0) 46 + #define TPS_REGSTATUS 0x02 47 + # define TPS_REG_ONOFF (1 << 7) 48 + # define TPS_REG_COVER (1 << 6) 49 + # define TPS_REG_UVLO (1 << 5) 50 + # define TPS_REG_NO_CHG (1 << 4) /* tps65013 */ 51 + # define TPS_REG_PG_LD02 (1 << 3) 52 + # define TPS_REG_PG_LD01 (1 << 2) 53 + # define TPS_REG_PG_MAIN (1 << 1) 54 + # define TPS_REG_PG_CORE (1 << 0) 55 + #define TPS_MASK1 0x03 56 + #define TPS_MASK2 0x04 57 + #define TPS_ACKINT1 0x05 58 + #define TPS_ACKINT2 0x06 59 + #define TPS_CHGCONFIG 0x07 60 + # define TPS_CHARGE_POR (1 << 7) /* 65010/65012 */ 61 + # define TPS65013_AUA (1 << 7) /* 65011/65013 */ 62 + # define TPS_CHARGE_RESET (1 << 6) 63 + # define TPS_CHARGE_FAST (1 << 5) 64 + # define TPS_CHARGE_CURRENT (3 << 3) 65 + # define TPS_VBUS_500MA (1 << 2) 66 + # define TPS_VBUS_CHARGING (1 << 1) 67 + # define TPS_CHARGE_ENABLE (1 << 0) 68 + #define TPS_LED1_ON 0x08 69 + #define TPS_LED1_PER 0x09 70 + #define TPS_LED2_ON 0x0a 71 + #define TPS_LED2_PER 0x0b 72 + #define TPS_VDCDC1 0x0c 73 + # define TPS_ENABLE_LP (1 << 3) 74 + #define TPS_VDCDC2 0x0d 75 + #define TPS_VREGS1 0x0e 76 + # define TPS_LDO2_ENABLE (1 << 7) 77 + # define TPS_LDO2_OFF (1 << 6) 78 + # define TPS_VLDO2_3_0V (3 << 4) 79 + # define TPS_VLDO2_2_75V (2 << 4) 80 + # define TPS_VLDO2_2_5V (1 << 4) 81 + # define TPS_VLDO2_1_8V (0 << 4) 82 + # define TPS_LDO1_ENABLE (1 << 3) 83 + # define TPS_LDO1_OFF (1 << 2) 84 + # define TPS_VLDO1_3_0V (3 << 0) 85 + # define TPS_VLDO1_2_75V (2 << 0) 86 + # define TPS_VLDO1_2_5V (1 << 0) 87 + # define TPS_VLDO1_ADJ (0 << 0) 88 + #define TPS_MASK3 0x0f 89 + #define TPS_DEFGPIO 0x10 90 + 91 + /* 92 + * ---------------------------------------------------------------------------- 33 93 * Macros used by exported functions 34 94 * ---------------------------------------------------------------------------- 35 95 */ ··· 131 71 */ 132 72 extern int tps65010_set_led(unsigned led, unsigned mode); 133 73 74 + /* tps65010_set_vib parameter: 75 + * value: ON or OFF 76 + */ 77 + extern int tps65010_set_vib(unsigned value); 78 + 134 79 /* tps65010_set_low_pwr parameter: 135 80 * mode: ON or OFF 136 81 */ 137 82 extern int tps65010_set_low_pwr(unsigned mode); 83 + 84 + /* tps65010_config_vregs1 parameter: 85 + * value to be written to VREGS1 register 86 + * Note: The complete register is written, set all bits you need 87 + */ 88 + extern int tps65010_config_vregs1(unsigned value); 89 + 90 + /* tps65013_set_low_pwr parameter: 91 + * mode: ON or OFF 92 + */ 93 + extern int tps65013_set_low_pwr(unsigned mode); 138 94 139 95 #endif /* __ASM_ARCH_TPS65010_H */ 140 96
+1
include/linux/i2c-id.h
··· 108 108 #define I2C_DRIVERID_TDA7313 62 /* TDA7313 audio processor */ 109 109 #define I2C_DRIVERID_MAX6900 63 /* MAX6900 real-time clock */ 110 110 #define I2C_DRIVERID_SAA7114H 64 /* video decoder */ 111 + #define I2C_DRIVERID_DS1374 65 /* DS1374 real time clock */ 111 112 112 113 113 114 #define I2C_DRIVERID_EXP0 0xF0 /* experimental use id's */
+4 -4
include/linux/i2c-sysfs.h include/linux/hwmon-sysfs.h
··· 1 1 /* 2 - * i2c-sysfs.h - i2c chip driver sysfs defines 2 + * hwmon-sysfs.h - hardware monitoring chip driver sysfs defines 3 3 * 4 4 * Copyright (C) 2005 Yani Ioannou <yani.ioannou@gmail.com> 5 5 * ··· 17 17 * along with this program; if not, write to the Free Software 18 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 19 */ 20 - #ifndef _LINUX_I2C_SYSFS_H 21 - #define _LINUX_I2C_SYSFS_H 20 + #ifndef _LINUX_HWMON_SYSFS_H 21 + #define _LINUX_HWMON_SYSFS_H 22 22 23 23 struct sensor_device_attribute{ 24 24 struct device_attribute dev_attr; ··· 33 33 .index = _index, \ 34 34 } 35 35 36 - #endif /* _LINUX_I2C_SYSFS_H */ 36 + #endif /* _LINUX_HWMON_SYSFS_H */
+12
include/linux/i2c-vid.h
··· 97 97 2050 - (val) * 50); 98 98 } 99 99 } 100 + 101 + static inline int vid_to_reg(int val, int vrm) 102 + { 103 + switch (vrm) { 104 + case 91: /* VRM 9.1 */ 105 + case 90: /* VRM 9.0 */ 106 + return ((val >= 1100) && (val <= 1850) ? 107 + ((18499 - val * 10) / 25 + 5) / 10 : -1); 108 + default: 109 + return -1; 110 + } 111 + }
-12
include/linux/i2c.h
··· 290 290 */ 291 291 struct i2c_client_address_data { 292 292 unsigned short *normal_i2c; 293 - unsigned short *normal_i2c_range; 294 293 unsigned short *probe; 295 - unsigned short *probe_range; 296 294 unsigned short *ignore; 297 - unsigned short *ignore_range; 298 295 unsigned short *force; 299 296 }; 300 297 ··· 560 563 #define I2C_CLIENT_INSMOD \ 561 564 I2C_CLIENT_MODULE_PARM(probe, \ 562 565 "List of adapter,address pairs to scan additionally"); \ 563 - I2C_CLIENT_MODULE_PARM(probe_range, \ 564 - "List of adapter,start-addr,end-addr triples to scan " \ 565 - "additionally"); \ 566 566 I2C_CLIENT_MODULE_PARM(ignore, \ 567 567 "List of adapter,address pairs not to scan"); \ 568 - I2C_CLIENT_MODULE_PARM(ignore_range, \ 569 - "List of adapter,start-addr,end-addr triples not to " \ 570 - "scan"); \ 571 568 I2C_CLIENT_MODULE_PARM(force, \ 572 569 "List of adapter,address pairs to boldly assume " \ 573 570 "to be present"); \ 574 571 static struct i2c_client_address_data addr_data = { \ 575 572 .normal_i2c = normal_i2c, \ 576 - .normal_i2c_range = normal_i2c_range, \ 577 573 .probe = probe, \ 578 - .probe_range = probe_range, \ 579 574 .ignore = ignore, \ 580 - .ignore_range = ignore_range, \ 581 575 .force = force, \ 582 576 } 583 577