Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp22130475rwd; Fri, 30 Jun 2023 04:25:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlHmtmphpQNJaU3Tei/L+7E6MTHAHgtQg6gwXT3qRdqM5kG4wObvEYNwSbUO/r1PA8Z9tkE1 X-Received: by 2002:a17:902:b689:b0:1ad:f138:b2f6 with SMTP id c9-20020a170902b68900b001adf138b2f6mr1643816pls.16.1688124329058; Fri, 30 Jun 2023 04:25:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688124329; cv=none; d=google.com; s=arc-20160816; b=O6zTs4LMUfDqZ9gdMsKlt29sy/mMgg/BW0kHM9aqkOdPN7ORIG1dFrwhG4i/dnvEE9 pGXwnXd9HhKpfEuqkHLCzw90iaQEp3bywzWS+N9+YjM/zOxG6lVOqQylFQH6uercfKHH YP14ESFwOTox1XWT3adN5Tp9yQMx7FrCPjBKz4VX6ze4uepg0LC9Ul85AHM19CHAnlQE UPcHoYvpFvAjQzv/yhmketQFc60BDSJResMQJH0u1WWB5rW3OyQcu6V6TBI6HIKndhKK oWxldLKbH4Ex9rKo1ZrquVqteY54Ho+rUZSTMDkBGQzUoGJpWkzHrvKiKEXrU9xTLDgq D2Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=FEoLul4t0glUrhhThocw3Oy4jFlcsRBbeVj0cl383hs=; fh=rZg3lIvN0abm+bcKRxTVDozxw/bYHp1ZLDp2JcSIm88=; b=0ZhbzsWyc5VF5zqtIXT5VE2rB6fuWJNFEjRF0IYvY9P0E3RWIW9BSryxMz3+1JXW0F 2L7Cb7A7A1cmKuLEQqhlwIbK3KGmYYixN99x9MBHr75Vsd/nfb4ghS0p1ZBSoxWNjDpt tuYhohdVXP88m9S6bZkJw62B+snqm4RuUKVO99b2sRO0GocdRQlD0yXGwpiUyEDJ0eo2 jiGMQCTACyhes6Hiset/fwWVD66j2IAt7/k57a0YvhZjheCdmxe2OLfpUNhNppgqOAdC ebOoQyoGLhpQE4fPApslEoiAekqoiY3babPTADTBM8ioICUyvolRjL5OFsqD9deEtrUm Yxzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=QHRTC8Kk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id li11-20020a170903294b00b001b7d4e7015esi11614411plb.402.2023.06.30.04.25.16; Fri, 30 Jun 2023 04:25:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=QHRTC8Kk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232504AbjF3KxA (ORCPT + 99 others); Fri, 30 Jun 2023 06:53:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232596AbjF3Kw4 (ORCPT ); Fri, 30 Jun 2023 06:52:56 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBA393A94; Fri, 30 Jun 2023 03:52:54 -0700 (PDT) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35UASUXb031403; Fri, 30 Jun 2023 10:52:49 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=FEoLul4t0glUrhhThocw3Oy4jFlcsRBbeVj0cl383hs=; b=QHRTC8KkKq+F/aSLDlD8+XZoGLQ9C3RtElv6OqShEH1Oc9AEeTLSXUsLraUrCuDWbZwg EsTRyxvTGZpYNl62m5iaDc0mBZWkl6nIcS4AOeHYXXTLV9TDhl5zc6PZkbI+ZFwiFQOw Flbuj7WhebhLOJSqpRc4mVfzSmL4HKrWQQ2G1BmkIc8fauUuO2Z1ng0w5bm2fdNotoQq xHXPkk4mJ5ol0Du0LDvo/iFMEeq3FBfPltMRn8dqV9UqFDVQkDTW+QjJZv418n6oQhkx 01FpiIC3gy7EuD7vDMQ4PpO5fysZ0GQ/jFCshObdouxpP4OFd4xmUejMRP2BLUSx8+K/ LQ== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3rhgpgsfsx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jun 2023 10:52:48 +0000 Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 35UAqHkk004751; Fri, 30 Jun 2023 10:52:17 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 3rdsjkpf2j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 30 Jun 2023 10:52:17 +0000 Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 35UAqHqK004736; Fri, 30 Jun 2023 10:52:17 GMT Received: from hu-sgudaval-hyd.qualcomm.com (hu-krichai-hyd.qualcomm.com [10.213.110.112]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTP id 35UAqHQx004729; Fri, 30 Jun 2023 10:52:17 +0000 Received: by hu-sgudaval-hyd.qualcomm.com (Postfix, from userid 4058933) id 6956D4AC5; Fri, 30 Jun 2023 16:22:16 +0530 (+0530) From: Krishna chaitanya chundru To: manivannan.sadhasivam@linaro.org Cc: helgaas@kernel.org, linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_vbadigan@quicinc.com, quic_nitegupt@quicinc.com, quic_skananth@quicinc.com, quic_ramkri@quicinc.com, krzysztof.kozlowski@linaro.org, Krishna chaitanya chundru , Manivannan Sadhasivam , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas Subject: [PATCH v2 6/8] PCI: qcom: ep: Add wake up host op to dw_pcie_ep_ops Date: Fri, 30 Jun 2023 16:22:09 +0530 Message-Id: <1688122331-25478-7-git-send-email-quic_krichai@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com> References: <1688122331-25478-1-git-send-email-quic_krichai@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: qykhW2nVBPsJKmkygPO8NU3Y3GbJ9mRN X-Proofpoint-ORIG-GUID: qykhW2nVBPsJKmkygPO8NU3Y3GbJ9mRN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-30_05,2023-06-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=993 adultscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306300092 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add wakeup host op to dw_pcie_ep_ops to wake up host. If the EPF asks to send PME trigger the inband PME by writing into the parf registers otherwise toggle wake signal. Signed-off-by: Krishna chaitanya chundru --- drivers/pci/controller/dwc/pcie-qcom-ep.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-qcom-ep.c b/drivers/pci/controller/dwc/pcie-qcom-ep.c index e75aec4..e382b4b 100644 --- a/drivers/pci/controller/dwc/pcie-qcom-ep.c +++ b/drivers/pci/controller/dwc/pcie-qcom-ep.c @@ -89,6 +89,7 @@ /* PARF_PM_CTRL register fields */ #define PARF_PM_CTRL_REQ_EXIT_L1 BIT(1) #define PARF_PM_CTRL_READY_ENTR_L23 BIT(2) +#define PARF_PM_CTRL_XMT_PME BIT(4) #define PARF_PM_CTRL_REQ_NOT_ENTR_L1 BIT(5) /* PARF_MHI_CLOCK_RESET_CTRL fields */ @@ -729,10 +730,40 @@ static void qcom_pcie_ep_init(struct dw_pcie_ep *ep) dw_pcie_ep_reset_bar(pci, bar); } +static int qcom_pcie_ep_wakeup_host(struct dw_pcie_ep *ep, u8 func_no, + enum pci_epc_wakeup_host_type type) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct qcom_pcie_ep *pcie_ep = to_pcie_ep(pci); + struct device *dev = pci->dev; + u32 val; + + if (type == PCI_WAKEUP_TOGGLE_WAKE) { + dev_dbg(dev, "Waking up the host by toggling WAKE#\n"); + gpiod_set_value_cansleep(pcie_ep->wake, 1); + usleep_range(WAKE_DELAY_US, WAKE_DELAY_US + 500); + gpiod_set_value_cansleep(pcie_ep->wake, 0); + return 0; + + } else if (type == PCI_WAKEUP_SEND_PME) { + dev_dbg(dev, "Waking up the host using PME\n"); + val = readl_relaxed(pcie_ep->parf + PARF_PM_CTRL); + val |= PARF_PM_CTRL_XMT_PME; + writel_relaxed(val, pcie_ep->parf + PARF_PM_CTRL); + + } else { + dev_err(dev, "Device is not in D3 state wakeup is not supported\n"); + return -EOPNOTSUPP; + } + + return 0; +} + static const struct dw_pcie_ep_ops pci_ep_ops = { .ep_init = qcom_pcie_ep_init, .raise_irq = qcom_pcie_ep_raise_irq, .get_features = qcom_pcie_epc_get_features, + .wakeup_host = qcom_pcie_ep_wakeup_host, }; static int qcom_pcie_ep_probe(struct platform_device *pdev) -- 2.7.4