Skip to contentSkip to conversation

twl4030-pwrbutton patches

PATCH In review Felipe Balbi 4 participants 15 messages Feb 19, 2009 – Mar 5, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover twl4030-pwrbutton patches

Moving out of drivers/i2c/chips

Felipe Balbi (2):
i2c: move twl4030-pwrbutton to child registration style
twl4030: move twl4030-pwrbutton to drivers/input/misc

 drivers/i2c/chips/Kconfig                          |    4 -
 drivers/i2c/chips/Makefile                         |    1 -
 drivers/input/misc/Kconfig                         |    4 +
 drivers/input/misc/Makefile                        |    1 +
 .../{i2c/chips => input/misc}/twl4030-pwrbutton.c  |   59 +++++++++++++------
 drivers/mfd/twl4030-core.c                         |   13 ++++
 6 files changed, 58 insertions(+), 24 deletions(-)
 rename drivers/{i2c/chips => input/misc}/twl4030-pwrbutton.c (70%)
#1 lore raw

PATCH 1/2 i2c: move twl4030-pwrbutton to child registration style

This patch is *compile tested only*. It moves twl4030-pwrbutton to a platform_driver so it can be registered as a child of twl4030-core.c.

Cc David Brownell <[email protected]>
Cc Samuel Ortiz <[email protected]>
---
 drivers/i2c/chips/twl4030-pwrbutton.c |   59 ++++++++++++++++++++++----------
 drivers/mfd/twl4030-core.c            |   12 +++++++
 2 files changed, 52 insertions(+), 19 deletions(-)
drivers/i2c/chips/twl4030-pwrbutton.c +40 -19
index 1d9cb90..b0a9c9f 100644
@@ -27,20 +27,15 @@
 #include <linux/errno.h>
 #include <linux/input.h>
 #include <linux/interrupt.h>
+#include <linux/platform_device.h>
 #include <linux/i2c/twl4030.h>
 
-
-#define PWR_PWRON_IRQ (1<<0)
+#define PWR_PWRON_IRQ (1 << 0)
 
 #define STS_HW_CONDITIONS 0xf
 
-
-/* FIXME have this constant delivered to us as part of the
- * twl4030-core setup ...
- */
-#define TWL4030_PWRIRQ_PWRBTN	(TWL4030_PWR_IRQ_BASE + 0)
-
 static struct input_dev *powerbutton_dev;
+static struct device *dbg_dev;
 
 static irqreturn_t powerbutton_irq(int irq, void *dev_id)
 {
@@ -61,29 +56,32 @@ static irqreturn_t powerbutton_irq(int irq, void *dev_id)
 		input_report_key(powerbutton_dev, KEY_POWER,
 				 value & PWR_PWRON_IRQ);
 	} else {
-		pr_err("twl4030: i2c error %d while reading TWL4030"
+		dev_err(dbg_dev, "twl4030: i2c error %d while reading TWL4030"
 			" PM_MASTER STS_HW_CONDITIONS register\n", err);
 	}
 
 	return IRQ_HANDLED;
 }
 
-static int __init twl4030_pwrbutton_init(void)
+static int __devinit twl4030_pwrbutton_probe(struct platform_device *pdev)
 {
 	int err = 0;
+	int irq = platform_get_irq(pdev, 0);
+
+	dbg_dev = &pdev->dev;
 
 	/* PWRBTN == PWRON */
-	err = request_irq(TWL4030_PWRIRQ_PWRBTN, powerbutton_irq,
+	err = request_irq(irq, powerbutton_irq,
 			IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
-			"PwrButton", NULL);
+			"twl4030-pwrbutton", NULL);
 	if (err < 0) {
-		pr_debug("Can't get IRQ for power button: %d\n", err);
+		dev_dbg(&pdev->dev, "Can't get IRQ for power button: %d\n", err);
 		goto out;
 	}
 
 	powerbutton_dev = input_allocate_device();
 	if (!powerbutton_dev) {
-		pr_debug("Can't allocate power button\n");
+		dev_dbg(&pdev->dev, "Can't allocate power button\n");
 		err = -ENOMEM;
 		goto free_irq_and_out;
 	}
@@ -94,11 +92,11 @@ static int __init twl4030_pwrbutton_init(void)
 
 	err = input_register_device(powerbutton_dev);
 	if (err) {
-		pr_debug("Can't register power button: %d\n", err);
+		dev_dbg(&pdev->dev, "Can't register power button: %d\n", err);
 		goto free_input_dev;
 	}
 
-	printk(KERN_INFO "triton2 power button driver initialized\n");
+	dev_info(&pdev->dev, "triton2 power button driver initialized\n");
 
 	return 0;
 
@@ -110,13 +108,36 @@ free_irq_and_out:
 out:
 	return err;
 }
-module_init(twl4030_pwrbutton_init);
 
-static void __exit twl4030_pwrbutton_exit(void)
+static int __devexit twl4030_pwrbutton_remove(struct platform_device *pdev)
 {
-	free_irq(TWL4030_PWRIRQ_PWRBTN, NULL);
+	int irq = platform_get_irq(pdev, 0);
+
+	free_irq(irq, NULL);
 	input_unregister_device(powerbutton_dev);
 	input_free_device(powerbutton_dev);
+
+	return 0;
+}
+
+struct platform_driver twl4030_pwrbutton_driver = {
+	.probe		= twl4030_pwrbutton_probe,
+	.remove		= twl4030_pwrbutton_remove,
+	.driver		= {
+		.name	= "twl4030-pwrbutton",
+		.owner	= THIS_MODULE,
+	},
+};
+
+static int __init twl4030_pwrbutton_init(void)
+{
+	return platform_driver_register(&twl4030_pwrbutton_driver);
+}
+module_init(twl4030_pwrbutton_init);
+
+static void __exit twl4030_pwrbutton_exit(void)
+{
+	platform_driver_unregister(&twl4030_pwrbutton_driver);
 }
 module_exit(twl4030_pwrbutton_exit);
 
drivers/mfd/twl4030-core.c +12 -0
index 19ee29b..1552296 100644
@@ -107,6 +107,11 @@
 #define twl_has_usb()	false
 #endif
 
+#if defined(CONFIG_TWL4030_PWRBUTTON) || defined(CONFIG_TWL4030_PWBUTTON_MODULE)
+#define twl_has_pwrbutton()	true
+#else
+#define twl_has_pwrbutton()	false
+#endif
 
 /* Triton Core internal information (BEGIN) */
 
@@ -534,6 +539,13 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
 		usb_transceiver = child;
 	}
 
+	if (twl_has_pwrbutton()) {
+		child = add_child(1, "twl4030_pwrbutton",
+				NULL, 0, true, pdata->irq_base + 8 + 0, 0);
+		if (IS_ERR(child))
+			return PTR_ERR(child);
+	}
+
 	if (twl_has_regulator()) {
 		/*
 		child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1);
Signature · 1 line
1.6.1.3
#2 lore raw

PATCH 2/2 twl4030: move twl4030-pwrbutton to drivers/input/misc

Take it out of drivers/i2c/chips as requested by Jean Delvare that all drivers move out of there.

Cc David Brownell <[email protected]>
Cc Samuel Ortiz <[email protected]>
---
 drivers/i2c/chips/Kconfig                          |    4 ----
 drivers/i2c/chips/Makefile                         |    1 -
 drivers/input/misc/Kconfig                         |    4 ++++
 drivers/input/misc/Makefile                        |    1 +
 .../{i2c/chips => input/misc}/twl4030-pwrbutton.c  |    0
 drivers/mfd/twl4030-core.c                         |    3 ++-
 6 files changed, 7 insertions(+), 6 deletions(-)
 rename drivers/{i2c/chips => input/misc}/twl4030-pwrbutton.c (100%)
drivers/i2c/chips/Kconfig +0 -4
index e4831e1..bf7bd1b 100644
@@ -98,10 +98,6 @@ config TWL4030_MADC
 	  to build it as a dinamically loadable module. The module will be
 	  called twl4030-madc.ko
 
-config TWL4030_PWRBUTTON
-	tristate "TWL4030 Power button Driver"
-	depends on TWL4030_CORE
-
 config TWL4030_POWEROFF
 	tristate "TWL4030 device poweroff"
 	depends on TWL4030_CORE
drivers/i2c/chips/Makefile +0 -1
index 1c94712..8da23ee 100644
@@ -18,7 +18,6 @@ obj-$(CONFIG_PCF8575)		+= pcf8575.o
 obj-$(CONFIG_SENSORS_PCF8591)	+= pcf8591.o
 obj-$(CONFIG_SENSORS_TSL2550)	+= tsl2550.o
 obj-$(CONFIG_TWL4030_POWEROFF)	+= twl4030-poweroff.o
-obj-$(CONFIG_TWL4030_PWRBUTTON)	+= twl4030-pwrbutton.o
 obj-$(CONFIG_TWL4030_MADC)	+= twl4030-madc.o
 obj-$(CONFIG_RTC_X1205_I2C)	+= x1205.o
 
drivers/input/misc/Kconfig +4 -0
index 67e5553..9667b50 100644
@@ -193,6 +193,10 @@ config INPUT_CM109
 	  To compile this driver as a module, choose M here: the module will be
 	  called cm109.
 
+config INPUT_TWL4030_PWRBUTTON
+	tristate "TWL4030 Power button Driver"
+	depends on TWL4030_CORE
+
 config INPUT_UINPUT
 	tristate "User level driver support"
 	help
drivers/input/misc/Makefile +1 -0
index bb62e6e..2fabcdb 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_INPUT_YEALINK)		+= yealink.o
 obj-$(CONFIG_INPUT_CM109)		+= cm109.o
 obj-$(CONFIG_HP_SDC_RTC)		+= hp_sdc_rtc.o
 obj-$(CONFIG_INPUT_UINPUT)		+= uinput.o
+obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON)	+= twl4030-pwrbutton.o
 obj-$(CONFIG_INPUT_APANEL)		+= apanel.o
 obj-$(CONFIG_INPUT_SGI_BTNS)		+= sgi_btns.o
 obj-$(CONFIG_INPUT_PCF50633_PMU)	+= pcf50633-input.o
drivers/input/misc/twl4030-pwrbutton.c renamed from drivers/i2c/chips/twl4030-pwrbutton.c +0 -0
similarity index 100%
rename from drivers/i2c/chips/twl4030-pwrbutton.c
rename to drivers/input/misc/twl4030-pwrbutton.c
drivers/mfd/twl4030-core.c +2 -1
index 1552296..bb25a4f 100644
@@ -107,7 +107,8 @@
 #define twl_has_usb()	false
 #endif
 
-#if defined(CONFIG_TWL4030_PWRBUTTON) || defined(CONFIG_TWL4030_PWBUTTON_MODULE)
+#if defined(CONFIG_INPUT_TWL4030_PWRBUTTON) \
+	|| defined(CONFIG_INPUT_TWL4030_PWBUTTON_MODULE)
 #define twl_has_pwrbutton()	true
 #else
 #define twl_has_pwrbutton()	false
Signature · 1 line
1.6.1.3
#3 lore raw

Re: [PATCH 2/2] twl4030: move twl4030-pwrbutton to drivers/input/misc

Quoted 6 lines · Felipe Balbi

Take it out of drivers/i2c/chips as requested by Jean Delvare that all drivers move out of there.

Cc David Brownell <[email protected]>
Cc Samuel Ortiz <[email protected]>

You're cc'ing Sam on these patches to the OMAP tree ... are you suggesting this code merge to mainline?

If so, you'll need to send the input driver to the input list as a patch against mainline, for review. The snippet from your patch 1/2 affecting the twl4030 MFD core might reasonably be merged with that, assuming Sam's OK with that going though the input tree.

- Dave

Quoted 10 lines
---
 drivers/i2c/chips/Kconfig                          |    4 ----
 drivers/i2c/chips/Makefile                         |    1 -
 drivers/input/misc/Kconfig                         |    4 ++++
 drivers/input/misc/Makefile                        |    1 +
 .../{i2c/chips => input/misc}/twl4030-pwrbutton.c  |    0
 drivers/mfd/twl4030-core.c                         |    3 ++-
 6 files changed, 7 insertions(+), 6 deletions(-)
 rename drivers/{i2c/chips => input/misc}/twl4030-pwrbutton.c (100%)
#4 lore raw

Re: [PATCH 2/2] twl4030: move twl4030-pwrbutton to drivers/input/misc

Quoted 10 lines · David Brownell
Quoted 6 lines · Felipe Balbi

Take it out of drivers/i2c/chips as requested by Jean Delvare that all drivers move out of there.

Cc David Brownell <[email protected]>
Cc Samuel Ortiz <[email protected]>

You're cc'ing Sam on these patches to the OMAP tree ... are you suggesting this code merge to mainline?

Just so he knows I'm willing to add a few more changes to twl4030-core.c, If you're ok with these patches, I'll send the final version to Sam, mainline and linux-input.

Quoted 5 lines

If so, you'll need to send the input driver to the input list as a patch against mainline, for review. The snippet from your patch 1/2 affecting the twl4030 MFD core might reasonably be merged with that, assuming Sam's OK with that going though the input tree.

I could also make them separate. Send the final drivers/input/misc/twl4030-pwrbutton.c to linux-input and the twl4030-core.c to be merged via Sam.

Signature · 1 line
balbi
#5 lore raw

Re: [PATCH 2/2] twl4030: move twl4030-pwrbutton to drivers/input/misc

Quoted 22 lines · Felipe Balbi
Quoted 10 lines · David Brownell
Quoted 6 lines · Felipe Balbi

Take it out of drivers/i2c/chips as requested by Jean Delvare that all drivers move out of there.

Cc David Brownell <[email protected]>
Cc Samuel Ortiz <[email protected]>

You're cc'ing Sam on these patches to the OMAP tree ... are you suggesting this code merge to mainline?

Just so he knows I'm willing to add a few more changes to twl4030-core.c, If you're ok with these patches, I'll send the final version to Sam, mainline and linux-input.

Quoted 5 lines

If so, you'll need to send the input driver to the input list as a patch against mainline, for review. The snippet from your patch 1/2 affecting the twl4030 MFD core might reasonably be merged with that, assuming Sam's OK with that going though the input tree.

Quoted 3 lines

I could also make them separate. Send the final drivers/input/misc/twl4030-pwrbutton.c to linux-input and the twl4030-core.c to be merged via Sam.

Does anyone have anything against this patch ? If not, I guess it should be applied and I'll generate the patch against mainline for input + mfd maintainers.

Signature · 1 line
balbi
maintainer
#6 lore raw

Re: [PATCH 2/2] twl4030: move twl4030-pwrbutton to drivers/input/misc

Quoted 23 lines · Felipe Balbi
Quoted 22 lines · Felipe Balbi
Quoted 10 lines · David Brownell
Quoted 6 lines · Felipe Balbi

Take it out of drivers/i2c/chips as requested by Jean Delvare that all drivers move out of there.

Cc David Brownell <[email protected]>
Cc Samuel Ortiz <[email protected]>

You're cc'ing Sam on these patches to the OMAP tree ... are you suggesting this code merge to mainline?

Just so he knows I'm willing to add a few more changes to twl4030-core.c, If you're ok with these patches, I'll send the final version to Sam, mainline and linux-input.

Quoted 5 lines

If so, you'll need to send the input driver to the input list as a patch against mainline, for review. The snippet from your patch 1/2 affecting the twl4030 MFD core might reasonably be merged with that, assuming Sam's OK with that going though the input tree.

Quoted 7 lines
Quoted 3 lines

I could also make them separate. Send the final drivers/input/misc/twl4030-pwrbutton.c to linux-input and the twl4030-core.c to be merged via Sam.

Does anyone have anything against this patch ? If not, I guess it should be applied and I'll generate the patch against mainline for input + mfd maintainers.

OK, pushed. These are currently also scheduled for getting reset to mainline twl code after v2.6.29-omap1 is tagged.

Regards,

Tony

#7 lore raw

Re: [PATCH 2/2] twl4030: move twl4030-pwrbutton to drivers/input/misc

Quoted 2 lines · Tony Lindgren

OK, pushed. These are currently also scheduled for getting reset to mainline twl code after v2.6.29-omap1 is tagged.

Just pushed to lkml, there will be one discrepancy with a debugging message easily fixable in a merge if you just use mainline's version, or I can send a fixup patch, if you wish.

Signature · 1 line
balbi
maintainer
#8 lore raw

Re: [PATCH 2/2] twl4030: move twl4030-pwrbutton to drivers/input/misc

Quoted 7 lines · Felipe Balbi
Quoted 2 lines · Tony Lindgren

OK, pushed. These are currently also scheduled for getting reset to mainline twl code after v2.6.29-omap1 is tagged.

Just pushed to lkml, there will be one discrepancy with a debugging message easily fixable in a merge if you just use mainline's version, or I can send a fixup patch, if you wish.

Well if you can send the patch, then that would be easiest. Patching based on the description usually cause something to go wrong :)

Tony

#9 lore raw

Re: [PATCH 2/2] twl4030: move twl4030-pwrbutton to drivers/input/misc

Quoted 11 lines · Tony Lindgren
Quoted 7 lines · Felipe Balbi
Quoted 2 lines · Tony Lindgren

OK, pushed. These are currently also scheduled for getting reset to mainline twl code after v2.6.29-omap1 is tagged.

Just pushed to lkml, there will be one discrepancy with a debugging message easily fixable in a merge if you just use mainline's version, or I can send a fixup patch, if you wish.

Well if you can send the patch, then that would be easiest. Patching based on the description usually cause something to go wrong :)

Let's then wait a bit longer and see if Sam or Dmitry will have anything to say about the driver, after that I can send one patch only.

Signature · 1 line
balbi
maintainer
#10 lore raw

Re: [PATCH 2/2] twl4030: move twl4030-pwrbutton to drivers/input/misc

Quoted 10 lines · Felipe Balbi
Quoted 9 lines · Tony Lindgren
Quoted 7 lines · Felipe Balbi
Quoted 2 lines · Tony Lindgren

OK, pushed. These are currently also scheduled for getting reset to mainline twl code after v2.6.29-omap1 is tagged.

Just pushed to lkml, there will be one discrepancy with a debugging message easily fixable in a merge if you just use mainline's version, or I can send a fixup patch, if you wish.

Quoted 5 lines
Quoted 2 lines

Well if you can send the patch, then that would be easiest. Patching based on the description usually cause something to go wrong :)

Let's then wait a bit longer and see if Sam or Dmitry will have anything to say about the driver, after that I can send one patch only.

OK

Tony

#11 lore raw

PATCH 1/1 input: twl4030-pwrbutton: avoid merge conflicts

In reply to Felipe Balbi

sync up with the version going upstream.

---
This patch is syncing with the fixed up version accepted in mainline. Should be applied to avoid merge conflicts on the next merge window.

 drivers/input/misc/Kconfig             |    6 ++
 drivers/input/misc/twl4030-pwrbutton.c |   87 ++++++++++++++++----------------
 2 files changed, 49 insertions(+), 44 deletions(-)
drivers/input/misc/Kconfig +6 -0
index 9667b50..6fa9e38 100644
@@ -196,6 +196,12 @@ config INPUT_CM109
 config INPUT_TWL4030_PWRBUTTON
 	tristate "TWL4030 Power button Driver"
 	depends on TWL4030_CORE
+	help
+	  Say Y here if you want to enable power key reporting via the
+	  TWL4030 family of chips.
+
+	  To compile this driver as a module, choose M here. The module will
+	  be called twl4030_pwrbutton.
 
 config INPUT_UINPUT
 	tristate "User level driver support"
drivers/input/misc/twl4030-pwrbutton.c +43 -44

156 lines not on this page · raw message

Signature · 1 line
1.6.2.rc0.61.g5cd12