From patchwork Fri Mar 1 14:44:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SmFzb24tSkggTGluICjmnpfnnb/npaUp?= X-Patchwork-Id: 208874 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp1125657dyb; Fri, 1 Mar 2024 06:44:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXQ4VdrOismpJn1pV5Z+Py6nYOPkTeBz/NduO980ddFB11LRK7f8Miy0G8FNb3QoPrA1ykCFQqQmQXVCPR+7OtPg1BxGQ== X-Google-Smtp-Source: AGHT+IG1myvdVagoA0o1gyIzFK5OMvRBYpUR5fY115RG5VyRd6Eh1BvfBkMsUPiOqln1g3JUYCfl X-Received: by 2002:a17:902:ec83:b0:1db:f952:eebf with SMTP id x3-20020a170902ec8300b001dbf952eebfmr1729554plg.44.1709304282909; Fri, 01 Mar 2024 06:44:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709304282; cv=pass; d=google.com; s=arc-20160816; b=O0zqA03cAYgiPQAkhwHrQIcFCKgYnNYSfxIwx3aZXTCGTABAYpZd9IgzZanlMHIhkG qNtOqJ3Dx3WQ/Ukc3jQ+4NICY3m2GUUx8b11mm3bcSZQ4YgZhfR/2zABvGCEP7gOaw3/ y4Ps4DTskOgipHWM4vpgpOk4EWwH9CavjvvYQseugVwUNojeE/41JNn9sOad7uXTH9H5 5U6zCB2x9FqXlE52cMZzJQQNzIDEGQjDkYhOkwtyav9MaLVBgVEZnhXnYQwZb3qPNYZy 14AJN5RXtbYcos5JtAvYxL3Ddwn53Y3CSupOD26/uAHQYPQ6M0NIeEv7dkz7aqoZpuiM RkFQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1jCHjECWvQc/BrF8PoLKpz6E7MT5BMb3T/DMj3fy5Qo=; fh=/ugC6UPXmWUlk9++6CULpLk86ijV12MoDCJJaRsql5M=; b=CO5AB2TIWQsv7C3iGNJ6o/triHpiVP9cMauy8NbwIQ8MPlcnFFrGn1UD/19HBtMNNJ oihskyd5XHYMTIfCPVShzpHLCXZkhioOL56/kW30hdkW6Jyi/imW9MaQddQYZu0iib8P 0jsFare4J7sN1M5D4LoIvMpTSV4ofc+gp49R93SQm8Qsbdfy01Yxtq+RCI5uJzbgRSGq Vy+tUMdA0uPhd+OHKgjnNmaKZgCZkYTvJVFBgpbDREgQdoOrj7NFdcYMcL2kBaydV9ND PeGLtEt38nQ38G0UAPHfAztaGklGaOyX2/maEvtwzmGyJTjQ3YMUtwmOfS+zYIlfrSqG uyYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=r6HQnGL4; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-88573-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88573-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j14-20020a170903024e00b001dcdb174f1csi3516618plh.400.2024.03.01.06.44.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 06:44:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88573-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=r6HQnGL4; arc=pass (i=1 spf=pass spfdomain=mediatek.com dkim=pass dkdomain=mediatek.com dmarc=pass fromdomain=mediatek.com); spf=pass (google.com: domain of linux-kernel+bounces-88573-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88573-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B065D2863F6 for ; Fri, 1 Mar 2024 14:44:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4056B6EB69; Fri, 1 Mar 2024 14:44:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="r6HQnGL4" Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C0CC23DE for ; Fri, 1 Mar 2024 14:44:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709304252; cv=none; b=mmiiFmNRd88SpzYLiqI/TWmUF3urEzH7frbWbCJskGaES9dKMISSTiUGIM/cZ12O0oKbxt1xYVC6hBdhr6UbXqnsDN/2VDYuv3yHRNwPYKx123cSf1yrJAi6Xepx4Zrxu7mmNDBmvxNHRwBf6/yRV7PJ7XcO778PFLKxAnrVjcA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709304252; c=relaxed/simple; bh=bG6jSphmtzNrlnQ+mLx8wtQj5gAx0UsXV140JZIHAxw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Pwn0NAUvxm4xoTJV6paxY9knxiRlghKT2DM+n2h5/4u93AZz+L33EjmW41zYYBu7hlbVntVp0d013LNj1GlvvgvJbNQdRXG2pKmdgxDU9PMDVYgI5hYzslwkDWB58/bDt/L5gUUm1UcaWudAZclxT0YJN4nOcKHzNLtW8JYokj0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=r6HQnGL4; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com X-UUID: 27b02358d7da11eeb8927bc1f75efef4-20240301 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=1jCHjECWvQc/BrF8PoLKpz6E7MT5BMb3T/DMj3fy5Qo=; b=r6HQnGL45/EeOIO4I0f1nxb7faQW1XznO6hhsFKFFTrCubTWHEhgIwjJxEaCnT2eRtYeKdC+SVQM72RJu/+vJ5ggiPKtmv0aj2heR5iGN0aLC1ccJuQXAEHUbuioYhE3yw0D4/dF0UfmhAOG5Ibk4NFQQlsXR5JL6oBGk+8HKjY=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:791913cd-204b-4096-bb22-15f28577dc55,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:6f543d0,CLOUDID:2e2c66ff-c16b-4159-a099-3b9d0558e447,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1, SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 27b02358d7da11eeb8927bc1f75efef4-20240301 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1511825525; Fri, 01 Mar 2024 22:44:06 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 1 Mar 2024 22:44:05 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 1 Mar 2024 22:44:05 +0800 From: Jason-JH.Lin To: Jassi Brar , Chun-Kuang Hu , Matthias Brugger CC: AngeloGioacchino Del Regno , Jason-ch Chen , "Jason-JH . Lin" , Singo Chang , Nancy Lin , Shawn Sung , , , , Subject: [RESEND, PATCH 5/5] mailbox: mtk-cmdq: Add support runtime get and set GCE event Date: Fri, 1 Mar 2024 22:44:03 +0800 Message-ID: <20240301144403.2977-6-jason-jh.lin@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20240301144403.2977-1-jason-jh.lin@mediatek.com> References: <20240301144403.2977-1-jason-jh.lin@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MTK: N X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792335447879169097 X-GMAIL-MSGID: 1792335447879169097 ISP drivers need to get and set GCE event in their runtime contorl flow. So add these functions to support get and set GCE by CPU. Signed-off-by: Jason-JH.Lin --- drivers/mailbox/mtk-cmdq-mailbox.c | 37 ++++++++++++++++++++++++ include/linux/mailbox/mtk-cmdq-mailbox.h | 2 ++ 2 files changed, 39 insertions(+) diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c index ead2200f39ba..d7c08249c898 100644 --- a/drivers/mailbox/mtk-cmdq-mailbox.c +++ b/drivers/mailbox/mtk-cmdq-mailbox.c @@ -25,7 +25,11 @@ #define CMDQ_GCE_NUM_MAX (2) #define CMDQ_CURR_IRQ_STATUS 0x10 +#define CMDQ_SYNC_TOKEN_ID 0x60 +#define CMDQ_SYNC_TOKEN_VALUE 0x64 +#define CMDQ_TOKEN_ID_MASK GENMASK(9, 0) #define CMDQ_SYNC_TOKEN_UPDATE 0x68 +#define CMDQ_TOKEN_UPDATE_VALUE BIT(16) #define CMDQ_THR_SLOT_CYCLES 0x30 #define CMDQ_THR_BASE 0x100 #define CMDQ_THR_SIZE 0x80 @@ -83,6 +87,7 @@ struct cmdq { struct cmdq_thread *thread; struct clk_bulk_data clocks[CMDQ_GCE_NUM_MAX]; bool suspended; + spinlock_t event_lock; /* lock for gce event */ }; struct gce_plat { @@ -113,6 +118,38 @@ u8 cmdq_get_shift_pa(struct mbox_chan *chan) } EXPORT_SYMBOL(cmdq_get_shift_pa); +void cmdq_set_event(void *chan, u16 event_id) +{ + struct cmdq *cmdq = container_of(((struct mbox_chan *)chan)->mbox, + typeof(*cmdq), mbox); + unsigned long flags; + + spin_lock_irqsave(&cmdq->event_lock, flags); + + writel(CMDQ_TOKEN_UPDATE_VALUE | event_id, cmdq->base + CMDQ_SYNC_TOKEN_UPDATE); + + spin_unlock_irqrestore(&cmdq->event_lock, flags); +} +EXPORT_SYMBOL(cmdq_set_event); + +u32 cmdq_get_event(void *chan, u16 event_id) +{ + struct cmdq *cmdq = container_of(((struct mbox_chan *)chan)->mbox, + typeof(*cmdq), mbox); + unsigned long flags; + u32 value = 0; + + spin_lock_irqsave(&cmdq->event_lock, flags); + + writel(CMDQ_TOKEN_ID_MASK & event_id, cmdq->base + CMDQ_SYNC_TOKEN_ID); + value = readl(cmdq->base + CMDQ_SYNC_TOKEN_VALUE); + + spin_unlock_irqrestore(&cmdq->event_lock, flags); + + return value; +} +EXPORT_SYMBOL(cmdq_get_event); + static int cmdq_thread_suspend(struct cmdq *cmdq, struct cmdq_thread *thread) { u32 status; diff --git a/include/linux/mailbox/mtk-cmdq-mailbox.h b/include/linux/mailbox/mtk-cmdq-mailbox.h index a8f0070c7aa9..f05cabd230da 100644 --- a/include/linux/mailbox/mtk-cmdq-mailbox.h +++ b/include/linux/mailbox/mtk-cmdq-mailbox.h @@ -79,5 +79,7 @@ struct cmdq_pkt { }; u8 cmdq_get_shift_pa(struct mbox_chan *chan); +void cmdq_set_event(void *chan, u16 event_id); +u32 cmdq_get_event(void *chan, u16 event_id); #endif /* __MTK_CMDQ_MAILBOX_H__ */