* [PATCH 1/3] input: touchscreen: ad7879: move header to input subdirectory
@ 2016-01-26 3:04 ` Stefan Agner
0 siblings, 0 replies; 23+ messages in thread
From: Stefan Agner @ 2016-01-26 3:04 UTC (permalink / raw)
To: dmitry.torokhov, michael.hennerich, robh+dt
Cc: mark.rutland, ijc+devicetree, galak, realmz6, broonie, jic23,
linux-input, devicetree, linux-kernel, Stefan Agner
The header file is used by the SPI and I2C variant of the driver.
Therefore, move it to a more generic place under input.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
arch/blackfin/mach-bf527/boards/ezbrd.c | 2 +-
arch/blackfin/mach-bf527/boards/ezkit.c | 2 +-
arch/blackfin/mach-bf527/boards/tll6527m.c | 2 +-
arch/blackfin/mach-bf537/boards/stamp.c | 2 +-
arch/blackfin/mach-bf538/boards/ezkit.c | 2 +-
drivers/input/touchscreen/ad7879.c | 4 +--
include/linux/input/ad7879.h | 41 ++++++++++++++++++++++++++++++
include/linux/spi/ad7879.h | 41 ------------------------------
8 files changed, 48 insertions(+), 48 deletions(-)
create mode 100644 include/linux/input/ad7879.h
delete mode 100644 include/linux/spi/ad7879.h
diff --git a/arch/blackfin/mach-bf527/boards/ezbrd.c b/arch/blackfin/mach-bf527/boards/ezbrd.c
index a3a5723..b5a74e5 100644
--- a/arch/blackfin/mach-bf527/boards/ezbrd.c
+++ b/arch/blackfin/mach-bf527/boards/ezbrd.c
@@ -279,7 +279,7 @@ static const struct ad7877_platform_data bfin_ad7877_ts_info = {
#endif
#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
-#include <linux/spi/ad7879.h>
+#include <linux/input/ad7879.h>
static const struct ad7879_platform_data bfin_ad7879_ts_info = {
.model = 7879, /* Model = AD7879 */
.x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
diff --git a/arch/blackfin/mach-bf527/boards/ezkit.c b/arch/blackfin/mach-bf527/boards/ezkit.c
index d4219e8..276270c 100644
--- a/arch/blackfin/mach-bf527/boards/ezkit.c
+++ b/arch/blackfin/mach-bf527/boards/ezkit.c
@@ -477,7 +477,7 @@ static const struct ad7877_platform_data bfin_ad7877_ts_info = {
#endif
#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
-#include <linux/spi/ad7879.h>
+#include <linux/input/ad7879.h>
static const struct ad7879_platform_data bfin_ad7879_ts_info = {
.model = 7879, /* Model = AD7879 */
.x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
diff --git a/arch/blackfin/mach-bf527/boards/tll6527m.c b/arch/blackfin/mach-bf527/boards/tll6527m.c
index a0f5856..ff67ddc 100644
--- a/arch/blackfin/mach-bf527/boards/tll6527m.c
+++ b/arch/blackfin/mach-bf527/boards/tll6527m.c
@@ -29,7 +29,7 @@
#include <asm/dpmc.h>
#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
-#include <linux/spi/ad7879.h>
+#include <linux/input/ad7879.h>
#define LCD_BACKLIGHT_GPIO 0x40
/* TLL6527M uses TLL7UIQ35 / ADI LCD EZ Extender. AD7879 AUX GPIO is used for
* LCD Backlight Enable
diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c
index c181543..cf063be 100644
--- a/arch/blackfin/mach-bf537/boards/stamp.c
+++ b/arch/blackfin/mach-bf537/boards/stamp.c
@@ -776,7 +776,7 @@ static const struct ad7877_platform_data bfin_ad7877_ts_info = {
#endif
#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
-#include <linux/spi/ad7879.h>
+#include <linux/input/ad7879.h>
static const struct ad7879_platform_data bfin_ad7879_ts_info = {
.model = 7879, /* Model = AD7879 */
.x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
diff --git a/arch/blackfin/mach-bf538/boards/ezkit.c b/arch/blackfin/mach-bf538/boards/ezkit.c
index ae2fcbb..849587c 100644
--- a/arch/blackfin/mach-bf538/boards/ezkit.c
+++ b/arch/blackfin/mach-bf538/boards/ezkit.c
@@ -521,7 +521,7 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
#endif /* CONFIG_SPI_BFIN5XX */
#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
-#include <linux/spi/ad7879.h>
+#include <linux/input/ad7879.h>
static const struct ad7879_platform_data bfin_ad7879_ts_info = {
.model = 7879, /* Model = AD7879 */
.x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
index 16b5cc2..a73934b 100644
--- a/drivers/input/touchscreen/ad7879.c
+++ b/drivers/input/touchscreen/ad7879.c
@@ -31,7 +31,7 @@
#include <linux/i2c.h>
#include <linux/gpio.h>
-#include <linux/spi/ad7879.h>
+#include <linux/input/ad7879.h>
#include <linux/module.h>
#include "ad7879.h"
@@ -170,7 +170,7 @@ static int ad7879_report(struct ad7879 *ts)
* filter. The combination of these two techniques provides a robust
* solution, discarding the spurious noise in the signal and keeping
* only the data of interest. The size of both filters is
- * programmable. (dev.platform_data, see linux/spi/ad7879.h) Other
+ * programmable. (dev.platform_data, see linux/input/ad7879.h) Other
* user-programmable conversion controls include variable acquisition
* time, and first conversion delay. Up to 16 averages can be taken
* per conversion.
diff --git a/include/linux/input/ad7879.h b/include/linux/input/ad7879.h
new file mode 100644
index 0000000..98fc270
--- /dev/null
+++ b/include/linux/input/ad7879.h
@@ -0,0 +1,41 @@
+/* linux/input/ad7879.h */
+
+/* Touchscreen characteristics vary between boards and models. The
+ * platform_data for the device's "struct device" holds this information.
+ *
+ * It's OK if the min/max values are zero.
+ */
+struct ad7879_platform_data {
+ u16 model; /* 7879 */
+ u16 x_plate_ohms;
+ u16 x_min, x_max;
+ u16 y_min, y_max;
+ u16 pressure_min, pressure_max;
+
+ bool swap_xy; /* swap x and y axes */
+
+ /* [0..255] 0=OFF Starts at 1=550us and goes
+ * all the way to 9.440ms in steps of 35us.
+ */
+ u8 pen_down_acc_interval;
+ /* [0..15] Starts at 0=128us and goes all the
+ * way to 4.096ms in steps of 128us.
+ */
+ u8 first_conversion_delay;
+ /* [0..3] 0 = 2us, 1 = 4us, 2 = 8us, 3 = 16us */
+ u8 acquisition_time;
+ /* [0..3] Average X middle samples 0 = 2, 1 = 4, 2 = 8, 3 = 16 */
+ u8 averaging;
+ /* [0..3] Perform X measurements 0 = OFF,
+ * 1 = 4, 2 = 8, 3 = 16 (median > averaging)
+ */
+ u8 median;
+ /* 1 = AUX/VBAT/GPIO export GPIO to gpiolib
+ * requires CONFIG_GPIOLIB
+ */
+ bool gpio_export;
+ /* identifies the first GPIO number handled by this chip;
+ * or, if negative, requests dynamic ID allocation.
+ */
+ s32 gpio_base;
+};
diff --git a/include/linux/spi/ad7879.h b/include/linux/spi/ad7879.h
deleted file mode 100644
index 58368be..0000000
--- a/include/linux/spi/ad7879.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* linux/spi/ad7879.h */
-
-/* Touchscreen characteristics vary between boards and models. The
- * platform_data for the device's "struct device" holds this information.
- *
- * It's OK if the min/max values are zero.
- */
-struct ad7879_platform_data {
- u16 model; /* 7879 */
- u16 x_plate_ohms;
- u16 x_min, x_max;
- u16 y_min, y_max;
- u16 pressure_min, pressure_max;
-
- bool swap_xy; /* swap x and y axes */
-
- /* [0..255] 0=OFF Starts at 1=550us and goes
- * all the way to 9.440ms in steps of 35us.
- */
- u8 pen_down_acc_interval;
- /* [0..15] Starts at 0=128us and goes all the
- * way to 4.096ms in steps of 128us.
- */
- u8 first_conversion_delay;
- /* [0..3] 0 = 2us, 1 = 4us, 2 = 8us, 3 = 16us */
- u8 acquisition_time;
- /* [0..3] Average X middle samples 0 = 2, 1 = 4, 2 = 8, 3 = 16 */
- u8 averaging;
- /* [0..3] Perform X measurements 0 = OFF,
- * 1 = 4, 2 = 8, 3 = 16 (median > averaging)
- */
- u8 median;
- /* 1 = AUX/VBAT/GPIO export GPIO to gpiolib
- * requires CONFIG_GPIOLIB
- */
- bool gpio_export;
- /* identifies the first GPIO number handled by this chip;
- * or, if negative, requests dynamic ID allocation.
- */
- s32 gpio_base;
-};
--
2.7.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 1/3] input: touchscreen: ad7879: move header to input subdirectory
@ 2016-01-26 3:04 ` Stefan Agner
0 siblings, 0 replies; 23+ messages in thread
From: Stefan Agner @ 2016-01-26 3:04 UTC (permalink / raw)
To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
michael.hennerich-OyLXuOCK7orQT0dZR+AlfA,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A
Cc: mark.rutland-5wv7dgnIgG8, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ, realmz6-Re5JQEeQqe8AvxtiuMwx3w,
broonie-DgEjT+Ai2ygdnm+yROfE0A, jic23-DgEjT+Ai2ygdnm+yROfE0A,
linux-input-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Stefan Agner
The header file is used by the SPI and I2C variant of the driver.
Therefore, move it to a more generic place under input.
Signed-off-by: Stefan Agner <stefan-XLVq0VzYD2Y@public.gmane.org>
---
arch/blackfin/mach-bf527/boards/ezbrd.c | 2 +-
arch/blackfin/mach-bf527/boards/ezkit.c | 2 +-
arch/blackfin/mach-bf527/boards/tll6527m.c | 2 +-
arch/blackfin/mach-bf537/boards/stamp.c | 2 +-
arch/blackfin/mach-bf538/boards/ezkit.c | 2 +-
drivers/input/touchscreen/ad7879.c | 4 +--
include/linux/input/ad7879.h | 41 ++++++++++++++++++++++++++++++
include/linux/spi/ad7879.h | 41 ------------------------------
8 files changed, 48 insertions(+), 48 deletions(-)
create mode 100644 include/linux/input/ad7879.h
delete mode 100644 include/linux/spi/ad7879.h
diff --git a/arch/blackfin/mach-bf527/boards/ezbrd.c b/arch/blackfin/mach-bf527/boards/ezbrd.c
index a3a5723..b5a74e5 100644
--- a/arch/blackfin/mach-bf527/boards/ezbrd.c
+++ b/arch/blackfin/mach-bf527/boards/ezbrd.c
@@ -279,7 +279,7 @@ static const struct ad7877_platform_data bfin_ad7877_ts_info = {
#endif
#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
-#include <linux/spi/ad7879.h>
+#include <linux/input/ad7879.h>
static const struct ad7879_platform_data bfin_ad7879_ts_info = {
.model = 7879, /* Model = AD7879 */
.x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
diff --git a/arch/blackfin/mach-bf527/boards/ezkit.c b/arch/blackfin/mach-bf527/boards/ezkit.c
index d4219e8..276270c 100644
--- a/arch/blackfin/mach-bf527/boards/ezkit.c
+++ b/arch/blackfin/mach-bf527/boards/ezkit.c
@@ -477,7 +477,7 @@ static const struct ad7877_platform_data bfin_ad7877_ts_info = {
#endif
#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
-#include <linux/spi/ad7879.h>
+#include <linux/input/ad7879.h>
static const struct ad7879_platform_data bfin_ad7879_ts_info = {
.model = 7879, /* Model = AD7879 */
.x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
diff --git a/arch/blackfin/mach-bf527/boards/tll6527m.c b/arch/blackfin/mach-bf527/boards/tll6527m.c
index a0f5856..ff67ddc 100644
--- a/arch/blackfin/mach-bf527/boards/tll6527m.c
+++ b/arch/blackfin/mach-bf527/boards/tll6527m.c
@@ -29,7 +29,7 @@
#include <asm/dpmc.h>
#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
-#include <linux/spi/ad7879.h>
+#include <linux/input/ad7879.h>
#define LCD_BACKLIGHT_GPIO 0x40
/* TLL6527M uses TLL7UIQ35 / ADI LCD EZ Extender. AD7879 AUX GPIO is used for
* LCD Backlight Enable
diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c
index c181543..cf063be 100644
--- a/arch/blackfin/mach-bf537/boards/stamp.c
+++ b/arch/blackfin/mach-bf537/boards/stamp.c
@@ -776,7 +776,7 @@ static const struct ad7877_platform_data bfin_ad7877_ts_info = {
#endif
#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
-#include <linux/spi/ad7879.h>
+#include <linux/input/ad7879.h>
static const struct ad7879_platform_data bfin_ad7879_ts_info = {
.model = 7879, /* Model = AD7879 */
.x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
diff --git a/arch/blackfin/mach-bf538/boards/ezkit.c b/arch/blackfin/mach-bf538/boards/ezkit.c
index ae2fcbb..849587c 100644
--- a/arch/blackfin/mach-bf538/boards/ezkit.c
+++ b/arch/blackfin/mach-bf538/boards/ezkit.c
@@ -521,7 +521,7 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
#endif /* CONFIG_SPI_BFIN5XX */
#if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7879)
-#include <linux/spi/ad7879.h>
+#include <linux/input/ad7879.h>
static const struct ad7879_platform_data bfin_ad7879_ts_info = {
.model = 7879, /* Model = AD7879 */
.x_plate_ohms = 620, /* 620 Ohm from the touch datasheet */
diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
index 16b5cc2..a73934b 100644
--- a/drivers/input/touchscreen/ad7879.c
+++ b/drivers/input/touchscreen/ad7879.c
@@ -31,7 +31,7 @@
#include <linux/i2c.h>
#include <linux/gpio.h>
-#include <linux/spi/ad7879.h>
+#include <linux/input/ad7879.h>
#include <linux/module.h>
#include "ad7879.h"
@@ -170,7 +170,7 @@ static int ad7879_report(struct ad7879 *ts)
* filter. The combination of these two techniques provides a robust
* solution, discarding the spurious noise in the signal and keeping
* only the data of interest. The size of both filters is
- * programmable. (dev.platform_data, see linux/spi/ad7879.h) Other
+ * programmable. (dev.platform_data, see linux/input/ad7879.h) Other
* user-programmable conversion controls include variable acquisition
* time, and first conversion delay. Up to 16 averages can be taken
* per conversion.
diff --git a/include/linux/input/ad7879.h b/include/linux/input/ad7879.h
new file mode 100644
index 0000000..98fc270
--- /dev/null
+++ b/include/linux/input/ad7879.h
@@ -0,0 +1,41 @@
+/* linux/input/ad7879.h */
+
+/* Touchscreen characteristics vary between boards and models. The
+ * platform_data for the device's "struct device" holds this information.
+ *
+ * It's OK if the min/max values are zero.
+ */
+struct ad7879_platform_data {
+ u16 model; /* 7879 */
+ u16 x_plate_ohms;
+ u16 x_min, x_max;
+ u16 y_min, y_max;
+ u16 pressure_min, pressure_max;
+
+ bool swap_xy; /* swap x and y axes */
+
+ /* [0..255] 0=OFF Starts at 1=550us and goes
+ * all the way to 9.440ms in steps of 35us.
+ */
+ u8 pen_down_acc_interval;
+ /* [0..15] Starts at 0=128us and goes all the
+ * way to 4.096ms in steps of 128us.
+ */
+ u8 first_conversion_delay;
+ /* [0..3] 0 = 2us, 1 = 4us, 2 = 8us, 3 = 16us */
+ u8 acquisition_time;
+ /* [0..3] Average X middle samples 0 = 2, 1 = 4, 2 = 8, 3 = 16 */
+ u8 averaging;
+ /* [0..3] Perform X measurements 0 = OFF,
+ * 1 = 4, 2 = 8, 3 = 16 (median > averaging)
+ */
+ u8 median;
+ /* 1 = AUX/VBAT/GPIO export GPIO to gpiolib
+ * requires CONFIG_GPIOLIB
+ */
+ bool gpio_export;
+ /* identifies the first GPIO number handled by this chip;
+ * or, if negative, requests dynamic ID allocation.
+ */
+ s32 gpio_base;
+};
diff --git a/include/linux/spi/ad7879.h b/include/linux/spi/ad7879.h
deleted file mode 100644
index 58368be..0000000
--- a/include/linux/spi/ad7879.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* linux/spi/ad7879.h */
-
-/* Touchscreen characteristics vary between boards and models. The
- * platform_data for the device's "struct device" holds this information.
- *
- * It's OK if the min/max values are zero.
- */
-struct ad7879_platform_data {
- u16 model; /* 7879 */
- u16 x_plate_ohms;
- u16 x_min, x_max;
- u16 y_min, y_max;
- u16 pressure_min, pressure_max;
-
- bool swap_xy; /* swap x and y axes */
-
- /* [0..255] 0=OFF Starts at 1=550us and goes
- * all the way to 9.440ms in steps of 35us.
- */
- u8 pen_down_acc_interval;
- /* [0..15] Starts at 0=128us and goes all the
- * way to 4.096ms in steps of 128us.
- */
- u8 first_conversion_delay;
- /* [0..3] 0 = 2us, 1 = 4us, 2 = 8us, 3 = 16us */
- u8 acquisition_time;
- /* [0..3] Average X middle samples 0 = 2, 1 = 4, 2 = 8, 3 = 16 */
- u8 averaging;
- /* [0..3] Perform X measurements 0 = OFF,
- * 1 = 4, 2 = 8, 3 = 16 (median > averaging)
- */
- u8 median;
- /* 1 = AUX/VBAT/GPIO export GPIO to gpiolib
- * requires CONFIG_GPIOLIB
- */
- bool gpio_export;
- /* identifies the first GPIO number handled by this chip;
- * or, if negative, requests dynamic ID allocation.
- */
- s32 gpio_base;
-};
--
2.7.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 2/3] input: touchscreen: ad7879: fix default x/y axis assignment
2016-01-26 3:04 ` Stefan Agner
@ 2016-01-26 3:04 ` Stefan Agner
-1 siblings, 0 replies; 23+ messages in thread
From: Stefan Agner @ 2016-01-26 3:04 UTC (permalink / raw)
To: dmitry.torokhov, michael.hennerich, robh+dt
Cc: mark.rutland, ijc+devicetree, galak, realmz6, broonie, jic23,
linux-input, devicetree, linux-kernel, Stefan Agner
The measurements read from the controller which are temporary stored
in conversion_data, are interpreted wrong. The first measurement X+
contains the Y position, and the second measurement Y+ the X position
(see also Table 11 Register Table in the data sheet).
The problem is already known and a swap option has been introduced:
commit 6680884a4420 ("Input: ad7879 - add option to correct xy axis")
However, with that the meaning of the new boolean is inverted since
the underlying values are already swapped. With this change, a true
in swap_xy actually swaps the two axis.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
Hi Michael,
It seems that swap_xy is not used in any board which is in mainline,
hence swap_xy is always false. Therefore, up until now all boards
actually used swapped axis. However, I doubt that the blackfin boards
really have those axis swapped, it is probably more likely that the
userspace calibration took care of it.
However, if they are really swapped, we should set the swap_xy flag
to 1 for those board...
Do you happen to now what is the case with those boards?
--
Stefan
drivers/input/touchscreen/ad7879.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
index a73934b..e290e7b 100644
--- a/drivers/input/touchscreen/ad7879.c
+++ b/drivers/input/touchscreen/ad7879.c
@@ -94,8 +94,8 @@
#define AD7879_TEMP_BIT (1<<1)
enum {
- AD7879_SEQ_XPOS = 0,
- AD7879_SEQ_YPOS = 1,
+ AD7879_SEQ_YPOS = 0,
+ AD7879_SEQ_XPOS = 1,
AD7879_SEQ_Z1 = 2,
AD7879_SEQ_Z2 = 3,
AD7879_NR_SENSE = 4,
--
2.7.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 2/3] input: touchscreen: ad7879: fix default x/y axis assignment
@ 2016-01-26 3:04 ` Stefan Agner
0 siblings, 0 replies; 23+ messages in thread
From: Stefan Agner @ 2016-01-26 3:04 UTC (permalink / raw)
To: dmitry.torokhov, michael.hennerich, robh+dt
Cc: mark.rutland, ijc+devicetree, galak, realmz6, broonie, jic23,
linux-input, devicetree, linux-kernel, Stefan Agner
The measurements read from the controller which are temporary stored
in conversion_data, are interpreted wrong. The first measurement X+
contains the Y position, and the second measurement Y+ the X position
(see also Table 11 Register Table in the data sheet).
The problem is already known and a swap option has been introduced:
commit 6680884a4420 ("Input: ad7879 - add option to correct xy axis")
However, with that the meaning of the new boolean is inverted since
the underlying values are already swapped. With this change, a true
in swap_xy actually swaps the two axis.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
Hi Michael,
It seems that swap_xy is not used in any board which is in mainline,
hence swap_xy is always false. Therefore, up until now all boards
actually used swapped axis. However, I doubt that the blackfin boards
really have those axis swapped, it is probably more likely that the
userspace calibration took care of it.
However, if they are really swapped, we should set the swap_xy flag
to 1 for those board...
Do you happen to now what is the case with those boards?
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 3/3] input: touchscreen: ad7879: add device tree support
2016-01-26 3:04 ` Stefan Agner
(?)
(?)
@ 2016-01-26 3:04 ` Stefan Agner
2016-01-26 3:28 ` kbuild test robot
` (5 more replies)
-1 siblings, 6 replies; 23+ messages in thread
From: Stefan Agner @ 2016-01-26 3:04 UTC (permalink / raw)
To: dmitry.torokhov, michael.hennerich, robh+dt
Cc: mark.rutland, ijc+devicetree, galak, realmz6, broonie, jic23,
linux-input, devicetree, linux-kernel, Stefan Agner
Add device tree support for the I2C variant of AD7879 (AD7879-1). This
allows to specify the touchscreen controller as a I2C client node.
Most of the options available as platform data are also available as
device tree properties. Exporting the GPIO is currently not possible
through device tree.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
.../bindings/input/touchscreen/ad7879-i2c.txt | 47 ++++++++++++++++
drivers/input/touchscreen/ad7879-i2c.c | 63 +++++++++++++++++++++-
drivers/input/touchscreen/ad7879-spi.c | 3 +-
drivers/input/touchscreen/ad7879.c | 2 +-
drivers/input/touchscreen/ad7879.h | 1 +
5 files changed, 113 insertions(+), 3 deletions(-)
create mode 100644 Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
diff --git a/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt b/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
new file mode 100644
index 0000000..bf169a2
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
@@ -0,0 +1,47 @@
+* Analog Devices AD7879-1/AD7889-1 touchscreen interface (I2C)
+
+Required properties:
+- compatible: must be "adi,ad7879-1"
+- reg: i2c slave address
+- interrupt-parent: the phandle for the interrupt controller
+- interrupts: touch controller interrupt
+- resistance-plate-x : total resistance of X-plate (for pressure
+ calculation)
+- touchscreen-max-pressure : maximum reported pressure
+- touchscreen-swapped-x-y : X and Y axis are swapped (boolean)
+ Swapping is done after inverting the axis
+Optional properties:
+- first-conversion-delay : 0-12 in 128us steps (starting with 128us)
+ 13: 2.560ms
+ 14: 3.584ms
+ 15: 4.096ms
+- acquisition-time : 0: 2us
+ 1: 4us
+ 2: 8us
+ 3: 16us
+- median-filter-size : 0: disabled
+ 1: 4 measurements
+ 2: 8 measurements
+ 3: 16 measurements
+- averaging : 0: 2 middle values (1 if median disabled)
+ 1: 4 middle values
+ 2: 8 middle values
+ 3: 16 values
+- conversion-interval: : 0: convert one time only
+ 1-255: 515us + val * 35us (up to 9.440ms)
+
+Example:
+
+ ad7879@2c {
+ compatible = "adi,ad7879-1";
+ reg = <0x2c>;
+ interrupt-parent = <&gpio1>;
+ interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
+ resistance-plate-x = <120>;
+ touchscreen-max-pressure = <4096>;
+ first-conversion-delay = /bits/ 8 <3>;
+ acquisition-time = /bits/ 8 <1>;
+ median-filter-size = /bits/ 8 <2>;
+ averaging = /bits/ 8 <1>;
+ conversion-interval = /bits/ 8 <255>;
+ };
diff --git a/drivers/input/touchscreen/ad7879-i2c.c b/drivers/input/touchscreen/ad7879-i2c.c
index d66962c..08a2c9a 100644
--- a/drivers/input/touchscreen/ad7879-i2c.c
+++ b/drivers/input/touchscreen/ad7879-i2c.c
@@ -11,6 +11,7 @@
#include <linux/module.h>
#include <linux/types.h>
#include <linux/pm.h>
+#include <linux/input/ad7879.h>
#include "ad7879.h"
@@ -54,9 +55,50 @@ static const struct ad7879_bus_ops ad7879_i2c_bus_ops = {
.write = ad7879_i2c_write,
};
+static struct ad7879_platform_data *ad7879_parse_dt(struct device *dev)
+{
+ struct ad7879_platform_data *pdata;
+ struct device_node *np = dev->of_node;
+ int err;
+ u32 tmp;
+
+ if (!np)
+ return NULL;
+
+ pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+
+ if (!pdata)
+ return ERR_PTR(-ENOMEM);
+
+ err = of_property_read_u32(np, "resistance-plate-x", &tmp);
+ if (err) {
+ dev_err(dev, "failed to get resistance-plate-x property\n");
+ return ERR_PTR(err);
+ }
+ pdata->x_plate_ohms = (u16)tmp;
+
+ err = of_property_read_u32(np, "touchscreen-max-pressure", &tmp);
+ if (err) {
+ dev_err(dev, "failed to get touchscreen-max-pressure property\n");
+ return ERR_PTR(err);
+ }
+ pdata->pressure_min = (u16)tmp;
+
+ of_property_read_u8(np, "first-conversion-delay", &pdata->first_conversion_delay);
+ of_property_read_u8(np, "acquisition-time", &pdata->acquisition_time);
+ of_property_read_u8(np, "median-filter-size", &pdata->median);
+ of_property_read_u8(np, "averaging", &pdata->averaging);
+ of_property_read_u8(np, "conversion-interval", &pdata->pen_down_acc_interval);
+
+ pdata->swap_xy = of_property_read_bool(np, "touchscreen-swapped-x-y");
+
+ return pdata;
+}
+
static int ad7879_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
+ struct ad7879_platform_data *pdata;
struct ad7879 *ts;
if (!i2c_check_functionality(client->adapter,
@@ -65,7 +107,17 @@ static int ad7879_i2c_probe(struct i2c_client *client,
return -EIO;
}
- ts = ad7879_probe(&client->dev, AD7879_DEVID, client->irq,
+ pdata = dev_get_platdata(&client->dev);
+
+ if (!pdata && IS_ENABLED(CONFIG_OF))
+ pdata = ad7879_parse_dt(&client->dev);
+
+ if (IS_ERR_OR_NULL(pdata)) {
+ dev_err(&client->dev, "Need platform data\n");
+ return PTR_ERR(pdata);
+ }
+
+ ts = ad7879_probe(&client->dev, AD7879_DEVID, client->irq, pdata,
&ad7879_i2c_bus_ops);
if (IS_ERR(ts))
return PTR_ERR(ts);
@@ -91,10 +143,19 @@ static const struct i2c_device_id ad7879_id[] = {
};
MODULE_DEVICE_TABLE(i2c, ad7879_id);
+#ifdef CONFIG_OF
+static const struct of_device_id ad7879_dt_ids[] = {
+ { .compatible = "adi,ad7879-1", },
+ { }
+};
+MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids);
+#endif
+
static struct i2c_driver ad7879_i2c_driver = {
.driver = {
.name = "ad7879",
.pm = &ad7879_pm_ops,
+ .of_match_table = of_match_ptr(ad7879_dt_ids),
},
.probe = ad7879_i2c_probe,
.remove = ad7879_i2c_remove,
diff --git a/drivers/input/touchscreen/ad7879-spi.c b/drivers/input/touchscreen/ad7879-spi.c
index 48033c2..8ebe604 100644
--- a/drivers/input/touchscreen/ad7879-spi.c
+++ b/drivers/input/touchscreen/ad7879-spi.c
@@ -128,7 +128,8 @@ static int ad7879_spi_probe(struct spi_device *spi)
return err;
}
- ts = ad7879_probe(&spi->dev, AD7879_DEVID, spi->irq, &ad7879_spi_bus_ops);
+ ts = ad7879_probe(&spi->dev, AD7879_DEVID, spi->irq, pdata,
+ dev_get_platdata(&spi->dev), &ad7879_spi_bus_ops);
if (IS_ERR(ts))
return PTR_ERR(ts);
diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
index e290e7b..e763c77 100644
--- a/drivers/input/touchscreen/ad7879.c
+++ b/drivers/input/touchscreen/ad7879.c
@@ -486,9 +486,9 @@ static inline void ad7879_gpio_remove(struct ad7879 *ts)
#endif
struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq,
+ struct ad7879_platform_data *pdata,
const struct ad7879_bus_ops *bops)
{
- struct ad7879_platform_data *pdata = dev_get_platdata(dev);
struct ad7879 *ts;
struct input_dev *input_dev;
int err;
diff --git a/drivers/input/touchscreen/ad7879.h b/drivers/input/touchscreen/ad7879.h
index 6fd13c4..fa363a0 100644
--- a/drivers/input/touchscreen/ad7879.h
+++ b/drivers/input/touchscreen/ad7879.h
@@ -24,6 +24,7 @@ struct ad7879_bus_ops {
extern const struct dev_pm_ops ad7879_pm_ops;
struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned irq,
+ struct ad7879_platform_data *pdata,
const struct ad7879_bus_ops *bops);
void ad7879_remove(struct ad7879 *);
--
2.7.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 3/3] input: touchscreen: ad7879: add device tree support
@ 2016-01-26 3:28 ` kbuild test robot
0 siblings, 0 replies; 23+ messages in thread
From: kbuild test robot @ 2016-01-26 3:28 UTC (permalink / raw)
To: Stefan Agner
Cc: kbuild-all, dmitry.torokhov, michael.hennerich, robh+dt,
mark.rutland, ijc+devicetree, galak, realmz6, broonie, jic23,
linux-input, devicetree, linux-kernel, Stefan Agner
[-- Attachment #1: Type: text/plain, Size: 5977 bytes --]
Hi Stefan,
[auto build test ERROR on input/next]
[also build test ERROR on v4.5-rc1 next-20160125]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Stefan-Agner/input-touchscreen-ad7879-move-header-to-input-subdirectory/20160126-110813
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: x86_64-randconfig-x012-01260845 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All error/warnings (new ones prefixed by >>):
In file included from drivers/input/touchscreen/ad7879-spi.c:14:0:
>> drivers/input/touchscreen/ad7879.h:28:21: warning: 'struct ad7879_platform_data' declared inside parameter list
const struct ad7879_bus_ops *bops);
^
>> drivers/input/touchscreen/ad7879.h:28:21: warning: its scope is only this definition or declaration, which is probably not what you want
drivers/input/touchscreen/ad7879-spi.c: In function 'ad7879_spi_probe':
>> drivers/input/touchscreen/ad7879-spi.c:131:55: error: 'pdata' undeclared (first use in this function)
ts = ad7879_probe(&spi->dev, AD7879_DEVID, spi->irq, pdata,
^
drivers/input/touchscreen/ad7879-spi.c:131:55: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/input/touchscreen/ad7879-spi.c:131:7: error: too many arguments to function 'ad7879_probe'
ts = ad7879_probe(&spi->dev, AD7879_DEVID, spi->irq, pdata,
^
In file included from drivers/input/touchscreen/ad7879-spi.c:14:0:
drivers/input/touchscreen/ad7879.h:26:16: note: declared here
struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned irq,
^
vim +/pdata +131 drivers/input/touchscreen/ad7879-spi.c
8
9 #include <linux/input.h> /* BUS_SPI */
10 #include <linux/pm.h>
11 #include <linux/spi/spi.h>
12 #include <linux/module.h>
13
> 14 #include "ad7879.h"
15
16 #define AD7879_DEVID 0x7A /* AD7879/AD7889 */
17
18 #define MAX_SPI_FREQ_HZ 5000000
19 #define AD7879_CMD_MAGIC 0xE000
20 #define AD7879_CMD_READ (1 << 10)
21 #define AD7879_CMD(reg) (AD7879_CMD_MAGIC | ((reg) & 0xF))
22 #define AD7879_WRITECMD(reg) (AD7879_CMD(reg))
23 #define AD7879_READCMD(reg) (AD7879_CMD(reg) | AD7879_CMD_READ)
24
25 /*
26 * ad7879_read/write are only used for initial setup and for sysfs controls.
27 * The main traffic is done in ad7879_collect().
28 */
29
30 static int ad7879_spi_xfer(struct spi_device *spi,
31 u16 cmd, u8 count, u16 *tx_buf, u16 *rx_buf)
32 {
33 struct spi_message msg;
34 struct spi_transfer *xfers;
35 void *spi_data;
36 u16 *command;
37 u16 *_rx_buf = _rx_buf; /* shut gcc up */
38 u8 idx;
39 int ret;
40
41 xfers = spi_data = kzalloc(sizeof(*xfers) * (count + 2), GFP_KERNEL);
42 if (!spi_data)
43 return -ENOMEM;
44
45 spi_message_init(&msg);
46
47 command = spi_data;
48 command[0] = cmd;
49 if (count == 1) {
50 /* ad7879_spi_{read,write} gave us buf on stack */
51 command[1] = *tx_buf;
52 tx_buf = &command[1];
53 _rx_buf = rx_buf;
54 rx_buf = &command[2];
55 }
56
57 ++xfers;
58 xfers[0].tx_buf = command;
59 xfers[0].len = 2;
60 spi_message_add_tail(&xfers[0], &msg);
61 ++xfers;
62
63 for (idx = 0; idx < count; ++idx) {
64 if (rx_buf)
65 xfers[idx].rx_buf = &rx_buf[idx];
66 if (tx_buf)
67 xfers[idx].tx_buf = &tx_buf[idx];
68 xfers[idx].len = 2;
69 spi_message_add_tail(&xfers[idx], &msg);
70 }
71
72 ret = spi_sync(spi, &msg);
73
74 if (count == 1)
75 _rx_buf[0] = command[2];
76
77 kfree(spi_data);
78
79 return ret;
80 }
81
82 static int ad7879_spi_multi_read(struct device *dev,
83 u8 first_reg, u8 count, u16 *buf)
84 {
85 struct spi_device *spi = to_spi_device(dev);
86
87 return ad7879_spi_xfer(spi, AD7879_READCMD(first_reg), count, NULL, buf);
88 }
89
90 static int ad7879_spi_read(struct device *dev, u8 reg)
91 {
92 struct spi_device *spi = to_spi_device(dev);
93 u16 ret, dummy;
94
95 return ad7879_spi_xfer(spi, AD7879_READCMD(reg), 1, &dummy, &ret) ? : ret;
96 }
97
98 static int ad7879_spi_write(struct device *dev, u8 reg, u16 val)
99 {
100 struct spi_device *spi = to_spi_device(dev);
101 u16 dummy;
102
103 return ad7879_spi_xfer(spi, AD7879_WRITECMD(reg), 1, &val, &dummy);
104 }
105
106 static const struct ad7879_bus_ops ad7879_spi_bus_ops = {
107 .bustype = BUS_SPI,
108 .read = ad7879_spi_read,
109 .multi_read = ad7879_spi_multi_read,
110 .write = ad7879_spi_write,
111 };
112
113 static int ad7879_spi_probe(struct spi_device *spi)
114 {
115 struct ad7879 *ts;
116 int err;
117
118 /* don't exceed max specified SPI CLK frequency */
119 if (spi->max_speed_hz > MAX_SPI_FREQ_HZ) {
120 dev_err(&spi->dev, "SPI CLK %d Hz?\n", spi->max_speed_hz);
121 return -EINVAL;
122 }
123
124 spi->bits_per_word = 16;
125 err = spi_setup(spi);
126 if (err) {
127 dev_dbg(&spi->dev, "spi master doesn't support 16 bits/word\n");
128 return err;
129 }
130
> 131 ts = ad7879_probe(&spi->dev, AD7879_DEVID, spi->irq, pdata,
132 dev_get_platdata(&spi->dev), &ad7879_spi_bus_ops);
133 if (IS_ERR(ts))
134 return PTR_ERR(ts);
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 26323 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 3/3] input: touchscreen: ad7879: add device tree support
@ 2016-01-26 3:28 ` kbuild test robot
0 siblings, 0 replies; 23+ messages in thread
From: kbuild test robot @ 2016-01-26 3:28 UTC (permalink / raw)
Cc: kbuild-all-JC7UmRfGjtg, dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
michael.hennerich-OyLXuOCK7orQT0dZR+AlfA,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ, realmz6-Re5JQEeQqe8AvxtiuMwx3w,
broonie-DgEjT+Ai2ygdnm+yROfE0A, jic23-DgEjT+Ai2ygdnm+yROfE0A,
linux-input-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Stefan Agner
[-- Attachment #1: Type: text/plain, Size: 5977 bytes --]
Hi Stefan,
[auto build test ERROR on input/next]
[also build test ERROR on v4.5-rc1 next-20160125]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Stefan-Agner/input-touchscreen-ad7879-move-header-to-input-subdirectory/20160126-110813
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: x86_64-randconfig-x012-01260845 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All error/warnings (new ones prefixed by >>):
In file included from drivers/input/touchscreen/ad7879-spi.c:14:0:
>> drivers/input/touchscreen/ad7879.h:28:21: warning: 'struct ad7879_platform_data' declared inside parameter list
const struct ad7879_bus_ops *bops);
^
>> drivers/input/touchscreen/ad7879.h:28:21: warning: its scope is only this definition or declaration, which is probably not what you want
drivers/input/touchscreen/ad7879-spi.c: In function 'ad7879_spi_probe':
>> drivers/input/touchscreen/ad7879-spi.c:131:55: error: 'pdata' undeclared (first use in this function)
ts = ad7879_probe(&spi->dev, AD7879_DEVID, spi->irq, pdata,
^
drivers/input/touchscreen/ad7879-spi.c:131:55: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/input/touchscreen/ad7879-spi.c:131:7: error: too many arguments to function 'ad7879_probe'
ts = ad7879_probe(&spi->dev, AD7879_DEVID, spi->irq, pdata,
^
In file included from drivers/input/touchscreen/ad7879-spi.c:14:0:
drivers/input/touchscreen/ad7879.h:26:16: note: declared here
struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned irq,
^
vim +/pdata +131 drivers/input/touchscreen/ad7879-spi.c
8
9 #include <linux/input.h> /* BUS_SPI */
10 #include <linux/pm.h>
11 #include <linux/spi/spi.h>
12 #include <linux/module.h>
13
> 14 #include "ad7879.h"
15
16 #define AD7879_DEVID 0x7A /* AD7879/AD7889 */
17
18 #define MAX_SPI_FREQ_HZ 5000000
19 #define AD7879_CMD_MAGIC 0xE000
20 #define AD7879_CMD_READ (1 << 10)
21 #define AD7879_CMD(reg) (AD7879_CMD_MAGIC | ((reg) & 0xF))
22 #define AD7879_WRITECMD(reg) (AD7879_CMD(reg))
23 #define AD7879_READCMD(reg) (AD7879_CMD(reg) | AD7879_CMD_READ)
24
25 /*
26 * ad7879_read/write are only used for initial setup and for sysfs controls.
27 * The main traffic is done in ad7879_collect().
28 */
29
30 static int ad7879_spi_xfer(struct spi_device *spi,
31 u16 cmd, u8 count, u16 *tx_buf, u16 *rx_buf)
32 {
33 struct spi_message msg;
34 struct spi_transfer *xfers;
35 void *spi_data;
36 u16 *command;
37 u16 *_rx_buf = _rx_buf; /* shut gcc up */
38 u8 idx;
39 int ret;
40
41 xfers = spi_data = kzalloc(sizeof(*xfers) * (count + 2), GFP_KERNEL);
42 if (!spi_data)
43 return -ENOMEM;
44
45 spi_message_init(&msg);
46
47 command = spi_data;
48 command[0] = cmd;
49 if (count == 1) {
50 /* ad7879_spi_{read,write} gave us buf on stack */
51 command[1] = *tx_buf;
52 tx_buf = &command[1];
53 _rx_buf = rx_buf;
54 rx_buf = &command[2];
55 }
56
57 ++xfers;
58 xfers[0].tx_buf = command;
59 xfers[0].len = 2;
60 spi_message_add_tail(&xfers[0], &msg);
61 ++xfers;
62
63 for (idx = 0; idx < count; ++idx) {
64 if (rx_buf)
65 xfers[idx].rx_buf = &rx_buf[idx];
66 if (tx_buf)
67 xfers[idx].tx_buf = &tx_buf[idx];
68 xfers[idx].len = 2;
69 spi_message_add_tail(&xfers[idx], &msg);
70 }
71
72 ret = spi_sync(spi, &msg);
73
74 if (count == 1)
75 _rx_buf[0] = command[2];
76
77 kfree(spi_data);
78
79 return ret;
80 }
81
82 static int ad7879_spi_multi_read(struct device *dev,
83 u8 first_reg, u8 count, u16 *buf)
84 {
85 struct spi_device *spi = to_spi_device(dev);
86
87 return ad7879_spi_xfer(spi, AD7879_READCMD(first_reg), count, NULL, buf);
88 }
89
90 static int ad7879_spi_read(struct device *dev, u8 reg)
91 {
92 struct spi_device *spi = to_spi_device(dev);
93 u16 ret, dummy;
94
95 return ad7879_spi_xfer(spi, AD7879_READCMD(reg), 1, &dummy, &ret) ? : ret;
96 }
97
98 static int ad7879_spi_write(struct device *dev, u8 reg, u16 val)
99 {
100 struct spi_device *spi = to_spi_device(dev);
101 u16 dummy;
102
103 return ad7879_spi_xfer(spi, AD7879_WRITECMD(reg), 1, &val, &dummy);
104 }
105
106 static const struct ad7879_bus_ops ad7879_spi_bus_ops = {
107 .bustype = BUS_SPI,
108 .read = ad7879_spi_read,
109 .multi_read = ad7879_spi_multi_read,
110 .write = ad7879_spi_write,
111 };
112
113 static int ad7879_spi_probe(struct spi_device *spi)
114 {
115 struct ad7879 *ts;
116 int err;
117
118 /* don't exceed max specified SPI CLK frequency */
119 if (spi->max_speed_hz > MAX_SPI_FREQ_HZ) {
120 dev_err(&spi->dev, "SPI CLK %d Hz?\n", spi->max_speed_hz);
121 return -EINVAL;
122 }
123
124 spi->bits_per_word = 16;
125 err = spi_setup(spi);
126 if (err) {
127 dev_dbg(&spi->dev, "spi master doesn't support 16 bits/word\n");
128 return err;
129 }
130
> 131 ts = ad7879_probe(&spi->dev, AD7879_DEVID, spi->irq, pdata,
132 dev_get_platdata(&spi->dev), &ad7879_spi_bus_ops);
133 if (IS_ERR(ts))
134 return PTR_ERR(ts);
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 26323 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 3/3] input: touchscreen: ad7879: add device tree support
@ 2016-01-26 3:57 ` kbuild test robot
0 siblings, 0 replies; 23+ messages in thread
From: kbuild test robot @ 2016-01-26 3:57 UTC (permalink / raw)
To: Stefan Agner
Cc: kbuild-all, dmitry.torokhov, michael.hennerich, robh+dt,
mark.rutland, ijc+devicetree, galak, realmz6, broonie, jic23,
linux-input, devicetree, linux-kernel, Stefan Agner
[-- Attachment #1: Type: text/plain, Size: 6282 bytes --]
Hi Stefan,
[auto build test ERROR on input/next]
[also build test ERROR on v4.5-rc1 next-20160125]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Stefan-Agner/input-touchscreen-ad7879-move-header-to-input-subdirectory/20160126-110813
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: x86_64-randconfig-s4-01261112 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All error/warnings (new ones prefixed by >>):
In file included from drivers/input/touchscreen/ad7879-i2c.c:11:0:
>> drivers/input/touchscreen/ad7879-i2c.c:151:25: error: 'st1232_ts_dt_ids' undeclared here (not in a function)
MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids);
^
include/linux/module.h:223:21: note: in definition of macro 'MODULE_DEVICE_TABLE'
extern const typeof(name) __mod_##type##__##name##_device_table \
^
>> include/linux/module.h:223:27: error: '__mod_of__st1232_ts_dt_ids_device_table' aliased to undefined symbol 'st1232_ts_dt_ids'
extern const typeof(name) __mod_##type##__##name##_device_table \
^
>> drivers/input/touchscreen/ad7879-i2c.c:151:1: note: in expansion of macro 'MODULE_DEVICE_TABLE'
MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids);
^
vim +/st1232_ts_dt_ids +151 drivers/input/touchscreen/ad7879-i2c.c
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9 #include <linux/input.h> /* BUS_I2C */
10 #include <linux/i2c.h>
> 11 #include <linux/module.h>
12 #include <linux/types.h>
13 #include <linux/pm.h>
14 #include <linux/input/ad7879.h>
15
16 #include "ad7879.h"
17
18 #define AD7879_DEVID 0x79 /* AD7879-1/AD7889-1 */
19
20 /* All registers are word-sized.
21 * AD7879 uses a high-byte first convention.
22 */
23 static int ad7879_i2c_read(struct device *dev, u8 reg)
24 {
25 struct i2c_client *client = to_i2c_client(dev);
26
27 return i2c_smbus_read_word_swapped(client, reg);
28 }
29
30 static int ad7879_i2c_multi_read(struct device *dev,
31 u8 first_reg, u8 count, u16 *buf)
32 {
33 struct i2c_client *client = to_i2c_client(dev);
34 u8 idx;
35
36 i2c_smbus_read_i2c_block_data(client, first_reg, count * 2, (u8 *)buf);
37
38 for (idx = 0; idx < count; ++idx)
39 buf[idx] = swab16(buf[idx]);
40
41 return 0;
42 }
43
44 static int ad7879_i2c_write(struct device *dev, u8 reg, u16 val)
45 {
46 struct i2c_client *client = to_i2c_client(dev);
47
48 return i2c_smbus_write_word_swapped(client, reg, val);
49 }
50
51 static const struct ad7879_bus_ops ad7879_i2c_bus_ops = {
52 .bustype = BUS_I2C,
53 .read = ad7879_i2c_read,
54 .multi_read = ad7879_i2c_multi_read,
55 .write = ad7879_i2c_write,
56 };
57
58 static struct ad7879_platform_data *ad7879_parse_dt(struct device *dev)
59 {
60 struct ad7879_platform_data *pdata;
61 struct device_node *np = dev->of_node;
62 int err;
63 u32 tmp;
64
65 if (!np)
66 return NULL;
67
68 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
69
70 if (!pdata)
71 return ERR_PTR(-ENOMEM);
72
73 err = of_property_read_u32(np, "resistance-plate-x", &tmp);
74 if (err) {
75 dev_err(dev, "failed to get resistance-plate-x property\n");
76 return ERR_PTR(err);
77 }
78 pdata->x_plate_ohms = (u16)tmp;
79
80 err = of_property_read_u32(np, "touchscreen-max-pressure", &tmp);
81 if (err) {
82 dev_err(dev, "failed to get touchscreen-max-pressure property\n");
83 return ERR_PTR(err);
84 }
85 pdata->pressure_min = (u16)tmp;
86
87 of_property_read_u8(np, "first-conversion-delay", &pdata->first_conversion_delay);
88 of_property_read_u8(np, "acquisition-time", &pdata->acquisition_time);
89 of_property_read_u8(np, "median-filter-size", &pdata->median);
90 of_property_read_u8(np, "averaging", &pdata->averaging);
91 of_property_read_u8(np, "conversion-interval", &pdata->pen_down_acc_interval);
92
93 pdata->swap_xy = of_property_read_bool(np, "touchscreen-swapped-x-y");
94
95 return pdata;
96 }
97
98 static int ad7879_i2c_probe(struct i2c_client *client,
99 const struct i2c_device_id *id)
100 {
101 struct ad7879_platform_data *pdata;
102 struct ad7879 *ts;
103
104 if (!i2c_check_functionality(client->adapter,
105 I2C_FUNC_SMBUS_WORD_DATA)) {
106 dev_err(&client->dev, "SMBUS Word Data not Supported\n");
107 return -EIO;
108 }
109
110 pdata = dev_get_platdata(&client->dev);
111
112 if (!pdata && IS_ENABLED(CONFIG_OF))
113 pdata = ad7879_parse_dt(&client->dev);
114
115 if (IS_ERR_OR_NULL(pdata)) {
116 dev_err(&client->dev, "Need platform data\n");
117 return PTR_ERR(pdata);
118 }
119
120 ts = ad7879_probe(&client->dev, AD7879_DEVID, client->irq, pdata,
121 &ad7879_i2c_bus_ops);
122 if (IS_ERR(ts))
123 return PTR_ERR(ts);
124
125 i2c_set_clientdata(client, ts);
126
127 return 0;
128 }
129
130 static int ad7879_i2c_remove(struct i2c_client *client)
131 {
132 struct ad7879 *ts = i2c_get_clientdata(client);
133
134 ad7879_remove(ts);
135
136 return 0;
137 }
138
139 static const struct i2c_device_id ad7879_id[] = {
140 { "ad7879", 0 },
141 { "ad7889", 0 },
142 { }
143 };
144 MODULE_DEVICE_TABLE(i2c, ad7879_id);
145
146 #ifdef CONFIG_OF
147 static const struct of_device_id ad7879_dt_ids[] = {
148 { .compatible = "adi,ad7879-1", },
149 { }
150 };
> 151 MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids);
152 #endif
153
154 static struct i2c_driver ad7879_i2c_driver = {
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 23964 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 3/3] input: touchscreen: ad7879: add device tree support
@ 2016-01-26 3:57 ` kbuild test robot
0 siblings, 0 replies; 23+ messages in thread
From: kbuild test robot @ 2016-01-26 3:57 UTC (permalink / raw)
Cc: kbuild-all-JC7UmRfGjtg, dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
michael.hennerich-OyLXuOCK7orQT0dZR+AlfA,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ, realmz6-Re5JQEeQqe8AvxtiuMwx3w,
broonie-DgEjT+Ai2ygdnm+yROfE0A, jic23-DgEjT+Ai2ygdnm+yROfE0A,
linux-input-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Stefan Agner
[-- Attachment #1: Type: text/plain, Size: 6282 bytes --]
Hi Stefan,
[auto build test ERROR on input/next]
[also build test ERROR on v4.5-rc1 next-20160125]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Stefan-Agner/input-touchscreen-ad7879-move-header-to-input-subdirectory/20160126-110813
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: x86_64-randconfig-s4-01261112 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All error/warnings (new ones prefixed by >>):
In file included from drivers/input/touchscreen/ad7879-i2c.c:11:0:
>> drivers/input/touchscreen/ad7879-i2c.c:151:25: error: 'st1232_ts_dt_ids' undeclared here (not in a function)
MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids);
^
include/linux/module.h:223:21: note: in definition of macro 'MODULE_DEVICE_TABLE'
extern const typeof(name) __mod_##type##__##name##_device_table \
^
>> include/linux/module.h:223:27: error: '__mod_of__st1232_ts_dt_ids_device_table' aliased to undefined symbol 'st1232_ts_dt_ids'
extern const typeof(name) __mod_##type##__##name##_device_table \
^
>> drivers/input/touchscreen/ad7879-i2c.c:151:1: note: in expansion of macro 'MODULE_DEVICE_TABLE'
MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids);
^
vim +/st1232_ts_dt_ids +151 drivers/input/touchscreen/ad7879-i2c.c
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9 #include <linux/input.h> /* BUS_I2C */
10 #include <linux/i2c.h>
> 11 #include <linux/module.h>
12 #include <linux/types.h>
13 #include <linux/pm.h>
14 #include <linux/input/ad7879.h>
15
16 #include "ad7879.h"
17
18 #define AD7879_DEVID 0x79 /* AD7879-1/AD7889-1 */
19
20 /* All registers are word-sized.
21 * AD7879 uses a high-byte first convention.
22 */
23 static int ad7879_i2c_read(struct device *dev, u8 reg)
24 {
25 struct i2c_client *client = to_i2c_client(dev);
26
27 return i2c_smbus_read_word_swapped(client, reg);
28 }
29
30 static int ad7879_i2c_multi_read(struct device *dev,
31 u8 first_reg, u8 count, u16 *buf)
32 {
33 struct i2c_client *client = to_i2c_client(dev);
34 u8 idx;
35
36 i2c_smbus_read_i2c_block_data(client, first_reg, count * 2, (u8 *)buf);
37
38 for (idx = 0; idx < count; ++idx)
39 buf[idx] = swab16(buf[idx]);
40
41 return 0;
42 }
43
44 static int ad7879_i2c_write(struct device *dev, u8 reg, u16 val)
45 {
46 struct i2c_client *client = to_i2c_client(dev);
47
48 return i2c_smbus_write_word_swapped(client, reg, val);
49 }
50
51 static const struct ad7879_bus_ops ad7879_i2c_bus_ops = {
52 .bustype = BUS_I2C,
53 .read = ad7879_i2c_read,
54 .multi_read = ad7879_i2c_multi_read,
55 .write = ad7879_i2c_write,
56 };
57
58 static struct ad7879_platform_data *ad7879_parse_dt(struct device *dev)
59 {
60 struct ad7879_platform_data *pdata;
61 struct device_node *np = dev->of_node;
62 int err;
63 u32 tmp;
64
65 if (!np)
66 return NULL;
67
68 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
69
70 if (!pdata)
71 return ERR_PTR(-ENOMEM);
72
73 err = of_property_read_u32(np, "resistance-plate-x", &tmp);
74 if (err) {
75 dev_err(dev, "failed to get resistance-plate-x property\n");
76 return ERR_PTR(err);
77 }
78 pdata->x_plate_ohms = (u16)tmp;
79
80 err = of_property_read_u32(np, "touchscreen-max-pressure", &tmp);
81 if (err) {
82 dev_err(dev, "failed to get touchscreen-max-pressure property\n");
83 return ERR_PTR(err);
84 }
85 pdata->pressure_min = (u16)tmp;
86
87 of_property_read_u8(np, "first-conversion-delay", &pdata->first_conversion_delay);
88 of_property_read_u8(np, "acquisition-time", &pdata->acquisition_time);
89 of_property_read_u8(np, "median-filter-size", &pdata->median);
90 of_property_read_u8(np, "averaging", &pdata->averaging);
91 of_property_read_u8(np, "conversion-interval", &pdata->pen_down_acc_interval);
92
93 pdata->swap_xy = of_property_read_bool(np, "touchscreen-swapped-x-y");
94
95 return pdata;
96 }
97
98 static int ad7879_i2c_probe(struct i2c_client *client,
99 const struct i2c_device_id *id)
100 {
101 struct ad7879_platform_data *pdata;
102 struct ad7879 *ts;
103
104 if (!i2c_check_functionality(client->adapter,
105 I2C_FUNC_SMBUS_WORD_DATA)) {
106 dev_err(&client->dev, "SMBUS Word Data not Supported\n");
107 return -EIO;
108 }
109
110 pdata = dev_get_platdata(&client->dev);
111
112 if (!pdata && IS_ENABLED(CONFIG_OF))
113 pdata = ad7879_parse_dt(&client->dev);
114
115 if (IS_ERR_OR_NULL(pdata)) {
116 dev_err(&client->dev, "Need platform data\n");
117 return PTR_ERR(pdata);
118 }
119
120 ts = ad7879_probe(&client->dev, AD7879_DEVID, client->irq, pdata,
121 &ad7879_i2c_bus_ops);
122 if (IS_ERR(ts))
123 return PTR_ERR(ts);
124
125 i2c_set_clientdata(client, ts);
126
127 return 0;
128 }
129
130 static int ad7879_i2c_remove(struct i2c_client *client)
131 {
132 struct ad7879 *ts = i2c_get_clientdata(client);
133
134 ad7879_remove(ts);
135
136 return 0;
137 }
138
139 static const struct i2c_device_id ad7879_id[] = {
140 { "ad7879", 0 },
141 { "ad7889", 0 },
142 { }
143 };
144 MODULE_DEVICE_TABLE(i2c, ad7879_id);
145
146 #ifdef CONFIG_OF
147 static const struct of_device_id ad7879_dt_ids[] = {
148 { .compatible = "adi,ad7879-1", },
149 { }
150 };
> 151 MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids);
152 #endif
153
154 static struct i2c_driver ad7879_i2c_driver = {
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 23964 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 3/3] input: touchscreen: ad7879: add device tree support
2016-01-26 3:04 ` [PATCH 3/3] input: touchscreen: ad7879: add device tree support Stefan Agner
@ 2016-01-26 4:50 ` kbuild test robot
2016-01-26 3:57 ` kbuild test robot
` (4 subsequent siblings)
5 siblings, 0 replies; 23+ messages in thread
From: kbuild test robot @ 2016-01-26 4:50 UTC (permalink / raw)
To: Stefan Agner
Cc: kbuild-all, dmitry.torokhov, michael.hennerich, robh+dt,
mark.rutland, ijc+devicetree, galak, realmz6, broonie, jic23,
linux-input, devicetree, linux-kernel, Stefan Agner
[-- Attachment #1: Type: text/plain, Size: 1498 bytes --]
Hi Stefan,
[auto build test ERROR on input/next]
[also build test ERROR on v4.5-rc1 next-20160125]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Stefan-Agner/input-touchscreen-ad7879-move-header-to-input-subdirectory/20160126-110813
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: sh-allmodconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sh
All errors (new ones prefixed by >>):
drivers/input/touchscreen/ad7879-i2c.c:151:1: error: 'st1232_ts_dt_ids' undeclared here (not in a function)
>> drivers/input/touchscreen/ad7879-i2c.c:151:1: error: '__mod_of__st1232_ts_dt_ids_device_table' aliased to undefined symbol 'st1232_ts_dt_ids'
vim +151 drivers/input/touchscreen/ad7879-i2c.c
145
146 #ifdef CONFIG_OF
147 static const struct of_device_id ad7879_dt_ids[] = {
148 { .compatible = "adi,ad7879-1", },
149 { }
150 };
> 151 MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids);
152 #endif
153
154 static struct i2c_driver ad7879_i2c_driver = {
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 37673 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 3/3] input: touchscreen: ad7879: add device tree support
@ 2016-01-26 4:50 ` kbuild test robot
0 siblings, 0 replies; 23+ messages in thread
From: kbuild test robot @ 2016-01-26 4:50 UTC (permalink / raw)
Cc: kbuild-all, dmitry.torokhov, michael.hennerich, robh+dt,
mark.rutland, ijc+devicetree, galak, realmz6, broonie, jic23,
linux-input, devicetree, linux-kernel, Stefan Agner
[-- Attachment #1: Type: text/plain, Size: 1498 bytes --]
Hi Stefan,
[auto build test ERROR on input/next]
[also build test ERROR on v4.5-rc1 next-20160125]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Stefan-Agner/input-touchscreen-ad7879-move-header-to-input-subdirectory/20160126-110813
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: sh-allmodconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sh
All errors (new ones prefixed by >>):
drivers/input/touchscreen/ad7879-i2c.c:151:1: error: 'st1232_ts_dt_ids' undeclared here (not in a function)
>> drivers/input/touchscreen/ad7879-i2c.c:151:1: error: '__mod_of__st1232_ts_dt_ids_device_table' aliased to undefined symbol 'st1232_ts_dt_ids'
vim +151 drivers/input/touchscreen/ad7879-i2c.c
145
146 #ifdef CONFIG_OF
147 static const struct of_device_id ad7879_dt_ids[] = {
148 { .compatible = "adi,ad7879-1", },
149 { }
150 };
> 151 MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids);
152 #endif
153
154 static struct i2c_driver ad7879_i2c_driver = {
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 37673 bytes --]
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/3] input: touchscreen: ad7879: fix default x/y axis assignment
2016-01-26 3:04 ` Stefan Agner
@ 2016-01-26 7:58 ` Michael Hennerich
-1 siblings, 0 replies; 23+ messages in thread
From: Michael Hennerich @ 2016-01-26 7:58 UTC (permalink / raw)
To: Stefan Agner, dmitry.torokhov, robh+dt
Cc: mark.rutland, ijc+devicetree, galak, realmz6, broonie, jic23,
linux-input, devicetree, linux-kernel
On 01/26/2016 04:04 AM, Stefan Agner wrote:
> The measurements read from the controller which are temporary stored
> in conversion_data, are interpreted wrong. The first measurement X+
> contains the Y position, and the second measurement Y+ the X position
> (see also Table 11 Register Table in the data sheet).
>
> The problem is already known and a swap option has been introduced:
> commit 6680884a4420 ("Input: ad7879 - add option to correct xy axis")
>
> However, with that the meaning of the new boolean is inverted since
> the underlying values are already swapped. With this change, a true
> in swap_xy actually swaps the two axis.
>
> Signed-off-by: Stefan Agner <stefan@agner.ch>
> ---
> Hi Michael,
>
> It seems that swap_xy is not used in any board which is in mainline,
> hence swap_xy is always false. Therefore, up until now all boards
> actually used swapped axis. However, I doubt that the blackfin boards
> really have those axis swapped, it is probably more likely that the
> userspace calibration took care of it.
>
> However, if they are really swapped, we should set the swap_xy flag
> to 1 for those board...
>
> Do you happen to now what is the case with those boards?
>
Hi Stefan,
I would be hesitant to invert the default behaviour of the driver.
Too many people in the field already using it as it is.
A XY swap can have multiple reasons.
Lot's of small VGA/QVGA TFTs have the option to switch the scan
direction from Landscape to Portrait. In addition you can also rotate
and flip or mirror using VDMA options. So it really depends on the use
case, how the touch panel is mounted to the screen or how it is wired.
Regards,
Michael
> --
> Stefan
>
> drivers/input/touchscreen/ad7879.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
> index a73934b..e290e7b 100644
> --- a/drivers/input/touchscreen/ad7879.c
> +++ b/drivers/input/touchscreen/ad7879.c
> @@ -94,8 +94,8 @@
> #define AD7879_TEMP_BIT (1<<1)
>
> enum {
> - AD7879_SEQ_XPOS = 0,
> - AD7879_SEQ_YPOS = 1,
> + AD7879_SEQ_YPOS = 0,
> + AD7879_SEQ_XPOS = 1,
> AD7879_SEQ_Z1 = 2,
> AD7879_SEQ_Z2 = 3,
> AD7879_NR_SENSE = 4,
>
--
Greetings,
Michael
--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin,
Margaret Seif
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/3] input: touchscreen: ad7879: fix default x/y axis assignment
@ 2016-01-26 7:58 ` Michael Hennerich
0 siblings, 0 replies; 23+ messages in thread
From: Michael Hennerich @ 2016-01-26 7:58 UTC (permalink / raw)
To: Stefan Agner, dmitry.torokhov, robh+dt
Cc: mark.rutland, ijc+devicetree, galak, realmz6, broonie, jic23,
linux-input, devicetree, linux-kernel
On 01/26/2016 04:04 AM, Stefan Agner wrote:
> The measurements read from the controller which are temporary stored
> in conversion_data, are interpreted wrong. The first measurement X+
> contains the Y position, and the second measurement Y+ the X position
> (see also Table 11 Register Table in the data sheet).
>
> The problem is already known and a swap option has been introduced:
> commit 6680884a4420 ("Input: ad7879 - add option to correct xy axis")
>
> However, with that the meaning of the new boolean is inverted since
> the underlying values are already swapped. With this change, a true
> in swap_xy actually swaps the two axis.
>
> Signed-off-by: Stefan Agner <stefan@agner.ch>
> ---
> Hi Michael,
>
> It seems that swap_xy is not used in any board which is in mainline,
> hence swap_xy is always false. Therefore, up until now all boards
> actually used swapped axis. However, I doubt that the blackfin boards
> really have those axis swapped, it is probably more likely that the
> userspace calibration took care of it.
>
> However, if they are really swapped, we should set the swap_xy flag
> to 1 for those board...
>
> Do you happen to now what is the case with those boards?
>
Hi Stefan,
I would be hesitant to invert the default behaviour of the driver.
Too many people in the field already using it as it is.
A XY swap can have multiple reasons.
Lot's of small VGA/QVGA TFTs have the option to switch the scan
direction from Landscape to Portrait. In addition you can also rotate
and flip or mirror using VDMA options. So it really depends on the use
case, how the touch panel is mounted to the screen or how it is wired.
Regards,
Michael
> --
> Stefan
>
> drivers/input/touchscreen/ad7879.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
> index a73934b..e290e7b 100644
> --- a/drivers/input/touchscreen/ad7879.c
> +++ b/drivers/input/touchscreen/ad7879.c
> @@ -94,8 +94,8 @@
> #define AD7879_TEMP_BIT (1<<1)
>
> enum {
> - AD7879_SEQ_XPOS = 0,
> - AD7879_SEQ_YPOS = 1,
> + AD7879_SEQ_YPOS = 0,
> + AD7879_SEQ_XPOS = 1,
> AD7879_SEQ_Z1 = 2,
> AD7879_SEQ_Z2 = 3,
> AD7879_NR_SENSE = 4,
>
--
Greetings,
Michael
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 3/3] input: touchscreen: ad7879: add device tree support
2016-01-26 3:04 ` [PATCH 3/3] input: touchscreen: ad7879: add device tree support Stefan Agner
@ 2016-01-26 8:14 ` Michael Hennerich
2016-01-26 3:57 ` kbuild test robot
` (4 subsequent siblings)
5 siblings, 0 replies; 23+ messages in thread
From: Michael Hennerich @ 2016-01-26 8:14 UTC (permalink / raw)
To: Stefan Agner, dmitry.torokhov, robh+dt
Cc: mark.rutland, ijc+devicetree, galak, realmz6, broonie, jic23,
linux-input, devicetree, linux-kernel
On 01/26/2016 04:04 AM, Stefan Agner wrote:
> Add device tree support for the I2C variant of AD7879 (AD7879-1). This
> allows to specify the touchscreen controller as a I2C client node.
> Most of the options available as platform data are also available as
> device tree properties. Exporting the GPIO is currently not possible
> through device tree.
>
> Signed-off-by: Stefan Agner <stefan@agner.ch>
Hi Stefan,
Thanks for the patch -
There is something similar in our tree but I forgot to send it mainline
a long time ago.
https://github.com/analogdevicesinc/linux/commit/69b16d4b616a4bbe9001d3f67d3ff54f3deb85ce
There are some build issues can you have a look?
I also don't understand why "exporting the GPIO is not possible through
device tree"?
Can you explain?
Regards,
Michael
> ---
> .../bindings/input/touchscreen/ad7879-i2c.txt | 47 ++++++++++++++++
> drivers/input/touchscreen/ad7879-i2c.c | 63 +++++++++++++++++++++-
> drivers/input/touchscreen/ad7879-spi.c | 3 +-
> drivers/input/touchscreen/ad7879.c | 2 +-
> drivers/input/touchscreen/ad7879.h | 1 +
> 5 files changed, 113 insertions(+), 3 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
>
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt b/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
> new file mode 100644
> index 0000000..bf169a2
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
> @@ -0,0 +1,47 @@
> +* Analog Devices AD7879-1/AD7889-1 touchscreen interface (I2C)
> +
> +Required properties:
> +- compatible: must be "adi,ad7879-1"
> +- reg: i2c slave address
> +- interrupt-parent: the phandle for the interrupt controller
> +- interrupts: touch controller interrupt
> +- resistance-plate-x : total resistance of X-plate (for pressure
> + calculation)
> +- touchscreen-max-pressure : maximum reported pressure
> +- touchscreen-swapped-x-y : X and Y axis are swapped (boolean)
> + Swapping is done after inverting the axis
> +Optional properties:
> +- first-conversion-delay : 0-12 in 128us steps (starting with 128us)
> + 13: 2.560ms
> + 14: 3.584ms
> + 15: 4.096ms
> +- acquisition-time : 0: 2us
> + 1: 4us
> + 2: 8us
> + 3: 16us
> +- median-filter-size : 0: disabled
> + 1: 4 measurements
> + 2: 8 measurements
> + 3: 16 measurements
> +- averaging : 0: 2 middle values (1 if median disabled)
> + 1: 4 middle values
> + 2: 8 middle values
> + 3: 16 values
> +- conversion-interval: : 0: convert one time only
> + 1-255: 515us + val * 35us (up to 9.440ms)
> +
> +Example:
> +
> + ad7879@2c {
> + compatible = "adi,ad7879-1";
> + reg = <0x2c>;
> + interrupt-parent = <&gpio1>;
> + interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
> + resistance-plate-x = <120>;
> + touchscreen-max-pressure = <4096>;
> + first-conversion-delay = /bits/ 8 <3>;
> + acquisition-time = /bits/ 8 <1>;
> + median-filter-size = /bits/ 8 <2>;
> + averaging = /bits/ 8 <1>;
> + conversion-interval = /bits/ 8 <255>;
> + };
> diff --git a/drivers/input/touchscreen/ad7879-i2c.c b/drivers/input/touchscreen/ad7879-i2c.c
> index d66962c..08a2c9a 100644
> --- a/drivers/input/touchscreen/ad7879-i2c.c
> +++ b/drivers/input/touchscreen/ad7879-i2c.c
> @@ -11,6 +11,7 @@
> #include <linux/module.h>
> #include <linux/types.h>
> #include <linux/pm.h>
> +#include <linux/input/ad7879.h>
>
> #include "ad7879.h"
>
> @@ -54,9 +55,50 @@ static const struct ad7879_bus_ops ad7879_i2c_bus_ops = {
> .write = ad7879_i2c_write,
> };
>
> +static struct ad7879_platform_data *ad7879_parse_dt(struct device *dev)
> +{
> + struct ad7879_platform_data *pdata;
> + struct device_node *np = dev->of_node;
> + int err;
> + u32 tmp;
> +
> + if (!np)
> + return NULL;
> +
> + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> +
> + if (!pdata)
> + return ERR_PTR(-ENOMEM);
> +
> + err = of_property_read_u32(np, "resistance-plate-x", &tmp);
> + if (err) {
> + dev_err(dev, "failed to get resistance-plate-x property\n");
> + return ERR_PTR(err);
> + }
> + pdata->x_plate_ohms = (u16)tmp;
> +
> + err = of_property_read_u32(np, "touchscreen-max-pressure", &tmp);
> + if (err) {
> + dev_err(dev, "failed to get touchscreen-max-pressure property\n");
> + return ERR_PTR(err);
> + }
> + pdata->pressure_min = (u16)tmp;
> +
> + of_property_read_u8(np, "first-conversion-delay", &pdata->first_conversion_delay);
> + of_property_read_u8(np, "acquisition-time", &pdata->acquisition_time);
> + of_property_read_u8(np, "median-filter-size", &pdata->median);
> + of_property_read_u8(np, "averaging", &pdata->averaging);
> + of_property_read_u8(np, "conversion-interval", &pdata->pen_down_acc_interval);
> +
> + pdata->swap_xy = of_property_read_bool(np, "touchscreen-swapped-x-y");
> +
> + return pdata;
> +}
> +
> static int ad7879_i2c_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> + struct ad7879_platform_data *pdata;
> struct ad7879 *ts;
>
> if (!i2c_check_functionality(client->adapter,
> @@ -65,7 +107,17 @@ static int ad7879_i2c_probe(struct i2c_client *client,
> return -EIO;
> }
>
> - ts = ad7879_probe(&client->dev, AD7879_DEVID, client->irq,
> + pdata = dev_get_platdata(&client->dev);
> +
> + if (!pdata && IS_ENABLED(CONFIG_OF))
> + pdata = ad7879_parse_dt(&client->dev);
> +
> + if (IS_ERR_OR_NULL(pdata)) {
> + dev_err(&client->dev, "Need platform data\n");
> + return PTR_ERR(pdata);
> + }
> +
> + ts = ad7879_probe(&client->dev, AD7879_DEVID, client->irq, pdata,
> &ad7879_i2c_bus_ops);
> if (IS_ERR(ts))
> return PTR_ERR(ts);
> @@ -91,10 +143,19 @@ static const struct i2c_device_id ad7879_id[] = {
> };
> MODULE_DEVICE_TABLE(i2c, ad7879_id);
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id ad7879_dt_ids[] = {
> + { .compatible = "adi,ad7879-1", },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids);
> +#endif
> +
> static struct i2c_driver ad7879_i2c_driver = {
> .driver = {
> .name = "ad7879",
> .pm = &ad7879_pm_ops,
> + .of_match_table = of_match_ptr(ad7879_dt_ids),
> },
> .probe = ad7879_i2c_probe,
> .remove = ad7879_i2c_remove,
> diff --git a/drivers/input/touchscreen/ad7879-spi.c b/drivers/input/touchscreen/ad7879-spi.c
> index 48033c2..8ebe604 100644
> --- a/drivers/input/touchscreen/ad7879-spi.c
> +++ b/drivers/input/touchscreen/ad7879-spi.c
> @@ -128,7 +128,8 @@ static int ad7879_spi_probe(struct spi_device *spi)
> return err;
> }
>
> - ts = ad7879_probe(&spi->dev, AD7879_DEVID, spi->irq, &ad7879_spi_bus_ops);
> + ts = ad7879_probe(&spi->dev, AD7879_DEVID, spi->irq, pdata,
> + dev_get_platdata(&spi->dev), &ad7879_spi_bus_ops);
> if (IS_ERR(ts))
> return PTR_ERR(ts);
>
> diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
> index e290e7b..e763c77 100644
> --- a/drivers/input/touchscreen/ad7879.c
> +++ b/drivers/input/touchscreen/ad7879.c
> @@ -486,9 +486,9 @@ static inline void ad7879_gpio_remove(struct ad7879 *ts)
> #endif
>
> struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq,
> + struct ad7879_platform_data *pdata,
> const struct ad7879_bus_ops *bops)
> {
> - struct ad7879_platform_data *pdata = dev_get_platdata(dev);
> struct ad7879 *ts;
> struct input_dev *input_dev;
> int err;
> diff --git a/drivers/input/touchscreen/ad7879.h b/drivers/input/touchscreen/ad7879.h
> index 6fd13c4..fa363a0 100644
> --- a/drivers/input/touchscreen/ad7879.h
> +++ b/drivers/input/touchscreen/ad7879.h
> @@ -24,6 +24,7 @@ struct ad7879_bus_ops {
> extern const struct dev_pm_ops ad7879_pm_ops;
>
> struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned irq,
> + struct ad7879_platform_data *pdata,
> const struct ad7879_bus_ops *bops);
> void ad7879_remove(struct ad7879 *);
>
>
--
Greetings,
Michael
--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin,
Margaret Seif
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 3/3] input: touchscreen: ad7879: add device tree support
@ 2016-01-26 8:14 ` Michael Hennerich
0 siblings, 0 replies; 23+ messages in thread
From: Michael Hennerich @ 2016-01-26 8:14 UTC (permalink / raw)
To: Stefan Agner, dmitry.torokhov, robh+dt
Cc: mark.rutland, ijc+devicetree, galak, realmz6, broonie, jic23,
linux-input, devicetree, linux-kernel
On 01/26/2016 04:04 AM, Stefan Agner wrote:
> Add device tree support for the I2C variant of AD7879 (AD7879-1). This
> allows to specify the touchscreen controller as a I2C client node.
> Most of the options available as platform data are also available as
> device tree properties. Exporting the GPIO is currently not possible
> through device tree.
>
> Signed-off-by: Stefan Agner <stefan@agner.ch>
Hi Stefan,
Thanks for the patch -
There is something similar in our tree but I forgot to send it mainline
a long time ago.
https://github.com/analogdevicesinc/linux/commit/69b16d4b616a4bbe9001d3f67d3ff54f3deb85ce
There are some build issues can you have a look?
I also don't understand why "exporting the GPIO is not possible through
device tree"?
Can you explain?
Regards,
Michael
> ---
> .../bindings/input/touchscreen/ad7879-i2c.txt | 47 ++++++++++++++++
> drivers/input/touchscreen/ad7879-i2c.c | 63 +++++++++++++++++++++-
> drivers/input/touchscreen/ad7879-spi.c | 3 +-
> drivers/input/touchscreen/ad7879.c | 2 +-
> drivers/input/touchscreen/ad7879.h | 1 +
> 5 files changed, 113 insertions(+), 3 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
>
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt b/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
> new file mode 100644
> index 0000000..bf169a2
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
> @@ -0,0 +1,47 @@
> +* Analog Devices AD7879-1/AD7889-1 touchscreen interface (I2C)
> +
> +Required properties:
> +- compatible: must be "adi,ad7879-1"
> +- reg: i2c slave address
> +- interrupt-parent: the phandle for the interrupt controller
> +- interrupts: touch controller interrupt
> +- resistance-plate-x : total resistance of X-plate (for pressure
> + calculation)
> +- touchscreen-max-pressure : maximum reported pressure
> +- touchscreen-swapped-x-y : X and Y axis are swapped (boolean)
> + Swapping is done after inverting the axis
> +Optional properties:
> +- first-conversion-delay : 0-12 in 128us steps (starting with 128us)
> + 13: 2.560ms
> + 14: 3.584ms
> + 15: 4.096ms
> +- acquisition-time : 0: 2us
> + 1: 4us
> + 2: 8us
> + 3: 16us
> +- median-filter-size : 0: disabled
> + 1: 4 measurements
> + 2: 8 measurements
> + 3: 16 measurements
> +- averaging : 0: 2 middle values (1 if median disabled)
> + 1: 4 middle values
> + 2: 8 middle values
> + 3: 16 values
> +- conversion-interval: : 0: convert one time only
> + 1-255: 515us + val * 35us (up to 9.440ms)
> +
> +Example:
> +
> + ad7879@2c {
> + compatible = "adi,ad7879-1";
> + reg = <0x2c>;
> + interrupt-parent = <&gpio1>;
> + interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
> + resistance-plate-x = <120>;
> + touchscreen-max-pressure = <4096>;
> + first-conversion-delay = /bits/ 8 <3>;
> + acquisition-time = /bits/ 8 <1>;
> + median-filter-size = /bits/ 8 <2>;
> + averaging = /bits/ 8 <1>;
> + conversion-interval = /bits/ 8 <255>;
> + };
> diff --git a/drivers/input/touchscreen/ad7879-i2c.c b/drivers/input/touchscreen/ad7879-i2c.c
> index d66962c..08a2c9a 100644
> --- a/drivers/input/touchscreen/ad7879-i2c.c
> +++ b/drivers/input/touchscreen/ad7879-i2c.c
> @@ -11,6 +11,7 @@
> #include <linux/module.h>
> #include <linux/types.h>
> #include <linux/pm.h>
> +#include <linux/input/ad7879.h>
>
> #include "ad7879.h"
>
> @@ -54,9 +55,50 @@ static const struct ad7879_bus_ops ad7879_i2c_bus_ops = {
> .write = ad7879_i2c_write,
> };
>
> +static struct ad7879_platform_data *ad7879_parse_dt(struct device *dev)
> +{
> + struct ad7879_platform_data *pdata;
> + struct device_node *np = dev->of_node;
> + int err;
> + u32 tmp;
> +
> + if (!np)
> + return NULL;
> +
> + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> +
> + if (!pdata)
> + return ERR_PTR(-ENOMEM);
> +
> + err = of_property_read_u32(np, "resistance-plate-x", &tmp);
> + if (err) {
> + dev_err(dev, "failed to get resistance-plate-x property\n");
> + return ERR_PTR(err);
> + }
> + pdata->x_plate_ohms = (u16)tmp;
> +
> + err = of_property_read_u32(np, "touchscreen-max-pressure", &tmp);
> + if (err) {
> + dev_err(dev, "failed to get touchscreen-max-pressure property\n");
> + return ERR_PTR(err);
> + }
> + pdata->pressure_min = (u16)tmp;
> +
> + of_property_read_u8(np, "first-conversion-delay", &pdata->first_conversion_delay);
> + of_property_read_u8(np, "acquisition-time", &pdata->acquisition_time);
> + of_property_read_u8(np, "median-filter-size", &pdata->median);
> + of_property_read_u8(np, "averaging", &pdata->averaging);
> + of_property_read_u8(np, "conversion-interval", &pdata->pen_down_acc_interval);
> +
> + pdata->swap_xy = of_property_read_bool(np, "touchscreen-swapped-x-y");
> +
> + return pdata;
> +}
> +
> static int ad7879_i2c_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> + struct ad7879_platform_data *pdata;
> struct ad7879 *ts;
>
> if (!i2c_check_functionality(client->adapter,
> @@ -65,7 +107,17 @@ static int ad7879_i2c_probe(struct i2c_client *client,
> return -EIO;
> }
>
> - ts = ad7879_probe(&client->dev, AD7879_DEVID, client->irq,
> + pdata = dev_get_platdata(&client->dev);
> +
> + if (!pdata && IS_ENABLED(CONFIG_OF))
> + pdata = ad7879_parse_dt(&client->dev);
> +
> + if (IS_ERR_OR_NULL(pdata)) {
> + dev_err(&client->dev, "Need platform data\n");
> + return PTR_ERR(pdata);
> + }
> +
> + ts = ad7879_probe(&client->dev, AD7879_DEVID, client->irq, pdata,
> &ad7879_i2c_bus_ops);
> if (IS_ERR(ts))
> return PTR_ERR(ts);
> @@ -91,10 +143,19 @@ static const struct i2c_device_id ad7879_id[] = {
> };
> MODULE_DEVICE_TABLE(i2c, ad7879_id);
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id ad7879_dt_ids[] = {
> + { .compatible = "adi,ad7879-1", },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids);
> +#endif
> +
> static struct i2c_driver ad7879_i2c_driver = {
> .driver = {
> .name = "ad7879",
> .pm = &ad7879_pm_ops,
> + .of_match_table = of_match_ptr(ad7879_dt_ids),
> },
> .probe = ad7879_i2c_probe,
> .remove = ad7879_i2c_remove,
> diff --git a/drivers/input/touchscreen/ad7879-spi.c b/drivers/input/touchscreen/ad7879-spi.c
> index 48033c2..8ebe604 100644
> --- a/drivers/input/touchscreen/ad7879-spi.c
> +++ b/drivers/input/touchscreen/ad7879-spi.c
> @@ -128,7 +128,8 @@ static int ad7879_spi_probe(struct spi_device *spi)
> return err;
> }
>
> - ts = ad7879_probe(&spi->dev, AD7879_DEVID, spi->irq, &ad7879_spi_bus_ops);
> + ts = ad7879_probe(&spi->dev, AD7879_DEVID, spi->irq, pdata,
> + dev_get_platdata(&spi->dev), &ad7879_spi_bus_ops);
> if (IS_ERR(ts))
> return PTR_ERR(ts);
>
> diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
> index e290e7b..e763c77 100644
> --- a/drivers/input/touchscreen/ad7879.c
> +++ b/drivers/input/touchscreen/ad7879.c
> @@ -486,9 +486,9 @@ static inline void ad7879_gpio_remove(struct ad7879 *ts)
> #endif
>
> struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq,
> + struct ad7879_platform_data *pdata,
> const struct ad7879_bus_ops *bops)
> {
> - struct ad7879_platform_data *pdata = dev_get_platdata(dev);
> struct ad7879 *ts;
> struct input_dev *input_dev;
> int err;
> diff --git a/drivers/input/touchscreen/ad7879.h b/drivers/input/touchscreen/ad7879.h
> index 6fd13c4..fa363a0 100644
> --- a/drivers/input/touchscreen/ad7879.h
> +++ b/drivers/input/touchscreen/ad7879.h
> @@ -24,6 +24,7 @@ struct ad7879_bus_ops {
> extern const struct dev_pm_ops ad7879_pm_ops;
>
> struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned irq,
> + struct ad7879_platform_data *pdata,
> const struct ad7879_bus_ops *bops);
> void ad7879_remove(struct ad7879 *);
>
>
--
Greetings,
Michael
--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin,
Margaret Seif
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/3] input: touchscreen: ad7879: fix default x/y axis assignment
@ 2016-01-26 17:04 ` Stefan Agner
0 siblings, 0 replies; 23+ messages in thread
From: Stefan Agner @ 2016-01-26 17:04 UTC (permalink / raw)
To: michael.hennerich
Cc: dmitry.torokhov, robh+dt, mark.rutland, ijc+devicetree, galak,
realmz6, broonie, jic23, linux-input, devicetree, linux-kernel
On 2016-01-25 23:58, Michael Hennerich wrote:
> On 01/26/2016 04:04 AM, Stefan Agner wrote:
>> The measurements read from the controller which are temporary stored
>> in conversion_data, are interpreted wrong. The first measurement X+
>> contains the Y position, and the second measurement Y+ the X position
>> (see also Table 11 Register Table in the data sheet).
>>
>> The problem is already known and a swap option has been introduced:
>> commit 6680884a4420 ("Input: ad7879 - add option to correct xy axis")
>>
>> However, with that the meaning of the new boolean is inverted since
>> the underlying values are already swapped. With this change, a true
>> in swap_xy actually swaps the two axis.
>>
>> Signed-off-by: Stefan Agner <stefan@agner.ch>
>> ---
>> Hi Michael,
>>
>> It seems that swap_xy is not used in any board which is in mainline,
>> hence swap_xy is always false. Therefore, up until now all boards
>> actually used swapped axis. However, I doubt that the blackfin boards
>> really have those axis swapped, it is probably more likely that the
>> userspace calibration took care of it.
>>
>> However, if they are really swapped, we should set the swap_xy flag
>> to 1 for those board...
>>
>> Do you happen to now what is the case with those boards?
>>
>
>
> Hi Stefan,
>
> I would be hesitant to invert the default behaviour of the driver.
> Too many people in the field already using it as it is.
Afaik, we should be able to change in-kernel API's (especially if they
are wrong) since we do not guarantee any API...
>
> A XY swap can have multiple reasons.
>
> Lot's of small VGA/QVGA TFTs have the option to switch the scan
> direction from Landscape to Portrait. In addition you can also rotate
> and flip or mirror using VDMA options. So it really depends on the use
> case, how the touch panel is mounted to the screen or how it is wired.
Ok, I see the reason for that functionality.
I am mainly concerned about the new DT bindings. The touchscreen binding
documents specify touchscreen-swapped-x-y, see:
https://www.kernel.org/doc/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
I would like to make sure that this property is really swapping axis
(and not necessary if the hardware is implemented according to the
datasheet...)
We could also implement a workaround to keep the platform data behavior
as is (invert the swap_xy flag)...
--
Stefan
>> --
>> Stefan
>>
>> drivers/input/touchscreen/ad7879.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
>> index a73934b..e290e7b 100644
>> --- a/drivers/input/touchscreen/ad7879.c
>> +++ b/drivers/input/touchscreen/ad7879.c
>> @@ -94,8 +94,8 @@
>> #define AD7879_TEMP_BIT (1<<1)
>>
>> enum {
>> - AD7879_SEQ_XPOS = 0,
>> - AD7879_SEQ_YPOS = 1,
>> + AD7879_SEQ_YPOS = 0,
>> + AD7879_SEQ_XPOS = 1,
>> AD7879_SEQ_Z1 = 2,
>> AD7879_SEQ_Z2 = 3,
>> AD7879_NR_SENSE = 4,
>>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/3] input: touchscreen: ad7879: fix default x/y axis assignment
@ 2016-01-26 17:04 ` Stefan Agner
0 siblings, 0 replies; 23+ messages in thread
From: Stefan Agner @ 2016-01-26 17:04 UTC (permalink / raw)
To: michael.hennerich-OyLXuOCK7orQT0dZR+AlfA
Cc: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ, realmz6-Re5JQEeQqe8AvxtiuMwx3w,
broonie-DgEjT+Ai2ygdnm+yROfE0A, jic23-DgEjT+Ai2ygdnm+yROfE0A,
linux-input-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
On 2016-01-25 23:58, Michael Hennerich wrote:
> On 01/26/2016 04:04 AM, Stefan Agner wrote:
>> The measurements read from the controller which are temporary stored
>> in conversion_data, are interpreted wrong. The first measurement X+
>> contains the Y position, and the second measurement Y+ the X position
>> (see also Table 11 Register Table in the data sheet).
>>
>> The problem is already known and a swap option has been introduced:
>> commit 6680884a4420 ("Input: ad7879 - add option to correct xy axis")
>>
>> However, with that the meaning of the new boolean is inverted since
>> the underlying values are already swapped. With this change, a true
>> in swap_xy actually swaps the two axis.
>>
>> Signed-off-by: Stefan Agner <stefan-XLVq0VzYD2Y@public.gmane.org>
>> ---
>> Hi Michael,
>>
>> It seems that swap_xy is not used in any board which is in mainline,
>> hence swap_xy is always false. Therefore, up until now all boards
>> actually used swapped axis. However, I doubt that the blackfin boards
>> really have those axis swapped, it is probably more likely that the
>> userspace calibration took care of it.
>>
>> However, if they are really swapped, we should set the swap_xy flag
>> to 1 for those board...
>>
>> Do you happen to now what is the case with those boards?
>>
>
>
> Hi Stefan,
>
> I would be hesitant to invert the default behaviour of the driver.
> Too many people in the field already using it as it is.
Afaik, we should be able to change in-kernel API's (especially if they
are wrong) since we do not guarantee any API...
>
> A XY swap can have multiple reasons.
>
> Lot's of small VGA/QVGA TFTs have the option to switch the scan
> direction from Landscape to Portrait. In addition you can also rotate
> and flip or mirror using VDMA options. So it really depends on the use
> case, how the touch panel is mounted to the screen or how it is wired.
Ok, I see the reason for that functionality.
I am mainly concerned about the new DT bindings. The touchscreen binding
documents specify touchscreen-swapped-x-y, see:
https://www.kernel.org/doc/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
I would like to make sure that this property is really swapping axis
(and not necessary if the hardware is implemented according to the
datasheet...)
We could also implement a workaround to keep the platform data behavior
as is (invert the swap_xy flag)...
--
Stefan
>> --
>> Stefan
>>
>> drivers/input/touchscreen/ad7879.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
>> index a73934b..e290e7b 100644
>> --- a/drivers/input/touchscreen/ad7879.c
>> +++ b/drivers/input/touchscreen/ad7879.c
>> @@ -94,8 +94,8 @@
>> #define AD7879_TEMP_BIT (1<<1)
>>
>> enum {
>> - AD7879_SEQ_XPOS = 0,
>> - AD7879_SEQ_YPOS = 1,
>> + AD7879_SEQ_YPOS = 0,
>> + AD7879_SEQ_XPOS = 1,
>> AD7879_SEQ_Z1 = 2,
>> AD7879_SEQ_Z2 = 3,
>> AD7879_NR_SENSE = 4,
>>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 3/3] input: touchscreen: ad7879: add device tree support
2016-01-26 8:14 ` Michael Hennerich
(?)
@ 2016-01-26 17:10 ` Stefan Agner
-1 siblings, 0 replies; 23+ messages in thread
From: Stefan Agner @ 2016-01-26 17:10 UTC (permalink / raw)
To: michael.hennerich
Cc: dmitry.torokhov, robh+dt, mark.rutland, ijc+devicetree, galak,
realmz6, broonie, jic23, linux-input, devicetree, linux-kernel
On 2016-01-26 00:14, Michael Hennerich wrote:
> On 01/26/2016 04:04 AM, Stefan Agner wrote:
>> Add device tree support for the I2C variant of AD7879 (AD7879-1). This
>> allows to specify the touchscreen controller as a I2C client node.
>> Most of the options available as platform data are also available as
>> device tree properties. Exporting the GPIO is currently not possible
>> through device tree.
>>
>> Signed-off-by: Stefan Agner <stefan@agner.ch>
>
>
> Hi Stefan,
>
> Thanks for the patch -
> There is something similar in our tree but I forgot to send it
> mainline a long time ago.
>
> https://github.com/analogdevicesinc/linux/commit/69b16d4b616a4bbe9001d3f67d3ff54f3deb85ce
Yeah I saw that patch. I tried to use the standard touchscreen
properties where applicable.
Also, my implementation is currently only for I2C. However, when I now
think about it, I might as well move my code into ad7879.c which would
enable to use the same bindings for SPI devices too.
>
> There are some build issues can you have a look?
Yeah I saw, shame on me. Will fix them.
>
> I also don't understand why "exporting the GPIO is not possible
> through device tree"?
>
> Can you explain?
I should have written "not implemented" instead of "not possible".
To implement proper device tree GPIO bindings it would need some more
changes. I did not look into that, hence the current device tree
bindings do not allow to enable the GPIO functionality.
--
Stefan
>
> Regards,
> Michael
>
>
>> ---
>> .../bindings/input/touchscreen/ad7879-i2c.txt | 47 ++++++++++++++++
>> drivers/input/touchscreen/ad7879-i2c.c | 63 +++++++++++++++++++++-
>> drivers/input/touchscreen/ad7879-spi.c | 3 +-
>> drivers/input/touchscreen/ad7879.c | 2 +-
>> drivers/input/touchscreen/ad7879.h | 1 +
>> 5 files changed, 113 insertions(+), 3 deletions(-)
>> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
>>
>> diff --git a/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt b/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
>> new file mode 100644
>> index 0000000..bf169a2
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
>> @@ -0,0 +1,47 @@
>> +* Analog Devices AD7879-1/AD7889-1 touchscreen interface (I2C)
>> +
>> +Required properties:
>> +- compatible: must be "adi,ad7879-1"
>> +- reg: i2c slave address
>> +- interrupt-parent: the phandle for the interrupt controller
>> +- interrupts: touch controller interrupt
>> +- resistance-plate-x : total resistance of X-plate (for pressure
>> + calculation)
>> +- touchscreen-max-pressure : maximum reported pressure
>> +- touchscreen-swapped-x-y : X and Y axis are swapped (boolean)
>> + Swapping is done after inverting the axis
>> +Optional properties:
>> +- first-conversion-delay : 0-12 in 128us steps (starting with 128us)
>> + 13: 2.560ms
>> + 14: 3.584ms
>> + 15: 4.096ms
>> +- acquisition-time : 0: 2us
>> + 1: 4us
>> + 2: 8us
>> + 3: 16us
>> +- median-filter-size : 0: disabled
>> + 1: 4 measurements
>> + 2: 8 measurements
>> + 3: 16 measurements
>> +- averaging : 0: 2 middle values (1 if median disabled)
>> + 1: 4 middle values
>> + 2: 8 middle values
>> + 3: 16 values
>> +- conversion-interval: : 0: convert one time only
>> + 1-255: 515us + val * 35us (up to 9.440ms)
>> +
>> +Example:
>> +
>> + ad7879@2c {
>> + compatible = "adi,ad7879-1";
>> + reg = <0x2c>;
>> + interrupt-parent = <&gpio1>;
>> + interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
>> + resistance-plate-x = <120>;
>> + touchscreen-max-pressure = <4096>;
>> + first-conversion-delay = /bits/ 8 <3>;
>> + acquisition-time = /bits/ 8 <1>;
>> + median-filter-size = /bits/ 8 <2>;
>> + averaging = /bits/ 8 <1>;
>> + conversion-interval = /bits/ 8 <255>;
>> + };
>> diff --git a/drivers/input/touchscreen/ad7879-i2c.c b/drivers/input/touchscreen/ad7879-i2c.c
>> index d66962c..08a2c9a 100644
>> --- a/drivers/input/touchscreen/ad7879-i2c.c
>> +++ b/drivers/input/touchscreen/ad7879-i2c.c
>> @@ -11,6 +11,7 @@
>> #include <linux/module.h>
>> #include <linux/types.h>
>> #include <linux/pm.h>
>> +#include <linux/input/ad7879.h>
>>
>> #include "ad7879.h"
>>
>> @@ -54,9 +55,50 @@ static const struct ad7879_bus_ops ad7879_i2c_bus_ops = {
>> .write = ad7879_i2c_write,
>> };
>>
>> +static struct ad7879_platform_data *ad7879_parse_dt(struct device *dev)
>> +{
>> + struct ad7879_platform_data *pdata;
>> + struct device_node *np = dev->of_node;
>> + int err;
>> + u32 tmp;
>> +
>> + if (!np)
>> + return NULL;
>> +
>> + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
>> +
>> + if (!pdata)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + err = of_property_read_u32(np, "resistance-plate-x", &tmp);
>> + if (err) {
>> + dev_err(dev, "failed to get resistance-plate-x property\n");
>> + return ERR_PTR(err);
>> + }
>> + pdata->x_plate_ohms = (u16)tmp;
>> +
>> + err = of_property_read_u32(np, "touchscreen-max-pressure", &tmp);
>> + if (err) {
>> + dev_err(dev, "failed to get touchscreen-max-pressure property\n");
>> + return ERR_PTR(err);
>> + }
>> + pdata->pressure_min = (u16)tmp;
>> +
>> + of_property_read_u8(np, "first-conversion-delay", &pdata->first_conversion_delay);
>> + of_property_read_u8(np, "acquisition-time", &pdata->acquisition_time);
>> + of_property_read_u8(np, "median-filter-size", &pdata->median);
>> + of_property_read_u8(np, "averaging", &pdata->averaging);
>> + of_property_read_u8(np, "conversion-interval", &pdata->pen_down_acc_interval);
>> +
>> + pdata->swap_xy = of_property_read_bool(np, "touchscreen-swapped-x-y");
>> +
>> + return pdata;
>> +}
>> +
>> static int ad7879_i2c_probe(struct i2c_client *client,
>> const struct i2c_device_id *id)
>> {
>> + struct ad7879_platform_data *pdata;
>> struct ad7879 *ts;
>>
>> if (!i2c_check_functionality(client->adapter,
>> @@ -65,7 +107,17 @@ static int ad7879_i2c_probe(struct i2c_client *client,
>> return -EIO;
>> }
>>
>> - ts = ad7879_probe(&client->dev, AD7879_DEVID, client->irq,
>> + pdata = dev_get_platdata(&client->dev);
>> +
>> + if (!pdata && IS_ENABLED(CONFIG_OF))
>> + pdata = ad7879_parse_dt(&client->dev);
>> +
>> + if (IS_ERR_OR_NULL(pdata)) {
>> + dev_err(&client->dev, "Need platform data\n");
>> + return PTR_ERR(pdata);
>> + }
>> +
>> + ts = ad7879_probe(&client->dev, AD7879_DEVID, client->irq, pdata,
>> &ad7879_i2c_bus_ops);
>> if (IS_ERR(ts))
>> return PTR_ERR(ts);
>> @@ -91,10 +143,19 @@ static const struct i2c_device_id ad7879_id[] = {
>> };
>> MODULE_DEVICE_TABLE(i2c, ad7879_id);
>>
>> +#ifdef CONFIG_OF
>> +static const struct of_device_id ad7879_dt_ids[] = {
>> + { .compatible = "adi,ad7879-1", },
>> + { }
>> +};
>> +MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids);
>> +#endif
>> +
>> static struct i2c_driver ad7879_i2c_driver = {
>> .driver = {
>> .name = "ad7879",
>> .pm = &ad7879_pm_ops,
>> + .of_match_table = of_match_ptr(ad7879_dt_ids),
>> },
>> .probe = ad7879_i2c_probe,
>> .remove = ad7879_i2c_remove,
>> diff --git a/drivers/input/touchscreen/ad7879-spi.c b/drivers/input/touchscreen/ad7879-spi.c
>> index 48033c2..8ebe604 100644
>> --- a/drivers/input/touchscreen/ad7879-spi.c
>> +++ b/drivers/input/touchscreen/ad7879-spi.c
>> @@ -128,7 +128,8 @@ static int ad7879_spi_probe(struct spi_device *spi)
>> return err;
>> }
>>
>> - ts = ad7879_probe(&spi->dev, AD7879_DEVID, spi->irq, &ad7879_spi_bus_ops);
>> + ts = ad7879_probe(&spi->dev, AD7879_DEVID, spi->irq, pdata,
>> + dev_get_platdata(&spi->dev), &ad7879_spi_bus_ops);
>> if (IS_ERR(ts))
>> return PTR_ERR(ts);
>>
>> diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
>> index e290e7b..e763c77 100644
>> --- a/drivers/input/touchscreen/ad7879.c
>> +++ b/drivers/input/touchscreen/ad7879.c
>> @@ -486,9 +486,9 @@ static inline void ad7879_gpio_remove(struct ad7879 *ts)
>> #endif
>>
>> struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq,
>> + struct ad7879_platform_data *pdata,
>> const struct ad7879_bus_ops *bops)
>> {
>> - struct ad7879_platform_data *pdata = dev_get_platdata(dev);
>> struct ad7879 *ts;
>> struct input_dev *input_dev;
>> int err;
>> diff --git a/drivers/input/touchscreen/ad7879.h b/drivers/input/touchscreen/ad7879.h
>> index 6fd13c4..fa363a0 100644
>> --- a/drivers/input/touchscreen/ad7879.h
>> +++ b/drivers/input/touchscreen/ad7879.h
>> @@ -24,6 +24,7 @@ struct ad7879_bus_ops {
>> extern const struct dev_pm_ops ad7879_pm_ops;
>>
>> struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned irq,
>> + struct ad7879_platform_data *pdata,
>> const struct ad7879_bus_ops *bops);
>> void ad7879_remove(struct ad7879 *);
>>
>>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 1/3] input: touchscreen: ad7879: move header to input subdirectory
2016-01-26 3:04 ` Stefan Agner
` (2 preceding siblings ...)
(?)
@ 2016-01-27 23:35 ` Dmitry Torokhov
-1 siblings, 0 replies; 23+ messages in thread
From: Dmitry Torokhov @ 2016-01-27 23:35 UTC (permalink / raw)
To: Stefan Agner
Cc: michael.hennerich, robh+dt, mark.rutland, ijc+devicetree, galak,
realmz6, broonie, jic23, linux-input, devicetree, linux-kernel
On Mon, Jan 25, 2016 at 07:04:35PM -0800, Stefan Agner wrote:
> The header file is used by the SPI and I2C variant of the driver.
> Therefore, move it to a more generic place under input.
Even better place would be include/linux/platform_data/ad7879.h
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 3/3] input: touchscreen: ad7879: add device tree support
@ 2016-01-27 23:38 ` Dmitry Torokhov
0 siblings, 0 replies; 23+ messages in thread
From: Dmitry Torokhov @ 2016-01-27 23:38 UTC (permalink / raw)
To: Stefan Agner
Cc: michael.hennerich, robh+dt, mark.rutland, ijc+devicetree, galak,
realmz6, broonie, jic23, linux-input, devicetree, linux-kernel
Hi Stefan,
On Mon, Jan 25, 2016 at 07:04:37PM -0800, Stefan Agner wrote:
> Add device tree support for the I2C variant of AD7879 (AD7879-1). This
> allows to specify the touchscreen controller as a I2C client node.
> Most of the options available as platform data are also available as
> device tree properties. Exporting the GPIO is currently not possible
> through device tree.
>
> Signed-off-by: Stefan Agner <stefan@agner.ch>
> ---
> .../bindings/input/touchscreen/ad7879-i2c.txt | 47 ++++++++++++++++
> drivers/input/touchscreen/ad7879-i2c.c | 63 +++++++++++++++++++++-
> drivers/input/touchscreen/ad7879-spi.c | 3 +-
> drivers/input/touchscreen/ad7879.c | 2 +-
> drivers/input/touchscreen/ad7879.h | 1 +
> 5 files changed, 113 insertions(+), 3 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
>
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt b/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
> new file mode 100644
> index 0000000..bf169a2
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
> @@ -0,0 +1,47 @@
> +* Analog Devices AD7879-1/AD7889-1 touchscreen interface (I2C)
> +
> +Required properties:
> +- compatible: must be "adi,ad7879-1"
> +- reg: i2c slave address
> +- interrupt-parent: the phandle for the interrupt controller
> +- interrupts: touch controller interrupt
> +- resistance-plate-x : total resistance of X-plate (for pressure
> + calculation)
> +- touchscreen-max-pressure : maximum reported pressure
> +- touchscreen-swapped-x-y : X and Y axis are swapped (boolean)
> + Swapping is done after inverting the axis
> +Optional properties:
> +- first-conversion-delay : 0-12 in 128us steps (starting with 128us)
> + 13: 2.560ms
> + 14: 3.584ms
> + 15: 4.096ms
> +- acquisition-time : 0: 2us
> + 1: 4us
> + 2: 8us
> + 3: 16us
> +- median-filter-size : 0: disabled
> + 1: 4 measurements
> + 2: 8 measurements
> + 3: 16 measurements
> +- averaging : 0: 2 middle values (1 if median disabled)
> + 1: 4 middle values
> + 2: 8 middle values
> + 3: 16 values
> +- conversion-interval: : 0: convert one time only
> + 1-255: 515us + val * 35us (up to 9.440ms)
> +
> +Example:
> +
> + ad7879@2c {
> + compatible = "adi,ad7879-1";
> + reg = <0x2c>;
> + interrupt-parent = <&gpio1>;
> + interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
> + resistance-plate-x = <120>;
> + touchscreen-max-pressure = <4096>;
> + first-conversion-delay = /bits/ 8 <3>;
> + acquisition-time = /bits/ 8 <1>;
> + median-filter-size = /bits/ 8 <2>;
> + averaging = /bits/ 8 <1>;
> + conversion-interval = /bits/ 8 <255>;
> + };
> diff --git a/drivers/input/touchscreen/ad7879-i2c.c b/drivers/input/touchscreen/ad7879-i2c.c
> index d66962c..08a2c9a 100644
> --- a/drivers/input/touchscreen/ad7879-i2c.c
> +++ b/drivers/input/touchscreen/ad7879-i2c.c
> @@ -11,6 +11,7 @@
> #include <linux/module.h>
> #include <linux/types.h>
> #include <linux/pm.h>
> +#include <linux/input/ad7879.h>
>
> #include "ad7879.h"
>
> @@ -54,9 +55,50 @@ static const struct ad7879_bus_ops ad7879_i2c_bus_ops = {
> .write = ad7879_i2c_write,
> };
>
> +static struct ad7879_platform_data *ad7879_parse_dt(struct device *dev)
> +{
> + struct ad7879_platform_data *pdata;
> + struct device_node *np = dev->of_node;
> + int err;
> + u32 tmp;
> +
> + if (!np)
> + return NULL;
> +
> + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> +
> + if (!pdata)
> + return ERR_PTR(-ENOMEM);
> +
> + err = of_property_read_u32(np, "resistance-plate-x", &tmp);
> + if (err) {
> + dev_err(dev, "failed to get resistance-plate-x property\n");
> + return ERR_PTR(err);
> + }
> + pdata->x_plate_ohms = (u16)tmp;
> +
> + err = of_property_read_u32(np, "touchscreen-max-pressure", &tmp);
> + if (err) {
> + dev_err(dev, "failed to get touchscreen-max-pressure property\n");
> + return ERR_PTR(err);
> + }
> + pdata->pressure_min = (u16)tmp;
> +
> + of_property_read_u8(np, "first-conversion-delay", &pdata->first_conversion_delay);
> + of_property_read_u8(np, "acquisition-time", &pdata->acquisition_time);
> + of_property_read_u8(np, "median-filter-size", &pdata->median);
> + of_property_read_u8(np, "averaging", &pdata->averaging);
> + of_property_read_u8(np, "conversion-interval", &pdata->pen_down_acc_interval);
> +
> + pdata->swap_xy = of_property_read_bool(np, "touchscreen-swapped-x-y");
I'd prefer if we used device_property_* API instead of of_property_*, so
that properties would work not only on OF, but also on other platforms
and even legacy boards could potentially be converted to properties.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 3/3] input: touchscreen: ad7879: add device tree support
@ 2016-01-27 23:38 ` Dmitry Torokhov
0 siblings, 0 replies; 23+ messages in thread
From: Dmitry Torokhov @ 2016-01-27 23:38 UTC (permalink / raw)
To: Stefan Agner
Cc: michael.hennerich-OyLXuOCK7orQT0dZR+AlfA,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg,
galak-sgV2jX0FEOL9JmXXK+q4OQ, realmz6-Re5JQEeQqe8AvxtiuMwx3w,
broonie-DgEjT+Ai2ygdnm+yROfE0A, jic23-DgEjT+Ai2ygdnm+yROfE0A,
linux-input-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
Hi Stefan,
On Mon, Jan 25, 2016 at 07:04:37PM -0800, Stefan Agner wrote:
> Add device tree support for the I2C variant of AD7879 (AD7879-1). This
> allows to specify the touchscreen controller as a I2C client node.
> Most of the options available as platform data are also available as
> device tree properties. Exporting the GPIO is currently not possible
> through device tree.
>
> Signed-off-by: Stefan Agner <stefan-XLVq0VzYD2Y@public.gmane.org>
> ---
> .../bindings/input/touchscreen/ad7879-i2c.txt | 47 ++++++++++++++++
> drivers/input/touchscreen/ad7879-i2c.c | 63 +++++++++++++++++++++-
> drivers/input/touchscreen/ad7879-spi.c | 3 +-
> drivers/input/touchscreen/ad7879.c | 2 +-
> drivers/input/touchscreen/ad7879.h | 1 +
> 5 files changed, 113 insertions(+), 3 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
>
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt b/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
> new file mode 100644
> index 0000000..bf169a2
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
> @@ -0,0 +1,47 @@
> +* Analog Devices AD7879-1/AD7889-1 touchscreen interface (I2C)
> +
> +Required properties:
> +- compatible: must be "adi,ad7879-1"
> +- reg: i2c slave address
> +- interrupt-parent: the phandle for the interrupt controller
> +- interrupts: touch controller interrupt
> +- resistance-plate-x : total resistance of X-plate (for pressure
> + calculation)
> +- touchscreen-max-pressure : maximum reported pressure
> +- touchscreen-swapped-x-y : X and Y axis are swapped (boolean)
> + Swapping is done after inverting the axis
> +Optional properties:
> +- first-conversion-delay : 0-12 in 128us steps (starting with 128us)
> + 13: 2.560ms
> + 14: 3.584ms
> + 15: 4.096ms
> +- acquisition-time : 0: 2us
> + 1: 4us
> + 2: 8us
> + 3: 16us
> +- median-filter-size : 0: disabled
> + 1: 4 measurements
> + 2: 8 measurements
> + 3: 16 measurements
> +- averaging : 0: 2 middle values (1 if median disabled)
> + 1: 4 middle values
> + 2: 8 middle values
> + 3: 16 values
> +- conversion-interval: : 0: convert one time only
> + 1-255: 515us + val * 35us (up to 9.440ms)
> +
> +Example:
> +
> + ad7879@2c {
> + compatible = "adi,ad7879-1";
> + reg = <0x2c>;
> + interrupt-parent = <&gpio1>;
> + interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
> + resistance-plate-x = <120>;
> + touchscreen-max-pressure = <4096>;
> + first-conversion-delay = /bits/ 8 <3>;
> + acquisition-time = /bits/ 8 <1>;
> + median-filter-size = /bits/ 8 <2>;
> + averaging = /bits/ 8 <1>;
> + conversion-interval = /bits/ 8 <255>;
> + };
> diff --git a/drivers/input/touchscreen/ad7879-i2c.c b/drivers/input/touchscreen/ad7879-i2c.c
> index d66962c..08a2c9a 100644
> --- a/drivers/input/touchscreen/ad7879-i2c.c
> +++ b/drivers/input/touchscreen/ad7879-i2c.c
> @@ -11,6 +11,7 @@
> #include <linux/module.h>
> #include <linux/types.h>
> #include <linux/pm.h>
> +#include <linux/input/ad7879.h>
>
> #include "ad7879.h"
>
> @@ -54,9 +55,50 @@ static const struct ad7879_bus_ops ad7879_i2c_bus_ops = {
> .write = ad7879_i2c_write,
> };
>
> +static struct ad7879_platform_data *ad7879_parse_dt(struct device *dev)
> +{
> + struct ad7879_platform_data *pdata;
> + struct device_node *np = dev->of_node;
> + int err;
> + u32 tmp;
> +
> + if (!np)
> + return NULL;
> +
> + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> +
> + if (!pdata)
> + return ERR_PTR(-ENOMEM);
> +
> + err = of_property_read_u32(np, "resistance-plate-x", &tmp);
> + if (err) {
> + dev_err(dev, "failed to get resistance-plate-x property\n");
> + return ERR_PTR(err);
> + }
> + pdata->x_plate_ohms = (u16)tmp;
> +
> + err = of_property_read_u32(np, "touchscreen-max-pressure", &tmp);
> + if (err) {
> + dev_err(dev, "failed to get touchscreen-max-pressure property\n");
> + return ERR_PTR(err);
> + }
> + pdata->pressure_min = (u16)tmp;
> +
> + of_property_read_u8(np, "first-conversion-delay", &pdata->first_conversion_delay);
> + of_property_read_u8(np, "acquisition-time", &pdata->acquisition_time);
> + of_property_read_u8(np, "median-filter-size", &pdata->median);
> + of_property_read_u8(np, "averaging", &pdata->averaging);
> + of_property_read_u8(np, "conversion-interval", &pdata->pen_down_acc_interval);
> +
> + pdata->swap_xy = of_property_read_bool(np, "touchscreen-swapped-x-y");
I'd prefer if we used device_property_* API instead of of_property_*, so
that properties would work not only on OF, but also on other platforms
and even legacy boards could potentially be converted to properties.
Thanks.
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 2/3] input: touchscreen: ad7879: fix default x/y axis assignment
2016-01-26 17:04 ` Stefan Agner
(?)
@ 2016-01-27 23:40 ` Dmitry Torokhov
-1 siblings, 0 replies; 23+ messages in thread
From: Dmitry Torokhov @ 2016-01-27 23:40 UTC (permalink / raw)
To: Stefan Agner
Cc: michael.hennerich, robh+dt, mark.rutland, ijc+devicetree, galak,
realmz6, broonie, jic23, linux-input, devicetree, linux-kernel
On Tue, Jan 26, 2016 at 09:04:20AM -0800, Stefan Agner wrote:
> On 2016-01-25 23:58, Michael Hennerich wrote:
> > On 01/26/2016 04:04 AM, Stefan Agner wrote:
> >> The measurements read from the controller which are temporary stored
> >> in conversion_data, are interpreted wrong. The first measurement X+
> >> contains the Y position, and the second measurement Y+ the X position
> >> (see also Table 11 Register Table in the data sheet).
> >>
> >> The problem is already known and a swap option has been introduced:
> >> commit 6680884a4420 ("Input: ad7879 - add option to correct xy axis")
> >>
> >> However, with that the meaning of the new boolean is inverted since
> >> the underlying values are already swapped. With this change, a true
> >> in swap_xy actually swaps the two axis.
> >>
> >> Signed-off-by: Stefan Agner <stefan@agner.ch>
> >> ---
> >> Hi Michael,
> >>
> >> It seems that swap_xy is not used in any board which is in mainline,
> >> hence swap_xy is always false. Therefore, up until now all boards
> >> actually used swapped axis. However, I doubt that the blackfin boards
> >> really have those axis swapped, it is probably more likely that the
> >> userspace calibration took care of it.
> >>
> >> However, if they are really swapped, we should set the swap_xy flag
> >> to 1 for those board...
> >>
> >> Do you happen to now what is the case with those boards?
> >>
> >
> >
> > Hi Stefan,
> >
> > I would be hesitant to invert the default behaviour of the driver.
> > Too many people in the field already using it as it is.
>
> Afaik, we should be able to change in-kernel API's (especially if they
> are wrong) since we do not guarantee any API...
>
> >
> > A XY swap can have multiple reasons.
> >
> > Lot's of small VGA/QVGA TFTs have the option to switch the scan
> > direction from Landscape to Portrait. In addition you can also rotate
> > and flip or mirror using VDMA options. So it really depends on the use
> > case, how the touch panel is mounted to the screen or how it is wired.
>
> Ok, I see the reason for that functionality.
>
> I am mainly concerned about the new DT bindings. The touchscreen binding
> documents specify touchscreen-swapped-x-y, see:
> https://www.kernel.org/doc/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
>
> I would like to make sure that this property is really swapping axis
> (and not necessary if the hardware is implemented according to the
> datasheet...)
>
> We could also implement a workaround to keep the platform data behavior
> as is (invert the swap_xy flag)...
That is probably the best option.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 3/3] input: touchscreen: ad7879: add device tree support
2016-01-26 3:04 ` [PATCH 3/3] input: touchscreen: ad7879: add device tree support Stefan Agner
` (4 preceding siblings ...)
2016-01-27 23:38 ` Dmitry Torokhov
@ 2016-01-29 3:00 ` Rob Herring
5 siblings, 0 replies; 23+ messages in thread
From: Rob Herring @ 2016-01-29 3:00 UTC (permalink / raw)
To: Stefan Agner
Cc: dmitry.torokhov, michael.hennerich, mark.rutland, ijc+devicetree,
galak, realmz6, broonie, jic23, linux-input, devicetree,
linux-kernel
On Mon, Jan 25, 2016 at 07:04:37PM -0800, Stefan Agner wrote:
> Add device tree support for the I2C variant of AD7879 (AD7879-1). This
> allows to specify the touchscreen controller as a I2C client node.
> Most of the options available as platform data are also available as
> device tree properties. Exporting the GPIO is currently not possible
> through device tree.
>
> Signed-off-by: Stefan Agner <stefan@agner.ch>
> ---
> .../bindings/input/touchscreen/ad7879-i2c.txt | 47 ++++++++++++++++
> drivers/input/touchscreen/ad7879-i2c.c | 63 +++++++++++++++++++++-
> drivers/input/touchscreen/ad7879-spi.c | 3 +-
> drivers/input/touchscreen/ad7879.c | 2 +-
> drivers/input/touchscreen/ad7879.h | 1 +
> 5 files changed, 113 insertions(+), 3 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
>
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt b/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
> new file mode 100644
> index 0000000..bf169a2
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/ad7879-i2c.txt
> @@ -0,0 +1,47 @@
> +* Analog Devices AD7879-1/AD7889-1 touchscreen interface (I2C)
> +
> +Required properties:
> +- compatible: must be "adi,ad7879-1"
> +- reg: i2c slave address
> +- interrupt-parent: the phandle for the interrupt controller
> +- interrupts: touch controller interrupt
> +- resistance-plate-x : total resistance of X-plate (for pressure
> + calculation)
> +- touchscreen-max-pressure : maximum reported pressure
> +- touchscreen-swapped-x-y : X and Y axis are swapped (boolean)
> + Swapping is done after inverting the axis
> +Optional properties:
> +- first-conversion-delay : 0-12 in 128us steps (starting with 128us)
> + 13: 2.560ms
> + 14: 3.584ms
> + 15: 4.096ms
> +- acquisition-time : 0: 2us
> + 1: 4us
> + 2: 8us
> + 3: 16us
> +- median-filter-size : 0: disabled
> + 1: 4 measurements
> + 2: 8 measurements
> + 3: 16 measurements
> +- averaging : 0: 2 middle values (1 if median disabled)
> + 1: 4 middle values
> + 2: 8 middle values
> + 3: 16 values
> +- conversion-interval: : 0: convert one time only
> + 1-255: 515us + val * 35us (up to 9.440ms)
These all should be prefixed with "adi,". Also, please state the sizes
are 8-bit.
> +
> +Example:
> +
> + ad7879@2c {
> + compatible = "adi,ad7879-1";
> + reg = <0x2c>;
> + interrupt-parent = <&gpio1>;
> + interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
> + resistance-plate-x = <120>;
> + touchscreen-max-pressure = <4096>;
> + first-conversion-delay = /bits/ 8 <3>;
> + acquisition-time = /bits/ 8 <1>;
> + median-filter-size = /bits/ 8 <2>;
> + averaging = /bits/ 8 <1>;
> + conversion-interval = /bits/ 8 <255>;
> + };
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2016-01-29 3:00 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-26 3:04 [PATCH 1/3] input: touchscreen: ad7879: move header to input subdirectory Stefan Agner
2016-01-26 3:04 ` Stefan Agner
2016-01-26 3:04 ` [PATCH 2/3] input: touchscreen: ad7879: fix default x/y axis assignment Stefan Agner
2016-01-26 3:04 ` Stefan Agner
2016-01-26 7:58 ` Michael Hennerich
2016-01-26 7:58 ` Michael Hennerich
2016-01-26 17:04 ` Stefan Agner
2016-01-26 17:04 ` Stefan Agner
2016-01-27 23:40 ` Dmitry Torokhov
2016-01-26 3:04 ` [PATCH 3/3] input: touchscreen: ad7879: add device tree support Stefan Agner
2016-01-26 3:28 ` kbuild test robot
2016-01-26 3:28 ` kbuild test robot
2016-01-26 3:57 ` kbuild test robot
2016-01-26 3:57 ` kbuild test robot
2016-01-26 4:50 ` kbuild test robot
2016-01-26 4:50 ` kbuild test robot
2016-01-26 8:14 ` Michael Hennerich
2016-01-26 8:14 ` Michael Hennerich
2016-01-26 17:10 ` Stefan Agner
2016-01-27 23:38 ` Dmitry Torokhov
2016-01-27 23:38 ` Dmitry Torokhov
2016-01-29 3:00 ` Rob Herring
2016-01-27 23:35 ` [PATCH 1/3] input: touchscreen: ad7879: move header to input subdirectory Dmitry Torokhov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.