From patchwork Thu Nov 9 05:45:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huisong Li X-Patchwork-Id: 13450628 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4B19BC4167D for ; Thu, 9 Nov 2023 05:46:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RFkZVT+PaICUIROCpcVO6aIQRyDPNhBrf84CYDP5gCg=; b=3ANm8SYqkO9oLx k7TSG+UJbuMpeYXSa1EyOy5+gV9NEK5/P4YCwecIGnk8E/lcCNHgcK/wRWLbkjcjZyMPeDHJheypy uyHN8Vt05sL6qnJCDugXaffRBAXvucf59DcfpOJKB37dThyKrAPzEcWXnDICDEf2KVJzzMEOnSPaZ dzJ3sqm8rXuNOmxmaU/PHqNxoXX6HDah3HZwJgYcytCw6/+Q9AePGdFuhYlXffIXzXfQTMbOx5BJe b5KyYi+wHfEe9Pp9hdUxIS/JN30OMXMeynx+q+3NgyVXbupU1XzNEeaKO1QeTQ0xZ5AJXqcsJg1AP rl0QV0SdVUVxRUfo4fgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r0xrc-005LHH-1i; Thu, 09 Nov 2023 05:46:00 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r0xrY-005LEZ-0Q for linux-arm-kernel@lists.infradead.org; Thu, 09 Nov 2023 05:45:58 +0000 Received: from kwepemm000004.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SQrSp5hf0z1P88K; Thu, 9 Nov 2023 13:42:34 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by kwepemm000004.china.huawei.com (7.193.23.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 9 Nov 2023 13:45:11 +0800 From: Huisong Li To: CC: , , , , , , , Subject: [PATCH v1 1/3] soc: hisilicon: kunpeng_hccs: Fix some incorrect format strings Date: Thu, 9 Nov 2023 13:45:24 +0800 Message-ID: <20231109054526.27270-2-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20231109054526.27270-1-lihuisong@huawei.com> References: <20231109054526.27270-1-lihuisong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm000004.china.huawei.com (7.193.23.18) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231108_214556_371944_41D5A417 X-CRM114-Status: UNSURE ( 9.08 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Fix some incorrect format strings. Signed-off-by: Huisong Li Reviewed-by: Jonathan Cameron --- drivers/soc/hisilicon/kunpeng_hccs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/soc/hisilicon/kunpeng_hccs.c b/drivers/soc/hisilicon/kunpeng_hccs.c index e31791659560..dad6235dbf1a 100644 --- a/drivers/soc/hisilicon/kunpeng_hccs.c +++ b/drivers/soc/hisilicon/kunpeng_hccs.c @@ -155,7 +155,7 @@ static int hccs_register_pcc_channel(struct hccs_dev *hdev) cl_info->pcc_comm_addr = ioremap(pcc_chan->shmem_base_addr, pcc_chan->shmem_size); if (!cl_info->pcc_comm_addr) { - dev_err(dev, "Failed to ioremap PCC communication region for channel-%d.\n", + dev_err(dev, "Failed to ioremap PCC communication region for channel-%u.\n", hdev->chan_id); rc = -ENOMEM; goto err_mbx_channel_free; @@ -1097,7 +1097,7 @@ static int hccs_create_hccs_dir(struct hccs_dev *hdev, int ret; ret = kobject_init_and_add(&port->kobj, &hccs_port_type, - &die->kobj, "hccs%d", port->port_id); + &die->kobj, "hccs%u", port->port_id); if (ret) { kobject_put(&port->kobj); return ret; @@ -1115,7 +1115,7 @@ static int hccs_create_die_dir(struct hccs_dev *hdev, u16 i; ret = kobject_init_and_add(&die->kobj, &hccs_die_type, - &chip->kobj, "die%d", die->die_id); + &chip->kobj, "die%u", die->die_id); if (ret) { kobject_put(&die->kobj); return ret; @@ -1125,7 +1125,7 @@ static int hccs_create_die_dir(struct hccs_dev *hdev, port = &die->ports[i]; ret = hccs_create_hccs_dir(hdev, die, port); if (ret) { - dev_err(hdev->dev, "create hccs%d dir failed.\n", + dev_err(hdev->dev, "create hccs%u dir failed.\n", port->port_id); goto err; } @@ -1147,7 +1147,7 @@ static int hccs_create_chip_dir(struct hccs_dev *hdev, u16 id; ret = kobject_init_and_add(&chip->kobj, &hccs_chip_type, - &hdev->dev->kobj, "chip%d", chip->chip_id); + &hdev->dev->kobj, "chip%u", chip->chip_id); if (ret) { kobject_put(&chip->kobj); return ret; @@ -1178,7 +1178,7 @@ static int hccs_create_topo_dirs(struct hccs_dev *hdev) chip = &hdev->chips[id]; ret = hccs_create_chip_dir(hdev, chip); if (ret) { - dev_err(hdev->dev, "init chip%d dir failed!\n", id); + dev_err(hdev->dev, "init chip%u dir failed!\n", id); goto err; } } From patchwork Thu Nov 9 05:45:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huisong Li X-Patchwork-Id: 13450626 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F3EEC4332F for ; Thu, 9 Nov 2023 05:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ElMZDqONVgbpFblvQAsRvTp8EBlxYlxPleyNDIsESDU=; b=FPmOfh03D5iHCi xtv8u2DgtVcek6thUL81dH3xjuPiILyndBVi2E0hzmqtfCaCsZd1KhW6aSB6ReDEo7enNwzx1CNqf bp9zeHsCf7dTSD44kWOf8FVb5Ck3v/GLNHk0pCSShftrnNR2xiDn/15c2fdJwg32Qv1NTTzrsq7nW 3WRkl86gQQWA5e4GulFaYkujsvXyjiKY6vSiduVOzbnPaeCLR5zqjta+llJa3KEFnVAl1uHD/d7Fe n0yc8Mp6GBhQhmZf4XEQUSnhT4Kvhq9pXW1YvESqfqVFj/C+U+eX9tRg5yyGl3NnVOY56BpR7/pDb jE+lOB/G64IwGIY4JoJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r0xrb-005LGv-38; Thu, 09 Nov 2023 05:45:59 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r0xrY-005LEY-0o for linux-arm-kernel@lists.infradead.org; Thu, 09 Nov 2023 05:45:58 +0000 Received: from kwepemm000004.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SQrSp732kz1P85Y; Thu, 9 Nov 2023 13:42:34 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by kwepemm000004.china.huawei.com (7.193.23.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 9 Nov 2023 13:45:11 +0800 From: Huisong Li To: CC: , , , , , , , Subject: [PATCH v1 2/3] soc: hisilicon: kunpeng_hccs: Add failure log for no _CRS method Date: Thu, 9 Nov 2023 13:45:25 +0800 Message-ID: <20231109054526.27270-3-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20231109054526.27270-1-lihuisong@huawei.com> References: <20231109054526.27270-1-lihuisong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm000004.china.huawei.com (7.193.23.18) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231108_214556_489261_D9F923E6 X-CRM114-Status: GOOD ( 11.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Driver gets the PCC channel id by using the PCC GAS in _CRS. But, currently, if the firmware has no _CRS method on platform, there is not any failure log. So this patch adds the log for this. Signed-off-by: Huisong Li Reviewed-by: Jonathan Cameron --- drivers/soc/hisilicon/kunpeng_hccs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/soc/hisilicon/kunpeng_hccs.c b/drivers/soc/hisilicon/kunpeng_hccs.c index dad6235dbf1a..fd3ca0eb8175 100644 --- a/drivers/soc/hisilicon/kunpeng_hccs.c +++ b/drivers/soc/hisilicon/kunpeng_hccs.c @@ -85,8 +85,10 @@ static int hccs_get_pcc_chan_id(struct hccs_dev *hdev) struct hccs_register_ctx ctx = {0}; acpi_status status; - if (!acpi_has_method(handle, METHOD_NAME__CRS)) + if (!acpi_has_method(handle, METHOD_NAME__CRS)) { + dev_err(hdev->dev, "No _CRS method.\n"); return -ENODEV; + } ctx.dev = hdev->dev; status = acpi_walk_resources(handle, METHOD_NAME__CRS, From patchwork Thu Nov 9 05:45:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huisong Li X-Patchwork-Id: 13450629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2ED44C4332F for ; Thu, 9 Nov 2023 05:46:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Kj8jIREKZJQ05I8anECUgEuDII/moOf2ZKuKMHhZS0Y=; b=RHhoj+l386Arma 0DedXx5hSZsik9PG9nt/9C+9YfTJGqoZqaGIGsuUnAg+4w82LsAN2egpU/YRcGB1Xt+1kA3bSTnJ7 XfK7nI7T3+dv9mHa0rgTyC7h81GVpgwEr/qbXtXkTRg93FMM3o1T5HLKOvBkhQPFzGuSr6HXG5CTU NFYLZl8d/+KFhGkSKMoU6VDWNlFy3XyPWudmXT7IsqUpC43JLYkcm5MNMEPR2/qvNMu/ksy0uRbqB 329mNV7kP5QcWMxggIu4IUuRby9WtjY0vuY2dBmUupD/ygmrj6Rf9G47j3V1LEqvNr5/mPG1TAUdu dBBlwWuerwLMhEVfaobg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r0xrf-005LI2-28; Thu, 09 Nov 2023 05:46:03 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r0xrY-005LEX-1l for linux-arm-kernel@lists.infradead.org; Thu, 09 Nov 2023 05:45:59 +0000 Received: from kwepemm000004.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SQrSq1Qmtz1P88y; Thu, 9 Nov 2023 13:42:35 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by kwepemm000004.china.huawei.com (7.193.23.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 9 Nov 2023 13:45:11 +0800 From: Huisong Li To: CC: , , , , , , , Subject: [PATCH v1 3/3] soc: hisilicon: kunpeng_hccs: Support the platform with PCC type3 and interrupt ack Date: Thu, 9 Nov 2023 13:45:26 +0800 Message-ID: <20231109054526.27270-4-lihuisong@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20231109054526.27270-1-lihuisong@huawei.com> References: <20231109054526.27270-1-lihuisong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm000004.china.huawei.com (7.193.23.18) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231108_214556_960851_E99ED863 X-CRM114-Status: GOOD ( 21.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Support the platform with PCC type3 and interrupt ack. Signed-off-by: Huisong Li --- drivers/soc/hisilicon/kunpeng_hccs.c | 137 +++++++++++++++++++++------ drivers/soc/hisilicon/kunpeng_hccs.h | 2 + 2 files changed, 110 insertions(+), 29 deletions(-) diff --git a/drivers/soc/hisilicon/kunpeng_hccs.c b/drivers/soc/hisilicon/kunpeng_hccs.c index fd3ca0eb8175..96cdac7be244 100644 --- a/drivers/soc/hisilicon/kunpeng_hccs.c +++ b/drivers/soc/hisilicon/kunpeng_hccs.c @@ -38,6 +38,11 @@ #define HCCS_PCC_CMD_WAIT_RETRIES_NUM 500ULL #define HCCS_POLL_STATUS_TIME_INTERVAL_US 3 +enum hccs_hw_device_version { + HCCS_HW_DEVICE_V1 = 0, + HCCS_HW_DEVICE_V2 = 1, +}; + static struct hccs_port_info *kobj_to_port_info(struct kobject *k) { return container_of(k, struct hccs_port_info, kobj); @@ -100,6 +105,21 @@ static int hccs_get_pcc_chan_id(struct hccs_dev *hdev) return 0; } +static int hccs_get_device_version(struct hccs_dev *hdev) +{ + const struct acpi_device_id *acpi_id; + + acpi_id = acpi_match_device(hdev->dev->driver->acpi_match_table, + hdev->dev); + if (!acpi_id) { + dev_err(hdev->dev, "get device version failed."); + return -EINVAL; + } + + hdev->dev_ver = (u8)acpi_id->driver_data; + return 0; +} + static void hccs_chan_tx_done(struct mbox_client *cl, void *msg, int ret) { if (ret < 0) @@ -110,6 +130,14 @@ static void hccs_chan_tx_done(struct mbox_client *cl, void *msg, int ret) *(u8 *)msg, ret); } +static void hccs_pcc_rx_callback(struct mbox_client *cl, void *m) +{ + struct hccs_mbox_client_info *cl_info = + container_of(cl, struct hccs_mbox_client_info, client); + + complete(&cl_info->done); +} + static void hccs_unregister_pcc_channel(struct hccs_dev *hdev) { struct hccs_mbox_client_info *cl_info = &hdev->cl_info; @@ -131,6 +159,11 @@ static int hccs_register_pcc_channel(struct hccs_dev *hdev) cl->tx_block = false; cl->knows_txdone = true; cl->tx_done = hccs_chan_tx_done; + if (hdev->dev_ver == HCCS_HW_DEVICE_V2) { + cl->rx_callback = hccs_pcc_rx_callback; + init_completion(&cl_info->done); + } + pcc_chan = pcc_mbox_request_channel(cl, hdev->chan_id); if (IS_ERR(pcc_chan)) { dev_err(dev, "PPC channel request failed.\n"); @@ -147,10 +180,16 @@ static int hccs_register_pcc_channel(struct hccs_dev *hdev) */ cl_info->deadline_us = HCCS_PCC_CMD_WAIT_RETRIES_NUM * pcc_chan->latency; - if (cl_info->mbox_chan->mbox->txdone_irq) { + if (hdev->dev_ver == HCCS_HW_DEVICE_V1 && + cl_info->mbox_chan->mbox->txdone_irq) { dev_err(dev, "PCC IRQ in PCCT is enabled.\n"); rc = -EINVAL; goto err_mbx_channel_free; + } else if (hdev->dev_ver == HCCS_HW_DEVICE_V2 && + !cl_info->mbox_chan->mbox->txdone_irq) { + dev_err(dev, "PCC IRQ in PCCT isn't supported.\n"); + rc = -EINVAL; + goto err_mbx_channel_free; } if (pcc_chan->shmem_base_addr) { @@ -175,49 +214,81 @@ static int hccs_register_pcc_channel(struct hccs_dev *hdev) static int hccs_check_chan_cmd_complete(struct hccs_dev *hdev) { struct hccs_mbox_client_info *cl_info = &hdev->cl_info; - struct acpi_pcct_shared_memory __iomem *comm_base = - cl_info->pcc_comm_addr; + struct acpi_pcct_shared_memory __iomem *comm_base; + int ret = 0; u16 status; - int ret; /* * Poll PCC status register every 3us(delay_us) for maximum of * deadline_us(timeout_us) until PCC command complete bit is set(cond) */ - ret = readw_poll_timeout(&comm_base->status, status, - status & PCC_STATUS_CMD_COMPLETE, - HCCS_POLL_STATUS_TIME_INTERVAL_US, - cl_info->deadline_us); - if (unlikely(ret)) - dev_err(hdev->dev, "poll PCC status failed, ret = %d.\n", ret); + if (hdev->dev_ver == HCCS_HW_DEVICE_V1) { + comm_base = cl_info->pcc_comm_addr; + ret = readw_poll_timeout(&comm_base->status, status, + status & PCC_STATUS_CMD_COMPLETE, + HCCS_POLL_STATUS_TIME_INTERVAL_US, + cl_info->deadline_us); + if (unlikely(ret)) + dev_err(hdev->dev, "poll PCC status failed, ret = %d.\n", ret); + } else { + if (!wait_for_completion_timeout(&cl_info->done, + usecs_to_jiffies(cl_info->deadline_us))) { + dev_err(hdev->dev, "PCC command executed timeout!\n"); + ret = -ETIMEDOUT; + } + } return ret; } +static void hccs_fill_pcc_shared_mem_region(struct hccs_dev *hdev, u8 cmd, + struct hccs_desc *desc, + void __iomem *comm_space, + u16 space_size) +{ + struct hccs_mbox_client_info *cl_info = &hdev->cl_info; + struct acpi_pcct_ext_pcc_shared_memory tmp1 = {0}; + struct acpi_pcct_shared_memory tmp2 = {0}; + + if (hdev->dev_ver == HCCS_HW_DEVICE_V1) { + tmp2.signature = PCC_SIGNATURE | hdev->chan_id; + tmp2.command = cmd; + tmp2.status = 0; + memcpy_toio(cl_info->pcc_comm_addr, (void *)&tmp2, + sizeof(struct acpi_pcct_shared_memory)); + } else { + tmp1.signature = PCC_SIGNATURE | hdev->chan_id; + tmp1.command = cmd; + tmp1.flags = PCC_CMD_COMPLETION_NOTIFY; + tmp1.length = HCCS_PCC_SHARE_MEM_BYTES; + memcpy_toio(cl_info->pcc_comm_addr, (void *)&tmp1, + sizeof(struct acpi_pcct_ext_pcc_shared_memory)); + } + + /* Copy the message to the PCC comm space */ + memcpy_toio(comm_space, (void *)desc, space_size); +} + static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd, struct hccs_desc *desc) { struct hccs_mbox_client_info *cl_info = &hdev->cl_info; - void __iomem *comm_space = cl_info->pcc_comm_addr + - sizeof(struct acpi_pcct_shared_memory); struct hccs_fw_inner_head *fw_inner_head; - struct acpi_pcct_shared_memory tmp = {0}; - u16 comm_space_size; + void __iomem *comm_space; + u16 shared_mem_size; + u16 space_size; int ret; - /* Write signature for this subspace */ - tmp.signature = PCC_SIGNATURE | hdev->chan_id; - /* Write to the shared command region */ - tmp.command = cmd; - /* Clear cmd complete bit */ - tmp.status = 0; - memcpy_toio(cl_info->pcc_comm_addr, (void *)&tmp, - sizeof(struct acpi_pcct_shared_memory)); + shared_mem_size = hdev->dev_ver == HCCS_HW_DEVICE_V1 ? + sizeof(struct acpi_pcct_shared_memory) : + sizeof(struct acpi_pcct_ext_pcc_shared_memory); + comm_space = cl_info->pcc_comm_addr + shared_mem_size; + space_size = HCCS_PCC_SHARE_MEM_BYTES - shared_mem_size; - /* Copy the message to the PCC comm space */ - comm_space_size = HCCS_PCC_SHARE_MEM_BYTES - - sizeof(struct acpi_pcct_shared_memory); - memcpy_toio(comm_space, (void *)desc, comm_space_size); + hccs_fill_pcc_shared_mem_region(hdev, cmd, desc, + comm_space, space_size); + if (cl_info->mbox_chan->mbox->txdone_irq) + reinit_completion(&cl_info->done); /* Ring doorbell */ ret = mbox_send_message(cl_info->mbox_chan, &cmd); @@ -233,7 +304,7 @@ static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd, goto end; /* Copy response data */ - memcpy_fromio((void *)desc, comm_space, comm_space_size); + memcpy_fromio((void *)desc, comm_space, space_size); fw_inner_head = &desc->rsp.fw_inner_head; if (fw_inner_head->retStatus) { dev_err(hdev->dev, "Execute PCC command failed, error code = %u.\n", @@ -242,7 +313,10 @@ static int hccs_pcc_cmd_send(struct hccs_dev *hdev, u8 cmd, } end: - mbox_client_txdone(cl_info->mbox_chan, ret); + if (cl_info->mbox_chan->mbox->txdone_irq) + mbox_chan_txdone(cl_info->mbox_chan, ret); + else + mbox_client_txdone(cl_info->mbox_chan, ret); return ret; } @@ -1214,6 +1288,10 @@ static int hccs_probe(struct platform_device *pdev) hdev->dev = &pdev->dev; platform_set_drvdata(pdev, hdev); + rc = hccs_get_device_version(hdev); + if (rc) + return rc; + mutex_init(&hdev->lock); rc = hccs_get_pcc_chan_id(hdev); if (rc) @@ -1251,7 +1329,8 @@ static void hccs_remove(struct platform_device *pdev) } static const struct acpi_device_id hccs_acpi_match[] = { - { "HISI04B1"}, + { "HISI04B1", HCCS_HW_DEVICE_V1}, + { "HISI04B2", HCCS_HW_DEVICE_V2}, { ""}, }; MODULE_DEVICE_TABLE(acpi, hccs_acpi_match); diff --git a/drivers/soc/hisilicon/kunpeng_hccs.h b/drivers/soc/hisilicon/kunpeng_hccs.h index 6012d2776028..bbb1aada0c6c 100644 --- a/drivers/soc/hisilicon/kunpeng_hccs.h +++ b/drivers/soc/hisilicon/kunpeng_hccs.h @@ -51,12 +51,14 @@ struct hccs_mbox_client_info { struct pcc_mbox_chan *pcc_chan; u64 deadline_us; void __iomem *pcc_comm_addr; + struct completion done; }; struct hccs_dev { struct device *dev; struct acpi_device *acpi_dev; u64 caps; + u8 dev_ver; u8 chip_num; struct hccs_chip_info *chips; u8 chan_id;