Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1220222 > unrolled thread
| Started by | Irina Tirdea <irina.tirdea@intel.com> |
|---|---|
| First post | 2015-09-07 16:40 +0200 |
| Last post | 2015-09-15 16:50 +0200 |
| Articles | 4 — 4 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v5 3/9] Input: goodix - reset device at init Irina Tirdea <irina.tirdea@intel.com> - 2015-09-07 16:40 +0200
Re: [PATCH v5 3/9] Input: goodix - reset device at init Bastien Nocera <hadess@hadess.net> - 2015-09-09 19:00 +0200
Re: [PATCH v5 3/9] Input: goodix - reset device at init Aleksei Mamlin <mamlinav@gmail.com> - 2015-09-15 11:50 +0200
RE: [PATCH v5 3/9] Input: goodix - reset device at init "Tirdea, Irina" <irina.tirdea@intel.com> - 2015-09-15 16:50 +0200
| From | Irina Tirdea <irina.tirdea@intel.com> |
|---|---|
| Date | 2015-09-07 16:40 +0200 |
| Subject | [PATCH v5 3/9] Input: goodix - reset device at init |
| Message-ID | <q65Kq-8kq-21@gated-at.bofh.it> |
After power on, it is recommended that the driver resets the device.
The reset procedure timing is described in the datasheet and is used
at device init (before writing device configuration) and
for power management. It is a sequence of setting the interrupt
and reset pins high/low at specific timing intervals. This procedure
also includes setting the slave address to the one specified in the
ACPI/device tree.
This is based on Goodix datasheets for GT911 and GT9271 and on Goodix
driver gt9xx.c for Android (publicly available in Android kernel
trees for various devices).
For reset the driver needs to control the interrupt and
reset gpio pins (configured through ACPI/device tree). For devices
that do not have the gpio pins declared, the functionality depending
on these pins will not be available, but the device can still be used
with basic functionality.
Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
---
.../bindings/input/touchscreen/goodix.txt | 5 +
drivers/input/touchscreen/goodix.c | 136 +++++++++++++++++++++
2 files changed, 141 insertions(+)
diff --git a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
index 8ba98ee..c0715f8 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
@@ -12,6 +12,8 @@ Required properties:
- reg : I2C address of the chip. Should be 0x5d or 0x14
- interrupt-parent : Interrupt controller to which the chip is connected
- interrupts : Interrupt to which the chip is connected
+ - gpios : GPIOS the chip is connected to: first one is the
+ interrupt gpio and second one the reset gpio.
Example:
@@ -23,6 +25,9 @@ Example:
reg = <0x5d>;
interrupt-parent = <&gpio>;
interrupts = <0 0>;
+
+ gpios = <&gpio1 0 0>, /* INT */
+ <&gpio1 1 0>; /* RST */
};
/* ... */
diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index 7be6eab..8edfc06 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -17,6 +17,7 @@
#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/dmi.h>
+#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/input/mt.h>
@@ -37,6 +38,8 @@ struct goodix_ts_data {
unsigned int int_trigger_type;
bool rotated_screen;
int cfg_len;
+ struct gpio_desc *gpiod_int;
+ struct gpio_desc *gpiod_rst;
};
#define GOODIX_MAX_HEIGHT 4096
@@ -89,6 +92,30 @@ static const struct dmi_system_id rotated_screen[] = {
{}
};
+/*
+ * ACPI table specifies gpio pins in this order: first rst pin and
+ * then interrupt pin.
+ */
+static const struct dmi_system_id goodix_rst_pin_first[] = {
+#if defined(CONFIG_DMI) && defined(CONFIG_X86)
+ {
+ .ident = "WinBook TW100",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "WinBook"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "TW100")
+ }
+ },
+ {
+ .ident = "WinBook TW700",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "WinBook"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "TW700")
+ },
+ },
+#endif
+ {}
+};
+
/**
* goodix_i2c_read - read data from a register of the i2c slave device.
*
@@ -237,6 +264,102 @@ static irqreturn_t goodix_ts_irq_handler(int irq, void *dev_id)
return IRQ_HANDLED;
}
+static int goodix_int_sync(struct goodix_ts_data *ts)
+{
+ int error;
+
+ error = gpiod_direction_output(ts->gpiod_int, 0);
+ if (error)
+ return error;
+ msleep(50); /* T5: 50ms */
+
+ return gpiod_direction_input(ts->gpiod_int);
+}
+
+/**
+ * goodix_reset - Reset device during power on
+ *
+ * @ts: goodix_ts_data pointer
+ */
+static int goodix_reset(struct goodix_ts_data *ts)
+{
+ int error;
+
+ /* begin select I2C slave addr */
+ error = gpiod_direction_output(ts->gpiod_rst, 0);
+ if (error)
+ return error;
+ msleep(20); /* T2: > 10ms */
+ /* HIGH: 0x28/0x29, LOW: 0xBA/0xBB */
+ error = gpiod_direction_output(ts->gpiod_int, ts->client->addr == 0x14);
+ if (error)
+ return error;
+ usleep_range(100, 2000); /* T3: > 100us */
+ error = gpiod_direction_output(ts->gpiod_rst, 1);
+ if (error)
+ return error;
+ usleep_range(6000, 10000); /* T4: > 5ms */
+ /* end select I2C slave addr */
+ error = gpiod_direction_input(ts->gpiod_rst);
+ if (error)
+ return error;
+ return goodix_int_sync(ts);
+}
+
+/**
+ * goodix_get_gpio_config - Get GPIO config from ACPI/DT
+ *
+ * @ts: goodix_ts_data pointer
+ */
+static int goodix_get_gpio_config(struct goodix_ts_data *ts,
+ const struct i2c_device_id *i2c_id)
+{
+ int error;
+ struct device *dev;
+ struct gpio_desc *gpiod;
+ /* Default gpio pin order: irq, rst */
+ int irq_idx = 0, rst_idx = 1;
+
+ if (!ts->client)
+ return -EINVAL;
+ dev = &ts->client->dev;
+
+ if (dmi_check_system(goodix_rst_pin_first)) {
+ dev_dbg(&ts->client->dev,
+ "Applying 'reverse gpio pin order' quirk\n");
+ rst_idx = 0;
+ irq_idx = 1;
+ }
+
+ /* Get interrupt GPIO pin number */
+ gpiod = devm_gpiod_get_index(dev, NULL, irq_idx, GPIOD_IN);
+ if (IS_ERR(gpiod)) {
+ error = PTR_ERR(gpiod);
+ if (error != -EPROBE_DEFER)
+ dev_warn(dev, "Failed to get GPIO %d: %d\n",
+ irq_idx, error);
+ if (error == -ENOENT)
+ return 0;
+ return error;
+ }
+ ts->gpiod_int = gpiod;
+
+ /* Get the reset line GPIO pin number */
+ gpiod = devm_gpiod_get_index(dev, NULL, rst_idx, GPIOD_IN);
+ if (IS_ERR(gpiod)) {
+ error = PTR_ERR(gpiod);
+ if (error != -EPROBE_DEFER)
+ dev_warn(dev, "Failed to get GPIO %d: %d\n",
+ rst_idx, error);
+ if (error == -ENOENT)
+ return 0;
+ return error;
+ }
+ ts->gpiod_rst = gpiod;
+
+ return 0;
+}
+
/**
* goodix_read_config - Read the embedded configuration of the panel
*
@@ -419,6 +542,19 @@ static int goodix_ts_probe(struct i2c_client *client,
ts->cfg_len = goodix_get_cfg_len(id_info);
+ error = goodix_get_gpio_config(ts, id);
+ if (error)
+ return error;
+
+ if (ts->gpiod_int && ts->gpiod_rst) {
+ /* reset the controller */
+ error = goodix_reset(ts);
+ if (error) {
+ dev_err(&client->dev, "Controller reset failed.\n");
+ return error;
+ }
+ }
+
goodix_read_config(ts);
error = goodix_request_input_dev(ts, version_info, id_info);
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Bastien Nocera <hadess@hadess.net> |
|---|---|
| Date | 2015-09-09 19:00 +0200 |
| Message-ID | <q6QT0-sK-17@gated-at.bofh.it> |
| In reply to | #1220222 |
On Mon, 2015-09-07 at 17:36 +0300, Irina Tirdea wrote:
> After power on, it is recommended that the driver resets the device.
> The reset procedure timing is described in the datasheet and is used
> at device init (before writing device configuration) and
> for power management. It is a sequence of setting the interrupt
> and reset pins high/low at specific timing intervals. This procedure
> also includes setting the slave address to the one specified in the
> ACPI/device tree.
>
> This is based on Goodix datasheets for GT911 and GT9271 and on Goodix
> driver gt9xx.c for Android (publicly available in Android kernel
> trees for various devices).
>
> For reset the driver needs to control the interrupt and
> reset gpio pins (configured through ACPI/device tree). For devices
> that do not have the gpio pins declared, the functionality depending
> on these pins will not be available, but the device can still be used
> with basic functionality.
This throws:
Sep 09 18:22:47 winbook kernel: Goodix-TS i2c-GDIX1001:00: ID 9271, version: 1040
Sep 09 18:22:47 winbook kernel: ------------[ cut here ]------------
Sep 09 18:22:47 winbook kernel: WARNING: CPU: 3 PID: 3298 at drivers/pinctrl/intel/pinctrl-baytrail.c:338 byt_gpio_direction_output+0x97/0xa0()
Sep 09 18:22:47 winbook kernel: Potential Error: Setting GPIO with direct_irq_en to output
Sep 09 18:22:47 winbook kernel: Modules linked in:
Sep 09 18:22:47 winbook kernel: goodix_backport(OE+) hid_logitech_hidpp hid_logitech_dj cdc_mbim cdc_wdm cdc_ncm usbnet mii uvcvideo videobuf2_vmalloc videobuf2_core videobuf2_memops v4l2_common snd_usb_audio v
Sep 09 18:22:47 winbook kernel: snd_soc_sst_byt_rt5640_mach coretemp snd_soc_sst_baytrail_pcm iTCO_vendor_support snd_soc_sst_ipc kvm_intel snd_soc_sst_dsp gpio_keys kvm snd_intel_sst_acpi snd_intel_sst_core sn
Sep 09 18:22:47 winbook kernel: lockd grace sunrpc i915 mmc_block i2c_algo_bit drm_kms_helper drm sdhci_acpi video sdhci mmc_core i2c_hid [last unloaded: goodix]
Sep 09 18:22:47 winbook kernel: CPU: 3 PID: 3298 Comm: insmod Tainted: G OE 4.2.0-0.rc3.git4.2.fc22.i686 #1
Sep 09 18:22:47 winbook kernel: Hardware name: WinBook TW100/TW100, BIOS 1.02.00 08/25/2014
Sep 09 18:22:47 winbook kernel: c0d439a7 bb4c1aaf 00000000 de2f7bb4 c0aa23b9 de2f7bf4 de2f7be4 c045c677
Sep 09 18:22:47 winbook kernel: c0cbe3b8 de2f7c14 00000ce2 c0cbe3f4 00000152 c073cd87 c073cd87 f7c5e0b8
Sep 09 18:22:47 winbook kernel: f4bb309c f7c5e0b0 de2f7c00 c045c6ee 00000009 de2f7bf4 c0cbe3b8 de2f7c14
Sep 09 18:22:47 winbook kernel: Call Trace:
Sep 09 18:22:47 winbook kernel: [<c0aa23b9>] dump_stack+0x41/0x52
Sep 09 18:22:47 winbook kernel: [<c045c677>] warn_slowpath_common+0x87/0xc0
Sep 09 18:22:47 winbook kernel: [<c073cd87>] ? byt_gpio_direction_output+0x97/0xa0
Sep 09 18:22:47 winbook kernel: [<c073cd87>] ? byt_gpio_direction_output+0x97/0xa0
Sep 09 18:22:47 winbook kernel: [<c045c6ee>] warn_slowpath_fmt+0x3e/0x60
Sep 09 18:22:47 winbook kernel: [<c073cd87>] byt_gpio_direction_output+0x97/0xa0
Sep 09 18:22:47 winbook kernel: [<c073ccf0>] ? byt_gpio_irq_handler+0xc0/0xc0
Sep 09 18:22:47 winbook kernel: [<c073f6f9>] _gpiod_direction_output_raw+0x59/0x1c0
Sep 09 18:22:47 winbook kernel: [<c073f8ca>] gpiod_direction_output+0x2a/0x50
Sep 09 18:22:47 winbook kernel: [<c04bc74b>] ? msleep+0x2b/0x40
Sep 09 18:22:47 winbook kernel: [<f935a87e>] goodix_reset+0x3e/0x90 [goodix_backport]
Sep 09 18:22:47 winbook kernel: [<f935b1ae>] goodix_ts_probe+0x27e/0x5a0 [goodix_backport]
Sep 09 18:22:47 winbook kernel: [<c090ea01>] i2c_device_probe+0x101/0x1b0
Sep 09 18:22:47 winbook kernel: [<c0613a05>] ? sysfs_create_link+0x25/0x50
Sep 09 18:22:47 winbook kernel: [<f935af30>] ? goodix_configure_dev+0x1e0/0x1e0 [goodix_backport]
Which is the same error I had previously:
https://lkml.org/lkml/2015/6/30/434
I was testing this on a Onda v975w, but I'm now testing it on a WinBook
TW100.
<snip>
> +/*
> + * ACPI table specifies gpio pins in this order: first rst pin and
> + * then interrupt pin.
> + */
> +static const struct dmi_system_id goodix_rst_pin_first[] = {
> +#if defined(CONFIG_DMI) && defined(CONFIG_X86)
> + {
> + .ident = "WinBook TW100",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "WinBook"),
> + DMI_MATCH(DMI_PRODUCT_NAME, "TW100")
> + }
> + },
The DSDT for the WinBook one is here:
https://people.gnome.org/~hadess/Winbook%20TW100%20DSDT.dsl
For reference, the DSDT for the Onda, the tablet I tested this on some
months ago:
https://bugzilla.kernel.org/attachment.cgi?id=149331
Cheers
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Aleksei Mamlin <mamlinav@gmail.com> |
|---|---|
| Date | 2015-09-15 11:50 +0200 |
| Message-ID | <q8V29-12p-9@gated-at.bofh.it> |
| In reply to | #1220222 |
On Mon, 7 Sep 2015 17:36:17 +0300
Irina Tirdea <irina.tirdea@intel.com> wrote:
> After power on, it is recommended that the driver resets the device.
> The reset procedure timing is described in the datasheet and is used
> at device init (before writing device configuration) and
> for power management. It is a sequence of setting the interrupt
> and reset pins high/low at specific timing intervals. This procedure
> also includes setting the slave address to the one specified in the
> ACPI/device tree.
>
> This is based on Goodix datasheets for GT911 and GT9271 and on Goodix
> driver gt9xx.c for Android (publicly available in Android kernel
> trees for various devices).
>
> For reset the driver needs to control the interrupt and
> reset gpio pins (configured through ACPI/device tree). For devices
> that do not have the gpio pins declared, the functionality depending
> on these pins will not be available, but the device can still be used
> with basic functionality.
>
> Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
> Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
> ---
> .../bindings/input/touchscreen/goodix.txt | 5 +
> drivers/input/touchscreen/goodix.c | 136 +++++++++++++++++++++
> 2 files changed, 141 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> index 8ba98ee..c0715f8 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/goodix.txt
> @@ -12,6 +12,8 @@ Required properties:
> - reg : I2C address of the chip. Should be 0x5d or 0x14
> - interrupt-parent : Interrupt controller to which the chip is connected
> - interrupts : Interrupt to which the chip is connected
> + - gpios : GPIOS the chip is connected to: first one is the
> + interrupt gpio and second one the reset gpio.
>
> Example:
>
> @@ -23,6 +25,9 @@ Example:
> reg = <0x5d>;
> interrupt-parent = <&gpio>;
> interrupts = <0 0>;
> +
> + gpios = <&gpio1 0 0>, /* INT */
> + <&gpio1 1 0>; /* RST */
> };
>
> /* ... */
> diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
> index 7be6eab..8edfc06 100644
> --- a/drivers/input/touchscreen/goodix.c
> +++ b/drivers/input/touchscreen/goodix.c
> @@ -17,6 +17,7 @@
> #include <linux/acpi.h>
> #include <linux/delay.h>
> #include <linux/dmi.h>
> +#include <linux/gpio.h>
> #include <linux/i2c.h>
> #include <linux/input.h>
> #include <linux/input/mt.h>
> @@ -37,6 +38,8 @@ struct goodix_ts_data {
> unsigned int int_trigger_type;
> bool rotated_screen;
> int cfg_len;
> + struct gpio_desc *gpiod_int;
> + struct gpio_desc *gpiod_rst;
> };
>
> #define GOODIX_MAX_HEIGHT 4096
> @@ -89,6 +92,30 @@ static const struct dmi_system_id rotated_screen[] = {
> {}
> };
>
> +/*
> + * ACPI table specifies gpio pins in this order: first rst pin and
> + * then interrupt pin.
> + */
> +static const struct dmi_system_id goodix_rst_pin_first[] = {
> +#if defined(CONFIG_DMI) && defined(CONFIG_X86)
> + {
> + .ident = "WinBook TW100",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "WinBook"),
> + DMI_MATCH(DMI_PRODUCT_NAME, "TW100")
> + }
> + },
> + {
> + .ident = "WinBook TW700",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "WinBook"),
> + DMI_MATCH(DMI_PRODUCT_NAME, "TW700")
> + },
> + },
> +#endif
> + {}
> +};
> +
> /**
> * goodix_i2c_read - read data from a register of the i2c slave device.
> *
> @@ -237,6 +264,102 @@ static irqreturn_t goodix_ts_irq_handler(int irq, void *dev_id)
> return IRQ_HANDLED;
> }
>
> +static int goodix_int_sync(struct goodix_ts_data *ts)
> +{
> + int error;
> +
> + error = gpiod_direction_output(ts->gpiod_int, 0);
> + if (error)
> + return error;
> + msleep(50); /* T5: 50ms */
> +
> + return gpiod_direction_input(ts->gpiod_int);
> +}
> +
> +/**
> + * goodix_reset - Reset device during power on
> + *
> + * @ts: goodix_ts_data pointer
> + */
> +static int goodix_reset(struct goodix_ts_data *ts)
> +{
> + int error;
> +
> + /* begin select I2C slave addr */
> + error = gpiod_direction_output(ts->gpiod_rst, 0);
> + if (error)
> + return error;
> + msleep(20); /* T2: > 10ms */
> + /* HIGH: 0x28/0x29, LOW: 0xBA/0xBB */
> + error = gpiod_direction_output(ts->gpiod_int, ts->client->addr == 0x14);
> + if (error)
> + return error;
> + usleep_range(100, 2000); /* T3: > 100us */
> + error = gpiod_direction_output(ts->gpiod_rst, 1);
> + if (error)
> + return error;
> + usleep_range(6000, 10000); /* T4: > 5ms */
> + /* end select I2C slave addr */
> + error = gpiod_direction_input(ts->gpiod_rst);
> + if (error)
> + return error;
> + return goodix_int_sync(ts);
> +}
> +
> +/**
> + * goodix_get_gpio_config - Get GPIO config from ACPI/DT
> + *
> + * @ts: goodix_ts_data pointer
> + */
> +static int goodix_get_gpio_config(struct goodix_ts_data *ts,
> + const struct i2c_device_id *i2c_id)
> +{
> + int error;
> + struct device *dev;
> + struct gpio_desc *gpiod;
> + /* Default gpio pin order: irq, rst */
> + int irq_idx = 0, rst_idx = 1;
> +
> + if (!ts->client)
> + return -EINVAL;
> + dev = &ts->client->dev;
> +
> + if (dmi_check_system(goodix_rst_pin_first)) {
> + dev_dbg(&ts->client->dev,
> + "Applying 'reverse gpio pin order' quirk\n");
> + rst_idx = 0;
> + irq_idx = 1;
> + }
> +
> + /* Get interrupt GPIO pin number */
> + gpiod = devm_gpiod_get_index(dev, NULL, irq_idx, GPIOD_IN);
> + if (IS_ERR(gpiod)) {
> + error = PTR_ERR(gpiod);
> + if (error != -EPROBE_DEFER)
> + dev_warn(dev, "Failed to get GPIO %d: %d\n",
> + irq_idx, error);
> + if (error == -ENOENT)
> + return 0;
> + return error;
> + }
> + ts->gpiod_int = gpiod;
> +
> + /* Get the reset line GPIO pin number */
> + gpiod = devm_gpiod_get_index(dev, NULL, rst_idx, GPIOD_IN);
> + if (IS_ERR(gpiod)) {
> + error = PTR_ERR(gpiod);
> + if (error != -EPROBE_DEFER)
> + dev_warn(dev, "Failed to get GPIO %d: %d\n",
> + rst_idx, error);
> + if (error == -ENOENT)
> + return 0;
> + return error;
> + }
> + ts->gpiod_rst = gpiod;
> +
> + return 0;
> +}
> +
> /**
> * goodix_read_config - Read the embedded configuration of the panel
> *
> @@ -419,6 +542,19 @@ static int goodix_ts_probe(struct i2c_client *client,
>
> ts->cfg_len = goodix_get_cfg_len(id_info);
>
> + error = goodix_get_gpio_config(ts, id);
> + if (error)
> + return error;
> +
> + if (ts->gpiod_int && ts->gpiod_rst) {
> + /* reset the controller */
> + error = goodix_reset(ts);
> + if (error) {
> + dev_err(&client->dev, "Controller reset failed.\n");
> + return error;
> + }
> + }
> +
On devices with devicetree, such as ARM tablets, we can set I2C address via DT, so driver should reset controller and set right address.
If we don't do this we get "I2C communication failure: -6".
Also, most of touchscreen drivers tries to reset controllers before start communicating, so we need do the same.
> goodix_read_config(ts);
>
> error = goodix_request_input_dev(ts, version_info, id_info);
> --
> 1.9.1
>
--
Thanks and regards,
Aleksei Mamlin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Tirdea, Irina" <irina.tirdea@intel.com> |
|---|---|
| Date | 2015-09-15 16:50 +0200 |
| Message-ID | <q8ZIw-7Nu-57@gated-at.bofh.it> |
| In reply to | #1224921 |
> -----Original Message-----
> From: Aleksei Mamlin [mailto:mamlinav@gmail.com]
> Sent: 15 September, 2015 12:48
> To: Tirdea, Irina
> Cc: Dmitry Torokhov; Bastien Nocera; linux-input@vger.kernel.org; Mark Rutland; Purdila, Octavian; linux-kernel@vger.kernel.org;
> devicetree@vger.kernel.org
> Subject: Re: [PATCH v5 3/9] Input: goodix - reset device at init
>
> On Mon, 7 Sep 2015 17:36:17 +0300
> Irina Tirdea <irina.tirdea@intel.com> wrote:
>
> > After power on, it is recommended that the driver resets the device.
> > The reset procedure timing is described in the datasheet and is used
> > at device init (before writing device configuration) and
> > for power management. It is a sequence of setting the interrupt
> > and reset pins high/low at specific timing intervals. This procedure
> > also includes setting the slave address to the one specified in the
> > ACPI/device tree.
> >
> > This is based on Goodix datasheets for GT911 and GT9271 and on Goodix
> > driver gt9xx.c for Android (publicly available in Android kernel
> > trees for various devices).
> >
> > For reset the driver needs to control the interrupt and
> > reset gpio pins (configured through ACPI/device tree). For devices
> > that do not have the gpio pins declared, the functionality depending
> > on these pins will not be available, but the device can still be used
> > with basic functionality.
> >
> > Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
> > Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
> > ---
> > .../bindings/input/touchscreen/goodix.txt | 5 +
> > drivers/input/touchscreen/goodix.c | 136 +++++++++++++++++++++
> > 2 files changed, 141 insertions(+)
> >
<snip>
> > +/**
> > + * goodix_reset - Reset device during power on
> > + *
> > + * @ts: goodix_ts_data pointer
> > + */
> > +static int goodix_reset(struct goodix_ts_data *ts)
> > +{
> > + int error;
> > +
> > + /* begin select I2C slave addr */
> > + error = gpiod_direction_output(ts->gpiod_rst, 0);
> > + if (error)
> > + return error;
> > + msleep(20); /* T2: > 10ms */
> > + /* HIGH: 0x28/0x29, LOW: 0xBA/0xBB */
> > + error = gpiod_direction_output(ts->gpiod_int, ts->client->addr == 0x14);
> > + if (error)
> > + return error;
> > + usleep_range(100, 2000); /* T3: > 100us */
> > + error = gpiod_direction_output(ts->gpiod_rst, 1);
> > + if (error)
> > + return error;
> > + usleep_range(6000, 10000); /* T4: > 5ms */
> > + /* end select I2C slave addr */
> > + error = gpiod_direction_input(ts->gpiod_rst);
> > + if (error)
> > + return error;
> > + return goodix_int_sync(ts);
> > +}
> > +
<snip>
> > /**
> > * goodix_read_config - Read the embedded configuration of the panel
> > *
> > @@ -419,6 +542,19 @@ static int goodix_ts_probe(struct i2c_client *client,
> >
> > ts->cfg_len = goodix_get_cfg_len(id_info);
> >
> > + error = goodix_get_gpio_config(ts, id);
> > + if (error)
> > + return error;
> > +
> > + if (ts->gpiod_int && ts->gpiod_rst) {
> > + /* reset the controller */
> > + error = goodix_reset(ts);
> > + if (error) {
> > + dev_err(&client->dev, "Controller reset failed.\n");
> > + return error;
> > + }
> > + }
> > +
>
> On devices with devicetree, such as ARM tablets, we can set I2C address via DT, so driver should reset controller and set right address.
> If we don't do this we get "I2C communication failure: -6".
>
This is exactly what this patch tries to do. The address set in ACPI or DT will be available
in ts->client->addr. The reset code checks for the address set by ACPI/DT and configures
the device to use that address.
> Also, most of touchscreen drivers tries to reset controllers before start communicating, so we need do the same.
Good catch! goodix_reset should be called before goodix_i2c_test. I'll send a new version with this fix.
Thanks,
Irina
>
> > goodix_read_config(ts);
> >
> > error = goodix_request_input_dev(ts, version_info, id_info);
> > --
> > 1.9.1
> >
>
>
> --
> Thanks and regards,
> Aleksei Mamlin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web