summaryrefslogtreecommitdiff
path: root/drivers/mfd/twl6040.c
AgeCommit message (Collapse)Author
2019-06-05treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 336Thomas Gleixner
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program if not write to the free software foundation inc 51 franklin st fifth floor boston ma 02110 1301 usa extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 246 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Alexios Zavras <alexios.zavras@intel.com> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190530000436.674189849@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-14mfd: twl6040: Fix device init errors for ACCCTL registerTony Lindgren
I noticed that we can get a -EREMOTEIO errors on at least omap4 duovero: twl6040 0-004b: Failed to write 2d = 19: -121 And then any following register access will produce errors. There 2d offset above is register ACCCTL that gets written on twl6040 powerup. With error checking added to the related regcache_sync() call, the -EREMOTEIO error is reproducable on twl6040 powerup at least duovero. To fix the error, we need to wait until twl6040 is accessible after the powerup. Based on tests on omap4 duovero, we need to wait over 8ms after powerup before register write will complete without failures. Let's also make sure we warn about possible errors too. Note that we have twl6040_patch[] reg_sequence with the ACCCTL register configuration and regcache_sync() will write the new value to ACCCTL. Signed-off-by: Tony Lindgren <tony@atomide.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2018-09-07regmap: split up regmap_config.use_single_rwDavid Frey
Split regmap_config.use_single_rw into use_single_read and use_single_write. This change enables drivers of devices which only support bulk operations in one direction to use the regmap_bulk_*() functions for both directions and have their bulk operation split into single operations only when necessary. Update all struct regmap_config instances where use_single_rw==true to instead set both use_single_read and use_single_write. No attempt was made to evaluate whether it is possible to set only one of use_single_read or use_single_write. Signed-off-by: David Frey <dpfrey@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-29mfd: twl6040: Fix child-node lookupJohan Hovold
Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children. To make things worse, the parent node was prematurely freed, while the child node was leaked. Note that the CONFIG_OF compile guard can be removed as of_get_child_by_name() provides a !CONFIG_OF implementation which always fails. Cc: stable <stable@vger.kernel.org> # 3.5 Fixes: 37e13cecaa14 ("mfd: Add support for Device Tree to twl6040") Fixes: ca2cad6ae38e ("mfd: Fix twl6040 build failure") Signed-off-by: Johan Hovold <johan@kernel.org> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2016-10-04mfd: twl6040: Register child device for twl6040-pdmclkPeter Ujfalusi
The McPDM in OMAP4/5 is using the pdmclk from twl6040 as functional clock. The twl6040-pdmclk driver provides a clock which can be used to make sure that the pdmclk is active when the McPDM is in use. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2016-10-04mfd: twl6040: The chip does not support bulk accessPeter Ujfalusi
Bulk access is not working with twl6040, we need to use single register access. Bulk access would happen when we try to sync the regcache after power on. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2016-06-29mfd: twl6040: Handle mclk used for HPPLL and optional internal clock sourcePeter Ujfalusi
On some boards, like omap5-uevm the MCLK is gated by default and in order to be able to use the High performance modes of twl6040 it need to be enabled by SW. Add support for handling the MCLK source clock via CCF. At the same time lower the print priority of the notification that the 32K clock is not provided and it is not going to be handled by the driver. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2016-05-09mfd: twl6040: Disable and unprepare clk32k in twl6040_power() error pathJavier Martinez Canillas
The clk32k clock is prepared and enabled in twl6040_power() but the clock is left enabled in case of an error while it should be disable/unprepared. Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2016-05-09mfd: twl6040: Check clk_prepare_enable() return value in twl6040_power()Javier Martinez Canillas
The clk_prepare_enable() function can fail so check the return value and propagate the error in case of a failure. Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2015-10-26mfd: twl6040: Fix deferred probe handling for clk32kTony Lindgren
Commit 68bab8662f49 ("mfd: twl6040: Optional clk32k clock handling") added clock handling for the 32k clock from palmas-clk. However, that patch did not consider a typical situation where twl6040 is built-in, and palmas-clk is a loadable module like we have in omap2plus_defconfig. If palmas-clk is not loaded before twl6040 probes, we will get a "clk32k is not handled" warning during booting. This means that any drivers relying on this clock will mysteriously fail, including omap5-uevm WLAN and audio. Note that for WLAN, we probably should also eventually get the clk32kgaudio for MMC3 directly as that's shared between audio and WLAN SDIO at least for omap5-uevm. It seems the WLAN chip cannot get it as otherwise MMC3 won't get properly probed. Fixes: 68bab8662f49 ("mfd: twl6040: Optional clk32k clock handling") Signed-off-by: Tony Lindgren <tony@atomide.com> Reviewed-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2015-09-04Merge tag 'sound-4.3-rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound Pull sound updates from Takashi Iwai: "There are little changes in core part, but lots of development are found in drivers, especially ASoC. The diffstat shows regmap-related changes for a slight API additions / changes, and that's all. Looking at the code size statistics, the most significant addition is for Intel Skylake. (Note that SKL support is still underway, the codec driver is missing.) Also STI controller driver is a major addition as well as a few new codec drivers. In HD-audio side, there are fewer changes than the past. The noticeable change is the support of ELD notification from i915 graphics driver. Thus this pull request carries a few changes in drm/i915. Other than that, USB-audio got a rewrite of runtime PM code. It was initiated by lockdep warning, but resulted in a good cleanup in the end. Below are the highlights: Common: - Factoring out of AC'97 reset code from ASoC into the core helper - A few regmap API extensions (in case it's not pulled yet) ASoC: - New drivers for Cirrus CS4349, GTM601, InvenSense ICS43432, Realtek RT298 and ST STI controllers - Machine drivers for Rockchip systems with MAX98090 and RT5645 and RT5650 - Initial driver support for Intel Skylake devices - Lots of rsnd cleanup and enhancements - A few DAPM fixes and cleanups - A large number of cleanups in various drivers (conversion and standardized to regmap, component) mostly by Lars-Peter and Axel HD-audio: - Extended HD-audio core for Intel Skylake controller support - Quirks for Dell headsets, Alienware 15 - Clean up of pin-based quirk tables for Realtek codecs - ELD notifier implenetation for Intel HDMI/DP USB-audio: - Refactor runtime PM code to make lockdep happier" * tag 'sound-4.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (411 commits) drm/i915: Add locks around audio component bind/unbind drm/i915: Drop port_mst_index parameter from pin/eld callback ALSA: hda - Fix missing inline for dummy snd_hdac_set_codec_wakeup() ALSA: hda - Wake the codec up on pin/ELD notify events ALSA: hda - allow codecs to access the i915 pin/ELD callback drm/i915: Call audio pin/ELD notify function drm/i915: Add audio pin sense / ELD callback ASoC: zx296702-i2s: Fix resource leak when unload module ASoC: sti_uniperif: Ensure component is unregistered when unload module ASoC: au1x: psc-i2s: Convert to use devm_ioremap_resource ASoC: sh: dma-sh7760: Convert to devm_snd_soc_register_platform ASoC: spear_pcm: Use devm_snd_dmaengine_pcm_register to fix resource leak ALSA: fireworks/bebob/dice/oxfw: fix substreams counting at vmalloc failure ASoC: Clean up docbook warnings ASoC: txx9: Convert to devm_snd_soc_register_platform ASoC: pxa: Convert to devm_snd_soc_register_platform ASoC: nuc900: Convert to devm_snd_soc_register_platform ASoC: blackfin: Convert to devm_snd_soc_register_platform ASoC: au1x: Convert to devm_snd_soc_register_platform ASoC: qcom: Constify asoc_qcom_lpass_cpu_dai_ops ...
2015-08-11mfd: Drop owner assignment from i2c_driversKrzysztof Kozlowski
i2c_driver does not need to set an owner because i2c_register_driver() will set it. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2015-07-16regmap: Use reg_sequence for multi_reg_write / register_patchNariman Poushin
Separate the functionality using sequences of register writes from the functions that take register defaults. This change renames the arguments in order to support the extension of reg_sequence to take an optional delay to be applied after any given register in a sequence is written. This avoids adding an int to all register defaults, which could substantially increase memory usage for regmaps with large default tables. This also updates all the clients of multi_reg_write/register_patch. Signed-off-by: Nariman Poushin <nariman@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2015-03-30mfd: twl6040: Remove wrong and unneeded "platform:twl6040" modaliasAxel Lin
This is a I2C driver, so it's wrong to use platform prefix for the modalias. We have all needed i2c aliases coming form MODULE_DEVICE_TABLE, so let's remove the wrong and unneeded "platform:twl6040" modalias. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2015-01-22mfd: twl6040: Constify struct regmap_config and reg_default arrayKrzysztof Kozlowski
The regmap_config struct may be const because it is not modified by the driver and regmap_init() accepts pointer to const. Make array of struct reg_default const as well. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-09-26mfd: twl6040: Fix error return codeJulia Lawall
Convert a zero return value on error to a negative one, as returned elsewhere in the function. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> ( if@p1 (\(ret < 0\|ret != 0\)) { ... return ret; } | ret@p1 = 0 ) ... when != ret = e1 when != &ret *if(...) { ... when != ret = e2 when forall return ret; } // </smpl> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-07-22mfd: twl6040: Fix 'insert space after ','', errorLee Jones
This is part of an effort to clean-up the MFD subsystem. ERROR: space required after that ',' (ctx:VxO) + 0, &twl6040_irq_chip,&twl6040->irq_data); ^ ERROR: space required before that '&' (ctx:OxV) + 0, &twl6040_irq_chip,&twl6040->irq_data); ^ total: 2 errors, 0 warnings, 816 lines checked Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-06-03mfd: twl6040: Correct HPPLL configuration for 19.2 and 38.4 MHz mclkPeter Ujfalusi
When the MCLK is 19.2 or 38.4 MHz the HPPLL need to be enabled and can be put in bypass mode. This will fix HPPLL use on boards with 19.2MHz mclk. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-06-03mfd: twl6040: Move register patching earlier in probePeter Ujfalusi
Make sure that we patch the ACCCTL register as the first thing when the driver loads, thus configuring I2C fast mode and i2c access for dual access registers. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-06-03mfd: twl6040: Optional clk32k clock handlingPeter Ujfalusi
In certain boards the source for the clk32k clock can be gated. In these boards the clk32k clock can be provided to the driver and it is going to be enabled/disabled when it is needed. If the clk32k clock is not provided the driver will assume that it is always running. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-06-03mfd: twl6040: Select i2c fast mode as default with regmap patchPeter Ujfalusi
All boards using twl6040 configures the i2c bus to 400KHz. While twl6040's defaults to normal mode (100KHz). So far twl6040 has no problem with i2c communication in this configuration it is safer to select fast i2c mode. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-06-03mfd: twl6040: Clear the interrupt ID register before requesting IRQPeter Ujfalusi
If for some reason the boot loader enabled the audpwron GPIO we will have pending IRQs to be handled. This seams to break twl6040 for some reason leading to non working i2c communication (i2c timeouts). Clearing the INTID register after we requested the audpwron GPIO (and set it to low) will ensure that the chip will operate normally in this case as well. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-03-19mfd: twl6040: Check for error when reading revision registerFlorian Vaussard
We may have an error when reading the revision register, so check for the returned value. Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-03-19mfd: twl6040: Remove duplicate register writeFlorian Vaussard
When probing, regmap_register_patch() will bypass the cache and perform i2c writes for the given patches. It is thus unnecessary to manually set the TWL6040_REG_ACCCTL register just before, as it will be done when registering the twl6040_patch. Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-01-21mfd: twl6040: Fix sparse non static symbol warningWei Yongjun
Fixes the following sparse warning: drivers/mfd/twl6040.c:89:20: warning: symbol 'twl6040_patch' was not declared. Should it be static? Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2013-12-19mfd: twl6040: reg_defaults support for regmapPeter Ujfalusi
Add reg_defaults to regmap and at the same time implement proper power state handling with using regcache_cache_only(), regcache_sync() and regcache_mark_dirty(). This will make sure that we do not need to do restore operations in child drivers anymore. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Acked-by: Mark Brown <broonie@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2013-10-25Merge tag 'mfd-lee-3.13-1' of git://git.linaro.org/people/ljones/mfdSamuel Ortiz
mfd-lee-3.13-1 MFD patches due for v3.13.
2013-10-24mfd: twl6040: Remove obsolete cleanup for i2c clientdataWolfram Sang
A few new i2c-drivers came into the kernel which clear the clientdata-pointer on exit or error. This is obsolete meanwhile, the core will do it. Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-10-23mfd: twl6040: Drop devm_free_irq of devm_ allocated irqWei Yongjun
The devm_request_irq function allocates irq that is released when a driver detaches. Thus, there is no reason to explicitly call devm_free_irq in probe or remove functions. Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2013-09-02Merge branch 'topic/for-asoc'Samuel Ortiz
2013-09-02mfd: twl6040: Use regmap for register cacheMark Brown
Rather then open coding a cache of the vibra control registers use the regmap cache code. Also cache the interrupt mask register, providing a small performance improvement for the interrupt code. Signed-off-by: Mark Brown <broonie@linaro.org> Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-07-31mfd: twl6040: Cleanup in early error handling in probe functionPeter Ujfalusi
The err: label is not needed we can just return instead of the jump there. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-07-31mfd: twl6040: Cosmetic, parameter alignment changePeter Ujfalusi
To comply with coding style. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-07-31mfd: twl6040: Remove support for legacy (pdata) modePeter Ujfalusi
TWL6040 is used only with OMAP4/5 SoCs and they can only boot in in DT mode. The support for pdata/legacy boot can be removed. Add TODO comment to the header file that all pdata struct can be removed in the next merge window (after the sub driver updates are in). Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-04-08mfd: twl6040: Use devm_*() functionsJingoo Han
Use devm_*() functions to make cleanup paths more simple. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2013-01-03Drivers: mfd: remove __dev* attributes.Greg Kroah-Hartman
CONFIG_HOTPLUG is going away as an option. As a result, the __dev* markings need to be removed. This change removes the use of __devinit, __devexit_p, __devinitdata, __devinitconst, and __devexit from these drivers. Based on patches originally written by Bill Pemberton, but redone by me in order to handle some of the coding style issues better, by hand. Cc: Bill Pemberton <wfp5p@virginia.edu> Cc: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-11-21mfd: twl6040: Remove duplicate inclusion of linux/err.hSachin Kamat
linux/err.h was included twice. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-11-13mfd: twl6040: Rename the core driverPeter Ujfalusi
After the regmap_irq conversion there is no need to call the driver as twl6040-core.c since there is only one c file remained. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>