2 * arch/arm/mach-tegra/board-vcm30_t124-power.c
4 * Copyright (c) 2013-2014, NVIDIA CORPORATION. All rights reserved.
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.
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
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/>.
18 #include <linux/i2c.h>
20 #include <linux/mfd/max77663-core.h>
21 #include <linux/regulator/max77663-regulator.h>
22 #include <linux/regulator/max15569-regulator.h>
23 #include <linux/gpio.h>
24 #include <linux/i2c/pca953x.h>
25 #include <linux/tegra-pmc.h>
29 #include "gpio-names.h"
30 #include "board-common.h"
31 #include "board-vcm30_t124.h"
32 #include "tegra_cl_dvfs.h"
34 #include "tegra11_soctherm.h"
35 #include <mach/board_id.h>
38 #define PMC_CTRL_INTR_LOW (1 << 17)
41 static struct regulator_consumer_supply max77663_ldo5_supply[] = {
42 REGULATOR_SUPPLY("vddio_sdmmc", "sdhci-tegra.2"),
43 REGULATOR_SUPPLY("vddio_sd_slot", "sdhci-tegra.2"),
44 REGULATOR_SUPPLY("pwrdet_sdmmc3", NULL),
47 static struct max77663_regulator_fps_cfg max77663_fps_cfgs[] = {
50 .en_src = FPS_EN_SRC_EN0,
51 .time_period = FPS_TIME_PERIOD_DEF,
55 .en_src = FPS_EN_SRC_EN1,
56 .time_period = FPS_TIME_PERIOD_DEF,
60 .en_src = FPS_EN_SRC_EN0,
61 .time_period = FPS_TIME_PERIOD_DEF,
65 #define MAX77663_PDATA_INIT(_rid, _id, _min_uV, _max_uV, _supply_reg, \
66 _always_on, _boot_on, _apply_uV, \
67 _fps_src, _fps_pu_period, _fps_pd_period, _flags) \
68 static struct regulator_init_data max77663_regulator_idata_##_id = { \
69 .supply_regulator = _supply_reg, \
71 .name = max77663_rails(_id), \
74 .valid_modes_mask = (REGULATOR_MODE_NORMAL | \
75 REGULATOR_MODE_STANDBY), \
76 .valid_ops_mask = (REGULATOR_CHANGE_MODE | \
77 REGULATOR_CHANGE_STATUS | \
78 REGULATOR_CHANGE_VOLTAGE), \
79 .always_on = _always_on, \
80 .boot_on = _boot_on, \
81 .apply_uV = _apply_uV, \
83 .num_consumer_supplies = \
84 ARRAY_SIZE(max77663_##_id##_supply), \
85 .consumer_supplies = max77663_##_id##_supply, \
87 static struct max77663_regulator_platform_data \
88 max77663_regulator_pdata_##_id = \
90 .reg_init_data = &max77663_regulator_idata_##_id, \
91 .id = MAX77663_REGULATOR_ID_##_rid, \
92 .fps_src = _fps_src, \
93 .fps_pu_period = _fps_pu_period, \
94 .fps_pd_period = _fps_pd_period, \
95 .fps_cfgs = max77663_fps_cfgs, \
99 MAX77663_PDATA_INIT(LDO5, ldo5, 800000, 3950000, NULL, 1, 1, 0,
100 FPS_SRC_1, FPS_POWER_PERIOD_7, FPS_POWER_PERIOD_0, 0);
102 #define MAX77663_REG(_id, _data) (&max77663_regulator_pdata_##_data)
104 static struct max77663_regulator_platform_data *max77663_reg_pdata[] = {
105 MAX77663_REG(LDO5, ldo5),
108 static struct max77663_gpio_config max77663_gpio_cfgs[] = {
110 .gpio = MAX77663_GPIO5,
112 .dout = GPIO_DOUT_HIGH,
113 .out_drv = GPIO_OUT_DRV_PUSH_PULL,
114 .alternate = GPIO_ALT_DISABLE,
118 static struct max77663_platform_data max77663_pdata = {
119 .irq_base = MAX77663_IRQ_BASE,
120 .gpio_base = MAX77663_GPIO_BASE,
122 .num_gpio_cfgs = ARRAY_SIZE(max77663_gpio_cfgs),
123 .gpio_cfgs = max77663_gpio_cfgs,
125 .regulator_pdata = max77663_reg_pdata,
126 .num_regulator_pdata = ARRAY_SIZE(max77663_reg_pdata),
128 .rtc_i2c_addr = 0x68,
130 .use_power_off = false,
133 static struct i2c_board_info __initdata max77663_regulators[] = {
135 /* The I2C address was determined by OTP factory setting */
136 I2C_BOARD_INFO("max77663", 0x3c),
138 .platform_data = &max77663_pdata,
142 /* MAX15569 switching regulator for vdd_cpu */
143 static struct regulator_consumer_supply max15569_vddcpu_supply[] = {
144 REGULATOR_SUPPLY("vdd_cpu", NULL),
147 static struct regulator_init_data max15569_vddcpu_init_data = {
151 .valid_modes_mask = (REGULATOR_MODE_NORMAL |
152 REGULATOR_MODE_STANDBY),
153 .valid_ops_mask = (REGULATOR_CHANGE_MODE |
154 REGULATOR_CHANGE_STATUS |
155 REGULATOR_CHANGE_CONTROL |
156 REGULATOR_CHANGE_VOLTAGE),
161 .num_consumer_supplies = ARRAY_SIZE(max15569_vddcpu_supply),
162 .consumer_supplies = max15569_vddcpu_supply,
165 static struct max15569_regulator_platform_data max15569_vddcpu_pdata = {
166 .reg_init_data = &max15569_vddcpu_init_data,
167 .max_voltage_uV = 1520000,
168 .slew_rate_mv_per_us = 44,
171 static struct i2c_board_info __initdata max15569_vddcpu_boardinfo[] = {
173 I2C_BOARD_INFO("max15569", 0x3a),
174 .platform_data = &max15569_vddcpu_pdata,
178 /* MAX15569 switching regulator for vdd_gpu */
179 static struct regulator_consumer_supply max15569_vddgpu_supply[] = {
180 REGULATOR_SUPPLY("vdd_gpu", NULL),
183 static struct regulator_init_data max15569_vddgpu_init_data = {
187 .valid_modes_mask = (REGULATOR_MODE_NORMAL |
188 REGULATOR_MODE_STANDBY),
189 .valid_ops_mask = (REGULATOR_CHANGE_MODE |
190 REGULATOR_CHANGE_STATUS |
191 REGULATOR_CHANGE_CONTROL |
192 REGULATOR_CHANGE_VOLTAGE),
197 .num_consumer_supplies = ARRAY_SIZE(max15569_vddgpu_supply),
198 .consumer_supplies = max15569_vddgpu_supply,
201 static struct max15569_regulator_platform_data max15569_vddgpu_pdata = {
202 .reg_init_data = &max15569_vddgpu_init_data,
203 .max_voltage_uV = 1400000,
204 .slew_rate_mv_per_us = 44,
207 static struct i2c_board_info __initdata max15569_vddgpu_boardinfo[] = {
209 I2C_BOARD_INFO("max15569", 0x38),
210 .platform_data = &max15569_vddgpu_pdata,
214 static int __init vcm30_t124_max77663_regulator_init(void)
216 i2c_register_board_info(4, max77663_regulators,
217 ARRAY_SIZE(max77663_regulators));
222 int __init vcm30_t124_regulator_init(void)
224 vcm30_t124_max77663_regulator_init();
225 i2c_register_board_info(4, max15569_vddcpu_boardinfo, 1);
226 i2c_register_board_info(4, max15569_vddgpu_boardinfo, 1);
231 static struct tegra_suspend_platform_data vcm30_t124_suspend_data = {
233 .cpu_off_timer = 2000,
234 .suspend_mode = TEGRA_SUSPEND_LP0,
235 .core_timer = 0xfefe,
236 .core_off_timer = 2000,
237 .corereq_high = true,
238 .sysclkreq_high = true,
239 .cpu_lp2_min_residency = 1000,
242 int __init vcm30_t124_suspend_init(void)
244 tegra_init_suspend(&vcm30_t124_suspend_data);
248 static struct thermal_zone_params soctherm_tzp = {
249 .governor_name = "pid_thermal_gov",
252 static struct tegra_thermtrip_pmic_data tpdata_palmas = {
255 .controller_type = 0,
256 .pmu_i2c_addr = 0x58,
257 .i2c_controller_id = 4,
258 .poweroff_reg_addr = 0xa0,
259 .poweroff_reg_data = 0x0,
262 static struct tegra_thermtrip_pmic_data tpdata_max77663 = {
265 .controller_type = 0,
266 .pmu_i2c_addr = 0x3c,
267 .i2c_controller_id = 4,
268 .poweroff_reg_addr = 0x41,
269 .poweroff_reg_data = 0x80,
272 static struct soctherm_platform_data vcm30_t124_soctherm_data = {
276 .passive_delay = 1000,
277 .hotspot_offset = 6000,
281 .cdev_type = "tegra-balanced",
283 .trip_type = THERMAL_TRIP_PASSIVE,
284 .upper = THERMAL_NO_LIMIT,
285 .lower = THERMAL_NO_LIMIT,
288 .cdev_type = "tegra-heavy",
290 .trip_type = THERMAL_TRIP_HOT,
291 .upper = THERMAL_NO_LIMIT,
292 .lower = THERMAL_NO_LIMIT,
295 .cdev_type = "tegra-shutdown",
297 .trip_type = THERMAL_TRIP_CRITICAL,
298 .upper = THERMAL_NO_LIMIT,
299 .lower = THERMAL_NO_LIMIT,
302 .tzp = &soctherm_tzp,
306 .passive_delay = 1000,
307 .hotspot_offset = 6000,
311 .cdev_type = "tegra-balanced",
313 .trip_type = THERMAL_TRIP_PASSIVE,
314 .upper = THERMAL_NO_LIMIT,
315 .lower = THERMAL_NO_LIMIT,
318 .cdev_type = "tegra-heavy",
320 .trip_type = THERMAL_TRIP_HOT,
321 .upper = THERMAL_NO_LIMIT,
322 .lower = THERMAL_NO_LIMIT,
325 .cdev_type = "tegra-shutdown",
327 .trip_type = THERMAL_TRIP_CRITICAL,
328 .upper = THERMAL_NO_LIMIT,
329 .lower = THERMAL_NO_LIMIT,
332 .tzp = &soctherm_tzp,
342 [THROTTLE_DEV_CPU] = {
349 .tshut_pmu_trip_data = &tpdata_palmas,
353 int __init vcm30_t124_soctherm_init(void)
356 vcm30_t124_soctherm_data.tshut_pmu_trip_data = &tpdata_max77663;
358 tegra_add_cpu_vmax_trips(vcm30_t124_soctherm_data.therm[THERM_CPU].trips,
359 &vcm30_t124_soctherm_data.therm[THERM_CPU].num_trips);
360 /*tegra_add_vc_trips(vcm30_t124_soctherm_data.therm[THERM_CPU].trips,
361 &vcm30_t124_soctherm_data.therm[THERM_CPU].num_trips);
363 return tegra11_soctherm_init(&vcm30_t124_soctherm_data);
367 * GPIO init table for PCA9539 MISC IO GPIOs
368 * that have to be brought up to a known good state
369 * except for WiFi as it is handled via the
372 static struct gpio vcm30_t124_system_0_gpios[] = {
373 {MISCIO_BT_RST_GPIO, GPIOF_OUT_INIT_HIGH, "bt_rst"},
374 #ifdef CONFIG_TEGRA_PREPOWER_WIFI
375 {MISCIO_WF_EN_GPIO, GPIOF_OUT_INIT_HIGH, "wifi_en"},
376 {MISCIO_WF_RST_GPIO, GPIOF_OUT_INIT_HIGH, "wifi_rst"},
378 {MISCIO_WF_EN_GPIO, GPIOF_OUT_INIT_LOW, "wifi_en"},
379 {MISCIO_WF_RST_GPIO, GPIOF_OUT_INIT_LOW, "wifi_rst"},
381 {MISCIO_BT_EN_GPIO, GPIOF_OUT_INIT_HIGH, "bt_en"},
382 {MISCIO_BT_WAKEUP_GPIO, GPIOF_OUT_INIT_HIGH, "bt_wk"},
383 {MISCIO_ABB_RST_GPIO, GPIOF_OUT_INIT_HIGH, "ebb_rst"},
384 {MISCIO_USER_LED2_GPIO, GPIOF_OUT_INIT_LOW, "usr_led2"},
385 {MISCIO_USER_LED1_GPIO, GPIOF_OUT_INIT_LOW, "usr_led1"},
389 * GPIO init table for PCA9539 MISC IO GPIOs
390 * related to DAP_D_SEL and DAP_D_EN.
392 static struct gpio vcm30_t124_system_1_gpios[] = {
393 {MISCIO_MUX_DAP_D_SEL, GPIOF_OUT_INIT_LOW, "dap_d_sel"},
394 {MISCIO_MUX_DAP_D_EN, GPIOF_OUT_INIT_LOW, "dap_d_en"},
397 static int __init vcm30_t124_system_0_gpio_init(void)
399 int ret, pin_count = 0;
400 struct gpio *gpios_info = NULL;
401 gpios_info = vcm30_t124_system_0_gpios;
402 pin_count = ARRAY_SIZE(vcm30_t124_system_0_gpios);
404 /* Set required system GPIOs to initial bootup values */
405 ret = gpio_request_array(gpios_info, pin_count);
408 pr_err("%s gpio_request_array failed(%d)\r\n",
411 gpio_free_array(gpios_info, pin_count);
416 static int __init vcm30_t124_system_1_gpio_init(void)
418 int ret, pin_count = 0;
419 struct gpio *gpios_info = NULL;
420 gpios_info = vcm30_t124_system_1_gpios;
421 pin_count = ARRAY_SIZE(vcm30_t124_system_1_gpios);
423 /* Set required system GPIOs to initial bootup values */
424 ret = gpio_request_array(gpios_info, pin_count);
427 pr_err("%s gpio_request_array failed(%d)\r\n",
430 gpio_free_array(gpios_info, pin_count);
436 * TODO: Check for the correct pca953x before invoking client
439 static int pca953x_client_setup(struct i2c_client *client,
440 unsigned gpio, unsigned ngpio,
444 int system = (int)context;
448 ret = vcm30_t124_system_0_gpio_init();
451 ret = vcm30_t124_system_1_gpio_init();
462 pr_err("%s failed(%d)\r\n", __func__, ret);
467 static struct pca953x_platform_data vcm30_t124_miscio_0_pca9539_data = {
468 .gpio_base = PCA953X_MISCIO_0_GPIO_BASE,
469 .setup = pca953x_client_setup,
470 .context = (void *)0,
473 static struct pca953x_platform_data vcm30_t124_miscio_1_pca9539_data = {
474 .gpio_base = PCA953X_MISCIO_1_GPIO_BASE,
475 .setup = pca953x_client_setup,
476 .context = (void *)1,
479 static struct i2c_board_info vcm30_t124_i2c2_board_info_pca9539_0 = {
480 I2C_BOARD_INFO("pca9539", PCA953X_MISCIO_0_ADDR),
481 .platform_data = &vcm30_t124_miscio_0_pca9539_data,
484 static struct i2c_board_info vcm30_t124_i2c2_board_info_pca9539_1 = {
485 I2C_BOARD_INFO("pca9539", PCA953X_MISCIO_1_ADDR),
486 .platform_data = &vcm30_t124_miscio_1_pca9539_data,
489 int __init vcm30_t124_pca953x_init(void)
491 int is_e1860_b00 = 0;
493 is_e1860_b00 = tegra_is_board(NULL, "61860", NULL, "300", NULL);
495 i2c_register_board_info(1, &vcm30_t124_i2c2_board_info_pca9539_0, 1);
498 i2c_register_board_info(1,
499 &vcm30_t124_i2c2_board_info_pca9539_1, 1);