From: Laura Abbott <laura-0PSzFVTn/CLa5EbDDlwbIw@public.gmane.org>
To: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Frank Rowand
<frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Sumit Semwal
<sumit.semwal-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Andrew Andrianov <andrew-g16cbSVCqPUdnm+yROfE0A@public.gmane.org>,
arve-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org,
Riley Andrews <riandrews-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
Cc: Laura Abbott <laura-0PSzFVTn/CLa5EbDDlwbIw@public.gmane.org>,
John Stultz <john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Grant Likely
<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Tom Gall <tom.gall-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Colin Cross <ccross-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b@public.gmane.org,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
romlem-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
mitchelh-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Feng Tang <feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Marek Szyprowski
<m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
Subject: [RESEND][PATCHv2 3/3] NOMERGE: Sample driver
Date: Mon, 11 Jan 2016 13:39:24 -0800 [thread overview]
Message-ID: <1452548364-9522-4-git-send-email-laura@labbott.name> (raw)
In-Reply-To: <1452548364-9522-1-git-send-email-laura-0PSzFVTn/CLa5EbDDlwbIw@public.gmane.org>
Small sample driver to show what setup would look like with the dt
bindings
Signed-off-by: Laura Abbott <laura-0PSzFVTn/CLa5EbDDlwbIw@public.gmane.org>
---
drivers/staging/android/ion/Kconfig | 6 ++
drivers/staging/android/ion/Makefile | 1 +
drivers/staging/android/ion/ion_of_sample.c | 96 +++++++++++++++++++++++++++++
3 files changed, 103 insertions(+)
create mode 100644 drivers/staging/android/ion/ion_of_sample.c
diff --git a/drivers/staging/android/ion/Kconfig b/drivers/staging/android/ion/Kconfig
index 9b6d65d..c2afb35 100644
--- a/drivers/staging/android/ion/Kconfig
+++ b/drivers/staging/android/ion/Kconfig
@@ -43,3 +43,9 @@ config ION_OF
extensions
If using Ion and devicetree, you should say Y here
+
+config ION_OF_SAMPLE
+ bool "Sample driver"
+ depends on ION_OF
+ help
+ Small sample driver showing the Ion OF interface
diff --git a/drivers/staging/android/ion/Makefile b/drivers/staging/android/ion/Makefile
index a77417b..1309b91 100644
--- a/drivers/staging/android/ion/Makefile
+++ b/drivers/staging/android/ion/Makefile
@@ -8,4 +8,5 @@ endif
obj-$(CONFIG_ION_DUMMY) += ion_dummy_driver.o
obj-$(CONFIG_ION_TEGRA) += tegra/
obj-$(CONFIG_ION_OF) += ion_of.o ion_physmem.o
+obj-$(CONFIG_ION_OF_SAMPLE) += ion_of_sample.o
diff --git a/drivers/staging/android/ion/ion_of_sample.c b/drivers/staging/android/ion/ion_of_sample.c
new file mode 100644
index 0000000..bbcdf4d
--- /dev/null
+++ b/drivers/staging/android/ion/ion_of_sample.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2015 RC Module
+ * Andrew Andrianov <andrew-g16cbSVCqPUdnm+yROfE0A@public.gmane.org>
+ * Also based on work from Google, The Linux Foundation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/of_address.h>
+#include <linux/clk.h>
+#include <linux/dma-mapping.h>
+#include <linux/io.h>
+#include "ion.h"
+#include "ion_priv.h"
+#include "ion_of.h"
+
+struct sample_ion_dev {
+ struct ion_heap **heaps;
+ struct ion_device *idev;
+};
+
+static struct ion_of_heap heaps[] = {
+ PLATFORM_HEAP("sample-system", 0, ION_HEAP_TYPE_SYSTEM, "system"),
+ PLATFORM_HEAP("sample-camera", 1, ION_HEAP_TYPE_DMA, "camera"),
+ PLATFORM_HEAP("sample-fb", 2, ION_HEAP_TYPE_DMA, "fb"),
+ {}
+};
+
+static int ion_sample_probe(struct platform_device *pdev)
+{
+ struct ion_platform_data *data;
+ struct sample_ion_dev *ipdev;
+ int i;
+
+ ipdev = devm_kzalloc(&pdev->dev, sizeof(*ipdev), GFP_KERNEL);
+ if (!ipdev)
+ return -ENOMEM;
+
+ platform_set_drvdata(pdev, ipdev);
+
+ ipdev->idev = ion_device_create(NULL);
+ if (!ipdev->idev)
+ return -ENOMEM;
+
+ data = ion_parse_dt(pdev, heaps);
+ if (IS_ERR(data))
+ return PTR_ERR(data);
+
+ ipdev->heaps = devm_kzalloc(&pdev->dev,
+ sizeof(struct ion_heap)*data->nr, GFP_KERNEL);
+
+ if (!ipdev->heaps)
+ return -ENOMEM;
+
+ for (i = 0; i < data->nr; i++) {
+ ipdev->heaps[i] = ion_heap_create(&data->heaps[i]);
+ if (!ipdev->heaps[i])
+ return -ENOMEM;
+ ion_device_add_heap(ipdev->idev, ipdev->heaps[i]);
+ }
+ return 0;
+}
+
+static int ion_sample_remove(struct platform_device *pdev)
+{
+ /* Everything should be devm */
+ return 0;
+}
+
+static const struct of_device_id of_match_table[] = {
+ { .compatible = "sample-ion", },
+ { /* end of list */ }
+};
+
+static struct platform_driver ion_sample_driver = {
+ .probe = ion_sample_probe,
+ .remove = ion_sample_remove,
+ .driver = {
+ .name = "ion-of",
+ .of_match_table = of_match_ptr(of_match_table),
+ },
+};
+
+static int __init ion_sample_init(void)
+{
+ return platform_driver_register(&ion_sample_driver);
+}
+device_initcall(ion_sample_init);
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-01-11 21:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-11 21:39 [RESEND][PATCHv2 0/3] Devicetree bindings for Ion Laura Abbott
[not found] ` <1452548364-9522-1-git-send-email-laura-0PSzFVTn/CLa5EbDDlwbIw@public.gmane.org>
2016-01-11 21:39 ` [RESEND][PATCHv2 1/3] ion: " Laura Abbott
2016-01-11 23:28 ` Rob Herring
2016-01-12 0:26 ` Laura Abbott
2016-01-11 21:39 ` Laura Abbott [this message]
2016-01-11 21:39 ` [RESEND][PATCHv2 2/3] staging: ion: Add files for parsing the devicetree Laura Abbott
[not found] ` <1452548364-9522-3-git-send-email-laura-0PSzFVTn/CLa5EbDDlwbIw@public.gmane.org>
2016-01-11 23:24 ` kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1452548364-9522-4-git-send-email-laura@labbott.name \
--to=laura-0pszfvtn/cla5ebddlwbiw@public.gmane.org \
--cc=andrew-g16cbSVCqPUdnm+yROfE0A@public.gmane.org \
--cc=arve-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org \
--cc=ccross-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=devel-gWbeCf7V1WCQmaza687I9mD2FQJk+8+b@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=mitchelh-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=riandrews-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=romlem-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=sumit.semwal-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=tom.gall-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).