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