2 * arch/arm/mach-tegra/board-pluto-sensors.c
4 * Copyright (c) 2012-2013, 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>
19 #include <linux/delay.h>
20 #include <linux/regulator/consumer.h>
21 #include <linux/gpio.h>
22 #include <linux/mpu.h>
23 #include <linux/max77665-charger.h>
24 #include <linux/mfd/max77665.h>
25 #include <linux/input/max77665-haptic.h>
26 #include <linux/power/max17042_battery.h>
27 #include <linux/power/power_supply_extcon.h>
28 #include <linux/nct1008.h>
30 #include <linux/interrupt.h>
31 #include <linux/pid_thermal_gov.h>
33 #include <mach/gpio-tegra.h>
34 #include <mach/pinmux-t11.h>
35 #include <mach/pinmux.h>
36 #include <media/max77665-flash.h>
38 #include <media/imx091.h>
39 #include <media/imx132.h>
40 #include <media/ad5816.h>
42 #include <asm/mach-types.h>
44 #include "gpio-names.h"
46 #include "board-common.h"
47 #include "board-pluto.h"
48 #include "cpu-tegra.h"
50 #include "tegra-board-id.h"
53 #include "battery-ini-model-data.h"
56 static struct nvc_gpio_pdata imx091_gpio_pdata[] = {
57 {IMX091_GPIO_RESET, CAM_RSTN, true, false},
58 {IMX091_GPIO_PWDN, CAM1_POWER_DWN_GPIO, true, false},
59 {IMX091_GPIO_GP1, CAM_GPIO1, true, false}
63 static struct board_info board_info;
65 static struct max17042_platform_data max17042_pdata = {
66 .config_data = &pluto_yoku_2000mA_max17042_battery,
69 .enable_por_init = 1, /* Use POR init from Maxim appnote */
70 .enable_current_sense = 1,
72 .is_battery_present = false, /* False as default */
75 static struct i2c_board_info max17042_device[] = {
77 I2C_BOARD_INFO("max17042", 0x36),
78 .platform_data = &max17042_pdata,
82 static struct nvc_torch_lumi_level_v1 pluto_max77665_lumi_tbl[] = {
101 static unsigned max77665_f_estates[] = { 3500, 2375, 560, 456, 0 };
103 static struct max77665_f_platform_data pluto_max77665_flash_pdata = {
106 /* set to true only when using the torch strobe input
107 * to trigger the flash.
109 .flash_on_torch = false,
110 /* use ONE-SHOOT flash mode - flash triggered at the
111 * raising edge of strobe or strobe signal.
114 /* .flash_on_torch = true, */
115 .max_total_current_mA = 1000,
116 .max_peak_current_mA = 600,
117 .max_flash_threshold_mV = 3400,
118 .max_flash_hysteresis_mV = 200,
119 .max_flash_lbdly_f_uS = 256,
120 .max_flash_lbdly_r_uS = 256,
122 .flash_torch_ratio = 18100,
124 .flash_levels = ARRAY_SIZE(pluto_max77665_lumi_tbl),
125 .lumi_levels = pluto_max77665_lumi_tbl,
128 .flash_torch_ratio = 18100,
130 .flash_levels = ARRAY_SIZE(pluto_max77665_lumi_tbl),
131 .lumi_levels = pluto_max77665_lumi_tbl,
135 .mask = 1 << (CAM_FLASH_STROBE - TEGRA_GPIO_PBB0),
136 .values = 1 << (CAM_FLASH_STROBE - TEGRA_GPIO_PBB0),
139 .gpio_strobe = CAM_FLASH_STROBE,
141 .states = max77665_f_estates,
142 .num_states = ARRAY_SIZE(max77665_f_estates),
143 .e0_index = ARRAY_SIZE(max77665_f_estates) - 1,
144 .priority = EDP_MAX_PRIO + 2,
148 static struct max77665_haptic_platform_data max77665_haptic_pdata = {
151 .type = MAX77665_HAPTIC_LRA,
152 .mode = MAX77665_INTERNAL_MODE,
153 .internal_mode_pattern = 0,
155 .pattern_signal_period = 0xD0,
156 .pwm_divisor = MAX77665_PWM_DIVISOR_128,
157 .feedback_duty_cycle = 12,
158 .invert = MAX77665_INVERT_OFF,
159 .cont_mode = MAX77665_CONT_MODE,
160 .motor_startup_val = 0,
162 .edp_states = { 360, 0 },
165 static struct max77665_charger_cable maxim_cable[] = {
176 .name = "Fast-charger",
179 .name = "Slow-charger",
182 .name = "Charge-downstream",
186 static struct regulator_consumer_supply max77665_charger_supply[] = {
187 REGULATOR_SUPPLY("usb_bat_chg", "tegra-udc.0"),
190 static struct max77665_charger_plat_data max77665_charger = {
191 .fast_chg_cc = 1500, /* fast charger current*/
192 .term_volt = 3700, /* charger termination voltage */
193 .curr_lim = 1500, /* input current limit */
194 .num_cables = MAX_CABLES,
195 .cables = maxim_cable,
196 .extcon_name = "tegra-udc",
197 .is_battery_present = false, /* false as default */
198 .consumer_supplies = max77665_charger_supply,
199 .num_consumer_supplies = ARRAY_SIZE(max77665_charger_supply),
202 static struct max77665_muic_platform_data max77665_muic = {
203 .ext_conn_name = "MAX77665_MUIC_ID",
206 struct max77665_system_interrupt max77665_sys_int = {
207 .enable_thermal_interrupt = true,
208 .enable_low_sys_interrupt = true,
211 static struct max77665_platform_data pluto_max77665_pdata = {
212 .irq_base = MAX77665_TEGRA_IRQ_BASE,
213 .irq_flag = IRQF_ONESHOT | IRQF_TRIGGER_FALLING,
214 .system_interrupt = &max77665_sys_int,
215 .muic_platform_data = {
216 .pdata = &max77665_muic,
217 .size = sizeof(max77665_muic),
219 .charger_platform_data = {
220 .pdata = &max77665_charger,
221 .size = sizeof(max77665_charger),
223 .flash_platform_data = {
224 .pdata = &pluto_max77665_flash_pdata,
225 .size = sizeof(pluto_max77665_flash_pdata),
227 .haptic_platform_data = {
228 .pdata = &max77665_haptic_pdata,
229 .size = sizeof(max77665_haptic_pdata),
233 static struct i2c_board_info pluto_i2c_board_info_max77665[] = {
235 I2C_BOARD_INFO("max77665", 0x66),
236 .platform_data = &pluto_max77665_pdata,
237 .irq = (TEGRA_SOC_OC_IRQ_BASE + TEGRA_SOC_OC_IRQ_4),
241 static struct power_supply_extcon_plat_data psy_extcon_pdata = {
242 .extcon_name = "tegra-udc",
245 static struct platform_device psy_extcon_device = {
246 .name = "power-supply-extcon",
249 .platform_data = &psy_extcon_pdata,
254 /* isl29029 support is provided by isl29028*/
255 static struct i2c_board_info pluto_i2c1_isl_board_info[] = {
257 I2C_BOARD_INFO("isl29028", 0x44),
261 static struct throttle_table tj_throttle_table[] = {
262 /* CPU_THROT_LOW cannot be used by other than CPU */
263 /* CPU, C2BUS, C3BUS, SCLK, EMC */
264 { { 1810500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
265 { { 1785000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
266 { { 1759500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
267 { { 1734000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
268 { { 1708500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
269 { { 1683000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
270 { { 1657500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
271 { { 1632000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
272 { { 1606500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
273 { { 1581000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
274 { { 1555500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
275 { { 1530000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
276 { { 1504500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
277 { { 1479000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
278 { { 1453500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
279 { { 1428000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
280 { { 1402500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
281 { { 1377000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
282 { { 1351500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
283 { { 1326000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
284 { { 1300500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
285 { { 1275000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
286 { { 1249500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
287 { { 1224000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
288 { { 1198500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
289 { { 1173000, 636000, NO_CAP, NO_CAP, NO_CAP } },
290 { { 1147500, 636000, NO_CAP, NO_CAP, NO_CAP } },
291 { { 1122000, 636000, NO_CAP, NO_CAP, NO_CAP } },
292 { { 1096500, 636000, NO_CAP, NO_CAP, NO_CAP } },
293 { { 1071000, 636000, NO_CAP, NO_CAP, NO_CAP } },
294 { { 1045500, 636000, NO_CAP, NO_CAP, NO_CAP } },
295 { { 1020000, 636000, NO_CAP, NO_CAP, NO_CAP } },
296 { { 994500, 636000, NO_CAP, NO_CAP, NO_CAP } },
297 { { 969000, 600000, NO_CAP, NO_CAP, NO_CAP } },
298 { { 943500, 600000, NO_CAP, NO_CAP, NO_CAP } },
299 { { 918000, 600000, NO_CAP, NO_CAP, NO_CAP } },
300 { { 892500, 600000, NO_CAP, NO_CAP, NO_CAP } },
301 { { 867000, 600000, NO_CAP, NO_CAP, NO_CAP } },
302 { { 841500, 564000, NO_CAP, NO_CAP, NO_CAP } },
303 { { 816000, 564000, NO_CAP, NO_CAP, 792000 } },
304 { { 790500, 564000, NO_CAP, 372000, 792000 } },
305 { { 765000, 564000, 468000, 372000, 792000 } },
306 { { 739500, 528000, 468000, 372000, 792000 } },
307 { { 714000, 528000, 468000, 336000, 792000 } },
308 { { 688500, 528000, 420000, 336000, 792000 } },
309 { { 663000, 492000, 420000, 336000, 792000 } },
310 { { 637500, 492000, 420000, 336000, 408000 } },
311 { { 612000, 492000, 420000, 300000, 408000 } },
312 { { 586500, 492000, 360000, 336000, 408000 } },
313 { { 561000, 420000, 420000, 300000, 408000 } },
314 { { 535500, 420000, 360000, 228000, 408000 } },
315 { { 510000, 420000, 288000, 228000, 408000 } },
316 { { 484500, 324000, 288000, 228000, 408000 } },
317 { { 459000, 324000, 288000, 228000, 408000 } },
318 { { 433500, 324000, 288000, 228000, 408000 } },
319 { { 408000, 324000, 288000, 228000, 408000 } },
322 static struct balanced_throttle tj_throttle = {
323 .throt_tab_size = ARRAY_SIZE(tj_throttle_table),
324 .throt_tab = tj_throttle_table,
327 static int __init pluto_throttle_init(void)
329 if (machine_is_tegra_pluto())
330 balanced_throttle_register(&tj_throttle, "tegra-balanced");
333 module_init(pluto_throttle_init);
335 static struct nct1008_platform_data pluto_nct1008_pdata = {
336 .supported_hwrev = true,
338 .conv_rate = 0x06, /* 4Hz conversion rate */
340 .shutdown_ext_limit = 105, /* C */
341 .shutdown_local_limit = 120, /* C */
346 .cdev_type = "suspend_soctherm",
348 .trip_type = THERMAL_TRIP_ACTIVE,
355 #ifdef CONFIG_TEGRA_LP1_LOW_COREVOLTAGE
356 .suspend_ext_limit_hi = 25000,
357 .suspend_ext_limit_lo = 20000,
358 .suspend_with_wakeup = tegra_is_lp1_suspend_mode,
362 static struct i2c_board_info pluto_i2c4_nct1008_board_info[] = {
364 I2C_BOARD_INFO("nct1008", 0x4C),
365 .platform_data = &pluto_nct1008_pdata,
371 #define VI_PINMUX(_pingroup, _mux, _pupd, _tri, _io, _lock, _ioreset) \
373 .pingroup = TEGRA_PINGROUP_##_pingroup, \
374 .func = TEGRA_MUX_##_mux, \
375 .pupd = TEGRA_PUPD_##_pupd, \
376 .tristate = TEGRA_TRI_##_tri, \
377 .io = TEGRA_PIN_##_io, \
378 .lock = TEGRA_PIN_LOCK_##_lock, \
379 .od = TEGRA_PIN_OD_DEFAULT, \
380 .ioreset = TEGRA_PIN_IO_RESET_##_ioreset \
383 static int pluto_focuser_power_on(struct ad5816_power_rail *pw)
387 if (unlikely(WARN_ON(!pw || !pw->vdd || !pw->vdd_i2c)))
390 err = regulator_enable(pw->vdd_i2c);
392 goto ad5816_vdd_i2c_fail;
394 err = regulator_enable(pw->vdd);
396 goto ad5816_vdd_fail;
401 regulator_disable(pw->vdd_i2c);
404 pr_err("%s FAILED\n", __func__);
409 static int pluto_focuser_power_off(struct ad5816_power_rail *pw)
411 if (unlikely(WARN_ON(!pw || !pw->vdd || !pw->vdd_i2c)))
414 regulator_disable(pw->vdd);
415 regulator_disable(pw->vdd_i2c);
420 static struct tegra_pingroup_config mclk_disable =
421 VI_PINMUX(CAM_MCLK, VI, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT);
423 static struct tegra_pingroup_config mclk_enable =
424 VI_PINMUX(CAM_MCLK, VI_ALT3, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT);
426 static struct tegra_pingroup_config pbb0_disable =
427 VI_PINMUX(GPIO_PBB0, VI, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT);
429 static struct tegra_pingroup_config pbb0_enable =
430 VI_PINMUX(GPIO_PBB0, VI_ALT3, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT);
433 * more regulators need to be allocated to activate the sensor devices.
434 * pluto_vcmvdd: this is a workaround due to the focuser device(AD5816) will
435 * hook up the i2c bus if it is not powered up.
436 * pluto_i2cvdd: by default, the power supply on the i2c bus is OFF. So it
437 * should be turned on every time any sensor device is activated.
439 static struct regulator *pluto_vcmvdd;
440 static struct regulator *pluto_i2cvdd;
442 static int pluto_get_extra_regulators(void)
445 pluto_vcmvdd = regulator_get(NULL, "vdd_af_cam1");
446 if (WARN_ON(IS_ERR(pluto_vcmvdd))) {
447 pr_err("%s: can't get regulator vdd_af_cam1: %ld\n",
448 __func__, PTR_ERR(pluto_vcmvdd));
455 pluto_i2cvdd = regulator_get(NULL, "vddio_cam_mb");
456 if (unlikely(WARN_ON(IS_ERR(pluto_i2cvdd)))) {
457 pr_err("%s: can't get regulator vddio_cam_mb: %ld\n",
458 __func__, PTR_ERR(pluto_i2cvdd));
467 static int pluto_imx091_power_on(struct nvc_regulator *vreg)
471 if (unlikely(WARN_ON(!vreg)))
474 if (pluto_get_extra_regulators())
475 goto imx091_poweron_fail;
477 gpio_set_value(CAM1_POWER_DWN_GPIO, 0);
478 usleep_range(10, 20);
480 err = regulator_enable(vreg[IMX091_VREG_AVDD].vreg);
482 goto imx091_avdd_fail;
484 err = regulator_enable(vreg[IMX091_VREG_DVDD].vreg);
486 goto imx091_dvdd_fail;
488 err = regulator_enable(vreg[IMX091_VREG_IOVDD].vreg);
490 goto imx091_iovdd_fail;
493 gpio_set_value(CAM1_POWER_DWN_GPIO, 1);
495 tegra_pinmux_config_table(&mclk_enable, 1);
496 err = regulator_enable(pluto_i2cvdd);
498 goto imx091_i2c_fail;
500 err = regulator_enable(pluto_vcmvdd);
502 goto imx091_vcm_fail;
503 usleep_range(300, 310);
508 regulator_disable(pluto_i2cvdd);
511 tegra_pinmux_config_table(&mclk_disable, 1);
512 gpio_set_value(CAM1_POWER_DWN_GPIO, 0);
513 regulator_disable(vreg[IMX091_VREG_IOVDD].vreg);
516 regulator_disable(vreg[IMX091_VREG_DVDD].vreg);
519 regulator_disable(vreg[IMX091_VREG_AVDD].vreg);
523 pr_err("%s FAILED\n", __func__);
527 static int pluto_imx091_power_off(struct nvc_regulator *vreg)
529 if (unlikely(WARN_ON(!vreg)))
533 tegra_pinmux_config_table(&mclk_disable, 1);
534 gpio_set_value(CAM1_POWER_DWN_GPIO, 0);
537 regulator_disable(vreg[IMX091_VREG_IOVDD].vreg);
538 regulator_disable(vreg[IMX091_VREG_DVDD].vreg);
539 regulator_disable(vreg[IMX091_VREG_AVDD].vreg);
541 regulator_disable(pluto_i2cvdd);
543 regulator_disable(pluto_vcmvdd);
548 static struct nvc_imager_cap imx091_cap = {
549 .identifier = "IMX091",
550 .sensor_nvc_interface = 3,
551 .pixel_types[0] = 0x100,
554 .initial_clock_rate_khz = 6000,
555 .clock_profiles[0] = {
556 .external_clock_khz = 24000,
557 .clock_multiplier = 850000, /* value / 1,000,000 */
559 .clock_profiles[1] = {
560 .external_clock_khz = 0,
561 .clock_multiplier = 0,
568 .virtual_channel_id = 0,
569 .discontinuous_clk_mode = 1,
570 .cil_threshold_settle = 0x0,
571 .min_blank_time_width = 16,
572 .min_blank_time_height = 16,
573 .preferred_mode_index = 0,
574 .focuser_guid = NVC_FOCUS_GUID(0),
575 .torch_guid = NVC_TORCH_GUID(0),
576 .cap_version = NVC_IMAGER_CAPABILITIES_VERSION2,
579 static unsigned imx091_estates[] = { 876, 656, 220, 0 };
581 static struct imx091_platform_data imx091_pdata = {
584 .dev_name = "camera",
585 .gpio_count = ARRAY_SIZE(imx091_gpio_pdata),
586 .gpio = imx091_gpio_pdata,
588 .sdo_trigger_enabled = 1,
589 .adjustable_flash_timing = 1,
593 .states = imx091_estates,
594 .num_states = ARRAY_SIZE(imx091_estates),
595 .e0_index = ARRAY_SIZE(imx091_estates) - 1,
596 .priority = EDP_MAX_PRIO + 1,
598 .power_on = pluto_imx091_power_on,
599 .power_off = pluto_imx091_power_off,
602 static int pluto_imx132_power_on(struct imx132_power_rail *pw)
606 if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd || !pw->dvdd)))
609 if (pluto_get_extra_regulators())
610 goto pluto_imx132_poweron_fail;
612 gpio_set_value(CAM2_POWER_DWN_GPIO, 0);
614 tegra_pinmux_config_table(&pbb0_enable, 1);
616 err = regulator_enable(pluto_i2cvdd);
618 goto imx132_i2c_fail;
620 err = regulator_enable(pluto_vcmvdd);
622 goto imx132_vcm_fail;
624 err = regulator_enable(pw->avdd);
626 goto imx132_avdd_fail;
628 err = regulator_enable(pw->dvdd);
630 goto imx132_dvdd_fail;
632 err = regulator_enable(pw->iovdd);
634 goto imx132_iovdd_fail;
638 gpio_set_value(CAM2_POWER_DWN_GPIO, 1);
643 regulator_disable(pw->dvdd);
646 regulator_disable(pw->avdd);
649 regulator_disable(pluto_vcmvdd);
652 regulator_disable(pluto_i2cvdd);
655 tegra_pinmux_config_table(&pbb0_disable, 1);
657 pluto_imx132_poweron_fail:
658 pr_err("%s failed.\n", __func__);
662 static int pluto_imx132_power_off(struct imx132_power_rail *pw)
664 if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd || !pw->dvdd ||
665 !pluto_i2cvdd || !pluto_vcmvdd)))
668 gpio_set_value(CAM2_POWER_DWN_GPIO, 0);
672 regulator_disable(pw->iovdd);
673 regulator_disable(pw->dvdd);
674 regulator_disable(pw->avdd);
676 tegra_pinmux_config_table(&pbb0_disable, 1);
678 regulator_disable(pluto_vcmvdd);
679 regulator_disable(pluto_i2cvdd);
684 struct imx132_platform_data imx132_pdata = {
685 .power_on = pluto_imx132_power_on,
686 .power_off = pluto_imx132_power_off,
689 static struct ad5816_platform_data pluto_ad5816_pdata = {
693 .dev_name = "focuser",
694 .power_on = pluto_focuser_power_on,
695 .power_off = pluto_focuser_power_off,
698 static struct i2c_board_info pluto_i2c_board_info_e1625[] = {
700 I2C_BOARD_INFO("imx091", 0x10),
701 .platform_data = &imx091_pdata,
704 I2C_BOARD_INFO("imx132", 0x36),
705 .platform_data = &imx132_pdata,
708 I2C_BOARD_INFO("ad5816", 0x0E),
709 .platform_data = &pluto_ad5816_pdata,
713 static int pluto_camera_init(void)
715 pr_debug("%s: ++\n", __func__);
717 tegra_pinmux_config_table(&mclk_disable, 1);
718 tegra_pinmux_config_table(&pbb0_disable, 1);
719 i2c_register_board_info(2, pluto_i2c_board_info_e1625,
720 ARRAY_SIZE(pluto_i2c_board_info_e1625));
726 /* MPU board file definition */
727 static struct mpu_platform_data mpu_gyro_data = {
730 .orientation = MPU_GYRO_ORIENTATION,
731 .sec_slave_type = SECONDARY_SLAVE_TYPE_NONE,
732 .key = {0x4E, 0xCC, 0x7E, 0xEB, 0xF6, 0x1E, 0x35, 0x22,
733 0x00, 0x34, 0x0D, 0x65, 0x32, 0xE9, 0x94, 0x89},
736 static struct mpu_platform_data mpu_compass_data = {
737 .orientation = MPU_COMPASS_ORIENTATION,
738 .config = NVI_CONFIG_BOOT_MPU,
741 static struct mpu_platform_data bmp180_pdata = {
742 .config = NVI_CONFIG_BOOT_MPU,
745 static struct i2c_board_info __initdata inv_mpu_i2c0_board_info[] = {
747 I2C_BOARD_INFO(MPU_GYRO_NAME, MPU_GYRO_ADDR),
748 .platform_data = &mpu_gyro_data,
751 /* The actual BMP180 address is 0x77 but because this conflicts
752 * with another device, this address is hacked so Linux will
753 * call the driver. The conflict is technically okay since the
754 * BMP180 is behind the MPU. Also, the BMP180 driver uses a
755 * hard-coded address of 0x77 since it can't be changed anyway.
757 I2C_BOARD_INFO("bmp180", 0x78),
758 .platform_data = &bmp180_pdata,
761 I2C_BOARD_INFO(MPU_COMPASS_NAME, MPU_COMPASS_ADDR),
762 .platform_data = &mpu_compass_data,
766 static void mpuirq_init(void)
771 pr_info("*** MPU START *** mpuirq_init...\n");
773 /* MPU-IRQ assignment */
774 ret = gpio_request(MPU_GYRO_IRQ_GPIO, MPU_GYRO_NAME);
776 pr_err("%s: gpio_request failed %d\n", __func__, ret);
780 ret = gpio_direction_input(MPU_GYRO_IRQ_GPIO);
782 pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
783 gpio_free(MPU_GYRO_IRQ_GPIO);
786 pr_info("*** MPU END *** mpuirq_init...\n");
788 inv_mpu_i2c0_board_info[i++].irq = gpio_to_irq(MPU_GYRO_IRQ_GPIO);
789 #if MPU_COMPASS_IRQ_GPIO
790 inv_mpu_i2c0_board_info[i++].irq = gpio_to_irq(MPU_COMPASS_IRQ_GPIO);
792 i2c_register_board_info(MPU_GYRO_BUS_NUM, inv_mpu_i2c0_board_info,
793 ARRAY_SIZE(inv_mpu_i2c0_board_info));
796 static int pluto_nct1008_init(void)
801 if (board_info.board_id == BOARD_E1580 ||
802 board_info.board_id == BOARD_E1575 ||
803 board_info.board_id == BOARD_E1577) {
804 nct1008_port = TEGRA_GPIO_PX6;
806 nct1008_port = TEGRA_GPIO_PX6;
807 pr_err("Warning: nct alert port assumed TEGRA_GPIO_PX6 for unknown pluto board id E%d\n",
808 board_info.board_id);
811 tegra_add_cdev_trips(pluto_nct1008_pdata.trips,
812 &pluto_nct1008_pdata.num_trips);
814 pluto_i2c4_nct1008_board_info[0].irq =
815 gpio_to_irq(nct1008_port);
816 pr_info("%s: pluto nct1008 irq %d",
817 __func__, pluto_i2c4_nct1008_board_info[0].irq);
819 ret = gpio_request(nct1008_port, "temp_alert");
823 ret = gpio_direction_input(nct1008_port);
825 pr_info("%s: calling gpio_free(nct1008_port)", __func__);
826 gpio_free(nct1008_port);
829 /* pluto has thermal sensor on GEN1-I2C i.e. instance 0 */
830 i2c_register_board_info(0, pluto_i2c4_nct1008_board_info,
831 ARRAY_SIZE(pluto_i2c4_nct1008_board_info));
836 #ifdef CONFIG_TEGRA_SKIN_THROTTLE
837 static struct thermal_trip_info skin_trips[] = {
839 .cdev_type = "skin-balanced",
841 .trip_type = THERMAL_TRIP_PASSIVE,
842 .upper = THERMAL_NO_LIMIT,
843 .lower = THERMAL_NO_LIMIT,
847 .cdev_type = "tegra-shutdown",
849 .trip_type = THERMAL_TRIP_CRITICAL,
850 .upper = THERMAL_NO_LIMIT,
851 .lower = THERMAL_NO_LIMIT,
856 static struct therm_est_subdevice skin_devs[] = {
858 .dev_data = "Tdiode",
868 .dev_data = "Tboard",
879 static struct pid_thermal_gov_params skin_pid_params = {
880 .max_err_temp = 4000,
881 .max_err_gain = 1000,
886 .up_compensation = 15,
887 .down_compensation = 15,
890 static struct thermal_zone_params skin_tzp = {
891 .governor_name = "pid_thermal_gov",
892 .governor_params = &skin_pid_params,
895 static struct therm_est_data skin_data = {
896 .num_trips = ARRAY_SIZE(skin_trips),
899 .polling_period = 1100,
900 .passive_delay = 15000,
903 .ndevs = ARRAY_SIZE(skin_devs),
908 static struct throttle_table skin_throttle_table[] = {
909 /* CPU_THROT_LOW cannot be used by other than CPU */
910 /* CPU, C2BUS, C3BUS, SCLK, EMC */
911 { { 1810500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
912 { { 1785000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
913 { { 1759500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
914 { { 1734000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
915 { { 1708500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
916 { { 1683000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
917 { { 1657500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
918 { { 1632000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
919 { { 1606500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
920 { { 1581000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
921 { { 1555500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
922 { { 1530000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
923 { { 1504500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
924 { { 1479000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
925 { { 1453500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
926 { { 1428000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
927 { { 1402500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
928 { { 1377000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
929 { { 1351500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
930 { { 1326000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
931 { { 1300500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
932 { { 1275000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
933 { { 1249500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
934 { { 1224000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
935 { { 1198500, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
936 { { 1173000, 636000, NO_CAP, NO_CAP, NO_CAP } },
937 { { 1147500, 636000, NO_CAP, NO_CAP, NO_CAP } },
938 { { 1122000, 636000, NO_CAP, NO_CAP, NO_CAP } },
939 { { 1096500, 636000, NO_CAP, NO_CAP, NO_CAP } },
940 { { 1071000, 636000, NO_CAP, NO_CAP, NO_CAP } },
941 { { 1045500, 636000, NO_CAP, NO_CAP, NO_CAP } },
942 { { 1020000, 636000, NO_CAP, NO_CAP, NO_CAP } },
943 { { 994500, 636000, NO_CAP, NO_CAP, NO_CAP } },
944 { { 969000, 600000, NO_CAP, NO_CAP, NO_CAP } },
945 { { 943500, 600000, NO_CAP, NO_CAP, NO_CAP } },
946 { { 918000, 600000, NO_CAP, NO_CAP, NO_CAP } },
947 { { 892500, 600000, NO_CAP, NO_CAP, NO_CAP } },
948 { { 867000, 600000, NO_CAP, NO_CAP, NO_CAP } },
949 { { 841500, 564000, NO_CAP, NO_CAP, NO_CAP } },
950 { { 816000, 564000, NO_CAP, NO_CAP, 792000 } },
951 { { 790500, 564000, NO_CAP, 372000, 792000 } },
952 { { 765000, 564000, 468000, 372000, 792000 } },
953 { { 739500, 528000, 468000, 372000, 792000 } },
954 { { 714000, 528000, 468000, 336000, 792000 } },
955 { { 688500, 528000, 420000, 336000, 792000 } },
956 { { 663000, 492000, 420000, 336000, 792000 } },
957 { { 637500, 492000, 420000, 336000, 408000 } },
958 { { 612000, 492000, 420000, 300000, 408000 } },
959 { { 586500, 492000, 360000, 336000, 408000 } },
960 { { 561000, 420000, 420000, 300000, 408000 } },
961 { { 535500, 420000, 360000, 228000, 408000 } },
962 { { 510000, 420000, 288000, 228000, 408000 } },
963 { { 484500, 324000, 288000, 228000, 408000 } },
964 { { 459000, 324000, 288000, 228000, 408000 } },
965 { { 433500, 324000, 288000, 228000, 408000 } },
966 { { 408000, 324000, 288000, 228000, 408000 } },
969 static struct balanced_throttle skin_throttle = {
970 .throt_tab_size = ARRAY_SIZE(skin_throttle_table),
971 .throt_tab = skin_throttle_table,
974 static int __init pluto_skin_init(void)
976 if (machine_is_tegra_pluto()) {
977 balanced_throttle_register(&skin_throttle, "skin-balanced");
978 tegra_skin_therm_est_device.dev.platform_data = &skin_data;
979 platform_device_register(&tegra_skin_therm_est_device);
984 late_initcall(pluto_skin_init);
987 void __init max77665_init(void)
991 /* For battery presence into charger driver */
992 if (get_power_supply_type() == POWER_SUPPLY_TYPE_BATTERY)
993 max77665_charger.is_battery_present = true;
995 err = i2c_register_board_info(4, pluto_i2c_board_info_max77665,
996 ARRAY_SIZE(pluto_i2c_board_info_max77665));
998 pr_err("%s: max77665 device register failed.\n", __func__);
1000 platform_device_register(&psy_extcon_device);
1005 int __init pluto_sensors_init(void)
1009 tegra_get_board_info(&board_info);
1011 pr_debug("%s: ++\n", __func__);
1014 pluto_camera_init();
1016 err = pluto_nct1008_init();
1020 err = i2c_register_board_info(0, pluto_i2c1_isl_board_info,
1021 ARRAY_SIZE(pluto_i2c1_isl_board_info));
1023 pr_err("%s: isl board register failed.\n", __func__);
1028 if (get_power_supply_type() == POWER_SUPPLY_TYPE_BATTERY)
1029 max17042_pdata.is_battery_present = true;
1031 err = i2c_register_board_info(0, max17042_device,
1032 ARRAY_SIZE(max17042_device));
1034 pr_err("%s: max17042 device register failed.\n", __func__);