Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1549584 > unrolled thread

[PATCH 0/4] Add touch key driver support for TM2

Started byJaechul Lee <jcsing.lee@samsung.com>
First post2017-01-03 09:00 +0100
Last post2017-01-03 11:10 +0100
Articles 18 — 7 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.


Contents

  [PATCH 0/4] Add touch key driver support for TM2 Jaechul Lee <jcsing.lee@samsung.com> - 2017-01-03 09:00 +0100
    [PATCH 2/4] input: tm2-touchkey: Add touchkey driver support for TM2 Jaechul Lee <jcsing.lee@samsung.com> - 2017-01-03 09:00 +0100
      Re: [PATCH 2/4] input: tm2-touchkey: Add touchkey driver support for  TM2 Javier Martinez Canillas <javier@osg.samsung.com> - 2017-01-03 14:20 +0100
        Re: [PATCH 2/4] input: tm2-touchkey: Add touchkey driver support for  TM2 Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-01-03 20:00 +0100
      Re: [PATCH 2/4] input: tm2-touchkey: Add touchkey driver support for  TM2 Krzysztof Kozlowski <krzk@kernel.org> - 2017-01-03 18:10 +0100
    Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from  each other Andi Shyti <andi.shyti@samsung.com> - 2017-01-03 09:20 +0100
    Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent  from each other Krzysztof Kozlowski <krzk@kernel.org> - 2017-01-03 09:30 +0100
      Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from  each other Andi Shyti <andi.shyti@samsung.com> - 2017-01-03 11:00 +0100
        Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent  from each other Chanwoo Choi <cwchoi00@gmail.com> - 2017-01-03 12:50 +0100
          Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from  each other Andi Shyti <andi.shyti@samsung.com> - 2017-01-03 13:00 +0100
            Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent  from each other Javier Martinez Canillas <javier@osg.samsung.com> - 2017-01-03 13:20 +0100
              Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent  from each other Andi Shyti <andi@etezian.org> - 2017-01-03 15:50 +0100
                Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent  from each other Javier Martinez Canillas <javier@osg.samsung.com> - 2017-01-03 16:10 +0100
                Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent  from each other Chanwoo Choi <cwchoi00@gmail.com> - 2017-01-03 17:10 +0100
                  Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent  from each other Krzysztof Kozlowski <krzk@kernel.org> - 2017-01-03 18:00 +0100
        Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from  each other Andi Shyti <andi.shyti@samsung.com> - 2017-01-03 11:30 +0100
          Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent  from each other Krzysztof Kozlowski <krzk@kernel.org> - 2017-01-03 17:50 +0100
        Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent  from each other Krzysztof Kozlowski <krzk@kernel.org> - 2017-01-03 11:10 +0100

#1549584 — [PATCH 0/4] Add touch key driver support for TM2

FromJaechul Lee <jcsing.lee@samsung.com>
Date2017-01-03 09:00 +0100
Subject[PATCH 0/4] Add touch key driver support for TM2
Message-ID<sVsaJ-2WV-3@gated-at.bofh.it>
Hi,

This patchset adds support for the tm2 touchkey device.

The driver has been ported from Tizen Kernel, originally written
by Beomho. I ported it to the latest mainline Kernel.

dts has been separated between tm2 and tm2e because touchkey is present in tm2
but not tm2e.

Best Regards,
Jaechul

Andi Shyti (1):
  arm64: dts: exynos: make tm2 and tm2e independent from each other

Jaechul Lee (3):
  input: Add support for the tm2 touchkey device driver
  input: tm2-touchkey: Add touchkey driver support for TM2
  arm64: dts: exynos: Add tm2 touchkey node

 .../bindings/input/samsung,tm2-touchkey.txt        |   27 +
 .../boot/dts/exynos/exynos5433-tm2-common.dtsi     | 1046 ++++++++++++++++++++
 arch/arm64/boot/dts/exynos/exynos5433-tm2.dts      | 1037 +------------------
 arch/arm64/boot/dts/exynos/exynos5433-tm2e.dts     |    2 +-
 drivers/input/keyboard/Kconfig                     |   11 +
 drivers/input/keyboard/Makefile                    |    1 +
 drivers/input/keyboard/tm2-touchkey.c              |  326 ++++++
 7 files changed, 1422 insertions(+), 1028 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/samsung,tm2-touchkey.txt
 create mode 100644 arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
 create mode 100644 drivers/input/keyboard/tm2-touchkey.c

-- 
2.7.4

[toc] | [next] | [standalone]


#1549586 — [PATCH 2/4] input: tm2-touchkey: Add touchkey driver support for TM2

FromJaechul Lee <jcsing.lee@samsung.com>
Date2017-01-03 09:00 +0100
Subject[PATCH 2/4] input: tm2-touchkey: Add touchkey driver support for TM2
Message-ID<sVsaK-2WV-23@gated-at.bofh.it>
In reply to#1549584
This patch adds support for the TM2 touch key and led
functionlity.

The driver interfaces with userspace through an input device and
reports KEY_PHONE and KEY_BACK event types. LED brightness can be
controlled by "/sys/class/leds/tm2-touchkey/brightness".

Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
---
 drivers/input/keyboard/Kconfig        |  11 ++
 drivers/input/keyboard/Makefile       |   1 +
 drivers/input/keyboard/tm2-touchkey.c | 326 ++++++++++++++++++++++++++++++++++
 3 files changed, 338 insertions(+)
 create mode 100644 drivers/input/keyboard/tm2-touchkey.c

diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index cbd75cf..72c0ba1 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -666,6 +666,17 @@ config KEYBOARD_TC3589X
 	  To compile this driver as a module, choose M here: the
 	  module will be called tc3589x-keypad.
 
+config KEYBOARD_TM2_TOUCHKEY
+	tristate "tm2-touchkey support"
+	depends on I2C
+	help
+	  Say Y here to enable the tm2-touchkey.
+	  touchkey driver for tm2. This driver can enable
+	  the interrupt and make input events and control led brightness.
+
+	  To compile this driver as a module, choose M here.
+	  module will be called tm2-touchkey
+
 config KEYBOARD_TWL4030
 	tristate "TI TWL4030/TWL5030/TPS659x0 keypad support"
 	depends on TWL4030_CORE
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index d9f4cfc..7d9acff 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -61,6 +61,7 @@ obj-$(CONFIG_KEYBOARD_SUN4I_LRADC)	+= sun4i-lradc-keys.o
 obj-$(CONFIG_KEYBOARD_SUNKBD)		+= sunkbd.o
 obj-$(CONFIG_KEYBOARD_TC3589X)		+= tc3589x-keypad.o
 obj-$(CONFIG_KEYBOARD_TEGRA)		+= tegra-kbc.o
+obj-$(CONFIG_KEYBOARD_TM2_TOUCHKEY)	+= tm2-touchkey.o
 obj-$(CONFIG_KEYBOARD_TWL4030)		+= twl4030_keypad.o
 obj-$(CONFIG_KEYBOARD_XTKBD)		+= xtkbd.o
 obj-$(CONFIG_KEYBOARD_W90P910)		+= w90p910_keypad.o
diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c
new file mode 100644
index 0000000..d9575d8
--- /dev/null
+++ b/drivers/input/keyboard/tm2-touchkey.c
@@ -0,0 +1,326 @@
+/*
+ * Driver for keys on GPIO lines capable of generating interrupts.
+ *
+ * Copyright 2005 Phil Blundell
+ * Copyright 2016 Samsung Electronics Co., Ltd.
+ *
+ * Author: Beomho Seo <beomho.seo@samsung.com>
+ * Author: Jaechul Lee <jcsing.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/i2c.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/leds.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/pm.h>
+#include <linux/regulator/consumer.h>
+#include <linux/workqueue.h>
+
+#define TM2_TOUCHKEY_DEV_NAME			"tm2-touchkey"
+#define TM2_TOUCHKEY_KEYCODE_REG			0x03
+#define TM2_TOUCHKEY_BASE_REG			0x00
+#define TM2_TOUCHKEY_CMD_LED_ON			0x10
+#define TM2_TOUCHKEY_CMD_LED_OFF			0x20
+#define TM2_TOUCHKEY_BIT_PRESS_EV			BIT(3)
+#define TM2_TOUCHKEY_BIT_KEYCODE			GENMASK(2, 0)
+#define TM2_TOUCHKEY_LED_VOLTAGE_MIN			2500000
+#define TM2_TOUCHKEY_LED_VOLTAGE_MAX			3300000
+
+enum {
+	TM2_TOUCHKEY_KEY_MENU = 0x1,
+	TM2_TOUCHKEY_KEY_BACK,
+};
+
+#define tm2_touchkey_power_enable(x) __tm2_touchkey_power_onoff(x, 1)
+#define tm2_touchkey_power_disable(x) __tm2_touchkey_power_onoff(x, 0)
+
+struct tm2_touchkey_data {
+	struct i2c_client *client;
+	struct input_dev *input_dev;
+	struct led_classdev led_dev;
+
+	u8 keycode_type;
+	u8 pressed;
+	struct work_struct irq_work;
+
+	bool power_onoff;
+	struct regulator *regulator_vcc;	/* 1.8V */
+	struct regulator *regulator_vdd;	/* 3.3V */
+};
+
+static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
+						enum led_brightness brightness)
+{
+	struct tm2_touchkey_data *samsung_touchkey =
+	    container_of(led_dev, struct tm2_touchkey_data, led_dev);
+	u32 volt;
+	u8 data;
+
+	if (brightness == LED_OFF) {
+		volt = TM2_TOUCHKEY_LED_VOLTAGE_MIN;
+		data = TM2_TOUCHKEY_CMD_LED_OFF;
+	} else {
+		volt = TM2_TOUCHKEY_LED_VOLTAGE_MAX;
+		data = TM2_TOUCHKEY_CMD_LED_ON;
+	}
+
+	regulator_set_voltage(samsung_touchkey->regulator_vdd, volt, volt);
+	i2c_smbus_write_byte_data(samsung_touchkey->client,
+				  TM2_TOUCHKEY_BASE_REG, data);
+}
+
+static int __tm2_touchkey_power_onoff(struct tm2_touchkey_data
+					  *samsung_touchkey, bool onoff)
+{
+	int ret = 0;
+
+	if (samsung_touchkey->power_onoff == onoff)
+		return ret;
+
+	if (onoff) {
+		ret = regulator_enable(samsung_touchkey->regulator_vcc);
+		if (ret)
+			return ret;
+
+		ret = regulator_enable(samsung_touchkey->regulator_vdd);
+		if (ret) {
+			regulator_disable(samsung_touchkey->regulator_vcc);
+			return ret;
+		}
+		msleep(150);
+	} else {
+		int err;
+
+		err = regulator_disable(samsung_touchkey->regulator_vcc);
+		if (err)
+			ret = err;
+
+		err = regulator_disable(samsung_touchkey->regulator_vdd);
+		if (err && !ret)
+			ret = err;
+	}
+	samsung_touchkey->power_onoff = onoff;
+
+	return ret;
+}
+
+static void tm2_touchkey_irq_work(struct work_struct *irq_work)
+{
+	struct tm2_touchkey_data *samsung_touchkey =
+	    container_of(irq_work, struct tm2_touchkey_data, irq_work);
+
+	if (!samsung_touchkey->pressed) {
+		input_report_key(samsung_touchkey->input_dev, KEY_PHONE, 0);
+		input_report_key(samsung_touchkey->input_dev, KEY_BACK, 0);
+	} else {
+		if (samsung_touchkey->keycode_type == TM2_TOUCHKEY_KEY_MENU)
+			input_report_key(samsung_touchkey->input_dev,
+					 KEY_PHONE, 1);
+		else
+			input_report_key(samsung_touchkey->input_dev,
+					 KEY_BACK, 1);
+	}
+	input_sync(samsung_touchkey->input_dev);
+}
+
+static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
+{
+	struct tm2_touchkey_data *samsung_touchkey = devid;
+	u32 data;
+
+	data = i2c_smbus_read_byte_data(samsung_touchkey->client,
+					TM2_TOUCHKEY_KEYCODE_REG);
+
+	if (data < 0) {
+		dev_err(&samsung_touchkey->client->dev, "Failed to read i2c data\n");
+		return IRQ_HANDLED;
+	}
+
+	samsung_touchkey->keycode_type = data & TM2_TOUCHKEY_BIT_KEYCODE;
+	samsung_touchkey->pressed = !(data & TM2_TOUCHKEY_BIT_PRESS_EV);
+
+	if (samsung_touchkey->keycode_type != TM2_TOUCHKEY_KEY_MENU &&
+	    samsung_touchkey->keycode_type != TM2_TOUCHKEY_KEY_BACK)
+		return IRQ_HANDLED;
+
+	schedule_work(&samsung_touchkey->irq_work);
+
+	return IRQ_HANDLED;
+}
+
+static int tm2_touchkey_probe(struct i2c_client *client,
+				  const struct i2c_device_id *id)
+{
+	struct tm2_touchkey_data *samsung_touchkey;
+	int ret;
+
+	ret = i2c_check_functionality(client->adapter,
+				      I2C_FUNC_SMBUS_BYTE |
+				      I2C_FUNC_SMBUS_BYTE_DATA);
+	if (!ret) {
+		dev_err(&client->dev, "No I2C functionality found\n");
+		return -ENODEV;
+	}
+
+	samsung_touchkey = devm_kzalloc(&client->dev,
+			sizeof(struct tm2_touchkey_data), GFP_KERNEL);
+
+	if (!samsung_touchkey) {
+		dev_err(&client->dev, "Failed to allocate memory.\n");
+		return -ENOMEM;
+	}
+
+	samsung_touchkey->client = client;
+	i2c_set_clientdata(client, samsung_touchkey);
+	INIT_WORK(&samsung_touchkey->irq_work, tm2_touchkey_irq_work);
+
+	/* regulator */
+	samsung_touchkey->regulator_vcc =
+				devm_regulator_get(&client->dev, "vcc");
+	if (IS_ERR(samsung_touchkey->regulator_vcc)) {
+		dev_err(&client->dev, "Failed to get vcc regulator\n");
+		return PTR_ERR(samsung_touchkey->regulator_vcc);
+	}
+
+	samsung_touchkey->regulator_vdd =
+				devm_regulator_get(&client->dev, "vdd");
+	if (IS_ERR(samsung_touchkey->regulator_vdd)) {
+		dev_err(&client->dev, "Failed to get vdd regulator\n");
+		return PTR_ERR(samsung_touchkey->regulator_vcc);
+	}
+
+	/* power */
+	ret = tm2_touchkey_power_enable(samsung_touchkey);
+	if (ret) {
+		dev_err(&client->dev, "Failed to enable power\n");
+		return ret;
+	}
+
+	/* irq */
+	ret = devm_request_threaded_irq(&client->dev,
+					client->irq, NULL,
+					tm2_touchkey_irq_handler,
+					IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+					TM2_TOUCHKEY_DEV_NAME,
+					samsung_touchkey);
+	if (ret) {
+		dev_err(&client->dev, "Failed to request threaded irq\n");
+		return ret;
+	}
+
+	/* input device */
+	samsung_touchkey->input_dev = devm_input_allocate_device(&client->dev);
+	if (!samsung_touchkey->input_dev) {
+		dev_err(&client->dev, "Failed to alloc input device.\n");
+		return -ENOMEM;
+	}
+	samsung_touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME;
+	samsung_touchkey->input_dev->id.bustype = BUS_I2C;
+	samsung_touchkey->input_dev->dev.parent = &client->dev;
+
+	set_bit(EV_KEY, samsung_touchkey->input_dev->evbit);
+	set_bit(KEY_PHONE, samsung_touchkey->input_dev->keybit);
+	set_bit(KEY_BACK, samsung_touchkey->input_dev->keybit);
+	input_set_drvdata(samsung_touchkey->input_dev, samsung_touchkey);
+
+	ret = input_register_device(samsung_touchkey->input_dev);
+	if (ret) {
+		dev_err(&client->dev, "Failed to register input device.\n");
+		return ret;
+	}
+
+	/* led device */
+	samsung_touchkey->led_dev.name = TM2_TOUCHKEY_DEV_NAME;
+	samsung_touchkey->led_dev.brightness = LED_FULL;
+	samsung_touchkey->led_dev.max_brightness = LED_FULL;
+	samsung_touchkey->led_dev.brightness_set =
+						tm2_touchkey_led_brightness_set;
+
+	ret = devm_led_classdev_register(&client->dev,
+					 &samsung_touchkey->led_dev);
+	if (ret < 0) {
+		dev_err(&client->dev, "Failed to register touchkey led\n");
+		return ret;
+	}
+
+	return 0;
+}
+
+static void tm2_touchkey_shutdown(struct i2c_client *client)
+{
+	struct tm2_touchkey_data *samsung_touchkey =
+						i2c_get_clientdata(client);
+	int ret;
+
+	disable_irq(client->irq);
+	ret = tm2_touchkey_power_disable(samsung_touchkey);
+	if (ret)
+		dev_err(&client->dev, "Failed to disable power\n");
+}
+
+static int tm2_touchkey_suspend(struct device *dev)
+{
+	struct tm2_touchkey_data *samsung_touchkey = dev_get_drvdata(dev);
+	int ret;
+
+	disable_irq(samsung_touchkey->client->irq);
+	ret = tm2_touchkey_power_disable(samsung_touchkey);
+	if (ret)
+		dev_err(dev, "Failed to disable power\n");
+
+	return ret;
+}
+
+static int tm2_touchkey_resume(struct device *dev)
+{
+	struct tm2_touchkey_data *samsung_touchkey = dev_get_drvdata(dev);
+	int ret;
+
+	enable_irq(samsung_touchkey->client->irq);
+	ret = tm2_touchkey_power_enable(samsung_touchkey);
+	if (ret)
+		dev_err(dev, "Failed to enable power\n");
+
+	return ret;
+}
+
+static SIMPLE_DEV_PM_OPS(tm2_touchkey_pm_ops, tm2_touchkey_suspend,
+							tm2_touchkey_resume);
+
+static const struct i2c_device_id tm2_touchkey_id_table[] = {
+	{TM2_TOUCHKEY_DEV_NAME, 0},
+	{},
+};
+
+static const struct of_device_id tm2_touchkey_of_match[] = {
+	{.compatible = "samsung,tm2-touchkey",},
+	{},
+};
+
+static struct i2c_driver tm2_touchkey_driver = {
+	.driver = {
+		.name = TM2_TOUCHKEY_DEV_NAME,
+		.pm = &tm2_touchkey_pm_ops,
+		.of_match_table = of_match_ptr(tm2_touchkey_of_match),
+	},
+	.probe = tm2_touchkey_probe,
+	.shutdown = tm2_touchkey_shutdown,
+	.id_table = tm2_touchkey_id_table,
+};
+
+module_i2c_driver(tm2_touchkey_driver);
+
+MODULE_AUTHOR("Beomho Seo <beomho.seo@samsung.com>");
+MODULE_AUTHOR("Jaechul Lee <jcsing.lee@samsung.com>");
+MODULE_DESCRIPTION("Samsung touchkey driver");
+MODULE_LICENSE("GPL v2");
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1549750 — Re: [PATCH 2/4] input: tm2-touchkey: Add touchkey driver support for TM2

FromJavier Martinez Canillas <javier@osg.samsung.com>
Date2017-01-03 14:20 +0100
SubjectRe: [PATCH 2/4] input: tm2-touchkey: Add touchkey driver support for TM2
Message-ID<sVxaq-6Tb-21@gated-at.bofh.it>
In reply to#1549586
Hello Jaechul,

On 01/03/2017 04:57 AM, Jaechul Lee wrote:
> This patch adds support for the TM2 touch key and led
> functionlity.
> 

s/functionlity/functionality

> The driver interfaces with userspace through an input device and
> reports KEY_PHONE and KEY_BACK event types. LED brightness can be
> controlled by "/sys/class/leds/tm2-touchkey/brightness".
> 
> Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> ---
>  drivers/input/keyboard/Kconfig        |  11 ++
>  drivers/input/keyboard/Makefile       |   1 +
>  drivers/input/keyboard/tm2-touchkey.c | 326 ++++++++++++++++++++++++++++++++++
>  3 files changed, 338 insertions(+)
>  create mode 100644 drivers/input/keyboard/tm2-touchkey.c
> 
> diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
> index cbd75cf..72c0ba1 100644
> --- a/drivers/input/keyboard/Kconfig
> +++ b/drivers/input/keyboard/Kconfig
> @@ -666,6 +666,17 @@ config KEYBOARD_TC3589X
>  	  To compile this driver as a module, choose M here: the
>  	  module will be called tc3589x-keypad.
>  
> +config KEYBOARD_TM2_TOUCHKEY
> +	tristate "tm2-touchkey support"
> +	depends on I2C
> +	help
> +	  Say Y here to enable the tm2-touchkey.
> +	  touchkey driver for tm2. This driver can enable
> +	  the interrupt and make input events and control led brightness.
> +
> +	  To compile this driver as a module, choose M here.
> +	  module will be called tm2-touchkey
> +
>  config KEYBOARD_TWL4030
>  	tristate "TI TWL4030/TWL5030/TPS659x0 keypad support"
>  	depends on TWL4030_CORE
> diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
> index d9f4cfc..7d9acff 100644
> --- a/drivers/input/keyboard/Makefile
> +++ b/drivers/input/keyboard/Makefile
> @@ -61,6 +61,7 @@ obj-$(CONFIG_KEYBOARD_SUN4I_LRADC)	+= sun4i-lradc-keys.o
>  obj-$(CONFIG_KEYBOARD_SUNKBD)		+= sunkbd.o
>  obj-$(CONFIG_KEYBOARD_TC3589X)		+= tc3589x-keypad.o
>  obj-$(CONFIG_KEYBOARD_TEGRA)		+= tegra-kbc.o
> +obj-$(CONFIG_KEYBOARD_TM2_TOUCHKEY)	+= tm2-touchkey.o
>  obj-$(CONFIG_KEYBOARD_TWL4030)		+= twl4030_keypad.o
>  obj-$(CONFIG_KEYBOARD_XTKBD)		+= xtkbd.o
>  obj-$(CONFIG_KEYBOARD_W90P910)		+= w90p910_keypad.o
> diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c
> new file mode 100644
> index 0000000..d9575d8
> --- /dev/null
> +++ b/drivers/input/keyboard/tm2-touchkey.c
> @@ -0,0 +1,326 @@
> +/*
> + * Driver for keys on GPIO lines capable of generating interrupts.
> + *
> + * Copyright 2005 Phil Blundell
> + * Copyright 2016 Samsung Electronics Co., Ltd.
> + *
> + * Author: Beomho Seo <beomho.seo@samsung.com>
> + * Author: Jaechul Lee <jcsing.lee@samsung.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <linux/bitops.h>
> +#include <linux/delay.h>
> +#include <linux/device.h>
> +#include <linux/i2c.h>
> +#include <linux/input.h>
> +#include <linux/interrupt.h>
> +#include <linux/irq.h>
> +#include <linux/leds.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/pm.h>
> +#include <linux/regulator/consumer.h>
> +#include <linux/workqueue.h>
> +
> +#define TM2_TOUCHKEY_DEV_NAME			"tm2-touchkey"
> +#define TM2_TOUCHKEY_KEYCODE_REG			0x03
> +#define TM2_TOUCHKEY_BASE_REG			0x00
> +#define TM2_TOUCHKEY_CMD_LED_ON			0x10
> +#define TM2_TOUCHKEY_CMD_LED_OFF			0x20
> +#define TM2_TOUCHKEY_BIT_PRESS_EV			BIT(3)
> +#define TM2_TOUCHKEY_BIT_KEYCODE			GENMASK(2, 0)
> +#define TM2_TOUCHKEY_LED_VOLTAGE_MIN			2500000
> +#define TM2_TOUCHKEY_LED_VOLTAGE_MAX			3300000
> +
> +enum {
> +	TM2_TOUCHKEY_KEY_MENU = 0x1,
> +	TM2_TOUCHKEY_KEY_BACK,
> +};
> +
> +#define tm2_touchkey_power_enable(x) __tm2_touchkey_power_onoff(x, 1)
> +#define tm2_touchkey_power_disable(x) __tm2_touchkey_power_onoff(x, 0)
> +
> +struct tm2_touchkey_data {
> +	struct i2c_client *client;
> +	struct input_dev *input_dev;
> +	struct led_classdev led_dev;
> +
> +	u8 keycode_type;
> +	u8 pressed;
> +	struct work_struct irq_work;
> +
> +	bool power_onoff;
> +	struct regulator *regulator_vcc;	/* 1.8V */
> +	struct regulator *regulator_vdd;	/* 3.3V */
> +};
> +
> +static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
> +						enum led_brightness brightness)
> +{
> +	struct tm2_touchkey_data *samsung_touchkey =
> +	    container_of(led_dev, struct tm2_touchkey_data, led_dev);
> +	u32 volt;
> +	u8 data;
> +
> +	if (brightness == LED_OFF) {
> +		volt = TM2_TOUCHKEY_LED_VOLTAGE_MIN;
> +		data = TM2_TOUCHKEY_CMD_LED_OFF;
> +	} else {
> +		volt = TM2_TOUCHKEY_LED_VOLTAGE_MAX;
> +		data = TM2_TOUCHKEY_CMD_LED_ON;
> +	}
> +
> +	regulator_set_voltage(samsung_touchkey->regulator_vdd, volt, volt);
> +	i2c_smbus_write_byte_data(samsung_touchkey->client,
> +				  TM2_TOUCHKEY_BASE_REG, data);
> +}
> +
> +static int __tm2_touchkey_power_onoff(struct tm2_touchkey_data
> +					  *samsung_touchkey, bool onoff)
> +{
> +	int ret = 0;
> +
> +	if (samsung_touchkey->power_onoff == onoff)
> +		return ret;
> +
> +	if (onoff) {
> +		ret = regulator_enable(samsung_touchkey->regulator_vcc);
> +		if (ret)
> +			return ret;
> +
> +		ret = regulator_enable(samsung_touchkey->regulator_vdd);
> +		if (ret) {
> +			regulator_disable(samsung_touchkey->regulator_vcc);
> +			return ret;
> +		}

I would add a comment about the sleep here.

> +		msleep(150);
> +	} else {
> +		int err;
> +
> +		err = regulator_disable(samsung_touchkey->regulator_vcc);
> +		if (err)
> +			ret = err;
> +
> +		err = regulator_disable(samsung_touchkey->regulator_vdd);
> +		if (err && !ret)
> +			ret = err;
> +	}
> +	samsung_touchkey->power_onoff = onoff;
> +
> +	return ret;
> +}
> +
> +static void tm2_touchkey_irq_work(struct work_struct *irq_work)
> +{
> +	struct tm2_touchkey_data *samsung_touchkey =
> +	    container_of(irq_work, struct tm2_touchkey_data, irq_work);
> +
> +	if (!samsung_touchkey->pressed) {
> +		input_report_key(samsung_touchkey->input_dev, KEY_PHONE, 0);
> +		input_report_key(samsung_touchkey->input_dev, KEY_BACK, 0);
> +	} else {
> +		if (samsung_touchkey->keycode_type == TM2_TOUCHKEY_KEY_MENU)
> +			input_report_key(samsung_touchkey->input_dev,
> +					 KEY_PHONE, 1);
> +		else
> +			input_report_key(samsung_touchkey->input_dev,
> +					 KEY_BACK, 1);
> +	}
> +	input_sync(samsung_touchkey->input_dev);
> +}
> +
> +static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
> +{
> +	struct tm2_touchkey_data *samsung_touchkey = devid;
> +	u32 data;
> +
> +	data = i2c_smbus_read_byte_data(samsung_touchkey->client,
> +					TM2_TOUCHKEY_KEYCODE_REG);
> +
> +	if (data < 0) {
> +		dev_err(&samsung_touchkey->client->dev, "Failed to read i2c data\n");
> +		return IRQ_HANDLED;
> +	}
> +
> +	samsung_touchkey->keycode_type = data & TM2_TOUCHKEY_BIT_KEYCODE;
> +	samsung_touchkey->pressed = !(data & TM2_TOUCHKEY_BIT_PRESS_EV);
> +
> +	if (samsung_touchkey->keycode_type != TM2_TOUCHKEY_KEY_MENU &&
> +	    samsung_touchkey->keycode_type != TM2_TOUCHKEY_KEY_BACK)

Shouldn't at least a debug message be printed here so the user can
know that an error occurred and a correct keycode was not received?

> +		return IRQ_HANDLED;
> +
> +	schedule_work(&samsung_touchkey->irq_work);
> +
> +	return IRQ_HANDLED;
> +}
> +
> +static int tm2_touchkey_probe(struct i2c_client *client,
> +				  const struct i2c_device_id *id)
> +{
> +	struct tm2_touchkey_data *samsung_touchkey;
> +	int ret;
> +
> +	ret = i2c_check_functionality(client->adapter,
> +				      I2C_FUNC_SMBUS_BYTE |
> +				      I2C_FUNC_SMBUS_BYTE_DATA);
> +	if (!ret) {
> +		dev_err(&client->dev, "No I2C functionality found\n");
> +		return -ENODEV;
> +	}
> +
> +	samsung_touchkey = devm_kzalloc(&client->dev,
> +			sizeof(struct tm2_touchkey_data), GFP_KERNEL);
> +
> +	if (!samsung_touchkey) {
> +		dev_err(&client->dev, "Failed to allocate memory.\n");
> +		return -ENOMEM;
> +	}
> +
> +	samsung_touchkey->client = client;
> +	i2c_set_clientdata(client, samsung_touchkey);
> +	INIT_WORK(&samsung_touchkey->irq_work, tm2_touchkey_irq_work);
> +
> +	/* regulator */
> +	samsung_touchkey->regulator_vcc =
> +				devm_regulator_get(&client->dev, "vcc");
> +	if (IS_ERR(samsung_touchkey->regulator_vcc)) {
> +		dev_err(&client->dev, "Failed to get vcc regulator\n");
> +		return PTR_ERR(samsung_touchkey->regulator_vcc);
> +	}
> +
> +	samsung_touchkey->regulator_vdd =
> +				devm_regulator_get(&client->dev, "vdd");
> +	if (IS_ERR(samsung_touchkey->regulator_vdd)) {
> +		dev_err(&client->dev, "Failed to get vdd regulator\n");
> +		return PTR_ERR(samsung_touchkey->regulator_vcc);
> +	}
> +
> +	/* power */
> +	ret = tm2_touchkey_power_enable(samsung_touchkey);
> +	if (ret) {
> +		dev_err(&client->dev, "Failed to enable power\n");
> +		return ret;
> +	}
> +
> +	/* irq */
> +	ret = devm_request_threaded_irq(&client->dev,
> +					client->irq, NULL,
> +					tm2_touchkey_irq_handler,
> +					IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> +					TM2_TOUCHKEY_DEV_NAME,
> +					samsung_touchkey);
> +	if (ret) {
> +		dev_err(&client->dev, "Failed to request threaded irq\n");
> +		return ret;
> +	}
> +
> +	/* input device */
> +	samsung_touchkey->input_dev = devm_input_allocate_device(&client->dev);
> +	if (!samsung_touchkey->input_dev) {
> +		dev_err(&client->dev, "Failed to alloc input device.\n");
> +		return -ENOMEM;
> +	}
> +	samsung_touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME;
> +	samsung_touchkey->input_dev->id.bustype = BUS_I2C;
> +	samsung_touchkey->input_dev->dev.parent = &client->dev;
> +
> +	set_bit(EV_KEY, samsung_touchkey->input_dev->evbit);
> +	set_bit(KEY_PHONE, samsung_touchkey->input_dev->keybit);
> +	set_bit(KEY_BACK, samsung_touchkey->input_dev->keybit);
> +	input_set_drvdata(samsung_touchkey->input_dev, samsung_touchkey);
> +
> +	ret = input_register_device(samsung_touchkey->input_dev);
> +	if (ret) {
> +		dev_err(&client->dev, "Failed to register input device.\n");
> +		return ret;
> +	}
> +
> +	/* led device */
> +	samsung_touchkey->led_dev.name = TM2_TOUCHKEY_DEV_NAME;
> +	samsung_touchkey->led_dev.brightness = LED_FULL;
> +	samsung_touchkey->led_dev.max_brightness = LED_FULL;
> +	samsung_touchkey->led_dev.brightness_set =
> +						tm2_touchkey_led_brightness_set;
> +
> +	ret = devm_led_classdev_register(&client->dev,
> +					 &samsung_touchkey->led_dev);
> +	if (ret < 0) {
> +		dev_err(&client->dev, "Failed to register touchkey led\n");
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +static void tm2_touchkey_shutdown(struct i2c_client *client)
> +{
> +	struct tm2_touchkey_data *samsung_touchkey =
> +						i2c_get_clientdata(client);
> +	int ret;
> +
> +	disable_irq(client->irq);
> +	ret = tm2_touchkey_power_disable(samsung_touchkey);
> +	if (ret)
> +		dev_err(&client->dev, "Failed to disable power\n");
> +}
> +
> +static int tm2_touchkey_suspend(struct device *dev)
> +{
> +	struct tm2_touchkey_data *samsung_touchkey = dev_get_drvdata(dev);
> +	int ret;
> +
> +	disable_irq(samsung_touchkey->client->irq);
> +	ret = tm2_touchkey_power_disable(samsung_touchkey);
> +	if (ret)
> +		dev_err(dev, "Failed to disable power\n");
> +
> +	return ret;
> +}

These two functions are basically the same, can you factor it out?

> +
> +static int tm2_touchkey_resume(struct device *dev)
> +{
> +	struct tm2_touchkey_data *samsung_touchkey = dev_get_drvdata(dev);
> +	int ret;
> +
> +	enable_irq(samsung_touchkey->client->irq);
> +	ret = tm2_touchkey_power_enable(samsung_touchkey);
> +	if (ret)
> +		dev_err(dev, "Failed to enable power\n");
> +
> +	return ret;
> +}
> +
> +static SIMPLE_DEV_PM_OPS(tm2_touchkey_pm_ops, tm2_touchkey_suspend,
> +							tm2_touchkey_resume);
> +
> +static const struct i2c_device_id tm2_touchkey_id_table[] = {
> +	{TM2_TOUCHKEY_DEV_NAME, 0},
> +	{},
> +};
> +

You need a MODULE_DEVICE_TABLE(i2c, tm2_touchkey_id_table) here so the
module can be autoloaded when the device is registered.

> +static const struct of_device_id tm2_touchkey_of_match[] = {
> +	{.compatible = "samsung,tm2-touchkey",},
> +	{},
> +};
> +

Here a MODULE_DEVICE_TABLE(of, tm2_touchkey_of_match) is not strictly
needed since the I2C core always reports MODALIAS of the form i2c:<dev>
but still is good to have so the I2C core can be fixed at some point.

> +static struct i2c_driver tm2_touchkey_driver = {
> +	.driver = {
> +		.name = TM2_TOUCHKEY_DEV_NAME,
> +		.pm = &tm2_touchkey_pm_ops,
> +		.of_match_table = of_match_ptr(tm2_touchkey_of_match),
> +	},
> +	.probe = tm2_touchkey_probe,
> +	.shutdown = tm2_touchkey_shutdown,
> +	.id_table = tm2_touchkey_id_table,
> +};
> +
> +module_i2c_driver(tm2_touchkey_driver);
> +
> +MODULE_AUTHOR("Beomho Seo <beomho.seo@samsung.com>");
> +MODULE_AUTHOR("Jaechul Lee <jcsing.lee@samsung.com>");
> +MODULE_DESCRIPTION("Samsung touchkey driver");
> +MODULE_LICENSE("GPL v2");
> 

The rest looks good to me, so after the changes I suggested:

Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America

[toc] | [prev] | [next] | [standalone]


#1550096 — Re: [PATCH 2/4] input: tm2-touchkey: Add touchkey driver support for TM2

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2017-01-03 20:00 +0100
SubjectRe: [PATCH 2/4] input: tm2-touchkey: Add touchkey driver support for TM2
Message-ID<sVCts-1ZW-25@gated-at.bofh.it>
In reply to#1549750
On Tue, Jan 03, 2017 at 10:11:39AM -0300, Javier Martinez Canillas wrote:
> Hello Jaechul,
> 
> On 01/03/2017 04:57 AM, Jaechul Lee wrote:
> > This patch adds support for the TM2 touch key and led
> > functionlity.
> > 
> 
> s/functionlity/functionality
> 
> > The driver interfaces with userspace through an input device and
> > reports KEY_PHONE and KEY_BACK event types. LED brightness can be
> > controlled by "/sys/class/leds/tm2-touchkey/brightness".
> > 
> > Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
> > Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> > ---
> >  drivers/input/keyboard/Kconfig        |  11 ++
> >  drivers/input/keyboard/Makefile       |   1 +
> >  drivers/input/keyboard/tm2-touchkey.c | 326 ++++++++++++++++++++++++++++++++++
> >  3 files changed, 338 insertions(+)
> >  create mode 100644 drivers/input/keyboard/tm2-touchkey.c
> > 
> > diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
> > index cbd75cf..72c0ba1 100644
> > --- a/drivers/input/keyboard/Kconfig
> > +++ b/drivers/input/keyboard/Kconfig
> > @@ -666,6 +666,17 @@ config KEYBOARD_TC3589X
> >  	  To compile this driver as a module, choose M here: the
> >  	  module will be called tc3589x-keypad.
> >  
> > +config KEYBOARD_TM2_TOUCHKEY
> > +	tristate "tm2-touchkey support"
> > +	depends on I2C

There should be LED dependency as well.

> > +	help
> > +	  Say Y here to enable the tm2-touchkey.
> > +	  touchkey driver for tm2. This driver can enable
> > +	  the interrupt and make input events and control led brightness.
> > +
> > +	  To compile this driver as a module, choose M here.
> > +	  module will be called tm2-touchkey
> > +
> >  config KEYBOARD_TWL4030
> >  	tristate "TI TWL4030/TWL5030/TPS659x0 keypad support"
> >  	depends on TWL4030_CORE
> > diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
> > index d9f4cfc..7d9acff 100644
> > --- a/drivers/input/keyboard/Makefile
> > +++ b/drivers/input/keyboard/Makefile
> > @@ -61,6 +61,7 @@ obj-$(CONFIG_KEYBOARD_SUN4I_LRADC)	+= sun4i-lradc-keys.o
> >  obj-$(CONFIG_KEYBOARD_SUNKBD)		+= sunkbd.o
> >  obj-$(CONFIG_KEYBOARD_TC3589X)		+= tc3589x-keypad.o
> >  obj-$(CONFIG_KEYBOARD_TEGRA)		+= tegra-kbc.o
> > +obj-$(CONFIG_KEYBOARD_TM2_TOUCHKEY)	+= tm2-touchkey.o
> >  obj-$(CONFIG_KEYBOARD_TWL4030)		+= twl4030_keypad.o
> >  obj-$(CONFIG_KEYBOARD_XTKBD)		+= xtkbd.o
> >  obj-$(CONFIG_KEYBOARD_W90P910)		+= w90p910_keypad.o
> > diff --git a/drivers/input/keyboard/tm2-touchkey.c b/drivers/input/keyboard/tm2-touchkey.c
> > new file mode 100644
> > index 0000000..d9575d8
> > --- /dev/null
> > +++ b/drivers/input/keyboard/tm2-touchkey.c
> > @@ -0,0 +1,326 @@
> > +/*
> > + * Driver for keys on GPIO lines capable of generating interrupts.

This does not match what the driver does.

> > + *
> > + * Copyright 2005 Phil Blundell
> > + * Copyright 2016 Samsung Electronics Co., Ltd.
> > + *
> > + * Author: Beomho Seo <beomho.seo@samsung.com>
> > + * Author: Jaechul Lee <jcsing.lee@samsung.com>
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + */
> > +
> > +#include <linux/bitops.h>
> > +#include <linux/delay.h>
> > +#include <linux/device.h>
> > +#include <linux/i2c.h>
> > +#include <linux/input.h>
> > +#include <linux/interrupt.h>
> > +#include <linux/irq.h>
> > +#include <linux/leds.h>
> > +#include <linux/module.h>
> > +#include <linux/of.h>
> > +#include <linux/pm.h>
> > +#include <linux/regulator/consumer.h>
> > +#include <linux/workqueue.h>
> > +
> > +#define TM2_TOUCHKEY_DEV_NAME			"tm2-touchkey"
> > +#define TM2_TOUCHKEY_KEYCODE_REG			0x03
> > +#define TM2_TOUCHKEY_BASE_REG			0x00
> > +#define TM2_TOUCHKEY_CMD_LED_ON			0x10
> > +#define TM2_TOUCHKEY_CMD_LED_OFF			0x20
> > +#define TM2_TOUCHKEY_BIT_PRESS_EV			BIT(3)
> > +#define TM2_TOUCHKEY_BIT_KEYCODE			GENMASK(2, 0)
> > +#define TM2_TOUCHKEY_LED_VOLTAGE_MIN			2500000
> > +#define TM2_TOUCHKEY_LED_VOLTAGE_MAX			3300000
> > +
> > +enum {
> > +	TM2_TOUCHKEY_KEY_MENU = 0x1,
> > +	TM2_TOUCHKEY_KEY_BACK,
> > +};
> > +
> > +#define tm2_touchkey_power_enable(x) __tm2_touchkey_power_onoff(x, 1)
> > +#define tm2_touchkey_power_disable(x) __tm2_touchkey_power_onoff(x, 0)
> > +
> > +struct tm2_touchkey_data {
> > +	struct i2c_client *client;
> > +	struct input_dev *input_dev;
> > +	struct led_classdev led_dev;
> > +
> > +	u8 keycode_type;
> > +	u8 pressed;
> > +	struct work_struct irq_work;
> > +
> > +	bool power_onoff;
> > +	struct regulator *regulator_vcc;	/* 1.8V */
> > +	struct regulator *regulator_vdd;	/* 3.3V */
> > +};
> > +
> > +static void tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
> > +						enum led_brightness brightness)
> > +{
> > +	struct tm2_touchkey_data *samsung_touchkey =

Just call it "touchkey", "samsung_touchkey" is too long for a local
variable.

> > +	    container_of(led_dev, struct tm2_touchkey_data, led_dev);
> > +	u32 volt;
> > +	u8 data;
> > +
> > +	if (brightness == LED_OFF) {
> > +		volt = TM2_TOUCHKEY_LED_VOLTAGE_MIN;
> > +		data = TM2_TOUCHKEY_CMD_LED_OFF;
> > +	} else {
> > +		volt = TM2_TOUCHKEY_LED_VOLTAGE_MAX;
> > +		data = TM2_TOUCHKEY_CMD_LED_ON;
> > +	}
> > +
> > +	regulator_set_voltage(samsung_touchkey->regulator_vdd, volt, volt);
> > +	i2c_smbus_write_byte_data(samsung_touchkey->client,
> > +				  TM2_TOUCHKEY_BASE_REG, data);
> > +}
> > +
> > +static int __tm2_touchkey_power_onoff(struct tm2_touchkey_data
> > +					  *samsung_touchkey, bool onoff)
> > +{
> > +	int ret = 0;
> > +
> > +	if (samsung_touchkey->power_onoff == onoff)
> > +		return ret;
> > +
> > +	if (onoff) {
> > +		ret = regulator_enable(samsung_touchkey->regulator_vcc);
> > +		if (ret)
> > +			return ret;
> > +
> > +		ret = regulator_enable(samsung_touchkey->regulator_vdd);
> > +		if (ret) {
> > +			regulator_disable(samsung_touchkey->regulator_vcc);
> > +			return ret;
> > +		}
> 
> I would add a comment about the sleep here.

Also "bulk" regulator API can be useful here.

> 
> > +		msleep(150);
> > +	} else {
> > +		int err;
> > +
> > +		err = regulator_disable(samsung_touchkey->regulator_vcc);
> > +		if (err)
> > +			ret = err;
> > +
> > +		err = regulator_disable(samsung_touchkey->regulator_vdd);
> > +		if (err && !ret)
> > +			ret = err;
> > +	}
> > +	samsung_touchkey->power_onoff = onoff;
> > +
> > +	return ret;
> > +}
> > +
> > +static void tm2_touchkey_irq_work(struct work_struct *irq_work)
> > +{
> > +	struct tm2_touchkey_data *samsung_touchkey =
> > +	    container_of(irq_work, struct tm2_touchkey_data, irq_work);
> > +
> > +	if (!samsung_touchkey->pressed) {
> > +		input_report_key(samsung_touchkey->input_dev, KEY_PHONE, 0);
> > +		input_report_key(samsung_touchkey->input_dev, KEY_BACK, 0);
> > +	} else {
> > +		if (samsung_touchkey->keycode_type == TM2_TOUCHKEY_KEY_MENU)
> > +			input_report_key(samsung_touchkey->input_dev,
> > +					 KEY_PHONE, 1);
> > +		else
> > +			input_report_key(samsung_touchkey->input_dev,
> > +					 KEY_BACK, 1);
> > +	}
> > +	input_sync(samsung_touchkey->input_dev);
> > +}

There is absolutely no reason for doing this in a work. Just call
input_report_key/input_sync from your threaded IRQ routine.

> > +
> > +static irqreturn_t tm2_touchkey_irq_handler(int irq, void *devid)
> > +{
> > +	struct tm2_touchkey_data *samsung_touchkey = devid;
> > +	u32 data;
> > +
> > +	data = i2c_smbus_read_byte_data(samsung_touchkey->client,
> > +					TM2_TOUCHKEY_KEYCODE_REG);
> > +
> > +	if (data < 0) {
> > +		dev_err(&samsung_touchkey->client->dev, "Failed to read i2c data\n");
> > +		return IRQ_HANDLED;
> > +	}
> > +
> > +	samsung_touchkey->keycode_type = data & TM2_TOUCHKEY_BIT_KEYCODE;
> > +	samsung_touchkey->pressed = !(data & TM2_TOUCHKEY_BIT_PRESS_EV);
> > +
> > +	if (samsung_touchkey->keycode_type != TM2_TOUCHKEY_KEY_MENU &&
> > +	    samsung_touchkey->keycode_type != TM2_TOUCHKEY_KEY_BACK)
> 
> Shouldn't at least a debug message be printed here so the user can
> know that an error occurred and a correct keycode was not received?
> 
> > +		return IRQ_HANDLED;
> > +
> > +	schedule_work(&samsung_touchkey->irq_work);
> > +
> > +	return IRQ_HANDLED;
> > +}
> > +
> > +static int tm2_touchkey_probe(struct i2c_client *client,
> > +				  const struct i2c_device_id *id)
> > +{
> > +	struct tm2_touchkey_data *samsung_touchkey;
> > +	int ret;
> > +
> > +	ret = i2c_check_functionality(client->adapter,
> > +				      I2C_FUNC_SMBUS_BYTE |
> > +				      I2C_FUNC_SMBUS_BYTE_DATA);
> > +	if (!ret) {
> > +		dev_err(&client->dev, "No I2C functionality found\n");
> > +		return -ENODEV;
> > +	}
> > +
> > +	samsung_touchkey = devm_kzalloc(&client->dev,
> > +			sizeof(struct tm2_touchkey_data), GFP_KERNEL);

sizeof(*touchkey)

> > +
> > +	if (!samsung_touchkey) {
> > +		dev_err(&client->dev, "Failed to allocate memory.\n");
> > +		return -ENOMEM;
> > +	}
> > +
> > +	samsung_touchkey->client = client;
> > +	i2c_set_clientdata(client, samsung_touchkey);
> > +	INIT_WORK(&samsung_touchkey->irq_work, tm2_touchkey_irq_work);

Work is not needed.

> > +
> > +	/* regulator */
> > +	samsung_touchkey->regulator_vcc =
> > +				devm_regulator_get(&client->dev, "vcc");
> > +	if (IS_ERR(samsung_touchkey->regulator_vcc)) {
> > +		dev_err(&client->dev, "Failed to get vcc regulator\n");
> > +		return PTR_ERR(samsung_touchkey->regulator_vcc);
> > +	}
> > +
> > +	samsung_touchkey->regulator_vdd =
> > +				devm_regulator_get(&client->dev, "vdd");
> > +	if (IS_ERR(samsung_touchkey->regulator_vdd)) {
> > +		dev_err(&client->dev, "Failed to get vdd regulator\n");
> > +		return PTR_ERR(samsung_touchkey->regulator_vcc);
> > +	}

devm_regulator_bulk_get

> > +
> > +	/* power */
> > +	ret = tm2_touchkey_power_enable(samsung_touchkey);
> > +	if (ret) {
> > +		dev_err(&client->dev, "Failed to enable power\n");
> > +		return ret;
> > +	}

You need to install devm action (devm_add_action_or_reset) to disable
power when unloading driver (or if initialization fails).

> > +
> > +	/* irq */
> > +	ret = devm_request_threaded_irq(&client->dev,
> > +					client->irq, NULL,
> > +					tm2_touchkey_irq_handler,
> > +					IRQF_TRIGGER_FALLING | IRQF_ONESHOT,

I'd rather we rely on IRQ trigger from DT, so just use IRQF_PNESHOT
here.

I'd rather you allocated input device before requesting IRQ. The
registering input device is fine to do after getting IRQ.

> > +					TM2_TOUCHKEY_DEV_NAME,
> > +					samsung_touchkey);
> > +	if (ret) {
> > +		dev_err(&client->dev, "Failed to request threaded irq\n");
> > +		return ret;
> > +	}
> > +
> > +	/* input device */
> > +	samsung_touchkey->input_dev = devm_input_allocate_device(&client->dev);
> > +	if (!samsung_touchkey->input_dev) {
> > +		dev_err(&client->dev, "Failed to alloc input device.\n");
> > +		return -ENOMEM;
> > +	}
> > +	samsung_touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME;
> > +	samsung_touchkey->input_dev->id.bustype = BUS_I2C;
> > +	samsung_touchkey->input_dev->dev.parent = &client->dev;

No need to set parent when using devm_input_allocate_device(), it is
done automatically.

> > +
> > +	set_bit(EV_KEY, samsung_touchkey->input_dev->evbit);
> > +	set_bit(KEY_PHONE, samsung_touchkey->input_dev->keybit);
> > +	set_bit(KEY_BACK, samsung_touchkey->input_dev->keybit);


Just do
	input_set_capability(touchkey->input_dev, EV_KEY, KEY_PHONE);
	input_set_capability(touchkey->input_dev, EV_KEY, KEY_BACK);


> > +	input_set_drvdata(samsung_touchkey->input_dev, samsung_touchkey);
> > +
> > +	ret = input_register_device(samsung_touchkey->input_dev);
> > +	if (ret) {
> > +		dev_err(&client->dev, "Failed to register input device.\n");
> > +		return ret;
> > +	}
> > +
> > +	/* led device */
> > +	samsung_touchkey->led_dev.name = TM2_TOUCHKEY_DEV_NAME;
> > +	samsung_touchkey->led_dev.brightness = LED_FULL;
> > +	samsung_touchkey->led_dev.max_brightness = LED_FULL;
> > +	samsung_touchkey->led_dev.brightness_set =
> > +						tm2_touchkey_led_brightness_set;
> > +
> > +	ret = devm_led_classdev_register(&client->dev,
> > +					 &samsung_touchkey->led_dev);
> > +	if (ret < 0) {
> > +		dev_err(&client->dev, "Failed to register touchkey led\n");
> > +		return ret;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static void tm2_touchkey_shutdown(struct i2c_client *client)
> > +{

This is something not normally done. Does your platform really keep
rails on when AP is off?

> > +	struct tm2_touchkey_data *samsung_touchkey =
> > +						i2c_get_clientdata(client);
> > +	int ret;
> > +
> > +	disable_irq(client->irq);
> > +	ret = tm2_touchkey_power_disable(samsung_touchkey);
> > +	if (ret)
> > +		dev_err(&client->dev, "Failed to disable power\n");
> > +}
> > +
> > +static int tm2_touchkey_suspend(struct device *dev)

__maybe_unused

> > +{
> > +	struct tm2_touchkey_data *samsung_touchkey = dev_get_drvdata(dev);
> > +	int ret;
> > +
> > +	disable_irq(samsung_touchkey->client->irq);
> > +	ret = tm2_touchkey_power_disable(samsung_touchkey);
> > +	if (ret)
> > +		dev_err(dev, "Failed to disable power\n");
> > +
> > +	return ret;
> > +}
> 
> These two functions are basically the same, can you factor it out?
> 
> > +
> > +static int tm2_touchkey_resume(struct device *dev)

__maybe_unused

> > +{
> > +	struct tm2_touchkey_data *samsung_touchkey = dev_get_drvdata(dev);
> > +	int ret;
> > +
> > +	enable_irq(samsung_touchkey->client->irq);
> > +	ret = tm2_touchkey_power_enable(samsung_touchkey);
> > +	if (ret)
> > +		dev_err(dev, "Failed to enable power\n");
> > +
> > +	return ret;
> > +}
> > +
> > +static SIMPLE_DEV_PM_OPS(tm2_touchkey_pm_ops, tm2_touchkey_suspend,
> > +							tm2_touchkey_resume);
> > +
> > +static const struct i2c_device_id tm2_touchkey_id_table[] = {
> > +	{TM2_TOUCHKEY_DEV_NAME, 0},
> > +	{},
> > +};
> > +
> 
> You need a MODULE_DEVICE_TABLE(i2c, tm2_touchkey_id_table) here so the
> module can be autoloaded when the device is registered.
> 
> > +static const struct of_device_id tm2_touchkey_of_match[] = {
> > +	{.compatible = "samsung,tm2-touchkey",},
> > +	{},
> > +};
> > +
> 
> Here a MODULE_DEVICE_TABLE(of, tm2_touchkey_of_match) is not strictly
> needed since the I2C core always reports MODALIAS of the form i2c:<dev>
> but still is good to have so the I2C core can be fixed at some point.

Yes, please add MODULE_DEVICE_TABLE(of, ...).

> 
> > +static struct i2c_driver tm2_touchkey_driver = {
> > +	.driver = {
> > +		.name = TM2_TOUCHKEY_DEV_NAME,
> > +		.pm = &tm2_touchkey_pm_ops,
> > +		.of_match_table = of_match_ptr(tm2_touchkey_of_match),
> > +	},
> > +	.probe = tm2_touchkey_probe,
> > +	.shutdown = tm2_touchkey_shutdown,
> > +	.id_table = tm2_touchkey_id_table,
> > +};
> > +
> > +module_i2c_driver(tm2_touchkey_driver);
> > +
> > +MODULE_AUTHOR("Beomho Seo <beomho.seo@samsung.com>");
> > +MODULE_AUTHOR("Jaechul Lee <jcsing.lee@samsung.com>");
> > +MODULE_DESCRIPTION("Samsung touchkey driver");
> > +MODULE_LICENSE("GPL v2");
> > 

Thanks.

-- 
Dmitry

[toc] | [prev] | [next] | [standalone]


#1549970 — Re: [PATCH 2/4] input: tm2-touchkey: Add touchkey driver support for TM2

FromKrzysztof Kozlowski <krzk@kernel.org>
Date2017-01-03 18:10 +0100
SubjectRe: [PATCH 2/4] input: tm2-touchkey: Add touchkey driver support for TM2
Message-ID<sVAL0-10T-23@gated-at.bofh.it>
In reply to#1549586
On Tue, Jan 03, 2017 at 04:57:15PM +0900, Jaechul Lee wrote:
> This patch adds support for the TM2 touch key and led
> functionlity.
> 
> The driver interfaces with userspace through an input device and
> reports KEY_PHONE and KEY_BACK event types. LED brightness can be
> controlled by "/sys/class/leds/tm2-touchkey/brightness".
> 
> Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> ---
>  drivers/input/keyboard/Kconfig        |  11 ++
>  drivers/input/keyboard/Makefile       |   1 +
>  drivers/input/keyboard/tm2-touchkey.c | 326 ++++++++++++++++++++++++++++++++++
>  3 files changed, 338 insertions(+)
>  create mode 100644 drivers/input/keyboard/tm2-touchkey.c
> 
> diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
> index cbd75cf..72c0ba1 100644
> --- a/drivers/input/keyboard/Kconfig
> +++ b/drivers/input/keyboard/Kconfig
> @@ -666,6 +666,17 @@ config KEYBOARD_TC3589X
>  	  To compile this driver as a module, choose M here: the
>  	  module will be called tc3589x-keypad.
>  
> +config KEYBOARD_TM2_TOUCHKEY
> +	tristate "tm2-touchkey support"
> +	depends on I2C
> +	help
> +	  Say Y here to enable the tm2-touchkey.

The ending full stop is not needed.

> +	  touchkey driver for tm2. This driver can enable
> +	  the interrupt and make input events and control led brightness.

This sentence needs improvements. How about just:
"Beside input device, this driver provides also brightness control for
LEDs on touch keys."

Best regards,
Krzysztof

[toc] | [prev] | [next] | [standalone]


#1549591 — Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other

FromAndi Shyti <andi.shyti@samsung.com>
Date2017-01-03 09:20 +0100
SubjectRe: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other
Message-ID<sVsu6-3kp-9@gated-at.bofh.it>
In reply to#1549584
Hi,

> +	compatible = "samsung,tm2e", "samsung,exynos5433";

this is supposed to be "samsung,tm2".
Will wait for other comments and fix it in v2.

Andi

[toc] | [prev] | [next] | [standalone]


#1549597 — Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other

FromKrzysztof Kozlowski <krzk@kernel.org>
Date2017-01-03 09:30 +0100
SubjectRe: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other
Message-ID<sVsDM-3nL-21@gated-at.bofh.it>
In reply to#1549584
On Tue, Jan 3, 2017 at 9:57 AM, Jaechul Lee <jcsing.lee@samsung.com> wrote:
> From: Andi Shyti <andi.shyti@samsung.com>
>
> Currently tm2e dts includes tm2 but there are some differences
> between the two boards and tm2 has some properties that tm2e
> doesn't have.
>
> That's why it's important to keep the two dts files independent
> and put all the commonalities in a tm2-common.dtsi file.
>
> Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
> Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
> ---
>  .../boot/dts/exynos/exynos5433-tm2-common.dtsi     | 1046 ++++++++++++++++++++
>  arch/arm64/boot/dts/exynos/exynos5433-tm2.dts      | 1033 +------------------
>  arch/arm64/boot/dts/exynos/exynos5433-tm2e.dts     |    2 +-
>  3 files changed, 1049 insertions(+), 1032 deletions(-)
>  create mode 100644 arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi

I would like to see here the rename and diff from it. Not entire delta
(deletions and addons). It is not possible to compare it... I think
git supports it by default with similarity of 50%.

Best regards,
Krzysztof

[toc] | [prev] | [next] | [standalone]


#1549659 — Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other

FromAndi Shyti <andi.shyti@samsung.com>
Date2017-01-03 11:00 +0100
SubjectRe: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other
Message-ID<sVu2R-4qr-17@gated-at.bofh.it>
In reply to#1549597
Hi Krzysztof,

> > Currently tm2e dts includes tm2 but there are some differences
> > between the two boards and tm2 has some properties that tm2e
> > doesn't have.
> >
> > That's why it's important to keep the two dts files independent
> > and put all the commonalities in a tm2-common.dtsi file.
> >
> > Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
> > Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
> > ---
> >  .../boot/dts/exynos/exynos5433-tm2-common.dtsi     | 1046 ++++++++++++++++++++
> >  arch/arm64/boot/dts/exynos/exynos5433-tm2.dts      | 1033 +------------------
> >  arch/arm64/boot/dts/exynos/exynos5433-tm2e.dts     |    2 +-
> >  3 files changed, 1049 insertions(+), 1032 deletions(-)
> >  create mode 100644 arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
> 
> I would like to see here the rename and diff from it. Not entire delta
> (deletions and addons). It is not possible to compare it... I think
> git supports it by default with similarity of 50%.

I understand, it's indeed quite cryptic to understand. But all
the diff algorithms (patience, minimal, histogram, myers) give
the same result. I don't know how to make it better.

I could split this patch, but this also means breaking tm2's
functionality, which looks worse.

Please tell me if you know a better way for generating the patch.

Thanks,
Andi

[toc] | [prev] | [next] | [standalone]


#1549660 — Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other

FromChanwoo Choi <cwchoi00@gmail.com>
Date2017-01-03 12:50 +0100
SubjectRe: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other
Message-ID<sVvLj-5zb-1@gated-at.bofh.it>
In reply to#1549659
Dear all,

2017-01-03 19:25 GMT+09:00 Andi Shyti <andi.shyti@samsung.com>:
>> >> > Currently tm2e dts includes tm2 but there are some differences
>> >> > between the two boards and tm2 has some properties that tm2e
>> >> > doesn't have.
>> >> >
>> >> > That's why it's important to keep the two dts files independent
>> >> > and put all the commonalities in a tm2-common.dtsi file.
>> >> >
>> >> > Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
>> >> > Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
>> >> > ---
>> >> >  .../boot/dts/exynos/exynos5433-tm2-common.dtsi     | 1046 ++++++++++++++++++++
>> >> >  arch/arm64/boot/dts/exynos/exynos5433-tm2.dts      | 1033 +------------------
>> >> >  arch/arm64/boot/dts/exynos/exynos5433-tm2e.dts     |    2 +-
>> >> >  3 files changed, 1049 insertions(+), 1032 deletions(-)
>> >> >  create mode 100644 arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
>> >>
>> >> I would like to see here the rename and diff from it. Not entire delta
>> >> (deletions and addons). It is not possible to compare it... I think
>> >> git supports it by default with similarity of 50%.
>> >
>> > I understand, it's indeed quite cryptic to understand. But all
>> > the diff algorithms (patience, minimal, histogram, myers) give
>> > the same result. I don't know how to make it better.
>> >
>> > I could split this patch, but this also means breaking tm2's
>> > functionality, which looks worse.
>> >
>> > Please tell me if you know a better way for generating the patch.
>>
>> git format-patch -M95%?
>
> Same thing with all M values.
>
> Because exynos5433-tm2.dts results modified, while
> exynos5433-tm2-common.dtsi is new. Even though I did:
>
> 1. mv exynos5433-tm2.dts exynos5433-tm2-common.dtsi
> 2. copied pieces from exynos5433-tm2-common.dtsi to a new
>    exynos5433-tm2.dts

I think that exynos5433-tm2-common.dtsi is not necessary because there
is small difference between TM2 and TM2E.

I explain the detailed difference between TM2 and TM2E and then reply
how to support the TM2E board with existing exynos5433-tm2.dts file
without exynos5433-tm2-common.dtsi.

Difference and the way to support TM2E with existing
exynos5433-tm2.dts file as following:
- hsi2c_9 is either used or not. TM2 uses the hsi2c_9 node for
touchkey. but TM2E do not use the hsi2c_9.
   : We can just disable the hsi2c_9 node on tm2e.dts as following:

   &hsi2c_9 {
         status = "disable";
   };

- The difference name and voltage of regulators.
   : Already modified on tm2e.dts.
- The size of touchscreen between tm2 and tm2e ('x-size', 'y-size')
   : We can update the x/y size on tm2e.dts.
- The timing value of display-timing between tm2 and tm2e
('clock-frequency', 'hactive')
   : We can update the 'clock-frequency' and 'hactive'  on tm2e.dts.

-- 
Best Regards,
Chanwoo Choi

[toc] | [prev] | [next] | [standalone]


#1549727 — Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other

FromAndi Shyti <andi.shyti@samsung.com>
Date2017-01-03 13:00 +0100
SubjectRe: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other
Message-ID<sVvV0-5CH-33@gated-at.bofh.it>
In reply to#1549660
Hi Chanwoo,

> >> >> > Currently tm2e dts includes tm2 but there are some differences
> >> >> > between the two boards and tm2 has some properties that tm2e
> >> >> > doesn't have.
> >> >> >
> >> >> > That's why it's important to keep the two dts files independent
> >> >> > and put all the commonalities in a tm2-common.dtsi file.
> >> >> >
> >> >> > Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
> >> >> > Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
> >> >> > ---
> >> >> >  .../boot/dts/exynos/exynos5433-tm2-common.dtsi     | 1046 ++++++++++++++++++++
> >> >> >  arch/arm64/boot/dts/exynos/exynos5433-tm2.dts      | 1033 +------------------
> >> >> >  arch/arm64/boot/dts/exynos/exynos5433-tm2e.dts     |    2 +-
> >> >> >  3 files changed, 1049 insertions(+), 1032 deletions(-)
> >> >> >  create mode 100644 arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
> >> >>

[...]

> > Because exynos5433-tm2.dts results modified, while
> > exynos5433-tm2-common.dtsi is new. Even though I did:
> >
> > 1. mv exynos5433-tm2.dts exynos5433-tm2-common.dtsi
> > 2. copied pieces from exynos5433-tm2-common.dtsi to a new
> >    exynos5433-tm2.dts
> 
> I think that exynos5433-tm2-common.dtsi is not necessary because there
> is small difference between TM2 and TM2E.
> 
> I explain the detailed difference between TM2 and TM2E and then reply
> how to support the TM2E board with existing exynos5433-tm2.dts file
> without exynos5433-tm2-common.dtsi.
> 
> Difference and the way to support TM2E with existing
> exynos5433-tm2.dts file as following:
> - hsi2c_9 is either used or not. TM2 uses the hsi2c_9 node for
> touchkey. but TM2E do not use the hsi2c_9.
>    : We can just disable the hsi2c_9 node on tm2e.dts as following:
> 
>    &hsi2c_9 {
>          status = "disable";
>    };

I thought about this alternative too, it just looked cleaner to
me to have a tm2-common.dtsi file.

Anyway, as you guys wish. If for you and Krzysztof is better this
way, we can drop this patch and add the above lines in the current
Jaechul's patch 4/4.

Thanks,
Andi

[toc] | [prev] | [next] | [standalone]


#1549734 — Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other

FromJavier Martinez Canillas <javier@osg.samsung.com>
Date2017-01-03 13:20 +0100
SubjectRe: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other
Message-ID<sVwem-60K-13@gated-at.bofh.it>
In reply to#1549727
Hello Andi,

On 01/03/2017 08:55 AM, Andi Shyti wrote:
> Hi Chanwoo,
> 
>>>>>>> Currently tm2e dts includes tm2 but there are some differences
>>>>>>> between the two boards and tm2 has some properties that tm2e
>>>>>>> doesn't have.
>>>>>>>
>>>>>>> That's why it's important to keep the two dts files independent
>>>>>>> and put all the commonalities in a tm2-common.dtsi file.
>>>>>>>
>>>>>>> Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
>>>>>>> Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
>>>>>>> ---
>>>>>>>  .../boot/dts/exynos/exynos5433-tm2-common.dtsi     | 1046 ++++++++++++++++++++
>>>>>>>  arch/arm64/boot/dts/exynos/exynos5433-tm2.dts      | 1033 +------------------
>>>>>>>  arch/arm64/boot/dts/exynos/exynos5433-tm2e.dts     |    2 +-
>>>>>>>  3 files changed, 1049 insertions(+), 1032 deletions(-)
>>>>>>>  create mode 100644 arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
>>>>>>
> 
> [...]
> 
>>> Because exynos5433-tm2.dts results modified, while
>>> exynos5433-tm2-common.dtsi is new. Even though I did:
>>>
>>> 1. mv exynos5433-tm2.dts exynos5433-tm2-common.dtsi
>>> 2. copied pieces from exynos5433-tm2-common.dtsi to a new
>>>    exynos5433-tm2.dts
>>
>> I think that exynos5433-tm2-common.dtsi is not necessary because there
>> is small difference between TM2 and TM2E.
>>
>> I explain the detailed difference between TM2 and TM2E and then reply
>> how to support the TM2E board with existing exynos5433-tm2.dts file
>> without exynos5433-tm2-common.dtsi.
>>
>> Difference and the way to support TM2E with existing
>> exynos5433-tm2.dts file as following:
>> - hsi2c_9 is either used or not. TM2 uses the hsi2c_9 node for
>> touchkey. but TM2E do not use the hsi2c_9.
>>    : We can just disable the hsi2c_9 node on tm2e.dts as following:
>>
>>    &hsi2c_9 {
>>          status = "disable";
>>    };
> 
> I thought about this alternative too, it just looked cleaner to
> me to have a tm2-common.dtsi file.
> 
> Anyway, as you guys wish. If for you and Krzysztof is better this
> way, we can drop this patch and add the above lines in the current
> Jaechul's patch 4/4.
>

FWIW, I also agree with Chanwoo that the difference is too small to
need a common .dtsi file.
 
> Thanks,
> Andi
> 

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America

[toc] | [prev] | [next] | [standalone]


#1549827 — Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other

FromAndi Shyti <andi@etezian.org>
Date2017-01-03 15:50 +0100
SubjectRe: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other
Message-ID<sVyzw-7Iz-7@gated-at.bofh.it>
In reply to#1549734
Hi,

> FWIW, I also agree with Chanwoo that the difference is too small to
> need a common .dtsi file.

in principle I don't like "switching on and off" properties by
overwriting them with "status = disable", unless it's really
necessary (and this case is not). Even for small differences. It
makes the DTS harder to read and duplicates nodes with different
values throughout the DTS include chain.

In my opinion this approach should be discouraged.

Besides, there are other overwritten differences in tm2e.dts that
I think should be separated as well. The "common" file approach is
widely used in arm/boot/dts/exynos* files.

The "status = disable" looks to me more like a temporary hack
rather than a permanent solution.

In any case, still up to you :)

Andi

[toc] | [prev] | [next] | [standalone]


#1549849 — Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other

FromJavier Martinez Canillas <javier@osg.samsung.com>
Date2017-01-03 16:10 +0100
SubjectRe: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other
Message-ID<sVySS-85Q-45@gated-at.bofh.it>
In reply to#1549827
Hello Andi,

On 01/03/2017 11:40 AM, Andi Shyti wrote:
> Hi,
> 
>> FWIW, I also agree with Chanwoo that the difference is too small to
>> need a common .dtsi file.
> 
> in principle I don't like "switching on and off" properties by
> overwriting them with "status = disable", unless it's really

This is a very good point. It would had been different if it was the
opposite and tm2e had to enable the device node, but disabling it is
indeed more confusing.

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America

[toc] | [prev] | [next] | [standalone]


#1549911 — Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other

FromChanwoo Choi <cwchoi00@gmail.com>
Date2017-01-03 17:10 +0100
SubjectRe: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other
Message-ID<sVzOW-jT-27@gated-at.bofh.it>
In reply to#1549827
Hi Andi,

2017-01-03 23:40 GMT+09:00 Andi Shyti <andi@etezian.org>:
> Hi,
>
>> FWIW, I also agree with Chanwoo that the difference is too small to
>> need a common .dtsi file.
>
> in principle I don't like "switching on and off" properties by
> overwriting them with "status = disable", unless it's really
> necessary (and this case is not). Even for small differences. It
> makes the DTS harder to read and duplicates nodes with different
> values throughout the DTS include chain.
>
> In my opinion this approach should be discouraged.
>
> Besides, there are other overwritten differences in tm2e.dts that
> I think should be separated as well. The "common" file approach is
> widely used in arm/boot/dts/exynos* files.
>
> The "status = disable" looks to me more like a temporary hack
> rather than a permanent solution.
>
> In any case, still up to you :)
>
> Andi

I think that "status=disabled" of hsi2c_9 is not hack. The overwrite
is possible for Device-tree. But, there is just difference how to
support them with some method.

Except for touchkey, all peripheral device are same on both tm2 and
tm2e. There are only small difference for a few property value.

To understand the difference between tm2 and tm2e, I made the patch
(it is not complete version). If we implement the following patch, we
support both tm2 and tm2e. So, I think that it is not complex to
understand the h/w difference between tm2 and tm2e.

diff --git a/arch/arm64/boot/dts/exynos/exynos5433-tm2e.dts
b/arch/arm64/boot/dts/exynos/exynos5433-tm2e.dts
index 1db4e7f..09b6935 100644
--- a/arch/arm64/boot/dts/exynos/exynos5433-tm2e.dts
+++ b/arch/arm64/boot/dts/exynos/exynos5433-tm2e.dts
@@ -18,6 +18,17 @@
        compatible = "samsung,tm2e", "samsung,exynos5433";
 };

+&display_timings {
+       clock-frequency = <16523724>;
+       hactive = <1600>;
+};
+
+&hsi2c_9 {
+        /* TM2E don't use the separate touchkey device. Instead, touchscreen
+         * device support the touchkey device.*/
+       status = "disabled";
+};
+
 &ldo23_reg {
        regulator-name = "CAM_SEN_CORE_1.025V_AP";
        regulator-max-microvolt = <1050000>;
@@ -39,3 +50,7 @@
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
 };
+
+&touchscreen {
+       x-size = "1599";
+};

-- 
Best Regards,
Chanwoo Choi

[toc] | [prev] | [next] | [standalone]


#1549962 — Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other

FromKrzysztof Kozlowski <krzk@kernel.org>
Date2017-01-03 18:00 +0100
SubjectRe: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other
Message-ID<sVABk-Hi-23@gated-at.bofh.it>
In reply to#1549911
On Wed, Jan 04, 2017 at 12:29:23AM +0900, Chanwoo Choi wrote:
> Hi Andi,
> 
> 2017-01-03 23:40 GMT+09:00 Andi Shyti <andi@etezian.org>:
> > Hi,
> >
> >> FWIW, I also agree with Chanwoo that the difference is too small to
> >> need a common .dtsi file.
> >
> > in principle I don't like "switching on and off" properties by
> > overwriting them with "status = disable", unless it's really
> > necessary (and this case is not). Even for small differences. It
> > makes the DTS harder to read and duplicates nodes with different
> > values throughout the DTS include chain.

I agree.

> >
> > In my opinion this approach should be discouraged.
> >
> > Besides, there are other overwritten differences in tm2e.dts that
> > I think should be separated as well. The "common" file approach is
> > widely used in arm/boot/dts/exynos* files.

I agree. Mostly we use:
1. Common DTSI and final addons/customizations in DTS.
2. Several common DTSI for specific parts (like sound).

> > The "status = disable" looks to me more like a temporary hack
> > rather than a permanent solution.
> >
> > In any case, still up to you :)
> >
> > Andi
> 
> I think that "status=disabled" of hsi2c_9 is not hack. The overwrite
> is possible for Device-tree. But, there is just difference how to
> support them with some method.
> 
> Except for touchkey, all peripheral device are same on both tm2 and
> tm2e. There are only small difference for a few property value.
> 
> To understand the difference between tm2 and tm2e, I made the patch
> (it is not complete version). If we implement the following patch, we
> support both tm2 and tm2e. So, I think that it is not complex to
> understand the h/w difference between tm2 and tm2e.

The difference below (I removed it from the quote) is indeed very small,
thanks Chanwoo for pointing this. However having common DTSI should not
end with much bigger final diff between files. I mean that it should be
the same amount of lines in total...

Actually, after applying this patch, the final exynos5433-tm2e.dts is
exactly the same as before. To me, this is a indication that a common
file is a good approach.


From a separate Javier's mail:
> On 01/03/2017 11:40 AM, Andi Shyti wrote:
> > Hi,
> > 
> >> FWIW, I also agree with Chanwoo that the difference is too small to
> >> need a common .dtsi file.
> > 
> > in principle I don't like "switching on and off" properties by
> > overwriting them with "status = disable", unless it's really
> 
> This is a very good point. It would had been different if it was the
> opposite and tm2e had to enable the device node, but disabling it is
> indeed more confusing.
> On 01/03/2017 11:40 AM, Andi Shyti wrote:
> > Hi,
> > 
> >> FWIW, I also agree with Chanwoo that the difference is too small to
> >> need a common .dtsi file.
> > 
> > in principle I don't like "switching on and off" properties by
> > overwriting them with "status = disable", unless it's really
> 
> This is a very good point. It would had been different if it was the
> opposite and tm2e had to enable the device node, but disabling it is
> indeed more confusing.

I agree, 'status = disable' in final DTS is not a common pattern and
to me when reading, it makes me wonder what was the author's intention.

Also including a DTS in DTS is not a common pattern, neither. It appears
(git grep include arch/arm/boot/dts | grep 'dts"') in few places but it
is not obvious. At least to me.

Overall, I prefer the common approach.

Best regards,
Krzysztof

[toc] | [prev] | [next] | [standalone]


#1549673 — Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other

FromAndi Shyti <andi.shyti@samsung.com>
Date2017-01-03 11:30 +0100
SubjectRe: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other
Message-ID<sVuvT-4Rn-1@gated-at.bofh.it>
In reply to#1549659
> >> > Currently tm2e dts includes tm2 but there are some differences
> >> > between the two boards and tm2 has some properties that tm2e
> >> > doesn't have.
> >> >
> >> > That's why it's important to keep the two dts files independent
> >> > and put all the commonalities in a tm2-common.dtsi file.
> >> >
> >> > Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
> >> > Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
> >> > ---
> >> >  .../boot/dts/exynos/exynos5433-tm2-common.dtsi     | 1046 ++++++++++++++++++++
> >> >  arch/arm64/boot/dts/exynos/exynos5433-tm2.dts      | 1033 +------------------
> >> >  arch/arm64/boot/dts/exynos/exynos5433-tm2e.dts     |    2 +-
> >> >  3 files changed, 1049 insertions(+), 1032 deletions(-)
> >> >  create mode 100644 arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
> >>
> >> I would like to see here the rename and diff from it. Not entire delta
> >> (deletions and addons). It is not possible to compare it... I think
> >> git supports it by default with similarity of 50%.
> >
> > I understand, it's indeed quite cryptic to understand. But all
> > the diff algorithms (patience, minimal, histogram, myers) give
> > the same result. I don't know how to make it better.
> >
> > I could split this patch, but this also means breaking tm2's
> > functionality, which looks worse.
> >
> > Please tell me if you know a better way for generating the patch.
> 
> git format-patch -M95%?

Same thing with all M values.

Because exynos5433-tm2.dts results modified, while
exynos5433-tm2-common.dtsi is new. Even though I did:

1. mv exynos5433-tm2.dts exynos5433-tm2-common.dtsi
2. copied pieces from exynos5433-tm2-common.dtsi to a new
   exynos5433-tm2.dts

Andi

[toc] | [prev] | [next] | [standalone]


#1549952 — Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other

FromKrzysztof Kozlowski <krzk@kernel.org>
Date2017-01-03 17:50 +0100
SubjectRe: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other
Message-ID<sVArE-DT-29@gated-at.bofh.it>
In reply to#1549673
On Tue, Jan 03, 2017 at 07:25:48PM +0900, Andi Shyti wrote:
> > >> > Currently tm2e dts includes tm2 but there are some differences
> > >> > between the two boards and tm2 has some properties that tm2e
> > >> > doesn't have.
> > >> >
> > >> > That's why it's important to keep the two dts files independent
> > >> > and put all the commonalities in a tm2-common.dtsi file.
> > >> >
> > >> > Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
> > >> > Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
> > >> > ---
> > >> >  .../boot/dts/exynos/exynos5433-tm2-common.dtsi     | 1046 ++++++++++++++++++++
> > >> >  arch/arm64/boot/dts/exynos/exynos5433-tm2.dts      | 1033 +------------------
> > >> >  arch/arm64/boot/dts/exynos/exynos5433-tm2e.dts     |    2 +-
> > >> >  3 files changed, 1049 insertions(+), 1032 deletions(-)
> > >> >  create mode 100644 arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
> > >>
> > >> I would like to see here the rename and diff from it. Not entire delta
> > >> (deletions and addons). It is not possible to compare it... I think
> > >> git supports it by default with similarity of 50%.
> > >
> > > I understand, it's indeed quite cryptic to understand. But all
> > > the diff algorithms (patience, minimal, histogram, myers) give
> > > the same result. I don't know how to make it better.
> > >
> > > I could split this patch, but this also means breaking tm2's
> > > functionality, which looks worse.
> > >
> > > Please tell me if you know a better way for generating the patch.
> > 
> > git format-patch -M95%?
> 
> Same thing with all M values.
> 
> Because exynos5433-tm2.dts results modified, while
> exynos5433-tm2-common.dtsi is new. Even though I did:
> 
> 1. mv exynos5433-tm2.dts exynos5433-tm2-common.dtsi
> 2. copied pieces from exynos5433-tm2-common.dtsi to a new
>    exynos5433-tm2.dts

mv/etc won't help. You need to convince git format-patch that it is
rename. For that, you need -B so copy will be considered a rename
(otherwise rename will be detected only if a file is removed), so:
	git format-patch -B50% -1

Please resend with this approach.

Best regards,
Krzysztof

[toc] | [prev] | [next] | [standalone]


#1549676 — Re: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other

FromKrzysztof Kozlowski <krzk@kernel.org>
Date2017-01-03 11:10 +0100
SubjectRe: [PATCH 3/4] arm64: dts: exynos: make tm2 and tm2e independent from each other
Message-ID<sVucx-4Jk-9@gated-at.bofh.it>
In reply to#1549659
On Tue, Jan 3, 2017 at 11:58 AM, Andi Shyti <andi.shyti@samsung.com> wrote:
> Hi Krzysztof,
>
>> > Currently tm2e dts includes tm2 but there are some differences
>> > between the two boards and tm2 has some properties that tm2e
>> > doesn't have.
>> >
>> > That's why it's important to keep the two dts files independent
>> > and put all the commonalities in a tm2-common.dtsi file.
>> >
>> > Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
>> > Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
>> > ---
>> >  .../boot/dts/exynos/exynos5433-tm2-common.dtsi     | 1046 ++++++++++++++++++++
>> >  arch/arm64/boot/dts/exynos/exynos5433-tm2.dts      | 1033 +------------------
>> >  arch/arm64/boot/dts/exynos/exynos5433-tm2e.dts     |    2 +-
>> >  3 files changed, 1049 insertions(+), 1032 deletions(-)
>> >  create mode 100644 arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
>>
>> I would like to see here the rename and diff from it. Not entire delta
>> (deletions and addons). It is not possible to compare it... I think
>> git supports it by default with similarity of 50%.
>
> I understand, it's indeed quite cryptic to understand. But all
> the diff algorithms (patience, minimal, histogram, myers) give
> the same result. I don't know how to make it better.
>
> I could split this patch, but this also means breaking tm2's
> functionality, which looks worse.
>
> Please tell me if you know a better way for generating the patch.

git format-patch -M95%?

Krzysztof

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web