Subject: [PATCH v2 0/8] PCCI: EPC: Add support to wake up host from D3 states

Here we propose this patch series to add support in PCI endpoint
driver to wake up host from D3 states.

As endpoint cannot send any data/MSI when the D-state is in
D3cold or D3hot. Endpoint needs to bring the device back to D0
to send any kind of data.

For this endpoint needs to send inband PME the device is in D3 state or
toggle wake when the device is D3 cold and vaux is not supplied.

As EPF doestn't know the D-state of the PCI, added a notify op whenever
device state changes.

Based on the D-state the EPF driver decides to wake host either by
toggling wake or by sending PME.

When the MHI state is in M3 MHI driver will wakeup the host using the
wakeup op.

Changes from v1:
- Moved from RFC patch to regular patch
- Inclueded EPF patch and added a new op patch to notify dstate change
Krishna chaitanya chundru (8):
PCI: endpoint: Add dstate change notifier support
PCI: qcom-ep: Add support for D-state change notification
PCI: epf-mhi: Add dtate change op
PCI: endpoint: Add wakeup host API to EPC core
pci: dwc: Add wakeup host op to pci_epc_ops
PCI: qcom: ep: Add wake up host op to dw_pcie_ep_ops
PCI: epf-mhi: Add wakeup host op
bus: mhi: ep: wake up host is the MHI state is in M3

Documentation/PCI/endpoint/pci-endpoint.rst | 11 +++++
drivers/bus/mhi/ep/main.c | 16 ++++++-
drivers/pci/controller/dwc/pcie-designware-ep.c | 12 +++++
drivers/pci/controller/dwc/pcie-designware.h | 3 ++
drivers/pci/controller/dwc/pcie-qcom-ep.c | 37 ++++++++++++++++
drivers/pci/endpoint/functions/pci-epf-mhi.c | 32 ++++++++++++++
drivers/pci/endpoint/pci-epc-core.c | 58 +++++++++++++++++++++++++
include/linux/mhi_ep.h | 4 ++
include/linux/pci-epc.h | 12 +++++
include/linux/pci-epf.h | 1 +
10 files changed, 185 insertions(+), 1 deletion(-)

--
2.7.4



Subject: [PATCH v2 6/8] PCI: qcom: ep: Add wake up host op to dw_pcie_ep_ops

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 <[email protected]>
---
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


Subject: [PATCH v2 1/8] PCI: endpoint: Add dstate change notifier support

Add support to notify the EPF device about the D-state change event
from the EPC device.

Signed-off-by: Krishna chaitanya chundru <[email protected]>
---
Documentation/PCI/endpoint/pci-endpoint.rst | 5 +++++
drivers/pci/endpoint/pci-epc-core.c | 27 +++++++++++++++++++++++++++
include/linux/pci-epc.h | 1 +
include/linux/pci-epf.h | 1 +
4 files changed, 34 insertions(+)

diff --git a/Documentation/PCI/endpoint/pci-endpoint.rst b/Documentation/PCI/endpoint/pci-endpoint.rst
index 4f5622a..0538cdc 100644
--- a/Documentation/PCI/endpoint/pci-endpoint.rst
+++ b/Documentation/PCI/endpoint/pci-endpoint.rst
@@ -78,6 +78,11 @@ by the PCI controller driver.
Cleanup the pci_epc_mem structure allocated during pci_epc_mem_init().


+* pci_epc_dstate_change()
+
+ In order to notify all the function devices that the EPC device has
+ changed its D-state.
+
EPC APIs for the PCI Endpoint Function Driver
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c
index 6c54fa5..cad360f 100644
--- a/drivers/pci/endpoint/pci-epc-core.c
+++ b/drivers/pci/endpoint/pci-epc-core.c
@@ -785,6 +785,33 @@ void pci_epc_bme_notify(struct pci_epc *epc)
EXPORT_SYMBOL_GPL(pci_epc_bme_notify);

/**
+ * pci_epc_dstate_change() - Notify the EPF device that EPC device D-state
+ * has changed
+ * @epc: the EPC device which has change in D-state
+ * @state: the changed D-state
+ *
+ * Invoke to Notify the EPF device that the EPC device has D-state has
+ * changed.
+ */
+void pci_epc_dstate_change(struct pci_epc *epc, pci_power_t state)
+{
+ struct pci_epf *epf;
+
+ if (!epc || IS_ERR(epc))
+ return;
+
+ mutex_lock(&epc->list_lock);
+ list_for_each_entry(epf, &epc->pci_epf, list) {
+ mutex_lock(&epf->lock);
+ if (epf->event_ops && epf->event_ops->dstate_change)
+ epf->event_ops->dstate_change(epf, state);
+ mutex_unlock(&epf->lock);
+ }
+ mutex_unlock(&epc->list_lock);
+}
+EXPORT_SYMBOL_GPL(pci_epc_dstate_change);
+
+/**
* pci_epc_destroy() - destroy the EPC device
* @epc: the EPC device that has to be destroyed
*
diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h
index 5cb6940..26a1108 100644
--- a/include/linux/pci-epc.h
+++ b/include/linux/pci-epc.h
@@ -251,4 +251,5 @@ void __iomem *pci_epc_mem_alloc_addr(struct pci_epc *epc,
phys_addr_t *phys_addr, size_t size);
void pci_epc_mem_free_addr(struct pci_epc *epc, phys_addr_t phys_addr,
void __iomem *virt_addr, size_t size);
+void pci_epc_dstate_change(struct pci_epc *epc, pci_power_t state);
#endif /* __LINUX_PCI_EPC_H */
diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h
index 4b52807..1d3c2a2 100644
--- a/include/linux/pci-epf.h
+++ b/include/linux/pci-epf.h
@@ -79,6 +79,7 @@ struct pci_epc_event_ops {
int (*link_up)(struct pci_epf *epf);
int (*link_down)(struct pci_epf *epf);
int (*bme)(struct pci_epf *epf);
+ int (*dstate_change)(struct pci_epf *epf, pci_power_t state);
};

/**
--
2.7.4


2023-07-07 05:59:02

by Manivannan Sadhasivam

[permalink] [raw]
Subject: Re: [PATCH v2 1/8] PCI: endpoint: Add dstate change notifier support

On Fri, Jun 30, 2023 at 04:22:04PM +0530, Krishna chaitanya chundru wrote:
> Add support to notify the EPF device about the D-state change event
> from the EPC device.
>
> Signed-off-by: Krishna chaitanya chundru <[email protected]>
> ---
> Documentation/PCI/endpoint/pci-endpoint.rst | 5 +++++
> drivers/pci/endpoint/pci-epc-core.c | 27 +++++++++++++++++++++++++++
> include/linux/pci-epc.h | 1 +
> include/linux/pci-epf.h | 1 +
> 4 files changed, 34 insertions(+)
>
> diff --git a/Documentation/PCI/endpoint/pci-endpoint.rst b/Documentation/PCI/endpoint/pci-endpoint.rst
> index 4f5622a..0538cdc 100644
> --- a/Documentation/PCI/endpoint/pci-endpoint.rst
> +++ b/Documentation/PCI/endpoint/pci-endpoint.rst
> @@ -78,6 +78,11 @@ by the PCI controller driver.
> Cleanup the pci_epc_mem structure allocated during pci_epc_mem_init().
>
>
> +* pci_epc_dstate_change()
> +
> + In order to notify all the function devices that the EPC device has
> + changed its D-state.
> +
> EPC APIs for the PCI Endpoint Function Driver
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c
> index 6c54fa5..cad360f 100644
> --- a/drivers/pci/endpoint/pci-epc-core.c
> +++ b/drivers/pci/endpoint/pci-epc-core.c
> @@ -785,6 +785,33 @@ void pci_epc_bme_notify(struct pci_epc *epc)
> EXPORT_SYMBOL_GPL(pci_epc_bme_notify);
>
> /**
> + * pci_epc_dstate_change() - Notify the EPF device that EPC device D-state
> + * has changed
> + * @epc: the EPC device which has change in D-state
> + * @state: the changed D-state
> + *
> + * Invoke to Notify the EPF device that the EPC device has D-state has
> + * changed.
> + */
> +void pci_epc_dstate_change(struct pci_epc *epc, pci_power_t state)

How about "pci_epc_dstate_notity()"?

Rest looks good.

- Mani

> +{
> + struct pci_epf *epf;
> +
> + if (!epc || IS_ERR(epc))
> + return;
> +
> + mutex_lock(&epc->list_lock);
> + list_for_each_entry(epf, &epc->pci_epf, list) {
> + mutex_lock(&epf->lock);
> + if (epf->event_ops && epf->event_ops->dstate_change)
> + epf->event_ops->dstate_change(epf, state);
> + mutex_unlock(&epf->lock);
> + }
> + mutex_unlock(&epc->list_lock);
> +}
> +EXPORT_SYMBOL_GPL(pci_epc_dstate_change);
> +
> +/**
> * pci_epc_destroy() - destroy the EPC device
> * @epc: the EPC device that has to be destroyed
> *
> diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h
> index 5cb6940..26a1108 100644
> --- a/include/linux/pci-epc.h
> +++ b/include/linux/pci-epc.h
> @@ -251,4 +251,5 @@ void __iomem *pci_epc_mem_alloc_addr(struct pci_epc *epc,
> phys_addr_t *phys_addr, size_t size);
> void pci_epc_mem_free_addr(struct pci_epc *epc, phys_addr_t phys_addr,
> void __iomem *virt_addr, size_t size);
> +void pci_epc_dstate_change(struct pci_epc *epc, pci_power_t state);
> #endif /* __LINUX_PCI_EPC_H */
> diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h
> index 4b52807..1d3c2a2 100644
> --- a/include/linux/pci-epf.h
> +++ b/include/linux/pci-epf.h
> @@ -79,6 +79,7 @@ struct pci_epc_event_ops {
> int (*link_up)(struct pci_epf *epf);
> int (*link_down)(struct pci_epf *epf);
> int (*bme)(struct pci_epf *epf);
> + int (*dstate_change)(struct pci_epf *epf, pci_power_t state);
> };
>
> /**
> --
> 2.7.4
>

--
மணிவண்ணன் சதாசிவம்

2023-07-07 06:20:19

by Manivannan Sadhasivam

[permalink] [raw]
Subject: Re: [PATCH v2 6/8] PCI: qcom: ep: Add wake up host op to dw_pcie_ep_ops

On Fri, Jun 30, 2023 at 04:22:09PM +0530, Krishna chaitanya chundru wrote:

Subject prefix should be "PCI: qcom-ep:"

> 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.
>

If the wakeup type is PME, then trigger inband PME by writing to the PARF
PARF_PM_CTRL register, otherwise toggle #WAKE.

> Signed-off-by: Krishna chaitanya chundru <[email protected]>
> ---
> 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;

This is not needed if you use bool. And this debug message is wrong btw since
you are not checking whether the device is in D3 state or not.

- Mani

> + }
> +
> + 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
>

--
மணிவண்ணன் சதாசிவம்

Subject: Re: [PATCH v2 1/8] PCI: endpoint: Add dstate change notifier support


On 7/7/2023 11:14 AM, Manivannan Sadhasivam wrote:
> On Fri, Jun 30, 2023 at 04:22:04PM +0530, Krishna chaitanya chundru wrote:
>> Add support to notify the EPF device about the D-state change event
>> from the EPC device.
>>
>> Signed-off-by: Krishna chaitanya chundru <[email protected]>
>> ---
>> Documentation/PCI/endpoint/pci-endpoint.rst | 5 +++++
>> drivers/pci/endpoint/pci-epc-core.c | 27 +++++++++++++++++++++++++++
>> include/linux/pci-epc.h | 1 +
>> include/linux/pci-epf.h | 1 +
>> 4 files changed, 34 insertions(+)
>>
>> diff --git a/Documentation/PCI/endpoint/pci-endpoint.rst b/Documentation/PCI/endpoint/pci-endpoint.rst
>> index 4f5622a..0538cdc 100644
>> --- a/Documentation/PCI/endpoint/pci-endpoint.rst
>> +++ b/Documentation/PCI/endpoint/pci-endpoint.rst
>> @@ -78,6 +78,11 @@ by the PCI controller driver.
>> Cleanup the pci_epc_mem structure allocated during pci_epc_mem_init().
>>
>>
>> +* pci_epc_dstate_change()
>> +
>> + In order to notify all the function devices that the EPC device has
>> + changed its D-state.
>> +
>> EPC APIs for the PCI Endpoint Function Driver
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c
>> index 6c54fa5..cad360f 100644
>> --- a/drivers/pci/endpoint/pci-epc-core.c
>> +++ b/drivers/pci/endpoint/pci-epc-core.c
>> @@ -785,6 +785,33 @@ void pci_epc_bme_notify(struct pci_epc *epc)
>> EXPORT_SYMBOL_GPL(pci_epc_bme_notify);
>>
>> /**
>> + * pci_epc_dstate_change() - Notify the EPF device that EPC device D-state
>> + * has changed
>> + * @epc: the EPC device which has change in D-state
>> + * @state: the changed D-state
>> + *
>> + * Invoke to Notify the EPF device that the EPC device has D-state has
>> + * changed.
>> + */
>> +void pci_epc_dstate_change(struct pci_epc *epc, pci_power_t state)
> How about "pci_epc_dstate_notity()"?
>
> Rest looks good.
>
> - Mani

sure I will change to pci_epc_dstate_notity

-KC

>
>> +{
>> + struct pci_epf *epf;
>> +
>> + if (!epc || IS_ERR(epc))
>> + return;
>> +
>> + mutex_lock(&epc->list_lock);
>> + list_for_each_entry(epf, &epc->pci_epf, list) {
>> + mutex_lock(&epf->lock);
>> + if (epf->event_ops && epf->event_ops->dstate_change)
>> + epf->event_ops->dstate_change(epf, state);
>> + mutex_unlock(&epf->lock);
>> + }
>> + mutex_unlock(&epc->list_lock);
>> +}
>> +EXPORT_SYMBOL_GPL(pci_epc_dstate_change);
>> +
>> +/**
>> * pci_epc_destroy() - destroy the EPC device
>> * @epc: the EPC device that has to be destroyed
>> *
>> diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h
>> index 5cb6940..26a1108 100644
>> --- a/include/linux/pci-epc.h
>> +++ b/include/linux/pci-epc.h
>> @@ -251,4 +251,5 @@ void __iomem *pci_epc_mem_alloc_addr(struct pci_epc *epc,
>> phys_addr_t *phys_addr, size_t size);
>> void pci_epc_mem_free_addr(struct pci_epc *epc, phys_addr_t phys_addr,
>> void __iomem *virt_addr, size_t size);
>> +void pci_epc_dstate_change(struct pci_epc *epc, pci_power_t state);
>> #endif /* __LINUX_PCI_EPC_H */
>> diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h
>> index 4b52807..1d3c2a2 100644
>> --- a/include/linux/pci-epf.h
>> +++ b/include/linux/pci-epf.h
>> @@ -79,6 +79,7 @@ struct pci_epc_event_ops {
>> int (*link_up)(struct pci_epf *epf);
>> int (*link_down)(struct pci_epf *epf);
>> int (*bme)(struct pci_epf *epf);
>> + int (*dstate_change)(struct pci_epf *epf, pci_power_t state);
>> };
>>
>> /**
>> --
>> 2.7.4
>>

Subject: Re: [PATCH v2 6/8] PCI: qcom: ep: Add wake up host op to dw_pcie_ep_ops


On 7/7/2023 11:40 AM, Manivannan Sadhasivam wrote:
> On Fri, Jun 30, 2023 at 04:22:09PM +0530, Krishna chaitanya chundru wrote:
>
> Subject prefix should be "PCI: qcom-ep:"
>
>> 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.
>>
> If the wakeup type is PME, then trigger inband PME by writing to the PARF
> PARF_PM_CTRL register, otherwise toggle #WAKE.
>
>> Signed-off-by: Krishna chaitanya chundru <[email protected]>
>> ---
>> 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;
> This is not needed if you use bool. And this debug message is wrong btw since
> you are not checking whether the device is in D3 state or not.
>
> - Mani

I will change it bool and will remove these.

- KC

>
>> + }
>> +
>> + 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
>>