Many Palmas PMIC variants have support for power button feature. This
feature depends on certain One Time Program (OTP) and board pull configurations
(POWERHOLD signal). However, on many platforms such as DRA72-evm, OMAP5-uevm,
this may be used to generate input events similar to twl4030-pwrbutton.c
Series is based on v3.17-rc1
Nishanth Menon (2):
doc: dt/bindings: input: introduce palmas power button description
Input: misc: introduce palmas-pwrbutton
.../bindings/input/ti,palmas-pwrbutton.txt | 32 ++
drivers/input/misc/Kconfig | 10 +
drivers/input/misc/Makefile | 1 +
drivers/input/misc/palmas-pwrbutton.c | 313 ++++++++++++++++++++
4 files changed, 356 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/ti,palmas-pwrbutton.txt
create mode 100644 drivers/input/misc/palmas-pwrbutton.c
--
1.7.9.5
Many palmas family of PMICs have support for interrupt based power
button. This allows the device to notify the processor of external
push button events over the shared palmas interrupt.
Document the hardware support for the same.
Signed-off-by: Nishanth Menon <nm@ti.com>
---
.../bindings/input/ti,palmas-pwrbutton.txt | 32 ++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/ti,palmas-pwrbutton.txt
@@ -0,0 +1,32 @@+Texas Instruments Palmas family power button module++This module is part of the Palmas family of PMICs. For more details+about the whole chip see:+Documentation/devicetree/bindings/mfd/palmas.txt.++This module provides a simple power button event via an Interrupt.++Required properties:+- compatible: should be one of the following+ - "ti,palmas-pwrbutton": For Palmas compatible power on button+- interrupt-parent: Parent interrupt device, must be handle of palmas node.+- interrupts: Interrupt number of power button submodule on device.++Optional Properties:++- ti,palmas-long-press-seconds: Duration in seconds which the power+ button should be kept pressed for Palmas to power off automatically.+ NOTE: This depends on OTP support and POWERHOLD signal configuration+ on platform.++Example:++&palmas {+ palmas_pwr_button: pwrbutton {+ compatible = "ti,palmas-pwrbutton";+ interrupt-parent = <&tps659038>;+ interrupts = <1 IRQ_TYPE_NONE>;+ wakeup-source;+ ti,palmas-long-press-seconds = <12>;+ };+};
Many palmas family of PMICs have support for interrupt based power
button. This allows the device to notify the processor of external
push button events over the shared palmas interrupt. However, this
event is generated only during a "press" operation. Software is
supposed to poll(sigh!) for detecting a release event.
The PMIC also supports ability to power off independent of the
software decisions when the button is pressed for a long duration if
the PMIC is appropriately configured on the platform.
Even though the function is similar to twl4030_pwrbutton, it is
substantially different in operation to belong to a new driver of it's
own.
Based on original work done by Girish S Ghongdemath [off-list ref]
Signed-off-by: Nishanth Menon <nm@ti.com>
---
drivers/input/misc/Kconfig | 10 ++
drivers/input/misc/Makefile | 1 +
drivers/input/misc/palmas-pwrbutton.c | 314 +++++++++++++++++++++++++++++++++
3 files changed, 325 insertions(+)
create mode 100644 drivers/input/misc/palmas-pwrbutton.c
Hi NIshanth,
On Mon, Aug 18, 2014 at 03:13:30PM -0500, Nishanth Menon wrote:
quoted hunk
Many palmas family of PMICs have support for interrupt based power
button. This allows the device to notify the processor of external
push button events over the shared palmas interrupt. However, this
event is generated only during a "press" operation. Software is
supposed to poll(sigh!) for detecting a release event.
The PMIC also supports ability to power off independent of the
software decisions when the button is pressed for a long duration if
the PMIC is appropriately configured on the platform.
Even though the function is similar to twl4030_pwrbutton, it is
substantially different in operation to belong to a new driver of it's
own.
Based on original work done by Girish S Ghongdemath [off-list ref]
Signed-off-by: Nishanth Menon <nm@ti.com>
---
drivers/input/misc/Kconfig | 10 ++
drivers/input/misc/Makefile | 1 +
drivers/input/misc/palmas-pwrbutton.c | 314 +++++++++++++++++++++++++++++++++
3 files changed, 325 insertions(+)
create mode 100644 drivers/input/misc/palmas-pwrbutton.c
@@ -0,0 +1,314 @@+/*+*TexasInstruments'PalmasPowerButtonInputDriver+*+*Copyright(C)2012-2014TexasInstrumentsIncorporated-http://www.ti.com/+*GirishSGhongdemath+*NishanthMenon+*+*Thisprogramisfreesoftware;youcanredistributeitand/ormodify+*itunderthetermsoftheGNUGeneralPublicLicenseversion2as+*publishedbytheFreeSoftwareFoundation.+*+*Thisprogramisdistributed"as is"WITHOUTANYWARRANTYofany+*kind,whetherexpressorimplied;withouteventheimpliedwarranty+*ofMERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe+*GNUGeneralPublicLicenseformoredetails.+*/+#include<linux/init.h>+#include<linux/input.h>+#include<linux/interrupt.h>+#include<linux/kernel.h>+#include<linux/mfd/palmas.h>+#include<linux/module.h>+#include<linux/of.h>+#include<linux/platform_device.h>+#include<linux/reboot.h>+#include<linux/slab.h>++#define PALMAS_LPK_TIME_MASK 0x0c+#define PALMAS_PWR_KEY_PRESS 0x01+#define PALMAS_PWR_KEY_Q_TIME_MS 20++/**+*structpalmas_pwron-Palmaspowerondata+*@palmas:pointertopalmasdevice+*@input_dev:pointertoinputdevice+*@irq:irqthatwearehookedonto+*@input_work:workfordetectingreleaseofkey+*@current_state:keycurrentstate+*@key_recheck_ms:durationforrecheckofkey(inmilli-seconds)+*/+structpalmas_pwron{+structpalmas*palmas;+structinput_dev*input_dev;+intirq;+structdelayed_workinput_work;+intcurrent_state;+u32key_recheck_ms;+};++/**+*structpalmas_pwron_config-configurationofpalmaspoweron+*@long_press_time_val:valueforlongpressh/wshutdownevent+*/+structpalmas_pwron_config{+u8long_press_time_val;+};++/**+*palmas_get_pwr_state()-readbuttonstate+*@pwron:pointertopwronstruct+*/+staticintpalmas_get_pwr_state(structpalmas_pwron*pwron)+{+structinput_dev*input_dev=pwron->input_dev;+structdevice*dev=input_dev->dev.parent;+unsignedintreg=0;+intret;++ret=palmas_read(pwron->palmas,PALMAS_INTERRUPT_BASE,+PALMAS_INT1_LINE_STATE,®);+if(ret){+dev_err(dev,"%s:Cannot read palmas PWRON status(%d)\n",+__func__,ret);+returnret;+}++/* PWRON line state is BIT(1) of the register */+returnreg&BIT(1)?0:PALMAS_PWR_KEY_PRESS;+}++/**+*palmas_power_button_work()-Detectsthebuttonreleaseevent+*@work:workitemtodetectbuttonrelease+*/+staticvoidpalmas_power_button_work(structwork_struct*work)+{+structpalmas_pwron*pwron=container_of((structdelayed_work*)work,+structpalmas_pwron,+input_work);+structinput_dev*input_dev=pwron->input_dev;+intnext_state;++next_state=palmas_get_pwr_state(pwron);+if(next_state<0)+return;++/*+*Ifthestatedidnotchangethenscheduleaworkitemtocheckthe+*statusofthepowerbuttonline+*/+if(next_state==pwron->current_state){+schedule_delayed_work(&pwron->input_work,+msecs_to_jiffies(pwron->key_recheck_ms));+return;+}++pwron->current_state=next_state;+input_report_key(input_dev,KEY_POWER,pwron->current_state);+input_sync(input_dev);+}++/**+*pwron_irq()-buttonpressisr+*@irq:irq+*@palmas_pwron:pwronstruct+*/+staticirqreturn_tpwron_irq(intirq,void*palmas_pwron)+{+structpalmas_pwron*pwron=palmas_pwron;+structinput_dev*input_dev=pwron->input_dev;++cancel_delayed_work_sync(&pwron->input_work);++pwron->current_state=PALMAS_PWR_KEY_PRESS;++input_report_key(input_dev,KEY_POWER,pwron->current_state);+pm_wakeup_event(input_dev->dev.parent,0);+input_sync(input_dev);++schedule_delayed_work(&pwron->input_work,0);
Instead of cancel/schedule use mod_delayed_work. BTW, why do you need to
schedule immediately instead of waiting key_recheck_ms? Also, are there any
concerns about need to debounce?
I am confused about this code sequence. Why do we get IRQ, then set up wakeup,
and then request irq? Normally you get irq number, and then you request it, and
then do other stuff.
+ if (ret < 0) {
+ dev_err(dev, "Can't get IRQ for pwron: %d\n", ret);
+ return ret;
+ }
+
+ enable_irq_wake(irq);
With devm you do not need to unregister input device. However this has problem:
what will happen if interrupt arrives here and we schedule workqueue? You need
free interrupt then cancel work and then free input device. Similar needs to be
done in probe(). I'd recommend not use devm_* here as you need to manually
unwind anyway.
+
+ return 0;
+}
+
+#ifdef CONFIG_PM
+/**
+ * palmas_pwron_suspend() - suspend handler
+ * @dev: power button device
+ *
+ * Cancel all pending work items for the power button
+ */
+static int palmas_pwron_suspend(struct device *dev)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct palmas_pwron *pwron = platform_get_drvdata(pdev);
+
+ cancel_delayed_work_sync(&pwron->input_work);
+
+ return 0;
+}
+
+static UNIVERSAL_DEV_PM_OPS(palmas_pwron_pm, palmas_pwron_suspend, NULL, NULL);
On Mon, Aug 18, 2014 at 03:13:29PM -0500, Nishanth Menon wrote:
quoted hunk
Many palmas family of PMICs have support for interrupt based power
button. This allows the device to notify the processor of external
push button events over the shared palmas interrupt.
Document the hardware support for the same.
Signed-off-by: Nishanth Menon <nm@ti.com>
---
.../bindings/input/ti,palmas-pwrbutton.txt | 32 ++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/ti,palmas-pwrbutton.txt
@@ -0,0 +1,32 @@+Texas Instruments Palmas family power button module++This module is part of the Palmas family of PMICs. For more details+about the whole chip see:+Documentation/devicetree/bindings/mfd/palmas.txt.++This module provides a simple power button event via an Interrupt.++Required properties:+- compatible: should be one of the following+ - "ti,palmas-pwrbutton": For Palmas compatible power on button+- interrupt-parent: Parent interrupt device, must be handle of palmas node.+- interrupts: Interrupt number of power button submodule on device.++Optional Properties:++- ti,palmas-long-press-seconds: Duration in seconds which the power+ button should be kept pressed for Palmas to power off automatically.+ NOTE: This depends on OTP support and POWERHOLD signal configuration+ on platform.
Only a few values are valid for this property, I think you should mention that.
Instead of cancel/schedule use mod_delayed_work. BTW, why do you need to
schedule immediately instead of waiting key_recheck_ms? Also, are there any
Good point, I had missed these. Will fix.
concerns about need to debounce?
I believe PMIC already takes care of debounce, let me see if there are
configuration registers possible. if yes, I think it might be nice to
add in.
[...]
I am confused about this code sequence. Why do we get IRQ, then set up wakeup,
and then request irq? Normally you get irq number, and then you request it, and
then do other stuff.
Uggh.. right.. will fix.
quoted
+ if (ret < 0) {
+ dev_err(dev, "Can't get IRQ for pwron: %d\n", ret);
+ return ret;
+ }
+
+ enable_irq_wake(irq);
Shouldn't this be in suspend callback?
yes, it should have been.. my bad.. :( thanks for catching it.
With devm you do not need to unregister input device. However this has problem:
what will happen if interrupt arrives here and we schedule workqueue? You need
free interrupt then cancel work and then free input device. Similar needs to be
done in probe(). I'd recommend not use devm_* here as you need to manually
unwind anyway.
True. I will fix these as well.
quoted
+
+ return 0;
+}
+
+#ifdef CONFIG_PM
+/**
+ * palmas_pwron_suspend() - suspend handler
+ * @dev: power button device
+ *
+ * Cancel all pending work items for the power button
+ */
+static int palmas_pwron_suspend(struct device *dev)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct palmas_pwron *pwron = platform_get_drvdata(pdev);
+
+ cancel_delayed_work_sync(&pwron->input_work);
+
+ return 0;
+}
+
+static UNIVERSAL_DEV_PM_OPS(palmas_pwron_pm, palmas_pwron_suspend, NULL, NULL);
On Mon, Aug 18, 2014 at 03:13:29PM -0500, Nishanth Menon wrote:
quoted
Many palmas family of PMICs have support for interrupt based power
button. This allows the device to notify the processor of external
push button events over the shared palmas interrupt.
Document the hardware support for the same.
Signed-off-by: Nishanth Menon <nm@ti.com>
---
.../bindings/input/ti,palmas-pwrbutton.txt | 32 ++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/ti,palmas-pwrbutton.txt
@@ -0,0 +1,32 @@+Texas Instruments Palmas family power button module++This module is part of the Palmas family of PMICs. For more details+about the whole chip see:+Documentation/devicetree/bindings/mfd/palmas.txt.++This module provides a simple power button event via an Interrupt.++Required properties:+- compatible: should be one of the following+ - "ti,palmas-pwrbutton": For Palmas compatible power on button+- interrupt-parent: Parent interrupt device, must be handle of palmas node.+- interrupts: Interrupt number of power button submodule on device.++Optional Properties:++- ti,palmas-long-press-seconds: Duration in seconds which the power+ button should be kept pressed for Palmas to power off automatically.+ NOTE: This depends on OTP support and POWERHOLD signal configuration+ on platform.
Only a few values are valid for this property, I think you should mention that.
Why none? Can we specify appropriate trigger here instead of hard-coding in the
driver?
Following the convention as in
Documentation/devicetree/bindings/mfd/palmas.txt - for whatever reason
we went with interrupt-cells = <2> when palmas interrupt configuration
was hardcoded in the chip(not reconfigurable). I believe it was level,
will check and update the example here.
quoted
+ wakeup-source;
What handles this attribute? I do not see it handled in the driver.
we dont explicitly need to in the driver, it was meant to indicate that
this is a wakeup source, but in reality, it is a palmas PMIC which is
the wakeup source.. so, will drop this.
Many Palmas PMIC variants have support for power button feature. This
feature depends on certain One Time Program (OTP) and board pull
configurations (POWERHOLD signal). However, on many platforms such
as DRA72-evm, OMAP5-uevm, this may be used to generate input events
similar to twl4030-pwrbutton.c
Series is based on v3.17-rc1
V2 of the series incorporating comments from http://marc.info/?l=linux-input&m=140839287431882&w=2
Nishanth Menon (2):
doc: dt/bindings: input: introduce palmas power button description
Input: misc: introduce palmas-pwrbutton
.../bindings/input/ti,palmas-pwrbutton.txt | 36 ++
drivers/input/misc/Kconfig | 10 +
drivers/input/misc/Makefile | 1 +
drivers/input/misc/palmas-pwrbutton.c | 356 ++++++++++++++++++++
4 files changed, 403 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/ti,palmas-pwrbutton.txt
create mode 100644 drivers/input/misc/palmas-pwrbutton.c
--
1.7.9.5
Many palmas family of PMICs have support for interrupt based power
button. This allows the device to notify the processor of external
push button events over the shared palmas interrupt.
Document the hardware support for the same.
Signed-off-by: Nishanth Menon <nm@ti.com>
---
Changes in v2:
- Added debounce description for palmas variants like TWL6037 that
actually allow it.
- Review comments incorportated.
V1: https://patchwork.kernel.org/patch/4739061/
.../bindings/input/ti,palmas-pwrbutton.txt | 36 ++++++++++++++++++++
1 file changed, 36 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/ti,palmas-pwrbutton.txt
@@ -0,0 +1,36 @@+Texas Instruments Palmas family power button module++This module is part of the Palmas family of PMICs. For more details+about the whole chip see:+Documentation/devicetree/bindings/mfd/palmas.txt.++This module provides a simple power button event via an Interrupt.++Required properties:+- compatible: should be one of the following+ - "ti,palmas-pwrbutton": For Palmas compatible power on button+- interrupt-parent: Parent interrupt device, must be handle of palmas node.+- interrupts: Interrupt number of power button submodule on device.++Optional Properties:++- ti,palmas-long-press-seconds: Duration in seconds which the power+ button should be kept pressed for Palmas to power off automatically.+ NOTE: This depends on OTP support and POWERHOLD signal configuration+ on platform. Valid values are 6, 8, 10 and 12.+- ti,palmas-pwron-debounce-milli-seconds: Duration in milliseconds+ which the power button should be kept pressed for Palmas to register+ a press for debouncing purposes. NOTE: This depends on specific+ Palmas variation capability. Valid values are 15, 100, 500 and 1000.++Example:++&palmas {+ palmas_pwr_button: pwrbutton {+ compatible = "ti,palmas-pwrbutton";+ interrupt-parent = <&tps659038>;+ interrupts = <1 IRQ_TYPE_EDGE_FALLING>;+ ti,palmas-long-press-seconds = <12>;+ ti,palmas-pwron-debounce-milli-seconds = <15>;+ };+};
Many palmas family of PMICs have support for interrupt based power
button. This allows the device to notify the processor of external
push button events over the shared palmas interrupt. However, this
event is generated only during a "press" operation. Software is
supposed to poll(sigh!) for detecting a release event.
The PMIC also supports ability to power off independent of the
software decisions when the button is pressed for a long duration if
the PMIC is appropriately configured on the platform.
Even though the function is similar to twl4030_pwrbutton, it is
substantially different in operation to belong to a new driver of it's
own.
Based on original work done by Girish S Ghongdemath [off-list ref]
Signed-off-by: Nishanth Menon <nm@ti.com>
---
Changes in v2:
- review comments incorporated
- debounce programming for TWL variants that actually support it.
V1: https://patchwork.kernel.org/patch/4739041/
drivers/input/misc/Kconfig | 10 +
drivers/input/misc/Makefile | 1 +
drivers/input/misc/palmas-pwrbutton.c | 356 +++++++++++++++++++++++++++++++++
3 files changed, 367 insertions(+)
create mode 100644 drivers/input/misc/palmas-pwrbutton.c
From: Murphy, Dan <hidden> Date: 2014-08-21 16:59:58
On 08/21/2014 11:04 AM, Menon, Nishanth wrote:
quoted hunk
Many palmas family of PMICs have support for interrupt based power
button. This allows the device to notify the processor of external
push button events over the shared palmas interrupt. However, this
event is generated only during a "press" operation. Software is
supposed to poll(sigh!) for detecting a release event.
The PMIC also supports ability to power off independent of the
software decisions when the button is pressed for a long duration if
the PMIC is appropriately configured on the platform.
Even though the function is similar to twl4030_pwrbutton, it is
substantially different in operation to belong to a new driver of it's
own.
Based on original work done by Girish S Ghongdemath [off-list ref]
Signed-off-by: Nishanth Menon <nm@ti.com>
---
Changes in v2:
- review comments incorporated
- debounce programming for TWL variants that actually support it.
V1: https://patchwork.kernel.org/patch/4739041/
drivers/input/misc/Kconfig | 10 +
drivers/input/misc/Makefile | 1 +
drivers/input/misc/palmas-pwrbutton.c | 356 +++++++++++++++++++++++++++++++++
3 files changed, 367 insertions(+)
create mode 100644 drivers/input/misc/palmas-pwrbutton.c
I don't see any reboot calls made do we need this?
+#include <linux/slab.h>
+
+#define PALMAS_LPK_TIME_MASK 0x0c
+#define PALMAS_PWRON_DEBOUNCE_MASK 0x03
+#define PALMAS_PWR_KEY_PRESS 0x01
+#define PALMAS_PWR_KEY_Q_TIME_MS 20
+
+/**
+ * struct palmas_pwron - Palmas power on data
+ * @palmas: pointer to palmas device
+ * @input_dev: pointer to input device
+ * @irq: irq that we are hooked on to
+ * @input_work: work for detecting release of key
+ * @current_state: key current state
+ * @key_recheck_ms: duration for recheck of key (in milli-seconds)
+ */
+struct palmas_pwron {
+ struct palmas *palmas;
+ struct input_dev *input_dev;
+ int irq;
+ struct delayed_work input_work;
+ int current_state;
+ u32 key_recheck_ms;
+};
+
+/**
+ * struct palmas_pwron_config - configuration of palmas power on
+ * @long_press_time_val: value for long press h/w shutdown event
+ * @pwron_debounce_val: value for debounce of power button
+ */
+struct palmas_pwron_config {
+ u8 long_press_time_val;
+ u8 pwron_debounce_val;
+};
+
+/**
+ * palmas_get_pwr_state() - read button state
+ * @pwron: pointer to pwron struct
+ *
+ * Return: 0 for no press, PALMAS_PWR_KEY_PRESS for keypress
+ * and on error, appropriate error value.
+ */
+static int palmas_get_pwr_state(struct palmas_pwron *pwron)
+{
+ struct input_dev *input_dev = pwron->input_dev;
+ struct device *dev = input_dev->dev.parent;
+ unsigned int reg = 0;
+ int ret;
+
+ ret = palmas_read(pwron->palmas, PALMAS_INTERRUPT_BASE,
+ PALMAS_INT1_LINE_STATE, ®);
+ if (ret) {
+ dev_err(dev, "%s:Cannot read palmas PWRON status(%d)\n",
+ __func__, ret);
+ return ret;
+ }
+
+ /* PWRON line state is BIT(1) of the register */
+ return reg & BIT(1) ? 0 : PALMAS_PWR_KEY_PRESS;
+}
+
+/**
+ * palmas_power_button_work() - Detects the button release event
+ * @work: work item to detect button release
+ */
+static void palmas_power_button_work(struct work_struct *work)
+{
+ struct palmas_pwron *pwron = container_of((struct delayed_work *)work,
+ struct palmas_pwron,
+ input_work);
+ struct input_dev *input_dev = pwron->input_dev;
+ int next_state;
+
+ next_state = palmas_get_pwr_state(pwron);
+ if (next_state < 0)
+ return;
+
+ /*
+ * If the state did not change then schedule a work item to check the
+ * status of the power button line
+ */
+ if (next_state == pwron->current_state) {
+ schedule_delayed_work(&pwron->input_work,
+ msecs_to_jiffies(pwron->key_recheck_ms));
+ return;
+ }
+
+ pwron->current_state = next_state;
+ input_report_key(input_dev, KEY_POWER, pwron->current_state);
+ input_sync(input_dev);
+}
+
+/**
+ * pwron_irq() - button press isr
+ * @irq: irq
+ * @palmas_pwron: pwron struct
+ *
+ * Return: IRQ_HANDLED
+ */
+static irqreturn_t pwron_irq(int irq, void *palmas_pwron)
+{
+ struct palmas_pwron *pwron = palmas_pwron;
+ struct input_dev *input_dev = pwron->input_dev;
+
+ pwron->current_state = PALMAS_PWR_KEY_PRESS;
+
+ input_report_key(input_dev, KEY_POWER, pwron->current_state);
+ pm_wakeup_event(input_dev->dev.parent, 0);
+ input_sync(input_dev);
+
+ mod_delayed_work(system_wq, &pwron->input_work,
+ msecs_to_jiffies(pwron->key_recheck_ms));
+
+ return IRQ_HANDLED;
+}
+
+/**
+ * palmas_pwron_params_ofinit() - device tree parameter parser
+ * @dev: palmas button device
+ * @config: configuration params that this fills up
+ */
+static void palmas_pwron_params_ofinit(struct device *dev,
+ struct palmas_pwron_config *config)
Maybe we should change this to return an int so that if the DT is not populated
then the LPK and debounce is not set but we continue anyway.
Is there support for platform data itself?
Probably should check the return to make sure the value exists and that is is
within an expected range. Since this is an optional parameter it may not be
populated. And below it sets a preliminary value to the max as the default.
Maybe the default setting should be set at the beginning of this function so
that if there is no dt data then at least the values will be defaulted.
+ config->long_press_time_val = ARRAY_SIZE(lpk_times) - 1;
+ for (i = 0; i < ARRAY_SIZE(lpk_times); i++) {
+ if (val <= lpk_times[i]) {
+ config->long_press_time_val = i;
+ break;
+ }
+ }
+
+ val = 0;
Don't think we need this either if we check the return on the call
below.
Hi Nishanth,
On Thu, Aug 21, 2014 at 11:02:15AM -0500, Nishanth Menon wrote:
+
+ ret = input_register_device(input_dev);
+ if (ret) {
+ free_irq(irq, pwron);
You can not use free_irq with devm-managed resources. As I mentioned, since you
need manual unwinding, I'd rather you not use managed resources in the driver
at all.
On Thu, Aug 21, 2014 at 12:05 PM, Dmitry Torokhov
[off-list ref] wrote:
You can not use free_irq with devm-managed resources. As I mentioned, since you
need manual unwinding, I'd rather you not use managed resources in the driver
at all.
ok. will drop all devm_ ops in the next version.
---
Regards,
Nishanth Menon
I don't see any reboot calls made do we need this?
Arrgh.. yes. will drop.
[..]
quoted
+/**
+ * palmas_pwron_params_ofinit() - device tree parameter parser
+ * @dev: palmas button device
+ * @config: configuration params that this fills up
+ */
+static void palmas_pwron_params_ofinit(struct device *dev,
+ struct palmas_pwron_config *config)
Maybe we should change this to return an int so that if the DT is not populated
then the LPK and debounce is not set but we continue anyway.
Why? these are optional properties, the defaults are 12 seconds for
LPK and 15 ms for debounce. there is no reason for it to return an
error value at this point.
Is there support for platform data itself?
No platform data support. The driver can function without these
properties - these are not mandatory.
Probably should check the return to make sure the value exists and that is is
within an expected range. Since this is an optional parameter it may not be
populated. And below it sets a preliminary value to the max as the default.
Maybe the default setting should be set at the beginning of this function so
that if there is no dt data then at least the values will be defaulted.
quoted
+ config->long_press_time_val = ARRAY_SIZE(lpk_times) - 1;
+ for (i = 0; i < ARRAY_SIZE(lpk_times); i++) {
+ if (val <= lpk_times[i]) {
+ config->long_press_time_val = i;
+ break;
+ }
+ }
+
+ val = 0;
Don't think we need this either if we check the return on the call
below.
Probably should check the return to make sure the value exists and that is is
within an expected range.
It is an optional parameter and may not exist in dt. when it does
exist, the logic tries to do a best match (this is the for loop in the
logic just below).
--
Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Probably should check the return to make sure the value exists and that is is
within an expected range.
It is an optional parameter and may not exist in dt. when it does
exist, the logic tries to do a best match (this is the for loop in the
logic just below).
The issue is val might be returned as a negative which will then proceed to
set the config->long_press_time_val to the lowest time value which then overrides
your initial setting of config->long_press_time_val = ARRAY_SIZE(lpk_times) - 1;
Dan
--
------------------
Dan Murphy
Probably should check the return to make sure the value exists and that is is
within an expected range.
It is an optional parameter and may not exist in dt. when it does
exist, the logic tries to do a best match (this is the for loop in the
logic just below).
The issue is val might be returned as a negative which will then proceed to
set the config->long_press_time_val to the lowest time value which then overrides
your initial setting of config->long_press_time_val = ARRAY_SIZE(lpk_times) - 1;
Does the following as a replacement look OK? if yes, I can incorporate
as part of v3 of this series.
/**
* palmas_pwron_params_ofinit() - device tree parameter parser
* @dev: palmas button device
* @config: configuration params that this fills up
*/
static void palmas_pwron_params_ofinit(struct device *dev,
struct palmas_pwron_config *config)
{
struct device_node *np;
u32 val;
int i, ret;
u8 lpk_times[] = { 6, 8, 10, 12 };
int pwr_on_deb_ms[] = { 15, 100, 500, 1000 };
/* Handle cases where device node based configuration is not present */
if (!of_have_populated_dt())
return;
np = of_node_get(dev->of_node);
if (!np)
return;
/* Default config parameters - least debounce, max long key press */
config->pwron_debounce_val = 0;
config->long_press_time_val = ARRAY_SIZE(lpk_times) - 1;
ret = of_property_read_u32(np, "ti,palmas-long-press-seconds", &val);
if (ret)
goto skip_lpk;
for (i = 0; i < ARRAY_SIZE(lpk_times); i++) {
if (val <= lpk_times[i]) {
config->long_press_time_val = i;
break;
}
}
skip_lpk:
ret = of_property_read_u32(np, "ti,palmas-pwron-debounce-milli-seconds",
&val);
if (ret)
goto skip_debounce;
for (i = 0; i < ARRAY_SIZE(pwr_on_deb_ms); i++) {
if (val <= pwr_on_deb_ms[i]) {
config->pwron_debounce_val = i;
break;
}
}
skip_debounce:
dev_info(dev, "h/w controlled shutdown duration=%d seconds\n",
lpk_times[config->long_press_time_val]);
of_node_put(np);
}
--
Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Probably should check the return to make sure the value exists and that is is
within an expected range.
It is an optional parameter and may not exist in dt. when it does
exist, the logic tries to do a best match (this is the for loop in the
logic just below).
The issue is val might be returned as a negative which will then proceed to
set the config->long_press_time_val to the lowest time value which then overrides
your initial setting of config->long_press_time_val = ARRAY_SIZE(lpk_times) - 1;
Does the following as a replacement look OK? if yes, I can incorporate
as part of v3 of this series.
/**
* palmas_pwron_params_ofinit() - device tree parameter parser
* @dev: palmas button device
* @config: configuration params that this fills up
*/
static void palmas_pwron_params_ofinit(struct device *dev,
struct palmas_pwron_config *config)
{
struct device_node *np;
u32 val;
int i, ret;
u8 lpk_times[] = { 6, 8, 10, 12 };
int pwr_on_deb_ms[] = { 15, 100, 500, 1000 };
/* Handle cases where device node based configuration is not present */
if (!of_have_populated_dt())
return;
np = of_node_get(dev->of_node);
if (!np)
return;
/* Default config parameters - least debounce, max long key press */
config->pwron_debounce_val = 0;
And you can drop this as this value is set to zero in the probe when initialized.
Probably should check the return to make sure the value exists and that is is
within an expected range.
It is an optional parameter and may not exist in dt. when it does
exist, the logic tries to do a best match (this is the for loop in the
logic just below).
The issue is val might be returned as a negative which will then proceed to
set the config->long_press_time_val to the lowest time value which then overrides
your initial setting of config->long_press_time_val = ARRAY_SIZE(lpk_times) - 1;
Does the following as a replacement look OK? if yes, I can incorporate
as part of v3 of this series.
/**
* palmas_pwron_params_ofinit() - device tree parameter parser
* @dev: palmas button device
* @config: configuration params that this fills up
*/
static void palmas_pwron_params_ofinit(struct device *dev,
struct palmas_pwron_config *config)
{
struct device_node *np;
u32 val;
int i, ret;
u8 lpk_times[] = { 6, 8, 10, 12 };
int pwr_on_deb_ms[] = { 15, 100, 500, 1000 };
/* Handle cases where device node based configuration is not present */
if (!of_have_populated_dt())
return;
np = of_node_get(dev->of_node);
if (!np)
return;
/* Default config parameters - least debounce, max long key press */
config->pwron_debounce_val = 0;
config->long_press_time_val = ARRAY_SIZE(lpk_times) - 1;
ret = of_property_read_u32(np, "ti,palmas-long-press-seconds", &val);
if (ret)
goto skip_lpk;
Just without gotos please. They are nice in error handling paths and in some
other rare circumstances, but not here.
for (i = 0; i < ARRAY_SIZE(lpk_times); i++) {
if (val <= lpk_times[i]) {
config->long_press_time_val = i;
break;
}
}
skip_lpk:
ret = of_property_read_u32(np, "ti,palmas-pwron-debounce-milli-seconds",
&val);
if (ret)
goto skip_debounce;
for (i = 0; i < ARRAY_SIZE(pwr_on_deb_ms); i++) {
if (val <= pwr_on_deb_ms[i]) {
config->pwron_debounce_val = i;
break;
}
}
skip_debounce:
dev_info(dev, "h/w controlled shutdown duration=%d seconds\n",
lpk_times[config->long_press_time_val]);
of_node_put(np);
BTW, I do not think you need to use of_node_get/put here, it's not going anywhere.
Thanks.
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Many palmas family of PMICs have support for interrupt based power
button. This allows the device to notify the processor of external
push button events over the shared palmas interrupt. However, this
event is generated only during a "press" operation. Software is
supposed to poll(sigh!) for detecting a release event.
The PMIC also supports ability to power off independent of the
software decisions when the button is pressed for a long duration if
the PMIC is appropriately configured on the platform.
Even though the function is similar to twl4030_pwrbutton, it is
substantially different in operation to belong to a new driver of it's
own.
Based on original work done by Girish S Ghongdemath [off-list ref]
Signed-off-by: Nishanth Menon <redacted>
---
I am not re-posting patch #1/2 as it is already available in
https://patchwork.kernel.org/patch/4758681/ without any comments. Do
let me know if we want it reposted.
Changes since V2:
- Integrated review comments of v2 (improvement in dt parse, header
cleanups, no more managed resource usage)
V2: https://patchwork.kernel.org/patch/4758711/
V1: https://patchwork.kernel.org/patch/4739041/
drivers/input/misc/Kconfig | 10 +
drivers/input/misc/Makefile | 1 +
drivers/input/misc/palmas-pwrbutton.c | 368 +++++++++++++++++++++++++++++++++
3 files changed, 379 insertions(+)
create mode 100644 drivers/input/misc/palmas-pwrbutton.c
@@ -0,0 +1,368 @@+/*+*TexasInstruments'PalmasPowerButtonInputDriver+*+*Copyright(C)2012-2014TexasInstrumentsIncorporated-http://www.ti.com/+*GirishSGhongdemath+*NishanthMenon+*+*Thisprogramisfreesoftware;youcanredistributeitand/ormodify+*itunderthetermsoftheGNUGeneralPublicLicenseversion2as+*publishedbytheFreeSoftwareFoundation.+*+*Thisprogramisdistributed"as is"WITHOUTANYWARRANTYofany+*kind,whetherexpressorimplied;withouteventheimpliedwarranty+*ofMERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe+*GNUGeneralPublicLicenseformoredetails.+*/+#include<linux/init.h>+#include<linux/input.h>+#include<linux/interrupt.h>+#include<linux/kernel.h>+#include<linux/mfd/palmas.h>+#include<linux/module.h>+#include<linux/of.h>+#include<linux/platform_device.h>+#include<linux/slab.h>++#define PALMAS_LPK_TIME_MASK 0x0c+#define PALMAS_PWRON_DEBOUNCE_MASK 0x03+#define PALMAS_PWR_KEY_PRESS 0x01+#define PALMAS_PWR_KEY_Q_TIME_MS 20++/**+*structpalmas_pwron-Palmaspowerondata+*@palmas:pointertopalmasdevice+*@input_dev:pointertoinputdevice+*@irq:irqthatwearehookedonto+*@input_work:workfordetectingreleaseofkey+*@current_state:keycurrentstate+*@key_recheck_ms:durationforrecheckofkey(inmilli-seconds)+*/+structpalmas_pwron{+structpalmas*palmas;+structinput_dev*input_dev;+intirq;+structdelayed_workinput_work;+intcurrent_state;+u32key_recheck_ms;+};++/**+*structpalmas_pwron_config-configurationofpalmaspoweron+*@long_press_time_val:valueforlongpressh/wshutdownevent+*@pwron_debounce_val:valuefordebounceofpowerbutton+*/+structpalmas_pwron_config{+u8long_press_time_val;+u8pwron_debounce_val;+};++/**+*palmas_get_pwr_state()-readbuttonstate+*@pwron:pointertopwronstruct+*+*Return:0fornopress,PALMAS_PWR_KEY_PRESSforkeypress+*andonerror,appropriateerrorvalue.+*/+staticintpalmas_get_pwr_state(structpalmas_pwron*pwron)+{+structinput_dev*input_dev=pwron->input_dev;+structdevice*dev=input_dev->dev.parent;+unsignedintreg=0;+intret;++ret=palmas_read(pwron->palmas,PALMAS_INTERRUPT_BASE,+PALMAS_INT1_LINE_STATE,®);+if(ret){+dev_err(dev,"%s:Cannot read palmas PWRON status(%d)\n",+__func__,ret);+returnret;+}++/* PWRON line state is BIT(1) of the register */+returnreg&BIT(1)?0:PALMAS_PWR_KEY_PRESS;+}++/**+*palmas_power_button_work()-Detectsthebuttonreleaseevent+*@work:workitemtodetectbuttonrelease+*/+staticvoidpalmas_power_button_work(structwork_struct*work)+{+structpalmas_pwron*pwron=container_of((structdelayed_work*)work,+structpalmas_pwron,+input_work);+structinput_dev*input_dev=pwron->input_dev;+intnext_state;++next_state=palmas_get_pwr_state(pwron);+if(next_state<0)+return;++/*+*Ifthestatedidnotchangethenscheduleaworkitemtocheckthe+*statusofthepowerbuttonline+*/+if(next_state==pwron->current_state){+schedule_delayed_work(&pwron->input_work,+msecs_to_jiffies(pwron->key_recheck_ms));+return;+}++pwron->current_state=next_state;+input_report_key(input_dev,KEY_POWER,pwron->current_state);+input_sync(input_dev);+}++/**+*pwron_irq()-buttonpressisr+*@irq:irq+*@palmas_pwron:pwronstruct+*+*Return:IRQ_HANDLED+*/+staticirqreturn_tpwron_irq(intirq,void*palmas_pwron)+{+structpalmas_pwron*pwron=palmas_pwron;+structinput_dev*input_dev=pwron->input_dev;++pwron->current_state=PALMAS_PWR_KEY_PRESS;++input_report_key(input_dev,KEY_POWER,pwron->current_state);+pm_wakeup_event(input_dev->dev.parent,0);+input_sync(input_dev);++mod_delayed_work(system_wq,&pwron->input_work,+msecs_to_jiffies(pwron->key_recheck_ms));++returnIRQ_HANDLED;+}++/**+*palmas_pwron_params_ofinit()-devicetreeparameterparser+*@dev:palmasbuttondevice+*@config:configurationparamsthatthisfillsup+*/+staticvoidpalmas_pwron_params_ofinit(structdevice*dev,+structpalmas_pwron_config*config)+{+structdevice_node*np;+u32val;+inti,ret;+u8lpk_times[]={6,8,10,12};+intpwr_on_deb_ms[]={15,100,500,1000};++/* Default config parameters */+config->long_press_time_val=ARRAY_SIZE(lpk_times)-1;++/* Handle cases where device node based configuration is not present */+if(!of_have_populated_dt())+return;+np=of_node_get(dev->of_node);+if(!np)+return;++ret=of_property_read_u32(np,"ti,palmas-long-press-seconds",&val);+if(!ret){+for(i=0;i<ARRAY_SIZE(lpk_times);i++){+if(val<=lpk_times[i]){+config->long_press_time_val=i;+break;+}+}+}++ret=of_property_read_u32(np,"ti,palmas-pwron-debounce-milli-seconds",+&val);+if(!ret){+for(i=0;i<ARRAY_SIZE(pwr_on_deb_ms);i++){+if(val<=pwr_on_deb_ms[i]){+config->pwron_debounce_val=i;+break;+}+}+}++dev_info(dev,"h/w controlled shutdown duration=%d seconds\n",+lpk_times[config->long_press_time_val]);++of_node_put(np);+}++/**+*palmas_pwron_probe()-probe+*@pdev:platformdeviceforthebutton+*+*Return:0forsuccessfulprobeelseappropriateerror+*/+staticintpalmas_pwron_probe(structplatform_device*pdev)+{+structpalmas*palmas=dev_get_drvdata(pdev->dev.parent);+structdevice*dev=&pdev->dev;+structinput_dev*input_dev;+structpalmas_pwron*pwron;+intirq,ret,val;+structpalmas_pwron_configconfig={0};++palmas_pwron_params_ofinit(dev,&config);++pwron=kzalloc(sizeof(*pwron),GFP_KERNEL);+if(!pwron)+return-ENOMEM;++input_dev=input_allocate_device();+if(!input_dev){+dev_err(dev,"Can't allocate power button\n");+ret=-ENOMEM;+gotoexit_pwron;+}++/*+*Setupdefaulthardwareshutdownoption(longkeypress)+*anddebounce.+*/+val=config.long_press_time_val<<__ffs(PALMAS_LPK_TIME_MASK);+val|=config.pwron_debounce_val<<__ffs(PALMAS_PWRON_DEBOUNCE_MASK);+ret=palmas_update_bits(palmas,PALMAS_PMU_CONTROL_BASE,+PALMAS_LONG_PRESS_KEY,+PALMAS_LPK_TIME_MASK|+PALMAS_PWRON_DEBOUNCE_MASK,val);+if(ret<0){+dev_err(dev,"LONG_PRESS_KEY_UPDATE failed!\n");+gotoexit_input_dev;+}++input_dev->evbit[0]=BIT_MASK(EV_KEY);+input_dev->keybit[BIT_WORD(KEY_POWER)]=BIT_MASK(KEY_POWER);+input_dev->name="palmas_pwron";+input_dev->phys="palmas_pwron/input0";+input_dev->dev.parent=dev;++pwron->palmas=palmas;+pwron->input_dev=input_dev;++INIT_DELAYED_WORK(&pwron->input_work,palmas_power_button_work);++irq=platform_get_irq(pdev,0);+ret=request_threaded_irq(irq,NULL,pwron_irq,+IRQF_TRIGGER_HIGH|+IRQF_TRIGGER_LOW,dev_name(dev),pwron);+if(ret<0){+dev_err(dev,"Can't get IRQ for pwron: %d\n",ret);+gotoexit_input_dev;+}++device_init_wakeup(dev,true);++ret=input_register_device(input_dev);+if(ret){+free_irq(irq,pwron);+cancel_delayed_work_sync(&pwron->input_work);+dev_dbg(dev,"Can't register power button: %d\n",ret);+gotoexit_free_irq;+}+pwron->irq=irq;++pwron->key_recheck_ms=PALMAS_PWR_KEY_Q_TIME_MS;++platform_set_drvdata(pdev,pwron);++return0;++exit_free_irq:+free_irq(irq,pwron);+exit_input_dev:+input_free_device(input_dev);+exit_pwron:+kfree(pwron);++returnret;+}++/**+*palmas_pwron_remove()-Cleanuponremoval+*@pdev:platformdeviceforthebutton+*+*Return:0+*/+staticintpalmas_pwron_remove(structplatform_device*pdev)+{+structpalmas_pwron*pwron=platform_get_drvdata(pdev);++free_irq(pwron->irq,pwron);+cancel_delayed_work_sync(&pwron->input_work);+input_unregister_device(pwron->input_dev);+input_free_device(pwron->input_dev);+kfree(pwron);++return0;+}++/**+*palmas_pwron_suspend()-suspendhandler+*@dev:powerbuttondevice+*+*Cancelallpendingworkitemsforthepowerbutton,setupirqforwakeup+*+*Return:0+*/+staticintpalmas_pwron_suspend(structdevice*dev)+{+structplatform_device*pdev=to_platform_device(dev);+structpalmas_pwron*pwron=platform_get_drvdata(pdev);++cancel_delayed_work_sync(&pwron->input_work);++if(device_may_wakeup(dev))+enable_irq_wake(pwron->irq);++return0;+}++/**+*palmas_pwron_resume()-resumehandler+*@dev:powerbuttondevice+*+*Justdisablethewakeupcapabilityofirqhere.+*+*Return:0+*/+staticintpalmas_pwron_resume(structdevice*dev)+{+structplatform_device*pdev=to_platform_device(dev);+structpalmas_pwron*pwron=platform_get_drvdata(pdev);++if(device_may_wakeup(dev))+disable_irq_wake(pwron->irq);++return0;+}++staticSIMPLE_DEV_PM_OPS(palmas_pwron_pm,+palmas_pwron_suspend,palmas_pwron_resume);++#ifdef CONFIG_OF+staticstructof_device_idof_palmas_pwr_match[]={+{.compatible="ti,palmas-pwrbutton"},+{},+};++MODULE_DEVICE_TABLE(of,of_palmas_pwr_match);+#endif++staticstructplatform_driverpalmas_pwron_driver={+.probe=palmas_pwron_probe,+.remove=palmas_pwron_remove,+.driver={+.name="palmas_pwrbutton",+.owner=THIS_MODULE,+.of_match_table=of_match_ptr(of_palmas_pwr_match),+.pm=&palmas_pwron_pm,+},+};+module_platform_driver(palmas_pwron_driver);++MODULE_ALIAS("platform:palmas-pwrbutton");+MODULE_DESCRIPTION("Palmas Power Button");+MODULE_LICENSE("GPL V2");+MODULE_AUTHOR("Texas Instruments Inc.");
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
On 08/21/2014 01:03 PM, Dmitry Torokhov wrote:
I believe I have taken care of other concerns on v2, but..Arrgh.. I
did not reply to this comment..
BTW, I do not think you need to use of_node_get/put here, it's not going anywhere.
It has been mentioned as a good practice to ensure we use get_put in
to ensure reference count is appropriately maintained. So, I have'nt
changed that in v3.
--
Regards,
Nishanth Menon
Hi Nishanth,
On Thu, Aug 21, 2014 at 02:01:43PM -0500, Nishanth Menon wrote:
On 08/21/2014 01:03 PM, Dmitry Torokhov wrote:
I believe I have taken care of other concerns on v2, but..Arrgh.. I
did not reply to this comment..
quoted
BTW, I do not think you need to use of_node_get/put here, it's not going anywhere.
It has been mentioned as a good practice to ensure we use get_put in
to ensure reference count is appropriately maintained. So, I have'nt
changed that in v3.
You only need to maintain reference count if you pass the handle on.
Otherwise you'd have to do get/put every time you dereference something.
Anyway, I did a few changes to the driver (no need to store current
state, do not fre einput device after unregister, etc.), could you
please tell me if the version below still works for you?
Thanks.
--
Dmitry
Input: introduce palmas-pwrbutton
From: Nishanth Menon <nm@ti.com>
Many palmas family of PMICs have support for interrupt based power button.
This allows the device to notify the processor of external push button
events over the shared palmas interrupt. However, this event is generated
only during a "press" operation. Software is supposed to poll(sigh!) for
detecting a release event.
The PMIC also supports ability to power off independent of the software
decisions when the button is pressed for a long duration if the PMIC is
appropriately configured on the platform.
Even though the function is similar to twl4030_pwrbutton, it is
substantially different in operation to belong to a new driver of it's own.
Based on original work done by Girish S Ghongdemath [off-list ref]
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
.../bindings/input/ti,palmas-pwrbutton.txt | 36 ++
drivers/input/misc/Kconfig | 10 +
drivers/input/misc/Makefile | 1
drivers/input/misc/palmas-pwrbutton.c | 330 ++++++++++++++++++++
4 files changed, 377 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/ti,palmas-pwrbutton.txt
create mode 100644 drivers/input/misc/palmas-pwrbutton.c
@@ -0,0 +1,36 @@+Texas Instruments Palmas family power button module++This module is part of the Palmas family of PMICs. For more details+about the whole chip see:+Documentation/devicetree/bindings/mfd/palmas.txt.++This module provides a simple power button event via an Interrupt.++Required properties:+- compatible: should be one of the following+ - "ti,palmas-pwrbutton": For Palmas compatible power on button+- interrupt-parent: Parent interrupt device, must be handle of palmas node.+- interrupts: Interrupt number of power button submodule on device.++Optional Properties:++- ti,palmas-long-press-seconds: Duration in seconds which the power+ button should be kept pressed for Palmas to power off automatically.+ NOTE: This depends on OTP support and POWERHOLD signal configuration+ on platform. Valid values are 6, 8, 10 and 12.+- ti,palmas-pwron-debounce-milli-seconds: Duration in milliseconds+ which the power button should be kept pressed for Palmas to register+ a press for debouncing purposes. NOTE: This depends on specific+ Palmas variation capability. Valid values are 15, 100, 500 and 1000.++Example:++&palmas {+ palmas_pwr_button: pwrbutton {+ compatible = "ti,palmas-pwrbutton";+ interrupt-parent = <&tps659038>;+ interrupts = <1 IRQ_TYPE_EDGE_FALLING>;+ ti,palmas-long-press-seconds = <12>;+ ti,palmas-pwron-debounce-milli-seconds = <15>;+ };+};
Hi Dimtry,
On 14:13-20140910, Dmitry Torokhov wrote:
On Thu, Aug 21, 2014 at 02:01:43PM -0500, Nishanth Menon wrote:
quoted
On 08/21/2014 01:03 PM, Dmitry Torokhov wrote:
I believe I have taken care of other concerns on v2, but..Arrgh.. I
did not reply to this comment..
quoted
BTW, I do not think you need to use of_node_get/put here, it's not going anywhere.
It has been mentioned as a good practice to ensure we use get_put in
to ensure reference count is appropriately maintained. So, I have'nt
changed that in v3.
You only need to maintain reference count if you pass the handle on.
Otherwise you'd have to do get/put every time you dereference something.
Anyway, I did a few changes to the driver (no need to store current
state, do not fre einput device after unregister, etc.), could you
please tell me if the version below still works for you?
[...]
Thanks for taking the time to do all the changes - they are awesome and
the resultant driver does work.
--
Regards,
Nishanth Menon
On Thu, Sep 11, 2014 at 07:01:19AM -0500, Nishanth Menon wrote:
Hi Dimtry,
On 14:13-20140910, Dmitry Torokhov wrote:
quoted
On Thu, Aug 21, 2014 at 02:01:43PM -0500, Nishanth Menon wrote:
quoted
On 08/21/2014 01:03 PM, Dmitry Torokhov wrote:
I believe I have taken care of other concerns on v2, but..Arrgh.. I
did not reply to this comment..
quoted
BTW, I do not think you need to use of_node_get/put here, it's not going anywhere.
It has been mentioned as a good practice to ensure we use get_put in
to ensure reference count is appropriately maintained. So, I have'nt
changed that in v3.
You only need to maintain reference count if you pass the handle on.
Otherwise you'd have to do get/put every time you dereference something.
Anyway, I did a few changes to the driver (no need to store current
state, do not fre einput device after unregister, etc.), could you
please tell me if the version below still works for you?
[...]
Thanks for taking the time to do all the changes - they are awesome and
the resultant driver does work.
Thank you for [re]testing. I queued the driver for the next merge
window.
--
Dmitry