1. 10 May, 2020 7 commits
    • Hans de Goede's avatar
      iio: light: cm32181: Handle CM3218 ACPI devices with 2 I2C resources · c1e62062
      Hans de Goede authored
      Some ACPI systems list 2 I2C resources for the CM3218 sensor. On these
      systems the first I2cSerialBus ACPI-resource points to the SMBus Alert
      Response Address (ARA, 0x0c) and the second I2cSerialBus ACPI-resource
      points to the actual CM3218 sensor address:
      
       Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
       {
           Name (SBUF, ResourceTemplate ()
           {
               I2cSerialBusV2 (0x000C, ControllerInitiated, 0x00061A80,
                   AddressingMode7Bit, "\\_SB.I2C3",
                   0x00, ResourceConsumer, , Exclusive,
                   )
               I2cSerialBusV2 (0x0048, ControllerInitiated, 0x00061A80,
                   AddressingMode7Bit, "\\_SB.I2C3",
                   0x00, ResourceConsumer, , Exclusive,
                   )
               Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, )
               {
                   0x00000033,
               }
           })
           Return (SBUF) /* \_SB_.I2C3.ALSD._CRS.SBUF */
       }
      
      Detect this and take the following step to deal with it:
      
      1. When a SMBus Alert capable sensor has an Alert asserted, it will
         not respond on its actual I2C address. Read a byte from the ARA
         to clear any pending Alerts.
      
      2. Create a "dummy" client for the actual I2C address and
         use that client to communicate with the sensor.
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      c1e62062
    • Hans de Goede's avatar
      iio: light: cm32181: Clean up the probe function a bit · b885d0fa
      Hans de Goede authored
      3 small cleanups to cm32181_probe():
      
      1. Do not log an error when we fail to allocate memory (as a general
      rule drivers do not log errors for this as the kernel will already
      have complained loudly that it could not alloc the mem).
      
      2. Remove the i2c_set_clientdata() call, we never use i2c_get_clientdata()
      or dev_get_drvdata() anywhere.
      
      3. Add a dev helper variable and use it in various places instead of
      &client->dev.
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      b885d0fa
    • Hans de Goede's avatar
      iio: light: cm32181: Add support for the CM3218 · 02cdab2a
      Hans de Goede authored
      Add support for the CM3218 which is an older version of the
      CM32181.
      
      This is based on a newer version of cm32181.c, with a copyright of:
      
       * Copyright (C) 2014 Capella Microsystems Inc.
       * Author: Kevin Tsai <ktsai@capellamicro.com>
       *
       * This program is free software; you can redistribute it and/or modify it
       * under the terms of the GNU General Public License version 2, as published
       * by the Free Software Foundation.
      
      Which is floating around on the net in various places, but the changes
      from this newer version never made it upstream.
      
      This was tested on an Asus T100TA and an Asus T100CHI, which both come
      with the CM3218 variant of the light sensor.
      Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      02cdab2a
    • Hans de Goede's avatar
      iio: light: cm32181: Add some extra register defines · 3bf4a59c
      Hans de Goede authored
      These come from a newer version of cm32181.c, which is floating around
      the net, with a copyright of:
      
       * Copyright (C) 2014 Capella Microsystems Inc.
       * Author: Kevin Tsai <ktsai@capellamicro.com>
       *
       * This program is free software; you can redistribute it and/or modify it
       * under the terms of the GNU General Public License version 2, as published
       * by the Free Software Foundation.
      
      Note that this removes the bogus CM32181_CMD_ALS_ENABLE define, there
      is no enable bit, only a disable bit and enabled is the absence of
      being disabled.
      
      This is a preparation patch for adding support for the older
      CM3218 model of the light sensor.
      Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      3bf4a59c
    • Hans de Goede's avatar
      iio: light: cm32181: Add support for ACPI enumeration · 44b9409c
      Hans de Goede authored
      Add support for ACPI enumeration, this has been tested on a HP
      HP Pavilion x2 Detachable 10 (Bay Trail model).
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      44b9409c
    • Hans de Goede's avatar
      iio: light: cm32181: Switch to new style i2c-driver probe function · 06770454
      Hans de Goede authored
      Switch to the new style i2c-driver probe_new probe function and drop the
      unnecessary i2c_device_id table (we do not have any old style board files
      using this).
      
      This is a preparation patch for adding ACPI binding support.
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      06770454
    • Alexandru Ardelean's avatar
      iio: hid-sensors: move triggered buffer setup into hid_sensor_setup_trigger · 067fda1c
      Alexandru Ardelean authored
      The main intent here is to get rid of the iio_buffer_set_attrs() helper, or
      at least rework it's usage a bit.
      The problem with that helper is that it needs a pointer to the buffer,
      which makes supporting multiple buffers per IIO device a bit more
      cumbersome.
      
      The hid_sensor_setup_trigger() is pretty much used in the same way:
      - iio_triggered_buffer_setup() gets called before
      - then hid_sensor_setup_trigger() and hid_sensor_setup_batch_mode() gets
        called which may attach some fifo attributes
      
      This change merges the 2 together under the hid_sensor_setup_trigger()
      function. Only the &iio_pollfunc_store_time is passed to all devices, so
      it's not even required to pass it explicitly outside of the common
      hid_sensor_setup_trigger() function.
      
      Moving the devm_iio_triggered_buffer_setup/cleanup() calls into the common
      place code can help the rework of the buffer code, since it is in one
      place.
      
      One detail of the change is that there are 2 drivers that use
      devm_iio_triggered_buffer_setup(). That function gets implicitly
      replaced with iio_triggered_buffer_setup()/cleanup(), but since all drivers
      call both hid_sensor_setup_trigger9) & hid_sensor_remove_trigger() trigger,
      the iio_triggered_buffer_cleanup() piggy backs on the
      hid_sensor_remove_trigger() call, which should cover the cleanup.
      Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
      Acked-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      067fda1c
  2. 03 May, 2020 33 commits