From patchwork Sat May 27 23:14:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 100607 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp840000qge; Sat, 27 May 2017 16:14:37 -0700 (PDT) X-Received: by 10.84.198.36 with SMTP id o33mr67560381pld.145.1495926877285; Sat, 27 May 2017 16:14:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495926877; cv=none; d=google.com; s=arc-20160816; b=F5P+3g0EHxDagardeWdjNUAAk1RVV8suiUFeV9sW2ILtjdo6FHnjwXlb+DOu0O3qNR 69mhrS1O0t1vk/xrfAUGPnLee+P+Xejbd0uQpMAJRKyW4TPlRbIpHRK5jkDxTMMYwQ7c LsI9A4xQESHQRSncw+2+yPYdNHNRiNMQP4rEHVHc8hfJZwc82ac0pXdnvnrOLPWx2HTl Q614iHEqY77bNM7ZaiMvJJp+N2U9zQUTe/sw/kmLvlcUgXb4B5KKwLf1pog2QT31mXZj dqEC9H0zWD9u3YIph6p2OhsrHD2DxRvyclxsfVSJ6m3jWjj2FZLnMJSlVTrau7wF36az azfg== 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=hSIYGN5HAEU71OSCuSQM7P1K2za0DX4LFBz8EqvgKh0=; b=I1RPUA42Vn/pF3iZRJ+JEswsOscpdVUHRApBNuFYD9X23W/NTDF7Vbor7uUeb8bLcp 1QVN+Z1lHWihPt81Nw0joNs4wCn08PxWb875lDQuc/DG6O98vYtw9SKO08LN6row389K VlXKqQmWhjk1z1zcWBke6EVfne01dVIBGcEWkBDn5Fl91489j3t/VGJEJlHPU1rve3Tb NJVpxvaHjipbpHy4gcjRjdxaGTXj6c/gMTk8QsQvNwIVZ02CJDxDLBBixrOEuyOVydq6 ju1RNnr7R3HMsbeOEwC5OYmSqsXi6lENgr6QmdGw1qqE+6b5e9xLaKlFGK7NwsvFfCIS 88xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (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 28si5484132pfq.323.2017.05.27.16.14.36; Sat, 27 May 2017 16:14:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750820AbdE0XOO (ORCPT + 10 others); Sat, 27 May 2017 19:14:14 -0400 Received: from mail-pg0-f50.google.com ([74.125.83.50]:35704 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750793AbdE0XOM (ORCPT ); Sat, 27 May 2017 19:14:12 -0400 Received: by mail-pg0-f50.google.com with SMTP id 8so8247114pgc.2 for ; Sat, 27 May 2017 16:14:12 -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=h0cuj2WZjUo8TL/IlpCCHquLTuc1YcEzMhe3Ek+yw38=; b=JgfSJxAC/wDnpeEIGF9GZwCxHzgk6FyVGdedgtPtW8xB80nUJYhQBlDdEfY5sR+ohh SZmaus/7atgM81mKtZO5MEhHkIt8FxoQzaKbcPL4QtNYRg3Rrp3MIQ3v90HvLQJHnJ4I Bs7QsMouXUpW+ox7qIpF2ZPCYFCar9M1uk204= 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=h0cuj2WZjUo8TL/IlpCCHquLTuc1YcEzMhe3Ek+yw38=; b=eYBmxQuHzP0tQEIXug363O21w/bRs8jBNbvz78p3T0wmCBz4lfybSyhnT4Xz1lFlo7 1iJ4HAk7AyVhL0jNfzyGFeXXPuyPanOcMIScbXBqSX/xkaq5JS0/yF8ra854cBog9VPF 44By5Ik6MDfNYXP2eot1K8ZnPt0S/QXjPI47FXUzdFuMtRg5OsMrojtRF2L6C7egE4UY iUCEhg51TZZC4o3OOVSSjVJwXKMnBkGy6eH7UpvmkXRkw+aWOHq6IpQTzQVQQne9dqm3 7uzY1B59SRGT/R9X3c8c+qRdt2CYi7SteVoOpZDwMTCXl9diKLFjvbl1YDpVflS3xVIo l/nA== X-Gm-Message-State: AODbwcD4RHYG5Jc3Sx/4c/y9Zq5jpklw5Z6sBYoKjzkSr3eeN48Jqd+I hL847lprsbH//PFj X-Received: by 10.98.65.26 with SMTP id o26mr9905546pfa.228.1495926851722; Sat, 27 May 2017 16:14:11 -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 c67sm10070255pfe.37.2017.05.27.16.14.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 May 2017 16:14:11 -0700 (PDT) From: Bjorn Andersson To: Jassi Brar Cc: Rob Herring , Mark Rutland , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v7 3/3] mailbox: Introduce Qualcomm APCS IPC driver Date: Sat, 27 May 2017 16:14:04 -0700 Message-Id: <20170527231404.7632-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170527231404.7632-1-bjorn.andersson@linaro.org> References: <20170527231404.7632-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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. Signed-off-by: Bjorn Andersson --- Changes since v6: - Add COMPILE_TEST - Drop "dev" from apcs_ipc struct - Track only the IPC register instead of base and offset drivers/mailbox/Kconfig | 8 ++ drivers/mailbox/Makefile | 2 + drivers/mailbox/qcom-apcs-ipc-mailbox.c | 129 ++++++++++++++++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 drivers/mailbox/qcom-apcs-ipc-mailbox.c -- 2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index ee1a3d9147ef..c5731e5e3c6c 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 || COMPILE_TEST + help + Say y here to enable support for the APCS IPC mailbox 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 e2bcb03cd35b..d54e41206e17 100644 --- a/drivers/mailbox/Makefile +++ b/drivers/mailbox/Makefile @@ -32,4 +32,6 @@ obj-$(CONFIG_BCM_PDC_MBOX) += bcm-pdc-mailbox.o obj-$(CONFIG_BCM_FLEXRM_MBOX) += bcm-flexrm-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..9924c6d7f05d --- /dev/null +++ b/drivers/mailbox/qcom-apcs-ipc-mailbox.c @@ -0,0 +1,129 @@ +/* + * 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 mbox_controller mbox; + struct mbox_chan mbox_chans[QCOM_APCS_IPC_BITS]; + + void __iomem *reg; + 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->reg); + + 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 offset; + void __iomem *base; + unsigned long i; + int ret; + + apcs = devm_kzalloc(&pdev->dev, sizeof(*apcs), GFP_KERNEL); + if (!apcs) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + + offset = (unsigned long)of_device_get_match_data(&pdev->dev); + + apcs->reg = base + offset; + + /* 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");