ARM: tegra12: set CPU rate to 2.2GHz for sku 0x87
[linux-3.10.git] / arch / arm / mach-tegra / board-loki-powermon.c
1 /*
2  * arch/arm/mach-tegra/board-loki-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
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/ina3221.h>
23
24 #include "board.h"
25 #include "board-loki.h"
26 #include "tegra-board-id.h"
27
28 enum {
29         VDD_CPU_BAT_VBUS,
30         VDD_DDR_SOC_GPU,
31         VDD_3V3_EMMC_MDM,
32         VDD_BAT_VBUS_MODEM,
33         VDD_BAT_VBUS_MODEM_P2530_A03,
34 };
35
36 static struct ina3221_platform_data power_mon_info[] = {
37         [VDD_CPU_BAT_VBUS] = {
38                 .rail_name = {"VDD_CPU", "VDD_BAT",
39                                                         "VDD_VBUS"},
40                 .shunt_resistor = {5, 5, 20},
41                 .cont_conf_data = INA3221_CONT_CONFIG_DATA,
42                 .trig_conf_data = INA3221_TRIG_CONFIG_DATA,
43                 .warn_conf_limits = {-1, -1, -1},
44                 .crit_conf_limits = {-1, 6800, -1},
45         },
46         [VDD_DDR_SOC_GPU] = {
47                 .rail_name = {"VDD_DDR", "VDD_SOC",
48                                                         "VDD_GPU"},
49                 .shunt_resistor = {30, 30, 10},
50                 .cont_conf_data = INA3221_CONT_CONFIG_DATA,
51                 .trig_conf_data = INA3221_TRIG_CONFIG_DATA,
52                 .warn_conf_limits = {-1, -1, -1},
53                 .crit_conf_limits = {-1, -1, -1},
54         },
55         [VDD_3V3_EMMC_MDM] = {
56                 .rail_name = {"VDD_3V3_SYS", "VDD_EMMC",
57                                                         "VDD_MDM"},
58                 .shunt_resistor = {30, 30, 20},
59                 .cont_conf_data = INA3221_CONT_CONFIG_DATA,
60                 .trig_conf_data = INA3221_TRIG_CONFIG_DATA,
61                 .warn_conf_limits = {-1, -1, -1},
62                 .crit_conf_limits = {-1, -1, -1},
63         },
64         [VDD_BAT_VBUS_MODEM] = {
65                 .rail_name = {"VDD_BATT", "VDD_VBUS",
66                                                         "VDD_MODEM"},
67                 .shunt_resistor = {10, 10, 10},
68                 .cont_conf_data = INA3221_CONT_CONFIG_DATA,
69                 .trig_conf_data = INA3221_TRIG_CONFIG_DATA,
70                 .warn_conf_limits = {-1, -1, -1},
71                 .crit_conf_limits = {6800, -1, -1},
72         },
73         [VDD_BAT_VBUS_MODEM_P2530_A03] = {
74                 .rail_name = {"VDD_BATT", "VDD_VBUS",
75                                                         "VDD_MODEM"},
76                 .shunt_resistor = {5, 5, 5},
77                 .cont_conf_data = INA3221_CONT_CONFIG_DATA,
78                 .trig_conf_data = INA3221_TRIG_CONFIG_DATA,
79                 .warn_conf_limits = {-1, -1, -1},
80                 .crit_conf_limits = {6800, -1, -1},
81         },
82 };
83
84 enum {
85         INA_I2C_ADDR_40,
86         INA_I2C_ADDR_41,
87         INA_I2C_ADDR_42,
88 };
89
90 static struct i2c_board_info loki_i2c1_ina3221_board_e2548_info[] = {
91         [INA_I2C_ADDR_40] = {
92                 I2C_BOARD_INFO("ina3221", 0x40),
93                 .platform_data = &power_mon_info[VDD_CPU_BAT_VBUS],
94                 .irq = -1,
95         },
96         [INA_I2C_ADDR_41] = {
97                 I2C_BOARD_INFO("ina3221", 0x41),
98                 .platform_data = &power_mon_info[VDD_DDR_SOC_GPU],
99                 .irq = -1,
100         },
101         [INA_I2C_ADDR_42] = {
102                 I2C_BOARD_INFO("ina3221", 0x42),
103                 .platform_data = &power_mon_info[VDD_3V3_EMMC_MDM],
104                 .irq = -1,
105         },
106 };
107
108 static struct i2c_board_info loki_i2c1_ina3221_board_e2549_info[] = {
109         [INA_I2C_ADDR_40] = {
110                 I2C_BOARD_INFO("ina3221", 0x40),
111                 .platform_data = &power_mon_info[VDD_BAT_VBUS_MODEM],
112                 .irq = -1,
113         },
114 };
115
116 static struct i2c_board_info loki_i2c1_ina3221_board_p2530_A03_info[] = {
117         [INA_I2C_ADDR_40] = {
118                 I2C_BOARD_INFO("ina3221", 0x40),
119                 .platform_data = &power_mon_info[VDD_BAT_VBUS_MODEM_P2530_A03],
120                 .irq = -1,
121         },
122 };
123
124 int __init loki_pmon_init(void)
125 {
126         struct board_info info;
127         tegra_get_board_info(&info);
128         if (info.board_id == BOARD_E2548) {
129                 pr_info("INA3221: registering for E2548\n");
130                 i2c_register_board_info(1, loki_i2c1_ina3221_board_e2548_info,
131                         ARRAY_SIZE(loki_i2c1_ina3221_board_e2548_info));
132         } else if (info.board_id == BOARD_E2549 ||
133                 (info.board_id == BOARD_P2530 && info.fab < 0xa3)) {
134                 pr_info("INA3221: registering for E2549/P2530-A00 and A01\n");
135                 i2c_register_board_info(1, loki_i2c1_ina3221_board_e2549_info,
136                         ARRAY_SIZE(loki_i2c1_ina3221_board_e2549_info));
137         } else if (info.board_id == BOARD_P2530 && info.fab >= 0xa3) {
138                 pr_info("INA3221: registering for P2530-A03\n");
139                 i2c_register_board_info(1,
140                 loki_i2c1_ina3221_board_p2530_A03_info,
141                 ARRAY_SIZE(loki_i2c1_ina3221_board_p2530_A03_info));
142         } else
143                 pr_err("INA3221: Didn't find the right board config\n");
144         return 0;
145 }