From patchwork Thu Nov 9 17:10:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 10051369 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 3A96260632 for ; Thu, 9 Nov 2017 17:13:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21C7D2B038 for ; Thu, 9 Nov 2017 17:13:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 167172B052; Thu, 9 Nov 2017 17:13:23 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E778B2B038 for ; Thu, 9 Nov 2017 17:13:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCqLy-0004YP-TA; Thu, 09 Nov 2017 17:10:58 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCqLy-0004W3-DG for xen-devel@lists.xenproject.org; Thu, 09 Nov 2017 17:10:58 +0000 Received: from [85.158.139.211] by server-5.bemta-5.messagelabs.com id CF/FC-02209-12C840A5; Thu, 09 Nov 2017 17:10:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrIIsWRWlGSWpSXmKPExsVyMfS6o65iD0u UwdQWNovvWyYzOTB6HP5whSWAMYo1My8pvyKBNaPlzmSmgml6FRcub2NtYJyi3sXIxSEkMJ1R YtOL00wgDovASxaJ778+sYA4EgL9rBKrNqxj72LkBHKyJGZ/2MIIYadJXJz6GMouk1j+YQVYj ZCAksTrnZuZIMbOZpKY1HebBSTBJmAgsf/dE7AiEaCie6smgxUxC/QzSsyY858VJCEs4CLxat liZhCbRUBV4snn82xdjBwcvEDxi0ezIJbJSdw81wlWwgkUfvPxOhvEYmeJi6+Ps01gFFzAyLC KUaM4tagstUjX0EQvqSgzPaMkNzEzR9fQwFQvN7W4ODE9NScxqVgvOT93EyMw6BiAYAfj2dOe hxglOZiURHmlLFmihPiS8lMqMxKLM+KLSnNSiw8xynBwKEnwencD5QSLUtNTK9Iyc4DhD5OW4 OBREuF91wWU5i0uSMwtzkyHSJ1iDOS4cOfSHyaOAxOugMg9t4Dkppt3geSG7w+A5LOZrxuYOa ZdbW1iFmLJy89LlRLntQLZIwAyKKM0D24NLKYvMcpKCfMyAh0uxFOQWpSbWYIq/4pRnINRSZj XEGQKT2ZeCdw1r4AOZQI6NJod7NCSRISUVAOjV/AqgwVGZo8Ph2Vv0c/z4D/rZ3Ls2bTQ5c/T v1w7sjhR+dlFl6XxLOmBPS9NdnZGuH27e8JajdVD+P6bwv3Ribb7Vj0yPbdz7oc2o6C8WR2f5 yxiWnb9nbNc5EKmgNqVE6fLhW5wyV6Uf1XB4aKO0UVzrsS5kVbmLYy3gjitWnK7tiu5+jxXYi nOSDTUYi4qTgQA5yy2suQCAAA= X-Env-Sender: olekstysh@gmail.com X-Msg-Ref: server-8.tower-206.messagelabs.com!1510247456!106397035!1 X-Originating-IP: [209.85.215.65] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 39524 invoked from network); 9 Nov 2017 17:10:57 -0000 Received: from mail-lf0-f65.google.com (HELO mail-lf0-f65.google.com) (209.85.215.65) by server-8.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 9 Nov 2017 17:10:57 -0000 Received: by mail-lf0-f65.google.com with SMTP id s16so7782544lfs.1 for ; Thu, 09 Nov 2017 09:10:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UQML11F3dLjpcgBB6Lj84Mg5aD5FKku+Sxg15UwSHsw=; b=FyjJl2ELp0i2B6++rN8WM27d9iMzEGsdj4NQi2ONp2QPxahR4slvbbEggmdku5KXeQ 33SzHXrM4lhBdiKpKZOex0nes0R89qGOSbWaT+qfZL7g469t/F4aKCj/2Kh6coJ6kBLj TCb/xD9nvMsKcPASU9JtyO6Ru4c94uJ1IqtcfvP+bX00GMmgpT2iQktakRAgEPUvNT9i mQQfAUWCSZrgIw2nprEUQTk5jA1ELnZuUphbY7xusdfuYhCG8EYKrmG82s9vG0j9MiiG jGuJLcSJ2Jfz+7DrED3StStjFw/ZQeLdSN5xCpAN+dnuP+l6T5cnC4JbV5BN2lCTiYir bB/w== 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=UQML11F3dLjpcgBB6Lj84Mg5aD5FKku+Sxg15UwSHsw=; b=K/jILig7Ow69+3NCgccFE3Rct/Hsfbc+TGCMzFa70f7b5dGAsb/Q9NYFyhhpi4ULLp 7EdTQIRsN6qXuRWifly4qHcCZ8QqN4W1xg+7OrFMqzCfJs7EI7nWwjpt5wRRBBxiL8gC UzRpIb1x7euDSuqFXmnp6d4hayuGGqUGic9JZzYhfv6rUuoLajdpa5PUnBzG5O1+9F5S FwM8QeKUIwvqgMNEKkchpEuC3adEsk5Ek/8FL994qla0XhHDS/gjhg7niHRwKErp+e6e NeTaavrZpEUEc1y6Q7a34xi/dxBYMhcTCM17XVTJAtP0rhaDI2pGjj8XJEhbHTAF/ZO2 CWKg== X-Gm-Message-State: AJaThX5i/Omtrv9b+h8DaUDibQZUfEYB0wpKwxOpwBwjx/5Sh7aVGj6y zfOdaPMH2nD9f3T8c5jN/uNHqQ== X-Google-Smtp-Source: AGs4zMbmBXF4gP7vE2JZ1EuFOwHYKXw+l9aRvzi3/jNJ8H2z6QDjva6XvSg14alkutup1WirSpZmCw== X-Received: by 10.46.71.82 with SMTP id u79mr495267lja.52.1510247456179; Thu, 09 Nov 2017 09:10:56 -0800 (PST) Received: from otyshchenko.kyiv.epam.com (ll-53.209.223.85.sovam.net.ua. [85.223.209.53]) by smtp.gmail.com with ESMTPSA id x90sm1394299ljb.86.2017.11.09.09.10.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Nov 2017 09:10:55 -0800 (PST) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Thu, 9 Nov 2017 19:10:12 +0200 Message-Id: <1510247421-24094-23-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510247421-24094-1-git-send-email-olekstysh@gmail.com> References: <1510247421-24094-1-git-send-email-olekstysh@gmail.com> Cc: Oleksandr Tyshchenko , Stefano Stabellini , Julien Grall Subject: [Xen-devel] [RFC PATCH 22/31] xen/arm: Add Xen changes to SCPI protocol X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Tyshchenko Modify the direct ported SCPI Message Protocol driver to be functional inside Xen. As SCPI Message protocol driver expects mailbox to be registed, find and initialize mailbox before probing it. Include "wrappers.h" which contains all required things the direct ported code relies on. Signed-off-by: Oleksandr Tyshchenko CC: Stefano Stabellini CC: Julien Grall --- xen/arch/arm/cpufreq/arm_scpi.c | 90 ++++++++++++++++++++++++++++++++++++ xen/arch/arm/cpufreq/scpi_protocol.h | 32 +++++++++++++ 2 files changed, 122 insertions(+) diff --git a/xen/arch/arm/cpufreq/arm_scpi.c b/xen/arch/arm/cpufreq/arm_scpi.c index 7da9f1b..553a516 100644 --- a/xen/arch/arm/cpufreq/arm_scpi.c +++ b/xen/arch/arm/cpufreq/arm_scpi.c @@ -23,8 +23,16 @@ * * You should have received a copy of the GNU General Public License along * with this program. If not, see . + * + * Based on Linux drivers/firmware/arm_scpi.c + * => commit 0d30176819c8738b012ec623c7b3db19df818e70 + * + * Xen modification: + * Oleksandr Tyshchenko + * Copyright (C) 2017 EPAM Systems Inc. */ +#if 0 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include @@ -44,6 +52,22 @@ #include #include #include +#endif + +#include +#include +#include +#include + +#include "scpi_protocol.h" +#include "mailbox_client.h" +#include "mailbox_controller.h" +#include "wrappers.h" + +/* + * TODO: + * 1. Add releasing resources since devm. + */ #define CMD_ID_SHIFT 0 #define CMD_ID_MASK 0x7f @@ -859,6 +883,7 @@ static int scpi_init_versions(struct scpi_drvinfo *info) return ret; } +#if 0 static ssize_t protocol_version_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -888,6 +913,7 @@ static struct attribute *versions_attrs[] = { NULL, }; ATTRIBUTE_GROUPS(versions); +#endif static void scpi_free_channels(struct device *dev, struct scpi_chan *pchan, int count) @@ -909,8 +935,10 @@ static int scpi_remove(struct platform_device *pdev) scpi_info = NULL; /* stop exporting SCPI ops through get_scpi_ops */ +#if 0 of_platform_depopulate(dev); sysfs_remove_groups(&dev->kobj, versions_groups); +#endif scpi_free_channels(dev, info->channels, info->num_chans); platform_set_drvdata(pdev, NULL); @@ -1055,11 +1083,15 @@ err: FW_REV_PATCH(scpi_info->firmware_version)); scpi_info->scpi_ops = &scpi_ops; +#if 0 ret = sysfs_create_groups(&dev->kobj, versions_groups); if (ret) dev_err(dev, "unable to create sysfs version group\n"); return of_platform_populate(dev->of_node, NULL, NULL, dev); +#else + return 0; +#endif } static const struct of_device_id scpi_of_match[] = { @@ -1070,6 +1102,7 @@ static const struct of_device_id scpi_of_match[] = { MODULE_DEVICE_TABLE(of, scpi_of_match); +#if 0 static struct platform_driver scpi_driver = { .driver = { .name = "scpi_protocol", @@ -1083,3 +1116,60 @@ module_platform_driver(scpi_driver); MODULE_AUTHOR("Sudeep Holla "); MODULE_DESCRIPTION("ARM SCPI mailbox protocol driver"); MODULE_LICENSE("GPL v2"); +#endif + +static struct device *scpi_dev; + +struct device *get_scpi_dev(void) +{ + return scpi_dev; +} + +int __init scpi_init(void) +{ + struct dt_device_node *scpi, *mbox; + bool has_mbox = false; + int ret = -ENODEV; + + scpi = dt_find_matching_node(NULL, scpi_of_match); + if (!scpi) { + printk("failed to find SCPI node in the device tree\n"); + return -ENXIO; + } + + /* At first find and initialize mailbox to communicate with SCP */ + dt_for_each_device_node(dt_host, mbox) { + ret = device_init(mbox, DEVICE_MAILBOX, NULL); + if (!ret) { + has_mbox = true; + break; + } + } + + if (!has_mbox) { + dev_err(&scpi->dev, "failed to init Mailbox interface (%d)\n", ret); + return ret; + } + + ret = scpi_probe(scpi); + if (ret) { + /* TODO Do we need to deinit mailbox? */ + dev_err(&scpi->dev, "failed to init SCPI Message Protocol (%d)\n", ret); + return ret; + } + + scpi_dev = &scpi->dev; + + /* TODO Do we need to mark device as used by Xen? */ + + return 0; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 8 + * indent-tabs-mode: t + * End: + */ diff --git a/xen/arch/arm/cpufreq/scpi_protocol.h b/xen/arch/arm/cpufreq/scpi_protocol.h index 327d656..0f6dab3 100644 --- a/xen/arch/arm/cpufreq/scpi_protocol.h +++ b/xen/arch/arm/cpufreq/scpi_protocol.h @@ -14,8 +14,25 @@ * * You should have received a copy of the GNU General Public License along with * this program. If not, see . + * + * Based on Linux include/linux/scpi_protocol.h + * => commit 45ca7df7c345465dbd2426a33012c9c33d27de62 + * + * Xen modification: + * Oleksandr Tyshchenko + * Copyright (C) 2017 EPAM Systems Inc. */ + +#ifndef __ARCH_ARM_CPUFREQ_SCPI_PROTOCOL_H__ +#define __ARCH_ARM_CPUFREQ_SCPI_PROTOCOL_H__ + +#if 0 #include +#endif + +#include + +#define IS_REACHABLE(CONFIG_ARM_SCPI_PROTOCOL) 1 struct scpi_opp { u32 freq; @@ -78,7 +95,22 @@ struct scpi_ops { }; #if IS_REACHABLE(CONFIG_ARM_SCPI_PROTOCOL) +int scpi_init(void); +struct device *get_scpi_dev(void); struct scpi_ops *get_scpi_ops(void); #else +static inline int scpi_init(void) { return -1; } +static inline struct device *get_scpi_dev(void) { return NULL; } static inline struct scpi_ops *get_scpi_ops(void) { return NULL; } #endif + +#endif /* __ARCH_ARM_CPUFREQ_SCPI_PROTOCOL_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 8 + * indent-tabs-mode: t + * End: + */