]> git.karo-electronics.de Git - karo-tx-uboot.git/blob - board/karo/common/karo.h
arm64: add support for Ka-Ro TXSD-410E
[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 struct gpio_desc;
22
23 #ifdef CONFIG_SYS_LVDS_IF
24 #define is_lvds()                       1
25 #else
26 #define is_lvds()                       0
27 #endif
28
29 void env_cleanup(void);
30
31 #ifdef CONFIG_OF_LIBFDT
32 void karo_fdt_remove_node(void *blob, const char *node);
33 void karo_fdt_move_fdt(void);
34 void karo_fdt_fixup_touchpanel(void *blob, const char *panels[],
35                         size_t num_panels);
36 void karo_fdt_fixup_usb_otg(void *blob, const char *node, const char *phy,
37                         const char *phy_supply);
38 void karo_fdt_fixup_flexcan(void *blob, int xcvr_present);
39 void karo_fdt_del_prop(void *blob, const char *compat, u32 offs,
40                 const char *prop);
41 void karo_fdt_enable_node(void *blob, const char *node, int enable);
42 int karo_fdt_get_fb_mode(const void *blob, const char *name,
43                 struct fb_videomode *fb_mode);
44 int karo_fdt_update_fb_mode(void *blob, const char *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 int karo_fdt_get_backlight_gpio(const void *blob, struct gpio_desc *desc);
49 #else
50 static inline void karo_fdt_remove_node(void *blob, const char *node)
51 {
52 }
53 static inline void karo_fdt_move_fdt(void)
54 {
55 }
56 static inline void karo_fdt_fixup_touchpanel(void *blob, const char *panels[],
57                                         size_t num_panels)
58 {
59 }
60 static inline void karo_fdt_fixup_usb_otg(void *blob, const char *node,
61                                         const char *phy,
62                                         const char *phy_supply)
63 {
64 }
65 static inline void karo_fdt_fixup_flexcan(void *blob, int xcvr_present)
66 {
67 }
68 static inline void karo_fdt_del_prop(void *blob, const char *compat,
69                                 u32 offs, const char *prop)
70 {
71 }
72 static inline void karo_fdt_enable_node(void *blob, const char *node,
73                                         int enable)
74 {
75 }
76 static inline int karo_fdt_get_fb_mode(void *blob, const char *name,
77                                 struct fb_videomode *fb_mode)
78 {
79         return 0;
80 }
81 static inline int karo_fdt_update_fb_mode(void *blob, const char *name)
82 {
83         return 0;
84 }
85 static inline int karo_fdt_create_fb_mode(void *blob,
86                                         const char *name,
87                                         struct fb_videomode *mode)
88 {
89         return 0;
90 }
91 static inline int karo_fdt_get_backlight_polarity(const void *blob)
92 {
93         return getenv_yesno("backlight_polarity");
94 }
95 static inline int karo_fdt_get_backlight_gpio(const void *blob,
96                                         struct gpio_desc *desc)
97 {
98         return -ENOENT;
99 }
100 #endif
101
102 #if defined(CONFIG_SYS_LVDS_IF) && defined(CONFIG_OF_LIBFDT)
103 int karo_fdt_get_lcd_bus_width(const void *blob, int default_width);
104 int karo_fdt_get_lvds_mapping(const void *blob, int default_mapping);
105 u8 karo_fdt_get_lvds_channels(const void *blob);
106 #else
107 static inline int karo_fdt_get_lcd_bus_width(const void *blob, int default_width)
108 {
109         return default_width;
110 }
111 static inline int karo_fdt_get_lvds_mapping(const void *blob, int default_mapping)
112 {
113         return default_mapping;
114 }
115 static inline u8 karo_fdt_get_lvds_channels(const void *blob)
116 {
117         return 0;
118 }
119 #endif
120
121 static inline const char *karo_get_vmode(const char *video_mode)
122 {
123         const char *vmode = NULL;
124
125         if (video_mode == NULL || strlen(video_mode) == 0)
126                 return NULL;
127
128         vmode = strchr(video_mode, ':');
129         return vmode ? vmode + 1 : video_mode;
130 }
131
132 #ifdef CONFIG_LCD
133 #ifdef CONFIG_VIDEO_IPUV3
134 #include <mxcfb.h>
135 #endif
136
137 #ifndef FB_SYNC_CLK_LAT_FALL
138 #define FB_SYNC_CLK_LAT_FALL            0
139 #define FB_SYNC_OE_LOW_ACT              0
140 #endif
141
142 int karo_get_fb_mode(const char *name, struct fb_videomode **mode);
143 #else
144 static inline int karo_get_fb_mode(const char *name,
145                                 struct fb_videomode **mode)
146 {
147         return -EOPNOTSUPP;
148 }
149 #endif /* CONFIG_LCD */
150
151 #ifdef CONFIG_SPLASH_SCREEN
152 int karo_load_splashimage(int mode);
153 #else
154 static inline int karo_load_splashimage(int mode)
155 {
156         return 0;
157 }
158 #endif /* CONFIG_SPLASH_SCREEN */
159
160 #ifdef CONFIG_CMD_NAND
161 int karo_nand_load_part(const char *part, void *addr, size_t len);
162 #else
163 static inline int karo_nand_load_part(const char *part, void *addr, size_t len)
164 {
165         return -EOPNOTSUPP;
166 }
167 #endif
168
169 #ifdef CONFIG_ENV_IS_IN_MMC
170 int karo_mmc_load_part(const char *part, void *addr, size_t len);
171 #else
172 static inline int karo_mmc_load_part(const char *part, void *addr, size_t len)
173 {
174         return -EOPNOTSUPP;
175 }
176 #endif
177
178 static inline int karo_load_part(const char *part, void *addr, size_t len)
179 {
180         int ret;
181
182         ret = karo_nand_load_part(part, addr, len);
183         if (ret == -EOPNOTSUPP)
184                 return karo_mmc_load_part(part, addr, len);
185         return ret;
186 }
187
188 #define DIV_ROUND(n, d)         (((n) + (d) / 2) / (d))