@@ -100,6 +100,7 @@ static int golden_temp_offset;
100
100
101
101
struct lvts_sensor_data {
102
102
int dt_id ;
103
+ u8 cal_offsets [3 ];
103
104
};
104
105
105
106
struct lvts_ctrl_data {
@@ -665,18 +666,25 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
665
666
* <-----ap--tc#3-----> <-----sensor#7-----> <-----sensor#8----->
666
667
* 0x40 | 0x41 | 0x42 | 0x43 | 0x44 | 0x45 | 0x46 | 0x47 | 0x48
667
668
*
668
- * The data description gives the offset of the calibration data in
669
- * this bytes stream for each sensor.
669
+ * Note: In some cases, values don't strictly follow a little endian ordering.
670
+ * The data description gives byte offsets constituting each calibration value
671
+ * for each sensor.
670
672
*/
671
673
static int lvts_calibration_init (struct device * dev , struct lvts_ctrl * lvts_ctrl ,
672
674
const struct lvts_ctrl_data * lvts_ctrl_data ,
673
675
u8 * efuse_calibration )
674
676
{
675
677
int i ;
676
678
677
- for (i = 0 ; i < lvts_ctrl_data -> num_lvts_sensor ; i ++ )
678
- memcpy (& lvts_ctrl -> calibration [i ],
679
- efuse_calibration + lvts_ctrl_data -> cal_offset [i ], 3 );
679
+ for (i = 0 ; i < lvts_ctrl_data -> num_lvts_sensor ; i ++ ) {
680
+ const struct lvts_sensor_data * sensor =
681
+ & lvts_ctrl_data -> lvts_sensor [i ];
682
+
683
+ lvts_ctrl -> calibration [i ] =
684
+ (efuse_calibration [sensor -> cal_offsets [0 ]] << 0 ) +
685
+ (efuse_calibration [sensor -> cal_offsets [1 ]] << 8 ) +
686
+ (efuse_calibration [sensor -> cal_offsets [2 ]] << 16 );
687
+ }
680
688
681
689
return 0 ;
682
690
}
@@ -1299,23 +1307,29 @@ static void lvts_remove(struct platform_device *pdev)
1299
1307
1300
1308
static const struct lvts_ctrl_data mt7988_lvts_ap_data_ctrl [] = {
1301
1309
{
1302
- .cal_offset = { 0x00 , 0x04 , 0x08 , 0x0c },
1303
1310
.lvts_sensor = {
1304
- { .dt_id = MT7988_CPU_0 },
1305
- { .dt_id = MT7988_CPU_1 },
1306
- { .dt_id = MT7988_ETH2P5G_0 },
1307
- { .dt_id = MT7988_ETH2P5G_1 }
1311
+ { .dt_id = MT7988_CPU_0 ,
1312
+ .cal_offsets = { 0x00 , 0x01 , 0x02 } },
1313
+ { .dt_id = MT7988_CPU_1 ,
1314
+ .cal_offsets = { 0x04 , 0x05 , 0x06 } },
1315
+ { .dt_id = MT7988_ETH2P5G_0 ,
1316
+ .cal_offsets = { 0x08 , 0x09 , 0x0a } },
1317
+ { .dt_id = MT7988_ETH2P5G_1 ,
1318
+ .cal_offsets = { 0x0c , 0x0d , 0x0e } }
1308
1319
},
1309
1320
.num_lvts_sensor = 4 ,
1310
1321
.offset = 0x0 ,
1311
1322
},
1312
1323
{
1313
- .cal_offset = { 0x14 , 0x18 , 0x1c , 0x20 },
1314
1324
.lvts_sensor = {
1315
- { .dt_id = MT7988_TOPS_0 },
1316
- { .dt_id = MT7988_TOPS_1 },
1317
- { .dt_id = MT7988_ETHWARP_0 },
1318
- { .dt_id = MT7988_ETHWARP_1 }
1325
+ { .dt_id = MT7988_TOPS_0 ,
1326
+ .cal_offsets = { 0x14 , 0x15 , 0x16 } },
1327
+ { .dt_id = MT7988_TOPS_1 ,
1328
+ .cal_offsets = { 0x18 , 0x19 , 0x1a } },
1329
+ { .dt_id = MT7988_ETHWARP_0 ,
1330
+ .cal_offsets = { 0x1c , 0x1d , 0x1e } },
1331
+ { .dt_id = MT7988_ETHWARP_1 ,
1332
+ .cal_offsets = { 0x20 , 0x21 , 0x22 } }
1319
1333
},
1320
1334
.num_lvts_sensor = 4 ,
1321
1335
.offset = 0x100 ,
@@ -1356,32 +1370,37 @@ static int lvts_resume(struct device *dev)
1356
1370
1357
1371
static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl [] = {
1358
1372
{
1359
- .cal_offset = { 0x04 , 0x08 },
1360
1373
.lvts_sensor = {
1361
- { .dt_id = MT8192_MCU_BIG_CPU0 },
1362
- { .dt_id = MT8192_MCU_BIG_CPU1 }
1374
+ { .dt_id = MT8192_MCU_BIG_CPU0 ,
1375
+ .cal_offsets = { 0x04 , 0x05 , 0x06 } },
1376
+ { .dt_id = MT8192_MCU_BIG_CPU1 ,
1377
+ .cal_offsets = { 0x08 , 0x09 , 0x0a } }
1363
1378
},
1364
1379
.num_lvts_sensor = 2 ,
1365
1380
.offset = 0x0 ,
1366
1381
.mode = LVTS_MSR_FILTERED_MODE ,
1367
1382
},
1368
1383
{
1369
- .cal_offset = { 0x0c , 0x10 },
1370
1384
.lvts_sensor = {
1371
- { .dt_id = MT8192_MCU_BIG_CPU2 },
1372
- { .dt_id = MT8192_MCU_BIG_CPU3 }
1385
+ { .dt_id = MT8192_MCU_BIG_CPU2 ,
1386
+ .cal_offsets = { 0x0c , 0x0d , 0x0e } },
1387
+ { .dt_id = MT8192_MCU_BIG_CPU3 ,
1388
+ .cal_offsets = { 0x10 , 0x11 , 0x12 } }
1373
1389
},
1374
1390
.num_lvts_sensor = 2 ,
1375
1391
.offset = 0x100 ,
1376
1392
.mode = LVTS_MSR_FILTERED_MODE ,
1377
1393
},
1378
1394
{
1379
- .cal_offset = { 0x14 , 0x18 , 0x1c , 0x20 },
1380
1395
.lvts_sensor = {
1381
- { .dt_id = MT8192_MCU_LITTLE_CPU0 },
1382
- { .dt_id = MT8192_MCU_LITTLE_CPU1 },
1383
- { .dt_id = MT8192_MCU_LITTLE_CPU2 },
1384
- { .dt_id = MT8192_MCU_LITTLE_CPU3 }
1396
+ { .dt_id = MT8192_MCU_LITTLE_CPU0 ,
1397
+ .cal_offsets = { 0x14 , 0x15 , 0x16 } },
1398
+ { .dt_id = MT8192_MCU_LITTLE_CPU1 ,
1399
+ .cal_offsets = { 0x18 , 0x19 , 0x1a } },
1400
+ { .dt_id = MT8192_MCU_LITTLE_CPU2 ,
1401
+ .cal_offsets = { 0x1c , 0x1d , 0x1e } },
1402
+ { .dt_id = MT8192_MCU_LITTLE_CPU3 ,
1403
+ .cal_offsets = { 0x20 , 0x21 , 0x22 } }
1385
1404
},
1386
1405
.num_lvts_sensor = 4 ,
1387
1406
.offset = 0x200 ,
@@ -1390,39 +1409,44 @@ static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl[] = {
1390
1409
};
1391
1410
1392
1411
static const struct lvts_ctrl_data mt8192_lvts_ap_data_ctrl [] = {
1393
- {
1394
- .cal_offset = { 0x24 , 0x28 },
1412
+ {
1395
1413
.lvts_sensor = {
1396
- { .dt_id = MT8192_AP_VPU0 },
1397
- { .dt_id = MT8192_AP_VPU1 }
1414
+ { .dt_id = MT8192_AP_VPU0 ,
1415
+ .cal_offsets = { 0x24 , 0x25 , 0x26 } },
1416
+ { .dt_id = MT8192_AP_VPU1 ,
1417
+ .cal_offsets = { 0x28 , 0x29 , 0x2a } }
1398
1418
},
1399
1419
.num_lvts_sensor = 2 ,
1400
1420
.offset = 0x0 ,
1401
1421
},
1402
1422
{
1403
- .cal_offset = { 0x2c , 0x30 },
1404
1423
.lvts_sensor = {
1405
- { .dt_id = MT8192_AP_GPU0 },
1406
- { .dt_id = MT8192_AP_GPU1 }
1424
+ { .dt_id = MT8192_AP_GPU0 ,
1425
+ .cal_offsets = { 0x2c , 0x2d , 0x2e } },
1426
+ { .dt_id = MT8192_AP_GPU1 ,
1427
+ .cal_offsets = { 0x30 , 0x31 , 0x32 } }
1407
1428
},
1408
1429
.num_lvts_sensor = 2 ,
1409
1430
.offset = 0x100 ,
1410
1431
},
1411
1432
{
1412
- .cal_offset = { 0x34 , 0x38 },
1413
1433
.lvts_sensor = {
1414
- { .dt_id = MT8192_AP_INFRA },
1415
- { .dt_id = MT8192_AP_CAM },
1434
+ { .dt_id = MT8192_AP_INFRA ,
1435
+ .cal_offsets = { 0x34 , 0x35 , 0x36 } },
1436
+ { .dt_id = MT8192_AP_CAM ,
1437
+ .cal_offsets = { 0x38 , 0x39 , 0x3a } },
1416
1438
},
1417
1439
.num_lvts_sensor = 2 ,
1418
1440
.offset = 0x200 ,
1419
1441
},
1420
1442
{
1421
- .cal_offset = { 0x3c , 0x40 , 0x44 },
1422
1443
.lvts_sensor = {
1423
- { .dt_id = MT8192_AP_MD0 },
1424
- { .dt_id = MT8192_AP_MD1 },
1425
- { .dt_id = MT8192_AP_MD2 }
1444
+ { .dt_id = MT8192_AP_MD0 ,
1445
+ .cal_offsets = { 0x3c , 0x3d , 0x3e } },
1446
+ { .dt_id = MT8192_AP_MD1 ,
1447
+ .cal_offsets = { 0x40 , 0x41 , 0x42 } },
1448
+ { .dt_id = MT8192_AP_MD2 ,
1449
+ .cal_offsets = { 0x44 , 0x45 , 0x46 } }
1426
1450
},
1427
1451
.num_lvts_sensor = 3 ,
1428
1452
.offset = 0x300 ,
@@ -1431,70 +1455,80 @@ static const struct lvts_ctrl_data mt8192_lvts_ap_data_ctrl[] = {
1431
1455
1432
1456
static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl [] = {
1433
1457
{
1434
- .cal_offset = { 0x04 , 0x07 },
1435
1458
.lvts_sensor = {
1436
- { .dt_id = MT8195_MCU_BIG_CPU0 },
1437
- { .dt_id = MT8195_MCU_BIG_CPU1 }
1459
+ { .dt_id = MT8195_MCU_BIG_CPU0 ,
1460
+ .cal_offsets = { 0x04 , 0x05 , 0x06 } },
1461
+ { .dt_id = MT8195_MCU_BIG_CPU1 ,
1462
+ .cal_offsets = { 0x07 , 0x08 , 0x09 } }
1438
1463
},
1439
1464
.num_lvts_sensor = 2 ,
1440
1465
.offset = 0x0 ,
1441
1466
},
1442
1467
{
1443
- .cal_offset = { 0x0d , 0x10 },
1444
1468
.lvts_sensor = {
1445
- { .dt_id = MT8195_MCU_BIG_CPU2 },
1446
- { .dt_id = MT8195_MCU_BIG_CPU3 }
1469
+ { .dt_id = MT8195_MCU_BIG_CPU2 ,
1470
+ .cal_offsets = { 0x0d , 0x0e , 0x0f } },
1471
+ { .dt_id = MT8195_MCU_BIG_CPU3 ,
1472
+ .cal_offsets = { 0x10 , 0x11 , 0x12 } }
1447
1473
},
1448
1474
.num_lvts_sensor = 2 ,
1449
1475
.offset = 0x100 ,
1450
1476
},
1451
1477
{
1452
- .cal_offset = { 0x16 , 0x19 , 0x1c , 0x1f },
1453
1478
.lvts_sensor = {
1454
- { .dt_id = MT8195_MCU_LITTLE_CPU0 },
1455
- { .dt_id = MT8195_MCU_LITTLE_CPU1 },
1456
- { .dt_id = MT8195_MCU_LITTLE_CPU2 },
1457
- { .dt_id = MT8195_MCU_LITTLE_CPU3 }
1479
+ { .dt_id = MT8195_MCU_LITTLE_CPU0 ,
1480
+ .cal_offsets = { 0x16 , 0x17 , 0x18 } },
1481
+ { .dt_id = MT8195_MCU_LITTLE_CPU1 ,
1482
+ .cal_offsets = { 0x19 , 0x1a , 0x1b } },
1483
+ { .dt_id = MT8195_MCU_LITTLE_CPU2 ,
1484
+ .cal_offsets = { 0x1c , 0x1d , 0x1e } },
1485
+ { .dt_id = MT8195_MCU_LITTLE_CPU3 ,
1486
+ .cal_offsets = { 0x1f , 0x20 , 0x21 } }
1458
1487
},
1459
1488
.num_lvts_sensor = 4 ,
1460
1489
.offset = 0x200 ,
1461
1490
}
1462
1491
};
1463
1492
1464
1493
static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl [] = {
1465
- {
1466
- .cal_offset = { 0x25 , 0x28 },
1494
+ {
1467
1495
.lvts_sensor = {
1468
- { .dt_id = MT8195_AP_VPU0 },
1469
- { .dt_id = MT8195_AP_VPU1 }
1496
+ { .dt_id = MT8195_AP_VPU0 ,
1497
+ .cal_offsets = { 0x25 , 0x26 , 0x27 } },
1498
+ { .dt_id = MT8195_AP_VPU1 ,
1499
+ .cal_offsets = { 0x28 , 0x29 , 0x2a } }
1470
1500
},
1471
1501
.num_lvts_sensor = 2 ,
1472
1502
.offset = 0x0 ,
1473
1503
},
1474
1504
{
1475
- .cal_offset = { 0x2e , 0x31 },
1476
1505
.lvts_sensor = {
1477
- { .dt_id = MT8195_AP_GPU0 },
1478
- { .dt_id = MT8195_AP_GPU1 }
1506
+ { .dt_id = MT8195_AP_GPU0 ,
1507
+ .cal_offsets = { 0x2e , 0x2f , 0x30 } },
1508
+ { .dt_id = MT8195_AP_GPU1 ,
1509
+ .cal_offsets = { 0x31 , 0x32 , 0x33 } }
1479
1510
},
1480
1511
.num_lvts_sensor = 2 ,
1481
1512
.offset = 0x100 ,
1482
1513
},
1483
1514
{
1484
- .cal_offset = { 0x37 , 0x3a , 0x3d },
1485
1515
.lvts_sensor = {
1486
- { .dt_id = MT8195_AP_VDEC },
1487
- { .dt_id = MT8195_AP_IMG },
1488
- { .dt_id = MT8195_AP_INFRA },
1516
+ { .dt_id = MT8195_AP_VDEC ,
1517
+ .cal_offsets = { 0x37 , 0x38 , 0x39 } },
1518
+ { .dt_id = MT8195_AP_IMG ,
1519
+ .cal_offsets = { 0x3a , 0x3b , 0x3c } },
1520
+ { .dt_id = MT8195_AP_INFRA ,
1521
+ .cal_offsets = { 0x3d , 0x3e , 0x3f } }
1489
1522
},
1490
1523
.num_lvts_sensor = 3 ,
1491
1524
.offset = 0x200 ,
1492
1525
},
1493
1526
{
1494
- .cal_offset = { 0x43 , 0x46 },
1495
1527
.lvts_sensor = {
1496
- { .dt_id = MT8195_AP_CAM0 },
1497
- { .dt_id = MT8195_AP_CAM1 }
1528
+ { .dt_id = MT8195_AP_CAM0 ,
1529
+ .cal_offsets = { 0x43 , 0x44 , 0x45 } },
1530
+ { .dt_id = MT8195_AP_CAM1 ,
1531
+ .cal_offsets = { 0x46 , 0x47 , 0x48 } }
1498
1532
},
1499
1533
.num_lvts_sensor = 2 ,
1500
1534
.offset = 0x300 ,
0 commit comments