@@ -100,6 +100,7 @@ static int golden_temp_offset;
100100
101101struct lvts_sensor_data {
102102 int dt_id ;
103+ u8 cal_offsets [3 ];
103104};
104105
105106struct lvts_ctrl_data {
@@ -665,18 +666,25 @@ static int lvts_sensor_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
665666 * <-----ap--tc#3-----> <-----sensor#7-----> <-----sensor#8----->
666667 * 0x40 | 0x41 | 0x42 | 0x43 | 0x44 | 0x45 | 0x46 | 0x47 | 0x48
667668 *
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.
670672 */
671673static int lvts_calibration_init (struct device * dev , struct lvts_ctrl * lvts_ctrl ,
672674 const struct lvts_ctrl_data * lvts_ctrl_data ,
673675 u8 * efuse_calibration )
674676{
675677 int i ;
676678
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+ }
680688
681689 return 0 ;
682690}
@@ -1299,23 +1307,29 @@ static void lvts_remove(struct platform_device *pdev)
12991307
13001308static const struct lvts_ctrl_data mt7988_lvts_ap_data_ctrl [] = {
13011309 {
1302- .cal_offset = { 0x00 , 0x04 , 0x08 , 0x0c },
13031310 .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 } }
13081319 },
13091320 .num_lvts_sensor = 4 ,
13101321 .offset = 0x0 ,
13111322 },
13121323 {
1313- .cal_offset = { 0x14 , 0x18 , 0x1c , 0x20 },
13141324 .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 } }
13191333 },
13201334 .num_lvts_sensor = 4 ,
13211335 .offset = 0x100 ,
@@ -1356,32 +1370,37 @@ static int lvts_resume(struct device *dev)
13561370
13571371static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl [] = {
13581372 {
1359- .cal_offset = { 0x04 , 0x08 },
13601373 .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 } }
13631378 },
13641379 .num_lvts_sensor = 2 ,
13651380 .offset = 0x0 ,
13661381 .mode = LVTS_MSR_FILTERED_MODE ,
13671382 },
13681383 {
1369- .cal_offset = { 0x0c , 0x10 },
13701384 .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 } }
13731389 },
13741390 .num_lvts_sensor = 2 ,
13751391 .offset = 0x100 ,
13761392 .mode = LVTS_MSR_FILTERED_MODE ,
13771393 },
13781394 {
1379- .cal_offset = { 0x14 , 0x18 , 0x1c , 0x20 },
13801395 .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 } }
13851404 },
13861405 .num_lvts_sensor = 4 ,
13871406 .offset = 0x200 ,
@@ -1390,39 +1409,44 @@ static const struct lvts_ctrl_data mt8192_lvts_mcu_data_ctrl[] = {
13901409};
13911410
13921411static const struct lvts_ctrl_data mt8192_lvts_ap_data_ctrl [] = {
1393- {
1394- .cal_offset = { 0x24 , 0x28 },
1412+ {
13951413 .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 } }
13981418 },
13991419 .num_lvts_sensor = 2 ,
14001420 .offset = 0x0 ,
14011421 },
14021422 {
1403- .cal_offset = { 0x2c , 0x30 },
14041423 .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 } }
14071428 },
14081429 .num_lvts_sensor = 2 ,
14091430 .offset = 0x100 ,
14101431 },
14111432 {
1412- .cal_offset = { 0x34 , 0x38 },
14131433 .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 } },
14161438 },
14171439 .num_lvts_sensor = 2 ,
14181440 .offset = 0x200 ,
14191441 },
14201442 {
1421- .cal_offset = { 0x3c , 0x40 , 0x44 },
14221443 .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 } }
14261450 },
14271451 .num_lvts_sensor = 3 ,
14281452 .offset = 0x300 ,
@@ -1431,70 +1455,80 @@ static const struct lvts_ctrl_data mt8192_lvts_ap_data_ctrl[] = {
14311455
14321456static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl [] = {
14331457 {
1434- .cal_offset = { 0x04 , 0x07 },
14351458 .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 } }
14381463 },
14391464 .num_lvts_sensor = 2 ,
14401465 .offset = 0x0 ,
14411466 },
14421467 {
1443- .cal_offset = { 0x0d , 0x10 },
14441468 .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 } }
14471473 },
14481474 .num_lvts_sensor = 2 ,
14491475 .offset = 0x100 ,
14501476 },
14511477 {
1452- .cal_offset = { 0x16 , 0x19 , 0x1c , 0x1f },
14531478 .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 } }
14581487 },
14591488 .num_lvts_sensor = 4 ,
14601489 .offset = 0x200 ,
14611490 }
14621491};
14631492
14641493static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl [] = {
1465- {
1466- .cal_offset = { 0x25 , 0x28 },
1494+ {
14671495 .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 } }
14701500 },
14711501 .num_lvts_sensor = 2 ,
14721502 .offset = 0x0 ,
14731503 },
14741504 {
1475- .cal_offset = { 0x2e , 0x31 },
14761505 .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 } }
14791510 },
14801511 .num_lvts_sensor = 2 ,
14811512 .offset = 0x100 ,
14821513 },
14831514 {
1484- .cal_offset = { 0x37 , 0x3a , 0x3d },
14851515 .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 } }
14891522 },
14901523 .num_lvts_sensor = 3 ,
14911524 .offset = 0x200 ,
14921525 },
14931526 {
1494- .cal_offset = { 0x43 , 0x46 },
14951527 .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 } }
14981532 },
14991533 .num_lvts_sensor = 2 ,
15001534 .offset = 0x300 ,
0 commit comments