.. | .. |
---|
25 | 25 | #include <linux/of_device.h> |
---|
26 | 26 | #include <linux/dma-mapping.h> |
---|
27 | 27 | #include <linux/dmaengine.h> |
---|
| 28 | +#include <linux/dma/mxs-dma.h> |
---|
28 | 29 | |
---|
29 | 30 | #define DRIVER_NAME "mxs-i2c" |
---|
30 | 31 | |
---|
.. | .. |
---|
200 | 201 | dma_map_sg(i2c->dev, &i2c->sg_io[0], 1, DMA_TO_DEVICE); |
---|
201 | 202 | desc = dmaengine_prep_slave_sg(i2c->dmach, &i2c->sg_io[0], 1, |
---|
202 | 203 | DMA_MEM_TO_DEV, |
---|
203 | | - DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
---|
| 204 | + DMA_PREP_INTERRUPT | |
---|
| 205 | + MXS_DMA_CTRL_WAIT4END); |
---|
204 | 206 | if (!desc) { |
---|
205 | 207 | dev_err(i2c->dev, |
---|
206 | 208 | "Failed to get DMA data write descriptor.\n"); |
---|
.. | .. |
---|
228 | 230 | dma_map_sg(i2c->dev, &i2c->sg_io[1], 1, DMA_FROM_DEVICE); |
---|
229 | 231 | desc = dmaengine_prep_slave_sg(i2c->dmach, &i2c->sg_io[1], 1, |
---|
230 | 232 | DMA_DEV_TO_MEM, |
---|
231 | | - DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
---|
| 233 | + DMA_PREP_INTERRUPT | |
---|
| 234 | + MXS_DMA_CTRL_WAIT4END); |
---|
232 | 235 | if (!desc) { |
---|
233 | 236 | dev_err(i2c->dev, |
---|
234 | 237 | "Failed to get DMA data write descriptor.\n"); |
---|
.. | .. |
---|
260 | 263 | dma_map_sg(i2c->dev, i2c->sg_io, 2, DMA_TO_DEVICE); |
---|
261 | 264 | desc = dmaengine_prep_slave_sg(i2c->dmach, i2c->sg_io, 2, |
---|
262 | 265 | DMA_MEM_TO_DEV, |
---|
263 | | - DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
---|
| 266 | + DMA_PREP_INTERRUPT | |
---|
| 267 | + MXS_DMA_CTRL_WAIT4END); |
---|
264 | 268 | if (!desc) { |
---|
265 | 269 | dev_err(i2c->dev, |
---|
266 | 270 | "Failed to get DMA data write descriptor.\n"); |
---|
.. | .. |
---|
731 | 735 | * This is compensated for by subtracting the respective constants |
---|
732 | 736 | * from the values written to the timing registers. |
---|
733 | 737 | */ |
---|
734 | | - if (speed > 100000) { |
---|
| 738 | + if (speed > I2C_MAX_STANDARD_MODE_FREQ) { |
---|
735 | 739 | /* fast mode */ |
---|
736 | 740 | low_count = DIV_ROUND_CLOSEST(divider * 13, (13 + 6)); |
---|
737 | 741 | high_count = DIV_ROUND_CLOSEST(divider * 6, (13 + 6)); |
---|
.. | .. |
---|
769 | 773 | ret = of_property_read_u32(node, "clock-frequency", &speed); |
---|
770 | 774 | if (ret) { |
---|
771 | 775 | dev_warn(dev, "No I2C speed selected, using 100kHz\n"); |
---|
772 | | - speed = 100000; |
---|
| 776 | + speed = I2C_MAX_STANDARD_MODE_FREQ; |
---|
773 | 777 | } |
---|
774 | 778 | |
---|
775 | 779 | mxs_i2c_derive_timing(i2c, speed); |
---|
.. | .. |
---|
802 | 806 | struct device *dev = &pdev->dev; |
---|
803 | 807 | struct mxs_i2c_dev *i2c; |
---|
804 | 808 | struct i2c_adapter *adap; |
---|
805 | | - struct resource *res; |
---|
806 | 809 | int err, irq; |
---|
807 | 810 | |
---|
808 | 811 | i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL); |
---|
.. | .. |
---|
814 | 817 | i2c->dev_type = device_id->driver_data; |
---|
815 | 818 | } |
---|
816 | 819 | |
---|
817 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
---|
818 | | - i2c->regs = devm_ioremap_resource(&pdev->dev, res); |
---|
| 820 | + i2c->regs = devm_platform_ioremap_resource(pdev, 0); |
---|
819 | 821 | if (IS_ERR(i2c->regs)) |
---|
820 | 822 | return PTR_ERR(i2c->regs); |
---|
821 | 823 | |
---|
.. | .. |
---|
838 | 840 | } |
---|
839 | 841 | |
---|
840 | 842 | /* Setup the DMA */ |
---|
841 | | - i2c->dmach = dma_request_slave_channel(dev, "rx-tx"); |
---|
842 | | - if (!i2c->dmach) { |
---|
843 | | - dev_err(dev, "Failed to request dma\n"); |
---|
844 | | - return -ENODEV; |
---|
| 843 | + i2c->dmach = dma_request_chan(dev, "rx-tx"); |
---|
| 844 | + if (IS_ERR(i2c->dmach)) { |
---|
| 845 | + return dev_err_probe(dev, PTR_ERR(i2c->dmach), |
---|
| 846 | + "Failed to request dma\n"); |
---|
845 | 847 | } |
---|
846 | 848 | |
---|
847 | 849 | platform_set_drvdata(pdev, i2c); |
---|