aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/dac
AgeCommit message (Collapse)Author
2024-04-29iio: dac: ad9739a: write complete MU_CNT1 register during lockNuno Sa
As specified by the datasheet we should write the value 0x3 (enable plus tracking gain) into the MU_CNT1 register during the MU lock phase. Currently we were only setting the enable bit (bit 0) as the tracking gain default value is already set to 1. While we should be mostly fine in assuming the tracking gain will have the value it should, better to explicitly write it. On top of that the datasheet also states to re-attempt the writes in case the lock fails which we were not doing for the tracking gain bit. Lastly, the recommended value for the MU phase slope lock (bit 6) is 0 but for some reason the default value is 1 and hence, we were not changing it accordingly. Note there was no problem with the MU lock mechanism so this is not being treated as a fix but rather an improvement. Signed-off-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20240429-ad9739a-improv-v1-1-c076a06a697d@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-04-29iio: dac: adi-axi: fix a mistake in axi_dac_ext_info_set()Dan Carpenter
The last parameter of these axi_dac_(frequency|scale|phase)_set() functions is supposed to be true for TONE_2 and false for TONE_1. The bug is the last call where it passes "private - TONE_2". That subtraction is going to be zero/false for TONE_2 and and -1/true for TONE_1. Fix the bug, and re-write it as "private == TONE_2" so it's more obvious what is happening. Fixes: 4e3949a192e4 ("iio: dac: add support for AXI DAC IP core") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/df7c6e1b-b619-40c3-9881-838587ed15d4@moroto.mountain Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-04-20iio: dac: support the ad9739a RF DACNuno Sa
The AD9739A is a 14-bit, 2.5 GSPS high performance RF DACs that are capable of synthesizing wideband signals from DC up to 3 GHz. A dual-port, source synchronous, LVDS interface simplifies the digital interface with existing FGPA/ASIC technology. On-chip controllers are used to manage external and internal clock domain variations over temperature to ensure reliable data transfer from the host to the DAC core. Co-developed-by: Dragos Bogdan <dragos.bogdan@analog.com> Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com> Signed-off-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20240419-iio-backend-axi-dac-v4-10-5ca45b4de294@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-04-20iio: dac: add support for AXI DAC IP coreNuno Sa
Support the Analog Devices Generic AXI DAC IP core. The IP core is used for interfacing with digital-to-analog (DAC) converters that require either a high-speed serial interface (JESD204B/C) or a source synchronous parallel interface (LVDS/CMOS). Typically (for such devices) SPI will be used for configuration only, while this IP core handles the streaming of data into memory via DMA. Signed-off-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20240419-iio-backend-axi-dac-v4-9-5ca45b4de294@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-04-13iio: dac: ad5755: make use of of_device_id tableKrzysztof Kozlowski
Store pointers to chip info (struct ad5755_chip_info) in driver match data, instead of enum, so every value will be != 0, populate the of_device_id table and use it in driver. Even though it is one change, it gives multiple benefits: 1. Allows to use spi_get_device_match_data() dropping local 'type' variable. 2. Makes both ID tables usable, so kernel can match via any of these methods. 3. Code is more obvious as both tables are properly filled. 4. Fixes W=1 warning: ad5755.c:866:34: error: unused variable 'ad5755_of_match' [-Werror,-Wunused-const-variable] Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20240413154511.52576-1-krzysztof.kozlowski@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-04-06iio: dac: ad3552: Use __free(fwnode_handle) to simplify error handling.Jonathan Cameron
By using this scoped based cleanup direct returns on errors are enabled simplifying the code. Cc: Mihail Chindris <mihail.chindris@analog.com> Cc: Marcelo Schmitt <marcelo.schmitt1@gmail.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20240330190849.1321065-8-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-04-06iio: dac: ad5770r: Use device_for_each_child_node_scoped()Jonathan Cameron
Switching to the _scoped() version removes the need for manual calling of fwnode_handle_put() in the paths where the code exits the loop early. In this case that's all in error paths. Cc: Nuno Sá <nuno.sa@analog.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20240330185305.1319844-9-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-04-06iio: dac: ad3552r: Use device_for_each_child_node_scoped()Jonathan Cameron
Switching to the _scoped() version removes the need for manual calling of fwnode_handle_put() in the paths where the code exits the loop early. In this case that's all in error paths. Removing the goto err; statements also allows more extensive use of dev_err_probe() further simplifying the code. Cc: Mihail Chindris <mihail.chindris@analog.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20240330185305.1319844-8-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-03-28iio: dac: ti-dac5571: Add DAC081C081 supportLaurent Pinchart
The DAC081C081 is a TI DAC whose software interface is compatible with the DAC5571. It is the 8-bit version of the DAC121C081, already supported by the DAC5571 driver. Extends the driver to support this chip. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Sean Nyekjaer <sean@geanix.com <mailto:sean@geanix.com>> Link: https://lore.kernel.org/r/20240325203245.31660-3-laurent.pinchart@ideasonboard.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-03-25iio: dac: ltc2688: Use device_for_each_child_node_scoped()Jonathan Cameron
Switching to the _scoped() version removes the need for manual calling of fwnode_handle_put() in the paths where the code exits the loop early. In this case that's all in error paths. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Nuno Sa <nuno.sa@analog.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20240217164249.921878-16-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-02-28iio: dac: mcp4821: Switch to including mod_devicetable.h for struct ↵Jonathan Cameron
of_device_id definition. of.h was only included for this definition, so include the correct header instead. Reviewed-by: Nuno Sa <nuno.sa@analog.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20240218173323.1023703-9-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-12-21iio: dac: driver for MCP4821Anshul Dalal
Adds driver for the MCP48xx series of DACs. Device uses a simplex SPI channel. To set the value of an output channel, a 16-bit data of following format must be written: Bit field | Description 15 [MSB] | Channel selection bit 0 -> Channel A 1 -> Channel B 13 | Output Gain Selection bit 0 -> 2x Gain (Vref = 4.096V) 1 -> 1x Gain (Vref = 2.048V) 12 | Output Shutdown Control bit 0 -> Shutdown the selected channel 1 -> Active mode operation 11-0 [LSB]| DAC Input Data bits Value's big endian representation is taken as input for the selected DAC channel. For devices with a resolution of less than 12-bits, only the x most significant bits are considered where x is the resolution of the device. Reference: Page#22 [MCP48x2 Datasheet] Supported devices: +---------+--------------+-------------+ | Device | Resolution | Channels | |---------|--------------|-------------| | MCP4801 | 8-bit | 1 | | MCP4802 | 8-bit | 2 | | MCP4811 | 10-bit | 1 | | MCP4812 | 10-bit | 2 | | MCP4821 | 12-bit | 1 | | MCP4822 | 12-bit | 2 | +---------+--------------+-------------+ Devices tested: MCP4821 [12-bit single channel] MCP4802 [8-bit dual channel] Tested on Raspberry Pi Zero 2W Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/22244B.pdf #MCP48x1 Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/20002249B.pdf #MCP48x2 Signed-off-by: Anshul Dalal <anshulusr@gmail.com> Link: https://lore.kernel.org/r/20231220151954.154595-2-anshulusr@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-12-04iio: dac: ad5791: Add support for controlling RBUF via devicetreeMichael Hennerich
This patch adds support for an external amplifier to be connected in a gain of two configuration. Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20231129-ad5791-michael-stuff-v3-2-48e192b00909@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-10-20Merge tag 'iio-for-6.7a' of ↵Greg Kroah-Hartman
https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next Jonathan writes: IIO: 1st set of new device support, features and cleanup for 6.7 Particularly great to see a resolver driver move out of staging via a massive set of changes. Only took 13 years :) One small patch added then reverted due to a report of test breakage (ashai-kasei,ak8975: Drop deprecated enums.) An immutable branch was used for some hid-senors changes in case there was a need to take them into the HID tree as well. New device support ----------------- adi,hmc425a - Add support for HMC540SLP3E broadband 4-bit digital attenuator. kionix,kx022a - Add support for the kx132-1211 accelerometer. Require significant driver rework to enable this including add a chip type specific structure to deal with the chip differences. - Add support for the kx132acr-lbz accelerometer (subset of the kx022a feature set). lltc,ltc2309 - New driver for this 8 channel ADC. microchip,mcp3911 - Add support for rest of mcp391x family of ADCs (there are various differences beyond simple channel count variation. Series includes some general driver cleanup. microchip,mcp3564 - New driver for MCP3461, MCP3462, MCP3464, MCP3541, MCP3562, MCP3564 and their R variants of 16/24bit ADCs. A few minor fixed followed. rohm,bu1390 - New driver for this pressure sensor. Staging graduation ------------------ adi,ad1210 (after 13 or so years :) - More or less a complete (step-wise) rewrite of this resolver driver to bring it up to date with modern IIO standards. The fault signal handling mapping to event channels was particularly complex and significant part of the changes. Features -------- iio-core - Add chromacity and color temperature channel types. adi,ad7192 - Oversampling ratio control (called fast settling in datasheet). adi,adis16475 - Add core support and then driver support for delta angle and delta velocity channels. These are intended for summation to establish angle and velocity changes over larger timescales. Fix was needed for alignment after the temperature channel. Further fix reduced set of devices for which the buffer support was applicable as seems burst reads don't cover these on all devices. hid-sensors-als - Chromacity and color temperatures support including in amd sfh. stx104 - Add support for counter subsystem to this multipurpose device. ti,twl6030 - Add missing device tree binding description. Clean up and minor fixes. ------------------------ treewide - Drop some unused declarations across IIO. - Make more use of device_get_match_data() instead of OF specific approaches. Similar cleanup to sets of drivers. - Stop platform remove callbacks returning anything by using the temporary remove_new() callback. - Use i2c_get_match_data() to cope nicely with all types of ID table entry. - Use device_get_match_data() for various platform device to cope with more types of firmware. - Convert from enum to pointer in ID tables allowing use of i2c_get_match_data(). - Fix sorting on some ID tables. - Include specific string helper headers rather than simply string_helpers.h docs - Better description of the ordering requirements etc for available_scan_masks. tools - Handle alignment of mixed sizes where the last element isn't the biggest correctly. Seems that doesn't happen often! adi,ad2s1210 - Lots of work from David Lechner on this driver including a few fixes that are going with the rework to avoid slowing that down. adi,ad4310 - Replace deprecated devm_clk_register() adi,ad74413r - Bring the channel function setting inline with the datasheet. adi,ad7192 - Change to FIELD_PREP(), FIELD_GET(). - Calculate f_order from the sinc filter and chop filter states. - Move more per chip config into data in struct ad7192_chip_info - Cleanup unused parameter in channel macros. adi,adf4350 - Make use of devm_* to simplify error handling for many of the setup calls in probe() / tear down in remove() and error paths. Some more work to be done on this one. - Use dev_err_probe() for errors in probe() callback. adi,adf4413 - Typo in function name prefix. adi,adxl345 - Add channel scale to the chip type specific structure and drop using a type field previously used for indirection. asahi,ak8985 - Fix a mismatch introduced when switching from enum->pointers in the match tables. amlogic,meson - Expand error logging during probe. invensense,mpu6050 - Support level-shifter control. Whilst no one is sure exactly what this is doing it is needed for some old boards. - Document mount-matrix dt-binding. mediatek,mt6577 - Use devm_clk_get_enabled() to replace open coded version and move everything over to being device managed. Drop now empty remove() callback. Fix follows to put the drvdata back. - Use dev_err_probe() for error reporting in probe() callback. memsic,mxc4005 - Add of_match_table. microchip,mcp4725 - Move various chip specific data from being looked up by chip ID to data in the chip type specific structure. silicon-labs,si7005 - Add of_match_table and entry in trivial-devices.yaml st,lsm6dsx - Add missing mount-matrix dt binding documentation. st,spear - Use devm_clk_get_enabled() and some other devm calls to move everything over to being device managed. Drop now empty remove() callback. - Use dev_err_probe() to better handled deferred probing and tidy up error reporting in probe() callback. st,stm32-adc - Add a bit of additional checking in probe() to protect against a NULL pointer (no known path to trigger it today). - Replace deprecated strncpy() ti,ads1015 - Allow for edge triggers. - Document interrupt in dt-bindings. * tag 'iio-for-6.7a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (201 commits) iio: Use device_get_match_data() iio: adc: MCP3564: fix warn: unsigned '__x' is never less than zero. dt-bindings: trivial-devices: add silabs,si7005 iio: si7005: Add device tree support drivers: imu: adis16475.c: Remove scan index from delta channels dt-bindings: iio: imu: st,lsm6dsx: add mount-matrix property iio: resolver: ad2s1210: remove of_match_ptr() iio: resolver: ad2s1210: remove DRV_NAME macro iio: resolver: ad2s1210: move out of staging staging: iio: resolver: ad2s1210: simplify code with guard(mutex) staging: iio: resolver: ad2s1210: clear faults after soft reset staging: iio: resolver: ad2s1210: refactor sample toggle staging: iio: resolver: ad2s1210: remove fault attribute staging: iio: resolver: ad2s1210: add label attribute support staging: iio: resolver: ad2s1210: add register/fault support summary staging: iio: resolver: ad2s1210: implement fault events iio: event: add optional event label support staging: iio: resolver: ad2s1210: rename DOS reset min/max attrs staging: iio: resolver: ad2s1210: convert DOS mismatch threshold to event attr staging: iio: resolver: ad2s1210: convert DOS overrange threshold to event attr ...
2023-10-14iio: Use device_get_match_data()Rob Herring
Use preferred device_get_match_data() instead of of_match_device() to get the driver match data. With this, adjust the includes to explicitly include the correct headers. Signed-off-by: Rob Herring <robh@kernel.org> Link: https://lore.kernel.org/r/20231006224440.442864-1-robh@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-23iio: dac: vf610: Convert to platform remove callback returning voidUwe Kleine-König
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230919174931.1417681-34-u.kleine-koenig@pengutronix.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-23iio: dac: stm32-dac: Convert to platform remove callback returning voidUwe Kleine-König
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230919174931.1417681-33-u.kleine-koenig@pengutronix.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-23iio: dac: stm32-dac-core: Convert to platform remove callback returning voidUwe Kleine-König
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230919174931.1417681-32-u.kleine-koenig@pengutronix.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-23iio: dac: lpc18xx_dac: Convert to platform remove callback returning voidUwe Kleine-König
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230919174931.1417681-31-u.kleine-koenig@pengutronix.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-23iio: dac: dpot-dac: Convert to platform remove callback returning voidUwe Kleine-König
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.kernel.org/r/20230919174931.1417681-30-u.kleine-koenig@pengutronix.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-12iio: dac: mcp4725: Add dac_reg_offset to struct mcp4725_chip_infoBiju Das
The MCP4725 has a register offset '3' for reading DAC value compared to '4' for MCP4726. Add dac_reg_offset variable to struct mcp4725_chip_info to handle this difference. Drop chip_id from struct mcp4725_chip_info as it is unused. Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Link: https://lore.kernel.org/r/20230903115548.59306-5-biju.das.jz@bp.renesas.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-12iio: dac: mcp4725: Add use_ext_ref_voltage to struct mcp4725_chip_infoBiju Das
The MCP4725 has external voltage reference compared MCP4725 which has reference embeedded in eeprom. Add use_ext_ref_voltage variable to struct mcp4725_chip_info to handle this difference. Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Link: https://lore.kernel.org/r/20230903115548.59306-4-biju.das.jz@bp.renesas.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-12iio: dac: mcp4725: Use i2c_get_match_data()Biju Das
Add struct mcp4725_chip_info with chan_spec and chip_id variable. After this simplify probe() by replacing device_get_match_data() and id lookup for retrieving match data by i2c_get_match_data() by converting enum->pointer for data in the match table. Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Link: https://lore.kernel.org/r/20230903115548.59306-3-biju.das.jz@bp.renesas.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-12iio: dac: mcp4725: Replace variable 'id' from struct mcp4725_dataBiju Das
Replace the variable 'id' from struct mcp4725_data with local variable chip_id in probe() as the id variable is not used elsewhere in the driver. Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Link: https://lore.kernel.org/r/20230903115548.59306-2-biju.das.jz@bp.renesas.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-12iio: dac: stm32-dac: Use correct header(s) instead of string_helpers.hAndy Shevchenko
There is nothing from string_helpers.h used in the driver, correct the header inclusion block accordingly. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20230808164137.66663-1-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11iio: dac: ad3552r: Correct device IDsMarcelo Schmitt
Device IDs for AD3542R and AD3552R were swapped leading to unintended collection of DAC output ranges being used for each design. Change device ID values so they are correct for each DAC chip. Fixes: 8f2b54824b28 ("drivers:iio:dac: Add AD3552R driver support") Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com> Reported-by: Chandrakant Minajigi <Chandrakant.Minajigi@analog.com> Link: https://lore.kernel.org/r/011f480220799fbfabdd53896f8a2f251ad995ad.1691091324.git.marcelo.schmitt1@gmail.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11iio: dac: ti-dac5571: Sort match tablesBiju Das
Sort ID table alphabetically by name and OF table by compatible for single_*bit enums. Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Link: https://lore.kernel.org/r/20230818173907.323640-3-biju.das.jz@bp.renesas.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-09-11iio: dac: ti-dac5571: Use i2c_get_match_data()Biju Das
Replace device_get_match_data() and id lookup for retrieving match data by i2c_get_match_data() by converting enum->pointer for data in the match table. Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Link: https://lore.kernel.org/r/20230818173907.323640-2-biju.das.jz@bp.renesas.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-08-05iio: add MCP4728 I2C DAC driverAndrea Collamati
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-06-15Merge tag 'iio-for-6.5a' of ↵Greg Kroah-Hartman
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-05-21iio: Switch i2c drivers back to use .probe()Uwe Kleine-König
After commit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new() call-back type"), all drivers being converted to .probe_new() and then 03c835f498b5 ("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-13iio: dac: mcp4725: Fix i2c_master_send() return value handlingMarek Vasut
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: cf35ad61aca2 ("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-13iio: dac: build ad5758 driver when AD5758 is selectedLukas Bulwahn
Commit 28d1a7ac2a0d ("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: 28d1a7ac2a0d ("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-04-27Merge tag 'char-misc-6.4-rc1' of ↵Linus Torvalds
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-12Merge tag 'iio-for-6.4a' of ↵Greg Kroah-Hartman
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-10iio: dac: set variable max5522_channels storage-class-specifier to staticTom Rix
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-01iio: dac: ad5755: Add missing fwnode_handle_put()Liang He
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: 3ac27afefd5d ("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-03-28Merge tag 'iio-fixes-for-6.3a' of ↵Greg Kroah-Hartman
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-18iio: dac: cio-dac: Migrate to the regmap APIWilliam Breathitt Gray
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-11iio: dac: cio-dac: Fix typo in comment listing supported devicesWilliam Breathitt Gray
This driver supports the CIO-DAC08 device and not "CIO-DAC06". Signed-off-by: William Breathitt Gray <william.gray@linaro.org> Link: https://lore.kernel.org/r/20230311002434.8761-1-william.gray@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-03-11iio: dac: cio-dac: Fix max DAC write value check for 12-bitWilliam Breathitt Gray
The CIO-DAC series of devices only supports DAC values up to 12-bit rather than 16-bit. Trying to write a 16-bit value results in only the lower 12 bits affecting the DAC output which is not what the user expects. Instead, adjust the DAC write value check to reject values larger than 12-bit so that they fail explicitly as invalid for the user. Fixes: 3b8df5fd526e ("iio: Add IIO support for the Measurement Computing CIO-DAC family") Cc: stable@vger.kernel.org Signed-off-by: William Breathitt Gray <william.gray@linaro.org> Link: https://lore.kernel.org/r/20230311002248.8548-1-william.gray@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-03-11drivers: iio: dac: ad5592r: add gpio_chip namesAntoniu Miclaus
Add array of explicit gpio names for the `gpiochip` structure of ad5592r, mainly for debug purposes. Since the gpios are configurable via the dts, generic names are used. Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Link: https://lore.kernel.org/r/20221117090130.51702-1-antoniu.miclaus@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-01-21iio: dac: add support for max5522Angelo Dureghello
Add initial support for DAC max5522. Tested writing DAC A and B with some values, from 0 to 1023, measured output voltages, driver works properly. Additions for max5523/24/25 will follow. Signed-off-by: Angelo Dureghello <angelo.dureghello@timesys.com> Link: https://lore.kernel.org/r/20221106165928.223318-1-angelo.dureghello@timesys.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-12-28iio: dac: ad5686: Add support for AD5337Fabio Estevam
AD5337 belongs to the same family as the AD5338. The difference is that the AD5337 has 8-bit precision instead of 10-bit. Add support for the AD5337 chip in the driver. Signed-off-by: Fabio Estevam <festevam@gmail.com> Link: https://lore.kernel.org/r/20221130182632.3856675-2-festevam@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-11-23iio: dac: ti-dac5571: Convert to i2c's .probe_new()Uwe Kleine-König
.probe_new() doesn't get the i2c_device_id * parameter, so determine that explicitly in the probe function. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Link: https://lore.kernel.org/r/20221118224540.619276-93-uwe@kleine-koenig.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-11-23iio: dac: mcp4725: Convert to i2c's .probe_new()Uwe Kleine-König
.probe_new() doesn't get the i2c_device_id * parameter, so determine that explicitly in the probe function. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20221118224540.619276-92-uwe@kleine-koenig.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-11-23iio: dac: max5821: Convert to i2c's .probe_new()Uwe Kleine-König
.probe_new() doesn't get the i2c_device_id * parameter, so determine that explicitly in the probe function. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20221118224540.619276-91-uwe@kleine-koenig.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-11-23iio: dac: max517: Convert to i2c's .probe_new()Uwe Kleine-König
.probe_new() doesn't get the i2c_device_id * parameter, so determine that explicitly in the probe function. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20221118224540.619276-90-uwe@kleine-koenig.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-11-23iio: dac: m62332: Convert to i2c's .probe_new()Uwe Kleine-König
The probe function doesn't make use of the i2c_device_id * parameter so it can be trivially converted. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20221118224540.619276-89-uwe@kleine-koenig.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-11-23iio: dac: ds4424: Convert to i2c's .probe_new()Uwe Kleine-König
.probe_new() doesn't get the i2c_device_id * parameter, so determine that explicitly in the probe function. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20221118224540.619276-88-uwe@kleine-koenig.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>