1. 06 Nov, 2016 5 commits
    • Brian Masney's avatar
      staging: iio: tsl2583: don't shutdown chip when updating the lux table · 0561155f
      Brian Masney authored
      in_illuminance_lux_table_store() shuts down the chip, updates the
      contents of the lux table, and then turns the chip back on. The values
      in lux table are not used by the chip and are only used internally by
      the driver. It is not necessary to change the power state on the chip.
      This patch removes the calls to taos_chip_off() and taos_chip_on()
      in in_illuminance_lux_table_store().
      Signed-off-by: default avatarBrian Masney <masneyb@onstation.org>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      0561155f
    • Brian Masney's avatar
      staging: iio: tsl2583: remove redundant power off sequence in taos_chip_on() · babe4447
      Brian Masney authored
      taos_chip_on() explicitly turns the sensor power on and then writes the
      8 registers that are stored in taos_config. The first register in
      taos_config is the CONTROL register and the configuration is set to
      turn the power off. The existing state sequence in taos_chip_on() is:
      
      - Turn device power on
      - Turn device power off (via taos_config)
      - Configure other 7 registers (via taos_config)
      - Turn device power on, enable ADC
      
      This patch changes the code so that the device is not powered off via
      taos_config.
      
      Verified that the driver still functions correctly using a TSL2581
      hooked up to a Raspberry Pi 2.
      Signed-off-by: default avatarBrian Masney <masneyb@onstation.org>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      babe4447
    • Brian Masney's avatar
      staging: iio: tsl2583: fixed ordering of comments · 4a0f3614
      Brian Masney authored
      in taos_defaults()
      
      The comments in taos_defaults() appear after the line of code
      that they apply to. This patch moves the comments so that they appear
      before the code. Some of the comments were updated to be more
      informative.
      Signed-off-by: default avatarBrian Masney <masneyb@onstation.org>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      4a0f3614
    • Brian Masney's avatar
      staging: iio: tsl2583: removed unused code from device probing · 6bd0cb2b
      Brian Masney authored
      taos_probe() queries the all of the sensor's registers and loads all of
      the values into a buffer stored on the stack. Only the chip ID register
      was actually used. Change the probe function to just query the chip ID
      register on the device.
      
      Verified that the driver still functions correctly using a TSL2581
      hooked up to a Raspberry Pi 2.
      Signed-off-by: default avatarBrian Masney <masneyb@onstation.org>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      6bd0cb2b
    • Brian Masney's avatar
      staging: iio: tsl2583: i2c_smbus_write_byte() / i2c_smbus_read_byte() migration · 6ba5dee9
      Brian Masney authored
      There were several places where the driver would first call
      i2c_smbus_write_byte() to select the register on the device, and then
      call i2c_smbus_read_byte() to get the contents of that register. The
      code would look roughly like:
      
      /* Select register */
      i2c_smbus_write_byte(client, REGISTER);
      
      /* Read the the last register that was written to */
      int data = i2c_smbus_read_byte(client);
      
      Rewrite this to use i2c_smbus_read_byte_data() to combine the two
      calls into one:
      
      int data = i2c_smbus_read_byte_data(chip->client, REGISTER);
      
      Verified that the driver still functions correctly using a TSL2581
      hooked up to a Raspberry Pi 2.
      
      This fixes the following warnings that were found by the
      kbuild test robot that were introduced by commit 8ba355cce3c6 ("staging:
      iio: tsl2583: check for error code from i2c_smbus_read_byte()").
      
      drivers/staging/iio/light/tsl2583.c:365:5-12: WARNING: Unsigned
      expression compared with zero: reg_val < 0
      
      drivers/staging/iio/light/tsl2583.c:388:5-12: WARNING: Unsigned
      expression compared with zero: reg_val < 0
      
      This also removes the need for the taos_i2c_read() function since all
      callers were only calling the function with a length of 1.
      Signed-off-by: default avatarBrian Masney <masneyb@onstation.org>
      Cc: Julia Lawall <julia.lawall@lip6.fr>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      6ba5dee9
  2. 05 Nov, 2016 11 commits
  3. 01 Nov, 2016 17 commits
  4. 25 Oct, 2016 7 commits
    • Enric Balletbo i Serra's avatar
      platform/chrome: cros_ec_dev - Register cros-ec sensors · 5668bfdd
      Enric Balletbo i Serra authored
      Check whether the ChromeOS Embedded Controller is a sensor hub and in
      such case issue a command to get the number of sensors and register them
      all.
      Signed-off-by: default avatarGwendal Grignou <gwendal@chromium.org>
      Signed-off-by: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
      Reviewed-by: default avatarGuenter Roeck <groeck@chromium.org>
      Acked-by: default avatarOlof Johansson <olof@lixom.net>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      5668bfdd
    • Vincent Palatin's avatar
      platform/chrome: Introduce a new function to check EC features. · e4244ebd
      Vincent Palatin authored
      Use the EC_CMD_GET_FEATURES message to check the supported features for
      each MCU.
      Signed-off-by: default avatarVincent Palatin <vpalatin@chromium.org>
      [tomeu: adapted to changes in mainline]
      Signed-off-by: default avatarTomeu Vizoso <tomeu.vizoso@collabora.com>
      [enric: remove references to USB PD feature and do it more generic]
      Signed-off-by: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
      Reviewed-by: default avatarGuenter Roeck <groeck@chromium.org>
      For the MFD changes:
      Acked-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      e4244ebd
    • Enric Balletbo i Serra's avatar
      iio: cros_ec_sensors: add ChromeOS EC Contiguous Sensors driver · c14dca07
      Enric Balletbo i Serra authored
      Handle 3d contiguous sensors like Accelerometers, Gyroscope and
      Magnetometer that are presented by the ChromeOS EC Sensor hub.
      Signed-off-by: default avatarGuenter Roeck <groeck@chromium.org>
      Signed-off-by: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      c14dca07
    • Enric Balletbo i Serra's avatar
      iio: cros_ec_sensors_core: Add common functions for the ChromeOS EC Sensor Hub. · 974e6f02
      Enric Balletbo i Serra authored
      Add the core functions to be able to support the sensors attached behind
      the ChromeOS Embedded Controller and used by other IIO cros-ec sensor
      drivers.
      
      The cros_ec_sensor_core driver matches with current driver in ChromeOS
      4.4 tree, so it includes all the fixes at the moment. The support for
      this driver was made by Gwendal Grignou. The original patch and all the
      fixes has been squashed and rebased on top of mainline.
      Signed-off-by: default avatarGwendal Grignou <gwendal@chromium.org>
      Signed-off-by: default avatarGuenter Roeck <groeck@chromium.org>
      [eballetbo: split, squash and rebase on top of mainline the patches
      found in ChromeOS tree]
      Signed-off-by: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      974e6f02
    • Arnd Bergmann's avatar
      iio: maxim_thermocouple: detect invalid storage size in read() · 32cb7d27
      Arnd Bergmann authored
      As found by gcc -Wmaybe-uninitialized, having a storage_bytes value other
      than 2 or 4 will result in undefined behavior:
      
      drivers/iio/temperature/maxim_thermocouple.c: In function 'maxim_thermocouple_read':
      drivers/iio/temperature/maxim_thermocouple.c:141:5: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      
      This probably cannot happen, but returning -EINVAL here is appropriate
      and makes gcc happy and the code more robust.
      
      Fixes: 231147ee ("iio: maxim_thermocouple: Align 16 bit big endian value of raw reads")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      32cb7d27
    • Arnd Bergmann's avatar
      staging: iio: cdc/ad7746: fix missing return value · 3089ec2c
      Arnd Bergmann authored
      As found by "gcc -Wmaybe-uninitialized", the latest change to the
      driver lacked an initalization for the return code in one of the
      added cases:
      
      drivers/staging/iio/cdc/ad7746.c: In function ‘ad7746_read_raw’:
      drivers/staging/iio/cdc/ad7746.c:655:2: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
      
      This sets it to IIO_VAL_INT, which I think is what we want here.
      
      Fixes: 2296c062 ("staging: iio: cdc: ad7746: implement IIO_CHAN_INFO_SAMP_FREQ")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      3089ec2c
    • Linus Walleij's avatar
      iio: gyro: Add driver for the MPU-3050 gyroscope · 3904b28e
      Linus Walleij authored
      This adds a new driver for the Invensense MPU-3050 gyroscope.
      This driver is based on information from the rough input driver
      in drivers/input/misc/mpu3050.c and the scratch misc driver
      posted by Nathan Royer in 2011. Some years have passed but this
      is finally a fully-fledged driver for this gyroscope. It was
      developed and tested on the Qualcomm APQ8060 Dragonboard.
      
      The driver supports both raw and buffered input. It also
      supports the internal trigger mechanism by registering a trigger
      that can fire in response to the internal sample engine of the
      component. In addition to reading out the gyroscope sensor
      values, the driver also supports reading the temperature from
      the sensor.
      
      The driver currently only supports I2C but the MPU-3050 can
      also be used from SPI, so the I2C portions are split in their
      own file and we just use regmap to access all registers, so
      it will be trivial to plug in SPI support if/when someone has
      a system requiring this.
      
      To conserve power, the driver utilizes the runtime PM
      framework and will put the sensor in off mode and disable the
      regulators when unused, after a timeout of 10 seconds.
      
      The fullscale can be set for the sensor to 250, 500, 1000 or
      2000 deg/s. This corresponds to scale values of rougly 0.000122,
      0.000275, 0.000512 or 0.001068. By writing such values (or close
      to these) into "in_anglevel_scale", the corresponding fullscale
      can be chosen. It will default to 2000 deg/s (~35 rad/s).
      
      The gyro component can have DC offsets on all axes. These can be
      compensated using the standard sysfs ABI property
      "in_anglevel_[xyz]_calibbias". This is in positive/negative
      values of the raw values, so a suitable calibration bias can be
      determined by userspace by reading the "in_anglevel_[xyz]_raw"
      for a few iterations while holding the sensor still, create an
      average integer, and writing the negative inverse of that into
      "in_anglevel_[xyz]_calibbias". After this the hardware will
      automatically subtract the bias, also when using buffered
      readings.
      
      Since the MPU-3050 has an outgoing I2C port it needs to act as
      an I2C mux. This means that the device is switching I2C traffic
      to devices beyond it. On my system this is the only way to reach
      the accelerometer. The "sensor fusion" ability of the MPU-3050
      to directly talk to the device on the outgoing I2C port is
      currently not used by the driver, but it has code to allow I2C
      traffic to pass through so that the Linux kernel can reach the
      device on the other side with a kernel driver.
      
      Example usage with the native trigger:
      
      $ generic_buffer -a -c10 -n mpu3050
      iio device number being used is 0
      iio trigger number being used is 0
      No channels are enabled, enabling all channels
      Enabling: in_anglvel_z_en
      Enabling: in_timestamp_en
      Enabling: in_anglvel_y_en
      Enabling: in_temp_en
      Enabling: in_anglvel_x_en
      /sys/bus/iio/devices/iio:device0 mpu3050-dev0
      29607.142578 -0.117493 0.074768 0.012817 180788797150
      29639.285156 -0.117493 0.076904 0.013885 180888982335
      29696.427734 -0.116425 0.076904 0.012817 180989178039
      29742.857422 -0.117493 0.076904 0.012817 181089377742
      29764.285156 -0.116425 0.077972 0.012817 181189574187
      29860.714844 -0.115356 0.076904 0.012817 181289772705
      29864.285156 -0.117493 0.076904 0.012817 181389971520
      29910.714844 -0.115356 0.076904 0.013885 181490170483
      29917.857422 -0.116425 0.076904 0.011749 181590369742
      29975.000000 -0.116425 0.076904 0.012817 181690567075
      Disabling: in_anglvel_z_en
      Disabling: in_timestamp_en
      Disabling: in_anglvel_y_en
      Disabling: in_temp_en
      Disabling: in_anglvel_x_en
      
      The first column is the temperature in millidegrees, then the x,y,z
      axes in succession followed by the timestamp. Also tested successfully
      using the HRTimer trigger.
      
      Cc: Nick Vaccaro <nvaccaro@google.com>
      Cc: Ge Gao <ggao@invensense.com>
      Cc: Anna Si <asi@invensense.com>
      Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
      Cc: Crestez Dan Leonard <leonard.crestez@intel.com>
      Cc: Daniel Baluta <daniel.baluta@intel.com>
      Cc: Gregor Boirie <gregor.boirie@parrot.com>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      3904b28e