xref: /rk3399_rockchip-uboot/include/hwconfig.h (revision dd50af2515ad39fa2f6c09ab621f69fef4f5fceb)
193f9dcf9SAnton Vorontsov /*
293f9dcf9SAnton Vorontsov  * An inteface for configuring a hardware via u-boot environment.
393f9dcf9SAnton Vorontsov  *
493f9dcf9SAnton Vorontsov  * Copyright (c) 2009  MontaVista Software, Inc.
5*dd50af25SKumar Gala  * Copyright 2011 Freescale Semiconductor, Inc.
693f9dcf9SAnton Vorontsov  *
793f9dcf9SAnton Vorontsov  * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
893f9dcf9SAnton Vorontsov  *
993f9dcf9SAnton Vorontsov  * This program is free software; you can redistribute it and/or
1093f9dcf9SAnton Vorontsov  * modify it under the terms of the GNU General Public License as
1193f9dcf9SAnton Vorontsov  * published by the Free Software Foundation; either version 2 of
1293f9dcf9SAnton Vorontsov  * the License, or (at your option) any later version.
1393f9dcf9SAnton Vorontsov  */
1493f9dcf9SAnton Vorontsov 
1593f9dcf9SAnton Vorontsov #ifndef _HWCONFIG_H
1693f9dcf9SAnton Vorontsov #define _HWCONFIG_H
1793f9dcf9SAnton Vorontsov 
1893f9dcf9SAnton Vorontsov #include <linux/types.h>
1993f9dcf9SAnton Vorontsov #include <asm/errno.h>
2093f9dcf9SAnton Vorontsov 
2193f9dcf9SAnton Vorontsov #ifdef CONFIG_HWCONFIG
2293f9dcf9SAnton Vorontsov 
23*dd50af25SKumar Gala extern int hwconfig_f(const char *opt, char *buf);
24*dd50af25SKumar Gala extern const char *hwconfig_arg_f(const char *opt, size_t *arglen, char *buf);
25*dd50af25SKumar Gala extern int hwconfig_arg_cmp_f(const char *opt, const char *arg, char *buf);
26*dd50af25SKumar Gala extern int hwconfig_sub_f(const char *opt, const char *subopt, char *buf);
27*dd50af25SKumar Gala extern const char *hwconfig_subarg_f(const char *opt, const char *subopt,
28*dd50af25SKumar Gala 				     size_t *subarglen, char *buf);
29*dd50af25SKumar Gala extern int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
30*dd50af25SKumar Gala 				 const char *subarg, char *buf);
3193f9dcf9SAnton Vorontsov #else
3293f9dcf9SAnton Vorontsov 
33*dd50af25SKumar Gala static inline int hwconfig_f(const char *opt, char *buf)
3493f9dcf9SAnton Vorontsov {
3593f9dcf9SAnton Vorontsov 	return -ENOSYS;
3693f9dcf9SAnton Vorontsov }
3793f9dcf9SAnton Vorontsov 
38*dd50af25SKumar Gala static inline const char *hwconfig_arg_f(const char *opt, size_t *arglen,
39*dd50af25SKumar Gala 					 char *buf)
4093f9dcf9SAnton Vorontsov {
4193f9dcf9SAnton Vorontsov 	*arglen = 0;
4293f9dcf9SAnton Vorontsov 	return "";
4393f9dcf9SAnton Vorontsov }
4493f9dcf9SAnton Vorontsov 
45*dd50af25SKumar Gala static inline int hwconfig_arg_cmp_f(const char *opt, const char *arg,
46*dd50af25SKumar Gala 				     char *buf)
4793f9dcf9SAnton Vorontsov {
4893f9dcf9SAnton Vorontsov 	return -ENOSYS;
4993f9dcf9SAnton Vorontsov }
5093f9dcf9SAnton Vorontsov 
51*dd50af25SKumar Gala static inline int hwconfig_sub_f(const char *opt, const char *subopt, char *buf)
5293f9dcf9SAnton Vorontsov {
5393f9dcf9SAnton Vorontsov 	return -ENOSYS;
5493f9dcf9SAnton Vorontsov }
5593f9dcf9SAnton Vorontsov 
56*dd50af25SKumar Gala static inline const char *hwconfig_subarg_f(const char *opt, const char *subopt,
57*dd50af25SKumar Gala 					    size_t *subarglen, char *buf)
5893f9dcf9SAnton Vorontsov {
5993f9dcf9SAnton Vorontsov 	*subarglen = 0;
6093f9dcf9SAnton Vorontsov 	return "";
6193f9dcf9SAnton Vorontsov }
6293f9dcf9SAnton Vorontsov 
63*dd50af25SKumar Gala static inline int hwconfig_subarg_cmp_f(const char *opt, const char *subopt,
64*dd50af25SKumar Gala 					const char *subarg, char *buf)
6593f9dcf9SAnton Vorontsov {
6693f9dcf9SAnton Vorontsov 	return -ENOSYS;
6793f9dcf9SAnton Vorontsov }
6893f9dcf9SAnton Vorontsov 
6993f9dcf9SAnton Vorontsov #endif /* CONFIG_HWCONFIG */
7093f9dcf9SAnton Vorontsov 
71*dd50af25SKumar Gala static inline int hwconfig(const char *opt)
72*dd50af25SKumar Gala {
73*dd50af25SKumar Gala 	return hwconfig_f(opt, NULL);
74*dd50af25SKumar Gala }
75*dd50af25SKumar Gala 
76*dd50af25SKumar Gala static inline const char *hwconfig_arg(const char *opt, size_t *arglen)
77*dd50af25SKumar Gala {
78*dd50af25SKumar Gala 	return hwconfig_arg_f(opt, arglen, NULL);
79*dd50af25SKumar Gala }
80*dd50af25SKumar Gala 
81*dd50af25SKumar Gala static inline int hwconfig_arg_cmp(const char *opt, const char *arg)
82*dd50af25SKumar Gala {
83*dd50af25SKumar Gala 	return hwconfig_arg_cmp_f(opt, arg, NULL);
84*dd50af25SKumar Gala }
85*dd50af25SKumar Gala 
86*dd50af25SKumar Gala static inline int hwconfig_sub(const char *opt, const char *subopt)
87*dd50af25SKumar Gala {
88*dd50af25SKumar Gala 	return hwconfig_sub_f(opt, subopt, NULL);
89*dd50af25SKumar Gala }
90*dd50af25SKumar Gala 
91*dd50af25SKumar Gala static inline const char *hwconfig_subarg(const char *opt, const char *subopt,
92*dd50af25SKumar Gala 					  size_t *subarglen)
93*dd50af25SKumar Gala {
94*dd50af25SKumar Gala 	return hwconfig_subarg_f(opt, subopt, subarglen, NULL);
95*dd50af25SKumar Gala }
96*dd50af25SKumar Gala 
97*dd50af25SKumar Gala static inline int hwconfig_subarg_cmp(const char *opt, const char *subopt,
98*dd50af25SKumar Gala 				      const char *subarg)
99*dd50af25SKumar Gala {
100*dd50af25SKumar Gala 	return hwconfig_subarg_cmp_f(opt, subopt, subarg, NULL);
101*dd50af25SKumar Gala }
102*dd50af25SKumar Gala 
10393f9dcf9SAnton Vorontsov #endif /* _HWCONFIG_H */
104