Message ID | 20231007154806.605-8-quic_kriskura@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp992301vqo; Sat, 7 Oct 2023 08:49:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvZx1unvqfCLkbmlI/LCOpqbYx0ZmyOvFlSLxjop8DRCmZZVYVHtWuiHbqIBVVt9ezOygW X-Received: by 2002:a05:6e02:1ca6:b0:34c:bc10:2573 with SMTP id x6-20020a056e021ca600b0034cbc102573mr13127924ill.3.1696693785794; Sat, 07 Oct 2023 08:49:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696693785; cv=none; d=google.com; s=arc-20160816; b=sisPm0hEXBlNl7jko32aDd84l979gOojVvddVrHL9LfoBp3+/UXgIHPx/xek+uqXKy uuIpUGXIn+1Ju93S7UDIEsqafkteuobZ+/KkPO66RiGzzLIYR8b5OKBkZc11tXWlonwU TfxZ0pCdQrOldEHwSdFaz3LpOMNN1hvR/RsPBqDInl17UUxrBo7mGgLjXY0xLSDWjII4 x1T8Ebsi9dA6dQ8f1DlhGD2frDIunPX43qGajF3AOEOXnxZWD3HjZOb73SgKazb27czA 65FpxEBrs4bQETNK6tp6gxHhqx3H36s/wIMuECU8DxNtUs+IBjz9fNG8oNJFPNIKrspo zc0A== 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 :dkim-signature; bh=k1NDylHKSYeI5UYWFLGJ4cy2Wuo0jxcJAkPAngncU30=; fh=a++TWPJw3Cn9MYBczZLXAB+Eob7lKtyrQCXvx5EPkG8=; b=eRhDJU4zHhne+IgZ5PvJMxW9wBkmdqilJxsJUe4keC3z3TX0kkwf6UXP+JwMeFSTbe vZmxTUKb9ZtAQv3pRtZf+NbMfWDnqVOlYg7HOMYtbOgTMZ+BD77m0FnOUCjY9JMtmVTj K5q2R7mQ5Lp1JYB92h4MrzYqO0Kru1No8eYjsiJBM1Odohgq2zvdLaEbo4R9IMoMWeHe 0FuUf8UbwlyoPD6Y+ZgSboveAVBJzXgIBAsbaGHU5mvDQQL+YFl42l9/eJ+aLY9FddvQ 2WdUoWsROgAbJcNiOzJSAAalC7RBGKwZMgo38Lw7MM4LpZpOfUuAYKiyu+zMrSUwAJEZ tdSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Y88vhYm8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id bx16-20020a056a00429000b0069338b22c0csi3681733pfb.359.2023.10.07.08.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 08:49:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Y88vhYm8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 8B27D80B28A1; Sat, 7 Oct 2023 08:49:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344017AbjJGPt0 (ORCPT <rfc822;pusanteemu@gmail.com> + 17 others); Sat, 7 Oct 2023 11:49:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344053AbjJGPtY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 7 Oct 2023 11:49:24 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7950DF; Sat, 7 Oct 2023 08:49:22 -0700 (PDT) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 397FNpes016503; Sat, 7 Oct 2023 15:49:14 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 : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=k1NDylHKSYeI5UYWFLGJ4cy2Wuo0jxcJAkPAngncU30=; b=Y88vhYm8L8sT4GZgtMHPj0b390RYdw28BmS7jaytKvqYV1R/OGkUuPoS5+rOFsexLa4S NXUSpYsFWjfzsvtpwhz+cZd/hfYlhZneqEeKhVAUD16TNwumxlcIEYAm22+0RN9lrz6d sdAw8OjDriwU3rAes5VBhS5fRjOgVJhW/eh6Km4q0jML8yhXt+lBaIi2fEzMYHhwvHT+ UU5uMtNBS68SbDWOFH6t32VL+dXpS8SmUDB1ZyZ9zUOKxKDhCRC8kywgGk8nY6dA/PER AT03kt5rkLTsimsPlcibWYtcUrqkVVxpoZhCvshKhIuP6iJqfCAtE2gJw1WIKfC+DGvC 1A== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3tjyqc8x78-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 07 Oct 2023 15:49:14 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 397FnDlG003220 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 7 Oct 2023 15:49:13 GMT Received: from hu-kriskura-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.36; Sat, 7 Oct 2023 08:49:07 -0700 From: Krishna Kurapati <quic_kriskura@quicinc.com> To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Philipp Zabel <p.zabel@pengutronix.de>, "Andy Gross" <agross@kernel.org>, Bjorn Andersson <andersson@kernel.org>, "Konrad Dybcio" <konrad.dybcio@linaro.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Felipe Balbi <balbi@kernel.org>, Wesley Cheng <quic_wcheng@quicinc.com>, Johan Hovold <johan@kernel.org> CC: <linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>, <devicetree@vger.kernel.org>, <quic_pkondeti@quicinc.com>, <quic_ppratap@quicinc.com>, <quic_jackp@quicinc.com>, <ahalaney@redhat.com>, <quic_shazhuss@quicinc.com>, Krishna Kurapati <quic_kriskura@quicinc.com> Subject: [PATCH v13 07/10] usb: dwc3: qcom: Add multiport suspend/resume support for wrapper Date: Sat, 7 Oct 2023 21:18:03 +0530 Message-ID: <20231007154806.605-8-quic_kriskura@quicinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231007154806.605-1-quic_kriskura@quicinc.com> References: <20231007154806.605-1-quic_kriskura@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: RaxiRJJM0eIqYDaqgQSyQ3fvy4IzSN_H X-Proofpoint-ORIG-GUID: RaxiRJJM0eIqYDaqgQSyQ3fvy4IzSN_H X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-07_12,2023-10-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=886 phishscore=0 suspectscore=0 mlxscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310070143 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sat, 07 Oct 2023 08:49:38 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779112383076371205 X-GMAIL-MSGID: 1779112383076371205 |
Series |
Add multiport support for DWC3 controllers
|
|
Commit Message
Krishna Kurapati
Oct. 7, 2023, 3:48 p.m. UTC
QCOM SoC SA8295P's tertiary quad port controller supports 2 HS+SS
ports and 2 HS only ports. Add support for configuring PWR_EVENT_IRQ's
for all the ports during suspend/resume.
Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
---
drivers/usb/dwc3/dwc3-qcom.c | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
Comments
On Sat, Oct 07, 2023 at 09:18:03PM +0530, Krishna Kurapati wrote: > QCOM SoC SA8295P's tertiary quad port controller supports 2 HS+SS > ports and 2 HS only ports. Add support for configuring PWR_EVENT_IRQ's > for all the ports during suspend/resume. No need to mention SA8295P as this is needed for all multiport controllers. Say something about adding support for multiport controllers generally instead and mention what the power event irqs are used for. > Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com> > --- > drivers/usb/dwc3/dwc3-qcom.c | 35 ++++++++++++++++++++++++++++------- > 1 file changed, 28 insertions(+), 7 deletions(-) > > diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c > index 651b9775a0c2..dbd4239e61c9 100644 > --- a/drivers/usb/dwc3/dwc3-qcom.c > +++ b/drivers/usb/dwc3/dwc3-qcom.c > @@ -37,7 +37,11 @@ > #define PIPE3_PHYSTATUS_SW BIT(3) > #define PIPE_UTMI_CLK_DIS BIT(8) > > -#define PWR_EVNT_IRQ_STAT_REG 0x58 > +#define PWR_EVNT_IRQ1_STAT_REG 0x58 > +#define PWR_EVNT_IRQ2_STAT_REG 0x1dc > +#define PWR_EVNT_IRQ3_STAT_REG 0x228 > +#define PWR_EVNT_IRQ4_STAT_REG 0x238 Not sure these defines makes sense on their own. You now only use them via the array below. I think I already asked you whether these offsets depend on SoC and you said no, right? > + > #define PWR_EVNT_LPM_IN_L2_MASK BIT(4) > #define PWR_EVNT_LPM_OUT_L2_MASK BIT(5) > > @@ -107,6 +111,19 @@ struct dwc3_qcom { > int num_ports; > }; > > +/* > + * Currently non-multiport controller have only one PWR_EVENT_IRQ register, > + * but multiport controllers like SA8295 contain upto 4 of them. > + */ Please try not talk about "currently" and as things are likely to change or, in fact, even *are* changing with your very patch series. Again, this is not SA8295 specific. > +#define NUM_PWR_EVENT_STAT_REGS 4 You already have MAX_PORTS, why are you defining a new define that will always have to be equal to MAX_PORTS? > + > +static u32 pwr_evnt_irq_stat_reg_offset[NUM_PWR_EVENT_STAT_REGS] = { missing const > + PWR_EVNT_IRQ1_STAT_REG, > + PWR_EVNT_IRQ2_STAT_REG, > + PWR_EVNT_IRQ3_STAT_REG, > + PWR_EVNT_IRQ4_STAT_REG, > +}; > + > static inline void dwc3_qcom_setbits(void __iomem *base, u32 offset, u32 val) > { > u32 reg; > @@ -446,9 +463,11 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup) > if (qcom->is_suspended) > return 0; > > - val = readl(qcom->qscratch_base + PWR_EVNT_IRQ_STAT_REG); > - if (!(val & PWR_EVNT_LPM_IN_L2_MASK)) > - dev_err(qcom->dev, "HS-PHY not in L2\n"); > + for (i = 0; i < qcom->num_ports; i++) { > + val = readl(qcom->qscratch_base + pwr_evnt_irq_stat_reg_offset[i]); > + if (!(val & PWR_EVNT_LPM_IN_L2_MASK)) > + dev_err(qcom->dev, "HS-PHY not in L2\n"); Error message should contain the port number. > + } > > for (i = qcom->num_clocks - 1; i >= 0; i--) > clk_disable_unprepare(qcom->clks[i]); > @@ -494,9 +513,11 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom, bool wakeup) > dev_warn(qcom->dev, "failed to enable interconnect: %d\n", ret); > > /* Clear existing events from PHY related to L2 in/out */ > - dwc3_qcom_setbits(qcom->qscratch_base, PWR_EVNT_IRQ_STAT_REG, > - PWR_EVNT_LPM_IN_L2_MASK | PWR_EVNT_LPM_OUT_L2_MASK); > - > + for (i = 0; i < qcom->num_ports; i++) { > + dwc3_qcom_setbits(qcom->qscratch_base, > + pwr_evnt_irq_stat_reg_offset[i], > + PWR_EVNT_LPM_IN_L2_MASK | PWR_EVNT_LPM_OUT_L2_MASK); Again, continuation lines should be indented at least two tabs further. > + } > qcom->is_suspended = false; > > return 0; Johan
On 10/23/2023 9:28 PM, Johan Hovold wrote: > On Sat, Oct 07, 2023 at 09:18:03PM +0530, Krishna Kurapati wrote: >> QCOM SoC SA8295P's tertiary quad port controller supports 2 HS+SS >> ports and 2 HS only ports. Add support for configuring PWR_EVENT_IRQ's >> for all the ports during suspend/resume. > > No need to mention SA8295P as this is needed for all multiport > controllers. > > Say something about adding support for multiport controllers generally > instead and mention what the power event irqs are used for. > ACK. >> Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com> >> --- >> drivers/usb/dwc3/dwc3-qcom.c | 35 ++++++++++++++++++++++++++++------- >> 1 file changed, 28 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c >> index 651b9775a0c2..dbd4239e61c9 100644 >> --- a/drivers/usb/dwc3/dwc3-qcom.c >> +++ b/drivers/usb/dwc3/dwc3-qcom.c >> @@ -37,7 +37,11 @@ >> #define PIPE3_PHYSTATUS_SW BIT(3) >> #define PIPE_UTMI_CLK_DIS BIT(8) >> >> -#define PWR_EVNT_IRQ_STAT_REG 0x58 >> +#define PWR_EVNT_IRQ1_STAT_REG 0x58 >> +#define PWR_EVNT_IRQ2_STAT_REG 0x1dc >> +#define PWR_EVNT_IRQ3_STAT_REG 0x228 >> +#define PWR_EVNT_IRQ4_STAT_REG 0x238 > > Not sure these defines makes sense on their own. You now only use them > via the array below. > > I think I already asked you whether these offsets depend on SoC and you > said no, right? > There are only 3 QC SoC's today that support multiport. The offsets mentioned here are for SC8280 based platforms. For Sc8180 based platforms, these are the offsets: USB3_MP_PWR_EVNT_IRQ_STAT 0xA4F8858 USB3_MP_PWR_EVNT_IRQ_1_STAT 0xA4F89DC These would translate to 0x58 and 0x1DC And for SX8380 the values are as follows: USB3_MP_PWR_EVNT_IRQ_STAT 0xA4F8858 USB3_MP_PWR_EVNT_IRQ_1_STAT 0xA4F89DC So here also, the offsets are same. 0x58 and 0x1DC. So these are not SoC specific (atleast looking at the controllers present). But there is no mathematical pattern to denote this as in the following form (x + (port_num) * y). So made an array like this. >> + >> #define PWR_EVNT_LPM_IN_L2_MASK BIT(4) >> #define PWR_EVNT_LPM_OUT_L2_MASK BIT(5) >> >> @@ -107,6 +111,19 @@ struct dwc3_qcom { >> int num_ports; >> }; >> >> +/* >> + * Currently non-multiport controller have only one PWR_EVENT_IRQ register, >> + * but multiport controllers like SA8295 contain upto 4 of them. >> + */ > > Please try not talk about "currently" and as things are likely to > change or, in fact, even *are* changing with your very patch series. > > Again, this is not SA8295 specific. > >> +#define NUM_PWR_EVENT_STAT_REGS 4 > > You already have MAX_PORTS, why are you defining a new define that will > always have to be equal to MAX_PORTS? > Do you recommend using the same max_ports ? If so, I can remove this macro altogether. >> + >> +static u32 pwr_evnt_irq_stat_reg_offset[NUM_PWR_EVENT_STAT_REGS] = { > > missing const > >> + PWR_EVNT_IRQ1_STAT_REG, >> + PWR_EVNT_IRQ2_STAT_REG, >> + PWR_EVNT_IRQ3_STAT_REG, >> + PWR_EVNT_IRQ4_STAT_REG, >> +}; >> + >> static inline void dwc3_qcom_setbits(void __iomem *base, u32 offset, u32 val) >> { >> u32 reg; >> @@ -446,9 +463,11 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup) >> if (qcom->is_suspended) >> return 0; >> >> - val = readl(qcom->qscratch_base + PWR_EVNT_IRQ_STAT_REG); >> - if (!(val & PWR_EVNT_LPM_IN_L2_MASK)) >> - dev_err(qcom->dev, "HS-PHY not in L2\n"); >> + for (i = 0; i < qcom->num_ports; i++) { >> + val = readl(qcom->qscratch_base + pwr_evnt_irq_stat_reg_offset[i]); >> + if (!(val & PWR_EVNT_LPM_IN_L2_MASK)) >> + dev_err(qcom->dev, "HS-PHY not in L2\n"); > > Error message should contain the port number. > ACK >> + } >> >> for (i = qcom->num_clocks - 1; i >= 0; i--) >> clk_disable_unprepare(qcom->clks[i]); >> @@ -494,9 +513,11 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom, bool wakeup) >> dev_warn(qcom->dev, "failed to enable interconnect: %d\n", ret); >> >> /* Clear existing events from PHY related to L2 in/out */ >> - dwc3_qcom_setbits(qcom->qscratch_base, PWR_EVNT_IRQ_STAT_REG, >> - PWR_EVNT_LPM_IN_L2_MASK | PWR_EVNT_LPM_OUT_L2_MASK); >> - >> + for (i = 0; i < qcom->num_ports; i++) { >> + dwc3_qcom_setbits(qcom->qscratch_base, >> + pwr_evnt_irq_stat_reg_offset[i], >> + PWR_EVNT_LPM_IN_L2_MASK | PWR_EVNT_LPM_OUT_L2_MASK); > > Again, continuation lines should be indented at least two tabs further. > ACK. Thanks for the review. Regards, Krishna,
On Mon, Oct 23, 2023 at 10:52:38PM +0530, Krishna Kurapati PSSNV wrote: > On 10/23/2023 9:28 PM, Johan Hovold wrote: > > On Sat, Oct 07, 2023 at 09:18:03PM +0530, Krishna Kurapati wrote: > >> -#define PWR_EVNT_IRQ_STAT_REG 0x58 > >> +#define PWR_EVNT_IRQ1_STAT_REG 0x58 > >> +#define PWR_EVNT_IRQ2_STAT_REG 0x1dc > >> +#define PWR_EVNT_IRQ3_STAT_REG 0x228 > >> +#define PWR_EVNT_IRQ4_STAT_REG 0x238 > > > > Not sure these defines makes sense on their own. You now only use them > > via the array below. > > > > I think I already asked you whether these offsets depend on SoC and you > > said no, right? > > > There are only 3 QC SoC's today that support multiport. > The offsets mentioned here are for SC8280 based platforms. > > For Sc8180 based platforms, these are the offsets: > USB3_MP_PWR_EVNT_IRQ_STAT 0xA4F8858 > USB3_MP_PWR_EVNT_IRQ_1_STAT 0xA4F89DC > > These would translate to 0x58 and 0x1DC > > And for SX8380 the values are as follows: > > USB3_MP_PWR_EVNT_IRQ_STAT 0xA4F8858 > USB3_MP_PWR_EVNT_IRQ_1_STAT 0xA4F89DC > > So here also, the offsets are same. 0x58 and 0x1DC. > So these are not SoC specific (atleast looking at the controllers > present). But there is no mathematical pattern to denote this as in the > following form (x + (port_num) * y). So made an array like this. Sounds good. Thanks for confirming. > >> +#define NUM_PWR_EVENT_STAT_REGS 4 > > > > You already have MAX_PORTS, why are you defining a new define that will > > always have to be equal to MAX_PORTS? > > > Do you recommend using the same max_ports ? If so, I can remove this > macro altogether. Indeed, and perhaps also some (compile-time) assert as the driver breaks if they ever get out of sync. Johan
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c index 651b9775a0c2..dbd4239e61c9 100644 --- a/drivers/usb/dwc3/dwc3-qcom.c +++ b/drivers/usb/dwc3/dwc3-qcom.c @@ -37,7 +37,11 @@ #define PIPE3_PHYSTATUS_SW BIT(3) #define PIPE_UTMI_CLK_DIS BIT(8) -#define PWR_EVNT_IRQ_STAT_REG 0x58 +#define PWR_EVNT_IRQ1_STAT_REG 0x58 +#define PWR_EVNT_IRQ2_STAT_REG 0x1dc +#define PWR_EVNT_IRQ3_STAT_REG 0x228 +#define PWR_EVNT_IRQ4_STAT_REG 0x238 + #define PWR_EVNT_LPM_IN_L2_MASK BIT(4) #define PWR_EVNT_LPM_OUT_L2_MASK BIT(5) @@ -107,6 +111,19 @@ struct dwc3_qcom { int num_ports; }; +/* + * Currently non-multiport controller have only one PWR_EVENT_IRQ register, + * but multiport controllers like SA8295 contain upto 4 of them. + */ +#define NUM_PWR_EVENT_STAT_REGS 4 + +static u32 pwr_evnt_irq_stat_reg_offset[NUM_PWR_EVENT_STAT_REGS] = { + PWR_EVNT_IRQ1_STAT_REG, + PWR_EVNT_IRQ2_STAT_REG, + PWR_EVNT_IRQ3_STAT_REG, + PWR_EVNT_IRQ4_STAT_REG, +}; + static inline void dwc3_qcom_setbits(void __iomem *base, u32 offset, u32 val) { u32 reg; @@ -446,9 +463,11 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup) if (qcom->is_suspended) return 0; - val = readl(qcom->qscratch_base + PWR_EVNT_IRQ_STAT_REG); - if (!(val & PWR_EVNT_LPM_IN_L2_MASK)) - dev_err(qcom->dev, "HS-PHY not in L2\n"); + for (i = 0; i < qcom->num_ports; i++) { + val = readl(qcom->qscratch_base + pwr_evnt_irq_stat_reg_offset[i]); + if (!(val & PWR_EVNT_LPM_IN_L2_MASK)) + dev_err(qcom->dev, "HS-PHY not in L2\n"); + } for (i = qcom->num_clocks - 1; i >= 0; i--) clk_disable_unprepare(qcom->clks[i]); @@ -494,9 +513,11 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom, bool wakeup) dev_warn(qcom->dev, "failed to enable interconnect: %d\n", ret); /* Clear existing events from PHY related to L2 in/out */ - dwc3_qcom_setbits(qcom->qscratch_base, PWR_EVNT_IRQ_STAT_REG, - PWR_EVNT_LPM_IN_L2_MASK | PWR_EVNT_LPM_OUT_L2_MASK); - + for (i = 0; i < qcom->num_ports; i++) { + dwc3_qcom_setbits(qcom->qscratch_base, + pwr_evnt_irq_stat_reg_offset[i], + PWR_EVNT_LPM_IN_L2_MASK | PWR_EVNT_LPM_OUT_L2_MASK); + } qcom->is_suspended = false; return 0;