From patchwork Mon Jan 11 21:39:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 8011821 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 508799FC5C for ; Mon, 11 Jan 2016 21:42:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 608F02022A for ; Mon, 11 Jan 2016 21:42:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6EA01201EC for ; Mon, 11 Jan 2016 21:42:13 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aIkCd-0004t9-J1; Mon, 11 Jan 2016 21:40:39 +0000 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aIkBx-0002qI-Bt for linux-arm-kernel@lists.infradead.org; Mon, 11 Jan 2016 21:39:59 +0000 Received: by mail-pf0-x22c.google.com with SMTP id q63so52191943pfb.1 for ; Mon, 11 Jan 2016 13:39:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=labbott.name; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Okd1ExAKUsTc8AteUSJsNaiAjGGv8RURQFZKvSu4Pb8=; b=Ag+4ZDSSyACFFYZjpSS0lrvGZMmqaSLUE7FYd15ewdpf5DYf3/S95oCvvKj5H+Zk0w IaBeXCWpy82K7r3X9x//pVFgKYP+iwucgLInagQg0Py3nSaZ1DRYO9MSkrLQlmcztVd2 TR9mlyEDpY+7b2yaKeWep0I8Er0UtM0C/ZRa4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Okd1ExAKUsTc8AteUSJsNaiAjGGv8RURQFZKvSu4Pb8=; b=jTkE/2EDy37yaFnOKI00GaOl2kP+5lUbS5gNW7fMOQbiSVf+vyvQI9IEfe7P0seze+ DvGdpGYzH9Klws37HzUrEngZZN8TBq0oSqnwFpIJJzW+RpFxG8Jt8smMO0QdGuAuMEBa eNlgXCmvmxTr7ys3KjBETj2LAlxwm/huGCXwAaHsMZTD4TlCVyQEgCPdPtOnwk2utQOT RO2OoJigFLP+XNFdvanZn5UjtP2Kv6UdgEpx30Dd5xjSSPWcIL6Lheg4D8gW3RNFAOdo 8cfNW6lhLo0qlhhRa/4JHJkJ7MhOV/vWeDezgB3btTugOQXiGV0Nmr5vjWDcl7Nbx2LI +B9Q== X-Gm-Message-State: ALoCoQnqXcpJ7uX5mwGNnhkvQS5zOCfhfV6PuiUan5mEjQ+RNNSCK2PkOsuomwl/UigCJtnzhp6YpC6SENR4KkkPQSaviv9JEg== X-Received: by 10.98.10.66 with SMTP id s63mr29684640pfi.119.1452548376476; Mon, 11 Jan 2016 13:39:36 -0800 (PST) Received: from localhost.net ([2601:602:8b00:aef6:da97:baff:fe80:3e00]) by smtp.gmail.com with ESMTPSA id fl9sm187847396pab.33.2016.01.11.13.39.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jan 2016 13:39:36 -0800 (PST) From: Laura Abbott To: Rob Herring , Frank Rowand , Sumit Semwal , Andrew Andrianov , , Riley Andrews Subject: [RESEND][PATCHv2 3/3] NOMERGE: Sample driver Date: Mon, 11 Jan 2016 13:39:24 -0800 Message-Id: <1452548364-9522-4-git-send-email-laura@labbott.name> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1452548364-9522-1-git-send-email-laura@labbott.name> References: <1452548364-9522-1-git-send-email-laura@labbott.name> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160111_133957_569057_00DAA3A6 X-CRM114-Status: GOOD ( 19.65 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, devicetree@vger.kernel.org, Feng Tang , Tom Gall , romlem@google.com, Greg Kroah-Hartman , Mark Rutland , linux-kernel@vger.kernel.org, Colin Cross , John Stultz , Grant Likely , Laura Abbott , mitchelh@codeaurora.org, linux-arm-kernel@lists.infradead.org, Marek Szyprowski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);