]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/karo/common/karo.h
Merge branch 'karo-tx-uboot' into kc-merge
[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
18 #include <errno.h>
19
20 struct fb_videomode;
21
22 #ifdef CONFIG_SYS_LVDS_IF
23 #define is_lvds()                       1
24 #else
25 #define is_lvds()                       0
26 #endif
27
28 void env_cleanup(void);
29
30 #ifdef CONFIG_OF_LIBFDT
31 void karo_fdt_remove_node(void *blob, const char *node);
32 void karo_fdt_move_fdt(void);
33 void karo_fdt_fixup_touchpanel(void *blob, const char *panels[],
34                         size_t num_panels);
35 void karo_fdt_fixup_usb_otg(void *blob, const char *node, const char *phy,
36                         const char *phy_supply);
37 void karo_fdt_fixup_flexcan(void *blob, int xcvr_present);
38 void karo_fdt_del_prop(void *blob, const char *compat, u32 offs,
39                 const char *prop);
40 void karo_fdt_enable_node(void *blob, const char *node, int enable);
41 int karo_fdt_get_fb_mode(void *blob, const char *name,
42                 struct fb_videomode *fb_mode);
43 int karo_fdt_update_fb_mode(void *blob, const char *name);
44 int karo_fdt_create_fb_mode(void *blob, const char *name,
45                         struct fb_videomode *mode);
46 int karo_fdt_get_backlight_polarity(const void *blob);
47 #else
48 static inline void karo_fdt_remove_node(void *blob, const char *node)
49 {
50 }
51 static inline void karo_fdt_move_fdt(void)
52 {
53 }
54 static inline void karo_fdt_fixup_touchpanel(void *blob, const char *panels[],
55                                         size_t num_panels)
56 {
57 }
58 static inline void karo_fdt_fixup_usb_otg(void *blob, const char *node,
59                                         const char *phy,
60                                         const char *phy_supply)
61 {
62 }
63 static inline void karo_fdt_fixup_flexcan(void *blob, int xcvr_present)
64 {
65 }
66 static inline void karo_fdt_del_prop(void *blob, const char *compat,
67                                 u32 offs, const char *prop)
68 {
69 }
70 static inline void karo_fdt_enable_node(void *blob, const char *node,
71                                         int enable)
72 {
73 }
74 static inline int karo_fdt_get_fb_mode(void *blob, const char *name,
75                                 struct fb_videomode *fb_mode)
76 {
77         return 0;
78 }
79 static inline int karo_fdt_update_fb_mode(void *blob, const char *name)
80 {
81         return 0;
82 }
83 static inline int karo_fdt_create_fb_mode(void *blob,
84                                         const char *name,
85                                         struct fb_videomode *mode)
86 {
87         return 0;
88 }
89 static inline int karo_fdt_get_backlight_polarity(const void *blob)
90 {
91         return getenv_yesno("backlight_polarity");
92 }
93 #endif
94
95 #if defined(CONFIG_SYS_LVDS_IF) && defined(CONFIG_OF_LIBFDT)
96 int karo_fdt_get_lcd_bus_width(const void *blob, int default_width);
97 int karo_fdt_get_lvds_mapping(const void *blob, int default_mapping);
98 u8 karo_fdt_get_lvds_channels(const void *blob);
99 #else
100 static inline int karo_fdt_get_lcd_bus_width(const void *blob, int default_width)
101 {
102         return default_width;
103 }
104 static inline int karo_fdt_get_lvds_mapping(const void *blob, int default_mapping)
105 {
106         return default_mapping;
107 }
108 static inline u8 karo_fdt_get_lvds_channels(const void *blob)
109 {
110         return 0;
111 }
112 #endif
113
114 static inline const char *karo_get_vmode(const char *video_mode)
115 {
116         const char *vmode = NULL;
117
118         if (video_mode == NULL || strlen(video_mode) == 0)
119                 return NULL;
120
121         vmode = strchr(video_mode, ':');
122         return vmode ? vmode + 1 : video_mode;
123 }
124
125 #ifdef CONFIG_SPLASH_SCREEN
126 int karo_load_splashimage(int mode);
127 #else
128 static inline int karo_load_splashimage(int mode)
129 {
130         return 0;
131 }
132 #endif
133
134 #ifdef CONFIG_CMD_NAND
135 int karo_load_nand_part(const char *part, void *addr, size_t len);
136 #else
137 static inline int karo_load_nand_part(const char *part, void *addr, size_t len)
138 {
139         return -EOPNOTSUPP;
140 }
141 #endif
142
143 #ifdef CONFIG_ENV_IS_IN_MMC
144 int karo_load_mmc_part(const char *part, void *addr, size_t len);
145 #else
146 static inline int karo_load_mmc_part(const char *part, void *addr, size_t len)
147 {
148         return -EOPNOTSUPP;
149 }
150 #endif
151
152 static inline int karo_load_part(const char *part, void *addr, size_t len)
153 {
154         int ret;
155
156         ret = karo_load_nand_part(part, addr, len);
157         if (ret == -EOPNOTSUPP)
158                 return karo_load_mmc_part(part, addr, len);
159         return ret;
160 }
161
162 #define DIV_ROUND(n, d)         (((n) + (d) / 2) / (d))