From patchwork Wed Dec 11 03:22:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason-JH.Lin" X-Patchwork-Id: 13902809 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (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 D6ED920C027; Wed, 11 Dec 2024 03:23:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733887386; cv=none; b=tGBPOWMl1MXnyXqQ71gb1+fp76F7qd7ZhfuzUVvOfqkfPpJL+MH+zJfmXzLqtSFnI6Y8KYyGCM0HEwTcVGIeX32zDSBhWfEpgTx2N+o5XVldfGSYTdI7LMWqx4Tm9h3+mAlB0RDEoQJ6C4RHdBkHBeQTTvsxDqc372TgWD6qykA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733887386; c=relaxed/simple; bh=xyrqhSTrfAChIcSZfpA10SYVxwtUoWrjj+NPUBw/pT4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cqpKlWGsta6emrfhjqdDkc+KECFQTGx+Yky2xkJNmmmccv9p47xtQtChF+2tTjokJKzAur4/F/AQl+cNIJal/vhGe2A3lBNuD8b8PW7Z0bR5dzwhZ/iYDLUOfiA7H5aH1KJEeZgwofk7CAEseC/h4DJiuDp+jpX/BiY0x8871E8= 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=uIQ3GXjz; arc=none smtp.client-ip=210.61.82.184 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="uIQ3GXjz" X-UUID: 39626ddeb76f11efbd192953cf12861f-20241211 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=WWVBpx6kIE9j12QdCFxTHZgkyE+RzxbJALQBeccRuJ8=; b=uIQ3GXjzgJBULQjEXFJn7M3UkOrezAXri4MJyZ8cP98bPK0d3NSBrK7HgOX3PI+o1O6lHHHq1Os1EF6LXnqMI56tpPu6azzx6RcH8Q1451jb+sWzu2C+MJt8WkdkZzxn7doWjhkn/M41fgDzrQ8vhCCgMCkifgmv8XWyeRSYda4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.45,REQID:082da553-0c26-4554-baf5-4d1cd7db7a53,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:6493067,CLOUDID:28532dc1-1c82-4420-82d9-d6eb228f5c4a,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0,EDM:-3,IP :nil,URL: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,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 39626ddeb76f11efbd192953cf12861f-20241211 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 748043963; Wed, 11 Dec 2024 11:23:00 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 11 Dec 2024 11:22:59 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 11 Dec 2024 11:22:59 +0800 From: Jason-JH.Lin To: Jassi Brar , Chun-Kuang Hu , AngeloGioacchino Del Regno , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , Mauro Carvalho Chehab CC: David Airlie , Simona Vetter , , , , , , , "Jason-JH . Lin" , Singo Chang , Nancy Lin , Moudy Ho , Xavier Chang , Subject: [PATCH v2 6/8] soc: mediatek: Add programming flow for unsupported subsys ID hardware Date: Wed, 11 Dec 2024 11:22:54 +0800 Message-ID: <20241211032256.28494-7-jason-jh.lin@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20241211032256.28494-1-jason-jh.lin@mediatek.com> References: <20241211032256.28494-1-jason-jh.lin@mediatek.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--6.341800-8.000000 X-TMASE-MatchedRID: wDTc/wNgEcNYXTxImR5ZvBes/RxhysDbu56wFPSkMVEs/uUAk6xP7PlY oV6p/cSxrKWVhE5vxYb5CFR3bPuHIixDojmF3AkddAg4yd14qAThKQh1LCmGBjb9TB28Ubkiz1r LcNpRkyiTFmqgSxbocJ9vpuXVh9T3HxPMjOKY7A8LbigRnpKlKSPzRlrdFGDw70DvyaD6XnZqRZ ljJQ6IE4pKEUj+UU0L4qutW8oZlIcWM7ewxYxMMg== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--6.341800-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 5D7B39F7E5620480764DF7006E5915F7D7D095FAA3FB6039B2710A021656D7A22000:8 X-MTK: N To support hardware without subsys IDs on new SoCs, add a programming flow that checks whether the subsys ID is valid. If the subsys ID is invalid, the flow will call 2 alternative CMDQ APIs: cmdq_pkt_assign() and cmdq_pkt_write_s_value() to achieve the same functionality. Signed-off-by: Jason-JH.Lin --- drivers/soc/mediatek/mtk-mmsys.c | 16 +++++++++++++--- drivers/soc/mediatek/mtk-mutex.c | 12 ++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/soc/mediatek/mtk-mmsys.c b/drivers/soc/mediatek/mtk-mmsys.c index bb4639ca0b8c..fbf97ae9dc28 100644 --- a/drivers/soc/mediatek/mtk-mmsys.c +++ b/drivers/soc/mediatek/mtk-mmsys.c @@ -167,9 +167,19 @@ static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 tmp; if (mmsys->cmdq_base.size && cmdq_pkt) { - ret = cmdq_pkt_write_mask(cmdq_pkt, mmsys->cmdq_base.subsys, - mmsys->cmdq_base.offset + offset, val, - mask); + struct cmdq_client *cl = (struct cmdq_client *)cmdq_pkt->cl; + + offset += mmsys->cmdq_base.offset; + if (cmdq_subsys_is_valid(cl->chan, mmsys->cmdq_base.subsys)) { + ret = cmdq_pkt_write_mask(cmdq_pkt, mmsys->cmdq_base.subsys, + offset, val, mask); + } else { + /* only MMIO access, no need to check mminfro_offset */ + ret = cmdq_pkt_assign(cmdq_pkt, 0, + CMDQ_ADDR_HIGH(mmsys->cmdq_base.pa_base)); + ret |= cmdq_pkt_write_s_mask_value(cmdq_pkt, 0, + CMDQ_ADDR_LOW(offset), val, mask); + } if (ret) pr_debug("CMDQ unavailable: using CPU write\n"); else diff --git a/drivers/soc/mediatek/mtk-mutex.c b/drivers/soc/mediatek/mtk-mutex.c index 5250c1d702eb..e94df5b783ce 100644 --- a/drivers/soc/mediatek/mtk-mutex.c +++ b/drivers/soc/mediatek/mtk-mutex.c @@ -963,6 +963,8 @@ int mtk_mutex_enable_by_cmdq(struct mtk_mutex *mutex, void *pkt) struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx, mutex[mutex->id]); struct cmdq_pkt *cmdq_pkt = (struct cmdq_pkt *)pkt; + struct cmdq_client *cl = (struct cmdq_client *)cmdq_pkt->cl; + dma_addr_t en_addr = mtx->addr + DISP_REG_MUTEX_EN(mutex->id); WARN_ON(&mtx->mutex[mutex->id] != mutex); @@ -971,8 +973,14 @@ int mtk_mutex_enable_by_cmdq(struct mtk_mutex *mutex, void *pkt) return -ENODEV; } - cmdq_pkt_write(cmdq_pkt, mtx->cmdq_reg.subsys, - mtx->addr + DISP_REG_MUTEX_EN(mutex->id), 1); + if (cmdq_subsys_is_valid(cl->chan, mtx->cmdq_reg.subsys)) { + cmdq_pkt_write(cmdq_pkt, mtx->cmdq_reg.subsys, en_addr, 1); + } else { + /* only MMIO access, no need to check mminfro_offset */ + cmdq_pkt_assign(cmdq_pkt, 0, CMDQ_ADDR_HIGH(en_addr)); + cmdq_pkt_write_s_value(cmdq_pkt, 0, CMDQ_ADDR_LOW(en_addr), 1); + } + return 0; } EXPORT_SYMBOL_GPL(mtk_mutex_enable_by_cmdq);