--- v4
+++ v2
@@ -1,114 +1,108 @@
-As preparation for the extension of support for all three mc13xxx
-variants, convert the members of mc13xxx_buttons_platform_data to
-arrays to allow index access within the next commit.
+Add a buttons node and properties describing the "ONOFD" (MC13783) and
+"PWRON" (MC13892/MC34708) buttons available in the fsl,mc13xxx PMIC ICs.
Signed-off-by: Alexander Kurz <akurz@blala.de>
---
- drivers/input/misc/mc13783-pwrbutton.c | 42 +++++++++++++-------------
- include/linux/mfd/mc13xxx.h | 8 ++---
- 2 files changed, 23 insertions(+), 27 deletions(-)
+ .../devicetree/bindings/mfd/fsl,mc13xxx.yaml | 58 +++++++++++++++++++
+ 1 file changed, 58 insertions(+)
-diff --git a/drivers/input/misc/mc13783-pwrbutton.c b/drivers/input/misc/mc13783-pwrbutton.c
-index 20f68aab6edf..2ee115d77b1c 100644
---- a/drivers/input/misc/mc13783-pwrbutton.c
-+++ b/drivers/input/misc/mc13783-pwrbutton.c
-@@ -108,24 +108,24 @@ static int mc13783_pwrbutton_probe(struct platform_device *pdev)
- if (!priv)
- return -ENOMEM;
+diff --git a/Documentation/devicetree/bindings/mfd/fsl,mc13xxx.yaml b/Documentation/devicetree/bindings/mfd/fsl,mc13xxx.yaml
+index 94e2f6557376..761267b42c85 100644
+--- a/Documentation/devicetree/bindings/mfd/fsl,mc13xxx.yaml
++++ b/Documentation/devicetree/bindings/mfd/fsl,mc13xxx.yaml
+@@ -39,6 +39,41 @@ properties:
+ interrupts:
+ maxItems: 1
-- reg |= (pdata->b1on_flags & 0x3) << MC13783_POWER_CONTROL_2_ON1BDBNC;
-- reg |= (pdata->b2on_flags & 0x3) << MC13783_POWER_CONTROL_2_ON2BDBNC;
-- reg |= (pdata->b3on_flags & 0x3) << MC13783_POWER_CONTROL_2_ON3BDBNC;
-+ reg |= (pdata->b_on_flags[0] & 0x3) << MC13783_POWER_CONTROL_2_ON1BDBNC;
-+ reg |= (pdata->b_on_flags[1] & 0x3) << MC13783_POWER_CONTROL_2_ON2BDBNC;
-+ reg |= (pdata->b_on_flags[2] & 0x3) << MC13783_POWER_CONTROL_2_ON3BDBNC;
++ buttons:
++ type: object
++ $ref: /schemas/input/input.yaml#
++ description: Buttons
++ properties:
++ reg:
++ description: |
++ One of
++ MC13783 BUTTON IDs:
++ 0: ONOFD1
++ 1: ONOFD2
++ 2: ONOFD3
++ MC13892 BUTTON IDs:
++ 0: PWRON1
++ 1: PWRON2
++ 2: PWRON3
++ MC34708 BUTTON IDs:
++ 0: PWRON1
++ 1: PWRON2
++
++ debounce-delay-ms:
++ enum: [0, 30, 150, 750]
++ default: 30
++ description: |
++ Sets the debouncing delay in milliseconds.
++ Valid values: 0, 30, 150 and 750ms.
++
++ active-low:
++ description: Set active when pin is pulled low.
++
++ fsl,enable-reset:
++ description: |
++ Setting of the global reset option.
++ type: boolean
++
+ leds:
+ type: object
+ $ref: /schemas/leds/common.yaml#
+@@ -119,6 +154,10 @@ allOf:
+ const: fsl,mc13783
+ then:
+ properties:
++ buttons:
++ properties:
++ reg:
++ enum: [0, 1, 2]
+ leds:
+ properties:
+ fsl,led-control:
+@@ -137,6 +176,10 @@ allOf:
+ const: fsl,mc13892
+ then:
+ properties:
++ buttons:
++ properties:
++ reg:
++ enum: [0, 1, 2]
+ leds:
+ properties:
+ fsl,led-control:
+@@ -155,6 +198,10 @@ allOf:
+ const: fsl,mc34708
+ then:
+ properties:
++ buttons:
++ properties:
++ reg:
++ enum: [0, 1]
+ leds:
+ properties:
+ fsl,led-control:
+@@ -183,6 +230,17 @@ examples:
+ fsl,mc13xxx-uses-rtc;
+ fsl,mc13xxx-uses-adc;
- priv->pwr = pwr;
- priv->mc13783 = mc13783;
-
- mc13xxx_lock(mc13783);
-
-- if (pdata->b1on_flags & MC13783_BUTTON_ENABLE) {
-- priv->keymap[0] = pdata->b1on_key;
-- if (pdata->b1on_key != KEY_RESERVED)
-- __set_bit(pdata->b1on_key, pwr->keybit);
-+ if (pdata->b_on_flags[0] & MC13783_BUTTON_ENABLE) {
-+ priv->keymap[0] = pdata->b_on_key[0];
-+ if (pdata->b_on_key[0] != KEY_RESERVED)
-+ __set_bit(pdata->b_on_key[0], pwr->keybit);
-
-- if (pdata->b1on_flags & MC13783_BUTTON_POL_INVERT)
-+ if (pdata->b_on_flags[0] & MC13783_BUTTON_POL_INVERT)
- priv->flags |= MC13783_PWRB_B1_POL_INVERT;
-
-- if (pdata->b1on_flags & MC13783_BUTTON_RESET_EN)
-+ if (pdata->b_on_flags[0] & MC13783_BUTTON_RESET_EN)
- reg |= MC13783_POWER_CONTROL_2_ON1BRSTEN;
-
- irq = platform_get_irq_byname(pdev, "b1on");
-@@ -144,15 +144,15 @@ static int mc13783_pwrbutton_probe(struct platform_device *pdev)
- priv->irq[0] = irq;
- }
-
-- if (pdata->b2on_flags & MC13783_BUTTON_ENABLE) {
-- priv->keymap[1] = pdata->b2on_key;
-- if (pdata->b2on_key != KEY_RESERVED)
-- __set_bit(pdata->b2on_key, pwr->keybit);
-+ if (pdata->b_on_flags[1] & MC13783_BUTTON_ENABLE) {
-+ priv->keymap[1] = pdata->b_on_key[1];
-+ if (pdata->b_on_key[1] != KEY_RESERVED)
-+ __set_bit(pdata->b_on_key[1], pwr->keybit);
-
-- if (pdata->b2on_flags & MC13783_BUTTON_POL_INVERT)
-+ if (pdata->b_on_flags[1] & MC13783_BUTTON_POL_INVERT)
- priv->flags |= MC13783_PWRB_B2_POL_INVERT;
-
-- if (pdata->b2on_flags & MC13783_BUTTON_RESET_EN)
-+ if (pdata->b_on_flags[1] & MC13783_BUTTON_RESET_EN)
- reg |= MC13783_POWER_CONTROL_2_ON2BRSTEN;
-
- irq = platform_get_irq_byname(pdev, "b2on");
-@@ -171,15 +171,15 @@ static int mc13783_pwrbutton_probe(struct platform_device *pdev)
- priv->irq[1] = irq;
- }
-
-- if (pdata->b3on_flags & MC13783_BUTTON_ENABLE) {
-- priv->keymap[2] = pdata->b3on_key;
-- if (pdata->b3on_key != KEY_RESERVED)
-- __set_bit(pdata->b3on_key, pwr->keybit);
-+ if (pdata->b_on_flags[2] & MC13783_BUTTON_ENABLE) {
-+ priv->keymap[2] = pdata->b_on_key[2];
-+ if (pdata->b_on_key[2] != KEY_RESERVED)
-+ __set_bit(pdata->b_on_key[2], pwr->keybit);
-
-- if (pdata->b3on_flags & MC13783_BUTTON_POL_INVERT)
-+ if (pdata->b_on_flags[2] & MC13783_BUTTON_POL_INVERT)
- priv->flags |= MC13783_PWRB_B3_POL_INVERT;
-
-- if (pdata->b3on_flags & MC13783_BUTTON_RESET_EN)
-+ if (pdata->b_on_flags[2] & MC13783_BUTTON_RESET_EN)
- reg |= MC13783_POWER_CONTROL_2_ON3BRSTEN;
-
- irq = platform_get_irq_byname(pdev, "b3on");
-diff --git a/include/linux/mfd/mc13xxx.h b/include/linux/mfd/mc13xxx.h
-index dd46fe424a80..4437ab80fcf8 100644
---- a/include/linux/mfd/mc13xxx.h
-+++ b/include/linux/mfd/mc13xxx.h
-@@ -181,12 +181,8 @@ struct mc13xxx_leds_platform_data {
- #define MC13783_BUTTON_RESET_EN (1 << 4)
-
- struct mc13xxx_buttons_platform_data {
-- int b1on_flags;
-- unsigned short b1on_key;
-- int b2on_flags;
-- unsigned short b2on_key;
-- int b3on_flags;
-- unsigned short b3on_key;
-+ int b_on_flags[3];
-+ unsigned int b_on_key[3];
- };
-
- #define MC13783_TS_ATO_FIRST false
++ buttons {
++ #address-cells = <1>;
++ #size-cells = <0>;
++ onkey1@0 {
++ reg = <0>;
++ debounce-delay-ms = <30>;
++ active-low;
++ fsl,enable-reset;
++ };
++ };
++
+ leds {
+ #address-cells = <1>;
+ #size-cells = <0>;
--
2.39.5