]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/karo/common/karo.h
karo: remove dynamically created variables from the environment upon boot
[karo-tx-uboot.git] / board / karo / common / karo.h
1 /*
2  * (C) Copyright 2012 Lothar Waßmann <LW@KARO-electronics.de>
3  *
4  * See file CREDITS for list of people who contributed to this
5  * project.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16 */
17 struct fb_videomode;
18
19 #ifdef CONFIG_SYS_LVDS_IF
20 #define is_lvds()                       1
21 #else
22 #define is_lvds()                       0
23 #endif
24
25 void env_cleanup(void);
26
27 #ifdef CONFIG_OF_LIBFDT
28 void karo_fdt_remove_node(void *blob, const char *node);
29 void karo_fdt_move_fdt(void);
30 void karo_fdt_fixup_touchpanel(void *blob, const char *panels[],
31                         size_t num_panels);
32 void karo_fdt_fixup_usb_otg(void *blob, const char *node, const char *phy,
33                         const char *phy_supply);
34 void karo_fdt_fixup_flexcan(void *blob, int xcvr_present);
35 void karo_fdt_del_prop(void *blob, const char *compat, u32 offs,
36                 const char *prop);
37 void karo_fdt_enable_node(void *blob, const char *node, int enable);
38 int karo_fdt_get_fb_mode(void *blob, const char *name,
39                 struct fb_videomode *fb_mode);
40 int karo_fdt_update_fb_mode(void *blob, const char *name);
41 int karo_fdt_create_fb_mode(void *blob, const char *name,
42                         struct fb_videomode *mode);
43 int karo_fdt_get_backlight_polarity(const void *blob);
44 #else
45 static inline void karo_fdt_remove_node(void *blob, const char *node)
46 {
47 }
48 static inline void karo_fdt_move_fdt(void)
49 {
50 }
51 static inline void karo_fdt_fixup_touchpanel(void *blob, const char *panels[],
52                                         size_t num_panels)
53 {
54 }
55 static inline void karo_fdt_fixup_usb_otg(void *blob, const char *node,
56                                         const char *phy,
57                                         const char *phy_supply)
58 {
59 }
60 static inline void karo_fdt_fixup_flexcan(void *blob, int xcvr_present)
61 {
62 }
63 static inline void karo_fdt_del_prop(void *blob, const char *compat,
64                                 u32 offs, const char *prop)
65 {
66 }
67 static inline void karo_fdt_enable_node(void *blob, const char *node,
68                                         int enable)
69 {
70 }
71 static inline int karo_fdt_get_fb_mode(void *blob, const char *name,
72                                 struct fb_videomode *fb_mode)
73 {
74         return 0;
75 }
76 static inline int karo_fdt_update_fb_mode(void *blob, const char *name)
77 {
78         return 0;
79 }
80 static inline int karo_fdt_create_fb_mode(void *blob,
81                                         const char *name,
82                                         struct fb_videomode *mode)
83 {
84         return 0;
85 }
86 static inline int karo_fdt_get_backlight_polarity(const void *blob)
87 {
88         return getenv_yesno("backlight_polarity");
89 }
90 #endif
91
92 #if defined(CONFIG_SYS_LVDS_IF) && defined(CONFIG_OF_LIBFDT)
93 int karo_fdt_get_lcd_bus_width(const void *blob, int default_width);
94 int karo_fdt_get_lvds_mapping(const void *blob, int default_mapping);
95 u8 karo_fdt_get_lvds_channels(const void *blob);
96 #else
97 static inline int karo_fdt_get_lcd_bus_width(const void *blob, int default_width)
98 {
99         return default_width;
100 }
101 static inline int karo_fdt_get_lvds_mapping(const void *blob, int default_mapping)
102 {
103         return default_mapping;
104 }
105 static inline u8 karo_fdt_get_lvds_channels(const void *blob)
106 {
107         return 0;
108 }
109 #endif
110
111 static inline const char *karo_get_vmode(const char *video_mode)
112 {
113         const char *vmode = NULL;
114
115         if (video_mode == NULL || strlen(video_mode) == 0)
116                 return NULL;
117
118         vmode = strchr(video_mode, ':');
119         return vmode ? vmode + 1 : video_mode;
120 }
121
122 #ifdef CONFIG_SPLASH_SCREEN
123 int karo_load_splashimage(int mode);
124 #else
125 static inline int karo_load_splashimage(int mode)
126 {
127         return 0;
128 }
129 #endif
130
131 #ifdef CONFIG_CMD_NAND
132 int karo_load_nand_part(const char *part, void *addr, size_t len);
133 #else
134 static inline int karo_load_nand_part(const char *part, void *addr, size_t len)
135 {
136         return -EOPNOTSUPP;
137 }
138 #endif
139
140 #ifdef CONFIG_ENV_IS_IN_MMC
141 int karo_load_mmc_part(const char *part, void *addr, size_t len);
142 #else
143 static inline int karo_load_mmc_part(const char *part, void *addr, size_t len)
144 {
145         return -EOPNOTSUPP;
146 }
147 #endif
148
149 static inline int karo_load_part(const char *part, void *addr, size_t len)
150 {
151         int ret;
152
153         ret = karo_load_nand_part(part, addr, len);
154         if (ret == -EOPNOTSUPP)
155                 return karo_load_mmc_part(part, addr, len);
156         return ret;
157 }