Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2846625lqt; Tue, 23 Apr 2024 03:34:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU7fpgbeqo4HzMLNiJVllTG8MbUE1oj3GXeVF0lXu4KnSR/xBuz1t8ErD3KFX/kJJS1DCYGR8FCWEdB95cI9R4pSQl9EezA31/CR+pbOg== X-Google-Smtp-Source: AGHT+IFertneHOQ16nOT2McelSifnbFTCwNiKEQrDeC191mK4KxvaY31zK5JtMF6N3SrMWDmoQQB X-Received: by 2002:a05:6214:11a3:b0:6a0:7a3d:841d with SMTP id u3-20020a05621411a300b006a07a3d841dmr7200417qvv.22.1713868464327; Tue, 23 Apr 2024 03:34:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713868464; cv=pass; d=google.com; s=arc-20160816; b=EMf/IAAgH4nJL2BVyLbO4DUNIlsYgE0DbPzY5/HXTQB02fzmGDy8nSQkb4572lLEy9 evaoaHCyo0NGEFdQq4ELiatrpQngZl32Lqocb+GOzxLQONVpxdT3bskay4nTrLQbe5D1 FjNey63174C0nGZ3n0R83bknVxIKsAc5k0i3aI8nLkg+rbgwb3ioomjqgkKHAZO9+yjy uPA32U59uWcWaVgBZh2kI6okeE1KcD+Bzy033AZcgq7gyRSbfrOdL5I5AWMuHszS0hF4 lUTXnnmlidtj0pc3UfKQuSWM5XtvmR2QbmBruGrCVHk9CPxnTCaqa4Mk+4UycRUlxm2V nDsA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=MiYKtVjiYGayHJ4uhB0s6D821r2mrG8hS7wgv8FbeJE=; fh=f4KQnOf4DL3FZ4rINpxCCB681RH9plJXTbAzdkN1cKE=; b=IkwDT6KS+1aDOqhuYo/tGT2HZbUXRXdvehS/glUCUCHgc9xfawj8TEIWsFD1Wans89 yZ5dETij9YP2aEX7FjQndPA2W2TVwRYDJO+IIZpgtj+3C1xPuqYTnPx8iFMzo1dAFjjo AWqrDAqmM+sDroylm5Hm/o20MTN5UnwCVgHrDWmkGEdDTK7HTC5Sx1f+Ut7YJ7W435QV SzZ7x3QCUvvWp47XwsK2Rs5z63lJpopgp6jVM2DJ5EF9ZjCcA+oKZ+yZN8p0q6cSoThk Ch10nn1Knh4UqBWB2Gf6RKb6gBd3t2/GoZpS9s4+b+eD27buplE1rQA7hAut9CYUqkT6 5RFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=MfDgEw2J; arc=pass (i=1 spf=pass spfdomain=qualcomm.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-154873-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154873-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ib2-20020a0562141c8200b00699403c5771si12406434qvb.291.2024.04.23.03.34.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 03:34:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154873-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=MfDgEw2J; arc=pass (i=1 spf=pass spfdomain=qualcomm.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-154873-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154873-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 124871C21A2B for ; Tue, 23 Apr 2024 10:34:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 469497641E; Tue, 23 Apr 2024 10:33:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="MfDgEw2J" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 E3CC74501F; Tue, 23 Apr 2024 10:33:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713868437; cv=none; b=Xqxak7uSweIwC41C5FEpVkRqcnbBGZI0ZGb5xLlqchd/XrsfTXKB3nQqeWUc69PFN+CJi5D/Mbo9buptbrfO7hMRlzEFvrMFCDlVwFE3LCP99LA6X3v2KjYLQ1voMe9f3MbZTsz7RjdRXHNIPwVzn22+mQyLRPky2tUpdiqaQYQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713868437; c=relaxed/simple; bh=XIPYcrQ3GunBqF7O2yX/Nrd0N+vABpiohMutuXWlHLk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=WhUgwgFZtgUYlOc7tR+AayNnrCB89ZDrLPyR6XRKpb6Qc9r04QArcFFChqO6Wlzo/PxZb6BfWaYNaKN4umCzn+X/ujmuwNXb61KmdWr0PYYEYwqHYWxxAWZ624YQwQdi7ScwZ4Wcc4A0FRr9te9TFUCbc8ElgAvzDYO5XtfUCXE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=MfDgEw2J; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qualcomm.com Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 43N5Tj4Z012462; Tue, 23 Apr 2024 10:33:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= qcppdkim1; bh=MiYKtVjiYGayHJ4uhB0s6D821r2mrG8hS7wgv8FbeJE=; b=Mf DgEw2JukuSF2ZlcjBATtdQWwUtmQLG7phAvAuxvSF+UgR5IGzoY6YGBLOQ555a2x IfOTalO9VDEXmdD1IErFxmoi3fdBHL+TIJc3UzuiMj1CRQlFcow0wd7lCoKen512 1qzs5iDR5ZL/7x5OddxyIhcSpv7ucPks89DWkXTtebyu8liDq6y6guXfS7X7iMfX UBvj7EDa0JI4JCTFzZcg404taKPy+qIXk4ybiuONv/xEkd8B674tF2Dq8pwvJmih 2/vJ0ejEKYJEAaevGN75ttY6WxSsdOIwLjVgcpTYnCRemdf9eaT9+pocHRZDwBe8 5GJdlPK4Z7Pw0a91/sNw== Received: from aptaippmta02.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com [103.229.16.4]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3xnvtn9qxc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Apr 2024 10:33:43 +0000 (GMT) Received: from pps.filterd (APTAIPPMTA02.qualcomm.com [127.0.0.1]) by APTAIPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 43NAXf3F030334; Tue, 23 Apr 2024 10:33:41 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APTAIPPMTA02.qualcomm.com (PPS) with ESMTP id 3xm6skdt6e-1; Tue, 23 Apr 2024 10:33:41 +0000 Received: from APTAIPPMTA02.qualcomm.com (APTAIPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 43NAXfuX030329; Tue, 23 Apr 2024 10:33:41 GMT Received: from cbsp-sh-gv.qualcomm.com (CBSP-SH-gv.ap.qualcomm.com [10.231.249.68]) by APTAIPPMTA02.qualcomm.com (PPS) with ESMTP id 43NAXeX4030328; Tue, 23 Apr 2024 10:33:41 +0000 Received: by cbsp-sh-gv.qualcomm.com (Postfix, from userid 4098150) id EE2955B14; Tue, 23 Apr 2024 18:33:39 +0800 (CST) From: Qiang Yu To: mani@kernel.org, quic_jhugo@quicinc.com Cc: mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_cang@quicinc.com, quic_mrana@quicinc.com, Qiang Yu Subject: [PATCH v4 2/3] bus: mhi: host: Add a new API for getting channel doorbell address Date: Tue, 23 Apr 2024 18:33:36 +0800 Message-Id: <1713868417-37856-3-git-send-email-quic_qianyu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1713868417-37856-1-git-send-email-quic_qianyu@quicinc.com> References: <1713868417-37856-1-git-send-email-quic_qianyu@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: O8X6Ht0mrDFJqmpmjiWc153Lxw9F5fBe X-Proofpoint-ORIG-GUID: O8X6Ht0mrDFJqmpmjiWc153Lxw9F5fBe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-23_09,2024-04-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=999 phishscore=0 priorityscore=1501 mlxscore=0 adultscore=0 bulkscore=0 spamscore=0 malwarescore=0 impostorscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2404010003 definitions=main-2404230028 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Some controllers may want to know the address of a certain doorbell. Hence add a new API where we read CHDBOFF register to get the base address of doorbell, so that the controller can calculate the address of the doorbell it wants by adding additional offset. Signed-off-by: Qiang Yu --- drivers/bus/mhi/host/init.c | 6 ++---- drivers/bus/mhi/host/main.c | 16 ++++++++++++++++ include/linux/mhi.h | 6 ++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/bus/mhi/host/init.c b/drivers/bus/mhi/host/init.c index 7104c18..6e0fa79 100644 --- a/drivers/bus/mhi/host/init.c +++ b/drivers/bus/mhi/host/init.c @@ -541,11 +541,9 @@ int mhi_init_mmio(struct mhi_controller *mhi_cntrl) dev_dbg(dev, "Initializing MHI registers\n"); /* Read channel db offset */ - ret = mhi_read_reg(mhi_cntrl, base, CHDBOFF, &val); - if (ret) { - dev_err(dev, "Unable to read CHDBOFF register\n"); + ret = mhi_get_channel_doorbell_offset(mhi_cntrl, &val); + if (ret) return -EIO; - } if (val >= mhi_cntrl->reg_len - (8 * MHI_DEV_WAKE_DB)) { dev_err(dev, "CHDB offset: 0x%x is out of range: 0x%zx\n", diff --git a/drivers/bus/mhi/host/main.c b/drivers/bus/mhi/host/main.c index 15d657a..4de7567 100644 --- a/drivers/bus/mhi/host/main.c +++ b/drivers/bus/mhi/host/main.c @@ -1691,3 +1691,19 @@ void mhi_unprepare_from_transfer(struct mhi_device *mhi_dev) } } EXPORT_SYMBOL_GPL(mhi_unprepare_from_transfer); + +int mhi_get_channel_doorbell_offset(struct mhi_controller *mhi_cntrl, u32 *chdb_offset) +{ + struct device *dev = &mhi_cntrl->mhi_dev->dev; + void __iomem *base = mhi_cntrl->regs; + int ret; + + ret = mhi_read_reg(mhi_cntrl, base, CHDBOFF, chdb_offset); + if (ret) { + dev_err(dev, "Unable to read CHDBOFF register\n"); + return -EIO; + } + + return 0; +} +EXPORT_SYMBOL_GPL(mhi_get_channel_doorbell_offset); diff --git a/include/linux/mhi.h b/include/linux/mhi.h index d968e1a..cb3b676 100644 --- a/include/linux/mhi.h +++ b/include/linux/mhi.h @@ -816,4 +816,10 @@ int mhi_queue_skb(struct mhi_device *mhi_dev, enum dma_data_direction dir, */ bool mhi_queue_is_full(struct mhi_device *mhi_dev, enum dma_data_direction dir); +/** + * mhi_get_channel_doorbell_offset - Get the channel doorbell offset + * @mhi_cntrl: MHI controller + * @chdb_offset: Channel doorbell offset + */ +int mhi_get_channel_doorbell_offset(struct mhi_controller *mhi_cntrl, u32 *chdb_offset); #endif /* _MHI_H_ */ -- 2.7.4