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.

bu27034: ROHM BU27034ANUC correct gains and times

The ROHM BU27034NUC was cancelled and BU27034ANUC is replacing this
sensor. The BU27034ANUC does not support all the gains or all the
integration times that were supported on BU27034NUC.

Srop unsupported times and gains

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/19f8cca2b5498fbfea6e657b7b9c90b78516866a.1720176341.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Matti Vaittinen and committed by
Jonathan Cameron
bb105981 acfc80c7

+9 -19
+9 -19
drivers/iio/light/rohm-bu27034.c
··· 94 94 }; 95 95 96 96 /* 97 - * Available scales with gain 1x - 4096x, timings 55, 100, 200, 400 mS 97 + * Available scales with gain 1x - 1024x, timings 55, 100, 200, 400 mS 98 98 * Time impacts to gain: 1x, 2x, 4x, 8x. 99 99 * 100 - * => Max total gain is HWGAIN * gain by integration time (8 * 4096) = 32768 100 + * => Max total gain is HWGAIN * gain by integration time (8 * 1024) = 8192 101 + * if 1x gain is scale 1, scale for 2x gain is 0.5, 4x => 0.25, 102 + * ... 8192x => 0.0001220703125 => 122070.3125 nanos 101 103 * 102 - * Using NANO precision for scale we must use scale 64x corresponding gain 1x 103 - * to avoid precision loss. (32x would result scale 976 562.5(nanos). 104 + * Using NANO precision for scale, we must use scale 16x corresponding gain 1x 105 + * to avoid precision loss. (8x would result scale 976 562.5(nanos). 104 106 */ 105 - #define BU27034_SCALE_1X 64 107 + #define BU27034_SCALE_1X 16 106 108 107 109 /* See the data sheet for the "Gain Setting" table */ 108 110 #define BU27034_GSEL_1X 0x00 /* 00000 */ 109 111 #define BU27034_GSEL_4X 0x08 /* 01000 */ 110 - #define BU27034_GSEL_16X 0x0a /* 01010 */ 111 112 #define BU27034_GSEL_32X 0x0b /* 01011 */ 112 - #define BU27034_GSEL_64X 0x0c /* 01100 */ 113 113 #define BU27034_GSEL_256X 0x18 /* 11000 */ 114 114 #define BU27034_GSEL_512X 0x19 /* 11001 */ 115 115 #define BU27034_GSEL_1024X 0x1a /* 11010 */ 116 - #define BU27034_GSEL_2048X 0x1b /* 11011 */ 117 - #define BU27034_GSEL_4096X 0x1c /* 11100 */ 118 116 119 117 /* Available gain settings */ 120 118 static const struct iio_gain_sel_pair bu27034_gains[] = { 121 119 GAIN_SCALE_GAIN(1, BU27034_GSEL_1X), 122 120 GAIN_SCALE_GAIN(4, BU27034_GSEL_4X), 123 - GAIN_SCALE_GAIN(16, BU27034_GSEL_16X), 124 121 GAIN_SCALE_GAIN(32, BU27034_GSEL_32X), 125 - GAIN_SCALE_GAIN(64, BU27034_GSEL_64X), 126 122 GAIN_SCALE_GAIN(256, BU27034_GSEL_256X), 127 123 GAIN_SCALE_GAIN(512, BU27034_GSEL_512X), 128 124 GAIN_SCALE_GAIN(1024, BU27034_GSEL_1024X), 129 - GAIN_SCALE_GAIN(2048, BU27034_GSEL_2048X), 130 - GAIN_SCALE_GAIN(4096, BU27034_GSEL_4096X), 131 125 }; 132 126 133 127 /* 134 - * The IC has 5 modes for sampling time. 5 mS mode is exceptional as it limits 135 - * the data collection to data0-channel only and cuts the supported range to 136 - * 10 bit. It is not supported by the driver. 137 - * 138 - * "normal" modes are 55, 100, 200 and 400 mS modes - which do have direct 139 - * multiplying impact to the register values (similar to gain). 128 + * Measurement modes are 55, 100, 200 and 400 mS modes - which do have direct 129 + * multiplying impact to the data register values (similar to gain). 140 130 * 141 131 * This means that if meas-mode is changed for example from 400 => 200, 142 132 * the scale is doubled. Eg, time impact to total gain is x1, x2, x4, x8.