Add OnKey support for DA9063
Subsystems (5)
v3 cover Add OnKey support for DA9063
From: Steve Twiss <[email protected]>
This patch set adds OnKey driver support for the Dialog Semiconductor DA9063 PMIC.
[PATCH V3 1/3]: kernel driver onkey support
[PATCH V3 2/3]: device tree bindings document
[PATCH V3 3/3]: mfd core support
Thank you,
Steve Twiss, Dialog Semiconductor Ltd.
S Twiss (3):
input: misc: da9063: OnKey driver
devicetree: Add bindings for DA9063 OnKey
mfd: da9063: MFD support for OnKey driver
Documentation/devicetree/bindings/mfd/da9063.txt | 18 ++ drivers/input/misc/Kconfig | 10 + drivers/input/misc/Makefile | 1 + drivers/input/misc/da9063_onkey.c | 227 +++++++++++++++++++++++ drivers/mfd/da9063-core.c | 54 ++++++ include/linux/mfd/da9063/pdata.h | 1 + 6 files changed, 311 insertions(+) create mode 100644 drivers/input/misc/da9063_onkey.c
Signature · 1 line
end-of-patch for PATCH V3
PATCH v3 1/3 input: misc: da9063: OnKey driver
From: Steve Twiss <[email protected]>
Add OnKey driver support for DA9063
---
The changes made here have been taken from the DA9062 OnKey review thread. Please see https://lkml.org/lkml/2015/4/29/406 for more information on this.
Version History
Changes in V3
- Move the MFD code changes into a separate patch [PATCH V3 3/3]
- Rename OnKey driver to use underscore: da9063_onkey.c
- Header and MODULE_LICENSE macro update for GPL and filename change
- Remove MAINTAINERS file (no longer needed due to rename of onkey driver)
- Delete input_unregister_device call from platform driver remove function
- Replaced dev_notice() with dev_dbg() for key press notification
Changes in V2
- Remove the circular dependency comment in the main e-mail body linking PATCH V1 1/2 and 2/2
- Alter the copyright header information to match expected GPLv2 text from http://www.gnu.org/licenses/gpl-2.0.html
This patch applies against linux-next and v4.1-rc1
drivers/input/misc/Kconfig | 10 ++ drivers/input/misc/Makefile | 1 + drivers/input/misc/da9063_onkey.c | 227 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 238 insertions(+) create mode 100644 drivers/input/misc/da9063_onkey.c
drivers/input/misc/Kconfig +10 -0
@@ -610,6 +610,16 @@ config INPUT_DA9055_ONKEY To compile this driver as a module, choose M here: the module will be called da9055_onkey. +config INPUT_DA9063_ONKEY + tristate "Dialog DA9063 OnKey" + depends on MFD_DA9063 + help + Support the ONKEY of Dialog DA9063 Power Management IC as an + input device reporting power button statue. + + To compile this driver as a module, choose M here: the module + will be called da9063-onkey. + config INPUT_DM355EVM tristate "TI DaVinci DM355 EVM Keypad and IR Remote" depends on MFD_DM355EVM_MSP
drivers/input/misc/Makefile +1 -0
@@ -25,6 +25,7 @@ obj-$(CONFIG_INPUT_CMA3000_I2C) += cma3000_d0x_i2c.o obj-$(CONFIG_INPUT_COBALT_BTNS) += cobalt_btns.o obj-$(CONFIG_INPUT_DA9052_ONKEY) += da9052_onkey.o obj-$(CONFIG_INPUT_DA9055_ONKEY) += da9055_onkey.o +obj-$(CONFIG_INPUT_DA9063_ONKEY) += da9063_onkey.o obj-$(CONFIG_INPUT_DM355EVM) += dm355evm_keys.o obj-$(CONFIG_INPUT_E3X0_BUTTON) += e3x0-button.o obj-$(CONFIG_INPUT_DRV260X_HAPTICS) += drv260x.o
drivers/input/misc/da9063_onkey.c new file +227 -0
227 lines not on this page · raw message
Signature · 1 line
end-of-patch for PATCH V3
PATCH v3 2/3 devicetree: Add bindings for DA9063 OnKey
In reply to S TwissFrom: Steve Twiss <[email protected]>
Add device tree bindings for the DA9063 OnKey driver
---
Version History
Changes in V3
- No change
Changes in V2
- Remove the circular dependency comment linking patches in the main e-mail
- Search and replace 'keyword' with 'property' in onkey sub-node description
- Reformat onkey sub-node content to move the description for key-power into a new optional properties sub-section so it has a more promiment position
This patch applies against linux-next and v4.1-rc1
Documentation/devicetree/bindings/mfd/da9063.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
Documentation/devicetree/bindings/mfd/da9063.txt +18 -0
@@ -5,6 +5,7 @@ DA9093 consists of a large and varied group of sub-devices (I2C Only): Device Supply Names Description ------ ------------ ----------- da9063-regulator : : LDOs & BUCKs +da9063-onkey : : On Key da9063-rtc : : Real-Time Clock da9063-watchdog : : Watchdog
@@ -51,6 +52,18 @@ Sub-nodes: the DA9063. There are currently no entries in this binding, however compatible = "dlg,da9063-rtc" should be added if a node is created. +- onkey : This node defines the OnKey settings for controlling the key + functionality of the device. The node should contain the compatible property + with the value "dlg,da9063-onkey". + + Optional onkey properties: + + - dlg,disable-key-power : Disable power-down using a long key-press. If this + entry exists the OnKey driver will remove support for the KEY_POWER key + press. If this entry does not exist then by default the key-press + triggered power down is enabled and the OnKey will support both KEY_POWER + and KEY_SLEEP. + - watchdog : This node defines settings for the Watchdog timer associated with the DA9063. There are currently no entries in this binding, however compatible = "dlg,da9063-watchdog" should be added if a node is created.
@@ -73,6 +86,11 @@ Example: compatible = "dlg,da9063-watchdog"; }; + onkey { + compatible = "dlg,da9063-onkey"; + dlg,disable-key-power; + }; + regulators { DA9063_BCORE1: bcore1 { regulator-name = "BCORE1";
Signature · 1 line
end-of-patch for PATCH V3
PATCH v3 3/3 mfd: da9063: MFD support for OnKey driver
In reply to S TwissFrom: Steve Twiss <[email protected]>
Add MFD support for the DA9063 OnKey driver
---
Version History
Changes in V3
- The MFD code was originally in [PATCH V2 1/2]. This is now been moved into this patch [PATCH V3 3/3].
- Whitespace cleanup
This patch applies against linux-next and v4.1-rc1
drivers/mfd/da9063-core.c | 54 ++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/da9063/pdata.h | 1 + 2 files changed, 55 insertions(+)
drivers/mfd/da9063-core.c +54 -0
@@ -60,6 +60,7 @@ static struct resource da9063_rtc_resources[] = {static struct resource da9063_onkey_resources[] = { { + .name ="ONKEY" , .start =DA9063_IRQ_ONKEY , .end =DA9063_IRQ_ONKEY , .flags =IORESOURCE_IRQ ,
@@ -97,6 +98,7 @@ static const struct mfd_cell da9063_devs[] = { .name = DA9063_DRVNAME_ONKEY, .num_resources = ARRAY_SIZE(da9063_onkey_resources), .resources = da9063_onkey_resources, + .of_compatible = "dlg,da9063-onkey", }, { .name = DA9063_DRVNAME_RTC,
@@ -109,12 +111,64 @@ static const struct mfd_cell da9063_devs[] = { }, }; +static int da9063_clear_fault_log (struct da9063 *da9063) +{ +int ret =0 ; +int fault_log =0 ; + + ret =regmap_read (da9063->regmap,DA9063_REG_FAULT_LOG , &fault_log); +if (ret <0 ) { +dev_err (da9063->dev,"Cannot read FAULT_LOG.\n" ); +return -EIO ; + } + +if (fault_log) { +if (fault_log &DA9063_TWD_ERROR ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_TWD_ERROR\n" ); +if (fault_log &DA9063_POR ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_POR\n" ); +if (fault_log &DA9063_VDD_FAULT ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_VDD_FAULT\n" ); +if (fault_log &DA9063_VDD_START ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_VDD_START\n" ); +if (fault_log &DA9063_TEMP_CRIT ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_TEMP_CRIT\n" ); +if (fault_log &DA9063_KEY_RESET ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_KEY_RESET\n" ); +if (fault_log &DA9063_NSHUTDOWN ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_NSHUTDOWN\n" ); +if (fault_log &DA9063_WAIT_SHUT ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_WAIT_SHUT\n" ); + } + + ret =regmap_write (da9063->regmap, +DA9063_REG_FAULT_LOG , + fault_log); +if (ret <0 ) +dev_err (da9063->dev, +"Cannot reset FAULT_LOG values %d\n" , ret); + +return ret; +} +int da9063_device_init (struct da9063 *da9063,unsigned int irq) {struct da9063_pdata *pdata = da9063->dev->platform_data;int model, variant_id, variant_code;int ret; + ret =da9063_clear_fault_log (da9063); +if (ret <0 ) +dev_err (da9063->dev,"Cannot clear fault log\n" ); +if (pdata) { da9063->flags = pdata->flags; da9063->irq_base = pdata->irq_base;
include/linux/mfd/da9063/pdata.h +1 -0
@@ -103,6 +103,7 @@ struct da9063;struct da9063_pdata {int (*init)(struct da9063 *da9063);int irq_base; +bool key_power;unsigned flags;struct da9063_regulators_pdata *regulators_pdata;struct led_platform_data *leds_pdata;
Signature · 1 line
end-of-patch for PATCH V3
Re: [PATCH V3 3/3] mfd: da9063: MFD support for OnKey driver
Hi Steve,
Quoted 1 line · S Twiss
Add MFD support for the DA9063 OnKey driver
Thanks for your patch!
Quoted 73 lines
drivers/mfd/da9063-core.c +50
-0@@ -60,6 +60,7 @@ static struct resource da9063_rtc_resources[] = {static struct resource da9063_onkey_resources[] = { { + .name ="ONKEY" , .start =DA9063_IRQ_ONKEY , .end =DA9063_IRQ_ONKEY , .flags =IORESOURCE_IRQ ,@@ -97,6 +98,7 @@ static const struct mfd_cell da9063_devs[] = { .name = DA9063_DRVNAME_ONKEY, .num_resources = ARRAY_SIZE(da9063_onkey_resources), .resources = da9063_onkey_resources, + .of_compatible = "dlg,da9063-onkey", }, { .name = DA9063_DRVNAME_RTC,@@ -109,12 +111,64 @@ static const struct mfd_cell da9063_devs[] = { }, }; +static int da9063_clear_fault_log (struct da9063 *da9063) +{ +int ret =0 ; +int fault_log =0 ; + + ret =regmap_read (da9063->regmap,DA9063_REG_FAULT_LOG , &fault_log); +if (ret <0 ) { +dev_err (da9063->dev,"Cannot read FAULT_LOG.\n" ); +return -EIO ; + } + +if (fault_log) { +if (fault_log &DA9063_TWD_ERROR ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_TWD_ERROR\n" ); +if (fault_log &DA9063_POR ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_POR\n" ); +if (fault_log &DA9063_VDD_FAULT ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_VDD_FAULT\n" ); +if (fault_log &DA9063_VDD_START ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_VDD_START\n" ); +if (fault_log &DA9063_TEMP_CRIT ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_TEMP_CRIT\n" ); +if (fault_log &DA9063_KEY_RESET ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_KEY_RESET\n" ); +if (fault_log &DA9063_NSHUTDOWN ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_NSHUTDOWN\n" ); +if (fault_log &DA9063_WAIT_SHUT ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_WAIT_SHUT\n" ); + } + + ret =regmap_write (da9063->regmap, +DA9063_REG_FAULT_LOG , + fault_log); +if (ret <0 ) +dev_err (da9063->dev, +"Cannot reset FAULT_LOG values %d\n" , ret); + +return ret; +} +int da9063_device_init (struct da9063 *da9063,unsigned int irq) {struct da9063_pdata *pdata = da9063->dev->platform_data;
drivers/mfd/da9063-core.c static const struct mfd_cell da9063_devs[] = { · line 174
Quoted 10 lines
drivers/mfd/da9063-core.c +4
-0int model, variant_id, variant_code;int ret; + ret =da9063_clear_fault_log (da9063); +if (ret <0 ) +dev_err (da9063->dev,"Cannot clear fault log\n" ); +if (pdata) { da9063->flags = pdata->flags; da9063->irq_base = pdata->irq_base;
The code above doesn't seem to match the patch description. Can you please explain why it is needed?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
RE: [PATCH V3 3/3] mfd: da9063: MFD support for OnKey driver
Quoted 61 lines · Geert Uytterhoeven
Quoted 1 line · S Twiss
Add MFD support for the DA9063 OnKey driver
Thanks for your patch!
drivers/mfd/da9063-core.c static const struct mfd_cell da9063_devs[] = {
Quoted 6 lines
drivers/mfd/da9063-core.c +6
-0+static int da9063_clear_fault_log (struct da9063 *da9063) +{ +int ret =0 ; +int fault_log =0 ; + + ret = regmap_read(da9063->regmap, DA9063_REG_FAULT_LOG,
&fault_log);Quoted 48 lines
drivers/mfd/da9063-core.c +42
-0+if (ret <0 ) { +dev_err (da9063->dev,"Cannot read FAULT_LOG.\n" ); +return -EIO ; + } + +if (fault_log) { +if (fault_log &DA9063_TWD_ERROR ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_TWD_ERROR\n" ); +if (fault_log &DA9063_POR ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_POR\n" ); +if (fault_log &DA9063_VDD_FAULT ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_VDD_FAULT\n" ); +if (fault_log &DA9063_VDD_START ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_VDD_START\n" ); +if (fault_log &DA9063_TEMP_CRIT ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_TEMP_CRIT\n" ); +if (fault_log &DA9063_KEY_RESET ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_KEY_RESET\n" ); +if (fault_log &DA9063_NSHUTDOWN ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_NSHUTDOWN\n" ); +if (fault_log &DA9063_WAIT_SHUT ) +dev_dbg (da9063->dev, +"Fault log entry detected: DA9063_WAIT_SHUT\n" ); + } + + ret =regmap_write (da9063->regmap, +DA9063_REG_FAULT_LOG , + fault_log); +if (ret <0 ) +dev_err (da9063->dev, +"Cannot reset FAULT_LOG values %d\n" , ret); + +return ret; +} +int da9063_device_init (struct da9063 *da9063,unsigned int irq) {struct da9063_pdata *pdata = da9063->dev->platform_data;int model, variant_id, variant_code;int ret;
Quoted 11 lines
drivers/mfd/da9063-core.c static const struct mfd_cell da9063_devs[] = { · line 174
Quoted 7 lines
drivers/mfd/da9063-core.c +4
-0+ ret =da9063_clear_fault_log (da9063); +if (ret <0 ) +dev_err (da9063->dev,"Cannot clear fault log\n" ); +if (pdata) { da9063->flags = pdata->flags; da9063->irq_base = pdata->irq_base;The code above doesn't seem to match the patch description. Can you please explain why it is needed?
Hi Geert,
Yes, at first it does seem that the fault-log clearing function is unrelated to the "MFD support for the DA9063 OnKey driver", but there is an important connection that makes it essential for the OnKey driver in this case.
I have made some explanation of the OnKey's operation in this thread here:
https://lkml.org/lkml/2015/4/29/406
But I only described the OnKey's point-of-view for case (4) of the "OnKey operation" Case (4): the long-long press and no key release -- the hardware power-cut when software is unable to respond (for whatever reason).
In this case, if the software was not responsive and a hardware shutdown of the device was chosen, the FAULT_LOG would persist with information that would be accessible when the device was restarted: it would be possible to take action the next time the device was turned on again (maybe to trigger some mitigation exercise in the bootloader -- e.g. say to complete memory checks or put the device into a safe mode).
However this mitigation exercise and clearance of the fault-log cannot be counted on outside the Linux kernel and so the clearance function da9063_clear_fault_log () has been done here.
If this clearance function did not exist, then after a hardware shutdown (due to S/W failure), the next time the device is restarted the FAULT_LOG would persist with values from the previous error.
Regards,
Steve
Re: [PATCH V3 3/3] mfd: da9063: MFD support for OnKey driver
Hi Steve,
Quoted 45 lines · Opensource [Steve Twiss]
Quoted 15 lines · Geert Uytterhoeven
Quoted 13 lines · S Twiss
Add MFD support for the DA9063 OnKey driver
drivers/mfd/da9063-core.c +4
-0+static int da9063_clear_fault_log (struct da9063 *da9063) +{ +} +int da9063_device_init (struct da9063 *da9063,unsigned int irq) {struct da9063_pdata *pdata = da9063->dev->platform_data;int model, variant_id, variant_code;int ret;Quoted 10 lines
drivers/mfd/da9063-core.c static const struct mfd_cell da9063_devs[] = { · line 174
Quoted 7 lines
drivers/mfd/da9063-core.c +4
-0+ ret =da9063_clear_fault_log (da9063); +if (ret <0 ) +dev_err (da9063->dev,"Cannot clear fault log\n" ); +if (pdata) { da9063->flags = pdata->flags; da9063->irq_base = pdata->irq_base;The code above doesn't seem to match the patch description. Can you please explain why it is needed?
Yes, at first it does seem that the fault-log clearing function is unrelated to the "MFD support for the DA9063 OnKey driver", but there is an important connection that makes it essential for the OnKey driver in this case.
I have made some explanation of the OnKey's operation in this thread here:
https://lkml.org/lkml/2015/4/29/406But I only described the OnKey's point-of-view for case (4) of the "OnKey operation" Case (4): the long-long press and no key release -- the hardware power-cut when software is unable to respond (for whatever reason).
In this case, if the software was not responsive and a hardware shutdown of the device was chosen, the
FAULT_LOGwould persist with information that would be accessible when the device was restarted: it would be possible to take action the next time the device was turned on again (maybe to trigger some mitigation exercise in the bootloader -- e.g. say to complete memory checks or put the device into a safe mode).
Quoted 7 lines
However this mitigation exercise and clearance of the fault-log cannot be counted on outside the Linux kernel and so the clearance function
da9063_clear_fault_log() has been done here.If this clearance function did not exist, then after a hardware shutdown (due to S/W failure), the next time the device is restarted the
FAULT_LOGwould persist with values from the previous error.
Thanks for your explanation!
Please add (some parts of it) to the patch description.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
RE: [PATCH V3 3/3] mfd: da9063: MFD support for OnKey driver
Quoted 49 lines · On 05 May 2015 09:52 Geert Uytterhoeven wrote:
Quoted 47 lines · Opensource [Steve Twiss]
Quoted 13 lines · Geert Uytterhoeven
Quoted 12 lines · S Twiss
Add MFD support for the DA9063 OnKey driver
drivers/mfd/da9063-core.c +4
-0+static int da9063_clear_fault_log (struct da9063 *da9063) +{ +} +int da9063_device_init (struct da9063 *da9063,unsigned int irq) {struct da9063_pdata *pdata = da9063->dev->platform_data;int model, variant_id, variant_code;int ret;Quoted 10 lines
drivers/mfd/da9063-core.c static const struct mfd_cell da9063_devs[] = { · line 174
Quoted 7 lines
drivers/mfd/da9063-core.c +4
-0+ ret =da9063_clear_fault_log (da9063); +if (ret <0 ) +dev_err (da9063->dev,"Cannot clear fault log\n" ); +if (pdata) { da9063->flags = pdata->flags; da9063->irq_base = pdata->irq_base;The code above doesn't seem to match the patch description. Can you please explain why it is needed?
Yes, at first it does seem that the fault-log clearing function is unrelated to the "MFD support for the DA9063 OnKey driver", but there is an important connection that makes it essential for the OnKey driver in this case.
I have made some explanation of the OnKey's operation in this thread here:
https://lkml.org/lkml/2015/4/29/406But I only described the OnKey's point-of-view for case (4) of the "OnKey operation" Case (4): the long-long press and no key release -- the hardware power-cut when software is unable to respond (for whatever reason).
In this case, if the software was not responsive and a hardware shutdown of the device was chosen, the
FAULT_LOGwould persist with information that would be accessible when the device was restarted: it would be possible to take action the next time the device was turned on again (maybe to trigger some mitigation exercise in the bootloader -- e.g. say to complete memory checks or put the device into a safe mode).However this mitigation exercise and clearance of the fault-log cannot be counted on outside the Linux kernel and so the clearance function
da9063_clear_fault_log() has been done here.
Quoted 8 lines
Quoted 3 lines
If this clearance function did not exist, then after a hardware shutdown (due to S/W failure), the next time the device is restarted the
FAULT_LOGwould persist with values from the previous error.Thanks for your explanation!
Please add (some parts of it) to the patch description.
Thanks Geert,
I will do that.
I'll wait a while to see if there are any other responses (e.g. OnKey) and then make a new patch set called PATCH V4.
Regards,
Steve
CC: Dmitry Torokhov for information on these MFD changes since they also relate to the OnKey.