Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752929AbbKQA6C (ORCPT ); Mon, 16 Nov 2015 19:58:02 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:36800 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752211AbbKQA5q (ORCPT ); Mon, 16 Nov 2015 19:57:46 -0500 From: Laura Abbott To: Rob Herring , Frank Rowand , Sumit Semwal , Andrew Andrianov , , Riley Andrews Cc: Laura Abbott , John Stultz , Grant Likely , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Gall , Colin Cross , devel@driverdev.osuosl.org, Greg Kroah-Hartman , romlem@google.com, mitchelh@codeaurora.org, linux-arm-kernel@lists.infradead.org, Feng Tang , Marek Szyprowski Subject: [PATCHv2 3/3] NOMERGE: Sample driver Date: Mon, 16 Nov 2015 16:57:35 -0800 Message-Id: <1447721855-7574-4-git-send-email-laura@labbott.name> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1447721855-7574-1-git-send-email-laura@labbott.name> References: <1447721855-7574-1-git-send-email-laura@labbott.name> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4126 Lines: 147 Small sample driver to show what setup would look like with the dt bindings Signed-off-by: Laura Abbott --- 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 + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#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 linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/