diff options
-rw-r--r-- | drivers/i2c/busses/i2c-at91.c | 37 |
1 files changed, 3 insertions, 34 deletions
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c index 77fb6472fd5d..8790f2332458 100644 --- a/drivers/i2c/busses/i2c-at91.c +++ b/drivers/i2c/busses/i2c-at91.c | |||
@@ -75,7 +75,6 @@ struct at91_twi_pdata { | |||
75 | unsigned clk_max_div; | 75 | unsigned clk_max_div; |
76 | unsigned clk_offset; | 76 | unsigned clk_offset; |
77 | bool has_unre_flag; | 77 | bool has_unre_flag; |
78 | bool has_dma_support; | ||
79 | struct at_dma_slave dma_slave; | 78 | struct at_dma_slave dma_slave; |
80 | }; | 79 | }; |
81 | 80 | ||
@@ -556,35 +555,30 @@ static struct at91_twi_pdata at91rm9200_config = { | |||
556 | .clk_max_div = 5, | 555 | .clk_max_div = 5, |
557 | .clk_offset = 3, | 556 | .clk_offset = 3, |
558 | .has_unre_flag = true, | 557 | .has_unre_flag = true, |
559 | .has_dma_support = false, | ||
560 | }; | 558 | }; |
561 | 559 | ||
562 | static struct at91_twi_pdata at91sam9261_config = { | 560 | static struct at91_twi_pdata at91sam9261_config = { |
563 | .clk_max_div = 5, | 561 | .clk_max_div = 5, |
564 | .clk_offset = 4, | 562 | .clk_offset = 4, |
565 | .has_unre_flag = false, | 563 | .has_unre_flag = false, |
566 | .has_dma_support = false, | ||
567 | }; | 564 | }; |
568 | 565 | ||
569 | static struct at91_twi_pdata at91sam9260_config = { | 566 | static struct at91_twi_pdata at91sam9260_config = { |
570 | .clk_max_div = 7, | 567 | .clk_max_div = 7, |
571 | .clk_offset = 4, | 568 | .clk_offset = 4, |
572 | .has_unre_flag = false, | 569 | .has_unre_flag = false, |
573 | .has_dma_support = false, | ||
574 | }; | 570 | }; |
575 | 571 | ||
576 | static struct at91_twi_pdata at91sam9g20_config = { | 572 | static struct at91_twi_pdata at91sam9g20_config = { |
577 | .clk_max_div = 7, | 573 | .clk_max_div = 7, |
578 | .clk_offset = 4, | 574 | .clk_offset = 4, |
579 | .has_unre_flag = false, | 575 | .has_unre_flag = false, |
580 | .has_dma_support = false, | ||
581 | }; | 576 | }; |
582 | 577 | ||
583 | static struct at91_twi_pdata at91sam9g10_config = { | 578 | static struct at91_twi_pdata at91sam9g10_config = { |
584 | .clk_max_div = 7, | 579 | .clk_max_div = 7, |
585 | .clk_offset = 4, | 580 | .clk_offset = 4, |
586 | .has_unre_flag = false, | 581 | .has_unre_flag = false, |
587 | .has_dma_support = false, | ||
588 | }; | 582 | }; |
589 | 583 | ||
590 | static const struct platform_device_id at91_twi_devtypes[] = { | 584 | static const struct platform_device_id at91_twi_devtypes[] = { |
@@ -613,7 +607,6 @@ static struct at91_twi_pdata at91sam9x5_config = { | |||
613 | .clk_max_div = 7, | 607 | .clk_max_div = 7, |
614 | .clk_offset = 4, | 608 | .clk_offset = 4, |
615 | .has_unre_flag = false, | 609 | .has_unre_flag = false, |
616 | .has_dma_support = true, | ||
617 | }; | 610 | }; |
618 | 611 | ||
619 | static const struct of_device_id atmel_twi_dt_ids[] = { | 612 | static const struct of_device_id atmel_twi_dt_ids[] = { |
@@ -642,30 +635,11 @@ static const struct of_device_id atmel_twi_dt_ids[] = { | |||
642 | MODULE_DEVICE_TABLE(of, atmel_twi_dt_ids); | 635 | MODULE_DEVICE_TABLE(of, atmel_twi_dt_ids); |
643 | #endif | 636 | #endif |
644 | 637 | ||
645 | static bool filter(struct dma_chan *chan, void *pdata) | ||
646 | { | ||
647 | struct at91_twi_pdata *sl_pdata = pdata; | ||
648 | struct at_dma_slave *sl; | ||
649 | |||
650 | if (!sl_pdata) | ||
651 | return false; | ||
652 | |||
653 | sl = &sl_pdata->dma_slave; | ||
654 | if (sl && (sl->dma_dev == chan->device->dev)) { | ||
655 | chan->private = sl; | ||
656 | return true; | ||
657 | } else { | ||
658 | return false; | ||
659 | } | ||
660 | } | ||
661 | |||
662 | static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr) | 638 | static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr) |
663 | { | 639 | { |
664 | int ret = 0; | 640 | int ret = 0; |
665 | struct at91_twi_pdata *pdata = dev->pdata; | ||
666 | struct dma_slave_config slave_config; | 641 | struct dma_slave_config slave_config; |
667 | struct at91_twi_dma *dma = &dev->dma; | 642 | struct at91_twi_dma *dma = &dev->dma; |
668 | dma_cap_mask_t mask; | ||
669 | 643 | ||
670 | memset(&slave_config, 0, sizeof(slave_config)); | 644 | memset(&slave_config, 0, sizeof(slave_config)); |
671 | slave_config.src_addr = (dma_addr_t)phy_addr + AT91_TWI_RHR; | 645 | slave_config.src_addr = (dma_addr_t)phy_addr + AT91_TWI_RHR; |
@@ -676,19 +650,14 @@ static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr) | |||
676 | slave_config.dst_maxburst = 1; | 650 | slave_config.dst_maxburst = 1; |
677 | slave_config.device_fc = false; | 651 | slave_config.device_fc = false; |
678 | 652 | ||
679 | dma_cap_zero(mask); | 653 | dma->chan_tx = dma_request_slave_channel(dev->dev, "tx"); |
680 | dma_cap_set(DMA_SLAVE, mask); | ||
681 | |||
682 | dma->chan_tx = dma_request_slave_channel_compat(mask, filter, pdata, | ||
683 | dev->dev, "tx"); | ||
684 | if (!dma->chan_tx) { | 654 | if (!dma->chan_tx) { |
685 | dev_err(dev->dev, "can't get a DMA channel for tx\n"); | 655 | dev_err(dev->dev, "can't get a DMA channel for tx\n"); |
686 | ret = -EBUSY; | 656 | ret = -EBUSY; |
687 | goto error; | 657 | goto error; |
688 | } | 658 | } |
689 | 659 | ||
690 | dma->chan_rx = dma_request_slave_channel_compat(mask, filter, pdata, | 660 | dma->chan_rx = dma_request_slave_channel(dev->dev, "rx"); |
691 | dev->dev, "rx"); | ||
692 | if (!dma->chan_rx) { | 661 | if (!dma->chan_rx) { |
693 | dev_err(dev->dev, "can't get a DMA channel for rx\n"); | 662 | dev_err(dev->dev, "can't get a DMA channel for rx\n"); |
694 | ret = -EBUSY; | 663 | ret = -EBUSY; |
@@ -787,7 +756,7 @@ static int at91_twi_probe(struct platform_device *pdev) | |||
787 | } | 756 | } |
788 | clk_prepare_enable(dev->clk); | 757 | clk_prepare_enable(dev->clk); |
789 | 758 | ||
790 | if (dev->pdata->has_dma_support) { | 759 | if (dev->dev->of_node) { |
791 | if (at91_twi_configure_dma(dev, phy_addr) == 0) | 760 | if (at91_twi_configure_dma(dev, phy_addr) == 0) |
792 | dev->use_dma = true; | 761 | dev->use_dma = true; |
793 | } | 762 | } |