ARM: tegra: nct: Use new nct platform data
[linux-2.6.git] / arch / arm / mach-tegra / board-dalmore-sensors.c
1 /*
2  * arch/arm/mach-tegra/board-dalmore-sensors.c
3  *
4  * Copyright (c) 2012 NVIDIA CORPORATION, All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * Redistributions of source code must retain the above copyright notice,
11  * this list of conditions and the following disclaimer.
12  *
13  * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  *
17  * Neither the name of NVIDIA CORPORATION nor the names of its contributors
18  * may be used to endorse or promote products derived from this software
19  * without specific prior written permission.
20  *
21  * This software is licensed under the terms of the GNU General Public
22  * License version 2, as published by the Free Software Foundation, and
23  * may be copied, distributed, and modified under those terms.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28  * GNU General Public License for more details.
29  */
30
31 #include <linux/i2c.h>
32 #include <linux/delay.h>
33 #include <linux/mpu.h>
34 #include <linux/regulator/consumer.h>
35 #include <linux/gpio.h>
36 #include <linux/therm_est.h>
37 #include <linux/nct1008.h>
38 #include <mach/edp.h>
39
40 #include <mach/gpio-tegra.h>
41 #include <mach/pinmux-t11.h>
42 #include <mach/pinmux.h>
43 #include <media/imx091.h>
44 #include <media/ov9772.h>
45 #include <media/as364x.h>
46 #include <media/ad5816.h>
47 #include <generated/mach-types.h>
48 #include <linux/power/sbs-battery.h>
49
50 #include "gpio-names.h"
51 #include "board.h"
52 #include "board-dalmore.h"
53 #include "cpu-tegra.h"
54 #include "devices.h"
55 #include "tegra-board-id.h"
56
57 static struct nvc_gpio_pdata imx091_gpio_pdata[] = {
58         {IMX091_GPIO_RESET, CAM_RSTN, true, false},
59         {IMX091_GPIO_PWDN, CAM1_POWER_DWN_GPIO, true, false},
60         {IMX091_GPIO_GP1, CAM_GPIO1, true, false}
61 };
62
63 static struct board_info board_info;
64
65 static struct balanced_throttle tj_throttle = {
66         .throt_tab_size = 19,
67         .throt_tab = {
68                 {      0, 1000 },
69                 {  51000, 1000 },
70                 { 102000, 1000 },
71                 { 204000, 1000 },
72                 { 252000, 1000 },
73                 { 288000, 1000 },
74                 { 372000, 1000 },
75                 { 468000, 1000 },
76                 { 510000, 1000 },
77                 { 612000, 1000 },
78                 { 714000, 1050 },
79                 { 816000, 1050 },
80                 { 918000, 1050 },
81                 {1020000, 1100 },
82                 {1122000, 1100 },
83                 {1224000, 1100 },
84                 {1326000, 1100 },
85                 {1428000, 1100 },
86                 {1530000, 1100 },
87         },
88 };
89
90 static int __init dalmore_throttle_init(void)
91 {
92         if (machine_is_dalmore())
93                 balanced_throttle_register(&tj_throttle, "dalmore-nct");
94         return 0;
95 }
96 module_init(dalmore_throttle_init);
97
98 static struct nct1008_platform_data dalmore_nct1008_pdata = {
99         .supported_hwrev = true,
100         .ext_range = true,
101         .conv_rate = 0x08,
102         .offset = 80, /* 4 * 20C. Bug 844025 - 1C for device accuracies */
103         .shutdown_ext_limit = 90, /* C */
104         .shutdown_local_limit = 120, /* C */
105
106         .passive_delay = 2000,
107
108         .num_trips = 1,
109         .trips = {
110                 /* Thermal Throttling */
111                 [0] = {
112                         .cdev_type = "dalmore-nct",
113                         .trip_temp = 80000,
114                         .trip_type = THERMAL_TRIP_PASSIVE,
115                         .state = THERMAL_NO_LIMIT,
116                         .hysteresis = 0,
117                 },
118         },
119 };
120
121 static struct i2c_board_info dalmore_i2c4_nct1008_board_info[] = {
122         {
123                 I2C_BOARD_INFO("nct1008", 0x4C),
124                 .platform_data = &dalmore_nct1008_pdata,
125                 .irq = -1,
126         }
127 };
128
129 #define VI_PINMUX(_pingroup, _mux, _pupd, _tri, _io, _lock, _ioreset) \
130         {                                                       \
131                 .pingroup       = TEGRA_PINGROUP_##_pingroup,   \
132                 .func           = TEGRA_MUX_##_mux,             \
133                 .pupd           = TEGRA_PUPD_##_pupd,           \
134                 .tristate       = TEGRA_TRI_##_tri,             \
135                 .io             = TEGRA_PIN_##_io,              \
136                 .lock           = TEGRA_PIN_LOCK_##_lock,       \
137                 .od             = TEGRA_PIN_OD_DEFAULT,         \
138                 .ioreset        = TEGRA_PIN_IO_RESET_##_ioreset \
139 }
140
141 static int dalmore_focuser_power_on(struct ad5816_power_rail *pw)
142 {
143         int err;
144
145         if (unlikely(WARN_ON(!pw || !pw->vdd || !pw->vdd_i2c)))
146                 return -EFAULT;
147
148         err = regulator_enable(pw->vdd_i2c);
149         if (unlikely(err))
150                 goto ad5816_vdd_i2c_fail;
151
152         err = regulator_enable(pw->vdd);
153         if (unlikely(err))
154                 goto ad5816_vdd_fail;
155
156         return 0;
157
158 ad5816_vdd_fail:
159         regulator_disable(pw->vdd_i2c);
160
161 ad5816_vdd_i2c_fail:
162         pr_err("%s FAILED\n", __func__);
163
164         return -ENODEV;
165 }
166
167 static int dalmore_focuser_power_off(struct ad5816_power_rail *pw)
168 {
169         if (unlikely(WARN_ON(!pw || !pw->vdd || !pw->vdd_i2c)))
170                 return -EFAULT;
171
172         regulator_disable(pw->vdd);
173         regulator_disable(pw->vdd_i2c);
174
175         return 0;
176 }
177
178 static struct tegra_pingroup_config mclk_disable =
179         VI_PINMUX(CAM_MCLK, VI, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT);
180
181 static struct tegra_pingroup_config mclk_enable =
182         VI_PINMUX(CAM_MCLK, VI_ALT3, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT);
183
184 static struct tegra_pingroup_config pbb0_disable =
185         VI_PINMUX(GPIO_PBB0, VI, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT);
186
187 static struct tegra_pingroup_config pbb0_enable =
188         VI_PINMUX(GPIO_PBB0, VI_ALT3, NORMAL, NORMAL, OUTPUT, DEFAULT, DEFAULT);
189
190 /*
191  * As a workaround, dalmore_vcmvdd need to be allocated to activate the
192  * sensor devices. This is due to the focuser device(AD5816) will hook up
193  * the i2c bus if it is not powered up.
194 */
195 static struct regulator *dalmore_vcmvdd;
196
197 static int dalmore_get_vcmvdd(void)
198 {
199         if (!dalmore_vcmvdd) {
200                 dalmore_vcmvdd = regulator_get(NULL, "vdd_af_cam1");
201                 if (unlikely(WARN_ON(IS_ERR(dalmore_vcmvdd)))) {
202                         pr_err("%s: can't get regulator vcmvdd: %ld\n",
203                                 __func__, PTR_ERR(dalmore_vcmvdd));
204                         dalmore_vcmvdd = NULL;
205                         return -ENODEV;
206                 }
207         }
208         return 0;
209 }
210
211 static int dalmore_imx091_power_on(struct nvc_regulator *vreg)
212 {
213         int err;
214
215         if (unlikely(WARN_ON(!vreg)))
216                 return -EFAULT;
217
218         if (dalmore_get_vcmvdd())
219                 goto imx091_poweron_fail;
220
221         gpio_set_value(CAM1_POWER_DWN_GPIO, 0);
222         usleep_range(10, 20);
223
224         err = regulator_enable(vreg[IMX091_VREG_AVDD].vreg);
225         if (err)
226                 goto imx091_avdd_fail;
227
228         err = regulator_enable(vreg[IMX091_VREG_IOVDD].vreg);
229         if (err)
230                 goto imx091_iovdd_fail;
231
232         usleep_range(1, 2);
233         gpio_set_value(CAM1_POWER_DWN_GPIO, 1);
234
235         err = regulator_enable(dalmore_vcmvdd);
236         if (unlikely(err))
237                 goto imx091_vcmvdd_fail;
238
239         tegra_pinmux_config_table(&mclk_enable, 1);
240         usleep_range(300, 310);
241
242         return 1;
243
244 imx091_vcmvdd_fail:
245         regulator_disable(vreg[IMX091_VREG_IOVDD].vreg);
246
247 imx091_iovdd_fail:
248         regulator_disable(vreg[IMX091_VREG_AVDD].vreg);
249
250 imx091_avdd_fail:
251         gpio_set_value(CAM1_POWER_DWN_GPIO, 0);
252
253 imx091_poweron_fail:
254         pr_err("%s FAILED\n", __func__);
255         return -ENODEV;
256 }
257
258 static int dalmore_imx091_power_off(struct nvc_regulator *vreg)
259 {
260         if (unlikely(WARN_ON(!vreg)))
261                 return -EFAULT;
262
263         usleep_range(1, 2);
264         tegra_pinmux_config_table(&mclk_disable, 1);
265         gpio_set_value(CAM1_POWER_DWN_GPIO, 0);
266         usleep_range(1, 2);
267
268         regulator_disable(dalmore_vcmvdd);
269         regulator_disable(vreg[IMX091_VREG_IOVDD].vreg);
270         regulator_disable(vreg[IMX091_VREG_AVDD].vreg);
271
272         return 1;
273 }
274
275 static struct nvc_imager_cap imx091_cap = {
276         .identifier             = "IMX091",
277         .sensor_nvc_interface   = 3,
278         .pixel_types[0]         = 0x100,
279         .orientation            = 0,
280         .direction              = 0,
281         .initial_clock_rate_khz = 6000,
282         .clock_profiles[0] = {
283                 .external_clock_khz     = 24000,
284                 .clock_multiplier       = 10416667, /* value / 1,000,000 */
285         },
286         .clock_profiles[1] = {
287                 .external_clock_khz     = 0,
288                 .clock_multiplier       = 0,
289         },
290         .h_sync_edge            = 0,
291         .v_sync_edge            = 0,
292         .mclk_on_vgp0           = 0,
293         .csi_port               = 0,
294         .data_lanes             = 4,
295         .virtual_channel_id     = 0,
296         .discontinuous_clk_mode = 1,
297         .cil_threshold_settle   = 0x0,
298         .min_blank_time_width   = 16,
299         .min_blank_time_height  = 16,
300         .preferred_mode_index   = 0,
301         .focuser_guid           = NVC_FOCUS_GUID(0),
302         .torch_guid             = NVC_TORCH_GUID(0),
303         .cap_version            = NVC_IMAGER_CAPABILITIES_VERSION2,
304 };
305
306 static struct imx091_platform_data imx091_pdata = {
307         .num                    = 0,
308         .sync                   = 0,
309         .dev_name               = "camera",
310         .gpio_count             = ARRAY_SIZE(imx091_gpio_pdata),
311         .gpio                   = imx091_gpio_pdata,
312         .flash_cap              = {
313                 .sdo_trigger_enabled = 1,
314                 .adjustable_flash_timing = 1,
315         },
316         .cap                    = &imx091_cap,
317         .power_on               = dalmore_imx091_power_on,
318         .power_off              = dalmore_imx091_power_off,
319 };
320
321 struct sbs_platform_data sbs_pdata = {
322         .poll_retry_count = 100,
323         .i2c_retry_count = 2,
324 };
325
326 static int dalmore_ov9772_power_on(struct ov9772_power_rail *pw)
327 {
328         int err;
329
330         if (unlikely(!pw || !pw->avdd || !pw->dovdd))
331                 return -EFAULT;
332
333         if (dalmore_get_vcmvdd())
334                 goto ov9772_get_vcmvdd_fail;
335
336         gpio_set_value(CAM2_POWER_DWN_GPIO, 0);
337         gpio_set_value(CAM_RSTN, 0);
338
339         err = regulator_enable(pw->avdd);
340         if (unlikely(err))
341                 goto ov9772_avdd_fail;
342
343         err = regulator_enable(pw->dovdd);
344         if (unlikely(err))
345                 goto ov9772_dovdd_fail;
346
347         gpio_set_value(CAM_RSTN, 1);
348         gpio_set_value(CAM2_POWER_DWN_GPIO, 1);
349
350         err = regulator_enable(dalmore_vcmvdd);
351         if (unlikely(err))
352                 goto ov9772_vcmvdd_fail;
353
354         tegra_pinmux_config_table(&pbb0_enable, 1);
355         usleep_range(340, 380);
356
357         /* return 1 to skip the in-driver power_on sequence */
358         return 1;
359
360 ov9772_vcmvdd_fail:
361         regulator_disable(pw->dovdd);
362
363 ov9772_dovdd_fail:
364         regulator_disable(pw->avdd);
365
366 ov9772_avdd_fail:
367         gpio_set_value(CAM_RSTN, 0);
368         gpio_set_value(CAM2_POWER_DWN_GPIO, 0);
369
370 ov9772_get_vcmvdd_fail:
371         pr_err("%s FAILED\n", __func__);
372         return -ENODEV;
373 }
374
375 static int dalmore_ov9772_power_off(struct ov9772_power_rail *pw)
376 {
377         if (unlikely(!pw || !dalmore_vcmvdd || !pw->avdd || !pw->dovdd))
378                 return -EFAULT;
379
380         usleep_range(21, 25);
381         tegra_pinmux_config_table(&pbb0_disable, 1);
382
383         gpio_set_value(CAM2_POWER_DWN_GPIO, 0);
384         gpio_set_value(CAM_RSTN, 0);
385
386         regulator_disable(dalmore_vcmvdd);
387         regulator_disable(pw->dovdd);
388         regulator_disable(pw->avdd);
389
390         /* return 1 to skip the in-driver power_off sequence */
391         return 1;
392 }
393
394 static struct nvc_gpio_pdata ov9772_gpio_pdata[] = {
395         { OV9772_GPIO_TYPE_SHTDN, CAM2_POWER_DWN_GPIO, true, 0, },
396         { OV9772_GPIO_TYPE_PWRDN, CAM_RSTN, true, 0, },
397 };
398
399 static struct ov9772_platform_data dalmore_ov9772_pdata = {
400         .num            = 1,
401         .dev_name       = "camera",
402         .gpio_count     = ARRAY_SIZE(ov9772_gpio_pdata),
403         .gpio           = ov9772_gpio_pdata,
404         .power_on       = dalmore_ov9772_power_on,
405         .power_off      = dalmore_ov9772_power_off,
406 };
407
408 static int dalmore_as3648_power_on(struct as364x_power_rail *pw)
409 {
410         int err = dalmore_get_vcmvdd();
411
412         if (err)
413                 return err;
414
415         return regulator_enable(dalmore_vcmvdd);
416 }
417
418 static int dalmore_as3648_power_off(struct as364x_power_rail *pw)
419 {
420         if (!dalmore_vcmvdd)
421                 return -ENODEV;
422
423         return regulator_disable(dalmore_vcmvdd);
424 }
425
426 static struct as364x_platform_data dalmore_as3648_pdata = {
427         .config         = {
428                 .max_total_current_mA = 1000,
429                 .max_peak_current_mA = 600,
430                 .vin_low_v_run_mV = 3070,
431                 .strobe_type = 1,
432                 },
433         .pinstate       = {
434                 .mask   = 1 << (CAM_FLASH_STROBE - TEGRA_GPIO_PBB0),
435                 .values = 1 << (CAM_FLASH_STROBE - TEGRA_GPIO_PBB0)
436                 },
437         .dev_name       = "torch",
438         .type           = AS3648,
439         .gpio_strobe    = CAM_FLASH_STROBE,
440         .led_mask       = 3,
441
442         .power_on_callback = dalmore_as3648_power_on,
443         .power_off_callback = dalmore_as3648_power_off,
444 };
445
446 static struct ad5816_platform_data dalmore_ad5816_pdata = {
447         .cfg = 0,
448         .num = 0,
449         .sync = 0,
450         .dev_name = "focuser",
451         .power_on = dalmore_focuser_power_on,
452         .power_off = dalmore_focuser_power_off,
453 };
454
455 static struct i2c_board_info dalmore_i2c_board_info_e1625[] = {
456         {
457                 I2C_BOARD_INFO("imx091", 0x36),
458                 .platform_data = &imx091_pdata,
459         },
460         {
461                 I2C_BOARD_INFO("ov9772", 0x10),
462                 .platform_data = &dalmore_ov9772_pdata,
463         },
464         {
465                 I2C_BOARD_INFO("as3648", 0x30),
466                 .platform_data = &dalmore_as3648_pdata,
467         },
468         {
469                 I2C_BOARD_INFO("ad5816", 0x0E),
470                 .platform_data = &dalmore_ad5816_pdata,
471         },
472 };
473
474 static int dalmore_camera_init(void)
475 {
476         tegra_pinmux_config_table(&mclk_disable, 1);
477         tegra_pinmux_config_table(&pbb0_disable, 1);
478
479         i2c_register_board_info(2, dalmore_i2c_board_info_e1625,
480                 ARRAY_SIZE(dalmore_i2c_board_info_e1625));
481         return 0;
482 }
483
484 /* MPU board file definition    */
485 static struct mpu_platform_data mpu9150_gyro_data = {
486         .int_config     = 0x10,
487         .level_shifter  = 0,
488         /* Located in board_[platformname].h */
489         .orientation    = MPU_GYRO_ORIENTATION,
490         .sec_slave_type = SECONDARY_SLAVE_TYPE_COMPASS,
491         .sec_slave_id   = COMPASS_ID_AK8975,
492         .secondary_i2c_addr     = MPU_COMPASS_ADDR,
493         .secondary_read_reg     = 0x06,
494         .secondary_orientation  = MPU_COMPASS_ORIENTATION,
495         .key            = {0x4E, 0xCC, 0x7E, 0xEB, 0xF6, 0x1E, 0x35, 0x22,
496                            0x00, 0x34, 0x0D, 0x65, 0x32, 0xE9, 0x94, 0x89},
497 };
498
499 #define TEGRA_CAMERA_GPIO(_gpio, _label, _value)                \
500         {                                                       \
501                 .gpio = _gpio,                                  \
502                 .label = _label,                                \
503                 .value = _value,                                \
504         }
505
506 static struct i2c_board_info dalmore_i2c_board_info_cm3218[] = {
507         {
508                 I2C_BOARD_INFO("cm3218", 0x48),
509         },
510 };
511
512 static struct i2c_board_info __initdata inv_mpu9150_i2c2_board_info[] = {
513         {
514                 I2C_BOARD_INFO(MPU_GYRO_NAME, MPU_GYRO_ADDR),
515                 .platform_data = &mpu9150_gyro_data,
516         },
517 };
518
519 static void mpuirq_init(void)
520 {
521         int ret = 0;
522         unsigned gyro_irq_gpio = MPU_GYRO_IRQ_GPIO;
523         unsigned gyro_bus_num = MPU_GYRO_BUS_NUM;
524         char *gyro_name = MPU_GYRO_NAME;
525
526         pr_info("*** MPU START *** mpuirq_init...\n");
527
528         ret = gpio_request(gyro_irq_gpio, gyro_name);
529
530         if (ret < 0) {
531                 pr_err("%s: gpio_request failed %d\n", __func__, ret);
532                 return;
533         }
534
535         ret = gpio_direction_input(gyro_irq_gpio);
536         if (ret < 0) {
537                 pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
538                 gpio_free(gyro_irq_gpio);
539                 return;
540         }
541         pr_info("*** MPU END *** mpuirq_init...\n");
542
543         inv_mpu9150_i2c2_board_info[0].irq = gpio_to_irq(MPU_GYRO_IRQ_GPIO);
544         i2c_register_board_info(gyro_bus_num, inv_mpu9150_i2c2_board_info,
545                 ARRAY_SIZE(inv_mpu9150_i2c2_board_info));
546 }
547
548 static int dalmore_nct1008_init(void)
549 {
550         int nct1008_port = -1;
551         int ret = 0;
552
553 #if defined(CONFIG_ARCH_TEGRA_11x_SOC)
554         if ((board_info.board_id == BOARD_E1612) ||
555             (board_info.board_id == BOARD_E1641) ||
556             (board_info.board_id == BOARD_E1613) ||
557             (board_info.board_id == BOARD_P2454))
558         {
559                 /* per email from Matt 9/10/2012 */
560                 nct1008_port = TEGRA_GPIO_PX6;
561         } else if (board_info.board_id == BOARD_E1611) {
562                 if (board_info.fab == 0x04)
563                         nct1008_port = TEGRA_GPIO_PO4;
564                 else
565                         nct1008_port = TEGRA_GPIO_PX6;
566         } else {
567                 nct1008_port = TEGRA_GPIO_PX6;
568                 pr_err("Warning: nct alert_port assumed TEGRA_GPIO_PX6"
569                         " for unknown dalmore board id E%d\n",
570                         board_info.board_id);
571         }
572 #else
573         /* dalmore + AP30 interposer has SPI2_CS0 gpio */
574         nct1008_port = TEGRA_GPIO_PX3;
575 #endif
576
577         if (nct1008_port >= 0) {
578 #ifdef CONFIG_TEGRA_EDP_LIMITS
579                 const struct tegra_edp_limits *cpu_edp_limits;
580                 int cpu_edp_limits_size;
581                 int i;
582                 int trip;
583                 struct nct1008_platform_data *data = &dalmore_nct1008_pdata;
584                 struct nct_trip_temp *trip_state;
585
586                 /* edp capping */
587                 tegra_get_cpu_edp_limits(&cpu_edp_limits, &cpu_edp_limits_size);
588
589                 if (cpu_edp_limits_size > MAX_THROT_TABLE_SIZE)
590                         BUG();
591
592                 for (i = 0; i < cpu_edp_limits_size-1; i++) {
593                         trip = data->num_trips;
594                         trip_state = &data->trips[trip];
595
596                         trip_state->cdev_type = "edp";
597                         trip_state->trip_temp =
598                                         cpu_edp_limits[i].temperature * 1000;
599                         trip_state->trip_type = THERMAL_TRIP_ACTIVE;
600                         trip_state->state = i + 1;
601                         trip_state->hysteresis = 1000;
602
603                         data->num_trips++;
604
605                         if (data->num_trips > NCT_MAX_TRIPS)
606                                 BUG();
607                 }
608 #endif
609
610                 dalmore_i2c4_nct1008_board_info[0].irq = gpio_to_irq(nct1008_port);
611                 pr_info("%s: dalmore nct1008 irq %d", __func__, dalmore_i2c4_nct1008_board_info[0].irq);
612
613                 ret = gpio_request(nct1008_port, "temp_alert");
614                 if (ret < 0)
615                         return ret;
616
617                 ret = gpio_direction_input(nct1008_port);
618                 if (ret < 0) {
619                         pr_info("%s: calling gpio_free(nct1008_port)", __func__);
620                         gpio_free(nct1008_port);
621                 }
622         }
623
624         /* dalmore has thermal sensor on GEN1-I2C i.e. instance 0 */
625         i2c_register_board_info(0, dalmore_i2c4_nct1008_board_info,
626                 ARRAY_SIZE(dalmore_i2c4_nct1008_board_info));
627
628         return ret;
629 }
630
631 static struct i2c_board_info __initdata bq20z45_pdata[] = {
632         {
633                 I2C_BOARD_INFO("sbs-battery", 0x0B),
634                 .platform_data = &sbs_pdata,
635         },
636 };
637
638 #ifdef CONFIG_TEGRA_SKIN_THROTTLE
639 static int tegra_skin_match(struct thermal_zone_device *thz, void *data)
640 {
641         return strcmp((char *)data, thz->type) == 0;
642 }
643
644 static int tegra_skin_get_temp(void *data, long *temp)
645 {
646         struct thermal_zone_device *thz;
647
648         thz = thermal_zone_device_find(data, tegra_skin_match);
649
650         if (!thz || thz->ops->get_temp(thz, temp))
651                 *temp = 25000;
652
653         return 0;
654 }
655
656 static struct therm_est_data skin_data = {
657         .toffset = 9793,
658         .polling_period = 1100,
659         .ndevs = 2,
660         .devs = {
661                         {
662                                 .dev_data = "nct_ext",
663                                 .get_temp = tegra_skin_get_temp,
664                                 .coeffs = {
665                                         2, 1, 1, 1,
666                                         1, 1, 1, 1,
667                                         1, 1, 1, 0,
668                                         1, 1, 0, 0,
669                                         0, 0, -1, -7
670                                 },
671                         },
672                         {
673                                 .dev_data = "nct_int",
674                                 .get_temp = tegra_skin_get_temp,
675                                 .coeffs = {
676                                         -11, -7, -5, -3,
677                                         -3, -2, -1, 0,
678                                         0, 0, 1, 1,
679                                         1, 2, 2, 3,
680                                         4, 6, 11, 18
681                                 },
682                         },
683         },
684         .trip_temp = 43000,
685         .tc1 = 1,
686         .tc2 = 15,
687         .passive_delay = 15000,
688 };
689
690 static struct balanced_throttle skin_throttle = {
691         .throt_tab_size = 6,
692         .throt_tab = {
693                 { 640000, 1200 },
694                 { 640000, 1200 },
695                 { 760000, 1200 },
696                 { 760000, 1200 },
697                 {1000000, 1200 },
698                 {1000000, 1200 },
699         },
700 };
701
702 static int __init dalmore_skin_init(void)
703 {
704         struct thermal_cooling_device *skin_cdev;
705
706         skin_cdev = balanced_throttle_register(&skin_throttle, "dalmore-skin");
707
708         skin_data.cdev = skin_cdev;
709         tegra_skin_therm_est_device.dev.platform_data = &skin_data;
710         platform_device_register(&tegra_skin_therm_est_device);
711
712         return 0;
713 }
714 late_initcall(dalmore_skin_init);
715 #endif
716
717 int __init dalmore_sensors_init(void)
718 {
719         int err;
720
721         tegra_get_board_info(&board_info);
722
723         err = dalmore_nct1008_init();
724         if (err)
725                 return err;
726
727         dalmore_camera_init();
728         mpuirq_init();
729
730         i2c_register_board_info(0, dalmore_i2c_board_info_cm3218,
731                 ARRAY_SIZE(dalmore_i2c_board_info_cm3218));
732
733         i2c_register_board_info(0, bq20z45_pdata,
734                 ARRAY_SIZE(bq20z45_pdata));
735
736         return 0;
737 }