aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2013-02-25 22:20:22 -0500
committerShawn Guo <shawn.guo@linaro.org>2013-04-04 09:22:45 -0400
commite5aba13da0cc598a5573ea059717949fbd7536ad (patch)
tree6c47089e7225edb4024a8889b8ee6207f6eb6556 /drivers/i2c
parent26aafa77df61c4190eae80646211ee6f07c88eaf (diff)
i2c: i2c-mxs: move to use generic DMA helper
With the generic DMA device tree helper supported by mxs-dma driver, client devices only need to call dma_request_slave_channel() for requesting a DMA channel from dmaengine. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c')
-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 120f24646696..d1ba6b403b84 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
@@ -113,9 +112,7 @@ struct mxs_i2c_dev {
113 uint32_t timing1; 112 uint32_t timing1;
114 113
115 /* DMA support components */ 114 /* DMA support components */
116 int dma_channel;
117 struct dma_chan *dmach; 115 struct dma_chan *dmach;
118 struct mxs_dma_data dma_data;
119 uint32_t pio_data[2]; 116 uint32_t pio_data[2];
120 uint32_t addr_data; 117 uint32_t addr_data;
121 struct scatterlist sg_io[2]; 118 struct scatterlist sg_io[2];
@@ -518,21 +515,6 @@ static const struct i2c_algorithm mxs_i2c_algo = {
518 .functionality = mxs_i2c_func, 515 .functionality = mxs_i2c_func,
519}; 516};
520 517
521static bool mxs_i2c_dma_filter(struct dma_chan *chan, void *param)
522{
523 struct mxs_i2c_dev *i2c = param;
524
525 if (!mxs_dma_is_apbx(chan))
526 return false;
527
528 if (chan->chan_id != i2c->dma_channel)
529 return false;
530
531 chan->private = &i2c->dma_data;
532
533 return true;
534}
535
536static void mxs_i2c_derive_timing(struct mxs_i2c_dev *i2c, int speed) 518static void mxs_i2c_derive_timing(struct mxs_i2c_dev *i2c, int speed)
537{ 519{
538 /* The I2C block clock run at 24MHz */ 520 /* The I2C block clock run at 24MHz */
@@ -577,17 +559,6 @@ static int mxs_i2c_get_ofdata(struct mxs_i2c_dev *i2c)
577 struct device_node *node = dev->of_node; 559 struct device_node *node = dev->of_node;
578 int ret; 560 int ret;
579 561
580 /*
581 * TODO: This is a temporary solution and should be changed
582 * to use generic DMA binding later when the helpers get in.
583 */
584 ret = of_property_read_u32(node, "fsl,i2c-dma-channel",
585 &i2c->dma_channel);
586 if (ret) {
587 dev_err(dev, "Failed to get DMA channel!\n");
588 return -ENODEV;
589 }
590
591 ret = of_property_read_u32(node, "clock-frequency", &speed); 562 ret = of_property_read_u32(node, "clock-frequency", &speed);
592 if (ret) { 563 if (ret) {
593 dev_warn(dev, "No I2C speed selected, using 100kHz\n"); 564 dev_warn(dev, "No I2C speed selected, using 100kHz\n");
@@ -607,8 +578,7 @@ static int mxs_i2c_probe(struct platform_device *pdev)
607 struct pinctrl *pinctrl; 578 struct pinctrl *pinctrl;
608 struct resource *res; 579 struct resource *res;
609 resource_size_t res_size; 580 resource_size_t res_size;
610 int err, irq, dmairq; 581 int err, irq;
611 dma_cap_mask_t mask;
612 582
613 pinctrl = devm_pinctrl_get_select_default(dev); 583 pinctrl = devm_pinctrl_get_select_default(dev);
614 if (IS_ERR(pinctrl)) 584 if (IS_ERR(pinctrl))
@@ -620,9 +590,8 @@ static int mxs_i2c_probe(struct platform_device *pdev)
620 590
621 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 591 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
622 irq = platform_get_irq(pdev, 0); 592 irq = platform_get_irq(pdev, 0);
623 dmairq = platform_get_irq(pdev, 1);
624 593
625 if (!res || irq < 0 || dmairq < 0) 594 if (!res || irq < 0)
626 return -ENOENT; 595 return -ENOENT;
627 596
628 res_size = resource_size(res); 597 res_size = resource_size(res);
@@ -648,10 +617,7 @@ static int mxs_i2c_probe(struct platform_device *pdev)
648 } 617 }
649 618
650 /* Setup the DMA */ 619 /* Setup the DMA */
651 dma_cap_zero(mask); 620 i2c->dmach = dma_request_slave_channel(dev, "rx-tx");
652 dma_cap_set(DMA_SLAVE, mask);
653 i2c->dma_data.chan_irq = dmairq;
654 i2c->dmach = dma_request_channel(mask, mxs_i2c_dma_filter, i2c);
655 if (!i2c->dmach) { 621 if (!i2c->dmach) {
656 dev_err(dev, "Failed to request dma\n"); 622 dev_err(dev, "Failed to request dma\n");
657 return -ENODEV; 623 return -ENODEV;