summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2023-04-19 08:59:06 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2023-04-19 08:59:06 +0200
commit8dd99807baf0b15b74e68e4e66d93bb0fe597621 (patch)
treeb67bf286ffceb440dd5634371d47e63d4f5ec969 /include
parentc46996d29b49b9d7fc33aa4ae59ea90596da068f (diff)
parent378c97f9138ab4ec2e1257b4cc70072b459a5361 (diff)
downloadbarebox-8dd99807baf0b15b74e68e4e66d93bb0fe597621.tar.gz
Merge branch 'for-next/misc'
Diffstat (limited to 'include')
-rw-r--r--include/asm-generic/pointer.h30
-rw-r--r--include/clock.h3
-rw-r--r--include/driver.h12
-rw-r--r--include/dsa.h1
-rw-r--r--include/fb.h11
-rw-r--r--include/firmware.h16
-rw-r--r--include/image-metadata.h10
-rw-r--r--include/linux/remoteproc.h5
-rw-r--r--include/of.h30
-rw-r--r--include/spi/spi.h34
-rw-r--r--include/video/mipi_dbi.h69
11 files changed, 206 insertions, 15 deletions
diff --git a/include/asm-generic/pointer.h b/include/asm-generic/pointer.h
new file mode 100644
index 0000000000..8b9600b029
--- /dev/null
+++ b/include/asm-generic/pointer.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ASM_GENERIC_PTR_H___
+#define __ASM_GENERIC_PTR_H___
+
+#if __SIZEOF_POINTER__ == 8
+#ifdef __ASSEMBLY__
+#define ASM_PTR .quad
+#define ASM_SZPTR 8
+#define ASM_LGPTR 3
+#else
+#define ASM_PTR ".quad"
+#define ASM_SZPTR "8"
+#define ASM_LGPTR "3"
+#endif
+#elif __SIZEOF_POINTER__ == 4
+#ifdef __ASSEMBLY__
+#define ASM_PTR .word
+#define ASM_SZPTR 4
+#define ASM_LGPTR 2
+#else
+#define ASM_PTR ".word"
+#define ASM_SZPTR "4"
+#define ASM_LGPTR "2"
+#endif
+#else
+#error "Unexpected __SIZEOF_POINTER__"
+#endif
+
+#endif /* __ASM_GENERIC_PTR_H___ */
diff --git a/include/clock.h b/include/clock.h
index 8e07c35d37..03a38911a7 100644
--- a/include/clock.h
+++ b/include/clock.h
@@ -4,8 +4,9 @@
#include <types.h>
#include <linux/time.h>
+#include <linux/bitops.h>
-#define CLOCKSOURCE_MASK(bits) (uint64_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1)
+#define CLOCKSOURCE_MASK(bits) GENMASK_ULL((bits) - 1, 0)
struct clocksource {
uint32_t shift;
diff --git a/include/driver.h b/include/driver.h
index 2cf0190699..68e4bf559e 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -275,13 +275,21 @@ int device_add_resource(struct device *dev, const char *resname,
int device_add_data(struct device *dev, const void *data, size_t size);
+struct device *add_child_device(struct device *parent,
+ const char* devname, int id, const char *resname,
+ resource_size_t start, resource_size_t size, unsigned int flags,
+ void *pdata);
+
/*
* register a generic device
* with only one resource
*/
-struct device *add_generic_device(const char* devname, int id, const char *resname,
+static inline struct device *add_generic_device(const char* devname, int id, const char *resname,
resource_size_t start, resource_size_t size, unsigned int flags,
- void *pdata);
+ void *pdata)
+{
+ return add_child_device(NULL, devname, id, resname, start, size, flags, pdata);
+}
/*
* register a generic device
diff --git a/include/dsa.h b/include/dsa.h
index e823bac0a7..527941c269 100644
--- a/include/dsa.h
+++ b/include/dsa.h
@@ -55,6 +55,7 @@ struct dsa_switch_ops {
int (*phy_read)(struct dsa_switch *ds, int port, int regnum);
int (*phy_write)(struct dsa_switch *ds, int port, int regnum, u16 val);
+ void (*adjust_link)(struct eth_device *dev);
};
struct dsa_port {
diff --git a/include/fb.h b/include/fb.h
index bf5f688342..88e6c0e458 100644
--- a/include/fb.h
+++ b/include/fb.h
@@ -80,6 +80,13 @@ struct fb_bitfield {
struct fb_info;
+struct fb_rect {
+ u32 x1;
+ u32 y1;
+ u32 x2;
+ u32 y2;
+};
+
struct fb_ops {
/* set color register */
int (*fb_setcolreg)(unsigned regno, unsigned red, unsigned green,
@@ -87,6 +94,7 @@ struct fb_ops {
void (*fb_enable)(struct fb_info *info);
void (*fb_disable)(struct fb_info *info);
int (*fb_activate_var)(struct fb_info *info);
+ void (*fb_damage)(struct fb_info *info, const struct fb_rect *rect);
void (*fb_flush)(struct fb_info *info);
};
@@ -147,6 +155,8 @@ struct fb_info {
int shadowfb;
};
+int of_get_display_timing(const struct device_node *np, const char *name,
+ struct fb_videomode *mode);
struct display_timings *of_get_display_timings(struct device_node *np);
void display_timings_release(struct display_timings *);
@@ -154,6 +164,7 @@ int register_framebuffer(struct fb_info *info);
int fb_enable(struct fb_info *info);
int fb_disable(struct fb_info *info);
+void fb_damage(struct fb_info *info, struct fb_rect *rect);
void fb_flush(struct fb_info *info);
#define FBIOGET_SCREENINFO _IOR('F', 1, loff_t)
diff --git a/include/firmware.h b/include/firmware.h
index 05433f2f78..93c800e11b 100644
--- a/include/firmware.h
+++ b/include/firmware.h
@@ -13,6 +13,11 @@
#include <debug_ll.h>
#include <linux/kernel.h>
+struct firmware {
+ size_t size;
+ const u8 *data;
+};
+
struct firmware_handler {
char *id; /* unique identifier for this firmware device */
char *model; /* description for this device */
@@ -37,6 +42,8 @@ struct firmware_mgr *firmwaremgr_find_by_node(struct device_node *np);
int firmwaremgr_load_file(struct firmware_mgr *, const char *path);
char *firmware_get_searchpath(void);
void firmware_set_searchpath(const char *path);
+int request_firmware(const struct firmware **fw, const char *fw_name, struct device *dev);
+void release_firmware(const struct firmware *fw);
#else
static inline struct firmware_mgr *firmwaremgr_find_by_node(struct device_node *np)
{
@@ -57,6 +64,15 @@ static inline void firmware_set_searchpath(const char *path)
{
}
+static inline int request_firmware(const struct firmware **fw, const char *fw_name,
+ struct device *dev)
+{
+ return -EINVAL;
+}
+
+static inline void release_firmware(const struct firmware *fw)
+{
+}
#endif
void firmwaremgr_list_handlers(void);
diff --git a/include/image-metadata.h b/include/image-metadata.h
index bf4e08d98a..615632f9ce 100644
--- a/include/image-metadata.h
+++ b/include/image-metadata.h
@@ -156,10 +156,12 @@ static inline void imd_used(const void *unused)
#define IMD_USED(_name) \
imd_used(&__barebox_imd_##_name)
-#define IMD_USED_OF(_name) ({ \
- extern char __barebox_imd_OF_ ## _name[]; \
- imd_used(&__barebox_imd_OF_ ## _name); \
- })
+
+__attribute__((deprecated("IMD entries are now always referenced if DT itself is")))
+static inline void IMD_USED_OF(void)
+{}
+
+#define IMD_USED_OF(_name) IMD_USED_OF()
#endif /* __BAREBOX__ */
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index 170fff7987..33fe2f81b7 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -18,11 +18,6 @@ struct resource_table {
u32 offset[0];
} __packed;
-struct firmware {
- size_t size;
- const u8 *data;
-};
-
struct rproc;
struct rproc_ops {
diff --git a/include/of.h b/include/of.h
index 3fb6ecec8d..4b0266fd31 100644
--- a/include/of.h
+++ b/include/of.h
@@ -152,6 +152,9 @@ extern struct property *__of_new_property(struct device_node *node,
extern void of_delete_property(struct property *pp);
extern struct property *of_rename_property(struct device_node *np,
const char *old_name, const char *new_name);
+extern struct property *of_copy_property(const struct device_node *src,
+ const char *propname,
+ struct device_node *dst);
extern struct device_node *of_find_node_by_name(struct device_node *from,
const char *name);
@@ -576,6 +579,13 @@ static inline struct property *__of_new_property(struct device_node *node,
return NULL;
}
+static inline struct property *of_copy_property(const struct device_node *src,
+ const char *propname,
+ struct device_node *dst)
+{
+ return NULL;
+}
+
static inline void of_delete_property(struct property *pp)
{
}
@@ -1038,8 +1048,10 @@ static inline int of_property_read_string_index(const struct device_node *np,
* @np: device node from which the property value is to be read.
* @propname: name of the property to be searched.
*
- * Search for a property in a device node.
- * Returns true if the property exist false otherwise.
+ * Search for a boolean property in a device node. Usage on non-boolean
+ * property types is deprecated.
+
+ * Return: true if the property exist false otherwise.
*/
static inline bool of_property_read_bool(const struct device_node *np,
const char *propname)
@@ -1049,6 +1061,20 @@ static inline bool of_property_read_bool(const struct device_node *np,
return prop ? true : false;
}
+/**
+ * of_property_present - Test if a property is present in a node
+ * @np: device node to search for the property.
+ * @propname: name of the property to be searched.
+ *
+ * Test for a property present in a device node.
+ *
+ * Return: true if the property exists false otherwise.
+ */
+static inline bool of_property_present(const struct device_node *np, const char *propname)
+{
+ return of_property_read_bool(np, propname);
+}
+
static inline int of_property_read_u8(const struct device_node *np,
const char *propname,
u8 *out_value)
diff --git a/include/spi/spi.h b/include/spi/spi.h
index fa9329b08c..f806c7a30b 100644
--- a/include/spi/spi.h
+++ b/include/spi/spi.h
@@ -6,6 +6,7 @@
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/string.h>
+#include <linux/bitops.h>
struct spi_controller_mem_ops;
@@ -44,7 +45,7 @@ struct spi_board_info {
* This may be changed by the device's driver, or left at the
* default (0) indicating protocol words are eight bit bytes.
* The spi_transfer.bits_per_word can override this for each transfer
- * (FIXME: not currently implemented).
+ * (FIXME: not currently implemented by most drivers).
* @irq: Negative, or the number passed to request_irq() to receive
* interrupts from this device.
* @controller_state: Controller's runtime state
@@ -131,6 +132,11 @@ struct spi_message;
* SPI slaves, and are numbered from zero to num_chipselects.
* each slave has a chipselect signal, but it's common that not
* every chipselect is connected to a slave.
+ * @bits_per_word_mask: A mask indicating which values of bits_per_word are
+ * supported by the driver. Bit n indicates that a bits_per_word n+1 is
+ * supported. If set, the SPI core will reject any transfer with an
+ * unsupported bits_per_word. If not set, this value is simply ignored,
+ * and it's up to the individual driver to perform any validation.
* @max_speed_hz: Highest supported transfer speed
* @setup: updates the device mode and clocking records used by a
* device's SPI controller; protocol code may call this. This
@@ -165,6 +171,12 @@ struct spi_controller {
/* Optimized handlers for SPI memory-like operations */
const struct spi_controller_mem_ops *mem_ops;
+
+ /* Bitmask of supported bits_per_word for transfers */
+ u32 bits_per_word_mask;
+#define SPI_BPW_MASK(bits) BIT((bits) - 1)
+#define SPI_BPW_RANGE_MASK(min, max) GENMASK((max) - 1, (min) - 1)
+
/*
* on some hardware transfer size may be constrained
* the limit may depend on device transfer settings
@@ -435,6 +447,26 @@ spi_transfer_del(struct spi_transfer *t)
list_del(&t->transfer_list);
}
+/**
+ * spi_is_bpw_supported - Check if bits per word is supported
+ * @spi: SPI device
+ * @bpw: Bits per word
+ *
+ * This function checks to see if the SPI controller supports @bpw.
+ *
+ * Returns:
+ * True if @bpw is supported, false otherwise.
+ */
+static inline bool spi_is_bpw_supported(struct spi_device *spi, u32 bpw)
+{
+ u32 bpw_mask = spi->master->bits_per_word_mask;
+
+ if (bpw == 8 || (bpw <= 32 && bpw_mask & SPI_BPW_MASK(bpw)))
+ return true;
+
+ return false;
+}
+
/* All these synchronous SPI transfer routines are utilities layered
* over the core async transfer primitive. Here, "synchronous" means
* they will sleep uninterruptibly until the async transfer completes.
diff --git a/include/video/mipi_dbi.h b/include/video/mipi_dbi.h
index 5452600693..a15264c833 100644
--- a/include/video/mipi_dbi.h
+++ b/include/video/mipi_dbi.h
@@ -11,6 +11,7 @@
#include <linux/types.h>
#include <spi/spi.h>
#include <driver.h>
+#include <fb.h>
struct regulator;
struct fb_videomode;
@@ -55,6 +56,66 @@ struct mipi_dbi {
struct list_head list;
};
+/**
+ * struct mipi_dbi_dev - MIPI DBI device
+ */
+struct mipi_dbi_dev {
+ /**
+ * @dev: Device
+ */
+ struct device *dev;
+
+ /**
+ * @info: Framebuffer info
+ */
+ struct fb_info info;
+
+ /**
+ * @mode: Fixed display mode
+ */
+ struct fb_videomode mode;
+
+ /**
+ * @tx_buf: Buffer used for transfer (copy clip rect area)
+ */
+ u8 *tx_buf;
+
+ /**
+ * @backlight_node: backlight device node (optional)
+ */
+ struct device_node *backlight_node;
+
+ /**
+ * @backlight: backlight device (optional)
+ */
+ struct backlight_device *backlight;
+
+ /**
+ * @regulator: power regulator (Vdd) (optional)
+ */
+ struct regulator *regulator;
+
+ /**
+ * @io_regulator: I/O power regulator (Vddi) (optional)
+ */
+ struct regulator *io_regulator;
+
+ /**
+ * @dbi: MIPI DBI interface
+ */
+ struct mipi_dbi dbi;
+
+ /**
+ * @driver_private: Driver private data.
+ */
+ void *driver_private;
+
+ /**
+ * @damage: Damage rectangle.
+ */
+ struct fb_rect damage;
+};
+
static inline const char *mipi_dbi_name(struct mipi_dbi *dbi)
{
return dev_name(&dbi->spi->dev);
@@ -62,8 +123,16 @@ static inline const char *mipi_dbi_name(struct mipi_dbi *dbi)
int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *dbi,
int dc);
+int mipi_dbi_dev_init(struct mipi_dbi_dev *dbidev,
+ struct fb_ops *ops, struct fb_videomode *mode);
+void mipi_dbi_fb_damage(struct fb_info *info, const struct fb_rect *rect);
+void mipi_dbi_fb_flush(struct fb_info *info);
+void mipi_dbi_enable_flush(struct mipi_dbi_dev *dbidev,
+ struct fb_info *info);
+void mipi_dbi_fb_disable(struct fb_info *info);
void mipi_dbi_hw_reset(struct mipi_dbi *dbi);
bool mipi_dbi_display_is_on(struct mipi_dbi *dbi);
+int mipi_dbi_poweron_conditional_reset(struct mipi_dbi_dev *dbidev);
u32 mipi_dbi_spi_cmd_max_speed(struct spi_device *spi, size_t len);
int mipi_dbi_spi_transfer(struct spi_device *spi, u32 speed_hz,