ARM: tegra: laguna: Initialize INA226 on Laguna PM358
[linux-3.10.git] / arch / arm / mach-tegra / board-laguna-powermon.c
1 /*
2  * arch/arm/mach-tegra/board-laguna-powermon.c
3  *
4  * Copyright (c) 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
20 #include <linux/i2c.h>
21 #include <linux/platform_data/ina230.h>
22
23 #include "board.h"
24 #include "board-ardbeg.h"
25
26 #define PRECISION_MULTIPLIER_LAGUNA     1000
27
28 enum {
29         VDD_MUX,
30         VDD_CPU,
31         VDDIO_DDR_AP_1V35,
32         VDD_CORE,
33         COM_1V8,
34         VDDIO_DDR_1V35,
35         AVDDIO_PEX_AP_1V05,
36         PEX_PLL_AP_3V3,
37         VDD_USB_AP_3V3,
38         VDD_GPU,
39         HVDD_SATA_AP_3V3,
40         VDDIO_SYS_AP_1V8,
41         VDDIO_BB_AP,
42         AVDD_LVDS_AP_1V05,
43         AVDD_HDMI_AP_3V3,
44 };
45
46 /* power monitor parameters for Laguna PM358*/
47 static struct ina230_platform_data laguna_pm358_power_mon_info[] = {
48         [VDD_MUX] = {
49                 .calibration_data  = 0x7FFF,
50                 .power_lsb = 3.63304501 * PRECISION_MULTIPLIER_LAGUNA,
51                 .rail_name = "VDD_MUX",
52                 .divisor = 25,
53                 .precision_multiplier = PRECISION_MULTIPLIER_LAGUNA,
54         },
55         [VDD_CPU] = {
56                 .calibration_data  = 0x3E6A,
57                 .power_lsb = 16.02172852 * PRECISION_MULTIPLIER_LAGUNA,
58                 .rail_name = "VDD_CPU",
59                 .divisor = 25,
60                 .precision_multiplier = PRECISION_MULTIPLIER_LAGUNA,
61         },
62         [VDDIO_DDR_AP_1V35] = {
63                 .calibration_data  = 0x7FFF,
64                 .power_lsb = 0.550446687 * PRECISION_MULTIPLIER_LAGUNA,
65                 .rail_name = "VDDIO_DDR_AP_1V35",
66                 .divisor = 25,
67                 .precision_multiplier = PRECISION_MULTIPLIER_LAGUNA,
68         },
69         [VDD_CORE] = {
70                 .calibration_data  = 0x369D,
71                 .power_lsb = 4.577636719 * PRECISION_MULTIPLIER_LAGUNA,
72                 .rail_name = "VDD_CORE",
73                 .divisor = 25,
74                 .precision_multiplier = PRECISION_MULTIPLIER_LAGUNA,
75         },
76         [COM_1V8] = {
77                 .calibration_data  = 0x7FFF,
78                 .power_lsb = 0.053405762 * PRECISION_MULTIPLIER_LAGUNA,
79                 .rail_name = "COM_1V8",
80                 .divisor = 25,
81                 .precision_multiplier = PRECISION_MULTIPLIER_LAGUNA,
82         },
83         [VDDIO_DDR_1V35] = {
84                 .calibration_data  = 0x7FFF,
85                 .power_lsb = 0.762939453 * PRECISION_MULTIPLIER_LAGUNA,
86                 .rail_name = "VDDIO_DDR_1V35",
87                 .divisor = 25,
88                 .precision_multiplier = PRECISION_MULTIPLIER_LAGUNA,
89         },
90         [AVDDIO_PEX_AP_1V05] = {
91                 .calibration_data  = 0x7FFF,
92                 .power_lsb = 0.356038411 * PRECISION_MULTIPLIER_LAGUNA,
93                 .rail_name = "AVDDIO_PEX_AP_1V05",
94                 .divisor = 25,
95                 .precision_multiplier = PRECISION_MULTIPLIER_LAGUNA,
96         },
97         [PEX_PLL_AP_3V3] = {
98                 .calibration_data  = 0x7FFF,
99                 .power_lsb = 0.027743253 * PRECISION_MULTIPLIER_LAGUNA,
100                 .rail_name = "PEX_PLL_AP_3V3",
101                 .divisor = 25,
102                 .precision_multiplier = PRECISION_MULTIPLIER_LAGUNA,
103         },
104         [VDD_USB_AP_3V3] = {
105                 .calibration_data  = 0x7FFF,
106                 .power_lsb = 0.023119377 * PRECISION_MULTIPLIER_LAGUNA,
107                 .rail_name = "VDD_USB_AP_3V3",
108                 .divisor = 25,
109                 .precision_multiplier = PRECISION_MULTIPLIER_LAGUNA,
110         },
111         [VDD_GPU] = {
112                 .calibration_data  = 0x4EF5,
113                 .power_lsb = 6.332397461 * PRECISION_MULTIPLIER_LAGUNA,
114                 .rail_name = "VDD_GPU",
115                 .divisor = 25,
116                 .precision_multiplier = PRECISION_MULTIPLIER_LAGUNA,
117         },
118         [HVDD_SATA_AP_3V3] = {
119                 .calibration_data  = 0x7FFF,
120                 .power_lsb = 0.003467907 * PRECISION_MULTIPLIER_LAGUNA,
121                 .rail_name = "HVDD_SATA_AP_3V3",
122                 .divisor = 25,
123                 .precision_multiplier = PRECISION_MULTIPLIER_LAGUNA,
124         },
125         [VDDIO_SYS_AP_1V8] = {
126                 .calibration_data  = 0x7FFF,
127                 .power_lsb = 0.023312039 * PRECISION_MULTIPLIER_LAGUNA,
128                 .rail_name = "VDDIO_SYS_AP_1V8",
129                 .divisor = 25,
130                 .precision_multiplier = PRECISION_MULTIPLIER_LAGUNA,
131         },
132         [VDDIO_BB_AP] = {
133                 .calibration_data  = 0x7FFF,
134                 .power_lsb = 0.002288818 * PRECISION_MULTIPLIER_LAGUNA,
135                 .rail_name = "VDDIO_BB_AP",
136                 .divisor = 25,
137                 .precision_multiplier = PRECISION_MULTIPLIER_LAGUNA,
138         },
139         [AVDD_LVDS_AP_1V05] = {
140                 .calibration_data  = 0x7FFF,
141                 .power_lsb = 0.007629395 * PRECISION_MULTIPLIER_LAGUNA,
142                 .rail_name = "AVDD_LVDS_AP_1V05",
143                 .divisor = 25,
144                 .precision_multiplier = PRECISION_MULTIPLIER_LAGUNA,
145         },
146         [AVDD_HDMI_AP_3V3] = {
147                 .calibration_data  = 0x7FFF,
148                 .power_lsb = 0.070514101 * PRECISION_MULTIPLIER_LAGUNA,
149                 .rail_name = "AVDD_HDMI_AP_3V3",
150                 .divisor = 25,
151                 .precision_multiplier = PRECISION_MULTIPLIER_LAGUNA,
152         },
153
154 };
155
156 enum {
157         INA_I2C_ADDR_40,
158         INA_I2C_ADDR_41,
159         INA_I2C_ADDR_42,
160         INA_I2C_ADDR_43,
161         INA_I2C_ADDR_44,
162         INA_I2C_ADDR_45,
163         INA_I2C_ADDR_46,
164         INA_I2C_ADDR_47,
165         INA_I2C_ADDR_48,
166         INA_I2C_ADDR_49,
167         INA_I2C_ADDR_4A,
168         INA_I2C_ADDR_4B,
169         INA_I2C_ADDR_4D,
170         INA_I2C_ADDR_4E,
171         INA_I2C_ADDR_4F,
172 };
173
174 static struct i2c_board_info laguna_pm358_i2c_ina230_board_info[] = {
175         [INA_I2C_ADDR_40] = {
176                 I2C_BOARD_INFO("ina230", 0x40),
177                 .platform_data = &laguna_pm358_power_mon_info[VDD_MUX],
178                 .irq = -1,
179         },
180         [INA_I2C_ADDR_41] = {
181                 I2C_BOARD_INFO("ina230", 0x41),
182                 .platform_data = &laguna_pm358_power_mon_info[VDD_CPU],
183                 .irq = -1,
184         },
185         [INA_I2C_ADDR_42] = {
186                 I2C_BOARD_INFO("ina230", 0x42),
187                 .platform_data =
188                 &laguna_pm358_power_mon_info[VDDIO_DDR_AP_1V35],
189                 .irq = -1,
190         },
191         [INA_I2C_ADDR_43] = {
192                 I2C_BOARD_INFO("ina230", 0x43),
193                 .platform_data = &laguna_pm358_power_mon_info[VDD_CORE],
194                 .irq = -1,
195         },
196         [INA_I2C_ADDR_44] = {
197                 I2C_BOARD_INFO("ina230", 0x44),
198                 .platform_data = &laguna_pm358_power_mon_info[COM_1V8],
199                 .irq = -1,
200         },
201         [INA_I2C_ADDR_45] = {
202                 I2C_BOARD_INFO("ina230", 0x45),
203                 .platform_data = &laguna_pm358_power_mon_info[VDDIO_DDR_1V35],
204                 .irq = -1,
205         },
206         [INA_I2C_ADDR_46] = {
207                 I2C_BOARD_INFO("ina230", 0x46),
208                 .platform_data =
209                 &laguna_pm358_power_mon_info[AVDDIO_PEX_AP_1V05],
210                 .irq = -1,
211         },
212         [INA_I2C_ADDR_47] = {
213                 I2C_BOARD_INFO("ina230", 0x47),
214                 .platform_data = &laguna_pm358_power_mon_info[PEX_PLL_AP_3V3],
215                 .irq = -1,
216         },
217         [INA_I2C_ADDR_48] = {
218                 I2C_BOARD_INFO("ina230", 0x48),
219                 .platform_data = &laguna_pm358_power_mon_info[VDD_USB_AP_3V3],
220                 .irq = -1,
221         },
222         [INA_I2C_ADDR_49] = {
223                 I2C_BOARD_INFO("ina230", 0x49),
224                 .platform_data = &laguna_pm358_power_mon_info[VDD_GPU],
225                 .irq = -1,
226         },
227         [INA_I2C_ADDR_4A] = {
228                 I2C_BOARD_INFO("ina230", 0x4A),
229                 .platform_data =
230                 &laguna_pm358_power_mon_info[HVDD_SATA_AP_3V3],
231                 .irq = -1,
232         },
233         [INA_I2C_ADDR_4B] = {
234                 I2C_BOARD_INFO("ina230", 0x4B),
235                 .platform_data =
236                 &laguna_pm358_power_mon_info[VDDIO_SYS_AP_1V8],
237                 .irq = -1,
238         },
239         [INA_I2C_ADDR_4D] = {
240                 I2C_BOARD_INFO("ina230", 0x4D),
241                 .platform_data = &laguna_pm358_power_mon_info[VDDIO_BB_AP],
242                 .irq = -1,
243         },
244         [INA_I2C_ADDR_4E] = {
245                 I2C_BOARD_INFO("ina230", 0x4E),
246                 .platform_data =
247                 &laguna_pm358_power_mon_info[AVDD_LVDS_AP_1V05],
248                 .irq = -1,
249         },
250         [INA_I2C_ADDR_4F] = {
251                 I2C_BOARD_INFO("ina230", 0x4F),
252                 .platform_data =
253                 &laguna_pm358_power_mon_info[AVDD_HDMI_AP_3V3],
254                 .irq = -1,
255         },
256
257 };
258
259 int __init laguna_pm358_pmon_init(void)
260 {
261         i2c_register_board_info(1, laguna_pm358_i2c_ina230_board_info,
262                 ARRAY_SIZE(laguna_pm358_i2c_ina230_board_info));
263         return 0;
264 }
265