From patchwork Thu May 26 09:38:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 9136867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0FEBA607D5 for ; Thu, 26 May 2016 09:40:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F352E25EF7 for ; Thu, 26 May 2016 09:40:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8219280E5; Thu, 26 May 2016 09:40:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 8785325EF7 for ; Thu, 26 May 2016 09:40:18 +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 1b5rl3-0004Gi-8R; Thu, 26 May 2016 09:39:13 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b5rkh-00043n-Ve for linux-arm-kernel@lists.infradead.org; Thu, 26 May 2016 09:38:53 +0000 Received: by mail-wm0-x22d.google.com with SMTP id n129so217824846wmn.1 for ; Thu, 26 May 2016 02:38:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EjhcnF1B+zZDZisegCxjFAm5O/eIBm668nJd681LG3Q=; b=bdPsBfIdERbulHekChOCtjB1t+Rwvysx/ZzL3cLX31CEBHzbBBx583QqIVUXnX5k8/ CVmyg1632Qt2kV8YJ5K2DocbKfj+oolfg4xcDbgfN7YqwCcE5gtvtcxc5D/g3BAKWKzX O0pEpuojkXZumwodHzFaQe0dWDYQ8XtQSfLCMo7Xs2D/zzfVD3582/KcibGhns5FDvLu kwja6k404WllkONwr5qTMHXFJ3vOmCal3wLzqJu7SivUogrE7tX9B6W9owUIdKxRpxha cwKErwCssi0eILHN/PIBiH9UW7lIi6jY6zl6UMpf20pwOWBoeYboh2RjKp5LfyBOciVx wxxQ== 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=EjhcnF1B+zZDZisegCxjFAm5O/eIBm668nJd681LG3Q=; b=iD7RvpukK2IL06/a2JROF+z7zZvVLxKudVJDfSxoBGgjllb6hDVbwa1+EmBXcq8bZe g0EfUbT4942w4yNL+B1noV8SINpH7RpL8gN19AXPOrZAd/kkuzrmaYoV6S1JmNKJbKHS vJ9Q+l7dup7YoYWO/wP6PpMaLbTcSk2qTdc7DDx8wyQG/Akhi+s5CwKt98ROAGBr+RIl Rj+gQvJRl/g2+iJTxBj+82oIyzfT6fs3ztEFT6Hq3gtEtiN27TbO8ucsmMTG1mOTfNsO Hzbp7IcIvlKFJQc2O24vToT2xnajJez/Zve0ZcoRMLsgZBUDXHiSfDgZZNx5HtEumqSs HkZQ== X-Gm-Message-State: ALyK8tLw5N/1klqdCp5VYqbORBuscNyioYp1CGcC2p1WKX1KjQwsLUnbdHQO0EnKwLGVubyx X-Received: by 10.28.41.65 with SMTP id p62mr2560110wmp.15.1464255509808; Thu, 26 May 2016 02:38:29 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id hm7sm13332682wjb.41.2016.05.26.02.38.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 May 2016 02:38:29 -0700 (PDT) From: Neil Armstrong To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla Subject: [RFC PATCH 1/2] firmware: Add a SCPI framework to handle multiple vendors implementation Date: Thu, 26 May 2016 11:38:10 +0200 Message-Id: <1464255491-18503-2-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464255491-18503-1-git-send-email-narmstrong@baylibre.com> References: <1464255491-18503-1-git-send-email-narmstrong@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160526_023852_333645_E6D2FDC2 X-CRM114-Status: GOOD ( 18.98 ) 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: Neil Armstrong MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add a thin "register" interface for SCPI driver in order to register their ops along their node. Since nodes using the SCPI ops are currently sub-nodes, does not implement phandle xlate stuff. Signed-off-by: Neil Armstrong --- drivers/firmware/Makefile | 1 + drivers/firmware/scpi.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 drivers/firmware/scpi.c diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index 474bada..701a791 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -2,6 +2,7 @@ # Makefile for the linux kernel. # obj-$(CONFIG_ARM_PSCI_FW) += psci.o +obj-$(CONFIG_ARM_SCPI_PROTOCOL) += scpi.o obj-$(CONFIG_ARM_SCPI_PROTOCOL) += arm_scpi.o obj-$(CONFIG_DMI) += dmi_scan.o obj-$(CONFIG_DMI_SYSFS) += dmi-sysfs.o diff --git a/drivers/firmware/scpi.c b/drivers/firmware/scpi.c new file mode 100644 index 0000000..ba94ac4 --- /dev/null +++ b/drivers/firmware/scpi.c @@ -0,0 +1,110 @@ +/* + * System Control and Power Interface (SCPI) Message Protocol framework + * + * SCPI Message Protocol is used between the System Control Processor(SCP) + * and the Application Processors(AP). The Message Handling Unit(MHU) + * provides a mechanism for inter-processor communication between SCP's + * Cortex M3 and AP. + * + * SCP offers control and management of the core/cluster power states, + * various power domain DVFS including the core/cluster, certain system + * clocks configuration, thermal sensors and many others. + * + * Copyright (C) 2015 ARM Ltd. + * Copyright (C) 2016 BayLibre, SAS. + * Author: Neil Armstrong + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope 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. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static DEFINE_MUTEX(scpi_list_mutex); +static LIST_HEAD(scpi_drivers_list); + +struct scpi_ops *of_scpi_ops_get(struct device_node *node) +{ + struct scpi_ops *ops = NULL; + struct scpi_driver *r; + + if (!node) + return ERR_PTR(-EINVAL); + + mutex_lock(&scpi_list_mutex); + list_for_each_entry(r, &scpi_drivers_list, list) { + if (node == r->node) { + ops = r->ops; + break; + } + } + mutex_unlock(&scpi_list_mutex); + + if (!ops) + return ERR_PTR(-EPROBE_DEFER); + + return ops; +} +EXPORT_SYMBOL_GPL(of_scpi_ops_get); + +int scpi_driver_register(struct scpi_driver *drv) +{ + mutex_lock(&scpi_list_mutex); + list_add(&drv->list, &scpi_drivers_list); + mutex_unlock(&scpi_list_mutex); + + return 0; +} +EXPORT_SYMBOL_GPL(scpi_driver_register); + +void scpi_driver_unregister(struct scpi_driver *drv) +{ + mutex_lock(&scpi_list_mutex); + list_del(&drv->list); + mutex_unlock(&scpi_list_mutex); +} +EXPORT_SYMBOL_GPL(scpi_driver_unregister); + +static void devm_scpi_driver_unregister(struct device *dev, void *res) +{ + scpi_driver_unregister(*(struct scpi_driver **)res); +} + +int devm_scpi_driver_register(struct device *dev, + struct scpi_driver *drv) +{ + struct scpi_driver **rcdrv; + int ret; + + rcdrv = devres_alloc(devm_scpi_driver_unregister, sizeof(*drv), + GFP_KERNEL); + if (!rcdrv) + return -ENOMEM; + + ret = scpi_driver_register(drv); + if (!ret) { + *rcdrv = drv; + devres_add(dev, rcdrv); + } else + devres_free(rcdrv); + + return ret; +} +EXPORT_SYMBOL_GPL(devm_scpi_driver_register);