hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/i2c/busses/i2c-mxs.c
....@@ -25,6 +25,7 @@
2525 #include <linux/of_device.h>
2626 #include <linux/dma-mapping.h>
2727 #include <linux/dmaengine.h>
28
+#include <linux/dma/mxs-dma.h>
2829
2930 #define DRIVER_NAME "mxs-i2c"
3031
....@@ -200,7 +201,8 @@
200201 dma_map_sg(i2c->dev, &i2c->sg_io[0], 1, DMA_TO_DEVICE);
201202 desc = dmaengine_prep_slave_sg(i2c->dmach, &i2c->sg_io[0], 1,
202203 DMA_MEM_TO_DEV,
203
- DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
204
+ DMA_PREP_INTERRUPT |
205
+ MXS_DMA_CTRL_WAIT4END);
204206 if (!desc) {
205207 dev_err(i2c->dev,
206208 "Failed to get DMA data write descriptor.\n");
....@@ -228,7 +230,8 @@
228230 dma_map_sg(i2c->dev, &i2c->sg_io[1], 1, DMA_FROM_DEVICE);
229231 desc = dmaengine_prep_slave_sg(i2c->dmach, &i2c->sg_io[1], 1,
230232 DMA_DEV_TO_MEM,
231
- DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
233
+ DMA_PREP_INTERRUPT |
234
+ MXS_DMA_CTRL_WAIT4END);
232235 if (!desc) {
233236 dev_err(i2c->dev,
234237 "Failed to get DMA data write descriptor.\n");
....@@ -260,7 +263,8 @@
260263 dma_map_sg(i2c->dev, i2c->sg_io, 2, DMA_TO_DEVICE);
261264 desc = dmaengine_prep_slave_sg(i2c->dmach, i2c->sg_io, 2,
262265 DMA_MEM_TO_DEV,
263
- DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
266
+ DMA_PREP_INTERRUPT |
267
+ MXS_DMA_CTRL_WAIT4END);
264268 if (!desc) {
265269 dev_err(i2c->dev,
266270 "Failed to get DMA data write descriptor.\n");
....@@ -731,7 +735,7 @@
731735 * This is compensated for by subtracting the respective constants
732736 * from the values written to the timing registers.
733737 */
734
- if (speed > 100000) {
738
+ if (speed > I2C_MAX_STANDARD_MODE_FREQ) {
735739 /* fast mode */
736740 low_count = DIV_ROUND_CLOSEST(divider * 13, (13 + 6));
737741 high_count = DIV_ROUND_CLOSEST(divider * 6, (13 + 6));
....@@ -769,7 +773,7 @@
769773 ret = of_property_read_u32(node, "clock-frequency", &speed);
770774 if (ret) {
771775 dev_warn(dev, "No I2C speed selected, using 100kHz\n");
772
- speed = 100000;
776
+ speed = I2C_MAX_STANDARD_MODE_FREQ;
773777 }
774778
775779 mxs_i2c_derive_timing(i2c, speed);
....@@ -802,7 +806,6 @@
802806 struct device *dev = &pdev->dev;
803807 struct mxs_i2c_dev *i2c;
804808 struct i2c_adapter *adap;
805
- struct resource *res;
806809 int err, irq;
807810
808811 i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL);
....@@ -814,8 +817,7 @@
814817 i2c->dev_type = device_id->driver_data;
815818 }
816819
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);
819821 if (IS_ERR(i2c->regs))
820822 return PTR_ERR(i2c->regs);
821823
....@@ -838,10 +840,10 @@
838840 }
839841
840842 /* 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");
845847 }
846848
847849 platform_set_drvdata(pdev, i2c);