Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: magnetometer: yas530: Add YAS537 variant

Add support for the magnetometer Yamaha YAS537. The additions are based on
comparison of Yamaha Android kernel drivers for YAS532 [1] and YAS537 [2].

In the Yamaha YAS537 Android driver, there is an overflow/underflow control
implemented. For regular usage, this seems not necessary. A similar overflow/
underflow control of Yamaha YAS530/532 Android driver isn't integrated in the
mainline driver. It is therefore skipped for YAS537 in the mainline too.

Also in the Yamaha YAS537 Android driver, at the end of the reset_yas537()
function, a measurement is saved in "last_after_rcoil". Later on, this is
compared to current measurements. If the difference gets too big, a new
reset is initialized. The difference in measurements needs to be quite big,
it's hard to say if this is necessary for regular operation. Therefore this
isn't integrated in the mainline driver either.

[1] https://github.com/msm8916-mainline/android_kernel_qcom_msm8916/blob/GT-I9195I/drivers/iio/magnetometer/yas_mag_drv-yas532.c
[2] https://github.com/msm8916-mainline/android_kernel_qcom_msm8916/blob/GT-I9195I/drivers/iio/magnetometer/yas_mag_drv-yas537.c

Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/264c6488733a5c32089c9ab406a5bcb808c48fef.1660337264.git.jahau@rocketmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Jakob Hauser and committed by
Jonathan Cameron
65f79b50 059ff0f9

+423 -3
+2 -2
drivers/iio/magnetometer/Kconfig
··· 216 216 select IIO_TRIGGERED_BUFFER 217 217 help 218 218 Say Y here to add support for the Yamaha YAS530 series of 219 - 3-Axis Magnetometers. Right now YAS530, YAS532 and YAS533 are 220 - fully supported. 219 + 3-Axis Magnetometers. YAS530, YAS532, YAS533 and YAS537 are 220 + supported. 221 221 222 222 This driver can also be compiled as a module. 223 223 To compile this driver as a module, choose M here: the module
+421 -1
drivers/iio/magnetometer/yamaha-yas530.c
··· 17 17 * named "inv_compass" in the Tegra Android kernel tree. 18 18 * Copyright (C) 2012 InvenSense Corporation 19 19 * 20 + * Code functions for YAS537 based on Yamaha Android kernel driver. 21 + * Copyright (c) 2014 Yamaha Corporation 22 + * 20 23 * Author: Linus Walleij <linus.walleij@linaro.org> 21 24 */ 22 25 #include <linux/bitfield.h> ··· 35 32 #include <linux/regmap.h> 36 33 #include <linux/regulator/consumer.h> 37 34 #include <linux/random.h> 35 + #include <linux/units.h> 38 36 39 37 #include <linux/iio/buffer.h> 40 38 #include <linux/iio/iio.h> ··· 60 56 #define YAS530_TEST2 0x89 61 57 #define YAS530_CAL 0x90 62 58 59 + /* Registers used by YAS537 */ 60 + #define YAS537_MEASURE 0x81 /* Originally YAS537_REG_CMDR */ 61 + #define YAS537_CONFIG 0x82 /* Originally YAS537_REG_CONFR */ 62 + #define YAS537_MEASURE_INTERVAL 0x83 /* Originally YAS537_REG_INTRVLR */ 63 + #define YAS537_OFFSET_X 0x84 /* Originally YAS537_REG_OXR */ 64 + #define YAS537_OFFSET_Y1 0x85 /* Originally YAS537_REG_OY1R */ 65 + #define YAS537_OFFSET_Y2 0x86 /* Originally YAS537_REG_OY2R */ 66 + #define YAS537_AVR 0x87 67 + #define YAS537_HCK 0x88 68 + #define YAS537_LCK 0x89 69 + #define YAS537_SRST 0x90 70 + #define YAS537_ADCCAL 0x91 71 + #define YAS537_MTC 0x93 72 + #define YAS537_OC 0x9E 73 + #define YAS537_TRM 0x9F 74 + #define YAS537_CAL 0xC0 75 + 63 76 /* Bits in the YAS5xx config register */ 64 77 #define YAS5XX_CONFIG_INTON BIT(0) /* Interrupt on? */ 65 78 #define YAS5XX_CONFIG_INTHACT BIT(1) /* Interrupt active high? */ ··· 88 67 #define YAS5XX_MEASURE_LDTC BIT(1) 89 68 #define YAS5XX_MEASURE_FORS BIT(2) 90 69 #define YAS5XX_MEASURE_DLYMES BIT(4) 70 + #define YAS5XX_MEASURE_CONT BIT(5) 91 71 92 72 /* Bits in the measure data register */ 93 73 #define YAS5XX_MEASURE_DATA_BUSY BIT(7) ··· 113 91 #define YAS532_DATA_CENTER BIT(YAS532_DATA_BITS - 1) 114 92 #define YAS532_DATA_OVERFLOW (BIT(YAS532_DATA_BITS) - 1) 115 93 94 + #define YAS537_DEVICE_ID 0x07 /* YAS537 (MS-3T) */ 95 + #define YAS537_VERSION_0 0 /* Version naming unknown */ 96 + #define YAS537_VERSION_1 1 /* Version naming unknown */ 97 + #define YAS537_MAG_AVERAGE_32_MASK GENMASK(6, 4) 98 + #define YAS537_MEASURE_TIME_WORST_US 1500 99 + #define YAS537_DEFAULT_SENSOR_DELAY_MS 50 100 + #define YAS537_MAG_RCOIL_TIME_US 65 101 + #define YAS537_MTC3_MASK_PREP GENMASK(7, 0) 102 + #define YAS537_MTC3_MASK_GET GENMASK(7, 5) 103 + #define YAS537_MTC3_ADD_BIT BIT(4) 104 + #define YAS537_HCK_MASK_PREP GENMASK(4, 0) 105 + #define YAS537_HCK_MASK_GET GENMASK(7, 4) 106 + #define YAS537_LCK_MASK_PREP GENMASK(4, 0) 107 + #define YAS537_LCK_MASK_GET GENMASK(3, 0) 108 + #define YAS537_OC_MASK_GET GENMASK(5, 0) 109 + 116 110 /* Turn off device regulators etc after 5 seconds of inactivity */ 117 111 #define YAS5XX_AUTOSUSPEND_DELAY_MS 5000 118 112 ··· 136 98 yas530, 137 99 yas532, 138 100 yas533, 101 + yas537, 139 102 }; 140 103 141 104 static const int yas530_volatile_reg[] = { 142 105 YAS530_ACTUATE_INIT_COIL, 143 106 YAS530_MEASURE, 107 + }; 108 + 109 + static const int yas537_volatile_reg[] = { 110 + YAS537_MEASURE, 144 111 }; 145 112 146 113 struct yas5xx_calibration { ··· 181 138 * @power_on: function pointer to power-on procedure 182 139 * 183 140 * The "t_ref" value for YAS532/533 is known from the Android driver. 184 - * For YAS530 it was approximately measured. 141 + * For YAS530 and YAS537 it was approximately measured. 185 142 * 186 143 * The temperatures "min_temp_x10" are derived from the temperature resolutions 187 144 * given in the data sheets. ··· 355 312 return ret; 356 313 } 357 314 315 + /** 316 + * yas537_measure() - Make a measure from the hardware 317 + * @yas5xx: The device state 318 + * @t: the raw temperature measurement 319 + * @x: the raw x axis measurement 320 + * @y1: the y1 axis measurement 321 + * @y2: the y2 axis measurement 322 + * @return: 0 on success or error code 323 + */ 324 + static int yas537_measure(struct yas5xx *yas5xx, u16 *t, u16 *x, u16 *y1, u16 *y2) 325 + { 326 + struct yas5xx_calibration *c = &yas5xx->calibration; 327 + unsigned int busy; 328 + u8 data[8]; 329 + u16 xy1y2[3]; 330 + s32 h[3], s[3]; 331 + int i, ret; 332 + 333 + mutex_lock(&yas5xx->lock); 334 + 335 + /* Contrary to YAS530/532, also a "cont" bit is set, meaning unknown */ 336 + ret = regmap_write(yas5xx->map, YAS537_MEASURE, YAS5XX_MEASURE_START | 337 + YAS5XX_MEASURE_CONT); 338 + if (ret < 0) 339 + goto out_unlock; 340 + 341 + /* Use same timeout like YAS530/532 but the bit is in data row 2 */ 342 + ret = regmap_read_poll_timeout(yas5xx->map, YAS5XX_MEASURE_DATA + 2, busy, 343 + !(busy & YAS5XX_MEASURE_DATA_BUSY), 344 + 500, 20000); 345 + if (ret) { 346 + dev_err(yas5xx->dev, "timeout waiting for measurement\n"); 347 + goto out_unlock; 348 + } 349 + 350 + ret = regmap_bulk_read(yas5xx->map, YAS5XX_MEASURE_DATA, 351 + data, sizeof(data)); 352 + if (ret) 353 + goto out_unlock; 354 + 355 + mutex_unlock(&yas5xx->lock); 356 + 357 + *t = get_unaligned_be16(&data[0]); 358 + xy1y2[0] = FIELD_GET(GENMASK(13, 0), get_unaligned_be16(&data[2])); 359 + xy1y2[1] = get_unaligned_be16(&data[4]); 360 + xy1y2[2] = get_unaligned_be16(&data[6]); 361 + 362 + /* The second version of YAS537 needs to include calibration coefficients */ 363 + if (yas5xx->version == YAS537_VERSION_1) { 364 + for (i = 0; i < 3; i++) 365 + s[i] = xy1y2[i] - BIT(13); 366 + h[0] = (c->k * (128 * s[0] + c->a2 * s[1] + c->a3 * s[2])) / BIT(13); 367 + h[1] = (c->k * (c->a4 * s[0] + c->a5 * s[1] + c->a6 * s[2])) / BIT(13); 368 + h[2] = (c->k * (c->a7 * s[0] + c->a8 * s[1] + c->a9 * s[2])) / BIT(13); 369 + for (i = 0; i < 3; i++) { 370 + clamp_val(h[i], -BIT(13), BIT(13) - 1); 371 + xy1y2[i] = h[i] + BIT(13); 372 + } 373 + } 374 + 375 + *x = xy1y2[0]; 376 + *y1 = xy1y2[1]; 377 + *y2 = xy1y2[2]; 378 + 379 + return 0; 380 + 381 + out_unlock: 382 + mutex_unlock(&yas5xx->lock); 383 + return ret; 384 + } 385 + 358 386 /* Used by YAS530, YAS532 and YAS533 */ 359 387 static s32 yas530_linearize(struct yas5xx *yas5xx, u16 val, int axis) 360 388 { ··· 567 453 *xo = c->k * ((100 * sx + c->a2 * sy + c->a3 * sz) / 10); 568 454 *yo = c->k * ((c->a4 * sx + c->a5 * sy + c->a6 * sz) / 10); 569 455 *zo = c->k * ((c->a7 * sx + c->a8 * sy + c->a9 * sz) / 10); 456 + 457 + return 0; 458 + } 459 + 460 + /** 461 + * yas537_get_measure() - Measure a sample of all axis and process 462 + * @yas5xx: The device state 463 + * @to: Temperature out 464 + * @xo: X axis out 465 + * @yo: Y axis out 466 + * @zo: Z axis out 467 + * @return: 0 on success or error code 468 + */ 469 + static int yas537_get_measure(struct yas5xx *yas5xx, s32 *to, s32 *xo, s32 *yo, s32 *zo) 470 + { 471 + u16 t, x, y1, y2; 472 + int ret; 473 + 474 + /* We first get raw data that needs to be translated to [x,y,z] */ 475 + ret = yas537_measure(yas5xx, &t, &x, &y1, &y2); 476 + if (ret) 477 + return ret; 478 + 479 + /* Calculate temperature readout */ 480 + *to = yas5xx_calc_temperature(yas5xx, t); 481 + 482 + /* 483 + * Unfortunately, no linearization or temperature compensation formulas 484 + * are known for YAS537. 485 + */ 486 + 487 + /* Calculate x, y, z from x, y1, y2 */ 488 + *xo = (x - BIT(13)) * 300; 489 + *yo = (y1 - y2) * 1732 / 10; 490 + *zo = (-y1 - y2 + BIT(14)) * 300; 570 491 571 492 return 0; 572 493 } ··· 921 772 return 0; 922 773 } 923 774 775 + static int yas537_get_calibration_data(struct yas5xx *yas5xx) 776 + { 777 + struct yas5xx_calibration *c = &yas5xx->calibration; 778 + u8 data[17]; 779 + u32 val1, val2, val3, val4; 780 + int i, ret; 781 + 782 + /* Writing SRST register */ 783 + ret = regmap_write(yas5xx->map, YAS537_SRST, BIT(1)); 784 + if (ret) 785 + return ret; 786 + 787 + /* Calibration readout, YAS537 needs one readout only */ 788 + ret = regmap_bulk_read(yas5xx->map, YAS537_CAL, data, sizeof(data)); 789 + if (ret) 790 + return ret; 791 + dev_dbg(yas5xx->dev, "calibration data: %17ph\n", data); 792 + 793 + /* Sanity check, is this all zeroes? */ 794 + if (!memchr_inv(data, 0x00, 16) && !FIELD_GET(GENMASK(5, 0), data[16])) 795 + dev_warn(yas5xx->dev, "calibration is blank!\n"); 796 + 797 + /* Contribute calibration data to the input pool for kernel entropy */ 798 + add_device_randomness(data, sizeof(data)); 799 + 800 + /* Extract version information */ 801 + yas5xx->version = FIELD_GET(GENMASK(7, 6), data[16]); 802 + 803 + /* There are two versions of YAS537 behaving differently */ 804 + switch (yas5xx->version) { 805 + case YAS537_VERSION_0: 806 + /* 807 + * The first version simply writes data back into registers: 808 + * 809 + * data[0] YAS537_MTC 0x93 810 + * data[1] 0x94 811 + * data[2] 0x95 812 + * data[3] 0x96 813 + * data[4] 0x97 814 + * data[5] 0x98 815 + * data[6] 0x99 816 + * data[7] 0x9a 817 + * data[8] 0x9b 818 + * data[9] 0x9c 819 + * data[10] 0x9d 820 + * data[11] YAS537_OC 0x9e 821 + * 822 + * data[12] YAS537_OFFSET_X 0x84 823 + * data[13] YAS537_OFFSET_Y1 0x85 824 + * data[14] YAS537_OFFSET_Y2 0x86 825 + * 826 + * data[15] YAS537_HCK 0x88 827 + * data[16] YAS537_LCK 0x89 828 + */ 829 + for (i = 0; i < 12; i++) { 830 + ret = regmap_write(yas5xx->map, YAS537_MTC + i, 831 + data[i]); 832 + if (ret) 833 + return ret; 834 + } 835 + for (i = 0; i < 3; i++) { 836 + ret = regmap_write(yas5xx->map, YAS537_OFFSET_X + i, 837 + data[i + 12]); 838 + if (ret) 839 + return ret; 840 + yas5xx->hard_offsets[i] = data[i + 12]; 841 + } 842 + for (i = 0; i < 2; i++) { 843 + ret = regmap_write(yas5xx->map, YAS537_HCK + i, 844 + data[i + 15]); 845 + if (ret) 846 + return ret; 847 + } 848 + break; 849 + case YAS537_VERSION_1: 850 + /* 851 + * The second version writes some data into registers but also 852 + * extracts calibration coefficients. 853 + * 854 + * Registers being written: 855 + * 856 + * data[0] YAS537_MTC 0x93 857 + * data[1] YAS537_MTC+1 0x94 858 + * data[2] YAS537_MTC+2 0x95 859 + * data[3] YAS537_MTC+3 (partially) 0x96 860 + * 861 + * data[12] YAS537_OFFSET_X 0x84 862 + * data[13] YAS537_OFFSET_Y1 0x85 863 + * data[14] YAS537_OFFSET_Y2 0x86 864 + * 865 + * data[15] YAS537_HCK (partially) 0x88 866 + * YAS537_LCK (partially) 0x89 867 + * data[16] YAS537_OC (partially) 0x9e 868 + */ 869 + for (i = 0; i < 3; i++) { 870 + ret = regmap_write(yas5xx->map, YAS537_MTC + i, 871 + data[i]); 872 + if (ret) 873 + return ret; 874 + } 875 + for (i = 0; i < 3; i++) { 876 + ret = regmap_write(yas5xx->map, YAS537_OFFSET_X + i, 877 + data[i + 12]); 878 + if (ret) 879 + return ret; 880 + yas5xx->hard_offsets[i] = data[i + 12]; 881 + } 882 + /* 883 + * Visualization of partially taken data: 884 + * 885 + * data[3] n 7 6 5 4 3 2 1 0 886 + * YAS537_MTC+3 x x x 1 0 0 0 0 887 + * 888 + * data[15] n 7 6 5 4 3 2 1 0 889 + * YAS537_HCK x x x x 0 890 + * 891 + * data[15] n 7 6 5 4 3 2 1 0 892 + * YAS537_LCK x x x x 0 893 + * 894 + * data[16] n 7 6 5 4 3 2 1 0 895 + * YAS537_OC x x x x x x 896 + */ 897 + ret = regmap_write(yas5xx->map, YAS537_MTC + 3, 898 + FIELD_PREP(YAS537_MTC3_MASK_PREP, 899 + FIELD_GET(YAS537_MTC3_MASK_GET, data[3])) | 900 + YAS537_MTC3_ADD_BIT); 901 + if (ret) 902 + return ret; 903 + ret = regmap_write(yas5xx->map, YAS537_HCK, 904 + FIELD_PREP(YAS537_HCK_MASK_PREP, 905 + FIELD_GET(YAS537_HCK_MASK_GET, data[15]))); 906 + if (ret) 907 + return ret; 908 + ret = regmap_write(yas5xx->map, YAS537_LCK, 909 + FIELD_PREP(YAS537_LCK_MASK_PREP, 910 + FIELD_GET(YAS537_LCK_MASK_GET, data[15]))); 911 + if (ret) 912 + return ret; 913 + ret = regmap_write(yas5xx->map, YAS537_OC, 914 + FIELD_GET(YAS537_OC_MASK_GET, data[16])); 915 + if (ret) 916 + return ret; 917 + /* 918 + * For data extraction, build some blocks. Four 32-bit blocks 919 + * look appropriate. 920 + * 921 + * n 7 6 5 4 3 2 1 0 922 + * data[0] 0 [ Cx Cx Cx Cx Cx Cx Cx Cx ] bits 31 .. 24 923 + * data[1] 1 [ Cx C1 C1 C1 C1 C1 C1 C1 ] bits 23 .. 16 924 + * data[2] 2 [ C1 C1 C2 C2 C2 C2 C2 C2 ] bits 15 .. 8 925 + * data[3] 3 [ C2 C2 C2 ] bits 7 .. 0 926 + * 927 + * n 7 6 5 4 3 2 1 0 928 + * data[3] 0 [ a2 a2 a2 a2 a2 ] bits 31 .. 24 929 + * data[4] 1 [ a2 a2 a3 a3 a3 a3 a3 a3 ] bits 23 .. 16 930 + * data[5] 2 [ a3 a4 a4 a4 a4 a4 a4 a4 ] bits 15 .. 8 931 + * data[6] 3 [ a4 ] bits 7 .. 0 932 + * 933 + * n 7 6 5 4 3 2 1 0 934 + * data[6] 0 [ a5 a5 a5 a5 a5 a5 a5 ] bits 31 .. 24 935 + * data[7] 1 [ a5 a5 a6 a6 a6 a6 a6 a6 ] bits 23 .. 16 936 + * data[8] 2 [ a6 a7 a7 a7 a7 a7 a7 a7 ] bits 15 .. 8 937 + * data[9] 3 [ a7 ] bits 7 .. 0 938 + * 939 + * n 7 6 5 4 3 2 1 0 940 + * data[9] 0 [ a8 a8 a8 a8 a8 a8 a8 ] bits 31 .. 24 941 + * data[10] 1 [ a9 a9 a9 a9 a9 a9 a9 a9 ] bits 23 .. 16 942 + * data[11] 2 [ a9 k k k k k k k ] bits 15 .. 8 943 + * data[12] 3 [ ] bits 7 .. 0 944 + */ 945 + val1 = get_unaligned_be32(&data[0]); 946 + val2 = get_unaligned_be32(&data[3]); 947 + val3 = get_unaligned_be32(&data[6]); 948 + val4 = get_unaligned_be32(&data[9]); 949 + /* Extract calibration coefficients and modify */ 950 + c->Cx = FIELD_GET(GENMASK(31, 23), val1) - 256; 951 + c->Cy1 = FIELD_GET(GENMASK(22, 14), val1) - 256; 952 + c->Cy2 = FIELD_GET(GENMASK(13, 5), val1) - 256; 953 + c->a2 = FIELD_GET(GENMASK(28, 22), val2) - 64; 954 + c->a3 = FIELD_GET(GENMASK(21, 15), val2) - 64; 955 + c->a4 = FIELD_GET(GENMASK(14, 7), val2) - 128; 956 + c->a5 = FIELD_GET(GENMASK(30, 22), val3) - 112; 957 + c->a6 = FIELD_GET(GENMASK(21, 15), val3) - 64; 958 + c->a7 = FIELD_GET(GENMASK(14, 7), val3) - 128; 959 + c->a8 = FIELD_GET(GENMASK(30, 24), val4) - 64; 960 + c->a9 = FIELD_GET(GENMASK(23, 15), val4) - 112; 961 + c->k = FIELD_GET(GENMASK(14, 8), val4); 962 + break; 963 + default: 964 + dev_err(yas5xx->dev, "unknown version of YAS537\n"); 965 + return -EINVAL; 966 + } 967 + 968 + return 0; 969 + } 970 + 924 971 /* Used by YAS530, YAS532 and YAS533 */ 925 972 static void yas530_dump_calibration(struct yas5xx *yas5xx) 926 973 { ··· 1139 794 dev_dbg(yas5xx->dev, "a9 = %d\n", c->a9); 1140 795 dev_dbg(yas5xx->dev, "k = %d\n", c->k); 1141 796 dev_dbg(yas5xx->dev, "dck = %d\n", c->dck); 797 + } 798 + 799 + static void yas537_dump_calibration(struct yas5xx *yas5xx) 800 + { 801 + struct yas5xx_calibration *c = &yas5xx->calibration; 802 + 803 + if (yas5xx->version == YAS537_VERSION_1) { 804 + dev_dbg(yas5xx->dev, "Cx = %d\n", c->Cx); 805 + dev_dbg(yas5xx->dev, "Cy1 = %d\n", c->Cy1); 806 + dev_dbg(yas5xx->dev, "Cy2 = %d\n", c->Cy2); 807 + dev_dbg(yas5xx->dev, "a2 = %d\n", c->a2); 808 + dev_dbg(yas5xx->dev, "a3 = %d\n", c->a3); 809 + dev_dbg(yas5xx->dev, "a4 = %d\n", c->a4); 810 + dev_dbg(yas5xx->dev, "a5 = %d\n", c->a5); 811 + dev_dbg(yas5xx->dev, "a6 = %d\n", c->a6); 812 + dev_dbg(yas5xx->dev, "a7 = %d\n", c->a7); 813 + dev_dbg(yas5xx->dev, "a8 = %d\n", c->a8); 814 + dev_dbg(yas5xx->dev, "a9 = %d\n", c->a9); 815 + dev_dbg(yas5xx->dev, "k = %d\n", c->k); 816 + } 1142 817 } 1143 818 1144 819 /* Used by YAS530, YAS532 and YAS533 */ ··· 1282 917 return regmap_write(yas5xx->map, YAS530_MEASURE_INTERVAL, 0); 1283 918 } 1284 919 920 + static int yas537_power_on(struct yas5xx *yas5xx) 921 + { 922 + __be16 buf; 923 + int ret; 924 + u8 intrvl; 925 + 926 + /* Writing ADCCAL and TRM registers */ 927 + buf = cpu_to_be16(GENMASK(9, 3)); 928 + ret = regmap_bulk_write(yas5xx->map, YAS537_ADCCAL, &buf, sizeof(buf)); 929 + if (ret) 930 + return ret; 931 + ret = regmap_write(yas5xx->map, YAS537_TRM, GENMASK(7, 0)); 932 + if (ret) 933 + return ret; 934 + 935 + /* The interval value is static in regular operation */ 936 + intrvl = (YAS537_DEFAULT_SENSOR_DELAY_MS * MILLI 937 + - YAS537_MEASURE_TIME_WORST_US) / 4100; 938 + ret = regmap_write(yas5xx->map, YAS537_MEASURE_INTERVAL, intrvl); 939 + if (ret) 940 + return ret; 941 + 942 + /* The average value is also static in regular operation */ 943 + ret = regmap_write(yas5xx->map, YAS537_AVR, YAS537_MAG_AVERAGE_32_MASK); 944 + if (ret) 945 + return ret; 946 + 947 + /* Perform the "rcoil" part but skip the "last_after_rcoil" read */ 948 + ret = regmap_write(yas5xx->map, YAS537_CONFIG, BIT(3)); 949 + if (ret) 950 + return ret; 951 + 952 + /* Wait until the coil has ramped up */ 953 + usleep_range(YAS537_MAG_RCOIL_TIME_US, YAS537_MAG_RCOIL_TIME_US + 100); 954 + 955 + return 0; 956 + } 957 + 1285 958 static const struct yas5xx_chip_info yas5xx_chip_info_tbl[] = { 1286 959 [yas530] = { 1287 960 .devid = YAS530_DEVICE_ID, ··· 1365 962 .dump_calibration = yas530_dump_calibration, 1366 963 .measure_offsets = yas530_measure_offsets, 1367 964 .power_on = yas530_power_on, 965 + }, 966 + [yas537] = { 967 + .devid = YAS537_DEVICE_ID, 968 + .product_name = "YAS537 MS-3T", 969 + .version_names = { "v0", "v1" }, /* version naming unknown */ 970 + .volatile_reg = yas537_volatile_reg, 971 + .volatile_reg_qty = ARRAY_SIZE(yas537_volatile_reg), 972 + .scaling_val2 = 100000, /* nanotesla to Gauss */ 973 + .t_ref = 8120, /* counts */ 974 + .min_temp_x10 = -3860, /* 1/10:s degrees Celsius */ 975 + .get_measure = yas537_get_measure, 976 + .get_calibration_data = yas537_get_calibration_data, 977 + .dump_calibration = yas537_dump_calibration, 978 + /* .measure_offets is not needed for yas537 */ 979 + .power_on = yas537_power_on, 1368 980 }, 1369 981 }; 1370 982 ··· 1588 1170 {"yas530", yas530 }, 1589 1171 {"yas532", yas532 }, 1590 1172 {"yas533", yas533 }, 1173 + {"yas537", yas537 }, 1591 1174 {} 1592 1175 }; 1593 1176 MODULE_DEVICE_TABLE(i2c, yas5xx_id); ··· 1597 1178 { .compatible = "yamaha,yas530", }, 1598 1179 { .compatible = "yamaha,yas532", }, 1599 1180 { .compatible = "yamaha,yas533", }, 1181 + { .compatible = "yamaha,yas537", }, 1600 1182 {} 1601 1183 }; 1602 1184 MODULE_DEVICE_TABLE(of, yas5xx_of_match);