[PATCH 06/10] iio: exynos-adc: add experimental touchscreen support

2015-11-25 Thread Arnd Bergmann
This adds support for the touchscreen on Samsung s3c64xx.
The driver is completely untested but shows roughly how
it could be done, following the example of the at91 driver.

compared to the old plat-samsung/adc driver, there is
no support for prioritizing ts over other clients, nor
for oversampling. From my reading of the code, the
priorities didn't actually have any effect at all, but
the oversampling might be needed.

Verifying this driver is the main issue that is currently
holding up multiplatform support for s3c64xx, so any help
in testing is very much appreciated.

The current version uses the IS_REACHABLE() that is
going to be introduced in the linux-media tree, please
comment this out for testing.

Signed-off-by: Arnd Bergmann 
Acked-by: Dmitry Torokhov 
---
 .../devicetree/bindings/arm/samsung/exynos-adc.txt |   3 +
 drivers/iio/adc/exynos_adc.c   | 224 -
 2 files changed, 220 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt 
b/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt
index f46ca9a316a2..ccaaec6014bd 100644
--- a/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt
+++ b/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt
@@ -47,6 +47,9 @@ Required properties:
 
 - samsung,syscon-phandle Contains the PMU system controller node
(To access the ADC_PHY register on 
Exynos5250/5420/5800/3250)
+Optional properties:
+- has-touchscreen: If present, indicates that a touchscreen is
+   connected an usable.
 
 Note: child nodes can be added for auto probing from device tree.
 
diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
index 3a2dbb3b4926..d11cd604562c 100644
--- a/drivers/iio/adc/exynos_adc.c
+++ b/drivers/iio/adc/exynos_adc.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -42,12 +43,18 @@
 #include 
 #include 
 
+#include 
+
 /* S3C/EXYNOS4412/5250 ADC_V1 registers definitions */
 #define ADC_V1_CON(x)  ((x) + 0x00)
+#define ADC_V1_TSC(x)  ((x) + 0x04)
 #define ADC_V1_DLY(x)  ((x) + 0x08)
 #define ADC_V1_DATX(x) ((x) + 0x0C)
+#define ADC_V1_DATY(x) ((x) + 0x10)
+#define ADC_V1_UPDN(x) ((x) + 0x14)
 #define ADC_V1_INTCLR(x)   ((x) + 0x18)
 #define ADC_V1_MUX(x)  ((x) + 0x1c)
+#define ADC_V1_CLRINTPNDNUP(x) ((x) + 0x20)
 
 /* S3C2410 ADC registers definitions */
 #define ADC_S3C2410_MUX(x) ((x) + 0x18)
@@ -71,6 +78,30 @@
 #define ADC_S3C2410_DATX_MASK  0x3FF
 #define ADC_S3C2416_CON_RES_SEL(1u << 3)
 
+/* touch screen always uses channel 0 */
+#define ADC_S3C2410_MUX_TS 0
+
+/* ADCTSC Register Bits */
+#define ADC_S3C2443_TSC_UD_SEN (1u << 8)
+#define ADC_S3C2410_TSC_YM_SEN (1u << 7)
+#define ADC_S3C2410_TSC_YP_SEN (1u << 6)
+#define ADC_S3C2410_TSC_XM_SEN (1u << 5)
+#define ADC_S3C2410_TSC_XP_SEN (1u << 4)
+#define ADC_S3C2410_TSC_PULL_UP_DISABLE(1u << 3)
+#define ADC_S3C2410_TSC_AUTO_PST   (1u << 2)
+#define ADC_S3C2410_TSC_XY_PST(x)  (((x) & 0x3) << 0)
+
+#define ADC_TSC_WAIT4INT (ADC_S3C2410_TSC_YM_SEN | \
+ADC_S3C2410_TSC_YP_SEN | \
+ADC_S3C2410_TSC_XP_SEN | \
+ADC_S3C2410_TSC_XY_PST(3))
+
+#define ADC_TSC_AUTOPST(ADC_S3C2410_TSC_YM_SEN | \
+ADC_S3C2410_TSC_YP_SEN | \
+ADC_S3C2410_TSC_XP_SEN | \
+ADC_S3C2410_TSC_AUTO_PST | \
+ADC_S3C2410_TSC_XY_PST(0))
+
 /* Bit definitions for ADC_V2 */
 #define ADC_V2_CON1_SOFT_RESET (1u << 2)
 
@@ -88,7 +119,9 @@
 /* Bit definitions common for ADC_V1 and ADC_V2 */
 #define ADC_CON_EN_START   (1u << 0)
 #define ADC_CON_EN_START_MASK  (0x3 << 0)
+#define ADC_DATX_PRESSED   (1u << 15)
 #define ADC_DATX_MASK  0xFFF
+#define ADC_DATY_MASK  0xFFF
 
 #define EXYNOS_ADC_TIMEOUT (msecs_to_jiffies(100))
 
@@ -98,17 +131,24 @@
 struct exynos_adc {
struct exynos_adc_data  *data;
struct device   *dev;
+   struct input_dev*input;
void __iomem*regs;
struct regmap   *pmu_map;
struct clk  *clk;
struct clk  *sclk;
unsigned intirq;
+   unsigned inttsirq;
+   unsigned intdelay;
struct regulator*vdd;
 
struct completion   completion;
 
u32 value;
unsigned intversion;
+
+   boolread_ts;
+   u32 ts_x;
+   u32 ts_y;
 };
 
 struct exynos_adc_data {
@@ -197,6 +237,9 @@ static void exynos_adc_v1_init_hw(struct exynos_adc *info)
/* Enable 12-bit ADC resolution */
con1 |= ADC_V1_CON_RES;
   

Re: [PATCH 06/10] iio: exynos-adc: add experimental touchscreen support

2015-03-12 Thread Arnd Bergmann
On Wednesday 04 March 2015 15:10:00 Dmitry Torokhov wrote:
> > +static int exynos_adc_ts_init(struct exynos_adc *info)
> > +{
> > + int ret;
> > +
> > + if (info->tsirq <= 0)
> > + return -ENODEV;
> > +
> > + info->input = input_allocate_device();
> > + if (!info->input)
> > + return -ENOMEM;
> > +
> > + info->input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
> > + info->input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
> > +
> > + input_set_abs_params(info->input, ABS_X, 0, 0x3FF, 0, 0);
> > + input_set_abs_params(info->input, ABS_Y, 0, 0x3FF, 0, 0);
> > +
> > + info->input->name = "S3C24xx TouchScreen";
> > + info->input->id.bustype = BUS_HOST;
> > + info->input->open = exynos_adc_ts_open;
> > + info->input->close = exynos_adc_ts_close;
> > +
> > + input_set_drvdata(info->input, info);
> > +
> > + ret = input_register_device(info->input);
> > + if (ret)
> > + input_free_device(info->input);
> 
> 
> If you fail to register input device are you sure you want to continue
> and register interrupt?
> 
> > +
> > + disable_irq(info->tsirq);
> > + ret = request_threaded_irq(info->tsirq, NULL, exynos_ts_isr,
> > +0, "touchscreen", info);
> > + if (ret)
> > + input_unregister_device(info->input);
> > +
> > + return ret;
> > +}

Sorry for the delayed reply, I've now folded in this patch:


diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
index 75cd381a8181..d11cd604562c 100644
--- a/drivers/iio/adc/exynos_adc.c
+++ b/drivers/iio/adc/exynos_adc.c
@@ -732,8 +732,10 @@ static int exynos_adc_ts_init(struct exynos_adc *info)
input_set_drvdata(info->input, info);
 
ret = input_register_device(info->input);
-   if (ret)
+   if (ret) {
input_free_device(info->input);
+   return ret;
+   }
 
disable_irq(info->tsirq);
ret = request_threaded_irq(info->tsirq, NULL, exynos_ts_isr,


Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 06/10] iio: exynos-adc: add experimental touchscreen support

2015-03-04 Thread Dmitry Torokhov
Hi Arnd,

On Mon, Mar 02, 2015 at 01:35:59PM +0100, Arnd Bergmann wrote:
> This adds support for the touchscreen on Samsung s3c64xx.
> The driver is completely untested but shows roughly how
> it could be done, following the example of the at91 driver.
> 
> compared to the old plat-samsung/adc driver, there is
> no support for prioritizing ts over other clients, nor
> for oversampling. From my reading of the code, the
> priorities didn't actually have any effect at all, but
> the oversampling might be needed.
> 
> Verifying this driver is the main issue that is currently
> holding up multiplatform support for s3c64xx, so any help
> in testing is very much appreciated.
> 
> The current version uses the IS_REACHABLE() that is
> going to be introduced in the linux-media tree, please
> comment this out for testing.
> 
> Signed-off-by: Arnd Bergmann 
> Acked-by: Dmitry Torokhov 
> ---
>  .../devicetree/bindings/arm/samsung/exynos-adc.txt |   3 +
>  drivers/iio/adc/exynos_adc.c   | 222 
> -
>  2 files changed, 218 insertions(+), 7 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt 
> b/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt
> index f46ca9a316a2..ccaaec6014bd 100644
> --- a/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt
> +++ b/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt
> @@ -47,6 +47,9 @@ Required properties:
>  
>  - samsung,syscon-phandle Contains the PMU system controller node
>   (To access the ADC_PHY register on 
> Exynos5250/5420/5800/3250)
> +Optional properties:
> +- has-touchscreen:   If present, indicates that a touchscreen is
> + connected an usable.
>  
>  Note: child nodes can be added for auto probing from device tree.
>  
> diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
> index 3a2dbb3b4926..75cd381a8181 100644
> --- a/drivers/iio/adc/exynos_adc.c
> +++ b/drivers/iio/adc/exynos_adc.c
> @@ -35,6 +35,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #include 
> @@ -42,12 +43,18 @@
>  #include 
>  #include 
>  
> +#include 
> +
>  /* S3C/EXYNOS4412/5250 ADC_V1 registers definitions */
>  #define ADC_V1_CON(x)((x) + 0x00)
> +#define ADC_V1_TSC(x)((x) + 0x04)
>  #define ADC_V1_DLY(x)((x) + 0x08)
>  #define ADC_V1_DATX(x)   ((x) + 0x0C)
> +#define ADC_V1_DATY(x)   ((x) + 0x10)
> +#define ADC_V1_UPDN(x)   ((x) + 0x14)
>  #define ADC_V1_INTCLR(x) ((x) + 0x18)
>  #define ADC_V1_MUX(x)((x) + 0x1c)
> +#define ADC_V1_CLRINTPNDNUP(x)   ((x) + 0x20)
>  
>  /* S3C2410 ADC registers definitions */
>  #define ADC_S3C2410_MUX(x)   ((x) + 0x18)
> @@ -71,6 +78,30 @@
>  #define ADC_S3C2410_DATX_MASK0x3FF
>  #define ADC_S3C2416_CON_RES_SEL  (1u << 3)
>  
> +/* touch screen always uses channel 0 */
> +#define ADC_S3C2410_MUX_TS   0
> +
> +/* ADCTSC Register Bits */
> +#define ADC_S3C2443_TSC_UD_SEN   (1u << 8)
> +#define ADC_S3C2410_TSC_YM_SEN   (1u << 7)
> +#define ADC_S3C2410_TSC_YP_SEN   (1u << 6)
> +#define ADC_S3C2410_TSC_XM_SEN   (1u << 5)
> +#define ADC_S3C2410_TSC_XP_SEN   (1u << 4)
> +#define ADC_S3C2410_TSC_PULL_UP_DISABLE  (1u << 3)
> +#define ADC_S3C2410_TSC_AUTO_PST (1u << 2)
> +#define ADC_S3C2410_TSC_XY_PST(x)(((x) & 0x3) << 0)
> +
> +#define ADC_TSC_WAIT4INT (ADC_S3C2410_TSC_YM_SEN | \
> +  ADC_S3C2410_TSC_YP_SEN | \
> +  ADC_S3C2410_TSC_XP_SEN | \
> +  ADC_S3C2410_TSC_XY_PST(3))
> +
> +#define ADC_TSC_AUTOPST  (ADC_S3C2410_TSC_YM_SEN | \
> +  ADC_S3C2410_TSC_YP_SEN | \
> +  ADC_S3C2410_TSC_XP_SEN | \
> +  ADC_S3C2410_TSC_AUTO_PST | \
> +  ADC_S3C2410_TSC_XY_PST(0))
> +
>  /* Bit definitions for ADC_V2 */
>  #define ADC_V2_CON1_SOFT_RESET   (1u << 2)
>  
> @@ -88,7 +119,9 @@
>  /* Bit definitions common for ADC_V1 and ADC_V2 */
>  #define ADC_CON_EN_START (1u << 0)
>  #define ADC_CON_EN_START_MASK(0x3 << 0)
> +#define ADC_DATX_PRESSED (1u << 15)
>  #define ADC_DATX_MASK0xFFF
> +#define ADC_DATY_MASK0xFFF
>  
>  #define EXYNOS_ADC_TIMEOUT   (msecs_to_jiffies(100))
>  
> @@ -98,17 +131,24 @@
>  struct exynos_adc {
>   struct exynos_adc_data  *data;
>   struct device   *dev;
> + struct input_dev*input;
>   void __iomem*regs;
>   struct regmap   *pmu_map;
>   struct clk  *clk;
>   struct clk  *sclk;
>   unsigned intirq;
> + unsigned inttsirq;
> + unsigned intdelay;
>   struct regulator*vdd;
>  
>   struct completion   completion;
>  
>   u32 

[PATCH 06/10] iio: exynos-adc: add experimental touchscreen support

2015-03-02 Thread Arnd Bergmann
This adds support for the touchscreen on Samsung s3c64xx.
The driver is completely untested but shows roughly how
it could be done, following the example of the at91 driver.

compared to the old plat-samsung/adc driver, there is
no support for prioritizing ts over other clients, nor
for oversampling. From my reading of the code, the
priorities didn't actually have any effect at all, but
the oversampling might be needed.

Verifying this driver is the main issue that is currently
holding up multiplatform support for s3c64xx, so any help
in testing is very much appreciated.

The current version uses the IS_REACHABLE() that is
going to be introduced in the linux-media tree, please
comment this out for testing.

Signed-off-by: Arnd Bergmann 
Acked-by: Dmitry Torokhov 
---
 .../devicetree/bindings/arm/samsung/exynos-adc.txt |   3 +
 drivers/iio/adc/exynos_adc.c   | 222 -
 2 files changed, 218 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt 
b/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt
index f46ca9a316a2..ccaaec6014bd 100644
--- a/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt
+++ b/Documentation/devicetree/bindings/arm/samsung/exynos-adc.txt
@@ -47,6 +47,9 @@ Required properties:
 
 - samsung,syscon-phandle Contains the PMU system controller node
(To access the ADC_PHY register on 
Exynos5250/5420/5800/3250)
+Optional properties:
+- has-touchscreen: If present, indicates that a touchscreen is
+   connected an usable.
 
 Note: child nodes can be added for auto probing from device tree.
 
diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
index 3a2dbb3b4926..75cd381a8181 100644
--- a/drivers/iio/adc/exynos_adc.c
+++ b/drivers/iio/adc/exynos_adc.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -42,12 +43,18 @@
 #include 
 #include 
 
+#include 
+
 /* S3C/EXYNOS4412/5250 ADC_V1 registers definitions */
 #define ADC_V1_CON(x)  ((x) + 0x00)
+#define ADC_V1_TSC(x)  ((x) + 0x04)
 #define ADC_V1_DLY(x)  ((x) + 0x08)
 #define ADC_V1_DATX(x) ((x) + 0x0C)
+#define ADC_V1_DATY(x) ((x) + 0x10)
+#define ADC_V1_UPDN(x) ((x) + 0x14)
 #define ADC_V1_INTCLR(x)   ((x) + 0x18)
 #define ADC_V1_MUX(x)  ((x) + 0x1c)
+#define ADC_V1_CLRINTPNDNUP(x) ((x) + 0x20)
 
 /* S3C2410 ADC registers definitions */
 #define ADC_S3C2410_MUX(x) ((x) + 0x18)
@@ -71,6 +78,30 @@
 #define ADC_S3C2410_DATX_MASK  0x3FF
 #define ADC_S3C2416_CON_RES_SEL(1u << 3)
 
+/* touch screen always uses channel 0 */
+#define ADC_S3C2410_MUX_TS 0
+
+/* ADCTSC Register Bits */
+#define ADC_S3C2443_TSC_UD_SEN (1u << 8)
+#define ADC_S3C2410_TSC_YM_SEN (1u << 7)
+#define ADC_S3C2410_TSC_YP_SEN (1u << 6)
+#define ADC_S3C2410_TSC_XM_SEN (1u << 5)
+#define ADC_S3C2410_TSC_XP_SEN (1u << 4)
+#define ADC_S3C2410_TSC_PULL_UP_DISABLE(1u << 3)
+#define ADC_S3C2410_TSC_AUTO_PST   (1u << 2)
+#define ADC_S3C2410_TSC_XY_PST(x)  (((x) & 0x3) << 0)
+
+#define ADC_TSC_WAIT4INT (ADC_S3C2410_TSC_YM_SEN | \
+ADC_S3C2410_TSC_YP_SEN | \
+ADC_S3C2410_TSC_XP_SEN | \
+ADC_S3C2410_TSC_XY_PST(3))
+
+#define ADC_TSC_AUTOPST(ADC_S3C2410_TSC_YM_SEN | \
+ADC_S3C2410_TSC_YP_SEN | \
+ADC_S3C2410_TSC_XP_SEN | \
+ADC_S3C2410_TSC_AUTO_PST | \
+ADC_S3C2410_TSC_XY_PST(0))
+
 /* Bit definitions for ADC_V2 */
 #define ADC_V2_CON1_SOFT_RESET (1u << 2)
 
@@ -88,7 +119,9 @@
 /* Bit definitions common for ADC_V1 and ADC_V2 */
 #define ADC_CON_EN_START   (1u << 0)
 #define ADC_CON_EN_START_MASK  (0x3 << 0)
+#define ADC_DATX_PRESSED   (1u << 15)
 #define ADC_DATX_MASK  0xFFF
+#define ADC_DATY_MASK  0xFFF
 
 #define EXYNOS_ADC_TIMEOUT (msecs_to_jiffies(100))
 
@@ -98,17 +131,24 @@
 struct exynos_adc {
struct exynos_adc_data  *data;
struct device   *dev;
+   struct input_dev*input;
void __iomem*regs;
struct regmap   *pmu_map;
struct clk  *clk;
struct clk  *sclk;
unsigned intirq;
+   unsigned inttsirq;
+   unsigned intdelay;
struct regulator*vdd;
 
struct completion   completion;
 
u32 value;
unsigned intversion;
+
+   boolread_ts;
+   u32 ts_x;
+   u32 ts_y;
 };
 
 struct exynos_adc_data {
@@ -197,6 +237,9 @@ static void exynos_adc_v1_init_hw(struct exynos_adc *info)
/* Enable 12-bit ADC resolution */
con1 |= ADC_V1_CON_RES;