input: mc13783: Prepare driver to support MC13892 and OF
Subsystems (7)
PATCH v2 1/3 input: mc13783: Prepare driver to support MC13892 and OF
This patch is a preparation mc13xxx powerbutton driver to support MC13892 and support the probe through the DT.
Signed-off-by Alexander Shiyan <[email protected]>
--- arch/arm/mach-imx/mach-mx31moboard.c | 9 +- drivers/input/misc/mc13783-pwrbutton.c | 361 ++++++++++++++------------------- include/linux/mfd/mc13xxx.h | 28 +-- 3 files changed, 173 insertions(+), 225 deletions(-)
arch/arm/mach-imx/mach-mx31moboard.c +6 -3
@@ -276,9 +276,12 @@ static struct mc13xxx_leds_platform_data moboard_leds = { };static struct mc13xxx_buttons_platform_data moboard_buttons = { - .b1on_flags =MC13783_BUTTON_DBNC_750MS |MC13783_BUTTON_ENABLE | -MC13783_BUTTON_POL_INVERT , - .b1on_key =KEY_POWER , + .buttons[0 ] = { + .keycode =KEY_POWER , + .flags =MC13XXX_BUTTON_ENABLE | +MC13XXX_BUTTON_DBNC_750MS | +MC13XXX_BUTTON_POL_INVERT , + }, };static struct mc13xxx_codec_platform_data moboard_codec = {
drivers/input/misc/mc13783-pwrbutton.c +152 -209
400 lines not on this page · raw message
include/linux/mfd/mc13xxx.h +15 -13
@@ -142,20 +142,22 @@ struct mc13xxx_leds_platform_data {u32 led_control[MAX_LED_CONTROL_REGS ]; }; +#define MAX13XXX_NUM_BUTTONS 3 + +struct mc13xxx_button { +u16 keycode; +unsigned int flags; +#define MC13XXX_BUTTON_DBNC_0MS 0 +#define MC13XXX_BUTTON_DBNC_30MS 1 +#define MC13XXX_BUTTON_DBNC_150MS 2 +#define MC13XXX_BUTTON_DBNC_750MS 3 +#define MC13XXX_BUTTON_ENABLE (1 << 2) +#define MC13XXX_BUTTON_POL_INVERT (1 << 3) +#define MC13XXX_BUTTON_RESET_EN (1 << 4) +}; +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_button buttons[MAX13XXX_NUM_BUTTONS ]; };struct mc13xxx_ts_platform_data {
Signature · 1 line
1.8.1.5
PATCH v2 2/3 input: mc13783: Add MC13892 support
Signed-off-by Alexander Shiyan <[email protected]>
--- drivers/input/misc/Kconfig | 6 +++--- drivers/input/misc/mc13783-pwrbutton.c | 10 +++++++++- include/linux/mfd/mc13892.h | 4 ++++ 3 files changed, 16 insertions(+), 4 deletions(-)
drivers/input/misc/Kconfig +3 -3
@@ -167,10 +167,10 @@ config INPUT_MAX8997_HAPTIC module will be called max8997-haptic. config INPUT_MC13783_PWRBUTTON - tristate "MC13783 ON buttons" - depends on MFD_MC13783 + tristate "MC13783/MC13892 ON buttons" + depends on MFD_MC13XXX help - Support the ON buttons of MC13783 PMIC as an input device + Support the ON buttons of MC13783/MC13892 PMIC as an input device reporting power button status. To compile this driver as a module, choose M here: the module
drivers/input/misc/mc13783-pwrbutton.c +9 -1
@@ -26,6 +26,7 @@#include <linux/input.h> #include <linux/platform_device.h> #include <linux/mfd/mc13783.h> +#include <linux/mfd/mc13892.h> struct mc13xxx_button_def {unsigned int irq;
@@ -194,8 +195,15 @@ static const struct mc13xxx_pwrb_devtype mc13783_pwrb_devtype = { .btn_def[2] = { MC13783_IRQ_ONOFD3, BIT(5) } }; +static const struct mc13xxx_pwrb_devtype mc13892_pwrb_devtype = { + .btn_def[0 ] = {MC13892_IRQ_ONOFD1 ,BIT (3 ) }, + .btn_def[1 ] = {MC13892_IRQ_ONOFD2 ,BIT (4 ) }, + .btn_def[2 ] = {MC13892_IRQ_ONOFD3 ,BIT (2 ) } +}; +static const struct platform_device_id mc13xxx_pwrbutton_id_table[] = { {"mc13783-pwrbutton" , (kernel_ulong_t)&mc13783_pwrb_devtype }, + {"mc13892-pwrbutton" , (kernel_ulong_t)&mc13892_pwrb_devtype }, { } };MODULE_DEVICE_TABLE (platform, mc13xxx_pwrbutton_id_table);
@@ -209,6 +217,6 @@ static struct platform_driver mc13xxx_pwrbutton_driver = { };module_platform_driver_probe (mc13xxx_pwrbutton_driver, mc13xxx_pwrbutton_probe); -MODULE_DESCRIPTION ("MC13783 Power Button" ); +MODULE_DESCRIPTION ("MC13XXX Power Button" );MODULE_LICENSE ("GPL v2" );MODULE_AUTHOR ("Philippe Retornaz" );
include/linux/mfd/mc13892.h +4 -0
@@ -36,4 +36,8 @@#define MC13892_PWGT2SPI 22#define MC13892_VCOINCELL 23 +#define MC13892_IRQ_ONOFD3 26 +#define MC13892_IRQ_ONOFD1 27 +#define MC13892_IRQ_ONOFD2 28 +#endif
Signature · 1 line
1.8.1.5
PATCH v2 3/3 input: mc13783: Add DT probe support
In reply to Alexander ShiyanPatch adds DT support for MC13783/MC13892 PMICs.
Signed-off-by Alexander Shiyan <[email protected]>
--- Documentation/devicetree/bindings/mfd/mc13xxx.txt | 13 +++++ drivers/input/misc/mc13783-pwrbutton.c | 59 ++++++++++++++++++----- 2 files changed, 59 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/mfd/mc13xxx.txt +13 -0
@@ -10,6 +10,12 @@ Optional properties: - fsl,mc13xxx-uses-touch : Indicate the touchscreen controller is being used Sub-nodes: +- buttons : Contain power button nodes. Each button should be declared as + "button@<num>" and contain code in "linux,code" property. + Optional properties: + active-high : Change active button level from 0 to 1. + enable-reset: Performs hadware reset through PMIC. + debounce : Debounce value which will be taken from PMIC datasheet. - regulators : Contain the regulator nodes. The regulators are bound using their names as listed below with their registers and bits for enabling.
@@ -89,6 +95,13 @@ ecspi at 70010000 { /* ECSPI1 */ interrupt-parent = <&gpio0>; interrupts = <8>; + buttons { + button at 1 { + linux,code = <0x1f>; + debounce = <1>; + }; + }; + regulators { sw1_reg: mc13892__sw1 { regulator-min-microvolt = <600000>;
drivers/input/misc/mc13783-pwrbutton.c +46 -13
94 lines not on this page · raw message
Signature · 1 line
1.8.1.5
Dmitry Torokhov
maintainerPATCH v2 1/3 input: mc13783: Prepare driver to support MC13892 and OF
In reply to Alexander ShiyanHi Alexander,
drivers/input/misc/mc13783-pwrbutton.c line 86
Quoted 9 lines · Alexander Shiyan
drivers/input/misc/mc13783-pwrbutton.c +9
-0+ +for (i =0 ; i <MAX13XXX_NUM_BUTTONS ; i++) +if (priv->enabled &BIT (i)) { + ret =mc13xxx_irq_request (priv->mc13xxx, + priv->devtype->btn_def[i].irq, + mc13xxx_pwrbutton_irq,NULL , + priv); +if (!ret) +continue ;
I'd rather we continued requesting interrupts in probe() as opposed to open(). I believe the driver should acquire all resources it needs when binding, instead of later.
Thanks.
Signature · 1 line
Dmitry