Commit graph

7041 commits

Author SHA1 Message Date
Jinjie Ruan
449635ec21 iio: adc: at91_adc: Use devm_request_irq() helper function
Use devm_request_irq() to request the interrupt, so we can avoid
having to manually clean this up.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Link: https://lore.kernel.org/r/20230828064546.2383857-2-ruanjinjie@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11 20:12:41 +01:00
Jinjie Ruan
9979cc6485 iio: frequency: adf4350: Use device managed functions and fix power down issue.
The devm_clk_get_enabled() helper:
    - calls devm_clk_get()
    - calls clk_prepare_enable() and registers what is needed in order to
      call clk_disable_unprepare() when needed, as a managed resource.

Also replace devm_regulator_get() and regulator_enable() with
devm_regulator_get_enable() helper and remove regulator_disable().

Replace iio_device_register() with devm_iio_device_register() and remove
iio_device_unregister().

And st->reg is not used anymore, so remove it.

As Jonathan pointed out, couple of things that are wrong:

1) The device is powered down 'before' we unregister it with the
   subsystem and as such userspace interfaces are still exposed which
   probably won't do the right thing if the chip is powered down.

2) This isn't done in the error paths in probe.

To solve this problem, register a new callback adf4350_power_down()
with devm_add_action_or_reset(), to enable software power down in both
error and device detach path. So the remove function can be removed.

Remove spi_set_drvdata() from the probe function, since spi_get_drvdata()
is not used anymore.

Fixes: e31166f0fd ("iio: frequency: New driver for Analog Devices ADF4350/ADF4351 Wideband Synthesizers")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Link: https://lore.kernel.org/r/20230828062717.2310219-1-ruanjinjie@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11 20:12:40 +01:00
Marcus Folkesson
732ad34260 iio: adc: mcp3911: add support for the whole MCP39xx family
Microchip does have many similar chips, add support for those.

The new supported chips are:
  - microchip,mcp3910
  - microchip,mcp3912
  - microchip,mcp3913
  - microchip,mcp3914
  - microchip,mcp3918
  - microchip,mcp3919

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230822192259.1125792-7-marcus.folkesson@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11 20:12:40 +01:00
Marcus Folkesson
593d73629a iio: adc: mcp3911: avoid ambiguity parameters in macros
Name macro parameters after what they represent instead of 'x'
and make sure the evaluation of that will have no side effects.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Link: https://lore.kernel.org/r/20230822192259.1125792-6-marcus.folkesson@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11 20:12:40 +01:00
Marcus Folkesson
7e5047334f iio: adc: mcp3911: fix indentation
The whole file does not make use of indentation properly.
Do something about it.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Link: https://lore.kernel.org/r/20230822192259.1125792-5-marcus.folkesson@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11 20:12:40 +01:00
Marcus Folkesson
d1f6a2ac59 iio: adc: mcp3911: simplify usage of spi->dev
Replace the usage of `adc->spi->dev` with `dev` to make the code prettier.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Link: https://lore.kernel.org/r/20230822192259.1125792-4-marcus.folkesson@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11 20:12:40 +01:00
Marcus Folkesson
46d1bfa04f iio: adc: mcp3911: make use of dev_err_probe()
Simplify code by switch to dev_err_probe().

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Link: https://lore.kernel.org/r/20230822192259.1125792-3-marcus.folkesson@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11 20:12:40 +01:00
Jinjie Ruan
a2d518fbe3 iio: adc: mt6577_auxadc: Simplify with device managed function
Add a device managed hook, via devm_add_action_or_reset() and
mt6577_power_off(), to power off on device detach.

Replace iio_device_register() by devm_iio_device_register() and remove
the mt6577_auxadc_remove() function used to unregister the device and
power off the device.

Remove platform_set_drvdata() from the probe function, since
platform_get_drvdata() is not used anymore.

Remove mt6577_auxadc_mod_reg() call from the probe function error path.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Link: https://lore.kernel.org/r/20230826035402.3512033-3-ruanjinjie@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11 20:12:40 +01:00
Jinjie Ruan
8cbba23e43 iio: adc: mt6577_auxadc: Simplify with dev_err_probe()
Use the dev_err_probe() helper to simplify error handling during probe.
This also handle scenario, when EDEFER is returned and useless error
is printed.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Suggested-by: Jonathan Cameron <jic23@kernel.org>
Link: https://lore.kernel.org/r/20230826035402.3512033-2-ruanjinjie@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11 20:12:40 +01:00
Jinjie Ruan
b564b99de7 iio: adc: spear_adc: Use dev_err_probe()
Use the dev_err_probe() helper to simplify error handling during probe.
This also handle scenario, when EDEFER is returned and useless error
is printed.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Link: https://lore.kernel.org/r/20230826062733.3714169-3-ruanjinjie@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11 20:12:40 +01:00
Jinjie Ruan
3878ae2a1a iio: adc: spear_adc: Use device managed function
The devm_clk_get_enabled() helper:
    - calls devm_clk_get()
    - calls clk_prepare_enable() and registers what is needed in order to
      call clk_disable_unprepare() when needed, as a managed resource.

Switch to devm_iio_device_register() and drop the remove function.

This simplifies the code.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Link: https://lore.kernel.org/r/20230826062733.3714169-2-ruanjinjie@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11 20:12:39 +01:00
Jinjie Ruan
a3e9625ec0 iio: adc: mt6577_auxadc: Use devm_clk_get_enabled() helper function
The devm_clk_get_enabled() helper:
    - calls devm_clk_get()
    - calls clk_prepare_enable() and registers what is needed in order to
      call clk_disable_unprepare() when needed, as a managed resource.

This simplifies the code.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Link: https://lore.kernel.org/r/20230825105746.2999548-3-ruanjinjie@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11 20:12:39 +01:00
Linus Torvalds
1c9f8dff62 Char/Misc driver changes for 6.6-rc1
Here is the big set of char/misc and other small driver subsystem
 changes for 6.6-rc1.
 
 Stuff all over the place here, lots of driver updates and changes and
 new additions.  Short summary is:
   - new IIO drivers and updates
   - Interconnect driver updates
   - fpga driver updates and additions
   - fsi driver updates
   - mei driver updates
   - coresight driver updates
   - nvmem driver updates
   - counter driver updates
   - lots of smaller misc and char driver updates and additions
 
 All of these have been in linux-next for a long time with no reported
 problems.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCZPH64g8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ynr2QCfd3RKeR+WnGzyEOFhksl30UJJhiIAoNZtYT5+
 t9KG0iMDXRuTsOqeEQbd
 =tVnk
 -----END PGP SIGNATURE-----

Merge tag 'char-misc-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char/misc driver updates from Greg KH:
 "Here is the big set of char/misc and other small driver subsystem
  changes for 6.6-rc1.

  Stuff all over the place here, lots of driver updates and changes and
  new additions. Short summary is:

   - new IIO drivers and updates

   - Interconnect driver updates

   - fpga driver updates and additions

   - fsi driver updates

   - mei driver updates

   - coresight driver updates

   - nvmem driver updates

   - counter driver updates

   - lots of smaller misc and char driver updates and additions

  All of these have been in linux-next for a long time with no reported
  problems"

* tag 'char-misc-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (267 commits)
  nvmem: core: Notify when a new layout is registered
  nvmem: core: Do not open-code existing functions
  nvmem: core: Return NULL when no nvmem layout is found
  nvmem: core: Create all cells before adding the nvmem device
  nvmem: u-boot-env:: Replace zero-length array with DECLARE_FLEX_ARRAY() helper
  nvmem: sec-qfprom: Add Qualcomm secure QFPROM support
  dt-bindings: nvmem: sec-qfprom: Add bindings for secure qfprom
  dt-bindings: nvmem: Add compatible for QCM2290
  nvmem: Kconfig: Fix typo "drive" -> "driver"
  nvmem: Explicitly include correct DT includes
  nvmem: add new NXP QorIQ eFuse driver
  dt-bindings: nvmem: Add t1023-sfp efuse support
  dt-bindings: nvmem: qfprom: Add compatible for MSM8226
  nvmem: uniphier: Use devm_platform_get_and_ioremap_resource()
  nvmem: qfprom: do some cleanup
  nvmem: stm32-romem: Use devm_platform_get_and_ioremap_resource()
  nvmem: rockchip-efuse: Use devm_platform_get_and_ioremap_resource()
  nvmem: meson-mx-efuse: Convert to devm_platform_ioremap_resource()
  nvmem: lpc18xx_otp: Convert to devm_platform_ioremap_resource()
  nvmem: brcm_nvram: Use devm_platform_get_and_ioremap_resource()
  ...
2023-09-01 09:53:54 -07:00
Mark Brown
0bbe06493b
Add cs42l43 PC focused SoundWire CODEC
Merge series from Charles Keepax <ckeepax@opensource.cirrus.com>:

This patch chain adds support for the Cirrus Logic cs42l43 PC focused
SoundWire CODEC. The chain is currently based of Lee's for-mfd-next
branch.

This series is mostly just a resend keeping pace with the kernel under
it, except for a minor fixup in the ASoC stuff.

Thanks,
Charles

Charles Keepax (4):
  dt-bindings: mfd: cirrus,cs42l43: Add initial DT binding
  mfd: cs42l43: Add support for cs42l43 core driver
  pinctrl: cs42l43: Add support for the cs42l43
  ASoC: cs42l43: Add support for the cs42l43

Lucas Tanure (2):
  soundwire: bus: Allow SoundWire peripherals to register IRQ handlers
  spi: cs42l43: Add SPI controller support

 .../bindings/sound/cirrus,cs42l43.yaml        |  313 +++
 MAINTAINERS                                   |    4 +
 drivers/mfd/Kconfig                           |   23 +
 drivers/mfd/Makefile                          |    3 +
 drivers/mfd/cs42l43-i2c.c                     |   98 +
 drivers/mfd/cs42l43-sdw.c                     |  239 ++
 drivers/mfd/cs42l43.c                         | 1188 +++++++++
 drivers/mfd/cs42l43.h                         |   28 +
 drivers/pinctrl/cirrus/Kconfig                |   11 +
 drivers/pinctrl/cirrus/Makefile               |    2 +
 drivers/pinctrl/cirrus/pinctrl-cs42l43.c      |  609 +++++
 drivers/soundwire/bus.c                       |   32 +
 drivers/soundwire/bus_type.c                  |   12 +
 drivers/spi/Kconfig                           |    7 +
 drivers/spi/Makefile                          |    1 +
 drivers/spi/spi-cs42l43.c                     |  284 ++
 include/linux/mfd/cs42l43-regs.h              | 1184 +++++++++
 include/linux/mfd/cs42l43.h                   |  102 +
 include/linux/soundwire/sdw.h                 |    9 +
 include/sound/cs42l43.h                       |   17 +
 sound/soc/codecs/Kconfig                      |   16 +
 sound/soc/codecs/Makefile                     |    4 +
 sound/soc/codecs/cs42l43-jack.c               |  946 +++++++
 sound/soc/codecs/cs42l43-sdw.c                |   74 +
 sound/soc/codecs/cs42l43.c                    | 2278 +++++++++++++++++
 sound/soc/codecs/cs42l43.h                    |  131 +
 26 files changed, 7615 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/cirrus,cs42l43.yaml
 create mode 100644 drivers/mfd/cs42l43-i2c.c
 create mode 100644 drivers/mfd/cs42l43-sdw.c
 create mode 100644 drivers/mfd/cs42l43.c
 create mode 100644 drivers/mfd/cs42l43.h
 create mode 100644 drivers/pinctrl/cirrus/pinctrl-cs42l43.c
 create mode 100644 drivers/spi/spi-cs42l43.c
 create mode 100644 include/linux/mfd/cs42l43-regs.h
 create mode 100644 include/linux/mfd/cs42l43.h
 create mode 100644 include/sound/cs42l43.h
 create mode 100644 sound/soc/codecs/cs42l43-jack.c
 create mode 100644 sound/soc/codecs/cs42l43-sdw.c
 create mode 100644 sound/soc/codecs/cs42l43.c
 create mode 100644 sound/soc/codecs/cs42l43.h

--
2.30.2
2023-08-22 12:48:04 +01:00
Greg Kroah-Hartman
e75850b457 Merge 6.5-rc6 into char-misc-next
We need the char/misc fixes in here as well to build on top of.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-08-13 22:14:51 +02:00
Antoniu Miclaus
1ed8775496 drivers: iio: filter: admv8818: add bypass mode
Add filter bypass mode, which bypasses the low pass filter, high pass
filter and disables/unregister the clock rate notifier.

Currently a feature like bypassing the filter is not achievable
straightforward and not very deductive. The user has to look through the
code and call the set_lpf_3db_frequency and set_hpf_3db_frequency iio
attributes from the user interface using the corner cases (freq >
largest lpf supported by the part, respectively freq < smallest hpf
supported by the part). Moreover, in such case of bypassing the filter,
the input clock rate change might mess up things so we want to make sure
that it is disabled. Also, the feature will help emphasizing the filter
behavior, therefore adding it in the userspace will ease the
charcaterization of the filter's effects when active/disabled.

It was requested by users of the driver to ease the interaction with
different configuration modes of the device.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://lore.kernel.org/r/20230731084928.8302-1-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-08-08 09:51:06 +01:00
Matti Vaittinen
fdb48f9d1a iio: light: bd27008: Support BD27010 RGB
The ROHM BU27010 is an RGBC sensor with a flickering detection FIFO. The
RGBC+IR sensor functionality is largely similar to what the BU27008 has.
There are some notable things though:
  - gain setting is once again new and exotic. Now, there is 6bit gain
    setting where 4 of the bits are common to all channels and 2 bits
    can be configured separately for each channel. The BU27010 has
    similar "1X on other channels vs 2X on IR when selector is 0x0"
    gain design as BU27008 had. So, we use same gain setting policy for
    BU27010 as we did for BU27008 - driver sets same gain selector for all
    channels but shows the gains separately for all channels so users
    can (at least in theory) detect this 1X vs 2X madness...
  - BU27010 has suffled all the control register bitfields to new
    addresses and bit positions while still keeping the register naming
    same.
  - Some more power/reset control is added.
  - FIFO for "flickering detection" is added.

The control register suffling made this slightly nasty. Still, it is
easier for maintenance perspective to add the BU27010 support in BU27008
driver because - even though the bit positions/addresses were changed -
most of the driver structure can be re-used. Writing own driver for
BU27010 would mean plenty of duplicate code albeit a tad more clarity.

The flickering FIFO is not supported by the driver.

Add BU27010 RGBC+IR support to rohm-bu27008 driver.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/111cd217ccece1c1f16ab4287532dc4e1ddb8a3f.1690958450.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-08-08 09:51:06 +01:00
Matti Vaittinen
ccca97fb3c iio: light: bu27008: add chip info
The ROHM BU27010 RGB + flickering sensor is in many regards similar to
the BU27008. Prepare for adding support for BU27010 by allowing
chip-specific properties to be brought from the of_device_id data.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/d5994648033d5513993b8d72eb186ddda211b5ac.1690958450.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-08-08 09:50:51 +01:00
Andrea Collamati
7b24a034ad iio: add MCP4728 I2C DAC driver
MCP4728 is a 12-bit quad channel DAC with I2C interface.

support for:
 * per-channel gain
 * per-channel power state
 * per-channel power down mode control
 * per-channel vref selection internal/vdd
 * store current state to on-chip EEPROM

Signed-off-by: Andrea Collamati <andrea.collamati@gmail.com>
Link: https://lore.kernel.org/r/a0933003ed3c855f9d80d6ce0a40add2b6f0ba36.1691066050.git.andrea.collamati@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-08-05 19:29:39 +01:00
Antoniu Miclaus
320b92a4c1 drivers: iio: admv1013: add vcc regulators
Add regulators for the VCC supplies of the admv1013.

The patch aims to align the implementation with the current admv1014
driver where all the VCC supplies are handled as regulators.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://lore.kernel.org/r/20230731094455.26742-2-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-08-05 19:29:39 +01:00
Andrei Coardos
d866f14071 iio: trigger: stm32-lptimer-trigger: remove unneeded platform_set_drvdata()
This function call was found to be unnecessary as there is no equivalent
platform_get_drvdata() call to access the private data of the driver. Also,
the private data is defined in this driver, so there is no risk of it being
accessed outside of this driver file.

Reviewed-by: Alexandru Ardelean <alex@shruggie.ro>
Signed-off-by: Andrei Coardos <aboutphysycs@gmail.com>
Link: https://lore.kernel.org/r/20230802120915.25631-1-aboutphysycs@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-08-05 19:29:39 +01:00
Li Zetao
e19480dded iio: adc: men_z188_adc: Remove redundant initialization owner in men_z188_driver
The module_mcb_driver() will set "THIS_MODULE" to driver.owner when
register a mcb_driver, so it is redundant initialization to set
driver.owner in men_z188_driver statement. Remove it for clean code.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
Link: https://lore.kernel.org/r/20230804100938.100435-1-lizetao1@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-08-05 17:43:17 +01:00
Matti Vaittinen
b20f5801ec iio: cdc: ad7150: relax return value check for IRQ get
fwnode_irq_get[_byname]() were changed to not return 0 anymore. The
special error case where device-tree based IRQ mapping fails can't no
longer be reliably detected from this return value. This yields a
functional change in the driver where the mapping failure is treated as
an error.

The mapping failure can occur for example when the device-tree IRQ
information translation call-back(s) (xlate) fail, IRQ domain is not
found, IRQ type conflicts, etc. In most cases this indicates an error in
the device-tree and special handling is not really required.

One more thing to note is that ACPI APIs do not return zero for any
failures so this special handling did only apply on device-tree based
systems.

Drop the special handling for DT mapping failures as these can no longer
be separated from other errors at driver side. Change all failures in
IRQ getting to be handled by continuing without the events instead of
aborting the probe upon certain errors.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/3ad1c6f195ead3dfa8711235e1dead139d27f700.1690890774.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-08-01 18:55:55 +01:00
Matti Vaittinen
1402913c92 iio: mb1232: relax return value check for IRQ get
fwnode_irq_get() was changed to not return 0 anymore.

Drop check for return value 0.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/9e18cf49a8bb581a84c3fa548ea577e2a3eb840d.1690890774.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-08-01 18:55:46 +01:00
Ruan Jinjie
c09ddcdd4d iio: adc: fix the return value handle for platform_get_irq()
There is no possible for platform_get_irq() to return 0
and the return value of platform_get_irq() is more sensible
to show the error reason.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Link: https://lore.kernel.org/r/20230727131607.2897937-1-ruanjinjie@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-29 16:23:45 +01:00
Biju Das
9afc8c6dc6 iio: potentiometer: mcp4531: Use i2c_get_match_data()
Replace device_get_match_data() and i2c_match_id() by i2c_get_match
_data() by making similar I2C and DT-based matching table.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20230723102743.102284-1-biju.das.jz@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-29 15:55:48 +01:00
Biju Das
b68adc0ee5 iio: potentiometer: mcp4018: Use i2c_get_match_data()
Replace of_device_get_match_data() and i2c_match_id() by i2c_get_match
_data() by making similar I2C and DT-based matching table.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20230723105209.175545-1-biju.das.jz@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-29 15:53:59 +01:00
Andy Shevchenko
65659a8df1 iio: core: Fix issues and style of the comments
The `scripts/kernel-doc -v -none -Wall` reports several issues
with the kernel doc in IIO core C file. Update the comments
accordingly.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20230724110204.46285-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-29 12:48:09 +01:00
Andy Shevchenko
5a0821e0e3 iio: core: Switch to krealloc_array()
Let the krealloc_array() copy the original data and
check for a multiplication overflow.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230724110204.46285-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-29 12:47:28 +01:00
Andy Shevchenko
971ddd4b4d iio: core: Use sysfs_match_string() helper
Use sysfs_match_string() helper instead of open coded variant.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230724110204.46285-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-29 12:34:59 +01:00
Biju Das
579f6b003a iio: accel: adxl313: Use i2c_get_match_data
Replace device_get_match_data() and i2c_match_id() by i2c_get_match
_data() as we have similar I2C and DT-based matching table.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20230725171624.331283-3-biju.das.jz@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-29 12:30:39 +01:00
Biju Das
f636554c4c iio: accel: adxl313: Fix adxl313_i2c_id[] table
The .driver_data in adxl313_i2c_id[] for adxl312 and adxl314 is
wrong. Fix this issue by adding corresponding adxl31x_chip_info
data.

Reported-by: Jonathan Cameron <jic23@kernel.org>
Closes: https://lore.kernel.org/all/20230722172832.04ad7738@jic23-huawei
Fixes: a7a1c60bc4 ("drivers: iio: accel: adxl312 and adxl314 support")
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20230725171624.331283-2-biju.das.jz@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-29 12:30:39 +01:00
Yiyuan Guo
8a4629055e iio: cros_ec: Fix the allocation size for cros_ec_command
The struct cros_ec_command contains several integer fields and a
trailing array. An allocation size neglecting the integer fields can
lead to buffer overrun.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Yiyuan Guo <yguoaz@gmail.com>
Fixes: 974e6f02e2 ("iio: cros_ec_sensors_core: Add common functions for the ChromeOS EC Sensor Hub.")
Link: https://lore.kernel.org/r/20230630143719.1513906-1-yguoaz@gmail.com
Cc: <Stable@vger.kerenl.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-29 12:21:21 +01:00
Ruan Jinjie
089c1e1132 iio: adc: Remove redundant dev_err_probe()
There is no need to call the dev_err() function directly to print a custom
message when handling an error from either the platform_get_irq() or
platform_get_irq_byname() functions as both are going to display an
appropriate error message in case of a failure.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/r/20230727073912.4178659-1-ruanjinjie@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-29 12:13:17 +01:00
Alejandro Tafalla
6811694eb2 iio: imu: lsm6dsx: Fix mount matrix retrieval
The function lsm6dsx_get_acpi_mount_matrix should return an error when ACPI
support is not enabled to allow executing iio_read_mount_matrix in the
probe function.

Fixes: dc3d25f22b ("iio: imu: lsm6dsx: Add ACPI mount matrix retrieval")
Signed-off-by: Alejandro Tafalla <atafalla@dnyon.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/20230714153132.27265-1-atafalla@dnyon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-23 13:40:45 +01:00
Rob Herring
1240c94ce8 iio: adc: Explicitly include correct DT includes
The DT of_device.h and of_platform.h date back to the separate
of_platform_bus_type before it as merged into the regular platform bus.
As part of that merge prepping Arm DT support 13 years ago, they
"temporarily" include each other. They also include platform_device.h
and of.h. As a result, there's a pretty much random mix of those include
files used throughout the tree. In order to detangle these headers and
replace the implicit includes with struct declarations, users need to
explicitly include the correct includes.

Signed-off-by: Rob Herring <robh@kernel.org>
Acked-by: Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/r/20230714174628.4057920-1-robh@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-23 13:38:13 +01:00
Ramona Bolboaca
c1f10bff16 iio: imu: adis16475.c: Add has_burst32 flag to adis16477 devices
adis16477 devices support burst32 function, thus has_burst32
flag should be set to true.

Signed-off-by: Ramona Bolboaca <ramona.bolboaca@analog.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230719123152.309624-3-ramona.bolboaca@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-23 13:24:33 +01:00
Ramona Bolboaca
a216d411b5 iio: imu: adis16475.c: Remove unused enum elements
Remove unused enum elements ADIS16475_SCAN_DIAG_S_FLAGS and
ADIS16475_SCAN_CRC_FAILURE.

Signed-off-by: Ramona Bolboaca <ramona.bolboaca@analog.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230719123152.309624-2-ramona.bolboaca@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-23 13:23:22 +01:00
Waqar Hameed
3db3562bc6 iio: Add driver for Murata IRS-D200
Murata IRS-D200 is a PIR sensor for human detection. It has support for
raw data measurements and detection event notification.

Add a driver with support for triggered buffer and events. Map the
various settings to the `iio` framework, e.g. threshold values, sampling
frequency, filter frequencies etc.

Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://lore.kernel.org/r/d218a1bc75402b5ebd6e12a563f7315f83fe966c.1689753076.git.waqar.hameed@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-23 13:21:54 +01:00
Waqar Hameed
5e1cd3e97e iio: Add event enums for running period and count
There are devices (such as Murata IRS-D200 PIR proximity sensor) that
check the data signal with a running period. I.e. for a specified time,
they count the number of conditions that have occurred, and then signal
if that is more than a specified amount.

`IIO_EV_INFO_PERIOD` resets when the condition no longer is true and is
therefore not suitable for these devices. Add a new `iio_event_info`
`IIO_EV_INFO_RUNNING_PERIOD` that can be used as a running period. Also
add a new `IIO_EV_INFO_RUNNING_COUNT` that can be used to specify the
number of conditions that must occur during this running period.

Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://lore.kernel.org/r/ee4a801ae9b9c4716c7bd23d8f79f232351df8bd.1689753076.git.waqar.hameed@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-23 13:16:18 +01:00
Kim Seer Paller
247d3b6321 iio: amplifiers: ad8366: add support for HMC792A Attenuator
This change adds support for the HMC792A Digital Attenuator. The
HMC792A is a broadband 6-bit GaAs MMIC Digital Attenuator operating
from DC to 6.0 GHz with 15.75 dB attenuation control range in 0.25 dB steps.

Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/hmc792a.pdf
Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
Link: https://lore.kernel.org/r/20230721121038.183404-1-kimseer.paller@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-23 12:22:56 +01:00
Andy Shevchenko
b662f4ba20 iio: core: Improve indentation in a few places
Improve an indentation in a few places to increase readability.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230721170022.3461-9-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-23 10:24:16 +01:00
Andy Shevchenko
1702df5d8f iio: core: Get rid of redundant 'else'
In the snippets like the following

	if (...)
		return / goto / break / continue ...;
	else
		...

the 'else' is redundant. Get rid of it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230721170022.3461-6-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-23 10:15:42 +01:00
Andy Shevchenko
cb1d175350 iio: core: Use min() instead of min_t() to make code more robust
min() has strict type checking and preferred over min_t() for
unsigned types to avoid overflow. Here it's unclear why min_t()
was chosen since both variables are of the same type. In any
case update to use min().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230721170022.3461-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-23 10:13:47 +01:00
George Stark
09738ccbc4 iio: adc: meson: fix core clock enable/disable moment
Enable core clock at probe stage and disable it at remove stage.
Core clock is responsible for turning on/off the entire SoC module so
it should be on before the first module register is touched and be off
at very last moment.

Fixes: 3adbf34273 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs")
Signed-off-by: George Stark <gnstark@sberdevices.ru>
Link: https://lore.kernel.org/r/20230721102413.255726-2-gnstark@sberdevices.ru
Cc: <stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-22 18:12:53 +01:00
George Stark
90c6241860 iio: adc: meson: init voltage control bits
Define and init voltage configuration bits. Those bits are inited in
vendor boot code (bl2, bl33) already so do it in the driver to not depend
on other code.

Introduced bits:
REG11[0] - selects Vref. 0 - calibration voltage, 1 - VDDA. txlx and later
           SoCs support VDDA or calibration voltage as Vref, but others
           support only calibration voltage. For newer platforms vendor
	   uses VDDA as default.
REG11[1] - reserved bit. g12a and later SoCs must write 1, others SoCs
           write 0.
REG11[5] - Vref voltage. 0 - 0.9v, 1 - 1.8v. g12a and later SoCs must
           write 0, others SoCs write 1.
REG11[6] - selects common-mode voltage, 0: from AVDD, 1: from Vref.
           g12a and later SoCs must write 0, others SoCs write 1.

Signed-off-by: George Stark <gnstark@sberdevices.ru>
Link: https://lore.kernel.org/r/20230715110654.6035-4-gnstark@sberdevices.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-22 17:58:23 +01:00
George Stark
d1adcaf7a4 iio: adc: meson: init internal continuous ring counter
Disable internal continuous ring counter at init stage. Disable value
depends on SoC family: gxl and later SoCs write 1, others write 0.
This bit are inited in vendor boot code (bl2, bl33) already so do it
in the driver to not depend on other code.

Signed-off-by: George Stark <gnstark@sberdevices.ru>
Link: https://lore.kernel.org/r/20230715110654.6035-3-gnstark@sberdevices.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-22 17:58:23 +01:00
George Stark
6ad9f01cf4 iio: adc: meson: init channels 0,1 input muxes
Set up input channels 0,1 muxes in the same way as for the channels 2-7
later in the code.

Signed-off-by: George Stark <gnstark@sberdevices.ru>
Link: https://lore.kernel.org/r/20230715110654.6035-2-gnstark@sberdevices.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-22 17:58:23 +01:00
Milan Zamazal
b2a6996990 iio: core: Prevent invalid memory access when there is no parent
Commit 813665564b ("iio: core: Convert to use firmware node handle
instead of OF node") switched the kind of nodes to use for label
retrieval in device registration.  Probably an unwanted change in that
commit was that if the device has no parent then NULL pointer is
accessed.  This is what happens in the stock IIO dummy driver when a
new entry is created in configfs:

  # mkdir /sys/kernel/config/iio/devices/dummy/foo
  BUG: kernel NULL pointer dereference, address: ...
  ...
  Call Trace:
  __iio_device_register
  iio_dummy_probe

Since there seems to be no reason to make a parent device of an IIO
dummy device mandatory, let’s prevent the invalid memory access in
__iio_device_register when the parent device is NULL.  With this
change, the IIO dummy driver works fine with configfs.

Fixes: 813665564b ("iio: core: Convert to use firmware node handle instead of OF node")
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Link: https://lore.kernel.org/r/20230719083208.88149-1-mzamazal@redhat.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-22 17:51:55 +01:00
Dan Carpenter
507397d19b iio: frequency: admv1013: propagate errors from regulator_get_voltage()
The regulator_get_voltage() function returns negative error codes.
This function saves it to an unsigned int and then does some range
checking and, since the error code falls outside the correct range,
it returns -EINVAL.

Beyond the messiness, this is bad because the regulator_get_voltage()
function can return -EPROBE_DEFER and it's important to propagate that
back properly so it can be handled.

Fixes: da35a7b526 ("iio: frequency: admv1013: add support for ADMV1013")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/ce75aac3-2aba-4435-8419-02e59fdd862b@moroto.mountain
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-22 17:33:38 +01:00
Biju Das
ad25fc289b iio: accel: adxl355: Simplify probe()
Simplify the probe() by replacing of_device_get_match_data() and
i2c_match_id() by i2c_get_match_data() as we have similar I2C
and DT-based matching table.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Puranjay Mohan <puranjay12@gmail.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20230716175218.130557-2-biju.das.jz@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-22 17:24:51 +01:00
George Stark
3a06b2845a iio: adc: meson: support reading from channel 7 mux inputs
Add IIO channel for all muxed inputs of channel 7.
Meson saradc channel 7 is connected to a mux that can switch input
to well-known sources like Vdd, GND and several Vdd dividers.

Signed-off-by: George Stark <GNStark@sberdevices.ru>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230714114010.293440-7-gnstark@sberdevices.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:31 +01:00
George Stark
b593ce5db2 iio: adc: meson: add channel labels
Add channel labels to provide human-readable names for the inputs.

Signed-off-by: George Stark <GNStark@sberdevices.ru>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230714114010.293440-6-gnstark@sberdevices.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:31 +01:00
George Stark
c38180bf3d iio: adc: meson: add enum for iio channel numbers
Channels could be referenced in the driver code and using enum allows
to make it more robust.

Signed-off-by: George Stark <GNStark@sberdevices.ru>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230714114010.293440-5-gnstark@sberdevices.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:31 +01:00
George Stark
2b592ff48e iio: adc: meson: move meson_sar_adc_set_chan7_mux routine upper
meson_sar_adc_set_chan7_mux is a basic func() for writing single register,
defined as static. Moved it up so it could be used in more places.

Signed-off-by: George Stark <GNStark@sberdevices.ru>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230714114010.293440-4-gnstark@sberdevices.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:30 +01:00
George Stark
d26f0514f0 iio: adc: meson: move enums declaration before variables declaration
Allow to use enum items for variables initialization.
For this, move enums upper in the code.

Signed-off-by: George Stark <GNStark@sberdevices.ru>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230714114010.293440-3-gnstark@sberdevices.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:30 +01:00
George Stark
1a0dabd4df iio: adc: meson: remove unused timestamp channel
Remove IIO_CHAN_SOFT_TIMESTAMP channel because it's used only for
buffering mode which is not implemented.

Signed-off-by: George Stark <GNStark@sberdevices.ru>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230714114010.293440-2-gnstark@sberdevices.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:30 +01:00
Roan van Dijk
3f3caf5b2e iio: chemical: scd4x: Add pressure compensation
This patch adds pressure compensation to the scd4x driver. The pressure can
be written to the sensor in hPa. The pressure will be compensated
internally by the sensor.

Signed-off-by: Roan van Dijk <roan@protonic.nl>
Link: https://lore.kernel.org/r/20230711101419.2065107-1-roan@protonic.nl
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:30 +01:00
Waqar Hameed
4dc8f99dab iio: Make return value check for set_trigger_state() consistent
In `iio_trigger_detach_poll_func()` the return value from
`trig->ops->set_trigger_state(trig, false)` is checked with `if (ret)`.
However, in `iio_trigger_attach_poll_func()` it is checked with
`if (ret < 0)`. Resolve this mismatch by only checking for `if (ret)` in
both places.

Signed-off-by: Waqar Hameed <waqar.hameed@axis.com>
Link: https://lore.kernel.org/r/pndv8eojdey.fsf@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:30 +01:00
Leonard Göhrs
6c7bc1d27b iio: adc: ti-lmp92064: add buffering support
Enable buffered reading of samples from the LMP92064 ADC.
The main benefit of this change is being able to read out current and
voltage measurements in a single transfer, allowing instantaneous power
measurements.

Reads into the buffer can be triggered by any software triggers, e.g.
the iio-trig-hrtimer:

    $ mkdir /sys/kernel/config/iio/triggers/hrtimer/my-trigger
    $ cat /sys/bus/iio/devices/iio\:device3/name
    lmp92064
    $ iio_readdev -t my-trigger -b 16 iio:device3 | hexdump
    WARNING: High-speed mode not enabled
    0000000 0000 0176 0101 0001 5507 abd5 7645 1768
    0000010 0000 016d 0101 0001 ee1e ac6b 7645 1768
    ...

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230707063635.1496437-1-l.goehrs@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:30 +01:00
Yangtao Li
1f2a4d506f iio: adc: stm32-adc: Use devm_platform_get_and_ioremap_resource()
Convert platform_get_resource(), devm_ioremap_resource() to a single
call to devm_platform_get_and_ioremap_resource(), as this is exactly
what this function does.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Link: https://lore.kernel.org/r/20230704095808.33780-1-frank.li@vivo.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:30 +01:00
Konrad Dybcio
96543470d5 iio: adc: qcom-spmi-adc5: Add ADC5_GPIO2_100K_PU
Even though it existed in bindings for the longest time,
ADC5_GPIO2_100K_PU was never assigned in the driver. Do so.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230627-topic-adc-v1-1-c61581abffa3@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:30 +01:00
Jean-Baptiste Maneyrol
0829edc43e iio: imu: inv_mpu6050: read the full fifo when processing data
When processing data read the full fifo data in 1 time. If there
are several samples in the FIFO, it means we are experiencing
system delay. In this case, it is better to read all data with 1
bus access than to add additional latency by doing several ones.

This requires to use a bigger buffer depending on chip FIFO size
and do an additional local data copy before sending. But the cost
is minimal and behavior is still better like this under system
heavy load.

Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Link: https://lore.kernel.org/r/20230623082924.283967-1-inv.git-commit@tdk.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:30 +01:00
Alisa Roman
1cbf2c4bea iio: adc: ad7192: Use sysfs_emit_at
Replace scnprintf with sysfs_emit_at which is the preferred alternative.

Also make sure each fractional digit is in its place by padding with
zeros up to 3 digits: "...%03d...".

Signed-off-by: Alisa Roman <alisa.roman@analog.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230620163135.93780-1-alisa.roman@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:30 +01:00
Maksim Kiselev
046dd089eb iio: adc: Add Allwinner D1/T113s/R329/T507 SoCs GPADC
The General Purpose ADC (GPADC) can convert the external signal into
a certain proportion of digital value, to realize the measurement of
analog signal, which can be applied to power detection and key detection.

Theoretically, this ADC can support up to 16 channels. All SoCs below
contain this GPADC IP. The only difference between them is the number
of available channels:

 T113 - 1 channel
 D1   - 2 channels
 R329 - 4 channels
 T507 - 4 channels

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Maksim Kiselev <bigunclemax@gmail.com>
Link: https://lore.kernel.org/r/20230619154252.3951913-3-bigunclemax@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:29 +01:00
Maksim Kiselev
83e9612980 iio: adc: Kconfig change description for Allwinner GPADC
This patch adds SoCs names to Allwinner GPADC description to
make it more informative.

Signed-off-by: Maksim Kiselev <bigunclemax@gmail.com>
Link: https://lore.kernel.org/r/20230619154252.3951913-2-bigunclemax@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:29 +01:00
Astrid Rost
bb33e75149 iio: light: vcnl4000: Add calibration bias for 4040/4200
The calibration bias is setting the LED current to change the detection
distance. Add read/write attribute for proximity calibration bias and
read attribute for available values. This is supported for vcnl4040 and
vcnl4200.

Signed-off-by: Astrid Rost <astrid.rost@axis.com>
Link: https://lore.kernel.org/r/20230613135025.2596641-9-astrid.rost@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:29 +01:00
Astrid Rost
add9846676 iio: light: vcnl4000: Add oversampling_ratio for 4040/4200
Add the proximity multi pulse (PS_MPS) as oversampling_ratio.
Instead of one single pulse per every defined time frame, one can
program2, 4, or even 8 pulses. This leads to a longer IRED on-time
for each proximity measurement value, which also results in a higher
detection range.

Add read/write attribute for proximity oversampling-ratio and read
attribute for available oversampling-ratio.
This is supported for vcnl4040 and vcnl4200.

Signed-off-by: Astrid Rost <astrid.rost@axis.com>
Link: https://lore.kernel.org/r/20230613135025.2596641-8-astrid.rost@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:29 +01:00
Astrid Rost
7f8651270c iio: light: vcnl4000: Add period for vcnl4040/4200
Add read/write attribute for proximity and illuminance period. The
period is set in the interrupt persistence flags(PS_PERS and ALS_PERS).
An interrupt will not be asserted if the raw value is not over (or lower)
than the threshold for the set continued amount of measurements.
The time in seconds is calculated by the number of continued refreshes
multiplied with the integration time.
It will always pick the next lower possible value. The period changes,
if the integration time is changed.

Signed-off-by: Astrid Rost <astrid.rost@axis.com>
Link: https://lore.kernel.org/r/20230613135025.2596641-7-astrid.rost@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:29 +01:00
Astrid Rost
bc292aaf9c iio: light: vcnl4000: add illuminance irq vcnl4040/4200
Add support to configure ambient light sensor interrupts and threshold
limits for vcnl4040 and vcnl4200. If an interrupt is detected an event
will be pushed to the event interface.

Signed-off-by: Astrid Rost <astrid.rost@axis.com>
Link: https://lore.kernel.org/r/20230613135025.2596641-6-astrid.rost@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:29 +01:00
Astrid Rost
fea2c97d9e iio: light: vcnl4000: Add als_it for vcnl4040/4200
Add illuminance integration time for vcnl4040 and vcnl4200.
Add read/write attribute for illuminance integration time and read
attribute for available integration times.
Set scale and sampling rate according to the integration time.

Signed-off-by: Astrid Rost <astrid.rost@axis.com>
Link: https://lore.kernel.org/r/20230613135025.2596641-5-astrid.rost@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:29 +01:00
Astrid Rost
2be17b6889 iio: light: vcnl4000: Check type with switch case
Check IIO_PROXIMITY  with switch case in order to make it easier
to add further types like light.
Add check for IIO_EV_INFO_VALUE for writing rising or falling events.

Signed-off-by: Astrid Rost <astrid.rost@axis.com>
Link: https://lore.kernel.org/r/20230613135025.2596641-4-astrid.rost@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:29 +01:00
Astrid Rost
e55c96daf7 iio: light: vcnl4000: Add proximity ps_it for vcnl4200
Add ps_it attributes for vcnl4200 (similar to vcnl4040).
Add read/write attribute for proximity integration time.
Read attribute for available proximity integration times.
Change sampling rate depending on integration time.

Signed-off-by: Astrid Rost <astrid.rost@axis.com>
Link: https://lore.kernel.org/r/20230613135025.2596641-3-astrid.rost@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:29 +01:00
Astrid Rost
854965b7db iio: light: vcnl4000: Add proximity irq for vcnl4200
Add proximity interrupt support for vcnl4200 (similar to vcnl4040).
Add support to configure proximity sensor interrupts and threshold
limits. If an interrupt is detected an event will be pushed to the
event interface.

Signed-off-by: Astrid Rost <astrid.rost@axis.com>
Link: https://lore.kernel.org/r/20230613135025.2596641-2-astrid.rost@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:29 +01:00
Hans de Goede
3d936dfec0 iio: accel: da280: Add support for the DA217 accelerometer
The DA217 accelerometer is another DA280 compatible accelerometer,
add its device-ids to the da280 driver.

Reported-by: Juno Computers USA <usa@junocomputers.com>
Tested-by: Juno Computers USA <usa@junocomputers.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230613094346.162551-1-hdegoede@redhat.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:29 +01:00
Jean-Baptiste Maneyrol
111e1abd00 iio: imu: inv_mpu6050: use the common inv_sensors timestamp module
Replace timestamping by the new common inv_sensors timestamp
module. The principle behind is the same but the implementation in
the new module is far better providing less jitter and a better
estimation.

Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20230606162147.79667-5-inv.git-commit@tdk.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:29 +01:00
Jean-Baptiste Maneyrol
0ecc363cce iio: make invensense timestamp module generic
Rename common module to inv_sensors_timestamp, add configuration
at init (chip internal clock, acceptable jitter, ...) and update
inv_icm42600 driver integration.

Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20230606162147.79667-4-inv.git-commit@tdk.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:28 +01:00
Jean-Baptiste Maneyrol
d99ff463ec iio: move inv_icm42600 timestamp module in common
Create new inv_sensors common modules and move inv_icm42600
timestamp module inside. This module will be used by IMUs and
also in the future by other chips.

Modify inv_icm42600 driver to use timestamp module and do some
headers cleanup.

Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20230606162147.79667-3-inv.git-commit@tdk.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:28 +01:00
Jean-Baptiste Maneyrol
6e9f2d8375 iio: imu: inv_icm42600: make timestamp module chip independent
Move icm42600 dependent function inside the core module.
Do some headers cleanup at the same time.

Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20230606162147.79667-2-inv.git-commit@tdk.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-20 19:21:28 +01:00
Alvin Šipraga
a41e19cc0d iio: adc: ina2xx: avoid NULL pointer dereference on OF device match
The affected lines were resulting in a NULL pointer dereference on our
platform because the device tree contained the following list of
compatible strings:

    power-sensor@40 {
        compatible = "ti,ina232", "ti,ina231";
        ...
    };

Since the driver doesn't declare a compatible string "ti,ina232", the OF
matching succeeds on "ti,ina231". But the I2C device ID info is
populated via the first compatible string, cf. modalias population in
of_i2c_get_board_info(). Since there is no "ina232" entry in the legacy
I2C device ID table either, the struct i2c_device_id *id pointer in the
probe function is NULL.

Fix this by using the already populated type variable instead, which
points to the proper driver data. Since the name is also wanted, add a
generic one to the ina2xx_config table.

Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Fixes: c43a102e67 ("iio: ina2xx: add support for TI INA2xx Power Monitors")
Link: https://lore.kernel.org/r/20230619141239.2257392-1-alvin@pqrs.dk
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-15 18:02:02 +01:00
Matti Vaittinen
95fb1e7b23 iio: light: bu27008: Fix intensity data type
The intensity data from bu27008 is unsigned. The type of the scan data
was incorrectly marked as signed resulting large intensity values to be
interpreted as negative ones.

Fix the scan data type.

Fixes: 41ff93d14f ("iio: light: ROHM BU27008 color sensor")
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/240a7ca5fc1b76da20d81f930d00f31a54b1fdf8.1686648422.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-15 18:02:02 +01:00
Matti Vaittinen
096649cd7c iio: light: bu27008: Fix scale format
The driver is expecting accuracy of NANOs for intensity scale in
raw_write. The IIO core is however defaulting to MICROs. This leads the
raw-write of smallest scales to never succeed as correct selector(s) are
not found.

Fix this by implementing the .write_raw_get_fmt callback to use NANO
accuracy for writes of IIO_CHAN_INFO_SCALE.

Fixes: 41ff93d14f ("iio: light: ROHM BU27008 color sensor")
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/e4778b74cde41431f77bc8dd88ec18605da0b400.1686648422.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-15 18:02:02 +01:00
Matti Vaittinen
d47b9b8429 iio: light: bu27034: Fix scale format
The driver is expecting accuracy of NANOs for intensity scale in
raw_write. The IIO core is however defaulting to MICROs. This leads the
raw-write of smallest scales to never succeed as correct selector(s) are
not found.

Fix this by implementing the .write_raw_get_fmt callback to use NANO
accuracy for writes of IIO_CHAN_INFO_SCALE.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Fixes: e52afbd610 ("iio: light: ROHM BU27034 Ambient Light Sensor")
Link: https://lore.kernel.org/r/5369117315cf05b88cf0ccb87373fd77190f6ca2.1686648422.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-15 18:02:02 +01:00
Alisa Roman
6bc471b6c3 iio: adc: ad7192: Fix ac excitation feature
AC excitation enable feature exposed to user on AD7192, allowing a bit
which should be 0 to be set. This feature is specific only to AD7195. AC
excitation attribute moved accordingly.

In the AD7195 documentation, the AC excitation enable bit is on position
22 in the Configuration register. ACX macro changed to match correct
register and bit.

Note that the fix tag is for the commit that moved the driver out of
staging.

Fixes: b581f748cc ("staging: iio: adc: ad7192: move out of staging")
Signed-off-by: Alisa Roman <alisa.roman@analog.com>
Cc: stable@vger.kernel.org
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230614155242.160296-1-alisa.roman@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-15 18:02:02 +01:00
Markus Burri
f41f444334 iio: adi: ad7192: Add error check and more debug log
Print read and expected device ID as debug warning.
Add error check for ad_sd_init() result.

Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Signed-off-by: Markus Burri <markus.burri@mt.com>
Link: https://lore.kernel.org/r/20230614073033.2497318-1-markus.burri@mt.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-15 17:53:38 +01:00
Christophe JAILLET
478baae99c iio: adc: ad7192: Simplify using devm_clk_get_optional_enabled()
If st->mclk is not NULL, then st->clock_sel is either AD7192_CLK_EXT_MCLK2
or AD7192_CLK_EXT_MCLK1_2.

So devm_clk_get_optional_enabled() can be used instead of hand writing it.
This saves some line of code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/7dbe973905f1fdae5d2f5ae5a3b01dd1d6a9925b.1686774340.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-07-15 17:53:38 +01:00
Herve Codina
7560418078
iio: inkern: Add a helper to query an available minimum raw value
A helper, iio_read_max_channel_raw() exists to read the available
maximum raw value of a channel but nothing similar exists to read the
available minimum raw value.

This new helper, iio_read_min_channel_raw(), fills the hole and can be
used for reading the available minimum raw value of a channel.
It is fully based on the existing iio_read_max_channel_raw().

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/20230623085830.749991-11-herve.codina@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-09 22:48:17 +01:00
Herve Codina
4dc6037358
iio: inkern: Replace a FIXME comment by a TODO one
This FIXME comment is more a TODO one.
It is a note when someone will need for this currently unsupported case.

Change from FIXME to TODO.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Suggested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/20230623085830.749991-10-herve.codina@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-09 22:48:16 +01:00
Herve Codina
97aee7157e
iio: inkern: Use max_array() to get the maximum value from an array
Use max_array() to get the maximum value from an array instead of a
custom local loop.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/20230623085830.749991-9-herve.codina@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-09 22:48:15 +01:00
Herve Codina
524cfdf6b8
iio: inkern: Fix headers inclusion order
Fix the mutex.h inclusion order as it seems to be the only one
misplaces.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/20230623085830.749991-7-herve.codina@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-09 22:48:13 +01:00
Herve Codina
ad4e8480a1
iio: inkern: Remove the 'unused' variable usage in iio_channel_read_max()
The code uses a local variable to initialize a null pointer in order to
avoid accessing this null pointer later on.

Simply removed the 'unused' variable and check for the null pointer just
before accessing it.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/20230623085830.749991-6-herve.codina@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-09 22:48:12 +01:00
Herve Codina
f75c544d74
iio: inkern: Check error explicitly in iio_channel_read_max()
The current implementation returns the error code as part of the
default switch case.
This can lead to returning an incorrect positive value in case of
iio_avail_type enum entries evolution.

In order to avoid this case, be more strict in error checking.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/20230623085830.749991-4-herve.codina@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-07-09 22:48:10 +01:00
Linus Torvalds
fc75f21645 driver core changes for 6.5-rc1
Here are a small set of changes for 6.5-rc1 for some driver core
 changes.  Included in here are:
   - device property cleanups to make it easier to write "agnostic"
     drivers when regards to the firmware layer underneath them (DT vs.
     ACPI)
   - debugfs documentation updates
   - devres additions
   - sysfs documentation and changes to handle empty directory creation
     logic better
   - tiny kernfs optimizations
   - other tiny changes
 
 All of these have been in linux-next for a while with no reported
 problems.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCZKKSEQ8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ymoowCfT+Joha+cz4edAFUvd55lKPPJJFsAoNiprHmX
 di37sirvn6vo54Hk0Nyq
 =qqTo
 -----END PGP SIGNATURE-----

Merge tag 'driver-core-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core updates from Greg KH:
 "Here are a small set of changes for 6.5-rc1 for some driver core
  changes. Included in here are:

   - device property cleanups to make it easier to write "agnostic"
     drivers when regards to the firmware layer underneath them (DT vs.
     ACPI)

   - debugfs documentation updates

   - devres additions

   - sysfs documentation and changes to handle empty directory creation
     logic better

   - tiny kernfs optimizations

   - other tiny changes

  All of these have been in linux-next for a while with no reported
  problems"

* tag 'driver-core-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
  sysfs: Skip empty folders creation
  sysfs: Improve readability by following the kernel coding style
  drivers: fwnode: fix fwnode_irq_get[_byname]()
  ata: ahci_platform: Make code agnostic to OF/ACPI
  device property: Implement device_is_compatible()
  ACPI: Move ACPI_DEVICE_CLASS() to mod_devicetable.h
  base/node: Use 'property' to identify an access parameter
  driver core: device.h: add some missing kerneldocs
  kernfs: fix missing kernfs_idr_lock to remove an ID from the IDR
  isa: Remove unnecessary checks
  MAINTAINERS: add entry for auxiliary bus
  debugfs: Correct the 'debugfs_create_str' docs
  serial: qcom_geni: Comment use of devm_krealloc rather than devm_krealloc_array
  iio: adc: Use devm_krealloc_array
  hwmon: pmbus: Use devm_krealloc_array
2023-07-03 12:56:23 -07:00
Linus Torvalds
44aeec836d Char/Misc and other driver subsystem updates for 6.5-rc1
Here is the big set of char/misc and other driver subsystem updates for
 6.5-rc1.
 
 Lots of different, tiny, stuff in here, from a range of smaller driver
 subsystems, including pulls from some substems directly:
   - IIO driver updates and additions
   - W1 driver updates and fixes (and a new maintainer!)
   - FPGA driver updates and fixes
   - Counter driver updates
   - Extcon driver updates
   - Interconnect driver updates
   - Coresight driver updates
   - mfd tree tag merge needed for other updates
 on top of that, lots of small driver updates as patches, including:
   - static const updates for class structures
   - nvmem driver updates
   - pcmcia driver fix
   - lots of other small driver updates and fixes
 
 All of these have been in linux-next for a while with no reported
 problems.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCZKKNMw8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ylhlQCfZrtz8RIbau8zbzh/CKpKBOmvHp4An3V64hbz
 recBPLH0ZACKl0wPl4iZ
 =A83A
 -----END PGP SIGNATURE-----

Merge tag 'char-misc-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull Char/Misc updates from Greg KH:
 "Here is the big set of char/misc and other driver subsystem updates
  for 6.5-rc1.

  Lots of different, tiny, stuff in here, from a range of smaller driver
  subsystems, including pulls from some substems directly:

   - IIO driver updates and additions

   - W1 driver updates and fixes (and a new maintainer!)

   - FPGA driver updates and fixes

   - Counter driver updates

   - Extcon driver updates

   - Interconnect driver updates

   - Coresight driver updates

   - mfd tree tag merge needed for other updates on top of that, lots of
     small driver updates as patches, including:

   - static const updates for class structures

   - nvmem driver updates

   - pcmcia driver fix

   - lots of other small driver updates and fixes

  All of these have been in linux-next for a while with no reported
  problems"

* tag 'char-misc-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (243 commits)
  bsr: fix build problem with bsr_class static cleanup
  comedi: make all 'class' structures const
  char: xillybus: make xillybus_class a static const structure
  xilinx_hwicap: make icap_class a static const structure
  virtio_console: make port class a static const structure
  ppdev: make ppdev_class a static const structure
  char: misc: make misc_class a static const structure
  /dev/mem: make mem_class a static const structure
  char: lp: make lp_class a static const structure
  dsp56k: make dsp56k_class a static const structure
  bsr: make bsr_class a static const structure
  oradax: make 'cl' a static const structure
  hwtracing: hisi_ptt: Fix potential sleep in atomic context
  hwtracing: hisi_ptt: Advertise PERF_PMU_CAP_NO_EXCLUDE for PTT PMU
  hwtracing: hisi_ptt: Export available filters through sysfs
  hwtracing: hisi_ptt: Add support for dynamically updating the filter list
  hwtracing: hisi_ptt: Factor out filter allocation and release operation
  samples: pfsm: add CC_CAN_LINK dependency
  misc: fastrpc: check return value of devm_kasprintf()
  coresight: dummy: Update type of mode parameter in dummy_{sink,source}_enable()
  ...
2023-07-03 12:46:47 -07:00
Linus Torvalds
b8ec70ab66 - New Drivers
- Add support for TI TPS6594/TPS6593/LP8764 PMICs
    - Add support for Samsung RT5033 Battery Charger
    - Add support for Analog Devices MAX77540 and MAX77541 PMICs
 
  - New Device Support
    - Add support for SPI to Rockchip RK808 (and friends)
    - Add support for AXP192 PMIC to X-Powers AXP20X
    - Add support for AXP313a PMIC to X-Powers AXP20X
    - Add support for RK806 to Rockchip RK8XX
 
  - Removed Device Support
    - Removed MFD support for Richtek RT5033 Battery
 
  - Fix-ups
    - Remove superfluous code
    - Switch I2C drivers from .probe_new() to .probe()
    - Convert over to managed resources (devm_*(), etc)
    - Use dev_err_probe() for returning errors from .probe()
    - Add lots of Device Tree bindings / support
    - Improve cache efficiency by switching to Maple
    - Use own exported namespaces (NS)
    - Include missing and remove superfluous headers
    - Start using / convert to the new shutdown sys-off API
    - Trivial: variable / define renaming
    - Make use of of_property_read_reg() when requesting DT 'reg's
 
  - Bug Fixes
    - Fix chip revision readout due to incorrect data masking
    - Amend incorrect register and mask values used for charger state
    - Hide unused functionality at compile time
    - Fix resource leaks following error handling routines
    - Return correct error values and fix error handling in general
    - Repair incorrect device names - used for device matching
    - Remedy broken module auto-loading
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAmSinHkACgkQUa+KL4f8
 d2Gj3A/9EimIwZKau8OeHCVue1mNrEVkVsCiWIZF1eHliufNbH0g3+9gzTB1yQfL
 PmE2tN+vxdHNPJKzPnrmEEdJpm+rV6RikUD3I1mVN0wPSXDmZPx9kYuJD8SmMtZo
 aDLQIMwqY0ZijGgAoVWmRtYo5praWSFvyutiD1yYEI4yAz/QcLoNvWjt3qb0H+fq
 Un1LYErrLxLar0GllzQa5lzoNEAoSBvO1TmS8z4Cm5uiU6Orahh2DlsE/Do40GSc
 5YYntAEsuJ1Bkg7JB+bxdU4BJnJskqzaasLIe3Fc4rXf6zdh/21EpmhpFGY+BS8s
 51f+NjViMwi+3uiBe5g8f/pIy6dIpkfvdukzbqDhDwqXnexftpy3+i99PJiWludR
 Xpr6s+g6zpxLAoKzHNA1jm5B3I0IPJEBoWe8jAalIcGIQBdjiF9UAkas3z9NTEoa
 8TrjW1Abxow1TB9ouT0kE7hvQk2UpYLEbNdDAByE4mM33d5AF7UpcEBrhmbFDA/E
 12q5EMoV9uXIzf+LS2TdYroo8SVYHufiIoiwU6QPJzWVVFJ3lrU3pA1Oe+aICMNu
 90EVDI1Ve37WTJfN9+FAlncaWF99AEqZwrES25QrKhMQO4w6LS35shlzTzpUcB4k
 q+upr81cWLz0t7fmjgn4yVa1CWzaQ19nylqXF/Nb4RP/6ZiP2Dw=
 =EmOj
 -----END PGP SIGNATURE-----

Merge tag 'mfd-next-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd

Pull MFD updates from Lee Jones:
 "New Drivers:
   - Add support for TI TPS6594/TPS6593/LP8764 PMICs
   - Add support for Samsung RT5033 Battery Charger
   - Add support for Analog Devices MAX77540 and MAX77541 PMICs

  New Device Support:
   - Add support for SPI to Rockchip RK808 (and friends)
   - Add support for AXP192 PMIC to X-Powers AXP20X
   - Add support for AXP313a PMIC to X-Powers AXP20X
   - Add support for RK806 to Rockchip RK8XX

  Removed Device Support:
   - Removed MFD support for Richtek RT5033 Battery

  Fix-ups:
   - Remove superfluous code
   - Switch I2C drivers from .probe_new() to .probe()
   - Convert over to managed resources (devm_*(), etc)
   - Use dev_err_probe() for returning errors from .probe()
   - Add lots of Device Tree bindings / support
   - Improve cache efficiency by switching to Maple
   - Use own exported namespaces (NS)
   - Include missing and remove superfluous headers
   - Start using / convert to the new shutdown sys-off API
   - Trivial: variable / define renaming
   - Make use of of_property_read_reg() when requesting DT 'reg's

  Bug Fixes:
   - Fix chip revision readout due to incorrect data masking
   - Amend incorrect register and mask values used for charger state
   - Hide unused functionality at compile time
   - Fix resource leaks following error handling routines
   - Return correct error values and fix error handling in general
   - Repair incorrect device names - used for device matching
   - Remedy broken module auto-loading"

* tag 'mfd-next-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (51 commits)
  dt-bindings: mfd: max77541: Add ADI MAX77541/MAX77540
  iio: adc: max77541: Add ADI MAX77541 ADC Support
  regulator: max77541: Add ADI MAX77541/MAX77540 Regulator Support
  dt-bindings: regulator: max77541: Add ADI MAX77541/MAX77540 Regulator
  mfd: Switch two more drivers back to use struct i2c_driver::probe
  dt-bindings: mfd: samsung,s5m8767: Simplify excluding properties
  mfd: stmpe: Only disable the regulators if they are enabled
  mfd: max77541: Add ADI MAX77541/MAX77540 PMIC Support
  dt-bindings: mfd: gateworks-gsc: Remove unnecessary fan-controller nodes
  mfd: core: Use of_property_read_reg() to parse "reg"
  mfd: stmfx: Nullify stmfx->vdd in case of error
  mfd: stmfx: Fix error path in stmfx_chip_init
  mfd: intel-lpss: Add missing check for platform_get_resource
  mfd: stpmic1: Add PMIC poweroff via sys-off handler
  mfd: stpmic1: Fixup main control register and bits naming
  dt-bindings: mfd: qcom,tcsr: Add the compatible for IPQ8074
  mfd: tps65219: Add support for soft shutdown via sys-off API
  mfd: pm8008: Drop bogus i2c module alias
  mfd: pm8008: Fix module autoloading
  mfd: tps65219: Add GPIO cell instance
  ...
2023-07-03 10:55:04 -07:00
Okan Sahin
04c9a8eb72 iio: adc: max77541: Add ADI MAX77541 ADC Support
The MAX77541 has an 8-bit Successive Approximation Register (SAR) ADC
with four multiplexers for supporting the telemetry feature.

Signed-off-by: Okan Sahin <okan.sahin@analog.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230412111256.40013-4-okan.sahin@analog.com
Signed-off-by: Lee Jones <lee@kernel.org>
2023-06-28 15:18:11 +01:00
Greg Kroah-Hartman
269b9d8faf 1st set of IIO new device support, features and cleanup for the 6.5 cycle.
New device support
 - honeywell,mprls0025pa
   * New driver and dt-bindings for this series of pressure sensors.
 - invensense,mpu6050
   * Add support for ICM 20600 IMU (ID, bindings and device data).
 - melexis,mlx90614
   * Add support for mlx90615 Infra Red Thermometer after driver cleanup
     and refactoring to support the differences in this device.
 - renesas,x9250
   * New driver and bindings for this quad potentiometer.
 - rockchip,saradc
   * Add support for RK3588. Also included is a bunch of refactoring and
     cleanup for that driver.
 - rohm,bu27008
   * New driver bindings etc for this 5 photodiode color sensor.
 - st,lsm9ds0/st,st-sensors
   * ID added for LSM303D accelerometer and magnetometer including ACPI binding.
 - ti,opt4001
   * New driver and bindings for this ambient light sensor.
 
 Features
 - core
   * Introduce iio_validate_own_trigger() for cases where a driver can only
     consumer a trigger it registered (detected via same parent device).
     Use it in the kionix,kx022a driver and new rohm,by27008 driver.
 - dynaimage,al3320a
   * ACPI binding CALS0001 seen on Lenovo Yoga Table 2 devices.
 - kionix,kx002a
   * Enable asynchronous probe.
 - rohm,bu27034
   * Enable asynchronous probe.
 - ti,tmp006
   * Explicit support for DT including binding documentation.
 
 Cleanups, minor fixes and misc improvements.
 - treewide
   * Switch I2C drivers from probe_new() back to probe() - part of the
     long process of getting rid of a parameter from probe()
   * Various whitespace and typo fixes not otherwise called out.
 - core
   * industrialio-buffer,Style cleanup.
   * Add documentation to extend_name field of struct iio_chan_spec to
     direct people using it towards the label infrastructure instead.
     extend_name was a design mistake a long time back so directly people
     away from it may be useful.
 - adi,ad7606
   * Add HAS_IOPORT dependency to prepare for some Kconfig changes.
 - bosch,bma400
   * Drop pointless print of ret in a dev_err_probe() message.
 - invensense,icm42600
   * Rework timestamp handling to reduce jitter.
 - mediatek,mt7986-auxdac
   * Add DT binding for this part.
 - qcom,spmi-vadc
   * Allow for 1/16th prescaling used on a few devices.
   * Various changes to channel labeling and naming, including dropping
     use of fwnode_name which generates odd channel names. Small ABI
     change as a result, but not thought to be a problem for users of this
     platform.
 - st,lsm6dsx
   * dt-binding: Use common schema for mount-matrix via a reference.
 - st,stm32
   * Add a debug print for when legacy channel config is used.
 - ti,palmas-adc
   * Drop unused i2c.h include.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmSF83ARHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Foi+NRAAi8E2NRkzxteTuiFRsAokm/8HbAc/9rDq
 2Xyj8zT5B6jmqpbNKPtIbxxAxLV/JY+3HBIorvDNcOVfmOfshMpT31eaKpehxPJ3
 A00WaJ6bi7CTp0h/7QOZnZ27yr3tuJ2jpCiGKWERmTZ60kn3S/5JRrXWbfKVccyU
 DR1SrsiVSbtDhD9w6kA7HBRsL0EmTQOP/ARlUcO4SB5BOC7rj9akaN6Q6LYSafOa
 BFfTd2suekRA94mB/ugm25xAWLsl4Rdr1iNkHyaGcXaMOJZ/zWXq14y1eLbqIJIc
 am8Wu2zvo+umNzuG5DMi3gxP2B57Zhcieh6sJ5egdbxB4kh5z3jrsAFiw/MLTEME
 4Tc7uHBPFuXDdb8saxtmV2FVbC43+31FgCLivD0BGHtv0DndP7i//KCdp2aztmHo
 juyxRCw40xiul5Ihzh3NjukM0pb1inuhgblcEZVKOyaCjhur8NXoTEEcSqXczDVU
 BLHBmhQY2cKwqKWt1hbLXDs9iGlJBg0+P+P0VBsvy7WWOlvc9Hw8SryYwyBRJMYH
 LW/Wh85eIcyKaaGGEd+HQAyXwGSlrhycUSJzwdcc1IrK8TrIxn5k4BpQpeToQPjJ
 wBRRDigeciIN0K7L09N4hg+qTxtpLwFY945meAS0N60o5hZM4P40hnzL8m/Co0pH
 gx8SugY1NGk=
 =0gJ9
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-6.5a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes:

1st set of IIO new device support, features and cleanup for the 6.5 cycle.

New device support
- honeywell,mprls0025pa
  * New driver and dt-bindings for this series of pressure sensors.
- invensense,mpu6050
  * Add support for ICM 20600 IMU (ID, bindings and device data).
- melexis,mlx90614
  * Add support for mlx90615 Infra Red Thermometer after driver cleanup
    and refactoring to support the differences in this device.
- renesas,x9250
  * New driver and bindings for this quad potentiometer.
- rockchip,saradc
  * Add support for RK3588. Also included is a bunch of refactoring and
    cleanup for that driver.
- rohm,bu27008
  * New driver bindings etc for this 5 photodiode color sensor.
- st,lsm9ds0/st,st-sensors
  * ID added for LSM303D accelerometer and magnetometer including ACPI binding.
- ti,opt4001
  * New driver and bindings for this ambient light sensor.

Features
- core
  * Introduce iio_validate_own_trigger() for cases where a driver can only
    consumer a trigger it registered (detected via same parent device).
    Use it in the kionix,kx022a driver and new rohm,by27008 driver.
- dynaimage,al3320a
  * ACPI binding CALS0001 seen on Lenovo Yoga Table 2 devices.
- kionix,kx002a
  * Enable asynchronous probe.
- rohm,bu27034
  * Enable asynchronous probe.
- ti,tmp006
  * Explicit support for DT including binding documentation.

Cleanups, minor fixes and misc improvements.
- treewide
  * Switch I2C drivers from probe_new() back to probe() - part of the
    long process of getting rid of a parameter from probe()
  * Various whitespace and typo fixes not otherwise called out.
- core
  * industrialio-buffer,Style cleanup.
  * Add documentation to extend_name field of struct iio_chan_spec to
    direct people using it towards the label infrastructure instead.
    extend_name was a design mistake a long time back so directly people
    away from it may be useful.
- adi,ad7606
  * Add HAS_IOPORT dependency to prepare for some Kconfig changes.
- bosch,bma400
  * Drop pointless print of ret in a dev_err_probe() message.
- invensense,icm42600
  * Rework timestamp handling to reduce jitter.
- mediatek,mt7986-auxdac
  * Add DT binding for this part.
- qcom,spmi-vadc
  * Allow for 1/16th prescaling used on a few devices.
  * Various changes to channel labeling and naming, including dropping
    use of fwnode_name which generates odd channel names. Small ABI
    change as a result, but not thought to be a problem for users of this
    platform.
- st,lsm6dsx
  * dt-binding: Use common schema for mount-matrix via a reference.
- st,stm32
  * Add a debug print for when legacy channel config is used.
- ti,palmas-adc
  * Drop unused i2c.h include.

* tag 'iio-for-6.5a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (59 commits)
  dt-bindings: iio: rockchip: Fix 'oneOf' condition failed warning
  dt-bindings: iio: afe: voltage-divider: Spelling s/curcuit/circuit/
  dt-bindings: iio: adc: Add rockchip,rk3588-saradc string
  iio: adc: rockchip_saradc: Use dev_err_probe
  iio: adc: rockchip_saradc: Match alignment with open parenthesis
  iio: adc: rockchip_saradc: Use of_device_get_match_data
  iio: adc: rockchip_saradc: Make use of devm_clk_get_enabled
  iio: adc: rockchip_saradc: Add support for RK3588
  iio: adc: rockchip_saradc: Add callback functions
  iio: temperature: tmp006: Add OF device matching support
  dt-bindings: iio: temperature: Add support for tmp006
  staging: iio: Switch i2c drivers back to use .probe()
  iio: amplifiers: ad8366 Fix whitespace issue
  iio: imu: inv_icm42600: avoid frequent timestamp jitter
  MAINTAINERS: Add ROHM BU27008
  iio: light: ROHM BU27008 color sensor
  iio: kx022a: Use new iio_validate_own_trigger()
  iio: trigger: Add simple trigger_validation helper
  dt-bindings: iio: light: ROHM BU27008
  iio: mlx90614: Add MLX90615 support
  ...
2023-06-15 13:01:55 +02:00
George Stark
c57fa00370 meson saradc: fix clock divider mask length
According to the datasheets of supported meson SoCs length of ADC_CLK_DIV
field is 6-bit. Although all supported SoCs have the register
with that field documented later SoCs use external clock rather than
ADC internal clock so this patch affects only meson8 family (S8* SoCs).

Fixes: 3adbf34273 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs")
Signed-off-by: George Stark <GNStark@sberdevices.ru>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://lore.kernel.org/r/20230606165357.42417-1-gnstark@sberdevices.ru
Cc: <stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-06-10 18:57:51 +01:00
Sean Nyekjaer
b410a9307b iio: accel: fxls8962af: errata bug only applicable for FXLS8962AF
Remove special errata handling if FXLS8964AF is used.

Fixes: af959b7b96 ("iio: accel: fxls8962af: fix errata bug E3 - I2C burst reads")
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20230605103223.1400980-2-sean@geanix.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-06-05 20:05:48 +01:00
Sean Nyekjaer
d1cfbd52ed iio: accel: fxls8962af: fixup buffer scan element type
Scan elements for x,y,z channels is little endian and requires no bit shifts.
LE vs. BE is controlled in register SENS_CONFIG2 and bit LE_BE, default
value is LE.

Fixes: a3e0b51884 ("iio: accel: add support for FXLS8962AF/FXLS8964AF accelerometers")
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20230605103223.1400980-1-sean@geanix.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-06-05 20:05:41 +01:00
Greg Kroah-Hartman
16b58423b4 Merge 6.4-rc5 into driver-core-next
We need the driver core fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-06-05 07:37:37 +02:00
Fabrizio Lamarque
f7d9e21dd2 iio: adc: ad7192: Fix internal/external clock selection
Fix wrong selection of internal clock when mclk is defined.

Resolve a logical inversion introduced in c9ec2cb328.

Fixes: c9ec2cb328 ("iio: adc: ad7192: use devm_clk_get_optional() for mclk")
Signed-off-by: Fabrizio Lamarque <fl.scratchpad@gmail.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20230530075311.400686-3-fl.scratchpad@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-06-04 12:33:20 +01:00
Fabrizio Lamarque
9e58e3a6f8 iio: adc: ad7192: Fix null ad7192_state pointer access
Pointer to indio_dev structure is obtained via spi_get_drvdata() at
the beginning of function ad7192_setup(), but the spi->dev->driver_data
member is not initialized, hence a NULL pointer is returned.

Fix by changing ad7192_setup() signature to take pointer to struct
iio_dev, and get ad7192_state pointer via st = iio_priv(indio_dev);

Fixes: bd5dcdeb3f ("iio: adc: ad7192: convert to device-managed functions")
Signed-off-by: Fabrizio Lamarque <fl.scratchpad@gmail.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20230530075311.400686-2-fl.scratchpad@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-06-04 12:31:59 +01:00
Rasmus Villemoes
a4cba07e64 iio: addac: ad74413: don't set DIN_SINK for functions other than digital input
Apparently, despite the name Digital Input Configuration Register, the
settings in the DIN_CONFIGx registers also affect other channel
functions. In particular, setting a non-zero value in the DIN_SINK
field breaks the resistance measurement function.

Now, one can of course argue that specifying a drive-strength-microamp
property along with a adi,ch-func which is not one of the digital
input functions is a bug in the device tree. However, we have a rather
complicated setup with instances of ad74412r on external hardware
modules, and have set a default drive-strength-microamp in our DT
fragments describing those, merely modifying the adi,ch-func settings
to reflect however the modules have been wired up. And restricting
this setting to just being done for digital input doesn't make the
driver any more complex.

Fixes: 504eb48558 (iio: ad74413r: wire up support for drive-strength-microamp property)
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Link: https://lore.kernel.org/r/20230503105042.453755-1-linux@rasmusvillemoes.dk
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-06-04 12:25:01 +01:00
Shreeya Patel
5e63d7a260 iio: adc: rockchip_saradc: Use dev_err_probe
Use dev_err_probe instead of dev_err in probe function,
which simplifies code a little bit and prints the error
code.

Signed-off-by: Shreeya Patel <shreeya.patel@collabora.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20230603185340.13838-7-shreeya.patel@collabora.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-06-04 11:24:13 +01:00
Shreeya Patel
10bec68f51 iio: adc: rockchip_saradc: Match alignment with open parenthesis
Match alignment with open parenthesis for improving the code
readability.

Signed-off-by: Shreeya Patel <shreeya.patel@collabora.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20230603185340.13838-6-shreeya.patel@collabora.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-06-04 11:23:40 +01:00
Shreeya Patel
47902344c8 iio: adc: rockchip_saradc: Use of_device_get_match_data
Use of_device_get_match_data() to simplify the code.

Signed-off-by: Shreeya Patel <shreeya.patel@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20230603185340.13838-5-shreeya.patel@collabora.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-06-04 11:22:52 +01:00
Shreeya Patel
97ad10bb29 iio: adc: rockchip_saradc: Make use of devm_clk_get_enabled
Use devm_clk_get_enabled() to avoid manually disabling the
clock.

Signed-off-by: Shreeya Patel <shreeya.patel@collabora.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20230603185340.13838-4-shreeya.patel@collabora.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-06-04 11:22:10 +01:00
Simon Xue
757953f8ec iio: adc: rockchip_saradc: Add support for RK3588
Add new start and read functions to support rk3588 device.
Also, add a device compatible string for the same.

Signed-off-by: Simon Xue <xxm@rock-chips.com>
Signed-off-by: Shreeya Patel <shreeya.patel@collabora.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20230603185340.13838-3-shreeya.patel@collabora.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-06-04 11:20:48 +01:00
Simon Xue
fb1c13d595 iio: adc: rockchip_saradc: Add callback functions
Add start, read and power_down callback functions,
which will help in adding new rockchip device support
cleanly.

Signed-off-by: Simon Xue <xxm@rock-chips.com>
Signed-off-by: Shreeya Patel <shreeya.patel@collabora.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20230603185340.13838-2-shreeya.patel@collabora.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-06-04 11:19:39 +01:00
James Clark
7c054b2cba iio: adc: Use devm_krealloc_array
Now that it exists, use it instead of doing the multiplication and
checking for overflow manually.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: James Clark <james.clark@arm.com>
Link: https://lore.kernel.org/r/20230509094942.396150-4-james.clark@arm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-05-30 21:07:15 +01:00
Anup Sharma
12a875055c iio: temperature: tmp006: Add OF device matching support
Adds an of_device_id table entry to the driver, enabling
device matching through device tree. With this update, the driver
can now match devices using both the i2c_device_id entry and the
newly added of_device_id table.

Signed-off-by: Anup Sharma <anupnewsmail@gmail.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/72746bdfd8f74171943e41759b891c7af40627ec.1684579603.git.anupnewsmail@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-28 20:22:03 +01:00
Franziska Naepelt
8b5e7c33b3 iio: amplifiers: ad8366 Fix whitespace issue
This removes the following checkpatch issue:
- ERROR: space prohibited before that ',' (ctx:WxW)

Signed-off-by: Franziska Naepelt <franziska.naepelt@gmail.com>
Link: https://lore.kernel.org/r/20230528104802.22011-1-franziska.naepelt@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-28 16:01:55 +01:00
Jean-Baptiste Maneyrol
f3ae82534a iio: imu: inv_icm42600: avoid frequent timestamp jitter
We are currently synchronizing every time the data timestamp with
the IT timestamp, leading to system jitter jamming timestamps.
To fix that and keep it simple, let's just synchronize when the
delta is bigger than the acceptable jitter, and keep
synchronization at the jitter value.

The result is much stable timestamps reflecting better the real
physical value. Example @50Hz delta timestamp,
* before: 20.123ms, 19.721ms, 20.023ms, 20.353ms, 19.821ms, ...
* after: 20.173ms, 20.173ms, 20.173ms, 20.40ms, 20.173ms, ...

Refactorize code and delete the unnecessary handling of multiple
FIFO data.

Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Link: https://lore.kernel.org/r/20230522093210.817212-1-inv.git-commit@tdk.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-23 21:20:40 +01:00
Matti Vaittinen
41ff93d14f iio: light: ROHM BU27008 color sensor
The ROHM BU27008 is a sensor with 5 photodiodes (red, green, blue, clear
and IR) with four configurable channels. Red and green being always
available and two out of the rest three (blue, clear, IR) can be
selected to be simultaneously measured. Typical application is adjusting
LCD backlight of TVs, mobile phones and tablet PCs.

Add initial support for the ROHM BU27008 color sensor.
 - raw_read() of RGB and clear channels
 - triggered buffer w/ DRDY interrtupt

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/2594162f0e44148cffb1fb05f1d6edfde6bd11bc.1683541225.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-23 21:20:17 +01:00
Matti Vaittinen
2a4deb8488 iio: kx022a: Use new iio_validate_own_trigger()
The new generic iio_validate_own_trigger() can be used as
validate_trigger callback for verifying the used trigger belongs to same
device as the iio_dev.

Use the generic function instead of rolling own one.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/cbd585e4787f62dc1a343a51b629ce73dd7d5426.1683541225.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-23 21:20:17 +01:00
Matti Vaittinen
517985ebc5 iio: trigger: Add simple trigger_validation helper
Some triggers can only be attached to the IIO device that corresponds to
the same physical device. Implement generic helper which can be used as
a validate_trigger callback for such devices.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/51cd3e3e74a6addf8d333f4a109fb9c5a11086ee.1683541225.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-23 21:20:17 +01:00
Marek Vasut
7699e975e5 iio: mlx90614: Add MLX90615 support
Add support for MLX90615 Infra Red Thermometer, which seems to be
the predecesor of MLX90614 . There are significant differences in
the register layout compared to MLX90614, but the functionality
of the device is virtually identical.

The following differences have been identified:
- RAM/EEPROM/SLEEP access opcodes are different
- RAM/EEPROM registers are at different offsets
- EEPROM emissivity and configuration registers are at different offsets
- EEPROM configuration register bits are shuffled around
- EEPROM emissivity settings are 14 bit on MLX90615 , 16 bit on MLX90614
- MLX90615 can only ever support one sensor, MLX90614 could support two
- FIR filter is set to fixed settings on MLX90615
- IIR filter coefficients are different

This patch fills in the MLX90615 specific description and quirk handling.

The IIR filter coefficients were provided by Melexis as follows:
0b0000 - Forbidden value
0b0001 - 100% - settling time = refresh rate = 205ms (around 5Hz)
0b0010 - 50% - settling time = 2050ms (around 0.5Hz)
0b0011 - 33% - settling time = 36900ms (around 0.3Hz)
0b0100 - 25% - settling time = 5125ms (around 0.2Hz)
0b0101 - 20% - settling time = 6355ms (around 0.15Hz)
0b0110 - 17% - settling time = 7790ms (around 0.13Hz)
0b0111 - 14% - settling time = 9225ms (around 0.1Hz)

Signed-off-by: Marek Vasut <marex@denx.de>
Acked-by: Crt Mori <cmo@melexis.com>
Link: https://lore.kernel.org/r/20230510102251.10118-6-marex@denx.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-23 21:20:17 +01:00
Marek Vasut
3d5ead238b iio: mlx90614: Factor our register IO and constants into model specific descriptor
Factor out all the differences between MLX90614 and other similar chips
into a structure which describes the chip and allows abstracting out the
differences from the driver code. No functional change.

This patch moves all the RAM and EEPROM IO opcodes into the descriptor
structure and combines them, instead of combining the opcode and offset
in macros.

Acked-by: Crt Mori <cmo@melexis.com>
Tested-by: Crt Mori <cmo@melexis.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Link: https://lore.kernel.org/r/20230510102251.10118-5-marex@denx.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-23 21:20:17 +01:00
Marek Vasut
8a0377bf67 iio: mlx90614: Drop MLX90614_CONST_EMISSIVITY_RESOLUTION
The MLX90614_CONST_EMISSIVITY_RESOLUTION can be calculated from
MLX90614_CONST_RAW_EMISSIVITY_MAX, perform the calculation inline
and drio the MLX90614_CONST_EMISSIVITY_RESOLUTION.

Signed-off-by: Marek Vasut <marex@denx.de>
Acked-by: Crt Mori <cmo@melexis.com>
Link: https://lore.kernel.org/r/20230510102251.10118-4-marex@denx.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-23 21:20:16 +01:00
Marek Vasut
0221483728 iio: mlx90614: Drop unused register macros
To simplify addition of support for new parts, drop unused register macros.
No functional change.

Acked-by: Crt Mori <cmo@melexis.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Link: https://lore.kernel.org/r/20230510102251.10118-3-marex@denx.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-23 21:20:16 +01:00
Marek Vasut
4c077429b4 iio: mlx90614: Sort headers
Sort the headers alphabetically. No functional change.

Acked-by: Crt Mori <cmo@melexis.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Link: https://lore.kernel.org/r/20230510102251.10118-2-marex@denx.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-23 21:20:16 +01:00
Andreas Klinger
713337d914 iio: pressure: Honeywell mprls0025pa pressure sensor
Honeywell mprls0025pa is a series of pressure sensors.

Add initial I2C support.

Note:
- IIO buffered mode is supported
- SPI mode is not supported

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Link: https://lore.kernel.org/r/ZGNp3SqyOJeEcLsj@arbad
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-21 18:54:58 +01:00
Uwe Kleine-König
7cf15f4275 iio: Switch i2c drivers back to use .probe()
After commit b8a1a4cd5a ("i2c: Provide a temporary .probe_new()
call-back type"), all drivers being converted to .probe_new() and then
03c835f498 ("i2c: Switch .probe() to not take an id parameter") convert
back to (the new) .probe() to be able to eventually drop .probe_new() from
struct i2c_driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230515205048.19561-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-21 18:54:53 +01:00
Jean-Baptiste Maneyrol
bbaae0c79e iio: imu: inv_icm42600: fix timestamp reset
Timestamp reset is not done in the correct place. It must be done
before enabling buffer. The reason is that interrupt timestamping
is always happening when the chip is on, even if the
corresponding sensor is off. When the sensor restarts, timestamp
is wrong if you don't do a reset first.

Fixes: ec74ae9fd3 ("iio: imu: inv_icm42600: add accurate timestamping")
Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20230509152202.245444-1-inv.git-commit@tdk.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-20 17:33:14 +01:00
Niklas Schnelle
76aa53e20e iio: ad7606: Kconfig: add HAS_IOPORT dependencies
In a future patch HAS_IOPORT=n will result in inb()/outb() and friends
not being declared. We thus need to add HAS_IOPORT as dependency for
those drivers using them.

Co-developed-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Link: https://lore.kernel.org/r/20230516110038.2413224-13-schnelle@linux.ibm.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-20 17:30:45 +01:00
Herve Codina
66bfc528a6 iio: potentiometer: Add support for the Renesas X9250 potentiometers
The Renesas X9250 integrates four digitally controlled potentiometers.
On each potentiometer, the X9250T has a 100 kOhms total resistance and
the X9250U has a 50 kOhms total resistance.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Link: https://lore.kernel.org/r/20230509160852.158101-3-herve.codina@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-20 17:30:33 +01:00
Masahiro Honda
626d312028 iio: adc: ad_sigma_delta: Fix IRQ issue by setting IRQ_DISABLE_UNLAZY flag
The Sigma-Delta ADCs supported by this driver can use SDO as an interrupt
line to indicate the completion of a conversion. However, some devices
cannot properly detect the completion of a conversion by an interrupt.
This is for the reason mentioned in the following commit.

commit e9849777d0 ("genirq: Add flag to force mask in
                      disable_irq[_nosync]()")

A read operation is performed by an extra interrupt before the completion
of a conversion. At this time, the value read from the ADC data register
is the same as the previous conversion result. This patch fixes the issue
by setting IRQ_DISABLE_UNLAZY flag.

Fixes: 0c6ef985a1 ("iio: adc: ad7791: fix IRQ flags")
Fixes: 1a913270e5 ("iio: adc: ad7793: Fix IRQ flag")
Fixes: e081102f30 ("iio: adc: ad7780: Fix IRQ flag")
Fixes: 89a86da5cb ("iio: adc: ad7192: Add IRQ flag")
Fixes: 79ef91493f ("iio: adc: ad7124: Set IRQ type to falling")
Signed-off-by: Masahiro Honda <honda@mechatrax.com>
Link: https://lore.kernel.org/r/20230518110816.248-1-honda@mechatrax.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-20 16:34:52 +01:00
Marek Vasut
09d3bec700 iio: dac: mcp4725: Fix i2c_master_send() return value handling
The i2c_master_send() returns number of sent bytes on success,
or negative on error. The suspend/resume callbacks expect zero
on success and non-zero on error. Adapt the return value of the
i2c_master_send() to the expectation of the suspend and resume
callbacks, including proper validation of the return value.

Fixes: cf35ad61ac ("iio: add mcp4725 I2C DAC driver")
Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230511004330.206942-1-marex@denx.de
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 19:46:59 +01:00
Matti Vaittinen
56cd3d1c5c iio: accel: kx022a fix irq getting
The fwnode_irq_get_byname() was returning 0 at device-tree mapping
error. If this occurred, the KX022A driver did abort the probe but
errorneously directly returned the return value from
fwnode_irq_get_byname() from probe. In case of a device-tree mapping
error this indicated success.

The fwnode_irq_get_byname() has since been fixed to not return zero on
error so the check for fwnode_irq_get_byname() can be relaxed to only
treat negative values as errors. This will also do decent fix even when
backported to branches where fwnode_irq_get_byname() can still return
zero on error because KX022A probe should later fail at IRQ requesting
and a prober error handling should follow.

Relax the return value check for fwnode_irq_get_byname() to only treat
negative values as errors.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/r/202305110245.MFxC9bUj-lkp@intel.com/
Link: https://lore.kernel.org/r/202305110245.MFxC9bUj-lkp@intel.com/
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Fixes: 7c1d1677b3 ("iio: accel: Support Kionix/ROHM KX022A accelerometer")
Link: https://lore.kernel.org/r/b45b4b638db109c6078d243252df3a7b0485f7d5.1683875389.git.mazziesaccount@gmail.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 19:45:08 +01:00
Matti Vaittinen
d049151add iio: bu27034: Ensure reset is written
The reset bit must be always written to the hardware no matter what value
is in a cache or register. Ensure this by using regmap_write_bits()
instead of the regmap_update_bits(). Furthermore, the SWRESET bit may be
self-clearing, so mark the SYSTEM_CONTROL register volatile to guarantee
we do also read the right state - should we ever need to read it.

Finally, writing the SWRESET bit will restore the default register
values. This can cause register cache to be outdated if there are any
register values cached.

Rebuild register cache after SWRESET and use regmap_update_bits() when
performing the reset.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Fixes: e52afbd610 ("iio: light: ROHM BU27034 Ambient Light Sensor")
Link: https://lore.kernel.org/r/ZFjWhbfuN5XcKty+@fedora
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 19:22:01 +01:00
Lukas Bulwahn
a146eccb68 iio: dac: build ad5758 driver when AD5758 is selected
Commit 28d1a7ac2a ("iio: dac: Add AD5758 support") adds the config AD5758
and the corresponding driver ad5758.c. In the Makefile, the ad5758 driver
is however included when AD5755 is selected, not when AD5758 is selected.

Probably, this was simply a mistake that happened by copy-and-paste and
forgetting to adjust the actual line. Surprisingly, no one has ever noticed
that this driver is actually only included when AD5755 is selected and that
the config AD5758 has actually no effect on the build.

Fixes: 28d1a7ac2a ("iio: dac: Add AD5758 support")
Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Link: https://lore.kernel.org/r/20230508040208.12033-1-lukas.bulwahn@gmail.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 19:18:11 +01:00
Hermes Zhang
23cf1846f4 iio: imu: mpu6050: Add support for the ICM 20600 IMU
The Invensense ICM-20600 is a 6-axis MotionTracking device that combines a
3-axis gyroscope and an 3-axis accelerometer. It is very similar to the
ICM20602 imu which is already supported by the mpu6050 driver. The main
difference is that the ICM-20600 has a different WHOAMI value.

Signed-off-by: Hermes Zhang <chenhuiz@axis.com>
Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Link: https://lore.kernel.org/r/20230505054853.2155326-3-chenhuiz@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 18:57:36 +01:00
Marijn Suijten
3d0b126029 iio: adc: qcom-spmi-vadc: Propagate fw node label to userspace
Set the read_label() callback to return a friendly name provided in DT
(firmware), in order to make in_{therm,voltage}X_label attributes show
up in sysfs for userspace to consume a channel name.  This is
particularly useful for custom thermistors being attached to otherwise
generically named GPIOs, where the name is known by the board DT.

If the channel name isn't set in DT, use the datasheet_name hardcoded in
the driver instead.

Note that this doesn't fall back to fwnode_get_name() as that provides
suboptimally readable names, with an @xx address suffix from board DT.

Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230502-iio-adc-propagate-fw-node-label-v3-5-6be5db6e6b5a@somainline.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 18:28:10 +01:00
Marijn Suijten
ac0abf75e1 iio: adc: qcom-spmi-adc5: Remove unnecessary datasheet_name NULL check
datasheet_name is statically filled by a macro for every channel, and is
nor should ever be set to NULL.

Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230502-iio-adc-propagate-fw-node-label-v3-4-6be5db6e6b5a@somainline.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 18:28:10 +01:00
Marijn Suijten
0744ef3b2b iio: adc: qcom-spmi-adc5: Fall back to datasheet_name instead of fwnode name
Since the migration to fwnode_get_name in commit 4f47a236a2 ("iio:
adc: qcom-spmi-adc5: convert to device properties") the resulting
adc5_channel_prop::channel_name (renamed from datasheet_name in the
previous patch) - which is propagated into iio_chan_spec::extend_name -
was containing the DT node name including @xx suffix if a "label"
property is not present, while adc5_channels::datasheet_name was thus
far set by the macros but always remained unread.  Put it to use instead
of using a confusing name containing @xx in sysfs filenames (again, when
"label" is not set).

Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230502-iio-adc-propagate-fw-node-label-v3-3-6be5db6e6b5a@somainline.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 18:28:10 +01:00
Marijn Suijten
e93cde03ab iio: adc: qcom-spmi-adc5: Use driver datasheet_name instead of DT label
iio_chan_spec::datasheet_name expects a channel/pin name on the hardware
part, i.e. from its datasheet, instead of a friendly name from DT which
typically describes the use of said channel.  GPIO channels are commonly
specialized in QCOM board DTS based on what a - typically thermistor -
is connected to.

Also rename adc5_channel_prop::datasheet_name to channel_name to that
effect.

Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230502-iio-adc-propagate-fw-node-label-v3-2-6be5db6e6b5a@somainline.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 18:28:10 +01:00
Matti Vaittinen
a508fbfed3 iio: kx022a: Probe asynchronously
Devices which may take a while to initialize during probe and which have
no strong reason to probe synchronously can request asynchronous probing
as default probe strategy. This can speed-up start times on some
platforms.

The KX022A gets probe delayed for at least two reasons. It enables the
supply regulator, (which is likely to have ramp-up delay if it was
disabled) and additionally it delays while the sensor itself is
initializing.

Changing to asynchronous probing may cause problems. Some of which are
discussed in:
https://lore.kernel.org/all/06db017f-e985-4434-8d1d-02ca2100cca0@sirena.org.uk/

Enable asynchronous probing for KX022A.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/24cea76c282a28b7a4dba297ab627176f8097907.1683185765.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:56:06 +01:00
Matti Vaittinen
4cd56dbd76 iio: bu27034: Probe asynchronously
Devices which may take a while to initialize during probe and which have
no strong reason to probe synchronously can request asynchronous probing
as default probe strategy. This can speed-up start times on some
platforms.

The BU27034 gets probe delayed for at least two reasons. It enables the
supply regulator, (which is likely to have ramp-up delay if it was
disabled) and additionally it delays while the sensor itself is
initializing.

Changing to asynchronous probing may cause problems. Some of which are
discussed in:
https://lore.kernel.org/all/06db017f-e985-4434-8d1d-02ca2100cca0@sirena.org.uk/

Enabling async probing for the ROHM BU27034 should be fairly safe to try
though as there is no in-tree users for it yet. If the async probing
appears to be an issue we can switch easily back to synchronous (or
better yet, fix the actual problem).

Enable asynchronous probing for BU27034.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/e7088793e1868c77b1894b30cd026e8ed043ea7c.1683185765.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:56:06 +01:00
Nuno Sá
26e46ef775 iio: buffer: fix coding style warnings
Just cosmetics. No functional change intended...

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20230216101452.591805-4-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:56:06 +01:00
Stefan Windfeldt-Prytz
9a96084182 iio: light: Add support for TI OPT4001 light sensor
This driver uses the continuous mode of the chip and integration
time can be configured through sysfs.
The constants for calculating lux value differs between packaging
so it uses different compatible string for the two versions
"ti,opt4001-picostar" and "ti,opt4001-sot-5x3" since the device id
is the same.

Datasheet: https://www.ti.com/lit/gpn/opt4001
Signed-off-by: Stefan Windfeldt-Prytz <stefan.windfeldt-prytz@axis.com>
Link: https://lore.kernel.org/r/20230323-add-opt4001-driver-v3-2-62e121dab294@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:56:06 +01:00
Christophe JAILLET
b8ddd02281 iio: adc: palmas: Remove the unneeded include <linux/i2c.h>
This driver does not use i2c, so there is no point in including
<linux/i2c.h>

Remove it.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/9d23cd04d7f99dc8d813584aae5268b57f92fcd8.1682320298.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:56:05 +01:00
Sean Nyekjaer
7b0d54ae76 iio: adc: stm32-adc: add debug info if dt uses legacy channel config
Since nearly all stm32 dt's are using the legacy adc channel config,
we should warn users about using it.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Link: https://lore.kernel.org/r/20230421083858.2613289-1-sean@geanix.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:56:05 +01:00
Marius Hoch
5b24fdd991 iio: light: al3320a: Handle ACPI device CALS0001
This sensor can be found as CALS0001 on the Lenovo Yoga
Tablet 2 series.

Tested on a Lenovo Yoga Tablet 2 1051-F.

Signed-off-by: Marius Hoch <mail@mariushoch.de>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230420232631.68864-1-mail@mariushoch.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:56:05 +01:00
Christophe JAILLET
b4d32eb31f iio: accel: bma400: Simplify an error message
dev_err_probe() already display the error code. There is no need to
duplicate it explicitly in the error message.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/9373d41b0a1f3dc3fc0d31c1daaa19d9a7ec4dcd.1681575924.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:56:05 +01:00
Marius Hoch
598e971fab iio: st_sensors: Add ACPI support for lsm303d to the LSM9DS0 IMU driver
The lsm303d can be found as ACCL0001 on various Lenovo devices,
including the Lenovo Yoga Tablet 2 1051-F, where I tested this
patch.

Dropped SPI support as per discussion in thread linked below.

Signed-off-by: Marius Hoch <mail@mariushoch.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Hans de Goede <hansg@kernel.org>
Link: https://lore.kernel.org/r/20230415231130.115094-5-mail@mariushoch.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:56:04 +01:00
Marius Hoch
c0f68439ae iio: st_sensors: Add lsm303d support to the LSM9DS0 IMU driver
The lsm303d is basically the lsm9ds0 without the gyroscope
(which the LSM9DS0 IMU driver doesn't handle), as far as I
can tell.

Signed-off-by: Marius Hoch <mail@mariushoch.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Hans de Goede <hansg@kernel.org>
Link: https://lore.kernel.org/r/20230415231130.115094-4-mail@mariushoch.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:56:04 +01:00
Marius Hoch
a9e19f6360 iio: magnetometer: st_accel: Add LSM303D
The lsm303d has the same register mapping as the lsm9ds0,
thus we can just re-use that.

Tested on a Lenovo Yoga Tablet 2 1051-F.

Signed-off-by: Marius Hoch <mail@mariushoch.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Hans de Goede <hansg@kernel.org>
Link: https://lore.kernel.org/r/20230415231130.115094-3-mail@mariushoch.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:56:04 +01:00
Marius Hoch
9445368bca iio: accel: st_accel: Add LSM303D
The lsm303d has the same register mapping as the lsm9ds0,
thus we can just re-use that.

Tested on a Lenovo Yoga Tablet 2 1051-F.

Signed-off-by: Marius Hoch <mail@mariushoch.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Hans de Goede <hansg@kernel.org>
Link: https://lore.kernel.org/r/20230415231130.115094-2-mail@mariushoch.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:56:04 +01:00
Rasmus Villemoes
24febc99ca iio: addac: ad74413: fix resistance input processing
On success, ad74413r_get_single_adc_result() returns IIO_VAL_INT aka
1. So currently, the IIO_CHAN_INFO_PROCESSED case is effectively
equivalent to the IIO_CHAN_INFO_RAW case, and we never call
ad74413r_adc_to_resistance_result() to convert the adc measurement to
ohms.

Check ret for being negative rather than non-zero.

Fixes: fea251b6a5 (iio: addac: add AD74413R driver)
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230503095817.452551-1-linux@rasmusvillemoes.dk
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:54:58 +01:00
Frank Li
a551c26e8e iio: light: vcnl4035: fixed chip ID check
VCNL4035 register(0xE) ID_L and ID_M define as:

 ID_L: 0x80
 ID_H: 7:6 (0:0)
       5:4 (0:0) slave address = 0x60 (7-bit)
           (0:1) slave address = 0x51 (7-bit)
           (1:0) slave address = 0x40 (7-bit)
           (1:0) slave address = 0x41 (7-bit)
       3:0 Version code default	(0:0:0:0)

So just check ID_L.

Fixes: 55707294c4 ("iio: light: Add support for vishay vcnl4035")
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20230501143605.1615549-1-Frank.Li@nxp.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:54:58 +01:00
Sean Nyekjaer
3e27ef0ced iio: adc: stm32-adc: skip adc-channels setup if none is present
If only adc differential channels are defined driver will fail with
stm32-adc: probe of 48003000.adc:adc@0 failed with error -22

Fix this by skipping the initialization if no channels are defined.

This applies only to the legacy way of initializing adc channels.

Fixes: d7705f3544 ("iio: adc: stm32-adc: convert to device properties")
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Olivier Moysan <olivier.moysan@foss.st.com>
Link: https://lore.kernel.org/r/20230503162029.3654093-2-sean@geanix.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:54:57 +01:00
Sean Nyekjaer
9c0d6ccd7d iio: adc: stm32-adc: skip adc-diff-channels setup if none is present
If no adc differential channels are defined driver will fail with EINVAL:
stm32-adc: probe of 48003000.adc:adc@0 failed with error -22

Fix this by skipping the initialization if no channels are defined.

This applies only to the legacy way of initializing adc channels.

Fixes: d7705f3544 ("iio: adc: stm32-adc: convert to device properties")
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Link: https://lore.kernel.org/r/20230503162029.3654093-1-sean@geanix.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:54:57 +01:00
Paul Cercueil
e55245d115 iio: adc: ad7192: Change "shorted" channels to differential
The AD7192 provides a specific channel configuration where both negative
and positive inputs are connected to AIN2. This was represented in the
ad7192 driver as a IIO channel with .channel = 2 and .extended_name set
to "shorted".

The problem with this approach, is that the driver provided two IIO
channels with the identifier .channel = 2; one "shorted" and the other
not. This goes against the IIO ABI, as a channel identifier should be
unique.

Address this issue by changing "shorted" channels to being differential
instead, with channel 2 vs. itself, as we're actually measuring AIN2 vs.
itself.

Note that the fix tag is for the commit that moved the driver out of
staging. The bug existed before that, but backporting would become very
complex further down and unlikely to happen.

Fixes: b581f748cc ("staging: iio: adc: ad7192: move out of staging")
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Co-developed-by: Alisa Roman <alisa.roman@analog.com>
Signed-off-by: Alisa Roman <alisa.roman@analog.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230330102100.17590-1-paul@crapouillou.net
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:54:57 +01:00
Hans de Goede
79b8ded9d9 iio: accel: st_accel: Fix invalid mount_matrix on devices without ACPI _ONT method
When apply_acpi_orientation() fails, st_accel_common_probe() will fall back
to iio_read_mount_matrix(), which checks for a mount-matrix device property
and if that is not set falls back to the identity matrix.

But when a sensor has no ACPI companion fwnode, or when the ACPI fwnode
does not have a "_ONT" method apply_acpi_orientation() was returning 0,
causing iio_read_mount_matrix() to never get called resulting in an
invalid mount_matrix:

[root@fedora ~]# cat /sys/bus/iio/devices/iio\:device0/mount_matrix
(null), (null), (null); (null), (null), (null); (null), (null), (null)

Fix this by making apply_acpi_orientation() always return an error when
it did not set the mount_matrix.

Fixes: 3d8ad94bb1 ("iio: accel: st_sensors: Support generic mounting matrix")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Marius Hoch <mail@mariushoch.de>
Link: https://lore.kernel.org/r/20230416212409.310936-1-hdegoede@redhat.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:54:57 +01:00
Matti Vaittinen
e65065132f iio: gts-helpers: fix integration time units
The IIO ABI mandates expressing integration times in seconds. The GTS
helper errorneously uses micro seconds in integration_times_available.
Fix this by converting the lists to IIO_VAL_INT_PLUS_MICRO.

Fixes: 38416c28e1 ("iio: light: Add gain-time-scale helpers")
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/eeacd192c259e885850b5a2dd8b776bccfc44fa8.1681722914.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:54:57 +01:00
Matti Vaittinen
b7b04f393f iio: bu27034: Fix integration time
The bu27034 uses micro seconds for integration time configuration. This
is incorrect as the ABI mandates use of seconds.

Change BU27034 driver to use seconds for integration time.

Fixes: e52afbd610 ("iio: light: ROHM BU27034 Ambient Light Sensor")
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/a05647669af22ba919c7c87dccb43975e3235a87.1681722914.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:54:57 +01:00
Dan Carpenter
279c3a2a5e iio: adc: palmas: fix off by one bugs
Valid values for "adc_chan" are zero to (PALMAS_ADC_CH_MAX - 1).
Smatch detects some buffer overflows caused by this:
drivers/iio/adc/palmas_gpadc.c:721 palmas_gpadc_read_event_value() error: buffer overflow 'adc->thresholds' 16 <= 16
drivers/iio/adc/palmas_gpadc.c:758 palmas_gpadc_write_event_value() error: buffer overflow 'adc->thresholds' 16 <= 16

The effect of this bug in other functions is more complicated but
obviously we should fix all of them.

Fixes: a99544c6c8 ("iio: adc: palmas: add support for iio threshold events")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/14fee94a-7db7-4371-b7d6-e94d86b9561e@kili.mountain
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:54:57 +01:00
Jiakai Luo
27b2ed5b6d iio: adc: mxs-lradc: fix the order of two cleanup operations
Smatch reports:
drivers/iio/adc/mxs-lradc-adc.c:766 mxs_lradc_adc_probe() warn:
missing unwind goto?

the order of three init operation:
1.mxs_lradc_adc_trigger_init
2.iio_triggered_buffer_setup
3.mxs_lradc_adc_hw_init

thus, the order of three cleanup operation should be:
1.mxs_lradc_adc_hw_stop
2.iio_triggered_buffer_cleanup
3.mxs_lradc_adc_trigger_remove

we exchange the order of two cleanup operations,
introducing the following differences:
1.if mxs_lradc_adc_trigger_init fails, returns directly;
2.if trigger_init succeeds but iio_triggered_buffer_setup fails,
goto err_trig and remove the trigger.

In addition, we also reorder the unwind that goes on in the
remove() callback to match the new ordering.

Fixes: 6dd112b9f8 ("iio: adc: mxs-lradc: Add support for ADC driver")
Signed-off-by: Jiakai Luo <jkluo@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
Link: https://lore.kernel.org/r/20230422133407.72908-1-jkluo@hust.edu.cn
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:54:57 +01:00
Lars-Peter Clausen
28f73ded19 iio: ad4130: Make sure clock provider gets removed
The ad4130 driver registers a clock provider, but never removes it. This
leaves a stale clock provider behind that references freed clocks when the
device is unbound.

Register a managed action to remove the clock provider when the device is
removed.

Fixes: 62094060cf ("iio: adc: ad4130: add AD4130 driver")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20230414150702.518441-1-lars@metafoo.de
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:54:57 +01:00
Lars-Peter Clausen
265c82ea8b iio: tmag5273: Fix runtime PM leak on measurement error
The tmag5273 gets a runtime PM reference before reading a measurement and
releases it when done. But if the measurement fails the tmag5273_read_raw()
function exits before releasing the reference.

Make sure that this error path also releases the runtime PM reference.

Fixes: 866a138917 ("iio: magnetometer: add ti tmag5273 driver")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Gerald Loacker <gerald.loacker@wolfvision.net>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230414013752.498767-1-lars@metafoo.de
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:54:56 +01:00
ChiaEn Wu
00ffdd6fa9 iio: adc: mt6370: Fix ibus and ibat scaling value of some specific vendor ID chips
The scale value of ibus and ibat on the datasheet is incorrect due to the
customer report after the experimentation with some specific vendor ID
chips.

Fixes: c1404d1b65 ("iio: adc: mt6370: Add MediaTek MT6370 support")
Signed-off-by: ChiaEn Wu <chiaen_wu@richtek.com>
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Link: https://lore.kernel.org/r/1681122862-1994-1-git-send-email-chiaen_wu@richtek.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:54:56 +01:00
Dan Carpenter
20f291b88e iio: adc: imx93: fix a signedness bug in imx93_adc_read_raw()
The problem is these lines:

	ret = vref_uv = regulator_get_voltage(adc->vref);
	if (ret < 0)

The "ret" variable is type long and "vref_uv" is u32 so that means
the condition can never be true on a 64bit system.  A negative error
code from regulator_get_voltage() would be cast to a high positive
u32 value and then remain a high positive value when cast to a long.

The "ret" variable only ever stores ints so it should be declared as
an int.  We can delete the "vref_uv" variable and use "ret" directly.

Fixes: 7d02296ac8 ("iio: adc: add imx93 adc support")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
Link: https://lore.kernel.org/r/Y+utEvjfjQRQo2QB@kili
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-13 17:54:56 +01:00
Linus Torvalds
cec24b8b6b Char/Misc drivers for 6.4-rc1
Here is the "big" set of char/misc and other driver subsystems for
 6.4-rc1.
 
 It's pretty big, but due to the removal of pcmcia drivers, almost breaks
 even for number of lines added vs. removed, a nice change.
 
 Included in here are:
   - removal of unused PCMCIA drivers (finally!)
   - Interconnect driver updates and additions
   - Lots of IIO driver updates and additions
   - MHI driver updates
   - Coresight driver updates
   - NVMEM driver updates, which required some OF updates
   - W1 driver updates and a new maintainer to manage the subsystem
   - FPGA driver updates
   - New driver subsystem, CDX, for AMD systems
   - lots of other small driver updates and additions
 
 All of these have been in linux-next for a while with no reported
 issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCZEp5Eg8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ynSXgCg0kSw3vUYwpsnhAsQkoPw1QVA23sAn2edRCMa
 GEkPWjrROueCom7xbLMu
 =eR+P
 -----END PGP SIGNATURE-----

Merge tag 'char-misc-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char/misc drivers updates from Greg KH:
 "Here is the "big" set of char/misc and other driver subsystems for
  6.4-rc1.

  It's pretty big, but due to the removal of pcmcia drivers, almost
  breaks even for number of lines added vs. removed, a nice change.

  Included in here are:

   - removal of unused PCMCIA drivers (finally!)

   - Interconnect driver updates and additions

   - Lots of IIO driver updates and additions

   - MHI driver updates

   - Coresight driver updates

   - NVMEM driver updates, which required some OF updates

   - W1 driver updates and a new maintainer to manage the subsystem

   - FPGA driver updates

   - New driver subsystem, CDX, for AMD systems

   - lots of other small driver updates and additions

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'char-misc-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (196 commits)
  mcb-lpc: Reallocate memory region to avoid memory overlapping
  mcb-pci: Reallocate memory region to avoid memory overlapping
  mcb: Return actual parsed size when reading chameleon table
  kernel/configs: Drop Android config fragments
  virt: acrn: Replace obsolete memalign() with posix_memalign()
  spmi: Add a check for remove callback when removing a SPMI driver
  spmi: fix W=1 kernel-doc warnings
  spmi: mtk-pmif: Drop of_match_ptr for ID table
  spmi: pmic-arb: Convert to platform remove callback returning void
  spmi: mtk-pmif: Convert to platform remove callback returning void
  spmi: hisi-spmi-controller: Convert to platform remove callback returning void
  w1: gpio: remove unnecessary ENOMEM messages
  w1: omap-hdq: remove unnecessary ENOMEM messages
  w1: omap-hdq: add SPDX tag
  w1: omap-hdq: allow compile testing
  w1: matrox: remove unnecessary ENOMEM messages
  w1: matrox: use inline over __inline__
  w1: matrox: switch from asm to linux header
  w1: ds2482: do not use assignment in if condition
  w1: ds2482: drop unnecessary header
  ...
2023-04-27 12:07:50 -07:00
Linus Torvalds
fc2e58b8b7 spi: Updates for v6.4
A fairly standard release for SPI with the exception of a change to the
 API for specifying chip selects done in preparation for supporting
 devices with more than one chip select, this required some mechanical
 changes throughout the tree which have been cooking in -next happily for
 a while.  There's also a new API to allow us to TPM chips on half duplex
 controllers.
 
 There's three commits in here that were mangled by a bad interaction
 between the alsa-devel mailing list software and b4, I didn't notice
 until there were merges on top with it being SPI not ALSA.  It seemed
 clear enough to not be worth going back and fixing.
 
  - Refactoring in preparation for supporting multiple chip selects for a
    single device, needed by some flash devices, which required a change
    in the SPI device API visible throughout the tree.
  - Support for hardware assisted interaction with SPI TPMs on half
    duplex controllers, implemented on nVidia Tedra210 QuadSPI.
  - Optimisation for large transfers on fsl-cpm devices.
  - Cleanups around device property use which fix some sisues with
    fwnode.
  - Use of both void remove() and devm_platform_.*ioremap_resource().
  - Support for AMD Pensando Elba, Amlogic A1, Cadence device mode,
    Intel MetorLake-S and StarFive J7110 QuadSPI.
 
 The final commit converting to DEV_PM_OPS() was applied late to fix a
 warning that was introduced by some of the earlier work.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmRIFQgACgkQJNaLcl1U
 h9BJOwf+JF2RySdn5g1LsyTndPZhLfw4iJgTHaMlnv5tiPHvYVYMM/mNMbMr5Znh
 Y2T0OUkzuRfOK273C+hItC1bTYFTa2cEbDb5dpmKBOZdQ3hjGsZQBvuH2bScUQ+a
 H7UgD3FYOJST6k6rRgZQxVMPePFrXAOaO1gmFWTR3v1EcEr2JeQnjZsmymFXcTnc
 CtPg9N3RvhVnq5aXuxSgQeyyKIjo4LJh/eZ2mexPIu0DeUq3MftaWwSwCXFIoeNC
 DMLA4mZWTgf/yt6JUALwLr+bIiJjb4qGjp3xGZ2wmX7zn73f9QQvuunKb1V4zbNF
 EdXLo2VjA9cZjsihenBaKeHnkfgNfA==
 =IRqY
 -----END PGP SIGNATURE-----

Merge tag 'spi-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi updates from Mark Brown:
 "A fairly standard release for SPI with the exception of a change to
  the API for specifying chip selects done in preparation for supporting
  devices with more than one chip select, this required some mechanical
  changes throughout the tree which have been cooking in -next happily
  for a while.

  There's also a new API to allow us to support TPM chips on half duplex
  controllers.

  Summary:

   - Refactoring in preparation for supporting multiple chip selects for
     a single device, needed by some flash devices, which required a
     change in the SPI device API visible throughout the tree

   - Support for hardware assisted interaction with SPI TPMs on half
     duplex controllers, implemented on nVidia Tedra210 QuadSPI

   - Optimisation for large transfers on fsl-cpm devices

   - Cleanups around device property use which fix some sisues with
     fwnode

   - Use of both void remove() and devm_platform_.*ioremap_resource()

   - Support for AMD Pensando Elba, Amlogic A1, Cadence device mode,
     Intel MetorLake-S and StarFive J7110 QuadSPI"

* tag 'spi-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (185 commits)
  spi: bcm63xx: use macro DEFINE_SIMPLE_DEV_PM_OPS
  spi: tegra210-quad: Enable TPM wait polling
  spi: Add TPM HW flow flag
  spi: bcm63xx: remove PM_SLEEP based conditional compilation
  spi: cadence-quadspi: use macro DEFINE_SIMPLE_DEV_PM_OPS
  spi: spi-cadence: Add support for Slave mode
  spi: spi-cadence: Switch to spi_controller structure
  spi: cadence-quadspi: fix suspend-resume implementations
  spi: dw: Add support for AMD Pensando Elba SoC
  spi: dw: Add AMD Pensando Elba SoC SPI Controller
  spi: cadence-quadspi: Disable the SPI before reconfiguring
  spi: cadence-quadspi: Update the read timeout based on the length
  spi: spi-loopback-test: Add module param for iteration length
  spi: add support for Amlogic A1 SPI Flash Controller
  dt-bindings: spi: add Amlogic A1 SPI controller
  spi: fsl-spi: No need to check transfer length versus word size
  spi: fsl-spi: Change mspi_apply_cpu_mode_quirks() to void
  spi: fsl-cpm: Use 16 bit mode for large transfers with even size
  spi: fsl-spi: Re-organise transfer bits_per_word adaptation
  spi: fsl-spi: Fix CPM/QE mode Litte Endian
  ...
2023-04-27 11:02:26 -07:00
Linus Torvalds
793582ff47 ACPI updates for 6.4-rc1
- Update the ACPICA code in the kernel to upstream revision 20230331
    including the following changes:
    * Delete bogus node_array array of pointers from AEST table (Jessica
      Clarke).
    * Add support for trace buffer extension in GICC to the ACPI MADT
      parser (Xiongfeng Wang).
    * Add missing macro ACPI_FUNCTION_TRACE() for acpi_ns_repair_HID()
      (Xiongfeng Wang).
    * Add missing tables to astable (Pedro Falcato).
    * Add support for 64 bit loong_arch compilation to ACPICA (Huacai
      Chen).
    * Add support for ASPT table in disassembler to ACPICA (Jeremi
      Piotrowski).
    * Add support for Arm's MPAM ACPI table version 2 (Hesham Almatary).
    * Update all copyrights/signons in ACPICA to 2023 (Bob Moore).
    * Add support for ClockInput resource (v6.5) (Niyas Sait).
    * Add RISC-V INTC interrupt controller definition to the list of
      supported interrupt controllers for MADT (Sunil V L).
    * Add structure definitions for the RISC-V RHCT ACPI table (Sunil V L).
    * Address several cases in which the ACPICA code might lead to
      undefined behavior (Tamir Duberstein).
    * Make ACPICA code support flexible arrays properly (Kees Cook).
    * Check null return of ACPI_ALLOCATE_ZEROED in
      acpi_db_display_objects() (void0red).
    * Add os specific support for Zephyr RTOS to ACPICA (Najumon).
    * Update version to 20230331 (Bob Moore).
 
  - Fix evaluating the _PDC ACPI control method when running as Xen
    dom0 (Roger Pau Monne).
 
  - Use platform devices to load ACPI PPC and PCC drivers (Petr Pavlu).
 
  - Check for null return of devm_kzalloc() in fch_misc_setup() (Kang
    Chen).
 
  - Log a message if enable_irq_wake() fails for the ACPI SCI (Simon
    Gaiser).
 
  - Initialize the correct IOMMU fwspec while parsing ACPI VIOT
    (Jean-Philippe Brucker).
 
  - Amend indentation and prefix error messages with FW_BUG in the ACPI
    SPCR parsing code (Andy Shevchenko).
 
  - Enable ACPI sysfs support for CCEL records (Kuppuswamy
    Sathyanarayanan).
 
  - Make the APEI error injection code warn on invalid arguments when
    explicitly indicated by platform (Shuai Xue).
 
  - Add CXL error types to the error injection code in APEI (Tony Luck).
 
  - Refactor acpi_data_prop_read_single() (Andy Shevchenko).
 
  - Fix two issues in the ACPI SBS driver (Armin Wolf).
 
  - Replace ternary operator with min_t() in the generic ACPI thermal
    zone driver (Jiangshan Yi).
 
  - Ensure that ACPI notify handlers are not running after removal and
    clean up code in acpi_sb_notify() (Rafael Wysocki).
 
  - Remove register_backlight_delay module option and code and remove
    quirks for false-positive backlight control support advertised on
    desktop boards (Hans de Goede).
 
  - Replace irqdomain.h include with struct declarations in ACPI headers
    and update several pieces of code previously including of.h
    implicitly through those headers (Rob Herring).
 
  - Fix acpi_evaluate_dsm_typed() redefinition error (Kiran K).
 
  - Update the pm_profile sysfs attribute documentation (Rafael Wysocki).
 
  - Add 80862289 ACPI _HID for second PWM controller on Cherry Trail to
    the ACPI driver for Intel SoCs (Hans de Goede).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmRGvLQSHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxoV4P/jxWGAdldtgXORR58lKGbSs6lx/0Y+SF
 iI7qK88NcbcbWS+a3PqRrisNkjN17rjzajfp28Ue2CXFxzwTViyw6KYELbPJ6N/h
 /3prem++jKgf7qiueDJG/AyO8N2+Z+yciubhxdMiK1+c1dZM2ycwSyBzJgYocpXn
 fH+YFPhxE7c8Z8doBrTOZjRuU4SIEKCmxo3c5BbCuyVZkbqCRdQMIDCiBJgLTmbo
 z4pu9OFhAamB8Cth2QFfRbZWqmuY71Gt54+c4ITPPV2ALlLUYODyHZoSISBJULp3
 k0lU/hMCD+i1WRwv+Bb6of7pJPM4Lqp+wOirAtiiibjE9LRxVTNyOUAHLXbx+t2V
 PN8JKVJVCLaZO6TRELgFIL4nh4aBdOtr4BuaLnClZho9bG68jEkc8grnOZYhFYtM
 66BuJBW30rwwGY4N5VSZGzFFR7l2qaHIOSHdq681bxQ3e6erFEeIc5jQVEOKgCqd
 XWdELVkqf3CnCX0lgonj+AgoeCqOpYdrNcWqMsJ+6OyQRoFhLFltDSPeJm9gHGO7
 X+qCQru4ZgEDKexWKpGgH9x8AllDKbh/ApyyumXgsQOsRocVdoNaf+yCBlaaDyqu
 UYif6hgFYnIxF2Fg1r/POgHDXFobE4iUTHcUU1V2QhuByc4PkN9ljKsHeC2FgVUz
 JityWRiMABNv
 =O61K
 -----END PGP SIGNATURE-----

Merge tag 'acpi-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI updates from Rafael Wysocki:
 "These update the ACPICA code in the kernel to upstream revision
  20230331, fix the ACPI SBS driver and the evaluation of the _PDC
  method on Xen dom0 in the ACPI processor driver, update the ACPI
  driver for Intel SoCs and clean up code in multiple places.

  Specifics:

   - Update the ACPICA code in the kernel to upstream revision 20230331
     including the following changes:
       * Delete bogus node_array array of pointers from AEST table
         (Jessica Clarke)
       * Add support for trace buffer extension in GICC to the ACPI MADT
         parser (Xiongfeng Wang)
       * Add missing macro ACPI_FUNCTION_TRACE() for
         acpi_ns_repair_HID() (Xiongfeng Wang)
       * Add missing tables to astable (Pedro Falcato)
       * Add support for 64 bit loong_arch compilation to ACPICA (Huacai
         Chen)
       * Add support for ASPT table in disassembler to ACPICA (Jeremi
         Piotrowski)
       * Add support for Arm's MPAM ACPI table version 2 (Hesham
         Almatary)
       * Update all copyrights/signons in ACPICA to 2023 (Bob Moore)
       * Add support for ClockInput resource (v6.5) (Niyas Sait)
       * Add RISC-V INTC interrupt controller definition to the list of
         supported interrupt controllers for MADT (Sunil V L)
       * Add structure definitions for the RISC-V RHCT ACPI table (Sunil
         V L)
       * Address several cases in which the ACPICA code might lead to
         undefined behavior (Tamir Duberstein)
       * Make ACPICA code support flexible arrays properly (Kees Cook)
       * Check null return of ACPI_ALLOCATE_ZEROED in
         acpi_db_display_objects() (void0red)
       * Add os specific support for Zephyr RTOS to ACPICA (Najumon)
       * Update version to 20230331 (Bob Moore)

   - Fix evaluating the _PDC ACPI control method when running as Xen
     dom0 (Roger Pau Monne)

   - Use platform devices to load ACPI PPC and PCC drivers (Petr Pavlu)

   - Check for null return of devm_kzalloc() in fch_misc_setup() (Kang
     Chen)

   - Log a message if enable_irq_wake() fails for the ACPI SCI (Simon
     Gaiser)

   - Initialize the correct IOMMU fwspec while parsing ACPI VIOT
     (Jean-Philippe Brucker)

   - Amend indentation and prefix error messages with FW_BUG in the ACPI
     SPCR parsing code (Andy Shevchenko)

   - Enable ACPI sysfs support for CCEL records (Kuppuswamy
     Sathyanarayanan)

   - Make the APEI error injection code warn on invalid arguments when
     explicitly indicated by platform (Shuai Xue)

   - Add CXL error types to the error injection code in APEI (Tony Luck)

   - Refactor acpi_data_prop_read_single() (Andy Shevchenko)

   - Fix two issues in the ACPI SBS driver (Armin Wolf)

   - Replace ternary operator with min_t() in the generic ACPI thermal
     zone driver (Jiangshan Yi)

   - Ensure that ACPI notify handlers are not running after removal and
     clean up code in acpi_sb_notify() (Rafael Wysocki)

   - Remove register_backlight_delay module option and code and remove
     quirks for false-positive backlight control support advertised on
     desktop boards (Hans de Goede)

   - Replace irqdomain.h include with struct declarations in ACPI
     headers and update several pieces of code previously including of.h
     implicitly through those headers (Rob Herring)

   - Fix acpi_evaluate_dsm_typed() redefinition error (Kiran K)

   - Update the pm_profile sysfs attribute documentation (Rafael
     Wysocki)

   - Add 80862289 ACPI _HID for second PWM controller on Cherry Trail to
     the ACPI driver for Intel SoCs (Hans de Goede)"

* tag 'acpi-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (64 commits)
  ACPI: LPSS: Add 80862289 ACPI _HID for second PWM controller on Cherry Trail
  ACPI: bus: Ensure that notify handlers are not running after removal
  ACPI: bus: Add missing braces to acpi_sb_notify()
  ACPI: video: Remove desktops without backlight DMI quirks
  ACPI: video: Remove register_backlight_delay module option and code
  ACPI: Replace irqdomain.h include with struct declarations
  fpga: lattice-sysconfig-spi: Add explicit include for of.h
  tpm: atmel: Add explicit include for of.h
  virtio-mmio: Add explicit include for of.h
  pata: ixp4xx: Add explicit include for of.h
  ata: pata_macio: Add explicit include of irqdomain.h
  serial: 8250_tegra: Add explicit include for of.h
  net: rfkill-gpio: Add explicit include for of.h
  staging: iio: resolver: ad2s1210: Add explicit include for of.h
  iio: adc: ad7292: Add explicit include for of.h
  ACPICA: Update version to 20230331
  ACPICA: add os specific support for Zephyr RTOS
  ACPICA: ACPICA: check null return of ACPI_ALLOCATE_ZEROED in acpi_db_display_objects
  ACPICA: acpi_resource_irq: Replace 1-element arrays with flexible array
  ACPICA: acpi_madt_oem_data: Fix flexible array member definition
  ...
2023-04-25 18:37:41 -07:00
Linus Torvalds
5e0ca0bfc3 Thermal control updates for 6.4-rc1
- Add a thermal zone 'devdata' accessor and modify several drivers to
    use it (Daniel Lezcano).
 
  - Prevent drivers from using the 'device' internal thermal zone
    structure field directly (Daniel Lezcano).
 
  - Clean up the hwmon thermal driver (Daniel Lezcano).
 
  - Add thermal zone id accessor and thermal zone type accessor
    and prevent drivers from using thermal zone fields directly (Daniel
    Lezcano).
 
  - Clean up the acerhdf and tegra thermal drivers (Daniel Lezcano).
 
  - Add lower bound check for sysfs input to the x86_pkg_temp_thermal
    Intel thermal driver (Zhang Rui).
 
  - Add more thermal zone device encapsulation: prevent setting structure
    field directly, access the sensor device instead the thermal zone's
    device for trace, relocate the traces in drivers/thermal (Daniel
    Lezcano).
 
  - Use the generic trip point for the i.MX and remove the get_trip_temp
    ops (Daniel Lezcano).
 
  - Use the devm_platform_ioremap_resource() in the Hisilicon driver
    (Yang Li).
 
  - Remove R-Car H3 ES1.* handling as public has only access to the ES2
    version and the upstream support for the ES1 has been shutdown (Wolfram
    Sang).
 
  - Add a delay after initializing the bank in order to let the time to
    the hardware to initialze itself before reading the temperature
    (Amjad Ouled-Ameur).
 
  - Add MT8365 support (Amjad Ouled-Ameur).
 
  - Preparational cleanup and DT bindings for RK3588 support (Sebastian
    Reichel).
 
  - Add driver support for RK3588 (Finley Xiao).
 
  - Use devm_reset_control_array_get_exclusive() for the Rockchip driver
    (Ye Xingchen).
 
  - Detect power gated thermal zones and return -EAGAIN when reading the
    temperature (Mikko Perttunen).
 
  - Remove thermal_bind_params structure as it is unused (Zhang Rui)
 
  - Drop unneeded quotes in DT bindings allowing to run yamllint (Rob
    Herring).
 
  - Update the power allocator documentation according to the thermal
    trace relocation (Lukas Bulwahn).
 
  - Fix sensor 1 interrupt status bitmask for the Mediatek LVTS sensor
    (Chen-Yu Tsai).
 
  - Use the dev_err_probe() helper in the Amlogic driver (Ye Xingchen).
 
  - Add AP domain support to LVTS thermal controllers for mt8195
    (Balsam CHIHI).
 
  - Remove buggy call to thermal_of_zone_unregister() (Daniel Lezcano).
 
  - Make thermal_of_zone_[un]register() private to the thermal OF code
    (Daniel Lezcano).
 
  - Create a private copy of the thermal zone device parameters
    structure when registering a thermal zone (Daniel Lezcano).
 
  - Fix a kernel NULL pointer dereference in thermal_hwmon (Zhang Rui).
 
  - Revert recent message adjustment in thermal_hwmon (Rafael Wysocki).
 
  - Use of_property_present() for testing DT property presence in
    thermal control code (Rob Herring).
 
  - Clean up thermal_list_lock locking in the thermal core (Rafael
    Wysocki).
 
  - Add DLVR support for RFIM control in the int340x Intel thermal
    driver (Srinivas Pandruvada).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmRGvsYSHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxekAQAJ/hhUZyY2hcFveNfrutkO8OGY+/rtz8
 ozMxyfwAdHoD6/zg9zZQTHSQy3W9rx2FC3tYtwHlJopDYFQuNPsfrhYE97EfO9uT
 Baou3OhoXV+ZJ0EZqIuTNuLaDPD/Hg8KSNmZvb6p/30bLR3Y/gKZutX9+S0x8qpG
 y7JcA8qPDYTvNfxkDjYv3M7HlfpwIwpi/xPFuw9nI2Fdw0SYRWpHAQlNj6oaF0xT
 EaNIg5zh4rR81T34/DpaOm1mfrg3Lg9xOJMU0laS5sKkn5Ea8s0E5s3vb5Quup61
 eXL3DhxmsIv51+1URZMZIQo2FmogvLmgnIPQyaeSvtlic0t39YS70tL2i8JY6kfL
 Tkhm8bS8jKQ6Y8GUvUbE/qadWFgkV4/lFTREVkKuq0XUU/YEpl5iQJAc0iEa0soy
 SISucs/ugoFjqdlN1pNDv7mLIzqyYIF6tZekLZTVa1U++MHKRakY9folD3brc6xO
 ewp1yO6e/fYZJx0K8LNlBRzXqNuV1Tl+kBDvUNHDNAEN8jONiZ2v+pDQ+VqYYxIc
 1A2KVw0l3m0MQ97w3E8LqYJTH6f8bxSLxjXnHLSN0eAXJkn10olfz/RYNsqi+dUb
 YBnFU8t3plGMVGrDcoDtO6hkujUw3oF7pibWeXXFEvIyRUcOA2e94kd57i9a1zLS
 5yyH9UchFcQq
 =XNJE
 -----END PGP SIGNATURE-----

Merge tag 'thermal-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull thermal control updates from Rafael Wysocki:
 "These mostly continue to prepare the thermal control subsystem for
  using unified representation of trip points, which includes cleanups,
  code refactoring and similar and update several drivers (for other
  reasons), which includes new hardware support.

  Specifics:

   - Add a thermal zone 'devdata' accessor and modify several drivers to
     use it (Daniel Lezcano)

   - Prevent drivers from using the 'device' internal thermal zone
     structure field directly (Daniel Lezcano)

   - Clean up the hwmon thermal driver (Daniel Lezcano)

   - Add thermal zone id accessor and thermal zone type accessor and
     prevent drivers from using thermal zone fields directly (Daniel
     Lezcano)

   - Clean up the acerhdf and tegra thermal drivers (Daniel Lezcano)

   - Add lower bound check for sysfs input to the x86_pkg_temp_thermal
     Intel thermal driver (Zhang Rui)

   - Add more thermal zone device encapsulation: prevent setting
     structure field directly, access the sensor device instead the
     thermal zone's device for trace, relocate the traces in
     drivers/thermal (Daniel Lezcano)

   - Use the generic trip point for the i.MX and remove the
     get_trip_temp ops (Daniel Lezcano)

   - Use the devm_platform_ioremap_resource() in the Hisilicon driver
     (Yang Li)

   - Remove R-Car H3 ES1.* handling as public has only access to the ES2
     version and the upstream support for the ES1 has been shutdown
     (Wolfram Sang)

   - Add a delay after initializing the bank in order to let the time to
     the hardware to initialze itself before reading the temperature
     (Amjad Ouled-Ameur)

   - Add MT8365 support (Amjad Ouled-Ameur)

   - Preparational cleanup and DT bindings for RK3588 support (Sebastian
     Reichel)

   - Add driver support for RK3588 (Finley Xiao)

   - Use devm_reset_control_array_get_exclusive() for the Rockchip
     driver (Ye Xingchen)

   - Detect power gated thermal zones and return -EAGAIN when reading
     the temperature (Mikko Perttunen)

   - Remove thermal_bind_params structure as it is unused (Zhang Rui)

   - Drop unneeded quotes in DT bindings allowing to run yamllint (Rob
     Herring)

   - Update the power allocator documentation according to the thermal
     trace relocation (Lukas Bulwahn)

   - Fix sensor 1 interrupt status bitmask for the Mediatek LVTS sensor
     (Chen-Yu Tsai)

   - Use the dev_err_probe() helper in the Amlogic driver (Ye Xingchen)

   - Add AP domain support to LVTS thermal controllers for mt8195
     (Balsam CHIHI)

   - Remove buggy call to thermal_of_zone_unregister() (Daniel Lezcano)

   - Make thermal_of_zone_[un]register() private to the thermal OF code
     (Daniel Lezcano)

   - Create a private copy of the thermal zone device parameters
     structure when registering a thermal zone (Daniel Lezcano)

   - Fix a kernel NULL pointer dereference in thermal_hwmon (Zhang Rui)

   - Revert recent message adjustment in thermal_hwmon (Rafael Wysocki)

   - Use of_property_present() for testing DT property presence in
     thermal control code (Rob Herring)

   - Clean up thermal_list_lock locking in the thermal core (Rafael
     Wysocki)

   - Add DLVR support for RFIM control in the int340x Intel thermal
     driver (Srinivas Pandruvada)"

* tag 'thermal-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (55 commits)
  thermal: intel: int340x: Add DLVR support for RFIM control
  thermal/core: Alloc-copy-free the thermal zone parameters structure
  thermal/of: Unexport unused OF functions
  thermal/drivers/bcm2835: Remove buggy call to thermal_of_zone_unregister
  thermal/drivers/mediatek/lvts_thermal: Add AP domain for mt8195
  dt-bindings: thermal: mediatek: Add AP domain to LVTS thermal controllers for mt8195
  thermal: amlogic: Use dev_err_probe()
  thermal/drivers/mediatek/lvts_thermal: Fix sensor 1 interrupt status bitmask
  MAINTAINERS: adjust entry in THERMAL/POWER_ALLOCATOR after header movement
  dt-bindings: thermal: Drop unneeded quotes
  thermal/core: Remove thermal_bind_params structure
  thermal/drivers/tegra-bpmp: Handle offline zones
  thermal/drivers/rockchip: use devm_reset_control_array_get_exclusive()
  dt-bindings: rockchip-thermal: Support the RK3588 SoC compatible
  thermal/drivers/rockchip: Support RK3588 SoC in the thermal driver
  thermal/drivers/rockchip: Support dynamic sized sensor array
  thermal/drivers/rockchip: Simplify channel id logic
  thermal/drivers/rockchip: Use dev_err_probe
  thermal/drivers/rockchip: Simplify clock logic
  thermal/drivers/rockchip: Simplify getting match data
  ...
2023-04-25 18:32:43 -07:00
Rafael J. Wysocki
21fc506cf5 Merge branches 'acpi-bus', 'acpi-video' and 'acpi-misc'
Merge ACPI bus type driver changes, ACPI backlight driver updates and a
series of cleanups related to of.h for 6.4-rc1:

 - Ensure that ACPI notify handlers are not running after removal and
   clean up code in acpi_sb_notify() (Rafael Wysocki).

 - Remove register_backlight_delay module option and code and remove
   quirks for false-positive backlight control support advertised on
   desktop boards (Hans de Goede).

 - Replace irqdomain.h include with struct declarations in ACPI headers
   and update several pieces of code previously including of.h
   implicitly through those headers (Rob Herring).

* acpi-bus:
  ACPI: bus: Ensure that notify handlers are not running after removal
  ACPI: bus: Add missing braces to acpi_sb_notify()

* acpi-video:
  ACPI: video: Remove desktops without backlight DMI quirks
  ACPI: video: Remove register_backlight_delay module option and code

* acpi-misc:
  ACPI: Replace irqdomain.h include with struct declarations
  fpga: lattice-sysconfig-spi: Add explicit include for of.h
  tpm: atmel: Add explicit include for of.h
  virtio-mmio: Add explicit include for of.h
  pata: ixp4xx: Add explicit include for of.h
  ata: pata_macio: Add explicit include of irqdomain.h
  serial: 8250_tegra: Add explicit include for of.h
  net: rfkill-gpio: Add explicit include for of.h
  staging: iio: resolver: ad2s1210: Add explicit include for of.h
  iio: adc: ad7292: Add explicit include for of.h
2023-04-24 18:01:57 +02:00
Rafael J. Wysocki
065ca2a8c6 Merge back Intel thermal control material for 6.4-rc1. 2023-04-14 17:14:02 +02:00
Patrik Dahlström
52cc189b4f iio: adc: palmas: don't alter event config on suspend/resume
The event config is controlled through the IIO events subsystem and
device wakeup is controlled by /sys/devices/.../power/wakeup. Let's keep
those two knobs independent.

Signed-off-by: Patrik Dahlström <risca@dalakolonin.se>
Link: https://lore.kernel.org/r/20230408114825.824505-10-risca@dalakolonin.se
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-13 12:10:11 +01:00
Patrik Dahlström
a99544c6c8 iio: adc: palmas: add support for iio threshold events
The palmas gpadc block has support for monitoring up to 2 ADC channels
and issue an interrupt if they reach past a set threshold. This change
hooks into the IIO events system and exposes to userspace the ability to
configure these threshold values for each channel, but only allow up to
2 such thresholds to be enabled at any given time. Trying to enable a
third channel will result in an error.

Userspace is expected to input calibrated, as opposed to raw, values as
threshold. However, it is not enough to do the opposite of what is done
when converting the other way around. To account for tolerances in the
ADC, the calculated raw threshold should be adjusted based on the ADC
specifications for the device. These specifications include the integral
nonlinearity (INL), offset, and gain error. To adjust the high
threshold, use the following equation:

  (calibrated value + INL) * Gain error + offset = maximum value  [1]

Likewise, use the following equation for the low threshold:

  (calibrated value - INL) * Gain error - offset = minimum value

The gain error is a combination of gain error, as listed in the
datasheet, and gain error drift due to temperature and supply. The exact
values for these specifications vary between palmas devices. This patch
sets the values found in TWL6035, TWL6037 datasheet.

[1] TI Application Report, SLIA087A, Guide to Using the GPADC in
    TPS65903x, TPS65917-Q1, TPS65919-Q1, and TPS65916 Devices.

Signed-off-by: Patrik Dahlström <risca@dalakolonin.se>
Link: https://lore.kernel.org/r/20230408114825.824505-9-risca@dalakolonin.se
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-13 12:09:31 +01:00
Patrik Dahlström
773597aeee iio: adc: palmas: always reset events on unload
This prevents leaving the adc in freerunning mode when removing the
driver.

Signed-off-by: Patrik Dahlström <risca@dalakolonin.se>
Link: https://lore.kernel.org/r/20230408114825.824505-8-risca@dalakolonin.se
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-13 11:37:21 +01:00
Patrik Dahlström
2d48dbdfc7 iio: adc: palmas: move eventX_enable into palmas_adc_event
It just makes more sense to have all information regarding adc events in
one place.

Signed-off-by: Patrik Dahlström <risca@dalakolonin.se>
Link: https://lore.kernel.org/r/20230408114825.824505-7-risca@dalakolonin.se
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-13 11:37:21 +01:00
Patrik Dahlström
7501a3a97e iio: adc: palmas: use iio_event_direction for threshold polarity
Instead of having high_threshold > 0 as an indicator for upper threshold
event and lower threshold event otherwise, use enum iio_event_direction
instead. This is hopefully less ambiguous.

Signed-off-by: Patrik Dahlström <risca@dalakolonin.se>
Link: https://lore.kernel.org/r/20230408114825.824505-6-risca@dalakolonin.se
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-13 11:37:21 +01:00
Patrik Dahlström
d2ab4eea73 iio: adc: palmas: replace "wakeup" with "event"
The palmas gpadc block has support for monitoring up to 2 ADC channels
and issue an interrupt if they reach past a set threshold. This is
currently used to wake up the system from sleep, but the functionality
is more generic than that. As such, change the naming of functions and
variables to refer to it as events instead, except during suspend and
resume where wakeup still make sense.

Signed-off-by: Patrik Dahlström <risca@dalakolonin.se>
Link: https://lore.kernel.org/r/20230408114825.824505-5-risca@dalakolonin.se
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-13 11:37:21 +01:00
Patrik Dahlström
79d9622d62 iio: adc: palmas: remove adc_wakeupX_data
It does not seem to be used by anyone and later patches in this series
are made simpler by first removing this. There is now a lot of dead code
that cannot be reached, until later patches revive it. Arguably, this is
preferred over removing the code only to add it again.

Signed-off-by: Patrik Dahlström <risca@dalakolonin.se>
Link: https://lore.kernel.org/r/20230408114825.824505-4-risca@dalakolonin.se
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-13 11:37:21 +01:00
Jonathan Cameron
6d52b0e706 iio: adc: palmas: Take probe fully device managed.
Review of a recent fix highlighted that this driver could be trivially
converted to be entirely devm managed.

That fix should be applied to resolve the fix in a fashion easy to back port
even though this change removes the relevant code.

[1] https://patchwork.kernel.org/project/linux-iio/patch/20230313205029.1881745-1-risca@dalakolonin.se/

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Tested-by: Patrik Dahlström <risca@dalakolonin.se>
Reviewed-by: Patrik Dahlström <risca@dalakolonin.se>
Link: https://lore.kernel.org/r/20230318163039.56115-1-jic23@kernel.org
2023-04-13 11:37:21 +01:00
Jonathan Cameron
dc3d25f22b iio: imu: lsm6dsx: Add ACPI mount matrix retrieval
DSDT ROTM method seen in the wild with SMO8B30 _HID.
Making assumption it is similar to that used for bmc150 plus
information from Darrell that the rotation is out by 90 degrees at boot.

Method (ROTM, 0, NotSerialized)
{
    Name (RBUF, Package (0x03)
    {
        "0 -1 0",
        "1 0 0",
        "0 0 1"
    })
    Return (RBUF) /* \_SB_.PCI0.I2C5.DEV_.ROTM.RBUF */
}

Reported-by: Darrell Kavanagh <darrell.kavanagh@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Tested-by: Darrell Kavanagh <darrell.kavanagh@gmail.org>
Link: https://lore.kernel.org/r/20230130201018.981024-3-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-13 11:37:20 +01:00
Jonathan Cameron
bd66b6acd2 iio: imu: lsm6dsx: Support SMO8B30 ACPI ID for LSM6DS3TR-C
ID seen in the wild and it is a valid ST micro ID.
An offset of 1 for the device ID enum is needed when adding support for
retrieving the ID from device_get_match_data() to allow detection of
NULL pointer and fallback to i2c_device_id table.

DSDT chunk cropped for relevant parts.

   Scope (_SB.PCI0.I2C5)
    {
        Device (DEV)
        {
            Name (_HID, EisaId ("SMO8B30"))  // _HID: Hardware ID
            Name (_CID, EisaId ("SMO8B30"))  // _CID: Compatible ID
            Name (_UID, Zero)  // _UID: Unique ID
            Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
            {
                Name (RBUF, ResourceTemplate ()
                {
                    I2cSerialBusV2 (0x006A, ControllerInitiated, 0x00061A80,
                        AddressingMode7Bit, "\\_SB.PCI0.I2C5",
                        0x00, ResourceConsumer, , Exclusive,
                        )
                })
                Return (RBUF) /* \_SB_.PCI0.I2C5.DEV_._CRS.RBUF */
            }

            Method (ROTM, 0, NotSerialized)
            {
                Name (RBUF, Package (0x03)
                {
                    "0 -1 0",
                    "1 0 0",
                    "0 0 1"
                })
                Return (RBUF) /* \_SB_.PCI0.I2C5.DEV_.ROTM.RBUF */
            }
...

Link: https://lore.kernel.org/all/20230129182441.082f29d0@jic23-huawei/
Reported-by: Darrell Kavanagh <darrell.kavanagh@gmail.com>
Tested-by: Darrell Kavanagh <darrell.kavanagh@gmail.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20230130201018.981024-2-jic23@kernel.org
2023-04-12 21:02:55 +01:00
Greg Kroah-Hartman
fba51482b6 1st set of IIO new device support, features and cleanups for the 6.4 cycle.
New device support
 * bosch,bmp280
   - Add support for BMP580 - includes significant refactoring and general
     driver cleanup + support for non-volatile memory for trimming and config
     parameters.
 * rohm BU27034
   - New driver for this 3 channel ambient light sensor.
   - New support library for devices where both integration time and
     amplifier gain are configurable.  In these cases a scale change
     may require changing bother underlying values. This library module
     provides code to help with this.
 * st,accel
   - Add support for IIS328DQ (ID only as compatible wtih LIS331DL)
 * st,lsm6dsx
   - Add support for ASM330LHB automotive MEMS sensor.
 * ti,ads1100, ads1000
   - New driver for these 16 bit ADCs.
 * ti,tmp117
   - Add support for older tmp116 device. Includes some general driver cleanup.
 
 Staging driver drops
 * adi,ade7854
   - Driver was a very long way from compliant with IIO infrastructure and ABI.
     If anyone wants a non staging version of this driver they are better off
     starting from scratch. Hence drop it and the associated meter.h header.
 
 Features
 * adi,ad7441r
   - Add DT binding to set sink current for digital input.
 * semtech,sx9324,9360
   - Support older register mapping from firmware designed for windows.
 
 Core improvements.
 * Move iio_trigger_poll() docs to next to the implementation and add a note
   on expected caller context.
 * Rename iio_trigger_poll_chained() to iio_trigger_poll_nested() so
   as to use more standard / common terminology.
 * Improve main ABI docs references to offset and scale for raw values by
   making them consistent and clear.
 
 Cleanups and minor fixes:
 * adi,ad5592r
   - Add GPIO names - useful for debug.
 * adi,ad7441r
   - Fix current input, loop powered mode configuration setup.
 * adi,adis16475
   - Fix wrong commented value for minimum advised lower rate.
 * adi,admv1013
   - Use devm_clk_get_enabled() to reduce boilerplate.
 * adi,ads1210
   - Fix wrong bits for writing config register (late fix and has
     been broken a long time so not rushed upstream)
 * amlogic,meson-saradc
   - Improve cleanup in error handling if BL30 handshake fails.
 * apex-embedded,stx104
   - Migrate to regmap and use regmap_read_poll_timeout() to neatly handle
     retries.
   - Add local mutex to close various races.
   - Use define U16_MAX rather than value for limit.
   - Improve code readability with minor reorganization.
 * atmel,ad91-sama5d2
   - Drop trivial dead code.
 * kionix,kx022a
   - Drop unused structure element.
 * linear,ltc2983
   - Reorganize bindings doc to enable unevaluatedProperties to be set
     in one place for all child nodes.
   - Make binding for adi,custom-thermocouple accept signed values.
 * maxim,max44000
   - Add OF Device matching (of_match_table was not correctly set).
 * maxim,max5522
   - Missing static
 * measurement-computing,cio-dac
   - Fix wrong part name in comments.
   - Migrate to regmap.
   - Improve includes by replacing bitops.h with more direct bits.h
 * qcom,pm8xxx-xoadc
   - Remove a check that can never fail.
 * renesas,rcar-gyroadc
   - DT binding documentation improvements.
   - Tidy up an unused warning with __maybe_unused.
 * semtech,sx_common
   - Drop docs for a structure element that doesn't exist.
 * semtech,sx9500
   - Drop ACPI_PTR() and of_match_ptr() protections that just complicate
     the code / block some firmware registration types that would otherwise
     work.
 * sensiron,sps30
   - Comment formatting tidy up.
 * st,sensors
   - Drop duplicate text in DT binding.
 * st,stm32-adc
   - Add some missing static markings.
 * ti,ads1100
   - Use correct return code in dev_err_probe() call.
 * x-powers,axp20x_adc - precursor series to simplify addition of AXP192.
   - General code cleanup / minor refactoring for better readabilty of code.
   - Switch from boolean value to mask for adc_en2 field to avoid hard coding
     a mask that will be different in AXP192
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmQ0QiIRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Foh8dhAAlUDsEWKoYc2DMXs//UVh5ortcD/tVMDj
 +Oe6c92vTvZaritF9JN5fS5oO48d2Qx7VC8mIZvsCgLdloYtM8qns8KwPU8W589j
 Mdaq2e/p+CCVLxn+RttiINk7C/okXmc6nh21TABYgaHbi1Yzu0LooTobrdd5GHZX
 l+5n8diTgebkKWLKHtR/Wo0hZVdFtrxOb+bP6Lu+yjwUhlvmnuC18OPthDHBwss1
 3nWL5sAR8DWKTKPwmWl1pnn5fuZXxAnxYhsgzMiC/dNrv4GfjV76xFvwdFG97Qc4
 Qifo/t6AM6g7HplfRjtdGXGnew8RBj9jzw3W8NUzb/7UF0ywF+6KHBrgWVKLumsW
 uGsLGQsOoCVmycnppUZSZV0eI5qT+WS6GT0XucB3wlUriS56YgpMU/RVo9iE8yUd
 VqjacBJrh1SUIPQKXAGb1dlrfgxGRUFcDxea/XuqzXZIn4U3JM1wb0awIlfcrTNm
 4EdVH9r6lwU/7KcrVC10iZz5ZMFy15wNmCl4+Sn56QNIekXYMXFCHsoZs64UMuhU
 leczQdEp/wEG1p0mWdrpC4aEsMfK27RSbTh8AS3LiPHqI9FD+Jg+wULF6wpMIHvY
 rm4kxlznTdKsYOiHsOkYXCi06kS5k2SqQHtbKS3jiSsCw30eX6xzVjG8szivFIS5
 KEKqxRs1BxM=
 =xxs6
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-6.4a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes:

1st set of IIO new device support, features and cleanups for the 6.4 cycle.

New device support
* bosch,bmp280
  - Add support for BMP580 - includes significant refactoring and general
    driver cleanup + support for non-volatile memory for trimming and config
    parameters.
* rohm BU27034
  - New driver for this 3 channel ambient light sensor.
  - New support library for devices where both integration time and
    amplifier gain are configurable.  In these cases a scale change
    may require changing bother underlying values. This library module
    provides code to help with this.
* st,accel
  - Add support for IIS328DQ (ID only as compatible wtih LIS331DL)
* st,lsm6dsx
  - Add support for ASM330LHB automotive MEMS sensor.
* ti,ads1100, ads1000
  - New driver for these 16 bit ADCs.
* ti,tmp117
  - Add support for older tmp116 device. Includes some general driver cleanup.

Staging driver drops
* adi,ade7854
  - Driver was a very long way from compliant with IIO infrastructure and ABI.
    If anyone wants a non staging version of this driver they are better off
    starting from scratch. Hence drop it and the associated meter.h header.

Features
* adi,ad7441r
  - Add DT binding to set sink current for digital input.
* semtech,sx9324,9360
  - Support older register mapping from firmware designed for windows.

Core improvements.
* Move iio_trigger_poll() docs to next to the implementation and add a note
  on expected caller context.
* Rename iio_trigger_poll_chained() to iio_trigger_poll_nested() so
  as to use more standard / common terminology.
* Improve main ABI docs references to offset and scale for raw values by
  making them consistent and clear.

Cleanups and minor fixes:
* adi,ad5592r
  - Add GPIO names - useful for debug.
* adi,ad7441r
  - Fix current input, loop powered mode configuration setup.
* adi,adis16475
  - Fix wrong commented value for minimum advised lower rate.
* adi,admv1013
  - Use devm_clk_get_enabled() to reduce boilerplate.
* adi,ads1210
  - Fix wrong bits for writing config register (late fix and has
    been broken a long time so not rushed upstream)
* amlogic,meson-saradc
  - Improve cleanup in error handling if BL30 handshake fails.
* apex-embedded,stx104
  - Migrate to regmap and use regmap_read_poll_timeout() to neatly handle
    retries.
  - Add local mutex to close various races.
  - Use define U16_MAX rather than value for limit.
  - Improve code readability with minor reorganization.
* atmel,ad91-sama5d2
  - Drop trivial dead code.
* kionix,kx022a
  - Drop unused structure element.
* linear,ltc2983
  - Reorganize bindings doc to enable unevaluatedProperties to be set
    in one place for all child nodes.
  - Make binding for adi,custom-thermocouple accept signed values.
* maxim,max44000
  - Add OF Device matching (of_match_table was not correctly set).
* maxim,max5522
  - Missing static
* measurement-computing,cio-dac
  - Fix wrong part name in comments.
  - Migrate to regmap.
  - Improve includes by replacing bitops.h with more direct bits.h
* qcom,pm8xxx-xoadc
  - Remove a check that can never fail.
* renesas,rcar-gyroadc
  - DT binding documentation improvements.
  - Tidy up an unused warning with __maybe_unused.
* semtech,sx_common
  - Drop docs for a structure element that doesn't exist.
* semtech,sx9500
  - Drop ACPI_PTR() and of_match_ptr() protections that just complicate
    the code / block some firmware registration types that would otherwise
    work.
* sensiron,sps30
  - Comment formatting tidy up.
* st,sensors
  - Drop duplicate text in DT binding.
* st,stm32-adc
  - Add some missing static markings.
* ti,ads1100
  - Use correct return code in dev_err_probe() call.
* x-powers,axp20x_adc - precursor series to simplify addition of AXP192.
  - General code cleanup / minor refactoring for better readabilty of code.
  - Switch from boolean value to mask for adc_en2 field to avoid hard coding
    a mask that will be different in AXP192

* tag 'iio-for-6.4a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (63 commits)
  MAINTAINERS: Add ROHM BU27034
  iio: light: ROHM BU27034 Ambient Light Sensor
  dt-bindings: iio: light: Support ROHM BU27034
  MAINTAINERS: Add IIO gain-time-scale helpers
  iio: light: Add gain-time-scale helpers
  doc: Make sysfs-bus-iio doc more exact
  iio: dac: set variable max5522_channels storage-class-specifier to static
  dt-bindings: iio: temperature: ltc2983: Make 'adi,custom-thermocouple' signed
  dt-bindings: iio: temperature: ltc2983: Fix child node unevaluated properties
  iio: addac: stx104: Use regmap_read_poll_timeout() for conversion poll
  iio: addac: stx104: Migrate to the regmap API
  iio: addac: stx104: Improve indentation in stx104_write_raw()
  iio: addac: stx104: Use define rather than hardcoded limit for write val
  iio: addac: stx104: Fix race condition when converting analog-to-digital
  iio: addac: stx104: Fix race condition for stx104_write_raw()
  dt-bindings: iio: st-sensors: Fix repeated text
  staging: iio: resolver: ads1210: fix config mode
  iio: adc: ti-ads1100: fix error code in probe()
  iio: accel: add support for IIS328DQ variant
  dt-bindings: iio: st-sensors: Add IIS328DQ accelerometer
  ...
2023-04-12 09:45:34 +02:00
Matti Vaittinen
e52afbd610 iio: light: ROHM BU27034 Ambient Light Sensor
ROHM BU27034 is an ambient light sensor with 3 channels and 3 photo diodes
capable of detecting a very wide range of illuminance. Typical application
is adjusting LCD and backlight power of TVs and mobile phones.

Add initial  support for the ROHM BU27034 ambient light sensor.

NOTE:
	- Driver exposes 4 channels. One IIO_LIGHT channel providing the
	  calculated lux values based on measured data from diodes #0 and
	  #1. In addition, 3 IIO_INTENSITY channels are emitting the raw
	  register data from all diodes for more intense user-space
	  computations.
	- Sensor has GAIN values that can be adjusted from 1x to 4096x.
	- Sensor has adjustible measurement times of 5, 55, 100, 200 and
	  400 mS. Driver does not support 5 mS which has special
	  limitations.
	- Driver exposes standard 'scale' adjustment which is
	  implemented by:
		1) Trying to adjust only the GAIN
		2) If GAIN adjustment alone can't provide requested
		   scale, adjusting both the time and the gain is
		   attempted.
	- Driver exposes writable INT_TIME property that can be used
	  for adjusting the measurement time. Time adjustment will also
	  cause the driver to try to adjust the GAIN so that the
	  overall scale is kept as close to the original as possible.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/2a7efb6f335da5526fbe34b95137c5e45db5c5d3.1680263956.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-10 12:26:35 +01:00
Matti Vaittinen
38416c28e1 iio: light: Add gain-time-scale helpers
Some light sensors can adjust both the HW-gain and integration time.
There are cases where adjusting the integration time has similar impact
to the scale of the reported values as gain setting has.

IIO users do typically expect to handle scale by a single writable 'scale'
entry. Driver should then adjust the gain/time accordingly.

It however is difficult for a driver to know whether it should change
gain or integration time to meet the requested scale. Usually it is
preferred to have longer integration time which usually improves
accuracy, but there may be use-cases where long measurement times can be
an issue. Thus it can be preferable to allow also changing the
integration time - but mitigate the scale impact by also changing the gain
underneath. Eg, if integration time change doubles the measured values,
the driver can reduce the HW-gain to half.

The theory of the computations of gain-time-scale is simple. However,
some people (undersigned) got that implemented wrong for more than once.

Add some gain-time-scale helpers in order to not dublicate errors in all
drivers needing these computations.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/268d418e7cffcdaa2ece6738478bbc57692c213e.1680263956.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-10 12:26:34 +01:00
Tom Rix
f1caa90085 iio: dac: set variable max5522_channels storage-class-specifier to static
smatch reports
drivers/iio/dac/max5522.c:55:28: warning: symbol
  'max5522_channels' was not declared. Should it be static?

This variable is only used in one file so it should be static.

Signed-off-by: Tom Rix <trix@redhat.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230404013828.1914523-1-trix@redhat.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-10 12:26:34 +01:00
William Breathitt Gray
7c95a3f51a iio: addac: stx104: Use regmap_read_poll_timeout() for conversion poll
ADC sample captures take a certain amount of time to complete after
initiated; this conversion time range can be anywhere from 5
microseconds to 53.68 seconds depending on the configuration of the
Analog Input Frame Timer register. When the conversion is in progress,
the ADC Status register CNV bit is high. Call regmap_read_poll_timeout()
to poll until the ADC conversion is completed (or timeout if more than
53.68 seconds passes).

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
Link: https://lore.kernel.org/r/9ef433f107afd1d4dcd2d97ef0e932d7045c2bbd.1680790580.git.william.gray@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-10 12:26:34 +01:00
William Breathitt Gray
c7301b8481 iio: addac: stx104: Migrate to the regmap API
The regmap API supports IO port accessors so we can take advantage of
regmap abstractions rather than handling access to the device registers
directly in the driver.

In addition, to improve code organization in stx104_probe(), the
devm_iio_device_register() call is moved above GPIO configuration in
order to keep relevant code closer together.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
Link: https://lore.kernel.org/r/0bcdfc4738cc019fb2ff83f61eb46a3488bc166d.1680790580.git.william.gray@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-10 12:26:34 +01:00
William Breathitt Gray
a94abc74c5 iio: addac: stx104: Improve indentation in stx104_write_raw()
By bailing out early if chan->output is false for the IIO_CHAN_INFO_RAW,
indentation can be decreased by a tab and code readability improved.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
Link: https://lore.kernel.org/r/487d17da9e2612f3e6b2bd1c3def2fa1b955db9b.1680790580.git.william.gray@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-10 12:26:33 +01:00
William Breathitt Gray
46a4cac7f8 iio: addac: stx104: Use define rather than hardcoded limit for write val
The DAC register is 16 bits wide, so the value passed by write_raw()
should be checked against that limit. Rather than hardcoding the 16-bit
maximum value limit, use a define to improve readability and make the
intention of the code clearer. The explicit cast is also avoided by
instead explicitly checking for negative values.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
Link: https://lore.kernel.org/r/4c9f4f1b4a270d133be70c82a091351b531b5e3e.1680790580.git.william.gray@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-10 12:26:33 +01:00
William Breathitt Gray
4f9b80aefb iio: addac: stx104: Fix race condition when converting analog-to-digital
The ADC conversion procedure requires several device I/O operations
performed in a particular sequence. If stx104_read_raw() is called
concurrently, the ADC conversion procedure could be clobbered. Prevent
such a race condition by utilizing a mutex.

Fixes: 4075a283ae ("iio: stx104: Add IIO support for the ADC channels")
Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
Link: https://lore.kernel.org/r/2ae5e40eed5006ca735e4c12181a9ff5ced65547.1680790580.git.william.gray@linaro.org
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-10 12:26:33 +01:00
William Breathitt Gray
9740827468 iio: addac: stx104: Fix race condition for stx104_write_raw()
The priv->chan_out_states array and actual DAC value can become
mismatched if stx104_write_raw() is called concurrently. Prevent such a
race condition by utilizing a mutex.

Fixes: 97a445dad3 ("iio: Add IIO support for the DAC on the Apex Embedded Systems STX104")
Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
Link: https://lore.kernel.org/r/c95c9a77fcef36b2a052282146950f23bbc1ebdc.1680790580.git.william.gray@linaro.org
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-10 12:26:33 +01:00
Dan Carpenter
c4351b6461 iio: adc: ti-ads1100: fix error code in probe()
This code has a copy and paste bug so it accidentally returns
"PTR_ERR(data->reg_vdd)" which is a valid pointer cast to int. It
should return "ret" instead.

Fixes: 541880542f ("iio: adc: Add TI ADS1100 and ADS1000")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Link: https://lore.kernel.org/r/36fa2aeb-f392-4793-8b38-ae15514033c8@kili.mountain
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-10 12:26:33 +01:00
Brian Masney
b1cb00d51e iio: light: tsl2772: fix reading proximity-diodes from device tree
tsl2772_read_prox_diodes() will correctly parse the properties from
device tree to determine which proximity diode(s) to read from, however
it didn't actually set this value on the struct tsl2772_settings. Let's
go ahead and fix that.

Reported-by: Tom Rix <trix@redhat.com>
Link: https://lore.kernel.org/lkml/20230327120823.1369700-1-trix@redhat.com/
Fixes: 94cd1113aa ("iio: tsl2772: add support for reading proximity led settings from device tree")
Signed-off-by: Brian Masney <bmasney@redhat.com>
Link: https://lore.kernel.org/r/20230404011455.339454-1-bmasney@redhat.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-08 10:44:34 +01:00
Rob Herring
ff7f85e354 iio: adc: ad7292: Add explicit include for of.h
With linux/acpi.h no longer implicitly including of.h, add an explicit
include of of.h to fix the following error:

drivers/iio/adc/ad7292.c:307:9: error: implicit declaration of function 'for_each_available_child_of_node'; did you mean 'fwnode_for_each_available_child_node'? [-Werror=implicit-function-declaration]

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-04-06 20:36:26 +02:00
Liang He
ffef737915 iio: dac: ad5755: Add missing fwnode_handle_put()
In ad5755_parse_fw(), we should add fwnode_handle_put()
when break out of the iteration device_for_each_child_node()
as it will automatically increase and decrease the refcounter.

Fixes: 3ac27afefd ("iio:dac:ad5755: Switch to generic firmware properties and drop pdata")
Signed-off-by: Liang He <windhl@126.com>
Link: https://lore.kernel.org/r/20230322035627.1856421-1-windhl@126.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-01 16:41:52 +01:00
Dan Carpenter
73a428b37b iio: adc: at91-sama5d2_adc: fix an error code in at91_adc_allocate_trigger()
The at91_adc_allocate_trigger() function is supposed to return error
pointers.  Returning a NULL will cause an Oops.

Fixes: 5e1a1da0f8 ("iio: adc: at91-sama5d2_adc: add hw trigger and buffer support")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Link: https://lore.kernel.org/r/5d728f9d-31d1-410d-a0b3-df6a63a2c8ba@kili.mountain
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-04-01 15:50:11 +01:00
Greg Kroah-Hartman
4bffd2c7a3 1st set of IIO fixes for 6.3
Usual mixed bag:
 
 - core - output buffers
   Fix return of bytes written when only some succeed.
   Fix O_NONBLOCK handling to not block.
 
 - adi,ad7791
   Fix IRQ type.  Not confirmed to have any impact but good to correct it anyway
 
 - adi,adis16400
   Missing CONFIG_CRC32
 
 - capella,cm32181
   Unregister 2nd I2C client if one is used.
 
 - cio-dac
   Fix bitdepth for range check on write.
 
 - linear,ltc2497
   Fix a wrong shift of the LSB introduced when switching to be24 handling.
 
 - maxim,max11410
   Fix handling of return code in read_poll_timeout()
 
 - qcom,spmi-adc
   Fix an accidental change of channel name to include the reg value from OF.
 
 - ti,palmas
   Fix a null dereference on remove due to wrong function used to get the
   drvdata.
 
 - ti,ads7950
   Mark GPIO as can sleep.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmQgfMMRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FoiFqBAAisoI3rSjyelYy4+EfafRPFzzyGQPhuUk
 UYgjzhXfBVIRvAtjqM/tgWSXoFHEWZznC07Kelz8ErXrDkTEIR10YnqaQ1OoH57c
 58Es93Y0+W5xnHyNuNc36+fAjgSARFDRkD84utu4Q7sxrLDN18f2CpYspC0XAVG5
 4RXXl8W9RXQ+0hcLQIYwXtwl1fdThPqtAOLj4/0awNPdPnsg5ZWrgzK8yfS2IJwz
 M7ilBlkey1K6F+7KhmmGz6IRxsE1zCzAh8AzvIcQYIT5zgYi2xYZg1rAaSCyd4ti
 kR1sieDyWx9sAWunprfC64uCjXvze50lpXxa0CLRK9estrcEyKcAC/ZtVD+5MF9g
 NlD2IrlJ78ol0TrWjK5QKMED0BaNetxO2cCZNBnyX99ESsUJCXHlSyUYkHHt0p3e
 /myd8ap5T8B/6yiqT5uxnZFvxPLmJ17Cm9vtONf0X/H6Dpaf7B+otjjecNiSKV+w
 9careBV3EU0D2upGpkuD4Dfc2H+NJzaAeTbtKjo7mkUgdpluhTlgRYnG/w85z2Tk
 8KSlMcrGUfBbxi4R3WrJkXeHZIRto+YDeH+uzr7BvAHc5nPCY9LGxS9TE/Mosr+A
 ncBIm/yoPItO7G0xDpknVjI0k2ncbo6zwd798VO7Xx1UIvRd4It/FSjXQsHS/wU0
 T2XPtIBpGPM=
 =8wF1
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-6.3a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-linus

Jonathan writes:

1st set of IIO fixes for 6.3

Usual mixed bag:

- core - output buffers
  Fix return of bytes written when only some succeed.
  Fix O_NONBLOCK handling to not block.

- adi,ad7791
  Fix IRQ type.  Not confirmed to have any impact but good to correct it anyway

- adi,adis16400
  Missing CONFIG_CRC32

- capella,cm32181
  Unregister 2nd I2C client if one is used.

- cio-dac
  Fix bitdepth for range check on write.

- linear,ltc2497
  Fix a wrong shift of the LSB introduced when switching to be24 handling.

- maxim,max11410
  Fix handling of return code in read_poll_timeout()

- qcom,spmi-adc
  Fix an accidental change of channel name to include the reg value from OF.

- ti,palmas
  Fix a null dereference on remove due to wrong function used to get the
  drvdata.

- ti,ads7950
  Mark GPIO as can sleep.

* tag 'iio-fixes-for-6.3a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  iio: adc: ti-ads7950: Set `can_sleep` flag for GPIO chip
  iio: adc: palmas_gpadc: fix NULL dereference on rmmod
  iio: adc: max11410: fix read_poll_timeout() usage
  iio: dac: cio-dac: Fix max DAC write value check for 12-bit
  iio: light: cm32181: Unregister second I2C client if present
  iio: accel: kionix-kx022a: Get the timestamp from the driver's private data in the trigger_handler
  iio: adc: ad7791: fix IRQ flags
  iio: buffer: make sure O_NONBLOCK is respected
  iio: buffer: correctly return bytes written in output buffers
  iio: light: vcnl4000: Fix WARN_ON on uninitialized lock
  iio: adis16480: select CONFIG_CRC32
  drivers: iio: adc: ltc2497: fix LSB shift
  iio: adc: qcom-spmi-adc5: Fix the channel name
2023-03-28 13:30:55 +02:00
Stefan Wahren
46e33707fe iio: accel: add support for IIS328DQ variant
Since the ST IIS328DQ accelerometer is compatible to the ST LIS331DL,
just add the new compatible to the st_accel framework.

Link: https://www.st.com/resource/en/datasheet/iis328dq.pdf
Signed-off-by: Stefan Wahren <stefan.wahren@chargebyte.com>
Link: https://lore.kernel.org/r/20230317103323.7741-6-stefan.wahren@chargebyte.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-03-19 15:41:22 +00:00
William Breathitt Gray
aec463feac iio: addac: stx104: Replace bitops.h header inclusion with bits.h
The <linux/bitops.h> header is included in the stx104 driver so that we
can use the BIT() macro. This macro is actually defined in the
<linux/bits.h> header, so replace the <linux/bitops.h> header inclusion
with <linux/bits.h>.

Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
Link: https://lore.kernel.org/r/20230318185503.341914-1-william.gray@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-03-19 15:36:56 +00:00
William Breathitt Gray
87a1ff66a0 iio: dac: cio-dac: Migrate to the regmap API
The regmap API supports IO port accessors so we can take advantage of
regmap abstractions rather than handling access to the device registers
directly in the driver.

Includes trivial header inclusion tidy up.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
Link: https://lore.kernel.org/r/20230311140218.74920-1-william.gray@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-03-18 16:42:52 +00:00
Lars-Peter Clausen
363c7dc72f iio: adc: ti-ads7950: Set can_sleep flag for GPIO chip
The ads7950 uses a mutex as well as SPI transfers in its GPIO callbacks.
This means these callbacks can sleep and the `can_sleep` flag should be
set.

Having the flag set will make sure that warnings are generated when calling
any of the callbacks from a potentially non-sleeping context.

Fixes: c97dce792d ("iio: adc: ti-ads7950: add GPIO support")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: David Lechner <david@lechnology.com>
Link: https://lore.kernel.org/r/20230312210933.2275376-1-lars@metafoo.de
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-03-18 16:39:35 +00:00
Uwe Kleine-König
76f2c491a0 iio: frequency: admv1013: Benefit from devm_clk_get_enabled() to simplify
Make use of devm_clk_get_enabled() to replace some code that effectively
open codes this new function.

To retain ordering move the request to a place that is executed later.
This way the time of enable keeps the same.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230313185333.2776785-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-03-18 16:35:26 +00:00