From patchwork Thu Aug 18 10:10:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 9287267 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 017E160574 for ; Thu, 18 Aug 2016 10:13:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6E1328FD3 for ; Thu, 18 Aug 2016 10:13:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBA4128FD9; Thu, 18 Aug 2016 10:13:00 +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=ham 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 5408928FD3 for ; Thu, 18 Aug 2016 10:13:00 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1baKJf-00018q-AC; Thu, 18 Aug 2016 10:12:51 +0000 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1baKIZ-00005w-Lf for linux-amlogic@lists.infradead.org; Thu, 18 Aug 2016 10:11:54 +0000 Received: by mail-wm0-x22e.google.com with SMTP id o80so24578227wme.1 for ; Thu, 18 Aug 2016 03:11:23 -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=W4CbdBtNIF/uCostuz0m/oKz//tB7JYh7nNARHX3fbc=; b=bX6wsHop97Gkwuswfig0yeRuNgWisThkzkpuitWE9JmPPDoneMPUO7IMMEhYNU6/eU bdhLM2gExbuCDisE0tHExUeNu57fRe8WfJZsWTfS7mpd5O0Du9zavESYNx2KSrM3elmJ gSm7DuvENR4h/T2I5ZC9TAqEaawTtJUKL5+dTJ4Ooymxpvq8pXKzcoXCO6jDKAoFZQ8G 04WeeEXwTTdLO0V/rm3+BPh+mTd/9Mc6ynOAFoegzSbqrwC0EHHJ1Pzc2Nz64UZUoFpV cUkI7X2Ve5uc7j3fDx713haBkXh3uzdFslo6N4qKM6hKbuuOEf/obt4nfhI4GxFYOXz2 GyEA== 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=W4CbdBtNIF/uCostuz0m/oKz//tB7JYh7nNARHX3fbc=; b=V+Cl9W+SrfKG6tGZRoLqKbcXJHsQFuejVrHRC0t7Wp0oNrmN4qLGdbij1eKh5MnAuP bdHWmU4tDMh8higyOaYNmSn/Gl1qqLz8omDpL9XTnYOTXZCQSF76NFL5+lZVxvny/jmQ GDw3r43mdtIeLnpOWCFiqypixFUCfliIzg1XrlsPYGZDHmYKk3ojYiGwtNCEO5JdGq3y A+XQVcPBsZPTaHLt8aMiJqHT44/F02w3If+033zVnR7h0lzQzUejD7PeFLtebGdYyuN/ Mvxdx1y9XpeaVwp4hBycFc1WUdUaJ5/toyYpjva4LO/L05z64tDd8uLHF0TP23oL4EGg 3tXg== X-Gm-Message-State: AEkoousicF0H7mIxKUijZjVl83wcs/CiTy6CL0vJyZyPCAAPjnE2IK9zv9qQeGtUdnNm2esY X-Received: by 10.194.61.205 with SMTP id s13mr1423616wjr.86.1471515081748; Thu, 18 Aug 2016 03:11:21 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id f4sm30915247wmf.8.2016.08.18.03.11.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Aug 2016 03:11:21 -0700 (PDT) From: Neil Armstrong To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, sudeep.holla@arm.com Subject: [PATCH 01/13] scpi: Add vendor_send_message to enable access to vendor commands Date: Thu, 18 Aug 2016 12:10:54 +0200 Message-Id: <1471515066-3626-2-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1471515066-3626-1-git-send-email-narmstrong@baylibre.com> References: <1471515066-3626-1-git-send-email-narmstrong@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160818_031144_345134_651866BF X-CRM114-Status: GOOD ( 12.88 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: heiko@sntech.de, Neil Armstrong , frank.wang@rock-chips.com, khilman@baylibre.com, linux-amlogic@lists.infradead.org, wxt@rock-chips.com MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Adds an optional vendor_send_message to the scpi to enable sending vendor platform specific commands to the SCP firmware. Signed-off-by: Neil Armstrong --- drivers/firmware/arm_scpi.c | 26 +++++++++++++++++++++++--- include/linux/scpi_protocol.h | 4 ++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c index 4388937..403783a 100644 --- a/drivers/firmware/arm_scpi.c +++ b/drivers/firmware/arm_scpi.c @@ -46,6 +46,8 @@ #define CMD_ID_SHIFT 0 #define CMD_ID_MASK 0x7f +#define CMD_SET_SHIFT 7 +#define CMD_SET_MASK 0x1 #define CMD_TOKEN_ID_SHIFT 8 #define CMD_TOKEN_ID_MASK 0xff #define CMD_DATA_SIZE_SHIFT 16 @@ -53,6 +55,10 @@ #define PACK_SCPI_CMD(cmd_id, tx_sz) \ ((((cmd_id) & CMD_ID_MASK) << CMD_ID_SHIFT) | \ (((tx_sz) & CMD_DATA_SIZE_MASK) << CMD_DATA_SIZE_SHIFT)) +#define PACK_EXT_SCPI_CMD(cmd_id, tx_sz) \ + ((((cmd_id) & CMD_ID_MASK) << CMD_ID_SHIFT) | \ + (CMD_SET_MASK << CMD_SET_SHIFT) | \ + (((tx_sz) & CMD_DATA_SIZE_MASK) << CMD_DATA_SIZE_SHIFT)) #define ADD_SCPI_TOKEN(cmd, token) \ ((cmd) |= (((token) & CMD_TOKEN_ID_MASK) << CMD_TOKEN_ID_SHIFT)) @@ -344,8 +350,8 @@ static void put_scpi_xfer(struct scpi_xfer *t, struct scpi_chan *ch) mutex_unlock(&ch->xfers_lock); } -static int scpi_send_message(u8 cmd, void *tx_buf, unsigned int tx_len, - void *rx_buf, unsigned int rx_len) +static int __scpi_send_message(u8 cmd, void *tx_buf, unsigned int tx_len, + void *rx_buf, unsigned int rx_len, bool extn) { int ret; u8 chan; @@ -360,7 +366,8 @@ static int scpi_send_message(u8 cmd, void *tx_buf, unsigned int tx_len, return -ENOMEM; msg->slot = BIT(SCPI_SLOT); - msg->cmd = PACK_SCPI_CMD(cmd, tx_len); + msg->cmd = extn ? PACK_EXT_SCPI_CMD(cmd, tx_len) : + PACK_SCPI_CMD(cmd, tx_len); msg->tx_buf = tx_buf; msg->tx_len = tx_len; msg->rx_buf = rx_buf; @@ -385,6 +392,18 @@ out: return ret > 0 ? scpi_to_linux_errno(ret) : ret; } +static int scpi_send_message(u8 cmd, void *tx_buf, unsigned int tx_len, + void *rx_buf, unsigned int rx_len) +{ + return __scpi_send_message(cmd, tx_buf, tx_len, rx_buf, rx_len, false); +} + +static int scpi_ext_send_message(u8 cmd, void *tx_buf, unsigned int tx_len, + void *rx_buf, unsigned int rx_len) +{ + return __scpi_send_message(cmd, tx_buf, tx_len, rx_buf, rx_len, true); +} + static u32 scpi_get_version(void) { return scpi_info->protocol_version; @@ -578,6 +597,7 @@ static struct scpi_ops scpi_ops = { .sensor_get_value = scpi_sensor_get_value, .device_get_power_state = scpi_device_get_power_state, .device_set_power_state = scpi_device_set_power_state, + .vendor_send_message = scpi_ext_send_message, }; struct scpi_ops *get_scpi_ops(void) diff --git a/include/linux/scpi_protocol.h b/include/linux/scpi_protocol.h index dc5f989..2b68581 100644 --- a/include/linux/scpi_protocol.h +++ b/include/linux/scpi_protocol.h @@ -58,6 +58,8 @@ struct scpi_sensor_info { * OPP is an index to the list return by @dvfs_get_info * @dvfs_get_info: returns the DVFS capabilities of the given power * domain. It includes the OPP list and the latency information + * @vendor_send_message: vendor specific message sending, arg can specify + * a scpi implementation specific argument */ struct scpi_ops { u32 (*get_version)(void); @@ -72,6 +74,8 @@ struct scpi_ops { int (*sensor_get_value)(u16, u64 *); int (*device_get_power_state)(u16); int (*device_set_power_state)(u16, u8); + int (*vendor_send_message)(u8 cmd, void *tx_buf, unsigned int tx_len, + void *rx_buf, unsigned int rx_len); }; #if IS_REACHABLE(CONFIG_ARM_SCPI_PROTOCOL)