* [PATCH 0/5] AM437x SK: Add power-button support @ 2014-12-26 19:28 Felipe Balbi 2014-12-26 19:28 ` [PATCH 1/5] mfd: tps65218: make INT[12] and STATUS registers volatile Felipe Balbi ` (4 more replies) 0 siblings, 5 replies; 21+ messages in thread From: Felipe Balbi @ 2014-12-26 19:28 UTC (permalink / raw) To: linux-arm-kernel Hi, the following patches add tps65218 power button support and make it usable with AM437x SK. Developed and tested on top of v3.19-rc1. Logs at [1] [1] http://hastebin.com/ecopenuqot Felipe Balbi (5): mfd: tps65218: make INT[12] and STATUS registers volatile mfd: tps65218: make INT1 our status_base register input: misc: add tps65218 power button driver arm: boot: dts: am437x-sk: add power button binding arm: omap2plus_defconfig: enable TPS65218 power button arch/arm/boot/dts/am437x-sk-evm.dts | 5 ++ arch/arm/configs/omap2plus_defconfig | 1 + drivers/input/misc/Kconfig | 10 +++ drivers/input/misc/Makefile | 1 + drivers/input/misc/tps65218-pwrbutton.c | 135 ++++++++++++++++++++++++++++++++ drivers/mfd/tps65218.c | 12 +++ 6 files changed, 164 insertions(+) create mode 100644 drivers/input/misc/tps65218-pwrbutton.c -- 2.2.0 ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 1/5] mfd: tps65218: make INT[12] and STATUS registers volatile 2014-12-26 19:28 [PATCH 0/5] AM437x SK: Add power-button support Felipe Balbi @ 2014-12-26 19:28 ` Felipe Balbi 2015-01-06 17:37 ` Felipe Balbi 2015-01-18 9:52 ` Lee Jones 2014-12-26 19:28 ` [PATCH 2/5] mfd: tps65218: make INT1 our status_base register Felipe Balbi ` (3 subsequent siblings) 4 siblings, 2 replies; 21+ messages in thread From: Felipe Balbi @ 2014-12-26 19:28 UTC (permalink / raw) To: linux-arm-kernel STATUS register can be modified by the HW, so we should bypass cache because of that. In the case of INT[12] registers, they are the ones that actually clear the IRQ source at the time they are read. If we rely on the cache for them, we will never be able to clear the interrupt, which will cause our IRQ line to be disabled due to IRQ throttling. Fixes: 44b4dc6 mfd: tps65218: Add driver for the TPS65218 PMIC Cc: <stable@vger.kernel.org> # v3.15+ Cc: Keerthy <j-keerthy@ti.com> Cc: Lee Jones <lee.jones@linaro.org> Signed-off-by: Felipe Balbi <balbi@ti.com> --- drivers/mfd/tps65218.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/mfd/tps65218.c b/drivers/mfd/tps65218.c index 0d256cb..2243f75 100644 --- a/drivers/mfd/tps65218.c +++ b/drivers/mfd/tps65218.c @@ -125,10 +125,21 @@ int tps65218_clear_bits(struct tps65218 *tps, unsigned int reg, } EXPORT_SYMBOL_GPL(tps65218_clear_bits); +static const struct regmap_range tps65218_yes_ranges[] = { + regmap_reg_range(TPS65218_REG_INT1, TPS65218_REG_INT2), + regmap_reg_range(TPS65218_REG_STATUS, TPS65218_REG_STATUS), +}; + +static const struct regmap_access_table tps65218_volatile_table = { + .yes_ranges = tps65218_yes_ranges, + .n_yes_ranges = ARRAY_SIZE(tps65218_yes_ranges), +}; + static struct regmap_config tps65218_regmap_config = { .reg_bits = 8, .val_bits = 8, .cache_type = REGCACHE_RBTREE, + .volatile_table = &tps65218_volatile_table, }; static const struct regmap_irq tps65218_irqs[] = { -- 2.2.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 1/5] mfd: tps65218: make INT[12] and STATUS registers volatile 2014-12-26 19:28 ` [PATCH 1/5] mfd: tps65218: make INT[12] and STATUS registers volatile Felipe Balbi @ 2015-01-06 17:37 ` Felipe Balbi 2015-01-08 16:25 ` Felipe Balbi 2015-01-18 9:52 ` Lee Jones 1 sibling, 1 reply; 21+ messages in thread From: Felipe Balbi @ 2015-01-06 17:37 UTC (permalink / raw) To: linux-arm-kernel On Fri, Dec 26, 2014 at 01:28:20PM -0600, Felipe Balbi wrote: > STATUS register can be modified by the HW, so we > should bypass cache because of that. > > In the case of INT[12] registers, they are the ones > that actually clear the IRQ source at the time they > are read. If we rely on the cache for them, we will > never be able to clear the interrupt, which will cause > our IRQ line to be disabled due to IRQ throttling. > > Fixes: 44b4dc6 mfd: tps65218: Add driver for the TPS65218 PMIC > Cc: <stable@vger.kernel.org> # v3.15+ > Cc: Keerthy <j-keerthy@ti.com> > Cc: Lee Jones <lee.jones@linaro.org> > Signed-off-by: Felipe Balbi <balbi@ti.com> ping > --- > drivers/mfd/tps65218.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/mfd/tps65218.c b/drivers/mfd/tps65218.c > index 0d256cb..2243f75 100644 > --- a/drivers/mfd/tps65218.c > +++ b/drivers/mfd/tps65218.c > @@ -125,10 +125,21 @@ int tps65218_clear_bits(struct tps65218 *tps, unsigned int reg, > } > EXPORT_SYMBOL_GPL(tps65218_clear_bits); > > +static const struct regmap_range tps65218_yes_ranges[] = { > + regmap_reg_range(TPS65218_REG_INT1, TPS65218_REG_INT2), > + regmap_reg_range(TPS65218_REG_STATUS, TPS65218_REG_STATUS), > +}; > + > +static const struct regmap_access_table tps65218_volatile_table = { > + .yes_ranges = tps65218_yes_ranges, > + .n_yes_ranges = ARRAY_SIZE(tps65218_yes_ranges), > +}; > + > static struct regmap_config tps65218_regmap_config = { > .reg_bits = 8, > .val_bits = 8, > .cache_type = REGCACHE_RBTREE, > + .volatile_table = &tps65218_volatile_table, > }; > > static const struct regmap_irq tps65218_irqs[] = { > -- > 2.2.0 > -- balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150106/bc31b617/attachment-0001.sig> ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 1/5] mfd: tps65218: make INT[12] and STATUS registers volatile 2015-01-06 17:37 ` Felipe Balbi @ 2015-01-08 16:25 ` Felipe Balbi 2015-01-12 16:46 ` Felipe Balbi 0 siblings, 1 reply; 21+ messages in thread From: Felipe Balbi @ 2015-01-08 16:25 UTC (permalink / raw) To: linux-arm-kernel On Tue, Jan 06, 2015 at 11:37:34AM -0600, Felipe Balbi wrote: > On Fri, Dec 26, 2014 at 01:28:20PM -0600, Felipe Balbi wrote: > > STATUS register can be modified by the HW, so we > > should bypass cache because of that. > > > > In the case of INT[12] registers, they are the ones > > that actually clear the IRQ source at the time they > > are read. If we rely on the cache for them, we will > > never be able to clear the interrupt, which will cause > > our IRQ line to be disabled due to IRQ throttling. > > > > Fixes: 44b4dc6 mfd: tps65218: Add driver for the TPS65218 PMIC > > Cc: <stable@vger.kernel.org> # v3.15+ > > Cc: Keerthy <j-keerthy@ti.com> > > Cc: Lee Jones <lee.jones@linaro.org> > > Signed-off-by: Felipe Balbi <balbi@ti.com> > > ping another ping. Without this and the following patch TPS65218 power button driver which was already applied by Dmitry, won't work. > > --- > > drivers/mfd/tps65218.c | 11 +++++++++++ > > 1 file changed, 11 insertions(+) > > > > diff --git a/drivers/mfd/tps65218.c b/drivers/mfd/tps65218.c > > index 0d256cb..2243f75 100644 > > --- a/drivers/mfd/tps65218.c > > +++ b/drivers/mfd/tps65218.c > > @@ -125,10 +125,21 @@ int tps65218_clear_bits(struct tps65218 *tps, unsigned int reg, > > } > > EXPORT_SYMBOL_GPL(tps65218_clear_bits); > > > > +static const struct regmap_range tps65218_yes_ranges[] = { > > + regmap_reg_range(TPS65218_REG_INT1, TPS65218_REG_INT2), > > + regmap_reg_range(TPS65218_REG_STATUS, TPS65218_REG_STATUS), > > +}; > > + > > +static const struct regmap_access_table tps65218_volatile_table = { > > + .yes_ranges = tps65218_yes_ranges, > > + .n_yes_ranges = ARRAY_SIZE(tps65218_yes_ranges), > > +}; > > + > > static struct regmap_config tps65218_regmap_config = { > > .reg_bits = 8, > > .val_bits = 8, > > .cache_type = REGCACHE_RBTREE, > > + .volatile_table = &tps65218_volatile_table, > > }; > > > > static const struct regmap_irq tps65218_irqs[] = { > > -- > > 2.2.0 > > > > -- > balbi -- balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150108/b6f478c2/attachment.sig> ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 1/5] mfd: tps65218: make INT[12] and STATUS registers volatile 2015-01-08 16:25 ` Felipe Balbi @ 2015-01-12 16:46 ` Felipe Balbi 2015-01-14 17:07 ` Tony Lindgren 0 siblings, 1 reply; 21+ messages in thread From: Felipe Balbi @ 2015-01-12 16:46 UTC (permalink / raw) To: linux-arm-kernel Hi, On Thu, Jan 08, 2015 at 10:25:12AM -0600, Felipe Balbi wrote: > On Tue, Jan 06, 2015 at 11:37:34AM -0600, Felipe Balbi wrote: > > On Fri, Dec 26, 2014 at 01:28:20PM -0600, Felipe Balbi wrote: > > > STATUS register can be modified by the HW, so we > > > should bypass cache because of that. > > > > > > In the case of INT[12] registers, they are the ones > > > that actually clear the IRQ source at the time they > > > are read. If we rely on the cache for them, we will > > > never be able to clear the interrupt, which will cause > > > our IRQ line to be disabled due to IRQ throttling. > > > > > > Fixes: 44b4dc6 mfd: tps65218: Add driver for the TPS65218 PMIC > > > Cc: <stable@vger.kernel.org> # v3.15+ > > > Cc: Keerthy <j-keerthy@ti.com> > > > Cc: Lee Jones <lee.jones@linaro.org> > > > Signed-off-by: Felipe Balbi <balbi@ti.com> > > > > ping > > another ping. Without this and the following patch TPS65218 power button > driver which was already applied by Dmitry, won't work. Anybody ? -rc4 is out and tps65218 is still broken because nobody has acted on these two patches. All other patches which are meant for 3.20 merge window are applied and because of these pending, those patches won't work. > > > --- > > > drivers/mfd/tps65218.c | 11 +++++++++++ > > > 1 file changed, 11 insertions(+) > > > > > > diff --git a/drivers/mfd/tps65218.c b/drivers/mfd/tps65218.c > > > index 0d256cb..2243f75 100644 > > > --- a/drivers/mfd/tps65218.c > > > +++ b/drivers/mfd/tps65218.c > > > @@ -125,10 +125,21 @@ int tps65218_clear_bits(struct tps65218 *tps, unsigned int reg, > > > } > > > EXPORT_SYMBOL_GPL(tps65218_clear_bits); > > > > > > +static const struct regmap_range tps65218_yes_ranges[] = { > > > + regmap_reg_range(TPS65218_REG_INT1, TPS65218_REG_INT2), > > > + regmap_reg_range(TPS65218_REG_STATUS, TPS65218_REG_STATUS), > > > +}; > > > + > > > +static const struct regmap_access_table tps65218_volatile_table = { > > > + .yes_ranges = tps65218_yes_ranges, > > > + .n_yes_ranges = ARRAY_SIZE(tps65218_yes_ranges), > > > +}; > > > + > > > static struct regmap_config tps65218_regmap_config = { > > > .reg_bits = 8, > > > .val_bits = 8, > > > .cache_type = REGCACHE_RBTREE, > > > + .volatile_table = &tps65218_volatile_table, > > > }; > > > > > > static const struct regmap_irq tps65218_irqs[] = { > > > -- > > > 2.2.0 > > > > > > > -- > > balbi > > > > -- > balbi -- balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150112/f003e95c/attachment.sig> ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 1/5] mfd: tps65218: make INT[12] and STATUS registers volatile 2015-01-12 16:46 ` Felipe Balbi @ 2015-01-14 17:07 ` Tony Lindgren 2015-01-16 22:57 ` Felipe Balbi 0 siblings, 1 reply; 21+ messages in thread From: Tony Lindgren @ 2015-01-14 17:07 UTC (permalink / raw) To: linux-arm-kernel * Felipe Balbi <balbi@ti.com> [150112 08:50]: > Hi, > > On Thu, Jan 08, 2015 at 10:25:12AM -0600, Felipe Balbi wrote: > > On Tue, Jan 06, 2015 at 11:37:34AM -0600, Felipe Balbi wrote: > > > On Fri, Dec 26, 2014 at 01:28:20PM -0600, Felipe Balbi wrote: > > > > STATUS register can be modified by the HW, so we > > > > should bypass cache because of that. > > > > > > > > In the case of INT[12] registers, they are the ones > > > > that actually clear the IRQ source at the time they > > > > are read. If we rely on the cache for them, we will > > > > never be able to clear the interrupt, which will cause > > > > our IRQ line to be disabled due to IRQ throttling. > > > > > > > > Fixes: 44b4dc6 mfd: tps65218: Add driver for the TPS65218 PMIC > > > > Cc: <stable@vger.kernel.org> # v3.15+ > > > > Cc: Keerthy <j-keerthy@ti.com> > > > > Cc: Lee Jones <lee.jones@linaro.org> > > > > Signed-off-by: Felipe Balbi <balbi@ti.com> > > > > > > ping > > > > another ping. Without this and the following patch TPS65218 power button > > driver which was already applied by Dmitry, won't work. > > Anybody ? -rc4 is out and tps65218 is still broken because nobody has > acted on these two patches. All other patches which are meant for 3.20 > merge window are applied and because of these pending, those patches > won't work. Lee, are you planning to pick these two drivers/mfd patches? Regards, Tony ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 1/5] mfd: tps65218: make INT[12] and STATUS registers volatile 2015-01-14 17:07 ` Tony Lindgren @ 2015-01-16 22:57 ` Felipe Balbi 0 siblings, 0 replies; 21+ messages in thread From: Felipe Balbi @ 2015-01-16 22:57 UTC (permalink / raw) To: linux-arm-kernel Hi, On Wed, Jan 14, 2015 at 09:07:17AM -0800, Tony Lindgren wrote: > > > > > STATUS register can be modified by the HW, so we > > > > > should bypass cache because of that. > > > > > > > > > > In the case of INT[12] registers, they are the ones > > > > > that actually clear the IRQ source at the time they > > > > > are read. If we rely on the cache for them, we will > > > > > never be able to clear the interrupt, which will cause > > > > > our IRQ line to be disabled due to IRQ throttling. > > > > > > > > > > Fixes: 44b4dc6 mfd: tps65218: Add driver for the TPS65218 PMIC > > > > > Cc: <stable@vger.kernel.org> # v3.15+ > > > > > Cc: Keerthy <j-keerthy@ti.com> > > > > > Cc: Lee Jones <lee.jones@linaro.org> > > > > > Signed-off-by: Felipe Balbi <balbi@ti.com> > > > > > > > > ping > > > > > > another ping. Without this and the following patch TPS65218 power button > > > driver which was already applied by Dmitry, won't work. > > > > Anybody ? -rc4 is out and tps65218 is still broken because nobody has > > acted on these two patches. All other patches which are meant for 3.20 > > merge window are applied and because of these pending, those patches > > won't work. > > Lee, are you planning to pick these two drivers/mfd patches? Samuel, Lee, is someone planning on picking these two patches up ? v3.19 remains broken. -- balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150116/5feee76e/attachment.sig> ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 1/5] mfd: tps65218: make INT[12] and STATUS registers volatile 2014-12-26 19:28 ` [PATCH 1/5] mfd: tps65218: make INT[12] and STATUS registers volatile Felipe Balbi 2015-01-06 17:37 ` Felipe Balbi @ 2015-01-18 9:52 ` Lee Jones 2015-01-19 14:41 ` Felipe Balbi 1 sibling, 1 reply; 21+ messages in thread From: Lee Jones @ 2015-01-18 9:52 UTC (permalink / raw) To: linux-arm-kernel On Fri, 26 Dec 2014, Felipe Balbi wrote: > STATUS register can be modified by the HW, so we > should bypass cache because of that. > > In the case of INT[12] registers, they are the ones > that actually clear the IRQ source at the time they > are read. If we rely on the cache for them, we will > never be able to clear the interrupt, which will cause > our IRQ line to be disabled due to IRQ throttling. > > Fixes: 44b4dc6 mfd: tps65218: Add driver for the TPS65218 PMIC > Cc: <stable@vger.kernel.org> # v3.15+ > Cc: Keerthy <j-keerthy@ti.com> > Cc: Lee Jones <lee.jones@linaro.org> > Signed-off-by: Felipe Balbi <balbi@ti.com> > --- > drivers/mfd/tps65218.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) Sorry for the delay. It's difficult to get a WiFi signal 2000m up in an Austrian mountain. :) Applied now, thanks. > diff --git a/drivers/mfd/tps65218.c b/drivers/mfd/tps65218.c > index 0d256cb..2243f75 100644 > --- a/drivers/mfd/tps65218.c > +++ b/drivers/mfd/tps65218.c > @@ -125,10 +125,21 @@ int tps65218_clear_bits(struct tps65218 *tps, unsigned int reg, > } > EXPORT_SYMBOL_GPL(tps65218_clear_bits); > > +static const struct regmap_range tps65218_yes_ranges[] = { > + regmap_reg_range(TPS65218_REG_INT1, TPS65218_REG_INT2), > + regmap_reg_range(TPS65218_REG_STATUS, TPS65218_REG_STATUS), > +}; > + > +static const struct regmap_access_table tps65218_volatile_table = { > + .yes_ranges = tps65218_yes_ranges, > + .n_yes_ranges = ARRAY_SIZE(tps65218_yes_ranges), > +}; > + > static struct regmap_config tps65218_regmap_config = { > .reg_bits = 8, > .val_bits = 8, > .cache_type = REGCACHE_RBTREE, > + .volatile_table = &tps65218_volatile_table, > }; > > static const struct regmap_irq tps65218_irqs[] = { -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 1/5] mfd: tps65218: make INT[12] and STATUS registers volatile 2015-01-18 9:52 ` Lee Jones @ 2015-01-19 14:41 ` Felipe Balbi 0 siblings, 0 replies; 21+ messages in thread From: Felipe Balbi @ 2015-01-19 14:41 UTC (permalink / raw) To: linux-arm-kernel On Sun, Jan 18, 2015 at 09:52:14AM +0000, Lee Jones wrote: > On Fri, 26 Dec 2014, Felipe Balbi wrote: > > > STATUS register can be modified by the HW, so we > > should bypass cache because of that. > > > > In the case of INT[12] registers, they are the ones > > that actually clear the IRQ source at the time they > > are read. If we rely on the cache for them, we will > > never be able to clear the interrupt, which will cause > > our IRQ line to be disabled due to IRQ throttling. > > > > Fixes: 44b4dc6 mfd: tps65218: Add driver for the TPS65218 PMIC > > Cc: <stable@vger.kernel.org> # v3.15+ > > Cc: Keerthy <j-keerthy@ti.com> > > Cc: Lee Jones <lee.jones@linaro.org> > > Signed-off-by: Felipe Balbi <balbi@ti.com> > > --- > > drivers/mfd/tps65218.c | 11 +++++++++++ > > 1 file changed, 11 insertions(+) > > Sorry for the delay. It's difficult to get a WiFi signal 2000m up in > an Austrian mountain. :) now you're just making excuses ;-) > Applied now, thanks. thanks :-) -- balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150119/92854f0d/attachment.sig> ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 2/5] mfd: tps65218: make INT1 our status_base register 2014-12-26 19:28 [PATCH 0/5] AM437x SK: Add power-button support Felipe Balbi 2014-12-26 19:28 ` [PATCH 1/5] mfd: tps65218: make INT[12] and STATUS registers volatile Felipe Balbi @ 2014-12-26 19:28 ` Felipe Balbi 2015-01-06 17:37 ` Felipe Balbi 2015-01-18 9:52 ` Lee Jones 2014-12-26 19:28 ` [PATCH 3/5] input: misc: add tps65218 power button driver Felipe Balbi ` (2 subsequent siblings) 4 siblings, 2 replies; 21+ messages in thread From: Felipe Balbi @ 2014-12-26 19:28 UTC (permalink / raw) To: linux-arm-kernel If we don't tell regmap-irq that our first status register is at offset 1, it will try to read offset zero, which is the chipid register. Fixes: 44b4dc6 mfd: tps65218: Add driver for the TPS65218 PMIC Cc: <stable@vger.kernel.org> # v3.15+ Cc: Keerthy <j-keerthy@ti.com> Cc: Lee Jones <lee.jones@linaro.org> Signed-off-by: Felipe Balbi <balbi@ti.com> --- drivers/mfd/tps65218.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mfd/tps65218.c b/drivers/mfd/tps65218.c index 2243f75..d6b7643 100644 --- a/drivers/mfd/tps65218.c +++ b/drivers/mfd/tps65218.c @@ -204,6 +204,7 @@ static struct regmap_irq_chip tps65218_irq_chip = { .num_regs = 2, .mask_base = TPS65218_REG_INT_MASK1, + .status_base = TPS65218_REG_INT1, }; static const struct of_device_id of_tps65218_match_table[] = { -- 2.2.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 2/5] mfd: tps65218: make INT1 our status_base register 2014-12-26 19:28 ` [PATCH 2/5] mfd: tps65218: make INT1 our status_base register Felipe Balbi @ 2015-01-06 17:37 ` Felipe Balbi 2015-01-18 9:52 ` Lee Jones 1 sibling, 0 replies; 21+ messages in thread From: Felipe Balbi @ 2015-01-06 17:37 UTC (permalink / raw) To: linux-arm-kernel On Fri, Dec 26, 2014 at 01:28:21PM -0600, Felipe Balbi wrote: > If we don't tell regmap-irq that our first status > register is at offset 1, it will try to read offset > zero, which is the chipid register. > > Fixes: 44b4dc6 mfd: tps65218: Add driver for the TPS65218 PMIC > Cc: <stable@vger.kernel.org> # v3.15+ > Cc: Keerthy <j-keerthy@ti.com> > Cc: Lee Jones <lee.jones@linaro.org> > Signed-off-by: Felipe Balbi <balbi@ti.com> ping > --- > drivers/mfd/tps65218.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/mfd/tps65218.c b/drivers/mfd/tps65218.c > index 2243f75..d6b7643 100644 > --- a/drivers/mfd/tps65218.c > +++ b/drivers/mfd/tps65218.c > @@ -204,6 +204,7 @@ static struct regmap_irq_chip tps65218_irq_chip = { > > .num_regs = 2, > .mask_base = TPS65218_REG_INT_MASK1, > + .status_base = TPS65218_REG_INT1, > }; > > static const struct of_device_id of_tps65218_match_table[] = { > -- > 2.2.0 > -- balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150106/1074b56b/attachment-0001.sig> ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 2/5] mfd: tps65218: make INT1 our status_base register 2014-12-26 19:28 ` [PATCH 2/5] mfd: tps65218: make INT1 our status_base register Felipe Balbi 2015-01-06 17:37 ` Felipe Balbi @ 2015-01-18 9:52 ` Lee Jones 1 sibling, 0 replies; 21+ messages in thread From: Lee Jones @ 2015-01-18 9:52 UTC (permalink / raw) To: linux-arm-kernel On Fri, 26 Dec 2014, Felipe Balbi wrote: > If we don't tell regmap-irq that our first status > register is at offset 1, it will try to read offset > zero, which is the chipid register. > > Fixes: 44b4dc6 mfd: tps65218: Add driver for the TPS65218 PMIC > Cc: <stable@vger.kernel.org> # v3.15+ > Cc: Keerthy <j-keerthy@ti.com> > Cc: Lee Jones <lee.jones@linaro.org> > Signed-off-by: Felipe Balbi <balbi@ti.com> > --- > drivers/mfd/tps65218.c | 1 + > 1 file changed, 1 insertion(+) Sorry for the delay. It's difficult to get a WiFi signal 2000m up in an Austrian mountain. :) Applied now, thanks. > diff --git a/drivers/mfd/tps65218.c b/drivers/mfd/tps65218.c > index 2243f75..d6b7643 100644 > --- a/drivers/mfd/tps65218.c > +++ b/drivers/mfd/tps65218.c > @@ -204,6 +204,7 @@ static struct regmap_irq_chip tps65218_irq_chip = { > > .num_regs = 2, > .mask_base = TPS65218_REG_INT_MASK1, > + .status_base = TPS65218_REG_INT1, > }; > > static const struct of_device_id of_tps65218_match_table[] = { -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 3/5] input: misc: add tps65218 power button driver 2014-12-26 19:28 [PATCH 0/5] AM437x SK: Add power-button support Felipe Balbi 2014-12-26 19:28 ` [PATCH 1/5] mfd: tps65218: make INT[12] and STATUS registers volatile Felipe Balbi 2014-12-26 19:28 ` [PATCH 2/5] mfd: tps65218: make INT1 our status_base register Felipe Balbi @ 2014-12-26 19:28 ` Felipe Balbi 2014-12-26 19:33 ` Felipe Balbi 2014-12-26 23:41 ` Dmitry Torokhov 2014-12-26 19:28 ` [PATCH 4/5] arm: boot: dts: am437x-sk: add power button binding Felipe Balbi 2014-12-26 19:28 ` [PATCH 5/5] arm: omap2plus_defconfig: enable TPS65218 power button Felipe Balbi 4 siblings, 2 replies; 21+ messages in thread From: Felipe Balbi @ 2014-12-26 19:28 UTC (permalink / raw) To: linux-arm-kernel With this driver, we can report KEY_POWER on AM437x SK. This patch has been tested with said board. Signed-off-by: Felipe Balbi <balbi@ti.com> --- drivers/input/misc/Kconfig | 10 +++ drivers/input/misc/Makefile | 1 + drivers/input/misc/tps65218-pwrbutton.c | 135 ++++++++++++++++++++++++++++++++ 3 files changed, 146 insertions(+) create mode 100644 drivers/input/misc/tps65218-pwrbutton.c diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 23297ab..364cfb8 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -404,6 +404,16 @@ config INPUT_RETU_PWRBUTTON To compile this driver as a module, choose M here. The module will be called retu-pwrbutton. +config INPUT_TPS65218_PWRBUTTON + tristate "TPS65218 Power button driver" + depends on MFD_TPS65218 + help + Say Y here if you want to enable power buttong reporting for + the TPS65218 Power Management IC device. + + To compile this driver as a module, choose M here. The module will + be called tps65218-pwrbutton. + config INPUT_TWL4030_PWRBUTTON tristate "TWL4030 Power button Driver" depends on TWL4030_CORE diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 19c7603..a923753 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -59,6 +59,7 @@ obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o obj-$(CONFIG_INPUT_SIRFSOC_ONKEY) += sirfsoc-onkey.o obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY) += soc_button_array.o obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o +obj-$(CONFIG_INPUT_TPS65218_PWRBUTTON) += tps65218-pwrbutton.o obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON) += twl4030-pwrbutton.o obj-$(CONFIG_INPUT_TWL4030_VIBRA) += twl4030-vibra.o obj-$(CONFIG_INPUT_TWL6040_VIBRA) += twl6040-vibra.o diff --git a/drivers/input/misc/tps65218-pwrbutton.c b/drivers/input/misc/tps65218-pwrbutton.c new file mode 100644 index 0000000..a1f8a19 --- /dev/null +++ b/drivers/input/misc/tps65218-pwrbutton.c @@ -0,0 +1,135 @@ +/* + * Texas Instruments' TPS65218 Power Button Input Driver + * + * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ + * Author: Felipe Balbi <balbi@ti.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <linux/init.h> +#include <linux/input.h> +#include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/mfd/tps65218.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/slab.h> + +struct tps65218_pwrbutton { + struct device *dev; + struct tps65218 *tps; + struct input_dev *idev; + int irq; + + unsigned int pressed:1; +}; + +static irqreturn_t tps65218_pwr_irq(int irq, void *_pwr) +{ + struct tps65218_pwrbutton *pwr = _pwr; + unsigned int reg; + int ret; + + ret = tps65218_reg_read(pwr->tps, TPS65218_REG_STATUS, ®); + if (ret) { + dev_err(pwr->dev, "can't read register --> %d\n", ret); + goto out; + } + + if (reg & TPS65218_STATUS_PB_STATE) { + input_report_key(pwr->idev, KEY_POWER, 1); + pm_wakeup_event(pwr->dev, 0); + pwr->pressed = true; + } else { + /* + * we don't want to report KEY_POWER releases on any of the + * other IRQ sources. Only when button was previously pressed + */ + if (pwr->pressed) { + input_report_key(pwr->idev, KEY_POWER, 0); + pwr->pressed = false; + } + } + + input_sync(pwr->idev); + +out: + return IRQ_HANDLED; +} + +static int tps65218_pwron_probe(struct platform_device *pdev) +{ + struct tps65218 *tps = dev_get_drvdata(pdev->dev.parent); + struct device *dev = &pdev->dev; + struct tps65218_pwrbutton *pwr; + struct input_dev *idev; + int ret; + + pwr = devm_kzalloc(dev, sizeof(*pwr), GFP_KERNEL); + if (!pwr) + return -ENOMEM; + + idev = devm_input_allocate_device(dev); + if (!idev) + return -ENOMEM; + + idev->name = "tps65218_pwrbutton"; + idev->phys = "tps65218_pwrbutton/input0"; + idev->dev.parent = dev; + idev->id.bustype = BUS_I2C; + + input_set_capability(idev, EV_KEY, KEY_POWER); + + pwr->tps = tps; + pwr->dev = dev; + pwr->idev = idev; + pwr->irq = platform_get_irq(pdev, 0); + platform_set_drvdata(pdev, pwr); + device_init_wakeup(dev, true); + + ret = devm_request_threaded_irq(dev, pwr->irq, NULL, tps65218_pwr_irq, + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + dev_name(dev), pwr); + if (ret) { + dev_err(dev, "failed to request IRQ #%d --> %d\n", + pwr->irq, ret); + return ret; + } + + ret = input_register_device(idev); + if (ret) { + dev_err(dev, "Can't register power button --> %d\n", ret); + return ret; + } + + return 0; +} + +static struct of_device_id of_tps65218_pwr_match[] = { + { .compatible = "ti,tps65218-pwrbutton" }, + { }, +}; + +MODULE_DEVICE_TABLE(of, of_tps65218_pwr_match); + +static struct platform_driver tps65218_pwron_driver = { + .probe = tps65218_pwron_probe, + .driver = { + .name = "tps65218_pwrbutton", + .of_match_table = of_tps65218_pwr_match, + }, +}; +module_platform_driver(tps65218_pwron_driver); + +MODULE_DESCRIPTION("TPS65218 Power Button"); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); -- 2.2.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 3/5] input: misc: add tps65218 power button driver 2014-12-26 19:28 ` [PATCH 3/5] input: misc: add tps65218 power button driver Felipe Balbi @ 2014-12-26 19:33 ` Felipe Balbi 2014-12-26 23:41 ` Dmitry Torokhov 1 sibling, 0 replies; 21+ messages in thread From: Felipe Balbi @ 2014-12-26 19:33 UTC (permalink / raw) To: linux-arm-kernel Hi, On Fri, Dec 26, 2014 at 01:28:22PM -0600, Felipe Balbi wrote: > +static struct of_device_id of_tps65218_pwr_match[] = { > + { .compatible = "ti,tps65218-pwrbutton" }, forgot to document this compatible. I'll add it localy but still wait a a few days before resending so people have time to review. -- balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141226/0d6d889b/attachment.sig> ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 3/5] input: misc: add tps65218 power button driver 2014-12-26 19:28 ` [PATCH 3/5] input: misc: add tps65218 power button driver Felipe Balbi 2014-12-26 19:33 ` Felipe Balbi @ 2014-12-26 23:41 ` Dmitry Torokhov 2014-12-27 3:36 ` [PATCH v2 " Felipe Balbi 1 sibling, 1 reply; 21+ messages in thread From: Dmitry Torokhov @ 2014-12-26 23:41 UTC (permalink / raw) To: linux-arm-kernel Hi Felipe, On Fri, Dec 26, 2014 at 01:28:22PM -0600, Felipe Balbi wrote: > With this driver, we can report KEY_POWER on > AM437x SK. This patch has been tested with said > board. > > Signed-off-by: Felipe Balbi <balbi@ti.com> > --- > drivers/input/misc/Kconfig | 10 +++ > drivers/input/misc/Makefile | 1 + > drivers/input/misc/tps65218-pwrbutton.c | 135 ++++++++++++++++++++++++++++++++ > 3 files changed, 146 insertions(+) > create mode 100644 drivers/input/misc/tps65218-pwrbutton.c > > diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig > index 23297ab..364cfb8 100644 > --- a/drivers/input/misc/Kconfig > +++ b/drivers/input/misc/Kconfig > @@ -404,6 +404,16 @@ config INPUT_RETU_PWRBUTTON > To compile this driver as a module, choose M here. The module will > be called retu-pwrbutton. > > +config INPUT_TPS65218_PWRBUTTON > + tristate "TPS65218 Power button driver" > + depends on MFD_TPS65218 > + help > + Say Y here if you want to enable power buttong reporting for > + the TPS65218 Power Management IC device. > + > + To compile this driver as a module, choose M here. The module will > + be called tps65218-pwrbutton. > + > config INPUT_TWL4030_PWRBUTTON > tristate "TWL4030 Power button Driver" > depends on TWL4030_CORE > diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile > index 19c7603..a923753 100644 > --- a/drivers/input/misc/Makefile > +++ b/drivers/input/misc/Makefile > @@ -59,6 +59,7 @@ obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o > obj-$(CONFIG_INPUT_SIRFSOC_ONKEY) += sirfsoc-onkey.o > obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY) += soc_button_array.o > obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o > +obj-$(CONFIG_INPUT_TPS65218_PWRBUTTON) += tps65218-pwrbutton.o > obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON) += twl4030-pwrbutton.o > obj-$(CONFIG_INPUT_TWL4030_VIBRA) += twl4030-vibra.o > obj-$(CONFIG_INPUT_TWL6040_VIBRA) += twl6040-vibra.o > diff --git a/drivers/input/misc/tps65218-pwrbutton.c b/drivers/input/misc/tps65218-pwrbutton.c > new file mode 100644 > index 0000000..a1f8a19 > --- /dev/null > +++ b/drivers/input/misc/tps65218-pwrbutton.c > @@ -0,0 +1,135 @@ > +/* > + * Texas Instruments' TPS65218 Power Button Input Driver > + * > + * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ > + * Author: Felipe Balbi <balbi@ti.com> > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 as > + * published by the Free Software Foundation. > + * > + * This program is distributed "as is" WITHOUT ANY WARRANTY of any > + * kind, whether express or implied; without even the implied warranty > + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + */ > + > +#include <linux/init.h> > +#include <linux/input.h> > +#include <linux/interrupt.h> > +#include <linux/kernel.h> > +#include <linux/mfd/tps65218.h> > +#include <linux/module.h> > +#include <linux/of.h> > +#include <linux/platform_device.h> > +#include <linux/slab.h> > + > +struct tps65218_pwrbutton { > + struct device *dev; > + struct tps65218 *tps; > + struct input_dev *idev; > + int irq; You do not need to store IRQ since you are not using it outside of probe(). > + > + unsigned int pressed:1; You probably can remove 'pressed' as well and send events directly to input core and rely on it to filter out duplicates so there won't be release event without press event. If you prefer to keep it please use bool instead of bit field. > +}; > + > +static irqreturn_t tps65218_pwr_irq(int irq, void *_pwr) > +{ > + struct tps65218_pwrbutton *pwr = _pwr; > + unsigned int reg; > + int ret; > + > + ret = tps65218_reg_read(pwr->tps, TPS65218_REG_STATUS, ®); > + if (ret) { > + dev_err(pwr->dev, "can't read register --> %d\n", ret); > + goto out; > + } > + > + if (reg & TPS65218_STATUS_PB_STATE) { > + input_report_key(pwr->idev, KEY_POWER, 1); > + pm_wakeup_event(pwr->dev, 0); > + pwr->pressed = true; > + } else { > + /* > + * we don't want to report KEY_POWER releases on any of the > + * other IRQ sources. Only when button was previously pressed > + */ > + if (pwr->pressed) { > + input_report_key(pwr->idev, KEY_POWER, 0); > + pwr->pressed = false; > + } > + } > + > + input_sync(pwr->idev); > + > +out: > + return IRQ_HANDLED; > +} > + > +static int tps65218_pwron_probe(struct platform_device *pdev) > +{ > + struct tps65218 *tps = dev_get_drvdata(pdev->dev.parent); > + struct device *dev = &pdev->dev; > + struct tps65218_pwrbutton *pwr; > + struct input_dev *idev; > + int ret; > + > + pwr = devm_kzalloc(dev, sizeof(*pwr), GFP_KERNEL); > + if (!pwr) > + return -ENOMEM; > + > + idev = devm_input_allocate_device(dev); > + if (!idev) > + return -ENOMEM; > + > + idev->name = "tps65218_pwrbutton"; > + idev->phys = "tps65218_pwrbutton/input0"; > + idev->dev.parent = dev; > + idev->id.bustype = BUS_I2C; > + > + input_set_capability(idev, EV_KEY, KEY_POWER); > + > + pwr->tps = tps; > + pwr->dev = dev; > + pwr->idev = idev; > + pwr->irq = platform_get_irq(pdev, 0); > + platform_set_drvdata(pdev, pwr); > + device_init_wakeup(dev, true); > + > + ret = devm_request_threaded_irq(dev, pwr->irq, NULL, tps65218_pwr_irq, > + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, > + dev_name(dev), pwr); I am very fond of calling variables that hold error codes "error", Then you have: error = f(); if (error) { /* handle error */ } > + if (ret) { > + dev_err(dev, "failed to request IRQ #%d --> %d\n", > + pwr->irq, ret); > + return ret; > + } > + > + ret = input_register_device(idev); > + if (ret) { > + dev_err(dev, "Can't register power button --> %d\n", ret); > + return ret; > + } > + > + return 0; > +} > + > +static struct of_device_id of_tps65218_pwr_match[] = { > + { .compatible = "ti,tps65218-pwrbutton" }, > + { }, > +}; > + > +MODULE_DEVICE_TABLE(of, of_tps65218_pwr_match); > + > +static struct platform_driver tps65218_pwron_driver = { > + .probe = tps65218_pwron_probe, > + .driver = { > + .name = "tps65218_pwrbutton", > + .of_match_table = of_tps65218_pwr_match, > + }, > +}; > +module_platform_driver(tps65218_pwron_driver); > + > +MODULE_DESCRIPTION("TPS65218 Power Button"); > +MODULE_LICENSE("GPL v2"); > +MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); > -- > 2.2.0 > Thanks! -- Dmitry ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v2 3/5] input: misc: add tps65218 power button driver 2014-12-26 23:41 ` Dmitry Torokhov @ 2014-12-27 3:36 ` Felipe Balbi 2014-12-28 4:50 ` Dmitry Torokhov 0 siblings, 1 reply; 21+ messages in thread From: Felipe Balbi @ 2014-12-27 3:36 UTC (permalink / raw) To: linux-arm-kernel With this driver, we can report KEY_POWER on AM437x SK. This patch has been tested with said board. Signed-off-by: Felipe Balbi <balbi@ti.com> --- Changes since v1: - Add device tree documentation - s/ret/error - removed 'pressed' as input core will filter events - use a saner name when requesting IRQ. dev_name(dev) will return $i2c_bus_address.i2c-omap:0-0024:tps65218-pwrbutton - remove blank line before MODULE_DEVICE_TABLE() .../bindings/input/tps65218-pwrbutton.txt | 17 +++ drivers/input/misc/Kconfig | 10 ++ drivers/input/misc/Makefile | 1 + drivers/input/misc/tps65218-pwrbutton.c | 124 +++++++++++++++++++++ 4 files changed, 152 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt create mode 100644 drivers/input/misc/tps65218-pwrbutton.c diff --git a/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt b/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt new file mode 100644 index 0000000..e30e0b9 --- /dev/null +++ b/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt @@ -0,0 +1,17 @@ +Texas Instruments TPS65218 power button + +This driver provides a simple power button event via an Interrupt. + +Required properties: +- compatible: should be "ti,tps65218-pwrbutton" +- interrupts: should be one of the following + - <3 IRQ_TYPE_EDGE_BOTH>: For controllers compatible with tps65218 + +Example: + +&tps { + power-button { + compatible = "ti,tps65218-pwrbutton"; + interrupts = <3 IRQ_TYPE_EDGE_BOTH>; + }; +}; diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 23297ab..364cfb8 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -404,6 +404,16 @@ config INPUT_RETU_PWRBUTTON To compile this driver as a module, choose M here. The module will be called retu-pwrbutton. +config INPUT_TPS65218_PWRBUTTON + tristate "TPS65218 Power button driver" + depends on MFD_TPS65218 + help + Say Y here if you want to enable power buttong reporting for + the TPS65218 Power Management IC device. + + To compile this driver as a module, choose M here. The module will + be called tps65218-pwrbutton. + config INPUT_TWL4030_PWRBUTTON tristate "TWL4030 Power button Driver" depends on TWL4030_CORE diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 19c7603..a923753 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -59,6 +59,7 @@ obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o obj-$(CONFIG_INPUT_SIRFSOC_ONKEY) += sirfsoc-onkey.o obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY) += soc_button_array.o obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o +obj-$(CONFIG_INPUT_TPS65218_PWRBUTTON) += tps65218-pwrbutton.o obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON) += twl4030-pwrbutton.o obj-$(CONFIG_INPUT_TWL4030_VIBRA) += twl4030-vibra.o obj-$(CONFIG_INPUT_TWL6040_VIBRA) += twl6040-vibra.o diff --git a/drivers/input/misc/tps65218-pwrbutton.c b/drivers/input/misc/tps65218-pwrbutton.c new file mode 100644 index 0000000..2f85e2e --- /dev/null +++ b/drivers/input/misc/tps65218-pwrbutton.c @@ -0,0 +1,124 @@ +/* + * Texas Instruments' TPS65218 Power Button Input Driver + * + * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ + * Author: Felipe Balbi <balbi@ti.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <linux/init.h> +#include <linux/input.h> +#include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/mfd/tps65218.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/slab.h> + +struct tps65218_pwrbutton { + struct device *dev; + struct tps65218 *tps; + struct input_dev *idev; +}; + +static irqreturn_t tps65218_pwr_irq(int irq, void *_pwr) +{ + struct tps65218_pwrbutton *pwr = _pwr; + unsigned int reg; + int error; + + error = tps65218_reg_read(pwr->tps, TPS65218_REG_STATUS, ®); + if (error) { + dev_err(pwr->dev, "can't read register --> %d\n", error); + goto out; + } + + if (reg & TPS65218_STATUS_PB_STATE) { + input_report_key(pwr->idev, KEY_POWER, 1); + pm_wakeup_event(pwr->dev, 0); + } else { + input_report_key(pwr->idev, KEY_POWER, 0); + } + + input_sync(pwr->idev); + +out: + return IRQ_HANDLED; +} + +static int tps65218_pwron_probe(struct platform_device *pdev) +{ + struct tps65218 *tps = dev_get_drvdata(pdev->dev.parent); + struct device *dev = &pdev->dev; + struct tps65218_pwrbutton *pwr; + struct input_dev *idev; + int error; + int irq; + + pwr = devm_kzalloc(dev, sizeof(*pwr), GFP_KERNEL); + if (!pwr) + return -ENOMEM; + + idev = devm_input_allocate_device(dev); + if (!idev) + return -ENOMEM; + + idev->name = "tps65218_pwrbutton"; + idev->phys = "tps65218_pwrbutton/input0"; + idev->dev.parent = dev; + idev->id.bustype = BUS_I2C; + + input_set_capability(idev, EV_KEY, KEY_POWER); + + pwr->tps = tps; + pwr->dev = dev; + pwr->idev = idev; + platform_set_drvdata(pdev, pwr); + device_init_wakeup(dev, true); + + irq = platform_get_irq(pdev, 0); + error = devm_request_threaded_irq(dev, irq, NULL, tps65218_pwr_irq, + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + "tps65218-pwrbutton", pwr); + if (error) { + dev_err(dev, "failed to request IRQ #%d --> %d\n", + irq, error); + return error; + } + + error= input_register_device(idev); + if (error) { + dev_err(dev, "Can't register power button --> %d\n", error); + return error; + } + + return 0; +} + +static struct of_device_id of_tps65218_pwr_match[] = { + { .compatible = "ti,tps65218-pwrbutton" }, + { }, +}; +MODULE_DEVICE_TABLE(of, of_tps65218_pwr_match); + +static struct platform_driver tps65218_pwron_driver = { + .probe = tps65218_pwron_probe, + .driver = { + .name = "tps65218_pwrbutton", + .of_match_table = of_tps65218_pwr_match, + }, +}; +module_platform_driver(tps65218_pwron_driver); + +MODULE_DESCRIPTION("TPS65218 Power Button"); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); -- 2.2.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v2 3/5] input: misc: add tps65218 power button driver 2014-12-27 3:36 ` [PATCH v2 " Felipe Balbi @ 2014-12-28 4:50 ` Dmitry Torokhov 0 siblings, 0 replies; 21+ messages in thread From: Dmitry Torokhov @ 2014-12-28 4:50 UTC (permalink / raw) To: linux-arm-kernel On Fri, Dec 26, 2014 at 09:36:48PM -0600, Felipe Balbi wrote: > With this driver, we can report KEY_POWER on > AM437x SK. This patch has been tested with said > board. > > Signed-off-by: Felipe Balbi <balbi@ti.com> Applied, thank you. > --- > > Changes since v1: > - Add device tree documentation > - s/ret/error > - removed 'pressed' as input core will filter events > - use a saner name when requesting IRQ. dev_name(dev) will return > $i2c_bus_address.i2c-omap:0-0024:tps65218-pwrbutton > - remove blank line before MODULE_DEVICE_TABLE() > > .../bindings/input/tps65218-pwrbutton.txt | 17 +++ > drivers/input/misc/Kconfig | 10 ++ > drivers/input/misc/Makefile | 1 + > drivers/input/misc/tps65218-pwrbutton.c | 124 +++++++++++++++++++++ > 4 files changed, 152 insertions(+) > create mode 100644 Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt > create mode 100644 drivers/input/misc/tps65218-pwrbutton.c > > diff --git a/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt b/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt > new file mode 100644 > index 0000000..e30e0b9 > --- /dev/null > +++ b/Documentation/devicetree/bindings/input/tps65218-pwrbutton.txt > @@ -0,0 +1,17 @@ > +Texas Instruments TPS65218 power button > + > +This driver provides a simple power button event via an Interrupt. > + > +Required properties: > +- compatible: should be "ti,tps65218-pwrbutton" > +- interrupts: should be one of the following > + - <3 IRQ_TYPE_EDGE_BOTH>: For controllers compatible with tps65218 > + > +Example: > + > +&tps { > + power-button { > + compatible = "ti,tps65218-pwrbutton"; > + interrupts = <3 IRQ_TYPE_EDGE_BOTH>; > + }; > +}; > diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig > index 23297ab..364cfb8 100644 > --- a/drivers/input/misc/Kconfig > +++ b/drivers/input/misc/Kconfig > @@ -404,6 +404,16 @@ config INPUT_RETU_PWRBUTTON > To compile this driver as a module, choose M here. The module will > be called retu-pwrbutton. > > +config INPUT_TPS65218_PWRBUTTON > + tristate "TPS65218 Power button driver" > + depends on MFD_TPS65218 > + help > + Say Y here if you want to enable power buttong reporting for > + the TPS65218 Power Management IC device. > + > + To compile this driver as a module, choose M here. The module will > + be called tps65218-pwrbutton. > + > config INPUT_TWL4030_PWRBUTTON > tristate "TWL4030 Power button Driver" > depends on TWL4030_CORE > diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile > index 19c7603..a923753 100644 > --- a/drivers/input/misc/Makefile > +++ b/drivers/input/misc/Makefile > @@ -59,6 +59,7 @@ obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o > obj-$(CONFIG_INPUT_SIRFSOC_ONKEY) += sirfsoc-onkey.o > obj-$(CONFIG_INPUT_SOC_BUTTON_ARRAY) += soc_button_array.o > obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o > +obj-$(CONFIG_INPUT_TPS65218_PWRBUTTON) += tps65218-pwrbutton.o > obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON) += twl4030-pwrbutton.o > obj-$(CONFIG_INPUT_TWL4030_VIBRA) += twl4030-vibra.o > obj-$(CONFIG_INPUT_TWL6040_VIBRA) += twl6040-vibra.o > diff --git a/drivers/input/misc/tps65218-pwrbutton.c b/drivers/input/misc/tps65218-pwrbutton.c > new file mode 100644 > index 0000000..2f85e2e > --- /dev/null > +++ b/drivers/input/misc/tps65218-pwrbutton.c > @@ -0,0 +1,124 @@ > +/* > + * Texas Instruments' TPS65218 Power Button Input Driver > + * > + * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ > + * Author: Felipe Balbi <balbi@ti.com> > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 as > + * published by the Free Software Foundation. > + * > + * This program is distributed "as is" WITHOUT ANY WARRANTY of any > + * kind, whether express or implied; without even the implied warranty > + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + */ > + > +#include <linux/init.h> > +#include <linux/input.h> > +#include <linux/interrupt.h> > +#include <linux/kernel.h> > +#include <linux/mfd/tps65218.h> > +#include <linux/module.h> > +#include <linux/of.h> > +#include <linux/platform_device.h> > +#include <linux/slab.h> > + > +struct tps65218_pwrbutton { > + struct device *dev; > + struct tps65218 *tps; > + struct input_dev *idev; > +}; > + > +static irqreturn_t tps65218_pwr_irq(int irq, void *_pwr) > +{ > + struct tps65218_pwrbutton *pwr = _pwr; > + unsigned int reg; > + int error; > + > + error = tps65218_reg_read(pwr->tps, TPS65218_REG_STATUS, ®); > + if (error) { > + dev_err(pwr->dev, "can't read register --> %d\n", error); > + goto out; > + } > + > + if (reg & TPS65218_STATUS_PB_STATE) { > + input_report_key(pwr->idev, KEY_POWER, 1); > + pm_wakeup_event(pwr->dev, 0); > + } else { > + input_report_key(pwr->idev, KEY_POWER, 0); > + } > + > + input_sync(pwr->idev); > + > +out: > + return IRQ_HANDLED; > +} > + > +static int tps65218_pwron_probe(struct platform_device *pdev) > +{ > + struct tps65218 *tps = dev_get_drvdata(pdev->dev.parent); > + struct device *dev = &pdev->dev; > + struct tps65218_pwrbutton *pwr; > + struct input_dev *idev; > + int error; > + int irq; > + > + pwr = devm_kzalloc(dev, sizeof(*pwr), GFP_KERNEL); > + if (!pwr) > + return -ENOMEM; > + > + idev = devm_input_allocate_device(dev); > + if (!idev) > + return -ENOMEM; > + > + idev->name = "tps65218_pwrbutton"; > + idev->phys = "tps65218_pwrbutton/input0"; > + idev->dev.parent = dev; > + idev->id.bustype = BUS_I2C; > + > + input_set_capability(idev, EV_KEY, KEY_POWER); > + > + pwr->tps = tps; > + pwr->dev = dev; > + pwr->idev = idev; > + platform_set_drvdata(pdev, pwr); > + device_init_wakeup(dev, true); > + > + irq = platform_get_irq(pdev, 0); > + error = devm_request_threaded_irq(dev, irq, NULL, tps65218_pwr_irq, > + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, > + "tps65218-pwrbutton", pwr); > + if (error) { > + dev_err(dev, "failed to request IRQ #%d --> %d\n", > + irq, error); > + return error; > + } > + > + error= input_register_device(idev); > + if (error) { > + dev_err(dev, "Can't register power button --> %d\n", error); > + return error; > + } > + > + return 0; > +} > + > +static struct of_device_id of_tps65218_pwr_match[] = { > + { .compatible = "ti,tps65218-pwrbutton" }, > + { }, > +}; > +MODULE_DEVICE_TABLE(of, of_tps65218_pwr_match); > + > +static struct platform_driver tps65218_pwron_driver = { > + .probe = tps65218_pwron_probe, > + .driver = { > + .name = "tps65218_pwrbutton", > + .of_match_table = of_tps65218_pwr_match, > + }, > +}; > +module_platform_driver(tps65218_pwron_driver); > + > +MODULE_DESCRIPTION("TPS65218 Power Button"); > +MODULE_LICENSE("GPL v2"); > +MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); > -- > 2.2.0 > -- Dmitry ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 4/5] arm: boot: dts: am437x-sk: add power button binding 2014-12-26 19:28 [PATCH 0/5] AM437x SK: Add power-button support Felipe Balbi ` (2 preceding siblings ...) 2014-12-26 19:28 ` [PATCH 3/5] input: misc: add tps65218 power button driver Felipe Balbi @ 2014-12-26 19:28 ` Felipe Balbi 2015-01-08 0:09 ` Tony Lindgren 2014-12-26 19:28 ` [PATCH 5/5] arm: omap2plus_defconfig: enable TPS65218 power button Felipe Balbi 4 siblings, 1 reply; 21+ messages in thread From: Felipe Balbi @ 2014-12-26 19:28 UTC (permalink / raw) To: linux-arm-kernel Let this board report KEY_POWER so upper layers can decide what to do when power button is pressed. Signed-off-by: Felipe Balbi <balbi@ti.com> --- arch/arm/boot/dts/am437x-sk-evm.dts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/boot/dts/am437x-sk-evm.dts b/arch/arm/boot/dts/am437x-sk-evm.dts index 53bbfc9..c53840c 100644 --- a/arch/arm/boot/dts/am437x-sk-evm.dts +++ b/arch/arm/boot/dts/am437x-sk-evm.dts @@ -386,6 +386,11 @@ regulator-always-on; }; + power-button { + compatible = "ti,tps65218-pwrbutton"; + status = "okay"; + interrupts = <3 IRQ_TYPE_EDGE_BOTH>; + }; }; at24 at 50 { -- 2.2.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 4/5] arm: boot: dts: am437x-sk: add power button binding 2014-12-26 19:28 ` [PATCH 4/5] arm: boot: dts: am437x-sk: add power button binding Felipe Balbi @ 2015-01-08 0:09 ` Tony Lindgren 0 siblings, 0 replies; 21+ messages in thread From: Tony Lindgren @ 2015-01-08 0:09 UTC (permalink / raw) To: linux-arm-kernel * Felipe Balbi <balbi@ti.com> [141226 11:31]: > Let this board report KEY_POWER so upper layers > can decide what to do when power button is pressed. > > Signed-off-by: Felipe Balbi <balbi@ti.com> Applying this one into omap-for-v3.20/dt thanks. Tony > --- > arch/arm/boot/dts/am437x-sk-evm.dts | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/arm/boot/dts/am437x-sk-evm.dts b/arch/arm/boot/dts/am437x-sk-evm.dts > index 53bbfc9..c53840c 100644 > --- a/arch/arm/boot/dts/am437x-sk-evm.dts > +++ b/arch/arm/boot/dts/am437x-sk-evm.dts > @@ -386,6 +386,11 @@ > regulator-always-on; > }; > > + power-button { > + compatible = "ti,tps65218-pwrbutton"; > + status = "okay"; > + interrupts = <3 IRQ_TYPE_EDGE_BOTH>; > + }; > }; > > at24 at 50 { > -- > 2.2.0 > ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 5/5] arm: omap2plus_defconfig: enable TPS65218 power button 2014-12-26 19:28 [PATCH 0/5] AM437x SK: Add power-button support Felipe Balbi ` (3 preceding siblings ...) 2014-12-26 19:28 ` [PATCH 4/5] arm: boot: dts: am437x-sk: add power button binding Felipe Balbi @ 2014-12-26 19:28 ` Felipe Balbi 2015-01-08 0:55 ` Tony Lindgren 4 siblings, 1 reply; 21+ messages in thread From: Felipe Balbi @ 2014-12-26 19:28 UTC (permalink / raw) To: linux-arm-kernel Enable tps65218 power button driver by default as a dynamically linked module so AM437x SK can report power button presses. Signed-off-by: Felipe Balbi <balbi@ti.com> --- arch/arm/configs/omap2plus_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig index c2c3a85..f4a4b2f 100644 --- a/arch/arm/configs/omap2plus_defconfig +++ b/arch/arm/configs/omap2plus_defconfig @@ -183,6 +183,7 @@ CONFIG_TOUCHSCREEN_EDT_FT5X06=m CONFIG_TOUCHSCREEN_TSC2005=m CONFIG_TOUCHSCREEN_TSC2007=m CONFIG_INPUT_MISC=y +CONFIG_INPUT_TPS65218_PWRBUTTON=m CONFIG_INPUT_TWL4030_PWRBUTTON=y # CONFIG_LEGACY_PTYS is not set CONFIG_SERIAL_8250=y -- 2.2.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 5/5] arm: omap2plus_defconfig: enable TPS65218 power button 2014-12-26 19:28 ` [PATCH 5/5] arm: omap2plus_defconfig: enable TPS65218 power button Felipe Balbi @ 2015-01-08 0:55 ` Tony Lindgren 0 siblings, 0 replies; 21+ messages in thread From: Tony Lindgren @ 2015-01-08 0:55 UTC (permalink / raw) To: linux-arm-kernel * Felipe Balbi <balbi@ti.com> [141226 11:31]: > Enable tps65218 power button driver by default as > a dynamically linked module so AM437x SK can report > power button presses. > > Signed-off-by: Felipe Balbi <balbi@ti.com> Applying this into omap-for-v3.20/defconfig thanks. Tony > --- > arch/arm/configs/omap2plus_defconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig > index c2c3a85..f4a4b2f 100644 > --- a/arch/arm/configs/omap2plus_defconfig > +++ b/arch/arm/configs/omap2plus_defconfig > @@ -183,6 +183,7 @@ CONFIG_TOUCHSCREEN_EDT_FT5X06=m > CONFIG_TOUCHSCREEN_TSC2005=m > CONFIG_TOUCHSCREEN_TSC2007=m > CONFIG_INPUT_MISC=y > +CONFIG_INPUT_TPS65218_PWRBUTTON=m > CONFIG_INPUT_TWL4030_PWRBUTTON=y > # CONFIG_LEGACY_PTYS is not set > CONFIG_SERIAL_8250=y > -- > 2.2.0 > ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2015-01-19 14:41 UTC | newest] Thread overview: 21+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-12-26 19:28 [PATCH 0/5] AM437x SK: Add power-button support Felipe Balbi 2014-12-26 19:28 ` [PATCH 1/5] mfd: tps65218: make INT[12] and STATUS registers volatile Felipe Balbi 2015-01-06 17:37 ` Felipe Balbi 2015-01-08 16:25 ` Felipe Balbi 2015-01-12 16:46 ` Felipe Balbi 2015-01-14 17:07 ` Tony Lindgren 2015-01-16 22:57 ` Felipe Balbi 2015-01-18 9:52 ` Lee Jones 2015-01-19 14:41 ` Felipe Balbi 2014-12-26 19:28 ` [PATCH 2/5] mfd: tps65218: make INT1 our status_base register Felipe Balbi 2015-01-06 17:37 ` Felipe Balbi 2015-01-18 9:52 ` Lee Jones 2014-12-26 19:28 ` [PATCH 3/5] input: misc: add tps65218 power button driver Felipe Balbi 2014-12-26 19:33 ` Felipe Balbi 2014-12-26 23:41 ` Dmitry Torokhov 2014-12-27 3:36 ` [PATCH v2 " Felipe Balbi 2014-12-28 4:50 ` Dmitry Torokhov 2014-12-26 19:28 ` [PATCH 4/5] arm: boot: dts: am437x-sk: add power button binding Felipe Balbi 2015-01-08 0:09 ` Tony Lindgren 2014-12-26 19:28 ` [PATCH 5/5] arm: omap2plus_defconfig: enable TPS65218 power button Felipe Balbi 2015-01-08 0:55 ` Tony Lindgren
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).