···8383 more efficient. You should really be using libraw1394 for raw13948484 access anyway.8585Who: Jody McIntyre <scjody@steamballoon.com>8686+8787+---------------------------8888+8989+What: i2c sysfs name change: in1_ref, vid deprecated in favour of cpu0_vid9090+When: November 20059191+Files: drivers/i2c/chips/adm1025.c, drivers/i2c/chips/adm1026.c9292+Why: Match the other drivers' name for the same function, duplicate names9393+ will be available until removal of old names.9494+Who: Grant Coady <gcoady@gmail.com>9595+
+1-1
Documentation/i2c/busses/i2c-sis69x
···4242chipsets as well: 635, and 635T. If anyone owns a board with those chips4343AND is willing to risk crashing & burning an otherwise well-behaved kernel4444in the name of progress... please contact me at <mhoffman@lightlink.com> or4545-via the project's mailing list: <sensors@stimpy.netroedge.com>. Please4545+via the project's mailing list: <lm-sensors@lm-sensors.org>. Please4646send bug reports and/or success stories as well.47474848
+111
Documentation/i2c/chips/adm1021
···11+Kernel driver adm102122+=====================33+44+Supported chips:55+ * Analog Devices ADM102166+ Prefix: 'adm1021'77+ Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e88+ Datasheet: Publicly available at the Analog Devices website99+ * Analog Devices ADM1021A/ADM10231010+ Prefix: 'adm1023'1111+ Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e1212+ Datasheet: Publicly available at the Analog Devices website1313+ * Genesys Logic GL523SM1414+ Prefix: 'gl523sm'1515+ Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e1616+ Datasheet:1717+ * Intel Xeon Processor1818+ Prefix: - any other - may require 'force_adm1021' parameter1919+ Addresses scanned: none2020+ Datasheet: Publicly available at Intel website2121+ * Maxim MAX16172222+ Prefix: 'max1617'2323+ Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e2424+ Datasheet: Publicly available at the Maxim website2525+ * Maxim MAX1617A2626+ Prefix: 'max1617a'2727+ Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e2828+ Datasheet: Publicly available at the Maxim website2929+ * National Semiconductor LM843030+ Prefix: 'lm84'3131+ Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e3232+ Datasheet: Publicly available at the National Semiconductor website3333+ * Philips NE16173434+ Prefix: 'max1617' (probably detected as a max1617)3535+ Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e3636+ Datasheet: Publicly available at the Philips website3737+ * Philips NE1617A3838+ Prefix: 'max1617' (probably detected as a max1617)3939+ Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e4040+ Datasheet: Publicly available at the Philips website4141+ * TI THMC104242+ Prefix: 'thmc10'4343+ Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e4444+ Datasheet: Publicly available at the TI website4545+ * Onsemi MC10664646+ Prefix: 'mc1066'4747+ Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e4848+ Datasheet: Publicly available at the Onsemi website4949+5050+5151+Authors:5252+ Frodo Looijaard <frodol@dds.nl>,5353+ Philip Edelbrock <phil@netroedge.com>5454+5555+Module Parameters5656+-----------------5757+5858+* read_only: int5959+ Don't set any values, read only mode6060+6161+6262+Description6363+-----------6464+6565+The chips supported by this driver are very similar. The Maxim MAX1617 is6666+the oldest; it has the problem that it is not very well detectable. The6767+MAX1617A solves that. The ADM1021 is a straight clone of the MAX1617A.6868+Ditto for the THMC10. From here on, we will refer to all these chips as6969+ADM1021-clones.7070+7171+The ADM1021 and MAX1617A reports a die code, which is a sort of revision7272+code. This can help us pinpoint problems; it is not very useful7373+otherwise.7474+7575+ADM1021-clones implement two temperature sensors. One of them is internal,7676+and measures the temperature of the chip itself; the other is external and7777+is realised in the form of a transistor-like device. A special alarm7878+indicates whether the remote sensor is connected.7979+8080+Each sensor has its own low and high limits. When they are crossed, the8181+corresponding alarm is set and remains on as long as the temperature stays8282+out of range. Temperatures are measured in degrees Celsius. Measurements8383+are possible between -65 and +127 degrees, with a resolution of one degree.8484+8585+If an alarm triggers, it will remain triggered until the hardware register8686+is read at least once. This means that the cause for the alarm may already8787+have disappeared!8888+8989+This driver only updates its values each 1.5 seconds; reading it more often9090+will do no harm, but will return 'old' values. It is possible to make9191+ADM1021-clones do faster measurements, but there is really no good reason9292+for that.9393+9494+Xeon support9595+------------9696+9797+Some Xeon processors have real max1617, adm1021, or compatible chips9898+within them, with two temperature sensors.9999+100100+Other Xeons have chips with only one sensor.101101+102102+If you have a Xeon, and the adm1021 module loads, and both temperatures103103+appear valid, then things are good.104104+105105+If the adm1021 module doesn't load, you should try this:106106+ modprobe adm1021 force_adm1021=BUS,ADDRESS107107+ ADDRESS can only be 0x18, 0x1a, 0x29, 0x2b, 0x4c, or 0x4e.108108+109109+If you have dual Xeons you may have appear to have two separate110110+adm1021-compatible chips, or two single-temperature sensors, at distinct111111+addresses.
+51
Documentation/i2c/chips/adm1025
···11+Kernel driver adm102522+=====================33+44+Supported chips:55+ * Analog Devices ADM1025, ADM1025A66+ Prefix: 'adm1025'77+ Addresses scanned: I2C 0x2c - 0x2e88+ Datasheet: Publicly available at the Analog Devices website99+ * Philips NE16191010+ Prefix: 'ne1619'1111+ Addresses scanned: I2C 0x2c - 0x2d1212+ Datasheet: Publicly available at the Philips website1313+1414+The NE1619 presents some differences with the original ADM1025:1515+ * Only two possible addresses (0x2c - 0x2d).1616+ * No temperature offset register, but we don't use it anyway.1717+ * No INT mode for pin 16. We don't play with it anyway.1818+1919+Authors:2020+ Chen-Yuan Wu <gwu@esoft.com>,2121+ Jean Delvare <khali@linux-fr.org>2222+2323+Description2424+-----------2525+2626+(This is from Analog Devices.) The ADM1025 is a complete system hardware2727+monitor for microprocessor-based systems, providing measurement and limit2828+comparison of various system parameters. Five voltage measurement inputs2929+are provided, for monitoring +2.5V, +3.3V, +5V and +12V power supplies and3030+the processor core voltage. The ADM1025 can monitor a sixth power-supply3131+voltage by measuring its own VCC. One input (two pins) is dedicated to a3232+remote temperature-sensing diode and an on-chip temperature sensor allows3333+ambient temperature to be monitored.3434+3535+One specificity of this chip is that the pin 11 can be hardwired in two3636+different manners. It can act as the +12V power-supply voltage analog3737+input, or as the a fifth digital entry for the VID reading (bit 4). It's3838+kind of strange since both are useful, and the reason for designing the3939+chip that way is obscure at least to me. The bit 5 of the configuration4040+register can be used to define how the chip is hardwired. Please note that4141+it is not a choice you have to make as the user. The choice was already4242+made by your motherboard's maker. If the configuration bit isn't set4343+properly, you'll have a wrong +12V reading or a wrong VID reading. The way4444+the driver handles that is to preserve this bit through the initialization4545+process, assuming that the BIOS set it up properly beforehand. If it turns4646+out not to be true in some cases, we'll provide a module parameter to force4747+modes.4848+4949+This driver also supports the ADM1025A, which differs from the ADM10255050+only in that it has "open-drain VID inputs while the ADM1025 has on-chip5151+100k pull-ups on the VID inputs". It doesn't make any difference for us.
+93
Documentation/i2c/chips/adm1026
···11+Kernel driver adm102622+=====================33+44+Supported chips:55+ * Analog Devices ADM102666+ Prefix: 'adm1026'77+ Addresses scanned: I2C 0x2c, 0x2d, 0x2e88+ Datasheet: Publicly available at the Analog Devices website99+ http://www.analog.com/en/prod/0,,766_825_ADM1026,00.html1010+1111+Authors:1212+ Philip Pokorny <ppokorny@penguincomputing.com> for Penguin Computing1313+ Justin Thiessen <jthiessen@penguincomputing.com>1414+1515+Module Parameters1616+-----------------1717+1818+* gpio_input: int array (min = 1, max = 17)1919+ List of GPIO pins (0-16) to program as inputs2020+* gpio_output: int array (min = 1, max = 17)2121+ List of GPIO pins (0-16) to program as outputs2222+* gpio_inverted: int array (min = 1, max = 17)2323+ List of GPIO pins (0-16) to program as inverted2424+* gpio_normal: int array (min = 1, max = 17)2525+ List of GPIO pins (0-16) to program as normal/non-inverted2626+* gpio_fan: int array (min = 1, max = 8)2727+ List of GPIO pins (0-7) to program as fan tachs2828+2929+3030+Description3131+-----------3232+3333+This driver implements support for the Analog Devices ADM1026. Analog3434+Devices calls it a "complete thermal system management controller."3535+3636+The ADM1026 implements three (3) temperature sensors, 17 voltage sensors,3737+16 general purpose digital I/O lines, eight (8) fan speed sensors (8-bit),3838+an analog output and a PWM output along with limit, alarm and mask bits for3939+all of the above. There is even 8k bytes of EEPROM memory on chip.4040+4141+Temperatures are measured in degrees Celsius. There are two external4242+sensor inputs and one internal sensor. Each sensor has a high and low4343+limit. If the limit is exceeded, an interrupt (#SMBALERT) can be4444+generated. The interrupts can be masked. In addition, there are over-temp4545+limits for each sensor. If this limit is exceeded, the #THERM output will4646+be asserted. The current temperature and limits have a resolution of 14747+degree.4848+4949+Fan rotation speeds are reported in RPM (rotations per minute) but measured5050+in counts of a 22.5kHz internal clock. Each fan has a high limit which5151+corresponds to a minimum fan speed. If the limit is exceeded, an interrupt5252+can be generated. Each fan can be programmed to divide the reference clock5353+by 1, 2, 4 or 8. Not all RPM values can accurately be represented, so some5454+rounding is done. With a divider of 8, the slowest measurable speed of a5555+two pulse per revolution fan is 661 RPM.5656+5757+There are 17 voltage sensors. An alarm is triggered if the voltage has5858+crossed a programmable minimum or maximum limit. Note that minimum in this5959+case always means 'closest to zero'; this is important for negative voltage6060+measurements. Several inputs have integrated attenuators so they can measure6161+higher voltages directly. 3.3V, 5V, 12V, -12V and battery voltage all have6262+dedicated inputs. There are several inputs scaled to 0-3V full-scale range6363+for SCSI terminator power. The remaining inputs are not scaled and have6464+a 0-2.5V full-scale range. A 2.5V or 1.82V reference voltage is provided6565+for negative voltage measurements.6666+6767+If an alarm triggers, it will remain triggered until the hardware register6868+is read at least once. This means that the cause for the alarm may already6969+have disappeared! Note that in the current implementation, all hardware7070+registers are read whenever any data is read (unless it is less than 2.07171+seconds since the last update). This means that you can easily miss7272+once-only alarms.7373+7474+The ADM1026 measures continuously. Analog inputs are measured about 47575+times a second. Fan speed measurement time depends on fan speed and7676+divisor. It can take as long as 1.5 seconds to measure all fan speeds.7777+7878+The ADM1026 has the ability to automatically control fan speed based on the7979+temperature sensor inputs. Both the PWM output and the DAC output can be8080+used to control fan speed. Usually only one of these two outputs will be8181+used. Write the minimum PWM or DAC value to the appropriate control8282+register. Then set the low temperature limit in the tmin values for each8383+temperature sensor. The range of control is fixed at 20 �C, and the8484+largest difference between current and tmin of the temperature sensors sets8585+the control output. See the datasheet for several example circuits for8686+controlling fan speed with the PWM and DAC outputs. The fan speed sensors8787+do not have PWM compensation, so it is probably best to control the fan8888+voltage from the power lead rather than on the ground lead.8989+9090+The datasheet shows an example application with VID signals attached to9191+GPIO lines. Unfortunately, the chip may not be connected to the VID lines9292+in this way. The driver assumes that the chips *is* connected this way to9393+get a VID voltage.
+35
Documentation/i2c/chips/adm1031
···11+Kernel driver adm103122+=====================33+44+Supported chips:55+ * Analog Devices ADM103066+ Prefix: 'adm1030'77+ Addresses scanned: I2C 0x2c to 0x2e88+ Datasheet: Publicly available at the Analog Devices website99+ http://products.analog.com/products/info.asp?product=ADM10301010+1111+ * Analog Devices ADM10311212+ Prefix: 'adm1031'1313+ Addresses scanned: I2C 0x2c to 0x2e1414+ Datasheet: Publicly available at the Analog Devices website1515+ http://products.analog.com/products/info.asp?product=ADM10311616+1717+Authors:1818+ Alexandre d'Alton <alex@alexdalton.org>1919+ Jean Delvare <khali@linux-fr.org>2020+2121+Description2222+-----------2323+2424+The ADM1030 and ADM1031 are digital temperature sensors and fan controllers.2525+They sense their own temperature as well as the temperature of up to one2626+(ADM1030) or two (ADM1031) external diodes.2727+2828+All temperature values are given in degrees Celsius. Resolution is 0.52929+degree for the local temperature, 0.125 degree for the remote temperatures.3030+3131+Each temperature channel has its own high and low limits, plus a critical3232+limit.3333+3434+The ADM1030 monitors a single fan speed, while the ADM1031 monitors up to3535+two. Each fan channel has its own low speed limit.
+177
Documentation/i2c/chips/adm9240
···11+Kernel driver adm924022+=====================33+44+Supported chips:55+ * Analog Devices ADM924066+ Prefix: 'adm9240'77+ Addresses scanned: I2C 0x2c - 0x2f88+ Datasheet: Publicly available at the Analog Devices website99+ http://www.analog.com/UploadedFiles/Data_Sheets/79857778ADM9240_0.pdf1010+1111+ * Dallas Semiconductor DS17801212+ Prefix: 'ds1780'1313+ Addresses scanned: I2C 0x2c - 0x2f1414+ Datasheet: Publicly available at the Dallas Semiconductor (Maxim) website1515+ http://pdfserv.maxim-ic.com/en/ds/DS1780.pdf1616+1717+ * National Semiconductor LM811818+ Prefix: 'lm81'1919+ Addresses scanned: I2C 0x2c - 0x2f2020+ Datasheet: Publicly available at the National Semiconductor website2121+ http://www.national.com/ds.cgi/LM/LM81.pdf2222+2323+Authors:2424+ Frodo Looijaard <frodol@dds.nl>,2525+ Philip Edelbrock <phil@netroedge.com>,2626+ Michiel Rook <michiel@grendelproject.nl>,2727+ Grant Coady <gcoady@gmail.com> with guidance2828+ from Jean Delvare <khali@linux-fr.org>2929+3030+Interface3131+---------3232+The I2C addresses listed above assume BIOS has not changed the3333+chip MSB 5-bit address. Each chip reports a unique manufacturer3434+identification code as well as the chip revision/stepping level.3535+3636+Description3737+-----------3838+[From ADM9240] The ADM9240 is a complete system hardware monitor for3939+microprocessor-based systems, providing measurement and limit comparison4040+of up to four power supplies and two processor core voltages, plus4141+temperature, two fan speeds and chassis intrusion. Measured values can4242+be read out via an I2C-compatible serial System Management Bus, and values4343+for limit comparisons can be programmed in over the same serial bus. The4444+high speed successive approximation ADC allows frequent sampling of all4545+analog channels to ensure a fast interrupt response to any out-of-limit4646+measurement.4747+4848+The ADM9240, DS1780 and LM81 are register compatible, the following4949+details are common to the three chips. Chip differences are described5050+after this section.5151+5252+5353+Measurements5454+------------5555+The measurement cycle5656+5757+The adm9240 driver will take a measurement reading no faster than once5858+each two seconds. User-space may read sysfs interface faster than the5959+measurement update rate and will receive cached data from the most6060+recent measurement.6161+6262+ADM9240 has a very fast 320us temperature and voltage measurement cycle6363+with independent fan speed measurement cycles counting alternating rising6464+edges of the fan tacho inputs.6565+6666+DS1780 measurement cycle is about once per second including fan speed.6767+6868+LM81 measurement cycle is about once per 400ms including fan speed.6969+The LM81 12-bit extended temperature measurement mode is not supported.7070+7171+Temperature7272+-----------7373+On chip temperature is reported as degrees Celsius as 9-bit signed data7474+with resolution of 0.5 degrees Celsius. High and low temperature limits7575+are 8-bit signed data with resolution of one degree Celsius.7676+7777+Temperature alarm is asserted once the temperature exceeds the high limit,7878+and is cleared when the temperature falls below the temp1_max_hyst value.7979+8080+Fan Speed8181+---------8282+Two fan tacho inputs are provided, the ADM9240 gates an internal 22.5kHz8383+clock via a divider to an 8-bit counter. Fan speed (rpm) is calculated by:8484+8585+rpm = (22500 * 60) / (count * divider)8686+8787+Automatic fan clock divider8888+8989+ * User sets 0 to fan_min limit9090+ - low speed alarm is disabled9191+ - fan clock divider not changed9292+ - auto fan clock adjuster enabled for valid fan speed reading9393+9494+ * User sets fan_min limit too low9595+ - low speed alarm is enabled9696+ - fan clock divider set to max9797+ - fan_min set to register value 254 which corresponds9898+ to 664 rpm on adm92409999+ - low speed alarm will be asserted if fan speed is100100+ less than minimum measurable speed101101+ - auto fan clock adjuster disabled102102+103103+ * User sets reasonable fan speed104104+ - low speed alarm is enabled105105+ - fan clock divider set to suit fan_min106106+ - auto fan clock adjuster enabled: adjusts fan_min107107+108108+ * User sets unreasonably high low fan speed limit109109+ - resolution of the low speed limit may be reduced110110+ - alarm will be asserted111111+ - auto fan clock adjuster enabled: adjusts fan_min112112+113113+ * fan speed may be displayed as zero until the auto fan clock divider114114+ adjuster brings fan speed clock divider back into chip measurement115115+ range, this will occur within a few measurement cycles.116116+117117+Analog Output118118+-------------119119+An analog output provides a 0 to 1.25 volt signal intended for an external120120+fan speed amplifier circuit. The analog output is set to maximum value on121121+power up or reset. This doesn't do much on the test Intel SE440BX-2.122122+123123+Voltage Monitor124124+125125+Voltage (IN) measurement is internally scaled:126126+127127+ nr label nominal maximum resolution128128+ mV mV mV129129+ 0 +2.5V 2500 3320 13.0130130+ 1 Vccp1 2700 3600 14.1131131+ 2 +3.3V 3300 4380 17.2132132+ 3 +5V 5000 6640 26.0133133+ 4 +12V 12000 15940 62.5134134+ 5 Vccp2 2700 3600 14.1135135+136136+The reading is an unsigned 8-bit value, nominal voltage measurement is137137+represented by a reading of 192, being 3/4 of the measurement range.138138+139139+An alarm is asserted for any voltage going below or above the set limits.140140+141141+The driver reports and accepts voltage limits scaled to the above table.142142+143143+VID Monitor144144+-----------145145+The chip has five inputs to read the 5-bit VID and reports the mV value146146+based on detected CPU type.147147+148148+Chassis Intrusion149149+-----------------150150+An alarm is asserted when the CI pin goes active high. The ADM9240151151+Datasheet has an example of an external temperature sensor driving152152+this pin. On an Intel SE440BX-2 the Chassis Intrusion header is153153+connected to a normally open switch.154154+155155+The ADM9240 provides an internal open drain on this line, and may output156156+a 20 ms active low pulse to reset an external Chassis Intrusion latch.157157+158158+Clear the CI latch by writing value 1 to the sysfs chassis_clear file.159159+160160+Alarm flags reported as 16-bit word161161+162162+ bit label comment163163+ --- ------------- --------------------------164164+ 0 +2.5 V_Error high or low limit exceeded165165+ 1 VCCP_Error high or low limit exceeded166166+ 2 +3.3 V_Error high or low limit exceeded167167+ 3 +5 V_Error high or low limit exceeded168168+ 4 Temp_Error temperature error169169+ 6 FAN1_Error fan low limit exceeded170170+ 7 FAN2_Error fan low limit exceeded171171+ 8 +12 V_Error high or low limit exceeded172172+ 9 VCCP2_Error high or low limit exceeded173173+ 12 Chassis_Error CI pin went high174174+175175+Remaining bits are reserved and thus undefined. It is important to note176176+that alarm bits may be cleared on read, user-space may latch alarms and177177+provide the end-user with a method to clear alarm memory.
+72
Documentation/i2c/chips/asb100
···11+Kernel driver asb10022+====================33+44+Supported Chips:55+ * Asus ASB100 and ASB100-A "Bach"66+ Prefix: 'asb100'77+ Addresses scanned: I2C 0x2d88+ Datasheet: none released99+1010+Author: Mark M. Hoffman <mhoffman@lightlink.com>1111+1212+Description1313+-----------1414+1515+This driver implements support for the Asus ASB100 and ASB100-A "Bach".1616+These are custom ASICs available only on Asus mainboards. Asus refuses to1717+supply a datasheet for these chips. Thanks go to many people who helped1818+investigate their hardware, including:1919+2020+Vitaly V. Bursov2121+Alexander van Kaam (author of MBM for Windows)2222+Bertrik Sikken2323+2424+The ASB100 implements seven voltage sensors, three fan rotation speed2525+sensors, four temperature sensors, VID lines and alarms. In addition to2626+these, the ASB100-A also implements a single PWM controller for fans 2 and2727+3 (i.e. one setting controls both.) If you have a plain ASB100, the PWM2828+controller will simply not work (or maybe it will for you... it doesn't for2929+me).3030+3131+Temperatures are measured and reported in degrees Celsius.3232+3333+Fan speeds are reported in RPM (rotations per minute). An alarm is3434+triggered if the rotation speed has dropped below a programmable limit.3535+3636+Voltage sensors (also known as IN sensors) report values in volts.3737+3838+The VID lines encode the core voltage value: the voltage level your3939+processor should work with. This is hardcoded by the mainboard and/or4040+processor itself. It is a value in volts.4141+4242+Alarms: (TODO question marks indicate may or may not work)4343+4444+0x0001 => in0 (?)4545+0x0002 => in1 (?)4646+0x0004 => in24747+0x0008 => in34848+0x0010 => temp1 (1)4949+0x0020 => temp25050+0x0040 => fan15151+0x0080 => fan25252+0x0100 => in45353+0x0200 => in5 (?) (2)5454+0x0400 => in6 (?) (2)5555+0x0800 => fan35656+0x1000 => chassis switch5757+0x2000 => temp35858+5959+Alarm Notes:6060+6161+(1) This alarm will only trigger if the hysteresis value is 127C.6262+I.e. it behaves the same as w83781d.6363+6464+(2) The min and max registers for these values appear to6565+be read-only or otherwise stuck at 0x00.6666+6767+TODO:6868+* Experiment with fan divisors > 8.6969+* Experiment with temp. sensor types.7070+* Are there really 13 voltage inputs? Probably not...7171+* Cleanups, no doubt...7272+
+108
Documentation/i2c/chips/ds1621
···11+Kernel driver ds162122+====================33+44+Supported chips:55+ * Dallas Semiconductor DS162166+ Prefix: 'ds1621'77+ Addresses scanned: I2C 0x48 - 0x4f88+ Datasheet: Publicly available at the Dallas Semiconductor website99+ http://www.dalsemi.com/1010+ * Dallas Semiconductor DS16251111+ Prefix: 'ds1621'1212+ Addresses scanned: I2C 0x48 - 0x4f1313+ Datasheet: Publicly available at the Dallas Semiconductor website1414+ http://www.dalsemi.com/1515+1616+Authors:1717+ Christian W. Zuckschwerdt <zany@triq.net>1818+ valuable contributions by Jan M. Sendler <sendler@sendler.de>1919+ ported to 2.6 by Aurelien Jarno <aurelien@aurel32.net>2020+ with the help of Jean Delvare <khali@linux-fr.org>2121+2222+Module Parameters2323+------------------2424+2525+* polarity int2626+ Output's polarity: 0 = active high, 1 = active low2727+2828+Description2929+-----------3030+3131+The DS1621 is a (one instance) digital thermometer and thermostat. It has3232+both high and low temperature limits which can be user defined (i.e.3333+programmed into non-volatile on-chip registers). Temperature range is -553434+degree Celsius to +125 in 0.5 increments. You may convert this into a3535+Fahrenheit range of -67 to +257 degrees with 0.9 steps. If polarity3636+parameter is not provided, original value is used.3737+3838+As for the thermostat, behavior can also be programmed using the polarity3939+toggle. On the one hand ("heater"), the thermostat output of the chip,4040+Tout, will trigger when the low limit temperature is met or underrun and4141+stays high until the high limit is met or exceeded. On the other hand4242+("cooler"), vice versa. That way "heater" equals "active low", whereas4343+"conditioner" equals "active high". Please note that the DS1621 data sheet4444+is somewhat misleading in this point since setting the polarity bit does4545+not simply invert Tout.4646+4747+A second thing is that, during extensive testing, Tout showed a tolerance4848+of up to +/- 0.5 degrees even when compared against precise temperature4949+readings. Be sure to have a high vs. low temperature limit gap of al least5050+1.0 degree Celsius to avoid Tout "bouncing", though!5151+5252+As for alarms, you can read the alarm status of the DS1621 via the 'alarms'5353+/sys file interface. The result consists mainly of bit 6 and 5 of the5454+configuration register of the chip; bit 6 (0x40 or 64) is the high alarm5555+bit and bit 5 (0x20 or 32) the low one. These bits are set when the high or5656+low limits are met or exceeded and are reset by the module as soon as the5757+respective temperature ranges are left.5858+5959+The alarm registers are in no way suitable to find out about the actual6060+status of Tout. They will only tell you about its history, whether or not6161+any of the limits have ever been met or exceeded since last power-up or6262+reset. Be aware: When testing, it showed that the status of Tout can change6363+with neither of the alarms set.6464+6565+Temperature conversion of the DS1621 takes up to 1000ms; internal access to6666+non-volatile registers may last for 10ms or below.6767+6868+High Accuracy Temperature Reading6969+---------------------------------7070+7171+As said before, the temperature issued via the 9-bit i2c-bus data is7272+somewhat arbitrary. Internally, the temperature conversion is of a7373+different kind that is explained (not so...) well in the DS1621 data sheet.7474+To cut the long story short: Inside the DS1621 there are two oscillators,7575+both of them biassed by a temperature coefficient.7676+7777+Higher resolution of the temperature reading can be achieved using the7878+internal projection, which means taking account of REG_COUNT and REG_SLOPE7979+(the driver manages them):8080+8181+Taken from Dallas Semiconductors App Note 068: 'Increasing Temperature8282+Resolution on the DS1620' and App Note 105: 'High Resolution Temperature8383+Measurement with Dallas Direct-to-Digital Temperature Sensors'8484+8585+- Read the 9-bit temperature and strip the LSB (Truncate the .5 degs)8686+- The resulting value is TEMP_READ.8787+- Then, read REG_COUNT.8888+- And then, REG_SLOPE.8989+9090+ TEMP = TEMP_READ - 0.25 + ((REG_SLOPE - REG_COUNT) / REG_SLOPE)9191+9292+Note that this is what the DONE bit in the DS1621 configuration register is9393+good for: Internally, one temperature conversion takes up to 1000ms. Before9494+that conversion is complete you will not be able to read valid things out9595+of REG_COUNT and REG_SLOPE. The DONE bit, as you may have guessed by now,9696+tells you whether the conversion is complete ("done", in plain English) and9797+thus, whether the values you read are good or not.9898+9999+The DS1621 has two modes of operation: "Continuous" conversion, which can100100+be understood as the default stand-alone mode where the chip gets the101101+temperature and controls external devices via its Tout pin or tells other102102+i2c's about it if they care. The other mode is called "1SHOT", that means103103+that it only figures out about the temperature when it is explicitly told104104+to do so; this can be seen as power saving mode.105105+106106+Now if you want to read REG_COUNT and REG_SLOPE, you have to either stop107107+the continuous conversions until the contents of these registers are valid,108108+or, in 1SHOT mode, you have to have one conversion made.
+96
Documentation/i2c/chips/eeprom
···11+Kernel driver eeprom22+====================33+44+Supported chips:55+ * Any EEPROM chip in the designated address range66+ Prefix: 'eeprom'77+ Addresses scanned: I2C 0x50 - 0x5788+ Datasheets: Publicly available from:99+ Atmel (www.atmel.com),1010+ Catalyst (www.catsemi.com),1111+ Fairchild (www.fairchildsemi.com),1212+ Microchip (www.microchip.com),1313+ Philips (www.semiconductor.philips.com),1414+ Rohm (www.rohm.com),1515+ ST (www.st.com),1616+ Xicor (www.xicor.com),1717+ and others.1818+1919+ Chip Size (bits) Address2020+ 24C01 1K 0x50 (shadows at 0x51 - 0x57)2121+ 24C01A 1K 0x50 - 0x57 (Typical device on DIMMs)2222+ 24C02 2K 0x50 - 0x572323+ 24C04 4K 0x50, 0x52, 0x54, 0x562424+ (additional data at 0x51, 0x53, 0x55, 0x57)2525+ 24C08 8K 0x50, 0x54 (additional data at 0x51, 0x52,2626+ 0x53, 0x55, 0x56, 0x57)2727+ 24C16 16K 0x50 (additional data at 0x51 - 0x57)2828+ Sony 2K 0x572929+3030+ Atmel 34C02B 2K 0x50 - 0x57, SW write protect at 0x30-373131+ Catalyst 34FC02 2K 0x50 - 0x57, SW write protect at 0x30-373232+ Catalyst 34RC02 2K 0x50 - 0x57, SW write protect at 0x30-373333+ Fairchild 34W02 2K 0x50 - 0x57, SW write protect at 0x30-373434+ Microchip 24AA52 2K 0x50 - 0x57, SW write protect at 0x30-373535+ ST M34C02 2K 0x50 - 0x57, SW write protect at 0x30-373636+3737+3838+Authors:3939+ Frodo Looijaard <frodol@dds.nl>,4040+ Philip Edelbrock <phil@netroedge.com>,4141+ Jean Delvare <khali@linux-fr.org>,4242+ Greg Kroah-Hartman <greg@kroah.com>,4343+ IBM Corp.4444+4545+Description4646+-----------4747+4848+This is a simple EEPROM module meant to enable reading the first 256 bytes4949+of an EEPROM (on a SDRAM DIMM for example). However, it will access serial5050+EEPROMs on any I2C adapter. The supported devices are generically called5151+24Cxx, and are listed above; however the numbering for these5252+industry-standard devices may vary by manufacturer.5353+5454+This module was a programming exercise to get used to the new project5555+organization laid out by Frodo, but it should be at least completely5656+effective for decoding the contents of EEPROMs on DIMMs.5757+5858+DIMMS will typically contain a 24C01A or 24C02, or the 34C02 variants.5959+The other devices will not be found on a DIMM because they respond to more6060+than one address.6161+6262+DDC Monitors may contain any device. Often a 24C01, which responds to all 86363+addresses, is found.6464+6565+Recent Sony Vaio laptops have an EEPROM at 0x57. We couldn't get the6666+specification, so it is guess work and far from being complete.6767+6868+The Microchip 24AA52/24LCS52, ST M34C02, and others support an additional6969+software write protect register at 0x30 - 0x37 (0x20 less than the memory7070+location). The chip responds to "write quick" detection at this address but7171+does not respond to byte reads. If this register is present, the lower 1287272+bytes of the memory array are not write protected. Any byte data write to7373+this address will write protect the memory array permanently, and the7474+device will no longer respond at the 0x30-37 address. The eeprom driver7575+does not support this register.7676+7777+Lacking functionality:7878+7979+* Full support for larger devices (24C04, 24C08, 24C16). These are not8080+typically found on a PC. These devices will appear as separate devices at8181+multiple addresses.8282+8383+* Support for really large devices (24C32, 24C64, 24C128, 24C256, 24C512).8484+These devices require two-byte address fields and are not supported.8585+8686+* Enable Writing. Again, no technical reason why not, but making it easy8787+to change the contents of the EEPROMs (on DIMMs anyway) also makes it easy8888+to disable the DIMMs (potentially preventing the computer from booting)8989+until the values are restored somehow.9090+9191+Use:9292+9393+After inserting the module (and any other required SMBus/i2c modules), you9494+should have some EEPROM directories in /sys/bus/i2c/devices/* of names such9595+as "0-0050". Inside each of these is a series of files, the eeprom file9696+contains the binary data from EEPROM.
+169
Documentation/i2c/chips/fscher
···11+Kernel driver fscher22+====================33+44+Supported chips:55+ * Fujitsu-Siemens Hermes chip66+ Prefix: 'fscher'77+ Addresses scanned: I2C 0x7388+99+Authors:1010+ Reinhard Nissl <rnissl@gmx.de> based on work1111+ from Hermann Jung <hej@odn.de>,1212+ Frodo Looijaard <frodol@dds.nl>,1313+ Philip Edelbrock <phil@netroedge.com>1414+1515+Description1616+-----------1717+1818+This driver implements support for the Fujitsu-Siemens Hermes chip. It is1919+described in the 'Register Set Specification BMC Hermes based Systemboard'2020+from Fujitsu-Siemens.2121+2222+The Hermes chip implements a hardware-based system management, e.g. for2323+controlling fan speed and core voltage. There is also a watchdog counter on2424+the chip which can trigger an alarm and even shut the system down.2525+2626+The chip provides three temperature values (CPU, motherboard and2727+auxiliary), three voltage values (+12V, +5V and battery) and three fans2828+(power supply, CPU and auxiliary).2929+3030+Temperatures are measured in degrees Celsius. The resolution is 1 degree.3131+3232+Fan rotation speeds are reported in RPM (rotations per minute). The value3333+can be divided by a programmable divider (1, 2 or 4) which is stored on3434+the chip.3535+3636+Voltage sensors (also known as "in" sensors) report their values in volts.3737+3838+All values are reported as final values from the driver. There is no need3939+for further calculations.4040+4141+4242+Detailed description4343+--------------------4444+4545+Below you'll find a single line description of all the bit values. With4646+this information, you're able to decode e. g. alarms, wdog, etc. To make4747+use of the watchdog, you'll need to set the watchdog time and enable the4848+watchdog. After that it is necessary to restart the watchdog time within4949+the specified period of time, or a system reset will occur.5050+5151+* revision5252+ READING & 0xff = 0x??: HERMES revision identification5353+5454+* alarms5555+ READING & 0x80 = 0x80: CPU throttling active5656+ READING & 0x80 = 0x00: CPU running at full speed5757+5858+ READING & 0x10 = 0x10: software event (see control:1)5959+ READING & 0x10 = 0x00: no software event6060+6161+ READING & 0x08 = 0x08: watchdog event (see wdog:2)6262+ READING & 0x08 = 0x00: no watchdog event6363+6464+ READING & 0x02 = 0x02: thermal event (see temp*:1)6565+ READING & 0x02 = 0x00: no thermal event6666+6767+ READING & 0x01 = 0x01: fan event (see fan*:1)6868+ READING & 0x01 = 0x00: no fan event6969+7070+ READING & 0x13 ! 0x00: ALERT LED is flashing7171+7272+* control7373+ READING & 0x01 = 0x01: software event7474+ READING & 0x01 = 0x00: no software event7575+7676+ WRITING & 0x01 = 0x01: set software event7777+ WRITING & 0x01 = 0x00: clear software event7878+7979+* watchdog_control8080+ READING & 0x80 = 0x80: power off on watchdog event while thermal event8181+ READING & 0x80 = 0x00: watchdog power off disabled (just system reset enabled)8282+8383+ READING & 0x40 = 0x40: watchdog timebase 60 seconds (see also wdog:1)8484+ READING & 0x40 = 0x00: watchdog timebase 2 seconds8585+8686+ READING & 0x10 = 0x10: watchdog enabled8787+ READING & 0x10 = 0x00: watchdog disabled8888+8989+ WRITING & 0x80 = 0x80: enable "power off on watchdog event while thermal event"9090+ WRITING & 0x80 = 0x00: disable "power off on watchdog event while thermal event"9191+9292+ WRITING & 0x40 = 0x40: set watchdog timebase to 60 seconds9393+ WRITING & 0x40 = 0x00: set watchdog timebase to 2 seconds9494+9595+ WRITING & 0x20 = 0x20: disable watchdog9696+9797+ WRITING & 0x10 = 0x10: enable watchdog / restart watchdog time9898+9999+* watchdog_state100100+ READING & 0x02 = 0x02: watchdog system reset occurred101101+ READING & 0x02 = 0x00: no watchdog system reset occurred102102+103103+ WRITING & 0x02 = 0x02: clear watchdog event104104+105105+* watchdog_preset106106+ READING & 0xff = 0x??: configured watch dog time in units (see wdog:3 0x40)107107+108108+ WRITING & 0xff = 0x??: configure watch dog time in units109109+110110+* in* (0: +5V, 1: +12V, 2: onboard 3V battery)111111+ READING: actual voltage value112112+113113+* temp*_status (1: CPU sensor, 2: onboard sensor, 3: auxiliary sensor)114114+ READING & 0x02 = 0x02: thermal event (overtemperature)115115+ READING & 0x02 = 0x00: no thermal event116116+117117+ READING & 0x01 = 0x01: sensor is working118118+ READING & 0x01 = 0x00: sensor is faulty119119+120120+ WRITING & 0x02 = 0x02: clear thermal event121121+122122+* temp*_input (1: CPU sensor, 2: onboard sensor, 3: auxiliary sensor)123123+ READING: actual temperature value124124+125125+* fan*_status (1: power supply fan, 2: CPU fan, 3: auxiliary fan)126126+ READING & 0x04 = 0x04: fan event (fan fault)127127+ READING & 0x04 = 0x00: no fan event128128+129129+ WRITING & 0x04 = 0x04: clear fan event130130+131131+* fan*_div (1: power supply fan, 2: CPU fan, 3: auxiliary fan)132132+ Divisors 2,4 and 8 are supported, both for reading and writing133133+134134+* fan*_pwm (1: power supply fan, 2: CPU fan, 3: auxiliary fan)135135+ READING & 0xff = 0x00: fan may be switched off136136+ READING & 0xff = 0x01: fan must run at least at minimum speed (supply: 6V)137137+ READING & 0xff = 0xff: fan must run at maximum speed (supply: 12V)138138+ READING & 0xff = 0x??: fan must run at least at given speed (supply: 6V..12V)139139+140140+ WRITING & 0xff = 0x00: fan may be switched off141141+ WRITING & 0xff = 0x01: fan must run at least at minimum speed (supply: 6V)142142+ WRITING & 0xff = 0xff: fan must run at maximum speed (supply: 12V)143143+ WRITING & 0xff = 0x??: fan must run at least at given speed (supply: 6V..12V)144144+145145+* fan*_input (1: power supply fan, 2: CPU fan, 3: auxiliary fan)146146+ READING: actual RPM value147147+148148+149149+Limitations150150+-----------151151+152152+* Measuring fan speed153153+It seems that the chip counts "ripples" (typical fans produce 2 ripples per154154+rotation while VERAX fans produce 18) in a 9-bit register. This register is155155+read out every second, then the ripple prescaler (2, 4 or 8) is applied and156156+the result is stored in the 8 bit output register. Due to the limitation of157157+the counting register to 9 bits, it is impossible to measure a VERAX fan158158+properly (even with a prescaler of 8). At its maximum speed of 3500 RPM the159159+fan produces 1080 ripples per second which causes the counting register to160160+overflow twice, leading to only 186 RPM.161161+162162+* Measuring input voltages163163+in2 ("battery") reports the voltage of the onboard lithium battery and not164164++3.3V from the power supply.165165+166166+* Undocumented features167167+Fujitsu-Siemens Computers has not documented all features of the chip so168168+far. Their software, System Guard, shows that there are a still some169169+features which cannot be controlled by this implementation.
+74
Documentation/i2c/chips/gl518sm
···11+Kernel driver gl518sm22+=====================33+44+Supported chips:55+ * Genesys Logic GL518SM release 0x0066+ Prefix: 'gl518sm'77+ Addresses scanned: I2C 0x2c and 0x2d88+ Datasheet: http://www.genesyslogic.com/pdf99+ * Genesys Logic GL518SM release 0x801010+ Prefix: 'gl518sm'1111+ Addresses scanned: I2C 0x2c and 0x2d1212+ Datasheet: http://www.genesyslogic.com/pdf1313+1414+Authors:1515+ Frodo Looijaard <frodol@dds.nl>,1616+ Ky�sti M�lkki <kmalkki@cc.hut.fi>1717+ Hong-Gunn Chew <hglinux@gunnet.org>1818+ Jean Delvare <khali@linux-fr.org>1919+2020+Description2121+-----------2222+2323+IMPORTANT:2424+2525+For the revision 0x00 chip, the in0, in1, and in2 values (+5V, +3V,2626+and +12V) CANNOT be read. This is a limitation of the chip, not the driver.2727+2828+This driver supports the Genesys Logic GL518SM chip. There are at least2929+two revision of this chip, which we call revision 0x00 and 0x80. Revision3030+0x80 chips support the reading of all voltages and revision 0x00 only3131+for VIN3.3232+3333+The GL518SM implements one temperature sensor, two fan rotation speed3434+sensors, and four voltage sensors. It can report alarms through the3535+computer speakers.3636+3737+Temperatures are measured in degrees Celsius. An alarm goes off while the3838+temperature is above the over temperature limit, and has not yet dropped3939+below the hysteresis limit. The alarm always reflects the current4040+situation. Measurements are guaranteed between -10 degrees and +1104141+degrees, with a accuracy of +/-3 degrees.4242+4343+Rotation speeds are reported in RPM (rotations per minute). An alarm is4444+triggered if the rotation speed has dropped below a programmable limit. In4545+case when you have selected to turn fan1 off, no fan1 alarm is triggered.4646+4747+Fan readings can be divided by a programmable divider (1, 2, 4 or 8) to4848+give the readings more range or accuracy. Not all RPM values can4949+accurately be represented, so some rounding is done. With a divider5050+of 2, the lowest representable value is around 1900 RPM.5151+5252+Voltage sensors (also known as VIN sensors) report their values in volts.5353+An alarm is triggered if the voltage has crossed a programmable minimum or5454+maximum limit. Note that minimum in this case always means 'closest to5555+zero'; this is important for negative voltage measurements. The VDD input5656+measures voltages between 0.000 and 5.865 volt, with a resolution of 0.0235757+volt. The other inputs measure voltages between 0.000 and 4.845 volt, with5858+a resolution of 0.019 volt. Note that revision 0x00 chips do not support5959+reading the current voltage of any input except for VIN3; limit setting and6060+alarms work fine, though.6161+6262+When an alarm is triggered, you can be warned by a beeping signal through your6363+computer speaker. It is possible to enable all beeping globally, or only the6464+beeping for some alarms.6565+6666+If an alarm triggers, it will remain triggered until the hardware register6767+is read at least once (except for temperature alarms). This means that the6868+cause for the alarm may already have disappeared! Note that in the current6969+implementation, all hardware registers are read whenever any data is read7070+(unless it is less than 1.5 seconds since the last update). This means that7171+you can easily miss once-only alarms.7272+7373+The GL518SM only updates its values each 1.5 seconds; reading it more often7474+will do no harm, but will return 'old' values.
+96
Documentation/i2c/chips/it87
···11+Kernel driver it8722+==================33+44+Supported chips:55+ * IT8705F66+ Prefix: 'it87'77+ Addresses scanned: from Super I/O config space, or default ISA 0x290 (8 I/O ports)88+ Datasheet: Publicly available at the ITE website99+ http://www.ite.com.tw/1010+ * IT8712F1111+ Prefix: 'it8712'1212+ Addresses scanned: I2C 0x28 - 0x2f1313+ from Super I/O config space, or default ISA 0x290 (8 I/O ports)1414+ Datasheet: Publicly available at the ITE website1515+ http://www.ite.com.tw/1616+ * SiS950 [clone of IT8705F]1717+ Prefix: 'sis950'1818+ Addresses scanned: from Super I/O config space, or default ISA 0x290 (8 I/O ports)1919+ Datasheet: No longer be available2020+2121+Author: Christophe Gauthron <chrisg@0-in.com>2222+2323+2424+Module Parameters2525+-----------------2626+2727+* update_vbat: int2828+2929+ 0 if vbat should report power on value, 1 if vbat should be updated after3030+ each read. Default is 0. On some boards the battery voltage is provided3131+ by either the battery or the onboard power supply. Only the first reading3232+ at power on will be the actual battery voltage (which the chip does3333+ automatically). On other boards the battery voltage is always fed to3434+ the chip so can be read at any time. Excessive reading may decrease3535+ battery life but no information is given in the datasheet.3636+3737+* fix_pwm_polarity int3838+3939+ Force PWM polarity to active high (DANGEROUS). Some chips are4040+ misconfigured by BIOS - PWM values would be inverted. This option tries4141+ to fix this. Please contact your BIOS manufacturer and ask him for fix.4242+4343+Description4444+-----------4545+4646+This driver implements support for the IT8705F, IT8712F and SiS950 chips.4747+4848+This driver also supports IT8712F, which adds SMBus access, and a VID4949+input, used to report the Vcore voltage of the Pentium processor.5050+The IT8712F additionally features VID inputs.5151+5252+These chips are 'Super I/O chips', supporting floppy disks, infrared ports,5353+joysticks and other miscellaneous stuff. For hardware monitoring, they5454+include an 'environment controller' with 3 temperature sensors, 3 fan5555+rotation speed sensors, 8 voltage sensors, and associated alarms.5656+5757+Temperatures are measured in degrees Celsius. An alarm is triggered once5858+when the Overtemperature Shutdown limit is crossed.5959+6060+Fan rotation speeds are reported in RPM (rotations per minute). An alarm is6161+triggered if the rotation speed has dropped below a programmable limit. Fan6262+readings can be divided by a programmable divider (1, 2, 4 or 8) to give the6363+readings more range or accuracy. Not all RPM values can accurately be6464+represented, so some rounding is done. With a divider of 2, the lowest6565+representable value is around 2600 RPM.6666+6767+Voltage sensors (also known as IN sensors) report their values in volts. An6868+alarm is triggered if the voltage has crossed a programmable minimum or6969+maximum limit. Note that minimum in this case always means 'closest to7070+zero'; this is important for negative voltage measurements. All voltage7171+inputs can measure voltages between 0 and 4.08 volts, with a resolution of7272+0.016 volt. The battery voltage in8 does not have limit registers.7373+7474+The VID lines (IT8712F only) encode the core voltage value: the voltage7575+level your processor should work with. This is hardcoded by the mainboard7676+and/or processor itself. It is a value in volts.7777+7878+If an alarm triggers, it will remain triggered until the hardware register7979+is read at least once. This means that the cause for the alarm may already8080+have disappeared! Note that in the current implementation, all hardware8181+registers are read whenever any data is read (unless it is less than 1.58282+seconds since the last update). This means that you can easily miss8383+once-only alarms.8484+8585+The IT87xx only updates its values each 1.5 seconds; reading it more often8686+will do no harm, but will return 'old' values.8787+8888+To change sensor N to a thermistor, 'echo 2 > tempN_type' where N is 1, 2,8989+or 3. To change sensor N to a thermal diode, 'echo 3 > tempN_type'.9090+Give 0 for unused sensor. Any other value is invalid. To configure this at9191+startup, consult lm_sensors's /etc/sensors.conf. (2 = thermistor;9292+3 = thermal diode)9393+9494+The fan speed control features are limited to manual PWM mode. Automatic9595+"Smart Guardian" mode control handling is not implemented. However9696+if you want to go for "manual mode" just write 1 to pwmN_enable.
+57
Documentation/i2c/chips/lm63
···11+Kernel driver lm6322+==================33+44+Supported chips:55+ * National Semiconductor LM6366+ Prefix: 'lm63'77+ Addresses scanned: I2C 0x4c88+ Datasheet: Publicly available at the National Semiconductor website99+ http://www.national.com/pf/LM/LM63.html1010+1111+Author: Jean Delvare <khali@linux-fr.org>1212+1313+Thanks go to Tyan and especially Alex Buckingham for setting up a remote1414+access to their S4882 test platform for this driver.1515+ http://www.tyan.com/1616+1717+Description1818+-----------1919+2020+The LM63 is a digital temperature sensor with integrated fan monitoring2121+and control.2222+2323+The LM63 is basically an LM86 with fan speed monitoring and control2424+capabilities added. It misses some of the LM86 features though:2525+ - No low limit for local temperature.2626+ - No critical limit for local temperature.2727+ - Critical limit for remote temperature can be changed only once. We2828+ will consider that the critical limit is read-only.2929+3030+The datasheet isn't very clear about what the tachometer reading is.3131+3232+An explanation from National Semiconductor: The two lower bits of the read3333+value have to be masked out. The value is still 16 bit in width.3434+3535+All temperature values are given in degrees Celsius. Resolution is 1.03636+degree for the local temperature, 0.125 degree for the remote temperature.3737+3838+The fan speed is measured using a tachometer. Contrary to most chips which3939+store the value in an 8-bit register and have a selectable clock divider4040+to make sure that the result will fit in the register, the LM63 uses 16-bit4141+value for measuring the speed of the fan. It can measure fan speeds down to4242+83 RPM, at least in theory.4343+4444+Note that the pin used for fan monitoring is shared with an alert out4545+function. Depending on how the board designer wanted to use the chip, fan4646+speed monitoring will or will not be possible. The proper chip configuration4747+is left to the BIOS, and the driver will blindly trust it.4848+4949+A PWM output can be used to control the speed of the fan. The LM63 has two5050+PWM modes: manual and automatic. Automatic mode is not fully implemented yet5151+(you cannot define your custom PWM/temperature curve), and mode change isn't5252+supported either.5353+5454+The lm63 driver will not update its values more frequently than every5555+second; reading them more often will do no harm, but will return 'old'5656+values.5757+
+65
Documentation/i2c/chips/lm75
···11+Kernel driver lm7522+==================33+44+Supported chips:55+ * National Semiconductor LM7566+ Prefix: 'lm75'77+ Addresses scanned: I2C 0x48 - 0x4f88+ Datasheet: Publicly available at the National Semiconductor website99+ http://www.national.com/1010+ * Dallas Semiconductor DS751111+ Prefix: 'lm75'1212+ Addresses scanned: I2C 0x48 - 0x4f1313+ Datasheet: Publicly available at the Dallas Semiconductor website1414+ http://www.maxim-ic.com/1515+ * Dallas Semiconductor DS17751616+ Prefix: 'lm75'1717+ Addresses scanned: I2C 0x48 - 0x4f1818+ Datasheet: Publicly available at the Dallas Semiconductor website1919+ http://www.maxim-ic.com/2020+ * Maxim MAX6625, MAX66262121+ Prefix: 'lm75'2222+ Addresses scanned: I2C 0x48 - 0x4b2323+ Datasheet: Publicly available at the Maxim website2424+ http://www.maxim-ic.com/2525+ * Microchip (TelCom) TCN752626+ Prefix: 'lm75'2727+ Addresses scanned: I2C 0x48 - 0x4f2828+ Datasheet: Publicly available at the Microchip website2929+ http://www.microchip.com/3030+3131+Author: Frodo Looijaard <frodol@dds.nl>3232+3333+Description3434+-----------3535+3636+The LM75 implements one temperature sensor. Limits can be set through the3737+Overtemperature Shutdown register and Hysteresis register. Each value can be3838+set and read to half-degree accuracy.3939+An alarm is issued (usually to a connected LM78) when the temperature4040+gets higher then the Overtemperature Shutdown value; it stays on until4141+the temperature falls below the Hysteresis value.4242+All temperatures are in degrees Celsius, and are guaranteed within a4343+range of -55 to +125 degrees.4444+4545+The LM75 only updates its values each 1.5 seconds; reading it more often4646+will do no harm, but will return 'old' values.4747+4848+The LM75 is usually used in combination with LM78-like chips, to measure4949+the temperature of the processor(s).5050+5151+The DS75, DS1775, MAX6625, and MAX6626 are supported as well.5252+They are not distinguished from an LM75. While most of these chips5353+have three additional bits of accuracy (12 vs. 9 for the LM75),5454+the additional bits are not supported. Not only that, but these chips will5555+not be detected if not in 9-bit precision mode (use the force parameter if5656+needed).5757+5858+The TCN75 is supported as well, and is not distinguished from an LM75.5959+6060+The LM75 is essentially an industry standard; there may be other6161+LM75 clones not listed here, with or without various enhancements,6262+that are supported.6363+6464+The LM77 is not supported, contrary to what we pretended for a long time.6565+Both chips are simply not compatible, value encoding differs.
+22
Documentation/i2c/chips/lm77
···11+Kernel driver lm7722+==================33+44+Supported chips:55+ * National Semiconductor LM7766+ Prefix: 'lm77'77+ Addresses scanned: I2C 0x48 - 0x4b88+ Datasheet: Publicly available at the National Semiconductor website99+ http://www.national.com/1010+1111+Author: Andras BALI <drewie@freemail.hu>1212+1313+Description1414+-----------1515+1616+The LM77 implements one temperature sensor. The temperature1717+sensor incorporates a band-gap type temperature sensor,1818+10-bit ADC, and a digital comparator with user-programmable upper1919+and lower limit values.2020+2121+Limits can be set through the Overtemperature Shutdown register and2222+Hysteresis register.
+82
Documentation/i2c/chips/lm78
···11+Kernel driver lm7822+==================33+44+Supported chips:55+ * National Semiconductor LM7866+ Prefix: 'lm78'77+ Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)88+ Datasheet: Publicly available at the National Semiconductor website99+ http://www.national.com/1010+ * National Semiconductor LM78-J1111+ Prefix: 'lm78-j'1212+ Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)1313+ Datasheet: Publicly available at the National Semiconductor website1414+ http://www.national.com/1515+ * National Semiconductor LM791616+ Prefix: 'lm79'1717+ Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)1818+ Datasheet: Publicly available at the National Semiconductor website1919+ http://www.national.com/2020+2121+Author: Frodo Looijaard <frodol@dds.nl>2222+2323+Description2424+-----------2525+2626+This driver implements support for the National Semiconductor LM78, LM78-J2727+and LM79. They are described as 'Microprocessor System Hardware Monitors'.2828+2929+There is almost no difference between the three supported chips. Functionally,3030+the LM78 and LM78-J are exactly identical. The LM79 has one more VID line,3131+which is used to report the lower voltages newer Pentium processors use.3232+From here on, LM7* means either of these three types.3333+3434+The LM7* implements one temperature sensor, three fan rotation speed sensors,3535+seven voltage sensors, VID lines, alarms, and some miscellaneous stuff.3636+3737+Temperatures are measured in degrees Celsius. An alarm is triggered once3838+when the Overtemperature Shutdown limit is crossed; it is triggered again3939+as soon as it drops below the Hysteresis value. A more useful behavior4040+can be found by setting the Hysteresis value to +127 degrees Celsius; in4141+this case, alarms are issued during all the time when the actual temperature4242+is above the Overtemperature Shutdown value. Measurements are guaranteed4343+between -55 and +125 degrees, with a resolution of 1 degree.4444+4545+Fan rotation speeds are reported in RPM (rotations per minute). An alarm is4646+triggered if the rotation speed has dropped below a programmable limit. Fan4747+readings can be divided by a programmable divider (1, 2, 4 or 8) to give4848+the readings more range or accuracy. Not all RPM values can accurately be4949+represented, so some rounding is done. With a divider of 2, the lowest5050+representable value is around 2600 RPM.5151+5252+Voltage sensors (also known as IN sensors) report their values in volts.5353+An alarm is triggered if the voltage has crossed a programmable minimum5454+or maximum limit. Note that minimum in this case always means 'closest to5555+zero'; this is important for negative voltage measurements. All voltage5656+inputs can measure voltages between 0 and 4.08 volts, with a resolution5757+of 0.016 volt.5858+5959+The VID lines encode the core voltage value: the voltage level your processor6060+should work with. This is hardcoded by the mainboard and/or processor itself.6161+It is a value in volts. When it is unconnected, you will often find the6262+value 3.50 V here.6363+6464+In addition to the alarms described above, there are a couple of additional6565+ones. There is a BTI alarm, which gets triggered when an external chip has6666+crossed its limits. Usually, this is connected to all LM75 chips; if at6767+least one crosses its limits, this bit gets set. The CHAS alarm triggers6868+if your computer case is open. The FIFO alarms should never trigger; it6969+indicates an internal error. The SMI_IN alarm indicates some other chip7070+has triggered an SMI interrupt. As we do not use SMI interrupts at all,7171+this condition usually indicates there is a problem with some other7272+device.7373+7474+If an alarm triggers, it will remain triggered until the hardware register7575+is read at least once. This means that the cause for the alarm may7676+already have disappeared! Note that in the current implementation, all7777+hardware registers are read whenever any data is read (unless it is less7878+than 1.5 seconds since the last update). This means that you can easily7979+miss once-only alarms.8080+8181+The LM7* only updates its values each 1.5 seconds; reading it more often8282+will do no harm, but will return 'old' values.
+56
Documentation/i2c/chips/lm80
···11+Kernel driver lm8022+==================33+44+Supported chips:55+ * National Semiconductor LM8066+ Prefix: 'lm80'77+ Addresses scanned: I2C 0x28 - 0x2f88+ Datasheet: Publicly available at the National Semiconductor website99+ http://www.national.com/1010+1111+Authors:1212+ Frodo Looijaard <frodol@dds.nl>,1313+ Philip Edelbrock <phil@netroedge.com>1414+1515+Description1616+-----------1717+1818+This driver implements support for the National Semiconductor LM80.1919+It is described as a 'Serial Interface ACPI-Compatible Microprocessor2020+System Hardware Monitor'.2121+2222+The LM80 implements one temperature sensor, two fan rotation speed sensors,2323+seven voltage sensors, alarms, and some miscellaneous stuff.2424+2525+Temperatures are measured in degrees Celsius. There are two sets of limits2626+which operate independently. When the HOT Temperature Limit is crossed,2727+this will cause an alarm that will be reasserted until the temperature2828+drops below the HOT Hysteresis. The Overtemperature Shutdown (OS) limits2929+should work in the same way (but this must be checked; the datasheet3030+is unclear about this). Measurements are guaranteed between -55 and3131++125 degrees. The current temperature measurement has a resolution of3232+0.0625 degrees; the limits have a resolution of 1 degree.3333+3434+Fan rotation speeds are reported in RPM (rotations per minute). An alarm is3535+triggered if the rotation speed has dropped below a programmable limit. Fan3636+readings can be divided by a programmable divider (1, 2, 4 or 8) to give3737+the readings more range or accuracy. Not all RPM values can accurately be3838+represented, so some rounding is done. With a divider of 2, the lowest3939+representable value is around 2600 RPM.4040+4141+Voltage sensors (also known as IN sensors) report their values in volts.4242+An alarm is triggered if the voltage has crossed a programmable minimum4343+or maximum limit. Note that minimum in this case always means 'closest to4444+zero'; this is important for negative voltage measurements. All voltage4545+inputs can measure voltages between 0 and 2.55 volts, with a resolution4646+of 0.01 volt.4747+4848+If an alarm triggers, it will remain triggered until the hardware register4949+is read at least once. This means that the cause for the alarm may5050+already have disappeared! Note that in the current implementation, all5151+hardware registers are read whenever any data is read (unless it is less5252+than 2.0 seconds since the last update). This means that you can easily5353+miss once-only alarms.5454+5555+The LM80 only updates its values each 1.5 seconds; reading it more often5656+will do no harm, but will return 'old' values.
+76
Documentation/i2c/chips/lm83
···11+Kernel driver lm8322+==================33+44+Supported chips:55+ * National Semiconductor LM8366+ Prefix: 'lm83'77+ Addresses scanned: I2C 0x18 - 0x1a, 0x29 - 0x2b, 0x4c - 0x4e88+ Datasheet: Publicly available at the National Semiconductor website99+ http://www.national.com/pf/LM/LM83.html1010+1111+1212+Author: Jean Delvare <khali@linux-fr.org>1313+1414+Description1515+-----------1616+1717+The LM83 is a digital temperature sensor. It senses its own temperature as1818+well as the temperature of up to three external diodes. It is compatible1919+with many other devices such as the LM84 and all other ADM1021 clones.2020+The main difference between the LM83 and the LM84 in that the later can2121+only sense the temperature of one external diode.2222+2323+Using the adm1021 driver for a LM83 should work, but only two temperatures2424+will be reported instead of four.2525+2626+The LM83 is only found on a handful of motherboards. Both a confirmed2727+list and an unconfirmed list follow. If you can confirm or infirm the2828+fact that any of these motherboards do actually have an LM83, please2929+contact us. Note that the LM90 can easily be misdetected as a LM83.3030+3131+Confirmed motherboards:3232+ SBS P0143333+3434+Unconfirmed motherboards:3535+ Gigabyte GA-8IK11003636+ Iwill MPX23737+ Soltek SL-75DRV53838+3939+The driver has been successfully tested by Magnus Forsstr�m, who I'd4040+like to thank here. More testers will be of course welcome.4141+4242+The fact that the LM83 is only scarcely used can be easily explained.4343+Most motherboards come with more than just temperature sensors for4444+health monitoring. They also have voltage and fan rotation speed4545+sensors. This means that temperature-only chips are usually used as4646+secondary chips coupled with another chip such as an IT8705F or similar4747+chip, which provides more features. Since systems usually need three4848+temperature sensors (motherboard, processor, power supply) and primary4949+chips provide some temperature sensors, the secondary chip, if needed,5050+won't have to handle more than two temperatures. Thus, ADM1021 clones5151+are sufficient, and there is no need for a four temperatures sensor5252+chip such as the LM83. The only case where using an LM83 would make5353+sense is on SMP systems, such as the above-mentioned Iwill MPX2,5454+because you want an additional temperature sensor for each additional5555+CPU.5656+5757+On the SBS P014, this is different, since the LM83 is the only hardware5858+monitoring chipset. One temperature sensor is used for the motherboard5959+(actually measuring the LM83's own temperature), one is used for the6060+CPU. The two other sensors must be used to measure the temperature of6161+two other points of the motherboard. We suspect these points to be the6262+north and south bridges, but this couldn't be confirmed.6363+6464+All temperature values are given in degrees Celsius. Local temperature6565+is given within a range of 0 to +85 degrees. Remote temperatures are6666+given within a range of 0 to +125 degrees. Resolution is 1.0 degree,6767+accuracy is guaranteed to 3.0 degrees (see the datasheet for more6868+details).6969+7070+Each sensor has its own high limit, but the critical limit is common to7171+all four sensors. There is no hysteresis mechanism as found on most7272+recent temperature sensors.7373+7474+The lm83 driver will not update its values more frequently than every7575+other second; reading them more often will do no harm, but will return7676+'old' values.
+221
Documentation/i2c/chips/lm85
···11+Kernel driver lm8522+==================33+44+Supported chips:55+ * National Semiconductor LM85 (B and C versions)66+ Prefix: 'lm85'77+ Addresses scanned: I2C 0x2c, 0x2d, 0x2e88+ Datasheet: http://www.national.com/pf/LM/LM85.html99+ * Analog Devices ADM10271010+ Prefix: 'adm1027'1111+ Addresses scanned: I2C 0x2c, 0x2d, 0x2e1212+ Datasheet: http://www.analog.com/en/prod/0,,766_825_ADM1027,00.html1313+ * Analog Devices ADT74631414+ Prefix: 'adt7463'1515+ Addresses scanned: I2C 0x2c, 0x2d, 0x2e1616+ Datasheet: http://www.analog.com/en/prod/0,,766_825_ADT7463,00.html1717+ * SMSC EMC6D100, SMSC EMC6D1011818+ Prefix: 'emc6d100'1919+ Addresses scanned: I2C 0x2c, 0x2d, 0x2e2020+ Datasheet: http://www.smsc.com/main/tools/discontinued/6d100.pdf2121+ * SMSC EMC6D1022222+ Prefix: 'emc6d102'2323+ Addresses scanned: I2C 0x2c, 0x2d, 0x2e2424+ Datasheet: http://www.smsc.com/main/catalog/emc6d102.html2525+2626+Authors:2727+ Philip Pokorny <ppokorny@penguincomputing.com>,2828+ Frodo Looijaard <frodol@dds.nl>,2929+ Richard Barrington <rich_b_nz@clear.net.nz>,3030+ Margit Schubert-While <margitsw@t-online.de>,3131+ Justin Thiessen <jthiessen@penguincomputing.com>3232+3333+Description3434+-----------3535+3636+This driver implements support for the National Semiconductor LM85 and3737+compatible chips including the Analog Devices ADM1027, ADT7463 and3838+SMSC EMC6D10x chips family.3939+4040+The LM85 uses the 2-wire interface compatible with the SMBUS 2.04141+specification. Using an analog to digital converter it measures three (3)4242+temperatures and five (5) voltages. It has four (4) 16-bit counters for4343+measuring fan speed. Five (5) digital inputs are provided for sampling the4444+VID signals from the processor to the VRM. Lastly, there are three (3) PWM4545+outputs that can be used to control fan speed.4646+4747+The voltage inputs have internal scaling resistors so that the following4848+voltage can be measured without external resistors:4949+5050+ 2.5V, 3.3V, 5V, 12V, and CPU core voltage (2.25V)5151+5252+The temperatures measured are one internal diode, and two remote diodes.5353+Remote 1 is generally the CPU temperature. These inputs are designed to5454+measure a thermal diode like the one in a Pentium 4 processor in a socket5555+423 or socket 478 package. They can also measure temperature using a5656+transistor like the 2N3904.5757+5858+A sophisticated control system for the PWM outputs is designed into the5959+LM85 that allows fan speed to be adjusted automatically based on any of the6060+three temperature sensors. Each PWM output is individually adjustable and6161+programmable. Once configured, the LM85 will adjust the PWM outputs in6262+response to the measured temperatures without further host intervention.6363+This feature can also be disabled for manual control of the PWM's.6464+6565+Each of the measured inputs (voltage, temperature, fan speed) has6666+corresponding high/low limit values. The LM85 will signal an ALARM if any6767+measured value exceeds either limit.6868+6969+The LM85 samples all inputs continuously. The lm85 driver will not read7070+the registers more often than once a second. Further, configuration data is7171+only read once each 5 minutes. There is twice as much config data as7272+measurements, so this would seem to be a worthwhile optimization.7373+7474+Special Features7575+----------------7676+7777+The LM85 has four fan speed monitoring modes. The ADM1027 has only two.7878+Both have special circuitry to compensate for PWM interactions with the7979+TACH signal from the fans. The ADM1027 can be configured to measure the8080+speed of a two wire fan, but the input conditioning circuitry is different8181+for 3-wire and 2-wire mode. For this reason, the 2-wire fan modes are not8282+exposed to user control. The BIOS should initialize them to the correct8383+mode. If you've designed your own ADM1027, you'll have to modify the8484+init_client function and add an insmod parameter to set this up.8585+8686+To smooth the response of fans to changes in temperature, the LM85 has an8787+optional filter for smoothing temperatures. The ADM1027 has the same8888+config option but uses it to rate limit the changes to fan speed instead.8989+9090+The ADM1027 and ADT7463 have a 10-bit ADC and can therefore measure9191+temperatures with 0.25 degC resolution. They also provide an offset to the9292+temperature readings that is automatically applied during measurement.9393+This offset can be used to zero out any errors due to traces and placement.9494+The documentation says that the offset is in 0.25 degC steps, but in9595+initial testing of the ADM1027 it was 1.00 degC steps. Analog Devices has9696+confirmed this "bug". The ADT7463 is reported to work as described in the9797+documentation. The current lm85 driver does not show the offset register.9898+9999+The ADT7463 has a THERM asserted counter. This counter has a 22.76ms100100+resolution and a range of 5.8 seconds. The driver implements a 32-bit101101+accumulator of the counter value to extend the range to over a year. The102102+counter will stay at it's max value until read.103103+104104+See the vendor datasheets for more information. There is application note105105+from National (AN-1260) with some additional information about the LM85.106106+The Analog Devices datasheet is very detailed and describes a procedure for107107+determining an optimal configuration for the automatic PWM control.108108+109109+The SMSC EMC6D100 & EMC6D101 monitor external voltages, temperatures, and110110+fan speeds. They use this monitoring capability to alert the system to out111111+of limit conditions and can automatically control the speeds of multiple112112+fans in a PC or embedded system. The EMC6D101, available in a 24-pin SSOP113113+package, and the EMC6D100, available in a 28-pin SSOP package, are designed114114+to be register compatible. The EMC6D100 offers all the features of the115115+EMC6D101 plus additional voltage monitoring and system control features.116116+Unfortunately it is not possible to distinguish between the package117117+versions on register level so these additional voltage inputs may read118118+zero. The EMC6D102 features addtional ADC bits thus extending precision119119+of voltage and temperature channels.120120+121121+122122+Hardware Configurations123123+-----------------------124124+125125+The LM85 can be jumpered for 3 different SMBus addresses. There are126126+no other hardware configuration options for the LM85.127127+128128+The lm85 driver detects both LM85B and LM85C revisions of the chip. See the129129+datasheet for a complete description of the differences. Other than130130+identifying the chip, the driver behaves no differently with regard to131131+these two chips. The LM85B is recommended for new designs.132132+133133+The ADM1027 and ADT7463 chips have an optional SMBALERT output that can be134134+used to signal the chipset in case a limit is exceeded or the temperature135135+sensors fail. Individual sensor interrupts can be masked so they won't136136+trigger SMBALERT. The SMBALERT output if configured replaces one of the other137137+functions (PWM2 or IN0). This functionality is not implemented in current138138+driver.139139+140140+The ADT7463 also has an optional THERM output/input which can be connected141141+to the processor PROC_HOT output. If available, the autofan control142142+dynamic Tmin feature can be enabled to keep the system temperature within143143+spec (just?!) with the least possible fan noise.144144+145145+Configuration Notes146146+-------------------147147+148148+Besides standard interfaces driver adds following:149149+150150+* Temperatures and Zones151151+152152+Each temperature sensor is associated with a Zone. There are three153153+sensors and therefore three zones (# 1, 2 and 3). Each zone has the following154154+temperature configuration points:155155+156156+* temp#_auto_temp_off - temperature below which fans should be off or spinning very low.157157+* temp#_auto_temp_min - temperature over which fans start to spin.158158+* temp#_auto_temp_max - temperature when fans spin at full speed.159159+* temp#_auto_temp_crit - temperature when all fans will run full speed.160160+161161+* PWM Control162162+163163+There are three PWM outputs. The LM85 datasheet suggests that the164164+pwm3 output control both fan3 and fan4. Each PWM can be individually165165+configured and assigned to a zone for it's control value. Each PWM can be166166+configured individually according to the following options.167167+168168+* pwm#_auto_pwm_min - this specifies the PWM value for temp#_auto_temp_off169169+ temperature. (PWM value from 0 to 255)170170+171171+* pwm#_auto_pwm_freq - select base frequency of PWM output. You can select172172+ in range of 10.0 to 94.0 Hz in .1 Hz units.173173+ (Values 100 to 940).174174+175175+The pwm#_auto_pwm_freq can be set to one of the following 8 values. Setting the176176+frequency to a value not on this list, will result in the next higher frequency177177+being selected. The actual device frequency may vary slightly from this178178+specification as designed by the manufacturer. Consult the datasheet for more179179+details. (PWM Frequency values: 100, 150, 230, 300, 380, 470, 620, 940)180180+181181+* pwm#_auto_pwm_minctl - this flags selects for temp#_auto_temp_off temperature182182+ the bahaviour of fans. Write 1 to let fans spinning at183183+ pwm#_auto_pwm_min or write 0 to let them off.184184+185185+NOTE: It has been reported that there is a bug in the LM85 that causes the flag186186+to be associated with the zones not the PWMs. This contradicts all the187187+published documentation. Setting pwm#_min_ctl in this case actually affects all188188+PWMs controlled by zone '#'.189189+190190+* PWM Controlling Zone selection191191+192192+* pwm#_auto_channels - controls zone that is associated with PWM193193+194194+Configuration choices:195195+196196+ Value Meaning197197+ ------ ------------------------------------------------198198+ 1 Controlled by Zone 1199199+ 2 Controlled by Zone 2200200+ 3 Controlled by Zone 3201201+ 23 Controlled by higher temp of Zone 2 or 3202202+ 123 Controlled by highest temp of Zone 1, 2 or 3203203+ 0 PWM always 0% (off)204204+ -1 PWM always 100% (full on)205205+ -2 Manual control (write to 'pwm#' to set)206206+207207+The National LM85's have two vendor specific configuration208208+features. Tach. mode and Spinup Control. For more details on these,209209+see the LM85 datasheet or Application Note AN-1260.210210+211211+The Analog Devices ADM1027 has several vendor specific enhancements.212212+The number of pulses-per-rev of the fans can be set, Tach monitoring213213+can be optimized for PWM operation, and an offset can be applied to214214+the temperatures to compensate for systemic errors in the215215+measurements.216216+217217+In addition to the ADM1027 features, the ADT7463 also has Tmin control218218+and THERM asserted counts. Automatic Tmin control acts to adjust the219219+Tmin value to maintain the measured temperature sensor at a specified220220+temperature. There isn't much documentation on this feature in the221221+ADT7463 data sheet. This is not supported by current driver.
+73
Documentation/i2c/chips/lm87
···11+Kernel driver lm8722+==================33+44+Supported chips:55+ * National Semiconductor LM8766+ Prefix: 'lm87'77+ Addresses scanned: I2C 0x2c - 0x2f88+ Datasheet: http://www.national.com/pf/LM/LM87.html99+1010+Authors:1111+ Frodo Looijaard <frodol@dds.nl>,1212+ Philip Edelbrock <phil@netroedge.com>,1313+ Mark Studebaker <mdsxyz123@yahoo.com>,1414+ Stephen Rousset <stephen.rousset@rocketlogix.com>,1515+ Dan Eaton <dan.eaton@rocketlogix.com>,1616+ Jean Delvare <khali@linux-fr.org>,1717+ Original 2.6 port Jeff Oliver1818+1919+Description2020+-----------2121+2222+This driver implements support for the National Semiconductor LM87.2323+2424+The LM87 implements up to three temperature sensors, up to two fan2525+rotation speed sensors, up to seven voltage sensors, alarms, and some2626+miscellaneous stuff.2727+2828+Temperatures are measured in degrees Celsius. Each input has a high2929+and low alarm settings. A high limit produces an alarm when the value3030+goes above it, and an alarm is also produced when the value goes below3131+the low limit.3232+3333+Fan rotation speeds are reported in RPM (rotations per minute). An alarm is3434+triggered if the rotation speed has dropped below a programmable limit. Fan3535+readings can be divided by a programmable divider (1, 2, 4 or 8) to give3636+the readings more range or accuracy. Not all RPM values can accurately be3737+represented, so some rounding is done. With a divider of 2, the lowest3838+representable value is around 2600 RPM.3939+4040+Voltage sensors (also known as IN sensors) report their values in4141+volts. An alarm is triggered if the voltage has crossed a programmable4242+minimum or maximum limit. Note that minimum in this case always means4343+'closest to zero'; this is important for negative voltage measurements.4444+4545+If an alarm triggers, it will remain triggered until the hardware register4646+is read at least once. This means that the cause for the alarm may4747+already have disappeared! Note that in the current implementation, all4848+hardware registers are read whenever any data is read (unless it is less4949+than 1.0 seconds since the last update). This means that you can easily5050+miss once-only alarms.5151+5252+The lm87 driver only updates its values each 1.0 seconds; reading it more5353+often will do no harm, but will return 'old' values.5454+5555+5656+Hardware Configurations5757+-----------------------5858+5959+The LM87 has four pins which can serve one of two possible functions,6060+depending on the hardware configuration.6161+6262+Some functions share pins, so not all functions are available at the same6363+time. Which are depends on the hardware setup. This driver assumes that6464+the BIOS configured the chip correctly. In that respect, it differs from6565+the original driver (from lm_sensors for Linux 2.4), which would force the6666+LM87 to an arbitrary, compile-time chosen mode, regardless of the actual6767+chipset wiring.6868+6969+For reference, here is the list of exclusive functions:7070+ - in0+in5 (default) or temp37171+ - fan1 (default) or in67272+ - fan2 (default) or in77373+ - VID lines (default) or IRQ lines (not handled by this driver)
+121
Documentation/i2c/chips/lm90
···11+Kernel driver lm9022+==================33+44+Supported chips:55+ * National Semiconductor LM9066+ Prefix: 'lm90'77+ Addresses scanned: I2C 0x4c88+ Datasheet: Publicly available at the National Semiconductor website99+ http://www.national.com/pf/LM/LM90.html1010+ * National Semiconductor LM891111+ Prefix: 'lm99'1212+ Addresses scanned: I2C 0x4c and 0x4d1313+ Datasheet: Publicly available at the National Semiconductor website1414+ http://www.national.com/pf/LM/LM89.html1515+ * National Semiconductor LM991616+ Prefix: 'lm99'1717+ Addresses scanned: I2C 0x4c and 0x4d1818+ Datasheet: Publicly available at the National Semiconductor website1919+ http://www.national.com/pf/LM/LM99.html2020+ * National Semiconductor LM862121+ Prefix: 'lm86'2222+ Addresses scanned: I2C 0x4c2323+ Datasheet: Publicly available at the National Semiconductor website2424+ http://www.national.com/pf/LM/LM86.html2525+ * Analog Devices ADM10322626+ Prefix: 'adm1032'2727+ Addresses scanned: I2C 0x4c2828+ Datasheet: Publicly available at the Analog Devices website2929+ http://products.analog.com/products/info.asp?product=ADM10323030+ * Analog Devices ADT74613131+ Prefix: 'adt7461'3232+ Addresses scanned: I2C 0x4c3333+ Datasheet: Publicly available at the Analog Devices website3434+ http://products.analog.com/products/info.asp?product=ADT74613535+ Note: Only if in ADM1032 compatibility mode3636+ * Maxim MAX66573737+ Prefix: 'max6657'3838+ Addresses scanned: I2C 0x4c3939+ Datasheet: Publicly available at the Maxim website4040+ http://www.maxim-ic.com/quick_view2.cfm/qv_pk/25784141+ * Maxim MAX66584242+ Prefix: 'max6657'4343+ Addresses scanned: I2C 0x4c4444+ Datasheet: Publicly available at the Maxim website4545+ http://www.maxim-ic.com/quick_view2.cfm/qv_pk/25784646+ * Maxim MAX66594747+ Prefix: 'max6657'4848+ Addresses scanned: I2C 0x4c, 0x4d (unsupported 0x4e)4949+ Datasheet: Publicly available at the Maxim website5050+ http://www.maxim-ic.com/quick_view2.cfm/qv_pk/25785151+5252+5353+Author: Jean Delvare <khali@linux-fr.org>5454+5555+5656+Description5757+-----------5858+5959+The LM90 is a digital temperature sensor. It senses its own temperature as6060+well as the temperature of up to one external diode. It is compatible6161+with many other devices such as the LM86, the LM89, the LM99, the ADM1032,6262+the MAX6657, MAX6658 and the MAX6659 all of which are supported by this driver.6363+Note that there is no easy way to differentiate between the last three6464+variants. The extra address and features of the MAX6659 are not supported by6565+this driver. Additionally, the ADT7461 is supported if found in ADM10326666+compatibility mode.6767+6868+The specificity of this family of chipsets over the ADM1021/LM846969+family is that it features critical limits with hysteresis, and an7070+increased resolution of the remote temperature measurement.7171+7272+The different chipsets of the family are not strictly identical, although7373+very similar. This driver doesn't handle any specific feature for now,7474+but could if there ever was a need for it. For reference, here comes a7575+non-exhaustive list of specific features:7676+7777+LM90:7878+ * Filter and alert configuration register at 0xBF.7979+ * ALERT is triggered by temperatures over critical limits.8080+8181+LM86 and LM89:8282+ * Same as LM908383+ * Better external channel accuracy8484+8585+LM99:8686+ * Same as LM898787+ * External temperature shifted by 16 degrees down8888+8989+ADM1032:9090+ * Consecutive alert register at 0x22.9191+ * Conversion averaging.9292+ * Up to 64 conversions/s.9393+ * ALERT is triggered by open remote sensor.9494+9595+ADT74619696+ * Extended temperature range (breaks compatibility)9797+ * Lower resolution for remote temperature9898+9999+MAX6657 and MAX6658:100100+ * Remote sensor type selection101101+102102+MAX6659103103+ * Selectable address104104+ * Second critical temperature limit105105+ * Remote sensor type selection106106+107107+All temperature values are given in degrees Celsius. Resolution108108+is 1.0 degree for the local temperature, 0.125 degree for the remote109109+temperature.110110+111111+Each sensor has its own high and low limits, plus a critical limit.112112+Additionally, there is a relative hysteresis value common to both critical113113+values. To make life easier to user-space applications, two absolute values114114+are exported, one for each channel, but these values are of course linked.115115+Only the local hysteresis can be set from user-space, and the same delta116116+applies to the remote hysteresis.117117+118118+The lm90 driver will not update its values more frequently than every119119+other second; reading them more often will do no harm, but will return120120+'old' values.121121+
+37
Documentation/i2c/chips/lm92
···11+Kernel driver lm9222+==================33+44+Supported chips:55+ * National Semiconductor LM9266+ Prefix: 'lm92'77+ Addresses scanned: I2C 0x48 - 0x4b88+ Datasheet: http://www.national.com/pf/LM/LM92.html99+ * National Semiconductor LM761010+ Prefix: 'lm92'1111+ Addresses scanned: none, force parameter needed1212+ Datasheet: http://www.national.com/pf/LM/LM76.html1313+ * Maxim MAX6633/MAX6634/MAX66351414+ Prefix: 'lm92'1515+ Addresses scanned: I2C 0x48 - 0x4b1616+ MAX6633 with address in 0x40 - 0x47, 0x4c - 0x4f needs force parameter1717+ and MAX6634 with address in 0x4c - 0x4f needs force parameter1818+ Datasheet: http://www.maxim-ic.com/quick_view2.cfm/qv_pk/30741919+2020+Authors:2121+ Abraham van der Merwe <abraham@2d3d.co.za>2222+ Jean Delvare <khali@linux-fr.org>2323+2424+2525+Description2626+-----------2727+2828+This driver implements support for the National Semiconductor LM922929+temperature sensor.3030+3131+Each LM92 temperature sensor supports a single temperature sensor. There are3232+alarms for high, low, and critical thresholds. There's also an hysteresis to3333+control the thresholds for resetting alarms.3434+3535+Support was added later for the LM76 and Maxim MAX6633/MAX6634/MAX6635,3636+which are mostly compatible. They have not all been tested, so you3737+may need to use the force parameter.
+29
Documentation/i2c/chips/max1619
···11+Kernel driver max161922+=====================33+44+Supported chips:55+ * Maxim MAX161966+ Prefix: 'max1619'77+ Addresses scanned: I2C 0x18-0x1a, 0x29-0x2b, 0x4c-0x4e88+ Datasheet: Publicly available at the Maxim website99+ http://pdfserv.maxim-ic.com/en/ds/MAX1619.pdf1010+1111+Authors:1212+ Alexey Fisher <fishor@mail.ru>,1313+ Jean Delvare <khali@linux-fr.org>1414+1515+Description1616+-----------1717+1818+The MAX1619 is a digital temperature sensor. It senses its own temperature as1919+well as the temperature of up to one external diode.2020+2121+All temperature values are given in degrees Celsius. Resolution2222+is 1.0 degree for the local temperature and for the remote temperature.2323+2424+Only the external sensor has high and low limits.2525+2626+The max1619 driver will not update its values more frequently than every2727+other second; reading them more often will do no harm, but will return2828+'old' values.2929+
+54
Documentation/i2c/chips/max6875
···11+Kernel driver max687522+=====================33+44+Supported chips:55+ * Maxim max6874, max687566+ Prefixes: 'max6875'77+ Addresses scanned: 0x50, 0x5288+ Datasheets:99+ http://pdfserv.maxim-ic.com/en/ds/MAX6874-MAX6875.pdf1010+1111+Author: Ben Gardner <bgardner@wabtec.com>1212+1313+1414+Module Parameters1515+-----------------1616+1717+* allow_write int1818+ Set to non-zero to enable write permission:1919+ *0: Read only2020+ 1: Read and write2121+2222+2323+Description2424+-----------2525+2626+The MAXIM max6875 is a EEPROM-programmable power-supply sequencer/supervisor.2727+It provides timed outputs that can be used as a watchdog, if properly wired.2828+It also provides 512 bytes of user EEPROM.2929+3030+At reset, the max6875 reads the configuration eeprom into its configuration3131+registers. The chip then begins to operate according to the values in the3232+registers.3333+3434+See the datasheet for details on how to program the EEPROM.3535+3636+3737+Sysfs entries3838+-------------3939+4040+eeprom_user - 512 bytes of user-defined EEPROM space. Only writable if4141+ allow_write was set and register 0x43 is 0.4242+4343+eeprom_config - 70 bytes of config EEPROM. Note that changes will not get4444+ loaded into register space until a power cycle or device reset.4545+4646+reg_config - 70 bytes of register space. Any changes take affect immediately.4747+4848+4949+General Remarks5050+---------------5151+5252+A typical application will require that the EEPROMs be programmed once and5353+never altered afterwards.5454+
+189
Documentation/i2c/chips/pc87360
···11+Kernel driver pc8736022+=====================33+44+Supported chips:55+ * National Semiconductor PC87360, PC87363, PC87364, PC87365 and PC8736666+ Prefixes: 'pc87360', 'pc87363', 'pc87364', 'pc87365', 'pc87366'77+ Addresses scanned: none, address read from Super I/O config space88+ Datasheets:99+ http://www.national.com/pf/PC/PC87360.html1010+ http://www.national.com/pf/PC/PC87363.html1111+ http://www.national.com/pf/PC/PC87364.html1212+ http://www.national.com/pf/PC/PC87365.html1313+ http://www.national.com/pf/PC/PC87366.html1414+1515+Authors: Jean Delvare <khali@linux-fr.org>1616+1717+Thanks to Sandeep Mehta, Tonko de Rooy and Daniel Ceregatti for testing.1818+Thanks to Rudolf Marek for helping me investigate conversion issues.1919+2020+2121+Module Parameters2222+-----------------2323+2424+* init int2525+ Chip initialization level:2626+ 0: None2727+ *1: Forcibly enable internal voltage and temperature channels, except in92828+ 2: Forcibly enable all voltage and temperature channels, except in92929+ 3: Forcibly enable all voltage and temperature channels, including in93030+3131+Note that this parameter has no effect for the PC87360, PC87363 and PC873643232+chips.3333+3434+Also note that for the PC87366, initialization levels 2 and 3 don't enable3535+all temperature channels, because some of them share pins with each other,3636+so they can't be used at the same time.3737+3838+3939+Description4040+-----------4141+4242+The National Semiconductor PC87360 Super I/O chip contains monitoring and4343+PWM control circuitry for two fans. The PC87363 chip is similar, and the4444+PC87364 chip has monitoring and PWM control for a third fan.4545+4646+The National Semiconductor PC87365 and PC87366 Super I/O chips are complete4747+hardware monitoring chipsets, not only controlling and monitoring three fans,4848+but also monitoring eleven voltage inputs and two (PC87365) or up to four4949+(PC87366) temperatures.5050+5151+ Chip #vin #fan #pwm #temp devid5252+5353+ PC87360 - 2 2 - 0xE15454+ PC87363 - 2 2 - 0xE85555+ PC87364 - 3 3 - 0xE45656+ PC87365 11 3 3 2 0xE55757+ PC87366 11 3 3 3-4 0xE95858+5959+The driver assumes that no more than one chip is present, and one of the6060+standard Super I/O addresses is used (0x2E/0x2F or 0x4E/0x4F)6161+6262+Fan Monitoring6363+--------------6464+6565+Fan rotation speeds are reported in RPM (revolutions per minute). An alarm6666+is triggered if the rotation speed has dropped below a programmable limit.6767+A different alarm is triggered if the fan speed is too low to be measured.6868+6969+Fan readings are affected by a programmable clock divider, giving the7070+readings more range or accuracy. Usually, users have to learn how it works,7171+but this driver implements dynamic clock divider selection, so you don't7272+have to care no more.7373+7474+For reference, here are a few values about clock dividers:7575+7676+ slowest accuracy highest7777+ measurable around 3000 accurate7878+ divider speed (RPM) RPM (RPM) speed (RPM)7979+ 1 1882 18 69288080+ 2 941 37 48988181+ 4 470 74 34648282+ 8 235 150 24498383+8484+For the curious, here is how the values above were computed:8585+ * slowest measurable speed: clock/(255*divider)8686+ * accuracy around 3000 RPM: 3000^2/clock8787+ * highest accurate speed: sqrt(clock*100)8888+The clock speed for the PC87360 family is 480 kHz. I arbitrarily chose 1008989+RPM as the lowest acceptable accuracy.9090+9191+As mentioned above, you don't have to care about this no more.9292+9393+Note that not all RPM values can be represented, even when the best clock9494+divider is selected. This is not only true for the measured speeds, but9595+also for the programmable low limits, so don't be surprised if you try to9696+set, say, fan1_min to 2900 and it finally reads 2909.9797+9898+9999+Fan Control100100+-----------101101+102102+PWM (pulse width modulation) values range from 0 to 255, with 0 meaning103103+that the fan is stopped, and 255 meaning that the fan goes at full speed.104104+105105+Be extremely careful when changing PWM values. Low PWM values, even106106+non-zero, can stop the fan, which may cause irreversible damage to your107107+hardware if temperature increases too much. When changing PWM values, go108108+step by step and keep an eye on temperatures.109109+110110+One user reported problems with PWM. Changing PWM values would break fan111111+speed readings. No explanation nor fix could be found.112112+113113+114114+Temperature Monitoring115115+----------------------116116+117117+Temperatures are reported in degrees Celsius. Each temperature measured has118118+associated low, high and overtemperature limits, each of which triggers an119119+alarm when crossed.120120+121121+The first two temperature channels are external. The third one (PC87366122122+only) is internal.123123+124124+The PC87366 has three additional temperature channels, based on125125+thermistors (as opposed to thermal diodes for the first three temperature126126+channels). For technical reasons, these channels are held by the VLM127127+(voltage level monitor) logical device, not the TMS (temperature128128+measurement) one. As a consequence, these temperatures are exported as129129+voltages, and converted into temperatures in user-space.130130+131131+Note that these three additional channels share their pins with the132132+external thermal diode channels, so you (physically) can't use them all at133133+the same time. Although it should be possible to mix the two sensor types,134134+the documents from National Semiconductor suggest that motherboard135135+manufacturers should choose one type and stick to it. So you will more136136+likely have either channels 1 to 3 (thermal diodes) or 3 to 6 (internal137137+thermal diode, and thermistors).138138+139139+140140+Voltage Monitoring141141+------------------142142+143143+Voltages are reported relatively to a reference voltage, either internal or144144+external. Some of them (in7:Vsb, in8:Vdd and in10:AVdd) are divided by two145145+internally, you will have to compensate in sensors.conf. Others (in0 to in6)146146+are likely to be divided externally. The meaning of each of these inputs as147147+well as the values of the resistors used for division is left to the148148+motherboard manufacturers, so you will have to document yourself and edit149149+sensors.conf accordingly. National Semiconductor has a document with150150+recommended resistor values for some voltages, but this still leaves much151151+room for per motherboard specificities, unfortunately. Even worse,152152+motherboard manufacturers don't seem to care about National Semiconductor's153153+recommendations.154154+155155+Each voltage measured has associated low and high limits, each of which156156+triggers an alarm when crossed.157157+158158+When available, VID inputs are used to provide the nominal CPU Core voltage.159159+The driver will default to VRM 9.0, but this can be changed from user-space.160160+The chipsets can handle two sets of VID inputs (on dual-CPU systems), but161161+the driver will only export one for now. This may change later if there is162162+a need.163163+164164+165165+General Remarks166166+---------------167167+168168+If an alarm triggers, it will remain triggered until the hardware register169169+is read at least once. This means that the cause for the alarm may already170170+have disappeared! Note that all hardware registers are read whenever any171171+data is read (unless it is less than 2 seconds since the last update, in172172+which case cached values are returned instead). As a consequence, when173173+a once-only alarm triggers, it may take 2 seconds for it to show, and 2174174+more seconds for it to disappear.175175+176176+Monitoring of in9 isn't enabled at lower init levels (<3) because that177177+channel measures the battery voltage (Vbat). It is a known fact that178178+repeatedly sampling the battery voltage reduces its lifetime. National179179+Semiconductor smartly designed their chipset so that in9 is sampled only180180+once every 1024 sampling cycles (that is every 34 minutes at the default181181+sampling rate), so the effect is attenuated, but still present.182182+183183+184184+Limitations185185+-----------186186+187187+The datasheets suggests that some values (fan mins, fan dividers)188188+shouldn't be changed once the monitoring has started, but we ignore that189189+recommendation. We'll reconsider if it actually causes trouble.
+47
Documentation/i2c/chips/pca9539
···11+Kernel driver pca953922+=====================33+44+Supported chips:55+ * Philips PCA953966+ Prefix: 'pca9539'77+ Addresses scanned: 0x74 - 0x7788+ Datasheet:99+ http://www.semiconductors.philips.com/acrobat/datasheets/PCA9539_2.pdf1010+1111+Author: Ben Gardner <bgardner@wabtec.com>1212+1313+1414+Description1515+-----------1616+1717+The Philips PCA9539 is a 16 bit low power I/O device.1818+All 16 lines can be individually configured as an input or output.1919+The input sense can also be inverted.2020+The 16 lines are split between two bytes.2121+2222+2323+Sysfs entries2424+-------------2525+2626+Each is a byte that maps to the 8 I/O bits.2727+A '0' suffix is for bits 0-7, while '1' is for bits 8-15.2828+2929+input[01] - read the current value3030+output[01] - sets the output value3131+direction[01] - direction of each bit: 1=input, 0=output3232+invert[01] - toggle the input bit sense3333+3434+input reads the actual state of the line and is always available.3535+The direction defaults to input for all channels.3636+3737+3838+General Remarks3939+---------------4040+4141+Note that each output, direction, and invert entry controls 8 lines.4242+You should use the read, modify, write sequence.4343+For example. to set output bit 0 of 1.4444+ val=$(cat output0)4545+ val=$(( $val | 1 ))4646+ echo $val > output04747+
+69
Documentation/i2c/chips/pcf8574
···11+Kernel driver pcf857422+=====================33+44+Supported chips:55+ * Philips PCF857466+ Prefix: 'pcf8574'77+ Addresses scanned: I2C 0x20 - 0x2788+ Datasheet: Publicly available at the Philips Semiconductors website99+ http://www.semiconductors.philips.com/pip/PCF8574P.html1010+1111+ * Philips PCF8574A1212+ Prefix: 'pcf8574a'1313+ Addresses scanned: I2C 0x38 - 0x3f1414+ Datasheet: Publicly available at the Philips Semiconductors website1515+ http://www.semiconductors.philips.com/pip/PCF8574P.html1616+1717+Authors:1818+ Frodo Looijaard <frodol@dds.nl>,1919+ Philip Edelbrock <phil@netroedge.com>,2020+ Dan Eaton <dan.eaton@rocketlogix.com>,2121+ Aurelien Jarno <aurelien@aurel32.net>,2222+ Jean Delvare <khali@linux-fr.org>,2323+2424+2525+Description2626+-----------2727+The PCF8574(A) is an 8-bit I/O expander for the I2C bus produced by Philips2828+Semiconductors. It is designed to provide a byte I2C interface to up to 162929+separate devices (8 x PCF8574 and 8 x PCF8574A).3030+3131+This device consists of a quasi-bidirectional port. Each of the eight I/Os3232+can be independently used as an input or output. To setup an I/O as an3333+input, you have to write a 1 to the corresponding output.3434+3535+For more informations see the datasheet.3636+3737+3838+Accessing PCF8574(A) via /sys interface3939+-------------------------------------4040+4141+! Be careful !4242+The PCF8574(A) is plainly impossible to detect ! Stupid chip.4343+So every chip with address in the interval [20..27] and [38..3f] are4444+detected as PCF8574(A). If you have other chips in this address4545+range, the workaround is to load this module after the one4646+for your others chips.4747+4848+On detection (i.e. insmod, modprobe et al.), directories are being4949+created for each detected PCF8574(A):5050+5151+/sys/bus/i2c/devices/<0>-<1>/5252+where <0> is the bus the chip was detected on (e. g. i2c-0)5353+and <1> the chip address ([20..27] or [38..3f]):5454+5555+(example: /sys/bus/i2c/devices/1-0020/)5656+5757+Inside these directories, there are two files each:5858+read and write (and one file with chip name).5959+6060+The read file is read-only. Reading gives you the current I/O input6161+if the corresponding output is set as 1, otherwise the current output6262+value, that is to say 0.6363+6464+The write file is read/write. Writing a value outputs it on the I/O6565+port. Reading returns the last written value.6666+6767+On module initialization the chip is configured as eight inputs (all6868+outputs to 1), so you can connect any circuit to the PCF8574(A) without6969+being afraid of short-circuit.
+90
Documentation/i2c/chips/pcf8591
···11+Kernel driver pcf859122+=====================33+44+Supported chips:55+ * Philips PCF859166+ Prefix: 'pcf8591'77+ Addresses scanned: I2C 0x48 - 0x4f88+ Datasheet: Publicly available at the Philips Semiconductor website99+ http://www.semiconductors.philips.com/pip/PCF8591P.html1010+1111+Authors:1212+ Aurelien Jarno <aurelien@aurel32.net>1313+ valuable contributions by Jan M. Sendler <sendler@sendler.de>,1414+ Jean Delvare <khali@linux-fr.org>1515+1616+1717+Description1818+-----------1919+The PCF8591 is an 8-bit A/D and D/A converter (4 analog inputs and one2020+analog output) for the I2C bus produced by Philips Semiconductors. It2121+is designed to provide a byte I2C interface to up to 4 separate devices.2222+2323+The PCF8591 has 4 analog inputs programmable as single-ended or2424+differential inputs :2525+- mode 0 : four single ended inputs2626+ Pins AIN0 to AIN3 are single ended inputs for channels 0 to 32727+2828+- mode 1 : three differential inputs2929+ Pins AIN3 is the common negative differential input3030+ Pins AIN0 to AIN2 are positive differential inputs for channels 0 to 23131+3232+- mode 2 : single ended and differential mixed3333+ Pins AIN0 and AIN1 are single ended inputs for channels 0 and 13434+ Pins AIN2 is the positive differential input for channel 33535+ Pins AIN3 is the negative differential input for channel 33636+3737+- mode 3 : two differential inputs3838+ Pins AIN0 is the positive differential input for channel 03939+ Pins AIN1 is the negative differential input for channel 04040+ Pins AIN2 is the positive differential input for channel 14141+ Pins AIN3 is the negative differential input for channel 14242+4343+See the datasheet for details.4444+4545+Module parameters4646+-----------------4747+4848+* input_mode int4949+5050+ Analog input mode:5151+ 0 = four single ended inputs5252+ 1 = three differential inputs5353+ 2 = single ended and differential mixed5454+ 3 = two differential inputs5555+5656+5757+Accessing PCF8591 via /sys interface5858+-------------------------------------5959+6060+! Be careful !6161+The PCF8591 is plainly impossible to detect ! Stupid chip.6262+So every chip with address in the interval [48..4f] is6363+detected as PCF8591. If you have other chips in this address6464+range, the workaround is to load this module after the one6565+for your others chips.6666+6767+On detection (i.e. insmod, modprobe et al.), directories are being6868+created for each detected PCF8591:6969+7070+/sys/bus/devices/<0>-<1>/7171+where <0> is the bus the chip was detected on (e. g. i2c-0)7272+and <1> the chip address ([48..4f])7373+7474+Inside these directories, there are such files:7575+in0, in1, in2, in3, out0_enable, out0_output, name7676+7777+Name contains chip name.7878+7979+The in0, in1, in2 and in3 files are RO. Reading gives the value of the8080+corresponding channel. Depending on the current analog inputs configuration,8181+files in2 and/or in3 do not exist. Values range are from 0 to 255 for single8282+ended inputs and -128 to +127 for differential inputs (8-bit ADC).8383+8484+The out0_enable file is RW. Reading gives "1" for analog output enabled and8585+"0" for analog output disabled. Writing accepts "0" and "1" accordingly.8686+8787+The out0_output file is RW. Writing a number between 0 and 255 (8-bit DAC), send8888+the value to the digital-to-analog converter. Note that a voltage will8989+only appears on AOUT pin if aout0_enable equals 1. Reading returns the last9090+value written.
+106
Documentation/i2c/chips/sis5595
···11+Kernel driver sis559522+=====================33+44+Supported chips:55+ * Silicon Integrated Systems Corp. SiS5595 Southbridge Hardware Monitor66+ Prefix: 'sis5595'77+ Addresses scanned: ISA in PCI-space encoded address88+ Datasheet: Publicly available at the Silicon Integrated Systems Corp. site.99+1010+Authors:1111+ Ky�sti M�lkki <kmalkki@cc.hut.fi>,1212+ Mark D. Studebaker <mdsxyz123@yahoo.com>,1313+ Aurelien Jarno <aurelien@aurel32.net> 2.6 port1414+1515+ SiS southbridge has a LM78-like chip integrated on the same IC.1616+ This driver is a customized copy of lm78.c1717+1818+ Supports following revisions:1919+ Version PCI ID PCI Revision2020+ 1 1039/0008 AF or less2121+ 2 1039/0008 B0 or greater2222+2323+ Note: these chips contain a 0008 device which is incompatible with the2424+ 5595. We recognize these by the presence of the listed2525+ "blacklist" PCI ID and refuse to load.2626+2727+ NOT SUPPORTED PCI ID BLACKLIST PCI ID2828+ 540 0008 05402929+ 550 0008 05503030+ 5513 0008 55113131+ 5581 0008 55973232+ 5582 0008 55973333+ 5597 0008 55973434+ 630 0008 06303535+ 645 0008 06453636+ 730 0008 07303737+ 735 0008 07353838+3939+4040+Module Parameters4141+-----------------4242+force_addr=0xaddr Set the I/O base address. Useful for boards4343+ that don't set the address in the BIOS. Does not do a4444+ PCI force; the device must still be present in lspci.4545+ Don't use this unless the driver complains that the4646+ base address is not set.4747+ Example: 'modprobe sis5595 force_addr=0x290'4848+4949+5050+Description5151+-----------5252+5353+The SiS5595 southbridge has integrated hardware monitor functions. It also5454+has an I2C bus, but this driver only supports the hardware monitor. For the5555+I2C bus driver see i2c-sis5595.5656+5757+The SiS5595 implements zero or one temperature sensor, two fan speed5858+sensors, four or five voltage sensors, and alarms.5959+6060+On the first version of the chip, there are four voltage sensors and one6161+temperature sensor.6262+6363+On the second version of the chip, the temperature sensor (temp) and the6464+fifth voltage sensor (in4) share a pin which is configurable, but not6565+through the driver. Sorry. The driver senses the configuration of the pin,6666+which was hopefully set by the BIOS.6767+6868+Temperatures are measured in degrees Celsius. An alarm is triggered once6969+when the max is crossed; it is also triggered when it drops below the min7070+value. Measurements are guaranteed between -55 and +125 degrees, with a7171+resolution of 1 degree.7272+7373+Fan rotation speeds are reported in RPM (rotations per minute). An alarm is7474+triggered if the rotation speed has dropped below a programmable limit. Fan7575+readings can be divided by a programmable divider (1, 2, 4 or 8) to give7676+the readings more range or accuracy. Not all RPM values can accurately be7777+represented, so some rounding is done. With a divider of 2, the lowest7878+representable value is around 2600 RPM.7979+8080+Voltage sensors (also known as IN sensors) report their values in volts. An8181+alarm is triggered if the voltage has crossed a programmable minimum or8282+maximum limit. Note that minimum in this case always means 'closest to8383+zero'; this is important for negative voltage measurements. All voltage8484+inputs can measure voltages between 0 and 4.08 volts, with a resolution of8585+0.016 volt.8686+8787+In addition to the alarms described above, there is a BTI alarm, which gets8888+triggered when an external chip has crossed its limits. Usually, this is8989+connected to some LM75-like chip; if at least one crosses its limits, this9090+bit gets set.9191+9292+If an alarm triggers, it will remain triggered until the hardware register9393+is read at least once. This means that the cause for the alarm may already9494+have disappeared! Note that in the current implementation, all hardware9595+registers are read whenever any data is read (unless it is less than 1.59696+seconds since the last update). This means that you can easily miss9797+once-only alarms.9898+9999+The SiS5595 only updates its values each 1.5 seconds; reading it more often100100+will do no harm, but will return 'old' values.101101+102102+Problems103103+--------104104+Some chips refuse to be enabled. We don't know why.105105+The driver will recognize this and print a message in dmesg.106106+
···11+Kernel driver smsc47b39722+========================33+44+Supported chips:55+ * SMSC LPC47B397-NC66+ Prefix: 'smsc47b397'77+ Addresses scanned: none, address read from Super I/O config space88+ Datasheet: In this file99+1010+Authors: Mark M. Hoffman <mhoffman@lightlink.com>1111+ Utilitek Systems, Inc.1212+113November 23, 2004214315The following specification describes the SMSC LPC47B397-NC sensor chip44-(for which there is no public datasheet available). This document was1616+(for which there is no public datasheet available). This document was517provided by Craig Kelly (In-Store Broadcast Network) and edited/corrected618by Mark M. Hoffman <mhoffman@lightlink.com>.719···2210Methods for detecting the HP SIO and reading the thermal data on a dc7100.23112412The thermal information on the dc7100 is contained in the SIO Hardware Monitor2525-(HWM). The information is accessed through an index/data pair. The index/data2626-pair is located at the HWM Base Address + 0 and the HWM Base Address + 1. The1313+(HWM). The information is accessed through an index/data pair. The index/data1414+pair is located at the HWM Base Address + 0 and the HWM Base Address + 1. The2715HWM Base address can be obtained from Logical Device 8, registers 0x60 (MSB)2828-and 0x61 (LSB). Currently we are using 0x480 for the HWM Base Address and1616+and 0x61 (LSB). Currently we are using 0x480 for the HWM Base Address and29170x480 and 0x481 for the index/data pair.30183119Reading temperature information.···6250The LSB Must be read first.63516452How to convert the tach reading to RPM.6565-The tach reading (TCount) is given by: (Tach MSB * 256) + (Tach LSB)5353+The tach reading (TCount) is given by: (Tach MSB * 256) + (Tach LSB)6654The SIO counts the number of 90kHz (11.111us) pulses per revolution.6755RPM = 60/(TCount * 11.111us)6856···84728573Enter Configuration Mode8674To place the chip into the Configuration State The config key (0x55) is written8787-to the CONFIG PORT (0x2E). 7575+to the CONFIG PORT (0x2E).88768977Configuration Mode9078In configuration mode, the INDEX PORT is located at the CONFIG PORT address and9179the DATA PORT is at INDEX PORT address + 1.92809393-The desired configuration registers are accessed in two steps: 8181+The desired configuration registers are accessed in two steps:9482a. Write the index of the Logical Device Number Configuration Register9583 (i.e., 0x07) to the INDEX PORT and then write the number of the9684 desired logical device to the DATA PORT.97859886b. Write the address of the desired configuration register within the9987 logical device to the INDEX PORT and then write or read the config-100100- uration register through the DATA PORT. 8888+ uration register through the DATA PORT.1018910290Note: If accessing the Global Configuration Registers, step (a) is not required.10391···10896Programming Example10997The following is an example of how to read the SIO Device ID located at 0x2011098111111-; ENTER CONFIGURATION MODE 9999+; ENTER CONFIGURATION MODE112100MOV DX,02EH113101MOV AX,055H114102OUT DX,AL115115-; GLOBAL CONFIGURATION REGISTER 103103+; GLOBAL CONFIGURATION REGISTER116104MOV DX,02EH117105MOV AL,20H118118-OUT DX,AL 106106+OUT DX,AL119107; READ THE DATA120108MOV DX,02FH121109IN AL,DX122122-; EXIT CONFIGURATION MODE 110110+; EXIT CONFIGURATION MODE123111MOV DX,02EH124112MOV AX,0AAH125113OUT DX,AL···134122The following is an example of how to read the HWM Base Address located in135123Logical Device 8.136124137137-; ENTER CONFIGURATION MODE 125125+; ENTER CONFIGURATION MODE138126MOV DX,02EH139127MOV AX,055H140128OUT DX,AL141141-; CONFIGURE REGISTER CRE0, 142142-; LOGICAL DEVICE 8 129129+; CONFIGURE REGISTER CRE0,130130+; LOGICAL DEVICE 8143131MOV DX,02EH144132MOV AL,07H145133OUT DX,AL ;Point to LD# Config Reg···147135MOV AL, 08H148136OUT DX,AL;Point to Logical Device 8149137;150150-MOV DX,02EH 138138+MOV DX,02EH151139MOV AL,60H152140OUT DX,AL ; Point to HWM Base Addr MSB153141MOV DX,02FH154142IN AL,DX ; Get MSB of HWM Base Addr155155-; EXIT CONFIGURATION MODE 143143+; EXIT CONFIGURATION MODE156144MOV DX,02EH157145MOV AX,0AAH158146OUT DX,AL
+52
Documentation/i2c/chips/smsc47m1
···11+Kernel driver smsc47m122+======================33+44+Supported chips:55+ * SMSC LPC47B27x, LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x and LPC47M19266+ Addresses scanned: none, address read from Super I/O config space77+ Prefix: 'smsc47m1'88+ Datasheets:99+ http://www.smsc.com/main/datasheets/47b27x.pdf1010+ http://www.smsc.com/main/datasheets/47m10x.pdf1111+ http://www.smsc.com/main/tools/discontinued/47m13x.pdf1212+ http://www.smsc.com/main/datasheets/47m14x.pdf1313+ http://www.smsc.com/main/tools/discontinued/47m15x.pdf1414+ http://www.smsc.com/main/datasheets/47m192.pdf1515+1616+Authors:1717+ Mark D. Studebaker <mdsxyz123@yahoo.com>,1818+ With assistance from Bruce Allen <ballen@uwm.edu>, and his1919+ fan.c program: http://www.lsc-group.phys.uwm.edu/%7Eballen/driver/2020+ Gabriele Gorla <gorlik@yahoo.com>,2121+ Jean Delvare <khali@linux-fr.org>2222+2323+Description2424+-----------2525+2626+The Standard Microsystems Corporation (SMSC) 47M1xx Super I/O chips2727+contain monitoring and PWM control circuitry for two fans.2828+2929+The 47M15x and 47M192 chips contain a full 'hardware monitoring block'3030+in addition to the fan monitoring and control. The hardware monitoring3131+block is not supported by the driver.3232+3333+Fan rotation speeds are reported in RPM (rotations per minute). An alarm is3434+triggered if the rotation speed has dropped below a programmable limit. Fan3535+readings can be divided by a programmable divider (1, 2, 4 or 8) to give3636+the readings more range or accuracy. Not all RPM values can accurately be3737+represented, so some rounding is done. With a divider of 2, the lowest3838+representable value is around 2600 RPM.3939+4040+PWM values are from 0 to 255.4141+4242+If an alarm triggers, it will remain triggered until the hardware register4343+is read at least once. This means that the cause for the alarm may4444+already have disappeared! Note that in the current implementation, all4545+hardware registers are read whenever any data is read (unless it is less4646+than 1.5 seconds since the last update). This means that you can easily4747+miss once-only alarms.4848+4949+5050+**********************5151+The lm_sensors project gratefully acknowledges the support of5252+Intel in the development of this driver.
+65
Documentation/i2c/chips/via686a
···11+Kernel driver via686a22+=====================33+44+Supported chips:55+ * Via VT82C686A, VT82C686B Southbridge Integrated Hardware Monitor66+ Prefix: 'via686a'77+ Addresses scanned: ISA in PCI-space encoded address88+ Datasheet: On request through web form (http://www.via.com.tw/en/support/datasheets/)99+1010+Authors:1111+ Ky�sti M�lkki <kmalkki@cc.hut.fi>,1212+ Mark D. Studebaker <mdsxyz123@yahoo.com>1313+ Bob Dougherty <bobd@stanford.edu>1414+ (Some conversion-factor data were contributed by1515+ Jonathan Teh Soon Yew <j.teh@iname.com>1616+ and Alex van Kaam <darkside@chello.nl>.)1717+1818+Module Parameters1919+-----------------2020+2121+force_addr=0xaddr Set the I/O base address. Useful for Asus A7V boards2222+ that don't set the address in the BIOS. Does not do a2323+ PCI force; the via686a must still be present in lspci.2424+ Don't use this unless the driver complains that the2525+ base address is not set.2626+ Example: 'modprobe via686a force_addr=0x6000'2727+2828+Description2929+-----------3030+3131+The driver does not distinguish between the chips and reports3232+all as a 686A.3333+3434+The Via 686a southbridge has integrated hardware monitor functionality.3535+It also has an I2C bus, but this driver only supports the hardware monitor.3636+For the I2C bus driver, see <file:Documentation/i2c/busses/i2c-viapro>3737+3838+The Via 686a implements three temperature sensors, two fan rotation speed3939+sensors, five voltage sensors and alarms.4040+4141+Temperatures are measured in degrees Celsius. An alarm is triggered once4242+when the Overtemperature Shutdown limit is crossed; it is triggered again4343+as soon as it drops below the hysteresis value.4444+4545+Fan rotation speeds are reported in RPM (rotations per minute). An alarm is4646+triggered if the rotation speed has dropped below a programmable limit. Fan4747+readings can be divided by a programmable divider (1, 2, 4 or 8) to give4848+the readings more range or accuracy. Not all RPM values can accurately be4949+represented, so some rounding is done. With a divider of 2, the lowest5050+representable value is around 2600 RPM.5151+5252+Voltage sensors (also known as IN sensors) report their values in volts.5353+An alarm is triggered if the voltage has crossed a programmable minimum5454+or maximum limit. Voltages are internally scalled, so each voltage channel5555+has a different resolution and range.5656+5757+If an alarm triggers, it will remain triggered until the hardware register5858+is read at least once. This means that the cause for the alarm may5959+already have disappeared! Note that in the current implementation, all6060+hardware registers are read whenever any data is read (unless it is less6161+than 1.5 seconds since the last update). This means that you can easily6262+miss once-only alarms.6363+6464+The driver only updates its values each 1.5 seconds; reading it more often6565+will do no harm, but will return 'old' values.
+66
Documentation/i2c/chips/w83627hf
···11+Kernel driver w83627hf22+======================33+44+Supported chips:55+ * Winbond W83627HF (ISA accesses ONLY)66+ Prefix: 'w83627hf'77+ Addresses scanned: ISA address retrieved from Super I/O registers88+ Datasheet: http://www.winbond.com/PDF/sheet/w83627hf.pdf99+ * Winbond W83627THF1010+ Prefix: 'w83627thf'1111+ Addresses scanned: ISA address retrieved from Super I/O registers1212+ Datasheet: http://www.winbond.com/PDF/sheet/w83627thf.pdf1313+ * Winbond W83697HF1414+ Prefix: 'w83697hf'1515+ Addresses scanned: ISA address retrieved from Super I/O registers1616+ Datasheet: http://www.winbond.com/PDF/sheet/697hf.pdf1717+ * Winbond W83637HF1818+ Prefix: 'w83637hf'1919+ Addresses scanned: ISA address retrieved from Super I/O registers2020+ Datasheet: http://www.winbond.com/PDF/sheet/w83637hf.pdf2121+2222+Authors:2323+ Frodo Looijaard <frodol@dds.nl>,2424+ Philip Edelbrock <phil@netroedge.com>,2525+ Mark Studebaker <mdsxyz123@yahoo.com>,2626+ Bernhard C. Schrenk <clemy@clemy.org>2727+2828+Module Parameters2929+-----------------3030+3131+* force_addr: int3232+ Initialize the ISA address of the sensors3333+* force_i2c: int3434+ Initialize the I2C address of the sensors3535+* init: int3636+ (default is 1)3737+ Use 'init=0' to bypass initializing the chip.3838+ Try this if your computer crashes when you load the module.3939+4040+Description4141+-----------4242+4343+This driver implements support for ISA accesses *only* for4444+the Winbond W83627HF, W83627THF, W83697HF and W83637HF Super I/O chips.4545+We will refer to them collectively as Winbond chips.4646+4747+This driver supports ISA accesses, which should be more reliable4848+than i2c accesses. Also, for Tyan boards which contain both a4949+Super I/O chip and a second i2c-only Winbond chip (often a W83782D),5050+using this driver will avoid i2c address conflicts and complex5151+initialization that were required in the w83781d driver.5252+5353+If you really want i2c accesses for these Super I/O chips,5454+use the w83781d driver. However this is not the preferred method5555+now that this ISA driver has been developed.5656+5757+Technically, the w83627thf does not support a VID reading. However, it's5858+possible or even likely that your mainboard maker has routed these signals5959+to a specific set of general purpose IO pins (the Asus P4C800-E is one such6060+board). The w83627thf driver now interprets these as VID. If the VID on6161+your board doesn't work, first see doc/vid in the lm_sensors package. If6262+that still doesn't help, email us at lm-sensors@lm-sensors.org.6363+6464+For further information on this driver see the w83781d driver6565+documentation.6666+
+402
Documentation/i2c/chips/w83781d
···11+Kernel driver w83781d22+=====================33+44+Supported chips:55+ * Winbond W83781D66+ Prefix: 'w83781d'77+ Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)88+ Datasheet: http://www.winbond-usa.com/products/winbond_products/pdfs/PCIC/w83781d.pdf99+ * Winbond W83782D1010+ Prefix: 'w83782d'1111+ Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)1212+ Datasheet: http://www.winbond.com/PDF/sheet/w83782d.pdf1313+ * Winbond W83783S1414+ Prefix: 'w83783s'1515+ Addresses scanned: I2C 0x2d1616+ Datasheet: http://www.winbond-usa.com/products/winbond_products/pdfs/PCIC/w83783s.pdf1717+ * Winbond W83627HF1818+ Prefix: 'w83627hf'1919+ Addresses scanned: I2C 0x20 - 0x2f, ISA 0x290 (8 I/O ports)2020+ Datasheet: http://www.winbond.com/PDF/sheet/w83627hf.pdf2121+ * Asus AS99127F2222+ Prefix: 'as99127f'2323+ Addresses scanned: I2C 0x28 - 0x2f2424+ Datasheet: Unavailable from Asus2525+2626+Authors:2727+ Frodo Looijaard <frodol@dds.nl>,2828+ Philip Edelbrock <phil@netroedge.com>,2929+ Mark Studebaker <mdsxyz123@yahoo.com>3030+3131+Module parameters3232+-----------------3333+3434+* init int3535+ (default 1)3636+ Use 'init=0' to bypass initializing the chip.3737+ Try this if your computer crashes when you load the module.3838+3939+force_subclients=bus,caddr,saddr,saddr4040+ This is used to force the i2c addresses for subclients of4141+ a certain chip. Typical usage is `force_subclients=0,0x2d,0x4a,0x4b'4242+ to force the subclients of chip 0x2d on bus 0 to i2c addresses4343+ 0x4a and 0x4b. This parameter is useful for certain Tyan boards.4444+4545+Description4646+-----------4747+4848+This driver implements support for the Winbond W83781D, W83782D, W83783S,4949+W83627HF chips, and the Asus AS99127F chips. We will refer to them5050+collectively as W8378* chips.5151+5252+There is quite some difference between these chips, but they are similar5353+enough that it was sensible to put them together in one driver.5454+The W83627HF chip is assumed to be identical to the ISA W83782D.5555+The Asus chips are similar to an I2C-only W83782D.5656+5757+Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA5858+as99127f 7 3 0 3 0x31 0x12c3 yes no5959+as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no6060+w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes6161+w83627hf 9 3 2 3 0x21 0x5ca3 yes yes(LPC)6262+w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes6363+w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no6464+6565+Detection of these chips can sometimes be foiled because they can be in6666+an internal state that allows no clean access. If you know the address6767+of the chip, use a 'force' parameter; this will put them into a more6868+well-behaved state first.6969+7070+The W8378* implements temperature sensors (three on the W83781D and W83782D,7171+two on the W83783S), three fan rotation speed sensors, voltage sensors7272+(seven on the W83781D, nine on the W83782D and six on the W83783S), VID7373+lines, alarms with beep warnings, and some miscellaneous stuff.7474+7575+Temperatures are measured in degrees Celsius. There is always one main7676+temperature sensor, and one (W83783S) or two (W83781D and W83782D) other7777+sensors. An alarm is triggered for the main sensor once when the7878+Overtemperature Shutdown limit is crossed; it is triggered again as soon as7979+it drops below the Hysteresis value. A more useful behavior8080+can be found by setting the Hysteresis value to +127 degrees Celsius; in8181+this case, alarms are issued during all the time when the actual temperature8282+is above the Overtemperature Shutdown value. The driver sets the8383+hysteresis value for temp1 to 127 at initialization.8484+8585+For the other temperature sensor(s), an alarm is triggered when the8686+temperature gets higher then the Overtemperature Shutdown value; it stays8787+on until the temperature falls below the Hysteresis value. But on the8888+W83781D, there is only one alarm that functions for both other sensors!8989+Temperatures are guaranteed within a range of -55 to +125 degrees. The9090+main temperature sensors has a resolution of 1 degree; the other sensor(s)9191+of 0.5 degree.9292+9393+Fan rotation speeds are reported in RPM (rotations per minute). An alarm is9494+triggered if the rotation speed has dropped below a programmable limit. Fan9595+readings can be divided by a programmable divider (1, 2, 4 or 8 for the9696+W83781D; 1, 2, 4, 8, 16, 32, 64 or 128 for the others) to give9797+the readings more range or accuracy. Not all RPM values can accurately9898+be represented, so some rounding is done. With a divider of 2, the lowest9999+representable value is around 2600 RPM.100100+101101+Voltage sensors (also known as IN sensors) report their values in volts.102102+An alarm is triggered if the voltage has crossed a programmable minimum103103+or maximum limit. Note that minimum in this case always means 'closest to104104+zero'; this is important for negative voltage measurements. All voltage105105+inputs can measure voltages between 0 and 4.08 volts, with a resolution106106+of 0.016 volt.107107+108108+The VID lines encode the core voltage value: the voltage level your processor109109+should work with. This is hardcoded by the mainboard and/or processor itself.110110+It is a value in volts. When it is unconnected, you will often find the111111+value 3.50 V here.112112+113113+The W83782D and W83783S temperature conversion machine understands about114114+several kinds of temperature probes. You can program the so-called115115+beta value in the sensor files. '1' is the PII/Celeron diode, '2' is the116116+TN3904 transistor, and 3435 the default thermistor value. Other values117117+are (not yet) supported.118118+119119+In addition to the alarms described above, there is a CHAS alarm on the120120+chips which triggers if your computer case is open.121121+122122+When an alarm goes off, you can be warned by a beeping signal through123123+your computer speaker. It is possible to enable all beeping globally,124124+or only the beeping for some alarms.125125+126126+If an alarm triggers, it will remain triggered until the hardware register127127+is read at least once. This means that the cause for the alarm may128128+already have disappeared! Note that in the current implementation, all129129+hardware registers are read whenever any data is read (unless it is less130130+than 1.5 seconds since the last update). This means that you can easily131131+miss once-only alarms.132132+133133+The chips only update values each 1.5 seconds; reading them more often134134+will do no harm, but will return 'old' values.135135+136136+AS99127F PROBLEMS137137+-----------------138138+The as99127f support was developed without the benefit of a datasheet.139139+In most cases it is treated as a w83781d (although revision 2 of the140140+AS99127F looks more like a w83782d).141141+This support will be BETA until a datasheet is released.142142+One user has reported problems with fans stopping143143+occasionally.144144+145145+Note that the individual beep bits are inverted from the other chips.146146+The driver now takes care of this so that user-space applications147147+don't have to know about it.148148+149149+Known problems:150150+ - Problems with diode/thermistor settings (supported?)151151+ - One user reports fans stopping under high server load.152152+ - Revision 2 seems to have 2 PWM registers but we don't know153153+ how to handle them. More details below.154154+155155+These will not be fixed unless we get a datasheet.156156+If you have problems, please lobby Asus to release a datasheet.157157+Unfortunately several others have without success.158158+Please do not send mail to us asking for better as99127f support.159159+We have done the best we can without a datasheet.160160+Please do not send mail to the author or the sensors group asking for161161+a datasheet or ideas on how to convince Asus. We can't help.162162+163163+164164+NOTES:165165+-----166166+ 783s has no in1 so that in[2-6] are compatible with the 781d/782d.167167+168168+ 783s pin is programmable for -5V or temp1; defaults to -5V,169169+ no control in driver so temp1 doesn't work.170170+171171+ 782d and 783s datasheets differ on which is pwm1 and which is pwm2.172172+ We chose to follow 782d.173173+174174+ 782d and 783s pin is programmable for fan3 input or pwm2 output;175175+ defaults to fan3 input.176176+ If pwm2 is enabled (with echo 255 1 > pwm2), then177177+ fan3 will report 0.178178+179179+ 782d has pwm1-2 for ISA, pwm1-4 for i2c. (pwm3-4 share pins with180180+ the ISA pins)181181+182182+Data sheet updates:183183+------------------184184+ - PWM clock registers:185185+186186+ 000: master / 512187187+ 001: master / 1024188188+ 010: master / 2048189189+ 011: master / 4096190190+ 100: master / 8192191191+192192+193193+Answers from Winbond tech support194194+---------------------------------195195+>196196+> 1) In the W83781D data sheet section 7.2 last paragraph, it talks about197197+> reprogramming the R-T table if the Beta of the thermistor is not198198+> 3435K. The R-T table is described briefly in section 8.20.199199+> What formulas do I use to program a new R-T table for a given Beta?200200+>201201+ We are sorry that the calculation for R-T table value is202202+confidential. If you have another Beta value of thermistor, we can help203203+to calculate the R-T table for you. But you should give us real R-T204204+Table which can be gotten by thermistor vendor. Therefore we will calculate205205+them and obtain 32-byte data, and you can fill the 32-byte data to the206206+register in Bank0.CR51 of W83781D.207207+208208+209209+> 2) In the W83782D data sheet, it mentions that pins 38, 39, and 40 are210210+> programmable to be either thermistor or Pentium II diode inputs.211211+> How do I program them for diode inputs? I can't find any register212212+> to program these to be diode inputs.213213+ --> You may program Bank0 CR[5Dh] and CR[59h] registers.214214+215215+ CR[5Dh] bit 1(VTIN1) bit 2(VTIN2) bit 3(VTIN3)216216+217217+ thermistor 0 0 0218218+ diode 1 1 1219219+220220+221221+(error) CR[59h] bit 4(VTIN1) bit 2(VTIN2) bit 3(VTIN3)222222+(right) CR[59h] bit 4(VTIN1) bit 5(VTIN2) bit 6(VTIN3)223223+224224+ PII thermal diode 1 1 1225225+ 2N3904 diode 0 0 0226226+227227+228228+Asus Clones229229+-----------230230+231231+We have no datasheets for the Asus clones (AS99127F and ASB100 Bach).232232+Here are some very useful information that were given to us by Alex Van233233+Kaam about how to detect these chips, and how to read their values. He234234+also gives advice for another Asus chipset, the Mozart-2 (which we235235+don't support yet). Thanks Alex!236236+I reworded some parts and added personal comments.237237+238238+# Detection:239239+240240+AS99127F rev.1, AS99127F rev.2 and ASB100:241241+- I2C address range: 0x29 - 0x2F242242+- If register 0x58 holds 0x31 then we have an Asus (either ASB100 or243243+ AS99127F)244244+- Which one depends on register 0x4F (manufacturer ID):245245+ 0x06 or 0x94: ASB100246246+ 0x12 or 0xC3: AS99127F rev.1247247+ 0x5C or 0xA3: AS99127F rev.2248248+ Note that 0x5CA3 is Winbond's ID (WEC), which let us think Asus get their249249+ AS99127F rev.2 direct from Winbond. The other codes mean ATT and DVC,250250+ respectively. ATT could stand for Asustek something (although it would be251251+ very badly chosen IMHO), I don't know what DVC could stand for. Maybe252252+ these codes simply aren't meant to be decoded that way.253253+254254+Mozart-2:255255+- I2C address: 0x77256256+- If register 0x58 holds 0x56 or 0x10 then we have a Mozart-2257257+- Of the Mozart there are 3 types:258258+ 0x58=0x56, 0x4E=0x94, 0x4F=0x36: Asus ASM58 Mozart-2259259+ 0x58=0x56, 0x4E=0x94, 0x4F=0x06: Asus AS2K129R Mozart-2260260+ 0x58=0x10, 0x4E=0x5C, 0x4F=0xA3: Asus ??? Mozart-2261261+ You can handle all 3 the exact same way :)262262+263263+# Temperature sensors:264264+265265+ASB100:266266+- sensor 1: register 0x27267267+- sensor 2 & 3 are the 2 LM75's on the SMBus268268+- sensor 4: register 0x17269269+Remark: I noticed that on Intel boards sensor 2 is used for the CPU270270+ and 4 is ignored/stuck, on AMD boards sensor 4 is the CPU and sensor 2 is271271+ either ignored or a socket temperature.272272+273273+AS99127F (rev.1 and 2 alike):274274+- sensor 1: register 0x27275275+- sensor 2 & 3 are the 2 LM75's on the SMBus276276+Remark: Register 0x5b is suspected to be temperature type selector. Bit 1277277+ would control temp1, bit 3 temp2 and bit 5 temp3.278278+279279+Mozart-2:280280+- sensor 1: register 0x27281281+- sensor 2: register 0x13282282+283283+# Fan sensors:284284+285285+ASB100, AS99127F (rev.1 and 2 alike):286286+- 3 fans, identical to the W83781D287287+288288+Mozart-2:289289+- 2 fans only, 1350000/RPM/div290290+- fan 1: register 0x28, divisor on register 0xA1 (bits 4-5)291291+- fan 2: register 0x29, divisor on register 0xA1 (bits 6-7)292292+293293+# Voltages:294294+295295+This is where there is a difference between AS99127F rev.1 and 2.296296+Remark: The difference is similar to the difference between297297+ W83781D and W83782D.298298+299299+ASB100:300300+in0=r(0x20)*0.016301301+in1=r(0x21)*0.016302302+in2=r(0x22)*0.016303303+in3=r(0x23)*0.016*1.68304304+in4=r(0x24)*0.016*3.8305305+in5=r(0x25)*(-0.016)*3.97306306+in6=r(0x26)*(-0.016)*1.666307307+308308+AS99127F rev.1:309309+in0=r(0x20)*0.016310310+in1=r(0x21)*0.016311311+in2=r(0x22)*0.016312312+in3=r(0x23)*0.016*1.68313313+in4=r(0x24)*0.016*3.8314314+in5=r(0x25)*(-0.016)*3.97315315+in6=r(0x26)*(-0.016)*1.503316316+317317+AS99127F rev.2:318318+in0=r(0x20)*0.016319319+in1=r(0x21)*0.016320320+in2=r(0x22)*0.016321321+in3=r(0x23)*0.016*1.68322322+in4=r(0x24)*0.016*3.8323323+in5=(r(0x25)*0.016-3.6)*5.14+3.6324324+in6=(r(0x26)*0.016-3.6)*3.14+3.6325325+326326+Mozart-2:327327+in0=r(0x20)*0.016328328+in1=255329329+in2=r(0x22)*0.016330330+in3=r(0x23)*0.016*1.68331331+in4=r(0x24)*0.016*4332332+in5=255333333+in6=255334334+335335+336336+# PWM337337+338338+Additional info about PWM on the AS99127F (may apply to other Asus339339+chips as well) by Jean Delvare as of 2004-04-09:340340+341341+AS99127F revision 2 seems to have two PWM registers at 0x59 and 0x5A,342342+and a temperature sensor type selector at 0x5B (which basically means343343+that they swapped registers 0x59 and 0x5B when you compare with Winbond344344+chips).345345+Revision 1 of the chip also has the temperature sensor type selector at346346+0x5B, but PWM registers have no effect.347347+348348+We don't know exactly how the temperature sensor type selection works.349349+Looks like bits 1-0 are for temp1, bits 3-2 for temp2 and bits 5-4 for350350+temp3, although it is possible that only the most significant bit matters351351+each time. So far, values other than 0 always broke the readings.352352+353353+PWM registers seem to be split in two parts: bit 7 is a mode selector,354354+while the other bits seem to define a value or threshold.355355+356356+When bit 7 is clear, bits 6-0 seem to hold a threshold value. If the value357357+is below a given limit, the fan runs at low speed. If the value is above358358+the limit, the fan runs at full speed. We have no clue as to what the limit359359+represents. Note that there seem to be some inertia in this mode, speed360360+changes may need some time to trigger. Also, an hysteresis mechanism is361361+suspected since walking through all the values increasingly and then362362+decreasingly led to slightly different limits.363363+364364+When bit 7 is set, bits 3-0 seem to hold a threshold value, while bits 6-4365365+would not be significant. If the value is below a given limit, the fan runs366366+at full speed, while if it is above the limit it runs at low speed (so this367367+is the contrary of the other mode, in a way). Here again, we don't know368368+what the limit is supposed to represent.369369+370370+One remarkable thing is that the fans would only have two or three371371+different speeds (transitional states left apart), not a whole range as372372+you usually get with PWM.373373+374374+As a conclusion, you can write 0x00 or 0x8F to the PWM registers to make375375+fans run at low speed, and 0x7F or 0x80 to make them run at full speed.376376+377377+Please contact us if you can figure out how it is supposed to work. As378378+long as we don't know more, the w83781d driver doesn't handle PWM on379379+AS99127F chips at all.380380+381381+Additional info about PWM on the AS99127F rev.1 by Hector Martin:382382+383383+I've been fiddling around with the (in)famous 0x59 register and384384+found out the following values do work as a form of coarse pwm:385385+386386+0x80 - seems to turn fans off after some time(1-2 minutes)... might be387387+some form of auto-fan-control based on temp? hmm (Qfan? this mobo is an388388+old ASUS, it isn't marketed as Qfan. Maybe some beta pre-attemp at Qfan389389+that was dropped at the BIOS)390390+0x81 - off391391+0x82 - slightly "on-ner" than off, but my fans do not get to move. I can392392+hear the high-pitched PWM sound that motors give off at too-low-pwm.393393+0x83 - now they do move. Estimate about 70% speed or so.394394+0x84-0x8f - full on395395+396396+Changing the high nibble doesn't seem to do much except the high bit397397+(0x80) must be set for PWM to work, else the current pwm doesn't seem to398398+change.399399+400400+My mobo is an ASUS A7V266-E. This behavior is similar to what I got401401+with speedfan under Windows, where 0-15% would be off, 15-2x% (can't402402+remember the exact value) would be 70% and higher would be full on.
+39
Documentation/i2c/chips/w83l785ts
···11+Kernel driver w83l785ts22+=======================33+44+Supported chips:55+ * Winbond W83L785TS-S66+ Prefix: 'w83l785ts'77+ Addresses scanned: I2C 0x2e88+ Datasheet: Publicly available at the Winbond USA website99+ http://www.winbond-usa.com/products/winbond_products/pdfs/PCIC/W83L785TS-S.pdf1010+1111+Authors:1212+ Jean Delvare <khali@linux-fr.org>1313+1414+Description1515+-----------1616+1717+The W83L785TS-S is a digital temperature sensor. It senses the1818+temperature of a single external diode. The high limit is1919+theoretically defined as 85 or 100 degrees C through a combination2020+of external resistors, so the user cannot change it. Values seen so2121+far suggest that the two possible limits are actually 95 and 1102222+degrees C. The datasheet is rather poor and obviously inaccurate2323+on several points including this one.2424+2525+All temperature values are given in degrees Celsius. Resolution2626+is 1.0 degree. See the datasheet for details.2727+2828+The w83l785ts driver will not update its values more frequently than2929+every other second; reading them more often will do no harm, but will3030+return 'old' values.3131+3232+Known Issues3333+------------3434+3535+On some systems (Asus), the BIOS is known to interfere with the driver3636+and cause read errors. The driver will retry a given number of times3737+(5 by default) and then give up, returning the old value (or 0 if3838+there is no old value). It seems to work well enough so that you should3939+not notice anything. Thanks to James Bolt for helping test this feature.
+1-1
Documentation/i2c/porting-clients
···5757 Documentation/i2c/sysfs-interface for the individual files. Also5858 convert the units these files read and write to the specified ones.5959 If you need to add a new type of file, please discuss it on the6060- sensors mailing list <sensors@stimpy.netroedge.com> by providing a6060+ sensors mailing list <lm-sensors@lm-sensors.org> by providing a6161 patch to the Documentation/i2c/sysfs-interface file.62626363* [Attach] For I2C drivers, the attach function should make sure
+39
Documentation/i2c/userspace-tools
···11+Introduction22+------------33+44+Most mainboards have sensor chips to monitor system health (like temperatures,55+voltages, fans speed). They are often connected through an I2C bus, but some66+are also connected directly through the ISA bus.77+88+The kernel drivers make the data from the sensor chips available in the /sys99+virtual filesystem. Userspace tools are then used to display or set or the1010+data in a more friendly manner.1111+1212+Lm-sensors1313+----------1414+1515+Core set of utilites that will allow you to obtain health information,1616+setup monitoring limits etc. You can get them on their homepage1717+http://www.lm-sensors.nu/ or as a package from your Linux distribution.1818+1919+If from website:2020+Get lmsensors from project web site. Please note, you need only userspace2121+part, so compile with "make user_install" target.2222+2323+General hints to get things working:2424+2525+0) get lm-sensors userspace utils2626+1) compile all drivers in I2C section as modules in your kernel2727+2) run sensors-detect script, it will tell you what modules you need to load.2828+3) load them and run "sensors" command, you should see some results.2929+4) fix sensors.conf, labels, limits, fan divisors3030+5) if any more problems consult FAQ, or documentation3131+3232+Other utilites3333+--------------3434+3535+If you want some graphical indicators of system health look for applications3636+like: gkrellm, ksensors, xsensors, wmtemp, wmsensors, wmgtemp, ksysguardd,3737+hardware-monitor3838+3939+If you are server administrator you can try snmpd or mrtgutils.
+12-50
Documentation/i2c/writing-clients
···171171172172 normal_i2c: filled in by the module writer. 173173 A list of I2C addresses which should normally be examined.174174- normal_i2c_range: filled in by the module writer.175175- A list of pairs of I2C addresses, each pair being an inclusive range of176176- addresses which should normally be examined.177174 probe: insmod parameter. 178175 A list of pairs. The first value is a bus number (-1 for any I2C bus), 179176 the second is the address. These addresses are also probed, as if they 180177 were in the 'normal' list.181181- probe_range: insmod parameter. 182182- A list of triples. The first value is a bus number (-1 for any I2C bus), 183183- the second and third are addresses. These form an inclusive range of 184184- addresses that are also probed, as if they were in the 'normal' list.185178 ignore: insmod parameter.186179 A list of pairs. The first value is a bus number (-1 for any I2C bus), 187180 the second is the I2C address. These addresses are never probed. 188188- This parameter overrules 'normal' and 'probe', but not the 'force' lists.189189- ignore_range: insmod parameter. 190190- A list of triples. The first value is a bus number (-1 for any I2C bus), 191191- the second and third are addresses. These form an inclusive range of 192192- I2C addresses that are never probed.193181 This parameter overrules 'normal' and 'probe', but not the 'force' lists.194182 force: insmod parameter. 195183 A list of pairs. The first value is a bus number (-1 for any I2C bus),196184 the second is the I2C address. A device is blindly assumed to be on197185 the given address, no probing is done. 198186199199-Fortunately, as a module writer, you just have to define the `normal' 200200-and/or `normal_range' parameters. The complete declaration could look201201-like this:187187+Fortunately, as a module writer, you just have to define the `normal_i2c' 188188+parameter. The complete declaration could look like this:202189203203- /* Scan 0x20 to 0x2f, 0x37, and 0x40 to 0x4f */204204- static unsigned short normal_i2c[] = { 0x37,I2C_CLIENT_END }; 205205- static unsigned short normal_i2c_range[] = { 0x20, 0x2f, 0x40, 0x4f, 206206- I2C_CLIENT_END };190190+ /* Scan 0x37, and 0x48 to 0x4f */191191+ static unsigned short normal_i2c[] = { 0x37, 0x48, 0x49, 0x4a, 0x4b, 0x4c,192192+ 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };207193208194 /* Magic definition of all other variables and things */209195 I2C_CLIENT_INSMOD;210196211211-Note that you *have* to call the two defined variables `normal_i2c' and212212-`normal_i2c_range', without any prefix!197197+Note that you *have* to call the defined variable `normal_i2c',198198+without any prefix!213199214200215201Probing classes (sensors)···209223210224 normal_i2c: filled in by the module writer. Terminated by SENSORS_I2C_END.211225 A list of I2C addresses which should normally be examined.212212- normal_i2c_range: filled in by the module writer. Terminated by 213213- SENSORS_I2C_END214214- A list of pairs of I2C addresses, each pair being an inclusive range of215215- addresses which should normally be examined.216226 normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END.217227 A list of ISA addresses which should normally be examined.218218- normal_isa_range: filled in by the module writer. Terminated by 219219- SENSORS_ISA_END220220- A list of triples. The first two elements are ISA addresses, being an221221- range of addresses which should normally be examined. The third is the222222- modulo parameter: only addresses which are 0 module this value relative223223- to the first address of the range are actually considered.224228 probe: insmod parameter. Initialize this list with SENSORS_I2C_END values.225229 A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for226230 the ISA bus, -1 for any I2C bus), the second is the address. These227231 addresses are also probed, as if they were in the 'normal' list.228228- probe_range: insmod parameter. Initialize this list with SENSORS_I2C_END 229229- values.230230- A list of triples. The first value is a bus number (SENSORS_ISA_BUS for231231- the ISA bus, -1 for any I2C bus), the second and third are addresses. 232232- These form an inclusive range of addresses that are also probed, as233233- if they were in the 'normal' list.234232 ignore: insmod parameter. Initialize this list with SENSORS_I2C_END values.235233 A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for236234 the ISA bus, -1 for any I2C bus), the second is the I2C address. These237235 addresses are never probed. This parameter overrules 'normal' and 238236 'probe', but not the 'force' lists.239239- ignore_range: insmod parameter. Initialize this list with SENSORS_I2C_END 240240- values.241241- A list of triples. The first value is a bus number (SENSORS_ISA_BUS for242242- the ISA bus, -1 for any I2C bus), the second and third are addresses. 243243- These form an inclusive range of I2C addresses that are never probed.244244- This parameter overrules 'normal' and 'probe', but not the 'force' lists.245237246238Also used is a list of pointers to sensors_force_data structures:247239 force_data: insmod parameters. A list, ending with an element of which···233269So we have a generic insmod variabled `force', and chip-specific variables234270`force_CHIPNAME'.235271236236-Fortunately, as a module writer, you just have to define the `normal' 237237-and/or `normal_range' parameters, and define what chip names are used. 272272+Fortunately, as a module writer, you just have to define the `normal_i2c' 273273+and `normal_isa' parameters, and define what chip names are used. 238274The complete declaration could look like this:239239- /* Scan i2c addresses 0x20 to 0x2f, 0x37, and 0x40 to 0x4f240240- static unsigned short normal_i2c[] = {0x37,SENSORS_I2C_END};241241- static unsigned short normal_i2c_range[] = {0x20,0x2f,0x40,0x4f,242242- SENSORS_I2C_END};275275+ /* Scan i2c addresses 0x37, and 0x48 to 0x4f */276276+ static unsigned short normal_i2c[] = { 0x37, 0x48, 0x49, 0x4a, 0x4b, 0x4c,277277+ 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };243278 /* Scan ISA address 0x290 */244279 static unsigned int normal_isa[] = {0x0290,SENSORS_ISA_END};245245- static unsigned int normal_isa_range[] = {SENSORS_ISA_END};246280247281 /* Define chips foo and bar, as well as all module parameters and things */248282 SENSORS_INSMOD_2(foo,bar);
+8-8
MAINTAINERS
···194194ADM1025 HARDWARE MONITOR DRIVER195195P: Jean Delvare196196M: khali@linux-fr.org197197-L: sensors@stimpy.netroedge.com197197+L: lm-sensors@lm-sensors.org198198S: Maintained199199200200ADT746X FAN DRIVER···242242ALI1563 I2C DRIVER243243P: Rudolf Marek244244M: r.marek@sh.cvut.cz245245-L: sensors@stimpy.netroedge.com245245+L: lm-sensors@lm-sensors.org246246S: Maintained247247248248ALPHA PORT···10021002M: greg@kroah.com10031003P: Jean Delvare10041004M: khali@linux-fr.org10051005-L: sensors@stimpy.netroedge.com10051005+L: lm-sensors@lm-sensors.org10061006W: http://www.lm-sensors.nu/10071007S: Maintained10081008···14301430LM83 HARDWARE MONITOR DRIVER14311431P: Jean Delvare14321432M: khali@linux-fr.org14331433-L: sensors@stimpy.netroedge.com14331433+L: lm-sensors@lm-sensors.org14341434S: Maintained1435143514361436LM90 HARDWARE MONITOR DRIVER14371437P: Jean Delvare14381438M: khali@linux-fr.org14391439-L: sensors@stimpy.netroedge.com14391439+L: lm-sensors@lm-sensors.org14401440S: Maintained1441144114421442LOGICAL DISK MANAGER SUPPORT (LDM, Windows 2000/XP Dynamic Disks)···20752075SMSC47M1 HARDWARE MONITOR DRIVER20762076P: Jean Delvare20772077M: khali@linux-fr.org20782078-L: sensors@stimpy.netroedge.com20782078+L: lm-sensors@lm-sensors.org20792079S: Odd Fixes2080208020812081SMB FILESYSTEM···26142614W1 DALLAS'S 1-WIRE BUS26152615P: Evgeniy Polyakov26162616M: johnpol@2ka.mipt.ru26172617-L: sensors@stimpy.netroedge.com26172617+L: lm-sensors@lm-sensors.org26182618S: Maintained2619261926202620W83L51xD SD/MMC CARD INTERFACE DRIVER···26272627W83L785TS HARDWARE MONITOR DRIVER26282628P: Jean Delvare26292629M: khali@linux-fr.org26302630-L: sensors@stimpy.netroedge.com26302630+L: lm-sensors@lm-sensors.org26312631S: Odd Fixes2632263226332633WAN ROUTER & SANGOMA WANPIPE DRIVERS & API (X.25, FRAME RELAY, PPP, CISCO HDLC)
···4949/*5050 * Generate a start condition on the i2c bus.5151 *5252- * returns after the start condition has occured5252+ * returns after the start condition has occurred5353 */5454static void pca_start(struct i2c_algo_pca_data *adap)5555{···6262}63636464/*6565- * Generate a repeated start condition on the i2c bus 6565+ * Generate a repeated start condition on the i2c bus6666 *6767- * return after the repeated start condition has occured6767+ * return after the repeated start condition has occurred6868 */6969static void pca_repeated_start(struct i2c_algo_pca_data *adap)7070{···8282 * returns after the stop condition has been generated8383 *8484 * STOPs do not generate an interrupt or set the SI flag, since the8585- * part returns the the idle state (0xf8). Hence we don't need to8585+ * part returns the idle state (0xf8). Hence we don't need to8686 * pca_wait here.8787 */8888static void pca_stop(struct i2c_algo_pca_data *adap)
-1
drivers/i2c/algos/i2c-algo-sibyte.c
···24242525/* Ported for SiByte SOCs by Broadcom Corporation. */26262727-#include <linux/config.h>2827#include <linux/kernel.h>2928#include <linux/module.h>3029#include <linux/init.h>
+17-17
drivers/i2c/busses/Kconfig
···7788config I2C_ALI153599 tristate "ALI 1535"1010- depends on I2C && PCI && EXPERIMENTAL1010+ depends on I2C && PCI1111 help1212 If you say yes to this option, support will be included for the SMB1313 Host controller on Acer Labs Inc. (ALI) M1535 South Bridges. The SMB···31313232config I2C_ALI15X33333 tristate "ALI 15x3"3434- depends on I2C && PCI && EXPERIMENTAL3434+ depends on I2C && PCI3535 help3636 If you say yes to this option, support will be included for the3737 Acer Labs Inc. (ALI) M1514 and M1543 motherboard I2C interfaces.···41414242config I2C_AMD7564343 tristate "AMD 756/766/768/8111 and nVidia nForce"4444- depends on I2C && PCI && EXPERIMENTAL4444+ depends on I2C && PCI4545 help4646 If you say yes to this option, support will be included for the AMD4747 756/766/768 mainboard I2C interfaces. The driver also includes···66666767config I2C_AMD81116868 tristate "AMD 8111"6969- depends on I2C && PCI && EXPERIMENTAL6969+ depends on I2C && PCI7070 help7171 If you say yes to this option, support will be included for the7272 second (SMBus 2.0) AMD 8111 mainboard I2C interface.···109109110110config I2C_I801111111 tristate "Intel 82801 (ICH)"112112- depends on I2C && PCI && EXPERIMENTAL112112+ depends on I2C && PCI113113 help114114 If you say yes to this option, support will be included for the Intel115115 801 family of mainboard I2C interfaces. Specifically, the following···130130131131config I2C_I810132132 tristate "Intel 810/815"133133- depends on I2C && PCI && EXPERIMENTAL133133+ depends on I2C && PCI134134 select I2C_ALGOBIT135135 help136136 If you say yes to this option, support will be included for the Intel···183183184184config I2C_ISA185185 tristate "ISA Bus support"186186- depends on I2C && EXPERIMENTAL186186+ depends on I2C187187 help188188 If you say yes to this option, support will be included for i2c189189 interfaces that are on the ISA bus.···248248 will be called i2c-mpc.249249250250config I2C_NFORCE2251251- tristate "Nvidia Nforce2"252252- depends on I2C && PCI && EXPERIMENTAL251251+ tristate "Nvidia nForce2, nForce3 and nForce4"252252+ depends on I2C && PCI253253 help254254 If you say yes to this option, support will be included for the Nvidia255255- Nforce2 family of mainboard I2C interfaces.256256- This driver also supports the nForce3 Pro 150 MCP.255255+ nForce2, nForce3 and nForce4 families of mainboard I2C interfaces.257256258257 This driver can also be built as a module. If so, the module259258 will be called i2c-nforce2.···304305305306config I2C_PROSAVAGE306307 tristate "S3/VIA (Pro)Savage"307307- depends on I2C && PCI && EXPERIMENTAL308308+ depends on I2C && PCI308309 select I2C_ALGOBIT309310 help310311 If you say yes to this option, support will be included for the···387388388389config I2C_SIS5595389390 tristate "SiS 5595"390390- depends on I2C && PCI && EXPERIMENTAL391391+ depends on I2C && PCI391392 help392393 If you say yes to this option, support will be included for the 393394 SiS5595 SMBus (a subset of I2C) interface.···397398398399config I2C_SIS630399400 tristate "SiS 630/730"400400- depends on I2C && PCI && EXPERIMENTAL401401+ depends on I2C && PCI401402 help402403 If you say yes to this option, support will be included for the 403404 SiS630 and SiS730 SMBus (a subset of I2C) interface.···407408408409config I2C_SIS96X409410 tristate "SiS 96x"410410- depends on I2C && PCI && EXPERIMENTAL411411+ depends on I2C && PCI411412 help412413 If you say yes to this option, support will be included for the SiS413414 96x SMBus (a subset of I2C) interfaces. Specifically, the following···418419 648/961419420 650/961420421 735422422+ 745421423422424 This driver can also be built as a module. If so, the module423425 will be called i2c-sis96x.···449449450450config I2C_VIAPRO451451 tristate "VIA 82C596/82C686/823x"452452- depends on I2C && PCI && EXPERIMENTAL452452+ depends on I2C && PCI453453 help454454 If you say yes to this option, support will be included for the VIA455455 82C596/82C686/823x I2C interfaces. Specifically, the following ···467467468468config I2C_VOODOO3469469 tristate "Voodoo 3"470470- depends on I2C && PCI && EXPERIMENTAL470470+ depends on I2C && PCI471471 select I2C_ALGOBIT472472 help473473 If you say yes to this option, support will be included for the
-1
drivers/i2c/busses/i2c-ali1535.c
···53535454/* Note: we assume there can only be one ALI1535, with one SMBus interface */55555656-#include <linux/config.h>5756#include <linux/module.h>5857#include <linux/pci.h>5958#include <linux/kernel.h>
-1
drivers/i2c/busses/i2c-ali15x3.c
···60606161/* Note: we assume there can only be one ALI15X3, with one SMBus interface */62626363-#include <linux/config.h>6463#include <linux/module.h>6564#include <linux/pci.h>6665#include <linux/kernel.h>
-1
drivers/i2c/busses/i2c-amd756.c
···3737 Note: we assume there can only be one device, with one SMBus interface.3838*/39394040-#include <linux/config.h>4140#include <linux/module.h>4241#include <linux/pci.h>4342#include <linux/kernel.h>
-1
drivers/i2c/busses/i2c-amd8111.c
···88 * the Free Software Foundation version 2.99 */10101111-#include <linux/config.h>1211#include <linux/module.h>1312#include <linux/pci.h>1413#include <linux/kernel.h>
-1
drivers/i2c/busses/i2c-au1550.c
···2727 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.2828 */29293030-#include <linux/config.h>3130#include <linux/delay.h>3231#include <linux/kernel.h>3332#include <linux/module.h>
-1
drivers/i2c/busses/i2c-elektor.c
···2525/* Partialy rewriten by Oleg I. Vdovikin for mmapped support of 2626 for Alpha Processor Inc. UP-2000(+) boards */27272828-#include <linux/config.h>2928#include <linux/kernel.h>3029#include <linux/ioport.h>3130#include <linux/module.h>
-1
drivers/i2c/busses/i2c-frodo.c
···1212 * version 2 as published by the Free Software Foundation.1313 */14141515-#include <linux/config.h>1615#include <linux/module.h>1716#include <linux/kernel.h>1817#include <linux/init.h>
-1
drivers/i2c/busses/i2c-i801.c
···41414242/* Note: we assume there can only be one I801, with one SMBus interface */43434444-#include <linux/config.h>4544#include <linux/module.h>4645#include <linux/pci.h>4746#include <linux/kernel.h>
···8585 u32 cr = IOP3XX_ICR_GCD | IOP3XX_ICR_SCLEN | IOP3XX_ICR_UE;86868787 /* 8888- * Everytime unit enable is asserted, GPOD needs to be cleared8888+ * Every time unit enable is asserted, GPOD needs to be cleared8989 * on IOP321 to avoid data corruption on the bus.9090 */9191#ifdef CONFIG_ARCH_IOP321
-1
drivers/i2c/busses/i2c-isa.c
···2424 the SMBus and the ISA bus very much easier. See lm78.c for an example2525 of this. */26262727-#include <linux/config.h>2827#include <linux/init.h>2928#include <linux/module.h>3029#include <linux/kernel.h>
-1
drivers/i2c/busses/i2c-ite.c
···3333/* With some changes from Ky�sti M�lkki <kmalkki@cc.hut.fi> and even3434 Frodo Looijaard <frodol@dds.nl> */35353636-#include <linux/config.h>3736#include <linux/kernel.h>3837#include <linux/ioport.h>3938#include <linux/module.h>
-5
drivers/i2c/busses/i2c-ixp2000.c
···2626 * 'enabled' to drive the GPIOs.2727 */28282929-#include <linux/config.h>3030-#ifdef CONFIG_I2C_DEBUG_BUS3131-#define DEBUG 13232-#endif3333-3429#include <linux/kernel.h>3530#include <linux/init.h>3631#include <linux/device.h>
-5
drivers/i2c/busses/i2c-ixp4xx.c
···2626 * that is passed as the platform_data to this driver.2727 */28282929-#include <linux/config.h>3030-#ifdef CONFIG_I2C_DEBUG_BUS3131-#define DEBUG 13232-#endif3333-3429#include <linux/kernel.h>3530#include <linux/init.h>3631#include <linux/device.h>
-1
drivers/i2c/busses/i2c-keywest.c
···4646 sound driver to be happy4747*/48484949-#include <linux/config.h>5049#include <linux/module.h>5150#include <linux/kernel.h>5251#include <linux/ioport.h>
···37373838/* Note: we assume there can only be one nForce2, with two SMBus interfaces */39394040-#include <linux/config.h>4140#include <linux/module.h>4241#include <linux/pci.h>4342#include <linux/kernel.h>
-1
drivers/i2c/busses/i2c-parport-light.c
···2424 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.2525 * ------------------------------------------------------------------------ */26262727-#include <linux/config.h>2827#include <linux/kernel.h>2928#include <linux/module.h>3029#include <linux/init.h>
+1-2
drivers/i2c/busses/i2c-parport.c
···2424 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.2525 * ------------------------------------------------------------------------ */26262727-#include <linux/config.h>2827#include <linux/kernel.h>2928#include <linux/module.h>3029#include <linux/init.h>···130131/* Encapsulate the functions above in the correct structure.131132 Note that this is only a template, from which the real structures are132133 copied. The attaching code will set getscl to NULL for adapters that133133- cannot read SCL back, and will also make the the data field point to134134+ cannot read SCL back, and will also make the data field point to134135 the parallel port structure. */135136static struct i2c_algo_bit_data parport_algo_data = {136137 .setsda = parport_setsda,
-1
drivers/i2c/busses/i2c-pca-isa.c
···1717 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.1818 */19192020-#include <linux/config.h>2120#include <linux/kernel.h>2221#include <linux/ioport.h>2322#include <linux/module.h>
-1
drivers/i2c/busses/i2c-piix4.c
···2828 Note: we assume there can only be one device, with one SMBus interface.2929*/30303131-#include <linux/config.h>3231#include <linux/module.h>3332#include <linux/moduleparam.h>3433#include <linux/pci.h>
···2020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA2121*/22222323+#include <linux/config.h>2324#include <linux/kernel.h>2425#include <linux/module.h>2526···534533/* s3c24xx_i2c_xfer535534 *536535 * first port of call from the i2c bus code when an message needs537537- * transfering across the i2c bus.536536+ * transferring across the i2c bus.538537*/539538540539static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
-1
drivers/i2c/busses/i2c-savage4.c
···2929 it easier to add later.3030*/31313232-#include <linux/config.h>3332#include <linux/kernel.h>3433#include <linux/module.h>3534#include <linux/init.h>
-1
drivers/i2c/busses/i2c-sibyte.c
···1717 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.1818 */19192020-#include <linux/config.h>2120#include <linux/module.h>2221#include <linux/i2c-algo-sibyte.h>2322#include <asm/sibyte/sb1250_regs.h>
···4848 Note: we assume there can only be one device, with one SMBus interface.4949*/50505151-#include <linux/config.h>5251#include <linux/kernel.h>5352#include <linux/module.h>5453#include <linux/delay.h>
-1
drivers/i2c/busses/i2c-sis96x.c
···3232 We assume there can only be one SiS96x with one SMBus interface.3333*/34343535-#include <linux/config.h>3635#include <linux/module.h>3736#include <linux/pci.h>3837#include <linux/kernel.h>
···2121 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.2222*/23232424-#include <linux/config.h>2524#include <linux/kernel.h>2625#include <linux/module.h>2726#include <linux/pci.h>
-1
drivers/i2c/busses/i2c-viapro.c
···3333 Note: we assume there can only be one device, with one SMBus interface.3434*/35353636-#include <linux/config.h>3736#include <linux/module.h>3837#include <linux/delay.h>3938#include <linux/pci.h>
-1
drivers/i2c/busses/i2c-voodoo3.c
···2727/* This interfaces to the I2C bus of the Voodoo3 to gain access to2828 the BT869 and possibly other I2C devices. */29293030-#include <linux/config.h>3130#include <linux/kernel.h>3231#include <linux/module.h>3332#include <linux/init.h>
···11#22-# I2C Sensor device configuration22+# I2C Sensor and "other" chip configuration33#4455menu "Hardware Sensors Chip support"···11111212config SENSORS_ADM10211313 tristate "Analog Devices ADM1021 and compatibles"1414- depends on I2C && EXPERIMENTAL1414+ depends on I2C1515 select I2C_SENSOR1616 help1717 If you say yes here you get support for Analog Devices ADM1021 ···2929 help3030 If you say yes here you get support for Analog Devices ADM10253131 and Philips NE1619 sensor chips.3232+3233 This driver can also be built as a module. If so, the module3334 will be called adm1025.3435···3938 select I2C_SENSOR4039 help4140 If you say yes here you get support for Analog Devices ADM10264141+ sensor chip.4242+4243 This driver can also be built as a module. If so, the module4344 will be called adm1026.4445···5148 help5249 If you say yes here you get support for Analog Devices ADM1031 5350 and ADM1030 sensor chips.5151+5452 This driver can also be built as a module. If so, the module5553 will be called adm1031.5454+5555+config SENSORS_ADM92405656+ tristate "Analog Devices ADM9240 and compatibles"5757+ depends on I2C && EXPERIMENTAL5858+ select I2C_SENSOR5959+ help6060+ If you say yes here you get support for Analog Devices ADM9240,6161+ Dallas DS1780, National Semiconductor LM81 sensor chips.6262+6363+ This driver can also be built as a module. If so, the module6464+ will be called adm9240.56655766config SENSORS_ASB1005867 tristate "Asus ASB100 Bach"···76617762 This driver can also be built as a module. If so, the module7863 will be called asb100.6464+6565+config SENSORS_ATXP16666+ tristate "Attansic ATXP1 VID controller"6767+ depends on I2C && EXPERIMENTAL6868+ help6969+ If you say yes here you get support for the Attansic ATXP1 VID7070+ controller.7171+7272+ If your board have such a chip, you are able to control your CPU7373+ core and other voltages.7474+7575+ This driver can also be built as a module. If so, the module7676+ will be called atxp1.79778078config SENSORS_DS16218179 tristate "Dallas Semiconductor DS1621 and DS1625"···1259712698config SENSORS_GL518SM12799 tristate "Genesys Logic GL518SM"128128- depends on I2C && EXPERIMENTAL100100+ depends on I2C129101 select I2C_SENSOR130102 help131103 If you say yes here you get support for Genesys Logic GL518SM···147119148120config SENSORS_IT87149121 tristate "ITE IT87xx and compatibles"150150- depends on I2C && EXPERIMENTAL122122+ depends on I2C151123 select I2C_SENSOR152124 help153125 If you say yes here you get support for ITE IT87xx sensor chips···171143172144config SENSORS_LM75173145 tristate "National Semiconductor LM75 and compatibles"174174- depends on I2C && EXPERIMENTAL146146+ depends on I2C175147 select I2C_SENSOR176148 help177149 If you say yes here you get support for National Semiconductor LM75···202174 select I2C_SENSOR203175 help204176 If you say yes here you get support for National Semiconductor LM78,205205- LM78-J and LM79. This can also be built as a module which can be206206- inserted and removed while the kernel is running.177177+ LM78-J and LM79.207178208179 This driver can also be built as a module. If so, the module209180 will be called lm78.···235208 select I2C_SENSOR236209 help237210 If you say yes here you get support for National Semiconductor LM85238238- sensor chips and clones: ADT7463 and ADM1027.211211+ sensor chips and clones: ADT7463, EMC6D100, EMC6D102 and ADM1027.239212240213 This driver can also be built as a module. If so, the module241214 will be called lm85.···334307 help335308 If you say yes here you get support for the integrated fan336309 monitoring and control capabilities of the SMSC LPC47B27x,337337- LPC47M10x, LPC47M13x and LPC47M14x chips.310310+ LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x and LPC47M192 chips.338311339312 This driver can also be built as a module. If so, the module340313 will be called smsc47m1.341314342315config SENSORS_VIA686A343316 tristate "VIA686A"344344- depends on I2C && PCI && EXPERIMENTAL317317+ depends on I2C && PCI345318 select I2C_SENSOR346319 select I2C_ISA347320 help···353326354327config SENSORS_W83781D355328 tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F"356356- depends on I2C && EXPERIMENTAL329329+ depends on I2C357330 select I2C_SENSOR358331 help359332 If you say yes here you get support for the Winbond W8378x series···387360 This driver can also be built as a module. If so, the module388361 will be called w83627hf.389362363363+config SENSORS_W83627EHF364364+ tristate "Winbond W83627EHF"365365+ depends on I2C && EXPERIMENTAL366366+ select I2C_SENSOR367367+ select I2C_ISA368368+ help369369+ If you say yes here you get preliminary support for the hardware370370+ monitoring functionality of the Winbond W83627EHF Super-I/O chip.371371+ Only fan and temperature inputs are supported at the moment, while372372+ the chip does much more than that.373373+374374+ This driver can also be built as a module. If so, the module375375+ will be called w83627ehf.376376+390377endmenu391378392379menu "Other I2C Chip support"393380 depends on I2C394381395382config SENSORS_DS1337396396- tristate "Dallas Semiconductor DS1337 Real Time Clock"383383+ tristate "Dallas Semiconductor DS1337 and DS1339 Real Time Clock"397384 depends on I2C && EXPERIMENTAL398385 select I2C_SENSOR399386 help400387 If you say yes here you get support for Dallas Semiconductor401401- DS1337 real-time clock chips. 388388+ DS1337 and DS1339 real-time clock chips.402389403390 This driver can also be built as a module. If so, the module404391 will be called ds1337.392392+393393+config SENSORS_DS1374394394+ tristate "Maxim/Dallas Semiconductor DS1374 Real Time Clock"395395+ depends on I2C && EXPERIMENTAL396396+ select I2C_SENSOR397397+ help398398+ If you say yes here you get support for Dallas Semiconductor399399+ DS1374 real-time clock chips.400400+401401+ This driver can also be built as a module. If so, the module402402+ will be called ds1374.405403406404config SENSORS_EEPROM407405 tristate "EEPROM reader"···450398451399 This driver can also be built as a module. If so, the module452400 will be called pcf8574.401401+402402+config SENSORS_PCA9539403403+ tristate "Philips PCA9539 16-bit I/O port"404404+ depends on I2C && EXPERIMENTAL405405+ help406406+ If you say yes here you get support for the Philips PCA9539407407+ 16-bit I/O port.408408+409409+ This driver can also be built as a module. If so, the module410410+ will be called pca9539.453411454412config SENSORS_PCF8591455413 tristate "Philips PCF8591"···493431 This driver can also be built as a module. If so, the module494432 will be called isp1301_omap.495433434434+# NOTE: This isn't really OMAP-specific, except for the current435435+# interface location in <include/asm-arm/arch-omap/tps65010.h>436436+# and having mostly OMAP-specific board support437437+config TPS65010438438+ tristate "TPS6501x Power Management chips"439439+ depends on I2C && ARCH_OMAP440440+ default y if MACH_OMAP_H2 || MACH_OMAP_H3 || MACH_OMAP_OSK441441+ help442442+ If you say yes here you get support for the TPS6501x series of443443+ Power Management chips. These include voltage regulators,444444+ lithium ion/polymer battery charging, and other features that445445+ are often used in portable devices like cell phones and cameras.446446+447447+ This driver can also be built as a module. If so, the module448448+ will be called tps65010.449449+450450+496451config SENSORS_M41T00497452 tristate "ST M41T00 RTC chip"498453 depends on I2C && PPC32···518439519440 This driver can also be built as a module. If so, the module520441 will be called m41t00.442442+443443+config SENSORS_MAX6875444444+ tristate "MAXIM MAX6875 Power supply supervisor"445445+ depends on I2C && EXPERIMENTAL446446+ help447447+ If you say yes here you get support for the MAX6875448448+ EEPROM-Programmable, Hex/Quad, Power-Suppy Sequencers/Supervisors.449449+450450+ This provides a interface to program the EEPROM and reset the chip.451451+452452+ This driver can also be built as a module. If so, the module453453+ will be called max6875.521454522455endmenu
+9-1
drivers/i2c/chips/Makefile
···11#22-# Makefile for the kernel hardware sensors chip drivers.22+# Makefile for sensor and "other" I2C chip drivers.33#4455# asb100, then w83781d go first, as they can override other drivers' addresses.···1111obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o1212obj-$(CONFIG_SENSORS_ADM1026) += adm1026.o1313obj-$(CONFIG_SENSORS_ADM1031) += adm1031.o1414+obj-$(CONFIG_SENSORS_ADM9240) += adm9240.o1515+obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o1416obj-$(CONFIG_SENSORS_DS1337) += ds1337.o1717+obj-$(CONFIG_SENSORS_DS1374) += ds1374.o1518obj-$(CONFIG_SENSORS_DS1621) += ds1621.o1619obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o1720obj-$(CONFIG_SENSORS_FSCHER) += fscher.o···3330obj-$(CONFIG_SENSORS_LM90) += lm90.o3431obj-$(CONFIG_SENSORS_LM92) += lm92.o3532obj-$(CONFIG_SENSORS_MAX1619) += max1619.o3333+obj-$(CONFIG_SENSORS_MAX6875) += max6875.o3634obj-$(CONFIG_SENSORS_M41T00) += m41t00.o3735obj-$(CONFIG_SENSORS_PC87360) += pc87360.o3636+obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o3837obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o3938obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o4039obj-$(CONFIG_SENSORS_RTC8564) += rtc8564.o···4439obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o4540obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o4641obj-$(CONFIG_SENSORS_VIA686A) += via686a.o4242+obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o4743obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o4444+4845obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o4646+obj-$(CONFIG_TPS65010) += tps65010.o49475048ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)5149EXTRA_CFLAGS += -DDEBUG
···4545 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.4646 */47474848-#include <linux/config.h>4948#include <linux/module.h>5049#include <linux/init.h>5150#include <linux/slab.h>···286287 struct adm1025_data *data = adm1025_update_device(dev);287288 return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm));288289}290290+/* in1_ref is deprecated in favour of cpu0_vid, remove after 2005-11-11 */289291static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL);292292+static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);290293291294static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf)292295{···438437 device_create_file(&new_client->dev, &dev_attr_temp1_max);439438 device_create_file(&new_client->dev, &dev_attr_temp2_max);440439 device_create_file(&new_client->dev, &dev_attr_alarms);440440+ /* in1_ref is deprecated, remove after 2005-11-11 */441441 device_create_file(&new_client->dev, &dev_attr_in1_ref);442442+ device_create_file(&new_client->dev, &dev_attr_cpu0_vid);442443 device_create_file(&new_client->dev, &dev_attr_vrm);443444444445 /* Pin 11 is either in4 (+12V) or VID4 */
+5-3
drivers/i2c/chips/adm1026.c
···2323 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.2424*/25252626-#include <linux/config.h>2726#include <linux/module.h>2827#include <linux/init.h>2928#include <linux/slab.h>3029#include <linux/jiffies.h>3130#include <linux/i2c.h>3231#include <linux/i2c-sensor.h>3333-#include <linux/i2c-sysfs.h>3432#include <linux/i2c-vid.h>3333+#include <linux/hwmon-sysfs.h>35343635/* Addresses to scan */3736static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };···12241225 struct adm1026_data *data = adm1026_update_device(dev);12251226 return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm));12261227}12271227-12281228+/* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */12281229static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL);12301230+static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL);1229123112301232static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf)12311233{···16661666 device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable);16671667 device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable);16681668 device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable);16691669+ /* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */16691670 device_create_file(&new_client->dev, &dev_attr_vid);16711671+ device_create_file(&new_client->dev, &dev_attr_cpu0_vid);16701672 device_create_file(&new_client->dev, &dev_attr_vrm);16711673 device_create_file(&new_client->dev, &dev_attr_alarms);16721674 device_create_file(&new_client->dev, &dev_attr_alarm_mask);
+1-1
drivers/i2c/chips/adm1031.c
···440440441441/*442442 * That function checks the cases where the fan reading is not443443- * relevent. It is used to provide 0 as fan reading when the fan is443443+ * relevant. It is used to provide 0 as fan reading when the fan is444444 * not supposed to run445445 */446446static int trust_fan_readings(struct adm1031_data *data, int chan)
+791
drivers/i2c/chips/adm9240.c
···11+/*22+ * adm9240.c Part of lm_sensors, Linux kernel modules for hardware33+ * monitoring44+ *55+ * Copyright (C) 1999 Frodo Looijaard <frodol@dds.nl>66+ * Philip Edelbrock <phil@netroedge.com>77+ * Copyright (C) 2003 Michiel Rook <michiel@grendelproject.nl>88+ * Copyright (C) 2005 Grant Coady <gcoady@gmail.com> with valuable99+ * guidance from Jean Delvare1010+ *1111+ * Driver supports Analog Devices ADM92401212+ * Dallas Semiconductor DS17801313+ * National Semiconductor LM811414+ *1515+ * ADM9240 is the reference, DS1780 and LM81 are register compatibles1616+ *1717+ * Voltage Six inputs are scaled by chip, VID also reported1818+ * Temperature Chip temperature to 0.5'C, maximum and max_hysteris1919+ * Fans 2 fans, low speed alarm, automatic fan clock divider2020+ * Alarms 16-bit map of active alarms2121+ * Analog Out 0..1250 mV output2222+ *2323+ * Chassis Intrusion: clear CI latch with 'echo 1 > chassis_clear'2424+ *2525+ * Test hardware: Intel SE440BX-2 desktop motherboard --Grant2626+ *2727+ * LM81 extended temp reading not implemented2828+ *2929+ * This program is free software; you can redistribute it and/or modify3030+ * it under the terms of the GNU General Public License as published by3131+ * the Free Software Foundation; either version 2 of the License, or3232+ * (at your option) any later version.3333+ *3434+ * This program is distributed in the hope that it will be useful,3535+ * but WITHOUT ANY WARRANTY; without even the implied warranty of3636+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the3737+ * GNU General Public License for more details.3838+ *3939+ * You should have received a copy of the GNU General Public License4040+ * along with this program; if not, write to the Free Software4141+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.4242+ */4343+4444+#include <linux/init.h>4545+#include <linux/module.h>4646+#include <linux/slab.h>4747+#include <linux/i2c.h>4848+#include <linux/i2c-sensor.h>4949+#include <linux/i2c-vid.h>5050+5151+/* Addresses to scan */5252+static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,5353+ I2C_CLIENT_END };5454+5555+static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };5656+5757+/* Insmod parameters */5858+SENSORS_INSMOD_3(adm9240, ds1780, lm81);5959+6060+/* ADM9240 registers */6161+#define ADM9240_REG_MAN_ID 0x3e6262+#define ADM9240_REG_DIE_REV 0x3f6363+#define ADM9240_REG_CONFIG 0x406464+6565+#define ADM9240_REG_IN(nr) (0x20 + (nr)) /* 0..5 */6666+#define ADM9240_REG_IN_MAX(nr) (0x2b + (nr) * 2)6767+#define ADM9240_REG_IN_MIN(nr) (0x2c + (nr) * 2)6868+#define ADM9240_REG_FAN(nr) (0x28 + (nr)) /* 0..1 */6969+#define ADM9240_REG_FAN_MIN(nr) (0x3b + (nr))7070+#define ADM9240_REG_INT(nr) (0x41 + (nr))7171+#define ADM9240_REG_INT_MASK(nr) (0x43 + (nr))7272+#define ADM9240_REG_TEMP 0x277373+#define ADM9240_REG_TEMP_HIGH 0x397474+#define ADM9240_REG_TEMP_HYST 0x3a7575+#define ADM9240_REG_ANALOG_OUT 0x197676+#define ADM9240_REG_CHASSIS_CLEAR 0x467777+#define ADM9240_REG_VID_FAN_DIV 0x477878+#define ADM9240_REG_I2C_ADDR 0x487979+#define ADM9240_REG_VID4 0x498080+#define ADM9240_REG_TEMP_CONF 0x4b8181+8282+/* generalised scaling with integer rounding */8383+static inline int SCALE(long val, int mul, int div)8484+{8585+ if (val < 0)8686+ return (val * mul - div / 2) / div;8787+ else8888+ return (val * mul + div / 2) / div;8989+}9090+9191+/* adm9240 internally scales voltage measurements */9292+static const u16 nom_mv[] = { 2500, 2700, 3300, 5000, 12000, 2700 };9393+9494+static inline unsigned int IN_FROM_REG(u8 reg, int n)9595+{9696+ return SCALE(reg, nom_mv[n], 192);9797+}9898+9999+static inline u8 IN_TO_REG(unsigned long val, int n)100100+{101101+ return SENSORS_LIMIT(SCALE(val, 192, nom_mv[n]), 0, 255);102102+}103103+104104+/* temperature range: -40..125, 127 disables temperature alarm */105105+static inline s8 TEMP_TO_REG(long val)106106+{107107+ return SENSORS_LIMIT(SCALE(val, 1, 1000), -40, 127);108108+}109109+110110+/* two fans, each with low fan speed limit */111111+static inline unsigned int FAN_FROM_REG(u8 reg, u8 div)112112+{113113+ if (!reg) /* error */114114+ return -1;115115+116116+ if (reg == 255)117117+ return 0;118118+119119+ return SCALE(1350000, 1, reg * div);120120+}121121+122122+/* analog out 0..1250mV */123123+static inline u8 AOUT_TO_REG(unsigned long val)124124+{125125+ return SENSORS_LIMIT(SCALE(val, 255, 1250), 0, 255);126126+}127127+128128+static inline unsigned int AOUT_FROM_REG(u8 reg)129129+{130130+ return SCALE(reg, 1250, 255);131131+}132132+133133+static int adm9240_attach_adapter(struct i2c_adapter *adapter);134134+static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind);135135+static void adm9240_init_client(struct i2c_client *client);136136+static int adm9240_detach_client(struct i2c_client *client);137137+static struct adm9240_data *adm9240_update_device(struct device *dev);138138+139139+/* driver data */140140+static struct i2c_driver adm9240_driver = {141141+ .owner = THIS_MODULE,142142+ .name = "adm9240",143143+ .id = I2C_DRIVERID_ADM9240,144144+ .flags = I2C_DF_NOTIFY,145145+ .attach_adapter = adm9240_attach_adapter,146146+ .detach_client = adm9240_detach_client,147147+};148148+149149+/* per client data */150150+struct adm9240_data {151151+ enum chips type;152152+ struct i2c_client client;153153+ struct semaphore update_lock;154154+ char valid;155155+ unsigned long last_updated_measure;156156+ unsigned long last_updated_config;157157+158158+ u8 in[6]; /* ro in0_input */159159+ u8 in_max[6]; /* rw in0_max */160160+ u8 in_min[6]; /* rw in0_min */161161+ u8 fan[2]; /* ro fan1_input */162162+ u8 fan_min[2]; /* rw fan1_min */163163+ u8 fan_div[2]; /* rw fan1_div, read-only accessor */164164+ s16 temp; /* ro temp1_input, 9-bit sign-extended */165165+ s8 temp_high; /* rw temp1_max */166166+ s8 temp_hyst; /* rw temp1_max_hyst */167167+ u16 alarms; /* ro alarms */168168+ u8 aout; /* rw aout_output */169169+ u8 vid; /* ro vid */170170+ u8 vrm; /* -- vrm set on startup, no accessor */171171+};172172+173173+/* i2c byte read/write interface */174174+static int adm9240_read_value(struct i2c_client *client, u8 reg)175175+{176176+ return i2c_smbus_read_byte_data(client, reg);177177+}178178+179179+static int adm9240_write_value(struct i2c_client *client, u8 reg, u8 value)180180+{181181+ return i2c_smbus_write_byte_data(client, reg, value);182182+}183183+184184+/*** sysfs accessors ***/185185+186186+/* temperature */187187+#define show_temp(value, scale) \188188+static ssize_t show_##value(struct device *dev, \189189+ struct device_attribute *attr, \190190+ char *buf) \191191+{ \192192+ struct adm9240_data *data = adm9240_update_device(dev); \193193+ return sprintf(buf, "%d\n", data->value * scale); \194194+}195195+show_temp(temp_high, 1000);196196+show_temp(temp_hyst, 1000);197197+show_temp(temp, 500); /* 0.5'C per bit */198198+199199+#define set_temp(value, reg) \200200+static ssize_t set_##value(struct device *dev, \201201+ struct device_attribute *attr, \202202+ const char *buf, size_t count) \203203+{ \204204+ struct i2c_client *client = to_i2c_client(dev); \205205+ struct adm9240_data *data = adm9240_update_device(dev); \206206+ long temp = simple_strtoul(buf, NULL, 10); \207207+ \208208+ down(&data->update_lock); \209209+ data->value = TEMP_TO_REG(temp); \210210+ adm9240_write_value(client, reg, data->value); \211211+ up(&data->update_lock); \212212+ return count; \213213+}214214+215215+set_temp(temp_high, ADM9240_REG_TEMP_HIGH);216216+set_temp(temp_hyst, ADM9240_REG_TEMP_HYST);217217+218218+static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO,219219+ show_temp_high, set_temp_high);220220+static DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO,221221+ show_temp_hyst, set_temp_hyst);222222+static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL);223223+224224+/* voltage */225225+static ssize_t show_in(struct device *dev, char *buf, int nr)226226+{227227+ struct adm9240_data *data = adm9240_update_device(dev);228228+ return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr], nr));229229+}230230+231231+static ssize_t show_in_min(struct device *dev, char *buf, int nr)232232+{233233+ struct adm9240_data *data = adm9240_update_device(dev);234234+ return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr], nr));235235+}236236+237237+static ssize_t show_in_max(struct device *dev, char *buf, int nr)238238+{239239+ struct adm9240_data *data = adm9240_update_device(dev);240240+ return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr], nr));241241+}242242+243243+static ssize_t set_in_min(struct device *dev, const char *buf,244244+ size_t count, int nr)245245+{246246+ struct i2c_client *client = to_i2c_client(dev);247247+ struct adm9240_data *data = i2c_get_clientdata(client);248248+ unsigned long val = simple_strtoul(buf, NULL, 10);249249+250250+ down(&data->update_lock);251251+ data->in_min[nr] = IN_TO_REG(val, nr);252252+ adm9240_write_value(client, ADM9240_REG_IN_MIN(nr), data->in_min[nr]);253253+ up(&data->update_lock);254254+ return count;255255+}256256+257257+static ssize_t set_in_max(struct device *dev, const char *buf,258258+ size_t count, int nr)259259+{260260+ struct i2c_client *client = to_i2c_client(dev);261261+ struct adm9240_data *data = i2c_get_clientdata(client);262262+ unsigned long val = simple_strtoul(buf, NULL, 10);263263+264264+ down(&data->update_lock);265265+ data->in_max[nr] = IN_TO_REG(val, nr);266266+ adm9240_write_value(client, ADM9240_REG_IN_MAX(nr), data->in_max[nr]);267267+ up(&data->update_lock);268268+ return count;269269+}270270+271271+#define show_in_offset(offset) \272272+static ssize_t show_in##offset(struct device *dev, \273273+ struct device_attribute *attr, \274274+ char *buf) \275275+{ \276276+ return show_in(dev, buf, offset); \277277+} \278278+static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in##offset, NULL); \279279+static ssize_t show_in##offset##_min(struct device *dev, \280280+ struct device_attribute *attr, \281281+ char *buf) \282282+{ \283283+ return show_in_min(dev, buf, offset); \284284+} \285285+static ssize_t show_in##offset##_max(struct device *dev, \286286+ struct device_attribute *attr, \287287+ char *buf) \288288+{ \289289+ return show_in_max(dev, buf, offset); \290290+} \291291+static ssize_t \292292+set_in##offset##_min(struct device *dev, \293293+ struct device_attribute *attr, const char *buf, \294294+ size_t count) \295295+{ \296296+ return set_in_min(dev, buf, count, offset); \297297+} \298298+static ssize_t \299299+set_in##offset##_max(struct device *dev, \300300+ struct device_attribute *attr, const char *buf, \301301+ size_t count) \302302+{ \303303+ return set_in_max(dev, buf, count, offset); \304304+} \305305+static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \306306+ show_in##offset##_min, set_in##offset##_min); \307307+static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \308308+ show_in##offset##_max, set_in##offset##_max);309309+310310+show_in_offset(0);311311+show_in_offset(1);312312+show_in_offset(2);313313+show_in_offset(3);314314+show_in_offset(4);315315+show_in_offset(5);316316+317317+/* fans */318318+static ssize_t show_fan(struct device *dev, char *buf, int nr)319319+{320320+ struct adm9240_data *data = adm9240_update_device(dev);321321+ return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr],322322+ 1 << data->fan_div[nr]));323323+}324324+325325+static ssize_t show_fan_min(struct device *dev, char *buf, int nr)326326+{327327+ struct adm9240_data *data = adm9240_update_device(dev);328328+ return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr],329329+ 1 << data->fan_div[nr]));330330+}331331+332332+static ssize_t show_fan_div(struct device *dev, char *buf, int nr)333333+{334334+ struct adm9240_data *data = adm9240_update_device(dev);335335+ return sprintf(buf, "%d\n", 1 << data->fan_div[nr]);336336+}337337+338338+/* write new fan div, callers must hold data->update_lock */339339+static void adm9240_write_fan_div(struct i2c_client *client, int nr,340340+ u8 fan_div)341341+{342342+ u8 reg, old, shift = (nr + 2) * 2;343343+344344+ reg = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV);345345+ old = (reg >> shift) & 3;346346+ reg &= ~(3 << shift);347347+ reg |= (fan_div << shift);348348+ adm9240_write_value(client, ADM9240_REG_VID_FAN_DIV, reg);349349+ dev_dbg(&client->dev, "fan%d clock divider changed from %u "350350+ "to %u\n", nr + 1, 1 << old, 1 << fan_div);351351+}352352+353353+/* 354354+ * set fan speed low limit:355355+ *356356+ * - value is zero: disable fan speed low limit alarm357357+ *358358+ * - value is below fan speed measurement range: enable fan speed low359359+ * limit alarm to be asserted while fan speed too slow to measure360360+ *361361+ * - otherwise: select fan clock divider to suit fan speed low limit,362362+ * measurement code may adjust registers to ensure fan speed reading363363+ */364364+static ssize_t set_fan_min(struct device *dev, const char *buf,365365+ size_t count, int nr)366366+{367367+ struct i2c_client *client = to_i2c_client(dev);368368+ struct adm9240_data *data = i2c_get_clientdata(client);369369+ unsigned long val = simple_strtoul(buf, NULL, 10);370370+ u8 new_div;371371+372372+ down(&data->update_lock);373373+374374+ if (!val) {375375+ data->fan_min[nr] = 255;376376+ new_div = data->fan_div[nr];377377+378378+ dev_dbg(&client->dev, "fan%u low limit set disabled\n",379379+ nr + 1);380380+381381+ } else if (val < 1350000 / (8 * 254)) {382382+ new_div = 3;383383+ data->fan_min[nr] = 254;384384+385385+ dev_dbg(&client->dev, "fan%u low limit set minimum %u\n",386386+ nr + 1, FAN_FROM_REG(254, 1 << new_div));387387+388388+ } else {389389+ unsigned int new_min = 1350000 / val;390390+391391+ new_div = 0;392392+ while (new_min > 192 && new_div < 3) {393393+ new_div++;394394+ new_min /= 2;395395+ }396396+ if (!new_min) /* keep > 0 */397397+ new_min++;398398+399399+ data->fan_min[nr] = new_min;400400+401401+ dev_dbg(&client->dev, "fan%u low limit set fan speed %u\n",402402+ nr + 1, FAN_FROM_REG(new_min, 1 << new_div));403403+ }404404+405405+ if (new_div != data->fan_div[nr]) {406406+ data->fan_div[nr] = new_div;407407+ adm9240_write_fan_div(client, nr, new_div);408408+ }409409+ adm9240_write_value(client, ADM9240_REG_FAN_MIN(nr),410410+ data->fan_min[nr]);411411+412412+ up(&data->update_lock);413413+ return count;414414+}415415+416416+#define show_fan_offset(offset) \417417+static ssize_t show_fan_##offset (struct device *dev, \418418+ struct device_attribute *attr, \419419+ char *buf) \420420+{ \421421+return show_fan(dev, buf, offset - 1); \422422+} \423423+static ssize_t show_fan_##offset##_div (struct device *dev, \424424+ struct device_attribute *attr, \425425+ char *buf) \426426+{ \427427+return show_fan_div(dev, buf, offset - 1); \428428+} \429429+static ssize_t show_fan_##offset##_min (struct device *dev, \430430+ struct device_attribute *attr, \431431+ char *buf) \432432+{ \433433+return show_fan_min(dev, buf, offset - 1); \434434+} \435435+static ssize_t set_fan_##offset##_min (struct device *dev, \436436+ struct device_attribute *attr, \437437+ const char *buf, size_t count) \438438+{ \439439+return set_fan_min(dev, buf, count, offset - 1); \440440+} \441441+static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \442442+ show_fan_##offset, NULL); \443443+static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \444444+ show_fan_##offset##_div, NULL); \445445+static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \446446+ show_fan_##offset##_min, set_fan_##offset##_min);447447+448448+show_fan_offset(1);449449+show_fan_offset(2);450450+451451+/* alarms */452452+static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)453453+{454454+ struct adm9240_data *data = adm9240_update_device(dev);455455+ return sprintf(buf, "%u\n", data->alarms);456456+}457457+static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);458458+459459+/* vid */460460+static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)461461+{462462+ struct adm9240_data *data = adm9240_update_device(dev);463463+ return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm));464464+}465465+static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);466466+467467+/* analog output */468468+static ssize_t show_aout(struct device *dev, struct device_attribute *attr, char *buf)469469+{470470+ struct adm9240_data *data = adm9240_update_device(dev);471471+ return sprintf(buf, "%d\n", AOUT_FROM_REG(data->aout));472472+}473473+474474+static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)475475+{476476+ struct i2c_client *client = to_i2c_client(dev);477477+ struct adm9240_data *data = i2c_get_clientdata(client);478478+ unsigned long val = simple_strtol(buf, NULL, 10);479479+480480+ down(&data->update_lock);481481+ data->aout = AOUT_TO_REG(val);482482+ adm9240_write_value(client, ADM9240_REG_ANALOG_OUT, data->aout);483483+ up(&data->update_lock);484484+ return count;485485+}486486+static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);487487+488488+/* chassis_clear */489489+static ssize_t chassis_clear(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)490490+{491491+ struct i2c_client *client = to_i2c_client(dev);492492+ unsigned long val = simple_strtol(buf, NULL, 10);493493+494494+ if (val == 1) {495495+ adm9240_write_value(client, ADM9240_REG_CHASSIS_CLEAR, 0x80);496496+ dev_dbg(&client->dev, "chassis intrusion latch cleared\n");497497+ }498498+ return count;499499+}500500+static DEVICE_ATTR(chassis_clear, S_IWUSR, NULL, chassis_clear);501501+502502+503503+/*** sensor chip detect and driver install ***/504504+505505+static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)506506+{507507+ struct i2c_client *new_client;508508+ struct adm9240_data *data;509509+ int err = 0;510510+ const char *name = "";511511+ u8 man_id, die_rev;512512+513513+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))514514+ goto exit;515515+516516+ if (!(data = kmalloc(sizeof(struct adm9240_data), GFP_KERNEL))) {517517+ err = -ENOMEM;518518+ goto exit;519519+ }520520+ memset(data, 0, sizeof(struct adm9240_data));521521+522522+ new_client = &data->client;523523+ i2c_set_clientdata(new_client, data);524524+ new_client->addr = address;525525+ new_client->adapter = adapter;526526+ new_client->driver = &adm9240_driver;527527+ new_client->flags = 0;528528+529529+ if (kind == 0) {530530+ kind = adm9240;531531+ }532532+533533+ if (kind < 0) {534534+535535+ /* verify chip: reg address should match i2c address */536536+ if (adm9240_read_value(new_client, ADM9240_REG_I2C_ADDR)537537+ != address) {538538+ dev_err(&adapter->dev, "detect fail: address match, "539539+ "0x%02x\n", address);540540+ goto exit_free;541541+ }542542+543543+ /* check known chip manufacturer */544544+ man_id = adm9240_read_value(new_client, ADM9240_REG_MAN_ID);545545+546546+ if (man_id == 0x23) {547547+ kind = adm9240;548548+ } else if (man_id == 0xda) {549549+ kind = ds1780;550550+ } else if (man_id == 0x01) {551551+ kind = lm81;552552+ } else {553553+ dev_err(&adapter->dev, "detect fail: unknown manuf, "554554+ "0x%02x\n", man_id);555555+ goto exit_free;556556+ }557557+558558+ /* successful detect, print chip info */559559+ die_rev = adm9240_read_value(new_client, ADM9240_REG_DIE_REV);560560+ dev_info(&adapter->dev, "found %s revision %u\n",561561+ man_id == 0x23 ? "ADM9240" :562562+ man_id == 0xda ? "DS1780" : "LM81", die_rev);563563+ }564564+565565+ /* either forced or detected chip kind */566566+ if (kind == adm9240) {567567+ name = "adm9240";568568+ } else if (kind == ds1780) {569569+ name = "ds1780";570570+ } else if (kind == lm81) {571571+ name = "lm81";572572+ }573573+574574+ /* fill in the remaining client fields and attach */575575+ strlcpy(new_client->name, name, I2C_NAME_SIZE);576576+ data->type = kind;577577+ init_MUTEX(&data->update_lock);578578+579579+ if ((err = i2c_attach_client(new_client)))580580+ goto exit_free;581581+582582+ adm9240_init_client(new_client);583583+584584+ /* populate sysfs filesystem */585585+ device_create_file(&new_client->dev, &dev_attr_in0_input);586586+ device_create_file(&new_client->dev, &dev_attr_in0_min);587587+ device_create_file(&new_client->dev, &dev_attr_in0_max);588588+ device_create_file(&new_client->dev, &dev_attr_in1_input);589589+ device_create_file(&new_client->dev, &dev_attr_in1_min);590590+ device_create_file(&new_client->dev, &dev_attr_in1_max);591591+ device_create_file(&new_client->dev, &dev_attr_in2_input);592592+ device_create_file(&new_client->dev, &dev_attr_in2_min);593593+ device_create_file(&new_client->dev, &dev_attr_in2_max);594594+ device_create_file(&new_client->dev, &dev_attr_in3_input);595595+ device_create_file(&new_client->dev, &dev_attr_in3_min);596596+ device_create_file(&new_client->dev, &dev_attr_in3_max);597597+ device_create_file(&new_client->dev, &dev_attr_in4_input);598598+ device_create_file(&new_client->dev, &dev_attr_in4_min);599599+ device_create_file(&new_client->dev, &dev_attr_in4_max);600600+ device_create_file(&new_client->dev, &dev_attr_in5_input);601601+ device_create_file(&new_client->dev, &dev_attr_in5_min);602602+ device_create_file(&new_client->dev, &dev_attr_in5_max);603603+ device_create_file(&new_client->dev, &dev_attr_temp1_max);604604+ device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);605605+ device_create_file(&new_client->dev, &dev_attr_temp1_input);606606+ device_create_file(&new_client->dev, &dev_attr_fan1_input);607607+ device_create_file(&new_client->dev, &dev_attr_fan1_div);608608+ device_create_file(&new_client->dev, &dev_attr_fan1_min);609609+ device_create_file(&new_client->dev, &dev_attr_fan2_input);610610+ device_create_file(&new_client->dev, &dev_attr_fan2_div);611611+ device_create_file(&new_client->dev, &dev_attr_fan2_min);612612+ device_create_file(&new_client->dev, &dev_attr_alarms);613613+ device_create_file(&new_client->dev, &dev_attr_aout_output);614614+ device_create_file(&new_client->dev, &dev_attr_chassis_clear);615615+ device_create_file(&new_client->dev, &dev_attr_cpu0_vid);616616+617617+ return 0;618618+exit_free:619619+ kfree(new_client);620620+exit:621621+ return err;622622+}623623+624624+static int adm9240_attach_adapter(struct i2c_adapter *adapter)625625+{626626+ if (!(adapter->class & I2C_CLASS_HWMON))627627+ return 0;628628+ return i2c_detect(adapter, &addr_data, adm9240_detect);629629+}630630+631631+static int adm9240_detach_client(struct i2c_client *client)632632+{633633+ int err;634634+635635+ if ((err = i2c_detach_client(client))) {636636+ dev_err(&client->dev, "Client deregistration failed, "637637+ "client not detached.\n");638638+ return err;639639+ }640640+641641+ kfree(i2c_get_clientdata(client));642642+ return 0;643643+}644644+645645+static void adm9240_init_client(struct i2c_client *client)646646+{647647+ struct adm9240_data *data = i2c_get_clientdata(client);648648+ u8 conf = adm9240_read_value(client, ADM9240_REG_CONFIG);649649+ u8 mode = adm9240_read_value(client, ADM9240_REG_TEMP_CONF) & 3;650650+651651+ data->vrm = i2c_which_vrm(); /* need this to report vid as mV */652652+653653+ dev_info(&client->dev, "Using VRM: %d.%d\n", data->vrm / 10,654654+ data->vrm % 10);655655+656656+ if (conf & 1) { /* measurement cycle running: report state */657657+658658+ dev_info(&client->dev, "status: config 0x%02x mode %u\n",659659+ conf, mode);660660+661661+ } else { /* cold start: open limits before starting chip */662662+ int i;663663+664664+ for (i = 0; i < 6; i++)665665+ {666666+ adm9240_write_value(client,667667+ ADM9240_REG_IN_MIN(i), 0);668668+ adm9240_write_value(client,669669+ ADM9240_REG_IN_MAX(i), 255);670670+ }671671+ adm9240_write_value(client, ADM9240_REG_FAN_MIN(0), 255);672672+ adm9240_write_value(client, ADM9240_REG_FAN_MIN(1), 255);673673+ adm9240_write_value(client, ADM9240_REG_TEMP_HIGH, 127);674674+ adm9240_write_value(client, ADM9240_REG_TEMP_HYST, 127);675675+676676+ /* start measurement cycle */677677+ adm9240_write_value(client, ADM9240_REG_CONFIG, 1);678678+679679+ dev_info(&client->dev, "cold start: config was 0x%02x "680680+ "mode %u\n", conf, mode);681681+ }682682+}683683+684684+static struct adm9240_data *adm9240_update_device(struct device *dev)685685+{686686+ struct i2c_client *client = to_i2c_client(dev);687687+ struct adm9240_data *data = i2c_get_clientdata(client);688688+ int i;689689+690690+ down(&data->update_lock);691691+692692+ /* minimum measurement cycle: 1.75 seconds */693693+ if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4))694694+ || !data->valid) {695695+696696+ for (i = 0; i < 6; i++) /* read voltages */697697+ {698698+ data->in[i] = adm9240_read_value(client,699699+ ADM9240_REG_IN(i));700700+ }701701+ data->alarms = adm9240_read_value(client,702702+ ADM9240_REG_INT(0)) |703703+ adm9240_read_value(client,704704+ ADM9240_REG_INT(1)) << 8;705705+706706+ /* read temperature: assume temperature changes less than707707+ * 0.5'C per two measurement cycles thus ignore possible708708+ * but unlikely aliasing error on lsb reading. --Grant */709709+ data->temp = ((adm9240_read_value(client,710710+ ADM9240_REG_TEMP) << 8) |711711+ adm9240_read_value(client,712712+ ADM9240_REG_TEMP_CONF)) / 128;713713+714714+ for (i = 0; i < 2; i++) /* read fans */715715+ {716716+ data->fan[i] = adm9240_read_value(client,717717+ ADM9240_REG_FAN(i));718718+719719+ /* adjust fan clock divider on overflow */720720+ if (data->valid && data->fan[i] == 255 &&721721+ data->fan_div[i] < 3) {722722+723723+ adm9240_write_fan_div(client, i,724724+ ++data->fan_div[i]);725725+726726+ /* adjust fan_min if active, but not to 0 */727727+ if (data->fan_min[i] < 255 &&728728+ data->fan_min[i] >= 2)729729+ data->fan_min[i] /= 2;730730+ }731731+ }732732+ data->last_updated_measure = jiffies;733733+ }734734+735735+ /* minimum config reading cycle: 300 seconds */736736+ if (time_after(jiffies, data->last_updated_config + (HZ * 300))737737+ || !data->valid) {738738+739739+ for (i = 0; i < 6; i++)740740+ {741741+ data->in_min[i] = adm9240_read_value(client,742742+ ADM9240_REG_IN_MIN(i));743743+ data->in_max[i] = adm9240_read_value(client,744744+ ADM9240_REG_IN_MAX(i));745745+ }746746+ for (i = 0; i < 2; i++)747747+ {748748+ data->fan_min[i] = adm9240_read_value(client,749749+ ADM9240_REG_FAN_MIN(i));750750+ }751751+ data->temp_high = adm9240_read_value(client,752752+ ADM9240_REG_TEMP_HIGH);753753+ data->temp_hyst = adm9240_read_value(client,754754+ ADM9240_REG_TEMP_HYST);755755+756756+ /* read fan divs and 5-bit VID */757757+ i = adm9240_read_value(client, ADM9240_REG_VID_FAN_DIV);758758+ data->fan_div[0] = (i >> 4) & 3;759759+ data->fan_div[1] = (i >> 6) & 3;760760+ data->vid = i & 0x0f;761761+ data->vid |= (adm9240_read_value(client,762762+ ADM9240_REG_VID4) & 1) << 4;763763+ /* read analog out */764764+ data->aout = adm9240_read_value(client,765765+ ADM9240_REG_ANALOG_OUT);766766+767767+ data->last_updated_config = jiffies;768768+ data->valid = 1;769769+ }770770+ up(&data->update_lock);771771+ return data;772772+}773773+774774+static int __init sensors_adm9240_init(void)775775+{776776+ return i2c_add_driver(&adm9240_driver);777777+}778778+779779+static void __exit sensors_adm9240_exit(void)780780+{781781+ i2c_del_driver(&adm9240_driver);782782+}783783+784784+MODULE_AUTHOR("Michiel Rook <michiel@grendelproject.nl>, "785785+ "Grant Coady <gcoady@gmail.com> and others");786786+MODULE_DESCRIPTION("ADM9240/DS1780/LM81 driver");787787+MODULE_LICENSE("GPL");788788+789789+module_init(sensors_adm9240_init);790790+module_exit(sensors_adm9240_exit);791791+
···11+/*22+ atxp1.c - kernel module for setting CPU VID and general purpose33+ I/Os using the Attansic ATXP1 chip.44+55+ This program is free software; you can redistribute it and/or modify66+ it under the terms of the GNU General Public License as published by77+ the Free Software Foundation; either version 2 of the License, or88+ (at your option) any later version.99+1010+ This program is distributed in the hope that it will be useful,1111+ but WITHOUT ANY WARRANTY; without even the implied warranty of1212+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1313+ GNU General Public License for more details.1414+1515+ You should have received a copy of the GNU General Public License1616+ along with this program; if not, write to the Free Software1717+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.1818+1919+*/2020+2121+#include <linux/kernel.h>2222+#include <linux/init.h>2323+#include <linux/module.h>2424+#include <linux/i2c.h>2525+#include <linux/i2c-sensor.h>2626+#include <linux/i2c-vid.h>2727+2828+MODULE_LICENSE("GPL");2929+MODULE_DESCRIPTION("System voltages control via Attansic ATXP1");3030+MODULE_VERSION("0.6.2");3131+MODULE_AUTHOR("Sebastian Witt <se.witt@gmx.net>");3232+3333+#define ATXP1_VID 0x003434+#define ATXP1_CVID 0x013535+#define ATXP1_GPIO1 0x063636+#define ATXP1_GPIO2 0x0a3737+#define ATXP1_VIDENA 0x203838+#define ATXP1_VIDMASK 0x1f3939+#define ATXP1_GPIO1MASK 0x0f4040+4141+static unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END };4242+static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };4343+4444+SENSORS_INSMOD_1(atxp1);4545+4646+static int atxp1_attach_adapter(struct i2c_adapter * adapter);4747+static int atxp1_detach_client(struct i2c_client * client);4848+static struct atxp1_data * atxp1_update_device(struct device *dev);4949+static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind);5050+5151+static struct i2c_driver atxp1_driver = {5252+ .owner = THIS_MODULE,5353+ .name = "atxp1",5454+ .flags = I2C_DF_NOTIFY,5555+ .attach_adapter = atxp1_attach_adapter,5656+ .detach_client = atxp1_detach_client,5757+};5858+5959+struct atxp1_data {6060+ struct i2c_client client;6161+ struct semaphore update_lock;6262+ unsigned long last_updated;6363+ u8 valid;6464+ struct {6565+ u8 vid; /* VID output register */6666+ u8 cpu_vid; /* VID input from CPU */6767+ u8 gpio1; /* General purpose I/O register 1 */6868+ u8 gpio2; /* General purpose I/O register 2 */6969+ } reg;7070+ u8 vrm; /* Detected CPU VRM */7171+};7272+7373+static struct atxp1_data * atxp1_update_device(struct device *dev)7474+{7575+ struct i2c_client *client;7676+ struct atxp1_data *data;7777+7878+ client = to_i2c_client(dev);7979+ data = i2c_get_clientdata(client);8080+8181+ down(&data->update_lock);8282+8383+ if ((jiffies - data->last_updated > HZ) ||8484+ (jiffies < data->last_updated) ||8585+ !data->valid) {8686+8787+ /* Update local register data */8888+ data->reg.vid = i2c_smbus_read_byte_data(client, ATXP1_VID);8989+ data->reg.cpu_vid = i2c_smbus_read_byte_data(client, ATXP1_CVID);9090+ data->reg.gpio1 = i2c_smbus_read_byte_data(client, ATXP1_GPIO1);9191+ data->reg.gpio2 = i2c_smbus_read_byte_data(client, ATXP1_GPIO2);9292+9393+ data->valid = 1;9494+ }9595+9696+ up(&data->update_lock);9797+9898+ return(data);9999+}100100+101101+/* sys file functions for cpu0_vid */102102+static ssize_t atxp1_showvcore(struct device *dev, struct device_attribute *attr, char *buf)103103+{104104+ int size;105105+ struct atxp1_data *data;106106+107107+ data = atxp1_update_device(dev);108108+109109+ size = sprintf(buf, "%d\n", vid_from_reg(data->reg.vid & ATXP1_VIDMASK, data->vrm));110110+111111+ return size;112112+}113113+114114+static ssize_t atxp1_storevcore(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)115115+{116116+ struct atxp1_data *data;117117+ struct i2c_client *client;118118+ char vid;119119+ char cvid;120120+ unsigned int vcore;121121+122122+ client = to_i2c_client(dev);123123+ data = atxp1_update_device(dev);124124+125125+ vcore = simple_strtoul(buf, NULL, 10);126126+ vcore /= 25;127127+ vcore *= 25;128128+129129+ /* Calculate VID */130130+ vid = vid_to_reg(vcore, data->vrm);131131+132132+ if (vid < 0) {133133+ dev_err(dev, "VID calculation failed.\n");134134+ return -1;135135+ }136136+137137+ /* If output enabled, use control register value. Otherwise original CPU VID */138138+ if (data->reg.vid & ATXP1_VIDENA)139139+ cvid = data->reg.vid & ATXP1_VIDMASK;140140+ else141141+ cvid = data->reg.cpu_vid;142142+143143+ /* Nothing changed, aborting */144144+ if (vid == cvid)145145+ return count;146146+147147+ dev_info(dev, "Setting VCore to %d mV (0x%02x)\n", vcore, vid);148148+149149+ /* Write every 25 mV step to increase stability */150150+ if (cvid > vid) {151151+ for (; cvid >= vid; cvid--) {152152+ i2c_smbus_write_byte_data(client, ATXP1_VID, cvid | ATXP1_VIDENA);153153+ }154154+ }155155+ else {156156+ for (; cvid <= vid; cvid++) {157157+ i2c_smbus_write_byte_data(client, ATXP1_VID, cvid | ATXP1_VIDENA);158158+ }159159+ }160160+161161+ data->valid = 0;162162+163163+ return count;164164+}165165+166166+/* CPU core reference voltage167167+ unit: millivolt168168+*/169169+static DEVICE_ATTR(cpu0_vid, S_IRUGO | S_IWUSR, atxp1_showvcore, atxp1_storevcore);170170+171171+/* sys file functions for GPIO1 */172172+static ssize_t atxp1_showgpio1(struct device *dev, struct device_attribute *attr, char *buf)173173+{174174+ int size;175175+ struct atxp1_data *data;176176+177177+ data = atxp1_update_device(dev);178178+179179+ size = sprintf(buf, "0x%02x\n", data->reg.gpio1 & ATXP1_GPIO1MASK);180180+181181+ return size;182182+}183183+184184+static ssize_t atxp1_storegpio1(struct device *dev, struct device_attribute *attr, const char*buf, size_t count)185185+{186186+ struct atxp1_data *data;187187+ struct i2c_client *client;188188+ unsigned int value;189189+190190+ client = to_i2c_client(dev);191191+ data = atxp1_update_device(dev);192192+193193+ value = simple_strtoul(buf, NULL, 16);194194+195195+ value &= ATXP1_GPIO1MASK;196196+197197+ if (value != (data->reg.gpio1 & ATXP1_GPIO1MASK)) {198198+ dev_info(dev, "Writing 0x%x to GPIO1.\n", value);199199+200200+ i2c_smbus_write_byte_data(client, ATXP1_GPIO1, value);201201+202202+ data->valid = 0;203203+ }204204+205205+ return count;206206+}207207+208208+/* GPIO1 data register209209+ unit: Four bit as hex (e.g. 0x0f)210210+*/211211+static DEVICE_ATTR(gpio1, S_IRUGO | S_IWUSR, atxp1_showgpio1, atxp1_storegpio1);212212+213213+/* sys file functions for GPIO2 */214214+static ssize_t atxp1_showgpio2(struct device *dev, struct device_attribute *attr, char *buf)215215+{216216+ int size;217217+ struct atxp1_data *data;218218+219219+ data = atxp1_update_device(dev);220220+221221+ size = sprintf(buf, "0x%02x\n", data->reg.gpio2);222222+223223+ return size;224224+}225225+226226+static ssize_t atxp1_storegpio2(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)227227+{228228+ struct atxp1_data *data;229229+ struct i2c_client *client;230230+ unsigned int value;231231+232232+ client = to_i2c_client(dev);233233+ data = atxp1_update_device(dev);234234+235235+ value = simple_strtoul(buf, NULL, 16) & 0xff;236236+237237+ if (value != data->reg.gpio2) {238238+ dev_info(dev, "Writing 0x%x to GPIO1.\n", value);239239+240240+ i2c_smbus_write_byte_data(client, ATXP1_GPIO2, value);241241+242242+ data->valid = 0;243243+ }244244+245245+ return count;246246+}247247+248248+/* GPIO2 data register249249+ unit: Eight bit as hex (e.g. 0xff)250250+*/251251+static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2);252252+253253+254254+static int atxp1_attach_adapter(struct i2c_adapter *adapter)255255+{256256+ return i2c_detect(adapter, &addr_data, &atxp1_detect);257257+};258258+259259+static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)260260+{261261+ struct i2c_client * new_client;262262+ struct atxp1_data * data;263263+ int err = 0;264264+ u8 temp;265265+266266+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))267267+ goto exit;268268+269269+ if (!(data = kmalloc(sizeof(struct atxp1_data), GFP_KERNEL))) {270270+ err = -ENOMEM;271271+ goto exit;272272+ }273273+274274+ memset(data, 0, sizeof(struct atxp1_data));275275+ new_client = &data->client;276276+ i2c_set_clientdata(new_client, data);277277+278278+ new_client->addr = address;279279+ new_client->adapter = adapter;280280+ new_client->driver = &atxp1_driver;281281+ new_client->flags = 0;282282+283283+ /* Detect ATXP1, checking if vendor ID registers are all zero */284284+ if (!((i2c_smbus_read_byte_data(new_client, 0x3e) == 0) &&285285+ (i2c_smbus_read_byte_data(new_client, 0x3f) == 0) &&286286+ (i2c_smbus_read_byte_data(new_client, 0xfe) == 0) &&287287+ (i2c_smbus_read_byte_data(new_client, 0xff) == 0) )) {288288+289289+ /* No vendor ID, now checking if registers 0x10,0x11 (non-existent)290290+ * showing the same as register 0x00 */291291+ temp = i2c_smbus_read_byte_data(new_client, 0x00);292292+293293+ if (!((i2c_smbus_read_byte_data(new_client, 0x10) == temp) &&294294+ (i2c_smbus_read_byte_data(new_client, 0x11) == temp) ))295295+ goto exit_free;296296+ }297297+298298+ /* Get VRM */299299+ data->vrm = i2c_which_vrm();300300+301301+ if ((data->vrm != 90) && (data->vrm != 91)) {302302+ dev_err(&new_client->dev, "Not supporting VRM %d.%d\n",303303+ data->vrm / 10, data->vrm % 10);304304+ goto exit_free;305305+ }306306+307307+ strncpy(new_client->name, "atxp1", I2C_NAME_SIZE);308308+309309+ data->valid = 0;310310+311311+ init_MUTEX(&data->update_lock);312312+313313+ err = i2c_attach_client(new_client);314314+315315+ if (err)316316+ {317317+ dev_err(&new_client->dev, "Attach client error.\n");318318+ goto exit_free;319319+ }320320+321321+ device_create_file(&new_client->dev, &dev_attr_gpio1);322322+ device_create_file(&new_client->dev, &dev_attr_gpio2);323323+ device_create_file(&new_client->dev, &dev_attr_cpu0_vid);324324+325325+ dev_info(&new_client->dev, "Using VRM: %d.%d\n",326326+ data->vrm / 10, data->vrm % 10);327327+328328+ return 0;329329+330330+exit_free:331331+ kfree(data);332332+exit:333333+ return err;334334+};335335+336336+static int atxp1_detach_client(struct i2c_client * client)337337+{338338+ int err;339339+340340+ err = i2c_detach_client(client);341341+342342+ if (err)343343+ dev_err(&client->dev, "Failed to detach client.\n");344344+ else345345+ kfree(i2c_get_clientdata(client));346346+347347+ return err;348348+};349349+350350+static int __init atxp1_init(void)351351+{352352+ return i2c_add_driver(&atxp1_driver);353353+};354354+355355+static void __exit atxp1_exit(void)356356+{357357+ i2c_del_driver(&atxp1_driver);358358+};359359+360360+module_init(atxp1_init);361361+module_exit(atxp1_exit);
+40-57
drivers/i2c/chips/ds1337.c
···33 *44 * Copyright (C) 2005 James Chapman <jchapman@katalix.com>55 *66- * based on linux/drivers/acron/char/pcf8583.c66+ * based on linux/drivers/acorn/char/pcf8583.c77 * Copyright (C) 2000 Russell King88 *99 * This program is free software; you can redistribute it and/or modify1010 * it under the terms of the GNU General Public License version 2 as1111 * published by the Free Software Foundation.1212 *1313- * Driver for Dallas Semiconductor DS1337 real time clock chip1313+ * Driver for Dallas Semiconductor DS1337 and DS1339 real time clock chip1414 */15151616-#include <linux/config.h>1716#include <linux/module.h>1817#include <linux/init.h>1918#include <linux/slab.h>···6869struct ds1337_data {6970 struct i2c_client client;7071 struct list_head list;7171- int id;7272};73737474/*7575 * Internal variables7676 */7777-static int ds1337_id;7877static LIST_HEAD(ds1337_clients);79788079static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value)···9295 */9396static int ds1337_get_datetime(struct i2c_client *client, struct rtc_time *dt)9497{9595- struct ds1337_data *data = i2c_get_clientdata(client);9698 int result;9799 u8 buf[7];98100 u8 val;···99103 u8 offs = 0;100104101105 if (!dt) {102102- dev_dbg(&client->adapter->dev, "%s: EINVAL: dt=NULL\n",103103- __FUNCTION__);104104-106106+ dev_dbg(&client->dev, "%s: EINVAL: dt=NULL\n", __FUNCTION__);105107 return -EINVAL;106108 }107109···113119 msg[1].len = sizeof(buf);114120 msg[1].buf = &buf[0];115121116116- result = client->adapter->algo->master_xfer(client->adapter,117117- &msg[0], 2);122122+ result = i2c_transfer(client->adapter, msg, 2);118123119119- dev_dbg(&client->adapter->dev,120120- "%s: [%d] %02x %02x %02x %02x %02x %02x %02x\n",124124+ dev_dbg(&client->dev, "%s: [%d] %02x %02x %02x %02x %02x %02x %02x\n",121125 __FUNCTION__, result, buf[0], buf[1], buf[2], buf[3],122126 buf[4], buf[5], buf[6]);123127124124- if (result >= 0) {125125- dt->tm_sec = BCD_TO_BIN(buf[0]);126126- dt->tm_min = BCD_TO_BIN(buf[1]);128128+ if (result == 2) {129129+ dt->tm_sec = BCD2BIN(buf[0]);130130+ dt->tm_min = BCD2BIN(buf[1]);127131 val = buf[2] & 0x3f;128128- dt->tm_hour = BCD_TO_BIN(val);129129- dt->tm_wday = BCD_TO_BIN(buf[3]) - 1;130130- dt->tm_mday = BCD_TO_BIN(buf[4]);132132+ dt->tm_hour = BCD2BIN(val);133133+ dt->tm_wday = BCD2BIN(buf[3]) - 1;134134+ dt->tm_mday = BCD2BIN(buf[4]);131135 val = buf[5] & 0x7f;132132- dt->tm_mon = BCD_TO_BIN(val);133133- dt->tm_year = 1900 + BCD_TO_BIN(buf[6]);136136+ dt->tm_mon = BCD2BIN(val) - 1;137137+ dt->tm_year = BCD2BIN(buf[6]);134138 if (buf[5] & 0x80)135139 dt->tm_year += 100;136140137137- dev_dbg(&client->adapter->dev, "%s: secs=%d, mins=%d, "141141+ dev_dbg(&client->dev, "%s: secs=%d, mins=%d, "138142 "hours=%d, mday=%d, mon=%d, year=%d, wday=%d\n",139143 __FUNCTION__, dt->tm_sec, dt->tm_min,140144 dt->tm_hour, dt->tm_mday,141145 dt->tm_mon, dt->tm_year, dt->tm_wday);142142- } else {143143- dev_err(&client->adapter->dev, "ds1337[%d]: error reading "144144- "data! %d\n", data->id, result);145145- result = -EIO;146146+147147+ return 0;146148 }147149148148- return result;150150+ dev_err(&client->dev, "error reading data! %d\n", result);151151+ return -EIO;149152}150153151154static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt)152155{153153- struct ds1337_data *data = i2c_get_clientdata(client);154156 int result;155157 u8 buf[8];156158 u8 val;157159 struct i2c_msg msg[1];158160159161 if (!dt) {160160- dev_dbg(&client->adapter->dev, "%s: EINVAL: dt=NULL\n",161161- __FUNCTION__);162162-162162+ dev_dbg(&client->dev, "%s: EINVAL: dt=NULL\n", __FUNCTION__);163163 return -EINVAL;164164 }165165166166- dev_dbg(&client->adapter->dev, "%s: secs=%d, mins=%d, hours=%d, "166166+ dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, "167167 "mday=%d, mon=%d, year=%d, wday=%d\n", __FUNCTION__,168168 dt->tm_sec, dt->tm_min, dt->tm_hour,169169 dt->tm_mday, dt->tm_mon, dt->tm_year, dt->tm_wday);170170171171 buf[0] = 0; /* reg offset */172172- buf[1] = BIN_TO_BCD(dt->tm_sec);173173- buf[2] = BIN_TO_BCD(dt->tm_min);174174- buf[3] = BIN_TO_BCD(dt->tm_hour) | (1 << 6);175175- buf[4] = BIN_TO_BCD(dt->tm_wday) + 1;176176- buf[5] = BIN_TO_BCD(dt->tm_mday);177177- buf[6] = BIN_TO_BCD(dt->tm_mon);178178- if (dt->tm_year >= 2000) {179179- val = dt->tm_year - 2000;172172+ buf[1] = BIN2BCD(dt->tm_sec);173173+ buf[2] = BIN2BCD(dt->tm_min);174174+ buf[3] = BIN2BCD(dt->tm_hour) | (1 << 6);175175+ buf[4] = BIN2BCD(dt->tm_wday) + 1;176176+ buf[5] = BIN2BCD(dt->tm_mday);177177+ buf[6] = BIN2BCD(dt->tm_mon) + 1;178178+ val = dt->tm_year;179179+ if (val >= 100) {180180+ val -= 100;180181 buf[6] |= (1 << 7);181181- } else {182182- val = dt->tm_year - 1900;183182 }184184- buf[7] = BIN_TO_BCD(val);183183+ buf[7] = BIN2BCD(val);185184186185 msg[0].addr = client->addr;187186 msg[0].flags = 0;188187 msg[0].len = sizeof(buf);189188 msg[0].buf = &buf[0];190189191191- result = client->adapter->algo->master_xfer(client->adapter,192192- &msg[0], 1);193193- if (result < 0) {194194- dev_err(&client->adapter->dev, "ds1337[%d]: error "195195- "writing data! %d\n", data->id, result);196196- result = -EIO;197197- } else {198198- result = 0;199199- }190190+ result = i2c_transfer(client->adapter, msg, 1);191191+ if (result == 1)192192+ return 0;200193201201- return result;194194+ dev_err(&client->dev, "error writing data! %d\n", result);195195+ return -EIO;202196}203197204198static int ds1337_command(struct i2c_client *client, unsigned int cmd,205199 void *arg)206200{207207- dev_dbg(&client->adapter->dev, "%s: cmd=%d\n", __FUNCTION__, cmd);201201+ dev_dbg(&client->dev, "%s: cmd=%d\n", __FUNCTION__, cmd);208202209203 switch (cmd) {210204 case DS1337_GET_DATE:···210228 * Public API for access to specific device. Useful for low-level211229 * RTC access from kernel code.212230 */213213-int ds1337_do_command(int id, int cmd, void *arg)231231+int ds1337_do_command(int bus, int cmd, void *arg)214232{215233 struct list_head *walk;216234 struct list_head *tmp;···218236219237 list_for_each_safe(walk, tmp, &ds1337_clients) {220238 data = list_entry(walk, struct ds1337_data, list);221221- if (data->id == id)239239+ if (data->client.adapter->nr == bus)222240 return ds1337_command(&data->client, cmd, arg);223241 }224242···328346 ds1337_init_client(new_client);329347330348 /* Add client to local list */331331- data->id = ds1337_id++;332349 list_add(&data->list, &ds1337_clients);333350334351 return 0;···378397MODULE_AUTHOR("James Chapman <jchapman@katalix.com>");379398MODULE_DESCRIPTION("DS1337 RTC driver");380399MODULE_LICENSE("GPL");400400+401401+EXPORT_SYMBOL_GPL(ds1337_do_command);381402382403module_init(ds1337_init);383404module_exit(ds1337_exit);
+260
drivers/i2c/chips/ds1374.c
···11+/*22+ * drivers/i2c/chips/ds1374.c33+ *44+ * I2C client/driver for the Maxim/Dallas DS1374 Real-Time Clock55+ *66+ * Author: Randy Vinson <rvinson@mvista.com>77+ *88+ * Based on the m41t00.c by Mark Greer <mgreer@mvista.com>99+ *1010+ * 2005 (c) MontaVista Software, Inc. This file is licensed under1111+ * the terms of the GNU General Public License version 2. This program1212+ * is licensed "as is" without any warranty of any kind, whether express1313+ * or implied.1414+ */1515+/*1616+ * This i2c client/driver wedges between the drivers/char/genrtc.c RTC1717+ * interface and the SMBus interface of the i2c subsystem.1818+ * It would be more efficient to use i2c msgs/i2c_transfer directly but, as1919+ * recommened in .../Documentation/i2c/writing-clients section2020+ * "Sending and receiving", using SMBus level communication is preferred.2121+ */2222+2323+#include <linux/kernel.h>2424+#include <linux/module.h>2525+#include <linux/interrupt.h>2626+#include <linux/i2c.h>2727+#include <linux/rtc.h>2828+#include <linux/bcd.h>2929+3030+#define DS1374_REG_TOD0 0x003131+#define DS1374_REG_TOD1 0x013232+#define DS1374_REG_TOD2 0x023333+#define DS1374_REG_TOD3 0x033434+#define DS1374_REG_WDALM0 0x043535+#define DS1374_REG_WDALM1 0x053636+#define DS1374_REG_WDALM2 0x063737+#define DS1374_REG_CR 0x073838+#define DS1374_REG_SR 0x083939+#define DS1374_REG_SR_OSF 0x804040+#define DS1374_REG_TCR 0x094141+4242+#define DS1374_DRV_NAME "ds1374"4343+4444+static DECLARE_MUTEX(ds1374_mutex);4545+4646+static struct i2c_driver ds1374_driver;4747+static struct i2c_client *save_client;4848+4949+static unsigned short ignore[] = { I2C_CLIENT_END };5050+static unsigned short normal_addr[] = { 0x68, I2C_CLIENT_END };5151+5252+static struct i2c_client_address_data addr_data = {5353+ .normal_i2c = normal_addr,5454+ .probe = ignore,5555+ .ignore = ignore,5656+ .force = ignore,5757+};5858+5959+static ulong ds1374_read_rtc(void)6060+{6161+ ulong time = 0;6262+ int reg = DS1374_REG_WDALM0;6363+6464+ while (reg--) {6565+ s32 tmp;6666+ if ((tmp = i2c_smbus_read_byte_data(save_client, reg)) < 0) {6767+ dev_warn(&save_client->dev,6868+ "can't read from rtc chip\n");6969+ return 0;7070+ }7171+ time = (time << 8) | (tmp & 0xff);7272+ }7373+ return time;7474+}7575+7676+static void ds1374_write_rtc(ulong time)7777+{7878+ int reg;7979+8080+ for (reg = DS1374_REG_TOD0; reg < DS1374_REG_WDALM0; reg++) {8181+ if (i2c_smbus_write_byte_data(save_client, reg, time & 0xff)8282+ < 0) {8383+ dev_warn(&save_client->dev,8484+ "can't write to rtc chip\n");8585+ break;8686+ }8787+ time = time >> 8;8888+ }8989+}9090+9191+static void ds1374_check_rtc_status(void)9292+{9393+ s32 tmp;9494+9595+ tmp = i2c_smbus_read_byte_data(save_client, DS1374_REG_SR);9696+ if (tmp < 0) {9797+ dev_warn(&save_client->dev,9898+ "can't read status from rtc chip\n");9999+ return;100100+ }101101+ if (tmp & DS1374_REG_SR_OSF) {102102+ dev_warn(&save_client->dev,103103+ "oscillator discontinuity flagged, time unreliable\n");104104+ tmp &= ~DS1374_REG_SR_OSF;105105+ tmp = i2c_smbus_write_byte_data(save_client, DS1374_REG_SR,106106+ tmp & 0xff);107107+ if (tmp < 0)108108+ dev_warn(&save_client->dev,109109+ "can't clear discontinuity notification\n");110110+ }111111+}112112+113113+ulong ds1374_get_rtc_time(void)114114+{115115+ ulong t1, t2;116116+ int limit = 10; /* arbitrary retry limit */117117+118118+ down(&ds1374_mutex);119119+120120+ /*121121+ * Since the reads are being performed one byte at a time using122122+ * the SMBus vs a 4-byte i2c transfer, there is a chance that a123123+ * carry will occur during the read. To detect this, 2 reads are124124+ * performed and compared.125125+ */126126+ do {127127+ t1 = ds1374_read_rtc();128128+ t2 = ds1374_read_rtc();129129+ } while (t1 != t2 && limit--);130130+131131+ up(&ds1374_mutex);132132+133133+ if (t1 != t2) {134134+ dev_warn(&save_client->dev,135135+ "can't get consistent time from rtc chip\n");136136+ t1 = 0;137137+ }138138+139139+ return t1;140140+}141141+142142+static void ds1374_set_tlet(ulong arg)143143+{144144+ ulong t1, t2;145145+ int limit = 10; /* arbitrary retry limit */146146+147147+ t1 = *(ulong *) arg;148148+149149+ down(&ds1374_mutex);150150+151151+ /*152152+ * Since the writes are being performed one byte at a time using153153+ * the SMBus vs a 4-byte i2c transfer, there is a chance that a154154+ * carry will occur during the write. To detect this, the write155155+ * value is read back and compared.156156+ */157157+ do {158158+ ds1374_write_rtc(t1);159159+ t2 = ds1374_read_rtc();160160+ } while (t1 != t2 && limit--);161161+162162+ up(&ds1374_mutex);163163+164164+ if (t1 != t2)165165+ dev_warn(&save_client->dev,166166+ "can't confirm time set from rtc chip\n");167167+}168168+169169+ulong new_time;170170+171171+DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, (ulong) & new_time);172172+173173+int ds1374_set_rtc_time(ulong nowtime)174174+{175175+ new_time = nowtime;176176+177177+ if (in_interrupt())178178+ tasklet_schedule(&ds1374_tasklet);179179+ else180180+ ds1374_set_tlet((ulong) & new_time);181181+182182+ return 0;183183+}184184+185185+/*186186+ *****************************************************************************187187+ *188188+ * Driver Interface189189+ *190190+ *****************************************************************************191191+ */192192+static int ds1374_probe(struct i2c_adapter *adap, int addr, int kind)193193+{194194+ struct i2c_client *client;195195+ int rc;196196+197197+ client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);198198+ if (!client)199199+ return -ENOMEM;200200+201201+ memset(client, 0, sizeof(struct i2c_client));202202+ strncpy(client->name, DS1374_DRV_NAME, I2C_NAME_SIZE);203203+ client->flags = I2C_DF_NOTIFY;204204+ client->addr = addr;205205+ client->adapter = adap;206206+ client->driver = &ds1374_driver;207207+208208+ if ((rc = i2c_attach_client(client)) != 0) {209209+ kfree(client);210210+ return rc;211211+ }212212+213213+ save_client = client;214214+215215+ ds1374_check_rtc_status();216216+217217+ return 0;218218+}219219+220220+static int ds1374_attach(struct i2c_adapter *adap)221221+{222222+ return i2c_probe(adap, &addr_data, ds1374_probe);223223+}224224+225225+static int ds1374_detach(struct i2c_client *client)226226+{227227+ int rc;228228+229229+ if ((rc = i2c_detach_client(client)) == 0) {230230+ kfree(i2c_get_clientdata(client));231231+ tasklet_kill(&ds1374_tasklet);232232+ }233233+ return rc;234234+}235235+236236+static struct i2c_driver ds1374_driver = {237237+ .owner = THIS_MODULE,238238+ .name = DS1374_DRV_NAME,239239+ .id = I2C_DRIVERID_DS1374,240240+ .flags = I2C_DF_NOTIFY,241241+ .attach_adapter = ds1374_attach,242242+ .detach_client = ds1374_detach,243243+};244244+245245+static int __init ds1374_init(void)246246+{247247+ return i2c_add_driver(&ds1374_driver);248248+}249249+250250+static void __exit ds1374_exit(void)251251+{252252+ i2c_del_driver(&ds1374_driver);253253+}254254+255255+module_init(ds1374_init);256256+module_exit(ds1374_exit);257257+258258+MODULE_AUTHOR("Randy Vinson <rvinson@mvista.com>");259259+MODULE_DESCRIPTION("Maxim/Dallas DS1374 RTC I2C Client Driver");260260+MODULE_LICENSE("GPL");
+2-2
drivers/i2c/chips/ds1621.c
···121121static void ds1621_init_client(struct i2c_client *client)122122{123123 int reg = ds1621_read_value(client, DS1621_REG_CONF);124124- /* switch to continous conversion mode */124124+ /* switch to continuous conversion mode */125125 reg &= ~ DS1621_REG_CONFIG_1SHOT;126126127127 /* setup output polarity */···303303 data->temp_max = ds1621_read_value(client,304304 DS1621_REG_TEMP_MAX);305305306306- /* reset alarms if neccessary */306306+ /* reset alarms if necessary */307307 new_conf = data->conf;308308 if (data->temp < data->temp_min)309309 new_conf &= ~DS1621_ALARM_TEMP_LOW;
-1
drivers/i2c/chips/eeprom.c
···2626 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.2727*/28282929-#include <linux/config.h>3029#include <linux/kernel.h>3130#include <linux/init.h>3231#include <linux/module.h>
-1
drivers/i2c/chips/fscher.c
···2626 * and Philip Edelbrock <phil@netroedge.com>2727 */28282929-#include <linux/config.h>3029#include <linux/module.h>3130#include <linux/init.h>3231#include <linux/slab.h>
···1818 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.1919*/20202121-#include <linux/config.h>2221#include <linux/module.h>2322#include <linux/init.h>2423#include <linux/slab.h>
-1
drivers/i2c/chips/lm77.c
···2525 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.2626*/27272828-#include <linux/config.h>2928#include <linux/module.h>3029#include <linux/init.h>3130#include <linux/slab.h>
+2-3
drivers/i2c/chips/lm78.c
···1818 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.1919*/20202121-#include <linux/config.h>2221#include <linux/module.h>2322#include <linux/init.h>2423#include <linux/slab.h>···670671 return 0;671672}672673673673-/* The SMBus locks itself, but ISA access must be locked explicitely! 674674+/* The SMBus locks itself, but ISA access must be locked explicitly! 674675 We don't want to lock the whole ISA bus, so we lock each client675676 separately.676677 We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks,···689690 return i2c_smbus_read_byte_data(client, reg);690691}691692692692-/* The SMBus locks itself, but ISA access muse be locked explicitely! 693693+/* The SMBus locks itself, but ISA access muse be locked explicitly! 693694 We don't want to lock the whole ISA bus, so we lock each client694695 separately.695696 We ignore the LM78 BUSY flag at this moment - it could lead to deadlocks,
-1
drivers/i2c/chips/lm80.c
···2121 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.2222 */23232424-#include <linux/config.h>2524#include <linux/module.h>2625#include <linux/init.h>2726#include <linux/slab.h>
···2323 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.2424*/25252626-#include <linux/config.h>2726#include <linux/module.h>2827#include <linux/init.h>2928#include <linux/slab.h>···284285/* i2c-vid.h defines vid_from_reg() */285286#define VID_FROM_REG(val,vrm) (vid_from_reg((val),(vrm)))286287287287-#define ALARMS_FROM_REG(val) (val)288288-289288/* Unlike some other drivers we DO NOT set initial limits. Use290289 * the config file to set limits. Some users have reported291290 * motherboards shutting down when we set limits in a previous···478481static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)479482{480483 struct lm85_data *data = lm85_update_device(dev);481481- return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms));484484+ return sprintf(buf, "%u\n", data->alarms);482485}483486484487static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
-1
drivers/i2c/chips/lm87.c
···5252 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.5353 */54545555-#include <linux/config.h>5655#include <linux/module.h>5756#include <linux/init.h>5857#include <linux/slab.h>
+152-123
drivers/i2c/chips/lm90.c
···11/*22 * lm90.c - Part of lm_sensors, Linux kernel modules for hardware33 * monitoring44- * Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org>44+ * Copyright (C) 2003-2005 Jean Delvare <khali@linux-fr.org>55 *66 * Based on the lm83 driver. The LM90 is a sensor chip made by National77 * Semiconductor. It reports up to two temperatures (its own plus up to···1919 * Complete datasheets can be obtained from National's website at:2020 * http://www.national.com/pf/LM/LM89.html2121 * http://www.national.com/pf/LM/LM99.html2222- * Note that there is no way to differenciate between both chips.2222+ * Note that there is no way to differentiate between both chips.2323 *2424 * This driver also supports the LM86, another sensor chip made by2525 * National Semiconductor. It is exactly similar to the LM90 except it···3939 * chips made by Maxim. These chips are similar to the LM86. Complete4040 * datasheet can be obtained at Maxim's website at:4141 * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/25784242- * Note that there is no easy way to differenciate between the three4242+ * Note that there is no easy way to differentiate between the three4343 * variants. The extra address and features of the MAX6659 are not4444 * supported by this driver.4545 *···7070 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.7171 */72727373-#include <linux/config.h>7473#include <linux/module.h>7574#include <linux/init.h>7675#include <linux/slab.h>7776#include <linux/jiffies.h>7877#include <linux/i2c.h>7978#include <linux/i2c-sensor.h>7979+#include <linux/hwmon-sysfs.h>80808181/*8282 * Addresses to scan···139139/*140140 * Conversions and various macros141141 * For local temperatures and limits, critical limits and the hysteresis142142- * value, the LM90 uses signed 8-bit values with LSB = 1 degree Celcius.142142+ * value, the LM90 uses signed 8-bit values with LSB = 1 degree Celsius.143143 * For remote temperatures and limits, it uses signed 11-bit values with144144- * LSB = 0.125 degree Celcius, left-justified in 16-bit registers.144144+ * LSB = 0.125 degree Celsius, left-justified in 16-bit registers.145145 */146146147147#define TEMP1_FROM_REG(val) ((val) * 1000)···206206 int kind;207207208208 /* registers values */209209- s8 temp_input1, temp_low1, temp_high1; /* local */210210- s16 temp_input2, temp_low2, temp_high2; /* remote, combined */211211- s8 temp_crit1, temp_crit2;209209+ s8 temp8[5]; /* 0: local input210210+ 1: local low limit211211+ 2: local high limit212212+ 3: local critical limit213213+ 4: remote critical limit */214214+ s16 temp11[3]; /* 0: remote input215215+ 1: remote low limit216216+ 2: remote high limit */212217 u8 temp_hyst;213218 u8 alarms; /* bitvector */214219};···222217 * Sysfs stuff223218 */224219225225-#define show_temp(value, converter) \226226-static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \227227-{ \228228- struct lm90_data *data = lm90_update_device(dev); \229229- return sprintf(buf, "%d\n", converter(data->value)); \220220+static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr,221221+ char *buf)222222+{223223+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);224224+ struct lm90_data *data = lm90_update_device(dev);225225+ return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp8[attr->index]));230226}231231-show_temp(temp_input1, TEMP1_FROM_REG);232232-show_temp(temp_input2, TEMP2_FROM_REG);233233-show_temp(temp_low1, TEMP1_FROM_REG);234234-show_temp(temp_low2, TEMP2_FROM_REG);235235-show_temp(temp_high1, TEMP1_FROM_REG);236236-show_temp(temp_high2, TEMP2_FROM_REG);237237-show_temp(temp_crit1, TEMP1_FROM_REG);238238-show_temp(temp_crit2, TEMP1_FROM_REG);239227240240-#define set_temp1(value, reg) \241241-static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \242242- size_t count) \243243-{ \244244- struct i2c_client *client = to_i2c_client(dev); \245245- struct lm90_data *data = i2c_get_clientdata(client); \246246- long val = simple_strtol(buf, NULL, 10); \247247- \248248- down(&data->update_lock); \249249- if (data->kind == adt7461) \250250- data->value = TEMP1_TO_REG_ADT7461(val); \251251- else \252252- data->value = TEMP1_TO_REG(val); \253253- i2c_smbus_write_byte_data(client, reg, data->value); \254254- up(&data->update_lock); \255255- return count; \256256-}257257-#define set_temp2(value, regh, regl) \258258-static ssize_t set_##value(struct device *dev, struct device_attribute *attr, const char *buf, \259259- size_t count) \260260-{ \261261- struct i2c_client *client = to_i2c_client(dev); \262262- struct lm90_data *data = i2c_get_clientdata(client); \263263- long val = simple_strtol(buf, NULL, 10); \264264- \265265- down(&data->update_lock); \266266- if (data->kind == adt7461) \267267- data->value = TEMP2_TO_REG_ADT7461(val); \268268- else \269269- data->value = TEMP2_TO_REG(val); \270270- i2c_smbus_write_byte_data(client, regh, data->value >> 8); \271271- i2c_smbus_write_byte_data(client, regl, data->value & 0xff); \272272- up(&data->update_lock); \273273- return count; \274274-}275275-set_temp1(temp_low1, LM90_REG_W_LOCAL_LOW);276276-set_temp2(temp_low2, LM90_REG_W_REMOTE_LOWH, LM90_REG_W_REMOTE_LOWL);277277-set_temp1(temp_high1, LM90_REG_W_LOCAL_HIGH);278278-set_temp2(temp_high2, LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL);279279-set_temp1(temp_crit1, LM90_REG_W_LOCAL_CRIT);280280-set_temp1(temp_crit2, LM90_REG_W_REMOTE_CRIT);228228+static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,229229+ const char *buf, size_t count)230230+{231231+ static const u8 reg[4] = {232232+ LM90_REG_W_LOCAL_LOW,233233+ LM90_REG_W_LOCAL_HIGH,234234+ LM90_REG_W_LOCAL_CRIT,235235+ LM90_REG_W_REMOTE_CRIT,236236+ };281237282282-#define show_temp_hyst(value, basereg) \283283-static ssize_t show_##value(struct device *dev, struct device_attribute *attr, char *buf) \284284-{ \285285- struct lm90_data *data = lm90_update_device(dev); \286286- return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->basereg) \287287- - TEMP1_FROM_REG(data->temp_hyst)); \288288-}289289-show_temp_hyst(temp_hyst1, temp_crit1);290290-show_temp_hyst(temp_hyst2, temp_crit2);238238+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);239239+ struct i2c_client *client = to_i2c_client(dev);240240+ struct lm90_data *data = i2c_get_clientdata(client);241241+ long val = simple_strtol(buf, NULL, 10);242242+ int nr = attr->index;291243292292-static ssize_t set_temp_hyst1(struct device *dev, struct device_attribute *attr, const char *buf,293293- size_t count)244244+ down(&data->update_lock);245245+ if (data->kind == adt7461)246246+ data->temp8[nr] = TEMP1_TO_REG_ADT7461(val);247247+ else248248+ data->temp8[nr] = TEMP1_TO_REG(val);249249+ i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]);250250+ up(&data->update_lock);251251+ return count;252252+}253253+254254+static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr,255255+ char *buf)256256+{257257+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);258258+ struct lm90_data *data = lm90_update_device(dev);259259+ return sprintf(buf, "%d\n", TEMP2_FROM_REG(data->temp11[attr->index]));260260+}261261+262262+static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,263263+ const char *buf, size_t count)264264+{265265+ static const u8 reg[4] = {266266+ LM90_REG_W_REMOTE_LOWH,267267+ LM90_REG_W_REMOTE_LOWL,268268+ LM90_REG_W_REMOTE_HIGHH,269269+ LM90_REG_W_REMOTE_HIGHL,270270+ };271271+272272+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);273273+ struct i2c_client *client = to_i2c_client(dev);274274+ struct lm90_data *data = i2c_get_clientdata(client);275275+ long val = simple_strtol(buf, NULL, 10);276276+ int nr = attr->index;277277+278278+ down(&data->update_lock);279279+ if (data->kind == adt7461)280280+ data->temp11[nr] = TEMP2_TO_REG_ADT7461(val);281281+ else282282+ data->temp11[nr] = TEMP2_TO_REG(val);283283+ i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2],284284+ data->temp11[nr] >> 8);285285+ i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1],286286+ data->temp11[nr] & 0xff);287287+ up(&data->update_lock);288288+ return count;289289+}290290+291291+static ssize_t show_temphyst(struct device *dev, struct device_attribute *devattr,292292+ char *buf)293293+{294294+ struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);295295+ struct lm90_data *data = lm90_update_device(dev);296296+ return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp8[attr->index])297297+ - TEMP1_FROM_REG(data->temp_hyst));298298+}299299+300300+static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy,301301+ const char *buf, size_t count)294302{295303 struct i2c_client *client = to_i2c_client(dev);296304 struct lm90_data *data = i2c_get_clientdata(client);···311293 long hyst;312294313295 down(&data->update_lock);314314- hyst = TEMP1_FROM_REG(data->temp_crit1) - val;296296+ hyst = TEMP1_FROM_REG(data->temp8[3]) - val;315297 i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST,316298 HYST_TO_REG(hyst));317299 up(&data->update_lock);318300 return count;319301}320302321321-static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf)303303+static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy,304304+ char *buf)322305{323306 struct lm90_data *data = lm90_update_device(dev);324307 return sprintf(buf, "%d\n", data->alarms);325308}326309327327-static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL);328328-static DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input2, NULL);329329-static DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_low1,330330- set_temp_low1);331331-static DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_low2,332332- set_temp_low2);333333-static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_high1,334334- set_temp_high1);335335-static DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_high2,336336- set_temp_high2);337337-static DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp_crit1,338338- set_temp_crit1);339339-static DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp_crit2,340340- set_temp_crit2);341341-static DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temp_hyst1,342342- set_temp_hyst1);343343-static DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temp_hyst2, NULL);310310+static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp8, NULL, 0);311311+static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0);312312+static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp8,313313+ set_temp8, 1);314314+static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11,315315+ set_temp11, 1);316316+static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8,317317+ set_temp8, 2);318318+static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11,319319+ set_temp11, 2);320320+static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp8,321321+ set_temp8, 3);322322+static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp8,323323+ set_temp8, 4);324324+static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst,325325+ set_temphyst, 3);326326+static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 4);344327static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);345328346329/*···500481 lm90_init_client(new_client);501482502483 /* Register sysfs hooks */503503- device_create_file(&new_client->dev, &dev_attr_temp1_input);504504- device_create_file(&new_client->dev, &dev_attr_temp2_input);505505- device_create_file(&new_client->dev, &dev_attr_temp1_min);506506- device_create_file(&new_client->dev, &dev_attr_temp2_min);507507- device_create_file(&new_client->dev, &dev_attr_temp1_max);508508- device_create_file(&new_client->dev, &dev_attr_temp2_max);509509- device_create_file(&new_client->dev, &dev_attr_temp1_crit);510510- device_create_file(&new_client->dev, &dev_attr_temp2_crit);511511- device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst);512512- device_create_file(&new_client->dev, &dev_attr_temp2_crit_hyst);484484+ device_create_file(&new_client->dev,485485+ &sensor_dev_attr_temp1_input.dev_attr);486486+ device_create_file(&new_client->dev,487487+ &sensor_dev_attr_temp2_input.dev_attr);488488+ device_create_file(&new_client->dev,489489+ &sensor_dev_attr_temp1_min.dev_attr);490490+ device_create_file(&new_client->dev,491491+ &sensor_dev_attr_temp2_min.dev_attr);492492+ device_create_file(&new_client->dev,493493+ &sensor_dev_attr_temp1_max.dev_attr);494494+ device_create_file(&new_client->dev,495495+ &sensor_dev_attr_temp2_max.dev_attr);496496+ device_create_file(&new_client->dev,497497+ &sensor_dev_attr_temp1_crit.dev_attr);498498+ device_create_file(&new_client->dev,499499+ &sensor_dev_attr_temp2_crit.dev_attr);500500+ device_create_file(&new_client->dev,501501+ &sensor_dev_attr_temp1_crit_hyst.dev_attr);502502+ device_create_file(&new_client->dev,503503+ &sensor_dev_attr_temp2_crit_hyst.dev_attr);513504 device_create_file(&new_client->dev, &dev_attr_alarms);514505515506 return 0;···570541 u8 oldh, newh;571542572543 dev_dbg(&client->dev, "Updating lm90 data.\n");573573- data->temp_input1 = i2c_smbus_read_byte_data(client,574574- LM90_REG_R_LOCAL_TEMP);575575- data->temp_high1 = i2c_smbus_read_byte_data(client,576576- LM90_REG_R_LOCAL_HIGH);577577- data->temp_low1 = i2c_smbus_read_byte_data(client,578578- LM90_REG_R_LOCAL_LOW);579579- data->temp_crit1 = i2c_smbus_read_byte_data(client,580580- LM90_REG_R_LOCAL_CRIT);581581- data->temp_crit2 = i2c_smbus_read_byte_data(client,582582- LM90_REG_R_REMOTE_CRIT);544544+ data->temp8[0] = i2c_smbus_read_byte_data(client,545545+ LM90_REG_R_LOCAL_TEMP);546546+ data->temp8[1] = i2c_smbus_read_byte_data(client,547547+ LM90_REG_R_LOCAL_LOW);548548+ data->temp8[2] = i2c_smbus_read_byte_data(client,549549+ LM90_REG_R_LOCAL_HIGH);550550+ data->temp8[3] = i2c_smbus_read_byte_data(client,551551+ LM90_REG_R_LOCAL_CRIT);552552+ data->temp8[4] = i2c_smbus_read_byte_data(client,553553+ LM90_REG_R_REMOTE_CRIT);583554 data->temp_hyst = i2c_smbus_read_byte_data(client,584555 LM90_REG_R_TCRIT_HYST);585556···599570 */600571 oldh = i2c_smbus_read_byte_data(client,601572 LM90_REG_R_REMOTE_TEMPH);602602- data->temp_input2 = i2c_smbus_read_byte_data(client,603603- LM90_REG_R_REMOTE_TEMPL);573573+ data->temp11[0] = i2c_smbus_read_byte_data(client,574574+ LM90_REG_R_REMOTE_TEMPL);604575 newh = i2c_smbus_read_byte_data(client,605576 LM90_REG_R_REMOTE_TEMPH);606577 if (newh != oldh) {607607- data->temp_input2 = i2c_smbus_read_byte_data(client,608608- LM90_REG_R_REMOTE_TEMPL);578578+ data->temp11[0] = i2c_smbus_read_byte_data(client,579579+ LM90_REG_R_REMOTE_TEMPL);609580#ifdef DEBUG610581 oldh = i2c_smbus_read_byte_data(client,611582 LM90_REG_R_REMOTE_TEMPH);···615586 "wrong.\n");616587#endif617588 }618618- data->temp_input2 |= (newh << 8);589589+ data->temp11[0] |= (newh << 8);619590620620- data->temp_high2 = (i2c_smbus_read_byte_data(client,591591+ data->temp11[1] = (i2c_smbus_read_byte_data(client,592592+ LM90_REG_R_REMOTE_LOWH) << 8) +593593+ i2c_smbus_read_byte_data(client,594594+ LM90_REG_R_REMOTE_LOWL);595595+ data->temp11[2] = (i2c_smbus_read_byte_data(client,621596 LM90_REG_R_REMOTE_HIGHH) << 8) +622597 i2c_smbus_read_byte_data(client,623598 LM90_REG_R_REMOTE_HIGHL);624624- data->temp_low2 = (i2c_smbus_read_byte_data(client,625625- LM90_REG_R_REMOTE_LOWH) << 8) +626626- i2c_smbus_read_byte_data(client,627627- LM90_REG_R_REMOTE_LOWL);628599 data->alarms = i2c_smbus_read_byte_data(client,629600 LM90_REG_R_STATUS);630601
···11+/*22+ max6875.c - driver for MAX6874/MAX687533+44+ Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com>55+66+ Based on i2c/chips/eeprom.c77+88+ The MAX6875 has two EEPROM sections: config and user.99+ At reset, the config EEPROM is read into the registers.1010+1111+ This driver make 3 binary files available in sysfs:1212+ reg_config - direct access to the registers1313+ eeprom_config - acesses configuration eeprom space1414+ eeprom_user - free for application use1515+1616+ In our application, we put device serial & model numbers in user eeprom.1717+1818+ Notes:1919+ 1) The datasheet says that register 0x44 / EEPROM 0x8044 should NOT2020+ be overwritten, so the driver explicitly prevents that.2121+ 2) It's a good idea to keep the config (0x45) locked in config EEPROM.2222+ You can temporarily enable config writes by changing register 0x45.2323+2424+ This program is free software; you can redistribute it and/or modify2525+ it under the terms of the GNU General Public License as published by2626+ the Free Software Foundation; version 2 of the License.2727+*/2828+2929+#include <linux/config.h>3030+#include <linux/kernel.h>3131+#include <linux/init.h>3232+#include <linux/module.h>3333+#include <linux/slab.h>3434+#include <linux/sched.h>3535+#include <linux/delay.h>3636+#include <linux/i2c.h>3737+#include <linux/i2c-sensor.h>3838+3939+/* Addresses to scan */4040+static unsigned short normal_i2c[] = {0x50, 0x52, I2C_CLIENT_END};4141+static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END};4242+4343+/* Insmod parameters */4444+SENSORS_INSMOD_1(max6875);4545+4646+/* this param will prevent 'accidental' writes to the eeprom */4747+static int allow_write = 0;4848+module_param(allow_write, int, 0);4949+MODULE_PARM_DESC(allow_write,5050+ "Enable write access:\n"5151+ "*0: Read only\n"5252+ " 1: Read/Write access");5353+5454+/* The MAX6875 can only read/write 16 bytes at a time */5555+#define SLICE_SIZE 165656+#define SLICE_BITS 45757+5858+/* CONFIG EEPROM is at addresses 0x8000 - 0x8045, registers are at 0 - 0x45 */5959+#define CONFIG_EEPROM_BASE 0x80006060+#define CONFIG_EEPROM_SIZE 0x00466161+#define CONFIG_EEPROM_SLICES 56262+6363+/* USER EEPROM is at addresses 0x8100 - 0x82FF */6464+#define USER_EEPROM_BASE 0x81006565+#define USER_EEPROM_SIZE 0x02006666+#define USER_EEPROM_SLICES 326767+6868+/* MAX6875 commands */6969+#define MAX6875_CMD_BLOCK_WRITE 0x837070+#define MAX6875_CMD_BLOCK_READ 0x847171+#define MAX6875_CMD_REBOOT 0x887272+7373+enum max6875_area_type {7474+ max6875_register_config=0,7575+ max6875_eeprom_config,7676+ max6875_eeprom_user,7777+ max6857_max7878+};7979+8080+struct eeprom_block {8181+ enum max6875_area_type type;8282+ u8 slices;8383+ u32 size;8484+ u32 valid;8585+ u32 base;8686+ unsigned long *updated;8787+ u8 *data;8888+};8989+9090+/* Each client has this additional data */9191+struct max6875_data {9292+ struct i2c_client client;9393+ struct semaphore update_lock;9494+ struct eeprom_block blocks[max6857_max];9595+ /* the above structs point into the arrays below */9696+ u8 data[USER_EEPROM_SIZE + (CONFIG_EEPROM_SIZE*2)];9797+ unsigned long last_updated[USER_EEPROM_SLICES + (CONFIG_EEPROM_SLICES*2)];9898+};9999+100100+static int max6875_attach_adapter(struct i2c_adapter *adapter);101101+static int max6875_detect(struct i2c_adapter *adapter, int address, int kind);102102+static int max6875_detach_client(struct i2c_client *client);103103+104104+/* This is the driver that will be inserted */105105+static struct i2c_driver max6875_driver = {106106+ .owner = THIS_MODULE,107107+ .name = "max6875",108108+ .flags = I2C_DF_NOTIFY,109109+ .attach_adapter = max6875_attach_adapter,110110+ .detach_client = max6875_detach_client,111111+};112112+113113+static int max6875_update_slice(struct i2c_client *client,114114+ struct eeprom_block *blk,115115+ int slice)116116+{117117+ struct max6875_data *data = i2c_get_clientdata(client);118118+ int i, j, addr, count;119119+ u8 rdbuf[SLICE_SIZE];120120+ int retval = 0;121121+122122+ if (slice >= blk->slices)123123+ return -1;124124+125125+ down(&data->update_lock);126126+127127+ if (!(blk->valid & (1 << slice)) ||128128+ (jiffies - blk->updated[slice] > 300 * HZ) ||129129+ (jiffies < blk->updated[slice])) {130130+ dev_dbg(&client->dev, "Starting eeprom update, slice %u, base %u\n",131131+ slice, blk->base);132132+133133+ addr = blk->base + (slice << SLICE_BITS);134134+ count = blk->size - (slice << SLICE_BITS);135135+ if (count > SLICE_SIZE) {136136+ count = SLICE_SIZE;137137+ }138138+139139+ /* Preset the read address */140140+ if (addr < 0x100) {141141+ /* select the register */142142+ if (i2c_smbus_write_byte(client, addr & 0xFF)) {143143+ dev_dbg(&client->dev, "max6875 register select has failed!\n");144144+ retval = -1;145145+ goto exit;146146+ }147147+ } else {148148+ /* select the eeprom */149149+ if (i2c_smbus_write_byte_data(client, addr >> 8, addr & 0xFF)) {150150+ dev_dbg(&client->dev, "max6875 address set has failed!\n");151151+ retval = -1;152152+ goto exit;153153+ }154154+ }155155+156156+ if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {157157+ if (i2c_smbus_read_i2c_block_data(client, MAX6875_CMD_BLOCK_READ,158158+ rdbuf) != SLICE_SIZE)159159+ {160160+ retval = -1;161161+ goto exit;162162+ }163163+164164+ memcpy(&blk->data[slice << SLICE_BITS], rdbuf, count);165165+ } else {166166+ for (i = 0; i < count; i++) {167167+ j = i2c_smbus_read_byte(client);168168+ if (j < 0)169169+ {170170+ retval = -1;171171+ goto exit;172172+ }173173+ blk->data[(slice << SLICE_BITS) + i] = (u8) j;174174+ }175175+ }176176+ blk->updated[slice] = jiffies;177177+ blk->valid |= (1 << slice);178178+ }179179+ exit:180180+ up(&data->update_lock);181181+ return retval;182182+}183183+184184+static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off, size_t count,185185+ enum max6875_area_type area_type)186186+{187187+ struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj));188188+ struct max6875_data *data = i2c_get_clientdata(client);189189+ struct eeprom_block *blk;190190+ int slice;191191+192192+ blk = &data->blocks[area_type];193193+194194+ if (off > blk->size)195195+ return 0;196196+ if (off + count > blk->size)197197+ count = blk->size - off;198198+199199+ /* Only refresh slices which contain requested bytes */200200+ for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++)201201+ max6875_update_slice(client, blk, slice);202202+203203+ memcpy(buf, &blk->data[off], count);204204+205205+ return count;206206+}207207+208208+static ssize_t max6875_user_read(struct kobject *kobj, char *buf, loff_t off, size_t count)209209+{210210+ return max6875_read(kobj, buf, off, count, max6875_eeprom_user);211211+}212212+213213+static ssize_t max6875_config_read(struct kobject *kobj, char *buf, loff_t off, size_t count)214214+{215215+ return max6875_read(kobj, buf, off, count, max6875_eeprom_config);216216+}217217+218218+static ssize_t max6875_cfgreg_read(struct kobject *kobj, char *buf, loff_t off, size_t count)219219+{220220+ return max6875_read(kobj, buf, off, count, max6875_register_config);221221+}222222+223223+224224+static ssize_t max6875_write(struct kobject *kobj, char *buf, loff_t off, size_t count,225225+ enum max6875_area_type area_type)226226+{227227+ struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj));228228+ struct max6875_data *data = i2c_get_clientdata(client);229229+ struct eeprom_block *blk;230230+ int slice, addr, retval;231231+ ssize_t sent = 0;232232+233233+ blk = &data->blocks[area_type];234234+235235+ if (off > blk->size)236236+ return 0;237237+ if ((off + count) > blk->size)238238+ count = blk->size - off;239239+240240+ if (down_interruptible(&data->update_lock))241241+ return -EAGAIN;242242+243243+ /* writing to a register is done with i2c_smbus_write_byte_data() */244244+ if (blk->type == max6875_register_config) {245245+ for (sent = 0; sent < count; sent++) {246246+ addr = off + sent;247247+ if (addr == 0x44)248248+ continue;249249+250250+ retval = i2c_smbus_write_byte_data(client, addr, buf[sent]);251251+ }252252+ } else {253253+ int cmd, val;254254+255255+ /* We are writing to EEPROM */256256+ for (sent = 0; sent < count; sent++) {257257+ addr = blk->base + off + sent;258258+ cmd = addr >> 8;259259+ val = (addr & 0xff) | (buf[sent] << 8); // reversed260260+261261+ if (addr == 0x8044)262262+ continue;263263+264264+ retval = i2c_smbus_write_word_data(client, cmd, val);265265+266266+ if (retval) {267267+ goto error_exit;268268+ }269269+270270+ /* A write takes up to 11 ms */271271+ msleep(11);272272+ }273273+ }274274+275275+ /* Invalidate the scratch buffer */276276+ for (slice = (off >> SLICE_BITS); slice <= ((off + count - 1) >> SLICE_BITS); slice++)277277+ blk->valid &= ~(1 << slice);278278+279279+ error_exit:280280+ up(&data->update_lock);281281+282282+ return sent;283283+}284284+285285+static ssize_t max6875_user_write(struct kobject *kobj, char *buf, loff_t off, size_t count)286286+{287287+ return max6875_write(kobj, buf, off, count, max6875_eeprom_user);288288+}289289+290290+static ssize_t max6875_config_write(struct kobject *kobj, char *buf, loff_t off, size_t count)291291+{292292+ return max6875_write(kobj, buf, off, count, max6875_eeprom_config);293293+}294294+295295+static ssize_t max6875_cfgreg_write(struct kobject *kobj, char *buf, loff_t off, size_t count)296296+{297297+ return max6875_write(kobj, buf, off, count, max6875_register_config);298298+}299299+300300+static struct bin_attribute user_eeprom_attr = {301301+ .attr = {302302+ .name = "eeprom_user",303303+ .mode = S_IRUGO | S_IWUSR | S_IWGRP,304304+ .owner = THIS_MODULE,305305+ },306306+ .size = USER_EEPROM_SIZE,307307+ .read = max6875_user_read,308308+ .write = max6875_user_write,309309+};310310+311311+static struct bin_attribute config_eeprom_attr = {312312+ .attr = {313313+ .name = "eeprom_config",314314+ .mode = S_IRUGO | S_IWUSR,315315+ .owner = THIS_MODULE,316316+ },317317+ .size = CONFIG_EEPROM_SIZE,318318+ .read = max6875_config_read,319319+ .write = max6875_config_write,320320+};321321+322322+static struct bin_attribute config_register_attr = {323323+ .attr = {324324+ .name = "reg_config",325325+ .mode = S_IRUGO | S_IWUSR,326326+ .owner = THIS_MODULE,327327+ },328328+ .size = CONFIG_EEPROM_SIZE,329329+ .read = max6875_cfgreg_read,330330+ .write = max6875_cfgreg_write,331331+};332332+333333+static int max6875_attach_adapter(struct i2c_adapter *adapter)334334+{335335+ return i2c_detect(adapter, &addr_data, max6875_detect);336336+}337337+338338+/* This function is called by i2c_detect */339339+static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)340340+{341341+ struct i2c_client *new_client;342342+ struct max6875_data *data;343343+ int err = 0;344344+345345+ /* There are three ways we can read the EEPROM data:346346+ (1) I2C block reads (faster, but unsupported by most adapters)347347+ (2) Consecutive byte reads (100% overhead)348348+ (3) Regular byte data reads (200% overhead)349349+ The third method is not implemented by this driver because all350350+ known adapters support at least the second. */351351+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA |352352+ I2C_FUNC_SMBUS_BYTE |353353+ I2C_FUNC_SMBUS_WRITE_BYTE_DATA))354354+ goto exit;355355+356356+ /* OK. For now, we presume we have a valid client. We now create the357357+ client structure, even though we cannot fill it completely yet.358358+ But it allows us to access eeprom_{read,write}_value. */359359+ if (!(data = kmalloc(sizeof(struct max6875_data), GFP_KERNEL))) {360360+ err = -ENOMEM;361361+ goto exit;362362+ }363363+ memset(data, 0, sizeof(struct max6875_data));364364+365365+ new_client = &data->client;366366+ i2c_set_clientdata(new_client, data);367367+ new_client->addr = address;368368+ new_client->adapter = adapter;369369+ new_client->driver = &max6875_driver;370370+ new_client->flags = 0;371371+372372+ /* Setup the user section */373373+ data->blocks[max6875_eeprom_user].type = max6875_eeprom_user;374374+ data->blocks[max6875_eeprom_user].slices = USER_EEPROM_SLICES;375375+ data->blocks[max6875_eeprom_user].size = USER_EEPROM_SIZE;376376+ data->blocks[max6875_eeprom_user].base = USER_EEPROM_BASE;377377+ data->blocks[max6875_eeprom_user].data = data->data;378378+ data->blocks[max6875_eeprom_user].updated = data->last_updated;379379+380380+ /* Setup the config section */381381+ data->blocks[max6875_eeprom_config].type = max6875_eeprom_config;382382+ data->blocks[max6875_eeprom_config].slices = CONFIG_EEPROM_SLICES;383383+ data->blocks[max6875_eeprom_config].size = CONFIG_EEPROM_SIZE;384384+ data->blocks[max6875_eeprom_config].base = CONFIG_EEPROM_BASE;385385+ data->blocks[max6875_eeprom_config].data = &data->data[USER_EEPROM_SIZE];386386+ data->blocks[max6875_eeprom_config].updated = &data->last_updated[USER_EEPROM_SLICES];387387+388388+ /* Setup the register section */389389+ data->blocks[max6875_register_config].type = max6875_register_config;390390+ data->blocks[max6875_register_config].slices = CONFIG_EEPROM_SLICES;391391+ data->blocks[max6875_register_config].size = CONFIG_EEPROM_SIZE;392392+ data->blocks[max6875_register_config].base = 0;393393+ data->blocks[max6875_register_config].data = &data->data[USER_EEPROM_SIZE+CONFIG_EEPROM_SIZE];394394+ data->blocks[max6875_register_config].updated = &data->last_updated[USER_EEPROM_SLICES+CONFIG_EEPROM_SLICES];395395+396396+ /* Init the data */397397+ memset(data->data, 0xff, sizeof(data->data));398398+399399+ /* Fill in the remaining client fields */400400+ strlcpy(new_client->name, "max6875", I2C_NAME_SIZE);401401+ init_MUTEX(&data->update_lock);402402+403403+ /* Verify that the chip is really what we think it is */404404+ if ((max6875_update_slice(new_client, &data->blocks[max6875_eeprom_config], 4) < 0) ||405405+ (max6875_update_slice(new_client, &data->blocks[max6875_register_config], 4) < 0))406406+ goto exit_kfree;407407+408408+ /* 0x41,0x42 must be zero and 0x40 must match in eeprom and registers */409409+ if ((data->blocks[max6875_eeprom_config].data[0x41] != 0) ||410410+ (data->blocks[max6875_eeprom_config].data[0x42] != 0) ||411411+ (data->blocks[max6875_register_config].data[0x41] != 0) ||412412+ (data->blocks[max6875_register_config].data[0x42] != 0) ||413413+ (data->blocks[max6875_eeprom_config].data[0x40] !=414414+ data->blocks[max6875_register_config].data[0x40]))415415+ goto exit_kfree;416416+417417+ /* Tell the I2C layer a new client has arrived */418418+ if ((err = i2c_attach_client(new_client)))419419+ goto exit_kfree;420420+421421+ /* create the sysfs eeprom files with the correct permissions */422422+ if (allow_write == 0) {423423+ user_eeprom_attr.attr.mode &= ~S_IWUGO;424424+ user_eeprom_attr.write = NULL;425425+ config_eeprom_attr.attr.mode &= ~S_IWUGO;426426+ config_eeprom_attr.write = NULL;427427+ config_register_attr.attr.mode &= ~S_IWUGO;428428+ config_register_attr.write = NULL;429429+ }430430+ sysfs_create_bin_file(&new_client->dev.kobj, &user_eeprom_attr);431431+ sysfs_create_bin_file(&new_client->dev.kobj, &config_eeprom_attr);432432+ sysfs_create_bin_file(&new_client->dev.kobj, &config_register_attr);433433+434434+ return 0;435435+436436+exit_kfree:437437+ kfree(data);438438+exit:439439+ return err;440440+}441441+442442+static int max6875_detach_client(struct i2c_client *client)443443+{444444+ int err;445445+446446+ err = i2c_detach_client(client);447447+ if (err) {448448+ dev_err(&client->dev, "Client deregistration failed, client not detached.\n");449449+ return err;450450+ }451451+452452+ kfree(i2c_get_clientdata(client));453453+454454+ return 0;455455+}456456+457457+static int __init max6875_init(void)458458+{459459+ return i2c_add_driver(&max6875_driver);460460+}461461+462462+static void __exit max6875_exit(void)463463+{464464+ i2c_del_driver(&max6875_driver);465465+}466466+467467+468468+MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>");469469+MODULE_DESCRIPTION("MAX6875 driver");470470+MODULE_LICENSE("GPL");471471+472472+module_init(max6875_init);473473+module_exit(max6875_exit);
-1
drivers/i2c/chips/pc87360.c
···3333 * the standard Super-I/O addresses is used (0x2E/0x2F or 0x4E/0x4F).3434 */35353636-#include <linux/config.h>3736#include <linux/module.h>3837#include <linux/init.h>3938#include <linux/slab.h>
+192
drivers/i2c/chips/pca9539.c
···11+/*22+ pca9539.c - 16-bit I/O port with interrupt and reset33+44+ Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com>55+66+ This program is free software; you can redistribute it and/or modify77+ it under the terms of the GNU General Public License as published by88+ the Free Software Foundation; version 2 of the License.99+*/1010+1111+#include <linux/module.h>1212+#include <linux/init.h>1313+#include <linux/slab.h>1414+#include <linux/i2c.h>1515+#include <linux/hwmon-sysfs.h>1616+#include <linux/i2c-sensor.h>1717+1818+/* Addresses to scan */1919+static unsigned short normal_i2c[] = {0x74, 0x75, 0x76, 0x77, I2C_CLIENT_END};2020+static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END};2121+2222+/* Insmod parameters */2323+SENSORS_INSMOD_1(pca9539);2424+2525+enum pca9539_cmd2626+{2727+ PCA9539_INPUT_0 = 0,2828+ PCA9539_INPUT_1 = 1,2929+ PCA9539_OUTPUT_0 = 2,3030+ PCA9539_OUTPUT_1 = 3,3131+ PCA9539_INVERT_0 = 4,3232+ PCA9539_INVERT_1 = 5,3333+ PCA9539_DIRECTION_0 = 6,3434+ PCA9539_DIRECTION_1 = 7,3535+};3636+3737+static int pca9539_attach_adapter(struct i2c_adapter *adapter);3838+static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind);3939+static int pca9539_detach_client(struct i2c_client *client);4040+4141+/* This is the driver that will be inserted */4242+static struct i2c_driver pca9539_driver = {4343+ .owner = THIS_MODULE,4444+ .name = "pca9539",4545+ .flags = I2C_DF_NOTIFY,4646+ .attach_adapter = pca9539_attach_adapter,4747+ .detach_client = pca9539_detach_client,4848+};4949+5050+struct pca9539_data {5151+ struct i2c_client client;5252+};5353+5454+/* following are the sysfs callback functions */5555+static ssize_t pca9539_show(struct device *dev, struct device_attribute *attr,5656+ char *buf)5757+{5858+ struct sensor_device_attribute *psa = to_sensor_dev_attr(attr);5959+ struct i2c_client *client = to_i2c_client(dev);6060+ return sprintf(buf, "%d\n", i2c_smbus_read_byte_data(client,6161+ psa->index));6262+}6363+6464+static ssize_t pca9539_store(struct device *dev, struct device_attribute *attr,6565+ const char *buf, size_t count)6666+{6767+ struct sensor_device_attribute *psa = to_sensor_dev_attr(attr);6868+ struct i2c_client *client = to_i2c_client(dev);6969+ unsigned long val = simple_strtoul(buf, NULL, 0);7070+ if (val > 0xff)7171+ return -EINVAL;7272+ i2c_smbus_write_byte_data(client, psa->index, val);7373+ return count;7474+}7575+7676+/* Define the device attributes */7777+7878+#define PCA9539_ENTRY_RO(name, cmd_idx) \7979+ static SENSOR_DEVICE_ATTR(name, S_IRUGO, pca9539_show, NULL, cmd_idx)8080+8181+#define PCA9539_ENTRY_RW(name, cmd_idx) \8282+ static SENSOR_DEVICE_ATTR(name, S_IRUGO | S_IWUSR, pca9539_show, \8383+ pca9539_store, cmd_idx)8484+8585+PCA9539_ENTRY_RO(input0, PCA9539_INPUT_0);8686+PCA9539_ENTRY_RO(input1, PCA9539_INPUT_1);8787+PCA9539_ENTRY_RW(output0, PCA9539_OUTPUT_0);8888+PCA9539_ENTRY_RW(output1, PCA9539_OUTPUT_1);8989+PCA9539_ENTRY_RW(invert0, PCA9539_INVERT_0);9090+PCA9539_ENTRY_RW(invert1, PCA9539_INVERT_1);9191+PCA9539_ENTRY_RW(direction0, PCA9539_DIRECTION_0);9292+PCA9539_ENTRY_RW(direction1, PCA9539_DIRECTION_1);9393+9494+static struct attribute *pca9539_attributes[] = {9595+ &sensor_dev_attr_input0.dev_attr.attr,9696+ &sensor_dev_attr_input1.dev_attr.attr,9797+ &sensor_dev_attr_output0.dev_attr.attr,9898+ &sensor_dev_attr_output1.dev_attr.attr,9999+ &sensor_dev_attr_invert0.dev_attr.attr,100100+ &sensor_dev_attr_invert1.dev_attr.attr,101101+ &sensor_dev_attr_direction0.dev_attr.attr,102102+ &sensor_dev_attr_direction1.dev_attr.attr,103103+ NULL104104+};105105+106106+static struct attribute_group pca9539_defattr_group = {107107+ .attrs = pca9539_attributes,108108+};109109+110110+static int pca9539_attach_adapter(struct i2c_adapter *adapter)111111+{112112+ return i2c_detect(adapter, &addr_data, pca9539_detect);113113+}114114+115115+/* This function is called by i2c_detect */116116+static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)117117+{118118+ struct i2c_client *new_client;119119+ struct pca9539_data *data;120120+ int err = 0;121121+122122+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))123123+ goto exit;124124+125125+ /* OK. For now, we presume we have a valid client. We now create the126126+ client structure, even though we cannot fill it completely yet. */127127+ if (!(data = kmalloc(sizeof(struct pca9539_data), GFP_KERNEL))) {128128+ err = -ENOMEM;129129+ goto exit;130130+ }131131+ memset(data, 0, sizeof(struct pca9539_data));132132+133133+ new_client = &data->client;134134+ i2c_set_clientdata(new_client, data);135135+ new_client->addr = address;136136+ new_client->adapter = adapter;137137+ new_client->driver = &pca9539_driver;138138+ new_client->flags = 0;139139+140140+ /* Detection: the pca9539 only has 8 registers (0-7).141141+ A read of 7 should succeed, but a read of 8 should fail. */142142+ if ((i2c_smbus_read_byte_data(new_client, 7) < 0) ||143143+ (i2c_smbus_read_byte_data(new_client, 8) >= 0))144144+ goto exit_kfree;145145+146146+ strlcpy(new_client->name, "pca9539", I2C_NAME_SIZE);147147+148148+ /* Tell the I2C layer a new client has arrived */149149+ if ((err = i2c_attach_client(new_client)))150150+ goto exit_kfree;151151+152152+ /* Register sysfs hooks (don't care about failure) */153153+ sysfs_create_group(&new_client->dev.kobj, &pca9539_defattr_group);154154+155155+ return 0;156156+157157+exit_kfree:158158+ kfree(data);159159+exit:160160+ return err;161161+}162162+163163+static int pca9539_detach_client(struct i2c_client *client)164164+{165165+ int err;166166+167167+ if ((err = i2c_detach_client(client))) {168168+ dev_err(&client->dev, "Client deregistration failed.\n");169169+ return err;170170+ }171171+172172+ kfree(i2c_get_clientdata(client));173173+ return 0;174174+}175175+176176+static int __init pca9539_init(void)177177+{178178+ return i2c_add_driver(&pca9539_driver);179179+}180180+181181+static void __exit pca9539_exit(void)182182+{183183+ i2c_del_driver(&pca9539_driver);184184+}185185+186186+MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>");187187+MODULE_DESCRIPTION("PCA9539 driver");188188+MODULE_LICENSE("GPL");189189+190190+module_init(pca9539_init);191191+module_exit(pca9539_exit);192192+
···372372 * SMSC LPC47M10x/LPC47M13x (device id 0x59), LPC47M14x (device id373373 * 0x5F) and LPC47B27x (device id 0x51) have fan control.374374 * The LPC47M15x and LPC47M192 chips "with hardware monitoring block"375375- * can do much more besides (device id 0x60, unsupported).375375+ * can do much more besides (device id 0x60).376376 */377377 if (val == 0x51)378378- printk(KERN_INFO "smsc47m1: Found SMSC47B27x\n");378378+ printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n");379379 else if (val == 0x59)380380- printk(KERN_INFO "smsc47m1: Found SMSC47M10x/SMSC47M13x\n");380380+ printk(KERN_INFO "smsc47m1: Found SMSC LPC47M10x/LPC47M13x\n");381381 else if (val == 0x5F)382382- printk(KERN_INFO "smsc47m1: Found SMSC47M14x\n");382382+ printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n");383383+ else if (val == 0x60)384384+ printk(KERN_INFO "smsc47m1: Found SMSC LPC47M15x/LPC47M192\n");383385 else {384386 superio_exit();385387 return -ENODEV;
+1072
drivers/i2c/chips/tps65010.c
···11+/*22+ * tps65010 - driver for tps6501x power management chips33+ *44+ * Copyright (C) 2004 Texas Instruments55+ * Copyright (C) 2004-2005 David Brownell66+ *77+ * This program is free software; you can redistribute it and/or modify88+ * it under the terms of the GNU General Public License as published by99+ * the Free Software Foundation; either version 2 of the License, or1010+ * (at your option) any later version.1111+ *1212+ * This program is distributed in the hope that it will be useful,1313+ * but WITHOUT ANY WARRANTY; without even the implied warranty of1414+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1515+ * GNU General Public License for more details.1616+ *1717+ * You should have received a copy of the GNU General Public License1818+ * along with this program; if not, write to the Free Software1919+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.2020+ */2121+#undef DEBUG2222+2323+#include <linux/config.h>2424+#include <linux/kernel.h>2525+#include <linux/module.h>2626+#include <linux/init.h>2727+#include <linux/slab.h>2828+#include <linux/interrupt.h>2929+#include <linux/device.h>3030+#include <linux/i2c.h>3131+#include <linux/delay.h>3232+#include <linux/workqueue.h>3333+#include <linux/suspend.h>3434+#include <linux/debugfs.h>3535+#include <linux/seq_file.h>3636+3737+#include <asm/irq.h>3838+#include <asm/mach-types.h>3939+4040+#include <asm/arch/gpio.h>4141+#include <asm/arch/mux.h>4242+#include <asm/arch/tps65010.h>4343+4444+/*-------------------------------------------------------------------------*/4545+4646+#define DRIVER_VERSION "2 May 2005"4747+#define DRIVER_NAME (tps65010_driver.name)4848+4949+MODULE_DESCRIPTION("TPS6501x Power Management Driver");5050+MODULE_LICENSE("GPL");5151+5252+/* only two addresses possible */5353+#define TPS_BASE 0x485454+static unsigned short normal_i2c[] = {5555+ TPS_BASE,5656+ I2C_CLIENT_END };5757+static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };5858+5959+I2C_CLIENT_INSMOD;6060+6161+static struct i2c_driver tps65010_driver;6262+6363+/*-------------------------------------------------------------------------*/6464+6565+/* This driver handles a family of multipurpose chips, which incorporate6666+ * voltage regulators, lithium ion/polymer battery charging, GPIOs, LEDs,6767+ * and other features often needed in portable devices like cell phones6868+ * or digital cameras.6969+ *7070+ * The tps65011 and tps65013 have different voltage settings compared7171+ * to tps65010 and tps65012. The tps65013 has a NO_CHG status/irq.7272+ * All except tps65010 have "wait" mode, possibly defaulted so that7373+ * battery-insert != device-on.7474+ *7575+ * We could distinguish between some models by checking VDCDC1.UVLO or7676+ * other registers, unless they've been changed already after powerup7777+ * as part of board setup by a bootloader.7878+ */7979+enum tps_model {8080+ TPS_UNKNOWN = 0,8181+ TPS65010,8282+ TPS65011,8383+ TPS65012,8484+ TPS65013,8585+};8686+8787+struct tps65010 {8888+ struct i2c_client client;8989+ struct semaphore lock;9090+ int irq;9191+ struct work_struct work;9292+ struct dentry *file;9393+ unsigned charging:1;9494+ unsigned por:1;9595+ unsigned model:8;9696+ u16 vbus;9797+ unsigned long flags;9898+#define FLAG_VBUS_CHANGED 09999+#define FLAG_IRQ_ENABLE 1100100+101101+ /* copies of last register state */102102+ u8 chgstatus, regstatus, chgconf;103103+ u8 nmask1, nmask2;104104+105105+ /* plus four GPIOs, probably used to switch power */106106+};107107+108108+#define POWER_POLL_DELAY msecs_to_jiffies(800)109109+110110+/*-------------------------------------------------------------------------*/111111+112112+#if defined(DEBUG) || defined(CONFIG_DEBUG_FS)113113+114114+static void dbg_chgstat(char *buf, size_t len, u8 chgstatus)115115+{116116+ snprintf(buf, len, "%02x%s%s%s%s%s%s%s%s\n",117117+ chgstatus,118118+ (chgstatus & TPS_CHG_USB) ? " USB" : "",119119+ (chgstatus & TPS_CHG_AC) ? " AC" : "",120120+ (chgstatus & TPS_CHG_THERM) ? " therm" : "",121121+ (chgstatus & TPS_CHG_TERM) ? " done" :122122+ ((chgstatus & (TPS_CHG_USB|TPS_CHG_AC))123123+ ? " (charging)" : ""),124124+ (chgstatus & TPS_CHG_TAPER_TMO) ? " taper_tmo" : "",125125+ (chgstatus & TPS_CHG_CHG_TMO) ? " charge_tmo" : "",126126+ (chgstatus & TPS_CHG_PRECHG_TMO) ? " prechg_tmo" : "",127127+ (chgstatus & TPS_CHG_TEMP_ERR) ? " temp_err" : "");128128+}129129+130130+static void dbg_regstat(char *buf, size_t len, u8 regstatus)131131+{132132+ snprintf(buf, len, "%02x %s%s%s%s%s%s%s%s\n",133133+ regstatus,134134+ (regstatus & TPS_REG_ONOFF) ? "off" : "(on)",135135+ (regstatus & TPS_REG_COVER) ? " uncover" : "",136136+ (regstatus & TPS_REG_UVLO) ? " UVLO" : "",137137+ (regstatus & TPS_REG_NO_CHG) ? " NO_CHG" : "",138138+ (regstatus & TPS_REG_PG_LD02) ? " ld01_bad" : "",139139+ (regstatus & TPS_REG_PG_LD01) ? " ld01_bad" : "",140140+ (regstatus & TPS_REG_PG_MAIN) ? " main_bad" : "",141141+ (regstatus & TPS_REG_PG_CORE) ? " core_bad" : "");142142+}143143+144144+static void dbg_chgconf(int por, char *buf, size_t len, u8 chgconfig)145145+{146146+ char *hibit;147147+148148+ if (por)149149+ hibit = (chgconfig & TPS_CHARGE_POR)150150+ ? "POR=69ms" : "POR=1sec";151151+ else152152+ hibit = (chgconfig & TPS65013_AUA) ? "AUA" : "";153153+154154+ snprintf(buf, len, "%02x %s%s%s AC=%d%% USB=%dmA %sCharge\n",155155+ chgconfig, hibit,156156+ (chgconfig & TPS_CHARGE_RESET) ? " reset" : "",157157+ (chgconfig & TPS_CHARGE_FAST) ? " fast" : "",158158+ ({int p; switch ((chgconfig >> 3) & 3) {159159+ case 3: p = 100; break;160160+ case 2: p = 75; break;161161+ case 1: p = 50; break;162162+ default: p = 25; break;163163+ }; p; }),164164+ (chgconfig & TPS_VBUS_CHARGING)165165+ ? ((chgconfig & TPS_VBUS_500MA) ? 500 : 100)166166+ : 0,167167+ (chgconfig & TPS_CHARGE_ENABLE) ? "" : "No");168168+}169169+170170+#endif171171+172172+#ifdef DEBUG173173+174174+static void show_chgstatus(const char *label, u8 chgstatus)175175+{176176+ char buf [100];177177+178178+ dbg_chgstat(buf, sizeof buf, chgstatus);179179+ pr_debug("%s: %s %s", DRIVER_NAME, label, buf);180180+}181181+182182+static void show_regstatus(const char *label, u8 regstatus)183183+{184184+ char buf [100];185185+186186+ dbg_regstat(buf, sizeof buf, regstatus);187187+ pr_debug("%s: %s %s", DRIVER_NAME, label, buf);188188+}189189+190190+static void show_chgconfig(int por, const char *label, u8 chgconfig)191191+{192192+ char buf [100];193193+194194+ dbg_chgconf(por, buf, sizeof buf, chgconfig);195195+ pr_debug("%s: %s %s", DRIVER_NAME, label, buf);196196+}197197+198198+#else199199+200200+static inline void show_chgstatus(const char *label, u8 chgstatus) { }201201+static inline void show_regstatus(const char *label, u8 chgstatus) { }202202+static inline void show_chgconfig(int por, const char *label, u8 chgconfig) { }203203+204204+#endif205205+206206+#ifdef CONFIG_DEBUG_FS207207+208208+static int dbg_show(struct seq_file *s, void *_)209209+{210210+ struct tps65010 *tps = s->private;211211+ u8 value, v2;212212+ unsigned i;213213+ char buf[100];214214+ const char *chip;215215+216216+ switch (tps->model) {217217+ case TPS65010: chip = "tps65010"; break;218218+ case TPS65011: chip = "tps65011"; break;219219+ case TPS65012: chip = "tps65012"; break;220220+ case TPS65013: chip = "tps65013"; break;221221+ default: chip = NULL; break;222222+ }223223+ seq_printf(s, "driver %s\nversion %s\nchip %s\n\n",224224+ DRIVER_NAME, DRIVER_VERSION, chip);225225+226226+ down(&tps->lock);227227+228228+ /* FIXME how can we tell whether a battery is present?229229+ * likely involves a charge gauging chip (like BQ26501).230230+ */231231+232232+ seq_printf(s, "%scharging\n\n", tps->charging ? "" : "(not) ");233233+234234+235235+ /* registers for monitoring battery charging and status; note236236+ * that reading chgstat and regstat may ack IRQs...237237+ */238238+ value = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG);239239+ dbg_chgconf(tps->por, buf, sizeof buf, value);240240+ seq_printf(s, "chgconfig %s", buf);241241+242242+ value = i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS);243243+ dbg_chgstat(buf, sizeof buf, value);244244+ seq_printf(s, "chgstat %s", buf);245245+ value = i2c_smbus_read_byte_data(&tps->client, TPS_MASK1);246246+ dbg_chgstat(buf, sizeof buf, value);247247+ seq_printf(s, "mask1 %s", buf);248248+ /* ignore ackint1 */249249+250250+ value = i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS);251251+ dbg_regstat(buf, sizeof buf, value);252252+ seq_printf(s, "regstat %s", buf);253253+ value = i2c_smbus_read_byte_data(&tps->client, TPS_MASK2);254254+ dbg_regstat(buf, sizeof buf, value);255255+ seq_printf(s, "mask2 %s\n", buf);256256+ /* ignore ackint2 */257257+258258+ (void) schedule_delayed_work(&tps->work, POWER_POLL_DELAY);259259+260260+261261+ /* VMAIN voltage, enable lowpower, etc */262262+ value = i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC1);263263+ seq_printf(s, "vdcdc1 %02x\n", value);264264+265265+ /* VCORE voltage, vibrator on/off */266266+ value = i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC2);267267+ seq_printf(s, "vdcdc2 %02x\n", value);268268+269269+ /* both LD0s, and their lowpower behavior */270270+ value = i2c_smbus_read_byte_data(&tps->client, TPS_VREGS1);271271+ seq_printf(s, "vregs1 %02x\n\n", value);272272+273273+274274+ /* LEDs and GPIOs */275275+ value = i2c_smbus_read_byte_data(&tps->client, TPS_LED1_ON);276276+ v2 = i2c_smbus_read_byte_data(&tps->client, TPS_LED1_PER);277277+ seq_printf(s, "led1 %s, on=%02x, per=%02x, %d/%d msec\n",278278+ (value & 0x80)279279+ ? ((v2 & 0x80) ? "on" : "off")280280+ : ((v2 & 0x80) ? "blink" : "(nPG)"),281281+ value, v2,282282+ (value & 0x7f) * 10, (v2 & 0x7f) * 100);283283+284284+ value = i2c_smbus_read_byte_data(&tps->client, TPS_LED2_ON);285285+ v2 = i2c_smbus_read_byte_data(&tps->client, TPS_LED2_PER);286286+ seq_printf(s, "led2 %s, on=%02x, per=%02x, %d/%d msec\n",287287+ (value & 0x80)288288+ ? ((v2 & 0x80) ? "on" : "off")289289+ : ((v2 & 0x80) ? "blink" : "off"),290290+ value, v2,291291+ (value & 0x7f) * 10, (v2 & 0x7f) * 100);292292+293293+ value = i2c_smbus_read_byte_data(&tps->client, TPS_DEFGPIO);294294+ v2 = i2c_smbus_read_byte_data(&tps->client, TPS_MASK3);295295+ seq_printf(s, "defgpio %02x mask3 %02x\n", value, v2);296296+297297+ for (i = 0; i < 4; i++) {298298+ if (value & (1 << (4 +i)))299299+ seq_printf(s, " gpio%d-out %s\n", i + 1,300300+ (value & (1 << i)) ? "low" : "hi ");301301+ else302302+ seq_printf(s, " gpio%d-in %s %s %s\n", i + 1,303303+ (value & (1 << i)) ? "hi " : "low",304304+ (v2 & (1 << i)) ? "no-irq" : "irq",305305+ (v2 & (1 << (4 + i))) ? "rising" : "falling");306306+ }307307+308308+ up(&tps->lock);309309+ return 0;310310+}311311+312312+static int dbg_tps_open(struct inode *inode, struct file *file)313313+{314314+ return single_open(file, dbg_show, inode->u.generic_ip);315315+}316316+317317+static struct file_operations debug_fops = {318318+ .open = dbg_tps_open,319319+ .read = seq_read,320320+ .llseek = seq_lseek,321321+ .release = single_release,322322+};323323+324324+#define DEBUG_FOPS &debug_fops325325+326326+#else327327+#define DEBUG_FOPS NULL328328+#endif329329+330330+/*-------------------------------------------------------------------------*/331331+332332+/* handle IRQS in a task context, so we can use I2C calls */333333+static void tps65010_interrupt(struct tps65010 *tps)334334+{335335+ u8 tmp = 0, mask, poll;336336+337337+ /* IRQs won't trigger irqs for certain events, but we can get338338+ * others by polling (normally, with external power applied).339339+ */340340+ poll = 0;341341+342342+ /* regstatus irqs */343343+ if (tps->nmask2) {344344+ tmp = i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS);345345+ mask = tmp ^ tps->regstatus;346346+ tps->regstatus = tmp;347347+ mask &= tps->nmask2;348348+ } else349349+ mask = 0;350350+ if (mask) {351351+ tps->regstatus = tmp;352352+ /* may need to shut something down ... */353353+354354+ /* "off" usually means deep sleep */355355+ if (tmp & TPS_REG_ONOFF) {356356+ pr_info("%s: power off button\n", DRIVER_NAME);357357+#if 0358358+ /* REVISIT: this might need its own workqueue359359+ * plus tweaks including deadlock avoidance ...360360+ */361361+ software_suspend();362362+#endif363363+ poll = 1;364364+ }365365+ }366366+367367+ /* chgstatus irqs */368368+ if (tps->nmask1) {369369+ tmp = i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS);370370+ mask = tmp ^ tps->chgstatus;371371+ tps->chgstatus = tmp;372372+ mask &= tps->nmask1;373373+ } else374374+ mask = 0;375375+ if (mask) {376376+ unsigned charging = 0;377377+378378+ show_chgstatus("chg/irq", tmp);379379+ if (tmp & (TPS_CHG_USB|TPS_CHG_AC))380380+ show_chgconfig(tps->por, "conf", tps->chgconf);381381+382382+ /* Unless it was turned off or disabled, we charge any383383+ * battery whenever there's power available for it384384+ * and the charger hasn't been disabled.385385+ */386386+ if (!(tps->chgstatus & ~(TPS_CHG_USB|TPS_CHG_AC))387387+ && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))388388+ && (tps->chgconf & TPS_CHARGE_ENABLE)389389+ ) {390390+ if (tps->chgstatus & TPS_CHG_USB) {391391+ /* VBUS options are readonly until reconnect */392392+ if (mask & TPS_CHG_USB)393393+ set_bit(FLAG_VBUS_CHANGED, &tps->flags);394394+ charging = 1;395395+ } else if (tps->chgstatus & TPS_CHG_AC)396396+ charging = 1;397397+ }398398+ if (charging != tps->charging) {399399+ tps->charging = charging;400400+ pr_info("%s: battery %scharging\n",401401+ DRIVER_NAME, charging ? "" :402402+ ((tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC))403403+ ? "NOT " : "dis"));404404+ }405405+ }406406+407407+ /* always poll to detect (a) power removal, without tps65013408408+ * NO_CHG IRQ; or (b) restart of charging after stop.409409+ */410410+ if ((tps->model != TPS65013 || !tps->charging)411411+ && (tps->chgstatus & (TPS_CHG_USB|TPS_CHG_AC)))412412+ poll = 1;413413+ if (poll)414414+ (void) schedule_delayed_work(&tps->work, POWER_POLL_DELAY);415415+416416+ /* also potentially gpio-in rise or fall */417417+}418418+419419+/* handle IRQs and polling using keventd for now */420420+static void tps65010_work(void *_tps)421421+{422422+ struct tps65010 *tps = _tps;423423+424424+ down(&tps->lock);425425+426426+ tps65010_interrupt(tps);427427+428428+ if (test_and_clear_bit(FLAG_VBUS_CHANGED, &tps->flags)) {429429+ int status;430430+ u8 chgconfig, tmp;431431+432432+ chgconfig = i2c_smbus_read_byte_data(&tps->client,433433+ TPS_CHGCONFIG);434434+ chgconfig &= ~(TPS_VBUS_500MA | TPS_VBUS_CHARGING);435435+ if (tps->vbus == 500)436436+ chgconfig |= TPS_VBUS_500MA | TPS_VBUS_CHARGING;437437+ else if (tps->vbus >= 100)438438+ chgconfig |= TPS_VBUS_CHARGING;439439+440440+ status = i2c_smbus_write_byte_data(&tps->client,441441+ TPS_CHGCONFIG, chgconfig);442442+443443+ /* vbus update fails unless VBUS is connected! */444444+ tmp = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG);445445+ tps->chgconf = tmp;446446+ show_chgconfig(tps->por, "update vbus", tmp);447447+ }448448+449449+ if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags))450450+ enable_irq(tps->irq);451451+452452+ up(&tps->lock);453453+}454454+455455+static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs)456456+{457457+ struct tps65010 *tps = _tps;458458+459459+ disable_irq_nosync(irq);460460+ set_bit(FLAG_IRQ_ENABLE, &tps->flags);461461+ (void) schedule_work(&tps->work);462462+ return IRQ_HANDLED;463463+}464464+465465+/*-------------------------------------------------------------------------*/466466+467467+static struct tps65010 *the_tps;468468+469469+static int __exit tps65010_detach_client(struct i2c_client *client)470470+{471471+ struct tps65010 *tps;472472+473473+ tps = container_of(client, struct tps65010, client);474474+#ifdef CONFIG_ARM475475+ if (machine_is_omap_h2())476476+ omap_free_gpio(58);477477+ if (machine_is_omap_osk())478478+ omap_free_gpio(OMAP_MPUIO(1));479479+#endif480480+ free_irq(tps->irq, tps);481481+ debugfs_remove(tps->file);482482+ if (i2c_detach_client(client) == 0)483483+ kfree(tps);484484+ the_tps = 0;485485+ return 0;486486+}487487+488488+static int tps65010_noscan(struct i2c_adapter *bus)489489+{490490+ /* pure paranoia, in case someone adds another i2c bus491491+ * after our init section's gone...492492+ */493493+ return -ENODEV;494494+}495495+496496+/* no error returns, they'd just make bus scanning stop */497497+static int __init498498+tps65010_probe(struct i2c_adapter *bus, int address, int kind)499499+{500500+ struct tps65010 *tps;501501+ int status;502502+503503+ if (the_tps) {504504+ dev_dbg(&bus->dev, "only one %s for now\n", DRIVER_NAME);505505+ return 0;506506+ }507507+508508+ tps = kmalloc(sizeof *tps, GFP_KERNEL);509509+ if (!tps)510510+ return 0;511511+512512+ memset(tps, 0, sizeof *tps);513513+ init_MUTEX(&tps->lock);514514+ INIT_WORK(&tps->work, tps65010_work, tps);515515+ tps->irq = -1;516516+ tps->client.addr = address;517517+ i2c_set_clientdata(&tps->client, tps);518518+ tps->client.adapter = bus;519519+ tps->client.driver = &tps65010_driver;520520+ strlcpy(tps->client.name, DRIVER_NAME, I2C_NAME_SIZE);521521+522522+ status = i2c_attach_client(&tps->client);523523+ if (status < 0) {524524+ dev_dbg(&bus->dev, "can't attach %s to device %d, err %d\n",525525+ DRIVER_NAME, address, status);526526+fail1:527527+ kfree(tps);528528+ return 0;529529+ }530530+531531+#ifdef CONFIG_ARM532532+ if (machine_is_omap_h2()) {533533+ tps->model = TPS65010;534534+ omap_cfg_reg(W4_GPIO58);535535+ tps->irq = OMAP_GPIO_IRQ(58);536536+ omap_request_gpio(58);537537+ omap_set_gpio_direction(58, 1);538538+ omap_set_gpio_edge_ctrl(58, OMAP_GPIO_FALLING_EDGE);539539+ }540540+ if (machine_is_omap_osk()) {541541+ tps->model = TPS65010;542542+ // omap_cfg_reg(U19_1610_MPUIO1);543543+ tps->irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1));544544+ omap_request_gpio(OMAP_MPUIO(1));545545+ omap_set_gpio_direction(OMAP_MPUIO(1), 1);546546+ omap_set_gpio_edge_ctrl(OMAP_MPUIO(1), OMAP_GPIO_FALLING_EDGE);547547+ }548548+ if (machine_is_omap_h3()) {549549+ tps->model = TPS65013;550550+551551+ // FIXME set up this board's IRQ ...552552+ }553553+#else554554+#define set_irq_type(num,trigger) do{}while(0)555555+#endif556556+557557+ if (tps->irq > 0) {558558+ set_irq_type(tps->irq, IRQT_LOW);559559+ status = request_irq(tps->irq, tps65010_irq,560560+ SA_SAMPLE_RANDOM, DRIVER_NAME, tps);561561+ if (status < 0) {562562+ dev_dbg(&tps->client.dev, "can't get IRQ %d, err %d\n",563563+ tps->irq, status);564564+ i2c_detach_client(&tps->client);565565+ goto fail1;566566+ }567567+#ifdef CONFIG_ARM568568+ /* annoying race here, ideally we'd have an option569569+ * to claim the irq now and enable it later.570570+ */571571+ disable_irq(tps->irq);572572+ set_bit(FLAG_IRQ_ENABLE, &tps->flags);573573+#endif574574+ } else575575+ printk(KERN_WARNING "%s: IRQ not configured!\n",576576+ DRIVER_NAME);577577+578578+579579+ switch (tps->model) {580580+ case TPS65010:581581+ case TPS65012:582582+ tps->por = 1;583583+ break;584584+ case TPS_UNKNOWN:585585+ printk(KERN_WARNING "%s: unknown TPS chip\n", DRIVER_NAME);586586+ break;587587+ /* else CHGCONFIG.POR is replaced by AUA, enabling a WAIT mode */588588+ }589589+ tps->chgconf = i2c_smbus_read_byte_data(&tps->client, TPS_CHGCONFIG);590590+ show_chgconfig(tps->por, "conf/init", tps->chgconf);591591+592592+ show_chgstatus("chg/init",593593+ i2c_smbus_read_byte_data(&tps->client, TPS_CHGSTATUS));594594+ show_regstatus("reg/init",595595+ i2c_smbus_read_byte_data(&tps->client, TPS_REGSTATUS));596596+597597+ pr_debug("%s: vdcdc1 0x%02x, vdcdc2 %02x, vregs1 %02x\n", DRIVER_NAME,598598+ i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC1),599599+ i2c_smbus_read_byte_data(&tps->client, TPS_VDCDC2),600600+ i2c_smbus_read_byte_data(&tps->client, TPS_VREGS1));601601+ pr_debug("%s: defgpio 0x%02x, mask3 0x%02x\n", DRIVER_NAME,602602+ i2c_smbus_read_byte_data(&tps->client, TPS_DEFGPIO),603603+ i2c_smbus_read_byte_data(&tps->client, TPS_MASK3));604604+605605+ tps65010_driver.attach_adapter = tps65010_noscan;606606+ the_tps = tps;607607+608608+#if defined(CONFIG_USB_GADGET) && !defined(CONFIG_USB_OTG)609609+ /* USB hosts can't draw VBUS. OTG devices could, later610610+ * when OTG infrastructure enables it. USB peripherals611611+ * could be relying on VBUS while booting, though.612612+ */613613+ tps->vbus = 100;614614+#endif615615+616616+ /* unmask the "interesting" irqs, then poll once to617617+ * kickstart monitoring, initialize shadowed status618618+ * registers, and maybe disable VBUS draw.619619+ */620620+ tps->nmask1 = ~0;621621+ (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK1, ~tps->nmask1);622622+623623+ tps->nmask2 = TPS_REG_ONOFF;624624+ if (tps->model == TPS65013)625625+ tps->nmask2 |= TPS_REG_NO_CHG;626626+ (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK2, ~tps->nmask2);627627+628628+ (void) i2c_smbus_write_byte_data(&tps->client, TPS_MASK3, 0x0f629629+ | i2c_smbus_read_byte_data(&tps->client, TPS_MASK3));630630+631631+ tps65010_work(tps);632632+633633+ tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL,634634+ tps, DEBUG_FOPS);635635+ return 0;636636+}637637+638638+static int __init tps65010_scan_bus(struct i2c_adapter *bus)639639+{640640+ if (!i2c_check_functionality(bus, I2C_FUNC_SMBUS_BYTE_DATA))641641+ return -EINVAL;642642+ return i2c_probe(bus, &addr_data, tps65010_probe);643643+}644644+645645+static struct i2c_driver tps65010_driver = {646646+ .owner = THIS_MODULE,647647+ .name = "tps65010",648648+ .id = 888, /* FIXME assign "official" value */649649+ .flags = I2C_DF_NOTIFY,650650+ .attach_adapter = tps65010_scan_bus,651651+ .detach_client = __exit_p(tps65010_detach_client),652652+};653653+654654+/*-------------------------------------------------------------------------*/655655+656656+/* Draw from VBUS:657657+ * 0 mA -- DON'T DRAW (might supply power instead)658658+ * 100 mA -- usb unit load (slowest charge rate)659659+ * 500 mA -- usb high power (fast battery charge)660660+ */661661+int tps65010_set_vbus_draw(unsigned mA)662662+{663663+ unsigned long flags;664664+665665+ if (!the_tps)666666+ return -ENODEV;667667+668668+ /* assumes non-SMP */669669+ local_irq_save(flags);670670+ if (mA >= 500)671671+ mA = 500;672672+ else if (mA >= 100)673673+ mA = 100;674674+ else675675+ mA = 0;676676+ the_tps->vbus = mA;677677+ if ((the_tps->chgstatus & TPS_CHG_USB)678678+ && test_and_set_bit(679679+ FLAG_VBUS_CHANGED, &the_tps->flags)) {680680+ /* gadget drivers call this in_irq() */681681+ (void) schedule_work(&the_tps->work);682682+ }683683+ local_irq_restore(flags);684684+685685+ return 0;686686+}687687+EXPORT_SYMBOL(tps65010_set_vbus_draw);688688+689689+/*-------------------------------------------------------------------------*/690690+/* tps65010_set_gpio_out_value parameter:691691+ * gpio: GPIO1, GPIO2, GPIO3 or GPIO4692692+ * value: LOW or HIGH693693+ */694694+int tps65010_set_gpio_out_value(unsigned gpio, unsigned value)695695+{696696+ int status;697697+ unsigned defgpio;698698+699699+ if (!the_tps)700700+ return -ENODEV;701701+ if ((gpio < GPIO1) || (gpio > GPIO4))702702+ return -EINVAL;703703+704704+ down(&the_tps->lock);705705+706706+ defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO);707707+708708+ /* Configure GPIO for output */709709+ defgpio |= 1 << (gpio + 3);710710+711711+ /* Writing 1 forces a logic 0 on that GPIO and vice versa */712712+ switch (value) {713713+ case LOW:714714+ defgpio |= 1 << (gpio - 1); /* set GPIO low by writing 1 */715715+ break;716716+ /* case HIGH: */717717+ default:718718+ defgpio &= ~(1 << (gpio - 1)); /* set GPIO high by writing 0 */719719+ break;720720+ }721721+722722+ status = i2c_smbus_write_byte_data(&the_tps->client,723723+ TPS_DEFGPIO, defgpio);724724+725725+ pr_debug("%s: gpio%dout = %s, defgpio 0x%02x\n", DRIVER_NAME,726726+ gpio, value ? "high" : "low",727727+ i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO));728728+729729+ up(&the_tps->lock);730730+ return status;731731+}732732+EXPORT_SYMBOL(tps65010_set_gpio_out_value);733733+734734+/*-------------------------------------------------------------------------*/735735+/* tps65010_set_led parameter:736736+ * led: LED1 or LED2737737+ * mode: ON, OFF or BLINK738738+ */739739+int tps65010_set_led(unsigned led, unsigned mode)740740+{741741+ int status;742742+ unsigned led_on, led_per, offs;743743+744744+ if (!the_tps)745745+ return -ENODEV;746746+747747+ if(led == LED1)748748+ offs = 0;749749+ else {750750+ offs = 2;751751+ led = LED2;752752+ }753753+754754+ down(&the_tps->lock);755755+756756+ dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led,757757+ i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs));758758+759759+ dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led,760760+ i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs));761761+762762+ switch (mode) {763763+ case OFF:764764+ led_on = 1 << 7;765765+ led_per = 0 << 7;766766+ break;767767+ case ON:768768+ led_on = 1 << 7;769769+ led_per = 1 << 7;770770+ break;771771+ case BLINK:772772+ led_on = 0x30 | (0 << 7);773773+ led_per = 0x08 | (1 << 7);774774+ break;775775+ default:776776+ printk(KERN_ERR "%s: Wrong mode parameter for tps65010_set_led()\n",777777+ DRIVER_NAME);778778+ up(&the_tps->lock);779779+ return -EINVAL;780780+ }781781+782782+ status = i2c_smbus_write_byte_data(&the_tps->client,783783+ TPS_LED1_ON + offs, led_on);784784+785785+ if (status != 0) {786786+ printk(KERN_ERR "%s: Failed to write led%i_on register\n",787787+ DRIVER_NAME, led);788788+ up(&the_tps->lock);789789+ return status;790790+ }791791+792792+ dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led,793793+ i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs));794794+795795+ status = i2c_smbus_write_byte_data(&the_tps->client,796796+ TPS_LED1_PER + offs, led_per);797797+798798+ if (status != 0) {799799+ printk(KERN_ERR "%s: Failed to write led%i_per register\n",800800+ DRIVER_NAME, led);801801+ up(&the_tps->lock);802802+ return status;803803+ }804804+805805+ dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led,806806+ i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs));807807+808808+ up(&the_tps->lock);809809+810810+ return status;811811+}812812+EXPORT_SYMBOL(tps65010_set_led);813813+814814+/*-------------------------------------------------------------------------*/815815+/* tps65010_set_vib parameter:816816+ * value: ON or OFF817817+ */818818+int tps65010_set_vib(unsigned value)819819+{820820+ int status;821821+ unsigned vdcdc2;822822+823823+ if (!the_tps)824824+ return -ENODEV;825825+826826+ down(&the_tps->lock);827827+828828+ vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2);829829+ vdcdc2 &= ~(1 << 1);830830+ if (value)831831+ vdcdc2 |= (1 << 1);832832+ status = i2c_smbus_write_byte_data(&the_tps->client,833833+ TPS_VDCDC2, vdcdc2);834834+835835+ pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off");836836+837837+ up(&the_tps->lock);838838+ return status;839839+}840840+EXPORT_SYMBOL(tps65010_set_vib);841841+842842+/*-------------------------------------------------------------------------*/843843+/* tps65010_set_low_pwr parameter:844844+ * mode: ON or OFF845845+ */846846+int tps65010_set_low_pwr(unsigned mode)847847+{848848+ int status;849849+ unsigned vdcdc1;850850+851851+ if (!the_tps)852852+ return -ENODEV;853853+854854+ down(&the_tps->lock);855855+856856+ pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME,857857+ mode ? "enable" : "disable",858858+ i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));859859+860860+ vdcdc1 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1);861861+862862+ switch (mode) {863863+ case OFF:864864+ vdcdc1 &= ~TPS_ENABLE_LP; /* disable ENABLE_LP bit */865865+ break;866866+ /* case ON: */867867+ default:868868+ vdcdc1 |= TPS_ENABLE_LP; /* enable ENABLE_LP bit */869869+ break;870870+ }871871+872872+ status = i2c_smbus_write_byte_data(&the_tps->client,873873+ TPS_VDCDC1, vdcdc1);874874+875875+ if (status != 0)876876+ printk(KERN_ERR "%s: Failed to write vdcdc1 register\n",877877+ DRIVER_NAME);878878+ else879879+ pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME,880880+ i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));881881+882882+ up(&the_tps->lock);883883+884884+ return status;885885+}886886+EXPORT_SYMBOL(tps65010_set_low_pwr);887887+888888+/*-------------------------------------------------------------------------*/889889+/* tps65010_config_vregs1 parameter:890890+ * value to be written to VREGS1 register891891+ * Note: The complete register is written, set all bits you need892892+ */893893+int tps65010_config_vregs1(unsigned value)894894+{895895+ int status;896896+897897+ if (!the_tps)898898+ return -ENODEV;899899+900900+ down(&the_tps->lock);901901+902902+ pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,903903+ i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));904904+905905+ status = i2c_smbus_write_byte_data(&the_tps->client,906906+ TPS_VREGS1, value);907907+908908+ if (status != 0)909909+ printk(KERN_ERR "%s: Failed to write vregs1 register\n",910910+ DRIVER_NAME);911911+ else912912+ pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,913913+ i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));914914+915915+ up(&the_tps->lock);916916+917917+ return status;918918+}919919+EXPORT_SYMBOL(tps65010_config_vregs1);920920+921921+/*-------------------------------------------------------------------------*/922922+/* tps65013_set_low_pwr parameter:923923+ * mode: ON or OFF924924+ */925925+926926+/* FIXME: Assumes AC or USB power is present. Setting AUA bit is not927927+ required if power supply is through a battery */928928+929929+int tps65013_set_low_pwr(unsigned mode)930930+{931931+ int status;932932+ unsigned vdcdc1, chgconfig;933933+934934+ if (!the_tps || the_tps->por)935935+ return -ENODEV;936936+937937+ down(&the_tps->lock);938938+939939+ pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n",940940+ DRIVER_NAME,941941+ mode ? "enable" : "disable",942942+ i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG),943943+ i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));944944+945945+ chgconfig = i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG);946946+ vdcdc1 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1);947947+948948+ switch (mode) {949949+ case OFF:950950+ chgconfig &= ~TPS65013_AUA; /* disable AUA bit */951951+ vdcdc1 &= ~TPS_ENABLE_LP; /* disable ENABLE_LP bit */952952+ break;953953+ /* case ON: */954954+ default:955955+ chgconfig |= TPS65013_AUA; /* enable AUA bit */956956+ vdcdc1 |= TPS_ENABLE_LP; /* enable ENABLE_LP bit */957957+ break;958958+ }959959+960960+ status = i2c_smbus_write_byte_data(&the_tps->client,961961+ TPS_CHGCONFIG, chgconfig);962962+ if (status != 0) {963963+ printk(KERN_ERR "%s: Failed to write chconfig register\n",964964+ DRIVER_NAME);965965+ up(&the_tps->lock);966966+ return status;967967+ }968968+969969+ chgconfig = i2c_smbus_read_byte_data(&the_tps->client, TPS_CHGCONFIG);970970+ the_tps->chgconf = chgconfig;971971+ show_chgconfig(0, "chgconf", chgconfig);972972+973973+ status = i2c_smbus_write_byte_data(&the_tps->client,974974+ TPS_VDCDC1, vdcdc1);975975+976976+ if (status != 0)977977+ printk(KERN_ERR "%s: Failed to write vdcdc1 register\n",978978+ DRIVER_NAME);979979+ else980980+ pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME,981981+ i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));982982+983983+ up(&the_tps->lock);984984+985985+ return status;986986+}987987+EXPORT_SYMBOL(tps65013_set_low_pwr);988988+989989+/*-------------------------------------------------------------------------*/990990+991991+static int __init tps_init(void)992992+{993993+ u32 tries = 3;994994+ int status = -ENODEV;995995+996996+ printk(KERN_INFO "%s: version %s\n", DRIVER_NAME, DRIVER_VERSION);997997+998998+ /* some boards have startup glitches */999999+ while (tries--) {10001000+ status = i2c_add_driver(&tps65010_driver);10011001+ if (the_tps)10021002+ break;10031003+ i2c_del_driver(&tps65010_driver);10041004+ if (!tries) {10051005+ printk(KERN_ERR "%s: no chip?\n", DRIVER_NAME);10061006+ return -ENODEV;10071007+ }10081008+ pr_debug("%s: re-probe ...\n", DRIVER_NAME);10091009+ msleep(10);10101010+ }10111011+10121012+#if defined(CONFIG_ARM)10131013+ if (machine_is_omap_osk()) {10141014+10151015+ // FIXME: More should be placed in the initialization code10161016+ // of the submodules (DSP, ethernet, power management,10171017+ // board-osk.c). Careful: I2C is initialized "late".10181018+10191019+ /* Let LED1 (D9) blink */10201020+ tps65010_set_led(LED1, BLINK);10211021+10221022+ /* Disable LED 2 (D2) */10231023+ tps65010_set_led(LED2, OFF);10241024+10251025+ /* Set GPIO 1 HIGH to disable VBUS power supply;10261026+ * OHCI driver powers it up/down as needed.10271027+ */10281028+ tps65010_set_gpio_out_value(GPIO1, HIGH);10291029+10301030+ /* Set GPIO 2 low to turn on LED D3 */10311031+ tps65010_set_gpio_out_value(GPIO2, HIGH);10321032+10331033+ /* Set GPIO 3 low to take ethernet out of reset */10341034+ tps65010_set_gpio_out_value(GPIO3, LOW);10351035+10361036+ /* gpio4 for VDD_DSP */10371037+10381038+ /* Enable LOW_PWR */10391039+ tps65010_set_low_pwr(ON);10401040+10411041+ /* Switch VLDO2 to 3.0V for AIC23 */10421042+ tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V | TPS_LDO1_ENABLE);10431043+10441044+ } else if (machine_is_omap_h2()) {10451045+ /* gpio3 for SD, gpio4 for VDD_DSP */10461046+10471047+ /* Enable LOW_PWR */10481048+ tps65010_set_low_pwr(ON);10491049+ } else if (machine_is_omap_h3()) {10501050+ /* gpio4 for SD, gpio3 for VDD_DSP */10511051+#ifdef CONFIG_PM10521052+ /* Enable LOW_PWR */10531053+ tps65013_set_low_pwr(ON);10541054+#endif10551055+ }10561056+#endif10571057+10581058+ return status;10591059+}10601060+/* NOTE: this MUST be initialized before the other parts of the system10611061+ * that rely on it ... but after the i2c bus on which this relies.10621062+ * That is, much earlier than on PC-type systems, which don't often use10631063+ * I2C as a core system bus.10641064+ */10651065+subsys_initcall(tps_init);10661066+10671067+static void __exit tps_exit(void)10681068+{10691069+ i2c_del_driver(&tps65010_driver);10701070+}10711071+module_exit(tps_exit);10721072+
+147-150
drivers/i2c/chips/via686a.c
···11/*22 via686a.c - Part of lm_sensors, Linux kernel modules33 for hardware monitoring44-44+55 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,66 Ky�sti M�lkki <kmalkki@cc.hut.fi>,77 Mark Studebaker <mdsxyz123@yahoo.com>,88 and Bob Dougherty <bobd@stanford.edu>99- (Some conversion-factor data were contributed by Jonathan Teh Soon Yew 99+ (Some conversion-factor data were contributed by Jonathan Teh Soon Yew1010 <j.teh@iname.com> and Alex van Kaam <darkside@chello.nl>.)11111212 This program is free software; you can redistribute it and/or modify···3030 Warning - only supports a single device.3131*/32323333-#include <linux/config.h>3433#include <linux/module.h>3534#include <linux/slab.h>3635#include <linux/pci.h>3737-#include <linux/delay.h>3836#include <linux/jiffies.h>3937#include <linux/i2c.h>4038#include <linux/i2c-sensor.h>···6466/* Many VIA686A constants specified below */65676668/* Length of ISA address segment */6767-#define VIA686A_EXTENT 0x806868-#define VIA686A_BASE_REG 0x706969-#define VIA686A_ENABLE_REG 0x746969+#define VIA686A_EXTENT 0x807070+#define VIA686A_BASE_REG 0x707171+#define VIA686A_ENABLE_REG 0x7470727173/* The VIA686A registers */7274/* ins numbered 0-4 */7373-#define VIA686A_REG_IN_MAX(nr) (0x2b + ((nr) * 2))7474-#define VIA686A_REG_IN_MIN(nr) (0x2c + ((nr) * 2))7575-#define VIA686A_REG_IN(nr) (0x22 + (nr))7575+#define VIA686A_REG_IN_MAX(nr) (0x2b + ((nr) * 2))7676+#define VIA686A_REG_IN_MIN(nr) (0x2c + ((nr) * 2))7777+#define VIA686A_REG_IN(nr) (0x22 + (nr))76787779/* fans numbered 1-2 */7878-#define VIA686A_REG_FAN_MIN(nr) (0x3a + (nr))7979-#define VIA686A_REG_FAN(nr) (0x28 + (nr))8080-8181-/* the following values are as speced by VIA: */8282-static const u8 regtemp[] = { 0x20, 0x21, 0x1f };8383-static const u8 regover[] = { 0x39, 0x3d, 0x1d };8484-static const u8 reghyst[] = { 0x3a, 0x3e, 0x1e };8080+#define VIA686A_REG_FAN_MIN(nr) (0x3a + (nr))8181+#define VIA686A_REG_FAN(nr) (0x28 + (nr))85828683/* temps numbered 1-3 */8787-#define VIA686A_REG_TEMP(nr) (regtemp[nr])8888-#define VIA686A_REG_TEMP_OVER(nr) (regover[nr])8989-#define VIA686A_REG_TEMP_HYST(nr) (reghyst[nr])9090-#define VIA686A_REG_TEMP_LOW1 0x4b // bits 7-69191-#define VIA686A_REG_TEMP_LOW23 0x49 // 2 = bits 5-4, 3 = bits 7-68484+static const u8 VIA686A_REG_TEMP[] = { 0x20, 0x21, 0x1f };8585+static const u8 VIA686A_REG_TEMP_OVER[] = { 0x39, 0x3d, 0x1d };8686+static const u8 VIA686A_REG_TEMP_HYST[] = { 0x3a, 0x3e, 0x1e };8787+/* bits 7-6 */8888+#define VIA686A_REG_TEMP_LOW1 0x4b8989+/* 2 = bits 5-4, 3 = bits 7-6 */9090+#define VIA686A_REG_TEMP_LOW23 0x4992919393-#define VIA686A_REG_ALARM1 0x419494-#define VIA686A_REG_ALARM2 0x429595-#define VIA686A_REG_FANDIV 0x479696-#define VIA686A_REG_CONFIG 0x409797-/* The following register sets temp interrupt mode (bits 1-0 for temp1, 9292+#define VIA686A_REG_ALARM1 0x419393+#define VIA686A_REG_ALARM2 0x429494+#define VIA686A_REG_FANDIV 0x479595+#define VIA686A_REG_CONFIG 0x409696+/* The following register sets temp interrupt mode (bits 1-0 for temp1,9897 3-2 for temp2, 5-4 for temp3). Modes are:9998 00 interrupt stays as long as value is out-of-range10099 01 interrupt is cleared once register is read (default)101100 10 comparator mode- like 00, but ignores hysteresis102101 11 same as 00 */103103-#define VIA686A_REG_TEMP_MODE 0x4b102102+#define VIA686A_REG_TEMP_MODE 0x4b104103/* We'll just assume that you want to set all 3 simultaneously: */105105-#define VIA686A_TEMP_MODE_MASK 0x3F106106-#define VIA686A_TEMP_MODE_CONTINUOUS (0x00)104104+#define VIA686A_TEMP_MODE_MASK 0x3F105105+#define VIA686A_TEMP_MODE_CONTINUOUS 0x00107106108107/* Conversions. Limit checking is only done on the TO_REG109109- variants. 108108+ variants.110109111110********* VOLTAGE CONVERSIONS (Bob Dougherty) ********112111 From HWMon.cpp (Copyright 1998-2000 Jonathan Teh Soon Yew):···116121 That is:117122 volts = (25*regVal+133)*factor118123 regVal = (volts/factor-133)/25119119- (These conversions were contributed by Jonathan Teh Soon Yew 124124+ (These conversions were contributed by Jonathan Teh Soon Yew120125 <j.teh@iname.com>) */121126static inline u8 IN_TO_REG(long val, int inNum)122127{···177182 else178183 return double(temp)*0.924-127.33;179184180180- A fifth-order polynomial fits the unofficial data (provided by Alex van 181181- Kaam <darkside@chello.nl>) a bit better. It also give more reasonable 182182- numbers on my machine (ie. they agree with what my BIOS tells me). 185185+ A fifth-order polynomial fits the unofficial data (provided by Alex van186186+ Kaam <darkside@chello.nl>) a bit better. It also give more reasonable187187+ numbers on my machine (ie. they agree with what my BIOS tells me).183188 Here's the fifth-order fit to the 8-bit data:184184- temp = 1.625093e-10*val^5 - 1.001632e-07*val^4 + 2.457653e-05*val^3 - 189189+ temp = 1.625093e-10*val^5 - 1.001632e-07*val^4 + 2.457653e-05*val^3 -185190 2.967619e-03*val^2 + 2.175144e-01*val - 7.090067e+0.186191187187- (2000-10-25- RFD: thanks to Uwe Andersen <uandersen@mayah.com> for 192192+ (2000-10-25- RFD: thanks to Uwe Andersen <uandersen@mayah.com> for188193 finding my typos in this formula!)189194190190- Alas, none of the elegant function-fit solutions will work because we 191191- aren't allowed to use floating point in the kernel and doing it with 192192- integers doesn't rpovide enough precision. So we'll do boring old 193193- look-up table stuff. The unofficial data (see below) have effectively 194194- 7-bit resolution (they are rounded to the nearest degree). I'm assuming 195195- that the transfer function of the device is monotonic and smooth, so a 196196- smooth function fit to the data will allow us to get better precision. 195195+ Alas, none of the elegant function-fit solutions will work because we196196+ aren't allowed to use floating point in the kernel and doing it with197197+ integers doesn't provide enough precision. So we'll do boring old198198+ look-up table stuff. The unofficial data (see below) have effectively199199+ 7-bit resolution (they are rounded to the nearest degree). I'm assuming200200+ that the transfer function of the device is monotonic and smooth, so a201201+ smooth function fit to the data will allow us to get better precision.197202 I used the 5th-order poly fit described above and solved for198198- VIA register values 0-255. I *10 before rounding, so we get tenth-degree 199199- precision. (I could have done all 1024 values for our 10-bit readings, 200200- but the function is very linear in the useful range (0-80 deg C), so 201201- we'll just use linear interpolation for 10-bit readings.) So, tempLUT 203203+ VIA register values 0-255. I *10 before rounding, so we get tenth-degree204204+ precision. (I could have done all 1024 values for our 10-bit readings,205205+ but the function is very linear in the useful range (0-80 deg C), so206206+ we'll just use linear interpolation for 10-bit readings.) So, tempLUT202207 is the temp at via register values 0-255: */203208static const long tempLUT[] =204204- { -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519,205205- -503, -487, -471, -456, -442, -428, -414, -400, -387, -375,206206- -362, -350, -339, -327, -316, -305, -295, -285, -275, -265,207207- -255, -246, -237, -229, -220, -212, -204, -196, -188, -180,208208- -173, -166, -159, -152, -145, -139, -132, -126, -120, -114,209209- -108, -102, -96, -91, -85, -80, -74, -69, -64, -59, -54, -49,210210- -44, -39, -34, -29, -25, -20, -15, -11, -6, -2, 3, 7, 12, 16,211211- 20, 25, 29, 33, 37, 42, 46, 50, 54, 59, 63, 67, 71, 75, 79, 84,212212- 88, 92, 96, 100, 104, 109, 113, 117, 121, 125, 130, 134, 138,213213- 142, 146, 151, 155, 159, 163, 168, 172, 176, 181, 185, 189,214214- 193, 198, 202, 206, 211, 215, 219, 224, 228, 232, 237, 241,215215- 245, 250, 254, 259, 263, 267, 272, 276, 281, 285, 290, 294,216216- 299, 303, 307, 312, 316, 321, 325, 330, 334, 339, 344, 348,217217- 353, 357, 362, 366, 371, 376, 380, 385, 390, 395, 399, 404,218218- 409, 414, 419, 423, 428, 433, 438, 443, 449, 454, 459, 464,219219- 469, 475, 480, 486, 491, 497, 502, 508, 514, 520, 526, 532,220220- 538, 544, 551, 557, 564, 571, 578, 584, 592, 599, 606, 614,221221- 621, 629, 637, 645, 654, 662, 671, 680, 689, 698, 708, 718,222222- 728, 738, 749, 759, 770, 782, 793, 805, 818, 830, 843, 856,223223- 870, 883, 898, 912, 927, 943, 958, 975, 991, 1008, 1026, 1044,224224- 1062, 1081, 1101, 1121, 1141, 1162, 1184, 1206, 1229, 1252,225225- 1276, 1301, 1326, 1352, 1378, 1406, 1434, 1462209209+{ -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519,210210+ -503, -487, -471, -456, -442, -428, -414, -400, -387, -375,211211+ -362, -350, -339, -327, -316, -305, -295, -285, -275, -265,212212+ -255, -246, -237, -229, -220, -212, -204, -196, -188, -180,213213+ -173, -166, -159, -152, -145, -139, -132, -126, -120, -114,214214+ -108, -102, -96, -91, -85, -80, -74, -69, -64, -59, -54, -49,215215+ -44, -39, -34, -29, -25, -20, -15, -11, -6, -2, 3, 7, 12, 16,216216+ 20, 25, 29, 33, 37, 42, 46, 50, 54, 59, 63, 67, 71, 75, 79, 84,217217+ 88, 92, 96, 100, 104, 109, 113, 117, 121, 125, 130, 134, 138,218218+ 142, 146, 151, 155, 159, 163, 168, 172, 176, 181, 185, 189,219219+ 193, 198, 202, 206, 211, 215, 219, 224, 228, 232, 237, 241,220220+ 245, 250, 254, 259, 263, 267, 272, 276, 281, 285, 290, 294,221221+ 299, 303, 307, 312, 316, 321, 325, 330, 334, 339, 344, 348,222222+ 353, 357, 362, 366, 371, 376, 380, 385, 390, 395, 399, 404,223223+ 409, 414, 419, 423, 428, 433, 438, 443, 449, 454, 459, 464,224224+ 469, 475, 480, 486, 491, 497, 502, 508, 514, 520, 526, 532,225225+ 538, 544, 551, 557, 564, 571, 578, 584, 592, 599, 606, 614,226226+ 621, 629, 637, 645, 654, 662, 671, 680, 689, 698, 708, 718,227227+ 728, 738, 749, 759, 770, 782, 793, 805, 818, 830, 843, 856,228228+ 870, 883, 898, 912, 927, 943, 958, 975, 991, 1008, 1026, 1044,229229+ 1062, 1081, 1101, 1121, 1141, 1162, 1184, 1206, 1229, 1252,230230+ 1276, 1301, 1326, 1352, 1378, 1406, 1434, 1462226231};227232228228-/* the original LUT values from Alex van Kaam <darkside@chello.nl> 233233+/* the original LUT values from Alex van Kaam <darkside@chello.nl>229234 (for via register values 12-240):230235{-50,-49,-47,-45,-43,-41,-39,-38,-37,-35,-34,-33,-32,-31,231236-30,-29,-28,-27,-26,-25,-24,-24,-23,-22,-21,-20,-20,-19,-18,-17,-17,-16,-15,···240245241246242247 Here's the reverse LUT. I got it by doing a 6-th order poly fit (needed243243- an extra term for a good fit to these inverse data!) and then 244244- solving for each temp value from -50 to 110 (the useable range for 245245- this chip). Here's the fit: 246246- viaRegVal = -1.160370e-10*val^6 +3.193693e-08*val^5 - 1.464447e-06*val^4 248248+ an extra term for a good fit to these inverse data!) and then249249+ solving for each temp value from -50 to 110 (the useable range for250250+ this chip). Here's the fit:251251+ viaRegVal = -1.160370e-10*val^6 +3.193693e-08*val^5 - 1.464447e-06*val^4247252 - 2.525453e-04*val^3 + 1.424593e-02*val^2 + 2.148941e+00*val +7.275808e+01)248253 Note that n=161: */249254static const u8 viaLUT[] =250250- { 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 23,251251- 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40,252252- 41, 43, 45, 46, 48, 49, 51, 53, 55, 57, 59, 60, 62, 64, 66,253253- 69, 71, 73, 75, 77, 79, 82, 84, 86, 88, 91, 93, 95, 98, 100,254254- 103, 105, 107, 110, 112, 115, 117, 119, 122, 124, 126, 129,255255- 131, 134, 136, 138, 140, 143, 145, 147, 150, 152, 154, 156,256256- 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180,257257- 182, 183, 185, 187, 188, 190, 192, 193, 195, 196, 198, 199,258258- 200, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 213,259259- 214, 215, 216, 217, 218, 219, 220, 221, 222, 222, 223, 224,260260- 225, 226, 226, 227, 228, 228, 229, 230, 230, 231, 232, 232,261261- 233, 233, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239,262262- 239, 240255255+{ 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20, 21, 22, 23,256256+ 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 35, 36, 37, 39, 40,257257+ 41, 43, 45, 46, 48, 49, 51, 53, 55, 57, 59, 60, 62, 64, 66,258258+ 69, 71, 73, 75, 77, 79, 82, 84, 86, 88, 91, 93, 95, 98, 100,259259+ 103, 105, 107, 110, 112, 115, 117, 119, 122, 124, 126, 129,260260+ 131, 134, 136, 138, 140, 143, 145, 147, 150, 152, 154, 156,261261+ 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180,262262+ 182, 183, 185, 187, 188, 190, 192, 193, 195, 196, 198, 199,263263+ 200, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 213,264264+ 214, 215, 216, 217, 218, 219, 220, 221, 222, 222, 223, 224,265265+ 225, 226, 226, 227, 228, 228, 229, 230, 230, 231, 232, 232,266266+ 233, 233, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239,267267+ 239, 240263268};264269265270/* Converting temps to (8-bit) hyst and over registers···267272 The +50 is because the temps start at -50 */268273static inline u8 TEMP_TO_REG(long val)269274{270270- return viaLUT[val <= -50000 ? 0 : val >= 110000 ? 160 : 275275+ return viaLUT[val <= -50000 ? 0 : val >= 110000 ? 160 :271276 (val < 0 ? val - 500 : val + 500) / 1000 + 50];272277}273278···286291287292 /* do some linear interpolation */288293 return (tempLUT[eightBits] * (4 - twoBits) +289289- tempLUT[eightBits + 1] * twoBits) * 25;294294+ tempLUT[eightBits + 1] * twoBits) * 25;290295}291291-292292-#define ALARMS_FROM_REG(val) (val)293296294297#define DIV_FROM_REG(val) (1 << (val))295298#define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1)···351358 return sprintf(buf, "%ld\n", IN_FROM_REG(data->in_max[nr], nr));352359}353360354354-static ssize_t set_in_min(struct device *dev, const char *buf, 361361+static ssize_t set_in_min(struct device *dev, const char *buf,355362 size_t count, int nr) {356363 struct i2c_client *client = to_i2c_client(dev);357364 struct via686a_data *data = i2c_get_clientdata(client);358365 unsigned long val = simple_strtoul(buf, NULL, 10);359366360367 down(&data->update_lock);361361- data->in_min[nr] = IN_TO_REG(val,nr);362362- via686a_write_value(client, VIA686A_REG_IN_MIN(nr), 368368+ data->in_min[nr] = IN_TO_REG(val, nr);369369+ via686a_write_value(client, VIA686A_REG_IN_MIN(nr),363370 data->in_min[nr]);364371 up(&data->update_lock);365372 return count;366373}367367-static ssize_t set_in_max(struct device *dev, const char *buf, 374374+static ssize_t set_in_max(struct device *dev, const char *buf,368375 size_t count, int nr) {369376 struct i2c_client *client = to_i2c_client(dev);370377 struct via686a_data *data = i2c_get_clientdata(client);371378 unsigned long val = simple_strtoul(buf, NULL, 10);372379373380 down(&data->update_lock);374374- data->in_max[nr] = IN_TO_REG(val,nr);375375- via686a_write_value(client, VIA686A_REG_IN_MAX(nr), 381381+ data->in_max[nr] = IN_TO_REG(val, nr);382382+ via686a_write_value(client, VIA686A_REG_IN_MAX(nr),376383 data->in_max[nr]);377384 up(&data->update_lock);378385 return count;···428435 struct via686a_data *data = via686a_update_device(dev);429436 return sprintf(buf, "%ld\n", TEMP_FROM_REG(data->temp_hyst[nr]));430437}431431-static ssize_t set_temp_over(struct device *dev, const char *buf, 438438+static ssize_t set_temp_over(struct device *dev, const char *buf,432439 size_t count, int nr) {433440 struct i2c_client *client = to_i2c_client(dev);434441 struct via686a_data *data = i2c_get_clientdata(client);···436443437444 down(&data->update_lock);438445 data->temp_over[nr] = TEMP_TO_REG(val);439439- via686a_write_value(client, VIA686A_REG_TEMP_OVER(nr), data->temp_over[nr]);446446+ via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr],447447+ data->temp_over[nr]);440448 up(&data->update_lock);441449 return count;442450}443443-static ssize_t set_temp_hyst(struct device *dev, const char *buf, 451451+static ssize_t set_temp_hyst(struct device *dev, const char *buf,444452 size_t count, int nr) {445453 struct i2c_client *client = to_i2c_client(dev);446454 struct via686a_data *data = i2c_get_clientdata(client);···449455450456 down(&data->update_lock);451457 data->temp_hyst[nr] = TEMP_TO_REG(val);452452- via686a_write_value(client, VIA686A_REG_TEMP_HYST(nr), data->temp_hyst[nr]);458458+ via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr],459459+ data->temp_hyst[nr]);453460 up(&data->update_lock);454461 return count;455462}···483488static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \484489 show_temp_##offset##_over, set_temp_##offset##_over); \485490static DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \486486- show_temp_##offset##_hyst, set_temp_##offset##_hyst); 491491+ show_temp_##offset##_hyst, set_temp_##offset##_hyst);487492488493show_temp_offset(1);489494show_temp_offset(2);···492497/* 2 Fans */493498static ssize_t show_fan(struct device *dev, char *buf, int nr) {494499 struct via686a_data *data = via686a_update_device(dev);495495- return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], 500500+ return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr],496501 DIV_FROM_REG(data->fan_div[nr])) );497502}498503static ssize_t show_fan_min(struct device *dev, char *buf, int nr) {499504 struct via686a_data *data = via686a_update_device(dev);500500- return sprintf(buf,"%d\n",505505+ return sprintf(buf, "%d\n",501506 FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr])) );502507}503508static ssize_t show_fan_div(struct device *dev, char *buf, int nr) {504509 struct via686a_data *data = via686a_update_device(dev);505505- return sprintf(buf,"%d\n", DIV_FROM_REG(data->fan_div[nr]) );510510+ return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]) );506511}507507-static ssize_t set_fan_min(struct device *dev, const char *buf, 512512+static ssize_t set_fan_min(struct device *dev, const char *buf,508513 size_t count, int nr) {509514 struct i2c_client *client = to_i2c_client(dev);510515 struct via686a_data *data = i2c_get_clientdata(client);···516521 up(&data->update_lock);517522 return count;518523}519519-static ssize_t set_fan_div(struct device *dev, const char *buf, 524524+static ssize_t set_fan_div(struct device *dev, const char *buf,520525 size_t count, int nr) {521526 struct i2c_client *client = to_i2c_client(dev);522527 struct via686a_data *data = i2c_get_clientdata(client);···567572/* Alarms */568573static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, char *buf) {569574 struct via686a_data *data = via686a_update_device(dev);570570- return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms));575575+ return sprintf(buf, "%u\n", data->alarms);571576}572577static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);573578···607612 }608613609614 /* 8231 requires multiple of 256, we enforce that on 686 as well */610610- if(force_addr)615615+ if (force_addr)611616 address = force_addr & 0xFF00;612617613613- if(force_addr) {614614- dev_warn(&adapter->dev,"forcing ISA address 0x%04X\n", address);618618+ if (force_addr) {619619+ dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n",620620+ address);615621 if (PCIBIOS_SUCCESSFUL !=616622 pci_write_config_word(s_bridge, VIA686A_BASE_REG, address))617623 return -ENODEV;···621625 pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val))622626 return -ENODEV;623627 if (!(val & 0x0001)) {624624- dev_warn(&adapter->dev,"enabling sensors\n");628628+ dev_warn(&adapter->dev, "enabling sensors\n");625629 if (PCIBIOS_SUCCESSFUL !=626630 pci_write_config_word(s_bridge, VIA686A_ENABLE_REG,627627- val | 0x0001))631631+ val | 0x0001))628632 return -ENODEV;629633 }630634631635 /* Reserve the ISA region */632636 if (!request_region(address, VIA686A_EXTENT, via686a_driver.name)) {633633- dev_err(&adapter->dev,"region 0x%x already in use!\n",634634- address);637637+ dev_err(&adapter->dev, "region 0x%x already in use!\n",638638+ address);635639 return -ENODEV;636640 }637641···656660 /* Tell the I2C layer a new client has arrived */657661 if ((err = i2c_attach_client(new_client)))658662 goto ERROR3;659659-663663+660664 /* Initialize the VIA686A chip */661665 via686a_init_client(new_client);662666···695699696700 return 0;697701698698- ERROR3:702702+ERROR3:699703 kfree(data);700700- ERROR0:704704+ERROR0:701705 release_region(address, VIA686A_EXTENT);702706 return err;703707}···728732 via686a_write_value(client, VIA686A_REG_CONFIG, (reg|0x01)&0x7F);729733730734 /* Configure temp interrupt mode for continuous-interrupt operation */731731- via686a_write_value(client, VIA686A_REG_TEMP_MODE, 735735+ via686a_write_value(client, VIA686A_REG_TEMP_MODE,732736 via686a_read_value(client, VIA686A_REG_TEMP_MODE) &733737 !(VIA686A_TEMP_MODE_MASK | VIA686A_TEMP_MODE_CONTINUOUS));734738}···760764 }761765 for (i = 0; i <= 2; i++) {762766 data->temp[i] = via686a_read_value(client,763763- VIA686A_REG_TEMP(i)) << 2;767767+ VIA686A_REG_TEMP[i]) << 2;764768 data->temp_over[i] =765769 via686a_read_value(client,766766- VIA686A_REG_TEMP_OVER(i));770770+ VIA686A_REG_TEMP_OVER[i]);767771 data->temp_hyst[i] =768772 via686a_read_value(client,769769- VIA686A_REG_TEMP_HYST(i));773773+ VIA686A_REG_TEMP_HYST[i]);770774 }771771- /* add in lower 2 bits 775775+ /* add in lower 2 bits772776 temp1 uses bits 7-6 of VIA686A_REG_TEMP_LOW1773777 temp2 uses bits 5-4 of VIA686A_REG_TEMP_LOW23774778 temp3 uses bits 7-6 of VIA686A_REG_TEMP_LOW23···800804}801805802806static struct pci_device_id via686a_pci_ids[] = {803803- { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4) },804804- { 0, }807807+ { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4) },808808+ { 0, }805809};806810807811MODULE_DEVICE_TABLE(pci, via686a_pci_ids);808812809813static int __devinit via686a_pci_probe(struct pci_dev *dev,810810- const struct pci_device_id *id)814814+ const struct pci_device_id *id)811815{812812- u16 val;813813- int addr = 0;816816+ u16 val;817817+ int addr = 0;814818815815- if (PCIBIOS_SUCCESSFUL !=816816- pci_read_config_word(dev, VIA686A_BASE_REG, &val))817817- return -ENODEV;819819+ if (PCIBIOS_SUCCESSFUL !=820820+ pci_read_config_word(dev, VIA686A_BASE_REG, &val))821821+ return -ENODEV;818822819819- addr = val & ~(VIA686A_EXTENT - 1);820820- if (addr == 0 && force_addr == 0) {821821- dev_err(&dev->dev,"base address not set - upgrade BIOS or use force_addr=0xaddr\n");822822- return -ENODEV;823823- }824824- if (force_addr)825825- addr = force_addr; /* so detect will get called */823823+ addr = val & ~(VIA686A_EXTENT - 1);824824+ if (addr == 0 && force_addr == 0) {825825+ dev_err(&dev->dev, "base address not set - upgrade BIOS "826826+ "or use force_addr=0xaddr\n");827827+ return -ENODEV;828828+ }829829+ if (force_addr)830830+ addr = force_addr; /* so detect will get called */826831827827- if (!addr) {828828- dev_err(&dev->dev,"No Via 686A sensors found.\n");829829- return -ENODEV;830830- }831831- normal_isa[0] = addr;832832+ if (!addr) {833833+ dev_err(&dev->dev, "No Via 686A sensors found.\n");834834+ return -ENODEV;835835+ }836836+ normal_isa[0] = addr;832837833838 s_bridge = pci_dev_get(dev);834839 if (i2c_add_driver(&via686a_driver)) {···845848}846849847850static struct pci_driver via686a_pci_driver = {848848- .name = "via686a",849849- .id_table = via686a_pci_ids,850850- .probe = via686a_pci_probe,851851+ .name = "via686a",852852+ .id_table = via686a_pci_ids,853853+ .probe = via686a_pci_probe,851854};852855853856static int __init sm_via686a_init(void)854857{855855- return pci_register_driver(&via686a_pci_driver);858858+ return pci_register_driver(&via686a_pci_driver);856859}857860858861static void __exit sm_via686a_exit(void)···866869}867870868871MODULE_AUTHOR("Ky�sti M�lkki <kmalkki@cc.hut.fi>, "869869- "Mark Studebaker <mdsxyz123@yahoo.com> "870870- "and Bob Dougherty <bobd@stanford.edu>");872872+ "Mark Studebaker <mdsxyz123@yahoo.com> "873873+ "and Bob Dougherty <bobd@stanford.edu>");871874MODULE_DESCRIPTION("VIA 686A Sensor device");872875MODULE_LICENSE("GPL");873876
+846
drivers/i2c/chips/w83627ehf.c
···11+/*22+ w83627ehf - Driver for the hardware monitoring functionality of33+ the Winbond W83627EHF Super-I/O chip44+ Copyright (C) 2005 Jean Delvare <khali@linux-fr.org>55+66+ Shamelessly ripped from the w83627hf driver77+ Copyright (C) 2003 Mark Studebaker88+99+ Thanks to Leon Moonen, Steve Cliffe and Grant Coady for their help1010+ in testing and debugging this driver.1111+1212+ This program is free software; you can redistribute it and/or modify1313+ it under the terms of the GNU General Public License as published by1414+ the Free Software Foundation; either version 2 of the License, or1515+ (at your option) any later version.1616+1717+ This program is distributed in the hope that it will be useful,1818+ but WITHOUT ANY WARRANTY; without even the implied warranty of1919+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2020+ GNU General Public License for more details.2121+2222+ You should have received a copy of the GNU General Public License2323+ along with this program; if not, write to the Free Software2424+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.2525+2626+2727+ Supports the following chips:2828+2929+ Chip #vin #fan #pwm #temp chip_id man_id3030+ w83627ehf - 5 - 3 0x88 0x5ca33131+3232+ This is a preliminary version of the driver, only supporting the3333+ fan and temperature inputs. The chip does much more than that.3434+*/3535+3636+#include <linux/module.h>3737+#include <linux/init.h>3838+#include <linux/slab.h>3939+#include <linux/i2c.h>4040+#include <linux/i2c-sensor.h>4141+#include <asm/io.h>4242+#include "lm75.h"4343+4444+/* Addresses to scan4545+ The actual ISA address is read from Super-I/O configuration space */4646+static unsigned short normal_i2c[] = { I2C_CLIENT_END };4747+static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END };4848+4949+/* Insmod parameters */5050+SENSORS_INSMOD_1(w83627ehf);5151+5252+/*5353+ * Super-I/O constants and functions5454+ */5555+5656+static int REG; /* The register to read/write */5757+static int VAL; /* The value to read/write */5858+5959+#define W83627EHF_LD_HWM 0x0b6060+6161+#define SIO_REG_LDSEL 0x07 /* Logical device select */6262+#define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */6363+#define SIO_REG_ENABLE 0x30 /* Logical device enable */6464+#define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */6565+6666+#define SIO_W83627EHF_ID 0x88406767+#define SIO_ID_MASK 0xFFC06868+6969+static inline void7070+superio_outb(int reg, int val)7171+{7272+ outb(reg, REG);7373+ outb(val, VAL);7474+}7575+7676+static inline int7777+superio_inb(int reg)7878+{7979+ outb(reg, REG);8080+ return inb(VAL);8181+}8282+8383+static inline void8484+superio_select(int ld)8585+{8686+ outb(SIO_REG_LDSEL, REG);8787+ outb(ld, VAL);8888+}8989+9090+static inline void9191+superio_enter(void)9292+{9393+ outb(0x87, REG);9494+ outb(0x87, REG);9595+}9696+9797+static inline void9898+superio_exit(void)9999+{100100+ outb(0x02, REG);101101+ outb(0x02, VAL);102102+}103103+104104+/*105105+ * ISA constants106106+ */107107+108108+#define REGION_LENGTH 8109109+#define ADDR_REG_OFFSET 5110110+#define DATA_REG_OFFSET 6111111+112112+#define W83627EHF_REG_BANK 0x4E113113+#define W83627EHF_REG_CONFIG 0x40114114+#define W83627EHF_REG_CHIP_ID 0x49115115+#define W83627EHF_REG_MAN_ID 0x4F116116+117117+static const u16 W83627EHF_REG_FAN[] = { 0x28, 0x29, 0x2a, 0x3f, 0x553 };118118+static const u16 W83627EHF_REG_FAN_MIN[] = { 0x3b, 0x3c, 0x3d, 0x3e, 0x55c };119119+120120+#define W83627EHF_REG_TEMP1 0x27121121+#define W83627EHF_REG_TEMP1_HYST 0x3a122122+#define W83627EHF_REG_TEMP1_OVER 0x39123123+static const u16 W83627EHF_REG_TEMP[] = { 0x150, 0x250 };124124+static const u16 W83627EHF_REG_TEMP_HYST[] = { 0x153, 0x253 };125125+static const u16 W83627EHF_REG_TEMP_OVER[] = { 0x155, 0x255 };126126+static const u16 W83627EHF_REG_TEMP_CONFIG[] = { 0x152, 0x252 };127127+128128+/* Fan clock dividers are spread over the following five registers */129129+#define W83627EHF_REG_FANDIV1 0x47130130+#define W83627EHF_REG_FANDIV2 0x4B131131+#define W83627EHF_REG_VBAT 0x5D132132+#define W83627EHF_REG_DIODE 0x59133133+#define W83627EHF_REG_SMI_OVT 0x4C134134+135135+/*136136+ * Conversions137137+ */138138+139139+static inline unsigned int140140+fan_from_reg(u8 reg, unsigned int div)141141+{142142+ if (reg == 0 || reg == 255)143143+ return 0;144144+ return 1350000U / (reg * div);145145+}146146+147147+static inline unsigned int148148+div_from_reg(u8 reg)149149+{150150+ return 1 << reg;151151+}152152+153153+static inline int154154+temp1_from_reg(s8 reg)155155+{156156+ return reg * 1000;157157+}158158+159159+static inline s8160160+temp1_to_reg(int temp)161161+{162162+ if (temp <= -128000)163163+ return -128;164164+ if (temp >= 127000)165165+ return 127;166166+ if (temp < 0)167167+ return (temp - 500) / 1000;168168+ return (temp + 500) / 1000;169169+}170170+171171+/*172172+ * Data structures and manipulation thereof173173+ */174174+175175+struct w83627ehf_data {176176+ struct i2c_client client;177177+ struct semaphore lock;178178+179179+ struct semaphore update_lock;180180+ char valid; /* !=0 if following fields are valid */181181+ unsigned long last_updated; /* In jiffies */182182+183183+ /* Register values */184184+ u8 fan[5];185185+ u8 fan_min[5];186186+ u8 fan_div[5];187187+ u8 has_fan; /* some fan inputs can be disabled */188188+ s8 temp1;189189+ s8 temp1_max;190190+ s8 temp1_max_hyst;191191+ s16 temp[2];192192+ s16 temp_max[2];193193+ s16 temp_max_hyst[2];194194+};195195+196196+static inline int is_word_sized(u16 reg)197197+{198198+ return (((reg & 0xff00) == 0x100199199+ || (reg & 0xff00) == 0x200)200200+ && ((reg & 0x00ff) == 0x50201201+ || (reg & 0x00ff) == 0x53202202+ || (reg & 0x00ff) == 0x55));203203+}204204+205205+/* We assume that the default bank is 0, thus the following two functions do206206+ nothing for registers which live in bank 0. For others, they respectively207207+ set the bank register to the correct value (before the register is208208+ accessed), and back to 0 (afterwards). */209209+static inline void w83627ehf_set_bank(struct i2c_client *client, u16 reg)210210+{211211+ if (reg & 0xff00) {212212+ outb_p(W83627EHF_REG_BANK, client->addr + ADDR_REG_OFFSET);213213+ outb_p(reg >> 8, client->addr + DATA_REG_OFFSET);214214+ }215215+}216216+217217+static inline void w83627ehf_reset_bank(struct i2c_client *client, u16 reg)218218+{219219+ if (reg & 0xff00) {220220+ outb_p(W83627EHF_REG_BANK, client->addr + ADDR_REG_OFFSET);221221+ outb_p(0, client->addr + DATA_REG_OFFSET);222222+ }223223+}224224+225225+static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg)226226+{227227+ struct w83627ehf_data *data = i2c_get_clientdata(client);228228+ int res, word_sized = is_word_sized(reg);229229+230230+ down(&data->lock);231231+232232+ w83627ehf_set_bank(client, reg);233233+ outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET);234234+ res = inb_p(client->addr + DATA_REG_OFFSET);235235+ if (word_sized) {236236+ outb_p((reg & 0xff) + 1,237237+ client->addr + ADDR_REG_OFFSET);238238+ res = (res << 8) + inb_p(client->addr + DATA_REG_OFFSET);239239+ }240240+ w83627ehf_reset_bank(client, reg);241241+242242+ up(&data->lock);243243+244244+ return res;245245+}246246+247247+static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value)248248+{249249+ struct w83627ehf_data *data = i2c_get_clientdata(client);250250+ int word_sized = is_word_sized(reg);251251+252252+ down(&data->lock);253253+254254+ w83627ehf_set_bank(client, reg);255255+ outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET);256256+ if (word_sized) {257257+ outb_p(value >> 8, client->addr + DATA_REG_OFFSET);258258+ outb_p((reg & 0xff) + 1,259259+ client->addr + ADDR_REG_OFFSET);260260+ }261261+ outb_p(value & 0xff, client->addr + DATA_REG_OFFSET);262262+ w83627ehf_reset_bank(client, reg);263263+264264+ up(&data->lock);265265+ return 0;266266+}267267+268268+/* This function assumes that the caller holds data->update_lock */269269+static void w83627ehf_write_fan_div(struct i2c_client *client, int nr)270270+{271271+ struct w83627ehf_data *data = i2c_get_clientdata(client);272272+ u8 reg;273273+274274+ switch (nr) {275275+ case 0:276276+ reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0xcf)277277+ | ((data->fan_div[0] & 0x03) << 4);278278+ w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg);279279+ reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xdf)280280+ | ((data->fan_div[0] & 0x04) << 3);281281+ w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg);282282+ break;283283+ case 1:284284+ reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0x3f)285285+ | ((data->fan_div[1] & 0x03) << 6);286286+ w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg);287287+ reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xbf)288288+ | ((data->fan_div[1] & 0x04) << 4);289289+ w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg);290290+ break;291291+ case 2:292292+ reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV2) & 0x3f)293293+ | ((data->fan_div[2] & 0x03) << 6);294294+ w83627ehf_write_value(client, W83627EHF_REG_FANDIV2, reg);295295+ reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0x7f)296296+ | ((data->fan_div[2] & 0x04) << 5);297297+ w83627ehf_write_value(client, W83627EHF_REG_VBAT, reg);298298+ break;299299+ case 3:300300+ reg = (w83627ehf_read_value(client, W83627EHF_REG_DIODE) & 0xfc)301301+ | (data->fan_div[3] & 0x03);302302+ w83627ehf_write_value(client, W83627EHF_REG_DIODE, reg);303303+ reg = (w83627ehf_read_value(client, W83627EHF_REG_SMI_OVT) & 0x7f)304304+ | ((data->fan_div[3] & 0x04) << 5);305305+ w83627ehf_write_value(client, W83627EHF_REG_SMI_OVT, reg);306306+ break;307307+ case 4:308308+ reg = (w83627ehf_read_value(client, W83627EHF_REG_DIODE) & 0x73)309309+ | ((data->fan_div[4] & 0x03) << 3)310310+ | ((data->fan_div[4] & 0x04) << 5);311311+ w83627ehf_write_value(client, W83627EHF_REG_DIODE, reg);312312+ break;313313+ }314314+}315315+316316+static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)317317+{318318+ struct i2c_client *client = to_i2c_client(dev);319319+ struct w83627ehf_data *data = i2c_get_clientdata(client);320320+ int i;321321+322322+ down(&data->update_lock);323323+324324+ if (time_after(jiffies, data->last_updated + HZ)325325+ || !data->valid) {326326+ /* Fan clock dividers */327327+ i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1);328328+ data->fan_div[0] = (i >> 4) & 0x03;329329+ data->fan_div[1] = (i >> 6) & 0x03;330330+ i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV2);331331+ data->fan_div[2] = (i >> 6) & 0x03;332332+ i = w83627ehf_read_value(client, W83627EHF_REG_VBAT);333333+ data->fan_div[0] |= (i >> 3) & 0x04;334334+ data->fan_div[1] |= (i >> 4) & 0x04;335335+ data->fan_div[2] |= (i >> 5) & 0x04;336336+ if (data->has_fan & ((1 << 3) | (1 << 4))) {337337+ i = w83627ehf_read_value(client, W83627EHF_REG_DIODE);338338+ data->fan_div[3] = i & 0x03;339339+ data->fan_div[4] = ((i >> 2) & 0x03)340340+ | ((i >> 5) & 0x04);341341+ }342342+ if (data->has_fan & (1 << 3)) {343343+ i = w83627ehf_read_value(client, W83627EHF_REG_SMI_OVT);344344+ data->fan_div[3] |= (i >> 5) & 0x04;345345+ }346346+347347+ /* Measured fan speeds and limits */348348+ for (i = 0; i < 5; i++) {349349+ if (!(data->has_fan & (1 << i)))350350+ continue;351351+352352+ data->fan[i] = w83627ehf_read_value(client,353353+ W83627EHF_REG_FAN[i]);354354+ data->fan_min[i] = w83627ehf_read_value(client,355355+ W83627EHF_REG_FAN_MIN[i]);356356+357357+ /* If we failed to measure the fan speed and clock358358+ divider can be increased, let's try that for next359359+ time */360360+ if (data->fan[i] == 0xff361361+ && data->fan_div[i] < 0x07) {362362+ dev_dbg(&client->dev, "Increasing fan %d "363363+ "clock divider from %u to %u\n",364364+ i, div_from_reg(data->fan_div[i]),365365+ div_from_reg(data->fan_div[i] + 1));366366+ data->fan_div[i]++;367367+ w83627ehf_write_fan_div(client, i);368368+ /* Preserve min limit if possible */369369+ if (data->fan_min[i] >= 2370370+ && data->fan_min[i] != 255)371371+ w83627ehf_write_value(client,372372+ W83627EHF_REG_FAN_MIN[i],373373+ (data->fan_min[i] /= 2));374374+ }375375+ }376376+377377+ /* Measured temperatures and limits */378378+ data->temp1 = w83627ehf_read_value(client,379379+ W83627EHF_REG_TEMP1);380380+ data->temp1_max = w83627ehf_read_value(client,381381+ W83627EHF_REG_TEMP1_OVER);382382+ data->temp1_max_hyst = w83627ehf_read_value(client,383383+ W83627EHF_REG_TEMP1_HYST);384384+ for (i = 0; i < 2; i++) {385385+ data->temp[i] = w83627ehf_read_value(client,386386+ W83627EHF_REG_TEMP[i]);387387+ data->temp_max[i] = w83627ehf_read_value(client,388388+ W83627EHF_REG_TEMP_OVER[i]);389389+ data->temp_max_hyst[i] = w83627ehf_read_value(client,390390+ W83627EHF_REG_TEMP_HYST[i]);391391+ }392392+393393+ data->last_updated = jiffies;394394+ data->valid = 1;395395+ }396396+397397+ up(&data->update_lock);398398+ return data;399399+}400400+401401+/*402402+ * Sysfs callback functions403403+ */404404+405405+#define show_fan_reg(reg) \406406+static ssize_t \407407+show_##reg(struct device *dev, char *buf, int nr) \408408+{ \409409+ struct w83627ehf_data *data = w83627ehf_update_device(dev); \410410+ return sprintf(buf, "%d\n", \411411+ fan_from_reg(data->reg[nr], \412412+ div_from_reg(data->fan_div[nr]))); \413413+}414414+show_fan_reg(fan);415415+show_fan_reg(fan_min);416416+417417+static ssize_t418418+show_fan_div(struct device *dev, char *buf, int nr)419419+{420420+ struct w83627ehf_data *data = w83627ehf_update_device(dev);421421+ return sprintf(buf, "%u\n",422422+ div_from_reg(data->fan_div[nr]));423423+}424424+425425+static ssize_t426426+store_fan_min(struct device *dev, const char *buf, size_t count, int nr)427427+{428428+ struct i2c_client *client = to_i2c_client(dev);429429+ struct w83627ehf_data *data = i2c_get_clientdata(client);430430+ unsigned int val = simple_strtoul(buf, NULL, 10);431431+ unsigned int reg;432432+ u8 new_div;433433+434434+ down(&data->update_lock);435435+ if (!val) {436436+ /* No min limit, alarm disabled */437437+ data->fan_min[nr] = 255;438438+ new_div = data->fan_div[nr]; /* No change */439439+ dev_info(dev, "fan%u low limit and alarm disabled\n", nr + 1);440440+ } else if ((reg = 1350000U / val) >= 128 * 255) {441441+ /* Speed below this value cannot possibly be represented,442442+ even with the highest divider (128) */443443+ data->fan_min[nr] = 254;444444+ new_div = 7; /* 128 == (1 << 7) */445445+ dev_warn(dev, "fan%u low limit %u below minimum %u, set to "446446+ "minimum\n", nr + 1, val, fan_from_reg(254, 128));447447+ } else if (!reg) {448448+ /* Speed above this value cannot possibly be represented,449449+ even with the lowest divider (1) */450450+ data->fan_min[nr] = 1;451451+ new_div = 0; /* 1 == (1 << 0) */452452+ dev_warn(dev, "fan%u low limit %u above maximum %u, set to "453453+ "maximum\n", nr + 1, val, fan_from_reg(1, 1));454454+ } else {455455+ /* Automatically pick the best divider, i.e. the one such456456+ that the min limit will correspond to a register value457457+ in the 96..192 range */458458+ new_div = 0;459459+ while (reg > 192 && new_div < 7) {460460+ reg >>= 1;461461+ new_div++;462462+ }463463+ data->fan_min[nr] = reg;464464+ }465465+466466+ /* Write both the fan clock divider (if it changed) and the new467467+ fan min (unconditionally) */468468+ if (new_div != data->fan_div[nr]) {469469+ if (new_div > data->fan_div[nr])470470+ data->fan[nr] >>= (data->fan_div[nr] - new_div);471471+ else472472+ data->fan[nr] <<= (new_div - data->fan_div[nr]);473473+474474+ dev_dbg(dev, "fan%u clock divider changed from %u to %u\n",475475+ nr + 1, div_from_reg(data->fan_div[nr]),476476+ div_from_reg(new_div));477477+ data->fan_div[nr] = new_div;478478+ w83627ehf_write_fan_div(client, nr);479479+ }480480+ w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr],481481+ data->fan_min[nr]);482482+ up(&data->update_lock);483483+484484+ return count;485485+}486486+487487+#define sysfs_fan_offset(offset) \488488+static ssize_t \489489+show_reg_fan_##offset(struct device *dev, struct device_attribute *attr, \490490+ char *buf) \491491+{ \492492+ return show_fan(dev, buf, offset-1); \493493+} \494494+static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \495495+ show_reg_fan_##offset, NULL);496496+497497+#define sysfs_fan_min_offset(offset) \498498+static ssize_t \499499+show_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \500500+ char *buf) \501501+{ \502502+ return show_fan_min(dev, buf, offset-1); \503503+} \504504+static ssize_t \505505+store_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \506506+ const char *buf, size_t count) \507507+{ \508508+ return store_fan_min(dev, buf, count, offset-1); \509509+} \510510+static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \511511+ show_reg_fan##offset##_min, \512512+ store_reg_fan##offset##_min);513513+514514+#define sysfs_fan_div_offset(offset) \515515+static ssize_t \516516+show_reg_fan##offset##_div(struct device *dev, struct device_attribute *attr, \517517+ char *buf) \518518+{ \519519+ return show_fan_div(dev, buf, offset - 1); \520520+} \521521+static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \522522+ show_reg_fan##offset##_div, NULL);523523+524524+sysfs_fan_offset(1);525525+sysfs_fan_min_offset(1);526526+sysfs_fan_div_offset(1);527527+sysfs_fan_offset(2);528528+sysfs_fan_min_offset(2);529529+sysfs_fan_div_offset(2);530530+sysfs_fan_offset(3);531531+sysfs_fan_min_offset(3);532532+sysfs_fan_div_offset(3);533533+sysfs_fan_offset(4);534534+sysfs_fan_min_offset(4);535535+sysfs_fan_div_offset(4);536536+sysfs_fan_offset(5);537537+sysfs_fan_min_offset(5);538538+sysfs_fan_div_offset(5);539539+540540+#define show_temp1_reg(reg) \541541+static ssize_t \542542+show_##reg(struct device *dev, struct device_attribute *attr, \543543+ char *buf) \544544+{ \545545+ struct w83627ehf_data *data = w83627ehf_update_device(dev); \546546+ return sprintf(buf, "%d\n", temp1_from_reg(data->reg)); \547547+}548548+show_temp1_reg(temp1);549549+show_temp1_reg(temp1_max);550550+show_temp1_reg(temp1_max_hyst);551551+552552+#define store_temp1_reg(REG, reg) \553553+static ssize_t \554554+store_temp1_##reg(struct device *dev, struct device_attribute *attr, \555555+ const char *buf, size_t count) \556556+{ \557557+ struct i2c_client *client = to_i2c_client(dev); \558558+ struct w83627ehf_data *data = i2c_get_clientdata(client); \559559+ u32 val = simple_strtoul(buf, NULL, 10); \560560+ \561561+ down(&data->update_lock); \562562+ data->temp1_##reg = temp1_to_reg(val); \563563+ w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \564564+ data->temp1_##reg); \565565+ up(&data->update_lock); \566566+ return count; \567567+}568568+store_temp1_reg(OVER, max);569569+store_temp1_reg(HYST, max_hyst);570570+571571+static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL);572572+static DEVICE_ATTR(temp1_max, S_IRUGO| S_IWUSR,573573+ show_temp1_max, store_temp1_max);574574+static DEVICE_ATTR(temp1_max_hyst, S_IRUGO| S_IWUSR,575575+ show_temp1_max_hyst, store_temp1_max_hyst);576576+577577+#define show_temp_reg(reg) \578578+static ssize_t \579579+show_##reg (struct device *dev, char *buf, int nr) \580580+{ \581581+ struct w83627ehf_data *data = w83627ehf_update_device(dev); \582582+ return sprintf(buf, "%d\n", \583583+ LM75_TEMP_FROM_REG(data->reg[nr])); \584584+}585585+show_temp_reg(temp);586586+show_temp_reg(temp_max);587587+show_temp_reg(temp_max_hyst);588588+589589+#define store_temp_reg(REG, reg) \590590+static ssize_t \591591+store_##reg (struct device *dev, const char *buf, size_t count, int nr) \592592+{ \593593+ struct i2c_client *client = to_i2c_client(dev); \594594+ struct w83627ehf_data *data = i2c_get_clientdata(client); \595595+ u32 val = simple_strtoul(buf, NULL, 10); \596596+ \597597+ down(&data->update_lock); \598598+ data->reg[nr] = LM75_TEMP_TO_REG(val); \599599+ w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \600600+ data->reg[nr]); \601601+ up(&data->update_lock); \602602+ return count; \603603+}604604+store_temp_reg(OVER, temp_max);605605+store_temp_reg(HYST, temp_max_hyst);606606+607607+#define sysfs_temp_offset(offset) \608608+static ssize_t \609609+show_reg_temp##offset (struct device *dev, struct device_attribute *attr, \610610+ char *buf) \611611+{ \612612+ return show_temp(dev, buf, offset - 2); \613613+} \614614+static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \615615+ show_reg_temp##offset, NULL);616616+617617+#define sysfs_temp_reg_offset(reg, offset) \618618+static ssize_t \619619+show_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \620620+ char *buf) \621621+{ \622622+ return show_temp_##reg(dev, buf, offset - 2); \623623+} \624624+static ssize_t \625625+store_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \626626+ const char *buf, size_t count) \627627+{ \628628+ return store_temp_##reg(dev, buf, count, offset - 2); \629629+} \630630+static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \631631+ show_reg_temp##offset##_##reg, \632632+ store_reg_temp##offset##_##reg);633633+634634+sysfs_temp_offset(2);635635+sysfs_temp_reg_offset(max, 2);636636+sysfs_temp_reg_offset(max_hyst, 2);637637+sysfs_temp_offset(3);638638+sysfs_temp_reg_offset(max, 3);639639+sysfs_temp_reg_offset(max_hyst, 3);640640+641641+/*642642+ * Driver and client management643643+ */644644+645645+static struct i2c_driver w83627ehf_driver;646646+647647+static void w83627ehf_init_client(struct i2c_client *client)648648+{649649+ int i;650650+ u8 tmp;651651+652652+ /* Start monitoring is needed */653653+ tmp = w83627ehf_read_value(client, W83627EHF_REG_CONFIG);654654+ if (!(tmp & 0x01))655655+ w83627ehf_write_value(client, W83627EHF_REG_CONFIG,656656+ tmp | 0x01);657657+658658+ /* Enable temp2 and temp3 if needed */659659+ for (i = 0; i < 2; i++) {660660+ tmp = w83627ehf_read_value(client,661661+ W83627EHF_REG_TEMP_CONFIG[i]);662662+ if (tmp & 0x01)663663+ w83627ehf_write_value(client,664664+ W83627EHF_REG_TEMP_CONFIG[i],665665+ tmp & 0xfe);666666+ }667667+}668668+669669+static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind)670670+{671671+ struct i2c_client *client;672672+ struct w83627ehf_data *data;673673+ int i, err = 0;674674+675675+ if (!i2c_is_isa_adapter(adapter))676676+ return 0;677677+678678+ if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) {679679+ err = -EBUSY;680680+ goto exit;681681+ }682682+683683+ if (!(data = kmalloc(sizeof(struct w83627ehf_data), GFP_KERNEL))) {684684+ err = -ENOMEM;685685+ goto exit_release;686686+ }687687+ memset(data, 0, sizeof(struct w83627ehf_data));688688+689689+ client = &data->client;690690+ i2c_set_clientdata(client, data);691691+ client->addr = address;692692+ init_MUTEX(&data->lock);693693+ client->adapter = adapter;694694+ client->driver = &w83627ehf_driver;695695+ client->flags = 0;696696+697697+ strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE);698698+ data->valid = 0;699699+ init_MUTEX(&data->update_lock);700700+701701+ /* Tell the i2c layer a new client has arrived */702702+ if ((err = i2c_attach_client(client)))703703+ goto exit_free;704704+705705+ /* Initialize the chip */706706+ w83627ehf_init_client(client);707707+708708+ /* A few vars need to be filled upon startup */709709+ for (i = 0; i < 5; i++)710710+ data->fan_min[i] = w83627ehf_read_value(client,711711+ W83627EHF_REG_FAN_MIN[i]);712712+713713+ /* It looks like fan4 and fan5 pins can be alternatively used714714+ as fan on/off switches */715715+ data->has_fan = 0x07; /* fan1, fan2 and fan3 */716716+ i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1);717717+ if (i & (1 << 2))718718+ data->has_fan |= (1 << 3);719719+ if (i & (1 << 0))720720+ data->has_fan |= (1 << 4);721721+722722+ /* Register sysfs hooks */723723+ device_create_file(&client->dev, &dev_attr_fan1_input);724724+ device_create_file(&client->dev, &dev_attr_fan1_min);725725+ device_create_file(&client->dev, &dev_attr_fan1_div);726726+ device_create_file(&client->dev, &dev_attr_fan2_input);727727+ device_create_file(&client->dev, &dev_attr_fan2_min);728728+ device_create_file(&client->dev, &dev_attr_fan2_div);729729+ device_create_file(&client->dev, &dev_attr_fan3_input);730730+ device_create_file(&client->dev, &dev_attr_fan3_min);731731+ device_create_file(&client->dev, &dev_attr_fan3_div);732732+733733+ if (data->has_fan & (1 << 3)) {734734+ device_create_file(&client->dev, &dev_attr_fan4_input);735735+ device_create_file(&client->dev, &dev_attr_fan4_min);736736+ device_create_file(&client->dev, &dev_attr_fan4_div);737737+ }738738+ if (data->has_fan & (1 << 4)) {739739+ device_create_file(&client->dev, &dev_attr_fan5_input);740740+ device_create_file(&client->dev, &dev_attr_fan5_min);741741+ device_create_file(&client->dev, &dev_attr_fan5_div);742742+ }743743+744744+ device_create_file(&client->dev, &dev_attr_temp1_input);745745+ device_create_file(&client->dev, &dev_attr_temp1_max);746746+ device_create_file(&client->dev, &dev_attr_temp1_max_hyst);747747+ device_create_file(&client->dev, &dev_attr_temp2_input);748748+ device_create_file(&client->dev, &dev_attr_temp2_max);749749+ device_create_file(&client->dev, &dev_attr_temp2_max_hyst);750750+ device_create_file(&client->dev, &dev_attr_temp3_input);751751+ device_create_file(&client->dev, &dev_attr_temp3_max);752752+ device_create_file(&client->dev, &dev_attr_temp3_max_hyst);753753+754754+ return 0;755755+756756+exit_free:757757+ kfree(data);758758+exit_release:759759+ release_region(address, REGION_LENGTH);760760+exit:761761+ return err;762762+}763763+764764+static int w83627ehf_attach_adapter(struct i2c_adapter *adapter)765765+{766766+ if (!(adapter->class & I2C_CLASS_HWMON))767767+ return 0;768768+ return i2c_detect(adapter, &addr_data, w83627ehf_detect);769769+}770770+771771+static int w83627ehf_detach_client(struct i2c_client *client)772772+{773773+ int err;774774+775775+ if ((err = i2c_detach_client(client))) {776776+ dev_err(&client->dev, "Client deregistration failed, "777777+ "client not detached.\n");778778+ return err;779779+ }780780+ release_region(client->addr, REGION_LENGTH);781781+ kfree(i2c_get_clientdata(client));782782+783783+ return 0;784784+}785785+786786+static struct i2c_driver w83627ehf_driver = {787787+ .owner = THIS_MODULE,788788+ .name = "w83627ehf",789789+ .flags = I2C_DF_NOTIFY,790790+ .attach_adapter = w83627ehf_attach_adapter,791791+ .detach_client = w83627ehf_detach_client,792792+};793793+794794+static int __init w83627ehf_find(int sioaddr, int *address)795795+{796796+ u16 val;797797+798798+ REG = sioaddr;799799+ VAL = sioaddr + 1;800800+ superio_enter();801801+802802+ val = (superio_inb(SIO_REG_DEVID) << 8)803803+ | superio_inb(SIO_REG_DEVID + 1);804804+ if ((val & SIO_ID_MASK) != SIO_W83627EHF_ID) {805805+ superio_exit();806806+ return -ENODEV;807807+ }808808+809809+ superio_select(W83627EHF_LD_HWM);810810+ val = (superio_inb(SIO_REG_ADDR) << 8)811811+ | superio_inb(SIO_REG_ADDR + 1);812812+ *address = val & ~(REGION_LENGTH - 1);813813+ if (*address == 0) {814814+ superio_exit();815815+ return -ENODEV;816816+ }817817+818818+ /* Activate logical device if needed */819819+ val = superio_inb(SIO_REG_ENABLE);820820+ if (!(val & 0x01))821821+ superio_outb(SIO_REG_ENABLE, val | 0x01);822822+823823+ superio_exit();824824+ return 0;825825+}826826+827827+static int __init sensors_w83627ehf_init(void)828828+{829829+ if (w83627ehf_find(0x2e, &normal_isa[0])830830+ && w83627ehf_find(0x4e, &normal_isa[0]))831831+ return -ENODEV;832832+833833+ return i2c_add_driver(&w83627ehf_driver);834834+}835835+836836+static void __exit sensors_w83627ehf_exit(void)837837+{838838+ i2c_del_driver(&w83627ehf_driver);839839+}840840+841841+MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");842842+MODULE_DESCRIPTION("W83627EHF driver");843843+MODULE_LICENSE("GPL");844844+845845+module_init(sensors_w83627ehf_init);846846+module_exit(sensors_w83627ehf_exit);
+1-1
drivers/i2c/chips/w83627hf.c
···264264{265265 int i;266266 val = SENSORS_LIMIT(val, 1, 128) >> 1;267267- for (i = 0; i < 6; i++) {267267+ for (i = 0; i < 7; i++) {268268 if (val == 0)269269 break;270270 val >>= 1;
+23-55
drivers/i2c/chips/w83781d.c
···2828 as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no2929 w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes3030 w83627hf 9 3 2 3 0x21 0x5ca3 yes yes(LPC)3131- w83627thf 9 3 2 3 0x90 0x5ca3 no yes(LPC)3231 w83782d 9 3 2-4 3 0x30 0x5ca3 yes yes3332 w83783s 5-6 3 2 1-2 0x40 0x5ca3 yes no3434- w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC)35333634*/37353838-#include <linux/config.h>3936#include <linux/module.h>4037#include <linux/init.h>4138#include <linux/slab.h>···5053static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END };51545255/* Insmod parameters */5353-SENSORS_INSMOD_6(w83781d, w83782d, w83783s, w83627hf, as99127f, w83697hf);5656+SENSORS_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f);5457I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: "5558 "{bus, clientaddr, subclientaddr1, subclientaddr2}");5659···170173 : (val)) / 1000, 0, 0xff))171174#define TEMP_FROM_REG(val) (((val) & 0x80 ? (val)-0x100 : (val)) * 1000)172175173173-#define ALARMS_FROM_REG(val) (val)174176#define PWM_FROM_REG(val) (val)175177#define PWM_TO_REG(val) (SENSORS_LIMIT((val),0,255))176178#define BEEP_MASK_FROM_REG(val,type) ((type) == as99127f ? \···189193 val = SENSORS_LIMIT(val, 1,190194 ((type == w83781d191195 || type == as99127f) ? 8 : 128)) >> 1;192192- for (i = 0; i < 6; i++) {196196+ for (i = 0; i < 7; i++) {193197 if (val == 0)194198 break;195199 val >>= 1;···520524show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)521525{522526 struct w83781d_data *data = w83781d_update_device(dev);523523- return sprintf(buf, "%ld\n", (long) ALARMS_FROM_REG(data->alarms));527527+ return sprintf(buf, "%u\n", data->alarms);524528}525529526530static···9961000 err = -EINVAL;9971001 goto ERROR0;9981002 }999999- if (!is_isa && kind == w83697hf) {10001000- dev_err(&adapter->dev,10011001- "Cannot force ISA-only chip for I2C address 0x%02x.\n",10021002- address);10031003- err = -EINVAL;10041004- goto ERROR0;10051005- }1006100310071004 if (is_isa)10081005 if (!request_region(address, W83781D_EXTENT,···11281139 else if (val1 == 0x40 && vendid == winbond && !is_isa11291140 && address == 0x2d)11301141 kind = w83783s;11311131- else if ((val1 == 0x21 || val1 == 0x90) && vendid == winbond)11421142+ else if (val1 == 0x21 && vendid == winbond)11321143 kind = w83627hf;11331144 else if (val1 == 0x31 && !is_isa && address >= 0x28)11341145 kind = as99127f;11351135- else if (val1 == 0x60 && vendid == winbond && is_isa)11361136- kind = w83697hf;11371146 else {11381147 if (kind == 0)11391148 dev_warn(&new_client->dev, "Ignoring 'force' "···11501163 } else if (kind == w83783s) {11511164 client_name = "w83783s";11521165 } else if (kind == w83627hf) {11531153- if (val1 == 0x90)11541154- client_name = "w83627thf";11551155- else11561156- client_name = "w83627hf";11661166+ client_name = "w83627hf";11571167 } else if (kind == as99127f) {11581168 client_name = "as99127f";11591159- } else if (kind == w83697hf) {11601160- client_name = "w83697hf";11611169 }1162117011631171 /* Fill in the remaining client fields and put into the global list */···1190120811911209 /* Register sysfs hooks */11921210 device_create_file_in(new_client, 0);11931193- if (kind != w83783s && kind != w83697hf)12111211+ if (kind != w83783s)11941212 device_create_file_in(new_client, 1);11951213 device_create_file_in(new_client, 2);11961214 device_create_file_in(new_client, 3);···1204122212051223 device_create_file_fan(new_client, 1);12061224 device_create_file_fan(new_client, 2);12071207- if (kind != w83697hf)12081208- device_create_file_fan(new_client, 3);12251225+ device_create_file_fan(new_client, 3);1209122612101227 device_create_file_temp(new_client, 1);12111228 device_create_file_temp(new_client, 2);12121212- if (kind != w83783s && kind != w83697hf)12291229+ if (kind != w83783s)12131230 device_create_file_temp(new_client, 3);1214123112151215- if (kind != w83697hf)12161216- device_create_file_vid(new_client);12171217-12181218- if (kind != w83697hf)12191219- device_create_file_vrm(new_client);12321232+ device_create_file_vid(new_client);12331233+ device_create_file_vrm(new_client);1220123412211235 device_create_file_fan_div(new_client, 1);12221236 device_create_file_fan_div(new_client, 2);12231223- if (kind != w83697hf)12241224- device_create_file_fan_div(new_client, 3);12371237+ device_create_file_fan_div(new_client, 3);1225123812261239 device_create_file_alarms(new_client);12271240···12351258 if (kind != as99127f && kind != w83781d) {12361259 device_create_file_sensor(new_client, 1);12371260 device_create_file_sensor(new_client, 2);12381238- if (kind != w83783s && kind != w83697hf)12611261+ if (kind != w83783s)12391262 device_create_file_sensor(new_client, 3);12401263 }12411264···14581481 else14591482 data->sens[i - 1] = 2;14601483 }14611461- if ((type == w83783s || type == w83697hf) && (i == 2))14841484+ if (type == w83783s && i == 2)14621485 break;14631486 }14641487 }···14741497 }1475149814761499 /* Enable temp3 */14771477- if (type != w83783s && type != w83697hf) {15001500+ if (type != w83783s) {14781501 tmp = w83781d_read_value(client,14791502 W83781D_REG_TEMP3_CONFIG);14801503 if (tmp & 0x01) {···15151538 dev_dbg(dev, "Starting device update\n");1516153915171540 for (i = 0; i <= 8; i++) {15181518- if ((data->type == w83783s || data->type == w83697hf)15191519- && (i == 1))15411541+ if (data->type == w83783s && i == 1)15201542 continue; /* 783S has no in1 */15211543 data->in[i] =15221544 w83781d_read_value(client, W83781D_REG_IN(i));···15231547 w83781d_read_value(client, W83781D_REG_IN_MIN(i));15241548 data->in_max[i] =15251549 w83781d_read_value(client, W83781D_REG_IN_MAX(i));15261526- if ((data->type != w83782d) && (data->type != w83697hf)15501550+ if ((data->type != w83782d)15271551 && (data->type != w83627hf) && (i == 6))15281552 break;15291553 }···15591583 w83781d_read_value(client, W83781D_REG_TEMP_OVER(2));15601584 data->temp_max_hyst_add[0] =15611585 w83781d_read_value(client, W83781D_REG_TEMP_HYST(2));15621562- if (data->type != w83783s && data->type != w83697hf) {15861586+ if (data->type != w83783s) {15631587 data->temp_add[1] =15641588 w83781d_read_value(client, W83781D_REG_TEMP(3));15651589 data->temp_max_add[1] =···15701594 W83781D_REG_TEMP_HYST(3));15711595 }15721596 i = w83781d_read_value(client, W83781D_REG_VID_FANDIV);15731573- if (data->type != w83697hf) {15741574- data->vid = i & 0x0f;15751575- data->vid |=15761576- (w83781d_read_value(client, W83781D_REG_CHIPID) &15771577- 0x01)15781578- << 4;15791579- }15971597+ data->vid = i & 0x0f;15981598+ data->vid |= (w83781d_read_value(client,15991599+ W83781D_REG_CHIPID) & 0x01) << 4;15801600 data->fan_div[0] = (i >> 4) & 0x03;15811601 data->fan_div[1] = (i >> 6) & 0x03;15821582- if (data->type != w83697hf) {15831583- data->fan_div[2] = (w83781d_read_value(client,15841584- W83781D_REG_PIN)15851585- >> 6) & 0x03;15861586- }16021602+ data->fan_div[2] = (w83781d_read_value(client,16031603+ W83781D_REG_PIN) >> 6) & 0x03;15871604 if ((data->type != w83781d) && (data->type != as99127f)) {15881605 i = w83781d_read_value(client, W83781D_REG_VBAT);15891606 data->fan_div[0] |= (i >> 3) & 0x04;15901607 data->fan_div[1] |= (i >> 4) & 0x04;15911591- if (data->type != w83697hf)15921592- data->fan_div[2] |= (i >> 5) & 0x04;16081608+ data->fan_div[2] |= (i >> 5) & 0x04;15931609 }15941610 data->alarms =15951611 w83781d_read_value(client,
-1
drivers/i2c/chips/w83l785ts.c
···3030 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.3131 */32323333-#include <linux/config.h>3433#include <linux/module.h>3534#include <linux/delay.h>3635#include <linux/init.h>
+20-80
drivers/i2c/i2c-core.c
···2121 All SMBus-related things are written by Frodo Looijaard <frodol@dds.nl>2222 SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> */23232424-#include <linux/config.h>2524#include <linux/module.h>2625#include <linux/kernel.h>2726#include <linux/errno.h>···238239 }239240240241 /* detach any active clients. This must be done first, because241241- * it can fail; in which case we give upp. */242242+ * it can fail; in which case we give up. */242243 list_for_each_safe(item, _n, &adap->clients) {243244 client = list_entry(item, struct i2c_client, list);244245···611612 struct i2c_adapter *adap=client->adapter;612613 struct i2c_msg msg;613614614614- if (client->adapter->algo->master_xfer) {615615- msg.addr = client->addr;616616- msg.flags = client->flags & I2C_M_TEN;617617- msg.len = count;618618- msg.buf = (char *)buf;615615+ msg.addr = client->addr;616616+ msg.flags = client->flags & I2C_M_TEN;617617+ msg.len = count;618618+ msg.buf = (char *)buf;619619620620- dev_dbg(&client->adapter->dev, "master_send: writing %d bytes.\n",621621- count);622622-623623- down(&adap->bus_lock);624624- ret = adap->algo->master_xfer(adap,&msg,1);625625- up(&adap->bus_lock);620620+ ret = i2c_transfer(adap, &msg, 1);626621627627- /* if everything went ok (i.e. 1 msg transmitted), return #bytes628628- * transmitted, else error code.629629- */630630- return (ret == 1 )? count : ret;631631- } else {632632- dev_err(&client->adapter->dev, "I2C level transfers not supported\n");633633- return -ENOSYS;634634- }622622+ /* If everything went ok (i.e. 1 msg transmitted), return #bytes623623+ transmitted, else error code. */624624+ return (ret == 1) ? count : ret;635625}636626637627int i2c_master_recv(struct i2c_client *client, char *buf ,int count)···628640 struct i2c_adapter *adap=client->adapter;629641 struct i2c_msg msg;630642 int ret;631631- if (client->adapter->algo->master_xfer) {632632- msg.addr = client->addr;633633- msg.flags = client->flags & I2C_M_TEN;634634- msg.flags |= I2C_M_RD;635635- msg.len = count;636636- msg.buf = buf;637643638638- dev_dbg(&client->adapter->dev, "master_recv: reading %d bytes.\n",639639- count);640640-641641- down(&adap->bus_lock);642642- ret = adap->algo->master_xfer(adap,&msg,1);643643- up(&adap->bus_lock);644644-645645- dev_dbg(&client->adapter->dev, "master_recv: return:%d (count:%d, addr:0x%02x)\n",646646- ret, count, client->addr);647647-648648- /* if everything went ok (i.e. 1 msg transmitted), return #bytes649649- * transmitted, else error code.650650- */651651- return (ret == 1 )? count : ret;652652- } else {653653- dev_err(&client->adapter->dev, "I2C level transfers not supported\n");654654- return -ENOSYS;655655- }644644+ msg.addr = client->addr;645645+ msg.flags = client->flags & I2C_M_TEN;646646+ msg.flags |= I2C_M_RD;647647+ msg.len = count;648648+ msg.buf = buf;649649+650650+ ret = i2c_transfer(adap, &msg, 1);651651+652652+ /* If everything went ok (i.e. 1 msg transmitted), return #bytes653653+ transmitted, else error code. */654654+ return (ret == 1) ? count : ret;656655}657656658657···717742 found = 1;718743 }719744 }720720- for (i = 0;721721- !found && (address_data->ignore_range[i] != I2C_CLIENT_END);722722- i += 3) {723723- if (((adap_id == address_data->ignore_range[i]) ||724724- ((address_data->ignore_range[i]==ANY_I2C_BUS))) &&725725- (addr >= address_data->ignore_range[i+1]) &&726726- (addr <= address_data->ignore_range[i+2])) {727727- dev_dbg(&adapter->dev, "found ignore_range parameter for adapter %d, "728728- "addr %04x\n", adap_id,addr);729729- found = 1;730730- }731731- }732745 if (found) 733746 continue;734747···733770 }734771735772 for (i = 0;736736- !found && (address_data->normal_i2c_range[i] != I2C_CLIENT_END);737737- i += 2) {738738- if ((addr >= address_data->normal_i2c_range[i]) &&739739- (addr <= address_data->normal_i2c_range[i+1])) {740740- found = 1;741741- dev_dbg(&adapter->dev, "found normal i2c_range entry for adapter %d, "742742- "addr %04x\n", adap_id,addr);743743- }744744- }745745-746746- for (i = 0;747773 !found && (address_data->probe[i] != I2C_CLIENT_END);748774 i += 2) {749775 if (((adap_id == address_data->probe[i]) ||···740788 (addr == address_data->probe[i+1])) {741789 found = 1;742790 dev_dbg(&adapter->dev, "found probe parameter for adapter %d, "743743- "addr %04x\n", adap_id,addr);744744- }745745- }746746- for (i = 0;747747- !found && (address_data->probe_range[i] != I2C_CLIENT_END);748748- i += 3) {749749- if (((adap_id == address_data->probe_range[i]) ||750750- (address_data->probe_range[i] == ANY_I2C_BUS)) &&751751- (addr >= address_data->probe_range[i+1]) &&752752- (addr <= address_data->probe_range[i+2])) {753753- found = 1;754754- dev_dbg(&adapter->dev, "found probe_range parameter for adapter %d, "755791 "addr %04x\n", adap_id,addr);756792 }757793 }
+1-2
drivers/i2c/i2c-dev.c
···2929/* The devfs code is contributed by Philipp Matthias Hahn 3030 <pmhahn@titan.lahn.de> */31313232-#include <linux/config.h>3332#include <linux/kernel.h>3433#include <linux/module.h>3534#include <linux/fs.h>···213214 sizeof(rdwr_arg)))214215 return -EFAULT;215216216216- /* Put an arbritrary limit on the number of messages that can217217+ /* Put an arbitrary limit on the number of messages that can217218 * be sent at once */218219 if (rdwr_arg.nmsgs > I2C_RDRW_IOCTL_MAX_MSGS)219220 return -EINVAL;
+4-2
drivers/macintosh/therm_windtunnel.c
···5151static int do_probe( struct i2c_adapter *adapter, int addr, int kind);52525353/* scan 0x48-0x4f (DS1775) and 0x2c-2x2f (ADM1030) */5454-static unsigned short normal_i2c[] = { 0x49, 0x2c, I2C_CLIENT_END };5555-static unsigned short normal_i2c_range[] = { 0x48, 0x4f, 0x2c, 0x2f, I2C_CLIENT_END };5454+static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b,5555+ 0x4c, 0x4d, 0x4e, 0x4f,5656+ 0x2c, 0x2d, 0x2e, 0x2f,5757+ I2C_CLIENT_END };56585759I2C_CLIENT_INSMOD;5860
···22222323/* Addresses to scan */2424static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END};2525-static unsigned short normal_i2c_range[] = {I2C_CLIENT_END};2625I2C_CLIENT_INSMOD;27262827MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder");
+4-12
drivers/media/video/saa7185.c
···380380 * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1'381381 */382382static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END };383383-static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };384383385385-static unsigned short probe[2] = { I2C_CLIENT_END, I2C_CLIENT_END };386386-static unsigned short probe_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };387387-static unsigned short ignore[2] = { I2C_CLIENT_END, I2C_CLIENT_END };388388-static unsigned short ignore_range[2] = { I2C_CLIENT_END, I2C_CLIENT_END };389389-static unsigned short force[2] = { I2C_CLIENT_END , I2C_CLIENT_END };384384+static unsigned short ignore = I2C_CLIENT_END;390385391386static struct i2c_client_address_data addr_data = {392387 .normal_i2c = normal_i2c,393393- .normal_i2c_range = normal_i2c_range,394394- .probe = probe,395395- .probe_range = probe_range,396396- .ignore = ignore,397397- .ignore_range = ignore_range,398398- .force = force388388+ .probe = &ignore,389389+ .ignore = &ignore,390390+ .force = &ignore,399391};400392401393static struct i2c_driver i2c_driver_saa7185;
-1
drivers/media/video/tda7432.c
···7474 I2C_TDA7432 >> 1,7575 I2C_CLIENT_END,7676};7777-static unsigned short normal_i2c_range[] = { I2C_CLIENT_END, I2C_CLIENT_END };7877I2C_CLIENT_INSMOD;79788079/* Structure of address and subaddresses for the tda7432 */
-1
drivers/media/video/tda9840.c
···43434444/* addresses to scan, found only at 0x42 (7-Bit) */4545static unsigned short normal_i2c[] = { I2C_TDA9840, I2C_CLIENT_END };4646-static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };47464847/* magic definition of all other variables and things */4948I2C_CLIENT_INSMOD;
-1
drivers/media/video/tda9875.c
···4444 I2C_TDA9875 >> 1,4545 I2C_CLIENT_END4646};4747-static unsigned short normal_i2c_range[] = {I2C_CLIENT_END};4847I2C_CLIENT_INSMOD;49485049/* This is a superset of the TDA9875 */
···43434444/* addresses to scan, found only at 0x03 and/or 0x43 (7-bit) */4545static unsigned short normal_i2c[] = { I2C_TEA6415C_1, I2C_TEA6415C_2, I2C_CLIENT_END };4646-static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };47464847/* magic definition of all other variables and things */4948I2C_CLIENT_INSMOD;
-1
drivers/media/video/tea6420.c
···40404141/* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */4242static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END };4343-static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };44434544/* magic definition of all other variables and things */4645I2C_CLIENT_INSMOD;