]> git.sur5r.net Git - u-boot/blobdiff - drivers/input/cros_ec_keyb.c
arm: socfpga: stratix10: Add SPL driver for Stratix10 SoC
[u-boot] / drivers / input / cros_ec_keyb.c
index 00381dcd720ac1b92b70d8afd4b52191d2c47d64..8c1a25c73f772e9f3282b3b477d3467f11b6dd6b 100644 (file)
@@ -1,23 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Chromium OS Matrix Keyboard
  *
  * Copyright (c) 2012 The Chromium OS Authors.
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <cros_ec.h>
 #include <dm.h>
 #include <errno.h>
-#include <fdtdec.h>
 #include <input.h>
 #include <keyboard.h>
 #include <key_matrix.h>
 #include <stdio_dev.h>
 
-DECLARE_GLOBAL_DATA_PTR;
-
 enum {
        KBC_MAX_KEYS            = 8,    /* Maximum keys held down at once */
        KBC_REPEAT_RATE_MS      = 30,
@@ -161,15 +157,15 @@ int cros_ec_kbc_check(struct input_config *input)
  * @param config       Configuration data read from fdt
  * @return 0 if ok, -1 on error
  */
-static int cros_ec_keyb_decode_fdt(const void *blob, int node,
-                               struct cros_ec_keyb_priv *config)
+static int cros_ec_keyb_decode_fdt(struct udevice *dev,
+                                  struct cros_ec_keyb_priv *config)
 {
        /*
         * Get keyboard rows and columns - at present we are limited to
         * 8 columns by the protocol (one byte per row scan)
         */
-       config->key_rows = fdtdec_get_int(blob, node, "keypad,num-rows", 0);
-       config->key_cols = fdtdec_get_int(blob, node, "keypad,num-columns", 0);
+       config->key_rows = dev_read_u32_default(dev, "keypad,num-rows", 0);
+       config->key_cols = dev_read_u32_default(dev, "keypad,num-columns", 0);
        if (!config->key_rows || !config->key_cols ||
                        config->key_rows * config->key_cols / 8
                                > CROS_EC_KEYSCAN_COLS) {
@@ -177,8 +173,8 @@ static int cros_ec_keyb_decode_fdt(const void *blob, int node,
                      config->key_rows, config->key_cols);
                return -1;
        }
-       config->ghost_filter = fdtdec_get_bool(blob, node,
-                                              "google,needs-ghost-filter");
+       config->ghost_filter = dev_read_bool(dev, "google,needs-ghost-filter");
+
        return 0;
 }
 
@@ -188,12 +184,13 @@ static int cros_ec_kbd_probe(struct udevice *dev)
        struct keyboard_priv *uc_priv = dev_get_uclass_priv(dev);
        struct stdio_dev *sdev = &uc_priv->sdev;
        struct input_config *input = &uc_priv->input;
-       const void *blob = gd->fdt_blob;
-       int node = dev_of_offset(dev);
        int ret;
 
-       if (cros_ec_keyb_decode_fdt(blob, node, priv))
-               return -1;
+       ret = cros_ec_keyb_decode_fdt(dev, priv);
+       if (ret) {
+               debug("%s: Cannot decode node (ret=%d)\n", __func__, ret);
+               return -EINVAL;
+       }
        input_set_delays(input, KBC_REPEAT_DELAY_MS, KBC_REPEAT_RATE_MS);
        ret = key_matrix_init(&priv->matrix, priv->key_rows, priv->key_cols,
                              priv->ghost_filter);
@@ -201,7 +198,7 @@ static int cros_ec_kbd_probe(struct udevice *dev)
                debug("%s: cannot init key matrix\n", __func__);
                return ret;
        }
-       ret = key_matrix_decode_fdt(&priv->matrix, gd->fdt_blob, node);
+       ret = key_matrix_decode_fdt(dev, &priv->matrix);
        if (ret) {
                debug("%s: Could not decode key matrix from fdt\n", __func__);
                return ret;