linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] add ION driver for STIh4xx SoC
@ 2016-11-15 11:17 Benjamin Gaignard
  2016-11-15 11:17 ` [PATCH v2 1/3] add binding for STIh4xx ION driver Benjamin Gaignard
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Benjamin Gaignard @ 2016-11-15 11:17 UTC (permalink / raw)
  To: labbott, sumit.semwal, gregkh, yudongbin, puck.chen, linux-kernel
  Cc: linaro-kernel, kernel, Benjamin Gaignard

version 2:
- rebased on kernel 4.9-rc5
- change heap bindings to use definitions of drivers/staging/android/ion/devicetree.txt

version 1:
- initial patch

It is more or less a copy of Hisilicon driver but with a heap definition
fitting with STIH4xx SoC needs.
I have just chnage the some function prefix from "hi6220" to "sti".


Benjamin Gaignard (3):
  add binding for STIh4xx ION driver
  add STIH4xx ION driver
  add STIH4xx ION driver in DT

 .../devicetree/bindings/staging/ion/st,sti-ion.txt |  17 ++++
 arch/arm/boot/dts/stih407-family.dtsi              |   8 ++
 drivers/staging/android/ion/Kconfig                |   7 ++
 drivers/staging/android/ion/Makefile               |   2 +
 drivers/staging/android/ion/sti/Makefile           |   1 +
 drivers/staging/android/ion/sti/sti_ion.c          | 103 +++++++++++++++++++++
 6 files changed, 138 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/staging/ion/st,sti-ion.txt
 create mode 100644 drivers/staging/android/ion/sti/Makefile
 create mode 100644 drivers/staging/android/ion/sti/sti_ion.c

-- 
1.9.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/3] add binding for STIh4xx ION driver
  2016-11-15 11:17 [PATCH v2 0/3] add ION driver for STIh4xx SoC Benjamin Gaignard
@ 2016-11-15 11:17 ` Benjamin Gaignard
  2016-11-15 11:17 ` [PATCH v2 2/3] add STIH4xx " Benjamin Gaignard
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Benjamin Gaignard @ 2016-11-15 11:17 UTC (permalink / raw)
  To: labbott, sumit.semwal, gregkh, yudongbin, puck.chen, linux-kernel
  Cc: linaro-kernel, kernel, Benjamin Gaignard

Describe bindings for STIH4xx ION driver.
They are limited to have is used by ion_of.c

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
---
 .../devicetree/bindings/staging/ion/st,sti-ion.txt      | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/staging/ion/st,sti-ion.txt

diff --git a/Documentation/devicetree/bindings/staging/ion/st,sti-ion.txt b/Documentation/devicetree/bindings/staging/ion/st,sti-ion.txt
new file mode 100644
index 0000000..ec6dd9d
--- /dev/null
+++ b/Documentation/devicetree/bindings/staging/ion/st,sti-ion.txt
@@ -0,0 +1,17 @@
+STIH4xxSoC ION
+
+Required properties:
+- compatible: "st,sti-ion", "linux,ion"
+- list of ION heaps:
+	- compatible: "st,cma-heap", "linux,ion-heap-dma"
+
+heap bindings are defined in drivers/staging/android/ion/devicetree.txt
+
+Example:
+	ion {
+		compatible = "st,sti-ion", "linux,ion";
+
+		ion-cma-heap {
+			compatible = "st,cma-heap", "linux,ion-heap-dma";
+		};
+	};
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/3] add STIH4xx ION driver
  2016-11-15 11:17 [PATCH v2 0/3] add ION driver for STIh4xx SoC Benjamin Gaignard
  2016-11-15 11:17 ` [PATCH v2 1/3] add binding for STIh4xx ION driver Benjamin Gaignard
@ 2016-11-15 11:17 ` Benjamin Gaignard
  2016-11-15 11:17 ` [PATCH v2 3/3] add STIH4xx ION driver in DT Benjamin Gaignard
  2016-11-15 23:45 ` [PATCH v2 0/3] add ION driver for STIh4xx SoC Laura Abbott
  3 siblings, 0 replies; 5+ messages in thread
From: Benjamin Gaignard @ 2016-11-15 11:17 UTC (permalink / raw)
  To: labbott, sumit.semwal, gregkh, yudongbin, puck.chen, linux-kernel
  Cc: linaro-kernel, kernel, Benjamin Gaignard

This the same driver that Hisilicon one.
Change the list of heap to fit with sti SoC needs.
Rename/prefix some functions and structure with sti

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
---
 drivers/staging/android/ion/Kconfig       |   7 ++
 drivers/staging/android/ion/Makefile      |   2 +
 drivers/staging/android/ion/sti/Makefile  |   1 +
 drivers/staging/android/ion/sti/sti_ion.c | 103 ++++++++++++++++++++++++++++++
 4 files changed, 113 insertions(+)
 create mode 100644 drivers/staging/android/ion/sti/Makefile
 create mode 100644 drivers/staging/android/ion/sti/sti_ion.c

diff --git a/drivers/staging/android/ion/Kconfig b/drivers/staging/android/ion/Kconfig
index c8fb413..eb47230 100644
--- a/drivers/staging/android/ion/Kconfig
+++ b/drivers/staging/android/ion/Kconfig
@@ -42,6 +42,13 @@ config ION_HISI
 
 source "drivers/staging/android/ion/hisilicon/Kconfig"
 
+config ION_STI
+        bool "stih4xx ION Driver"
+        depends on ARCH_STI && ION
+	select ION_OF
+        help
+          Choose this option if you wish to use ion on STIH4xx SoC.
+
 config ION_OF
 	bool "Devicetree support for Ion"
 	depends on ION && OF_ADDRESS
diff --git a/drivers/staging/android/ion/Makefile b/drivers/staging/android/ion/Makefile
index 5d630a0..bc02ea4 100644
--- a/drivers/staging/android/ion/Makefile
+++ b/drivers/staging/android/ion/Makefile
@@ -9,5 +9,7 @@ endif
 obj-$(CONFIG_ION_DUMMY) += ion_dummy_driver.o
 obj-$(CONFIG_ION_TEGRA) += tegra/
 obj-$(CONFIG_ION_HISI) += hisilicon/
+obj-$(CONFIG_ION_STI) += sti/
+
 obj-$(CONFIG_ION_OF) += ion_of.o
 
diff --git a/drivers/staging/android/ion/sti/Makefile b/drivers/staging/android/ion/sti/Makefile
new file mode 100644
index 0000000..5690431
--- /dev/null
+++ b/drivers/staging/android/ion/sti/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_ION_STI) += sti_ion.o
diff --git a/drivers/staging/android/ion/sti/sti_ion.c b/drivers/staging/android/ion/sti/sti_ion.c
new file mode 100644
index 0000000..0db9f3e
--- /dev/null
+++ b/drivers/staging/android/ion/sti/sti_ion.c
@@ -0,0 +1,103 @@
+/*
+ * STIH4xx ION Driver
+ *
+ * Copyright (c) 2016 STMicroelectronics
+ *
+ * Author: Benjamin Gaignard <benjamin.gaignard@st.com>
+ *
+ * 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/err.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#include "../ion_priv.h"
+#include "../ion.h"
+#include "../ion_of.h"
+
+struct sti_ion_dev {
+	struct ion_heap	**heaps;
+	struct ion_device *idev;
+	struct ion_platform_data *data;
+};
+
+static struct ion_of_heap sti_heaps[] = {
+	PLATFORM_HEAP("linux,ion-heap-dma", 0, ION_HEAP_TYPE_DMA, "cma"),
+	{}
+};
+
+static int sti_ion_probe(struct platform_device *pdev)
+{
+	struct sti_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 (IS_ERR(ipdev->idev))
+		return PTR_ERR(ipdev->idev);
+
+	ipdev->data = ion_parse_dt(pdev, sti_heaps);
+	if (IS_ERR(ipdev->data))
+		return PTR_ERR(ipdev->data);
+
+	ipdev->heaps = devm_kzalloc(&pdev->dev,
+				sizeof(struct ion_heap) * ipdev->data->nr,
+				GFP_KERNEL);
+	if (!ipdev->heaps) {
+		ion_destroy_platform_data(ipdev->data);
+		return -ENOMEM;
+	}
+
+	for (i = 0; i < ipdev->data->nr; i++) {
+		ipdev->heaps[i] = ion_heap_create(&ipdev->data->heaps[i]);
+		if (!ipdev->heaps) {
+			ion_destroy_platform_data(ipdev->data);
+			return -ENOMEM;
+		}
+		ion_device_add_heap(ipdev->idev, ipdev->heaps[i]);
+	}
+	return 0;
+}
+
+static int sti_ion_remove(struct platform_device *pdev)
+{
+	struct sti_ion_dev *ipdev;
+	int i;
+
+	ipdev = platform_get_drvdata(pdev);
+
+	for (i = 0; i < ipdev->data->nr; i++)
+		ion_heap_destroy(ipdev->heaps[i]);
+
+	ion_destroy_platform_data(ipdev->data);
+	ion_device_destroy(ipdev->idev);
+
+	return 0;
+}
+
+static const struct of_device_id sti_ion_match_table[] = {
+	{.compatible = "st,sti-ion"},
+	{},
+};
+
+static struct platform_driver sti_ion_driver = {
+	.probe = sti_ion_probe,
+	.remove = sti_ion_remove,
+	.driver = {
+		.name = "ion-sti",
+		.of_match_table = sti_ion_match_table,
+	},
+};
+
+module_platform_driver(sti_ion_driver);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 3/3] add STIH4xx ION driver in DT
  2016-11-15 11:17 [PATCH v2 0/3] add ION driver for STIh4xx SoC Benjamin Gaignard
  2016-11-15 11:17 ` [PATCH v2 1/3] add binding for STIh4xx ION driver Benjamin Gaignard
  2016-11-15 11:17 ` [PATCH v2 2/3] add STIH4xx " Benjamin Gaignard
@ 2016-11-15 11:17 ` Benjamin Gaignard
  2016-11-15 23:45 ` [PATCH v2 0/3] add ION driver for STIh4xx SoC Laura Abbott
  3 siblings, 0 replies; 5+ messages in thread
From: Benjamin Gaignard @ 2016-11-15 11:17 UTC (permalink / raw)
  To: labbott, sumit.semwal, gregkh, yudongbin, puck.chen, linux-kernel
  Cc: linaro-kernel, kernel, Benjamin Gaignard

Very simple and limited to one heap for contiguous memory allocation

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
---
 arch/arm/boot/dts/stih407-family.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/stih407-family.dtsi b/arch/arm/boot/dts/stih407-family.dtsi
index 91096a4..3654f8f 100644
--- a/arch/arm/boot/dts/stih407-family.dtsi
+++ b/arch/arm/boot/dts/stih407-family.dtsi
@@ -1007,4 +1007,12 @@
 			status = "disabled";
 		};
 	};
+
+	ion {
+		compatible = "st,sti-ion", "linux,ion";
+
+		ion-cma-heap {
+			compatible = "st,cma-heap", "linux,ion-heap-dma";
+		};
+	};
 };
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/3] add ION driver for STIh4xx SoC
  2016-11-15 11:17 [PATCH v2 0/3] add ION driver for STIh4xx SoC Benjamin Gaignard
                   ` (2 preceding siblings ...)
  2016-11-15 11:17 ` [PATCH v2 3/3] add STIH4xx ION driver in DT Benjamin Gaignard
@ 2016-11-15 23:45 ` Laura Abbott
  3 siblings, 0 replies; 5+ messages in thread
From: Laura Abbott @ 2016-11-15 23:45 UTC (permalink / raw)
  To: Benjamin Gaignard, sumit.semwal, gregkh, yudongbin, puck.chen,
	linux-kernel
  Cc: linaro-kernel, kernel

On 11/15/2016 03:17 AM, Benjamin Gaignard wrote:
> version 2:
> - rebased on kernel 4.9-rc5
> - change heap bindings to use definitions of drivers/staging/android/ion/devicetree.txt
> 
> version 1:
> - initial patch
> 
> It is more or less a copy of Hisilicon driver but with a heap definition
> fitting with STIH4xx SoC needs.
> I have just chnage the some function prefix from "hi6220" to "sti".
> 
> 
> Benjamin Gaignard (3):
>   add binding for STIh4xx ION driver
>   add STIH4xx ION driver
>   add STIH4xx ION driver in DT
> 
>  .../devicetree/bindings/staging/ion/st,sti-ion.txt |  17 ++++
>  arch/arm/boot/dts/stih407-family.dtsi              |   8 ++
>  drivers/staging/android/ion/Kconfig                |   7 ++
>  drivers/staging/android/ion/Makefile               |   2 +
>  drivers/staging/android/ion/sti/Makefile           |   1 +
>  drivers/staging/android/ion/sti/sti_ion.c          | 103 +++++++++++++++++++++
>  6 files changed, 138 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/staging/ion/st,sti-ion.txt
>  create mode 100644 drivers/staging/android/ion/sti/Makefile
>  create mode 100644 drivers/staging/android/ion/sti/sti_ion.c
> 

The DT maintainers still don't like these bindings so we should
not add any more platform support based on the ion/devicetree.txt
options.

Thanks,
Laura

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-11-15 23:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-15 11:17 [PATCH v2 0/3] add ION driver for STIh4xx SoC Benjamin Gaignard
2016-11-15 11:17 ` [PATCH v2 1/3] add binding for STIh4xx ION driver Benjamin Gaignard
2016-11-15 11:17 ` [PATCH v2 2/3] add STIH4xx " Benjamin Gaignard
2016-11-15 11:17 ` [PATCH v2 3/3] add STIH4xx ION driver in DT Benjamin Gaignard
2016-11-15 23:45 ` [PATCH v2 0/3] add ION driver for STIh4xx SoC Laura Abbott

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).