From patchwork Thu Jul 8 18:08:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 471274 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp525941jao; Thu, 8 Jul 2021 11:09:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdxM0Klv0XEnU82J6Aea3ciyIfD86jx1PCqbrEewj3okoJVHh8u5y8ocxa9VGfo6KHtr+f X-Received: by 2002:a17:906:28c4:: with SMTP id p4mr3897101ejd.302.1625767746652; Thu, 08 Jul 2021 11:09:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625767746; cv=none; d=google.com; s=arc-20160816; b=dMF3MR0zRh8Evvci6TYIwI9cRy783JLblv+aKueQcmrF4N8yy2GnWzYQdjrj7q4VzK tGydkZBUvdQR0/t8bF1r3cxzhfUBw3YrFIx8JlAL7poO11wXHvWvXT7kZL7Kov9dNK9O L03N2a4+gk3otMHz1Eq/BwOMn9Z25aEEvakLaVRVZyWd+j4U5YqJMbsEOdP2ahfMxT0z ug3XcjdZlDAhjKBCQj9IM+k3CXplnAWFAIqe6wJAUWaBBKdpnEUG0d4Qy51zpSx2LSz6 MPJqPwoeUrJmtiyyzzx2lBSHqUu8IP5LKIvlE0j3B2u7vUgXxkLVKe5w5LyJeI/T0bRu kSvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=sgzLHhMYxKROSJeRvFi5xsnYR7zMK1dwLnzSJoAru8c=; b=0V/GqlthAivu9y3jtVTsHHhNes04odhHZExfFz4M6rgITGxri/gEiuVDXRqADDa3wB EsXlLAscG04sI4/AEnWJtngxyrDcyyWFStuhZnnAdYnEYPtvBU9Vp2NEzhnT8ipxILoc WrD9yLT+FVgycVr7AacExob6oZhNY4ajYTFpcxioVAXlAAa8S7Gs3OVhL9wPUS9ucRSO qJNxCpkBp6V7HIc998dCRjtIF9cXjaCITje6MOqiq6f5zrljODFq+gFIJrJvuJPjjyRB 9yZheHVz58JpnZReA/xfvS6nzURO/BenlhRiuXvfeRTKE9Wyc33hiBF0JFLb33QLmFaE pEqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 24si3945545ejw.232.2021.07.08.11.09.06; Thu, 08 Jul 2021 11:09:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230155AbhGHSLr (ORCPT + 4 others); Thu, 8 Jul 2021 14:11:47 -0400 Received: from foss.arm.com ([217.140.110.172]:35996 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230220AbhGHSLq (ORCPT ); Thu, 8 Jul 2021 14:11:46 -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 5581A1063; Thu, 8 Jul 2021 11:09:04 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6FB7D3F66F; Thu, 8 Jul 2021 11:09:03 -0700 (PDT) From: Sudeep Holla To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi , "Rafael J . Wysocki" , Jassi Brar Subject: [PATCH 05/13] mailbox: pcc: Consolidate subspace doorbell register parsing Date: Thu, 8 Jul 2021 19:08:43 +0100 Message-Id: <20210708180851.2311192-6-sudeep.holla@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210708180851.2311192-1-sudeep.holla@arm.com> References: <20210708180851.2311192-1-sudeep.holla@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Extended PCC subspaces(Type 3 and 4) differs from generic(Type 0) and HW-Reduced Communication(Type 1 and 2) subspace structures. However some fields share same offsets and same type of structure can be use to extract the fields. In order to simplify that, let us move all the doorbell register parsing into pcc_parse_subspace_db_reg and consolidate there. It will be easier to extend it if required within the same. Signed-off-by: Sudeep Holla --- drivers/mailbox/pcc.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) -- 2.25.1 Reviewed-by: Cristian Marussi diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 55866676a508..5f19bee71c04 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -447,6 +447,28 @@ static int pcc_parse_subspace_irq(struct pcc_chan_info *pchan, return 0; } +/** + * pcc_parse_subspace_db_reg - Parse the PCC doorbell register + * + * @pchan: Pointer to the PCC channel info structure. + * @pcct_entry: Pointer to the ACPI subtable header. + * + */ +static void pcc_parse_subspace_db_reg(struct pcc_chan_info *pchan, + struct acpi_subtable_header *pcct_entry) +{ + struct acpi_pcct_subspace *pcct_ss; + struct acpi_generic_address *db_reg; + + pcct_ss = (struct acpi_pcct_subspace *)pcct_entry; + + /* If doorbell is in system memory cache the virt address */ + db_reg = &pcct_ss->doorbell_register; + if (db_reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) + pchan->db_vaddr = acpi_os_ioremap(db_reg->address, + db_reg->bit_width / 8); +} + /** * acpi_pcc_probe - Parse the ACPI tree for the PCCT. * @@ -512,8 +534,6 @@ static int __init acpi_pcc_probe(void) for (i = 0; i < count; i++) { struct pcc_chan_info *pchan = chan_info + i; - struct acpi_generic_address *db_reg; - struct acpi_pcct_subspace *pcct_ss; pcc_mbox_channels[i].con_priv = pcct_entry; if (pcc_mbox_ctrl.txdone_irq) { @@ -521,13 +541,8 @@ static int __init acpi_pcc_probe(void) if (rc < 0) goto err; } - pcct_ss = (struct acpi_pcct_subspace *) pcct_entry; + pcc_parse_subspace_db_reg(pchan, pcct_entry); - /* If doorbell is in system memory cache the virt address */ - db_reg = &pcct_ss->doorbell_register; - if (db_reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) - pchan->db_vaddr = acpi_os_ioremap(db_reg->address, - db_reg->bit_width / 8); pcct_entry = (struct acpi_subtable_header *) ((unsigned long) pcct_entry + pcct_entry->length); }