aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-mxs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses/i2c-mxs.c')
-rw-r--r--drivers/i2c/busses/i2c-mxs.c40
1 files changed, 3 insertions, 37 deletions
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index c67d89fc6254..2039f230482d 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -31,7 +31,6 @@
31#include <linux/of_i2c.h> 31#include <linux/of_i2c.h>
32#include <linux/dma-mapping.h> 32#include <linux/dma-mapping.h>
33#include <linux/dmaengine.h> 33#include <linux/dmaengine.h>
34#include <linux/fsl/mxs-dma.h>
35 34
36#define DRIVER_NAME "mxs-i2c" 35#define DRIVER_NAME "mxs-i2c"
37 36
@@ -118,9 +117,7 @@ struct mxs_i2c_dev {
118 uint32_t timing1; 117 uint32_t timing1;
119 118
120 /* DMA support components */ 119 /* DMA support components */
121 int dma_channel;
122 struct dma_chan *dmach; 120 struct dma_chan *dmach;
123 struct mxs_dma_data dma_data;
124 uint32_t pio_data[2]; 121 uint32_t pio_data[2];
125 uint32_t addr_data; 122 uint32_t addr_data;
126 struct scatterlist sg_io[2]; 123 struct scatterlist sg_io[2];
@@ -581,21 +578,6 @@ static const struct i2c_algorithm mxs_i2c_algo = {
581 .functionality = mxs_i2c_func, 578 .functionality = mxs_i2c_func,
582}; 579};
583 580
584static bool mxs_i2c_dma_filter(struct dma_chan *chan, void *param)
585{
586 struct mxs_i2c_dev *i2c = param;
587
588 if (!mxs_dma_is_apbx(chan))
589 return false;
590
591 if (chan->chan_id != i2c->dma_channel)
592 return false;
593
594 chan->private = &i2c->dma_data;
595
596 return true;
597}
598
599static void mxs_i2c_derive_timing(struct mxs_i2c_dev *i2c, int speed) 581static void mxs_i2c_derive_timing(struct mxs_i2c_dev *i2c, int speed)
600{ 582{
601 /* The I2C block clock run at 24MHz */ 583 /* The I2C block clock run at 24MHz */
@@ -640,17 +622,6 @@ static int mxs_i2c_get_ofdata(struct mxs_i2c_dev *i2c)
640 struct device_node *node = dev->of_node; 622 struct device_node *node = dev->of_node;
641 int ret; 623 int ret;
642 624
643 /*
644 * TODO: This is a temporary solution and should be changed
645 * to use generic DMA binding later when the helpers get in.
646 */
647 ret = of_property_read_u32(node, "fsl,i2c-dma-channel",
648 &i2c->dma_channel);
649 if (ret) {
650 dev_err(dev, "Failed to get DMA channel!\n");
651 return -ENODEV;
652 }
653
654 ret = of_property_read_u32(node, "clock-frequency", &speed); 625 ret = of_property_read_u32(node, "clock-frequency", &speed);
655 if (ret) { 626 if (ret) {
656 dev_warn(dev, "No I2C speed selected, using 100kHz\n"); 627 dev_warn(dev, "No I2C speed selected, using 100kHz\n");
@@ -670,8 +641,7 @@ static int mxs_i2c_probe(struct platform_device *pdev)
670 struct pinctrl *pinctrl; 641 struct pinctrl *pinctrl;
671 struct resource *res; 642 struct resource *res;
672 resource_size_t res_size; 643 resource_size_t res_size;
673 int err, irq, dmairq; 644 int err, irq;
674 dma_cap_mask_t mask;
675 645
676 pinctrl = devm_pinctrl_get_select_default(dev); 646 pinctrl = devm_pinctrl_get_select_default(dev);
677 if (IS_ERR(pinctrl)) 647 if (IS_ERR(pinctrl))
@@ -683,9 +653,8 @@ static int mxs_i2c_probe(struct platform_device *pdev)
683 653
684 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 654 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
685 irq = platform_get_irq(pdev, 0); 655 irq = platform_get_irq(pdev, 0);
686 dmairq = platform_get_irq(pdev, 1);
687 656
688 if (!res || irq < 0 || dmairq < 0) 657 if (!res || irq < 0)
689 return -ENOENT; 658 return -ENOENT;
690 659
691 res_size = resource_size(res); 660 res_size = resource_size(res);
@@ -711,10 +680,7 @@ static int mxs_i2c_probe(struct platform_device *pdev)
711 } 680 }
712 681
713 /* Setup the DMA */ 682 /* Setup the DMA */
714 dma_cap_zero(mask); 683 i2c->dmach = dma_request_slave_channel(dev, "rx-tx");
715 dma_cap_set(DMA_SLAVE, mask);
716 i2c->dma_data.chan_irq = dmairq;
717 i2c->dmach = dma_request_channel(mask, mxs_i2c_dma_filter, i2c);
718 if (!i2c->dmach) { 684 if (!i2c->dmach) {
719 dev_err(dev, "Failed to request dma\n"); 685 dev_err(dev, "Failed to request dma\n");
720 return -ENODEV; 686 return -ENODEV;