arm: tegra: Added platform data for max77665 haptics driver
[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 };
142
143 static struct max77665_charger_cable maxim_cable[] = {
144         {
145                 .name           = "USB",
146         },
147         {
148                 .name           = "USB-Host",
149         },
150         {
151                 .name           = "TA",
152         },
153         {
154                 .name           = "Fast-charger",
155         },
156         {
157                 .name           = "Slow-charger",
158         },
159         {
160                 .name           = "Charge-downstream",
161         },
162 };
163
164 static struct max77665_charger_plat_data max77665_charger = {
165         .fast_chg_cc = 1500, /* fast charger current*/
166         .term_volt = 3700, /* charger termination voltage */
167         .curr_lim = 1500, /* input current limit */
168         .num_cables = MAX_CABLES,
169         .cables = maxim_cable,
170 };
171
172 static struct max77665_muic_platform_data max77665_muic = {
173         .irq_base = 0,
174 };
175
176 static struct max77665_platform_data pluto_max77665_pdata = {
177         .irq_base = 0,
178         .muic_platform_data = {
179                 .pdata = &max77665_muic,
180                 .size = sizeof(max77665_muic),
181                 },
182         .charger_platform_data = {
183                 .pdata = &max77665_charger,
184                 .size = sizeof(max77665_charger),
185                 },
186         .flash_platform_data = {
187                 .pdata = &pluto_max77665_flash_pdata,
188                 .size = sizeof(pluto_max77665_flash_pdata),
189                 },
190         .haptic_platform_data = {
191                 .pdata = &max77665_haptic_pdata,
192                 .size = sizeof(max77665_haptic_pdata),
193                 },
194 };
195
196 static const struct i2c_board_info pluto_i2c_board_info_max77665[] = {
197         {
198                 I2C_BOARD_INFO("max77665", 0x66),
199                 .platform_data = &pluto_max77665_pdata,
200         },
201 };
202
203 /* isl29029 support is provided by isl29028*/
204 static struct i2c_board_info pluto_i2c1_isl_board_info[] = {
205         {
206                 I2C_BOARD_INFO("isl29028", 0x44),
207         }
208 };
209
210 static struct balanced_throttle tj_throttle = {
211         .throt_tab_size = 10,
212         .throt_tab = {
213                 {      0, 1000 },
214                 { 640000, 1000 },
215                 { 640000, 1000 },
216                 { 640000, 1000 },
217                 { 640000, 1000 },
218                 { 640000, 1000 },
219                 { 760000, 1000 },
220                 { 760000, 1050 },
221                 {1000000, 1050 },
222                 {1000000, 1100 },
223         },
224 };
225
226 static struct nct1008_platform_data pluto_nct1008_pdata = {
227         .supported_hwrev = true,
228         .ext_range = true,
229         .conv_rate = 0x08,
230         .offset = 80, /* 4 * 20C. Bug 844025 - 1C for device accuracies */
231         .shutdown_ext_limit = 90, /* C */
232         .shutdown_local_limit = 120, /* C */
233
234         /* Thermal Throttling */
235         .passive = {
236                 .create_cdev = (struct thermal_cooling_device *(*)(void *))
237                                 balanced_throttle_register,
238                 .cdev_data = &tj_throttle,
239                 .trip_temp = 80000,
240                 .tc1 = 0,
241                 .tc2 = 1,
242                 .passive_delay = 2000,
243         }
244 };
245
246 static struct i2c_board_info pluto_i2c4_nct1008_board_info[] = {
247         {
248                 I2C_BOARD_INFO("nct1008", 0x4C),
249                 .platform_data = &pluto_nct1008_pdata,
250                 .irq = -1,
251         }
252 };
253
254 #define VI_PINMUX(_pingroup, _mux, _pupd, _tri, _io, _lock, _ioreset) \
255         {                                                       \
256                 .pingroup       = TEGRA_PINGROUP_##_pingroup,   \
257                 .func           = TEGRA_MUX_##_mux,             \
258                 .pupd           = TEGRA_PUPD_##_pupd,           \
259                 .tristate       = TEGRA_TRI_##_tri,             \
260                 .io             = TEGRA_PIN_##_io,              \
261                 .lock           = TEGRA_PIN_LOCK_##_lock,       \
262                 .od             = TEGRA_PIN_OD_DEFAULT,         \
263                 .ioreset        = TEGRA_PIN_IO_RESET_##_ioreset \
264         }
265
266 static struct tegra_pingroup_config mclk_disable =
267         VI_PINMUX(CAM_MCLK, VI, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT);
268
269 static struct tegra_pingroup_config mclk_enable =
270         VI_PINMUX(CAM_MCLK, VI_ALT3, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT);
271
272 static struct tegra_pingroup_config pbb0_disable =
273         VI_PINMUX(GPIO_PBB0, VI, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT);
274
275 static struct tegra_pingroup_config pbb0_enable =
276         VI_PINMUX(GPIO_PBB0, VI_ALT3, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT);
277
278 /*
279  * more regulators need to be allocated to activate the sensor devices.
280  * pluto_vcmvdd: this is a workaround due to the focuser device(AD5816) will
281  *               hook up the i2c bus if it is not powered up.
282  * pluto_i2cvdd: by default, the power supply on the i2c bus is OFF. So it
283  *               should be turned on every time any sensor device is activated.
284 */
285 static struct regulator *pluto_vcmvdd;
286 static struct regulator *pluto_i2cvdd;
287
288 static int pluto_get_extra_regulators(void)
289 {
290         if (!pluto_vcmvdd) {
291                 pluto_vcmvdd = regulator_get(NULL, "vdd_af_cam1");
292                 if (WARN_ON(IS_ERR(pluto_vcmvdd))) {
293                         pr_err("%s: can't get regulator vdd_af_cam1: %ld\n",
294                                 __func__, PTR_ERR(pluto_vcmvdd));
295                         pluto_vcmvdd = NULL;
296                         return -ENODEV;
297                 }
298         }
299
300         if (!pluto_i2cvdd) {
301                 pluto_i2cvdd = regulator_get(NULL, "vddio_cam_mb");
302                 if (unlikely(WARN_ON(IS_ERR(pluto_i2cvdd)))) {
303                         pr_err("%s: can't get regulator vddio_cam_mb: %ld\n",
304                                 __func__, PTR_ERR(pluto_i2cvdd));
305                         pluto_i2cvdd = NULL;
306                         return -ENODEV;
307                 }
308         }
309
310         return 0;
311 }
312
313 static int pluto_imx091_power_on(struct imx091_power_rail *pw)
314 {
315         int err;
316
317         if (unlikely(WARN_ON(!pw || !pw->dvdd || !pw->iovdd || !pw->avdd)))
318                 return -EFAULT;
319
320         if (pluto_get_extra_regulators())
321                 goto imx091_poweron_fail;
322
323         gpio_set_value(CAM1_POWER_DWN_GPIO, 0);
324         usleep_range(10, 20);
325
326         err = regulator_enable(pw->avdd);
327         if (unlikely(err))
328                 goto imx091_avdd_fail;
329
330         err = regulator_enable(pw->dvdd);
331         if (unlikely(err))
332                 goto imx091_dvdd_fail;
333
334         err = regulator_enable(pw->iovdd);
335         if (unlikely(err))
336                 goto imx091_iovdd_fail;
337
338         usleep_range(1, 2);
339         gpio_set_value(CAM1_POWER_DWN_GPIO, 1);
340
341         tegra_pinmux_config_table(&mclk_enable, 1);
342         err = regulator_enable(pluto_i2cvdd);
343         if (unlikely(err))
344                 goto imx091_i2c_fail;
345
346         err = regulator_enable(pluto_vcmvdd);
347         if (unlikely(err))
348                 goto imx091_vcm_fail;
349         usleep_range(300, 310);
350
351         return 0;
352
353 imx091_vcm_fail:
354         regulator_disable(pluto_i2cvdd);
355
356 imx091_i2c_fail:
357         tegra_pinmux_config_table(&mclk_disable, 1);
358         gpio_set_value(CAM1_POWER_DWN_GPIO, 0);
359         regulator_disable(pw->iovdd);
360
361 imx091_iovdd_fail:
362         regulator_disable(pw->dvdd);
363
364 imx091_dvdd_fail:
365         regulator_disable(pw->avdd);
366
367 imx091_avdd_fail:
368 imx091_poweron_fail:
369         pr_err("%s FAILED\n", __func__);
370         return -ENODEV;
371 }
372
373 static int pluto_imx091_power_off(struct imx091_power_rail *pw)
374 {
375         if (unlikely(WARN_ON(!pw || !pluto_i2cvdd || !pluto_vcmvdd ||
376                         !pw->dvdd || !pw->iovdd || !pw->avdd)))
377                 return -EFAULT;
378
379         usleep_range(1, 2);
380         tegra_pinmux_config_table(&mclk_disable, 1);
381         gpio_set_value(CAM1_POWER_DWN_GPIO, 0);
382         usleep_range(1, 2);
383
384         regulator_disable(pw->iovdd);
385         regulator_disable(pw->dvdd);
386         regulator_disable(pw->avdd);
387         regulator_disable(pluto_i2cvdd);
388         regulator_disable(pluto_vcmvdd);
389
390         return 0;
391 }
392
393 struct imx091_platform_data pluto_imx091_data = {
394         .power_on = pluto_imx091_power_on,
395         .power_off = pluto_imx091_power_off,
396 };
397
398 static int pluto_imx132_power_on(struct imx132_power_rail *pw)
399 {
400         int err;
401
402         if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd || !pw->dvdd)))
403                 return -EFAULT;
404
405         if (pluto_get_extra_regulators())
406                 goto pluto_imx132_poweron_fail;
407
408         gpio_set_value(CAM2_POWER_DWN_GPIO, 0);
409
410         tegra_pinmux_config_table(&pbb0_enable, 1);
411
412         err = regulator_enable(pluto_i2cvdd);
413         if (unlikely(err))
414                 goto imx132_i2c_fail;
415
416         err = regulator_enable(pluto_vcmvdd);
417         if (unlikely(err))
418                 goto imx132_vcm_fail;
419
420         err = regulator_enable(pw->avdd);
421         if (unlikely(err))
422                 goto imx132_avdd_fail;
423
424         err = regulator_enable(pw->dvdd);
425         if (unlikely(err))
426                 goto imx132_dvdd_fail;
427
428         err = regulator_enable(pw->iovdd);
429         if (unlikely(err))
430                 goto imx132_iovdd_fail;
431
432         usleep_range(1, 2);
433
434         gpio_set_value(CAM2_POWER_DWN_GPIO, 1);
435
436         return 0;
437
438 imx132_iovdd_fail:
439         regulator_disable(pw->dvdd);
440
441 imx132_dvdd_fail:
442         regulator_disable(pw->avdd);
443
444 imx132_avdd_fail:
445         regulator_disable(pluto_vcmvdd);
446
447 imx132_vcm_fail:
448         regulator_disable(pluto_i2cvdd);
449
450 imx132_i2c_fail:
451         tegra_pinmux_config_table(&pbb0_disable, 1);
452
453 pluto_imx132_poweron_fail:
454         pr_err("%s failed.\n", __func__);
455         return -ENODEV;
456 }
457
458 static int pluto_imx132_power_off(struct imx132_power_rail *pw)
459 {
460         if (unlikely(WARN_ON(!pw || !pw->avdd || !pw->iovdd || !pw->dvdd ||
461                         !pluto_i2cvdd || !pluto_vcmvdd)))
462                 return -EFAULT;
463
464         gpio_set_value(CAM2_POWER_DWN_GPIO, 0);
465
466         usleep_range(1, 2);
467
468         regulator_disable(pw->iovdd);
469         regulator_disable(pw->dvdd);
470         regulator_disable(pw->avdd);
471
472         tegra_pinmux_config_table(&pbb0_disable, 1);
473
474         regulator_disable(pluto_vcmvdd);
475         regulator_disable(pluto_i2cvdd);
476
477         return 0;
478 }
479
480 struct imx132_platform_data pluto_imx132_data = {
481         .power_on = pluto_imx132_power_on,
482         .power_off = pluto_imx132_power_off,
483 };
484
485 static struct ad5816_platform_data pluto_ad5816_pdata = {
486         .cfg            = 0,
487         .num            = 0,
488         .sync           = 0,
489         .dev_name       = "focuser",
490 };
491
492 static struct i2c_board_info pluto_i2c_board_info_e1625[] = {
493         {
494                 I2C_BOARD_INFO("imx091", 0x10),
495                 .platform_data = &pluto_imx091_data,
496         },
497         {
498                 I2C_BOARD_INFO("imx132", 0x36),
499                 .platform_data = &pluto_imx132_data,
500         },
501         {
502                 I2C_BOARD_INFO("ad5816", 0x0E),
503                 .platform_data = &pluto_ad5816_pdata,
504         },
505 };
506
507 static int pluto_camera_init(void)
508 {
509         pr_debug("%s: ++\n", __func__);
510
511         tegra_pinmux_config_table(&mclk_disable, 1);
512         tegra_pinmux_config_table(&pbb0_disable, 1);
513
514         i2c_register_board_info(2, pluto_i2c_board_info_e1625,
515                 ARRAY_SIZE(pluto_i2c_board_info_e1625));
516
517         return 0;
518 }
519
520 /* MPU board file definition */
521 static struct mpu_platform_data mpu_gyro_data = {
522         .int_config     = 0x10,
523         .level_shifter  = 0,
524         .orientation    = MPU_GYRO_ORIENTATION,
525         .sec_slave_type = SECONDARY_SLAVE_TYPE_NONE,
526         .key            = {0x4E, 0xCC, 0x7E, 0xEB, 0xF6, 0x1E, 0x35, 0x22,
527                            0x00, 0x34, 0x0D, 0x65, 0x32, 0xE9, 0x94, 0x89},
528 };
529
530 static struct mpu_platform_data mpu_compass_data = {
531         .orientation    = MPU_COMPASS_ORIENTATION,
532         .sec_slave_type = SECONDARY_SLAVE_TYPE_NONE,
533 };
534
535 static struct i2c_board_info __initdata inv_mpu_i2c0_board_info[] = {
536         {
537                 I2C_BOARD_INFO(MPU_GYRO_NAME, MPU_GYRO_ADDR),
538                 .platform_data = &mpu_gyro_data,
539         },
540         {
541                 I2C_BOARD_INFO(MPU_COMPASS_NAME, MPU_COMPASS_ADDR),
542                 .platform_data = &mpu_compass_data,
543         },
544 };
545
546 static void mpuirq_init(void)
547 {
548         int ret = 0;
549         int i = 0;
550
551         pr_info("*** MPU START *** mpuirq_init...\n");
552
553         /* MPU-IRQ assignment */
554         ret = gpio_request(MPU_GYRO_IRQ_GPIO, MPU_GYRO_NAME);
555         if (ret < 0) {
556                 pr_err("%s: gpio_request failed %d\n", __func__, ret);
557                 return;
558         }
559
560         ret = gpio_direction_input(MPU_GYRO_IRQ_GPIO);
561         if (ret < 0) {
562                 pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
563                 gpio_free(MPU_GYRO_IRQ_GPIO);
564                 return;
565         }
566         pr_info("*** MPU END *** mpuirq_init...\n");
567
568         inv_mpu_i2c0_board_info[i++].irq = gpio_to_irq(MPU_GYRO_IRQ_GPIO);
569 #if MPU_COMPASS_IRQ_GPIO
570         inv_mpu_i2c0_board_info[i++].irq = gpio_to_irq(MPU_COMPASS_IRQ_GPIO);
571 #endif
572         i2c_register_board_info(MPU_GYRO_BUS_NUM, inv_mpu_i2c0_board_info,
573                 ARRAY_SIZE(inv_mpu_i2c0_board_info));
574 }
575
576 static int pluto_nct1008_init(void)
577 {
578         int nct1008_port = -1;
579         int ret = 0;
580
581 #if defined(CONFIG_ARCH_TEGRA_11x_SOC)
582         if (board_info.board_id == BOARD_E1580 ||
583             board_info.board_id == BOARD_E1575) {
584                 nct1008_port = TEGRA_GPIO_PX6;
585         } else {
586                 nct1008_port = TEGRA_GPIO_PX6;
587                 pr_err("Warning: nct alert port assumed TEGRA_GPIO_PX6 for unknown pluto board id E%d\n",
588                        board_info.board_id);
589         }
590 #else
591         /* pluto + AP30 interposer has SPI2_CS0 gpio */
592         nct1008_port = TEGRA_GPIO_PX3;
593 #endif
594
595         if (nct1008_port >= 0) {
596 #ifdef CONFIG_TEGRA_EDP_LIMITS
597                 const struct tegra_edp_limits *cpu_edp_limits;
598                 int cpu_edp_limits_size;
599                 int i;
600
601                 /* edp capping */
602                 tegra_get_cpu_edp_limits(&cpu_edp_limits, &cpu_edp_limits_size);
603
604                 if (cpu_edp_limits_size > MAX_THROT_TABLE_SIZE)
605                         BUG();
606
607                 for (i = 0; i < cpu_edp_limits_size-1; i++) {
608                         pluto_nct1008_pdata.active[i].create_cdev =
609                                 (struct thermal_cooling_device *(*)(void *))
610                                         edp_cooling_device_create;
611                         pluto_nct1008_pdata.active[i].cdev_data = (void *)i;
612                         pluto_nct1008_pdata.active[i].trip_temp =
613                                 cpu_edp_limits[i].temperature * 1000;
614                         pluto_nct1008_pdata.active[i].hysteresis = 1000;
615                 }
616                 pluto_nct1008_pdata.active[i].create_cdev = NULL;
617 #endif
618
619                 pluto_i2c4_nct1008_board_info[0].irq = gpio_to_irq(nct1008_port);
620                 pr_info("%s: pluto nct1008 irq %d", __func__, pluto_i2c4_nct1008_board_info[0].irq);
621
622                 ret = gpio_request(nct1008_port, "temp_alert");
623                 if (ret < 0)
624                         return ret;
625
626                 ret = gpio_direction_input(nct1008_port);
627                 if (ret < 0) {
628                         pr_info("%s: calling gpio_free(nct1008_port)", __func__);
629                         gpio_free(nct1008_port);
630                 }
631         }
632
633         /* pluto has thermal sensor on GEN1-I2C i.e. instance 0 */
634         i2c_register_board_info(0, pluto_i2c4_nct1008_board_info,
635                 ARRAY_SIZE(pluto_i2c4_nct1008_board_info));
636
637         return ret;
638 }
639
640 #ifdef CONFIG_TEGRA_SKIN_THROTTLE
641 static int tegra_skin_match(struct thermal_zone_device *thz, void *data)
642 {
643         return strcmp((char *)data, thz->type) == 0;
644 }
645
646 static int tegra_skin_get_temp(void *data, long *temp)
647 {
648         struct thermal_zone_device *thz;
649
650         thz = thermal_zone_device_find(data, tegra_skin_match);
651
652         if (!thz || thz->ops->get_temp(thz, temp))
653                 *temp = 25000;
654
655         return 0;
656 }
657
658 static struct therm_est_data skin_data = {
659         .toffset = 9793,
660         .polling_period = 1100,
661         .ndevs = 2,
662         .devs = {
663                         {
664                                 .dev_data = "nct_ext",
665                                 .get_temp = tegra_skin_get_temp,
666                                 .coeffs = {
667                                         2, 1, 1, 1,
668                                         1, 1, 1, 1,
669                                         1, 1, 1, 0,
670                                         1, 1, 0, 0,
671                                         0, 0, -1, -7
672                                 },
673                         },
674                         {
675                                 .dev_data = "nct_int",
676                                 .get_temp = tegra_skin_get_temp,
677                                 .coeffs = {
678                                         -11, -7, -5, -3,
679                                         -3, -2, -1, 0,
680                                         0, 0, 1, 1,
681                                         1, 2, 2, 3,
682                                         4, 6, 11, 18
683                                 },
684                         },
685         },
686         .trip_temp = 43000,
687         .tc1 = 1,
688         .tc2 = 15,
689         .passive_delay = 15000,
690 };
691
692 static struct balanced_throttle skin_throttle = {
693         .throt_tab_size = 6,
694         .throt_tab = {
695                 { 640000, 1200 },
696                 { 640000, 1200 },
697                 { 760000, 1200 },
698                 { 760000, 1200 },
699                 {1000000, 1200 },
700                 {1000000, 1200 },
701         },
702 };
703
704 static int __init pluto_skin_init(void)
705 {
706         struct thermal_cooling_device *skin_cdev;
707
708         skin_cdev = balanced_throttle_register(&skin_throttle);
709
710         skin_data.cdev = skin_cdev;
711         tegra_skin_therm_est_device.dev.platform_data = &skin_data;
712         platform_device_register(&tegra_skin_therm_est_device);
713
714         return 0;
715 }
716 late_initcall(pluto_skin_init);
717 #endif
718
719 int __init pluto_sensors_init(void)
720 {
721         int err;
722
723         tegra_get_board_info(&board_info);
724
725         pr_debug("%s: ++\n", __func__);
726         pluto_camera_init();
727
728         err = pluto_nct1008_init();
729         if (err)
730                 return err;
731
732         err = i2c_register_board_info(0, pluto_i2c1_isl_board_info,
733                                 ARRAY_SIZE(pluto_i2c1_isl_board_info));
734         if (err)
735                 pr_err("%s: isl board register failed.\n", __func__);
736
737         mpuirq_init();
738
739         err = i2c_register_board_info(4, pluto_i2c_board_info_max77665,
740                 ARRAY_SIZE(pluto_i2c_board_info_max77665));
741         if (err)
742                 pr_err("%s: max77665 device register failed.\n", __func__);
743
744         err = i2c_register_board_info(0, max17042_device,
745                                 ARRAY_SIZE(max17042_device));
746         if (err)
747                 pr_err("%s: max17042 device register failed.\n", __func__);
748
749
750         return 0;
751 }