* [PATCH v1] HID: intel-ish-hid: Switch to use new generic UUID API
From: Andy Shevchenko @ 2019-01-10 15:48 UTC (permalink / raw)
To: Srinivas Pandruvada, linux-input, Even Xu, linux-kernel,
Christoph Hellwig
Cc: Andy Shevchenko
There are new types and helpers that are supposed to be used in new code.
As a preparation to get rid of legacy types and API functions do
the conversion here.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/hid/intel-ish-hid/ishtp-hid-client.c | 3 +--
drivers/hid/intel-ish-hid/ishtp-hid.h | 6 +++---
drivers/hid/intel-ish-hid/ishtp/bus.c | 19 ++++++++-----------
drivers/hid/intel-ish-hid/ishtp/bus.h | 4 ++--
drivers/hid/intel-ish-hid/ishtp/client.h | 2 +-
drivers/hid/intel-ish-hid/ishtp/hbm.h | 2 +-
6 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/drivers/hid/intel-ish-hid/ishtp-hid-client.c b/drivers/hid/intel-ish-hid/ishtp-hid-client.c
index e64243bc9c96..2246697ada1d 100644
--- a/drivers/hid/intel-ish-hid/ishtp-hid-client.c
+++ b/drivers/hid/intel-ish-hid/ishtp-hid-client.c
@@ -788,8 +788,7 @@ static int hid_ishtp_cl_probe(struct ishtp_cl_device *cl_device)
if (!cl_device)
return -ENODEV;
- if (uuid_le_cmp(hid_ishtp_guid,
- cl_device->fw_client->props.protocol_name) != 0)
+ if (!guid_equal(&hid_ishtp_guid, &cl_device->fw_client->props.protocol_name))
return -ENODEV;
client_data = devm_kzalloc(&cl_device->dev, sizeof(*client_data),
diff --git a/drivers/hid/intel-ish-hid/ishtp-hid.h b/drivers/hid/intel-ish-hid/ishtp-hid.h
index f5c7eb79b7b5..1cd07a441cd4 100644
--- a/drivers/hid/intel-ish-hid/ishtp-hid.h
+++ b/drivers/hid/intel-ish-hid/ishtp-hid.h
@@ -29,9 +29,9 @@
client->cl_device->ishtp_dev, __VA_ARGS__)
/* ISH Transport protocol (ISHTP in short) GUID */
-static const uuid_le hid_ishtp_guid = UUID_LE(0x33AECD58, 0xB679, 0x4E54,
- 0x9B, 0xD9, 0xA0, 0x4D, 0x34,
- 0xF0, 0xC2, 0x26);
+static const guid_t hid_ishtp_guid =
+ GUID_INIT(0x33AECD58, 0xB679, 0x4E54,
+ 0x9B, 0xD9, 0xA0, 0x4D, 0x34, 0xF0, 0xC2, 0x26);
/* ISH HID message structure */
struct hostif_msg_hdr {
diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c b/drivers/hid/intel-ish-hid/ishtp/bus.c
index 728dc6d4561a..1b6092b300fe 100644
--- a/drivers/hid/intel-ish-hid/ishtp/bus.c
+++ b/drivers/hid/intel-ish-hid/ishtp/bus.c
@@ -133,18 +133,15 @@ int ishtp_write_message(struct ishtp_device *dev, struct ishtp_msg_hdr *hdr,
*
* Return: fw client index or -ENOENT if not found
*/
-int ishtp_fw_cl_by_uuid(struct ishtp_device *dev, const uuid_le *uuid)
+int ishtp_fw_cl_by_uuid(struct ishtp_device *dev, const guid_t *uuid)
{
- int i, res = -ENOENT;
+ unsigned int i;
for (i = 0; i < dev->fw_clients_num; ++i) {
- if (uuid_le_cmp(*uuid, dev->fw_clients[i].props.protocol_name)
- == 0) {
- res = i;
- break;
- }
+ if (guid_equal(uuid, &dev->fw_clients[i].props.protocol_name))
+ return i;
}
- return res;
+ return -ENOENT;
}
EXPORT_SYMBOL(ishtp_fw_cl_by_uuid);
@@ -158,7 +155,7 @@ EXPORT_SYMBOL(ishtp_fw_cl_by_uuid);
* Return: pointer of client information on success, NULL on failure.
*/
struct ishtp_fw_client *ishtp_fw_cl_get_client(struct ishtp_device *dev,
- const uuid_le *uuid)
+ const guid_t *uuid)
{
int i;
unsigned long flags;
@@ -401,7 +398,7 @@ static const struct device_type ishtp_cl_device_type = {
* Return: ishtp_cl_device pointer or NULL on failure
*/
static struct ishtp_cl_device *ishtp_bus_add_device(struct ishtp_device *dev,
- uuid_le uuid, char *name)
+ guid_t uuid, char *name)
{
struct ishtp_cl_device *device;
int status;
@@ -629,7 +626,7 @@ int ishtp_bus_new_client(struct ishtp_device *dev)
int i;
char *dev_name;
struct ishtp_cl_device *cl_device;
- uuid_le device_uuid;
+ guid_t device_uuid;
/*
* For all reported clients, create an unconnected client and add its
diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.h b/drivers/hid/intel-ish-hid/ishtp/bus.h
index b8a5bcc82536..babf19ba3ff6 100644
--- a/drivers/hid/intel-ish-hid/ishtp/bus.h
+++ b/drivers/hid/intel-ish-hid/ishtp/bus.h
@@ -112,8 +112,8 @@ void ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver);
int ishtp_register_event_cb(struct ishtp_cl_device *device,
void (*read_cb)(struct ishtp_cl_device *));
-int ishtp_fw_cl_by_uuid(struct ishtp_device *dev, const uuid_le *cuuid);
+int ishtp_fw_cl_by_uuid(struct ishtp_device *dev, const guid_t *cuuid);
struct ishtp_fw_client *ishtp_fw_cl_get_client(struct ishtp_device *dev,
- const uuid_le *uuid);
+ const guid_t *uuid);
#endif /* _LINUX_ISHTP_CL_BUS_H */
diff --git a/drivers/hid/intel-ish-hid/ishtp/client.h b/drivers/hid/intel-ish-hid/ishtp/client.h
index 042f4c4853b1..e0df3eb611e6 100644
--- a/drivers/hid/intel-ish-hid/ishtp/client.h
+++ b/drivers/hid/intel-ish-hid/ishtp/client.h
@@ -126,7 +126,7 @@ struct ishtp_cl {
};
/* Client connection managenment internal functions */
-int ishtp_can_client_connect(struct ishtp_device *ishtp_dev, uuid_le *uuid);
+int ishtp_can_client_connect(struct ishtp_device *ishtp_dev, guid_t *uuid);
int ishtp_fw_cl_by_id(struct ishtp_device *dev, uint8_t client_id);
void ishtp_cl_send_msg(struct ishtp_device *dev, struct ishtp_cl *cl);
void recv_ishtp_cl_msg(struct ishtp_device *dev,
diff --git a/drivers/hid/intel-ish-hid/ishtp/hbm.h b/drivers/hid/intel-ish-hid/ishtp/hbm.h
index d96111cef7f8..7286e3600140 100644
--- a/drivers/hid/intel-ish-hid/ishtp/hbm.h
+++ b/drivers/hid/intel-ish-hid/ishtp/hbm.h
@@ -149,7 +149,7 @@ struct hbm_host_enum_response {
} __packed;
struct ishtp_client_properties {
- uuid_le protocol_name;
+ guid_t protocol_name;
uint8_t protocol_version;
uint8_t max_number_of_connections;
uint8_t fixed_address;
--
2.20.1
^ permalink raw reply related
* Re: [PATCH v6 1/8] dt-bindings: stmpe: reformatting parameter list and use tabs only
From: Linus Walleij @ 2019-01-10 9:50 UTC (permalink / raw)
To: Philippe Schenker
Cc: Jonathan Cameron, Marcel Ziswiler, Stefan Agner, Rob Herring,
Alexandre TORGUE, Shawn Guo, Dmitry Torokhov,
thierry.reding@gmail.com, Maxime Coquelin, Dmitry Osipenko,
Lee Jones, Philippe Schenker,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
Max Krummenacher, Jonathan Cameron, Linux Input,
linux-kernel@vger.kernel.org
In-Reply-To: <20190109134208.5660-2-dev@pschenker.ch>
On Wed, Jan 9, 2019 at 2:43 PM Philippe Schenker <dev@pschenker.ch> wrote:
> From: Philippe Schenker <philippe.schenker@toradex.com>
>
> This patch reformats the parameter list for stmpe device in a
> table-style so it is more clear to read.
>
> Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
> Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
> Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply
* [PATCH v6 6/8] iio: adc: add STMPE ADC devicetree bindings
From: Philippe Schenker @ 2019-01-09 13:42 UTC (permalink / raw)
To: jic23, marcel.ziswiler, stefan
Cc: robh, alexandre.torgue, shawnguo, dmitry.torokhov, thierry.reding,
mcoquelin.stm32, digetx, lee.jones, Max Krummenacher,
Philippe Schenker, Jonathan Cameron, devicetree, linux-iio,
Hartmut Knaack, linux-input, linux-kernel, Rob Herring,
Mark Rutland, Peter Meerwald-Stadler, linux-stm32,
linux-arm-kernel, Lars-Peter Clausen
In-Reply-To: <20190109134208.5660-1-dev@pschenker.ch>
From: Stefan Agner <stefan@agner.ch>
This adds the devicetree bindings for the STMPE ADC. This also corrects
a typo in st,sample-time it is rather "6 -> 124 clocks" according
to the datasheet and not 144.
We need to use the naming stmpe_adc in devicetree because this is given
by the mfd device.
Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
Changes in v6:
- Added Rob's Reviewed-by
Changes in v5:
- 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:
- Put reformatting in a separate precursor patch.
Changes in v3:
- 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.
Changes in v2:
- Moved the bindings for ADC to the overlying mfd.
- Reformatted for better readability
.../devicetree/bindings/iio/adc/stmpe-adc.txt | 21 +++++
.../bindings/input/touchscreen/stmpe.txt | 88 +++++++++++++------
.../devicetree/bindings/mfd/stmpe.txt | 14 +++
3 files changed, 98 insertions(+), 25 deletions(-)
create mode 100644 Documentation/devicetree/bindings/iio/adc/stmpe-adc.txt
diff --git a/Documentation/devicetree/bindings/iio/adc/stmpe-adc.txt b/Documentation/devicetree/bindings/iio/adc/stmpe-adc.txt
new file mode 100644
index 000000000000..480e66422625
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/stmpe-adc.txt
@@ -0,0 +1,21 @@
+STMPE ADC driver
+----------------
+
+Required properties:
+ - compatible: "st,stmpe-adc"
+
+Optional properties:
+Note that the ADC is shared with the STMPE touchscreen. ADC related settings
+have to be done in the mfd.
+- st,norequest-mask: bitmask specifying which ADC channels should _not_ be
+ requestable due to different usage (e.g. touch)
+
+Node name must be stmpe_adc and should be child node of stmpe node to
+which it belongs.
+
+Example:
+
+ stmpe_adc {
+ compatible = "st,stmpe-adc";
+ st,norequest-mask = <0x0F>; /* dont use ADC CH3-0 */
+ };
diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
index bf66a55a7de5..c549924603d2 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
@@ -5,24 +5,6 @@ Required properties:
- compatible: "st,stmpe-ts"
Optional properties:
-- st,sample-time : ADC conversion time in number of clock.
- 0 -> 36 clocks
- 1 -> 44 clocks
- 2 -> 56 clocks
- 3 -> 64 clocks
- 4 -> 80 clocks (recommended)
- 5 -> 96 clocks
- 6 -> 144 clocks
-- st,mod-12b : ADC Bit mode
- 0 -> 10bit ADC
- 1 -> 12bit ADC
-- st,ref-sel : ADC reference source
- 0 -> internal
- 1 -> external
-- st,adc-freq : ADC Clock speed
- 0 -> 1.625 MHz
- 1 -> 3.25 MHz
- 2 || 3 -> 6.5 MHz
- st,ave-ctrl : Sample average control
0 -> 1 sample
1 -> 2 samples
@@ -52,20 +34,76 @@ Optional properties:
0 -> 20 mA (typical 35mA max)
1 -> 50 mA (typical 80 mA max)
+Optional properties common with MFD (deprecated):
+ - st,sample-time : ADC conversion time in number of clock.
+ 0 -> 36 clocks
+ 1 -> 44 clocks
+ 2 -> 56 clocks
+ 3 -> 64 clocks
+ 4 -> 80 clocks (recommended)
+ 5 -> 96 clocks
+ 6 -> 124 clocks
+ - st,mod-12b : ADC Bit mode
+ 0 -> 10bit ADC
+ 1 -> 12bit ADC
+ - st,ref-sel : ADC reference source
+ 0 -> internal
+ 1 -> external
+ - st,adc-freq : ADC Clock speed
+ 0 -> 1.625 MHz
+ 1 -> 3.25 MHz
+ 2 || 3 -> 6.5 MHz
+
Node name must be stmpe_touchscreen and should be child node of stmpe node to
which it belongs.
+Note that common ADC settings of stmpe_touchscreen (child) will take precedence
+over the settings done in MFD.
+
Example:
+stmpe811@41 {
+ compatible = "st,stmpe811";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_touch_int>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0x41>;
+ interrupts = <10 IRQ_TYPE_LEVEL_LOW>;
+ interrupt-parent = <&gpio4>;
+ interrupt-controller;
+ id = <0>;
+ blocks = <0x5>;
+ irq-trigger = <0x1>;
+ /* Common ADC settings */
+ /* 3.25 MHz ADC clock speed */
+ st,adc-freq = <1>;
+ /* 12-bit ADC */
+ st,mod-12b = <1>;
+ /* internal ADC reference */
+ st,ref-sel = <0>;
+ /* ADC converstion time: 80 clocks */
+ st,sample-time = <4>;
+
stmpe_touchscreen {
compatible = "st,stmpe-ts";
- st,sample-time = <4>;
- st,mod-12b = <1>;
- st,ref-sel = <0>;
- st,adc-freq = <1>;
- st,ave-ctrl = <1>;
- st,touch-det-delay = <2>;
- st,settling = <2>;
+ reg = <0>;
+ /* 8 sample average control */
+ st,ave-ctrl = <3>;
+ /* 5 ms touch detect interrupt delay */
+ st,touch-det-delay = <5>;
+ /* 1 ms panel driver settling time */
+ st,settling = <3>;
+ /* 7 length fractional part in z */
st,fraction-z = <7>;
+ /*
+ * 50 mA typical 80 mA max touchscreen drivers
+ * current limit value
+ */
st,i-drive = <1>;
};
+ stmpe_adc {
+ compatible = "st,stmpe-adc";
+ st,norequest-mask = <0x0F>;
+ };
+};
diff --git a/Documentation/devicetree/bindings/mfd/stmpe.txt b/Documentation/devicetree/bindings/mfd/stmpe.txt
index a46e7177195d..d4408a417193 100644
--- a/Documentation/devicetree/bindings/mfd/stmpe.txt
+++ b/Documentation/devicetree/bindings/mfd/stmpe.txt
@@ -14,6 +14,20 @@ Optional properties:
- st,autosleep-timeout : Valid entries (ms); 4, 16, 32, 64, 128, 256, 512 and 1024
- irq-gpio : If present, which GPIO to use for event IRQ
+Optional properties for devices with touch and ADC (STMPE811|STMPE610):
+ - st,sample-time : ADC conversion time in number of clock.
+ 0 -> 36 clocks 4 -> 80 clocks (recommended)
+ 1 -> 44 clocks 5 -> 96 clocks
+ 2 -> 56 clocks 6 -> 124 clocks
+ 3 -> 64 clocks
+ - st,mod-12b : ADC Bit mode
+ 0 -> 10bit ADC 1 -> 12bit ADC
+ - st,ref-sel : ADC reference source
+ 0 -> internal 1 -> external
+ - st,adc-freq : ADC Clock speed
+ 0 -> 1.625 MHz 2 || 3 -> 6.5 MHz
+ 1 -> 3.25 MHz
+
Example:
stmpe1601: stmpe1601@40 {
--
2.20.1
^ permalink raw reply related
* [PATCH v6 4/8] Input: stmpe-ts: preparations for STMPE ADC driver
From: Philippe Schenker @ 2019-01-09 13:42 UTC (permalink / raw)
To: jic23, marcel.ziswiler, stefan
Cc: robh, alexandre.torgue, lee.jones, dmitry.torokhov, linux-kernel,
Philippe Schenker, thierry.reding, mcoquelin.stm32, linux-input,
digetx, shawnguo, linux-stm32, linux-arm-kernel
In-Reply-To: <20190109134208.5660-1-dev@pschenker.ch>
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 v6:
- Added Dmitry's ack
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.20.1
^ permalink raw reply related
* [PATCH v6 2/8] mfd: stmpe: Move ADC related defines to header of mfd
From: Philippe Schenker @ 2019-01-09 13:42 UTC (permalink / raw)
To: jic23, marcel.ziswiler, stefan
Cc: robh, alexandre.torgue, shawnguo, dmitry.torokhov, thierry.reding,
mcoquelin.stm32, digetx, lee.jones, Philippe Schenker,
linux-kernel, linux-input, linux-stm32, linux-arm-kernel
In-Reply-To: <20190109134208.5660-1-dev@pschenker.ch>
From: Philippe Schenker <philippe.schenker@toradex.com>
Move defines that are ADC related to the header of the overlying mfd,
so they can be used from multiple sub-devices.
Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Changes in v6: None
Changes in v5:
- Changed author of commit to use correct email
Changes in v4:
- Added Lee Jone's Ack
- Added Dmitry Torokhov's Ack
Changes in v3: 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_
drivers/input/touchscreen/stmpe-ts.c | 34 +++++++++++-----------------
include/linux/mfd/stmpe.h | 11 +++++++++
2 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
index 2a78e27b4495..c5d9006588a2 100644
--- a/drivers/input/touchscreen/stmpe-ts.c
+++ b/drivers/input/touchscreen/stmpe-ts.c
@@ -49,17 +49,6 @@
#define STMPE_IRQ_TOUCH_DET 0
-#define SAMPLE_TIME(x) ((x & 0xf) << 4)
-#define MOD_12B(x) ((x & 0x1) << 3)
-#define REF_SEL(x) ((x & 0x1) << 1)
-#define ADC_FREQ(x) (x & 0x3)
-#define AVE_CTRL(x) ((x & 0x3) << 6)
-#define DET_DELAY(x) ((x & 0x7) << 3)
-#define SETTLING(x) (x & 0x7)
-#define FRACTION_Z(x) (x & 0x7)
-#define I_DRIVE(x) (x & 0x1)
-#define OP_MODE(x) ((x & 0x7) << 1)
-
#define STMPE_TS_NAME "stmpe-ts"
#define XY_MASK 0xfff
@@ -213,9 +202,10 @@ static int stmpe_init_hw(struct stmpe_touch *ts)
return ret;
}
- adc_ctrl1 = SAMPLE_TIME(ts->sample_time) | MOD_12B(ts->mod_12b) |
- REF_SEL(ts->ref_sel);
- adc_ctrl1_mask = SAMPLE_TIME(0xff) | MOD_12B(0xff) | REF_SEL(0xff);
+ 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);
@@ -225,15 +215,17 @@ static int stmpe_init_hw(struct stmpe_touch *ts)
}
ret = stmpe_set_bits(stmpe, STMPE_REG_ADC_CTRL2,
- ADC_FREQ(0xff), ADC_FREQ(ts->adc_freq));
+ STMPE_ADC_FREQ(0xff), STMPE_ADC_FREQ(ts->adc_freq));
if (ret) {
dev_err(dev, "Could not setup ADC\n");
return ret;
}
- tsc_cfg = AVE_CTRL(ts->ave_ctrl) | DET_DELAY(ts->touch_det_delay) |
- SETTLING(ts->settling);
- tsc_cfg_mask = AVE_CTRL(0xff) | DET_DELAY(0xff) | SETTLING(0xff);
+ tsc_cfg = STMPE_AVE_CTRL(ts->ave_ctrl) |
+ STMPE_DET_DELAY(ts->touch_det_delay) |
+ STMPE_SETTLING(ts->settling);
+ tsc_cfg_mask = STMPE_AVE_CTRL(0xff) | STMPE_DET_DELAY(0xff) |
+ STMPE_SETTLING(0xff);
ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_CFG, tsc_cfg_mask, tsc_cfg);
if (ret) {
@@ -242,14 +234,14 @@ static int stmpe_init_hw(struct stmpe_touch *ts)
}
ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_FRACTION_Z,
- FRACTION_Z(0xff), FRACTION_Z(ts->fraction_z));
+ STMPE_FRACTION_Z(0xff), STMPE_FRACTION_Z(ts->fraction_z));
if (ret) {
dev_err(dev, "Could not config touch\n");
return ret;
}
ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_I_DRIVE,
- I_DRIVE(0xff), I_DRIVE(ts->i_drive));
+ STMPE_I_DRIVE(0xff), STMPE_I_DRIVE(ts->i_drive));
if (ret) {
dev_err(dev, "Could not config touch\n");
return ret;
@@ -263,7 +255,7 @@ static int stmpe_init_hw(struct stmpe_touch *ts)
}
ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_CTRL,
- OP_MODE(0xff), OP_MODE(OP_MOD_XYZ));
+ STMPE_OP_MODE(0xff), STMPE_OP_MODE(OP_MOD_XYZ));
if (ret) {
dev_err(dev, "Could not set mode\n");
return ret;
diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
index 4a827af17e59..c0353f6431f9 100644
--- a/include/linux/mfd/stmpe.h
+++ b/include/linux/mfd/stmpe.h
@@ -10,6 +10,17 @@
#include <linux/mutex.h>
+#define STMPE_SAMPLE_TIME(x) ((x & 0xf) << 4)
+#define STMPE_MOD_12B(x) ((x & 0x1) << 3)
+#define STMPE_REF_SEL(x) ((x & 0x1) << 1)
+#define STMPE_ADC_FREQ(x) (x & 0x3)
+#define STMPE_AVE_CTRL(x) ((x & 0x3) << 6)
+#define STMPE_DET_DELAY(x) ((x & 0x7) << 3)
+#define STMPE_SETTLING(x) (x & 0x7)
+#define STMPE_FRACTION_Z(x) (x & 0x7)
+#define STMPE_I_DRIVE(x) (x & 0x1)
+#define STMPE_OP_MODE(x) ((x & 0x7) << 1)
+
struct device;
struct regulator;
--
2.20.1
^ permalink raw reply related
* [PATCH v6 1/8] dt-bindings: stmpe: reformatting parameter list and use tabs only
From: Philippe Schenker @ 2019-01-09 13:42 UTC (permalink / raw)
To: jic23, marcel.ziswiler, stefan
Cc: robh, alexandre.torgue, shawnguo, dmitry.torokhov, thierry.reding,
mcoquelin.stm32, digetx, lee.jones, Philippe Schenker, devicetree,
Max Krummenacher, Jonathan Cameron, linux-input, linux-kernel,
Rob Herring, Mark Rutland, linux-stm32, linux-arm-kernel
In-Reply-To: <20190109134208.5660-1-dev@pschenker.ch>
From: Philippe Schenker <philippe.schenker@toradex.com>
This patch reformats the parameter list for stmpe device in a
table-style so it is more clear to read.
Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Rob Herring <robh@kernel.org>
---
Changes in v6:
- Added Rob's Reviewed-by
Changes in v5:
- Made a one column list
- Added lee's Acked-for-MFD
- Changed author of commit to use correct email.
Changes in v4:
- New separate precursor patch for holding reformatting
Changes in v3: None
Changes in v2: None
.../bindings/input/touchscreen/stmpe.txt | 64 +++++++++++++------
.../devicetree/bindings/mfd/stmpe.txt | 14 ++--
2 files changed, 53 insertions(+), 25 deletions(-)
diff --git a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
index 127baa31a77a..bf66a55a7de5 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/stmpe.txt
@@ -5,24 +5,52 @@ Required properties:
- compatible: "st,stmpe-ts"
Optional properties:
-- st,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.
-- st,mod-12b: ADC Bit mode (0 -> 10bit ADC, 1 -> 12bit ADC)
-- st,ref-sel: ADC reference source (0 -> internal reference, 1 -> external
- reference)
-- st,adc-freq: ADC Clock speed (0 -> 1.625 MHz, 1 -> 3.25 MHz, 2 || 3 -> 6.5 MHz)
-- st,ave-ctrl: Sample average control (0 -> 1 sample, 1 -> 2 samples, 2 -> 4
- samples, 3 -> 8 samples)
-- st,touch-det-delay: Touch detect interrupt delay (0 -> 10 us, 1 -> 50 us, 2 ->
- 100 us, 3 -> 500 us, 4-> 1 ms, 5 -> 5 ms, 6 -> 10 ms, 7 -> 50 ms) recommended
- is 3
-- st,settling: Panel driver settling time (0 -> 10 us, 1 -> 100 us, 2 -> 500 us, 3
- -> 1 ms, 4 -> 5 ms, 5 -> 10 ms, 6 for 50 ms, 7 -> 100 ms) recommended is 2
-- st,fraction-z: Length of the fractional part in z (fraction-z ([0..7]) = Count of
- the fractional part) recommended is 7
-- st,i-drive: current limit value of the touchscreen drivers (0 -> 20 mA typical 35
- mA max, 1 -> 50 mA typical 80 mA max)
+- st,sample-time : ADC conversion time in number of clock.
+ 0 -> 36 clocks
+ 1 -> 44 clocks
+ 2 -> 56 clocks
+ 3 -> 64 clocks
+ 4 -> 80 clocks (recommended)
+ 5 -> 96 clocks
+ 6 -> 144 clocks
+- st,mod-12b : ADC Bit mode
+ 0 -> 10bit ADC
+ 1 -> 12bit ADC
+- st,ref-sel : ADC reference source
+ 0 -> internal
+ 1 -> external
+- st,adc-freq : ADC Clock speed
+ 0 -> 1.625 MHz
+ 1 -> 3.25 MHz
+ 2 || 3 -> 6.5 MHz
+- st,ave-ctrl : Sample average control
+ 0 -> 1 sample
+ 1 -> 2 samples
+ 2 -> 4 samples
+ 3 -> 8 samples
+- st,touch-det-delay : Touch detect interrupt delay (recommended is 3)
+ 0 -> 10 us
+ 1 -> 50 us
+ 2 -> 100 us
+ 3 -> 500 us
+ 4 -> 1 ms
+ 5 -> 5 ms
+ 6 -> 10 ms
+ 7 -> 50 ms
+- st,settling : Panel driver settling time (recommended is 2)
+ 0 -> 10 us
+ 1 -> 100 us
+ 2 -> 500 us
+ 3 -> 1 ms
+ 4 -> 5 ms
+ 5 -> 10 ms
+ 6 -> 50 ms
+ 7 -> 100 ms
+- st,fraction-z : Length of the fractional part in z (recommended is 7)
+ (fraction-z ([0..7]) = Count of the fractional part)
+- st,i-drive : current limit value of the touchscreen drivers
+ 0 -> 20 mA (typical 35mA max)
+ 1 -> 50 mA (typical 80 mA max)
Node name must be stmpe_touchscreen and should be child node of stmpe node to
which it belongs.
diff --git a/Documentation/devicetree/bindings/mfd/stmpe.txt b/Documentation/devicetree/bindings/mfd/stmpe.txt
index c797c05cd3c2..a46e7177195d 100644
--- a/Documentation/devicetree/bindings/mfd/stmpe.txt
+++ b/Documentation/devicetree/bindings/mfd/stmpe.txt
@@ -4,15 +4,15 @@ STMPE is an MFD device which may expose the following inbuilt devices: gpio,
keypad, touchscreen, adc, pwm, rotator.
Required properties:
- - compatible : "st,stmpe[610|801|811|1600|1601|2401|2403]"
- - reg : I2C/SPI address of the device
+ - compatible : "st,stmpe[610|801|811|1600|1601|2401|2403]"
+ - reg : I2C/SPI address of the device
Optional properties:
- - interrupts : The interrupt outputs from the controller
- - interrupt-controller : Marks the device node as an interrupt controller
- - wakeup-source : Marks the input device as wakable
- - st,autosleep-timeout : Valid entries (ms); 4, 16, 32, 64, 128, 256, 512 and 1024
- - irq-gpio : If present, which GPIO to use for event IRQ
+ - interrupts : The interrupt outputs from the controller
+ - interrupt-controller : Marks the device node as an interrupt controller
+ - wakeup-source : Marks the input device as wakable
+ - st,autosleep-timeout : Valid entries (ms); 4, 16, 32, 64, 128, 256, 512 and 1024
+ - irq-gpio : If present, which GPIO to use for event IRQ
Example:
--
2.20.1
^ permalink raw reply related
* [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
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