xref: /openbmc/linux/Documentation/hwmon/smsc47b397.rst (revision c39f2d9db0fd81ea20bb5cce9b3f082ca63753e2)
1*7ebd8b66SMauro Carvalho ChehabKernel driver smsc47b397
2*7ebd8b66SMauro Carvalho Chehab========================
3*7ebd8b66SMauro Carvalho Chehab
4*7ebd8b66SMauro Carvalho ChehabSupported chips:
5*7ebd8b66SMauro Carvalho Chehab
6*7ebd8b66SMauro Carvalho Chehab  * SMSC LPC47B397-NC
7*7ebd8b66SMauro Carvalho Chehab
8*7ebd8b66SMauro Carvalho Chehab  * SMSC SCH5307-NS
9*7ebd8b66SMauro Carvalho Chehab
10*7ebd8b66SMauro Carvalho Chehab  * SMSC SCH5317
11*7ebd8b66SMauro Carvalho Chehab
12*7ebd8b66SMauro Carvalho Chehab    Prefix: 'smsc47b397'
13*7ebd8b66SMauro Carvalho Chehab
14*7ebd8b66SMauro Carvalho Chehab    Addresses scanned: none, address read from Super I/O config space
15*7ebd8b66SMauro Carvalho Chehab
16*7ebd8b66SMauro Carvalho Chehab    Datasheet: In this file
17*7ebd8b66SMauro Carvalho Chehab
18*7ebd8b66SMauro Carvalho ChehabAuthors:
19*7ebd8b66SMauro Carvalho Chehab
20*7ebd8b66SMauro Carvalho Chehab       - Mark M. Hoffman <mhoffman@lightlink.com>
21*7ebd8b66SMauro Carvalho Chehab       - Utilitek Systems, Inc.
22*7ebd8b66SMauro Carvalho Chehab
23*7ebd8b66SMauro Carvalho ChehabNovember 23, 2004
24*7ebd8b66SMauro Carvalho Chehab
25*7ebd8b66SMauro Carvalho ChehabThe following specification describes the SMSC LPC47B397-NC [1]_ sensor chip
26*7ebd8b66SMauro Carvalho Chehab(for which there is no public datasheet available). This document was
27*7ebd8b66SMauro Carvalho Chehabprovided by Craig Kelly (In-Store Broadcast Network) and edited/corrected
28*7ebd8b66SMauro Carvalho Chehabby Mark M. Hoffman <mhoffman@lightlink.com>.
29*7ebd8b66SMauro Carvalho Chehab
30*7ebd8b66SMauro Carvalho Chehab.. [1] And SMSC SCH5307-NS and SCH5317, which have different device IDs but are
31*7ebd8b66SMauro Carvalho Chehab       otherwise compatible.
32*7ebd8b66SMauro Carvalho Chehab
33*7ebd8b66SMauro Carvalho Chehab-------------------------------------------------------------------------
34*7ebd8b66SMauro Carvalho Chehab
35*7ebd8b66SMauro Carvalho ChehabMethods for detecting the HP SIO and reading the thermal data on a dc7100
36*7ebd8b66SMauro Carvalho Chehab-------------------------------------------------------------------------
37*7ebd8b66SMauro Carvalho Chehab
38*7ebd8b66SMauro Carvalho ChehabThe thermal information on the dc7100 is contained in the SIO Hardware Monitor
39*7ebd8b66SMauro Carvalho Chehab(HWM). The information is accessed through an index/data pair. The index/data
40*7ebd8b66SMauro Carvalho Chehabpair is located at the HWM Base Address + 0 and the HWM Base Address + 1. The
41*7ebd8b66SMauro Carvalho ChehabHWM Base address can be obtained from Logical Device 8, registers 0x60 (MSB)
42*7ebd8b66SMauro Carvalho Chehaband 0x61 (LSB). Currently we are using 0x480 for the HWM Base Address and
43*7ebd8b66SMauro Carvalho Chehab0x480 and 0x481 for the index/data pair.
44*7ebd8b66SMauro Carvalho Chehab
45*7ebd8b66SMauro Carvalho ChehabReading temperature information.
46*7ebd8b66SMauro Carvalho ChehabThe temperature information is located in the following registers:
47*7ebd8b66SMauro Carvalho Chehab
48*7ebd8b66SMauro Carvalho Chehab=============== ======= =======================================================
49*7ebd8b66SMauro Carvalho ChehabTemp1		0x25	(Currently, this reflects the CPU temp on all systems).
50*7ebd8b66SMauro Carvalho ChehabTemp2		0x26
51*7ebd8b66SMauro Carvalho ChehabTemp3		0x27
52*7ebd8b66SMauro Carvalho ChehabTemp4		0x80
53*7ebd8b66SMauro Carvalho Chehab=============== ======= =======================================================
54*7ebd8b66SMauro Carvalho Chehab
55*7ebd8b66SMauro Carvalho ChehabProgramming Example
56*7ebd8b66SMauro Carvalho ChehabThe following is an example of how to read the HWM temperature registers::
57*7ebd8b66SMauro Carvalho Chehab
58*7ebd8b66SMauro Carvalho Chehab	MOV	DX,480H
59*7ebd8b66SMauro Carvalho Chehab	MOV	AX,25H
60*7ebd8b66SMauro Carvalho Chehab	OUT	DX,AL
61*7ebd8b66SMauro Carvalho Chehab	MOV	DX,481H
62*7ebd8b66SMauro Carvalho Chehab	IN	AL,DX
63*7ebd8b66SMauro Carvalho Chehab
64*7ebd8b66SMauro Carvalho ChehabAL contains the data in hex, the temperature in Celsius is the decimal
65*7ebd8b66SMauro Carvalho Chehabequivalent.
66*7ebd8b66SMauro Carvalho Chehab
67*7ebd8b66SMauro Carvalho ChehabEx: If AL contains 0x2A, the temperature is 42 degrees C.
68*7ebd8b66SMauro Carvalho Chehab
69*7ebd8b66SMauro Carvalho ChehabReading tach information.
70*7ebd8b66SMauro Carvalho ChehabThe fan speed information is located in the following registers:
71*7ebd8b66SMauro Carvalho Chehab
72*7ebd8b66SMauro Carvalho Chehab=============== ======= ======= =================================
73*7ebd8b66SMauro Carvalho Chehab		LSB	MSB
74*7ebd8b66SMauro Carvalho ChehabTach1		0x28	0x29	(Currently, this reflects the CPU
75*7ebd8b66SMauro Carvalho Chehab				fan speed on all systems).
76*7ebd8b66SMauro Carvalho ChehabTach2		0x2A	0x2B
77*7ebd8b66SMauro Carvalho ChehabTach3		0x2C	0x2D
78*7ebd8b66SMauro Carvalho ChehabTach4		0x2E	0x2F
79*7ebd8b66SMauro Carvalho Chehab=============== ======= ======= =================================
80*7ebd8b66SMauro Carvalho Chehab
81*7ebd8b66SMauro Carvalho Chehab.. Important::
82*7ebd8b66SMauro Carvalho Chehab
83*7ebd8b66SMauro Carvalho Chehab	Reading the tach LSB locks the tach MSB.
84*7ebd8b66SMauro Carvalho Chehab	The LSB Must be read first.
85*7ebd8b66SMauro Carvalho Chehab
86*7ebd8b66SMauro Carvalho ChehabHow to convert the tach reading to RPM
87*7ebd8b66SMauro Carvalho Chehab--------------------------------------
88*7ebd8b66SMauro Carvalho Chehab
89*7ebd8b66SMauro Carvalho ChehabThe tach reading (TCount) is given by: (Tach MSB * 256) + (Tach LSB)
90*7ebd8b66SMauro Carvalho ChehabThe SIO counts the number of 90kHz (11.111us) pulses per revolution.
91*7ebd8b66SMauro Carvalho ChehabRPM = 60/(TCount * 11.111us)
92*7ebd8b66SMauro Carvalho Chehab
93*7ebd8b66SMauro Carvalho ChehabExample::
94*7ebd8b66SMauro Carvalho Chehab
95*7ebd8b66SMauro Carvalho Chehab	Reg 0x28 = 0x9B
96*7ebd8b66SMauro Carvalho Chehab	Reg 0x29 = 0x08
97*7ebd8b66SMauro Carvalho Chehab
98*7ebd8b66SMauro Carvalho ChehabTCount = 0x89B = 2203
99*7ebd8b66SMauro Carvalho Chehab
100*7ebd8b66SMauro Carvalho ChehabRPM = 60 / (2203 * 11.11111 E-6) = 2451 RPM
101*7ebd8b66SMauro Carvalho Chehab
102*7ebd8b66SMauro Carvalho ChehabObtaining the SIO version.
103*7ebd8b66SMauro Carvalho Chehab
104*7ebd8b66SMauro Carvalho ChehabConfiguration Sequence
105*7ebd8b66SMauro Carvalho Chehab----------------------
106*7ebd8b66SMauro Carvalho Chehab
107*7ebd8b66SMauro Carvalho ChehabTo program the configuration registers, the following sequence must be followed:
108*7ebd8b66SMauro Carvalho Chehab1. Enter Configuration Mode
109*7ebd8b66SMauro Carvalho Chehab2. Configure the Configuration Registers
110*7ebd8b66SMauro Carvalho Chehab3. Exit Configuration Mode.
111*7ebd8b66SMauro Carvalho Chehab
112*7ebd8b66SMauro Carvalho ChehabEnter Configuration Mode
113*7ebd8b66SMauro Carvalho Chehab^^^^^^^^^^^^^^^^^^^^^^^^
114*7ebd8b66SMauro Carvalho Chehab
115*7ebd8b66SMauro Carvalho ChehabTo place the chip into the Configuration State The config key (0x55) is written
116*7ebd8b66SMauro Carvalho Chehabto the CONFIG PORT (0x2E).
117*7ebd8b66SMauro Carvalho Chehab
118*7ebd8b66SMauro Carvalho ChehabConfiguration Mode
119*7ebd8b66SMauro Carvalho Chehab^^^^^^^^^^^^^^^^^^
120*7ebd8b66SMauro Carvalho Chehab
121*7ebd8b66SMauro Carvalho ChehabIn configuration mode, the INDEX PORT is located at the CONFIG PORT address and
122*7ebd8b66SMauro Carvalho Chehabthe DATA PORT is at INDEX PORT address + 1.
123*7ebd8b66SMauro Carvalho Chehab
124*7ebd8b66SMauro Carvalho ChehabThe desired configuration registers are accessed in two steps:
125*7ebd8b66SMauro Carvalho Chehab
126*7ebd8b66SMauro Carvalho Chehaba.	Write the index of the Logical Device Number Configuration Register
127*7ebd8b66SMauro Carvalho Chehab	(i.e., 0x07) to the INDEX PORT and then write the number of the
128*7ebd8b66SMauro Carvalho Chehab	desired logical device to the DATA PORT.
129*7ebd8b66SMauro Carvalho Chehab
130*7ebd8b66SMauro Carvalho Chehabb.	Write the address of the desired configuration register within the
131*7ebd8b66SMauro Carvalho Chehab	logical device to the INDEX PORT and then write or read the config-
132*7ebd8b66SMauro Carvalho Chehab	uration register through the DATA PORT.
133*7ebd8b66SMauro Carvalho Chehab
134*7ebd8b66SMauro Carvalho ChehabNote:
135*7ebd8b66SMauro Carvalho Chehab	If accessing the Global Configuration Registers, step (a) is not required.
136*7ebd8b66SMauro Carvalho Chehab
137*7ebd8b66SMauro Carvalho ChehabExit Configuration Mode
138*7ebd8b66SMauro Carvalho Chehab^^^^^^^^^^^^^^^^^^^^^^^
139*7ebd8b66SMauro Carvalho Chehab
140*7ebd8b66SMauro Carvalho ChehabTo exit the Configuration State the write 0xAA to the CONFIG PORT (0x2E).
141*7ebd8b66SMauro Carvalho ChehabThe chip returns to the RUN State.  (This is important).
142*7ebd8b66SMauro Carvalho Chehab
143*7ebd8b66SMauro Carvalho ChehabProgramming Example
144*7ebd8b66SMauro Carvalho Chehab^^^^^^^^^^^^^^^^^^^
145*7ebd8b66SMauro Carvalho Chehab
146*7ebd8b66SMauro Carvalho ChehabThe following is an example of how to read the SIO Device ID located at 0x20:
147*7ebd8b66SMauro Carvalho Chehab
148*7ebd8b66SMauro Carvalho Chehab	; ENTER CONFIGURATION MODE
149*7ebd8b66SMauro Carvalho Chehab	MOV	DX,02EH
150*7ebd8b66SMauro Carvalho Chehab	MOV	AX,055H
151*7ebd8b66SMauro Carvalho Chehab	OUT	DX,AL
152*7ebd8b66SMauro Carvalho Chehab	; GLOBAL CONFIGURATION  REGISTER
153*7ebd8b66SMauro Carvalho Chehab	MOV	DX,02EH
154*7ebd8b66SMauro Carvalho Chehab	MOV	AL,20H
155*7ebd8b66SMauro Carvalho Chehab	OUT	DX,AL
156*7ebd8b66SMauro Carvalho Chehab	; READ THE DATA
157*7ebd8b66SMauro Carvalho Chehab	MOV	DX,02FH
158*7ebd8b66SMauro Carvalho Chehab	IN	AL,DX
159*7ebd8b66SMauro Carvalho Chehab	; EXIT CONFIGURATION MODE
160*7ebd8b66SMauro Carvalho Chehab	MOV	DX,02EH
161*7ebd8b66SMauro Carvalho Chehab	MOV	AX,0AAH
162*7ebd8b66SMauro Carvalho Chehab	OUT	DX,AL
163*7ebd8b66SMauro Carvalho Chehab
164*7ebd8b66SMauro Carvalho ChehabThe registers of interest for identifying the SIO on the dc7100 are Device ID
165*7ebd8b66SMauro Carvalho Chehab(0x20) and Device Rev  (0x21).
166*7ebd8b66SMauro Carvalho Chehab
167*7ebd8b66SMauro Carvalho ChehabThe Device ID will read 0x6F (0x81 for SCH5307-NS, and 0x85 for SCH5317)
168*7ebd8b66SMauro Carvalho ChehabThe Device Rev currently reads 0x01
169*7ebd8b66SMauro Carvalho Chehab
170*7ebd8b66SMauro Carvalho ChehabObtaining the HWM Base Address
171*7ebd8b66SMauro Carvalho Chehab------------------------------
172*7ebd8b66SMauro Carvalho Chehab
173*7ebd8b66SMauro Carvalho ChehabThe following is an example of how to read the HWM Base Address located in
174*7ebd8b66SMauro Carvalho ChehabLogical Device 8::
175*7ebd8b66SMauro Carvalho Chehab
176*7ebd8b66SMauro Carvalho Chehab	; ENTER CONFIGURATION MODE
177*7ebd8b66SMauro Carvalho Chehab	MOV	DX,02EH
178*7ebd8b66SMauro Carvalho Chehab	MOV	AX,055H
179*7ebd8b66SMauro Carvalho Chehab	OUT	DX,AL
180*7ebd8b66SMauro Carvalho Chehab	; CONFIGURE REGISTER CRE0,
181*7ebd8b66SMauro Carvalho Chehab	; LOGICAL DEVICE 8
182*7ebd8b66SMauro Carvalho Chehab	MOV	DX,02EH
183*7ebd8b66SMauro Carvalho Chehab	MOV	AL,07H
184*7ebd8b66SMauro Carvalho Chehab	OUT	DX,AL ;Point to LD# Config Reg
185*7ebd8b66SMauro Carvalho Chehab	MOV	DX,02FH
186*7ebd8b66SMauro Carvalho Chehab	MOV	AL, 08H
187*7ebd8b66SMauro Carvalho Chehab	OUT	DX,AL;Point to Logical Device 8
188*7ebd8b66SMauro Carvalho Chehab	;
189*7ebd8b66SMauro Carvalho Chehab	MOV	DX,02EH
190*7ebd8b66SMauro Carvalho Chehab	MOV	AL,60H
191*7ebd8b66SMauro Carvalho Chehab	OUT	DX,AL	; Point to HWM Base Addr MSB
192*7ebd8b66SMauro Carvalho Chehab	MOV	DX,02FH
193*7ebd8b66SMauro Carvalho Chehab	IN	AL,DX	; Get MSB of HWM Base Addr
194*7ebd8b66SMauro Carvalho Chehab	; EXIT CONFIGURATION MODE
195*7ebd8b66SMauro Carvalho Chehab	MOV	DX,02EH
196*7ebd8b66SMauro Carvalho Chehab	MOV	AX,0AAH
197*7ebd8b66SMauro Carvalho Chehab	OUT	DX,AL
198