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