From 77a8f0ad38844b5d4163424c4feb8abbbbb55af0 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 17 Jan 2016 10:18:12 -0800 Subject: Input: rotary_encoder - convert to use gpiod API Instead of using old GPIO API, let's switch to GPIOD API, which automatically handles polarity. Signed-off-by: Dmitry Torokhov --- arch/arm/mach-pxa/raumfeld.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'arch/arm/mach-pxa') diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c index 36571a9a44fe..bac88e0be58a 100644 --- a/arch/arm/mach-pxa/raumfeld.c +++ b/arch/arm/mach-pxa/raumfeld.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -366,14 +367,21 @@ static struct pxaohci_platform_data raumfeld_ohci_info = { * Rotary encoder input device */ +static struct gpiod_lookup_table raumfeld_rotary_gpios_table = { + .dev_id = "rotary-encoder.0", + .table = { + GPIO_LOOKUP_IDX("gpio-0", + GPIO_VOLENC_A, NULL, 0, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("gpio-0", + GPIO_VOLENC_B, NULL, 1, GPIO_ACTIVE_HIGH), + { }, + }, +}; + static struct rotary_encoder_platform_data raumfeld_rotary_encoder_info = { .steps = 24, .axis = REL_X, .relative_axis = 1, - .gpio_a = GPIO_VOLENC_A, - .gpio_b = GPIO_VOLENC_B, - .inverted_a = 1, - .inverted_b = 0, }; static struct platform_device rotary_encoder_device = { @@ -1051,7 +1059,10 @@ static void __init raumfeld_controller_init(void) int ret; pxa3xx_mfp_config(ARRAY_AND_SIZE(raumfeld_controller_pin_config)); + + gpiod_add_lookup_table(&raumfeld_rotary_gpios_table); platform_device_register(&rotary_encoder_device); + spi_register_board_info(ARRAY_AND_SIZE(controller_spi_devices)); i2c_register_board_info(0, &raumfeld_controller_i2c_board_info, 1); @@ -1086,6 +1097,8 @@ static void __init raumfeld_speaker_init(void) i2c_register_board_info(0, &raumfeld_connector_i2c_board_info, 1); platform_device_register(&smc91x_device); + + gpiod_add_lookup_table(&raumfeld_rotary_gpios_table); platform_device_register(&rotary_encoder_device); raumfeld_audio_init(); -- cgit From a9e340dce3c3bceeb42f6b6d33b7858822d76cb6 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sun, 17 Jan 2016 10:57:09 -0800 Subject: Input: rotary_encoder - move away from platform data structure Drop support for platform data passed via a C-structure and switch to device properties instead, which should make the driver compatible with all platforms: OF, ACPI and static boards. Static boards should use property sets to communicate device parameters to the driver. Signed-off-by: Dmitry Torokhov --- arch/arm/mach-pxa/raumfeld.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'arch/arm/mach-pxa') diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c index bac88e0be58a..82689ac20ccf 100644 --- a/arch/arm/mach-pxa/raumfeld.c +++ b/arch/arm/mach-pxa/raumfeld.c @@ -18,13 +18,13 @@ #include #include +#include #include #include #include #include #include #include -#include #include #include #include @@ -378,18 +378,27 @@ static struct gpiod_lookup_table raumfeld_rotary_gpios_table = { }, }; -static struct rotary_encoder_platform_data raumfeld_rotary_encoder_info = { - .steps = 24, - .axis = REL_X, - .relative_axis = 1, +static u32 raumfeld_rotary_encoder_steps = 24; +static u32 raumfeld_rotary_encoder_axis = REL_X; +static u32 raumfeld_rotary_encoder_relative_axis = 1; + +static struct property_entry raumfeld_rotary_properties[] = { + { "rotary-encoder,steps-per-period", + DEV_PROP_U32, 1, &raumfeld_rotary_encoder_steps, }, + { "linux,axis", + DEV_PROP_U32, 1, &raumfeld_rotary_encoder_axis, }, + { "rotary-encoder,relative_axis", + DEV_PROP_U32, 1, &raumfeld_rotary_encoder_relative_axis, }, + { NULL } +}; + +static struct property_set raumfeld_rotary_property_set = { + .properties = raumfeld_rotary_properties, }; static struct platform_device rotary_encoder_device = { .name = "rotary-encoder", .id = 0, - .dev = { - .platform_data = &raumfeld_rotary_encoder_info, - } }; /** @@ -1061,6 +1070,8 @@ static void __init raumfeld_controller_init(void) pxa3xx_mfp_config(ARRAY_AND_SIZE(raumfeld_controller_pin_config)); gpiod_add_lookup_table(&raumfeld_rotary_gpios_table); + device_add_property_set(&rotary_encoder_device.dev, + &raumfeld_rotary_property_set); platform_device_register(&rotary_encoder_device); spi_register_board_info(ARRAY_AND_SIZE(controller_spi_devices)); @@ -1099,6 +1110,8 @@ static void __init raumfeld_speaker_init(void) platform_device_register(&smc91x_device); gpiod_add_lookup_table(&raumfeld_rotary_gpios_table); + device_add_property_set(&rotary_encoder_device.dev, + &raumfeld_rotary_property_set); platform_device_register(&rotary_encoder_device); raumfeld_audio_init(); -- cgit From 4d2508a55990c9b0fc1afb2c2cc5636712fd30f7 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 15 Mar 2016 16:46:12 -0700 Subject: ARM: pxa/raumfeld: use PROPERTY_ENTRY_INTEGER to define props gcc-6.0 notices that the use of the property_entry in this file that was recently introduced cannot work right, as we initialize the wrong field: raumfeld.c:387:3: error: the address of 'raumfeld_rotary_encoder_steps' will always evaluate as 'true' [-Werror=address] DEV_PROP_U32, 1, &raumfeld_rotary_encoder_steps, }, ^~~~~~~~~~~~ raumfeld.c:389:3: error: the address of 'raumfeld_rotary_encoder_axis' will always evaluate as 'true' [-Werror=address] DEV_PROP_U32, 1, &raumfeld_rotary_encoder_axis, }, ^~~~~~~~~~~~ raumfeld.c:391:3: error: the address of 'raumfeld_rotary_encoder_relative_axis' will always evaluate as 'true' [-Werror=address] DEV_PROP_U32, 1, &raumfeld_rotary_encoder_relative_axis, }, ^~~~~~~~~~~~ The problem appears to stem from relying on an old definition of 'struct property', but it has changed several times since the code could have last been correct. This changes the code to use the PROPERTY_ENTRY_INTEGER() macro instead, which works fine for the current definition and is a safer way of doing the initialization. Signed-off-by: Arnd Bergmann Fixes: a9e340dce3c3 ("Input: rotary_encoder - move away from platform data structure") Signed-off-by: Dmitry Torokhov --- arch/arm/mach-pxa/raumfeld.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'arch/arm/mach-pxa') diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c index 16ffd01daff1..5a941bd3dbed 100644 --- a/arch/arm/mach-pxa/raumfeld.c +++ b/arch/arm/mach-pxa/raumfeld.c @@ -378,18 +378,11 @@ static struct gpiod_lookup_table raumfeld_rotary_gpios_table = { }, }; -static u32 raumfeld_rotary_encoder_steps = 24; -static u32 raumfeld_rotary_encoder_axis = REL_X; -static u32 raumfeld_rotary_encoder_relative_axis = 1; - static struct property_entry raumfeld_rotary_properties[] = { - { "rotary-encoder,steps-per-period", - DEV_PROP_U32, 1, &raumfeld_rotary_encoder_steps, }, - { "linux,axis", - DEV_PROP_U32, 1, &raumfeld_rotary_encoder_axis, }, - { "rotary-encoder,relative_axis", - DEV_PROP_U32, 1, &raumfeld_rotary_encoder_relative_axis, }, - { NULL } + PROPERTY_ENTRY_INTEGER("rotary-encoder,steps-per-period", u32, 24), + PROPERTY_ENTRY_INTEGER("linux,axis", u32, REL_X), + PROPERTY_ENTRY_INTEGER("rotary-encoder,relative_axis", u32, 1), + { }, }; static struct property_set raumfeld_rotary_property_set = { -- cgit