dm: input: add implementation of driver model key uclass

Change-Id: I379b694dfaee14ed23cc7abfa05aff77933bb725
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen 2017-09-18 19:41:54 +08:00 committed by Kever Yang
parent a7ca45e88e
commit b398a9a7fa
5 changed files with 53 additions and 0 deletions

View File

@ -7,6 +7,12 @@ config DM_KEYBOARD
includes methods to start/stop the device, check for available
input and update LEDs if the keyboard has them.
config DM_KEY
bool "Enable driver model key support"
depends on DM
help
This adds a simple uclass for key.
config CROS_EC_KEYB
bool "Enable Chrome OS EC keyboard support"
help

View File

@ -6,6 +6,7 @@
#
obj-$(CONFIG_DM_KEYBOARD) += keyboard-uclass.o
obj-$(CONFIG_DM_KEY) += key-uclass.o
obj-$(CONFIG_I8042_KEYB) += i8042.o
obj-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o

View File

@ -0,0 +1,23 @@
/*
* (C) Copyright 2017 Rockchip Electronics Co., Ltd
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <dm.h>
#include <key.h>
int key_read(struct udevice *dev)
{
const struct dm_key_ops *ops = dev_get_driver_ops(dev);
if (!ops || !ops->read)
return -ENOSYS;
return ops->read(dev);
}
UCLASS_DRIVER(key) = {
.id = UCLASS_KEY,
.name = "key",
};

View File

@ -90,6 +90,7 @@ enum uclass_id {
UCLASS_VIDEO_CONSOLE, /* Text console driver for video device */
UCLASS_WDT, /* Watchdot Timer driver */
UCLASS_FG,
UCLASS_KEY,
UCLASS_COUNT,
UCLASS_INVALID = -1,

22
include/key.h Normal file
View File

@ -0,0 +1,22 @@
/*
* (C) Copyright 2017 Rockchip Electronics Co., Ltd
*
* SPDX-License-Identifier: GPL-2.0+
*/
#ifndef _KEY_H_
#define _KEY_H_
enum key_state {
KEY_PRESS_NONE,
KEY_PRESS_UP,
KEY_PRESS_DOWN,
};
struct dm_key_ops {
int (*read)(struct udevice *dev);
};
int key_read(struct udevice *dev);
#endif