From patchwork Mon Jul 8 15:47:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 168678 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp7331183ilk; Mon, 8 Jul 2019 08:47:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQdeDD+tICZGDu3i2/0sKbwj8UOlyyf4TE4rVEpCH/htASQGHjNkiuZxn1sxxUBj8G3wLm X-Received: by 2002:a65:44c8:: with SMTP id g8mr24502097pgs.443.1562600873812; Mon, 08 Jul 2019 08:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562600873; cv=none; d=google.com; s=arc-20160816; b=ZLi2QaCeMf7YenPTBc4/e5cB+2tquDM/+bVKKav+MgECkq0kyJEiCozkgPEK+Ez7i4 /NW6rsLf+2mpOhEzZw1IrdhnpcRlygV1JaRKJwXFZR7mBiqjBARv6c1QhlJcCYc6yYbW knRviVUt6CGuNNCNrOPZKc2S0k84bbkFRL0n0nxRONHl/2zzntV4aHmcGKe0G5ooiTqR wVgzuWNEd+hjSZwAlmGUCGedTv1L8h6AcxyyYYfEWDYOgAbniwKEU6fKNiXhotizlDmZ k5ZC+G7t5+mgHhWw+fcXClAn98vUbETXAUWI5ujUxTOE1mFOy0vzBD1IwPyqL7cKuDc4 H6MQ== 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; bh=G5u18gST3P5z1dSHkdRsT03fztTeInB+nkzmjegL22I=; b=hQCsMbENmgFJjxlHHP2r3H9iQmLwQJAwgg8ZMyWDkzOZocARudP3ZsYQuExQxjI0qM 5f5NwTGN5Vd9MbWK2qszcRKnqrDnZd9yIDKAXn5SzSlGAhQqiU6tN3h40oWEJp3EhUfc +30SH0l5PkQh6KOZiSyReI8LvYbb4rqIQXjx+S62A97J2wHsE55fx+v3MiLR71IWctT4 p8fLyIkOVkgjC71BoTVlG1FmgFIL/R/TZ/DKZkuEJVOJ5+osEhUn9hlMvnJ8QPumW139 psxW1gdc+ZqCGIN9jKHavm5eYMBjrkmXsVngDBPeCIHmqXVVz52pO68jJRiTWfL8Vncl G8vg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f74si19378230pfa.57.2019.07.08.08.47.53; Mon, 08 Jul 2019 08:47:53 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391336AbfGHPrw (ORCPT + 30 others); Mon, 8 Jul 2019 11:47:52 -0400 Received: from foss.arm.com ([217.140.110.172]:52386 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391308AbfGHPrt (ORCPT ); Mon, 8 Jul 2019 11:47:49 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ABE591509; Mon, 8 Jul 2019 08:47:48 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A948A3F59C; Mon, 8 Jul 2019 08:47:47 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Peng Fan , Jim Quinlan , Bo Zhang , Volodymyr Babchuk Subject: [PATCH 06/11] firmware: arm_scmi: Add mechanism to unpack message headers Date: Mon, 8 Jul 2019 16:47:25 +0100 Message-Id: <20190708154730.16643-7-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708154730.16643-1-sudeep.holla@arm.com> References: <20190708154730.16643-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to identify the message type when a response arrives, we need a mechanism to unpack the message header similar to packing. Let's add one. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/driver.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) -- 2.17.1 diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index eb5a2f271806..b384c818d8dd 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -30,8 +30,14 @@ #include "common.h" #define MSG_ID_MASK GENMASK(7, 0) +#define MSG_XTRACT_ID(hdr) FIELD_GET(MSG_ID_MASK, (hdr)) #define MSG_TYPE_MASK GENMASK(9, 8) +#define MSG_XTRACT_TYPE(hdr) FIELD_GET(MSG_TYPE_MASK, (hdr)) +#define MSG_TYPE_COMMAND 0 +#define MSG_TYPE_DELAYED_RESP 2 +#define MSG_TYPE_NOTIFICATION 3 #define MSG_PROTOCOL_ID_MASK GENMASK(17, 10) +#define MSG_XTRACT_PROT_ID(hdr) FIELD_GET(MSG_PROTOCOL_ID_MASK, (hdr)) #define MSG_TOKEN_ID_MASK GENMASK(27, 18) #define MSG_XTRACT_TOKEN(hdr) FIELD_GET(MSG_TOKEN_ID_MASK, (hdr)) #define MSG_TOKEN_MAX (MSG_XTRACT_TOKEN(MSG_TOKEN_ID_MASK) + 1) @@ -216,6 +222,18 @@ static inline u32 pack_scmi_header(struct scmi_msg_hdr *hdr) FIELD_PREP(MSG_PROTOCOL_ID_MASK, hdr->protocol_id); } +/** + * unpack_scmi_header() - unpacks and records message and protocol id + * + * @msg_hdr: 32-bit packed message header sent from the platform + * @hdr: pointer to header to fetch message and protocol id. + */ +static inline void unpack_scmi_header(u32 msg_hdr, struct scmi_msg_hdr *hdr) +{ + hdr->id = MSG_XTRACT_ID(msg_hdr); + hdr->protocol_id = MSG_XTRACT_PROT_ID(msg_hdr); +} + /** * scmi_tx_prepare() - mailbox client callback to prepare for the transfer *