
Add a method for setting up the LPC device after it has been probed. This is needed because the device cannot fully init until other parts of the system are ready.
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/x86/lib/lpc-uclass.c | 11 +++++++++++ include/lpc.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 include/lpc.h
diff --git a/arch/x86/lib/lpc-uclass.c b/arch/x86/lib/lpc-uclass.c index c6e8f73..399e3db 100644 --- a/arch/x86/lib/lpc-uclass.c +++ b/arch/x86/lib/lpc-uclass.c @@ -7,10 +7,21 @@
#include <common.h> #include <dm.h> +#include <lpc.h> #include <dm/root.h>
DECLARE_GLOBAL_DATA_PTR;
+int lpc_init(struct udevice *dev) +{ + struct lpc_ops *ops = lpc_get_ops(dev); + + if (!ops->init) + return -ENOSYS; + + return ops->init(dev); +} + static int lpc_uclass_post_bind(struct udevice *bus) { /* diff --git a/include/lpc.h b/include/lpc.h new file mode 100644 index 0000000..9bd2c72 --- /dev/null +++ b/include/lpc.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2015 Google, Inc + * Written by Simon Glass sjg@chromium.org + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __lpc_h +#define __lpc_h + +struct lpc_ops { + /** + * init() - set up the LPC device + * + * Complete any init needed to bring the LPC fully into operation. + */ + int (*init)(struct udevice *dev); +}; + +#define lpc_get_ops(dev) ((struct lpc_ops *)(dev)->driver->ops) + +/** + * lpc_init() - init a LPC + * + * Complete any init needed to bring the LPC fully into operation. + * + * @dev: LPC device to init + * @return 0 if OK, -ve on error + */ +int lpc_init(struct udevice *dev); + +#endif