summaryrefslogtreecommitdiffstats
path: root/drivers/mfd/ti_am335x_tscadc.c
AgeCommit message (Collapse)AuthorFilesLines
2021-11-05mfd: ti_am335x_tscadc: Fix spelling mistake "atleast" -> "at least"Colin Ian King1-1/+1
There is a spelling mistake in a dev_err message. Fix it. Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2021-10-21mfd: ti_am335x_tscadc: Support the correctly spelled DT propertyMiquel Raynal1-1/+7
There was in the past a typo in the coordinate readouts property. The bindings have been updated, the touchscreen driver as well and now supports both. However, the MFD driver that is in charge of verifying the validity of the property only checks the bogus one. Add support for the correctly spelled DT property. Fixes: c9aeb249bf72 ("Input: ti_am335x_tsc - fix spelling mistake in TSC/ADC DT binding") Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-38-miquel.raynal@bootlin.com
2021-10-21mfd: ti_am335x_tscadc: Add ADC1/magnetic reader supportMiquel Raynal1-7/+30
Introduce a new compatible that has another set of driver data, targeting am437x SoCs with a magnetic reader instead of the touchscreen and a more featureful set of registers. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-37-miquel.raynal@bootlin.com
2021-10-21mfd: ti_am335x_tscadc: Introduce a helper to deal with the type of hardwareMiquel Raynal1-15/+21
One way of knowing which hardware we are dealing with is to check the compatible string. When this must be done at several places, it's best and certainly more clear to use a helper for that. Introduce ti_adc_with_touchscreen() to indicate if there is a touchscreen controller available (meaning it's an am33xx-like ADC). This helper does not indicate if it is actually used (that is the purpose of the use_tsc boolean). Introducing this helper helps making a difference in the code between what is generic to both types of ADCs and what is specific to the am33xx hardware before introducing support for the am437x hardware. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-36-miquel.raynal@bootlin.com
2021-10-21mfd: ti_am335x_tscadc: Add a boolean to clarify the presence of a touchscreenMiquel Raynal1-2/+5
Just checking the number of wires will soon not be enough, add a boolean to indicate the actual use or not of the touchscreen. Certain checks only make sense when there is a touchscreen wired. Make these checks explicitly depend on the presence of the touchscreen. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-35-miquel.raynal@bootlin.com
2021-10-21mfd: ti_am335x_tscadc: Fix an error messageMiquel Raynal1-1/+1
The error message if we cannot retrieve the clock tells us that the touchscreen controller clock was unavailable. This is wrong, this is the "main" clock for the hardware block, it is not specific to the touchscreen and won't change when we will introduce ADC1/magnetic reader support so let's correct this comment. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-34-miquel.raynal@bootlin.com
2021-10-21mfd: ti_am335x_tscadc: Rename a variableMiquel Raynal1-6/+6
We need to retrieve the number of wires used by the "secondary" device (the touchscreen or the magnetic reader). Let's rename tsc_wires to become tscmag_wires to clarify the fact that this variable can be used in both situations. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-33-miquel.raynal@bootlin.com
2021-10-21mfd: ti_am335x_tscadc: Add TSC prefix in certain macrosMiquel Raynal1-5/+5
While the register list (and names) between ADC0 and ADC1 are pretty close, the bits inside changed a little bit. To avoid any future confusion, let's add the TSC prefix when some bits are in a register that is common to both revisions of the ADC, but are specific to the am33xx hardware. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-32-miquel.raynal@bootlin.com
2021-10-21mfd: ti_am335x_tscadc: Rename the subsystem enable macroMiquel Raynal1-3/+3
This bit is common to all devices (ADC, Touchscreen, Magnetic reader) so make it clear that it can be used from any location by operating a mechanical rename: s/CNTRLREG_TSCSSENB/CNTRLREG_SSENB/ Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-31-miquel.raynal@bootlin.com
2021-10-20mfd: ti_am335x_tscadc: Gather the ctrl register logic in one placeMiquel Raynal1-25/+14
Instead of deriving in the probe and in the resume path the value of the ctrl register, let's do it only once in the probe, save the value of this register (all but the subsystem enable bit) in the driver's structure and use it from the resume callback. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-23-miquel.raynal@bootlin.com
2021-10-20mfd: ti_am335x_tscadc: Reorder the initialization stepsMiquel Raynal1-6/+5
TI AM335X TRM [1] states that most of the configuration should be set in the control register in the first place, before actually enabling the hardware with the subsystem enable bit. So far only half of the configuration was made in the first step (before enabling the "subsystem"), which does not make really sense. Also, the probe and the resume patch were acting differently. Let's harmonize all this by following these steps: 1/ Configure the CLKDIV register 2/ Configure the CTRL register 3/ Configure the idle configuration 4/ Really enable the device by rewriting the CTRL register with the subsystem enable bit set. [1] https://www.ti.com/lit/pdf/spruh73 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-22-miquel.raynal@bootlin.com
2021-10-20mfd: ti_am335x_tscadc: Always provide an idle configurationMiquel Raynal1-3/+5
The idle register is valid no matter if the touchscreen is used or not, let's always configure it. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-21-miquel.raynal@bootlin.com
2021-10-20mfd: ti_am335x_tscadc: Drop useless variables from the driver structureMiquel Raynal1-11/+4
Keeping the count of tsc_cells and adc_cells is completely redundant, we can derive this information from other variables. Plus, these variables are not used anywhere else now. Let's get rid of them. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-20-miquel.raynal@bootlin.com
2021-10-20mfd: ti_am335x_tscadc: Mimic the probe from resume()Miquel Raynal1-1/+1
Use the number of touchscreen wires (tsc_wires) instead of the flag indicating a touchscreen cell (tsc_cell) to mimic the logic from the probe. Besides keeping a certain harmony in the driver, the main benefit is that we are going to simplify the number of entries in the main MFD structure and tsc_cell can now be removed more easily. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-19-miquel.raynal@bootlin.com
2021-10-20mfd: ti_am335x_tscadc: Use driver dataMiquel Raynal1-6/+16
So far every sub-cell parameter in this driver was hardcoded: cell name, cell compatible, specific clock name and desired clock frequency. As we are about to introduce support for ADC1/magnetic reader, we need a bit of flexibility. Let's add a driver data structure which will contain these information. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-18-miquel.raynal@bootlin.com
2021-10-20mfd: ti_am335x_tscadc: Move the driver structure allocation earlierMiquel Raynal1-7/+7
Allocating the driver structure should be done earlier in the probe so that we can used its members from the beginning. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-17-miquel.raynal@bootlin.com
2021-10-20mfd: ti_am335x_tscadc: Simplify divisor calculationMiquel Raynal1-5/+1
Let's rewrite this on a single line, it does not hurt the readability and saves a useless temporary variable. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-16-miquel.raynal@bootlin.com
2021-10-20mfd: ti_am335x_tscadc: Don't search the tree for our clockMiquel Raynal1-1/+1
There is a single clock available in our node, which is named "fck". The clock handler then points to adc_tsc_fck but no need to point directly to it and do a full tree search. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-15-miquel.raynal@bootlin.com
2021-10-20mfd: ti_am335x_tscadc: Reword the comment explaining the dividersMiquel Raynal1-6/+6
The comment misses the main information which is that we assume that a sample takes 15 ADC clock cycles to be generated. Let's take the occasion to rework a little bit this comment. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-14-miquel.raynal@bootlin.com
2021-10-20mfd: ti_am335x_tscadc: Drop extra spacing when declaring stack variablesMiquel Raynal1-15/+15
Many variables will be updated (renamed, dropped, added) in the upcoming changes, so let's simplify the style to avoid messing with spaces over and over again. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-12-miquel.raynal@bootlin.com
2021-10-20mfd: ti_am335x_tscadc: Get rid of useless gotosMiquel Raynal1-4/+3
Goto's jumping to a return statement are not really useful, drop them. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-13-miquel.raynal@bootlin.com
2021-10-20mfd: ti_am335x_tscadc: Fix styleMiquel Raynal1-2/+4
These are mostly deffects reported by checkpatch.pl. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-11-miquel.raynal@bootlin.com
2021-10-20mfd: ti_am335x_tscadc: Replace license text with SPDX tagMiquel Raynal1-9/+1
Drop the text license and replace it with an equivalent SPDX license tag identifier which also matches the MODULE_LICENSE(GPL) macro. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-10-miquel.raynal@bootlin.com
2021-10-20mfd: ti_am335x_tscadc: Ensure a balanced number of node get/putMiquel Raynal1-0/+5
of_node_put() should be called after a successful of_get_child_by_name(). Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20211015081506.933180-9-miquel.raynal@bootlin.com
2021-08-16mfd: ti_am335x_tscadc: Delete superfluous error messageTang Bin1-3/+2
In the function ti_tscadc_probe(), when get irq failed, platform_get_irq() logs an error message, so remove redundant message here. Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2020-08-13mfd: Replace HTTP links with HTTPS onesAlexander A. Klimov1-1/+1
Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2019-11-11mfd: ti_am335x_tscadc: Fix static checker warningVignesh Raghavendra1-1/+1
It is possible that platform_get_resource() might return NULL and therefore code needs to check for this condition before de-referencing the pointer. Therefore move the de-referencing of 'res' pointer after devm_ioremap_resource() which would have checked the validity of the pointer. Reported-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2018-12-03mfd: ti_am335x_tscadc: Use PLATFORM_DEVID_AUTO while registering mfd cellsVignesh R1-2/+3
Use PLATFORM_DEVID_AUTO to number mfd cells while registering, so that different instances are uniquely identified. This is required in order to support registering of multiple instances of same ti_am335x_tscadc IP. Signed-off-by: Vignesh R <vigneshr@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2018-10-09mfd: ti_am335x_tscadc: Keep ADC interface on if child is wakeup capableVignesh R1-0/+13
If a child device like touchscreen is wakeup capable, then keep ADC interface on, so that a touching resistive screen will generate wakeup event to the system. Signed-off-by: Vignesh R <vigneshr@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2018-10-09mfd: ti_am335x_tscadc: Don't mark TSCADC MFD as wakeup capableVignesh R1-1/+0
Currently tscadc MFD is marked as wakeup capable which incorrect because, its actually touch event by child TSC device that wakes up the system. Therefore, remove device_init_wakeup() call that marks TSCADC device as wakeup capable in favor of moving to mark TSC input device as wakeup capable later. Signed-off-by: Vignesh R <vigneshr@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2018-07-27mfd: ti_am335x_tscadc: Fix struct clk memory leakZumeng Chen1-2/+1
Use devm_elk_get() to let Linux manage struct clk memory to avoid the following memory leakage report: unreferenced object 0xdd75efc0 (size 64): comm "systemd-udevd", pid 186, jiffies 4294945126 (age 1195.750s) hex dump (first 32 bytes): 61 64 63 5f 74 73 63 5f 66 63 6b 00 00 00 00 00 adc_tsc_fck..... 00 00 00 00 92 03 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<c0a15260>] kmemleak_alloc+0x40/0x74 [<c0287a10>] __kmalloc_track_caller+0x198/0x388 [<c0255610>] kstrdup+0x40/0x5c [<c025565c>] kstrdup_const+0x30/0x3c [<c0636630>] __clk_create_clk+0x60/0xac [<c0630918>] clk_get_sys+0x74/0x144 [<c0630cdc>] clk_get+0x5c/0x68 [<bf0ac540>] ti_tscadc_probe+0x260/0x468 [ti_am335x_tscadc] [<c06f3c0c>] platform_drv_probe+0x60/0xac [<c06f1abc>] driver_probe_device+0x214/0x2dc [<c06f1c18>] __driver_attach+0x94/0xc0 [<c06efe2c>] bus_for_each_dev+0x90/0xa0 [<c06f1470>] driver_attach+0x28/0x30 [<c06f1030>] bus_add_driver+0x184/0x1ec [<c06f2b74>] driver_register+0xb0/0xf0 [<c06f3b4c>] __platform_driver_register+0x40/0x54 Signed-off-by: Zumeng Chen <zumeng.chen@gmail.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2018-05-16mfd: ti_am335x_tscadc: Delete an error message for a failed memory ↵Markus Elfring1-3/+2
allocation in ti_tscadc_probe() Omit an extra message for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2018-01-08mfd: ti_am335x_tscadc: Remove redundant assignment to nodeColin Ian King1-1/+1
Node is being initialized a value that is never read, it is being written over a few statements into the function with the return value from call to of_get_child_by_name. Hence this initialization can be removed. Cleans up clang warning: drivers/mfd/ti_am335x_tscadc.c:127:22: warning: Value stored to 'node' during its initialization is never read Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2016-11-05mfd: ti_am335x_tscadc: store physical addressMugunthan V N1-0/+1
store the physical address of the device in its priv to use it for DMA addressing in the client drivers. Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-29mfd: ti_am335x_tscadc: Rename regmap_tscadc to regmapAndrew F. Davis1-18/+18
The regmap structure pointer is named regmap_tscadc, this is not consistent with other drivers and is redundant, it also contributes to several checkpatch warnings involving long lines. Rename this. Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2016-06-29mfd: ti_am335x_tscadc: Unify variable naming when referencing ti_tscadc_devAndrew F. Davis1-44/+44
All functions in this driver reference the same ti_tscadc_dev per device but use several different names for this structure pointer, this can be confusing when following the code. Use the name 'tscadc' everywhere. Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2016-06-29mfd: ti_am335x_tscadc: Use SIMPLE_DEV_PM_OPS helper macroAndrew F. Davis1-12/+4
Replace ifdefs with SIMPLE_DEV_PM_OPS helper macro. Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2016-06-29mfd: ti_am335x_tscadc: Remove use of single line functionsAndrew F. Davis1-29/+15
tscadc_readl and tscadc_writel are single line functions and do not save use anything, remove these. Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2016-06-29mfd: ti_am335x_tscadc: Use variable name for sizeof() operatorAndrew F. Davis1-2/+1
Fix the code formatting to use the kernel preferred style of using the actual variables to determine the size using the sizeof() operator. Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2015-03-03mfd: ti_am335x_tscadc: Remove unwanted reg_se_cache saveVignesh R1-8/+5
In one shot mode, sequencer automatically disables all enabled steps at the end of each cycle. (both ADC steps and TSC steps) Hence these steps need not be saved in reg_se_cache for clearing these steps at a later stage. Also, when ADC wakes up Sequencer should not be busy executing any of the config steps except for the charge step. Previously charge step was 1 ADC clock cycle and hence it was ignored. TSC steps are always disabled at the end of each conversion cycle, hence there is no need to explicitly disable TSC steps by writing 0 to REG_SE. Signed-off-by: Vignesh R <vigneshr@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-10-20mfd: drop owner assignment from platform_driversWolfram Sang1-1/+0
A platform_driver does not need to set an owner, it will be populated by the driver core. Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2014-09-26mfd: ti_am335x_tscadc: Update logic in CTRL register for 5-wire TSJeff Lance1-13/+17
The logic in AFE_Pen_Ctrl bitmask in the CTRL register is different for five wire versus four or eight wire touschscreens. This patch should fix this for five-wire touch screens. There should be no change needed here for four and eight wire tousch screens. Signed-off-by: Jeff Lance <j-lance1@ti.com> [bigeasy: keep the change mfd only] Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-09-26mfd: ti_am335x_tscadc: Fix TSC resumeSebastian Andrzej Siewior1-1/+1
In the resume path, the ADC invokes am335x_tsc_se_set_cache() with 0 as the steps argument if continous mode is not in use. This in turn disables all steps and so the TSC is not working until one ADC sampling is performed. This patch fixes it by writing the current cached mask instead of the passed steps. Fixes: 7ca6740cd1cd ("mfd: input: iio: ti_amm335x: Rework TSC/ADCA synchronization") Cc: stable@vger.kernel.org # v3.13+ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-09-26mfd: ti_am335x_tscadc: Fix TSC operation after ADC continouous modeVignesh R1-1/+2
After enabling and disabling ADC continuous mode via sysfs, ts_print_raw fails to return any data. This is because when ADC is configured for continuous mode, it disables touch screen steps.These steps are not re-enabled when ADC continuous mode is disabled. Therefore existing values of REG_SE needs to be cached before enabling continuous mode and disabling touch screen steps and enabling ADC steps. The cached value are to be restored to REG_SE once ADC is disabled. Fixes: 7ca6740cd1cd ("mfd: input: iio: ti_amm335x: Rework TSC/ADC synchronization") Cc: stable@vger.kernel.org # v3.13+ Signed-off-by: Vignesh R <vigneshr@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-03-19mfd: ti_am335x_tscadc: Use devm_ioremap_resource()Jingoo Han1-19/+4
Use devm_ioremap_resource() in order to make the code simpler, and remove redundant return value check of platform_get_resource() because the value is checked by devm_ioremap_resource(). Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-03-19mfd: Delete non-required instances of include <linux/init.h>Paul Gortmaker1-1/+0
None of these files are actually using any __init type directives and hence don't need to include <linux/init.h>. Most are just a left over from __devinit and __cpuinit removal, or simply due to code getting copied from one driver to the next. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-01-07mfd: input: iio: ti_amm335x: Rework TSC/ADC synchronizationSebastian Andrzej Siewior1-10/+53
The ADC driver always programs all possible ADC values and discards them except for the value IIO asked for. On the am335x-evm the driver programs four values and it takes 500us to gather them. Reducing the number of conversations down to the (required) one also reduces the busy loop down to 125us. This leads to another error, namely the FIFOCOUNT register is sometimes (like one out of 10 attempts) not updated in time leading to EBUSY. The next read has the FIFOCOUNT register updated. Checking for the ADCSTAT register for being idle isn't a good choice either. The problem is that if TSC is used at the same time, the HW completes the conversation for ADC *and* before the driver noticed it, the HW begins to perform a TSC conversation and so the driver never seen the HW idle. The next time we would have two values in the FIFO but since the driver reads everything we always see the current one. So instead of polling for the IDLE bit in ADCStatus register, we should check the FIFOCOUNT register. It should be one instead of zero because we request one value. This change in turn leads to another error. Sometimes if TSC & ADC are used together the TSC starts generating interrupts even if nobody actually touched the touchscreen. The interrupts seem valid because TSC's FIFO is filled with values for each channel of the TSC. This condition stops after a few ADC reads but will occur again. Not good. On top of this (even without the changes I just mentioned) there is a ADC & TSC lockup condition which was reported to me by Jeff Lance including the following test case: A busy loop of "cat /sys/bus/iio/devices/iio\:device0/in_voltage4_raw" and a mug on touch screen. With this setup, the hardware will lockup after something between 20 minutes and it could take up to a couple of hours. During that lockup, the ADCSTAT register says 0x30 (or 0x70) which means STEP_ID = IDLE and FSM_BUSY = yes. That means the hardware says that it is idle and busy at the same time which is an invalid condition. For all this reasons I decided to rework this TSC/ADC part and add a handshake / synchronization here: First the ADC signals that it needs the HW and writes a 0 mask into the SE register. The HW (if active) will complete the current conversation and become idle. The TSC driver will gather the values from the FIFO (woken up by an interrupt) and won't "enable" another conversation. Instead it will wake up the ADC driver which is already waiting. The ADC driver will start "its" conversation and once it is done, it will enable the TSC steps so the TSC will work again. After this rework I haven't observed the lockup so far. Plus the busy loop has been reduced from 500us to 125us. The continues-read mode remains unchanged. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-01-07mfd: ti_am335x: Drop am335x_tsc_se_update() from resume pathSebastian Andrzej Siewior1-1/+0
The update of the SE register in MFD doesn't look right as it has nothing to do with it. The better place to do it is in TSC driver (which is already doing it) and in the ADC driver which needs this only in the continues mode. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-01-07mfd: ti_am335x_tscadc: Don't read back REG_SESebastian Andrzej Siewior1-4/+12
The purpose of reg_se_cache has been defeated. It should avoid the read-back of the register to avoid the latency and the fact that the bits are reset to 0 after the individual conversation took place. The reason why this is required like this to work, is that read-back of the register removes the bits of the ADC so they do not start another conversation after the register is re-written from the TSC side for the update. To avoid the not required read-back I introduce a "set once" variant which does not update the cache mask. After the conversation completes, the bit is removed from the SE register anyway and we don't plan a new conversation "any time soon". The current set function is renamed to set_cache to distinguish the two operations. This is a small preparation for a larger sync-rework. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-01-07mfd: ti_am335x_tscadc: Make am335x_tsc_se_update() localSebastian Andrzej Siewior1-2/+1
Since the "recent" changes, am335x_tsc_se_update() has no longer any users outside of this file so make it local. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Lee Jones <lee.jones@linaro.org>