summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-07-09 16:54:22 +0300
committerTom Rini <trini@konsulko.com>2020-07-09 16:54:22 +0300
commit506d52308a2f5de48c2b9a08229fee9a0ee2842a (patch)
treed0d96d1fac8c0912155941f8b684f8654ce27d50 /include
parentd9107930af63d88c2d84560db19e65f1a51c4cbd (diff)
parentdb17e40ccab6526a9db6ffdd071182a37dd888eb (diff)
downloadu-boot-506d52308a2f5de48c2b9a08229fee9a0ee2842a.tar.xz
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-x86
- Add two- and three-argument versions of CONFIG_IS_ENABLED in linux/kconfig.h - Adds a new feature which supports copying modified parts of the frame buffer to the uncached hardware buffer - Enable the copy framebuffer on various x86 targets
Diffstat (limited to 'include')
-rw-r--r--include/bootstage.h2
-rw-r--r--include/console.h13
-rw-r--r--include/dm/test.h14
-rw-r--r--include/linux/kconfig.h103
-rw-r--r--include/spi.h13
-rw-r--r--include/video.h41
-rw-r--r--include/video_console.h51
7 files changed, 175 insertions, 62 deletions
diff --git a/include/bootstage.h b/include/bootstage.h
index f507271375..00c85fb86a 100644
--- a/include/bootstage.h
+++ b/include/bootstage.h
@@ -338,7 +338,7 @@ int bootstage_stash(void *base, int size);
* @param base Base address of memory buffer
* @param size Size of memory buffer (-1 if unknown)
* @return 0 if unstashed ok, -ENOENT if bootstage info not found, -ENOSPC if
- * there is not space for read the stacked data, or other error if
+ * there is not space for read the stashed data, or other error if
* something else went wrong
*/
int bootstage_unstash(const void *base, int size);
diff --git a/include/console.h b/include/console.h
index 74afe22b7e..4c6b8f2614 100644
--- a/include/console.h
+++ b/include/console.h
@@ -7,6 +7,8 @@
#ifndef __CONSOLE_H
#define __CONSOLE_H
+#include <stdbool.h>
+
extern char console_buffer[];
/* common/console.c */
@@ -72,6 +74,17 @@ int console_record_avail(void);
*/
int console_announce_r(void);
+/**
+ * console_puts_select_stderr() - Output a string to selected console devices
+ *
+ * This writes to stderr only. It is useful for outputting errors
+ *
+ * @serial_only: true to output only to serial, false to output to everything
+ * else
+ * @s: String to output
+ */
+void console_puts_select_stderr(bool serial_only, const char *s);
+
/*
* CONSOLE multiplexing.
*/
diff --git a/include/dm/test.h b/include/dm/test.h
index f0f36624ce..d39686cde2 100644
--- a/include/dm/test.h
+++ b/include/dm/test.h
@@ -159,7 +159,19 @@ enum {
/* Declare a new driver model test */
#define DM_TEST(_name, _flags) UNIT_TEST(_name, _flags, dm_test)
-/* This platform data is needed in tests, so declare it here */
+/*
+ * struct sandbox_sdl_plat - Platform data for the SDL video driver
+ *
+ * This platform data is needed in tests, so declare it here
+ *
+ * @xres: Width of display in pixels
+ * @yres: Height of display in pixels
+ * @bpix: Log2 of bits per pixel (enum video_log2_bpp)
+ * @rot: Console rotation (0=normal orientation, 1=90 degrees clockwise,
+ * 2=upside down, 3=90 degree counterclockwise)
+ * @vidconsole_drv_name: Name of video console driver (set by tests)
+ * @font_size: Console font size to select (set by tests)
+ */
struct sandbox_sdl_plat {
int xres;
int yres;
diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 3a2da738c4..d109ed3119 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -23,54 +23,30 @@
#define ___config_enabled(__ignored, val, ...) val
/*
- * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',
+ * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y',
* 0 otherwise.
*
*/
#define IS_ENABLED(option) \
- (config_enabled(option) || config_enabled(option##_MODULE))
-
-/*
- * IS_BUILTIN(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', 0
- * otherwise. For boolean options, this is equivalent to
- * IS_ENABLED(CONFIG_FOO).
- */
-#define IS_BUILTIN(option) config_enabled(option)
-
-/*
- * IS_MODULE(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'm', 0
- * otherwise.
- */
-#define IS_MODULE(option) config_enabled(option##_MODULE)
+ (config_enabled(option))
/*
* U-Boot add-on: Helper macros to reference to different macros
* (CONFIG_ or CONFIG_SPL_ prefixed), depending on the build context.
*/
-#ifdef CONFIG_SPL_BUILD
-#define _IS_SPL 1
-#endif
-
-#ifdef CONFIG_TPL_BUILD
-#define _IS_TPL 1
-#endif
#if defined(CONFIG_TPL_BUILD)
-#define config_val(cfg) _config_val(_IS_TPL, cfg)
-#define _config_val(x, cfg) __config_val(x, cfg)
-#define __config_val(x, cfg) ___config_val(__ARG_PLACEHOLDER_##x, cfg)
-#define ___config_val(arg1_or_junk, cfg) \
- ____config_val(arg1_or_junk CONFIG_TPL_##cfg, CONFIG_##cfg)
-#define ____config_val(__ignored, val, ...) val
+#define _CONFIG_PREFIX TPL_
+#elif defined(CONFIG_SPL_BUILD)
+#define _CONFIG_PREFIX SPL_
#else
-#define config_val(cfg) _config_val(_IS_SPL, cfg)
-#define _config_val(x, cfg) __config_val(x, cfg)
-#define __config_val(x, cfg) ___config_val(__ARG_PLACEHOLDER_##x, cfg)
-#define ___config_val(arg1_or_junk, cfg) \
- ____config_val(arg1_or_junk CONFIG_SPL_##cfg, CONFIG_##cfg)
-#define ____config_val(__ignored, val, ...) val
+#define _CONFIG_PREFIX
#endif
+#define config_val(cfg) _config_val(_CONFIG_PREFIX, cfg)
+#define _config_val(pfx, cfg) __config_val(pfx, cfg)
+#define __config_val(pfx, cfg) CONFIG_ ## pfx ## cfg
+
/*
* CONFIG_VAL(FOO) evaluates to the value of
* CONFIG_FOO if CONFIG_SPL_BUILD is undefined,
@@ -80,30 +56,55 @@
#define CONFIG_VAL(option) config_val(option)
/*
- * CONFIG_IS_ENABLED(FOO) evaluates to
- * 1 if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y' or 'm',
- * 1 if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y' or 'm',
- * 1 if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y' or 'm',
- * 0 otherwise.
+ * Count number of arguments to a variadic macro. Currently only need
+ * it for 1, 2 or 3 arguments.
*/
-#define CONFIG_IS_ENABLED(option) \
- (config_enabled(CONFIG_VAL(option)) || \
- config_enabled(CONFIG_VAL(option##_MODULE)))
+#define __arg6(a1, a2, a3, a4, a5, a6, ...) a6
+#define __count_args(...) __arg6(dummy, ##__VA_ARGS__, 4, 3, 2, 1, 0)
+
+#define __concat(a, b) ___concat(a, b)
+#define ___concat(a, b) a ## b
+
+#define __unwrap(...) __VA_ARGS__
+#define __unwrap1(case1, case0) __unwrap case1
+#define __unwrap0(case1, case0) __unwrap case0
+
+#define __CONFIG_IS_ENABLED_1(option) __CONFIG_IS_ENABLED_3(option, (1), (0))
+#define __CONFIG_IS_ENABLED_2(option, case1) __CONFIG_IS_ENABLED_3(option, case1, ())
+#define __CONFIG_IS_ENABLED_3(option, case1, case0) \
+ __concat(__unwrap, config_enabled(CONFIG_VAL(option))) (case1, case0)
/*
- * CONFIG_IS_BUILTIN(FOO) evaluates to
+ * CONFIG_IS_ENABLED(FOO) expands to
* 1 if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
* 1 if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
+ * 1 if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
* 0 otherwise.
+ *
+ * CONFIG_IS_ENABLED(FOO, (abc)) expands to
+ * abc if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
+ * abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
+ * abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
+ * nothing otherwise.
+ *
+ * CONFIG_IS_ENABLED(FOO, (abc), (def)) expands to
+ * abc if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
+ * abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
+ * abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
+ * def otherwise.
+ *
+ * The optional second and third arguments must be parenthesized; that
+ * allows one to include a trailing comma, e.g. for use in
+ *
+ * CONFIG_IS_ENABLED(ACME, ({.compatible = "acme,frobnozzle"},))
+ *
+ * which adds an entry to the array being defined if CONFIG_ACME (or
+ * CONFIG_SPL_ACME/CONFIG_TPL_ACME, depending on build context) is
+ * set, and nothing otherwise.
*/
-#define CONFIG_IS_BUILTIN(option) config_enabled(CONFIG_VAL(option))
-/*
- * CONFIG_IS_MODULE(FOO) evaluates to
- * 1 if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'm',
- * 1 if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'm',
- * 0 otherwise.
- */
-#define CONFIG_IS_MODULE(option) config_enabled(CONFIG_VAL(option##_MODULE))
+#define CONFIG_IS_ENABLED(option, ...) \
+ __concat(__CONFIG_IS_ENABLED_, __count_args(option, ##__VA_ARGS__)) (option, ##__VA_ARGS__)
+
#endif /* __LINUX_KCONFIG_H */
diff --git a/include/spi.h b/include/spi.h
index 9b4fb8dc0b..a37900b2fd 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -39,7 +39,6 @@
#define SPI_DEFAULT_WORDLEN 8
-#if CONFIG_IS_ENABLED(DM_SPI)
/* TODO(sjg@chromium.org): Remove this and use max_hz from struct spi_slave */
struct dm_spi_bus {
uint max_hz;
@@ -65,8 +64,6 @@ struct dm_spi_slave_platdata {
uint mode;
};
-#endif /* CONFIG_DM_SPI */
-
/**
* enum spi_clock_phase - indicates the clock phase to use for SPI (CPHA)
*
@@ -317,6 +314,11 @@ void spi_flash_copy_mmap(void *data, void *offset, size_t len);
*/
int spi_cs_is_valid(unsigned int bus, unsigned int cs);
+/*
+ * These names are used in several drivers and these declarations will be
+ * removed soon as part of the SPI DM migration. Drop them if driver model is
+ * enabled for SPI.
+ */
#if !CONFIG_IS_ENABLED(DM_SPI)
/**
* Activate a SPI chipselect.
@@ -335,6 +337,7 @@ void spi_cs_activate(struct spi_slave *slave);
* select to the device identified by "slave".
*/
void spi_cs_deactivate(struct spi_slave *slave);
+#endif
/**
* Set transfer speed.
@@ -343,7 +346,6 @@ void spi_cs_deactivate(struct spi_slave *slave);
* @hz: The transfer speed
*/
void spi_set_speed(struct spi_slave *slave, uint hz);
-#endif
/**
* Write 8 bits, then read 8 bits.
@@ -367,8 +369,6 @@ static inline int spi_w8r8(struct spi_slave *slave, unsigned char byte)
return ret < 0 ? ret : din[1];
}
-#if CONFIG_IS_ENABLED(DM_SPI)
-
/**
* struct spi_cs_info - Information about a bus chip select
*
@@ -717,6 +717,5 @@ int dm_spi_get_mmap(struct udevice *dev, ulong *map_basep, uint *map_sizep,
/* Access the operations for a SPI device */
#define spi_get_ops(dev) ((struct dm_spi_ops *)(dev)->driver->ops)
#define spi_emul_get_ops(dev) ((struct dm_spi_emul_ops *)(dev)->driver->ops)
-#endif /* CONFIG_DM_SPI */
#endif /* _SPI_H_ */
diff --git a/include/video.h b/include/video.h
index e7c58e86cb..1a0ffd8037 100644
--- a/include/video.h
+++ b/include/video.h
@@ -19,10 +19,25 @@
struct udevice;
+/**
+ * struct video_uc_platdata - uclass platform data for a video device
+ *
+ * This holds information that the uclass needs to know about each device. It
+ * is accessed using dev_get_uclass_platdata(dev). See 'Theory of operation' at
+ * the top of video-uclass.c for details on how this information is set.
+ *
+ * @align: Frame-buffer alignment, indicating the memory boundary the frame
+ * buffer should start on. If 0, 1MB is assumed
+ * @size: Frame-buffer size, in bytes
+ * @base: Base address of frame buffer, 0 if not yet known
+ * @copy_base: Base address of a hardware copy of the frame buffer. See
+ * CONFIG_VIDEO_COPY.
+ */
struct video_uc_platdata {
uint align;
uint size;
ulong base;
+ ulong copy_base;
};
enum video_polarity {
@@ -63,6 +78,8 @@ enum video_log2_bpp {
* @font_size: Font size in pixels (0 to use a default value)
* @fb: Frame buffer
* @fb_size: Frame buffer size
+ * @copy_fb: Copy of the frame buffer to keep up to date; see struct
+ * video_uc_platdata
* @line_length: Length of each frame buffer line, in bytes. This can be
* set by the driver, but if not, the uclass will set it after
* probing
@@ -89,6 +106,7 @@ struct video_priv {
*/
void *fb;
int fb_size;
+ void *copy_fb;
int line_length;
u32 colour_fg;
u32 colour_bg;
@@ -202,6 +220,29 @@ void video_set_flush_dcache(struct udevice *dev, bool flush);
*/
void video_set_default_colors(struct udevice *dev, bool invert);
+#ifdef CONFIG_VIDEO_COPY
+/**
+ * vidconsole_sync_copy() - Sync back to the copy framebuffer
+ *
+ * This ensures that the copy framebuffer has the same data as the framebuffer
+ * for a particular region. It should be called after the framebuffer is updated
+ *
+ * @from and @to can be in either order. The region between them is synced.
+ *
+ * @dev: Vidconsole device being updated
+ * @from: Start/end address within the framebuffer (->fb)
+ * @to: Other address within the frame buffer
+ * @return 0 if OK, -EFAULT if the start address is before the start of the
+ * frame buffer start
+ */
+int video_sync_copy(struct udevice *dev, void *from, void *to);
+#else
+static inline int video_sync_copy(struct udevice *dev, void *from, void *to)
+{
+ return 0;
+}
+#endif
+
#endif /* CONFIG_DM_VIDEO */
#ifndef CONFIG_DM_VIDEO
diff --git a/include/video_console.h b/include/video_console.h
index 0936ceaaf1..06b798ef10 100644
--- a/include/video_console.h
+++ b/include/video_console.h
@@ -8,6 +8,8 @@
#include <video.h>
+struct video_priv;
+
#define VID_FRAC_DIV 256
#define VID_TO_PIXEL(x) ((x) / VID_FRAC_DIV)
@@ -241,8 +243,6 @@ int vidconsole_put_string(struct udevice *dev, const char *str);
void vidconsole_position_cursor(struct udevice *dev, unsigned col,
unsigned row);
-#ifdef CONFIG_DM_VIDEO
-
/**
* vid_console_color() - convert a color code to a pixel's internal
* representation
@@ -256,6 +256,53 @@ void vidconsole_position_cursor(struct udevice *dev, unsigned col,
*/
u32 vid_console_color(struct video_priv *priv, unsigned int idx);
+#ifdef CONFIG_VIDEO_COPY
+/**
+ * vidconsole_sync_copy() - Sync back to the copy framebuffer
+ *
+ * This ensures that the copy framebuffer has the same data as the framebuffer
+ * for a particular region. It should be called after the framebuffer is updated
+ *
+ * @from and @to can be in either order. The region between them is synced.
+ *
+ * @dev: Vidconsole device being updated
+ * @from: Start/end address within the framebuffer (->fb)
+ * @to: Other address within the frame buffer
+ * @return 0 if OK, -EFAULT if the start address is before the start of the
+ * frame buffer start
+ */
+int vidconsole_sync_copy(struct udevice *dev, void *from, void *to);
+
+/**
+ * vidconsole_memmove() - Perform a memmove() within the frame buffer
+ *
+ * This handles a memmove(), e.g. for scrolling. It also updates the copy
+ * framebuffer.
+ *
+ * @dev: Vidconsole device being updated
+ * @dst: Destination address within the framebuffer (->fb)
+ * @src: Source address within the framebuffer (->fb)
+ * @size: Number of bytes to transfer
+ * @return 0 if OK, -EFAULT if the start address is before the start of the
+ * frame buffer start
+ */
+int vidconsole_memmove(struct udevice *dev, void *dst, const void *src,
+ int size);
+#else
+static inline int vidconsole_sync_copy(struct udevice *dev, void *from,
+ void *to)
+{
+ return 0;
+}
+
+static inline int vidconsole_memmove(struct udevice *dev, void *dst,
+ const void *src, int size)
+{
+ memmove(dst, src, size);
+
+ return 0;
+}
+
#endif
#endif