1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
|
/*
* arch/arm/mach-tegra/board-roth-sensors.c
*
* Copyright (c) 2012-2013 NVIDIA CORPORATION, All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of NVIDIA CORPORATION nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/i2c.h>
#include <linux/delay.h>
#include <linux/mpu.h>
#include <linux/gpio.h>
#include <linux/therm_est.h>
#include <linux/nct1008.h>
#include <mach/edp.h>
#include <mach/gpio-tegra.h>
#include <mach/pinmux-t11.h>
#include <mach/pinmux.h>
#include <generated/mach-types.h>
#include "gpio-names.h"
#include "board.h"
#include "board-common.h"
#include "board-roth.h"
#include "cpu-tegra.h"
#include "devices.h"
#include "tegra-board-id.h"
#include "dvfs.h"
static struct board_info board_info;
static struct throttle_table tj_throttle_table[] = {
/* CPU_THROT_LOW cannot be used by other than CPU */
/* NO_CAP cannot be used by CPU */
/* CPU, C2BUS, C3BUS, SCLK, EMC */
{ { 1530000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1428000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1326000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1224000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1122000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1020000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 918000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 816000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 714000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 612000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 612000, 564000, 564000, NO_CAP, NO_CAP } },
{ { 612000, 528000, 528000, NO_CAP, NO_CAP } },
{ { 612000, 492000, 492000, NO_CAP, NO_CAP } },
{ { 612000, 420000, 420000, NO_CAP, NO_CAP } },
{ { 612000, 408000, 408000, NO_CAP, NO_CAP } },
{ { 612000, 360000, 360000, NO_CAP, NO_CAP } },
{ { 612000, 360000, 360000, 312000, NO_CAP } },
{ { 510000, 360000, 360000, 312000, 480000 } },
{ { 468000, 360000, 360000, 312000, 480000 } },
{ { 468000, 276000, 276000, 208000, 480000 } },
{ { 372000, 276000, 276000, 208000, 204000 } },
{ { 288000, 276000, 276000, 208000, 204000 } },
{ { 252000, 276000, 228000, 208000, 102000 } },
{ { 204000, 276000, 228000, 208000, 102000 } },
{ { 102000, 276000, 228000, 208000, 102000 } },
{ { CPU_THROT_LOW, 276000, 228000, 208000, 102000 } },
};
static struct balanced_throttle tj_throttle = {
.throt_tab_size = ARRAY_SIZE(tj_throttle_table),
.throt_tab = tj_throttle_table,
};
static int __init roth_throttle_init(void)
{
if (machine_is_roth())
balanced_throttle_register(&tj_throttle, "tegra-balanced");
return 0;
}
module_init(roth_throttle_init);
static struct nct1008_platform_data roth_nct1008_pdata = {
.supported_hwrev = true,
.ext_range = true,
.conv_rate = 0x08,
.offset = 0,
.shutdown_ext_limit = 85, /* C */
.shutdown_local_limit = 120, /* C */
.loc_name = "soc",
.passive_delay = 2000,
.num_trips = 1,
.trips = {
/* Thermal Throttling */
[0] = {
.cdev_type = "tegra-balanced",
.trip_temp = 75000,
.trip_type = THERMAL_TRIP_PASSIVE,
.upper = THERMAL_NO_LIMIT,
.lower = THERMAL_NO_LIMIT,
.hysteresis = 0,
},
},
};
static struct nct1008_platform_data roth_nct1008_left_pdata = {
.supported_hwrev = true,
.ext_range = true,
.conv_rate = 0x08,
.offset = 0,
.loc_name = "left",
.shutdown_ext_limit = 90, /* C */
.shutdown_local_limit = 120, /* C */
};
static struct nct1008_platform_data roth_nct1008_right_pdata = {
.supported_hwrev = true,
.ext_range = true,
.conv_rate = 0x08,
.offset = 0,
.loc_name = "right",
.shutdown_ext_limit = 90, /* C */
.shutdown_local_limit = 120, /* C */
};
static struct i2c_board_info roth_i2c4_nct1008_board_info[] = {
{
I2C_BOARD_INFO("nct1008", 0x4C),
.platform_data = &roth_nct1008_pdata,
.irq = -1,
}
};
static struct i2c_board_info roth_i2c4_nct1008_lr_board_info[] = {
{
I2C_BOARD_INFO("nct1008", 0x4C),
.platform_data = &roth_nct1008_left_pdata,
.irq = -1,
},
{
I2C_BOARD_INFO("nct1008", 0x4D),
.platform_data = &roth_nct1008_right_pdata,
.irq = -1,
}
};
#define VI_PINMUX(_pingroup, _mux, _pupd, _tri, _io, _lock, _ioreset) \
{ \
.pingroup = TEGRA_PINGROUP_##_pingroup, \
.func = TEGRA_MUX_##_mux, \
.pupd = TEGRA_PUPD_##_pupd, \
.tristate = TEGRA_TRI_##_tri, \
.io = TEGRA_PIN_##_io, \
.lock = TEGRA_PIN_LOCK_##_lock, \
.od = TEGRA_PIN_OD_DEFAULT, \
.ioreset = TEGRA_PIN_IO_RESET_##_ioreset \
}
/* MPU board file definition */
static struct mpu_platform_data mpu6050_gyro_data = {
.int_config = 0x10,
.level_shifter = 0,
/* Located in board_[platformname].h */
.orientation = MPU_GYRO_ORIENTATION,
.sec_slave_type = SECONDARY_SLAVE_TYPE_NONE,
.key = {0x4E, 0xCC, 0x7E, 0xEB, 0xF6, 0x1E, 0x35, 0x22,
0x00, 0x34, 0x0D, 0x65, 0x32, 0xE9, 0x94, 0x89},
};
static struct i2c_board_info __initdata inv_mpu6050_i2c2_board_info[] = {
{
I2C_BOARD_INFO(MPU_GYRO_NAME, MPU_GYRO_ADDR),
.platform_data = &mpu6050_gyro_data,
},
};
static void mpuirq_init(void)
{
int ret = 0;
unsigned gyro_irq_gpio = MPU_GYRO_IRQ_GPIO;
unsigned gyro_bus_num = MPU_GYRO_BUS_NUM;
char *gyro_name = MPU_GYRO_NAME;
pr_info("*** MPU START *** mpuirq_init...\n");
ret = gpio_request(gyro_irq_gpio, gyro_name);
if (ret < 0) {
pr_err("%s: gpio_request failed %d\n", __func__, ret);
return;
}
ret = gpio_direction_input(gyro_irq_gpio);
if (ret < 0) {
pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
gpio_free(gyro_irq_gpio);
return;
}
pr_info("*** MPU END *** mpuirq_init...\n");
inv_mpu6050_i2c2_board_info[0].irq = gpio_to_irq(MPU_GYRO_IRQ_GPIO);
i2c_register_board_info(gyro_bus_num, inv_mpu6050_i2c2_board_info,
ARRAY_SIZE(inv_mpu6050_i2c2_board_info));
}
static int roth_nct1008_init(void)
{
int nct1008_port = TEGRA_GPIO_PX6;
int ret = 0;
tegra_platform_edp_init(roth_nct1008_pdata.trips,
&roth_nct1008_pdata.num_trips);
tegra_add_cdev_trips(roth_nct1008_pdata.trips,
&roth_nct1008_pdata.num_trips);
tegra_add_tj_trips(roth_nct1008_pdata.trips,
&roth_nct1008_pdata.num_trips);
roth_i2c4_nct1008_board_info[0].irq = gpio_to_irq(nct1008_port);
pr_info("%s: roth nct1008 irq %d", __func__, \
roth_i2c4_nct1008_board_info[0].irq);
ret = gpio_request(nct1008_port, "temp_alert");
if (ret < 0)
return ret;
ret = gpio_direction_input(nct1008_port);
if (ret < 0) {
pr_info("%s: calling gpio_free(nct1008_port)", __func__);
gpio_free(nct1008_port);
}
/* roth has thermal sensor on GEN1-I2C i.e. instance 0 */
i2c_register_board_info(0, roth_i2c4_nct1008_board_info,
ARRAY_SIZE(roth_i2c4_nct1008_board_info));
i2c_register_board_info(1, roth_i2c4_nct1008_lr_board_info,
ARRAY_SIZE(roth_i2c4_nct1008_lr_board_info));
return ret;
}
static struct i2c_board_info __initdata bq20z45_pdata[] = {
{
I2C_BOARD_INFO("sbs-battery", 0x0B),
},
};
#ifdef CONFIG_TEGRA_SKIN_THROTTLE
static int tegra_skin_match(struct thermal_zone_device *thz, void *data)
{
return strcmp((char *)data, thz->type) == 0;
}
static int tegra_skin_get_temp(void *data, long *temp)
{
struct thermal_zone_device *thz;
thz = thermal_zone_device_find(data, tegra_skin_match);
if (!thz || thz->ops->get_temp(thz, temp))
*temp = 25000;
return 0;
}
static struct therm_est_data skin_data = {
.cdev_type = "skin-balanced",
.toffset = 9793,
.polling_period = 1100,
.ndevs = 2,
.tc1 = 5,
.tc2 = 1,
.devs = {
{
.dev_data = "nct_ext",
.get_temp = tegra_skin_get_temp,
.coeffs = {
2, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 0,
1, 1, 0, 0,
0, 0, -1, -7
},
},
{
.dev_data = "nct_int",
.get_temp = tegra_skin_get_temp,
.coeffs = {
-11, -7, -5, -3,
-3, -2, -1, 0,
0, 0, 1, 1,
1, 2, 2, 3,
4, 6, 11, 18
},
},
},
.trip_temp = 43000,
.passive_delay = 5000,
};
static struct throttle_table skin_throttle_table[] = {
/* CPU_THROT_LOW cannot be used by other than CPU */
/* NO_CAP cannot be used by CPU */
/* CPU, C2BUS, C3BUS, SCLK, EMC */
{ { 1530000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1530000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1326000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1326000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1326000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1326000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1326000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1122000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1122000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1122000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1122000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1122000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1122000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1020000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1020000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1020000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1020000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1020000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 1020000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 918000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 918000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 918000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 918000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 918000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 918000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 816000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 816000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 816000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 816000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 816000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 816000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 714000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 714000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 714000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 714000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 714000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 714000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 612000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 612000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 612000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 612000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 612000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 612000, NO_CAP, NO_CAP, NO_CAP, NO_CAP } },
{ { 612000, 564000, 564000, NO_CAP, NO_CAP } },
{ { 612000, 564000, 564000, NO_CAP, NO_CAP } },
{ { 612000, 528000, 528000, NO_CAP, NO_CAP } },
{ { 612000, 528000, 528000, NO_CAP, NO_CAP } },
{ { 612000, 492000, 492000, NO_CAP, NO_CAP } },
{ { 612000, 492000, 492000, NO_CAP, NO_CAP } },
{ { 612000, 420000, 420000, NO_CAP, NO_CAP } },
{ { 612000, 420000, 420000, NO_CAP, NO_CAP } },
{ { 612000, 408000, 408000, NO_CAP, NO_CAP } },
{ { 612000, 408000, 408000, NO_CAP, NO_CAP } },
{ { 612000, 360000, 360000, NO_CAP, NO_CAP } },
{ { 612000, 360000, 360000, NO_CAP, NO_CAP } },
{ { 510000, 360000, 360000, 312000, NO_CAP } },
{ { 510000, 360000, 360000, 312000, NO_CAP } },
{ { 510000, 360000, 360000, 312000, 480000 } },
{ { 510000, 360000, 360000, 312000, 480000 } },
{ { 510000, 360000, 360000, 312000, 480000 } },
{ { 510000, 360000, 360000, 312000, 480000 } },
{ { 510000, 360000, 360000, 312000, 480000 } },
{ { 510000, 360000, 360000, 312000, 480000 } },
{ { 468000, 360000, 360000, 312000, 480000 } },
{ { 468000, 360000, 360000, 312000, 480000 } },
{ { 468000, 276000, 276000, 208000, 480000 } },
{ { 468000, 276000, 276000, 208000, 480000 } },
{ { 372000, 276000, 276000, 208000, 204000 } },
{ { 372000, 276000, 276000, 208000, 204000 } },
{ { 288000, 276000, 276000, 208000, 204000 } },
{ { 288000, 276000, 276000, 208000, 204000 } },
{ { 252000, 276000, 228000, 208000, 102000 } },
{ { 252000, 276000, 228000, 208000, 102000 } },
{ { 204000, 276000, 228000, 208000, 102000 } },
{ { 204000, 276000, 228000, 208000, 102000 } },
{ { 102000, 276000, 228000, 208000, 102000 } },
{ { CPU_THROT_LOW, 276000, 228000, 208000, 102000 } },
};
static struct balanced_throttle skin_throttle = {
.throt_tab_size = ARRAY_SIZE(skin_throttle_table),
.throt_tab = skin_throttle_table,
};
static int __init roth_skin_init(void)
{
if (machine_is_roth()) {
balanced_throttle_register(&skin_throttle, "skin-balanced");
tegra_skin_therm_est_device.dev.platform_data = &skin_data;
platform_device_register(&tegra_skin_therm_est_device);
}
return 0;
}
late_initcall(roth_skin_init);
#endif
static int roth_fan_est_match(struct thermal_zone_device *thz, void *data)
{
return (strcmp((char *)data, thz->type) == 0);
}
static int roth_fan_est_get_temp(void *data, long *temp)
{
struct thermal_zone_device *thz;
thz = thermal_zone_device_find(data, roth_fan_est_match);
if (!thz || thz->ops->get_temp(thz, temp))
*temp = 25000;
return 0;
}
static struct therm_fan_est_data fan_est_data = {
.toffset = 0,
.polling_period = 1100,
.ndevs = 2,
.devs = {
{
.dev_data = "nct_ext_soc",
.get_temp = roth_fan_est_get_temp,
.coeffs = {
100, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0
},
},
{
.dev_data = "nct_int_soc",
.get_temp = roth_fan_est_get_temp,
.coeffs = {
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0
},
},
},
.active_trip_temps = {57000, 58000, 59000, 60000, 61000, 62000, 63000,
64000, 65000, 68000},
};
static struct platform_device roth_fan_therm_est_device = {
.name = "therm-fan-est",
.id = -1,
.num_resources = 0,
.dev = {
.platform_data = &fan_est_data,
},
};
static int __init roth_fan_est_init(void)
{
platform_device_register(&roth_fan_therm_est_device);
return 0;
}
int __init roth_sensors_init(void)
{
int err;
tegra_get_board_info(&board_info);
err = roth_nct1008_init();
if (err)
return err;
mpuirq_init();
roth_fan_est_init();
if (0)
i2c_register_board_info(0, bq20z45_pdata,
ARRAY_SIZE(bq20z45_pdata));
return 0;
}
|