arm: tegra: Added MAX77665 vibrator EDP data
[linux-3.10.git] / arch / arm / mach-tegra / board-pluto-sensors.c
1 /*
2  * arch/arm/mach-tegra/board-pluto-sensors.c
3  *
4  * Copyright (c) 2012, 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 #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/nct1008.h>
28 #include <mach/edp.h>
29 #include <mach/gpio-tegra.h>
30 #include <mach/pinmux-t11.h>
31 #include <mach/pinmux.h>
32 #include <media/max77665-flash.h>
33 #include <media/imx091.h>
34 #include <media/imx132.h>
35 #include <media/ad5816.h>
36
37 #include "gpio-names.h"
38 #include "board.h"
39 #include "board-pluto.h"
40 #include "cpu-tegra.h"
41 #include "devices.h"
42 #include "tegra-board-id.h"
43
44 #define NTC_10K_TGAIN   0xE6A2
45 #define NTC_10K_TOFF    0x2694
46
47 static struct board_info board_info;
48 static struct max17042_config_data conf_data = {
49         .valrt_thresh = 0xff00,
50         .talrt_thresh = 0xff00,
51         .soc_alrt_thresh = 0xff00,
52         .shdntimer = 0xe000,
53         .design_cap = 0x07d0,
54         .at_rate = 0x0000,
55         .tgain = NTC_10K_TGAIN,
56         .toff = NTC_10K_TOFF,
57         .vempty = 0xACDA,
58         .qrtbl00 = 0x5C80,
59         .qrtbl10 = 0x438C,
60         .qrtbl20 = 0x1198,
61         .qrtbl30 = 0x0E19,
62         .full_soc_thresh = 0x5A00,
63         .rcomp0 = 0x0077,
64         .tcompc0 = 0x1F2A,
65         .ichgt_term = 0x0320,
66         .temp_nom = 0x1400,
67         .temp_lim = 0x2305,
68         .filter_cfg = 0x87A4,
69         .config = 0x2210,
70         .learn_cfg = 0x2606,
71         .misc_cfg = 0x0810,
72         .fullcap =  0x07d0,
73         .fullcapnom = 0x07d0,
74         .lavg_empty = 0x1000,
75         .dqacc = 0x01f4,
76         .dpacc = 0x3200,
77         .fctc = 0x05e0,
78         .kempty0 = 0x0600,
79         .cell_technology = POWER_SUPPLY_TECHNOLOGY_LION,
80         .cell_char_tbl = {
81                 /* Data to be written from 0x80h */
82                 0x9180, 0xA4C0, 0xB6A0, 0xB760, 0xB980, 0xBB30,
83                 0xBBC0, 0xBC50, 0xBD50, 0xBE50, 0xBF80, 0xC290,
84                 0xC470, 0xC7D0, 0xCC40, 0xCFB0,
85                 /* Data to be written from 0x90h */
86                 0x00C0, 0x0200, 0x1C10, 0x0B00, 0x0900, 0x1F00,
87                 0x1F00, 0x23C0, 0x1990, 0x19F0, 0x09A0, 0x0CE0,
88                 0x0BE0, 0x07D0, 0x0990, 0x0990,
89                 /* Data to be written from 0xA0h */
90                 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
91                 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
92                 0x0100, 0x0100, 0x0100, 0x0100,
93         },
94 };
95
96 static struct max17042_platform_data max17042_pdata = {
97         .config_data = &conf_data,
98         .init_data  = NULL,
99         .num_init_data = 0,
100         .enable_por_init = 1, /* Use POR init from Maxim appnote */
101         .enable_current_sense = 1,
102         .r_sns = 0,
103 };
104
105 static struct i2c_board_info max17042_device[] = {
106         {
107                 I2C_BOARD_INFO("max17042", 0x36),
108                 .platform_data = &max17042_pdata,
109         },
110 };
111
112 static struct max77665_f_platform_data pluto_max77665_flash_pdata = {
113         .config         = {
114                 .led_mask               = 3,
115                 .flash_on_torch         = true,
116                 .max_total_current_mA   = 1000,
117                 .max_peak_current_mA    = 600,
118                 },
119         .pinstate       = {
120                 .mask   = 1 << (CAM_FLASH_STROBE - TEGRA_GPIO_PBB0),
121                 .values = 1 << (CAM_FLASH_STROBE - TEGRA_GPIO_PBB0),
122                 },
123         .dev_name       = "torch",
124         .gpio_strobe    = CAM_FLASH_STROBE,
125 };
126
127 static struct max77665_haptic_platform_data max77665_haptic_pdata = {
128         .pwm_channel_id = 2,
129         .pwm_period = 50,
130         .type = MAX77665_HAPTIC_LRA,
131         .mode = MAX77665_INTERNAL_MODE,
132         .internal_mode_pattern = 0,
133         .pattern_cycle = 10,
134         .pattern_signal_period = 0xD0,
135         .pwm_divisor = MAX77665_PWM_DIVISOR_128,
136         .feedback_duty_cycle = 12,
137         .invert = MAX77665_INVERT_OFF,
138         .cont_mode = MAX77665_CONT_MODE,
139         .motor_startup_val = 0,
140         .scf_val = 2,
141         .edp_states = {90, 0},
142 };
143
144 static struct max77665_charger_cable maxim_cable[] = {
145         {
146                 .name           = "USB",
147         },
148         {
149                 .name           = "USB-Host",
150         },
151         {
152                 .name           = "TA",
153         },
154         {
155                 .name           = "Fast-charger",
156         },
157         {
158                 .name           = "Slow-charger",
159         },
160         {
161                 .name           = "Charge-downstream",
162         },
163 };
164
165 static struct max77665_charger_plat_data max77665_charger = {
166         .fast_chg_cc = 1500, /* fast charger current*/
167         .term_volt = 3700, /* charger termination voltage */
168         .curr_lim = 1500, /* input current limit */
169         .num_cables = MAX_CABLES,
170         .cables = maxim_cable,
171 };
172
173 static struct max77665_muic_platform_data max77665_muic = {
174         .irq_base = 0,
175 };
176
177 static struct max77665_platform_data pluto_max77665_pdata = {
178         .irq_base = 0,
179         .muic_platform_data = {
180                 .pdata = &max77665_muic,
181                 .size = sizeof(max77665_muic),
182                 },
183         .charger_platform_data = {
184                 .pdata = &max77665_charger,
185                 .size = sizeof(max77665_charger),
186                 },
187         .flash_platform_data = {
188                 .pdata = &pluto_max77665_flash_pdata,
189                 .size = sizeof(pluto_max77665_flash_pdata),
190                 },
191         .haptic_platform_data = {
192                 .pdata = &max77665_haptic_pdata,
193                 .size = sizeof(max77665_haptic_pdata),
194                 },
195 };
196
197 static const struct i2c_board_info pluto_i2c_board_info_max77665[] = {
198         {
199                 I2C_BOARD_INFO("max77665", 0x66),
200                 .platform_data = &pluto_max77665_pdata,
201         },
202 };
203
204 /* isl29029 support is provided by isl29028*/
205 static struct i2c_board_info pluto_i2c1_isl_board_info[] = {
206         {
207                 I2C_BOARD_INFO("isl29028", 0x44),
208         }
209 };
210
211 static struct balanced_throttle tj_throttle = {
212         .throt_tab_size = 10,
213         .throt_tab = {
214                 {      0, 1000 },
215                 { 640000, 1000 },
216                 { 640000, 1000 },
217                 { 640000, 1000 },
218                 { 640000, 1000 },
219                 { 640000, 1000 },
220                 { 760000, 1000 },
221                 { 760000, 1050 },
222                 {1000000, 1050 },
223                 {1000000, 1100 },
224         },
225 };
226
227 static struct nct1008_platform_data pluto_nct1008_pdata = {
228         .supported_hwrev = true,
229         .ext_range = true,
230         .conv_rate = 0x08,
231         .offset = 80, /* 4 * 20C. Bug 844025 - 1C for device accuracies */
232         .shutdown_ext_limit = 90, /* C */
233         .shutdown_local_limit = 120, /* C */
234
235         /* Thermal Throttling */
236         .passive = {
237                 .create_cdev = (struct thermal_cooling_device *(*)(void *))
238                                 balanced_throttle_register,
239                 .cdev_data = &tj_throttle,
240                 .trip_temp = 80000,
241                 .tc1 = 0,
242                 .tc2 = 1,
243                 .passive_delay = 2000,
244         }
245 };
246
247 static struct i2c_board_info pluto_i2c4_nct1008_board_info[] = {
248         {
249                 I2C_BOARD_INFO("nct1008", 0x4C),
250                 .platform_data = &pluto_nct1008_pdata,
251                 .irq = -1,
252         }
253 };
254
255 #define VI_PINMUX(_pingroup, _mux, _pupd, _tri, _io, _lock, _ioreset) \
256         {                                                       \
257                 .pingroup       = TEGRA_PINGROUP_##_pingroup,   \
258                 .func           = TEGRA_MUX_##_mux,             \
259                 .pupd           = TEGRA_PUPD_##_pupd,           \
260                 .tristate       = TEGRA_TRI_##_tri,             \
261                 .io             = TEGRA_PIN_##_io,              \
262                 .lock           = TEGRA_PIN_LOCK_##_lock,       \
263                 .od             = TEGRA_PIN_OD_DEFAULT,         \
264                 .ioreset        = TEGRA_PIN_IO_RESET_##_ioreset \
265         }
266
267 static struct tegra_pingroup_config mclk_disable =
268         VI_PINMUX(CAM_MCLK, VI, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT);
269
270 static struct tegra_pingroup_config mclk_enable =
271         VI_PINMUX(CAM_MCLK, VI_ALT3, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT);
272
273 static struct tegra_pingroup_config pbb0_disable =
274         VI_PINMUX(GPIO_PBB0, VI, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT);
275
276 static struct tegra_pingroup_config pbb0_enable =
277         VI_PINMUX(GPIO_PBB0, VI_ALT3, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT);
278
279 /*
280  * more regulators need to be allocated to activate the sensor devices.
281  * pluto_vcmvdd: this is a workaround due to the focuser device(AD5816) will
282  *               hook up the i2c bus if it is not powered up.
283  * pluto_i2cvdd: by default, the power supply on the i2c bus is OFF. So it
284  *               should be turned on every time any sensor device is activated.
285 */
286 static struct regulator *pluto_vcmvdd;
287 static struct regulator *pluto_i2cvdd;
288
289 static int pluto_get_extra_regulators(void)
290 {
291         if (!pluto_vcmvdd) {
292                 pluto_vcmvdd = regulator_get(NULL, "vdd_af_cam1");
293                 if (WARN_ON(IS_ERR(pluto_vcmvdd))) {
294                         pr_err("%s: can't get regulator vdd_af_cam1: %ld\n",
295                                 __func__, PTR_ERR(pluto_vcmvdd));
296                         pluto_vcmvdd = NULL;
297                         return -ENODEV;
298                 }
299         }
300
301         if (!pluto_i2cvdd) {
302                 pluto_i2cvdd = regulator_get(NULL, "vddio_cam_mb");
303                 if (unlikely(WARN_ON(IS_ERR(pluto_i2cvdd)))) {
304                         pr_err("%s: can't get regulator vddio_cam_mb: %ld\n",
305                                 __func__, PTR_ERR(pluto_i2cvdd));
306                         pluto_i2cvdd = NULL;
307                         return -ENODEV;
308                 }
309         }
310
311         return 0;
312 }
313
314 static int pluto_imx091_power_on(struct imx091_power_rail *pw)
315 {
316         int err;
317
318         if (unlikely(WARN_ON(!pw || !pw->dvdd || !pw->iovdd || !pw->avdd)))
319                 return -EFAULT;
320
321         if (pluto_get_extra_regulators())
322                 goto imx091_poweron_fail;
323
324         gpio_set_value(CAM1_POWER_DWN_GPIO, 0);
325         usleep_range(10, 20);
326
327         err = regulator_enable(pw->avdd);
328         if (unlikely(err))
329                 goto imx091_avdd_fail;
330
331         err = regulator_enable(pw->dvdd);
332         if (unlikely(err))
333                 goto imx091_dvdd_fail;
334
335         err = regulator_enable(pw->iovdd);
336         if (unlikely(err))
337                 goto imx091_iovdd_fail;
338
339         usleep_range(1, 2);
340         gpio_set_value(CAM1_POWER_DWN_GPIO, 1);
341
342         tegra_pinmux_config_table(&mclk_enable, 1);
343         err = regulator_enable(pluto_i2cvdd);
344         if (unlikely(err))
345                 goto imx091_i2c_fail;
346
347         err = regulator_enable(pluto_vcmvdd);
348         if (unlikely(err))
349                 goto imx091_vcm_fail;
350         usleep_range(300, 310);
351
352         return 0;
353
354 imx091_vcm_fail:
355         regulator_disable(pluto_i2cvdd);
356
357 imx091_i2c_fail:
358         tegra_pinmux_config_table(&mclk_disable, 1);
359         gpio_set_value(CAM1_POWER_DWN_GPIO, 0);
360         regulator_disable(pw->iovdd);
361
362 imx091_iovdd_fail:
363         regulator_disable(pw->dvdd);
364
365 imx091_dvdd_fail:
366         regulator_disable(pw->avdd);
367
368 imx091_avdd_fail:
369 imx091_poweron_fail:
370         pr_err("%s FAILED\n", __func__);
371         return -ENODEV;
372 }
373
374 static int pluto_imx091_power_off(struct imx091_power_rail *pw)
375 {
376         if (unlikely(WARN_ON(!pw || !pluto_i2cvdd || !pluto_vcmvdd ||
377                         !pw->dvdd || !pw->iovdd || !pw->avdd)))
378                 return -EFAULT;
379
380         usleep_range(1, 2);
381         tegra_pinmux_config_table(&mclk_disable, 1);
382         gpio_set_value(CAM1_POWER_DWN_GPIO, 0);
383         usleep_range(1, 2);
384
385         regulator_disable(pw->iovdd);
386         regulator_disable(pw->dvdd);
387         regulator_disable(pw->avdd);
388         regulator_disable(pluto_i2cvdd);
389         regulator_disable(pluto_vcmvdd);
390
391         return 0;
392 }
393
394 struct imx091_platform_data pluto_imx091_data = {
395         .power_on = pluto_imx091_power_on,
396         .power_off = pluto_imx091_power_off,
397 };
398
399 static int pluto_imx132_power_on(struct imx132_power_rail *pw)
400 {
401         int err;
402
403         if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd || !pw->dvdd)))
404                 return -EFAULT;
405
406         if (pluto_get_extra_regulators())
407                 goto pluto_imx132_poweron_fail;
408
409         gpio_set_value(CAM2_POWER_DWN_GPIO, 0);
410
411         tegra_pinmux_config_table(&pbb0_enable, 1);
412
413         err = regulator_enable(pluto_i2cvdd);
414         if (unlikely(err))
415                 goto imx132_i2c_fail;
416
417         err = regulator_enable(pluto_vcmvdd);
418         if (unlikely(err))
419                 goto imx132_vcm_fail;
420
421         err = regulator_enable(pw->avdd);
422         if (unlikely(err))
423                 goto imx132_avdd_fail;
424
425         err = regulator_enable(pw->dvdd);
426         if (unlikely(err))
427                 goto imx132_dvdd_fail;
428
429         err = regulator_enable(pw->iovdd);
430         if (unlikely(err))
431                 goto imx132_iovdd_fail;
432
433         usleep_range(1, 2);
434
435         gpio_set_value(CAM2_POWER_DWN_GPIO, 1);
436
437         return 0;
438
439 imx132_iovdd_fail:
440         regulator_disable(pw->dvdd);
441
442 imx132_dvdd_fail:
443         regulator_disable(pw->avdd);
444
445 imx132_avdd_fail:
446         regulator_disable(pluto_vcmvdd);
447
448 imx132_vcm_fail:
449         regulator_disable(pluto_i2cvdd);
450
451 imx132_i2c_fail:
452         tegra_pinmux_config_table(&pbb0_disable, 1);
453
454 pluto_imx132_poweron_fail:
455         pr_err("%s failed.\n", __func__);
456         return -ENODEV;
457 }
458
459 static int pluto_imx132_power_off(struct imx132_power_rail *pw)
460 {
461         if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd || !pw->dvdd ||
462                         !pluto_i2cvdd || !pluto_vcmvdd)))
463                 return -EFAULT;
464
465         gpio_set_value(CAM2_POWER_DWN_GPIO, 0);
466
467         usleep_range(1, 2);
468
469         regulator_disable(pw->iovdd);
470         regulator_disable(pw->dvdd);
471         regulator_disable(pw->avdd);
472
473         tegra_pinmux_config_table(&pbb0_disable, 1);
474
475         regulator_disable(pluto_vcmvdd);
476         regulator_disable(pluto_i2cvdd);
477
478         return 0;
479 }
480
481 struct imx132_platform_data pluto_imx132_data = {
482         .power_on = pluto_imx132_power_on,
483         .power_off = pluto_imx132_power_off,
484 };
485
486 static struct ad5816_platform_data pluto_ad5816_pdata = {
487         .cfg            = 0,
488         .num            = 0,
489         .sync           = 0,
490         .dev_name       = "focuser",
491 };
492
493 static struct i2c_board_info pluto_i2c_board_info_e1625[] = {
494         {
495                 I2C_BOARD_INFO("imx091", 0x10),
496                 .platform_data = &pluto_imx091_data,
497         },
498         {
499                 I2C_BOARD_INFO("imx132", 0x36),
500                 .platform_data = &pluto_imx132_data,
501         },
502         {
503                 I2C_BOARD_INFO("ad5816", 0x0E),
504                 .platform_data = &pluto_ad5816_pdata,
505         },
506 };
507
508 static int pluto_camera_init(void)
509 {
510         pr_debug("%s: ++\n", __func__);
511
512         tegra_pinmux_config_table(&mclk_disable, 1);
513         tegra_pinmux_config_table(&pbb0_disable, 1);
514
515         i2c_register_board_info(2, pluto_i2c_board_info_e1625,
516                 ARRAY_SIZE(pluto_i2c_board_info_e1625));
517
518         return 0;
519 }
520
521 /* MPU board file definition */
522 static struct mpu_platform_data mpu_gyro_data = {
523         .int_config     = 0x10,
524         .level_shifter  = 0,
525         .orientation    = MPU_GYRO_ORIENTATION,
526         .sec_slave_type = SECONDARY_SLAVE_TYPE_NONE,
527         .key            = {0x4E, 0xCC, 0x7E, 0xEB, 0xF6, 0x1E, 0x35, 0x22,
528                            0x00, 0x34, 0x0D, 0x65, 0x32, 0xE9, 0x94, 0x89},
529 };
530
531 static struct mpu_platform_data mpu_compass_data = {
532         .orientation    = MPU_COMPASS_ORIENTATION,
533         .sec_slave_type = SECONDARY_SLAVE_TYPE_NONE,
534 };
535
536 static struct i2c_board_info __initdata inv_mpu_i2c0_board_info[] = {
537         {
538                 I2C_BOARD_INFO(MPU_GYRO_NAME, MPU_GYRO_ADDR),
539                 .platform_data = &mpu_gyro_data,
540         },
541         {
542                 I2C_BOARD_INFO(MPU_COMPASS_NAME, MPU_COMPASS_ADDR),
543                 .platform_data = &mpu_compass_data,
544         },
545 };
546
547 static void mpuirq_init(void)
548 {
549         int ret = 0;
550         int i = 0;
551
552         pr_info("*** MPU START *** mpuirq_init...\n");
553
554         /* MPU-IRQ assignment */
555         ret = gpio_request(MPU_GYRO_IRQ_GPIO, MPU_GYRO_NAME);
556         if (ret < 0) {
557                 pr_err("%s: gpio_request failed %d\n", __func__, ret);
558                 return;
559         }
560
561         ret = gpio_direction_input(MPU_GYRO_IRQ_GPIO);
562         if (ret < 0) {
563                 pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
564                 gpio_free(MPU_GYRO_IRQ_GPIO);
565                 return;
566         }
567         pr_info("*** MPU END *** mpuirq_init...\n");
568
569         inv_mpu_i2c0_board_info[i++].irq = gpio_to_irq(MPU_GYRO_IRQ_GPIO);
570 #if MPU_COMPASS_IRQ_GPIO
571         inv_mpu_i2c0_board_info[i++].irq = gpio_to_irq(MPU_COMPASS_IRQ_GPIO);
572 #endif
573         i2c_register_board_info(MPU_GYRO_BUS_NUM, inv_mpu_i2c0_board_info,
574                 ARRAY_SIZE(inv_mpu_i2c0_board_info));
575 }
576
577 static int pluto_nct1008_init(void)
578 {
579         int nct1008_port = -1;
580         int ret = 0;
581
582 #if defined(CONFIG_ARCH_TEGRA_11x_SOC)
583         if (board_info.board_id == BOARD_E1580 ||
584             board_info.board_id == BOARD_E1575) {
585                 nct1008_port = TEGRA_GPIO_PX6;
586         } else {
587                 nct1008_port = TEGRA_GPIO_PX6;
588                 pr_err("Warning: nct alert port assumed TEGRA_GPIO_PX6 for unknown pluto board id E%d\n",
589                        board_info.board_id);
590         }
591 #else
592         /* pluto + AP30 interposer has SPI2_CS0 gpio */
593         nct1008_port = TEGRA_GPIO_PX3;
594 #endif
595
596         if (nct1008_port >= 0) {
597 #ifdef CONFIG_TEGRA_EDP_LIMITS
598                 const struct tegra_edp_limits *cpu_edp_limits;
599                 int cpu_edp_limits_size;
600                 int i;
601
602                 /* edp capping */
603                 tegra_get_cpu_edp_limits(&cpu_edp_limits, &cpu_edp_limits_size);
604
605                 if (cpu_edp_limits_size > MAX_THROT_TABLE_SIZE)
606                         BUG();
607
608                 for (i = 0; i < cpu_edp_limits_size-1; i++) {
609                         pluto_nct1008_pdata.active[i].create_cdev =
610                                 (struct thermal_cooling_device *(*)(void *))
611                                         edp_cooling_device_create;
612                         pluto_nct1008_pdata.active[i].cdev_data = (void *)i;
613                         pluto_nct1008_pdata.active[i].trip_temp =
614                                 cpu_edp_limits[i].temperature * 1000;
615                         pluto_nct1008_pdata.active[i].hysteresis = 1000;
616                 }
617                 pluto_nct1008_pdata.active[i].create_cdev = NULL;
618 #endif
619
620                 pluto_i2c4_nct1008_board_info[0].irq = gpio_to_irq(nct1008_port);
621                 pr_info("%s: pluto nct1008 irq %d", __func__, pluto_i2c4_nct1008_board_info[0].irq);
622
623                 ret = gpio_request(nct1008_port, "temp_alert");
624                 if (ret < 0)
625                         return ret;
626
627                 ret = gpio_direction_input(nct1008_port);
628                 if (ret < 0) {
629                         pr_info("%s: calling gpio_free(nct1008_port)", __func__);
630                         gpio_free(nct1008_port);
631                 }
632         }
633
634         /* pluto has thermal sensor on GEN1-I2C i.e. instance 0 */
635         i2c_register_board_info(0, pluto_i2c4_nct1008_board_info,
636                 ARRAY_SIZE(pluto_i2c4_nct1008_board_info));
637
638         return ret;
639 }
640
641 #ifdef CONFIG_TEGRA_SKIN_THROTTLE
642 static int tegra_skin_match(struct thermal_zone_device *thz, void *data)
643 {
644         return strcmp((char *)data, thz->type) == 0;
645 }
646
647 static int tegra_skin_get_temp(void *data, long *temp)
648 {
649         struct thermal_zone_device *thz;
650
651         thz = thermal_zone_device_find(data, tegra_skin_match);
652
653         if (!thz || thz->ops->get_temp(thz, temp))
654                 *temp = 25000;
655
656         return 0;
657 }
658
659 static struct therm_est_data skin_data = {
660         .toffset = 9793,
661         .polling_period = 1100,
662         .ndevs = 2,
663         .devs = {
664                         {
665                                 .dev_data = "nct_ext",
666                                 .get_temp = tegra_skin_get_temp,
667                                 .coeffs = {
668                                         2, 1, 1, 1,
669                                         1, 1, 1, 1,
670                                         1, 1, 1, 0,
671                                         1, 1, 0, 0,
672                                         0, 0, -1, -7
673                                 },
674                         },
675                         {
676                                 .dev_data = "nct_int",
677                                 .get_temp = tegra_skin_get_temp,
678                                 .coeffs = {
679                                         -11, -7, -5, -3,
680                                         -3, -2, -1, 0,
681                                         0, 0, 1, 1,
682                                         1, 2, 2, 3,
683                                         4, 6, 11, 18
684                                 },
685                         },
686         },
687         .trip_temp = 43000,
688         .tc1 = 1,
689         .tc2 = 15,
690         .passive_delay = 15000,
691 };
692
693 static struct balanced_throttle skin_throttle = {
694         .throt_tab_size = 6,
695         .throt_tab = {
696                 { 640000, 1200 },
697                 { 640000, 1200 },
698                 { 760000, 1200 },
699                 { 760000, 1200 },
700                 {1000000, 1200 },
701                 {1000000, 1200 },
702         },
703 };
704
705 static int __init pluto_skin_init(void)
706 {
707         struct thermal_cooling_device *skin_cdev;
708
709         skin_cdev = balanced_throttle_register(&skin_throttle);
710
711         skin_data.cdev = skin_cdev;
712         tegra_skin_therm_est_device.dev.platform_data = &skin_data;
713         platform_device_register(&tegra_skin_therm_est_device);
714
715         return 0;
716 }
717 late_initcall(pluto_skin_init);
718 #endif
719
720 int __init pluto_sensors_init(void)
721 {
722         int err;
723
724         tegra_get_board_info(&board_info);
725
726         pr_debug("%s: ++\n", __func__);
727         pluto_camera_init();
728
729         err = pluto_nct1008_init();
730         if (err)
731                 return err;
732
733         err = i2c_register_board_info(0, pluto_i2c1_isl_board_info,
734                                 ARRAY_SIZE(pluto_i2c1_isl_board_info));
735         if (err)
736                 pr_err("%s: isl board register failed.\n", __func__);
737
738         mpuirq_init();
739
740         err = i2c_register_board_info(4, pluto_i2c_board_info_max77665,
741                 ARRAY_SIZE(pluto_i2c_board_info_max77665));
742         if (err)
743                 pr_err("%s: max77665 device register failed.\n", __func__);
744
745         err = i2c_register_board_info(0, max17042_device,
746                                 ARRAY_SIZE(max17042_device));
747         if (err)
748                 pr_err("%s: max17042 device register failed.\n", __func__);
749
750
751         return 0;
752 }