Commit b23fea11 authored by Fabio Baltieri's avatar Fabio Baltieri Committed by Carles Cufi
Browse files

input: gpio_keys: add a no-disconnect property

Add a no-disconnect property that skips the call to disconnect the pin
during suspend, this is useful as not all gpio controllers supports pin
disconnection, and right now using the gpio-keys driver on one of those
results in a failed initialization if PM runtime is enabled.

Signed-off-by: default avatarFabio Baltieri <fabiobaltieri@google.com>
parent ca3dc019
Loading
Loading
Loading
Loading
+6 −0
Changes for drivers/input/input_gpio_keys.c: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ struct gpio_keys_config {
	struct gpio_keys_pin_data *pin_data;
	k_work_handler_t handler;
	bool polling_mode;
	bool no_disconnect;
};

struct gpio_keys_data {
@@ -238,12 +239,14 @@ static int gpio_keys_pm_action(const struct device *dev,
				}
			}

			if (!cfg->no_disconnect) {
				ret = gpio_pin_configure_dt(gpio, GPIO_DISCONNECTED);
				if (ret != 0) {
					LOG_ERR("Pin %d configuration failed: %d", i, ret);
					return ret;
				}
			}
		}

		return 0;
	case PM_DEVICE_ACTION_RESUME:
@@ -252,11 +255,13 @@ static int gpio_keys_pm_action(const struct device *dev,
		for (int i = 0; i < cfg->num_keys; i++) {
			const struct gpio_dt_spec *gpio = &cfg->pin_cfg[i].spec;

			if (!cfg->no_disconnect) {
				ret = gpio_pin_configure_dt(gpio, GPIO_INPUT);
				if (ret != 0) {
					LOG_ERR("Pin %d configuration failed: %d", i, ret);
					return ret;
				}
			}

			if (cfg->polling_mode) {
				k_work_reschedule(&pin_data[0].work,
@@ -304,6 +309,7 @@ static int gpio_keys_pm_action(const struct device *dev,
		.handler = COND_CODE_1(DT_INST_PROP(i, polling_mode),                              \
				       (gpio_keys_poll_pins), (gpio_keys_change_deferred)),        \
		.polling_mode = DT_INST_PROP(i, polling_mode),                                     \
		.no_disconnect = DT_INST_PROP(i, no_disconnect),                                   \
	};                                                                                         \
												   \
	static struct gpio_keys_data gpio_keys_data_##i;                                           \
+6 −0
Changes for dts/bindings/input/gpio-keys.yaml: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -41,6 +41,12 @@ properties:
      Do not use interrupts for the key GPIOs, poll the pin periodically at the
      specified debounce-interval-ms instead.

  no-disconnect:
    type: boolean
    description: |
      Do not try to disconnect the pin on suspend. Can be used if the GPIO
      controller does not support the GPIO_DISCONNECTED flag.

child-binding:
  description: GPIO KEYS child node
  properties: