Commit e3dd8cd4 authored by Alexandre Bounine's avatar Alexandre Bounine Committed by Linus Torvalds

rapidio/tsi721: add shutdown notification callback

Add device driver specific shutdown notification callback.
Signed-off-by: default avatarAlexandre Bounine <alexandre.bounine@idt.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Aurelien Jacquiot <a-jacquiot@ti.com>
Cc: Andre van Herk <andre.van.herk@prodrive-technologies.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 83dc2cbc
...@@ -2638,6 +2638,8 @@ static int tsi721_probe(struct pci_dev *pdev, ...@@ -2638,6 +2638,8 @@ static int tsi721_probe(struct pci_dev *pdev,
if (err) if (err)
goto err_free_consistent; goto err_free_consistent;
pci_set_drvdata(pdev, priv);
return 0; return 0;
err_free_consistent: err_free_consistent:
...@@ -2660,6 +2662,18 @@ static int tsi721_probe(struct pci_dev *pdev, ...@@ -2660,6 +2662,18 @@ static int tsi721_probe(struct pci_dev *pdev,
return err; return err;
} }
static void tsi721_shutdown(struct pci_dev *pdev)
{
struct tsi721_device *priv = pci_get_drvdata(pdev);
dev_dbg(&pdev->dev, "RIO: %s\n", __func__);
tsi721_disable_ints(priv);
tsi721_dma_stop_all(priv);
pci_clear_master(pdev);
pci_disable_device(pdev);
}
static const struct pci_device_id tsi721_pci_tbl[] = { static const struct pci_device_id tsi721_pci_tbl[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_IDT, PCI_DEVICE_ID_TSI721) }, { PCI_DEVICE(PCI_VENDOR_ID_IDT, PCI_DEVICE_ID_TSI721) },
{ 0, } /* terminate list */ { 0, } /* terminate list */
...@@ -2671,6 +2685,7 @@ static struct pci_driver tsi721_driver = { ...@@ -2671,6 +2685,7 @@ static struct pci_driver tsi721_driver = {
.name = "tsi721", .name = "tsi721",
.id_table = tsi721_pci_tbl, .id_table = tsi721_pci_tbl,
.probe = tsi721_probe, .probe = tsi721_probe,
.shutdown = tsi721_shutdown,
}; };
static int __init tsi721_init(void) static int __init tsi721_init(void)
......
...@@ -866,6 +866,9 @@ struct tsi721_device { ...@@ -866,6 +866,9 @@ struct tsi721_device {
#ifdef CONFIG_RAPIDIO_DMA_ENGINE #ifdef CONFIG_RAPIDIO_DMA_ENGINE
extern void tsi721_bdma_handler(struct tsi721_bdma_chan *bdma_chan); extern void tsi721_bdma_handler(struct tsi721_bdma_chan *bdma_chan);
extern int tsi721_register_dma(struct tsi721_device *priv); extern int tsi721_register_dma(struct tsi721_device *priv);
extern void tsi721_dma_stop_all(struct tsi721_device *priv);
#else
#define tsi721_dma_stop_all(priv) do {} while (0)
#endif #endif
#endif #endif
...@@ -852,6 +852,36 @@ static int tsi721_terminate_all(struct dma_chan *dchan) ...@@ -852,6 +852,36 @@ static int tsi721_terminate_all(struct dma_chan *dchan)
return 0; return 0;
} }
static void tsi721_dma_stop(struct tsi721_bdma_chan *bdma_chan)
{
if (!bdma_chan->active)
return;
spin_lock_bh(&bdma_chan->lock);
if (!tsi721_dma_is_idle(bdma_chan)) {
int timeout = 100000;
/* stop the transfer in progress */
iowrite32(TSI721_DMAC_CTL_SUSP,
bdma_chan->regs + TSI721_DMAC_CTL);
/* Wait until DMA channel stops */
while (!tsi721_dma_is_idle(bdma_chan) && --timeout)
udelay(1);
}
spin_unlock_bh(&bdma_chan->lock);
}
void tsi721_dma_stop_all(struct tsi721_device *priv)
{
int i;
for (i = 0; i < TSI721_DMA_MAXCH; i++) {
if (i != TSI721_DMACH_MAINT)
tsi721_dma_stop(&priv->bdma[i]);
}
}
int tsi721_register_dma(struct tsi721_device *priv) int tsi721_register_dma(struct tsi721_device *priv)
{ {
int i; int i;
......
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