Now that gpiolib supports software nodes to describe GPIOs, switch the driver away from using GPIO lookup tables for wm1502 devices to using PROPERTY_ENTRY_GPIO(). With that we can remove support for gpiod_lookup_tables from the driver. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx> --- drivers/platform/x86/x86-android-tablets.c | 117 ++++++++++++--------- 1 file changed, 69 insertions(+), 48 deletions(-) diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c index 02ee793a934e..878b2b72d214 100644 --- a/drivers/platform/x86/x86-android-tablets.c +++ b/drivers/platform/x86/x86-android-tablets.c @@ -16,7 +16,6 @@ #include <linux/gpio_keys.h> #include <linux/gpio/consumer.h> #include <linux/gpio/driver.h> -#include <linux/gpio/machine.h> #include <linux/gpio/property.h> #include <linux/i2c.h> #include <linux/input.h> @@ -29,6 +28,7 @@ #include <linux/platform_data/lp855x.h> #include <linux/platform_device.h> #include <linux/power/bq24190_charger.h> +#include <linux/property.h> #include <linux/reboot.h> #include <linux/rmi.h> #include <linux/serdev.h> @@ -174,7 +174,6 @@ struct x86_dev_info { char *invalid_aei_gpiochip; const char * const *modules; const struct software_node *bat_swnode; - struct gpiod_lookup_table * const *gpiod_lookup_tables; const struct x86_i2c_client_info *i2c_client_info; const struct platform_device_info *pdev_info; const struct x86_serdev_info *serdev_info; @@ -269,79 +268,102 @@ static const char * const bq24190_modules[] __initconst = { * which is not described in the ACPI tables in anyway. * Use the x86-android-tablets infra to create a gpio-button device for this. */ -static struct gpio_keys_button advantech_mica_071_button = { - .code = KEY_PROG1, - /* .gpio gets filled in by advantech_mica_071_init() */ - .active_low = true, - .desc = "prog1_key", - .type = EV_KEY, - .wakeup = false, - .debounce_interval = 50, -}; - -static const struct gpio_keys_platform_data advantech_mica_071_button_pdata __initconst = { - .buttons = &advantech_mica_071_button, - .nbuttons = 1, +static const struct software_node advantech_mica_071_gpio_keys_node = { .name = "prog1_key", }; -static const struct platform_device_info advantech_mica_071_pdevs[] __initconst = { +static const struct property_entry advantech_mica_071_prog1_key_props[] = { + PROPERTY_ENTRY_U32("linux,code", KEY_PROG1), + PROPERTY_ENTRY_STRING("label", "prog1_key"), + PROPERTY_ENTRY_GPIO("gpios", + &int33fc_gpiochip_nodes[0], 2, GPIO_ACTIVE_LOW), + PROPERTY_ENTRY_U32("debounce-interval", 50), + { } +}; + +static const struct software_node advantech_mica_071_prog1_key_node = { + .parent = &advantech_mica_071_gpio_keys_node, + .properties = advantech_mica_071_prog1_key_props, +}; + +static const struct software_node *advantech_mica_071_swnodes[] = { + &advantech_mica_071_gpio_keys_node, + &advantech_mica_071_prog1_key_node, + NULL +}; + +static struct platform_device_info advantech_mica_071_pdevs[] = { { .name = "gpio-keys", .id = PLATFORM_DEVID_AUTO, - .data = &advantech_mica_071_button_pdata, - .size_data = sizeof(advantech_mica_071_button_pdata), + /* .fwnode will be filled by advantech_mica_071_init() */ }, }; static int __init advantech_mica_071_init(void) { - struct gpio_desc *gpiod; int ret; - ret = x86_android_tablet_get_gpiod("INT33FC:00", 2, &gpiod); + ret = software_node_register_node_group(advantech_mica_071_swnodes); if (ret < 0) return ret; - advantech_mica_071_button.gpio = desc_to_gpio(gpiod); + + advantech_mica_071_pdevs[0].fwnode = + software_node_fwnode(advantech_mica_071_swnodes[0]); return 0; } +static void __exit advantech_mica_071_exit(void) +{ + software_node_unregister_node_group(advantech_mica_071_swnodes); +} + static const struct x86_dev_info advantech_mica_071_info __initconst = { .pdev_info = advantech_mica_071_pdevs, .pdev_count = ARRAY_SIZE(advantech_mica_071_pdevs), .init = advantech_mica_071_init, + .exit = advantech_mica_071_exit, }; /* Asus ME176C and TF103C tablets shared data */ -static struct gpio_keys_button asus_me176c_tf103c_lid = { - .code = SW_LID, - /* .gpio gets filled in by asus_me176c_tf103c_init() */ - .active_low = true, - .desc = "lid_sw", - .type = EV_SW, - .wakeup = true, - .debounce_interval = 50, -}; - -static const struct gpio_keys_platform_data asus_me176c_tf103c_lid_pdata __initconst = { - .buttons = &asus_me176c_tf103c_lid, - .nbuttons = 1, +static const struct software_node asus_me176c_tf103c_gpio_keys_node = { .name = "lid_sw", }; +static const struct property_entry asus_me176c_tf103c_lid_props[] = { + PROPERTY_ENTRY_U32("linux,input-type", EV_SW), + PROPERTY_ENTRY_U32("linux,code", SW_LID), + PROPERTY_ENTRY_STRING("label", "lid_sw"), + PROPERTY_ENTRY_GPIO("gpios", + &int33fc_gpiochip_nodes[2], 2, GPIO_ACTIVE_LOW), + PROPERTY_ENTRY_U32("debounce-interval", 50), + PROPERTY_ENTRY_BOOL("wakeup-source"), + { } +}; + +static const struct software_node asus_me176c_tf103c_lid_node = { + .parent = &asus_me176c_tf103c_gpio_keys_node, + .properties = asus_me176c_tf103c_lid_props, +}; + +static const struct software_node *asus_me176c_tf103c_lid_swnodes[] = { + &asus_me176c_tf103c_gpio_keys_node, + &asus_me176c_tf103c_lid_node, + NULL +}; + static const struct property_entry asus_me176c_tf103c_int3496_props[] = { PROPERTY_ENTRY_GPIO("id-gpios", &int33fc_gpiochip_nodes[2], 22, GPIO_ACTIVE_HIGH), { } }; -static const struct platform_device_info asus_me176c_tf103c_pdevs[] __initconst = { +static struct platform_device_info asus_me176c_tf103c_pdevs[] = { { .name = "gpio-keys", .id = PLATFORM_DEVID_AUTO, - .data = &asus_me176c_tf103c_lid_pdata, - .size_data = sizeof(asus_me176c_tf103c_lid_pdata), + /* .fwnode will be filled by asus_me176c_tf103c_init() */ }, { /* For micro USB ID pin handling */ @@ -353,17 +375,22 @@ static const struct platform_device_info asus_me176c_tf103c_pdevs[] __initconst static int __init asus_me176c_tf103c_init(void) { - struct gpio_desc *gpiod; int ret; - ret = x86_android_tablet_get_gpiod("INT33FC:02", 12, &gpiod); + ret = software_node_register_node_group(asus_me176c_tf103c_lid_swnodes); if (ret < 0) return ret; - asus_me176c_tf103c_lid.gpio = desc_to_gpio(gpiod); + + asus_me176c_tf103c_pdevs[0].fwnode = + software_node_fwnode(asus_me176c_tf103c_lid_swnodes[0]); return 0; } +static void __exit asus_me176c_tf103c_exit(void) +{ + software_node_unregister_node_group(asus_me176c_tf103c_lid_swnodes); +} /* Asus ME176C tablets have an Android factory img with everything hardcoded */ static const char * const asus_me176c_accel_mount_matrix[] = { @@ -504,6 +531,7 @@ static const struct x86_dev_info asus_me176c_info __initconst = { .modules = bq24190_modules, .invalid_aei_gpiochip = "INT33FC:02", .init = asus_me176c_tf103c_init, + .exit = asus_me176c_tf103c_exit, }; /* Asus TF103C tablets have an Android factory img with everything hardcoded */ @@ -641,6 +669,7 @@ static const struct x86_dev_info asus_tf103c_info __initconst = { .modules = bq24190_modules, .invalid_aei_gpiochip = "INT33FC:02", .init = asus_me176c_tf103c_init, + .exit = asus_me176c_tf103c_exit, }; /* @@ -1583,7 +1612,6 @@ static int serdev_count; static struct i2c_client **i2c_clients; static struct platform_device **pdevs; static struct serdev_device **serdevs; -static struct gpiod_lookup_table * const *gpiod_lookup_tables; static const struct software_node *bat_swnode; static void (*exit_handler)(void); @@ -1706,9 +1734,6 @@ static void x86_android_tablet_cleanup(void) if (exit_handler) exit_handler(); - for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++) - gpiod_remove_lookup_table(gpiod_lookup_tables[i]); - software_node_unregister(bat_swnode); software_node_unregister_node_group(int33fc_gpiochip_node_group); } @@ -1760,10 +1785,6 @@ static __init int x86_android_tablet_init(void) } } - gpiod_lookup_tables = dev_info->gpiod_lookup_tables; - for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++) - gpiod_add_lookup_table(gpiod_lookup_tables[i]); - if (dev_info->init) { ret = dev_info->init(); if (ret < 0) { -- 2.40.1.606.ga4b1b128d6-goog