summaryrefslogtreecommitdiffstats
path: root/drivers/core
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-03-25 12:21:53 -0600
committerSimon Glass <sjg@chromium.org>2015-04-18 11:11:19 -0600
commit2c03c4633b092d695d04bd38053da4d7dc59a9a5 (patch)
treea9cbb4c80fbb9a902056440555e009446a63906a /drivers/core
parente23eb614a415afa6bc2b3609b4f7a07c0f425744 (diff)
downloadtalos-obmc-uboot-2c03c4633b092d695d04bd38053da4d7dc59a9a5.tar.gz
talos-obmc-uboot-2c03c4633b092d695d04bd38053da4d7dc59a9a5.zip
dm: core: Support allocating driver-private data for DMA
Some driver want to put DMA buffers in their private data. Add a flag to tell driver model to align driver-private data to a cache boundary so that DMA will work correctly in this case. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Marek Vasut <marex@denx.de>
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/device.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 748340598a..1ca5d1c7bc 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -164,6 +164,21 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
-1, devp);
}
+static void *alloc_priv(int size, uint flags)
+{
+ void *priv;
+
+ if (flags & DM_FLAG_ALLOC_PRIV_DMA) {
+ priv = memalign(ARCH_DMA_MINALIGN, size);
+ if (priv)
+ memset(priv, '\0', size);
+ } else {
+ priv = calloc(1, size);
+ }
+
+ return priv;
+}
+
int device_probe_child(struct udevice *dev, void *parent_priv)
{
struct driver *drv;
@@ -182,7 +197,7 @@ int device_probe_child(struct udevice *dev, void *parent_priv)
/* Allocate private data if requested */
if (drv->priv_auto_alloc_size) {
- dev->priv = calloc(1, drv->priv_auto_alloc_size);
+ dev->priv = alloc_priv(drv->priv_auto_alloc_size, drv->flags);
if (!dev->priv) {
ret = -ENOMEM;
goto fail;
@@ -206,7 +221,7 @@ int device_probe_child(struct udevice *dev, void *parent_priv)
per_child_auto_alloc_size;
}
if (size) {
- dev->parent_priv = calloc(1, size);
+ dev->parent_priv = alloc_priv(size, drv->flags);
if (!dev->parent_priv) {
ret = -ENOMEM;
goto fail;
OpenPOWER on IntegriCloud