ARM: tegra: powermon: Fix copyrights from GPLv3 to GPLv2
[linux-3.10.git] / arch / arm / mach-tegra / board-pismo-powermon.c
1 /*
2  * arch/arm/mach-tegra/board-pismo-powermon.c
3  *
4  * Copyright (c) 2011-2013, NVIDIA Corporation. All Rights Reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #include <linux/i2c.h>
20 #include <linux/ina219.h>
21
22 #include "board.h"
23 #include "board-pismo.h"
24
25 #define PRECISION_MULTIPLIER_PISMO 1000
26
27 enum {
28         VDD_12V_DCIN_RS,
29         VDD_AC_BAT_VIN1,
30         VDD_5V0_SYS,
31         VDD_3V3_SYS,
32         VDD_3V3_SYS_VIN4_5_7,
33         AVDD_USB_HDMI,
34         VDD_AC_BAT_D1,
35         VDD_AO_SMPS12_IN,
36         VDD_3V3_SYS_SMPS45_IN,
37         VDD_AO_SMPS2_IN,
38         VDDIO_HV_AP,
39         VDD_1V8_LDO3_IN,
40         VDD_3V3_SYS_LDO4_IN,
41         VDD_AO_LDO8_IN,
42         VDD_1V8_AP,
43         VDD_1V8_DSM,
44 };
45
46 static struct ina219_platform_data power_mon_info[] = {
47         [VDD_12V_DCIN_RS] = {
48                 .calibration_data  = 0xaec0,
49                 .power_lsb = 1.8311874106 * PRECISION_MULTIPLIER_PISMO,
50                 .rail_name = "VDD_12V_DCIN_RS",
51                 .divisor = 20,
52                 .precision_multiplier = PRECISION_MULTIPLIER_PISMO,
53                 .cont_conf = 0x3FFF,
54                 .trig_conf = 0x1DB,
55                 .shunt_resistor = 10,
56         },
57
58         [VDD_AC_BAT_VIN1] = {
59                 .calibration_data  = 0xfffe,
60                 .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_PISMO,
61                 .rail_name = "VDD_AC_BAT_VIN1",
62                 .divisor = 20,
63                 .precision_multiplier = PRECISION_MULTIPLIER_PISMO,
64                 .cont_conf = 0x3FFF,
65                 .trig_conf = 0x1DB,
66                 .shunt_resistor = 10,
67         },
68
69         [VDD_5V0_SYS] = {
70                 .calibration_data  = 0xfffe,
71                 .power_lsb = 2.5000762963 * PRECISION_MULTIPLIER_PISMO,
72                 .rail_name = "VDD_5V0_SYS",
73                 .divisor = 20,
74                 .precision_multiplier = PRECISION_MULTIPLIER_PISMO,
75                 .cont_conf = 0x3FFF,
76                 .trig_conf = 0x1DB,
77                 .shunt_resistor = 5,
78         },
79
80         [VDD_3V3_SYS] = {
81                 .calibration_data  = 0xfffe,
82                 .power_lsb = 2.5000762963 * PRECISION_MULTIPLIER_PISMO,
83                 .rail_name = "VDD_3V3_SYS",
84                 .divisor = 20,
85                 .precision_multiplier = PRECISION_MULTIPLIER_PISMO,
86                 .cont_conf = 0x3FFF,
87                 .trig_conf = 0x1DB,
88                 .shunt_resistor = 5,
89         },
90
91         [VDD_3V3_SYS_VIN4_5_7] = {
92                 .calibration_data  = 0xfffe,
93                 .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_PISMO,
94                 .rail_name = "VDD_3V3_SYS_VIN4_5_7",
95                 .divisor = 20,
96                 .precision_multiplier = PRECISION_MULTIPLIER_PISMO,
97                 .cont_conf = 0x3FFF,
98                 .trig_conf = 0x1DB,
99                 .shunt_resistor = 10,
100         },
101
102         [AVDD_USB_HDMI] = {
103                 .calibration_data  = 0xfffe,
104                 .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_PISMO,
105                 .rail_name = "AVDD_USB_HDMI",
106                 .divisor = 20,
107                 .precision_multiplier = PRECISION_MULTIPLIER_PISMO,
108                 .cont_conf = 0x3FFF,
109                 .trig_conf = 0x1DB,
110                 .shunt_resistor = 10,
111         },
112
113         [VDD_AC_BAT_D1] = {
114                 .calibration_data  = 0x7CD2,
115                 .power_lsb = 2.563685298 * PRECISION_MULTIPLIER_PISMO,
116                 .rail_name = "VDD_AC_BAT_D1",
117                 .divisor = 20,
118                 .precision_multiplier = PRECISION_MULTIPLIER_PISMO,
119                 .cont_conf = 0x3FFF,
120                 .trig_conf = 0x1DB,
121                 .shunt_resistor = 10,
122         },
123
124         [VDD_AO_SMPS12_IN] = {
125                 .calibration_data  = 0xaec0,
126                 .power_lsb = 1.8311874106 * PRECISION_MULTIPLIER_PISMO,
127                 .rail_name = "VDD_AO_SMPS12_IN",
128                 .divisor = 20,
129                 .precision_multiplier = PRECISION_MULTIPLIER_PISMO,
130                 .cont_conf = 0x3FFF,
131                 .trig_conf = 0x1DB,
132                 .shunt_resistor = 10,
133         },
134
135         [VDD_3V3_SYS_SMPS45_IN] = {
136                 .calibration_data  = 0xfffe,
137                 .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_PISMO,
138                 .rail_name = "VDD_3V3_SYS_SMPS45_IN",
139                 .divisor = 20,
140                 .precision_multiplier = PRECISION_MULTIPLIER_PISMO,
141                 .cont_conf = 0x3FFF,
142                 .trig_conf = 0x1DB,
143                 .shunt_resistor = 10,
144         },
145
146         [VDD_AO_SMPS2_IN] = {
147                 .calibration_data  = 0xfffe,
148                 .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_PISMO,
149                 .rail_name = "VDD_AO_SMPS2_IN",
150                 .divisor = 20,
151                 .precision_multiplier = PRECISION_MULTIPLIER_PISMO,
152                 .cont_conf = 0x3FFF,
153                 .trig_conf = 0x1DB,
154                 .shunt_resistor = 10,
155         },
156
157         [VDDIO_HV_AP] = {
158                 .calibration_data  = 0xfffe,
159                 .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_PISMO,
160                 .rail_name = "VDDIO_HV_AP",
161                 .divisor = 20,
162                 .precision_multiplier = PRECISION_MULTIPLIER_PISMO,
163                 .cont_conf = 0x3FFF,
164                 .trig_conf = 0x1DB,
165                 .shunt_resistor = 10,
166         },
167
168         [VDD_1V8_LDO3_IN] = {
169                 .calibration_data  = 0xfffe,
170                 .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_PISMO,
171                 .rail_name = "VDD_1V8_LDO3_IN",
172                 .divisor = 20,
173                 .precision_multiplier = PRECISION_MULTIPLIER_PISMO,
174                 .cont_conf = 0x3FFF,
175                 .trig_conf = 0x1DB,
176                 .shunt_resistor = 10,
177         },
178
179         [VDD_3V3_SYS_LDO4_IN] = {
180                 .calibration_data  = 0xfffe,
181                 .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_PISMO,
182                 .rail_name = "VDD_3V3_SYS_LDO4_IN",
183                 .divisor = 20,
184                 .precision_multiplier = PRECISION_MULTIPLIER_PISMO,
185                 .cont_conf = 0x3FFF,
186                 .trig_conf = 0x1DB,
187                 .shunt_resistor = 10,
188         },
189
190         [VDD_AO_LDO8_IN] = {
191                 .calibration_data  = 0xfffe,
192                 .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_PISMO,
193                 .rail_name = "VDD_AO_LDO8_IN",
194                 .divisor = 20,
195                 .precision_multiplier = PRECISION_MULTIPLIER_PISMO,
196                 .cont_conf = 0x3FFF,
197                 .trig_conf = 0x1DB,
198                 .shunt_resistor = 10,
199         },
200
201         [VDD_1V8_AP] = {
202                 .calibration_data  = 0xfffe,
203                 .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_PISMO,
204                 .rail_name = "VDD_1V8_AP",
205                 .divisor = 20,
206                 .precision_multiplier = PRECISION_MULTIPLIER_PISMO,
207                 .cont_conf = 0x3FFF,
208                 .trig_conf = 0x1DB,
209                 .shunt_resistor = 10,
210         },
211
212         [VDD_1V8_DSM] = {
213                 .calibration_data  = 0xfffe,
214                 .power_lsb = 1.2500381481 * PRECISION_MULTIPLIER_PISMO,
215                 .rail_name = "VDD_1V8_DSM",
216                 .divisor = 20,
217                 .precision_multiplier = PRECISION_MULTIPLIER_PISMO,
218                 .cont_conf = 0x3FFF,
219                 .trig_conf = 0x1DB,
220                 .shunt_resistor = 10,
221         },
222 };
223
224 enum {
225         INA_I2C_ADDR_40,
226         INA_I2C_ADDR_41,
227         INA_I2C_ADDR_42,
228         INA_I2C_ADDR_43,
229         INA_I2C_ADDR_44,
230         INA_I2C_ADDR_45,
231         INA_I2C_ADDR_46,
232         INA_I2C_ADDR_47,
233         INA_I2C_ADDR_48,
234         INA_I2C_ADDR_49,
235         INA_I2C_ADDR_4A,
236         INA_I2C_ADDR_4B,
237         INA_I2C_ADDR_4C,
238         INA_I2C_ADDR_4D,
239         INA_I2C_ADDR_4E,
240         INA_I2C_ADDR_4F,
241 };
242
243 static struct i2c_board_info pismo_i2c0_ina219_board_info[] = {
244         [INA_I2C_ADDR_40] = {
245                 I2C_BOARD_INFO("ina219", 0x40),
246                 .platform_data = &power_mon_info[VDD_12V_DCIN_RS],
247                 .irq = -1,
248         },
249
250         [INA_I2C_ADDR_41] = {
251                 I2C_BOARD_INFO("ina219", 0x41),
252                 .platform_data = &power_mon_info[VDD_AC_BAT_VIN1],
253                 .irq = -1,
254         },
255
256         [INA_I2C_ADDR_42] = {
257                 I2C_BOARD_INFO("ina219", 0x42),
258                 .platform_data = &power_mon_info[VDD_5V0_SYS],
259                 .irq = -1,
260         },
261
262         [INA_I2C_ADDR_43] = {
263                 I2C_BOARD_INFO("ina219", 0x43),
264                 .platform_data = &power_mon_info[VDD_3V3_SYS],
265                 .irq = -1,
266         },
267
268         [INA_I2C_ADDR_44] = {
269                 I2C_BOARD_INFO("ina219", 0x44),
270                 .platform_data = &power_mon_info[VDD_3V3_SYS_VIN4_5_7],
271                 .irq = -1,
272         },
273
274         [INA_I2C_ADDR_45] = {
275                 I2C_BOARD_INFO("ina219", 0x45),
276                 .platform_data = &power_mon_info[AVDD_USB_HDMI],
277                 .irq = -1,
278         },
279
280         [INA_I2C_ADDR_46] = {
281                 I2C_BOARD_INFO("ina219", 0x46),
282                 .platform_data = &power_mon_info[VDD_AC_BAT_D1],
283                 .irq = -1,
284         },
285
286         [INA_I2C_ADDR_47] = {
287                 I2C_BOARD_INFO("ina219", 0x47),
288                 .platform_data = &power_mon_info[VDD_AO_SMPS12_IN],
289                 .irq = -1,
290         },
291
292         [INA_I2C_ADDR_48] = {
293                 I2C_BOARD_INFO("ina219", 0x48),
294                 .platform_data = &power_mon_info[VDD_3V3_SYS_SMPS45_IN],
295                 .irq = -1,
296         },
297
298         [INA_I2C_ADDR_49] = {
299                 I2C_BOARD_INFO("ina219", 0x49),
300                 .platform_data = &power_mon_info[VDD_AO_SMPS2_IN],
301                 .irq = -1,
302         },
303
304         [INA_I2C_ADDR_4A] = {
305                 I2C_BOARD_INFO("ina219", 0x4A),
306                 .platform_data = &power_mon_info[VDDIO_HV_AP],
307                 .irq = -1,
308         },
309
310         [INA_I2C_ADDR_4B] = {
311                 I2C_BOARD_INFO("ina219", 0x4B),
312                 .platform_data = &power_mon_info[VDD_1V8_LDO3_IN],
313                 .irq = -1,
314         },
315
316         [INA_I2C_ADDR_4C] = {
317                 I2C_BOARD_INFO("ina219", 0x4C),
318                 .platform_data = &power_mon_info[VDD_3V3_SYS_LDO4_IN],
319                 .irq = -1,
320         },
321
322         [INA_I2C_ADDR_4D] = {
323                 I2C_BOARD_INFO("ina219", 0x4D),
324                 .platform_data = &power_mon_info[VDD_AO_LDO8_IN],
325                 .irq = -1,
326         },
327
328         [INA_I2C_ADDR_4E] = {
329                 I2C_BOARD_INFO("ina219", 0x4E),
330                 .platform_data = &power_mon_info[VDD_1V8_AP],
331                 .irq = -1,
332         },
333
334         [INA_I2C_ADDR_4F] = {
335                 I2C_BOARD_INFO("ina219", 0x4F),
336                 .platform_data = &power_mon_info[VDD_1V8_DSM],
337                 .irq = -1,
338         },
339 };
340
341 int __init pismo_pmon_init(void)
342 {
343         i2c_register_board_info(1, pismo_i2c0_ina219_board_info,
344                 ARRAY_SIZE(pismo_i2c0_ina219_board_info));
345
346         return 0;
347 }
348