Commit 4a94d7e3 authored by Martin Hundebøll's avatar Martin Hundebøll Committed by Marc Kleine-Budde

can: m_can: allow keeping the transceiver running in suspend

Add a flag to the device class structure that leaves the chip in a
running state with rx interrupt enabled, so that an m_can device driver
can configure and use the interrupt as a wakeup source.
Signed-off-by: default avatarMartin Hundebøll <martin@geanix.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent b00cf4f6
...@@ -2382,7 +2382,15 @@ int m_can_class_suspend(struct device *dev) ...@@ -2382,7 +2382,15 @@ int m_can_class_suspend(struct device *dev)
if (netif_running(ndev)) { if (netif_running(ndev)) {
netif_stop_queue(ndev); netif_stop_queue(ndev);
netif_device_detach(ndev); netif_device_detach(ndev);
/* leave the chip running with rx interrupt enabled if it is
* used as a wake-up source.
*/
if (cdev->pm_wake_source)
m_can_write(cdev, M_CAN_IE, IR_RF0N);
else
m_can_stop(ndev); m_can_stop(ndev);
m_can_clk_stop(cdev); m_can_clk_stop(cdev);
} }
...@@ -2409,12 +2417,16 @@ int m_can_class_resume(struct device *dev) ...@@ -2409,12 +2417,16 @@ int m_can_class_resume(struct device *dev)
ret = m_can_clk_start(cdev); ret = m_can_clk_start(cdev);
if (ret) if (ret)
return ret; return ret;
if (cdev->pm_wake_source) {
m_can_write(cdev, M_CAN_IE, cdev->active_interrupts);
} else {
ret = m_can_start(ndev); ret = m_can_start(ndev);
if (ret) { if (ret) {
m_can_clk_stop(cdev); m_can_clk_stop(cdev);
return ret; return ret;
} }
}
netif_device_attach(ndev); netif_device_attach(ndev);
netif_start_queue(ndev); netif_start_queue(ndev);
......
...@@ -97,6 +97,7 @@ struct m_can_classdev { ...@@ -97,6 +97,7 @@ struct m_can_classdev {
u32 irqstatus; u32 irqstatus;
int pm_clock_support; int pm_clock_support;
int pm_wake_source;
int is_peripheral; int is_peripheral;
// Cached M_CAN_IE register content // Cached M_CAN_IE register content
......
...@@ -125,6 +125,7 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) ...@@ -125,6 +125,7 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
mcan_class->dev = &pci->dev; mcan_class->dev = &pci->dev;
mcan_class->net->irq = pci_irq_vector(pci, 0); mcan_class->net->irq = pci_irq_vector(pci, 0);
mcan_class->pm_clock_support = 1; mcan_class->pm_clock_support = 1;
mcan_class->pm_wake_source = 0;
mcan_class->can.clock.freq = id->driver_data; mcan_class->can.clock.freq = id->driver_data;
mcan_class->ops = &m_can_pci_ops; mcan_class->ops = &m_can_pci_ops;
......
...@@ -139,6 +139,7 @@ static int m_can_plat_probe(struct platform_device *pdev) ...@@ -139,6 +139,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
mcan_class->net->irq = irq; mcan_class->net->irq = irq;
mcan_class->pm_clock_support = 1; mcan_class->pm_clock_support = 1;
mcan_class->pm_wake_source = 0;
mcan_class->can.clock.freq = clk_get_rate(mcan_class->cclk); mcan_class->can.clock.freq = clk_get_rate(mcan_class->cclk);
mcan_class->dev = &pdev->dev; mcan_class->dev = &pdev->dev;
mcan_class->transceiver = transceiver; mcan_class->transceiver = transceiver;
......
...@@ -411,6 +411,7 @@ static int tcan4x5x_can_probe(struct spi_device *spi) ...@@ -411,6 +411,7 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
priv->spi = spi; priv->spi = spi;
mcan_class->pm_clock_support = 0; mcan_class->pm_clock_support = 0;
mcan_class->pm_wake_source = 0;
mcan_class->can.clock.freq = freq; mcan_class->can.clock.freq = freq;
mcan_class->dev = &spi->dev; mcan_class->dev = &spi->dev;
mcan_class->ops = &tcan4x5x_ops; mcan_class->ops = &tcan4x5x_ops;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment