* [PATCH v6 0/8] Adding support for STMPE811 ADC
From: Philippe Schenker @ 2019-01-09 13:41 UTC (permalink / raw)
To: jic23, marcel.ziswiler, stefan
Cc: robh, alexandre.torgue, shawnguo, dmitry.torokhov, thierry.reding,
mcoquelin.stm32, digetx, lee.jones, Philippe Schenker, Mark Brown,
Arnaud Pouliquen, linux-iio, Pengutronix Kernel Team, Rob Herring,
Geert Uytterhoeven, Stefan Popa, William Breathitt Gray,
linux-stm32, Fabio Estevam, Randy Dunlap, Jonathan Cameron,
Freeman Liu
From: Philippe Schenker <philippe.schenker@toradex.com>
Hello everyone,
This patchset is adding an ADC driver for STMPE811. The STMPE811 is a
Multi-Frontend-Device that supports a touchscreen, ADC, GPIO and a
temperature sensor.
For Touchscreen and GPIO there are already existing drivers in
mainline. This patchset will add support, to read out the ADC and
temperature sensor.
This patchset is also reformatting device tree bindings, so they are
easier to read (PATCH 1/1).
To be able to add this ADC driver it is necessary to move some defines
from the touchscreen driver to the mfd device (PATCH 2/8) so they are
also accessible by mfd and adc driver.
Because the touchscreen driver is also using the internal ADC it makes
sense to put the common adc settings of stmpe-ts.c and stmpe_adc.c to
the MFD. In the MFD there is then also an initialisation for the common
settings of ADC done. The existing initialisation in touchscreen driver
is kept for backwards-compatibility. All of this MFD related changes
are in PATCH 3/8.
In PATCH 4/8 then these settings are removed from stmpe-ts and grabbed
from MFD.
PATCH 5/8 is actually adding the ADC driver that also supports the
built-in temperature sensor.
PATCH 6/8 is then adding the needed devicetree bindings.
PATCH 7/8 and 8/8 is lastly adding the stmpe_adc DT-nodes as found on
Toradex boards.
Changes in v6:
- Added Rob's Reviewed-by
- Added Dmitry's ack
- Added Rob's Reviewed-by
- Just realized that the comment for st,norequest-mask was at the wrong
place, fixed.
- Just realized that the comment for st,norequest-mask was at the wrong
place, fixed.
- Added also tegra30-apalis-v1.1.dtsi, as I forgot that.
Changes in v5:
- Made a one column list
- Added lee's Acked-for-MFD
- Changed author of commit to use correct email.
- Changed author of commit to use correct email
- Added Lee Jone's Ack
- Changed author of commit. Previous patch versions author was wrong
by mistake.
- Changed author of commit to use correct email.
- Removed devm_add_action_or_reset
- Changed iio_device_register to devm_iio_device_register
- Added Jonathan Cameron's Reviewed-by
- Added correct author of commit, as this changed by accident
- Made a one column list
- Cleared note about precedence
- Changed example to a full STMPE811 device with MFD, touchscreen, and the new
stmpe_adc driver.
- Added Jonathan Cameron's Reviewed-by
Changes in v4:
- New separate precursor patch for holding reformatting
- Added Lee Jone's Ack
- Added Dmitry Torokhov's Ack
- New patch: split mfd changes into this precursor patch
- Export the added stmpe811_adc_commmon_init function
- Disabling adc when mfd is removed
- New patch: Split changes in stmpe-ts.c to a separate commit
- Remove common adc settings from init and call the
stmpe811_adc_common_init function
- Moved MFD changes to a precursor patch
- Moved stmpe-ts changes to a precursor patch
- Created stmpe_read_temp and stmpe_read_voltage functions to make
read_raw more readable
- Added local lock instead of using indio_dev's mlock
- Use be16_to_cpu() macro instead of bitshifting
- Added stmpe_enable again to stmpe_adc_init_hw
- Use devm_add_action_or_reset to get rid of the remove function
(I tested if that actually works)
- Put reformatting in a separate precursor patch.
- Moved T30 devicetree settings to separate commit
- New separate commit to hold T30 devicetree changes
Changes in v3:
- Undo ADC-settings related code-deletions in stmpe-ts.c that the code
is backwards-compatible to older devicetrees.
- Removed COMPILE_TEST from dependings in Kconfig
- Removed stmpe_adc_get_platform_info() function and integrated the
few code lines in the other function
- Reformatted documentation for touchscreen to use tabs and have a better
overview of the settings.
- Added note which adc-settings will take precedence.
- changed typo in sample-time setting from 144 clocks to 124 clocks, as stated
in the datasheet.
- None
Changes in v2:
- This is a new added commit. Separate commit for moving the defines
out of drivers/input/touchscreen/stmpe-ts.c to overlying mfd-device
drivers/mfd/stmpe.c
- Pre-fix defines with STMPE_
- Move code to setup ADC to MFD device, as it is used by both drivers
adc and touchscreen
- Code formatting
- Removed unused includes
- Defined the macro STMPE_START_ONE_TEMP_CONV with other macros.
- Added new macro that defines the channel of the temperature sensor.
Took new name for STMPE_MAX_ADC->STMPE_ADC_LAST_NR and used it
throughout the code for better readability.
- Added mutex_unlock where missing.
- Moved the bindings for ADC to the overlying mfd.
- Reformatted for better readability
- Put common ADC settings in mfd
Philippe Schenker (5):
dt-bindings: stmpe: reformatting parameter list and use tabs only
mfd: stmpe: Move ADC related defines to header of mfd
Input: stmpe-ts: preparations for STMPE ADC driver
ARM: dts: Add stmpe-adc DT node to Toradex iMX6 modules
ARM: dts: Add stmpe-adc DT node to Toradex T30 modules
Stefan Agner (3):
mfd: stmpe: preparations for STMPE ADC driver
iio: adc: add STMPE ADC driver using IIO framework
iio: adc: add STMPE ADC devicetree bindings
.../devicetree/bindings/iio/adc/stmpe-adc.txt | 21 +
.../bindings/input/touchscreen/stmpe.txt | 116 ++++--
.../devicetree/bindings/mfd/stmpe.txt | 28 +-
arch/arm/boot/dts/imx6qdl-apalis.dtsi | 22 +-
arch/arm/boot/dts/imx6qdl-colibri.dtsi | 23 +-
arch/arm/boot/dts/tegra30-apalis-v1.1.dtsi | 22 +-
arch/arm/boot/dts/tegra30-apalis.dtsi | 22 +-
arch/arm/boot/dts/tegra30-colibri.dtsi | 22 +-
drivers/iio/adc/Kconfig | 7 +
drivers/iio/adc/Makefile | 1 +
drivers/iio/adc/stmpe-adc.c | 363 ++++++++++++++++++
drivers/input/touchscreen/stmpe-ts.c | 66 +---
drivers/mfd/Kconfig | 3 +-
drivers/mfd/stmpe.c | 68 ++++
include/linux/mfd/stmpe.h | 21 +
15 files changed, 681 insertions(+), 124 deletions(-)
create mode 100644 Documentation/devicetree/bindings/iio/adc/stmpe-adc.txt
create mode 100644 drivers/iio/adc/stmpe-adc.c
--
2.20.1
^ permalink raw reply
* Re: [PATCH v3 1/4] dt-bindings: input: touchscreen: goodix: Document AVDD28-supply property
From: Rob Herring @ 2019-01-09 13:37 UTC (permalink / raw)
To: Dmitry Torokhov, Jagan Teki
Cc: Chen-Yu Tsai, linux-input, linux-kernel@vger.kernel.org,
Michael Trimarchi, linux-amarula
In-Reply-To: <20190107225810.ggmkkbrnkoy2ykx5@penguin>
Please CC DT list if you want bindings reviewed.
On Wed, Jan 9, 2019 at 1:40 AM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>
> On Sat, Dec 15, 2018 at 08:47:59PM +0530, Jagan Teki wrote:
> > Most of the Goodix CTP controllers are supply with AVDD28 pin.
> > which need to supply for controllers like GT5663 on some boards
> > to trigger the power.
> >
> > So, document the supply property so-that the require boards
> > that used on GT5663 can enable it via device tree.
> >
> > Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> > ---
> > Documentation/devicetree/bindings/input/touchscreen/goodix.txt | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> > index f7e95c52f3c7..c4622c983e08 100644
> > --- a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> > +++ b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> > @@ -23,6 +23,7 @@ Optional properties:
> > - touchscreen-inverted-y : Y axis is inverted (boolean)
> > - touchscreen-swapped-x-y : X and Y axis are swapped (boolean)
> > (swapping is done after inverting the axis)
> > + - AVDD28-supply : Analog power supply regulator on AVDD28 pin
>
> I think we normally use lower case in DT bindings and rarely encode
> voltage in the supply name unless we are dealing with several supplies
> of the same kind, but I'll let Ron comment on this.
Yes on lowercase though there are some exceptions.
There's also a AVDD22 supply as well as DVDD12 and VDDIO. So we
probably need to keep the voltage, but the binding is incomplete.
Rob
^ permalink raw reply
* [PATCH] Input: mcs_touchkey - use struct_size() in kzalloc()
From: Gustavo A. R. Silva @ 2019-01-08 21:15 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, Gustavo A. R. Silva
One of the more common cases of allocation size calculations is finding the
size of a structure that has a zero-sized array at the end, along with memory
for some number of elements for that array. For example:
struct foo {
int stuff;
void *entry[];
};
instance = kzalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
Instead of leaving these open-coded and prone to type mistakes, we can now
use the new struct_size() helper:
instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);
This code was detected with the help of Coccinelle.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/input/keyboard/mcs_touchkey.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/input/keyboard/mcs_touchkey.c b/drivers/input/keyboard/mcs_touchkey.c
index be56d4f262a7..b132662201a4 100644
--- a/drivers/input/keyboard/mcs_touchkey.c
+++ b/drivers/input/keyboard/mcs_touchkey.c
@@ -113,9 +113,8 @@ static int mcs_touchkey_probe(struct i2c_client *client,
return -EINVAL;
}
- data = kzalloc(sizeof(struct mcs_touchkey_data) +
- sizeof(data->keycodes[0]) * (pdata->key_maxval + 1),
- GFP_KERNEL);
+ data = kzalloc(struct_size(data, keycodes, pdata->key_maxval + 1),
+ GFP_KERNEL);
input_dev = input_allocate_device();
if (!data || !input_dev) {
dev_err(&client->dev, "Failed to allocate memory\n");
--
2.20.1
^ permalink raw reply related
* Re: [PATCH] Input: goodix - decouple irq and reset lines
From: Gonzalez, Alex @ 2019-01-08 17:20 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Bastien Nocera, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org
In-Reply-To: <20190107185607.GA141497@dtor-ws>
>
>My concern with trying to do the address selection without RST line is
>that it is quite unreliable, as it really depends on timings between the
>chip reset, INT line being driven by the host and then being switched to
>input.
I think you are right. thinking twice I should be able to fake the reset line
by controlling a regulator to the voltage source for the pull-up. It seems a
more solid solution.
Thanks a lot for your help and sorry for the noise.
Alex
^ permalink raw reply
* [PATCH] Input: tca6416-keypad: use struct_size() in kzalloc()
From: Gustavo A. R. Silva @ 2019-01-08 15:28 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, Gustavo A. R. Silva
One of the more common cases of allocation size calculations is finding the
size of a structure that has a zero-sized array at the end, along with memory
for some number of elements for that array. For example:
struct foo {
int stuff;
void *entry[];
};
instance = kzalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
Instead of leaving these open-coded and prone to type mistakes, we can now
use the new struct_size() helper:
instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);
This code was detected with the help of Coccinelle.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/input/keyboard/tca6416-keypad.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/input/keyboard/tca6416-keypad.c b/drivers/input/keyboard/tca6416-keypad.c
index dc983ab6c0ad..cdeef180aead 100644
--- a/drivers/input/keyboard/tca6416-keypad.c
+++ b/drivers/input/keyboard/tca6416-keypad.c
@@ -219,9 +219,7 @@ static int tca6416_keypad_probe(struct i2c_client *client,
return -EINVAL;
}
- chip = kzalloc(sizeof(struct tca6416_keypad_chip) +
- pdata->nbuttons * sizeof(struct tca6416_button),
- GFP_KERNEL);
+ chip = kzalloc(struct_size(chip, buttons, pdata->nbuttons), GFP_KERNEL);
input = input_allocate_device();
if (!chip || !input) {
error = -ENOMEM;
--
2.20.1
^ permalink raw reply related
* [PATCH] Input: elan_i2c - Add auto recovery handle for absolute mode
From: KT Liao @ 2019-01-08 7:30 UTC (permalink / raw)
To: linux-kernel, linux-input, dmitry.torokhov, ulrik.debie-os; +Cc: kt.liao
Sometimes touchpad will be reset to mouse mode unexpectedly.
And cause invalid report detection.
I add a mouse report detection and send mode-switching command again.
Signed-off-by: KT Liao <kt.liao@emc.com.tw>
---
drivers/input/mouse/elan_i2c_core.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index 2690a4b..56b5766 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -51,6 +51,7 @@
#define ETP_MAX_FINGERS 5
#define ETP_FINGER_DATA_LEN 5
+#define ETP_MOUSE_REPORT_ID 0x01
#define ETP_REPORT_ID 0x5D
#define ETP_TP_REPORT_ID 0x5E
#define ETP_REPORT_ID_OFFSET 2
@@ -988,6 +989,14 @@ static irqreturn_t elan_isr(int irq, void *dev_id)
case ETP_TP_REPORT_ID:
elan_report_trackpoint(data, report);
break;
+ case ETP_MOUSE_REPORT_ID:
+ dev_info(dev, "Mouse report now, mode switch again\n");
+ data->mode |= ETP_ENABLE_ABS;
+ error = data->ops->set_mode(data->client, data->mode);
+ if (error)
+ dev_err(dev, "fail to switch to absolute mode(%d)\n",
+ error);
+ break;
default:
dev_err(dev, "invalid report id data (%x)\n",
report[ETP_REPORT_ID_OFFSET]);
--
2.7.4
^ permalink raw reply related
* [PATCH v2] dt-bindings: input: ti-tsc-adc: Add new compatible for AM654 SoCs
From: Vignesh R @ 2019-01-08 5:26 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Rob Herring, Vignesh R, linux-input, devicetree, linux-kernel,
linux-omap, Lee Jones
AM654 SoCs has ADC IP which is similar to AM335x, but without the
touchscreen part. Add new compatible to handle AM654 SoCs. Also, it
seems that existing compatible strings used in the kernel DTs were never
documented. So, document them now.
Signed-off-by: Vignesh R <vigneshr@ti.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
v2:
Fix subject line to include subsystem name
Rebase onto v5.0-rc1
v1: https://lkml.org/lkml/2018/11/19/313
.../devicetree/bindings/input/touchscreen/ti-tsc-adc.txt | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt b/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
index b1163bf97146..aad5e34965eb 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
@@ -2,7 +2,12 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Required properties:
+- mfd
+ compatible: Should be
+ "ti,am3359-tscadc" for AM335x/AM437x SoCs
+ "ti,am654-tscadc", "ti,am3359-tscadc" for AM654 SoCs
- child "tsc"
+ compatible: Should be "ti,am3359-tsc".
ti,wires: Wires refer to application modes i.e. 4/5/8 wire touchscreen
support on the platform.
ti,x-plate-resistance: X plate resistance
@@ -25,6 +30,9 @@ Required properties:
AIN0 = 0, AIN1 = 1 and so on till AIN7 = 7.
XP = 0, XN = 1, YP = 2, YN = 3.
- child "adc"
+ compatible: Should be
+ "ti,am3359-adc" for AM335x/AM437x SoCs
+ "ti,am654-adc", "ti,am3359-adc" for AM654 SoCs
ti,adc-channels: List of analog inputs available for ADC.
AIN0 = 0, AIN1 = 1 and so on till AIN7 = 7.
--
2.20.1
^ permalink raw reply related
* Re: [PATCH v5 4/8] Input: stmpe-ts: preparations for STMPE ADC driver
From: Dmitry Torokhov @ 2019-01-07 23:03 UTC (permalink / raw)
To: Philippe Schenker
Cc: jic23, marcel.ziswiler, stefan, robh, alexandre.torgue, shawnguo,
thierry.reding, digetx, lee.jones, coquelin.stm32,
Philippe Schenker, linux-kernel, linux-input, Maxime Coquelin,
linux-stm32, linux-arm-kernel
In-Reply-To: <20181221134638.20600-5-dev@pschenker.ch>
On Fri, Dec 21, 2018 at 02:46:33PM +0100, Philippe Schenker wrote:
> From: Philippe Schenker <philippe.schenker@toradex.com>
>
> This patch removes common ADC settings in favor to use
> stmpe811_adc_common_init that is present in MFD. This is necessary in
> preparation for the stmpe-adc driver, because those two drivers have
> common settings for the ADC.
>
> Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>
> ---
>
> Changes in v5:
> - Changed author of commit to use correct email.
>
> Changes in v4:
> - New patch: Split changes in stmpe-ts.c to a separate commit
> - Remove common adc settings from init and call the
> stmpe811_adc_common_init function
>
> Changes in v3:
> - Undo ADC-settings related code-deletions in stmpe-ts.c that the code
> is backwards-compatible to older devicetrees.
>
> Changes in v2: None
>
> drivers/input/touchscreen/stmpe-ts.c | 42 +++++-----------------------
> 1 file changed, 7 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
> index c5d9006588a2..cf9c9aa39f6e 100644
> --- a/drivers/input/touchscreen/stmpe-ts.c
> +++ b/drivers/input/touchscreen/stmpe-ts.c
> @@ -30,8 +30,6 @@
> * with touchscreen controller
> */
> #define STMPE_REG_INT_STA 0x0B
> -#define STMPE_REG_ADC_CTRL1 0x20
> -#define STMPE_REG_ADC_CTRL2 0x21
> #define STMPE_REG_TSC_CTRL 0x40
> #define STMPE_REG_TSC_CFG 0x41
> #define STMPE_REG_FIFO_TH 0x4A
> @@ -58,15 +56,6 @@
> * @idev: registered input device
> * @work: a work item used to scan the device
> * @dev: a pointer back to the MFD cell struct device*
> - * @sample_time: ADC converstion time in number of clock.
> - * (0 -> 36 clocks, 1 -> 44 clocks, 2 -> 56 clocks, 3 -> 64 clocks,
> - * 4 -> 80 clocks, 5 -> 96 clocks, 6 -> 144 clocks),
> - * recommended is 4.
> - * @mod_12b: ADC Bit mode (0 -> 10bit ADC, 1 -> 12bit ADC)
> - * @ref_sel: ADC reference source
> - * (0 -> internal reference, 1 -> external reference)
> - * @adc_freq: ADC Clock speed
> - * (0 -> 1.625 MHz, 1 -> 3.25 MHz, 2 || 3 -> 6.5 MHz)
> * @ave_ctrl: Sample average control
> * (0 -> 1 sample, 1 -> 2 samples, 2 -> 4 samples, 3 -> 8 samples)
> * @touch_det_delay: Touch detect interrupt delay
> @@ -88,10 +77,6 @@ struct stmpe_touch {
> struct input_dev *idev;
> struct delayed_work work;
> struct device *dev;
> - u8 sample_time;
> - u8 mod_12b;
> - u8 ref_sel;
> - u8 adc_freq;
> u8 ave_ctrl;
> u8 touch_det_delay;
> u8 settling;
> @@ -192,7 +177,7 @@ static irqreturn_t stmpe_ts_handler(int irq, void *data)
> static int stmpe_init_hw(struct stmpe_touch *ts)
> {
> int ret;
> - u8 adc_ctrl1, adc_ctrl1_mask, tsc_cfg, tsc_cfg_mask;
> + u8 tsc_cfg, tsc_cfg_mask;
> struct stmpe *stmpe = ts->stmpe;
> struct device *dev = ts->dev;
>
> @@ -202,22 +187,9 @@ static int stmpe_init_hw(struct stmpe_touch *ts)
> return ret;
> }
>
> - adc_ctrl1 = STMPE_SAMPLE_TIME(ts->sample_time) |
> - STMPE_MOD_12B(ts->mod_12b) | STMPE_REF_SEL(ts->ref_sel);
> - adc_ctrl1_mask = STMPE_SAMPLE_TIME(0xff) | STMPE_MOD_12B(0xff) |
> - STMPE_REF_SEL(0xff);
> -
> - ret = stmpe_set_bits(stmpe, STMPE_REG_ADC_CTRL1,
> - adc_ctrl1_mask, adc_ctrl1);
> - if (ret) {
> - dev_err(dev, "Could not setup ADC\n");
> - return ret;
> - }
> -
> - ret = stmpe_set_bits(stmpe, STMPE_REG_ADC_CTRL2,
> - STMPE_ADC_FREQ(0xff), STMPE_ADC_FREQ(ts->adc_freq));
> + ret = stmpe811_adc_common_init(stmpe);
> if (ret) {
> - dev_err(dev, "Could not setup ADC\n");
> + stmpe_disable(stmpe, STMPE_BLOCK_TOUCHSCREEN | STMPE_BLOCK_ADC);
> return ret;
> }
>
> @@ -295,13 +267,13 @@ static void stmpe_ts_get_platform_info(struct platform_device *pdev,
>
> if (np) {
> if (!of_property_read_u32(np, "st,sample-time", &val))
> - ts->sample_time = val;
> + ts->stmpe->sample_time = val;
> if (!of_property_read_u32(np, "st,mod-12b", &val))
> - ts->mod_12b = val;
> + ts->stmpe->mod_12b = val;
> if (!of_property_read_u32(np, "st,ref-sel", &val))
> - ts->ref_sel = val;
> + ts->stmpe->ref_sel = val;
> if (!of_property_read_u32(np, "st,adc-freq", &val))
> - ts->adc_freq = val;
> + ts->stmpe->adc_freq = val;
> if (!of_property_read_u32(np, "st,ave-ctrl", &val))
> ts->ave_ctrl = val;
> if (!of_property_read_u32(np, "st,touch-det-delay", &val))
> --
> 2.19.2
>
--
Dmitry
^ permalink raw reply
* Re: [PATCH v3 2/4] Input: goodix - Add AVDD28-supply regulator support
From: Dmitry Torokhov @ 2019-01-07 23:00 UTC (permalink / raw)
To: Jagan Teki
Cc: Chen-Yu Tsai, linux-input, linux-kernel, Michael Trimarchi,
linux-amarula
In-Reply-To: <20181215151802.18592-3-jagan@amarulasolutions.com>
Hi Jagan,
On Sat, Dec 15, 2018 at 08:48:00PM +0530, Jagan Teki wrote:
> Goodix CTP controllers have AVDD28 pin connected to voltage
> regulator which may not be turned on by default, like for GT5663.
>
> Add support for such ctp used boards by adding voltage regulator
> handling code to goodix ctp driver.
>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
> drivers/input/touchscreen/goodix.c | 33 +++++++++++++++++++++++++-----
> 1 file changed, 28 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
> index f2d9c2c41885..7371f6946098 100644
> --- a/drivers/input/touchscreen/goodix.c
> +++ b/drivers/input/touchscreen/goodix.c
> @@ -27,6 +27,7 @@
> #include <linux/delay.h>
> #include <linux/irq.h>
> #include <linux/interrupt.h>
> +#include <linux/regulator/consumer.h>
> #include <linux/slab.h>
> #include <linux/acpi.h>
> #include <linux/of.h>
> @@ -47,6 +48,7 @@ struct goodix_ts_data {
> struct touchscreen_properties prop;
> unsigned int max_touch_num;
> unsigned int int_trigger_type;
> + struct regulator *avdd28;
> struct gpio_desc *gpiod_int;
> struct gpio_desc *gpiod_rst;
> u16 id;
> @@ -786,25 +788,41 @@ static int goodix_ts_probe(struct i2c_client *client,
> if (error)
> return error;
>
> + ts->avdd28 = devm_regulator_get(&client->dev, "AVDD28");
> + if (IS_ERR(ts->avdd28)) {
> + error = PTR_ERR(ts->avdd28);
> + if (error != -EPROBE_DEFER)
> + dev_err(&client->dev,
> + "Failed to get AVDD28 regulator: %d\n", error);
> + return error;
> + }
> +
> + /* power the controller */
> + error = regulator_enable(ts->avdd28);
> + if (error) {
> + dev_err(&client->dev, "Controller fail to enable AVDD28\n");
> + return error;
> + }
> +
> if (ts->gpiod_int && ts->gpiod_rst) {
> /* reset the controller */
> error = goodix_reset(ts);
> if (error) {
> dev_err(&client->dev, "Controller reset failed.\n");
> - return error;
> + goto error;
> }
> }
>
> error = goodix_i2c_test(client);
> if (error) {
> dev_err(&client->dev, "I2C communication failure: %d\n", error);
> - return error;
> + goto error;
> }
>
> error = goodix_read_version(ts);
> if (error) {
> dev_err(&client->dev, "Read version failed.\n");
> - return error;
> + goto error;
> }
>
> ts->chip = goodix_get_chip_data(ts->id);
> @@ -823,23 +841,28 @@ static int goodix_ts_probe(struct i2c_client *client,
> dev_err(&client->dev,
> "Failed to invoke firmware loader: %d\n",
> error);
> - return error;
> + goto error;
> }
>
> return 0;
> } else {
> error = goodix_configure_dev(ts);
> if (error)
> - return error;
> + goto error;
> }
>
> return 0;
> +
> +error:
> + regulator_disable(ts->avdd28);
> + return error;
> }
>
> static int goodix_ts_remove(struct i2c_client *client)
> {
> struct goodix_ts_data *ts = i2c_get_clientdata(client);
>
> + regulator_disable(ts->avdd28);
This may be disabling the regulator too early. Please use
devm_add_action_or_reset() to install a custom devm handler that would
disable the regulator in line with the rest of devm unwinding flow.
> if (ts->gpiod_int && ts->gpiod_rst)
> wait_for_completion(&ts->firmware_loading_complete);
>
> --
> 2.18.0.321.gffc6fa0e3
>
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH v3 1/4] dt-bindings: input: touchscreen: goodix: Document AVDD28-supply property
From: Dmitry Torokhov @ 2019-01-07 22:58 UTC (permalink / raw)
To: Jagan Teki, robh
Cc: Chen-Yu Tsai, linux-input, linux-kernel, Michael Trimarchi,
linux-amarula
In-Reply-To: <20181215151802.18592-2-jagan@amarulasolutions.com>
On Sat, Dec 15, 2018 at 08:47:59PM +0530, Jagan Teki wrote:
> Most of the Goodix CTP controllers are supply with AVDD28 pin.
> which need to supply for controllers like GT5663 on some boards
> to trigger the power.
>
> So, document the supply property so-that the require boards
> that used on GT5663 can enable it via device tree.
>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> ---
> Documentation/devicetree/bindings/input/touchscreen/goodix.txt | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> index f7e95c52f3c7..c4622c983e08 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> @@ -23,6 +23,7 @@ Optional properties:
> - touchscreen-inverted-y : Y axis is inverted (boolean)
> - touchscreen-swapped-x-y : X and Y axis are swapped (boolean)
> (swapping is done after inverting the axis)
> + - AVDD28-supply : Analog power supply regulator on AVDD28 pin
I think we normally use lower case in DT bindings and rarely encode
voltage in the supply name unless we are dealing with several supplies
of the same kind, but I'll let Ron comment on this.
Thanks.
--
Dmitry
^ permalink raw reply
* Re: [PATCH] [v2] Input: touchscreen: Fix a missing check on regmap_bulk_read
From: Dmitry Torokhov @ 2019-01-07 20:00 UTC (permalink / raw)
To: Aditya Pakki; +Cc: kjlu, Michael Hennerich, linux-input, linux-kernel
In-Reply-To: <20190106181727.11815-1-pakki001@umn.edu>
On Sun, Jan 06, 2019 at 12:17:27PM -0600, Aditya Pakki wrote:
> regmap_bulk_read() can return a non zero value on failure. The fix
> checks if the function call succeeded before calling mod_timer. The
> issue was identified by a static analysis tool.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
Applied, thank you.
> ---
> drivers/input/touchscreen/ad7879.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
> index 6fa714c587b4..8c908572c1f2 100644
> --- a/drivers/input/touchscreen/ad7879.c
> +++ b/drivers/input/touchscreen/ad7879.c
> @@ -246,11 +246,14 @@ static void ad7879_timer(struct timer_list *t)
> static irqreturn_t ad7879_irq(int irq, void *handle)
> {
> struct ad7879 *ts = handle;
> + int error;
>
> - regmap_bulk_read(ts->regmap, AD7879_REG_XPLUS,
> - ts->conversion_data, AD7879_NR_SENSE);
> -
> - if (!ad7879_report(ts))
> + error = regmap_bulk_read(ts->regmap, AD7879_REG_XPLUS,
> + ts->conversion_data, AD7879_NR_SENSE);
> + if (error)
> + dev_err_ratelimited(ts->dev, "failed to read %#02x: %d\n",
> + AD7879_REG_XPLUS, error);
> + else if (!ad7879_report(ts))
> mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT);
>
> return IRQ_HANDLED;
> --
> 2.17.1
>
--
Dmitry
^ permalink raw reply
* Re: [PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas
From: Dmitry Torokhov @ 2019-01-07 19:53 UTC (permalink / raw)
To: Paweł Chmiel
Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
xc-racer2, simon
In-Reply-To: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com>
On Mon, Jan 07, 2019 at 07:53:39PM +0100, Paweł Chmiel wrote:
> This patches adds support for Aries (Samsung i9000) and Midas (Samsung S3)
> based devices to TM2 Touchkey driver.
Applied the lot, thank you.
>
> Changes from v2:
> - Change property name from keycodes to linux,keycodes
>
> Changes from v1:
> - Added Reviewed-by to some patches
> - Use ints for keycodes (they could be bigger than 255)
> - Droped separate name changes
> - Added missing const in few places
> - Removed redundant cast
>
> Jonathan Bakker (5):
> Input: tm2-touchkey: Correct initial brightness
> Input: tm2-touchkey: Allow specifying custom keycodes
> Input: dt-bindings: tm2-touchkey: Document new keycodes property
> Input: tm2-touchkey: Add support for aries touchkey variant
> Input: dt-bindings: tm2-touchkey: Add support for aries touchkey
>
> Simon Shields (2):
> Input: tm2-touchkey: Add support for midas touchkey
> Input: dt-bindings: tm2-touchkey: Add support for midas touchkey
>
> .../bindings/input/cypress,tm2-touchkey.txt | 9 +-
> drivers/input/keyboard/tm2-touchkey.c | 132 +++++++++++++-----
> 2 files changed, 108 insertions(+), 33 deletions(-)
>
> --
> 2.17.1
>
--
Dmitry
^ permalink raw reply
* Re: [PATCH] Input: goodix - decouple irq and reset lines
From: Dmitry Torokhov @ 2019-01-07 18:56 UTC (permalink / raw)
To: Gonzalez, Alex
Cc: Bastien Nocera, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org
In-Reply-To: <20190107164225.GA5394@agonzal-linux>
On Mon, Jan 07, 2019 at 04:42:26PM +0000, Gonzalez, Alex wrote:
> Hi Bastien,
>
> >Given that we do have access to the datasheet, it would also be useful
> >for the patch to mention where in the datasheet it says that the reset
> >line can be left pulled-up,
>
> The pin description table on section 4, on the "Reset pin" row, contains a
> remark as follows:
>
> External 10K pull-up resistor required, active-low reset
>
> This comes from a newer revision of the datasheet though:
> http://focuslcds.com/content/GT911.pdf
>
> I guess it's open to interpretation whether driving the reset line is
> optional. The code seemed to imply it by using devm_gpiod_get_optional() to
> obtain the GPIO.
They are optional in the sense that driver should work without them, but
if they specified we need both.
>
> >or mention on which shipping device this
> >setup is already used (and if so, what the DTS or ACPI snippet that
> >declares those is).
> >
>
> I am testing with an LCD application kit for the ConnectCore 6UL SBC Pro:
>
> https://www.digi.com/products/models/cc-acc-lcdw-10
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/imx6ul-ccimx6ulsbcpro.dts?h=v5.0-rc1#n120
>
> This display in particular does not have the reset line available on the
> connector. The only way to make it work seems to be to use the INT line to fix
> an I2C address.
Do you have to use 0x14 address? Can you used the default 0x5d?
My concern with trying to do the address selection without RST line is
that it is quite unreliable, as it really depends on timings between the
chip reset, INT line being driven by the host and then being switched to
input.
Thanks.
--
Dmitry
^ permalink raw reply
* [PATCH v3 7/7] Input: dt-bindings: tm2-touchkey: Add support for aries touchkey
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
To: dmitry.torokhov
Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
pawel.mikolaj.chmiel, xc-racer2, simon
In-Reply-To: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com>
From: Jonathan Bakker <xc-racer2@live.ca>
Document compatible for aries touchkey.
Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
Changes from v1:
- Added Reviewed-by
---
Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
index 8ef1517c0220..ef2ae729718f 100644
--- a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
+++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
@@ -4,6 +4,7 @@ Required properties:
- compatible:
* "cypress,tm2-touchkey" - for the touchkey found on the tm2 board
* "cypress,midas-touchkey" - for the touchkey found on midas boards
+ * "cypress,aries-touchkey" - for the touchkey found on aries boards
- reg: I2C address of the chip.
- interrupts: interrupt to which the chip is connected (see interrupt
binding[0]).
--
2.17.1
^ permalink raw reply related
* [PATCH v3 6/7] Input: tm2-touchkey: Add support for aries touchkey variant
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
To: dmitry.torokhov
Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
pawel.mikolaj.chmiel, xc-racer2, simon
In-Reply-To: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com>
From: Jonathan Bakker <xc-racer2@live.ca>
The touchkey variant found on aries board is slighty different,
it uses a fixed regulator and writes/read to the same place
Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
---
drivers/input/keyboard/tm2-touchkey.c | 53 +++++++++++++++++++++++----
1 file changed, 46 insertions(+), 7 deletions(-)
diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c
index b55faf597d8a..7dbef96559d2 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -28,6 +28,8 @@
#define TM2_TOUCHKEY_DEV_NAME "tm2-touchkey"
+#define ARIES_TOUCHKEY_CMD_LED_ON 0x1
+#define ARIES_TOUCHKEY_CMD_LED_OFF 0x2
#define TM2_TOUCHKEY_CMD_LED_ON 0x10
#define TM2_TOUCHKEY_CMD_LED_OFF 0x20
#define TM2_TOUCHKEY_BIT_PRESS_EV BIT(3)
@@ -38,6 +40,10 @@
struct touchkey_variant {
u8 keycode_reg;
u8 base_reg;
+ u8 cmd_led_on;
+ u8 cmd_led_off;
+ bool no_reg;
+ bool fixed_regulator;
};
struct tm2_touchkey_data {
@@ -54,11 +60,22 @@ struct tm2_touchkey_data {
static const struct touchkey_variant tm2_touchkey_variant = {
.keycode_reg = 0x03,
.base_reg = 0x00,
+ .cmd_led_on = TM2_TOUCHKEY_CMD_LED_ON,
+ .cmd_led_off = TM2_TOUCHKEY_CMD_LED_OFF,
};
static const struct touchkey_variant midas_touchkey_variant = {
.keycode_reg = 0x00,
.base_reg = 0x00,
+ .cmd_led_on = TM2_TOUCHKEY_CMD_LED_ON,
+ .cmd_led_off = TM2_TOUCHKEY_CMD_LED_OFF,
+};
+
+static struct touchkey_variant aries_touchkey_variant = {
+ .no_reg = true,
+ .fixed_regulator = true,
+ .cmd_led_on = ARIES_TOUCHKEY_CMD_LED_ON,
+ .cmd_led_off = ARIES_TOUCHKEY_CMD_LED_OFF,
};
static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
@@ -71,15 +88,20 @@ static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
if (brightness == LED_OFF) {
volt = TM2_TOUCHKEY_LED_VOLTAGE_MIN;
- data = TM2_TOUCHKEY_CMD_LED_OFF;
+ data = touchkey->variant->cmd_led_off;
} else {
volt = TM2_TOUCHKEY_LED_VOLTAGE_MAX;
- data = TM2_TOUCHKEY_CMD_LED_ON;
+ data = touchkey->variant->cmd_led_on;
}
- regulator_set_voltage(touchkey->vdd, volt, volt);
- i2c_smbus_write_byte_data(touchkey->client,
- touchkey->variant->base_reg, data);
+ if (!touchkey->variant->fixed_regulator)
+ regulator_set_voltage(touchkey->vdd, volt, volt);
+
+ if (touchkey->variant->no_reg)
+ i2c_smbus_write_byte(touchkey->client, data);
+ else
+ i2c_smbus_write_byte_data(touchkey->client,
+ touchkey->variant->base_reg, data);
}
static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey)
@@ -112,8 +134,11 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
int index;
int i;
- data = i2c_smbus_read_byte_data(touchkey->client,
- touchkey->variant->keycode_reg);
+ if (touchkey->variant->no_reg)
+ data = i2c_smbus_read_byte(touchkey->client);
+ else
+ data = i2c_smbus_read_byte_data(touchkey->client,
+ touchkey->variant->keycode_reg);
if (data < 0) {
dev_err(&touchkey->client->dev,
"failed to read i2c data: %d\n", data);
@@ -139,6 +164,14 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
input_sync(touchkey->input_dev);
out:
+ if (touchkey->variant->fixed_regulator &&
+ data & TM2_TOUCHKEY_BIT_PRESS_EV) {
+ /* touch turns backlight on, so make sure we're in sync */
+ if (touchkey->led_dev.brightness == LED_OFF)
+ tm2_touchkey_led_brightness_set(&touchkey->led_dev,
+ LED_OFF);
+ }
+
return IRQ_HANDLED;
}
@@ -246,6 +279,9 @@ static int tm2_touchkey_probe(struct i2c_client *client,
return error;
}
+ if (touchkey->variant->fixed_regulator)
+ tm2_touchkey_led_brightness_set(&touchkey->led_dev, LED_ON);
+
return 0;
}
@@ -291,6 +327,9 @@ static const struct of_device_id tm2_touchkey_of_match[] = {
}, {
.compatible = "cypress,midas-touchkey",
.data = &midas_touchkey_variant,
+ }, {
+ .compatible = "cypress,aries-touchkey",
+ .data = &aries_touchkey_variant,
},
{ },
};
--
2.17.1
^ permalink raw reply related
* [PATCH v3 5/7] Input: dt-bindings: tm2-touchkey: Document new keycodes property
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
To: dmitry.torokhov
Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
pawel.mikolaj.chmiel, xc-racer2, simon
In-Reply-To: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com>
From: Jonathan Bakker <xc-racer2@live.ca>
Document new optional property for setting custom keycodes.
Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
---
Changes from v2:
- Change property name from keycodes to linux,keycodes
Changes from v1:
- Because key codes could be bigger than 255, use ints for keycodes
---
.../devicetree/bindings/input/cypress,tm2-touchkey.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
index dfb3b9f0ee40..8ef1517c0220 100644
--- a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
+++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
@@ -10,6 +10,9 @@ Required properties:
- vcc-supply : internal regulator output. 1.8V
- vdd-supply : power supply for IC 3.3V
+Optional properties:
+- linux,keycodes: array of keycodes (max 4), default KEY_PHONE and KEY_BACK
+
[0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
Example:
@@ -23,5 +26,6 @@ Example:
interrupts = <2 IRQ_TYPE_EDGE_FALLING>;
vcc-supply=<&ldo32_reg>;
vdd-supply=<&ldo33_reg>;
+ linux,keycodes = <KEY_PHONE KEY_BACK>;
};
};
--
2.17.1
^ permalink raw reply related
* [PATCH v3 4/7] Input: tm2-touchkey: Allow specifying custom keycodes
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
To: dmitry.torokhov
Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
pawel.mikolaj.chmiel, xc-racer2, simon
In-Reply-To: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com>
From: Jonathan Bakker <xc-racer2@live.ca>
Not all devices use the same keycodes in the same order,
so add possibility to define keycodes for buttons present
on actual hardware.
If keycodes property is not present, we assume that device has
at least MENU and BACK keys.
Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
---
Changes from v2:
- Change property name from keycodes to linux,keycodes
Changes from v1:
- Because key codes could be bigger than 255, use ints for keycodes
---
drivers/input/keyboard/tm2-touchkey.c | 49 +++++++++++++++------------
1 file changed, 27 insertions(+), 22 deletions(-)
diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c
index 0336789ab1bb..b55faf597d8a 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -35,11 +35,6 @@
#define TM2_TOUCHKEY_LED_VOLTAGE_MIN 2500000
#define TM2_TOUCHKEY_LED_VOLTAGE_MAX 3300000
-enum {
- TM2_TOUCHKEY_KEY_MENU = 0x1,
- TM2_TOUCHKEY_KEY_BACK,
-};
-
struct touchkey_variant {
u8 keycode_reg;
u8 base_reg;
@@ -52,6 +47,8 @@ struct tm2_touchkey_data {
struct regulator *vdd;
struct regulator_bulk_data regulators[2];
const struct touchkey_variant *variant;
+ u32 keycodes[4];
+ int num_keycodes;
};
static const struct touchkey_variant tm2_touchkey_variant = {
@@ -112,7 +109,8 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
{
struct tm2_touchkey_data *touchkey = devid;
int data;
- int key;
+ int index;
+ int i;
data = i2c_smbus_read_byte_data(touchkey->client,
touchkey->variant->keycode_reg);
@@ -122,26 +120,20 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
goto out;
}
- switch (data & TM2_TOUCHKEY_BIT_KEYCODE) {
- case TM2_TOUCHKEY_KEY_MENU:
- key = KEY_PHONE;
- break;
-
- case TM2_TOUCHKEY_KEY_BACK:
- key = KEY_BACK;
- break;
-
- default:
+ index = (data & TM2_TOUCHKEY_BIT_KEYCODE) - 1;
+ if (index < 0 || index >= touchkey->num_keycodes) {
dev_warn(&touchkey->client->dev,
- "unhandled keycode, data %#02x\n", data);
+ "invalid keycode index %d\n", index);
goto out;
}
if (data & TM2_TOUCHKEY_BIT_PRESS_EV) {
- input_report_key(touchkey->input_dev, KEY_PHONE, 0);
- input_report_key(touchkey->input_dev, KEY_BACK, 0);
+ for (i = 0; i < touchkey->num_keycodes; i++)
+ input_report_key(touchkey->input_dev,
+ touchkey->keycodes[i], 0);
} else {
- input_report_key(touchkey->input_dev, key, 1);
+ input_report_key(touchkey->input_dev,
+ touchkey->keycodes[index], 1);
}
input_sync(touchkey->input_dev);
@@ -153,8 +145,10 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
static int tm2_touchkey_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
+ struct device_node *np = client->dev.of_node;
struct tm2_touchkey_data *touchkey;
int error;
+ int i;
if (!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA)) {
@@ -184,6 +178,16 @@ static int tm2_touchkey_probe(struct i2c_client *client,
/* Save VDD for easy access */
touchkey->vdd = touchkey->regulators[1].consumer;
+ touchkey->num_keycodes = of_property_read_variable_u32_array(np,
+ "linux,keycodes", touchkey->keycodes, 0,
+ ARRAY_SIZE(touchkey->keycodes));
+ if (touchkey->num_keycodes <= 0) {
+ /* default keycodes */
+ touchkey->keycodes[0] = KEY_PHONE;
+ touchkey->keycodes[1] = KEY_BACK;
+ touchkey->num_keycodes = 2;
+ }
+
error = tm2_touchkey_power_enable(touchkey);
if (error) {
dev_err(&client->dev, "failed to power up device: %d\n", error);
@@ -208,8 +212,9 @@ static int tm2_touchkey_probe(struct i2c_client *client,
touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME;
touchkey->input_dev->id.bustype = BUS_I2C;
- input_set_capability(touchkey->input_dev, EV_KEY, KEY_PHONE);
- input_set_capability(touchkey->input_dev, EV_KEY, KEY_BACK);
+ for (i = 0; i < touchkey->num_keycodes; i++)
+ input_set_capability(touchkey->input_dev, EV_KEY,
+ touchkey->keycodes[i]);
error = input_register_device(touchkey->input_dev);
if (error) {
--
2.17.1
^ permalink raw reply related
* [PATCH v3 3/7] Input: tm2-touchkey: Correct initial brightness
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
To: dmitry.torokhov
Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
pawel.mikolaj.chmiel, xc-racer2, simon
In-Reply-To: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com>
From: Jonathan Bakker <xc-racer2@live.ca>
Tm2-touchkey don't have brightness levels, but only on/off states,
so replace LED_FULL with LED_ON.
Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
---
drivers/input/keyboard/tm2-touchkey.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c
index 5a1fe08bdd76..0336789ab1bb 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -230,7 +230,7 @@ static int tm2_touchkey_probe(struct i2c_client *client,
/* led device */
touchkey->led_dev.name = TM2_TOUCHKEY_DEV_NAME;
- touchkey->led_dev.brightness = LED_FULL;
+ touchkey->led_dev.brightness = LED_ON;
touchkey->led_dev.max_brightness = LED_ON;
touchkey->led_dev.brightness_set = tm2_touchkey_led_brightness_set;
--
2.17.1
^ permalink raw reply related
* [PATCH v3 2/7] Input: dt-bindings: tm2-touchkey: Add support for midas touchkey
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
To: dmitry.torokhov
Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
pawel.mikolaj.chmiel, xc-racer2, simon
In-Reply-To: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com>
From: Simon Shields <simon@lineageos.org>
Document compatible for midas touchkey.
Signed-off-by: Simon Shields <simon@lineageos.org>
Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
Changes from v1:
- Added Reviewed-by
---
.../devicetree/bindings/input/cypress,tm2-touchkey.txt | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
index 0c252d9306da..dfb3b9f0ee40 100644
--- a/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
+++ b/Documentation/devicetree/bindings/input/cypress,tm2-touchkey.txt
@@ -1,7 +1,9 @@
Samsung tm2-touchkey
Required properties:
-- compatible: must be "cypress,tm2-touchkey"
+- compatible:
+ * "cypress,tm2-touchkey" - for the touchkey found on the tm2 board
+ * "cypress,midas-touchkey" - for the touchkey found on midas boards
- reg: I2C address of the chip.
- interrupts: interrupt to which the chip is connected (see interrupt
binding[0]).
--
2.17.1
^ permalink raw reply related
* [PATCH v3 1/7] Input: tm2-touchkey: Add support for midas touchkey
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
To: dmitry.torokhov
Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
pawel.mikolaj.chmiel, xc-racer2, simon
In-Reply-To: <20190107185346.30184-1-pawel.mikolaj.chmiel@gmail.com>
From: Simon Shields <simon@lineageos.org>
The touchkey on midas boards is almost identical.
The only real difference is that it uses the same register for both
keycode and base.
Signed-off-by: Simon Shields <simon@lineageos.org>
Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
---
Changes from v1:
- Droped separate name changes
- Added missing const in few places
- Removed redundant cast
---
drivers/input/keyboard/tm2-touchkey.c | 34 +++++++++++++++++++++++----
1 file changed, 29 insertions(+), 5 deletions(-)
diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c
index abc266e40e17..5a1fe08bdd76 100644
--- a/drivers/input/keyboard/tm2-touchkey.c
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -22,12 +22,12 @@
#include <linux/leds.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/pm.h>
#include <linux/regulator/consumer.h>
#define TM2_TOUCHKEY_DEV_NAME "tm2-touchkey"
-#define TM2_TOUCHKEY_KEYCODE_REG 0x03
-#define TM2_TOUCHKEY_BASE_REG 0x00
+
#define TM2_TOUCHKEY_CMD_LED_ON 0x10
#define TM2_TOUCHKEY_CMD_LED_OFF 0x20
#define TM2_TOUCHKEY_BIT_PRESS_EV BIT(3)
@@ -40,12 +40,28 @@ enum {
TM2_TOUCHKEY_KEY_BACK,
};
+struct touchkey_variant {
+ u8 keycode_reg;
+ u8 base_reg;
+};
+
struct tm2_touchkey_data {
struct i2c_client *client;
struct input_dev *input_dev;
struct led_classdev led_dev;
struct regulator *vdd;
struct regulator_bulk_data regulators[2];
+ const struct touchkey_variant *variant;
+};
+
+static const struct touchkey_variant tm2_touchkey_variant = {
+ .keycode_reg = 0x03,
+ .base_reg = 0x00,
+};
+
+static const struct touchkey_variant midas_touchkey_variant = {
+ .keycode_reg = 0x00,
+ .base_reg = 0x00,
};
static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
@@ -66,7 +82,7 @@ static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
regulator_set_voltage(touchkey->vdd, volt, volt);
i2c_smbus_write_byte_data(touchkey->client,
- TM2_TOUCHKEY_BASE_REG, data);
+ touchkey->variant->base_reg, data);
}
static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey)
@@ -99,7 +115,7 @@ static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
int key;
data = i2c_smbus_read_byte_data(touchkey->client,
- TM2_TOUCHKEY_KEYCODE_REG);
+ touchkey->variant->keycode_reg);
if (data < 0) {
dev_err(&touchkey->client->dev,
"failed to read i2c data: %d\n", data);
@@ -153,6 +169,8 @@ static int tm2_touchkey_probe(struct i2c_client *client,
touchkey->client = client;
i2c_set_clientdata(client, touchkey);
+ touchkey->variant = of_device_get_match_data(&client->dev);
+
touchkey->regulators[0].supply = "vcc";
touchkey->regulators[1].supply = "vdd";
error = devm_regulator_bulk_get(&client->dev,
@@ -262,7 +280,13 @@ static const struct i2c_device_id tm2_touchkey_id_table[] = {
MODULE_DEVICE_TABLE(i2c, tm2_touchkey_id_table);
static const struct of_device_id tm2_touchkey_of_match[] = {
- { .compatible = "cypress,tm2-touchkey", },
+ {
+ .compatible = "cypress,tm2-touchkey",
+ .data = &tm2_touchkey_variant,
+ }, {
+ .compatible = "cypress,midas-touchkey",
+ .data = &midas_touchkey_variant,
+ },
{ },
};
MODULE_DEVICE_TABLE(of, tm2_touchkey_of_match);
--
2.17.1
^ permalink raw reply related
* [PATCH v3 0/7] Input: tm2-touchkey: Add support for Aries and Midas
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
To: dmitry.torokhov
Cc: robh+dt, mark.rutland, devicetree, linux-input, linux-kernel,
pawel.mikolaj.chmiel, xc-racer2, simon
This patches adds support for Aries (Samsung i9000) and Midas (Samsung S3)
based devices to TM2 Touchkey driver.
Changes from v2:
- Change property name from keycodes to linux,keycodes
Changes from v1:
- Added Reviewed-by to some patches
- Use ints for keycodes (they could be bigger than 255)
- Droped separate name changes
- Added missing const in few places
- Removed redundant cast
Jonathan Bakker (5):
Input: tm2-touchkey: Correct initial brightness
Input: tm2-touchkey: Allow specifying custom keycodes
Input: dt-bindings: tm2-touchkey: Document new keycodes property
Input: tm2-touchkey: Add support for aries touchkey variant
Input: dt-bindings: tm2-touchkey: Add support for aries touchkey
Simon Shields (2):
Input: tm2-touchkey: Add support for midas touchkey
Input: dt-bindings: tm2-touchkey: Add support for midas touchkey
.../bindings/input/cypress,tm2-touchkey.txt | 9 +-
drivers/input/keyboard/tm2-touchkey.c | 132 +++++++++++++-----
2 files changed, 108 insertions(+), 33 deletions(-)
--
2.17.1
^ permalink raw reply
* Re: [PATCH v2 5/7] Input: dt-bindings: tm2-touchkey: Document new keycodes property
From: Paweł Chmiel @ 2019-01-07 18:53 UTC (permalink / raw)
To: Rob Herring
Cc: Dmitry Torokhov, Mark Rutland, DTML, linux-input@vger.kernel.org,
lkml, xc-racer2, Simon Shields
In-Reply-To: <CAL_JsqLoyQDzyhFvXn=DEucdh-9uwvrcXBK38izeGPdQsuv=Zw@mail.gmail.com>
Dnia czwartek, 3 stycznia 2019 19:27:39 CET Rob Herring pisze:
> On Fri, Dec 28, 2018 at 4:52 PM Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> >
> > On Fri, Dec 28, 2018 at 2:47 PM Rob Herring <robh@kernel.org> wrote:
> > >
> > > On Fri, 28 Dec 2018 16:46:07 +0100, =?UTF-8?q?Pawe=C5=82=20Chmiel?= wrote:
> > > > From: Jonathan Bakker <xc-racer2@live.ca>
> > > >
> > > > Document new optional property for setting custom keycodes.
> > > >
> > > > Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
> > > > Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
> > > > ---
> > > > Changes from v1:
> > > > - Because key codes could be bigger than 255, use ints for keycodes
> > > > ---
> > > > .../devicetree/bindings/input/cypress,tm2-touchkey.txt | 4 ++++
> > > > 1 file changed, 4 insertions(+)
> > > >
> > >
> > > Reviewed-by: Rob Herring <robh@kernel.org>
> >
> > Shouldn't this be "linux,keycodes" though?
>
> Sigh, yes.
>
> Rob
I'll send v3 version with this property name fixed (both in documentation and in driver).
Thanks
^ permalink raw reply
* Re: [PATCH] Input: goodix - decouple irq and reset lines
From: Gonzalez, Alex @ 2019-01-07 16:44 UTC (permalink / raw)
To: Bastien Nocera
Cc: Dmitry Torokhov, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org
In-Reply-To: <5dfd17505a7c2f650f1102a8c0d7008ca8dc0b1f.camel@hadess.net>
>
>If it doesn't work with the vendor code, then we might not want to make
>it work with our driver either.
>
Thanks Bastien. The vendor code does seem to require both INT and RESET gpios.
^ permalink raw reply
* [PATCH V2 2/2] Input: rotaty-encoder - Add DT binding document
From: Donghoon Han @ 2019-01-07 16:42 UTC (permalink / raw)
To: linux-input; +Cc: Dmitry Torokhov, Daniel Mack, linux-kernel, devicetree
In-Reply-To: <20190107164249.2342-1-nazgul33@gmail.com>
Add DT binding document for rotary-encoder, keycode options.
Signed-off-by: Donghoon Han <nazgul33@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Daniel Mack <daniel@caiaq.de>
Cc: devicetree@vger.kernel.org
To: linux-input@vger.kernel.org
---
.../devicetree/bindings/input/rotary-encoder.txt | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/Documentation/devicetree/bindings/input/rotary-encoder.txt b/Documentation/devicetree/bindings/input/rotary-encoder.txt
index f99fe5cdeaec..9986ec2af2d4 100644
--- a/Documentation/devicetree/bindings/input/rotary-encoder.txt
+++ b/Documentation/devicetree/bindings/input/rotary-encoder.txt
@@ -12,6 +12,10 @@ Optional properties:
- rotary-encoder,relative-axis: register a relative axis rather than an
absolute one. Relative axis will only generate +1/-1 events on the input
device, hence no steps need to be passed.
+- rotary-encoder,relative-keys : generate pair of key events. This setting
+ behaves just like relative-axis, generating key events instead.
+ (Keycodes[2] corresponds to -1/1 events.)
+- rotary-encoder,relative-keycodes : keycodes for relative-keys
- rotary-encoder,rollover: Automatic rollover when the rotary value becomes
greater than the specified steps or smaller than 0. For absolute axis only.
- rotary-encoder,steps-per-period: Number of steps (stable states) per period.
@@ -48,3 +52,11 @@ Example:
rotary-encoder,encoding = "binary";
rotary-encoder,rollover;
};
+
+ rotary@2 {
+ compatible = "rotary-encoder";
+ gpios = <&gpio 21 0>, <&gpio 22 0>;
+ rotary-encoder,relative-keys;
+ rotary-encoder,relative-keycode = <103>, <108>;
+ rotary-encoder,steps-per-period = <2>;
+ };
--
2.17.1
^ permalink raw reply related
* [PATCH V2 1/2] Input: rotary_encoder - Support key events
From: Donghoon Han @ 2019-01-07 16:42 UTC (permalink / raw)
To: linux-input; +Cc: Dmitry Torokhov, Daniel Mack, linux-kernel, Steven Han
In-Reply-To: <20190107164249.2342-1-nazgul33@gmail.com>
From: Steven Han <nazgul33@gmail.com>
Support generating EV_KEY pair, instead of EV_REL.
Signed-off-by: Donghoon Han <nazgul33@gmail.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Daniel Mack <daniel@caiaq.de>
To: linux-input@vger.kernel.org
---
V2: added missing input_sync()
---
drivers/input/misc/rotary_encoder.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c
index 72eee6d55527..0014a7d9f8f9 100644
--- a/drivers/input/misc/rotary_encoder.c
+++ b/drivers/input/misc/rotary_encoder.c
@@ -41,6 +41,8 @@ struct rotary_encoder {
u32 steps;
u32 axis;
bool relative_axis;
+ bool relative_keys;
+ u32 keycodes[2];
bool rollover;
enum rotary_encoder_encoding encoding;
@@ -79,6 +81,11 @@ static void rotary_encoder_report_event(struct rotary_encoder *encoder)
if (encoder->relative_axis) {
input_report_rel(encoder->input,
encoder->axis, encoder->dir);
+ } else if (encoder->relative_keys) {
+ u32 keycode = encoder->keycodes[encoder->dir > 0];
+ input_event(encoder->input, EV_KEY, keycode, 1);
+ input_sync(encoder->input);
+ input_event(encoder->input, EV_KEY, keycode, 0);
} else {
unsigned int pos = encoder->pos;
@@ -237,6 +244,16 @@ static int rotary_encoder_probe(struct platform_device *pdev)
device_property_read_u32(dev, "linux,axis", &encoder->axis);
encoder->relative_axis =
device_property_read_bool(dev, "rotary-encoder,relative-axis");
+ encoder->relative_keys =
+ device_property_read_bool(dev, "rotary-encoder,relative-keys");
+ if (encoder->relative_keys) {
+ err = device_property_read_u32_array(dev,
+ "rotary-encoder,relative-keycodes",
+ encoder->keycodes, 2);
+ if (err)
+ dev_err(dev, "unable to get keycodes: %d\n", err);
+ return err;
+ }
encoder->gpios = devm_gpiod_get_array(dev, NULL, GPIOD_IN);
if (IS_ERR(encoder->gpios)) {
@@ -260,9 +277,12 @@ static int rotary_encoder_probe(struct platform_device *pdev)
input->id.bustype = BUS_HOST;
input->dev.parent = dev;
- if (encoder->relative_axis)
+ if (encoder->relative_axis) {
input_set_capability(input, EV_REL, encoder->axis);
- else
+ } else if (encoder->relative_keys) {
+ input_set_capability(input, EV_KEY, encoder->keycodes[0]);
+ input_set_capability(input, EV_KEY, encoder->keycodes[1]);
+ } else
input_set_abs_params(input,
encoder->axis, 0, encoder->steps, 0, 1);
--
2.17.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox