From patchwork Thu May 4 20:05:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 98566 Delivered-To: patch@linaro.org Received: by 10.140.89.200 with SMTP id v66csp788072qgd; Thu, 4 May 2017 13:06:23 -0700 (PDT) X-Received: by 10.99.123.77 with SMTP id k13mr19102519pgn.32.1493928383686; Thu, 04 May 2017 13:06:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1493928383; cv=none; d=google.com; s=arc-20160816; b=FmENdIqP1/5kTD9LQfN5NpiCfy7IzHY6VL6pocs8bR5dFfhhniihL1xgXkDURK8tqv Mlcu58Rcs683FEGGJP2pgRBLKB27b+aY7gIz2bLPRe7QrNMEeAK9s5/y7aMAIgW/oTdk P0Hf9pgGQA7/JHK+0hOX+28d5MnF5XbhHFLuzwvu7rE4FnbNru6JPk9OZyWnIf8R/vzy CKqfy7lIhvkkXnEvD0VZnxXx9UAzFBeolKeQvQXVuA6kAN5m1tVnB+qOx+ZBZRHnb/Wd kbVMFj8bq+Ay/7JuUjGxJbqq2NYmeNCTF01tBRuorfAwN4jRnNkYaAXz4oYIZu8Y581Q gB8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=U87A0kQ0fzxsK6Ayi6xj/dl6L0DefAmezae0cnD3cN4=; b=spePNWX6J7Gp3YpPfMqUyJL0d5xst74kwNjK8dA28n5ew5haWtTt6vn0PFqoPWoQyQ eKF6Qkzx62hYahSj/6ejDogcA/02M9xl1GeTwCPn2Bj7yeB0g5JLrNx28ckRAeDOZQVq XhY3aNeURG8QthoavuVSbTeFNEBW+r0PVTL+foM5iudTCsWa8ahv+jWT/kPl8eq0qCsf nlO+ojBtXQWR+lu2I0mTE1bgjQj2CyeqLyMHa0gMOG1DAgNcx++1pCs6FhWStcaD2m2Y B4B3mRjMjKVRRxPcn0p66yb5iA9QH0yQQdXci8/YslRgioUvk5Ma/wIZV+xf8TxZeJ8A +Ctw== ARC-Authentication-Results: i=1; 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 sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s1si3018118plk.256.2017.05.04.13.06.23; Thu, 04 May 2017 13:06:23 -0700 (PDT) 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 sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757216AbdEDUGK (ORCPT + 25 others); Thu, 4 May 2017 16:06:10 -0400 Received: from mail-pf0-f180.google.com ([209.85.192.180]:34378 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754888AbdEDUFq (ORCPT ); Thu, 4 May 2017 16:05:46 -0400 Received: by mail-pf0-f180.google.com with SMTP id e64so12503410pfd.1 for ; Thu, 04 May 2017 13:05:46 -0700 (PDT) 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=U87A0kQ0fzxsK6Ayi6xj/dl6L0DefAmezae0cnD3cN4=; b=E569wyxiDx4fEnwSRhrXRcroH1luICYjNie0AbOFoKFC1RhgyXzSXw/R0C+pjJEzZf 1d49QlfMTU619S6r49YfGUshsJkCRErKjkWb65cpAXRXpDyaJkLZBpvyHkTmxJF0sOjA pXamdJ66rHYfvcYHNwkOI4fX3+nq5m1eUtfxc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U87A0kQ0fzxsK6Ayi6xj/dl6L0DefAmezae0cnD3cN4=; b=lIzXbtMGtZuxKAoz843omBj9ZMcsvZmbVs3zu/66OMtHBzpFxjzFnnbcVm1iOu+g0G 9cZL0cWMYIc2VC5VqVIuzLeFJCcnIOsJoCJjENBjZZG1QUqq6b0BG8Q1146NvtsQA1Ra mZcO7v4PBrM6AjaRJfObZyRuuv5DlearcAsNTmqZFUf44bC3zw9+RcDQLYfToLohTbIz A+HJw3uT0mGKT/5TSv6UevKo2j0WFPcuKyLVcVDd3ZYELpnxU4/fiA7qfX+Ll38F/hem Gv9kS7CqFwyh1SjT/luEtQ4ippRHx4wrzq2iOa4Ye4sLobvRxtZv3pz3W2UMI2XXSMoI ZHQQ== X-Gm-Message-State: AN3rC/4NsXar160s8LYILbLprlP5ambX+4RjcWMCLT+m2lNp5+BHfBXc wDjQ7insf4+sHOs3 X-Received: by 10.98.34.212 with SMTP id p81mr13048456pfj.118.1493928345884; Thu, 04 May 2017 13:05:45 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id s68sm5969712pgc.5.2017.05.04.13.05.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 May 2017 13:05:45 -0700 (PDT) From: Bjorn Andersson To: Andy Gross , Rob Herring , Mark Rutland , Ohad Ben-Cohen , Jassi Brar Cc: linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org Subject: [PATCH v4 3/5] soc: qcom: Introduce APCS IPC driver Date: Thu, 4 May 2017 13:05:37 -0700 Message-Id: <20170504200539.27027-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170504200539.27027-1-bjorn.andersson@linaro.org> References: <20170504200539.27027-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This implements a driver that exposes the IPC bits found in the APCS Global block in various Qualcomm platforms. The bits are used to signal inter-processor communication signals from the application CPU to other masters. The driver implements the "doorbell" binding and could be used as basis for a new Linux framework, if found useful outside Qualcomm. Signed-off-by: Bjorn Andersson --- Changes since v3: - Migrate to mailbox framework Changes since v2: - New driver drivers/mailbox/Kconfig | 8 ++ drivers/mailbox/Makefile | 2 + drivers/mailbox/qcom-apcs-ipc-mailbox.c | 128 ++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 drivers/mailbox/qcom-apcs-ipc-mailbox.c -- 2.12.0 diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index ceff415f201c..fffc64da61f9 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -124,6 +124,14 @@ config MAILBOX_TEST Test client to help with testing new Controller driver implementations. +config QCOM_APCS_IPC + tristate "Qualcomm APCS IPC driver" + depends on ARCH_QCOM + help + Say y here to enable support for the APCS IPC doorbell driver, + providing an interface for invoking the inter-process communication + signals from the application processor to other masters. + config TEGRA_HSP_MBOX bool "Tegra HSP (Hardware Synchronization Primitives) Driver" depends on ARCH_TEGRA_186_SOC diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile index 7dde4f609ae8..cc718c79669a 100644 --- a/drivers/mailbox/Makefile +++ b/drivers/mailbox/Makefile @@ -30,4 +30,6 @@ obj-$(CONFIG_HI6220_MBOX) += hi6220-mailbox.o obj-$(CONFIG_BCM_PDC_MBOX) += bcm-pdc-mailbox.o +obj-$(CONFIG_QCOM_APCS_IPC) += qcom-apcs-ipc-mailbox.o + obj-$(CONFIG_TEGRA_HSP_MBOX) += tegra-hsp.o diff --git a/drivers/mailbox/qcom-apcs-ipc-mailbox.c b/drivers/mailbox/qcom-apcs-ipc-mailbox.c new file mode 100644 index 000000000000..41e31c66c7aa --- /dev/null +++ b/drivers/mailbox/qcom-apcs-ipc-mailbox.c @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2017, Linaro Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define QCOM_APCS_IPC_BITS 32 + +struct qcom_apcs_ipc { + struct device *dev; + + struct mbox_controller mbox; + struct mbox_chan mbox_chans[QCOM_APCS_IPC_BITS]; + + void __iomem *base; + unsigned long offset; +}; + +static int qcom_apcs_ipc_send_data(struct mbox_chan *chan, void *data) +{ + struct qcom_apcs_ipc *apcs = container_of(chan->mbox, + struct qcom_apcs_ipc, mbox); + unsigned long idx = (unsigned long)chan->con_priv; + + writel(BIT(idx), apcs->base + apcs->offset); + + return 0; +} + +static const struct mbox_chan_ops qcom_apcs_ipc_ops = { + .send_data = qcom_apcs_ipc_send_data, +}; + +static int qcom_apcs_ipc_probe(struct platform_device *pdev) +{ + struct qcom_apcs_ipc *apcs; + struct resource *res; + unsigned long i; + int ret; + + apcs = devm_kzalloc(&pdev->dev, sizeof(*apcs), GFP_KERNEL); + if (!apcs) + return -ENOMEM; + + apcs->dev = &pdev->dev; + apcs->offset = (unsigned long)of_device_get_match_data(&pdev->dev); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + apcs->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(apcs->base)) + return PTR_ERR(apcs->base); + + /* Initialize channel identifiers */ + for (i = 0; i < ARRAY_SIZE(apcs->mbox_chans); i++) + apcs->mbox_chans[i].con_priv = (void *)i; + + apcs->mbox.dev = &pdev->dev; + apcs->mbox.ops = &qcom_apcs_ipc_ops; + apcs->mbox.chans = apcs->mbox_chans; + apcs->mbox.num_chans = ARRAY_SIZE(apcs->mbox_chans); + + ret = mbox_controller_register(&apcs->mbox); + if (ret) { + dev_err(&pdev->dev, "failed to register APCS IPC controller\n"); + return ret; + } + + platform_set_drvdata(pdev, apcs); + + return 0; +} + +static int qcom_apcs_ipc_remove(struct platform_device *pdev) +{ + struct qcom_apcs_ipc *apcs = platform_get_drvdata(pdev); + + mbox_controller_unregister(&apcs->mbox); + + return 0; +} + +/* .data is the offset of the ipc register within the global block */ +static const struct of_device_id qcom_apcs_ipc_of_match[] = { + { .compatible = "qcom,msm8916-apcs-kpss-global", .data = (void *)8 }, + { .compatible = "qcom,msm8996-apcs-hmss-global", .data = (void *)16 }, + {} +}; +MODULE_DEVICE_TABLE(of, qcom_apcs_ipc_of_match); + +static struct platform_driver qcom_apcs_ipc_driver = { + .probe = qcom_apcs_ipc_probe, + .remove = qcom_apcs_ipc_remove, + .driver = { + .name = "qcom_apcs_ipc", + .of_match_table = qcom_apcs_ipc_of_match, + }, +}; + +static int __init qcom_apcs_ipc_init(void) +{ + return platform_driver_register(&qcom_apcs_ipc_driver); +} +postcore_initcall(qcom_apcs_ipc_init); + +static void __exit qcom_apcs_ipc_exit(void) +{ + platform_driver_unregister(&qcom_apcs_ipc_driver); +} +module_exit(qcom_apcs_ipc_exit); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("Qualcomm APCS IPC driver");