aboutsummaryrefslogtreecommitdiff
path: root/drivers/iio/adc
AgeCommit message (Collapse)Author
2019-04-22iio: imx7d_adc: Use devm_iio_device_register()Andrey Smirnov
Use devm_iio_device_register() and drop imx7d_adc_remove(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Jonathan Cameron <jic23@kernel.org> Cc: Hartmut Knaack <knaack.h@gmx.de> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Cc: Chris Healy <cphealy@gmail.com> Cc: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-22iio: imx7d_adc: Simplify imx7d_adc_remove() with imx7d_adc_suspend()Andrey Smirnov
Since imx7d_adc_remove() does exactly the same thing as imx7d_adc_suspend() we can use the latter together with devm_add_action_or_reset() to simplify the former. Rename imx7d_adc_suspend() to imx7d_adc_disable() for clarity while at it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Jonathan Cameron <jic23@kernel.org> Cc: Hartmut Knaack <knaack.h@gmx.de> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Cc: Chris Healy <cphealy@gmail.com> Cc: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-22iio: imx7d_adc: Simplify imx7d_adc_probe() with imx7d_adc_resume()Andrey Smirnov
Initialization sequence performed in imx7d_adc_resume() is exactly the same as the one being done in imx7d_adc_probe(). Make use of the former in the latter to avoid code duplication. Rename imx7d_adc_resume() to imx7d_adc_enable() for clarity while at it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Jonathan Cameron <jic23@kernel.org> Cc: Hartmut Knaack <knaack.h@gmx.de> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Cc: Chris Healy <cphealy@gmail.com> Cc: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-22iio: adc: Add driver for the TI ADS8344 A/DC chipsGregory CLEMENT
This adds support for the Texas Instruments ADS8344 ADC chip. This chip has a 16-bit 8-Channel ADC and is access directly through SPI. Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-14iio: adc: ti-ads7950: Fix build error without CONFIG_GPIOLIBYueHaibing
When building with CONFIG_GPIOLIB is not set gcc warns this: drivers/iio/adc/ti-ads7950.c:75:19: error: field chip has incomplete type struct gpio_chip chip; ^~~~ drivers/iio/adc/ti-ads7950.c: In function ti_ads7950_set: drivers/iio/adc/ti-ads7950.c:409:32: error: implicit declaration of function gpiochip_get_data; did you mean acpi_get_data? [-Werror=implicit-function-declaration] struct ti_ads7950_state *st = gpiochip_get_data(chip); ^~~~~~~~~~~~~~~~~ acpi_get_data Reported-by: Hulk Robot <hulkci@huawei.com> Fixes: c97dce792dc8 ("iio: adc: ti-ads7950: add GPIO support") Signed-off-by: YueHaibing <yuehaibing@huawei.com> Reviewed-by: Justin Chen <justinpopo6@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-14iio: imx7d_adc: Use devm_platform_ioremap_resource()Andrey Smirnov
Use devm_platform_ioremap_resource() to be able to drop a bit of explicit boilerplate code. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Jonathan Cameron <jic23@kernel.org> Cc: Hartmut Knaack <knaack.h@gmx.de> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Cc: Chris Healy <cphealy@gmail.com> Cc: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-14iio: imx7d_adc: Replace pr_err with dev_errAndrey Smirnov
Replace combination of pr_err()/dev_name() with an equivalent call for dev_err(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Jonathan Cameron <jic23@kernel.org> Cc: Hartmut Knaack <knaack.h@gmx.de> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Cc: Chris Healy <cphealy@gmail.com> Cc: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-14iio: imx7d_adc: Add local struct device pointer in imx7d_adc_probe()Andrey Smirnov
Use a local "struct device *dev" in imx7d_adc_probe() for brevity. No functional change intended. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Jonathan Cameron <jic23@kernel.org> Cc: Hartmut Knaack <knaack.h@gmx.de> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Cc: Chris Healy <cphealy@gmail.com> Cc: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-14iio: adc: ad7616: Add support for AD7616 ADCBeniamin Bia
The AD7616 is a 12-bit ADC with 16 channels. The AD7616 can be configured to work in hardware mode by controlling it via gpio pins and read data via spi. No support for software mode yet, but it is a work in progress. This device requires a reset in order to update oversampling, so chip info has got a new attribute to mark this. The current assumption that this driver makes for AD7616, is that it's working in Hardware Mode with Serial, Burst and Sequencer modes activated. To activate them, following pins must be pulled high: -SER/PAR -SEQEN And following must be pulled low: -WR/BURST -DB4/SEQEN Datasheets: Link: https://www.analog.com/media/en/technical-documentation/data-sheets/ad7616.pdf Signed-off-by: Beniamin Bia <beniamin.bia@analog.com> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-14iio: adc: ad7606: Move oversampling options in chip info and rework *_avail ↵Stefan Popa
attributes Available oversampling ratios and scales can be shown by calling a common ad7606_show_avail function which takes as parameters the array which stores the values, together with the size of the array. Oversampling options are now defined in chip info structure and they are loaded at probe. Has_Oversampling attribute was removed because oversampling_num was added and it is not needed anymore. The purpose of this patch is to deal with the scale_avail and oversampling_avail arrays in a generic way. This makes it easier to add support for new devices which will work with different scales and oversampling ratios. It is also an intermediate step for adding support for ad7616 which has different oversampling sampling ratios available. Signed-off-by: Stefan Popa <stefan.popa@analog.com> Signed-off-by: Beniamin Bia <beniamin.bia@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-14iio: adc: Fix MAX9611 spacingFabrizio Castro
Between "config" and "MAX9611" there is a tab, replace it with a space. Signed-off-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: ad_sigma_delta: Properly handle SPI bus locking vs CS assertionLars-Peter Clausen
For devices from the SigmaDelta family we need to keep CS low when doing a conversion, since the device will use the MISO line as a interrupt to indicate that the conversion is complete. This is why the driver locks the SPI bus and when the SPI bus is locked keeps as long as a conversion is going on. The current implementation gets one small detail wrong though. CS is only de-asserted after the SPI bus is unlocked. This means it is possible for a different SPI device on the same bus to send a message which would be wrongfully be addressed to the SigmaDelta device as well. Make sure that the last SPI transfer that is done while holding the SPI bus lock de-asserts the CS signal. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Alexandru Ardelean <Alexandru.Ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: stm32-dfsdm: add PM supportFabrice Gasnier
Add PM and runtime PM support to STM32 DFSDM drivers: - stm32-dfsdm-core: manage clocks. - stm32-dfsdm-adc: restore channels configuration upon resume. Also stop restart everything in case of buffer mode. Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: stm32-dfsdm: improve sampling frequency accuracyFabrice Gasnier
The sample frequency is driven using the oversampling ratio depending on the SPI bus frequency. Currently, oversampling ratio is computed by an entire division: - spi_freq / sample_freq. This may result in inaccurate value. Using DIV_ROUND_CLOSEST improves resulting sample frequency, which is useful for audio that requests fixed rates (such as: 8, 16 or 32 kHz). BTW, introduce new routine to re-factor sample frequency setting, and move frequency accuracy message from warning to debug level. Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: stm32-dfsdm: claim direct mode for raw read and settingsFabrice Gasnier
Claim direct mode to ensure no buffer mode is in use for: - single conversion - sample rate setting (must be set when filter isn't enabled). - oversampling ratio (must be set when filter isn't enabled). Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: stm32-dfsdm: add support for buffer modesFabrice Gasnier
DFSDM conversions can be launched continuously, or using various triggers: - by software - hardware triggers (e.g. like in stm32-adc: TIM, LPTIM, EXTI) - synchronously with DFSDM filter 0. e.g. for filters 1, 2 Launching conversions can be done using two methods: a - injected: - scan mode can be used to convert several channels each time a trigger occurs. - When not is scan mode, channels are converted in sequence, one upon each trigger. b - regular: - supports software triggers or synchronous with filter 0 - single or continuous conversions This patch finalizes DFSDM operating modes using IIO buffer modes: - INDIO_BUFFER_SOFTWARE: regular continuous conversions (no trigger) but limited to 1 channel. Users must set sampling frequency in this case. For filters > 1, conversions can be started synchronously with filter 0. - INDIO_BUFFER_TRIGGERED: triggered conversions uses injected mode for launching conversions. DFSDM can use hardware triggers (e.g. STM32 timer or lptimer), so add INDIO_HARDWARE_TRIGGERED to supported modes. - INDIO_DIRECT_MODE: Only support DMA-based buffer modes. In case no DMA is available, only support single conversions. From userland perspective, to summarize various use cases: 1 - single conversion on any filter: $ cd iio:deviceX $ cat in_voltageY_raw This uses regular a conversion (not continuous) 2 - Using sampling frequency without trigger (single channel, buffer) $ cd iio:deviceX $ echo 100 > sampling_frequency $ echo "" > trigger/current_trigger $ echo 1 > scan_elements/in_voltageY_en $ echo 1 > buffer/enable This uses regular conversion in continuous mode (Frequency is achieved by tuning filter parameters) 3 - sync mode with filter 0: other filters can be converted when using "st,filter0-sync" dt property. The conversions will get started at the same time as filter 0. So for any filters > 1: $ cd iio:deviceX $ echo 100 > sampling_frequency $ echo "" > trigger/current_trigger $ echo 1 > scan_elements/in_voltageY_en $ echo 1 > buffer/enable Then start filter 0 as in 2 above. 4 - Using a hardware trigger (with one channel): - check trigger, configure it: $ cat /sys/bus/iio/devices/trigger1/name tim6_trgo $ echo 100 > /sys/bus/iio/devices/trigger1/sampling_frequency - go to any filter: $ echo 1 > scan_elements/in_voltageY_en $ echo tim6_trgo > trigger/current_trigger $ echo 1 > buffer/enable This uses injected conversion as it uses a hardware trigger (without scan) 5 - Using a hardware trigger (with 2+ channel): Same as in 4/ above, but enable two or more channels in scan_elements. This uses injected conversion as it uses a hardware trigger (with scan mode) Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: stm32-dfsdm: add support for scan modeFabrice Gasnier
In order to support multiple channels in buffer mode, add support for scan mode. This is precursor patch to ease support of triggered buffer mode. Currently, only audio uses buffer mode: Regular continuous conversions with a single channel (per filter). DFSDM hardware supports scan mode (only) with injected conversions. Conversions can be launched by software (JSWSTART), trigger or synchronously with filter 0 (e.g. JSYNC). Continuous conversion mode isn't available for injected. Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: stm32-dfsdm: enable hw consumerFabrice Gasnier
Optionally enable IIO hw consumer, when provided (e.g. for DFSDM_IIO type). This is precursor patch to introduce buffer modes. Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: stm32-dfsdm: move dma slave config to start routineFabrice Gasnier
Move DMA slave configuration to start routine: depending on regular or injected mode is in use, DMA needs to read resp. RDATAR or JDATAR. This is precursor patch to introduce injected mode (used for scan). Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: stm32-dfsdm: move dma enable from start_conv() to start_dma()Fabrice Gasnier
Move DMA enable (e.g. set RDMAEN bit) away from start_conv() that is used for both buffer and single conversions. Thus, single conv rely on interrupt, not dma. Note: take care to prepare all DMA stuff and set RDMAEN before starting filter (can be set only when DFEN=0). This is precursor patch to ease support of triggered buffer mode. Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: stm32-dfsdm: continuous mode depends on current modeFabrice Gasnier
DFSDM regular continuous mode usage depends on current mode (not DMA): - for single conversion, RCONT doesn't need to be set. - for buffer mode, RCONT has to be set (e.g. INDIO_BUFFER_SOFTWARE used by audio currently). This is related to filter configuration, move it to relevant routine. This is precursor patch to ease support of triggered buffer mode. Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: stm32-dfsdm: make spi_master_freq more accurateFabrice Gasnier
Current ckout divider may be set to a value that makes ckout to exceed spi-max-frequency. Rather use lower value (e.g. round up divider when ckout isn't accurate). Also when the SPI clock isn't accurate, 'spi_master_freq' is filled in with expected frequency. Use computed value instead to be more accurate: - e.g. source clock / (CKOUTDIV + 1) Enforce checks on the divider: ckoutdiv range can be from 1-255 to provide divider of 2-256. Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: ad7780: Add parentheses to macrosVladimir Petrigo
- Fix CHECK Macro argument 'wordsize' may be better as '(wordsize)' to avoid precedence issues Slightly modified by Jonathan to take into account the staging graduation and a copy and paste version of the same item on the following line. Signed-off-by: Vladimir Petrigo <vladimir.petrigo@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04staging: iio: ad7780: moving ad7780 out of stagingRenato Lui Geh
Move ad7780 ADC driver out of staging and into the mainline. The ad7780 is a sigma-delta analog to digital converter. This driver provides reading voltage values and status bits from both the ad778x and ad717x series. Its interface also allows writing on the FILTER and GAIN GPIO pins on the ad778x. Signed-off-by: Renato Lui Geh <renatogeh@gmail.com> Signed-off-by: Giuliano Belinassi <giuliano.belinassi@usp.br> Co-developed-by: Giuliano Belinassi <giuliano.belinassi@usp.br> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: lpc32xx: Add scale featureGregory CLEMENT
Until now this driver only exposed the raw value of the channels. With this patch, the scale value is also exposed. It depends of a regulator supply, and unlike most of the other driver, do not having this regulator won't prevent to use the driver. The reason for it is to allow to continue to use this driver with an old device tree. If there is no regulator supply then the scale won't be exposed. Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: lpc32xx: Cleanup headersGregory CLEMENT
A few headers is useless: remove them. Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: lpc32xx: Sort headersGregory CLEMENT
Sort the headers in alphabetic order in order to ease the maintenance for this part. Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: ad7124 fix indentation issue, remove extra tabColin Ian King
A return statement is indented one level too deeply; clean this up by removing a tab. Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Stefan Popa <stefan.popa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04drivers: iio: Kconfig: pedantic cleanupEnrico Weigelt, metux IT consult
Formatting of Kconfig files doesn't look so pretty, so just take damp cloth and clean it up. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: stmpe-adc: Shuffle an if statement around in stmpe_adc_isrNathan Chancellor
When building with -Wsometimes-uninitialized, Clang warns: drivers/iio/adc/stmpe-adc.c:204:13: warning: variable 'data' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] Clang can't tell that data will never be used uninitialized because the two if statements take care of all cases. Remove the first if statement and make it the else branch of the second one so that it is apparent to Clang that all cases are covered. Link: https://github.com/ClangBuiltLinux/linux/issues/387 Suggested-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Reviewed-by: NIck Desaulniers <ndesaulniers@google.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: ti-ads7950: add GPIO supportJustin Chen
The ADS79XX has GPIO pins that can be used. Add support for the GPIO pins using the GPIO chip framework. Signed-off-by: Justin Chen <justinpopo6@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: fix a potential NULL pointer dereferenceKangjie Lu
devm_iio_trigger_alloc may fail and return NULL. The fix returns ENOMEM when it fails. Signed-off-by: Kangjie Lu <kjlu@umn.edu> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: ti-ads8688: Update the module author email addressSean Nyekjaer
Update the module author to the current email address. Signed-off-by: Sean Nyekjaer <sean@geanix.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: meson-saradc: add support for Meson G12ANeil Armstrong
Add the SAR ADC driver for the Amlogic Meson-G12A SoC. Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio:adc:ad7923: Rewrite comparison to NULLBárbara Fernandes
Solves checkpath.pl's message: CHECK: Comparison to NULL could be written "!indio_dev" Signed-off-by: Bárbara Fernandes <barbara.fernandes@usp.br> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio:adc:ad7923: Put macro argument between ()'sBárbara Fernandes
Put macro argument between parenthesis in order to avoid precedence issues. Solves the following checkpath.pl's messages: CHECK: Macro argument 'mode' may be better as '(mode)' to avoid precedence issues CHECK: Macro argument 'channel' may be better as '(channel)' to avoid precedence issues CHECK: Macro argument reuse 'sequence' - possible side-effects? CHECK: Macro argument 'sequence' may be better as '(sequence)' to avoid precedence issues CHECK: Macro argument 'val' may be better as '(val)' to avoid precedence issues CHECK: Macro argument 'dec' may be better as '(dec)' to avoid precedence issues CHECK: Macro argument 'bits' may be better as '(bits)' to avoid precedence issues Signed-off-by: Bárbara Fernandes <barbara.fernandes@usp.br> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio:adc:ad7923: Use BIT macro instead of bitshiftBárbara Fernandes
Replace use of the operation '<<' by the BIT macro. Solves checkpath.pl's message: CHECK: Prefer using the BIT macro Signed-off-by: Bárbara Fernandes <barbara.fernandes@usp.br> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio:adc:ad7923: Align broken line to parenthesisBárbara Fernandes
Get broken line aligned with parenthesis on upper line. Solves checkpatch.pl's message: CHECK: Alignment should match open parenthesis Signed-off-by: Bárbara Fernandes <barbara.fernandes@usp.br> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: ti-ads7950: Fix improper use of mlockJustin Chen
Indio->mlock is used for protecting the different iio device modes. It is currently not being used in this way. Replace the lock with an internal lock specifically used for protecting the SPI transfer buffer. Signed-off-by: Justin Chen <justinpopo6@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04iio: adc: ingenic: remove redundant dev_err call in ingenic_adc_probe()Wei Yongjun
There is a error message within devm_ioremap_resource already, so remove the dev_err call to avoid redundant error message. Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-08Merge tag 'mfd-next-5.1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd Pull MFD updates from Lee Jones: "New Drivers: - Add STMPE ADC Input driver - Add STMicroelectronics STPMIC1 Parent driver - Add STMicroelectronics STPMIC1 OnKey Misc driver - Add STMicroelectronics STPMIC1 Watchdog driver - Add Cirrus Logic Lochnagar Parent driver - Add TQ-Systems TQMX86 Parent driver New Device Support: - Add support for ADC to STMPE New (or moved) Functionality: - Move Lightbar functionality to its own driver; cros_ec_lightbar - Move VBC functionality to its own driver; cros_ec_vbc - Move VBC functionality to its own driver; cros_ec_vbc - Move DebugFS functionality to its own driver; cros_ec_debugfs - Move SYSFS functionality to its own driver; cros_ec_sysfs - Add support for input voltage options; tps65218 Fixes: - Use devm_* managed resources; cros_ec - Device Tree documentation; stmpe, aspeed-lpc, lochnagar - Trivial Clean-ups; stmpe - Rip out broken modular code; aat2870-core, adp5520, as3711, db8500-prcmu, htc-i2cpld, max8925-core, rc5t583, sta2x11-mfd, syscon, tps65090, tps65910, tps68470 tps80031, wm831x-spi, wm831x-i2c, wm831x-core, wm8350-i2c, wm8350-core, wm8400-core - Kconfig fixups; INTEL_SOC_PMIC - Improve error path; sm501, sec-core - Use struct_size() helper; sm501 - Constify; at91-usart - Use pointers instead of copying data; at91-usart - Deliver proper return value; cros_ec_dev - Trivial formatting/whitespace; sec-core" * tag 'mfd-next-5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (53 commits) mfd: mxs-lradc: Mark expected switch fall-through mfd: sec-core: Cleanup formatting to a consistent style mfd: tqmx86: IO controller with I2C, Wachdog and GPIO mfd: intel-lpss: Move linux/pm.h to the local header mfd: cros_ec_dev: Return number of bytes read with CROS_EC_DEV_IOCRDMEM mfd: tps68470: Drop unused MODULE_DEVICE_TABLE mfd: at91-usart: No need to copy mfd_cell in probe mfd: at91-usart: Constify at91_usart_spi_subdev and at91_usart_serial_subdev mfd: lochnagar: Add support for the Cirrus Logic Lochnagar mfd: lochnagar: Add initial binding documentation dt-bindings: mfd: aspeed-lpc: Make parameter optional mfd: sec-core: Return gracefully instead of BUG() if device cannot match mfd: sm501: Use struct_size() in devm_kzalloc() mfd: sm501: Fix potential NULL pointer dereference mfd: Kconfig: Fix I2C_DESIGNWARE_PLATFORM dependencies mfd: tps65218.c: Add input voltage options mfd: wm8400-core: Make it explicitly non-modular mfd: wm8350-core: Drop unused module infrastructure from non-modular code mfd: wm8350-i2c: Make it explicitly non-modular mfd: wm831x-core: Drop unused module infrastructure from non-modular code ...
2019-03-06Merge tag 'staging-5.1-rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging Pull staging/IIO updates from Greg KH: "Here is the big staging/iio driver pull request for 5.1-rc1. Lots of good IIO driver updates and cleanups in here as always. Combined with the removal of the xgifb driver, we have a net "loss" of over 9000 lines in the pull request, always a nice thing. As the outreachy application process is currently happening, there are loads of tiny checkpatch cleanup fixes all over the staging tree, which accounts for the majority of the fixups" * tag 'staging-5.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (341 commits) staging: mt7621-dma: remove license boilerplate text staging: mt7621-dma: add SPDX GPL-2.0+ license identifier Staging: ks7010: Replace typecast to int Staging: vt6655: Align a static function declaration staging: speakup: fix line over 80 characters. staging: mt7621-eth: Remove license boilerplate text staging: mt7621-eth: Add SPDX license identifier staging: ks7010: removed custom Michael MIC implementation. staging: rtl8192e: Fix space and suspect issue Staging: vt6655: Modify comment style of SPDX License Identifier Staging: vt6655: Modify comment style for SPDX-License-Identifier Staging: vt6655: Align a function declaration Staging: vt6655: Alignment of function declaration staging: rtl8712: Fix indentation issue staging: wilc1000: fix incorrent type in initializer staging: rtl8188eu: remove unused P2P_PRIVATE_IOCTL_SET_LEN staging: rtl8188eu: remove unused enum P2P_PROTO_WK_ID staging: rtl8723bs: Remove duplicated include from drv_types.h Staging: vt6655: Alignment should match open parenthesis staging: erofs: fix mis-acted TAIL merging behavior ...
2019-03-06iio: adc: fix warning in Qualcomm PM8xxx HK/XOADC driverLinus Torvalds
The pm8xxx_get_channel() implementation is unclear, and causes gcc to suddenly generate odd warnings. The trigger for the warning (at least for me) was the entirely unrelated commit 79a4e91d1bb2 ("device.h: Add __cold to dev_<level> logging functions"), which apparently changes gcc code generation in the caller function enough to cause this: drivers/iio/adc/qcom-pm8xxx-xoadc.c: In function ‘pm8xxx_xoadc_probe’: drivers/iio/adc/qcom-pm8xxx-xoadc.c:633:8: warning: ‘ch’ may be used uninitialized in this function [-Wmaybe-uninitialized] ret = pm8xxx_read_channel_rsv(adc, ch, AMUX_RSV4, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ &read_nomux_rsv4, true); ~~~~~~~~~~~~~~~~~~~~~~~ drivers/iio/adc/qcom-pm8xxx-xoadc.c:426:27: note: ‘ch’ was declared here struct pm8xxx_chan_info *ch; ^~ because gcc for some reason then isn't able to see that the termination condition for the "for( )" loop in that function is also the condition for returning NULL. So it's not _actually_ uninitialized, but the function is admittedly just unnecessarily oddly written. Simplify and clarify the function, making gcc also see that it always returns a valid initialized value. Cc: Joe Perches <joe@perches.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Andy Gross <andy.gross@linaro.org> Cc: David Brown <david.brown@linaro.org> Cc: Jonathan Cameron <jic23@kernel.org> Cc: Hartmut Knaack <knaack.h@gmx.de> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-02-13Merge tag 'iio-for-5.1b' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next Jonathan writes: Second set of new device support, features and cleanup for IIO in the 5.1 cycle. There are a few late breaking fixes in here that weren't worth trying to rush into 5.0 as they have been with us for quite a while. New device support * ad7476 - add support for TI ADS786X parts that are compatible with this Analog Devices driver. Good to see some simple devices are so similar. * Ingenic jz47xx SoC ADCs - new driver and bindings * Plantower PMS7003 partical sensor - new driver and bindings including vendor prefix. * TI DAC7612 - new driver and bindings for this dual DAC. New features * ad7768-1 - Sampling frequency control * bmi160 - Data ready trigger support, including open-drain dt binding. Cleanup / minor fixes. * Analog Device DACs - Fix some inconsistent licenses. These are only ones where there were two different license marked in the same file, and hence were previously unclear. * ads124s08 - Spelling fix. * adxl345 - Parameter alignement tidy up. * bmi160 - SPDX - correct a note on the types of supported interrupts which was too strict. - use iio_pollfunc_store_time to grab an earlier timestamp. - use if (ret) instead of if (ret < 0) to be consistent whilst simplifying some handling where ret was effectively getting written to 0 even though it was always already 0. * exynos_adc - Fix a null pointer dereference on unbind. - Fix number of channels on Exynos4x12 devices to be 4 rather than 8. * lpc32xx-adc - Move DT bindings doc out of staging. Oops, I missed this one when moving the driver. - SPDX. * npcm-adc - drop documentation of reset node as going to be done differently. It's a new driver this cycle so no need to support the previous binding going forwards. * sps30 - Fix an issue with a loop timeout test that meant it would never identify a timeout. - Mark deliberate switch fall throughs. * tag 'iio-for-5.1b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (26 commits) iio: adc: exynos-adc: Use proper number of channels for Exynos4x12 dt-binding: iio: remove rst node from NPCM ADC document dt-bindings: iio: chemical: pms7003: add device tree support dt-bindings: add Plantower to the vendor prefixes iio: chemical: add support for Plantower PMS7003 sensor iio:chemical:sps30 Supress some switch fallthrough warnings. iio:adc:lpc32xx use SPDX-License-Identifier dt-bindings: iio: adc: move lpc32xx-adc out of staging iio: adc: ads124s08: fix spelling mistake "converions" -> "conversions" iio: adc: exynos-adc: Fix NULL pointer exception on unbind iio: chemical: sps30: fix a loop timeout test iio:accel:adxl345: Change alignment to match paranthesis iio:dac:dac7612: device tree bindings iio:dac:ti-dac7612: Add driver for Texas Instruments DAC7612 iio: adc: ad7476: Add support for TI ADS786X ADCs iio: adc: ad7768-1: Add support for setting the sampling frequency drivers: iio: dac: Fix wrong license for ADI drivers IIO: add Ingenic JZ47xx ADC driver. dt-bindings: iio/adc: Add bindings for Ingenic JZ47xx SoCs ADC. dt-bindings: iio/adc: Add docs for Ingenic JZ47xx SoCs ADC. ...
2019-02-12iio: adc: exynos-adc: Use proper number of channels for Exynos4x12Krzysztof Kozlowski
Exynos4212 and Exynos4412 have only four ADC channels so using "samsung,exynos-adc-v1" compatible (for eight channels ADCv1) on them is wrong. Add a new compatible for Exynos4x12. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-11Merge 5.0-rc6 into staging-nextGreg Kroah-Hartman
We need the staging fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-09iio:adc:lpc32xx use SPDX-License-IdentifierGregory CLEMENT
Convert the driver to SPDX license description which allow removing several lines in the file. Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09iio: adc: ads124s08: fix spelling mistake "converions" -> "conversions"Colin Ian King
There is a spelling mistake in several dev_err messages. Fix these. Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09iio: adc: exynos-adc: Fix NULL pointer exception on unbindKrzysztof Kozlowski
Fix NULL pointer exception on device unbind when device tree does not contain "has-touchscreen" property. In such case the input device is not registered so it should not be unregistered. $ echo "12d10000.adc" > /sys/bus/platform/drivers/exynos-adc/unbind Unable to handle kernel NULL pointer dereference at virtual address 00000474 ... (input_unregister_device) from [<c0772060>] (exynos_adc_remove+0x20/0x80) (exynos_adc_remove) from [<c0587d5c>] (platform_drv_remove+0x20/0x40) (platform_drv_remove) from [<c05860f0>] (device_release_driver_internal+0xdc/0x1ac) (device_release_driver_internal) from [<c0583ecc>] (unbind_store+0x60/0xd4) (unbind_store) from [<c031b89c>] (kernfs_fop_write+0x100/0x1e0) (kernfs_fop_write) from [<c029709c>] (__vfs_write+0x2c/0x17c) (__vfs_write) from [<c0297374>] (vfs_write+0xa4/0x184) (vfs_write) from [<c0297594>] (ksys_write+0x4c/0xac) (ksys_write) from [<c0101000>] (ret_fast_syscall+0x0/0x28) Fixes: 2bb8ad9b44c5 ("iio: exynos-adc: add experimental touchscreen support") Cc: <stable@vger.kernel.org> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09iio: adc: ad7476: Add support for TI ADS786X ADCsRicardo Ribalda Delgado
Add support for Texas Instruments ADS7866, ADS7867 and ADS7868 8/10/12 bit Single channel ADC. Datasheet: http://www.ti.com/lit/ds/symlink/ads7868.pdf Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>