[linux-sunxi] Re: [PATCH 1/5] input: Add new sun4i-ts driver for Allwinner sunxi SoC's rtp controller

2013-12-26 Thread Dmitry Torokhov
On Thu, Dec 26, 2013 at 11:33:06PM +0100, Hans de Goede wrote:
 On 12/26/2013 11:15 PM, Dmitry Torokhov wrote:
 
 Are we 1000% sure that the device is quiesced here and we will not get a
 stray interrupt? Even if we are sure I'd still rather allocate input
 device earlier, together with ts structure.
 
 I will change things to allocate the input device earlier. What about
 registering it, when is the best time to do that?

The common pattern for the most input drivers is to register it last,
but that usually matters when you are not using managed input devices
since it helps making error unwinding path simpler. I'd still register
it last just so it looks the same as the rest of the drivers.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[linux-sunxi] Re: [PATCH v2 2/5] input: sun4i-ts: Add support for temperature sensor

2013-12-27 Thread Dmitry Torokhov
Hi Hans,

On Fri, Dec 27, 2013 at 03:59:56PM +0100, Hans de Goede wrote:
 +
 + if (!ts-input)
 + goto leave;
 +
   if (reg_val  FIFO_DATA_PENDING) {
   x = readl(ts-base + TP_DATA);
   y = readl(ts-base + TP_DATA);
 @@ -140,6 +151,7 @@ static irqreturn_t sun4i_ts_irq(int irq, void *dev_id)
   input_sync(ts-input);
   }
  
 +leave:

Can we please not introduce gotos where they are not needed? If you
concerned about extra indent just split touchscreen handling into a
separate function and then do

if (ts-input)
sun4i_ts_handle_touchscreen_data(...);


   writel(reg_val, ts-base + TP_INT_FIFOS);
  
   return IRQ_HANDLED;
 @@ -149,9 +161,9 @@ static int sun4i_ts_open(struct input_dev *dev)
  {
   struct sun4i_ts_data *ts = input_get_drvdata(dev);
  
 - /* Flush, set trig level to 1, enable data and up irqs */
 - writel(DATA_IRQ_EN(1) | FIFO_TRIG(1) |FIFO_FLUSH(1) | TP_UP_IRQ_EN(1),
 -ts-base + TP_INT_FIFOC);
 + /* Flush, set trig level to 1, enable temp, data and up irqs */
 + writel(TEMP_IRQ_EN(1) | DATA_IRQ_EN(1) | FIFO_TRIG(1) | FIFO_FLUSH(1) |
 + TP_UP_IRQ_EN(1), ts-base + TP_INT_FIFOC);
  
   return 0;
  }
 @@ -160,40 +172,76 @@ static void sun4i_ts_close(struct input_dev *dev)
  {
   struct sun4i_ts_data *ts = input_get_drvdata(dev);
  
 - /* Deactivate all IRQs */
 - writel(0, ts-base + TP_INT_FIFOC);
 + /* Deactivate all input IRQs */
 + writel(TEMP_IRQ_EN(1), ts-base + TP_INT_FIFOC);
   synchronize_irq(ts-irq);

Hmm, it would be nice we touchscreen methods only affected touchscreen
functionality. Can you read current state and adjust it as needed
instead of clobbering it? Then you could do away with remove() method
altogether.

  }
  
 +static ssize_t show_temp(struct device *dev, struct device_attribute 
 *devattr,
 +  char *buf)
 +{
 + struct sun4i_ts_data *ts = dev_get_drvdata(dev);
 +
 + /* No temp_data until the first irq */
 + if (ts-temp_data == -1)
 + return -EAGAIN;
 +
 + return sprintf(buf, %d\n, (ts-temp_data - 1447) * 100);
 +}
 +
 +static ssize_t show_temp_label(struct device *dev,
 +   struct device_attribute *devattr, char *buf)
 +{
 + return sprintf(buf, SoC temperature\n);
 +}
 +
 +static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL);
 +static DEVICE_ATTR(temp1_label, S_IRUGO, show_temp_label, NULL);
 +
 +static struct attribute *sun4i_ts_attrs[] = {
 + dev_attr_temp1_input.attr,
 + dev_attr_temp1_label.attr,
 + NULL
 +};
 +ATTRIBUTE_GROUPS(sun4i_ts);
 +
  static int sun4i_ts_probe(struct platform_device *pdev)
  {
   struct sun4i_ts_data *ts;
   struct device *dev = pdev-dev;
 + struct device_node *np =dev-of_node;
 + struct device *hwmon;
   int ret;
 + bool ts_attached;
 +
 + ts_attached = of_property_read_bool(np, ts-attached);
  
   ts = devm_kzalloc(dev, sizeof(struct sun4i_ts_data), GFP_KERNEL);
   if (!ts)
   return -ENOMEM;
  
   ts-dev = dev;
 -
 - ts-input = devm_input_allocate_device(dev);
 - if (!ts-input)
 - return -ENOMEM;
 -
 - ts-input-name = pdev-name;
 - ts-input-phys = sun4i_ts/input0;
 - ts-input-open = sun4i_ts_open;
 - ts-input-close = sun4i_ts_close;
 - ts-input-id.bustype = BUS_HOST;
 - ts-input-id.vendor = 0x0001;
 - ts-input-id.product = 0x0001;
 - ts-input-id.version = 0x0100;
 - ts-input-evbit[0] =  BIT(EV_SYN) | BIT(EV_KEY) | BIT(EV_ABS);
 - set_bit(BTN_TOUCH, ts-input-keybit);
 - input_set_abs_params(ts-input, ABS_X, 0, 4095, 0, 0);
 - input_set_abs_params(ts-input, ABS_Y, 0, 4095, 0, 0);
 - input_set_drvdata(ts-input, ts);
 + ts-temp_data = -1;
 +
 + if (ts_attached) {
 + ts-input = devm_input_allocate_device(dev);
 + if (!ts-input)
 + return -ENOMEM;
 +
 + ts-input-name = pdev-name;
 + ts-input-phys = sun4i_ts/input0;
 + ts-input-open = sun4i_ts_open;
 + ts-input-close = sun4i_ts_close;
 + ts-input-id.bustype = BUS_HOST;
 + ts-input-id.vendor = 0x0001;
 + ts-input-id.product = 0x0001;
 + ts-input-id.version = 0x0100;
 + ts-input-evbit[0] =  BIT(EV_SYN) | BIT(EV_KEY) | BIT(EV_ABS);
 + set_bit(BTN_TOUCH, ts-input-keybit);
 + input_set_abs_params(ts-input, ABS_X, 0, 4095, 0, 0);
 + input_set_abs_params(ts-input, ABS_Y, 0, 4095, 0, 0);
 + input_set_drvdata(ts-input, ts);
 + }
  
   ts-base = devm_ioremap_resource(dev,
 platform_get_resource(pdev, IORESOURCE_MEM, 0));
 @@ -232,14 +280,42 @@ static int sun4i_ts_probe(struct platform_device *pdev)
   writel(STYLUS_UP_DEBOUN(5) | STYLUS_UP_DEBOUN_EN(1) | TP_MODE_EN(1),
  ts-base + 

[linux-sunxi] Re: [PATCH 1/4] input: Add new sun4i-lradc-keys drivers

2014-01-01 Thread Dmitry Torokhov
Hi Hans,

On Wed, Jan 01, 2014 at 08:30:07PM +0100, Hans de Goede wrote:
 +Required properties:
 + - compatible: allwinner,sun4i-lradc-keys
 + - reg: mmio address range of the chip
 + - interrupts: interrupt to which the chip is connected
 + - allwinner,chan0-step: step in mV between keys must be 150 or 200
 + - allwinner,chan0-keycodes: array of include/uapi/linux/input.h KEY_ codes

I think this should be linux,chan0-keycodes.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [linux-sunxi] Re: [PATCH v2 1/8] mfd: AXP20x: Add mfd driver for AXP20x PMIC

2014-03-22 Thread Dmitry Torokhov
On Sat, Mar 22, 2014 at 07:13:36PM +0100, Carlo Caione wrote:
 On Sat, Mar 22, 2014 at 6:33 PM, Mark Brown broo...@kernel.org wrote:
  On Sat, Mar 22, 2014 at 05:51:32PM +0100, Carlo Caione wrote:
  On Tue, Mar 18, 2014 at 03:59:19PM +, Lee Jones wrote:
 
+ of_id = of_match_device(axp20x_of_match, i2c-dev);
+ if (!of_id) {
+ dev_err(i2c-dev, Unable to setup AXP20X data\n);
+ return -ENODEV;
+ }
+ axp20x-variant = (int) of_id-data;
 
   No need to cast from void *.
 
  My compiler says otherwise :)
 
  Are you sure your compiler isn't correctly telling you not to cast away
  const?  If the compiler is complaining about a cast on void then it's
  spotted a definite bug.
 
 [resend since gmail decided to not put broonie in CC]
 
 drivers/mfd/axp20x.c:172:18: warning: assignment makes integer
 frompointer without a cast [enabled by default]

You need to cast to long, otherwise you will get warnings when compiling
on 64 bit arches.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v3 04/10] input: misc: Add driver for AXP20x Power Enable Key

2014-03-28 Thread Dmitry Torokhov
Hi Carlo,

On Thu, Mar 27, 2014 at 10:29:18PM +0100, Carlo Caione wrote:
 This patch add support for the Power Enable Key found on MFD AXP202 and
 AXP209. Besides the basic support for the button, the driver adds two
 entries in sysfs to configure the time delay for power on/off.
 
 Signed-off-by: Carlo Caione ca...@caione.org
 ---
  drivers/input/misc/Kconfig  |  11 ++
  drivers/input/misc/Makefile |   1 +
  drivers/input/misc/axp20x-pek.c | 260 
 
  3 files changed, 272 insertions(+)
  create mode 100644 drivers/input/misc/axp20x-pek.c
 
 diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
 index 7904ab0..87244fb 100644
 --- a/drivers/input/misc/Kconfig
 +++ b/drivers/input/misc/Kconfig
 @@ -393,6 +393,17 @@ config INPUT_RETU_PWRBUTTON
 To compile this driver as a module, choose M here. The module will
 be called retu-pwrbutton.
  
 +config INPUT_AXP20X_PEK
 + tristate X-Powers AXP20X power button driver
 + depends on MFD_AXP20X
 + help
 +   Say Y here if you want to enable power key reporting via the
 +   AXP20X PMIC.
 +
 +   To compile this driver as a module, choose M here. The module will
 +   be called axp20x-pek.
 +
 +
  config INPUT_TWL4030_PWRBUTTON
   tristate TWL4030 Power button Driver
   depends on TWL4030_CORE
 diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
 index cda71fc..624abf5 100644
 --- a/drivers/input/misc/Makefile
 +++ b/drivers/input/misc/Makefile
 @@ -50,6 +50,7 @@ obj-$(CONFIG_INPUT_POWERMATE)   += powermate.o
  obj-$(CONFIG_INPUT_PWM_BEEPER)   += pwm-beeper.o
  obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o
  obj-$(CONFIG_INPUT_RETU_PWRBUTTON)   += retu-pwrbutton.o
 +obj-$(CONFIG_INPUT_AXP20X_PEK)   += axp20x-pek.o
  obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)  += rotary_encoder.o
  obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o
  obj-$(CONFIG_INPUT_SIRFSOC_ONKEY)+= sirfsoc-onkey.o
 diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
 new file mode 100644
 index 000..6698a69
 --- /dev/null
 +++ b/drivers/input/misc/axp20x-pek.c
 @@ -0,0 +1,260 @@
 +/*
 + * axp20x power button driver.
 + *
 + * Copyright (C) 2013 Carlo Caione ca...@caione.org
 + *
 + * This file is subject to the terms and conditions of the GNU General
 + * Public License. See the file COPYING in the main directory of this
 + * archive for more details.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 + * GNU General Public License for more details.
 + */
 +
 +#include linux/errno.h
 +#include linux/irq.h
 +#include linux/init.h
 +#include linux/input.h
 +#include linux/interrupt.h
 +#include linux/kernel.h
 +#include linux/mfd/axp20x.h
 +#include linux/module.h
 +#include linux/platform_device.h
 +#include linux/regmap.h
 +#include linux/slab.h
 +
 +#define AXP20X_PEK_STARTUP_MASK  (0xc0)
 +#define AXP20X_PEK_SHUTDOWN_MASK (0x03)
 +
 +static const char const *startup_time[] = { 128ms, 3s , 1s, 2s };
 +static const char const *shutdown_time[] = { 4s, 6s , 8s, 10s };

Why not have everything expressed in milliseconds and have sysfs
attribute apply the closest one possible?

By the way, do you want to plumb these through device tree as well?

 +
 +struct axp20x_pek {
 + struct axp20x_dev *axp20x;
 + struct input_dev *input;
 + int irq_dbr;
 + int irq_dbf;
 +};
 +
 +struct axp20x_pek_ext_attr {
 + const char const **str;
 + unsigned int mask;
 +};
 +
 +static struct axp20x_pek_ext_attr axp20x_pek_startup_ext_attr = {
 + .str= startup_time,
 + .mask   = AXP20X_PEK_STARTUP_MASK,
 +};
 +
 +static struct axp20x_pek_ext_attr axp20x_pek_shutdown_ext_attr = {
 + .str= shutdown_time,
 + .mask   = AXP20X_PEK_SHUTDOWN_MASK,
 +};
 +
 +static struct axp20x_pek_ext_attr *get_axp_ext_attr(struct device_attribute 
 *attr)
 +{
 + return container_of(attr, struct dev_ext_attribute, attr)-var;
 +}
 +
 +static ssize_t axp20x_show_ext_attr(struct device *dev, struct 
 device_attribute *attr,
 +  char *buf)
 +{
 + struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
 + struct axp20x_pek_ext_attr *axp20x_ea = get_axp_ext_attr(attr);
 + unsigned int val;
 + int ret, i;
 + int cnt = 0;
 +
 + ret = regmap_read(axp20x_pek-axp20x-regmap, AXP20X_PEK_KEY, val);
 + if (ret != 0)
 + return ret;
 +
 + val = axp20x_ea-mask;
 + val = ffs(axp20x_ea-mask) - 1;
 +
 + for (i = 0; i  4; i++) {
 + if (val == i)
 + cnt += sprintf(buf + cnt, [%s] , axp20x_ea-str[i]);
 + else
 + cnt += sprintf(buf + cnt, %s , axp20x_ea-str[i]);

Please just return the current value; why do we 

[linux-sunxi] Re: [PATCH v4 4/9] input: misc: Add driver for AXP20x Power Enable Key

2014-04-13 Thread Dmitry Torokhov
On Fri, Apr 11, 2014 at 11:38:08AM +0200, Carlo Caione wrote:
 This patch add support for the Power Enable Key found on MFD AXP202 and
 AXP209. Besides the basic support for the button, the driver adds two
 entries in sysfs to configure the time delay for power on/off.
 
 Signed-off-by: Carlo Caione ca...@caione.org
 ---
  drivers/input/misc/Kconfig  |  11 ++
  drivers/input/misc/Makefile |   1 +
  drivers/input/misc/axp20x-pek.c | 261 
 
  3 files changed, 273 insertions(+)
  create mode 100644 drivers/input/misc/axp20x-pek.c
 
 diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
 index 7904ab0..87244fb 100644
 --- a/drivers/input/misc/Kconfig
 +++ b/drivers/input/misc/Kconfig
 @@ -393,6 +393,17 @@ config INPUT_RETU_PWRBUTTON
 To compile this driver as a module, choose M here. The module will
 be called retu-pwrbutton.
  
 +config INPUT_AXP20X_PEK
 + tristate X-Powers AXP20X power button driver
 + depends on MFD_AXP20X
 + help
 +   Say Y here if you want to enable power key reporting via the
 +   AXP20X PMIC.
 +
 +   To compile this driver as a module, choose M here. The module will
 +   be called axp20x-pek.
 +
 +
  config INPUT_TWL4030_PWRBUTTON
   tristate TWL4030 Power button Driver
   depends on TWL4030_CORE
 diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
 index cda71fc..624abf5 100644
 --- a/drivers/input/misc/Makefile
 +++ b/drivers/input/misc/Makefile
 @@ -50,6 +50,7 @@ obj-$(CONFIG_INPUT_POWERMATE)   += powermate.o
  obj-$(CONFIG_INPUT_PWM_BEEPER)   += pwm-beeper.o
  obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o
  obj-$(CONFIG_INPUT_RETU_PWRBUTTON)   += retu-pwrbutton.o
 +obj-$(CONFIG_INPUT_AXP20X_PEK)   += axp20x-pek.o
  obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER)  += rotary_encoder.o
  obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o
  obj-$(CONFIG_INPUT_SIRFSOC_ONKEY)+= sirfsoc-onkey.o
 diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
 new file mode 100644
 index 000..a9112bd
 --- /dev/null
 +++ b/drivers/input/misc/axp20x-pek.c
 @@ -0,0 +1,261 @@
 +/*
 + * axp20x power button driver.
 + *
 + * Copyright (C) 2013 Carlo Caione ca...@caione.org
 + *
 + * This file is subject to the terms and conditions of the GNU General
 + * Public License. See the file COPYING in the main directory of this
 + * archive for more details.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 + * GNU General Public License for more details.
 + */
 +
 +#include linux/errno.h
 +#include linux/irq.h
 +#include linux/init.h
 +#include linux/input.h
 +#include linux/interrupt.h
 +#include linux/kernel.h
 +#include linux/mfd/axp20x.h
 +#include linux/module.h
 +#include linux/platform_device.h
 +#include linux/regmap.h
 +#include linux/slab.h
 +
 +#define AXP20X_PEK_STARTUP_MASK  (0xc0)
 +#define AXP20X_PEK_SHUTDOWN_MASK (0x03)
 +
 +struct axp20x_pek {
 + struct axp20x_dev *axp20x;
 + struct input_dev *input;
 + int irq_dbr;
 + int irq_dbf;
 +};
 +
 +struct axp20x_time {
 + unsigned int time;
 + unsigned int idx;
 +};
 +
 +static const struct axp20x_time startup_time[] = {
 + { .time = 128,  .idx = 0 },
 + { .time = 1000, .idx = 2 },
 + { .time = 3000, .idx = 1 },
 + { .time = 2000, .idx = 3 },
 +};
 +
 +static const struct axp20x_time shutdown_time[] = {
 + { .time = 4000,  .idx = 0 },
 + { .time = 6000,  .idx = 1 },
 + { .time = 8000,  .idx = 2 },
 + { .time = 1, .idx = 3 },
 +};
 +
 +struct axp20x_pek_ext_attr {
 + const struct axp20x_time *p_time;
 + unsigned int mask;
 +};
 +
 +static struct axp20x_pek_ext_attr axp20x_pek_startup_ext_attr = {
 + .p_time = startup_time,
 + .mask   = AXP20X_PEK_STARTUP_MASK,
 +};
 +
 +static struct axp20x_pek_ext_attr axp20x_pek_shutdown_ext_attr = {
 + .p_time = shutdown_time,
 + .mask   = AXP20X_PEK_SHUTDOWN_MASK,
 +};
 +
 +static struct axp20x_pek_ext_attr *get_axp_ext_attr(struct device_attribute 
 *attr)
 +{
 + return container_of(attr, struct dev_ext_attribute, attr)-var;
 +}
 +
 +static ssize_t axp20x_show_ext_attr(struct device *dev, struct 
 device_attribute *attr,
 + char *buf)
 +{
 + struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
 + struct axp20x_pek_ext_attr *axp20x_ea = get_axp_ext_attr(attr);
 + unsigned int val;
 + int ret, i;
 +
 + ret = regmap_read(axp20x_pek-axp20x-regmap, AXP20X_PEK_KEY, val);
 + if (ret != 0)
 + return ret;
 +
 + val = axp20x_ea-mask;
 + val = ffs(axp20x_ea-mask) - 1;
 +
 + for (i = 0; i  4; i++)
 + if (val == axp20x_ea-p_time[i].idx)
 + val = 

Re: [linux-sunxi] [PATCH v4 2/2] input: sun4i-ts: Add support for temperature sensor

2014-05-14 Thread Dmitry Torokhov
On Mon, May 12, 2014 at 04:44:51PM +0800, Chen-Yu Tsai wrote:
 Hi,
 
 On Sun, May 11, 2014 at 4:06 PM, Hans de Goede hdego...@redhat.com wrote:
  @@ -232,14 +284,39 @@ static int sun4i_ts_probe(struct platform_device 
  *pdev)
  writel(STYLUS_UP_DEBOUN(5) | STYLUS_UP_DEBOUN_EN(1) | TP_MODE_EN(1),
 ts-base + TP_CTRL1);
 
  -   ret = input_register_device(ts-input);
  -   if (ret)
  -   return ret;
  +   hwmon = devm_hwmon_device_register_with_groups(ts-dev, sun4i_ts,
  +  ts, sun4i_ts_groups);
 
 This fails to compile when HWMON is not selected:
 
 drivers/built-in.o: In function `sun4i_ts_probe':
 /home/wens/cubieboard/linux/drivers/input/touchscreen/sun4i-ts.c:287:
 undefined reference to `devm_hwmon_device_register_with_groups'
 
 Best do a wrapper around the hwmon related code.
 drivers/input/touchscreen/ads7846.c has something similar, albeit for voltage.

I added dependency on HWMON and applied, thank you.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v5 4/8] input: misc: Add driver for AXP20x Power Enable Key

2014-05-18 Thread Dmitry Torokhov
On Fri, May 02, 2014 at 06:06:04PM -0700, Maxime Ripard wrote:
 On Thu, May 01, 2014 at 02:29:30PM +0200, Carlo Caione wrote:
  This patch add support for the Power Enable Key found on MFD AXP202 and
  AXP209. Besides the basic support for the button, the driver adds two
  entries in sysfs to configure the time delay for power on/off.
  
  Signed-off-by: Carlo Caione ca...@caione.org
 
 Acked-by: Maxime Ripard maxime.rip...@free-electrons.com

Acked-by: Dmitry Torokhov dmitry.torok...@gmail.com

How are we merging it? MFD tree?

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 1/2] touchscreen: sun4i-ts: A10 (sun4i) has double the temperature precision

2014-06-16 Thread Dmitry Torokhov
Hi Hans,

On Mon, Jun 16, 2014 at 08:24:28PM +0200, Hans de Goede wrote:
 Testing has revealed that the temperature in the rtp controller of the A10
 (sun4i) SoC has a resolution of 50 milli degrees / step, where as the
 A13 (sun5i) and later models have 100 milli degrees / step.
 
 Add a new sun5i-a13-ts compatible to differentiate the newer models and
 set the resolution based on the compatible string.
 
 This fixes the temperature reported on the A10 being twice as high as 
 expected.

Should we maybe add explicit temperature steps property so that we won;t
need to patch again if they decided to change resolution again?

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 2/3] drivers:input:ps2 Added sunxi A20 ps2 driver, changed makefile and Kconfig

2014-12-03 Thread Dmitry Torokhov
On Thu, Dec 04, 2014 at 04:23:44AM +0530, vishnupatekar wrote:
 ---
  drivers/input/serio/Kconfig |9 ++
  drivers/input/serio/Makefile|1 +
  drivers/input/serio/sunxi-ps2.c |  305 
 +++
  3 files changed, 315 insertions(+)
  create mode 100644 drivers/input/serio/sunxi-ps2.c
 
 diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
 index bc2d474..1a86e41 100644
 --- a/drivers/input/serio/Kconfig
 +++ b/drivers/input/serio/Kconfig
 @@ -281,4 +281,13 @@ config HYPERV_KEYBOARD
 To compile this driver as a module, choose M here: the module will
 be called hyperv_keyboard.
  
 +config SERIO_SUNXI_PS2
 + tristate Allwinner Sun7i-A20 PS/2 controller
 + default m

Why default m? Default should be n. Also it seems it has to depend on
OF. And what about depending on arch || COMPILE_TEST?

 + help
 +   Say Y here if you have Sun7i-A20 Allwinner PS/2 ports.
 +
 +   To compile this driver as a module, choose M here: the
 +   module will be called sunxi-ps2.
 +
  endif
 diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile
 index 815d874..0fa0f78 100644
 --- a/drivers/input/serio/Makefile
 +++ b/drivers/input/serio/Makefile
 @@ -29,3 +29,4 @@ obj-$(CONFIG_SERIO_ARC_PS2) += arc_ps2.o
  obj-$(CONFIG_SERIO_APBPS2)   += apbps2.o
  obj-$(CONFIG_SERIO_OLPC_APSP)+= olpc_apsp.o
  obj-$(CONFIG_HYPERV_KEYBOARD)+= hyperv-keyboard.o
 +obj-$(CONFIG_SERIO_SUNXI_PS2)+= sunxi-ps2.o
 diff --git a/drivers/input/serio/sunxi-ps2.c b/drivers/input/serio/sunxi-ps2.c
 new file mode 100644
 index 000..ccd7b29
 --- /dev/null
 +++ b/drivers/input/serio/sunxi-ps2.c
 @@ -0,0 +1,305 @@
 +/*
 + * sunxi-ps2.c Support for Allwinner A20 PS2 host controller

No file names in sources please.

 + *
 + * Author: Aaron.maoye leafy.m...@newbietech.com
 + *  Vishnu Patekar vishnupatekar0...@gmail.com
 + * Based on sunxi-ps2.c 3.0 kernel
 + *
 +*/
 +
 +#include linux/module.h
 +#include linux/serio.h
 +#include linux/interrupt.h
 +#include linux/errno.h
 +#include linux/slab.h
 +#include linux/list.h
 +#include linux/io.h
 +#include linux/of_address.h
 +#include linux/of_device.h
 +#include linux/of_irq.h
 +#include linux/of_platform.h
 +#include linux/clk.h
 +#include linux/delay.h
 +
 +#define DRIVER_NAME  sunxi-ps2
 +
 +#define RESSIZE(res)(((res)-end - (res)-start)+1)

I am sure we have something generic for it, no?

 +
 +#define SW_PS2_GCTRL(0x00)
 +#define SW_PS2_DATA (0x04)
 +#define SW_PS2_LCTRL(0x08)
 +#define SW_PS2_LSTAT(0x0c)
 +#define SW_PS2_FCTRL(0x10)
 +#define SW_PS2_FSTAT(0x14)
 +#define SW_PS2_CLKDR(0x18)
 +
 +/* SW_PS2_GCTRL */
 +#define SWPS2_BUSEN (1  0)
 +#define SWPS2_MASTER(1  1)
 +#define SWPS2_RESET (1  2)
 +#define SWPS2_INTEN (1  3)
 +#define SWPS2_INTFLAG   (1  3)
 +
 +/* SW_PS2_LCTRL */
 +#define SWPS2_LCTL_NOACK(0x0  18)
 +#define SWPS2_LCTL_TXDTOEN  (0x1  8)
 +#define SWPS2_LCTL_STOPERREN(0x1  3)
 +#define SWPS2_LCTL_ACKERREN (0x1  2)
 +#define SWPS2_LCTL_PARERREN (0x1  1)
 +#define SWPS2_LCTL_RXDTOEN  (0x1  0)
 +
 +/* SW_PS2_FSTAT */
 +#define SWPS2_FSTA_RXRDY(1  0)
 +#define SWPS2_FSTA_RXOF (1  1)
 +#define SWPS2_FSTA_RXUF (1  2)
 +#define SWPS2_FSTA_TXRDY(1  8)
 +#define SWPS2_FSTA_TXOF (1  9)
 +#define SWPS2_FSTA_TXUF (1  10)
 +
 +#define SW_PS2_SAMPLE_CLK  (100)
 +#define SW_PS2_SCLK(125000)
 +
 +struct sunxips2data {
 + int irq;
 + spinlock_t ps2_lock;
 + void __iomem *base_address; /* virt address of control registers*/
 + struct serio *serio;/* serio*/
 + struct device *dev;
 + struct  clk *pclk;
 +};
 +
 +/*/
 +/* Interrupt handler */
 +/*/
 +static irqreturn_t sunxips2_interrupt(int irq, void *dev_id)
 +{
 + struct sunxips2data *drvdata = dev_id;
 + u32 intr_status;
 + u32 fifo_status;
 + unsigned char byte;
 + u32 rval;
 + u32 error = 0;
 +
 + spin_lock(drvdata-ps2_lock);
 +
 + /* Get the PS/2 interrupts and clear them */
 + intr_status  = readl(drvdata-base_address + SW_PS2_LSTAT);
 + fifo_status  = readl(drvdata-base_address + SW_PS2_FSTAT);
 +
 + /*Check Line Status Register*/
 + if (intr_status  0x10f) {
 + if (intr_status  0x08)
 + dev_info(drvdata-dev, PS/2 Stop Bit Error!);
 + if (intr_status  0x04)
 + dev_info(drvdata-dev, PS/2 Acknowledge Error!\n);
 + if (intr_status  0x02)
 + dev_info(drvdata-dev, PS/2 Parity Error!\n);
 + if (intr_status  0x100)
 + dev_info(drvdata-dev, PS/2 Transmit Data Timeout!\n);
 + if (intr_status  0x01)
 + dev_info(drvdata-dev, PS/2 

[linux-sunxi] Re: [PATCH 2/3] drivers:input:ps2 Added sunxi A20 ps2 driver, changed makefile and Kconfig

2014-12-05 Thread Dmitry Torokhov
Hi Arnd,

On December 5, 2014 2:33:11 AM PST, Arnd Bergmann a...@arndb.de wrote:
On Thursday 04 December 2014 04:23:44 vishnupatekar wrote:
 +
 +struct sunxips2data {
 +int irq;
 +spinlock_t ps2_lock;
 +void __iomem *base_address; /* virt address of control registers*/
 +struct serio *serio;/* serio*/
 +struct device *dev;
 +struct  clk *pclk;
 +};

As this is dynamically allocated, better embed the serio member
directly to avoid allocating both separately.

That would be wrong - serio is refcounted and it may outlive instance of 
sunxips2data you embedded it into.


Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 2/3] drivers:input:ps2 Added sunxi A20 ps2 driver, changed makefile and Kconfig

2014-12-05 Thread Dmitry Torokhov
On December 5, 2014 7:50:18 AM PST, Arnd Bergmann a...@arndb.de wrote:
On Friday 05 December 2014 07:01:17 Dmitry Torokhov wrote:
 
 On December 5, 2014 2:33:11 AM PST, Arnd Bergmann a...@arndb.de
wrote:
 On Thursday 04 December 2014 04:23:44 vishnupatekar wrote:
  +
  +struct sunxips2data {
  +int irq;
  +spinlock_t ps2_lock;
  +void __iomem *base_address; /* virt address of control
registers*/
  +struct serio *serio;/* serio*/
  +struct device *dev;
  +struct  clk *pclk;
  +};
 
 As this is dynamically allocated, better embed the serio member
 directly to avoid allocating both separately.
 
 That would be wrong - serio is refcounted and it may outlive instance
of sunxips2data you embedded it into.

Ok, I see. I guess in this case the use of devm_kzalloc for serio is a
bug,
because that would lead to a double free upon module unload, right?


Exactly. I already mentioned that in my review.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH resend v2] input: Add new sun4i-lradc-keys driver

2014-12-17 Thread Dmitry Torokhov
On Wednesday, December 17, 2014 03:43:31 PM Hans de Goede wrote:
 +   /*
 +* lradc supports only one keypress at a time, release does not give
 +* any info as to which key was released, so we cache the keycode.
 +*/
 +   if ((ints  CHAN0_KEYDOWN_IRQ)  lradc-chan0_keycode == 0) {
 +   val = readl(lradc-base + LRADC_DATA0)  0x3f;
 +   voltage = val * lradc-vref / 63;
 +
 +   for (i = 0; i  lradc-chan0_map_count; i++) {
 +   diff = abs(lradc-chan0_map[i].voltage - voltage);
 +   if (diff  closest) {
 +   closest = diff;
 +   keycode = lradc-chan0_map[i].keycode;
 +   }
 +   }
 +
 +   lradc-chan0_keycode = keycode;
 +   input_report_key(lradc-input, lradc-chan0_keycode, 1);
 +   }
 +
 +   if (ints  CHAN0_KEYUP_IRQ) {
 +   input_report_key(lradc-input, lradc-chan0_keycode, 0);
 +   lradc-chan0_keycode = 0;
 +   }

Can release and press be reported simultaneously? Should we process release 
first?

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v3] input: Add new sun4i-lradc-keys driver

2014-12-18 Thread Dmitry Torokhov
Hi Hans,

On Thu, Dec 18, 2014 at 11:23:13AM +0100, Hans de Goede wrote:
 Allwinnner sunxi SoCs have a low resolution adc (called lradc) which is
 specifically designed to have various (tablet) keys (ie home, back, search,
 etc). attached to it using a resistor network. This adds a driver for this.
 
 There are 2 channels, currently this driver only supports chan0 since there
 are no boards known to use chan1.
 
 This has been tested on an olimex a10s-olinuxino-micro, a13-olinuxino, and
 a20-olinuxino-micro.
 
 Signed-off-by: Hans de Goede hdego...@redhat.com
 --
 Changes in v2:
 -Change devicetree bindings to use a per key subnode, like gpio-keys does
 Changes in v3:
 -Handle keyup irq flag before irqdown, in case we get both at once

Thank you for making changes. Can you please tell me if the driver still
works if you drop the patch below on top of it? The changes are:

- split DT parsing into a separate function;
- make sure keymap is not empty;
- change 'ret' variable to 'error'; 

Thanks!

-- 
Dmitry

Input: sun4i-lradc-keys - misc changes

From: Dmitry Torokhov dmitry.torok...@gmail.com

Signed-off-by: Dmitry Torokhov dmitry.torok...@gmail.com
---
 drivers/input/keyboard/sun4i-lradc-keys.c |   87 +++--
 1 file changed, 57 insertions(+), 30 deletions(-)

diff --git a/drivers/input/keyboard/sun4i-lradc-keys.c 
b/drivers/input/keyboard/sun4i-lradc-keys.c
index 06d5c69..cc8f7dd 100644
--- a/drivers/input/keyboard/sun4i-lradc-keys.c
+++ b/drivers/input/keyboard/sun4i-lradc-keys.c
@@ -122,11 +122,11 @@ static irqreturn_t sun4i_lradc_irq(int irq, void *dev_id)
 static int sun4i_lradc_open(struct input_dev *dev)
 {
struct sun4i_lradc_data *lradc = input_get_drvdata(dev);
-   int ret;
+   int error;
 
-   ret = regulator_enable(lradc-vref_supply);
-   if (ret)
-   return ret;
+   error = regulator_enable(lradc-vref_supply);
+   if (error)
+   return error;
 
/* lradc Vref internally is divided by 2/3 */
lradc-vref = regulator_get_voltage(lradc-vref_supply) * 2 / 3;
@@ -155,42 +155,48 @@ static void sun4i_lradc_close(struct input_dev *dev)
regulator_disable(lradc-vref_supply);
 }
 
-static int sun4i_lradc_probe(struct platform_device *pdev)
+static int sun4i_lradc_load_dt_keymap(struct device *dev,
+ struct sun4i_lradc_data *lradc)
 {
-   struct sun4i_lradc_data *lradc;
-   struct device *dev = pdev-dev;
-   struct device_node *pp, *np = dev-of_node;
-   u32 channel;
-   int i, ret;
+   struct device_node *np, *pp;
+   int i;
+   int error;
 
-   lradc = devm_kzalloc(dev, sizeof(struct sun4i_lradc_data), GFP_KERNEL);
-   if (!lradc)
-   return -ENOMEM;
+   np = dev-of_node;
+   if (!np)
+   return -EINVAL;
 
lradc-chan0_map_count = of_get_child_count(np);
-   lradc-chan0_map = devm_kmalloc(dev, lradc-chan0_map_count *
-   sizeof(struct sun4i_lradc_keymap), GFP_KERNEL);
+   if (lradc-chan0_map_count == 0) {
+   dev_err(dev, keymap is missing in device tree\n);
+   return -EINVAL;
+   }
+
+   lradc-chan0_map = devm_kmalloc_array(dev, lradc-chan0_map_count,
+ sizeof(struct sun4i_lradc_keymap),
+ GFP_KERNEL);
if (!lradc-chan0_map)
return -ENOMEM;
 
i = 0;
for_each_child_of_node(np, pp) {
struct sun4i_lradc_keymap *map = lradc-chan0_map[i];
+   u32 channel;
 
-   ret = of_property_read_u32(pp, channel, channel);
-   if (ret || channel != 0) {
+   error = of_property_read_u32(pp, channel, channel);
+   if (error || channel != 0) {
dev_err(dev, %s: Inval channel prop\n, pp-name);
return -EINVAL;
}
 
-   ret = of_property_read_u32(pp, voltage, map-voltage);
-   if (ret) {
+   error = of_property_read_u32(pp, voltage, map-voltage);
+   if (error) {
dev_err(dev, %s: Inval voltage prop\n, pp-name);
return -EINVAL;
}
 
-   ret = of_property_read_u32(pp, linux,code, map-keycode);
-   if (ret) {
+   error = of_property_read_u32(pp, linux,code, map-keycode);
+   if (error) {
dev_err(dev, %s: Inval linux,code prop\n, pp-name);
return -EINVAL;
}
@@ -198,6 +204,24 @@ static int sun4i_lradc_probe(struct platform_device *pdev)
i++;
}
 
+   return 0;
+}
+
+static int sun4i_lradc_probe(struct platform_device *pdev)
+{
+   struct sun4i_lradc_data *lradc;
+   struct device *dev = pdev-dev;
+   int i;
+   int error

[linux-sunxi] Re: [PATCH v3] input: Add new sun4i-lradc-keys driver

2014-12-21 Thread Dmitry Torokhov
On Sat, Dec 20, 2014 at 11:44:37AM +0100, Hans de Goede wrote:
 Hi Dmitry,
 
 On 18-12-14 18:51, Dmitry Torokhov wrote:
 Hi Hans,
 
 On Thu, Dec 18, 2014 at 11:23:13AM +0100, Hans de Goede wrote:
 Allwinnner sunxi SoCs have a low resolution adc (called lradc) which is
 specifically designed to have various (tablet) keys (ie home, back, search,
 etc). attached to it using a resistor network. This adds a driver for this.
 
 There are 2 channels, currently this driver only supports chan0 since there
 are no boards known to use chan1.
 
 This has been tested on an olimex a10s-olinuxino-micro, a13-olinuxino, and
 a20-olinuxino-micro.
 
 Signed-off-by: Hans de Goede hdego...@redhat.com
 --
 Changes in v2:
 -Change devicetree bindings to use a per key subnode, like gpio-keys does
 Changes in v3:
 -Handle keyup irq flag before irqdown, in case we get both at once
 
 Thank you for making changes. Can you please tell me if the driver still
 works if you drop the patch below on top of it? The changes are:
 
 - split DT parsing into a separate function;
 - make sure keymap is not empty;
 - change 'ret' variable to 'error';
 
 The proposed changes look good, and I've given them a test-spin and everything
 still works fine.

Excellent, folded and applied.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v8 3/6] input: misc: Add driver for AXP20x Power Enable Key

2014-12-29 Thread Dmitry Torokhov
On Tue, Dec 23, 2014 at 10:53:11AM +0800, Chen-Yu Tsai wrote:
 From: Carlo Caione ca...@caione.org
 
 This patch add support for the Power Enable Key found on MFD AXP202 and
 AXP209. Besides the basic support for the button, the driver adds two
 entries in sysfs to configure the time delay for power on/off.
 
 Signed-off-by: Carlo Caione ca...@caione.org
 Acked-by: Dmitry Torokhov dmitry.torok...@gmail.com
 [w...@csie.org: make axp20x_pek_remove() static; remove driver owner field]
 Signed-off-by: Chen-Yu Tsai w...@csie.org

Hmm, it looks like MFD parts are in mainline, so I can actually pick
this up myself. OK.

By the way, does driver works for you with the patch below?

Thanks.

-- 
Dmitry

Input: axp20x-pek - switch over to using attribute group

From: Dmitry Torokhov dmitry.torok...@gmail.com

Instead of registering device attributes individually let's use attribute
groups and also devm_* infrastructure to ease cleanup.

Refresh of synaptics-forcepad-pnp.patch
---
 drivers/input/misc/axp20x-pek.c |   64 ++-
 1 file changed, 36 insertions(+), 28 deletions(-)

diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index 8dbd097..f1c8447 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -138,17 +138,28 @@ static ssize_t axp20x_store_ext_attr(struct device *dev,
 axp20x_ea-mask, idx);
if (ret != 0)
return -EINVAL;
+
return count;
 }
 
 static struct dev_ext_attribute axp20x_dev_attr_startup = {
.attr   = __ATTR(startup, 0644, axp20x_show_ext_attr, 
axp20x_store_ext_attr),
-   .var= axp20x_pek_startup_ext_attr
+   .var= axp20x_pek_startup_ext_attr,
 };
 
 static struct dev_ext_attribute axp20x_dev_attr_shutdown = {
.attr   = __ATTR(shutdown, 0644, axp20x_show_ext_attr, 
axp20x_store_ext_attr),
-   .var= axp20x_pek_shutdown_ext_attr
+   .var= axp20x_pek_shutdown_ext_attr,
+};
+
+static struct attribute *axp20x_attributes[] = {
+   axp20x_dev_attr_startup.attr.attr,
+   axp20x_dev_attr_shutdown.attr.attr,
+   NULL,
+};
+
+static const struct attribute_group axp20x_attribute_group = {
+   .attrs = axp20x_attributes,
 };
 
 static irqreturn_t axp20x_pek_irq(int irq, void *pwr)
@@ -166,6 +177,13 @@ static irqreturn_t axp20x_pek_irq(int irq, void *pwr)
return IRQ_HANDLED;
 }
 
+static void axp20x_remove_sysfs_group(void *_data)
+{
+   struct device *dev = _data;
+
+   sysfs_remove_group(dev-kobj, axp20x_attribute_group);
+}
+
 static int axp20x_pek_probe(struct platform_device *pdev)
 {
struct axp20x_pek *axp20x_pek;
@@ -214,12 +232,11 @@ static int axp20x_pek_probe(struct platform_device *pdev)
input_set_drvdata(idev, axp20x_pek);
 
error = devm_request_any_context_irq(pdev-dev, axp20x_pek-irq_dbr,
- axp20x_pek_irq, 0,
- axp20x-pek-dbr, idev);
+axp20x_pek_irq, 0,
+axp20x-pek-dbr, idev);
if (error  0) {
dev_err(axp20x-dev, Failed to request dbr IRQ#%d: %d\n,
axp20x_pek-irq_dbr, error);
-
return error;
}
 
@@ -232,45 +249,36 @@ static int axp20x_pek_probe(struct platform_device *pdev)
return error;
}
 
-   error = device_create_file(pdev-dev, axp20x_dev_attr_startup.attr);
-   if (error)
+   error = sysfs_create_group(pdev-dev.kobj, axp20x_attribute_group);
+   if (error) {
+   dev_err(axp20x-dev, Failed to create sysfs attributes: %d\n,
+   error);
return error;
+   }
 
-   error = device_create_file(pdev-dev, axp20x_dev_attr_shutdown.attr);
-   if (error)
-   goto clear_startup_attr;
+   error = devm_add_action(pdev-dev,
+   axp20x_remove_sysfs_group, pdev-dev);
+   if (error) {
+   axp20x_remove_sysfs_group(pdev-dev);
+   dev_err(pdev-dev, Failed to add sysfs cleanup action: %d\n,
+   error);
+   return error;
+   }
 
error = input_register_device(idev);
if (error) {
dev_err(axp20x-dev, Can't register input device: %d\n,
error);
-   goto clear_attr;
+   return error;
}
 
platform_set_drvdata(pdev, axp20x_pek);
 
return 0;
-
-clear_attr:
-   device_remove_file(pdev-dev, axp20x_dev_attr_shutdown.attr);
-
-clear_startup_attr:
-   device_remove_file(pdev-dev, axp20x_dev_attr_startup.attr);
-
-   return error;
-}
-
-static int axp20x_pek_remove(struct platform_device *pdev)
-{
-   device_remove_file(pdev-dev, axp20x_dev_attr_shutdown.attr);
-   device_remove_file(pdev-dev

[linux-sunxi] Re: [PATCH] arm: sunxi: input: RFC: Add sysfs voltage for sun4i-lradc driver

2015-01-26 Thread Dmitry Torokhov
On Mon, Jan 26, 2015 at 08:28:29PM +0100, Hans de Goede wrote:
 Hi,
 
 On 26-01-15 17:58, Priit Laes wrote:
 
 No commit message? Please write an informative commit msg, like why we want 
 this patch,
 I guess it is to help figuring out the voltage levels for various buttons 
 when creating
 a dts, but I would prefer to not guess, which is where a good commit message 
 would
 come in handy ...
 
 ---
   .../ABI/testing/sysfs-driver-input-sun4i-lradc |  4 ++
   drivers/input/keyboard/sun4i-lradc-keys.c  | 49 
  +-
   2 files changed, 43 insertions(+), 10 deletions(-)
   create mode 100644 Documentation/ABI/testing/sysfs-driver-input-sun4i-lradc
 
 diff --git a/Documentation/ABI/testing/sysfs-driver-input-sun4i-lradc 
 b/Documentation/ABI/testing/sysfs-driver-input-sun4i-lradc
 new file mode 100644
 index 000..e4e6448
 --- /dev/null
 +++ b/Documentation/ABI/testing/sysfs-driver-input-sun4i-lradc
 @@ -0,0 +1,4 @@
 +What:   /sys/class/input/input(x)/device/voltage
 +Date:   February 2015
 +Contact:Priit Laes pl...@plaes.org
 +Description:ADC output voltage in microvolts or 0 if device is not 
 opened.
 diff --git a/drivers/input/keyboard/sun4i-lradc-keys.c 
 b/drivers/input/keyboard/sun4i-lradc-keys.c
 index cc8f7dd..c0ab8ec 100644
 --- a/drivers/input/keyboard/sun4i-lradc-keys.c
 +++ b/drivers/input/keyboard/sun4i-lradc-keys.c
 @@ -79,10 +79,27 @@ struct sun4i_lradc_data {
  u32 vref;
   };
 
 +static u32 sun4i_lradc_read_voltage(struct sun4i_lradc_data *lradc)
 +{
 +u32 val = readl(lradc-base + LRADC_DATA0)  0x3f;
 +return val * lradc-vref / 63;
 +};
 +
 +static ssize_t
 +sun4i_lradc_dev_voltage_show(struct device *dev,
 +struct device_attribute *attr, char *buf)
 +{
 +struct sun4i_lradc_data *lradc = dev_get_drvdata(dev);
 +
 +return sprintf(buf, %u\n, sun4i_lradc_read_voltage(lradc));
 +}
 +
 +static const DEVICE_ATTR(voltage, S_IRUGO, sun4i_lradc_dev_voltage_show, 
 NULL);
 +
   static irqreturn_t sun4i_lradc_irq(int irq, void *dev_id)
   {
  struct sun4i_lradc_data *lradc = dev_id;
 -u32 i, ints, val, voltage, diff, keycode = 0, closest = 0x;
 +u32 i, ints, voltage, diff, keycode = 0, closest = 0x;
 
  ints  = readl(lradc-base + LRADC_INTS);
 
 @@ -97,8 +114,7 @@ static irqreturn_t sun4i_lradc_irq(int irq, void *dev_id)
  }
 
  if ((ints  CHAN0_KEYDOWN_IRQ)  lradc-chan0_keycode == 0) {
 -val = readl(lradc-base + LRADC_DATA0)  0x3f;
 -voltage = val * lradc-vref / 63;
 +voltage = sun4i_lradc_read_voltage(lradc);
 
  for (i = 0; i  lradc-chan0_map_count; i++) {
  diff = abs(lradc-chan0_map[i].voltage - voltage);
 @@ -156,7 +172,7 @@ static void sun4i_lradc_close(struct input_dev *dev)
   }
 
   static int sun4i_lradc_load_dt_keymap(struct device *dev,
 -  struct sun4i_lradc_data *lradc)
 +struct sun4i_lradc_data *lradc)
   {
  struct device_node *np, *pp;
  int i;
 
 Why this identation change ?
 
 @@ -168,8 +184,8 @@ static int sun4i_lradc_load_dt_keymap(struct device *dev,
 
  lradc-chan0_map_count = of_get_child_count(np);
  if (lradc-chan0_map_count == 0) {
 -dev_err(dev, keymap is missing in device tree\n);
 -return -EINVAL;
 +dev_info(dev, keymap is missing in device tree\n);
 +return 0;
  }
 
  lradc-chan0_map = devm_kmalloc_array(dev, lradc-chan0_map_count,
 
 I assume this is so that people can still use the sysfs node, to create a 
 dts, right
 not sure I like this, might be better to document to simple create a dts with
 a single button mapping for 200 mV (most board use 200 mV steps between the 
 buttons).
 
 @@ -185,19 +201,19 @@ static int sun4i_lradc_load_dt_keymap(struct device 
 *dev,
 
  error = of_property_read_u32(pp, channel, channel);
  if (error || channel != 0) {
 -dev_err(dev, %s: Inval channel prop\n, pp-name);
 +dev_err(dev, %s: Invalid 'channel' property\n, 
 pp-name);
  return -EINVAL;
  }
 
  error = of_property_read_u32(pp, voltage, map-voltage);
  if (error) {
 -dev_err(dev, %s: Inval voltage prop\n, pp-name);
 +dev_err(dev, %s: Invalid 'voltage' property\n, 
 pp-name);
  return -EINVAL;
  }
 
  error = of_property_read_u32(pp, linux,code, map-keycode);
  if (error) {
 -dev_err(dev, %s: Inval linux,code prop\n, pp-name);
 +dev_err(dev, %s: Invalid 'linux,code' property\n, 
 pp-name);
  return -EINVAL;
  }
 
 
 This hunk / 3 changes belong in a separate patch. Also please run checkpatch, 
 I think
 you're running over 80 chars here.
 
 
 @@ 

[linux-sunxi] Re: [PATCH v8 4/6] input: misc: Add ABI docs for AXP20x PEK

2015-01-15 Thread Dmitry Torokhov
Hi Chen-Yu,

On Fri, Jan 16, 2015 at 12:00:31AM +0800, Chen-Yu Tsai wrote:
 On Tue, Dec 23, 2014 at 10:53 AM, Chen-Yu Tsai w...@csie.org wrote:
  From: Carlo Caione ca...@caione.org
 
  Add ABI entries for the PEK found on PMU X-Powers AXP202 and AXP209.
 
 Hi Dmitry,
 
 Would it be possible to take this patch through your tree?

Actually I folded it into the original patch adding the code so it's
already there.

Thanks.

 
 
 Thanks
 ChenYu
 
  Signed-off-by: Carlo Caione ca...@caione.org
  [w...@csie.org: Fixed path for sysfs entries]
  Signed-off-by: Chen-Yu Tsai w...@csie.org
  ---
   Documentation/ABI/testing/sysfs-driver-input-axp-pek | 11 +++
   1 file changed, 11 insertions(+)
   create mode 100644 Documentation/ABI/testing/sysfs-driver-input-axp-pek
 
  diff --git a/Documentation/ABI/testing/sysfs-driver-input-axp-pek 
  b/Documentation/ABI/testing/sysfs-driver-input-axp-pek
  new file mode 100644
  index ..a5e671b9fa79
  --- /dev/null
  +++ b/Documentation/ABI/testing/sysfs-driver-input-axp-pek
  @@ -0,0 +1,11 @@
  +What:  /sys/class/input/input(x)/device/startup
  +Date:  March 2014
  +Contact:   Carlo Caione ca...@caione.org
  +Description:   Startup time in us. Board is powered on if the button is 
  pressed
  +   for more than startup_time
  +
  +What:  /sys/class/input/input(x)/device/shutdown
  +Date:  March 2014
  +Contact:   Carlo Caione ca...@caione.org
  +Description:   Shutdown time in us. Board is powered off if the button is 
  pressed
  +   for more than shutdown_time
  --
  2.1.4
 

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v4 2/5] ARM:sunxi:drivers:input Add support for A10/A20 PS2

2015-01-19 Thread Dmitry Torokhov
On Mon, Jan 19, 2015 at 11:37:38AM +0530, Vishnu Patekar wrote:
 Hello Dmitry,
 
 Thank you for review comments. Please see in-lined.
 
 On Sun, Jan 18, 2015 at 3:55 AM, Dmitry Torokhov
 dmitry.torok...@gmail.com wrote:
  Hi Vishnu,
 
  On Fri, Jan 16, 2015 at 07:33:38PM +0530, Vishnu Patekar wrote:
  Signed-off-by: VishnuPatekar vishnupatekar0...@gmail.com
  ---
   drivers/input/serio/Kconfig |   11 ++
   drivers/input/serio/Makefile|1 +
   drivers/input/serio/sun4i-ps2.c |  330 
  +++
   3 files changed, 342 insertions(+)
   create mode 100644 drivers/input/serio/sun4i-ps2.c
 
  diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
  index bc2d474..964afc5 100644
  --- a/drivers/input/serio/Kconfig
  +++ b/drivers/input/serio/Kconfig
  @@ -281,4 +281,15 @@ config HYPERV_KEYBOARD
  To compile this driver as a module, choose M here: the module will
  be called hyperv_keyboard.
 
  +config SERIO_SUN4I_PS2
  + tristate Allwinner A10 PS/2 controller support
  + default n
  + depends on ARCH_SUNXI || COMPILE_TEST
  + help
  +   This selects support for the PS/2 Host Controller on
  +   Allwinner A10.
  +
  +   To compile this driver as a module, choose M here: the
  +   module will be called sun4i-ps2.
  +
   endif
  diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile
  index 815d874..c600089 100644
  --- a/drivers/input/serio/Makefile
  +++ b/drivers/input/serio/Makefile
  @@ -29,3 +29,4 @@ obj-$(CONFIG_SERIO_ARC_PS2) += arc_ps2.o
   obj-$(CONFIG_SERIO_APBPS2)   += apbps2.o
   obj-$(CONFIG_SERIO_OLPC_APSP)+= olpc_apsp.o
   obj-$(CONFIG_HYPERV_KEYBOARD)+= hyperv-keyboard.o
  +obj-$(CONFIG_SERIO_SUN4I_PS2)+= sun4i-ps2.o
  diff --git a/drivers/input/serio/sun4i-ps2.c 
  b/drivers/input/serio/sun4i-ps2.c
  new file mode 100644
  index 000..06b3fef
  --- /dev/null
  +++ b/drivers/input/serio/sun4i-ps2.c
  @@ -0,0 +1,330 @@
  +/*
  + *   Driver for Allwinner A10 PS2 host controller
  + *
  + *   Author: Vishnu Patekar vishnupatekar0...@gmail.com
  + *   Aaron.maoye leafy.m...@newbietech.com
  + *
  + *
  + */
  +
  +#include linux/module.h
  +#include linux/serio.h
  +#include linux/interrupt.h
  +#include linux/errno.h
  +#include linux/slab.h
  +#include linux/list.h
  +#include linux/io.h
  +#include linux/of_address.h
  +#include linux/of_device.h
  +#include linux/of_irq.h
  +#include linux/of_platform.h
  +#include linux/clk.h
  +#include linux/delay.h
  +
  +#define DRIVER_NAME  sun4i-ps2
  +
  +/* register offset definitions */
  +#define PS2_REG_GCTL 0x00/*  PS2 Module Global Control Reg */
  +#define PS2_REG_DATA 0x04/*  PS2 Module Data Reg */
  +#define PS2_REG_LCTL 0x08/*  PS2 Module Line Control Reg */
  +#define PS2_REG_LSTS 0x0C/*  PS2 Module Line Status Reg  */
  +#define PS2_REG_FCTL 0x10/*  PS2 Module FIFO Control Reg */
  +#define PS2_REG_FSTS 0x14/*  PS2 Module FIFO Status Reg  */
  +#define PS2_REG_CLKDR0x18/*  PS2 Module Clock Divider 
  Reg*/
  +
  +/*  PS2 GLOBAL CONTROL REGISTER PS2_GCTL */
  +#define PS2_GCTL_INTFLAG BIT(4)
  +#define PS2_GCTL_INTEN   BIT(3)
  +#define PS2_GCTL_RESET   BIT(2)
  +#define PS2_GCTL_MASTER  BIT(1)
  +#define PS2_GCTL_BUSEN   BIT(0)
  +
  +/* PS2 LINE CONTROL REGISTER */
  +#define PS2_LCTL_NOACK   BIT(18)
  +#define PS2_LCTL_TXDTOEN BIT(8)
  +#define PS2_LCTL_STOPERREN   BIT(3)
  +#define PS2_LCTL_ACKERRENBIT(2)
  +#define PS2_LCTL_PARERRENBIT(1)
  +#define PS2_LCTL_RXDTOEN BIT(0)
  +
  +/* PS2 LINE STATUS REGISTER */
  +#define PS2_LSTS_TXTDO   BIT(8)
  +#define PS2_LSTS_STOPERR BIT(3)
  +#define PS2_LSTS_ACKERR  BIT(2)
  +#define PS2_LSTS_PARERR  BIT(1)
  +#define PS2_LSTS_RXTDO   BIT(0)
  +
  +#define PS2_LINE_ERROR_BIT \
  + (PS2_LSTS_TXTDO | PS2_LSTS_STOPERR | PS2_LSTS_ACKERR | \
  + PS2_LSTS_PARERR | PS2_LSTS_RXTDO)
  +
  +/* PS2 FIFO CONTROL REGISTER */
  +#define PS2_FCTL_TXRST   BIT(17)
  +#define PS2_FCTL_RXRST   BIT(16)
  +#define PS2_FCTL_TXUFIEN BIT(10)
  +#define PS2_FCTL_TXOFIEN BIT(9)
  +#define PS2_FCTL_TXRDYIENBIT(8)
  +#define PS2_FCTL_RXUFIEN BIT(2)
  +#define PS2_FCTL_RXOFIEN BIT(1)
  +#define PS2_FCTL_RXRDYIENBIT(0)
  +
  +/* PS2 FIFO STATUS REGISTER */
  +#define PS2_FSTS_TXUFBIT(10)
  +#define PS2_FSTS_TXOFBIT(9)
  +#define PS2_FSTS_TXRDY   BIT(8)
  +#define PS2_FSTS_RXUFBIT(2)
  +#define PS2_FSTS_RXOFBIT(1)
  +#define PS2_FSTS_RXRDY   BIT(0)
  +
  +#define PS2_FIFO_ERROR_BIT \
  + (PS2_FSTS_TXUF | PS2_FSTS_TXOF | PS2_FSTS_RXUF | PS2_FSTS_RXOF)
  +
  +#define PS2_SAMPLE_CLK

[linux-sunxi] Re: [PATCH v4 2/5] ARM:sunxi:drivers:input Add support for A10/A20 PS2

2015-01-17 Thread Dmitry Torokhov
Hi Vishnu,

On Fri, Jan 16, 2015 at 07:33:38PM +0530, Vishnu Patekar wrote:
 Signed-off-by: VishnuPatekar vishnupatekar0...@gmail.com
 ---
  drivers/input/serio/Kconfig |   11 ++
  drivers/input/serio/Makefile|1 +
  drivers/input/serio/sun4i-ps2.c |  330 
 +++
  3 files changed, 342 insertions(+)
  create mode 100644 drivers/input/serio/sun4i-ps2.c
 
 diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
 index bc2d474..964afc5 100644
 --- a/drivers/input/serio/Kconfig
 +++ b/drivers/input/serio/Kconfig
 @@ -281,4 +281,15 @@ config HYPERV_KEYBOARD
 To compile this driver as a module, choose M here: the module will
 be called hyperv_keyboard.
  
 +config SERIO_SUN4I_PS2
 + tristate Allwinner A10 PS/2 controller support
 + default n
 + depends on ARCH_SUNXI || COMPILE_TEST
 + help
 +   This selects support for the PS/2 Host Controller on
 +   Allwinner A10.
 +
 +   To compile this driver as a module, choose M here: the
 +   module will be called sun4i-ps2.
 +
  endif
 diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile
 index 815d874..c600089 100644
 --- a/drivers/input/serio/Makefile
 +++ b/drivers/input/serio/Makefile
 @@ -29,3 +29,4 @@ obj-$(CONFIG_SERIO_ARC_PS2) += arc_ps2.o
  obj-$(CONFIG_SERIO_APBPS2)   += apbps2.o
  obj-$(CONFIG_SERIO_OLPC_APSP)+= olpc_apsp.o
  obj-$(CONFIG_HYPERV_KEYBOARD)+= hyperv-keyboard.o
 +obj-$(CONFIG_SERIO_SUN4I_PS2)+= sun4i-ps2.o
 diff --git a/drivers/input/serio/sun4i-ps2.c b/drivers/input/serio/sun4i-ps2.c
 new file mode 100644
 index 000..06b3fef
 --- /dev/null
 +++ b/drivers/input/serio/sun4i-ps2.c
 @@ -0,0 +1,330 @@
 +/*
 + *   Driver for Allwinner A10 PS2 host controller
 + *
 + *   Author: Vishnu Patekar vishnupatekar0...@gmail.com
 + *   Aaron.maoye leafy.m...@newbietech.com
 + *
 + *
 + */
 +
 +#include linux/module.h
 +#include linux/serio.h
 +#include linux/interrupt.h
 +#include linux/errno.h
 +#include linux/slab.h
 +#include linux/list.h
 +#include linux/io.h
 +#include linux/of_address.h
 +#include linux/of_device.h
 +#include linux/of_irq.h
 +#include linux/of_platform.h
 +#include linux/clk.h
 +#include linux/delay.h
 +
 +#define DRIVER_NAME  sun4i-ps2
 +
 +/* register offset definitions */
 +#define PS2_REG_GCTL 0x00/*  PS2 Module Global Control Reg */
 +#define PS2_REG_DATA 0x04/*  PS2 Module Data Reg */
 +#define PS2_REG_LCTL 0x08/*  PS2 Module Line Control Reg */
 +#define PS2_REG_LSTS 0x0C/*  PS2 Module Line Status Reg  */
 +#define PS2_REG_FCTL 0x10/*  PS2 Module FIFO Control Reg */
 +#define PS2_REG_FSTS 0x14/*  PS2 Module FIFO Status Reg  */
 +#define PS2_REG_CLKDR0x18/*  PS2 Module Clock Divider 
 Reg*/
 +
 +/*  PS2 GLOBAL CONTROL REGISTER PS2_GCTL */
 +#define PS2_GCTL_INTFLAG BIT(4)
 +#define PS2_GCTL_INTEN   BIT(3)
 +#define PS2_GCTL_RESET   BIT(2)
 +#define PS2_GCTL_MASTER  BIT(1)
 +#define PS2_GCTL_BUSEN   BIT(0)
 +
 +/* PS2 LINE CONTROL REGISTER */
 +#define PS2_LCTL_NOACK   BIT(18)
 +#define PS2_LCTL_TXDTOEN BIT(8)
 +#define PS2_LCTL_STOPERREN   BIT(3)
 +#define PS2_LCTL_ACKERRENBIT(2)
 +#define PS2_LCTL_PARERRENBIT(1)
 +#define PS2_LCTL_RXDTOEN BIT(0)
 +
 +/* PS2 LINE STATUS REGISTER */
 +#define PS2_LSTS_TXTDO   BIT(8)
 +#define PS2_LSTS_STOPERR BIT(3)
 +#define PS2_LSTS_ACKERR  BIT(2)
 +#define PS2_LSTS_PARERR  BIT(1)
 +#define PS2_LSTS_RXTDO   BIT(0)
 +
 +#define PS2_LINE_ERROR_BIT \
 + (PS2_LSTS_TXTDO | PS2_LSTS_STOPERR | PS2_LSTS_ACKERR | \
 + PS2_LSTS_PARERR | PS2_LSTS_RXTDO)
 +
 +/* PS2 FIFO CONTROL REGISTER */
 +#define PS2_FCTL_TXRST   BIT(17)
 +#define PS2_FCTL_RXRST   BIT(16)
 +#define PS2_FCTL_TXUFIEN BIT(10)
 +#define PS2_FCTL_TXOFIEN BIT(9)
 +#define PS2_FCTL_TXRDYIENBIT(8)
 +#define PS2_FCTL_RXUFIEN BIT(2)
 +#define PS2_FCTL_RXOFIEN BIT(1)
 +#define PS2_FCTL_RXRDYIENBIT(0)
 +
 +/* PS2 FIFO STATUS REGISTER */
 +#define PS2_FSTS_TXUFBIT(10)
 +#define PS2_FSTS_TXOFBIT(9)
 +#define PS2_FSTS_TXRDY   BIT(8)
 +#define PS2_FSTS_RXUFBIT(2)
 +#define PS2_FSTS_RXOFBIT(1)
 +#define PS2_FSTS_RXRDY   BIT(0)
 +
 +#define PS2_FIFO_ERROR_BIT \
 + (PS2_FSTS_TXUF | PS2_FSTS_TXOF | PS2_FSTS_RXUF | PS2_FSTS_RXOF)
 +
 +#define PS2_SAMPLE_CLK   100
 +#define PS2_SCLK 125000
 +
 +struct sun4i_ps2data {
 + struct serio *serio;
 + struct device *dev;
 +
 + /* IO mapping base */
 + void __iomem*reg_base;
 +
 + /* clock management */
 + struct clk  *clk;
 +
 + /* irq */
 + spinlock_t  lock;
 + int irq;
 +};
 +
 

Re: [linux-sunxi] Re: [PATCH v4 2/5] ARM:sunxi:drivers:input Add support for A10/A20 PS2

2015-01-22 Thread Dmitry Torokhov
On Wed, Jan 21, 2015 at 04:52:04PM +0530, Vishnu Patekar wrote:
 Hello Dmitry,
 
 On Tue, Jan 20, 2015 at 6:05 AM, Dmitry Torokhov
 dmitry.torok...@gmail.com wrote:
  On Mon, Jan 19, 2015 at 11:37:38AM +0530, Vishnu Patekar wrote:
  Hello Dmitry,
 
  Thank you for review comments. Please see in-lined.
 
  On Sun, Jan 18, 2015 at 3:55 AM, Dmitry Torokhov
  dmitry.torok...@gmail.com wrote:
   Hi Vishnu,
  
   On Fri, Jan 16, 2015 at 07:33:38PM +0530, Vishnu Patekar wrote:
   Signed-off-by: VishnuPatekar vishnupatekar0...@gmail.com
   ---
drivers/input/serio/Kconfig |   11 ++
drivers/input/serio/Makefile|1 +
drivers/input/serio/sun4i-ps2.c |  330 
   +++
3 files changed, 342 insertions(+)
create mode 100644 drivers/input/serio/sun4i-ps2.c
  
   diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
   index bc2d474..964afc5 100644
   --- a/drivers/input/serio/Kconfig
   +++ b/drivers/input/serio/Kconfig
   @@ -281,4 +281,15 @@ config HYPERV_KEYBOARD
   To compile this driver as a module, choose M here: the module 
   will
   be called hyperv_keyboard.
  
   +config SERIO_SUN4I_PS2
   + tristate Allwinner A10 PS/2 controller support
   + default n
   + depends on ARCH_SUNXI || COMPILE_TEST
   + help
   +   This selects support for the PS/2 Host Controller on
   +   Allwinner A10.
   +
   +   To compile this driver as a module, choose M here: the
   +   module will be called sun4i-ps2.
   +
endif
   diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile
   index 815d874..c600089 100644
   --- a/drivers/input/serio/Makefile
   +++ b/drivers/input/serio/Makefile
   @@ -29,3 +29,4 @@ obj-$(CONFIG_SERIO_ARC_PS2) += arc_ps2.o
obj-$(CONFIG_SERIO_APBPS2)   += apbps2.o
obj-$(CONFIG_SERIO_OLPC_APSP)+= olpc_apsp.o
obj-$(CONFIG_HYPERV_KEYBOARD)+= hyperv-keyboard.o
   +obj-$(CONFIG_SERIO_SUN4I_PS2)+= sun4i-ps2.o
   diff --git a/drivers/input/serio/sun4i-ps2.c 
   b/drivers/input/serio/sun4i-ps2.c
   new file mode 100644
   index 000..06b3fef
   --- /dev/null
   +++ b/drivers/input/serio/sun4i-ps2.c
   @@ -0,0 +1,330 @@
   +/*
   + *   Driver for Allwinner A10 PS2 host controller
   + *
   + *   Author: Vishnu Patekar vishnupatekar0...@gmail.com
   + *   Aaron.maoye leafy.m...@newbietech.com
   + *
   + *
   + */
   +
   +#include linux/module.h
   +#include linux/serio.h
   +#include linux/interrupt.h
   +#include linux/errno.h
   +#include linux/slab.h
   +#include linux/list.h
   +#include linux/io.h
   +#include linux/of_address.h
   +#include linux/of_device.h
   +#include linux/of_irq.h
   +#include linux/of_platform.h
   +#include linux/clk.h
   +#include linux/delay.h
   +
   +#define DRIVER_NAME  sun4i-ps2
   +
   +/* register offset definitions */
   +#define PS2_REG_GCTL 0x00/*  PS2 Module Global Control Reg 
   */
   +#define PS2_REG_DATA 0x04/*  PS2 Module Data Reg */
   +#define PS2_REG_LCTL 0x08/*  PS2 Module Line Control Reg */
   +#define PS2_REG_LSTS 0x0C/*  PS2 Module Line Status Reg  */
   +#define PS2_REG_FCTL 0x10/*  PS2 Module FIFO Control Reg */
   +#define PS2_REG_FSTS 0x14/*  PS2 Module FIFO Status Reg  */
   +#define PS2_REG_CLKDR0x18/*  PS2 Module Clock 
   Divider Reg*/
   +
   +/*  PS2 GLOBAL CONTROL REGISTER PS2_GCTL */
   +#define PS2_GCTL_INTFLAG BIT(4)
   +#define PS2_GCTL_INTEN   BIT(3)
   +#define PS2_GCTL_RESET   BIT(2)
   +#define PS2_GCTL_MASTER  BIT(1)
   +#define PS2_GCTL_BUSEN   BIT(0)
   +
   +/* PS2 LINE CONTROL REGISTER */
   +#define PS2_LCTL_NOACK   BIT(18)
   +#define PS2_LCTL_TXDTOEN BIT(8)
   +#define PS2_LCTL_STOPERREN   BIT(3)
   +#define PS2_LCTL_ACKERRENBIT(2)
   +#define PS2_LCTL_PARERRENBIT(1)
   +#define PS2_LCTL_RXDTOEN BIT(0)
   +
   +/* PS2 LINE STATUS REGISTER */
   +#define PS2_LSTS_TXTDO   BIT(8)
   +#define PS2_LSTS_STOPERR BIT(3)
   +#define PS2_LSTS_ACKERR  BIT(2)
   +#define PS2_LSTS_PARERR  BIT(1)
   +#define PS2_LSTS_RXTDO   BIT(0)
   +
   +#define PS2_LINE_ERROR_BIT \
   + (PS2_LSTS_TXTDO | PS2_LSTS_STOPERR | PS2_LSTS_ACKERR | \
   + PS2_LSTS_PARERR | PS2_LSTS_RXTDO)
   +
   +/* PS2 FIFO CONTROL REGISTER */
   +#define PS2_FCTL_TXRST   BIT(17)
   +#define PS2_FCTL_RXRST   BIT(16)
   +#define PS2_FCTL_TXUFIEN BIT(10)
   +#define PS2_FCTL_TXOFIEN BIT(9)
   +#define PS2_FCTL_TXRDYIENBIT(8)
   +#define PS2_FCTL_RXUFIEN BIT(2)
   +#define PS2_FCTL_RXOFIEN BIT(1)
   +#define PS2_FCTL_RXRDYIENBIT(0)
   +
   +/* PS2 FIFO STATUS REGISTER */
   +#define PS2_FSTS_TXUFBIT(10)
   +#define PS2_FSTS_TXOFBIT(9)
   +#define PS2_FSTS_TXRDY

Re: [linux-sunxi] Re: [PATCH] arm: sunxi: input: RFC: Add sysfs voltage for sun4i-lradc driver

2015-01-27 Thread Dmitry Torokhov
On Tue, Jan 27, 2015 at 11:49:49AM +0200, Priit Laes wrote:
 
 On Tue, 2015-01-27 at 10:18 +0100, Maxime Ripard wrote:
  Hi,
  
  On Mon, Jan 26, 2015 at 06:58:32PM +0200, Priit Laes wrote:
   ---
  
  Like Hans was pointing out, commit log and signed-off-by please
  
.../ABI/testing/sysfs-driver-input-sun4i-lradc |  4 ++
drivers/input/keyboard/sun4i-lradc-keys.c  | 49 
   +-
2 files changed, 43 insertions(+), 10 deletions(-)
create mode 100644 Documentation/ABI/testing/sysfs-driver-input-
   sun4i-lradc
   
   diff --git a/Documentation/ABI/testing/sysfs-driver-input-sun4i-
   lradc b/Documentation/ABI/testing/sysfs-driver-input-sun4i-lradc
   new file mode 100644
   index 000..e4e6448
   --- /dev/null
   +++ b/Documentation/ABI/testing/sysfs-driver-input-sun4i-lradc
   @@ -0,0 +1,4 @@
   +What:  /sys/class/input/input(x)/device/voltage
   +Date:  February 2015
   +Contact:   Priit Laes pl...@plaes.org
   +Description:   ADC output voltage in microvolts or 0 if device is 
   not opened.
  
  Why is it returning 0 when device is not opened ? What does that 
  even mean? You can't read that file without opening it.
 
 It means that something has to open the /dev/input/inputX device which 
 sets up the ADC before the voltage can be read from the sysfs file.

I'd consider this a bug. Why someone has to use an unrelated interface for
another interface to work correctly?

 
 [...]
 
 
  
  As I told you already, if you're going to expose this an ADC in the 
  end, the proper solution is to use the IIO framework, not adding a 
  custom sysfs file.
 
 My intention was to expose just a simple debug output, so one can 
 press the buttons and read the voltages for devicetree keymap.
 
 If anyone can suggest a simpler approach than current sysfs based one, 
 I would do it. But full blown iio driver is currently out of scope. 
 Also, Carlo's (ccaione) initially submitted (?) driver for lradc 
 utilized iio subsystem.

For stuff like this debugfs (AKA dumping ground) is better suited as it does
not establish ABI.  i

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH] arm: sunxi: input: RFC: Add sysfs voltage for sun4i-lradc driver

2015-01-27 Thread Dmitry Torokhov
On Tue, Jan 27, 2015 at 10:03:35AM +0100, Hans de Goede wrote:
 Hi,
 
 On 26-01-15 23:06, Dmitry Torokhov wrote:
 On Mon, Jan 26, 2015 at 08:28:29PM +0100, Hans de Goede wrote:
 Hi,
 
 On 26-01-15 17:58, Priit Laes wrote:
 
 No commit message? Please write an informative commit msg, like why we want 
 this patch,
 I guess it is to help figuring out the voltage levels for various buttons 
 when creating
 a dts, but I would prefer to not guess, which is where a good commit 
 message would
 come in handy ...
 
 ---
   .../ABI/testing/sysfs-driver-input-sun4i-lradc |  4 ++
   drivers/input/keyboard/sun4i-lradc-keys.c  | 49 
  +-
   2 files changed, 43 insertions(+), 10 deletions(-)
   create mode 100644 
  Documentation/ABI/testing/sysfs-driver-input-sun4i-lradc
 
 diff --git a/Documentation/ABI/testing/sysfs-driver-input-sun4i-lradc 
 b/Documentation/ABI/testing/sysfs-driver-input-sun4i-lradc
 new file mode 100644
 index 000..e4e6448
 --- /dev/null
 +++ b/Documentation/ABI/testing/sysfs-driver-input-sun4i-lradc
 @@ -0,0 +1,4 @@
 +What: /sys/class/input/input(x)/device/voltage
 +Date: February 2015
 +Contact:  Priit Laes pl...@plaes.org
 +Description:  ADC output voltage in microvolts or 0 if device is not 
 opened.
 diff --git a/drivers/input/keyboard/sun4i-lradc-keys.c 
 b/drivers/input/keyboard/sun4i-lradc-keys.c
 index cc8f7dd..c0ab8ec 100644
 --- a/drivers/input/keyboard/sun4i-lradc-keys.c
 +++ b/drivers/input/keyboard/sun4i-lradc-keys.c
 @@ -79,10 +79,27 @@ struct sun4i_lradc_data {
u32 vref;
   };
 
 +static u32 sun4i_lradc_read_voltage(struct sun4i_lradc_data *lradc)
 +{
 +  u32 val = readl(lradc-base + LRADC_DATA0)  0x3f;
 +  return val * lradc-vref / 63;
 +};
 +
 +static ssize_t
 +sun4i_lradc_dev_voltage_show(struct device *dev,
 +  struct device_attribute *attr, char *buf)
 +{
 +  struct sun4i_lradc_data *lradc = dev_get_drvdata(dev);
 +
 +  return sprintf(buf, %u\n, sun4i_lradc_read_voltage(lradc));
 +}
 +
 +static const DEVICE_ATTR(voltage, S_IRUGO, sun4i_lradc_dev_voltage_show, 
 NULL);
 +
   static irqreturn_t sun4i_lradc_irq(int irq, void *dev_id)
   {
struct sun4i_lradc_data *lradc = dev_id;
 -  u32 i, ints, val, voltage, diff, keycode = 0, closest = 0x;
 +  u32 i, ints, voltage, diff, keycode = 0, closest = 0x;
 
ints  = readl(lradc-base + LRADC_INTS);
 
 @@ -97,8 +114,7 @@ static irqreturn_t sun4i_lradc_irq(int irq, void 
 *dev_id)
}
 
if ((ints  CHAN0_KEYDOWN_IRQ)  lradc-chan0_keycode == 0) {
 -  val = readl(lradc-base + LRADC_DATA0)  0x3f;
 -  voltage = val * lradc-vref / 63;
 +  voltage = sun4i_lradc_read_voltage(lradc);
 
for (i = 0; i  lradc-chan0_map_count; i++) {
diff = abs(lradc-chan0_map[i].voltage - voltage);
 @@ -156,7 +172,7 @@ static void sun4i_lradc_close(struct input_dev *dev)
   }
 
   static int sun4i_lradc_load_dt_keymap(struct device *dev,
 -struct sun4i_lradc_data *lradc)
 +  struct sun4i_lradc_data *lradc)
   {
struct device_node *np, *pp;
int i;
 
 Why this identation change ?
 
 @@ -168,8 +184,8 @@ static int sun4i_lradc_load_dt_keymap(struct device 
 *dev,
 
lradc-chan0_map_count = of_get_child_count(np);
if (lradc-chan0_map_count == 0) {
 -  dev_err(dev, keymap is missing in device tree\n);
 -  return -EINVAL;
 +  dev_info(dev, keymap is missing in device tree\n);
 +  return 0;
}
 
lradc-chan0_map = devm_kmalloc_array(dev, lradc-chan0_map_count,
 
 I assume this is so that people can still use the sysfs node, to create a 
 dts, right
 not sure I like this, might be better to document to simple create a dts 
 with
 a single button mapping for 200 mV (most board use 200 mV steps between the 
 buttons).
 
 @@ -185,19 +201,19 @@ static int sun4i_lradc_load_dt_keymap(struct device 
 *dev,
 
error = of_property_read_u32(pp, channel, channel);
if (error || channel != 0) {
 -  dev_err(dev, %s: Inval channel prop\n, pp-name);
 +  dev_err(dev, %s: Invalid 'channel' property\n, 
 pp-name);
return -EINVAL;
}
 
error = of_property_read_u32(pp, voltage, map-voltage);
if (error) {
 -  dev_err(dev, %s: Inval voltage prop\n, pp-name);
 +  dev_err(dev, %s: Invalid 'voltage' property\n, 
 pp-name);
return -EINVAL;
}
 
error = of_property_read_u32(pp, linux,code, map-keycode);
if (error) {
 -  dev_err(dev, %s: Inval linux,code prop\n, pp-name);
 +  dev_err(dev, %s: Invalid 'linux,code' property\n, 
 pp-name);
return -EINVAL;
}
 
 
 This hunk / 3 changes belong in a separate patch. Also please run 
 checkpatch, I think
 you're running over 80

[linux-sunxi] Re: [PATCH v5 2/4] ARM:sunxi:drivers:input Add support for A10/A20 PS2

2015-01-27 Thread Dmitry Torokhov
Hi Vishnu,

On Sun, Jan 25, 2015 at 07:10:07PM +0530, Vishnu Patekar wrote:
 Signed-off-by: VishnuPatekar vishnupatekar0...@gmail.com
 ---
  drivers/input/serio/Kconfig |   11 ++
  drivers/input/serio/Makefile|1 +
  drivers/input/serio/sun4i-ps2.c |  347 
 +++
  3 files changed, 359 insertions(+)
  create mode 100644 drivers/input/serio/sun4i-ps2.c
 
 diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
 index bc2d474..964afc5 100644
 --- a/drivers/input/serio/Kconfig
 +++ b/drivers/input/serio/Kconfig
 @@ -281,4 +281,15 @@ config HYPERV_KEYBOARD
 To compile this driver as a module, choose M here: the module will
 be called hyperv_keyboard.
  
 +config SERIO_SUN4I_PS2
 + tristate Allwinner A10 PS/2 controller support
 + default n
 + depends on ARCH_SUNXI || COMPILE_TEST
 + help
 +   This selects support for the PS/2 Host Controller on
 +   Allwinner A10.
 +
 +   To compile this driver as a module, choose M here: the
 +   module will be called sun4i-ps2.
 +
  endif
 diff --git a/drivers/input/serio/Makefile b/drivers/input/serio/Makefile
 index 815d874..c600089 100644
 --- a/drivers/input/serio/Makefile
 +++ b/drivers/input/serio/Makefile
 @@ -29,3 +29,4 @@ obj-$(CONFIG_SERIO_ARC_PS2) += arc_ps2.o
  obj-$(CONFIG_SERIO_APBPS2)   += apbps2.o
  obj-$(CONFIG_SERIO_OLPC_APSP)+= olpc_apsp.o
  obj-$(CONFIG_HYPERV_KEYBOARD)+= hyperv-keyboard.o
 +obj-$(CONFIG_SERIO_SUN4I_PS2)+= sun4i-ps2.o
 diff --git a/drivers/input/serio/sun4i-ps2.c b/drivers/input/serio/sun4i-ps2.c
 new file mode 100644
 index 000..d3cf6bc
 --- /dev/null
 +++ b/drivers/input/serio/sun4i-ps2.c
 @@ -0,0 +1,347 @@
 +/*
 + *   Driver for Allwinner A10 PS2 host controller
 + *
 + *   Author: Vishnu Patekar vishnupatekar0...@gmail.com
 + *   Aaron.maoye leafy.m...@newbietech.com
 + *
 + *
 + */
 +
 +#include linux/module.h
 +#include linux/serio.h
 +#include linux/interrupt.h
 +#include linux/errno.h
 +#include linux/slab.h
 +#include linux/list.h
 +#include linux/io.h
 +#include linux/of_address.h
 +#include linux/of_device.h
 +#include linux/of_irq.h
 +#include linux/of_platform.h

You do not really need all these of_* includes. Neither you need list.h.

 +#include linux/clk.h
 +#include linux/delay.h
 +
 +#define DRIVER_NAME  sun4i-ps2
 +
 +/* register offset definitions */
 +#define PS2_REG_GCTL 0x00/*  PS2 Module Global Control Reg */
 +#define PS2_REG_DATA 0x04/*  PS2 Module Data Reg */
 +#define PS2_REG_LCTL 0x08/*  PS2 Module Line Control Reg */
 +#define PS2_REG_LSTS 0x0C/*  PS2 Module Line Status Reg  */
 +#define PS2_REG_FCTL 0x10/*  PS2 Module FIFO Control Reg */
 +#define PS2_REG_FSTS 0x14/*  PS2 Module FIFO Status Reg  */
 +#define PS2_REG_CLKDR0x18/*  PS2 Module Clock Divider 
 Reg*/
 +
 +/*  PS2 GLOBAL CONTROL REGISTER PS2_GCTL */
 +#define PS2_GCTL_INTFLAG BIT(4)
 +#define PS2_GCTL_INTEN   BIT(3)
 +#define PS2_GCTL_RESET   BIT(2)
 +#define PS2_GCTL_MASTER  BIT(1)
 +#define PS2_GCTL_BUSEN   BIT(0)
 +
 +/* PS2 LINE CONTROL REGISTER */
 +#define PS2_LCTL_NOACK   BIT(18)
 +#define PS2_LCTL_TXDTOEN BIT(8)
 +#define PS2_LCTL_STOPERREN   BIT(3)
 +#define PS2_LCTL_ACKERRENBIT(2)
 +#define PS2_LCTL_PARERRENBIT(1)
 +#define PS2_LCTL_RXDTOEN BIT(0)
 +
 +/* PS2 LINE STATUS REGISTER */
 +#define PS2_LSTS_TXTDO   BIT(8)
 +#define PS2_LSTS_STOPERR BIT(3)
 +#define PS2_LSTS_ACKERR  BIT(2)
 +#define PS2_LSTS_PARERR  BIT(1)
 +#define PS2_LSTS_RXTDO   BIT(0)
 +
 +#define PS2_LINE_ERROR_BIT \
 + (PS2_LSTS_TXTDO | PS2_LSTS_STOPERR | PS2_LSTS_ACKERR | \
 + PS2_LSTS_PARERR | PS2_LSTS_RXTDO)
 +
 +/* PS2 FIFO CONTROL REGISTER */
 +#define PS2_FCTL_TXRST   BIT(17)
 +#define PS2_FCTL_RXRST   BIT(16)
 +#define PS2_FCTL_TXUFIEN BIT(10)
 +#define PS2_FCTL_TXOFIEN BIT(9)
 +#define PS2_FCTL_TXRDYIENBIT(8)
 +#define PS2_FCTL_RXUFIEN BIT(2)
 +#define PS2_FCTL_RXOFIEN BIT(1)
 +#define PS2_FCTL_RXRDYIENBIT(0)
 +
 +/* PS2 FIFO STATUS REGISTER */
 +#define PS2_FSTS_TXUFBIT(10)
 +#define PS2_FSTS_TXOFBIT(9)
 +#define PS2_FSTS_TXRDY   BIT(8)
 +#define PS2_FSTS_RXUFBIT(2)
 +#define PS2_FSTS_RXOFBIT(1)
 +#define PS2_FSTS_RXRDY   BIT(0)
 +
 +#define PS2_FIFO_ERROR_BIT \
 + (PS2_FSTS_TXUF | PS2_FSTS_TXOF | PS2_FSTS_RXUF | PS2_FSTS_RXOF)
 +
 +#define PS2_SAMPLE_CLK   100
 +#define PS2_SCLK 125000
 +
 +struct sun4i_ps2data {
 + struct serio *serio;
 + struct device *dev;
 +
 + /* IO mapping base */
 + void __iomem*reg_base;
 +
 + /* clock management */
 + struct clk  *clk;
 +
 + /* irq */
 

Re: [linux-sunxi] Re: [PATCH] arm: sunxi: input: RFC: Add sysfs voltage for sun4i-lradc driver

2015-01-27 Thread Dmitry Torokhov
On Tue, Jan 27, 2015 at 08:44:47PM +0100, Maxime Ripard wrote:
 On Tue, Jan 27, 2015 at 11:52:34AM +0100, Hans de Goede wrote:
  Hi,
  
  On 27-01-15 10:49, Priit Laes wrote:
  
  On Tue, 2015-01-27 at 10:18 +0100, Maxime Ripard wrote:
  Hi,
  
  On Mon, Jan 26, 2015 at 06:58:32PM +0200, Priit Laes wrote:
  ---
  
  Like Hans was pointing out, commit log and signed-off-by please
  
.../ABI/testing/sysfs-driver-input-sun4i-lradc |  4 ++
drivers/input/keyboard/sun4i-lradc-keys.c  | 49
  +-
2 files changed, 43 insertions(+), 10 deletions(-)
create mode 100644 Documentation/ABI/testing/sysfs-driver-input-
  sun4i-lradc
  
  diff --git a/Documentation/ABI/testing/sysfs-driver-input-sun4i-
  lradc b/Documentation/ABI/testing/sysfs-driver-input-sun4i-lradc
  new file mode 100644
  index 000..e4e6448
  --- /dev/null
  +++ b/Documentation/ABI/testing/sysfs-driver-input-sun4i-lradc
  @@ -0,0 +1,4 @@
  +What:  /sys/class/input/input(x)/device/voltage
  +Date:  February 2015
  +Contact:   Priit Laes pl...@plaes.org
  +Description:   ADC output voltage in microvolts or 0 if device is
  not opened.
  
  Why is it returning 0 when device is not opened ? What does that
  even mean? You can't read that file without opening it.
  
  It means that something has to open the /dev/input/inputX device which
  sets up the ADC before the voltage can be read from the sysfs file.
  
  [...]
  
  
  
  As I told you already, if you're going to expose this an ADC in the
  end, the proper solution is to use the IIO framework, not adding a
  custom sysfs file.
  
  My intention was to expose just a simple debug output, so one can
  press the buttons and read the voltages for devicetree keymap.
  
  If anyone can suggest a simpler approach than current sysfs based one,
  I would do it.
  
  The android driver always uses 0.2V / 200mV steps, so what I do is
  simply create a mapping with 200mV mapped to KEY_VOLUMEUP, 400mV mapped
  to KEY_VOLUMEDOWN, etc. following the hardcoded android driver mapping:
  
  https://github.com/linux-sunxi/linux-sunxi/blob/sunxi-3.4/drivers/input/keyboard/sun4i-keyboard.c#L136
  
  Usually this will be correct in one go, after testing one can shuffle
  key codes as needed (usually not needed) and/or remove unused entries.
  
  With that said I do think that a sysfs file to see the actual voltages,
  or a kernel parameter to printk them on keypress interrupt would be useful.
  
  I guess the printk option would be better as it would show the actual
  keypress value read, not some semi-random sample.
 
 That wouldn't require that much code actually. Either using dev_dbg,
 or debugfs like Dmitry was suggesting would be two nice solutions I
 guess.

Given the stated purpose I'd say dev_dbg() and call it a day.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v3] input: Add support for ChipOne icn8318 based touchscreens

2015-03-22 Thread Dmitry Torokhov
On Sun, Mar 22, 2015 at 12:00:55PM +0100, Hans de Goede wrote:
 Hi,
 
 On 22-03-15 05:03, Dmitry Torokhov wrote:
 Hi Hans,
 
 On Tue, Mar 10, 2015 at 06:05:33PM +0100, Hans de Goede wrote:
 +   error = devm_request_threaded_irq(dev, client-irq, NULL, icn8318_irq,
 + IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
 
 Shouldn't we let DT data tell us what trigger to use? I.e. just leave
 IRQF_ONESHOT here?
 
 That is an interesting question, that new data is available is signalled by
 the irq pin of the chip going low is a property of the chip, not the board
 layout, so I believe it is best to leave this as is.

My concern is that even if pin behavior is property of chip maybe on
some boards we want to use level-triggered interrupts instead of edge?
And if we indeed want to hard-code the trigger then shouldn't the
binding document use onecell mapping (so that users do not attempt to
configure triggers from DT)?

 
 Also note that if we want to get this from devicetree, that simply leaving 
 out the
 flag is not enough, we must specifically get the data from devicetree and pass
 it into request_irq AFAICT. So the above would change to:
 
   irqflags = irqd_get_trigger_type(irq_get_irq_data(client-irq)) | 
 IRQF_ONESHOT,
   error = devm_request_threaded_irq(dev, client-irq, NULL, icn8318_irq, 
 irqflags,

No, of_irq_get() that i2c core calls before probing driver should
already set the trigger type for us. There is no need for the individual
drivers to do that.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v3] input: Add support for ChipOne icn8318 based touchscreens

2015-03-21 Thread Dmitry Torokhov
Hi Hans,

On Tue, Mar 10, 2015 at 06:05:33PM +0100, Hans de Goede wrote:
 + error = devm_request_threaded_irq(dev, client-irq, NULL, icn8318_irq,
 +   IRQF_TRIGGER_FALLING | IRQF_ONESHOT,

Shouldn't we let DT data tell us what trigger to use? I.e. just leave
IRQF_ONESHOT here?

No need to resubmit, just let me know if you agree/disagree...

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 0/3] touchscreen: sun4i-ts: A10 (sun4i) has a different temperature curve

2015-03-08 Thread Dmitry Torokhov
Hi Hans,

On Sun, Mar 08, 2015 at 09:53:39PM +0100, Hans de Goede wrote:
 Hi Dmitry, Maxime, et al.
 
 Here is a patch-set for the sun4i-ts driver temperature sensor support,
 it consists of 2 fixes:
 
 1) Use a better temperature curve for A10 SoCs to avoid reporting a way to
 high temperature.
 
 2) Start with reporting an estimated temperature of 40 degrees rather then
 returning -EAGAIN until we get the first temperature ready interrupt to avoid
 the kernel tempzone core logging errors because of our -EAGAIN return.

No, I think we better teach thermal core not to complain about
-EAGAINs.

 
 Dmitry can you please queue up the 2 sun4i-ts patches for 4.1, and Maxime,
 can you please queue up the matching dts change ?
 
 Thanks  Regards,
 
 Hans

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 1/3] touchscreen: sun4i-ts: A10 (sun4i) has a different temperature curve

2015-03-08 Thread Dmitry Torokhov
On Sun, Mar 08, 2015 at 09:53:40PM +0100, Hans de Goede wrote:
 Testing has revealed that the temperature in the rtp controller of the A10
 (sun4i) SoC has a different curve then on the A13 (sun5i) and later models.
 
 Add a new sun5i-a13-ts compatible to differentiate the newer models and
 set the curve based on the compatible string.
 
 The new curve is still not ideal on all A10-s, that seems to have to
 do with there being a large spread between different A10-s out there,
 the new curve us based on callibration results on 4 completely different
 models:
 raw min raw max temp min temp max stepsize offset
 Tong Zhang's hackberry2402268045.0 80.00.125   -255.3
 Hansg's Cubieboard2207230036.0 45.00.096   -175.8
 Olliver's lime 1 (*): 2258253748.3 87.10.139   -265.7
 Olliver's lime 2 (*): 248646.7 91.70.170   -331.0
 *) from: http://linux-sunxi.org/Temperature_Calibration
 
 Average all 4: 0.133   -257.0
 Average without outliers (middle 2):   0.132   -261.0
 
 Since it is better to slightly overreport the temperature this patch uses
 the average of all 4 as curve.
 
 This fixes the temperature reported on the A10 being much higher then
 expected.
 
 Cc: Tong Zhang lovewill...@gmail.com
 Cc: Olliver Schinagl o.schin...@ultimaker.com
 Reported-by: Tong Zhang lovewill...@gmail.com
 Signed-off-by: Hans de Goede hdego...@redhat.com


Applied, thank you.

 ---
  .../devicetree/bindings/input/touchscreen/sun4i.txt  |  3 ++-
  drivers/input/touchscreen/sun4i-ts.c | 16 
 +---
  2 files changed, 15 insertions(+), 4 deletions(-)
 
 diff --git a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt 
 b/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
 index 42d..d59d252 100644
 --- a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
 +++ b/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
 @@ -2,7 +2,8 @@ sun4i resistive touchscreen controller
  --
  
  Required properties:
 - - compatible: allwinner,sun4i-a10-ts or allwinner,sun6i-a31-ts
 + - compatible: allwinner,sun4i-a10-ts, allwinner,sun5i-a13-ts or
 +   allwinner,sun6i-a31-ts
   - reg: mmio address range of the chip
   - interrupts: interrupt to which the chip is connected
   - #thermal-sensor-cells: shall be 0
 diff --git a/drivers/input/touchscreen/sun4i-ts.c 
 b/drivers/input/touchscreen/sun4i-ts.c
 index b93a28b..66ccd5a 100644
 --- a/drivers/input/touchscreen/sun4i-ts.c
 +++ b/drivers/input/touchscreen/sun4i-ts.c
 @@ -258,6 +258,15 @@ static int sun4i_ts_probe(struct platform_device *pdev)
   /* Allwinner SDK has temperature = -271 + (value / 6) (C) */
   ts-temp_offset = 1626;
   ts-temp_step = 167;
 + } else if (of_device_is_compatible(np, allwinner,sun4i-a10-ts)) {
 + /*
 +  * The A10 temperature sensor has quite a wide spread, these
 +  * parameters are based on the averaging of the calibration
 +  * results of 4 completely different boards, with a spread of
 +  * temp_step from 96 - 170 and temp_offset from 1758 - 3310.
 +  */
 + ts-temp_offset = 2570;
 + ts-temp_step = 133;
   } else {
   /*
* The user manuals do not contain the formula for calculating
 @@ -330,10 +339,10 @@ static int sun4i_ts_probe(struct platform_device *pdev)
* finally enable tp mode.
*/
   reg = STYLUS_UP_DEBOUN(5) | STYLUS_UP_DEBOUN_EN(1);
 - if (of_device_is_compatible(np, allwinner,sun4i-a10-ts))
 - reg |= TP_MODE_EN(1);
 - else
 + if (of_device_is_compatible(np, allwinner,sun6i-a31-ts))
   reg |= SUN6I_TP_MODE_EN(1);
 + else
 + reg |= TP_MODE_EN(1);
   writel(reg, ts-base + TP_CTRL1);
  
   /*
 @@ -383,6 +392,7 @@ static int sun4i_ts_remove(struct platform_device *pdev)
  
  static const struct of_device_id sun4i_ts_of_match[] = {
   { .compatible = allwinner,sun4i-a10-ts, },
 + { .compatible = allwinner,sun5i-a13-ts, },
   { .compatible = allwinner,sun6i-a31-ts, },
   { /* sentinel */ }
  };
 -- 
 2.3.1
 

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH] touchscreen: sun4i-ts: Really fix A10 temperature reporting

2015-03-12 Thread Dmitry Torokhov
On Mon, Mar 09, 2015 at 10:37:50AM +0100, Hans de Goede wrote:
 The commit titled:
 touchscreen: sun4i-ts: A10 (sun4i) has a different temperature curve
 contains a math error, the offset it uses is in degrees, but the actual code
 applies the offset before multiplying by stepsize :|
 
 Given that this is rather backwards (every math course ever thought applies
 the multiplication before the offset for linear functions), this commit
 fixes things by changing the code applying the offset to do the logical
 thing, adjusting the offset for the other models accordingly.
 
 This has been tested on an A10, A13, A20 and A31 to make sure everything 
 really
 is correct now.
 
 Signed-off-by: Hans de Goede hdego...@redhat.com
 ---
 Note if possible this commit should be squashed into the original
 touchscreen: sun4i-ts: A10 (sun4i) has a different temperature curve
 commit as a fixup.

It's a bit too late, I do not like rewinding my 'next' branch unless it
is a compile error caught recently. So applied as a separate commit.

Thanks.

 ---
  drivers/input/touchscreen/sun4i-ts.c | 14 +++---
  1 file changed, 7 insertions(+), 7 deletions(-)
 
 diff --git a/drivers/input/touchscreen/sun4i-ts.c 
 b/drivers/input/touchscreen/sun4i-ts.c
 index 66ccd5a..178d2ef 100644
 --- a/drivers/input/touchscreen/sun4i-ts.c
 +++ b/drivers/input/touchscreen/sun4i-ts.c
 @@ -193,7 +193,7 @@ static int sun4i_get_temp(const struct sun4i_ts_data *ts, 
 long *temp)
   if (ts-temp_data == -1)
   return -EAGAIN;
  
 - *temp = (ts-temp_data - ts-temp_offset) * ts-temp_step;
 + *temp = ts-temp_data * ts-temp_step - ts-temp_offset;
  
   return 0;
  }
 @@ -255,17 +255,17 @@ static int sun4i_ts_probe(struct platform_device *pdev)
   ts-ignore_fifo_data = true;
   ts-temp_data = -1;
   if (of_device_is_compatible(np, allwinner,sun6i-a31-ts)) {
 - /* Allwinner SDK has temperature = -271 + (value / 6) (C) */
 - ts-temp_offset = 1626;
 + /* Allwinner SDK has temperature (C) = (value / 6) - 271 */
 + ts-temp_offset = 271000;
   ts-temp_step = 167;
   } else if (of_device_is_compatible(np, allwinner,sun4i-a10-ts)) {
   /*
* The A10 temperature sensor has quite a wide spread, these
* parameters are based on the averaging of the calibration
* results of 4 completely different boards, with a spread of
 -  * temp_step from 96 - 170 and temp_offset from 1758 - 3310.
 +  * temp_step from 0.096 - 0.170 and temp_offset from 176 - 331.
*/
 - ts-temp_offset = 2570;
 + ts-temp_offset = 257000;
   ts-temp_step = 133;
   } else {
   /*
 @@ -273,13 +273,13 @@ static int sun4i_ts_probe(struct platform_device *pdev)
* the temperature. The formula used here is from the AXP209,
* which is designed by X-Powers, an affiliate of Allwinner:
*
 -  * temperature = -144.7 + (value * 0.1)
 +  * temperature (C) = (value * 0.1) - 144.7
*
* Allwinner does not have any documentation whatsoever for
* this hardware. Moreover, it is claimed that the sensor
* is inaccurate and cannot work properly.
*/
 - ts-temp_offset = 1447;
 + ts-temp_offset = 144700;
   ts-temp_step = 100;
   }
  
 -- 
 2.3.1
 

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v3] input: Add support for ChipOne icn8318 based touchscreens

2015-03-24 Thread Dmitry Torokhov
On Tue, Mar 24, 2015 at 06:45:03PM +0100, Hans de Goede wrote:
 Hi,
 
 On 03/22/2015 11:42 PM, Dmitry Torokhov wrote:
 On Sun, Mar 22, 2015 at 12:00:55PM +0100, Hans de Goede wrote:
 Hi,
 
 On 22-03-15 05:03, Dmitry Torokhov wrote:
 Hi Hans,
 
 On Tue, Mar 10, 2015 at 06:05:33PM +0100, Hans de Goede wrote:
 + error = devm_request_threaded_irq(dev, client-irq, NULL, icn8318_irq,
 +   IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
 
 Shouldn't we let DT data tell us what trigger to use? I.e. just leave
 IRQF_ONESHOT here?
 
 That is an interesting question, that new data is available is signalled by
 the irq pin of the chip going low is a property of the chip, not the board
 layout, so I believe it is best to leave this as is.
 
 My concern is that even if pin behavior is property of chip maybe on
 some boards we want to use level-triggered interrupts instead of edge?
 And if we indeed want to hard-code the trigger then shouldn't the
 binding document use onecell mapping (so that users do not attempt to
 configure triggers from DT)?
 
 The number of irq cells is specified by the interrupt controller driver
 rather then by the device binding.
 
 
 
 Also note that if we want to get this from devicetree, that simply leaving 
 out the
 flag is not enough, we must specifically get the data from devicetree and 
 pass
 it into request_irq AFAICT. So the above would change to:
 
 irqflags = irqd_get_trigger_type(irq_get_irq_data(client-irq)) | 
  IRQF_ONESHOT,
 error = devm_request_threaded_irq(dev, client-irq, NULL, icn8318_irq, 
  irqflags,
 
 No, of_irq_get() that i2c core calls before probing driver should
 already set the trigger type for us. There is no need for the individual
 drivers to do that.
 
 Ah I see, ok I've just tested removing the IRQF_TRIGGER_FALLING flag and 
 indeed
 things still work fine, so feel free to merge this patch with that flagged 
 dropped.

OK, thanks, queued for 4.1.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH] Input: sun4i-ts - allow to adjust some settings via device-tree properties.

2015-03-23 Thread Dmitry Torokhov
On Wed, Mar 18, 2015 at 12:01:58PM +0100, Hans de Goede wrote:
 Hi,
 
 On 18-03-15 11:37, Maxime Ripard wrote:
 On Thu, Mar 12, 2015 at 04:45:50PM +0100, Jens Thiele wrote:
 This commit introduces two new optional device-tree properties:
 tp-sensitive-adjust: adjust sensitivity of pen down detection
 filter-type: select median and averaging filter
 
 The previous fixed defaults, didn't work well for the Olimex
 A13-LCD10TS (I have).
 
 Signed-off-by: Jens Thiele ka...@karme.de
 ---
   .../devicetree/bindings/input/touchscreen/sun4i.txt |   19 
  +--
   drivers/input/touchscreen/sun4i-ts.c|   17 
  +
   2 files changed, 30 insertions(+), 6 deletions(-)
 
 diff --git a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt 
 b/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
 index 42d..c93edfa 100644
 --- a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
 +++ b/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
 @@ -8,8 +8,20 @@ Required properties:
- #thermal-sensor-cells: shall be 0
 
   Optional properties:
 - - allwinner,ts-attached: boolean indicating that an actual touchscreen is
 - attached to the controller
 + - allwinner,ts-attached: boolean indicating that an actual touchscreen
 +  is attached to the controller
 + - allwinner,tp-sensitive-adjust : integer (4 bits)
 +  adjust sensitivity of pen down detection
 +  between 0 (least sensitive) and 15
 +  (defaults to 15)
 + - allwinner,filter-type: integer (2 bits)
 +  select median and averaging filter
 +  samples used for median / averaging filter
 +  0: 4/2
 +  1: 5/3
 +  2: 8/4
 +  3: 16/8
 +  (defaults to 1)
 
 You shouldn't rely on any bits length in your binding.
 
 And this looks really more of a configuration option, and would be
 better exposed through sysfs.
 
 Erm, no, this is to adjust for properties of the touchscreen, so this is
 hardware configuration, and as such definitely belongs in the dts.

Applied, thank you.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH] input: axp20x-pek: Fix reporting button state as inverted

2015-06-22 Thread Dmitry Torokhov
On Sun, Jun 14, 2015 at 12:42:21PM +0200, Hans de Goede wrote:
 Currently we are reporting the button state as inverted on all boards with
 an axp209 pmic, tested on a ba10-tvbox, bananapi, bananapro, cubietruck and
 utoo-p66 tablet.
 
 The axp209 datasheet clearly states that the power button must be connected
 between the PWRON key and ground. Which means that on a press we will get
 a falling edge (dbf) irq not a rising one, and likewise on release we will
 get a rising edge (dbr) irq, not a falling one.
 
 This commit swaps the check for the 2 irqs fixing the inverted reporting of
 the power button state.
 
 Signed-off-by: Hans de Goede hdego...@redhat.com

Carlo, Chen-Yu, could you please give this patch a spin and let us know
if it works on your boards?

Thanks!

 ---
  drivers/input/misc/axp20x-pek.c | 8 ++--
  1 file changed, 6 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
 index f1c8447..10e140a 100644
 --- a/drivers/input/misc/axp20x-pek.c
 +++ b/drivers/input/misc/axp20x-pek.c
 @@ -167,9 +167,13 @@ static irqreturn_t axp20x_pek_irq(int irq, void *pwr)
   struct input_dev *idev = pwr;
   struct axp20x_pek *axp20x_pek = input_get_drvdata(idev);
  
 - if (irq == axp20x_pek-irq_dbr)
 + /*
 +  * The power-button is connected to ground so a falling edge (dbf)
 +  * means it is pressed.
 +  */
 + if (irq == axp20x_pek-irq_dbf)
   input_report_key(idev, KEY_POWER, true);
 - else if (irq == axp20x_pek-irq_dbf)
 + else if (irq == axp20x_pek-irq_dbr)
   input_report_key(idev, KEY_POWER, false);
  
   input_sync(idev);
 -- 
 2.4.3
 

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH] touchscreen: sun4i-ts: Really fix A10 temperature reporting

2015-06-23 Thread Dmitry Torokhov
On Tue, Jun 23, 2015 at 09:46:20PM +0200, Hans de Goede wrote:
 Hi,
 
 On 06/23/2015 05:06 PM, m.silentcr...@gmail.com wrote:
 Hi Hans,
 
 is it possible that this patch (and the parent commit Input: sun4i-ts - 
 allow controlling filter and sensitivity via DT) has quite an adversial 
 effect on other boards than the ones tested?
 
 On my Lemaker Bananapi the temperature is now being reported as somwhere 
 between -15°C to -10°C with the latest Kernel 4.1.0. These negative values 
 are obviously way off. On Kernel 4.0.5 the temperature reading was usually 
 around 40°C. While that might not have been accurate either, it was at least 
 plausible.
 
 The temperature curve for the A20 SoC was not changed, if it did change then
 you're using an old dtb file with a new kernel, you must always update your
 dtb file together with the kernel.

Umm, we should keep compatibility with old DTS...

 
 
 
 
 Given that there is no Documentation and things seem quite board-specific, I 
 really don't know how this could be improved, so I can merely report my 
 observation.
 
 Kind regards,
 
 Timo
 
 
 Am Montag, 9. März 2015 10:38:02 UTC+1 schrieb Hans de Goede:
 The commit titled:
 touchscreen: sun4i-ts: A10 (sun4i) has a different temperature curve
 contains a math error, the offset it uses is in degrees, but the actual code
 applies the offset before multiplying by stepsize :|
 
 Given that this is rather backwards (every math course ever thought applies
 the multiplication before the offset for linear functions), this commit
 fixes things by changing the code applying the offset to do the logical
 thing, adjusting the offset for the other models accordingly.
 
 This has been tested on an A10, A13, A20 and A31 to make sure everything 
 really
 is correct now.
 
 Signed-off-by: Hans de Goede hdego...@redhat.com
 ---
 Note if possible this commit should be squashed into the original
 touchscreen: sun4i-ts: A10 (sun4i) has a different temperature curve
 commit as a fixup.
 ---
   drivers/input/touchscreen/sun4i-ts.c | 14 +++---
   1 file changed, 7 insertions(+), 7 deletions(-)
 
 diff --git a/drivers/input/touchscreen/sun4i-ts.c 
 b/drivers/input/touchscreen/sun4i-ts.c
 index 66ccd5a..178d2ef 100644
 --- a/drivers/input/touchscreen/sun4i-ts.c
 +++ b/drivers/input/touchscreen/sun4i-ts.c
 @@ -193,7 +193,7 @@ static int sun4i_get_temp(const struct sun4i_ts_data 
 *ts, long *temp)
 if (ts-temp_data == -1)
 return -EAGAIN;
 
 -   *temp = (ts-temp_data - ts-temp_offset) * ts-temp_step;
 +   *temp = ts-temp_data * ts-temp_step - ts-temp_offset;
 
 return 0;
   }
 @@ -255,17 +255,17 @@ static int sun4i_ts_probe(struct platform_device 
 *pdev)
 ts-ignore_fifo_data = true;
 ts-temp_data = -1;
 if (of_device_is_compatible(np, allwinner,sun6i-a31-ts)) {
 -   /* Allwinner SDK has temperature = -271 + (value / 6) (C) */
 -   ts-temp_offset = 1626;
 +   /* Allwinner SDK has temperature (C) = (value / 6) - 271 */
 +   ts-temp_offset = 271000;
 ts-temp_step = 167;
 } else if (of_device_is_compatible(np, allwinner,sun4i-a10-ts)) {
 /*
  * The A10 temperature sensor has quite a wide spread, these
  * parameters are based on the averaging of the calibration
  * results of 4 completely different boards, with a spread of
 -* temp_step from 96 - 170 and temp_offset from 1758 - 3310.
 +* temp_step from 0.096 - 0.170 and temp_offset from 176 - 331.
  */
 -   ts-temp_offset = 2570;
 +   ts-temp_offset = 257000;
 ts-temp_step = 133;
 } else {
 /*
 @@ -273,13 +273,13 @@ static int sun4i_ts_probe(struct platform_device 
 *pdev)
  * the temperature. The formula used here is from the AXP209,
  * which is designed by X-Powers, an affiliate of Allwinner:
  *
 -* temperature = -144.7 + (value * 0.1)
 +* temperature (C) = (value * 0.1) - 144.7
  *
  * Allwinner does not have any documentation whatsoever for
  * this hardware. Moreover, it is claimed that the sensor
  * is inaccurate and cannot work properly.
  */
 -   ts-temp_offset = 1447;
 +   ts-temp_offset = 144700;
 ts-temp_step = 100;
 }
 
 --
 2.3.1
 
 
 Regards,
 
 Hans

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH] input: axp20x-pek: Fix reporting button state as inverted

2015-06-24 Thread Dmitry Torokhov
On Wed, Jun 24, 2015 at 11:19:39AM +0200, Carlo Caione wrote:
 On Wed, Jun 24, 2015 at 3:42 AM, Chen-Yu Tsai w...@csie.org wrote:
  On Tue, Jun 23, 2015 at 5:30 AM, Dmitry Torokhov
  dmitry.torok...@gmail.com wrote:
  On Sun, Jun 14, 2015 at 12:42:21PM +0200, Hans de Goede wrote:
  Currently we are reporting the button state as inverted on all boards with
  an axp209 pmic, tested on a ba10-tvbox, bananapi, bananapro, cubietruck 
  and
  utoo-p66 tablet.
 
  The axp209 datasheet clearly states that the power button must be 
  connected
  between the PWRON key and ground. Which means that on a press we will get
  a falling edge (dbf) irq not a rising one, and likewise on release we will
  get a rising edge (dbr) irq, not a falling one.
 
  This commit swaps the check for the 2 irqs fixing the inverted reporting 
  of
  the power button state.
 
  Signed-off-by: Hans de Goede hdego...@redhat.com
 
  Carlo, Chen-Yu, could you please give this patch a spin and let us know
  if it works on your boards?
 
  I've not actually tested this patch on my boards, but I can confirm that
  the original code had the state inverted, by checking /proc/interrupts
  counters, before and after releasing the power button.
 
  Acked-by: Chen-Yu Tsai w...@csie.org
 
 Same here (I don't have the board anymore)
 
 Acked-by: Carlo Caione ca...@caione.org

Applied, thank you.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] [PATCH] Input: axp20x-pek: Add module alias

2015-08-03 Thread Dmitry Torokhov
On Mon, Aug 03, 2015 at 09:56:09AM +0200, Carlo Caione wrote:
 On Mon, Aug 3, 2015 at 9:48 AM, Chen-Yu Tsai w...@csie.org wrote:
  Add a proper module alias so the driver can be autoloaded when the
  parent axp20x mfd driver registers its cells.
 
  Signed-off-by: Chen-Yu Tsai w...@csie.org
 
 Acked-by: Carlo Caione ca...@caione.org

Applied, thank you.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [linux-sunxi] Re: [PATCH] Input: axp20x-pek: Add module alias

2015-08-04 Thread Dmitry Torokhov
On Tue, Aug 04, 2015 at 05:04:55PM +0800, Chen-Yu Tsai wrote:
 On Tue, Aug 4, 2015 at 4:42 PM, Paul Bolle pebo...@tiscali.nl wrote:
  On ma, 2015-08-03 at 15:48 +0800, Chen-Yu Tsai wrote:
  Add a proper module alias so the driver can be autoloaded when the
  parent axp20x mfd driver registers its cells.
 
  Signed-off-by: Chen-Yu Tsai w...@csie.org
 
  --- a/drivers/input/misc/axp20x-pek.c
  +++ b/drivers/input/misc/axp20x-pek.c
 
  +MODULE_ALIAS(platform:axp20x-pek);
 
  Should this eventually go into stable?
 
  The AXP20x Power Enable Key driver was added in v4.0, so this patch
  could currently be relevant for the v4.1.y tree. (In that tree a parent
  MFD driver appears to be present too.)
 
 (Since I forgot to add the stable tag,) I can submit it for inclusion
 into stable after it's merged into Linus' tree.

OTOH do we have many general users needing this driver as a
automatically loaded module? If not that many then it is OK to just
merge it in mainline and skip stable.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
linux-sunxi group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 2/4] devicetree: bindings: Add header file with evdev type and abs/rel code defines

2015-09-10 Thread Dmitry Torokhov
On Thu, Sep 10, 2015 at 11:40 AM, Hans de Goede <hdego...@redhat.com> wrote:
> Hi,
>
>
> On 10-09-15 20:34, Dmitry Torokhov wrote:
>>
>> On Thu, Sep 10, 2015 at 10:25 AM, Rob Herring <r...@kernel.org> wrote:
>>>
>>> On 09/09/2015 04:11 AM, Hans de Goede wrote:
>>>>
>>>> This header provides evdev constants for linux,code, and linux,input-*
>>>> properties.
>>>>
>>>> Signed-off-by: Hans de Goede <hdego...@redhat.com>
>>>> ---
>>>>   include/dt-bindings/input/evdev.h | 76
>>>> +++
>>>
>>>
>>> This looks fine, but please just add to input/input.h.
>>>
>>> Rob
>>>
>>>>   1 file changed, 76 insertions(+)
>>>>   create mode 100644 include/dt-bindings/input/evdev.h
>>>>
>>>> diff --git a/include/dt-bindings/input/evdev.h
>>>> b/include/dt-bindings/input/evdev.h
>>>> new file mode 100644
>>>> index 000..c1f7e0d
>>>> --- /dev/null
>>>> +++ b/include/dt-bindings/input/evdev.h
>>>> @@ -0,0 +1,76 @@
>>>> +/*
>>>> + * This header provides evdev constants for linux,code, and
>>>> linux,input-*
>>>> + * properties.
>>>> + */
>>>> +
>>>> +#ifndef _DT_BINDINGS_INPUT_LINUX_H
>>>> +#define _DT_BINDINGS_INPUT_LINUX_H
>>>> +
>>>> +/*
>>>> + * Event types
>>>> + */
>>>> +
>>>> +#define EV_SYN   0x00
>>>> +#define EV_KEY   0x01
>>>> +#define EV_REL   0x02
>>>> +#define EV_ABS   0x03
>>>> +#define EV_MSC   0x04
>>>> +#define EV_SW0x05
>>>> +#define EV_LED   0x11
>>>> +#define EV_SND   0x12
>>>> +#define EV_REP   0x14
>>>> +#define EV_FF0x15
>>>> +#define EV_PWR   0x16
>>>> +#define EV_FF_STATUS 0x17
>>>> +#define EV_MAX   0x1f
>>>> +
>>>> +/*
>>>> + * Relative axes
>>>> + */
>>>> +
>>>> +#define REL_X0x00
>>>> +#define REL_Y0x01
>>>> +#define REL_Z0x02
>>>> +#define REL_RX   0x03
>>>> +#define REL_RY   0x04
>>>> +#define REL_RZ   0x05
>>>> +#define REL_HWHEEL   0x06
>>>> +#define REL_DIAL 0x07
>>>> +#define REL_WHEEL0x08
>>>> +#define REL_MISC 0x09
>>>> +#define REL_MAX  0x0f
>>>> +
>>>> +/*
>>>> + * Absolute axes
>>>> + */
>>>> +
>>>> +#define ABS_X0x00
>>>> +#define ABS_Y0x01
>>>> +#define ABS_Z0x02
>>>> +#define ABS_RX   0x03
>>>> +#define ABS_RY   0x04
>>>> +#define ABS_RZ   0x05
>>>> +#define ABS_THROTTLE 0x06
>>>> +#define ABS_RUDDER   0x07
>>>> +#define ABS_WHEEL0x08
>>>> +#define ABS_GAS  0x09
>>>> +#define ABS_BRAKE0x0a
>>>> +#define ABS_HAT0X0x10
>>>> +#define ABS_HAT0Y0x11
>>>> +#define ABS_HAT1X0x12
>>>> +#define ABS_HAT1Y0x13
>>>> +#define ABS_HAT2X0x14
>>>> +#define ABS_HAT2Y0x15
>>>> +#define ABS_HAT3X0x16
>>>> +#define ABS_HAT3Y0x17
>>>> +#define ABS_PRESSURE 0x18
>>>> +#define ABS_DISTANCE 0x19
>>>> +#define ABS_TILT_X   0x1a
>>>> +#define ABS_TILT_Y   0x1b
>>>> +#define ABS_TOOL_WIDTH   0x1c
>>>> +
>>>> +#define ABS_VOLUME   0x20
>>>> +
>>>> +#define ABS_MISC 0x28
>>>> +
>>>> +#endif /* _DT_BINDINGS_INPUT_LINUX_H */
>>>>
>>>
>>
>> Actually I'd rather we removed include/dt-bindings/input/input.h and
>> instead used the header file from uapi. As it is now we already
>> duplicating definitions and the copy in dt-bindings is missing several
>> key codes. Until we split DT bindings form the kernel code I'd rather
>> have definitions in one place.
>
>
> AFAIK we cannot do that as the uapi header also contains things like:
>
> struct input_event {
> struct timeval time;
> __u16 type;
> __u16 code;
> __s32 value;
> };
>
> Which is not valid device tree syntax.
>
> If you want this we need to split the uapi headers in one with only
> defines and one with all the rest.

That would be fine by me. event-codes.h?

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 2/4] devicetree: bindings: Add header file with evdev type and abs/rel code defines

2015-09-10 Thread Dmitry Torokhov
On Thu, Sep 10, 2015 at 10:25 AM, Rob Herring  wrote:
> On 09/09/2015 04:11 AM, Hans de Goede wrote:
>> This header provides evdev constants for linux,code, and linux,input-*
>> properties.
>>
>> Signed-off-by: Hans de Goede 
>> ---
>>  include/dt-bindings/input/evdev.h | 76 
>> +++
>
> This looks fine, but please just add to input/input.h.
>
> Rob
>
>>  1 file changed, 76 insertions(+)
>>  create mode 100644 include/dt-bindings/input/evdev.h
>>
>> diff --git a/include/dt-bindings/input/evdev.h 
>> b/include/dt-bindings/input/evdev.h
>> new file mode 100644
>> index 000..c1f7e0d
>> --- /dev/null
>> +++ b/include/dt-bindings/input/evdev.h
>> @@ -0,0 +1,76 @@
>> +/*
>> + * This header provides evdev constants for linux,code, and linux,input-*
>> + * properties.
>> + */
>> +
>> +#ifndef _DT_BINDINGS_INPUT_LINUX_H
>> +#define _DT_BINDINGS_INPUT_LINUX_H
>> +
>> +/*
>> + * Event types
>> + */
>> +
>> +#define EV_SYN   0x00
>> +#define EV_KEY   0x01
>> +#define EV_REL   0x02
>> +#define EV_ABS   0x03
>> +#define EV_MSC   0x04
>> +#define EV_SW0x05
>> +#define EV_LED   0x11
>> +#define EV_SND   0x12
>> +#define EV_REP   0x14
>> +#define EV_FF0x15
>> +#define EV_PWR   0x16
>> +#define EV_FF_STATUS 0x17
>> +#define EV_MAX   0x1f
>> +
>> +/*
>> + * Relative axes
>> + */
>> +
>> +#define REL_X0x00
>> +#define REL_Y0x01
>> +#define REL_Z0x02
>> +#define REL_RX   0x03
>> +#define REL_RY   0x04
>> +#define REL_RZ   0x05
>> +#define REL_HWHEEL   0x06
>> +#define REL_DIAL 0x07
>> +#define REL_WHEEL0x08
>> +#define REL_MISC 0x09
>> +#define REL_MAX  0x0f
>> +
>> +/*
>> + * Absolute axes
>> + */
>> +
>> +#define ABS_X0x00
>> +#define ABS_Y0x01
>> +#define ABS_Z0x02
>> +#define ABS_RX   0x03
>> +#define ABS_RY   0x04
>> +#define ABS_RZ   0x05
>> +#define ABS_THROTTLE 0x06
>> +#define ABS_RUDDER   0x07
>> +#define ABS_WHEEL0x08
>> +#define ABS_GAS  0x09
>> +#define ABS_BRAKE0x0a
>> +#define ABS_HAT0X0x10
>> +#define ABS_HAT0Y0x11
>> +#define ABS_HAT1X0x12
>> +#define ABS_HAT1Y0x13
>> +#define ABS_HAT2X0x14
>> +#define ABS_HAT2Y0x15
>> +#define ABS_HAT3X0x16
>> +#define ABS_HAT3Y0x17
>> +#define ABS_PRESSURE 0x18
>> +#define ABS_DISTANCE 0x19
>> +#define ABS_TILT_X   0x1a
>> +#define ABS_TILT_Y   0x1b
>> +#define ABS_TOOL_WIDTH   0x1c
>> +
>> +#define ABS_VOLUME   0x20
>> +
>> +#define ABS_MISC 0x28
>> +
>> +#endif /* _DT_BINDINGS_INPUT_LINUX_H */
>>
>

Actually I'd rather we removed include/dt-bindings/input/input.h and
instead used the header file from uapi. As it is now we already
duplicating definitions and the copy in dt-bindings is missing several
key codes. Until we split DT bindings form the kernel code I'd rather
have definitions in one place.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 2/4] devicetree: bindings: Add header file with evdev type and abs/rel code defines

2015-09-12 Thread Dmitry Torokhov
On Thu, Sep 10, 2015 at 3:48 PM, Rob Herring <r...@kernel.org> wrote:
> +Ian
>
> On 09/10/2015 01:50 PM, Hans de Goede wrote:
>> Hi,
>>
>> On 10-09-15 20:42, Dmitry Torokhov wrote:
>>> On Thu, Sep 10, 2015 at 11:40 AM, Hans de Goede <hdego...@redhat.com>
>>> wrote:
>>>> Hi,
>>>>
>>>>
>>>> On 10-09-15 20:34, Dmitry Torokhov wrote:
>>>>>
>>>>> On Thu, Sep 10, 2015 at 10:25 AM, Rob Herring <r...@kernel.org> wrote:
>>>>>>
>>>>>> On 09/09/2015 04:11 AM, Hans de Goede wrote:
>>>>>>>
>>>>>>> This header provides evdev constants for linux,code, and
>>>>>>> linux,input-*
>>>>>>> properties.
>>>>>>>
>>>>>>> Signed-off-by: Hans de Goede <hdego...@redhat.com>
>>>>>>> ---
>>>>>>>include/dt-bindings/input/evdev.h | 76
>>>>>>> +++
>>>>>>
>>>>>>
>>>>>> This looks fine, but please just add to input/input.h.
>
> [...]
>
>>>>> Actually I'd rather we removed include/dt-bindings/input/input.h and
>>>>> instead used the header file from uapi. As it is now we already
>>>>> duplicating definitions and the copy in dt-bindings is missing several
>>>>> key codes. Until we split DT bindings form the kernel code I'd rather
>>>>> have definitions in one place.
>
> We do already have split binding tree. It is generated from the kernel
> tree ATM.

But the data in the kernel is the "source of truth" for now since the
other tree is simply generated.

> Adding Ian for any comments.
>
>>>> AFAIK we cannot do that as the uapi header also contains things like:
>>>>
>>>> struct input_event {
>>>>  struct timeval time;
>>>>  __u16 type;
>>>>  __u16 code;
>>>>  __s32 value;
>>>> };
>>>>
>>>> Which is not valid device tree syntax.
>>>>
>>>> If you want this we need to split the uapi headers in one with only
>>>> defines and one with all the rest.
>>>
>>> That would be fine by me. event-codes.h?
>>
>> Since this will live in the generic include/linux namespace (for userspace)
>> maybe input-event-codes ?
>>
>> Rob are you ok with including uapi headers from dts files if those uapi
>> headers are guaranteed to have only #define-s in them?
>
> No. If you can do it as a symlink or some limited way, I'd be fine with
> that. I don't want to see wholesale addition of uapi headers though.

Umm, not sure if I like symlink, it makes hard to see what includes
what. The individual DTSes will continue including
dt-bindings/input/input.h and only input.h will include uapi header
(so use of uapi is internal detail). Would that still be a problem?

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 3/4] input: Add new sun4i-keypad driver

2015-09-21 Thread Dmitry Torokhov
Hi Yassin,

On Wed, Sep 16, 2015 at 12:05:56AM +1000, yassinjaf...@gmail.com wrote:
> From: Yassin Jaffer 
> 
> Allwinnner SUN4i Keypad controller is used to interface a SoC
> with a matrix-typekeypad device.
> The keypad controller supports multiple row and column lines.
> A key can be placed at each intersection of a unique
> row and a unique column.
> The keypad controller can sense a key-press and key-release and report the
> event using a interrupt to the cpu.
> This patch adds a driver support to this.
> The keypad controller driver does not give proper information
> if more that two keys are selected.
> 
> Signed-off-by: Yassin Jaffer 
> ---
>  drivers/input/keyboard/Kconfig|  11 ++
>  drivers/input/keyboard/Makefile   |   1 +
>  drivers/input/keyboard/sun4i-keypad.c | 361 
> ++
>  3 files changed, 373 insertions(+)
>  create mode 100644 drivers/input/keyboard/sun4i-keypad.c
> 
> diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
> index 2e80107..4f2f3f8 100644
> --- a/drivers/input/keyboard/Kconfig
> +++ b/drivers/input/keyboard/Kconfig
> @@ -590,6 +590,17 @@ config KEYBOARD_SUN4I_LRADC
> To compile this driver as a module, choose M here: the
> module will be called sun4i-lradc-keys.
>  
> +config KEYBOARD_SUN4I_KEYPAD
> + tristate "Allwinner sun4i keypad support"
> + depends on ARCH_SUNXI
> + select INPUT_MATRIXKMAP
> + help
> +   This selects support for the Allwinner keypad
> +   on Allwinner sunxi SoCs.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called sun4i-keypad.
> +
>  config KEYBOARD_DAVINCI
>   tristate "TI DaVinci Key Scan"
>   depends on ARCH_DAVINCI_DM365
> diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
> index 1d416dd..d9f54b4 100644
> --- a/drivers/input/keyboard/Makefile
> +++ b/drivers/input/keyboard/Makefile
> @@ -57,6 +57,7 @@ obj-$(CONFIG_KEYBOARD_STMPE)+= 
> stmpe-keypad.o
>  obj-$(CONFIG_KEYBOARD_STOWAWAY)  += stowaway.o
>  obj-$(CONFIG_KEYBOARD_ST_KEYSCAN)+= st-keyscan.o
>  obj-$(CONFIG_KEYBOARD_SUN4I_LRADC)   += sun4i-lradc-keys.o
> +obj-$(CONFIG_KEYBOARD_SUN4I_KEYPAD)  += sun4i-keypad.o
>  obj-$(CONFIG_KEYBOARD_SUNKBD)+= sunkbd.o
>  obj-$(CONFIG_KEYBOARD_TC3589X)   += tc3589x-keypad.o
>  obj-$(CONFIG_KEYBOARD_TEGRA) += tegra-kbc.o
> diff --git a/drivers/input/keyboard/sun4i-keypad.c 
> b/drivers/input/keyboard/sun4i-keypad.c
> new file mode 100644
> index 000..995f9665
> --- /dev/null
> +++ b/drivers/input/keyboard/sun4i-keypad.c
> @@ -0,0 +1,361 @@
> +/*
> + * Allwinner sun4i keypad Controller driver
> + *
> + * Copyright (C) 2015 Yassin Jaffer 
> + *
> + * Parts of this software are based on (derived from):
> + * Copyright (C) 2013-2015 lim...@allwinnertech.com,
> + *qys
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/*
> + * Keypad Controller registers
> + */
> +#define KP_CTL   0x00  /* Keypad Control register */
> +#define KP_TIMING0x04  /* Keypad Timing register */
> +#define KP_INT_CFG   0x08  /* Keypad interrupt Config register */
> +#define KP_INT_STA   0x0c  /* Keypad interrupt Status register */
> +
> +#define KP_IN_OFFSET 0x10 /* Keypad Input Data register 0 */
> +#define KP_INX_OFFSET(reg_n) (KP_IN_OFFSET + 4 * (reg_n))
> +
> +/* KP_CTL bits */
> +#define ENABLE(x)((x) << 0)
> +#define COLMASK(x)   ((~x & 0xff) << 8)
> +#define ROWMASK(x)   ((~x & 0xff) << 16)
> +
> +/* KP_TIMING bits */
> +#define SCAN_CYCLE(x)((x) << 0)
> +#define DBC_CYCLE(x) ((x) << 16)
> +
> +/* KP_INT_CFG bits */
> +#define KP_IRQ_FEDGE BIT(0)
> +#define  KP_IRQ_REDGEBIT(1)
> +
> +/* KP_INT_STA bits */
> +#define KP_STA_FEDGE BIT(0)
> +#define  KP_STA_REDGEBIT(1)
> +
> +#define KP_MAX_ROWS  8
> +#define KP_MAX_COLS  8
> +#define N_ROWS_REG   2
> +#define KP_ROW_SHIFT 3
> +#define KP_BIT_SHIFT32
> +
> +#define MAX_MATRIX_KEY_NUM   (KP_MAX_ROWS * KP_MAX_COLS)
> +
> +#define 

[linux-sunxi] Re: [PATCH v3] touchscreen: pixcir_i2c: Add support for wake and enable gpios

2015-12-01 Thread Dmitry Torokhov
On Sun, Nov 22, 2015 at 04:19:50PM -0600, Rob Herring wrote:
> On Sun, Nov 22, 2015 at 04:57:33PM +0100, Hans de Goede wrote:
> > From: Sander Vermin 
> > 
> > On some devices the wake and enable pins of the pixcir touchscreen
> > controller are connected to gpios and these must be controlled by the
> > driver for the device to operate properly.
> > 
> > Signed-off-by: Sander Vermin 
> > Signed-off-by: Hans de Goede 
> > ---
> > Changes in v2 (Hans de Goede):
> > -Split the changes for dealing with inverted / swapped axis out into a
> >  separate patch
> > -Remove a bunch of dev_info calls to make the driver less chatty
> > -Use devm_gpiod_get_optional as these new gpios are optional
> > -Only msleep after setting enable high if we have an enable pin
> > Changes in v3 (Hans de Goede):
> > -Use "if (ts->gpio_foo)" instead of "if (!IS_ERR_OR_NULL(ts->foo))"
> > -No need to set gpio-s to 1 after requesting them with GPIOD_OUT_HIGH
> > ---
> >  .../bindings/input/touchscreen/pixcir_i2c_ts.txt   |  2 ++
> 
> For the binding:
> 
> Acked-by: Rob Herring 

Applied, thank you.

> 
> >  drivers/input/touchscreen/pixcir_i2c_ts.c  | 40 
> > ++
> >  2 files changed, 42 insertions(+)
> > 
> > diff --git 
> > a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt 
> > b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> > index 8eb240a..72ca5ec 100644
> > --- a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> > +++ b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> > @@ -10,6 +10,8 @@ Required properties:
> >  
> >  Optional properties:
> >  - reset-gpio: GPIO connected to the RESET line of the chip
> > +- enable-gpios: GPIO connected to the ENABLE line of the chip
> > +- wake-gpios: GPIO connected to the WAKE line of the chip
> >  
> >  Example:
> >  
> > diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c 
> > b/drivers/input/touchscreen/pixcir_i2c_ts.c
> > index 211408c..22a67c6 100644
> > --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> > +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> > @@ -38,6 +38,8 @@ struct pixcir_i2c_ts_data {
> > struct input_dev *input;
> > struct gpio_desc *gpio_attb;
> > struct gpio_desc *gpio_reset;
> > +   struct gpio_desc *gpio_enable;
> > +   struct gpio_desc *gpio_wake;
> > const struct pixcir_i2c_chip_data *chip;
> > int max_fingers;/* Max fingers supported in this instance */
> > bool running;
> > @@ -208,6 +210,11 @@ static int pixcir_set_power_mode(struct 
> > pixcir_i2c_ts_data *ts,
> > struct device *dev = >client->dev;
> > int ret;
> >  
> > +   if (mode == PIXCIR_POWER_ACTIVE || mode == PIXCIR_POWER_IDLE) {
> > +   if (ts->gpio_wake)
> > +   gpiod_set_value_cansleep(ts->gpio_wake, 1);
> > +   }
> > +
> > ret = i2c_smbus_read_byte_data(ts->client, PIXCIR_REG_POWER_MODE);
> > if (ret < 0) {
> > dev_err(dev, "%s: can't read reg 0x%x : %d\n",
> > @@ -228,6 +235,11 @@ static int pixcir_set_power_mode(struct 
> > pixcir_i2c_ts_data *ts,
> > return ret;
> > }
> >  
> > +   if (mode == PIXCIR_POWER_HALT) {
> > +   if (ts->gpio_wake)
> > +   gpiod_set_value_cansleep(ts->gpio_wake, 0);
> > +   }
> > +
> > return 0;
> >  }
> >  
> > @@ -302,6 +314,11 @@ static int pixcir_start(struct pixcir_i2c_ts_data *ts)
> > struct device *dev = >client->dev;
> > int error;
> >  
> > +   if (ts->gpio_enable) {
> > +   gpiod_set_value_cansleep(ts->gpio_enable, 1);
> > +   msleep(100);
> > +   }
> > +
> > /* LEVEL_TOUCH interrupt with active low polarity */
> > error = pixcir_set_int_mode(ts, PIXCIR_INT_LEVEL_TOUCH, 0);
> > if (error) {
> > @@ -343,6 +360,9 @@ static int pixcir_stop(struct pixcir_i2c_ts_data *ts)
> > /* Wait till running ISR is complete */
> > synchronize_irq(ts->client->irq);
> >  
> > +   if (ts->gpio_enable)
> > +   gpiod_set_value_cansleep(ts->gpio_enable, 0);
> > +
> > return 0;
> >  }
> >  
> > @@ -534,6 +554,26 @@ static int pixcir_i2c_ts_probe(struct i2c_client 
> > *client,
> > return error;
> > }
> >  
> > +   tsdata->gpio_wake = devm_gpiod_get_optional(dev, "wake",
> > +   GPIOD_OUT_HIGH);
> > +   if (IS_ERR(tsdata->gpio_wake)) {
> > +   error = PTR_ERR(tsdata->gpio_wake);
> > +   if (error != -EPROBE_DEFER)
> > +   dev_err(dev, "Failed to get wake gpio: %d\n", error);
> > +   return error;
> > +   }
> > +
> > +   tsdata->gpio_enable = devm_gpiod_get_optional(dev, "enable",
> > + GPIOD_OUT_HIGH);
> > +   if (IS_ERR(tsdata->gpio_enable)) {
> > +   error = PTR_ERR(tsdata->gpio_enable);
> > +   if (error != -EPROBE_DEFER)
> > +   

[linux-sunxi] Re: [PATCH 4/7] touchscreen: pixcir_i2c: Add support for wake and enable gpios

2015-11-20 Thread Dmitry Torokhov
On Fri, Nov 20, 2015 at 12:17:10PM +0100, Hans de Goede wrote:
> From: Sander Vermin 
> 
> On some devices the wake and enable pins of the pixcir touchscreen
> controller are connected to gpios and these must be controlled by the
> driver for the device to operate properly.
> 
> Signed-off-by: Sander Vermin 
> Signed-off-by: Hans de Goede 
> ---
> Changes in v2 (Hans de Goede):
> -Split the changes for dealing with inverted / swapped axis out into a
>  separate patch
> -Remove a bunch of dev_info calls to make the driver less chatty
> -Use devm_gpiod_get_optional as these new gpios are optional
> -Only msleep after setting enable high if we have an enable pin
> ---
>  .../bindings/input/touchscreen/pixcir_i2c_ts.txt   |  2 +
>  drivers/input/touchscreen/pixcir_i2c_ts.c  | 46 
> ++
>  2 files changed, 48 insertions(+)
> 
> diff --git 
> a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt 
> b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> index 8eb240a..72ca5ec 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> @@ -10,6 +10,8 @@ Required properties:
>  
>  Optional properties:
>  - reset-gpio: GPIO connected to the RESET line of the chip
> +- enable-gpios: GPIO connected to the ENABLE line of the chip
> +- wake-gpios: GPIO connected to the WAKE line of the chip
>  
>  Example:
>  
> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c 
> b/drivers/input/touchscreen/pixcir_i2c_ts.c
> index 211408c..b75ef65 100644
> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> @@ -38,6 +38,8 @@ struct pixcir_i2c_ts_data {
>   struct input_dev *input;
>   struct gpio_desc *gpio_attb;
>   struct gpio_desc *gpio_reset;
> + struct gpio_desc *gpio_enable;
> + struct gpio_desc *gpio_wake;
>   const struct pixcir_i2c_chip_data *chip;
>   int max_fingers;/* Max fingers supported in this instance */
>   bool running;
> @@ -208,6 +210,11 @@ static int pixcir_set_power_mode(struct 
> pixcir_i2c_ts_data *ts,
>   struct device *dev = >client->dev;
>   int ret;
>  
> + if (mode == PIXCIR_POWER_ACTIVE || mode == PIXCIR_POWER_IDLE) {
> + if (!IS_ERR_OR_NULL(ts->gpio_wake))
> + gpiod_set_value_cansleep(ts->gpio_wake, 1);

I believe you error out in case when IS_ERR(ts->gpio_wake) is true, so I
wonder if we should simply use

if (ts->gpio_wake)
gpiod_set_value_cansleep(ts->gpio_wake, 1);

here and elsewhere.

No need to resubmit, just let me know.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v2 4/7] touchscreen: pixcir_i2c: Add support for wake and enable gpios

2015-11-20 Thread Dmitry Torokhov
On Fri, Nov 20, 2015 at 02:24:49PM +0100, Hans de Goede wrote:
> From: Sander Vermin 
> 
> On some devices the wake and enable pins of the pixcir touchscreen
> controller are connected to gpios and these must be controlled by the
> driver for the device to operate properly.
> 
> Signed-off-by: Sander Vermin 
> Signed-off-by: Hans de Goede 
> ---
> Changes in v2 (Hans de Goede):
> -Split the changes for dealing with inverted / swapped axis out into a
>  separate patch
> -Remove a bunch of dev_info calls to make the driver less chatty
> -Use devm_gpiod_get_optional as these new gpios are optional
> -Only msleep after setting enable high if we have an enable pin
> ---
>  .../bindings/input/touchscreen/pixcir_i2c_ts.txt   |  2 +
>  drivers/input/touchscreen/pixcir_i2c_ts.c  | 46 
> ++
>  2 files changed, 48 insertions(+)
> 
> diff --git 
> a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt 
> b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> index 8eb240a..72ca5ec 100644
> --- a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> +++ b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
> @@ -10,6 +10,8 @@ Required properties:
>  
>  Optional properties:
>  - reset-gpio: GPIO connected to the RESET line of the chip
> +- enable-gpios: GPIO connected to the ENABLE line of the chip
> +- wake-gpios: GPIO connected to the WAKE line of the chip
>  
>  Example:
>  
> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c 
> b/drivers/input/touchscreen/pixcir_i2c_ts.c
> index 211408c..b75ef65 100644
> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> @@ -38,6 +38,8 @@ struct pixcir_i2c_ts_data {
>   struct input_dev *input;
>   struct gpio_desc *gpio_attb;
>   struct gpio_desc *gpio_reset;
> + struct gpio_desc *gpio_enable;
> + struct gpio_desc *gpio_wake;
>   const struct pixcir_i2c_chip_data *chip;
>   int max_fingers;/* Max fingers supported in this instance */
>   bool running;
> @@ -208,6 +210,11 @@ static int pixcir_set_power_mode(struct 
> pixcir_i2c_ts_data *ts,
>   struct device *dev = >client->dev;
>   int ret;
>  
> + if (mode == PIXCIR_POWER_ACTIVE || mode == PIXCIR_POWER_IDLE) {
> + if (!IS_ERR_OR_NULL(ts->gpio_wake))
> + gpiod_set_value_cansleep(ts->gpio_wake, 1);
> + }
> +
>   ret = i2c_smbus_read_byte_data(ts->client, PIXCIR_REG_POWER_MODE);
>   if (ret < 0) {
>   dev_err(dev, "%s: can't read reg 0x%x : %d\n",
> @@ -228,6 +235,11 @@ static int pixcir_set_power_mode(struct 
> pixcir_i2c_ts_data *ts,
>   return ret;
>   }
>  
> + if (mode == PIXCIR_POWER_HALT) {
> + if (!IS_ERR_OR_NULL(ts->gpio_wake))
> + gpiod_set_value_cansleep(ts->gpio_wake, 0);
> + }
> +
>   return 0;
>  }
>  
> @@ -302,6 +314,11 @@ static int pixcir_start(struct pixcir_i2c_ts_data *ts)
>   struct device *dev = >client->dev;
>   int error;
>  
> + if (!IS_ERR_OR_NULL(ts->gpio_enable)) {
> + gpiod_set_value_cansleep(ts->gpio_enable, 1);
> + msleep(100);
> + }
> +
>   /* LEVEL_TOUCH interrupt with active low polarity */
>   error = pixcir_set_int_mode(ts, PIXCIR_INT_LEVEL_TOUCH, 0);
>   if (error) {
> @@ -343,6 +360,9 @@ static int pixcir_stop(struct pixcir_i2c_ts_data *ts)
>   /* Wait till running ISR is complete */
>   synchronize_irq(ts->client->irq);
>  
> + if (!IS_ERR_OR_NULL(ts->gpio_enable))
> + gpiod_set_value_cansleep(ts->gpio_enable, 0);
> +
>   return 0;
>  }
>  
> @@ -534,6 +554,24 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
>   return error;
>   }
>  
> + tsdata->gpio_wake = devm_gpiod_get_optional(dev, "wake",
> + GPIOD_OUT_HIGH);
> + if (IS_ERR(tsdata->gpio_wake)) {
> + error = PTR_ERR(tsdata->gpio_wake);
> + if (error != -EPROBE_DEFER)
> + dev_err(dev, "Failed to get wake gpio: %d\n", error);
> + return error;
> + }
> +
> + tsdata->gpio_enable = devm_gpiod_get_optional(dev, "enable",
> +   GPIOD_OUT_HIGH);
> + if (IS_ERR(tsdata->gpio_enable)) {
> + error = PTR_ERR(tsdata->gpio_enable);
> + if (error != -EPROBE_DEFER)
> + dev_err(dev, "Failed to get enable gpio: %d\n", error);
> + return error;
> + }
> +
>   error = devm_request_threaded_irq(dev, client->irq, NULL, pixcir_ts_isr,
> IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> client->name, tsdata);
> @@ -542,6 +580,14 @@ static int pixcir_i2c_ts_probe(struct i2c_client 

[linux-sunxi] Re: [PATCH v5 32/46] pwm: deprecate pwm_config(), pwm_enable() and pwm_disable()

2016-03-31 Thread Dmitry Torokhov
Hi Boris,

On Wed, Mar 30, 2016 at 10:03:55PM +0200, Boris Brezillon wrote:
> Prefix those function as deprecated to encourage all existing users to
> switch to pwm_apply_state().

Why not keep at least some of them as wrappers where we do not need to
chnage several parameters at once? It is much easier to have a driver
do:

error = pwm_enable(pwm);
if (error)
...

rather than declaring the state variable, fectch it, adjust and then
apply.

> 
> Signed-off-by: Boris Brezillon 
> ---
>  include/linux/pwm.h | 24 
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/include/linux/pwm.h b/include/linux/pwm.h
> index 4aad4eb..9bac10f 100644
> --- a/include/linux/pwm.h
> +++ b/include/linux/pwm.h
> @@ -225,8 +225,8 @@ int pwm_apply_state(struct pwm_device *pwm, struct 
> pwm_state *state);
>   *
>   * Returns: 0 on success or a negative error code on failure.
>   */
> -static inline int pwm_config(struct pwm_device *pwm, int duty_ns,
> -  int period_ns)
> +static inline int __deprecated pwm_config(struct pwm_device *pwm, int 
> duty_ns,
> +   int period_ns)
>  {
>   struct pwm_state pstate;
>  
> @@ -252,8 +252,8 @@ static inline int pwm_config(struct pwm_device *pwm, int 
> duty_ns,
>   *
>   * Returns: 0 on success or a negative error code on failure.
>   */
> -static inline int pwm_set_polarity(struct pwm_device *pwm,
> -enum pwm_polarity polarity)
> +static inline int __deprecated pwm_set_polarity(struct pwm_device *pwm,
> + enum pwm_polarity polarity)
>  {
>   struct pwm_state pstate;
>  
> @@ -284,7 +284,7 @@ static inline int pwm_set_polarity(struct pwm_device *pwm,
>   *
>   * Returns: 0 on success or a negative error code on failure.
>   */
> -static inline int pwm_enable(struct pwm_device *pwm)
> +static inline int __deprecated pwm_enable(struct pwm_device *pwm)
>  {
>   struct pwm_state pstate;
>  
> @@ -303,7 +303,7 @@ static inline int pwm_enable(struct pwm_device *pwm)
>   * pwm_disable() - stop a PWM output toggling
>   * @pwm: PWM device
>   */
> -static inline void pwm_disable(struct pwm_device *pwm)
> +static inline void __deprecated pwm_disable(struct pwm_device *pwm)
>  {
>   struct pwm_state pstate;
>  
> @@ -360,24 +360,24 @@ static inline int pwm_apply_state(struct pwm_device 
> *pwm,
>   return -ENOTSUPP;
>  }
>  
> -static inline int pwm_config(struct pwm_device *pwm, int duty_ns,
> -  int period_ns)
> +static inline int __deprecated pwm_config(struct pwm_device *pwm, int 
> duty_ns,
> +   int period_ns)
>  {
>   return -EINVAL;
>  }
>  
> -static inline int pwm_set_polarity(struct pwm_device *pwm,
> -enum pwm_polarity polarity)
> +static inline int __deprecated pwm_set_polarity(struct pwm_device *pwm,
> + enum pwm_polarity polarity)
>  {
>   return -ENOTSUPP;
>  }
>  
> -static inline int pwm_enable(struct pwm_device *pwm)
> +static inline int __deprecated pwm_enable(struct pwm_device *pwm)
>  {
>   return -EINVAL;
>  }
>  
> -static inline void pwm_disable(struct pwm_device *pwm)
> +static inline void __deprecated pwm_disable(struct pwm_device *pwm)
>  {
>  }
>  
> -- 
> 2.5.0
> 

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v5 36/46] input: misc: max77693: switch to the atomic API

2016-03-31 Thread Dmitry Torokhov
Hi Boris,

On Wed, Mar 30, 2016 at 10:03:59PM +0200, Boris Brezillon wrote:
> pwm_config/enable/disable() have been deprecated and should be replaced
> by pwm_apply_state().
> 
> Signed-off-by: Boris Brezillon 
> ---
>  drivers/input/misc/max77693-haptic.c | 23 +--
>  1 file changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/input/misc/max77693-haptic.c 
> b/drivers/input/misc/max77693-haptic.c
> index cf6aac0..aef7dc4 100644
> --- a/drivers/input/misc/max77693-haptic.c
> +++ b/drivers/input/misc/max77693-haptic.c
> @@ -70,13 +70,16 @@ struct max77693_haptic {
>  
>  static int max77693_haptic_set_duty_cycle(struct max77693_haptic *haptic)
>  {
> + struct pwm_state pstate;
>   struct pwm_args pargs = { };
> - int delta;
>   int error;
>  
>   pwm_get_args(haptic->pwm_dev, );
> - delta = (pargs.period + haptic->pwm_duty) / 2;
> - error = pwm_config(haptic->pwm_dev, delta, pargs.period);
> + pwm_get_state(haptic->pwm_dev, );
> +
> + pstate.period = pargs.period;
> + pstate.duty_cycle = (pargs.period + haptic->pwm_duty) / 2;
> + error = pwm_apply_state(haptic->pwm_dev, );

This does not make sense with regard to the atomic API. If you look in
max77693_haptic_play_work(), right after calling
max77693_haptic_set_duty_cycle() we either try to enable or disable the
pwm. When switching to this new API we should combine both actions.

>   if (error) {
>   dev_err(haptic->dev, "failed to configure pwm: %d\n", error);
>   return error;
> @@ -161,12 +164,16 @@ static int max77693_haptic_lowsys(struct 
> max77693_haptic *haptic, bool enable)
>  
>  static void max77693_haptic_enable(struct max77693_haptic *haptic)
>  {
> + struct pwm_state pstate;
>   int error;
>  
>   if (haptic->enabled)
>   return;
>  
> - error = pwm_enable(haptic->pwm_dev);
> + pwm_get_state(haptic->pwm_dev, );
> + pstate.enabled = true;
> +
> + error = pwm_apply_state(haptic->pwm_dev, );

As I mentioned I'd rather we did not deprecate pwm_enable() and
pwm_disable() (and maybe others), as it forces us to add unnecessary
boilerplate code to the drivers.
 
>   if (error) {
>   dev_err(haptic->dev,
>   "failed to enable haptic pwm device: %d\n", error);
> @@ -188,11 +195,13 @@ static void max77693_haptic_enable(struct 
> max77693_haptic *haptic)
>  err_enable_config:
>   max77693_haptic_lowsys(haptic, false);
>  err_enable_lowsys:
> - pwm_disable(haptic->pwm_dev);
> + pstate.enabled = false;
> + pwm_apply_state(haptic->pwm_dev, );
>  }
>  
>  static void max77693_haptic_disable(struct max77693_haptic *haptic)
>  {
> + struct pwm_state pstate;
>   int error;
>  
>   if (!haptic->enabled)
> @@ -206,7 +215,9 @@ static void max77693_haptic_disable(struct 
> max77693_haptic *haptic)
>   if (error)
>   goto err_disable_lowsys;
>  
> - pwm_disable(haptic->pwm_dev);
> + pwm_get_state(haptic->pwm_dev, );
> + pstate.enabled = false;
> + pwm_apply_state(haptic->pwm_dev, );

Same here.

>   haptic->enabled = false;
>  
>   return;
> -- 
> 2.5.0
> 

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v5 13/24] input: misc: max8997: explicitly apply PWM config extracted from pwm_args

2016-04-17 Thread Dmitry Torokhov
On Thu, Apr 14, 2016 at 09:17:33PM +0200, Boris Brezillon wrote:
> Call pwm_apply_args() just after requesting the PWM device so that the
> polarity and period are initialized according to the information provided
> in pwm_args.
> 
> This is an intermediate state, and pwm_apply_args() should be dropped as
> soon as the atomic PWM infrastructure is in place and the driver makes
> use of it.
> 
> Signed-off-by: Boris Brezillon 
> ---
>  drivers/input/misc/max8997_haptic.c | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/input/misc/max8997_haptic.c 
> b/drivers/input/misc/max8997_haptic.c
> index a806ba3..bf17f65 100644
> --- a/drivers/input/misc/max8997_haptic.c
> +++ b/drivers/input/misc/max8997_haptic.c
> @@ -304,6 +304,12 @@ static int max8997_haptic_probe(struct platform_device 
> *pdev)
>   error);
>   goto err_free_mem;
>   }
> +
> + /*
> +  * FIXME: pwm_apply_args() should be removed when switching to
> +  * the atomic PWM API.
> +  */
> + pwm_apply_args(chip->pwm);

I do not understand. We did not fetch/modify any args, what are we
applying and why? Especially since we saying we want to remove this
later.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 1/5] dt-bindings: add vendor prefix for ILI Technology Corp

2016-10-10 Thread Dmitry Torokhov
On Mon, Oct 10, 2016 at 5:33 PM, Icenowy Zheng  wrote:
> ILI Technology Corp (a.k.a Ilitek, http://www.ilitek.com/index-e.asp ) is a
> company that produces LCD driver ICs and touch screen controller ICs.

Was there patch 3/5? I do not see it in my mailbox.

>
> Signed-off-by: Icenowy Zheng 
> ---
>  Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
> b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index 24c6f65..4d37fdc 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -130,6 +130,7 @@ i2seI2SE GmbH
>  ibmInternational Business Machines (IBM)
>  idtIntegrated Device Technologies, Inc.
>  ifiIngenieurburo Fur Ic-Technologie (I/F/I)
> +ilitek ILI Technologies Corp.
>  imgImagination Technologies Ltd.
>  infineon Infineon Technologies
>  inforceInforce Computing
> --
> 2.10.1
>



-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 3/5] Input: add driver for Ilitek ili2139 touch IC

2016-10-11 Thread Dmitry Torokhov
Hi Icenowy,

On Tue, Oct 11, 2016 at 08:33:57AM +0800, Icenowy Zheng wrote:
> This driver adds support for Ilitek ili2139 touch IC, which is used in
> several Colorfly tablets (for example, Colorfly E708 Q1, which is an
> Allwinner A31s tablet with mainline kernel support).
> 
> Theortically it may support more Ilitek touch ICs, however, only ili2139
> is used in any mainlined device.
> 
> It supports device tree enumeration, with screen resolution and axis
> quirks configurable.
> 
> Signed-off-by: Icenowy Zheng 

Please extend ili210x.c instead of adding brand new driver, they look
very similar.

Thanks.

> ---
>  drivers/input/touchscreen/Kconfig   |  14 ++
>  drivers/input/touchscreen/Makefile  |   1 +
>  drivers/input/touchscreen/ili2139.c | 320 
> 
>  3 files changed, 335 insertions(+)
>  create mode 100644 drivers/input/touchscreen/ili2139.c
> 
> diff --git a/drivers/input/touchscreen/Kconfig 
> b/drivers/input/touchscreen/Kconfig
> index 5079813..bb4d9d2 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -348,6 +348,20 @@ config TOUCHSCREEN_ILI210X
> To compile this driver as a module, choose M here: the
> module will be called ili210x.
>  
> +config TOUCHSCREEN_ILI2139
> + tristate "Ilitek ILI2139 based touchscreen"
> + depends on I2C
> + depends on OF
> + help
> +   Say Y here if you have a ILI2139 based touchscreen
> +   controller. Such kind of chipsets can be found in several
> +   Colorfly tablets.
> +
> +   If unsure, say N.
> +
> +   To compile this driver as a module, choose M here; the
> +   module will be called ili2139.
> +
>  config TOUCHSCREEN_IPROC
>   tristate "IPROC touch panel driver support"
>   depends on ARCH_BCM_IPROC || COMPILE_TEST
> diff --git a/drivers/input/touchscreen/Makefile 
> b/drivers/input/touchscreen/Makefile
> index 81b8645..930b5e2 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -40,6 +40,7 @@ obj-$(CONFIG_TOUCHSCREEN_EGALAX_SERIAL) += 
> egalax_ts_serial.o
>  obj-$(CONFIG_TOUCHSCREEN_FUJITSU)+= fujitsu_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_GOODIX) += goodix.o
>  obj-$(CONFIG_TOUCHSCREEN_ILI210X)+= ili210x.o
> +obj-$(CONFIG_TOUCHSCREEN_ILI2139)+= ili2139.o
>  obj-$(CONFIG_TOUCHSCREEN_IMX6UL_TSC) += imx6ul_tsc.o
>  obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o
>  obj-$(CONFIG_TOUCHSCREEN_INTEL_MID)  += intel-mid-touch.o
> diff --git a/drivers/input/touchscreen/ili2139.c 
> b/drivers/input/touchscreen/ili2139.c
> new file mode 100644
> index 000..65c2dea
> --- /dev/null
> +++ b/drivers/input/touchscreen/ili2139.c
> @@ -0,0 +1,320 @@
> +/* -
> + * Copyright (C) 2016, Icenowy Zheng 
> + *
> + * Derived from:
> + *  ili210x.c
> + *  Copyright (C) Olivier Sobrie 
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + * -
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define DEFAULT_POLL_PERIOD  20
> +
> +#define MAX_TOUCHES  10
> +#define COMPATIBLE_TOUCHES   2
> +
> +/* Touchscreen commands */
> +#define REG_TOUCHDATA0x10
> +#define REG_TOUCHSUBDATA 0x11
> +#define REG_PANEL_INFO   0x20
> +#define REG_FIRMWARE_VERSION 0x40
> +#define REG_PROTO_VERSION0x42
> +
> +#define SUBDATA_STATUS_TOUCH_POINT   0x80
> +#define SUBDATA_STATUS_RELEASE_POINT 0x00
> +
> +struct finger {
> + u8 x_low;
> + u8 x_high;
> + u8 y_low;
> + u8 y_high;
> +} __packed;
> +
> +struct touchdata {
> + u8 length;
> + struct finger finger[COMPATIBLE_TOUCHES];
> +} __packed;
> +
> +struct touch_subdata {
> + u8 status;
> + struct finger finger;
> +} __packed;
> +
> +struct panel_info {
> + struct finger finger_max;
> + u8 xchannel_num;
> + u8 ychannel_num;
> +} __packed;
> +
> +struct firmware_version {
> + u8 id;
> + u8 major;
> + u8 minor;
> +} __packed;
> +
> +struct ili2139 {
> + struct i2c_client *client;
> + struct input_dev *input;
> + unsigned int poll_period;
> + struct delayed_work dwork;
> + struct touchscreen_properties prop;
> + int slots[MAX_TOUCHES];
> + int ids[MAX_TOUCHES];
> +

[linux-sunxi] Re: [PATCH 3/5] Input: add driver for Ilitek ili2139 touch IC

2016-10-11 Thread Dmitry Torokhov
On Wed, Oct 12, 2016 at 02:34:01AM +0800, Icenowy Zheng wrote:
> 
> 
> 12.10.2016, 01:40, "Dmitry Torokhov" <dmitry.torok...@gmail.com>:
> > Hi Icenowy,
> >
> > On Tue, Oct 11, 2016 at 08:33:57AM +0800, Icenowy Zheng wrote:
> >>  This driver adds support for Ilitek ili2139 touch IC, which is used in
> >>  several Colorfly tablets (for example, Colorfly E708 Q1, which is an
> >>  Allwinner A31s tablet with mainline kernel support).
> >>
> >>  Theortically it may support more Ilitek touch ICs, however, only ili2139
> >>  is used in any mainlined device.
> >>
> >>  It supports device tree enumeration, with screen resolution and axis
> >>  quirks configurable.
> >>
> >>  Signed-off-by: Icenowy Zheng <icen...@aosc.xyz>
> >
> > Please extend ili210x.c instead of adding brand new driver, they look
> > very similar.
> >
> > Thanks.
> 
> The driver is too old, lack of maintaince and needs some platform data hacks.
> (At least makes it not capable to be used on current ARM devices, as they're
> described with device tree)

There are many drivers that can do both platform and dt-setup.

> 
> Maybe I will rename the new driver modified by me to ili210x, add support for
> the old protocol (but I have no chips to test it), and drop the old ili210x.
> (This driver is capable of dt probing, and uses devm_ functions)

You can add "racy on removal" to the list (you need to take care your
work is canceled at right times, and canceling it before interrupt is
freed is not the right time as interrupt might fire and the work get
scheduled again). Also I think your driver is essentially working in
polling mode because you always reschedule the delayed work.

No, like I said, please work with existing driver, adding DT support and
support for the newer version of the protocol.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH v3 05/11] Documentation: DT: bindings: input: touschcreen: remove sun4i documentation

2017-04-03 Thread Dmitry Torokhov
On Wed, Mar 29, 2017 at 08:58:26AM +0100, Lee Jones wrote:
> On Tue, 21 Mar 2017, Quentin Schulz wrote:
> 
> > This patch removes the sun4i touchscreen controller binding
> > documentation since it has been merged with the sun4i GPADC binding
> > documentation.
> > 
> > Signed-off-by: Quentin Schulz <quentin.sch...@free-electrons.com>
> > Acked-by: Rob Herring <r...@kernel.org>
> > ---
> > 
> > added in v2
> > 
> >  .../bindings/input/touchscreen/sun4i.txt   | 38 
> > --
> 
> Just an Input Ack missing here.

Acked-by: Dmitry Torokhov <dmitry.torok...@gmail.com>

> 
> >  1 file changed, 38 deletions(-)
> >  delete mode 100644 
> > Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt 
> > b/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
> > deleted file mode 100644
> > index 89abecd..000
> > --- a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
> > +++ /dev/null
> > @@ -1,38 +0,0 @@
> > -sun4i resistive touchscreen controller
> > ---
> > -
> > -Required properties:
> > - - compatible: "allwinner,sun4i-a10-ts", "allwinner,sun5i-a13-ts" or
> > -   "allwinner,sun6i-a31-ts"
> > - - reg: mmio address range of the chip
> > - - interrupts: interrupt to which the chip is connected
> > - - #thermal-sensor-cells: shall be 0
> > -
> > -Optional properties:
> > - - allwinner,ts-attached: boolean indicating that an actual touchscreen
> > -  is attached to the controller
> > - - allwinner,tp-sensitive-adjust : integer (4 bits)
> > -  adjust sensitivity of pen down detection
> > -  between 0 (least sensitive) and 15
> > -  (defaults to 15)
> > - - allwinner,filter-type: integer (2 bits)
> > -  select median and averaging filter
> > -  samples used for median / averaging filter
> > -  0: 4/2
> > -  1: 5/3
> > -  2: 8/4
> > -  3: 16/8
> > -  (defaults to 1)
> > -
> > -Example:
> > -
> > -   rtp: rtp@01c25000 {
> > -   compatible = "allwinner,sun4i-a10-ts";
> > -   reg = <0x01c25000 0x100>;
> > -   interrupts = <29>;
> > -   allwinner,ts-attached;
> > -   #thermal-sensor-cells = <0>;
> > -   /* sensitive/noisy touch panel */
> > -   allwinner,tp-sensitive-adjust = <0>;
> > -   allwinner,filter-type = <3>;
> > -   };
> 
> -- 
> Lee Jones
> Linaro STMicroelectronics Landing Team Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH 6/9] Input: goodix - Add vcc-supply regulator support

2018-12-03 Thread Dmitry Torokhov
On Mon, Dec 03, 2018 at 03:45:44PM +0530, Jagan Teki wrote:
> vcc-supply property is need for some Goodix CTP controller like GT5663
> where 3.3V external pull-up regulator connected via controller VCC pin.
> 
> So, enable the regulator for those it attached the vcc-supply.
> 
> Signed-off-by: Jagan Teki 
> ---
>  drivers/input/touchscreen/goodix.c | 39 ++
>  1 file changed, 34 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/goodix.c 
> b/drivers/input/touchscreen/goodix.c
> index f2d9c2c41885..7adcf1491609 100644
> --- a/drivers/input/touchscreen/goodix.c
> +++ b/drivers/input/touchscreen/goodix.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -47,6 +48,7 @@ struct goodix_ts_data {
>   struct touchscreen_properties prop;
>   unsigned int max_touch_num;
>   unsigned int int_trigger_type;
> + struct regulator *vcc;
>   struct gpio_desc *gpiod_int;
>   struct gpio_desc *gpiod_rst;
>   u16 id;
> @@ -58,6 +60,7 @@ struct goodix_ts_data {
>  
>  #define GOODIX_GPIO_INT_NAME "irq"
>  #define GOODIX_GPIO_RST_NAME "reset"
> +#define GOODIX_VCC_CTP_NAME  "vcc"
>  
>  #define GOODIX_MAX_HEIGHT4096
>  #define GOODIX_MAX_WIDTH 4096
> @@ -525,12 +528,24 @@ static int goodix_get_gpio_config(struct goodix_ts_data 
> *ts)
>  {
>   int error;
>   struct device *dev;
> + struct regulator *regulator;
>   struct gpio_desc *gpiod;
>  
>   if (!ts->client)
>   return -EINVAL;
>   dev = >client->dev;
>  
> + regulator = devm_regulator_get(dev, GOODIX_VCC_CTP_NAME);
> + if (IS_ERR(regulator)) {
> + error = PTR_ERR(regulator);
> + if (error != -EPROBE_DEFER)
> + dev_err(dev, "Failed to get vcc regulator: %d\n",
> + error);
> + return error;
> + }
> +
> + ts->vcc = regulator;
> +
>   /* Get the interrupt GPIO pin number */
>   gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_INT_NAME, GPIOD_IN);
>   if (IS_ERR(gpiod)) {
> @@ -786,25 +801,34 @@ static int goodix_ts_probe(struct i2c_client *client,
>   if (error)
>   return error;
>  
> + /* power the controller */
> + if (ts->vcc) {

ts->vcc is never NULL.

> + error = regulator_enable(ts->vcc);
> + if (error) {
> + dev_err(>dev, "Controller fail to enable 
> vcc\n");
> + return error;
> + }
> + }
> +
>   if (ts->gpiod_int && ts->gpiod_rst) {
>   /* reset the controller */
>   error = goodix_reset(ts);
>   if (error) {
>   dev_err(>dev, "Controller reset failed.\n");
> - return error;
> + goto error;
>   }
>   }
>  
>   error = goodix_i2c_test(client);
>   if (error) {
>   dev_err(>dev, "I2C communication failure: %d\n", error);
> - return error;
> + goto error;
>   }
>  
>   error = goodix_read_version(ts);
>   if (error) {
>   dev_err(>dev, "Read version failed.\n");
> - return error;
> + goto error;
>   }
>  
>   ts->chip = goodix_get_chip_data(ts->id);
> @@ -823,17 +847,22 @@ static int goodix_ts_probe(struct i2c_client *client,
>   dev_err(>dev,
>   "Failed to invoke firmware loader: %d\n",
>   error);
> - return error;
> + goto error;
>   }
>  
>   return 0;
>   } else {
>   error = goodix_configure_dev(ts);
>   if (error)
> - return error;
> + goto error;
>   }
>  
>   return 0;
> +
> +error:
> + if (ts->vcc)
> + regulator_disable(ts->vcc);

Same here.

> + return error;
>  }
>  
>  static int goodix_ts_remove(struct i2c_client *client)

You need to disable regulator on removal as well.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH RESEND v4 1/4] input: sun4i-a10-lradc-keys: Add support for A83T

2019-04-04 Thread Dmitry Torokhov
On Wed, Mar 27, 2019 at 03:33:36AM +0100, meg...@megous.com wrote:
> From: Ziping Chen 
> 
> Allwinner A83T SoC has a low res adc like the one in Allwinner A10 SoC,
> however, the A10 SoC's vref of lradc internally is divided by 2/3 and
> the A83T SoC's vref of lradc internally is divided by 3/4, thus add
> a hardware variant for it to be compatible with various devices.
> 
> Signed-off-by: Ziping Chen 
> Acked-by: Maxime Ripard 

Applied, this and binding patch; the dts changes should go through other
relevant trees I believe.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[linux-sunxi] Re: [PATCH] input: sun4i-lradc-keys: Add wakup support

2019-10-28 Thread Dmitry Torokhov
On Tue, Oct 29, 2019 at 12:56:26AM +0100, Ondřej Jirman wrote:
> Hello Dmitry,
> 
> On Mon, Oct 28, 2019 at 04:38:28PM -0700, Dmitry Torokhov wrote:
> > Hi Ondrej,
> > 
> > On Mon, Oct 28, 2019 at 11:15:02PM +0100, Ondrej Jirman wrote:
> > > Allow the driver to wakeup the system on key press.
> > > 
> > > Signed-off-by: Ondrej Jirman 
> > > ---
> > >  drivers/input/keyboard/sun4i-lradc-keys.c | 22 ++
> > >  1 file changed, 18 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/input/keyboard/sun4i-lradc-keys.c 
> > > b/drivers/input/keyboard/sun4i-lradc-keys.c
> > > index 4a796bed48ac..bba679d7b54b 100644
> > > --- a/drivers/input/keyboard/sun4i-lradc-keys.c
> > > +++ b/drivers/input/keyboard/sun4i-lradc-keys.c
> > > @@ -22,6 +22,8 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > > +#include 
> > >  #include 
> > >  #include 
> > >  
> > > @@ -226,8 +228,7 @@ static int sun4i_lradc_probe(struct platform_device 
> > > *pdev)
> > >  {
> > >   struct sun4i_lradc_data *lradc;
> > >   struct device *dev = >dev;
> > > - int i;
> > > - int error;
> > > + int i, error, irq;
> > >  
> > >   lradc = devm_kzalloc(dev, sizeof(struct sun4i_lradc_data), GFP_KERNEL);
> > >   if (!lradc)
> > > @@ -272,8 +273,13 @@ static int sun4i_lradc_probe(struct platform_device 
> > > *pdev)
> > >   if (IS_ERR(lradc->base))
> > >   return PTR_ERR(lradc->base);
> > >  
> > > - error = devm_request_irq(dev, platform_get_irq(pdev, 0),
> > > -  sun4i_lradc_irq, 0,
> > > + irq = platform_get_irq(pdev, 0);
> > > + if (irq < 0) {
> > > + dev_err(>dev, "Failed to get IRQ\n");
> > > + return irq;
> > > + }
> > > +
> > > + error = devm_request_irq(dev, irq, sun4i_lradc_irq, 0,
> > >"sun4i-a10-lradc-keys", lradc);
> > >   if (error)
> > >   return error;
> > > @@ -282,6 +288,14 @@ static int sun4i_lradc_probe(struct platform_device 
> > > *pdev)
> > >   if (error)
> > >   return error;
> > >  
> > > + device_init_wakeup(dev, true);
> > 
> > I do not think we want to do this unconditionally. Can we maybe key off
> > "wakeup-source" device property.
> 
> Sure thing.
> 
> > > +
> > > + error = dev_pm_set_wake_irq(dev, irq);
> > > + if (error) {
> > > + dev_err(dev, "Could not set wake IRQ\n");
> > > + return error;
> > > + }
> > > +
> > 
> > I wonder if we could teach platform driver core to handle this for us.
> 
> Not sure, some drivers do enable/disable wake_irq by hand in suspend/resume
> callbacks, so it would probably need to be opt-in somehow. I guess calling the
> function like this is one way to make it opt-in.
> 
> The other way may be by passing a flag somewhere, like to
> request_threaded_irq. Did you have something more concrete in mind?

I think it is perfectly fine to continue using enable_irq_wake and
disable_irq_wake from the driver while marking irq as being wake irq
form the core.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20191029001250.GB57214%40dtor-ws.


[linux-sunxi] Re: [PATCH] input: sun4i-lradc-keys: Add wakup support

2019-10-28 Thread Dmitry Torokhov
Hi Ondrej,

On Mon, Oct 28, 2019 at 11:15:02PM +0100, Ondrej Jirman wrote:
> Allow the driver to wakeup the system on key press.
> 
> Signed-off-by: Ondrej Jirman 
> ---
>  drivers/input/keyboard/sun4i-lradc-keys.c | 22 ++
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/keyboard/sun4i-lradc-keys.c 
> b/drivers/input/keyboard/sun4i-lradc-keys.c
> index 4a796bed48ac..bba679d7b54b 100644
> --- a/drivers/input/keyboard/sun4i-lradc-keys.c
> +++ b/drivers/input/keyboard/sun4i-lradc-keys.c
> @@ -22,6 +22,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
>  
> @@ -226,8 +228,7 @@ static int sun4i_lradc_probe(struct platform_device *pdev)
>  {
>   struct sun4i_lradc_data *lradc;
>   struct device *dev = >dev;
> - int i;
> - int error;
> + int i, error, irq;
>  
>   lradc = devm_kzalloc(dev, sizeof(struct sun4i_lradc_data), GFP_KERNEL);
>   if (!lradc)
> @@ -272,8 +273,13 @@ static int sun4i_lradc_probe(struct platform_device 
> *pdev)
>   if (IS_ERR(lradc->base))
>   return PTR_ERR(lradc->base);
>  
> - error = devm_request_irq(dev, platform_get_irq(pdev, 0),
> -  sun4i_lradc_irq, 0,
> + irq = platform_get_irq(pdev, 0);
> + if (irq < 0) {
> + dev_err(>dev, "Failed to get IRQ\n");
> + return irq;
> + }
> +
> + error = devm_request_irq(dev, irq, sun4i_lradc_irq, 0,
>"sun4i-a10-lradc-keys", lradc);
>   if (error)
>   return error;
> @@ -282,6 +288,14 @@ static int sun4i_lradc_probe(struct platform_device 
> *pdev)
>   if (error)
>   return error;
>  
> + device_init_wakeup(dev, true);

I do not think we want to do this unconditionally. Can we maybe key off
"wakeup-source" device property.

> +
> + error = dev_pm_set_wake_irq(dev, irq);
> + if (error) {
> + dev_err(dev, "Could not set wake IRQ\n");
> + return error;
> + }
> +

I wonder if we could teach platform driver core to handle this for us.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20191028233828.GA57214%40dtor-ws.


Re: [linux-sunxi] Re: [PATCH] input: sun4i-lradc-keys: Add wakup support

2019-10-28 Thread Dmitry Torokhov
On Tue, Oct 29, 2019 at 02:45:59AM +0100, Ondřej Jirman wrote:
> On Mon, Oct 28, 2019 at 05:12:50PM -0700, Dmitry Torokhov wrote:
> > On Tue, Oct 29, 2019 at 12:56:26AM +0100, Ondřej Jirman wrote:
> > > On Mon, Oct 28, 2019 at 04:38:28PM -0700, Dmitry Torokhov wrote:
> > > > > +
> > > > > + error = dev_pm_set_wake_irq(dev, irq);
> > > > > + if (error) {
> > > > > + dev_err(dev, "Could not set wake IRQ\n");
> > > > > + return error;
> > > > > + }
> > > > > +
> > > > 
> > > > I wonder if we could teach platform driver core to handle this for us.
> > > 
> > > Not sure, some drivers do enable/disable wake_irq by hand in 
> > > suspend/resume
> > > callbacks, so it would probably need to be opt-in somehow. I guess 
> > > calling the
> > > function like this is one way to make it opt-in.
> > > 
> > > The other way may be by passing a flag somewhere, like to
> > > request_threaded_irq. Did you have something more concrete in mind?
> > 
> > I think it is perfectly fine to continue using enable_irq_wake and
> > disable_irq_wake from the driver while marking irq as being wake irq
> > form the core.
> 
> I see, it looks like irq_set_irq_wake will track the calls via wake_depth
> 
> https://elixir.bootlin.com/linux/latest/source/kernel/irq/manage.c#L714
> 
> But all irqs are not necessarily wake irqs, no? So it still may need to be
> opt-in somehow.

I thought we'd do that for IRQ named "wakeirq" or the very first IRQ if
there is no named IRQ, and when we have the "wakeup-source" property,
similarly to what we do in I2C bus.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20191029041804.GF57214%40dtor-ws.


[linux-sunxi] Re: [PATCH 1/3] input: edt-ft5x06: Add support for regulator

2019-10-28 Thread Dmitry Torokhov
On Tue, Oct 29, 2019 at 01:58:04AM +0100, Ondrej Jirman wrote:
> From: Mylčne Josserand 
> 
> Add the support for enabling optional regulator that may be used as VCC
> source.
> 
> Signed-off-by: Ondrej Jirman 
> Signed-off-by: Mylčne Josserand 

Applied, thank you.

> ---
>  drivers/input/touchscreen/edt-ft5x06.c | 30 ++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/drivers/input/touchscreen/edt-ft5x06.c 
> b/drivers/input/touchscreen/edt-ft5x06.c
> index 5525f1fb1526..d61731c0037d 100644
> --- a/drivers/input/touchscreen/edt-ft5x06.c
> +++ b/drivers/input/touchscreen/edt-ft5x06.c
> @@ -28,6 +28,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #define WORK_REGISTER_THRESHOLD  0x00
>  #define WORK_REGISTER_REPORT_RATE0x08
> @@ -88,6 +89,7 @@ struct edt_ft5x06_ts_data {
>   struct touchscreen_properties prop;
>   u16 num_x;
>   u16 num_y;
> + struct regulator *vcc;
>  
>   struct gpio_desc *reset_gpio;
>   struct gpio_desc *wake_gpio;
> @@ -1036,6 +1038,13 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data 
> *tsdata)
>   }
>  }
>  
> +static void edt_ft5x06_disable_regulator(void *arg)
> +{
> + struct edt_ft5x06_ts_data *data = arg;
> +
> + regulator_disable(data->vcc);
> +}
> +
>  static int edt_ft5x06_ts_probe(struct i2c_client *client,
>const struct i2c_device_id *id)
>  {
> @@ -1064,6 +1073,27 @@ static int edt_ft5x06_ts_probe(struct i2c_client 
> *client,
>  
>   tsdata->max_support_points = chip_data->max_support_points;
>  
> + tsdata->vcc = devm_regulator_get(>dev, "vcc");
> + if (IS_ERR(tsdata->vcc)) {
> + error = PTR_ERR(tsdata->vcc);
> + if (error != -EPROBE_DEFER)
> + dev_err(>dev,
> + "failed to request regulator: %d\n", error);
> + return error;
> + }
> +
> + error = regulator_enable(tsdata->vcc);
> + if (error < 0) {
> + dev_err(>dev, "failed to enable vcc: %d\n", error);
> + return error;
> + }
> +
> + error = devm_add_action_or_reset(>dev,
> +  edt_ft5x06_disable_regulator,
> +  tsdata);
> + if (error)
> + return error;
> +
>   tsdata->reset_gpio = devm_gpiod_get_optional(>dev,
>"reset", GPIOD_OUT_HIGH);
>   if (IS_ERR(tsdata->reset_gpio)) {
> -- 
> 2.23.0
> 

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20191029041233.GD57214%40dtor-ws.


[linux-sunxi] Re: [PATCH 0/3] Add touchscreen support for TBS A711 Tablet

2019-10-28 Thread Dmitry Torokhov
On Tue, Oct 29, 2019 at 01:58:03AM +0100, Ondrej Jirman wrote:
> This is a resurrection of https://lkml.org/lkml/2018/7/25/143
> 
> Compared to v4 of Mylčne's series I've dropped all attempts to
> power off the chip during suspend. This patch just enables the
> regulator during probe and disables it on driver rmmod.
> 
> I've tested the driver with suspend/resume and touching the
> panel resumes my soc.

OK, I guess we can revisit when someone really needs power savings in
suspend...

I folded bindings into the driver change and applied, dts changes should
go through respective tree.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20191029041516.GE57214%40dtor-ws.


[linux-sunxi] Re: [PATCH 3/3] Input: axp20x-pek - Enable wakeup for all AXP variants

2020-01-13 Thread Dmitry Torokhov
Hi Samuel,

On Sun, Jan 12, 2020 at 09:20:32PM -0600, Samuel Holland wrote:
> There are many devices, including several mobile battery-powered
> devices, using other AXP variants as their PMIC. Enable them to use
> the power key as a wakeup source.

Are these X86 or ARM devices? If anything, I'd prefer individual drivers
not declare themselves as wakeup sources unconditionally. With devic
etree we have standard "wakeup-source" property, but I am not quite sure
what's the latest on X86...

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20200113212654.GA47797%40dtor-ws.


[linux-sunxi] Re: [PATCH 2/3] Input: axp20x-pek - Respect userspace wakeup configuration

2020-01-13 Thread Dmitry Torokhov
On Mon, Jan 13, 2020 at 11:48:35AM +0100, Hans de Goede wrote:
> Hi,
> 
> On 13-01-2020 04:20, Samuel Holland wrote:
> > Unlike most other power button drivers, this driver unconditionally
> > enables its wakeup IRQ. It should be using device_may_wakeup() to
> > respect the userspace configuration of wakeup sources.
> > 
> > Because the AXP20x MFD device uses regmap-irq, the AXP20x PEK IRQs are
> > nested off of regmap-irq's threaded interrupt handler. The device core
> > ignores such interrupts, so to actually disable wakeup, we must
> > explicitly disable all non-wakeup interrupts during suspend.
> > 
> > Signed-off-by: Samuel Holland 
> > ---
> >   drivers/input/misc/axp20x-pek.c | 42 -
> >   1 file changed, 41 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/input/misc/axp20x-pek.c 
> > b/drivers/input/misc/axp20x-pek.c
> > index 7d0ee5bececb..38cd4a4aeb65 100644
> > --- a/drivers/input/misc/axp20x-pek.c
> > +++ b/drivers/input/misc/axp20x-pek.c
> > @@ -280,7 +280,7 @@ static int axp20x_pek_probe_input_device(struct 
> > axp20x_pek *axp20x_pek,
> > }
> > if (axp20x_pek->axp20x->variant == AXP288_ID)
> > -   enable_irq_wake(axp20x_pek->irq_dbr);
> > +   device_init_wakeup(>dev, true);
> > return 0;
> >   }
> > @@ -352,6 +352,45 @@ static int axp20x_pek_probe(struct platform_device 
> > *pdev)
> > return 0;
> >   }
> > +#if CONFIG_PM_SLEEP
> 
> As the kbuild test robot pointed out, you need to use #ifdef here.

I prefer __maybe_unused as this gives more compile coverage.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20200113213855.GB47797%40dtor-ws.


[linux-sunxi] Re: [PATCH v2 1/2] Input: axp20x-pek - Respect userspace wakeup configuration

2020-01-21 Thread Dmitry Torokhov
On Wed, Jan 15, 2020 at 11:50:08AM +0100, Hans de Goede wrote:
> Hi,
> 
> On 15-01-2020 06:12, Samuel Holland wrote:
> > Unlike most other power button drivers, this driver unconditionally
> > enables its wakeup IRQ. It should be using device_may_wakeup() to
> > respect the userspace configuration of wakeup sources.
> > 
> > Because the AXP20x MFD device uses regmap-irq, the AXP20x PEK IRQs are
> > nested off of regmap-irq's threaded interrupt handler. The device core
> > ignores such interrupts, so to actually disable wakeup, we must
> > explicitly disable all non-wakeup interrupts during suspend.
> > 
> > Signed-off-by: Samuel Holland 
> 
> Patch looks good to me:
> 
> Reviewed-by: Hans de Goede 

Applied, thank you.

> 
> Regards,
> 
> Hans
> 
> 
> 
> > ---
> >   drivers/input/misc/axp20x-pek.c | 37 -
> >   1 file changed, 36 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/input/misc/axp20x-pek.c 
> > b/drivers/input/misc/axp20x-pek.c
> > index 17c1cca74498..0ace3fe3d7dc 100644
> > --- a/drivers/input/misc/axp20x-pek.c
> > +++ b/drivers/input/misc/axp20x-pek.c
> > @@ -280,7 +280,7 @@ static int axp20x_pek_probe_input_device(struct 
> > axp20x_pek *axp20x_pek,
> > }
> > if (axp20x_pek->axp20x->variant == AXP288_ID)
> > -   enable_irq_wake(axp20x_pek->irq_dbr);
> > +   device_init_wakeup(>dev, true);
> > return 0;
> >   }
> > @@ -352,6 +352,40 @@ static int axp20x_pek_probe(struct platform_device 
> > *pdev)
> > return 0;
> >   }
> > +static int __maybe_unused axp20x_pek_suspend(struct device *dev)
> > +{
> > +   struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
> > +
> > +   /*
> > +* As nested threaded IRQs are not automatically disabled during
> > +* suspend, we must explicitly disable non-wakeup IRQs.
> > +*/
> > +   if (device_may_wakeup(dev)) {
> > +   enable_irq_wake(axp20x_pek->irq_dbf);
> > +   enable_irq_wake(axp20x_pek->irq_dbr);
> > +   } else {
> > +   disable_irq(axp20x_pek->irq_dbf);
> > +   disable_irq(axp20x_pek->irq_dbr);
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> > +static int __maybe_unused axp20x_pek_resume(struct device *dev)
> > +{
> > +   struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
> > +
> > +   if (device_may_wakeup(dev)) {
> > +   disable_irq_wake(axp20x_pek->irq_dbf);
> > +   disable_irq_wake(axp20x_pek->irq_dbr);
> > +   } else {
> > +   enable_irq(axp20x_pek->irq_dbf);
> > +   enable_irq(axp20x_pek->irq_dbr);
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> >   static int __maybe_unused axp20x_pek_resume_noirq(struct device *dev)
> >   {
> > struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
> > @@ -371,6 +405,7 @@ static int __maybe_unused 
> > axp20x_pek_resume_noirq(struct device *dev)
> >   }
> >   static const struct dev_pm_ops axp20x_pek_pm_ops = {
> > +   SET_SYSTEM_SLEEP_PM_OPS(axp20x_pek_suspend, axp20x_pek_resume)
> >   #ifdef CONFIG_PM_SLEEP
> > .resume_noirq = axp20x_pek_resume_noirq,
> >   #endif
> > 
> 

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20200122060419.GD110084%40dtor-ws.


[linux-sunxi] Re: [PATCH v2 2/2] Input: axp20x-pek - Enable wakeup for all AXP variants

2020-01-21 Thread Dmitry Torokhov
On Tue, Jan 14, 2020 at 11:12:53PM -0600, Samuel Holland wrote:
> There are many devices, including several mobile battery-powered
> devices, using other AXP variants as their PMIC. Allow them to use
> the power key as a wakeup source.
> 
> Reviewed-by: Hans de Goede 
> Signed-off-by: Samuel Holland 

Applied, thank you.

> ---
>  drivers/input/misc/axp20x-pek.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
> index 0ace3fe3d7dc..1872607e87c3 100644
> --- a/drivers/input/misc/axp20x-pek.c
> +++ b/drivers/input/misc/axp20x-pek.c
> @@ -279,8 +279,7 @@ static int axp20x_pek_probe_input_device(struct 
> axp20x_pek *axp20x_pek,
>   return error;
>   }
>  
> - if (axp20x_pek->axp20x->variant == AXP288_ID)
> - device_init_wakeup(>dev, true);
> + device_init_wakeup(>dev, true);
>  
>   return 0;
>  }
> -- 
> 2.23.0
> 

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20200122060427.GE110084%40dtor-ws.


[linux-sunxi] Re: [PATCH v2 1/4] dt-bindings: input: gpio-vibrator: Don't require enable-gpios

2020-05-12 Thread Dmitry Torokhov
On Wed, May 13, 2020 at 12:22:02AM +0200, Ondrej Jirman wrote:
> It is possible to turn the motor on/off just by enabling/disabling
> the vcc-supply.
> 
> Signed-off-by: Ondrej Jirman 
> Acked-by: Rob Herring 
> ---
>  Documentation/devicetree/bindings/input/gpio-vibrator.yaml | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/input/gpio-vibrator.yaml 
> b/Documentation/devicetree/bindings/input/gpio-vibrator.yaml
> index 2384465eaa19..c700b640bd53 100644
> --- a/Documentation/devicetree/bindings/input/gpio-vibrator.yaml
> +++ b/Documentation/devicetree/bindings/input/gpio-vibrator.yaml
> @@ -24,7 +24,6 @@ properties:
>  
>  required:
>- compatible
> -  - enable-gpios

Hmm we need at least one of the 2 (gpio and supply). Should we encode it
in the binding?

Also, in the dirver code, I guess we need to switch to have regulator
optional (so we are not given the dummy one) and bail if neither
regulator nor GPIO is found.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20200512225212.GE89269%40dtor-ws.


[linux-sunxi] Re: [PATCH v2 1/4] dt-bindings: input: gpio-vibrator: Don't require enable-gpios

2020-05-12 Thread Dmitry Torokhov
On Wed, May 13, 2020 at 01:05:57AM +0200, Ondřej Jirman wrote:
> On Tue, May 12, 2020 at 03:52:12PM -0700, Dmitry Torokhov wrote:
> > On Wed, May 13, 2020 at 12:22:02AM +0200, Ondrej Jirman wrote:
> > > It is possible to turn the motor on/off just by enabling/disabling
> > > the vcc-supply.
> > > 
> > > Signed-off-by: Ondrej Jirman 
> > > Acked-by: Rob Herring 
> > > ---
> > >  Documentation/devicetree/bindings/input/gpio-vibrator.yaml | 1 -
> > >  1 file changed, 1 deletion(-)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/input/gpio-vibrator.yaml 
> > > b/Documentation/devicetree/bindings/input/gpio-vibrator.yaml
> > > index 2384465eaa19..c700b640bd53 100644
> > > --- a/Documentation/devicetree/bindings/input/gpio-vibrator.yaml
> > > +++ b/Documentation/devicetree/bindings/input/gpio-vibrator.yaml
> > > @@ -24,7 +24,6 @@ properties:
> > >  
> > >  required:
> > >- compatible
> > > -  - enable-gpios
> > 
> > Hmm we need at least one of the 2 (gpio and supply). Should we encode it
> > in the binding?
> 
> Not sure how to encode either one or the other property being required, but
> not both at once.
> 
> Maybe I can add a supply-vibrator compatible to the driver and binding and
> make requirements dependent on the compatible?

Rob is our bindings overlord... I'll defer to him here.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20200512232505.GF89269%40dtor-ws.


[linux-sunxi] Re: [PATCH v4 2/4] input: gpio-vibra: Allow to use vcc-supply alone to control the vibrator

2020-07-30 Thread Dmitry Torokhov
Hi Ondrej,

On Tue, Jul 14, 2020 at 12:23:01PM +0200, Ondrej Jirman wrote:
> Make enable-gpio optional to allow using this driver with boards that
> have vibrator connected to a power supply without intermediate gpio
> based enable circuitry.
> 
> Also avoid a case where neither regulator nor enable gpio is specified,
> and bail out in probe in such a case.
> 
> Signed-off-by: Ondrej Jirman 
> ---
>  drivers/input/misc/gpio-vibra.c | 14 ++
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/misc/gpio-vibra.c b/drivers/input/misc/gpio-vibra.c
> index f79f75595dd7..b3bb7e61ed1d 100644
> --- a/drivers/input/misc/gpio-vibra.c
> +++ b/drivers/input/misc/gpio-vibra.c
> @@ -39,7 +39,7 @@ static int gpio_vibrator_start(struct gpio_vibrator 
> *vibrator)
>   struct device *pdev = vibrator->input->dev.parent;
>   int err;
>  
> - if (!vibrator->vcc_on) {
> + if (vibrator->vcc && !vibrator->vcc_on) {
>   err = regulator_enable(vibrator->vcc);
>   if (err) {
>   dev_err(pdev, "failed to enable regulator: %d\n", err);
> @@ -57,7 +57,7 @@ static void gpio_vibrator_stop(struct gpio_vibrator 
> *vibrator)
>  {
>   gpiod_set_value_cansleep(vibrator->gpio, 0);
>  
> - if (vibrator->vcc_on) {
> + if (vibrator->vcc && vibrator->vcc_on) {
>   regulator_disable(vibrator->vcc);
>   vibrator->vcc_on = false;
>   }
> @@ -112,7 +112,7 @@ static int gpio_vibrator_probe(struct platform_device 
> *pdev)
>   if (!vibrator->input)
>   return -ENOMEM;
>  
> - vibrator->vcc = devm_regulator_get(>dev, "vcc");
> + vibrator->vcc = devm_regulator_get_optional(>dev, "vcc");

I know it is very surprising, but regulator_get_optional does not return
NULL when regulator is not present, but rather ERR_PTR(-ENODEV). You
need to replace it with NULL in the branch below, or change conditions
to !IS_ERR(virbrator->vcc) (and still handle -ENODEV in the branch
below).

>   err = PTR_ERR_OR_ZERO(vibrator->vcc);
>   if (err) {
>   if (err != -EPROBE_DEFER)
> @@ -121,7 +121,8 @@ static int gpio_vibrator_probe(struct platform_device 
> *pdev)
>   return err;
>   }
>  
> - vibrator->gpio = devm_gpiod_get(>dev, "enable", GPIOD_OUT_LOW);
> + vibrator->gpio = devm_gpiod_get_optional(>dev, "enable",
> +  GPIOD_OUT_LOW);
>   err = PTR_ERR_OR_ZERO(vibrator->gpio);
>   if (err) {
>   if (err != -EPROBE_DEFER)
> @@ -130,6 +131,11 @@ static int gpio_vibrator_probe(struct platform_device 
> *pdev)
>   return err;
>   }
>  
> + if (!vibrator->vcc && !vibrator->gpio) {
> + dev_err(>dev, "Neither gpio nor regulator provided\n");
> + return -EINVAL;
> + }
> +
>   INIT_WORK(>play_work, gpio_vibrator_play_work);
>  
>   vibrator->input->name = "gpio-vibrator";
> -- 
> 2.27.0
> 

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/20200730061939.GF1665100%40dtor-ws.


[linux-sunxi] Re: [PATCH] input: sun4i-lradc-keys - Add wakup support

2021-01-03 Thread Dmitry Torokhov
Hi Samuel,

On Sun, Jan 03, 2021 at 04:54:46AM -0600, Samuel Holland wrote:
> From: Ondrej Jirman 
> 
> Allow the driver to wake up the system on key press. Since using the
> LRADC as a wakeup source requires keeping on an additional power domain,
> disable the wakeup source by default.

Why isn't this controlled via DT property? wakeup-source?

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/X/JK3ffFV3s5BigQ%40google.com.


[linux-sunxi] Re: [PATCH v5 05/20] Input: axp20x-pek: Bail out if AXP has no interrupt line connected

2021-01-27 Thread Dmitry Torokhov
Hi Andre,

On Wed, Jan 27, 2021 at 05:24:45PM +, Andre Przywara wrote:
> On at least one board (Orangepi Zero2) the AXP305 PMIC does not have its
> interrupt line connected to the CPU (mostly because the H616 SoC does
> not feature an NMI pin anymore).
> After allowing the AXP driver to proceed without an "interrupts"
> property [1], the axp20x-pek driver crashes with a NULL pointer
> dereference (see below).
> 
> Check for the regmap_irqc member to be not NULL before proceeding with
> probe. This gets normally filled by the call to regmap_add_irq_chip(),
> which we allow to skip now, when the DT node lacks an interrupt
> property.

No, the driver is not the right place to patch this; regmap should be
fixed so it does not crash instead.

Thanks.

-- 
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/linux-sunxi/YBHCF2tWIX4MeMia%40google.com.