diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2009-06-10 00:25:27 +0400 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2009-07-16 22:23:53 +0200 |
commit | 93f9dcf9e8b8182e97aeb7965c687176cbd0b933 (patch) | |
tree | 90793882a7d90ce0401a151ba40bfd1ce2cbfede /include/hwconfig.h | |
parent | cd21a458da20f62807fedbed86b65f2d59d6b611 (diff) | |
download | u-boot-imx-93f9dcf9e8b8182e97aeb7965c687176cbd0b933.zip u-boot-imx-93f9dcf9e8b8182e97aeb7965c687176cbd0b933.tar.gz u-boot-imx-93f9dcf9e8b8182e97aeb7965c687176cbd0b933.tar.bz2 |
Add simple hwconfig infrastructure
This patch implements simple hwconfig infrastructure: an
interface for software knobs to control a hardware.
This is very simple implementation, i.e. it is implemented
via `hwconfig' environment variable. Later we could write
some "hwconfig <enable|disable|list>" commands, ncurses
interface for Award BIOS-like interface, and frame-buffer
interface for AMI GUI[1] BIOS-like interface with mouse
support[2].
Current implementation details/limitations:
1. Doesn't support options dependencies and mutual exclusion.
We can implement this by integrating apt-get[3] into the
u-boot. But I didn't bother yet.
2. Since we don't implement hwconfig command, i.e. we're working
with the environement directly, there is no way to tell that
toggling a particular option will need a reboot to take
an effect. So, for now it's advised to always reboot the
target after modifying hwconfig variable.
3. We support hwconfig options with arguments. For example,
set hwconfig dr_usb:mode=peripheral,phy_type=ulpi
That means:
- dr_usb - enable Dual-Role USB controller;
- dr_usb:mode=peripheral - USB in Function mode;
- dr_usb:phy_type=ulpi - USB should work with ULPI PHYs;
The purpose of this simple implementation is to define some
internal API and then we can continue improving user experience
by adding more mature interface, like hwconfig command with
bells and whistles. Or not adding, if we feel that current
interface fits its needs.
[1] http://en.wikipedia.org/wiki/American_Megatrends
[2] Regarding ncurses and GUI with mouse support -- I'm just
kidding.
[3] The comment regarding apt-get is also a joke, meaning that
dependency tracking could be non-trivial. For example, for
enabling HW feature X we may need to disable Y, and turn Z
into reduced mode (like RMII-only interface for ethernet,
no MII).
It's quite trivial to implement simple cases though.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Acked-by: Kim Phillips <kim.phillips@freescale.com>
Diffstat (limited to 'include/hwconfig.h')
-rw-r--r-- | include/hwconfig.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/include/hwconfig.h b/include/hwconfig.h new file mode 100644 index 0000000..d517f78 --- /dev/null +++ b/include/hwconfig.h @@ -0,0 +1,69 @@ +/* + * An inteface for configuring a hardware via u-boot environment. + * + * Copyright (c) 2009 MontaVista Software, Inc. + * + * Author: Anton Vorontsov <avorontsov@ru.mvista.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + */ + +#ifndef _HWCONFIG_H +#define _HWCONFIG_H + +#include <linux/types.h> +#include <asm/errno.h> + +#ifdef CONFIG_HWCONFIG + +extern int hwconfig(const char *opt); +extern const char *hwconfig_arg(const char *opt, size_t *arglen); +extern int hwconfig_arg_cmp(const char *opt, const char *arg); +extern int hwconfig_sub(const char *opt, const char *subopt); +extern const char *hwconfig_subarg(const char *opt, const char *subopt, + size_t *subarglen); +extern int hwconfig_subarg_cmp(const char *opt, const char *subopt, + const char *subarg); + +#else + +static inline int hwconfig(const char *opt) +{ + return -ENOSYS; +} + +static inline const char *hwconfig_arg(const char *opt, size_t *arglen) +{ + *arglen = 0; + return ""; +} + +static inline int hwconfig_arg_cmp(const char *opt, const char *arg) +{ + return -ENOSYS; +} + +static inline int hwconfig_sub(const char *opt, const char *subopt) +{ + return -ENOSYS; +} + +static inline const char *hwconfig_subarg(const char *opt, const char *subopt, + size_t *subarglen) +{ + *subarglen = 0; + return ""; +} + +static inline int hwconfig_subarg_cmp(const char *opt, const char *subopt, + const char *subarg) +{ + return -ENOSYS; +} + +#endif /* CONFIG_HWCONFIG */ + +#endif /* _HWCONFIG_H */ |