summaryrefslogtreecommitdiff
path: root/include/dm/device.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2014-07-23 06:55:20 -0600
committerSimon Glass <sjg@chromium.org>2014-07-23 14:08:37 +0100
commite59f458de6999b8a786da857e653db6777f675ca (patch)
tree0e57f9b83b6a484fce0543562c7c313e66b89c75 /include/dm/device.h
parent997c87bb0b1981fd33e34cefc26d9138f27326ce (diff)
downloadu-boot-imx-e59f458de6999b8a786da857e653db6777f675ca.zip
u-boot-imx-e59f458de6999b8a786da857e653db6777f675ca.tar.gz
u-boot-imx-e59f458de6999b8a786da857e653db6777f675ca.tar.bz2
dm: Introduce per-child data for devices
Some device types can have child devices and want to store information about them. For example a USB flash stick attached to a USB host controller would likely use this space. The controller can hold information about the USB state of each of its children. The data is stored attached to the child device in the 'parent_priv' member. It can be auto-allocated by dm when the child is probed. To do this, add a per_child_auto_alloc_size value to the parent driver. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/dm/device.h')
-rw-r--r--include/dm/device.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/dm/device.h b/include/dm/device.h
index 3f0f711..20207ce 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -51,6 +51,7 @@ struct driver_info;
* @priv: Private data for this device
* @uclass: Pointer to uclass for this device
* @uclass_priv: The uclass's private data for this device
+ * @parent_priv: The parent's private data for this device
* @uclass_node: Used by uclass to link its devices
* @child_head: List of children of this device
* @sibling_node: Next device in list of all devices
@@ -67,6 +68,7 @@ struct udevice {
void *priv;
struct uclass *uclass;
void *uclass_priv;
+ void *parent_priv;
struct list_head uclass_node;
struct list_head child_head;
struct list_head sibling_node;
@@ -124,6 +126,9 @@ struct udevice_id {
* This is typically only useful for device-tree-aware drivers (those with
* an of_match), since drivers which use platdata will have the data
* provided in the U_BOOT_DEVICE() instantiation.
+ * @per_child_auto_alloc_size: Each device can hold private data owned by
+ * its parent. If required this will be automatically allocated if this
+ * value is non-zero.
* @ops: Driver-specific operations. This is typically a list of function
* pointers defined by the driver, to implement driver functions required by
* the uclass.
@@ -140,6 +145,7 @@ struct driver {
int (*ofdata_to_platdata)(struct udevice *dev);
int priv_auto_alloc_size;
int platdata_auto_alloc_size;
+ int per_child_auto_alloc_size;
const void *ops; /* driver-specific operations */
uint32_t flags;
};
@@ -159,6 +165,20 @@ struct driver {
void *dev_get_platdata(struct udevice *dev);
/**
+ * dev_get_parentdata() - Get the parent data for a device
+ *
+ * The parent data is data stored in the device but owned by the parent.
+ * For example, a USB device may have parent data which contains information
+ * about how to talk to the device over USB.
+ *
+ * This checks that dev is not NULL, but no other checks for now
+ *
+ * @dev Device to check
+ * @return parent data, or NULL if none
+ */
+void *dev_get_parentdata(struct udevice *dev);
+
+/**
* dev_get_priv() - Get the private data for a device
*
* This checks that dev is not NULL, but no other checks for now