From patchwork Tue Nov 15 11:17:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 82304 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1472055qge; Tue, 15 Nov 2016 03:19:04 -0800 (PST) X-Received: by 10.98.220.75 with SMTP id t72mr45712322pfg.164.1479208744606; Tue, 15 Nov 2016 03:19:04 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 73si26129659pfw.55.2016.11.15.03.19.04; Tue, 15 Nov 2016 03:19:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932579AbcKOLSq (ORCPT + 26 others); Tue, 15 Nov 2016 06:18:46 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:38099 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932346AbcKOLSm (ORCPT ); Tue, 15 Nov 2016 06:18:42 -0500 Received: by mail-wm0-f51.google.com with SMTP id f82so161957746wmf.1 for ; Tue, 15 Nov 2016 03:18:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xaT1jVsNH4RNrIMmNT5q92Yd5Ezdb4cI1mEeF07GA4U=; b=TkA4vKCN/nSQlc2OMz11ZF216LzWrRXt6xQZgUANbnj5EngQPZkvIKKOr2lG55Ut6E VT50O1W5xHlcr3nA8NDsj24bXSq6GGeB6Yur1J+bthHt9eZARZIQ62Sg51eR2jVf/OOJ U5kn/7MXi7BmUm9ll/PNp3UKMFNzKrVIlGFMo= 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=xaT1jVsNH4RNrIMmNT5q92Yd5Ezdb4cI1mEeF07GA4U=; b=WWqmJAV0fcZj11vvZtBjQLb7XAqahB7nNezZVgLQarUiQH+PQ72mcZS+S0o1p6ZHLY 85P4M4nOUOxbzQK90ANDYWgBFaobVr+VIEjNbHWrB+8gjOT7lS5hwnVgjMp7yThw644/ sIGlZPducnrg9zxjvqNFduZghTB0SF+Z71TqDnl8FCnvaeo8gcrqScmdE7WYKlQW7krf nYMp8alkTm9yXLYR214yxJpzByMK0ZBfjs8Cycs0ULG17sFw4BcWk3msDOLi5hQTPjI4 A9s7fQHqdlHnx+hrbZNjCWG8CFkeCur8QcZactGLyJwcVi+vXj9VgxZsvlSvuEmlPuWm BOlg== X-Gm-Message-State: ABUngvc7mMLtkEgRuB6T6LMVgkOlywfCINeIoroKtsrou7JgDSNBe3CcshErGqDezcUrq5Qx X-Received: by 10.28.184.23 with SMTP id i23mr3514980wmf.66.1479208715283; Tue, 15 Nov 2016 03:18:35 -0800 (PST) Received: from lmenx321.st.com. ([80.215.34.27]) by smtp.gmail.com with ESMTPSA id hy10sm34072002wjb.10.2016.11.15.03.18.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Nov 2016 03:18:34 -0800 (PST) From: Benjamin Gaignard To: labbott@redhat.com, sumit.semwal@linaro.org, gregkh@linuxfoundation.org, yudongbin@hisilicon.com, puck.chen@hisilicon.com, linux-kernel@vger.kernel.org Cc: linaro-kernel@lists.linaro.org, kernel@stlinux.com, Benjamin Gaignard Subject: [PATCH v2 2/3] add STIH4xx ION driver Date: Tue, 15 Nov 2016 12:17:28 +0100 Message-Id: <1479208649-23725-3-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1479208649-23725-1-git-send-email-benjamin.gaignard@linaro.org> References: <1479208649-23725-1-git-send-email-benjamin.gaignard@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 -- 1.9.1 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 + * + * 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 "../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);