mc13783: add pwr button support
Subsystems (6)
v3 cover mc13783: add pwr button support
Hello
This add button handling for the MC13783 PMIC.
The first patch modify the mc13783 MFD driver to add a button subdevice and also adds the mc13783-pwrbutton driver using a misc input device.
The second patch adds the power on button support to the mx31moboard boards.
The third patch is optional and modify the mc13xxx driver to use the platform data to check if the leds and buttons subdevices should be enabled.
We need to keep the regulator flags as the regulator platform data can be NULL on mc13892.
v2: first patch modified according to comments by Dmitry Torokhov
v3: Implement review by Uwe
Philippe Rétornaz (3):
mc13783: add power button support
mx31moboard: Add MC13783 power button support
mc13xxx: implicitly enable leds and buttons
arch/arm/mach-imx/mach-mx31moboard.c | 10 +- drivers/input/misc/Kconfig | 10 + drivers/input/misc/Makefile | 1 + drivers/input/misc/mc13783-pwrbutton.c | 288 ++++++++++++++++++++++++++++++++ drivers/mfd/mc13xxx-core.c | 6 +- include/linux/mfd/mc13783.h | 2 +- include/linux/mfd/mc13xxx.h | 18 ++- 7 files changed, 331 insertions(+), 4 deletions(-) create mode 100644 drivers/input/misc/mc13783-pwrbutton.c
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 1/3 mc13783: add power button support
This adds support for the power-on buttons of MC13783 PMIC. This is done using a misc input device.
--- drivers/input/misc/Kconfig | 10 + drivers/input/misc/Makefile | 1 + drivers/input/misc/mc13783-pwrbutton.c | 288 ++++++++++++++++++++++++++++++++ drivers/mfd/mc13xxx-core.c | 4 + include/linux/mfd/mc13783.h | 1 + include/linux/mfd/mc13xxx.h | 18 ++ 6 files changed, 322 insertions(+), 0 deletions(-) create mode 100644 drivers/input/misc/mc13783-pwrbutton.c
drivers/input/misc/Kconfig +10 -0
@@ -100,6 +100,16 @@ config INPUT_MAX8925_ONKEY To compile this driver as a module, choose M here: the module will be called max8925_onkey. +config INPUT_MC13783_PWRBUTTON + tristate "MC13783 ON buttons" + depends on MFD_MC13783 + help + Support the ON buttons of MC13783 PMIC as an input device + reporting power button status. + + To compile this driver as a module, choose M here: the module + will be called mc13783-pwrbutton. + config INPUT_APANEL tristate "Fujitsu Lifebook Application Panel buttons" depends on X86 && I2C && LEDS_CLASS
drivers/input/misc/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_INPUT_IXP4XX_BEEPER) += ixp4xx-beeper.o obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o obj-$(CONFIG_INPUT_MAX8925_ONKEY) += max8925_onkey.o +obj-$(CONFIG_INPUT_MC13783_PWRBUTTON) += mc13783-pwrbutton.o obj-$(CONFIG_INPUT_PCAP) += pcap_keys.o obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o obj-$(CONFIG_INPUT_PCF8574) += pcf8574_keypad.o
drivers/input/misc/mc13783-pwrbutton.c new file +288 -0
288 lines not on this page · raw message
drivers/mfd/mc13xxx-core.c +4 -0
@@ -778,6 +778,10 @@ err_revision:mc13xxx_add_subdevice_pdata (mc13xxx,"%s-led" , pdata->leds,sizeof (*pdata->leds)); +if (pdata->flags &MC13XXX_USE_BUTTON ) +mc13xxx_add_subdevice_pdata (mc13xxx,"%s-pwrbutton" , + pdata->buttons,sizeof (*pdata->buttons)); +return 0 ; }
include/linux/mfd/mc13783.h +1 -0
@@ -106,6 +106,7 @@ static inline int mc13783_irq_ack(struct mc13783 *mc13783, int irq)#define mc13783_regulator_platform_data mc13xxx_regulator_platform_data#define mc13783_led_platform_data mc13xxx_led_platform_data#define mc13783_leds_platform_data mc13xxx_leds_platform_data +#define mc13783_buttons_platform_data mc13xxx_buttons_platform_data#define mc13783_platform_data mc13xxx_platform_data#define MC13783_USE_TOUCHSCREEN MC13XXX_USE_TOUCHSCREEN
include/linux/mfd/mc13xxx.h +18 -0
@@ -137,6 +137,22 @@ struct mc13xxx_leds_platform_data {char tc3_period; }; +struct mc13xxx_buttons_platform_data { +#define MC13783_BUTTON_DBNC_0MS 0 +#define MC13783_BUTTON_DBNC_30MS 1 +#define MC13783_BUTTON_DBNC_150MS 2 +#define MC13783_BUTTON_DBNC_750MS 3 +#define MC13783_BUTTON_ENABLE (1 << 2) +#define MC13783_BUTTON_POL_INVERT (1 << 3) +#define MC13783_BUTTON_RESET_EN (1 << 4) +int b1on_flags; +unsigned short b1on_key; +int b2on_flags; +unsigned short b2on_key; +int b3on_flags; +unsigned short b3on_key; +}; +struct mc13xxx_platform_data {#define MC13XXX_USE_TOUCHSCREEN (1 << 0)#define MC13XXX_USE_CODEC (1 << 1)
@@ -144,10 +160,12 @@ struct mc13xxx_platform_data {#define MC13XXX_USE_RTC (1 << 3)#define MC13XXX_USE_REGULATOR (1 << 4)#define MC13XXX_USE_LED (1 << 5) +#define MC13XXX_USE_BUTTON (1 << 6)unsigned int flags;struct mc13xxx_regulator_platform_data regulators;struct mc13xxx_leds_platform_data *leds; + struct mc13xxx_buttons_platform_data *buttons; };#endif /* ifndef __LINUX_MFD_MC13XXX_H */
Signature · 6 lines
1.6.3.3 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 2/3 mx31moboard: Add MC13783 power button support
Add the power-on button on mx31moboard using MC13783 PMIC.
--- arch/arm/mach-imx/mach-mx31moboard.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
arch/arm/mach-imx/mach-mx31moboard.c +9 -1
@@ -28,6 +28,7 @@#include <linux/spi/spi.h> #include <linux/types.h> #include <linux/memblock.h> +#include <linux/input.h> #include <linux/usb/otg.h> #include <linux/usb/ulpi.h>
@@ -264,14 +265,21 @@ static struct mc13783_leds_platform_data moboard_leds = { .tc2_period = MC13783_LED_PERIOD_10MS, }; +static struct mc13783_buttons_platform_data moboard_buttons = { + .b1on_flags =MC13783_BUTTON_DBNC_750MS |MC13783_BUTTON_ENABLE | +MC13783_BUTTON_POL_INVERT , + .b1on_key =KEY_POWER , +}; +static struct mc13xxx_platform_data moboard_pmic = { .regulators = { .regulators = moboard_regulators, .num_regulators =ARRAY_SIZE (moboard_regulators), }, .leds = &moboard_leds, + .buttons = &moboard_buttons, .flags =MC13XXX_USE_REGULATOR |MC13XXX_USE_RTC | -MC13XXX_USE_ADC |MC13XXX_USE_LED , +MC13XXX_USE_ADC |MC13XXX_USE_LED |MC13XXX_USE_BUTTON , };static struct spi_board_info moboard_spi_board_info[]__initdata = {
Signature · 6 lines
1.6.3.3 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 3/3 mc13xxx: implicitly enable leds and buttons
The leds and buttons subdevices cannot be used without additional platform data.
Use the presence of the platform data to enable the device instead of an additional flag.
--- arch/arm/mach-imx/mach-mx31moboard.c | 2 +- drivers/mfd/mc13xxx-core.c | 4 ++-- include/linux/mfd/mc13783.h | 1 - include/linux/mfd/mc13xxx.h | 2 -- 4 files changed, 3 insertions(+), 6 deletions(-)
arch/arm/mach-imx/mach-mx31moboard.c +1 -1
@@ -279,7 +279,7 @@ static struct mc13xxx_platform_data moboard_pmic = { .leds = &moboard_leds, .buttons = &moboard_buttons, .flags = MC13XXX_USE_REGULATOR | MC13XXX_USE_RTC | - MC13XXX_USE_ADC | MC13XXX_USE_LED | MC13XXX_USE_BUTTON, + MC13XXX_USE_ADC, };static struct spi_board_info moboard_spi_board_info[]__initdata = {
drivers/mfd/mc13xxx-core.c +2 -2
@@ -774,11 +774,11 @@ err_revision:if (pdata->flags &MC13XXX_USE_TOUCHSCREEN )mc13xxx_add_subdevice (mc13xxx,"%s-ts" ); -if (pdata->flags &MC13XXX_USE_LED ) +if (pdata->leds)mc13xxx_add_subdevice_pdata (mc13xxx,"%s-led" , pdata->leds,sizeof (*pdata->leds)); -if (pdata->flags &MC13XXX_USE_BUTTON ) +if (pdata->buttons)mc13xxx_add_subdevice_pdata (mc13xxx,"%s-pwrbutton" , pdata->buttons,sizeof (*pdata->buttons));
include/linux/mfd/mc13783.h +0 -1
@@ -114,7 +114,6 @@ static inline int mc13783_irq_ack(struct mc13783 *mc13783, int irq)#define MC13783_USE_ADC MC13XXX_USE_ADC#define MC13783_USE_RTC MC13XXX_USE_RTC#define MC13783_USE_REGULATOR MC13XXX_USE_REGULATOR -#define MC13783_USE_LED MC13XXX_USE_LED#define MC13783_ADC_MODE_TS 1#define MC13783_ADC_MODE_SINGLE_CHAN 2
include/linux/mfd/mc13xxx.h +0 -2
@@ -159,8 +159,6 @@ struct mc13xxx_platform_data {#define MC13XXX_USE_ADC (1 << 2)#define MC13XXX_USE_RTC (1 << 3)#define MC13XXX_USE_REGULATOR (1 << 4) -#define MC13XXX_USE_LED (1 << 5) -#define MC13XXX_USE_BUTTON (1 << 6)unsigned int flags;struct mc13xxx_regulator_platform_data regulators;
Signature · 6 lines
1.6.3.3 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/3 mc13xxx: implicitly enable leds and buttons
Hello,
Quoted 5 lines · Philippe R?tornaz
The leds and buttons subdevices cannot be used without additional platform data.
Use the presence of the platform data to enable the device instead of an additional flag.
I guess you could make some people happy by splitting this patch into:
- mfd/mc13xxx: implicitly enable leds and buttons (and regulators?)
- drop MC13XXX_USE_... in arch code
because the patches have different paths into mainline (unless it's handled otherwise).
And I wonder why you introduce MC13XXX_USE_BUTTON in the first place.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH 3/3 mc13xxx: implicitly enable leds and buttons
Quoted 2 lines · Uwe Kleine-K?nig
- mfd/mc13xxx: implicitly enable leds and buttons (and regulators?)
It's nicer to enable regulators unconditionally, even if they're not controlled by software in the system reading their state can still be useful.
PATCH v3 3/3 mc13xxx: implicitly enable leds and buttons
In reply to Uwe Kleine-KönigLe dimanche 10 juillet 2011 10:04:50, Uwe Kleine-K?nig a ?crit :
Quoted 6 lines
Hello,
Quoted 3 lines · Philippe R?tornaz
The leds and buttons subdevices cannot be used without additional platform data.
Quoted 8 lines
Quoted 2 lines
Use the presence of the platform data to enable the device instead of an additional flag.
I guess you could make some people happy by splitting this patch into:
- mfd/mc13xxx: implicitly enable leds and buttons (and regulators?)
- dropMC13XXX_USE_... in arch code
But this mean that between the two commit the build will be broken or the behavior will change. Which will break bissections.
For the regulator stuff, I don't want to change the behavior of others board as some (mx31lite) enable the regualtor without platform data. That's why I did not changed it.
Moreover for the mc13892 chip (which share the same flag), the probe() does modify some registers, so it's not just some cosmetic change, it will change the behavior on some boards.
BTW I will be on holydays next week so I won't be able to produce new patches soon.
Thanks,
Philippe
PATCH 3/3 mc13xxx: implicitly enable leds and buttons
Hello Philippe,
Quoted 10 lines · Philippe R?tornaz
Le dimanche 10 juillet 2011 10:04:50, Uwe Kleine-K?nig a ?crit :
Quoted 9 lines
Hello,
Quoted 5 lines · Philippe R?tornaz
The leds and buttons subdevices cannot be used without additional platform data.
Use the presence of the platform data to enable the device instead of an additional flag.
Quoted 8 lines
Quoted 5 lines
I guess you could make some people happy by splitting this patch into:
- mfd/mc13xxx: implicitly enable leds and buttons (and regulators?)
- dropMC13XXX_USE_... in arch codeBut this mean that between the two commit the build will be broken or the behavior will change. Which will break bissections.
If you don't remove the MC13XXX_USE_... constants the unconverted boards should still compile.
Quoted 4 lines
For the regulator stuff, I don't want to change the behavior of others board as some (mx31lite) enable the regualtor without platform data. That's why I did not changed it.
If having pdata=NULL is a valid config then either we need to keep the constant for regulators or (as Mark suggested) register unconditionally.
Quoted 3 lines
Moreover for the mc13892 chip (which share the same flag), the
probe()does modify some registers, so it's not just some cosmetic change, it will change the behavior on some boards.
no fear, that's what the -rc phase is there for. When improving something you often have to change behaviour.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |