rtc: tps80031: register as mfd sub device
[linux-2.6.git] / arch / arm / mach-tegra / board-cardhu-powermon.c
1 /*
2  * arch/arm/mach-tegra/board-cardhu-powermon.c
3  *
4  * Copyright (c) 2011, NVIDIA, 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-cardhu.h"
26
27 enum {
28         VDD_AC_BAT,
29         VDD_DRAM_IN,
30         VDD_BACKLIGHT_IN,
31         VDD_CPU_IN,
32         VDD_CORE_IN,
33         VDD_DISPLAY_IN,
34         VDD_3V3_TEGRA,
35         VDD_OTHER_PMU_IN,
36         VDD_1V8_TEGRA,
37         VDD_1V8_OTHER,
38         UNUSED_RAIL,
39 };
40
41 static struct ina219_platform_data power_mon_info[] = {
42         [VDD_AC_BAT] = {
43                 .calibration_data  = 0xa000,
44                 .power_lsb = 2,
45                 .rail_name = "VDD_AC_BAT",
46                 .divisor = 20,
47         },
48
49         [VDD_DRAM_IN] = {
50                 .calibration_data  = 0xa000,
51                 .power_lsb = 2,
52                 .rail_name = "VDD_DRAM_IN",
53                 .divisor = 20,
54         },
55
56         [VDD_BACKLIGHT_IN] = {
57                 .calibration_data  = 0x6aaa,
58                 .power_lsb = 1,
59                 .rail_name = "VDD_BACKLIGHT_IN",
60                 .divisor = 20,
61         },
62
63         [VDD_CPU_IN] = {
64                 .calibration_data  = 0xa000,
65                 .power_lsb = 1,
66                 .rail_name = "VDD_CPU_IN",
67                 .divisor = 20,
68         },
69
70         [VDD_CORE_IN] = {
71                 .calibration_data  = 0x6aaa,
72                 .power_lsb = 1,
73                 .rail_name = "VDD_CORE_IN",
74                 .divisor = 20,
75         },
76
77         [VDD_DISPLAY_IN] = {
78                 .calibration_data  = 0x4000,
79                 .power_lsb = 1,
80                 .rail_name = "VDD_DISPLAY_IN",
81                 .divisor = 20,
82         },
83
84         [VDD_3V3_TEGRA] = {
85                 .calibration_data  = 0x6aaa,
86                 .power_lsb = 1,
87                 .rail_name = "VDD_3V3_TEGRA",
88                 .divisor = 20,
89         },
90
91         [VDD_OTHER_PMU_IN] = {
92                 .calibration_data  = 0xa000,
93                 .power_lsb = 1,
94                 .rail_name = "VDD_OTHER_PMU_IN",
95                 .divisor = 20,
96         },
97
98         [VDD_1V8_TEGRA] = {
99                 .calibration_data  = 0x4000,
100                 .power_lsb = 1,
101                 .rail_name = "VDD_1V8_TEGRA",
102                 .divisor = 20,
103         },
104
105         [VDD_1V8_OTHER] = {
106                 .calibration_data  = 0xa000,
107                 .power_lsb = 1,
108                 .rail_name = "VDD_1V8_OTHER",
109                 .divisor = 20,
110         },
111
112         /* All unused INA219 devices use below data*/
113         [UNUSED_RAIL] = {
114                 .calibration_data  = 0x4000,
115                 .power_lsb = 1,
116                 .rail_name = "unused_rail",
117                 .divisor = 20,
118         },
119 };
120
121 enum {
122         INA_I2C_ADDR_40,
123         INA_I2C_ADDR_41,
124         INA_I2C_ADDR_42,
125         INA_I2C_ADDR_43,
126         INA_I2C_ADDR_44,
127         INA_I2C_ADDR_45,
128         INA_I2C_ADDR_46,
129         INA_I2C_ADDR_47,
130         INA_I2C_ADDR_48,
131         INA_I2C_ADDR_49,
132         INA_I2C_ADDR_4A,
133         INA_I2C_ADDR_4B,
134         INA_I2C_ADDR_4C,
135         INA_I2C_ADDR_4D,
136         INA_I2C_ADDR_4E,
137         INA_I2C_ADDR_4F,
138 };
139
140 static struct i2c_board_info cardhu_i2c0_ina219_board_info[] = {
141         [INA_I2C_ADDR_40] = {
142                 I2C_BOARD_INFO("ina219", 0x40),
143                 .platform_data = &power_mon_info[VDD_AC_BAT],
144                 .irq = -1,
145         },
146
147         [INA_I2C_ADDR_41] = {
148                 I2C_BOARD_INFO("ina219", 0x41),
149                 .platform_data = &power_mon_info[VDD_DRAM_IN],
150                 .irq = -1,
151         },
152
153         [INA_I2C_ADDR_42] = {
154                 I2C_BOARD_INFO("ina219", 0x42),
155                 .platform_data = &power_mon_info[VDD_BACKLIGHT_IN],
156                 .irq = -1,
157         },
158
159         [INA_I2C_ADDR_43] = {
160                 I2C_BOARD_INFO("ina219", 0x43),
161                 .platform_data = &power_mon_info[VDD_CPU_IN],
162                 .irq = -1,
163         },
164
165         [INA_I2C_ADDR_44] = {
166                 I2C_BOARD_INFO("ina219", 0x44),
167                 .platform_data = &power_mon_info[VDD_CORE_IN],
168                 .irq = -1,
169         },
170
171         [INA_I2C_ADDR_45] = {
172                 I2C_BOARD_INFO("ina219", 0x45),
173                 .platform_data = &power_mon_info[VDD_DISPLAY_IN],
174                 .irq = -1,
175         },
176
177         [INA_I2C_ADDR_46] = {
178                 I2C_BOARD_INFO("ina219", 0x46),
179                 .platform_data = &power_mon_info[VDD_3V3_TEGRA],
180                 .irq = -1,
181         },
182
183         [INA_I2C_ADDR_47] = {
184                 I2C_BOARD_INFO("ina219", 0x47),
185                 .platform_data = &power_mon_info[VDD_OTHER_PMU_IN],
186                 .irq = -1,
187         },
188
189         [INA_I2C_ADDR_48] = {
190                 I2C_BOARD_INFO("ina219", 0x48),
191                 .platform_data = &power_mon_info[VDD_1V8_TEGRA],
192                 .irq = -1,
193         },
194
195         [INA_I2C_ADDR_49] = {
196                 I2C_BOARD_INFO("ina219", 0x49),
197                 .platform_data = &power_mon_info[VDD_1V8_OTHER],
198                 .irq = -1,
199         },
200
201         [INA_I2C_ADDR_4A] = {
202                 I2C_BOARD_INFO("ina219", 0x4A),
203                 .platform_data = &power_mon_info[UNUSED_RAIL],
204                 .irq = -1,
205         },
206
207         [INA_I2C_ADDR_4B] = {
208                 I2C_BOARD_INFO("ina219", 0x4B),
209                 .platform_data = &power_mon_info[UNUSED_RAIL],
210                 .irq = -1,
211         },
212
213         [INA_I2C_ADDR_4C] = {
214                 I2C_BOARD_INFO("ina219", 0x4C),
215                 .platform_data = &power_mon_info[UNUSED_RAIL],
216                 .irq = -1,
217         },
218
219         [INA_I2C_ADDR_4D] = {
220                 I2C_BOARD_INFO("ina219", 0x4D),
221                 .platform_data = &power_mon_info[UNUSED_RAIL],
222                 .irq = -1,
223         },
224
225         [INA_I2C_ADDR_4E] = {
226                 I2C_BOARD_INFO("ina219", 0x4E),
227                 .platform_data = &power_mon_info[UNUSED_RAIL],
228                 .irq = -1,
229         },
230
231         [INA_I2C_ADDR_4F] = {
232                 I2C_BOARD_INFO("ina219", 0x4F),
233                 .platform_data = &power_mon_info[UNUSED_RAIL],
234                 .irq = -1,
235         },
236 };
237
238 int __init cardhu_pmon_init(void)
239 {
240         struct board_info bi;
241
242         tegra_get_board_info(&bi);
243
244         /* for fab A04 VDD_CORE_IN changed from ina with addr 0x44 to 0x4A */
245         if (bi.fab == BOARD_FAB_A04) {
246                 cardhu_i2c0_ina219_board_info[INA_I2C_ADDR_44].platform_data =
247                         &power_mon_info[UNUSED_RAIL];
248                 cardhu_i2c0_ina219_board_info[INA_I2C_ADDR_4A].platform_data =
249                         &power_mon_info[VDD_CORE_IN];
250         }
251
252         if (bi.board_id != BOARD_PM269) {
253                 i2c_register_board_info(0, cardhu_i2c0_ina219_board_info,
254                         ARRAY_SIZE(cardhu_i2c0_ina219_board_info));
255         }
256
257         return 0;
258 }
259