@@ -99,6 +99,26 @@ int sysinfo_get_str(struct udevice *dev, int id, size_t size, char *val)
return ops->get_str(dev, id, size, val);
}
+int sysinfo_get_data(struct udevice *dev, int id, void **data, size_t *size)
+{
+ struct sysinfo_priv *priv;
+ struct sysinfo_ops *ops;
+
+ if (!dev)
+ return -ENOSYS;
+
+ priv = dev_get_uclass_priv(dev);
+ ops = sysinfo_get_ops(dev);
+
+ if (!priv->detected)
+ return -EPERM;
+
+ if (!ops->get_data)
+ return -ENOSYS;
+
+ return ops->get_data(dev, id, data, size);
+}
+
UCLASS_DRIVER(sysinfo) = {
.id = UCLASS_SYSINFO,
.name = "sysinfo",
@@ -115,6 +115,18 @@ struct sysinfo_ops {
*/
int (*get_str)(struct udevice *dev, int id, size_t size, char *val);
+ /**
+ * get_data() - Read a specific string data value that describes the
+ * hardware setup.
+ * @dev: The sysinfo instance to gather the data.
+ * @id: A unique identifier for the data area to be get.
+ * @data: Pointer to the address of the data area.
+ * @size: Pointer to the size of the data area.
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+ int (*get_data)(struct udevice *dev, int id, void **data, size_t *size);
+
/**
* get_fit_loadable - Get the name of an image to load from FIT
* This function can be used to provide the image names based on runtime
@@ -186,6 +198,18 @@ int sysinfo_get_int(struct udevice *dev, int id, int *val);
*/
int sysinfo_get_str(struct udevice *dev, int id, size_t size, char *val);
+/**
+ * sysinfo_get_data() - Get a data area from the platform.
+ * @dev: The sysinfo instance to gather the data.
+ * @id: A unique identifier for the data area to be get.
+ * @data: Pointer to the address of the data area.
+ * @size: Pointer to the size of the data area.
+ *
+ * Return: 0 if OK, -EPERM if called before sysinfo_detect(), else -ve on
+ * error.
+ */
+int sysinfo_get_data(struct udevice *dev, int id, void **data, size_t *size);
+
/**
* sysinfo_get() - Return the sysinfo device for the sysinfo in question.
* @devp: Pointer to structure to receive the sysinfo device.
@@ -241,6 +265,12 @@ static inline int sysinfo_get_str(struct udevice *dev, int id, size_t size,
return -ENOSYS;
}
+static inline int sysinfo_get_data(struct udevice *dev, int id, void **data,
+ size_t *size)
+{
+ return -ENOSYS;
+}
+
static inline int sysinfo_get(struct udevice **devp)
{
return -ENOSYS;
Add interface for sysinfo to access a data area from the platform. This is useful to save/read a memory region of platform-specific data. Signed-off-by: Raymond Mao <raymond.mao@linaro.org> --- Changes in v2 - None. Changes in v3 - Use void pointer to avoid casting. drivers/sysinfo/sysinfo-uclass.c | 20 ++++++++++++++++++++ include/sysinfo.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+)