Adjust the tegra keyboard driver to support driver model, using the new
uclass. Make this the default for all Tegra boards so that those that use
a keyboard will build correctly with this driver.
Signed-off-by: Simon Glass
---
Changes in v2: None
arch/arm/mach-tegra/Kconfig | 1 +
drivers/input/tegra-kbc.c | 243
include/fdtdec.h| 1 -
lib/fdtdec.c| 1 -
4 files changed, 112 insertions(+), 134 deletions(-)
diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index a5b7e0d..de2454e 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -12,6 +12,7 @@ config TEGRA_ARMV7_COMMON
select DM_I2C
select DM_SPI
select DM_GPIO
+ select DM_KEYBOARD
choice
prompt "Tegra SoC select"
diff --git a/drivers/input/tegra-kbc.c b/drivers/input/tegra-kbc.c
index 3310f84..a7137f1 100644
--- a/drivers/input/tegra-kbc.c
+++ b/drivers/input/tegra-kbc.c
@@ -6,8 +6,10 @@
*/
#include
+#include
#include
#include
+#include
#include
#include
#include
@@ -40,14 +42,13 @@ enum {
};
/* keyboard controller config and state */
-static struct keyb {
- struct input_config input; /* The input layer */
+struct tegra_kbd_priv {
+ struct input_config *input; /* The input layer */
struct key_matrix matrix; /* The key matrix layer */
struct kbc_tegra *kbc; /* tegra keyboard controller */
unsigned char inited; /* 1 if keyboard has been inited */
unsigned char first_scan; /* 1 if this is our first key scan */
- unsigned char created; /* 1 if driver has been created */
/*
* After init we must wait a short time before polling the keyboard.
@@ -58,17 +59,17 @@ static struct keyb {
unsigned int start_time_ms; /* Time that we inited (in ms) */
unsigned int last_poll_ms; /* Time we should last polled */
unsigned int next_repeat_ms;/* Next time we repeat a key */
-} config;
+};
/**
* reads the keyboard fifo for current keypresses
*
- * @param config Keyboard config
+ * @param priv Keyboard private data
* @param fifo Place to put fifo results
* @param max_keycodes Maximum number of key codes to put in the fifo
* @return number of items put into fifo
*/
-static int tegra_kbc_find_keys(struct keyb *config, int *fifo,
+static int tegra_kbc_find_keys(struct tegra_kbd_priv *priv, int *fifo,
int max_keycodes)
{
struct key_matrix_key keys[KBC_MAX_KPENT], *key;
@@ -78,7 +79,7 @@ static int tegra_kbc_find_keys(struct keyb *config, int *fifo,
for (key = keys, i = 0; i < KBC_MAX_KPENT; i++, key++) {
/* Get next word */
if (!(i & 3))
- kp_ent = readl(>kbc->kp_ent[i / 4]);
+ kp_ent = readl(>kbc->kp_ent[i / 4]);
key->valid = (kp_ent & KBC_KPENT_VALID) != 0;
key->row = (kp_ent >> 3) & 0xf;
@@ -87,7 +88,7 @@ static int tegra_kbc_find_keys(struct keyb *config, int *fifo,
/* Shift to get next entry */
kp_ent >>= 8;
}
- return key_matrix_decode(>matrix, keys, KBC_MAX_KPENT, fifo,
+ return key_matrix_decode(>matrix, keys, KBC_MAX_KPENT, fifo,
max_keycodes);
}
@@ -106,10 +107,10 @@ static int tegra_kbc_find_keys(struct keyb *config, int
*fifo,
* Note: if fifo_cnt is 0, we will tell the input layer that no keys are
* pressed.
*
- * @param config Keyboard config
+ * @param priv Keyboard private data
* @param fifo_cnt Number of entries in the keyboard fifo
*/
-static void process_fifo(struct keyb *config, int fifo_cnt)
+static void process_fifo(struct tegra_kbd_priv *priv, int fifo_cnt)
{
int fifo[KBC_MAX_KPENT];
int cnt = 0;
@@ -117,9 +118,9 @@ static void process_fifo(struct keyb *config, int fifo_cnt)
/* Always call input_send_keycodes() at least once */
do {
if (fifo_cnt)
- cnt = tegra_kbc_find_keys(config, fifo, KBC_MAX_KPENT);
+ cnt = tegra_kbc_find_keys(priv, fifo, KBC_MAX_KPENT);
- input_send_keycodes(>input, fifo, cnt);
+ input_send_keycodes(priv->input, fifo, cnt);
} while (--fifo_cnt > 0);
}
@@ -127,24 +128,24 @@ static void process_fifo(struct keyb *config, int
fifo_cnt)
* Check the keyboard controller and emit ASCII characters for any keys that
* are pressed.
*
- * @param config Keyboard config
+ * @param priv Keyboard private data
*/
-static void check_for_keys(struct keyb *config)
+static void check_for_keys(struct tegra_kbd_priv *priv)
{
int fifo_cnt;
- if (!config->first_scan &&
-