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