1. 31 Dec, 2016 2 commits
    • Linus Walleij's avatar
      iio: accel: st_accel: fix LIS3LV02 reading and scaling · 65e4345c
      Linus Walleij authored
      The LIS3LV02 has a special bit that need to be set to get the
      read values left aligned. Before this patch we get gibberish
      like this:
      
      iio_generic_buffer -a -c10 -n lis3lv02dl_accel
      (...)
      0.000000 -0.010042 -0.642688 19155832931907
      0.000000 -0.010042 -0.642688 19155858751073
      
      Which is because we read a raw value for 1g as 64 which is
      the nominal 1024 for 1g shifted 4 bits to the left by being
      right-aligned rather than left aligned.
      
      Since all other sensors are left aligned, add some code to
      set the special DAS (data alignment setting) bit to 1 so that
      the right value is now read like this:
      
      iio_generic_buffer -a -c10 -n lis3lv02dl_accel
      (...)
      0.000000 -0.147095 -10.120135 24761614364956
      -0.029419 -0.176514 -10.120135 24761631624540
      
      The scaling was weird as well: we have a gain of 1000 for 1g
      and 3000 for 6g. I don't even remember how I came up with the
      old values but they are wrong.
      
      Fixes: 3acddf74 ("iio: st-sensors: add support for lis3lv02d accelerometer")
      Cc: Lorenzo Bianconi <lorenzo.bianconi@st.com>
      Cc: Giuseppe Barba <giuseppe.barba@st.com>
      Cc: Denis Ciocca <denis.ciocca@st.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      65e4345c
    • Lorenzo Bianconi's avatar
      iio: common: st_sensors: fix channel data parsing · 65c8aea0
      Lorenzo Bianconi authored
      Using realbits as i2c/spi read len, when that value is not byte aligned
      (e.g 12 bits), lead to skip msb part of out data registers.
      Fix this taking into account scan_type.shift in addition to
      scan_type.realbits as read length:
      
      read_len = DIV_ROUND_UP(realbits + shift, 8)
      
      This fix has been tested on 8, 12, 16, 24 bit sensors
      
      Fixes: e7385de5 ("iio:st_sensors: align on storagebits boundaries")
      Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@st.com>
      Tested-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      65c8aea0
  2. 30 Dec, 2016 3 commits
  3. 03 Dec, 2016 3 commits
  4. 01 Dec, 2016 13 commits
  5. 30 Nov, 2016 2 commits
  6. 29 Nov, 2016 17 commits